wrangler 2.1.4 → 2.1.6

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.
Files changed (46) hide show
  1. package/miniflare-dist/index.mjs +4 -1
  2. package/package.json +1 -1
  3. package/src/__tests__/api-dev.test.ts +3 -3
  4. package/src/__tests__/api-devregistry.test.js +56 -0
  5. package/src/__tests__/configuration.test.ts +3 -0
  6. package/src/__tests__/dev.test.tsx +39 -1
  7. package/src/__tests__/helpers/worker-scripts/child-wrangler.toml +1 -0
  8. package/src/__tests__/helpers/{hello-world-worker.js → worker-scripts/hello-world-worker.js} +0 -0
  9. package/src/__tests__/helpers/worker-scripts/hello-world-wrangler.toml +1 -0
  10. package/src/__tests__/helpers/worker-scripts/parent-worker.js +8 -0
  11. package/src/__tests__/helpers/worker-scripts/parent-wrangler.toml +5 -0
  12. package/src/__tests__/init.test.ts +72 -0
  13. package/src/__tests__/middleware.scheduled.test.ts +135 -0
  14. package/src/__tests__/middleware.test.ts +703 -745
  15. package/src/__tests__/pages.test.ts +35 -40
  16. package/src/__tests__/publish.test.ts +57 -1
  17. package/src/api/dev.ts +2 -0
  18. package/src/bundle.ts +14 -16
  19. package/src/config/config.ts +12 -0
  20. package/src/config/validation.ts +9 -0
  21. package/src/create-worker-upload-form.ts +3 -2
  22. package/src/dev/dev.tsx +12 -21
  23. package/src/dev/local.tsx +1 -0
  24. package/src/dev/remote.tsx +38 -50
  25. package/src/dev/start-server.ts +43 -8
  26. package/src/dev/use-esbuild.ts +4 -0
  27. package/src/dev-registry.tsx +30 -0
  28. package/src/dev.tsx +21 -3
  29. package/src/index.tsx +8 -1
  30. package/src/init.ts +3 -1
  31. package/src/inspect.ts +26 -26
  32. package/src/miniflare-cli/assets.ts +8 -1
  33. package/src/pages/constants.ts +2 -1
  34. package/src/pages/dev.tsx +133 -10
  35. package/src/pages/errors.ts +48 -4
  36. package/src/pages/functions/routes-transformation.ts +1 -14
  37. package/src/pages/functions/routes-validation.test.ts +403 -0
  38. package/src/pages/functions/routes-validation.ts +202 -0
  39. package/src/pages/functions.tsx +4 -18
  40. package/src/pages/publish.tsx +6 -22
  41. package/src/publish.ts +3 -1
  42. package/src/worker.ts +1 -1
  43. package/templates/middleware/middleware-scheduled.ts +2 -1
  44. package/templates/pages-dev-pipeline.ts +35 -0
  45. package/wrangler-dist/cli.d.ts +2 -0
  46. package/wrangler-dist/cli.js +611 -353
