alchemy 0.41.1 → 0.42.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.
- package/README.md +2 -0
- package/bin/alchemy.mjs +99 -44
- package/lib/build-date.d.ts +1 -1
- package/lib/build-date.js +1 -1
- package/lib/cloudflare/certificate-pack.d.ts +216 -0
- package/lib/cloudflare/certificate-pack.d.ts.map +1 -0
- package/lib/cloudflare/certificate-pack.js +350 -0
- package/lib/cloudflare/certificate-pack.js.map +1 -0
- package/lib/cloudflare/container.d.ts +6 -0
- package/lib/cloudflare/container.d.ts.map +1 -1
- package/lib/cloudflare/container.js +32 -25
- package/lib/cloudflare/container.js.map +1 -1
- package/lib/cloudflare/index.d.ts +3 -0
- package/lib/cloudflare/index.d.ts.map +1 -1
- package/lib/cloudflare/index.js +3 -0
- package/lib/cloudflare/index.js.map +1 -1
- package/lib/cloudflare/orange.d.ts +37 -0
- package/lib/cloudflare/orange.d.ts.map +1 -0
- package/lib/cloudflare/orange.js +48 -0
- package/lib/cloudflare/orange.js.map +1 -0
- package/lib/cloudflare/redirect-rule.d.ts +168 -0
- package/lib/cloudflare/redirect-rule.d.ts.map +1 -0
- package/lib/cloudflare/redirect-rule.js +380 -0
- package/lib/cloudflare/redirect-rule.js.map +1 -0
- package/lib/cloudflare/worker/miniflare-worker-options.d.ts.map +1 -1
- package/lib/cloudflare/worker/miniflare-worker-options.js +11 -12
- package/lib/cloudflare/worker/miniflare-worker-options.js.map +1 -1
- package/lib/cloudflare/worker.d.ts +1 -1
- package/lib/fs/file-system-state-store.d.ts.map +1 -1
- package/lib/fs/file-system-state-store.js +8 -1
- package/lib/fs/file-system-state-store.js.map +1 -1
- package/package.json +1 -1
- package/src/build-date.ts +1 -1
- package/src/cloudflare/certificate-pack.ts +698 -0
- package/src/cloudflare/container.ts +44 -30
- package/src/cloudflare/index.ts +3 -0
- package/src/cloudflare/orange.ts +61 -0
- package/src/cloudflare/redirect-rule.ts +642 -0
- package/src/cloudflare/worker/miniflare-worker-options.ts +14 -12
- package/src/fs/file-system-state-store.ts +8 -1
- package/templates/astro/package.json +1 -1
- package/templates/nuxt/package.json +1 -1
- package/templates/react-router/package.json +1 -1
- package/templates/rwsdk/package.json +1 -1
- package/templates/sveltekit/package.json +1 -1
- package/templates/tanstack-start/package.json +1 -1
- package/templates/typescript/package.json +1 -1
- package/templates/vite/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Assets } from "./assets.js";
|
|
2
|
+
import type { Bindings } from "./bindings.js";
|
|
3
|
+
import { type WebsiteProps } from "./website.js";
|
|
4
|
+
import type { Worker } from "./worker.js";
|
|
5
|
+
export interface OrangeProps<B extends Bindings> extends WebsiteProps<B> {
|
|
6
|
+
}
|
|
7
|
+
export type Orange<B extends Bindings> = B extends {
|
|
8
|
+
ASSETS: any;
|
|
9
|
+
} ? never : Worker<B & {
|
|
10
|
+
ASSETS: Assets;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Deploys an Orange application to Cloudflare Workers.
|
|
14
|
+
*
|
|
15
|
+
* This resource simplifies deploying Orange applications by assuming the build
|
|
16
|
+
* command, main entrypoint, and assets directory based on the `create-orange`
|
|
17
|
+
* template CLI.
|
|
18
|
+
*
|
|
19
|
+
* It wraps the underlying `Website` resource.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Deploy a basic Orange application with default settings
|
|
23
|
+
* const orangeApp = await Orange("my-orange-app");
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Deploy with a database binding
|
|
27
|
+
* const database = await D1Database("orange-db");
|
|
28
|
+
* const orangeApp = await Orange("orange-with-db", {
|
|
29
|
+
* bindings: { DB: database }
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* @param id - Unique identifier for the Orange resource
|
|
33
|
+
* @param props - Configuration properties for the Orange resource
|
|
34
|
+
* @returns A Cloudflare Worker resource representing the deployed Orange application
|
|
35
|
+
*/
|
|
36
|
+
export declare function Orange<B extends Bindings>(id: string, props?: Partial<OrangeProps<B>>): Promise<Orange<B>>;
|
|
37
|
+
//# sourceMappingURL=orange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orange.d.ts","sourceRoot":"","sources":["../../src/cloudflare/orange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,QAAQ,CAAE,SAAQ,YAAY,CAAC,CAAC,CAAC;CAAG;AAG3E,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,QAAQ,IAAI,CAAC,SAAS;IAAE,MAAM,EAAE,GAAG,CAAA;CAAE,GAC9D,KAAK,GACL,MAAM,CAAC,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,MAAM,CAAC,CAAC,SAAS,QAAQ,EAC7C,EAAE,EAAE,MAAM,EACV,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAqBpB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Website } from "./website.js";
|
|
2
|
+
/**
|
|
3
|
+
* Deploys an Orange application to Cloudflare Workers.
|
|
4
|
+
*
|
|
5
|
+
* This resource simplifies deploying Orange applications by assuming the build
|
|
6
|
+
* command, main entrypoint, and assets directory based on the `create-orange`
|
|
7
|
+
* template CLI.
|
|
8
|
+
*
|
|
9
|
+
* It wraps the underlying `Website` resource.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Deploy a basic Orange application with default settings
|
|
13
|
+
* const orangeApp = await Orange("my-orange-app");
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Deploy with a database binding
|
|
17
|
+
* const database = await D1Database("orange-db");
|
|
18
|
+
* const orangeApp = await Orange("orange-with-db", {
|
|
19
|
+
* bindings: { DB: database }
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* @param id - Unique identifier for the Orange resource
|
|
23
|
+
* @param props - Configuration properties for the Orange resource
|
|
24
|
+
* @returns A Cloudflare Worker resource representing the deployed Orange application
|
|
25
|
+
*/
|
|
26
|
+
export async function Orange(id, props) {
|
|
27
|
+
return Website(id, {
|
|
28
|
+
...props,
|
|
29
|
+
command: props?.command ?? "bun run build",
|
|
30
|
+
// The entrypoint and the Wrangler main must differ for the Cloudflare vite plugin
|
|
31
|
+
// to bundle the application correctly, and alchemy must run our bundler on the Vite
|
|
32
|
+
// output since we don't resolve vite imports.
|
|
33
|
+
wrangler: props?.wrangler ?? {
|
|
34
|
+
main: "app/entry.server.ts",
|
|
35
|
+
},
|
|
36
|
+
// Since we've already bundled the application with the build command, we can just
|
|
37
|
+
// upload the modules in the `dist/srr` directory. With `noBundle: true`, any files
|
|
38
|
+
// that match `**/*.js`, `**/*.mjs`, and `**/*.wasm` under the entrypoint's directory
|
|
39
|
+
// (which is `dist/ssr`) will be uploaded to the worker so we don't need any explicit
|
|
40
|
+
// module rules.
|
|
41
|
+
noBundle: true,
|
|
42
|
+
// `main` is used as the entrypoint in the Worker resource.
|
|
43
|
+
main: props?.main ?? "dist/ssr/entry.server.js",
|
|
44
|
+
assets: props?.assets ?? "dist/client",
|
|
45
|
+
compatibilityFlags: ["nodejs_compat", ...(props?.compatibilityFlags ?? [])],
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=orange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orange.js","sourceRoot":"","sources":["../../src/cloudflare/orange.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAqB,MAAM,cAAc,CAAC;AAU1D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,EAAU,EACV,KAA+B;IAE/B,OAAO,OAAO,CAAC,EAAE,EAAE;QACjB,GAAG,KAAK;QACR,OAAO,EAAE,KAAK,EAAE,OAAO,IAAI,eAAe;QAC1C,kFAAkF;QAClF,oFAAoF;QACpF,8CAA8C;QAC9C,QAAQ,EAAE,KAAK,EAAE,QAAQ,IAAI;YAC3B,IAAI,EAAE,qBAAqB;SAC5B;QACD,kFAAkF;QAClF,mFAAmF;QACnF,qFAAqF;QACrF,qFAAqF;QACrF,gBAAgB;QAChB,QAAQ,EAAE,IAAI;QACd,2DAA2D;QAC3D,IAAI,EAAE,KAAK,EAAE,IAAI,IAAI,0BAA0B;QAC/C,MAAM,EAAE,KAAK,EAAE,MAAM,IAAI,aAAa;QACtC,kBAAkB,EAAE,CAAC,eAAe,EAAE,GAAG,CAAC,KAAK,EAAE,kBAAkB,IAAI,EAAE,CAAC,CAAC;KAC5E,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { Context } from "../context.ts";
|
|
2
|
+
import { Resource } from "../resource.ts";
|
|
3
|
+
import { type CloudflareApi, type CloudflareApiOptions } from "./api.ts";
|
|
4
|
+
import type { Zone } from "./zone.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Properties for creating or updating a RedirectRule
|
|
7
|
+
*/
|
|
8
|
+
export interface RedirectRuleProps extends CloudflareApiOptions {
|
|
9
|
+
/**
|
|
10
|
+
* The zone where the redirect rule will be applied
|
|
11
|
+
* Can be a zone ID string or a Zone resource
|
|
12
|
+
*/
|
|
13
|
+
zone: string | Zone;
|
|
14
|
+
/**
|
|
15
|
+
* For wildcard redirects: the URL pattern to match
|
|
16
|
+
* Example: "https://*.example.com/files/*"
|
|
17
|
+
* This is mutually exclusive with `expression`
|
|
18
|
+
*/
|
|
19
|
+
requestUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* For dynamic redirects: a Cloudflare Rules expression
|
|
22
|
+
* Example: 'http.request.uri.path matches "/autodiscover\\.(xml|src)$"'
|
|
23
|
+
* This is mutually exclusive with `requestUrl`
|
|
24
|
+
* @see https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/
|
|
25
|
+
*/
|
|
26
|
+
expression?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The target URL for the redirect
|
|
29
|
+
* Can include placeholders like ${1}, ${2} for wildcard matches
|
|
30
|
+
* Example: "https://example.com/${1}/files/${2}"
|
|
31
|
+
*/
|
|
32
|
+
targetUrl: string;
|
|
33
|
+
/**
|
|
34
|
+
* HTTP status code for the redirect
|
|
35
|
+
* @default 301
|
|
36
|
+
*/
|
|
37
|
+
statusCode?: 301 | 302 | 303 | 307 | 308;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to preserve query string parameters
|
|
40
|
+
* @default true
|
|
41
|
+
*/
|
|
42
|
+
preserveQueryString?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Cloudflare Rule response format
|
|
46
|
+
*/
|
|
47
|
+
interface CloudflareRule {
|
|
48
|
+
id: string;
|
|
49
|
+
version: string;
|
|
50
|
+
action: string;
|
|
51
|
+
expression: string;
|
|
52
|
+
description?: string;
|
|
53
|
+
last_updated: string;
|
|
54
|
+
ref: string;
|
|
55
|
+
enabled: boolean;
|
|
56
|
+
action_parameters?: {
|
|
57
|
+
from_value?: {
|
|
58
|
+
status_code?: number;
|
|
59
|
+
target_url?: {
|
|
60
|
+
value?: string;
|
|
61
|
+
expression?: string;
|
|
62
|
+
};
|
|
63
|
+
preserve_query_string?: boolean;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Output returned after RedirectRule creation/update
|
|
69
|
+
*/
|
|
70
|
+
export interface RedirectRule extends Resource<"cloudflare::RedirectRule"> {
|
|
71
|
+
/**
|
|
72
|
+
* The ID of the redirect rule
|
|
73
|
+
*/
|
|
74
|
+
ruleId: string;
|
|
75
|
+
/**
|
|
76
|
+
* The ID of the ruleset containing this rule
|
|
77
|
+
*/
|
|
78
|
+
rulesetId: string;
|
|
79
|
+
/**
|
|
80
|
+
* The zone ID where the rule is applied
|
|
81
|
+
*/
|
|
82
|
+
zoneId: string;
|
|
83
|
+
/**
|
|
84
|
+
* The request URL pattern (for wildcard redirects)
|
|
85
|
+
*/
|
|
86
|
+
requestUrl?: string;
|
|
87
|
+
/**
|
|
88
|
+
* The expression (for dynamic redirects)
|
|
89
|
+
*/
|
|
90
|
+
expression?: string;
|
|
91
|
+
/**
|
|
92
|
+
* The target URL for the redirect
|
|
93
|
+
*/
|
|
94
|
+
targetUrl: string;
|
|
95
|
+
/**
|
|
96
|
+
* HTTP status code for the redirect
|
|
97
|
+
*/
|
|
98
|
+
statusCode: number;
|
|
99
|
+
/**
|
|
100
|
+
* Whether query string parameters are preserved
|
|
101
|
+
*/
|
|
102
|
+
preserveQueryString: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Whether the rule is enabled
|
|
105
|
+
*/
|
|
106
|
+
enabled: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Time when the rule was last updated
|
|
109
|
+
*/
|
|
110
|
+
lastUpdated: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* A Cloudflare Redirect Rule enables URL redirects and rewrites using Cloudflare's Rules engine.
|
|
114
|
+
* Supports wildcard redirects, static redirects, and dynamic redirects with expressions.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ## Wildcard Redirect
|
|
118
|
+
*
|
|
119
|
+
* Redirect from a wildcard pattern to a target URL with placeholders.
|
|
120
|
+
*
|
|
121
|
+
* ```ts
|
|
122
|
+
* const wildcardRedirect = await RedirectRule("my-wildcard-redirect", {
|
|
123
|
+
* zone: "example.com",
|
|
124
|
+
* requestUrl: "https://*.example.com/files/*",
|
|
125
|
+
* targetUrl: "https://example.com/${1}/files/${2}",
|
|
126
|
+
* statusCode: 301,
|
|
127
|
+
* preserveQueryString: true
|
|
128
|
+
* });
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ## Static Redirect
|
|
133
|
+
*
|
|
134
|
+
* Simple redirect from any request to a static target URL.
|
|
135
|
+
*
|
|
136
|
+
* ```ts
|
|
137
|
+
* const staticRedirect = await RedirectRule("my-static-redirect", {
|
|
138
|
+
* zone: "example.com",
|
|
139
|
+
* targetUrl: "https://example.com/",
|
|
140
|
+
* statusCode: 301,
|
|
141
|
+
* preserveQueryString: true
|
|
142
|
+
* });
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ## Dynamic Redirect with Expression
|
|
147
|
+
*
|
|
148
|
+
* Complex redirect using Cloudflare's Rules language for advanced matching.
|
|
149
|
+
*
|
|
150
|
+
* ```ts
|
|
151
|
+
* const dynamicRedirect = await RedirectRule("my-dynamic-redirect", {
|
|
152
|
+
* zone: "example.com",
|
|
153
|
+
* expression: 'http.request.uri.path matches "/autodiscover\\.(xml|src)$"',
|
|
154
|
+
* targetUrl: "https://example.com/not-found",
|
|
155
|
+
* statusCode: 301,
|
|
156
|
+
* preserveQueryString: true
|
|
157
|
+
* });
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @see https://developers.cloudflare.com/rules/url-forwarding/single-redirects/
|
|
161
|
+
*/
|
|
162
|
+
export declare const RedirectRule: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<RedirectRule>, _id: string, props: RedirectRuleProps) => Promise<RedirectRule>);
|
|
163
|
+
/**
|
|
164
|
+
* Find a specific rule in a ruleset
|
|
165
|
+
*/
|
|
166
|
+
export declare function findRuleInRuleset(api: CloudflareApi, zoneId: string, rulesetId: string, ruleId: string): Promise<CloudflareRule | null>;
|
|
167
|
+
export {};
|
|
168
|
+
//# sourceMappingURL=redirect-rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirect-rule.d.ts","sourceRoot":"","sources":["../../src/cloudflare/redirect-rule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAC1B,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC7D;;;OAGG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,UAAU,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAEzC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAgBD;;GAEG;AACH,UAAU,cAAc;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,CAAC,EAAE;QAClB,UAAU,CAAC,EAAE;YACX,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,UAAU,CAAC,EAAE;gBACX,KAAK,CAAC,EAAE,MAAM,CAAC;gBACf,UAAU,CAAC,EAAE,MAAM,CAAC;aACrB,CAAC;YACF,qBAAqB,CAAC,EAAE,OAAO,CAAC;SACjC,CAAC;KACH,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,QAAQ,CAAC,0BAA0B,CAAC;IACxE;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,mBAAmB,EAAE,OAAO,CAAC;IAE7B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,YAAY,yFAGf,OAAO,CAAC,YAAY,CAAC,OACtB,MAAM,SACJ,iBAAiB,KACvB,OAAO,CAAC,YAAY,CAAC,CAmGzB,CAAC;AAiNF;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAchC"}
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { Resource } from "../resource.js";
|
|
2
|
+
import { createCloudflareApi, } from "./api.js";
|
|
3
|
+
/**
|
|
4
|
+
* A Cloudflare Redirect Rule enables URL redirects and rewrites using Cloudflare's Rules engine.
|
|
5
|
+
* Supports wildcard redirects, static redirects, and dynamic redirects with expressions.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ## Wildcard Redirect
|
|
9
|
+
*
|
|
10
|
+
* Redirect from a wildcard pattern to a target URL with placeholders.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const wildcardRedirect = await RedirectRule("my-wildcard-redirect", {
|
|
14
|
+
* zone: "example.com",
|
|
15
|
+
* requestUrl: "https://*.example.com/files/*",
|
|
16
|
+
* targetUrl: "https://example.com/${1}/files/${2}",
|
|
17
|
+
* statusCode: 301,
|
|
18
|
+
* preserveQueryString: true
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ## Static Redirect
|
|
24
|
+
*
|
|
25
|
+
* Simple redirect from any request to a static target URL.
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* const staticRedirect = await RedirectRule("my-static-redirect", {
|
|
29
|
+
* zone: "example.com",
|
|
30
|
+
* targetUrl: "https://example.com/",
|
|
31
|
+
* statusCode: 301,
|
|
32
|
+
* preserveQueryString: true
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ## Dynamic Redirect with Expression
|
|
38
|
+
*
|
|
39
|
+
* Complex redirect using Cloudflare's Rules language for advanced matching.
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* const dynamicRedirect = await RedirectRule("my-dynamic-redirect", {
|
|
43
|
+
* zone: "example.com",
|
|
44
|
+
* expression: 'http.request.uri.path matches "/autodiscover\\.(xml|src)$"',
|
|
45
|
+
* targetUrl: "https://example.com/not-found",
|
|
46
|
+
* statusCode: 301,
|
|
47
|
+
* preserveQueryString: true
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @see https://developers.cloudflare.com/rules/url-forwarding/single-redirects/
|
|
52
|
+
*/
|
|
53
|
+
export const RedirectRule = Resource("cloudflare::RedirectRule", async function (_id, props) {
|
|
54
|
+
// Create Cloudflare API client
|
|
55
|
+
const api = await createCloudflareApi(props);
|
|
56
|
+
// Get zone ID
|
|
57
|
+
const zoneId = typeof props.zone === "string" ? props.zone : props.zone.id;
|
|
58
|
+
if (this.phase === "delete") {
|
|
59
|
+
if (this.output?.ruleId && this.output?.rulesetId) {
|
|
60
|
+
// Let delete errors propagate instead of swallowing them
|
|
61
|
+
await deleteRedirectRule(api, zoneId, this.output.rulesetId, this.output.ruleId);
|
|
62
|
+
}
|
|
63
|
+
return this.destroy();
|
|
64
|
+
}
|
|
65
|
+
// Validate props
|
|
66
|
+
if (props.requestUrl && props.expression) {
|
|
67
|
+
throw new Error("Cannot specify both requestUrl and expression. Use requestUrl for wildcard redirects or expression for dynamic redirects.");
|
|
68
|
+
}
|
|
69
|
+
const statusCode = props.statusCode ?? 301;
|
|
70
|
+
const preserveQueryString = props.preserveQueryString ?? true;
|
|
71
|
+
// Build the rule expression
|
|
72
|
+
let ruleExpression;
|
|
73
|
+
if (props.requestUrl) {
|
|
74
|
+
// Convert wildcard URL to Cloudflare expression
|
|
75
|
+
ruleExpression = convertWildcardUrlToExpression(props.requestUrl);
|
|
76
|
+
}
|
|
77
|
+
else if (props.expression) {
|
|
78
|
+
ruleExpression = props.expression;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// Static redirect - match all requests
|
|
82
|
+
ruleExpression = "true";
|
|
83
|
+
}
|
|
84
|
+
if (this.phase === "update" &&
|
|
85
|
+
this.output?.ruleId &&
|
|
86
|
+
this.output?.rulesetId) {
|
|
87
|
+
// Update existing rule
|
|
88
|
+
const updatedRule = await updateRedirectRule(api, zoneId, this.output.rulesetId, this.output.ruleId, {
|
|
89
|
+
expression: ruleExpression,
|
|
90
|
+
targetUrl: props.targetUrl,
|
|
91
|
+
statusCode,
|
|
92
|
+
preserveQueryString,
|
|
93
|
+
});
|
|
94
|
+
return this({
|
|
95
|
+
ruleId: updatedRule.id,
|
|
96
|
+
rulesetId: this.output.rulesetId,
|
|
97
|
+
zoneId,
|
|
98
|
+
requestUrl: props.requestUrl,
|
|
99
|
+
expression: props.expression,
|
|
100
|
+
targetUrl: props.targetUrl,
|
|
101
|
+
statusCode,
|
|
102
|
+
preserveQueryString,
|
|
103
|
+
enabled: updatedRule.enabled ?? true,
|
|
104
|
+
lastUpdated: updatedRule.last_updated,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
// Get or create the redirect ruleset for this zone
|
|
108
|
+
const rulesetId = await getOrCreateRedirectRuleset(api, zoneId);
|
|
109
|
+
// Create the rule
|
|
110
|
+
const createdRule = await createRedirectRule(api, zoneId, rulesetId, {
|
|
111
|
+
expression: ruleExpression,
|
|
112
|
+
targetUrl: props.targetUrl,
|
|
113
|
+
statusCode,
|
|
114
|
+
preserveQueryString,
|
|
115
|
+
});
|
|
116
|
+
return this({
|
|
117
|
+
ruleId: createdRule.id,
|
|
118
|
+
rulesetId,
|
|
119
|
+
zoneId,
|
|
120
|
+
requestUrl: props.requestUrl,
|
|
121
|
+
expression: props.expression,
|
|
122
|
+
targetUrl: props.targetUrl,
|
|
123
|
+
statusCode,
|
|
124
|
+
preserveQueryString,
|
|
125
|
+
enabled: createdRule.enabled ?? true,
|
|
126
|
+
lastUpdated: createdRule.last_updated,
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
/**
|
|
130
|
+
* Get existing redirect ruleset for a zone
|
|
131
|
+
*/
|
|
132
|
+
async function getRedirectRuleset(api, zoneId) {
|
|
133
|
+
const response = await api.get(`/zones/${zoneId}/rulesets`);
|
|
134
|
+
if (!response.ok) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
const result = (await response.json());
|
|
138
|
+
const redirectRuleset = result.result.find((ruleset) => ruleset.phase === "http_request_dynamic_redirect");
|
|
139
|
+
return redirectRuleset?.id || null;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Create a new redirect ruleset for a zone
|
|
143
|
+
*/
|
|
144
|
+
async function createRedirectRuleset(api, zoneId) {
|
|
145
|
+
const response = await api.post(`/zones/${zoneId}/rulesets`, {
|
|
146
|
+
name: "Zone-level redirect ruleset",
|
|
147
|
+
description: "Redirect rules for the zone",
|
|
148
|
+
kind: "zone",
|
|
149
|
+
phase: "http_request_dynamic_redirect",
|
|
150
|
+
});
|
|
151
|
+
if (!response.ok) {
|
|
152
|
+
throw new Error(`Failed to create redirect ruleset: ${response.statusText}`);
|
|
153
|
+
}
|
|
154
|
+
const result = (await response.json());
|
|
155
|
+
return result.result.id;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Get or create the redirect ruleset for a zone
|
|
159
|
+
*/
|
|
160
|
+
async function getOrCreateRedirectRuleset(api, zoneId) {
|
|
161
|
+
const existingRulesetId = await getRedirectRuleset(api, zoneId);
|
|
162
|
+
if (existingRulesetId) {
|
|
163
|
+
return existingRulesetId;
|
|
164
|
+
}
|
|
165
|
+
return await createRedirectRuleset(api, zoneId);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Create a new redirect rule by updating the ruleset
|
|
169
|
+
*/
|
|
170
|
+
async function createRedirectRule(api, zoneId, rulesetId, ruleData) {
|
|
171
|
+
// Get current ruleset
|
|
172
|
+
const ruleset = await getRuleset(api, zoneId, rulesetId);
|
|
173
|
+
if (!ruleset) {
|
|
174
|
+
throw new Error(`Ruleset ${rulesetId} not found`);
|
|
175
|
+
}
|
|
176
|
+
// Create new rule object
|
|
177
|
+
const newRule = {
|
|
178
|
+
action: "redirect",
|
|
179
|
+
expression: ruleData.expression,
|
|
180
|
+
action_parameters: {
|
|
181
|
+
from_value: {
|
|
182
|
+
status_code: ruleData.statusCode,
|
|
183
|
+
target_url: {
|
|
184
|
+
value: ruleData.targetUrl,
|
|
185
|
+
},
|
|
186
|
+
preserve_query_string: ruleData.preserveQueryString,
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
enabled: true,
|
|
190
|
+
};
|
|
191
|
+
// Update ruleset with new rule
|
|
192
|
+
const response = await api.put(`/zones/${zoneId}/rulesets/${rulesetId}`, {
|
|
193
|
+
name: ruleset.name,
|
|
194
|
+
description: ruleset.description,
|
|
195
|
+
kind: ruleset.kind,
|
|
196
|
+
phase: ruleset.phase,
|
|
197
|
+
rules: [...ruleset.rules, newRule],
|
|
198
|
+
});
|
|
199
|
+
if (!response.ok) {
|
|
200
|
+
const errorBody = await response.text();
|
|
201
|
+
throw new Error(`Failed to create redirect rule: ${response.statusText}\nResponse: ${errorBody}`);
|
|
202
|
+
}
|
|
203
|
+
const result = (await response.json());
|
|
204
|
+
// Return the last rule (the one we just added)
|
|
205
|
+
const createdRule = result.result.rules[result.result.rules.length - 1];
|
|
206
|
+
return createdRule;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Update an existing redirect rule by updating the ruleset
|
|
210
|
+
*/
|
|
211
|
+
async function updateRedirectRule(api, zoneId, rulesetId, ruleId, ruleData) {
|
|
212
|
+
// Get current ruleset
|
|
213
|
+
const ruleset = await getRuleset(api, zoneId, rulesetId);
|
|
214
|
+
if (!ruleset) {
|
|
215
|
+
throw new Error(`Ruleset ${rulesetId} not found`);
|
|
216
|
+
}
|
|
217
|
+
// Find and update the rule
|
|
218
|
+
const updatedRules = ruleset.rules.map((rule) => {
|
|
219
|
+
if (rule.id === ruleId) {
|
|
220
|
+
return {
|
|
221
|
+
...rule,
|
|
222
|
+
action: "redirect",
|
|
223
|
+
expression: ruleData.expression,
|
|
224
|
+
action_parameters: {
|
|
225
|
+
from_value: {
|
|
226
|
+
status_code: ruleData.statusCode,
|
|
227
|
+
target_url: {
|
|
228
|
+
value: ruleData.targetUrl,
|
|
229
|
+
},
|
|
230
|
+
preserve_query_string: ruleData.preserveQueryString,
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
enabled: true,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
return rule;
|
|
237
|
+
});
|
|
238
|
+
// Update ruleset with modified rules
|
|
239
|
+
const response = await api.put(`/zones/${zoneId}/rulesets/${rulesetId}`, {
|
|
240
|
+
name: ruleset.name,
|
|
241
|
+
description: ruleset.description,
|
|
242
|
+
kind: ruleset.kind,
|
|
243
|
+
phase: ruleset.phase,
|
|
244
|
+
rules: updatedRules,
|
|
245
|
+
});
|
|
246
|
+
if (!response.ok) {
|
|
247
|
+
throw new Error(`Failed to update redirect rule: ${response.statusText}`);
|
|
248
|
+
}
|
|
249
|
+
const result = (await response.json());
|
|
250
|
+
// Find and return the updated rule
|
|
251
|
+
const updatedRule = result.result.rules.find((rule) => rule.id === ruleId);
|
|
252
|
+
if (!updatedRule) {
|
|
253
|
+
throw new Error(`Updated rule ${ruleId} not found in response`);
|
|
254
|
+
}
|
|
255
|
+
return updatedRule;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Get a ruleset with its rules
|
|
259
|
+
*/
|
|
260
|
+
async function getRuleset(api, zoneId, rulesetId) {
|
|
261
|
+
const response = await api.get(`/zones/${zoneId}/rulesets/${rulesetId}`);
|
|
262
|
+
if (!response.ok) {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
const result = (await response.json());
|
|
266
|
+
return result.result;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Find a specific rule in a ruleset
|
|
270
|
+
*/
|
|
271
|
+
export async function findRuleInRuleset(api, zoneId, rulesetId, ruleId) {
|
|
272
|
+
const response = await api.get(`/zones/${zoneId}/rulesets/${rulesetId}`);
|
|
273
|
+
if (!response.ok) {
|
|
274
|
+
throw new Error(`Failed to get ruleset: ${response.status} ${response.statusText}`);
|
|
275
|
+
}
|
|
276
|
+
const rulesetData = (await response.json());
|
|
277
|
+
const rule = rulesetData.result.rules.find((r) => r.id === ruleId);
|
|
278
|
+
return rule || null;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Delete a redirect rule by updating the ruleset to exclude it
|
|
282
|
+
*/
|
|
283
|
+
async function deleteRedirectRule(api, zoneId, rulesetId, ruleId) {
|
|
284
|
+
const ruleset = await getRuleset(api, zoneId, rulesetId);
|
|
285
|
+
if (!ruleset) {
|
|
286
|
+
throw new Error(`Ruleset ${rulesetId} not found for deletion`);
|
|
287
|
+
}
|
|
288
|
+
// Filter out the rule to delete
|
|
289
|
+
const updatedRules = ruleset.rules.filter((rule) => rule.id !== ruleId);
|
|
290
|
+
// Update the ruleset with the filtered rules
|
|
291
|
+
const response = await api.put(`/zones/${zoneId}/rulesets/${rulesetId}`, {
|
|
292
|
+
name: ruleset.name,
|
|
293
|
+
description: ruleset.description,
|
|
294
|
+
kind: ruleset.kind,
|
|
295
|
+
phase: ruleset.phase,
|
|
296
|
+
rules: updatedRules,
|
|
297
|
+
});
|
|
298
|
+
if (!response.ok) {
|
|
299
|
+
throw new Error(`Failed to delete redirect rule: ${response.statusText}`);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Convert a wildcard URL pattern to a Cloudflare Rules expression
|
|
304
|
+
* Uses operators available on Free plans (no regex matching)
|
|
305
|
+
*/
|
|
306
|
+
function convertWildcardUrlToExpression(wildcardUrl) {
|
|
307
|
+
// Parse the URL to extract components
|
|
308
|
+
const url = new URL(wildcardUrl);
|
|
309
|
+
const hostname = url.hostname;
|
|
310
|
+
const pathname = url.pathname;
|
|
311
|
+
let expression = "";
|
|
312
|
+
// Handle hostname wildcards
|
|
313
|
+
if (hostname.includes("*")) {
|
|
314
|
+
// For simple wildcard patterns, use contains or ends_with operators
|
|
315
|
+
if (hostname.startsWith("*")) {
|
|
316
|
+
// *.example.com -> http.host ends_with ".example.com"
|
|
317
|
+
const suffix = hostname.substring(1); // Remove the *
|
|
318
|
+
expression += `http.host ends_with "${suffix}"`;
|
|
319
|
+
}
|
|
320
|
+
else if (hostname.endsWith("*")) {
|
|
321
|
+
// subdomain.* -> http.host starts_with "subdomain."
|
|
322
|
+
const prefix = hostname.substring(0, hostname.length - 1); // Remove the *
|
|
323
|
+
expression += `http.host starts_with "${prefix}"`;
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
// More complex wildcards - fallback to a broader match
|
|
327
|
+
const parts = hostname.split("*");
|
|
328
|
+
if (parts.length === 2) {
|
|
329
|
+
expression += `http.host starts_with "${parts[0]}" and http.host ends_with "${parts[1]}"`;
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
// Fallback to domain contains for complex patterns
|
|
333
|
+
const baseDomain = hostname.replace(/^\*\./, "").replace(/\.\*$/, "");
|
|
334
|
+
expression += `http.host contains "${baseDomain}"`;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
expression += `http.host == "${hostname}"`;
|
|
340
|
+
}
|
|
341
|
+
// Handle pathname wildcards
|
|
342
|
+
if (pathname.includes("*")) {
|
|
343
|
+
if (pathname.endsWith("*")) {
|
|
344
|
+
// /files/* -> starts_with "/files/"
|
|
345
|
+
const prefix = pathname.substring(0, pathname.length - 1); // Remove the *
|
|
346
|
+
expression += ` and http.request.uri.path starts_with "${prefix}"`;
|
|
347
|
+
}
|
|
348
|
+
else if (pathname.startsWith("*")) {
|
|
349
|
+
// *.html -> ends_with ".html"
|
|
350
|
+
const suffix = pathname.substring(1); // Remove the *
|
|
351
|
+
expression += ` and http.request.uri.path ends_with "${suffix}"`;
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
// More complex wildcards - use contains
|
|
355
|
+
const parts = pathname.split("*");
|
|
356
|
+
if (parts.length === 2 && parts[0] && parts[1]) {
|
|
357
|
+
expression += ` and http.request.uri.path starts_with "${parts[0]}" and http.request.uri.path ends_with "${parts[1]}"`;
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
// Fallback to contains for the non-wildcard part
|
|
361
|
+
const nonWildcardPart = parts.find((part) => part.length > 0) || "";
|
|
362
|
+
if (nonWildcardPart) {
|
|
363
|
+
expression += ` and http.request.uri.path contains "${nonWildcardPart}"`;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
else if (pathname !== "/") {
|
|
369
|
+
expression += ` and http.request.uri.path == "${pathname}"`;
|
|
370
|
+
}
|
|
371
|
+
// Handle protocol
|
|
372
|
+
if (url.protocol === "https:") {
|
|
373
|
+
expression += " and ssl";
|
|
374
|
+
}
|
|
375
|
+
else if (url.protocol === "http:") {
|
|
376
|
+
expression += " and not ssl";
|
|
377
|
+
}
|
|
378
|
+
return expression;
|
|
379
|
+
}
|
|
380
|
+
//# sourceMappingURL=redirect-rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirect-rule.js","sourceRoot":"","sources":["../../src/cloudflare/redirect-rule.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACL,mBAAmB,GAGpB,MAAM,UAAU,CAAC;AA8IlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAClC,0BAA0B,EAC1B,KAAK,WAEH,GAAW,EACX,KAAwB;IAExB,+BAA+B;IAC/B,MAAM,GAAG,GAAG,MAAM,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAE7C,cAAc;IACd,MAAM,MAAM,GAAG,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;IAE3E,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,IAAI,IAAI,CAAC,MAAM,EAAE,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC;YAClD,yDAAyD;YACzD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IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC9B,UAAU,IAAI,UAAU,CAAC;IAC3B,CAAC;SAAM,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACpC,UAAU,IAAI,cAAc,CAAC;IAC/B,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"miniflare-worker-options.d.ts","sourceRoot":"","sources":["../../../src/cloudflare/worker/miniflare-worker-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AAInB,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACvC,WAAW,EACT,UAAU,GACV,cAAc,GACd,mBAAmB,GACnB,oBAAoB,GACpB,QAAQ,CACX,GAAG;IACF,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AA4BF,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,IAAI,CAAC,sBAAsB,EAAE,UAAU,CAAC,uBAWhD;AAkJD,wBAAgB,2BAA2B,CAAC,EAC1C,IAAI,EAAE,UAAU,EAChB,MAAM,EACN,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,2BAA2B,GAC5B,EAAE,sBAAsB,GAAG;IAC1B,2BAA2B,EAAE,2BAA2B,GAAG,SAAS,CAAC;CACtE,GAAG,aAAa,
|
|
1
|
+
{"version":3,"file":"miniflare-worker-options.d.ts","sourceRoot":"","sources":["../../../src/cloudflare/worker/miniflare-worker-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AAInB,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACvC,WAAW,EACT,UAAU,GACV,cAAc,GACd,mBAAmB,GACnB,oBAAoB,GACpB,QAAQ,CACX,GAAG;IACF,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AA4BF,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,IAAI,CAAC,sBAAsB,EAAE,UAAU,CAAC,uBAWhD;AAkJD,wBAAgB,2BAA2B,CAAC,EAC1C,IAAI,EAAE,UAAU,EAChB,MAAM,EACN,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,2BAA2B,GAC5B,EAAE,sBAAsB,GAAG;IAC1B,2BAA2B,EAAE,2BAA2B,GAAG,SAAS,CAAC;CACtE,GAAG,aAAa,CAqVhB"}
|