wrangler 4.131.1 → 4.132.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/config-schema.json +20 -73
- package/package.json +24 -19
- package/templates/middleware/loader-sw.ts +52 -18
- package/wrangler-dist/cli.d.ts +14 -20
- package/wrangler-dist/cli.js +30844 -30096
- package/wrangler-dist/experimental-config.d.mts +215 -34
- package/wrangler-dist/experimental-config.d.mts.map +1 -1
- package/wrangler-dist/experimental-config.mjs +11 -8
- package/wrangler-dist/experimental-config.mjs.map +1 -1
- package/templates/__tests__/pages-dev-util.test.ts +0 -124
- package/templates/__tests__/tsconfig-sanity.ts +0 -12
- package/templates/__tests__/tsconfig.json +0 -8
- package/templates/facade.d.ts +0 -19
- package/templates/middleware/middleware-patch-console-prefix.d.ts +0 -3
- package/templates/new-worker-scheduled.js +0 -17
- package/templates/new-worker-scheduled.ts +0 -32
- package/templates/new-worker.js +0 -15
- package/templates/new-worker.ts +0 -33
- package/templates/startDevWorker/InspectorProxyWorker.ts +0 -713
- package/templates/startDevWorker/ProxyWorker.ts +0 -478
- package/templates/tsconfig-sanity.ts +0 -11
- package/templates/tsconfig.init.json +0 -22
- package/templates/tsconfig.json +0 -14
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { isRoutingRuleMatch } from "../pages-dev-util";
|
|
2
|
-
|
|
3
|
-
describe("isRoutingRuleMatch", () => {
|
|
4
|
-
it("should match rules referencing root level correctly", () => {
|
|
5
|
-
const routingRule = "/";
|
|
6
|
-
|
|
7
|
-
expect(isRoutingRuleMatch("/", routingRule)).toBeTruthy();
|
|
8
|
-
expect(isRoutingRuleMatch("/foo", routingRule)).toBeFalsy();
|
|
9
|
-
expect(isRoutingRuleMatch("/foo/", routingRule)).toBeFalsy();
|
|
10
|
-
expect(isRoutingRuleMatch("/foo/bar", routingRule)).toBeFalsy();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("should match include-all rules correctly", () => {
|
|
14
|
-
const routingRule = "/*";
|
|
15
|
-
|
|
16
|
-
expect(isRoutingRuleMatch("/", routingRule)).toBeTruthy();
|
|
17
|
-
expect(isRoutingRuleMatch("/foo", routingRule)).toBeTruthy();
|
|
18
|
-
expect(isRoutingRuleMatch("/foo/", routingRule)).toBeTruthy();
|
|
19
|
-
expect(isRoutingRuleMatch("/foo/bar", routingRule)).toBeTruthy();
|
|
20
|
-
expect(isRoutingRuleMatch("/foo/bar/", routingRule)).toBeTruthy();
|
|
21
|
-
expect(isRoutingRuleMatch("/foo/bar/baz", routingRule)).toBeTruthy();
|
|
22
|
-
expect(isRoutingRuleMatch("/foo/bar/baz/", routingRule)).toBeTruthy();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("should match `/*` suffix-ed rules correctly", () => {
|
|
26
|
-
let routingRule = "/foo/*";
|
|
27
|
-
|
|
28
|
-
expect(isRoutingRuleMatch("/foo", routingRule)).toBeTruthy();
|
|
29
|
-
expect(isRoutingRuleMatch("/foo/", routingRule)).toBeTruthy();
|
|
30
|
-
expect(isRoutingRuleMatch("/foobar", routingRule)).toBeFalsy();
|
|
31
|
-
expect(isRoutingRuleMatch("/foo/bar", routingRule)).toBeTruthy();
|
|
32
|
-
expect(isRoutingRuleMatch("/foo/bar/baz", routingRule)).toBeTruthy();
|
|
33
|
-
expect(isRoutingRuleMatch("/bar/foo", routingRule)).toBeFalsy();
|
|
34
|
-
expect(isRoutingRuleMatch("/bar/foo/baz", routingRule)).toBeFalsy();
|
|
35
|
-
|
|
36
|
-
routingRule = "/foo/bar/*";
|
|
37
|
-
|
|
38
|
-
expect(isRoutingRuleMatch("/foo", routingRule)).toBeFalsy();
|
|
39
|
-
expect(isRoutingRuleMatch("/foo/", routingRule)).toBeFalsy();
|
|
40
|
-
expect(isRoutingRuleMatch("/foo/bar", routingRule)).toBeTruthy();
|
|
41
|
-
expect(isRoutingRuleMatch("/foo/bar/baz", routingRule)).toBeTruthy();
|
|
42
|
-
expect(isRoutingRuleMatch("/foo/barfoo", routingRule)).toBeFalsy();
|
|
43
|
-
expect(isRoutingRuleMatch("baz/foo/bar", routingRule)).toBeFalsy();
|
|
44
|
-
expect(isRoutingRuleMatch("baz/foo/bar/", routingRule)).toBeFalsy();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("should match `/` suffix-ed rules correctly", () => {
|
|
48
|
-
let routingRule = "/foo/";
|
|
49
|
-
expect(isRoutingRuleMatch("/foo/", routingRule)).toBeTruthy();
|
|
50
|
-
expect(isRoutingRuleMatch("/foo", routingRule)).toBeTruthy();
|
|
51
|
-
|
|
52
|
-
routingRule = "/foo/bar/";
|
|
53
|
-
expect(isRoutingRuleMatch("/foo/bar/", routingRule)).toBeTruthy();
|
|
54
|
-
expect(isRoutingRuleMatch("/foo/bar", routingRule)).toBeTruthy();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("should match `*` suffix-ed rules correctly", () => {
|
|
58
|
-
let routingRule = "/foo*";
|
|
59
|
-
expect(isRoutingRuleMatch("/foo", routingRule)).toBeTruthy();
|
|
60
|
-
expect(isRoutingRuleMatch("/foo/", routingRule)).toBeTruthy();
|
|
61
|
-
expect(isRoutingRuleMatch("/foobar", routingRule)).toBeTruthy();
|
|
62
|
-
expect(isRoutingRuleMatch("/barfoo", routingRule)).toBeFalsy();
|
|
63
|
-
expect(isRoutingRuleMatch("/foo/bar", routingRule)).toBeTruthy();
|
|
64
|
-
expect(isRoutingRuleMatch("/bar/foo", routingRule)).toBeFalsy();
|
|
65
|
-
expect(isRoutingRuleMatch("/bar/foobar", routingRule)).toBeFalsy();
|
|
66
|
-
expect(isRoutingRuleMatch("/foo/bar/baz", routingRule)).toBeTruthy();
|
|
67
|
-
expect(isRoutingRuleMatch("/bar/foo/baz", routingRule)).toBeFalsy();
|
|
68
|
-
|
|
69
|
-
routingRule = "/foo/bar*";
|
|
70
|
-
expect(isRoutingRuleMatch("/foo/bar", routingRule)).toBeTruthy();
|
|
71
|
-
expect(isRoutingRuleMatch("/foo/bar/", routingRule)).toBeTruthy();
|
|
72
|
-
expect(isRoutingRuleMatch("/foo/barfoo", routingRule)).toBeTruthy();
|
|
73
|
-
expect(isRoutingRuleMatch("/bar/foo/barfoo", routingRule)).toBeFalsy();
|
|
74
|
-
expect(isRoutingRuleMatch("/foo/bar/baz", routingRule)).toBeTruthy();
|
|
75
|
-
expect(isRoutingRuleMatch("/bar/foo/bar/baz", routingRule)).toBeFalsy();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("should match rules without wildcards correctly", () => {
|
|
79
|
-
let routingRule = "/foo";
|
|
80
|
-
|
|
81
|
-
expect(isRoutingRuleMatch("/foo", routingRule)).toBeTruthy();
|
|
82
|
-
expect(isRoutingRuleMatch("/foo/", routingRule)).toBeTruthy();
|
|
83
|
-
expect(isRoutingRuleMatch("/foo/bar", routingRule)).toBeFalsy();
|
|
84
|
-
expect(isRoutingRuleMatch("/bar/foo", routingRule)).toBeFalsy();
|
|
85
|
-
|
|
86
|
-
routingRule = "/foo/bar";
|
|
87
|
-
expect(isRoutingRuleMatch("/foo/bar", routingRule)).toBeTruthy();
|
|
88
|
-
expect(isRoutingRuleMatch("/foo/bar/", routingRule)).toBeTruthy();
|
|
89
|
-
expect(isRoutingRuleMatch("/foo/bar/baz", routingRule)).toBeFalsy();
|
|
90
|
-
expect(isRoutingRuleMatch("/baz/foo/bar", routingRule)).toBeFalsy();
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("should throw an error if pathname or routing rule params are missing", () => {
|
|
94
|
-
// MISSING PATHNAME
|
|
95
|
-
expect(() =>
|
|
96
|
-
// @ts-expect-error -- Intentionally testing invalid types
|
|
97
|
-
isRoutingRuleMatch(undefined, "/*")
|
|
98
|
-
).toThrow("Pathname is undefined.");
|
|
99
|
-
|
|
100
|
-
expect(() =>
|
|
101
|
-
// @ts-expect-error -- Intentionally testing invalid types
|
|
102
|
-
isRoutingRuleMatch(null, "/*")
|
|
103
|
-
).toThrow("Pathname is undefined.");
|
|
104
|
-
|
|
105
|
-
expect(() => isRoutingRuleMatch("", "/*")).toThrow(
|
|
106
|
-
"Pathname is undefined."
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
// MISSING ROUTING RULE
|
|
110
|
-
expect(() =>
|
|
111
|
-
// @ts-expect-error -- Intentionally testing invalid types
|
|
112
|
-
isRoutingRuleMatch("/foo", undefined)
|
|
113
|
-
).toThrow("Routing rule is undefined.");
|
|
114
|
-
|
|
115
|
-
expect(() =>
|
|
116
|
-
// @ts-expect-error -- Intentionally testing invalid types
|
|
117
|
-
isRoutingRuleMatch("/foo", null)
|
|
118
|
-
).toThrow("Routing rule is undefined.");
|
|
119
|
-
|
|
120
|
-
expect(() => isRoutingRuleMatch("/foo", "")).toThrow(
|
|
121
|
-
"Routing rule is undefined."
|
|
122
|
-
);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// `@types/node` should be included
|
|
2
|
-
Buffer.from("test");
|
|
3
|
-
|
|
4
|
-
// `@types/jest` should be included
|
|
5
|
-
test("test");
|
|
6
|
-
|
|
7
|
-
// @ts-expect-error `@cloudflare/workers-types` should NOT be included
|
|
8
|
-
const _handler: ExportedHandler = {};
|
|
9
|
-
// @ts-expect-error `@cloudflare/workers-types` should NOT be included
|
|
10
|
-
new HTMLRewriter();
|
|
11
|
-
|
|
12
|
-
export {};
|
package/templates/facade.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
declare module "__ENTRY_POINT__" {
|
|
2
|
-
import { WorkerEntrypoint } from "cloudflare:workers";
|
|
3
|
-
import { Middleware } from "./middleware/common";
|
|
4
|
-
|
|
5
|
-
export type WorkerEntrypointConstructor = typeof WorkerEntrypoint;
|
|
6
|
-
|
|
7
|
-
const worker: ExportedHandler | WorkerEntrypointConstructor;
|
|
8
|
-
export default worker;
|
|
9
|
-
export const __INTERNAL_WRANGLER_MIDDLEWARE__: Middleware[];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare module "__KV_ASSET_HANDLER__" {
|
|
13
|
-
export * from "@cloudflare/kv-asset-handler";
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declare module "__STATIC_CONTENT_MANIFEST" {
|
|
17
|
-
const manifest: string;
|
|
18
|
-
export default manifest;
|
|
19
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Welcome to Cloudflare Workers! This is your first scheduled worker.
|
|
3
|
-
*
|
|
4
|
-
* - Run `wrangler dev` in your terminal to start a development server
|
|
5
|
-
* - Run `curl "http://localhost:8787/cdn-cgi/local/scheduled"` to trigger the scheduled event
|
|
6
|
-
* - Go back to the console to see what your worker has logged
|
|
7
|
-
* - Update the Cron trigger in wrangler.toml (see https://developers.cloudflare.com/workers/configuration/cron-triggers/)
|
|
8
|
-
* - Run `wrangler publish --name my-worker` to publish your worker
|
|
9
|
-
*
|
|
10
|
-
* Learn more at https://developers.cloudflare.com/workers/runtime-apis/scheduled-event/
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export default {
|
|
14
|
-
async scheduled(controller, env, ctx) {
|
|
15
|
-
console.log(`Hello World!`);
|
|
16
|
-
},
|
|
17
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Welcome to Cloudflare Workers! This is your first scheduled worker.
|
|
3
|
-
*
|
|
4
|
-
* - Run `wrangler dev` in your terminal to start a development server
|
|
5
|
-
* - Run `curl "http://localhost:8787/cdn-cgi/local/scheduled"` to trigger the scheduled event
|
|
6
|
-
* - Go back to the console to see what your worker has logged
|
|
7
|
-
* - Update the Cron trigger in wrangler.toml (see https://developers.cloudflare.com/workers/configuration/cron-triggers/)
|
|
8
|
-
* - Run `wrangler deploy --name my-worker` to deploy your worker
|
|
9
|
-
*
|
|
10
|
-
* Learn more at https://developers.cloudflare.com/workers/runtime-apis/scheduled-event/
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export interface Env {
|
|
14
|
-
// Example binding to KV. Learn more at https://developers.cloudflare.com/workers/runtime-apis/kv/
|
|
15
|
-
// MY_KV_NAMESPACE: KVNamespace;
|
|
16
|
-
//
|
|
17
|
-
// Example binding to Durable Object. Learn more at https://developers.cloudflare.com/workers/runtime-apis/durable-objects/
|
|
18
|
-
// MY_DURABLE_OBJECT: DurableObjectNamespace;
|
|
19
|
-
//
|
|
20
|
-
// Example binding to R2. Learn more at https://developers.cloudflare.com/workers/runtime-apis/r2/
|
|
21
|
-
// MY_BUCKET: R2Bucket;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default {
|
|
25
|
-
async scheduled(
|
|
26
|
-
controller: ScheduledController,
|
|
27
|
-
env: Env,
|
|
28
|
-
ctx: ExecutionContext
|
|
29
|
-
): Promise<void> {
|
|
30
|
-
console.log(`Hello World!`);
|
|
31
|
-
},
|
|
32
|
-
};
|
package/templates/new-worker.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Welcome to Cloudflare Workers! This is your first worker.
|
|
3
|
-
*
|
|
4
|
-
* - Run `npx wrangler dev src/index.js` in your terminal to start a development server
|
|
5
|
-
* - Open a browser tab at http://localhost:8787/ to see your worker in action
|
|
6
|
-
* - Run `npx wrangler publish src/index.js --name my-worker` to publish your worker
|
|
7
|
-
*
|
|
8
|
-
* Learn more at https://developers.cloudflare.com/workers/
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export default {
|
|
12
|
-
async fetch(request, env, ctx) {
|
|
13
|
-
return new Response("Hello World!");
|
|
14
|
-
},
|
|
15
|
-
};
|
package/templates/new-worker.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Welcome to Cloudflare Workers! This is your first worker.
|
|
3
|
-
*
|
|
4
|
-
* - Run `wrangler dev src/index.ts` in your terminal to start a development server
|
|
5
|
-
* - Open a browser tab at http://localhost:8787/ to see your worker in action
|
|
6
|
-
* - Run `wrangler deploy src/index.ts --name my-worker` to deploy your worker
|
|
7
|
-
*
|
|
8
|
-
* Learn more at https://developers.cloudflare.com/workers/
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export interface Env {
|
|
12
|
-
// Example binding to KV. Learn more at https://developers.cloudflare.com/workers/runtime-apis/kv/
|
|
13
|
-
// MY_KV_NAMESPACE: KVNamespace;
|
|
14
|
-
//
|
|
15
|
-
// Example binding to Durable Object. Learn more at https://developers.cloudflare.com/workers/runtime-apis/durable-objects/
|
|
16
|
-
// MY_DURABLE_OBJECT: DurableObjectNamespace;
|
|
17
|
-
//
|
|
18
|
-
// Example binding to R2. Learn more at https://developers.cloudflare.com/workers/runtime-apis/r2/
|
|
19
|
-
// MY_BUCKET: R2Bucket;
|
|
20
|
-
//
|
|
21
|
-
// Example binding to a Service. Learn more at https://developers.cloudflare.com/workers/runtime-apis/service-bindings/
|
|
22
|
-
// MY_SERVICE: Fetcher;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default {
|
|
26
|
-
async fetch(
|
|
27
|
-
request: Request,
|
|
28
|
-
env: Env,
|
|
29
|
-
ctx: ExecutionContext
|
|
30
|
-
): Promise<Response> {
|
|
31
|
-
return new Response("Hello World!");
|
|
32
|
-
},
|
|
33
|
-
};
|