@voidzero-dev/vite-plus-core 0.2.8 → 0.3.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.
Files changed (63) hide show
  1. package/LICENSE +30 -1
  2. package/dist/rolldown/cli.mjs +14 -10
  3. package/dist/rolldown/config.d.mts +1 -1
  4. package/dist/rolldown/config.mjs +2 -2
  5. package/dist/rolldown/experimental-index.d.mts +5 -5
  6. package/dist/rolldown/experimental-index.mjs +11 -9
  7. package/dist/rolldown/filter-index.d.mts +1 -1
  8. package/dist/rolldown/index.d.mts +2 -2
  9. package/dist/rolldown/index.mjs +4 -4
  10. package/dist/rolldown/parallel-plugin-worker.mjs +2 -2
  11. package/dist/rolldown/parallel-plugin.d.mts +1 -1
  12. package/dist/rolldown/parse-ast-index.d.mts +1 -1
  13. package/dist/rolldown/parse-ast-index.mjs +1 -1
  14. package/dist/rolldown/plugins-index.d.mts +3 -3
  15. package/dist/rolldown/plugins-index.mjs +2 -2
  16. package/dist/rolldown/shared/{binding-CVtkJvyl.d.mts → binding-Bvw14S3g.d.mts} +70 -1
  17. package/dist/rolldown/shared/binding-C__LJDBG.mjs +675 -0
  18. package/dist/rolldown/shared/{bindingify-input-options-B03y7DfJ.mjs → bindingify-input-options-V9YvAjrr.mjs} +6 -10
  19. package/dist/rolldown/shared/{constructors-ALilxAii.d.mts → constructors-CRumnw21.d.mts} +2 -2
  20. package/dist/rolldown/shared/{constructors-COwFYQna.mjs → constructors-DklcHr18.mjs} +1 -1
  21. package/dist/rolldown/shared/{create-bundler-option-B-tSTZRt.mjs → create-bundler-option-DbV2ud0B.mjs} +5 -4
  22. package/dist/rolldown/shared/{define-config-DSMNXceb.d.mts → define-config-DwTNhgWB.d.mts} +12 -10
  23. package/dist/rolldown/shared/{error-nLggAzpQ.mjs → error-NcRuXAVN.mjs} +1 -1
  24. package/dist/rolldown/shared/{load-config-O4G7NVNA.mjs → load-config-Dd7jKGUy.mjs} +1 -1
  25. package/dist/rolldown/shared/{normalize-string-or-regex-Cj-DgIV1.mjs → normalize-string-or-regex-CFtim40S.mjs} +1 -1
  26. package/dist/rolldown/shared/{parse-CQfUbVuN.mjs → parse-rvxTD36n.mjs} +2 -2
  27. package/dist/rolldown/shared/{resolve-tsconfig-CE3HNSOK.mjs → resolve-tsconfig-D2vSIIkR.mjs} +2 -2
  28. package/dist/rolldown/shared/{rolldown-qV_fUwyM.mjs → rolldown-Bblizyw1.mjs} +4 -4
  29. package/dist/rolldown/shared/{transform-WmU_cI8e.d.mts → transform--WSMLt1x.d.mts} +1 -1
  30. package/dist/rolldown/shared/{watch-BNIsji74.mjs → watch-DPvOlccK.mjs} +5 -5
  31. package/dist/rolldown/utils-index.d.mts +3 -3
  32. package/dist/rolldown/utils-index.mjs +15 -13
  33. package/dist/tsdown/{build-D_enfyvD-X5SFXZZc.js → build-D_enfyvD-tOzhITac.js} +1076 -20
  34. package/dist/tsdown/{debug-CKcBYQLP-avlAPNcV.js → debug-CKcBYQLP-By_AQqN8.js} +3 -3
  35. package/dist/tsdown/{detect-DGhJGEqb-CGd2brAW.js → detect-DGhJGEqb-LL52mV6u.js} +1 -1
  36. package/dist/tsdown/{dist-BZO8q3c0.js → dist-BsS7BOcb.js} +5 -5
  37. package/dist/tsdown/index-types.d.ts +4 -4
  38. package/dist/tsdown/index.js +4 -4
  39. package/dist/tsdown/internal-DSmmwu4u.js +3 -0
  40. package/dist/tsdown/{main-Jz_9T-KA.js → main-Bcv7jU2b.js} +210 -196
  41. package/dist/tsdown/npm_entry_picomatch.cjs +10 -6
  42. package/dist/tsdown/npm_entry_tree-kill.cjs +4 -2
  43. package/dist/tsdown/{resolver-cwLsPb2o-BqQjnCbF.js → resolver-cwLsPb2o-Bb9SDBm6.js} +2 -2
  44. package/dist/tsdown/run.js +6 -6
  45. package/dist/tsdown/{src-D5keKqGd.js → src-JVSpR8xt.js} +5 -5
  46. package/dist/tsdown/{target-Bab3CUeB-CERZYTwS.js → target-Bab3CUeB-8PBzMh3p.js} +5 -5
  47. package/dist/tsdown/{tsc-DmzrnJwy.js → tsc-B8FD48Oc.js} +3 -3
  48. package/dist/tsdown/tsdown-css.js +5 -5
  49. package/dist/tsdown/tsdown-exe.js +4 -4
  50. package/dist/vite/client/bundledDevClient.mjs +393 -27
  51. package/dist/vite/client/client.mjs +20 -14
  52. package/dist/vite/node/chunks/build.js +70 -64
  53. package/dist/vite/node/chunks/dist.js +36 -29
  54. package/dist/vite/node/chunks/dist2.js +193 -149
  55. package/dist/vite/node/chunks/node.js +1047 -875
  56. package/dist/vite/node/chunks/postcss-import.js +23 -25
  57. package/dist/vite/node/index.d.ts +63 -58
  58. package/dist/vite/node/module-runner.d.ts +13 -13
  59. package/dist/vite/node/module-runner.js +24 -19
  60. package/package.json +32 -26
  61. package/dist/rolldown/shared/binding-DwUQWZOo.mjs +0 -662
  62. package/dist/tsdown/dist-CMKwGGNp.js +0 -1059
  63. package/dist/tsdown/internal-DyaNxVWW.js +0 -3
@@ -1180,10 +1180,12 @@ var require_parse$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1180
1180
  }
1181
1181
  return esc ? m : `\\${m}`;
1182
1182
  });
1183
- if (backslashes === true) if (opts.unescape === true) output = output.replace(/\\/g, "");
1184
- else output = output.replace(/\\+/g, (m) => {
1185
- return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
1186
- });
1183
+ if (backslashes === true) {
1184
+ if (opts.unescape === true) output = output.replace(/\\/g, "");
1185
+ else output = output.replace(/\\+/g, (m) => {
1186
+ return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
1187
+ });
1188
+ }
1187
1189
  if (output === input && opts.contains === true) {
1188
1190
  state.output = input;
1189
1191
  return state;
@@ -1949,8 +1951,10 @@ var require_picomatch$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1949
1951
  output = format ? format(input) : input;
1950
1952
  match = output === glob;
1951
1953
  }
