@powerlines/plugin-cloudflare 0.2.19 → 0.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -16
- package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -1
- package/dist/_virtual/_rolldown/runtime.mjs +3 -0
- package/dist/components/cloudflare-builtin.cjs +225 -224
- package/dist/components/cloudflare-builtin.d.cts.map +1 -1
- package/dist/components/cloudflare-builtin.d.mts +2 -2
- package/dist/components/cloudflare-builtin.d.mts.map +1 -1
- package/dist/components/env-builtin.cjs +10 -9
- package/dist/components/env-builtin.d.cts +2 -2
- package/dist/components/env-builtin.d.cts.map +1 -1
- package/dist/components/env-builtin.d.mts.map +1 -1
- package/dist/components/index.cjs +1 -0
- package/dist/components/worker-entry.cjs +45 -44
- package/dist/components/worker-entry.d.cts +0 -1
- package/dist/components/worker-entry.d.cts.map +1 -1
- package/dist/components/worker-entry.d.mts +0 -1
- package/dist/components/worker-entry.d.mts.map +1 -1
- package/dist/index.cjs +30 -31
- package/dist/index.d.cts +0 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +0 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -4
- package/dist/index.mjs.map +1 -1
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +27 -24
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.3/node_modules/@stryke/string-format/dist/get-words.cjs +0 -38
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.3/node_modules/@stryke/string-format/dist/get-words.mjs +0 -38
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.3/node_modules/@stryke/string-format/dist/get-words.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.3/node_modules/@stryke/string-format/dist/kebab-case.cjs +0 -33
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.3/node_modules/@stryke/string-format/dist/kebab-case.mjs +0 -34
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.3/node_modules/@stryke/string-format/dist/kebab-case.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.38/node_modules/@stryke/type-checks/dist/get-object-tag.cjs +0 -15
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.38/node_modules/@stryke/type-checks/dist/get-object-tag.mjs +0 -15
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.38/node_modules/@stryke/type-checks/dist/get-object-tag.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.38/node_modules/@stryke/type-checks/dist/is-function.cjs +0 -25
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.38/node_modules/@stryke/type-checks/dist/is-function.mjs +0 -26
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.38/node_modules/@stryke/type-checks/dist/is-function.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare-builtin.d.cts","names":[],"sources":["../../src/components/cloudflare-builtin.tsx"],"
|
|
1
|
+
{"version":3,"file":"cloudflare-builtin.d.cts","names":[],"sources":["../../src/components/cloudflare-builtin.tsx"],"mappings":";;;;KAoCY,sBAAA,GAAyB,OAAA,CAAQ,gBAAA,IAC3C,IAAA,CAAK,gBAAA;;;AADP;iBAMgB,iBAAA,CAAkB,KAAA,EAAO,sBAAA,GAAsB,eAAA,CAAA,QAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
2
2
|
import { BuiltinFileProps } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
3
3
|
|
|
4
4
|
//#region src/components/cloudflare-builtin.d.ts
|
|
@@ -6,7 +6,7 @@ type CloudflareBuiltinProps = Partial<BuiltinFileProps> & Omit<BuiltinFileProps,
|
|
|
6
6
|
/**
|
|
7
7
|
* Generates the Cloudflare environment configuration module for the Powerlines project.
|
|
8
8
|
*/
|
|
9
|
-
declare function CloudflareBuiltin(props: CloudflareBuiltinProps):
|
|
9
|
+
declare function CloudflareBuiltin(props: CloudflareBuiltinProps): _alloy_js_core0.Children;
|
|
10
10
|
declare type __ΩCloudflareBuiltinProps = any[];
|
|
11
11
|
//#endregion
|
|
12
12
|
export { CloudflareBuiltin, CloudflareBuiltinProps, __ΩCloudflareBuiltinProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare-builtin.d.mts","names":[],"sources":["../../src/components/cloudflare-builtin.tsx"],"
|
|
1
|
+
{"version":3,"file":"cloudflare-builtin.d.mts","names":[],"sources":["../../src/components/cloudflare-builtin.tsx"],"mappings":";;;;KAoCY,sBAAA,GAAyB,OAAA,CAAQ,gBAAA,IAC3C,IAAA,CAAK,gBAAA;;;AADP;iBAMgB,iBAAA,CAAkB,KAAA,EAAO,sBAAA,GAAsB,eAAA,CAAA,QAAA;AAAA"}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
let
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
4
5
|
let defu = require("defu");
|
|
5
|
-
defu =
|
|
6
|
-
let
|
|
7
|
-
let
|
|
6
|
+
defu = require_runtime.__toESM(defu);
|
|
7
|
+
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
8
|
+
let _powerlines_plugin_env_components_env_builtin = require("@powerlines/plugin-env/components/env-builtin");
|
|
8
9
|
|
|
9
10
|
//#region src/components/env-builtin.tsx
|
|
10
11
|
/**
|
|
11
12
|
* Generates the Cloudflare environment configuration module for the Powerlines project.
|
|
12
13
|
*/
|
|
13
14
|
function CloudflareEnvBuiltin(props) {
|
|
14
|
-
const [{ children, imports }, rest] = (0,
|
|
15
|
-
return (0,
|
|
15
|
+
const [{ children, imports }, rest] = (0, _alloy_js_core.splitProps)(props, ["children", "imports"]);
|
|
16
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_env_components_env_builtin.EnvBuiltin, (0, _alloy_js_core_jsx_runtime.mergeProps)({ defaultConfig: _alloy_js_core.code`env` }, rest, {
|
|
16
17
|
get imports() {
|
|
17
18
|
return (0, defu.default)({ "cloudflare:workers": ["env"] }, imports ?? {});
|
|
18
19
|
},
|
|
19
20
|
get children() {
|
|
20
|
-
return [(0,
|
|
21
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
21
22
|
get when() {
|
|
22
23
|
return Boolean(children);
|
|
23
24
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
2
2
|
import { EnvBuiltinProps } from "@powerlines/plugin-env/components/env-builtin";
|
|
3
3
|
|
|
4
4
|
//#region src/components/env-builtin.d.ts
|
|
@@ -6,7 +6,7 @@ type CloudflareEnvBuiltinProps = Omit<EnvBuiltinProps, "defaultConfig">;
|
|
|
6
6
|
/**
|
|
7
7
|
* Generates the Cloudflare environment configuration module for the Powerlines project.
|
|
8
8
|
*/
|
|
9
|
-
declare function CloudflareEnvBuiltin(props: CloudflareEnvBuiltinProps):
|
|
9
|
+
declare function CloudflareEnvBuiltin(props: CloudflareEnvBuiltinProps): _alloy_js_core0.Children;
|
|
10
10
|
declare type __ΩCloudflareEnvBuiltinProps = any[];
|
|
11
11
|
//#endregion
|
|
12
12
|
export { CloudflareEnvBuiltin, CloudflareEnvBuiltinProps, __ΩCloudflareEnvBuiltinProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-builtin.d.cts","names":[],"sources":["../../src/components/env-builtin.tsx"],"
|
|
1
|
+
{"version":3,"file":"env-builtin.d.cts","names":[],"sources":["../../src/components/env-builtin.tsx"],"mappings":";;;;KA0BY,yBAAA,GAA4B,IAAA,CAAK,eAAA;;;AAA7C;iBAKgB,oBAAA,CAAqB,KAAA,EAAO,yBAAA,GAAyB,eAAA,CAAA,QAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-builtin.d.mts","names":[],"sources":["../../src/components/env-builtin.tsx"],"
|
|
1
|
+
{"version":3,"file":"env-builtin.d.mts","names":[],"sources":["../../src/components/env-builtin.tsx"],"mappings":";;;;KA0BY,yBAAA,GAA4B,IAAA,CAAK,eAAA;;;AAA7C;iBAKgB,oBAAA,CAAqB,KAAA,EAAO,yBAAA,GAAyB,eAAA,CAAA,QAAA;AAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
1
2
|
const require_components_cloudflare_builtin = require('./cloudflare-builtin.cjs');
|
|
2
3
|
const require_components_env_builtin = require('./env-builtin.cjs');
|
|
3
4
|
const require_components_worker_entry = require('./worker-entry.cjs');
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
let
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
4
5
|
let defu = require("defu");
|
|
5
|
-
defu =
|
|
6
|
-
let
|
|
7
|
-
let
|
|
8
|
-
let
|
|
9
|
-
let
|
|
10
|
-
let
|
|
11
|
-
let
|
|
6
|
+
defu = require_runtime.__toESM(defu);
|
|
7
|
+
let _powerlines_plugin_alloy_core_components = require("@powerlines/plugin-alloy/core/components");
|
|
8
|
+
let _powerlines_plugin_alloy_core_contexts = require("@powerlines/plugin-alloy/core/contexts");
|
|
9
|
+
let _powerlines_plugin_alloy_typescript_components_entry_file = require("@powerlines/plugin-alloy/typescript/components/entry-file");
|
|
10
|
+
let _stryke_hash = require("@stryke/hash");
|
|
11
|
+
let _stryke_path_find = require("@stryke/path/find");
|
|
12
|
+
let _stryke_path_replace = require("@stryke/path/replace");
|
|
12
13
|
|
|
13
14
|
//#region src/components/worker-entry.tsx
|
|
14
15
|
/**
|
|
15
16
|
* Generates a [Cloudflare Worker](https://developers.cloudflare.com/workers/runtime-apis/handlers/) entry module for the Powerlines project, providing a runtime context and utilities for integrating with Cloudflare services. This module defines a `CloudflareContext` interface, an `AsyncLocalStorage` instance for managing the context, and helper functions for retrieving and running code within the context. The generated module is designed to be used as a built-in file within the Powerlines environment, allowing developers to easily access Cloudflare-specific functionality in their applications.
|
|
16
17
|
*/
|
|
17
18
|
function WorkerEntry(props) {
|
|
18
|
-
const [{ worker, children, imports, builtinImports }, rest] = (0,
|
|
19
|
+
const [{ worker, children, imports, builtinImports }, rest] = (0, _alloy_js_core.splitProps)(props, [
|
|
19
20
|
"worker",
|
|
20
21
|
"children",
|
|
21
22
|
"imports",
|
|
22
23
|
"builtinImports"
|
|
23
24
|
]);
|
|
24
|
-
const context = (0,
|
|
25
|
-
const entryPath = (0,
|
|
26
|
-
return (0,
|
|
27
|
-
return `worker-${(0,
|
|
25
|
+
const context = (0, _powerlines_plugin_alloy_core_contexts.usePowerlines)();
|
|
26
|
+
const entryPath = (0, _alloy_js_core.computed)(() => `./${(0, _stryke_path_replace.replaceExtension)((0, _stryke_path_find.relativePath)(context.entryPath, worker.entry.input?.file || worker.entry.file))}`);
|
|
27
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_entry_file.EntryFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({ get path() {
|
|
28
|
+
return `worker-${(0, _stryke_hash.murmurhash)(worker.entry, { maxLength: 8 })}-entry.ts`;
|
|
28
29
|
} }, rest, {
|
|
29
30
|
get imports() {
|
|
30
31
|
return (0, defu.default)({
|
|
@@ -95,99 +96,99 @@ function WorkerEntry(props) {
|
|
|
95
96
|
},
|
|
96
97
|
get children() {
|
|
97
98
|
return [
|
|
98
|
-
|
|
99
|
-
(0,
|
|
100
|
-
(0,
|
|
99
|
+
_alloy_js_core.code`export default { `,
|
|
100
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
101
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
101
102
|
get when() {
|
|
102
103
|
return worker.fetch;
|
|
103
104
|
},
|
|
104
|
-
children:
|
|
105
|
+
children: _alloy_js_core.code` async fetch(request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: CloudflareBindings, ctx: ExecutionContext): Promise<Response> {
|
|
105
106
|
return await withFetchContext({ request, env, ctx }, async (context) => {
|
|
106
107
|
return worker.fetch(context.request, context.env, context.ctx);
|
|
107
108
|
});
|
|
108
109
|
}, `
|
|
109
110
|
}),
|
|
110
|
-
(0,
|
|
111
|
-
(0,
|
|
111
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
112
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
112
113
|
get when() {
|
|
113
114
|
return worker.tail;
|
|
114
115
|
},
|
|
115
|
-
children:
|
|
116
|
+
children: _alloy_js_core.code` async tail(events: TraceItem[], env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {
|
|
116
117
|
return withTailContext({ events, env, ctx }, async (context) => {
|
|
117
118
|
return worker.tail(context.events, context.env, context.ctx);
|
|
118
119
|
});
|
|
119
120
|
}, `
|
|
120
121
|
}),
|
|
121
|
-
(0,
|
|
122
|
-
(0,
|
|
122
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
123
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
123
124
|
get when() {
|
|
124
125
|
return worker.trace;
|
|
125
126
|
},
|
|
126
|
-
children:
|
|
127
|
+
children: _alloy_js_core.code` async trace(traces: TraceItem[], env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {
|
|
127
128
|
return withTraceContext({ traces, env, ctx }, async (context) => {
|
|
128
129
|
return worker.trace(context.traces, context.env, context.ctx);
|
|
129
130
|
});
|
|
130
131
|
}, `
|
|
131
132
|
}),
|
|
132
|
-
(0,
|
|
133
|
-
(0,
|
|
133
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
134
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
134
135
|
get when() {
|
|
135
136
|
return worker.tailStream;
|
|
136
137
|
},
|
|
137
|
-
children:
|
|
138
|
+
children: _alloy_js_core.code` async tailStream(event: TailStream.TailEvent<TailStream.Onset>, env: CloudflareBindings, ctx: ExecutionContext): Promise<ReadableStream> {
|
|
138
139
|
return await withTailStreamContext({ event, env, ctx }, async (context) => {
|
|
139
140
|
return await worker.tailStream(context.event, context.env, context.ctx);
|
|
140
141
|
});
|
|
141
142
|
}, `
|
|
142
143
|
}),
|
|
143
|
-
(0,
|
|
144
|
-
(0,
|
|
144
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
145
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
145
146
|
get when() {
|
|
146
147
|
return worker.scheduled;
|
|
147
148
|
},
|
|
148
|
-
children:
|
|
149
|
+
children: _alloy_js_core.code` async scheduled(controller: ScheduledController, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {
|
|
149
150
|
return withScheduledContext({ controller, env, ctx }, async (context) => {
|
|
150
151
|
return worker.scheduled(context.controller, context.env, context.ctx);
|
|
151
152
|
});
|
|
152
153
|
}, `
|
|
153
154
|
}),
|
|
154
|
-
(0,
|
|
155
|
-
(0,
|
|
155
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
156
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
156
157
|
get when() {
|
|
157
158
|
return worker.test;
|
|
158
159
|
},
|
|
159
|
-
children:
|
|
160
|
+
children: _alloy_js_core.code` async test(controller: TestController, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {
|
|
160
161
|
return withTestContext({ controller, env, ctx }, async (context) => {
|
|
161
162
|
return worker.test(context.controller, context.env, context.ctx);
|
|
162
163
|
});
|
|
163
164
|
}, `
|
|
164
165
|
}),
|
|
165
|
-
(0,
|
|
166
|
-
(0,
|
|
166
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
167
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
167
168
|
get when() {
|
|
168
169
|
return worker.email;
|
|
169
170
|
},
|
|
170
|
-
children:
|
|
171
|
+
children: _alloy_js_core.code` async email(message: ForwardableEmailMessage, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {
|
|
171
172
|
return withEmailContext({ message, env, ctx }, async (context) => {
|
|
172
173
|
return worker.email(context.message, context.env, context.ctx);
|
|
173
174
|
});
|
|
174
175
|
}, `
|
|
175
176
|
}),
|
|
176
|
-
(0,
|
|
177
|
-
(0,
|
|
177
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
178
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
178
179
|
get when() {
|
|
179
180
|
return worker.queue;
|
|
180
181
|
},
|
|
181
|
-
children:
|
|
182
|
+
children: _alloy_js_core.code` async queue(batch: MessageBatch, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {
|
|
182
183
|
return withQueueContext({ batch, env, ctx }, async (context) => {
|
|
183
184
|
return worker.queue(context.batch, context.env, context.ctx);
|
|
184
185
|
});
|
|
185
186
|
}, `
|
|
186
187
|
}),
|
|
187
|
-
(0,
|
|
188
|
-
|
|
189
|
-
(0,
|
|
190
|
-
(0,
|
|
188
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
189
|
+
_alloy_js_core.code` } satisfies ExportedHandler<CloudflareBindings>; `,
|
|
190
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
|
|
191
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
191
192
|
get when() {
|
|
192
193
|
return Boolean(children);
|
|
193
194
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-entry.d.cts","names":[],"sources":["../../src/components/worker-entry.tsx"],"
|
|
1
|
+
{"version":3,"file":"worker-entry.d.cts","names":[],"sources":["../../src/components/worker-entry.tsx"],"mappings":";;;;;KA+BY,gBAAA,GAAmB,OAAA,CAAQ,cAAA,IACrC,IAAA,CAAK,cAAA;EACH,MAAA,EAAQ,2BAAA;AAAA;;AAFZ;;iBAQgB,WAAA,CAAY,KAAA,EAAO,gBAAA,GAAgB,eAAA,CAAA,QAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-entry.d.mts","names":[],"sources":["../../src/components/worker-entry.tsx"],"
|
|
1
|
+
{"version":3,"file":"worker-entry.d.mts","names":[],"sources":["../../src/components/worker-entry.tsx"],"mappings":";;;;;KA+BY,gBAAA,GAAmB,OAAA,CAAQ,cAAA,IACrC,IAAA,CAAK,cAAA;EACH,MAAA,EAAQ,2BAAA;AAAA;;AAFZ;;iBAQgB,WAAA,CAAY,KAAA,EAAO,gBAAA,GAAgB,eAAA,CAAA,QAAA;AAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
Object.
|
|
2
|
-
const
|
|
3
|
-
const require_kebab_case = require('./node_modules/.pnpm/@stryke_string-format@0.17.3/node_modules/@stryke/string-format/dist/kebab-case.cjs');
|
|
4
|
-
const require_is_function = require('./node_modules/.pnpm/@stryke_type-checks@0.5.38/node_modules/@stryke/type-checks/dist/is-function.cjs');
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
5
3
|
const require_components_cloudflare_builtin = require('./components/cloudflare-builtin.cjs');
|
|
6
4
|
const require_components_env_builtin = require('./components/env-builtin.cjs');
|
|
7
5
|
const require_components_worker_entry = require('./components/worker-entry.cjs');
|
|
8
6
|
require('./components/index.cjs');
|
|
9
|
-
let
|
|
10
|
-
let
|
|
11
|
-
let
|
|
12
|
-
let
|
|
13
|
-
let
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
let
|
|
7
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
8
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
9
|
+
let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
|
|
10
|
+
let _powerlines_plugin_env_helpers = require("@powerlines/plugin-env/helpers");
|
|
11
|
+
let _powerlines_plugin_esbuild_helpers_resolve = require("@powerlines/plugin-esbuild/helpers/resolve");
|
|
12
|
+
let _pulumi_cloudflare = require("@pulumi/cloudflare");
|
|
13
|
+
_pulumi_cloudflare = require_runtime.__toESM(_pulumi_cloudflare);
|
|
14
|
+
let _stryke_path = require("@stryke/path");
|
|
15
|
+
let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
|
|
16
|
+
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
17
17
|
let defu = require("defu");
|
|
18
|
-
defu =
|
|
18
|
+
defu = require_runtime.__toESM(defu);
|
|
19
19
|
|
|
20
20
|
//#region src/index.tsx
|
|
21
21
|
/**
|
|
@@ -31,8 +31,8 @@ function plugin(options = {}) {
|
|
|
31
31
|
this.devDependencies["@cloudflare/workers-types"] = "^4.20240616.0";
|
|
32
32
|
},
|
|
33
33
|
async prepare() {
|
|
34
|
-
const result = await (0,
|
|
35
|
-
return (0,
|
|
34
|
+
const result = await (0, _powerlines_plugin_env_helpers.readEnvTypeReflection)(this, "env");
|
|
35
|
+
return (0, _powerlines_plugin_alloy_render.render)(this, [(0, _alloy_js_core_jsx_runtime.createComponent)(require_components_cloudflare_builtin.CloudflareBuiltin, {}), (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_env_builtin.CloudflareEnvBuiltin, { reflection: result })]);
|
|
36
36
|
},
|
|
37
37
|
build: {
|
|
38
38
|
order: "pre",
|
|
@@ -40,25 +40,25 @@ function plugin(options = {}) {
|
|
|
40
40
|
const _self$ = this;
|
|
41
41
|
this.workers = await Promise.all(this.entry.map(async (entry) => {
|
|
42
42
|
if (!entry.input) throw new Error(`Cloudflare Worker entry "${entry.name}" is missing an input file.`);
|
|
43
|
-
const workerModule = await (0,
|
|
43
|
+
const workerModule = await (0, _powerlines_plugin_esbuild_helpers_resolve.resolveModule)(this, entry.input);
|
|
44
44
|
if (!workerModule?.default) throw new Error(`Cloudflare Worker entry "${entry.name}" does not export a default handler. The Powerlines Cloudflare plugin expects each Worker entry module to export a default object matching the \`ExportedHandler\` interface from "@cloudflare/workers-types".`);
|
|
45
45
|
return {
|
|
46
46
|
entry,
|
|
47
|
-
fetch:
|
|
48
|
-
tail:
|
|
49
|
-
trace:
|
|
50
|
-
tailStream:
|
|
51
|
-
scheduled:
|
|
52
|
-
test:
|
|
53
|
-
email:
|
|
54
|
-
queue:
|
|
47
|
+
fetch: (0, _stryke_type_checks_is_function.isFunction)(workerModule.default.fetch),
|
|
48
|
+
tail: (0, _stryke_type_checks_is_function.isFunction)(workerModule.default.tail),
|
|
49
|
+
trace: (0, _stryke_type_checks_is_function.isFunction)(workerModule.default.trace),
|
|
50
|
+
tailStream: (0, _stryke_type_checks_is_function.isFunction)(workerModule.default.tailStream),
|
|
51
|
+
scheduled: (0, _stryke_type_checks_is_function.isFunction)(workerModule.default.scheduled),
|
|
52
|
+
test: (0, _stryke_type_checks_is_function.isFunction)(workerModule.default.test),
|
|
53
|
+
email: (0, _stryke_type_checks_is_function.isFunction)(workerModule.default.email),
|
|
54
|
+
queue: (0, _stryke_type_checks_is_function.isFunction)(workerModule.default.queue)
|
|
55
55
|
};
|
|
56
56
|
}));
|
|
57
|
-
return (0,
|
|
57
|
+
return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
58
58
|
get each() {
|
|
59
59
|
return _self$.workers;
|
|
60
60
|
},
|
|
61
|
-
children: (worker) => (0,
|
|
61
|
+
children: (worker) => (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_worker_entry.WorkerEntry, { worker })
|
|
62
62
|
}));
|
|
63
63
|
}
|
|
64
64
|
},
|
|
@@ -70,19 +70,18 @@ function plugin(options = {}) {
|
|
|
70
70
|
else throw new Error("Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.");
|
|
71
71
|
}
|
|
72
72
|
await this.pulumi.setConfig("cloudflare:apiToken", { value: apiToken });
|
|
73
|
-
return { worker: new
|
|
73
|
+
return { worker: new _pulumi_cloudflare.WorkersScript(`${(0, _stryke_string_format_kebab_case.kebabCase)(this.config.name)}-worker`, {
|
|
74
74
|
accountId: this.config.cloudflare.accountId,
|
|
75
|
-
scriptName: this.config.cloudflare.scriptName ||
|
|
76
|
-
contentFile: (0,
|
|
75
|
+
scriptName: this.config.cloudflare.scriptName || (0, _stryke_string_format_kebab_case.kebabCase)(this.config.name),
|
|
76
|
+
contentFile: (0, _stryke_path.joinPaths)(this.config.output.outputPath, "index.js")
|
|
77
77
|
}) };
|
|
78
78
|
}
|
|
79
79
|
}];
|
|
80
80
|
}
|
|
81
|
-
var src_default = plugin;
|
|
82
81
|
|
|
83
82
|
//#endregion
|
|
84
83
|
exports.CloudflareBuiltin = require_components_cloudflare_builtin.CloudflareBuiltin;
|
|
85
84
|
exports.CloudflareEnvBuiltin = require_components_env_builtin.CloudflareEnvBuiltin;
|
|
86
85
|
exports.WorkerEntry = require_components_worker_entry.WorkerEntry;
|
|
87
|
-
exports.default =
|
|
86
|
+
exports.default = plugin;
|
|
88
87
|
exports.plugin = plugin;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { CloudflareBuiltin, CloudflareBuiltinProps, __ΩCloudflareBuiltinProps } from "./components/cloudflare-builtin.cjs";
|
|
2
2
|
import { CloudflareEnvBuiltin, CloudflareEnvBuiltinProps, __ΩCloudflareEnvBuiltinProps } from "./components/env-builtin.cjs";
|
|
3
3
|
import { CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule } from "./types/plugin.cjs";
|
|
4
|
-
import "./types/index.cjs";
|
|
5
4
|
import { WorkerEntry, WorkerEntryProps, __ΩWorkerEntryProps } from "./components/worker-entry.cjs";
|
|
6
|
-
import "./components/index.cjs";
|
|
7
5
|
import { Plugin } from "powerlines";
|
|
8
6
|
|
|
9
7
|
//#region src/index.d.ts
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;;;YAyCY,MAAA;IACR,UAAA,GAAa,uBAAA;EAAA;AAAA;AAJY;;;AAAA,iBAWb,MAAA,kBACG,uBAAA,GAA0B,uBAAA,CAAA,CAC3C,OAAA,GAAS,uBAAA,GAqGJ,MAAA,CAAO,QAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { CloudflareBuiltin, CloudflareBuiltinProps, __ΩCloudflareBuiltinProps } from "./components/cloudflare-builtin.mjs";
|
|
2
2
|
import { CloudflareEnvBuiltin, CloudflareEnvBuiltinProps, __ΩCloudflareEnvBuiltinProps } from "./components/env-builtin.mjs";
|
|
3
3
|
import { CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule } from "./types/plugin.mjs";
|
|
4
|
-
import "./types/index.mjs";
|
|
5
4
|
import { WorkerEntry, WorkerEntryProps, __ΩWorkerEntryProps } from "./components/worker-entry.mjs";
|
|
6
|
-
import "./components/index.mjs";
|
|
7
5
|
import { Plugin } from "powerlines";
|
|
8
6
|
|
|
9
7
|
//#region src/index.d.ts
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;;;YAyCY,MAAA;IACR,UAAA,GAAa,uBAAA;EAAA;AAAA;AAJY;;;AAAA,iBAWb,MAAA,kBACG,uBAAA,GAA0B,uBAAA,CAAA,CAC3C,OAAA,GAAS,uBAAA,GAqGJ,MAAA,CAAO,QAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { kebabCase } from "./node_modules/.pnpm/@stryke_string-format@0.17.3/node_modules/@stryke/string-format/dist/kebab-case.mjs";
|
|
2
|
-
import { isFunction } from "./node_modules/.pnpm/@stryke_type-checks@0.5.38/node_modules/@stryke/type-checks/dist/is-function.mjs";
|
|
3
1
|
import { CloudflareBuiltin } from "./components/cloudflare-builtin.mjs";
|
|
4
2
|
import { CloudflareEnvBuiltin } from "./components/env-builtin.mjs";
|
|
5
3
|
import { WorkerEntry } from "./components/worker-entry.mjs";
|
|
@@ -11,6 +9,8 @@ import { readEnvTypeReflection } from "@powerlines/plugin-env/helpers";
|
|
|
11
9
|
import { resolveModule } from "@powerlines/plugin-esbuild/helpers/resolve";
|
|
12
10
|
import * as pulumiCloudflare from "@pulumi/cloudflare";
|
|
13
11
|
import { joinPaths } from "@stryke/path";
|
|
12
|
+
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
13
|
+
import { isFunction } from "@stryke/type-checks/is-function";
|
|
14
14
|
import defu from "defu";
|
|
15
15
|
|
|
16
16
|
//#region src/index.tsx
|
|
@@ -74,8 +74,7 @@ function plugin(options = {}) {
|
|
|
74
74
|
}
|
|
75
75
|
}];
|
|
76
76
|
}
|
|
77
|
-
var src_default = plugin;
|
|
78
77
|
|
|
79
78
|
//#endregion
|
|
80
|
-
export { CloudflareBuiltin, CloudflareEnvBuiltin, WorkerEntry,
|
|
79
|
+
export { CloudflareBuiltin, CloudflareEnvBuiltin, WorkerEntry, plugin as default, plugin };
|
|
81
80
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["For","render","readEnvTypeReflection","resolveModule","pulumiCloudflare","joinPaths","kebabCase","isFunction","defu","CloudflareEnvBuiltin","CloudflareBuiltin","WorkerEntry","plugin","options","name","config","cloudflare","configResolved","devDependencies","prepare","result","_$createComponent","reflection","build","order","handler","_self$","workers","Promise","all","entry","map","input","Error","workerModule","default","fetch","tail","trace","tailStream","scheduled","test","email","queue","each","children","worker","deployPulumi","apiToken","process","env","CLOUDFLARE_API_TOKEN","warn","pulumi","setConfig","value","WorkersScript","accountId","scriptName","contentFile","output","outputPath"],"sources":["../src/index.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { For } from \"@alloy-js/core\";\nimport { ExportedHandler } from \"@cloudflare/workers-types\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport { readEnvTypeReflection } from \"@powerlines/plugin-env/helpers\";\nimport { resolveModule } from \"@powerlines/plugin-esbuild/helpers/resolve\";\nimport * as pulumiCloudflare from \"@pulumi/cloudflare\";\nimport { joinPaths } from \"@stryke/path\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { CloudflareEnvBuiltin } from \"./components\";\nimport { CloudflareBuiltin } from \"./components/cloudflare-builtin\";\nimport { WorkerEntry } from \"./components/worker-entry\";\nimport {\n CloudflarePluginContext,\n CloudflarePluginOptions\n} from \"./types/plugin\";\n\nexport * from \"./components\";\nexport type * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n cloudflare?: CloudflarePluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport function plugin<\n TContext extends CloudflarePluginContext = CloudflarePluginContext\n>(options: CloudflarePluginOptions = {}) {\n return [\n {\n name: \"cloudflare\",\n config() {\n return {\n cloudflare: defu(options, {})\n };\n },\n configResolved() {\n this.devDependencies[\"@cloudflare/workers-types\"] = \"^4.20240616.0\";\n },\n async prepare() {\n const result = await readEnvTypeReflection(this, \"env\");\n\n return render(\n this,\n <>\n <CloudflareBuiltin />\n <CloudflareEnvBuiltin reflection={result} />\n </>\n );\n },\n build: {\n order: \"pre\",\n async handler() {\n this.workers = await Promise.all(\n this.entry.map(async entry => {\n if (!entry.input) {\n throw new Error(\n `Cloudflare Worker entry \"${entry.name}\" is missing an input file.`\n );\n }\n\n const workerModule = await resolveModule<{\n default: ExportedHandler;\n }>(this, entry.input);\n if (!workerModule?.default) {\n throw new Error(\n `Cloudflare Worker entry \"${\n entry.name\n }\" does not export a default handler. The Powerlines Cloudflare plugin expects each Worker entry module to export a default object matching the \\`ExportedHandler\\` interface from \"@cloudflare/workers-types\".`\n );\n }\n\n return {\n entry,\n fetch: isFunction(workerModule.default.fetch),\n tail: isFunction(workerModule.default.tail),\n trace: isFunction(workerModule.default.trace),\n tailStream: isFunction(workerModule.default.tailStream),\n scheduled: isFunction(workerModule.default.scheduled),\n test: isFunction(workerModule.default.test),\n email: isFunction(workerModule.default.email),\n queue: isFunction(workerModule.default.queue)\n };\n })\n );\n\n return render(\n this,\n <For each={this.workers}>\n {worker => <WorkerEntry worker={worker} />}\n </For>\n );\n }\n },\n async deployPulumi() {\n let apiToken = process.env.CLOUDFLARE_API_TOKEN;\n if (!apiToken) {\n apiToken = this.config.cloudflare.apiToken;\n if (apiToken) {\n this.warn(\n \"If possible, please use the `CLOUDFLARE_API_TOKEN` environment variable instead of using the `apiToken` option directly. The `apiToken` option will work; however, this is a less secure method of configuration.\"\n );\n } else {\n throw new Error(\n \"Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.\"\n );\n }\n }\n\n await this.pulumi.setConfig(\"cloudflare:apiToken\", {\n value: apiToken\n });\n\n const worker = new pulumiCloudflare.WorkersScript(\n `${kebabCase(this.config.name)}-worker`,\n {\n accountId: this.config.cloudflare.accountId,\n scriptName:\n this.config.cloudflare.scriptName || kebabCase(this.config.name),\n contentFile: joinPaths(this.config.output.outputPath, \"index.js\")\n }\n );\n\n return {\n worker\n };\n }\n }\n ] as Plugin<TContext>[];\n}\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiDA,SAAgBY,OAEdC,UAAmC,EAAE,EAAE;AACvC,QAAO,CACL;EACEC,MAAM;EACNC,SAAS;AACP,UAAO,EACLC,YAAYR,KAAKK,SAAS,EAAE,CAAA,EAC7B;;EAEHI,iBAAiB;AACf,QAAKC,gBAAgB,+BAA+B;;EAEtD,MAAMC,UAAU;GACd,MAAMC,SAAS,MAAMlB,sBAAsB,MAAM,MAAM;AAEvD,UAAOD,OACL,MAAI,CAAAoB,gBAEDX,mBAAiB,EAAA,CAAA,EAAAW,gBACjBZ,sBAAoB,EAACa,YAAYF,QAAM,CAAA,CAE5C,CAAC;;EAEHG,OAAO;GACLC,OAAO;GACP,MAAMC,UAAU;IAAA,MAAAC,SAAA;AACd,SAAKC,UAAU,MAAMC,QAAQC,IAC3B,KAAKC,MAAMC,IAAI,OAAMD,UAAS;AAC5B,SAAI,CAACA,MAAME,MACT,OAAM,IAAIC,MACR,4BAA4BH,MAAMhB,KAAI,6BACvC;KAGH,MAAMoB,eAAe,MAAM/B,cAExB,MAAM2B,MAAME,MAAM;AACrB,SAAI,CAACE,cAAcC,QACjB,OAAM,IAAIF,MACR,4BACEH,MAAMhB,KAAI,gNAEb;AAGH,YAAO;MACLgB;MACAM,OAAO7B,WAAW2B,aAAaC,QAAQC,MAAM;MAC7CC,MAAM9B,WAAW2B,aAAaC,QAAQE,KAAK;MAC3CC,OAAO/B,WAAW2B,aAAaC,QAAQG,MAAM;MAC7CC,YAAYhC,WAAW2B,aAAaC,QAAQI,WAAW;MACvDC,WAAWjC,WAAW2B,aAAaC,QAAQK,UAAU;MACrDC,MAAMlC,WAAW2B,aAAaC,QAAQM,KAAK;MAC3CC,OAAOnC,WAAW2B,aAAaC,QAAQO,MAAM;MAC7CC,OAAOpC,WAAW2B,aAAaC,QAAQQ,MAAK;MAC7C;MAEL,CAAC;AAED,WAAO1C,OACL,MAAIoB,gBACHrB,KAAG;KAAA,IAAC4C,OAAI;AAAA,aAAElB,OAAKC;;KAAOkB,WACpBC,WAAMzB,gBAAKV,aAAW,EAASmC,QAAM,CAAA;KAAI,CAE9C,CAAC;;GAEJ;EACD,MAAMC,eAAe;GACnB,IAAIC,WAAWC,QAAQC,IAAIC;AAC3B,OAAI,CAACH,UAAU;AACbA,eAAW,KAAKjC,OAAOC,WAAWgC;AAClC,QAAIA,SACF,MAAKI,KACH,oNACD;QAED,OAAM,IAAInB,MACR,4GACD;;AAIL,SAAM,KAAKoB,OAAOC,UAAU,uBAAuB,EACjDC,OAAOP,UACR,CAAC;AAYF,UAAO,EACLF,QAXa,IAAI1C,iBAAiBoD,cAClC,GAAGlD,UAAU,KAAKS,OAAOD,KAAK,CAAA,UAC9B;IACE2C,WAAW,KAAK1C,OAAOC,WAAWyC;IAClCC,YACE,KAAK3C,OAAOC,WAAW0C,cAAcpD,UAAU,KAAKS,OAAOD,KAAK;IAClE6C,aAAatD,UAAU,KAAKU,OAAO6C,OAAOC,YAAY,WAAU;IAEpE,CAAC,EAIA;;EAEJ,CACF
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["For","render","readEnvTypeReflection","resolveModule","pulumiCloudflare","joinPaths","kebabCase","isFunction","defu","CloudflareEnvBuiltin","CloudflareBuiltin","WorkerEntry","plugin","options","name","config","cloudflare","configResolved","devDependencies","prepare","result","_$createComponent","reflection","build","order","handler","_self$","workers","Promise","all","entry","map","input","Error","workerModule","default","fetch","tail","trace","tailStream","scheduled","test","email","queue","each","children","worker","deployPulumi","apiToken","process","env","CLOUDFLARE_API_TOKEN","warn","pulumi","setConfig","value","WorkersScript","accountId","scriptName","contentFile","output","outputPath"],"sources":["../src/index.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { For } from \"@alloy-js/core\";\nimport { ExportedHandler } from \"@cloudflare/workers-types\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport { readEnvTypeReflection } from \"@powerlines/plugin-env/helpers\";\nimport { resolveModule } from \"@powerlines/plugin-esbuild/helpers/resolve\";\nimport * as pulumiCloudflare from \"@pulumi/cloudflare\";\nimport { joinPaths } from \"@stryke/path\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { CloudflareEnvBuiltin } from \"./components\";\nimport { CloudflareBuiltin } from \"./components/cloudflare-builtin\";\nimport { WorkerEntry } from \"./components/worker-entry\";\nimport {\n CloudflarePluginContext,\n CloudflarePluginOptions\n} from \"./types/plugin\";\n\nexport * from \"./components\";\nexport type * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n cloudflare?: CloudflarePluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport function plugin<\n TContext extends CloudflarePluginContext = CloudflarePluginContext\n>(options: CloudflarePluginOptions = {}) {\n return [\n {\n name: \"cloudflare\",\n config() {\n return {\n cloudflare: defu(options, {})\n };\n },\n configResolved() {\n this.devDependencies[\"@cloudflare/workers-types\"] = \"^4.20240616.0\";\n },\n async prepare() {\n const result = await readEnvTypeReflection(this, \"env\");\n\n return render(\n this,\n <>\n <CloudflareBuiltin />\n <CloudflareEnvBuiltin reflection={result} />\n </>\n );\n },\n build: {\n order: \"pre\",\n async handler() {\n this.workers = await Promise.all(\n this.entry.map(async entry => {\n if (!entry.input) {\n throw new Error(\n `Cloudflare Worker entry \"${entry.name}\" is missing an input file.`\n );\n }\n\n const workerModule = await resolveModule<{\n default: ExportedHandler;\n }>(this, entry.input);\n if (!workerModule?.default) {\n throw new Error(\n `Cloudflare Worker entry \"${\n entry.name\n }\" does not export a default handler. The Powerlines Cloudflare plugin expects each Worker entry module to export a default object matching the \\`ExportedHandler\\` interface from \"@cloudflare/workers-types\".`\n );\n }\n\n return {\n entry,\n fetch: isFunction(workerModule.default.fetch),\n tail: isFunction(workerModule.default.tail),\n trace: isFunction(workerModule.default.trace),\n tailStream: isFunction(workerModule.default.tailStream),\n scheduled: isFunction(workerModule.default.scheduled),\n test: isFunction(workerModule.default.test),\n email: isFunction(workerModule.default.email),\n queue: isFunction(workerModule.default.queue)\n };\n })\n );\n\n return render(\n this,\n <For each={this.workers}>\n {worker => <WorkerEntry worker={worker} />}\n </For>\n );\n }\n },\n async deployPulumi() {\n let apiToken = process.env.CLOUDFLARE_API_TOKEN;\n if (!apiToken) {\n apiToken = this.config.cloudflare.apiToken;\n if (apiToken) {\n this.warn(\n \"If possible, please use the `CLOUDFLARE_API_TOKEN` environment variable instead of using the `apiToken` option directly. The `apiToken` option will work; however, this is a less secure method of configuration.\"\n );\n } else {\n throw new Error(\n \"Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.\"\n );\n }\n }\n\n await this.pulumi.setConfig(\"cloudflare:apiToken\", {\n value: apiToken\n });\n\n const worker = new pulumiCloudflare.WorkersScript(\n `${kebabCase(this.config.name)}-worker`,\n {\n accountId: this.config.cloudflare.accountId,\n scriptName:\n this.config.cloudflare.scriptName || kebabCase(this.config.name),\n contentFile: joinPaths(this.config.output.outputPath, \"index.js\")\n }\n );\n\n return {\n worker\n };\n }\n }\n ] as Plugin<TContext>[];\n}\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiDA,SAAgBY,OAEdC,UAAmC,EAAE,EAAE;AACvC,QAAO,CACL;EACEC,MAAM;EACNC,SAAS;AACP,UAAO,EACLC,YAAYR,KAAKK,SAAS,EAAE,CAAA,EAC7B;;EAEHI,iBAAiB;AACf,QAAKC,gBAAgB,+BAA+B;;EAEtD,MAAMC,UAAU;GACd,MAAMC,SAAS,MAAMlB,sBAAsB,MAAM,MAAM;AAEvD,UAAOD,OACL,MAAI,CAAAoB,gBAEDX,mBAAiB,EAAA,CAAA,EAAAW,gBACjBZ,sBAAoB,EAACa,YAAYF,QAAM,CAAA,CAE5C,CAAC;;EAEHG,OAAO;GACLC,OAAO;GACP,MAAMC,UAAU;IAAA,MAAAC,SAAA;AACd,SAAKC,UAAU,MAAMC,QAAQC,IAC3B,KAAKC,MAAMC,IAAI,OAAMD,UAAS;AAC5B,SAAI,CAACA,MAAME,MACT,OAAM,IAAIC,MACR,4BAA4BH,MAAMhB,KAAI,6BACvC;KAGH,MAAMoB,eAAe,MAAM/B,cAExB,MAAM2B,MAAME,MAAM;AACrB,SAAI,CAACE,cAAcC,QACjB,OAAM,IAAIF,MACR,4BACEH,MAAMhB,KAAI,gNAEb;AAGH,YAAO;MACLgB;MACAM,OAAO7B,WAAW2B,aAAaC,QAAQC,MAAM;MAC7CC,MAAM9B,WAAW2B,aAAaC,QAAQE,KAAK;MAC3CC,OAAO/B,WAAW2B,aAAaC,QAAQG,MAAM;MAC7CC,YAAYhC,WAAW2B,aAAaC,QAAQI,WAAW;MACvDC,WAAWjC,WAAW2B,aAAaC,QAAQK,UAAU;MACrDC,MAAMlC,WAAW2B,aAAaC,QAAQM,KAAK;MAC3CC,OAAOnC,WAAW2B,aAAaC,QAAQO,MAAM;MAC7CC,OAAOpC,WAAW2B,aAAaC,QAAQQ,MAAK;MAC7C;MAEL,CAAC;AAED,WAAO1C,OACL,MAAIoB,gBACHrB,KAAG;KAAA,IAAC4C,OAAI;AAAA,aAAElB,OAAKC;;KAAOkB,WACpBC,WAAMzB,gBAAKV,aAAW,EAASmC,QAAM,CAAA;KAAI,CAE9C,CAAC;;GAEJ;EACD,MAAMC,eAAe;GACnB,IAAIC,WAAWC,QAAQC,IAAIC;AAC3B,OAAI,CAACH,UAAU;AACbA,eAAW,KAAKjC,OAAOC,WAAWgC;AAClC,QAAIA,SACF,MAAKI,KACH,oNACD;QAED,OAAM,IAAInB,MACR,4GACD;;AAIL,SAAM,KAAKoB,OAAOC,UAAU,uBAAuB,EACjDC,OAAOP,UACR,CAAC;AAYF,UAAO,EACLF,QAXa,IAAI1C,iBAAiBoD,cAClC,GAAGlD,UAAU,KAAKS,OAAOD,KAAK,CAAA,UAC9B;IACE2C,WAAW,KAAK1C,OAAOC,WAAWyC;IAClCC,YACE,KAAK3C,OAAOC,WAAW0C,cAAcpD,UAAU,KAAKS,OAAOD,KAAK;IAClE6C,aAAatD,UAAU,KAAKU,OAAO6C,OAAOC,YAAY,WAAU;IAEpE,CAAC,EAIA;;EAEJ,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;UA+BiB,uBAAA;;AAAjB;;;;;;;EASE,SAAA;EAuBU;;AAGZ;;;;;;EAhBE,QAAA;EAqBsC;;;EAhBtC,MAAA;EAgBe;;;AAGjB;;;EAXE,UAAA;AAAA;AAAA,KAGU,0BAAA,GAA6B,mBAAA,GACvC,sBAAA;EAYc;;;EARZ,UAAA,GAAa,uBAAA;AAAA;AAAA,KAGL,8BAAA,GAAiC,uBAAA,GAC3C,0BAAA;EAIc;;;EAAZ,UAAA,EAAY,QAAA,CAAS,uBAAA;AAAA;AAAA,KAGb,2BAAA,GAA8B,MAAA,OAClC,eAAA;EAGN,KAAA,EAAO,2BAAA;AAAA;AAAA,KAGG,uBAAA,yBACc,8BAAA,GACtB,8BAAA,IACA,aAAA,CAAc,eAAA,IAChB,gBAAA,CAAiB,eAAA,IACjB,mBAAA,CAAoB,eAAA;EAClB,OAAA,EAAS,2BAAA;AAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;UA+BiB,uBAAA;;AAAjB;;;;;;;EASE,SAAA;EAuBU;;AAGZ;;;;;;EAhBE,QAAA;EAqBsC;;;EAhBtC,MAAA;EAgBe;;;AAGjB;;;EAXE,UAAA;AAAA;AAAA,KAGU,0BAAA,GAA6B,mBAAA,GACvC,sBAAA;EAYc;;;EARZ,UAAA,GAAa,uBAAA;AAAA;AAAA,KAGL,8BAAA,GAAiC,uBAAA,GAC3C,0BAAA;EAIc;;;EAAZ,UAAA,EAAY,QAAA,CAAS,uBAAA;AAAA;AAAA,KAGb,2BAAA,GAA8B,MAAA,OAClC,eAAA;EAGN,KAAA,EAAO,2BAAA;AAAA;AAAA,KAGG,uBAAA,yBACc,8BAAA,GACtB,8BAAA,IACA,aAAA,CAAc,eAAA,IAChB,gBAAA,CAAiB,eAAA,IACjB,mBAAA,CAAoB,eAAA;EAClB,OAAA,EAAS,2BAAA;AAAA;AAAA"}
|