@cloudflare/vite-plugin 1.31.1 → 1.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  import { builtinModules, createRequire } from "node:module";
2
2
  import assert from "node:assert";
3
- import * as fs$1 from "node:fs";
3
+ import * as fs$2 from "node:fs";
4
4
  import fs, { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
5
5
  import * as nodePath from "node:path";
6
6
  import path3, { dirname, isAbsolute, join, relative, resolve } from "node:path";
7
7
  import os from "node:os";
8
- import { CoreHeaders, Log, LogLevel, Miniflare, Request as Request$1, Response as Response$1, coupleWebSocket, getDefaultDevRegistryPath, getNodeCompat, getWorkerRegistry, kUnsafeEphemeralUniqueKey } from "miniflare";
8
+ import { CoreHeaders, CorePaths, Log, LogLevel, Miniflare, Request as Request$1, Response as Response$1, coupleWebSocket, getDefaultDevRegistryPath, getNodeCompat, getWorkerRegistry, kUnsafeEphemeralUniqueKey } from "miniflare";
9
9
  import * as wrangler from "wrangler";
10
10
  import * as util$1 from "node:util";
11
- import { format, inspect } from "node:util";
11
+ import { format, inspect, promisify } from "node:util";
12
12
  import * as vite from "vite";
13
13
  import { version } from "vite";
14
14
  import { randomUUID } from "node:crypto";
@@ -18,10 +18,12 @@ import process$1 from "node:process";
18
18
  import v8 from "node:v8";
19
19
  import { defineEnv } from "unenv";
20
20
  import * as fsp from "node:fs/promises";
21
+ import fs$1, { constants } from "node:fs/promises";
21
22
  import net from "node:net";
22
- import { execFileSync, spawn } from "node:child_process";
23
+ import childProcess, { execFile, execFileSync, spawn } from "node:child_process";
23
24
  import path, { posix } from "path";
24
25
  import { WebSocketServer } from "ws";
26
+ import { Buffer as Buffer$1 } from "node:buffer";
25
27
 
26
28
  //#region rolldown:runtime
27
29
  var __create$1 = Object.create;
@@ -97,7 +99,7 @@ var __toESM = (mod, isNodeMode, target$1) => (target$1 = mod != null ? __create(
97
99
  }) : target$1, mod));
98
100
 
99
101
  //#endregion
100
- //#region ../workers-utils/dist/chunk-LX2YG63L.mjs
102
+ //#region ../workers-utils/dist/chunk-S3JFRPJM.mjs
101
103
  function isCompatDate(str) {
102
104
  return /^\d{4}-\d{2}-\d{2}$/.test(str);
103
105
  }
@@ -185,6 +187,12 @@ function mapWorkerMetadataBindings(bindings) {
185
187
  enable_timer: binding.enable_timer
186
188
  }];
187
189
  break;
190
+ case "flagship":
191
+ configObj.flagship = [...configObj.flagship ?? [], {
192
+ binding: binding.name,
193
+ app_id: binding.app_id
194
+ }];
195
+ break;
188
196
  case "service":