1952
- if (match === false || opts.capture === true) if (opts.matchBase === true || opts.basename === true) match = picomatch.matchBase(input, regex, options, posix);
1953
- else match = regex.exec(output);
1954
+ if (match === false || opts.capture === true) {
1955
+ if (opts.matchBase === true || opts.basename === true) match = picomatch.matchBase(input, regex, options, posix);
1956
+ else match = regex.exec(output);
1957
+ }
1954
1958
  return {
1955
1959
  isMatch: Boolean(match),
1956
1960
  match,
@@ -3220,7 +3224,7 @@ const importMetaResolveWithCustomHookString = `
3220
3224
  `;
3221
3225
  //#endregion
3222
3226
  //#region ../../vite/packages/vite/package.json
3223
- var version = "8.2.0";
3227
+ var version = "8.2.2";
3224
3228
  //#endregion
3225
3229
  //#region ../../vite/packages/vite/src/node/constants.ts
3226
3230
  const ROLLUP_HOOKS = [
@@ -3318,7 +3322,9 @@ const VITE_PACKAGE_DIR = path.join(fileURLToPath(
3318
3322
  import.meta.url
3319
3323
  ), "..", "..", "..", "..", "..");
3320
3324
  const CLIENT_ENTRY = path.join(VITE_PACKAGE_DIR, "dist/vite/client/client.mjs");
3321
- const BUNDLED_DEV_CLIENT_ENTRY = resolve(VITE_PACKAGE_DIR, "dist/client/bundledDevClient.mjs");
3325
+ const BUNDLED_DEV_CLIENT_ENTRY = path.join(VITE_PACKAGE_DIR, "dist/vite/client/bundledDevClient.mjs");
3326
+ /** URL filename the bundled-dev server serves the vite client under */
3327
+ const BUNDLED_DEV_CLIENT_FILENAME = "bundledDevClient.mjs";
3322
3328
  const ENV_ENTRY = path.join(VITE_PACKAGE_DIR, "dist/vite/client/env.mjs");
3323
3329
  const CLIENT_DIR = path.dirname(CLIENT_ENTRY);
3324
3330
  const KNOWN_ASSET_TYPES = [
@@ -4621,15 +4627,16 @@ function loadPackageData(pkgPath) {
4621
4627
  const { sideEffects } = data;
4622
4628
  let hasSideEffects;
4623
4629
  if (typeof sideEffects === "boolean") hasSideEffects = () => sideEffects;
4624
- else if (Array.isArray(sideEffects)) if (sideEffects.length <= 0) hasSideEffects = () => false;
4625
- else {
4626
- const finalPackageSideEffects = sideEffects.map((sideEffect) => {
4627
- if (sideEffect.includes("/")) return sideEffect;
4628
- return `**/${sideEffect}`;
4629
- });
4630
- hasSideEffects = createFilter$1(finalPackageSideEffects, null, { resolve: pkgDir });
4631
- }
4632
- else hasSideEffects = () => null;
4630
+ else if (Array.isArray(sideEffects)) {
4631
+ if (sideEffects.length <= 0) hasSideEffects = () => false;
4632
+ else {
4633
+ const finalPackageSideEffects = sideEffects.map((sideEffect) => {
4634
+ if (sideEffect.includes("/")) return sideEffect;
4635
+ return `**/${sideEffect}`;
4636
+ });
4637
+ hasSideEffects = createFilter$1(finalPackageSideEffects, null, { resolve: pkgDir });
4638
+ }
4639
+ } else hasSideEffects = () => null;
4633
4640
  const resolvedCache = {};
4634
4641
  return {
4635
4642
  dir: pkgDir,
@@ -5839,7 +5846,8 @@ function formatAndTruncateFileList(files) {
5839
5846
  truncated
5840
5847
  };
5841
5848
  }
5842
- const hashbangRE = /^#!.*\n/;
5849
+ const lineTerminatorRE = /[\r\n\u2028\u2029]$/;
5850
+ const hashbangRE = /^#![^\r\n\u2028\u2029]*(?:\r\n|[\r\n\u2028\u2029])?/;
5843
5851
  function getFileStartIndex(code) {
5844
5852
  return hashbangRE.exec(code)?.[0].length ?? 0;
5845
5853
  }
@@ -5917,18 +5925,19 @@ function createLogger(level = "info", options = {}) {
5917
5925
  if (thresh >= LogLevels[type]) {
5918
5926
  const method = type === "info" ? "log" : type;
5919
5927
  if (options.error) loggedErrors.add(options.error);
5920
- if (canClearScreen) if (type === lastType && msg === lastMsg) {
5921
- sameCount++;
5922
- clear();
5923
- console[method](format(type, msg, options), import_picocolors.default.yellow(`(x${sameCount + 1})`));
5924
- } else {
5925
- sameCount = 0;
5926
- lastMsg = msg;
5927
- lastType = type;
5928
- if (options.clear) clear();
5929
- console[method](format(type, msg, options));
5930
- }
5931
- else console[method](format(type, msg, options));
5928
+ if (canClearScreen) {
5929
+ if (type === lastType && msg === lastMsg) {
5930
+ sameCount++;
5931
+ clear();
5932
+ console[method](format(type, msg, options), import_picocolors.default.yellow(`(x${sameCount + 1})`));
5933
+ } else {
5934
+ sameCount = 0;
5935
+ lastMsg = msg;
5936
+ lastType = type;
5937
+ if (options.clear) clear();
5938
+ console[method](format(type, msg, options));
5939
+ }
5940
+ } else console[method](format(type, msg, options));
5932
5941
  }
5933
5942
  }
5934
5943
  const warnedMessages = /* @__PURE__ */ new Set();
@@ -6164,22 +6173,24 @@ function resolveEsbuildTranspileOptions(config, format) {
6164
6173
  minifyWhitespace: false,
6165
6174
  treeShaking: false
6166
6175
  };
6167
- if (options.minifyIdentifiers != null || options.minifySyntax != null || options.minifyWhitespace != null) if (isEsLibBuild) return {
6168
- ...options,
6169
- minify: false,
6170
- minifyIdentifiers: options.minifyIdentifiers ?? true,
6171
- minifySyntax: options.minifySyntax ?? true,
6172
- minifyWhitespace: false,
6173
- treeShaking: true
6174
- };
6175
- else return {
6176
- ...options,
6177
- minify: false,
6178
- minifyIdentifiers: options.minifyIdentifiers ?? true,
6179
- minifySyntax: options.minifySyntax ?? true,
6180
- minifyWhitespace: options.minifyWhitespace ?? true,
6181
- treeShaking: true
6182
- };
6176
+ if (options.minifyIdentifiers != null || options.minifySyntax != null || options.minifyWhitespace != null) {
6177
+ if (isEsLibBuild) return {
6178
+ ...options,
6179
+ minify: false,
6180
+ minifyIdentifiers: options.minifyIdentifiers ?? true,
6181
+ minifySyntax: options.minifySyntax ?? true,
6182
+ minifyWhitespace: false,
6183
+ treeShaking: true
6184
+ };
6185
+ else return {
6186
+ ...options,
6187
+ minify: false,
6188
+ minifyIdentifiers: options.minifyIdentifiers ?? true,
6189
+ minifySyntax: options.minifySyntax ?? true,
6190
+ minifyWhitespace: options.minifyWhitespace ?? true,
6191
+ treeShaking: true
6192
+ };
6193
+ }
6183
6194
  if (isEsLibBuild) return {
6184
6195
  ...options,
6185
6196
  minify: false,
@@ -6883,7 +6894,7 @@ function warnDeprecatedShouldBeConvertedToPluginOptions(logger, name) {
6883
6894
  logger.warn(import_picocolors.default.yellow(`\`esbuild.${name}\` option was specified. But this option is deprecated and will be removed in future versions. This option can be achieved by using a plugin with transform hook, please use that instead.`));
6884
6895
  }
6885
6896
  //#endregion
6886
- //#region ../../node_modules/.pnpm/magic-string@1.1.0/node_modules/magic-string/dist/index.mjs
6897
+ //#region ../../node_modules/.pnpm/magic-string@1.2.1/node_modules/magic-string/dist/index.mjs
6887
6898
  var BitSet = class BitSet {
6888
6899
  constructor(arg) {
6889
6900
  this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
@@ -7021,12 +7032,24 @@ var Chunk = class Chunk {
7021
7032
  }
7022
7033
  }
7023
7034
  };
7035
+ /**
7036
+ * The single error type thrown by MagicString.
7037
+ *
7038
+ * Every message is prefixed with `[MagicString]` so its source is obvious at a
7039
+ * glance, and is kept short and consistent in tone.
7040
+ */
7041
+ var MagicStringError = class extends Error {
7042
+ name = "MagicStringError";
7043
+ constructor(message, options) {
7044
+ super(`[MagicString] ${message}`, options);
7045
+ }
7046
+ };
7024
7047
  function getBtoa() {
7025
7048
  if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
7026
7049
  const buffer = globalThis["Buffer"];
7027
7050
  if (buffer) return (str) => buffer.from(str, "utf-8").toString("base64");
7028
7051
  return () => {
7029
- throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
7052
+ throw new MagicStringError("unsupported environment: `btoa` or `Buffer` is required");
7030
7053
  };
7031
7054
  }
7032
7055
  const btoa$1 = /* #__PURE__ */ getBtoa();
@@ -7243,11 +7266,11 @@ var MagicString = class MagicString {
7243
7266
  },
7244
7267
  byStart: {
7245
7268
  writable: true,
7246
- value: {}
7269
+ value: /* @__PURE__ */ new Map([[0, chunk]])
7247
7270
  },
7248
7271
  byEnd: {
7249
7272
  writable: true,
7250
- value: {}
7273
+ value: /* @__PURE__ */ new Map([[string.length, chunk]])
7251
7274
  },
7252
7275
  filename: {
7253
7276
  writable: true,
@@ -7276,10 +7299,12 @@ var MagicString = class MagicString {
7276
7299
  offset: {
7277
7300
  writable: true,
7278
7301
  value: options.offset || 0
7302
+ },
7303
+ hasMovedChunks: {
7304
+ writable: true,
7305
+ value: false
7279
7306
  }
7280
7307
  });
7281
- this.byStart = /* @__PURE__ */ new Map([[0, chunk]]);
7282
- this.byEnd = /* @__PURE__ */ new Map([[string.length, chunk]]);
7283
7308
  }
7284
7309
  /**
7285
7310
  * Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is false.
@@ -7291,7 +7316,7 @@ var MagicString = class MagicString {
7291
7316
  * Appends the specified content to the end of the string.
7292
7317
  */
7293
7318
  append(content) {
7294
- if (typeof content !== "string") throw new TypeError("outro content must be a string");
7319
+ if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
7295
7320
  this.outro += content;
7296
7321
  return this;
7297
7322
  }
@@ -7302,7 +7327,7 @@ var MagicString = class MagicString {
7302
7327
  */
7303
7328
  appendLeft(index, content) {
7304
7329
  index = index + this.offset;
7305
- if (typeof content !== "string") throw new TypeError("inserted content must be a string");
7330
+ if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
7306
7331
  this._split(index);
7307
7332
  const chunk = this.byEnd.get(index);
7308
7333
  if (chunk) chunk.appendLeft(content);
@@ -7316,7 +7341,7 @@ var MagicString = class MagicString {
7316
7341
  */
7317
7342
  appendRight(index, content) {
7318
7343
  index = index + this.offset;
7319
- if (typeof content !== "string") throw new TypeError("inserted content must be a string");
7344
+ if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
7320
7345
  this._split(index);
7321
7346
  const chunk = this.byStart.get(index);
7322
7347
  if (chunk) chunk.appendRight(content);
@@ -7350,6 +7375,7 @@ var MagicString = class MagicString {
7350
7375
  cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
7351
7376
  cloned.intro = this.intro;
7352
7377
  cloned.outro = this.outro;
7378
+ cloned.hasMovedChunks = this.hasMovedChunks;
7353
7379
  return cloned;
7354
7380
  }
7355
7381
  /**
@@ -7478,7 +7504,7 @@ var MagicString = class MagicString {
7478
7504
  }
7479
7505
  /** @internal */
7480
7506
  insert() {
7481
- throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)");
7507
+ throw new MagicStringError("insert() is deprecated, use appendLeft() or prependRight()");
7482
7508
  }
7483
7509
  /** @internal */
7484
7510
  insertLeft(index, content) {
@@ -7504,12 +7530,19 @@ var MagicString = class MagicString {
7504
7530
  end = end + this.offset;
7505
7531
  index = index + this.offset;
7506
7532
  if (start === end) return this;
7507
- if (index >= start && index <= end) throw new Error("Cannot move a selection inside itself");
7533
+ if (index >= start && index <= end) throw new MagicStringError("cannot move a selection inside itself");
7508
7534
  this._split(start);
7509
7535
  this._split(end);
7510
7536
  this._split(index);
7511
7537
  const first = this.byStart.get(start);
7512
7538
  const last = this.byEnd.get(end);
7539
+ if (this.hasMovedChunks) {
7540
+ let cursor = first;
7541
+ while (cursor !== last) {
7542
+ cursor = cursor.next;
7543
+ if (!cursor || cursor.start < start || cursor.end > end) throw new MagicStringError(`cannot move ${start} to ${end} because an earlier move split that range`);
7544
+ }
7545
+ }
7513
7546
  const oldLeft = first.previous;
7514
7547
  const oldRight = last.next;
7515
7548
  const newRight = this.byStart.get(index);
@@ -7528,6 +7561,7 @@ var MagicString = class MagicString {
7528
7561
  last.next = newRight || null;
7529
7562
  if (!newLeft) this.firstChunk = first;
7530
7563
  if (!newRight) this.lastChunk = last;
7564
+ this.hasMovedChunks = true;
7531
7565
  return this;
7532
7566
  }
7533
7567
  /**
@@ -7557,13 +7591,15 @@ var MagicString = class MagicString {
7557
7591
  update(start, end, content, options) {
7558
7592
  start = start + this.offset;
7559
7593
  end = end + this.offset;
7560
- if (typeof content !== "string") throw new TypeError("replacement content must be a string");
7594
+ if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
7561
7595
  if (this.original.length !== 0) {
7562
7596
  while (start < 0) start += this.original.length;
7563
7597
  while (end < 0) end += this.original.length;
7564
7598
  }
7565
- if (end > this.original.length) throw new Error("end is out of bounds");
7566
- if (start === end) throw new Error("Cannot overwrite a zero-length range – use appendLeft or prependRight instead");
7599
+ if (start < 0) throw new MagicStringError(`start ${start} is out of bounds`);
7600
+ if (end > this.original.length) throw new MagicStringError(`end ${end} is out of bounds`);
7601
+ if (start === end) throw new MagicStringError(`cannot overwrite a zero-length range at ${start}, use appendLeft() or prependRight()`);
7602
+ if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
7567
7603
  this._split(start);
7568
7604
  this._split(end);
7569
7605
  if (options === true) {
@@ -7589,7 +7625,7 @@ var MagicString = class MagicString {
7589
7625
  if (first) {
7590
7626
  let chunk = first;
7591
7627
  while (chunk !== last) {
7592
- if (chunk.next !== this.byStart.get(chunk.end)) throw new Error("Cannot overwrite across a split point");
7628
+ if (chunk.next !== this.byStart.get(chunk.end)) throw new MagicStringError("cannot overwrite across a split point");
7593
7629
  chunk = chunk.next;
7594
7630
  chunk.edit("", false);
7595
7631
  }
@@ -7605,7 +7641,7 @@ var MagicString = class MagicString {
7605
7641
  * Prepends the string with the specified content.
7606
7642
  */
7607
7643
  prepend(content) {
7608
- if (typeof content !== "string") throw new TypeError("outro content must be a string");
7644
+ if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
7609
7645
  this.intro = content + this.intro;
7610
7646
  return this;
7611
7647
  }
@@ -7614,7 +7650,7 @@ var MagicString = class MagicString {
7614
7650
  */
7615
7651
  prependLeft(index, content) {
7616
7652
  index = index + this.offset;
7617
- if (typeof content !== "string") throw new TypeError("inserted content must be a string");
7653
+ if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
7618
7654
  this._split(index);
7619
7655
  const chunk = this.byEnd.get(index);
7620
7656
  if (chunk) chunk.prependLeft(content);
@@ -7626,7 +7662,7 @@ var MagicString = class MagicString {
7626
7662
  */
7627
7663
  prependRight(index, content) {
7628
7664
  index = index + this.offset;
7629
- if (typeof content !== "string") throw new TypeError("inserted content must be a string");
7665
+ if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
7630
7666
  this._split(index);
7631
7667
  const chunk = this.byStart.get(index);
7632
7668
  if (chunk) chunk.prependRight(content);
@@ -7645,8 +7681,8 @@ var MagicString = class MagicString {
7645
7681
  while (end < 0) end += this.original.length;
7646
7682
  }
7647
7683
  if (start === end) return this;
7648
- if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
7649
- if (start > end) throw new Error("end must be greater than start");
7684
+ if (start < 0 || end > this.original.length) throw new MagicStringError(`range ${start}–${end} is out of bounds`);
7685
+ if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
7650
7686
  this._split(start);
7651
7687
  this._split(end);
7652
7688
  let chunk = this.byStart.get(start);
@@ -7669,8 +7705,8 @@ var MagicString = class MagicString {
7669
7705
  while (end < 0) end += this.original.length;
7670
7706
  }
7671
7707
  if (start === end) return this;
7672
- if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
7673
- if (start > end) throw new Error("end must be greater than start");
7708
+ if (start < 0 || end > this.original.length) throw new MagicStringError(`range ${start}–${end} is out of bounds`);
7709
+ if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
7674
7710
  this._split(start);
7675
7711
  this._split(end);
7676
7712
  let chunk = this.byStart.get(start);
@@ -7736,12 +7772,12 @@ var MagicString = class MagicString {
7736
7772
  if (chunk.start < end && chunk.end >= end) return result;
7737
7773
  chunk = chunk.next;
7738
7774
  }
7739
- if (chunk && chunk.edited && chunk.start !== start) throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
7775
+ if (chunk && chunk.edited && chunk.start !== start) throw new MagicStringError(`cannot use edited character ${start} as slice start anchor`);
7740
7776
  const startChunk = chunk;
7741
7777
  while (chunk) {
7742
7778
  if (chunk.intro && (startChunk !== chunk || chunk.start === start)) result += chunk.intro;
7743
7779
  const containsEnd = chunk.start < end && chunk.end >= end;
7744
- if (containsEnd && chunk.edited && chunk.end !== end) throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
7780
+ if (containsEnd && chunk.edited && chunk.end !== end) throw new MagicStringError(`cannot use edited character ${end} as slice end anchor`);
7745
7781
  const sliceStart = startChunk === chunk ? start - chunk.start : 0;
7746
7782
  const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
7747
7783
  result += chunk.content.slice(sliceStart, sliceEnd);
@@ -7777,7 +7813,7 @@ var MagicString = class MagicString {
7777
7813
  _splitChunk(chunk, index) {
7778
7814
  if (chunk.edited && chunk.content.length) {
7779
7815
  const loc = getLocator(this.original)(index);
7780
- throw new Error(`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`);
7816
+ throw new MagicStringError(`cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`);
7781
7817
  }
7782
7818
  const newChunk = chunk.split(index);
7783
7819
  this.byEnd.set(index, chunk);
@@ -7959,7 +7995,7 @@ var MagicString = class MagicString {
7959
7995
  */
7960
7996
  replaceAll(searchValue, replacement) {
7961
7997
  if (typeof searchValue === "string") return this._replaceAllString(searchValue, replacement);
7962
- if (!searchValue.global) throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");
7998
+ if (!searchValue.global) throw new MagicStringError("replaceAll() requires a global RegExp");
7963
7999
  return this._replaceRegexp(searchValue, replacement);
7964
8000
  }
7965
8001
  };
@@ -8218,10 +8254,12 @@ codes.ERR_INVALID_ARG_TYPE = createError(
8218
8254
  message += `an instance of ${formatList(instances, "or")}`;
8219
8255
  if (other.length > 0) message += " or ";
8220
8256
  }
8221
- if (other.length > 0) if (other.length > 1) message += `one of ${formatList(other, "or")}`;
8222
- else {
8223
- if (other[0].toLowerCase() !== other[0]) message += "an ";
8224
- message += `${other[0]}`;
8257
+ if (other.length > 0) {
8258
+ if (other.length > 1) message += `one of ${formatList(other, "or")}`;
8259
+ else {
8260
+ if (other[0].toLowerCase() !== other[0]) message += "an ";
8261
+ message += `${other[0]}`;
8262
+ }
8225
8263
  }
8226
8264
  message += `. Received ${determineSpecificType(actual)}`;
8227
8265
  return message;
@@ -8515,9 +8553,10 @@ var import_main = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
8515
8553
  defaultValue = r.join(splitter);
8516
8554
  value = env[key];
8517
8555
  }
8518
- if (value) if (seen.has(value)) result = result.replace(template, defaultValue);
8519
- else result = result.replace(template, value);
8520
- else result = result.replace(template, defaultValue);
8556
+ if (value) {
8557
+ if (seen.has(value)) result = result.replace(template, defaultValue);
8558
+ else result = result.replace(template, value);
8559
+ } else result = result.replace(template, defaultValue);
8521
8560
  if (result === runningParsed[key]) break;
8522
8561
  regex.lastIndex = 0;
8523
8562
  }
@@ -8826,7 +8865,7 @@ var require_ms$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8826
8865
  }
8827
8866
  }));
8828
8867
  //#endregion
8829
- //#region ../../node_modules/.pnpm/debug@2.6.9/node_modules/debug/src/debug.js
8868
+ //#region ../../node_modules/.pnpm/debug@2.6.9_supports-color@8.1.1/node_modules/debug/src/debug.js
8830
8869
  var require_debug$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8831
8870
  /**
8832
8871
  * This is the common logic for both the Node.js and web browser
@@ -8965,7 +9004,7 @@ var require_debug$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8965
9004
  }
8966
9005
  }));
8967
9006
  //#endregion
8968
- //#region ../../node_modules/.pnpm/debug@2.6.9/node_modules/debug/src/browser.js
9007
+ //#region ../../node_modules/.pnpm/debug@2.6.9_supports-color@8.1.1/node_modules/debug/src/browser.js
8969
9008
  var require_browser$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8970
9009
  /**
8971
9010
  * This is the web browser implementation of `debug()`.
@@ -9087,7 +9126,7 @@ var require_browser$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9087
9126
  }
9088
9127
  }));
9089
9128
  //#endregion
9090
- //#region ../../node_modules/.pnpm/debug@2.6.9/node_modules/debug/src/node.js
9129
+ //#region ../../node_modules/.pnpm/debug@2.6.9_supports-color@8.1.1/node_modules/debug/src/node.js
9091
9130
  var require_node$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9092
9131
  /**
9093
9132
  * Module dependencies.
@@ -9259,7 +9298,7 @@ var require_node$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9259
9298
  exports.enable(load());
9260
9299
  }));
9261
9300
  //#endregion
9262
- //#region ../../node_modules/.pnpm/debug@2.6.9/node_modules/debug/src/index.js
9301
+ //#region ../../node_modules/.pnpm/debug@2.6.9_supports-color@8.1.1/node_modules/debug/src/index.js
9263
9302
  var require_src$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9264
9303
  /**
9265
9304
  * Detect Electron renderer process, which is node, but we should
@@ -9898,7 +9937,7 @@ var require_unpipe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9898
9937
  }
9899
9938
  }));
9900
9939
  //#endregion
9901
- //#region ../../node_modules/.pnpm/finalhandler@1.1.2/node_modules/finalhandler/index.js
9940
+ //#region ../../node_modules/.pnpm/finalhandler@1.1.2_supports-color@8.1.1/node_modules/finalhandler/index.js
9902
9941
  /*!
9903
9942
  * finalhandler
9904
9943
  * Copyright(c) 2014-2017 Douglas Christopher Wilson
@@ -10138,7 +10177,7 @@ var require_utils_merge = /* @__PURE__ */ __commonJSMin(((exports, module) => {
10138
10177
  };
10139
10178
  }));
10140
10179
  //#endregion
10141
- //#region ../../node_modules/.pnpm/connect@3.7.0/node_modules/connect/index.js
10180
+ //#region ../../node_modules/.pnpm/connect@3.7.0_supports-color@8.1.1/node_modules/connect/index.js
10142
10181
  /*!
10143
10182
  * connect
10144
10183
  * Copyright(c) 2010 Sencha Inc.
@@ -11363,10 +11402,12 @@ var require_parse$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11363
11402
  }
11364
11403
  return esc ? m : `\\${m}`;
11365
11404
  });
11366
- if (backslashes === true) if (opts.unescape === true) output = output.replace(/\\/g, "");
11367
- else output = output.replace(/\\+/g, (m) => {
11368
- return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
11369
- });
11405
+ if (backslashes === true) {
11406
+ if (opts.unescape === true) output = output.replace(/\\/g, "");
11407
+ else output = output.replace(/\\+/g, (m) => {
11408
+ return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
11409
+ });
11410
+ }
11370
11411
  if (output === input && opts.contains === true) {
11371
11412
  state.output = input;
11372
11413
  return state;
@@ -12123,8 +12164,10 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12123
12164
  output = format ? format(input) : input;
12124
12165
  match = output === glob;
12125
12166
  }
12126
- if (match === false || opts.capture === true) if (opts.matchBase === true || opts.basename === true) match = picomatch.matchBase(input, regex, options, posix);
12127
- else match = regex.exec(output);
12167
+ if (match === false || opts.capture === true) {
12168
+ if (opts.matchBase === true || opts.basename === true) match = picomatch.matchBase(input, regex, options, posix);
12169
+ else match = regex.exec(output);
12170
+ }
12128
12171
  return {
12129
12172
  isMatch: Boolean(match),
12130
12173
  match,
@@ -14875,17 +14918,18 @@ var require_fsevents_handler = /* @__PURE__ */ __commonJSMin(((exports, module)
14875
14918
  const parent = sysPath$1.dirname(path);
14876
14919
  const item = sysPath$1.basename(path);
14877
14920
  const watchedDir = this.fsw._getWatchedDir(info.type === FSEVENT_TYPE_DIRECTORY ? path : parent);
14878
- if (wrongEventFlags.has(flags) || info.event === FSEVENT_UNKNOWN) if (typeof opts.ignored === FUNCTION_TYPE) {
14879
- let stats;
14880
- try {
14881
- stats = await stat(path);
14882
- } catch (error) {}
14883
- if (this.fsw.closed) return;
14884
- if (this.checkIgnored(path, stats)) return;
14885
- if (sameTypes(info, stats)) this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts);
14886
- else this.handleEvent(EV_UNLINK, path, fullPath, realPath, parent, watchedDir, item, info, opts);
14887
- } else this.checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts);
14888
- else switch (info.event) {
14921
+ if (wrongEventFlags.has(flags) || info.event === FSEVENT_UNKNOWN) {
14922
+ if (typeof opts.ignored === FUNCTION_TYPE) {
14923
+ let stats;
14924
+ try {
14925
+ stats = await stat(path);
14926
+ } catch (error) {}
14927
+ if (this.fsw.closed) return;
14928
+ if (this.checkIgnored(path, stats)) return;
14929
+ if (sameTypes(info, stats)) this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts);
14930
+ else this.handleEvent(EV_UNLINK, path, fullPath, realPath, parent, watchedDir, item, info, opts);
14931
+ } else this.checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts);
14932
+ } else switch (info.event) {
14889
14933
  case FSEVENT_CREATED:
14890
14934
  case FSEVENT_MODIFIED: return this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts);
14891
14935
  case FSEVENT_DELETED:
@@ -14989,13 +15033,15 @@ var require_fsevents_handler = /* @__PURE__ */ __commonJSMin(((exports, module)
14989
15033
  this.fsw._emitReady();
14990
15034
  }
14991
15035
  }
14992
- if (opts.persistent && forceAdd !== true) if (typeof transform === FUNCTION_TYPE) this.initWatch(void 0, path, wh, processPath);
14993
- else {
14994
- let realPath;
14995
- try {
14996
- realPath = await realpath(wh.watchPath);
14997
- } catch (e) {}
14998
- this.initWatch(realPath, path, wh, processPath);
15036
+ if (opts.persistent && forceAdd !== true) {
15037
+ if (typeof transform === FUNCTION_TYPE) this.initWatch(void 0, path, wh, processPath);
15038
+ else {
15039
+ let realPath;
15040
+ try {
15041
+ realPath = await realpath(wh.watchPath);
15042
+ } catch (e) {}
15043
+ this.initWatch(realPath, path, wh, processPath);
15044
+ }
14999
15045
  }
15000
15046
  }
15001
15047
  };
@@ -15833,16 +15879,17 @@ var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15833
15879
  if (esc) {
15834
15880
  out += c;
15835
15881
  esc = false;
15836
- } else if (quote) if (c === quote) quote = false;
15837
- else if (quote == SQ) out += c;
15838
- else if (c === BS) {
15839
- i += 1;
15840
- c = s.charAt(i);
15841
- if (c === DQ || c === BS || c === DS) out += c;
15842
- else out += BS + c;
15843
- } else if (c === DS) out += parseEnvVar();
15844
- else out += c;
15845
- else if (c === DQ || c === SQ) quote = c;
15882
+ } else if (quote) {
15883
+ if (c === quote) quote = false;
15884
+ else if (quote == SQ) out += c;
15885
+ else if (c === BS) {
15886
+ i += 1;
15887
+ c = s.charAt(i);
15888
+ if (c === DQ || c === BS || c === DS) out += c;
15889
+ else out += BS + c;
15890
+ } else if (c === DS) out += parseEnvVar();
15891
+ else out += c;
15892
+ } else if (c === DQ || c === SQ) quote = c;
15846
15893
  else if (controlRE.test(c)) return { op: s };
15847
15894
  else if (hash.test(c)) {
15848
15895
  commented = true;
@@ -16276,7 +16323,7 @@ var require_launch_editor_middleware = /* @__PURE__ */ __commonJSMin(((exports,
16276
16323
  };
16277
16324
  }));
16278
16325
  //#endregion
16279
- //#region ../../node_modules/.pnpm/@vercel+detect-agent@1.2.3/node_modules/@vercel/detect-agent/dist/index.js
16326
+ //#region ../../node_modules/.pnpm/@vercel+detect-agent@1.2.5/node_modules/@vercel/detect-agent/dist/index.js
16280
16327
  var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
16281
16328
  var __defProp = Object.defineProperty;
16282
16329
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -16453,6 +16500,22 @@ async function readFileIfExists(value) {
16453
16500
  if (typeof value === "string") return fsp.readFile(path.resolve(value)).catch(() => value);
16454
16501
  return value;
16455
16502
  }
16503
+ async function getAvailableEphemeralPort(specifiedHost) {
16504
+ for (let attempt = 0; attempt < 3; attempt++) {
16505
+ let port = 0;
16506
+ let available = true;
16507
+ for (const host of [...wildcardHosts, specifiedHost]) {
16508
+ const availablePort = await tryListen(port, host).catch(() => port);
16509
+ if (availablePort == null) {
16510
+ available = false;
16511
+ break;
16512
+ }
16513
+ port = availablePort;
16514
+ }
16515
+ if (available) return port;
16516
+ }
16517
+ return null;
16518
+ }
16456
16519
  async function isPortAvailable(port) {
16457
16520
  for (const host of wildcardHosts) if (!await tryListen(port, host).catch(() => true)) return false;
16458
16521
  return true;
@@ -16461,10 +16524,11 @@ function tryListen(port, host) {
16461
16524
  return new Promise((resolve) => {
16462
16525
  const server = net.createServer();
16463
16526
  server.once("error", (e) => {
16464
- server.close(() => resolve(e.code !== "EADDRINUSE"));
16527
+ server.close(() => resolve(e.code === "EADDRINUSE" ? null : port));
16465
16528
  });
16466
16529
  server.once("listening", () => {
16467
- server.close(() => resolve(true));
16530
+ const address = server.address();
16531
+ server.close(() => resolve(typeof address === "object" && address ? address.port : port));
16468
16532
  });
16469
16533
  server.listen(port, host);
16470
16534
  });
@@ -16492,6 +16556,14 @@ async function tryBindServer(httpServer, port, host) {
16492
16556
  const MAX_PORT = 65535;
16493
16557
  async function httpServerStart(httpServer, serverOptions) {
16494
16558
  const { port: startPort, strictPort, host, logger } = serverOptions;
16559
+ if (startPort === 0) {
16560
+ const port = await getAvailableEphemeralPort(host);
16561
+ if (port == null) throw new Error("No available ephemeral port found");
16562
+ const result = await tryBindServer(httpServer, port, host);
16563
+ if (result.success) return port;
16564
+ if (result.error.code !== "EADDRINUSE") throw result.error;
16565
+ throw new Error(`Port ${port} is already in use`);
16566
+ }
16495
16567
  for (let port = startPort; port <= MAX_PORT; port++) {
16496
16568
  const portAvailableOnWildcard = await isPortAvailable(port);
16497
16569
  if (strictPort) {
@@ -16776,10 +16848,12 @@ var WalkerBase = class {
16776
16848
  * @param {Node} node
16777
16849
  */
16778
16850
  replace(parent, prop, index, node) {
16779
- if (parent && prop) if (index != null)
16851
+ if (parent && prop) {
16852
+ if (index != null)
16780
16853
  /** @type {Array<Node>} */ parent[prop][index] = node;
16781
- else
16854
+ else
16782
16855
  /** @type {Node} */ parent[prop] = node;
16856
+ }
16783
16857
  }
16784
16858
  /**
16785
16859
  * @template {Node} Parent
@@ -16788,9 +16862,11 @@ var WalkerBase = class {
16788
16862
  * @param {number | null | undefined} index
16789
16863
  */
16790
16864
  remove(parent, prop, index) {
16791
- if (parent && prop) if (index !== null && index !== void 0)
16865
+ if (parent && prop) {
16866
+ if (index !== null && index !== void 0)
16792
16867
  /** @type {Array<Node>} */ parent[prop].splice(index, 1);
16793
- else delete parent[prop];
16868
+ else delete parent[prop];
16869
+ }
16794
16870
  }
16795
16871
  };
16796
16872
  //#endregion
@@ -17018,45 +17094,50 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
17018
17094
  if (s.type === "ImportSpecifier") return getIdentifierNameOrLiteralValue$1(s.imported);
17019
17095
  else if (s.type === "ImportDefaultSpecifier") return "default";
17020
17096
  }).filter(isDefined) });
17021
- for (const spec of node.specifiers) if (spec.type === "ImportSpecifier") if (spec.imported.type === "Identifier") idToImportMap.set(spec.local.name, `${importId}.${spec.imported.name}`);
17022
- else idToImportMap.set(spec.local.name, `${importId}[${JSON.stringify(spec.imported.value)}]`);
17023
- else if (spec.type === "ImportDefaultSpecifier") idToImportMap.set(spec.local.name, `${importId}.default`);
17097
+ for (const spec of node.specifiers) if (spec.type === "ImportSpecifier") {
17098
+ if (spec.imported.type === "Identifier") idToImportMap.set(spec.local.name, `${importId}.${spec.imported.name}`);
17099
+ else idToImportMap.set(spec.local.name, `${importId}[${JSON.stringify(spec.imported.value)}]`);
17100
+ } else if (spec.type === "ImportDefaultSpecifier") idToImportMap.set(spec.local.name, `${importId}.default`);
17024
17101
  else idToImportMap.set(spec.local.name, importId);
17025
17102
  }
17026
17103
  for (const node of exports) {
17027
- if (node.type === "ExportNamedDeclaration") if (node.declaration) {
17028
- if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") defineExport(node.declaration.id.name);
17029
- else {
17030
- const declaration = node.declaration;
17031
- for (const decl of declaration.declarations) {
17032
- const names = extract_names(decl.id);
17033
- for (const name of names) defineExport(name);
17104
+ if (node.type === "ExportNamedDeclaration") {
17105
+ if (node.declaration) {
17106
+ if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") defineExport(node.declaration.id.name);
17107
+ else {
17108
+ const declaration = node.declaration;
17109
+ for (const decl of declaration.declarations) {
17110
+ const names = extract_names(decl.id);
17111
+ for (const name of names) defineExport(name);
17112
+ }
17113
+ }
17114
+ s.remove(node.start, node.declaration.start);
17115
+ } else if (node.source) {
17116
+ const importId = reExportImportIdMap.get(node);
17117
+ for (const spec of node.specifiers) {
17118
+ const exportedAs = getIdentifierNameOrLiteralValue$1(spec.exported);
17119
+ if (spec.local.type === "Identifier") defineExport(exportedAs, `${importId}.${spec.local.name}`);
17120
+ else defineExport(exportedAs, `${importId}[${JSON.stringify(spec.local.value)}]`);
17121
+ }
17122
+ } else {
17123
+ s.remove(node.start, node.end);
17124
+ for (const spec of node.specifiers) {
17125
+ const local = spec.local.name;
17126
+ const binding = idToImportMap.get(local);
17127
+ defineExport(getIdentifierNameOrLiteralValue$1(spec.exported), binding || local);
17034
17128
  }
17035
- }
17036
- s.remove(node.start, node.declaration.start);
17037
- } else if (node.source) {
17038
- const importId = reExportImportIdMap.get(node);
17039
- for (const spec of node.specifiers) {
17040
- const exportedAs = getIdentifierNameOrLiteralValue$1(spec.exported);
17041
- if (spec.local.type === "Identifier") defineExport(exportedAs, `${importId}.${spec.local.name}`);
17042
- else defineExport(exportedAs, `${importId}[${JSON.stringify(spec.local.value)}]`);
17043
- }
17044
- } else {
17045
- s.remove(node.start, node.end);
17046
- for (const spec of node.specifiers) {
17047
- const local = spec.local.name;
17048
- const binding = idToImportMap.get(local);
17049
- defineExport(getIdentifierNameOrLiteralValue$1(spec.exported), binding || local);
17050
17129
  }
17051
17130
  }
17052
- if (node.type === "ExportDefaultDeclaration") if ("id" in node.declaration && node.declaration.id && !["FunctionExpression", "ClassExpression"].includes(node.declaration.type)) {
17053
- const { name } = node.declaration.id;
17054
- s.remove(node.start, node.start + 15);
17055
- defineExport("default", name);
17056
- } else {
17057
- const name = `__vite_ssr_export_default__`;
17058
- s.update(node.start, node.start + 14, `const ${name} =`);
17059
- defineExport("default", name);
17131
+ if (node.type === "ExportDefaultDeclaration") {
17132
+ if ("id" in node.declaration && node.declaration.id && !["FunctionExpression", "ClassExpression"].includes(node.declaration.type)) {
17133
+ const { name } = node.declaration.id;
17134
+ s.remove(node.start, node.start + 15);
17135
+ defineExport("default", name);
17136
+ } else {
17137
+ const name = `__vite_ssr_export_default__`;
17138
+ s.update(node.start, node.start + 14, `const ${name} =`);
17139
+ defineExport("default", name);
17140
+ }
17060
17141
  }
17061
17142
  if (node.type === "ExportAllDeclaration") {
17062
17143
  const importId = reExportImportIdMap.get(node);
@@ -17082,15 +17163,16 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
17082
17163
  const topNode = parentStack[parentStack.length - 2];
17083
17164
  s.prependRight(topNode.start, `const ${id.name} = ${binding};\n`);
17084
17165
  }
17085
- } else if (parent.type === "CallExpression") if (id === parent.callee && !parent.optional) {
17086
- const argsStart = parent.arguments.length ? parent.arguments[0].start : parent.end;
17087
- s.update(id.start, argsStart, `(0,${binding})${code.slice(id.end, argsStart)}`);
17088
- } else {
17089
- s.update(id.start, id.end, binding);
17090
- s.prependRight(id.start, `(0,`);
17091
- s.appendLeft(id.end, `)`);
17092
- }
17093
- else if (!(parent.type === "ClassExpression" && id === parent.id)) s.update(id.start, id.end, binding);
17166
+ } else if (parent.type === "CallExpression") {
17167
+ if (id === parent.callee && !parent.optional) {
17168
+ const argsStart = parent.arguments.length ? parent.arguments[0].start : parent.end;
17169
+ s.update(id.start, argsStart, `(0,${binding})${code.slice(id.end, argsStart)}`);
17170
+ } else {
17171
+ s.update(id.start, id.end, binding);
17172
+ s.prependRight(id.start, `(0,`);
17173
+ s.appendLeft(id.end, `)`);
17174
+ }
17175
+ } else if (!(parent.type === "ClassExpression" && id === parent.id)) s.update(id.start, id.end, binding);
17094
17176
  },
17095
17177
  onImportMeta(node) {
17096
17178
  s.update(node.start, node.end, ssrImportMetaKey);
@@ -17173,19 +17255,7 @@ function walk(root, { onIdentifier, onImportMeta, onDynamicImport, onStatements
17173
17255
  if (parentScope) setScope(parentScope, node.id.name);
17174
17256
  }
17175
17257
  if (node.type === "FunctionExpression" && node.id) setScope(node, node.id.name);
17176
- node.params.forEach((p) => {
17177
- if (p.type === "ObjectPattern" || p.type === "ArrayPattern") {
17178
- handlePattern(p, node);
17179
- return;
17180
- }
17181
- walk$1(p.type === "AssignmentPattern" ? p.left : p, { enter(child, parent) {
17182
- if (parent?.type === "AssignmentPattern" && parent.right === child) return this.skip();
17183
- if (child.type !== "Identifier") return;
17184
- if (isStaticPropertyKey(child, parent)) return;
17185
- if (parent?.type === "TemplateLiteral" && parent.expressions.includes(child) || parent?.type === "CallExpression" && parent.callee === child) return;
17186
- setScope(node, child.name);
17187
- } });
17188
- });
17258
+ node.params.forEach((p) => handlePattern(p, node));
17189
17259
  } else if (node.type === "ClassDeclaration") {
17190
17260
  const parentScope = findParentScope(parentStack);
17191
17261
  if (parentScope) setScope(parentScope, node.id.name);
@@ -17846,8 +17916,10 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17846
17916
  if (ii === pathExt.length) return resolve(step(i + 1));
17847
17917
  const ext = pathExt[ii];
17848
17918
  isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
17849
- if (!er && is) if (opt.all) found.push(p + ext);
17850
- else return resolve(p + ext);
17919
+ if (!er && is) {
17920
+ if (opt.all) found.push(p + ext);
17921
+ else return resolve(p + ext);
17922
+ }
17851
17923
  return resolve(subStep(p, i, ii + 1));
17852
17924
  });
17853
17925
  });
@@ -17865,8 +17937,10 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17865
17937
  for (let j = 0; j < pathExt.length; j++) {
17866
17938
  const cur = p + pathExt[j];
17867
17939
  try {
17868
- if (isexe.sync(cur, { pathExt: pathExtExe })) if (opt.all) found.push(cur);
17869
- else return cur;
17940
+ if (isexe.sync(cur, { pathExt: pathExtExe })) {
17941
+ if (opt.all) found.push(cur);
17942
+ else return cur;
17943
+ }
17870
17944
  } catch (ex) {}
17871
17945
  }
17872
17946
  }
@@ -18377,7 +18451,7 @@ function checkPublicFile(url, config) {
18377
18451
  return tryStatSync(publicFile)?.isFile() ? publicFile : void 0;
18378
18452
  }
18379
18453
  //#endregion
18380
- //#region ../../node_modules/.pnpm/ws@8.21.1/node_modules/ws/lib/constants.js
18454
+ //#region ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/constants.js
18381
18455
  var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
18382
18456
  const BINARY_TYPES = [
18383
18457
  "nodebuffer",
@@ -18400,7 +18474,7 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
18400
18474
  };
18401
18475
  }));
18402
18476
  //#endregion
18403
- //#region ../../node_modules/.pnpm/ws@8.21.1/node_modules/ws/lib/buffer-util.js
18477
+ //#region ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/buffer-util.js
18404
18478
  var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
18405
18479
  const { EMPTY_BUFFER } = require_constants();
18406
18480
  const FastBuffer = Buffer[Symbol.species];
@@ -18500,7 +18574,7 @@ var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
18500
18574
  } catch (e) {}
18501
18575
  }));
