@powerlines/plugin-cloudflare 0.2.28 → 0.2.30
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 +1 -1
- package/dist/components/cloudflare-builtin.cjs +846 -792
- package/dist/components/cloudflare-builtin.mjs +846 -792
- package/dist/components/cloudflare-builtin.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +14 -10
- package/dist/components/env-builtin.mjs +14 -10
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/components/worker-entry.cjs +142 -118
- package/dist/components/worker-entry.mjs +142 -118
- package/dist/components/worker-entry.mjs.map +1 -1
- package/dist/index.cjs +8 -5
- package/dist/index.mjs +8 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-entry.mjs","names":[],"sources":["../../src/components/worker-entry.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 { code, computed, Show, splitProps } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts\";\nimport {\n EntryFile,\n EntryFileProps\n} from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { murmurhash } from \"@stryke/hash\";\nimport { relativePath } from \"@stryke/path/find\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport defu from \"defu\";\nimport { CloudflarePluginContext, CloudflareWorkerEntryModule } from \"../types\";\n\nexport type WorkerEntryProps = Partial<EntryFileProps> &\n Omit<EntryFileProps, \"path\"> & {\n worker: CloudflareWorkerEntryModule;\n };\n\n/**\n * 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.\n */\nexport function WorkerEntry(props: WorkerEntryProps) {\n const [{ worker, children, imports, builtinImports }, rest] = splitProps(\n props,\n [\"worker\", \"children\", \"imports\", \"builtinImports\"]\n );\n\n const context = usePowerlines<CloudflarePluginContext>();\n const entryPath = computed(\n () =>\n `./${replaceExtension(\n relativePath(\n context.entryPath,\n worker.entry.input?.file || worker.entry.file\n )\n )}`\n );\n\n return (\n <EntryFile\n path={`worker-${murmurhash(worker.entry, {\n maxLength: 8\n })}-entry.ts`}\n {...rest}\n imports={defu(\n {\n \"@cloudflare/workers-types\": [\n { name: \"Request\", type: true },\n { name: \"Response\", type: true },\n { name: \"ExecutionContext\", type: true },\n { name: \"IncomingRequestCfProperties\", type: true },\n { name: \"ScheduledController\", type: true },\n { name: \"ForwardableEmailMessage\", type: true },\n { name: \"MessageBatch\", type: true },\n { name: \"TailStream\", type: true },\n { name: \"TraceItem\", type: true },\n { name: \"TailStream.TailEvent\", type: true },\n { name: \"TailStream.Onset\", type: true },\n { name: \"TailStream.TailEventHandlerType\", type: true }\n ],\n [entryPath.value]: \"worker\"\n },\n imports ?? {}\n )}\n builtinImports={defu(\n {\n cloudflare: [\n \"withFetchContext\",\n \"withTailContext\",\n \"withTraceContext\",\n \"withTailStreamContext\",\n \"withScheduledContext\",\n \"withTestContext\",\n \"withEmailContext\",\n \"withQueueContext\"\n ]\n },\n builtinImports ?? {}\n )}>\n {code`export default { `}\n <hbr />\n <Show when={worker.fetch}>\n {code` async fetch(request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: CloudflareBindings, ctx: ExecutionContext): Promise<Response> {\n return await withFetchContext({ request, env, ctx }, async (context) => {\n return worker.fetch(context.request, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.tail}>\n {code` async tail(events: TraceItem[], env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withTailContext({ events, env, ctx }, async (context) => {\n return worker.tail(context.events, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.trace}>\n {code` async trace(traces: TraceItem[], env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withTraceContext({ traces, env, ctx }, async (context) => {\n return worker.trace(context.traces, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.tailStream}>\n {code` async tailStream(event: TailStream.TailEvent<TailStream.Onset>, env: CloudflareBindings, ctx: ExecutionContext): Promise<ReadableStream> {\n return await withTailStreamContext({ event, env, ctx }, async (context) => {\n return await worker.tailStream(context.event, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.scheduled}>\n {code` async scheduled(controller: ScheduledController, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withScheduledContext({ controller, env, ctx }, async (context) => {\n return worker.scheduled(context.controller, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.test}>\n {code` async test(controller: TestController, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withTestContext({ controller, env, ctx }, async (context) => {\n return worker.test(context.controller, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.email}>\n {code` async email(message: ForwardableEmailMessage, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withEmailContext({ message, env, ctx }, async (context) => {\n return worker.email(context.message, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.queue}>\n {code` async queue(batch: MessageBatch, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withQueueContext({ batch, env, ctx }, async (context) => {\n return worker.queue(context.batch, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n {code` } satisfies ExportedHandler<CloudflareBindings>; `}\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </EntryFile>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"worker-entry.mjs","names":[],"sources":["../../src/components/worker-entry.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 { code, computed, Show, splitProps } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts\";\nimport {\n EntryFile,\n EntryFileProps\n} from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { murmurhash } from \"@stryke/hash\";\nimport { relativePath } from \"@stryke/path/find\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport defu from \"defu\";\nimport { CloudflarePluginContext, CloudflareWorkerEntryModule } from \"../types\";\n\nexport type WorkerEntryProps = Partial<EntryFileProps> &\n Omit<EntryFileProps, \"path\"> & {\n worker: CloudflareWorkerEntryModule;\n };\n\n/**\n * 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.\n */\nexport function WorkerEntry(props: WorkerEntryProps) {\n const [{ worker, children, imports, builtinImports }, rest] = splitProps(\n props,\n [\"worker\", \"children\", \"imports\", \"builtinImports\"]\n );\n\n const context = usePowerlines<CloudflarePluginContext>();\n const entryPath = computed(\n () =>\n `./${replaceExtension(\n relativePath(\n context.entryPath,\n worker.entry.input?.file || worker.entry.file\n )\n )}`\n );\n\n return (\n <EntryFile\n path={`worker-${murmurhash(worker.entry, {\n maxLength: 8\n })}-entry.ts`}\n {...rest}\n imports={defu(\n {\n \"@cloudflare/workers-types\": [\n { name: \"Request\", type: true },\n { name: \"Response\", type: true },\n { name: \"ExecutionContext\", type: true },\n { name: \"IncomingRequestCfProperties\", type: true },\n { name: \"ScheduledController\", type: true },\n { name: \"ForwardableEmailMessage\", type: true },\n { name: \"MessageBatch\", type: true },\n { name: \"TailStream\", type: true },\n { name: \"TraceItem\", type: true },\n { name: \"TailStream.TailEvent\", type: true },\n { name: \"TailStream.Onset\", type: true },\n { name: \"TailStream.TailEventHandlerType\", type: true }\n ],\n [entryPath.value]: \"worker\"\n },\n imports ?? {}\n )}\n builtinImports={defu(\n {\n cloudflare: [\n \"withFetchContext\",\n \"withTailContext\",\n \"withTraceContext\",\n \"withTailStreamContext\",\n \"withScheduledContext\",\n \"withTestContext\",\n \"withEmailContext\",\n \"withQueueContext\"\n ]\n },\n builtinImports ?? {}\n )}>\n {code`export default { `}\n <hbr />\n <Show when={worker.fetch}>\n {code` async fetch(request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: CloudflareBindings, ctx: ExecutionContext): Promise<Response> {\n return await withFetchContext({ request, env, ctx }, async (context) => {\n return worker.fetch(context.request, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.tail}>\n {code` async tail(events: TraceItem[], env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withTailContext({ events, env, ctx }, async (context) => {\n return worker.tail(context.events, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.trace}>\n {code` async trace(traces: TraceItem[], env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withTraceContext({ traces, env, ctx }, async (context) => {\n return worker.trace(context.traces, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.tailStream}>\n {code` async tailStream(event: TailStream.TailEvent<TailStream.Onset>, env: CloudflareBindings, ctx: ExecutionContext): Promise<ReadableStream> {\n return await withTailStreamContext({ event, env, ctx }, async (context) => {\n return await worker.tailStream(context.event, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.scheduled}>\n {code` async scheduled(controller: ScheduledController, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withScheduledContext({ controller, env, ctx }, async (context) => {\n return worker.scheduled(context.controller, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.test}>\n {code` async test(controller: TestController, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withTestContext({ controller, env, ctx }, async (context) => {\n return worker.test(context.controller, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.email}>\n {code` async email(message: ForwardableEmailMessage, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withEmailContext({ message, env, ctx }, async (context) => {\n return worker.email(context.message, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n <Show when={worker.queue}>\n {code` async queue(batch: MessageBatch, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {\n return withQueueContext({ batch, env, ctx }, async (context) => {\n return worker.queue(context.batch, context.env, context.ctx);\n });\n }, `}\n </Show>\n <hbr />\n {code` } satisfies ExportedHandler<CloudflareBindings>; `}\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </EntryFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;CAoCE,MAAA,CAAA,EACC,QACD,UACF,SACE,kBACE,QAAK,WAAA,OAAA;EAAA;EAAA;EAAA;EAAA;EAAA,CAAA;CACP,MAAI,UAAU,eAAsC;CACpD,MAAC,YAAA,eAAA,KAAA,iBAAA,aAAA,QAAA,WAAA,OAAA,MAAA,OAAA,QAAA,OAAA,MAAA,KAAA,CAAA,GAAA;gDAED,IAAM,OAAO;AACb,SAAM,UAAY,WAAQ,OAAA,OAAA,EACpB,WAAA,GACD,CAAC,CAAC;IAEN,EAAE,MAAK;EACN,IAAI,UAAS;AACX,UAAE,KAAA;IACA,6BAAA;KAAA;MACL,MAAA;;MAEM;KAAA;MACJ,MAAA;MACK,MAAG;MACL;KAAA;MACE,MAAM;MACN,MAAI;MACR;KAAA;MACE,MAAA;MACE,MAAE;MACH;KAAE;MACD,MAAI;MACJ,MAAI;MACL;KAAE;MACD,MAAI;MACJ,MAAI;MACL;KAAE;MACD,MAAI;MACJ,MAAI;MACL;KAAE;MACD,MAAI;MACJ,MAAI;MACL;KAAE;MACD,MAAC;MACF,MAAA;MACD;KAAA;MACD,MAAA;MACD,MAAA;MACE;KAAA;MACE,MAAA;MACA,MAAG;MACJ;KAAE;MACD,MAAG;MACH,MAAG;MACJ;KAAC;KACD,UAAI,QAAA;IACN,EAAE,WAAI,EAAA,CAAA;;EAET,IAAI,iBAAE;AACJ,UAAG,KAAA,EACD,YAAA;IAAA;IAAmB;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA,EACpB,EAAC,kBAAA,EAAA,CAAA;;EAEJ,IAAG,WAAK;AACN,UAAM;IAAA,IAAM;IAAa,gBAAA,OAAA,EAAA,CAAA;IAAA,gBAAA,MAAA;KACvB,IAAC,OAAM;AACP,aAAO,OAAM;;KAEb,UAAE,IAAA;;;;;KAKH,CAAC;IAAC,gBAAiB,OAAQ,EAAA,CAAA;IAAA,gBAAkB,MAAA;KAC5C,IAAA,OAAO;AACL,aAAO,OAAO;;KAEhB,UAAE,IAAA;;;;;KAKH,CAAC;IAAA,gBAAO,OAAmB,EAAA,CAAA;IAAM,gBAAc,MAAO;KACrD,IAAE,OAAO;AACP,aAAA,OAAA;;KAEF,UAAI,IAAA;;;;;KAKL,CAAC;IAAE,gBAAa,OAAO,EAAA,CAAA;IAAU,gBAAgB,MAAQ;KACxD,IAAE,OAAA;AACA,aAAA,OAAA;;KAEH,UAAK,IAAA;;;;;KAKL,CAAC;IAAE,gBAAA,OAAA,EAAA,CAAA;IAAA,gBAAA,MAAA;KACF,IAAE,OAAA;AACF,aAAI,OAAA;;KAEL,UAAW,IAAA;;;;;KAKX,CAAC;IAAE,gBAAA,OAAA,EAAA,CAAA;IAAA,gBAAA,MAAA;KACF,IAAI,OAAA;AACF,aAAE,OAAA;;KAEJ,UAAO,IAAM;;;;;KAKd,CAAC;IAAA,gBAAI,OAAA,EAAA,CAAA;IAAA,gBAAA,MAAA;KACL,IAAK,OAAA;AACL,aAAU,OAAO;;KAEhB,UAAO,IAAA;;;;;KAKR,CAAA;IAAG,gBAAE,OAAA,EAAA,CAAA;IAAA,gBAAA,MAAA;KACL,IAAK,OAAG;AACR,aAAS,OAAA;;KAEV,UAAS,IAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -4,6 +4,7 @@ const require_components_cloudflare_builtin = require('./components/cloudflare-b
|
|
|
4
4
|
const require_components_env_builtin = require('./components/env-builtin.cjs');
|
|
5
5
|
const require_components_worker_entry = require('./components/worker-entry.cjs');
|
|
6
6
|
require('./components/index.cjs');
|
|
7
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
7
8
|
let _alloy_js_core = require("@alloy-js/core");
|
|
8
9
|
let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
|
|
9
10
|
let _powerlines_plugin_env_helpers = require("@powerlines/plugin-env/helpers");
|
|
@@ -15,7 +16,6 @@ let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case
|
|
|
15
16
|
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
16
17
|
let defu = require("defu");
|
|
17
18
|
defu = require_runtime.__toESM(defu);
|
|
18
|
-
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
19
19
|
|
|
20
20
|
//#region src/index.tsx
|
|
21
21
|
/**
|
|
@@ -32,11 +32,12 @@ function plugin(options = {}) {
|
|
|
32
32
|
},
|
|
33
33
|
async prepare() {
|
|
34
34
|
const result = await (0, _powerlines_plugin_env_helpers.readEnvTypeReflection)(this, "env");
|
|
35
|
-
return (0, _powerlines_plugin_alloy_render.render)(this,
|
|
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",
|
|
39
39
|
async handler() {
|
|
40
|
+
const _self$ = this;
|
|
40
41
|
this.workers = await Promise.all(this.entry.map(async (entry) => {
|
|
41
42
|
if (!entry.input) throw new Error(`Cloudflare Worker entry "${entry.name}" is missing an input file.`);
|
|
42
43
|
const workerModule = await (0, _powerlines_plugin_esbuild_helpers_resolve.resolveModule)(this, entry.input);
|
|
@@ -53,9 +54,11 @@ function plugin(options = {}) {
|
|
|
53
54
|
queue: (0, _stryke_type_checks_is_function.isFunction)(workerModule.default.queue)
|
|
54
55
|
};
|
|
55
56
|
}));
|
|
56
|
-
return (0, _powerlines_plugin_alloy_render.render)(this,
|
|
57
|
-
each
|
|
58
|
-
|
|
57
|
+
return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
58
|
+
get each() {
|
|
59
|
+
return _self$.workers;
|
|
60
|
+
},
|
|
61
|
+
children: (worker) => (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_worker_entry.WorkerEntry, { worker })
|
|
59
62
|
}));
|
|
60
63
|
}
|
|
61
64
|
},
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { CloudflareBuiltin } from "./components/cloudflare-builtin.mjs";
|
|
|
2
2
|
import { CloudflareEnvBuiltin } from "./components/env-builtin.mjs";
|
|
3
3
|
import { WorkerEntry } from "./components/worker-entry.mjs";
|
|
4
4
|
import "./components/index.mjs";
|
|
5
|
+
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
5
6
|
import { For } from "@alloy-js/core";
|
|
6
7
|
import { render } from "@powerlines/plugin-alloy/render";
|
|
7
8
|
import { readEnvTypeReflection } from "@powerlines/plugin-env/helpers";
|
|
@@ -11,7 +12,6 @@ import { joinPaths } from "@stryke/path";
|
|
|
11
12
|
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
12
13
|
import { isFunction } from "@stryke/type-checks/is-function";
|
|
13
14
|
import defu from "defu";
|
|
14
|
-
import { Fragment, jsx, jsxs } from "@alloy-js/core/jsx-runtime";
|
|
15
15
|
|
|
16
16
|
//#region src/index.tsx
|
|
17
17
|
/**
|
|
@@ -28,11 +28,12 @@ function plugin(options = {}) {
|
|
|
28
28
|
},
|
|
29
29
|
async prepare() {
|
|
30
30
|
const result = await readEnvTypeReflection(this, "env");
|
|
31
|
-
return render(this,
|
|
31
|
+
return render(this, [createComponent(CloudflareBuiltin, {}), createComponent(CloudflareEnvBuiltin, { reflection: result })]);
|
|
32
32
|
},
|
|
33
33
|
build: {
|
|
34
34
|
order: "pre",
|
|
35
35
|
async handler() {
|
|
36
|
+
const _self$ = this;
|
|
36
37
|
this.workers = await Promise.all(this.entry.map(async (entry) => {
|
|
37
38
|
if (!entry.input) throw new Error(`Cloudflare Worker entry "${entry.name}" is missing an input file.`);
|
|
38
39
|
const workerModule = await resolveModule(this, entry.input);
|
|
@@ -49,9 +50,11 @@ function plugin(options = {}) {
|
|
|
49
50
|
queue: isFunction(workerModule.default.queue)
|
|
50
51
|
};
|
|
51
52
|
}));
|
|
52
|
-
return render(this,
|
|
53
|
-
each
|
|
54
|
-
|
|
53
|
+
return render(this, createComponent(For, {
|
|
54
|
+
get each() {
|
|
55
|
+
return _self$.workers;
|
|
56
|
+
},
|
|
57
|
+
children: (worker) => createComponent(WorkerEntry, { worker })
|
|
55
58
|
}));
|
|
56
59
|
}
|
|
57
60
|
},
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"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":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"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":";;;;;;;;;;;;;;;;;;;;AA8CE,QAAA,CAAA;EACE,MAAC;EACH,SAAA;AACI,UAAC,EACL,YAAiB,KAAA,SAAA,EAAA,CAAA,EACjB;;EAEE,iBAAA;AACE,QAAK,gBAAa,+BAAA;;EAEpB,MAAI,UAAO;GACT,MAAI,SAAW,MAAM,sBAAW,MAAA,MAAA;AAChC,UAAG,OAAA,MAAA,CAAA,gBAAA,mBAAA,EAAA,CAAA,EAAA,gBAAA,sBAAA,EACF,YAAA,QACD,CAAA,CAAA,CAAA;;EAEF,OAAG;GACD,OAAM;GACN,MAAE,UAAc;;AAEd,SAAA,UAAa,MAAA,QAAA,IAAA,KAAA,MAAA,IAAA,OAAA,UAAA;AACX,SAAI,CAAA,MAAA,MACH,OAAA,IAAA,MAAA,4BAAA,MAAA,KAAA,6BAAA;KAED,MAAG,eAAA,MAAqB,cAEzB,MAAA,MAAA,MAAA;AACF,SAAA,CAAA,cAAA,QACK,OAAC,IAAA,MAAA,4BAAA,MAAA,KAAA,gNAAA;AAEL,YAAM;MACJ;MACE,OAAK,WAAU,aAAe,QAAA,MAAA;MAC9B,MAAM,WAAO,aAAO,QAAA,KAAA;MACpB,OAAI,WAAU,aAAK,QAAA,MAAA;MACnB,YAAO,WAAW,aAAgB,QAAU,WAAM;MAClD,WAAK,WAAA,aAAA,QAAA,UAAA;MACL,MAAE,WAAA,aAAA,QAAA,KAAA;;MAEF,OAAO,WAAC,aAAqB,QAAA,MAAc;MAC5C;MACD,CAAC;AACH,WAAM,OAAK,MAAA,gBAAuB,KAAA;KAChC,IAAI,OAAO;AACT,aAAO,OAAA;;KAET,WAAU,WAAU,gBAAiB,aAAa,EAC3C,QACN,CAAC;;;GAGP;EACD,MAAM,eAAa;GACjB,IAAI,WAAW,QAAC,IAAW;AAC3B,OAAI,CAAC,UAAU;AACb,eAAQ,KAAA,OAAY,WAAW;AAC/B,QAAI,SACF,MAAK,KAAK,oNAAuC;QAEjD,OAAM,IAAA,MAAO,4GAAqC;;AAGtD,SAAK,KAAA,OAAA,UAAA,uBAAA,mBAEJ,CAAC;AAMF,UAAE,EACD,QANS,IAAA,iBAAA,cAAA,GAAA,UAAA,KAAA,OAAA,KAAA,CAAA,UAAA;IACR,WAAS,KAAM,OAAK,WAAQ;IAC5B,YAAO,KAAU,OAAC,WAAY,cAAkB,UAAA,KAAA,OAAA,KAAA;IAChD,aAAS,UAAA,KAAA,OAAA,OAAA,YAAA,WAAA;IACV,CAAC,EAGF;;EAEH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-cloudflare",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.30",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A Powerlines plugin that provides integration with Cloudflare services.",
|
|
6
6
|
"keywords": ["powerlines", "storm-software", "powerlines-plugin"],
|
|
@@ -148,24 +148,24 @@
|
|
|
148
148
|
"@alloy-js/core": "0.23.0-dev.8",
|
|
149
149
|
"@alloy-js/typescript": "0.23.0-dev.4",
|
|
150
150
|
"@cloudflare/workers-types": "^4.20260313.1",
|
|
151
|
-
"@powerlines/plugin-env": "^0.16.
|
|
152
|
-
"@powerlines/plugin-pulumi": "^0.5.
|
|
151
|
+
"@powerlines/plugin-env": "^0.16.70",
|
|
152
|
+
"@powerlines/plugin-pulumi": "^0.5.30",
|
|
153
153
|
"@pulumi/cloudflare": "^6.13.0",
|
|
154
154
|
"@pulumi/pulumi": "^3.225.1",
|
|
155
155
|
"@storm-software/config-tools": "1.189.28",
|
|
156
|
-
"@stryke/hash": "^0.13.
|
|
157
|
-
"@stryke/path": "^0.
|
|
158
|
-
"@stryke/string-format": "^0.17.
|
|
159
|
-
"@stryke/type-checks": "^0.5.
|
|
156
|
+
"@stryke/hash": "^0.13.11",
|
|
157
|
+
"@stryke/path": "^0.27.0",
|
|
158
|
+
"@stryke/string-format": "^0.17.4",
|
|
159
|
+
"@stryke/type-checks": "^0.5.39",
|
|
160
160
|
"defu": "^6.1.4",
|
|
161
|
-
"powerlines": "^0.41.
|
|
161
|
+
"powerlines": "^0.41.14"
|
|
162
162
|
},
|
|
163
163
|
"devDependencies": {
|
|
164
164
|
"@cloudflare/workers-types": "^4.20260313.1",
|
|
165
|
-
"@powerlines/plugin-alloy": "^0.25.
|
|
166
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
165
|
+
"@powerlines/plugin-alloy": "^0.25.35",
|
|
166
|
+
"@powerlines/plugin-plugin": "^0.12.300",
|
|
167
167
|
"@types/node": "^25.5.0"
|
|
168
168
|
},
|
|
169
169
|
"publishConfig": { "access": "public" },
|
|
170
|
-
"gitHead": "
|
|
170
|
+
"gitHead": "9a873b7c4bc2a376b58e2721aa6211ca162c1f61"
|
|
171
171
|
}
|