wrangler 0.0.0-fd084bc0 → 0.0.0-fd0fb230
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/package.json +13 -5
- package/templates/startDevWorker/ProxyWorker.ts +97 -34
- package/wrangler-dist/ProxyWorker.js +64 -24
- package/wrangler-dist/ProxyWorker.js.map +1 -1
- package/wrangler-dist/cli.d.ts +68 -24
- package/wrangler-dist/cli.js +1345 -650
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrangler",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-fd0fb230",
|
|
4
4
|
"description": "Command-line interface for all things Cloudflare Workers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wrangler",
|
|
@@ -83,7 +83,6 @@
|
|
|
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",
|
|
@@ -96,7 +95,8 @@
|
|
|
96
95
|
"selfsigned": "^2.0.1",
|
|
97
96
|
"source-map": "0.6.1",
|
|
98
97
|
"xxhash-wasm": "^1.0.1",
|
|
99
|
-
"
|
|
98
|
+
"@cloudflare/kv-asset-handler": "0.3.1",
|
|
99
|
+
"miniflare": "3.20240129.3"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@cloudflare/ai": "^1.0.35",
|
|
@@ -187,12 +187,20 @@
|
|
|
187
187
|
"yargs": "^17.7.2",
|
|
188
188
|
"yoga-layout": "file:../../vendor/yoga-layout-2.0.0-beta.1.tgz",
|
|
189
189
|
"@cloudflare/cli": "1.1.1",
|
|
190
|
-
"@cloudflare/pages-shared": "^0.11.
|
|
190
|
+
"@cloudflare/pages-shared": "^0.11.13",
|
|
191
191
|
"@cloudflare/workers-tsconfig": "0.0.0"
|
|
192
192
|
},
|
|
193
193
|
"optionalDependencies": {
|
|
194
194
|
"fsevents": "~2.3.2"
|
|
195
195
|
},
|
|
196
|
+
"peerDependencies": {
|
|
197
|
+
"@cloudflare/workers-types": "^4.20230914.0"
|
|
198
|
+
},
|
|
199
|
+
"peerDependenciesMeta": {
|
|
200
|
+
"@cloudflare/workers-types": {
|
|
201
|
+
"optional": true
|
|
202
|
+
}
|
|
203
|
+
},
|
|
196
204
|
"engines": {
|
|
197
205
|
"node": ">=16.17.0"
|
|
198
206
|
},
|
|
@@ -212,7 +220,7 @@
|
|
|
212
220
|
"test": "pnpm run assert-git-version && jest",
|
|
213
221
|
"test:ci": "pnpm run test --coverage",
|
|
214
222
|
"test:debug": "pnpm run test --silent=false --verbose=true",
|
|
215
|
-
"test:e2e": "vitest --test-timeout 240000 --
|
|
223
|
+
"test:e2e": "vitest --test-timeout 240000 --poolOptions.threads.singleThread --dir ./e2e --retry 2 run",
|
|
216
224
|
"test:watch": "pnpm run test --testTimeout=50000 --watch",
|
|
217
225
|
"type:tests": "tsc -p ./src/__tests__/tsconfig.json && tsc -p ./e2e/tsconfig.json"
|
|
218
226
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
1
|
import {
|
|
3
2
|
createDeferred,
|
|
4
3
|
DeferredPromise,
|
|
4
|
+
urlFromParts,
|
|
5
5
|
} from "../../src/api/startDevWorker/utils";
|
|
6
6
|
import type {
|
|
7
7
|
ProxyData,
|
|
@@ -37,6 +37,7 @@ export class ProxyWorker implements DurableObject {
|
|
|
37
37
|
|
|
38
38
|
proxyData?: ProxyData;
|
|
39
39
|
requestQueue = new Map<Request, DeferredPromise<Response>>();
|
|
40
|
+
requestRetryQueue = new Map<Request, DeferredPromise<Response>>();
|
|
40
41
|
|
|
41
42
|
fetch(request: Request) {
|
|
42
43
|
if (isRequestForLiveReloadWebsocket(request)) {
|
|
@@ -94,17 +95,29 @@ export class ProxyWorker implements DurableObject {
|
|
|
94
95
|
return new Response(null, { status: 204 });
|
|
95
96
|
}
|
|
96
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Process requests that are being retried first, then process newer requests.
|
|
100
|
+
* Requests that are being retried are, by definition, older than requests which haven't been processed yet.
|
|
101
|
+
* We don't need to be more accurate than this re ordering, since the requests are being fired off synchronously.
|
|
102
|
+
*/
|
|
103
|
+
*getOrderedQueue() {
|
|
104
|
+
yield* this.requestRetryQueue;
|
|
105
|
+
yield* this.requestQueue;
|
|
106
|
+
}
|
|
107
|
+
|
|
97
108
|
processQueue() {
|
|
98
|
-
const { proxyData } = this; //
|
|
109
|
+
const { proxyData } = this; // store proxyData at the moment this function was called
|
|
99
110
|
if (proxyData === undefined) return;
|
|
100
111
|
|
|
101
|
-
for (const [request, deferredResponse] of this.
|
|
112
|
+
for (const [request, deferredResponse] of this.getOrderedQueue()) {
|
|
113
|
+
this.requestRetryQueue.delete(request);
|
|
102
114
|
this.requestQueue.delete(request);
|
|
103
115
|
|
|
104
|
-
const
|
|
116
|
+
const outerUrl = new URL(request.url);
|
|
105
117
|
const headers = new Headers(request.headers);
|
|
106
118
|
|
|
107
119
|
// override url parts for proxying
|
|
120
|
+
const userWorkerUrl = new URL(request.url);
|
|
108
121
|
Object.assign(userWorkerUrl, proxyData.userWorkerUrl);
|
|
109
122
|
|
|
110
123
|
// set request.url in the UserWorker
|
|
@@ -113,8 +126,12 @@ export class ProxyWorker implements DurableObject {
|
|
|
113
126
|
headers.set("MF-Original-URL", innerUrl.href);
|
|
114
127
|
headers.set("MF-Disable-Pretty-Error", "true"); // disables the UserWorker miniflare instance from rendering the pretty error -- instead the ProxyWorker miniflare instance will intercept the json error response and render the pretty error page
|
|
115
128
|
|
|
129
|
+
rewriteUrlRelatedHeaders(headers, outerUrl, innerUrl);
|
|
130
|
+
|
|
116
131
|
// merge proxyData headers with the request headers
|
|
117
132
|
for (const [key, value] of Object.entries(proxyData.headers ?? {})) {
|
|
133
|
+
if (value === undefined) continue;
|
|
134
|
+
|
|
118
135
|
if (key.toLowerCase() === "cookie") {
|
|
119
136
|
const existing = request.headers.get("cookie") ?? "";
|
|
120
137
|
headers.set("cookie", `${existing};${value}`);
|
|
@@ -123,10 +140,12 @@ export class ProxyWorker implements DurableObject {
|
|
|
123
140
|
}
|
|
124
141
|
}
|
|
125
142
|
|
|
126
|
-
// explicitly NOT await-ing this promise, we are in a loop and want to process the whole queue quickly
|
|
127
|
-
// if we decide to await, we should include a timeout (~100ms) in case the user worker has long-running/parellel requests
|
|
143
|
+
// explicitly NOT await-ing this promise, we are in a loop and want to process the whole queue quickly + synchronously
|
|
128
144
|
void fetch(userWorkerUrl, new Request(request, { headers }))
|
|
129
145
|
.then((res) => {
|
|
146
|
+
res = new Response(res.body, res);
|
|
147
|
+
rewriteUrlRelatedHeaders(res.headers, innerUrl, outerUrl);
|
|
148
|
+
|
|
130
149
|
if (isHtmlResponse(res)) {
|
|
131
150
|
res = insertLiveReloadScript(request, res, this.env, proxyData);
|
|
132
151
|
}
|
|
@@ -137,17 +156,55 @@ export class ProxyWorker implements DurableObject {
|
|
|
137
156
|
// errors here are network errors or from response post-processing
|
|
138
157
|
// to catch only network errors, use the 2nd param of the fetch.then()
|
|
139
158
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
159
|
+
// we have crossed an async boundary, so proxyData may have changed
|
|
160
|
+
// if proxyData.userWorkerUrl has changed, it means there is a new downstream UserWorker
|
|
161
|
+
// and that this error is stale since it was for a request to the old UserWorker
|
|
162
|
+
// so here we construct a newUserWorkerUrl so we can compare it to the (old) userWorkerUrl
|
|
163
|
+
const newUserWorkerUrl =
|
|
164
|
+
this.proxyData && urlFromParts(this.proxyData.userWorkerUrl);
|
|
165
|
+
|
|
166
|
+
// only report errors if the downstream proxy has NOT changed
|
|
167
|
+
if (userWorkerUrl.href === newUserWorkerUrl?.href) {
|
|
168
|
+
void sendMessageToProxyController(this.env, {
|
|
169
|
+
type: "error",
|
|
170
|
+
error: {
|
|
171
|
+
name: error.name,
|
|
172
|
+
message: error.message,
|
|
173
|
+
stack: error.stack,
|
|
174
|
+
cause: error.cause,
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
deferredResponse.reject(error);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// if the request can be retried (subset of idempotent requests which have no body), requeue it
|
|
182
|
+
else if (request.method === "GET" || request.method === "HEAD") {
|
|
183
|
+
this.requestRetryQueue.set(request, deferredResponse);
|
|
184
|
+
// we would only end up here if the downstream UserWorker is chang*ing*
|
|
185
|
+
// i.e. we are in a `pause`d state and expecting a `play` message soon
|
|
186
|
+
// this request will be processed (retried) when the `play` message arrives
|
|
187
|
+
// for that reason, we do not need to call `this.processQueue` here
|
|
188
|
+
// (but, also, it can't hurt to call it since it bails when
|
|
189
|
+
// in a `pause`d state i.e. `this.proxyData` is undefined)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// if the request cannot be retried, respond with 503 Service Unavailable
|
|
193
|
+
// important to note, this is not an (unexpected) error -- it is an acceptable flow of local development
|
|
194
|
+
// it would be incorrect to retry non-idempotent requests
|
|
195
|
+
// and would require cloning all body streams to avoid stream reuse (which is inefficient but not out of the question in the future)
|
|
196
|
+
// this is a good enough UX for now since it solves the most common GET use-case
|
|
197
|
+
else {
|
|
198
|
+
deferredResponse.resolve(
|
|
199
|
+
new Response(
|
|
200
|
+
"Your worker restarted mid-request. Please try sending the request again. Only GET or HEAD requests are retried automatically.",
|
|
201
|
+
{
|
|
202
|
+
status: 503,
|
|
203
|
+
headers: { "Retry-After": "0" },
|
|
204
|
+
}
|
|
205
|
+
)
|
|
206
|
+
);
|
|
207
|
+
}
|
|
151
208
|
});
|
|
152
209
|
}
|
|
153
210
|
}
|
|
@@ -166,25 +223,14 @@ function isRequestForLiveReloadWebsocket(req: Request): boolean {
|
|
|
166
223
|
return isWebSocketUpgrade && websocketProtocol === LIVE_RELOAD_PROTOCOL;
|
|
167
224
|
}
|
|
168
225
|
|
|
169
|
-
|
|
226
|
+
function sendMessageToProxyController(
|
|
170
227
|
env: Env,
|
|
171
|
-
message: ProxyWorkerOutgoingRequestBody
|
|
172
|
-
retries = 3
|
|
228
|
+
message: ProxyWorkerOutgoingRequestBody
|
|
173
229
|
) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
});
|
|
179
|
-
} catch (cause) {
|
|
180
|
-
if (retries > 0) {
|
|
181
|
-
return sendMessageToProxyController(env, message, retries - 1);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// no point sending an error message if we can't send this message
|
|
185
|
-
|
|
186
|
-
throw cause;
|
|
187
|
-
}
|
|
230
|
+
return env.PROXY_CONTROLLER.fetch("http://dummy", {
|
|
231
|
+
method: "POST",
|
|
232
|
+
body: JSON.stringify(message),
|
|
233
|
+
});
|
|
188
234
|
}
|
|
189
235
|
|
|
190
236
|
function insertLiveReloadScript(
|
|
@@ -250,3 +296,20 @@ function insertLiveReloadScript(
|
|
|
250
296
|
|
|
251
297
|
return htmlRewriter.transform(response);
|
|
252
298
|
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Rewrite references to URLs in request/response headers.
|
|
302
|
+
*
|
|
303
|
+
* This function is used to map the URLs in headers like Origin and Access-Control-Allow-Origin
|
|
304
|
+
* so that this proxy is transparent to the Client Browser and User Worker.
|
|
305
|
+
*/
|
|
306
|
+
function rewriteUrlRelatedHeaders(headers: Headers, from: URL, to: URL) {
|
|
307
|
+
headers.forEach((value, key) => {
|
|
308
|
+
if (typeof value === "string" && value.includes(from.host)) {
|
|
309
|
+
headers.set(
|
|
310
|
+
key,
|
|
311
|
+
value.replaceAll(from.origin, to.origin).replaceAll(from.host, to.host)
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
}
|
|
@@ -15,6 +15,11 @@ function createDeferred(previousDeferred) {
|
|
|
15
15
|
reject
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
+
function urlFromParts(parts, base = "http://localhost") {
|
|
19
|
+
const url = new URL(base);
|
|
20
|
+
Object.assign(url, parts);
|
|
21
|
+
return url;
|
|
22
|
+
}
|
|
18
23
|
|
|
19
24
|
// templates/startDevWorker/ProxyWorker.ts
|
|
20
25
|
var LIVE_RELOAD_PROTOCOL = "WRANGLER_PROXYWORKER_LIVE_RELOAD_PROTOCOL";
|
|
@@ -32,6 +37,7 @@ var ProxyWorker = class {
|
|
|
32
37
|
}
|
|
33
38
|
proxyData;
|
|
34
39
|
requestQueue = /* @__PURE__ */ new Map();
|
|
40
|
+
requestRetryQueue = /* @__PURE__ */ new Map();
|
|
35
41
|
fetch(request) {
|
|
36
42
|
if (isRequestForLiveReloadWebsocket(request)) {
|
|
37
43
|
return this.handleLiveReloadWebSocket(request);
|
|
@@ -68,20 +74,34 @@ var ProxyWorker = class {
|
|
|
68
74
|
}
|
|
69
75
|
return new Response(null, { status: 204 });
|
|
70
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Process requests that are being retried first, then process newer requests.
|
|
79
|
+
* Requests that are being retried are, by definition, older than requests which haven't been processed yet.
|
|
80
|
+
* We don't need to be more accurate than this re ordering, since the requests are being fired off synchronously.
|
|
81
|
+
*/
|
|
82
|
+
*getOrderedQueue() {
|
|
83
|
+
yield* this.requestRetryQueue;
|
|
84
|
+
yield* this.requestQueue;
|
|
85
|
+
}
|
|
71
86
|
processQueue() {
|
|
72
87
|
const { proxyData } = this;
|
|
73
88
|
if (proxyData === void 0)
|
|
74
89
|
return;
|
|
75
|
-
for (const [request, deferredResponse] of this.
|
|
90
|
+
for (const [request, deferredResponse] of this.getOrderedQueue()) {
|
|
91
|
+
this.requestRetryQueue.delete(request);
|
|
76
92
|
this.requestQueue.delete(request);
|
|
77
|
-
const
|
|
93
|
+
const outerUrl = new URL(request.url);
|
|
78
94
|
const headers = new Headers(request.headers);
|
|
95
|
+
const userWorkerUrl = new URL(request.url);
|
|
79
96
|
Object.assign(userWorkerUrl, proxyData.userWorkerUrl);
|
|
80
97
|
const innerUrl = new URL(request.url);
|
|
81
98
|
Object.assign(innerUrl, proxyData.userWorkerInnerUrlOverrides);
|
|
82
99
|
headers.set("MF-Original-URL", innerUrl.href);
|
|
83
100
|
headers.set("MF-Disable-Pretty-Error", "true");
|
|
101
|
+
rewriteUrlRelatedHeaders(headers, outerUrl, innerUrl);
|
|
84
102
|
for (const [key, value] of Object.entries(proxyData.headers ?? {})) {
|
|
103
|
+
if (value === void 0)
|
|
104
|
+
continue;
|
|
85
105
|
if (key.toLowerCase() === "cookie") {
|
|
86
106
|
const existing = request.headers.get("cookie") ?? "";
|
|
87
107
|
headers.set("cookie", `${existing};${value}`);
|
|
@@ -90,21 +110,38 @@ var ProxyWorker = class {
|
|
|
90
110
|
}
|
|
91
111
|
}
|
|
92
112
|
void fetch(userWorkerUrl, new Request(request, { headers })).then((res) => {
|
|
113
|
+
res = new Response(res.body, res);
|
|
114
|
+
rewriteUrlRelatedHeaders(res.headers, innerUrl, outerUrl);
|
|
93
115
|
if (isHtmlResponse(res)) {
|
|
94
116
|
res = insertLiveReloadScript(request, res, this.env, proxyData);
|
|
95
117
|
}
|
|
96
118
|
deferredResponse.resolve(res);
|
|
97
119
|
}).catch((error) => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
120
|
+
const newUserWorkerUrl = this.proxyData && urlFromParts(this.proxyData.userWorkerUrl);
|
|
121
|
+
if (userWorkerUrl.href === newUserWorkerUrl?.href) {
|
|
122
|
+
void sendMessageToProxyController(this.env, {
|
|
123
|
+
type: "error",
|
|
124
|
+
error: {
|
|
125
|
+
name: error.name,
|
|
126
|
+
message: error.message,
|
|
127
|
+
stack: error.stack,
|
|
128
|
+
cause: error.cause
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
deferredResponse.reject(error);
|
|
132
|
+
} else if (request.method === "GET" || request.method === "HEAD") {
|
|
133
|
+
this.requestRetryQueue.set(request, deferredResponse);
|
|
134
|
+
} else {
|
|
135
|
+
deferredResponse.resolve(
|
|
136
|
+
new Response(
|
|
137
|
+
"Your worker restarted mid-request. Please try sending the request again. Only GET or HEAD requests are retried automatically.",
|
|
138
|
+
{
|
|
139
|
+
status: 503,
|
|
140
|
+
headers: { "Retry-After": "0" }
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
);
|
|
144
|
+
}
|
|
108
145
|
});
|
|
109
146
|
}
|
|
110
147
|
}
|
|
@@ -120,18 +157,11 @@ function isRequestForLiveReloadWebsocket(req) {
|
|
|
120
157
|
const isWebSocketUpgrade = req.headers.get("Upgrade") === "websocket";
|
|
121
158
|
return isWebSocketUpgrade && websocketProtocol === LIVE_RELOAD_PROTOCOL;
|
|
122
159
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
});
|
|
129
|
-
} catch (cause) {
|
|
130
|
-
if (retries > 0) {
|
|
131
|
-
return sendMessageToProxyController(env, message, retries - 1);
|
|
132
|
-
}
|
|
133
|
-
throw cause;
|
|
134
|
-
}
|
|
160
|
+
function sendMessageToProxyController(env, message) {
|
|
161
|
+
return env.PROXY_CONTROLLER.fetch("http://dummy", {
|
|
162
|
+
method: "POST",
|
|
163
|
+
body: JSON.stringify(message)
|
|
164
|
+
});
|
|
135
165
|
}
|
|
136
166
|
function insertLiveReloadScript(request, response, env, proxyData) {
|
|
137
167
|
const htmlRewriter = new HTMLRewriter();
|
|
@@ -179,6 +209,16 @@ function insertLiveReloadScript(request, response, env, proxyData) {
|
|
|
179
209
|
});
|
|
180
210
|
return htmlRewriter.transform(response);
|
|
181
211
|
}
|
|
212
|
+
function rewriteUrlRelatedHeaders(headers, from, to) {
|
|
213
|
+
headers.forEach((value, key) => {
|
|
214
|
+
if (typeof value === "string" && value.includes(from.host)) {
|
|
215
|
+
headers.set(
|
|
216
|
+
key,
|
|
217
|
+
value.replaceAll(from.origin, to.origin).replaceAll(from.host, to.host)
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
182
222
|
export {
|
|
183
223
|
ProxyWorker,
|
|
184
224
|
ProxyWorker_default as default
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/api/startDevWorker/utils.ts", "../templates/startDevWorker/ProxyWorker.ts"],
|
|
4
|
-
"mappings": ";AAAA,OAAO,YAAY;AASZ,SAAS,eACf,kBACqB;AACrB,MAAI,SAAS;AACb,QAAM,aAAa,IAAI,QAAW,CAAC,UAAU,YAAY;AACxD,cAAU;AACV,aAAS;AAAA,EACV,CAAC;AACD,SAAO,OAAO;AACd,SAAO,MAAM;AAIb,oBAAkB,QAAQ,UAAU;AAEpC,SAAO;AAAA,IACN,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACD;AACD;;;
|
|
4
|
+
"mappings": ";AAAA,OAAO,YAAY;AASZ,SAAS,eACf,kBACqB;AACrB,MAAI,SAAS;AACb,QAAM,aAAa,IAAI,QAAW,CAAC,UAAU,YAAY;AACxD,cAAU;AACV,aAAS;AAAA,EACV,CAAC;AACD,SAAO,OAAO;AACd,SAAO,MAAM;AAIb,oBAAkB,QAAQ,UAAU;AAEpC,SAAO;AAAA,IACN,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACD;AACD;AAIO,SAAS,aACf,OACA,OAAO,oBACD;AACN,QAAM,MAAM,IAAI,IAAI,IAAI;AAExB,SAAO,OAAO,KAAK,KAAK;AAExB,SAAO;AACR;;;AClBA,IAAM,uBAAuB;AA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|
import { Duplex } from 'stream';
|
|
7
7
|
import { EventEmitter } from 'events';
|
|
8
8
|
import { EventEmitter as EventEmitter_2 } from 'node:events';
|
|
9
|
+
import type { IncomingRequestCfProperties as IncomingRequestCfProperties_2 } from '@cloudflare/workers-types/experimental';
|
|
9
10
|
import { IpcNetConnectOpts } from 'net';
|
|
10
11
|
import type { Json } from 'miniflare';
|
|
11
12
|
import type { MessagePort as MessagePort_2 } from 'worker_threads';
|
|
@@ -136,19 +137,11 @@ declare type Binding = {
|
|
|
136
137
|
/**
|
|
137
138
|
* Result of the `getBindingsProxy` utility
|
|
138
139
|
*/
|
|
139
|
-
export declare type BindingsProxy<Bindings = Record<string, unknown
|
|
140
|
+
export declare type BindingsProxy<Bindings = Record<string, unknown>, CfProperties extends Record<string, unknown> = IncomingRequestCfProperties_2> = Omit<PlatformProxy<Bindings, CfProperties>, "env"> & {
|
|
140
141
|
/**
|
|
141
142
|
* Object containing the various proxies
|
|
142
143
|
*/
|
|
143
144
|
bindings: Bindings;
|
|
144
|
-
/**
|
|
145
|
-
* Caches object emulating the Workers Cache runtime API
|
|
146
|
-
*/
|
|
147
|
-
caches: CacheStorage_3;
|
|
148
|
-
/**
|
|
149
|
-
* Function used to dispose of the child process providing the bindings implementation
|
|
150
|
-
*/
|
|
151
|
-
dispose: () => Promise<void>;
|
|
152
145
|
};
|
|
153
146
|
|
|
154
147
|
declare interface BlobPropertyBag {
|
|
@@ -317,9 +310,9 @@ declare type CacheQueryOptions_3 = {
|
|
|
317
310
|
ignoreMethod?: boolean;
|
|
318
311
|
};
|
|
319
312
|
|
|
320
|
-
declare type CacheRequest =
|
|
313
|
+
declare type CacheRequest = any;
|
|
321
314
|
|
|
322
|
-
declare type CacheResponse =
|
|
315
|
+
declare type CacheResponse = any;
|
|
323
316
|
|
|
324
317
|
declare const caches_2: CacheStorage_2;
|
|
325
318
|
|
|
@@ -344,7 +337,7 @@ declare const CacheStorage_2: {
|
|
|
344
337
|
*
|
|
345
338
|
* We are not using miniflare's implementation because that would require the user to provide
|
|
346
339
|
* miniflare-specific Request objects and they would receive back miniflare-specific Response
|
|
347
|
-
* objects, this (in particular the Request part) is not really suitable for `
|
|
340
|
+
* objects, this (in particular the Request part) is not really suitable for `getPlatformProxy`
|
|
348
341
|
* as people would ideally interact with their bindings in a very production-like manner and
|
|
349
342
|
* requiring them to deal with miniflare-specific classes defeats a bit the purpose of the utility.
|
|
350
343
|
*
|
|
@@ -359,6 +352,7 @@ declare const CacheStorage_2: {
|
|
|
359
352
|
* No-op implementation of CacheStorage
|
|
360
353
|
*/
|
|
361
354
|
declare class CacheStorage_3 {
|
|
355
|
+
constructor();
|
|
362
356
|
open(cacheName: string): Promise<Cache_3>;
|
|
363
357
|
get default(): Cache_3;
|
|
364
358
|
}
|
|
@@ -431,7 +425,7 @@ declare interface CfModule {
|
|
|
431
425
|
/**
|
|
432
426
|
* A module type.
|
|
433
427
|
*/
|
|
434
|
-
declare type CfModuleType = "esm" | "commonjs" | "compiled-wasm" | "text" | "buffer";
|
|
428
|
+
declare type CfModuleType = "esm" | "commonjs" | "compiled-wasm" | "text" | "buffer" | "python" | "python-requirement";
|
|
435
429
|
|
|
436
430
|
/**
|
|
437
431
|
* The type of Worker
|
|
@@ -700,7 +694,7 @@ declare interface ConfigFields<Dev extends RawDevConfig> {
|
|
|
700
694
|
/**
|
|
701
695
|
* The possible types for a `Rule`.
|
|
702
696
|
*/
|
|
703
|
-
declare type ConfigModuleRuleType = "ESModule" | "CommonJS" | "CompiledWasm" | "Text" | "Data";
|
|
697
|
+
declare type ConfigModuleRuleType = "ESModule" | "CommonJS" | "CompiledWasm" | "Text" | "Data" | "PythonModule" | "PythonRequirement";
|
|
704
698
|
|
|
705
699
|
declare type ConfigUpdateEvent = {
|
|
706
700
|
type: "configUpdate";
|
|
@@ -2083,6 +2077,11 @@ declare type EventTarget_2 = typeof globalThis extends { EventTarget: infer T }
|
|
|
2083
2077
|
): void
|
|
2084
2078
|
}
|
|
2085
2079
|
|
|
2080
|
+
declare class ExecutionContext_2 {
|
|
2081
|
+
waitUntil(promise: Promise<any>): void;
|
|
2082
|
+
passThroughOnException(): void;
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2086
2085
|
declare function fetch_2 (
|
|
2087
2086
|
input: RequestInfo_2,
|
|
2088
2087
|
init?: RequestInit_2
|
|
@@ -2266,15 +2265,36 @@ declare type FormDataEntryValue = string | File_2
|
|
|
2266
2265
|
* By reading from a `wrangler.toml` file this function generates proxy binding objects that can be
|
|
2267
2266
|
* used to simulate the interaction with bindings during local development in a Node.js environment
|
|
2268
2267
|
*
|
|
2268
|
+
* @deprecated use `getPlatformProxy` instead
|
|
2269
|
+
*
|
|
2270
|
+
* @param options The various options that can tweak this function's behavior
|
|
2271
|
+
* @returns An Object containing the generated proxies alongside other related utilities
|
|
2272
|
+
*/
|
|
2273
|
+
export declare function getBindingsProxy<Bindings = Record<string, unknown>, CfProperties extends Record<string, unknown> = IncomingRequestCfProperties_2>(options?: GetBindingsProxyOptions): Promise<BindingsProxy<Bindings, CfProperties>>;
|
|
2274
|
+
|
|
2275
|
+
/** Options for the `getBindingsProxy` utility */
|
|
2276
|
+
export declare type GetBindingsProxyOptions = GetPlatformProxyOptions;
|
|
2277
|
+
|
|
2278
|
+
declare function getCookies (headers: Headers_2): Record<string, string>
|
|
2279
|
+
|
|
2280
|
+
declare function getGlobalDispatcher(): Dispatcher;
|
|
2281
|
+
|
|
2282
|
+
declare function getGlobalOrigin(): URL | undefined;
|
|
2283
|
+
|
|
2284
|
+
/**
|
|
2285
|
+
* By reading from a `wrangler.toml` file this function generates proxy objects that can be
|
|
2286
|
+
* used to simulate the interaction with the Cloudflare platform during local development
|
|
2287
|
+
* in a Node.js environment
|
|
2288
|
+
*
|
|
2269
2289
|
* @param options The various options that can tweak this function's behavior
|
|
2270
2290
|
* @returns An Object containing the generated proxies alongside other related utilities
|
|
2271
2291
|
*/
|
|
2272
|
-
export declare function
|
|
2292
|
+
export declare function getPlatformProxy<Env = Record<string, unknown>, CfProperties extends Record<string, unknown> = IncomingRequestCfProperties_2>(options?: GetPlatformProxyOptions): Promise<PlatformProxy<Env, CfProperties>>;
|
|
2273
2293
|
|
|
2274
2294
|
/**
|
|
2275
|
-
* Options for the `
|
|
2295
|
+
* Options for the `getPlatformProxy` utility
|
|
2276
2296
|
*/
|
|
2277
|
-
export declare type
|
|
2297
|
+
export declare type GetPlatformProxyOptions = {
|
|
2278
2298
|
/**
|
|
2279
2299
|
* The path to the config object to use (default `wrangler.toml`)
|
|
2280
2300
|
*/
|
|
@@ -2296,12 +2316,6 @@ export declare type GetBindingsProxyOptions = {
|
|
|
2296
2316
|
};
|
|
2297
2317
|
};
|
|
2298
2318
|
|
|
2299
|
-
declare function getCookies (headers: Headers_2): Record<string, string>
|
|
2300
|
-
|
|
2301
|
-
declare function getGlobalDispatcher(): Dispatcher;
|
|
2302
|
-
|
|
2303
|
-
declare function getGlobalOrigin(): URL | undefined;
|
|
2304
|
-
|
|
2305
2319
|
declare function getSetCookies (headers: Headers_2): Cookie[]
|
|
2306
2320
|
|
|
2307
2321
|
declare class Headers_2 implements SpecIterable<[string, string]> {
|
|
@@ -2646,6 +2660,32 @@ options: { dispatcher?: Dispatcher } & Omit<Dispatcher.PipelineOptions, 'origin'
|
|
|
2646
2660
|
handler: Dispatcher.PipelineHandler
|
|
2647
2661
|
): Duplex;
|
|
2648
2662
|
|
|
2663
|
+
/**
|
|
2664
|
+
* Result of the `getPlatformProxy` utility
|
|
2665
|
+
*/
|
|
2666
|
+
export declare type PlatformProxy<Env = Record<string, unknown>, CfProperties extends Record<string, unknown> = IncomingRequestCfProperties_2> = {
|
|
2667
|
+
/**
|
|
2668
|
+
* Environment object containing the various Cloudflare bindings
|
|
2669
|
+
*/
|
|
2670
|
+
env: Env;
|
|
2671
|
+
/**
|
|
2672
|
+
* Mock of the context object that Workers received in their request handler, all the object's methods are no-op
|
|
2673
|
+
*/
|
|
2674
|
+
cf: CfProperties;
|
|
2675
|
+
/**
|
|
2676
|
+
* Mock of the context object that Workers received in their request handler, all the object's methods are no-op
|
|
2677
|
+
*/
|
|
2678
|
+
ctx: ExecutionContext_2;
|
|
2679
|
+
/**
|
|
2680
|
+
* Caches object emulating the Workers Cache runtime API
|
|
2681
|
+
*/
|
|
2682
|
+
caches: CacheStorage_3;
|
|
2683
|
+
/**
|
|
2684
|
+
* Function used to dispose of the child process providing the bindings implementation
|
|
2685
|
+
*/
|
|
2686
|
+
dispose: () => Promise<void>;
|
|
2687
|
+
};
|
|
2688
|
+
|
|
2649
2689
|
declare class Pool extends Dispatcher {
|
|
2650
2690
|
constructor(url: string | URL_2, options?: Pool.Options)
|
|
2651
2691
|
/** `true` after `pool.close()` has been called. */
|
|
@@ -23004,7 +23044,7 @@ declare type ProxyData = {
|
|
|
23004
23044
|
userWorkerUrl: UrlOriginParts;
|
|
23005
23045
|
userWorkerInspectorUrl: UrlOriginAndPathnameParts;
|
|
23006
23046
|
userWorkerInnerUrlOverrides: Partial<UrlOriginParts>;
|
|
23007
|
-
headers: Record<string, string
|
|
23047
|
+
headers: Record<string, string>;
|
|
23008
23048
|
liveReload?: boolean;
|
|
23009
23049
|
proxyLogsToController?: boolean;
|
|
23010
23050
|
internalDurableObjects?: CfDurableObject[];
|
|
@@ -23469,6 +23509,8 @@ declare interface StartDevWorkerOptions {
|
|
|
23469
23509
|
hostname?: string;
|
|
23470
23510
|
port?: number;
|
|
23471
23511
|
secure?: boolean;
|
|
23512
|
+
httpsKeyPath?: string;
|
|
23513
|
+
httpsCertPath?: string;
|
|
23472
23514
|
};
|
|
23473
23515
|
/** Controls what request.url looks like inside the worker. */
|
|
23474
23516
|
urlOverrides?: {
|
|
@@ -23678,6 +23720,8 @@ export declare interface UnstableDevOptions {
|
|
|
23678
23720
|
bundle?: boolean;
|
|
23679
23721
|
inspectorPort?: number;
|
|
23680
23722
|
localProtocol?: "http" | "https";
|
|
23723
|
+
httpsKeyPath?: string;
|
|
23724
|
+
httpsCertPath?: string;
|
|
23681
23725
|
assets?: string;
|
|
23682
23726
|
site?: string;
|
|
23683
23727
|
siteInclude?: string[];
|