18502
18576
  //#endregion
18503
- //#region ../../node_modules/.pnpm/ws@8.21.1/node_modules/ws/lib/limiter.js
18577
+ //#region ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/limiter.js
18504
18578
  var require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
18505
18579
  const kDone = Symbol("kDone");
18506
18580
  const kRun = Symbol("kRun");
@@ -18551,7 +18625,7 @@ var require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
18551
18625
  module.exports = Limiter;
18552
18626
  }));
18553
18627
  //#endregion
18554
- //#region ../../node_modules/.pnpm/ws@8.21.1/node_modules/ws/lib/permessage-deflate.js
18628
+ //#region ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/permessage-deflate.js
18555
18629
  var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
18556
18630
  const zlib$1 = __require$1("zlib");
18557
18631
  const bufferUtil = require_buffer_util();
@@ -18671,7 +18745,7 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
18671
18745
  acceptAsServer(offers) {
18672
18746
  const opts = this._options;
18673
18747
  const accepted = offers.find((params) => {
18674
- if (opts.serverNoContextTakeover === false && params.server_no_context_takeover || params.server_max_window_bits && (opts.serverMaxWindowBits === false || typeof opts.serverMaxWindowBits === "number" && opts.serverMaxWindowBits > params.server_max_window_bits) || typeof opts.clientMaxWindowBits === "number" && !params.client_max_window_bits) return false;
18748
+ if (opts.serverNoContextTakeover === false && params.server_no_context_takeover || params.server_max_window_bits && (opts.serverMaxWindowBits === false || typeof opts.serverMaxWindowBits === "number" && opts.serverMaxWindowBits > params.server_max_window_bits) || typeof opts.clientMaxWindowBits === "number" && (typeof params.client_max_window_bits === "number" ? opts.clientMaxWindowBits > params.client_max_window_bits : !params.client_max_window_bits)) return false;
18675
18749
  return true;
18676
18750
  });
18677
18751
  if (!accepted) throw new Error("None of the extension offers can be accepted");
@@ -18887,7 +18961,7 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
18887
18961
  }
18888
18962
  }));
18889
18963
  //#endregion
18890
- //#region ../../node_modules/.pnpm/ws@8.21.1/node_modules/ws/lib/validation.js
18964
+ //#region ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/validation.js
18891
18965
  var require_validation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
18892
18966
  const { isUtf8 } = __require$1("buffer");
18893
18967
  const { hasBlob } = require_constants();
@@ -19083,7 +19157,7 @@ var require_validation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
19083
19157
  } catch (e) {}
19084
19158
  }));
19085
19159
  //#endregion
19086
- //#region ../../node_modules/.pnpm/ws@8.21.1/node_modules/ws/lib/receiver.js
19160
+ //#region ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/receiver.js
19087
19161
  var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
19088
19162
  const { Writable: Writable$1 } = __require$1("stream");
19089
19163
  const PerMessageDeflate = require_permessage_deflate();
@@ -19546,7 +19620,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
19546
19620
  module.exports = Receiver;
19547
19621
  }));
19548
19622
  //#endregion
19549
- //#region ../../node_modules/.pnpm/ws@8.21.1/node_modules/ws/lib/sender.js
19623
+ //#region ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/sender.js
19550
19624
  var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
19551
19625
  const { Duplex: Duplex$3 } = __require$1("stream");
19552
19626
  const { randomFillSync } = __require$1("crypto");
@@ -19632,12 +19706,13 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
19632
19706
  offset = 6;
19633
19707
  }
19634
19708
  let dataLength;
19635
- if (typeof data === "string") if ((!options.mask || skipMasking) && options[kByteLength] !== void 0) dataLength = options[kByteLength];
19636
- else {
19637
- data = Buffer.from(data);
19638
- dataLength = data.length;
19639
- }
19640
- else {
19709
+ if (typeof data === "string") {
19710
+ if ((!options.mask || skipMasking) && options[kByteLength] !== void 0) dataLength = options[kByteLength];
19711
+ else {
19712
+ data = Buffer.from(data);
19713
+ dataLength = data.length;
19714
+ }
19715
+ } else {
19641
19716
  dataLength = data.length;
19642
19717
  merge = options.mask && options.readOnly && !skipMasking;
19643
19718
  }
@@ -19749,15 +19824,16 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
19749
19824
  readOnly,
19750
19825
  rsv1: false
19751
19826
  };
