@powerlines/plugin-cloudflare 0.2.0

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.
Files changed (58) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +304 -0
  3. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  4. package/dist/components/cloudflare-builtin.cjs +916 -0
  5. package/dist/components/cloudflare-builtin.d.cts +13 -0
  6. package/dist/components/cloudflare-builtin.d.cts.map +1 -0
  7. package/dist/components/cloudflare-builtin.d.mts +13 -0
  8. package/dist/components/cloudflare-builtin.d.mts.map +1 -0
  9. package/dist/components/cloudflare-builtin.mjs +915 -0
  10. package/dist/components/cloudflare-builtin.mjs.map +1 -0
  11. package/dist/components/env-builtin.cjs +31 -0
  12. package/dist/components/env-builtin.d.cts +13 -0
  13. package/dist/components/env-builtin.d.cts.map +1 -0
  14. package/dist/components/env-builtin.d.mts +13 -0
  15. package/dist/components/env-builtin.d.mts.map +1 -0
  16. package/dist/components/env-builtin.mjs +30 -0
  17. package/dist/components/env-builtin.mjs.map +1 -0
  18. package/dist/components/index.cjs +7 -0
  19. package/dist/components/index.d.cts +4 -0
  20. package/dist/components/index.d.mts +4 -0
  21. package/dist/components/index.mjs +5 -0
  22. package/dist/components/worker-entry.cjs +202 -0
  23. package/dist/components/worker-entry.d.cts +17 -0
  24. package/dist/components/worker-entry.d.cts.map +1 -0
  25. package/dist/components/worker-entry.d.mts +17 -0
  26. package/dist/components/worker-entry.d.mts.map +1 -0
  27. package/dist/components/worker-entry.mjs +201 -0
  28. package/dist/components/worker-entry.mjs.map +1 -0
  29. package/dist/index.cjs +88 -0
  30. package/dist/index.d.cts +21 -0
  31. package/dist/index.d.cts.map +1 -0
  32. package/dist/index.d.mts +21 -0
  33. package/dist/index.d.mts.map +1 -0
  34. package/dist/index.mjs +81 -0
  35. package/dist/index.mjs.map +1 -0
  36. package/dist/node_modules/.pnpm/@stryke_string-format@0.16.0/node_modules/@stryke/string-format/dist/get-words.cjs +38 -0
  37. package/dist/node_modules/.pnpm/@stryke_string-format@0.16.0/node_modules/@stryke/string-format/dist/get-words.mjs +38 -0
  38. package/dist/node_modules/.pnpm/@stryke_string-format@0.16.0/node_modules/@stryke/string-format/dist/get-words.mjs.map +1 -0
  39. package/dist/node_modules/.pnpm/@stryke_string-format@0.16.0/node_modules/@stryke/string-format/dist/kebab-case.cjs +33 -0
  40. package/dist/node_modules/.pnpm/@stryke_string-format@0.16.0/node_modules/@stryke/string-format/dist/kebab-case.mjs +34 -0
  41. package/dist/node_modules/.pnpm/@stryke_string-format@0.16.0/node_modules/@stryke/string-format/dist/kebab-case.mjs.map +1 -0
  42. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.34/node_modules/@stryke/type-checks/dist/get-object-tag.cjs +15 -0
  43. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.34/node_modules/@stryke/type-checks/dist/get-object-tag.mjs +15 -0
  44. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.34/node_modules/@stryke/type-checks/dist/get-object-tag.mjs.map +1 -0
  45. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.34/node_modules/@stryke/type-checks/dist/is-function.cjs +25 -0
  46. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.34/node_modules/@stryke/type-checks/dist/is-function.mjs +26 -0
  47. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.34/node_modules/@stryke/type-checks/dist/is-function.mjs.map +1 -0
  48. package/dist/types/index.cjs +0 -0
  49. package/dist/types/index.d.cts +2 -0
  50. package/dist/types/index.d.mts +2 -0
  51. package/dist/types/index.mjs +1 -0
  52. package/dist/types/plugin.cjs +0 -0
  53. package/dist/types/plugin.d.cts +63 -0
  54. package/dist/types/plugin.d.cts.map +1 -0
  55. package/dist/types/plugin.d.mts +63 -0
  56. package/dist/types/plugin.d.mts.map +1 -0
  57. package/dist/types/plugin.mjs +1 -0
  58. package/package.json +168 -0
