wrangler 3.106.0 → 3.107.1
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 +47 -1
- package/package.json +11 -10
- package/wrangler-dist/cli.d.ts +34 -12
- package/wrangler-dist/cli.js +853 -406
package/wrangler-dist/cli.js
CHANGED
@@ -4603,7 +4603,7 @@ var require_file = __commonJS({
|
|
4603
4603
|
var { parseMIMEType, serializeAMimeType } = require_dataURL();
|
4604
4604
|
var { kEnumerableProperty } = require_util();
|
4605
4605
|
var encoder = new TextEncoder();
|
4606
|
-
var
|
4606
|
+
var File8 = class extends Blob6 {
|
4607
4607
|
constructor(fileBits, fileName, options30 = {}) {
|
4608
4608
|
webidl.argumentLengthCheck(arguments, 2, { header: "File constructor" });
|
4609
4609
|
fileBits = webidl.converters["sequence<BlobPart>"](fileBits);
|
@@ -4631,19 +4631,19 @@ var require_file = __commonJS({
|
|
4631
4631
|
};
|
4632
4632
|
}
|
4633
4633
|
get name() {
|
4634
|
-
webidl.brandCheck(this,
|
4634
|
+
webidl.brandCheck(this, File8);
|
4635
4635
|
return this[kState].name;
|
4636
4636
|
}
|
4637
4637
|
get lastModified() {
|
4638
|
-
webidl.brandCheck(this,
|
4638
|
+
webidl.brandCheck(this, File8);
|
4639
4639
|
return this[kState].lastModified;
|
4640
4640
|
}
|
4641
4641
|
get type() {
|
4642
|
-
webidl.brandCheck(this,
|
4642
|
+
webidl.brandCheck(this, File8);
|
4643
4643
|
return this[kState].type;
|
4644
4644
|
}
|
4645
4645
|
};
|
4646
|
-
__name(
|
4646
|
+
__name(File8, "File");
|
4647
4647
|
var FileLike = class {
|
4648
4648
|
constructor(blobLike, fileName, options30 = {}) {
|
4649
4649
|
const n6 = fileName;
|
@@ -4693,7 +4693,7 @@ var require_file = __commonJS({
|
|
4693
4693
|
}
|
4694
4694
|
};
|
4695
4695
|
__name(FileLike, "FileLike");
|
4696
|
-
Object.defineProperties(
|
4696
|
+
Object.defineProperties(File8.prototype, {
|
4697
4697
|
[Symbol.toStringTag]: {
|
4698
4698
|
value: "File",
|
4699
4699
|
configurable: true
|
@@ -4775,10 +4775,10 @@ var require_file = __commonJS({
|
|
4775
4775
|
}
|
4776
4776
|
__name(convertLineEndingsNative, "convertLineEndingsNative");
|
4777
4777
|
function isFileLike(object) {
|
4778
|
-
return NativeFile && object instanceof NativeFile || object instanceof
|
4778
|
+
return NativeFile && object instanceof NativeFile || object instanceof File8 || object && (typeof object.stream === "function" || typeof object.arrayBuffer === "function") && object[Symbol.toStringTag] === "File";
|
4779
4779
|
}
|
4780
4780
|
__name(isFileLike, "isFileLike");
|
4781
|
-
module3.exports = { File:
|
4781
|
+
module3.exports = { File: File8, FileLike, isFileLike };
|
4782
4782
|
}
|
4783
4783
|
});
|
4784
4784
|
|
@@ -4792,7 +4792,7 @@ var require_formdata = __commonJS({
|
|
4792
4792
|
var { File: UndiciFile, FileLike, isFileLike } = require_file();
|
4793
4793
|
var { webidl } = require_webidl();
|
4794
4794
|
var { Blob: Blob6, File: NativeFile } = require("buffer");
|
4795
|
-
var
|
4795
|
+
var File8 = NativeFile ?? UndiciFile;
|
4796
4796
|
var FormData11 = class {
|
4797
4797
|
constructor(form) {
|
4798
4798
|
if (form !== void 0) {
|
@@ -4924,14 +4924,14 @@ var require_formdata = __commonJS({
|
|
4924
4924
|
value = Buffer.from(value).toString("utf8");
|
4925
4925
|
} else {
|
4926
4926
|
if (!isFileLike(value)) {
|
4927
|
-
value = value instanceof Blob6 ? new
|
4927
|
+
value = value instanceof Blob6 ? new File8([value], "blob", { type: value.type }) : new FileLike(value, "blob", { type: value.type });
|
4928
4928
|
}
|
4929
4929
|
if (filename !== void 0) {
|
4930
4930
|
const options30 = {
|
4931
4931
|
type: value.type,
|
4932
4932
|
lastModified: value.lastModified
|
4933
4933
|
};
|
4934
|
-
value = NativeFile && value instanceof NativeFile || value instanceof UndiciFile ? new
|
4934
|
+
value = NativeFile && value instanceof NativeFile || value instanceof UndiciFile ? new File8([value], filename, options30) : new FileLike(value, filename, options30);
|
4935
4935
|
}
|
4936
4936
|
}
|
4937
4937
|
return { name: name2, value };
|
@@ -4968,7 +4968,7 @@ var require_body = __commonJS({
|
|
4968
4968
|
var { File: UndiciFile } = require_file();
|
4969
4969
|
var { parseMIMEType, serializeAMimeType } = require_dataURL();
|
4970
4970
|
var ReadableStream3 = globalThis.ReadableStream;
|
4971
|
-
var
|
4971
|
+
var File8 = NativeFile ?? UndiciFile;
|
4972
4972
|
var textEncoder = new TextEncoder();
|
4973
4973
|
var textDecoder = new TextDecoder();
|
4974
4974
|
function extractBody(object, keepalive = false) {
|
@@ -5209,14 +5209,14 @@ Content-Type: ${value.type || "application/octet-stream"}\r
|
|
5209
5209
|
});
|
5210
5210
|
value.on("end", () => {
|
5211
5211
|
chunks.push(Buffer.from(base64chunk, "base64"));
|
5212
|
-
responseFormData.append(name2, new
|
5212
|
+
responseFormData.append(name2, new File8(chunks, filename, { type: mimeType }));
|
5213
5213
|
});
|
5214
5214
|
} else {
|
5215
5215
|
value.on("data", (chunk) => {
|
5216
5216
|
chunks.push(chunk);
|
5217
5217
|
});
|
5218
5218
|
value.on("end", () => {
|
5219
|
-
responseFormData.append(name2, new
|
5219
|
+
responseFormData.append(name2, new File8(chunks, filename, { type: mimeType }));
|
5220
5220
|
});
|
5221
5221
|
}
|
5222
5222
|
});
|
@@ -11837,11 +11837,11 @@ var require_response = __commonJS({
|
|
11837
11837
|
var { types } = require("util");
|
11838
11838
|
var ReadableStream3 = globalThis.ReadableStream || require("stream/web").ReadableStream;
|
11839
11839
|
var textEncoder = new TextEncoder("utf-8");
|
11840
|
-
var
|
11840
|
+
var Response11 = class {
|
11841
11841
|
// Creates network error Response.
|
11842
11842
|
static error() {
|
11843
11843
|
const relevantRealm = { settingsObject: {} };
|
11844
|
-
const responseObject = new
|
11844
|
+
const responseObject = new Response11();
|
11845
11845
|
responseObject[kState] = makeNetworkError();
|
11846
11846
|
responseObject[kRealm] = relevantRealm;
|
11847
11847
|
responseObject[kHeaders][kHeadersList] = responseObject[kState].headersList;
|
@@ -11860,7 +11860,7 @@ var require_response = __commonJS({
|
|
11860
11860
|
);
|
11861
11861
|
const body = extractBody(bytes);
|
11862
11862
|
const relevantRealm = { settingsObject: {} };
|
11863
|
-
const responseObject = new
|
11863
|
+
const responseObject = new Response11();
|
11864
11864
|
responseObject[kRealm] = relevantRealm;
|
11865
11865
|
responseObject[kHeaders][kGuard] = "response";
|
11866
11866
|
responseObject[kHeaders][kRealm] = relevantRealm;
|
@@ -11884,7 +11884,7 @@ var require_response = __commonJS({
|
|
11884
11884
|
if (!redirectStatusSet.has(status2)) {
|
11885
11885
|
throw new RangeError("Invalid status code " + status2);
|
11886
11886
|
}
|
11887
|
-
const responseObject = new
|
11887
|
+
const responseObject = new Response11();
|
11888
11888
|
responseObject[kRealm] = relevantRealm;
|
11889
11889
|
responseObject[kHeaders][kGuard] = "immutable";
|
11890
11890
|
responseObject[kHeaders][kRealm] = relevantRealm;
|
@@ -11914,12 +11914,12 @@ var require_response = __commonJS({
|
|
11914
11914
|
}
|
11915
11915
|
// Returns response’s type, e.g., "cors".
|
11916
11916
|
get type() {
|
11917
|
-
webidl.brandCheck(this,
|
11917
|
+
webidl.brandCheck(this, Response11);
|
11918
11918
|
return this[kState].type;
|
11919
11919
|
}
|
11920
11920
|
// Returns response’s URL, if it has one; otherwise the empty string.
|
11921
11921
|
get url() {
|
11922
|
-
webidl.brandCheck(this,
|
11922
|
+
webidl.brandCheck(this, Response11);
|
11923
11923
|
const urlList = this[kState].urlList;
|
11924
11924
|
const url4 = urlList[urlList.length - 1] ?? null;
|
11925
11925
|
if (url4 === null) {
|
@@ -11929,40 +11929,40 @@ var require_response = __commonJS({
|
|
11929
11929
|
}
|
11930
11930
|
// Returns whether response was obtained through a redirect.
|
11931
11931
|
get redirected() {
|
11932
|
-
webidl.brandCheck(this,
|
11932
|
+
webidl.brandCheck(this, Response11);
|
11933
11933
|
return this[kState].urlList.length > 1;
|
11934
11934
|
}
|
11935
11935
|
// Returns response’s status.
|
11936
11936
|
get status() {
|
11937
|
-
webidl.brandCheck(this,
|
11937
|
+
webidl.brandCheck(this, Response11);
|
11938
11938
|
return this[kState].status;
|
11939
11939
|
}
|
11940
11940
|
// Returns whether response’s status is an ok status.
|
11941
11941
|
get ok() {
|
11942
|
-
webidl.brandCheck(this,
|
11942
|
+
webidl.brandCheck(this, Response11);
|
11943
11943
|
return this[kState].status >= 200 && this[kState].status <= 299;
|
11944
11944
|
}
|
11945
11945
|
// Returns response’s status message.
|
11946
11946
|
get statusText() {
|
11947
|
-
webidl.brandCheck(this,
|
11947
|
+
webidl.brandCheck(this, Response11);
|
11948
11948
|
return this[kState].statusText;
|
11949
11949
|
}
|
11950
11950
|
// Returns response’s headers as Headers.
|
11951
11951
|
get headers() {
|
11952
|
-
webidl.brandCheck(this,
|
11952
|
+
webidl.brandCheck(this, Response11);
|
11953
11953
|
return this[kHeaders];
|
11954
11954
|
}
|
11955
11955
|
get body() {
|
11956
|
-
webidl.brandCheck(this,
|
11956
|
+
webidl.brandCheck(this, Response11);
|
11957
11957
|
return this[kState].body ? this[kState].body.stream : null;
|
11958
11958
|
}
|
11959
11959
|
get bodyUsed() {
|
11960
|
-
webidl.brandCheck(this,
|
11960
|
+
webidl.brandCheck(this, Response11);
|
11961
11961
|
return !!this[kState].body && util5.isDisturbed(this[kState].body.stream);
|
11962
11962
|
}
|
11963
11963
|
// Returns a clone of response.
|
11964
11964
|
clone() {
|
11965
|
-
webidl.brandCheck(this,
|
11965
|
+
webidl.brandCheck(this, Response11);
|
11966
11966
|
if (this.bodyUsed || this.body && this.body.locked) {
|
11967
11967
|
throw webidl.errors.exception({
|
11968
11968
|
header: "Response.clone",
|
@@ -11970,7 +11970,7 @@ var require_response = __commonJS({
|
|
11970
11970
|
});
|
11971
11971
|
}
|
11972
11972
|
const clonedResponse = cloneResponse(this[kState]);
|
11973
|
-
const clonedResponseObject = new
|
11973
|
+
const clonedResponseObject = new Response11();
|
11974
11974
|
clonedResponseObject[kState] = clonedResponse;
|
11975
11975
|
clonedResponseObject[kRealm] = this[kRealm];
|
11976
11976
|
clonedResponseObject[kHeaders][kHeadersList] = clonedResponse.headersList;
|
@@ -11979,9 +11979,9 @@ var require_response = __commonJS({
|
|
11979
11979
|
return clonedResponseObject;
|
11980
11980
|
}
|
11981
11981
|
};
|
11982
|
-
__name(
|
11983
|
-
mixinBody(
|
11984
|
-
Object.defineProperties(
|
11982
|
+
__name(Response11, "Response");
|
11983
|
+
mixinBody(Response11);
|
11984
|
+
Object.defineProperties(Response11.prototype, {
|
11985
11985
|
type: kEnumerableProperty,
|
11986
11986
|
url: kEnumerableProperty,
|
11987
11987
|
status: kEnumerableProperty,
|
@@ -11997,7 +11997,7 @@ var require_response = __commonJS({
|
|
11997
11997
|
configurable: true
|
11998
11998
|
}
|
11999
11999
|
});
|
12000
|
-
Object.defineProperties(
|
12000
|
+
Object.defineProperties(Response11, {
|
12001
12001
|
json: kEnumerableProperty,
|
12002
12002
|
redirect: kEnumerableProperty,
|
12003
12003
|
error: kEnumerableProperty
|
@@ -12186,7 +12186,7 @@ var require_response = __commonJS({
|
|
12186
12186
|
makeResponse,
|
12187
12187
|
makeAppropriateNetworkError,
|
12188
12188
|
filterResponse,
|
12189
|
-
Response:
|
12189
|
+
Response: Response11,
|
12190
12190
|
cloneResponse
|
12191
12191
|
};
|
12192
12192
|
}
|
@@ -12841,7 +12841,7 @@ var require_fetch = __commonJS({
|
|
12841
12841
|
"use strict";
|
12842
12842
|
init_import_meta_url();
|
12843
12843
|
var {
|
12844
|
-
Response:
|
12844
|
+
Response: Response11,
|
12845
12845
|
makeNetworkError,
|
12846
12846
|
makeAppropriateNetworkError,
|
12847
12847
|
filterResponse,
|
@@ -12982,7 +12982,7 @@ var require_fetch = __commonJS({
|
|
12982
12982
|
);
|
12983
12983
|
return Promise.resolve();
|
12984
12984
|
}
|
12985
|
-
responseObject = new
|
12985
|
+
responseObject = new Response11();
|
12986
12986
|
responseObject[kState] = response;
|
12987
12987
|
responseObject[kRealm] = relevantRealm;
|
12988
12988
|
responseObject[kHeaders][kHeadersList] = response.headersList;
|
@@ -14773,7 +14773,7 @@ var require_cache = __commonJS({
|
|
14773
14773
|
var { kEnumerableProperty, isDisturbed } = require_util();
|
14774
14774
|
var { kHeadersList } = require_symbols();
|
14775
14775
|
var { webidl } = require_webidl();
|
14776
|
-
var { Response:
|
14776
|
+
var { Response: Response11, cloneResponse } = require_response();
|
14777
14777
|
var { Request: Request4 } = require_request2();
|
14778
14778
|
var { kState, kHeaders, kGuard, kRealm } = require_symbols2();
|
14779
14779
|
var { fetching } = require_fetch();
|
@@ -14832,7 +14832,7 @@ var require_cache = __commonJS({
|
|
14832
14832
|
}
|
14833
14833
|
const responseList = [];
|
14834
14834
|
for (const response of responses) {
|
14835
|
-
const responseObject = new
|
14835
|
+
const responseObject = new Response11(response.body?.source ?? null);
|
14836
14836
|
const body = responseObject[kState].body;
|
14837
14837
|
responseObject[kState] = response;
|
14838
14838
|
responseObject[kState].body = body;
|
@@ -15289,7 +15289,7 @@ var require_cache = __commonJS({
|
|
15289
15289
|
converter: webidl.converters.DOMString
|
15290
15290
|
}
|
15291
15291
|
]);
|
15292
|
-
webidl.converters.Response = webidl.interfaceConverter(
|
15292
|
+
webidl.converters.Response = webidl.interfaceConverter(Response11);
|
15293
15293
|
webidl.converters["sequence<RequestInfo>"] = webidl.sequenceConverter(
|
15294
15294
|
webidl.converters.RequestInfo
|
15295
15295
|
);
|
@@ -71460,7 +71460,7 @@ var require_src5 = __commonJS({
|
|
71460
71460
|
QueueEvent: () => QueueEvent,
|
71461
71461
|
ReloadEvent: () => ReloadEvent,
|
71462
71462
|
Request: () => Request4,
|
71463
|
-
Response: () =>
|
71463
|
+
Response: () => Response11,
|
71464
71464
|
Router: () => Router,
|
71465
71465
|
RouterError: () => RouterError,
|
71466
71466
|
ScheduledController: () => ScheduledController,
|
@@ -72419,14 +72419,14 @@ var require_src5 = __commonJS({
|
|
72419
72419
|
"statusText",
|
72420
72420
|
"status"
|
72421
72421
|
];
|
72422
|
-
var
|
72422
|
+
var Response11 = /* @__PURE__ */ __name(class extends Body {
|
72423
72423
|
static redirect(url4, status2 = 302) {
|
72424
72424
|
const res = import_undici26.Response.redirect(url4, status2);
|
72425
|
-
return new
|
72425
|
+
return new Response11(res.body, res);
|
72426
72426
|
}
|
72427
72427
|
static json(data, init2) {
|
72428
72428
|
const res = import_undici26.Response.json(data, init2);
|
72429
|
-
return new
|
72429
|
+
return new Response11(res.body, res);
|
72430
72430
|
}
|
72431
72431
|
#encodeBody;
|
72432
72432
|
#status;
|
@@ -72446,7 +72446,7 @@ var require_src5 = __commonJS({
|
|
72446
72446
|
if (body instanceof import_web3.ReadableStream && _isByteStream(body)) {
|
72447
72447
|
body = convertToRegularStream(body);
|
72448
72448
|
}
|
72449
|
-
if (init2 instanceof
|
72449
|
+
if (init2 instanceof Response11) {
|
72450
72450
|
encodeBody = init2.#encodeBody;
|
72451
72451
|
status2 = init2.#status;
|
72452
72452
|
webSocket = init2.#webSocket;
|
@@ -72476,7 +72476,7 @@ var require_src5 = __commonJS({
|
|
72476
72476
|
if (contentLength !== void 0) {
|
72477
72477
|
this.headers.set("content-length", contentLength.toString());
|
72478
72478
|
}
|
72479
|
-
makeEnumerable(
|
72479
|
+
makeEnumerable(Response11.prototype, this, enumerableResponseKeys);
|
72480
72480
|
Object.defineProperty(this, kWaitUntil, nonEnumerable);
|
72481
72481
|
}
|
72482
72482
|
clone() {
|
@@ -72485,7 +72485,7 @@ var require_src5 = __commonJS({
|
|
72485
72485
|
}
|
72486
72486
|
const innerClone = this[_kInner].clone();
|
72487
72487
|
this[kBodyStream] = void 0;
|
72488
|
-
const clone = new
|
72488
|
+
const clone = new Response11(innerClone.body, innerClone);
|
72489
72489
|
clone[kInputGated] = this[kInputGated];
|
72490
72490
|
clone[kFormDataFiles] = this[kFormDataFiles];
|
72491
72491
|
clone.#encodeBody = this.#encodeBody;
|
@@ -72527,7 +72527,7 @@ var require_src5 = __commonJS({
|
|
72527
72527
|
}
|
72528
72528
|
}, "Response");
|
72529
72529
|
function withWaitUntil(res, waitUntil) {
|
72530
|
-
const resWaitUntil = res instanceof
|
72530
|
+
const resWaitUntil = res instanceof Response11 ? res : new Response11(res.body, res);
|
72531
72531
|
resWaitUntil[kWaitUntil] = waitUntil;
|
72532
72532
|
return resWaitUntil;
|
72533
72533
|
}
|
@@ -72537,7 +72537,7 @@ var require_src5 = __commonJS({
|
|
72537
72537
|
}
|
72538
72538
|
__name(_getURLList, "_getURLList");
|
72539
72539
|
function _getBodyLength(res) {
|
72540
|
-
if (res instanceof
|
72540
|
+
if (res instanceof Response11)
|
72541
72541
|
res = res[_kInner];
|
72542
72542
|
return res[fetchSymbols.kState]?.body?.length ?? void 0;
|
72543
72543
|
}
|
@@ -72609,7 +72609,7 @@ var require_src5 = __commonJS({
|
|
72609
72609
|
if (urlList)
|
72610
72610
|
ctx.incrementExternalSubrequests(urlList.length - 1);
|
72611
72611
|
}
|
72612
|
-
const res = new
|
72612
|
+
const res = new Response11(nullBodyStatus.includes(baseRes.status) ? null : baseRes.body, baseRes);
|
72613
72613
|
res.headers[fetchSymbols.kGuard] = "immutable";
|
72614
72614
|
await (0, import_shared5.waitForOpenInputGate)();
|
72615
72615
|
ctx?.advanceCurrentTime();
|
@@ -72974,7 +72974,7 @@ ${SUGGEST_GLOBAL_BINDING_MODULES}`);
|
|
72974
72974
|
event[kSent] = true;
|
72975
72975
|
}
|
72976
72976
|
if (res !== void 0) {
|
72977
|
-
const validRes = res instanceof
|
72977
|
+
const validRes = res instanceof Response11 || res instanceof import_undici32.Response;
|
72978
72978
|
if (!validRes) {
|
72979
72979
|
const suggestion = this.#modules ? SUGGEST_RES_MODULES : SUGGEST_RES;
|
72980
72980
|
throw new FetchError("ERR_RESPONSE_TYPE", `Fetch handler didn't respond with a Response object.
|
@@ -73112,12 +73112,12 @@ Make sure you're ${suggestion}.`);
|
|
73112
73112
|
function getRangeResponse(requestRangeHeader, responseStatus, responseHeaders, responseBody) {
|
73113
73113
|
const ranges = parseRanges(requestRangeHeader, responseBody.byteLength);
|
73114
73114
|
if (ranges === void 0) {
|
73115
|
-
return new
|
73115
|
+
return new Response11(null, {
|
73116
73116
|
status: 416,
|
73117
73117
|
headers: { "Content-Range": `bytes */${responseBody.byteLength}` }
|
73118
73118
|
});
|
73119
73119
|
} else if (ranges.length === 0) {
|
73120
|
-
return new
|
73120
|
+
return new Response11(responseBody, {
|
73121
73121
|
status: responseStatus,
|
73122
73122
|
headers: responseHeaders
|
73123
73123
|
});
|
@@ -73125,7 +73125,7 @@ Make sure you're ${suggestion}.`);
|
|
73125
73125
|
const [start, end] = ranges[0];
|
73126
73126
|
responseHeaders.set("Content-Range", `bytes ${start}-${end}/${responseBody.byteLength}`);
|
73127
73127
|
responseHeaders.set("Content-Length", `${end - start + 1}`);
|
73128
|
-
return new
|
73128
|
+
return new Response11(responseBody.slice(start, end + 1), {
|
73129
73129
|
status: 206,
|
73130
73130
|
headers: responseHeaders
|
73131
73131
|
});
|
@@ -73152,7 +73152,7 @@ Content-Range: bytes ${start}-${end}/${responseBody.byteLength}\r
|
|
73152
73152
|
}
|
73153
73153
|
});
|
73154
73154
|
responseHeaders.set("Content-Type", `multipart/byteranges; boundary=${boundary}`);
|
73155
|
-
return new
|
73155
|
+
return new Response11(stream2, {
|
73156
73156
|
status: 206,
|
73157
73157
|
headers: responseHeaders
|
73158
73158
|
});
|
@@ -73559,7 +73559,7 @@ Make sure "${service}" is mounted so Miniflare knows where to find it.`);
|
|
73559
73559
|
}
|
73560
73560
|
}
|
73561
73561
|
__name(_populateBuildConfig, "_populateBuildConfig");
|
73562
|
-
var
|
73562
|
+
var import_buffer6 = __toModule(require("buffer"));
|
73563
73563
|
var import_promises210 = __toModule(require("fs/promises"));
|
73564
73564
|
var import_path42 = __toModule(require("path"));
|
73565
73565
|
var import_web5 = __toModule(require("stream/web"));
|
@@ -73784,10 +73784,10 @@ Make sure "${service}" is mounted so Miniflare knows where to find it.`);
|
|
73784
73784
|
}
|
73785
73785
|
const extraGlobals = {};
|
73786
73786
|
let CompatRequest = Request4;
|
73787
|
-
let CompatResponse =
|
73787
|
+
let CompatResponse = Response11;
|
73788
73788
|
if (!ctx.compat.isEnabled("formdata_parser_supports_files")) {
|
73789
73789
|
CompatRequest = proxyStringFormDataFiles(Request4);
|
73790
|
-
CompatResponse = proxyStringFormDataFiles(
|
73790
|
+
CompatResponse = proxyStringFormDataFiles(Response11);
|
73791
73791
|
}
|
73792
73792
|
if (ctx.compat.isEnabled("global_navigator")) {
|
73793
73793
|
extraGlobals.navigator = new Navigator();
|
@@ -73856,7 +73856,7 @@ Make sure "${service}" is mounted so Miniflare knows where to find it.`);
|
|
73856
73856
|
Request: CompatRequest,
|
73857
73857
|
Response: CompatResponse,
|
73858
73858
|
FormData: import_undici42.FormData,
|
73859
|
-
Blob:
|
73859
|
+
Blob: import_buffer6.Blob,
|
73860
73860
|
File: import_undici42.File,
|
73861
73861
|
URL: import_url22.URL,
|
73862
73862
|
URLSearchParams: import_url22.URLSearchParams,
|
@@ -76846,17 +76846,17 @@ async function generateASSETSBinding(options30) {
|
|
76846
76846
|
try {
|
76847
76847
|
const url4 = new URL(miniflareRequest.url);
|
76848
76848
|
url4.host = `localhost:${options30.proxyPort}`;
|
76849
|
-
const proxyRequest = new
|
76849
|
+
const proxyRequest = new import_miniflare18.Request(url4, miniflareRequest);
|
76850
76850
|
if (proxyRequest.headers.get("Upgrade") === "websocket") {
|
76851
76851
|
proxyRequest.headers.delete("Sec-WebSocket-Accept");
|
76852
76852
|
proxyRequest.headers.delete("Sec-WebSocket-Key");
|
76853
76853
|
}
|
76854
|
-
return await (0,
|
76854
|
+
return await (0, import_miniflare18.fetch)(proxyRequest, {
|
76855
76855
|
dispatcher: new ProxyDispatcher(miniflareRequest.headers.get("Host"))
|
76856
76856
|
});
|
76857
76857
|
} catch (thrown) {
|
76858
76858
|
options30.log.error(new Error(`Could not proxy request: ${thrown}`));
|
76859
|
-
return new
|
76859
|
+
return new import_miniflare18.Response(`[wrangler] Could not proxy request: ${thrown}`, {
|
76860
76860
|
status: 502
|
76861
76861
|
});
|
76862
76862
|
}
|
@@ -76865,7 +76865,7 @@ async function generateASSETSBinding(options30) {
|
|
76865
76865
|
return await assetsFetch(miniflareRequest);
|
76866
76866
|
} catch (thrown) {
|
76867
76867
|
options30.log.error(new Error(`Could not serve static asset: ${thrown}`));
|
76868
|
-
return new
|
76868
|
+
return new import_miniflare18.Response(
|
76869
76869
|
`[wrangler] Could not serve static asset: ${thrown}`,
|
76870
76870
|
{ status: 502 }
|
76871
76871
|
);
|
@@ -76977,11 +76977,11 @@ async function generateAssetsFetch(directory, log2) {
|
|
76977
76977
|
});
|
76978
76978
|
}, "generateResponse");
|
76979
76979
|
return async (input, init2) => {
|
76980
|
-
const request4 = new
|
76980
|
+
const request4 = new import_miniflare18.Request(input, init2);
|
76981
76981
|
return await generateResponse(request4);
|
76982
76982
|
};
|
76983
76983
|
}
|
76984
|
-
var import_node_assert18, import_node_fs20, import_node_path37, import_mime3,
|
76984
|
+
var import_node_assert18, import_node_fs20, import_node_path37, import_mime3, import_miniflare18, import_undici8, ProxyDispatcher, invalidAssetsFetch;
|
76985
76985
|
var init_assets = __esm({
|
76986
76986
|
"src/miniflare-cli/assets.ts"() {
|
76987
76987
|
init_import_meta_url();
|
@@ -76993,7 +76993,7 @@ var init_assets = __esm({
|
|
76993
76993
|
init_parseRedirects();
|
76994
76994
|
init_esm2();
|
76995
76995
|
import_mime3 = __toESM(require_mime());
|
76996
|
-
|
76996
|
+
import_miniflare18 = require("miniflare");
|
76997
76997
|
import_undici8 = __toESM(require_undici());
|
76998
76998
|
init_hash();
|
76999
76999
|
__name(generateASSETSBinding, "generateASSETSBinding");
|
@@ -79765,23 +79765,23 @@ var init_dist_es5 = __esm({
|
|
79765
79765
|
});
|
79766
79766
|
|
79767
79767
|
// ../../node_modules/.pnpm/@smithy+util-buffer-from@3.0.0/node_modules/@smithy/util-buffer-from/dist-es/index.js
|
79768
|
-
var
|
79768
|
+
var import_buffer2, fromArrayBuffer, fromString;
|
79769
79769
|
var init_dist_es6 = __esm({
|
79770
79770
|
"../../node_modules/.pnpm/@smithy+util-buffer-from@3.0.0/node_modules/@smithy/util-buffer-from/dist-es/index.js"() {
|
79771
79771
|
init_import_meta_url();
|
79772
79772
|
init_dist_es5();
|
79773
|
-
|
79773
|
+
import_buffer2 = require("buffer");
|
79774
79774
|
fromArrayBuffer = /* @__PURE__ */ __name((input, offset = 0, length = input.byteLength - offset) => {
|
79775
79775
|
if (!isArrayBuffer(input)) {
|
79776
79776
|
throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof input} (${input})`);
|
79777
79777
|
}
|
79778
|
-
return
|
79778
|
+
return import_buffer2.Buffer.from(input, offset, length);
|
79779
79779
|
}, "fromArrayBuffer");
|
79780
79780
|
fromString = /* @__PURE__ */ __name((input, encoding) => {
|
79781
79781
|
if (typeof input !== "string") {
|
79782
79782
|
throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
|
79783
79783
|
}
|
79784
|
-
return encoding ?
|
79784
|
+
return encoding ? import_buffer2.Buffer.from(input, encoding) : import_buffer2.Buffer.from(input);
|
79785
79785
|
}, "fromString");
|
79786
79786
|
}
|
79787
79787
|
});
|
@@ -88965,19 +88965,19 @@ function httpRequest(options30) {
|
|
88965
88965
|
chunks.push(chunk);
|
88966
88966
|
});
|
88967
88967
|
res.on("end", () => {
|
88968
|
-
resolve24(
|
88968
|
+
resolve24(import_buffer4.Buffer.concat(chunks));
|
88969
88969
|
req.destroy();
|
88970
88970
|
});
|
88971
88971
|
});
|
88972
88972
|
req.end();
|
88973
88973
|
});
|
88974
88974
|
}
|
88975
|
-
var
|
88975
|
+
var import_buffer4, import_http2;
|
88976
88976
|
var init_httpRequest2 = __esm({
|
88977
88977
|
"../../node_modules/.pnpm/@smithy+credential-provider-imds@3.2.8/node_modules/@smithy/credential-provider-imds/dist-es/remoteProvider/httpRequest.js"() {
|
88978
88978
|
init_import_meta_url();
|
88979
88979
|
init_dist_es16();
|
88980
|
-
|
88980
|
+
import_buffer4 = require("buffer");
|
88981
88981
|
import_http2 = require("http");
|
88982
88982
|
__name(httpRequest, "httpRequest");
|
88983
88983
|
}
|
@@ -89958,7 +89958,7 @@ var init_dist_es41 = __esm({
|
|
89958
89958
|
|
89959
89959
|
// ../../node_modules/.pnpm/@smithy+hash-node@3.0.11/node_modules/@smithy/hash-node/dist-es/index.js
|
89960
89960
|
function castSourceData(toCast, encoding) {
|
89961
|
-
if (
|
89961
|
+
if (import_buffer5.Buffer.isBuffer(toCast)) {
|
89962
89962
|
return toCast;
|
89963
89963
|
}
|
89964
89964
|
if (typeof toCast === "string") {
|
@@ -89969,13 +89969,13 @@ function castSourceData(toCast, encoding) {
|
|
89969
89969
|
}
|
89970
89970
|
return fromArrayBuffer(toCast);
|
89971
89971
|
}
|
89972
|
-
var
|
89972
|
+
var import_buffer5, import_crypto5, Hash;
|
89973
89973
|
var init_dist_es42 = __esm({
|
89974
89974
|
"../../node_modules/.pnpm/@smithy+hash-node@3.0.11/node_modules/@smithy/hash-node/dist-es/index.js"() {
|
89975
89975
|
init_import_meta_url();
|
89976
89976
|
init_dist_es6();
|
89977
89977
|
init_dist_es7();
|
89978
|
-
|
89978
|
+
import_buffer5 = require("buffer");
|
89979
89979
|
import_crypto5 = require("crypto");
|
89980
89980
|
Hash = class {
|
89981
89981
|
constructor(algorithmIdentifier, secret3) {
|
@@ -98088,14 +98088,14 @@ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
98088
98088
|
var source_default = chalk;
|
98089
98089
|
|
98090
98090
|
// src/api/startDevWorker/MultiworkerRuntimeController.ts
|
98091
|
-
var
|
98091
|
+
var import_miniflare8 = require("miniflare");
|
98092
98092
|
|
98093
98093
|
// src/dev/miniflare.ts
|
98094
98094
|
init_import_meta_url();
|
98095
98095
|
var import_node_assert5 = __toESM(require("node:assert"));
|
98096
98096
|
var import_node_crypto4 = require("node:crypto");
|
98097
98097
|
var import_node_path14 = __toESM(require("node:path"));
|
98098
|
-
var
|
98098
|
+
var import_miniflare6 = require("miniflare");
|
98099
98099
|
|
98100
98100
|
// src/ai/fetcher.ts
|
98101
98101
|
init_import_meta_url();
|
@@ -98108,7 +98108,7 @@ var import_undici3 = __toESM(require_undici());
|
|
98108
98108
|
|
98109
98109
|
// package.json
|
98110
98110
|
var name = "wrangler";
|
98111
|
-
var version = "3.
|
98111
|
+
var version = "3.107.1";
|
98112
98112
|
|
98113
98113
|
// src/environment-variables/misc-variables.ts
|
98114
98114
|
init_import_meta_url();
|
@@ -100873,6 +100873,7 @@ var friendlyBindingNames = {
|
|
100873
100873
|
text_blobs: "Text Blobs",
|
100874
100874
|
browser: "Browser",
|
100875
100875
|
ai: "AI",
|
100876
|
+
images: "Images",
|
100876
100877
|
version_metadata: "Worker Version Metadata",
|
100877
100878
|
unsafe: "Unsafe Metadata",
|
100878
100879
|
vars: "Vars",
|
@@ -100911,6 +100912,7 @@ function printBindings(bindings, context2 = {}) {
|
|
100911
100912
|
text_blobs,
|
100912
100913
|
browser,
|
100913
100914
|
ai: ai3,
|
100915
|
+
images,
|
100914
100916
|
version_metadata,
|
100915
100917
|
unsafe,
|
100916
100918
|
vars,
|
@@ -101123,6 +101125,17 @@ function printBindings(bindings, context2 = {}) {
|
|
101123
101125
|
entries: [{ key: "Name", value: browser.binding }]
|
101124
101126
|
});
|
101125
101127
|
}
|
101128
|
+
if (images !== void 0) {
|
101129
|
+
output.push({
|
101130
|
+
name: friendlyBindingNames.images,
|
101131
|
+
entries: [
|
101132
|
+
{
|
101133
|
+
key: "Name",
|
101134
|
+
value: addLocalSuffix(images.binding, !!context2.imagesLocalMode)
|
101135
|
+
}
|
101136
|
+
]
|
101137
|
+
});
|
101138
|
+
}
|
101126
101139
|
if (ai3 !== void 0) {
|
101127
101140
|
const entries = [
|
101128
101141
|
{ key: "Name", value: ai3.binding }
|
@@ -102047,6 +102060,28 @@ function normalizeAndValidateDev(diagnostics, rawDev, args) {
|
|
102047
102060
|
return { ip, port, inspector_port, local_protocol, upstream_protocol, host };
|
102048
102061
|
}
|
102049
102062
|
__name(normalizeAndValidateDev, "normalizeAndValidateDev");
|
102063
|
+
function normalizeAndValidateAssets(diagnostics, topLevelEnv, rawEnv) {
|
102064
|
+
if (rawEnv?.assets !== void 0) {
|
102065
|
+
deprecated(
|
102066
|
+
diagnostics,
|
102067
|
+
rawEnv,
|
102068
|
+
"assets.experimental_serve_directly",
|
102069
|
+
`The "experimental_serve_directly" field is not longer supported. Please use run_worker_first.
|
102070
|
+
Read more: https://developers.cloudflare.com/workers/static-assets/binding/#run_worker_first`,
|
102071
|
+
false
|
102072
|
+
// Leave in for the moment, to be removed in a future release
|
102073
|
+
);
|
102074
|
+
}
|
102075
|
+
return inheritable(
|
102076
|
+
diagnostics,
|
102077
|
+
topLevelEnv,
|
102078
|
+
rawEnv,
|
102079
|
+
"assets",
|
102080
|
+
validateAssetsConfig,
|
102081
|
+
void 0
|
102082
|
+
);
|
102083
|
+
}
|
102084
|
+
__name(normalizeAndValidateAssets, "normalizeAndValidateAssets");
|
102050
102085
|
function normalizeAndValidateSite(diagnostics, configPath, rawConfig, mainEntryPoint) {
|
102051
102086
|
if (rawConfig?.site !== void 0) {
|
102052
102087
|
const { bucket, include = [], exclude: exclude2 = [], ...rest } = rawConfig.site;
|
@@ -102566,14 +102601,7 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
|
|
102566
102601
|
isObjectWith("crons"),
|
102567
102602
|
{ crons: [] }
|
102568
102603
|
),
|
102569
|
-
assets:
|
102570
|
-
diagnostics,
|
102571
|
-
topLevelEnv,
|
102572
|
-
rawEnv,
|
102573
|
-
"assets",
|
102574
|
-
validateAssetsConfig,
|
102575
|
-
void 0
|
102576
|
-
),
|
102604
|
+
assets: normalizeAndValidateAssets(diagnostics, topLevelEnv, rawEnv),
|
102577
102605
|
usage_model: inheritable(
|
102578
102606
|
diagnostics,
|
102579
102607
|
topLevelEnv,
|
@@ -102795,7 +102823,7 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
|
|
102795
102823
|
rawEnv,
|
102796
102824
|
envName,
|
102797
102825
|
"browser",
|
102798
|
-
|
102826
|
+
validateNamedSimpleBinding(envName),
|
102799
102827
|
void 0
|
102800
102828
|
),
|
102801
102829
|
ai: notInheritable(
|
@@ -102808,6 +102836,16 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
|
|
102808
102836
|
validateAIBinding(envName),
|
102809
102837
|
void 0
|
102810
102838
|
),
|
102839
|
+
images: notInheritable(
|
102840
|
+
diagnostics,
|
102841
|
+
topLevelEnv,
|
102842
|
+
rawConfig,
|
102843
|
+
rawEnv,
|
102844
|
+
envName,
|
102845
|
+
"images",
|
102846
|
+
validateNamedSimpleBinding(envName),
|
102847
|
+
void 0
|
102848
|
+
),
|
102811
102849
|
pipelines: notInheritable(
|
102812
102850
|
diagnostics,
|
102813
102851
|
topLevelEnv,
|
@@ -103339,6 +103377,13 @@ var validateAssetsConfig = /* @__PURE__ */ __name((diagnostics, field, value) =>
|
|
103339
103377
|
"string",
|
103340
103378
|
["single-page-application", "404-page", "none"]
|
103341
103379
|
) && isValid2;
|
103380
|
+
isValid2 = validateOptionalProperty(
|
103381
|
+
diagnostics,
|
103382
|
+
field,
|
103383
|
+
"run_worker_first",
|
103384
|
+
value.run_worker_first,
|
103385
|
+
"boolean"
|
103386
|
+
) && isValid2;
|
103342
103387
|
isValid2 = validateOptionalProperty(
|
103343
103388
|
diagnostics,
|
103344
103389
|
field,
|
@@ -103351,11 +103396,12 @@ var validateAssetsConfig = /* @__PURE__ */ __name((diagnostics, field, value) =>
|
|
103351
103396
|
"binding",
|
103352
103397
|
"html_handling",
|
103353
103398
|
"not_found_handling",
|
103399
|
+
"run_worker_first",
|
103354
103400
|
"experimental_serve_directly"
|
103355
103401
|
]) && isValid2;
|
103356
103402
|
return isValid2;
|
103357
103403
|
}, "validateAssetsConfig");
|
103358
|
-
var
|
103404
|
+
var validateNamedSimpleBinding = /* @__PURE__ */ __name((envName) => (diagnostics, field, value, config) => {
|
103359
103405
|
const fieldPath = config === void 0 ? `${field}` : `env.${envName}.${field}`;
|
103360
103406
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
103361
103407
|
diagnostics.errors.push(
|
@@ -103374,7 +103420,7 @@ var validateBrowserBinding = /* @__PURE__ */ __name((envName) => (diagnostics, f
|
|
103374
103420
|
"binding"
|
103375
103421
|
]);
|
103376
103422
|
return isValid2;
|
103377
|
-
}, "
|
103423
|
+
}, "validateNamedSimpleBinding");
|
103378
103424
|
var validateAIBinding = /* @__PURE__ */ __name((envName) => (diagnostics, field, value, config) => {
|
103379
103425
|
const fieldPath = config === void 0 ? `${field}` : `env.${envName}.${field}`;
|
103380
103426
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
@@ -104520,6 +104566,7 @@ var defaultWranglerConfig = {
|
|
104520
104566
|
services: [],
|
104521
104567
|
analytics_engine_datasets: [],
|
104522
104568
|
ai: void 0,
|
104569
|
+
images: void 0,
|
104523
104570
|
version_metadata: void 0,
|
104524
104571
|
/*====================================================*/
|
104525
104572
|
/* Fields supported by Workers only */
|
@@ -108589,7 +108636,9 @@ async function matchFiles(files, relativeTo, { rules, removedRules }) {
|
|
108589
108636
|
continue;
|
108590
108637
|
}
|
108591
108638
|
const absoluteFilePath = import_node_path12.default.join(relativeTo, filePath);
|
108592
|
-
const fileContent = await (0, import_promises3.readFile)(
|
108639
|
+
const fileContent = await (0, import_promises3.readFile)(
|
108640
|
+
absoluteFilePath
|
108641
|
+
);
|
108593
108642
|
const module3 = {
|
108594
108643
|
name: filePath,
|
108595
108644
|
content: fileContent,
|
@@ -108755,7 +108804,9 @@ function createModuleCollector(props) {
|
|
108755
108804
|
props.wrangler1xLegacyModuleReferences.rootDirectory,
|
108756
108805
|
args.path
|
108757
108806
|
);
|
108758
|
-
const fileContent = await (0, import_promises4.readFile)(
|
108807
|
+
const fileContent = await (0, import_promises4.readFile)(
|
108808
|
+
filePath
|
108809
|
+
);
|
108759
108810
|
const fileHash = import_node_crypto3.default.createHash("sha1").update(fileContent).digest("hex");
|
108760
108811
|
const fileName = props.preserveFileNames ? args.path : `./${fileHash}-${import_node_path13.default.basename(args.path)}`;
|
108761
108812
|
const { rule } = rulesMatchers.find(({ regex: regex2 }) => regex2.test(fileName)) || {};
|
@@ -108818,7 +108869,9 @@ function createModuleCollector(props) {
|
|
108818
108869
|
filePath = resolved;
|
108819
108870
|
} catch (e7) {
|
108820
108871
|
}
|
108821
|
-
const fileContent = await (0, import_promises4.readFile)(
|
108872
|
+
const fileContent = await (0, import_promises4.readFile)(
|
108873
|
+
filePath
|
108874
|
+
);
|
108822
108875
|
const fileHash = import_node_crypto3.default.createHash("sha1").update(fileContent).digest("hex");
|
108823
108876
|
const fileName = props.preserveFileNames ? args.path : `./${fileHash}-${import_node_path13.default.basename(args.path)}`;
|
108824
108877
|
modules.push({
|
@@ -108915,12 +108968,218 @@ function withSourceURLs(entrypointPath, entrypointSource, modules) {
|
|
108915
108968
|
}
|
108916
108969
|
__name(withSourceURLs, "withSourceURLs");
|
108917
108970
|
|
108971
|
+
// src/images/fetcher.ts
|
108972
|
+
init_import_meta_url();
|
108973
|
+
var import_miniflare3 = require("miniflare");
|
108974
|
+
|
108975
|
+
// src/images/local.ts
|
108976
|
+
init_import_meta_url();
|
108977
|
+
var import_buffer = require("buffer");
|
108978
|
+
var import_sharp = __toESM(require("sharp"));
|
108979
|
+
function validateTransforms(inputTransforms) {
|
108980
|
+
if (!Array.isArray(inputTransforms)) {
|
108981
|
+
return null;
|
108982
|
+
}
|
108983
|
+
for (const transform of inputTransforms) {
|
108984
|
+
for (const key of ["imageIndex", "rotate", "width", "height"]) {
|
108985
|
+
if (transform[key] !== void 0 && typeof transform[key] != "number") {
|
108986
|
+
return null;
|
108987
|
+
}
|
108988
|
+
}
|
108989
|
+
}
|
108990
|
+
return inputTransforms;
|
108991
|
+
}
|
108992
|
+
__name(validateTransforms, "validateTransforms");
|
108993
|
+
async function imagesLocalFetcher(request4) {
|
108994
|
+
const data = await request4.formData();
|
108995
|
+
const body = data.get("image");
|
108996
|
+
if (!body || !(body instanceof import_buffer.File)) {
|
108997
|
+
return errorResponse(
|
108998
|
+
400,
|
108999
|
+
9523,
|
109000
|
+
`ERROR: Internal Images binding error: expected image in request, got ${body}`
|
109001
|
+
);
|
109002
|
+
}
|
109003
|
+
const transformer = (0, import_sharp.default)(await body.arrayBuffer(), {});
|
109004
|
+
const url4 = new URL(request4.url);
|
109005
|
+
if (url4.pathname == "/info") {
|
109006
|
+
return runInfo(transformer);
|
109007
|
+
} else {
|
109008
|
+
const badTransformsResponse = errorResponse(
|
109009
|
+
400,
|
109010
|
+
9523,
|
109011
|
+
"ERROR: Internal Images binding error: Expected JSON array of valid transforms in transforms field"
|
109012
|
+
);
|
109013
|
+
try {
|
109014
|
+
const transformsJson = data.get("transforms");
|
109015
|
+
if (typeof transformsJson !== "string") {
|
109016
|
+
return badTransformsResponse;
|
109017
|
+
}
|
109018
|
+
const transforms = validateTransforms(JSON.parse(transformsJson));
|
109019
|
+
if (transforms === null) {
|
109020
|
+
return badTransformsResponse;
|
109021
|
+
}
|
109022
|
+
const outputFormat = data.get("output_format");
|
109023
|
+
if (outputFormat != null && typeof outputFormat !== "string") {
|
109024
|
+
return errorResponse(
|
109025
|
+
400,
|
109026
|
+
9523,
|
109027
|
+
"ERROR: Internal Images binding error: Expected output format to be a string if provided"
|
109028
|
+
);
|
109029
|
+
}
|
109030
|
+
return runTransform(transformer, transforms, outputFormat);
|
109031
|
+
} catch (e7) {
|
109032
|
+
return badTransformsResponse;
|
109033
|
+
}
|
109034
|
+
}
|
109035
|
+
}
|
109036
|
+
__name(imagesLocalFetcher, "imagesLocalFetcher");
|
109037
|
+
async function runInfo(transformer) {
|
109038
|
+
const metadata = await transformer.metadata();
|
109039
|
+
let mime = null;
|
109040
|
+
switch (metadata.format) {
|
109041
|
+
case "jpeg":
|
109042
|
+
mime = "image/jpeg";
|
109043
|
+
break;
|
109044
|
+
case "svg":
|
109045
|
+
mime = "image/svg+xml";
|
109046
|
+
break;
|
109047
|
+
case "png":
|
109048
|
+
mime = "image/png";
|
109049
|
+
break;
|
109050
|
+
case "webp":
|
109051
|
+
mime = "image/webp";
|
109052
|
+
break;
|
109053
|
+
case "gif":
|
109054
|
+
mime = "image/gif";
|
109055
|
+
break;
|
109056
|
+
case "avif":
|
109057
|
+
mime = "image/avif";
|
109058
|
+
break;
|
109059
|
+
default:
|
109060
|
+
return errorResponse(
|
109061
|
+
415,
|
109062
|
+
9520,
|
109063
|
+
`ERROR: Unsupported image type ${metadata.format}, expected one of: JPEG, SVG, PNG, WebP, GIF or AVIF`
|
109064
|
+
);
|
109065
|
+
}
|
109066
|
+
let resp;
|
109067
|
+
if (mime == "image/svg+xml") {
|
109068
|
+
resp = {
|
109069
|
+
format: mime
|
109070
|
+
};
|
109071
|
+
} else {
|
109072
|
+
if (!metadata.size || !metadata.width || !metadata.height) {
|
109073
|
+
return errorResponse(
|
109074
|
+
500,
|
109075
|
+
9523,
|
109076
|
+
"ERROR: Internal Images binding error: Expected size, width and height for bitmap input"
|
109077
|
+
);
|
109078
|
+
}
|
109079
|
+
resp = {
|
109080
|
+
format: mime,
|
109081
|
+
fileSize: metadata.size,
|
109082
|
+
width: metadata.width,
|
109083
|
+
height: metadata.height
|
109084
|
+
};
|
109085
|
+
}
|
109086
|
+
return Response.json(resp);
|
109087
|
+
}
|
109088
|
+
__name(runInfo, "runInfo");
|
109089
|
+
async function runTransform(transformer, transforms, outputFormat) {
|
109090
|
+
for (const transform of transforms) {
|
109091
|
+
if (transform.imageIndex !== void 0 && transform.imageIndex !== 0) {
|
109092
|
+
continue;
|
109093
|
+
}
|
109094
|
+
if (transform.rotate !== void 0) {
|
109095
|
+
transformer.rotate(transform.rotate);
|
109096
|
+
}
|
109097
|
+
if (transform.width !== void 0 || transform.height !== void 0) {
|
109098
|
+
transformer.resize(transform.width || null, transform.height || null, {
|
109099
|
+
fit: "contain"
|
109100
|
+
});
|
109101
|
+
}
|
109102
|
+
}
|
109103
|
+
switch (outputFormat) {
|
109104
|
+
case "image/avif":
|
109105
|
+
transformer.avif();
|
109106
|
+
break;
|
109107
|
+
case "image/gif":
|
109108
|
+
return errorResponse(
|
109109
|
+
415,
|
109110
|
+
9520,
|
109111
|
+
"ERROR: GIF output is not supported in local mode"
|
109112
|
+
);
|
109113
|
+
case "image/jpeg":
|
109114
|
+
transformer.jpeg();
|
109115
|
+
break;
|
109116
|
+
case "image/png":
|
109117
|
+
transformer.png();
|
109118
|
+
break;
|
109119
|
+
case "image/webp":
|
109120
|
+
transformer.webp();
|
109121
|
+
break;
|
109122
|
+
case "rgb":
|
109123
|
+
case "rgba":
|
109124
|
+
return errorResponse(
|
109125
|
+
415,
|
109126
|
+
9520,
|
109127
|
+
"ERROR: RGB/RGBA output is not supported in local mode"
|
109128
|
+
);
|
109129
|
+
default:
|
109130
|
+
outputFormat = "image/jpeg";
|
109131
|
+
break;
|
109132
|
+
}
|
109133
|
+
return new Response(transformer, {
|
109134
|
+
headers: {
|
109135
|
+
"content-type": outputFormat
|
109136
|
+
}
|
109137
|
+
});
|
109138
|
+
}
|
109139
|
+
__name(runTransform, "runTransform");
|
109140
|
+
function errorResponse(status2, code, message) {
|
109141
|
+
return new Response(`ERROR ${code}: ${message}`, {
|
109142
|
+
status: status2,
|
109143
|
+
headers: {
|
109144
|
+
"content-type": "text/plain",
|
109145
|
+
"cf-images-binding": `err=${code}`
|
109146
|
+
}
|
109147
|
+
});
|
109148
|
+
}
|
109149
|
+
__name(errorResponse, "errorResponse");
|
109150
|
+
|
109151
|
+
// src/images/fetcher.ts
|
109152
|
+
var EXTERNAL_IMAGES_WORKER_NAME = "__WRANGLER_EXTERNAL_IMAGES_WORKER";
|
109153
|
+
var EXTERNAL_IMAGES_WORKER_SCRIPT = `
|
109154
|
+
import makeBinding from 'cloudflare-internal:images-api'
|
109155
|
+
|
109156
|
+
export default function (env) {
|
109157
|
+
return makeBinding({
|
109158
|
+
fetcher: env.FETCHER,
|
109159
|
+
});
|
109160
|
+
}
|
109161
|
+
`;
|
109162
|
+
async function imagesRemoteFetcher(request4) {
|
109163
|
+
const accountId = await getAccountId();
|
109164
|
+
const url4 = `/accounts/${accountId}/images_edge/v2/binding/preview${new URL(request4.url).pathname}`;
|
109165
|
+
const res = await performApiFetch(url4, {
|
109166
|
+
method: request4.method,
|
109167
|
+
body: request4.body,
|
109168
|
+
duplex: "half",
|
109169
|
+
headers: {
|
109170
|
+
"content-type": request4.headers.get("content-type") || ""
|
109171
|
+
}
|
109172
|
+
});
|
109173
|
+
return new import_miniflare3.Response(res.body, { headers: res.headers });
|
109174
|
+
}
|
109175
|
+
__name(imagesRemoteFetcher, "imagesRemoteFetcher");
|
109176
|
+
|
108918
109177
|
// src/sourcemap.ts
|
108919
109178
|
init_import_meta_url();
|
108920
109179
|
var import_node_assert4 = __toESM(require("node:assert"));
|
108921
109180
|
var import_node_fs8 = __toESM(require("node:fs"));
|
108922
109181
|
var import_node_url5 = __toESM(require("node:url"));
|
108923
|
-
var
|
109182
|
+
var import_miniflare4 = require("miniflare");
|
108924
109183
|
function maybeGetFile(filePath) {
|
108925
109184
|
try {
|
108926
109185
|
return import_node_fs8.default.readFileSync(filePath, "utf8");
|
@@ -108968,7 +109227,7 @@ function getSourceMappingPrepareStackTrace(retrieveSourceMap) {
|
|
108968
109227
|
if (sourceMappingPrepareStackTrace !== void 0) {
|
108969
109228
|
return sourceMappingPrepareStackTrace;
|
108970
109229
|
}
|
108971
|
-
const support = (0,
|
109230
|
+
const support = (0, import_miniflare4.getFreshSourceMapSupport)();
|
108972
109231
|
const originalPrepareStackTrace = Error.prepareStackTrace;
|
108973
109232
|
support.install({
|
108974
109233
|
environment: "node",
|
@@ -109175,7 +109434,7 @@ __name(updateCheck, "updateCheck");
|
|
109175
109434
|
|
109176
109435
|
// src/vectorize/fetcher.ts
|
109177
109436
|
init_import_meta_url();
|
109178
|
-
var
|
109437
|
+
var import_miniflare5 = require("miniflare");
|
109179
109438
|
var EXTERNAL_VECTORIZE_WORKER_NAME = "__WRANGLER_EXTERNAL_VECTORIZE_WORKER";
|
109180
109439
|
var EXTERNAL_VECTORIZE_WORKER_SCRIPT = `
|
109181
109440
|
import makeBinding from 'cloudflare-internal:vectorize-api'
|
@@ -109208,7 +109467,7 @@ function MakeVectorizeFetcher(indexId) {
|
|
109208
109467
|
body: request4.body,
|
109209
109468
|
duplex: "half"
|
109210
109469
|
});
|
109211
|
-
const respHeaders = new
|
109470
|
+
const respHeaders = new import_miniflare5.Headers(res.headers);
|
109212
109471
|
respHeaders.delete("Host");
|
109213
109472
|
respHeaders.delete("Content-Length");
|
109214
109473
|
const apiResponse = await res.json();
|
@@ -109216,7 +109475,7 @@ function MakeVectorizeFetcher(indexId) {
|
|
109216
109475
|
error: apiResponse.errors[0].message,
|
109217
109476
|
code: apiResponse.errors[0].code
|
109218
109477
|
};
|
109219
|
-
return new
|
109478
|
+
return new import_miniflare5.Response(JSON.stringify(newResponse), {
|
109220
109479
|
status: res.status,
|
109221
109480
|
headers: respHeaders
|
109222
109481
|
});
|
@@ -109374,7 +109633,7 @@ export default {
|
|
109374
109633
|
}
|
109375
109634
|
}
|
109376
109635
|
`;
|
109377
|
-
var WranglerLog = class extends
|
109636
|
+
var WranglerLog = class extends import_miniflare6.Log {
|
109378
109637
|
#warnedCompatibilityDateFallback = false;
|
109379
109638
|
log(message) {
|
109380
109639
|
if (message.includes(EXTERNAL_SERVICE_WORKER_NAME)) {
|
@@ -109419,13 +109678,13 @@ function castLogLevel(level) {
|
|
109419
109678
|
if (key === "LOG") {
|
109420
109679
|
key = "INFO";
|
109421
109680
|
}
|
109422
|
-
return
|
109681
|
+
return import_miniflare6.LogLevel[key];
|
109423
109682
|
}
|
109424
109683
|
__name(castLogLevel, "castLogLevel");
|
109425
109684
|
function buildLog() {
|
109426
109685
|
let level = castLogLevel(logger.loggerLevel);
|
109427
|
-
if (level <=
|
109428
|
-
level = Math.min(level,
|
109686
|
+
if (level <= import_miniflare6.LogLevel.DEBUG) {
|
109687
|
+
level = Math.min(level, import_miniflare6.LogLevel.WARN);
|
109429
109688
|
}
|
109430
109689
|
return new WranglerLog(level, { prefix: "wrangler-UserWorker" });
|
109431
109690
|
}
|
@@ -109565,7 +109824,7 @@ function buildMiniflareBindingOptions(config) {
|
|
109565
109824
|
};
|
109566
109825
|
} else {
|
109567
109826
|
let address;
|
109568
|
-
let style =
|
109827
|
+
let style = import_miniflare6.HttpOptions_Style.PROXY;
|
109569
109828
|
if (service.entrypoint !== void 0) {
|
109570
109829
|
if (target.entrypointAddresses === void 0) {
|
109571
109830
|
throw new UserError(
|
@@ -109588,7 +109847,7 @@ function buildMiniflareBindingOptions(config) {
|
|
109588
109847
|
);
|
109589
109848
|
}
|
109590
109849
|
address = `${target.host}:${target.port}`;
|
109591
|
-
style =
|
109850
|
+
style = import_miniflare6.HttpOptions_Style.HOST;
|
109592
109851
|
} else {
|
109593
109852
|
address = `${defaultEntrypointAddress.host}:${defaultEntrypointAddress.port}`;
|
109594
109853
|
}
|
@@ -109598,7 +109857,7 @@ function buildMiniflareBindingOptions(config) {
|
|
109598
109857
|
address,
|
109599
109858
|
http: {
|
109600
109859
|
style,
|
109601
|
-
cfBlobHeader:
|
109860
|
+
cfBlobHeader: import_miniflare6.CoreHeaders.CF_BLOB
|
109602
109861
|
}
|
109603
109862
|
}
|
109604
109863
|
};
|
@@ -109681,6 +109940,24 @@ function buildMiniflareBindingOptions(config) {
|
|
109681
109940
|
scriptName: EXTERNAL_AI_WORKER_NAME
|
109682
109941
|
};
|
109683
109942
|
}
|
109943
|
+
if (bindings.images?.binding) {
|
109944
|
+
externalWorkers.push({
|
109945
|
+
name: EXTERNAL_IMAGES_WORKER_NAME,
|
109946
|
+
modules: [
|
109947
|
+
{
|
109948
|
+
type: "ESModule",
|
109949
|
+
path: "index.mjs",
|
109950
|
+
contents: EXTERNAL_IMAGES_WORKER_SCRIPT
|
109951
|
+
}
|
109952
|
+
],
|
109953
|
+
serviceBindings: {
|
109954
|
+
FETCHER: config.imagesLocalMode ? imagesLocalFetcher : imagesRemoteFetcher
|
109955
|
+
}
|
109956
|
+
});
|
109957
|
+
wrappedBindings[bindings.images?.binding] = {
|
109958
|
+
scriptName: EXTERNAL_IMAGES_WORKER_NAME
|
109959
|
+
};
|
109960
|
+
}
|
109684
109961
|
if (bindings.vectorize) {
|
109685
109962
|
for (const vectorizeBinding of bindings.vectorize) {
|
109686
109963
|
const bindingName = vectorizeBinding.binding;
|
@@ -109895,6 +110172,7 @@ __name(handleRuntimeStdio, "handleRuntimeStdio");
|
|
109895
110172
|
var didWarnMiniflareCronSupport = false;
|
109896
110173
|
var didWarnMiniflareVectorizeSupport = false;
|
109897
110174
|
var didWarnAiAccountUsage = false;
|
110175
|
+
var didWarnImagesLocalModeUsage = false;
|
109898
110176
|
async function buildMiniflareOptions(log2, config, proxyToUserWorkerAuthenticationSecret) {
|
109899
110177
|
if (config.crons.length > 0 && !config.testScheduled) {
|
109900
110178
|
if (!didWarnMiniflareCronSupport) {
|
@@ -109926,6 +110204,14 @@ async function buildMiniflareOptions(log2, config, proxyToUserWorkerAuthenticati
|
|
109926
110204
|
);
|
109927
110205
|
}
|
109928
110206
|
}
|
110207
|
+
if (config.bindings.images && config.imagesLocalMode) {
|
110208
|
+
if (!didWarnImagesLocalModeUsage) {
|
110209
|
+
didWarnImagesLocalModeUsage = true;
|
110210
|
+
logger.info(
|
110211
|
+
"You are using Images local mode. This only supports resizing, rotating and transcoding."
|
110212
|
+
);
|
110213
|
+
}
|
110214
|
+
}
|
109929
110215
|
const upstream = typeof config.localUpstream === "string" ? `${config.upstreamProtocol}://${config.localUpstream}` : void 0;
|
109930
110216
|
const { sourceOptions, entrypointNames } = await buildSourceOptions(config);
|
109931
110217
|
const { bindingOptions, internalObjects, externalWorkers } = buildMiniflareBindingOptions(config);
|
@@ -109988,7 +110274,7 @@ __name(castErrorCause, "castErrorCause");
|
|
109988
110274
|
init_import_meta_url();
|
109989
110275
|
var import_node_crypto5 = require("node:crypto");
|
109990
110276
|
var import_promises6 = require("node:fs/promises");
|
109991
|
-
var
|
110277
|
+
var import_miniflare7 = require("miniflare");
|
109992
110278
|
|
109993
110279
|
// src/api/startDevWorker/BaseController.ts
|
109994
110280
|
init_import_meta_url();
|
@@ -110167,6 +110453,11 @@ function convertCfWorkerInitBindingstoBindings(inputBindings) {
|
|
110167
110453
|
output[binding] = { type: "ai", ...x6 };
|
110168
110454
|
break;
|
110169
110455
|
}
|
110456
|
+
case "images": {
|
110457
|
+
const { binding, ...x6 } = info;
|
110458
|
+
output[binding] = { type: "images", ...x6 };
|
110459
|
+
break;
|
110460
|
+
}
|
110170
110461
|
case "version_metadata": {
|
110171
110462
|
const { binding, ...x6 } = info;
|
110172
110463
|
output[binding] = { type: "version_metadata", ...x6 };
|
@@ -110217,6 +110508,7 @@ async function convertBindingsToCfWorkerInitBindings(inputBindings) {
|
|
110217
110508
|
text_blobs: void 0,
|
110218
110509
|
browser: void 0,
|
110219
110510
|
ai: void 0,
|
110511
|
+
images: void 0,
|
110220
110512
|
version_metadata: void 0,
|
110221
110513
|
data_blobs: void 0,
|
110222
110514
|
durable_objects: void 0,
|
@@ -110268,6 +110560,8 @@ async function convertBindingsToCfWorkerInitBindings(inputBindings) {
|
|
110268
110560
|
bindings.browser = { binding: name2 };
|
110269
110561
|
} else if (binding.type === "ai") {
|
110270
110562
|
bindings.ai = { binding: name2 };
|
110563
|
+
} else if (binding.type === "images") {
|
110564
|
+
bindings.images = { binding: name2 };
|
110271
110565
|
} else if (binding.type === "version_metadata") {
|
110272
110566
|
bindings.version_metadata = { binding: name2 };
|
110273
110567
|
} else if (binding.type === "durable_object_namespace") {
|
@@ -110439,6 +110733,7 @@ async function convertToConfigBundle(event) {
|
|
110439
110733
|
services: bindings.services,
|
110440
110734
|
serviceBindings: fetchers,
|
110441
110735
|
bindVectorizeToProd: event.config.dev?.bindVectorizeToProd ?? false,
|
110736
|
+
imagesLocalMode: event.config.dev?.imagesLocalMode ?? false,
|
110442
110737
|
testScheduled: !!event.config.dev.testScheduled
|
110443
110738
|
};
|
110444
110739
|
}
|
@@ -110456,7 +110751,7 @@ var LocalRuntimeController = class extends RuntimeController {
|
|
110456
110751
|
// `buildMiniflareOptions()` is asynchronous, meaning if multiple bundle
|
110457
110752
|
// updates were submitted, the second may apply before the first. Therefore,
|
110458
110753
|
// wrap updates in a mutex, so they're always applied in invocation order.
|
110459
|
-
#mutex = new
|
110754
|
+
#mutex = new import_miniflare7.Mutex();
|
110460
110755
|
#mf;
|
110461
110756
|
onBundleStart(_4) {
|
110462
110757
|
}
|
@@ -110470,7 +110765,7 @@ var LocalRuntimeController = class extends RuntimeController {
|
|
110470
110765
|
options30.liveReload = false;
|
110471
110766
|
if (this.#mf === void 0) {
|
110472
110767
|
logger.log(source_default.dim("\u2394 Starting local server..."));
|
110473
|
-
this.#mf = new
|
110768
|
+
this.#mf = new import_miniflare7.Miniflare(options30);
|
110474
110769
|
} else {
|
110475
110770
|
logger.log(source_default.dim("\u2394 Reloading local server..."));
|
110476
110771
|
await this.#mf.setOptions(options30);
|
@@ -110607,7 +110902,7 @@ var MultiworkerRuntimeController = class extends LocalRuntimeController {
|
|
110607
110902
|
// `buildMiniflareOptions()` is asynchronous, meaning if multiple bundle
|
110608
110903
|
// updates were submitted, the second may apply before the first. Therefore,
|
110609
110904
|
// wrap updates in a mutex, so they're always applied in invocation order.
|
110610
|
-
#mutex = new
|
110905
|
+
#mutex = new import_miniflare8.Mutex();
|
110611
110906
|
#mf;
|
110612
110907
|
#options = /* @__PURE__ */ new Map();
|
110613
110908
|
#canStartMiniflare() {
|
@@ -110645,7 +110940,7 @@ var MultiworkerRuntimeController = class extends LocalRuntimeController {
|
|
110645
110940
|
const mergedMfOptions = ensureMatchingSql(this.#mergedMfOptions());
|
110646
110941
|
if (this.#mf === void 0) {
|
110647
110942
|
logger.log(source_default.dim("\u2394 Starting local server..."));
|
110648
|
-
this.#mf = new
|
110943
|
+
this.#mf = new import_miniflare8.Miniflare(mergedMfOptions);
|
110649
110944
|
} else {
|
110650
110945
|
logger.log(source_default.dim("\u2394 Reloading local server..."));
|
110651
110946
|
await this.#mf.setOptions(mergedMfOptions);
|
@@ -110743,7 +111038,7 @@ var import_node_assert9 = __toESM(require("node:assert"));
|
|
110743
111038
|
var import_node_crypto7 = require("node:crypto");
|
110744
111039
|
var import_node_events2 = __toESM(require("node:events"));
|
110745
111040
|
var import_node_path18 = __toESM(require("node:path"));
|
110746
|
-
var
|
111041
|
+
var import_miniflare10 = require("miniflare");
|
110747
111042
|
|
110748
111043
|
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/wrangler/templates/startDevWorker/InspectorProxyWorker.ts
|
110749
111044
|
init_import_meta_url();
|
@@ -111054,7 +111349,7 @@ var openInspector = /* @__PURE__ */ __name(async (inspectorPort, worker) => {
|
|
111054
111349
|
init_import_meta_url();
|
111055
111350
|
var fs9 = __toESM(require("node:fs"));
|
111056
111351
|
var path20 = __toESM(require("node:path"));
|
111057
|
-
var
|
111352
|
+
var import_miniflare9 = require("miniflare");
|
111058
111353
|
var CERT_EXPIRY_DAYS = 30;
|
111059
111354
|
var ONE_DAY_IN_MS = 864e5;
|
111060
111355
|
var getHttpsKeyPathFromEnv = getEnvironmentVariableFactory({
|
@@ -111154,7 +111449,7 @@ function generateCertificate() {
|
|
111154
111449
|
name: "subjectAltName",
|
111155
111450
|
altNames: [
|
111156
111451
|
{ type: 2, value: "localhost" },
|
111157
|
-
...(0,
|
111452
|
+
...(0, import_miniflare9.getAccessibleHosts)(false).map((ip) => ({ type: 7, ip }))
|
111158
111453
|
]
|
111159
111454
|
}
|
111160
111455
|
]
|
@@ -111205,7 +111500,7 @@ var ProxyController = class extends Controller {
|
|
111205
111500
|
PROXY_CONTROLLER: async (req) => {
|
111206
111501
|
const message = await req.json();
|
111207
111502
|
this.onProxyWorkerMessage(message);
|
111208
|
-
return new
|
111503
|
+
return new import_miniflare10.Response(null, { status: 204 });
|
111209
111504
|
}
|
111210
111505
|
},
|
111211
111506
|
bindings: {
|
@@ -111266,7 +111561,7 @@ var ProxyController = class extends Controller {
|
|
111266
111561
|
proxyWorkerOptions
|
111267
111562
|
);
|
111268
111563
|
const willInstantiateMiniflareInstance = !this.proxyWorker || proxyWorkerOptionsChanged;
|
111269
|
-
this.proxyWorker ??= new
|
111564
|
+
this.proxyWorker ??= new import_miniflare10.Miniflare(proxyWorkerOptions);
|
111270
111565
|
this.proxyWorkerOptions = proxyWorkerOptions;
|
111271
111566
|
if (proxyWorkerOptionsChanged) {
|
111272
111567
|
logger.debug("ProxyWorker miniflare options changed, reinstantiating...");
|
@@ -111348,7 +111643,7 @@ var ProxyController = class extends Controller {
|
|
111348
111643
|
this.inspectorProxyWorkerWebSocket?.resolve(webSocket);
|
111349
111644
|
return webSocket;
|
111350
111645
|
}
|
111351
|
-
runtimeMessageMutex = new
|
111646
|
+
runtimeMessageMutex = new import_miniflare10.Mutex();
|
111352
111647
|
async sendMessageToProxyWorker(message, retries = 3) {
|
111353
111648
|
if (this._torndown) {
|
111354
111649
|
return;
|
@@ -111501,15 +111796,15 @@ var ProxyController = class extends Controller {
|
|
111501
111796
|
);
|
111502
111797
|
}
|
111503
111798
|
if (maybeContents === void 0) {
|
111504
|
-
return new
|
111799
|
+
return new import_miniflare10.Response(null, { status: 404 });
|
111505
111800
|
}
|
111506
|
-
return new
|
111801
|
+
return new import_miniflare10.Response(maybeContents);
|
111507
111802
|
}
|
111508
111803
|
default:
|
111509
111804
|
assertNever(message);
|
111510
|
-
return new
|
111805
|
+
return new import_miniflare10.Response(null, { status: 404 });
|
111511
111806
|
}
|
111512
|
-
return new
|
111807
|
+
return new import_miniflare10.Response(null, { status: 204 });
|
111513
111808
|
}
|
111514
111809
|
_torndown = false;
|
111515
111810
|
async teardown() {
|
@@ -111562,7 +111857,7 @@ var ProxyController = class extends Controller {
|
|
111562
111857
|
__name(ProxyController, "ProxyController");
|
111563
111858
|
var ProxyControllerLogger = class extends WranglerLog {
|
111564
111859
|
log(message) {
|
111565
|
-
if (message.includes("/cdn-cgi/") && this.level <
|
111860
|
+
if (message.includes("/cdn-cgi/") && this.level < import_miniflare10.LogLevel.DEBUG) {
|
111566
111861
|
return;
|
111567
111862
|
}
|
111568
111863
|
super.log(message);
|
@@ -115409,7 +115704,8 @@ var AssetConfigSchema = z2.object({
|
|
115409
115704
|
"none"
|
115410
115705
|
]).optional(),
|
115411
115706
|
not_found_handling: z2.enum(["single-page-application", "404-page", "none"]).optional(),
|
115412
|
-
serve_directly: z2.boolean().optional()
|
115707
|
+
serve_directly: z2.boolean().optional(),
|
115708
|
+
run_worker_first: z2.boolean().optional()
|
115413
115709
|
});
|
115414
115710
|
var InternalConfigSchema = z2.object({
|
115415
115711
|
// Used for analytics and reporting
|
@@ -116156,8 +116452,7 @@ var Handler2 = withConfig(
|
|
116156
116452
|
}
|
116157
116453
|
}
|
116158
116454
|
);
|
116159
|
-
var listDatabases = /* @__PURE__ */ __name(async (accountId, limitCalls = false) => {
|
116160
|
-
const pageSize = 10;
|
116455
|
+
var listDatabases = /* @__PURE__ */ __name(async (accountId, limitCalls = false, pageSize = 10) => {
|
116161
116456
|
let page = 1;
|
116162
116457
|
const results = [];
|
116163
116458
|
while (results.length % pageSize === 0) {
|
@@ -116217,22 +116512,22 @@ var getDatabaseByNameOrBinding = /* @__PURE__ */ __name(async (config, accountId
|
|
116217
116512
|
}
|
116218
116513
|
return matchingDB;
|
116219
116514
|
}, "getDatabaseByNameOrBinding");
|
116220
|
-
var
|
116515
|
+
var getDatabaseInfoFromIdOrName = /* @__PURE__ */ __name(async (accountId, databaseIdOrName) => {
|
116221
116516
|
return await fetchResult(
|
116222
|
-
`/accounts/${accountId}/d1/database/${
|
116517
|
+
`/accounts/${accountId}/d1/database/${databaseIdOrName}`,
|
116223
116518
|
{
|
116224
116519
|
headers: {
|
116225
116520
|
"Content-Type": "application/json"
|
116226
116521
|
}
|
116227
116522
|
}
|
116228
116523
|
);
|
116229
|
-
}, "
|
116524
|
+
}, "getDatabaseInfoFromIdOrName");
|
116230
116525
|
|
116231
116526
|
// src/kv/helpers.ts
|
116232
116527
|
init_import_meta_url();
|
116233
116528
|
var import_node_buffer = require("node:buffer");
|
116234
116529
|
var import_node_url8 = require("node:url");
|
116235
|
-
var
|
116530
|
+
var import_miniflare12 = require("miniflare");
|
116236
116531
|
var import_undici4 = __toESM(require_undici());
|
116237
116532
|
|
116238
116533
|
// src/dev/get-local-persistence-path.ts
|
@@ -116503,7 +116798,7 @@ __name(getKVNamespaceId, "getKVNamespaceId");
|
|
116503
116798
|
async function usingLocalNamespace(persistTo, config, namespaceId, closure) {
|
116504
116799
|
const persist = getLocalPersistencePath(persistTo, config);
|
116505
116800
|
const persistOptions = buildPersistOptions(persist);
|
116506
|
-
const mf = new
|
116801
|
+
const mf = new import_miniflare12.Miniflare({
|
116507
116802
|
script: 'addEventListener("fetch", (e) => e.respondWith(new Response(null, { status: 404 })))',
|
116508
116803
|
...persistOptions,
|
116509
116804
|
kvNamespaces: { NAMESPACE: namespaceId }
|
@@ -116521,7 +116816,7 @@ __name(usingLocalNamespace, "usingLocalNamespace");
|
|
116521
116816
|
init_import_meta_url();
|
116522
116817
|
var fs10 = __toESM(require("node:fs"));
|
116523
116818
|
var import_web = require("node:stream/web");
|
116524
|
-
var
|
116819
|
+
var import_miniflare14 = require("miniflare");
|
116525
116820
|
|
116526
116821
|
// src/queues/client.ts
|
116527
116822
|
init_import_meta_url();
|
@@ -116961,7 +117256,7 @@ __name(deleteR2Object, "deleteR2Object");
|
|
116961
117256
|
async function usingLocalBucket(persistTo, config, bucketName, closure) {
|
116962
117257
|
const persist = getLocalPersistencePath(persistTo, config);
|
116963
117258
|
const persistOptions = buildPersistOptions(persist);
|
116964
|
-
const mf = new
|
117259
|
+
const mf = new import_miniflare14.Miniflare({
|
116965
117260
|
modules: true,
|
116966
117261
|
// TODO(soon): import `reduceError()` from `miniflare:shared`
|
116967
117262
|
script: `
|
@@ -117500,6 +117795,7 @@ function getBindings(config, options30) {
|
|
117500
117795
|
wasm_modules: options30?.pages ? void 0 : config?.wasm_modules,
|
117501
117796
|
browser: config?.browser,
|
117502
117797
|
ai: config?.ai,
|
117798
|
+
images: config?.images,
|
117503
117799
|
version_metadata: config?.version_metadata,
|
117504
117800
|
text_blobs: options30?.pages ? void 0 : config?.text_blobs,
|
117505
117801
|
data_blobs: options30?.pages ? void 0 : config?.data_blobs,
|
@@ -117527,144 +117823,264 @@ function getBindings(config, options30) {
|
|
117527
117823
|
};
|
117528
117824
|
}
|
117529
117825
|
__name(getBindings, "getBindings");
|
117530
|
-
|
117531
|
-
|
117532
|
-
|
117533
|
-
|
117534
|
-
|
117535
|
-
|
117536
|
-
|
117537
|
-
|
117538
|
-
|
117539
|
-
}
|
117540
|
-
|
117826
|
+
var ProvisionResourceHandler = class {
|
117827
|
+
constructor(type, binding, idField, accountId) {
|
117828
|
+
this.type = type;
|
117829
|
+
this.binding = binding;
|
117830
|
+
this.idField = idField;
|
117831
|
+
this.accountId = accountId;
|
117832
|
+
}
|
117833
|
+
inherit() {
|
117834
|
+
this.binding[this.idField] = INHERIT_SYMBOL;
|
117835
|
+
}
|
117836
|
+
connect(id) {
|
117837
|
+
this.binding[this.idField] = id;
|
117838
|
+
}
|
117839
|
+
async provision(name2) {
|
117840
|
+
const id = await this.create(name2);
|
117841
|
+
this.connect(id);
|
117842
|
+
}
|
117843
|
+
// This binding is fully specified and can't/shouldn't be provisioned
|
117844
|
+
// This is usually when it has an id (e.g. D1 `database_id`)
|
117845
|
+
isFullySpecified() {
|
117846
|
+
return false;
|
117541
117847
|
}
|
117542
|
-
|
117543
|
-
|
117544
|
-
|
117545
|
-
|
117848
|
+
// Does this binding need to be provisioned?
|
117849
|
+
// Some bindings are not fully specified, but don't need provisioning
|
117850
|
+
// (e.g. R2 binding, with a bucket_name that already exists)
|
117851
|
+
async isConnectedToExistingResource() {
|
117852
|
+
return false;
|
117853
|
+
}
|
117854
|
+
// Should this resource be provisioned?
|
117855
|
+
async shouldProvision(settings) {
|
117856
|
+
if (!this.isFullySpecified()) {
|
117857
|
+
if (await this.canInherit(settings)) {
|
117858
|
+
this.inherit();
|
117546
117859
|
} else {
|
117547
|
-
|
117548
|
-
|
117549
|
-
|
117550
|
-
|
117551
|
-
return id;
|
117552
|
-
},
|
117553
|
-
updateId(id) {
|
117554
|
-
kv.id = id;
|
117860
|
+
const connected = await this.isConnectedToExistingResource();
|
117861
|
+
if (connected) {
|
117862
|
+
if (typeof connected === "string") {
|
117863
|
+
this.connect(connected);
|
117555
117864
|
}
|
117556
|
-
|
117865
|
+
return false;
|
117866
|
+
}
|
117867
|
+
return true;
|
117557
117868
|
}
|
117558
117869
|
}
|
117870
|
+
return false;
|
117559
117871
|
}
|
117560
|
-
|
117561
|
-
|
117562
|
-
|
117563
|
-
|
117564
|
-
|
117565
|
-
|
117566
|
-
|
117567
|
-
|
117568
|
-
|
117569
|
-
|
117570
|
-
|
117571
|
-
|
117572
|
-
|
117573
|
-
|
117574
|
-
|
117575
|
-
|
117872
|
+
};
|
117873
|
+
__name(ProvisionResourceHandler, "ProvisionResourceHandler");
|
117874
|
+
var R2Handler = class extends ProvisionResourceHandler {
|
117875
|
+
get name() {
|
117876
|
+
return this.binding.bucket_name;
|
117877
|
+
}
|
117878
|
+
async create(name2) {
|
117879
|
+
await createR2Bucket(
|
117880
|
+
this.accountId,
|
117881
|
+
name2,
|
117882
|
+
void 0,
|
117883
|
+
this.binding.jurisdiction
|
117884
|
+
);
|
117885
|
+
return name2;
|
117886
|
+
}
|
117887
|
+
constructor(binding, accountId) {
|
117888
|
+
super("r2_bucket", binding, "bucket_name", accountId);
|
117889
|
+
}
|
117890
|
+
canInherit(settings) {
|
117891
|
+
return !!settings?.bindings.find(
|
117892
|
+
(existing) => existing.type === this.type && existing.name === this.binding.binding && existing.jurisdiction === this.binding.jurisdiction
|
117893
|
+
);
|
117894
|
+
}
|
117895
|
+
async isConnectedToExistingResource() {
|
117896
|
+
(0, import_node_assert10.default)(typeof this.binding.bucket_name !== "symbol");
|
117897
|
+
if (!this.binding.bucket_name) {
|
117898
|
+
return false;
|
117899
|
+
}
|
117900
|
+
try {
|
117901
|
+
await getR2Bucket(
|
117902
|
+
this.accountId,
|
117903
|
+
this.binding.bucket_name,
|
117904
|
+
this.binding.jurisdiction
|
117905
|
+
);
|
117906
|
+
return true;
|
117907
|
+
} catch (e7) {
|
117908
|
+
if (!(e7 instanceof APIError && e7.code === 10006)) {
|
117909
|
+
throw e7;
|
117576
117910
|
}
|
117577
|
-
|
117578
|
-
binding: r22.binding,
|
117579
|
-
name: r22.bucket_name,
|
117580
|
-
async create(bucketName) {
|
117581
|
-
await createR2Bucket(
|
117582
|
-
accountId,
|
117583
|
-
bucketName,
|
117584
|
-
void 0,
|
117585
|
-
// respect jurisdiction if it has been specified in the config, but don't prompt
|
117586
|
-
r22.jurisdiction
|
117587
|
-
);
|
117588
|
-
return bucketName;
|
117589
|
-
},
|
117590
|
-
updateId(bucketName) {
|
117591
|
-
r22.bucket_name = bucketName;
|
117592
|
-
}
|
117593
|
-
});
|
117911
|
+
return false;
|
117594
117912
|
}
|
117595
117913
|
}
|
117596
|
-
|
117597
|
-
|
117598
|
-
|
117599
|
-
|
117600
|
-
|
117601
|
-
|
117602
|
-
|
117603
|
-
|
117604
|
-
|
117605
|
-
|
117606
|
-
|
117607
|
-
|
117608
|
-
|
117609
|
-
|
117610
|
-
|
117611
|
-
|
117612
|
-
|
117914
|
+
};
|
117915
|
+
__name(R2Handler, "R2Handler");
|
117916
|
+
var KVHandler = class extends ProvisionResourceHandler {
|
117917
|
+
get name() {
|
117918
|
+
return void 0;
|
117919
|
+
}
|
117920
|
+
async create(name2) {
|
117921
|
+
return await createKVNamespace(this.accountId, name2);
|
117922
|
+
}
|
117923
|
+
constructor(binding, accountId) {
|
117924
|
+
super("kv_namespace", binding, "id", accountId);
|
117925
|
+
}
|
117926
|
+
canInherit(settings) {
|
117927
|
+
return !!settings?.bindings.find(
|
117928
|
+
(existing) => existing.type === this.type && existing.name === this.binding.binding
|
117929
|
+
);
|
117930
|
+
}
|
117931
|
+
isFullySpecified() {
|
117932
|
+
return !!this.binding.id;
|
117933
|
+
}
|
117934
|
+
};
|
117935
|
+
__name(KVHandler, "KVHandler");
|
117936
|
+
var D1Handler = class extends ProvisionResourceHandler {
|
117937
|
+
get name() {
|
117938
|
+
return this.binding.database_name;
|
117939
|
+
}
|
117940
|
+
async create(name2) {
|
117941
|
+
const db = await createD1Database(this.accountId, name2);
|
117942
|
+
return db.uuid;
|
117943
|
+
}
|
117944
|
+
constructor(binding, accountId) {
|
117945
|
+
super("d1", binding, "database_id", accountId);
|
117946
|
+
}
|
117947
|
+
async canInherit(settings) {
|
117948
|
+
const maybeInherited = settings?.bindings.find(
|
117949
|
+
(existing) => existing.type === this.type && existing.name === this.binding.binding
|
117950
|
+
);
|
117951
|
+
if (maybeInherited) {
|
117952
|
+
if (!this.binding.database_name) {
|
117953
|
+
return true;
|
117954
|
+
}
|
117955
|
+
const dbFromId = await getDatabaseInfoFromIdOrName(
|
117956
|
+
this.accountId,
|
117957
|
+
maybeInherited.id
|
117958
|
+
);
|
117959
|
+
if (this.binding.database_name === dbFromId.name) {
|
117960
|
+
return true;
|
117961
|
+
}
|
117962
|
+
}
|
117963
|
+
return false;
|
117964
|
+
}
|
117965
|
+
async isConnectedToExistingResource() {
|
117966
|
+
(0, import_node_assert10.default)(typeof this.binding.database_name !== "symbol");
|
117967
|
+
if (!this.binding.database_name) {
|
117968
|
+
return false;
|
117969
|
+
}
|
117970
|
+
try {
|
117971
|
+
const db = await getDatabaseInfoFromIdOrName(
|
117972
|
+
this.accountId,
|
117973
|
+
this.binding.database_name
|
117974
|
+
);
|
117975
|
+
return db.uuid;
|
117976
|
+
} catch (e7) {
|
117977
|
+
if (!(e7 instanceof APIError && e7.code === 7404)) {
|
117978
|
+
throw e7;
|
117979
|
+
}
|
117980
|
+
return false;
|
117981
|
+
}
|
117982
|
+
}
|
117983
|
+
isFullySpecified() {
|
117984
|
+
return !!this.binding.database_id;
|
117985
|
+
}
|
117986
|
+
};
|
117987
|
+
__name(D1Handler, "D1Handler");
|
117988
|
+
var HANDLERS = {
|
117989
|
+
kv_namespaces: {
|
117990
|
+
Handler: KVHandler,
|
117991
|
+
sort: 0,
|
117992
|
+
name: "KV Namespace",
|
117993
|
+
keyDescription: "title or id"
|
117994
|
+
},
|
117995
|
+
d1_databases: {
|
117996
|
+
Handler: D1Handler,
|
117997
|
+
sort: 1,
|
117998
|
+
name: "D1 Database",
|
117999
|
+
keyDescription: "name or id"
|
118000
|
+
},
|
118001
|
+
r2_buckets: {
|
118002
|
+
Handler: R2Handler,
|
118003
|
+
sort: 2,
|
118004
|
+
name: "R2 Bucket",
|
118005
|
+
keyDescription: "name"
|
118006
|
+
}
|
118007
|
+
};
|
118008
|
+
var LOADERS = {
|
118009
|
+
kv_namespaces: async (accountId) => {
|
118010
|
+
const preExistingKV = await listKVNamespaces(accountId, true);
|
118011
|
+
return preExistingKV.map((ns) => ({ title: ns.title, value: ns.id }));
|
118012
|
+
},
|
118013
|
+
d1_databases: async (accountId) => {
|
118014
|
+
const preExisting = await listDatabases(accountId, true, 1e3);
|
118015
|
+
return preExisting.map((db) => ({ title: db.name, value: db.uuid }));
|
118016
|
+
},
|
118017
|
+
r2_buckets: async (accountId) => {
|
118018
|
+
const preExisting = await listR2Buckets(accountId);
|
118019
|
+
return preExisting.map((bucket) => ({
|
118020
|
+
title: bucket.name,
|
118021
|
+
value: bucket.name
|
118022
|
+
}));
|
118023
|
+
}
|
118024
|
+
};
|
118025
|
+
async function collectPendingResources(accountId, scriptName, bindings) {
|
118026
|
+
let settings;
|
118027
|
+
try {
|
118028
|
+
settings = await getSettings(accountId, scriptName);
|
118029
|
+
} catch (error2) {
|
118030
|
+
logger.debug("No settings found");
|
118031
|
+
}
|
118032
|
+
const pendingResources = [];
|
118033
|
+
try {
|
118034
|
+
settings = await getSettings(accountId, scriptName);
|
118035
|
+
} catch (error2) {
|
118036
|
+
logger.debug("No settings found");
|
118037
|
+
}
|
118038
|
+
for (const resourceType of Object.keys(
|
118039
|
+
HANDLERS
|
118040
|
+
)) {
|
118041
|
+
for (const resource of bindings[resourceType] ?? []) {
|
118042
|
+
const h6 = new HANDLERS[resourceType].Handler(resource, accountId);
|
118043
|
+
if (await h6.shouldProvision(settings)) {
|
118044
|
+
pendingResources.push({
|
118045
|
+
binding: resource.binding,
|
118046
|
+
resourceType,
|
118047
|
+
handler: h6
|
118048
|
+
});
|
117613
118049
|
}
|
117614
|
-
pendingResources.d1_databases?.push({
|
117615
|
-
binding: d12.binding,
|
117616
|
-
name: d12.database_name,
|
117617
|
-
async create(name2) {
|
117618
|
-
const db = await createD1Database(accountId, name2);
|
117619
|
-
return db.uuid;
|
117620
|
-
},
|
117621
|
-
updateId(id) {
|
117622
|
-
d12.database_id = id;
|
117623
|
-
}
|
117624
|
-
});
|
117625
118050
|
}
|
117626
118051
|
}
|
117627
|
-
|
118052
|
+
return pendingResources.sort(
|
118053
|
+
(a5, b6) => HANDLERS[a5.resourceType].sort - HANDLERS[b6.resourceType].sort
|
118054
|
+
);
|
118055
|
+
}
|
118056
|
+
__name(collectPendingResources, "collectPendingResources");
|
118057
|
+
async function provisionBindings(bindings, accountId, scriptName, autoCreate, config) {
|
118058
|
+
const pendingResources = await collectPendingResources(
|
118059
|
+
accountId,
|
118060
|
+
scriptName,
|
118061
|
+
bindings
|
118062
|
+
);
|
118063
|
+
if (pendingResources.length > 0) {
|
117628
118064
|
if (!isLegacyEnv(config)) {
|
117629
118065
|
throw new UserError(
|
117630
118066
|
"Provisioning resources is not supported with a service environment"
|
117631
118067
|
);
|
117632
118068
|
}
|
117633
118069
|
logger.log();
|
117634
|
-
|
117635
|
-
|
117636
|
-
|
117637
|
-
|
117638
|
-
await runProvisioningFlow(
|
117639
|
-
pendingResources.kv_namespaces,
|
117640
|
-
preExistingKV.map((ns) => ({ title: ns.title, value: ns.id })),
|
117641
|
-
"KV Namespace",
|
117642
|
-
"title or id",
|
117643
|
-
scriptName,
|
117644
|
-
autoCreate
|
117645
|
-
);
|
117646
|
-
}
|
117647
|
-
if (pendingResources.d1_databases?.length) {
|
117648
|
-
const preExisting = await listDatabases(accountId, true);
|
117649
|
-
await runProvisioningFlow(
|
117650
|
-
pendingResources.d1_databases,
|
117651
|
-
preExisting.map((db) => ({ title: db.name, value: db.uuid })),
|
117652
|
-
"D1 Database",
|
117653
|
-
"name or id",
|
117654
|
-
scriptName,
|
117655
|
-
autoCreate
|
117656
|
-
);
|
118070
|
+
const printable = {};
|
118071
|
+
for (const resource of pendingResources) {
|
118072
|
+
printable[resource.resourceType] ??= [];
|
118073
|
+
printable[resource.resourceType].push({ binding: resource.binding });
|
117657
118074
|
}
|
117658
|
-
|
117659
|
-
|
118075
|
+
printBindings(printable, { provisioning: true });
|
118076
|
+
logger.log();
|
118077
|
+
const existingResources = {};
|
118078
|
+
for (const resource of pendingResources) {
|
118079
|
+
existingResources[resource.resourceType] ??= await LOADERS[resource.resourceType](accountId);
|
117660
118080
|
await runProvisioningFlow(
|
117661
|
-
|
117662
|
-
|
117663
|
-
|
117664
|
-
value: bucket.name
|
117665
|
-
})),
|
117666
|
-
"R2 Bucket",
|
117667
|
-
"name",
|
118081
|
+
resource,
|
118082
|
+
existingResources[resource.resourceType],
|
118083
|
+
HANDLERS[resource.resourceType].name,
|
117668
118084
|
scriptName,
|
117669
118085
|
autoCreate
|
117670
118086
|
);
|
@@ -117674,21 +118090,6 @@ async function provisionBindings(bindings, accountId, scriptName, autoCreate, co
|
|
117674
118090
|
}
|
117675
118091
|
}
|
117676
118092
|
__name(provisionBindings, "provisionBindings");
|
117677
|
-
function inBindingSettings(settings, type, bindingName, other) {
|
117678
|
-
return settings?.bindings.find(
|
117679
|
-
(binding) => {
|
117680
|
-
if (other) {
|
117681
|
-
for (const [k6, v7] of Object.entries(other)) {
|
117682
|
-
if (other[k6] !== v7) {
|
117683
|
-
return false;
|
117684
|
-
}
|
117685
|
-
}
|
117686
|
-
}
|
117687
|
-
return binding.type === type && binding.name === bindingName;
|
117688
|
-
}
|
117689
|
-
);
|
117690
|
-
}
|
117691
|
-
__name(inBindingSettings, "inBindingSettings");
|
117692
118093
|
function getSettings(accountId, scriptName) {
|
117693
118094
|
return fetchResult(
|
117694
118095
|
`/accounts/${accountId}/workers/scripts/${scriptName}/settings`
|
@@ -117697,103 +118098,75 @@ function getSettings(accountId, scriptName) {
|
|
117697
118098
|
__name(getSettings, "getSettings");
|
117698
118099
|
function printDivider() {
|
117699
118100
|
logger.log();
|
117700
|
-
logger.log(source_default.dim("--------------------------------------"));
|
117701
|
-
logger.log();
|
117702
118101
|
}
|
117703
118102
|
__name(printDivider, "printDivider");
|
117704
|
-
async function runProvisioningFlow(
|
118103
|
+
async function runProvisioningFlow(item, preExisting, friendlyBindingName, scriptName, autoCreate) {
|
117705
118104
|
const NEW_OPTION_VALUE = "__WRANGLER_INTERNAL_NEW";
|
117706
118105
|
const SEARCH_OPTION_VALUE = "__WRANGLER_INTERNAL_SEARCH";
|
117707
118106
|
const MAX_OPTIONS = 4;
|
117708
|
-
|
117709
|
-
|
117710
|
-
|
117711
|
-
|
117712
|
-
|
117713
|
-
|
117714
|
-
|
117715
|
-
|
117716
|
-
|
117717
|
-
|
117718
|
-
|
117719
|
-
|
117720
|
-
|
117721
|
-
|
117722
|
-
|
117723
|
-
|
117724
|
-
|
117725
|
-
|
117726
|
-
|
117727
|
-
|
117728
|
-
|
117729
|
-
|
117730
|
-
|
117731
|
-
|
117732
|
-
|
117733
|
-
|
117734
|
-
|
117735
|
-
|
117736
|
-
if (!proceed) {
|
117737
|
-
throw new UserError("Resource provisioning cancelled.");
|
117738
|
-
}
|
117739
|
-
logger.log(`\u{1F300} Creating new ${friendlyBindingName} "${name2}"...`);
|
117740
|
-
const id = await item.create(name2);
|
117741
|
-
item.updateId(id);
|
118107
|
+
const options30 = preExisting.slice(0, MAX_OPTIONS - 1);
|
118108
|
+
if (options30.length < preExisting.length) {
|
118109
|
+
options30.push({
|
118110
|
+
title: "Other (too many to list)",
|
118111
|
+
value: SEARCH_OPTION_VALUE
|
118112
|
+
});
|
118113
|
+
}
|
118114
|
+
const defaultName = `${scriptName}-${item.binding.toLowerCase().replace("_", "-")}`;
|
118115
|
+
logger.log("Provisioning", item.binding, `(${friendlyBindingName})...`);
|
118116
|
+
if (item.handler.name) {
|
118117
|
+
logger.log("Resource name found in config:", item.handler.name);
|
118118
|
+
logger.log(
|
118119
|
+
`\u{1F300} Creating new ${friendlyBindingName} "${item.handler.name}"...`
|
118120
|
+
);
|
118121
|
+
await item.handler.provision(item.handler.name);
|
118122
|
+
} else if (autoCreate) {
|
118123
|
+
logger.log(`\u{1F300} Creating new ${friendlyBindingName} "${defaultName}"...`);
|
118124
|
+
await item.handler.provision(defaultName);
|
118125
|
+
} else {
|
118126
|
+
let action = NEW_OPTION_VALUE;
|
118127
|
+
if (options30.length > 0) {
|
118128
|
+
action = await select(
|
118129
|
+
`Would you like to connect an existing ${friendlyBindingName} or create a new one?`,
|
118130
|
+
{
|
118131
|
+
choices: options30.concat([
|
118132
|
+
{ title: "Create new", value: NEW_OPTION_VALUE }
|
118133
|
+
]),
|
118134
|
+
defaultOption: options30.length
|
117742
118135
|
}
|
117743
|
-
|
117744
|
-
|
117745
|
-
|
117746
|
-
|
117747
|
-
|
117748
|
-
|
117749
|
-
|
117750
|
-
choices: options30.concat([
|
117751
|
-
{ title: "Create new", value: NEW_OPTION_VALUE }
|
117752
|
-
]),
|
117753
|
-
defaultOption: options30.length
|
117754
|
-
}
|
117755
|
-
);
|
118136
|
+
);
|
118137
|
+
}
|
118138
|
+
if (action === NEW_OPTION_VALUE) {
|
118139
|
+
const name2 = await prompt(
|
118140
|
+
`Enter a name for your new ${friendlyBindingName}`,
|
118141
|
+
{
|
118142
|
+
defaultValue: defaultName
|
117756
118143
|
}
|
117757
|
-
|
117758
|
-
|
117759
|
-
|
117760
|
-
|
117761
|
-
|
117762
|
-
|
117763
|
-
|
117764
|
-
item.
|
117765
|
-
|
117766
|
-
|
117767
|
-
|
117768
|
-
|
117769
|
-
|
117770
|
-
|
117771
|
-
foundResource = preExisting.find(
|
117772
|
-
(r7) => r7.title === input || r7.value === input
|
117773
|
-
);
|
117774
|
-
if (foundResource) {
|
117775
|
-
name2 = foundResource.title;
|
117776
|
-
item.updateId(foundResource.value);
|
117777
|
-
} else {
|
117778
|
-
logger.log(
|
117779
|
-
`No ${friendlyBindingName} with that ${resourceKeyDescriptor} "${input}" found. Please try again.`
|
117780
|
-
);
|
117781
|
-
}
|
117782
|
-
}
|
118144
|
+
);
|
118145
|
+
logger.log(`\u{1F300} Creating new ${friendlyBindingName} "${name2}"...`);
|
118146
|
+
await item.handler.provision(name2);
|
118147
|
+
} else if (action === SEARCH_OPTION_VALUE) {
|
118148
|
+
let foundResource;
|
118149
|
+
while (foundResource === void 0) {
|
118150
|
+
const input = await prompt(
|
118151
|
+
`Enter the ${HANDLERS[item.resourceType].keyDescription} for an existing ${friendlyBindingName}`
|
118152
|
+
);
|
118153
|
+
foundResource = preExisting.find(
|
118154
|
+
(r7) => r7.title === input || r7.value === input
|
118155
|
+
);
|
118156
|
+
if (foundResource) {
|
118157
|
+
item.handler.connect(foundResource.value);
|
117783
118158
|
} else {
|
117784
|
-
|
117785
|
-
|
118159
|
+
logger.log(
|
118160
|
+
`No ${friendlyBindingName} with that ${HANDLERS[item.resourceType].keyDescription} "${input}" found. Please try again.`
|
117786
118161
|
);
|
117787
|
-
if (selectedResource) {
|
117788
|
-
name2 = selectedResource.title;
|
117789
|
-
item.updateId(selected);
|
117790
|
-
}
|
117791
118162
|
}
|
117792
118163
|
}
|
117793
|
-
|
117794
|
-
|
118164
|
+
} else {
|
118165
|
+
item.handler.connect(action);
|
117795
118166
|
}
|
117796
118167
|
}
|
118168
|
+
logger.log(`\u2728 ${item.binding} provisioned \u{1F389}`);
|
118169
|
+
printDivider();
|
117797
118170
|
}
|
117798
118171
|
__name(runProvisioningFlow, "runProvisioningFlow");
|
117799
118172
|
|
@@ -118926,10 +119299,16 @@ function createWorkerUploadForm(worker) {
|
|
118926
119299
|
assets,
|
118927
119300
|
observability
|
118928
119301
|
} = worker;
|
119302
|
+
let runWorkerFirst = void 0;
|
119303
|
+
if (assets?.assetConfig?.run_worker_first !== void 0) {
|
119304
|
+
runWorkerFirst = assets.assetConfig?.run_worker_first;
|
119305
|
+
} else if (assets?.assetConfig?.serve_directly !== void 0) {
|
119306
|
+
runWorkerFirst = !assets?.assetConfig?.serve_directly;
|
119307
|
+
}
|
118929
119308
|
const assetConfig = {
|
118930
119309
|
html_handling: assets?.assetConfig?.html_handling,
|
118931
119310
|
not_found_handling: assets?.assetConfig?.not_found_handling,
|
118932
|
-
|
119311
|
+
run_worker_first: runWorkerFirst
|
118933
119312
|
};
|
118934
119313
|
if (assets && !assets.routingConfig.has_user_worker) {
|
118935
119314
|
formData.set(
|
@@ -119150,6 +119529,12 @@ function createWorkerUploadForm(worker) {
|
|
119150
119529
|
type: "ai"
|
119151
119530
|
});
|
119152
119531
|
}
|
119532
|
+
if (bindings.images !== void 0) {
|
119533
|
+
metadataBindings.push({
|
119534
|
+
name: bindings.images.binding,
|
119535
|
+
type: "images"
|
119536
|
+
});
|
119537
|
+
}
|
119153
119538
|
if (bindings.version_metadata !== void 0) {
|
119154
119539
|
metadataBindings.push({
|
119155
119540
|
name: bindings.version_metadata.binding,
|
@@ -119361,7 +119746,7 @@ __name(logBuildOutput, "logBuildOutput");
|
|
119361
119746
|
|
119362
119747
|
// src/deployment-bundle/node-compat.ts
|
119363
119748
|
init_import_meta_url();
|
119364
|
-
var
|
119749
|
+
var import_miniflare16 = require("miniflare");
|
119365
119750
|
function validateNodeCompatMode(compatibilityDateStr = "2000-01-01", compatibilityFlags, {
|
119366
119751
|
nodeCompat: legacy = false,
|
119367
119752
|
noBundle = void 0
|
@@ -119372,7 +119757,7 @@ function validateNodeCompatMode(compatibilityDateStr = "2000-01-01", compatibili
|
|
119372
119757
|
hasNodejsCompatFlag,
|
119373
119758
|
hasNodejsCompatV2Flag,
|
119374
119759
|
hasExperimentalNodejsCompatV2Flag
|
119375
|
-
} = (0,
|
119760
|
+
} = (0, import_miniflare16.getNodeCompat)(compatibilityDateStr, compatibilityFlags, {
|
119376
119761
|
nodeCompat: legacy
|
119377
119762
|
});
|
119378
119763
|
if (hasExperimentalNodejsCompatV2Flag) {
|
@@ -120829,6 +121214,9 @@ ${dashLink}`);
|
|
120829
121214
|
if (config.workflows?.length) {
|
120830
121215
|
logger.once.warn("Workflows is currently in open beta.");
|
120831
121216
|
for (const workflow of config.workflows) {
|
121217
|
+
if (workflow.script_name !== void 0 && workflow.script_name !== scriptName) {
|
121218
|
+
continue;
|
121219
|
+
}
|
120832
121220
|
deployments.push(
|
120833
121221
|
fetchResult(`/accounts/${accountId}/workflows/${workflow.name}`, {
|
120834
121222
|
method: "PUT",
|
@@ -121641,7 +122029,10 @@ var validateRoutes3 = /* @__PURE__ */ __name((routes, assets) => {
|
|
121641
122029
|
`Paths are not allowed in Custom Domains`
|
121642
122030
|
);
|
121643
122031
|
}
|
121644
|
-
} else if (
|
122032
|
+
} else if (
|
122033
|
+
// If we have Assets but we're not always hitting the Worker then validate
|
122034
|
+
assets?.directory !== void 0 && assets.assetConfig.run_worker_first !== true
|
122035
|
+
) {
|
121645
122036
|
const pattern = typeof route2 === "string" ? route2 : route2.pattern;
|
121646
122037
|
const components = pattern.split("/");
|
121647
122038
|
if (!(components.length === 2 && components[1] === "*")) {
|
@@ -122070,13 +122461,15 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
122070
122461
|
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
122071
122462
|
} else {
|
122072
122463
|
(0, import_node_assert16.default)(accountId, "Missing accountId");
|
122073
|
-
getFlag("RESOURCES_PROVISION")
|
122074
|
-
|
122075
|
-
|
122076
|
-
|
122077
|
-
|
122078
|
-
|
122079
|
-
|
122464
|
+
if (getFlag("RESOURCES_PROVISION")) {
|
122465
|
+
await provisionBindings(
|
122466
|
+
bindings,
|
122467
|
+
accountId,
|
122468
|
+
scriptName,
|
122469
|
+
props.experimentalAutoCreate,
|
122470
|
+
props.config
|
122471
|
+
);
|
122472
|
+
}
|
122080
122473
|
await ensureQueuesExistByConfig(config);
|
122081
122474
|
let bindingsPrinted = false;
|
122082
122475
|
try {
|
@@ -123093,11 +123486,12 @@ ${resolvedAssetsPath}`,
|
|
123093
123486
|
}
|
123094
123487
|
const routingConfig = {
|
123095
123488
|
has_user_worker: Boolean(args.script || config.main),
|
123096
|
-
invoke_user_worker_ahead_of_assets:
|
123489
|
+
invoke_user_worker_ahead_of_assets: config.assets?.run_worker_first || false
|
123097
123490
|
};
|
123098
123491
|
const assetConfig = {
|
123099
123492
|
html_handling: config.assets?.html_handling,
|
123100
123493
|
not_found_handling: config.assets?.not_found_handling,
|
123494
|
+
run_worker_first: config.assets?.run_worker_first,
|
123101
123495
|
serve_directly: config.assets?.experimental_serve_directly
|
123102
123496
|
};
|
123103
123497
|
return {
|
@@ -123132,20 +123526,24 @@ function validateAssetsArgsAndConfig(args, config) {
|
|
123132
123526
|
{ telemetryMessage: true }
|
123133
123527
|
);
|
123134
123528
|
}
|
123135
|
-
if (config?.placement?.mode === "smart" && config?.assets?.
|
123529
|
+
if (config?.placement?.mode === "smart" && config?.assets?.run_worker_first === true) {
|
123136
123530
|
logger.warn(
|
123137
|
-
"Turning on Smart Placement in a Worker that is using assets and
|
123531
|
+
"Turning on Smart Placement in a Worker that is using assets and run_worker_first set to true means that your entire Worker could be moved to run closer to your data source, and all requests will go to that Worker before serving assets.\nThis could result in poor performance as round trip times could increase when serving assets.\n\nRead more: https://developers.cloudflare.com/workers/static-assets/binding/#smart-placement"
|
123532
|
+
);
|
123533
|
+
}
|
123534
|
+
if ("legacy" in args ? args.assets?.assetConfig?.run_worker_first !== void 0 && args.assets?.assetConfig.serve_directly !== void 0 : config?.assets?.run_worker_first !== void 0 && config?.assets?.experimental_serve_directly !== void 0) {
|
123535
|
+
throw new UserError(
|
123536
|
+
"run_worker_first and experimental_serve_directly specified.\nOnly one of these configuration options may be provided."
|
123138
123537
|
);
|
123139
123538
|
}
|
123140
|
-
if ("legacy" in args ? args.assets?.assetConfig?.
|
123539
|
+
if ("legacy" in args ? args.assets?.assetConfig?.run_worker_first === true && !args.assets?.binding : config?.assets?.run_worker_first === true && !config?.assets?.binding) {
|
123141
123540
|
logger.warn(
|
123142
|
-
"
|
123541
|
+
"run_worker_first=true set without an assets binding\nSetting run_worker_first to true will always invoke your Worker script.\nTo fetch your assets from your Worker, please set the [assets.binding] key in your configuration file.\n\nRead more: https://developers.cloudflare.com/workers/static-assets/binding/#binding"
|
123143
123542
|
);
|
123144
123543
|
}
|
123145
|
-
if ("legacy" in args ? args.entrypoint === noOpEntrypoint && args.assets?.assetConfig?.
|
123544
|
+
if ("legacy" in args ? args.entrypoint === noOpEntrypoint && args.assets?.assetConfig?.run_worker_first === true : !config?.main && config?.assets?.run_worker_first === true) {
|
123146
123545
|
throw new UserError(
|
123147
|
-
"Cannot set
|
123148
|
-
{ telemetryMessage: true }
|
123546
|
+
"Cannot set run_worker_first=true without a Worker script.\nPlease remove run_worker_first from your configuration file, or provide a Worker script in your configuration file (`main`)."
|
123149
123547
|
);
|
123150
123548
|
}
|
123151
123549
|
}
|
@@ -123392,7 +123790,7 @@ init_import_meta_url();
|
|
123392
123790
|
// src/cli-hotkeys.ts
|
123393
123791
|
init_import_meta_url();
|
123394
123792
|
var import_readline = __toESM(require("readline"));
|
123395
|
-
var
|
123793
|
+
var import_miniflare17 = require("miniflare");
|
123396
123794
|
|
123397
123795
|
// src/utils/onKeyPress.ts
|
123398
123796
|
init_import_meta_url();
|
@@ -123486,16 +123884,16 @@ function cli_hotkeys_default(options30) {
|
|
123486
123884
|
__name(printInstructions, "printInstructions");
|
123487
123885
|
Logger.registerBeforeLogHook(clearPreviousInstructions);
|
123488
123886
|
Logger.registerAfterLogHook(printInstructions);
|
123489
|
-
|
123490
|
-
|
123887
|
+
import_miniflare17.Log.unstable_registerBeforeLogHook(clearPreviousInstructions);
|
123888
|
+
import_miniflare17.Log.unstable_registerAfterLogHook(printInstructions);
|
123491
123889
|
printInstructions();
|
123492
123890
|
return () => {
|
123493
123891
|
unregisterKeyPress();
|
123494
123892
|
clearPreviousInstructions();
|
123495
123893
|
Logger.registerBeforeLogHook(void 0);
|
123496
123894
|
Logger.registerAfterLogHook(void 0);
|
123497
|
-
|
123498
|
-
|
123895
|
+
import_miniflare17.Log.unstable_registerBeforeLogHook(void 0);
|
123896
|
+
import_miniflare17.Log.unstable_registerAfterLogHook(void 0);
|
123499
123897
|
};
|
123500
123898
|
}
|
123501
123899
|
__name(cli_hotkeys_default, "default");
|
@@ -123876,6 +124274,11 @@ var dev = createCommand({
|
|
123876
124274
|
type: "boolean",
|
123877
124275
|
describe: "Bind to production Vectorize indexes in local development mode",
|
123878
124276
|
default: false
|
124277
|
+
},
|
124278
|
+
"experimental-images-local-mode": {
|
124279
|
+
type: "boolean",
|
124280
|
+
describe: "Use a local lower-fidelity implementation of the Images binding",
|
124281
|
+
default: false
|
123879
124282
|
}
|
123880
124283
|
},
|
123881
124284
|
async validateArgs(args) {
|
@@ -124015,6 +124418,7 @@ async function setupDevEnv(devEnv, configPath, auth, args) {
|
|
124015
124418
|
text_blobs: void 0,
|
124016
124419
|
browser: void 0,
|
124017
124420
|
ai: args.ai,
|
124421
|
+
images: void 0,
|
124018
124422
|
version_metadata: args.version_metadata,
|
124019
124423
|
data_blobs: void 0,
|
124020
124424
|
durable_objects: { bindings: args.durableObjects ?? [] },
|
@@ -124057,6 +124461,7 @@ async function setupDevEnv(devEnv, configPath, auth, args) {
|
|
124057
124461
|
logLevel: args.logLevel,
|
124058
124462
|
registry: args.disableDevRegistry ? null : devEnv.config.latestConfig?.dev.registry,
|
124059
124463
|
bindVectorizeToProd: args.experimentalVectorizeBindToProd,
|
124464
|
+
imagesLocalMode: args.experimentalImagesLocalMode,
|
124060
124465
|
multiworkerPrimary: args.multiworkerPrimary
|
124061
124466
|
},
|
124062
124467
|
legacy: {
|
@@ -124418,6 +124823,7 @@ function getBindings2(configParam, env7, local, args) {
|
|
124418
124823
|
analytics_engine_datasets: configParam.analytics_engine_datasets,
|
124419
124824
|
browser: configParam.browser,
|
124420
124825
|
ai: args.ai || configParam.ai,
|
124826
|
+
images: configParam.images,
|
124421
124827
|
version_metadata: args.version_metadata || configParam.version_metadata,
|
124422
124828
|
unsafe: {
|
124423
124829
|
bindings: configParam.unsafe.bindings,
|
@@ -124476,6 +124882,7 @@ async function unstable_dev(script, options30, apiOptions) {
|
|
124476
124882
|
testMode,
|
124477
124883
|
testScheduled,
|
124478
124884
|
vectorizeBindToProd,
|
124885
|
+
imagesLocalMode,
|
124479
124886
|
// 2. options for alpha/beta products/libs
|
124480
124887
|
d1Databases,
|
124481
124888
|
enablePagesAssetsServiceBinding
|
@@ -124566,6 +124973,7 @@ unstable_dev()'s behaviour will likely change in future releases`
|
|
124566
124973
|
port: options30?.port ?? 0,
|
124567
124974
|
experimentalProvision: void 0,
|
124568
124975
|
experimentalVectorizeBindToProd: vectorizeBindToProd ?? false,
|
124976
|
+
experimentalImagesLocalMode: imagesLocalMode ?? false,
|
124569
124977
|
enableIpc: options30?.experimental?.enableIpc
|
124570
124978
|
};
|
124571
124979
|
const devServer = await run(
|
@@ -127127,7 +127535,8 @@ async function resolveDevConfig(config, input) {
|
|
127127
127535
|
persist: localPersistencePath,
|
127128
127536
|
registry: input.dev?.registry,
|
127129
127537
|
bindVectorizeToProd: input.dev?.bindVectorizeToProd ?? false,
|
127130
|
-
multiworkerPrimary: input.dev?.multiworkerPrimary
|
127538
|
+
multiworkerPrimary: input.dev?.multiworkerPrimary,
|
127539
|
+
imagesLocalMode: input.dev?.imagesLocalMode ?? false
|
127131
127540
|
};
|
127132
127541
|
}
|
127133
127542
|
__name(resolveDevConfig, "resolveDevConfig");
|
@@ -127162,6 +127571,7 @@ async function resolveBindings(config, input) {
|
|
127162
127571
|
{
|
127163
127572
|
registry: input.dev?.registry,
|
127164
127573
|
local: !input.dev?.remote,
|
127574
|
+
imagesLocalMode: input.dev?.imagesLocalMode,
|
127165
127575
|
name: config.name
|
127166
127576
|
}
|
127167
127577
|
);
|
@@ -127415,7 +127825,7 @@ __name(ConfigController, "ConfigController");
|
|
127415
127825
|
|
127416
127826
|
// src/api/startDevWorker/RemoteRuntimeController.ts
|
127417
127827
|
init_import_meta_url();
|
127418
|
-
var
|
127828
|
+
var import_miniflare19 = require("miniflare");
|
127419
127829
|
|
127420
127830
|
// src/dev/create-worker-preview.ts
|
127421
127831
|
init_import_meta_url();
|
@@ -127769,7 +128179,7 @@ __name(notImplemented, "notImplemented");
|
|
127769
128179
|
var RemoteRuntimeController = class extends RuntimeController {
|
127770
128180
|
#abortController = new AbortController();
|
127771
128181
|
#currentBundleId = 0;
|
127772
|
-
#mutex = new
|
128182
|
+
#mutex = new import_miniflare19.Mutex();
|
127773
128183
|
#session;
|
127774
128184
|
async #previewSession(props) {
|
127775
128185
|
try {
|
@@ -128162,7 +128572,7 @@ init_import_meta_url();
|
|
128162
128572
|
|
128163
128573
|
// src/api/integrations/platform/index.ts
|
128164
128574
|
init_import_meta_url();
|
128165
|
-
var
|
128575
|
+
var import_miniflare21 = require("miniflare");
|
128166
128576
|
|
128167
128577
|
// src/api/integrations/platform/caches.ts
|
128168
128578
|
init_import_meta_url();
|
@@ -128223,7 +128633,7 @@ __name(ExecutionContext, "ExecutionContext");
|
|
128223
128633
|
|
128224
128634
|
// src/api/integrations/platform/services.ts
|
128225
128635
|
init_import_meta_url();
|
128226
|
-
var
|
128636
|
+
var import_miniflare20 = require("miniflare");
|
128227
128637
|
var import_undici13 = __toESM(require_undici());
|
128228
128638
|
async function getServiceBindings(services = []) {
|
128229
128639
|
if (services.length === 0) {
|
@@ -128275,9 +128685,9 @@ function getServiceBindingProxyFetch({
|
|
128275
128685
|
try {
|
128276
128686
|
const resp = await (0, import_undici13.fetch)(newUrl, request4);
|
128277
128687
|
const respBody = await resp.arrayBuffer();
|
128278
|
-
return new
|
128688
|
+
return new import_miniflare20.Response(respBody, resp);
|
128279
128689
|
} catch {
|
128280
|
-
return new
|
128690
|
+
return new import_miniflare20.Response(
|
128281
128691
|
`Error: Unable to fetch from external service (${serviceName} bound with ${bindingName} binding), please make sure that the service is still running with \`wrangler dev\``,
|
128282
128692
|
{ status: 500 }
|
128283
128693
|
);
|
@@ -128308,20 +128718,16 @@ async function getPlatformProxy(options30 = {}) {
|
|
128308
128718
|
},
|
128309
128719
|
() => getMiniflareOptionsFromConfig(rawConfig, env7, options30)
|
128310
128720
|
);
|
128311
|
-
const mf = new
|
128721
|
+
const mf = new import_miniflare21.Miniflare({
|
128312
128722
|
script: "",
|
128313
128723
|
modules: true,
|
128314
128724
|
...miniflareOptions
|
128315
128725
|
});
|
128316
128726
|
const bindings = await mf.getBindings();
|
128317
|
-
const vars = getVarsForDev(rawConfig, env7);
|
128318
128727
|
const cf2 = await mf.getCf();
|
128319
128728
|
deepFreeze(cf2);
|
128320
128729
|
return {
|
128321
|
-
env:
|
128322
|
-
...vars,
|
128323
|
-
...bindings
|
128324
|
-
},
|
128730
|
+
env: bindings,
|
128325
128731
|
cf: cf2,
|
128326
128732
|
ctx: new ExecutionContext(),
|
128327
128733
|
caches: new CacheStorage(),
|
@@ -128343,7 +128749,8 @@ async function getMiniflareOptionsFromConfig(rawConfig, env7, options30) {
|
|
128343
128749
|
queueConsumers: void 0,
|
128344
128750
|
services: rawConfig.services,
|
128345
128751
|
serviceBindings: {},
|
128346
|
-
migrations: rawConfig.migrations
|
128752
|
+
migrations: rawConfig.migrations,
|
128753
|
+
imagesLocalMode: false
|
128347
128754
|
});
|
128348
128755
|
const persistOptions = getMiniflarePersistOptions(options30.persist);
|
128349
128756
|
const serviceBindings = await getServiceBindings(bindings.services);
|
@@ -128410,12 +128817,13 @@ function unstable_getMiniflareWorkerOptions(configOrConfigPath, env7) {
|
|
128410
128817
|
queueConsumers: config.queues.consumers,
|
128411
128818
|
services: [],
|
128412
128819
|
serviceBindings: {},
|
128413
|
-
migrations: config.migrations
|
128820
|
+
migrations: config.migrations,
|
128821
|
+
imagesLocalMode: false
|
128414
128822
|
});
|
128415
128823
|
if (bindings.services !== void 0) {
|
128416
128824
|
bindingOptions.serviceBindings = Object.fromEntries(
|
128417
128825
|
bindings.services.map((binding) => {
|
128418
|
-
const name2 = binding.service === config.name ?
|
128826
|
+
const name2 = binding.service === config.name ? import_miniflare21.kCurrentWorker : binding.service;
|
128419
128827
|
return [binding.binding, { name: name2, entrypoint: binding.entrypoint }];
|
128420
128828
|
})
|
128421
128829
|
);
|
@@ -140068,7 +140476,7 @@ var import_fs13 = require("fs");
|
|
140068
140476
|
var import_node_assert25 = __toESM(require("node:assert"));
|
140069
140477
|
var import_node_path54 = __toESM(require("node:path"));
|
140070
140478
|
var import_md5_file = __toESM(require_md5_file());
|
140071
|
-
var
|
140479
|
+
var import_miniflare23 = require("miniflare");
|
140072
140480
|
var import_undici16 = __toESM(require_undici());
|
140073
140481
|
|
140074
140482
|
// src/d1/splitter.ts
|
@@ -140404,7 +140812,7 @@ async function executeLocally({
|
|
140404
140812
|
logger.log(
|
140405
140813
|
"\u{1F300} To execute on your remote database, add a --remote flag to your wrangler command."
|
140406
140814
|
);
|
140407
|
-
const mf = new
|
140815
|
+
const mf = new import_miniflare23.Miniflare({
|
140408
140816
|
modules: true,
|
140409
140817
|
script: "",
|
140410
140818
|
d1Persist,
|
@@ -140667,7 +141075,7 @@ __name(checkForSQLiteBinary, "checkForSQLiteBinary");
|
|
140667
141075
|
init_import_meta_url();
|
140668
141076
|
var import_promises24 = __toESM(require("node:fs/promises"));
|
140669
141077
|
var import_node_path55 = __toESM(require("node:path"));
|
140670
|
-
var
|
141078
|
+
var import_miniflare24 = require("miniflare");
|
140671
141079
|
var import_undici17 = __toESM(require_undici());
|
140672
141080
|
function Options7(yargs) {
|
140673
141081
|
return Name(yargs).option("local", {
|
@@ -140736,7 +141144,7 @@ async function exportLocal(config, name2, output, tables, noSchema, noData) {
|
|
140736
141144
|
logger.log(
|
140737
141145
|
"\u{1F300} To export your remote database, add a --remote flag to your wrangler command."
|
140738
141146
|
);
|
140739
|
-
const mf = new
|
141147
|
+
const mf = new import_miniflare24.Miniflare({
|
140740
141148
|
modules: true,
|
140741
141149
|
script: "export default {}",
|
140742
141150
|
d1Persist,
|
@@ -140860,7 +141268,7 @@ var Handler8 = withConfig(
|
|
140860
141268
|
accountId,
|
140861
141269
|
name2
|
140862
141270
|
);
|
140863
|
-
const result = await
|
141271
|
+
const result = await getDatabaseInfoFromIdOrName(accountId, db.uuid);
|
140864
141272
|
const output = { ...result };
|
140865
141273
|
if (output["file_size"]) {
|
140866
141274
|
output["database_size"] = output["file_size"];
|
@@ -141050,7 +141458,7 @@ var Handler9 = withConfig(
|
|
141050
141458
|
accountId,
|
141051
141459
|
name2
|
141052
141460
|
);
|
141053
|
-
const result = await
|
141461
|
+
const result = await getDatabaseInfoFromIdOrName(accountId, db.uuid);
|
141054
141462
|
const output = [];
|
141055
141463
|
if (result.version !== "alpha") {
|
141056
141464
|
const [startDate, endDate] = getDurationDates(timePeriod);
|
@@ -141382,7 +141790,10 @@ Your database may not be available to serve requests during the migration, conti
|
|
141382
141790
|
"In non-local mode `databaseInfo` should be defined."
|
141383
141791
|
);
|
141384
141792
|
const accountId = await requireAuth(config);
|
141385
|
-
const dbInfo = await
|
141793
|
+
const dbInfo = await getDatabaseInfoFromIdOrName(
|
141794
|
+
accountId,
|
141795
|
+
databaseInfo?.uuid
|
141796
|
+
);
|
141386
141797
|
if (dbInfo.version === "alpha") {
|
141387
141798
|
logger.log("\u{1F552} Creating backup...");
|
141388
141799
|
await createBackup(accountId, databaseInfo.uuid);
|
@@ -141601,7 +142012,7 @@ var getBookmarkIdFromTimestamp = /* @__PURE__ */ __name(async (accountId, databa
|
|
141601
142012
|
return bookmarkResult;
|
141602
142013
|
}, "getBookmarkIdFromTimestamp");
|
141603
142014
|
var throwIfDatabaseIsAlpha = /* @__PURE__ */ __name(async (accountId, databaseId) => {
|
141604
|
-
const dbInfo = await
|
142015
|
+
const dbInfo = await getDatabaseInfoFromIdOrName(accountId, databaseId);
|
141605
142016
|
if (dbInfo.version === "alpha") {
|
141606
142017
|
throw new UserError(
|
141607
142018
|
"Time travel is not available for alpha D1 databases. You will need to migrate to a new database for access to this feature."
|
@@ -143590,7 +144001,7 @@ async function mapBindings(accountId, bindings) {
|
|
143590
144001
|
const d1BindingsWithInfo = {};
|
143591
144002
|
await Promise.all(
|
143592
144003
|
bindings.filter((binding) => binding.type === "d1").map(async (binding) => {
|
143593
|
-
const dbInfo = await
|
144004
|
+
const dbInfo = await getDatabaseInfoFromIdOrName(accountId, binding.id);
|
143594
144005
|
d1BindingsWithInfo[binding.id] = dbInfo;
|
143595
144006
|
})
|
143596
144007
|
);
|
@@ -143662,6 +144073,13 @@ async function mapBindings(accountId, bindings) {
|
|
143662
144073
|
};
|
143663
144074
|
}
|
143664
144075
|
break;
|
144076
|
+
case "images":
|
144077
|
+
{
|
144078
|
+
configObj.images = {
|
144079
|
+
binding: binding.name
|
144080
|
+
};
|
144081
|
+
}
|
144082
|
+
break;
|
143665
144083
|
case "r2_bucket":
|
143666
144084
|
{
|
143667
144085
|
configObj.r2_buckets = [
|
@@ -147290,6 +147708,11 @@ function Options14(yargs) {
|
|
147290
147708
|
type: "boolean",
|
147291
147709
|
describe: "Bind to production Vectorize indexes in local development mode",
|
147292
147710
|
default: false
|
147711
|
+
},
|
147712
|
+
"experimental-images-local-mode": {
|
147713
|
+
type: "boolean",
|
147714
|
+
describe: "Use a local lower-fidelity implementation of the Images binding",
|
147715
|
+
default: false
|
147293
147716
|
}
|
147294
147717
|
});
|
147295
147718
|
}
|
@@ -147730,6 +148153,7 @@ ${JSON.stringify(defaultRoutesJSONSpec, null, 2)}`
|
|
147730
148153
|
logLevel: args.logLevel ?? "log",
|
147731
148154
|
experimentalProvision: void 0,
|
147732
148155
|
experimentalVectorizeBindToProd: false,
|
148156
|
+
experimentalImagesLocalMode: false,
|
147733
148157
|
enableIpc: true,
|
147734
148158
|
config: Array.isArray(args.config) ? args.config : void 0,
|
147735
148159
|
legacyAssets: void 0,
|
@@ -148015,12 +148439,12 @@ init_import_meta_url();
|
|
148015
148439
|
var import_fs14 = require("fs");
|
148016
148440
|
var import_promises28 = require("node:fs/promises");
|
148017
148441
|
var import_toml8 = __toESM(require_toml());
|
148018
|
-
var
|
148442
|
+
var import_miniflare25 = require("miniflare");
|
148019
148443
|
async function toEnvironment(deploymentConfig, accountId) {
|
148020
148444
|
const configObj = {};
|
148021
148445
|
configObj.compatibility_date = deploymentConfig.compatibility_date ?? (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
|
148022
148446
|
if (deploymentConfig.always_use_latest_compatibility_date) {
|
148023
|
-
configObj.compatibility_date =
|
148447
|
+
configObj.compatibility_date = import_miniflare25.supportedCompatibilityDate;
|
148024
148448
|
}
|
148025
148449
|
if (deploymentConfig.compatibility_flags?.length) {
|
148026
148450
|
configObj.compatibility_flags = deploymentConfig.compatibility_flags;
|
@@ -148378,6 +148802,7 @@ async function createDraftWorker({
|
|
148378
148802
|
wasm_modules: {},
|
148379
148803
|
browser: void 0,
|
148380
148804
|
ai: void 0,
|
148805
|
+
images: void 0,
|
148381
148806
|
version_metadata: void 0,
|
148382
148807
|
text_blobs: {},
|
148383
148808
|
data_blobs: {},
|
@@ -149401,12 +149826,12 @@ init_import_meta_url();
|
|
149401
149826
|
init_import_meta_url();
|
149402
149827
|
|
149403
149828
|
// ../../node_modules/.pnpm/@smithy+util-buffer-from@2.2.0/node_modules/@smithy/util-buffer-from/dist-es/index.js
|
149404
|
-
var
|
149829
|
+
var import_buffer3 = require("buffer");
|
149405
149830
|
var fromString2 = /* @__PURE__ */ __name((input, encoding) => {
|
149406
149831
|
if (typeof input !== "string") {
|
149407
149832
|
throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
|
149408
149833
|
}
|
149409
|
-
return encoding ?
|
149834
|
+
return encoding ? import_buffer3.Buffer.from(input, encoding) : import_buffer3.Buffer.from(input);
|
149410
149835
|
}, "fromString");
|
149411
149836
|
|
149412
149837
|
// ../../node_modules/.pnpm/@smithy+util-utf8@2.3.0/node_modules/@smithy/util-utf8/dist-es/fromUtf8.js
|
@@ -165795,13 +166220,13 @@ __name(triggersDeployHandler, "triggersDeployHandler");
|
|
165795
166220
|
init_import_meta_url();
|
165796
166221
|
var fs28 = __toESM(require("node:fs"));
|
165797
166222
|
var import_node_path66 = require("node:path");
|
165798
|
-
var
|
166223
|
+
var import_miniflare27 = require("miniflare");
|
165799
166224
|
|
165800
166225
|
// src/type-generation/runtime/index.ts
|
165801
166226
|
init_import_meta_url();
|
165802
166227
|
var import_fs23 = require("fs");
|
165803
166228
|
var import_promises32 = require("fs/promises");
|
165804
|
-
var
|
166229
|
+
var import_miniflare26 = require("miniflare");
|
165805
166230
|
var import_workerd = require("workerd");
|
165806
166231
|
var DEFAULT_OUTFILE_RELATIVE_PATH = "./.wrangler/types/runtime.d.ts";
|
165807
166232
|
async function generateRuntimeTypes({
|
@@ -165843,7 +166268,7 @@ async function generate({
|
|
165843
166268
|
compatibilityFlags = []
|
165844
166269
|
}) {
|
165845
166270
|
const worker = (0, import_fs23.readFileSync)(require.resolve("workerd/worker.mjs")).toString();
|
165846
|
-
const mf = new
|
166271
|
+
const mf = new import_miniflare26.Miniflare({
|
165847
166272
|
compatibilityDate: "2024-01-01",
|
165848
166273
|
compatibilityFlags: ["nodejs_compat", "rtti_api"],
|
165849
166274
|
modules: true,
|
@@ -165985,7 +166410,7 @@ var typesCommand = createCommand({
|
|
165985
166410
|
});
|
165986
166411
|
const tsconfigPath = config.tsconfig ?? (0, import_node_path66.join)((0, import_node_path66.dirname)(config.configPath), "tsconfig.json");
|
165987
166412
|
const tsconfigTypes = readTsconfigTypes(tsconfigPath);
|
165988
|
-
const { mode } = (0,
|
166413
|
+
const { mode } = (0, import_miniflare27.getNodeCompat)(
|
165989
166414
|
config.compatibility_date,
|
165990
166415
|
config.compatibility_flags,
|
165991
166416
|
{
|
@@ -168860,10 +169285,21 @@ var versionsUploadCommand = createCommand({
|
|
168860
169285
|
describe: "A descriptive message for this Worker Gradual Rollouts Version",
|
168861
169286
|
type: "string",
|
168862
169287
|
requiresArg: true
|
169288
|
+
},
|
169289
|
+
"experimental-auto-create": {
|
169290
|
+
describe: "Automatically provision draft bindings with new resources",
|
169291
|
+
type: "boolean",
|
169292
|
+
default: true,
|
169293
|
+
hidden: true,
|
169294
|
+
alias: "x-auto-create"
|
168863
169295
|
}
|
168864
169296
|
},
|
168865
169297
|
behaviour: {
|
168866
|
-
useConfigRedirectIfAvailable: true
|
169298
|
+
useConfigRedirectIfAvailable: true,
|
169299
|
+
overrideExperimentalFlags: (args) => ({
|
169300
|
+
MULTIWORKER: false,
|
169301
|
+
RESOURCES_PROVISION: args.experimentalProvision ?? false
|
169302
|
+
})
|
168867
169303
|
},
|
168868
169304
|
handler: /* @__PURE__ */ __name(async function versionsUploadHandler(args, { config }) {
|
168869
169305
|
const entry = await getEntry(args, config, "versions upload");
|
@@ -168951,7 +169387,8 @@ var versionsUploadCommand = createCommand({
|
|
168951
169387
|
keepVars: false,
|
168952
169388
|
projectRoot: entry.projectRoot,
|
168953
169389
|
tag: args.tag,
|
168954
|
-
message: args.message
|
169390
|
+
message: args.message,
|
169391
|
+
experimentalAutoCreate: args.experimentalAutoCreate
|
168955
169392
|
});
|
168956
169393
|
writeOutput({
|
168957
169394
|
type: "version-upload",
|
@@ -169215,6 +169652,16 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
169215
169652
|
if (props.dryRun) {
|
169216
169653
|
printBindings({ ...bindings, vars: maskedVars });
|
169217
169654
|
} else {
|
169655
|
+
(0, import_node_assert30.default)(accountId, "Missing accountId");
|
169656
|
+
if (getFlag("RESOURCES_PROVISION")) {
|
169657
|
+
await provisionBindings(
|
169658
|
+
bindings,
|
169659
|
+
accountId,
|
169660
|
+
scriptName,
|
169661
|
+
props.experimentalAutoCreate,
|
169662
|
+
props.config
|
169663
|
+
);
|
169664
|
+
}
|
169218
169665
|
await ensureQueuesExistByConfig(config);
|
169219
169666
|
let bindingsPrinted = false;
|
169220
169667
|
try {
|