@voidzero-dev/vite-plus-core 1.0.0-rc.0 → 1.0.0-rc.1

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 (55) hide show
  1. package/dist/rolldown/cli.mjs +6 -6
  2. package/dist/rolldown/config.d.mts +1 -1
  3. package/dist/rolldown/config.mjs +2 -2
  4. package/dist/rolldown/experimental-index.d.mts +8 -5
  5. package/dist/rolldown/experimental-index.mjs +14 -11
  6. package/dist/rolldown/experimental-runtime-types.d.ts +3 -26
  7. package/dist/rolldown/experimental-runtime.d.ts +3 -26
  8. package/dist/rolldown/experimental-runtime.mjs +4 -47
  9. package/dist/rolldown/filter-index.d.mts +1 -1
  10. package/dist/rolldown/index.d.mts +1 -1
  11. package/dist/rolldown/index.mjs +4 -4
  12. package/dist/rolldown/parallel-plugin-worker.mjs +2 -2
  13. package/dist/rolldown/parallel-plugin.d.mts +1 -1
  14. package/dist/rolldown/parse-ast-index.mjs +2 -2
  15. package/dist/rolldown/plugins-index.d.mts +2 -2
  16. package/dist/rolldown/plugins-index.mjs +2 -2
  17. package/dist/rolldown/shared/{binding-BbrDfv1x.mjs → binding-BY0qR5iS.mjs} +28 -27
  18. package/dist/rolldown/shared/{bindingify-input-options-CbBAjvu6.mjs → bindingify-input-options-B8JHmN6_.mjs} +10 -8
  19. package/dist/rolldown/shared/{constructors-CmDKpWIU.d.mts → constructors-DuOq7MqW.d.mts} +1 -1
  20. package/dist/rolldown/shared/{constructors-D9jwEbE4.mjs → constructors-xEvVj3lN.mjs} +1 -1
  21. package/dist/rolldown/shared/{create-bundler-option-wxuQPB7F.mjs → create-bundler-option-COco-7P6.mjs} +93 -19
  22. package/dist/rolldown/shared/{define-config-BFdLpVut.d.mts → define-config-C7HCoqY8.d.mts} +11 -1
  23. package/dist/rolldown/shared/{error-CGhV1ebk.mjs → error-C7pxws0W.mjs} +1 -1
  24. package/dist/rolldown/shared/{load-config-DOMKIWz0.mjs → load-config-DkUBnDsI.mjs} +1 -1
  25. package/dist/rolldown/shared/{logs-DmYCAKcW.mjs → logs-D6uA606S.mjs} +8 -1
  26. package/dist/rolldown/shared/{normalize-string-or-regex-zc1bUto6.mjs → normalize-string-or-regex-F14uvr6D.mjs} +2 -2
  27. package/dist/rolldown/shared/{parse-6TJ5OMPh.mjs → parse-BWeE7Vr9.mjs} +1 -1
  28. package/dist/rolldown/shared/{resolve-tsconfig-Bf6oL9fm.mjs → resolve-tsconfig-DHwpIs5e.mjs} +2 -2
  29. package/dist/rolldown/shared/{rolldown-DZGaRc5R.mjs → rolldown-Bue0gNT5.mjs} +4 -4
  30. package/dist/rolldown/shared/{watch-CUKYWzxY.mjs → watch-RXhXN1aG.mjs} +5 -5
  31. package/dist/rolldown/utils-index.mjs +2 -2
  32. package/dist/tsdown/{build-JVmLFaZt-BN9yuB6k.js → build-JVmLFaZt-DRlLhpV3.js} +10 -8
  33. package/dist/tsdown/{debug-CpC4hV25-BeCITV83.js → debug-CpC4hV25-C-OYr2iI.js} +4 -3
  34. package/dist/tsdown/{detect-Bg-d8iUV-Cr_BRLVW.js → detect-Bg-d8iUV-Du8LljhG.js} +1 -1
  35. package/dist/tsdown/{dist-ByW_jJfv.js → dist-VDcV1Qyy.js} +19 -49
  36. package/dist/tsdown/index-types.d.ts +209 -209
  37. package/dist/tsdown/index.js +4 -4
  38. package/dist/tsdown/{main-bgV9NlwM.js → main-CyNcZUzu.js} +3 -88
  39. package/dist/tsdown/require-BbBF8Ii0-BDaWJgzA.js +320 -0
  40. package/dist/tsdown/{resolver-DE0_sy8o-UMsN-SXx.js → resolver-DE0_sy8o-Bi3xbRxi.js} +2 -3
  41. package/dist/tsdown/run.js +5 -4
  42. package/dist/tsdown/{src-D5xv98Iu.js → src-pN7Bl6zo.js} +4 -4
  43. package/dist/tsdown/style-DiMP8pYv-DIC5PXeH.js +88 -0
  44. package/dist/tsdown/{target-DgdLrXba-DaJJ11xX.js → target-DgdLrXba-DpO9JXxB.js} +6 -172
  45. package/dist/tsdown/{tsc-BFDF_Im9.js → tsc-BLb4pSBY.js} +8 -7
  46. package/dist/tsdown/tsdown-css.js +4 -5
  47. package/dist/tsdown/tsdown-exe.js +41 -4
  48. package/dist/tsdown/version-CQ98ZBpL-D6GAHapk.js +169 -0
  49. package/dist/vite/client/bundledDevClient.mjs +8 -42
  50. package/dist/vite/client/client.mjs +4 -4
  51. package/dist/vite/node/chunks/dist2.js +107 -104
  52. package/dist/vite/node/chunks/node.js +303 -100
  53. package/dist/vite/node/index.d.ts +4 -3
  54. package/package.json +14 -14
  55. package/dist/tsdown/internal-DTYQdXId.js +0 -3
@@ -3321,7 +3321,7 @@ var BaseEnvironment = class extends PartialEnvironment {
3321
3321
  };
3322
3322
  //#endregion
3323
3323
  //#region ../../vite/packages/vite/package.json
3324
- var version = "8.3.0";
3324
+ var version = "8.3.1";
3325
3325
  //#endregion
3326
3326
  //#region ../../vite/packages/vite/src/node/constants.ts
