wrangler 3.106.0 → 3.107.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config-schema.json +47 -1
- package/package.json +7 -6
- package/wrangler-dist/cli.d.ts +34 -12
- package/wrangler-dist/cli.js +848 -406
- package/wrangler-dist/cli.js.map +7 -0
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.0";
|
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,23 @@ 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
|
+
validateAssetsConfig(diagnostics, "assets", rawEnv.assets, topLevelEnv);
|
102075
|
+
return rawEnv.assets;
|
102076
|
+
}
|
102077
|
+
return void 0;
|
102078
|
+
}
|
102079
|
+
__name(normalizeAndValidateAssets, "normalizeAndValidateAssets");
|
102050
102080
|
function normalizeAndValidateSite(diagnostics, configPath, rawConfig, mainEntryPoint) {
|
102051
102081
|
if (rawConfig?.site !== void 0) {
|
102052
102082
|
const { bucket, include = [], exclude: exclude2 = [], ...rest } = rawConfig.site;
|
@@ -102566,14 +102596,7 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
|
|
102566
102596
|
isObjectWith("crons"),
|
102567
102597
|
{ crons: [] }
|
102568
102598
|
),
|
102569
|
-
assets:
|
102570
|
-
diagnostics,
|
102571
|
-
topLevelEnv,
|
102572
|
-
rawEnv,
|
102573
|
-
"assets",
|
102574
|
-
validateAssetsConfig,
|
102575
|
-
void 0
|
102576
|
-
),
|
102599
|
+
assets: normalizeAndValidateAssets(diagnostics, topLevelEnv, rawEnv),
|
102577
102600
|
usage_model: inheritable(
|
102578
102601
|
diagnostics,
|
102579
102602
|
topLevelEnv,
|
@@ -102795,7 +102818,7 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
|
|
102795
102818
|
rawEnv,
|
102796
102819
|
envName,
|
102797
102820
|
"browser",
|
102798
|
-
|
102821
|
+
validateNamedSimpleBinding(envName),
|
102799
102822
|
void 0
|
102800
102823
|
),
|
102801
102824
|
ai: notInheritable(
|
@@ -102808,6 +102831,16 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
|
|
102808
102831
|
validateAIBinding(envName),
|
102809
102832
|
void 0
|
102810
102833
|
),
|
102834
|
+
images: notInheritable(
|
102835
|
+
diagnostics,
|
102836
|
+
topLevelEnv,
|
102837
|
+
rawConfig,
|
102838
|
+
rawEnv,
|
102839
|
+
envName,
|
102840
|
+
"images",
|
102841
|
+
validateNamedSimpleBinding(envName),
|
102842
|
+
void 0
|
102843
|
+
),
|
102811
102844
|
pipelines: notInheritable(
|
102812
102845
|
diagnostics,
|
102813
102846
|
topLevelEnv,
|
@@ -103339,6 +103372,13 @@ var validateAssetsConfig = /* @__PURE__ */ __name((diagnostics, field, value) =>
|
|
103339
103372
|
"string",
|
103340
103373
|
["single-page-application", "404-page", "none"]
|
103341
103374
|
) && isValid2;
|
103375
|
+
isValid2 = validateOptionalProperty(
|
103376
|
+
diagnostics,
|
103377
|
+
field,
|
103378
|
+
"run_worker_first",
|
103379
|
+
value.run_worker_first,
|
103380
|
+
"boolean"
|
103381
|
+
) && isValid2;
|
103342
103382
|
isValid2 = validateOptionalProperty(
|
103343
103383
|
diagnostics,
|
103344
103384
|
field,
|
@@ -103351,11 +103391,12 @@ var validateAssetsConfig = /* @__PURE__ */ __name((diagnostics, field, value) =>
|
|
103351
103391
|
"binding",
|
103352
103392
|
"html_handling",
|
103353
103393
|
"not_found_handling",
|
103394
|
+
"run_worker_first",
|
103354
103395
|
"experimental_serve_directly"
|
103355
103396
|
]) && isValid2;
|
103356
103397
|
return isValid2;
|
103357
103398
|
}, "validateAssetsConfig");
|
103358
|
-
var
|
103399
|
+
var validateNamedSimpleBinding = /* @__PURE__ */ __name((envName) => (diagnostics, field, value, config) => {
|
103359
103400
|
const fieldPath = config === void 0 ? `${field}` : `env.${envName}.${field}`;
|
103360
103401
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
103361
103402
|
diagnostics.errors.push(
|
@@ -103374,7 +103415,7 @@ var validateBrowserBinding = /* @__PURE__ */ __name((envName) => (diagnostics, f
|
|
103374
103415
|
"binding"
|
103375
103416
|
]);
|
103376
103417
|
return isValid2;
|
103377
|
-
}, "
|
103418
|
+
}, "validateNamedSimpleBinding");
|
103378
103419
|
var validateAIBinding = /* @__PURE__ */ __name((envName) => (diagnostics, field, value, config) => {
|
103379
103420
|
const fieldPath = config === void 0 ? `${field}` : `env.${envName}.${field}`;
|
103380
103421
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
@@ -104520,6 +104561,7 @@ var defaultWranglerConfig = {
|
|
104520
104561
|
services: [],
|
104521
104562
|
analytics_engine_datasets: [],
|
104522
104563
|
ai: void 0,
|
104564
|
+
images: void 0,
|
104523
104565
|
version_metadata: void 0,
|
104524
104566
|
/*====================================================*/
|
104525
104567
|
/* Fields supported by Workers only */
|
@@ -108589,7 +108631,9 @@ async function matchFiles(files, relativeTo, { rules, removedRules }) {
|
|
108589
108631
|
continue;
|
108590
108632
|
}
|
108591
108633
|
const absoluteFilePath = import_node_path12.default.join(relativeTo, filePath);
|
108592
|
-
const fileContent = await (0, import_promises3.readFile)(
|
108634
|
+
const fileContent = await (0, import_promises3.readFile)(
|
108635
|
+
absoluteFilePath
|
108636
|
+
);
|
108593
108637
|
const module3 = {
|
108594
108638
|
name: filePath,
|
108595
108639
|
content: fileContent,
|
@@ -108755,7 +108799,9 @@ function createModuleCollector(props) {
|
|
108755
108799
|
props.wrangler1xLegacyModuleReferences.rootDirectory,
|
108756
108800
|
args.path
|
108757
108801
|
);
|
108758
|
-
const fileContent = await (0, import_promises4.readFile)(
|
108802
|
+
const fileContent = await (0, import_promises4.readFile)(
|
108803
|
+
filePath
|
108804
|
+
);
|
108759
108805
|
const fileHash = import_node_crypto3.default.createHash("sha1").update(fileContent).digest("hex");
|
108760
108806
|
const fileName = props.preserveFileNames ? args.path : `./${fileHash}-${import_node_path13.default.basename(args.path)}`;
|
108761
108807
|
const { rule } = rulesMatchers.find(({ regex: regex2 }) => regex2.test(fileName)) || {};
|
@@ -108818,7 +108864,9 @@ function createModuleCollector(props) {
|
|
108818
108864
|
filePath = resolved;
|
108819
108865
|
} catch (e7) {
|
108820
108866
|
}
|
108821
|
-
const fileContent = await (0, import_promises4.readFile)(
|
108867
|
+
const fileContent = await (0, import_promises4.readFile)(
|
108868
|
+
filePath
|
108869
|
+
);
|
108822
108870
|
const fileHash = import_node_crypto3.default.createHash("sha1").update(fileContent).digest("hex");
|
108823
108871
|
const fileName = props.preserveFileNames ? args.path : `./${fileHash}-${import_node_path13.default.basename(args.path)}`;
|
108824
108872
|
modules.push({
|
@@ -108915,12 +108963,218 @@ function withSourceURLs(entrypointPath, entrypointSource, modules) {
|
|
108915
108963
|
}
|
108916
108964
|
__name(withSourceURLs, "withSourceURLs");
|
108917
108965
|
|
108966
|
+
// src/images/fetcher.ts
|
108967
|
+
init_import_meta_url();
|
108968
|
+
var import_miniflare3 = require("miniflare");
|
108969
|
+
|
108970
|
+
// src/images/local.ts
|
108971
|
+
init_import_meta_url();
|
108972
|
+
var import_buffer = require("buffer");
|
108973
|
+
var import_sharp = __toESM(require("sharp"));
|
108974
|
+
function validateTransforms(inputTransforms) {
|
108975
|
+
if (!Array.isArray(inputTransforms)) {
|
108976
|
+
return null;
|
108977
|
+
}
|
108978
|
+
for (const transform of inputTransforms) {
|
108979
|
+
for (const key of ["imageIndex", "rotate", "width", "height"]) {
|
108980
|
+
if (transform[key] !== void 0 && typeof transform[key] != "number") {
|
108981
|
+
return null;
|
108982
|
+
}
|
108983
|
+
}
|
108984
|
+
}
|
108985
|
+
return inputTransforms;
|
108986
|
+
}
|
108987
|
+
__name(validateTransforms, "validateTransforms");
|
108988
|
+
async function imagesLocalFetcher(request4) {
|
108989
|
+
const data = await request4.formData();
|
108990
|
+
const body = data.get("image");
|
108991
|
+
if (!body || !(body instanceof import_buffer.File)) {
|
108992
|
+
return errorResponse(
|
108993
|
+
400,
|
108994
|
+
9523,
|
108995
|
+
`ERROR: Internal Images binding error: expected image in request, got ${body}`
|
108996
|
+
);
|
108997
|
+
}
|
108998
|
+
const transformer = (0, import_sharp.default)(await body.arrayBuffer(), {});
|
108999
|
+
const url4 = new URL(request4.url);
|
109000
|
+
if (url4.pathname == "/info") {
|
109001
|
+
return runInfo(transformer);
|
109002
|
+
} else {
|
109003
|
+
const badTransformsResponse = errorResponse(
|
109004
|
+
400,
|
109005
|
+
9523,
|
109006
|
+
"ERROR: Internal Images binding error: Expected JSON array of valid transforms in transforms field"
|
109007
|
+
);
|
109008
|
+
try {
|
109009
|
+
const transformsJson = data.get("transforms");
|
109010
|
+
if (typeof transformsJson !== "string") {
|
109011
|
+
return badTransformsResponse;
|
109012
|
+
}
|
109013
|
+
const transforms = validateTransforms(JSON.parse(transformsJson));
|
109014
|
+
if (transforms === null) {
|
109015
|
+
return badTransformsResponse;
|
109016
|
+
}
|
109017
|
+
const outputFormat = data.get("output_format");
|
109018
|
+
if (outputFormat != null && typeof outputFormat !== "string") {
|
109019
|
+
return errorResponse(
|
109020
|
+
400,
|
109021
|
+
9523,
|
109022
|
+
"ERROR: Internal Images binding error: Expected output format to be a string if provided"
|
109023
|
+
);
|
109024
|
+
}
|
109025
|
+
return runTransform(transformer, transforms, outputFormat);
|
109026
|
+
} catch (e7) {
|
109027
|
+
return badTransformsResponse;
|
109028
|
+
}
|
109029
|
+
}
|
109030
|
+
}
|
109031
|
+
__name(imagesLocalFetcher, "imagesLocalFetcher");
|
109032
|
+
async function runInfo(transformer) {
|
109033
|
+
const metadata = await transformer.metadata();
|
109034
|
+
let mime = null;
|
109035
|
+
switch (metadata.format) {
|
109036
|
+
case "jpeg":
|
109037
|
+
mime = "image/jpeg";
|
109038
|
+
break;
|
109039
|
+
case "svg":
|
109040
|
+
mime = "image/svg+xml";
|
109041
|
+
break;
|
109042
|
+
case "png":
|
109043
|
+
mime = "image/png";
|
109044
|
+
break;
|
109045
|
+
case "webp":
|
109046
|
+
mime = "image/webp";
|
109047
|
+
break;
|
109048
|
+
case "gif":
|
109049
|
+
mime = "image/gif";
|
109050
|
+
break;
|
109051
|
+
case "avif":
|
109052
|
+
mime = "image/avif";
|
109053
|
+
break;
|
109054
|
+
default:
|
109055
|
+
return errorResponse(
|
109056
|
+
415,
|
109057
|
+
9520,
|
109058
|
+
`ERROR: Unsupported image type ${metadata.format}, expected one of: JPEG, SVG, PNG, WebP, GIF or AVIF`
|
109059
|
+
);
|
109060
|
+
}
|
109061
|
+
let resp;
|
109062
|
+
if (mime == "image/svg+xml") {
|
109063
|
+
resp = {
|
109064
|
+
format: mime
|
109065
|
+
};
|
109066
|
+
} else {
|
109067
|
+
if (!metadata.size || !metadata.width || !metadata.height) {
|
109068
|
+
return errorResponse(
|
109069
|
+
500,
|
109070
|
+
9523,
|
109071
|
+
"ERROR: Internal Images binding error: Expected size, width and height for bitmap input"
|
109072
|
+
);
|
109073
|
+
}
|
109074
|
+
resp = {
|
109075
|
+
format: mime,
|
109076
|
+
fileSize: metadata.size,
|
109077
|
+
width: metadata.width,
|
109078
|
+
height: metadata.height
|
109079
|
+
};
|
109080
|
+
}
|
109081
|
+
return Response.json(resp);
|
109082
|
+
}
|
109083
|
+
__name(runInfo, "runInfo");
|
109084
|
+
async function runTransform(transformer, transforms, outputFormat) {
|
109085
|
+
for (const transform of transforms) {
|
109086
|
+
if (transform.imageIndex !== void 0 && transform.imageIndex !== 0) {
|
109087
|
+
continue;
|
109088
|
+
}
|
109089
|
+
if (transform.rotate !== void 0) {
|
109090
|
+
transformer.rotate(transform.rotate);
|
109091
|
+
}
|
109092
|
+
if (transform.width !== void 0 || transform.height !== void 0) {
|
109093
|
+
transformer.resize(transform.width || null, transform.height || null, {
|
109094
|
+
fit: "contain"
|
109095
|
+
});
|
109096
|
+
}
|
109097
|
+
}
|
109098
|
+
switch (outputFormat) {
|
109099
|
+
case "image/avif":
|
109100
|
+
transformer.avif();
|
109101
|
+
break;
|
109102
|
+
case "image/gif":
|
109103
|
+
return errorResponse(
|
109104
|
+
415,
|
109105
|
+
9520,
|
109106
|
+
"ERROR: GIF output is not supported in local mode"
|
109107
|
+
);
|
109108
|
+
case "image/jpeg":
|
109109
|
+
transformer.jpeg();
|
109110
|
+
break;
|
109111
|
+
case "image/png":
|
109112
|
+
transformer.png();
|
109113
|
+
break;
|
109114
|
+
case "image/webp":
|
109115
|
+
transformer.webp();
|
109116
|
+
break;
|
109117
|
+
case "rgb":
|
109118
|
+
case "rgba":
|
109119
|
+
return errorResponse(
|
109120
|
+
415,
|
109121
|
+
9520,
|
109122
|
+
"ERROR: RGB/RGBA output is not supported in local mode"
|
109123
|
+
);
|
109124
|
+
default:
|
109125
|
+
outputFormat = "image/jpeg";
|
109126
|
+
break;
|
109127
|
+
}
|
109128
|
+
return new Response(transformer, {
|
109129
|
+
headers: {
|
109130
|
+
"content-type": outputFormat
|
109131
|
+
}
|
109132
|
+
});
|
109133
|
+
}
|
109134
|
+
__name(runTransform, "runTransform");
|
109135
|
+
function errorResponse(status2, code, message) {
|
109136
|
+
return new Response(`ERROR ${code}: ${message}`, {
|
109137
|
+
status: status2,
|
109138
|
+
headers: {
|
109139
|
+
"content-type": "text/plain",
|
109140
|
+
"cf-images-binding": `err=${code}`
|
109141
|
+
}
|
109142
|
+
});
|
109143
|
+
}
|
109144
|
+
__name(errorResponse, "errorResponse");
|
109145
|
+
|
109146
|
+
// src/images/fetcher.ts
|
109147
|
+
var EXTERNAL_IMAGES_WORKER_NAME = "__WRANGLER_EXTERNAL_IMAGES_WORKER";
|
109148
|
+
var EXTERNAL_IMAGES_WORKER_SCRIPT = `
|
109149
|
+
import makeBinding from 'cloudflare-internal:images-api'
|
109150
|
+
|
109151
|
+
export default function (env) {
|
109152
|
+
return makeBinding({
|
109153
|
+
fetcher: env.FETCHER,
|
109154
|
+
});
|
109155
|
+
}
|
109156
|
+
`;
|
109157
|
+
async function imagesRemoteFetcher(request4) {
|
109158
|
+
const accountId = await getAccountId();
|
109159
|
+
const url4 = `/accounts/${accountId}/images_edge/v2/binding/preview${new URL(request4.url).pathname}`;
|
109160
|
+
const res = await performApiFetch(url4, {
|
109161
|
+
method: request4.method,
|
109162
|
+
body: request4.body,
|
109163
|
+
duplex: "half",
|
109164
|
+
headers: {
|
109165
|
+
"content-type": request4.headers.get("content-type") || ""
|
109166
|
+
}
|
109167
|
+
});
|
109168
|
+
return new import_miniflare3.Response(res.body, { headers: res.headers });
|
109169
|
+
}
|
109170
|
+
__name(imagesRemoteFetcher, "imagesRemoteFetcher");
|
109171
|
+
|
108918
109172
|
// src/sourcemap.ts
|
108919
109173
|
init_import_meta_url();
|
108920
109174
|
var import_node_assert4 = __toESM(require("node:assert"));
|
108921
109175
|
var import_node_fs8 = __toESM(require("node:fs"));
|
108922
109176
|
var import_node_url5 = __toESM(require("node:url"));
|
108923
|
-
var
|
109177
|
+
var import_miniflare4 = require("miniflare");
|
108924
109178
|
function maybeGetFile(filePath) {
|
108925
109179
|
try {
|
108926
109180
|
return import_node_fs8.default.readFileSync(filePath, "utf8");
|
@@ -108968,7 +109222,7 @@ function getSourceMappingPrepareStackTrace(retrieveSourceMap) {
|
|
108968
109222
|
if (sourceMappingPrepareStackTrace !== void 0) {
|
108969
109223
|
return sourceMappingPrepareStackTrace;
|
108970
109224
|
}
|
108971
|
-
const support = (0,
|
109225
|
+
const support = (0, import_miniflare4.getFreshSourceMapSupport)();
|
108972
109226
|
const originalPrepareStackTrace = Error.prepareStackTrace;
|
108973
109227
|
support.install({
|
108974
109228
|
environment: "node",
|
@@ -109175,7 +109429,7 @@ __name(updateCheck, "updateCheck");
|
|
109175
109429
|
|
109176
109430
|
// src/vectorize/fetcher.ts
|
109177
109431
|
init_import_meta_url();
|
109178
|
-
var
|
109432
|
+
var import_miniflare5 = require("miniflare");
|
109179
109433
|
var EXTERNAL_VECTORIZE_WORKER_NAME = "__WRANGLER_EXTERNAL_VECTORIZE_WORKER";
|
109180
109434
|
var EXTERNAL_VECTORIZE_WORKER_SCRIPT = `
|
109181
109435
|
import makeBinding from 'cloudflare-internal:vectorize-api'
|
@@ -109208,7 +109462,7 @@ function MakeVectorizeFetcher(indexId) {
|
|
109208
109462
|
body: request4.body,
|
109209
109463
|
duplex: "half"
|
109210
109464
|
});
|
109211
|
-
const respHeaders = new
|
109465
|
+
const respHeaders = new import_miniflare5.Headers(res.headers);
|
109212
109466
|
respHeaders.delete("Host");
|
109213
109467
|
respHeaders.delete("Content-Length");
|
109214
109468
|
const apiResponse = await res.json();
|
@@ -109216,7 +109470,7 @@ function MakeVectorizeFetcher(indexId) {
|
|
109216
109470
|
error: apiResponse.errors[0].message,
|
109217
109471
|
code: apiResponse.errors[0].code
|
109218
109472
|
};
|
109219
|
-
return new
|
109473
|
+
return new import_miniflare5.Response(JSON.stringify(newResponse), {
|
109220
109474
|
status: res.status,
|
109221
109475
|
headers: respHeaders
|
109222
109476
|
});
|
@@ -109374,7 +109628,7 @@ export default {
|
|
109374
109628
|
}
|
109375
109629
|
}
|
109376
109630
|
`;
|
109377
|
-
var WranglerLog = class extends
|
109631
|
+
var WranglerLog = class extends import_miniflare6.Log {
|
109378
109632
|
#warnedCompatibilityDateFallback = false;
|
109379
109633
|
log(message) {
|
109380
109634
|
if (message.includes(EXTERNAL_SERVICE_WORKER_NAME)) {
|
@@ -109419,13 +109673,13 @@ function castLogLevel(level) {
|
|
109419
109673
|
if (key === "LOG") {
|
109420
109674
|
key = "INFO";
|
109421
109675
|
}
|
109422
|
-
return
|
109676
|
+
return import_miniflare6.LogLevel[key];
|
109423
109677
|
}
|
109424
109678
|
__name(castLogLevel, "castLogLevel");
|
109425
109679
|
function buildLog() {
|
109426
109680
|
let level = castLogLevel(logger.loggerLevel);
|
109427
|
-
if (level <=
|
109428
|
-
level = Math.min(level,
|
109681
|
+
if (level <= import_miniflare6.LogLevel.DEBUG) {
|
109682
|
+
level = Math.min(level, import_miniflare6.LogLevel.WARN);
|
109429
109683
|
}
|
109430
109684
|
return new WranglerLog(level, { prefix: "wrangler-UserWorker" });
|
109431
109685
|
}
|
@@ -109565,7 +109819,7 @@ function buildMiniflareBindingOptions(config) {
|
|
109565
109819
|
};
|
109566
109820
|
} else {
|
109567
109821
|
let address;
|
109568
|
-
let style =
|
109822
|
+
let style = import_miniflare6.HttpOptions_Style.PROXY;
|
109569
109823
|
if (service.entrypoint !== void 0) {
|
109570
109824
|
if (target.entrypointAddresses === void 0) {
|
109571
109825
|
throw new UserError(
|
@@ -109588,7 +109842,7 @@ function buildMiniflareBindingOptions(config) {
|
|
109588
109842
|
);
|
109589
109843
|
}
|
109590
109844
|
address = `${target.host}:${target.port}`;
|
109591
|
-
style =
|
109845
|
+
style = import_miniflare6.HttpOptions_Style.HOST;
|
109592
109846
|
} else {
|
109593
109847
|
address = `${defaultEntrypointAddress.host}:${defaultEntrypointAddress.port}`;
|
109594
109848
|
}
|
@@ -109598,7 +109852,7 @@ function buildMiniflareBindingOptions(config) {
|
|
109598
109852
|
address,
|
109599
109853
|
http: {
|
109600
109854
|
style,
|
109601
|
-
cfBlobHeader:
|
109855
|
+
cfBlobHeader: import_miniflare6.CoreHeaders.CF_BLOB
|
109602
109856
|
}
|
109603
109857
|
}
|
109604
109858
|
};
|
@@ -109681,6 +109935,24 @@ function buildMiniflareBindingOptions(config) {
|
|
109681
109935
|
scriptName: EXTERNAL_AI_WORKER_NAME
|
109682
109936
|
};
|
109683
109937
|
}
|
109938
|
+
if (bindings.images?.binding) {
|
109939
|
+
externalWorkers.push({
|
109940
|
+
name: EXTERNAL_IMAGES_WORKER_NAME,
|
109941
|
+
modules: [
|
109942
|
+
{
|
109943
|
+
type: "ESModule",
|
109944
|
+
path: "index.mjs",
|
109945
|
+
contents: EXTERNAL_IMAGES_WORKER_SCRIPT
|
109946
|
+
}
|
109947
|
+
],
|
109948
|
+
serviceBindings: {
|
109949
|
+
FETCHER: config.imagesLocalMode ? imagesLocalFetcher : imagesRemoteFetcher
|
109950
|
+
}
|
109951
|
+
});
|
109952
|
+
wrappedBindings[bindings.images?.binding] = {
|
109953
|
+
scriptName: EXTERNAL_IMAGES_WORKER_NAME
|
109954
|
+
};
|
109955
|
+
}
|
109684
109956
|
if (bindings.vectorize) {
|
109685
109957
|
for (const vectorizeBinding of bindings.vectorize) {
|
109686
109958
|
const bindingName = vectorizeBinding.binding;
|
@@ -109895,6 +110167,7 @@ __name(handleRuntimeStdio, "handleRuntimeStdio");
|
|
109895
110167
|
var didWarnMiniflareCronSupport = false;
|
109896
110168
|
var didWarnMiniflareVectorizeSupport = false;
|
109897
110169
|
var didWarnAiAccountUsage = false;
|
110170
|
+
var didWarnImagesLocalModeUsage = false;
|
109898
110171
|
async function buildMiniflareOptions(log2, config, proxyToUserWorkerAuthenticationSecret) {
|
109899
110172
|
if (config.crons.length > 0 && !config.testScheduled) {
|
109900
110173
|
if (!didWarnMiniflareCronSupport) {
|
@@ -109926,6 +110199,14 @@ async function buildMiniflareOptions(log2, config, proxyToUserWorkerAuthenticati
|
|
109926
110199
|
);
|
109927
110200
|
}
|
109928
110201
|
}
|
110202
|
+
if (config.bindings.images && config.imagesLocalMode) {
|
110203
|
+
if (!didWarnImagesLocalModeUsage) {
|
110204
|
+
didWarnImagesLocalModeUsage = true;
|
110205
|
+
logger.info(
|
110206
|
+
"You are using Images local mode. This only supports resizing, rotating and transcoding."
|
110207
|
+
);
|
110208
|
+
}
|
110209
|
+
}
|
109929
110210
|
const upstream = typeof config.localUpstream === "string" ? `${config.upstreamProtocol}://${config.localUpstream}` : void 0;
|
109930
110211
|
const { sourceOptions, entrypointNames } = await buildSourceOptions(config);
|
109931
110212
|
const { bindingOptions, internalObjects, externalWorkers } = buildMiniflareBindingOptions(config);
|
@@ -109988,7 +110269,7 @@ __name(castErrorCause, "castErrorCause");
|
|
109988
110269
|
init_import_meta_url();
|
109989
110270
|
var import_node_crypto5 = require("node:crypto");
|
109990
110271
|
var import_promises6 = require("node:fs/promises");
|
109991
|
-
var
|
110272
|
+
var import_miniflare7 = require("miniflare");
|
109992
110273
|
|
109993
110274
|
// src/api/startDevWorker/BaseController.ts
|
109994
110275
|
init_import_meta_url();
|
@@ -110167,6 +110448,11 @@ function convertCfWorkerInitBindingstoBindings(inputBindings) {
|
|
110167
110448
|
output[binding] = { type: "ai", ...x6 };
|
110168
110449
|
break;
|
110169
110450
|
}
|
110451
|
+
case "images": {
|
110452
|
+
const { binding, ...x6 } = info;
|
110453
|
+
output[binding] = { type: "images", ...x6 };
|
110454
|
+
break;
|
110455
|
+
}
|
110170
110456
|
case "version_metadata": {
|
110171
110457
|
const { binding, ...x6 } = info;
|
110172
110458
|
output[binding] = { type: "version_metadata", ...x6 };
|
@@ -110217,6 +110503,7 @@ async function convertBindingsToCfWorkerInitBindings(inputBindings) {
|
|
110217
110503
|
text_blobs: void 0,
|
110218
110504
|
browser: void 0,
|
110219
110505
|
ai: void 0,
|
110506
|
+
images: void 0,
|
110220
110507
|
version_metadata: void 0,
|
110221
110508
|
data_blobs: void 0,
|
110222
110509
|
durable_objects: void 0,
|
@@ -110268,6 +110555,8 @@ async function convertBindingsToCfWorkerInitBindings(inputBindings) {
|
|
110268
110555
|
bindings.browser = { binding: name2 };
|
110269
110556
|
} else if (binding.type === "ai") {
|
110270
110557
|
bindings.ai = { binding: name2 };
|
110558
|
+
} else if (binding.type === "images") {
|
110559
|
+
bindings.images = { binding: name2 };
|
110271
110560
|
} else if (binding.type === "version_metadata") {
|
110272
110561
|
bindings.version_metadata = { binding: name2 };
|
110273
110562
|
} else if (binding.type === "durable_object_namespace") {
|
@@ -110439,6 +110728,7 @@ async function convertToConfigBundle(event) {
|
|
110439
110728
|
services: bindings.services,
|
110440
110729
|
serviceBindings: fetchers,
|
110441
110730
|
bindVectorizeToProd: event.config.dev?.bindVectorizeToProd ?? false,
|
110731
|
+
imagesLocalMode: event.config.dev?.imagesLocalMode ?? false,
|
110442
110732
|
testScheduled: !!event.config.dev.testScheduled
|
110443
110733
|
};
|
110444
110734
|
}
|
@@ -110456,7 +110746,7 @@ var LocalRuntimeController = class extends RuntimeController {
|
|
110456
110746
|
// `buildMiniflareOptions()` is asynchronous, meaning if multiple bundle
|
110457
110747
|
// updates were submitted, the second may apply before the first. Therefore,
|
110458
110748
|
// wrap updates in a mutex, so they're always applied in invocation order.
|
110459
|
-
#mutex = new
|
110749
|
+
#mutex = new import_miniflare7.Mutex();
|
110460
110750
|
#mf;
|
110461
110751
|
onBundleStart(_4) {
|
110462
110752
|
}
|
@@ -110470,7 +110760,7 @@ var LocalRuntimeController = class extends RuntimeController {
|
|
110470
110760
|
options30.liveReload = false;
|
110471
110761
|
if (this.#mf === void 0) {
|
110472
110762
|
logger.log(source_default.dim("\u2394 Starting local server..."));
|
110473
|
-
this.#mf = new
|
110763
|
+
this.#mf = new import_miniflare7.Miniflare(options30);
|
110474
110764
|
} else {
|
110475
110765
|
logger.log(source_default.dim("\u2394 Reloading local server..."));
|
110476
110766
|
await this.#mf.setOptions(options30);
|
@@ -110607,7 +110897,7 @@ var MultiworkerRuntimeController = class extends LocalRuntimeController {
|
|
110607
110897
|
// `buildMiniflareOptions()` is asynchronous, meaning if multiple bundle
|
110608
110898
|
// updates were submitted, the second may apply before the first. Therefore,
|
110609
110899
|
// wrap updates in a mutex, so they're always applied in invocation order.
|
110610
|
-
#mutex = new
|
110900
|
+
#mutex = new import_miniflare8.Mutex();
|
110611
110901
|
#mf;
|
110612
110902
|
#options = /* @__PURE__ */ new Map();
|
110613
110903
|
#canStartMiniflare() {
|
@@ -110645,7 +110935,7 @@ var MultiworkerRuntimeController = class extends LocalRuntimeController {
|
|
110645
110935
|
const mergedMfOptions = ensureMatchingSql(this.#mergedMfOptions());
|
110646
110936
|
if (this.#mf === void 0) {
|
110647
110937
|
logger.log(source_default.dim("\u2394 Starting local server..."));
|
110648
|
-
this.#mf = new
|
110938
|
+
this.#mf = new import_miniflare8.Miniflare(mergedMfOptions);
|
110649
110939
|
} else {
|
110650
110940
|
logger.log(source_default.dim("\u2394 Reloading local server..."));
|
110651
110941
|
await this.#mf.setOptions(mergedMfOptions);
|
@@ -110743,7 +111033,7 @@ var import_node_assert9 = __toESM(require("node:assert"));
|
|
110743
111033
|
var import_node_crypto7 = require("node:crypto");
|
110744
111034
|
var import_node_events2 = __toESM(require("node:events"));
|
110745
111035
|
var import_node_path18 = __toESM(require("node:path"));
|
110746
|
-
var
|
111036
|
+
var import_miniflare10 = require("miniflare");
|
110747
111037
|
|
110748
111038
|
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/wrangler/templates/startDevWorker/InspectorProxyWorker.ts
|
110749
111039
|
init_import_meta_url();
|
@@ -111054,7 +111344,7 @@ var openInspector = /* @__PURE__ */ __name(async (inspectorPort, worker) => {
|
|
111054
111344
|
init_import_meta_url();
|
111055
111345
|
var fs9 = __toESM(require("node:fs"));
|
111056
111346
|
var path20 = __toESM(require("node:path"));
|
111057
|
-
var
|
111347
|
+
var import_miniflare9 = require("miniflare");
|
111058
111348
|
var CERT_EXPIRY_DAYS = 30;
|
111059
111349
|
var ONE_DAY_IN_MS = 864e5;
|
111060
111350
|
var getHttpsKeyPathFromEnv = getEnvironmentVariableFactory({
|
@@ -111154,7 +111444,7 @@ function generateCertificate() {
|
|
111154
111444
|
name: "subjectAltName",
|
111155
111445
|
altNames: [
|
111156
111446
|
{ type: 2, value: "localhost" },
|
111157
|
-
...(0,
|
111447
|
+
...(0, import_miniflare9.getAccessibleHosts)(false).map((ip) => ({ type: 7, ip }))
|
111158
111448
|
]
|
111159
111449
|
}
|
111160
111450
|
]
|
@@ -111205,7 +111495,7 @@ var ProxyController = class extends Controller {
|
|
111205
111495
|
PROXY_CONTROLLER: async (req) => {
|
111206
111496
|
const message = await req.json();
|
111207
111497
|
this.onProxyWorkerMessage(message);
|
111208
|
-
return new
|
111498
|
+
return new import_miniflare10.Response(null, { status: 204 });
|
111209
111499
|
}
|
111210
111500
|
},
|
111211
111501
|
bindings: {
|
@@ -111266,7 +111556,7 @@ var ProxyController = class extends Controller {
|
|
111266
111556
|
proxyWorkerOptions
|
111267
111557
|
);
|
111268
111558
|
const willInstantiateMiniflareInstance = !this.proxyWorker || proxyWorkerOptionsChanged;
|
111269
|
-
this.proxyWorker ??= new
|
111559
|
+
this.proxyWorker ??= new import_miniflare10.Miniflare(proxyWorkerOptions);
|
111270
111560
|
this.proxyWorkerOptions = proxyWorkerOptions;
|
111271
111561
|
if (proxyWorkerOptionsChanged) {
|
111272
111562
|
logger.debug("ProxyWorker miniflare options changed, reinstantiating...");
|
@@ -111348,7 +111638,7 @@ var ProxyController = class extends Controller {
|
|
111348
111638
|
this.inspectorProxyWorkerWebSocket?.resolve(webSocket);
|
111349
111639
|
return webSocket;
|
111350
111640
|
}
|
111351
|
-
runtimeMessageMutex = new
|
111641
|
+
runtimeMessageMutex = new import_miniflare10.Mutex();
|
111352
111642
|
async sendMessageToProxyWorker(message, retries = 3) {
|
111353
111643
|
if (this._torndown) {
|
111354
111644
|
return;
|
@@ -111501,15 +111791,15 @@ var ProxyController = class extends Controller {
|
|
111501
111791
|
);
|
111502
111792
|
}
|
111503
111793
|
if (maybeContents === void 0) {
|
111504
|
-
return new
|
111794
|
+
return new import_miniflare10.Response(null, { status: 404 });
|
111505
111795
|
}
|
111506
|
-
return new
|
111796
|
+
return new import_miniflare10.Response(maybeContents);
|
111507
111797
|
}
|
111508
111798
|
default:
|
111509
111799
|
assertNever(message);
|
111510
|
-
return new
|
111800
|
+
return new import_miniflare10.Response(null, { status: 404 });
|
111511
111801
|
}
|
111512
|
-
return new
|
111802
|
+
return new import_miniflare10.Response(null, { status: 204 });
|
111513
111803
|
}
|
111514
111804
|
_torndown = false;
|
111515
111805
|
async teardown() {
|
@@ -111562,7 +111852,7 @@ var ProxyController = class extends Controller {
|
|
111562
111852
|
__name(ProxyController, "ProxyController");
|
111563
111853
|
var ProxyControllerLogger = class extends WranglerLog {
|
111564
111854
|
log(message) {
|
111565
|
-
if (message.includes("/cdn-cgi/") && this.level <
|
111855
|
+
if (message.includes("/cdn-cgi/") && this.level < import_miniflare10.LogLevel.DEBUG) {
|
111566
111856
|
return;
|
111567
111857
|
}
|
111568
111858
|
super.log(message);
|
@@ -115409,7 +115699,8 @@ var AssetConfigSchema = z2.object({
|
|
115409
115699
|
"none"
|
115410
115700
|
]).optional(),
|
115411
115701
|
not_found_handling: z2.enum(["single-page-application", "404-page", "none"]).optional(),
|
115412
|
-
serve_directly: z2.boolean().optional()
|
115702
|
+
serve_directly: z2.boolean().optional(),
|
115703
|
+
run_worker_first: z2.boolean().optional()
|
115413
115704
|
});
|
115414
115705
|
var InternalConfigSchema = z2.object({
|
115415
115706
|
// Used for analytics and reporting
|
@@ -116156,8 +116447,7 @@ var Handler2 = withConfig(
|
|
116156
116447
|
}
|
116157
116448
|
}
|
116158
116449
|
);
|
116159
|
-
var listDatabases = /* @__PURE__ */ __name(async (accountId, limitCalls = false) => {
|
116160
|
-
const pageSize = 10;
|
116450
|
+
var listDatabases = /* @__PURE__ */ __name(async (accountId, limitCalls = false, pageSize = 10) => {
|
116161
116451
|
let page = 1;
|
116162
116452
|
const results = [];
|
116163
116453
|
while (results.length % pageSize === 0) {
|
@@ -116217,22 +116507,22 @@ var getDatabaseByNameOrBinding = /* @__PURE__ */ __name(async (config, accountId
|
|
116217
116507
|
}
|
116218
116508
|
return matchingDB;
|
116219
116509
|
}, "getDatabaseByNameOrBinding");
|
116220
|
-
var
|
116510
|
+
var getDatabaseInfoFromIdOrName = /* @__PURE__ */ __name(async (accountId, databaseIdOrName) => {
|
116221
116511
|
return await fetchResult(
|
116222
|
-
`/accounts/${accountId}/d1/database/${
|
116512
|
+
`/accounts/${accountId}/d1/database/${databaseIdOrName}`,
|
116223
116513
|
{
|
116224
116514
|
headers: {
|
116225
116515
|
"Content-Type": "application/json"
|
116226
116516
|
}
|
116227
116517
|
}
|
116228
116518
|
);
|
116229
|
-
}, "
|
116519
|
+
}, "getDatabaseInfoFromIdOrName");
|
116230
116520
|
|
116231
116521
|
// src/kv/helpers.ts
|
116232
116522
|
init_import_meta_url();
|
116233
116523
|
var import_node_buffer = require("node:buffer");
|
116234
116524
|
var import_node_url8 = require("node:url");
|
116235
|
-
var
|
116525
|
+
var import_miniflare12 = require("miniflare");
|
116236
116526
|
var import_undici4 = __toESM(require_undici());
|
116237
116527
|
|
116238
116528
|
// src/dev/get-local-persistence-path.ts
|
@@ -116503,7 +116793,7 @@ __name(getKVNamespaceId, "getKVNamespaceId");
|
|
116503
116793
|
async function usingLocalNamespace(persistTo, config, namespaceId, closure) {
|
116504
116794
|
const persist = getLocalPersistencePath(persistTo, config);
|
116505
116795
|
const persistOptions = buildPersistOptions(persist);
|
116506
|
-
const mf = new
|
116796
|
+
const mf = new import_miniflare12.Miniflare({
|
116507
116797
|
script: 'addEventListener("fetch", (e) => e.respondWith(new Response(null, { status: 404 })))',
|
116508
116798
|
...persistOptions,
|
116509
116799
|
kvNamespaces: { NAMESPACE: namespaceId }
|
@@ -116521,7 +116811,7 @@ __name(usingLocalNamespace, "usingLocalNamespace");
|
|
116521
116811
|
init_import_meta_url();
|
116522
116812
|
var fs10 = __toESM(require("node:fs"));
|
116523
116813
|
var import_web = require("node:stream/web");
|
116524
|
-
var
|
116814
|
+
var import_miniflare14 = require("miniflare");
|
116525
116815
|
|
116526
116816
|
// src/queues/client.ts
|
116527
116817
|
init_import_meta_url();
|
@@ -116961,7 +117251,7 @@ __name(deleteR2Object, "deleteR2Object");
|
|
116961
117251
|
async function usingLocalBucket(persistTo, config, bucketName, closure) {
|
116962
117252
|
const persist = getLocalPersistencePath(persistTo, config);
|
116963
117253
|
const persistOptions = buildPersistOptions(persist);
|
116964
|
-
const mf = new
|
117254
|
+
const mf = new import_miniflare14.Miniflare({
|
116965
117255
|
modules: true,
|
116966
117256
|
// TODO(soon): import `reduceError()` from `miniflare:shared`
|
116967
117257
|
script: `
|
@@ -117500,6 +117790,7 @@ function getBindings(config, options30) {
|
|
117500
117790
|
wasm_modules: options30?.pages ? void 0 : config?.wasm_modules,
|
117501
117791
|
browser: config?.browser,
|
117502
117792
|
ai: config?.ai,
|
117793
|
+
images: config?.images,
|
117503
117794
|
version_metadata: config?.version_metadata,
|
117504
117795
|
text_blobs: options30?.pages ? void 0 : config?.text_blobs,
|
117505
117796
|
data_blobs: options30?.pages ? void 0 : config?.data_blobs,
|
@@ -117527,144 +117818,264 @@ function getBindings(config, options30) {
|
|
117527
117818
|
};
|
117528
117819
|
}
|
117529
117820
|
__name(getBindings, "getBindings");
|
117530
|
-
|
117531
|
-
|
117532
|
-
|
117533
|
-
|
117534
|
-
|
117535
|
-
|
117536
|
-
|
117537
|
-
|
117538
|
-
|
117539
|
-
}
|
117540
|
-
|
117821
|
+
var ProvisionResourceHandler = class {
|
117822
|
+
constructor(type, binding, idField, accountId) {
|
117823
|
+
this.type = type;
|
117824
|
+
this.binding = binding;
|
117825
|
+
this.idField = idField;
|
117826
|
+
this.accountId = accountId;
|
117827
|
+
}
|
117828
|
+
inherit() {
|
117829
|
+
this.binding[this.idField] = INHERIT_SYMBOL;
|
117830
|
+
}
|
117831
|
+
connect(id) {
|
117832
|
+
this.binding[this.idField] = id;
|
117833
|
+
}
|
117834
|
+
async provision(name2) {
|
117835
|
+
const id = await this.create(name2);
|
117836
|
+
this.connect(id);
|
117837
|
+
}
|
117838
|
+
// This binding is fully specified and can't/shouldn't be provisioned
|
117839
|
+
// This is usually when it has an id (e.g. D1 `database_id`)
|
117840
|
+
isFullySpecified() {
|
117841
|
+
return false;
|
117541
117842
|
}
|
117542
|
-
|
117543
|
-
|
117544
|
-
|
117545
|
-
|
117843
|
+
// Does this binding need to be provisioned?
|
117844
|
+
// Some bindings are not fully specified, but don't need provisioning
|
117845
|
+
// (e.g. R2 binding, with a bucket_name that already exists)
|
117846
|
+
async isConnectedToExistingResource() {
|
117847
|
+
return false;
|
117848
|
+
}
|
117849
|
+
// Should this resource be provisioned?
|
117850
|
+
async shouldProvision(settings) {
|
117851
|
+
if (!this.isFullySpecified()) {
|
117852
|
+
if (await this.canInherit(settings)) {
|
117853
|
+
this.inherit();
|
117546
117854
|
} else {
|
117547
|
-
|
117548
|
-
|
117549
|
-
|
117550
|
-
|
117551
|
-
return id;
|
117552
|
-
},
|
117553
|
-
updateId(id) {
|
117554
|
-
kv.id = id;
|
117855
|
+
const connected = await this.isConnectedToExistingResource();
|
117856
|
+
if (connected) {
|
117857
|
+
if (typeof connected === "string") {
|
117858
|
+
this.connect(connected);
|
117555
117859
|
}
|
117556
|
-
|
117860
|
+
return false;
|
117861
|
+
}
|
117862
|
+
return true;
|
117557
117863
|
}
|
117558
117864
|
}
|
117865
|
+
return false;
|
117559
117866
|
}
|
117560
|
-
|
117561
|
-
|
117562
|
-
|
117563
|
-
|
117564
|
-
|
117565
|
-
|
117566
|
-
|
117567
|
-
|
117568
|
-
|
117569
|
-
|
117570
|
-
|
117571
|
-
|
117572
|
-
|
117573
|
-
|
117574
|
-
|
117575
|
-
|
117867
|
+
};
|
117868
|
+
__name(ProvisionResourceHandler, "ProvisionResourceHandler");
|
117869
|
+
var R2Handler = class extends ProvisionResourceHandler {
|
117870
|
+
get name() {
|
117871
|
+
return this.binding.bucket_name;
|
117872
|
+
}
|
117873
|
+
async create(name2) {
|
117874
|
+
await createR2Bucket(
|
117875
|
+
this.accountId,
|
117876
|
+
name2,
|
117877
|
+
void 0,
|
117878
|
+
this.binding.jurisdiction
|
117879
|
+
);
|
117880
|
+
return name2;
|
117881
|
+
}
|
117882
|
+
constructor(binding, accountId) {
|
117883
|
+
super("r2_bucket", binding, "bucket_name", accountId);
|
117884
|
+
}
|
117885
|
+
canInherit(settings) {
|
117886
|
+
return !!settings?.bindings.find(
|
117887
|
+
(existing) => existing.type === this.type && existing.name === this.binding.binding && existing.jurisdiction === this.binding.jurisdiction
|
117888
|
+
);
|
117889
|
+
}
|
117890
|
+
async isConnectedToExistingResource() {
|
117891
|
+
(0, import_node_assert10.default)(typeof this.binding.bucket_name !== "symbol");
|
117892
|
+
if (!this.binding.bucket_name) {
|
117893
|
+
return false;
|
117894
|
+
}
|
117895
|
+
try {
|
117896
|
+
await getR2Bucket(
|
117897
|
+
this.accountId,
|
117898
|
+
this.binding.bucket_name,
|
117899
|
+
this.binding.jurisdiction
|
117900
|
+
);
|
117901
|
+
return true;
|
117902
|
+
} catch (e7) {
|
117903
|
+
if (!(e7 instanceof APIError && e7.code === 10006)) {
|
117904
|
+
throw e7;
|
117576
117905
|
}
|
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
|
-
});
|
117906
|
+
return false;
|
117594
117907
|
}
|
117595
117908
|
}
|
117596
|
-
|
117597
|
-
|
117598
|
-
|
117599
|
-
|
117600
|
-
|
117601
|
-
|
117602
|
-
|
117603
|
-
|
117604
|
-
|
117605
|
-
|
117606
|
-
|
117607
|
-
|
117608
|
-
|
117609
|
-
|
117610
|
-
|
117611
|
-
|
117612
|
-
|
117909
|
+
};
|
117910
|
+
__name(R2Handler, "R2Handler");
|
117911
|
+
var KVHandler = class extends ProvisionResourceHandler {
|
117912
|
+
get name() {
|
117913
|
+
return void 0;
|
117914
|
+
}
|
117915
|
+
async create(name2) {
|
117916
|
+
return await createKVNamespace(this.accountId, name2);
|
117917
|
+
}
|
117918
|
+
constructor(binding, accountId) {
|
117919
|
+
super("kv_namespace", binding, "id", accountId);
|
117920
|
+
}
|
117921
|
+
canInherit(settings) {
|
117922
|
+
return !!settings?.bindings.find(
|
117923
|
+
(existing) => existing.type === this.type && existing.name === this.binding.binding
|
117924
|
+
);
|
117925
|
+
}
|
117926
|
+
isFullySpecified() {
|
117927
|
+
return !!this.binding.id;
|
117928
|
+
}
|
117929
|
+
};
|
117930
|
+
__name(KVHandler, "KVHandler");
|
117931
|
+
var D1Handler = class extends ProvisionResourceHandler {
|
117932
|
+
get name() {
|
117933
|
+
return this.binding.database_name;
|
117934
|
+
}
|
117935
|
+
async create(name2) {
|
117936
|
+
const db = await createD1Database(this.accountId, name2);
|
117937
|
+
return db.uuid;
|
117938
|
+
}
|
117939
|
+
constructor(binding, accountId) {
|
117940
|
+
super("d1", binding, "database_id", accountId);
|
117941
|
+
}
|
117942
|
+
async canInherit(settings) {
|
117943
|
+
const maybeInherited = settings?.bindings.find(
|
117944
|
+
(existing) => existing.type === this.type && existing.name === this.binding.binding
|
117945
|
+
);
|
117946
|
+
if (maybeInherited) {
|
117947
|
+
if (!this.binding.database_name) {
|
117948
|
+
return true;
|
117949
|
+
}
|
117950
|
+
const dbFromId = await getDatabaseInfoFromIdOrName(
|
117951
|
+
this.accountId,
|
117952
|
+
maybeInherited.id
|
117953
|
+
);
|
117954
|
+
if (this.binding.database_name === dbFromId.name) {
|
117955
|
+
return true;
|
117956
|
+
}
|
117957
|
+
}
|
117958
|
+
return false;
|
117959
|
+
}
|
117960
|
+
async isConnectedToExistingResource() {
|
117961
|
+
(0, import_node_assert10.default)(typeof this.binding.database_name !== "symbol");
|
117962
|
+
if (!this.binding.database_name) {
|
117963
|
+
return false;
|
117964
|
+
}
|
117965
|
+
try {
|
117966
|
+
const db = await getDatabaseInfoFromIdOrName(
|
117967
|
+
this.accountId,
|
117968
|
+
this.binding.database_name
|
117969
|
+
);
|
117970
|
+
return db.uuid;
|
117971
|
+
} catch (e7) {
|
117972
|
+
if (!(e7 instanceof APIError && e7.code === 7404)) {
|
117973
|
+
throw e7;
|
117974
|
+
}
|
117975
|
+
return false;
|
117976
|
+
}
|
117977
|
+
}
|
117978
|
+
isFullySpecified() {
|
117979
|
+
return !!this.binding.database_id;
|
117980
|
+
}
|
117981
|
+
};
|
117982
|
+
__name(D1Handler, "D1Handler");
|
117983
|
+
var HANDLERS = {
|
117984
|
+
kv_namespaces: {
|
117985
|
+
Handler: KVHandler,
|
117986
|
+
sort: 0,
|
117987
|
+
name: "KV Namespace",
|
117988
|
+
keyDescription: "title or id"
|
117989
|
+
},
|
117990
|
+
d1_databases: {
|
117991
|
+
Handler: D1Handler,
|
117992
|
+
sort: 1,
|
117993
|
+
name: "D1 Database",
|
117994
|
+
keyDescription: "name or id"
|
117995
|
+
},
|
117996
|
+
r2_buckets: {
|
117997
|
+
Handler: R2Handler,
|
117998
|
+
sort: 2,
|
117999
|
+
name: "R2 Bucket",
|
118000
|
+
keyDescription: "name"
|
118001
|
+
}
|
118002
|
+
};
|
118003
|
+
var LOADERS = {
|
118004
|
+
kv_namespaces: async (accountId) => {
|
118005
|
+
const preExistingKV = await listKVNamespaces(accountId, true);
|
118006
|
+
return preExistingKV.map((ns) => ({ title: ns.title, value: ns.id }));
|
118007
|
+
},
|
118008
|
+
d1_databases: async (accountId) => {
|
118009
|
+
const preExisting = await listDatabases(accountId, true, 1e3);
|
118010
|
+
return preExisting.map((db) => ({ title: db.name, value: db.uuid }));
|
118011
|
+
},
|
118012
|
+
r2_buckets: async (accountId) => {
|
118013
|
+
const preExisting = await listR2Buckets(accountId);
|
118014
|
+
return preExisting.map((bucket) => ({
|
118015
|
+
title: bucket.name,
|
118016
|
+
value: bucket.name
|
118017
|
+
}));
|
118018
|
+
}
|
118019
|
+
};
|
118020
|
+
async function collectPendingResources(accountId, scriptName, bindings) {
|
118021
|
+
let settings;
|
118022
|
+
try {
|
118023
|
+
settings = await getSettings(accountId, scriptName);
|
118024
|
+
} catch (error2) {
|
118025
|
+
logger.debug("No settings found");
|
118026
|
+
}
|
118027
|
+
const pendingResources = [];
|
118028
|
+
try {
|
118029
|
+
settings = await getSettings(accountId, scriptName);
|
118030
|
+
} catch (error2) {
|
118031
|
+
logger.debug("No settings found");
|
118032
|
+
}
|
118033
|
+
for (const resourceType of Object.keys(
|
118034
|
+
HANDLERS
|
118035
|
+
)) {
|
118036
|
+
for (const resource of bindings[resourceType] ?? []) {
|
118037
|
+
const h6 = new HANDLERS[resourceType].Handler(resource, accountId);
|
118038
|
+
if (await h6.shouldProvision(settings)) {
|
118039
|
+
pendingResources.push({
|
118040
|
+
binding: resource.binding,
|
118041
|
+
resourceType,
|
118042
|
+
handler: h6
|
118043
|
+
});
|
117613
118044
|
}
|
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
118045
|
}
|
117626
118046
|
}
|
117627
|
-
|
118047
|
+
return pendingResources.sort(
|
118048
|
+
(a5, b6) => HANDLERS[a5.resourceType].sort - HANDLERS[b6.resourceType].sort
|
118049
|
+
);
|
118050
|
+
}
|
118051
|
+
__name(collectPendingResources, "collectPendingResources");
|
118052
|
+
async function provisionBindings(bindings, accountId, scriptName, autoCreate, config) {
|
118053
|
+
const pendingResources = await collectPendingResources(
|
118054
|
+
accountId,
|
118055
|
+
scriptName,
|
118056
|
+
bindings
|
118057
|
+
);
|
118058
|
+
if (pendingResources.length > 0) {
|
117628
118059
|
if (!isLegacyEnv(config)) {
|
117629
118060
|
throw new UserError(
|
117630
118061
|
"Provisioning resources is not supported with a service environment"
|
117631
118062
|
);
|
117632
118063
|
}
|
117633
118064
|
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
|
-
);
|
118065
|
+
const printable = {};
|
118066
|
+
for (const resource of pendingResources) {
|
118067
|
+
printable[resource.resourceType] ??= [];
|
118068
|
+
printable[resource.resourceType].push({ binding: resource.binding });
|
117657
118069
|
}
|
117658
|
-
|
117659
|
-
|
118070
|
+
printBindings(printable, { provisioning: true });
|
118071
|
+
logger.log();
|
118072
|
+
const existingResources = {};
|
118073
|
+
for (const resource of pendingResources) {
|
118074
|
+
existingResources[resource.resourceType] ??= await LOADERS[resource.resourceType](accountId);
|
117660
118075
|
await runProvisioningFlow(
|
117661
|
-
|
117662
|
-
|
117663
|
-
|
117664
|
-
value: bucket.name
|
117665
|
-
})),
|
117666
|
-
"R2 Bucket",
|
117667
|
-
"name",
|
118076
|
+
resource,
|
118077
|
+
existingResources[resource.resourceType],
|
118078
|
+
HANDLERS[resource.resourceType].name,
|
117668
118079
|
scriptName,
|
117669
118080
|
autoCreate
|
117670
118081
|
);
|
@@ -117674,21 +118085,6 @@ async function provisionBindings(bindings, accountId, scriptName, autoCreate, co
|
|
117674
118085
|
}
|
117675
118086
|
}
|
117676
118087
|
__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
118088
|
function getSettings(accountId, scriptName) {
|
117693
118089
|
return fetchResult(
|
117694
118090
|
`/accounts/${accountId}/workers/scripts/${scriptName}/settings`
|
@@ -117697,103 +118093,75 @@ function getSettings(accountId, scriptName) {
|
|
117697
118093
|
__name(getSettings, "getSettings");
|
117698
118094
|
function printDivider() {
|
117699
118095
|
logger.log();
|
117700
|
-
logger.log(source_default.dim("--------------------------------------"));
|
117701
|
-
logger.log();
|
117702
118096
|
}
|
117703
118097
|
__name(printDivider, "printDivider");
|
117704
|
-
async function runProvisioningFlow(
|
118098
|
+
async function runProvisioningFlow(item, preExisting, friendlyBindingName, scriptName, autoCreate) {
|
117705
118099
|
const NEW_OPTION_VALUE = "__WRANGLER_INTERNAL_NEW";
|
117706
118100
|
const SEARCH_OPTION_VALUE = "__WRANGLER_INTERNAL_SEARCH";
|
117707
118101
|
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);
|
118102
|
+
const options30 = preExisting.slice(0, MAX_OPTIONS - 1);
|
118103
|
+
if (options30.length < preExisting.length) {
|
118104
|
+
options30.push({
|
118105
|
+
title: "Other (too many to list)",
|
118106
|
+
value: SEARCH_OPTION_VALUE
|
118107
|
+
});
|
118108
|
+
}
|
118109
|
+
const defaultName = `${scriptName}-${item.binding.toLowerCase().replace("_", "-")}`;
|
118110
|
+
logger.log("Provisioning", item.binding, `(${friendlyBindingName})...`);
|
118111
|
+
if (item.handler.name) {
|
118112
|
+
logger.log("Resource name found in config:", item.handler.name);
|
118113
|
+
logger.log(
|
118114
|
+
`\u{1F300} Creating new ${friendlyBindingName} "${item.handler.name}"...`
|
118115
|
+
);
|
118116
|
+
await item.handler.provision(item.handler.name);
|
118117
|
+
} else if (autoCreate) {
|
118118
|
+
logger.log(`\u{1F300} Creating new ${friendlyBindingName} "${defaultName}"...`);
|
118119
|
+
await item.handler.provision(defaultName);
|
118120
|
+
} else {
|
118121
|
+
let action = NEW_OPTION_VALUE;
|
118122
|
+
if (options30.length > 0) {
|
118123
|
+
action = await select(
|
118124
|
+
`Would you like to connect an existing ${friendlyBindingName} or create a new one?`,
|
118125
|
+
{
|
118126
|
+
choices: options30.concat([
|
118127
|
+
{ title: "Create new", value: NEW_OPTION_VALUE }
|
118128
|
+
]),
|
118129
|
+
defaultOption: options30.length
|
117742
118130
|
}
|
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
|
-
);
|
118131
|
+
);
|
118132
|
+
}
|
118133
|
+
if (action === NEW_OPTION_VALUE) {
|
118134
|
+
const name2 = await prompt(
|
118135
|
+
`Enter a name for your new ${friendlyBindingName}`,
|
118136
|
+
{
|
118137
|
+
defaultValue: defaultName
|
117756
118138
|
}
|
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
|
-
}
|
118139
|
+
);
|
118140
|
+
logger.log(`\u{1F300} Creating new ${friendlyBindingName} "${name2}"...`);
|
118141
|
+
await item.handler.provision(name2);
|
118142
|
+
} else if (action === SEARCH_OPTION_VALUE) {
|
118143
|
+
let foundResource;
|
118144
|
+
while (foundResource === void 0) {
|
118145
|
+
const input = await prompt(
|
118146
|
+
`Enter the ${HANDLERS[item.resourceType].keyDescription} for an existing ${friendlyBindingName}`
|
118147
|
+
);
|
118148
|
+
foundResource = preExisting.find(
|
118149
|
+
(r7) => r7.title === input || r7.value === input
|
118150
|
+
);
|
118151
|
+
if (foundResource) {
|
118152
|
+
item.handler.connect(foundResource.value);
|
117783
118153
|
} else {
|
117784
|
-
|
117785
|
-
|
118154
|
+
logger.log(
|
118155
|
+
`No ${friendlyBindingName} with that ${HANDLERS[item.resourceType].keyDescription} "${input}" found. Please try again.`
|
117786
118156
|
);
|
117787
|
-
if (selectedResource) {
|
117788
|
-
name2 = selectedResource.title;
|
117789
|
-
item.updateId(selected);
|
117790
|
-
}
|
117791
118157
|
}
|
117792
118158
|
}
|
117793
|
-
|
117794
|
-
|
118159
|
+
} else {
|
118160
|
+
item.handler.connect(action);
|
117795
118161
|
}
|
117796
118162
|
}
|
118163
|
+
logger.log(`\u2728 ${item.binding} provisioned \u{1F389}`);
|
118164
|
+
printDivider();
|
117797
118165
|
}
|
117798
118166
|
__name(runProvisioningFlow, "runProvisioningFlow");
|
117799
118167
|
|
@@ -118926,10 +119294,16 @@ function createWorkerUploadForm(worker) {
|
|
118926
119294
|
assets,
|
118927
119295
|
observability
|
118928
119296
|
} = worker;
|
119297
|
+
let runWorkerFirst = void 0;
|
119298
|
+
if (assets?.assetConfig?.run_worker_first !== void 0) {
|
119299
|
+
runWorkerFirst = assets.assetConfig?.run_worker_first;
|
119300
|
+
} else if (assets?.assetConfig?.serve_directly !== void 0) {
|
119301
|
+
runWorkerFirst = !assets?.assetConfig?.serve_directly;
|
119302
|
+
}
|
118929
119303
|
const assetConfig = {
|
118930
119304
|
html_handling: assets?.assetConfig?.html_handling,
|
118931
119305
|
not_found_handling: assets?.assetConfig?.not_found_handling,
|
118932
|
-
|
119306
|
+
run_worker_first: runWorkerFirst
|
118933
119307
|
};
|
118934
119308
|
if (assets && !assets.routingConfig.has_user_worker) {
|
118935
119309
|
formData.set(
|
@@ -119150,6 +119524,12 @@ function createWorkerUploadForm(worker) {
|
|
119150
119524
|
type: "ai"
|
119151
119525
|
});
|
119152
119526
|
}
|
119527
|
+
if (bindings.images !== void 0) {
|
119528
|
+
metadataBindings.push({
|
119529
|
+
name: bindings.images.binding,
|
119530
|
+
type: "images"
|
119531
|
+
});
|
119532
|
+
}
|
119153
119533
|
if (bindings.version_metadata !== void 0) {
|
119154
119534
|
metadataBindings.push({
|
119155
119535
|
name: bindings.version_metadata.binding,
|
@@ -119361,7 +119741,7 @@ __name(logBuildOutput, "logBuildOutput");
|
|
119361
119741
|
|
119362
119742
|
// src/deployment-bundle/node-compat.ts
|
119363
119743
|
init_import_meta_url();
|
119364
|
-
var
|
119744
|
+
var import_miniflare16 = require("miniflare");
|
119365
119745
|
function validateNodeCompatMode(compatibilityDateStr = "2000-01-01", compatibilityFlags, {
|
119366
119746
|
nodeCompat: legacy = false,
|
119367
119747
|
noBundle = void 0
|
@@ -119372,7 +119752,7 @@ function validateNodeCompatMode(compatibilityDateStr = "2000-01-01", compatibili
|
|
119372
119752
|
hasNodejsCompatFlag,
|
119373
119753
|
hasNodejsCompatV2Flag,
|
119374
119754
|
hasExperimentalNodejsCompatV2Flag
|
119375
|
-
} = (0,
|
119755
|
+
} = (0, import_miniflare16.getNodeCompat)(compatibilityDateStr, compatibilityFlags, {
|
119376
119756
|
nodeCompat: legacy
|
119377
119757
|
});
|
119378
119758
|
if (hasExperimentalNodejsCompatV2Flag) {
|
@@ -120829,6 +121209,9 @@ ${dashLink}`);
|
|
120829
121209
|
if (config.workflows?.length) {
|
120830
121210
|
logger.once.warn("Workflows is currently in open beta.");
|
120831
121211
|
for (const workflow of config.workflows) {
|
121212
|
+
if (workflow.script_name !== void 0 && workflow.script_name !== scriptName) {
|
121213
|
+
continue;
|
121214
|
+
}
|
120832
121215
|
deployments.push(
|
120833
121216
|
fetchResult(`/accounts/${accountId}/workflows/${workflow.name}`, {
|
120834
121217
|
method: "PUT",
|
@@ -121641,7 +122024,10 @@ var validateRoutes3 = /* @__PURE__ */ __name((routes, assets) => {
|
|
121641
122024
|
`Paths are not allowed in Custom Domains`
|
121642
122025
|
);
|
121643
122026
|
}
|
121644
|
-
} else if (
|
122027
|
+
} else if (
|
122028
|
+
// If we have Assets but we're not always hitting the Worker then validate
|
122029
|
+
assets?.directory !== void 0 && assets.assetConfig.run_worker_first !== true
|
122030
|
+
) {
|
121645
122031
|
const pattern = typeof route2 === "string" ? route2 : route2.pattern;
|
121646
122032
|
const components = pattern.split("/");
|
121647
122033
|
if (!(components.length === 2 && components[1] === "*")) {
|
@@ -122070,13 +122456,15 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
122070
122456
|
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
122071
122457
|
} else {
|
122072
122458
|
(0, import_node_assert16.default)(accountId, "Missing accountId");
|
122073
|
-
getFlag("RESOURCES_PROVISION")
|
122074
|
-
|
122075
|
-
|
122076
|
-
|
122077
|
-
|
122078
|
-
|
122079
|
-
|
122459
|
+
if (getFlag("RESOURCES_PROVISION")) {
|
122460
|
+
await provisionBindings(
|
122461
|
+
bindings,
|
122462
|
+
accountId,
|
122463
|
+
scriptName,
|
122464
|
+
props.experimentalAutoCreate,
|
122465
|
+
props.config
|
122466
|
+
);
|
122467
|
+
}
|
122080
122468
|
await ensureQueuesExistByConfig(config);
|
122081
122469
|
let bindingsPrinted = false;
|
122082
122470
|
try {
|
@@ -123093,11 +123481,12 @@ ${resolvedAssetsPath}`,
|
|
123093
123481
|
}
|
123094
123482
|
const routingConfig = {
|
123095
123483
|
has_user_worker: Boolean(args.script || config.main),
|
123096
|
-
invoke_user_worker_ahead_of_assets:
|
123484
|
+
invoke_user_worker_ahead_of_assets: config.assets?.run_worker_first || false
|
123097
123485
|
};
|
123098
123486
|
const assetConfig = {
|
123099
123487
|
html_handling: config.assets?.html_handling,
|
123100
123488
|
not_found_handling: config.assets?.not_found_handling,
|
123489
|
+
run_worker_first: config.assets?.run_worker_first,
|
123101
123490
|
serve_directly: config.assets?.experimental_serve_directly
|
123102
123491
|
};
|
123103
123492
|
return {
|
@@ -123132,20 +123521,24 @@ function validateAssetsArgsAndConfig(args, config) {
|
|
123132
123521
|
{ telemetryMessage: true }
|
123133
123522
|
);
|
123134
123523
|
}
|
123135
|
-
if (config?.placement?.mode === "smart" && config?.assets?.
|
123524
|
+
if (config?.placement?.mode === "smart" && config?.assets?.run_worker_first === true) {
|
123136
123525
|
logger.warn(
|
123137
|
-
"Turning on Smart Placement in a Worker that is using assets and
|
123526
|
+
"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"
|
123527
|
+
);
|
123528
|
+
}
|
123529
|
+
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) {
|
123530
|
+
throw new UserError(
|
123531
|
+
"run_worker_first and experimental_serve_directly specified.\nOnly one of these configuration options may be provided."
|
123138
123532
|
);
|
123139
123533
|
}
|
123140
|
-
if ("legacy" in args ? args.assets?.assetConfig?.
|
123534
|
+
if ("legacy" in args ? args.assets?.assetConfig?.run_worker_first === true && !args.assets?.binding : config?.assets?.run_worker_first === true && !config?.assets?.binding) {
|
123141
123535
|
logger.warn(
|
123142
|
-
"
|
123536
|
+
"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
123537
|
);
|
123144
123538
|
}
|
123145
|
-
if ("legacy" in args ? args.entrypoint === noOpEntrypoint && args.assets?.assetConfig?.
|
123539
|
+
if ("legacy" in args ? args.entrypoint === noOpEntrypoint && args.assets?.assetConfig?.run_worker_first === true : !config?.main && config?.assets?.run_worker_first === true) {
|
123146
123540
|
throw new UserError(
|
123147
|
-
"Cannot set
|
123148
|
-
{ telemetryMessage: true }
|
123541
|
+
"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
123542
|
);
|
123150
123543
|
}
|
123151
123544
|
}
|
@@ -123392,7 +123785,7 @@ init_import_meta_url();
|
|
123392
123785
|
// src/cli-hotkeys.ts
|
123393
123786
|
init_import_meta_url();
|
123394
123787
|
var import_readline = __toESM(require("readline"));
|
123395
|
-
var
|
123788
|
+
var import_miniflare17 = require("miniflare");
|
123396
123789
|
|
123397
123790
|
// src/utils/onKeyPress.ts
|
123398
123791
|
init_import_meta_url();
|
@@ -123486,16 +123879,16 @@ function cli_hotkeys_default(options30) {
|
|
123486
123879
|
__name(printInstructions, "printInstructions");
|
123487
123880
|
Logger.registerBeforeLogHook(clearPreviousInstructions);
|
123488
123881
|
Logger.registerAfterLogHook(printInstructions);
|
123489
|
-
|
123490
|
-
|
123882
|
+
import_miniflare17.Log.unstable_registerBeforeLogHook(clearPreviousInstructions);
|
123883
|
+
import_miniflare17.Log.unstable_registerAfterLogHook(printInstructions);
|
123491
123884
|
printInstructions();
|
123492
123885
|
return () => {
|
123493
123886
|
unregisterKeyPress();
|
123494
123887
|
clearPreviousInstructions();
|
123495
123888
|
Logger.registerBeforeLogHook(void 0);
|
123496
123889
|
Logger.registerAfterLogHook(void 0);
|
123497
|
-
|
123498
|
-
|
123890
|
+
import_miniflare17.Log.unstable_registerBeforeLogHook(void 0);
|
123891
|
+
import_miniflare17.Log.unstable_registerAfterLogHook(void 0);
|
123499
123892
|
};
|
123500
123893
|
}
|
123501
123894
|
__name(cli_hotkeys_default, "default");
|
@@ -123876,6 +124269,11 @@ var dev = createCommand({
|
|
123876
124269
|
type: "boolean",
|
123877
124270
|
describe: "Bind to production Vectorize indexes in local development mode",
|
123878
124271
|
default: false
|
124272
|
+
},
|
124273
|
+
"experimental-images-local-mode": {
|
124274
|
+
type: "boolean",
|
124275
|
+
describe: "Use a local lower-fidelity implementation of the Images binding",
|
124276
|
+
default: false
|
123879
124277
|
}
|
123880
124278
|
},
|
123881
124279
|
async validateArgs(args) {
|
@@ -124015,6 +124413,7 @@ async function setupDevEnv(devEnv, configPath, auth, args) {
|
|
124015
124413
|
text_blobs: void 0,
|
124016
124414
|
browser: void 0,
|
124017
124415
|
ai: args.ai,
|
124416
|
+
images: void 0,
|
124018
124417
|
version_metadata: args.version_metadata,
|
124019
124418
|
data_blobs: void 0,
|
124020
124419
|
durable_objects: { bindings: args.durableObjects ?? [] },
|
@@ -124057,6 +124456,7 @@ async function setupDevEnv(devEnv, configPath, auth, args) {
|
|
124057
124456
|
logLevel: args.logLevel,
|
124058
124457
|
registry: args.disableDevRegistry ? null : devEnv.config.latestConfig?.dev.registry,
|
124059
124458
|
bindVectorizeToProd: args.experimentalVectorizeBindToProd,
|
124459
|
+
imagesLocalMode: args.experimentalImagesLocalMode,
|
124060
124460
|
multiworkerPrimary: args.multiworkerPrimary
|
124061
124461
|
},
|
124062
124462
|
legacy: {
|
@@ -124418,6 +124818,7 @@ function getBindings2(configParam, env7, local, args) {
|
|
124418
124818
|
analytics_engine_datasets: configParam.analytics_engine_datasets,
|
124419
124819
|
browser: configParam.browser,
|
124420
124820
|
ai: args.ai || configParam.ai,
|
124821
|
+
images: configParam.images,
|
124421
124822
|
version_metadata: args.version_metadata || configParam.version_metadata,
|
124422
124823
|
unsafe: {
|
124423
124824
|
bindings: configParam.unsafe.bindings,
|
@@ -124476,6 +124877,7 @@ async function unstable_dev(script, options30, apiOptions) {
|
|
124476
124877
|
testMode,
|
124477
124878
|
testScheduled,
|
124478
124879
|
vectorizeBindToProd,
|
124880
|
+
imagesLocalMode,
|
124479
124881
|
// 2. options for alpha/beta products/libs
|
124480
124882
|
d1Databases,
|
124481
124883
|
enablePagesAssetsServiceBinding
|
@@ -124566,6 +124968,7 @@ unstable_dev()'s behaviour will likely change in future releases`
|
|
124566
124968
|
port: options30?.port ?? 0,
|
124567
124969
|
experimentalProvision: void 0,
|
124568
124970
|
experimentalVectorizeBindToProd: vectorizeBindToProd ?? false,
|
124971
|
+
experimentalImagesLocalMode: imagesLocalMode ?? false,
|
124569
124972
|
enableIpc: options30?.experimental?.enableIpc
|
124570
124973
|
};
|
124571
124974
|
const devServer = await run(
|
@@ -127127,7 +127530,8 @@ async function resolveDevConfig(config, input) {
|
|
127127
127530
|
persist: localPersistencePath,
|
127128
127531
|
registry: input.dev?.registry,
|
127129
127532
|
bindVectorizeToProd: input.dev?.bindVectorizeToProd ?? false,
|
127130
|
-
multiworkerPrimary: input.dev?.multiworkerPrimary
|
127533
|
+
multiworkerPrimary: input.dev?.multiworkerPrimary,
|
127534
|
+
imagesLocalMode: input.dev?.imagesLocalMode ?? false
|
127131
127535
|
};
|
127132
127536
|
}
|
127133
127537
|
__name(resolveDevConfig, "resolveDevConfig");
|
@@ -127162,6 +127566,7 @@ async function resolveBindings(config, input) {
|
|
127162
127566
|
{
|
127163
127567
|
registry: input.dev?.registry,
|
127164
127568
|
local: !input.dev?.remote,
|
127569
|
+
imagesLocalMode: input.dev?.imagesLocalMode,
|
127165
127570
|
name: config.name
|
127166
127571
|
}
|
127167
127572
|
);
|
@@ -127415,7 +127820,7 @@ __name(ConfigController, "ConfigController");
|
|
127415
127820
|
|
127416
127821
|
// src/api/startDevWorker/RemoteRuntimeController.ts
|
127417
127822
|
init_import_meta_url();
|
127418
|
-
var
|
127823
|
+
var import_miniflare19 = require("miniflare");
|
127419
127824
|
|
127420
127825
|
// src/dev/create-worker-preview.ts
|
127421
127826
|
init_import_meta_url();
|
@@ -127769,7 +128174,7 @@ __name(notImplemented, "notImplemented");
|
|
127769
128174
|
var RemoteRuntimeController = class extends RuntimeController {
|
127770
128175
|
#abortController = new AbortController();
|
127771
128176
|
#currentBundleId = 0;
|
127772
|
-
#mutex = new
|
128177
|
+
#mutex = new import_miniflare19.Mutex();
|
127773
128178
|
#session;
|
127774
128179
|
async #previewSession(props) {
|
127775
128180
|
try {
|
@@ -128162,7 +128567,7 @@ init_import_meta_url();
|
|
128162
128567
|
|
128163
128568
|
// src/api/integrations/platform/index.ts
|
128164
128569
|
init_import_meta_url();
|
128165
|
-
var
|
128570
|
+
var import_miniflare21 = require("miniflare");
|
128166
128571
|
|
128167
128572
|
// src/api/integrations/platform/caches.ts
|
128168
128573
|
init_import_meta_url();
|
@@ -128223,7 +128628,7 @@ __name(ExecutionContext, "ExecutionContext");
|
|
128223
128628
|
|
128224
128629
|
// src/api/integrations/platform/services.ts
|
128225
128630
|
init_import_meta_url();
|
128226
|
-
var
|
128631
|
+
var import_miniflare20 = require("miniflare");
|
128227
128632
|
var import_undici13 = __toESM(require_undici());
|
128228
128633
|
async function getServiceBindings(services = []) {
|
128229
128634
|
if (services.length === 0) {
|
@@ -128275,9 +128680,9 @@ function getServiceBindingProxyFetch({
|
|
128275
128680
|
try {
|
128276
128681
|
const resp = await (0, import_undici13.fetch)(newUrl, request4);
|
128277
128682
|
const respBody = await resp.arrayBuffer();
|
128278
|
-
return new
|
128683
|
+
return new import_miniflare20.Response(respBody, resp);
|
128279
128684
|
} catch {
|
128280
|
-
return new
|
128685
|
+
return new import_miniflare20.Response(
|
128281
128686
|
`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
128687
|
{ status: 500 }
|
128283
128688
|
);
|
@@ -128308,20 +128713,16 @@ async function getPlatformProxy(options30 = {}) {
|
|
128308
128713
|
},
|
128309
128714
|
() => getMiniflareOptionsFromConfig(rawConfig, env7, options30)
|
128310
128715
|
);
|
128311
|
-
const mf = new
|
128716
|
+
const mf = new import_miniflare21.Miniflare({
|
128312
128717
|
script: "",
|
128313
128718
|
modules: true,
|
128314
128719
|
...miniflareOptions
|
128315
128720
|
});
|
128316
128721
|
const bindings = await mf.getBindings();
|
128317
|
-
const vars = getVarsForDev(rawConfig, env7);
|
128318
128722
|
const cf2 = await mf.getCf();
|
128319
128723
|
deepFreeze(cf2);
|
128320
128724
|
return {
|
128321
|
-
env:
|
128322
|
-
...vars,
|
128323
|
-
...bindings
|
128324
|
-
},
|
128725
|
+
env: bindings,
|
128325
128726
|
cf: cf2,
|
128326
128727
|
ctx: new ExecutionContext(),
|
128327
128728
|
caches: new CacheStorage(),
|
@@ -128343,7 +128744,8 @@ async function getMiniflareOptionsFromConfig(rawConfig, env7, options30) {
|
|
128343
128744
|
queueConsumers: void 0,
|
128344
128745
|
services: rawConfig.services,
|
128345
128746
|
serviceBindings: {},
|
128346
|
-
migrations: rawConfig.migrations
|
128747
|
+
migrations: rawConfig.migrations,
|
128748
|
+
imagesLocalMode: false
|
128347
128749
|
});
|
128348
128750
|
const persistOptions = getMiniflarePersistOptions(options30.persist);
|
128349
128751
|
const serviceBindings = await getServiceBindings(bindings.services);
|
@@ -128410,12 +128812,13 @@ function unstable_getMiniflareWorkerOptions(configOrConfigPath, env7) {
|
|
128410
128812
|
queueConsumers: config.queues.consumers,
|
128411
128813
|
services: [],
|
128412
128814
|
serviceBindings: {},
|
128413
|
-
migrations: config.migrations
|
128815
|
+
migrations: config.migrations,
|
128816
|
+
imagesLocalMode: false
|
128414
128817
|
});
|
128415
128818
|
if (bindings.services !== void 0) {
|
128416
128819
|
bindingOptions.serviceBindings = Object.fromEntries(
|
128417
128820
|
bindings.services.map((binding) => {
|
128418
|
-
const name2 = binding.service === config.name ?
|
128821
|
+
const name2 = binding.service === config.name ? import_miniflare21.kCurrentWorker : binding.service;
|
128419
128822
|
return [binding.binding, { name: name2, entrypoint: binding.entrypoint }];
|
128420
128823
|
})
|
128421
128824
|
);
|
@@ -140068,7 +140471,7 @@ var import_fs13 = require("fs");
|
|
140068
140471
|
var import_node_assert25 = __toESM(require("node:assert"));
|
140069
140472
|
var import_node_path54 = __toESM(require("node:path"));
|
140070
140473
|
var import_md5_file = __toESM(require_md5_file());
|
140071
|
-
var
|
140474
|
+
var import_miniflare23 = require("miniflare");
|
140072
140475
|
var import_undici16 = __toESM(require_undici());
|
140073
140476
|
|
140074
140477
|
// src/d1/splitter.ts
|
@@ -140404,7 +140807,7 @@ async function executeLocally({
|
|
140404
140807
|
logger.log(
|
140405
140808
|
"\u{1F300} To execute on your remote database, add a --remote flag to your wrangler command."
|
140406
140809
|
);
|
140407
|
-
const mf = new
|
140810
|
+
const mf = new import_miniflare23.Miniflare({
|
140408
140811
|
modules: true,
|
140409
140812
|
script: "",
|
140410
140813
|
d1Persist,
|
@@ -140667,7 +141070,7 @@ __name(checkForSQLiteBinary, "checkForSQLiteBinary");
|
|
140667
141070
|
init_import_meta_url();
|
140668
141071
|
var import_promises24 = __toESM(require("node:fs/promises"));
|
140669
141072
|
var import_node_path55 = __toESM(require("node:path"));
|
140670
|
-
var
|
141073
|
+
var import_miniflare24 = require("miniflare");
|
140671
141074
|
var import_undici17 = __toESM(require_undici());
|
140672
141075
|
function Options7(yargs) {
|
140673
141076
|
return Name(yargs).option("local", {
|
@@ -140736,7 +141139,7 @@ async function exportLocal(config, name2, output, tables, noSchema, noData) {
|
|
140736
141139
|
logger.log(
|
140737
141140
|
"\u{1F300} To export your remote database, add a --remote flag to your wrangler command."
|
140738
141141
|
);
|
140739
|
-
const mf = new
|
141142
|
+
const mf = new import_miniflare24.Miniflare({
|
140740
141143
|
modules: true,
|
140741
141144
|
script: "export default {}",
|
140742
141145
|
d1Persist,
|
@@ -140860,7 +141263,7 @@ var Handler8 = withConfig(
|
|
140860
141263
|
accountId,
|
140861
141264
|
name2
|
140862
141265
|
);
|
140863
|
-
const result = await
|
141266
|
+
const result = await getDatabaseInfoFromIdOrName(accountId, db.uuid);
|
140864
141267
|
const output = { ...result };
|
140865
141268
|
if (output["file_size"]) {
|
140866
141269
|
output["database_size"] = output["file_size"];
|
@@ -141050,7 +141453,7 @@ var Handler9 = withConfig(
|
|
141050
141453
|
accountId,
|
141051
141454
|
name2
|
141052
141455
|
);
|
141053
|
-
const result = await
|
141456
|
+
const result = await getDatabaseInfoFromIdOrName(accountId, db.uuid);
|
141054
141457
|
const output = [];
|
141055
141458
|
if (result.version !== "alpha") {
|
141056
141459
|
const [startDate, endDate] = getDurationDates(timePeriod);
|
@@ -141382,7 +141785,10 @@ Your database may not be available to serve requests during the migration, conti
|
|
141382
141785
|
"In non-local mode `databaseInfo` should be defined."
|
141383
141786
|
);
|
141384
141787
|
const accountId = await requireAuth(config);
|
141385
|
-
const dbInfo = await
|
141788
|
+
const dbInfo = await getDatabaseInfoFromIdOrName(
|
141789
|
+
accountId,
|
141790
|
+
databaseInfo?.uuid
|
141791
|
+
);
|
141386
141792
|
if (dbInfo.version === "alpha") {
|
141387
141793
|
logger.log("\u{1F552} Creating backup...");
|
141388
141794
|
await createBackup(accountId, databaseInfo.uuid);
|
@@ -141601,7 +142007,7 @@ var getBookmarkIdFromTimestamp = /* @__PURE__ */ __name(async (accountId, databa
|
|
141601
142007
|
return bookmarkResult;
|
141602
142008
|
}, "getBookmarkIdFromTimestamp");
|
141603
142009
|
var throwIfDatabaseIsAlpha = /* @__PURE__ */ __name(async (accountId, databaseId) => {
|
141604
|
-
const dbInfo = await
|
142010
|
+
const dbInfo = await getDatabaseInfoFromIdOrName(accountId, databaseId);
|
141605
142011
|
if (dbInfo.version === "alpha") {
|
141606
142012
|
throw new UserError(
|
141607
142013
|
"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 +143996,7 @@ async function mapBindings(accountId, bindings) {
|
|
143590
143996
|
const d1BindingsWithInfo = {};
|
143591
143997
|
await Promise.all(
|
143592
143998
|
bindings.filter((binding) => binding.type === "d1").map(async (binding) => {
|
143593
|
-
const dbInfo = await
|
143999
|
+
const dbInfo = await getDatabaseInfoFromIdOrName(accountId, binding.id);
|
143594
144000
|
d1BindingsWithInfo[binding.id] = dbInfo;
|
143595
144001
|
})
|
143596
144002
|
);
|
@@ -143662,6 +144068,13 @@ async function mapBindings(accountId, bindings) {
|
|
143662
144068
|
};
|
143663
144069
|
}
|
143664
144070
|
break;
|
144071
|
+
case "images":
|
144072
|
+
{
|
144073
|
+
configObj.images = {
|
144074
|
+
binding: binding.name
|
144075
|
+
};
|
144076
|
+
}
|
144077
|
+
break;
|
143665
144078
|
case "r2_bucket":
|
143666
144079
|
{
|
143667
144080
|
configObj.r2_buckets = [
|
@@ -147290,6 +147703,11 @@ function Options14(yargs) {
|
|
147290
147703
|
type: "boolean",
|
147291
147704
|
describe: "Bind to production Vectorize indexes in local development mode",
|
147292
147705
|
default: false
|
147706
|
+
},
|
147707
|
+
"experimental-images-local-mode": {
|
147708
|
+
type: "boolean",
|
147709
|
+
describe: "Use a local lower-fidelity implementation of the Images binding",
|
147710
|
+
default: false
|
147293
147711
|
}
|
147294
147712
|
});
|
147295
147713
|
}
|
@@ -147730,6 +148148,7 @@ ${JSON.stringify(defaultRoutesJSONSpec, null, 2)}`
|
|
147730
148148
|
logLevel: args.logLevel ?? "log",
|
147731
148149
|
experimentalProvision: void 0,
|
147732
148150
|
experimentalVectorizeBindToProd: false,
|
148151
|
+
experimentalImagesLocalMode: false,
|
147733
148152
|
enableIpc: true,
|
147734
148153
|
config: Array.isArray(args.config) ? args.config : void 0,
|
147735
148154
|
legacyAssets: void 0,
|
@@ -148015,12 +148434,12 @@ init_import_meta_url();
|
|
148015
148434
|
var import_fs14 = require("fs");
|
148016
148435
|
var import_promises28 = require("node:fs/promises");
|
148017
148436
|
var import_toml8 = __toESM(require_toml());
|
148018
|
-
var
|
148437
|
+
var import_miniflare25 = require("miniflare");
|
148019
148438
|
async function toEnvironment(deploymentConfig, accountId) {
|
148020
148439
|
const configObj = {};
|
148021
148440
|
configObj.compatibility_date = deploymentConfig.compatibility_date ?? (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
|
148022
148441
|
if (deploymentConfig.always_use_latest_compatibility_date) {
|
148023
|
-
configObj.compatibility_date =
|
148442
|
+
configObj.compatibility_date = import_miniflare25.supportedCompatibilityDate;
|
148024
148443
|
}
|
148025
148444
|
if (deploymentConfig.compatibility_flags?.length) {
|
148026
148445
|
configObj.compatibility_flags = deploymentConfig.compatibility_flags;
|
@@ -148378,6 +148797,7 @@ async function createDraftWorker({
|
|
148378
148797
|
wasm_modules: {},
|
148379
148798
|
browser: void 0,
|
148380
148799
|
ai: void 0,
|
148800
|
+
images: void 0,
|
148381
148801
|
version_metadata: void 0,
|
148382
148802
|
text_blobs: {},
|
148383
148803
|
data_blobs: {},
|
@@ -149401,12 +149821,12 @@ init_import_meta_url();
|
|
149401
149821
|
init_import_meta_url();
|
149402
149822
|
|
149403
149823
|
// ../../node_modules/.pnpm/@smithy+util-buffer-from@2.2.0/node_modules/@smithy/util-buffer-from/dist-es/index.js
|
149404
|
-
var
|
149824
|
+
var import_buffer3 = require("buffer");
|
149405
149825
|
var fromString2 = /* @__PURE__ */ __name((input, encoding) => {
|
149406
149826
|
if (typeof input !== "string") {
|
149407
149827
|
throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
|
149408
149828
|
}
|
149409
|
-
return encoding ?
|
149829
|
+
return encoding ? import_buffer3.Buffer.from(input, encoding) : import_buffer3.Buffer.from(input);
|
149410
149830
|
}, "fromString");
|
149411
149831
|
|
149412
149832
|
// ../../node_modules/.pnpm/@smithy+util-utf8@2.3.0/node_modules/@smithy/util-utf8/dist-es/fromUtf8.js
|
@@ -165795,13 +166215,13 @@ __name(triggersDeployHandler, "triggersDeployHandler");
|
|
165795
166215
|
init_import_meta_url();
|
165796
166216
|
var fs28 = __toESM(require("node:fs"));
|
165797
166217
|
var import_node_path66 = require("node:path");
|
165798
|
-
var
|
166218
|
+
var import_miniflare27 = require("miniflare");
|
165799
166219
|
|
165800
166220
|
// src/type-generation/runtime/index.ts
|
165801
166221
|
init_import_meta_url();
|
165802
166222
|
var import_fs23 = require("fs");
|
165803
166223
|
var import_promises32 = require("fs/promises");
|
165804
|
-
var
|
166224
|
+
var import_miniflare26 = require("miniflare");
|
165805
166225
|
var import_workerd = require("workerd");
|
165806
166226
|
var DEFAULT_OUTFILE_RELATIVE_PATH = "./.wrangler/types/runtime.d.ts";
|
165807
166227
|
async function generateRuntimeTypes({
|
@@ -165843,7 +166263,7 @@ async function generate({
|
|
165843
166263
|
compatibilityFlags = []
|
165844
166264
|
}) {
|
165845
166265
|
const worker = (0, import_fs23.readFileSync)(require.resolve("workerd/worker.mjs")).toString();
|
165846
|
-
const mf = new
|
166266
|
+
const mf = new import_miniflare26.Miniflare({
|
165847
166267
|
compatibilityDate: "2024-01-01",
|
165848
166268
|
compatibilityFlags: ["nodejs_compat", "rtti_api"],
|
165849
166269
|
modules: true,
|
@@ -165985,7 +166405,7 @@ var typesCommand = createCommand({
|
|
165985
166405
|
});
|
165986
166406
|
const tsconfigPath = config.tsconfig ?? (0, import_node_path66.join)((0, import_node_path66.dirname)(config.configPath), "tsconfig.json");
|
165987
166407
|
const tsconfigTypes = readTsconfigTypes(tsconfigPath);
|
165988
|
-
const { mode } = (0,
|
166408
|
+
const { mode } = (0, import_miniflare27.getNodeCompat)(
|
165989
166409
|
config.compatibility_date,
|
165990
166410
|
config.compatibility_flags,
|
165991
166411
|
{
|
@@ -168860,10 +169280,21 @@ var versionsUploadCommand = createCommand({
|
|
168860
169280
|
describe: "A descriptive message for this Worker Gradual Rollouts Version",
|
168861
169281
|
type: "string",
|
168862
169282
|
requiresArg: true
|
169283
|
+
},
|
169284
|
+
"experimental-auto-create": {
|
169285
|
+
describe: "Automatically provision draft bindings with new resources",
|
169286
|
+
type: "boolean",
|
169287
|
+
default: true,
|
169288
|
+
hidden: true,
|
169289
|
+
alias: "x-auto-create"
|
168863
169290
|
}
|
168864
169291
|
},
|
168865
169292
|
behaviour: {
|
168866
|
-
useConfigRedirectIfAvailable: true
|
169293
|
+
useConfigRedirectIfAvailable: true,
|
169294
|
+
overrideExperimentalFlags: (args) => ({
|
169295
|
+
MULTIWORKER: false,
|
169296
|
+
RESOURCES_PROVISION: args.experimentalProvision ?? false
|
169297
|
+
})
|
168867
169298
|
},
|
168868
169299
|
handler: /* @__PURE__ */ __name(async function versionsUploadHandler(args, { config }) {
|
168869
169300
|
const entry = await getEntry(args, config, "versions upload");
|
@@ -168951,7 +169382,8 @@ var versionsUploadCommand = createCommand({
|
|
168951
169382
|
keepVars: false,
|
168952
169383
|
projectRoot: entry.projectRoot,
|
168953
169384
|
tag: args.tag,
|
168954
|
-
message: args.message
|
169385
|
+
message: args.message,
|
169386
|
+
experimentalAutoCreate: args.experimentalAutoCreate
|
168955
169387
|
});
|
168956
169388
|
writeOutput({
|
168957
169389
|
type: "version-upload",
|
@@ -169215,6 +169647,16 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
169215
169647
|
if (props.dryRun) {
|
169216
169648
|
printBindings({ ...bindings, vars: maskedVars });
|
169217
169649
|
} else {
|
169650
|
+
(0, import_node_assert30.default)(accountId, "Missing accountId");
|
169651
|
+
if (getFlag("RESOURCES_PROVISION")) {
|
169652
|
+
await provisionBindings(
|
169653
|
+
bindings,
|
169654
|
+
accountId,
|
169655
|
+
scriptName,
|
169656
|
+
props.experimentalAutoCreate,
|
169657
|
+
props.config
|
169658
|
+
);
|
169659
|
+
}
|
169218
169660
|
await ensureQueuesExistByConfig(config);
|
169219
169661
|
let bindingsPrinted = false;
|
169220
169662
|
try {
|