wrangler 3.63.0 → 3.63.2

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.
@@ -85870,7 +85870,7 @@ var require_view = __commonJS({
85870
85870
  var debug = require_src3()("express:view");
85871
85871
  var path72 = require("path");
85872
85872
  var fs26 = require("fs");
85873
- var dirname13 = path72.dirname;
85873
+ var dirname14 = path72.dirname;
85874
85874
  var basename4 = path72.basename;
85875
85875
  var extname4 = path72.extname;
85876
85876
  var join16 = path72.join;
@@ -85910,7 +85910,7 @@ var require_view = __commonJS({
85910
85910
  for (var i = 0; i < roots.length && !path73; i++) {
85911
85911
  var root = roots[i];
85912
85912
  var loc = resolve19(root, name);
85913
- var dir = dirname13(loc);
85913
+ var dir = dirname14(loc);
85914
85914
  var file = basename4(loc);
85915
85915
  path73 = this.resolve(dir, file);
85916
85916
  }
@@ -103142,9 +103142,9 @@ var require_command_exists = __commonJS({
103142
103142
  cleanInput = /* @__PURE__ */ __name(function(s) {
103143
103143
  var isPathName = /[\\]/.test(s);
103144
103144
  if (isPathName) {
103145
- var dirname13 = '"' + path72.dirname(s) + '"';
103145
+ var dirname14 = '"' + path72.dirname(s) + '"';
103146
103146
  var basename4 = '"' + path72.basename(s) + '"';
103147
- return dirname13 + ":" + basename4;
103147
+ return dirname14 + ":" + basename4;
103148
103148
  }
103149
103149
  return '"' + s + '"';
103150
103150
  }, "cleanInput");
@@ -152612,7 +152612,7 @@ init_import_meta_url();
152612
152612
  init_import_meta_url();
152613
152613
 
152614
152614
  // package.json
152615
- var version = "3.63.0";
152615
+ var version = "3.63.2";
152616
152616
  var package_default = {
152617
152617
  name: "wrangler",
152618
152618
  version,
@@ -152965,10 +152965,6 @@ var FunctionsBuildError = class extends UserError {
152965
152965
  }
152966
152966
  };
152967
152967
  __name(FunctionsBuildError, "FunctionsBuildError");
152968
- function getFunctionsBuildWarning(functionsDirectory, suffix) {
152969
- return `Unexpected error building Functions directory: ${functionsDirectory}${suffix ? " - " + suffix : ""}`;
152970
- }
152971
- __name(getFunctionsBuildWarning, "getFunctionsBuildWarning");
152972
152968
  var FunctionsNoRoutesError = class extends UserError {
152973
152969
  constructor(message) {
152974
152970
  super(message);
@@ -176235,7 +176231,10 @@ var Handler4 = /* @__PURE__ */ __name(async (args) => {
176235
176231
  await printWranglerBanner();
176236
176232
  const config = readConfig(args.config, args);
176237
176233
  if (file && command2) {
176238
- return logger.error(`Error: can't provide both --command and --file.`);
176234
+ throw createFatalError(
176235
+ `Error: can't provide both --command and --file.`,
176236
+ json
176237
+ );
176239
176238
  }
176240
176239
  const isInteractive3 = process.stdout.isTTY;
176241
176240
  try {
@@ -176573,17 +176572,24 @@ async function pollUntilComplete(response, accountId, db) {
176573
176572
  }
176574
176573
  __name(pollUntilComplete, "pollUntilComplete");
176575
176574
  async function d1ApiPost(accountId, db, action, body) {
176576
- return await fetchResult(
176577
- `/accounts/${accountId}/d1/database/${db.uuid}/${action}`,
176578
- {
176579
- method: "POST",
176580
- headers: {
176581
- "Content-Type": "application/json",
176582
- ...db.internal_env ? { "x-d1-internal-env": db.internal_env } : {}
176583
- },
176584
- body: JSON.stringify(body)
176575
+ try {
176576
+ return await fetchResult(
176577
+ `/accounts/${accountId}/d1/database/${db.uuid}/${action}`,
176578
+ {
176579
+ method: "POST",
176580
+ headers: {
176581
+ "Content-Type": "application/json",
176582
+ ...db.internal_env ? { "x-d1-internal-env": db.internal_env } : {}
176583
+ },
176584
+ body: JSON.stringify(body)
176585
+ }
176586
+ );
176587
+ } catch (x2) {
176588
+ if (x2 instanceof APIError) {
176589
+ x2.preventReport();
176585
176590
  }
176586
- );
176591
+ throw x2;
176592
+ }
176587
176593
  }
176588
176594
  __name(d1ApiPost, "d1ApiPost");
176589
176595
  function logResult(r3) {
@@ -185042,6 +185048,11 @@ The Worker script should be named \`_worker.js\` and located in the build output
185042
185048
  }
185043
185049
  });
185044
185050
  } else if (usingWorkerScript) {
185051
+ const watcher = (0, import_chokidar3.watch)([workerScriptPath], {
185052
+ persistent: true,
185053
+ ignoreInitial: true
185054
+ });
185055
+ let watchedBundleDependencies = [];
185045
185056
  scriptPath3 = workerScriptPath;
185046
185057
  let runBuild2 = /* @__PURE__ */ __name(async () => {
185047
185058
  await checkRawWorker(
@@ -185056,33 +185067,54 @@ The Worker script should be named \`_worker.js\` and located in the build output
185056
185067
  `./bundledWorker-${Math.random()}.mjs`
185057
185068
  );
185058
185069
  runBuild2 = /* @__PURE__ */ __name(async () => {
185059
- try {
185060
- await buildRawWorker({
185061
- workerScriptPath: usingWorkerDirectory ? (0, import_node_path50.join)(workerScriptPath, "index.js") : workerScriptPath,
185062
- outfile: scriptPath3,
185063
- directory: directory ?? ".",
185064
- nodejsCompatMode,
185065
- local: true,
185066
- sourcemap: true,
185067
- watch: false,
185068
- onEnd: () => scriptReadyResolve(),
185069
- defineNavigatorUserAgent
185070
- });
185071
- } catch (e3) {
185072
- logger.warn("Failed to bundle _worker.js.", e3);
185070
+ const workerScriptDirectory = (0, import_node_path50.dirname)(workerScriptPath);
185071
+ let currentBundleDependencies = [];
185072
+ const bundle = await buildRawWorker({
185073
+ workerScriptPath: usingWorkerDirectory ? (0, import_node_path50.join)(workerScriptPath, "index.js") : workerScriptPath,
185074
+ outfile: scriptPath3,
185075
+ directory: directory ?? ".",
185076
+ nodejsCompatMode,
185077
+ local: true,
185078
+ sourcemap: true,
185079
+ watch: false,
185080
+ onEnd: () => scriptReadyResolve(),
185081
+ defineNavigatorUserAgent
185082
+ });
185083
+ const bundleDependencies = Object.keys(bundle.dependencies).map((dep) => (0, import_node_path50.resolve)(workerScriptDirectory, dep)).filter(
185084
+ (resolvedDep) => !resolvedDep.includes((0, import_node_path50.normalize)(singleWorkerScriptPath)) && !resolvedDep.includes((0, import_node_path50.normalize)("/.wrangler/")) && resolvedDep.includes((0, import_node_path50.resolve)(process.cwd()))
185085
+ );
185086
+ const bundleModules = bundle.modules.filter((module3) => !!module3.filePath).map(
185087
+ (module3) => (0, import_node_path50.resolve)(workerScriptDirectory, module3.filePath)
185088
+ );
185089
+ currentBundleDependencies = [...bundleDependencies, ...bundleModules];
185090
+ if (watchedBundleDependencies.length) {
185091
+ watcher.unwatch(watchedBundleDependencies);
185073
185092
  }
185093
+ watcher.add(currentBundleDependencies);
185094
+ watchedBundleDependencies = [...currentBundleDependencies];
185074
185095
  }, "runBuild");
185075
185096
  }
185076
- await runBuild2();
185077
- (0, import_chokidar3.watch)([workerScriptPath], {
185078
- persistent: true,
185079
- ignoreInitial: true
185080
- }).on("all", async (event) => {
185081
- if (event === "unlink") {
185082
- return;
185097
+ const debouncedRunBuild = debounce(async () => {
185098
+ try {
185099
+ await runBuild2();
185100
+ } catch (e3) {
185101
+ logger.warn(
185102
+ `Failed to build ${singleWorkerScriptPath}. Continuing to serve the last successfully built version of the Worker.`
185103
+ );
185083
185104
  }
185105
+ }, 50);
185106
+ try {
185084
185107
  await runBuild2();
185085
- });
185108
+ watcher.on("all", async (eventName, path72) => {
185109
+ logger.debug(`\u{1F300} "${eventName}" event detected at ${path72}.`);
185110
+ if (eventName === "unlink") {
185111
+ return;
185112
+ }
185113
+ debouncedRunBuild();
185114
+ });
185115
+ } catch (e3) {
185116
+ throw new FatalError(`Failed to build ${singleWorkerScriptPath}.`);
185117
+ }
185086
185118
  } else if (usingFunctions) {
185087
185119
  scriptPath3 = (0, import_node_path50.join)(
185088
185120
  getPagesTmpDir(),
@@ -185094,74 +185126,55 @@ The Worker script should be named \`_worker.js\` and located in the build output
185094
185126
  );
185095
185127
  logger.debug(`Compiling worker to "${scriptPath3}"...`);
185096
185128
  const onEnd = /* @__PURE__ */ __name(() => scriptReadyResolve(), "onEnd");
185097
- const watchedBundleDependencies = /* @__PURE__ */ new Set();
185098
185129
  const watcher = (0, import_chokidar3.watch)([functionsDirectory], {
185099
185130
  persistent: true,
185100
185131
  ignoreInitial: true
185101
185132
  });
185102
- try {
185103
- const buildFn = /* @__PURE__ */ __name(async () => {
185104
- const currentBundleDependencies = /* @__PURE__ */ new Set();
185105
- const bundle = await buildFunctions({
185106
- outfile: scriptPath3,
185107
- functionsDirectory,
185108
- sourcemap: true,
185109
- watch: false,
185110
- onEnd,
185111
- buildOutputDirectory: directory,
185112
- nodejsCompatMode,
185113
- local: true,
185114
- routesModule,
185115
- defineNavigatorUserAgent
185116
- });
185117
- for (const dep in bundle.dependencies) {
185118
- const resolvedDep = (0, import_node_path50.resolve)(functionsDirectory, dep);
185119
- if (!resolvedDep.includes((0, import_node_path50.normalize)("/functions/")) && !resolvedDep.includes((0, import_node_path50.normalize)("/.wrangler/")) && resolvedDep.includes((0, import_node_path50.resolve)(process.cwd()))) {
185120
- currentBundleDependencies.add(resolvedDep);
185121
- if (!watchedBundleDependencies.has(resolvedDep)) {
185122
- watchedBundleDependencies.add(resolvedDep);
185123
- watcher.add(resolvedDep);
185124
- }
185125
- }
185126
- }
185127
- for (const module3 of bundle.modules) {
185128
- if (module3.filePath) {
185129
- const resolvedDep = (0, import_node_path50.resolve)(functionsDirectory, module3.filePath);
185130
- currentBundleDependencies.add(resolvedDep);
185131
- if (!watchedBundleDependencies.has(resolvedDep)) {
185132
- watchedBundleDependencies.add(resolvedDep);
185133
- watcher.add(resolvedDep);
185134
- }
185135
- }
185136
- }
185137
- watchedBundleDependencies.forEach(async (path72) => {
185138
- if (!currentBundleDependencies.has(path72)) {
185139
- watchedBundleDependencies.delete(path72);
185140
- watcher.unwatch(path72);
185141
- }
185142
- });
185143
- await sendMetricsEvent("build pages functions");
185144
- }, "buildFn");
185145
- const debouncedBuildFn = debounce(async () => {
185146
- try {
185147
- await buildFn();
185148
- } catch (e3) {
185149
- if (e3 instanceof FunctionsNoRoutesError) {
185150
- logger.error(
185151
- getFunctionsNoRoutesWarning(functionsDirectory, "skipping")
185152
- );
185153
- } else if (e3 instanceof FunctionsBuildError) {
185154
- logger.error(
185155
- getFunctionsBuildWarning(functionsDirectory, e3.message)
185156
- );
185157
- } else {
185158
- logger.error(
185159
- `Error while attempting to build the Functions directory ${functionsDirectory}. Skipping to last successfully built version of Functions.
185160
- ${e3}`
185161
- );
185162
- }
185133
+ let watchedBundleDependencies = [];
185134
+ const buildFn = /* @__PURE__ */ __name(async () => {
185135
+ let currentBundleDependencies = [];
185136
+ const bundle = await buildFunctions({
185137
+ outfile: scriptPath3,
185138
+ functionsDirectory,
185139
+ sourcemap: true,
185140
+ watch: false,
185141
+ onEnd,
185142
+ buildOutputDirectory: directory,
185143
+ nodejsCompatMode,
185144
+ local: true,
185145
+ routesModule,
185146
+ defineNavigatorUserAgent
185147
+ });
185148
+ const bundleDependencies = Object.keys(bundle.dependencies).map((dep) => (0, import_node_path50.resolve)(functionsDirectory, dep)).filter(
185149
+ (resolvedDep) => !resolvedDep.includes((0, import_node_path50.normalize)("/functions/")) && !resolvedDep.includes((0, import_node_path50.normalize)("/.wrangler/")) && resolvedDep.includes((0, import_node_path50.resolve)(process.cwd()))
185150
+ );
185151
+ const bundleModules = bundle.modules.filter((module3) => !!module3.filePath).map(
185152
+ (module3) => (0, import_node_path50.resolve)(functionsDirectory, module3.filePath)
185153
+ );
185154
+ currentBundleDependencies = [...bundleDependencies, ...bundleModules];
185155
+ if (watchedBundleDependencies.length) {
185156
+ watcher.unwatch(watchedBundleDependencies);
185157
+ }
185158
+ watcher.add(currentBundleDependencies);
185159
+ watchedBundleDependencies = [...currentBundleDependencies];
185160
+ await sendMetricsEvent("build pages functions");
185161
+ }, "buildFn");
185162
+ const debouncedBuildFn = debounce(async () => {
185163
+ try {
185164
+ await buildFn();
185165
+ } catch (e3) {
185166
+ if (e3 instanceof FunctionsNoRoutesError) {
185167
+ logger.warn(
185168
+ `${getFunctionsNoRoutesWarning(functionsDirectory)}. Continuing to serve the last successfully built version of Functions.`
185169
+ );
185170
+ } else {
185171
+ logger.warn(
185172
+ `Failed to build Functions at ${functionsDirectory}. Continuing to serve the last successfully built version of Functions.`
185173
+ );
185163
185174
  }
185164
- }, 50);
185175
+ }
185176
+ }, 50);
185177
+ try {
185165
185178
  await buildFn();
185166
185179
  watcher.on("all", async (eventName, path72) => {
185167
185180
  logger.debug(`\u{1F300} "${eventName}" event detected at ${path72}.`);
@@ -185176,15 +185189,14 @@ ${e3}`
185176
185189
  usingFunctions = false;
185177
185190
  } else {
185178
185191
  throw new FatalError(
185179
- `Error while attempting to build the Functions directory ${functionsDirectory}
185180
- ${e3}`
185192
+ `Failed to build Functions at ${functionsDirectory}.`
185181
185193
  );
185182
185194
  }
185183
185195
  }
185184
185196
  }
185185
185197
  if (!usingFunctions && !usingWorkerScript) {
185186
185198
  scriptReadyResolve();
185187
- logger.log("No functions. Shimming...");
185199
+ logger.log("No Functions. Shimming...");
185188
185200
  scriptPath3 = (0, import_node_path50.resolve)(getBasePath(), "templates/pages-shim.ts");
185189
185201
  }
185190
185202
  await scriptReadyPromise;
@@ -185581,24 +185593,40 @@ init_import_meta_url();
185581
185593
  var import_fs9 = require("fs");
185582
185594
  var import_promises20 = require("node:fs/promises");
185583
185595
  var import_toml4 = __toESM(require_toml());
185584
- async function toEnvironment(project, accountId) {
185596
+ var import_miniflare11 = require("miniflare");
185597
+ async function toEnvironment(deploymentConfig, accountId) {
185585
185598
  const configObj = {};
185586
- configObj.compatibility_date = project.compatibility_date ?? (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
185587
- if (project.compatibility_flags?.length) {
185588
- configObj.compatibility_flags = project.compatibility_flags;
185599
+ configObj.compatibility_date = deploymentConfig.compatibility_date ?? (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
185600
+ if (deploymentConfig.always_use_latest_compatibility_date) {
185601
+ configObj.compatibility_date = import_miniflare11.supportedCompatibilityDate;
185602
+ }
185603
+ if (deploymentConfig.compatibility_flags?.length) {
185604
+ configObj.compatibility_flags = deploymentConfig.compatibility_flags;
185605
+ }
185606
+ if (deploymentConfig.placement) {
185607
+ configObj.placement = deploymentConfig.placement;
185608
+ } else {
185609
+ configObj.placement = { mode: "off" };
185610
+ }
185611
+ if (deploymentConfig.limits) {
185612
+ configObj.limits = deploymentConfig.limits;
185589
185613
  }
185590
- for (const [name, envVar] of Object.entries(project.env_vars ?? {})) {
185614
+ for (const [name, envVar] of Object.entries(
185615
+ deploymentConfig.env_vars ?? {}
185616
+ )) {
185591
185617
  if (envVar?.value && envVar?.type == "plain_text") {
185592
185618
  configObj.vars ??= {};
185593
185619
  configObj.vars[name] = envVar?.value;
185594
185620
  }
185595
185621
  }
185596
- for (const [name, namespace] of Object.entries(project.kv_namespaces ?? {})) {
185622
+ for (const [name, namespace] of Object.entries(
185623
+ deploymentConfig.kv_namespaces ?? {}
185624
+ )) {
185597
185625
  configObj.kv_namespaces ??= [];
185598
185626
  configObj.kv_namespaces.push({ id: namespace.namespace_id, binding: name });
185599
185627
  }
185600
185628
  for (const [name, ns] of Object.entries(
185601
- project.durable_object_namespaces ?? {}
185629
+ deploymentConfig.durable_object_namespaces ?? {}
185602
185630
  )) {
185603
185631
  configObj.durable_objects ??= { bindings: [] };
185604
185632
  if (ns.class_name && ns.class_name !== "") {
@@ -185620,7 +185648,9 @@ async function toEnvironment(project, accountId) {
185620
185648
  });
185621
185649
  }
185622
185650
  }
185623
- for (const [name, namespace] of Object.entries(project.d1_databases ?? {})) {
185651
+ for (const [name, namespace] of Object.entries(
185652
+ deploymentConfig.d1_databases ?? {}
185653
+ )) {
185624
185654
  configObj.d1_databases ??= [];
185625
185655
  configObj.d1_databases.push({
185626
185656
  database_id: namespace.id,
@@ -185628,7 +185658,9 @@ async function toEnvironment(project, accountId) {
185628
185658
  database_name: name
185629
185659
  });
185630
185660
  }
185631
- for (const [name, bucket] of Object.entries(project.r2_buckets ?? {})) {
185661
+ for (const [name, bucket] of Object.entries(
185662
+ deploymentConfig.r2_buckets ?? {}
185663
+ )) {
185632
185664
  configObj.r2_buckets ??= [];
185633
185665
  configObj.r2_buckets.push({
185634
185666
  bucket_name: bucket.name,
@@ -185636,7 +185668,7 @@ async function toEnvironment(project, accountId) {
185636
185668
  });
185637
185669
  }
185638
185670
  for (const [name, { service, environment }] of Object.entries(
185639
- project.services ?? {}
185671
+ deploymentConfig.services ?? {}
185640
185672
  )) {
185641
185673
  configObj.services ??= [];
185642
185674
  configObj.services.push({
@@ -185645,7 +185677,9 @@ async function toEnvironment(project, accountId) {
185645
185677
  environment
185646
185678
  });
185647
185679
  }
185648
- for (const [name, queue] of Object.entries(project.queue_producers ?? {})) {
185680
+ for (const [name, queue] of Object.entries(
185681
+ deploymentConfig.queue_producers ?? {}
185682
+ )) {
185649
185683
  configObj.queues ??= { producers: [] };
185650
185684
  configObj.queues?.producers?.push({
185651
185685
  binding: name,
@@ -185653,7 +185687,7 @@ async function toEnvironment(project, accountId) {
185653
185687
  });
185654
185688
  }
185655
185689
  for (const [name, { dataset }] of Object.entries(
185656
- project.analytics_engine_datasets ?? {}
185690
+ deploymentConfig.analytics_engine_datasets ?? {}
185657
185691
  )) {
185658
185692
  configObj.analytics_engine_datasets ??= [];
185659
185693
  configObj.analytics_engine_datasets.push({
@@ -185661,36 +185695,70 @@ async function toEnvironment(project, accountId) {
185661
185695
  dataset
185662
185696
  });
185663
185697
  }
185664
- for (const [name] of Object.entries(project.ai_bindings ?? {})) {
185698
+ for (const [name] of Object.entries(deploymentConfig.ai_bindings ?? {})) {
185665
185699
  configObj.ai = { binding: name };
185666
185700
  }
185667
185701
  return configObj;
185668
185702
  }
185669
185703
  __name(toEnvironment, "toEnvironment");
185670
185704
  async function writeWranglerToml(toml) {
185705
+ let tomlString = import_toml4.default.stringify(toml);
185706
+ tomlString = tomlString.split("\n").map((line) => line.trimStart()).join("\n");
185671
185707
  await (0, import_promises20.writeFile)(
185672
185708
  "wrangler.toml",
185673
- [
185674
- `# Generated by Wrangler on ${/* @__PURE__ */ new Date()}`,
185675
- import_toml4.default.stringify(toml)
185676
- ].join("\n")
185709
+ `# Generated by Wrangler on ${/* @__PURE__ */ new Date()}
185710
+ ${tomlString}`
185677
185711
  );
185678
185712
  }
185679
185713
  __name(writeWranglerToml, "writeWranglerToml");
185714
+ function simplifyEnvironments(preview, production) {
185715
+ const topLevel = { ...preview };
185716
+ if (preview.compatibility_date === production.compatibility_date) {
185717
+ delete production.compatibility_date;
185718
+ delete preview.compatibility_date;
185719
+ }
185720
+ if (JSON.stringify(preview.compatibility_flags) === JSON.stringify(production.compatibility_flags)) {
185721
+ delete production.compatibility_flags;
185722
+ delete preview.compatibility_date;
185723
+ }
185724
+ if (JSON.stringify(preview.placement) === JSON.stringify(production.placement)) {
185725
+ delete production.placement;
185726
+ delete preview.placement;
185727
+ if (topLevel.placement?.mode === "off") {
185728
+ delete topLevel.placement;
185729
+ }
185730
+ }
185731
+ if (JSON.stringify(preview.limits) === JSON.stringify(production.limits)) {
185732
+ delete production.limits;
185733
+ delete preview.limits;
185734
+ return { topLevel, production };
185735
+ } else if (preview.limits && !production.limits) {
185736
+ delete topLevel.limits;
185737
+ return { topLevel, production, preview };
185738
+ }
185739
+ return { topLevel, production };
185740
+ }
185741
+ __name(simplifyEnvironments, "simplifyEnvironments");
185680
185742
  async function downloadProject(accountId, projectName) {
185681
185743
  const project = await fetchResult(
185682
185744
  `/accounts/${accountId}/pages/projects/${projectName}`
185683
185745
  );
185684
185746
  logger.debug(JSON.stringify(project, null, 2));
185747
+ const { topLevel, preview, production } = simplifyEnvironments(
185748
+ await toEnvironment(project.deployment_configs.preview, accountId),
185749
+ await toEnvironment(project.deployment_configs.production, accountId)
185750
+ );
185685
185751
  return {
185686
185752
  name: project.name,
185687
185753
  pages_build_output_dir: project.build_config.destination_dir,
185688
- ...await toEnvironment(project.deployment_configs.preview, accountId),
185689
- env: {
185690
- production: await toEnvironment(
185691
- project.deployment_configs.production,
185692
- accountId
185693
- )
185754
+ ...topLevel,
185755
+ ...{
185756
+ env: preview ? {
185757
+ preview,
185758
+ production
185759
+ } : {
185760
+ production
185761
+ }
185694
185762
  }
185695
185763
  };
185696
185764
  }
@@ -187455,7 +187523,7 @@ var MAX_UPLOAD_SIZE = 300 * 1024 * 1024;
187455
187523
 
187456
187524
  // src/r2/helpers.ts
187457
187525
  init_import_meta_url();
187458
- var import_miniflare11 = require("miniflare");
187526
+ var import_miniflare12 = require("miniflare");
187459
187527
  async function listR2Buckets(accountId, jurisdiction) {
187460
187528
  const headers = {};
187461
187529
  if (jurisdiction !== void 0) {
@@ -187582,7 +187650,7 @@ __name(deleteR2Object, "deleteR2Object");
187582
187650
  async function usingLocalBucket(persistTo, configPath, bucketName, closure) {
187583
187651
  const persist = getLocalPersistencePath(persistTo, configPath);
187584
187652
  const persistOptions = buildPersistOptions(persist);
187585
- const mf = new import_miniflare11.Miniflare({
187653
+ const mf = new import_miniflare12.Miniflare({
187586
187654
  modules: true,
187587
187655
  // TODO(soon): import `reduceError()` from `miniflare:shared`
187588
187656
  script: `
@@ -204708,7 +204776,7 @@ var import_node_http3 = require("node:http");
204708
204776
  var import_node_http22 = require("node:http2");
204709
204777
  var import_node_https = __toESM(require("node:https"));
204710
204778
  var import_http_terminator2 = __toESM(require_src5());
204711
- var import_miniflare14 = require("miniflare");
204779
+ var import_miniflare15 = require("miniflare");
204712
204780
  var import_react2 = __toESM(require_react());
204713
204781
  var import_serve_static = __toESM(require_serve_static());
204714
204782
 
@@ -204716,7 +204784,7 @@ var import_serve_static = __toESM(require_serve_static());
204716
204784
  init_import_meta_url();
204717
204785
  var fs25 = __toESM(require("node:fs"));
204718
204786
  var path61 = __toESM(require("node:path"));
204719
- var import_miniflare13 = require("miniflare");
204787
+ var import_miniflare14 = require("miniflare");
204720
204788
  var CERT_EXPIRY_DAYS = 30;
204721
204789
  var ONE_DAY_IN_MS = 864e5;
204722
204790
  function getHttpsOptions(customHttpsKeyPath, customHttpsCertPath) {
@@ -204810,7 +204878,7 @@ function generateCertificate() {
204810
204878
  name: "subjectAltName",
204811
204879
  altNames: [
204812
204880
  { type: 2, value: "localhost" },
204813
- ...(0, import_miniflare13.getAccessibleHosts)(false).map((ip2) => ({ type: 7, ip: ip2 }))
204881
+ ...(0, import_miniflare14.getAccessibleHosts)(false).map((ip2) => ({ type: 7, ip: ip2 }))
204814
204882
  ]
204815
204883
  }
204816
204884
  ]
@@ -204921,7 +204989,7 @@ async function startPreviewServer({
204921
204989
  logger.log(`\u2B23 Listening at ${localProtocol}://${ip2}:${usedPort}`);
204922
204990
  const accessibleHosts = [];
204923
204991
  if (ip2 === "::" || ip2 === "*" || ip2 === "0.0.0.0") {
204924
- accessibleHosts.push(...(0, import_miniflare14.getAccessibleHosts)(true));
204992
+ accessibleHosts.push(...(0, import_miniflare15.getAccessibleHosts)(true));
204925
204993
  if (ip2 !== "0.0.0.0") {
204926
204994
  accessibleHosts.push("localhost");
204927
204995
  accessibleHosts.push("[::1]");
@@ -206748,7 +206816,7 @@ init_import_meta_url();
206748
206816
  // src/cli-hotkeys.ts
206749
206817
  init_import_meta_url();
206750
206818
  var import_readline2 = __toESM(require("readline"));
206751
- var import_miniflare15 = require("miniflare");
206819
+ var import_miniflare16 = require("miniflare");
206752
206820
 
206753
206821
  // src/utils/onKeyPress.ts
206754
206822
  init_import_meta_url();
@@ -206828,16 +206896,16 @@ function cli_hotkeys_default(options29) {
206828
206896
  __name(printInstructions, "printInstructions");
206829
206897
  Logger.registerBeforeLogHook(clearPreviousInstructions);
206830
206898
  Logger.registerAfterLogHook(printInstructions);
206831
- import_miniflare15.Log.unstable_registerBeforeLogHook(clearPreviousInstructions);
206832
- import_miniflare15.Log.unstable_registerAfterLogHook(printInstructions);
206899
+ import_miniflare16.Log.unstable_registerBeforeLogHook(clearPreviousInstructions);
206900
+ import_miniflare16.Log.unstable_registerAfterLogHook(printInstructions);
206833
206901
  printInstructions();
206834
206902
  return () => {
206835
206903
  unregisterKeyPress();
206836
206904
  clearPreviousInstructions();
206837
206905
  Logger.registerBeforeLogHook(void 0);
206838
206906
  Logger.registerAfterLogHook(void 0);
206839
- import_miniflare15.Log.unstable_registerBeforeLogHook(void 0);
206840
- import_miniflare15.Log.unstable_registerAfterLogHook(void 0);
206907
+ import_miniflare16.Log.unstable_registerBeforeLogHook(void 0);
206908
+ import_miniflare16.Log.unstable_registerAfterLogHook(void 0);
206841
206909
  };
206842
206910
  }
206843
206911
  __name(cli_hotkeys_default, "default");
@@ -209246,7 +209314,7 @@ __name(ConfigController, "ConfigController");
209246
209314
  init_import_meta_url();
209247
209315
  var import_node_crypto8 = require("node:crypto");
209248
209316
  var import_promises24 = require("node:fs/promises");
209249
- var import_miniflare17 = require("miniflare");
209317
+ var import_miniflare18 = require("miniflare");
209250
209318
  async function getBinaryFileContents2(file) {
209251
209319
  if ("contents" in file) {
209252
209320
  if (file.contents instanceof Buffer) {
@@ -209356,7 +209424,7 @@ var LocalRuntimeController = class extends RuntimeController {
209356
209424
  // `buildMiniflareOptions()` is asynchronous, meaning if multiple bundle
209357
209425
  // updates were submitted, the second may apply before the first. Therefore,
209358
209426
  // wrap updates in a mutex, so they're always applied in invocation order.
209359
- #mutex = new import_miniflare17.Mutex();
209427
+ #mutex = new import_miniflare18.Mutex();
209360
209428
  #mf;
209361
209429
  onBundleStart(_3) {
209362
209430
  }
@@ -209369,7 +209437,7 @@ var LocalRuntimeController = class extends RuntimeController {
209369
209437
  );
209370
209438
  if (this.#mf === void 0) {
209371
209439
  logger.log(source_default.dim("\u2394 Starting local server..."));
209372
- this.#mf = new import_miniflare17.Miniflare(options29);
209440
+ this.#mf = new import_miniflare18.Miniflare(options29);
209373
209441
  } else {
209374
209442
  logger.log(source_default.dim("\u2394 Reloading local server..."));
209375
209443
  await this.#mf.setOptions(options29);
@@ -209470,7 +209538,7 @@ var import_node_assert23 = __toESM(require("node:assert"));
209470
209538
  var import_node_crypto9 = require("node:crypto");
209471
209539
  var import_node_events4 = __toESM(require("node:events"));
209472
209540
  var import_node_path65 = __toESM(require("node:path"));
209473
- var import_miniflare18 = require("miniflare");
209541
+ var import_miniflare19 = require("miniflare");
209474
209542
 
209475
209543
  // embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/wrangler/templates/startDevWorker/InspectorProxyWorker.ts
209476
209544
  init_import_meta_url();
@@ -209525,7 +209593,7 @@ var ProxyController = class extends Controller {
209525
209593
  PROXY_CONTROLLER: async (req) => {
209526
209594
  const message = await req.json();
209527
209595
  this.onProxyWorkerMessage(message);
209528
- return new import_miniflare18.Response(null, { status: 204 });
209596
+ return new import_miniflare19.Response(null, { status: 204 });
209529
209597
  }
209530
209598
  },
209531
209599
  bindings: {
@@ -209582,7 +209650,7 @@ var ProxyController = class extends Controller {
209582
209650
  proxyWorkerOptions
209583
209651
  );
209584
209652
  const willInstantiateMiniflareInstance = !this.proxyWorker || proxyWorkerOptionsChanged;
209585
- this.proxyWorker ??= new import_miniflare18.Miniflare(proxyWorkerOptions);
209653
+ this.proxyWorker ??= new import_miniflare19.Miniflare(proxyWorkerOptions);
209586
209654
  this.proxyWorkerOptions = proxyWorkerOptions;
209587
209655
  if (proxyWorkerOptionsChanged) {
209588
209656
  logger.debug("ProxyWorker miniflare options changed, reinstantiating...");
@@ -209655,7 +209723,7 @@ var ProxyController = class extends Controller {
209655
209723
  this.inspectorProxyWorkerWebSocket?.resolve(webSocket);
209656
209724
  return webSocket;
209657
209725
  }
209658
- runtimeMessageMutex = new import_miniflare18.Mutex();
209726
+ runtimeMessageMutex = new import_miniflare19.Mutex();
209659
209727
  async sendMessageToProxyWorker(message, retries = 3) {
209660
209728
  if (this._torndown) {
209661
209729
  return;
@@ -209810,15 +209878,15 @@ var ProxyController = class extends Controller {
209810
209878
  );
209811
209879
  }
209812
209880
  if (maybeContents === void 0) {
209813
- return new import_miniflare18.Response(null, { status: 404 });
209881
+ return new import_miniflare19.Response(null, { status: 404 });
209814
209882
  }
209815
- return new import_miniflare18.Response(maybeContents);
209883
+ return new import_miniflare19.Response(maybeContents);
209816
209884
  }
209817
209885
  default:
209818
209886
  assertNever(message);
209819
- return new import_miniflare18.Response(null, { status: 404 });
209887
+ return new import_miniflare19.Response(null, { status: 404 });
209820
209888
  }
209821
- return new import_miniflare18.Response(null, { status: 204 });
209889
+ return new import_miniflare19.Response(null, { status: 204 });
209822
209890
  }
209823
209891
  _torndown = false;
209824
209892
  async teardown() {
@@ -209871,7 +209939,7 @@ var ProxyController = class extends Controller {
209871
209939
  __name(ProxyController, "ProxyController");
209872
209940
  var ProxyControllerLogger = class extends WranglerLog {
209873
209941
  log(message) {
209874
- if (message.includes("/cdn-cgi/") && this.level < import_miniflare18.LogLevel.DEBUG) {
209942
+ if (message.includes("/cdn-cgi/") && this.level < import_miniflare19.LogLevel.DEBUG) {
209875
209943
  return;
209876
209944
  }
209877
209945
  super.log(message);
@@ -209892,7 +209960,7 @@ __name(didMiniflareOptionsChange, "didMiniflareOptionsChange");
209892
209960
 
209893
209961
  // src/api/startDevWorker/RemoteRuntimeController.ts
209894
209962
  init_import_meta_url();
209895
- var import_miniflare20 = require("miniflare");
209963
+ var import_miniflare21 = require("miniflare");
209896
209964
 
209897
209965
  // src/api/startDevWorker/NotImplementedError.ts
209898
209966
  init_import_meta_url();
@@ -209918,7 +209986,7 @@ __name(notImplemented, "notImplemented");
209918
209986
  var RemoteRuntimeController = class extends RuntimeController {
209919
209987
  #abortController = new AbortController();
209920
209988
  #currentBundleId = 0;
209921
- #mutex = new import_miniflare20.Mutex();
209989
+ #mutex = new import_miniflare21.Mutex();
209922
209990
  #session;
209923
209991
  async #previewSession(props) {
209924
209992
  try {
@@ -210299,7 +210367,7 @@ init_import_meta_url();
210299
210367
 
210300
210368
  // src/api/integrations/platform/index.ts
210301
210369
  init_import_meta_url();
210302
- var import_miniflare22 = require("miniflare");
210370
+ var import_miniflare23 = require("miniflare");
210303
210371
 
210304
210372
  // src/api/integrations/platform/caches.ts
210305
210373
  init_import_meta_url();
@@ -210346,15 +210414,21 @@ init_import_meta_url();
210346
210414
  var ExecutionContext = class {
210347
210415
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, unused-imports/no-unused-vars
210348
210416
  waitUntil(promise) {
210417
+ if (!(this instanceof ExecutionContext)) {
210418
+ throw new Error("Illegal invocation");
210419
+ }
210349
210420
  }
210350
210421
  passThroughOnException() {
210422
+ if (!(this instanceof ExecutionContext)) {
210423
+ throw new Error("Illegal invocation");
210424
+ }
210351
210425
  }
210352
210426
  };
210353
210427
  __name(ExecutionContext, "ExecutionContext");
210354
210428
 
210355
210429
  // src/api/integrations/platform/services.ts
210356
210430
  init_import_meta_url();
210357
- var import_miniflare21 = require("miniflare");
210431
+ var import_miniflare22 = require("miniflare");
210358
210432
  var import_undici27 = __toESM(require_undici());
210359
210433
  async function getServiceBindings(services = []) {
210360
210434
  if (services.length === 0) {
@@ -210406,9 +210480,9 @@ function getServiceBindingProxyFetch({
210406
210480
  try {
210407
210481
  const resp = await (0, import_undici27.fetch)(newUrl, request3);
210408
210482
  const respBody = await resp.arrayBuffer();
210409
- return new import_miniflare21.Response(respBody, resp);
210483
+ return new import_miniflare22.Response(respBody, resp);
210410
210484
  } catch {
210411
- return new import_miniflare21.Response(
210485
+ return new import_miniflare22.Response(
210412
210486
  `Error: Unable to fetch from external service (${serviceName} bound with ${bindingName} binding), please make sure that the service is still running with \`wrangler dev\``,
210413
210487
  { status: 500 }
210414
210488
  );
@@ -210440,7 +210514,7 @@ async function getPlatformProxy(options29 = {}) {
210440
210514
  },
210441
210515
  () => getMiniflareOptionsFromConfig(rawConfig, env7, options29)
210442
210516
  );
210443
- const mf = new import_miniflare22.Miniflare({
210517
+ const mf = new import_miniflare23.Miniflare({
210444
210518
  script: "",
210445
210519
  modules: true,
210446
210520
  ...miniflareOptions
@@ -210546,7 +210620,7 @@ function unstable_getMiniflareWorkerOptions(configPath, env7) {
210546
210620
  if (bindings.services !== void 0) {
210547
210621
  bindingOptions.serviceBindings = Object.fromEntries(
210548
210622
  bindings.services.map((binding) => {
210549
- const name = binding.service === config.name ? import_miniflare22.kCurrentWorker : binding.service;
210623
+ const name = binding.service === config.name ? import_miniflare23.kCurrentWorker : binding.service;
210550
210624
  return [binding.binding, { name, entrypoint: binding.entrypoint }];
210551
210625
  })
210552
210626
  );
@@ -211242,3 +211316,4 @@ yargs-parser/build/lib/index.js:
211242
211316
  * SPDX-License-Identifier: ISC
211243
211317
  *)
211244
211318
  */
211319
+ //# sourceMappingURL=cli.js.map