wrangler 0.0.21 → 0.0.24

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 (40) hide show
  1. package/README.md +1 -1
  2. package/bin/wrangler.js +10 -1
  3. package/miniflare-dist/index.mjs +79 -0
  4. package/miniflare-dist/index.mjs.map +7 -0
  5. package/package.json +3 -4
  6. package/src/__tests__/configuration.test.ts +522 -300
  7. package/src/__tests__/dev.test.tsx +99 -3
  8. package/src/__tests__/guess-worker-format.test.ts +10 -0
  9. package/src/__tests__/index.test.ts +3 -11
  10. package/src/__tests__/kv.test.ts +16 -18
  11. package/src/__tests__/pages.test.ts +48 -10
  12. package/src/__tests__/publish.test.ts +1319 -421
  13. package/src/__tests__/r2.test.ts +4 -4
  14. package/src/__tests__/tail.test.ts +29 -4
  15. package/src/bundle.ts +15 -2
  16. package/src/config/README.md +6 -6
  17. package/src/config/config.ts +16 -77
  18. package/src/config/environment.ts +67 -1
  19. package/src/config/index.ts +13 -3
  20. package/src/config/validation-helpers.ts +105 -19
  21. package/src/config/validation.ts +272 -97
  22. package/src/dev/dev.tsx +72 -42
  23. package/src/dev/local.tsx +103 -118
  24. package/src/dev/use-esbuild.ts +4 -0
  25. package/src/entry.ts +84 -3
  26. package/src/index.tsx +137 -113
  27. package/src/intl-polyfill.d.ts +139 -0
  28. package/src/kv.ts +7 -27
  29. package/src/miniflare-cli/README.md +30 -0
  30. package/src/miniflare-cli/enum-keys.ts +17 -0
  31. package/src/miniflare-cli/index.ts +37 -0
  32. package/src/module-collection.ts +58 -53
  33. package/src/pages.tsx +26 -10
  34. package/src/publish.ts +17 -21
  35. package/src/sites.tsx +59 -52
  36. package/src/tail/printing.ts +2 -2
  37. package/src/user.tsx +12 -3
  38. package/wrangler-dist/cli.js +836 -649
  39. package/wrangler-dist/cli.js.map +2 -2
  40. package/src/__tests__/dev2.test.tsx +0 -154
