wrangler 4.24.2 → 4.24.3

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.
@@ -22064,29 +22064,46 @@ async function constructBuildCommand(options, configPath, logger4) {
22064
22064
  }
22065
22065
  function dockerBuild(dockerPath, options) {
22066
22066
  let errorHandled = false;
22067
- return new Promise((resolve24, reject) => {
22068
- const child = (0, import_child_process.spawn)(dockerPath, options.buildCmd, {
22069
- stdio: ["pipe", "inherit", "inherit"]
22070
- });
22071
- if (child.stdin !== null) {
22072
- child.stdin.write(options.dockerfile);
22073
- child.stdin.end();
22067
+ let resolve24;
22068
+ let reject;
22069
+ const ready = new Promise((res, rej) => {
22070
+ resolve24 = res;
22071
+ reject = rej;
22072
+ });
22073
+ const child = (0, import_child_process.spawn)(dockerPath, options.buildCmd, {
22074
+ stdio: ["pipe", "inherit", "inherit"],
22075
+ // We need to set detached to true so that the child process
22076
+ // will control all of its child processed and we can kill
22077
+ // all of them in case we need to abort the build process
22078
+ detached: true
22079
+ });
22080
+ if (child.stdin !== null) {
22081
+ child.stdin.write(options.dockerfile);
22082
+ child.stdin.end();
22083
+ }
22084
+ child.on("exit", (code) => {
22085
+ if (code === 0) {
22086
+ resolve24();
22087
+ } else if (!errorHandled) {
22088
+ errorHandled = true;
22089
+ reject(new Error(`Build exited with code: ${code}`));
22074
22090
  }
22075
- child.on("exit", (code) => {
22076
- if (code === 0) {
22077
- resolve24();
22078
- } else if (!errorHandled) {
22079
- errorHandled = true;
22080
- reject(new Error(`Build exited with code: ${code}`));
22081
- }
22082
- });
22083
- child.on("error", (err) => {
22084
- if (!errorHandled) {
22085
- errorHandled = true;
22086
- reject(err);
22087
- }
22088
- });
22089
22091
  });
22092
+ child.on("error", (err) => {
22093
+ if (!errorHandled) {
22094
+ errorHandled = true;
22095
+ reject(err);
22096
+ }
22097
+ });
22098
+ return {
22099
+ abort: /* @__PURE__ */ __name(() => {
22100
+ child.unref();
22101
+ if (child.pid !== void 0) {
22102
+ process.kill(-child.pid);
22103
+ }
22104
+ }, "abort"),
22105
+ ready
22106
+ };
22090
22107
  }
22091
22108
  async function buildImage(dockerPath, options, configPath) {
22092
22109
  const { buildCmd, dockerfile } = await constructBuildCommand(
@@ -22099,7 +22116,7 @@ async function buildImage(dockerPath, options, configPath) {
22099
22116
  },
22100
22117
  configPath
22101
22118
  );
22102
- await dockerBuild(dockerPath, { buildCmd, dockerfile });
22119
+ return dockerBuild(dockerPath, { buildCmd, dockerfile });
22103
22120
  }
22104
22121
  var import_child_process, import_fs5, import_path5;
22105
22122
  var init_build = __esm({
@@ -22256,27 +22273,47 @@ var init_utils = __esm({
22256
22273
  import_fs6 = require("fs");
22257
22274
  import_path6 = __toESM(require("path"));
22258
22275
  init_inspect();
22259
- runDockerCmd = /* @__PURE__ */ __name(async (dockerPath, args, stdio) => {
22276
+ runDockerCmd = /* @__PURE__ */ __name((dockerPath, args, stdio) => {
22277
+ let aborted = false;
22278
+ let resolve24;
22279
+ let reject;
22280
+ const ready = new Promise((res, rej) => {
22281
+ resolve24 = res;
22282
+ reject = rej;
22283
+ });
22260
22284
  const child = (0, import_child_process3.spawn)(dockerPath, args, {
22261
- stdio: stdio ?? "inherit"
22285
+ stdio: stdio ?? "inherit",
22286
+ // We need to set detached to true so that the child process
22287
+ // will control all of its child processed and we can kill
22288
+ // all of them in case we need to abort the build process
22289
+ detached: true
22262
22290
  });
22263
22291
  let errorHandled = false;
22264
- await new Promise((resolve24, reject) => {
22265
- child.on("close", (code) => {
22266
- if (code === 0) {
22267
- resolve24();
22268
- } else if (!errorHandled) {
22269
- errorHandled = true;
22270
- reject(new Error(`Docker command exited with code: ${code}`));
22271
- }
22272
- });
22273
- child.on("error", (err) => {
22274
- if (!errorHandled) {
22275
- errorHandled = true;
22276
- reject(new Error(`Docker command failed: ${err.message}`));
22277
- }
22278
- });
22292
+ child.on("close", (code) => {
22293
+ if (code === 0 || aborted) {
22294
+ resolve24({ aborted });
22295
+ } else if (!errorHandled) {
22296
+ errorHandled = true;
22297
+ reject(new Error(`Docker command exited with code: ${code}`));
22298
+ }
22299
+ });
22300
+ child.on("error", (err) => {
22301
+ if (!errorHandled) {
22302
+ errorHandled = true;
22303
+ reject(new Error(`Docker command failed: ${err.message}`));
22304
+ }
22279
22305
  });
22306
+ return {
22307
+ abort: /* @__PURE__ */ __name(() => {
22308
+ aborted = true;
22309
+ child.unref();
22310
+ if (child.pid !== void 0) {
22311
+ process.kill(-child.pid);
22312
+ }
22313
+ }, "abort"),
22314
+ ready,
22315
+ then: /* @__PURE__ */ __name(async (resolve25, reject2) => ready.then(resolve25).catch(reject2), "then")
22316
+ };
22280
22317
  }, "runDockerCmd");
22281
22318
  runDockerCmdWithOutput = /* @__PURE__ */ __name(async (dockerPath, args) => {
22282
22319
  return new Promise((resolve24, reject) => {
@@ -22383,16 +22420,27 @@ var init_types = __esm({
22383
22420
  // ../containers-shared/src/images.ts
22384
22421
  async function pullImage(dockerPath, options) {
22385
22422
  await dockerLoginManagedRegistry(dockerPath);
22386
- await runDockerCmd(dockerPath, [
22423
+ const pull = runDockerCmd(dockerPath, [
22387
22424
  "pull",
22388
22425
  options.image,
22389
22426
  // All containers running on our platform need to be built for amd64 architecture, but by default docker pull seems to look for an image matching the host system, so we need to specify this here
22390
22427
  "--platform",
22391
22428
  "linux/amd64"
22392
22429
  ]);
22393
- await runDockerCmd(dockerPath, ["tag", options.image, options.imageTag]);
22430
+ const ready = pull.ready.then(async ({ aborted }) => {
22431
+ if (!aborted) {
22432
+ await runDockerCmd(dockerPath, ["tag", options.image, options.imageTag]);
22433
+ }
22434
+ });
22435
+ return {
22436
+ abort: /* @__PURE__ */ __name(() => {
22437
+ pull.abort();
22438
+ }, "abort"),
22439
+ ready
22440
+ };
22394
22441
  }
22395
- async function prepareContainerImagesForDev(dockerPath, containerOptions, configPath) {
22442
+ async function prepareContainerImagesForDev(dockerPath, containerOptions, configPath, onContainerImagePreparationStart, onContainerImagePreparationEnd) {
22443
+ let aborted = false;
22396
22444
  if (process.platform === "win32") {
22397
22445
  throw new Error(
22398
22446
  "Local development with containers is currently not supported on Windows. You should use WSL instead. You can also set `enable_containers` to false if you do not need to develop the container part of your application."
@@ -22401,7 +22449,18 @@ async function prepareContainerImagesForDev(dockerPath, containerOptions, config
22401
22449
  await verifyDockerInstalled(dockerPath);
22402
22450
  for (const options of containerOptions) {
22403
22451
  if (isDockerfile(options.image, configPath)) {
22404
- await buildImage(dockerPath, options, configPath);
22452
+ const build5 = await buildImage(dockerPath, options, configPath);
22453
+ onContainerImagePreparationStart({
22454
+ containerOptions: options,
22455
+ abort: /* @__PURE__ */ __name(() => {
22456
+ aborted = true;
22457
+ build5.abort();
22458
+ }, "abort")
22459
+ });
22460
+ await build5.ready;
22461
+ onContainerImagePreparationEnd({
22462
+ containerOptions: options
22463
+ });
22405
22464
  } else {
22406
22465
  if (!isCloudflareRegistryLink(options.image)) {
22407
22466
  throw new Error(
@@ -22409,12 +22468,25 @@ async function prepareContainerImagesForDev(dockerPath, containerOptions, config
22409
22468
  To use an existing image from another repository, see https://developers.cloudflare.com/containers/image-management/#using-existing-images`
22410
22469
  );
22411
22470
  }
22412
- await pullImage(dockerPath, options);
22471
+ const pull = await pullImage(dockerPath, options);
22472
+ onContainerImagePreparationStart({
22473
+ containerOptions: options,
22474
+ abort: /* @__PURE__ */ __name(() => {
22475
+ aborted = true;
22476
+ pull.abort();
22477
+ }, "abort")
22478
+ });
22479
+ await pull.ready;
22480
+ onContainerImagePreparationEnd({
22481
+ containerOptions: options
22482
+ });
22483
+ }
22484
+ if (!aborted) {
22485
+ await checkExposedPorts(dockerPath, options);
22413
22486
  }
22414
- await checkExposedPorts(dockerPath, options);
22415
22487
  }
22416
22488
  }
22417
- async function resolveImageName(accountId, image) {
22489
+ function resolveImageName(accountId, image) {
22418
22490
  let url4;
22419
22491
  try {
22420
22492
  url4 = new URL(`http://${image}`);
@@ -29515,7 +29587,7 @@ var name, version;
29515
29587
  var init_package = __esm({
29516
29588
  "package.json"() {
29517
29589
  name = "wrangler";
29518
- version = "4.24.2";
29590
+ version = "4.24.3";
29519
29591
  }
29520
29592
  });
29521
29593
 
@@ -60406,38 +60478,7 @@ var init_navigator_user_agent = __esm({
60406
60478
  }
60407
60479
  });
60408
60480
 
60409
- // src/pages/utils.ts
60410
- function isUrl(maybeUrl) {
60411
- if (!maybeUrl) {
60412
- return false;
60413
- }
60414
- try {
60415
- new URL(maybeUrl);
60416
- return true;
60417
- } catch (e7) {
60418
- return false;
60419
- }
60420
- }
60421
- function getPagesProjectRoot() {
60422
- const cwd2 = process.cwd();
60423
- if (projectRootCache !== void 0 && projectRootCacheCwd === cwd2) {
60424
- return projectRootCache;
60425
- }
60426
- const packagePath = findUpSync("package.json");
60427
- projectRootCache = packagePath ? import_node_path23.default.dirname(packagePath) : process.cwd();
60428
- projectRootCacheCwd = cwd2;
60429
- return projectRootCache;
60430
- }
60431
- function getPagesTmpDir() {
60432
- const projectRoot = getPagesProjectRoot();
60433
- if (tmpDirCache !== void 0 && tmpDirCacheProjectRoot === projectRoot) {
60434
- return tmpDirCache;
60435
- }
60436
- const tmpDir = getWranglerTmpDir(getPagesProjectRoot(), "pages");
60437
- tmpDirCache = tmpDir.path;
60438
- tmpDirCacheProjectRoot = projectRoot;
60439
- return tmpDirCache;
60440
- }
60481
+ // src/utils/debounce.ts
60441
60482
  function debounce(fn2, delayMs = 100) {
60442
60483
  let crrTimeoutId;
60443
60484
  return () => {
@@ -60449,22 +60490,9 @@ function debounce(fn2, delayMs = 100) {
60449
60490
  }, delayMs);
60450
60491
  };
60451
60492
  }
60452
- var import_node_path23, RUNNING_BUILDERS, CLEANUP_CALLBACKS, CLEANUP, projectRootCacheCwd, projectRootCache, tmpDirCacheProjectRoot, tmpDirCache;
60453
- var init_utils3 = __esm({
60454
- "src/pages/utils.ts"() {
60493
+ var init_debounce = __esm({
60494
+ "src/utils/debounce.ts"() {
60455
60495
  init_import_meta_url();
60456
- import_node_path23 = __toESM(require("path"));
60457
- init_find_up();
60458
- init_paths();
60459
- RUNNING_BUILDERS = [];
60460
- CLEANUP_CALLBACKS = [];
60461
- CLEANUP = /* @__PURE__ */ __name(() => {
60462
- CLEANUP_CALLBACKS.forEach((callback) => callback());
60463
- RUNNING_BUILDERS.forEach((builder) => builder.stop?.());
60464
- }, "CLEANUP");
60465
- __name(isUrl, "isUrl");
60466
- __name(getPagesProjectRoot, "getPagesProjectRoot");
60467
- __name(getPagesTmpDir, "getPagesTmpDir");
60468
60496
  __name(debounce, "debounce");
60469
60497
  }
60470
60498
  });
@@ -60487,8 +60515,8 @@ var init_BundlerController = __esm({
60487
60515
  init_use_esbuild();
60488
60516
  init_logger();
60489
60517
  init_navigator_user_agent();
60490
- init_utils3();
60491
60518
  init_paths();
60519
+ init_debounce();
60492
60520
  init_BaseController();
60493
60521
  init_events();
60494
60522
  init_utils2();
@@ -62729,7 +62757,7 @@ async function buildAndMaybePush(args, pathToDocker, push, configPath, container
62729
62757
  await dockerBuild(pathToDocker, {
62730
62758
  buildCmd,
62731
62759
  dockerfile
62732
- });
62760
+ }).ready;
62733
62761
  const inspectOutput = await dockerImageInspect(pathToDocker, {
62734
62762
  imageTag,
62735
62763
  formatString: "{{ .Size }} {{ len .RootFS.Layers }} {{json .RepoDigests}}"
@@ -63791,9 +63819,12 @@ function createApplicationToModifyApplication(req) {
63791
63819
  scheduling_policy: req.scheduling_policy
63792
63820
  };
63793
63821
  }
63794
- function applicationToCreateApplication(application) {
63822
+ function applicationToCreateApplication(accountId, application) {
63795
63823
  const app = {
63796
- configuration: application.configuration,
63824
+ configuration: {
63825
+ ...application.configuration,
63826
+ image: resolveImageName(accountId, application.configuration.image)
63827
+ },
63797
63828
  constraints: application.constraints,
63798
63829
  max_instances: application.max_instances,
63799
63830
  name: application.name,
@@ -63835,7 +63866,7 @@ function containerAppToInstanceType(containerApp) {
63835
63866
  return "dev" /* DEV */;
63836
63867
  }
63837
63868
  }
63838
- function containerAppToCreateApplication(containerApp, observability, existingApp, skipDefaults = false) {
63869
+ function containerAppToCreateApplication(accountId, containerApp, observability, existingApp, skipDefaults = false) {
63839
63870
  const observabilityConfiguration = observabilityToConfiguration(
63840
63871
  observability,
63841
63872
  existingApp?.configuration.observability
@@ -63854,7 +63885,11 @@ function containerAppToCreateApplication(containerApp, observability, existingAp
63854
63885
  const app = {
63855
63886
  ...containerApp,
63856
63887
  name: containerApp.name,
63857
- configuration,
63888
+ configuration: {
63889
+ ...configuration,
63890
+ // De-sugar image name
63891
+ image: resolveImageName(accountId, configuration.image)
63892
+ },
63858
63893
  instances: containerApp.instances ?? 0,
63859
63894
  scheduling_policy: containerApp.scheduling_policy ?? "default" /* DEFAULT */,
63860
63895
  constraints: {
@@ -64049,7 +64084,9 @@ async function apply(args, config) {
64049
64084
  appConfigNoDefaults.configuration ??= {};
64050
64085
  appConfigNoDefaults.configuration.image = application.configuration.image;
64051
64086
  }
64087
+ const accountId = config.account_id || await getAccountId(config);
64052
64088
  const appConfig = containerAppToCreateApplication(
64089
+ accountId,
64053
64090
  appConfigNoDefaults,
64054
64091
  config.observability,
64055
64092
  application,
@@ -64057,7 +64094,7 @@ async function apply(args, config) {
64057
64094
  );
64058
64095
  if (application !== void 0 && application !== null) {
64059
64096
  const prevApp = sortObjectRecursive(
64060
- stripUndefined(applicationToCreateApplication(application))
64097
+ stripUndefined(applicationToCreateApplication(accountId, application))
64061
64098
  );
64062
64099
  if (appConfigNoDefaults.scheduling_policy === void 0) {
64063
64100
  appConfig.scheduling_policy = prevApp.scheduling_policy;
@@ -64179,16 +64216,7 @@ async function apply(args, config) {
64179
64216
  s5.split("\n").map((line) => line.trim()).forEach((el) => {
64180
64217
  printLine(el, " ");
64181
64218
  });
64182
- const accountId = config.account_id || await getAccountId(config);
64183
- const configToPush = {
64184
- ...appConfig,
64185
- configuration: {
64186
- ...appConfig.configuration,
64187
- // De-sugar image name. We do it here so that the user
64188
- // sees the simplified image name in diffs.
64189
- image: await resolveImageName(accountId, appConfig.configuration.image)
64190
- }
64191
- };
64219
+ const configToPush = { ...appConfig };
64192
64220
  actions.push({
64193
64221
  action: "create",
64194
64222
  application: configToPush
@@ -64697,7 +64725,7 @@ function getDatabaseInfoFromConfig(config, name2) {
64697
64725
  return null;
64698
64726
  }
64699
64727
  var getDatabaseByNameOrBinding, getDatabaseInfoFromIdOrName;
64700
- var init_utils4 = __esm({
64728
+ var init_utils3 = __esm({
64701
64729
  "src/d1/utils.ts"() {
64702
64730
  init_import_meta_url();
64703
64731
  init_cfetch();
@@ -65207,7 +65235,7 @@ function getMetricsConfig({
65207
65235
  return { enabled: true, deviceId };
65208
65236
  }
65209
65237
  function writeMetricsConfig(config) {
65210
- (0, import_node_fs12.mkdirSync)(import_node_path24.default.dirname(getMetricsConfigPath()), { recursive: true });
65238
+ (0, import_node_fs12.mkdirSync)(import_node_path23.default.dirname(getMetricsConfigPath()), { recursive: true });
65211
65239
  (0, import_node_fs12.writeFileSync)(
65212
65240
  getMetricsConfigPath(),
65213
65241
  JSON.stringify(
@@ -65237,7 +65265,7 @@ function updateMetricsPermission(enabled) {
65237
65265
  writeMetricsConfig(config);
65238
65266
  }
65239
65267
  function getMetricsConfigPath() {
65240
- return import_node_path24.default.resolve(getGlobalWranglerConfigPath(), "metrics.json");
65268
+ return import_node_path23.default.resolve(getGlobalWranglerConfigPath(), "metrics.json");
65241
65269
  }
65242
65270
  function getDeviceId(config) {
65243
65271
  const deviceId = config.deviceId ?? (0, import_node_crypto5.randomUUID)();
@@ -65246,13 +65274,13 @@ function getDeviceId(config) {
65246
65274
  }
65247
65275
  return deviceId;
65248
65276
  }
65249
- var import_node_crypto5, import_node_fs12, import_node_path24, CURRENT_METRICS_DATE;
65277
+ var import_node_crypto5, import_node_fs12, import_node_path23, CURRENT_METRICS_DATE;
65250
65278
  var init_metrics_config = __esm({
65251
65279
  "src/metrics/metrics-config.ts"() {
65252
65280
  init_import_meta_url();
65253
65281
  import_node_crypto5 = require("crypto");
65254
65282
  import_node_fs12 = require("fs");
65255
- import_node_path24 = __toESM(require("path"));
65283
+ import_node_path23 = __toESM(require("path"));
65256
65284
  init_misc_variables();
65257
65285
  init_global_wrangler_config_path();
65258
65286
  init_logger();
@@ -65773,7 +65801,7 @@ var init_bindings = __esm({
65773
65801
  init_cfetch();
65774
65802
  init_create();
65775
65803
  init_list();
65776
- init_utils4();
65804
+ init_utils3();
65777
65805
  init_dialogs();
65778
65806
  init_errors();
65779
65807
  init_helpers4();
@@ -66229,18 +66257,18 @@ var require_command_exists2 = __commonJS({
66229
66257
  // src/deployment-bundle/capnp.ts
66230
66258
  function handleUnsafeCapnp(capnp) {
66231
66259
  if (capnp.compiled_schema) {
66232
- return (0, import_node_fs13.readFileSync)((0, import_node_path25.resolve)(capnp.compiled_schema));
66260
+ return (0, import_node_fs13.readFileSync)((0, import_node_path24.resolve)(capnp.compiled_schema));
66233
66261
  }
66234
66262
  const { base_path, source_schemas } = capnp;
66235
66263
  const capnpSchemas = (source_schemas ?? []).map(
66236
- (x6) => (0, import_node_path25.resolve)(base_path, x6)
66264
+ (x6) => (0, import_node_path24.resolve)(base_path, x6)
66237
66265
  );
66238
66266
  if (!(0, import_command_exists.sync)("capnp")) {
66239
66267
  throw new UserError(
66240
66268
  "The capnp compiler is required to upload capnp schemas, but is not present."
66241
66269
  );
66242
66270
  }
66243
- const srcPrefix = (0, import_node_path25.resolve)(base_path ?? ".");
66271
+ const srcPrefix = (0, import_node_path24.resolve)(base_path ?? ".");
66244
66272
  const capnpProcess = (0, import_node_child_process3.spawnSync)("capnp", [
66245
66273
  "compile",
66246
66274
  "-o-",
@@ -66255,13 +66283,13 @@ function handleUnsafeCapnp(capnp) {
66255
66283
  }
66256
66284
  return capnpProcess.stdout;
66257
66285
  }
66258
- var import_node_child_process3, import_node_fs13, import_node_path25, import_command_exists;
66286
+ var import_node_child_process3, import_node_fs13, import_node_path24, import_command_exists;
66259
66287
  var init_capnp = __esm({
66260
66288
  "src/deployment-bundle/capnp.ts"() {
66261
66289
  init_import_meta_url();
66262
66290
  import_node_child_process3 = require("child_process");
66263
66291
  import_node_fs13 = require("fs");
66264
- import_node_path25 = require("path");
66292
+ import_node_path24 = require("path");
66265
66293
  import_command_exists = __toESM(require_command_exists2());
66266
66294
  init_errors();
66267
66295
  __name(handleUnsafeCapnp, "handleUnsafeCapnp");
@@ -66620,14 +66648,14 @@ function createWorkerUploadForm(worker) {
66620
66648
  if (hasManifest && main2.type === "esm") {
66621
66649
  (0, import_node_assert13.default)(modules !== void 0);
66622
66650
  const subDirs = new Set(
66623
- modules.map((module3) => import_node_path26.default.posix.dirname(module3.name))
66651
+ modules.map((module3) => import_node_path25.default.posix.dirname(module3.name))
66624
66652
  );
66625
66653
  for (const subDir of subDirs) {
66626
66654
  if (subDir === ".") {
66627
66655
  continue;
66628
66656
  }
66629
- const relativePath = import_node_path26.default.posix.relative(subDir, manifestModuleName);
66630
- const filePath = import_node_path26.default.posix.join(subDir, manifestModuleName);
66657
+ const relativePath = import_node_path25.default.posix.relative(subDir, manifestModuleName);
66658
+ const filePath = import_node_path25.default.posix.join(subDir, manifestModuleName);
66631
66659
  modules.push({
66632
66660
  name: filePath,
66633
66661
  filePath,
@@ -66744,13 +66772,13 @@ function createWorkerUploadForm(worker) {
66744
66772
  }
66745
66773
  return formData;
66746
66774
  }
66747
- var import_node_assert13, import_node_fs14, import_node_path26, import_undici6, moduleTypeMimeType;
66775
+ var import_node_assert13, import_node_fs14, import_node_path25, import_undici6, moduleTypeMimeType;
66748
66776
  var init_create_worker_upload_form = __esm({
66749
66777
  "src/deployment-bundle/create-worker-upload-form.ts"() {
66750
66778
  init_import_meta_url();
66751
66779
  import_node_assert13 = __toESM(require("assert"));
66752
66780
  import_node_fs14 = require("fs");
66753
- import_node_path26 = __toESM(require("path"));
66781
+ import_node_path25 = __toESM(require("path"));
66754
66782
  import_undici6 = __toESM(require_undici());
66755
66783
  init_errors();
66756
66784
  init_bindings();
@@ -66979,9 +67007,9 @@ async function* getFilesInFolder(dirPath) {
66979
67007
  continue;
66980
67008
  }
66981
67009
  if (file.isDirectory()) {
66982
- yield* await getFilesInFolder(path30.join(dirPath, file.name));
67010
+ yield* await getFilesInFolder(path29.join(dirPath, file.name));
66983
67011
  } else {
66984
- yield path30.join(dirPath, file.name);
67012
+ yield path29.join(dirPath, file.name);
66985
67013
  }
66986
67014
  }
66987
67015
  }
@@ -66989,11 +67017,11 @@ function hashFileContent(hasher, content) {
66989
67017
  return hasher.h64ToString(content).substring(0, 10);
66990
67018
  }
66991
67019
  function hashAsset(hasher, filePath, content) {
66992
- const extName = path30.extname(filePath) || "";
66993
- const baseName = path30.basename(filePath, extName);
66994
- const directory = path30.dirname(filePath);
67020
+ const extName = path29.extname(filePath) || "";
67021
+ const baseName = path29.basename(filePath, extName);
67022
+ const directory = path29.dirname(filePath);
66995
67023
  const hash = hashFileContent(hasher, content);
66996
- return urlSafe(path30.join(directory, `${baseName}.${hash}${extName}`));
67024
+ return urlSafe(path29.join(directory, `${baseName}.${hash}${extName}`));
66997
67025
  }
66998
67026
  async function createKVNamespaceIfNotAlreadyExisting(complianceConfig, title, accountId) {
66999
67027
  const namespaces = await listKVNamespaces(complianceConfig, accountId);
@@ -67034,7 +67062,7 @@ async function syncWorkersSite(complianceConfig, accountId, scriptName, siteAsse
67034
67062
  );
67035
67063
  const namespaceKeyInfoMap = new Map(namespaceKeysResponse.map((x6) => [x6.name, x6]));
67036
67064
  const namespaceKeys = new Set(namespaceKeysResponse.map((x6) => x6.name));
67037
- const assetDirectory = path30.join(
67065
+ const assetDirectory = path29.join(
67038
67066
  siteAssets.baseDirectory,
67039
67067
  siteAssets.assetDirectory
67040
67068
  );
@@ -67063,7 +67091,7 @@ async function syncWorkersSite(complianceConfig, accountId, scriptName, siteAsse
67063
67091
  __name(logDiff, "logDiff");
67064
67092
  logger.info("Building list of assets to upload...");
67065
67093
  for await (const absAssetFile of getFilesInFolder(assetDirectory)) {
67066
- const assetFile = path30.relative(assetDirectory, absAssetFile);
67094
+ const assetFile = path29.relative(assetDirectory, absAssetFile);
67067
67095
  if (!include(assetFile) || exclude2(assetFile)) {
67068
67096
  continue;
67069
67097
  }
@@ -67089,7 +67117,7 @@ async function syncWorkersSite(complianceConfig, accountId, scriptName, siteAsse
67089
67117
  skipCount++;
67090
67118
  }
67091
67119
  namespaceKeys.delete(assetKey);
67092
- const manifestKey = urlSafe(path30.relative(assetDirectory, absAssetFile));
67120
+ const manifestKey = urlSafe(path29.relative(assetDirectory, absAssetFile));
67093
67121
  manifest[manifestKey] = assetKey;
67094
67122
  }
67095
67123
  if (uploadBucket.length > 0) {
@@ -67224,7 +67252,7 @@ function urlSafe(filePath) {
67224
67252
  return filePath.replace(/\\/g, "/");
67225
67253
  }
67226
67254
  function getSiteAssetPaths(config, assetDirectory, includePatterns = config.site?.include ?? [], excludePatterns = config.site?.exclude ?? []) {
67227
- const baseDirectory = assetDirectory ? process.cwd() : path30.resolve(path30.dirname(config.configPath ?? "wrangler.toml"));
67255
+ const baseDirectory = assetDirectory ? process.cwd() : path29.resolve(path29.dirname(config.configPath ?? "wrangler.toml"));
67228
67256
  assetDirectory ??= config.site?.bucket;
67229
67257
  if (assetDirectory) {
67230
67258
  return {
@@ -67237,13 +67265,13 @@ function getSiteAssetPaths(config, assetDirectory, includePatterns = config.site
67237
67265
  return void 0;
67238
67266
  }
67239
67267
  }
67240
- var import_node_assert15, import_promises9, path30, ALWAYS_IGNORE, HIDDEN_FILES_TO_INCLUDE, MAX_DIFF_LINES, MAX_BUCKET_SIZE2, MAX_BUCKET_KEYS, MAX_BATCH_OPERATIONS;
67268
+ var import_node_assert15, import_promises9, path29, ALWAYS_IGNORE, HIDDEN_FILES_TO_INCLUDE, MAX_DIFF_LINES, MAX_BUCKET_SIZE2, MAX_BUCKET_KEYS, MAX_BATCH_OPERATIONS;
67241
67269
  var init_sites = __esm({
67242
67270
  "src/sites.ts"() {
67243
67271
  init_import_meta_url();
67244
67272
  import_node_assert15 = __toESM(require("assert"));
67245
67273
  import_promises9 = require("fs/promises");
67246
- path30 = __toESM(require("path"));
67274
+ path29 = __toESM(require("path"));
67247
67275
  init_workers_shared();
67248
67276
  init_source();
67249
67277
  init_xxhash_wasm();
@@ -75008,7 +75036,7 @@ async function aiFinetuneList(complianceConfig, accountId) {
75008
75036
  return results;
75009
75037
  }
75010
75038
  var listCatalogEntries, listFinetuneEntries;
75011
- var init_utils5 = __esm({
75039
+ var init_utils4 = __esm({
75012
75040
  "src/ai/utils.ts"() {
75013
75041
  init_import_meta_url();
75014
75042
  init_cfetch();
@@ -75038,7 +75066,7 @@ var init_createFinetune = __esm({
75038
75066
  init_create_command();
75039
75067
  init_logger();
75040
75068
  init_user2();
75041
- init_utils5();
75069
+ init_utils4();
75042
75070
  requiredAssets = ["adapter_config.json", "adapter_model.safetensors"];
75043
75071
  aiFineTuneCreateCommand = createCommand({
75044
75072
  metadata: {
@@ -75149,7 +75177,7 @@ var init_listCatalog = __esm({
75149
75177
  init_create_command();
75150
75178
  init_logger();
75151
75179
  init_user2();
75152
- init_utils5();
75180
+ init_utils4();
75153
75181
  aiModelsCommand = createCommand({
75154
75182
  metadata: {
75155
75183
  description: "List catalog models",
@@ -75201,7 +75229,7 @@ var init_listFinetune = __esm({
75201
75229
  init_create_command();
75202
75230
  init_logger();
75203
75231
  init_user2();
75204
- init_utils5();
75232
+ init_utils4();
75205
75233
  aiFineTuneListCommand = createCommand({
75206
75234
  metadata: {
75207
75235
  description: "List your finetune files",
@@ -77978,7 +78006,7 @@ var init_delete2 = __esm({
77978
78006
  init_dialogs();
77979
78007
  init_logger();
77980
78008
  init_user2();
77981
- init_utils4();
78009
+ init_utils3();
77982
78010
  d1DeleteCommand = createCommand({
77983
78011
  metadata: {
77984
78012
  description: "Delete D1 database",
@@ -78286,7 +78314,7 @@ async function executeLocally({
78286
78314
  }
78287
78315
  const id = localDB.previewDatabaseUuid ?? localDB.uuid;
78288
78316
  const persistencePath = getLocalPersistencePath(persistTo, config);
78289
- const d1Persist = import_node_path27.default.join(persistencePath, "v3", "d1");
78317
+ const d1Persist = import_node_path26.default.join(persistencePath, "v3", "d1");
78290
78318
  logger.log(
78291
78319
  `\u{1F300} Executing on local database ${name2} (${id}) from ${readableRelative(
78292
78320
  d1Persist
@@ -78567,13 +78595,13 @@ async function checkForSQLiteBinary(filename) {
78567
78595
  );
78568
78596
  }
78569
78597
  }
78570
- var import_fs15, import_node_assert16, import_node_path27, import_md5_file, import_miniflare12, import_undici8, d1ExecuteCommand;
78598
+ var import_fs15, import_node_assert16, import_node_path26, import_md5_file, import_miniflare12, import_undici8, d1ExecuteCommand;
78571
78599
  var init_execute = __esm({
78572
78600
  "src/d1/execute.ts"() {
78573
78601
  init_import_meta_url();
78574
78602
  import_fs15 = require("fs");
78575
78603
  import_node_assert16 = __toESM(require("assert"));
78576
- import_node_path27 = __toESM(require("path"));
78604
+ import_node_path26 = __toESM(require("path"));
78577
78605
  init_interactive();
78578
78606
  init_source();
78579
78607
  import_md5_file = __toESM(require_md5_file());
@@ -78590,7 +78618,7 @@ var init_execute = __esm({
78590
78618
  init_paths();
78591
78619
  init_user2();
78592
78620
  init_splitter();
78593
- init_utils4();
78621
+ init_utils3();
78594
78622
  d1ExecuteCommand = createCommand({
78595
78623
  metadata: {
78596
78624
  description: "Execute a command or SQL file",
@@ -78743,7 +78771,7 @@ async function exportLocal(config, name2, output, tables, noSchema, noData) {
78743
78771
  }
78744
78772
  const id = localDB.previewDatabaseUuid ?? localDB.uuid;
78745
78773
  const persistencePath = getLocalPersistencePath(void 0, config);
78746
- const d1Persist = import_node_path28.default.join(persistencePath, "v3", "d1");
78774
+ const d1Persist = import_node_path27.default.join(persistencePath, "v3", "d1");
78747
78775
  logger.log(
78748
78776
  `\u{1F300} Exporting local database ${name2} (${id}) from ${readableRelative(
78749
78777
  d1Persist
@@ -78857,12 +78885,12 @@ async function pollExport(s5, complianceConfig, accountId, db, dumpOptions, curr
78857
78885
  );
78858
78886
  }
78859
78887
  }
78860
- var import_promises12, import_node_path28, import_miniflare13, import_undici9, d1ExportCommand;
78888
+ var import_promises12, import_node_path27, import_miniflare13, import_undici9, d1ExportCommand;
78861
78889
  var init_export = __esm({
78862
78890
  "src/d1/export.ts"() {
78863
78891
  init_import_meta_url();
78864
78892
  import_promises12 = __toESM(require("fs/promises"));
78865
- import_node_path28 = __toESM(require("path"));
78893
+ import_node_path27 = __toESM(require("path"));
78866
78894
  init_interactive();
78867
78895
  init_source();
78868
78896
  import_miniflare13 = require("miniflare");
@@ -78876,7 +78904,7 @@ var init_export = __esm({
78876
78904
  init_parse();
78877
78905
  init_paths();
78878
78906
  init_user2();
78879
- init_utils4();
78907
+ init_utils3();
78880
78908
  d1ExportCommand = createCommand({
78881
78909
  metadata: {
78882
78910
  description: "Export the contents or schema of your database as a .sql file",
@@ -78961,7 +78989,7 @@ var init_info = __esm({
78961
78989
  init_create_command();
78962
78990
  init_logger();
78963
78991
  init_user2();
78964
- init_utils4();
78992
+ init_utils3();
78965
78993
  d1InfoCommand = createCommand({
78966
78994
  metadata: {
78967
78995
  description: "Get information about a D1 database, including the current database size and state",
@@ -79147,7 +79175,7 @@ var init_insights = __esm({
79147
79175
  init_create_command();
79148
79176
  init_logger();
79149
79177
  init_user2();
79150
- init_utils4();
79178
+ init_utils3();
79151
79179
  cliOptionToGraphQLOption = {
79152
79180
  time: "queryDurationMs",
79153
79181
  reads: "rowsRead",
@@ -79478,7 +79506,7 @@ var init_apply2 = __esm({
79478
79506
  init_logger();
79479
79507
  init_constants4();
79480
79508
  init_execute();
79481
- init_utils4();
79509
+ init_utils3();
79482
79510
  init_helpers6();
79483
79511
  d1MigrationsApplyCommand = createCommand({
79484
79512
  metadata: {
@@ -79665,7 +79693,7 @@ var init_create3 = __esm({
79665
79693
  init_errors();
79666
79694
  init_logger();
79667
79695
  init_constants4();
79668
- init_utils4();
79696
+ init_utils3();
79669
79697
  init_helpers6();
79670
79698
  d1MigrationsCreateCommand = createCommand({
79671
79699
  metadata: {
@@ -79735,7 +79763,7 @@ var init_list3 = __esm({
79735
79763
  init_logger();
79736
79764
  init_user2();
79737
79765
  init_constants4();
79738
- init_utils4();
79766
+ init_utils3();
79739
79767
  init_helpers6();
79740
79768
  d1MigrationsListCommand = createCommand({
79741
79769
  metadata: {
@@ -79852,12 +79880,12 @@ function getLocalISOString(date) {
79852
79880
  ).padStart(2, "0")}:${String(offsetAbs % 60).padStart(2, "0")}`;
79853
79881
  }
79854
79882
  var getBookmarkIdFromTimestamp, throwIfDatabaseIsAlpha, ISO_DATE_REG_EXP, convertTimestampToISO;
79855
- var init_utils6 = __esm({
79883
+ var init_utils5 = __esm({
79856
79884
  "src/d1/timeTravel/utils.ts"() {
79857
79885
  init_import_meta_url();
79858
79886
  init_cfetch();
79859
79887
  init_errors();
79860
- init_utils4();
79888
+ init_utils3();
79861
79889
  getBookmarkIdFromTimestamp = /* @__PURE__ */ __name(async (complianceConfig, accountId, databaseId, timestamp) => {
79862
79890
  const searchParams = new URLSearchParams();
79863
79891
  if (timestamp) {
@@ -79927,8 +79955,8 @@ var init_info2 = __esm({
79927
79955
  init_create_command();
79928
79956
  init_logger();
79929
79957
  init_user2();
79930
- init_utils4();
79931
- init_utils6();
79958
+ init_utils3();
79959
+ init_utils5();
79932
79960
  d1TimeTravelInfoCommand = createCommand({
79933
79961
  metadata: {
79934
79962
  description: "Retrieve information about a database at a specific point-in-time using Time Travel",
@@ -79992,8 +80020,8 @@ var init_restore = __esm({
79992
80020
  init_errors();
79993
80021
  init_logger();
79994
80022
  init_user2();
79995
- init_utils4();
79996
- init_utils6();
80023
+ init_utils3();
80024
+ init_utils5();
79997
80025
  d1TimeTravelRestoreCommand = createCommand({
79998
80026
  metadata: {
79999
80027
  description: "Restore a database back to a specific point-in-time",
@@ -80304,10 +80332,10 @@ var init_delete3 = __esm({
80304
80332
 
80305
80333
  // src/deployment-bundle/guess-worker-format.ts
80306
80334
  async function guessWorkerFormat(entryFile, entryWorkingDirectory, tsconfig) {
80307
- const parsedEntryPath = import_node_path29.default.parse(entryFile);
80335
+ const parsedEntryPath = import_node_path28.default.parse(entryFile);
80308
80336
  if (parsedEntryPath.ext == ".py") {
80309
80337
  logger.warn(
80310
- `The entrypoint ${import_node_path29.default.relative(
80338
+ `The entrypoint ${import_node_path28.default.relative(
80311
80339
  process.cwd(),
80312
80340
  entryFile
80313
80341
  )} defines a Python worker, support for Python workers is currently experimental. Python workers with a requirements.txt file can only be run locally and cannot be deployed.`
@@ -80332,7 +80360,7 @@ async function guessWorkerFormat(entryFile, entryWorkingDirectory, tsconfig) {
80332
80360
  guessedWorkerFormat = "modules";
80333
80361
  } else {
80334
80362
  logger.warn(
80335
- `The entrypoint ${import_node_path29.default.relative(
80363
+ `The entrypoint ${import_node_path28.default.relative(
80336
80364
  process.cwd(),
80337
80365
  entryFile
80338
80366
  )} has exports like an ES Module, but hasn't defined a default export like a module worker normally would. Building the worker using "service-worker" format...`
@@ -80344,11 +80372,11 @@ async function guessWorkerFormat(entryFile, entryWorkingDirectory, tsconfig) {
80344
80372
  }
80345
80373
  return { format: guessedWorkerFormat, exports: exports2 };
80346
80374
  }
80347
- var import_node_path29, esbuild2;
80375
+ var import_node_path28, esbuild2;
80348
80376
  var init_guess_worker_format = __esm({
80349
80377
  "src/deployment-bundle/guess-worker-format.ts"() {
80350
80378
  init_import_meta_url();
80351
- import_node_path29 = __toESM(require("path"));
80379
+ import_node_path28 = __toESM(require("path"));
80352
80380
  esbuild2 = __toESM(require("esbuild"));
80353
80381
  init_logger();
80354
80382
  init_bundle();
@@ -80480,7 +80508,7 @@ ${migrateUrl}`
80480
80508
  projectRoot,
80481
80509
  configPath: config.configPath,
80482
80510
  format: format9,
80483
- moduleRoot: args.moduleRoot ?? config.base_dir ?? import_node_path30.default.dirname(paths.absolutePath),
80511
+ moduleRoot: args.moduleRoot ?? config.base_dir ?? import_node_path29.default.dirname(paths.absolutePath),
80484
80512
  name: config.name ?? "worker",
80485
80513
  exports: exports2
80486
80514
  };
@@ -80520,11 +80548,11 @@ function getNpxEquivalent() {
80520
80548
  return "npx";
80521
80549
  }
80522
80550
  }
80523
- var import_node_path30;
80551
+ var import_node_path29;
80524
80552
  var init_entry = __esm({
80525
80553
  "src/deployment-bundle/entry.ts"() {
80526
80554
  init_import_meta_url();
80527
- import_node_path30 = __toESM(require("path"));
80555
+ import_node_path29 = __toESM(require("path"));
80528
80556
  init_esm2();
80529
80557
  init_config2();
80530
80558
  init_errors();
@@ -80626,20 +80654,20 @@ function getOutputFilePath() {
80626
80654
  const outputFileDirectoryFromEnv = getOutputFileDirectoryFromEnv();
80627
80655
  if (outputFileDirectoryFromEnv) {
80628
80656
  const date = (/* @__PURE__ */ new Date()).toISOString().replaceAll(":", "-").replace(".", "_").replace("T", "_").replace("Z", "");
80629
- return (0, import_node_path31.resolve)(
80657
+ return (0, import_node_path30.resolve)(
80630
80658
  outputFileDirectoryFromEnv,
80631
80659
  `wrangler-output-${date}-${(0, import_node_crypto6.randomBytes)(3).toString("hex")}.json`
80632
80660
  );
80633
80661
  }
80634
80662
  return null;
80635
80663
  }
80636
- var import_node_crypto6, import_node_fs18, import_node_path31, outputFilePath;
80664
+ var import_node_crypto6, import_node_fs18, import_node_path30, outputFilePath;
80637
80665
  var init_output = __esm({
80638
80666
  "src/output.ts"() {
80639
80667
  init_import_meta_url();
80640
80668
  import_node_crypto6 = require("crypto");
80641
80669
  import_node_fs18 = require("fs");
80642
- import_node_path31 = require("path");
80670
+ import_node_path30 = require("path");
80643
80671
  init_misc_variables();
80644
80672
  init_filesystem();
80645
80673
  __name(writeOutput, "writeOutput");
@@ -80686,12 +80714,12 @@ var init_getRules = __esm({
80686
80714
  });
80687
80715
 
80688
80716
  // src/deploy/index.ts
80689
- var import_node_assert17, import_node_path32, deployCommand;
80717
+ var import_node_assert17, import_node_path31, deployCommand;
80690
80718
  var init_deploy3 = __esm({
80691
80719
  "src/deploy/index.ts"() {
80692
80720
  init_import_meta_url();
80693
80721
  import_node_assert17 = __toESM(require("assert"));
80694
- import_node_path32 = __toESM(require("path"));
80722
+ import_node_path31 = __toESM(require("path"));
80695
80723
  init_assets();
80696
80724
  init_config2();
80697
80725
  init_create_command();
@@ -80919,7 +80947,7 @@ var init_deploy3 = __esm({
80919
80947
  { telemetryMessage: true }
80920
80948
  );
80921
80949
  }
80922
- const projectRoot = config.userConfigPath && import_node_path32.default.dirname(config.userConfigPath);
80950
+ const projectRoot = config.userConfigPath && import_node_path31.default.dirname(config.userConfigPath);
80923
80951
  const entry = await getEntry(args, config, "deploy");
80924
80952
  validateAssetsArgsAndConfig(args, config);
80925
80953
  const assetsOptions = getAssetsOptions(args, config);
@@ -83076,19 +83104,19 @@ async function downloadWorker(accountId, workerName) {
83076
83104
  config
83077
83105
  };
83078
83106
  }
83079
- var import_promises13, import_node_path33, import_toml4, init;
83107
+ var import_promises13, import_node_path32, import_toml4, init;
83080
83108
  var init_init = __esm({
83081
83109
  "src/init.ts"() {
83082
83110
  init_import_meta_url();
83083
83111
  import_promises13 = require("fs/promises");
83084
- import_node_path33 = __toESM(require("path"));
83112
+ import_node_path32 = __toESM(require("path"));
83085
83113
  import_toml4 = __toESM(require_toml());
83086
83114
  init_execa();
83087
83115
  init_utils2();
83088
83116
  init_cfetch();
83089
83117
  init_internal();
83090
83118
  init_create_command();
83091
- init_utils4();
83119
+ init_utils3();
83092
83120
  init_misc_variables();
83093
83121
  init_errors();
83094
83122
  init_logger();
@@ -83162,13 +83190,13 @@ var init_init = __esm({
83162
83190
  }
83163
83191
  throw err;
83164
83192
  }
83165
- const creationDir = import_node_path33.default.join(process.cwd(), args.fromDash);
83193
+ const creationDir = import_node_path32.default.join(process.cwd(), args.fromDash);
83166
83194
  await (0, import_promises13.mkdir)(creationDir, { recursive: true });
83167
83195
  const { modules, config } = await downloadWorker(
83168
83196
  accountId,
83169
83197
  args.fromDash
83170
83198
  );
83171
- await (0, import_promises13.mkdir)(import_node_path33.default.join(creationDir, "./src"), {
83199
+ await (0, import_promises13.mkdir)(import_node_path32.default.join(creationDir, "./src"), {
83172
83200
  recursive: true
83173
83201
  });
83174
83202
  config.main = `src/${config.main}`;
@@ -83176,15 +83204,15 @@ var init_init = __esm({
83176
83204
  for (const files of createBatches(modules, 10)) {
83177
83205
  await Promise.all(
83178
83206
  files.map(async (file) => {
83179
- const filepath = import_node_path33.default.join(creationDir, `./src/${file.name}`);
83180
- const directory = (0, import_node_path33.dirname)(filepath);
83207
+ const filepath = import_node_path32.default.join(creationDir, `./src/${file.name}`);
83208
+ const directory = (0, import_node_path32.dirname)(filepath);
83181
83209
  await (0, import_promises13.mkdir)(directory, { recursive: true });
83182
83210
  await (0, import_promises13.writeFile)(filepath, file.stream());
83183
83211
  })
83184
83212
  );
83185
83213
  }
83186
83214
  await (0, import_promises13.writeFile)(
83187
- import_node_path33.default.join(creationDir, "wrangler.toml"),
83215
+ import_node_path32.default.join(creationDir, "wrangler.toml"),
83188
83216
  import_toml4.default.stringify(config)
83189
83217
  );
83190
83218
  } else {
@@ -84350,13 +84378,64 @@ var init_cli3 = __esm({
84350
84378
  }
84351
84379
  });
84352
84380
 
84381
+ // src/pages/utils.ts
84382
+ function isUrl(maybeUrl) {
84383
+ if (!maybeUrl) {
84384
+ return false;
84385
+ }
84386
+ try {
84387
+ new URL(maybeUrl);
84388
+ return true;
84389
+ } catch (e7) {
84390
+ return false;
84391
+ }
84392
+ }
84393
+ function getPagesProjectRoot() {
84394
+ const cwd2 = process.cwd();
84395
+ if (projectRootCache !== void 0 && projectRootCacheCwd === cwd2) {
84396
+ return projectRootCache;
84397
+ }
84398
+ const packagePath = findUpSync("package.json");
84399
+ projectRootCache = packagePath ? import_node_path33.default.dirname(packagePath) : process.cwd();
84400
+ projectRootCacheCwd = cwd2;
84401
+ return projectRootCache;
84402
+ }
84403
+ function getPagesTmpDir() {
84404
+ const projectRoot = getPagesProjectRoot();
84405
+ if (tmpDirCache !== void 0 && tmpDirCacheProjectRoot === projectRoot) {
84406
+ return tmpDirCache;
84407
+ }
84408
+ const tmpDir = getWranglerTmpDir(getPagesProjectRoot(), "pages");
84409
+ tmpDirCache = tmpDir.path;
84410
+ tmpDirCacheProjectRoot = projectRoot;
84411
+ return tmpDirCache;
84412
+ }
84413
+ var import_node_path33, RUNNING_BUILDERS, CLEANUP_CALLBACKS, CLEANUP, projectRootCacheCwd, projectRootCache, tmpDirCacheProjectRoot, tmpDirCache;
84414
+ var init_utils6 = __esm({
84415
+ "src/pages/utils.ts"() {
84416
+ init_import_meta_url();
84417
+ import_node_path33 = __toESM(require("path"));
84418
+ init_find_up();
84419
+ init_paths();
84420
+ RUNNING_BUILDERS = [];
84421
+ CLEANUP_CALLBACKS = [];
84422
+ CLEANUP = /* @__PURE__ */ __name(() => {
84423
+ CLEANUP_CALLBACKS.forEach((callback) => callback());
84424
+ RUNNING_BUILDERS.forEach((builder) => builder.stop?.());
84425
+ }, "CLEANUP");
84426
+ __name(isUrl, "isUrl");
84427
+ __name(getPagesProjectRoot, "getPagesProjectRoot");
84428
+ __name(getPagesTmpDir, "getPagesTmpDir");
84429
+ }
84430
+ });
84431
+
84353
84432
  // src/pages/index.ts
84354
84433
  var pagesNamespace, pagesFunctionsNamespace, pagesProjectNamespace, pagesDeploymentNamespace, pagesDownloadNamespace;
84355
84434
  var init_pages = __esm({
84356
84435
  "src/pages/index.ts"() {
84357
84436
  init_import_meta_url();
84358
84437
  init_create_command();
84359
- init_utils3();
84438
+ init_utils6();
84360
84439
  pagesNamespace = createNamespace({
84361
84440
  metadata: {
84362
84441
  description: "\u26A1\uFE0F Configure Cloudflare Pages",
@@ -84811,7 +84890,7 @@ var init_buildWorker = __esm({
84811
84890
  init_errors();
84812
84891
  init_logger();
84813
84892
  init_paths();
84814
- init_utils3();
84893
+ init_utils6();
84815
84894
  __name(buildWorkerFromFunctions, "buildWorkerFromFunctions");
84816
84895
  __name(buildRawWorker, "buildRawWorker");
84817
84896
  __name(produceWorkerBundleForWorkerJSDirectory, "produceWorkerBundleForWorkerJSDirectory");
@@ -84937,7 +85016,7 @@ var init_buildPlugin = __esm({
84937
85016
  init_bundle();
84938
85017
  init_module_collection();
84939
85018
  init_paths();
84940
- init_utils3();
85019
+ init_utils6();
84941
85020
  init_buildWorker();
84942
85021
  __name(buildPluginFromFunctions, "buildPluginFromFunctions");
84943
85022
  }
@@ -85520,7 +85599,7 @@ var init_buildFunctions = __esm({
85520
85599
  init_filepath_routing();
85521
85600
  init_routes2();
85522
85601
  init_routes_transformation();
85523
- init_utils3();
85602
+ init_utils6();
85524
85603
  __name(buildFunctions, "buildFunctions");
85525
85604
  }
85526
85605
  });
@@ -87623,7 +87702,7 @@ var init_deploy4 = __esm({
87623
87702
  init_buildWorker();
87624
87703
  init_routes_validation();
87625
87704
  init_upload();
87626
- init_utils3();
87705
+ init_utils6();
87627
87706
  init_validate2();
87628
87707
  init_create_worker_bundle_contents();
87629
87708
  __name(deploy2, "deploy");
@@ -88049,7 +88128,7 @@ var init_deploy5 = __esm({
88049
88128
  init_errors3();
88050
88129
  init_projects();
88051
88130
  init_prompt_select_project();
88052
- init_utils3();
88131
+ init_utils6();
88053
88132
  pagesDeploymentCreateCommand = createAlias({
88054
88133
  aliasOf: "wrangler pages deploy"
88055
88134
  });
@@ -89958,7 +90037,7 @@ var init_deployment_tails = __esm({
89958
90037
  init_user2();
89959
90038
  init_constants3();
89960
90039
  init_prompt_select_project();
89961
- init_utils3();
90040
+ init_utils6();
89962
90041
  statusChoices = ["ok", "error", "canceled"];
89963
90042
  isStatusChoiceList = /* @__PURE__ */ __name((data) => data?.every((d6) => statusChoices.includes(d6)) ?? false, "isStatusChoiceList");
89964
90043
  pagesDeploymentTailCommand = createCommand({
@@ -90579,13 +90658,14 @@ var init_dev = __esm({
90579
90658
  init_metrics();
90580
90659
  init_navigator_user_agent();
90581
90660
  init_paths();
90661
+ init_debounce();
90582
90662
  init_shell_quote();
90583
90663
  init_buildFunctions();
90584
90664
  init_constants3();
90585
90665
  init_errors3();
90586
90666
  init_buildWorker();
90587
90667
  init_routes_validation();
90588
- init_utils3();
90668
+ init_utils6();
90589
90669
  DURABLE_OBJECTS_BINDING_REGEXP = new RegExp(
90590
90670
  /^(?<binding>[^=]+)=(?<className>[^@\s]+)(@(?<scriptName>.*)$)?$/
90591
90671
  );
@@ -174905,6 +174985,9 @@ var init_LocalRuntimeController = __esm({
174905
174985
  // If this doesn't match what is in config, trigger a rebuild.
174906
174986
  // Used for the rebuild hotkey
174907
174987
  #currentContainerBuildId;
174988
+ // Used to store the information and abort handle for the
174989
+ // current container that is being built
174990
+ containerBeingBuilt;
174908
174991
  onBundleStart(_4) {
174909
174992
  }
174910
174993
  async #onBundleComplete(data, id) {
@@ -174931,8 +175014,20 @@ var init_LocalRuntimeController = __esm({
174931
175014
  await prepareContainerImagesForDev(
174932
175015
  this.#dockerPath,
174933
175016
  containerOptions,
174934
- data.config.config
175017
+ data.config.config,
175018
+ (buildStartEvent) => {
175019
+ this.containerBeingBuilt = {
175020
+ ...buildStartEvent,
175021
+ abortRequested: false
175022
+ };
175023
+ },
175024
+ () => {
175025
+ this.containerBeingBuilt = void 0;
175026
+ }
174935
175027
  );
175028
+ if (this.containerBeingBuilt) {
175029
+ this.containerBeingBuilt.abortRequested = false;
175030
+ }
174936
175031
  this.#currentContainerBuildId = data.config.dev.containerBuildId;
174937
175032
  logger.log(source_default.dim("\u2394 Container image(s) ready"));
174938
175033
  }
@@ -174996,6 +175091,9 @@ var init_LocalRuntimeController = __esm({
174996
175091
  }
174997
175092
  });
174998
175093
  } catch (error2) {
175094
+ if (this.containerBeingBuilt?.abortRequested && error2 instanceof Error && error2.message === "Build exited with code: 1") {
175095
+ return;
175096
+ }
174999
175097
  this.emitErrorEvent({
175000
175098
  type: "error",
175001
175099
  reason: "Error reloading local server",
@@ -175640,7 +175738,15 @@ function registerDevHotKeys(devEnv, args) {
175640
175738
  disabled: /* @__PURE__ */ __name(() => {
175641
175739
  return !devEnv.config.latestConfig?.dev?.enableContainers || !devEnv.config.latestConfig?.containers?.length;
175642
175740
  }, "disabled"),
175643
- handler: /* @__PURE__ */ __name(async () => {
175741
+ handler: debounce(async () => {
175742
+ devEnv.runtimes.forEach((runtime) => {
175743
+ if (runtime instanceof LocalRuntimeController) {
175744
+ if (runtime.containerBeingBuilt) {
175745
+ runtime.containerBeingBuilt.abort();
175746
+ runtime.containerBeingBuilt.abortRequested = true;
175747
+ }
175748
+ }
175749
+ });
175644
175750
  const newContainerBuildId = (0, import_crypto7.randomUUID)().slice(0, 8);
175645
175751
  devEnv.runtimes.map(async (runtime) => {
175646
175752
  if (runtime instanceof LocalRuntimeController) {
@@ -175653,7 +175759,7 @@ function registerDevHotKeys(devEnv, args) {
175653
175759
  containerBuildId: newContainerBuildId
175654
175760
  }
175655
175761
  });
175656
- }, "handler")
175762
+ }, 250)
175657
175763
  },
175658
175764
  {
175659
175765
  keys: ["l"],
@@ -175671,13 +175777,26 @@ function registerDevHotKeys(devEnv, args) {
175671
175777
  keys: ["c"],
175672
175778
  label: "clear console",
175673
175779
  handler: /* @__PURE__ */ __name(async () => {
175674
- logger.console("clear");
175780
+ const someContainerIsBeingBuilt = devEnv.runtimes.some(
175781
+ (runtime) => runtime instanceof LocalRuntimeController && runtime.containerBeingBuilt
175782
+ );
175783
+ if (!someContainerIsBeingBuilt) {
175784
+ logger.console("clear");
175785
+ }
175675
175786
  }, "handler")
175676
175787
  },
175677
175788
  {
175678
175789
  keys: ["x", "q", "ctrl+c"],
175679
175790
  label: "to exit",
175680
175791
  handler: /* @__PURE__ */ __name(async () => {
175792
+ devEnv.runtimes.forEach((runtime) => {
175793
+ if (runtime instanceof LocalRuntimeController) {
175794
+ if (runtime.containerBeingBuilt) {
175795
+ runtime.containerBeingBuilt.abort();
175796
+ runtime.containerBeingBuilt.abortRequested = true;
175797
+ }
175798
+ }
175799
+ });
175681
175800
  await devEnv.teardown();
175682
175801
  }, "handler")
175683
175802
  }
@@ -175693,6 +175812,7 @@ var init_hotkeys = __esm({
175693
175812
  init_cli_hotkeys();
175694
175813
  init_logger();
175695
175814
  init_open_in_browser();
175815
+ init_debounce();
175696
175816
  init_inspect2();
175697
175817
  __name(registerDevHotKeys, "registerDevHotKeys");
175698
175818
  }