wrangler 3.105.1 → 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.
@@ -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 File7 = class extends Blob6 {
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, File7);
4634
+ webidl.brandCheck(this, File8);
4635
4635
  return this[kState].name;
4636
4636
  }
4637
4637
  get lastModified() {
4638
- webidl.brandCheck(this, File7);
4638
+ webidl.brandCheck(this, File8);
4639
4639
  return this[kState].lastModified;
4640
4640
  }
4641
4641
  get type() {
4642
- webidl.brandCheck(this, File7);
4642
+ webidl.brandCheck(this, File8);
4643
4643
  return this[kState].type;
4644
4644
  }
4645
4645
  };
4646
- __name(File7, "File");
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(File7.prototype, {
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 File7 || object && (typeof object.stream === "function" || typeof object.arrayBuffer === "function") && object[Symbol.toStringTag] === "File";
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: File7, FileLike, isFileLike };
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 File7 = NativeFile ?? UndiciFile;
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 File7([value], "blob", { type: value.type }) : new FileLike(value, "blob", { type: value.type });
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 File7([value], filename, options30) : new FileLike(value, filename, options30);
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 File7 = NativeFile ?? UndiciFile;
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 File7(chunks, filename, { type: mimeType }));
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 File7(chunks, filename, { type: mimeType }));
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 Response10 = class {
11840
+ var Response11 = class {
11841
11841
  // Creates network error Response.
11842
11842
  static error() {
11843
11843
  const relevantRealm = { settingsObject: {} };
11844
- const responseObject = new Response10();
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 Response10();
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 Response10();
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, Response10);
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, Response10);
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, Response10);
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, Response10);
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, Response10);
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, Response10);
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, Response10);
11952
+ webidl.brandCheck(this, Response11);
11953
11953
  return this[kHeaders];
11954
11954
  }