@@ -1659,20 +1659,20 @@ var require_parse_async = __commonJS({
1659
1659
  const index = 0;
1660
1660
  const blocksize = opts.blocksize || 40960;
1661
1661
  const parser2 = new TOMLParser();
1662
- return new Promise((resolve7, reject) => {
1663
- setImmediate(parseAsyncNext, index, blocksize, resolve7, reject);
1662
+ return new Promise((resolve8, reject) => {
1663
+ setImmediate(parseAsyncNext, index, blocksize, resolve8, reject);
1664
1664
  });
1665
- function parseAsyncNext(index2, blocksize2, resolve7, reject) {
1665
+ function parseAsyncNext(index2, blocksize2, resolve8, reject) {
1666
1666
  if (index2 >= str.length) {
1667
1667
  try {
1668
- return resolve7(parser2.finish());
1668
+ return resolve8(parser2.finish());
1669
1669
  } catch (err2) {
1670
1670
  return reject(prettyError(err2, str));
1671
1671
  }
1672
1672
  }
1673
1673
  try {
1674
1674
  parser2.parse(str.slice(index2, index2 + blocksize2));
1675
- setImmediate(parseAsyncNext, index2 + blocksize2, blocksize2, resolve7, reject);
1675
+ setImmediate(parseAsyncNext, index2 + blocksize2, blocksize2, resolve8, reject);
1676
1676
  } catch (err2) {
1677
1677
  reject(prettyError(err2, str));
1678
1678
  }
@@ -1699,7 +1699,7 @@ var require_parse_stream = __commonJS({
1699
1699
  function parseReadable(stm) {
1700
1700
  const parser2 = new TOMLParser();
1701
1701
  stm.setEncoding("utf8");
1702
- return new Promise((resolve7, reject) => {
1702
+ return new Promise((resolve8, reject) => {
1703
1703
  let readable;
1704
1704
  let ended = false;
1705
1705
  let errored = false;
@@ -1708,7 +1708,7 @@ var require_parse_stream = __commonJS({
1708
1708
  if (readable)
1709
1709
  return;
1710
1710
  try {
1711
- resolve7(parser2.finish());
1711
+ resolve8(parser2.finish());
1712
1712
  } catch (err2) {
1713
1713
  reject(err2);
1714
1714
  }
@@ -2167,11 +2167,11 @@ var require_tslib = __commonJS({
2167
2167
  };
2168
2168
  __awaiter = function(thisArg, _arguments, P, generator) {
2169
2169
  function adopt(value) {
2170
- return value instanceof P ? value : new P(function(resolve7) {
2171
- resolve7(value);
2170
+ return value instanceof P ? value : new P(function(resolve8) {
2171
+ resolve8(value);
2172
2172
  });
2173
2173
  }
2174
- return new (P || (P = Promise))(function(resolve7, reject) {
2174
+ return new (P || (P = Promise))(function(resolve8, reject) {
2175
2175
  function fulfilled(value) {
2176
2176
  try {
2177
2177
  step(generator.next(value));
@@ -2187,7 +2187,7 @@ var require_tslib = __commonJS({
2187
2187
  }
2188
2188
  }
2189
2189
  function step(result) {
2190
- result.done ? resolve7(result.value) : adopt(result.value).then(fulfilled, rejected);
2190
+ result.done ? resolve8(result.value) : adopt(result.value).then(fulfilled, rejected);
2191
2191
  }
2192
2192
  step((generator = generator.apply(thisArg, _arguments || [])).next());
2193
2193
  });
@@ -2387,14 +2387,14 @@ var require_tslib = __commonJS({
2387
2387
  }, i2);
2388
2388
  function verb(n) {
2389
2389
  i2[n] = o[n] && function(v) {
2390
- return new Promise(function(resolve7, reject) {
2391
- v = o[n](v), settle(resolve7, reject, v.done, v.value);
2390
+ return new Promise(function(resolve8, reject) {
2391
+ v = o[n](v), settle(resolve8, reject, v.done, v.value);
2392
2392
  });
2393
2393
  };
2394
2394
  }
2395
- function settle(resolve7, reject, d, v) {
2395
+ function settle(resolve8, reject, d, v) {
2396
2396
  Promise.resolve(v).then(function(v2) {
2397
- resolve7({ value: v2, done: d });
2397
+ resolve8({ value: v2, done: d });
2398
2398
  }, reject);
2399
2399
  }
2400
2400
  };
@@ -4075,7 +4075,7 @@ var require_path = __commonJS({
4075
4075
  var parts = splitPathRe.exec(filename);
4076
4076
  return parts ? parts.slice(1) : [];
4077
4077
  }
4078
- function resolve7() {
4078
+ function resolve8() {
4079
4079
  var args2 = [];
4080
4080
  for (var _i = 0; _i < arguments.length; _i++) {
4081
4081
  args2[_i] = arguments[_i];
@@ -4095,7 +4095,7 @@ var require_path = __commonJS({
4095
4095
  }), !resolvedAbsolute).join("/");
4096
4096
  return (resolvedAbsolute ? "/" : "") + resolvedPath || ".";
4097
4097
  }
4098
- exports2.resolve = resolve7;
4098
+ exports2.resolve = resolve8;
4099
4099
  function trim(arr) {
4100
4100
  var start = 0;
4101
4101
  for (; start < arr.length; start++) {
@@ -4115,8 +4115,8 @@ var require_path = __commonJS({
4115
4115
  return arr.slice(start, end - start + 1);
4116
4116
  }
4117
4117
  function relative4(from, to) {
4118
- from = resolve7(from).substr(1);
4119
- to = resolve7(to).substr(1);
4118
+ from = resolve8(from).substr(1);
4119
+ to = resolve8(to).substr(1);
4120
4120
  var fromParts = trim(from.split("/"));
4121
4121
  var toParts = trim(to.split("/"));
4122
4122
  var length = Math.min(fromParts.length, toParts.length);
@@ -4193,8 +4193,8 @@ var require_syncpromise = __commonJS({
4193
4193
  Object.defineProperty(exports2, "__esModule", { value: true });
4194
4194
  var is_1 = require_is();
4195
4195
  function resolvedSyncPromise(value) {
4196
- return new SyncPromise(function(resolve7) {
4197
- resolve7(value);
4196
+ return new SyncPromise(function(resolve8) {
4197
+ resolve8(value);
4198
4198
  });
4199
4199
  }
4200
4200
  exports2.resolvedSyncPromise = resolvedSyncPromise;
@@ -4254,15 +4254,15 @@ var require_syncpromise = __commonJS({
4254
4254
  }
4255
4255
  SyncPromise2.prototype.then = function(onfulfilled, onrejected) {
4256
4256
  var _this = this;
4257
- return new SyncPromise2(function(resolve7, reject) {
4257
+ return new SyncPromise2(function(resolve8, reject) {
4258
4258
  _this._handlers.push([
4259
4259
  false,
4260
4260
  function(result) {
4261
4261
  if (!onfulfilled) {
4262
- resolve7(result);
4262
+ resolve8(result);
4263
4263
  } else {
4264
4264
  try {
4265
- resolve7(onfulfilled(result));
4265
+ resolve8(onfulfilled(result));
4266
4266
  } catch (e2) {
4267
4267
  reject(e2);
4268
4268
  }
@@ -4273,7 +4273,7 @@ var require_syncpromise = __commonJS({
4273
4273
  reject(reason);
4274
4274
  } else {
4275
4275
  try {
4276
- resolve7(onrejected(reason));
4276
+ resolve8(onrejected(reason));
4277
4277
  } catch (e2) {
4278
4278
  reject(e2);
4279
4279
  }
@@ -4290,7 +4290,7 @@ var require_syncpromise = __commonJS({
4290
4290
  };
4291
4291
  SyncPromise2.prototype.finally = function(onfinally) {
4292
4292
  var _this = this;
4293
- return new SyncPromise2(function(resolve7, reject) {
4293
+ return new SyncPromise2(function(resolve8, reject) {
4294
4294
  var val;
4295
4295
  var isRejected;
4296
4296
  return _this.then(function(value) {
@@ -4310,7 +4310,7 @@ var require_syncpromise = __commonJS({
4310
4310
  reject(val);
4311
4311
  return;
4312
4312
  }
4313
- resolve7(val);
4313
+ resolve8(val);
4314
4314
  });
4315
4315
  });
4316
4316
  };
@@ -4352,21 +4352,21 @@ var require_promisebuffer = __commonJS({
4352
4352
  return task;
4353
4353
  }
4354
4354
  function drain(timeout) {
4355
- return new syncpromise_1.SyncPromise(function(resolve7, reject) {
4355
+ return new syncpromise_1.SyncPromise(function(resolve8, reject) {
4356
4356
  var counter = buffer2.length;
4357
4357
  if (!counter) {
4358
- return resolve7(true);
4358
+ return resolve8(true);
4359
4359
  }
4360
4360
  var capturedSetTimeout = setTimeout(function() {
4361
4361
  if (timeout && timeout > 0) {
4362
- resolve7(false);
4362
+ resolve8(false);
4363
4363
  }
4364
4364
  }, timeout);
4365
4365
  buffer2.forEach(function(item) {
4366
4366
  void syncpromise_1.resolvedSyncPromise(item).then(function() {
4367
4367
  if (!--counter) {
4368
4368
  clearTimeout(capturedSetTimeout);
4369
- resolve7(true);
4369
+ resolve8(true);
4370
4370
  }
4371
4371
  }, reject);
4372
4372
  });
@@ -5303,8 +5303,8 @@ var require_localforage = __commonJS({
5303
5303
  }
5304
5304
  return out;
5305
5305
  }
5306
- Promise2.resolve = resolve7;
5307
- function resolve7(value) {
5306
+ Promise2.resolve = resolve8;
5307
+ function resolve8(value) {
5308
5308
  if (value instanceof this) {
5309
5309
  return value;
5310
5310
  }
@@ -5500,19 +5500,19 @@ var require_localforage = __commonJS({
5500
5500
  return buf;
5501
5501
  }
5502
5502
  function _checkBlobSupportWithoutCaching(idb2) {
5503
- return new Promise$1(function(resolve7) {
5503
+ return new Promise$1(function(resolve8) {
5504
5504
  var txn = idb2.transaction(DETECT_BLOB_SUPPORT_STORE, READ_WRITE);
5505
5505
  var blob = createBlob([""]);
5506
5506
  txn.objectStore(DETECT_BLOB_SUPPORT_STORE).put(blob, "key");
5507
5507
  txn.onabort = function(e2) {
5508
5508
  e2.preventDefault();
5509
5509
  e2.stopPropagation();
5510
- resolve7(false);
5510
+ resolve8(false);
5511
5511
  };
5512
5512
  txn.oncomplete = function() {
5513
5513
  var matchedChrome = navigator.userAgent.match(/Chrome\/(\d+)/);
5514
5514
  var matchedEdge = navigator.userAgent.match(/Edge\//);
5515
- resolve7(matchedEdge || !matchedChrome || parseInt(matchedChrome[1], 10) >= 43);
5515
+ resolve8(matchedEdge || !matchedChrome || parseInt(matchedChrome[1], 10) >= 43);
5516
5516
  };
5517
5517
  })["catch"](function() {
5518
5518
  return false;
@@ -5530,8 +5530,8 @@ var require_localforage = __commonJS({
5530
5530
  function _deferReadiness(dbInfo) {
5531
5531
  var dbContext = dbContexts[dbInfo.name];
5532
5532
  var deferredOperation = {};
5533
- deferredOperation.promise = new Promise$1(function(resolve7, reject) {
5534
- deferredOperation.resolve = resolve7;
5533
+ deferredOperation.promise = new Promise$1(function(resolve8, reject) {
5534
+ deferredOperation.resolve = resolve8;
5535
5535
  deferredOperation.reject = reject;
5536
5536
  });
5537
5537
  dbContext.deferredOperations.push(deferredOperation);
@@ -5560,14 +5560,14 @@ var require_localforage = __commonJS({
5560
5560
  }
5561
5561
  }
5562
5562
  function _getConnection(dbInfo, upgradeNeeded) {
5563
- return new Promise$1(function(resolve7, reject) {
5563
+ return new Promise$1(function(resolve8, reject) {
5564
5564
  dbContexts[dbInfo.name] = dbContexts[dbInfo.name] || createDbContext();
5565
5565
  if (dbInfo.db) {
5566
5566
  if (upgradeNeeded) {
5567
5567
  _deferReadiness(dbInfo);
5568
5568
  dbInfo.db.close();
5569
5569
  } else {
5570
- return resolve7(dbInfo.db);
5570
+ return resolve8(dbInfo.db);
5571
5571
  }
5572
5572
  }
5573
5573
  var dbArgs = [dbInfo.name];
@@ -5601,7 +5601,7 @@ var require_localforage = __commonJS({
5601
5601
  db.onversionchange = function(e2) {
5602
5602
  e2.target.close();
5603
5603
  };
5604
- resolve7(db);
5604
+ resolve8(db);
5605
5605
  _advanceReadiness(dbInfo);
5606
5606
  };
5607
5607
  });
@@ -5637,12 +5637,12 @@ var require_localforage = __commonJS({
5637
5637
  return false;
5638
5638
  }
5639
5639
  function _encodeBlob(blob) {
5640
- return new Promise$1(function(resolve7, reject) {
5640
+ return new Promise$1(function(resolve8, reject) {
5641
5641
  var reader = new FileReader();
5642
5642
  reader.onerror = reject;
5643
5643
  reader.onloadend = function(e2) {
5644
5644
  var base64 = btoa(e2.target.result || "");
5645
- resolve7({
5645
+ resolve8({
5646
5646
  __local_forage_encoded_blob: true,
5647
5647
  data: base64,
5648
5648
  type: blob.type
@@ -5785,7 +5785,7 @@ var require_localforage = __commonJS({
5785
5785
  function getItem(key3, callback) {
5786
5786
  var self2 = this;
5787
5787
  key3 = normalizeKey(key3);
5788
- var promise = new Promise$1(function(resolve7, reject) {
5788
+ var promise = new Promise$1(function(resolve8, reject) {
5789
5789
  self2.ready().then(function() {
5790
5790
  createTransaction(self2._dbInfo, READ_ONLY, function(err2, transaction) {
5791
5791
  if (err2) {
@@ -5802,7 +5802,7 @@ var require_localforage = __commonJS({
5802
5802
  if (_isEncodedBlob(value)) {
5803
5803
  value = _decodeBlob(value);
5804
5804
  }
5805
- resolve7(value);
5805
+ resolve8(value);
5806
5806
  };
5807
5807
  req.onerror = function() {
5808
5808
  reject(req.error);
@@ -5818,7 +5818,7 @@ var require_localforage = __commonJS({
5818
5818
  }
5819
5819
  function iterate(iterator, callback) {
5820
5820
  var self2 = this;
5821
- var promise = new Promise$1(function(resolve7, reject) {
5821
+ var promise = new Promise$1(function(resolve8, reject) {
5822
5822
  self2.ready().then(function() {
5823
5823
  createTransaction(self2._dbInfo, READ_ONLY, function(err2, transaction) {
5824
5824
  if (err2) {
@@ -5837,12 +5837,12 @@ var require_localforage = __commonJS({
5837
5837
  }
5838
5838
  var result = iterator(value, cursor.key, iterationNumber++);
5839
5839
  if (result !== void 0) {
5840
- resolve7(result);
5840
+ resolve8(result);
5841
5841
  } else {
5842
5842
  cursor["continue"]();
5843
5843
  }
5844
5844
  } else {
5845
- resolve7();
5845
+ resolve8();
5846
5846
  }
5847
5847
  };
5848
5848
  req.onerror = function() {
@@ -5860,7 +5860,7 @@ var require_localforage = __commonJS({
5860
5860
  function setItem(key3, value, callback) {
5861
5861
  var self2 = this;
5862
5862
  key3 = normalizeKey(key3);
5863
- var promise = new Promise$1(function(resolve7, reject) {
5863
+ var promise = new Promise$1(function(resolve8, reject) {
5864
5864
  var dbInfo;
5865
5865
  self2.ready().then(function() {
5866
5866
  dbInfo = self2._dbInfo;
@@ -5888,7 +5888,7 @@ var require_localforage = __commonJS({
5888
5888
  if (value2 === void 0) {
5889
5889
  value2 = null;
5890
5890
  }
5891
- resolve7(value2);
5891
+ resolve8(value2);
5892
5892
  };
5893
5893
  transaction.onabort = transaction.onerror = function() {
5894
5894
  var err3 = req.error ? req.error : req.transaction.error;
@@ -5906,7 +5906,7 @@ var require_localforage = __commonJS({
5906
5906
  function removeItem(key3, callback) {
5907
5907
  var self2 = this;
5908
5908
  key3 = normalizeKey(key3);
5909
- var promise = new Promise$1(function(resolve7, reject) {
5909
+ var promise = new Promise$1(function(resolve8, reject) {
5910
5910
  self2.ready().then(function() {
5911
5911
  createTransaction(self2._dbInfo, READ_WRITE, function(err2, transaction) {
5912
5912
  if (err2) {
@@ -5916,7 +5916,7 @@ var require_localforage = __commonJS({
5916
5916
  var store = transaction.objectStore(self2._dbInfo.storeName);
5917
5917
  var req = store["delete"](key3);
5918
5918
  transaction.oncomplete = function() {
5919
- resolve7();
5919
+ resolve8();
5920
5920
  };
5921
5921
  transaction.onerror = function() {
5922
5922
  reject(req.error);
@@ -5936,7 +5936,7 @@ var require_localforage = __commonJS({
5936
5936
  }
5937
5937
  function clear(callback) {
5938
5938
  var self2 = this;
5939
- var promise = new Promise$1(function(resolve7, reject) {
5939
+ var promise = new Promise$1(function(resolve8, reject) {
5940
5940
  self2.ready().then(function() {
5941
5941
  createTransaction(self2._dbInfo, READ_WRITE, function(err2, transaction) {
5942
5942
  if (err2) {
@@ -5946,7 +5946,7 @@ var require_localforage = __commonJS({
5946
5946
  var store = transaction.objectStore(self2._dbInfo.storeName);
5947
5947
  var req = store.clear();
5948
5948
  transaction.oncomplete = function() {
5949
- resolve7();
5949
+ resolve8();
5950
5950
  };
5951
5951
  transaction.onabort = transaction.onerror = function() {
5952
5952
  var err3 = req.error ? req.error : req.transaction.error;
@@ -5963,7 +5963,7 @@ var require_localforage = __commonJS({
5963
5963
  }
5964
5964
  function length(callback) {
5965
5965
  var self2 = this;
5966
- var promise = new Promise$1(function(resolve7, reject) {
5966
+ var promise = new Promise$1(function(resolve8, reject) {
5967
5967
  self2.ready().then(function() {
5968
5968
  createTransaction(self2._dbInfo, READ_ONLY, function(err2, transaction) {
5969
5969
  if (err2) {
@@ -5973,7 +5973,7 @@ var require_localforage = __commonJS({
5973
5973
  var store = transaction.objectStore(self2._dbInfo.storeName);
5974
5974
  var req = store.count();
5975
5975
  req.onsuccess = function() {
5976
- resolve7(req.result);
5976
+ resolve8(req.result);
5977
5977
  };
5978
5978
  req.onerror = function() {
5979
5979
  reject(req.error);
@@ -5989,9 +5989,9 @@ var require_localforage = __commonJS({
5989
5989
  }
5990
5990
  function key2(n, callback) {
5991
5991
  var self2 = this;
5992
- var promise = new Promise$1(function(resolve7, reject) {
5992
+ var promise = new Promise$1(function(resolve8, reject) {
5993
5993
  if (n < 0) {
5994
- resolve7(null);
5994
+ resolve8(null);
5995
5995
  return;
5996
5996
  }
5997
5997
  self2.ready().then(function() {
@@ -6006,17 +6006,17 @@ var require_localforage = __commonJS({
6006
6006
  req.onsuccess = function() {
6007
6007
  var cursor = req.result;
6008
6008
  if (!cursor) {
6009
- resolve7(null);
6009
+ resolve8(null);
6010
6010
  return;
6011
6011
  }
6012
6012
  if (n === 0) {
6013
- resolve7(cursor.key);
6013
+ resolve8(cursor.key);
6014
6014
  } else {
6015
6015
  if (!advanced) {
6016
6016
  advanced = true;
6017
6017
  cursor.advance(n);
6018
6018
  } else {
6019
- resolve7(cursor.key);
6019
+ resolve8(cursor.key);
6020
6020
  }
6021
6021
  }
6022
6022
  };
@@ -6034,7 +6034,7 @@ var require_localforage = __commonJS({
6034
6034
  }
6035
6035
  function keys(callback) {
6036
6036
  var self2 = this;
6037
- var promise = new Promise$1(function(resolve7, reject) {
6037
+ var promise = new Promise$1(function(resolve8, reject) {
6038
6038
  self2.ready().then(function() {
6039
6039
  createTransaction(self2._dbInfo, READ_ONLY, function(err2, transaction) {
6040
6040
  if (err2) {
@@ -6047,7 +6047,7 @@ var require_localforage = __commonJS({
6047
6047
  req.onsuccess = function() {
6048
6048
  var cursor = req.result;
6049
6049
  if (!cursor) {
6050
- resolve7(keys2);
6050
+ resolve8(keys2);
6051
6051
  return;
6052
6052
  }
6053
6053
  keys2.push(cursor.key);
@@ -6098,7 +6098,7 @@ var require_localforage = __commonJS({
6098
6098
  var forage = forages[i2];
6099
6099
  forage._dbInfo.db = null;
6100
6100
  }
6101
- var dropDBPromise = new Promise$1(function(resolve7, reject) {
6101
+ var dropDBPromise = new Promise$1(function(resolve8, reject) {
6102
6102
  var req = idb.deleteDatabase(options.name);
6103
6103
  req.onerror = function() {
6104
6104
  var db2 = req.result;
@@ -6115,7 +6115,7 @@ var require_localforage = __commonJS({
6115
6115
  if (db2) {
6116
6116
  db2.close();
6117
6117
  }
6118
- resolve7(db2);
6118
+ resolve8(db2);
6119
6119
  };
6120
6120
  });
6121
6121
  return dropDBPromise.then(function(db2) {
@@ -6145,7 +6145,7 @@ var require_localforage = __commonJS({
6145
6145
  forage._dbInfo.db = null;
6146
6146
  forage._dbInfo.version = newVersion;
6147
6147
  }
6148
- var dropObjectPromise = new Promise$1(function(resolve7, reject) {
6148
+ var dropObjectPromise = new Promise$1(function(resolve8, reject) {
6149
6149
  var req = idb.open(options.name, newVersion);
6150
6150
  req.onerror = function(err2) {
6151
6151
  var db2 = req.result;
@@ -6159,7 +6159,7 @@ var require_localforage = __commonJS({
6159
6159
  req.onsuccess = function() {
6160
6160
  var db2 = req.result;
6161
6161
  db2.close();
6162
- resolve7(db2);
6162
+ resolve8(db2);
6163
6163
  };
6164
6164
  });
6165
6165
  return dropObjectPromise.then(function(db2) {
@@ -6368,7 +6368,7 @@ var require_localforage = __commonJS({
6368
6368
  dbInfo[i2] = typeof options[i2] !== "string" ? options[i2].toString() : options[i2];
6369
6369
  }
6370
6370
  }
6371
- var dbInfoPromise = new Promise$1(function(resolve7, reject) {
6371
+ var dbInfoPromise = new Promise$1(function(resolve8, reject) {
6372
6372
  try {
6373
6373
  dbInfo.db = openDatabase(dbInfo.name, String(dbInfo.version), dbInfo.description, dbInfo.size);
6374
6374
  } catch (e2) {
@@ -6377,7 +6377,7 @@ var require_localforage = __commonJS({
6377
6377
  dbInfo.db.transaction(function(t2) {
6378
6378
  createDbTable(t2, dbInfo, function() {
6379
6379
  self2._dbInfo = dbInfo;
6380
- resolve7();
6380
+ resolve8();
6381
6381
  }, function(t3, error) {
6382
6382
  reject(error);
6383
6383
  });
@@ -6406,7 +6406,7 @@ var require_localforage = __commonJS({
6406
6406
  function getItem$1(key3, callback) {
6407
6407
  var self2 = this;
6408
6408
  key3 = normalizeKey(key3);
6409
- var promise = new Promise$1(function(resolve7, reject) {
6409
+ var promise = new Promise$1(function(resolve8, reject) {
6410
6410
  self2.ready().then(function() {
6411
6411
  var dbInfo = self2._dbInfo;
6412
6412
  dbInfo.db.transaction(function(t2) {
@@ -6415,7 +6415,7 @@ var require_localforage = __commonJS({
6415
6415
  if (result) {
6416
6416
  result = dbInfo.serializer.deserialize(result);
6417
6417
  }
6418
- resolve7(result);
6418
+ resolve8(result);
6419
6419
  }, function(t3, error) {
6420
6420
  reject(error);
6421
6421
  });
@@ -6427,7 +6427,7 @@ var require_localforage = __commonJS({
6427
6427
  }
6428
6428
  function iterate$1(iterator, callback) {
6429
6429
  var self2 = this;
6430
- var promise = new Promise$1(function(resolve7, reject) {
6430
+ var promise = new Promise$1(function(resolve8, reject) {
6431
6431
  self2.ready().then(function() {
6432
6432
  var dbInfo = self2._dbInfo;
6433
6433
  dbInfo.db.transaction(function(t2) {
@@ -6442,11 +6442,11 @@ var require_localforage = __commonJS({
6442
6442
  }
6443
6443
  result = iterator(result, item.key, i2 + 1);
6444
6444
  if (result !== void 0) {
6445
- resolve7(result);
6445
+ resolve8(result);
6446
6446
  return;
6447
6447
  }
6448
6448
  }
6449
- resolve7();
6449
+ resolve8();
6450
6450
  }, function(t3, error) {
6451
6451
  reject(error);
6452
6452
  });
@@ -6459,7 +6459,7 @@ var require_localforage = __commonJS({
6459
6459
  function _setItem(key3, value, callback, retriesLeft) {
6460
6460
  var self2 = this;
6461
6461
  key3 = normalizeKey(key3);
6462
- var promise = new Promise$1(function(resolve7, reject) {
6462
+ var promise = new Promise$1(function(resolve8, reject) {
6463
6463
  self2.ready().then(function() {
6464
6464
  if (value === void 0) {
6465
6465
  value = null;
@@ -6472,14 +6472,14 @@ var require_localforage = __commonJS({
6472
6472
  } else {
6473
6473
  dbInfo.db.transaction(function(t2) {
6474
6474
  tryExecuteSql(t2, dbInfo, "INSERT OR REPLACE INTO " + dbInfo.storeName + " (key, value) VALUES (?, ?)", [key3, value2], function() {
6475
- resolve7(originalValue);
6475
+ resolve8(originalValue);
6476
6476
  }, function(t3, error2) {
6477
6477
  reject(error2);
6478
6478
  });
6479
6479
  }, function(sqlError) {
6480
6480
  if (sqlError.code === sqlError.QUOTA_ERR) {
6481
6481
  if (retriesLeft > 0) {
6482
- resolve7(_setItem.apply(self2, [key3, originalValue, callback, retriesLeft - 1]));
6482
+ resolve8(_setItem.apply(self2, [key3, originalValue, callback, retriesLeft - 1]));
6483
6483
  return;
6484
6484
  }
6485
6485
  reject(sqlError);
@@ -6498,12 +6498,12 @@ var require_localforage = __commonJS({
6498
6498
  function removeItem$1(key3, callback) {
6499
6499
  var self2 = this;
6500
6500
  key3 = normalizeKey(key3);
6501
- var promise = new Promise$1(function(resolve7, reject) {
6501
+ var promise = new Promise$1(function(resolve8, reject) {
6502
6502
  self2.ready().then(function() {
6503
6503
  var dbInfo = self2._dbInfo;
6504
6504
  dbInfo.db.transaction(function(t2) {
6505
6505
  tryExecuteSql(t2, dbInfo, "DELETE FROM " + dbInfo.storeName + " WHERE key = ?", [key3], function() {
6506
- resolve7();
6506
+ resolve8();
6507
6507
  }, function(t3, error) {
6508
6508
  reject(error);
6509
6509
  });
@@ -6515,12 +6515,12 @@ var require_localforage = __commonJS({
6515
6515
  }
6516
6516
  function clear$1(callback) {
6517
6517
  var self2 = this;
6518
- var promise = new Promise$1(function(resolve7, reject) {
6518
+ var promise = new Promise$1(function(resolve8, reject) {
6519
6519
  self2.ready().then(function() {
6520
6520
  var dbInfo = self2._dbInfo;
6521
6521
  dbInfo.db.transaction(function(t2) {
6522
6522
  tryExecuteSql(t2, dbInfo, "DELETE FROM " + dbInfo.storeName, [], function() {
6523
- resolve7();
6523
+ resolve8();
6524
6524
  }, function(t3, error) {
6525
6525
  reject(error);
6526
6526
  });
@@ -6532,13 +6532,13 @@ var require_localforage = __commonJS({
6532
6532
  }
6533
6533
  function length$1(callback) {
6534
6534
  var self2 = this;
6535
- var promise = new Promise$1(function(resolve7, reject) {
6535
+ var promise = new Promise$1(function(resolve8, reject) {
6536
6536
  self2.ready().then(function() {
6537
6537
  var dbInfo = self2._dbInfo;
6538
6538
  dbInfo.db.transaction(function(t2) {
6539
6539
  tryExecuteSql(t2, dbInfo, "SELECT COUNT(key) as c FROM " + dbInfo.storeName, [], function(t3, results) {
6540
6540
  var result = results.rows.item(0).c;
6541
- resolve7(result);
6541
+ resolve8(result);
6542
6542
  }, function(t3, error) {
6543
6543
  reject(error);
6544
6544
  });
@@ -6550,13 +6550,13 @@ var require_localforage = __commonJS({
6550
6550
  }
6551
6551
  function key$1(n, callback) {
6552
6552
  var self2 = this;
6553
- var promise = new Promise$1(function(resolve7, reject) {
6553
+ var promise = new Promise$1(function(resolve8, reject) {
6554
6554
  self2.ready().then(function() {
6555
6555
  var dbInfo = self2._dbInfo;
6556
6556
  dbInfo.db.transaction(function(t2) {
6557
6557
  tryExecuteSql(t2, dbInfo, "SELECT key FROM " + dbInfo.storeName + " WHERE id = ? LIMIT 1", [n + 1], function(t3, results) {
6558
6558
  var result = results.rows.length ? results.rows.item(0).key : null;
6559
- resolve7(result);
6559
+ resolve8(result);
6560
6560
  }, function(t3, error) {
6561
6561
  reject(error);
6562
6562
  });
@@ -6568,7 +6568,7 @@ var require_localforage = __commonJS({
6568
6568
  }
6569
6569
  function keys$1(callback) {
6570
6570
  var self2 = this;
6571
- var promise = new Promise$1(function(resolve7, reject) {
6571
+ var promise = new Promise$1(function(resolve8, reject) {
6572
6572
  self2.ready().then(function() {
6573
6573
  var dbInfo = self2._dbInfo;
6574
6574
  dbInfo.db.transaction(function(t2) {
@@ -6577,7 +6577,7 @@ var require_localforage = __commonJS({
6577
6577
  for (var i2 = 0; i2 < results.rows.length; i2++) {
6578
6578
  keys2.push(results.rows.item(i2).key);
6579
6579
  }
6580
- resolve7(keys2);
6580
+ resolve8(keys2);
6581
6581
  }, function(t3, error) {
6582
6582
  reject(error);
6583
6583
  });
@@ -6588,14 +6588,14 @@ var require_localforage = __commonJS({
6588
6588
  return promise;
6589
6589
  }
6590
6590
  function getAllStoreNames(db) {
6591
- return new Promise$1(function(resolve7, reject) {
6591
+ return new Promise$1(function(resolve8, reject) {
6592
6592
  db.transaction(function(t2) {
6593
6593
  t2.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'", [], function(t3, results) {
6594
6594
  var storeNames = [];
6595
6595
  for (var i2 = 0; i2 < results.rows.length; i2++) {
6596
6596
  storeNames.push(results.rows.item(i2).name);
6597
6597
  }
6598
- resolve7({
6598
+ resolve8({
6599
6599
  db,
6600
6600
  storeNames
6601
6601
  });
@@ -6620,7 +6620,7 @@ var require_localforage = __commonJS({
6620
6620
  if (!options.name) {
6621
6621
  promise = Promise$1.reject("Invalid arguments");
6622
6622
  } else {
6623
- promise = new Promise$1(function(resolve7) {
6623
+ promise = new Promise$1(function(resolve8) {
6624
6624
  var db;
6625
6625
  if (options.name === currentConfig.name) {
6626
6626
  db = self2._dbInfo.db;
@@ -6628,20 +6628,20 @@ var require_localforage = __commonJS({
6628
6628
  db = openDatabase(options.name, "", "", 0);
6629
6629
  }
6630
6630
  if (!options.storeName) {
6631
- resolve7(getAllStoreNames(db));
6631
+ resolve8(getAllStoreNames(db));
6632
6632
  } else {
6633
- resolve7({
6633
+ resolve8({
6634
6634
  db,
6635
6635
  storeNames: [options.storeName]
6636
6636
  });
6637
6637
  }
6638
6638
  }).then(function(operationInfo) {
6639
- return new Promise$1(function(resolve7, reject) {
6639
+ return new Promise$1(function(resolve8, reject) {
6640
6640
  operationInfo.db.transaction(function(t2) {
6641
6641
  function dropTable(storeName) {
6642
- return new Promise$1(function(resolve8, reject2) {
6642
+ return new Promise$1(function(resolve9, reject2) {
6643
6643
  t2.executeSql("DROP TABLE IF EXISTS " + storeName, [], function() {
6644
- resolve8();
6644
+ resolve9();
6645
6645
  }, function(t3, error) {
6646
6646
  reject2(error);
6647
6647
  });
@@ -6652,7 +6652,7 @@ var require_localforage = __commonJS({
6652
6652
  operations.push(dropTable(operationInfo.storeNames[i2]));
6653
6653
  }
6654
6654
  Promise$1.all(operations).then(function() {
6655
- resolve7();
6655
+ resolve8();
6656
6656
  })["catch"](function(e2) {
6657
6657
  reject(e2);
6658
6658
  });
@@ -6837,7 +6837,7 @@ var require_localforage = __commonJS({
6837
6837
  value = null;
6838
6838
  }
6839
6839
  var originalValue = value;
6840
- return new Promise$1(function(resolve7, reject) {
6840
+ return new Promise$1(function(resolve8, reject) {
6841
6841
  var dbInfo = self2._dbInfo;
6842
6842
  dbInfo.serializer.serialize(value, function(value2, error) {
6843
6843
  if (error) {
@@ -6845,7 +6845,7 @@ var require_localforage = __commonJS({
6845
6845
  } else {
6846
6846
  try {
6847
6847
  localStorage.setItem(dbInfo.keyPrefix + key3, value2);
6848
- resolve7(originalValue);
6848
+ resolve8(originalValue);
6849
6849
  } catch (e2) {
6850
6850
  if (e2.name === "QuotaExceededError" || e2.name === "NS_ERROR_DOM_QUOTA_REACHED") {
6851
6851
  reject(e2);
@@ -6872,11 +6872,11 @@ var require_localforage = __commonJS({
6872
6872
  if (!options.name) {
6873
6873
  promise = Promise$1.reject("Invalid arguments");
6874
6874
  } else {
6875
- promise = new Promise$1(function(resolve7) {
6875
+ promise = new Promise$1(function(resolve8) {
6876
6876
  if (!options.storeName) {
6877
- resolve7(options.name + "/");
6877
+ resolve8(options.name + "/");
6878
6878
  } else {
6879
- resolve7(_getKeyPrefix(options, self2._defaultConfig));
6879
+ resolve8(_getKeyPrefix(options, self2._defaultConfig));
6880
6880
  }
6881
6881
  }).then(function(keyPrefix) {
6882
6882
  for (var i2 = localStorage.length - 1; i2 >= 0; i2--) {
@@ -7012,7 +7012,7 @@ var require_localforage = __commonJS({
7012
7012
  }
7013
7013
  };
7014
7014
  LocalForage2.prototype.defineDriver = function defineDriver(driverObject, callback, errorCallback) {
7015
- var promise = new Promise$1(function(resolve7, reject) {
7015
+ var promise = new Promise$1(function(resolve8, reject) {
7016
7016
  try {
7017
7017
  var driverName = driverObject._driver;
7018
7018
  var complianceError = new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");
@@ -7052,7 +7052,7 @@ var require_localforage = __commonJS({
7052
7052
  }
7053
7053
  DefinedDrivers[driverName] = driverObject;
7054
7054
  DriverSupport[driverName] = support;
7055
- resolve7();
7055
+ resolve8();
7056
7056
  };
7057
7057
  if ("_support" in driverObject) {
7058
7058
  if (driverObject._support && typeof driverObject._support === "function") {
@@ -8059,18 +8059,18 @@ var require_scope = __commonJS({
8059
8059
  if (index === void 0) {
8060
8060
  index = 0;
8061
8061
  }
8062
- return new utils_1.SyncPromise(function(resolve7, reject) {
8062
+ return new utils_1.SyncPromise(function(resolve8, reject) {
8063
8063
  var processor = processors[index];
8064
8064
  if (event === null || typeof processor !== "function") {
8065
- resolve7(event);
8065
+ resolve8(event);
8066
8066
  } else {
8067
8067
  var result = processor(tslib_1.__assign({}, event), hint);
8068
8068
  if (utils_1.isThenable(result)) {
8069
8069
  void result.then(function(final) {
8070
- return _this._notifyEventProcessors(processors, final, hint, index + 1).then(resolve7);
8070
+ return _this._notifyEventProcessors(processors, final, hint, index + 1).then(resolve8);
8071
8071
  }).then(null, reject);
8072
8072
  } else {
8073
- void _this._notifyEventProcessors(processors, result, hint, index + 1).then(resolve7).then(null, reject);
8073
+ void _this._notifyEventProcessors(processors, result, hint, index + 1).then(resolve8).then(null, reject);
8074
8074
  }
8075
8075
  }
8076
8076
  });
@@ -9105,18 +9105,18 @@ var require_baseclient = __commonJS({
9105
9105
  };
9106
9106
  BaseClient2.prototype._isClientDoneProcessing = function(timeout) {
9107
9107
  var _this = this;
9108
- return new utils_1.SyncPromise(function(resolve7) {
9108
+ return new utils_1.SyncPromise(function(resolve8) {
9109
9109
  var ticked = 0;
9110
9110
  var tick = 1;
9111
9111
  var interval2 = setInterval(function() {
9112
9112
  if (_this._numProcessing == 0) {
9113
9113
  clearInterval(interval2);
9114
- resolve7(true);
9114
+ resolve8(true);
9115
9115
  } else {
9116
9116
  ticked += tick;
9117
9117
  if (timeout && ticked >= timeout) {
9118
9118
  clearInterval(interval2);
9119
- resolve7(false);
9119
+ resolve8(false);
9120
9120
  }
9121
9121
  }
9122
9122
  }, tick);
@@ -10122,7 +10122,7 @@ var require_parsers = __commonJS({
10122
10122
  if (filenames.length === 0) {
10123
10123
  return utils_1.resolvedSyncPromise({});
10124
10124
  }
10125
- return new utils_1.SyncPromise(function(resolve7) {
10125
+ return new utils_1.SyncPromise(function(resolve8) {
10126
10126
  var sourceFiles = {};
10127
10127
  var count = 0;
10128
10128
  var _loop_1 = function(i3) {
@@ -10134,7 +10134,7 @@ var require_parsers = __commonJS({
10134
10134
  }
10135
10135
  count++;
10136
10136
  if (count === filenames.length) {
10137
- resolve7(sourceFiles);
10137
+ resolve8(sourceFiles);
10138
10138
  }
10139
10139
  return "continue";
10140
10140
  }
@@ -10144,7 +10144,7 @@ var require_parsers = __commonJS({
10144
10144
  FILE_CONTENT_CACHE.set(filename, content);
10145
10145
  count++;
10146
10146
  if (count === filenames.length) {
10147
- resolve7(sourceFiles);
10147
+ resolve8(sourceFiles);
10148
10148
  }
10149
10149
  });
10150
10150
  };
@@ -10193,7 +10193,7 @@ var require_parsers = __commonJS({
10193
10193
  }
10194
10194
  exports2.parseStack = parseStack;
10195
10195
  function addPrePostContext(filesToRead, frames, linesOfContext) {
10196
- return new utils_1.SyncPromise(function(resolve7) {
10196
+ return new utils_1.SyncPromise(function(resolve8) {
10197
10197
  return readSourceFiles(filesToRead).then(function(sourceFiles) {
10198
10198
  var result = frames.map(function(frame) {
10199
10199
  if (frame.filename && sourceFiles[frame.filename]) {
@@ -10205,14 +10205,14 @@ var require_parsers = __commonJS({
10205
10205
  }
10206
10206
  return frame;
10207
10207
  });
10208
- resolve7(result);
10208
+ resolve8(result);
10209
10209
  });
10210
10210
  });
10211
10211
  }
10212
10212
  function getExceptionFromError(error, options) {
10213
10213
  var name2 = error.name || error.constructor.name;
10214
10214
  var stack2 = extractStackFromError(error);
10215
- return new utils_1.SyncPromise(function(resolve7) {
10215
+ return new utils_1.SyncPromise(function(resolve8) {
10216
10216
  return parseStack(stack2, options).then(function(frames) {
10217
10217
  var result = {
10218
10218
  stacktrace: {
@@ -10221,15 +10221,15 @@ var require_parsers = __commonJS({
10221
10221
  type: name2,
10222
10222
  value: error.message
10223
10223
  };
10224
- resolve7(result);
10224
+ resolve8(result);
10225
10225
  });
10226
10226
  });
10227
10227
  }
10228
10228
  exports2.getExceptionFromError = getExceptionFromError;
10229
10229
  function parseError(error, options) {
10230
- return new utils_1.SyncPromise(function(resolve7) {
10230
+ return new utils_1.SyncPromise(function(resolve8) {
10231
10231
  return getExceptionFromError(error, options).then(function(exception) {
10232
- resolve7({
10232
+ resolve8({
10233
10233
  exception: {
10234
10234
  values: [exception]
10235
10235
  }
@@ -10284,11 +10284,11 @@ var require_eventbuilder = __commonJS({
10284
10284
  }
10285
10285
  mechanism.synthetic = true;
10286
10286
  }
10287
- return new utils_1.SyncPromise(function(resolve7, reject) {
10287
+ return new utils_1.SyncPromise(function(resolve8, reject) {
10288
10288
  return parsers_1.parseError(ex, options).then(function(event) {
10289
10289
  utils_1.addExceptionTypeValue(event, void 0, void 0);
10290
10290
  utils_1.addExceptionMechanism(event, mechanism);
10291
- resolve7(tslib_1.__assign(tslib_1.__assign({}, event), { event_id: hint && hint.event_id }));
10291
+ resolve8(tslib_1.__assign(tslib_1.__assign({}, event), { event_id: hint && hint.event_id }));
10292
10292
  }).then(null, reject);
10293
10293
  });
10294
10294
  }
@@ -10302,19 +10302,19 @@ var require_eventbuilder = __commonJS({
10302
10302
  level,
10303
10303
  message: message2
10304
10304
  };
10305
- return new utils_1.SyncPromise(function(resolve7) {
10305
+ return new utils_1.SyncPromise(function(resolve8) {
10306
10306
  if (options.attachStacktrace && hint && hint.syntheticException) {
10307
10307
  var stack2 = hint.syntheticException ? parsers_1.extractStackFromError(hint.syntheticException) : [];
10308
10308
  void parsers_1.parseStack(stack2, options).then(function(frames) {
10309
10309
  event.stacktrace = {
10310
10310
  frames: parsers_1.prepareFramesForEvent(frames)
10311
10311
  };
10312
- resolve7(event);
10312
+ resolve8(event);
10313
10313
  }).then(null, function() {
10314
- resolve7(event);
10314
+ resolve8(event);
10315
10315
  });
10316
10316
  } else {
10317
- resolve7(event);
10317
+ resolve8(event);
10318
10318
  }
10319
10319
  });
10320
10320
  }
@@ -10485,7 +10485,7 @@ var require_base = __commonJS({
10485
10485
  })];
10486
10486
  }
10487
10487
  return [2, this._buffer.add(function() {
10488
- return new Promise(function(resolve7, reject) {
10488
+ return new Promise(function(resolve8, reject) {
10489
10489
  if (!_this.module) {
10490
10490
  throw new utils_1.SentryError("No module available");
10491
10491
  }
@@ -10506,7 +10506,7 @@ var require_base = __commonJS({
10506
10506
  if (limited)
10507
10507
  utils_1.logger.warn("Too many " + sentryRequest.type + " requests, backing off until: " + _this._disabledUntil(sentryRequest.type));
10508
10508
  if (status === "success") {
10509
- resolve7({ status });
10509
+ resolve8({ status });
10510
10510
  } else {
10511
10511
  var rejectionMessage = "HTTP Error (" + statusCode + ")";
10512
10512
  if (res.headers && res.headers["x-sentry-error"]) {
@@ -11278,12 +11278,12 @@ var require_promisify = __commonJS({
11278
11278
  Object.defineProperty(exports2, "__esModule", { value: true });
11279
11279
  function promisify2(fn2) {
11280
11280
  return function(req, opts) {
11281
- return new Promise((resolve7, reject) => {
11281
+ return new Promise((resolve8, reject) => {
11282
11282
  fn2.call(this, req, opts, (err2, rtn) => {
11283
11283
  if (err2) {
11284
11284
  reject(err2);
11285
11285
  } else {
11286
- resolve7(rtn);
11286
+ resolve8(rtn);
11287
11287
  }
11288
11288
  });
11289
11289
  });
@@ -11483,7 +11483,7 @@ var require_parse_proxy_response = __commonJS({
11483
11483
  var debug_1 = __importDefault(require_src());
11484
11484
  var debug = debug_1.default("https-proxy-agent:parse-proxy-response");
11485
11485
  function parseProxyResponse(socket) {
11486
- return new Promise((resolve7, reject) => {
11486
+ return new Promise((resolve8, reject) => {
11487
11487
  let buffersLength = 0;
11488
11488
  const buffers = [];
11489
11489
  function read2() {
@@ -11523,7 +11523,7 @@ var require_parse_proxy_response = __commonJS({
11523
11523
  const firstLine = buffered.toString("ascii", 0, buffered.indexOf("\r\n"));
11524
11524
  const statusCode = +firstLine.split(" ")[1];
11525
11525
  debug("got proxy server response: %o", firstLine);
11526
- resolve7({
11526
+ resolve8({
11527
11527
  statusCode,
11528
11528
  buffered
11529
11529
  });
@@ -11545,11 +11545,11 @@ var require_agent = __commonJS({
11545
11545
  init_import_meta_url();
11546
11546
  var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
11547
11547
  function adopt(value) {
11548
- return value instanceof P ? value : new P(function(resolve7) {
11549
- resolve7(value);
11548
+ return value instanceof P ? value : new P(function(resolve8) {
11549
+ resolve8(value);
11550
11550
  });
11551
11551
  }
11552
- return new (P || (P = Promise))(function(resolve7, reject) {
11552
+ return new (P || (P = Promise))(function(resolve8, reject) {
11553
11553
  function fulfilled(value) {
11554
11554
  try {
11555
11555
  step(generator.next(value));
@@ -11565,7 +11565,7 @@ var require_agent = __commonJS({
11565
11565
  }
11566
11566
  }
11567
11567
  function step(result) {
11568
- result.done ? resolve7(result.value) : adopt(result.value).then(fulfilled, rejected);
11568
+ result.done ? resolve8(result.value) : adopt(result.value).then(fulfilled, rejected);
11569
11569
  }
11570
11570
  step((generator = generator.apply(thisArg, _arguments || [])).next());
11571
11571
  });
@@ -12393,14 +12393,14 @@ var require_linkederrors = __commonJS({
12393
12393
  if (!event.exception || !event.exception.values || !hint || !utils_1.isInstanceOf(hint.originalException, Error)) {
12394
12394
  return utils_1.resolvedSyncPromise(event);
12395
12395
  }
12396
- return new utils_1.SyncPromise(function(resolve7) {
12396
+ return new utils_1.SyncPromise(function(resolve8) {
12397
12397
  void _this._walkErrorTree(hint.originalException, _this._key).then(function(linkedErrors) {
12398
12398
  if (event && event.exception && event.exception.values) {
12399
12399
  event.exception.values = tslib_1.__spread(linkedErrors, event.exception.values);
12400
12400
  }
12401
- resolve7(event);
12401
+ resolve8(event);
12402
12402
  }).then(null, function() {
12403
- resolve7(event);
12403
+ resolve8(event);
12404
12404
  });
12405
12405
  });
12406
12406
  };
@@ -12412,9 +12412,9 @@ var require_linkederrors = __commonJS({
12412
12412
  if (!utils_1.isInstanceOf(error[key2], Error) || stack2.length + 1 >= this._limit) {
12413
12413
  return utils_1.resolvedSyncPromise(stack2);
12414
12414
  }
12415
- return new utils_1.SyncPromise(function(resolve7, reject) {
12415
+ return new utils_1.SyncPromise(function(resolve8, reject) {
12416
12416
  void parsers_1.getExceptionFromError(error[key2]).then(function(exception) {
12417
- void _this._walkErrorTree(error[key2], key2, tslib_1.__spread([exception], stack2)).then(resolve7).then(null, function() {
12417
+ void _this._walkErrorTree(error[key2], key2, tslib_1.__spread([exception], stack2)).then(resolve8).then(null, function() {
12418
12418
  reject();
12419
12419
  });
12420
12420
  }).then(null, function() {
@@ -15379,12 +15379,12 @@ var require_isexe = __commonJS({
15379
15379
  if (typeof Promise !== "function") {
15380
15380
  throw new TypeError("callback not provided");
15381
15381
  }
15382
- return new Promise(function(resolve7, reject) {
15382
+ return new Promise(function(resolve8, reject) {
15383
15383
  isexe(path22, options || {}, function(er, is) {
15384
15384
  if (er) {
15385
15385
  reject(er);
15386
15386
  } else {
15387
- resolve7(is);
15387
+ resolve8(is);
15388
15388
  }
15389
15389
  });
15390
15390
  });
@@ -15449,27 +15449,27 @@ var require_which = __commonJS({
15449
15449
  opt = {};
15450
15450
  const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
15451
15451
  const found = [];
15452
- const step = (i2) => new Promise((resolve7, reject) => {
15452
+ const step = (i2) => new Promise((resolve8, reject) => {
15453
15453
  if (i2 === pathEnv.length)
15454
- return opt.all && found.length ? resolve7(found) : reject(getNotFoundError(cmd));
15454
+ return opt.all && found.length ? resolve8(found) : reject(getNotFoundError(cmd));
15455
15455
  const ppRaw = pathEnv[i2];
15456
15456
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
15457
15457
  const pCmd = path22.join(pathPart, cmd);
15458
15458
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
15459
- resolve7(subStep(p, i2, 0));
15459
+ resolve8(subStep(p, i2, 0));
15460
15460
  });
15461
- const subStep = (p, i2, ii) => new Promise((resolve7, reject) => {
15461
+ const subStep = (p, i2, ii) => new Promise((resolve8, reject) => {
15462
15462
  if (ii === pathExt.length)
15463
- return resolve7(step(i2 + 1));
15463
+ return resolve8(step(i2 + 1));
15464
15464
  const ext = pathExt[ii];
15465
15465
  isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
15466
15466
  if (!er && is) {
15467
15467
  if (opt.all)
15468
15468
  found.push(p + ext);
15469
15469
  else
15470
- return resolve7(p + ext);
15470
+ return resolve8(p + ext);
15471
15471
  }
15472
- return resolve7(subStep(p, i2, ii + 1));
15472
+ return resolve8(subStep(p, i2, ii + 1));
15473
15473
  });
15474
15474
  });
15475
15475
  return cb2 ? step(0).then((res) => cb2(null, res), cb2) : step(0);
@@ -16041,7 +16041,7 @@ var require_get_stream = __commonJS({
16041
16041
  };
16042
16042
  const { maxBuffer } = options;
16043
16043
  const stream2 = bufferStream(options);
16044
- await new Promise((resolve7, reject) => {
16044
+ await new Promise((resolve8, reject) => {
16045
16045
  const rejectPromise = (error) => {
16046
16046
  if (error && stream2.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
16047
16047
  error.bufferedData = stream2.getBufferedValue();
@@ -16051,7 +16051,7 @@ var require_get_stream = __commonJS({
16051
16051
  (async () => {
16052
16052
  try {
16053
16053
  await streamPipelinePromisified(inputStream, stream2);
16054
- resolve7();
16054
+ resolve8();
16055
16055
  } catch (error) {
16056
16056
  rejectPromise(error);
16057
16057
  }
@@ -16662,7 +16662,7 @@ var require_text = __commonJS({
16662
16662
  "../../node_modules/prompts/dist/elements/text.js"(exports2, module2) {
16663
16663
  "use strict";
16664
16664
  init_import_meta_url();
16665
- function asyncGeneratorStep(gen, resolve7, reject, _next, _throw, key2, arg2) {
16665
+ function asyncGeneratorStep(gen, resolve8, reject, _next, _throw, key2, arg2) {
16666
16666
  try {
16667
16667
  var info = gen[key2](arg2);
16668
16668
  var value = info.value;
@@ -16671,7 +16671,7 @@ var require_text = __commonJS({
16671
16671
  return;
16672
16672
  }
16673
16673
  if (info.done) {
16674
- resolve7(value);
16674
+ resolve8(value);
16675
16675
  } else {
16676
16676
  Promise.resolve(value).then(_next, _throw);
16677
16677
  }
@@ -16679,13 +16679,13 @@ var require_text = __commonJS({
16679
16679
  function _asyncToGenerator(fn2) {
16680
16680
  return function() {
16681
16681
  var self2 = this, args2 = arguments;
16682
- return new Promise(function(resolve7, reject) {
16682
+ return new Promise(function(resolve8, reject) {
16683
16683
  var gen = fn2.apply(self2, args2);
16684
16684
  function _next(value) {
16685
- asyncGeneratorStep(gen, resolve7, reject, _next, _throw, "next", value);
16685
+ asyncGeneratorStep(gen, resolve8, reject, _next, _throw, "next", value);
16686
16686
  }
16687
16687
  function _throw(err2) {
16688
- asyncGeneratorStep(gen, resolve7, reject, _next, _throw, "throw", err2);
16688
+ asyncGeneratorStep(gen, resolve8, reject, _next, _throw, "throw", err2);
16689
16689
  }
16690
16690
  _next(void 0);
16691
16691
  });
@@ -17435,7 +17435,7 @@ var require_date = __commonJS({
17435
17435
  "../../node_modules/prompts/dist/elements/date.js"(exports2, module2) {
17436
17436
  "use strict";
17437
17437
  init_import_meta_url();
17438
- function asyncGeneratorStep(gen, resolve7, reject, _next, _throw, key2, arg2) {
17438
+ function asyncGeneratorStep(gen, resolve8, reject, _next, _throw, key2, arg2) {
17439
17439
  try {
17440
17440
  var info = gen[key2](arg2);
17441
17441
  var value = info.value;
@@ -17444,7 +17444,7 @@ var require_date = __commonJS({
17444
17444
  return;
17445
17445
  }
17446
17446
  if (info.done) {
17447
- resolve7(value);
17447
+ resolve8(value);
17448
17448
  } else {
17449
17449
  Promise.resolve(value).then(_next, _throw);
17450
17450
  }
@@ -17452,13 +17452,13 @@ var require_date = __commonJS({
17452
17452
  function _asyncToGenerator(fn2) {
17453
17453
  return function() {
17454
17454
  var self2 = this, args2 = arguments;
17455
- return new Promise(function(resolve7, reject) {
17455
+ return new Promise(function(resolve8, reject) {
17456
17456
  var gen = fn2.apply(self2, args2);
17457
17457
  function _next(value) {
17458
- asyncGeneratorStep(gen, resolve7, reject, _next, _throw, "next", value);
17458
+ asyncGeneratorStep(gen, resolve8, reject, _next, _throw, "next", value);
17459
17459
  }
17460
17460
  function _throw(err2) {
17461
- asyncGeneratorStep(gen, resolve7, reject, _next, _throw, "throw", err2);
17461
+ asyncGeneratorStep(gen, resolve8, reject, _next, _throw, "throw", err2);
17462
17462
  }
17463
17463
  _next(void 0);
17464
17464
  });
@@ -17662,7 +17662,7 @@ var require_number = __commonJS({
17662
17662
  "../../node_modules/prompts/dist/elements/number.js"(exports2, module2) {
17663
17663
  "use strict";
17664
17664
  init_import_meta_url();
17665
- function asyncGeneratorStep(gen, resolve7, reject, _next, _throw, key2, arg2) {
17665
+ function asyncGeneratorStep(gen, resolve8, reject, _next, _throw, key2, arg2) {
17666
17666
  try {
17667
17667
  var info = gen[key2](arg2);
17668
17668
  var value = info.value;
@@ -17671,7 +17671,7 @@ var require_number = __commonJS({
17671
17671
  return;
17672
17672
  }
17673
17673
  if (info.done) {
17674
- resolve7(value);
17674
+ resolve8(value);
17675
17675
  } else {
17676
17676
  Promise.resolve(value).then(_next, _throw);
17677
17677
  }
@@ -17679,13 +17679,13 @@ var require_number = __commonJS({
17679
17679
  function _asyncToGenerator(fn2) {
17680
17680
  return function() {
17681
17681
  var self2 = this, args2 = arguments;
17682
- return new Promise(function(resolve7, reject) {
17682
+ return new Promise(function(resolve8, reject) {
17683
17683
  var gen = fn2.apply(self2, args2);
17684
17684
  function _next(value) {
17685
- asyncGeneratorStep(gen, resolve7, reject, _next, _throw, "next", value);
17685
+ asyncGeneratorStep(gen, resolve8, reject, _next, _throw, "next", value);
17686
17686
  }
17687
17687
  function _throw(err2) {
17688
- asyncGeneratorStep(gen, resolve7, reject, _next, _throw, "throw", err2);
17688
+ asyncGeneratorStep(gen, resolve8, reject, _next, _throw, "throw", err2);
17689
17689
  }
17690
17690
  _next(void 0);
17691
17691
  });
@@ -18122,7 +18122,7 @@ var require_autocomplete = __commonJS({
18122
18122
  "../../node_modules/prompts/dist/elements/autocomplete.js"(exports2, module2) {
18123
18123
  "use strict";
18124
18124
  init_import_meta_url();
18125
- function asyncGeneratorStep(gen, resolve7, reject, _next, _throw, key2, arg2) {
18125
+ function asyncGeneratorStep(gen, resolve8, reject, _next, _throw, key2, arg2) {
18126
18126
  try {
18127
18127
  var info = gen[key2](arg2);
18128
18128
  var value = info.value;
@@ -18131,7 +18131,7 @@ var require_autocomplete = __commonJS({
18131
18131
  return;
18132
18132
  }
18133
18133
  if (info.done) {
18134
- resolve7(value);
18134
+ resolve8(value);
18135
18135
  } else {
18136
18136
  Promise.resolve(value).then(_next, _throw);
18137
18137
  }
@@ -18139,13 +18139,13 @@ var require_autocomplete = __commonJS({
18139
18139
  function _asyncToGenerator(fn2) {
18140
18140
  return function() {
18141
18141
  var self2 = this, args2 = arguments;
18142
- return new Promise(function(resolve7, reject) {
18142
+ return new Promise(function(resolve8, reject) {
18143
18143
  var gen = fn2.apply(self2, args2);
18144
18144
  function _next(value) {
18145
- asyncGeneratorStep(gen, resolve7, reject, _next, _throw, "next", value);
18145
+ asyncGeneratorStep(gen, resolve8, reject, _next, _throw, "next", value);
18146
18146
  }
18147
18147
  function _throw(err2) {
18148
- asyncGeneratorStep(gen, resolve7, reject, _next, _throw, "throw", err2);
18148
+ asyncGeneratorStep(gen, resolve8, reject, _next, _throw, "throw", err2);
18149
18149
  }
18150
18150
  _next(void 0);
18151
18151
  });
@@ -18813,7 +18813,7 @@ var require_dist10 = __commonJS({
18813
18813
  arr2[i2] = arr[i2];
18814
18814
  return arr2;
18815
18815
  }
18816
- function asyncGeneratorStep(gen, resolve7, reject, _next, _throw, key2, arg2) {
18816
+ function asyncGeneratorStep(gen, resolve8, reject, _next, _throw, key2, arg2) {
18817
18817
  try {
18818
18818
  var info = gen[key2](arg2);
18819
18819
  var value = info.value;
@@ -18822,7 +18822,7 @@ var require_dist10 = __commonJS({
18822
18822
  return;
18823
18823
  }
18824
18824
  if (info.done) {
18825
- resolve7(value);
18825
+ resolve8(value);
18826
18826
  } else {
18827
18827
  Promise.resolve(value).then(_next, _throw);
18828
18828
  }
@@ -18830,13 +18830,13 @@ var require_dist10 = __commonJS({
18830
18830
  function _asyncToGenerator(fn2) {
18831
18831
  return function() {
18832
18832
  var self2 = this, args2 = arguments;
18833
- return new Promise(function(resolve7, reject) {
18833
+ return new Promise(function(resolve8, reject) {
18834
18834
  var gen = fn2.apply(self2, args2);
18835
18835
  function _next(value) {
18836
- asyncGeneratorStep(gen, resolve7, reject, _next, _throw, "next", value);
18836
+ asyncGeneratorStep(gen, resolve8, reject, _next, _throw, "next", value);
18837
18837
  }
18838
18838
  function _throw(err2) {
18839
- asyncGeneratorStep(gen, resolve7, reject, _next, _throw, "throw", err2);
18839
+ asyncGeneratorStep(gen, resolve8, reject, _next, _throw, "throw", err2);
18840
18840
  }
18841
18841
  _next(void 0);
18842
18842
  });
@@ -47798,12 +47798,12 @@ For more info, visit https://reactjs.org/link/mock-scheduler`);
47798
47798
  }
47799
47799
  }
47800
47800
  return {
47801
- then: function(resolve7, reject) {
47801
+ then: function(resolve8, reject) {
47802
47802
  called = true;
47803
47803
  result.then(function() {
47804
47804
  if (actingUpdatesScopeDepth > 1 || isSchedulerMocked === true && previousIsSomeRendererActing === true) {
47805
47805
  onDone();
47806
- resolve7();
47806
+ resolve8();
47807
47807
  return;
47808
47808
  }
47809
47809
  flushWorkAndMicroTasks(function(err2) {
@@ -47811,7 +47811,7 @@ For more info, visit https://reactjs.org/link/mock-scheduler`);
47811
47811
  if (err2) {
47812
47812
  reject(err2);
47813
47813
  } else {
47814
- resolve7();
47814
+ resolve8();
47815
47815
  }
47816
47816
  });
47817
47817
  }, function(err2) {
@@ -47836,11 +47836,11 @@ For more info, visit https://reactjs.org/link/mock-scheduler`);
47836
47836
  throw err2;
47837
47837
  }
47838
47838
  return {
47839
- then: function(resolve7) {
47839
+ then: function(resolve8) {
47840
47840
  {
47841
47841
  error("Do not await the result of calling act(...) with sync logic, it is not a Promise.");
47842
47842
  }
47843
- resolve7();
47843
+ resolve8();
47844
47844
  }
47845
47845
  };
47846
47846
  }
@@ -89632,7 +89632,7 @@ var require_backend2 = __commonJS({
89632
89632
  }
89633
89633
  ;
89634
89634
  return function(data) {
89635
- return new Promise(function(resolve7, reject) {
89635
+ return new Promise(function(resolve8, reject) {
89636
89636
  _intercept = true;
89637
89637
  if (typeof data === "string") {
89638
89638
  _data = {
@@ -89651,7 +89651,7 @@ var require_backend2 = __commonJS({
89651
89651
  try {
89652
89652
  if (document.execCommand("copy")) {
89653
89653
  cleanup();
89654
- resolve7();
89654
+ resolve8();
89655
89655
  } else {
89656
89656
  if (!tryBogusSelect) {
89657
89657
  bogusSelect();
@@ -89678,15 +89678,15 @@ var require_backend2 = __commonJS({
89678
89678
  if (_intercept) {
89679
89679
  _intercept = false;
89680
89680
  e2.preventDefault();
89681
- var resolve7 = _resolve;
89681
+ var resolve8 = _resolve;
89682
89682
  _resolve = null;
89683
- resolve7(e2.clipboardData.getData(_dataType));
89683
+ resolve8(e2.clipboardData.getData(_dataType));
89684
89684
  }
89685
89685
  });
89686
89686
  return function(dataType) {
89687
- return new Promise(function(resolve7, reject) {
89687
+ return new Promise(function(resolve8, reject) {
89688
89688
  _intercept = true;
89689
- _resolve = resolve7;
89689
+ _resolve = resolve8;
89690
89690
  _dataType = dataType || "text/plain";
89691
89691
  try {
89692
89692
  if (!document.execCommand("paste")) {
@@ -89821,24 +89821,24 @@ var require_backend2 = __commonJS({
89821
89821
  }, module3.exports ? module3.exports = c : a.Promise || (a.Promise = c);
89822
89822
  })(this);
89823
89823
  clipboard6.copy = function(data) {
89824
- return new Promise(function(resolve7, reject) {
89824
+ return new Promise(function(resolve8, reject) {
89825
89825
  if (typeof data !== "string" && !("text/plain" in data)) {
89826
89826
  throw new Error("You must provide a text/plain type.");
89827
89827
  }
89828
89828
  var strData = typeof data === "string" ? data : data["text/plain"];
89829
89829
  var copySucceeded = window.clipboardData.setData("Text", strData);
89830
89830
  if (copySucceeded) {
89831
- resolve7();
89831
+ resolve8();
89832
89832
  } else {
89833
89833
  reject(new Error("Copying was rejected."));
89834
89834
  }
89835
89835
  });
89836
89836
  };
89837
89837
  clipboard6.paste = function() {
89838
- return new Promise(function(resolve7, reject) {
89838
+ return new Promise(function(resolve8, reject) {
89839
89839
  var strData = window.clipboardData.getData("Text");
89840
89840
  if (strData) {
89841
- resolve7(strData);
89841
+ resolve8(strData);
89842
89842
  } else {
89843
89843
  reject(new Error("Pasting was rejected."));
89844
89844
  }
@@ -99125,8 +99125,8 @@ var require_ink = __commonJS({
99125
99125
  }
99126
99126
  waitUntilExit() {
99127
99127
  if (!this.exitPromise) {
99128
- this.exitPromise = new Promise((resolve7, reject) => {
99129
- this.resolveExitPromise = resolve7;
99128
+ this.exitPromise = new Promise((resolve8, reject) => {
99129
+ this.resolveExitPromise = resolve8;
99130
99130
  this.rejectExitPromise = reject;
99131
99131
  });
99132
99132
  }
@@ -99328,8 +99328,8 @@ var require_use_stdin = __commonJS({
99328
99328
  Object.defineProperty(exports2, "__esModule", { value: true });
99329
99329
  var react_1 = require_react();
99330
99330
  var StdinContext_1 = __importDefault(require_StdinContext());
99331
- var useStdin = () => react_1.useContext(StdinContext_1.default);
99332
- exports2.default = useStdin;
99331
+ var useStdin2 = () => react_1.useContext(StdinContext_1.default);
99332
+ exports2.default = useStdin2;
99333
99333
  }
99334
99334
  });
99335
99335
 
@@ -101214,9 +101214,9 @@ var require_client2 = __commonJS({
101214
101214
  }
101215
101215
  close(callback) {
101216
101216
  if (callback === void 0) {
101217
- return new Promise((resolve7, reject) => {
101217
+ return new Promise((resolve8, reject) => {
101218
101218
  this.close((err2, data) => {
101219
- return err2 ? reject(err2) : resolve7(data);
101219
+ return err2 ? reject(err2) : resolve8(data);
101220
101220
  });
101221
101221
  });
101222
101222
  }
@@ -101240,9 +101240,9 @@ var require_client2 = __commonJS({
101240
101240
  err2 = null;
101241
101241
  }
101242
101242
  if (callback === void 0) {
101243
- return new Promise((resolve7, reject) => {
101243
+ return new Promise((resolve8, reject) => {
101244
101244
  this.destroy(err2, (err3, data) => {
101245
- return err3 ? reject(err3) : resolve7(data);
101245
+ return err3 ? reject(err3) : resolve8(data);
101246
101246
  });
101247
101247
  });
101248
101248
  }
@@ -101823,7 +101823,7 @@ var require_client2 = __commonJS({
101823
101823
  });
101824
101824
  }
101825
101825
  try {
101826
- const socket = await new Promise((resolve7, reject) => {
101826
+ const socket = await new Promise((resolve8, reject) => {
101827
101827
  client[kConnector]({
101828
101828
  host,
101829
101829
  hostname,
@@ -101834,7 +101834,7 @@ var require_client2 = __commonJS({
101834
101834
  if (err2) {
101835
101835
  reject(err2);
101836
101836
  } else {
101837
- resolve7(socket2);
101837
+ resolve8(socket2);
101838
101838
  }
101839
101839
  });
101840
101840
  });
@@ -102204,12 +102204,12 @@ upgrade: ${upgrade}\r
102204
102204
  cb2();
102205
102205
  }
102206
102206
  }
102207
- const waitForDrain = () => new Promise((resolve7, reject) => {
102207
+ const waitForDrain = () => new Promise((resolve8, reject) => {
102208
102208
  assert10(callback === null);
102209
102209
  if (socket[kError]) {
102210
102210
  reject(socket[kError]);
102211
102211
  } else {
102212
- callback = resolve7;
102212
+ callback = resolve8;
102213
102213
  }
102214
102214
  });
102215
102215
  socket.on("close", onDrain).on("drain", onDrain);
@@ -102548,8 +102548,8 @@ var require_pool_base = __commonJS({
102548
102548
  if (this[kQueue].isEmpty()) {
102549
102549
  this[kClosedPromise] = Promise.all(this[kClients].map((c) => c.close()));
102550
102550
  } else {
102551
- this[kClosedPromise] = new Promise((resolve7) => {
102552
- this[kClosedResolve] = resolve7;
102551
+ this[kClosedPromise] = new Promise((resolve8) => {
102552
+ this[kClosedResolve] = resolve8;
102553
102553
  });
102554
102554
  }
102555
102555
  this[kClosedPromise] = this[kClosedPromise].then(() => {
@@ -103139,11 +103139,11 @@ var require_readable = __commonJS({
103139
103139
  throw new TypeError("unusable");
103140
103140
  }
103141
103141
  assert10(!stream[kConsume]);
103142
- return new Promise((resolve7, reject) => {
103142
+ return new Promise((resolve8, reject) => {
103143
103143
  stream[kConsume] = {
103144
103144
  type: type2,
103145
103145
  stream,
103146
- resolve: resolve7,
103146
+ resolve: resolve8,
103147
103147
  reject,
103148
103148
  length: 0,
103149
103149
  body: []
@@ -103178,12 +103178,12 @@ var require_readable = __commonJS({
103178
103178
  }
103179
103179
  }
103180
103180
  function consumeEnd(consume2) {
103181
- const { type: type2, body, resolve: resolve7, stream, length } = consume2;
103181
+ const { type: type2, body, resolve: resolve8, stream, length } = consume2;
103182
103182
  try {
103183
103183
  if (type2 === "text") {
103184
- resolve7(toUSVString(Buffer.concat(body)));
103184
+ resolve8(toUSVString(Buffer.concat(body)));
103185
103185
  } else if (type2 === "json") {
103186
- resolve7(JSON.parse(Buffer.concat(body)));
103186
+ resolve8(JSON.parse(Buffer.concat(body)));
103187
103187
  } else if (type2 === "arrayBuffer") {
103188
103188
  const dst = new Uint8Array(length);
103189
103189
  let pos = 0;
@@ -103191,12 +103191,12 @@ var require_readable = __commonJS({
103191
103191
  dst.set(buf, pos);
103192
103192
  pos += buf.byteLength;
103193
103193
  }
103194
- resolve7(dst);
103194
+ resolve8(dst);
103195
103195
  } else if (type2 === "blob") {
103196
103196
  if (!Blob2) {
103197
103197
  Blob2 = require("buffer").Blob;
103198
103198
  }
103199
- resolve7(new Blob2(body, { type: stream[kContentType] }));
103199
+ resolve8(new Blob2(body, { type: stream[kContentType] }));
103200
103200
  }
103201
103201
  consumeFinish(consume2);
103202
103202
  } catch (err2) {
@@ -103397,9 +103397,9 @@ var require_api_request = __commonJS({
103397
103397
  };
103398
103398
  function request(opts, callback) {
103399
103399
  if (callback === void 0) {
103400
- return new Promise((resolve7, reject) => {
103400
+ return new Promise((resolve8, reject) => {
103401
103401
  request.call(this, opts, (err2, data) => {
103402
- return err2 ? reject(err2) : resolve7(data);
103402
+ return err2 ? reject(err2) : resolve8(data);
103403
103403
  });
103404
103404
  });
103405
103405
  }
@@ -103552,9 +103552,9 @@ var require_api_stream = __commonJS({
103552
103552
  };
103553
103553
  function stream(opts, factory, callback) {
103554
103554
  if (callback === void 0) {
103555
- return new Promise((resolve7, reject) => {
103555
+ return new Promise((resolve8, reject) => {
103556
103556
  stream.call(this, opts, factory, (err2, data) => {
103557
- return err2 ? reject(err2) : resolve7(data);
103557
+ return err2 ? reject(err2) : resolve8(data);
103558
103558
  });
103559
103559
  });
103560
103560
  }
@@ -103837,9 +103837,9 @@ var require_api_upgrade = __commonJS({
103837
103837
  };
103838
103838
  function upgrade(opts, callback) {
103839
103839
  if (callback === void 0) {
103840
- return new Promise((resolve7, reject) => {
103840
+ return new Promise((resolve8, reject) => {
103841
103841
  upgrade.call(this, opts, (err2, data) => {
103842
- return err2 ? reject(err2) : resolve7(data);
103842
+ return err2 ? reject(err2) : resolve8(data);
103843
103843
  });
103844
103844
  });
103845
103845
  }
@@ -103926,9 +103926,9 @@ var require_api_connect = __commonJS({
103926
103926
  };
103927
103927
  function connect2(opts, callback) {
103928
103928
  if (callback === void 0) {
103929
- return new Promise((resolve7, reject) => {
103929
+ return new Promise((resolve8, reject) => {
103930
103930
  connect2.call(this, opts, (err2, data) => {
103931
- return err2 ? reject(err2) : resolve7(data);
103931
+ return err2 ? reject(err2) : resolve8(data);
103932
103932
  });
103933
103933
  });
103934
103934
  }
@@ -105336,8 +105336,8 @@ var require_util5 = __commonJS({
105336
105336
  function createDeferredPromise() {
105337
105337
  let res;
105338
105338
  let rej;
105339
- const promise = new Promise((resolve7, reject) => {
105340
- res = resolve7;
105339
+ const promise = new Promise((resolve8, reject) => {
105340
+ res = resolve8;
105341
105341
  rej = reject;
105342
105342
  });
105343
105343
  return { promise, resolve: res, reject: rej };
@@ -107350,7 +107350,7 @@ var require_fetch = __commonJS({
107350
107350
  }
107351
107351
  function httpNetworkFetch(fetchParams, includeCredentials = false, forceNewConnection = false) {
107352
107352
  const context = this;
107353
- return new Promise((resolve7) => {
107353
+ return new Promise((resolve8) => {
107354
107354
  assert10(!context.connection || context.connection.destroyed);
107355
107355
  context.connection = {
107356
107356
  abort: null,
@@ -107404,9 +107404,9 @@ var require_fetch = __commonJS({
107404
107404
  const aborted = this.terminated.aborted;
107405
107405
  this.connection.destroy();
107406
107406
  if (aborted) {
107407
- return resolve7(makeNetworkError(new AbortError()));
107407
+ return resolve8(makeNetworkError(new AbortError()));
107408
107408
  }
107409
- return resolve7(makeNetworkError(this.terminated.reason));
107409
+ return resolve8(makeNetworkError(this.terminated.reason));
107410
107410
  }
107411
107411
  let pullAlgorithm;
107412
107412
  const cancelAlgorithm = () => {
@@ -107423,8 +107423,8 @@ var require_fetch = __commonJS({
107423
107423
  },
107424
107424
  async pull(controller) {
107425
107425
  if (!pullAlgorithm) {
107426
- await new Promise((resolve8) => {
107427
- pullResolve = resolve8;
107426
+ await new Promise((resolve9) => {
107427
+ pullResolve = resolve9;
107428
107428
  });
107429
107429
  }
107430
107430
  await pullAlgorithm(controller);
@@ -107537,7 +107537,7 @@ var require_fetch = __commonJS({
107537
107537
  pullResolve();
107538
107538
  pullResolve = null;
107539
107539
  }
107540
- resolve7(response);
107540
+ resolve8(response);
107541
107541
  return true;
107542
107542
  },
107543
107543
  onData(chunk) {
@@ -107555,7 +107555,7 @@ var require_fetch = __commonJS({
107555
107555
  this.decoder?.destroy(error);
107556
107556
  this.context.terminate({ reason: error });
107557
107557
  if (!response) {
107558
- resolve7(makeNetworkError(error));
107558
+ resolve8(makeNetworkError(error));
107559
107559
  }
107560
107560
  }
107561
107561
  });
@@ -109431,14 +109431,14 @@ var require_open = __commonJS({
109431
109431
  }
109432
109432
  const subprocess = childProcess2.spawn(command2, cliArguments, childProcessOptions);
109433
109433
  if (options.wait) {
109434
- return new Promise((resolve7, reject) => {
109434
+ return new Promise((resolve8, reject) => {
109435
109435
  subprocess.once("error", reject);
109436
109436
  subprocess.once("close", (exitCode) => {
109437
109437
  if (options.allowNonzeroExitCode && exitCode > 0) {
109438
109438
  reject(new Error(`Exited with code ${exitCode}`));
109439
109439
  return;
109440
109440
  }
109441
- resolve7(subprocess);
109441
+ resolve8(subprocess);
109442
109442
  });
109443
109443
  });
109444
109444
  }
@@ -111205,9 +111205,9 @@ var require_readdirp = __commonJS({
111205
111205
  return new ReaddirpStream(options);
111206
111206
  };
111207
111207
  var readdirpPromise = (root, options = {}) => {
111208
- return new Promise((resolve7, reject) => {
111208
+ return new Promise((resolve8, reject) => {
111209
111209
  const files = [];
111210
- readdirp(root, options).on("data", (entry) => files.push(entry)).on("end", () => resolve7(files)).on("error", (error) => reject(error));
111210
+ readdirp(root, options).on("data", (entry) => files.push(entry)).on("end", () => resolve8(files)).on("error", (error) => reject(error));
111211
111211
  });
111212
111212
  };
111213
111213
  readdirp.promise = readdirpPromise;
@@ -113235,13 +113235,13 @@ var require_nodefs_handler = __commonJS({
113235
113235
  this._addToNodeFs(path22, initialAdd, wh, depth + 1);
113236
113236
  }
113237
113237
  }).on(EV_ERROR, this._boundHandleError);
113238
- return new Promise((resolve7) => stream.once(STR_END, () => {
113238
+ return new Promise((resolve8) => stream.once(STR_END, () => {
113239
113239
  if (this.fsw.closed) {
113240
113240
  stream = void 0;
113241
113241
  return;
113242
113242
  }
113243
113243
  const wasThrottled = throttler ? throttler.clear() : false;
113244
- resolve7();
113244
+ resolve8();
113245
113245
  previous.getChildren().filter((item) => {
113246
113246
  return item !== directory && !current.has(item) && (!wh.hasGlob || wh.filterPath({
113247
113247
  fullPath: sysPath.resolve(directory, item)
@@ -115096,7 +115096,7 @@ var require_kill = __commonJS({
115096
115096
  return spawnedPromise;
115097
115097
  }
115098
115098
  let timeoutId;
115099
- const timeoutPromise = new Promise((resolve7, reject) => {
115099
+ const timeoutPromise = new Promise((resolve8, reject) => {
115100
115100
  timeoutId = setTimeout(() => {
115101
115101
  timeoutKill2(spawned, killSignal, reject);
115102
115102
  }, timeout);
@@ -115245,9 +115245,9 @@ var require_promise = __commonJS({
115245
115245
  return spawned;
115246
115246
  };
115247
115247
  var getSpawnedPromise2 = (spawned) => {
115248
- return new Promise((resolve7, reject) => {
115248
+ return new Promise((resolve8, reject) => {
115249
115249
  spawned.on("exit", (exitCode, signal) => {
115250
- resolve7({ exitCode, signal });
115250
+ resolve8({ exitCode, signal });
115251
115251
  });
115252
115252
  spawned.on("error", (error) => {
115253
115253
  reject(error);
@@ -115680,10 +115680,10 @@ var require_command_exists = __commonJS({
115680
115680
  module2.exports = function commandExists2(commandName, callback) {
115681
115681
  var cleanedCommandName = cleanInput(commandName);
115682
115682
  if (!callback && typeof Promise !== "undefined") {
115683
- return new Promise(function(resolve7, reject) {
115683
+ return new Promise(function(resolve8, reject) {
115684
115684
  commandExists2(commandName, function(error, output) {
115685
115685
  if (output) {
115686
- resolve7(commandName);
115686
+ resolve8(commandName);
115687
115687
  } else {
115688
115688
  reject(error);
115689
115689
  }
@@ -126331,7 +126331,7 @@ var require_send = __commonJS({
126331
126331
  var extname3 = path22.extname;
126332
126332
  var join6 = path22.join;
126333
126333
  var normalize2 = path22.normalize;
126334
- var resolve7 = path22.resolve;
126334
+ var resolve8 = path22.resolve;
126335
126335
  var sep = path22.sep;
126336
126336
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
126337
126337
  var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
@@ -126368,7 +126368,7 @@ var require_send = __commonJS({
126368
126368
  this._maxage = opts.maxAge || opts.maxage;
126369
126369
  this._maxage = typeof this._maxage === "string" ? ms(this._maxage) : Number(this._maxage);
126370
126370
  this._maxage = !isNaN(this._maxage) ? Math.min(Math.max(0, this._maxage), MAX_MAXAGE) : 0;
126371
- this._root = opts.root ? resolve7(opts.root) : null;
126371
+ this._root = opts.root ? resolve8(opts.root) : null;
126372
126372
  if (!this._root && opts.from) {
126373
126373
  this.from(opts.from);
126374
126374
  }
@@ -126392,7 +126392,7 @@ var require_send = __commonJS({
126392
126392
  return this;
126393
126393
  }, "send.index: pass index as option");
126394
126394
  SendStream.prototype.root = function root(path23) {
126395
- this._root = resolve7(String(path23));
126395
+ this._root = resolve8(String(path23));
126396
126396
  debug("root %s", this._root);
126397
126397
  return this;
126398
126398
  };
@@ -126554,7 +126554,7 @@ var require_send = __commonJS({
126554
126554
  return res;
126555
126555
  }
126556
126556
  parts = normalize2(path23).split(sep);
126557
- path23 = resolve7(path23);
126557
+ path23 = resolve8(path23);
126558
126558
  }
126559
126559
  if (containsDotFile(parts)) {
126560
126560
  var access = this._dotfiles;
@@ -126865,7 +126865,7 @@ var require_serve_static = __commonJS({
126865
126865
  var encodeUrl = require_encodeurl();
126866
126866
  var escapeHtml = require_escape_html();
126867
126867
  var parseUrl = require_parseurl();
126868
- var resolve7 = require("path").resolve;
126868
+ var resolve8 = require("path").resolve;
126869
126869
  var send = require_send();
126870
126870
  var url2 = require("url");
126871
126871
  module2.exports = serveStatic2;
@@ -126885,7 +126885,7 @@ var require_serve_static = __commonJS({
126885
126885
  throw new TypeError("option setHeaders must be function");
126886
126886
  }
126887
126887
  opts.maxage = opts.maxage || opts.maxAge || 0;
126888
- opts.root = resolve7(root);
126888
+ opts.root = resolve8(root);
126889
126889
  var onDirectory = redirect ? createRedirectDirectoryListener() : createNotFoundDirectoryListener();
126890
126890
  return function serveStatic3(req, res, next) {
126891
126891
  if (req.method !== "GET" && req.method !== "HEAD") {
@@ -131357,7 +131357,7 @@ var setupTimeout = (spawned, { timeout, killSignal = "SIGTERM" }, spawnedPromise
131357
131357
  return spawnedPromise;
131358
131358
  }
131359
131359
  let timeoutId;
131360
- const timeoutPromise = new Promise((resolve7, reject) => {
131360
+ const timeoutPromise = new Promise((resolve8, reject) => {
131361
131361
  timeoutId = setTimeout(() => {
131362
131362
  timeoutKill(spawned, killSignal, reject);
131363
131363
  }, timeout);
@@ -131475,9 +131475,9 @@ var mergePromise = (spawned, promise) => {
131475
131475
  }
131476
131476
  return spawned;
131477
131477
  };
131478
- var getSpawnedPromise = (spawned) => new Promise((resolve7, reject) => {
131478
+ var getSpawnedPromise = (spawned) => new Promise((resolve8, reject) => {
131479
131479
  spawned.on("exit", (exitCode, signal) => {
131480
- resolve7({ exitCode, signal });
131480
+ resolve8({ exitCode, signal });
131481
131481
  });
131482
131482
  spawned.on("error", (error) => {
131483
131483
  reject(error);
@@ -131708,7 +131708,7 @@ var import_prompts = __toESM(require_prompts3());
131708
131708
 
131709
131709
  // package.json
131710
131710
  var name = "wrangler";
131711
- var version = "0.0.21";
131711
+ var version = "0.0.24";
131712
131712
 
131713
131713
  // src/reporting.ts
131714
131714
  function initReporting() {
@@ -131887,18 +131887,18 @@ function pLimit(concurrency) {
131887
131887
  queue.dequeue()();
131888
131888
  }
131889
131889
  };
131890
- const run2 = async (fn2, resolve7, args2) => {
131890
+ const run2 = async (fn2, resolve8, args2) => {
131891
131891
  activeCount++;
131892
131892
  const result = (async () => fn2(...args2))();
131893
- resolve7(result);
131893
+ resolve8(result);
131894
131894
  try {
131895
131895
  await result;
131896
131896
  } catch {
131897
131897
  }
131898
131898
  next();
131899
131899
  };
131900
- const enqueue = (fn2, resolve7, args2) => {
131901
- queue.enqueue(run2.bind(void 0, fn2, resolve7, args2));
131900
+ const enqueue = (fn2, resolve8, args2) => {
131901
+ queue.enqueue(run2.bind(void 0, fn2, resolve8, args2));
131902
131902
  (async () => {
131903
131903
  await Promise.resolve();
131904
131904
  if (activeCount < concurrency && queue.size > 0) {
@@ -131906,8 +131906,8 @@ function pLimit(concurrency) {
131906
131906
  }
131907
131907
  })();
131908
131908
  };
131909
- const generator = (fn2, ...args2) => new Promise((resolve7) => {
131910
- enqueue(fn2, resolve7, args2);
131909
+ const generator = (fn2, ...args2) => new Promise((resolve8) => {
131910
+ enqueue(fn2, resolve8, args2);
131911
131911
  });
131912
131912
  Object.defineProperties(generator, {
131913
131913
  activeCount: {
@@ -132108,14 +132108,14 @@ var getLocalHosts = () => {
132108
132108
  }
132109
132109
  return results;
132110
132110
  };
132111
- var checkAvailablePort = (options) => new Promise((resolve7, reject) => {
132111
+ var checkAvailablePort = (options) => new Promise((resolve8, reject) => {
132112
132112
  const server = import_node_net.default.createServer();
132113
132113
  server.unref();
132114
132114
  server.on("error", reject);
132115
132115
  server.listen(options, () => {
132116
132116
  const { port } = server.address();
132117
132117
  server.close(() => {
132118
- resolve7(port);
132118
+ resolve8(port);
132119
132119
  });
132120
132120
  });
132121
132121
  });
@@ -134457,12 +134457,12 @@ var YargsInstance = class {
134457
134457
  async getCompletion(args2, done) {
134458
134458
  argsert("<array> [function]", [args2, done], arguments.length);
134459
134459
  if (!done) {
134460
- return new Promise((resolve7, reject) => {
134460
+ return new Promise((resolve8, reject) => {
134461
134461
  __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args2, (err2, completions) => {
134462
134462
  if (err2)
134463
134463
  reject(err2);
134464
134464
  else
134465
- resolve7(completions);
134465
+ resolve8(completions);
134466
134466
  });
134467
134467
  });
134468
134468
  } else {
@@ -135852,7 +135852,7 @@ async function getAuthURL(scopes = ScopeKeys) {
135852
135852
  codeVerifier,
135853
135853
  stateQueryParam
135854
135854
  });
135855
- return AUTH_URL + `?response_type=code&client_id=${encodeURIComponent(CLIENT_ID)}&redirect_uri=${encodeURIComponent(CALLBACK_URL)}&scope=${encodeURIComponent(scopes.concat("offline_access").join(" "))}&state=${stateQueryParam}&code_challenge=${encodeURIComponent(codeChallenge)}&code_challenge_method=S256`;
135855
+ return AUTH_URL + `?response_type=code&client_id=${encodeURIComponent(CLIENT_ID)}&redirect_uri=${encodeURIComponent(CALLBACK_URL)}&scope=${encodeURIComponent([...scopes, "offline_access"].join(" "))}&state=${stateQueryParam}&code_challenge=${encodeURIComponent(codeChallenge)}&code_challenge_method=S256`;
135856
135856
  }
135857
135857
  async function exchangeRefreshTokenForAccessToken() {
135858
135858
  if (!LocalState.refreshToken) {
@@ -136004,7 +136004,12 @@ async function loginOrRefreshIfRequired(isInteractive = true) {
136004
136004
  if (!getAPIToken()) {
136005
136005
  return isInteractive && await login();
136006
136006
  } else if (isAccessTokenExpired()) {
136007
- return await refreshToken();
136007
+ const didRefresh = await refreshToken();
136008
+ if (didRefresh) {
136009
+ return true;
136010
+ } else {
136011
+ return isInteractive && await login();
136012
+ }
136008
136013
  } else {
136009
136014
  return true;
136010
136015
  }
@@ -136015,15 +136020,15 @@ async function login(props) {
136015
136020
  await openInBrowser(urlToOpen);
136016
136021
  let server;
136017
136022
  let loginTimeoutHandle;
136018
- const timerPromise = new Promise((resolve7) => {
136023
+ const timerPromise = new Promise((resolve8) => {
136019
136024
  loginTimeoutHandle = setTimeout(() => {
136020
136025
  console.error("Timed out waiting for authorization code, please try again.");
136021
136026
  server.close();
136022
136027
  clearTimeout(loginTimeoutHandle);
136023
- resolve7(false);
136028
+ resolve8(false);
136024
136029
  }, 6e4);
136025
136030
  });
136026
- const loginPromise = new Promise((resolve7, reject) => {
136031
+ const loginPromise = new Promise((resolve8, reject) => {
136027
136032
  server = import_node_http.default.createServer(async (req, res) => {
136028
136033
  function finish(status, error) {
136029
136034
  clearTimeout(loginTimeoutHandle);
@@ -136031,7 +136036,7 @@ async function login(props) {
136031
136036
  if (error || closeErr) {
136032
136037
  reject(error || closeErr);
136033
136038
  } else
136034
- resolve7(status);
136039
+ resolve8(status);
136035
136040
  });
136036
136041
  }
136037
136042
  (0, import_node_assert.default)(req.url, "This request doesn't have a URL");
@@ -136166,12 +136171,12 @@ async function getAccountId(isInteractive = true) {
136166
136171
  if (responseJSON.result.length === 1) {
136167
136172
  accountId = responseJSON.result[0].account.id;
136168
136173
  } else if (isInteractive) {
136169
- accountId = await new Promise((resolve7) => {
136174
+ accountId = await new Promise((resolve8) => {
136170
136175
  const accounts = responseJSON.result.map((x) => x.account);
136171
136176
  const { unmount } = (0, import_ink.render)(/* @__PURE__ */ import_react.default.createElement(ChooseAccount, {
136172
136177
  accounts,
136173
136178
  onSelect: async (selected) => {
136174
- resolve7(selected.value.id);
136179
+ resolve8(selected.value.id);
136175
136180
  unmount();
136176
136181
  }
136177
136182
  }));
@@ -136399,23 +136404,24 @@ function experimental(diagnostics, config, fieldPath) {
136399
136404
  diagnostics.warnings.push(`"${fieldPath}" fields are experimental and may change or break at any time.`);
136400
136405
  }
136401
136406
  }
136402
- function inheritable(diagnostics, config, rawEnv, field, validate, defaultValue) {
136403
- validate(diagnostics, field, rawEnv[field], config);
136404
- return rawEnv[field] ?? config?.[field] ?? defaultValue;
136407
+ function inheritable(diagnostics, topLevelEnv, rawEnv, field, validate, defaultValue, transformFn = (v) => v) {
136408
+ validate(diagnostics, field, rawEnv[field], topLevelEnv);
136409
+ return rawEnv[field] ?? transformFn(topLevelEnv?.[field]) ?? defaultValue;
136405
136410
  }
136406
- function inheritableInLegacyEnvironments(diagnostics, config, rawEnv, field, validate, defaultValue) {
136407
- return config === void 0 || config.legacy_env ? inheritable(diagnostics, config, rawEnv, field, validate, defaultValue) : notAllowedInNamedServiceEnvironment(diagnostics, config, rawEnv, field);
136411
+ function inheritableInLegacyEnvironments(diagnostics, isLegacyEnv2, topLevelEnv, rawEnv, field, validate, transformFn, defaultValue) {
136412
+ return topLevelEnv === void 0 || isLegacyEnv2 === true ? inheritable(diagnostics, topLevelEnv, rawEnv, field, validate, defaultValue, transformFn) : notAllowedInNamedServiceEnvironment(diagnostics, topLevelEnv, rawEnv, field);
136408
136413
  }
136409
- function notAllowedInNamedServiceEnvironment(diagnostics, config, rawEnv, field) {
136414
+ var appendEnvName = (envName) => (fieldValue) => fieldValue ? `${fieldValue}-${envName}` : void 0;
136415
+ function notAllowedInNamedServiceEnvironment(diagnostics, topLevelEnv, rawEnv, field) {
136410
136416
  if (field in rawEnv) {
136411
136417
  diagnostics.errors.push(`The "${field}" field is not allowed in named service environments.
136412
136418
  Please remove the field from this environment.`);
136413
136419
  }
136414
- return config[field];
136420
+ return topLevelEnv[field];
136415
136421
  }
136416
- function notInheritable(diagnostics, config, rawConfig, rawEnv, envName, field, validate, defaultValue) {
136422
+ function notInheritable(diagnostics, topLevelEnv, rawConfig, rawEnv, envName, field, validate, defaultValue) {
136417
136423
  if (rawEnv[field] !== void 0) {
136418
- validate(diagnostics, field, rawEnv[field], config);
136424
+ validate(diagnostics, field, rawEnv[field], topLevelEnv);
136419
136425
  } else {
136420
136426
  if (rawConfig?.[field] !== void 0) {
136421
136427
  diagnostics.warnings.push(`"${field}" exists at the top level, but not on "env.${envName}".
@@ -136438,21 +136444,21 @@ function unwindPropertyPath(root, path22) {
136438
136444
  }
136439
136445
  var isString = (diagnostics, field, value) => {
136440
136446
  if (value !== void 0 && typeof value !== "string") {
136441
- diagnostics.errors.push(`Expected "${field}" field to be a string but got ${JSON.stringify(value)}.`);
136447
+ diagnostics.errors.push(`Expected "${field}" to be of type string but got ${JSON.stringify(value)}.`);
136442
136448
  return false;
136443
136449
  }
136444
136450
  return true;
136445
136451
  };
136446
136452
  var isStringArray = (diagnostics, field, value) => {
136447
136453
  if (value !== void 0 && (!Array.isArray(value) || value.some((item) => typeof item !== "string"))) {
136448
- diagnostics.errors.push(`Expected "${field}" field to be an array of strings but got ${JSON.stringify(value)}.`);
136454
+ diagnostics.errors.push(`Expected "${field}" to be of type string array but got ${JSON.stringify(value)}.`);
136449
136455
  return false;
136450
136456
  }
136451
136457
  return true;
136452
136458
  };
136453
136459
  var isObjectWith = (...properties) => (diagnostics, field, value) => {
136454
136460
  if (value !== void 0 && (typeof value !== "object" || value === null || !properties.every((prop) => prop in value))) {
136455
- diagnostics.errors.push(`Expected "${field}" field to be an object containing properties ${properties} but got ${JSON.stringify(value)}.`);
136461
+ diagnostics.errors.push(`Expected "${field}" to be of type object, containing properties ${properties}, but got ${JSON.stringify(value)}.`);
136456
136462
  return false;
136457
136463
  }
136458
136464
  return true;
@@ -136482,7 +136488,10 @@ var isMutuallyExclusiveWith = (container, ...fields) => {
136482
136488
  }
136483
136489
  for (const exclusiveWith of fields) {
136484
136490
  if (container[exclusiveWith] !== void 0) {
136485
- diagnostics.errors.push(`Expected exactly one of ${JSON.stringify([field, ...fields])}.`);
136491
+ diagnostics.errors.push(`Expected exactly one of the following fields ${JSON.stringify([
136492
+ field,
136493
+ ...fields
136494
+ ])}.`);
136486
136495
  return false;
136487
136496
  }
136488
136497
  }
@@ -136491,7 +136500,7 @@ var isMutuallyExclusiveWith = (container, ...fields) => {
136491
136500
  };
136492
136501
  var isBoolean2 = (diagnostics, field, value) => {
136493
136502
  if (value !== void 0 && typeof value !== "boolean") {
136494
- diagnostics.errors.push(`Expected "${field}" field to be a boolean but got ${JSON.stringify(value)}.`);
136503
+ diagnostics.errors.push(`Expected "${field}" to be of type boolean but got ${JSON.stringify(value)}.`);
136495
136504
  return false;
136496
136505
  }
136497
136506
  return true;
@@ -136552,59 +136561,93 @@ var validateAdditionalProperties = (diagnostics, fieldPath, restProps, knownProp
136552
136561
  }
136553
136562
  return true;
136554
136563
  };
136564
+ var getBindingNames = (value) => {
136565
+ if (typeof value !== "object" || value === null) {
136566
+ return [];
136567
+ }
136568
+ if (isBindingList(value)) {
136569
+ return value.bindings.map(({ name: name2 }) => name2);
136570
+ } else if (isNamespaceList(value)) {
136571
+ return value.map(({ binding }) => binding);
136572
+ } else if (isRecord(value)) {
136573
+ return Object.keys(value);
136574
+ } else {
136575
+ return [];
136576
+ }
136577
+ };
136578
+ var isBindingList = (value) => isRecord(value) && "bindings" in value && Array.isArray(value.bindings) && value.bindings.every((binding) => isRecord(binding) && "name" in binding && typeof binding.name === "string");
136579
+ var isNamespaceList = (value) => Array.isArray(value) && value.every((entry) => isRecord(entry) && "binding" in entry && typeof entry.binding === "string");
136580
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
136555
136581
 
136556
136582
  // src/config/validation.ts
136557
- function normalizeAndValidateConfig(rawConfig, configPath) {
136583
+ var ENGLISH = new Intl.ListFormat("en");
136584
+ function normalizeAndValidateConfig(rawConfig, configPath, args2) {
136558
136585
  const diagnostics = new Diagnostics(`Processing ${configPath ? import_node_path8.default.relative(process.cwd(), configPath) : "wrangler"} configuration:`);
136559
136586
  deprecated(diagnostics, rawConfig, "type", "DO NOT USE THIS. Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build.", true);
136560
136587
  deprecated(diagnostics, rawConfig, "webpack_config", "DO NOT USE THIS. Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build.", true);
136561
136588
  deprecated(diagnostics, rawConfig, `site.entry-point`, `The \`site.entry-point\` config field is no longer used.
136562
136589
  The entry-point should be specified via the command line or the \`main\` config field.`, false, true);
136563
- const { deprecatedUpload, ...build5 } = normalizeAndValidateBuild(diagnostics, rawConfig, rawConfig.build ?? {}, configPath);
136564
136590
  validateOptionalProperty(diagnostics, "", "legacy_env", rawConfig.legacy_env, "boolean");
136591
+ const isLegacyEnv2 = args2["legacy-env"] ?? rawConfig.legacy_env ?? true;
136592
+ const topLevelEnv = normalizeAndValidateEnvironment(diagnostics, configPath, rawConfig);
136593
+ const envName = args2.env;
136594
+ let activeEnv = topLevelEnv;
136595
+ if (envName !== void 0) {
136596
+ const envDiagnostics = new Diagnostics(`"env.${envName}" environment configuration`);
136597
+ const rawEnv = rawConfig.env?.[envName];
136598
+ if (rawEnv !== void 0) {
136599
+ activeEnv = normalizeAndValidateEnvironment(envDiagnostics, configPath, rawEnv, envName, topLevelEnv, isLegacyEnv2, rawConfig);
136600
+ diagnostics.addChild(envDiagnostics);
136601
+ } else {
136602
+ activeEnv = normalizeAndValidateEnvironment(envDiagnostics, configPath, {}, envName, topLevelEnv, isLegacyEnv2, rawConfig);
136603
+ const envNames = rawConfig.env ? `The available configured environment names are: ${JSON.stringify(Object.keys(rawConfig.env))}
136604
+ ` : "";
136605
+ const message2 = `No environment found in configuration with name "${envName}".
136606
+ Before using \`--env=${envName}\` there should be an equivalent environment section in the configuration.
136607
+ ${envNames}
136608
+ Consider adding an environment configuration section to the wrangler.toml file:
136609
+ \`\`\`
136610
+ [env.` + envName + "]\n```\n";
136611
+ if (envNames.length > 0) {
136612
+ diagnostics.errors.push(message2);
136613
+ } else {
136614
+ diagnostics.warnings.push(message2);
136615
+ }
136616
+ }
136617
+ }
136565
136618
  const config = {
136566
136619
  configPath,
136567
- main: normalizeAndValidateMainField(diagnostics, configPath, rawConfig.main, deprecatedUpload),
136568
- legacy_env: rawConfig.legacy_env ?? true,
136569
- ...normalizeAndValidateEnvironment(diagnostics, rawConfig, deprecatedUpload.rules),
136570
- env: {},
136620
+ legacy_env: isLegacyEnv2,
136621
+ ...activeEnv,
136571
136622
  dev: normalizeAndValidateDev(diagnostics, rawConfig.dev ?? {}),
136572
136623
  migrations: normalizeAndValidateMigrations(diagnostics, rawConfig.migrations ?? []),
136573
136624
  site: normalizeAndValidateSite(diagnostics, rawConfig.site),
136574
136625
  wasm_modules: normalizeAndValidateModulePaths(diagnostics, configPath, "wasm_modules", rawConfig.wasm_modules),
136575
- text_blobs: normalizeAndValidateModulePaths(diagnostics, configPath, "text_blobs", rawConfig.text_blobs),
136576
- build: build5
136626
+ text_blobs: normalizeAndValidateModulePaths(diagnostics, configPath, "text_blobs", rawConfig.text_blobs)
136577
136627
  };
136578
- if (rawConfig.env !== void 0) {
136579
- for (const envName of Object.keys(rawConfig.env)) {
136580
- const envDiagnostics = new Diagnostics(`"env.${envName}" environment configuration`);
136581
- const environment = normalizeAndValidateEnvironment(envDiagnostics, rawConfig.env[envName], deprecatedUpload.rules, envName, config, rawConfig);
136582
- config.env[envName] = environment;
136583
- diagnostics.addChild(envDiagnostics);
136584
- }
136585
- }
136586
- validateAdditionalProperties(diagnostics, "top-level", Object.keys(rawConfig), [...Object.keys(config), "miniflare"]);
136628
+ validateBindingsHaveUniqueNames(diagnostics, config);
136629
+ validateAdditionalProperties(diagnostics, "top-level", Object.keys(rawConfig), [...Object.keys(config), "env", "miniflare"]);
136587
136630
  return { config, diagnostics };
136588
136631
  }
136589
- function normalizeAndValidateBuild(diagnostics, rawConfig, rawBuild, configPath) {
136632
+ function normalizeAndValidateBuild(diagnostics, rawEnv, rawBuild, configPath) {
136590
136633
  const { command: command2, cwd, watch_dir, upload, ...rest } = rawBuild;
136591
136634
  const deprecatedUpload = { ...upload };
136592
136635
  validateAdditionalProperties(diagnostics, "build", Object.keys(rest), []);
136593
136636
  validateOptionalProperty(diagnostics, "build", "command", command2, "string");
136594
136637
  validateOptionalProperty(diagnostics, "build", "cwd", cwd, "string");
136595
136638
  validateOptionalProperty(diagnostics, "build", "watch_dir", watch_dir, "string");
136596
- deprecated(diagnostics, rawConfig, "build.upload.format", "The format is inferred automatically from the code.", true);
136597
- if (rawConfig.main !== void 0 && rawBuild.upload?.main) {
136639
+ deprecated(diagnostics, rawEnv, "build.upload.format", "The format is inferred automatically from the code.", true);
136640
+ if (rawEnv.main !== void 0 && rawBuild.upload?.main) {
136598
136641
  diagnostics.errors.push(`Don't define both the \`main\` and \`build.upload.main\` fields in your configuration.
136599
136642
  They serve the same purpose: to point to the entry-point of your worker.
136600
136643
  Delete the \`build.upload.main\` and \`build.upload.dir\` field from your config.`);
136601
136644
  } else {
136602
- deprecated(diagnostics, rawConfig, "build.upload.main", `Delete the \`build.upload.main\` and \`build.upload.dir\` fields.
136645
+ deprecated(diagnostics, rawEnv, "build.upload.main", `Delete the \`build.upload.main\` and \`build.upload.dir\` fields.
136603
136646
  Then add the top level \`main\` field to your configuration file:
136604
136647
  \`\`\`
136605
136648
  main = "${import_node_path8.default.join(rawBuild.upload?.dir ?? "./dist", rawBuild.upload?.main ?? ".")}"
136606
136649
  \`\`\``, true);
136607
- deprecated(diagnostics, rawConfig, "build.upload.dir", `Use the top level "main" field or a command-line argument to specify the entry-point for the Worker.`, true);
136650
+ deprecated(diagnostics, rawEnv, "build.upload.dir", `Use the top level "main" field or a command-line argument to specify the entry-point for the Worker.`, true);
136608
136651
  }
136609
136652
  return {
136610
136653
  command: command2,
@@ -136613,18 +136656,17 @@ main = "${import_node_path8.default.join(rawBuild.upload?.dir ?? "./dist", rawBu
136613
136656
  deprecatedUpload
136614
136657
  };
136615
136658
  }
136616
- function normalizeAndValidateMainField(diagnostics, configPath, rawMain, deprecatedUpload) {
136659
+ function normalizeAndValidateMainField(configPath, rawMain, deprecatedUpload) {
136617
136660
  const configDir = import_node_path8.default.dirname(configPath ?? "wrangler.toml");
136618
136661
  if (rawMain !== void 0) {
136619
136662
  if (typeof rawMain === "string") {
136620
136663
  const directory = import_node_path8.default.resolve(configDir);
136621
136664
  return import_node_path8.default.resolve(directory, rawMain);
136622
136665
  } else {
136623
- diagnostics.errors.push(`Expected "main" to be a string but got ${JSON.stringify(rawMain)}`);
136624
- return;
136666
+ return rawMain;
136625
136667
  }
136626
- } else if (deprecatedUpload.main !== void 0) {
136627
- const directory = import_node_path8.default.resolve(configDir, deprecatedUpload.dir || "./dist");
136668
+ } else if (deprecatedUpload?.main !== void 0) {
136669
+ const directory = import_node_path8.default.resolve(configDir, deprecatedUpload?.dir || "./dist");
136628
136670
  return import_node_path8.default.resolve(directory, deprecatedUpload.main);
136629
136671
  } else {
136630
136672
  return;
@@ -136693,7 +136735,7 @@ function normalizeAndValidateModulePaths(diagnostics, configPath, field, rawMapp
136693
136735
  }
136694
136736
  return mapping;
136695
136737
  }
136696
- function normalizeAndValidateEnvironment(diagnostics, rawEnv, deprecatedRules, envName = "top level", config, rawConfig) {
136738
+ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, envName = "top level", topLevelEnv, isLegacyEnv2, rawConfig) {
136697
136739
  deprecated(diagnostics, rawEnv, "zone_id", "This is unnecessary since we can deduce this from routes directly.", false);
136698
136740
  deprecated(diagnostics, rawEnv, "experimental_services", `The "experimental_services" field is no longer supported. Instead, use [[unsafe.bindings]] to enable experimental features. Add this to your wrangler.toml:
136699
136741
  \`\`\`
@@ -136710,37 +136752,45 @@ function normalizeAndValidateEnvironment(diagnostics, rawEnv, deprecatedRules, e
136710
136752
  }
136711
136753
  }) + "```", true);
136712
136754
  experimental(diagnostics, rawEnv, "unsafe");
136713
- const route = inheritable(diagnostics, config, rawEnv, "route", isString, void 0);
136714
- const routes = inheritable(diagnostics, config, rawEnv, "routes", all(isStringArray, isMutuallyExclusiveWith(rawEnv, "route")), void 0);
136715
- const workers_dev = inheritable(diagnostics, config, rawEnv, "workers_dev", isBoolean2, !(routes || route));
136755
+ const route = inheritable(diagnostics, topLevelEnv, rawEnv, "route", isString, void 0);
136756
+ const routes = inheritable(diagnostics, topLevelEnv, rawEnv, "routes", all(isStringArray, isMutuallyExclusiveWith(rawEnv, "route")), void 0);
136757
+ const workers_dev = inheritable(diagnostics, topLevelEnv, rawEnv, "workers_dev", isBoolean2, void 0);
136758
+ const { deprecatedUpload, ...build5 } = normalizeAndValidateBuild(diagnostics, rawEnv, rawEnv.build ?? topLevelEnv?.build ?? {}, configPath);
136716
136759
  const environment = {
136717
- account_id: inheritable(diagnostics, config, rawEnv, "account_id", isString, void 0),
136718
- compatibility_date: inheritable(diagnostics, config, rawEnv, "compatibility_date", isString, void 0),
136719
- compatibility_flags: inheritable(diagnostics, config, rawEnv, "compatibility_flags", isStringArray, []),
136720
- jsx_factory: inheritable(diagnostics, config, rawEnv, "jsx_factory", isString, "React.createElement"),
136721
- jsx_fragment: inheritable(diagnostics, config, rawEnv, "jsx_fragment", isString, "React.Fragment"),
136722
- rules: validateAndNormalizeRules(diagnostics, config, rawEnv, deprecatedRules, envName),
136723
- name: inheritableInLegacyEnvironments(diagnostics, config, rawEnv, "name", isString, void 0),
136760
+ account_id: inheritable(diagnostics, topLevelEnv, rawEnv, "account_id", isString, void 0),
136761
+ compatibility_date: inheritable(diagnostics, topLevelEnv, rawEnv, "compatibility_date", isString, void 0),
136762
+ compatibility_flags: inheritable(diagnostics, topLevelEnv, rawEnv, "compatibility_flags", isStringArray, []),
136763
+ jsx_factory: inheritable(diagnostics, topLevelEnv, rawEnv, "jsx_factory", isString, "React.createElement"),
136764
+ jsx_fragment: inheritable(diagnostics, topLevelEnv, rawEnv, "jsx_fragment", isString, "React.Fragment"),
136765
+ tsconfig: validateAndNormalizeTsconfig(diagnostics, topLevelEnv, rawEnv, configPath),
136766
+ rules: validateAndNormalizeRules(diagnostics, topLevelEnv, rawEnv, deprecatedUpload?.rules, envName),
136767
+ name: inheritableInLegacyEnvironments(diagnostics, isLegacyEnv2, topLevelEnv, rawEnv, "name", isString, appendEnvName(envName), void 0),
136768
+ main: normalizeAndValidateMainField(configPath, inheritable(diagnostics, topLevelEnv, rawEnv, "main", isString, void 0), deprecatedUpload),
136724
136769
  route,
136725
136770
  routes,
136726
- triggers: inheritable(diagnostics, config, rawEnv, "triggers", isObjectWith("crons"), { crons: [] }),
136727
- usage_model: inheritable(diagnostics, config, rawEnv, "usage_model", isOneOf("bundled", "unbound"), void 0),
136771
+ triggers: inheritable(diagnostics, topLevelEnv, rawEnv, "triggers", isObjectWith("crons"), { crons: [] }),
136772
+ usage_model: inheritable(diagnostics, topLevelEnv, rawEnv, "usage_model", isOneOf("bundled", "unbound"), void 0),
136773
+ build: build5,
136728
136774
  workers_dev,
136729
- vars: notInheritable(diagnostics, config, rawConfig, rawEnv, envName, "vars", validateVars(envName), {}),
136730
- durable_objects: notInheritable(diagnostics, config, rawConfig, rawEnv, envName, "durable_objects", validateBindingsProperty(envName, validateDurableObjectBinding), {
136775
+ vars: notInheritable(diagnostics, topLevelEnv, rawConfig, rawEnv, envName, "vars", validateVars(envName), {}),
136776
+ durable_objects: notInheritable(diagnostics, topLevelEnv, rawConfig, rawEnv, envName, "durable_objects", validateBindingsProperty(envName, validateDurableObjectBinding), {
136731
136777
  bindings: []
136732
136778
  }),
136733
- kv_namespaces: notInheritable(diagnostics, config, rawConfig, rawEnv, envName, "kv_namespaces", validateBindingArray(envName, validateKVBinding), []),
136734
- r2_buckets: notInheritable(diagnostics, config, rawConfig, rawEnv, envName, "r2_buckets", validateBindingArray(envName, validateR2Binding), []),
136735
- unsafe: notInheritable(diagnostics, config, rawConfig, rawEnv, envName, "unsafe", validateBindingsProperty(envName, validateUnsafeBinding), {
136779
+ kv_namespaces: notInheritable(diagnostics, topLevelEnv, rawConfig, rawEnv, envName, "kv_namespaces", validateBindingArray(envName, validateKVBinding), []),
136780
+ r2_buckets: notInheritable(diagnostics, topLevelEnv, rawConfig, rawEnv, envName, "r2_buckets", validateBindingArray(envName, validateR2Binding), []),
136781
+ unsafe: notInheritable(diagnostics, topLevelEnv, rawConfig, rawEnv, envName, "unsafe", validateBindingsProperty(envName, validateUnsafeBinding), {
136736
136782
  bindings: []
136737
136783
  }),
136738
136784
  zone_id: rawEnv.zone_id
136739
136785
  };
136740
136786
  return environment;
136741
136787
  }
136742
- var validateAndNormalizeRules = (diagnostics, config, rawEnv, deprecatedRules, envName) => {
136743
- if (config === void 0) {
136788
+ function validateAndNormalizeTsconfig(diagnostics, topLevelEnv, rawEnv, configPath) {
136789
+ const tsconfig = inheritable(diagnostics, topLevelEnv, rawEnv, "tsconfig", isString, void 0);
136790
+ return configPath && tsconfig ? import_node_path8.default.relative(process.cwd(), import_node_path8.default.join(import_node_path8.default.dirname(configPath), tsconfig)) : tsconfig;
136791
+ }
136792
+ var validateAndNormalizeRules = (diagnostics, topLevelEnv, rawEnv, deprecatedRules, envName) => {
136793
+ if (topLevelEnv === void 0) {
136744
136794
  if (rawEnv.rules && deprecatedRules) {
136745
136795
  diagnostics.errors.push(`You cannot configure both [rules] and [build.upload.rules] in your wrangler.toml. Delete the \`build.upload\` section.`);
136746
136796
  } else if (deprecatedRules) {
@@ -136749,7 +136799,7 @@ var validateAndNormalizeRules = (diagnostics, config, rawEnv, deprecatedRules, e
136749
136799
  ` + import_toml4.default.stringify({ rules: deprecatedRules }) + "```");
136750
136800
  }
136751
136801
  }
136752
- return inheritable(diagnostics, config, rawEnv, "rules", validateRules(envName), deprecatedRules ?? []);
136802
+ return inheritable(diagnostics, topLevelEnv, rawEnv, "rules", validateRules(envName), deprecatedRules ?? []);
136753
136803
  };
136754
136804
  var validateRules = (envName) => (diagnostics, field, envValue, config) => {
136755
136805
  if (!envValue) {
@@ -136845,7 +136895,6 @@ Please add a binding for each to "${fieldPath}.bindings".` + missingBindings.map
136845
136895
  }
136846
136896
  return isValid;
136847
136897
  };
136848
- var getBindingNames = (value) => (value?.bindings ?? []).map((binding) => binding.name);
136849
136898
  var validateDurableObjectBinding = (diagnostics, field, value) => {
136850
136899
  if (typeof value !== "object" || value === null) {
136851
136900
  diagnostics.errors.push(`Expected "${field}" to be an object but got ${JSON.stringify(value)}`);
@@ -136963,9 +137012,61 @@ var validateR2Binding = (diagnostics, field, value) => {
136963
137012
  }
136964
137013
  return isValid;
136965
137014
  };
137015
+ var validateBindingsHaveUniqueNames = (diagnostics, {
137016
+ durable_objects,
137017
+ kv_namespaces,
137018
+ r2_buckets,
137019
+ text_blobs,
137020
+ unsafe,
137021
+ vars,
137022
+ wasm_modules
137023
+ }) => {
137024
+ let hasDuplicates = false;
137025
+ const bindingsGroupedByType = {
137026
+ "Durable Object": getBindingNames(durable_objects),
137027
+ "KV Namespace": getBindingNames(kv_namespaces),
137028
+ "R2 Bucket": getBindingNames(r2_buckets),
137029
+ "Text Blob": getBindingNames(text_blobs),
137030
+ Unsafe: getBindingNames(unsafe),
137031
+ "Environment Variable": getBindingNames(vars),
137032
+ "WASM Module": getBindingNames(wasm_modules)
137033
+ };
137034
+ const bindingsGroupedByName = {};
137035
+ for (const bindingType in bindingsGroupedByType) {
137036
+ const bindingNames = bindingsGroupedByType[bindingType];
137037
+ for (const bindingName of bindingNames) {
137038
+ if (!(bindingName in bindingsGroupedByName)) {
137039
+ bindingsGroupedByName[bindingName] = [];
137040
+ }
137041
+ bindingsGroupedByName[bindingName].push(bindingType);
137042
+ }
137043
+ }
137044
+ for (const bindingName in bindingsGroupedByName) {
137045
+ const bindingTypes = bindingsGroupedByName[bindingName];
137046
+ if (bindingTypes.length < 2) {
137047
+ continue;
137048
+ }
137049
+ hasDuplicates = true;
137050
+ const sameType = bindingTypes.filter((type2, i2) => bindingTypes.indexOf(type2) !== i2).filter((type2, i2, duplicateBindingTypes) => duplicateBindingTypes.indexOf(type2) === i2);
137051
+ const differentTypes = bindingTypes.filter((type2, i2) => bindingTypes.indexOf(type2) === i2);
137052
+ if (differentTypes.length > 1) {
137053
+ diagnostics.errors.push(`${bindingName} assigned to ${ENGLISH.format(differentTypes)} bindings.`);
137054
+ }
137055
+ sameType.forEach((bindingType) => {
137056
+ diagnostics.errors.push(`${bindingName} assigned to multiple ${bindingType} bindings.`);
137057
+ });
137058
+ }
137059
+ if (hasDuplicates) {
137060
+ const problem = "Bindings must have unique names, so that they can all be referenced in the worker.";
137061
+ const resolution = "Please change your bindings to have unique names.";
137062
+ diagnostics.errors.push(`${problem}
137063
+ ${resolution}`);
137064
+ }
137065
+ return !hasDuplicates;
137066
+ };
136966
137067
 
136967
137068
  // src/config/index.ts
136968
- function readConfig(configPath) {
137069
+ function readConfig(configPath, args2) {
136969
137070
  let rawConfig = {};
136970
137071
  if (!configPath) {
136971
137072
  configPath = findWranglerToml();
@@ -136973,7 +137074,7 @@ function readConfig(configPath) {
136973
137074
  if (configPath) {
136974
137075
  rawConfig = parseTOML(readFileSync5(configPath), configPath);
136975
137076
  }
136976
- const { config, diagnostics } = normalizeAndValidateConfig(rawConfig, configPath);
137077
+ const { config, diagnostics } = normalizeAndValidateConfig(rawConfig, configPath, args2);
136977
137078
  if (diagnostics.hasWarnings()) {
136978
137079
  console.warn(diagnostics.renderWarnings());
136979
137080
  }
@@ -137328,7 +137429,23 @@ async function getEntry(args2, config, command2) {
137328
137429
  if (fileExists(file) === false) {
137329
137430
  throw new Error(`Could not resolve "${import_node_path11.default.relative(process.cwd(), file)}".`);
137330
137431
  }
137331
- const format3 = await guessWorkerFormat(file, directory, args2.format ?? config.build?.upload?.format);
137432
+ const format3 = await guessWorkerFormat(file, directory, args2.format ?? config.build?.upload?.format, config.tsconfig);
137433
+ const { localBindings, remoteBindings } = partitionDurableObjectBindings(config);
137434
+ if (command2 === "dev" && remoteBindings.length > 0) {
137435
+ console.warn("WARNING: You have Durable Object bindings, which are not defined locally in the worker being developed.\nBe aware that changes to the data stored in these Durable Objects will be permanent and affect the live instances.\nRemote Durable Objects that are affected:\n" + remoteBindings.map((b) => `- ${JSON.stringify(b)}`).join("\n"));
137436
+ }
137437
+ if (format3 === "service-worker" && localBindings.length > 0) {
137438
+ const errorMessage = "You seem to be trying to use Durable Objects in a Worker written with Service Worker syntax.";
137439
+ const addScriptName = "You can use Durable Objects defined in other Workers by specifying a `script_name` in your wrangler.toml, where `script_name` is the name of the Worker that implements that Durable Object. For example:";
137440
+ const addScriptNameExamples = generateAddScriptNameExamples(localBindings);
137441
+ const migrateText = "Alternatively, migrate your worker to ES Module syntax to implement a Durable Object in this Worker:";
137442
+ const migrateUrl = "https://developers.cloudflare.com/workers/learning/migrating-to-module-workers/";
137443
+ throw new Error(`${errorMessage}
137444
+ ${addScriptName}
137445
+ ${addScriptNameExamples}
137446
+ ${migrateText}
137447
+ ${migrateUrl}`);
137448
+ }
137332
137449
  return { file, directory, format: format3 };
137333
137450
  }
137334
137451
  async function runCustomBuild(expectedEntry, build5) {
@@ -137346,14 +137463,20 @@ async function runCustomBuild(expectedEntry, build5) {
137346
137463
  }
137347
137464
  }
137348
137465
  }
137349
- async function guessWorkerFormat(entryFile, entryWorkingDirectory, hint) {
137466
+ async function guessWorkerFormat(entryFile, entryWorkingDirectory, hint, tsconfig) {
137350
137467
  const result = await esbuild.build({
137351
137468
  entryPoints: [entryFile],
137352
137469
  absWorkingDir: entryWorkingDirectory,
137353
137470
  metafile: true,
137354
137471
  bundle: false,
137355
137472
  format: "esm",
137356
- write: false
137473
+ write: false,
137474
+ loader: {
137475
+ ".js": "jsx",
137476
+ ".mjs": "jsx",
137477
+ ".cjs": "jsx"
137478
+ },
137479
+ ...tsconfig && { tsconfig }
137357
137480
  });
137358
137481
  const metafile = result.metafile;
137359
137482
  const entryPoints = Object.entries(metafile.outputs).filter(([_path, output]) => output.entryPoint !== void 0);
@@ -137386,6 +137509,29 @@ function fileExists(filePath) {
137386
137509
  }
137387
137510
  return false;
137388
137511
  }
137512
+ function partitionDurableObjectBindings(config) {
137513
+ const localBindings = [];
137514
+ const remoteBindings = [];
137515
+ for (const binding of config.durable_objects.bindings) {
137516
+ if (binding.script_name === void 0) {
137517
+ localBindings.push(binding);
137518
+ } else {
137519
+ remoteBindings.push(binding);
137520
+ }
137521
+ }
137522
+ return { localBindings, remoteBindings };
137523
+ }
137524
+ function generateAddScriptNameExamples(localBindings) {
137525
+ function exampleScriptName(binding_name) {
137526
+ return `${binding_name.toLowerCase().replaceAll("_", "-")}-worker`;
137527
+ }
137528
+ return localBindings.map(({ name: name2, class_name }) => {
137529
+ const script_name = exampleScriptName(name2);
137530
+ const currentBinding = `{ name = ${name2}, class_name = ${class_name} }`;
137531
+ const fixedBinding = `{ name = ${name2}, class_name = ${class_name}, script_name = ${script_name} }`;
137532
+ return `${currentBinding} ==> ${fixedBinding}`;
137533
+ }).join("\n");
137534
+ }
137389
137535
 
137390
137536
  // src/dev/local.tsx
137391
137537
  init_import_meta_url();
@@ -137684,7 +137830,7 @@ function createStreamHandler(previewToken, remote, localPort, localProtocol) {
137684
137830
  };
137685
137831
  }
137686
137832
  async function waitForPortToBeAvailable(port, options) {
137687
- return new Promise((resolve7, reject) => {
137833
+ return new Promise((resolve8, reject) => {
137688
137834
  const timeout = setTimeout(() => {
137689
137835
  doReject(new Error(`Timed out waiting for port ${port}`));
137690
137836
  }, options.timeout);
@@ -137693,7 +137839,7 @@ async function waitForPortToBeAvailable(port, options) {
137693
137839
  function doResolve() {
137694
137840
  clearTimeout(timeout);
137695
137841
  clearInterval(interval2);
137696
- resolve7();
137842
+ resolve8();
137697
137843
  }
137698
137844
  function doReject(err2) {
137699
137845
  clearInterval(interval2);
@@ -138094,32 +138240,34 @@ function createModuleCollector(props) {
138094
138240
  };
138095
138241
  });
138096
138242
  });
138097
- build5.onResolve({
138098
- filter: new RegExp([...props.wrangler1xlegacyModuleReferences.fileNames].map((fileName) => `^${fileName}$`).join("|"))
138099
- }, async (args2) => {
138100
- if (args2.kind !== "import-statement" && args2.kind !== "require-call") {
138101
- return;
138102
- }
138103
- console.warn(`Deprecation warning: detected a legacy module import in "./${import_node_path12.default.relative(process.cwd(), args2.importer)}". This will stop working in the future. Replace references to "${args2.path}" with "./${args2.path}";`);
138104
- const filePath = import_node_path12.default.join(props.wrangler1xlegacyModuleReferences.rootDirectory, args2.path);
138105
- const fileContent = await (0, import_promises2.readFile)(filePath);
138106
- const fileHash = import_node_crypto2.default.createHash("sha1").update(fileContent).digest("hex");
138107
- const fileName = `./${fileHash}-${import_node_path12.default.basename(args2.path)}`;
138108
- const { rule } = rulesMatchers.find(({ regex }) => regex.test(fileName)) || {};
138109
- if (rule) {
138110
- modules.push({
138111
- name: fileName,
138112
- content: fileContent,
138113
- type: RuleTypeToModuleType[rule.type]
138114
- });
138115
- return {
138116
- path: fileName,
138117
- external: props.format === "modules",
138118
- namespace: `wrangler-module-${rule.type}`,
138119
- watchFiles: [filePath]
138120
- };
138121
- }
138122
- });
138243
+ if (props.wrangler1xlegacyModuleReferences.fileNames.size > 0) {
138244
+ build5.onResolve({
138245
+ filter: new RegExp("^(" + [...props.wrangler1xlegacyModuleReferences.fileNames].join("|") + ")$")
138246
+ }, async (args2) => {
138247
+ if (args2.kind !== "import-statement" && args2.kind !== "require-call") {
138248
+ return;
138249
+ }
138250
+ console.warn(`Deprecation warning: detected a legacy module import in "./${import_node_path12.default.relative(process.cwd(), args2.importer)}". This will stop working in the future. Replace references to "${args2.path}" with "./${args2.path}";`);
138251
+ const filePath = import_node_path12.default.join(props.wrangler1xlegacyModuleReferences.rootDirectory, args2.path);
138252
+ const fileContent = await (0, import_promises2.readFile)(filePath);
138253
+ const fileHash = import_node_crypto2.default.createHash("sha1").update(fileContent).digest("hex");
138254
+ const fileName = `./${fileHash}-${import_node_path12.default.basename(args2.path)}`;
138255
+ const { rule } = rulesMatchers.find(({ regex }) => regex.test(fileName)) || {};
138256
+ if (rule) {
138257
+ modules.push({
138258
+ name: fileName,
138259
+ content: fileContent,
138260
+ type: RuleTypeToModuleType[rule.type]
138261
+ });
138262
+ return {
138263
+ path: fileName,
138264
+ external: props.format === "modules",
138265
+ namespace: `wrangler-module-${rule.type}`,
138266
+ watchFiles: [filePath]
138267
+ };
138268
+ }
138269
+ });
138270
+ }
138123
138271
  rules?.forEach((rule) => {
138124
138272
  if (rule.type === "ESModule" || rule.type === "CommonJS")
138125
138273
  return;
@@ -138164,18 +138312,7 @@ function createModuleCollector(props) {
138164
138312
 
138165
138313
  // src/dev/local.tsx
138166
138314
  function Local(props) {
138167
- const { inspectorUrl } = useLocalWorker({
138168
- name: props.name,
138169
- bundle: props.bundle,
138170
- format: props.format,
138171
- bindings: props.bindings,
138172
- assetPaths: props.assetPaths,
138173
- public: props.public,
138174
- port: props.port,
138175
- ip: props.ip,
138176
- rules: props.rules,
138177
- enableLocalPersistence: props.enableLocalPersistence
138178
- });
138315
+ const { inspectorUrl } = useLocalWorker(props);
138179
138316
  useInspector({
138180
138317
  inspectorUrl,
138181
138318
  port: props.inspectorPort,
@@ -138183,8 +138320,20 @@ function Local(props) {
138183
138320
  });
138184
138321
  return null;
138185
138322
  }
138186
- function useLocalWorker(props) {
138187
- const { bundle, format: format3, bindings, port, ip, assetPaths } = props;
138323
+ function useLocalWorker({
138324
+ name: workerName,
138325
+ bundle,
138326
+ format: format3,
138327
+ compatibilityDate,
138328
+ compatibilityFlags,
138329
+ bindings,
138330
+ assetPaths,
138331
+ public: publicDirectory,
138332
+ port,
138333
+ rules,
138334
+ enableLocalPersistence,
138335
+ ip
138336
+ }) {
138188
138337
  const local = (0, import_react4.useRef)();
138189
138338
  const removeSignalExitListener = (0, import_react4.useRef)();
138190
138339
  const [inspectorUrl, setInspectorUrl] = (0, import_react4.useState)();
@@ -138193,81 +138342,63 @@ function useLocalWorker(props) {
138193
138342
  if (!bundle || !format3)
138194
138343
  return;
138195
138344
  await waitForPortToBeAvailable(port, { retryPeriod: 200, timeout: 2e3 });
138196
- if (props.public) {
138345
+ if (publicDirectory) {
138197
138346
  throw new Error('\u2394 A "public" folder is not yet supported in local mode.');
138198
138347
  }
138199
138348
  for (const module2 of bundle.modules) {
138200
138349
  await (0, import_promises3.writeFile)(import_node_path13.default.join(import_node_path13.default.dirname(bundle.path), module2.name), module2.content);
138201
138350
  }
138351
+ const scriptPath = (0, import_node_fs5.realpathSync)(bundle.path);
138352
+ const wasmBindings = { ...bindings.wasm_modules };
138353
+ if (format3 === "service-worker") {
138354
+ for (const { type: type2, name: name2 } of bundle.modules) {
138355
+ if (type2 === "compiled-wasm") {
138356
+ const identifier = name2.replace(/[^a-zA-Z0-9_$]/g, "_");
138357
+ wasmBindings[identifier] = name2;
138358
+ }
138359
+ }
138360
+ }
138361
+ const options = {
138362
+ name: workerName,
138363
+ port,
138364
+ scriptPath,
138365
+ host: ip,
138366
+ modules: format3 === "modules",
138367
+ modulesRules: (rules || []).concat(DEFAULT_MODULE_RULES).map(({ type: type2, globs: include, fallthrough }) => ({
138368
+ type: type2,
138369
+ include,
138370
+ fallthrough
138371
+ })),
138372
+ compatibilityDate,
138373
+ compatibilityFlags,
138374
+ kvNamespaces: bindings.kv_namespaces?.map((kv) => kv.binding),
138375
+ kvPersist: enableLocalPersistence,
138376
+ durableObjects: Object.fromEntries((bindings.durable_objects?.bindings ?? []).map((value) => [value.name, value.class_name])),
138377
+ durableObjectsPersist: enableLocalPersistence,
138378
+ cachePersist: enableLocalPersistence,
138379
+ sitePath: assetPaths?.assetDirectory ? import_node_path13.default.join(assetPaths.baseDirectory, assetPaths.assetDirectory) : void 0,
138380
+ siteInclude: assetPaths?.includePatterns.length ? assetPaths?.includePatterns : void 0,
138381
+ siteExclude: assetPaths?.excludePatterns.length ? assetPaths.excludePatterns : void 0,
138382
+ bindings: bindings.vars,
138383
+ wasmBindings,
138384
+ sourceMap: true,
138385
+ logUnhandledRejections: true
138386
+ };
138387
+ const miniflareCLIPath = import_node_path13.default.resolve(__dirname, "../miniflare-dist/index.mjs");
138388
+ const optionsArg = JSON.stringify(options, null);
138202
138389
  console.log("\u2394 Starting a local server...");
138203
138390
  local.current = (0, import_node_child_process2.spawn)("node", [
138204
138391
  "--experimental-vm-modules",
138392
+ "--no-warnings",
138205
138393
  "--inspect",
138206
- require.resolve("miniflare/cli"),
138207
- (0, import_node_fs5.realpathSync)(bundle.path),
138208
- "--watch",
138209
- "--wrangler-config",
138210
- import_node_path13.default.join(__dirname, "../miniflare-config-stubs/wrangler.empty.toml"),
138211
- "--env",
138212
- import_node_path13.default.join(__dirname, "../miniflare-config-stubs/.env.empty"),
138213
- "--package",
138214
- import_node_path13.default.join(__dirname, "../miniflare-config-stubs/package.empty.json"),
138215
- "--port",
138216
- port.toString(),
138217
- "--host",
138218
- ip,
138219
- ...assetPaths ? [
138220
- "--site",
138221
- import_node_path13.default.join(process.cwd(), assetPaths.baseDirectory),
138222
- ...assetPaths.includePatterns.map((pattern) => [
138223
- "--site-include",
138224
- pattern
138225
- ]),
138226
- ...assetPaths.excludePatterns.map((pattern) => [
138227
- "--site-exclude",
138228
- pattern
138229
- ])
138230
- ].flatMap((x) => x) : [],
138231
- ...props.enableLocalPersistence ? ["--kv-persist", "--cache-persist", "--do-persist"] : [],
138232
- ...Object.entries(bindings.vars || {}).flatMap(([key2, value]) => {
138233
- return ["--binding", `${key2}=${value}`];
138234
- }),
138235
- ...(bindings.kv_namespaces || []).flatMap(({ binding }) => {
138236
- return ["--kv", binding];
138237
- }),
138238
- ...(bindings.durable_objects?.bindings || []).flatMap(({ name: name2, class_name }) => {
138239
- return ["--do", `${name2}=${class_name}`];
138240
- }),
138241
- ...Object.entries(bindings.wasm_modules || {}).flatMap(([name2, filePath]) => {
138242
- return [
138243
- "--wasm",
138244
- `${name2}=${import_node_path13.default.join(process.cwd(), filePath)}`
138245
- ];
138246
- }),
138247
- ...bundle.modules.reduce((cmd, { name: name2, type: type2 }) => {
138248
- if (format3 === "service-worker") {
138249
- if (type2 === "compiled-wasm") {
138250
- const identifier = name2.replace(/[^a-zA-Z0-9_$]/g, "_");
138251
- return cmd.concat([`--wasm`, `${identifier}=${name2}`]);
138252
- } else {
138253
- throw new Error(`\u2394 Unsupported module type ${type2} for file ${name2} in service-worker format`);
138254
- }
138255
- }
138256
- return cmd;
138257
- }, []),
138258
- "--modules",
138259
- String(format3 === "modules"),
138260
- ...(props.rules || []).concat(DEFAULT_MODULE_RULES).flatMap((rule) => rule.globs.flatMap((glob) => [
138261
- "--modules-rule",
138262
- `${rule.type}=${glob}`
138263
- ]))
138394
+ miniflareCLIPath,
138395
+ optionsArg
138264
138396
  ], {
138265
- cwd: import_node_path13.default.dirname((0, import_node_fs5.realpathSync)(bundle.path))
138397
+ cwd: import_node_path13.default.dirname(scriptPath)
138266
138398
  });
138267
- console.log(`\u2B23 Listening at http://localhost:${port}`);
138268
138399
  local.current.on("close", (code) => {
138269
138400
  if (code) {
138270
- console.log(`miniflare process exited with code ${code}`);
138401
+ console.log(`Miniflare process exited with code ${code}`);
138271
138402
  }
138272
138403
  });
138273
138404
  local.current.stdout?.on("data", (data) => {
@@ -138282,11 +138413,11 @@ function useLocalWorker(props) {
138282
138413
  });
138283
138414
  local.current.on("exit", (code) => {
138284
138415
  if (code) {
138285
- console.error(`miniflare process exited with code ${code}`);
138416
+ console.error(`Miniflare process exited with code ${code}`);
138286
138417
  }
138287
138418
  });
138288
138419
  local.current.on("error", (error) => {
138289
- console.error(`miniflare process failed to spawn`);
138420
+ console.error(`Miniflare process failed to spawn`);
138290
138421
  console.error(error);
138291
138422
  });
138292
138423
  removeSignalExitListener.current = (0, import_signal_exit2.default)((_code, _signal) => {
@@ -138309,16 +138440,19 @@ function useLocalWorker(props) {
138309
138440
  };
138310
138441
  }, [
138311
138442
  bundle,
138443
+ workerName,
138312
138444
  format3,
138313
138445
  port,
138314
138446
  ip,
138315
138447
  bindings.durable_objects?.bindings,
138316
138448
  bindings.kv_namespaces,
138317
138449
  bindings.vars,
138318
- props.enableLocalPersistence,
138450
+ compatibilityDate,
138451
+ compatibilityFlags,
138452
+ enableLocalPersistence,
138319
138453
  assetPaths,
138320
- props.public,
138321
- props.rules,
138454
+ publicDirectory,
138455
+ rules,
138322
138456
  bindings.wasm_modules
138323
138457
  ]);
138324
138458
  return { inspectorUrl };
@@ -138548,30 +138682,20 @@ async function deleteBulkKeyValue(accountId, namespaceId, keys, progressCallback
138548
138682
  progressCallback(keys.length, keys.length);
138549
138683
  }
138550
138684
  }
138551
- function getNamespaceId({ preview, binding, "namespace-id": namespaceId, env: env4 }, configOrEnv) {
138685
+ function getNamespaceId({ preview, binding, "namespace-id": namespaceId }, config) {
138552
138686
  if (namespaceId) {
138553
138687
  return namespaceId;
138554
138688
  }
138555
- if (binding && !configOrEnv) {
138689
+ if (binding && !config) {
138556
138690
  throw new Error("--binding specified, but no config file was found.");
138557
138691
  }
138558
- if (!configOrEnv) {
138692
+ if (!config) {
138559
138693
  throw new Error("Failed to find a config file.\nEither use --namespace-id to upload directly or create a configuration file with a binding.");
138560
138694
  }
138561
- if (env4) {
138562
- if (!("env" in configOrEnv) || !configOrEnv.env[env4]) {
138563
- throw new Error(`Failed to find environment "${env4}" in configuration file!`);
138564
- }
138565
- return getNamespaceId({
138566
- binding,
138567
- "namespace-id": namespaceId,
138568
- preview
138569
- }, configOrEnv.env[env4]);
138570
- }
138571
- if (!configOrEnv.kv_namespaces || configOrEnv.kv_namespaces.length === 0) {
138695
+ if (!config.kv_namespaces || config.kv_namespaces.length === 0) {
138572
138696
  throw new Error("No KV Namespaces configured! Either use --namespace-id to upload directly or add a KV namespace to your wrangler config file.");
138573
138697
  }
138574
- const namespace = configOrEnv.kv_namespaces.find((ns) => ns.binding === binding);
138698
+ const namespace = config.kv_namespaces.find((ns) => ns.binding === binding);
138575
138699
  if (!namespace) {
138576
138700
  throw new Error(`A namespace with binding name "${binding}" was not found in the configured "kv_namespaces".`);
138577
138701
  }
@@ -138608,7 +138732,6 @@ var ALWAYS_IGNORE = /* @__PURE__ */ new Set(["node_modules"]);
138608
138732
  var HIDDEN_FILES_TO_INCLUDE = /* @__PURE__ */ new Set([
138609
138733
  ".well-known"
138610
138734
  ]);
138611
- var FIVE_MINUTES = 60 * 5;
138612
138735
  async function* getFilesInFolder(dirPath) {
138613
138736
  const files = await (0, import_promises4.readdir)(dirPath, { withFileTypes: true });
138614
138737
  for (const file of files) {
@@ -138655,25 +138778,27 @@ async function syncAssets(accountId, scriptName, siteAssets, preview) {
138655
138778
  const title = `__${scriptName}-workers_sites_assets${preview ? "_preview" : ""}`;
138656
138779
  const { id: namespace } = await createKVNamespaceIfNotAlreadyExisting(title, accountId);
138657
138780
  const result = await listNamespaceKeys(accountId, namespace);
138658
- const keyMap = result.reduce((km, key2) => Object.assign(km, { [key2.name]: key2 }), {});
138781
+ const keys = new Set(result.map((x) => x.name));
138659
138782
  const manifest = {};
138660
138783
  const toUpload = [];
138661
138784
  const include = createPatternMatcher(siteAssets.includePatterns, false);
138662
138785
  const exclude = createPatternMatcher(siteAssets.excludePatterns, true);
138663
138786
  const hasher = await e();
138664
- for await (const file of getFilesInFolder(siteAssets.baseDirectory)) {
138665
- if (!include(file)) {
138787
+ const assetDirectory = path14.join(siteAssets.baseDirectory, siteAssets.assetDirectory);
138788
+ for await (const absAssetFile of getFilesInFolder(assetDirectory)) {
138789
+ const assetFile = path14.relative(siteAssets.baseDirectory, absAssetFile);
138790
+ if (!include(assetFile)) {
138666
138791
  continue;
138667
138792
  }
138668
- if (exclude(file)) {
138793
+ if (exclude(assetFile)) {
138669
138794
  continue;
138670
138795
  }
138671
- await validateAssetSize(file);
138672
- console.log(`reading ${file}...`);
138673
- const content = await (0, import_promises4.readFile)(file, "base64");
138674
- const assetKey = hashAsset(hasher, file, content);
138796
+ await validateAssetSize(absAssetFile, assetFile);
138797
+ console.log(`reading ${assetFile}...`);
138798
+ const content = await (0, import_promises4.readFile)(absAssetFile, "base64");
138799
+ const assetKey = hashAsset(hasher, assetFile, content);
138675
138800
  validateAssetKey(assetKey);
138676
- if (!(assetKey in keyMap) || keyMap[assetKey].expiration) {
138801
+ if (!keys.has(assetKey)) {
138677
138802
  console.log(`uploading as ${assetKey}...`);
138678
138803
  toUpload.push({
138679
138804
  key: assetKey,
@@ -138683,27 +138808,19 @@ async function syncAssets(accountId, scriptName, siteAssets, preview) {
138683
138808
  } else {
138684
138809
  console.log(`skipping - already uploaded`);
138685
138810
  }
138686
- delete keyMap[assetKey];
138687
- manifest[path14.relative(siteAssets.baseDirectory, file)] = assetKey;
138811
+ keys.delete(assetKey);
138812
+ manifest[path14.relative(siteAssets.assetDirectory, absAssetFile)] = assetKey;
138688
138813
  }
138689
- let toExpire = [];
138690
- for (const asset of Object.values(keyMap)) {
138691
- if (!asset.expiration) {
138692
- console.log(`expiring unused ${asset.name}...`);
138693
- toExpire.push({
138694
- key: asset.name,
138695
- value: "",
138696
- expiration_ttl: FIVE_MINUTES,
138697
- base64: true
138698
- });
138699
- }
138814
+ for (const key2 of keys) {
138815
+ console.log(`deleting ${key2} from the asset store...`);
138700
138816
  }
138701
- toExpire = await Promise.all(toExpire.map(async (asset) => ({
138702
- ...asset,
138703
- value: await getKeyValue(accountId, namespace, asset.key)
138704
- })));
138705
- await putBulkKeyValue(accountId, namespace, toUpload.concat(toExpire), () => {
138706
- });
138817
+ await Promise.all([
138818
+ putBulkKeyValue(accountId, namespace, toUpload, () => {
138819
+ }),
138820
+ deleteBulkKeyValue(accountId, namespace, Array.from(keys), () => {
138821
+ })
138822
+ ]);
138823
+ console.log("\u2197\uFE0F Done syncing assets");
138707
138824
  return { manifest, namespace };
138708
138825
  }
138709
138826
  function createPatternMatcher(patterns, exclude) {
@@ -138714,10 +138831,10 @@ function createPatternMatcher(patterns, exclude) {
138714
138831
  return (filePath) => ignorer.test(filePath).ignored;
138715
138832
  }
138716
138833
  }
138717
- async function validateAssetSize(filePath) {
138718
- const { size } = await (0, import_promises4.stat)(filePath);
138834
+ async function validateAssetSize(absFilePath, relativeFilePath) {
138835
+ const { size } = await (0, import_promises4.stat)(absFilePath);
138719
138836
  if (size > 25 * 1024 * 1024) {
138720
- throw new Error(`File ${filePath} is too big, it should be under 25 MiB. See https://developers.cloudflare.com/workers/platform/limits#kv-limits`);
138837
+ throw new Error(`File ${relativeFilePath} is too big, it should be under 25 MiB. See https://developers.cloudflare.com/workers/platform/limits#kv-limits`);
138721
138838
  }
138722
138839
  }
138723
138840
  function validateAssetKey(assetKey) {
@@ -138728,9 +138845,11 @@ function validateAssetKey(assetKey) {
138728
138845
  function urlSafe(filePath) {
138729
138846
  return filePath.replace(/\\/g, "/");
138730
138847
  }
138731
- function getAssetPaths(config, baseDirectory = config.site?.bucket, includePatterns = config.site?.include ?? [], excludePatterns = config.site?.exclude ?? []) {
138732
- return baseDirectory ? {
138848
+ function getAssetPaths(config, assetDirectory = config.site?.bucket, includePatterns = config.site?.include ?? [], excludePatterns = config.site?.exclude ?? []) {
138849
+ const baseDirectory = path14.resolve(path14.dirname(config.configPath ?? "wrangler.toml"));
138850
+ return assetDirectory ? {
138733
138851
  baseDirectory,
138852
+ assetDirectory,
138734
138853
  includePatterns,
138735
138854
  excludePatterns
138736
138855
  } : void 0;
@@ -138867,7 +138986,14 @@ var fs5 = __toESM(require("node:fs"));
138867
138986
  var path16 = __toESM(require("node:path"));
138868
138987
  var esbuild2 = __toESM(require("esbuild"));
138869
138988
  async function bundleWorker(entry, destination, options) {
138870
- const { serveAssetsFromWorker, jsxFactory, jsxFragment, rules, watch: watch3 } = options;
138989
+ const {
138990
+ serveAssetsFromWorker,
138991
+ jsxFactory,
138992
+ jsxFragment,
138993
+ rules,
138994
+ watch: watch3,
138995
+ tsconfig
138996
+ } = options;
138871
138997
  const entryDirectory = path16.dirname(entry.file);
138872
138998
  const moduleCollector = createModuleCollector({
138873
138999
  wrangler1xlegacyModuleReferences: {
@@ -138887,6 +139013,11 @@ async function bundleWorker(entry, destination, options) {
138887
139013
  sourcemap: true,
138888
139014
  metafile: true,
138889
139015
  conditions: ["worker", "browser"],
139016
+ ...process.env.NODE_ENV && {
139017
+ define: {
139018
+ "process.env.NODE_ENV": `"${process.env.NODE_ENV}"`
139019
+ }
139020
+ },
138890
139021
  loader: {
138891
139022
  ".js": "jsx",
138892
139023
  ".mjs": "jsx",
@@ -138895,6 +139026,7 @@ async function bundleWorker(entry, destination, options) {
138895
139026
  plugins: [moduleCollector.plugin],
138896
139027
  ...jsxFactory && { jsxFactory },
138897
139028
  ...jsxFragment && { jsxFragment },
139029
+ ...tsconfig && { tsconfig },
138898
139030
  watch: watch3
138899
139031
  });
138900
139032
  const entryPointOutputs = Object.entries(result.metafile.outputs).filter(([_path, output]) => output.entryPoint !== void 0);
@@ -138935,7 +139067,8 @@ function useEsbuild({
138935
139067
  jsxFactory,
138936
139068
  jsxFragment,
138937
139069
  rules,
138938
- serveAssetsFromWorker
139070
+ serveAssetsFromWorker,
139071
+ tsconfig
138939
139072
  }) {
138940
139073
  const [bundle, setBundle] = (0, import_react6.useState)();
138941
139074
  (0, import_react6.useEffect)(() => {
@@ -138960,7 +139093,8 @@ function useEsbuild({
138960
139093
  jsxFactory,
138961
139094
  jsxFragment,
138962
139095
  rules,
138963
- watch: watchMode
139096
+ watch: watchMode,
139097
+ tsconfig
138964
139098
  });
138965
139099
  stopWatching = stop;
138966
139100
  setBundle({
@@ -138984,17 +139118,17 @@ function useEsbuild({
138984
139118
  jsxFactory,
138985
139119
  jsxFragment,
138986
139120
  serveAssetsFromWorker,
138987
- rules
139121
+ rules,
139122
+ tsconfig
138988
139123
  ]);
138989
139124
  return bundle;
138990
139125
  }
138991
139126
 
138992
139127
  // src/dev/dev.tsx
138993
139128
  function DevImplementation(props) {
138994
- const port = props.port ?? 8787;
138995
139129
  const apiToken = props.initialMode === "remote" ? getAPIToken() : void 0;
138996
139130
  const directory = useTmpDir();
138997
- useCustomBuild(props.entry, props.buildCommand);
139131
+ useCustomBuild(props.entry, props.build);
138998
139132
  if (props.public && props.entry.format === "service-worker") {
138999
139133
  throw new Error("You cannot use the service worker format with a `public` directory.");
139000
139134
  }
@@ -139011,35 +139145,61 @@ function DevImplementation(props) {
139011
139145
  jsxFactory: props.jsxFactory,
139012
139146
  rules: props.rules,
139013
139147
  jsxFragment: props.jsxFragment,
139014
- serveAssetsFromWorker: !!props.public
139148
+ serveAssetsFromWorker: !!props.public,
139149
+ tsconfig: props.tsconfig
139015
139150
  });
139151
+ const { isRawModeSupported } = (0, import_ink2.useStdin)();
139152
+ return isRawModeSupported ? /* @__PURE__ */ import_react7.default.createElement(InteractiveDevSession, {
139153
+ ...props,
139154
+ bundle,
139155
+ apiToken
139156
+ }) : /* @__PURE__ */ import_react7.default.createElement(DevSession, {
139157
+ ...props,
139158
+ bundle,
139159
+ apiToken,
139160
+ local: props.initialMode === "local"
139161
+ });
139162
+ }
139163
+ function InteractiveDevSession(props) {
139016
139164
  const toggles = useHotkeys({
139017
139165
  local: props.initialMode === "local",
139018
139166
  tunnel: false
139019
- }, port, props.ip, props.inspectorPort, props.localProtocol);
139167
+ }, props.port, props.ip, props.inspectorPort, props.localProtocol);
139020
139168
  useTunnel(toggles.tunnel);
139021
- return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, toggles.local ? /* @__PURE__ */ import_react7.default.createElement(Local, {
139169
+ return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, /* @__PURE__ */ import_react7.default.createElement(DevSession, {
139170
+ ...props,
139171
+ local: toggles.local
139172
+ }), /* @__PURE__ */ import_react7.default.createElement(import_ink2.Box, {
139173
+ borderStyle: "round",
139174
+ paddingLeft: 1,
139175
+ paddingRight: 1
139176
+ }, /* @__PURE__ */ import_react7.default.createElement(import_ink2.Text, null, `B to open a browser, D to open Devtools, L to ${toggles.local ? "turn off" : "turn on"} local mode, X to exit`)));
139177
+ }
139178
+ function DevSession(props) {
139179
+ return props.local ? /* @__PURE__ */ import_react7.default.createElement(Local, {
139022
139180
  name: props.name,
139023
- bundle,
139181
+ bundle: props.bundle,
139024
139182
  format: props.entry.format,
139183
+ compatibilityDate: props.compatibilityDate,
139184
+ compatibilityFlags: props.compatibilityFlags,
139025
139185
  bindings: props.bindings,
139026
139186
  assetPaths: props.assetPaths,
139027
139187
  public: props.public,
139028
- port,
139188
+ port: props.port,
139029
139189
  ip: props.ip,
139030
139190
  rules: props.rules,
139031
139191
  inspectorPort: props.inspectorPort,
139032
139192
  enableLocalPersistence: props.enableLocalPersistence
139033
139193
  }) : /* @__PURE__ */ import_react7.default.createElement(Remote, {
139034
139194
  name: props.name,
139035
- bundle,
139195
+ bundle: props.bundle,
139036
139196
  format: props.entry.format,
139037
139197
  accountId: props.accountId,
139038
- apiToken,
139198
+ apiToken: props.apiToken,
139039
139199
  bindings: props.bindings,
139040
139200
  assetPaths: props.assetPaths,
139041
139201
  public: props.public,
139042
- port,
139202
+ port: props.port,
139043
139203
  ip: props.ip,
139044
139204
  localProtocol: props.localProtocol,
139045
139205
  inspectorPort: props.inspectorPort,
@@ -139049,11 +139209,7 @@ function DevImplementation(props) {
139049
139209
  env: props.env,
139050
139210
  legacyEnv: props.legacyEnv,
139051
139211
  zone: props.zone
139052
- }), /* @__PURE__ */ import_react7.default.createElement(import_ink2.Box, {
139053
- borderStyle: "round",
139054
- paddingLeft: 1,
139055
- paddingRight: 1
139056
- }, /* @__PURE__ */ import_react7.default.createElement(import_ink2.Text, null, `B to open a browser, D to open Devtools, L to ${toggles.local ? "turn off" : "turn on"} local mode, X to exit`)));
139212
+ });
139057
139213
  }
139058
139214
  function useTmpDir() {
139059
139215
  const [directory, setDirectory] = (0, import_react7.useState)();
@@ -139096,7 +139252,7 @@ function useCustomBuild(expectedEntry, build5) {
139096
139252
  }, [build5, expectedEntry.file]);
139097
139253
  }
139098
139254
  function sleep(period) {
139099
- return new Promise((resolve7) => setTimeout(resolve7, period));
139255
+ return new Promise((resolve8) => setTimeout(resolve8, period));
139100
139256
  }
139101
139257
  var SLEEP_DURATION = 2e3;
139102
139258
  var hostNameRegex = /userHostname="(.*)"/g;
@@ -139220,12 +139376,12 @@ function Confirm(props) {
139220
139376
  return /* @__PURE__ */ React3.createElement(import_ink3.Box, null, /* @__PURE__ */ React3.createElement(import_ink3.Text, null, props.text, " (y/n) "));
139221
139377
  }
139222
139378
  function confirm(text) {
139223
- return new Promise((resolve7) => {
139379
+ return new Promise((resolve8) => {
139224
139380
  const { unmount } = (0, import_ink3.render)(/* @__PURE__ */ React3.createElement(Confirm, {
139225
139381
  text,
139226
139382
  onConfirm: (answer) => {
139227
139383
  unmount();
139228
- resolve7(answer);
139384
+ resolve8(answer);
139229
139385
  }
139230
139386
  }));
139231
139387
  });
@@ -139240,13 +139396,13 @@ function Prompt(props) {
139240
139396
  })));
139241
139397
  }
139242
139398
  async function prompt(text, type2 = "text") {
139243
- return new Promise((resolve7) => {
139399
+ return new Promise((resolve8) => {
139244
139400
  const { unmount } = (0, import_ink3.render)(/* @__PURE__ */ React3.createElement(Prompt, {
139245
139401
  text,
139246
139402
  type: type2,
139247
139403
  onSubmit: (inputText) => {
139248
139404
  unmount();
139249
- resolve7(inputText);
139405
+ resolve8(inputText);
139250
139406
  }
139251
139407
  }));
139252
139408
  });
@@ -139665,6 +139821,7 @@ export const routes = [
139665
139821
  }
139666
139822
 
139667
139823
  // src/pages.tsx
139824
+ var pagesBetaWarning = "\u{1F6A7} 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose";
139668
139825
  var EXIT_CALLBACKS = [];
139669
139826
  var EXIT = (message2, code) => {
139670
139827
  if (message2)
@@ -139672,6 +139829,7 @@ var EXIT = (message2, code) => {
139672
139829
  if (code)
139673
139830
  process.exitCode = code;
139674
139831
  EXIT_CALLBACKS.forEach((callback) => callback());
139832
+ RUNNING_BUILDERS.forEach((builder) => builder.stop?.());
139675
139833
  process.exit(code);
139676
139834
  };
139677
139835
  process.on("SIGINT", () => EXIT());
@@ -139681,7 +139839,7 @@ function isWindows() {
139681
139839
  }
139682
139840
  var SECONDS_TO_WAIT_FOR_PROXY = 5;
139683
139841
  async function sleep2(ms) {
139684
- await new Promise((resolve7) => setTimeout(resolve7, ms));
139842
+ await new Promise((resolve8) => setTimeout(resolve8, ms));
139685
139843
  }
139686
139844
  function getPids(pid) {
139687
139845
  const pids = [pid];
@@ -140161,7 +140319,7 @@ var pages = (yargs) => {
140161
140319
  default: false,
140162
140320
  description: "Auto reload HTML pages when change is detected"
140163
140321
  }
140164
- });
140322
+ }).epilogue(pagesBetaWarning);
140165
140323
  }, async ({
140166
140324
  local,
140167
140325
  directory,
@@ -140174,6 +140332,7 @@ var pages = (yargs) => {
140174
140332
  "live-reload": liveReload,
140175
140333
  _: [_pages, _dev, ...remaining]
140176
140334
  }) => {
140335
+ console.log(pagesBetaWarning);
140177
140336
  if (!local) {
140178
140337
  console.error("Only local mode is supported at the moment.");
140179
140338
  return;
@@ -140192,17 +140351,20 @@ var pages = (yargs) => {
140192
140351
  }
140193
140352
  let miniflareArgs = {};
140194
140353
  let scriptReadyResolve;
140195
- const scriptReadyPromise = new Promise((resolve7) => scriptReadyResolve = resolve7);
140354
+ const scriptReadyPromise = new Promise((resolve8) => scriptReadyResolve = resolve8);
140196
140355
  if (usingFunctions) {
140197
140356
  const scriptPath = (0, import_node_path19.join)((0, import_node_os7.tmpdir)(), "./functionsWorker.js");
140198
140357
  console.log(`Compiling worker to "${scriptPath}"...`);
140199
- await buildFunctions({
140200
- scriptPath,
140201
- functionsDirectory,
140202
- sourcemap: true,
140203
- watch: true,
140204
- onEnd: () => scriptReadyResolve()
140205
- });
140358
+ try {
140359
+ await buildFunctions({
140360
+ scriptPath,
140361
+ functionsDirectory,
140362
+ sourcemap: true,
140363
+ watch: true,
140364
+ onEnd: () => scriptReadyResolve()
140365
+ });
140366
+ } catch {
140367
+ }
140206
140368
  (0, import_chokidar2.watch)([functionsDirectory], {
140207
140369
  persistent: true,
140208
140370
  ignoreInitial: true
@@ -140252,7 +140414,7 @@ var pages = (yargs) => {
140252
140414
  kvNamespaces: kvs.map((kv) => kv.toString()),
140253
140415
  durableObjects: Object.fromEntries(durableObjects.map((durableObject) => durableObject.toString().split("="))),
140254
140416
  bindings: {
140255
- ...Object.fromEntries(bindings.map((binding) => binding.toString().split("=", 1)))
140417
+ ...Object.fromEntries(bindings.map((binding) => binding.toString().split("=")).map(([key2, ...values]) => [key2, values.join("=")]))
140256
140418
  },
140257
140419
  serviceBindings: {
140258
140420
  async ASSETS(request) {
@@ -140337,7 +140499,7 @@ var pages = (yargs) => {
140337
140499
  default: false,
140338
140500
  description: "Watch for changes to the functions and automatically rebuild the Worker script"
140339
140501
  }
140340
- }), async ({
140502
+ }).epilogue(pagesBetaWarning), async ({
140341
140503
  directory,
140342
140504
  "script-path": scriptPath,
140343
140505
  "output-config-path": outputConfigPath,
@@ -140346,6 +140508,7 @@ var pages = (yargs) => {
140346
140508
  fallbackService,
140347
140509
  watch: watch3
140348
140510
  }) => {
140511
+ console.log(pagesBetaWarning);
140349
140512
  await buildFunctions({
140350
140513
  scriptPath,
140351
140514
  outputConfigPath,
@@ -140369,17 +140532,16 @@ var import_node_path20 = __toESM(require("node:path"));
140369
140532
  var import_node_url9 = require("node:url");
140370
140533
  var import_tmp_promise2 = __toESM(require_tmp_promise());
140371
140534
  function sleep3(ms) {
140372
- return new Promise((resolve7) => setTimeout(resolve7, ms));
140535
+ return new Promise((resolve8) => setTimeout(resolve8, ms));
140373
140536
  }
140374
140537
  async function publish(props) {
140375
140538
  const { config, accountId } = props;
140376
- const envRootObj = props.env && config.env[props.env] || config;
140377
- (0, import_node_assert7.default)(props.compatibilityDate || envRootObj.compatibility_date, "A compatibility_date is required when publishing. Add one to your wrangler.toml file, or pass it in your terminal as --compatibility_date. See https://developers.cloudflare.com/workers/platform/compatibility-dates for more information.");
140378
- const triggers = props.triggers || envRootObj.triggers?.crons;
140379
- const routes = props.routes ?? envRootObj.routes ?? (envRootObj.route ? [envRootObj.route] : []) ?? [];
140380
- const deployToWorkersDev = envRootObj.workers_dev;
140381
- const jsxFactory = props.jsxFactory || envRootObj.jsx_factory;
140382
- const jsxFragment = props.jsxFragment || envRootObj.jsx_fragment;
140539
+ (0, import_node_assert7.default)(props.compatibilityDate || config.compatibility_date, "A compatibility_date is required when publishing. Add one to your wrangler.toml file, or pass it in your terminal as --compatibility_date. See https://developers.cloudflare.com/workers/platform/compatibility-dates for more information.");
140540
+ const triggers = props.triggers || config.triggers?.crons;
140541
+ const routes = props.routes ?? config.routes ?? (config.route ? [config.route] : []) ?? [];
140542
+ const deployToWorkersDev = config.workers_dev ?? routes.length === 0;
140543
+ const jsxFactory = props.jsxFactory || config.jsx_factory;
140544
+ const jsxFragment = props.jsxFragment || config.jsx_fragment;
140383
140545
  const scriptName = props.name;
140384
140546
  (0, import_node_assert7.default)(scriptName, 'You need to provide a name when publishing a worker. Either pass it as a cli arg with `--name <name>` or in your config file as `name = "<name>"`');
140385
140547
  (0, import_node_assert7.default)(!config.site || config.site.bucket, "A [site] definition requires a `bucket` field with a path to the site's public directory.");
@@ -140400,7 +140562,8 @@ async function publish(props) {
140400
140562
  serveAssetsFromWorker: props.experimentalPublic,
140401
140563
  jsxFactory,
140402
140564
  jsxFragment,
140403
- rules: props.rules
140565
+ rules: props.rules,
140566
+ tsconfig: props.tsconfig ?? config.tsconfig
140404
140567
  });
140405
140568
  const content = (0, import_node_fs8.readFileSync)(resolvedEntryPointPath, {
140406
140569
  encoding: "utf-8"
@@ -140434,8 +140597,8 @@ async function publish(props) {
140434
140597
  }
140435
140598
  const assets = await syncAssets(accountId, scriptName + (!props.legacyEnv && props.env ? `-${props.env}` : ""), props.assetPaths, false);
140436
140599
  const bindings = {
140437
- kv_namespaces: (envRootObj.kv_namespaces || []).concat(assets.namespace ? { binding: "__STATIC_CONTENT", id: assets.namespace } : []),
140438
- vars: envRootObj.vars,
140600
+ kv_namespaces: (config.kv_namespaces || []).concat(assets.namespace ? { binding: "__STATIC_CONTENT", id: assets.namespace } : []),
140601
+ vars: config.vars,
140439
140602
  wasm_modules: config.wasm_modules,
140440
140603
  text_blobs: {
140441
140604
  ...config.text_blobs,
@@ -140443,9 +140606,9 @@ async function publish(props) {
140443
140606
  __STATIC_CONTENT_MANIFEST: "__STATIC_CONTENT_MANIFEST"
140444
140607
  }
140445
140608
  },
140446
- durable_objects: envRootObj.durable_objects,
140447
- r2_buckets: envRootObj.r2_buckets,
140448
- unsafe: envRootObj.unsafe?.bindings
140609
+ durable_objects: config.durable_objects,
140610
+ r2_buckets: config.r2_buckets,
140611
+ unsafe: config.unsafe?.bindings
140449
140612
  };
140450
140613
  if (assets.manifest) {
140451
140614
  modules.push({
@@ -140464,9 +140627,9 @@ async function publish(props) {
140464
140627
  bindings,
140465
140628
  migrations,
140466
140629
  modules,
140467
- compatibility_date: props.compatibilityDate ?? envRootObj.compatibility_date,
140468
- compatibility_flags: props.compatibilityFlags ?? envRootObj.compatibility_flags,
140469
- usage_model: envRootObj.usage_model
140630
+ compatibility_date: props.compatibilityDate ?? config.compatibility_date,
140631
+ compatibility_flags: props.compatibilityFlags ?? config.compatibility_flags,
140632
+ usage_model: config.usage_model
140470
140633
  };
140471
140634
  const start = Date.now();
140472
140635
  const notProd = !props.legacyEnv && props.env;
@@ -140673,12 +140836,12 @@ function prettyPrintLogs(data) {
140673
140836
  }
140674
140837
  if (eventMessage.logs.length > 0) {
140675
140838
  eventMessage.logs.forEach(({ level, message: message2 }) => {
140676
- console.log(` (${level}) ${message2}`);
140839
+ console.log(` (${level})`, message2);
140677
140840
  });
140678
140841
  }
140679
140842
  if (eventMessage.exceptions.length > 0) {
140680
140843
  eventMessage.exceptions.forEach(({ name: name2, message: message2 }) => {
140681
- console.error(` ${name2}: ${message2}`);
140844
+ console.error(` ${name2}:`, message2);
140682
140845
  });
140683
140846
  }
140684
140847
  }
@@ -140812,14 +140975,19 @@ function printWranglerBanner() {
140812
140975
  console.log(text + "\n" + (supports_color_default.stdout ? import_chalk.default.hex("#FF8800")("-".repeat(text.length)) : "-".repeat(text.length)));
140813
140976
  }
140814
140977
  function isLegacyEnv(args2, config) {
140815
- return args2["legacy-env"] ?? config.legacy_env;
140978
+ return config.legacy_env;
140816
140979
  }
140817
140980
  function getScriptName(args2, config) {
140818
- const shortScriptName = args2.name ?? config.name;
140819
- if (!shortScriptName) {
140820
- return;
140981
+ if (args2.name && isLegacyEnv(args2, config) && args2.env) {
140982
+ throw new CommandLineArgsError(`In legacy environment mode you cannot use --name and --env together. If you want to specify a Worker name for a specific environment you can add the following to your wrangler.toml config:
140983
+ [env.${args2.env}]
140984
+ name = "${args2.name}"
140985
+ `);
140821
140986
  }
140822
- return isLegacyEnv(args2, config) ? `${shortScriptName}${args2.env ? `-${args2.env}` : ""}` : shortScriptName;
140987
+ return args2.name ?? config.name;
140988
+ }
140989
+ function getLegacyScriptName(args2, config) {
140990
+ return args2.name && args2.env && isLegacyEnv(args2, config) ? `${args2.name}-${args2.env}` : args2.name ?? config.name;
140823
140991
  }
140824
140992
  async function requireAuth(config, isInteractive = true) {
140825
140993
  const loggedIn = await loginOrRefreshIfRequired(isInteractive);
@@ -140833,7 +141001,7 @@ async function requireAuth(config, isInteractive = true) {
140833
141001
  return accountId;
140834
141002
  }
140835
141003
  function readFromStdin() {
140836
- return new Promise((resolve7, reject) => {
141004
+ return new Promise((resolve8, reject) => {
140837
141005
  const stdin = process.stdin;
140838
141006
  const chunks = [];
140839
141007
  stdin.on("readable", () => {
@@ -140843,7 +141011,7 @@ function readFromStdin() {
140843
141011
  }
140844
141012
  });
140845
141013
  stdin.on("end", () => {
140846
- resolve7(chunks.join(""));
141014
+ resolve8(chunks.join(""));
140847
141015
  });
140848
141016
  stdin.on("error", (err2) => {
140849
141017
  reject(err2);
@@ -140871,7 +141039,7 @@ ${message2}`);
140871
141039
  }
140872
141040
  };
140873
141041
  async function main(argv) {
140874
- const wrangler = yargs_default(argv).showHelpOnFail(false).fail((msg, error) => {
141042
+ const wrangler = yargs_default(argv).strict().showHelpOnFail(false).fail((msg, error) => {
140875
141043
  if (!error) {
140876
141044
  error = new CommandLineArgsError(msg);
140877
141045
  }
@@ -140906,6 +141074,11 @@ async function main(argv) {
140906
141074
  return yargs.positional("name", {
140907
141075
  describe: "The name of your worker",
140908
141076
  type: "string"
141077
+ }).option("type", {
141078
+ describe: "The type of worker to create",
141079
+ type: "string",
141080
+ choices: ["rust", "javascript", "webpack"],
141081
+ deprecated: true
140909
141082
  }).option("yes", {
140910
141083
  describe: 'Answer "yes" to any prompts for new projects',
140911
141084
  type: "boolean",
@@ -140913,7 +141086,7 @@ async function main(argv) {
140913
141086
  });
140914
141087
  }, async (args2) => {
140915
141088
  printWranglerBanner();
140916
- if ("type" in args2) {
141089
+ if (args2.type) {
140917
141090
  let message2 = "The --type option is no longer supported.";
140918
141091
  if (args2.type === "webpack") {
140919
141092
  message2 += "\nIf you wish to use webpack then you will need to create a custom build.";
@@ -141115,7 +141288,8 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141115
141288
  describe: "Choose an entry type"
141116
141289
  }).option("env", {
141117
141290
  describe: "Perform on a specific environment",
141118
- type: "string"
141291
+ type: "string",
141292
+ alias: "e"
141119
141293
  }).option("compatibility-date", {
141120
141294
  describe: "Date to use for compatibility checks",
141121
141295
  type: "string"
@@ -141169,6 +141343,9 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141169
141343
  }).option("jsx-fragment", {
141170
141344
  describe: "The function that is called for each JSX fragment",
141171
141345
  type: "string"
141346
+ }).option("tsconfig", {
141347
+ describe: "Path to a custom tsconfig.json file",
141348
+ type: "string"
141172
141349
  }).option("local", {
141173
141350
  alias: "l",
141174
141351
  describe: "Run on my machine",
@@ -141180,7 +141357,8 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141180
141357
  });
141181
141358
  }, async (args2) => {
141182
141359
  printWranglerBanner();
141183
- const config = readConfig(args2.config || args2.script && findWranglerToml(import_node_path21.default.dirname(args2.script)));
141360
+ const configPath = args2.config || args2.script && findWranglerToml(import_node_path21.default.dirname(args2.script));
141361
+ const config = readConfig(configPath, args2);
141184
141362
  const entry = await getEntry(args2, config, "dev");
141185
141363
  if (args2["experimental-public"]) {
141186
141364
  console.warn("\u{1F6A8} The --experimental-public field is experimental and will change in the future.");
@@ -141199,29 +141377,30 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141199
141377
  }
141200
141378
  return new URL(urlLike).host;
141201
141379
  }
141202
- async function getZoneId(host2) {
141203
- const zones = await fetchResult(`/zones`, {}, new URLSearchParams({ name: host2 }));
141380
+ async function getZoneId(host) {
141381
+ const zones = await fetchResult(`/zones`, {}, new URLSearchParams({ name: host }));
141204
141382
  return zones[0]?.id;
141205
141383
  }
141206
- const environments = config.env ?? {};
141207
- const envRootObj = args2.env ? environments[args2.env] || {} : config;
141208
- const hostLike = args2.host || config.dev.host || args2.routes && args2.routes[0] || envRootObj.route || envRootObj.routes && envRootObj.routes[0];
141209
- const host = typeof hostLike === "string" ? getHost(hostLike) : void 0;
141210
- let zoneId;
141211
- const hostPieces = typeof host === "string" ? host.split(".") : void 0;
141212
- while (hostPieces && hostPieces.length > 1) {
141213
- zoneId = await getZoneId(hostPieces.join("."));
141214
- if (zoneId)
141215
- break;
141216
- hostPieces.shift();
141217
- }
141218
- if (host && !zoneId) {
141219
- throw new Error(`Could not find zone for ${hostLike}`);
141384
+ let zone;
141385
+ if (!args2.local) {
141386
+ const hostLike = args2.host || config.dev.host || args2.routes && args2.routes[0] || config.route || config.routes && config.routes[0];
141387
+ const host = typeof hostLike === "string" ? getHost(hostLike) : void 0;
141388
+ let zoneId;
141389
+ const hostPieces = typeof host === "string" ? host.split(".") : void 0;
141390
+ while (hostPieces && hostPieces.length > 1) {
141391
+ zoneId = await getZoneId(hostPieces.join("."));
141392
+ if (zoneId)
141393
+ break;
141394
+ hostPieces.shift();
141395
+ }
141396
+ if (host && !zoneId) {
141397
+ throw new Error(`Could not find zone for ${hostLike}`);
141398
+ }
141399
+ zone = typeof zoneId === "string" && typeof host === "string" ? {
141400
+ host,
141401
+ id: zoneId
141402
+ } : void 0;
141220
141403
  }
141221
- const zone = typeof zoneId === "string" && typeof host === "string" ? {
141222
- host,
141223
- id: zoneId
141224
- } : void 0;
141225
141404
  const { waitUntilExit } = (0, import_ink5.render)(/* @__PURE__ */ import_react10.default.createElement(dev_default, {
141226
141405
  name: getScriptName(args2, config),
141227
141406
  entry,
@@ -141229,10 +141408,11 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141229
141408
  zone,
141230
141409
  rules: getRules(config),
141231
141410
  legacyEnv: isLegacyEnv(args2, config),
141232
- buildCommand: config.build || {},
141411
+ build: config.build || {},
141233
141412
  initialMode: args2.local ? "local" : "remote",
141234
- jsxFactory: args2["jsx-factory"] || envRootObj?.jsx_factory,
141235
- jsxFragment: args2["jsx-fragment"] || envRootObj?.jsx_fragment,
141413
+ jsxFactory: args2["jsx-factory"] || config.jsx_factory,
141414
+ jsxFragment: args2["jsx-fragment"] || config.jsx_fragment,
141415
+ tsconfig: args2.tsconfig ?? config.tsconfig,
141236
141416
  upstreamProtocol,
141237
141417
  localProtocol: args2["local-protocol"] || config.dev.local_protocol,
141238
141418
  enableLocalPersistence: args2["experimental-enable-local-persistence"] || false,
@@ -141244,9 +141424,9 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141244
141424
  public: args2["experimental-public"],
141245
141425
  compatibilityDate: args2["compatibility-date"] || config.compatibility_date || new Date().toISOString().substring(0, 10),
141246
141426
  compatibilityFlags: args2["compatibility-flags"] || config.compatibility_flags,
141247
- usageModel: envRootObj.usage_model,
141427
+ usageModel: config.usage_model,
141248
141428
  bindings: {
141249
- kv_namespaces: envRootObj.kv_namespaces?.map(({ binding, preview_id, id: _id }) => {
141429
+ kv_namespaces: config.kv_namespaces?.map(({ binding, preview_id, id: _id }) => {
141250
141430
  if (!preview_id) {
141251
141431
  throw new Error(`In development, you should use a separate kv namespace than the one you'd use in production. Please create a new kv namespace with "wrangler kv:namespace create <name> --preview" and add its id as preview_id to the kv_namespace "${binding}" in your wrangler.toml`);
141252
141432
  }
@@ -141255,12 +141435,12 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141255
141435
  id: preview_id
141256
141436
  };
141257
141437
  }),
141258
- vars: envRootObj.vars,
141438
+ vars: config.vars,
141259
141439
  wasm_modules: config.wasm_modules,
141260
141440
  text_blobs: config.text_blobs,
141261
- durable_objects: envRootObj.durable_objects,
141262
- r2_buckets: envRootObj.r2_buckets,
141263
- unsafe: envRootObj.unsafe?.bindings
141441
+ durable_objects: config.durable_objects,
141442
+ r2_buckets: config.r2_buckets,
141443
+ unsafe: config.unsafe?.bindings
141264
141444
  }
141265
141445
  }));
141266
141446
  await waitUntilExit();
@@ -141268,7 +141448,8 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141268
141448
  wrangler.command("publish [script]", "\u{1F199} Publish your Worker to Cloudflare.", (yargs) => {
141269
141449
  return yargs.option("env", {
141270
141450
  type: "string",
141271
- describe: "Perform on a specific environment"
141451
+ describe: "Perform on a specific environment",
141452
+ alias: "e"
141272
141453
  }).positional("script", {
141273
141454
  describe: "The path to an entry point for your worker",
141274
141455
  type: "string"
@@ -141317,6 +141498,9 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141317
141498
  }).option("jsx-fragment", {
141318
141499
  describe: "The function that is called for each JSX fragment",
141319
141500
  type: "string"
141501
+ }).option("tsconfig", {
141502
+ describe: "Path to a custom tsconfig.json file",
141503
+ type: "string"
141320
141504
  });
141321
141505
  }, async (args2) => {
141322
141506
  printWranglerBanner();
@@ -141326,7 +141510,8 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141326
141510
  if (args2.public) {
141327
141511
  throw new Error("\u{1F6A8} The --public field has been renamed to --experimental-public, and will change behaviour in the future.");
141328
141512
  }
141329
- const config = readConfig(args2.config || args2.script && findWranglerToml(import_node_path21.default.dirname(args2.script)));
141513
+ const configPath = args2.config || args2.script && findWranglerToml(import_node_path21.default.dirname(args2.script));
141514
+ const config = readConfig(configPath, args2);
141330
141515
  const entry = await getEntry(args2, config, "publish");
141331
141516
  if (args2.latest) {
141332
141517
  console.warn("\u26A0\uFE0F Using the latest version of the Workers runtime. To silence this warning, please choose a specific version of the runtime with --compatibility-date, or add a compatibility_date to your wrangler.toml.\n");
@@ -141345,6 +141530,7 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141345
141530
  triggers: args2.triggers,
141346
141531
  jsxFactory: args2["jsx-factory"],
141347
141532
  jsxFragment: args2["jsx-fragment"],
141533
+ tsconfig: args2.tsconfig,
141348
141534
  routes: args2.routes,
141349
141535
  assetPaths,
141350
141536
  legacyEnv: isLegacyEnv(args2, config),
@@ -141356,7 +141542,7 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141356
141542
  describe: "Name of the worker",
141357
141543
  type: "string"
141358
141544
  }).option("format", {
141359
- default: "json",
141545
+ default: "pretty",
141360
141546
  choices: ["json", "pretty"],
141361
141547
  describe: "The format of log entries"
141362
141548
  }).option("status", {
@@ -141382,7 +141568,8 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141382
141568
  array: true
141383
141569
  }).option("env", {
141384
141570
  type: "string",
141385
- describe: "Perform on a specific environment"
141571
+ describe: "Perform on a specific environment",
141572
+ alias: "e"
141386
141573
  }).option("debug", {
141387
141574
  type: "boolean",
141388
141575
  hidden: true,
@@ -141393,8 +141580,8 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141393
141580
  if (args2.format === "pretty") {
141394
141581
  printWranglerBanner();
141395
141582
  }
141396
- const config = readConfig(args2.config);
141397
- const scriptName = getScriptName(args2, config);
141583
+ const config = readConfig(args2.config, args2);
141584
+ const scriptName = getLegacyScriptName(args2, config);
141398
141585
  if (!scriptName) {
141399
141586
  throw new Error("Missing script name");
141400
141587
  }
@@ -141455,11 +141642,9 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141455
141642
  throw new DeprecationError2("The `wrangler preview` command has been deprecated.\nTry using `wrangler dev` to to try out a worker during development.\n");
141456
141643
  }
141457
141644
  console.warn("***************************************************\nThe `wrangler preview` command has been deprecated.\nAttempting to run `wrangler dev` instead.\n***************************************************\n");
141458
- const config = readConfig(args2.config);
141645
+ const config = readConfig(args2.config, args2);
141459
141646
  const entry = await getEntry({}, config, "dev");
141460
141647
  const accountId = await requireAuth(config);
141461
- const environments = config.env ?? {};
141462
- const envRootObj = args2.env ? environments[args2.env] || {} : config;
141463
141648
  const { waitUntilExit } = (0, import_ink5.render)(/* @__PURE__ */ import_react10.default.createElement(dev_default, {
141464
141649
  name: config.name,
141465
141650
  entry,
@@ -141467,10 +141652,11 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141467
141652
  env: args2.env,
141468
141653
  zone: void 0,
141469
141654
  legacyEnv: isLegacyEnv(args2, config),
141470
- buildCommand: config.build || {},
141655
+ build: config.build || {},
141471
141656
  initialMode: args2.local ? "local" : "remote",
141472
- jsxFactory: envRootObj?.jsx_factory,
141473
- jsxFragment: envRootObj?.jsx_fragment,
141657
+ jsxFactory: config.jsx_factory,
141658
+ jsxFragment: config.jsx_fragment,
141659
+ tsconfig: config.tsconfig,
141474
141660
  upstreamProtocol: config.dev.upstream_protocol,
141475
141661
  localProtocol: config.dev.local_protocol,
141476
141662
  enableLocalPersistence: false,
@@ -141483,7 +141669,7 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141483
141669
  compatibilityFlags: args2["compatibility-flags"] || config.compatibility_flags,
141484
141670
  usageModel: config.usage_model,
141485
141671
  bindings: {
141486
- kv_namespaces: envRootObj.kv_namespaces?.map(({ binding, preview_id, id: _id }) => {
141672
+ kv_namespaces: config.kv_namespaces?.map(({ binding, preview_id, id: _id }) => {
141487
141673
  if (!preview_id) {
141488
141674
  throw new Error(`In development, you should use a separate kv namespace than the one you'd use in production. Please create a new kv namespace with "wrangler kv:namespace create <name> --preview" and add its id as preview_id to the kv_namespace "${binding}" in your wrangler.toml`);
141489
141675
  }
@@ -141492,12 +141678,12 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141492
141678
  id: preview_id
141493
141679
  };
141494
141680
  }),
141495
- vars: envRootObj.vars,
141681
+ vars: config.vars,
141496
141682
  wasm_modules: config.wasm_modules,
141497
141683
  text_blobs: config.text_blobs,
141498
- durable_objects: envRootObj.durable_objects,
141499
- r2_buckets: envRootObj.r2_buckets,
141500
- unsafe: envRootObj.unsafe?.bindings
141684
+ durable_objects: config.durable_objects,
141685
+ r2_buckets: config.r2_buckets,
141686
+ unsafe: config.unsafe?.bindings
141501
141687
  },
141502
141688
  inspectorPort: await getPorts({ port: 9229 })
141503
141689
  }));
@@ -141522,7 +141708,7 @@ To start developing your Worker, run \`npx wrangler dev\`${isCreatingWranglerTom
141522
141708
  throw new DeprecationError2(`${deprecationNotice}
141523
141709
  ${futureRoutes}
141524
141710
  ${presentRoutes}`);
141525
- }).command("delete", "Delete a route associated with a zone", (yargs) => {
141711
+ }).command("delete [id]", "Delete a route associated with a zone", (yargs) => {
141526
141712
  return yargs.positional("id", {
141527
141713
  describe: "The hash of the route ID to delete.",
141528
141714
  type: "string"
@@ -141560,12 +141746,13 @@ ${shouldDo}`);
141560
141746
  type: "string"
141561
141747
  }).option("env", {
141562
141748
  type: "string",
141563
- describe: "Binds the secret to the Worker of the specific environment"
141749
+ describe: "Binds the secret to the Worker of the specific environment",
141750
+ alias: "e"
141564
141751
  });
141565
141752
  }, async (args2) => {
141566
141753
  printWranglerBanner();
141567
- const config = readConfig(args2.config);
141568
- const scriptName = getScriptName(args2, config);
141754
+ const config = readConfig(args2.config, args2);
141755
+ const scriptName = getLegacyScriptName(args2, config);
141569
141756
  if (!scriptName) {
141570
141757
  throw new Error("Missing script name");
141571
141758
  }
@@ -141636,11 +141823,12 @@ ${shouldDo}`);
141636
141823
  type: "string"
141637
141824
  }).option("env", {
141638
141825
  type: "string",
141639
- describe: "Binds the secret to the Worker of the specific environment"
141826
+ describe: "Binds the secret to the Worker of the specific environment",
141827
+ alias: "e"
141640
141828
  });
141641
141829
  }, async (args2) => {
141642
- const config = readConfig(args2.config);
141643
- const scriptName = getScriptName(args2, config);
141830
+ const config = readConfig(args2.config, args2);
141831
+ const scriptName = getLegacyScriptName(args2, config);
141644
141832
  if (!scriptName) {
141645
141833
  throw new Error("Missing script name");
141646
141834
  }
@@ -141657,11 +141845,12 @@ ${shouldDo}`);
141657
141845
  type: "string"
141658
141846
  }).option("env", {
141659
141847
  type: "string",
141660
- describe: "Binds the secret to the Worker of the specific environment."
141848
+ describe: "Binds the secret to the Worker of the specific environment.",
141849
+ alias: "e"
141661
141850
  });
141662
141851
  }, async (args2) => {
141663
- const config = readConfig(args2.config);
141664
- const scriptName = getScriptName(args2, config);
141852
+ const config = readConfig(args2.config, args2);
141853
+ const scriptName = getLegacyScriptName(args2, config);
141665
141854
  if (!scriptName) {
141666
141855
  throw new Error("Missing script name");
141667
141856
  }
@@ -141678,21 +141867,18 @@ ${shouldDo}`);
141678
141867
  demandOption: true
141679
141868
  }).option("env", {
141680
141869
  type: "string",
141681
- describe: "Perform on a specific environment"
141870
+ describe: "Perform on a specific environment",
141871
+ alias: "e"
141682
141872
  }).option("preview", {
141683
141873
  type: "boolean",
141684
141874
  describe: "Interact with a preview namespace"
141685
141875
  });
141686
141876
  }, async (args2) => {
141687
141877
  printWranglerBanner();
141688
- if (args2._.length > 2) {
141689
- const extraArgs = args2._.slice(2).join(" ");
141690
- throw new CommandLineArgsError(`Unexpected additional positional arguments "${extraArgs}".`);
141691
- }
141692
141878
  if (!isValidNamespaceBinding(args2.namespace)) {
141693
141879
  throw new CommandLineArgsError(`The namespace binding name "${args2.namespace}" is invalid. It can only have alphanumeric and _ characters, and cannot begin with a number.`);
141694
141880
  }
141695
- const config = readConfig(args2.config);
141881
+ const config = readConfig(args2.config, args2);
141696
141882
  if (!config.name) {
141697
141883
  console.warn("No configured name present, using `worker` as a prefix for the title");
141698
141884
  }
@@ -141709,7 +141895,7 @@ ${shouldDo}`);
141709
141895
  console.log(`Add the following to your configuration file in your kv_namespaces array${envString}:`);
141710
141896
  console.log(`{ binding = "${args2.namespace}", ${previewString}id = "${namespaceId}" }`);
141711
141897
  }).command("list", "Outputs a list of all KV namespaces associated with your account id.", {}, async (args2) => {
141712
- const config = readConfig(args2.config);
141898
+ const config = readConfig(args2.config, args2);
141713
141899
  const accountId = await requireAuth(config);
141714
141900
  console.log(JSON.stringify(await listNamespaces(accountId), null, " "));
141715
141901
  }).command("delete", "Deletes a given namespace.", (yargs) => {
@@ -141721,14 +141907,15 @@ ${shouldDo}`);
141721
141907
  describe: "The id of the namespace to delete"
141722
141908
  }).check(demandOneOfOption("binding", "namespace-id")).option("env", {
141723
141909
  type: "string",
141724
- describe: "Perform on a specific environment"
141910
+ describe: "Perform on a specific environment",
141911
+ alias: "e"
141725
141912
  }).option("preview", {
141726
141913
  type: "boolean",
141727
141914
  describe: "Interact with a preview namespace"
141728
141915
  });
141729
141916
  }, async (args2) => {
141730
141917
  printWranglerBanner();
141731
- const config = readConfig(args2.config);
141918
+ const config = readConfig(args2.config, args2);
141732
141919
  let id;
141733
141920
  try {
141734
141921
  id = getNamespaceId(args2, config);
@@ -141756,7 +141943,8 @@ ${shouldDo}`);
141756
141943
  describe: "The id of the namespace to write to"
141757
141944
  }).check(demandOneOfOption("binding", "namespace-id")).option("env", {
141758
141945
  type: "string",
141759
- describe: "Perform on a specific environment"
141946
+ describe: "Perform on a specific environment",
141947
+ alias: "e"
141760
141948
  }).option("preview", {
141761
141949
  type: "boolean",
141762
141950
  describe: "Interact with a preview namespace"
@@ -141772,7 +141960,7 @@ ${shouldDo}`);
141772
141960
  }).check(demandOneOfOption("value", "path"));
141773
141961
  }, async ({ key: key2, ttl, expiration, ...args2 }) => {
141774
141962
  printWranglerBanner();
141775
- const config = readConfig(args2.config);
141963
+ const config = readConfig(args2.config, args2);
141776
141964
  const namespaceId = getNamespaceId(args2, config);
141777
141965
  const value = args2.path ? readFileSync5(args2.path) : args2.value;
141778
141966
  if (args2.path) {
@@ -141796,7 +141984,8 @@ ${shouldDo}`);
141796
141984
  describe: "The id of the namespace to list"
141797
141985
  }).check(demandOneOfOption("binding", "namespace-id")).option("env", {
141798
141986
  type: "string",
141799
- describe: "Perform on a specific environment"
141987
+ describe: "Perform on a specific environment",
141988
+ alias: "e"
141800
141989
  }).option("preview", {
141801
141990
  type: "boolean",
141802
141991
  default: false,
@@ -141806,7 +141995,7 @@ ${shouldDo}`);
141806
141995
  describe: "A prefix to filter listed keys"
141807
141996
  });
141808
141997
  }, async ({ prefix: prefix2, ...args2 }) => {
141809
- const config = readConfig(args2.config);
141998
+ const config = readConfig(args2.config, args2);
141810
141999
  const namespaceId = getNamespaceId(args2, config);
141811
142000
  const accountId = await requireAuth(config);
141812
142001
  const results = await listNamespaceKeys(accountId, namespaceId, prefix2);
@@ -141824,7 +142013,8 @@ ${shouldDo}`);
141824
142013
  describe: "The id of the namespace to get from"
141825
142014
  }).check(demandOneOfOption("binding", "namespace-id")).option("env", {
141826
142015
  type: "string",
141827
- describe: "Perform on a specific environment"
142016
+ describe: "Perform on a specific environment",
142017
+ alias: "e"
141828
142018
  }).option("preview", {
141829
142019
  type: "boolean",
141830
142020
  describe: "Interact with a preview namespace"
@@ -141834,7 +142024,7 @@ ${shouldDo}`);
141834
142024
  describe: "Interact with a preview namespace"
141835
142025
  });
141836
142026
  }, async ({ key: key2, ...args2 }) => {
141837
- const config = readConfig(args2.config);
142027
+ const config = readConfig(args2.config, args2);
141838
142028
  const namespaceId = getNamespaceId(args2, config);
141839
142029
  const accountId = await requireAuth(config);
141840
142030
  console.log(await getKeyValue(accountId, namespaceId, key2));
@@ -141851,14 +142041,15 @@ ${shouldDo}`);
141851
142041
  describe: "The id of the namespace to delete from"
141852
142042
  }).check(demandOneOfOption("binding", "namespace-id")).option("env", {
141853
142043
  type: "string",
141854
- describe: "Perform on a specific environment"
142044
+ describe: "Perform on a specific environment",
142045
+ alias: "e"
141855
142046
  }).option("preview", {
141856
142047
  type: "boolean",
141857
142048
  describe: "Interact with a preview namespace"
141858
142049
  });
141859
142050
  }, async ({ key: key2, ...args2 }) => {
141860
142051
  printWranglerBanner();
141861
- const config = readConfig(args2.config);
142052
+ const config = readConfig(args2.config, args2);
141862
142053
  const namespaceId = getNamespaceId(args2, config);
141863
142054
  console.log(`deleting the key "${key2}" on namespace ${namespaceId}`);
141864
142055
  const accountId = await requireAuth(config);
@@ -141879,14 +142070,15 @@ ${shouldDo}`);
141879
142070
  describe: "The id of the namespace to insert values into"
141880
142071
  }).check(demandOneOfOption("binding", "namespace-id")).option("env", {
141881
142072
  type: "string",
141882
- describe: "Perform on a specific environment"
142073
+ describe: "Perform on a specific environment",
142074
+ alias: "e"
141883
142075
  }).option("preview", {
141884
142076
  type: "boolean",
141885
142077
  describe: "Interact with a preview namespace"
141886
142078
  });
141887
142079
  }, async ({ filename, ...args2 }) => {
141888
142080
  printWranglerBanner();
141889
- const config = readConfig(args2.config);
142081
+ const config = readConfig(args2.config, args2);
141890
142082
  const namespaceId = getNamespaceId(args2, config);
141891
142083
  const content = parseJSON(readFileSync5(filename), filename);
141892
142084
  if (!Array.isArray(content)) {
@@ -141945,7 +142137,8 @@ interface KeyValue {
141945
142137
  describe: "The id of the namespace to delete from"
141946
142138
  }).check(demandOneOfOption("binding", "namespace-id")).option("env", {
141947
142139
  type: "string",
141948
- describe: "Perform on a specific environment"
142140
+ describe: "Perform on a specific environment",
142141
+ alias: "e"
141949
142142
  }).option("preview", {
141950
142143
  type: "boolean",
141951
142144
  describe: "Interact with a preview namespace"
@@ -141956,7 +142149,7 @@ interface KeyValue {
141956
142149
  });
141957
142150
  }, async ({ filename, ...args2 }) => {
141958
142151
  printWranglerBanner();
141959
- const config = readConfig(args2.config);
142152
+ const config = readConfig(args2.config, args2);
141960
142153
  const namespaceId = getNamespaceId(args2, config);
141961
142154
  if (!args2.force) {
141962
142155
  const result = await confirm(`Are you sure you want to delete all the keys read from "${filename}" from kv-namespace with id "${namespaceId}"?`);
@@ -141990,7 +142183,9 @@ Expected an array of strings.
141990
142183
  console.log("Success!");
141991
142184
  });
141992
142185
  });
141993
- wrangler.command("pages", "\u26A1\uFE0F Configure Cloudflare Pages", (pagesYargs) => pages(pagesYargs.command(subHelp)));
142186
+ wrangler.command("pages", "\u26A1\uFE0F Configure Cloudflare Pages", async (pagesYargs) => {
142187
+ await pages(pagesYargs.command(subHelp).epilogue(pagesBetaWarning));
142188
+ });
141994
142189
  wrangler.command("r2", "\u{1F4E6} Interact with an R2 store", (r2Yargs) => {
141995
142190
  return r2Yargs.command(subHelp).command("bucket", "Manage R2 buckets", (r2BucketYargs) => {
141996
142191
  r2BucketYargs.command("create <name>", "Create a new R2 bucket", (yargs) => {
@@ -142001,18 +142196,14 @@ Expected an array of strings.
142001
142196
  });
142002
142197
  }, async (args2) => {
142003
142198
  printWranglerBanner();
142004
- if (args2._.length > 3) {
142005
- const extraArgs = args2._.slice(3).join(" ");
142006
- throw new CommandLineArgsError(`Unexpected additional positional arguments "${extraArgs}".`);
142007
- }
142008
- const config = readConfig(args2.config);
142199
+ const config = readConfig(args2.config, args2);
142009
142200
  const accountId = await requireAuth(config);
142010
142201
  console.log(`Creating bucket ${args2.name}.`);
142011
142202
  await createR2Bucket(accountId, args2.name);
142012
142203
  console.log(`Created bucket ${args2.name}.`);
142013
142204
  });
142014
142205
  r2BucketYargs.command("list", "List R2 buckets", {}, async (args2) => {
142015
- const config = readConfig(args2.config);
142206
+ const config = readConfig(args2.config, args2);
142016
142207
  const accountId = await requireAuth(config);
142017
142208
  console.log(JSON.stringify(await listR2Buckets(accountId), null, 2));
142018
142209
  });
@@ -142024,11 +142215,7 @@ Expected an array of strings.
142024
142215
  });
142025
142216
  }, async (args2) => {
142026
142217
  printWranglerBanner();
142027
- if (args2._.length > 3) {
142028
- const extraArgs = args2._.slice(3).join(" ");
142029
- throw new CommandLineArgsError(`Unexpected additional positional arguments "${extraArgs}".`);
142030
- }
142031
- const config = readConfig(args2.config);
142218
+ const config = readConfig(args2.config, args2);
142032
142219
  const accountId = await requireAuth(config);
142033
142220
  console.log(`Deleting bucket ${args2.name}.`);
142034
142221
  await deleteR2Bucket(accountId, args2.name);