189
197
  configObj.services = [...configObj.services ?? [], {
190
198
  binding: binding.name,
@@ -3454,6 +3462,7 @@ var defaultWranglerConfig = {
3454
3462
  media: void 0,
3455
3463
  version_metadata: void 0,
3456
3464
  unsafe_hello_world: [],
3465
+ flagship: [],
3457
3466
  ratelimits: [],
3458
3467
  worker_loaders: [],
3459
3468
  legacy_env: true,
@@ -3496,6 +3505,7 @@ var defaultWranglerConfig = {
3496
3505
  cache: void 0,
3497
3506
  compliance_region: void 0,
3498
3507
  python_modules: { exclude: ["**/*.pyc"] },
3508
+ previews: void 0,
3499
3509
  define: {},
3500
3510
  cloudchamber: {},
3501
3511
  containers: void 0,
@@ -7508,6 +7518,7 @@ var friendlyBindingNames = {
7508
7518
  ratelimits: "Rate Limit",
7509
7519
  assets: "Assets",
7510
7520
  unsafe_hello_world: "Hello World",
7521
+ flagship: "Flagship",
7511
7522
  worker_loaders: "Worker Loader",
7512
7523
  vpc_services: "VPC Service",
7513
7524
  vpc_networks: "VPC Network"
@@ -7544,6 +7555,7 @@ var bindingTypeFriendlyNames = {
7544
7555
  secrets_store_secret: "Secrets Store Secret",
7545
7556
  logfwdr: "logfwdr",
7546
7557
  unsafe_hello_world: "Hello World",
7558
+ flagship: "Flagship",
7547
7559
  ratelimit: "Rate Limit",
7548
7560
  worker_loader: "Worker Loader",
7549
7561
  vpc_service: "VPC Service",
@@ -8016,6 +8028,7 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
8016
8028
  pipelines: notInheritable(diagnostics, topLevelEnv, rawConfig, rawEnv, envName, "pipelines", validateBindingArray(envName, validatePipelineBinding), []),
8017
8029
  secrets_store_secrets: notInheritable(diagnostics, topLevelEnv, rawConfig, rawEnv, envName, "secrets_store_secrets", validateBindingArray(envName, validateSecretsStoreSecretBinding), []),
8018
8030
  unsafe_hello_world: notInheritable(diagnostics, topLevelEnv, rawConfig, rawEnv, envName, "unsafe_hello_world", validateBindingArray(envName, validateHelloWorldBinding), []),
8031
+ flagship: notInheritable(diagnostics, topLevelEnv, rawConfig, rawEnv, envName, "flagship", validateBindingArray(envName, validateFlagshipBinding), []),
8019
8032
  worker_loaders: notInheritable(diagnostics, topLevelEnv, rawConfig, rawEnv, envName, "worker_loaders", validateBindingArray(envName, validateWorkerLoaderBinding), []),
8020
8033
  ratelimits: notInheritable(diagnostics, topLevelEnv, rawConfig, rawEnv, envName, "ratelimits", validateBindingArray(envName, validateRateLimitBinding), []),
8021
8034
  vpc_services: notInheritable(diagnostics, topLevelEnv, rawConfig, rawEnv, envName, "vpc_services", validateBindingArray(envName, validateVpcServiceBinding), []),
@@ -8031,7 +8044,8 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
8031
8044
  observability: inheritable(diagnostics, topLevelEnv, rawEnv, "observability", validateObservability, void 0),
8032
8045
  cache: inheritable(diagnostics, topLevelEnv, rawEnv, "cache", validateCache, void 0),
8033
8046
  compliance_region: inheritable(diagnostics, topLevelEnv, rawEnv, "compliance_region", isOneOf("public", "fedramp_high"), void 0),
8034
- python_modules: inheritable(diagnostics, topLevelEnv, rawEnv, "python_modules", validatePythonModules, { exclude: ["**/*.pyc"] })
8047
+ python_modules: inheritable(diagnostics, topLevelEnv, rawEnv, "python_modules", validatePythonModules, { exclude: ["**/*.pyc"] }),
8048
+ previews: inheritable(diagnostics, topLevelEnv, rawEnv, "previews", validatePreviewsConfig(envName), void 0)
8035
8049
  };
8036
8050
  warnIfDurableObjectsHaveNoMigrations(diagnostics, environment.durable_objects, environment.migrations, configPath);
8037
8051
  if (envName !== "top level") validateAdditionalProperties(diagnostics, "env." + envName, Object.keys(rawEnv), Object.keys(environment));
@@ -8449,6 +8463,7 @@ var validateUnsafeBinding = /* @__PURE__ */ __name((diagnostics, field, value) =
8449
8463
  "pipeline",
8450
8464
  "worker_loader",
8451
8465
  "vpc_service",
8466
+ "flagship",
8452
8467
  "vpc_network",
8453
8468
  "stream",
8454
8469
  "media"
@@ -9118,6 +9133,7 @@ var validateMTlsCertificateBinding = /* @__PURE__ */ __name((diagnostics, field,
9118
9133
  }, "validateMTlsCertificateBinding");
9119
9134
  function validateQueues(envName) {
9120
9135
  return (diagnostics, field, value, config) => {
9136
+ if (value === void 0) return true;
9121
9137
  const fieldPath = config === void 0 ? `${field}` : `env.${envName}.${field}`;
9122
9138
  if (typeof value !== "object" || Array.isArray(value) || value === null) {
9123
9139
  diagnostics.errors.push(`The field "${fieldPath}" should be an object but got ${JSON.stringify(value)}.`);
@@ -9276,6 +9292,28 @@ var validateHelloWorldBinding = /* @__PURE__ */ __name((diagnostics, field, valu
9276
9292
  validateAdditionalProperties(diagnostics, field, Object.keys(value), ["binding", "enable_timer"]);
9277
9293
  return isValid2;
9278
9294
  }, "validateHelloWorldBinding");
9295
+ var validateFlagshipBinding = /* @__PURE__ */ __name((diagnostics, field, value) => {
9296
+ if (typeof value !== "object" || value === null) {
9297
+ diagnostics.errors.push(`"flagship" bindings should be objects, but got ${JSON.stringify(value)}`);
9298
+ return false;
9299
+ }
9300
+ let isValid2 = true;
9301
+ if (!isRequiredProperty(value, "binding", "string")) {
9302
+ diagnostics.errors.push(`"${field}" bindings must have a string "binding" field but got ${JSON.stringify(value)}.`);
9303
+ isValid2 = false;
9304
+ }
9305
+ if (!isRequiredProperty(value, "app_id", "string")) {
9306
+ diagnostics.errors.push(`"${field}" bindings must have a string "app_id" field but got ${JSON.stringify(value)}.`);
9307
+ isValid2 = false;
9308
+ }
9309
+ validateAdditionalProperties(diagnostics, field, Object.keys(value), [
9310
+ "binding",
9311
+ "app_id",
9312
+ "remote"
9313
+ ]);
9314
+ if (!isRemoteValid(value, field, diagnostics)) isValid2 = false;
9315
+ return isValid2;
9316
+ }, "validateFlagshipBinding");
9279
9317
  var validateWorkerLoaderBinding = /* @__PURE__ */ __name((diagnostics, field, value) => {
9280
9318
  if (typeof value !== "object" || value === null) {
9281
9319
  diagnostics.errors.push(`"worker_loader" bindings should be objects, but got ${JSON.stringify(value)}`);
@@ -9335,6 +9373,87 @@ function normalizeAndValidateLimits(diagnostics, topLevelEnv, rawEnv) {
9335
9373
  return inheritable(diagnostics, topLevelEnv, rawEnv, "limits", () => true, void 0);
9336
9374
  }
9337
9375
  __name(normalizeAndValidateLimits, "normalizeAndValidateLimits");
9376
+ var validatePreviewsConfig = /* @__PURE__ */ __name((envName) => (diagnostics, field, value) => {
9377
+ if (value === void 0) return true;
9378
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
9379
+ diagnostics.errors.push(`The field "${field}" should be an object but got ${JSON.stringify(value)}.`);
9380
+ return false;
9381
+ }
9382
+ const previews = value;
9383
+ let isValid2 = true;
9384
+ isValid2 = validateAdditionalProperties(diagnostics, field, Object.keys(previews), [
9385
+ "vars",
9386
+ "define",
9387
+ "durable_objects",
9388
+ "workflows",
9389
+ "kv_namespaces",
9390
+ "send_email",
9391
+ "queues",
9392
+ "d1_databases",
9393
+ "r2_buckets",
9394
+ "vectorize",
9395
+ "hyperdrive",
9396
+ "services",
9397
+ "analytics_engine_datasets",
9398
+ "dispatch_namespaces",
9399
+ "mtls_certificates",
9400
+ "tail_consumers",
9401
+ "streaming_tail_consumers",
9402
+ "unsafe",
9403
+ "browser",
9404
+ "ai",
9405
+ "images",
9406
+ "stream",
9407
+ "media",
9408
+ "pipelines",
9409
+ "secrets_store_secrets",
9410
+ "unsafe_hello_world",
9411
+ "worker_loaders",
9412
+ "ratelimits",
9413
+ "vpc_services",
9414
+ "version_metadata",
9415
+ "logpush",
9416
+ "observability",
9417
+ "limits"
9418
+ ]) && isValid2;
9419
+ isValid2 = validateVars(envName)(diagnostics, `${field}.vars`, previews.vars, void 0) && isValid2;
9420
+ isValid2 = validateDefines(envName)(diagnostics, `${field}.define`, previews.define, void 0) && isValid2;
9421
+ isValid2 = validateBindingsProperty(envName, validateDurableObjectBinding)(diagnostics, `${field}.durable_objects`, previews.durable_objects, void 0) && isValid2;
9422
+ isValid2 = all(validateBindingArray(envName, validateWorkflowBinding), validateUniqueNameProperty)(diagnostics, `${field}.workflows`, previews.workflows, void 0) && isValid2;
9423
+ isValid2 = validateBindingArray(envName, validateKVBinding)(diagnostics, `${field}.kv_namespaces`, previews.kv_namespaces, void 0) && isValid2;
9424
+ isValid2 = validateBindingArray(envName, validateSendEmailBinding)(diagnostics, `${field}.send_email`, previews.send_email, void 0) && isValid2;
9425
+ isValid2 = validateQueues(envName)(diagnostics, `${field}.queues`, previews.queues, void 0) && isValid2;
9426
+ isValid2 = validateBindingArray(envName, validateD1Binding)(diagnostics, `${field}.d1_databases`, previews.d1_databases, void 0) && isValid2;
9427
+ isValid2 = validateBindingArray(envName, validateR2Binding)(diagnostics, `${field}.r2_buckets`, previews.r2_buckets, void 0) && isValid2;
9428
+ isValid2 = validateBindingArray(envName, validateVectorizeBinding)(diagnostics, `${field}.vectorize`, previews.vectorize, void 0) && isValid2;
9429
+ isValid2 = validateBindingArray(envName, validateHyperdriveBinding)(diagnostics, `${field}.hyperdrive`, previews.hyperdrive, void 0) && isValid2;
9430
+ isValid2 = validateBindingArray(envName, validateServiceBinding)(diagnostics, `${field}.services`, previews.services, void 0) && isValid2;
9431
+ isValid2 = validateBindingArray(envName, validateAnalyticsEngineBinding)(diagnostics, `${field}.analytics_engine_datasets`, previews.analytics_engine_datasets, void 0) && isValid2;
9432
+ isValid2 = validateBindingArray(envName, validateWorkerNamespaceBinding)(diagnostics, `${field}.dispatch_namespaces`, previews.dispatch_namespaces, void 0) && isValid2;
9433
+ isValid2 = validateBindingArray(envName, validateMTlsCertificateBinding)(diagnostics, `${field}.mtls_certificates`, previews.mtls_certificates, void 0) && isValid2;
9434
+ isValid2 = validateTailConsumers(diagnostics, `${field}.tail_consumers`, previews.tail_consumers, void 0) && isValid2;
9435
+ isValid2 = validateStreamingTailConsumers(diagnostics, `${field}.streaming_tail_consumers`, previews.streaming_tail_consumers, void 0) && isValid2;
9436
+ if (previews.unsafe !== void 0) isValid2 = validateUnsafeSettings(envName)(diagnostics, `${field}.unsafe`, previews.unsafe, void 0) && isValid2;
9437
+ if (previews.browser !== void 0) isValid2 = validateNamedSimpleBinding(envName)(diagnostics, `${field}.browser`, previews.browser, void 0) && isValid2;
9438
+ if (previews.ai !== void 0) isValid2 = validateAIBinding(envName)(diagnostics, `${field}.ai`, previews.ai, void 0) && isValid2;
9439
+ if (previews.images !== void 0) isValid2 = validateNamedSimpleBinding(envName)(diagnostics, `${field}.images`, previews.images, void 0) && isValid2;
9440
+ if (previews.stream !== void 0) isValid2 = validateNamedSimpleBinding(envName)(diagnostics, `${field}.stream`, previews.stream, void 0) && isValid2;
9441
+ if (previews.media !== void 0) isValid2 = validateNamedSimpleBinding(envName)(diagnostics, `${field}.media`, previews.media, void 0) && isValid2;
9442
+ isValid2 = validateBindingArray(envName, validatePipelineBinding)(diagnostics, `${field}.pipelines`, previews.pipelines, void 0) && isValid2;
9443
+ isValid2 = validateBindingArray(envName, validateSecretsStoreSecretBinding)(diagnostics, `${field}.secrets_store_secrets`, previews.secrets_store_secrets, void 0) && isValid2;
9444
+ isValid2 = validateBindingArray(envName, validateHelloWorldBinding)(diagnostics, `${field}.unsafe_hello_world`, previews.unsafe_hello_world, void 0) && isValid2;
9445
+ isValid2 = validateBindingArray(envName, validateWorkerLoaderBinding)(diagnostics, `${field}.worker_loaders`, previews.worker_loaders, void 0) && isValid2;
9446
+ isValid2 = validateBindingArray(envName, validateRateLimitBinding)(diagnostics, `${field}.ratelimits`, previews.ratelimits, void 0) && isValid2;
9447
+ isValid2 = validateBindingArray(envName, validateVpcServiceBinding)(diagnostics, `${field}.vpc_services`, previews.vpc_services, void 0) && isValid2;
9448
+ if (previews.version_metadata !== void 0) isValid2 = validateVersionMetadataBinding(envName)(diagnostics, `${field}.version_metadata`, previews.version_metadata, void 0) && isValid2;
9449
+ isValid2 = isBoolean(diagnostics, `${field}.logpush`, previews.logpush, void 0) && isValid2;
9450
+ isValid2 = validateObservability(diagnostics, `${field}.observability`, previews.observability, void 0) && isValid2;
9451
+ if (previews.limits) {
9452
+ isValid2 = validateOptionalProperty(diagnostics, `${field}.limits`, "cpu_ms", previews.limits.cpu_ms, "number") && isValid2;
9453
+ isValid2 = validateOptionalProperty(diagnostics, `${field}.limits`, "subrequests", previews.limits.subrequests, "number") && isValid2;
9454
+ }
9455
+ return isValid2;
9456
+ }, "validatePreviewsConfig");
9338
9457
  var validateMigrations = /* @__PURE__ */ __name((diagnostics, field, value) => {
9339
9458
  const rawMigrations = value ?? [];
9340
9459
  if (!Array.isArray(rawMigrations)) {
@@ -10927,7 +11046,7 @@ var require_subset = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/se
10927
11046
  //#region ../../node_modules/.pnpm/semver@7.7.3/node_modules/semver/index.js
10928
11047
  var require_semver = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/semver@7.7.3/node_modules/semver/index.js": ((exports, module) => {
10929
11048
  const internalRe = require_re();
10930
- const constants$2 = require_constants$1();
11049
+ const constants$3 = require_constants$1();
10931
11050
  const SemVer = require_semver$1();
10932
11051
  const identifiers = require_identifiers();
10933
11052
  const parse$2 = require_parse$1();
@@ -11009,8 +11128,8 @@ var require_semver = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/se
11009
11128
  re: internalRe.re,
11010
11129
  src: internalRe.src,
11011
11130
  tokens: internalRe.t,
11012
- SEMVER_SPEC_VERSION: constants$2.SEMVER_SPEC_VERSION,
11013
- RELEASE_TYPES: constants$2.RELEASE_TYPES,
11131
+ SEMVER_SPEC_VERSION: constants$3.SEMVER_SPEC_VERSION,
11132
+ RELEASE_TYPES: constants$3.RELEASE_TYPES,
11014
11133
  compareIdentifiers: identifiers.compareIdentifiers,
11015
11134
  rcompareIdentifiers: identifiers.rcompareIdentifiers
11016
11135
  };
@@ -11481,7 +11600,7 @@ function getDeployConfigPath(root) {
11481
11600
  }
11482
11601
  function getWorkerConfigs(root, isPrerender) {
11483
11602
  const deployConfigPath = getDeployConfigPath(root);
11484
- const deployConfig = JSON.parse(fs$1.readFileSync(deployConfigPath, "utf-8"));
11603
+ const deployConfig = JSON.parse(fs$2.readFileSync(deployConfigPath, "utf-8"));
11485
11604
  return [
11486
11605
  ...isPrerender && deployConfig.prerenderWorkerConfigPath ? [{ configPath: deployConfig.prerenderWorkerConfigPath }] : [],
11487
11606
  { configPath: deployConfig.configPath },
@@ -11497,7 +11616,7 @@ function getRelativePathToWorkerConfig(deployConfigDirectory, root, outputDirect
11497
11616
  function writeDeployConfig(resolvedPluginConfig, resolvedViteConfig) {
11498
11617
  const deployConfigPath = getDeployConfigPath(resolvedViteConfig.root);
11499
11618
  const deployConfigDirectory = nodePath.dirname(deployConfigPath);
11500
- fs$1.mkdirSync(deployConfigDirectory, { recursive: true });
11619
+ fs$2.mkdirSync(deployConfigDirectory, { recursive: true });
11501
11620
  if (resolvedPluginConfig.type === "assets-only") {
11502
11621
  const clientOutputDirectory = resolvedViteConfig.environments.client?.build.outDir;
11503
11622
  assert(clientOutputDirectory, "Unexpected error: client environment output directory is undefined");
@@ -11507,7 +11626,7 @@ function writeDeployConfig(resolvedPluginConfig, resolvedViteConfig) {
11507
11626
  auxiliaryWorkers: [],
11508
11627
  prerenderWorkerConfigPath: prerenderOutputDirectory ? getRelativePathToWorkerConfig(deployConfigDirectory, resolvedViteConfig.root, prerenderOutputDirectory) : void 0
11509
11628
  };
11510
- fs$1.writeFileSync(deployConfigPath, JSON.stringify(deployConfig));
11629
+ fs$2.writeFileSync(deployConfigPath, JSON.stringify(deployConfig));
11511
11630
  } else {
11512
11631
  let entryWorkerConfigPath;
11513
11632
  let prerenderWorkerConfigPath;
@@ -11526,7 +11645,7 @@ function writeDeployConfig(resolvedPluginConfig, resolvedViteConfig) {
11526
11645
  auxiliaryWorkers,
11527
11646
  prerenderWorkerConfigPath
11528
11647
  };
11529
- fs$1.writeFileSync(deployConfigPath, JSON.stringify(deployConfig));
11648
+ fs$2.writeFileSync(deployConfigPath, JSON.stringify(deployConfig));
11530
11649
  }
11531
11650
  }
11532
11651
 
@@ -18207,7 +18326,7 @@ function maybeResolveMain(main, configPath, root) {
18207
18326
  const baseDir = configPath ? nodePath.dirname(configPath) : root;
18208
18327
  if (!baseDir) return main;
18209
18328
  const resolvedMain = nodePath.resolve(baseDir, main);
18210
- if (!fs$1.existsSync(resolvedMain)) throw new Error(`The provided Wrangler config main field (${resolvedMain}) doesn't point to an existing file`);
18329
+ if (!fs$2.existsSync(resolvedMain)) throw new Error(`The provided Wrangler config main field (${resolvedMain}) doesn't point to an existing file`);
18211
18330
  return resolvedMain;
18212
18331
  }
18213
18332
  /**
@@ -18228,7 +18347,7 @@ function getValidatedWranglerConfigPath(root, requestedConfigPath, isForAuxiliar
18228
18347
  const foundExtensionMessage = !fileExtension ? "no extension found" : `"${fileExtension}" found`;
18229
18348
  throw new Error(`${errorMessagePrefix} doesn't point to a file with the correct file extension. It should point to a jsonc, json or toml file (${foundExtensionMessage} instead)`);
18230
18349
  }
18231
- const mainStat = fs$1.statSync(configPath, { throwIfNoEntry: false });
18350
+ const mainStat = fs$2.statSync(configPath, { throwIfNoEntry: false });
18232
18351
  if (!mainStat) throw new Error(`${errorMessagePrefix} doesn't point to an existing file`);
18233
18352
  if (mainStat.isDirectory()) throw new Error(`${errorMessagePrefix} points to a directory. It should point to a file.`);
18234
18353
  return configPath;
@@ -18239,7 +18358,7 @@ function getValidatedWranglerConfigPath(root, requestedConfigPath, isForAuxiliar
18239
18358
  function findWranglerConfig(root) {
18240
18359
  for (const extension of allowedWranglerConfigExtensions) {
18241
18360
  const configPath = nodePath.join(root, `wrangler.${extension}`);
18242
- if (fs$1.existsSync(configPath)) return configPath;
18361
+ if (fs$2.existsSync(configPath)) return configPath;
18243
18362
  }
18244
18363
  }
18245
18364
  const allowedWranglerConfigExtensions = [
@@ -25164,9 +25283,9 @@ function getHeadersConfigPath(config) {
25164
25283
  var require_picocolors = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js": ((exports, module) => {
25165
25284
  let p = process || {}, argv = p.argv || [], env = p.env || {};
25166
25285
  let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
25167
- let formatter = (open, close, replace = open) => (input) => {
25168
- let string = "" + input, index = string.indexOf(close, open.length);
25169
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
25286
+ let formatter = (open$1, close, replace = open$1) => (input) => {
25287
+ let string = "" + input, index = string.indexOf(close, open$1.length);
25288
+ return ~index ? open$1 + replaceClose(string, close, replace, index) + close : open$1 + string + close;
25170
25289
  };
25171
25290
  let replaceClose = (string, close, replace, index) => {
25172
25291
  let result = "", cursor = 0;
@@ -25237,7 +25356,7 @@ function createBuildApp(resolvedPluginConfig) {
25237
25356
  const clientEnvironment = builder.environments.client;
25238
25357
  assert(clientEnvironment, `No "client" environment`);
25239
25358
  const defaultHtmlPath = nodePath.resolve(builder.config.root, "index.html");
25240
- const hasClientEntry = clientEnvironment.config.build.rollupOptions.input || fs$1.existsSync(defaultHtmlPath);
25359
+ const hasClientEntry = clientEnvironment.config.build.rollupOptions.input || fs$2.existsSync(defaultHtmlPath);
25241
25360
  const workerEnvironments = [...resolvedPluginConfig.environmentNameToWorkerMap.keys()].map((environmentName) => {
25242
25361
  const environment = builder.environments[environmentName];
25243
25362
  assert(environment, `"${environmentName}" environment not found`);
@@ -25265,12 +25384,12 @@ function createBuildApp(resolvedPluginConfig) {
25265
25384
  for (const assetPath of importedAssetPaths) {
25266
25385
  const src$1 = nodePath.join(entryWorkerBuildDirectory, assetPath);
25267
25386
  const dest = nodePath.join(clientBuildDirectory, assetPath);
25268
- if (!fs$1.existsSync(src$1)) continue;
25269
- if (fs$1.existsSync(dest)) fs$1.unlinkSync(src$1);
25387
+ if (!fs$2.existsSync(src$1)) continue;
25388
+ if (fs$2.existsSync(dest)) fs$2.unlinkSync(src$1);
25270
25389
  else {
25271
25390
  const destDir = nodePath.dirname(dest);
25272
- fs$1.mkdirSync(destDir, { recursive: true });
25273
- fs$1.renameSync(src$1, dest);
25391
+ fs$2.mkdirSync(destDir, { recursive: true });
25392
+ fs$2.renameSync(src$1, dest);
25274
25393
  movedAssetPaths.push(dest);
25275
25394
  }
25276
25395
  }
@@ -25280,7 +25399,7 @@ function createBuildApp(resolvedPluginConfig) {
25280
25399
  function getHasPublicAssets({ publicDir }) {
25281
25400
  let hasPublicAssets = false;
25282
25401
  if (publicDir) try {
25283
- if (fs$1.readdirSync(publicDir).length) hasPublicAssets = true;
25402
+ if (fs$2.readdirSync(publicDir).length) hasPublicAssets = true;
25284
25403
  } catch {}
25285
25404
  return hasPublicAssets;
25286
25405
  }
@@ -25292,10 +25411,10 @@ async function fallbackBuild(builder, environment) {
25292
25411
  };
25293
25412
  await builder.build(environment);
25294
25413
  const fallbackEntryPath = nodePath.resolve(builder.config.root, environment.config.build.outDir, CLIENT_FALLBACK_ENTRY_NAME);
25295
- fs$1.unlinkSync(fallbackEntryPath);
25414
+ fs$2.unlinkSync(fallbackEntryPath);
25296
25415
  }
25297
25416
  function loadViteManifest(directory) {
25298
- const contents = fs$1.readFileSync(nodePath.resolve(directory, ".vite", "manifest.json"), "utf-8");
25417
+ const contents = fs$2.readFileSync(nodePath.resolve(directory, ".vite", "manifest.json"), "utf-8");
25299
25418
  return JSON.parse(contents);
25300
25419
  }
25301
25420
  function getImportedAssetPaths(viteManifest) {
@@ -25307,9 +25426,9 @@ function getImportedAssetPaths(viteManifest) {
25307
25426
  */
25308
25427
  function removeAssetsField(entryWorkerBuildDirectory) {
25309
25428
  const entryWorkerConfigPath = nodePath.join(entryWorkerBuildDirectory, "wrangler.json");
25310
- const workerConfig = JSON.parse(fs$1.readFileSync(entryWorkerConfigPath, "utf-8"));
25429
+ const workerConfig = JSON.parse(fs$2.readFileSync(entryWorkerConfigPath, "utf-8"));
25311
25430
  workerConfig.assets = void 0;
25312
- fs$1.writeFileSync(entryWorkerConfigPath, JSON.stringify(workerConfig));
25431
+ fs$2.writeFileSync(entryWorkerConfigPath, JSON.stringify(workerConfig));
25313
25432
  }
25314
25433
 
25315
25434
  //#endregion
@@ -26621,14 +26740,14 @@ var ImageRegistriesService = class {
26621
26740
  //#endregion
26622
26741
  //#region ../containers-shared/src/build.ts
26623
26742
  async function constructBuildCommand(options, logger) {
26624
- const platform = options.platform ?? "linux/amd64";
26743
+ const platform$1 = options.platform ?? "linux/amd64";
26625
26744
  const buildCmd = [
26626
26745
  "build",
26627
26746
  "--load",
26628
26747
  "-t",
26629
26748
  options.tag,
26630
26749
  "--platform",
26631
- platform,
26750
+ platform$1,
26632
26751
  "--provenance=false"
26633
26752
  ];
26634
26753
  if (options.args) for (const arg in options.args) buildCmd.push("--build-arg", `${arg}=${options.args[arg]}`);
@@ -27815,8 +27934,8 @@ var require_utils = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/pic
27815
27934
  exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
27816
27935
  exports.isWindows = () => {
27817
27936
  if (typeof navigator !== "undefined" && navigator.platform) {
27818
- const platform = navigator.platform.toLowerCase();
27819
- return platform === "win32" || platform === "windows";
27937
+ const platform$1 = navigator.platform.toLowerCase();
27938
+ return platform$1 === "win32" || platform$1 === "windows";
27820
27939
  }
27821
27940
  if (typeof process !== "undefined" && process.platform) return process.platform === "win32";
27822
27941
  return false;
@@ -28144,12 +28263,12 @@ var require_scan = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/pico
28144
28263
  //#endregion
28145
28264
  //#region ../../node_modules/.pnpm/picomatch@4.0.2/node_modules/picomatch/lib/parse.js
28146
28265
  var require_parse = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/picomatch@4.0.2/node_modules/picomatch/lib/parse.js": ((exports, module) => {
28147
- const constants$1 = require_constants();
28266
+ const constants$2 = require_constants();
28148
28267
  const utils$2 = require_utils();
28149
28268
  /**
28150
28269
  * Constants
28151
28270
  */
28152
- const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants$1;
28271
+ const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants$2;
28153
28272
  /**
28154
28273
  * Helpers
28155
28274
  */
@@ -28190,8 +28309,8 @@ var require_parse = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/pic
28190
28309
  };
28191
28310
  const tokens = [bos];
28192
28311
  const capture = opts.capture ? "" : "?:";
28193
- const PLATFORM_CHARS = constants$1.globChars(opts.windows);
28194
- const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
28312
+ const PLATFORM_CHARS = constants$2.globChars(opts.windows);
28313
+ const EXTGLOB_CHARS = constants$2.extglobChars(PLATFORM_CHARS);
28195
28314
  const { DOT_LITERAL: DOT_LITERAL$1, PLUS_LITERAL: PLUS_LITERAL$1, SLASH_LITERAL: SLASH_LITERAL$1, ONE_CHAR: ONE_CHAR$1, DOTS_SLASH: DOTS_SLASH$1, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK: QMARK$1, QMARK_NO_DOT, STAR, START_ANCHOR: START_ANCHOR$1 } = PLATFORM_CHARS;
28196
28315
  const globstar = (opts$1) => {
28197
28316
  return `(${capture}(?:(?!${START_ANCHOR$1}${opts$1.dot ? DOTS_SLASH$1 : DOT_LITERAL$1}).)*?)`;
@@ -28537,15 +28656,15 @@ var require_parse = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/pic
28537
28656
  */
28538
28657
  if (value === "{" && opts.nobrace !== true) {
28539
28658
  increment("braces");
28540
- const open = {
28659
+ const open$1 = {
28541
28660
  type: "brace",
28542
28661
  value,
28543
28662
  output: "(",
28544
28663
  outputIndex: state.output.length,
28545
28664
  tokensIndex: state.tokens.length
28546
28665
  };
28547
- braces.push(open);
28548
- push(open);
28666
+ braces.push(open$1);
28667
+ push(open$1);
28549
28668
  continue;
28550
28669
  }
28551
28670
  if (value === "}") {
@@ -28960,7 +29079,7 @@ var require_parse = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/pic
28960
29079
  const len = input.length;
28961
29080
  if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
28962
29081
  input = REPLACEMENTS[input] || input;
28963
- const { DOT_LITERAL: DOT_LITERAL$1, SLASH_LITERAL: SLASH_LITERAL$1, ONE_CHAR: ONE_CHAR$1, DOTS_SLASH: DOTS_SLASH$1, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR: START_ANCHOR$1 } = constants$1.globChars(opts.windows);
29082
+ const { DOT_LITERAL: DOT_LITERAL$1, SLASH_LITERAL: SLASH_LITERAL$1, ONE_CHAR: ONE_CHAR$1, DOTS_SLASH: DOTS_SLASH$1, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR: START_ANCHOR$1 } = constants$2.globChars(opts.windows);
28964
29083
  const nodot = opts.dot ? NO_DOTS : NO_DOT;
28965
29084
  const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
28966
29085
  const capture = opts.capture ? "" : "?:";
@@ -29006,7 +29125,7 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
29006
29125
  const scan = require_scan();
29007
29126
  const parse = require_parse();
29008
29127
  const utils$1 = require_utils();
29009
- const constants = require_constants();
29128
+ const constants$1 = require_constants();
29010
29129
  const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
29011
29130
  /**
29012
29131
  * Creates a matcher function from one or more glob patterns. The
@@ -29286,7 +29405,7 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
29286
29405
  * Picomatch constants.
29287
29406
  * @return {Object}
29288
29407
  */
29289
- picomatch$2.constants = constants;
29408
+ picomatch$2.constants = constants$1;
29290
29409
  /**
29291
29410
  * Expose "picomatch"
29292
29411
  */
@@ -29721,7 +29840,7 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
29721
29840
  modules: [{
29722
29841
  type: "ESModule",
29723
29842
  path: nodePath.join(miniflareModulesRoot, ROUTER_WORKER_PATH),
29724
- contents: fs$1.readFileSync(fileURLToPath(new URL(ROUTER_WORKER_PATH, import.meta.url)))
29843
+ contents: fs$2.readFileSync(fileURLToPath(new URL(ROUTER_WORKER_PATH, import.meta.url)))
29725
29844
  }],
29726
29845
  bindings: { CONFIG: { has_user_worker: resolvedPluginConfig.type === "workers" } },
29727
29846
  serviceBindings: {
@@ -29736,7 +29855,7 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
29736
29855
  modules: [{
29737
29856
  type: "ESModule",
29738
29857
  path: nodePath.join(miniflareModulesRoot, ASSET_WORKER_PATH),
29739
- contents: fs$1.readFileSync(fileURLToPath(new URL(ASSET_WORKER_PATH, import.meta.url)))
29858
+ contents: fs$2.readFileSync(fileURLToPath(new URL(ASSET_WORKER_PATH, import.meta.url)))
29740
29859
  }],
29741
29860
  bindings: {
29742
29861
  CONFIG: assetsConfig,
@@ -29780,7 +29899,7 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
29780
29899
  modules: [{
29781
29900
  type: "ESModule",
29782
29901
  path: nodePath.join(miniflareModulesRoot, VITE_PROXY_WORKER_PATH),
29783
- contents: fs$1.readFileSync(fileURLToPath(new URL(VITE_PROXY_WORKER_PATH, import.meta.url)))
29902
+ contents: fs$2.readFileSync(fileURLToPath(new URL(VITE_PROXY_WORKER_PATH, import.meta.url)))
29784
29903
  }],
29785
29904
  serviceBindings: {
29786
29905
  ...entryWorkerConfig ? { ENTRY_USER_WORKER: entryWorkerConfig.name } : {},
@@ -29841,12 +29960,12 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
29841
29960
  {
29842
29961
  type: "ESModule",
29843
29962
  path: nodePath.join(miniflareModulesRoot, RUNNER_PATH),
29844
- contents: fs$1.readFileSync(fileURLToPath(new URL(RUNNER_PATH, import.meta.url)))
29963
+ contents: fs$2.readFileSync(fileURLToPath(new URL(RUNNER_PATH, import.meta.url)))
29845
29964
  },
29846
29965
  {
29847
29966
  type: "ESModule",
29848
29967
  path: nodePath.join(miniflareModulesRoot, "workers/runner-worker/vite/module-runner"),
29849
- contents: fs$1.readFileSync(fileURLToPath(new URL(satisfiesMinimumViteVersion("7.2.0") ? MODULE_RUNNER_PATH : MODULE_RUNNER_LEGACY_PATH, import.meta.url)))
29968
+ contents: fs$2.readFileSync(fileURLToPath(new URL(satisfiesMinimumViteVersion("7.2.0") ? MODULE_RUNNER_PATH : MODULE_RUNNER_LEGACY_PATH, import.meta.url)))
29850
29969
  }
29851
29970
  ],
29852
29971
  unsafeUseModuleFallbackService: true,
@@ -29896,6 +30015,7 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
29896
30015
  unsafeDevRegistryPath: getDefaultDevRegistryPath(),
29897
30016
  unsafeTriggerHandlers: true,
29898
30017
  unsafeLocalExplorer: getLocalExplorerEnabledFromEnv(),
30018
+ telemetry: { enabled: false },
29899
30019
  handleStructuredLogs: getStructuredLogsLogger(logger),
29900
30020
  defaultPersistRoot: getPersistenceRoot(resolvedViteConfig.root, resolvedPluginConfig.persistState),
29901
30021
  workers: [
@@ -30000,6 +30120,7 @@ async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
30000
30120
  unsafeDevRegistryPath: getDefaultDevRegistryPath(),
30001
30121
  unsafeTriggerHandlers: true,
30002
30122
  unsafeLocalExplorer: getLocalExplorerEnabledFromEnv(),
30123
+ telemetry: { enabled: false },
30003
30124
  handleStructuredLogs: getStructuredLogsLogger(logger),
30004
30125
  defaultPersistRoot: getPersistenceRoot(resolvedViteConfig.root, resolvedPluginConfig.persistState),
30005
30126
  workers
@@ -30457,6 +30578,545 @@ const rscPlugin = createPlugin("rsc", () => {
30457
30578
  };
30458
30579
  });
30459
30580
 
30581
+ //#endregion
30582
+ //#region ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
30583
+ let isDockerCached;
30584
+ function hasDockerEnv() {
30585
+ try {
30586
+ fs.statSync("/.dockerenv");
30587
+ return true;
30588
+ } catch {
30589
+ return false;
30590
+ }
30591
+ }
30592
+ function hasDockerCGroup() {
30593
+ try {
30594
+ return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
30595
+ } catch {
30596
+ return false;
30597
+ }
30598
+ }
30599
+ function isDocker() {
30600
+ if (isDockerCached === void 0) isDockerCached = hasDockerEnv() || hasDockerCGroup();
30601
+ return isDockerCached;
30602
+ }
30603
+
30604
+ //#endregion
30605
+ //#region ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
30606
+ let cachedResult;
30607
+ const hasContainerEnv = () => {
30608
+ try {
30609
+ fs.statSync("/run/.containerenv");
30610
+ return true;
30611
+ } catch {
30612
+ return false;
30613
+ }
30614
+ };
30615
+ function isInsideContainer() {
30616
+ if (cachedResult === void 0) cachedResult = hasContainerEnv() || isDocker();
30617
+ return cachedResult;
30618
+ }
30619
+
30620
+ //#endregion
30621
+ //#region ../../node_modules/.pnpm/is-wsl@3.1.0/node_modules/is-wsl/index.js
30622
+ const isWsl = () => {
30623
+ if (process$1.platform !== "linux") return false;
30624
+ if (os.release().toLowerCase().includes("microsoft")) {
30625
+ if (isInsideContainer()) return false;
30626
+ return true;
30627
+ }
30628
+ try {
30629
+ return fs.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
30630
+ } catch {
30631
+ return false;
30632
+ }
30633
+ };
30634
+ var is_wsl_default = process$1.env.__IS_WSL_TEST__ ? isWsl : isWsl();
30635
+
30636
+ //#endregion
30637
+ //#region ../../node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js
30638
+ const execFile$2 = promisify(childProcess.execFile);
30639
+ const powerShellPath$1 = () => `${process$1.env.SYSTEMROOT || process$1.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
30640
+ const executePowerShell = async (command, options = {}) => {
30641
+ const { powerShellPath: psPath,...execFileOptions } = options;
30642
+ const encodedCommand = executePowerShell.encodeCommand(command);
30643
+ return execFile$2(psPath ?? powerShellPath$1(), [...executePowerShell.argumentsPrefix, encodedCommand], {
30644
+ encoding: "utf8",
30645
+ ...execFileOptions
30646
+ });
30647
+ };
30648
+ executePowerShell.argumentsPrefix = [
30649
+ "-NoProfile",
30650
+ "-NonInteractive",
30651
+ "-ExecutionPolicy",
30652
+ "Bypass",
30653
+ "-EncodedCommand"
30654
+ ];
30655
+ executePowerShell.encodeCommand = (command) => Buffer$1.from(command, "utf16le").toString("base64");
30656
+ executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
30657
+
30658
+ //#endregion
30659
+ //#region ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/utilities.js
30660
+ function parseMountPointFromConfig(content) {
30661
+ for (const line of content.split("\n")) {
30662
+ if (/^\s*#/.test(line)) continue;
30663
+ const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
30664
+ if (!match) continue;
30665
+ return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
30666
+ }
30667
+ }
30668
+
30669
+ //#endregion
30670
+ //#region ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js
30671
+ const execFile$1 = promisify(childProcess.execFile);
30672
+ const wslDrivesMountPoint = (() => {
30673
+ const defaultMountPoint = "/mnt/";
30674
+ let mountPoint;
30675
+ return async function() {
30676
+ if (mountPoint) return mountPoint;
30677
+ const configFilePath = "/etc/wsl.conf";
30678
+ let isConfigFileExists = false;
30679
+ try {
30680
+ await fs$1.access(configFilePath, constants.F_OK);
30681
+ isConfigFileExists = true;
30682
+ } catch {}
30683
+ if (!isConfigFileExists) return defaultMountPoint;
30684
+ const parsedMountPoint = parseMountPointFromConfig(await fs$1.readFile(configFilePath, { encoding: "utf8" }));
30685
+ if (parsedMountPoint === void 0) return defaultMountPoint;
30686
+ mountPoint = parsedMountPoint;
30687
+ mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
30688
+ return mountPoint;
30689
+ };
30690
+ })();
30691
+ const powerShellPathFromWsl = async () => {
30692
+ return `${await wslDrivesMountPoint()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
30693
+ };
30694
+ const powerShellPath = is_wsl_default ? powerShellPathFromWsl : powerShellPath$1;
30695
+ let canAccessPowerShellPromise;
30696
+ const canAccessPowerShell = async () => {
30697
+ canAccessPowerShellPromise ??= (async () => {
30698
+ try {
30699
+ const psPath = await powerShellPath();
30700
+ await fs$1.access(psPath, constants.X_OK);
30701
+ return true;
30702
+ } catch {
30703
+ return false;
30704
+ }
30705
+ })();
30706
+ return canAccessPowerShellPromise;
30707
+ };
30708
+ const wslDefaultBrowser = async () => {
30709
+ const psPath = await powerShellPath();
30710
+ const { stdout } = await executePowerShell(String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`, { powerShellPath: psPath });
30711
+ return stdout.trim();
30712
+ };
30713
+ const convertWslPathToWindows = async (path$1) => {
30714
+ if (/^[a-z]+:\/\//i.test(path$1)) return path$1;
30715
+ try {
30716
+ const { stdout } = await execFile$1("wslpath", ["-aw", path$1], { encoding: "utf8" });
30717
+ return stdout.trim();
30718
+ } catch {
30719
+ return path$1;
30720
+ }
30721
+ };
30722
+
30723
+ //#endregion
30724
+ //#region ../../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
30725
+ function defineLazyProperty(object, propertyName, valueGetter) {
30726
+ const define$1 = (value) => Object.defineProperty(object, propertyName, {
30727
+ value,
30728
+ enumerable: true,
30729
+ writable: true
30730
+ });
30731
+ Object.defineProperty(object, propertyName, {
30732
+ configurable: true,
30733
+ enumerable: true,
30734
+ get() {
30735
+ const result = valueGetter();
30736
+ define$1(result);
30737
+ return result;
30738
+ },
30739
+ set(value) {
30740
+ define$1(value);
30741
+ }
30742
+ });
30743
+ return object;
30744
+ }
30745
+
30746
+ //#endregion
30747
+ //#region ../../node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
30748
+ const execFileAsync$3 = promisify(execFile);
30749
+ async function defaultBrowserId() {
30750
+ if (process$1.platform !== "darwin") throw new Error("macOS only");
30751
+ const { stdout } = await execFileAsync$3("defaults", [
30752
+ "read",
30753
+ "com.apple.LaunchServices/com.apple.launchservices.secure",
30754
+ "LSHandlers"
30755
+ ]);
30756
+ const browserId = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout)?.groups.id ?? "com.apple.Safari";
30757
+ if (browserId === "com.apple.safari") return "com.apple.Safari";
30758
+ return browserId;
30759
+ }
30760
+
30761
+ //#endregion
30762
+ //#region ../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
30763
+ const execFileAsync$2 = promisify(execFile);
30764
+ async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
30765
+ if (process$1.platform !== "darwin") throw new Error("macOS only");
30766
+ const outputArguments = humanReadableOutput ? [] : ["-ss"];
30767
+ const execOptions = {};
30768
+ if (signal) execOptions.signal = signal;
30769
+ const { stdout } = await execFileAsync$2("osascript", [
30770
+ "-e",
30771
+ script,
30772
+ outputArguments
30773
+ ], execOptions);
30774
+ return stdout.trim();
30775
+ }
30776
+
30777
+ //#endregion
30778
+ //#region ../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js
30779
+ async function bundleName(bundleId) {
30780
+ return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
30781
+ }
30782
+
30783
+ //#endregion
30784
+ //#region ../../node_modules/.pnpm/default-browser@5.4.0/node_modules/default-browser/windows.js
30785
+ const execFileAsync$1 = promisify(execFile);
30786
+ const windowsBrowserProgIds = {
30787
+ MSEdgeHTM: {
30788
+ name: "Edge",
30789
+ id: "com.microsoft.edge"
30790
+ },
30791
+ MSEdgeBHTML: {
30792
+ name: "Edge Beta",
30793
+ id: "com.microsoft.edge.beta"
30794
+ },
30795
+ MSEdgeDHTML: {
30796
+ name: "Edge Dev",
30797
+ id: "com.microsoft.edge.dev"
30798
+ },
30799
+ AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {
30800
+ name: "Edge",
30801
+ id: "com.microsoft.edge.old"
30802
+ },
30803
+ ChromeHTML: {
30804
+ name: "Chrome",
30805
+ id: "com.google.chrome"
30806
+ },
30807
+ ChromeBHTML: {
30808
+ name: "Chrome Beta",
30809
+ id: "com.google.chrome.beta"
30810
+ },
30811
+ ChromeDHTML: {
30812
+ name: "Chrome Dev",
30813
+ id: "com.google.chrome.dev"
30814
+ },
30815
+ ChromiumHTM: {
30816
+ name: "Chromium",
30817
+ id: "org.chromium.Chromium"
30818
+ },
30819
+ BraveHTML: {
30820
+ name: "Brave",
30821
+ id: "com.brave.Browser"
30822
+ },
30823
+ BraveBHTML: {
30824
+ name: "Brave Beta",
30825
+ id: "com.brave.Browser.beta"
30826
+ },
30827
+ BraveDHTML: {
30828
+ name: "Brave Dev",
30829
+ id: "com.brave.Browser.dev"
30830
+ },
30831
+ BraveSSHTM: {
30832
+ name: "Brave Nightly",
30833
+ id: "com.brave.Browser.nightly"
30834
+ },
30835
+ FirefoxURL: {
30836
+ name: "Firefox",
30837
+ id: "org.mozilla.firefox"
30838
+ },
30839
+ OperaStable: {
30840
+ name: "Opera",
30841
+ id: "com.operasoftware.Opera"
30842
+ },
30843
+ VivaldiHTM: {
30844
+ name: "Vivaldi",
30845
+ id: "com.vivaldi.Vivaldi"
30846
+ },
30847
+ "IE.HTTP": {
30848
+ name: "Internet Explorer",
30849
+ id: "com.microsoft.ie"
30850
+ }
30851
+ };
30852
+ const _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
30853
+ var UnknownBrowserError = class extends Error {};
30854
+ async function defaultBrowser$1(_execFileAsync = execFileAsync$1) {
30855
+ const { stdout } = await _execFileAsync("reg", [
30856
+ "QUERY",
30857
+ " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
30858
+ "/v",
30859
+ "ProgId"
30860
+ ]);
30861
+ const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
30862
+ if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
30863
+ const { id } = match.groups;
30864
+ const browser = windowsBrowserProgIds[id];
30865
+ if (!browser) throw new UnknownBrowserError(`Unknown browser ID: ${id}`);
30866
+ return browser;
30867
+ }
30868
+
30869
+ //#endregion
30870
+ //#region ../../node_modules/.pnpm/default-browser@5.4.0/node_modules/default-browser/index.js
30871
+ const execFileAsync = promisify(execFile);
30872
+ const titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
30873
+ async function defaultBrowser() {
30874
+ if (process$1.platform === "darwin") {
30875
+ const id = await defaultBrowserId();
30876
+ return {
30877
+ name: await bundleName(id),
30878
+ id
30879
+ };
30880
+ }
30881
+ if (process$1.platform === "linux") {
30882
+ const { stdout } = await execFileAsync("xdg-mime", [
30883
+ "query",
30884
+ "default",
30885
+ "x-scheme-handler/http"
30886
+ ]);
30887
+ const id = stdout.trim();
30888
+ return {
30889
+ name: titleize(id.replace(/.desktop$/, "").replace("-", " ")),
30890
+ id
30891
+ };
30892
+ }
30893
+ if (process$1.platform === "win32") return defaultBrowser$1();
30894
+ throw new Error("Only macOS, Linux, and Windows are supported");
30895
+ }
30896
+
30897
+ //#endregion
30898
+ //#region ../../node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js
30899
+ const isInSsh = Boolean(process$1.env.SSH_CONNECTION || process$1.env.SSH_CLIENT || process$1.env.SSH_TTY);
30900
+ var is_in_ssh_default = isInSsh;
30901
+
30902
+ //#endregion
30903
+ //#region ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
30904
+ const fallbackAttemptSymbol = Symbol("fallbackAttempt");
30905
+ const __dirname = import.meta.url ? path3.dirname(fileURLToPath(import.meta.url)) : "";
30906
+ const localXdgOpenPath = path3.join(__dirname, "xdg-open");
30907
+ const { platform, arch } = process$1;
30908
+ const tryEachApp = async (apps$1, opener) => {
30909
+ if (apps$1.length === 0) return;
30910
+ const errors = [];
30911
+ for (const app of apps$1) try {
30912
+ return await opener(app);
30913
+ } catch (error) {
30914
+ errors.push(error);
30915
+ }
30916
+ throw new AggregateError(errors, "Failed to open in all supported apps");
30917
+ };
30918
+ const baseOpen = async (options) => {
30919
+ options = {
30920
+ wait: false,
30921
+ background: false,
30922
+ newInstance: false,
30923
+ allowNonzeroExitCode: false,
30924
+ ...options
30925
+ };
30926
+ const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
30927
+ delete options[fallbackAttemptSymbol];
30928
+ if (Array.isArray(options.app)) return tryEachApp(options.app, (singleApp) => baseOpen({
30929
+ ...options,
30930
+ app: singleApp,
30931
+ [fallbackAttemptSymbol]: true
30932
+ }));
30933
+ let { name: app, arguments: appArguments = [] } = options.app ?? {};
30934
+ appArguments = [...appArguments];
30935
+ if (Array.isArray(app)) return tryEachApp(app, (appName) => baseOpen({
30936
+ ...options,
30937
+ app: {
30938
+ name: appName,
30939
+ arguments: appArguments
30940
+ },
30941
+ [fallbackAttemptSymbol]: true
30942
+ }));
30943
+ if (app === "browser" || app === "browserPrivate") {
30944
+ const ids = {
30945
+ "com.google.chrome": "chrome",
30946
+ "google-chrome.desktop": "chrome",
30947
+ "com.brave.browser": "brave",
30948
+ "org.mozilla.firefox": "firefox",
30949
+ "firefox.desktop": "firefox",
30950
+ "com.microsoft.msedge": "edge",
30951
+ "com.microsoft.edge": "edge",
30952
+ "com.microsoft.edgemac": "edge",
30953
+ "microsoft-edge.desktop": "edge",
30954
+ "com.apple.safari": "safari"
30955
+ };
30956
+ const flags = {
30957
+ chrome: "--incognito",
30958
+ brave: "--incognito",
30959
+ firefox: "--private-window",
30960
+ edge: "--inPrivate"
30961
+ };
30962
+ let browser;
30963
+ if (is_wsl_default) {
30964
+ const progId = await wslDefaultBrowser();
30965
+ browser = _windowsBrowserProgIdMap.get(progId) ?? {};
30966
+ } else browser = await defaultBrowser();
30967
+ if (browser.id in ids) {
30968
+ const browserName = ids[browser.id.toLowerCase()];
30969
+ if (app === "browserPrivate") {
30970
+ if (browserName === "safari") throw new Error("Safari doesn't support opening in private mode via command line");
30971
+ appArguments.push(flags[browserName]);
30972
+ }
30973
+ return baseOpen({
30974
+ ...options,
30975
+ app: {
30976
+ name: apps[browserName],
30977
+ arguments: appArguments
30978
+ }
30979
+ });
30980
+ }
30981
+ throw new Error(`${browser.name} is not supported as a default browser`);
30982
+ }
30983
+ let command;
30984
+ const cliArguments = [];
30985
+ const childProcessOptions = {};
30986
+ let shouldUseWindowsInWsl = false;
30987
+ if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) shouldUseWindowsInWsl = await canAccessPowerShell();
30988
+ if (platform === "darwin") {
30989
+ command = "open";
30990
+ if (options.wait) cliArguments.push("--wait-apps");
30991
+ if (options.background) cliArguments.push("--background");
30992
+ if (options.newInstance) cliArguments.push("--new");
30993
+ if (app) cliArguments.push("-a", app);
30994
+ } else if (platform === "win32" || shouldUseWindowsInWsl) {
30995
+ command = await powerShellPath();
30996
+ cliArguments.push(...executePowerShell.argumentsPrefix);
30997
+ if (!is_wsl_default) childProcessOptions.windowsVerbatimArguments = true;
30998
+ if (is_wsl_default && options.target) options.target = await convertWslPathToWindows(options.target);
30999
+ const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
31000
+ if (options.wait) encodedArguments.push("-Wait");
31001
+ if (app) {
31002
+ encodedArguments.push(executePowerShell.escapeArgument(app));
31003
+ if (options.target) appArguments.push(options.target);
31004
+ } else if (options.target) encodedArguments.push(executePowerShell.escapeArgument(options.target));
31005
+ if (appArguments.length > 0) {
31006
+ appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
31007
+ encodedArguments.push("-ArgumentList", appArguments.join(","));
31008
+ }
31009
+ options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
31010
+ if (!options.wait) childProcessOptions.stdio = "ignore";
31011
+ } else {
31012
+ if (app) command = app;
31013
+ else {
31014
+ const isBundled = !__dirname || __dirname === "/";
31015
+ let exeLocalXdgOpen = false;
31016
+ try {
31017
+ await fs$1.access(localXdgOpenPath, constants.X_OK);
31018
+ exeLocalXdgOpen = true;
31019
+ } catch {}
31020
+ command = process$1.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen) ? "xdg-open" : localXdgOpenPath;
31021
+ }
31022
+ if (appArguments.length > 0) cliArguments.push(...appArguments);
31023
+ if (!options.wait) {
31024
+ childProcessOptions.stdio = "ignore";
31025
+ childProcessOptions.detached = true;
31026
+ }
31027
+ }
31028
+ if (platform === "darwin" && appArguments.length > 0) cliArguments.push("--args", ...appArguments);
31029
+ if (options.target) cliArguments.push(options.target);
31030
+ const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
31031
+ if (options.wait) return new Promise((resolve$2, reject) => {
31032
+ subprocess.once("error", reject);
31033
+ subprocess.once("close", (exitCode) => {
31034
+ if (!options.allowNonzeroExitCode && exitCode !== 0) {
31035
+ reject(/* @__PURE__ */ new Error(`Exited with code ${exitCode}`));
31036
+ return;
31037
+ }
31038
+ resolve$2(subprocess);
31039
+ });
31040
+ });
31041
+ if (isFallbackAttempt) return new Promise((resolve$2, reject) => {
31042
+ subprocess.once("error", reject);
31043
+ subprocess.once("spawn", () => {
31044
+ subprocess.once("close", (exitCode) => {
31045
+ subprocess.off("error", reject);
31046
+ if (exitCode !== 0) {
31047
+ reject(/* @__PURE__ */ new Error(`Exited with code ${exitCode}`));
31048
+ return;
31049
+ }
31050
+ subprocess.unref();
31051
+ resolve$2(subprocess);
31052
+ });
31053
+ });
31054
+ });
31055
+ subprocess.unref();
31056
+ return new Promise((resolve$2, reject) => {
31057
+ subprocess.once("error", reject);
31058
+ subprocess.once("spawn", () => {
31059
+ subprocess.off("error", reject);
31060
+ resolve$2(subprocess);
31061
+ });
31062
+ });
31063
+ };
31064
+ const open = (target$1, options) => {
31065
+ if (typeof target$1 !== "string") throw new TypeError("Expected a `target`");
31066
+ return baseOpen({
31067
+ ...options,
31068
+ target: target$1
31069
+ });
31070
+ };
31071
+ function detectArchBinary(binary) {
31072
+ if (typeof binary === "string" || Array.isArray(binary)) return binary;
31073
+ const { [arch]: archBinary } = binary;
31074
+ if (!archBinary) throw new Error(`${arch} is not supported`);
31075
+ return archBinary;
31076
+ }
31077
+ function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
31078
+ if (wsl && is_wsl_default) return detectArchBinary(wsl);
31079
+ if (!platformBinary) throw new Error(`${platform} is not supported`);
31080
+ return detectArchBinary(platformBinary);
31081
+ }
31082
+ const apps = {
31083
+ browser: "browser",
31084
+ browserPrivate: "browserPrivate"
31085
+ };
31086
+ defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
31087
+ darwin: "google chrome",
31088
+ win32: "chrome",
31089
+ linux: [
31090
+ "google-chrome",
31091
+ "google-chrome-stable",
31092
+ "chromium",
31093
+ "chromium-browser"
31094
+ ]
31095
+ }, { wsl: {
31096
+ ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
31097
+ x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
31098
+ } }));
31099
+ defineLazyProperty(apps, "brave", () => detectPlatformBinary({
31100
+ darwin: "brave browser",
31101
+ win32: "brave",
31102
+ linux: ["brave-browser", "brave"]
31103
+ }, { wsl: {
31104
+ ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
31105
+ x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
31106
+ } }));
31107
+ defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
31108
+ darwin: "firefox",
31109
+ win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
31110
+ linux: "firefox"
31111
+ }, { wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe" }));
31112
+ defineLazyProperty(apps, "edge", () => detectPlatformBinary({
31113
+ darwin: "microsoft edge",
31114
+ win32: "msedge",
31115
+ linux: ["microsoft-edge", "microsoft-edge-dev"]
31116
+ }, { wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" }));
31117
+ defineLazyProperty(apps, "safari", () => detectPlatformBinary({ darwin: "Safari" }));
31118
+ var open_default = open;
31119
+
30460
31120
  //#endregion
30461
31121
  //#region src/plugins/shortcuts.ts
30462
31122
  var import_picocolors = /* @__PURE__ */ __toESM$1(require_picocolors(), 1);
@@ -30467,11 +31127,13 @@ const shortcutsPlugin = createPlugin("shortcuts", (ctx) => {
30467
31127
  if (!isCustomShortcutsSupported) return;
30468
31128
  assertIsNotPreview(ctx);
30469
31129
  addBindingsShortcut(viteDevServer, ctx);
31130
+ addExplorerShortcut(viteDevServer);
30470
31131
  },
30471
31132
  async configurePreviewServer(vitePreviewServer) {
30472
31133
  if (!isCustomShortcutsSupported) return;
30473
31134
  assertIsPreview(ctx);
30474
31135
  addBindingsShortcut(vitePreviewServer, ctx);
31136
+ addExplorerShortcut(vitePreviewServer);
30475
31137
  }
30476
31138
  };
30477
31139
  });
@@ -30504,6 +31166,30 @@ function addBindingsShortcut(server, ctx) {
30504
31166
  };
30505
31167
  server.bindCLIShortcuts({ customShortcuts: [printBindingsShortcut] });
30506
31168
  }
31169
+ function addExplorerShortcut(server) {
31170
+ if (!process.stdin.isTTY) return;
31171
+ const openExplorerShortcut = {
31172
+ key: "e",
31173
+ description: "open local explorer",
31174
+ action: async (viteServer) => {
31175
+ const url = viteServer.resolvedUrls?.local[0];
31176
+ if (!url) {
31177
+ viteServer.config.logger.warn("No local URL available");
31178
+ return;
31179
+ }
31180
+ const explorerUrl = new URL(CorePaths.EXPLORER, url).href;
31181
+ (await open_default(explorerUrl)).on("error", () => {
31182
+ viteServer.config.logger.warn("Failed to open browser, the local explorer can be accessed at " + explorerUrl);
31183
+ });
31184
+ }
31185
+ };
31186
+ const bindCLIShortcuts = server.bindCLIShortcuts.bind(server);
31187
+ server.bindCLIShortcuts = (options) => {
31188
+ if (server.httpServer && process.stdin.isTTY && !process.env.CI && options?.print) server.config.logger.info(import_picocolors.default.dim(import_picocolors.default.green(" ➜")) + import_picocolors.default.dim(" press ") + import_picocolors.default.bold(`${openExplorerShortcut.key} + enter`) + import_picocolors.default.dim(` to ${openExplorerShortcut.description}`));
31189
+ bindCLIShortcuts(options);
31190
+ };
31191
+ server.bindCLIShortcuts({ customShortcuts: [openExplorerShortcut] });
31192
+ }
30507
31193
 
30508
31194
  //#endregion
30509
31195
  //#region src/plugins/wasm.ts