3327
3327
  const ROLLUP_HOOKS = [
@@ -3459,7 +3459,7 @@ const KNOWN_ASSET_TYPES = [
3459
3459
  "pdf",
3460
3460
  "txt"
3461
3461
  ];
3462
- const DEFAULT_ASSETS_RE = new RegExp(`\\.(` + KNOWN_ASSET_TYPES.join("|") + `)(\\?.*)?$`, "i");
3462
+ const DEFAULT_ASSETS_RE = new RegExp(`\\.(?:` + KNOWN_ASSET_TYPES.join("|") + `)(\\?.*)?$`, "i");
3463
3463
  const DEP_VERSION_RE = /[?&](v=[\w.-]+)\b/;
3464
3464
  const loopbackHosts = /* @__PURE__ */ new Set([
3465
3465
  "localhost",
@@ -3649,11 +3649,11 @@ function printServerUrls(urls, optionsHost, info) {
3649
3649
  var comma$1 = ",".charCodeAt(0);
3650
3650
  var semicolon = ";".charCodeAt(0);
3651
3651
  var chars$1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
3652
- var intToChar$1 = /* @__PURE__ */ new Uint8Array(64);
3652
+ var intToChar$2 = /* @__PURE__ */ new Uint8Array(64);
3653
3653
  var charToInt$1 = /* @__PURE__ */ new Uint8Array(128);
3654
3654
  for (let i = 0; i < chars$1.length; i++) {
3655
3655
  const c = chars$1.charCodeAt(i);
3656
- intToChar$1[i] = c;
3656
+ intToChar$2[i] = c;
3657
3657
  charToInt$1[c] = i;
3658
3658
  }
3659
3659
  function decodeInteger$1(reader) {
@@ -3675,7 +3675,7 @@ function encodeInteger(builder, num) {
3675
3675
  let clamped = num & 31;
3676
3676
  num >>>= 5;
3677
3677
  if (num > 0) clamped |= 32;
3678
- builder.write(intToChar$1[clamped]);
3678
+ builder.write(intToChar$2[clamped]);
3679
3679
  } while (num > 0);
3680
3680
  }
3681
3681
  function encodeSign(num) {
@@ -5620,7 +5620,10 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
5620
5620
  const merged = { ...defaults };
5621
5621
  if (rollupOptionsRootPaths.has(rootPath)) setupRollupOptionCompat(merged, rootPath);
5622
5622
  if (rootPath === "server") setupHmrWsOptionCompat(merged);
5623
- if (rootPath === "server.hmr") for (const key of wsOptionKeys) Object.defineProperty(merged, key, Object.getOwnPropertyDescriptor(defaults, key));
5623
+ if (rootPath === "server.hmr") for (const key of wsOptionKeys) {
5624
+ const descriptor = Object.getOwnPropertyDescriptor(defaults, key);
5625
+ if (descriptor) Object.defineProperty(merged, key, descriptor);
5626
+ }
5624
5627
  for (const key in overrides) {
5625
5628
  const value = overrides[key];
5626
5629
  if (value == null) continue;
@@ -6250,7 +6253,7 @@ function alias$1(options = {}) {
6250
6253
  };
6251
6254
  }
6252
6255
  //#endregion
6253
- //#region ../../node_modules/.pnpm/magic-string@1.3.1/node_modules/magic-string/dist/index.mjs
6256
+ //#region ../../node_modules/.pnpm/magic-string@1.4.2/node_modules/magic-string/dist/index.mjs
6254
6257
  var BitSet = class BitSet {
6255
6258
  constructor(arg) {
6256
6259
  this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
@@ -6344,7 +6347,7 @@ var Chunk = class Chunk {
6344
6347
  this.outro = "";
6345
6348
  this.end = index;
6346
6349
  if (this.edited) {
6347
- newChunk.edit("", false);
6350
+ newChunk.edit("", false, true);
6348
6351
  this.content = "";
6349
6352
  } else this.content = originalBefore;
6350
6353
  newChunk.next = this.next;
@@ -6422,7 +6425,7 @@ var SourceMap = class {
6422
6425
  this.sources = properties.sources;
6423
6426
  this.sourcesContent = properties.sourcesContent;
6424
6427
  this.names = properties.names;
6425
- this.mappings = encode$1(properties.mappings);
6428
+ this.mappings = typeof properties.mappings === "string" ? properties.mappings : encode$1(properties.mappings);
6426
6429
  if (typeof properties.x_google_ignoreList !== "undefined") this.x_google_ignoreList = properties.x_google_ignoreList;
6427
6430
  if (typeof properties.debugId !== "undefined") this.debugId = properties.debugId;
6428
6431
  if (typeof properties.rangeMappings !== "undefined") {
@@ -6496,12 +6499,100 @@ const toString = Object.prototype.toString;
6496
6499
  function isObject(thing) {
6497
6500
  return toString.call(thing) === "[object Object]";
6498
6501
  }
6502
+ const BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
6503
+ const intToChar$1 = /* #__PURE__ */ (() => {
6504
+ const chars = /* @__PURE__ */ new Uint8Array(64);
6505
+ for (let i = 0; i < 64; i++) chars[i] = BASE64_CHARS.charCodeAt(i);
6506
+ return chars;
6507
+ })();
6508
+ const COMMA = 44;
6509
+ const SEMICOLON = 59;
6510
+ const BUFFER_SIZE = 16384;
6511
+ const FLUSH_THRESHOLD = 16348;
6512
+ const scratch = /* #__PURE__ */ new Uint8Array(BUFFER_SIZE);
6513
+ function writeVlq(pos, num) {
6514
+ num = num < 0 ? -num << 1 | 1 : num << 1;
6515
+ do {
6516
+ let clamped = num & 31;
6517
+ num >>>= 5;
6518
+ if (num > 0) clamped |= 32;
6519
+ scratch[pos++] = intToChar$1[clamped];
6520
+ } while (num > 0);
6521
+ return pos;
6522
+ }
6523
+ const decoder$1 = /* #__PURE__ */ new TextDecoder();
6524
+ var MappingsEncoder = class {
6525
+ constructor() {
6526
+ this.out = "";
6527
+ this.pos = 0;
6528
+ this.lines = [];
6529
+ this.buffered = 0;
6530
+ this.needsComma = false;
6531
+ this.prevGenColumn = 0;
6532
+ this.prevSourceIndex = 0;
6533
+ this.prevSourceLine = 0;
6534
+ this.prevSourceColumn = 0;
6535
+ this.prevNameIndex = 0;
6536
+ }
6537
+ endLine(segments) {
6538
+ this.lines.push(segments);
6539
+ this.buffered += segments.length + 1;
6540
+ if (this.buffered >= 4096) this.drain(null);
6541
+ }
6542
+ segments(segments) {
6543
+ this.drain(segments);
6544
+ }
6545
+ finish(segments) {
6546
+ this.drain(segments);
6547
+ this.flush();
6548
+ return this.out;
6549
+ }
6550
+ drain(trailing) {
6551
+ const lines = this.lines;
6552
+ const lineCount = lines.length;
6553
+ for (let l = 0; l <= lineCount; l++) {
6554
+ const line = l < lineCount ? lines[l] : trailing;
6555
+ if (line === null) break;
6556
+ for (let i = 0; i < line.length; i++) {
6557
+ if (this.pos > FLUSH_THRESHOLD) this.flush();
6558
+ const segment = line[i];
6559
+ if (this.needsComma) scratch[this.pos++] = COMMA;
6560
+ this.needsComma = true;
6561
+ this.pos = writeVlq(this.pos, segment[0] - this.prevGenColumn);
6562
+ this.prevGenColumn = segment[0];
6563
+ this.pos = writeVlq(this.pos, segment[1] - this.prevSourceIndex);
6564
+ this.prevSourceIndex = segment[1];
6565
+ this.pos = writeVlq(this.pos, segment[2] - this.prevSourceLine);
6566
+ this.prevSourceLine = segment[2];
6567
+ this.pos = writeVlq(this.pos, segment[3] - this.prevSourceColumn);
6568
+ this.prevSourceColumn = segment[3];
6569
+ if (segment.length === 5) {
6570
+ this.pos = writeVlq(this.pos, segment[4] - this.prevNameIndex);
6571
+ this.prevNameIndex = segment[4];
6572
+ }
6573
+ }
6574
+ if (l < lineCount) {
6575
+ if (this.pos > FLUSH_THRESHOLD) this.flush();
6576
+ scratch[this.pos++] = SEMICOLON;
6577
+ this.needsComma = false;
6578
+ this.prevGenColumn = 0;
6579
+ }
6580
+ }
6581
+ lines.length = 0;
6582
+ this.buffered = 0;
6583
+ this.flush();
6584
+ }
6585
+ flush() {
6586
+ this.out += decoder$1.decode(scratch.subarray(0, this.pos));
6587
+ this.pos = 0;
6588
+ }
6589
+ };
6499
6590
  const NEWLINE_CHAR$1 = 10;
6500
6591
  function isWordCode(code) {
6501
6592
  return code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57 || code === 95;
6502
6593
  }
6503
6594
  var Mappings = class {
6504
- constructor(hires) {
6595
+ constructor(hires, encoder = null) {
6505
6596
  this.hires = hires;
6506
6597
  this.generatedCodeLine = 0;
6507
6598
  this.generatedCodeColumn = 0;
@@ -6509,10 +6600,21 @@ var Mappings = class {
6509
6600
  this.rawSegments = this.raw[this.generatedCodeLine] = [];
6510
6601
  this.rawRangeMappings = [];
6511
6602
  this.rawRangeMappingsIndices = this.rawRangeMappings[this.generatedCodeLine] = [];
6512
- this.pending = null;
6603
+ this.encoder = encoder;
6604
+ }
6605
+ nextLine() {
6606
+ if (this.encoder === null) {
6607
+ this.generatedCodeLine += 1;
6608
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
6609
+ } else {
6610
+ this.encoder.endLine(this.rawSegments);
6611
+ this.rawSegments = [];
6612
+ this.generatedCodeLine += 1;
6613
+ }
6614
+ this.generatedCodeColumn = 0;
6615
+ this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
6513
6616
  }
6514
6617
  addEdit(sourceIndex, content, loc, nameIndex) {
6515
- /* v8 ignore else -- `pending` is never assigned a truthy value */
6516
6618
  if (content.length) {
6517
6619
  const contentLengthMinusOne = content.length - 1;
6518
6620
  let contentLineEnd = content.indexOf("\n", 0);
@@ -6526,10 +6628,7 @@ var Mappings = class {
6526
6628
  ];
6527
6629
  if (nameIndex >= 0) segment.push(nameIndex);
6528
6630
  this.rawSegments.push(segment);
6529
- this.generatedCodeLine += 1;
6530
- this.raw[this.generatedCodeLine] = this.rawSegments = [];
6531
- this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
6532
- this.generatedCodeColumn = 0;
6631
+ this.nextLine();
6533
6632
  previousContentLineEnd = contentLineEnd;
6534
6633
  contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
6535
6634
  }
@@ -6542,11 +6641,7 @@ var Mappings = class {
6542
6641
  if (nameIndex >= 0) segment.push(nameIndex);
6543
6642
  this.rawSegments.push(segment);
6544
6643
  this.advance(content.slice(previousContentLineEnd + 1));
6545
- } else if (this.pending) {
6546
- this.rawSegments.push(this.pending);
6547
- this.advance(content);
6548
6644
  }
6549
- this.pending = null;
6550
6645
  }
6551
6646
  addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
6552
6647
  const end = chunk.end;
@@ -6554,8 +6649,13 @@ var Mappings = class {
6554
6649
  if (this.hires) {
6555
6650
  const boundary = this.hires === "boundary";
6556
6651
  const experimentalRange = this.hires === "experimental-range";
6652
+ const encoder = experimentalRange ? null : this.encoder;
6557
6653
  let charInHiresBoundary = false;
6558
6654
  while (i < end) {
6655
+ if (encoder !== null && this.rawSegments.length >= 4096) {
6656
+ encoder.segments(this.rawSegments);
6657
+ this.rawSegments.length = 0;
6658
+ }
6559
6659
  if (experimentalRange && i + 1 >= end) this.rawSegments.push([
6560
6660
  this.generatedCodeColumn,
6561
6661
  sourceIndex,
@@ -6566,10 +6666,7 @@ var Mappings = class {
6566
6666
  if (code === NEWLINE_CHAR$1) {
6567
6667
  loc.line += 1;
6568
6668
  loc.column = 0;
6569
- this.generatedCodeLine += 1;
6570
- this.raw[this.generatedCodeLine] = this.rawSegments = [];
6571
- this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
6572
- this.generatedCodeColumn = 0;
6669
+ this.nextLine();
6573
6670
  charInHiresBoundary = false;
6574
6671
  } else {
6575
6672
  if (boundary) {
@@ -6650,26 +6747,15 @@ var Mappings = class {
6650
6747
  if (newline === end) break;
6651
6748
  loc.line += 1;
6652
6749
  loc.column = 0;
6653
- this.generatedCodeLine += 1;
6654
- this.raw[this.generatedCodeLine] = this.rawSegments = [];
6655
- this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
6656
- this.generatedCodeColumn = 0;
6750
+ this.nextLine();
6657
6751
  i = newline + 1;
6658
6752
  }
6659
6753
  }
6660
- this.pending = null;
6661
6754
  }
6662
6755
  advance(str) {
6663
6756
  if (!str) return;
6664
6757
  const lastNewline = str.lastIndexOf("\n");
6665
- if (lastNewline !== -1) {
6666
- for (let i = str.indexOf("\n"); i !== -1; i = str.indexOf("\n", i + 1)) {
6667
- this.generatedCodeLine++;
6668
- this.raw[this.generatedCodeLine] = this.rawSegments = [];
6669
- this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
6670
- }
6671
- this.generatedCodeColumn = 0;
6672
- }
6758
+ for (let i = str.indexOf("\n"); i !== -1; i = str.indexOf("\n", i + 1)) this.nextLine();
6673
6759
  this.generatedCodeColumn += str.length - lastNewline - 1;
6674
6760
  }
6675
6761
  };
@@ -6888,9 +6974,32 @@ var MagicString = class MagicString {
6888
6974
  */
6889
6975
  generateDecodedMap(options) {
6890
6976
  options = options || {};
6977
+ const mappings = new Mappings(options.hires);
6978
+ const names = this._generateMappings(mappings);
6979
+ return {
6980
+ ...this._mapProperties(options, names),
6981
+ mappings: mappings.raw,
6982
+ rangeMappings: mappings.rawRangeMappings
6983
+ };
6984
+ }
6985
+ /**
6986
+ * Generates a version 3 sourcemap.
6987
+ */
6988
+ generateMap(options) {
6989
+ options = options || {};
6990
+ const encoder = new MappingsEncoder();
6991
+ const mappings = new Mappings(options.hires, encoder);
6992
+ const names = this._generateMappings(mappings);
6993
+ return new SourceMap({
6994
+ ...this._mapProperties(options, names),
6995
+ mappings: encoder.finish(mappings.rawSegments),
6996
+ rangeMappings: mappings.rawRangeMappings
6997
+ });
6998
+ }
6999
+ /** @internal */
7000
+ _generateMappings(mappings) {
6891
7001
  const sourceIndex = 0;
6892
7002
  const names = Object.keys(this.storedNames);
6893
- const mappings = new Mappings(options.hires);
6894
7003
  const locate = getLocator(this.original);
6895
7004
  if (this.intro) mappings.advance(this.intro);
6896
7005
  this.firstChunk.eachNext((chunk) => {
@@ -6901,22 +7010,18 @@ var MagicString = class MagicString {
6901
7010
  if (chunk.outro.length) mappings.advance(chunk.outro);
6902
7011
  });
6903
7012
  if (this.outro) mappings.advance(this.outro);
7013
+ return names;
7014
+ }
7015
+ /** @internal */
7016
+ _mapProperties(options, names) {
6904
7017
  return {
6905
7018
  file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
6906
7019
  sources: [options.source ? getRelativePath(options.file || "", options.source) : options.file || ""],
6907
7020
  sourcesContent: options.includeContent ? [this.original] : void 0,
6908
7021
  names,
6909
- mappings: mappings.raw,
6910
- x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0,
6911
- rangeMappings: mappings.rawRangeMappings
7022
+ x_google_ignoreList: this.ignoreList ? [0] : void 0
6912
7023
  };
6913
7024
  }
6914
- /**
6915
- * Generates a version 3 sourcemap.
6916
- */
6917
- generateMap(options) {
6918
- return new SourceMap(this.generateDecodedMap(options));
6919
- }
6920
7025
  /** @internal */
6921
7026
  _ensureindentStr() {
6922
7027
  if (this.indentStr === void 0) this.indentStr = guessIndent(this.original);
@@ -7029,8 +7134,14 @@ var MagicString = class MagicString {
7029
7134
  }
7030
7135
  /**
7031
7136
  * Moves the characters from `start` and `end` to `index`.
7137
+ *
7138
+ * `affinity` controls where the range is anchored at `index`. With the
7139
+ * default `'right'`, it is inserted before the content that starts at `index`;
7140
+ * with `'left'`, it is inserted after the content that ends at `index`. The
7141
+ * two differ only when other content has already been moved to that boundary,
7142
+ * mirroring the `appendLeft`/`appendRight` distinction.
7032
7143
  */
7033
- move(start, end, index) {
7144
+ move(start, end, index, affinity = "right") {
7034
7145
  start = start + this.offset;
7035
7146
  end = end + this.offset;
7036
7147
  index = index + this.offset;
@@ -7050,9 +7161,27 @@ var MagicString = class MagicString {
7050
7161
  }
7051
7162
  const oldLeft = first.previous;
7052
7163
  const oldRight = last.next;
7053
- const newRight = this.byStart.get(index);
7054
- if (!newRight && last === this.lastChunk) return this;
7055
- const newLeft = newRight ? newRight.previous : this.lastChunk;
7164
+ let newLeft;
7165
+ let newRight;
7166
+ if (affinity === "left") {
7167
+ newLeft = this.byEnd.get(index) ?? null;
7168
+ if (!newLeft) {
7169
+ if (first === this.firstChunk) return this;
7170
+ newRight = this.firstChunk;
7171
+ } else {
7172
+ if (newLeft.next === first) return this;
7173
+ newRight = newLeft.next;
7174
+ }
7175
+ } else {
7176
+ newRight = this.byStart.get(index) ?? null;
7177
+ if (!newRight) {
7178
+ if (last === this.lastChunk) return this;
7179
+ newLeft = this.lastChunk;
7180
+ } else {
7181
+ if (newRight.previous === last) return this;
7182
+ newLeft = newRight.previous;
7183
+ }
7184
+ }
7056
7185
  if (oldLeft) oldLeft.next = oldRight;
7057
7186
  if (oldRight) oldRight.previous = oldLeft;
7058
7187
  if (newLeft) newLeft.next = first;
@@ -7177,7 +7306,10 @@ var MagicString = class MagicString {
7177
7306
  }
7178
7307
  /**
7179
7308
  * Removes the characters from `start` to `end` (of the original string, **not** the generated string).
7180
- * Removing the same content twice, or making removals that partially overlap, will cause an error.
7309
+ * Content appended or prepended at positions strictly inside the range is removed with it, while
7310
+ * content attached at `start` or `end` is preserved — use `s.overwrite(start, end, '')` to remove
7311
+ * the range including its edge inserts.
7312
+ * Repeated removals and removals with partially overlapping ranges are allowed.
7181
7313
  */
7182
7314
  remove(start, end) {
7183
7315
  start = start + this.offset;
@@ -7193,9 +7325,9 @@ var MagicString = class MagicString {
7193
7325
  this._split(end);
7194
7326
  let chunk = this.byStart.get(start);
7195
7327
  while (chunk) {
7196
- chunk.intro = "";
7197
- chunk.outro = "";
7198
- chunk.edit("");
7328
+ if (chunk.start > start) chunk.intro = "";
7329
+ if (chunk.end < end) chunk.outro = "";
7330
+ chunk.edit("", false, true);
7199
7331
  chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
7200
7332
  }
7201
7333
  return this;
@@ -7275,12 +7407,13 @@ var MagicString = class MagicString {
7275
7407
  let result = "";
7276
7408
  let chunk = this.firstChunk;
7277
7409
  while (chunk && (chunk.start > start || chunk.end <= start)) {
7278
- if (chunk.start < end && chunk.end >= end) return result;
7410
+ if (chunk.start < end && chunk.end >= end || end === 0 && chunk.start === 0) return result;
7279
7411
  chunk = chunk.next;
7280
7412
  }
7281
7413
  if (chunk && chunk.edited && chunk.start !== start) throw new MagicStringError(`cannot use edited character ${start} as slice start anchor`);
7282
7414
  const startChunk = chunk;
7283
7415
  while (chunk) {
7416
+ if (end === 0 && chunk.start === 0) break;
7284
7417
  if (chunk.intro && (startChunk !== chunk || chunk.start === start)) result += chunk.intro;
7285
7418
  const containsEnd = chunk.start < end && chunk.end >= end;
7286
7419
  if (containsEnd && chunk.edited && chunk.end !== end) throw new MagicStringError(`cannot use edited character ${end} as slice end anchor`);
@@ -7393,7 +7526,8 @@ var MagicString = class MagicString {
7393
7526
  if (aborted) return true;
7394
7527
  chunk = chunk.previous;
7395
7528
  } while (chunk);
7396
- return false;
7529
+ this.intro = this.intro.replace(rx, "");
7530
+ return this.intro.length > 0;
7397
7531
  }
7398
7532
  /**
7399
7533
  * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end.
@@ -7420,7 +7554,8 @@ var MagicString = class MagicString {
7420
7554
  if (aborted) return true;
7421
7555
  chunk = chunk.next;
7422
7556
  } while (chunk);
7423
- return false;
7557
+ this.outro = this.outro.replace(rx, "");
7558
+ return this.outro.length > 0;
7424
7559
  }
7425
7560
  /**
7426
7561
  * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start.
@@ -7447,6 +7582,28 @@ var MagicString = class MagicString {
7447
7582
  }
7448
7583
  return outputIndex !== this.original.length;
7449
7584
  }
7585
+ /**
7586
+ * Whether the original range [start, end) has had any of its characters
7587
+ * removed. `replace`/`replaceAll` search `original`, so a match can land on
7588
+ * text that is no longer in the output - overwriting it would resurrect the
7589
+ * removed characters, so such matches are skipped instead.
7590
+ *
7591
+ * @internal
7592
+ */
7593
+ _hasRemovedContent(start, end) {
7594
+ let chunk = this.byStart.get(start);
7595
+ if (!chunk) {
7596
+ chunk = this.lastSearchedChunk;
7597
+ const searchForward = start >= chunk.end;
7598
+ while (chunk && !chunk.contains(start)) chunk = searchForward ? this.byStart.get(chunk.end) : this.byEnd.get(chunk.start);
7599
+ if (chunk) this.lastSearchedChunk = chunk;
7600
+ }
7601
+ while (chunk && chunk.start < end) {
7602
+ if (chunk.content === "") return true;
7603
+ chunk = this.byStart.get(chunk.end);
7604
+ }
7605
+ return false;
7606
+ }
7450
7607
  /** @internal */
7451
7608
  _replaceRegexp(searchValue, replacement) {
7452
7609
  function getReplacement(match, str) {
@@ -7455,32 +7612,42 @@ var MagicString = class MagicString {
7455
7612
  }
7456
7613
  const replaceMatch = (match) => {
7457
7614
  /* v8 ignore next 2 -- `match.index` is always defined for matches from `matchAll` */
7458
- if (match.index == null) return;
7615
+ if (match.index == null) return false;
7616
+ if (this._hasRemovedContent(match.index, match.index + match[0].length)) return false;
7459
7617
  const replacement = getReplacement(match, this.original);
7460
- if (replacement === match[0]) return;
7618
+ if (replacement === match[0]) return true;
7461
7619
  if (match[0].length === 0) this.appendRight(match.index, replacement);
7462
7620
  else this.overwrite(match.index, match.index + match[0].length, replacement);
7621
+ return true;
7463
7622
  };
7464
7623
  if (searchValue.global) {
7465
7624
  searchValue.lastIndex = 0;
7466
7625
  for (const match of this.original.matchAll(searchValue)) replaceMatch(match);
7467
7626
  } else {
7468
7627
  const match = this.original.match(searchValue);
7469
- if (match) replaceMatch(match);
7628
+ if (match && !replaceMatch(match)) {
7629
+ const global = new RegExp(searchValue.source, `${searchValue.flags}g`);
7630
+ for (const next of this.original.matchAll(global)) if (replaceMatch(next)) break;
7631
+ }
7470
7632
  }
7471
7633
  return this;
7472
7634
  }
7473
7635
  /** @internal */
7474
7636
  _replaceString(string, replacement) {
7475
7637
  const { original } = this;
7476
- const index = original.indexOf(string);
7477
- if (index !== -1) {
7638
+ let index = original.indexOf(string);
7639
+ while (index !== -1) {
7640
+ if (this._hasRemovedContent(index, index + string.length)) {
7641
+ index = original.indexOf(string, index + string.length);
7642
+ continue;
7643
+ }
7478
7644
  if (typeof replacement === "function") replacement = replacement(string, index, original);
7479
7645
  else replacement = expandReplacement(replacement, string, index, original, [], void 0);
7480
7646
  if (string !== replacement) {
7481
7647
  if (string.length === 0) this.appendRight(index, replacement);
7482
7648
  else this.overwrite(index, index + string.length, replacement);
7483
7649
  }
7650
+ break;
7484
7651
  }
7485
7652
  return this;
7486
7653
  }
@@ -7497,12 +7664,14 @@ var MagicString = class MagicString {
7497
7664
  const stringLength = string.length;
7498
7665
  if (stringLength === 0) {
7499
7666
  for (let index = 0; index <= original.length; index += 1) {
7667
+ if (this._hasRemovedContent(index, index)) continue;
7500
7668
  const _replacement = typeof replacement === "function" ? replacement("", index, original) : expandReplacement(replacement, "", index, original, [], void 0);
7501
7669
  if (_replacement !== "") this.appendRight(index, _replacement);
7502
7670
  }
7503
7671
  return this;
7504
7672
  }
7505
7673
  for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
7674
+ if (this._hasRemovedContent(index, index + stringLength)) continue;
7506
7675
  const previous = original.slice(index, index + stringLength);
7507
7676
  const _replacement = typeof replacement === "function" ? replacement(previous, index, original) : expandReplacement(replacement, previous, index, original, [], void 0);
7508
7677
  if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
@@ -8717,7 +8886,7 @@ function perEnvironmentState(initial) {
8717
8886
  };
8718
8887
  }
8719
8888
  //#endregion
8720
- //#region ../../node_modules/.pnpm/artichokie@0.4.4/node_modules/artichokie/dist/index.js
8889
+ //#region ../../node_modules/.pnpm/artichokie@0.4.5/node_modules/artichokie/dist/index.js
8721
8890
  const AsyncFunction = async function() {}.constructor;
8722
8891
  const codeToDataUrl = (code) => `data:application/javascript,${encodeURIComponent(code + "\n//# sourceURL=[worker-eval(artichokie)]")}`;
8723
8892
  const viteSsrDynamicImport = "__vite_ssr_dynamic_import__";
@@ -8752,7 +8921,14 @@ var Worker$1 = class {
8752
8921
  return new Promise((resolve, reject) => {
8753
8922
  worker.currentResolve = resolve;
8754
8923
  worker.currentReject = reject;
8755
- worker.postMessage({ args });
8924
+ try {
8925
+ worker.postMessage({ args });
8926
+ } catch (err) {
8927
+ worker.currentResolve = null;
8928
+ worker.currentReject = null;
8929
+ this._assignDoneWorker(worker);
8930
+ throw err;
8931
+ }
8756
8932
  });
8757
8933
  }
8758
8934
  stop() {
@@ -8795,18 +8971,23 @@ var Worker$1 = class {
8795
8971
  }
8796
8972
  this._assignDoneWorker(worker);
8797
8973
  });
8798
- worker.on("error", (err) => {
8974
+ const rejectWorker = (err) => {
8799
8975
  worker.currentReject?.(err);
8800
8976
  worker.currentReject = null;
8801
8977
  parentFunctionResponder.close();
8802
- });
8978
+ };
8979
+ worker.on("error", rejectWorker);
8803
8980
  worker.on("exit", (code) => {
8804
8981
  const i = this._pool.indexOf(worker);
8805
8982
  if (i > -1) this._pool.splice(i, 1);
8806
- if (code !== 0 && worker.currentReject) {
8807
- worker.currentReject(/* @__PURE__ */ new Error(`Worker stopped with non-0 exit code ${code}`));
8808
- worker.currentReject = null;
8809
- parentFunctionResponder.close();
8983
+ const idleIndex = this._idlePool.indexOf(worker);
8984
+ if (idleIndex > -1) this._idlePool.splice(idleIndex, 1);
8985
+ if (code !== 0) {
8986
+ rejectWorker(/* @__PURE__ */ new Error(`Worker stopped with non-0 exit code ${code}`));
8987
+ if (this._queue.length) {
8988
+ const [resolve, reject] = this._queue.shift();
8989
+ this._getAvailableWorker().then(resolve, reject);
8990
+ }
8810
8991
  }
8811
8992
  });
8812
8993
  this._pool.push(worker);
@@ -9403,7 +9584,7 @@ var require_src$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9403
9584
  };
9404
9585
  }));
9405
9586
  //#endregion
9406
- //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.28_tsx@4.23.13_yaml@2.9.0/node_modules/postcss-load-config/src/req.js
9587
+ //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.28_tsx@4.23.15_yaml@2.9.1/node_modules/postcss-load-config/src/req.js
9407
9588
  var require_req = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9408
9589
  const { createRequire: createRequire$2 } = __require$1("node:module");
9409
9590
  const { fileURLToPath: fileURLToPath$2, pathToFileURL: pathToFileURL$1 } = __require$1("node:url");
@@ -9445,7 +9626,7 @@ var require_req = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9445
9626
  module.exports = req;
9446
9627
  }));
9447
9628
  //#endregion
9448
- //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.28_tsx@4.23.13_yaml@2.9.0/node_modules/postcss-load-config/src/options.js
9629
+ //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.28_tsx@4.23.15_yaml@2.9.1/node_modules/postcss-load-config/src/options.js
9449
9630
  var require_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9450
9631
  const req = require_req();
9451
9632
  /**
@@ -9479,7 +9660,7 @@ var require_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9479
9660
  module.exports = options;
9480
9661
  }));
9481
9662
  //#endregion
9482
- //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.28_tsx@4.23.13_yaml@2.9.0/node_modules/postcss-load-config/src/plugins.js
9663
+ //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.28_tsx@4.23.15_yaml@2.9.1/node_modules/postcss-load-config/src/plugins.js
9483
9664
  var require_plugins = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9484
9665
  const req = require_req();
9485
9666
  /**
@@ -9533,7 +9714,7 @@ var require_plugins = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9533
9714
  module.exports = plugins;
9534
9715
  }));
9535
9716
  //#endregion
9536
- //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.28_tsx@4.23.13_yaml@2.9.0/node_modules/postcss-load-config/src/index.js
9717
+ //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.28_tsx@4.23.15_yaml@2.9.1/node_modules/postcss-load-config/src/index.js
9537
9718
  var require_src$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9538
9719
  const { resolve: resolve$3 } = __require$1("node:path");
9539
9720
  const config = require_src$3();
@@ -21196,6 +21377,26 @@ var NoopWatcher = class extends EventEmitter {
21196
21377
  function createNoopWatcher(options) {
21197
21378
  return new NoopWatcher(options);
21198
21379
  }
21380
+ /**
21381
+ * Chokidar's `add()` reopens a closed watcher. It may be called after shutdown
21382
+ * starts from an in-flight plugin hook or directly through the exposed watcher.
21383
+ * This wrapper makes `close()` final so those calls cannot create new file
21384
+ * system handles.
21385
+ */
21386
+ function makeWatcherCloseFinal(watcher) {
21387
+ let closed = false;
21388
+ const add = watcher.add;
21389
+ watcher.add = function(...args) {
21390
+ if (closed) return this;
21391
+ return add.apply(this, args);
21392
+ };
21393
+ const close = watcher.close;
21394
+ watcher.close = function(...args) {
21395
+ closed = true;
21396
+ return close.apply(this, args);
21397
+ };
21398
+ return watcher;
21399
+ }
21199
21400
  //#endregion
21200
21401
  //#region ../../vite/packages/vite/src/node/server/middlewares/base.ts
21201
21402
  function baseMiddleware(rawBase, middlewareMode) {
@@ -21847,6 +22048,7 @@ async function computeSourceRoute(map, file) {
21847
22048
  return sourceRoot;
21848
22049
  }
21849
22050
  async function injectSourcesContent(map, file, logger) {
22051
+ if (map.sourceRoot && isExternalUrl(map.sourceRoot)) return;
21850
22052
  let sourceRootPromise;
21851
22053
  const packageRoot = getNodeModulesPackageRoot(file);
21852
22054
  const missingSources = [];
@@ -21854,7 +22056,7 @@ async function injectSourcesContent(map, file, logger) {
21854
22056
  const sourcesContentPromises = [];
21855
22057
  for (let index = 0; index < map.sources.length; index++) {
21856
22058
  const sourcePath = map.sources[index];
21857
- if (sourcesContent[index] == null && sourcePath && !virtualSourceRE.test(sourcePath)) sourcesContentPromises.push((async () => {
22059
+ if (sourcesContent[index] == null && sourcePath && !isExternalUrl(sourcePath) && !virtualSourceRE.test(sourcePath)) sourcesContentPromises.push((async () => {
21858
22060
  sourceRootPromise ??= computeSourceRoute(map, file);
21859
22061
  const sourceRoot = await sourceRootPromise;
21860
22062
  let resolvedSourcePath = cleanUrl(decodeURI(sourcePath));
@@ -29800,12 +30002,12 @@ async function _createServer(inlineConfig = {}, options) {
29800
30002
  const publicFiles = await initPublicFilesPromise;
29801
30003
  const { publicDir } = config;
29802
30004
  if (httpServer) setClientErrorHandler(httpServer, config.logger);
29803
- const watcher = serverConfig.watch !== null ? import_chokidar.watch([
30005
+ const watcher = serverConfig.watch !== null ? makeWatcherCloseFinal(import_chokidar.watch([
29804
30006
  ...config.experimental.bundledDev ? [] : [root],
29805
30007
  ...config.configFileDependencies,
29806
30008
  ...getEnvFilesForMode(config.mode, config.envDir),
29807
30009
  ...publicDir && publicFiles ? [publicDir] : []
29808
- ], resolvedWatchOptions) : createNoopWatcher(resolvedWatchOptions);
30010
+ ], resolvedWatchOptions)) : createNoopWatcher(resolvedWatchOptions);
29809
30011
  const environments = {};
29810
30012
  await Promise.all(Object.entries(config.environments).map(async ([name, environmentOptions]) => {
29811
30013
  const environment = await environmentOptions.dev.createEnvironment(name, config, { ws });
@@ -30831,6 +31033,7 @@ function optimizedDepsPlugin() {
30831
31033
  if (info) {
30832
31034
  if (browserHash && info.browserHash !== browserHash && !environment.config.optimizeDeps.ignoreOutdatedRequests) throwOutdatedRequest(id);
30833
31035
  try {
31036
+ if (info.processing && depsOptimizer.initState === "idle") debug$7?.(`transforming ${import_picocolors.default.cyan(file)} is waiting for the dependency optimizer to initialize`);
30834
31037
  await info.processing;
30835
31038
  } catch {
30836
31039
  throwProcessingError(id);
@@ -30890,7 +31093,7 @@ function preAliasPlugin(config) {
30890
31093
  const ssr = environment.config.consumer === "server";
30891
31094
  const depsOptimizer = environment.depsOptimizer;
30892
31095
  if (importer && depsOptimizer && bareImportRE.test(id) && !options.scan && id !== "@vite/client" && id !== "@vite/env") {
30893
- if (findPatterns.find((pattern) => matches(pattern, id))) {
31096
+ if (findPatterns.some((pattern) => matches(pattern, id))) {
30894
31097
  const optimizedId = await tryOptimizedResolve(depsOptimizer, id, importer, config.resolve.preserveSymlinks, config.packageCache);
30895
31098
  if (optimizedId) return optimizedId;
30896
31099
  if (depsOptimizer.options.noDiscovery) return;
@@ -32933,7 +33136,7 @@ function devToScanEnvironment(environment) {
32933
33136
  }
32934
33137
  const debug$5 = createDebugger("vite:deps");
32935
33138
  const htmlTypesRE = /\.(?:html|vue|svelte|astro|imba)$/;
32936
- const importsRE = /(?<!\/\/.*)(?<=^|;|\*\/)\s*import(?!\s+type)(?:[\w*{}\n\r\t, ]+from)?\s*("[^"]+"|'[^']+')\s*(?=$|;|\/\/|\/\*)/gm;
33139
+ const importsRE = /(?<!\/\/.*)(?<=^|;|\*\/)\s*import(?!\s+type\b)(?:[\w*{}\n\r\t, ]+from)?\s*("[^"]+"|'[^']+')\s*(?=$|;|\/\/|\/\*)/gm;
32937
33140
  function scanImports(environment) {
32938
33141
  const start = performance$1.now();
32939
33142
  const { config } = environment;
@@ -39490,10 +39693,8 @@ function resolveRolldownOptions(environment, chunkMetadataMap) {
39490
39693
  ...options.rolldownOptions.resolve,
39491
39694
  tsconfigFilename: void 0
39492
39695
  } : options.rolldownOptions.resolve,
39493
- output: options.rolldownOptions.output,
39494
39696
  input,
39495
39697
  plugins,
39496
- external: options.rolldownOptions.external,
39497
39698
  onLog(level, log) {
39498
39699
  onRollupLog(level, log, environment);
39499
39700
  },
@@ -39537,19 +39738,19 @@ function resolveRolldownOptions(environment, chunkMetadataMap) {
39537
39738
  chunkFileNames: libOptions ? `[name]-[hash].${jsExt}` : path.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`),
39538
39739
  assetFileNames: libOptions ? `[name].[ext]` : path.posix.join(options.assetsDir, `[name]-[hash].[ext]`),
39539
39740
  codeSplitting: output.codeSplitting ?? (output.format === "umd" || output.format === "iife" || isSsrTargetWebworkerEnvironment && (typeof input === "string" || Object.keys(input).length === 1) ? false : void 0),
39540
- comments: typeof output.comments === "boolean" ? output.comments : {
39541
- annotation: !options.minify || libOptions && (format === "es" || format === "esm"),
39542
- jsdoc: !options.minify,
39543
- legal: !options.minify,
39544
- ...output.comments
39545
- },
39546
39741
  minify: options.minify === "oxc" ? libOptions && (format === "es" || format === "esm") ? {
39547
39742
  compress: true,
39548
39743
  mangle: true,
39549
39744
  codegen: false
39550
39745
  } : true : options.minify === false ? "dce-only" : false,
39551
39746
  topLevelVar: true,
39552
- ...output
39747
+ ...output,
39748
+ comments: typeof output.comments === "boolean" ? output.comments : {
39749
+ annotation: !options.minify || libOptions && (format === "es" || format === "esm"),
39750
+ jsdoc: !options.minify,
39751
+ legal: !options.minify,
39752
+ ...output.comments
39753
+ }
39553
39754
  };
39554
39755
  };
39555
39756
  const outputs = resolveBuildOutputs(options.rolldownOptions.output, libOptions, logger);
@@ -40476,6 +40677,7 @@ function createDepsOptimizer(environment) {
40476
40677
  let metadata = initDepsOptimizerMetadata(environment, sessionTimestamp);
40477
40678
  const depsOptimizer = {
40478
40679
  init,
40680
+ initState: "idle",
40479
40681
  metadata,
40480
40682
  registerMissingImport,
40481
40683
  run: () => debouncedProcessing(0),
@@ -40516,16 +40718,19 @@ function createDepsOptimizer(environment) {
40516
40718
  let discover;
40517
40719
  async function close() {
40518
40720
  closed = true;
40721
+ if (debounceProcessingHandle) clearTimeout(debounceProcessingHandle);
40722
+ debounceProcessingHandle = void 0;
40519
40723
  await Promise.allSettled([
40520
40724
  discover?.cancel(),
40521
40725
  depsOptimizer.scanProcessing,
40522
40726
  optimizationResult?.cancel()
40523
40727
  ]);
40728
+ depOptimizationProcessing.resolve();
40729
+ resolveEnqueuedProcessingPromises();
40524
40730
  }
40525
- let initState = "idle";
40526
40731
  async function init() {
40527
- if (initState !== "idle") return;
40528
- initState = "initializing";
40732
+ if (depsOptimizer.initState !== "idle") return;
40733
+ depsOptimizer.initState = "initializing";
40529
40734
  const cachedMetadata = await loadCachedDepOptimizationMetadata(environment);
40530
40735
  firstRunCalled = !!cachedMetadata;
40531
40736
  metadata = depsOptimizer.metadata = cachedMetadata || initDepsOptimizerMetadata(environment, sessionTimestamp);
@@ -40582,7 +40787,7 @@ function createDepsOptimizer(environment) {
40582
40787
  })();
40583
40788
  });
40584
40789
  }
40585
- initState = "initialized";
40790
+ depsOptimizer.initState = "initialized";
40586
40791
  }
40587
40792
  function startNextDiscoveredBatch() {
40588
40793
  newDepsDiscovered = false;
@@ -40606,8 +40811,6 @@ function createDepsOptimizer(environment) {
40606
40811
  if (debounceProcessingHandle) clearTimeout(debounceProcessingHandle);
40607
40812
  if (closed) {
40608
40813
  currentlyProcessing = false;
40609
- depOptimizationProcessing.resolve();
40610
- resolveEnqueuedProcessingPromises();
40611
40814
  return;
40612
40815
  }
40613
40816
  currentlyProcessing = true;
@@ -40624,7 +40827,6 @@ function createDepsOptimizer(environment) {
40624
40827
  if (closed) {
40625
40828
  currentlyProcessing = false;
40626
40829
  processingResult.cancel();
40627
- resolveEnqueuedProcessingPromises();
40628
40830
  return;
40629
40831
  }
40630
40832
  const newData = processingResult.metadata;
@@ -40719,7 +40921,7 @@ function createDepsOptimizer(environment) {
40719
40921
  let missing = metadata.discovered[id];
40720
40922
  if (missing) return missing;
40721
40923
  missing = addMissingDep(id, resolved);
40722
- if (initState === "initialized" && !waitingForCrawlEnd) debouncedProcessing();
40924
+ if (depsOptimizer.initState === "initialized" && !waitingForCrawlEnd) debouncedProcessing();
40723
40925
  return missing;
40724
40926
  }
40725
40927
  function addMissingDep(id, resolved) {
@@ -40796,6 +40998,7 @@ function createDepsOptimizer(environment) {
40796
40998
  function createExplicitDepsOptimizer(environment) {
40797
40999
  const depsOptimizer = {
40798
41000
  metadata: initDepsOptimizerMetadata(environment),
41001
+ initState: "idle",
40799
41002
  isOptimizedDepFile: createIsOptimizedDepFile(environment),
40800
41003
  isOptimizedDepUrl: createIsOptimizedDepUrl(environment),
40801
41004
  getOptimizedDepId: (depInfo) => `${depInfo.file}?v=${depInfo.browserHash}`,
@@ -40807,11 +41010,11 @@ function createExplicitDepsOptimizer(environment) {
40807
41010
  close: async () => {},
40808
41011
  options: environment.config.optimizeDeps
40809
41012
  };
40810
- let inited = false;
40811
41013
  async function init() {
40812
- if (inited) return;
40813
- inited = true;
41014
+ if (depsOptimizer.initState !== "idle") return;
41015
+ depsOptimizer.initState = "initializing";
40814
41016
  depsOptimizer.metadata = await optimizeExplicitEnvironmentDeps(environment);
41017
+ depsOptimizer.initState = "initialized";
40815
41018
  }
40816
41019
  return depsOptimizer;
40817
41020
  }