@@ -0,0 +1,201 @@
1
+ import { createComponent, createIntrinsic, mergeProps } from "@alloy-js/core/jsx-runtime";
2
+ import { Show, code, computed, splitProps } from "@alloy-js/core";
3
+ import defu from "defu";
4
+ import { Spacing } from "@powerlines/plugin-alloy/core/components";
5
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts";
6
+ import { EntryFile } from "@powerlines/plugin-alloy/typescript/components/entry-file";
7
+ import { murmurhash } from "@stryke/hash";
8
+ import { relativePath } from "@stryke/path/find";
9
+ import { replaceExtension } from "@stryke/path/replace";
10
+
11
+ //#region src/components/worker-entry.tsx
12
+ /**
13
+ * 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.
14
+ */
15
+ function WorkerEntry(props) {
16
+ const [{ worker, children, imports, builtinImports }, rest] = splitProps(props, [
17
+ "worker",
18
+ "children",
19
+ "imports",
20
+ "builtinImports"
21
+ ]);
22
+ const context = usePowerlines();
23
+ const entryPath = computed(() => `./${replaceExtension(relativePath(context.entryPath, worker.entry.input?.file || worker.entry.file))}`);
24
+ return createComponent(EntryFile, mergeProps({ get path() {
25
+ return `worker-${murmurhash(worker.entry, { maxLength: 8 })}-entry.ts`;
26
+ } }, rest, {
27
+ get imports() {
28
+ return defu({
29
+ "@cloudflare/workers-types": [
30
+ {
31
+ name: "Request",
32
+ type: true
33
+ },
34
+ {
35
+ name: "Response",
36
+ type: true
37
+ },
38
+ {
39
+ name: "ExecutionContext",
40
+ type: true
41
+ },
42
+ {
43
+ name: "IncomingRequestCfProperties",
44
+ type: true
45
+ },
46
+ {
47
+ name: "ScheduledController",
48
+ type: true
49
+ },
50
+ {
51
+ name: "ForwardableEmailMessage",
52
+ type: true
53
+ },
54
+ {
55
+ name: "MessageBatch",
56
+ type: true
57
+ },
58
+ {
59
+ name: "TailStream",
60
+ type: true
61
+ },
62
+ {
63
+ name: "TraceItem",
64
+ type: true
65
+ },
66
+ {
67
+ name: "TailStream.TailEvent",
68
+ type: true
69
+ },
70
+ {
71
+ name: "TailStream.Onset",
72
+ type: true
73
+ },
74
+ {
75
+ name: "TailStream.TailEventHandlerType",
76
+ type: true
77
+ }
78
+ ],
79
+ [entryPath.value]: "worker"
80
+ }, imports ?? {});
81
+ },
82
+ get builtinImports() {
83
+ return defu({ cloudflare: [
84
+ "withFetchContext",
85
+ "withTailContext",
86
+ "withTraceContext",
87
+ "withTailStreamContext",
88
+ "withScheduledContext",
89
+ "withTestContext",
90
+ "withEmailContext",
91
+ "withQueueContext"
92
+ ] }, builtinImports ?? {});
93
+ },
94
+ get children() {
95
+ return [
96
+ code`export default { `,
97
+ createIntrinsic("hbr", {}),
98
+ createComponent(Show, {
99
+ get when() {
100
+ return worker.fetch;
101
+ },
102
+ children: code` async fetch(request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: CloudflareBindings, ctx: ExecutionContext): Promise<Response> {
103
+ return await withFetchContext({ request, env, ctx }, async (context) => {
104
+ return worker.fetch(context.request, context.env, context.ctx);
105
+ });
106
+ }, `
107
+ }),
108
+ createIntrinsic("hbr", {}),
109
+ createComponent(Show, {
110
+ get when() {
111
+ return worker.tail;
112
+ },
113
+ children: code` async tail(events: TraceItem[], env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {
114
+ return withTailContext({ events, env, ctx }, async (context) => {
115
+ return worker.tail(context.events, context.env, context.ctx);
116
+ });
117
+ }, `
118
+ }),
119
+ createIntrinsic("hbr", {}),
120
+ createComponent(Show, {
121
+ get when() {
122
+ return worker.trace;
123
+ },
124
+ children: code` async trace(traces: TraceItem[], env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {
125
+ return withTraceContext({ traces, env, ctx }, async (context) => {
126
+ return worker.trace(context.traces, context.env, context.ctx);
127
+ });
128
+ }, `
129
+ }),
130
+ createIntrinsic("hbr", {}),
131
+ createComponent(Show, {
132
+ get when() {
133
+ return worker.tailStream;
134
+ },
135
+ children: code` async tailStream(event: TailStream.TailEvent<TailStream.Onset>, env: CloudflareBindings, ctx: ExecutionContext): Promise<ReadableStream> {
136
+ return await withTailStreamContext({ event, env, ctx }, async (context) => {
137
+ return await worker.tailStream(context.event, context.env, context.ctx);
138
+ });
139
+ }, `
140
+ }),
141
+ createIntrinsic("hbr", {}),
142
+ createComponent(Show, {
143
+ get when() {
144
+ return worker.scheduled;
145
+ },
146
+ children: code` async scheduled(controller: ScheduledController, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {
147
+ return withScheduledContext({ controller, env, ctx }, async (context) => {
148
+ return worker.scheduled(context.controller, context.env, context.ctx);
149
+ });
150
+ }, `
151
+ }),
152
+ createIntrinsic("hbr", {}),
153
+ createComponent(Show, {
154
+ get when() {
155
+ return worker.test;
156
+ },
157
+ children: code` async test(controller: TestController, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {
158
+ return withTestContext({ controller, env, ctx }, async (context) => {
159
+ return worker.test(context.controller, context.env, context.ctx);
160
+ });
161
+ }, `
162
+ }),
163
+ createIntrinsic("hbr", {}),
164
+ createComponent(Show, {
165
+ get when() {
166
+ return worker.email;
167
+ },
168
+ children: code` async email(message: ForwardableEmailMessage, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {
169
+ return withEmailContext({ message, env, ctx }, async (context) => {
170
+ return worker.email(context.message, context.env, context.ctx);
171
+ });
172
+ }, `
173
+ }),
174
+ createIntrinsic("hbr", {}),
175
+ createComponent(Show, {
176
+ get when() {
177
+ return worker.queue;
178
+ },
179
+ children: code` async queue(batch: MessageBatch, env: CloudflareBindings, ctx: ExecutionContext): Promise<void> {
180
+ return withQueueContext({ batch, env, ctx }, async (context) => {
181
+ return worker.queue(context.batch, context.env, context.ctx);
182
+ });
183
+ }, `
184
+ }),
185
+ createIntrinsic("hbr", {}),
186
+ code` } satisfies ExportedHandler<CloudflareBindings>; `,
187
+ createComponent(Spacing, {}),
188
+ createComponent(Show, {
189
+ get when() {
190
+ return Boolean(children);
191
+ },
192
+ children
193
+ })
194
+ ];
195
+ }
196
+ }));
197
+ }
198
+
199
+ //#endregion
200
+ export { WorkerEntry };
201
+ //# sourceMappingURL=worker-entry.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-entry.mjs","names":["code","computed","Show","splitProps","Spacing","usePowerlines","EntryFile","murmurhash","relativePath","replaceExtension","defu","WorkerEntry","props","worker","children","imports","builtinImports","rest","context","entryPath","entry","input","file","_$createComponent","_$mergeProps","path","maxLength","name","type","value","cloudflare","_$createIntrinsic","when","fetch","tail","trace","tailStream","scheduled","test","email","queue","Boolean"],"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":"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"}
package/dist/index.cjs ADDED
@@ -0,0 +1,88 @@
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
+ const require_kebab_case = require('./node_modules/.pnpm/@stryke_string-format@0.16.0/node_modules/@stryke/string-format/dist/kebab-case.cjs');
4
+ const require_is_function = require('./node_modules/.pnpm/@stryke_type-checks@0.5.34/node_modules/@stryke/type-checks/dist/is-function.cjs');
5
+ const require_components_cloudflare_builtin = require('./components/cloudflare-builtin.cjs');
6
+ const require_components_env_builtin = require('./components/env-builtin.cjs');
7
+ const require_components_worker_entry = require('./components/worker-entry.cjs');
8
+ require('./components/index.cjs');
9
+ let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
10
+ let __alloy_js_core = require("@alloy-js/core");
11
+ let __powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
12
+ let __powerlines_plugin_env_helpers = require("@powerlines/plugin-env/helpers");
13
+ let __powerlines_plugin_esbuild_helpers_resolve = require("@powerlines/plugin-esbuild/helpers/resolve");
14
+ let __pulumi_cloudflare = require("@pulumi/cloudflare");
15
+ __pulumi_cloudflare = require_rolldown_runtime.__toESM(__pulumi_cloudflare);
16
+ let __stryke_path = require("@stryke/path");
17
+ let defu = require("defu");
18
+ defu = require_rolldown_runtime.__toESM(defu);
19
+
20
+ //#region src/index.tsx
21
+ /**
22
+ * A Powerlines plugin to assist in developing other Powerlines plugins.
23
+ */
24
+ function plugin(options = {}) {
25
+ return [{
26
+ name: "cloudflare",
27
+ config() {
28
+ return { cloudflare: (0, defu.default)(options, {}) };
29
+ },
30
+ configResolved() {
31
+ this.devDependencies["@cloudflare/workers-types"] = "^4.20240616.0";
32
+ },
33
+ async prepare() {
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
+ },
37
+ build: {
38
+ order: "pre",
39
+ async handler() {
40
+ const _self$ = this;
41
+ this.workers = await Promise.all(this.entry.map(async (entry) => {
42
+ if (!entry.input) throw new Error(`Cloudflare Worker entry "${entry.name}" is missing an input file.`);
43
+ const workerModule = await (0, __powerlines_plugin_esbuild_helpers_resolve.resolveModule)(this, entry.input);
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
+ return {
46
+ entry,
47
+ fetch: require_is_function.isFunction(workerModule.default.fetch),
48
+ tail: require_is_function.isFunction(workerModule.default.tail),
49
+ trace: require_is_function.isFunction(workerModule.default.trace),
50
+ tailStream: require_is_function.isFunction(workerModule.default.tailStream),
51
+ scheduled: require_is_function.isFunction(workerModule.default.scheduled),
52
+ test: require_is_function.isFunction(workerModule.default.test),
53
+ email: require_is_function.isFunction(workerModule.default.email),
54
+ queue: require_is_function.isFunction(workerModule.default.queue)
55
+ };
56
+ }));
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 })
62
+ }));
63
+ }
64
+ },
65
+ async deployPulumi() {
66
+ let apiToken = process.env.CLOUDFLARE_API_TOKEN;
67
+ if (!apiToken) {
68
+ apiToken = this.config.cloudflare.apiToken;
69
+ if (apiToken) this.warn("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.");
70
+ else throw new Error("Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.");
71
+ }
72
+ await this.pulumi.setConfig("cloudflare:apiToken", { value: apiToken });
73
+ return { worker: new __pulumi_cloudflare.WorkersScript(`${require_kebab_case.kebabCase(this.config.name)}-worker`, {
74
+ accountId: this.config.cloudflare.accountId,
75
+ scriptName: this.config.cloudflare.scriptName || require_kebab_case.kebabCase(this.config.name),
76
+ contentFile: (0, __stryke_path.joinPaths)(this.config.output.outputPath, "index.js")
77
+ }) };
78
+ }
79
+ }];
80
+ }
81
+ var src_default = plugin;
82
+
83
+ //#endregion
84
+ exports.CloudflareBuiltin = require_components_cloudflare_builtin.CloudflareBuiltin;
85
+ exports.CloudflareEnvBuiltin = require_components_env_builtin.CloudflareEnvBuiltin;
86
+ exports.WorkerEntry = require_components_worker_entry.WorkerEntry;
87
+ exports.default = src_default;
88
+ exports.plugin = plugin;
@@ -0,0 +1,21 @@
1
+ import { CloudflareBuiltin, CloudflareBuiltinProps, __ΩCloudflareBuiltinProps } from "./components/cloudflare-builtin.cjs";
2
+ import { CloudflareEnvBuiltin, CloudflareEnvBuiltinProps, __ΩCloudflareEnvBuiltinProps } from "./components/env-builtin.cjs";
3
+ import { CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule } from "./types/plugin.cjs";
4
+ import "./types/index.cjs";
5
+ import { WorkerEntry, WorkerEntryProps, __ΩWorkerEntryProps } from "./components/worker-entry.cjs";
6
+ import "./components/index.cjs";
7
+ import { Plugin } from "powerlines";
8
+
9
+ //#region src/index.d.ts
10
+ declare module "powerlines" {
11
+ interface Config {
12
+ cloudflare?: CloudflarePluginOptions;
13
+ }
14
+ }
15
+ /**
16
+ * A Powerlines plugin to assist in developing other Powerlines plugins.
17
+ */
18
+ declare function plugin<TContext extends CloudflarePluginContext = CloudflarePluginContext>(options?: CloudflarePluginOptions): Plugin<TContext>[];
19
+ //#endregion
20
+ export { CloudflareBuiltin, CloudflareBuiltinProps, CloudflareEnvBuiltin, CloudflareEnvBuiltinProps, CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, WorkerEntry, WorkerEntryProps, __ΩCloudflareBuiltinProps, __ΩCloudflareEnvBuiltinProps, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule, __ΩWorkerEntryProps, plugin as default, plugin };
21
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;iBA0CiB;;;AAJY;;;AAIW,iBAOxB,MAPwB,CAAA,iBAQrB,uBARqB,GAQK,uBARL,CAAA,CAAA,OAAA,CAAA,EAS7B,uBAT6B,CAAA,EA8GjC,MA9GiC,CA8G1B,QA9G0B,CAAA,EAAA"}
@@ -0,0 +1,21 @@
1
+ import { CloudflareBuiltin, CloudflareBuiltinProps, __ΩCloudflareBuiltinProps } from "./components/cloudflare-builtin.mjs";
2
+ import { CloudflareEnvBuiltin, CloudflareEnvBuiltinProps, __ΩCloudflareEnvBuiltinProps } from "./components/env-builtin.mjs";
3
+ import { CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule } from "./types/plugin.mjs";
4
+ import "./types/index.mjs";
5
+ import { WorkerEntry, WorkerEntryProps, __ΩWorkerEntryProps } from "./components/worker-entry.mjs";
6
+ import "./components/index.mjs";
7
+ import { Plugin } from "powerlines";
8
+
9
+ //#region src/index.d.ts
10
+ declare module "powerlines" {
11
+ interface Config {
12
+ cloudflare?: CloudflarePluginOptions;
13
+ }
14
+ }
15
+ /**
16
+ * A Powerlines plugin to assist in developing other Powerlines plugins.
17
+ */
18
+ declare function plugin<TContext extends CloudflarePluginContext = CloudflarePluginContext>(options?: CloudflarePluginOptions): Plugin<TContext>[];
19
+ //#endregion
20
+ export { CloudflareBuiltin, CloudflareBuiltinProps, CloudflareEnvBuiltin, CloudflareEnvBuiltinProps, CloudflarePluginContext, CloudflarePluginOptions, CloudflarePluginResolvedConfig, CloudflarePluginUserConfig, CloudflareWorkerEntryModule, WorkerEntry, WorkerEntryProps, __ΩCloudflareBuiltinProps, __ΩCloudflareEnvBuiltinProps, __ΩCloudflarePluginContext, __ΩCloudflarePluginOptions, __ΩCloudflarePluginResolvedConfig, __ΩCloudflarePluginUserConfig, __ΩCloudflareWorkerEntryModule, __ΩWorkerEntryProps, plugin as default, plugin };
21
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;iBA0CiB;;;AAJY;;;AAIW,iBAOxB,MAPwB,CAAA,iBAQrB,uBARqB,GAQK,uBARL,CAAA,CAAA,OAAA,CAAA,EAS7B,uBAT6B,CAAA,EA8GjC,MA9GiC,CA8G1B,QA9G0B,CAAA,EAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +1,81 @@
1
+ import { kebabCase } from "./node_modules/.pnpm/@stryke_string-format@0.16.0/node_modules/@stryke/string-format/dist/kebab-case.mjs";
2
+ import { isFunction } from "./node_modules/.pnpm/@stryke_type-checks@0.5.34/node_modules/@stryke/type-checks/dist/is-function.mjs";
3
+ import { CloudflareBuiltin } from "./components/cloudflare-builtin.mjs";
4
+ import { CloudflareEnvBuiltin } from "./components/env-builtin.mjs";
5
+ import { WorkerEntry } from "./components/worker-entry.mjs";
6
+ import "./components/index.mjs";
7
+ import { createComponent } from "@alloy-js/core/jsx-runtime";
8
+ import { For } from "@alloy-js/core";
9
+ import { render } from "@powerlines/plugin-alloy/render";
10
+ import { readEnvTypeReflection } from "@powerlines/plugin-env/helpers";
11
+ import { resolveModule } from "@powerlines/plugin-esbuild/helpers/resolve";
12
+ import * as pulumiCloudflare from "@pulumi/cloudflare";
13
+ import { joinPaths } from "@stryke/path";
14
+ import defu from "defu";
15
+
16
+ //#region src/index.tsx
17
+ /**
18
+ * A Powerlines plugin to assist in developing other Powerlines plugins.
19
+ */
20
+ function plugin(options = {}) {
21
+ return [{
22
+ name: "cloudflare",
23
+ config() {
24
+ return { cloudflare: defu(options, {}) };
25
+ },
26
+ configResolved() {
27
+ this.devDependencies["@cloudflare/workers-types"] = "^4.20240616.0";
28
+ },
29
+ async prepare() {
30
+ const result = await readEnvTypeReflection(this, "env");
31
+ return render(this, [createComponent(CloudflareBuiltin, {}), createComponent(CloudflareEnvBuiltin, { reflection: result })]);
32
+ },
33
+ build: {
34
+ order: "pre",
35
+ async handler() {
36
+ const _self$ = this;
37
+ this.workers = await Promise.all(this.entry.map(async (entry) => {
38
+ if (!entry.input) throw new Error(`Cloudflare Worker entry "${entry.name}" is missing an input file.`);
39
+ const workerModule = await resolveModule(this, entry.input);
40
+ 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".`);
41
+ return {
42
+ entry,
43
+ fetch: isFunction(workerModule.default.fetch),
44
+ tail: isFunction(workerModule.default.tail),
45
+ trace: isFunction(workerModule.default.trace),
46
+ tailStream: isFunction(workerModule.default.tailStream),
47
+ scheduled: isFunction(workerModule.default.scheduled),
48
+ test: isFunction(workerModule.default.test),
49
+ email: isFunction(workerModule.default.email),
50
+ queue: isFunction(workerModule.default.queue)
51
+ };
52
+ }));
53
+ return render(this, createComponent(For, {
54
+ get each() {
55
+ return _self$.workers;
56
+ },
57
+ children: (worker) => createComponent(WorkerEntry, { worker })
58
+ }));
59
+ }
60
+ },
61
+ async deployPulumi() {
62
+ let apiToken = process.env.CLOUDFLARE_API_TOKEN;
63
+ if (!apiToken) {
64
+ apiToken = this.config.cloudflare.apiToken;
65
+ if (apiToken) this.warn("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.");
66
+ else throw new Error("Unable to determine the Cloudflare API token. Please set the `CLOUDFLARE_API_TOKEN` environment variable.");
67
+ }
68
+ await this.pulumi.setConfig("cloudflare:apiToken", { value: apiToken });
69
+ return { worker: new pulumiCloudflare.WorkersScript(`${kebabCase(this.config.name)}-worker`, {
70
+ accountId: this.config.cloudflare.accountId,
71
+ scriptName: this.config.cloudflare.scriptName || kebabCase(this.config.name),
72
+ contentFile: joinPaths(this.config.output.outputPath, "index.js")
73
+ }) };
74
+ }
75
+ }];
76
+ }
77
+ var src_default = plugin;
78
+
79
+ //#endregion
80
+ export { CloudflareBuiltin, CloudflareEnvBuiltin, WorkerEntry, src_default as default, plugin };
81
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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;;AAGH,kBAAejD"}
@@ -0,0 +1,38 @@
1
+
2
+ //#region ../../node_modules/.pnpm/@stryke+string-format@0.16.0/node_modules/@stryke/string-format/dist/get-words.mjs
3
+ /**
4
+ * Regular expression pattern to split strings into words for various case conversions
5
+ *
6
+ * This pattern matches sequences of characters in a string, considering the following case:
7
+ * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)
8
+ * - Sequences of one uppercase letter optionally followed by lowercase letters and digits
9
+ * - Single uppercase letters
10
+ * - Sequences of digits
11
+ *
12
+ * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into
13
+ * a consistent format like snake case.
14
+ *
15
+ * @example
16
+ * const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);
17
+ * // matches: ['camel', 'Case', 'HTTP', 'Request']
18
+ */
19
+ const CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|\d+|[A-Z]+(?![a-z])/g;
20
+ const RELAXED_SPLIT_PATTERN = /[A-Z/.-]?[a-z/.-]+|\d+|[A-Z/.-]+(?![a-z/.-])/g;
21
+ /**
22
+ * Splits a string into words using a regular expression pattern
23
+ *
24
+ * @example
25
+ * const words = getWords('camelCaseHTTPRequest');
26
+ * // words: ['camel', 'Case', 'HTTP', 'Request']
27
+ *
28
+ * @param str - The string to split into words
29
+ * @param options - Options for splitting the string
30
+ * @returns An array of words
31
+ */
32
+ function getWords(str, options = {}) {
33
+ if (str.length > 5e3) throw new Error("The regular expression parameter of `get-words` can't handle strings longer than 2000 characters");
34
+ return [...str.match(options.split ?? (options.relaxed ? RELAXED_SPLIT_PATTERN : CASE_SPLIT_PATTERN)) ?? []];
35
+ }
36
+
37
+ //#endregion
38
+ exports.getWords = getWords;
@@ -0,0 +1,38 @@
1
+ //#region ../../node_modules/.pnpm/@stryke+string-format@0.16.0/node_modules/@stryke/string-format/dist/get-words.mjs
2
+ /**
3
+ * Regular expression pattern to split strings into words for various case conversions
4
+ *
5
+ * This pattern matches sequences of characters in a string, considering the following case:
6
+ * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)
7
+ * - Sequences of one uppercase letter optionally followed by lowercase letters and digits
8
+ * - Single uppercase letters
9
+ * - Sequences of digits
10
+ *
11
+ * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into
12
+ * a consistent format like snake case.
13
+ *
14
+ * @example
15
+ * const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);
16
+ * // matches: ['camel', 'Case', 'HTTP', 'Request']
17
+ */
18
+ const CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|\d+|[A-Z]+(?![a-z])/g;
19
+ const RELAXED_SPLIT_PATTERN = /[A-Z/.-]?[a-z/.-]+|\d+|[A-Z/.-]+(?![a-z/.-])/g;
20
+ /**
21
+ * Splits a string into words using a regular expression pattern
22
+ *
23
+ * @example
24
+ * const words = getWords('camelCaseHTTPRequest');
25
+ * // words: ['camel', 'Case', 'HTTP', 'Request']
26
+ *
27
+ * @param str - The string to split into words
28
+ * @param options - Options for splitting the string
29
+ * @returns An array of words
30
+ */
31
+ function getWords(str, options = {}) {
32
+ if (str.length > 5e3) throw new Error("The regular expression parameter of `get-words` can't handle strings longer than 2000 characters");
33
+ return [...str.match(options.split ?? (options.relaxed ? RELAXED_SPLIT_PATTERN : CASE_SPLIT_PATTERN)) ?? []];
34
+ }
35
+
36
+ //#endregion
37
+ export { getWords };
38
+ //# sourceMappingURL=get-words.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-words.mjs","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/@stryke+string-format@0.16.0/node_modules/@stryke/string-format/dist/get-words.mjs"],"sourcesContent":["//#region src/get-words.ts\n/**\n* Regular expression pattern to split strings into words for various case conversions\n*\n* This pattern matches sequences of characters in a string, considering the following case:\n* - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)\n* - Sequences of one uppercase letter optionally followed by lowercase letters and digits\n* - Single uppercase letters\n* - Sequences of digits\n*\n* The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into\n* a consistent format like snake case.\n*\n* @example\n* const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);\n* // matches: ['camel', 'Case', 'HTTP', 'Request']\n*/\nconst CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|\\d+|[A-Z]+(?![a-z])/g;\nconst RELAXED_SPLIT_PATTERN = /[A-Z/.-]?[a-z/.-]+|\\d+|[A-Z/.-]+(?![a-z/.-])/g;\n/**\n* Splits a string into words using a regular expression pattern\n*\n* @example\n* const words = getWords('camelCaseHTTPRequest');\n* // words: ['camel', 'Case', 'HTTP', 'Request']\n*\n* @param str - The string to split into words\n* @param options - Options for splitting the string\n* @returns An array of words\n*/\nfunction getWords(str, options = {}) {\n\tif (str.length > 5e3) throw new Error(\"The regular expression parameter of `get-words` can't handle strings longer than 2000 characters\");\n\treturn [...str.match(options.split ?? (options.relaxed ? RELAXED_SPLIT_PATTERN : CASE_SPLIT_PATTERN)) ?? []];\n}\n\n//#endregion\nexport { CASE_SPLIT_PATTERN, RELAXED_SPLIT_PATTERN, getWords };\n//# sourceMappingURL=get-words.mjs.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAM,qBAAqB;AAC3B,MAAM,wBAAwB;;;;;;;;;;;;AAY9B,SAAS,SAAS,KAAK,UAAU,EAAE,EAAE;AACpC,KAAI,IAAI,SAAS,IAAK,OAAM,IAAI,MAAM,mGAAmG;AACzI,QAAO,CAAC,GAAG,IAAI,MAAM,QAAQ,UAAU,QAAQ,UAAU,wBAAwB,oBAAoB,IAAI,EAAE,CAAC"}
@@ -0,0 +1,33 @@
1
+ const require_get_words = require('./get-words.cjs');
2
+
3
+ //#region ../../node_modules/.pnpm/@stryke+string-format@0.16.0/node_modules/@stryke/string-format/dist/kebab-case.mjs
4
+ /**
5
+ * Check if the input string is in kebab case.
6
+ *
7
+ * @remarks
8
+ * Kebab case is defined as all lowercase letters with hyphens separating words - "this-is-an-example".
9
+ *
10
+ * @param input - The input string to check.
11
+ * @returns True if the input is in kebab case, false otherwise.
12
+ */
13
+ function isKebabCase(input) {
14
+ return input ? /^[a-z]+(?:-[a-z0-9]+)*$/.test(input) : false;
15
+ }
16
+ /**
17
+ * Convert the input string to kebab case.
18
+ *
19
+ * @remarks
20
+ * Kebab case is defined as all lowercase letters with hyphens separating words - "this-is-an-example".
21
+ *
22
+ * @param input - The input string.
23
+ * @returns The kebab-cased string.
24
+ */
25
+ function kebabCase(input) {
26
+ if (isKebabCase(input) || input === void 0) return input;
27
+ const parts = input ? require_get_words.getWords(input) : [];
28
+ if (parts.length === 0) return "";
29
+ return parts.join("-").toLowerCase();
30
+ }
31
+
32
+ //#endregion
33
+ exports.kebabCase = kebabCase;
@@ -0,0 +1,34 @@
1
+ import { getWords } from "./get-words.mjs";
2
+
3
+ //#region ../../node_modules/.pnpm/@stryke+string-format@0.16.0/node_modules/@stryke/string-format/dist/kebab-case.mjs
4
+ /**
5
+ * Check if the input string is in kebab case.
6
+ *
7
+ * @remarks
8
+ * Kebab case is defined as all lowercase letters with hyphens separating words - "this-is-an-example".
9
+ *
10
+ * @param input - The input string to check.
11
+ * @returns True if the input is in kebab case, false otherwise.
12
+ */
13
+ function isKebabCase(input) {
14
+ return input ? /^[a-z]+(?:-[a-z0-9]+)*$/.test(input) : false;
15
+ }
16
+ /**
17
+ * Convert the input string to kebab case.
18
+ *
19
+ * @remarks
20
+ * Kebab case is defined as all lowercase letters with hyphens separating words - "this-is-an-example".
21
+ *
22
+ * @param input - The input string.
23
+ * @returns The kebab-cased string.
24
+ */
25
+ function kebabCase(input) {
26
+ if (isKebabCase(input) || input === void 0) return input;
27
+ const parts = input ? getWords(input) : [];
28
+ if (parts.length === 0) return "";
29
+ return parts.join("-").toLowerCase();
30
+ }
31
+
32
+ //#endregion
33
+ export { kebabCase };
34
+ //# sourceMappingURL=kebab-case.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kebab-case.mjs","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/@stryke+string-format@0.16.0/node_modules/@stryke/string-format/dist/kebab-case.mjs"],"sourcesContent":["import { getWords } from \"./get-words.mjs\";\n\n//#region src/kebab-case.ts\n/**\n* Check if the input string is in kebab case.\n*\n* @remarks\n* Kebab case is defined as all lowercase letters with hyphens separating words - \"this-is-an-example\".\n*\n* @param input - The input string to check.\n* @returns True if the input is in kebab case, false otherwise.\n*/\nfunction isKebabCase(input) {\n\treturn input ? /^[a-z]+(?:-[a-z0-9]+)*$/.test(input) : false;\n}\n/**\n* Convert the input string to kebab case.\n*\n* @remarks\n* Kebab case is defined as all lowercase letters with hyphens separating words - \"this-is-an-example\".\n*\n* @param input - The input string.\n* @returns The kebab-cased string.\n*/\nfunction kebabCase(input) {\n\tif (isKebabCase(input) || input === void 0) return input;\n\tconst parts = input ? getWords(input) : [];\n\tif (parts.length === 0) return \"\";\n\treturn parts.join(\"-\").toLowerCase();\n}\n\n//#endregion\nexport { isKebabCase, kebabCase };\n//# sourceMappingURL=kebab-case.mjs.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;AAYA,SAAS,YAAY,OAAO;AAC3B,QAAO,QAAQ,0BAA0B,KAAK,MAAM,GAAG;;;;;;;;;;;AAWxD,SAAS,UAAU,OAAO;AACzB,KAAI,YAAY,MAAM,IAAI,UAAU,KAAK,EAAG,QAAO;CACnD,MAAM,QAAQ,QAAQ,SAAS,MAAM,GAAG,EAAE;AAC1C,KAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,QAAO,MAAM,KAAK,IAAI,CAAC,aAAa"}
@@ -0,0 +1,15 @@
1
+
2
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.34/node_modules/@stryke/type-checks/dist/get-object-tag.mjs
3
+ /**
4
+ * Gets the `toStringTag` of `obj`.
5
+ *
6
+ * @param value - The obj to query.
7
+ * @returns Returns the `toStringTag`.
8
+ */
9
+ const getObjectTag = (value) => {
10
+ if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
11
+ return Object.prototype.toString.call(value);
12
+ };
13
+
14
+ //#endregion
15
+ exports.getObjectTag = getObjectTag;