11955
11955
  get body() {
11956
- webidl.brandCheck(this, Response10);
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, Response10);
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, Response10);
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 Response10();
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(Response10, "Response");
11983
- mixinBody(Response10);
11984
- Object.defineProperties(Response10.prototype, {
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(Response10, {
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: Response10,
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: Response10,
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 Response10();
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: Response10, cloneResponse } = require_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 Response10(response.body?.source ?? null);
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(Response10);
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: () => Response10,
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 Response10 = /* @__PURE__ */ __name(class extends Body {
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 Response10(res.body, res);
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 Response10(res.body, res);
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 Response10) {
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(Response10.prototype, this, enumerableResponseKeys);
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 Response10(innerClone.body, innerClone);
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 Response10 ? res : new Response10(res.body, res);
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 Response10)
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 Response10(nullBodyStatus.includes(baseRes.status) ? null : baseRes.body, baseRes);
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 Response10 || res instanceof import_undici32.Response;
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 Response10(null, {
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 Response10(responseBody, {
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 Response10(responseBody.slice(start, end + 1), {
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 Response10(stream2, {
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 import_buffer5 = __toModule(require("buffer"));
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 = Response10;
73787
+ let CompatResponse = Response11;
73788
73788
  if (!ctx.compat.isEnabled("formdata_parser_supports_files")) {
73789
73789
  CompatRequest = proxyStringFormDataFiles(Request4);
73790
- CompatResponse = proxyStringFormDataFiles(Response10);
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: import_buffer5.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 import_miniflare17.Request(url4, miniflareRequest);
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, import_miniflare17.fetch)(proxyRequest, {
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 import_miniflare17.Response(`[wrangler] Could not proxy request: ${thrown}`, {
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 import_miniflare17.Response(
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 import_miniflare17.Request(input, init2);
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, import_miniflare17, import_undici8, ProxyDispatcher, invalidAssetsFetch;
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
- import_miniflare17 = require("miniflare");
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 import_buffer, fromArrayBuffer, fromString;
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
- import_buffer = require("buffer");
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 import_buffer.Buffer.from(input, offset, length);
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 ? import_buffer.Buffer.from(input, encoding) : import_buffer.Buffer.from(input);
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(import_buffer3.Buffer.concat(chunks));
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 import_buffer3, import_http2;
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
- import_buffer3 = require("buffer");
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 (import_buffer4.Buffer.isBuffer(toCast)) {
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 import_buffer4, import_crypto5, Hash;
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
- import_buffer4 = require("buffer");
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 import_miniflare7 = require("miniflare");
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 import_miniflare5 = require("miniflare");
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.105.1";
98111
+ var version = "3.107.0";
98112
98112
 
98113
98113
  // src/environment-variables/misc-variables.ts
98114
98114
  init_import_meta_url();
@@ -98229,22 +98229,24 @@ var getRegistryPath = getEnvironmentVariableFactory({
98229
98229
  // src/errors.ts
98230
98230
  init_import_meta_url();
98231
98231
  var UserError = class extends Error {
98232
- constructor(...args) {
98233
- super(...args);
98232
+ telemetryMessage;
98233
+ constructor(message, options30) {
98234
+ super(message, options30);
98234
98235
  Object.setPrototypeOf(this, new.target.prototype);
98236
+ this.telemetryMessage = options30?.telemetryMessage === true ? message : options30?.telemetryMessage;
98235
98237
  }
98236
98238
  };
98237
98239
  __name(UserError, "UserError");
98238
98240
  var DeprecationError = class extends UserError {
98239
- constructor(message) {
98241
+ constructor(message, options30) {
98240
98242
  super(`Deprecation:
98241
- ${message}`);
98243
+ ${message}`, options30);
98242
98244
  }
98243
98245
  };
98244
98246
  __name(DeprecationError, "DeprecationError");
98245
98247
  var FatalError = class extends UserError {
98246
- constructor(message, code) {
98247
- super(message);
98248
+ constructor(message, code, options30) {
98249
+ super(message, options30);
98248
98250
  this.code = code;
98249
98251
  }
98250
98252
  };
@@ -98253,23 +98255,29 @@ var CommandLineArgsError = class extends UserError {
98253
98255
  };
98254
98256
  __name(CommandLineArgsError, "CommandLineArgsError");
98255
98257
  var JsonFriendlyFatalError = class extends FatalError {
98256
- constructor(message, code) {
98257
- super(message);
98258
+ constructor(message, code, options30) {
98259
+ super(message, code, options30);
98258
98260
  this.code = code;
98259
98261
  }
98260
98262
  };
98261
98263
  __name(JsonFriendlyFatalError, "JsonFriendlyFatalError");
98262
98264
  var MissingConfigError = class extends Error {
98265
+ telemetryMessage;
98263
98266
  constructor(key) {
98264
98267
  super(`Missing config value for ${key}`);
98268
+ this.telemetryMessage = `Missing config value for ${key}`;
98265
98269
  }
98266
98270
  };
98267
98271
  __name(MissingConfigError, "MissingConfigError");
98268
- function createFatalError(message, isJson, code) {
98272
+ function createFatalError(message, isJson, code, telemetryMessage) {
98269
98273
  if (isJson) {
98270
- return new JsonFriendlyFatalError(JSON.stringify(message), code);
98274
+ return new JsonFriendlyFatalError(
98275
+ JSON.stringify(message),
98276
+ code,
98277
+ telemetryMessage
98278
+ );
98271
98279
  } else {
98272
- return new FatalError(`${message}`, code);
98280
+ return new FatalError(`${message}`, code, telemetryMessage);
98273
98281
  }
98274
98282
  }
98275
98283
  __name(createFatalError, "createFatalError");
@@ -99959,8 +99967,8 @@ var ParseError = class extends UserError {
99959
99967
  notes;
99960
99968
  location;
99961
99969
  kind;
99962
- constructor({ text, notes, location, kind }) {
99963
- super(text);
99970
+ constructor({ text, notes, location, kind, telemetryMessage }) {
99971
+ super(text, { telemetryMessage });
99964
99972
  this.name = this.constructor.name;
99965
99973
  this.text = text;
99966
99974
  this.notes = notes ?? [];
@@ -100017,43 +100025,37 @@ function parseTOML(input, file) {
100017
100025
  file,
100018
100026
  fileText: input
100019
100027
  };
100020
- throw new ParseError({ text, location });
100028
+ throw new ParseError({
100029
+ text,
100030
+ location,
100031
+ telemetryMessage: "TOML parse error"
100032
+ });
100021
100033
  }
100022
100034
  }
100023
100035
  __name(parseTOML, "parseTOML");
100024
- var JSON_ERROR_SUFFIX = " in JSON at position ";
100025
100036
  function parsePackageJSON(input, file) {
100026
100037
  return parseJSON(input, file);
100027
100038
  }
100028
100039
  __name(parsePackageJSON, "parsePackageJSON");
100029
100040
  function parseJSON(input, file) {
100030
- try {
100031
- return JSON.parse(input);
100032
- } catch (err) {
100033
- const { message } = err;
100034
- const index = message.lastIndexOf(JSON_ERROR_SUFFIX);
100035
- if (index < 0) {
100036
- throw err;
100037
- }
100038
- const text = message.substring(0, index);
100039
- const position = parseInt(
100040
- message.substring(index + JSON_ERROR_SUFFIX.length)
100041
- );
100042
- const location = indexLocation({ file, fileText: input }, position);
100043
- throw new ParseError({ text, location });
100044
- }
100041
+ return parseJSONC(input, file, {
100042
+ allowEmptyContent: false,
100043
+ allowTrailingComma: false,
100044
+ disallowComments: true
100045
+ });
100045
100046
  }
100046
100047
  __name(parseJSON, "parseJSON");
100047
- function parseJSONC(input, file) {
100048
+ function parseJSONC(input, file, options30 = { allowTrailingComma: true }) {
100048
100049
  const errors = [];
100049
- const data = parse2(input, errors, { allowTrailingComma: true });
100050
+ const data = parse2(input, errors, options30);
100050
100051
  if (errors.length) {
100051
100052
  throw new ParseError({
100052
100053
  text: printParseErrorCode(errors[0].error),
100053
100054
  location: {
100054
100055
  ...indexLocation({ file, fileText: input }, errors[0].offset + 1),
100055
100056
  length: errors[0].length
100056
- }
100057
+ },
100058
+ telemetryMessage: "JSON(C) parse error"
100057
100059
  });
100058
100060
  }
100059
100061
  return data;
@@ -100086,7 +100088,8 @@ function readFileSync5(file) {
100086
100088
  {
100087
100089
  text: message.replace(file, (0, import_node_path4.resolve)(file))
100088
100090
  }
100089
- ]
100091
+ ],
100092
+ telemetryMessage: "Could not read file"
100090
100093
  });
100091
100094
  }
100092
100095
  }
@@ -100773,10 +100776,7 @@ function findRedirectedWranglerConfig(cwd2, userConfigPath) {
100773
100776
  let redirectedConfigPath;
100774
100777
  const deployConfigFile = readFileSync5(deployConfigPath);
100775
100778
  try {
100776
- const deployConfig = parseJSONC(
100777
- deployConfigFile,
100778
- deployConfigPath
100779
- );
100779
+ const deployConfig = parseJSONC(deployConfigFile, deployConfigPath);
100780
100780
  redirectedConfigPath = deployConfig.configPath && import_node_path7.default.resolve(import_node_path7.default.dirname(deployConfigPath), deployConfig.configPath);
100781
100781
  } catch (e7) {
100782
100782
  throw new UserError(
@@ -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: inheritable(
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
- validateBrowserBinding(envName),
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 validateBrowserBinding = /* @__PURE__ */ __name((envName) => (diagnostics, field, value, config) => {
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
- }, "validateBrowserBinding");
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 */
@@ -106852,7 +106894,9 @@ init_import_meta_url();
106852
106894
  var import_prompts = __toESM(require_prompts3());
106853
106895
  var NoDefaultValueProvided = class extends UserError {
106854
106896
  constructor() {
106855
- super("This command cannot be run in a non-interactive context");
106897
+ super("This command cannot be run in a non-interactive context", {
106898
+ telemetryMessage: true
106899
+ });
106856
106900
  Object.setPrototypeOf(this, new.target.prototype);
106857
106901
  }
106858
106902
  };
@@ -108587,7 +108631,9 @@ async function matchFiles(files, relativeTo, { rules, removedRules }) {
108587
108631
  continue;
108588
108632
  }
108589
108633
  const absoluteFilePath = import_node_path12.default.join(relativeTo, filePath);
108590
- const fileContent = await (0, import_promises3.readFile)(absoluteFilePath);
108634
+ const fileContent = await (0, import_promises3.readFile)(
108635
+ absoluteFilePath
108636
+ );
108591
108637
  const module3 = {
108592
108638
  name: filePath,
108593
108639
  content: fileContent,
@@ -108753,7 +108799,9 @@ function createModuleCollector(props) {
108753
108799
  props.wrangler1xLegacyModuleReferences.rootDirectory,
108754
108800
  args.path
108755
108801
  );
108756
- const fileContent = await (0, import_promises4.readFile)(filePath);
108802
+ const fileContent = await (0, import_promises4.readFile)(
108803
+ filePath
108804
+ );
108757
108805
  const fileHash = import_node_crypto3.default.createHash("sha1").update(fileContent).digest("hex");
108758
108806
  const fileName = props.preserveFileNames ? args.path : `./${fileHash}-${import_node_path13.default.basename(args.path)}`;
108759
108807
  const { rule } = rulesMatchers.find(({ regex: regex2 }) => regex2.test(fileName)) || {};
@@ -108816,7 +108864,9 @@ function createModuleCollector(props) {
108816
108864
  filePath = resolved;
108817
108865
  } catch (e7) {
108818
108866
  }
108819
- const fileContent = await (0, import_promises4.readFile)(filePath);
108867
+ const fileContent = await (0, import_promises4.readFile)(
108868
+ filePath
108869
+ );
108820
108870
  const fileHash = import_node_crypto3.default.createHash("sha1").update(fileContent).digest("hex");
108821
108871
  const fileName = props.preserveFileNames ? args.path : `./${fileHash}-${import_node_path13.default.basename(args.path)}`;
108822
108872
  modules.push({
@@ -108913,12 +108963,218 @@ function withSourceURLs(entrypointPath, entrypointSource, modules) {
108913
108963
  }
108914
108964
  __name(withSourceURLs, "withSourceURLs");
108915
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
+
108916
109172
  // src/sourcemap.ts
108917
109173
  init_import_meta_url();
108918
109174
  var import_node_assert4 = __toESM(require("node:assert"));
108919
109175
  var import_node_fs8 = __toESM(require("node:fs"));
108920
109176
  var import_node_url5 = __toESM(require("node:url"));
108921
- var import_miniflare3 = require("miniflare");
109177
+ var import_miniflare4 = require("miniflare");
108922
109178
  function maybeGetFile(filePath) {
108923
109179
  try {
108924
109180
  return import_node_fs8.default.readFileSync(filePath, "utf8");
@@ -108966,7 +109222,7 @@ function getSourceMappingPrepareStackTrace(retrieveSourceMap) {
108966
109222
  if (sourceMappingPrepareStackTrace !== void 0) {
108967
109223
  return sourceMappingPrepareStackTrace;
108968
109224
  }
108969
- const support = (0, import_miniflare3.getFreshSourceMapSupport)();
109225
+ const support = (0, import_miniflare4.getFreshSourceMapSupport)();
108970
109226
  const originalPrepareStackTrace = Error.prepareStackTrace;
108971
109227
  support.install({
108972
109228
  environment: "node",
@@ -109173,7 +109429,7 @@ __name(updateCheck, "updateCheck");
109173
109429
 
109174
109430
  // src/vectorize/fetcher.ts
109175
109431
  init_import_meta_url();
109176
- var import_miniflare4 = require("miniflare");
109432
+ var import_miniflare5 = require("miniflare");
109177
109433
  var EXTERNAL_VECTORIZE_WORKER_NAME = "__WRANGLER_EXTERNAL_VECTORIZE_WORKER";
109178
109434
  var EXTERNAL_VECTORIZE_WORKER_SCRIPT = `
109179
109435
  import makeBinding from 'cloudflare-internal:vectorize-api'
@@ -109206,7 +109462,7 @@ function MakeVectorizeFetcher(indexId) {
109206
109462
  body: request4.body,
109207
109463
  duplex: "half"
109208
109464
  });
109209
- const respHeaders = new import_miniflare4.Headers(res.headers);
109465
+ const respHeaders = new import_miniflare5.Headers(res.headers);
109210
109466
  respHeaders.delete("Host");
109211
109467
  respHeaders.delete("Content-Length");
109212
109468
  const apiResponse = await res.json();
@@ -109214,7 +109470,7 @@ function MakeVectorizeFetcher(indexId) {
109214
109470
  error: apiResponse.errors[0].message,
109215
109471
  code: apiResponse.errors[0].code
109216
109472
  };
109217
- return new import_miniflare4.Response(JSON.stringify(newResponse), {
109473
+ return new import_miniflare5.Response(JSON.stringify(newResponse), {
109218
109474
  status: res.status,
109219
109475
  headers: respHeaders
109220
109476
  });
@@ -109372,7 +109628,7 @@ export default {
109372
109628
  }
109373
109629
  }
109374
109630
  `;
109375
- var WranglerLog = class extends import_miniflare5.Log {
109631
+ var WranglerLog = class extends import_miniflare6.Log {
109376
109632
  #warnedCompatibilityDateFallback = false;
109377
109633
  log(message) {
109378
109634
  if (message.includes(EXTERNAL_SERVICE_WORKER_NAME)) {
@@ -109417,13 +109673,13 @@ function castLogLevel(level) {
109417
109673
  if (key === "LOG") {
109418
109674
  key = "INFO";
109419
109675
  }
109420
- return import_miniflare5.LogLevel[key];
109676
+ return import_miniflare6.LogLevel[key];
109421
109677
  }
109422
109678
  __name(castLogLevel, "castLogLevel");
109423
109679
  function buildLog() {
109424
109680
  let level = castLogLevel(logger.loggerLevel);
109425
- if (level <= import_miniflare5.LogLevel.DEBUG) {
109426
- level = Math.min(level, import_miniflare5.LogLevel.WARN);
109681
+ if (level <= import_miniflare6.LogLevel.DEBUG) {
109682
+ level = Math.min(level, import_miniflare6.LogLevel.WARN);
109427
109683
  }
109428
109684
  return new WranglerLog(level, { prefix: "wrangler-UserWorker" });
109429
109685
  }
@@ -109563,7 +109819,7 @@ function buildMiniflareBindingOptions(config) {
109563
109819
  };
109564
109820
  } else {
109565
109821
  let address;
109566
- let style = import_miniflare5.HttpOptions_Style.PROXY;
109822
+ let style = import_miniflare6.HttpOptions_Style.PROXY;
109567
109823
  if (service.entrypoint !== void 0) {
109568
109824
  if (target.entrypointAddresses === void 0) {
109569
109825
  throw new UserError(
@@ -109586,7 +109842,7 @@ function buildMiniflareBindingOptions(config) {
109586
109842
  );
109587
109843
  }
109588
109844
  address = `${target.host}:${target.port}`;
109589
- style = import_miniflare5.HttpOptions_Style.HOST;
109845
+ style = import_miniflare6.HttpOptions_Style.HOST;
109590
109846
  } else {
109591
109847
  address = `${defaultEntrypointAddress.host}:${defaultEntrypointAddress.port}`;
109592
109848
  }
@@ -109596,7 +109852,7 @@ function buildMiniflareBindingOptions(config) {
109596
109852
  address,
109597
109853
  http: {
109598
109854
  style,
109599
- cfBlobHeader: import_miniflare5.CoreHeaders.CF_BLOB
109855
+ cfBlobHeader: import_miniflare6.CoreHeaders.CF_BLOB
109600
109856
  }
109601
109857
  }
109602
109858
  };
@@ -109679,6 +109935,24 @@ function buildMiniflareBindingOptions(config) {
109679
109935
  scriptName: EXTERNAL_AI_WORKER_NAME
109680
109936
  };
109681
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
+ }
109682
109956
  if (bindings.vectorize) {
109683
109957
  for (const vectorizeBinding of bindings.vectorize) {
109684
109958
  const bindingName = vectorizeBinding.binding;
@@ -109893,6 +110167,7 @@ __name(handleRuntimeStdio, "handleRuntimeStdio");
109893
110167
  var didWarnMiniflareCronSupport = false;
109894
110168
  var didWarnMiniflareVectorizeSupport = false;
109895
110169
  var didWarnAiAccountUsage = false;
110170
+ var didWarnImagesLocalModeUsage = false;
109896
110171
  async function buildMiniflareOptions(log2, config, proxyToUserWorkerAuthenticationSecret) {
109897
110172
  if (config.crons.length > 0 && !config.testScheduled) {
109898
110173
  if (!didWarnMiniflareCronSupport) {
@@ -109924,6 +110199,14 @@ async function buildMiniflareOptions(log2, config, proxyToUserWorkerAuthenticati
109924
110199
  );
109925
110200
  }
109926
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
+ }
109927
110210
  const upstream = typeof config.localUpstream === "string" ? `${config.upstreamProtocol}://${config.localUpstream}` : void 0;
109928
110211
  const { sourceOptions, entrypointNames } = await buildSourceOptions(config);
109929
110212
  const { bindingOptions, internalObjects, externalWorkers } = buildMiniflareBindingOptions(config);
@@ -109986,7 +110269,7 @@ __name(castErrorCause, "castErrorCause");
109986
110269
  init_import_meta_url();
109987
110270
  var import_node_crypto5 = require("node:crypto");
109988
110271
  var import_promises6 = require("node:fs/promises");
109989
- var import_miniflare6 = require("miniflare");
110272
+ var import_miniflare7 = require("miniflare");
109990
110273
 
109991
110274
  // src/api/startDevWorker/BaseController.ts
109992
110275
  init_import_meta_url();
@@ -110165,6 +110448,11 @@ function convertCfWorkerInitBindingstoBindings(inputBindings) {
110165
110448
  output[binding] = { type: "ai", ...x6 };
110166
110449
  break;
110167
110450
  }
110451
+ case "images": {
110452
+ const { binding, ...x6 } = info;
110453
+ output[binding] = { type: "images", ...x6 };
110454
+ break;
110455
+ }
110168
110456
  case "version_metadata": {
110169
110457
  const { binding, ...x6 } = info;
110170
110458
  output[binding] = { type: "version_metadata", ...x6 };
@@ -110215,6 +110503,7 @@ async function convertBindingsToCfWorkerInitBindings(inputBindings) {
110215
110503
  text_blobs: void 0,
110216
110504
  browser: void 0,
110217
110505
  ai: void 0,
110506
+ images: void 0,
110218
110507
  version_metadata: void 0,
110219
110508
  data_blobs: void 0,
110220
110509
  durable_objects: void 0,
@@ -110266,6 +110555,8 @@ async function convertBindingsToCfWorkerInitBindings(inputBindings) {
110266
110555
  bindings.browser = { binding: name2 };
110267
110556
  } else if (binding.type === "ai") {
110268
110557
  bindings.ai = { binding: name2 };
110558
+ } else if (binding.type === "images") {
110559
+ bindings.images = { binding: name2 };
110269
110560
  } else if (binding.type === "version_metadata") {
110270
110561
  bindings.version_metadata = { binding: name2 };
110271
110562
  } else if (binding.type === "durable_object_namespace") {
@@ -110437,6 +110728,7 @@ async function convertToConfigBundle(event) {
110437
110728
  services: bindings.services,
110438
110729
  serviceBindings: fetchers,
110439
110730
  bindVectorizeToProd: event.config.dev?.bindVectorizeToProd ?? false,
110731
+ imagesLocalMode: event.config.dev?.imagesLocalMode ?? false,
110440
110732
  testScheduled: !!event.config.dev.testScheduled
110441
110733
  };
110442
110734
  }
@@ -110454,7 +110746,7 @@ var LocalRuntimeController = class extends RuntimeController {
110454
110746
  // `buildMiniflareOptions()` is asynchronous, meaning if multiple bundle
110455
110747
  // updates were submitted, the second may apply before the first. Therefore,
110456
110748
  // wrap updates in a mutex, so they're always applied in invocation order.
110457
- #mutex = new import_miniflare6.Mutex();
110749
+ #mutex = new import_miniflare7.Mutex();
110458
110750
  #mf;
110459
110751
  onBundleStart(_4) {
110460
110752
  }
@@ -110468,7 +110760,7 @@ var LocalRuntimeController = class extends RuntimeController {
110468
110760
  options30.liveReload = false;
110469
110761
  if (this.#mf === void 0) {
110470
110762
  logger.log(source_default.dim("\u2394 Starting local server..."));
110471
- this.#mf = new import_miniflare6.Miniflare(options30);
110763
+ this.#mf = new import_miniflare7.Miniflare(options30);
110472
110764
  } else {
110473
110765
  logger.log(source_default.dim("\u2394 Reloading local server..."));
110474
110766
  await this.#mf.setOptions(options30);
@@ -110605,7 +110897,7 @@ var MultiworkerRuntimeController = class extends LocalRuntimeController {
110605
110897
  // `buildMiniflareOptions()` is asynchronous, meaning if multiple bundle
110606
110898
  // updates were submitted, the second may apply before the first. Therefore,
110607
110899
  // wrap updates in a mutex, so they're always applied in invocation order.
110608
- #mutex = new import_miniflare7.Mutex();
110900
+ #mutex = new import_miniflare8.Mutex();
110609
110901
  #mf;
110610
110902
  #options = /* @__PURE__ */ new Map();
110611
110903
  #canStartMiniflare() {
@@ -110643,7 +110935,7 @@ var MultiworkerRuntimeController = class extends LocalRuntimeController {
110643
110935
  const mergedMfOptions = ensureMatchingSql(this.#mergedMfOptions());
110644
110936
  if (this.#mf === void 0) {
110645
110937
  logger.log(source_default.dim("\u2394 Starting local server..."));
110646
- this.#mf = new import_miniflare7.Miniflare(mergedMfOptions);
110938
+ this.#mf = new import_miniflare8.Miniflare(mergedMfOptions);
110647
110939
  } else {
110648
110940
  logger.log(source_default.dim("\u2394 Reloading local server..."));
110649
110941
  await this.#mf.setOptions(mergedMfOptions);
@@ -110741,7 +111033,7 @@ var import_node_assert9 = __toESM(require("node:assert"));
110741
111033
  var import_node_crypto7 = require("node:crypto");
110742
111034
  var import_node_events2 = __toESM(require("node:events"));
110743
111035
  var import_node_path18 = __toESM(require("node:path"));
110744
- var import_miniflare9 = require("miniflare");
111036
+ var import_miniflare10 = require("miniflare");
110745
111037
 
110746
111038
  // embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/wrangler/templates/startDevWorker/InspectorProxyWorker.ts
110747
111039
  init_import_meta_url();
@@ -111052,7 +111344,7 @@ var openInspector = /* @__PURE__ */ __name(async (inspectorPort, worker) => {
111052
111344
  init_import_meta_url();
111053
111345
  var fs9 = __toESM(require("node:fs"));
111054
111346
  var path20 = __toESM(require("node:path"));
111055
- var import_miniflare8 = require("miniflare");
111347
+ var import_miniflare9 = require("miniflare");
111056
111348
  var CERT_EXPIRY_DAYS = 30;
111057
111349
  var ONE_DAY_IN_MS = 864e5;
111058
111350
  var getHttpsKeyPathFromEnv = getEnvironmentVariableFactory({
@@ -111152,7 +111444,7 @@ function generateCertificate() {
111152
111444
  name: "subjectAltName",
111153
111445
  altNames: [
111154
111446
  { type: 2, value: "localhost" },
111155
- ...(0, import_miniflare8.getAccessibleHosts)(false).map((ip) => ({ type: 7, ip }))
111447
+ ...(0, import_miniflare9.getAccessibleHosts)(false).map((ip) => ({ type: 7, ip }))
111156
111448
  ]
111157
111449
  }
111158
111450
  ]
@@ -111203,7 +111495,7 @@ var ProxyController = class extends Controller {
111203
111495
  PROXY_CONTROLLER: async (req) => {
111204
111496
  const message = await req.json();
111205
111497
  this.onProxyWorkerMessage(message);
111206
- return new import_miniflare9.Response(null, { status: 204 });
111498
+ return new import_miniflare10.Response(null, { status: 204 });
111207
111499
  }
111208
111500
  },
111209
111501
  bindings: {
@@ -111264,7 +111556,7 @@ var ProxyController = class extends Controller {
111264
111556
  proxyWorkerOptions
111265
111557
  );
111266
111558
  const willInstantiateMiniflareInstance = !this.proxyWorker || proxyWorkerOptionsChanged;
111267
- this.proxyWorker ??= new import_miniflare9.Miniflare(proxyWorkerOptions);
111559
+ this.proxyWorker ??= new import_miniflare10.Miniflare(proxyWorkerOptions);
111268
111560
  this.proxyWorkerOptions = proxyWorkerOptions;
111269
111561
  if (proxyWorkerOptionsChanged) {
111270
111562
  logger.debug("ProxyWorker miniflare options changed, reinstantiating...");
@@ -111346,7 +111638,7 @@ var ProxyController = class extends Controller {
111346
111638
  this.inspectorProxyWorkerWebSocket?.resolve(webSocket);
111347
111639
  return webSocket;
111348
111640
  }
111349
- runtimeMessageMutex = new import_miniflare9.Mutex();
111641
+ runtimeMessageMutex = new import_miniflare10.Mutex();
111350
111642
  async sendMessageToProxyWorker(message, retries = 3) {
111351
111643
  if (this._torndown) {
111352
111644
  return;
@@ -111499,15 +111791,15 @@ var ProxyController = class extends Controller {
111499
111791
  );
111500
111792
  }
111501
111793
  if (maybeContents === void 0) {
111502
- return new import_miniflare9.Response(null, { status: 404 });
111794
+ return new import_miniflare10.Response(null, { status: 404 });
111503
111795
  }
111504
- return new import_miniflare9.Response(maybeContents);
111796
+ return new import_miniflare10.Response(maybeContents);
111505
111797
  }
111506
111798
  default:
111507
111799
  assertNever(message);
111508
- return new import_miniflare9.Response(null, { status: 404 });
111800
+ return new import_miniflare10.Response(null, { status: 404 });
111509
111801
  }
111510
- return new import_miniflare9.Response(null, { status: 204 });
111802
+ return new import_miniflare10.Response(null, { status: 204 });
111511
111803
  }
111512
111804
  _torndown = false;
111513
111805
  async teardown() {
@@ -111560,7 +111852,7 @@ var ProxyController = class extends Controller {
111560
111852
  __name(ProxyController, "ProxyController");
111561
111853
  var ProxyControllerLogger = class extends WranglerLog {
111562
111854
  log(message) {
111563
- if (message.includes("/cdn-cgi/") && this.level < import_miniflare9.LogLevel.DEBUG) {
111855
+ if (message.includes("/cdn-cgi/") && this.level < import_miniflare10.LogLevel.DEBUG) {
111564
111856
  return;
111565
111857
  }
111566
111858
  super.log(message);
@@ -115407,7 +115699,8 @@ var AssetConfigSchema = z2.object({
115407
115699
  "none"
115408
115700
  ]).optional(),
115409
115701
  not_found_handling: z2.enum(["single-page-application", "404-page", "none"]).optional(),
115410
- serve_directly: z2.boolean().optional()
115702
+ serve_directly: z2.boolean().optional(),
115703
+ run_worker_first: z2.boolean().optional()
115411
115704
  });
115412
115705
  var InternalConfigSchema = z2.object({
115413
115706
  // Used for analytics and reporting
@@ -116154,8 +116447,7 @@ var Handler2 = withConfig(
116154
116447
  }
116155
116448
  }
116156
116449
  );
116157
- var listDatabases = /* @__PURE__ */ __name(async (accountId, limitCalls = false) => {
116158
- const pageSize = 10;
116450
+ var listDatabases = /* @__PURE__ */ __name(async (accountId, limitCalls = false, pageSize = 10) => {
116159
116451
  let page = 1;
116160
116452
  const results = [];
116161
116453
  while (results.length % pageSize === 0) {
@@ -116215,22 +116507,22 @@ var getDatabaseByNameOrBinding = /* @__PURE__ */ __name(async (config, accountId
116215
116507
  }
116216
116508
  return matchingDB;
116217
116509
  }, "getDatabaseByNameOrBinding");
116218
- var getDatabaseInfoFromId = /* @__PURE__ */ __name(async (accountId, databaseId) => {
116510
+ var getDatabaseInfoFromIdOrName = /* @__PURE__ */ __name(async (accountId, databaseIdOrName) => {
116219
116511
  return await fetchResult(
116220
- `/accounts/${accountId}/d1/database/${databaseId}`,
116512
+ `/accounts/${accountId}/d1/database/${databaseIdOrName}`,
116221
116513
  {
116222
116514
  headers: {
116223
116515
  "Content-Type": "application/json"
116224
116516
  }
116225
116517
  }
116226
116518
  );
116227
- }, "getDatabaseInfoFromId");
116519
+ }, "getDatabaseInfoFromIdOrName");
116228
116520
 
116229
116521
  // src/kv/helpers.ts
116230
116522
  init_import_meta_url();
116231
116523
  var import_node_buffer = require("node:buffer");
116232
116524
  var import_node_url8 = require("node:url");
116233
- var import_miniflare11 = require("miniflare");
116525
+ var import_miniflare12 = require("miniflare");
116234
116526
  var import_undici4 = __toESM(require_undici());
116235
116527
 
116236
116528
  // src/dev/get-local-persistence-path.ts
@@ -116501,7 +116793,7 @@ __name(getKVNamespaceId, "getKVNamespaceId");
116501
116793
  async function usingLocalNamespace(persistTo, config, namespaceId, closure) {
116502
116794
  const persist = getLocalPersistencePath(persistTo, config);
116503
116795
  const persistOptions = buildPersistOptions(persist);
116504
- const mf = new import_miniflare11.Miniflare({
116796
+ const mf = new import_miniflare12.Miniflare({
116505
116797
  script: 'addEventListener("fetch", (e) => e.respondWith(new Response(null, { status: 404 })))',
116506
116798
  ...persistOptions,
116507
116799
  kvNamespaces: { NAMESPACE: namespaceId }
@@ -116519,7 +116811,7 @@ __name(usingLocalNamespace, "usingLocalNamespace");
116519
116811
  init_import_meta_url();
116520
116812
  var fs10 = __toESM(require("node:fs"));
116521
116813
  var import_web = require("node:stream/web");
116522
- var import_miniflare13 = require("miniflare");
116814
+ var import_miniflare14 = require("miniflare");
116523
116815
 
116524
116816
  // src/queues/client.ts
116525
116817
  init_import_meta_url();
@@ -116959,7 +117251,7 @@ __name(deleteR2Object, "deleteR2Object");
116959
117251
  async function usingLocalBucket(persistTo, config, bucketName, closure) {
116960
117252
  const persist = getLocalPersistencePath(persistTo, config);
116961
117253
  const persistOptions = buildPersistOptions(persist);
116962
- const mf = new import_miniflare13.Miniflare({
117254
+ const mf = new import_miniflare14.Miniflare({
116963
117255
  modules: true,
116964
117256
  // TODO(soon): import `reduceError()` from `miniflare:shared`
116965
117257
  script: `
@@ -117455,7 +117747,7 @@ async function deleteCORSPolicy(accountId, bucketName, jurisdiction) {
117455
117747
  }
117456
117748
  __name(deleteCORSPolicy, "deleteCORSPolicy");
117457
117749
  function isValidR2BucketName(name2) {
117458
- return typeof name2 === "string" && /^[a-zA-Z][a-zA-Z0-9-]*$/.test(name2);
117750
+ return typeof name2 === "string" && /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/.test(name2);
117459
117751
  }
117460
117752
  __name(isValidR2BucketName, "isValidR2BucketName");
117461
117753
  var CHUNK_SIZE = 1024;
@@ -117498,6 +117790,7 @@ function getBindings(config, options30) {
117498
117790
  wasm_modules: options30?.pages ? void 0 : config?.wasm_modules,
117499
117791
  browser: config?.browser,
117500
117792
  ai: config?.ai,
117793
+ images: config?.images,
117501
117794
  version_metadata: config?.version_metadata,
117502
117795
  text_blobs: options30?.pages ? void 0 : config?.text_blobs,
117503
117796
  data_blobs: options30?.pages ? void 0 : config?.data_blobs,
@@ -117525,144 +117818,264 @@ function getBindings(config, options30) {
117525
117818
  };
117526
117819
  }
117527
117820
  __name(getBindings, "getBindings");
117528
- async function provisionBindings(bindings, accountId, scriptName, autoCreate, config) {
117529
- const pendingResources = {
117530
- d1_databases: [],
117531
- r2_buckets: [],
117532
- kv_namespaces: []
117533
- };
117534
- let settings;
117535
- try {
117536
- settings = await getSettings(accountId, scriptName);
117537
- } catch (error2) {
117538
- logger.debug("No settings found");
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;
117539
117842
  }
117540
- for (const kv of bindings.kv_namespaces ?? []) {
117541
- if (!kv.id) {
117542
- if (inBindingSettings(settings, "kv_namespace", kv.binding)) {
117543
- kv.id = INHERIT_SYMBOL;
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();
117544
117854
  } else {
117545
- pendingResources.kv_namespaces?.push({
117546
- binding: kv.binding,
117547
- async create(title) {
117548
- const id = await createKVNamespace(accountId, title);
117549
- return id;
117550
- },
117551
- updateId(id) {
117552
- kv.id = id;
117855
+ const connected = await this.isConnectedToExistingResource();
117856
+ if (connected) {
117857
+ if (typeof connected === "string") {
117858
+ this.connect(connected);
117553
117859
  }
117554
- });
117860
+ return false;
117861
+ }
117862
+ return true;
117555
117863
  }
117556
117864
  }
117865
+ return false;
117557
117866
  }
117558
- for (const r22 of bindings.r2_buckets ?? []) {
117559
- (0, import_node_assert10.default)(typeof r22.bucket_name !== "symbol");
117560
- if (inBindingSettings(settings, "r2_bucket", r22.binding, {
117561
- bucket_name: r22.bucket_name
117562
- })) {
117563
- r22.bucket_name = INHERIT_SYMBOL;
117564
- } else {
117565
- if (r22.bucket_name) {
117566
- try {
117567
- await getR2Bucket(accountId, r22.bucket_name);
117568
- continue;
117569
- } catch (e7) {
117570
- if (!(e7 instanceof APIError && e7.code === 10006)) {
117571
- throw e7;
117572
- }
117573
- }
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;
117574
117905
  }
117575
- pendingResources.r2_buckets?.push({
117576
- binding: r22.binding,
117577
- name: r22.bucket_name,
117578
- async create(bucketName) {
117579
- await createR2Bucket(
117580
- accountId,
117581
- bucketName,
117582
- void 0,
117583
- // respect jurisdiction if it has been specified in the config, but don't prompt
117584
- r22.jurisdiction
117585
- );
117586
- return bucketName;
117587
- },
117588
- updateId(bucketName) {
117589
- r22.bucket_name = bucketName;
117590
- }
117591
- });
117906
+ return false;
117592
117907
  }
117593
117908
  }
117594
- for (const d12 of bindings.d1_databases ?? []) {
117595
- if (!d12.database_id) {
117596
- const maybeInherited = inBindingSettings(settings, "d1", d12.binding);
117597
- if (maybeInherited) {
117598
- if (!d12.database_name) {
117599
- d12.database_id = INHERIT_SYMBOL;
117600
- continue;
117601
- } else {
117602
- const dbFromId = await getDatabaseInfoFromId(
117603
- accountId,
117604
- maybeInherited.id
117605
- );
117606
- if (d12.database_name === dbFromId.name) {
117607
- d12.database_id = INHERIT_SYMBOL;
117608
- continue;
117609
- }
117610
- }
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
+ });
117611
118044
  }
117612
- pendingResources.d1_databases?.push({
117613
- binding: d12.binding,
117614
- name: d12.database_name,
117615
- async create(name2) {
117616
- const db = await createD1Database(accountId, name2);
117617
- return db.uuid;
117618
- },
117619
- updateId(id) {
117620
- d12.database_id = id;
117621
- }
117622
- });
117623
118045
  }
117624
118046
  }
117625
- if (Object.values(pendingResources).some((v7) => v7 && v7.length > 0)) {
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) {
117626
118059
  if (!isLegacyEnv(config)) {
117627
118060
  throw new UserError(
117628
118061
  "Provisioning resources is not supported with a service environment"
117629
118062
  );
117630
118063
  }
117631
118064
  logger.log();
117632
- printBindings(pendingResources, { provisioning: true });
117633
- logger.log();
117634
- if (pendingResources.kv_namespaces?.length) {
117635
- const preExistingKV = await listKVNamespaces(accountId, true);
117636
- await runProvisioningFlow(
117637
- pendingResources.kv_namespaces,
117638
- preExistingKV.map((ns) => ({ title: ns.title, value: ns.id })),
117639
- "KV Namespace",
117640
- "title or id",
117641
- scriptName,
117642
- autoCreate
117643
- );
117644
- }
117645
- if (pendingResources.d1_databases?.length) {
117646
- const preExisting = await listDatabases(accountId, true);
117647
- await runProvisioningFlow(
117648
- pendingResources.d1_databases,
117649
- preExisting.map((db) => ({ title: db.name, value: db.uuid })),
117650
- "D1 Database",
117651
- "name or id",
117652
- scriptName,
117653
- autoCreate
117654
- );
118065
+ const printable = {};
118066
+ for (const resource of pendingResources) {
118067
+ printable[resource.resourceType] ??= [];
118068
+ printable[resource.resourceType].push({ binding: resource.binding });
117655
118069
  }
117656
- if (pendingResources.r2_buckets?.length) {
117657
- const preExisting = await listR2Buckets(accountId);
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);
117658
118075
  await runProvisioningFlow(
117659
- pendingResources.r2_buckets,
117660
- preExisting.map((bucket) => ({
117661
- title: bucket.name,
117662
- value: bucket.name
117663
- })),
117664
- "R2 Bucket",
117665
- "name",
118076
+ resource,
118077
+ existingResources[resource.resourceType],
118078
+ HANDLERS[resource.resourceType].name,
117666
118079
  scriptName,
117667
118080
  autoCreate
117668
118081
  );
@@ -117672,21 +118085,6 @@ async function provisionBindings(bindings, accountId, scriptName, autoCreate, co
117672
118085
  }
117673
118086
  }
117674
118087
  __name(provisionBindings, "provisionBindings");
117675
- function inBindingSettings(settings, type, bindingName, other) {
117676
- return settings?.bindings.find(
117677
- (binding) => {
117678
- if (other) {
117679
- for (const [k6, v7] of Object.entries(other)) {
117680
- if (other[k6] !== v7) {
117681
- return false;
117682
- }
117683
- }
117684
- }
117685
- return binding.type === type && binding.name === bindingName;
117686
- }
117687
- );
117688
- }
117689
- __name(inBindingSettings, "inBindingSettings");
117690
118088
  function getSettings(accountId, scriptName) {
117691
118089
  return fetchResult(
117692
118090
  `/accounts/${accountId}/workers/scripts/${scriptName}/settings`
@@ -117695,103 +118093,75 @@ function getSettings(accountId, scriptName) {
117695
118093
  __name(getSettings, "getSettings");
117696
118094
  function printDivider() {
117697
118095
  logger.log();
117698
- logger.log(source_default.dim("--------------------------------------"));
117699
- logger.log();
117700
118096
  }
117701
118097
  __name(printDivider, "printDivider");
117702
- async function runProvisioningFlow(pending, preExisting, friendlyBindingName, resourceKeyDescriptor, scriptName, autoCreate) {
118098
+ async function runProvisioningFlow(item, preExisting, friendlyBindingName, scriptName, autoCreate) {
117703
118099
  const NEW_OPTION_VALUE = "__WRANGLER_INTERNAL_NEW";
117704
118100
  const SEARCH_OPTION_VALUE = "__WRANGLER_INTERNAL_SEARCH";
117705
118101
  const MAX_OPTIONS = 4;
117706
- if (pending.length) {
117707
- const options30 = preExisting.slice(0, MAX_OPTIONS - 1);
117708
- if (options30.length < preExisting.length) {
117709
- options30.push({
117710
- title: "Other (too many to list)",
117711
- value: SEARCH_OPTION_VALUE
117712
- });
117713
- }
117714
- for (const item of pending) {
117715
- logger.log("Provisioning", item.binding, `(${friendlyBindingName})...`);
117716
- let name2 = item.name;
117717
- let selected;
117718
- if (name2) {
117719
- logger.log("Resource name found in config:", name2);
117720
- const foundResourceId = preExisting.find(
117721
- (r7) => r7.title === name2
117722
- )?.value;
117723
- if (foundResourceId) {
117724
- logger.log("Existing resource found with that name.");
117725
- item.updateId(foundResourceId);
117726
- } else {
117727
- logger.log("No pre-existing resource found with that name");
117728
- logger.debug(
117729
- "If you have many resources, we may not have searched through them all. Please provide the id in that case. This is a temporary limitation."
117730
- );
117731
- const proceed = autoCreate ? true : await confirm(
117732
- `Would you like to create a new ${friendlyBindingName} named "${name2}"?`
117733
- );
117734
- if (!proceed) {
117735
- throw new UserError("Resource provisioning cancelled.");
117736
- }
117737
- logger.log(`\u{1F300} Creating new ${friendlyBindingName} "${name2}"...`);
117738
- const id = await item.create(name2);
117739
- 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
117740
118130
  }
117741
- } else {
117742
- if (options30.length === 0 || autoCreate) {
117743
- selected = NEW_OPTION_VALUE;
117744
- } else {
117745
- selected = await select(
117746
- `Would you like to connect an existing ${friendlyBindingName} or create a new one?`,
117747
- {
117748
- choices: options30.concat([
117749
- { title: "Create new", value: NEW_OPTION_VALUE }
117750
- ]),
117751
- defaultOption: options30.length
117752
- }
117753
- );
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
117754
118138
  }
117755
- if (selected === NEW_OPTION_VALUE) {
117756
- const defaultValue = `${scriptName}-${item.binding.toLowerCase().replace("_", "-")}`;
117757
- name2 = autoCreate ? defaultValue : await prompt(`Enter a name for your new ${friendlyBindingName}`, {
117758
- defaultValue
117759
- });
117760
- logger.log(`\u{1F300} Creating new ${friendlyBindingName} "${name2}"...`);
117761
- const id = await item.create(name2);
117762
- item.updateId(id);
117763
- } else if (selected === SEARCH_OPTION_VALUE) {
117764
- let foundResource;
117765
- while (foundResource === void 0) {
117766
- const input = await prompt(
117767
- `Enter the ${resourceKeyDescriptor} for an existing ${friendlyBindingName}`
117768
- );
117769
- foundResource = preExisting.find(
117770
- (r7) => r7.title === input || r7.value === input
117771
- );
117772
- if (foundResource) {
117773
- name2 = foundResource.title;
117774
- item.updateId(foundResource.value);
117775
- } else {
117776
- logger.log(
117777
- `No ${friendlyBindingName} with that ${resourceKeyDescriptor} "${input}" found. Please try again.`
117778
- );
117779
- }
117780
- }
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);
117781
118153
  } else {
117782
- const selectedResource = preExisting.find(
117783
- (r7) => r7.value === selected
118154
+ logger.log(
118155
+ `No ${friendlyBindingName} with that ${HANDLERS[item.resourceType].keyDescription} "${input}" found. Please try again.`
117784
118156
  );
117785
- if (selectedResource) {
117786
- name2 = selectedResource.title;
117787
- item.updateId(selected);
117788
- }
117789
118157
  }
117790
118158
  }
117791
- logger.log(`\u2728 ${item.binding} provisioned with ${name2}`);
117792
- printDivider();
118159
+ } else {
118160
+ item.handler.connect(action);
117793
118161
  }
117794
118162
  }
118163
+ logger.log(`\u2728 ${item.binding} provisioned \u{1F389}`);
118164
+ printDivider();
117795
118165
  }
117796
118166
  __name(runProvisioningFlow, "runProvisioningFlow");
117797
118167
 
@@ -118791,7 +119161,7 @@ init_import_meta_url();
118791
119161
  var import_node_buffer2 = require("node:buffer");
118792
119162
  var import_node_zlib = require("node:zlib");
118793
119163
  var ONE_KIB_BYTES = 1024;
118794
- var ALLOWED_INITIAL_MAX = ONE_KIB_BYTES * 1024;
119164
+ var MAX_GZIP_SIZE_BYTES = 3 * ONE_KIB_BYTES * ONE_KIB_BYTES;
118795
119165
  async function getSize(modules) {
118796
119166
  const gzipSize = (0, import_node_zlib.gzipSync)(
118797
119167
  await new import_node_buffer2.Blob(modules.map((file) => file.content)).arrayBuffer()
@@ -118803,7 +119173,7 @@ __name(getSize, "getSize");
118803
119173
  async function printBundleSize(main2, modules) {
118804
119174
  const { size, gzipSize } = await getSize([...modules, main2]);
118805
119175
  const bundleReport = `${(size / ONE_KIB_BYTES).toFixed(2)} KiB / gzip: ${(gzipSize / ONE_KIB_BYTES).toFixed(2)} KiB`;
118806
- const percentage = gzipSize / ALLOWED_INITIAL_MAX * 100;
119176
+ const percentage = gzipSize / MAX_GZIP_SIZE_BYTES * 100;
118807
119177
  const colorizedReport = percentage > 90 ? source_default.red(bundleReport) : percentage > 70 ? source_default.yellow(bundleReport) : source_default.green(bundleReport);
118808
119178
  logger.log(`Total Upload: ${colorizedReport}`);
118809
119179
  }
@@ -118924,10 +119294,16 @@ function createWorkerUploadForm(worker) {
118924
119294
  assets,
118925
119295
  observability
118926
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
+ }
118927
119303
  const assetConfig = {
118928
119304
  html_handling: assets?.assetConfig?.html_handling,
118929
119305
  not_found_handling: assets?.assetConfig?.not_found_handling,
118930
- serve_directly: assets?.assetConfig?.serve_directly
119306
+ run_worker_first: runWorkerFirst
118931
119307
  };
118932
119308
  if (assets && !assets.routingConfig.has_user_worker) {
118933
119309
  formData.set(
@@ -119148,6 +119524,12 @@ function createWorkerUploadForm(worker) {
119148
119524
  type: "ai"
119149
119525
  });
119150
119526
  }
119527
+ if (bindings.images !== void 0) {
119528
+ metadataBindings.push({
119529
+ name: bindings.images.binding,
119530
+ type: "images"
119531
+ });
119532
+ }
119151
119533
  if (bindings.version_metadata !== void 0) {
119152
119534
  metadataBindings.push({
119153
119535
  name: bindings.version_metadata.binding,
@@ -119359,7 +119741,7 @@ __name(logBuildOutput, "logBuildOutput");
119359
119741
 
119360
119742
  // src/deployment-bundle/node-compat.ts
119361
119743
  init_import_meta_url();
119362
- var import_miniflare15 = require("miniflare");
119744
+ var import_miniflare16 = require("miniflare");
119363
119745
  function validateNodeCompatMode(compatibilityDateStr = "2000-01-01", compatibilityFlags, {
119364
119746
  nodeCompat: legacy = false,
119365
119747
  noBundle = void 0
@@ -119370,7 +119752,7 @@ function validateNodeCompatMode(compatibilityDateStr = "2000-01-01", compatibili
119370
119752
  hasNodejsCompatFlag,
119371
119753
  hasNodejsCompatV2Flag,
119372
119754
  hasExperimentalNodejsCompatV2Flag
119373
- } = (0, import_miniflare15.getNodeCompat)(compatibilityDateStr, compatibilityFlags, {
119755
+ } = (0, import_miniflare16.getNodeCompat)(compatibilityDateStr, compatibilityFlags, {
119374
119756
  nodeCompat: legacy
119375
119757
  });
119376
119758
  if (hasExperimentalNodejsCompatV2Flag) {
@@ -120827,6 +121209,9 @@ ${dashLink}`);
120827
121209
  if (config.workflows?.length) {
120828
121210
  logger.once.warn("Workflows is currently in open beta.");
120829
121211
  for (const workflow of config.workflows) {
121212
+ if (workflow.script_name !== void 0 && workflow.script_name !== scriptName) {
121213
+ continue;
121214
+ }
120830
121215
  deployments.push(
120831
121216
  fetchResult(`/accounts/${accountId}/workflows/${workflow.name}`, {
120832
121217
  method: "PUT",
@@ -120867,7 +121252,11 @@ async function retryOnAPIFailure(action, backoff = 0, attempts = MAX_ATTEMPTS) {
120867
121252
  try {
120868
121253
  return await action();
120869
121254
  } catch (err) {
120870
- if (err instanceof APIError && !err.isRetryable() || !(err instanceof TypeError)) {
121255
+ if (err instanceof APIError) {
121256
+ if (!err.isRetryable()) {
121257
+ throw err;
121258
+ }
121259
+ } else if (!(err instanceof TypeError)) {
120871
121260
  throw err;
120872
121261
  }
120873
121262
  logger.info(source_default.dim(`Retrying API call after error...`));
@@ -121635,7 +122024,10 @@ var validateRoutes3 = /* @__PURE__ */ __name((routes, assets) => {
121635
122024
  `Paths are not allowed in Custom Domains`
121636
122025
  );
121637
122026
  }
121638
- } else if (assets?.directory !== void 0 && assets.assetConfig.serve_directly !== true) {
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
+ ) {
121639
122031
  const pattern = typeof route2 === "string" ? route2 : route2.pattern;
121640
122032
  const components = pattern.split("/");
121641
122033
  if (!(components.length === 2 && components[1] === "*")) {
@@ -122064,13 +122456,15 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
122064
122456
  printBindings({ ...withoutStaticAssets, vars: maskedVars });
122065
122457
  } else {
122066
122458
  (0, import_node_assert16.default)(accountId, "Missing accountId");
122067
- getFlag("RESOURCES_PROVISION") ? await provisionBindings(
122068
- bindings,
122069
- accountId,
122070
- scriptName,
122071
- props.experimentalAutoCreate,
122072
- props.config
122073
- ) : null;
122459
+ if (getFlag("RESOURCES_PROVISION")) {
122460
+ await provisionBindings(
122461
+ bindings,
122462
+ accountId,
122463
+ scriptName,
122464
+ props.experimentalAutoCreate,
122465
+ props.config
122466
+ );
122467
+ }
122074
122468
  await ensureQueuesExistByConfig(config);
122075
122469
  let bindingsPrinted = false;
122076
122470
  try {
@@ -122854,7 +123248,8 @@ var syncAssets = /* @__PURE__ */ __name(async (accountId, assetDirectory, script
122854
123248
  if (!initializeAssetsResponse.jwt) {
122855
123249
  throw new FatalError(
122856
123250
  "Could not find assets information to attach to deployment. Please try again.",
122857
- 1
123251
+ 1,
123252
+ { telemetryMessage: true }
122858
123253
  );
122859
123254
  }
122860
123255
  logger.info(`No files to upload. Proceeding with deployment...`);
@@ -122874,7 +123269,10 @@ var syncAssets = /* @__PURE__ */ __name(async (accountId, assetDirectory, script
122874
123269
  if (manifestEntry === void 0) {
122875
123270
  throw new FatalError(
122876
123271
  `A file was requested that does not appear to exist.`,
122877
- 1
123272
+ 1,
123273
+ {
123274
+ telemetryMessage: "A file was requested that does not appear to exist. (asset manifest upload)"
123275
+ }
122878
123276
  );
122879
123277
  }
122880
123278
  assetLogCount = logAssetUpload(`+ ${manifestEntry[0]}`, assetLogCount);
@@ -122945,7 +123343,9 @@ var syncAssets = /* @__PURE__ */ __name(async (accountId, assetDirectory, script
122945
123343
  throw new FatalError(
122946
123344
  `Upload took too long.
122947
123345
  Asset upload took too long on bucket ${bucketIndex + 1}/${initializeAssetsResponse.buckets.length}. Please try again.
122948
- Assets already uploaded have been saved, so the next attempt will automatically resume from this point.`
123346
+ Assets already uploaded have been saved, so the next attempt will automatically resume from this point.`,
123347
+ void 0,
123348
+ { telemetryMessage: "Asset upload took too long" }
122949
123349
  );
122950
123350
  } else {
122951
123351
  throw e7;
@@ -122966,7 +123366,8 @@ Assets already uploaded have been saved, so the next attempt will automatically
122966
123366
  if (!completionJwt) {
122967
123367
  throw new FatalError(
122968
123368
  "Failed to complete asset upload. Please try again.",
122969
- 1
123369
+ 1,
123370
+ { telemetryMessage: true }
122970
123371
  );
122971
123372
  }
122972
123373
  const uploadMs = Date.now() - start;
@@ -122999,7 +123400,8 @@ var buildAssetManifest = /* @__PURE__ */ __name(async (dir) => {
122999
123400
  throw new UserError(
123000
123401
  `Maximum number of assets exceeded.
123001
123402
  Cloudflare Workers supports up to ${MAX_ASSET_COUNT2.toLocaleString()} assets in a version. We found ${counter.toLocaleString()} files in the specified assets directory "${dir}".
123002
- Ensure your assets directory contains a maximum of ${MAX_ASSET_COUNT2.toLocaleString()} files, and that you have specified your assets directory correctly.`
123403
+ Ensure your assets directory contains a maximum of ${MAX_ASSET_COUNT2.toLocaleString()} files, and that you have specified your assets directory correctly.`,
123404
+ { telemetryMessage: "Maximum number of assets exceeded" }
123003
123405
  );
123004
123406
  }
123005
123407
  if (filestat.size > MAX_ASSET_SIZE2) {
@@ -123016,7 +123418,8 @@ Cloudflare Workers supports assets with sizes of up to ${prettyBytes(
123016
123418
  binary: true
123017
123419
  }
123018
123420
  )}.
123019
- Ensure all assets in your assets directory "${dir}" conform with the Workers maximum size requirement.`
123421
+ Ensure all assets in your assets directory "${dir}" conform with the Workers maximum size requirement.`,
123422
+ { telemetryMessage: "Asset too large" }
123020
123423
  );
123021
123424
  }
123022
123425
  manifest[normalizeFilePath(relativeFilepath)] = {
@@ -123055,11 +123458,14 @@ function getAssetsOptions(args, config) {
123055
123458
  const { directory, binding } = assets;
123056
123459
  if (directory === void 0) {
123057
123460
  throw new UserError(
123058
- "The `assets` property in your configuration is missing the required `directory` property."
123461
+ "The `assets` property in your configuration is missing the required `directory` property.",
123462
+ { telemetryMessage: true }
123059
123463
  );
123060
123464
  }
123061
123465
  if (directory === "") {
123062
- throw new UserError("`The assets directory cannot be an empty string.");
123466
+ throw new UserError("`The assets directory cannot be an empty string.", {
123467
+ telemetryMessage: true
123468
+ });
123063
123469
  }
123064
123470
  const assetsBasePath = getAssetsBasePath(config, args.assets);
123065
123471
  const resolvedAssetsPath = path32.resolve(assetsBasePath, directory);
@@ -123067,16 +123473,20 @@ function getAssetsOptions(args, config) {
123067
123473
  const sourceOfTruthMessage = args.assets ? '"--assets" command line argument' : '"assets.directory" field in your configuration file';
123068
123474
  throw new UserError(
123069
123475
  `The directory specified by the ${sourceOfTruthMessage} does not exist:
123070
- ${resolvedAssetsPath}`
123476
+ ${resolvedAssetsPath}`,
123477
+ {
123478
+ telemetryMessage: `The assets directory specified does not exist`
123479
+ }
123071
123480
  );
123072
123481
  }
123073
123482
  const routingConfig = {
123074
123483
  has_user_worker: Boolean(args.script || config.main),
123075
- invoke_user_worker_ahead_of_assets: !(config.assets?.experimental_serve_directly ?? true)
123484
+ invoke_user_worker_ahead_of_assets: config.assets?.run_worker_first || false
123076
123485
  };
123077
123486
  const assetConfig = {
123078
123487
  html_handling: config.assets?.html_handling,
123079
123488
  not_found_handling: config.assets?.not_found_handling,
123489
+ run_worker_first: config.assets?.run_worker_first,
123080
123490
  serve_directly: config.assets?.experimental_serve_directly
123081
123491
  };
123082
123492
  return {
@@ -123090,7 +123500,10 @@ __name(getAssetsOptions, "getAssetsOptions");
123090
123500
  function validateAssetsArgsAndConfig(args, config) {
123091
123501
  if ("legacy" in args ? args.assets && args.legacy.legacyAssets : (args.assets || config?.assets) && (args?.legacyAssets || config?.legacy_assets)) {
123092
123502
  throw new UserError(
123093
- "Cannot use assets and legacy assets in the same Worker.\nPlease remove either the `legacy_assets` or `assets` field from your configuration file."
123503
+ "Cannot use assets and legacy assets in the same Worker.\nPlease remove either the `legacy_assets` or `assets` field from your configuration file.",
123504
+ {
123505
+ telemetryMessage: "Cannot use assets and legacy assets in the same Worker"
123506
+ }
123094
123507
  );
123095
123508
  }
123096
123509
  if ("legacy" in args ? args.assets && args.legacy.site : (args.assets || config?.assets) && (args.site || config?.site)) {
@@ -123104,22 +123517,28 @@ function validateAssetsArgsAndConfig(args, config) {
123104
123517
  );
123105
123518
  if ("legacy" in args ? args.entrypoint === noOpEntrypoint && args.assets?.binding : !(args.script || config?.main) && config?.assets?.binding) {
123106
123519
  throw new UserError(
123107
- "Cannot use assets with a binding in an assets-only Worker.\nPlease remove the asset binding from your configuration file, or provide a Worker script in your configuration file (`main`)."
123520
+ "Cannot use assets with a binding in an assets-only Worker.\nPlease remove the asset binding from your configuration file, or provide a Worker script in your configuration file (`main`).",
123521
+ { telemetryMessage: true }
123108
123522
  );
123109
123523
  }
123110
- if (config?.placement?.mode === "smart" && config?.assets?.experimental_serve_directly === false) {
123524
+ if (config?.placement?.mode === "smart" && config?.assets?.run_worker_first === true) {
123111
123525
  logger.warn(
123112
- "Turning on Smart Placement in a Worker that is using assets and serve_directly set to false 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"
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."
123113
123532
  );
123114
123533
  }
123115
- if ("legacy" in args ? args.assets?.assetConfig?.serve_directly === false && !args.assets?.binding : config?.assets?.experimental_serve_directly === false && !config?.assets?.binding) {
123534
+ if ("legacy" in args ? args.assets?.assetConfig?.run_worker_first === true && !args.assets?.binding : config?.assets?.run_worker_first === true && !config?.assets?.binding) {
123116
123535
  logger.warn(
123117
- "experimental_serve_directly=false set without an assets binding\nSetting experimental_serve_directly to false 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"
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"
123118
123537
  );
123119
123538
  }
123120
- if ("legacy" in args ? args.entrypoint === noOpEntrypoint && args.assets?.assetConfig?.serve_directly === false : !config?.main && config?.assets?.experimental_serve_directly === false) {
123539
+ if ("legacy" in args ? args.entrypoint === noOpEntrypoint && args.assets?.assetConfig?.run_worker_first === true : !config?.main && config?.assets?.run_worker_first === true) {
123121
123540
  throw new UserError(
123122
- "Cannot set experimental_serve_directly=false without a Worker script.\nPlease remove experimental_serve_directly from your configuration file, or provide a Worker script in your configuration file (`main`)."
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`)."
123123
123542
  );
123124
123543
  }
123125
123544
  }
@@ -123139,12 +123558,15 @@ function errorOnLegacyPagesWorkerJSAsset(file, hasAssetsIgnoreFile) {
123139
123558
  if (!hasAssetsIgnoreFile) {
123140
123559
  const workerJsType = file === "_worker.js" ? "file" : file.startsWith("_worker.js") ? "directory" : null;
123141
123560
  if (workerJsType !== null) {
123142
- throw new UserError(dedent2`
123561
+ throw new UserError(
123562
+ dedent2`
123143
123563
  Uploading a Pages _worker.js ${workerJsType} as an asset.
123144
123564
  This could expose your private server-side code to the public Internet. Is this intended?
123145
123565
  If you do not want to upload this ${workerJsType}, either remove it or add an "${CF_ASSETS_IGNORE_FILENAME}" file, to the root of your asset directory, containing "_worker.js" to avoid uploading.
123146
123566
  If you do want to upload this ${workerJsType}, you can add an empty "${CF_ASSETS_IGNORE_FILENAME}" file, to the root of your asset directory, to hide this error.
123147
- `);
123567
+ `,
123568
+ { telemetryMessage: true }
123569
+ );
123148
123570
  }
123149
123571
  }
123150
123572
  }
@@ -123363,7 +123785,7 @@ init_import_meta_url();
123363
123785
  // src/cli-hotkeys.ts
123364
123786
  init_import_meta_url();
123365
123787
  var import_readline = __toESM(require("readline"));
123366
- var import_miniflare16 = require("miniflare");
123788
+ var import_miniflare17 = require("miniflare");
123367
123789
 
123368
123790
  // src/utils/onKeyPress.ts
123369
123791
  init_import_meta_url();
@@ -123457,16 +123879,16 @@ function cli_hotkeys_default(options30) {
123457
123879
  __name(printInstructions, "printInstructions");
123458
123880
  Logger.registerBeforeLogHook(clearPreviousInstructions);
123459
123881
  Logger.registerAfterLogHook(printInstructions);
123460
- import_miniflare16.Log.unstable_registerBeforeLogHook(clearPreviousInstructions);
123461
- import_miniflare16.Log.unstable_registerAfterLogHook(printInstructions);
123882
+ import_miniflare17.Log.unstable_registerBeforeLogHook(clearPreviousInstructions);
123883
+ import_miniflare17.Log.unstable_registerAfterLogHook(printInstructions);
123462
123884
  printInstructions();
123463
123885
  return () => {
123464
123886
  unregisterKeyPress();
123465
123887
  clearPreviousInstructions();
123466
123888
  Logger.registerBeforeLogHook(void 0);
123467
123889
  Logger.registerAfterLogHook(void 0);
123468
- import_miniflare16.Log.unstable_registerBeforeLogHook(void 0);
123469
- import_miniflare16.Log.unstable_registerAfterLogHook(void 0);
123890
+ import_miniflare17.Log.unstable_registerBeforeLogHook(void 0);
123891
+ import_miniflare17.Log.unstable_registerAfterLogHook(void 0);
123470
123892
  };
123471
123893
  }
123472
123894
  __name(cli_hotkeys_default, "default");
@@ -123847,6 +124269,11 @@ var dev = createCommand({
123847
124269
  type: "boolean",
123848
124270
  describe: "Bind to production Vectorize indexes in local development mode",
123849
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
123850
124277
  }
123851
124278
  },
123852
124279
  async validateArgs(args) {
@@ -123986,6 +124413,7 @@ async function setupDevEnv(devEnv, configPath, auth, args) {
123986
124413
  text_blobs: void 0,
123987
124414
  browser: void 0,
123988
124415
  ai: args.ai,
124416
+ images: void 0,
123989
124417
  version_metadata: args.version_metadata,
123990
124418
  data_blobs: void 0,
123991
124419
  durable_objects: { bindings: args.durableObjects ?? [] },
@@ -124028,6 +124456,7 @@ async function setupDevEnv(devEnv, configPath, auth, args) {
124028
124456
  logLevel: args.logLevel,
124029
124457
  registry: args.disableDevRegistry ? null : devEnv.config.latestConfig?.dev.registry,
124030
124458
  bindVectorizeToProd: args.experimentalVectorizeBindToProd,
124459
+ imagesLocalMode: args.experimentalImagesLocalMode,
124031
124460
  multiworkerPrimary: args.multiworkerPrimary
124032
124461
  },
124033
124462
  legacy: {
@@ -124339,7 +124768,7 @@ function getBindings2(configParam, env7, local, args) {
124339
124768
  );
124340
124769
  const hyperdriveBindings = configParam.hyperdrive.map((hyperdrive2) => {
124341
124770
  const connectionStringFromEnv = process.env[`WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_${hyperdrive2.binding}`];
124342
- if (!connectionStringFromEnv && !hyperdrive2.localConnectionString) {
124771
+ if (local && connectionStringFromEnv === void 0 && hyperdrive2.localConnectionString === void 0) {
124343
124772
  throw new UserError(
124344
124773
  `When developing locally, you should use a local Postgres connection string to emulate Hyperdrive functionality. Please setup Postgres locally and set the value of the 'WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_${hyperdrive2.binding}' variable or "${hyperdrive2.binding}"'s "localConnectionString" to the Postgres connection string.`
124345
124774
  );
@@ -124389,6 +124818,7 @@ function getBindings2(configParam, env7, local, args) {
124389
124818
  analytics_engine_datasets: configParam.analytics_engine_datasets,
124390
124819
  browser: configParam.browser,
124391
124820
  ai: args.ai || configParam.ai,
124821
+ images: configParam.images,
124392
124822
  version_metadata: args.version_metadata || configParam.version_metadata,
124393
124823
  unsafe: {
124394
124824
  bindings: configParam.unsafe.bindings,
@@ -124447,6 +124877,7 @@ async function unstable_dev(script, options30, apiOptions) {
124447
124877
  testMode,
124448
124878
  testScheduled,
124449
124879
  vectorizeBindToProd,
124880
+ imagesLocalMode,
124450
124881
  // 2. options for alpha/beta products/libs
124451
124882
  d1Databases,
124452
124883
  enablePagesAssetsServiceBinding
@@ -124537,6 +124968,7 @@ unstable_dev()'s behaviour will likely change in future releases`
124537
124968
  port: options30?.port ?? 0,
124538
124969
  experimentalProvision: void 0,
124539
124970
  experimentalVectorizeBindToProd: vectorizeBindToProd ?? false,
124971
+ experimentalImagesLocalMode: imagesLocalMode ?? false,
124540
124972
  enableIpc: options30?.experimental?.enableIpc
124541
124973
  };
124542
124974
  const devServer = await run(
@@ -127098,7 +127530,8 @@ async function resolveDevConfig(config, input) {
127098
127530
  persist: localPersistencePath,
127099
127531
  registry: input.dev?.registry,
127100
127532
  bindVectorizeToProd: input.dev?.bindVectorizeToProd ?? false,
127101
- multiworkerPrimary: input.dev?.multiworkerPrimary
127533
+ multiworkerPrimary: input.dev?.multiworkerPrimary,
127534
+ imagesLocalMode: input.dev?.imagesLocalMode ?? false
127102
127535
  };
127103
127536
  }
127104
127537
  __name(resolveDevConfig, "resolveDevConfig");
@@ -127133,6 +127566,7 @@ async function resolveBindings(config, input) {
127133
127566
  {
127134
127567
  registry: input.dev?.registry,
127135
127568
  local: !input.dev?.remote,
127569
+ imagesLocalMode: input.dev?.imagesLocalMode,
127136
127570
  name: config.name
127137
127571
  }
127138
127572
  );
@@ -127386,7 +127820,7 @@ __name(ConfigController, "ConfigController");
127386
127820
 
127387
127821
  // src/api/startDevWorker/RemoteRuntimeController.ts
127388
127822
  init_import_meta_url();
127389
- var import_miniflare18 = require("miniflare");
127823
+ var import_miniflare19 = require("miniflare");
127390
127824
 
127391
127825
  // src/dev/create-worker-preview.ts
127392
127826
  init_import_meta_url();
@@ -127740,7 +128174,7 @@ __name(notImplemented, "notImplemented");
127740
128174
  var RemoteRuntimeController = class extends RuntimeController {
127741
128175
  #abortController = new AbortController();
127742
128176
  #currentBundleId = 0;
127743
- #mutex = new import_miniflare18.Mutex();
128177
+ #mutex = new import_miniflare19.Mutex();
127744
128178
  #session;
127745
128179
  async #previewSession(props) {
127746
128180
  try {
@@ -128133,7 +128567,7 @@ init_import_meta_url();
128133
128567
 
128134
128568
  // src/api/integrations/platform/index.ts
128135
128569
  init_import_meta_url();
128136
- var import_miniflare20 = require("miniflare");
128570
+ var import_miniflare21 = require("miniflare");
128137
128571
 
128138
128572
  // src/api/integrations/platform/caches.ts
128139
128573
  init_import_meta_url();
@@ -128194,7 +128628,7 @@ __name(ExecutionContext, "ExecutionContext");
128194
128628
 
128195
128629
  // src/api/integrations/platform/services.ts
128196
128630
  init_import_meta_url();
128197
- var import_miniflare19 = require("miniflare");
128631
+ var import_miniflare20 = require("miniflare");
128198
128632
  var import_undici13 = __toESM(require_undici());
128199
128633
  async function getServiceBindings(services = []) {
128200
128634
  if (services.length === 0) {
@@ -128246,9 +128680,9 @@ function getServiceBindingProxyFetch({
128246
128680
  try {
128247
128681
  const resp = await (0, import_undici13.fetch)(newUrl, request4);
128248
128682
  const respBody = await resp.arrayBuffer();
128249
- return new import_miniflare19.Response(respBody, resp);
128683
+ return new import_miniflare20.Response(respBody, resp);
128250
128684
  } catch {
128251
- return new import_miniflare19.Response(
128685
+ return new import_miniflare20.Response(
128252
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\``,
128253
128687
  { status: 500 }
128254
128688
  );
@@ -128279,20 +128713,16 @@ async function getPlatformProxy(options30 = {}) {
128279
128713
  },
128280
128714
  () => getMiniflareOptionsFromConfig(rawConfig, env7, options30)
128281
128715
  );
128282
- const mf = new import_miniflare20.Miniflare({
128716
+ const mf = new import_miniflare21.Miniflare({
128283
128717
  script: "",
128284
128718
  modules: true,
128285
128719
  ...miniflareOptions
128286
128720
  });
128287
128721
  const bindings = await mf.getBindings();
128288
- const vars = getVarsForDev(rawConfig, env7);
128289
128722
  const cf2 = await mf.getCf();
128290
128723
  deepFreeze(cf2);
128291
128724
  return {
128292
- env: {
128293
- ...vars,
128294
- ...bindings
128295
- },
128725
+ env: bindings,
128296
128726
  cf: cf2,
128297
128727
  ctx: new ExecutionContext(),
128298
128728
  caches: new CacheStorage(),
@@ -128314,7 +128744,8 @@ async function getMiniflareOptionsFromConfig(rawConfig, env7, options30) {
128314
128744
  queueConsumers: void 0,
128315
128745
  services: rawConfig.services,
128316
128746
  serviceBindings: {},
128317
- migrations: rawConfig.migrations
128747
+ migrations: rawConfig.migrations,
128748
+ imagesLocalMode: false
128318
128749
  });
128319
128750
  const persistOptions = getMiniflarePersistOptions(options30.persist);
128320
128751
  const serviceBindings = await getServiceBindings(bindings.services);
@@ -128381,12 +128812,13 @@ function unstable_getMiniflareWorkerOptions(configOrConfigPath, env7) {
128381
128812
  queueConsumers: config.queues.consumers,
128382
128813
  services: [],
128383
128814
  serviceBindings: {},
128384
- migrations: config.migrations
128815
+ migrations: config.migrations,
128816
+ imagesLocalMode: false
128385
128817
  });
128386
128818
  if (bindings.services !== void 0) {
128387
128819
  bindingOptions.serviceBindings = Object.fromEntries(
128388
128820
  bindings.services.map((binding) => {
128389
- const name2 = binding.service === config.name ? import_miniflare20.kCurrentWorker : binding.service;
128821
+ const name2 = binding.service === config.name ? import_miniflare21.kCurrentWorker : binding.service;
128390
128822
  return [binding.binding, { name: name2, entrypoint: binding.entrypoint }];
128391
128823
  })
128392
128824
  );
@@ -140039,7 +140471,7 @@ var import_fs13 = require("fs");
140039
140471
  var import_node_assert25 = __toESM(require("node:assert"));
140040
140472
  var import_node_path54 = __toESM(require("node:path"));
140041
140473
  var import_md5_file = __toESM(require_md5_file());
140042
- var import_miniflare22 = require("miniflare");
140474
+ var import_miniflare23 = require("miniflare");
140043
140475
  var import_undici16 = __toESM(require_undici());
140044
140476
 
140045
140477
  // src/d1/splitter.ts
@@ -140243,7 +140675,9 @@ var Handler6 = /* @__PURE__ */ __name(async (args) => {
140243
140675
  if (file && command2) {
140244
140676
  throw createFatalError(
140245
140677
  `Error: can't provide both --command and --file.`,
140246
- json
140678
+ json,
140679
+ void 0,
140680
+ { telemetryMessage: true }
140247
140681
  );
140248
140682
  }
140249
140683
  const isInteractive3 = process.stdout.isTTY;
@@ -140373,7 +140807,7 @@ async function executeLocally({
140373
140807
  logger.log(
140374
140808
  "\u{1F300} To execute on your remote database, add a --remote flag to your wrangler command."
140375
140809
  );
140376
- const mf = new import_miniflare22.Miniflare({
140810
+ const mf = new import_miniflare23.Miniflare({
140377
140811
  modules: true,
140378
140812
  script: "",
140379
140813
  d1Persist,
@@ -140636,7 +141070,7 @@ __name(checkForSQLiteBinary, "checkForSQLiteBinary");
140636
141070
  init_import_meta_url();
140637
141071
  var import_promises24 = __toESM(require("node:fs/promises"));
140638
141072
  var import_node_path55 = __toESM(require("node:path"));
140639
- var import_miniflare23 = require("miniflare");
141073
+ var import_miniflare24 = require("miniflare");
140640
141074
  var import_undici17 = __toESM(require_undici());
140641
141075
  function Options7(yargs) {
140642
141076
  return Name(yargs).option("local", {
@@ -140705,7 +141139,7 @@ async function exportLocal(config, name2, output, tables, noSchema, noData) {
140705
141139
  logger.log(
140706
141140
  "\u{1F300} To export your remote database, add a --remote flag to your wrangler command."
140707
141141
  );
140708
- const mf = new import_miniflare23.Miniflare({
141142
+ const mf = new import_miniflare24.Miniflare({
140709
141143
  modules: true,
140710
141144
  script: "export default {}",
140711
141145
  d1Persist,
@@ -140829,7 +141263,7 @@ var Handler8 = withConfig(
140829
141263
  accountId,
140830
141264
  name2
140831
141265
  );
140832
- const result = await getDatabaseInfoFromId(accountId, db.uuid);
141266
+ const result = await getDatabaseInfoFromIdOrName(accountId, db.uuid);
140833
141267
  const output = { ...result };
140834
141268
  if (output["file_size"]) {
140835
141269
  output["database_size"] = output["file_size"];
@@ -141019,7 +141453,7 @@ var Handler9 = withConfig(
141019
141453
  accountId,
141020
141454
  name2
141021
141455
  );
141022
- const result = await getDatabaseInfoFromId(accountId, db.uuid);
141456
+ const result = await getDatabaseInfoFromIdOrName(accountId, db.uuid);
141023
141457
  const output = [];
141024
141458
  if (result.version !== "alpha") {
141025
141459
  const [startDate, endDate] = getDurationDates(timePeriod);
@@ -141351,7 +141785,10 @@ Your database may not be available to serve requests during the migration, conti
141351
141785
  "In non-local mode `databaseInfo` should be defined."
141352
141786
  );
141353
141787
  const accountId = await requireAuth(config);
141354
- const dbInfo = await getDatabaseInfoFromId(accountId, databaseInfo?.uuid);
141788
+ const dbInfo = await getDatabaseInfoFromIdOrName(
141789
+ accountId,
141790
+ databaseInfo?.uuid
141791
+ );
141355
141792
  if (dbInfo.version === "alpha") {
141356
141793
  logger.log("\u{1F552} Creating backup...");
141357
141794
  await createBackup(accountId, databaseInfo.uuid);
@@ -141570,7 +142007,7 @@ var getBookmarkIdFromTimestamp = /* @__PURE__ */ __name(async (accountId, databa
141570
142007
  return bookmarkResult;
141571
142008
  }, "getBookmarkIdFromTimestamp");
141572
142009
  var throwIfDatabaseIsAlpha = /* @__PURE__ */ __name(async (accountId, databaseId) => {
141573
- const dbInfo = await getDatabaseInfoFromId(accountId, databaseId);
142010
+ const dbInfo = await getDatabaseInfoFromIdOrName(accountId, databaseId);
141574
142011
  if (dbInfo.version === "alpha") {
141575
142012
  throw new UserError(
141576
142013
  "Time travel is not available for alpha D1 databases. You will need to migrate to a new database for access to this feature."
@@ -141857,7 +142294,8 @@ async function deleteHandler(args) {
141857
142294
  const config = readConfig(args);
141858
142295
  if (config.pages_build_output_dir) {
141859
142296
  throw new UserError(
141860
- "It looks like you've run a Workers-specific command in a Pages project.\nFor Pages, please run `wrangler pages project delete` instead."
142297
+ "It looks like you've run a Workers-specific command in a Pages project.\nFor Pages, please run `wrangler pages project delete` instead.",
142298
+ { telemetryMessage: true }
141861
142299
  );
141862
142300
  }
141863
142301
  sendMetricsEvent(
@@ -141869,7 +142307,10 @@ async function deleteHandler(args) {
141869
142307
  const scriptName = getScriptName(args, config);
141870
142308
  if (!scriptName) {
141871
142309
  throw new UserError(
141872
- `A worker name must be defined, either via --name, or in your ${configFileName(config.configPath)} file`
142310
+ `A worker name must be defined, either via --name, or in your ${configFileName(config.configPath)} file`,
142311
+ {
142312
+ telemetryMessage: "`A worker name must be defined, either via --name, or in your config file"
142313
+ }
141873
142314
  );
141874
142315
  }
141875
142316
  if (args.dryRun) {
@@ -143555,7 +143996,7 @@ async function mapBindings(accountId, bindings) {
143555
143996
  const d1BindingsWithInfo = {};
143556
143997
  await Promise.all(
143557
143998
  bindings.filter((binding) => binding.type === "d1").map(async (binding) => {
143558
- const dbInfo = await getDatabaseInfoFromId(accountId, binding.id);
143999
+ const dbInfo = await getDatabaseInfoFromIdOrName(accountId, binding.id);
143559
144000
  d1BindingsWithInfo[binding.id] = dbInfo;
143560
144001
  })
143561
144002
  );
@@ -143627,6 +144068,13 @@ async function mapBindings(accountId, bindings) {
143627
144068
  };
143628
144069
  }
143629
144070
  break;
144071
+ case "images":
144072
+ {
144073
+ configObj.images = {
144074
+ binding: binding.name
144075
+ };
144076
+ }
144077
+ break;
143630
144078
  case "r2_bucket":
143631
144079
  {
143632
144080
  configObj.r2_buckets = [
@@ -147255,6 +147703,11 @@ function Options14(yargs) {
147255
147703
  type: "boolean",
147256
147704
  describe: "Bind to production Vectorize indexes in local development mode",
147257
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
147258
147711
  }
147259
147712
  });
147260
147713
  }
@@ -147695,6 +148148,7 @@ ${JSON.stringify(defaultRoutesJSONSpec, null, 2)}`
147695
148148
  logLevel: args.logLevel ?? "log",
147696
148149
  experimentalProvision: void 0,
147697
148150
  experimentalVectorizeBindToProd: false,
148151
+ experimentalImagesLocalMode: false,
147698
148152
  enableIpc: true,
147699
148153
  config: Array.isArray(args.config) ? args.config : void 0,
147700
148154
  legacyAssets: void 0,
@@ -147980,12 +148434,12 @@ init_import_meta_url();
147980
148434
  var import_fs14 = require("fs");
147981
148435
  var import_promises28 = require("node:fs/promises");
147982
148436
  var import_toml8 = __toESM(require_toml());
147983
- var import_miniflare24 = require("miniflare");
148437
+ var import_miniflare25 = require("miniflare");
147984
148438
  async function toEnvironment(deploymentConfig, accountId) {
147985
148439
  const configObj = {};
147986
148440
  configObj.compatibility_date = deploymentConfig.compatibility_date ?? (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
147987
148441
  if (deploymentConfig.always_use_latest_compatibility_date) {
147988
- configObj.compatibility_date = import_miniflare24.supportedCompatibilityDate;
148442
+ configObj.compatibility_date = import_miniflare25.supportedCompatibilityDate;
147989
148443
  }
147990
148444
  if (deploymentConfig.compatibility_flags?.length) {
147991
148445
  configObj.compatibility_flags = deploymentConfig.compatibility_flags;
@@ -148343,6 +148797,7 @@ async function createDraftWorker({
148343
148797
  wasm_modules: {},
148344
148798
  browser: void 0,
148345
148799
  ai: void 0,
148800
+ images: void 0,
148346
148801
  version_metadata: void 0,
148347
148802
  text_blobs: {},
148348
148803
  data_blobs: {},
@@ -149366,12 +149821,12 @@ init_import_meta_url();
149366
149821
  init_import_meta_url();
149367
149822
 
149368
149823
  // ../../node_modules/.pnpm/@smithy+util-buffer-from@2.2.0/node_modules/@smithy/util-buffer-from/dist-es/index.js
149369
- var import_buffer2 = require("buffer");
149824
+ var import_buffer3 = require("buffer");
149370
149825
  var fromString2 = /* @__PURE__ */ __name((input, encoding) => {
149371
149826
  if (typeof input !== "string") {
149372
149827
  throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
149373
149828
  }
149374
- return encoding ? import_buffer2.Buffer.from(input, encoding) : import_buffer2.Buffer.from(input);
149829
+ return encoding ? import_buffer3.Buffer.from(input, encoding) : import_buffer3.Buffer.from(input);
149375
149830
  }, "fromString");
149376
149831
 
149377
149832
  // ../../node_modules/.pnpm/@smithy+util-utf8@2.3.0/node_modules/@smithy/util-utf8/dist-es/fromUtf8.js
@@ -152889,11 +153344,21 @@ async function authorizeR2Bucket(pipelineName, accountId, bucketName) {
152889
153344
  });
152890
153345
  !__testSkipDelaysFlag && await retryOnAPIFailure(
152891
153346
  async () => {
152892
- await r22.send(
152893
- new HeadBucketCommand({
152894
- Bucket: bucketName
152895
- })
152896
- );
153347
+ try {
153348
+ await r22.send(
153349
+ new HeadBucketCommand({
153350
+ Bucket: bucketName
153351
+ })
153352
+ );
153353
+ } catch (err) {
153354
+ if (err instanceof Error && err.name === "401") {
153355
+ throw new AuthAPIError({
153356
+ status: 401,
153357
+ text: "R2 HeadBucket request failed with status: 401"
153358
+ });
153359
+ }
153360
+ throw err;
153361
+ }
152897
153362
  },
152898
153363
  1e3,
152899
153364
  10
@@ -152901,6 +153366,12 @@ async function authorizeR2Bucket(pipelineName, accountId, bucketName) {
152901
153366
  return serviceToken;
152902
153367
  }
152903
153368
  __name(authorizeR2Bucket, "authorizeR2Bucket");
153369
+ var AuthAPIError = class extends APIError {
153370
+ isRetryable() {
153371
+ return true;
153372
+ }
153373
+ };
153374
+ __name(AuthAPIError, "AuthAPIError");
152904
153375
  function getAccountR2Endpoint(accountId) {
152905
153376
  return `https://${accountId}.r2.cloudflarestorage.com`;
152906
153377
  }
@@ -154442,7 +154913,7 @@ var r2BucketCreateCommand = createCommand({
154442
154913
  const { name: name2, location, storageClass, jurisdiction } = args;
154443
154914
  if (!isValidR2BucketName(name2)) {
154444
154915
  throw new UserError(
154445
- `The bucket name "${name2}" is invalid. Bucket names can only have alphanumeric and - characters.`
154916
+ `The bucket name "${name2}" is invalid. Bucket names must begin and end with an alphanumeric and can only contain letters (a-z), numbers (0-9), and hyphens (-).`
154446
154917
  );
154447
154918
  }
154448
154919
  if (jurisdiction && location) {
@@ -154701,10 +155172,7 @@ var r2BucketCORSSetCommand = createCommand({
154701
155172
  async handler({ bucket, file, jurisdiction, force }, { config }) {
154702
155173
  const accountId = await requireAuth(config);
154703
155174
  const jsonFilePath = import_node_path65.default.resolve(file);
154704
- const corsConfig = parseJSON(
154705
- readFileSync5(jsonFilePath),
154706
- jsonFilePath
154707
- );
155175
+ const corsConfig = parseJSON(readFileSync5(jsonFilePath), jsonFilePath);
154708
155176
  if (!corsConfig.rules || !Array.isArray(corsConfig.rules)) {
154709
155177
  throw new UserError(
154710
155178
  `The CORS configuration file must contain a 'rules' array as expected by the request body of the CORS API: https://developers.cloudflare.com/api/operations/r2-put-bucket-cors-policy`
@@ -165661,7 +166129,8 @@ var tailCommand = createCommand({
165661
166129
  throw createFatalError(
165662
166130
  "Tail disconnected, exiting.",
165663
166131
  args.format === "json",
165664
- 1
166132
+ 1,
166133
+ { telemetryMessage: true }
165665
166134
  );
165666
166135
  }
165667
166136
  waitingForPong = true;
@@ -165746,13 +166215,13 @@ __name(triggersDeployHandler, "triggersDeployHandler");
165746
166215
  init_import_meta_url();
165747
166216
  var fs28 = __toESM(require("node:fs"));
165748
166217
  var import_node_path66 = require("node:path");
165749
- var import_miniflare26 = require("miniflare");
166218
+ var import_miniflare27 = require("miniflare");
165750
166219
 
165751
166220
  // src/type-generation/runtime/index.ts
165752
166221
  init_import_meta_url();
165753
166222
  var import_fs23 = require("fs");
165754
166223
  var import_promises32 = require("fs/promises");
165755
- var import_miniflare25 = require("miniflare");
166224
+ var import_miniflare26 = require("miniflare");
165756
166225
  var import_workerd = require("workerd");
165757
166226
  var DEFAULT_OUTFILE_RELATIVE_PATH = "./.wrangler/types/runtime.d.ts";
165758
166227
  async function generateRuntimeTypes({
@@ -165794,7 +166263,7 @@ async function generate({
165794
166263
  compatibilityFlags = []
165795
166264
  }) {
165796
166265
  const worker = (0, import_fs23.readFileSync)(require.resolve("workerd/worker.mjs")).toString();
165797
- const mf = new import_miniflare25.Miniflare({
166266
+ const mf = new import_miniflare26.Miniflare({
165798
166267
  compatibilityDate: "2024-01-01",
165799
166268
  compatibilityFlags: ["nodejs_compat", "rtti_api"],
165800
166269
  modules: true,
@@ -165936,7 +166405,7 @@ var typesCommand = createCommand({
165936
166405
  });
165937
166406
  const tsconfigPath = config.tsconfig ?? (0, import_node_path66.join)((0, import_node_path66.dirname)(config.configPath), "tsconfig.json");
165938
166407
  const tsconfigTypes = readTsconfigTypes(tsconfigPath);
165939
- const { mode } = (0, import_miniflare26.getNodeCompat)(
166408
+ const { mode } = (0, import_miniflare27.getNodeCompat)(
165940
166409
  config.compatibility_date,
165941
166410
  config.compatibility_flags,
165942
166411
  {
@@ -168811,10 +169280,21 @@ var versionsUploadCommand = createCommand({
168811
169280
  describe: "A descriptive message for this Worker Gradual Rollouts Version",
168812
169281
  type: "string",
168813
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"
168814
169290
  }
168815
169291
  },
168816
169292
  behaviour: {
168817
- useConfigRedirectIfAvailable: true
169293
+ useConfigRedirectIfAvailable: true,
169294
+ overrideExperimentalFlags: (args) => ({
169295
+ MULTIWORKER: false,
169296
+ RESOURCES_PROVISION: args.experimentalProvision ?? false
169297
+ })
168818
169298
  },
168819
169299
  handler: /* @__PURE__ */ __name(async function versionsUploadHandler(args, { config }) {
168820
169300
  const entry = await getEntry(args, config, "versions upload");
@@ -168902,7 +169382,8 @@ var versionsUploadCommand = createCommand({
168902
169382
  keepVars: false,
168903
169383
  projectRoot: entry.projectRoot,
168904
169384
  tag: args.tag,
168905
- message: args.message
169385
+ message: args.message,
169386
+ experimentalAutoCreate: args.experimentalAutoCreate
168906
169387
  });
168907
169388
  writeOutput({
168908
169389
  type: "version-upload",
@@ -169166,6 +169647,16 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
169166
169647
  if (props.dryRun) {
169167
169648
  printBindings({ ...bindings, vars: maskedVars });
169168
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
+ }
169169
169660
  await ensureQueuesExistByConfig(config);
169170
169661
  let bindingsPrinted = false;
169171
169662
  try {
@@ -170898,7 +171389,9 @@ if (proxy) {
170898
171389
  function createCLIParser(argv) {
170899
171390
  const wrangler = yargs_default(argv).strict().showHelpOnFail(false).fail((msg, error2) => {
170900
171391
  if (!error2 || error2.name === "YError") {
170901
- error2 = new CommandLineArgsError(msg);
171392
+ error2 = new CommandLineArgsError(msg, {
171393
+ telemetryMessage: "yargs validation error"
171394
+ });
170902
171395
  }
170903
171396
  throw error2;
170904
171397
  }).scriptName("wrangler").wrap(null).locale("en_US").version(false).option("v", {
@@ -170917,7 +171410,7 @@ function createCLIParser(argv) {
170917
171410
  )
170918
171411
  ).option("env", {
170919
171412
  alias: "e",
170920
- describe: "Environment to use for operations and .env files",
171413
+ describe: "Environment to use for operations, and for selecting .env and .dev.vars files",
170921
171414
  type: "string",
170922
171415
  requiresArg: true
170923
171416
  }).check(demandSingleValue("env")).option("experimental-json-config", {
@@ -170930,7 +171423,8 @@ function createCLIParser(argv) {
170930
171423
  }).check((args) => {
170931
171424
  if (args["experimental-json-config"] === false) {
170932
171425
  throw new CommandLineArgsError(
170933
- `Wrangler now supports wrangler.json configuration files by default and ignores the value of the \`--experimental-json-config\` flag.`
171426
+ `Wrangler now supports wrangler.json configuration files by default and ignores the value of the \`--experimental-json-config\` flag.`,
171427
+ { telemetryMessage: true }
170934
171428
  );
170935
171429
  }
170936
171430
  return true;
@@ -171659,7 +172153,8 @@ ${tryRunningItIn}${oneOfThese}`
171659
172153
  durationMs,
171660
172154
  durationSeconds: durationMs / 1e3,
171661
172155
  durationMinutes: durationMs / 1e3 / 60,
171662
- errorType: errorType ?? (e7 instanceof Error ? e7.constructor.name : void 0)
172156
+ errorType: errorType ?? (e7 instanceof Error ? e7.constructor.name : void 0),
172157
+ errorMessage: e7 instanceof UserError ? e7.telemetryMessage : void 0
171663
172158
  },
171664
172159
  argv
171665
172160
  );