19752
- if (isBlob(data)) if (this._state !== DEFAULT) this.enqueue([
19753
- this.getBlobData,
19754
- data,
19755
- false,
19756
- options,
19757
- cb
19758
- ]);
19759
- else this.getBlobData(data, false, options, cb);
19760
- else if (this._state !== DEFAULT) this.enqueue([
19827
+ if (isBlob(data)) {
19828
+ if (this._state !== DEFAULT) this.enqueue([
19829
+ this.getBlobData,
19830
+ data,
19831
+ false,
19832
+ options,
19833
+ cb
19834
+ ]);
19835
+ else this.getBlobData(data, false, options, cb);
19836
+ } else if (this._state !== DEFAULT) this.enqueue([
19761
19837
  this.dispatch,
19762
19838
  data,
19763
19839
  false,
@@ -19799,15 +19875,16 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
19799
19875
  readOnly,
19800
19876
  rsv1: false
19801
19877
  };
19802
- if (isBlob(data)) if (this._state !== DEFAULT) this.enqueue([
19803
- this.getBlobData,
19804
- data,
19805
- false,
19806
- options,
19807
- cb
19808
- ]);
19809
- else this.getBlobData(data, false, options, cb);
19810
- else if (this._state !== DEFAULT) this.enqueue([
19878
+ if (isBlob(data)) {
19879
+ if (this._state !== DEFAULT) this.enqueue([
19880
+ this.getBlobData,
19881
+ data,
19882
+ false,
19883
+ options,
19884
+ cb
19885
+ ]);
19886
+ else this.getBlobData(data, false, options, cb);
19887
+ } else if (this._state !== DEFAULT) this.enqueue([
19811
19888
  this.dispatch,
19812
19889
  data,
19813
19890
  false,
@@ -19868,15 +19945,16 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
19868
19945
  readOnly,
19869
19946
  rsv1
19870
19947
  };
19871
- if (isBlob(data)) if (this._state !== DEFAULT) this.enqueue([
19872
- this.getBlobData,
19873
- data,
19874
- this._compress,
19875
- opts,
19876
- cb
19877
- ]);
19878
- else this.getBlobData(data, this._compress, opts, cb);
19879
- else if (this._state !== DEFAULT) this.enqueue([
19948
+ if (isBlob(data)) {
19949
+ if (this._state !== DEFAULT) this.enqueue([
19950
+ this.getBlobData,
19951
+ data,
19952
+ this._compress,
19953
+ opts,
19954
+ cb
19955
+ ]);
19956
+ else this.getBlobData(data, this._compress, opts, cb);
19957
+ } else if (this._state !== DEFAULT) this.enqueue([
19880
19958
  this.dispatch,
19881
19959
  data,
19882
19960
  this._compress,
@@ -20040,7 +20118,7 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
20040
20118
  }
20041
20119
  }));
20042
20120
  //#endregion
20043
- //#region ../../node_modules/.pnpm/ws@8.21.1/node_modules/ws/lib/event-target.js
20121
+ //#region ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/event-target.js
20044
20122
  var require_event_target = /* @__PURE__ */ __commonJSMin(((exports, module) => {
20045
20123
  const { kForOnEventAttribute, kListener } = require_constants();
20046
20124
  const kCode = Symbol("kCode");
@@ -20271,7 +20349,7 @@ var require_event_target = /* @__PURE__ */ __commonJSMin(((exports, module) => {
20271
20349
  }
20272
20350
  }));
20273
20351
  //#endregion
20274
- //#region ../../node_modules/.pnpm/ws@8.21.1/node_modules/ws/lib/extension.js
20352
+ //#region ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/extension.js
20275
20353
  var require_extension = /* @__PURE__ */ __commonJSMin(((exports, module) => {
20276
20354
  const { tokenChars } = require_validation();
20277
20355
  /**
@@ -20309,51 +20387,54 @@ var require_extension = /* @__PURE__ */ __commonJSMin(((exports, module) => {
20309
20387
  let i = 0;
20310
20388
  for (; i < header.length; i++) {
20311
20389
  code = header.charCodeAt(i);
20312
- if (extensionName === void 0) if (end === -1 && tokenChars[code] === 1) {
20313
- if (start === -1) start = i;
20314
- } else if (i !== 0 && (code === 32 || code === 9)) {
20315
- if (end === -1 && start !== -1) end = i;
20316
- } else if (code === 59 || code === 44) {
20317
- if (start === -1) throw new SyntaxError(`Unexpected character at index ${i}`);
20318
- if (end === -1) end = i;
20319
- const name = header.slice(start, end);
20320
- if (code === 44) {
20321
- push(offers, name, params);
20322
- params = Object.create(null);
20323
- } else extensionName = name;
20324
- start = end = -1;
20325
- } else throw new SyntaxError(`Unexpected character at index ${i}`);
20326
- else if (paramName === void 0) if (end === -1 && tokenChars[code] === 1) {
20327
- if (start === -1) start = i;
20328
- } else if (code === 32 || code === 9) {
20329
- if (end === -1 && start !== -1) end = i;
20330
- } else if (code === 59 || code === 44) {
20331
- if (start === -1) throw new SyntaxError(`Unexpected character at index ${i}`);
20332
- if (end === -1) end = i;
20333
- push(params, header.slice(start, end), true);
20334
- if (code === 44) {
20335
- push(offers, extensionName, params);
20336
- params = Object.create(null);
20337
- extensionName = void 0;
20338
- }
20339
- start = end = -1;
20340
- } else if (code === 61 && start !== -1 && end === -1) {
20341
- paramName = header.slice(start, i);
20342
- start = end = -1;
20343
- } else throw new SyntaxError(`Unexpected character at index ${i}`);
20344
- else if (isEscaping) {
20390
+ if (extensionName === void 0) {
20391
+ if (end === -1 && tokenChars[code] === 1) {
20392
+ if (start === -1) start = i;
20393
+ } else if (i !== 0 && (code === 32 || code === 9)) {
20394
+ if (end === -1 && start !== -1) end = i;
20395
+ } else if (code === 59 || code === 44) {
20396
+ if (start === -1) throw new SyntaxError(`Unexpected character at index ${i}`);
20397
+ if (end === -1) end = i;
20398
+ const name = header.slice(start, end);
20399
+ if (code === 44) {
20400
+ push(offers, name, params);
20401
+ params = Object.create(null);
20402
+ } else extensionName = name;
20403
+ start = end = -1;
20404
+ } else throw new SyntaxError(`Unexpected character at index ${i}`);
20405
+ } else if (paramName === void 0) {
20406
+ if (end === -1 && tokenChars[code] === 1) {
20407
+ if (start === -1) start = i;
20408
+ } else if (code === 32 || code === 9) {
20409
+ if (end === -1 && start !== -1) end = i;
20410
+ } else if (code === 59 || code === 44) {
20411
+ if (start === -1) throw new SyntaxError(`Unexpected character at index ${i}`);
20412
+ if (end === -1) end = i;
20413
+ push(params, header.slice(start, end), true);
20414
+ if (code === 44) {
20415
+ push(offers, extensionName, params);
20416
+ params = Object.create(null);
20417
+ extensionName = void 0;
20418
+ }
20419
+ start = end = -1;
20420
+ } else if (code === 61 && start !== -1 && end === -1) {
20421
+ paramName = header.slice(start, i);
20422
+ start = end = -1;
20423
+ } else throw new SyntaxError(`Unexpected character at index ${i}`);
20424
+ } else if (isEscaping) {
20345
20425
  if (tokenChars[code] !== 1) throw new SyntaxError(`Unexpected character at index ${i}`);
20346
20426
  if (start === -1) start = i;
20347
20427
  else if (!mustUnescape) mustUnescape = true;
20348
20428
  isEscaping = false;
20349
- } else if (inQuotes) if (tokenChars[code] === 1) {
20350
- if (start === -1) start = i;
20351
- } else if (code === 34 && start !== -1) {
20352
- inQuotes = false;
20353
- end = i;
20354
- } else if (code === 92) isEscaping = true;
20355
- else throw new SyntaxError(`Unexpected character at index ${i}`);
20356
- else if (code === 34 && header.charCodeAt(i - 1) === 61) inQuotes = true;
20429
+ } else if (inQuotes) {
20430
+ if (tokenChars[code] === 1) {
20431
+ if (start === -1) start = i;
20432
+ } else if (code === 34 && start !== -1) {
20433
+ inQuotes = false;
20434
+ end = i;
20435
+ } else if (code === 92) isEscaping = true;
20436
+ else throw new SyntaxError(`Unexpected character at index ${i}`);
20437
+ } else if (code === 34 && header.charCodeAt(i - 1) === 61) inQuotes = true;
20357
20438
  else if (end === -1 && tokenChars[code] === 1) {
20358
20439
  if (start === -1) start = i;
20359
20440
  } else if (start !== -1 && (code === 32 || code === 9)) {
@@ -20414,7 +20495,7 @@ var require_extension = /* @__PURE__ */ __commonJSMin(((exports, module) => {
20414
20495
  };
20415
20496
  }));
20416
20497
  //#endregion
20417
- //#region ../../node_modules/.pnpm/ws@8.21.1/node_modules/ws/lib/websocket.js
20498
+ //#region ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/websocket.js
20418
20499
  var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
20419
20500
  const EventEmitter$2 = __require$1("events");
20420
20501
  const https$3 = __require$1("https");
@@ -20475,10 +20556,12 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
20475
20556
  this._isServer = false;
20476
20557
  this._redirects = 0;
20477
20558
  if (protocols === void 0) protocols = [];
20478
- else if (!Array.isArray(protocols)) if (typeof protocols === "object" && protocols !== null) {
20479
- options = protocols;
20480
- protocols = [];
20481
- } else protocols = [protocols];
20559
+ else if (!Array.isArray(protocols)) {
20560
+ if (typeof protocols === "object" && protocols !== null) {
20561
+ options = protocols;
20562
+ protocols = [];
20563
+ } else protocols = [protocols];
20564
+ }
20482
20565
  initAsClient(this, address, protocols, options);
20483
20566
  } else {
20484
20567
  this._autoPong = options.autoPong;
@@ -21020,8 +21103,10 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21020
21103
  }
21021
21104
  opts.headers["Sec-WebSocket-Protocol"] = protocols.join(",");
21022
21105
  }
21023
- if (opts.origin) if (opts.protocolVersion < 13) opts.headers["Sec-WebSocket-Origin"] = opts.origin;
21024
- else opts.headers.Origin = opts.origin;
21106
+ if (opts.origin) {
21107
+ if (opts.protocolVersion < 13) opts.headers["Sec-WebSocket-Origin"] = opts.origin;
21108
+ else opts.headers.Origin = opts.origin;
21109
+ }
21025
21110
  if (parsedUrl.username || parsedUrl.password) opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;
21026
21111
  if (isIpcUrl) {
21027
21112
  const parts = opts.path.split(":");
@@ -21403,7 +21488,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21403
21488
  }
21404
21489
  }));
21405
21490
  //#endregion
21406
- //#region ../../node_modules/.pnpm/ws@8.21.1/node_modules/ws/lib/stream.js
21491
+ //#region ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/stream.js
21407
21492
  var require_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21408
21493
  require_websocket();
21409
21494
  const { Duplex: Duplex$1 } = __require$1("stream");
@@ -21519,7 +21604,7 @@ var require_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21519
21604
  module.exports = createWebSocketStream;
21520
21605
  }));
21521
21606
  //#endregion
21522
- //#region ../../node_modules/.pnpm/ws@8.21.1/node_modules/ws/lib/subprotocol.js
21607
+ //#region ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/subprotocol.js
21523
21608
  var require_subprotocol = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21524
21609
  const { tokenChars } = require_validation();
21525
21610
  /**
@@ -21558,7 +21643,7 @@ var require_subprotocol = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21558
21643
  module.exports = { parse };
21559
21644
  }));
21560
21645
  //#endregion
21561
- //#region ../../node_modules/.pnpm/ws@8.21.1/node_modules/ws/lib/websocket-server.js
21646
+ //#region ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/websocket-server.js
21562
21647
  var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21563
21648
  const EventEmitter$1 = __require$1("events");
21564
21649
  const http$4 = __require$1("http");
@@ -21707,9 +21792,10 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
21707
21792
  this._removeListeners();
21708
21793
  this._removeListeners = this._server = null;
21709
21794
  }
21710
- if (this.clients) if (!this.clients.size) process.nextTick(emitClose, this);
21711
- else this._shouldEmitClose = true;
21712
- else process.nextTick(emitClose, this);
21795
+ if (this.clients) {
21796
+ if (!this.clients.size) process.nextTick(emitClose, this);
21797
+ else this._shouldEmitClose = true;
21798
+ } else process.nextTick(emitClose, this);
21713
21799
  } else {
21714
21800
  const server = this._server;
21715
21801
  this._removeListeners();
@@ -22397,7 +22483,7 @@ var require_ms = /* @__PURE__ */ __commonJSMin(((exports, module) => {
22397
22483
  }
22398
22484
  }));
22399
22485
  //#endregion
22400
- //#region ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js
22486
+ //#region ../../node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js
22401
22487
  var require_common$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
22402
22488
  /**
22403
22489
  * This is the common logic for both the Node.js and web browser
@@ -22535,15 +22621,16 @@ var require_common$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
22535
22621
  let templateIndex = 0;
22536
22622
  let starIndex = -1;
22537
22623
  let matchIndex = 0;
22538
- while (searchIndex < search.length) if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) if (template[templateIndex] === "*") {
22539
- starIndex = templateIndex;
22540
- matchIndex = searchIndex;
22541
- templateIndex++;
22542
- } else {
22543
- searchIndex++;
22544
- templateIndex++;
22545
- }
22546
- else if (starIndex !== -1) {
22624
+ while (searchIndex < search.length) if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
22625
+ if (template[templateIndex] === "*") {
22626
+ starIndex = templateIndex;
22627
+ matchIndex = searchIndex;
22628
+ templateIndex++;
22629
+ } else {
22630
+ searchIndex++;
22631
+ templateIndex++;
22632
+ }
22633
+ } else if (starIndex !== -1) {
22547
22634
  templateIndex = starIndex + 1;
22548
22635
  matchIndex++;
22549
22636
  searchIndex = matchIndex;
@@ -22598,7 +22685,7 @@ var require_common$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
22598
22685
  module.exports = setup;
22599
22686
  }));
22600
22687
  //#endregion
22601
- //#region ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js
22688
+ //#region ../../node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js
22602
22689
  var require_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
22603
22690
  /**
22604
22691
  * This is the web browser implementation of `debug()`.
@@ -22794,7 +22881,7 @@ var require_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
22794
22881
  };
22795
22882
  }));
22796
22883
  //#endregion
22797
- //#region ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js
22884
+ //#region ../../node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js
22798
22885
  var require_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
22799
22886
  /**
22800
22887
  * Module dependencies.
@@ -23001,7 +23088,7 @@ var require_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
23001
23088
  };
23002
23089
  }));
23003
23090
  //#endregion
23004
- //#region ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js
23091
+ //#region ../../node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js
23005
23092
  var require_src$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
23006
23093
  /**
23007
23094
  * Detect Electron renderer / nwjs process, which is node, but we should
@@ -23011,7 +23098,7 @@ var require_src$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
23011
23098
  else module.exports = require_node();
23012
23099
  }));
23013
23100
  //#endregion
23014
- //#region ../../node_modules/.pnpm/follow-redirects@1.16.0_debug@4.4.3/node_modules/follow-redirects/debug.js
23101
+ //#region ../../node_modules/.pnpm/follow-redirects@1.16.0_debug@4.4.3_supports-color@8.1.1_/node_modules/follow-redirects/debug.js
23015
23102
  var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
23016
23103
  var debug;
23017
23104
  module.exports = function() {
@@ -23025,7 +23112,7 @@ var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
23025
23112
  };
23026
23113
  }));
23027
23114
  //#endregion
23028
- //#region ../../node_modules/.pnpm/follow-redirects@1.16.0_debug@4.4.3/node_modules/follow-redirects/index.js
23115
+ //#region ../../node_modules/.pnpm/follow-redirects@1.16.0_debug@4.4.3_supports-color@8.1.1_/node_modules/follow-redirects/index.js
23029
23116
  var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module) => {
23030
23117
  var url$1 = __require$1("url");
23031
23118
  var URL = url$1.URL;
@@ -23470,7 +23557,7 @@ var require_follow_redirects = /* @__PURE__ */ __commonJSMin(((exports, module)
23470
23557
  module.exports.wrap = wrap;
23471
23558
  }));
23472
23559
  //#endregion
23473
- //#region ../../node_modules/.pnpm/http-proxy-3@1.23.3/node_modules/http-proxy-3/dist/lib/http-proxy/common.js
23560
+ //#region ../../node_modules/.pnpm/http-proxy-3@1.23.3_supports-color@8.1.1/node_modules/http-proxy-3/dist/lib/http-proxy/common.js
23474
23561
  var require_common = /* @__PURE__ */ __commonJSMin(((exports) => {
23475
23562
  Object.defineProperty(exports, "__esModule", { value: true });
23476
23563
  exports.isSSL = void 0;
@@ -23571,9 +23658,10 @@ var require_common = /* @__PURE__ */ __commonJSMin(((exports) => {
23571
23658
  let retSegs = "";
23572
23659
  for (const seg of args) {
23573
23660
  if (!seg) continue;
23574
- if (retSegs.endsWith("/")) if (seg.startsWith("/")) retSegs += seg.slice(1);
23575
- else retSegs += seg;
23576
- else if (seg.startsWith("/")) retSegs += seg;
23661
+ if (retSegs.endsWith("/")) {
23662
+ if (seg.startsWith("/")) retSegs += seg.slice(1);
23663
+ else retSegs += seg;
23664
+ } else if (seg.startsWith("/")) retSegs += seg;
23577
23665
  else retSegs += "/" + seg;
23578
23666
  }
23579
23667
  return queryParamRaw ? retSegs + "?" + queryParamRaw : retSegs;
@@ -23625,7 +23713,7 @@ var require_common = /* @__PURE__ */ __commonJSMin(((exports) => {
23625
23713
  }
23626
23714
  }));
23627
23715
  //#endregion
23628
- //#region ../../node_modules/.pnpm/http-proxy-3@1.23.3/node_modules/http-proxy-3/dist/lib/http-proxy/passes/web-outgoing.js
23716
+ //#region ../../node_modules/.pnpm/http-proxy-3@1.23.3_supports-color@8.1.1/node_modules/http-proxy-3/dist/lib/http-proxy/passes/web-outgoing.js
23629
23717
  var require_web_outgoing = /* @__PURE__ */ __commonJSMin(((exports) => {
23630
23718
  var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
23631
23719
  if (k2 === void 0) k2 = k;
@@ -23736,7 +23824,7 @@ var require_web_outgoing = /* @__PURE__ */ __commonJSMin(((exports) => {
23736
23824
  };
23737
23825
  }));
23738
23826
  //#endregion
23739
- //#region ../../node_modules/.pnpm/http-proxy-3@1.23.3/node_modules/http-proxy-3/dist/lib/http-proxy/passes/web-incoming.js
23827
+ //#region ../../node_modules/.pnpm/http-proxy-3@1.23.3_supports-color@8.1.1/node_modules/http-proxy-3/dist/lib/http-proxy/passes/web-incoming.js
23740
23828
  var require_web_incoming = /* @__PURE__ */ __commonJSMin(((exports) => {
23741
23829
  var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
23742
23830
  if (k2 === void 0) k2 = k;
@@ -23991,7 +24079,7 @@ var require_web_incoming = /* @__PURE__ */ __commonJSMin(((exports) => {
23991
24079
  };
23992
24080
  }));
23993
24081
  //#endregion
23994
- //#region ../../node_modules/.pnpm/http-proxy-3@1.23.3/node_modules/http-proxy-3/dist/lib/http-proxy/passes/ws-incoming.js
24082
+ //#region ../../node_modules/.pnpm/http-proxy-3@1.23.3_supports-color@8.1.1/node_modules/http-proxy-3/dist/lib/http-proxy/passes/ws-incoming.js
23995
24083
  var require_ws_incoming = /* @__PURE__ */ __commonJSMin(((exports) => {
23996
24084
  var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
23997
24085
  if (k2 === void 0) k2 = k;
@@ -24200,7 +24288,7 @@ var require_ws_incoming = /* @__PURE__ */ __commonJSMin(((exports) => {
24200
24288
  };
24201
24289
  }));
24202
24290
  //#endregion
24203
- //#region ../../node_modules/.pnpm/http-proxy-3@1.23.3/node_modules/http-proxy-3/dist/lib/http-proxy/index.js
24291
+ //#region ../../node_modules/.pnpm/http-proxy-3@1.23.3_supports-color@8.1.1/node_modules/http-proxy-3/dist/lib/http-proxy/index.js
24204
24292
  var require_http_proxy = /* @__PURE__ */ __commonJSMin(((exports) => {
24205
24293
  var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
24206
24294
  if (k2 === void 0) k2 = k;
@@ -24614,9 +24702,10 @@ var require_convert_source_map = /* @__PURE__ */ __commonJSMin(((exports) => {
24614
24702
  return /(?:\/\/[@#][ \t]+?sourceMappingURL=([^\s'"`]+?)[ \t]*?$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*?(?:\*\/){1}[ \t]*?$)/gm;
24615
24703
  } });
24616
24704
  var decodeBase64;
24617
- if (typeof Buffer !== "undefined") if (typeof Buffer.from === "function") decodeBase64 = decodeBase64WithBufferFrom;
24618
- else decodeBase64 = decodeBase64WithNewBuffer;
24619
- else decodeBase64 = decodeBase64WithAtob;
24705
+ if (typeof Buffer !== "undefined") {
24706
+ if (typeof Buffer.from === "function") decodeBase64 = decodeBase64WithBufferFrom;
24707
+ else decodeBase64 = decodeBase64WithNewBuffer;
24708
+ } else decodeBase64 = decodeBase64WithAtob;
24620
24709
  function decodeBase64WithBufferFrom(base64) {
24621
24710
  return Buffer.from(base64, "base64").toString();
24622
24711
  }
@@ -24655,9 +24744,10 @@ var require_convert_source_map = /* @__PURE__ */ __commonJSMin(((exports) => {
24655
24744
  Converter.prototype.toJSON = function(space) {
24656
24745
  return JSON.stringify(this.sourcemap, null, space);
24657
24746
  };
24658
- if (typeof Buffer !== "undefined") if (typeof Buffer.from === "function") Converter.prototype.toBase64 = encodeBase64WithBufferFrom;
24659
- else Converter.prototype.toBase64 = encodeBase64WithNewBuffer;
24660
- else Converter.prototype.toBase64 = encodeBase64WithBtoa;
24747
+ if (typeof Buffer !== "undefined") {
24748
+ if (typeof Buffer.from === "function") Converter.prototype.toBase64 = encodeBase64WithBufferFrom;
24749
+ else Converter.prototype.toBase64 = encodeBase64WithNewBuffer;
24750
+ } else Converter.prototype.toBase64 = encodeBase64WithBtoa;
24661
24751
  function encodeBase64WithBufferFrom() {
24662
24752
  var json = this.toJSON();
24663
24753
  return Buffer.from(json, "utf8").toString("base64");
@@ -25750,13 +25840,20 @@ function isFileInTargetPath(targetPath, filePath) {
25750
25840
  return isSameFilePath(targetPath, filePath) || isParentDirectory(targetPath, filePath);
25751
25841
  }
25752
25842
  const windowsDriveRE = /^[A-Z]:/i;
25843
+ const windowsShortNameSegmentRE = /^[^~.]{1,6}~\d+(?:\.[^~.]{0,3})?$/;
25844
+ /**
25845
+ * Warning: parameters are not validated, only works with normalized absolute paths
25846
+ */
25847
+ function looksLikeWindowsShortNamePath(filePath) {
25848
+ return filePath.includes("~") && filePath.split("/").some((segment) => windowsShortNameSegmentRE.test(segment));
25849
+ }
25753
25850
  /**
25754
25851
  * Warning: parameters are not validated, only works with normalized absolute paths
25755
25852
  */
25756
25853
  function isFileLoadingAllowed(config, filePath) {
25757
25854
  const { fs } = config.server;
25758
25855
  if (!fs.strict) return true;
25759
- if (isWindows && filePath.includes("~")) return false;
25856
+ if (isWindows && looksLikeWindowsShortNamePath(filePath)) return false;
25760
25857
  if ((isWindows && windowsDriveRE.test(filePath) ? filePath.slice(2) : filePath).includes(":")) return false;
25761
25858
  const filePathWithoutTrailingSlash = filePath.endsWith("/") ? filePath.slice(0, -1) : filePath;
25762
25859
  if (config.fsDenyGlob(filePathWithoutTrailingSlash)) return false;
@@ -26035,402 +26132,404 @@ function getModuleTypeFromId(id) {
26035
26132
  }
26036
26133
  }
26037
26134
  //#endregion
26038
- //#region ../../node_modules/.pnpm/strip-literal@3.1.0/node_modules/strip-literal/dist/index.mjs
26039
- var import_js_tokens = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
26040
- var HashbangComment;
26041
- var Identifier;
26042
- var JSXIdentifier;
26043
- var JSXPunctuator;
26044
- var JSXString;
26045
- var JSXText;
26046
- var KeywordsWithExpressionAfter;
26047
- var KeywordsWithNoLineTerminatorAfter;
26048
- var LineTerminatorSequence;
26049
- var MultiLineComment;
26050
- var Newline;
26051
- var NumericLiteral;
26052
- var Punctuator;
26053
- var RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:[^\]\\\n\r\u2028\u2029]+|\\.)*\]?|[^\/[\\\n\r\u2028\u2029]+|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/uy;
26054
- var SingleLineComment;
26055
- var StringLiteral;
26056
- var Template;
26057
- var TokensNotPrecedingObjectLiteral;
26058
- var TokensPrecedingExpression;
26059
- var WhiteSpace;
26060
- Punctuator = /--|\+\+|=>|\.{3}|\??\.(?!\d)|(?:&&|\|\||\?\?|[+\-%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\/(?![\/*]))=?|[?~,:;[\](){}]/y;
26061
- Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]+|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/uy;
26062
- StringLiteral = /(['"])(?:[^'"\\\n\r]+|(?!\1)['"]|\\(?:\r\n|[^]))*(\1)?/y;
26063
- NumericLiteral = /(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|0n|[1-9](?:_?\d)*n|(?:(?:0(?!\d)|0\d*[89]\d*|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?|0[0-7]+/y;
26064
- Template = /[`}](?:[^`\\$]+|\\[^]|\$(?!\{))*(`|\$\{)?/y;
26065
- WhiteSpace = /[\t\v\f\ufeff\p{Zs}]+/uy;
26066
- LineTerminatorSequence = /\r?\n|[\r\u2028\u2029]/y;
26067
- MultiLineComment = /\/\*(?:[^*]+|\*(?!\/))*(\*\/)?/y;
26068
- SingleLineComment = /\/\/.*/y;
26069
- HashbangComment = /^#!.*/;
26070
- JSXPunctuator = /[<>.:={}]|\/(?![\/*])/y;
26071
- JSXIdentifier = /[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}-]*/uy;
26072
- JSXString = /(['"])(?:[^'"]+|(?!\1)['"])*(\1)?/y;
26073
- JSXText = /[^<>{}]+/y;
26074
- TokensPrecedingExpression = /^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/;
26075
- TokensNotPrecedingObjectLiteral = /^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/;
26076
- KeywordsWithExpressionAfter = /^(?:await|case|default|delete|do|else|instanceof|new|return|throw|typeof|void|yield)$/;
26077
- KeywordsWithNoLineTerminatorAfter = /^(?:return|throw|yield)$/;
26078
- Newline = RegExp(LineTerminatorSequence.source);
26079
- module.exports = function* (input, { jsx = false } = {}) {
26080
- var braces, firstCodePoint, isExpression, lastIndex, lastSignificantToken, length, match, mode, nextLastIndex, nextLastSignificantToken, parenNesting, postfixIncDec, punctuator, stack;
26081
- ({length} = input);
26082
- lastIndex = 0;
26083
- lastSignificantToken = "";
26084
- stack = [{ tag: "JS" }];
26085
- braces = [];
26086
- parenNesting = 0;
26087
- postfixIncDec = false;
26088
- if (match = HashbangComment.exec(input)) {
26089
- yield {
26090
- type: "HashbangComment",
26091
- value: match[0]
26092
- };
26093
- lastIndex = match[0].length;
26094
- }
26095
- while (lastIndex < length) {
26096
- mode = stack[stack.length - 1];
26097
- switch (mode.tag) {
26098
- case "JS":
26099
- case "JSNonExpressionParen":
26100
- case "InterpolationInTemplate":
26101
- case "InterpolationInJSX":
26102
- if (input[lastIndex] === "/" && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
26103
- RegularExpressionLiteral.lastIndex = lastIndex;
26104
- if (match = RegularExpressionLiteral.exec(input)) {
26105
- lastIndex = RegularExpressionLiteral.lastIndex;
26106
- lastSignificantToken = match[0];
26107
- postfixIncDec = true;
26108
- yield {
26109
- type: "RegularExpressionLiteral",
26110
- value: match[0],
26111
- closed: match[1] !== void 0 && match[1] !== "\\"
26112
- };
26113
- continue;
26114
- }
26135
+ //#region ../../node_modules/.pnpm/js-tokens@10.0.0/node_modules/js-tokens/index.js
26136
+ var HashbangComment;
26137
+ var Identifier;
26138
+ var JSXIdentifier;
26139
+ var JSXPunctuator;
26140
+ var JSXString;
26141
+ var JSXText;
26142
+ var KeywordsWithExpressionAfter;
26143
+ var KeywordsWithNoLineTerminatorAfter;
26144
+ var LineTerminatorSequence;
26145
+ var MultiLineComment;
26146
+ var Newline;
26147
+ var NumericLiteral;
26148
+ var Punctuator;
26149
+ var RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:[^\]\\\n\r\u2028\u2029]+|\\.)*\]?|[^\/[\\\n\r\u2028\u2029]+|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/uy;
26150
+ var SingleLineComment;
26151
+ var StringLiteral;
26152
+ var Template;
26153
+ var TokensNotPrecedingObjectLiteral;
26154
+ var TokensPrecedingExpression;
26155
+ var WhiteSpace;
26156
+ var jsTokens;
26157
+ Punctuator = /--|\+\+|=>|\.{3}|\??\.(?!\d)|(?:&&|\|\||\?\?|[+\-%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\/(?![\/*]))=?|[?~,:;[\](){}]/y;
26158
+ Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]+|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/uy;
26159
+ StringLiteral = /(['"])(?:[^'"\\\n\r]+|(?!\1)['"]|\\(?:\r\n|[^]))*(\1)?/y;
26160
+ NumericLiteral = /(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|0n|[1-9](?:_?\d)*n|(?:(?:0(?!\d)|0\d*[89]\d*|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?|0[0-7]+/y;
26161
+ Template = /[`}](?:[^`\\$]+|\\[^]|\$(?!\{))*(`|\$\{)?/y;
26162
+ WhiteSpace = /[\t\v\f\ufeff\p{Zs}]+/uy;
26163
+ LineTerminatorSequence = /\r?\n|[\r\u2028\u2029]/y;
26164
+ MultiLineComment = /\/\*(?:[^*]+|\*(?!\/))*(\*\/)?/y;
26165
+ SingleLineComment = /\/\/.*/y;
26166
+ HashbangComment = /^#!.*/;
26167
+ JSXPunctuator = /[<>.:={}]|\/(?![\/*])/y;
26168
+ JSXIdentifier = /[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}-]*/uy;
26169
+ JSXString = /(['"])(?:[^'"]+|(?!\1)['"])*(\1)?/y;
26170
+ JSXText = /[^<>{}]+/y;
26171
+ TokensPrecedingExpression = /^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/;
26172
+ TokensNotPrecedingObjectLiteral = /^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/;
26173
+ KeywordsWithExpressionAfter = /^(?:await|case|default|delete|do|else|instanceof|new|return|throw|typeof|void|yield)$/;
26174
+ KeywordsWithNoLineTerminatorAfter = /^(?:return|throw|yield)$/;
26175
+ Newline = RegExp(LineTerminatorSequence.source);
26176
+ jsTokens = function* (input, { jsx = false } = {}) {
26177
+ var braces, firstCodePoint, isExpression, lastIndex, lastSignificantToken, length, match, mode, nextLastIndex, nextLastSignificantToken, parenNesting, postfixIncDec, punctuator, stack;
26178
+ ({length} = input);
26179
+ lastIndex = 0;
26180
+ lastSignificantToken = "";
26181
+ stack = [{ tag: "JS" }];
26182
+ braces = [];
26183
+ parenNesting = 0;
26184
+ postfixIncDec = false;
26185
+ if (match = HashbangComment.exec(input)) {
26186
+ yield {
26187
+ type: "HashbangComment",
26188
+ value: match[0]
26189
+ };
26190
+ lastIndex = match[0].length;
26191
+ }
26192
+ while (lastIndex < length) {
26193
+ mode = stack[stack.length - 1];
26194
+ switch (mode.tag) {
26195
+ case "JS":
26196
+ case "JSNonExpressionParen":
26197
+ case "InterpolationInTemplate":
26198
+ case "InterpolationInJSX":
26199
+ if (input[lastIndex] === "/" && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
26200
+ RegularExpressionLiteral.lastIndex = lastIndex;
26201
+ if (match = RegularExpressionLiteral.exec(input)) {
26202
+ lastIndex = RegularExpressionLiteral.lastIndex;
26203
+ lastSignificantToken = match[0];
26204
+ postfixIncDec = true;
26205
+ yield {
26206
+ type: "RegularExpressionLiteral",
26207
+ value: match[0],
26208
+ closed: match[1] !== void 0 && match[1] !== "\\"
26209
+ };
26210
+ continue;
26115
26211
  }
26116
- Punctuator.lastIndex = lastIndex;
26117
- if (match = Punctuator.exec(input)) {
26118
- punctuator = match[0];
26119
- nextLastIndex = Punctuator.lastIndex;
26120
- nextLastSignificantToken = punctuator;
26121
- switch (punctuator) {
26122
- case "(":
26123
- if (lastSignificantToken === "?NonExpressionParenKeyword") stack.push({
26124
- tag: "JSNonExpressionParen",
26125
- nesting: parenNesting
26126
- });
26127
- parenNesting++;
26128
- postfixIncDec = false;
26129
- break;
26130
- case ")":
26131
- parenNesting--;
26132
- postfixIncDec = true;
26133
- if (mode.tag === "JSNonExpressionParen" && parenNesting === mode.nesting) {
26134
- stack.pop();
26135
- nextLastSignificantToken = "?NonExpressionParenEnd";
26136
- postfixIncDec = false;
26137
- }
26138
- break;
26139
- case "{":
26140
- Punctuator.lastIndex = 0;
26141
- isExpression = !TokensNotPrecedingObjectLiteral.test(lastSignificantToken) && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken));
26142
- braces.push(isExpression);
26212
+ }
26213
+ Punctuator.lastIndex = lastIndex;
26214
+ if (match = Punctuator.exec(input)) {
26215
+ punctuator = match[0];
26216
+ nextLastIndex = Punctuator.lastIndex;
26217
+ nextLastSignificantToken = punctuator;
26218
+ switch (punctuator) {
26219
+ case "(":
26220
+ if (lastSignificantToken === "?NonExpressionParenKeyword") stack.push({
26221
+ tag: "JSNonExpressionParen",
26222
+ nesting: parenNesting
26223
+ });
26224
+ parenNesting++;
26225
+ postfixIncDec = false;
26226
+ break;
26227
+ case ")":
26228
+ parenNesting--;
26229
+ postfixIncDec = true;
26230
+ if (mode.tag === "JSNonExpressionParen" && parenNesting === mode.nesting) {
26231
+ stack.pop();
26232
+ nextLastSignificantToken = "?NonExpressionParenEnd";
26143
26233
  postfixIncDec = false;
26144
- break;
26145
- case "}":
26146
- switch (mode.tag) {
26147
- case "InterpolationInTemplate":
26148
- if (braces.length === mode.nesting) {
26149
- Template.lastIndex = lastIndex;
26150
- match = Template.exec(input);
26151
- lastIndex = Template.lastIndex;
26152
- lastSignificantToken = match[0];
26153
- if (match[1] === "${") {
26154
- lastSignificantToken = "?InterpolationInTemplate";
26155
- postfixIncDec = false;
26156
- yield {
26157
- type: "TemplateMiddle",
26158
- value: match[0]
26159
- };
26160
- } else {
26161
- stack.pop();
26162
- postfixIncDec = true;
26163
- yield {
26164
- type: "TemplateTail",
26165
- value: match[0],
26166
- closed: match[1] === "`"
26167
- };
26168
- }
26169
- continue;
26234
+ }
26235
+ break;
26236
+ case "{":
26237
+ Punctuator.lastIndex = 0;
26238
+ isExpression = !TokensNotPrecedingObjectLiteral.test(lastSignificantToken) && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken));
26239
+ braces.push(isExpression);
26240
+ postfixIncDec = false;
26241
+ break;
26242
+ case "}":
26243
+ switch (mode.tag) {
26244
+ case "InterpolationInTemplate":
26245
+ if (braces.length === mode.nesting) {
26246
+ Template.lastIndex = lastIndex;
26247
+ match = Template.exec(input);
26248
+ lastIndex = Template.lastIndex;
26249
+ lastSignificantToken = match[0];
26250
+ if (match[1] === "${") {
26251
+ lastSignificantToken = "?InterpolationInTemplate";
26252
+ postfixIncDec = false;
26253
+ yield {
26254
+ type: "TemplateMiddle",
26255
+ value: match[0]
26256
+ };
26257
+ } else {
26258
+ stack.pop();
26259
+ postfixIncDec = true;
26260
+ yield {
26261
+ type: "TemplateTail",
26262
+ value: match[0],
26263
+ closed: match[1] === "`"
26264
+ };
26170
26265
  }
26171
- break;
26172
- case "InterpolationInJSX": if (braces.length === mode.nesting) {
26173
- stack.pop();
26174
- lastIndex += 1;
26175
- lastSignificantToken = "}";
26176
- yield {
26177
- type: "JSXPunctuator",
26178
- value: "}"
26179
- };
26180
26266
  continue;
26181
26267
  }
26182
- }
26183
- postfixIncDec = braces.pop();
26184
- nextLastSignificantToken = postfixIncDec ? "?ExpressionBraceEnd" : "}";
26185
- break;
26186
- case "]":
26187
- postfixIncDec = true;
26188
- break;
26189
- case "++":
26190
- case "--":
26191
- nextLastSignificantToken = postfixIncDec ? "?PostfixIncDec" : "?UnaryIncDec";
26192
- break;
26193
- case "<":
26194
- if (jsx && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
26195
- stack.push({ tag: "JSXTag" });
26268
+ break;
26269
+ case "InterpolationInJSX": if (braces.length === mode.nesting) {
26270
+ stack.pop();
26196
26271
  lastIndex += 1;
26197
- lastSignificantToken = "<";
26272
+ lastSignificantToken = "}";
26198
26273
  yield {
26199
26274
  type: "JSXPunctuator",
26200
- value: punctuator
26275
+ value: "}"
26201
26276
  };
26202
26277
  continue;
26203
26278
  }
26204
- postfixIncDec = false;
26205
- break;
26206
- default: postfixIncDec = false;
26207
- }
26208
- lastIndex = nextLastIndex;
26209
- lastSignificantToken = nextLastSignificantToken;
26210
- yield {
26211
- type: "Punctuator",
26212
- value: punctuator
26213
- };
26214
- continue;
26279
+ }
26280
+ postfixIncDec = braces.pop();
26281
+ nextLastSignificantToken = postfixIncDec ? "?ExpressionBraceEnd" : "}";
26282
+ break;
26283
+ case "]":
26284
+ postfixIncDec = true;
26285
+ break;
26286
+ case "++":
26287
+ case "--":
26288
+ nextLastSignificantToken = postfixIncDec ? "?PostfixIncDec" : "?UnaryIncDec";
26289
+ break;
26290
+ case "<":
26291
+ if (jsx && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
26292
+ stack.push({ tag: "JSXTag" });
26293
+ lastIndex += 1;
26294
+ lastSignificantToken = "<";
26295
+ yield {
26296
+ type: "JSXPunctuator",
26297
+ value: punctuator
26298
+ };
26299
+ continue;
26300
+ }
26301
+ postfixIncDec = false;
26302
+ break;
26303
+ default: postfixIncDec = false;
26215
26304
  }
26216
- Identifier.lastIndex = lastIndex;
26217
- if (match = Identifier.exec(input)) {
26218
- lastIndex = Identifier.lastIndex;
26219
- nextLastSignificantToken = match[0];
26220
- switch (match[0]) {
26221
- case "for":
26222
- case "if":
26223
- case "while":
26224
- case "with": if (lastSignificantToken !== "." && lastSignificantToken !== "?.") nextLastSignificantToken = "?NonExpressionParenKeyword";
26225
- }
26226
- lastSignificantToken = nextLastSignificantToken;
26227
- postfixIncDec = !KeywordsWithExpressionAfter.test(match[0]);
26305
+ lastIndex = nextLastIndex;
26306
+ lastSignificantToken = nextLastSignificantToken;
26307
+ yield {
26308
+ type: "Punctuator",
26309
+ value: punctuator
26310
+ };
26311
+ continue;
26312
+ }
26313
+ Identifier.lastIndex = lastIndex;
26314
+ if (match = Identifier.exec(input)) {
26315
+ lastIndex = Identifier.lastIndex;
26316
+ nextLastSignificantToken = match[0];
26317
+ switch (match[0]) {
26318
+ case "for":
26319
+ case "if":
26320
+ case "while":
26321
+ case "with": if (lastSignificantToken !== "." && lastSignificantToken !== "?.") nextLastSignificantToken = "?NonExpressionParenKeyword";
26322
+ }
26323
+ lastSignificantToken = nextLastSignificantToken;
26324
+ postfixIncDec = !KeywordsWithExpressionAfter.test(match[0]);
26325
+ yield {
26326
+ type: match[1] === "#" ? "PrivateIdentifier" : "IdentifierName",
26327
+ value: match[0]
26328
+ };
26329
+ continue;
26330
+ }
26331
+ StringLiteral.lastIndex = lastIndex;
26332
+ if (match = StringLiteral.exec(input)) {
26333
+ lastIndex = StringLiteral.lastIndex;
26334
+ lastSignificantToken = match[0];
26335
+ postfixIncDec = true;
26336
+ yield {
26337
+ type: "StringLiteral",
26338
+ value: match[0],
26339
+ closed: match[2] !== void 0
26340
+ };
26341
+ continue;
26342
+ }
26343
+ NumericLiteral.lastIndex = lastIndex;
26344
+ if (match = NumericLiteral.exec(input)) {
26345
+ lastIndex = NumericLiteral.lastIndex;
26346
+ lastSignificantToken = match[0];
26347
+ postfixIncDec = true;
26348
+ yield {
26349
+ type: "NumericLiteral",
26350
+ value: match[0]
26351
+ };
26352
+ continue;
26353
+ }
26354
+ Template.lastIndex = lastIndex;
26355
+ if (match = Template.exec(input)) {
26356
+ lastIndex = Template.lastIndex;
26357
+ lastSignificantToken = match[0];
26358
+ if (match[1] === "${") {
26359
+ lastSignificantToken = "?InterpolationInTemplate";
26360
+ stack.push({
26361
+ tag: "InterpolationInTemplate",
26362
+ nesting: braces.length
26363
+ });
26364
+ postfixIncDec = false;
26228
26365
  yield {
26229
- type: match[1] === "#" ? "PrivateIdentifier" : "IdentifierName",
26366
+ type: "TemplateHead",
26230
26367
  value: match[0]
26231
26368
  };
26232
- continue;
26233
- }
26234
- StringLiteral.lastIndex = lastIndex;
26235
- if (match = StringLiteral.exec(input)) {
26236
- lastIndex = StringLiteral.lastIndex;
26237
- lastSignificantToken = match[0];
26369
+ } else {
26238
26370
  postfixIncDec = true;
26239
26371
  yield {
26240
- type: "StringLiteral",
26372
+ type: "NoSubstitutionTemplate",
26241
26373
  value: match[0],
26242
- closed: match[2] !== void 0
26243
- };
26244
- continue;
26245
- }
26246
- NumericLiteral.lastIndex = lastIndex;
26247
- if (match = NumericLiteral.exec(input)) {
26248
- lastIndex = NumericLiteral.lastIndex;
26249
- lastSignificantToken = match[0];
26250
- postfixIncDec = true;
26251
- yield {
26252
- type: "NumericLiteral",
26253
- value: match[0]
26374
+ closed: match[1] === "`"
26254
26375
  };
26255
- continue;
26256
26376
  }
26257
- Template.lastIndex = lastIndex;
26258
- if (match = Template.exec(input)) {
26259
- lastIndex = Template.lastIndex;
26260
- lastSignificantToken = match[0];
26261
- if (match[1] === "${") {
26262
- lastSignificantToken = "?InterpolationInTemplate";
26377
+ continue;
26378
+ }
26379
+ break;
26380
+ case "JSXTag":
26381
+ case "JSXTagEnd":
26382
+ JSXPunctuator.lastIndex = lastIndex;
26383
+ if (match = JSXPunctuator.exec(input)) {
26384
+ lastIndex = JSXPunctuator.lastIndex;
26385
+ nextLastSignificantToken = match[0];
26386
+ switch (match[0]) {
26387
+ case "<":
26388
+ stack.push({ tag: "JSXTag" });
26389
+ break;
26390
+ case ">":
26391
+ stack.pop();
26392
+ if (lastSignificantToken === "/" || mode.tag === "JSXTagEnd") {
26393
+ nextLastSignificantToken = "?JSX";
26394
+ postfixIncDec = true;
26395
+ } else stack.push({ tag: "JSXChildren" });
26396
+ break;
26397
+ case "{":
26263
26398
  stack.push({
26264
- tag: "InterpolationInTemplate",
26399
+ tag: "InterpolationInJSX",
26265
26400
  nesting: braces.length
26266
26401
  });
26402
+ nextLastSignificantToken = "?InterpolationInJSX";
26267
26403
  postfixIncDec = false;
26268
- yield {
26269
- type: "TemplateHead",
26270
- value: match[0]
26271
- };
26272
- } else {
26273
- postfixIncDec = true;
26274
- yield {
26275
- type: "NoSubstitutionTemplate",
26276
- value: match[0],
26277
- closed: match[1] === "`"
26278
- };
26404
+ break;
26405
+ case "/": if (lastSignificantToken === "<") {
26406
+ stack.pop();
26407
+ if (stack[stack.length - 1].tag === "JSXChildren") stack.pop();
26408
+ stack.push({ tag: "JSXTagEnd" });
26279
26409
  }
26280
- continue;
26281
26410
  }
26282
- break;
26283
- case "JSXTag":
26284
- case "JSXTagEnd":
26285
- JSXPunctuator.lastIndex = lastIndex;
26286
- if (match = JSXPunctuator.exec(input)) {
26287
- lastIndex = JSXPunctuator.lastIndex;
26288
- nextLastSignificantToken = match[0];
26289
- switch (match[0]) {
26290
- case "<":
26291
- stack.push({ tag: "JSXTag" });
26292
- break;
26293
- case ">":
26294
- stack.pop();
26295
- if (lastSignificantToken === "/" || mode.tag === "JSXTagEnd") {
26296
- nextLastSignificantToken = "?JSX";
26297
- postfixIncDec = true;
26298
- } else stack.push({ tag: "JSXChildren" });
26299
- break;
26300
- case "{":
26301
- stack.push({
26302
- tag: "InterpolationInJSX",
26303
- nesting: braces.length
26304
- });
26305
- nextLastSignificantToken = "?InterpolationInJSX";
26306
- postfixIncDec = false;
26307
- break;
26308
- case "/": if (lastSignificantToken === "<") {
26309
- stack.pop();
26310
- if (stack[stack.length - 1].tag === "JSXChildren") stack.pop();
26311
- stack.push({ tag: "JSXTagEnd" });
26312
- }
26313
- }
26314
- lastSignificantToken = nextLastSignificantToken;
26411
+ lastSignificantToken = nextLastSignificantToken;
26412
+ yield {
26413
+ type: "JSXPunctuator",
26414
+ value: match[0]
26415
+ };
26416
+ continue;
26417
+ }
26418
+ JSXIdentifier.lastIndex = lastIndex;
26419
+ if (match = JSXIdentifier.exec(input)) {
26420
+ lastIndex = JSXIdentifier.lastIndex;
26421
+ lastSignificantToken = match[0];
26422
+ yield {
26423
+ type: "JSXIdentifier",
26424
+ value: match[0]
26425
+ };
26426
+ continue;
26427
+ }
26428
+ JSXString.lastIndex = lastIndex;
26429
+ if (match = JSXString.exec(input)) {
26430
+ lastIndex = JSXString.lastIndex;
26431
+ lastSignificantToken = match[0];
26432
+ yield {
26433
+ type: "JSXString",
26434
+ value: match[0],
26435
+ closed: match[2] !== void 0
26436
+ };
26437
+ continue;
26438
+ }
26439
+ break;
26440
+ case "JSXChildren":
26441
+ JSXText.lastIndex = lastIndex;
26442
+ if (match = JSXText.exec(input)) {
26443
+ lastIndex = JSXText.lastIndex;
26444
+ lastSignificantToken = match[0];
26445
+ yield {
26446
+ type: "JSXText",
26447
+ value: match[0]
26448
+ };
26449
+ continue;
26450
+ }
26451
+ switch (input[lastIndex]) {
26452
+ case "<":
26453
+ stack.push({ tag: "JSXTag" });
26454
+ lastIndex++;
26455
+ lastSignificantToken = "<";
26315
26456
  yield {
26316
26457
  type: "JSXPunctuator",
26317
- value: match[0]
26318
- };
26319
- continue;
26320
- }
26321
- JSXIdentifier.lastIndex = lastIndex;
26322
- if (match = JSXIdentifier.exec(input)) {
26323
- lastIndex = JSXIdentifier.lastIndex;
26324
- lastSignificantToken = match[0];
26325
- yield {
26326
- type: "JSXIdentifier",
26327
- value: match[0]
26328
- };
26329
- continue;
26330
- }
26331
- JSXString.lastIndex = lastIndex;
26332
- if (match = JSXString.exec(input)) {
26333
- lastIndex = JSXString.lastIndex;
26334
- lastSignificantToken = match[0];
26335
- yield {
26336
- type: "JSXString",
26337
- value: match[0],
26338
- closed: match[2] !== void 0
26458
+ value: "<"
26339
26459
  };
26340
26460
  continue;
26341
- }
26342
- break;
26343
- case "JSXChildren":
26344
- JSXText.lastIndex = lastIndex;
26345
- if (match = JSXText.exec(input)) {
26346
- lastIndex = JSXText.lastIndex;
26347
- lastSignificantToken = match[0];
26461
+ case "{":
26462
+ stack.push({
26463
+ tag: "InterpolationInJSX",
26464
+ nesting: braces.length
26465
+ });
26466
+ lastIndex++;
26467
+ lastSignificantToken = "?InterpolationInJSX";
26468
+ postfixIncDec = false;
26348
26469
  yield {
26349
- type: "JSXText",
26350
- value: match[0]
26470
+ type: "JSXPunctuator",
26471
+ value: "{"
26351
26472
  };
26352
26473
  continue;
26353
- }
26354
- switch (input[lastIndex]) {
26355
- case "<":
26356
- stack.push({ tag: "JSXTag" });
26357
- lastIndex++;
26358
- lastSignificantToken = "<";
26359
- yield {
26360
- type: "JSXPunctuator",
26361
- value: "<"
26362
- };
26363
- continue;
26364
- case "{":
26365
- stack.push({
26366
- tag: "InterpolationInJSX",
26367
- nesting: braces.length
26368
- });
26369
- lastIndex++;
26370
- lastSignificantToken = "?InterpolationInJSX";
26371
- postfixIncDec = false;
26372
- yield {
26373
- type: "JSXPunctuator",
26374
- value: "{"
26375
- };
26376
- continue;
26377
- }
26378
- }
26379
- WhiteSpace.lastIndex = lastIndex;
26380
- if (match = WhiteSpace.exec(input)) {
26381
- lastIndex = WhiteSpace.lastIndex;
26382
- yield {
26383
- type: "WhiteSpace",
26384
- value: match[0]
26385
- };
26386
- continue;
26387
- }
26388
- LineTerminatorSequence.lastIndex = lastIndex;
26389
- if (match = LineTerminatorSequence.exec(input)) {
26390
- lastIndex = LineTerminatorSequence.lastIndex;
26474
+ }
26475
+ }
26476
+ WhiteSpace.lastIndex = lastIndex;
26477
+ if (match = WhiteSpace.exec(input)) {
26478
+ lastIndex = WhiteSpace.lastIndex;
26479
+ yield {
26480
+ type: "WhiteSpace",
26481
+ value: match[0]
26482
+ };
26483
+ continue;
26484
+ }
26485
+ LineTerminatorSequence.lastIndex = lastIndex;
26486
+ if (match = LineTerminatorSequence.exec(input)) {
26487
+ lastIndex = LineTerminatorSequence.lastIndex;
26488
+ postfixIncDec = false;
26489
+ if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) lastSignificantToken = "?NoLineTerminatorHere";
26490
+ yield {
26491
+ type: "LineTerminatorSequence",
26492
+ value: match[0]
26493
+ };
26494
+ continue;
26495
+ }
26496
+ MultiLineComment.lastIndex = lastIndex;
26497
+ if (match = MultiLineComment.exec(input)) {
26498
+ lastIndex = MultiLineComment.lastIndex;
26499
+ if (Newline.test(match[0])) {
26391
26500
  postfixIncDec = false;
26392
26501
  if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) lastSignificantToken = "?NoLineTerminatorHere";
26393
- yield {
26394
- type: "LineTerminatorSequence",
26395
- value: match[0]
26396
- };
26397
- continue;
26398
- }
26399
- MultiLineComment.lastIndex = lastIndex;
26400
- if (match = MultiLineComment.exec(input)) {
26401
- lastIndex = MultiLineComment.lastIndex;
26402
- if (Newline.test(match[0])) {
26403
- postfixIncDec = false;
26404
- if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) lastSignificantToken = "?NoLineTerminatorHere";
26405
- }
26406
- yield {
26407
- type: "MultiLineComment",
26408
- value: match[0],
26409
- closed: match[1] !== void 0
26410
- };
26411
- continue;
26412
- }
26413
- SingleLineComment.lastIndex = lastIndex;
26414
- if (match = SingleLineComment.exec(input)) {
26415
- lastIndex = SingleLineComment.lastIndex;
26416
- postfixIncDec = false;
26417
- yield {
26418
- type: "SingleLineComment",
26419
- value: match[0]
26420
- };
26421
- continue;
26422
26502
  }
26423
- firstCodePoint = String.fromCodePoint(input.codePointAt(lastIndex));
26424
- lastIndex += firstCodePoint.length;
26425
- lastSignificantToken = firstCodePoint;
26503
+ yield {
26504
+ type: "MultiLineComment",
26505
+ value: match[0],
26506
+ closed: match[1] !== void 0
26507
+ };
26508
+ continue;
26509
+ }
26510
+ SingleLineComment.lastIndex = lastIndex;
26511
+ if (match = SingleLineComment.exec(input)) {
26512
+ lastIndex = SingleLineComment.lastIndex;
26426
26513
  postfixIncDec = false;
26427
26514
  yield {
26428
- type: mode.tag.startsWith("JSX") ? "JSXInvalid" : "Invalid",
26429
- value: firstCodePoint
26515
+ type: "SingleLineComment",
26516
+ value: match[0]
26430
26517
  };
26518
+ continue;
26431
26519
  }
26432
- };
26433
- })))(), 1);
26520
+ firstCodePoint = String.fromCodePoint(input.codePointAt(lastIndex));
26521
+ lastIndex += firstCodePoint.length;
26522
+ lastSignificantToken = firstCodePoint;
26523
+ postfixIncDec = false;
26524
+ yield {
26525
+ type: mode.tag.startsWith("JSX") ? "JSXInvalid" : "Invalid",
26526
+ value: firstCodePoint
26527
+ };
26528
+ }
26529
+ };
26530
+ var js_tokens_default = jsTokens;
26531
+ //#endregion
26532
+ //#region ../../node_modules/.pnpm/strip-literal@4.0.0/node_modules/strip-literal/dist/index.mjs
26434
26533
  const FILL_COMMENT = " ";
26435
26534
  function stripLiteralFromToken(token, fillChar, filter) {
26436
26535
  if (token.type === "SingleLineComment") return FILL_COMMENT.repeat(token.value.length);
@@ -26468,10 +26567,13 @@ function optionsWithDefaults(options) {
26468
26567
  filter: options?.filter ?? (() => true)
26469
26568
  };
26470
26569
  }
26570
+ /**
26571
+ * Strip literal from code.
26572
+ */
26471
26573
  function stripLiteral(code, options) {
26472
26574
  let result = "";
26473
26575
  const _options = optionsWithDefaults(options);
26474
- for (const token of (0, import_js_tokens.default)(code, { jsx: false })) result += stripLiteralFromToken(token, _options.fillChar, _options.filter);
26576
+ for (const token of js_tokens_default(code, { jsx: false })) result += stripLiteralFromToken(token, _options.fillChar, _options.filter);
26475
26577
  return result;
26476
26578
  }
26477
26579
  //#endregion
@@ -26713,7 +26815,8 @@ function assetPlugin(config) {
26713
26815
  }
26714
26816
  }
26715
26817
  if (config.command === "build" && !this.environment.config.build.emitAssets) {
26716
- for (const file in bundle) if (bundle[file].type === "asset" && !file.endsWith("ssr-manifest.json") && !jsSourceMapRE.test(file)) delete bundle[file];
26818
+ const chunkImportMapEnabled = this.environment.config.build.chunkImportMap;
26819
+ for (const file in bundle) if (bundle[file].type === "asset" && !file.endsWith("ssr-manifest.json") && !jsSourceMapRE.test(file) && !(chunkImportMapEnabled && file === getImportMapFilename(this.environment.config))) delete bundle[file];
26717
26820
  }
26718
26821
  },
26719
26822
  watchChange(id) {
@@ -26776,8 +26879,10 @@ async function fileToBuiltUrl(pluginContext, id, skipPublicCheck = false, forceI
26776
26879
  const topLevelConfig = environment.getTopLevelConfig();
26777
26880
  if (!skipPublicCheck) {
26778
26881
  const publicFile = checkPublicFile(id, topLevelConfig);
26779
- if (publicFile) if (inlineRE$3.test(id)) id = publicFile;
26780
- else return publicFileToBuiltUrl(id, topLevelConfig);
26882
+ if (publicFile) {
26883
+ if (inlineRE$3.test(id)) id = publicFile;
26884
+ else return publicFileToBuiltUrl(id, topLevelConfig);
26885
+ }
26781
26886
  }
26782
26887
  const cache = assetCache.get(environment);
26783
26888
  const cached = cache.get(id);
@@ -27190,7 +27295,7 @@ var require_src$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
27190
27295
  };
27191
27296
  }));
27192
27297
  //#endregion
27193
- //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.25_tsx@4.23.1_yaml@2.9.0/node_modules/postcss-load-config/src/req.js
27298
+ //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.26_tsx@4.23.12_yaml@2.9.0/node_modules/postcss-load-config/src/req.js
27194
27299
  var require_req = /* @__PURE__ */ __commonJSMin(((exports, module) => {
27195
27300
  const { createRequire: createRequire$2 } = __require$1("node:module");
27196
27301
  const { fileURLToPath: fileURLToPath$2, pathToFileURL: pathToFileURL$1 } = __require$1("node:url");
@@ -27232,7 +27337,7 @@ var require_req = /* @__PURE__ */ __commonJSMin(((exports, module) => {
27232
27337
  module.exports = req;
27233
27338
  }));
27234
27339
  //#endregion
27235
- //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.25_tsx@4.23.1_yaml@2.9.0/node_modules/postcss-load-config/src/options.js
27340
+ //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.26_tsx@4.23.12_yaml@2.9.0/node_modules/postcss-load-config/src/options.js
27236
27341
  var require_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
27237
27342
  const req = require_req();
27238
27343
  /**
@@ -27266,7 +27371,7 @@ var require_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
27266
27371
  module.exports = options;
27267
27372
  }));
27268
27373
  //#endregion
27269
- //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.25_tsx@4.23.1_yaml@2.9.0/node_modules/postcss-load-config/src/plugins.js
27374
+ //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.26_tsx@4.23.12_yaml@2.9.0/node_modules/postcss-load-config/src/plugins.js
27270
27375
  var require_plugins = /* @__PURE__ */ __commonJSMin(((exports, module) => {
27271
27376
  const req = require_req();
27272
27377
  /**
@@ -27320,7 +27425,7 @@ var require_plugins = /* @__PURE__ */ __commonJSMin(((exports, module) => {
27320
27425
  module.exports = plugins;
27321
27426
  }));
27322
27427
  //#endregion
27323
- //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.25_tsx@4.23.1_yaml@2.9.0/node_modules/postcss-load-config/src/index.js
27428
+ //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.26_tsx@4.23.12_yaml@2.9.0/node_modules/postcss-load-config/src/index.js
27324
27429
  var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
27325
27430
  const { resolve: resolve$3 } = __require$1("node:path");
27326
27431
  const config = require_src$1();
@@ -27836,8 +27941,10 @@ function cssPlugin(config) {
27836
27941
  const resolveUrl = (url, importer) => idResolver(environment, url, importer);
27837
27942
  const urlResolver = async (url, importer) => {
27838
27943
  const decodedUrl = decodeURI(url);
27839
- if (checkPublicFile(decodedUrl, config)) if (encodePublicUrlsInCSS(config)) return [publicFileToBuiltUrl(decodedUrl, config), void 0];
27840
- else return [joinUrlSegments(joinUrlSegments(config.server.origin ?? "", config.base), decodedUrl), void 0];
27944
+ if (checkPublicFile(decodedUrl, config)) {
27945
+ if (encodePublicUrlsInCSS(config)) return [publicFileToBuiltUrl(decodedUrl, config), void 0];
27946
+ else return [joinUrlSegments(joinUrlSegments(config.server.origin ?? "", config.base), decodedUrl), void 0];
27947
+ }
27841
27948
  const [id, fragment] = decodedUrl.split("#");
27842
27949
  let resolved = await resolveUrl(id, importer);
27843
27950
  if (resolved) {
@@ -28102,11 +28209,13 @@ function cssPostPlugin(config) {
28102
28209
  chunkCSSMap.set(chunk.fileName, chunkCSS);
28103
28210
  }
28104
28211
  }
28105
- if (s) if (config.build.sourcemap) return {
28106
- code: s.toString(),
28107
- map: s.generateMap({ hires: "boundary" })
28108
- };
28109
- else return { code: s.toString() };
28212
+ if (s) {
28213
+ if (config.build.sourcemap) return {
28214
+ code: s.toString(),
28215
+ map: s.generateMap({ hires: "boundary" })
28216
+ };
28217
+ else return { code: s.toString() };
28218
+ }
28110
28219
  return null;
28111
28220
  },
28112
28221
  augmentChunkHash(chunk) {
@@ -28143,8 +28252,8 @@ function cssPostPlugin(config) {
28143
28252
  });
28144
28253
  }
28145
28254
  }
28146
- if (config.build.chunkImportMap && chunkCssReferences.size) {
28147
- const importMap = getImportMap(bundle, config);
28255
+ if (this.environment.config.build.chunkImportMap && chunkCssReferences.size) {
28256
+ const importMap = getImportMap(bundle, this.environment.config);
28148
28257
  const importMapReverseMapping = Object.fromEntries(Object.entries(importMap.mapping).map(([k, v]) => [v, k]));
28149
28258
  const chunksByPreliminaryFileName = new Map(Object.values(bundle).filter((output) => output.type === "chunk").map((chunk) => [chunk.preliminaryFileName, chunk]));
28150
28259
  for (const [chunkFileName, referenceId] of chunkCssReferences) {
@@ -28160,9 +28269,10 @@ function cssPostPlugin(config) {
28160
28269
  if (pureCssChunks.size) {
28161
28270
  const prelimaryNameToChunkMap = Object.fromEntries(Object.values(bundle).filter((chunk) => chunk.type === "chunk").map((chunk) => [chunk.preliminaryFileName, chunk.fileName]));
28162
28271
  const pureCssChunkNames = [...pureCssChunks].map((pureCssChunk) => prelimaryNameToChunkMap[pureCssChunk.fileName]).filter(Boolean);
28272
+ const pureCssChunkNameSet = new Set(pureCssChunkNames);
28163
28273
  let importMapReverseMapping;
28164
- if (config.build.chunkImportMap) {
28165
- const importMap = getImportMap(bundle, config);
28274
+ if (this.environment.config.build.chunkImportMap) {
28275
+ const importMap = getImportMap(bundle, this.environment.config);
28166
28276
  importMapReverseMapping = Object.fromEntries(Object.entries(importMap.mapping).map(([k, v]) => [v, k]));
28167
28277
  }
28168
28278
  const replaceEmptyChunk = getEmptyChunkReplacer(importMapReverseMapping ? pureCssChunkNames.map((name) => importMapReverseMapping[name] ?? name) : pureCssChunkNames, opts.format);
@@ -28171,7 +28281,7 @@ function cssPostPlugin(config) {
28171
28281
  if (chunk.type === "chunk") {
28172
28282
  let chunkImportsPureCssChunk = false;
28173
28283
  chunk.imports = chunk.imports.filter((file) => {
28174
- if (pureCssChunkNames.includes(file)) {
28284
+ if (pureCssChunkNameSet.has(file)) {
28175
28285
  const { importedCss, importedAssets } = bundle[file].viteMetadata;
28176
28286
  importedCss.forEach((file) => chunk.viteMetadata.importedCss.add(file));
28177
28287
  importedAssets.forEach((file) => chunk.viteMetadata.importedAssets.add(file));
@@ -28211,15 +28321,17 @@ function injectInlinedCSS(s, ctx, code, format, injectCode) {
28211
28321
  const m = (format === "iife" ? IIFE_BEGIN_RE : UMD_BEGIN_RE).exec(code);
28212
28322
  if (!m) ctx.error("Injection point for inlined CSS not found");
28213
28323
  injectionPoint = m.index + m[0].length;
28214
- } else if (format === "es") if (code.startsWith("#!")) {
28215
- const newlinePos = code.indexOf("\n");
28216
- if (newlinePos === -1) {
28217
- s.append(`\n${injectCode}`);
28218
- return;
28219
- }
28220
- injectionPoint = newlinePos + 1;
28221
- } else injectionPoint = 0;
28222
- else ctx.error("Non supported format");
28324
+ } else if (format === "es") {
28325
+ if (code.startsWith("#!")) {
28326
+ const fileStartIndex = getFileStartIndex(code);
28327
+ const hashbang = code.slice(0, fileStartIndex);
28328
+ if (!lineTerminatorRE.test(hashbang)) {
28329
+ s.append(`\n${injectCode}`);
28330
+ return;
28331
+ }
28332
+ injectionPoint = fileStartIndex;
28333
+ } else injectionPoint = 0;
28334
+ } else ctx.error("Non supported format");
28223
28335
  s.appendRight(injectionPoint, injectCode);
28224
28336
  }
28225
28337
  function cssAnalysisPlugin(config) {
@@ -28582,13 +28694,15 @@ async function resolvePostcssConfig(config) {
28582
28694
  const searchPath = typeof inlineOptions === "string" ? inlineOptions : config.root;
28583
28695
  const stopDir = searchForWorkspaceRoot(config.root);
28584
28696
  result = (0, import_src.default)({}, searchPath, { stopDir }).catch((e) => {
28585
- if (!e.message.includes("No PostCSS Config found")) if (e instanceof Error) {
28586
- const { name, message, stack } = e;
28587
- e.name = "Failed to load PostCSS config";
28588
- e.message = `Failed to load PostCSS config (searchPath: ${searchPath}): [${name}] ${message}\n${stack}`;
28589
- e.stack = "";
28590
- throw e;
28591
- } else throw new Error(`Failed to load PostCSS config: ${e}`);
28697
+ if (!e.message.includes("No PostCSS Config found")) {
28698
+ if (e instanceof Error) {
28699
+ const { name, message, stack } = e;
28700
+ e.name = "Failed to load PostCSS config";
28701
+ e.message = `Failed to load PostCSS config (searchPath: ${searchPath}): [${name}] ${message}\n${stack}`;
28702
+ e.stack = "";
28703
+ throw e;
28704
+ } else throw new Error(`Failed to load PostCSS config: ${e}`);
28705
+ }
28592
28706
  return null;
28593
28707
  });
28594
28708
  result.then((resolved) => {
@@ -28722,10 +28836,12 @@ async function minifyCSS(css, config, inlined, filename = defaultCssBundleName)
28722
28836
  const { code, warnings } = (await importLightningCSS()).transform({
28723
28837
  ...config.css.lightningcss,
28724
28838
  targets: convertTargets(config.build.cssTarget),
28725
- cssModules: void 0,
28726
28839
  filename,
28727
28840
  code: Buffer.from(css),
28728
- minify: true
28841
+ minify: true,
28842
+ cssModules: void 0,
28843
+ visitor: void 0,
28844
+ customAtRules: void 0
28729
28845
  });
28730
28846
  for (const warning of warnings) {
28731
28847
  let msg = `[lightningcss minify] ${warning.message}`;
@@ -29354,8 +29470,9 @@ async function compileLightningCSS(environment, id, src, deps, workerController,
29354
29470
  };
29355
29471
  }
29356
29472
  function getLightningCssErrorMessageForIeSyntaxes(code) {
29357
- if (/[\s;{]\*[a-zA-Z-][\w-]+\s*:/.test(code)) return ".\nThis file contains star property hack (e.g. `*zoom`), which was used in the past to support old Internet Explorer versions. This is not a valid CSS syntax and will be ignored by modern browsers. \nWhile this is not supported by LightningCSS, you can set `css.lightningcss.errorRecovery: true` to strip these codes.";
29358
- if (/min-width:\s*0\\0/.test(code)) return ".\nThis file contains @media zero hack (e.g. `@media (min-width: 0\\0)`), which was used in the past to support old Internet Explorer versions. This is not a valid CSS syntax and will be ignored by modern browsers. \nWhile this is not supported by LightningCSS, you can set `css.lightningcss.errorRecovery: true` to strip these codes.";
29473
+ const commonIeMessage = ", which was used in the past to support old Internet Explorer versions. This is not a valid CSS syntax and will be ignored by modern browsers. \nWhile this is not supported by LightningCSS, you can set `css.lightningcss.errorRecovery: true` to strip these codes.";
29474
+ if (/[\s;{]\*[a-zA-Z-][\w-]+\s*:/.test(code)) return ".\nThis file contains star property hack (e.g. `*zoom`)" + commonIeMessage;
29475
+ if (/min-width:\s*0\\0/.test(code)) return ".\nThis file contains @media zero hack (e.g. `@media (min-width: 0\\0)`)" + commonIeMessage;
29359
29476
  }
29360
29477
  const map = {
29361
29478
  chrome: "chrome",
@@ -29463,9 +29580,8 @@ const esRE = /es(6|\d{4})/;
29463
29580
  const versionRE = /\d/;
29464
29581
  const convertTargetsCache = /* @__PURE__ */ new Map();
29465
29582
  const convertTargets = (esbuildTarget) => {
29466
- if (!esbuildTarget) return {};
29467
- const cached = convertTargetsCache.get(esbuildTarget);
29468
- if (cached) return cached;
29583
+ if (!esbuildTarget) return void 0;
29584
+ if (convertTargetsCache.has(esbuildTarget)) return convertTargetsCache.get(esbuildTarget);
29469
29585
  const targets = {};
29470
29586
  const entriesWithoutES = arraify(esbuildTarget).flatMap((e) => {
29471
29587
  const match = esRE.exec(e);
@@ -29491,8 +29607,9 @@ const convertTargets = (esbuildTarget) => {
29491
29607
  }
29492
29608
  throw new Error(`Unsupported target "${entry}"`);
29493
29609
  }
29494
- convertTargetsCache.set(esbuildTarget, targets);
29495
- return targets;
29610
+ const result = Object.keys(targets).length > 0 ? targets : void 0;
29611
+ convertTargetsCache.set(esbuildTarget, result);
29612
+ return result;
29496
29613
  };
29497
29614
  function resolveLibCssFilename(libOptions, root, packageCache) {
29498
29615
  if (typeof libOptions.cssFileName === "string") return `${libOptions.cssFileName}.css`;
@@ -29823,20 +29940,22 @@ function buildHtmlPlugin(config) {
29823
29940
  else if (attr.type === "src") {
29824
29941
  const url = decodeURIIfPossible(attr.value);
29825
29942
  if (url === void 0) {} else if (checkPublicFile(url, config)) overwriteAttrValue(s, attr.location, partialEncodeURIPath(toOutputPublicFilePath(url)));
29826
- else if (!isExcludedUrl(url)) if (node.nodeName === "link" && isCSSRequest(url) && !("media" in attr.attributes || "disabled" in attr.attributes)) {
29827
- const importExpression = `\nimport ${JSON.stringify(url)}`;
29828
- styleUrls.push({
29829
- url,
29830
- start: nodeStartWithLeadingWhitespace(node),
29831
- end: node.sourceCodeLocation.endOffset
29832
- });
29833
- js += importExpression;
29834
- } else {
29835
- const shouldInline = node.nodeName === "link" && attr.attributes.rel && parseRelAttr(attr.attributes.rel).some((v) => noInlineLinkRels.has(v)) ? false : void 0;
29836
- assetUrlsPromises.push((async () => {
29837
- const processedUrl = await processAssetUrl(url, shouldInline);
29838
- if (processedUrl !== url) overwriteAttrValue(s, attr.location, partialEncodeURIPath(processedUrl));
29839
- })());
29943
+ else if (!isExcludedUrl(url)) {
29944
+ if (node.nodeName === "link" && isCSSRequest(url) && !("media" in attr.attributes || "disabled" in attr.attributes)) {
29945
+ const importExpression = `\nimport ${JSON.stringify(url)}`;
29946
+ styleUrls.push({
29947
+ url,
29948
+ start: nodeStartWithLeadingWhitespace(node),
29949
+ end: node.sourceCodeLocation.endOffset
29950
+ });
29951
+ js += importExpression;
29952
+ } else {
29953
+ const shouldInline = node.nodeName === "link" && attr.attributes.rel && parseRelAttr(attr.attributes.rel).some((v) => noInlineLinkRels.has(v)) ? false : void 0;
29954
+ assetUrlsPromises.push((async () => {
29955
+ const processedUrl = await processAssetUrl(url, shouldInline);
29956
+ if (processedUrl !== url) overwriteAttrValue(s, attr.location, partialEncodeURIPath(processedUrl));
29957
+ })());
29958
+ }
29840
29959
  }
29841
29960
  }
29842
29961
  const inlineStyle = findNeedTransformStyleAttribute(node);
@@ -29961,6 +30080,13 @@ function buildHtmlPlugin(config) {
29961
30080
  assetTags.push(...getCssTagsForChunk(chunk, toOutputAssetFilePath));
29962
30081
  result = injectToHead(result, assetTags);
29963
30082
  }
30083
+ if (config.command === "serve" && this.environment.config.consumer === "client" && this.environment.config.isBundled) result = injectToHead(result, [{
30084
+ tag: "script",
30085
+ attrs: {
30086
+ type: "module",
30087
+ src: path.posix.join(config.base, BUNDLED_DEV_CLIENT_FILENAME)
30088
+ }
30089
+ }], true);
29964
30090
  if (!this.environment.config.build.cssCodeSplit) {
29965
30091
  const cssBundleName = cssBundleNameCache.get(config);
29966
30092
  const cssChunk = cssBundleName && Object.values(bundle).find((chunk) => chunk.type === "asset" && chunk.names.includes(cssBundleName));
@@ -30058,7 +30184,7 @@ function preImportMapHook(config) {
30058
30184
  function postImportMapHook(config) {
30059
30185
  const decoder = new TextDecoder();
30060
30186
  return function(html, { bundle }) {
30061
- const chunkImportMapEnabled = config.command === "build" && config.build.chunkImportMap;
30187
+ const chunkImportMapEnabled = config.command === "build" && config.environments.client.build.chunkImportMap;
30062
30188
  if (importMapAppendRE.test(html)) {
30063
30189
  let importMap;
30064
30190
  html = html.replace(importMapRE, (match) => {
@@ -30072,7 +30198,7 @@ function postImportMapHook(config) {
30072
30198
  }
30073
30199
  if (chunkImportMapEnabled) {
30074
30200
  const nonce = config.html?.cspNonce;
30075
- const importMap = bundle[getImportMapFilename(config)];
30201
+ const importMap = bundle[getImportMapFilename(config.environments.client)];
30076
30202
  const importMapHtml = serializeTag({
30077
30203
  tag: "script",
30078
30204
  attrs: {
@@ -30296,23 +30422,29 @@ function serializeAttrs(attrs) {
30296
30422
  function incrementIndent(indent = "") {
30297
30423
  return `${indent}${indent[0] === " " ? " " : " "}`;
30298
30424
  }
30299
- function getImportMapFilename(config) {
30300
- const chunkImportMap = config.build.rolldownOptions.experimental?.chunkImportMap;
30425
+ function getImportMapFilename(options) {
30426
+ const chunkImportMap = options.build.rolldownOptions.experimental?.chunkImportMap;
30301
30427
  if (typeof chunkImportMap === "object" && chunkImportMap.fileName) return chunkImportMap.fileName;
30302
30428
  return "importmap.json";
30303
30429
  }
30430
+ function getImportMapBaseUrl(options) {
30431
+ const chunkImportMap = options.build.rolldownOptions.experimental?.chunkImportMap;
30432
+ if (typeof chunkImportMap === "object" && chunkImportMap.baseUrl) return chunkImportMap.baseUrl;
30433
+ return "/";
30434
+ }
30304
30435
  /**
30305
30436
  * Read and parse the chunk import map asset from the bundle.
30306
30437
  * Returns `undefined` when the import map is not present in the bundle.
30307
30438
  */
30308
- function getImportMap(bundle, config) {
30309
- const asset = bundle[getImportMapFilename(config)];
30439
+ function getImportMap(bundle, options) {
30440
+ const asset = bundle[getImportMapFilename(options)];
30310
30441
  if (!asset) return void 0;
30311
30442
  const content = JSON.parse(typeof asset.source === "string" ? asset.source : new TextDecoder().decode(asset.source));
30443
+ const baseUrl = getImportMapBaseUrl(options);
30312
30444
  return {
30313
30445
  asset,
30314
30446
  content,
30315
- mapping: Object.fromEntries(Object.entries(content.imports).map(([k, v]) => [k.slice(config.base.length), v.slice(config.base.length)]))
30447
+ mapping: Object.fromEntries(Object.entries(content.imports).map(([k, v]) => [k.slice(baseUrl.length), v.slice(baseUrl.length)]))
30316
30448
  };
30317
30449
  }
30318
30450
  //#endregion
@@ -30504,7 +30636,7 @@ If you intend to import that asset, put the file in the src directory, and use $
30504
30636
  //#region ../../vite/packages/vite/src/node/plugins/define.ts
30505
30637
  const nonJsRe = /\.json(?:$|\?)/;
30506
30638
  const isNonJsRequest = (request) => nonJsRe.test(request);
30507
- const escapedDotRE = /(?<!\\)\\./g;
30639
+ const escapedDotRE = /(?<!\\)\\\./g;
30508
30640
  function definePlugin(config) {
30509
30641
  const isBuild = config.command === "build";
30510
30642
  const isBuildLib = isBuild && config.build.lib;
@@ -30921,7 +31053,7 @@ function indexHtmlMiddleware(root, server) {
30921
31053
  }
30922
31054
  const filePath = pathname.slice(1);
30923
31055
  let file = fullBundle.memoryFiles.get(filePath);
30924
- if (!file && fullBundle.memoryFiles.size !== 0) return next();
31056
+ if (!file && fullBundle.hasBuildOutput) return next();
30925
31057
  if ([
30926
31058
  "document",
30927
31059
  "iframe",
@@ -31551,7 +31683,13 @@ function triggerLazyBundlingMiddleware(server) {
31551
31683
  }
31552
31684
  const moduleId = params.get("id");
31553
31685
  const clientId = params.get("clientId");
31554
- const result = await bundledDev.triggerLazyBundling(moduleId, clientId);
31686
+ let result;
31687
+ try {
31688
+ result = await bundledDev.triggerLazyBundling(moduleId, clientId);
31689
+ } catch (e) {
31690
+ server.config.logger.error(`Failed to trigger lazy bundling for ${moduleId} (clientId: ${clientId}):` + e, { error: e });
31691
+ return next(/* @__PURE__ */ new Error(`Failed to trigger lazy bundling`));
31692
+ }
31555
31693
  if (result == null) return next();
31556
31694
  res.setHeader("Content-Type", "application/javascript");
31557
31695
  res.on("finish", () => bundledDev.markPayloadDelivered(result.filename));
@@ -31904,7 +32042,7 @@ async function startServer(server, hostname, inlinePort) {
31904
32042
  if (!httpServer) throw new Error("Cannot call server.listen in middleware mode.");
31905
32043
  const options = server.config.server;
31906
32044
  const configPort = inlinePort ?? options.port;
31907
- const port = (!configPort || configPort === server._configServerPort ? server._currentServerPort : configPort) ?? 5173;
32045
+ const port = configPort === server._configServerPort ? server._currentServerPort ?? configPort : configPort;
31908
32046
  server._configServerPort = configPort;
31909
32047
  server._currentServerPort = await httpServerStart(httpServer, {
31910
32048
  port,
@@ -32535,9 +32673,10 @@ function lexAcceptedHmrDeps(code, start, urls) {
32535
32673
  prevState = state;
32536
32674
  state = 3;
32537
32675
  } else if (whitespaceRE.test(char)) continue;
32538
- else if (state === 0) if (char === `[`) state = 4;
32539
- else return true;
32540
- else if (char === `]`) return false;
32676
+ else if (state === 0) {
32677
+ if (char === `[`) state = 4;
32678
+ else return true;
32679
+ } else if (char === `]`) return false;
32541
32680
  else if (char === ",") continue;
32542
32681
  else error(i);
32543
32682
  break;
@@ -32879,16 +33018,18 @@ function webWorkerPostPlugin(_config) {
32879
33018
  }
32880
33019
  let injectedImportMeta = false;
32881
33020
  let s;
32882
- for (const { s: start, e: end, d: dynamicIndex } of imports) if (dynamicIndex === -2) if (code.slice(end, end + 4) === ".url") {
32883
- s ||= new MagicString(code);
32884
- s.overwrite(start, end + 4, "self.location.href");
32885
- } else {
32886
- s ||= new MagicString(code);
32887
- if (!injectedImportMeta) {
32888
- s.prepend("const _vite_importMeta = { url: self.location.href };\n");
32889
- injectedImportMeta = true;
33021
+ for (const { s: start, e: end, d: dynamicIndex } of imports) if (dynamicIndex === -2) {
33022
+ if (code.slice(end, end + 4) === ".url") {
33023
+ s ||= new MagicString(code);
33024
+ s.overwrite(start, end + 4, "self.location.href");
33025
+ } else {
33026
+ s ||= new MagicString(code);
33027
+ if (!injectedImportMeta) {
33028
+ s.prepend("const _vite_importMeta = { url: self.location.href };\n");
33029
+ injectedImportMeta = true;
33030
+ }
33031
+ s.overwrite(start, end, "_vite_importMeta");
32890
33032
  }
32891
- s.overwrite(start, end, "_vite_importMeta");
32892
33033
  }
32893
33034
  if (!s) return;
32894
33035
  return {
@@ -32928,13 +33069,14 @@ function webWorkerPlugin(config) {
32928
33069
  name: options?.name
32929
33070
  }`;
32930
33071
  let urlCode;
32931
- if (isBundled) if (isWorker && config.bundleChain.at(-1) === cleanUrl(id)) urlCode = "self.location.href";
32932
- else if (inlineRE.test(id)) {
32933
- const result = await bundleWorkerEntry(config, id);
32934
- for (const file of result.watchedFiles) this.addWatchFile(file);
32935
- const jsContent = `const jsContent = ${JSON.stringify(result.entryCode)};`;
32936
- return {
32937
- code: workerConstructor === "Worker" ? `${jsContent}
33072
+ if (isBundled) {
33073
+ if (isWorker && config.bundleChain.at(-1) === cleanUrl(id)) urlCode = "self.location.href";
33074
+ else if (inlineRE.test(id)) {
33075
+ const result = await bundleWorkerEntry(config, id);
33076
+ for (const file of result.watchedFiles) this.addWatchFile(file);
33077
+ const jsContent = `const jsContent = ${JSON.stringify(result.entryCode)};`;
33078
+ return {
33079
+ code: workerConstructor === "Worker" ? `${jsContent}
32938
33080
  const blob = typeof self !== "undefined" && self.Blob && new Blob([${workerType === "classic" ? `'(self.URL || self.webkitURL).revokeObjectURL(self.location.href);',` : `'URL.revokeObjectURL(import.meta.url);',`}jsContent], { type: "text/javascript;charset=utf-8" });
32939
33081
  export default function WorkerWrapper(options) {
32940
33082
  let objURL;
@@ -32960,19 +33102,19 @@ function webWorkerPlugin(config) {
32960
33102
  );
32961
33103
  }
32962
33104
  `,
32963
- map: { mappings: "" }
32964
- };
33105
+ map: { mappings: "" }
33106
+ };
33107
+ } else {
33108
+ const result = await workerFileToUrl(config, id);
33109
+ let url;
33110
+ if (this.environment.config.command === "serve" && this.environment.config.isBundled) {
33111
+ emitWorkerAssetsForBundledDev(this, config);
33112
+ url = toOutputFilePathInJSForBundledDev(this.environment, result.entryFilename);
33113
+ } else url = result.entryUrlPlaceholder;
33114
+ urlCode = JSON.stringify(url);
33115
+ for (const file of result.watchedFiles) this.addWatchFile(file);
33116
+ }
32965
33117
  } else {
32966
- const result = await workerFileToUrl(config, id);
32967
- let url;
32968
- if (this.environment.config.command === "serve" && this.environment.config.isBundled) {
32969
- emitWorkerAssetsForBundledDev(this, config);
32970
- url = toOutputFilePathInJSForBundledDev(this.environment, result.entryFilename);
32971
- } else url = result.entryUrlPlaceholder;
32972
- urlCode = JSON.stringify(url);
32973
- for (const file of result.watchedFiles) this.addWatchFile(file);
32974
- }
32975
- else {
32976
33118
  let url = await fileToUrl$1(this, cleanUrl(id));
32977
33119
  url = injectQuery(url, `${WORKER_FILE_ID}&type=${workerType}`);
32978
33120
  urlCode = JSON.stringify(url);
@@ -33001,10 +33143,12 @@ function webWorkerPlugin(config) {
33001
33143
  let injectEnv = "";
33002
33144
  if (workerType === "classic") injectEnv = `importScripts(${JSON.stringify(path.posix.join(config.base, ENV_PUBLIC_PATH))})\n`;
33003
33145
  else if (workerType === "module") injectEnv = `import ${JSON.stringify(ENV_PUBLIC_PATH)}\n`;
33004
- else if (workerType === "ignore") if (this.environment.config.isBundled) injectEnv = "";
33005
- else {
33006
- const environment = this.environment;
33007
- injectEnv = ((environment.mode === "dev" ? environment.moduleGraph : void 0)?.getModuleById(ENV_ENTRY))?.transformResult?.code || "";
33146
+ else if (workerType === "ignore") {
33147
+ if (this.environment.config.isBundled) injectEnv = "";
33148
+ else {
33149
+ const environment = this.environment;
33150
+ injectEnv = ((environment.mode === "dev" ? environment.moduleGraph : void 0)?.getModuleById(ENV_ENTRY))?.transformResult?.code || "";
33151
+ }
33008
33152
  }
33009
33153
  if (injectEnv) {
33010
33154
  const s = new MagicString(raw);
@@ -33334,13 +33478,15 @@ function importAnalysisPlugin(config) {
33334
33478
  if (prop === ".hot") {
33335
33479
  hasHMR = true;
33336
33480
  const endHot = end + 4 + (source[end + 4] === "?" ? 1 : 0);
33337
- if (source.slice(endHot, endHot + 7) === ".accept") if (source.slice(endHot, endHot + 14) === ".acceptExports") {
33338
- const importAcceptedExports = orderedAcceptedExports[index] = /* @__PURE__ */ new Set();
33339
- lexAcceptedHmrExports(source, source.indexOf("(", endHot + 14) + 1, importAcceptedExports);
33340
- isPartiallySelfAccepting = true;
33341
- } else {
33342
- const importAcceptedUrls = orderedAcceptedUrls[index] = /* @__PURE__ */ new Set();
33343
- if (lexAcceptedHmrDeps(source, source.indexOf("(", endHot + 7) + 1, importAcceptedUrls)) isSelfAccepting = true;
33481
+ if (source.slice(endHot, endHot + 7) === ".accept") {
33482
+ if (source.slice(endHot, endHot + 14) === ".acceptExports") {
33483
+ const importAcceptedExports = orderedAcceptedExports[index] = /* @__PURE__ */ new Set();
33484
+ lexAcceptedHmrExports(source, source.indexOf("(", endHot + 14) + 1, importAcceptedExports);
33485
+ isPartiallySelfAccepting = true;
33486
+ } else {
33487
+ const importAcceptedUrls = orderedAcceptedUrls[index] = /* @__PURE__ */ new Set();
33488
+ if (lexAcceptedHmrDeps(source, source.indexOf("(", endHot + 7) + 1, importAcceptedUrls)) isSelfAccepting = true;
33489
+ }
33344
33490
  }
33345
33491
  } else if (prop === ".env") hasEnv = true;
33346
33492
  return;
@@ -33415,8 +33561,10 @@ function importAnalysisPlugin(config) {
33415
33561
  debugHmr?.(`${isSelfAccepting ? `[self-accepts]` : isPartiallySelfAccepting ? `[accepts-exports]` : acceptedUrls.size ? `[accepts-deps]` : `[detected api usage]`} ${prettifyUrl(importer, root)}`);
33416
33562
  str().prepend(`import { createHotContext as __vite__createHotContext } from "${clientPublicPath}";import.meta.hot = __vite__createHotContext(${JSON.stringify(normalizeHmrUrl(importerModule.url))});`);
33417
33563
  }
33418
- if (needQueryInjectHelper) if (isClassicWorker) str().append("\n" + __vite__injectQuery.toString());
33419
- else str().prepend(`import { injectQuery as __vite__injectQuery } from "${clientPublicPath}";`);
33564
+ if (needQueryInjectHelper) {
33565
+ if (isClassicWorker) str().append("\n" + __vite__injectQuery.toString());
33566
+ else str().prepend(`import { injectQuery as __vite__injectQuery } from "${clientPublicPath}";`);
33567
+ }
33420
33568
  const normalizedAcceptedUrls = /* @__PURE__ */ new Set();
33421
33569
  for (const { url, start, end } of acceptedUrls) {
33422
33570
  let [normalized, resolvedId] = await normalizeUrl(url, start).catch(() => []);
@@ -33546,9 +33694,10 @@ function transformCjsImport(importExp, url, rawUrl, importIndex, importer, isNod
33546
33694
  const lines = [];
33547
33695
  importNames.forEach(({ importedName, localName }) => {
33548
33696
  if (importedName === "*") lines.push(`const ${localName} = (${interopHelperStr})(${cjsModuleName}, ${+isNodeMode})`);
33549
- else if (importedName === "default") if (isNodeMode) lines.push(`const ${localName} = ${cjsModuleName}`);
33550
- else lines.push(`const ${localName} = !${cjsModuleName}.__esModule ? ${cjsModuleName} : ${cjsModuleName}.default`);
33551
- else lines.push(`const ${localName} = ${cjsModuleName}["${importedName}"]`);
33697
+ else if (importedName === "default") {
33698
+ if (isNodeMode) lines.push(`const ${localName} = ${cjsModuleName}`);
33699
+ else lines.push(`const ${localName} = !${cjsModuleName}.__esModule ? ${cjsModuleName} : ${cjsModuleName}.default`);
33700
+ } else lines.push(`const ${localName} = ${cjsModuleName}["${importedName}"]`);
33552
33701
  });
33553
33702
  if (defaultExports) lines.push(`export default ${defaultExports}`);
33554
33703
  if (exportNames.length) lines.push(`export { ${exportNames.join(", ")} }`);
@@ -34206,8 +34355,8 @@ function buildImportAnalysisPlugin(config) {
34206
34355
  const { modulePreload } = this.environment.config.build;
34207
34356
  let importMapMapping;
34208
34357
  let importMapReverseMapping;
34209
- if (config.build.chunkImportMap) {
34210
- const importMap = getImportMap(bundle, config);
34358
+ if (this.environment.config.build.chunkImportMap) {
34359
+ const importMap = getImportMap(bundle, this.environment.config);
34211
34360
  importMapMapping = importMap.mapping;
34212
34361
  importMapReverseMapping = Object.fromEntries(Object.entries(importMapMapping).map(([k, v]) => [v, k]));
34213
34362
  if (config.isOutputOptionsForLegacyChunks?.(opts)) {
@@ -34216,7 +34365,7 @@ function buildImportAnalysisPlugin(config) {
34216
34365
  fileName: "importmap.legacy.json",
34217
34366
  source: importMap.asset.source
34218
34367
  });
34219
- delete bundle[getImportMapFilename(config)];
34368
+ delete bundle[getImportMapFilename(this.environment.config)];
34220
34369
  }
34221
34370
  }
34222
34371
  for (const file in bundle) {
@@ -34325,7 +34474,7 @@ function buildImportAnalysisPlugin(config) {
34325
34474
  }
34326
34475
  if (fileDeps.length > 0) {
34327
34476
  const mapDepsCode = `const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=${`[${fileDeps.map((fileDep) => fileDep.runtime ? fileDep.url : JSON.stringify(fileDep.url)).join(",")}]`})))=>i.map(i=>d[i]);\n`;
34328
- if (code.startsWith("#!")) s.prependLeft(code.indexOf("\n") + 1, mapDepsCode);
34477
+ if (code.startsWith("#!")) s.prependLeft(getFileStartIndex(code), mapDepsCode);
34329
34478
  else s.prepend(mapDepsCode);
34330
34479
  }
34331
34480
  let markerStartPos = findPreloadMarker(code);
@@ -35006,9 +35155,10 @@ async function toAbsoluteGlob(glob, root, importer, resolveId, base) {
35006
35155
  }
35007
35156
  root = globSafePath(root);
35008
35157
  let dir;
35009
- if (base) if (base[0] === "/") dir = posix.join(root, base);
35010
- else dir = posix.resolve(importer ? globSafePath(dirname$2(importer)) : root, base);
35011
- else dir = importer ? globSafePath(dirname$2(importer)) : root;
35158
+ if (base) {
35159
+ if (base[0] === "/") dir = posix.join(root, base);
35160
+ else dir = posix.resolve(importer ? globSafePath(dirname$2(importer)) : root, base);
35161
+ } else dir = importer ? globSafePath(dirname$2(importer)) : root;
35012
35162
  if (glob[0] === "/") return pre + posix.join(root, glob.slice(1));
35013
35163
  if (glob.startsWith("./")) return pre + posix.join(dir, glob.slice(2));
35014
35164
  if (glob.startsWith("../")) return pre + posix.join(dir, glob);
@@ -36995,34 +37145,36 @@ function expandGlobIds(id, config) {
36995
37145
  if (exports) {
36996
37146
  if (typeof exports === "string" || Array.isArray(exports)) return [pkgName];
36997
37147
  const possibleExportPaths = [];
36998
- for (const key in exports) if (key[0] === ".") if (key.includes("*")) {
36999
- const exportsValue = getFirstExportStringValue(exports[key]);
37000
- if (!exportsValue) continue;
37001
- const exportValuePattern = exportsValue.replace(/\*/g, "**/*");
37002
- const exportsValueGlobRe = new RegExp(exportsValue.split("*").map(escapeRegex).join("(.*)"));
37003
- possibleExportPaths.push(...globSync(exportValuePattern, {
37004
- cwd: pkgData.dir,
37005
- expandDirectories: false,
37006
- ignore: ["node_modules"]
37007
- }).map((filePath) => {
37008
- if (exportsValue.startsWith("./")) filePath = "./" + filePath;
37009
- const matched = exportsValueGlobRe.exec(slash(filePath));
37010
- if (matched) {
37011
- let allGlobSame = matched.length === 2;
37012
- if (!allGlobSame) {
37013
- allGlobSame = true;
37014
- for (let i = 2; i < matched.length; i++) if (matched[i] !== matched[i - 1]) {
37015
- allGlobSame = false;
37016
- break;
37148
+ for (const key in exports) if (key[0] === ".") {
37149
+ if (key.includes("*")) {
37150
+ const exportsValue = getFirstExportStringValue(exports[key]);
37151
+ if (!exportsValue) continue;
37152
+ const exportValuePattern = exportsValue.replace(/\*/g, "**/*");
37153
+ const exportsValueGlobRe = new RegExp(exportsValue.split("*").map(escapeRegex).join("(.*)"));
37154
+ possibleExportPaths.push(...globSync(exportValuePattern, {
37155
+ cwd: pkgData.dir,
37156
+ expandDirectories: false,
37157
+ ignore: ["node_modules"]
37158
+ }).map((filePath) => {
37159
+ if (exportsValue.startsWith("./")) filePath = "./" + filePath;
37160
+ const matched = exportsValueGlobRe.exec(slash(filePath));
37161
+ if (matched) {
37162
+ let allGlobSame = matched.length === 2;
37163
+ if (!allGlobSame) {
37164
+ allGlobSame = true;
37165
+ for (let i = 2; i < matched.length; i++) if (matched[i] !== matched[i - 1]) {
37166
+ allGlobSame = false;
37167
+ break;
37168
+ }
37017
37169
  }
37170
+ if (allGlobSame) return key.replace("*", matched[1]).slice(2);
37018
37171
  }
37019
- if (allGlobSame) return key.replace("*", matched[1]).slice(2);
37020
- }
37021
- return "";
37022
- }).filter(Boolean));
37023
- } else {
37024
- if (exports[key] == null) continue;
37025
- possibleExportPaths.push(key.slice(2));
37172
+ return "";
37173
+ }).filter(Boolean));
37174
+ } else {
37175
+ if (exports[key] == null) continue;
37176
+ possibleExportPaths.push(key.slice(2));
37177
+ }
37026
37178
  }
37027
37179
  const isMatch = (0, import_picomatch.default)(pattern);
37028
37180
  const matched = possibleExportPaths.filter((p) => isMatch(p)).map((match) => path.posix.join(pkgName, match));
@@ -37359,11 +37511,13 @@ async function loadCachedDepOptimizationMetadata(environment, force = environmen
37359
37511
  const cachedMetadataPath = path.join(depsCacheDir, METADATA_FILENAME);
37360
37512
  cachedMetadata = parseDepsOptimizerMetadata(await fsp.readFile(cachedMetadataPath, "utf-8"), depsCacheDir);
37361
37513
  } catch {}
37362
- if (cachedMetadata) if (cachedMetadata.lockfileHash !== getLockfileHash(environment)) environment.logger.info("Re-optimizing dependencies because lockfile has changed", { timestamp: true });
37363
- else if (cachedMetadata.configHash !== getConfigHash(environment)) environment.logger.info("Re-optimizing dependencies because vite config has changed", { timestamp: true });
37364
- else {
37365
- log?.(`(${environment.name}) Hash is consistent. Skipping. Use --force to override.`);
37366
- return cachedMetadata;
37514
+ if (cachedMetadata) {
37515
+ if (cachedMetadata.lockfileHash !== getLockfileHash(environment)) environment.logger.info("Re-optimizing dependencies because lockfile has changed", { timestamp: true });
37516
+ else if (cachedMetadata.configHash !== getConfigHash(environment)) environment.logger.info("Re-optimizing dependencies because vite config has changed", { timestamp: true });
37517
+ else {
37518
+ log?.(`(${environment.name}) Hash is consistent. Skipping. Use --force to override.`);
37519
+ return cachedMetadata;
37520
+ }
37367
37521
  }
37368
37522
  } else environment.logger.info("Forced re-optimization of dependencies", { timestamp: true });
37369
37523
  debug$4?.(`(${environment.name}) ${import_picocolors.default.green(`removing old cache dir ${depsCacheDir}`)}`);
@@ -37646,9 +37800,10 @@ async function addManuallyIncludedOptimizeDeps(environment, deps) {
37646
37800
  const normalizedId = normalizeId(id);
37647
37801
  if (!deps[normalizedId]) {
37648
37802
  const entry = await resolve(id);
37649
- if (entry) if (isOptimizable(entry, optimizeDeps)) deps[normalizedId] = entry;
37650
- else unableToOptimize(id, "Cannot optimize dependency");
37651
- else unableToOptimize(id, "Failed to resolve dependency");
37803
+ if (entry) {
37804
+ if (isOptimizable(entry, optimizeDeps)) deps[normalizedId] = entry;
37805
+ else unableToOptimize(id, "Cannot optimize dependency");
37806
+ } else unableToOptimize(id, "Failed to resolve dependency");
37652
37807
  }
37653
37808
  }
37654
37809
  }
@@ -37763,7 +37918,7 @@ async function extractExportsData(environment, filePath) {
37763
37918
  };
37764
37919
  }
37765
37920
  });
37766
- const [, exports, , hasModuleSyntax] = parse$2((await (await rolldown({
37921
+ const build = await rolldown({
37767
37922
  ...remainingRolldownOptions,
37768
37923
  plugins,
37769
37924
  input: [filePath],
@@ -37771,15 +37926,20 @@ async function extractExportsData(environment, filePath) {
37771
37926
  ".css": "js",
37772
37927
  ...remainingRolldownOptions.moduleTypes
37773
37928
  }
37774
- })).generate({
37775
- ...rolldownOptions.output,
37776
- format: "esm",
37777
- sourcemap: false
37778
- })).output[0].code);
37779
- return {
37780
- hasModuleSyntax,
37781
- exports: exports.map((e) => e.n)
37782
- };
37929
+ });
37930
+ try {
37931
+ const [, exports, , hasModuleSyntax] = parse$2((await build.generate({
37932
+ ...rolldownOptions.output,
37933
+ format: "esm",
37934
+ sourcemap: false
37935
+ })).output[0].code);
37936
+ return {
37937
+ hasModuleSyntax,
37938
+ exports: exports.map((e) => e.n)
37939
+ };
37940
+ } finally {
37941
+ await build.close();
37942
+ }
37783
37943
  }
37784
37944
  let parseResult;
37785
37945
  let usedJsxLoader = false;
@@ -38817,7 +38977,10 @@ function resolveBuildEnvironmentOptions(raw, logger, consumer, isBundledDev, inp
38817
38977
  platform: consumer === "client" || isSsrTargetWebworkerEnvironment ? "browser" : "node",
38818
38978
  ...merged.rolldownOptions
38819
38979
  };
38820
- if (merged.lib && merged.lib.entry == null && input != null) merged.lib.entry = input;
38980
+ if (merged.lib && merged.lib.entry == null && input != null) merged.lib = {
38981
+ ...merged.lib,
38982
+ entry: input
38983
+ };
38821
38984
  if (merged.target === "baseline-widely-available") merged.target = ESBUILD_BASELINE_WIDELY_AVAILABLE_TARGET;
38822
38985
  if (Array.isArray(merged.target)) merged.target = unique(merged.target);
38823
38986
  if (merged.minify === "false") merged.minify = false;
@@ -38913,7 +39076,10 @@ function resolveRolldownOptions(environment, chunkMetadataMap) {
38913
39076
  experimental: {
38914
39077
  ...options.rolldownOptions.experimental,
38915
39078
  viteMode: true,
38916
- chunkImportMap: options.chunkImportMap ? { baseUrl: base } : options.rolldownOptions.experimental?.chunkImportMap
39079
+ chunkImportMap: options.chunkImportMap ? {
39080
+ ...typeof options.rolldownOptions.experimental?.chunkImportMap === "object" ? options.rolldownOptions.experimental?.chunkImportMap : {},
39081
+ baseUrl: base
39082
+ } : options.rolldownOptions.experimental?.chunkImportMap
38917
39083
  }
38918
39084
  };
38919
39085
  const isSsrTargetWebworkerEnvironment = environment.name === "ssr" && environment.getTopLevelConfig().ssr?.target === "webworker";
@@ -39125,9 +39291,10 @@ function onRollupLog(level, log, environment) {
39125
39291
  clearLine();
39126
39292
  const userOnLog = environment.config.build.rolldownOptions?.onLog;
39127
39293
  const userOnWarn = environment.config.build.rolldownOptions?.onwarn;
39128
- if (userOnLog) if (userOnWarn) userOnLog(level, log, normalizeUserOnWarn(userOnWarn, viteLog));
39129
- else userOnLog(level, log, viteLog);
39130
- else if (userOnWarn) normalizeUserOnWarn(userOnWarn, viteLog)(level, log);
39294
+ if (userOnLog) {
39295
+ if (userOnWarn) userOnLog(level, log, normalizeUserOnWarn(userOnWarn, viteLog));
39296
+ else userOnLog(level, log, viteLog);
39297
+ } else if (userOnWarn) normalizeUserOnWarn(userOnWarn, viteLog)(level, log);
39131
39298
  else viteLog(level, log);
39132
39299
  }
39133
39300
  function normalizeUserOnWarn(userOnWarn, defaultHandler) {
@@ -40293,6 +40460,7 @@ var MemoryFiles = class {
40293
40460
  var BundledDev = class {
40294
40461
  environment;
40295
40462
  _devEngine;
40463
+ viteRuntime;
40296
40464
  initialBuildCompleted = false;
40297
40465
  _closed = false;
40298
40466
  clients = new Clients();
@@ -40325,6 +40493,9 @@ var BundledDev = class {
40325
40493
  return this._devEngine;
40326
40494
  }
40327
40495
  pendingPayloadFilenames = /* @__PURE__ */ new Set();
40496
+ get hasBuildOutput() {
40497
+ return this.memoryFiles.size > 1 || this.memoryFiles.size === 1 && !this.memoryFiles.has("bundledDevClient.mjs");
40498
+ }
40328
40499
  async listen() {
40329
40500
  this._closed = false;
40330
40501
  debug$1?.("INITIAL: setup bundle options");
@@ -40414,6 +40585,8 @@ var BundledDev = class {
40414
40585
  }, (e) => {
40415
40586
  debug$1?.("INITIAL: run error", e);
40416
40587
  });
40588
+ this.viteRuntime = await getHmrImplementation(this.environment.getTopLevelConfig());
40589
+ this.storeOutputFiles([]);
40417
40590
  this.waitForInitialBuildFinish().then(() => {
40418
40591
  if (this._closed) return;
40419
40592
  debug$1?.("INITIAL: build done");
@@ -40430,7 +40603,7 @@ var BundledDev = class {
40430
40603
  await this.devEngine.ensureCurrentBuildFinish();
40431
40604
  if (this._closed) return;
40432
40605
  let state = await this.devEngine.getBundleState();
40433
- while (this.memoryFiles.size === 0 && !state.lastBuildErrored) {
40606
+ while (!this.hasBuildOutput && !state.lastBuildErrored) {
40434
40607
  await setTimeout$1(10);
40435
40608
  if (this._closed) return;
40436
40609
  await this.devEngine.ensureCurrentBuildFinish();
@@ -40484,6 +40657,10 @@ var BundledDev = class {
40484
40657
  this.initialBuildCompleted = false;
40485
40658
  }
40486
40659
  storeOutputFiles(output) {
40660
+ if (this.viteRuntime) this.memoryFiles.set(BUNDLED_DEV_CLIENT_FILENAME, {
40661
+ source: this.viteRuntime,
40662
+ etag: (0, import_etag.default)(Buffer.from(this.viteRuntime), { weak: true })
40663
+ });
40487
40664
  for (const outputFile of output) this.memoryFiles.set(outputFile.fileName, () => {
40488
40665
  const source = outputFile.type === "chunk" ? outputFile.code : outputFile.source;
40489
40666
  return {
@@ -40499,23 +40676,11 @@ var BundledDev = class {
40499
40676
  rolldownOptions.experimental.devMode = {
40500
40677
  lazy: true,
40501
40678
  ...typeof rolldownOptions.experimental.devMode === "object" ? rolldownOptions.experimental.devMode : {},
40502
- implement: await getHmrImplementation(this.environment.getTopLevelConfig())
40679
+ implement: "",
40680
+ skipCommonRuntimeInjection: true
40503
40681
  };
40504
40682
  rolldownOptions.optimization ??= {};
40505
40683
  rolldownOptions.optimization.inlineConst = false;
40506
- const plugins = await asyncFlatten([rolldownOptions.plugins]);
40507
- for (const plugin of plugins) {
40508
- const transform = plugin && "transform" in plugin ? plugin.transform : void 0;
40509
- if (!transform) continue;
40510
- const handler = typeof transform === "function" ? transform : transform.handler;
40511
- const wrappedHandler = function(code, id, opts) {
40512
- if (id.includes("?rolldown-lazy=")) return null;
40513
- return handler.call(this, code, id, opts);
40514
- };
40515
- if (typeof transform === "function") plugin.transform = wrappedHandler;
40516
- else transform.handler = wrappedHandler;
40517
- }
40518
- rolldownOptions.plugins = plugins;
40519
40684
  if (Array.isArray(rolldownOptions.output)) for (const output of rolldownOptions.output) {
40520
40685
  output.entryFileNames = "assets/[name].js";
40521
40686
  output.chunkFileNames = "assets/[name]-[hash].js";
@@ -41297,6 +41462,7 @@ function idToPathAndNamespace(id) {
41297
41462
  //#endregion
41298
41463
  //#region ../../vite/packages/vite/src/node/config.ts
41299
41464
  var config_exports = /* @__PURE__ */ __exportAll({
41465
+ bundleConfigFile: () => bundleConfigFile,
41300
41466
  defineConfig: () => defineConfig,
41301
41467
  getDefaultEnvironmentOptions: () => getDefaultEnvironmentOptions,
41302
41468
  isResolvedConfig: () => isResolvedConfig,
@@ -41660,7 +41826,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
41660
41826
  if (tsconfigPathsPlugin) logger.warnOnce(import_picocolors.default.yellow(`The plugin ${JSON.stringify(tsconfigPathsPlugin.name)} is detected. Vite now supports tsconfig paths resolution natively via the ${import_picocolors.default.bold("resolve.tsconfigPaths")} option. You can remove the plugin and set ${import_picocolors.default.bold("resolve.tsconfigPaths: true")} in your Vite config instead.`));
41661
41827
  if (process.versions.pnp) logger.warnOnce(import_picocolors.default.yellow(`Using Yarn PnP with Vite is discouraged and PnP-specific bugs will no longer be actively worked on. Please switch to a different ${import_picocolors.default.bold("nodeLinker")} mode or to a different package manager.`));
41662
41828
  let nonNormalizedResolvedRoot = config.root ? path.resolve(config.root) : process.cwd();
41663
- try {
41829
+ if (!config.resolve?.preserveSymlinks) try {
41664
41830
  nonNormalizedResolvedRoot = safeRealpathSync(nonNormalizedResolvedRoot);
41665
41831
  } catch {}
41666
41832
  const resolvedRoot = normalizePath(nonNormalizedResolvedRoot);
@@ -41739,8 +41905,10 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
41739
41905
  if (envDir !== false) envDir = config.envDir ? normalizePath(path.resolve(resolvedRoot, config.envDir)) : resolvedRoot;
41740
41906
  const userEnv = loadEnv(mode, envDir, resolveEnvPrefix(config));
41741
41907
  const userNodeEnv = process.env.VITE_USER_NODE_ENV;
41742
- if (!isNodeEnvSet && userNodeEnv) if (userNodeEnv === "development") process.env.NODE_ENV = "development";
41743
- else logger.warn(`NODE_ENV=${userNodeEnv} is not supported in the .env file. Only NODE_ENV=development is supported to create a development build of your project. If you need to set process.env.NODE_ENV, you can set it in the Vite config instead.`);
41908
+ if (!isNodeEnvSet && userNodeEnv) {
41909
+ if (userNodeEnv === "development") process.env.NODE_ENV = "development";
41910
+ else logger.warn(`NODE_ENV=${userNodeEnv} is not supported in the .env file. Only NODE_ENV=development is supported to create a development build of your project. If you need to set process.env.NODE_ENV, you can set it in the Vite config instead.`);
41911
+ }
41744
41912
  const isProduction = process.env.NODE_ENV === "production";
41745
41913
  const resolvedBase = config.base === "" || config.base === "./" ? !isBuild || config.build?.ssr ? "/" : "./" : resolveBaseUrl(config.base, isBuild, logger);
41746
41914
  const pkgDir = findNearestPackageData(resolvedRoot, packageCache)?.dir;
@@ -41810,9 +41978,10 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
41810
41978
  if (Array.isArray(server.allowedHosts)) server.allowedHosts.push(...additionalAllowedHosts);
41811
41979
  if (Array.isArray(preview.allowedHosts)) preview.allowedHosts.push(...additionalAllowedHosts);
41812
41980
  let oxc = config.oxc;
41813
- if (config.esbuild) if (config.oxc) logger.warn(import_picocolors.default.yellow(`Both esbuild and oxc options were set. oxc options will be used and esbuild options will be ignored.`) + ` The following esbuild options were set: \`${inspect(config.esbuild)}\``);
41814
- else oxc = convertEsbuildConfigToOxcConfig(config.esbuild, logger);
41815
- else if (config.esbuild === false && config.oxc !== false) logger.warn(import_picocolors.default.yellow("`esbuild` option is set to false, but `oxc` option was not set to false. `esbuild: false` does not have effect any more. If you want to disable the default transformation, which is now handled by Oxc, please set `oxc: false` instead."));
41981
+ if (config.esbuild) {
41982
+ if (config.oxc) logger.warn(import_picocolors.default.yellow(`Both esbuild and oxc options were set. oxc options will be used and esbuild options will be ignored.`) + ` The following esbuild options were set: \`${inspect(config.esbuild)}\``);
41983
+ else oxc = convertEsbuildConfigToOxcConfig(config.esbuild, logger);
41984
+ } else if (config.esbuild === false && config.oxc !== false) logger.warn(import_picocolors.default.yellow("`esbuild` option is set to false, but `oxc` option was not set to false. `esbuild: false` does not have effect any more. If you want to disable the default transformation, which is now handled by Oxc, please set `oxc: false` instead."));
41816
41985
  const experimental = mergeWithDefaults(configDefaults.experimental, config.experimental ?? {});
41817
41986
  if (command === "serve" && experimental.bundledDev) experimental.renderBuiltUrl = void 0;
41818
41987
  const resolvedDevToolsConfig = await resolveDevToolsConfig(config.devtools, server.host, logger);
@@ -42063,6 +42232,7 @@ async function bundleConfigFile(fileName, isESM) {
42063
42232
  const importMetaUrlVarName = "__vite_injected_original_import_meta_url";
42064
42233
  const importMetaResolveVarName = "__vite_injected_original_import_meta_resolve";
42065
42234
  const importMetaResolveRegex = /import\.meta\s*\.\s*resolve/;
42235
+ const configFileRegex = /\.[cm]?[jt]s$/;
42066
42236
  const nativeIncompatibilities = [];
42067
42237
  const bundle = await rolldown({
42068
42238
  input: fileName,
@@ -42121,21 +42291,23 @@ async function bundleConfigFile(fileName, isESM) {
42121
42291
  {
42122
42292
  name: "inject-file-scope-variables",
42123
42293
  transform: {
42124
- filter: { id: /\.[cm]?[jt]s$/ },
42294
+ filter: { id: configFileRegex },
42125
42295
  handler(code, id) {
42126
42296
  let injectValues = `const ${dirnameVarName} = ${JSON.stringify(path.dirname(id))};const ${filenameVarName} = ${JSON.stringify(id)};const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL(id).href)};`;
42127
- if (importMetaResolveRegex.test(code)) if (isESM) {
42128
- if (!importMetaResolverRegistered) {
42129
- importMetaResolverRegistered = true;
42130
- createImportMetaResolver();
42131
- }
42132
- injectValues += `const ${importMetaResolveVarName} = (specifier, importer = ${importMetaUrlVarName}) => (${importMetaResolveWithCustomHookString})(specifier, importer);`;
42133
- } else injectValues += `const ${importMetaResolveVarName} = (specifier, importer = ${importMetaUrlVarName}) => { throw new Error('import.meta.resolve is not supported in CJS config files') };`;
42297
+ if (importMetaResolveRegex.test(code)) {
42298
+ if (isESM) {
42299
+ if (!importMetaResolverRegistered) {
42300
+ importMetaResolverRegistered = true;
42301
+ createImportMetaResolver();
42302
+ }
42303
+ injectValues += `const ${importMetaResolveVarName} = (specifier, importer = ${importMetaUrlVarName}) => (${importMetaResolveWithCustomHookString})(specifier, importer);`;
42304
+ } else injectValues += `const ${importMetaResolveVarName} = (specifier, importer = ${importMetaUrlVarName}) => { throw new Error('import.meta.resolve is not supported in CJS config files') };`;
42305
+ }
42134
42306
  let injectedContents;
42135
42307
  if (code.startsWith("#!")) {
42136
- let firstLineEndIndex = code.indexOf("\n");
42137
- if (firstLineEndIndex < 0) firstLineEndIndex = code.length;
42138
- injectedContents = code.slice(0, firstLineEndIndex + 1) + injectValues + code.slice(firstLineEndIndex + 1);
42308
+ const fileStartIndex = getFileStartIndex(code);
42309
+ const hashbang = code.slice(0, fileStartIndex);
42310
+ injectedContents = hashbang + (lineTerminatorRE.test(hashbang) ? "" : "\n") + injectValues + code.slice(fileStartIndex);
42139
42311
  } else injectedContents = injectValues + code;
42140
42312
  return {
42141
42313
  code: injectedContents,
@@ -42149,8 +42321,8 @@ async function bundleConfigFile(fileName, isESM) {
42149
42321
  const result = await bundle.generate({
42150
42322
  format: isESM ? "esm" : "cjs",
42151
42323
  sourcemap: "inline",
42152
- sourcemapPathTransform(relative) {
42153
- return path.resolve(fileName, relative);
42324
+ sourcemapPathTransform(relative, sourcemapPath) {
42325
+ return path.resolve(path.dirname(sourcemapPath), relative);
42154
42326
  },
42155
42327
  codeSplitting: false
42156
42328
  });