wrangler 0.0.0-ef949392 → 0.0.0-ef9fbba3
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/bin/wrangler.js +5 -0
- package/package.json +39 -20
- package/templates/gitignore +0 -5
- package/templates/init-tests/test-vitest-new-worker.js +1 -1
- package/templates/init-tests/test-vitest-new-worker.ts +1 -1
- package/templates/middleware/loader-modules.ts +3 -4
- package/templates/middleware/loader-sw.ts +4 -3
- package/templates/middleware/middleware-ensure-req-body-drained.ts +19 -0
- package/templates/middleware/middleware-multiworker-dev.ts +37 -28
- package/templates/middleware/middleware-serve-static-assets.ts +5 -5
- package/templates/modules-watch-stub.js +4 -0
- package/templates/pages-dev-pipeline.ts +2 -1
- package/templates/startDevWorker/InspectorProxyWorker.ts +661 -0
- package/templates/startDevWorker/ProxyWorker.ts +326 -0
- package/wrangler-dist/InspectorProxyWorker.js +464 -0
- package/wrangler-dist/InspectorProxyWorker.js.map +6 -0
- package/wrangler-dist/ProxyWorker.js +237 -0
- package/wrangler-dist/ProxyWorker.js.map +6 -0
- package/wrangler-dist/cli.d.ts +22335 -136
- package/wrangler-dist/cli.js +82564 -61606
package/bin/wrangler.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrangler",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-ef9fbba3",
|
|
4
4
|
"description": "Command-line interface for all things Cloudflare Workers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wrangler",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
]
|
|
76
76
|
},
|
|
77
77
|
"transformIgnorePatterns": [
|
|
78
|
-
"node_modules/.pnpm/(?!find-up|locate-path|p-locate|p-limit|p-timeout|p-queue|yocto-queue|path-exists|execa|strip-final-newline|npm-run-path|path-key|onetime|mimic-fn|human-signals|is-stream|get-port|supports-color|pretty-bytes|
|
|
78
|
+
"node_modules/.pnpm/(?!find-up|locate-path|p-locate|p-limit|p-timeout|p-queue|yocto-queue|path-exists|execa|strip-final-newline|npm-run-path|path-key|onetime|mimic-fn|human-signals|is-stream|get-port|supports-color|pretty-bytes|strip-ansi|ansi-regex)"
|
|
79
79
|
],
|
|
80
80
|
"snapshotFormat": {
|
|
81
81
|
"escapeString": true,
|
|
@@ -83,26 +83,32 @@
|
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@cloudflare/kv-asset-handler": "^0.2.0",
|
|
87
86
|
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
|
88
87
|
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
|
|
89
88
|
"blake3-wasm": "^2.1.5",
|
|
90
89
|
"chokidar": "^3.5.3",
|
|
91
90
|
"esbuild": "0.17.19",
|
|
92
|
-
"miniflare": "3.20230918.0",
|
|
93
91
|
"nanoid": "^3.3.3",
|
|
94
92
|
"path-to-regexp": "^6.2.0",
|
|
93
|
+
"resolve": "^1.22.8",
|
|
94
|
+
"resolve.exports": "^2.0.2",
|
|
95
95
|
"selfsigned": "^2.0.1",
|
|
96
96
|
"source-map": "0.6.1",
|
|
97
|
-
"
|
|
98
|
-
"
|
|
97
|
+
"xxhash-wasm": "^1.0.1",
|
|
98
|
+
"@cloudflare/kv-asset-handler": "0.3.1",
|
|
99
|
+
"miniflare": "3.20240329.0"
|
|
99
100
|
},
|
|
100
101
|
"devDependencies": {
|
|
102
|
+
"@cloudflare/ai": "^1.0.35",
|
|
101
103
|
"@cloudflare/eslint-config-worker": "*",
|
|
102
104
|
"@cloudflare/types": "^6.18.4",
|
|
103
|
-
"@cloudflare/workers-types": "^4.
|
|
105
|
+
"@cloudflare/workers-types": "^4.20240320.1",
|
|
106
|
+
"@cspotcode/source-map-support": "0.8.1",
|
|
104
107
|
"@iarna/toml": "^3.0.0",
|
|
105
108
|
"@microsoft/api-extractor": "^7.28.3",
|
|
109
|
+
"@sentry/node": "^7.86.0",
|
|
110
|
+
"@sentry/types": "^7.86.0",
|
|
111
|
+
"@sentry/utils": "^7.86.0",
|
|
106
112
|
"@types/body-parser": "^1.19.2",
|
|
107
113
|
"@types/busboy": "^1.5.0",
|
|
108
114
|
"@types/command-exists": "^1.2.0",
|
|
@@ -110,20 +116,20 @@
|
|
|
110
116
|
"@types/glob-to-regexp": "0.4.1",
|
|
111
117
|
"@types/is-ci": "^3.0.0",
|
|
112
118
|
"@types/javascript-time-ago": "^2.0.3",
|
|
119
|
+
"@types/jest": "^29.5.5",
|
|
113
120
|
"@types/mime": "^2.0.3",
|
|
114
121
|
"@types/minimatch": "^5.1.2",
|
|
115
122
|
"@types/prompts": "^2.0.14",
|
|
116
123
|
"@types/react": "^17.0.37",
|
|
124
|
+
"@types/resolve": "^1.20.6",
|
|
117
125
|
"@types/serve-static": "^1.13.10",
|
|
126
|
+
"@types/shell-quote": "^1.7.2",
|
|
118
127
|
"@types/signal-exit": "^3.0.1",
|
|
119
128
|
"@types/source-map-support": "^0.5.7",
|
|
120
129
|
"@types/supports-color": "^8.1.1",
|
|
121
130
|
"@types/ws": "^8.5.3",
|
|
122
131
|
"@types/yargs": "^17.0.10",
|
|
123
132
|
"@webcontainer/env": "^1.1.0",
|
|
124
|
-
"@types/jest": "^29.5.5",
|
|
125
|
-
"esbuild-jest": "0.5.0",
|
|
126
|
-
"jest": "^29.7.0",
|
|
127
133
|
"body-parser": "^1.20.0",
|
|
128
134
|
"chalk": "^2.4.2",
|
|
129
135
|
"cli-table3": "^0.6.3",
|
|
@@ -133,6 +139,7 @@
|
|
|
133
139
|
"concurrently": "^7.2.2",
|
|
134
140
|
"devtools-protocol": "^0.0.955664",
|
|
135
141
|
"dotenv": "^16.0.0",
|
|
142
|
+
"esbuild-jest": "0.5.0",
|
|
136
143
|
"execa": "^6.1.0",
|
|
137
144
|
"express": "^4.18.1",
|
|
138
145
|
"finalhandler": "^1.2.0",
|
|
@@ -140,6 +147,7 @@
|
|
|
140
147
|
"get-port": "^6.1.2",
|
|
141
148
|
"glob-to-regexp": "0.4.1",
|
|
142
149
|
"http-terminator": "^3.2.0",
|
|
150
|
+
"https-proxy-agent": "7.0.2",
|
|
143
151
|
"ignore": "^5.2.0",
|
|
144
152
|
"ink": "^3.2.0",
|
|
145
153
|
"ink-select-input": "^4.2.1",
|
|
@@ -149,12 +157,12 @@
|
|
|
149
157
|
"ink-text-input": "^4.0.3",
|
|
150
158
|
"is-ci": "^3.0.1",
|
|
151
159
|
"javascript-time-ago": "^2.5.4",
|
|
160
|
+
"jest": "^29.7.0",
|
|
152
161
|
"jest-fetch-mock": "^3.0.3",
|
|
153
162
|
"jest-websocket-mock": "^2.5.0",
|
|
154
163
|
"mime": "^3.0.0",
|
|
155
164
|
"minimatch": "^5.1.0",
|
|
156
165
|
"msw": "^0.49.1",
|
|
157
|
-
"npx-import": "^1.1.3",
|
|
158
166
|
"open": "^8.4.0",
|
|
159
167
|
"p-queue": "^7.2.0",
|
|
160
168
|
"patch-console": "^1.0.0",
|
|
@@ -165,28 +173,39 @@
|
|
|
165
173
|
"remove-accents-esm": "^0.0.1",
|
|
166
174
|
"semiver": "^1.1.0",
|
|
167
175
|
"serve-static": "^1.15.0",
|
|
176
|
+
"shell-quote": "^1.8.1",
|
|
168
177
|
"shellac": "^0.8.0",
|
|
169
178
|
"signal-exit": "^3.0.7",
|
|
170
179
|
"strip-ansi": "^7.0.1",
|
|
171
180
|
"supports-color": "^9.2.2",
|
|
172
181
|
"timeago.js": "^4.0.2",
|
|
173
|
-
"tmp-promise": "^3.0.3",
|
|
174
182
|
"ts-dedent": "^2.2.0",
|
|
175
|
-
"undici": "5.
|
|
183
|
+
"undici": "5.28.3",
|
|
176
184
|
"update-check": "^1.5.4",
|
|
177
|
-
"vitest": "^0.34.4",
|
|
178
185
|
"ws": "^8.5.0",
|
|
179
186
|
"xdg-app-paths": "^8.3.0",
|
|
180
|
-
"yargs": "^17.
|
|
187
|
+
"yargs": "^17.7.2",
|
|
181
188
|
"yoga-layout": "file:../../vendor/yoga-layout-2.0.0-beta.1.tgz",
|
|
182
|
-
"@cloudflare/
|
|
189
|
+
"@cloudflare/cli": "1.1.1",
|
|
190
|
+
"@cloudflare/pages-shared": "^0.11.23",
|
|
183
191
|
"@cloudflare/workers-tsconfig": "0.0.0"
|
|
184
192
|
},
|
|
185
193
|
"optionalDependencies": {
|
|
186
194
|
"fsevents": "~2.3.2"
|
|
187
195
|
},
|
|
196
|
+
"peerDependencies": {
|
|
197
|
+
"@cloudflare/workers-types": "^4.20240320.1"
|
|
198
|
+
},
|
|
199
|
+
"peerDependenciesMeta": {
|
|
200
|
+
"@cloudflare/workers-types": {
|
|
201
|
+
"optional": true
|
|
202
|
+
}
|
|
203
|
+
},
|
|
188
204
|
"engines": {
|
|
189
|
-
"node": ">=16.
|
|
205
|
+
"node": ">=16.17.0"
|
|
206
|
+
},
|
|
207
|
+
"workers-sdk": {
|
|
208
|
+
"prerelease": true
|
|
190
209
|
},
|
|
191
210
|
"scripts": {
|
|
192
211
|
"assert-git-version": "node -r esbuild-register scripts/assert-git-version.ts",
|
|
@@ -195,14 +214,14 @@
|
|
|
195
214
|
"check:lint": "eslint .",
|
|
196
215
|
"check:type": "tsc",
|
|
197
216
|
"clean": "rimraf wrangler-dist miniflare-dist emitted-types",
|
|
198
|
-
"dev": "pnpm run clean && concurrently -c black,blue --kill-others-on-fail false
|
|
217
|
+
"dev": "pnpm run clean && concurrently -c black,blue --kill-others-on-fail false \"pnpm run bundle --watch\" \"pnpm run check:type --watch --preserveWatchOutput\"",
|
|
199
218
|
"emit-types": "tsc -p tsconfig.emit.json && node -r esbuild-register scripts/emit-types.ts",
|
|
200
219
|
"start": "pnpm run bundle && cross-env NODE_OPTIONS=--enable-source-maps ./bin/wrangler.js",
|
|
201
220
|
"test": "pnpm run assert-git-version && jest",
|
|
202
221
|
"test:ci": "pnpm run test --coverage",
|
|
203
222
|
"test:debug": "pnpm run test --silent=false --verbose=true",
|
|
204
|
-
"test:e2e": "vitest
|
|
205
|
-
"test:watch": "pnpm run test --
|
|
223
|
+
"test:e2e": "vitest -c ./e2e/vitest.config.ts",
|
|
224
|
+
"test:watch": "pnpm run test --testTimeout=50000 --watch",
|
|
206
225
|
"type:tests": "tsc -p ./src/__tests__/tsconfig.json && tsc -p ./e2e/tsconfig.json"
|
|
207
226
|
}
|
|
208
227
|
}
|
package/templates/gitignore
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
1
2
|
import { unstable_dev } from "wrangler";
|
|
2
3
|
import type { UnstableDevWorker } from "wrangler";
|
|
3
|
-
import { describe, expect, it, beforeAll, afterAll } from "vitest";
|
|
4
4
|
|
|
5
5
|
describe("Worker", () => {
|
|
6
6
|
let worker: UnstableDevWorker;
|
|
@@ -4,15 +4,14 @@
|
|
|
4
4
|
// // through wrangler, or we can potentially let users directly add them as a sort
|
|
5
5
|
// // of "plugin" system.
|
|
6
6
|
|
|
7
|
+
import worker from "__ENTRY_POINT__";
|
|
7
8
|
import {
|
|
8
|
-
Dispatcher,
|
|
9
|
-
Middleware,
|
|
10
9
|
__facade_invoke__,
|
|
11
10
|
__facade_register__,
|
|
11
|
+
Dispatcher,
|
|
12
|
+
Middleware,
|
|
12
13
|
} from "./common";
|
|
13
14
|
|
|
14
|
-
import worker from "__ENTRY_POINT__";
|
|
15
|
-
|
|
16
15
|
// We need to preserve all of the exports from the worker
|
|
17
16
|
export * from "__ENTRY_POINT__";
|
|
18
17
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
__facade_invoke__,
|
|
3
|
+
__facade_register__,
|
|
4
|
+
__facade_registerInternal__,
|
|
2
5
|
Awaitable,
|
|
3
6
|
Dispatcher,
|
|
4
7
|
IncomingRequest,
|
|
5
8
|
Middleware,
|
|
6
|
-
__facade_invoke__,
|
|
7
|
-
__facade_register__,
|
|
8
|
-
__facade_registerInternal__,
|
|
9
9
|
} from "./common";
|
|
10
|
+
|
|
10
11
|
export { __facade_register__, __facade_registerInternal__ };
|
|
11
12
|
|
|
12
13
|
// Miniflare 2's `EventTarget` follows the spec and doesn't allow exceptions to
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Middleware } from "./common";
|
|
2
|
+
|
|
3
|
+
const drainBody: Middleware = async (request, env, _ctx, middlewareCtx) => {
|
|
4
|
+
try {
|
|
5
|
+
return await middlewareCtx.next(request, env);
|
|
6
|
+
} finally {
|
|
7
|
+
try {
|
|
8
|
+
if (request.body !== null && !request.bodyUsed) {
|
|
9
|
+
const reader = request.body.getReader();
|
|
10
|
+
while (!(await reader.read()).done) {}
|
|
11
|
+
}
|
|
12
|
+
} catch (e) {
|
|
13
|
+
console.error("Failed to drain the unused request body.", e);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default drainBody;
|
|
19
|
+
export const wrap = undefined;
|
|
@@ -4,6 +4,42 @@
|
|
|
4
4
|
import { workers } from "config:middleware/multiworker-dev";
|
|
5
5
|
import type { WorkerRegistry } from "../../src/dev-registry";
|
|
6
6
|
|
|
7
|
+
class Fetcher {
|
|
8
|
+
#name: string;
|
|
9
|
+
#details: WorkerRegistry[string];
|
|
10
|
+
constructor(name: string, details: WorkerRegistry[string]) {
|
|
11
|
+
this.#name = name;
|
|
12
|
+
this.#details = details;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async fetch(...reqArgs: Parameters<Fetcher["fetch"]>) {
|
|
16
|
+
const reqFromArgs = new Request(...reqArgs);
|
|
17
|
+
if (this.#details.headers) {
|
|
18
|
+
for (const [key, value] of Object.entries(this.#details.headers)) {
|
|
19
|
+
// In remote mode, you need to add a couple of headers
|
|
20
|
+
// to make sure it's talking to the 'dev' preview session
|
|
21
|
+
// (much like wrangler dev already does via proxy.ts)
|
|
22
|
+
reqFromArgs.headers.set(key, value);
|
|
23
|
+
}
|
|
24
|
+
return (env[this.#name] as Fetcher).fetch(reqFromArgs);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const url = new URL(reqFromArgs.url);
|
|
28
|
+
if (this.#details.protocol !== undefined) {
|
|
29
|
+
url.protocol = this.#details.protocol;
|
|
30
|
+
}
|
|
31
|
+
if (this.#details.host !== undefined) {
|
|
32
|
+
url.host = this.#details.host;
|
|
33
|
+
}
|
|
34
|
+
if (this.#details.port !== undefined) {
|
|
35
|
+
url.port = this.#details.port.toString();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const request = new Request(url.toString(), reqFromArgs);
|
|
39
|
+
return fetch(request);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
7
43
|
export function wrap(env: Record<string, unknown>) {
|
|
8
44
|
const facadeEnv = { ...env };
|
|
9
45
|
// For every Worker definition that's available,
|
|
@@ -14,34 +50,7 @@ export function wrap(env: Record<string, unknown>) {
|
|
|
14
50
|
|
|
15
51
|
for (const [name, details] of Object.entries(workers as WorkerRegistry)) {
|
|
16
52
|
if (details) {
|
|
17
|
-
facadeEnv[name] =
|
|
18
|
-
async fetch(...reqArgs: Parameters<Fetcher["fetch"]>) {
|
|
19
|
-
const reqFromArgs = new Request(...reqArgs);
|
|
20
|
-
if (details.headers) {
|
|
21
|
-
for (const [key, value] of Object.entries(details.headers)) {
|
|
22
|
-
// In remote mode, you need to add a couple of headers
|
|
23
|
-
// to make sure it's talking to the 'dev' preview session
|
|
24
|
-
// (much like wrangler dev already does via proxy.ts)
|
|
25
|
-
reqFromArgs.headers.set(key, value);
|
|
26
|
-
}
|
|
27
|
-
return (env[name] as Fetcher).fetch(reqFromArgs);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const url = new URL(reqFromArgs.url);
|
|
31
|
-
if (details.protocol !== undefined) {
|
|
32
|
-
url.protocol = details.protocol;
|
|
33
|
-
}
|
|
34
|
-
if (details.host !== undefined) {
|
|
35
|
-
url.host = details.host;
|
|
36
|
-
}
|
|
37
|
-
if (details.port !== undefined) {
|
|
38
|
-
url.port = details.port.toString();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const request = new Request(url.toString(), reqFromArgs);
|
|
42
|
-
return fetch(request);
|
|
43
|
-
},
|
|
44
|
-
};
|
|
53
|
+
facadeEnv[name] = new Fetcher(name, details);
|
|
45
54
|
} else {
|
|
46
55
|
// This means there's no dev binding available.
|
|
47
56
|
// Let's use whatever's available, or put a shim with a message.
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/// <reference path="middleware-serve-static-assets.d.ts"/>
|
|
2
2
|
|
|
3
|
+
import manifest from "__STATIC_CONTENT_MANIFEST";
|
|
3
4
|
import {
|
|
4
5
|
getAssetFromKV,
|
|
5
|
-
NotFoundError,
|
|
6
6
|
MethodNotAllowedError,
|
|
7
|
+
NotFoundError,
|
|
7
8
|
serveSinglePageApp,
|
|
8
9
|
} from "@cloudflare/kv-asset-handler";
|
|
10
|
+
import { cacheControl, spaMode } from "config:middleware/serve-static-assets";
|
|
11
|
+
import type { Middleware } from "./common";
|
|
9
12
|
import type { Options } from "@cloudflare/kv-asset-handler";
|
|
10
|
-
import { spaMode, cacheControl } from "config:middleware/serve-static-assets";
|
|
11
13
|
import type * as kvAssetHandler from "@cloudflare/kv-asset-handler";
|
|
12
|
-
import manifest from "__STATIC_CONTENT_MANIFEST";
|
|
13
|
-
const ASSET_MANIFEST = JSON.parse(manifest);
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const ASSET_MANIFEST = JSON.parse(manifest);
|
|
16
16
|
|
|
17
17
|
const staticAssets: Middleware = async (request, env, _ctx, middlewareCtx) => {
|
|
18
18
|
let options: Partial<Options> = {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// @ts-ignore entry point will get replaced
|
|
2
2
|
import worker from "__ENTRY_POINT__";
|
|
3
|
+
import { isRoutingRuleMatch } from "./pages-dev-util";
|
|
4
|
+
|
|
3
5
|
// @ts-ignore entry point will get replaced
|
|
4
6
|
export * from "__ENTRY_POINT__";
|
|
5
|
-
import { isRoutingRuleMatch } from "./pages-dev-util";
|
|
6
7
|
|
|
7
8
|
// @ts-ignore routes are injected
|
|
8
9
|
const routes = __ROUTES__;
|