@@ -1924,7 +1924,7 @@ var require_body = __commonJS({
1924
1924
  "../../node_modules/undici/lib/fetch/body.js"(exports2, module2) {
1925
1925
  "use strict";
1926
1926
  init_import_meta_url();
1927
- var util2 = require_util();
1927
+ var util3 = require_util();
1928
1928
  var { ReadableStreamFrom, toUSVString, isBlobLike } = require_util2();
1929
1929
  var { FormData: FormData5 } = require_formdata();
1930
1930
  var { kState } = require_symbols2();
@@ -1957,7 +1957,7 @@ var require_body = __commonJS({
1957
1957
  object = object.buffer;
1958
1958
  }
1959
1959
  source = new Uint8Array(object);
1960
- } else if (util2.isFormDataLike(object)) {
1960
+ } else if (util3.isFormDataLike(object)) {
1961
1961
  const boundary = "----formdata-undici-" + Math.random();
1962
1962
  const prefix2 = `--${boundary}\r
1963
1963
  Content-Disposition: form-data`;
@@ -1999,7 +1999,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r
1999
1999
  if (keepalive) {
2000
2000
  throw new TypeError("keepalive");
2001
2001
  }
2002
- if (util2.isDisturbed(object) || object.locked) {
2002
+ if (util3.isDisturbed(object) || object.locked) {
2003
2003
  throw new TypeError(
2004
2004
  "Response body object should not be disturbed or locked"
2005
2005
  );
@@ -2009,7 +2009,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r
2009
2009
  source = toUSVString(object);
2010
2010
  contentType = "text/plain;charset=UTF-8";
2011
2011
  }
2012
- if (typeof source === "string" || util2.isBuffer(source)) {
2012
+ if (typeof source === "string" || util3.isBuffer(source)) {
2013
2013
  length = Buffer.byteLength(source);
2014
2014
  }
2015
2015
  if (action != null) {
@@ -2055,7 +2055,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r
2055
2055
  ReadableStream = require("stream/web").ReadableStream;
2056
2056
  }
2057
2057
  if (object instanceof ReadableStream) {
2058
- assert12(!util2.isDisturbed(object), "disturbed");
2058
+ assert12(!util3.isDisturbed(object), "disturbed");
2059
2059
  assert12(!object.locked, "locked");
2060
2060
  }
2061
2061
  return extractBody(object, keepalive);
@@ -2075,7 +2075,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r
2075
2075
  yield body;
2076
2076
  } else {
2077
2077
  const stream2 = body.stream;
2078
- if (util2.isDisturbed(stream2)) {
2078
+ if (util3.isDisturbed(stream2)) {
2079
2079
  throw new TypeError("disturbed");
2080
2080
  }
2081
2081
  if (stream2.locked) {
@@ -2211,7 +2211,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r
2211
2211
  if (!this || !this[kState]) {
2212
2212
  throw new TypeError("Illegal invocation");
2213
2213
  }
2214
- return !!this[kState].body && util2.isDisturbed(this[kState].body.stream);
2214
+ return !!this[kState].body && util3.isDisturbed(this[kState].body.stream);
2215
2215
  }
2216
2216
  }
2217
2217
  };
@@ -2238,7 +2238,7 @@ var require_request = __commonJS({
2238
2238
  NotSupportedError
2239
2239
  } = require_errors();
2240
2240
  var assert12 = require("assert");
2241
- var util2 = require_util();
2241
+ var util3 = require_util();
2242
2242
  var tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/;
2243
2243
  var headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/;
2244
2244
  var invalidPathRegex = /[^\u0021-\u00ff]/;
@@ -2303,9 +2303,9 @@ var require_request = __commonJS({
2303
2303
  this.method = method;
2304
2304
  if (body == null) {
2305
2305
  this.body = null;
2306
- } else if (util2.isStream(body)) {
2306
+ } else if (util3.isStream(body)) {
2307
2307
  this.body = body;
2308
- } else if (util2.isBuffer(body)) {
2308
+ } else if (util3.isBuffer(body)) {
2309
2309
  this.body = body.byteLength ? body : null;
2310
2310
  } else if (ArrayBuffer.isView(body)) {
2311
2311
  this.body = body.buffer.byteLength ? Buffer.from(body.buffer, body.byteOffset, body.byteLength) : null;
@@ -2313,7 +2313,7 @@ var require_request = __commonJS({
2313
2313
  this.body = body.byteLength ? Buffer.from(body) : null;
2314
2314
  } else if (typeof body === "string") {
2315
2315
  this.body = body.length ? Buffer.from(body) : null;
2316
- } else if (util2.isFormDataLike(body) || util2.isIterable(body) || util2.isBlobLike(body)) {
2316
+ } else if (util3.isFormDataLike(body) || util3.isIterable(body) || util3.isBlobLike(body)) {
2317
2317
  this.body = body;
2318
2318
  } else {
2319
2319
  throw new InvalidArgumentError("body must be a string, a Buffer, a Readable stream, an iterable, or an async iterable");
@@ -2321,7 +2321,7 @@ var require_request = __commonJS({
2321
2321
  this.completed = false;
2322
2322
  this.aborted = false;
2323
2323
  this.upgrade = upgrade || null;
2324
- this.path = query ? util2.buildURL(path30, query) : path30;
2324
+ this.path = query ? util3.buildURL(path30, query) : path30;
2325
2325
  this.origin = origin;
2326
2326
  this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
2327
2327
  this.blocking = blocking == null ? false : blocking;
@@ -2345,7 +2345,7 @@ var require_request = __commonJS({
2345
2345
  } else if (headers != null) {
2346
2346
  throw new InvalidArgumentError("headers must be an object or an array");
2347
2347
  }
2348
- if (util2.isFormDataLike(this.body)) {
2348
+ if (util3.isFormDataLike(this.body)) {
2349
2349
  if (nodeMajor < 16 || nodeMajor === 16 && nodeMinor < 8) {
2350
2350
  throw new InvalidArgumentError("Form-Data bodies are only supported in node v16.8 and newer.");
2351
2351
  }
@@ -2359,13 +2359,13 @@ var require_request = __commonJS({
2359
2359
  `;
2360
2360
  }
2361
2361
  this.body = bodyStream.stream;
2362
- } else if (util2.isBlobLike(body) && this.contentType == null && body.type) {
2362
+ } else if (util3.isBlobLike(body) && this.contentType == null && body.type) {
2363
2363
  this.contentType = body.type;
2364
2364
  this.headers += `content-type: ${body.type}\r
2365
2365
  `;
2366
2366
  }
2367
- util2.validateHandler(handler2, method, upgrade);
2368
- this.servername = util2.getServerName(this.host);
2367
+ util3.validateHandler(handler2, method, upgrade);
2368
+ this.servername = util3.getServerName(this.host);
2369
2369
  this[kHandler] = handler2;
2370
2370
  if (channels.create.hasSubscribers) {
2371
2371
  channels.create.publish({ request: this });
@@ -2630,7 +2630,7 @@ var require_redirect = __commonJS({
2630
2630
  "../../node_modules/undici/lib/handler/redirect.js"(exports2, module2) {
2631
2631
  "use strict";
2632
2632
  init_import_meta_url();
2633
- var util2 = require_util();
2633
+ var util3 = require_util();
2634
2634
  var { kBodyUsed } = require_symbols();
2635
2635
  var assert12 = require("assert");
2636
2636
  var { InvalidArgumentError } = require_errors();
@@ -2653,7 +2653,7 @@ var require_redirect = __commonJS({
2653
2653
  if (maxRedirections != null && (!Number.isInteger(maxRedirections) || maxRedirections < 0)) {
2654
2654
  throw new InvalidArgumentError("maxRedirections must be a positive number");
2655
2655
  }
2656
- util2.validateHandler(handler2, opts.method, opts.upgrade);
2656
+ util3.validateHandler(handler2, opts.method, opts.upgrade);
2657
2657
  this.dispatcher = dispatcher;
2658
2658
  this.location = null;
2659
2659
  this.abort = null;
@@ -2661,8 +2661,8 @@ var require_redirect = __commonJS({
2661
2661
  this.maxRedirections = maxRedirections;
2662
2662
  this.handler = handler2;
2663
2663
  this.history = [];
2664
- if (util2.isStream(this.opts.body)) {
2665
- if (util2.bodyLength(this.opts.body) === 0) {
2664
+ if (util3.isStream(this.opts.body)) {
2665
+ if (util3.bodyLength(this.opts.body) === 0) {
2666
2666
  this.opts.body.on("data", function() {
2667
2667
  assert12(false);
2668
2668
  });
@@ -2675,7 +2675,7 @@ var require_redirect = __commonJS({
2675
2675
  }
2676
2676
  } else if (this.opts.body && typeof this.opts.body.pipeTo === "function") {
2677
2677
  this.opts.body = new BodyAsyncIterable(this.opts.body);
2678
- } else if (this.opts.body && typeof this.opts.body !== "string" && !ArrayBuffer.isView(this.opts.body) && util2.isIterable(this.opts.body)) {
2678
+ } else if (this.opts.body && typeof this.opts.body !== "string" && !ArrayBuffer.isView(this.opts.body) && util3.isIterable(this.opts.body)) {
2679
2679
  this.opts.body = new BodyAsyncIterable(this.opts.body);
2680
2680
  }
2681
2681
  }
@@ -2690,14 +2690,14 @@ var require_redirect = __commonJS({
2690
2690
  this.handler.onError(error);
2691
2691
  }
2692
2692
  onHeaders(statusCode, headers, resume, statusText) {
2693
- this.location = this.history.length >= this.maxRedirections || util2.isDisturbed(this.opts.body) ? null : parseLocation(statusCode, headers);
2693
+ this.location = this.history.length >= this.maxRedirections || util3.isDisturbed(this.opts.body) ? null : parseLocation(statusCode, headers);
2694
2694
  if (this.opts.origin) {
2695
2695
  this.history.push(new URL(this.opts.path, this.opts.origin));
2696
2696
  }
2697
2697
  if (!this.location) {
2698
2698
  return this.handler.onHeaders(statusCode, headers, resume, statusText);
2699
2699
  }
2700
- const { origin, pathname, search } = util2.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
2700
+ const { origin, pathname, search } = util3.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
2701
2701
  const path30 = search ? `${pathname}${search}` : pathname;
2702
2702
  this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
2703
2703
  this.opts.path = path30;
@@ -2772,7 +2772,7 @@ var require_connect = __commonJS({
2772
2772
  init_import_meta_url();
2773
2773
  var net3 = require("net");
2774
2774
  var assert12 = require("assert");
2775
- var util2 = require_util();
2775
+ var util3 = require_util();
2776
2776
  var { InvalidArgumentError, ConnectTimeoutError } = require_errors();
2777
2777
  var tls;
2778
2778
  function buildConnector({ maxCachedSessions, socketPath, timeout, ...opts }) {
@@ -2789,7 +2789,7 @@ var require_connect = __commonJS({
2789
2789
  if (!tls) {
2790
2790
  tls = require("tls");
2791
2791
  }
2792
- servername = servername || options.servername || util2.getServerName(host) || null;
2792
+ servername = servername || options.servername || util3.getServerName(host) || null;
2793
2793
  const sessionKey = servername || hostname;
2794
2794
  const session = sessionCache.get(sessionKey) || null;
2795
2795
  assert12(sessionKey);
@@ -2867,7 +2867,7 @@ var require_connect = __commonJS({
2867
2867
  };
2868
2868
  }
2869
2869
  function onConnectTimeout(socket) {
2870
- util2.destroy(socket, new ConnectTimeoutError());
2870
+ util3.destroy(socket, new ConnectTimeoutError());
2871
2871
  }
2872
2872
  module2.exports = buildConnector;
2873
2873
  }
@@ -3237,7 +3237,7 @@ var require_client = __commonJS({
3237
3237
  init_import_meta_url();
3238
3238
  var assert12 = require("assert");
3239
3239
  var net3 = require("net");
3240
- var util2 = require_util();
3240
+ var util3 = require_util();
3241
3241
  var Request2 = require_request();
3242
3242
  var DispatcherBase = require_dispatcher_base();
3243
3243
  var RedirectHandler = require_redirect();
@@ -3390,7 +3390,7 @@ var require_client = __commonJS({
3390
3390
  ...connect3
3391
3391
  });
3392
3392
  }
3393
- this[kUrl] = util2.parseOrigin(url3);
3393
+ this[kUrl] = util3.parseOrigin(url3);
3394
3394
  this[kConnector] = connect3;
3395
3395
  this[kSocket] = null;
3396
3396
  this[kPipelining] = pipelining != null ? pipelining : 1;
@@ -3450,7 +3450,7 @@ var require_client = __commonJS({
3450
3450
  const request = new Request2(origin, opts, handler2);
3451
3451
  this[kQueue].push(request);
3452
3452
  if (this[kResuming]) {
3453
- } else if (util2.bodyLength(request.body) == null && util2.isIterable(request.body)) {
3453
+ } else if (util3.bodyLength(request.body) == null && util3.isIterable(request.body)) {
3454
3454
  this[kResuming] = 1;
3455
3455
  process.nextTick(resume, this);
3456
3456
  } else {
@@ -3487,7 +3487,7 @@ var require_client = __commonJS({
3487
3487
  if (!this[kSocket]) {
3488
3488
  queueMicrotask(callback);
3489
3489
  } else {
3490
- util2.destroy(this[kSocket].on("close", callback), err2);
3490
+ util3.destroy(this[kSocket].on("close", callback), err2);
3491
3491
  }
3492
3492
  resume(this);
3493
3493
  });
@@ -3666,7 +3666,7 @@ var require_client = __commonJS({
3666
3666
  throw new HTTPParserError(message, constants3.ERROR[ret], data.slice(offset));
3667
3667
  }
3668
3668
  } catch (err2) {
3669
- util2.destroy(socket, err2);
3669
+ util3.destroy(socket, err2);
3670
3670
  }
3671
3671
  }
3672
3672
  finish() {
@@ -3677,7 +3677,7 @@ var require_client = __commonJS({
3677
3677
  currentParser = null;
3678
3678
  }
3679
3679
  } catch (err2) {
3680
- util2.destroy(this.socket, err2);
3680
+ util3.destroy(this.socket, err2);
3681
3681
  }
3682
3682
  }
3683
3683
  destroy() {
@@ -3732,7 +3732,7 @@ var require_client = __commonJS({
3732
3732
  trackHeader(len) {
3733
3733
  this.headersSize += len;
3734
3734
  if (this.headersSize >= this.headersMaxSize) {
3735
- util2.destroy(this.socket, new HeadersOverflowError());
3735
+ util3.destroy(this.socket, new HeadersOverflowError());
3736
3736
  }
3737
3737
  }
3738
3738
  onUpgrade(head) {
@@ -3762,7 +3762,7 @@ var require_client = __commonJS({
3762
3762
  try {
3763
3763
  request.onUpgrade(statusCode, headers, socket);
3764
3764
  } catch (err2) {
3765
- util2.destroy(socket, err2);
3765
+ util3.destroy(socket, err2);
3766
3766
  }
3767
3767
  resume(client);
3768
3768
  }
@@ -3778,11 +3778,11 @@ var require_client = __commonJS({
3778
3778
  assert12(!this.upgrade);
3779
3779
  assert12(this.statusCode < 200);
3780
3780
  if (statusCode === 100) {
3781
- util2.destroy(socket, new SocketError("bad response", util2.getSocketInfo(socket)));
3781
+ util3.destroy(socket, new SocketError("bad response", util3.getSocketInfo(socket)));
3782
3782
  return -1;
3783
3783
  }
3784
3784
  if (upgrade && !request.upgrade) {
3785
- util2.destroy(socket, new SocketError("bad upgrade", util2.getSocketInfo(socket)));
3785
+ util3.destroy(socket, new SocketError("bad upgrade", util3.getSocketInfo(socket)));
3786
3786
  return -1;
3787
3787
  }
3788
3788
  assert12.strictEqual(this.timeoutType, TIMEOUT_HEADERS);
@@ -3810,7 +3810,7 @@ var require_client = __commonJS({
3810
3810
  this.headers = [];
3811
3811
  this.headersSize = 0;
3812
3812
  if (shouldKeepAlive && client[kPipelining]) {
3813
- const keepAliveTimeout = this.keepAlive ? util2.parseKeepAliveTimeout(this.keepAlive) : null;
3813
+ const keepAliveTimeout = this.keepAlive ? util3.parseKeepAliveTimeout(this.keepAlive) : null;
3814
3814
  if (keepAliveTimeout != null) {
3815
3815
  const timeout = Math.min(
3816
3816
  keepAliveTimeout - client[kKeepAliveTimeoutThreshold],
@@ -3831,7 +3831,7 @@ var require_client = __commonJS({
3831
3831
  try {
3832
3832
  pause = request.onHeaders(statusCode, headers, this.resume, statusText) === false;
3833
3833
  } catch (err2) {
3834
- util2.destroy(socket, err2);
3834
+ util3.destroy(socket, err2);
3835
3835
  return -1;
3836
3836
  }
3837
3837
  if (request.method === "HEAD") {
@@ -3867,7 +3867,7 @@ var require_client = __commonJS({
3867
3867
  return constants3.ERROR.PAUSED;
3868
3868
  }
3869
3869
  } catch (err2) {
3870
- util2.destroy(socket, err2);
3870
+ util3.destroy(socket, err2);
3871
3871
  return -1;
3872
3872
  }
3873
3873
  }
@@ -3894,7 +3894,7 @@ var require_client = __commonJS({
3894
3894
  return;
3895
3895
  }
3896
3896
  if (request.method !== "HEAD" && contentLength && bytesRead !== parseInt(contentLength, 10)) {
3897
- util2.destroy(socket, new ResponseContentLengthMismatchError());
3897
+ util3.destroy(socket, new ResponseContentLengthMismatchError());
3898
3898
  return -1;
3899
3899
  }
3900
3900
  try {
@@ -3905,13 +3905,13 @@ var require_client = __commonJS({
3905
3905
  client[kQueue][client[kRunningIdx]++] = null;
3906
3906
  if (socket[kWriting]) {
3907
3907
  assert12.strictEqual(client[kRunning], 0);
3908
- util2.destroy(socket, new InformationalError("reset"));
3908
+ util3.destroy(socket, new InformationalError("reset"));
3909
3909
  return constants3.ERROR.PAUSED;
3910
3910
  } else if (!shouldKeepAlive) {
3911
- util2.destroy(socket, new InformationalError("reset"));
3911
+ util3.destroy(socket, new InformationalError("reset"));
3912
3912
  return constants3.ERROR.PAUSED;
3913
3913
  } else if (socket[kReset2] && client[kRunning] === 0) {
3914
- util2.destroy(socket, new InformationalError("reset"));
3914
+ util3.destroy(socket, new InformationalError("reset"));
3915
3915
  return constants3.ERROR.PAUSED;
3916
3916
  } else if (client[kPipelining] === 1) {
3917
3917
  setImmediate(resume, client);
@@ -3925,15 +3925,15 @@ var require_client = __commonJS({
3925
3925
  if (timeoutType === TIMEOUT_HEADERS) {
3926
3926
  if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) {
3927
3927
  assert12(!parser2.paused, "cannot be paused while waiting for headers");
3928
- util2.destroy(socket, new HeadersTimeoutError());
3928
+ util3.destroy(socket, new HeadersTimeoutError());
3929
3929
  }
3930
3930
  } else if (timeoutType === TIMEOUT_BODY) {
3931
3931
  if (!parser2.paused) {
3932
- util2.destroy(socket, new BodyTimeoutError());
3932
+ util3.destroy(socket, new BodyTimeoutError());
3933
3933
  }
3934
3934
  } else if (timeoutType === TIMEOUT_IDLE) {
3935
3935
  assert12(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]);
3936
- util2.destroy(socket, new InformationalError("socket idle timeout"));
3936
+ util3.destroy(socket, new InformationalError("socket idle timeout"));
3937
3937
  }
3938
3938
  }
3939
3939
  function onSocketReadable() {
@@ -3967,13 +3967,13 @@ var require_client = __commonJS({
3967
3967
  parser2.finish();
3968
3968
  return;
3969
3969
  }
3970
- util2.destroy(this, new SocketError("other side closed", util2.getSocketInfo(this)));
3970
+ util3.destroy(this, new SocketError("other side closed", util3.getSocketInfo(this)));
3971
3971
  }
3972
3972
  function onSocketClose() {
3973
3973
  const { [kClient]: client } = this;
3974
3974
  this[kParser].destroy();
3975
3975
  this[kParser] = null;
3976
- const err2 = this[kError] || new SocketError("closed", util2.getSocketInfo(this));
3976
+ const err2 = this[kError] || new SocketError("closed", util3.getSocketInfo(this));
3977
3977
  client[kSocket] = null;
3978
3978
  if (client.destroyed) {
3979
3979
  assert12(client[kPending] === 0);
@@ -4165,7 +4165,7 @@ var require_client = __commonJS({
4165
4165
  }
4166
4166
  client[kServerName] = request.servername;
4167
4167
  if (socket && socket.servername !== request.servername) {
4168
- util2.destroy(socket, new InformationalError("servername changed"));
4168
+ util3.destroy(socket, new InformationalError("servername changed"));
4169
4169
  return;
4170
4170
  }
4171
4171
  }
@@ -4185,17 +4185,17 @@ var require_client = __commonJS({
4185
4185
  if (client[kRunning] > 0 && (request.upgrade || request.method === "CONNECT")) {
4186
4186
  return;
4187
4187
  }
4188
- if (util2.isStream(request.body) && util2.bodyLength(request.body) === 0) {
4188
+ if (util3.isStream(request.body) && util3.bodyLength(request.body) === 0) {
4189
4189
  request.body.on("data", function() {
4190
4190
  assert12(false);
4191
4191
  }).on("error", function(err2) {
4192
4192
  errorRequest(client, request, err2);
4193
4193
  }).on("end", function() {
4194
- util2.destroy(this);
4194
+ util3.destroy(this);
4195
4195
  });
4196
4196
  request.body = null;
4197
4197
  }
4198
- if (client[kRunning] > 0 && (util2.isStream(request.body) || util2.isAsyncIterable(request.body))) {
4198
+ if (client[kRunning] > 0 && (util3.isStream(request.body) || util3.isAsyncIterable(request.body))) {
4199
4199
  return;
4200
4200
  }
4201
4201
  if (!request.aborted && write(client, request)) {
@@ -4211,7 +4211,7 @@ var require_client = __commonJS({
4211
4211
  if (body && typeof body.read === "function") {
4212
4212
  body.read(0);
4213
4213
  }
4214
- let contentLength = util2.bodyLength(body);
4214
+ let contentLength = util3.bodyLength(body);
4215
4215
  if (contentLength === null) {
4216
4216
  contentLength = request.contentLength;
4217
4217
  }
@@ -4232,7 +4232,7 @@ var require_client = __commonJS({
4232
4232
  return;
4233
4233
  }
4234
4234
  errorRequest(client, request, err2 || new RequestAbortedError());
4235
- util2.destroy(socket, new InformationalError("aborted"));
4235
+ util3.destroy(socket, new InformationalError("aborted"));
4236
4236
  });
4237
4237
  } catch (err2) {
4238
4238
  errorRequest(client, request, err2);
@@ -4286,7 +4286,7 @@ upgrade: ${upgrade}\r
4286
4286
  `, "ascii");
4287
4287
  }
4288
4288
  request.onRequestSent();
4289
- } else if (util2.isBuffer(body)) {
4289
+ } else if (util3.isBuffer(body)) {
4290
4290
  assert12(contentLength === body.byteLength, "buffer body must have content length");
4291
4291
  socket.cork();
4292
4292
  socket.write(`${header}content-length: ${contentLength}\r
@@ -4299,15 +4299,15 @@ upgrade: ${upgrade}\r
4299
4299
  if (!expectsPayload) {
4300
4300
  socket[kReset2] = true;
4301
4301
  }
4302
- } else if (util2.isBlobLike(body)) {
4302
+ } else if (util3.isBlobLike(body)) {
4303
4303
  if (typeof body.stream === "function") {
4304
4304
  writeIterable({ body: body.stream(), client, request, socket, contentLength, header, expectsPayload });
4305
4305
  } else {
4306
4306
  writeBlob({ body, client, request, socket, contentLength, header, expectsPayload });
4307
4307
  }
4308
- } else if (util2.isStream(body)) {
4308
+ } else if (util3.isStream(body)) {
4309
4309
  writeStream({ body, client, request, socket, contentLength, header, expectsPayload });
4310
- } else if (util2.isIterable(body)) {
4310
+ } else if (util3.isIterable(body)) {
4311
4311
  writeIterable({ body, client, request, socket, contentLength, header, expectsPayload });
4312
4312
  } else {
4313
4313
  assert12(false);
@@ -4325,7 +4325,7 @@ upgrade: ${upgrade}\r
4325
4325
  this.pause();
4326
4326
  }
4327
4327
  } catch (err2) {
4328
- util2.destroy(this, err2);
4328
+ util3.destroy(this, err2);
4329
4329
  }
4330
4330
  };
4331
4331
  const onDrain = function() {
@@ -4354,9 +4354,9 @@ upgrade: ${upgrade}\r
4354
4354
  }
4355
4355
  writer.destroy(err2);
4356
4356
  if (err2 && (err2.code !== "UND_ERR_INFO" || err2.message !== "reset")) {
4357
- util2.destroy(body, err2);
4357
+ util3.destroy(body, err2);
4358
4358
  } else {
4359
- util2.destroy(body);
4359
+ util3.destroy(body);
4360
4360
  }
4361
4361
  };
4362
4362
  body.on("data", onData).on("end", onFinished).on("error", onFinished).on("close", onAbort);
@@ -4385,7 +4385,7 @@ upgrade: ${upgrade}\r
4385
4385
  }
4386
4386
  resume(client);
4387
4387
  } catch (err2) {
4388
- util2.destroy(socket, err2);
4388
+ util3.destroy(socket, err2);
4389
4389
  }
4390
4390
  }
4391
4391
  async function writeIterable({ body, client, request, socket, contentLength, header, expectsPayload }) {
@@ -4524,7 +4524,7 @@ ${len.toString(16)}\r
4524
4524
  socket[kWriting] = false;
4525
4525
  if (err2) {
4526
4526
  assert12(client[kRunning] <= 1, "pipeline should only contain this request");
4527
- util2.destroy(socket, err2);
4527
+ util3.destroy(socket, err2);
4528
4528
  }
4529
4529
  }
4530
4530
  };
@@ -4803,7 +4803,7 @@ var require_pool = __commonJS({
4803
4803
  var {
4804
4804
  InvalidArgumentError
4805
4805
  } = require_errors();
4806
- var util2 = require_util();
4806
+ var util3 = require_util();
4807
4807
  var { kUrl } = require_symbols();
4808
4808
  var buildConnector = require_connect();
4809
4809
  var kOptions = Symbol("options");
@@ -4843,8 +4843,8 @@ var require_pool = __commonJS({
4843
4843
  });
4844
4844
  }
4845
4845
  this[kConnections] = connections || null;
4846
- this[kUrl] = util2.parseOrigin(origin);
4847
- this[kOptions] = { ...util2.deepClone(options), connect: connect2 };
4846
+ this[kUrl] = util3.parseOrigin(origin);
4847
+ this[kOptions] = { ...util3.deepClone(options), connect: connect2 };
4848
4848
  this[kFactory] = factory;
4849
4849
  }
4850
4850
  [kGetDispatcher]() {
@@ -5044,7 +5044,7 @@ var require_agent = __commonJS({
5044
5044
  var DispatcherBase = require_dispatcher_base();
5045
5045
  var Pool2 = require_pool();
5046
5046
  var Client = require_client();
5047
- var util2 = require_util();
5047
+ var util3 = require_util();
5048
5048
  var RedirectHandler = require_redirect();
5049
5049
  var { WeakRef: WeakRef2, FinalizationRegistry: FinalizationRegistry2 } = require_dispatcher_weakref()();
5050
5050
  var kOnConnect = Symbol("onConnect");
@@ -5073,7 +5073,7 @@ var require_agent = __commonJS({
5073
5073
  if (connect2 && typeof connect2 !== "function") {
5074
5074
  connect2 = { ...connect2 };
5075
5075
  }
5076
- this[kOptions] = { ...util2.deepClone(options), connect: connect2 };
5076
+ this[kOptions] = { ...util3.deepClone(options), connect: connect2 };
5077
5077
  this[kMaxRedirections] = maxRedirections;
5078
5078
  this[kFactory] = factory;
5079
5079
  this[kClients] = /* @__PURE__ */ new Map();
@@ -5161,7 +5161,7 @@ var require_readable = __commonJS({
5161
5161
  var assert12 = require("assert");
5162
5162
  var { Readable: Readable2 } = require("stream");
5163
5163
  var { RequestAbortedError, NotSupportedError } = require_errors();
5164
- var util2 = require_util();
5164
+ var util3 = require_util();
5165
5165
  var { ReadableStreamFrom, toUSVString } = require_util();
5166
5166
  var Blob3;
5167
5167
  var kConsume = Symbol("kConsume");
@@ -5245,7 +5245,7 @@ var require_readable = __commonJS({
5245
5245
  throw new NotSupportedError();
5246
5246
  }
5247
5247
  get bodyUsed() {
5248
- return util2.isDisturbed(this);
5248
+ return util3.isDisturbed(this);
5249
5249
  }
5250
5250
  get body() {
5251
5251
  if (!this[kBody]) {
@@ -5274,7 +5274,7 @@ var require_readable = __commonJS({
5274
5274
  return self2[kBody] && self2[kBody].locked === true || self2[kConsume];
5275
5275
  }
5276
5276
  function isUnusable(self2) {
5277
- return util2.isDisturbed(self2) || isLocked(self2);
5277
+ return util3.isDisturbed(self2) || isLocked(self2);
5278
5278
  }
5279
5279
  async function consume(stream2, type2) {
5280
5280
  if (isUnusable(stream2)) {
@@ -5432,7 +5432,7 @@ var require_api_request = __commonJS({
5432
5432
  RequestAbortedError,
5433
5433
  ResponseStatusCodeError
5434
5434
  } = require_errors();
5435
- var util2 = require_util();
5435
+ var util3 = require_util();
5436
5436
  var { AsyncResource } = require("async_hooks");
5437
5437
  var { addSignal, removeSignal } = require_abort_signal();
5438
5438
  var RequestHandler = class extends AsyncResource {
@@ -5456,8 +5456,8 @@ var require_api_request = __commonJS({
5456
5456
  }
5457
5457
  super("UNDICI_REQUEST");
5458
5458
  } catch (err2) {
5459
- if (util2.isStream(body)) {
5460
- util2.destroy(body.on("error", util2.nop), err2);
5459
+ if (util3.isStream(body)) {
5460
+ util3.destroy(body.on("error", util3.nop), err2);
5461
5461
  }
5462
5462
  throw err2;
5463
5463
  }
@@ -5471,7 +5471,7 @@ var require_api_request = __commonJS({
5471
5471
  this.context = null;
5472
5472
  this.onInfo = onInfo || null;
5473
5473
  this.throwOnError = throwOnError;
5474
- if (util2.isStream(body)) {
5474
+ if (util3.isStream(body)) {
5475
5475
  body.on("error", (err2) => {
5476
5476
  this.onError(err2);
5477
5477
  });
@@ -5489,17 +5489,17 @@ var require_api_request = __commonJS({
5489
5489
  const { callback, opaque, abort: abort2, context } = this;
5490
5490
  if (statusCode < 200) {
5491
5491
  if (this.onInfo) {
5492
- const headers2 = this.responseHeaders === "raw" ? util2.parseRawHeaders(rawHeaders) : util2.parseHeaders(rawHeaders);
5492
+ const headers2 = this.responseHeaders === "raw" ? util3.parseRawHeaders(rawHeaders) : util3.parseHeaders(rawHeaders);
5493
5493
  this.onInfo({ statusCode, headers: headers2 });
5494
5494
  }
5495
5495
  return;
5496
5496
  }
5497
- const parsedHeaders = util2.parseHeaders(rawHeaders);
5497
+ const parsedHeaders = util3.parseHeaders(rawHeaders);
5498
5498
  const contentType = parsedHeaders["content-type"];
5499
5499
  const body = new Readable2(resume, abort2, contentType);
5500
5500
  this.callback = null;
5501
5501
  this.res = body;
5502
- const headers = this.responseHeaders === "raw" ? util2.parseRawHeaders(rawHeaders) : util2.parseHeaders(rawHeaders);
5502
+ const headers = this.responseHeaders === "raw" ? util3.parseRawHeaders(rawHeaders) : util3.parseHeaders(rawHeaders);
5503
5503
  if (callback !== null) {
5504
5504
  if (this.throwOnError && statusCode >= 400) {
5505
5505
  this.runInAsyncScope(
@@ -5526,7 +5526,7 @@ var require_api_request = __commonJS({
5526
5526
  onComplete(trailers) {
5527
5527
  const { res } = this;
5528
5528
  removeSignal(this);
5529
- util2.parseHeaders(trailers, this.trailers);
5529
+ util3.parseHeaders(trailers, this.trailers);
5530
5530
  res.push(null);
5531
5531
  }
5532
5532
  onError(err2) {
@@ -5541,12 +5541,12 @@ var require_api_request = __commonJS({
5541
5541
  if (res) {
5542
5542
  this.res = null;
5543
5543
  queueMicrotask(() => {
5544
- util2.destroy(res, err2);
5544
+ util3.destroy(res, err2);
5545
5545
  });
5546
5546
  }
5547
5547
  if (body) {
5548
5548
  this.body = null;
5549
- util2.destroy(body, err2);
5549
+ util3.destroy(body, err2);
5550
5550
  }
5551
5551
  }
5552
5552
  };
@@ -5605,7 +5605,7 @@ var require_api_stream = __commonJS({
5605
5605
  InvalidReturnValueError,
5606
5606
  RequestAbortedError
5607
5607
  } = require_errors();
5608
- var util2 = require_util();
5608
+ var util3 = require_util();
5609
5609
  var { AsyncResource } = require("async_hooks");
5610
5610
  var { addSignal, removeSignal } = require_abort_signal();
5611
5611
  var StreamHandler = class extends AsyncResource {
@@ -5632,8 +5632,8 @@ var require_api_stream = __commonJS({
5632
5632
  }
5633
5633
  super("UNDICI_STREAM");
5634
5634
  } catch (err2) {
5635
- if (util2.isStream(body)) {
5636
- util2.destroy(body.on("error", util2.nop), err2);
5635
+ if (util3.isStream(body)) {
5636
+ util3.destroy(body.on("error", util3.nop), err2);
5637
5637
  }
5638
5638
  throw err2;
5639
5639
  }
@@ -5647,7 +5647,7 @@ var require_api_stream = __commonJS({
5647
5647
  this.trailers = null;
5648
5648
  this.body = body;
5649
5649
  this.onInfo = onInfo || null;
5650
- if (util2.isStream(body)) {
5650
+ if (util3.isStream(body)) {
5651
5651
  body.on("error", (err2) => {
5652
5652
  this.onError(err2);
5653
5653
  });
@@ -5665,13 +5665,13 @@ var require_api_stream = __commonJS({
5665
5665
  const { factory, opaque, context } = this;
5666
5666
  if (statusCode < 200) {
5667
5667
  if (this.onInfo) {
5668
- const headers2 = this.responseHeaders === "raw" ? util2.parseRawHeaders(rawHeaders) : util2.parseHeaders(rawHeaders);
5668
+ const headers2 = this.responseHeaders === "raw" ? util3.parseRawHeaders(rawHeaders) : util3.parseHeaders(rawHeaders);
5669
5669
  this.onInfo({ statusCode, headers: headers2 });
5670
5670
  }
5671
5671
  return;
5672
5672
  }
5673
5673
  this.factory = null;
5674
- const headers = this.responseHeaders === "raw" ? util2.parseRawHeaders(rawHeaders) : util2.parseHeaders(rawHeaders);
5674
+ const headers = this.responseHeaders === "raw" ? util3.parseRawHeaders(rawHeaders) : util3.parseHeaders(rawHeaders);
5675
5675
  const res = this.runInAsyncScope(factory, null, {
5676
5676
  statusCode,
5677
5677
  headers,
@@ -5686,7 +5686,7 @@ var require_api_stream = __commonJS({
5686
5686
  const { callback, res: res2, opaque: opaque2, trailers, abort: abort2 } = this;
5687
5687
  this.res = null;
5688
5688
  if (err2 || !res2.readable) {
5689
- util2.destroy(res2, err2);
5689
+ util3.destroy(res2, err2);
5690
5690
  }
5691
5691
  this.callback = null;
5692
5692
  this.runInAsyncScope(callback, null, err2 || null, { opaque: opaque2, trailers });
@@ -5705,7 +5705,7 @@ var require_api_stream = __commonJS({
5705
5705
  onComplete(trailers) {
5706
5706
  const { res } = this;
5707
5707
  removeSignal(this);
5708
- this.trailers = util2.parseHeaders(trailers);
5708
+ this.trailers = util3.parseHeaders(trailers);
5709
5709
  res.end();
5710
5710
  }
5711
5711
  onError(err2) {
@@ -5714,7 +5714,7 @@ var require_api_stream = __commonJS({
5714
5714
  this.factory = null;
5715
5715
  if (res) {
5716
5716
  this.res = null;
5717
- util2.destroy(res, err2);
5717
+ util3.destroy(res, err2);
5718
5718
  } else if (callback) {
5719
5719
  this.callback = null;
5720
5720
  queueMicrotask(() => {
@@ -5723,7 +5723,7 @@ var require_api_stream = __commonJS({
5723
5723
  }
5724
5724
  if (body) {
5725
5725
  this.body = null;
5726
- util2.destroy(body, err2);
5726
+ util3.destroy(body, err2);
5727
5727
  }
5728
5728
  }
5729
5729
  };
@@ -5764,7 +5764,7 @@ var require_api_pipeline = __commonJS({
5764
5764
  InvalidReturnValueError,
5765
5765
  RequestAbortedError
5766
5766
  } = require_errors();
5767
- var util2 = require_util();
5767
+ var util3 = require_util();
5768
5768
  var { AsyncResource } = require("async_hooks");
5769
5769
  var { addSignal, removeSignal } = require_abort_signal();
5770
5770
  var assert12 = require("assert");
@@ -5826,7 +5826,7 @@ var require_api_pipeline = __commonJS({
5826
5826
  this.abort = null;
5827
5827
  this.context = null;
5828
5828
  this.onInfo = onInfo || null;
5829
- this.req = new PipelineRequest().on("error", util2.nop);
5829
+ this.req = new PipelineRequest().on("error", util3.nop);
5830
5830
  this.ret = new Duplex({
5831
5831
  readableObjectMode: opts.objectMode,
5832
5832
  autoDestroy: true,
@@ -5852,9 +5852,9 @@ var require_api_pipeline = __commonJS({
5852
5852
  if (abort2 && err2) {
5853
5853
  abort2();
5854
5854
  }
5855
- util2.destroy(body, err2);
5856
- util2.destroy(req, err2);
5857
- util2.destroy(res, err2);
5855
+ util3.destroy(body, err2);
5856
+ util3.destroy(req, err2);
5857
+ util3.destroy(res, err2);
5858
5858
  removeSignal(this);
5859
5859
  callback(err2);
5860
5860
  }
@@ -5878,7 +5878,7 @@ var require_api_pipeline = __commonJS({
5878
5878
  const { opaque, handler: handler2, context } = this;
5879
5879
  if (statusCode < 200) {
5880
5880
  if (this.onInfo) {
5881
- const headers = this.responseHeaders === "raw" ? util2.parseRawHeaders(rawHeaders) : util2.parseHeaders(rawHeaders);
5881
+ const headers = this.responseHeaders === "raw" ? util3.parseRawHeaders(rawHeaders) : util3.parseHeaders(rawHeaders);
5882
5882
  this.onInfo({ statusCode, headers });
5883
5883
  }
5884
5884
  return;
@@ -5887,7 +5887,7 @@ var require_api_pipeline = __commonJS({
5887
5887
  let body;
5888
5888
  try {
5889
5889
  this.handler = null;
5890
- const headers = this.responseHeaders === "raw" ? util2.parseRawHeaders(rawHeaders) : util2.parseHeaders(rawHeaders);
5890
+ const headers = this.responseHeaders === "raw" ? util3.parseRawHeaders(rawHeaders) : util3.parseHeaders(rawHeaders);
5891
5891
  body = this.runInAsyncScope(handler2, null, {
5892
5892
  statusCode,
5893
5893
  headers,
@@ -5896,7 +5896,7 @@ var require_api_pipeline = __commonJS({
5896
5896
  context
5897
5897
  });
5898
5898
  } catch (err2) {
5899
- this.res.on("error", util2.nop);
5899
+ this.res.on("error", util3.nop);
5900
5900
  throw err2;
5901
5901
  }
5902
5902
  if (!body || typeof body.on !== "function") {
@@ -5909,14 +5909,14 @@ var require_api_pipeline = __commonJS({
5909
5909
  }
5910
5910
  }).on("error", (err2) => {
5911
5911
  const { ret } = this;
5912
- util2.destroy(ret, err2);
5912
+ util3.destroy(ret, err2);
5913
5913
  }).on("end", () => {
5914
5914
  const { ret } = this;
5915
5915
  ret.push(null);
5916
5916
  }).on("close", () => {
5917
5917
  const { ret } = this;
5918
5918
  if (!ret._readableState.ended) {
5919
- util2.destroy(ret, new RequestAbortedError());
5919
+ util3.destroy(ret, new RequestAbortedError());
5920
5920
  }
5921
5921
  });
5922
5922
  this.body = body;
@@ -5932,7 +5932,7 @@ var require_api_pipeline = __commonJS({
5932
5932
  onError(err2) {
5933
5933
  const { ret } = this;
5934
5934
  this.handler = null;
5935
- util2.destroy(ret, err2);
5935
+ util3.destroy(ret, err2);
5936
5936
  }
5937
5937
  };
5938
5938
  function pipeline2(opts, handler2) {
@@ -5955,7 +5955,7 @@ var require_api_upgrade = __commonJS({
5955
5955
  init_import_meta_url();
5956
5956
  var { InvalidArgumentError, RequestAbortedError, SocketError } = require_errors();
5957
5957
  var { AsyncResource } = require("async_hooks");
5958
- var util2 = require_util();
5958
+ var util3 = require_util();
5959
5959
  var { addSignal, removeSignal } = require_abort_signal();
5960
5960
  var assert12 = require("assert");
5961
5961
  var UpgradeHandler = class extends AsyncResource {
@@ -5993,7 +5993,7 @@ var require_api_upgrade = __commonJS({
5993
5993
  assert12.strictEqual(statusCode, 101);
5994
5994
  removeSignal(this);
5995
5995
  this.callback = null;
5996
- const headers = this.responseHeaders === "raw" ? util2.parseRawHeaders(rawHeaders) : util2.parseHeaders(rawHeaders);
5996
+ const headers = this.responseHeaders === "raw" ? util3.parseRawHeaders(rawHeaders) : util3.parseHeaders(rawHeaders);
5997
5997
  this.runInAsyncScope(callback, null, null, {
5998
5998
  headers,
5999
5999
  socket,
@@ -6046,7 +6046,7 @@ var require_api_connect = __commonJS({
6046
6046
  init_import_meta_url();
6047
6047
  var { InvalidArgumentError, RequestAbortedError, SocketError } = require_errors();
6048
6048
  var { AsyncResource } = require("async_hooks");
6049
- var util2 = require_util();
6049
+ var util3 = require_util();
6050
6050
  var { addSignal, removeSignal } = require_abort_signal();
6051
6051
  var ConnectHandler = class extends AsyncResource {
6052
6052
  constructor(opts, callback) {
@@ -6081,7 +6081,7 @@ var require_api_connect = __commonJS({
6081
6081
  const { callback, opaque, context } = this;
6082
6082
  removeSignal(this);
6083
6083
  this.callback = null;
6084
- const headers = this.responseHeaders === "raw" ? util2.parseRawHeaders(rawHeaders) : util2.parseHeaders(rawHeaders);
6084
+ const headers = this.responseHeaders === "raw" ? util3.parseRawHeaders(rawHeaders) : util3.parseHeaders(rawHeaders);
6085
6085
  this.runInAsyncScope(callback, null, null, {
6086
6086
  statusCode,
6087
6087
  headers,
@@ -7508,8 +7508,8 @@ var require_response = __commonJS({
7508
7508
  init_import_meta_url();
7509
7509
  var { Headers: Headers2, HeadersList, fill } = require_headers();
7510
7510
  var { extractBody, cloneBody, mixinBody } = require_body();
7511
- var util2 = require_util();
7512
- var { kEnumerableProperty } = util2;
7511
+ var util3 = require_util();
7512
+ var { kEnumerableProperty } = util3;
7513
7513
  var {
7514
7514
  responseURL,
7515
7515
  isValidReasonPhrase,
@@ -7885,7 +7885,7 @@ var require_request2 = __commonJS({
7885
7885
  init_import_meta_url();
7886
7886
  var { extractBody, mixinBody, cloneBody } = require_body();
7887
7887
  var { Headers: Headers2, fill: fillHeaders, HeadersList } = require_headers();
7888
- var util2 = require_util();
7888
+ var util3 = require_util();
7889
7889
  var {
7890
7890
  isValidHTTPToken,
7891
7891
  sameOrigin,
@@ -7900,7 +7900,7 @@ var require_request2 = __commonJS({
7900
7900
  requestCredentials,
7901
7901
  requestCache
7902
7902
  } = require_constants();
7903
- var { kEnumerableProperty } = util2;
7903
+ var { kEnumerableProperty } = util3;
7904
7904
  var { kHeaders, kSignal, kState, kGuard, kRealm } = require_symbols2();
7905
7905
  var { webidl } = require_webidl();
7906
7906
  var { kHeadersList } = require_symbols();
@@ -8150,7 +8150,7 @@ var require_request2 = __commonJS({
8150
8150
  }
8151
8151
  let finalBody = inputOrInitBody;
8152
8152
  if (initBody == null && inputBody != null) {
8153
- if (util2.isDisturbed(inputBody.stream) || inputBody.stream.locked) {
8153
+ if (util3.isDisturbed(inputBody.stream) || inputBody.stream.locked) {
8154
8154
  throw new TypeError(
8155
8155
  "Cannot construct a Request with a Request object that has already been used."
8156
8156
  );
@@ -9680,7 +9680,7 @@ var require_undici = __commonJS({
9680
9680
  var Pool2 = require_pool();
9681
9681
  var BalancedPool = require_balanced_pool();
9682
9682
  var Agent = require_agent();
9683
- var util2 = require_util();
9683
+ var util3 = require_util();
9684
9684
  var { InvalidArgumentError } = errors;
9685
9685
  var api = require_api();
9686
9686
  var buildConnector = require_connect();
@@ -9722,12 +9722,12 @@ var require_undici = __commonJS({
9722
9722
  if (!opts.path.startsWith("/")) {
9723
9723
  path30 = `/${path30}`;
9724
9724
  }
9725
- url3 = new URL(util2.parseOrigin(url3).origin + path30);
9725
+ url3 = new URL(util3.parseOrigin(url3).origin + path30);
9726
9726
  } else {
9727
9727
  if (!opts) {
9728
9728
  opts = typeof url3 === "object" ? url3 : {};
9729
9729
  }
9730
- url3 = util2.parseURL(url3);
9730
+ url3 = util3.parseURL(url3);
9731
9731
  }
9732
9732
  const { agent, dispatcher = getGlobalDispatcher() } = opts;
9733
9733
  if (agent) {
@@ -77538,14 +77538,14 @@ var require_inherits = __commonJS({
77538
77538
  "../../node_modules/inherits/inherits.js"(exports2, module2) {
77539
77539
  init_import_meta_url();
77540
77540
  try {
77541
- util2 = require("util");
77542
- if (typeof util2.inherits !== "function")
77541
+ util3 = require("util");
77542
+ if (typeof util3.inherits !== "function")
77543
77543
  throw "";
77544
- module2.exports = util2.inherits;
77544
+ module2.exports = util3.inherits;
77545
77545
  } catch (e2) {
77546
77546
  module2.exports = require_inherits_browser();
77547
77547
  }
77548
- var util2;
77548
+ var util3;
77549
77549
  }
77550
77550
  });
77551
77551
 
@@ -77774,7 +77774,7 @@ var require_sync = __commonJS({
77774
77774
  var minimatch = require_minimatch();
77775
77775
  var Minimatch = minimatch.Minimatch;
77776
77776
  var Glob = require_glob().Glob;
77777
- var util2 = require("util");
77777
+ var util3 = require("util");
77778
77778
  var path30 = require("path");
77779
77779
  var assert12 = require("assert");
77780
77780
  var isAbsolute = require_path_is_absolute();
@@ -78259,7 +78259,7 @@ var require_glob = __commonJS({
78259
78259
  var setopts = common.setopts;
78260
78260
  var ownProp = common.ownProp;
78261
78261
  var inflight = require_inflight();
78262
- var util2 = require("util");
78262
+ var util3 = require("util");
78263
78263
  var childrenIgnored = common.childrenIgnored;
78264
78264
  var isIgnored = common.isIgnored;
78265
78265
  var once = require_once();
@@ -80599,7 +80599,7 @@ var require_node = __commonJS({
80599
80599
  "../../node_modules/body-parser/node_modules/debug/src/node.js"(exports2, module2) {
80600
80600
  init_import_meta_url();
80601
80601
  var tty2 = require("tty");
80602
- var util2 = require("util");
80602
+ var util3 = require("util");
80603
80603
  exports2 = module2.exports = require_debug();
80604
80604
  exports2.init = init;
80605
80605
  exports2.log = log;
@@ -80628,7 +80628,7 @@ var require_node = __commonJS({
80628
80628
  }, {});
80629
80629
  var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
80630
80630
  if (1 !== fd && 2 !== fd) {
80631
- util2.deprecate(function() {
80631
+ util3.deprecate(function() {
80632
80632
  }, "except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)")();
80633
80633
  }
80634
80634
  var stream2 = 1 === fd ? process.stdout : 2 === fd ? process.stderr : createWritableStdioStream(fd);
@@ -80637,13 +80637,13 @@ var require_node = __commonJS({
80637
80637
  }
80638
80638
  exports2.formatters.o = function(v) {
80639
80639
  this.inspectOpts.colors = this.useColors;
80640
- return util2.inspect(v, this.inspectOpts).split("\n").map(function(str) {
80640
+ return util3.inspect(v, this.inspectOpts).split("\n").map(function(str) {
80641
80641
  return str.trim();
80642
80642
  }).join(" ");
80643
80643
  };
80644
80644
  exports2.formatters.O = function(v) {
80645
80645
  this.inspectOpts.colors = this.useColors;
80646
- return util2.inspect(v, this.inspectOpts);
80646
+ return util3.inspect(v, this.inspectOpts);
80647
80647
  };
80648
80648
  function formatArgs(args) {
80649
80649
  var name = this.namespace;
@@ -80658,7 +80658,7 @@ var require_node = __commonJS({
80658
80658
  }
80659
80659
  }
80660
80660
  function log() {
80661
- return stream2.write(util2.format.apply(util2, arguments) + "\n");
80661
+ return stream2.write(util3.format.apply(util3, arguments) + "\n");
80662
80662
  }
80663
80663
  function save(namespaces) {
80664
80664
  if (null == namespaces) {
@@ -96243,7 +96243,7 @@ var require_node2 = __commonJS({
96243
96243
  "../../node_modules/finalhandler/node_modules/debug/src/node.js"(exports2, module2) {
96244
96244
  init_import_meta_url();
96245
96245
  var tty2 = require("tty");
96246
- var util2 = require("util");
96246
+ var util3 = require("util");
96247
96247
  exports2 = module2.exports = require_debug2();
96248
96248
  exports2.init = init;
96249
96249
  exports2.log = log;
@@ -96272,7 +96272,7 @@ var require_node2 = __commonJS({
96272
96272
  }, {});
96273
96273
  var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
96274
96274
  if (1 !== fd && 2 !== fd) {
96275
- util2.deprecate(function() {
96275
+ util3.deprecate(function() {
96276
96276
  }, "except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)")();
96277
96277
  }
96278
96278
  var stream2 = 1 === fd ? process.stdout : 2 === fd ? process.stderr : createWritableStdioStream(fd);
@@ -96281,13 +96281,13 @@ var require_node2 = __commonJS({
96281
96281
  }
96282
96282
  exports2.formatters.o = function(v) {
96283
96283
  this.inspectOpts.colors = this.useColors;
96284
- return util2.inspect(v, this.inspectOpts).split("\n").map(function(str) {
96284
+ return util3.inspect(v, this.inspectOpts).split("\n").map(function(str) {
96285
96285
  return str.trim();
96286
96286
  }).join(" ");
96287
96287
  };
96288
96288
  exports2.formatters.O = function(v) {
96289
96289
  this.inspectOpts.colors = this.useColors;
96290
- return util2.inspect(v, this.inspectOpts);
96290
+ return util3.inspect(v, this.inspectOpts);
96291
96291
  };
96292
96292
  function formatArgs(args) {
96293
96293
  var name = this.namespace;
@@ -96302,7 +96302,7 @@ var require_node2 = __commonJS({
96302
96302
  }
96303
96303
  }
96304
96304
  function log() {
96305
- return stream2.write(util2.format.apply(util2, arguments) + "\n");
96305
+ return stream2.write(util3.format.apply(util3, arguments) + "\n");
96306
96306
  }
96307
96307
  function save(namespaces) {
96308
96308
  if (null == namespaces) {
@@ -96967,7 +96967,7 @@ var require_node3 = __commonJS({
96967
96967
  "../../node_modules/express/node_modules/debug/src/node.js"(exports2, module2) {
96968
96968
  init_import_meta_url();
96969
96969
  var tty2 = require("tty");
96970
- var util2 = require("util");
96970
+ var util3 = require("util");
96971
96971
  exports2 = module2.exports = require_debug3();
96972
96972
  exports2.init = init;
96973
96973
  exports2.log = log;
@@ -96996,7 +96996,7 @@ var require_node3 = __commonJS({
96996
96996
  }, {});
96997
96997
  var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
96998
96998
  if (1 !== fd && 2 !== fd) {
96999
- util2.deprecate(function() {
96999
+ util3.deprecate(function() {
97000
97000
  }, "except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)")();
97001
97001
  }
97002
97002
  var stream2 = 1 === fd ? process.stdout : 2 === fd ? process.stderr : createWritableStdioStream(fd);
@@ -97005,13 +97005,13 @@ var require_node3 = __commonJS({
97005
97005
  }
97006
97006
  exports2.formatters.o = function(v) {
97007
97007
  this.inspectOpts.colors = this.useColors;
97008
- return util2.inspect(v, this.inspectOpts).split("\n").map(function(str) {
97008
+ return util3.inspect(v, this.inspectOpts).split("\n").map(function(str) {
97009
97009
  return str.trim();
97010
97010
  }).join(" ");
97011
97011
  };
97012
97012
  exports2.formatters.O = function(v) {
97013
97013
  this.inspectOpts.colors = this.useColors;
97014
- return util2.inspect(v, this.inspectOpts);
97014
+ return util3.inspect(v, this.inspectOpts);
97015
97015
  };
97016
97016
  function formatArgs(args) {
97017
97017
  var name = this.namespace;
@@ -97026,7 +97026,7 @@ var require_node3 = __commonJS({
97026
97026
  }
97027
97027
  }
97028
97028
  function log() {
97029
- return stream2.write(util2.format.apply(util2, arguments) + "\n");
97029
+ return stream2.write(util3.format.apply(util3, arguments) + "\n");
97030
97030
  }
97031
97031
  function save(namespaces) {
97032
97032
  if (null == namespaces) {
@@ -98587,7 +98587,7 @@ var require_node4 = __commonJS({
98587
98587
  "../../node_modules/send/node_modules/debug/src/node.js"(exports2, module2) {
98588
98588
  init_import_meta_url();
98589
98589
  var tty2 = require("tty");
98590
- var util2 = require("util");
98590
+ var util3 = require("util");
98591
98591
  exports2 = module2.exports = require_debug4();
98592
98592
  exports2.init = init;
98593
98593
  exports2.log = log;
@@ -98616,7 +98616,7 @@ var require_node4 = __commonJS({
98616
98616
  }, {});
98617
98617
  var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
98618
98618
  if (1 !== fd && 2 !== fd) {
98619
- util2.deprecate(function() {
98619
+ util3.deprecate(function() {
98620
98620
  }, "except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)")();
98621
98621
  }
98622
98622
  var stream2 = 1 === fd ? process.stdout : 2 === fd ? process.stderr : createWritableStdioStream(fd);
@@ -98625,13 +98625,13 @@ var require_node4 = __commonJS({
98625
98625
  }
98626
98626
  exports2.formatters.o = function(v) {
98627
98627
  this.inspectOpts.colors = this.useColors;
98628
- return util2.inspect(v, this.inspectOpts).split("\n").map(function(str) {
98628
+ return util3.inspect(v, this.inspectOpts).split("\n").map(function(str) {
98629
98629
  return str.trim();
98630
98630
  }).join(" ");
98631
98631
  };
98632
98632
  exports2.formatters.O = function(v) {
98633
98633
  this.inspectOpts.colors = this.useColors;
98634
- return util2.inspect(v, this.inspectOpts);
98634
+ return util3.inspect(v, this.inspectOpts);
98635
98635
  };
98636
98636
  function formatArgs(args) {
98637
98637
  var name = this.namespace;
@@ -98646,7 +98646,7 @@ var require_node4 = __commonJS({
98646
98646
  }
98647
98647
  }
98648
98648
  function log() {
98649
- return stream2.write(util2.format.apply(util2, arguments) + "\n");
98649
+ return stream2.write(util3.format.apply(util3, arguments) + "\n");
98650
98650
  }
98651
98651
  function save(namespaces) {
98652
98652
  if (null == namespaces) {
@@ -99118,7 +99118,7 @@ var require_send = __commonJS({
99118
99118
  var path30 = require("path");
99119
99119
  var statuses = require_statuses();
99120
99120
  var Stream = require("stream");
99121
- var util2 = require("util");
99121
+ var util3 = require("util");
99122
99122
  var extname5 = path30.extname;
99123
99123
  var join12 = path30.join;
99124
99124
  var normalize2 = path30.normalize;
@@ -99164,7 +99164,7 @@ var require_send = __commonJS({
99164
99164
  this.from(opts.from);
99165
99165
  }
99166
99166
  }
99167
- util2.inherits(SendStream, Stream);
99167
+ util3.inherits(SendStream, Stream);
99168
99168
  SendStream.prototype.etag = deprecate.function(function etag2(val) {
99169
99169
  this._etag = Boolean(val);
99170
99170
  debug("etag %s", this._etag);
@@ -104132,10 +104132,10 @@ var require_schema_obj = __commonJS({
104132
104132
  "../../node_modules/ajv/lib/compile/schema_obj.js"(exports2, module2) {
104133
104133
  "use strict";
104134
104134
  init_import_meta_url();
104135
- var util2 = require_util4();
104135
+ var util3 = require_util4();
104136
104136
  module2.exports = SchemaObject;
104137
104137
  function SchemaObject(obj) {
104138
- util2.copy(obj, this);
104138
+ util3.copy(obj, this);
104139
104139
  }
104140
104140
  }
104141
104141
  });
@@ -104232,7 +104232,7 @@ var require_resolve = __commonJS({
104232
104232
  init_import_meta_url();
104233
104233
  var URI = require_uri_all();
104234
104234
  var equal = require_fast_deep_equal();
104235
- var util2 = require_util4();
104235
+ var util3 = require_util4();
104236
104236
  var SchemaObject = require_schema_obj();
104237
104237
  var traverse = require_json_schema_traverse();
104238
104238
  module2.exports = resolve14;
@@ -104309,7 +104309,7 @@ var require_resolve = __commonJS({
104309
104309
  return getJsonPointer.call(this, parsedRef, baseId, schema, root);
104310
104310
  }
104311
104311
  }
104312
- var PREVENT_SCOPE_CHANGE = util2.toHash(["properties", "patternProperties", "enum", "dependencies", "definitions"]);
104312
+ var PREVENT_SCOPE_CHANGE = util3.toHash(["properties", "patternProperties", "enum", "dependencies", "definitions"]);
104313
104313
  function getJsonPointer(parsedRef, baseId, schema, root) {
104314
104314
  parsedRef.fragment = parsedRef.fragment || "";
104315
104315
  if (parsedRef.fragment.slice(0, 1) != "/")
@@ -104318,7 +104318,7 @@ var require_resolve = __commonJS({
104318
104318
  for (var i2 = 1; i2 < parts.length; i2++) {
104319
104319
  var part = parts[i2];
104320
104320
  if (part) {
104321
- part = util2.unescapeFragment(part);
104321
+ part = util3.unescapeFragment(part);
104322
104322
  schema = schema[part];
104323
104323
  if (schema === void 0)
104324
104324
  break;
@@ -104342,7 +104342,7 @@ var require_resolve = __commonJS({
104342
104342
  if (schema !== void 0 && schema !== root.schema)
104343
104343
  return { schema, root, baseId };
104344
104344
  }
104345
- var SIMPLE_INLINED = util2.toHash([
104345
+ var SIMPLE_INLINED = util3.toHash([
104346
104346
  "type",
104347
104347
  "format",
104348
104348
  "pattern",
@@ -104443,7 +104443,7 @@ var require_resolve = __commonJS({
104443
104443
  var baseId = baseIds[parentJsonPtr];
104444
104444
  var fullPath = fullPaths[parentJsonPtr] + "/" + parentKeyword;
104445
104445
  if (keyIndex !== void 0)
104446
- fullPath += "/" + (typeof keyIndex == "number" ? keyIndex : util2.escapeFragment(keyIndex));
104446
+ fullPath += "/" + (typeof keyIndex == "number" ? keyIndex : util3.escapeFragment(keyIndex));
104447
104447
  if (typeof id == "string") {
104448
104448
  id = baseId = normalizeId(baseId ? URI.resolve(baseId, id) : id);
104449
104449
  var refVal = self2._refs[id];
@@ -105046,11 +105046,11 @@ var require_compile = __commonJS({
105046
105046
  "use strict";
105047
105047
  init_import_meta_url();
105048
105048
  var resolve14 = require_resolve();
105049
- var util2 = require_util4();
105049
+ var util3 = require_util4();
105050
105050
  var errorClasses = require_error_classes();
105051
105051
  var stableStringify = require_fast_json_stable_stringify();
105052
105052
  var validateGenerator = require_validate();
105053
- var ucs2length = util2.ucs2length;
105053
+ var ucs2length = util3.ucs2length;
105054
105054
  var equal = require_fast_deep_equal();
105055
105055
  var ValidationError = errorClasses.Validation;
105056
105056
  module2.exports = compile;
@@ -105104,7 +105104,7 @@ var require_compile = __commonJS({
105104
105104
  MissingRefError: errorClasses.MissingRef,
105105
105105
  RULES,
105106
105106
  validate: validateGenerator,
105107
- util: util2,
105107
+ util: util3,
105108
105108
  resolve: resolve14,
105109
105109
  resolveRef,
105110
105110
  usePattern,
@@ -105228,7 +105228,7 @@ var require_compile = __commonJS({
105228
105228
  case "number":
105229
105229
  return "" + value;
105230
105230
  case "string":
105231
- return util2.toQuotedString(value);
105231
+ return util3.toQuotedString(value);
105232
105232
  case "object":
105233
105233
  if (value === null)
105234
105234
  return "null";
@@ -105311,7 +105311,7 @@ var require_compile = __commonJS({
105311
105311
  return -1;
105312
105312
  }
105313
105313
  function patternCode(i2, patterns) {
105314
- return "var pattern" + i2 + " = new RegExp(" + util2.toQuotedString(patterns[i2]) + ");";
105314
+ return "var pattern" + i2 + " = new RegExp(" + util3.toQuotedString(patterns[i2]) + ");";
105315
105315
  }
105316
105316
  function defaultCode(i2) {
105317
105317
  return "var default" + i2 + " = defaults[" + i2 + "];";
@@ -105361,7 +105361,7 @@ var require_formats2 = __commonJS({
105361
105361
  "../../node_modules/ajv/lib/compile/formats.js"(exports2, module2) {
105362
105362
  "use strict";
105363
105363
  init_import_meta_url();
105364
- var util2 = require_util4();
105364
+ var util3 = require_util4();
105365
105365
  var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
105366
105366
  var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
105367
105367
  var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
@@ -105377,7 +105377,7 @@ var require_formats2 = __commonJS({
105377
105377
  module2.exports = formats;
105378
105378
  function formats(mode) {
105379
105379
  mode = mode == "full" ? "full" : "fast";
105380
- return util2.copy(formats[mode]);
105380
+ return util3.copy(formats[mode]);
105381
105381
  }
105382
105382
  formats.fast = {
105383
105383
  date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/,
@@ -108851,7 +108851,7 @@ var require_ajv = __commonJS({
108851
108851
  var formats = require_formats2();
108852
108852
  var rules = require_rules();
108853
108853
  var $dataMetaSchema = require_data();
108854
- var util2 = require_util4();
108854
+ var util3 = require_util4();
108855
108855
  module2.exports = Ajv;
108856
108856
  Ajv.prototype.validate = validate;
108857
108857
  Ajv.prototype.compile = compile;
@@ -108880,7 +108880,7 @@ var require_ajv = __commonJS({
108880
108880
  function Ajv(opts) {
108881
108881
  if (!(this instanceof Ajv))
108882
108882
  return new Ajv(opts);
108883
- opts = this._opts = util2.copy(opts) || {};
108883
+ opts = this._opts = util3.copy(opts) || {};
108884
108884
  setLogger(this);
108885
108885
  this._schemas = {};
108886
108886
  this._refs = {};
@@ -109199,7 +109199,7 @@ var require_ajv = __commonJS({
109199
109199
  throw new Error('schema with key or id "' + id + '" already exists');
109200
109200
  }
109201
109201
  function getMetaSchemaOptions(self2) {
109202
- var metaOpts = util2.copy(self2._opts);
109202
+ var metaOpts = util3.copy(self2._opts);
109203
109203
  for (var i2 = 0; i2 < META_IGNORE_OPTIONS.length; i2++)
109204
109204
  delete metaOpts[META_IGNORE_OPTIONS[i2]];
109205
109205
  return metaOpts;
@@ -111489,7 +111489,7 @@ var require_fast_json_stringify = __commonJS({
111489
111489
  }
111490
111490
  var arrayItemsReferenceSerializersMap = /* @__PURE__ */ new Map();
111491
111491
  var objectReferenceSerializersMap = /* @__PURE__ */ new Map();
111492
- function build6(schema, options) {
111492
+ function build7(schema, options) {
111493
111493
  arrayItemsReferenceSerializersMap.clear();
111494
111494
  objectReferenceSerializersMap.clear();
111495
111495
  options = options || {};
@@ -112651,7 +112651,7 @@ function $asStringSmall (str) {
112651
112651
  }
112652
112652
  return true;
112653
112653
  }
112654
- module2.exports = build6;
112654
+ module2.exports = build7;
112655
112655
  module2.exports.restore = function(debugModeStr, options = {}) {
112656
112656
  const dependencies = [debugModeStr];
112657
112657
  const args = [];
@@ -117216,13 +117216,13 @@ var require_streams2 = __commonJS({
117216
117216
  "use strict";
117217
117217
  init_import_meta_url();
117218
117218
  var Stream = require("stream").Stream;
117219
- var util2 = require("util");
117219
+ var util3 = require("util");
117220
117220
  var IO = function(driver) {
117221
117221
  this.readable = this.writable = true;
117222
117222
  this._paused = false;
117223
117223
  this._driver = driver;
117224
117224
  };
117225
- util2.inherits(IO, Stream);
117225
+ util3.inherits(IO, Stream);
117226
117226
  IO.prototype.pause = function() {
117227
117227
  this._paused = true;
117228
117228
  this._driver.messages._paused = true;
@@ -117260,7 +117260,7 @@ var require_streams2 = __commonJS({
117260
117260
  this._paused = false;
117261
117261
  this._driver = driver;
117262
117262
  };
117263
- util2.inherits(Messages, Stream);
117263
+ util3.inherits(Messages, Stream);
117264
117264
  Messages.prototype.pause = function() {
117265
117265
  this._driver.io._paused = true;
117266
117266
  };
@@ -117394,7 +117394,7 @@ var require_base = __commonJS({
117394
117394
  init_import_meta_url();
117395
117395
  var Buffer3 = require_safe_buffer3().Buffer;
117396
117396
  var Emitter = require("events").EventEmitter;
117397
- var util2 = require("util");
117397
+ var util3 = require("util");
117398
117398
  var streams = require_streams2();
117399
117399
  var Headers2 = require_headers2();
117400
117400
  var Reader = require_stream_reader();
@@ -117413,7 +117413,7 @@ var require_base = __commonJS({
117413
117413
  this.messages = new streams.Messages(this);
117414
117414
  this._bindEventListeners();
117415
117415
  };
117416
- util2.inherits(Base, Emitter);
117416
+ util3.inherits(Base, Emitter);
117417
117417
  Base.isWebSocket = function(request) {
117418
117418
  var connection = request.headers.connection || "", upgrade = request.headers.upgrade || "";
117419
117419
  return request.method === "GET" && connection.toLowerCase().split(/ *, */).indexOf("upgrade") >= 0 && upgrade.toLowerCase() === "websocket";
@@ -118635,7 +118635,7 @@ var require_hybi = __commonJS({
118635
118635
  init_import_meta_url();
118636
118636
  var Buffer3 = require_safe_buffer3().Buffer;
118637
118637
  var crypto5 = require("crypto");
118638
- var util2 = require("util");
118638
+ var util3 = require("util");
118639
118639
  var Extensions = require_websocket_extensions();
118640
118640
  var Base = require_base();
118641
118641
  var Frame = require_frame();
@@ -118662,7 +118662,7 @@ var require_hybi = __commonJS({
118662
118662
  }
118663
118663
  this.version = "hybi-" + Hybi.VERSION;
118664
118664
  };
118665
- util2.inherits(Hybi, Base);
118665
+ util3.inherits(Hybi, Base);
118666
118666
  Hybi.VERSION = "13";
118667
118667
  Hybi.mask = function(payload, mask2, offset) {
118668
118668
  if (!mask2 || mask2.length === 0)
@@ -119038,7 +119038,7 @@ var require_proxy = __commonJS({
119038
119038
  var Buffer3 = require_safe_buffer3().Buffer;
119039
119039
  var Stream = require("stream").Stream;
119040
119040
  var url3 = require("url");
119041
- var util2 = require("util");
119041
+ var util3 = require("util");
119042
119042
  var Base = require_base();
119043
119043
  var Headers2 = require_headers2();
119044
119044
  var HttpParser = require_http_parser2();
@@ -119060,7 +119060,7 @@ var require_proxy = __commonJS({
119060
119060
  if (auth)
119061
119061
  this._headers.set("Proxy-Authorization", "Basic " + auth);
119062
119062
  };
119063
- util2.inherits(Proxy2, Stream);
119063
+ util3.inherits(Proxy2, Stream);
119064
119064
  var instance = {
119065
119065
  setHeader: function(name, value) {
119066
119066
  if (this._state !== 0)
@@ -119129,7 +119129,7 @@ var require_client2 = __commonJS({
119129
119129
  var Buffer3 = require_safe_buffer3().Buffer;
119130
119130
  var crypto5 = require("crypto");
119131
119131
  var url3 = require("url");
119132
- var util2 = require("util");
119132
+ var util3 = require("util");
119133
119133
  var HttpParser = require_http_parser2();
119134
119134
  var Base = require_base();
119135
119135
  var Hybi = require_hybi();
@@ -119155,7 +119155,7 @@ var require_client2 = __commonJS({
119155
119155
  if (auth)
119156
119156
  this._headers.set("Authorization", "Basic " + auth);
119157
119157
  };
119158
- util2.inherits(Client, Hybi);
119158
+ util3.inherits(Client, Hybi);
119159
119159
  Client.generateKey = function() {
119160
119160
  return crypto5.randomBytes(16).toString("base64");
119161
119161
  };
@@ -119244,7 +119244,7 @@ var require_draft75 = __commonJS({
119244
119244
  init_import_meta_url();
119245
119245
  var Buffer3 = require_safe_buffer3().Buffer;
119246
119246
  var Base = require_base();
119247
- var util2 = require("util");
119247
+ var util3 = require("util");
119248
119248
  var Draft75 = function(request, url3, options) {
119249
119249
  Base.apply(this, arguments);
119250
119250
  this._stage = 0;
@@ -119254,7 +119254,7 @@ var require_draft75 = __commonJS({
119254
119254
  this._headers.set("WebSocket-Origin", this._request.headers.origin);
119255
119255
  this._headers.set("WebSocket-Location", this.url);
119256
119256
  };
119257
- util2.inherits(Draft75, Base);
119257
+ util3.inherits(Draft75, Base);
119258
119258
  var instance = {
119259
119259
  close: function() {
119260
119260
  if (this.readyState === 3)
@@ -119356,7 +119356,7 @@ var require_draft76 = __commonJS({
119356
119356
  var Base = require_base();
119357
119357
  var Draft75 = require_draft75();
119358
119358
  var crypto5 = require("crypto");
119359
- var util2 = require("util");
119359
+ var util3 = require("util");
119360
119360
  var numberFromKey = function(key3) {
119361
119361
  return parseInt((key3.match(/[0-9]/g) || []).join(""), 10);
119362
119362
  };
@@ -119374,7 +119374,7 @@ var require_draft76 = __commonJS({
119374
119374
  this._headers.set("Sec-WebSocket-Origin", this._request.headers.origin);
119375
119375
  this._headers.set("Sec-WebSocket-Location", this.url);
119376
119376
  };
119377
- util2.inherits(Draft76, Draft75);
119377
+ util3.inherits(Draft76, Draft75);
119378
119378
  var instance = {
119379
119379
  BODY_SIZE: 8,
119380
119380
  start: function() {
@@ -119448,7 +119448,7 @@ var require_server = __commonJS({
119448
119448
  "../../node_modules/websocket-driver/lib/websocket/driver/server.js"(exports2, module2) {
119449
119449
  "use strict";
119450
119450
  init_import_meta_url();
119451
- var util2 = require("util");
119451
+ var util3 = require("util");
119452
119452
  var HttpParser = require_http_parser2();
119453
119453
  var Base = require_base();
119454
119454
  var Draft75 = require_draft75();
@@ -119458,7 +119458,7 @@ var require_server = __commonJS({
119458
119458
  Base.call(this, null, null, options);
119459
119459
  this._http = new HttpParser("request");
119460
119460
  };
119461
- util2.inherits(Server, Base);
119461
+ util3.inherits(Server, Base);
119462
119462
  var instance = {
119463
119463
  EVENTS: ["open", "message", "error", "close", "ping", "pong"],
119464
119464
  _bindEventListeners: function() {
@@ -119649,7 +119649,7 @@ var require_api2 = __commonJS({
119649
119649
  "use strict";
119650
119650
  init_import_meta_url();
119651
119651
  var Stream = require("stream").Stream;
119652
- var util2 = require("util");
119652
+ var util3 = require("util");
119653
119653
  var driver = require_driver();
119654
119654
  var EventTarget = require_event_target3();
119655
119655
  var Event = require_event();
@@ -119702,7 +119702,7 @@ var require_api2 = __commonJS({
119702
119702
  this._driver.io.pipe(this._stream);
119703
119703
  }
119704
119704
  };
119705
- util2.inherits(API, Stream);
119705
+ util3.inherits(API, Stream);
119706
119706
  API.CONNECTING = 0;
119707
119707
  API.OPEN = 1;
119708
119708
  API.CLOSING = 2;
@@ -119836,7 +119836,7 @@ var require_client3 = __commonJS({
119836
119836
  "../../node_modules/faye-websocket/lib/faye/websocket/client.js"(exports2, module2) {
119837
119837
  "use strict";
119838
119838
  init_import_meta_url();
119839
- var util2 = require("util");
119839
+ var util3 = require("util");
119840
119840
  var net3 = require("net");
119841
119841
  var tls = require("tls");
119842
119842
  var url3 = require("url");
@@ -119867,7 +119867,7 @@ var require_client3 = __commonJS({
119867
119867
  this._configureProxy(proxy2, originTLS);
119868
119868
  API.call(this, options);
119869
119869
  };
119870
- util2.inherits(Client, API);
119870
+ util3.inherits(Client, API);
119871
119871
  Client.prototype._onConnect = function() {
119872
119872
  var worker = this._proxy || this._driver;
119873
119873
  worker.start();
@@ -119907,7 +119907,7 @@ var require_eventsource = __commonJS({
119907
119907
  "use strict";
119908
119908
  init_import_meta_url();
119909
119909
  var Stream = require("stream").Stream;
119910
- var util2 = require("util");
119910
+ var util3 = require("util");
119911
119911
  var driver = require_driver();
119912
119912
  var Headers2 = require_headers2();
119913
119913
  var API = require_api2();
@@ -119950,7 +119950,7 @@ var require_eventsource = __commonJS({
119950
119950
  });
119951
119951
  });
119952
119952
  };
119953
- util2.inherits(EventSource, Stream);
119953
+ util3.inherits(EventSource, Stream);
119954
119954
  EventSource.isEventSource = function(request) {
119955
119955
  if (request.method !== "GET")
119956
119956
  return false;
@@ -120031,7 +120031,7 @@ var require_websocket3 = __commonJS({
120031
120031
  "../../node_modules/faye-websocket/lib/faye/websocket.js"(exports2, module2) {
120032
120032
  "use strict";
120033
120033
  init_import_meta_url();
120034
- var util2 = require("util");
120034
+ var util3 = require("util");
120035
120035
  var driver = require_driver();
120036
120036
  var API = require_api2();
120037
120037
  var WebSocket3 = function(request, socket, body, protocols, options) {
@@ -120053,7 +120053,7 @@ var require_websocket3 = __commonJS({
120053
120053
  self2._driver.io.write(body);
120054
120054
  });
120055
120055
  };
120056
- util2.inherits(WebSocket3, API);
120056
+ util3.inherits(WebSocket3, API);
120057
120057
  WebSocket3.isWebSocket = function(request) {
120058
120058
  return driver.isWebSocket(request);
120059
120059
  };
@@ -128087,13 +128087,13 @@ var require_chalk = __commonJS({
128087
128087
  styles[key2] = {
128088
128088
  get() {
128089
128089
  const codes = ansiStyles[key2];
128090
- return build6.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key2);
128090
+ return build7.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key2);
128091
128091
  }
128092
128092
  };
128093
128093
  }
128094
128094
  styles.visible = {
128095
128095
  get() {
128096
- return build6.call(this, this._styles || [], true, "visible");
128096
+ return build7.call(this, this._styles || [], true, "visible");
128097
128097
  }
128098
128098
  };
128099
128099
  ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), "g");
@@ -128111,7 +128111,7 @@ var require_chalk = __commonJS({
128111
128111
  close: ansiStyles.color.close,
128112
128112
  closeRe: ansiStyles.color.closeRe
128113
128113
  };
128114
- return build6.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
128114
+ return build7.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
128115
128115
  };
128116
128116
  }
128117
128117
  };
@@ -128132,14 +128132,14 @@ var require_chalk = __commonJS({
128132
128132
  close: ansiStyles.bgColor.close,
128133
128133
  closeRe: ansiStyles.bgColor.closeRe
128134
128134
  };
128135
- return build6.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
128135
+ return build7.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
128136
128136
  };
128137
128137
  }
128138
128138
  };
128139
128139
  }
128140
128140
  var proto = Object.defineProperties(() => {
128141
128141
  }, styles);
128142
- function build6(_styles, _empty, key2) {
128142
+ function build7(_styles, _empty, key2) {
128143
128143
  const builder = function() {
128144
128144
  return applyStyle.apply(builder, arguments);
128145
128145
  };
@@ -135565,6 +135565,13 @@ function normalizeAndValidateConfig(rawConfig, configPath, args) {
135565
135565
  rawConfig.send_metrics,
135566
135566
  "boolean"
135567
135567
  );
135568
+ validateOptionalProperty(
135569
+ diagnostics,
135570
+ "",
135571
+ "keep_vars",
135572
+ rawConfig.keep_vars,
135573
+ "boolean"
135574
+ );
135568
135575
  const isLegacyEnv2 = args["legacy-env"] ?? rawConfig.legacy_env ?? true;
135569
135576
  if (!isLegacyEnv2) {
135570
135577
  diagnostics.warnings.push(
@@ -135625,6 +135632,7 @@ Consider adding an environment configuration section to the wrangler.toml file:
135625
135632
  configPath,
135626
135633
  legacy_env: isLegacyEnv2,
135627
135634
  send_metrics: rawConfig.send_metrics,
135635
+ keep_vars: rawConfig.keep_vars,
135628
135636
  ...activeEnv,
135629
135637
  dev: normalizeAndValidateDev(diagnostics, rawConfig.dev ?? {}),
135630
135638
  migrations: normalizeAndValidateMigrations(
@@ -136157,7 +136165,7 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, envNam
136157
136165
  isBoolean,
136158
136166
  void 0
136159
136167
  );
136160
- const { deprecatedUpload, ...build6 } = normalizeAndValidateBuild(
136168
+ const { deprecatedUpload, ...build7 } = normalizeAndValidateBuild(
136161
136169
  diagnostics,
136162
136170
  rawEnv,
136163
136171
  rawEnv.build ?? topLevelEnv?.build ?? {},
@@ -136250,7 +136258,7 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, envNam
136250
136258
  isOneOf("bundled", "unbound"),
136251
136259
  void 0
136252
136260
  ),
136253
- build: build6,
136261
+ build: build7,
136254
136262
  workers_dev,
136255
136263
  vars: notInheritable(
136256
136264
  diagnostics,
@@ -137414,6 +137422,22 @@ async function getRegisteredWorkers() {
137414
137422
  }
137415
137423
  }
137416
137424
  }
137425
+ async function getBoundRegisteredWorkers({
137426
+ services,
137427
+ durableObjects
137428
+ }) {
137429
+ const serviceNames = (services || []).map(
137430
+ (serviceBinding) => serviceBinding.service
137431
+ );
137432
+ const durableObjectServices = (durableObjects || { bindings: [] }).bindings.map((durableObjectBinding) => durableObjectBinding.script_name);
137433
+ const workerDefinitions = await getRegisteredWorkers();
137434
+ const filteredWorkers = Object.fromEntries(
137435
+ Object.entries(workerDefinitions || {}).filter(
137436
+ ([key2, _value]) => serviceNames.includes(key2) || durableObjectServices.includes(key2)
137437
+ )
137438
+ );
137439
+ return filteredWorkers;
137440
+ }
137417
137441
 
137418
137442
  // src/entry.ts
137419
137443
  init_import_meta_url();
@@ -138504,19 +138528,19 @@ ${migrateUrl}`
138504
138528
  }
138505
138529
  return { file, directory, format: format4 };
138506
138530
  }
138507
- async function runCustomBuild(expectedEntryAbsolute, expectedEntryRelative, build6) {
138508
- if (build6?.command) {
138509
- logger.log("Running custom build:", build6.command);
138510
- await execaCommand(build6.command, {
138531
+ async function runCustomBuild(expectedEntryAbsolute, expectedEntryRelative, build7) {
138532
+ if (build7?.command) {
138533
+ logger.log("Running custom build:", build7.command);
138534
+ await execaCommand(build7.command, {
138511
138535
  shell: true,
138512
138536
  stdout: "inherit",
138513
138537
  stderr: "inherit",
138514
- ...build6.cwd && { cwd: build6.cwd }
138538
+ ...build7.cwd && { cwd: build7.cwd }
138515
138539
  });
138516
138540
  if (fileExists(expectedEntryAbsolute) === false) {
138517
138541
  throw new Error(
138518
138542
  getMissingEntryPointMessage(
138519
- `The expected output file at "${expectedEntryRelative}" was not found after running custom build: ${build6.command}.
138543
+ `The expected output file at "${expectedEntryRelative}" was not found after running custom build: ${build7.command}.
138520
138544
  The \`main\` property in wrangler.toml should point to the file generated by the custom build.`,
138521
138545
  expectedEntryAbsolute,
138522
138546
  expectedEntryRelative
@@ -138674,7 +138698,7 @@ var import_websocket_server = __toESM(require_websocket_server2(), 1);
138674
138698
  var wrapper_default = import_websocket.default;
138675
138699
 
138676
138700
  // package.json
138677
- var version = "2.1.4";
138701
+ var version = "2.1.6";
138678
138702
  var package_default = {
138679
138703
  name: "wrangler",
138680
138704
  version,
@@ -139624,7 +139648,7 @@ function logConsoleMessage(evt) {
139624
139648
  break;
139625
139649
  case "weakmap":
139626
139650
  case "map":
139627
- args.push(
139651
+ ro.preview.entries === void 0 ? args.push("{}") : args.push(
139628
139652
  "{\n" + ro.preview.entries.map(({ key: key2, value }) => {
139629
139653
  return ` ${key2?.description ?? "<unknown>"} => ${value.description}`;
139630
139654
  }).join(",\n") + (ro.preview.overflow ? "\n ..." : "") + "\n}"
@@ -139632,7 +139656,7 @@ function logConsoleMessage(evt) {
139632
139656
  break;
139633
139657
  case "weakset":
139634
139658
  case "set":
139635
- args.push(
139659
+ ro.preview.entries === void 0 ? args.push("{}") : args.push(
139636
139660
  "{ " + ro.preview.entries.map(({ value }) => {
139637
139661
  return `${value.description}`;
139638
139662
  }).join(", ") + (ro.preview.overflow ? ", ..." : "") + " }"
@@ -139805,8 +139829,8 @@ function createModuleCollector(props) {
139805
139829
  modules,
139806
139830
  plugin: {
139807
139831
  name: "wrangler-module-collector",
139808
- setup(build6) {
139809
- build6.onStart(() => {
139832
+ setup(build7) {
139833
+ build7.onStart(() => {
139810
139834
  modules.splice(0);
139811
139835
  });
139812
139836
  const rulesMatchers = rules.flatMap((rule) => {
@@ -139819,7 +139843,7 @@ function createModuleCollector(props) {
139819
139843
  });
139820
139844
  });
139821
139845
  if (props.wrangler1xlegacyModuleReferences.fileNames.size > 0) {
139822
- build6.onResolve(
139846
+ build7.onResolve(
139823
139847
  {
139824
139848
  filter: new RegExp(
139825
139849
  "^(" + [...props.wrangler1xlegacyModuleReferences.fileNames].map((name) => name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|") + ")$"
@@ -139863,7 +139887,7 @@ function createModuleCollector(props) {
139863
139887
  if (rule.type === "ESModule" || rule.type === "CommonJS")
139864
139888
  return;
139865
139889
  rule.globs.forEach((glob) => {
139866
- build6.onResolve(
139890
+ build7.onResolve(
139867
139891
  { filter: (0, import_glob_to_regexp.default)(glob) },
139868
139892
  async (args) => {
139869
139893
  const filePath = import_node_path12.default.join(args.resolveDir, args.path);
@@ -139884,7 +139908,7 @@ function createModuleCollector(props) {
139884
139908
  }
139885
139909
  );
139886
139910
  if (props.format === "service-worker") {
139887
- build6.onLoad(
139911
+ build7.onLoad(
139888
139912
  { filter: (0, import_glob_to_regexp.default)(glob) },
139889
139913
  async (args) => {
139890
139914
  return {
@@ -139900,7 +139924,7 @@ function createModuleCollector(props) {
139900
139924
  });
139901
139925
  rulesToRemove.forEach((rule) => {
139902
139926
  rule.globs.forEach((glob) => {
139903
- build6.onResolve(
139927
+ build7.onResolve(
139904
139928
  { filter: (0, import_glob_to_regexp.default)(glob) },
139905
139929
  async (args) => {
139906
139930
  throw new Error(
@@ -141480,7 +141504,8 @@ function createWorkerUploadForm(worker) {
141480
141504
  migrations,
141481
141505
  usage_model,
141482
141506
  compatibility_date,
141483
- compatibility_flags
141507
+ compatibility_flags,
141508
+ keepVars
141484
141509
  } = worker;
141485
141510
  let { modules } = worker;
141486
141511
  const metadataBindings = [];
@@ -141617,7 +141642,7 @@ function createWorkerUploadForm(worker) {
141617
141642
  ...usage_model && { usage_model },
141618
141643
  ...migrations && { migrations },
141619
141644
  capnp_schema: bindings.logfwdr?.schema,
141620
- keep_bindings: ["plain_text", "json"]
141645
+ ...keepVars && { keep_bindings: ["plain_text", "json"] }
141621
141646
  };
141622
141647
  formData2.set("metadata", JSON.stringify(metadata));
141623
141648
  if (main2.type === "commonjs" && modules && modules.length > 0) {
@@ -142285,31 +142310,19 @@ function Remote(props) {
142285
142310
  }) : null;
142286
142311
  }
142287
142312
  function useWorker(props) {
142288
- const {
142289
- name,
142290
- bundle,
142291
- format: format4,
142292
- modules,
142293
- accountId,
142294
- bindings,
142295
- assetPaths,
142296
- compatibilityDate,
142297
- compatibilityFlags,
142298
- usageModel,
142299
- onReady
142300
- } = props;
142301
142313
  const [session, setSession] = (0, import_react6.useState)();
142302
142314
  const [token, setToken] = (0, import_react6.useState)();
142303
142315
  const [restartCounter, setRestartCounter] = (0, import_react6.useState)(0);
142304
142316
  const startedRef = (0, import_react6.useRef)(false);
142317
+ const { onReady } = props;
142305
142318
  (0, import_react6.useEffect)(() => {
142306
142319
  const abortController = new AbortController();
142307
142320
  async function start() {
142308
- if (accountId === void 0) {
142321
+ if (props.accountId === void 0) {
142309
142322
  return;
142310
142323
  }
142311
142324
  const workerAccount = {
142312
- accountId,
142325
+ accountId: props.accountId,
142313
142326
  apiToken: requireApiToken()
142314
142327
  };
142315
142328
  const workerCtx = {
@@ -142337,7 +142350,7 @@ function useWorker(props) {
142337
142350
  abortController.abort();
142338
142351
  };
142339
142352
  }, [
142340
- accountId,
142353
+ props.accountId,
142341
142354
  props.env,
142342
142355
  props.host,
142343
142356
  props.legacyEnv,
@@ -142349,40 +142362,40 @@ function useWorker(props) {
142349
142362
  (0, import_react6.useEffect)(() => {
142350
142363
  const abortController = new AbortController();
142351
142364
  async function start() {
142352
- if (accountId === void 0) {
142365
+ if (props.accountId === void 0) {
142353
142366
  return;
142354
142367
  }
142355
142368
  if (session === void 0) {
142356
142369
  return;
142357
142370
  }
142358
142371
  setToken(void 0);
142359
- if (!bundle || !format4)
142372
+ if (!props.bundle || !props.format)
142360
142373
  return;
142361
142374
  if (!startedRef.current) {
142362
142375
  startedRef.current = true;
142363
142376
  } else {
142364
142377
  logger.log("\u2394 Detected changes, restarted server.");
142365
142378
  }
142366
- const content = await (0, import_promises5.readFile)(bundle.path, "utf-8");
142379
+ const content = await (0, import_promises5.readFile)(props.bundle.path, "utf-8");
142367
142380
  void printBundleSize(
142368
- { name: import_node_path15.default.basename(bundle.path), content },
142369
- modules
142381
+ { name: import_node_path15.default.basename(props.bundle.path), content },
142382
+ props.modules
142370
142383
  );
142371
142384
  const assets = await syncAssets(
142372
- accountId,
142373
- name + (!props.legacyEnv && props.env ? `-${props.env}` : ""),
142374
- props.isWorkersSite ? assetPaths : void 0,
142385
+ props.accountId,
142386
+ props.name + (!props.legacyEnv && props.env ? `-${props.env}` : ""),
142387
+ props.isWorkersSite ? props.assetPaths : void 0,
142375
142388
  true,
142376
142389
  false
142377
142390
  );
142378
142391
  const init = {
142379
- name,
142392
+ name: props.name,
142380
142393
  main: {
142381
- name: import_node_path15.default.basename(bundle.path),
142382
- type: format4 === "modules" ? "esm" : "commonjs",
142394
+ name: import_node_path15.default.basename(props.bundle.path),
142395
+ type: props.format === "modules" ? "esm" : "commonjs",
142383
142396
  content
142384
142397
  },
142385
- modules: modules.concat(
142398
+ modules: props.modules.concat(
142386
142399
  assets.manifest ? {
142387
142400
  name: "__STATIC_CONTENT_MANIFEST",
142388
142401
  content: JSON.stringify(assets.manifest),
@@ -142390,25 +142403,25 @@ function useWorker(props) {
142390
142403
  } : []
142391
142404
  ),
142392
142405
  bindings: {
142393
- ...bindings,
142394
- kv_namespaces: (bindings.kv_namespaces || []).concat(
142406
+ ...props.bindings,
142407
+ kv_namespaces: (props.bindings.kv_namespaces || []).concat(
142395
142408
  assets.namespace ? { binding: "__STATIC_CONTENT", id: assets.namespace } : []
142396
142409
  ),
142397
142410
  text_blobs: {
142398
- ...bindings.text_blobs,
142399
- ...assets.manifest && format4 === "service-worker" && {
142411
+ ...props.bindings.text_blobs,
142412
+ ...assets.manifest && props.format === "service-worker" && {
142400
142413
  __STATIC_CONTENT_MANIFEST: "__STATIC_CONTENT_MANIFEST"
142401
142414
  }
142402
142415
  }
142403
142416
  },
142404
142417
  migrations: void 0,
142405
- compatibility_date: compatibilityDate,
142406
- compatibility_flags: compatibilityFlags,
142407
- usage_model: usageModel,
142408
- keep_bindings: true
142418
+ compatibility_date: props.compatibilityDate,
142419
+ compatibility_flags: props.compatibilityFlags,
142420
+ usage_model: props.usageModel,
142421
+ keepVars: true
142409
142422
  };
142410
142423
  const workerAccount = {
142411
- accountId,
142424
+ accountId: props.accountId,
142412
142425
  apiToken: requireApiToken()
142413
142426
  };
142414
142427
  const workerCtx = {
@@ -142434,7 +142447,7 @@ function useWorker(props) {
142434
142447
  if (err2.code === 10063) {
142435
142448
  const errorMessage = "Error: You need to register a workers.dev subdomain before running the dev command in remote mode";
142436
142449
  const solutionMessage = "You can either enable local mode by pressing l, or register a workers.dev subdomain here:";
142437
- const onboardingLink = `https://dash.cloudflare.com/${accountId}/workers/onboarding`;
142450
+ const onboardingLink = `https://dash.cloudflare.com/${props.accountId}/workers/onboarding`;
142438
142451
  logger.error(
142439
142452
  `${errorMessage}
142440
142453
  ${solutionMessage}
@@ -142452,17 +142465,17 @@ ${onboardingLink}`
142452
142465
  abortController.abort();
142453
142466
  };
142454
142467
  }, [
142455
- name,
142456
- bundle,
142457
- format4,
142458
- accountId,
142459
- assetPaths,
142468
+ props.name,
142469
+ props.bundle,
142470
+ props.format,
142471
+ props.accountId,
142472
+ props.assetPaths,
142460
142473
  props.isWorkersSite,
142461
- compatibilityDate,
142462
- compatibilityFlags,
142463
- usageModel,
142464
- bindings,
142465
- modules,
142474
+ props.compatibilityDate,
142475
+ props.compatibilityFlags,
142476
+ props.usageModel,
142477
+ props.bindings,
142478
+ props.modules,
142466
142479
  props.env,
142467
142480
  props.legacyEnv,
142468
142481
  props.zone,
@@ -142495,8 +142508,8 @@ var esbuild2 = __toESM(require("esbuild"));
142495
142508
  var import_tmp_promise = __toESM(require_tmp_promise());
142496
142509
  var checkForNodeBuiltinsPlugin = {
142497
142510
  name: "checkForNodeBuiltins",
142498
- setup(build6) {
142499
- build6.onResolve(
142511
+ setup(build7) {
142512
+ build7.onResolve(
142500
142513
  {
142501
142514
  filter: new RegExp(
142502
142515
  "^(" + import_node_module.builtinModules.join("|") + "|" + import_node_module.builtinModules.map((module2) => "node:" + module2).join("|") + ")$"
@@ -142526,7 +142539,8 @@ async function bundleWorker(entry, destination, options) {
142526
142539
  workerDefinitions,
142527
142540
  services,
142528
142541
  firstPartyWorkerDevFacade,
142529
- targetConsumer
142542
+ targetConsumer,
142543
+ testScheduled
142530
142544
  } = options;
142531
142545
  const tmpDir = await import_tmp_promise.default.dir({ unsafeCleanup: true });
142532
142546
  const entryDirectory = path17.dirname(entry.file);
@@ -142553,6 +142567,11 @@ async function bundleWorker(entry, destination, options) {
142553
142567
  );
142554
142568
  }
142555
142569
  const middlewareToLoad = [];
142570
+ if (testScheduled) {
142571
+ middlewareToLoad.push({
142572
+ path: "templates/middleware/middleware-scheduled.ts"
142573
+ });
142574
+ }
142556
142575
  const middleware = [
142557
142576
  serveAssetsFromWorker && ((currentEntry) => {
142558
142577
  return applyStaticAssetFacade(currentEntry, tmpDir.path, assets);
@@ -142654,8 +142673,8 @@ async function bundleWorker(entry, destination, options) {
142654
142673
  function esbuildAliasExternalPlugin(aliases2) {
142655
142674
  return {
142656
142675
  name: "alias",
142657
- setup(build6) {
142658
- build6.onResolve({ filter: /.*/g }, (args) => {
142676
+ setup(build7) {
142677
+ build7.onResolve({ filter: /.*/g }, (args) => {
142659
142678
  if (args.kind === "entry-point") {
142660
142679
  return {
142661
142680
  path: args.path
@@ -142732,7 +142751,7 @@ async function applyMiddlewareLoaderFacade(entry, tmpDirPath, middleware, module
142732
142751
  ...Object.fromEntries(
142733
142752
  middleware.map((val, index) => [
142734
142753
  middlewareIdentifiers[index],
142735
- path17.resolve(getBasePath(), val.path)
142754
+ toUrlPath(path17.resolve(getBasePath(), val.path))
142736
142755
  ])
142737
142756
  )
142738
142757
  })
@@ -142752,9 +142771,8 @@ async function applyMiddlewareLoaderFacade(entry, tmpDirPath, middleware, module
142752
142771
  plugins: [moduleCollectorPlugin]
142753
142772
  });
142754
142773
  const imports = middlewareIdentifiers.map(
142755
- (m, i2) => `import ${m} from "${path17.resolve(
142756
- getBasePath(),
142757
- middleware[i2].path
142774
+ (m, i2) => `import ${m} from "${toUrlPath(
142775
+ path17.resolve(getBasePath(), middleware[i2].path)
142758
142776
  )}";`
142759
142777
  ).join("\n");
142760
142778
  fs5.copyFileSync(targetPathInsertion, dynamicFacadePath);
@@ -142925,7 +142943,8 @@ function useEsbuild({
142925
142943
  services,
142926
142944
  durableObjects,
142927
142945
  firstPartyWorkerDevFacade,
142928
- targetConsumer
142946
+ targetConsumer,
142947
+ testScheduled
142929
142948
  }) {
142930
142949
  const [bundle, setBundle] = (0, import_react7.useState)();
142931
142950
  const { exit: exit2 } = (0, import_ink3.useApp)();
@@ -142949,7 +142968,7 @@ function useEsbuild({
142949
142968
  }
142950
142969
  }
142951
142970
  };
142952
- async function build6() {
142971
+ async function build7() {
142953
142972
  if (!destination)
142954
142973
  return;
142955
142974
  const {
@@ -142982,7 +143001,8 @@ function useEsbuild({
142982
143001
  workerDefinitions,
142983
143002
  services,
142984
143003
  firstPartyWorkerDevFacade,
142985
- targetConsumer
143004
+ targetConsumer,
143005
+ testScheduled
142986
143006
  });
142987
143007
  stopWatching = stop;
142988
143008
  if (noBundle) {
@@ -143004,7 +143024,7 @@ function useEsbuild({
143004
143024
  sourceMapPath
143005
143025
  });
143006
143026
  }
143007
- build6().catch((err2) => {
143027
+ build7().catch((err2) => {
143008
143028
  exit2(err2);
143009
143029
  });
143010
143030
  return () => {
@@ -143028,7 +143048,8 @@ function useEsbuild({
143028
143048
  durableObjects,
143029
143049
  workerDefinitions,
143030
143050
  firstPartyWorkerDevFacade,
143031
- targetConsumer
143051
+ targetConsumer,
143052
+ testScheduled
143032
143053
  ]);
143033
143054
  return bundle;
143034
143055
  }
@@ -143065,21 +143086,15 @@ function useDevRegistry(name, services, durableObjects, mode) {
143065
143086
  startWorkerRegistry().catch((err2) => {
143066
143087
  logger.error("failed to start worker registry", err2);
143067
143088
  });
143068
- const serviceNames = (services || []).map(
143069
- (serviceBinding) => serviceBinding.service
143070
- );
143071
- const durableObjectServices = (durableObjects || { bindings: [] }).bindings.map((durableObjectBinding) => durableObjectBinding.script_name);
143072
143089
  const interval2 = mode === "local" ? setInterval(() => {
143073
- getRegisteredWorkers().then(
143074
- (workerDefinitions) => {
143075
- const filteredWorkers = Object.fromEntries(
143076
- Object.entries(workerDefinitions || {}).filter(
143077
- ([key2, _value]) => serviceNames.includes(key2) || durableObjectServices.includes(key2)
143078
- )
143079
- );
143090
+ getBoundRegisteredWorkers({
143091
+ services,
143092
+ durableObjects
143093
+ }).then(
143094
+ (boundRegisteredWorkers) => {
143080
143095
  setWorkers((prevWorkers) => {
143081
- if (!util.isDeepStrictEqual(filteredWorkers, prevWorkers)) {
143082
- return filteredWorkers;
143096
+ if (!util.isDeepStrictEqual(boundRegisteredWorkers, prevWorkers)) {
143097
+ return boundRegisteredWorkers || {};
143083
143098
  }
143084
143099
  return prevWorkers;
143085
143100
  });
@@ -143188,7 +143203,8 @@ function DevSession(props) {
143188
143203
  services: props.bindings.services,
143189
143204
  durableObjects: props.bindings.durable_objects || { bindings: [] },
143190
143205
  firstPartyWorkerDevFacade: props.firstPartyWorker,
143191
- targetConsumer: "dev"
143206
+ targetConsumer: "dev",
143207
+ testScheduled: props.testScheduled ?? false
143192
143208
  });
143193
143209
  return props.local ? /* @__PURE__ */ import_react8.default.createElement(Local, {
143194
143210
  name: props.name,
@@ -143261,19 +143277,19 @@ function useTmpDir() {
143261
143277
  }, [handleError]);
143262
143278
  return directory?.name;
143263
143279
  }
143264
- function useCustomBuild(expectedEntry, build6) {
143280
+ function useCustomBuild(expectedEntry, build7) {
143265
143281
  (0, import_react8.useEffect)(() => {
143266
- if (!build6.command)
143282
+ if (!build7.command)
143267
143283
  return;
143268
143284
  let watcher;
143269
- if (build6.watch_dir) {
143270
- watcher = (0, import_chokidar2.watch)(build6.watch_dir, {
143285
+ if (build7.watch_dir) {
143286
+ watcher = (0, import_chokidar2.watch)(build7.watch_dir, {
143271
143287
  persistent: true,
143272
143288
  ignoreInitial: true
143273
143289
  }).on("all", (_event, filePath) => {
143274
143290
  const relativeFile = path18.relative(expectedEntry.directory, expectedEntry.file) || ".";
143275
143291
  logger.log(`The file ${filePath} changed, restarting build...`);
143276
- runCustomBuild(expectedEntry.file, relativeFile, build6).catch((err2) => {
143292
+ runCustomBuild(expectedEntry.file, relativeFile, build7).catch((err2) => {
143277
143293
  logger.error("Custom build failed:", err2);
143278
143294
  });
143279
143295
  });
@@ -143281,7 +143297,7 @@ function useCustomBuild(expectedEntry, build6) {
143281
143297
  return () => {
143282
143298
  watcher?.close();
143283
143299
  };
143284
- }, [build6, expectedEntry]);
143300
+ }, [build7, expectedEntry]);
143285
143301
  }
143286
143302
  function sleep(period) {
143287
143303
  return new Promise((resolve14) => setTimeout(resolve14, period));
@@ -143441,10 +143457,12 @@ var import_node_child_process4 = require("node:child_process");
143441
143457
  var import_node_fs7 = require("node:fs");
143442
143458
  var import_promises6 = require("node:fs/promises");
143443
143459
  var path20 = __toESM(require("node:path"));
143460
+ var util2 = __toESM(require("node:util"));
143444
143461
  var import_signal_exit4 = __toESM(require_signal_exit());
143445
143462
  var import_tmp_promise3 = __toESM(require_tmp_promise());
143446
143463
  async function startDevServer(props) {
143447
143464
  try {
143465
+ let workerDefinitions = {};
143448
143466
  validateDevProps(props);
143449
143467
  if (props.build.command) {
143450
143468
  const relativeFile = path20.relative(props.entry.directory, props.entry.file) || ".";
@@ -143458,6 +143476,18 @@ async function startDevServer(props) {
143458
143476
  if (!directory) {
143459
143477
  throw new Error("Failed to create temporary directory.");
143460
143478
  }
143479
+ startWorkerRegistry().catch((err2) => {
143480
+ logger.error("failed to start worker registry", err2);
143481
+ });
143482
+ if (props.local) {
143483
+ const boundRegisteredWorkers = await getBoundRegisteredWorkers({
143484
+ services: props.bindings.services,
143485
+ durableObjects: props.bindings.durable_objects
143486
+ });
143487
+ if (!util2.isDeepStrictEqual(boundRegisteredWorkers, workerDefinitions)) {
143488
+ workerDefinitions = boundRegisteredWorkers || {};
143489
+ }
143490
+ }
143461
143491
  const bundle = await runEsbuild({
143462
143492
  entry: props.entry,
143463
143493
  destination: directory.name,
@@ -143473,7 +143503,10 @@ async function startDevServer(props) {
143473
143503
  define: props.define,
143474
143504
  noBundle: props.noBundle,
143475
143505
  assets: props.assetsConfig,
143476
- services: props.bindings.services
143506
+ workerDefinitions,
143507
+ services: props.bindings.services,
143508
+ firstPartyWorkerDevFacade: props.firstPartyWorker,
143509
+ testScheduled: props.testScheduled
143477
143510
  });
143478
143511
  const { stop, inspectorUrl } = await startLocalServer({
143479
143512
  name: props.name,
@@ -143497,12 +143530,13 @@ async function startDevServer(props) {
143497
143530
  inspect: props.inspect,
143498
143531
  onReady: props.onReady,
143499
143532
  enablePagesAssetsServiceBinding: props.enablePagesAssetsServiceBinding,
143500
- usageModel: void 0,
143501
- workerDefinitions: void 0
143533
+ usageModel: props.usageModel,
143534
+ workerDefinitions
143502
143535
  });
143503
143536
  return {
143504
143537
  stop: async () => {
143505
143538
  stop();
143539
+ await stopWorkerRegistry();
143506
143540
  },
143507
143541
  inspectorUrl
143508
143542
  };
@@ -143531,7 +143565,11 @@ async function runEsbuild({
143531
143565
  minify,
143532
143566
  nodeCompat,
143533
143567
  define: define2,
143534
- noBundle
143568
+ noBundle,
143569
+ workerDefinitions,
143570
+ services,
143571
+ firstPartyWorkerDevFacade,
143572
+ testScheduled
143535
143573
  }) {
143536
143574
  if (!destination)
143537
143575
  return;
@@ -143560,10 +143598,11 @@ async function runEsbuild({
143560
143598
  ...assets,
143561
143599
  bypassCache: true
143562
143600
  },
143563
- services: void 0,
143564
- workerDefinitions: void 0,
143565
- firstPartyWorkerDevFacade: void 0,
143566
- targetConsumer: "dev"
143601
+ workerDefinitions,
143602
+ services,
143603
+ firstPartyWorkerDevFacade,
143604
+ targetConsumer: "dev",
143605
+ testScheduled
143567
143606
  });
143568
143607
  return {
143569
143608
  id: 0,
@@ -143617,8 +143656,8 @@ async function startLocalServer({
143617
143656
  });
143618
143657
  }
143619
143658
  if (bindings.services && bindings.services.length > 0) {
143620
- throw new Error(
143621
- "\u2394 Service bindings are not yet supported in local mode."
143659
+ logger.warn(
143660
+ "\u2394 Support for service bindings in local mode is experimental and may change."
143622
143661
  );
143623
143662
  }
143624
143663
  for (const module2 of bundle.modules) {
@@ -148547,7 +148586,7 @@ async function getWorkerConfig(accountId, fromDashScriptName, {
148547
148586
  });
148548
148587
  const routeOrRoutesToConfig = routeOrRoutes.length > 1 ? { routes: routeOrRoutes } : { route: routeOrRoutes[0] };
148549
148588
  return {
148550
- compatibility_date: serviceEnvMetadata.script.compatibility_date,
148589
+ compatibility_date: serviceEnvMetadata.script.compatibility_date ?? new Date().toISOString().substring(0, 10),
148551
148590
  ...routeOrRoutesToConfig,
148552
148591
  usage_model: serviceEnvMetadata.script.usage_model,
148553
148592
  migrations: [
@@ -148664,15 +148703,162 @@ var ROUTES_SPEC_DESCRIPTION = `Generated by wrangler@${version}`;
148664
148703
 
148665
148704
  // src/pages/errors.ts
148666
148705
  init_import_meta_url();
148706
+
148707
+ // src/pages/functions/routes-validation.ts
148708
+ init_import_meta_url();
148709
+ function isRoutesJSONSpec(data) {
148710
+ return typeof data === "object" && data && "version" in data && typeof data.version === "number" && data.version === ROUTES_SPEC_VERSION && Array.isArray(data.include) && Array.isArray(data.exclude) || false;
148711
+ }
148712
+ function validateRoutes2(routesJSON, routesPath) {
148713
+ if (!isRoutesJSONSpec(routesJSON)) {
148714
+ throw new FatalError(
148715
+ getRoutesValidationErrorMessage(
148716
+ 0 /* INVALID_JSON_SPEC */,
148717
+ routesPath
148718
+ ),
148719
+ 1
148720
+ );
148721
+ }
148722
+ if (!hasIncludeRules(routesJSON)) {
148723
+ throw new FatalError(
148724
+ getRoutesValidationErrorMessage(
148725
+ 1 /* NO_INCLUDE_RULES */,
148726
+ routesPath
148727
+ ),
148728
+ 1
148729
+ );
148730
+ }
148731
+ if (!hasValidRulesCount(routesJSON)) {
148732
+ throw new FatalError(
148733
+ getRoutesValidationErrorMessage(
148734
+ 3 /* TOO_MANY_RULES */,
148735
+ routesPath
148736
+ ),
148737
+ 1
148738
+ );
148739
+ }
148740
+ if (!hasValidRuleCharCount(routesJSON)) {
148741
+ throw new FatalError(
148742
+ getRoutesValidationErrorMessage(
148743
+ 4 /* RULE_TOO_LONG */,
148744
+ routesPath
148745
+ ),
148746
+ 1
148747
+ );
148748
+ }
148749
+ if (!hasValidRules(routesJSON)) {
148750
+ throw new FatalError(
148751
+ getRoutesValidationErrorMessage(
148752
+ 2 /* INVALID_RULES */,
148753
+ routesPath
148754
+ ),
148755
+ 1
148756
+ );
148757
+ }
148758
+ if (hasOverlappingRules(routesJSON.include) || hasOverlappingRules(routesJSON.exclude)) {
148759
+ throw new FatalError(
148760
+ getRoutesValidationErrorMessage(
148761
+ 5 /* OVERLAPPING_RULES */,
148762
+ routesPath
148763
+ ),
148764
+ 1
148765
+ );
148766
+ }
148767
+ }
148768
+ function hasIncludeRules(routesJSON) {
148769
+ if (!routesJSON || !routesJSON.include) {
148770
+ throw new Error(
148771
+ "Function `hasIncludeRules` was called out of context. Attempting to validate include rules for routes that are undefined or an invalid RoutesJSONSpec"
148772
+ );
148773
+ }
148774
+ return routesJSON?.include?.length > 0;
148775
+ }
148776
+ function hasValidRulesCount(routesJSON) {
148777
+ if (!routesJSON || !routesJSON.include || !routesJSON.exclude) {
148778
+ throw new Error(
148779
+ "Function `hasValidRulesCount` was called out of context. Attempting to validate maximum rules count for routes that are undefined or an invalid RoutesJSONSpec"
148780
+ );
148781
+ }
148782
+ return routesJSON.include.length + routesJSON.exclude.length <= MAX_FUNCTIONS_ROUTES_RULES;
148783
+ }
148784
+ function hasValidRuleCharCount(routesJSON) {
148785
+ if (!routesJSON || !routesJSON.include || !routesJSON.exclude) {
148786
+ throw new Error(
148787
+ "Function `hasValidRuleCharCount` was called out of context. Attempting to validate rules maximum character count for routes that are undefined or an invalid RoutesJSONSpec"
148788
+ );
148789
+ }
148790
+ const rules = [...routesJSON.include, ...routesJSON.exclude];
148791
+ return rules.filter((rule) => rule.length > MAX_FUNCTIONS_ROUTES_RULE_LENGTH).length === 0;
148792
+ }
148793
+ function hasValidRules(routesJSON) {
148794
+ if (!routesJSON || !routesJSON.include || !routesJSON.exclude) {
148795
+ throw new Error(
148796
+ "Function `hasValidRules` was called out of context. Attempting to validate rules for routes that are undefined or an invalid RoutesJSONSpec"
148797
+ );
148798
+ }
148799
+ const rules = [...routesJSON.include, ...routesJSON.exclude];
148800
+ return rules.filter((rule) => !rule.match(/^\//)).length === 0;
148801
+ }
148802
+ function hasOverlappingRules(routes) {
148803
+ if (!routes) {
148804
+ throw new Error(
148805
+ "Function `hasverlappingRules` was called out of context. Attempting to validate rules for routes that are undefined"
148806
+ );
148807
+ }
148808
+ const endingSplatRoutes = routes.filter((route) => route.endsWith("/*"));
148809
+ for (let i2 = 0; i2 < endingSplatRoutes.length; i2++) {
148810
+ const crrRoute = endingSplatRoutes[i2];
148811
+ const crrRouteTrimmed = crrRoute.substring(0, crrRoute.length - 1);
148812
+ for (let j = 0; j < routes.length; j++) {
148813
+ const nextRoute = routes[j];
148814
+ if (nextRoute !== crrRoute && nextRoute.startsWith(crrRouteTrimmed)) {
148815
+ return true;
148816
+ }
148817
+ }
148818
+ }
148819
+ return false;
148820
+ }
148821
+
148822
+ // src/pages/errors.ts
148823
+ var EXIT_CODE_FUNCTIONS_NO_ROUTES_ERROR = 156;
148667
148824
  var FunctionsNoRoutesError = class extends Error {
148668
148825
  constructor(message) {
148669
148826
  super(message);
148670
148827
  }
148671
148828
  };
148672
- var EXIT_CODE_FUNCTIONS_NO_ROUTES_ERROR = 156;
148673
148829
  function getFunctionsNoRoutesWarning(functionsDirectory, suffix) {
148674
148830
  return `No routes found when building Functions directory: ${functionsDirectory}${suffix ? " - " + suffix : ""}`;
148675
148831
  }
148832
+ function getRoutesValidationErrorMessage(errorCode, routesPath) {
148833
+ switch (errorCode) {
148834
+ case 1 /* NO_INCLUDE_RULES */:
148835
+ return `Invalid _routes.json file found at: ${routesPath}
148836
+ Routes must have at least 1 include rule, but no include rules were detected.`;
148837
+ case 3 /* TOO_MANY_RULES */:
148838
+ return `Invalid _routes.json file found at: ${routesPath}
148839
+ Detected rules that are over the ${MAX_FUNCTIONS_ROUTES_RULES} rule limit. Please make sure you have a total of ${MAX_FUNCTIONS_ROUTES_RULES} include and exclude rules combined.`;
148840
+ case 4 /* RULE_TOO_LONG */:
148841
+ return `Invalid _routes.json file found at: ${routesPath}
148842
+ Detected rules the are over the ${MAX_FUNCTIONS_ROUTES_RULE_LENGTH} character limit. Please make sure that each include and exclude routing rule is at most ${MAX_FUNCTIONS_ROUTES_RULE_LENGTH} characters long.`;
148843
+ case 2 /* INVALID_RULES */:
148844
+ return `Invalid _routes.json file found at: ${routesPath}
148845
+ All rules must start with '/'.`;
148846
+ case 5 /* OVERLAPPING_RULES */:
148847
+ return `Invalid _routes.json file found at: ${routesPath}
148848
+ Overlapping rules found. Please make sure that rules ending with a splat (eg. "/api/*") don't overlap any other rules (eg. "/api/foo"). This applies to both include and exclude rules individually.`;
148849
+ case 0 /* INVALID_JSON_SPEC */:
148850
+ default:
148851
+ return `Invalid _routes.json file found at: ${routesPath}
148852
+ Please make sure the JSON object has the following format:
148853
+ {
148854
+ version: ${ROUTES_SPEC_VERSION};
148855
+ include: string[];
148856
+ exclude: string[];
148857
+ }
148858
+ and that at least one include rule is provided.
148859
+ `;
148860
+ }
148861
+ }
148676
148862
 
148677
148863
  // src/pages/functions/buildPlugin.ts
148678
148864
  init_import_meta_url();
@@ -149315,9 +149501,6 @@ function compareRoutes2(routeA, routeB) {
149315
149501
  }
149316
149502
  return routeA.localeCompare(routeB);
149317
149503
  }
149318
- function isRoutesJSONSpec(data) {
149319
- return typeof data === "object" && data && "version" in data && typeof data.version === "number" && data.version === ROUTES_SPEC_VERSION && Array.isArray(data.include) && Array.isArray(data.exclude) || false;
149320
- }
149321
149504
 
149322
149505
  // src/pages/utils.ts
149323
149506
  init_import_meta_url();
@@ -149717,7 +149900,7 @@ var import_node_fs12 = require("node:fs");
149717
149900
  var import_node_os9 = require("node:os");
149718
149901
  var import_node_path26 = require("node:path");
149719
149902
  var import_chokidar3 = require("chokidar");
149720
- var import_esbuild6 = require("esbuild");
149903
+ var esbuild3 = __toESM(require("esbuild"));
149721
149904
  var DURABLE_OBJECTS_BINDING_REGEXP = new RegExp(
149722
149905
  /^(?<binding>[^=]+)=(?<className>[^@\s]+)(@(?<scriptName>.*)$)?$/
149723
149906
  );
@@ -149822,6 +150005,11 @@ function Options2(yargs) {
149822
150005
  describe: "Pages does not support wrangler.toml",
149823
150006
  type: "string",
149824
150007
  hidden: true
150008
+ },
150009
+ "log-level": {
150010
+ choices: ["debug", "info", "log", "warn", "error", "none"],
150011
+ describe: "Specify logging level",
150012
+ default: "log"
149825
150013
  }
149826
150014
  }).epilogue(pagesBetaWarning);
149827
150015
  }
@@ -149846,9 +150034,13 @@ var Handler2 = async ({
149846
150034
  persistTo,
149847
150035
  "node-compat": nodeCompat,
149848
150036
  config,
149849
- _: [_pages, _dev, ...remaining]
150037
+ _: [_pages, _dev, ...remaining],
150038
+ logLevel
149850
150039
  }) => {
149851
150040
  logger.log(pagesBetaWarning);
150041
+ if (logLevel) {
150042
+ logger.loggerLevel = logLevel === "none" ? "error" : logLevel;
150043
+ }
149852
150044
  if (!local) {
149853
150045
  throw new FatalError("Only local mode is supported at the moment.", 1);
149854
150046
  }
@@ -149857,6 +150049,7 @@ var Handler2 = async ({
149857
150049
  }
149858
150050
  const functionsDirectory = "./functions";
149859
150051
  let usingFunctions = (0, import_node_fs12.existsSync)(functionsDirectory);
150052
+ let usingWorkerScript = false;
149860
150053
  const command2 = remaining;
149861
150054
  let proxyPort;
149862
150055
  if (directory !== void 0 && command2.length > 0) {
@@ -149947,13 +150140,14 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
149947
150140
  if (!usingFunctions) {
149948
150141
  scriptReadyResolve();
149949
150142
  scriptPath = directory !== void 0 ? (0, import_node_path26.join)(directory, singleWorkerScriptPath) : singleWorkerScriptPath;
149950
- if (!(0, import_node_fs12.existsSync)(scriptPath)) {
150143
+ usingWorkerScript = (0, import_node_fs12.existsSync)(scriptPath);
150144
+ if (!usingWorkerScript) {
149951
150145
  logger.log("No functions. Shimming...");
149952
150146
  scriptPath = (0, import_node_path26.resolve)(getBasePath(), "templates/pages-shim.ts");
149953
150147
  } else {
149954
150148
  const runBuild = async () => {
149955
150149
  try {
149956
- await (0, import_esbuild6.build)({
150150
+ await esbuild3.build({
149957
150151
  entryPoints: [scriptPath],
149958
150152
  write: false,
149959
150153
  plugins: [blockWorkerJsImports]
@@ -149977,8 +150171,79 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
149977
150171
  1
149978
150172
  );
149979
150173
  }
150174
+ let entrypoint = scriptPath;
150175
+ if (directory && (usingFunctions || usingWorkerScript)) {
150176
+ const routesJSONPath = (0, import_node_path26.join)(directory, "_routes.json");
150177
+ if ((0, import_node_fs12.existsSync)(routesJSONPath)) {
150178
+ let routesJSONContents;
150179
+ const runBuild = async (entrypointFile, outfile, routes) => {
150180
+ await esbuild3.build({
150181
+ entryPoints: [
150182
+ (0, import_node_path26.resolve)(getBasePath(), "templates/pages-dev-pipeline.ts")
150183
+ ],
150184
+ bundle: true,
150185
+ sourcemap: true,
150186
+ format: "esm",
150187
+ plugins: [
150188
+ esbuildAliasExternalPlugin({
150189
+ __ENTRY_POINT__: entrypointFile
150190
+ })
150191
+ ],
150192
+ outfile,
150193
+ define: {
150194
+ __ROUTES__: routes
150195
+ }
150196
+ });
150197
+ };
150198
+ try {
150199
+ routesJSONContents = (0, import_node_fs12.readFileSync)(routesJSONPath, "utf-8");
150200
+ validateRoutes2(JSON.parse(routesJSONContents), directory);
150201
+ entrypoint = (0, import_node_path26.join)(
150202
+ (0, import_node_os9.tmpdir)(),
150203
+ `${Math.random().toString(36).slice(2)}.js`
150204
+ );
150205
+ await runBuild(scriptPath, entrypoint, routesJSONContents);
150206
+ } catch (err2) {
150207
+ if (err2 instanceof FatalError) {
150208
+ throw err2;
150209
+ } else {
150210
+ throw new FatalError(
150211
+ `Could not validate _routes.json at ${directory}: ${err2}`,
150212
+ 1
150213
+ );
150214
+ }
150215
+ }
150216
+ (0, import_chokidar3.watch)([routesJSONPath], {
150217
+ persistent: true,
150218
+ ignoreInitial: true
150219
+ }).on("all", async () => {
150220
+ try {
150221
+ routesJSONContents = (0, import_node_fs12.readFileSync)(routesJSONPath, "utf-8");
150222
+ validateRoutes2(JSON.parse(routesJSONContents), directory);
150223
+ await runBuild(scriptPath, entrypoint, routesJSONContents);
150224
+ } catch (err2) {
150225
+ const error = err2 instanceof FatalError ? err2 : `Could not validate _routes.json at ${directory}: ${err2}`;
150226
+ const defaultRoutesJSONSpec = {
150227
+ version: ROUTES_SPEC_VERSION,
150228
+ include: ["/*"],
150229
+ exclude: []
150230
+ };
150231
+ logger.error(error);
150232
+ logger.warn(
150233
+ `Falling back to the following _routes.json default: ${JSON.stringify(
150234
+ defaultRoutesJSONSpec,
150235
+ null,
150236
+ 2
150237
+ )}`
150238
+ );
150239
+ routesJSONContents = JSON.stringify(defaultRoutesJSONSpec);
150240
+ await runBuild(scriptPath, entrypoint, routesJSONContents);
150241
+ }
150242
+ });
150243
+ }
150244
+ }
149980
150245
  const { stop, waitUntilExit } = await unstable_dev(
149981
- scriptPath,
150246
+ entrypoint,
149982
150247
  {
149983
150248
  ip,
149984
150249
  port,
@@ -150023,7 +150288,7 @@ use --persist-to=./wrangler-local-state to keep using the old path.`
150023
150288
  persistTo,
150024
150289
  showInteractiveDevSession: void 0,
150025
150290
  inspect: true,
150026
- logLevel: "error",
150291
+ logLevel: "warn",
150027
150292
  logPrefix: "pages"
150028
150293
  },
150029
150294
  { testMode: false, disableExperimentalWarning: true }
@@ -150145,8 +150410,8 @@ async function spawnProxyProcess({
150145
150410
  }
150146
150411
  var blockWorkerJsImports = {
150147
150412
  name: "block-worker-js-imports",
150148
- setup(build6) {
150149
- build6.onResolve({ filter: /.*/g }, (_args) => {
150413
+ setup(build7) {
150414
+ build7.onResolve({ filter: /.*/g }, (_args) => {
150150
150415
  logger.error(
150151
150416
  `_worker.js is importing from another file. This will throw an error if deployed.
150152
150417
  You should bundle your Worker or remove the import if it is unused.`
@@ -150202,19 +150467,7 @@ async function OptimizeRoutesHandler({
150202
150467
  throw new FatalError(`Error while reading ${routesPath} file: ${err2}`);
150203
150468
  }
150204
150469
  const routes = JSON.parse(routesFileContents);
150205
- if (!isRoutesJSONSpec(routes)) {
150206
- throw new FatalError(
150207
- `
150208
- Invalid _routes.json file found at: ${routesPath}. Please make sure the JSON object has the following format:
150209
- {
150210
- version: ${ROUTES_SPEC_VERSION};
150211
- include: string[];
150212
- exclude: string[];
150213
- }
150214
- `,
150215
- 1
150216
- );
150217
- }
150470
+ validateRoutes2(routes, routesPath);
150218
150471
  const optimizedRoutes = optimizeRoutesJSONSpec(routes);
150219
150472
  const optimizedRoutesContents = JSON.stringify(optimizedRoutes);
150220
150473
  try {
@@ -151301,7 +151554,8 @@ To silence this warning, pass in --commit-dirty=true`
151301
151554
  logger.log(`\u2728 Uploading Functions`);
151302
151555
  if (_routesCustom) {
151303
151556
  try {
151304
- validateRoutesFile(_routesCustom, (0, import_node_path30.join)(directory, "_routes.json"));
151557
+ const routesCustomJSON = JSON.parse(_routesCustom);
151558
+ validateRoutes2(routesCustomJSON, (0, import_node_path30.join)(directory, "_routes.json"));
151305
151559
  formData2.append(
151306
151560
  "_routes.json",
151307
151561
  new import_undici9.File([_routesCustom], "_routes.json")
@@ -151332,7 +151586,8 @@ To silence this warning, pass in --commit-dirty=true`
151332
151586
  logger.log(`\u2728 Uploading _worker.js`);
151333
151587
  if (_routesCustom) {
151334
151588
  try {
151335
- validateRoutesFile(_routesCustom, (0, import_node_path30.join)(directory, "_routes.json"));
151589
+ const routesCustomJSON = JSON.parse(_routesCustom);
151590
+ validateRoutes2(routesCustomJSON, (0, import_node_path30.join)(directory, "_routes.json"));
151336
151591
  formData2.append(
151337
151592
  "_routes.json",
151338
151593
  new import_undici9.File([_routesCustom], "_routes.json")
@@ -151364,22 +151619,6 @@ To silence this warning, pass in --commit-dirty=true`
151364
151619
  );
151365
151620
  await sendMetricsEvent("create pages deployment");
151366
151621
  };
151367
- function validateRoutesFile(_routes, routesPath) {
151368
- const routes = JSON.parse(_routes);
151369
- if (!isRoutesJSONSpec(routes)) {
151370
- throw new FatalError(
151371
- `Invalid _routes.json file found at: ${routesPath}. Please make sure the JSON object has the following format:
151372
- {
151373
- version: ${ROUTES_SPEC_VERSION};
151374
- include: string[];
151375
- exclude: string[];
151376
- }
151377
- and that at least one include rule is provided.
151378
- `,
151379
- 1
151380
- );
151381
- }
151382
- }
151383
151622
 
151384
151623
  // src/pages/index.tsx
151385
151624
  process.on("SIGINT", () => {
@@ -151696,6 +151935,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
151696
151935
  const deployToWorkersDev = config.workers_dev ?? routes.length === 0;
151697
151936
  const jsxFactory = props.jsxFactory || config.jsx_factory;
151698
151937
  const jsxFragment = props.jsxFragment || config.jsx_fragment;
151938
+ const keepVars = props.keepVars ?? config.keep_vars;
151699
151939
  const minify = props.minify ?? config.minify;
151700
151940
  const nodeCompat = props.nodeCompat ?? config.node_compat;
151701
151941
  if (nodeCompat) {
@@ -151855,7 +152095,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
151855
152095
  compatibility_date: props.compatibilityDate ?? config.compatibility_date,
151856
152096
  compatibility_flags: props.compatibilityFlags ?? config.compatibility_flags,
151857
152097
  usage_model: config.usage_model,
151858
- keep_bindings: true
152098
+ keepVars
151859
152099
  };
151860
152100
  const bundleSizePromise = printBundleSize(
151861
152101
  { name: import_node_path31.default.basename(resolvedEntryPointPath), content },
@@ -153375,6 +153615,10 @@ function createCLIParser(argv) {
153375
153615
  }).option("dry-run", {
153376
153616
  describe: "Don't actually publish",
153377
153617
  type: "boolean"
153618
+ }).option("keep-vars", {
153619
+ describe: "Stop wrangler from deleting vars that are not present in the wrangler.toml\nBy default Wrangler will remove all vars and replace them with those found in the wrangler.toml configuration.\nIf your development approach is to modify vars after deployment via the dashboard you may wish to set this flag.",
153620
+ default: false,
153621
+ type: "boolean"
153378
153622
  }).option("legacy-env", {
153379
153623
  type: "boolean",
153380
153624
  describe: "Use legacy environments",
@@ -153458,7 +153702,8 @@ function createCLIParser(argv) {
153458
153702
  isWorkersSite: Boolean(args.site || config.site),
153459
153703
  outDir: args.outdir,
153460
153704
  dryRun: args.dryRun,
153461
- noBundle: !(args.bundle ?? !config.no_bundle)
153705
+ noBundle: !(args.bundle ?? !config.no_bundle),
153706
+ keepVars: args.keepVars
153462
153707
  });
153463
153708
  }
153464
153709
  );
@@ -153768,7 +154013,7 @@ ${shouldDo}`);
153768
154013
  compatibility_date: void 0,
153769
154014
  compatibility_flags: void 0,
153770
154015
  usage_model: void 0,
153771
- keep_bindings: false
154016
+ keepVars: false
153772
154017
  })
153773
154018
  }
153774
154019
  );
@@ -154971,6 +155216,14 @@ function devOptions(yargs) {
154971
155216
  type: "boolean",
154972
155217
  describe: "Use legacy environments",
154973
155218
  hidden: true
155219
+ }).option("test-scheduled", {
155220
+ describe: "Test scheduled events by visiting /__scheduled in browser",
155221
+ type: "boolean",
155222
+ default: false
155223
+ }).option("log-level", {
155224
+ choices: ["debug", "info", "log", "warn", "error", "none"],
155225
+ describe: "Specify logging level",
155226
+ default: "log"
154974
155227
  });
154975
155228
  }
154976
155229
  async function devHandler(args) {
@@ -155076,7 +155329,8 @@ async function startDev(args) {
155076
155329
  forceLocal: args.forceLocal,
155077
155330
  enablePagesAssetsServiceBinding: args.enablePagesAssetsServiceBinding,
155078
155331
  firstPartyWorker: configParam.first_party_worker,
155079
- sendMetrics: configParam.send_metrics
155332
+ sendMetrics: configParam.send_metrics,
155333
+ testScheduled: args["test-scheduled"]
155080
155334
  });
155081
155335
  }
155082
155336
  const devReactElement = (0, import_ink11.render)(await getDevReactElement(config));
@@ -155168,8 +155422,9 @@ async function startApiDev(args) {
155168
155422
  forceLocal: args.forceLocal,
155169
155423
  enablePagesAssetsServiceBinding: args.enablePagesAssetsServiceBinding,
155170
155424
  local: true,
155171
- firstPartyWorker: void 0,
155172
- sendMetrics: void 0
155425
+ firstPartyWorker: configParam.first_party_worker,
155426
+ sendMetrics: configParam.send_metrics,
155427
+ testScheduled: args.testScheduled
155173
155428
  });
155174
155429
  }
155175
155430
  const devServer = await getDevServer(config);
@@ -155280,7 +155535,10 @@ Move any existing data to .wrangler/state and use --persist, or
155280
155535
  use --persist-to=./wrangler-local-state to keep using the old path.`
155281
155536
  );
155282
155537
  }
155283
- const localPersistencePath = args.persistTo ? import_node_path33.default.resolve(process.cwd(), args.persistTo) : args.persist ? import_node_path33.default.resolve(config.configPath || process.cwd(), ".wrangler/state") : null;
155538
+ const localPersistencePath = args.persistTo ? import_node_path33.default.resolve(process.cwd(), args.persistTo) : args.persist ? import_node_path33.default.resolve(
155539
+ config.configPath ? import_node_path33.default.dirname(config.configPath) : process.cwd(),
155540
+ ".wrangler/state"
155541
+ ) : null;
155284
155542
  const cliDefines = args.define?.reduce((collectDefines, d) => {
155285
155543
  const [key2, ...value] = d.split(":");
155286
155544
  collectDefines[key2] = value.join("");