@depup/vite 8.3.0-depup.0 → 8.3.1-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/changes.json +3 -3
- package/dist/client/bundledDevClient.mjs +36 -6
- package/dist/client/client.mjs +4 -4
- package/dist/node/chunks/build.js +2 -2
- package/dist/node/chunks/lib.js +2 -2
- package/dist/node/chunks/node.js +540 -175
- package/dist/node/index.d.ts +4 -3
- package/dist/node/module-runner.js +10 -8
- package/package.json +14 -14
package/dist/node/chunks/node.js
CHANGED
|
@@ -628,7 +628,7 @@ var BaseEnvironment = class extends PartialEnvironment {
|
|
|
628
628
|
};
|
|
629
629
|
//#endregion
|
|
630
630
|
//#region package.json
|
|
631
|
-
var version = "8.3.
|
|
631
|
+
var version = "8.3.1";
|
|
632
632
|
//#endregion
|
|
633
633
|
//#region src/node/constants.ts
|
|
634
634
|
const ROLLUP_HOOKS = [
|
|
@@ -762,7 +762,7 @@ const KNOWN_ASSET_TYPES = [
|
|
|
762
762
|
"pdf",
|
|
763
763
|
"txt"
|
|
764
764
|
];
|
|
765
|
-
const DEFAULT_ASSETS_RE = new RegExp(`\\.(
|
|
765
|
+
const DEFAULT_ASSETS_RE = new RegExp(`\\.(?:` + KNOWN_ASSET_TYPES.join("|") + `)(\\?.*)?$`, "i");
|
|
766
766
|
const DEP_VERSION_RE = /[?&](v=[\w.-]+)\b/;
|
|
767
767
|
const loopbackHosts = /* @__PURE__ */ new Set([
|
|
768
768
|
"localhost",
|
|
@@ -840,18 +840,18 @@ function ignoreDeprecationWarnings(fn) {
|
|
|
840
840
|
return ret;
|
|
841
841
|
}
|
|
842
842
|
//#endregion
|
|
843
|
-
//#region ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.
|
|
843
|
+
//#region ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.6.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
844
844
|
var comma$1 = ",".charCodeAt(0);
|
|
845
845
|
var semicolon = ";".charCodeAt(0);
|
|
846
846
|
var chars$1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
847
|
-
var intToChar$
|
|
847
|
+
var intToChar$2 = /* @__PURE__ */ new Uint8Array(64);
|
|
848
848
|
var charToInt$1 = /* @__PURE__ */ new Uint8Array(128);
|
|
849
849
|
for (let i = 0; i < chars$1.length; i++) {
|
|
850
850
|
const c = chars$1.charCodeAt(i);
|
|
851
|
-
intToChar$
|
|
851
|
+
intToChar$2[i] = c;
|
|
852
852
|
charToInt$1[c] = i;
|
|
853
853
|
}
|
|
854
|
-
function decodeInteger$1(reader
|
|
854
|
+
function decodeInteger$1(reader) {
|
|
855
855
|
let value = 0;
|
|
856
856
|
let shift = 0;
|
|
857
857
|
let integer = 0;
|
|
@@ -860,21 +860,21 @@ function decodeInteger$1(reader, relative) {
|
|
|
860
860
|
value |= (integer & 31) << shift;
|
|
861
861
|
shift += 5;
|
|
862
862
|
} while (integer & 32);
|
|
863
|
-
|
|
864
|
-
value >>>= 1;
|
|
865
|
-
if (shouldNegate) value = -2147483648 | -value;
|
|
866
|
-
return relative + value;
|
|
863
|
+
return value;
|
|
867
864
|
}
|
|
868
|
-
function
|
|
869
|
-
|
|
870
|
-
|
|
865
|
+
function decodeSign(num) {
|
|
866
|
+
return num & 1 ? -2147483648 | -(num >>> 1) : num >>> 1;
|
|
867
|
+
}
|
|
868
|
+
function encodeInteger(builder, num) {
|
|
871
869
|
do {
|
|
872
|
-
let clamped =
|
|
873
|
-
|
|
874
|
-
if (
|
|
875
|
-
builder.write(intToChar$
|
|
876
|
-
} while (
|
|
877
|
-
|
|
870
|
+
let clamped = num & 31;
|
|
871
|
+
num >>>= 5;
|
|
872
|
+
if (num > 0) clamped |= 32;
|
|
873
|
+
builder.write(intToChar$2[clamped]);
|
|
874
|
+
} while (num > 0);
|
|
875
|
+
}
|
|
876
|
+
function encodeSign(num) {
|
|
877
|
+
return num < 0 ? -num << 1 | 1 : num << 1;
|
|
878
878
|
}
|
|
879
879
|
function hasMoreVlq$1(reader, max) {
|
|
880
880
|
if (reader.pos >= max) return false;
|
|
@@ -924,6 +924,21 @@ var StringReader$1 = class {
|
|
|
924
924
|
return idx === -1 ? buffer.length : idx;
|
|
925
925
|
}
|
|
926
926
|
};
|
|
927
|
+
function encodeRangeMappings(decoded) {
|
|
928
|
+
if (decoded.length === 0) return "";
|
|
929
|
+
const writer = new StringWriter();
|
|
930
|
+
for (let i = 0; i < decoded.length; i++) {
|
|
931
|
+
const indices = decoded[i];
|
|
932
|
+
if (i > 0) writer.write(semicolon);
|
|
933
|
+
let index = 0;
|
|
934
|
+
for (let j = 0; j < indices.length; j++) {
|
|
935
|
+
const offset = indices[j];
|
|
936
|
+
encodeInteger(writer, offset - index);
|
|
937
|
+
index = offset;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
return writer.flush();
|
|
941
|
+
}
|
|
927
942
|
function decode$1(mappings) {
|
|
928
943
|
const { length } = mappings;
|
|
929
944
|
const reader = new StringReader$1(mappings);
|
|
@@ -941,15 +956,15 @@ function decode$1(mappings) {
|
|
|
941
956
|
genColumn = 0;
|
|
942
957
|
while (reader.pos < semi) {
|
|
943
958
|
let seg;
|
|
944
|
-
genColumn
|
|
959
|
+
genColumn += decodeSign(decodeInteger$1(reader));
|
|
945
960
|
if (genColumn < lastCol) sorted = false;
|
|
946
961
|
lastCol = genColumn;
|
|
947
962
|
if (hasMoreVlq$1(reader, semi)) {
|
|
948
|
-
sourcesIndex
|
|
949
|
-
sourceLine
|
|
950
|
-
sourceColumn
|
|
963
|
+
sourcesIndex += decodeSign(decodeInteger$1(reader));
|
|
964
|
+
sourceLine += decodeSign(decodeInteger$1(reader));
|
|
965
|
+
sourceColumn += decodeSign(decodeInteger$1(reader));
|
|
951
966
|
if (hasMoreVlq$1(reader, semi)) {
|
|
952
|
-
namesIndex
|
|
967
|
+
namesIndex += decodeSign(decodeInteger$1(reader));
|
|
953
968
|
seg = [
|
|
954
969
|
genColumn,
|
|
955
970
|
sourcesIndex,
|
|
@@ -993,13 +1008,18 @@ function encode$1(decoded) {
|
|
|
993
1008
|
for (let j = 0; j < line.length; j++) {
|
|
994
1009
|
const segment = line[j];
|
|
995
1010
|
if (j > 0) writer.write(comma$1);
|
|
996
|
-
|
|
1011
|
+
encodeInteger(writer, encodeSign(segment[0] - genColumn));
|
|
1012
|
+
genColumn = segment[0];
|
|
997
1013
|
if (segment.length === 1) continue;
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1014
|
+
encodeInteger(writer, encodeSign(segment[1] - sourcesIndex));
|
|
1015
|
+
encodeInteger(writer, encodeSign(segment[2] - sourceLine));
|
|
1016
|
+
encodeInteger(writer, encodeSign(segment[3] - sourceColumn));
|
|
1017
|
+
sourcesIndex = segment[1];
|
|
1018
|
+
sourceLine = segment[2];
|
|
1019
|
+
sourceColumn = segment[3];
|
|
1001
1020
|
if (segment.length === 4) continue;
|
|
1002
|
-
|
|
1021
|
+
encodeInteger(writer, encodeSign(segment[4] - namesIndex));
|
|
1022
|
+
namesIndex = segment[4];
|
|
1003
1023
|
}
|
|
1004
1024
|
}
|
|
1005
1025
|
return writer.flush();
|
|
@@ -2807,7 +2827,10 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
|
|
|
2807
2827
|
const merged = { ...defaults };
|
|
2808
2828
|
if (rollupOptionsRootPaths.has(rootPath)) setupRollupOptionCompat(merged, rootPath);
|
|
2809
2829
|
if (rootPath === "server") setupHmrWsOptionCompat(merged);
|
|
2810
|
-
if (rootPath === "server.hmr") for (const key of wsOptionKeys)
|
|
2830
|
+
if (rootPath === "server.hmr") for (const key of wsOptionKeys) {
|
|
2831
|
+
const descriptor = Object.getOwnPropertyDescriptor(defaults, key);
|
|
2832
|
+
if (descriptor) Object.defineProperty(merged, key, descriptor);
|
|
2833
|
+
}
|
|
2811
2834
|
for (const key in overrides) {
|
|
2812
2835
|
const value = overrides[key];
|
|
2813
2836
|
if (value == null) continue;
|
|
@@ -3437,7 +3460,7 @@ function alias$1(options = {}) {
|
|
|
3437
3460
|
};
|
|
3438
3461
|
}
|
|
3439
3462
|
//#endregion
|
|
3440
|
-
//#region ../../node_modules/.pnpm/magic-string@1.
|
|
3463
|
+
//#region ../../node_modules/.pnpm/magic-string@1.4.1/node_modules/magic-string/dist/index.mjs
|
|
3441
3464
|
var BitSet = class BitSet {
|
|
3442
3465
|
constructor(arg) {
|
|
3443
3466
|
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
@@ -3548,8 +3571,10 @@ var Chunk = class Chunk {
|
|
|
3548
3571
|
if (this.outro.length) return true;
|
|
3549
3572
|
const trimmed = this.content.replace(rx, "");
|
|
3550
3573
|
if (trimmed.length) {
|
|
3551
|
-
if (trimmed !== this.content)
|
|
3552
|
-
|
|
3574
|
+
if (trimmed !== this.content) {
|
|
3575
|
+
if (this.edited) this.edit(trimmed, this.storeName, true);
|
|
3576
|
+
else this.split(this.start + trimmed.length).edit("", void 0, true);
|
|
3577
|
+
}
|
|
3553
3578
|
return true;
|
|
3554
3579
|
} else {
|
|
3555
3580
|
this.edit("", void 0, true);
|
|
@@ -3562,10 +3587,12 @@ var Chunk = class Chunk {
|
|
|
3562
3587
|
if (this.intro.length) return true;
|
|
3563
3588
|
const trimmed = this.content.replace(rx, "");
|
|
3564
3589
|
if (trimmed.length) {
|
|
3565
|
-
if (trimmed !== this.content)
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3590
|
+
if (trimmed !== this.content) {
|
|
3591
|
+
if (this.edited) this.edit(trimmed, this.storeName, true);
|
|
3592
|
+
else {
|
|
3593
|
+
this.split(this.end - trimmed.length);
|
|
3594
|
+
this.edit("", void 0, true);
|
|
3595
|
+
}
|
|
3569
3596
|
}
|
|
3570
3597
|
return true;
|
|
3571
3598
|
} else {
|
|
@@ -3588,12 +3615,14 @@ var MagicStringError = class extends Error {
|
|
|
3588
3615
|
}
|
|
3589
3616
|
};
|
|
3590
3617
|
function getBtoa() {
|
|
3618
|
+
/* v8 ignore next -- environment fallback, unreachable when `btoa` is present */
|
|
3591
3619
|
if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
|
|
3592
3620
|
const buffer = globalThis["Buffer"];
|
|
3593
3621
|
if (buffer) return (str) => buffer.from(str, "utf-8").toString("base64");
|
|
3594
3622
|
return () => {
|
|
3595
3623
|
throw new MagicStringError("unsupported environment: `btoa` or `Buffer` is required");
|
|
3596
3624
|
};
|
|
3625
|
+
/* v8 ignore stop */
|
|
3597
3626
|
}
|
|
3598
3627
|
const btoa$1 = /* #__PURE__ */ getBtoa();
|
|
3599
3628
|
var SourceMap = class {
|
|
@@ -3603,9 +3632,17 @@ var SourceMap = class {
|
|
|
3603
3632
|
this.sources = properties.sources;
|
|
3604
3633
|
this.sourcesContent = properties.sourcesContent;
|
|
3605
3634
|
this.names = properties.names;
|
|
3606
|
-
this.mappings = encode$1(properties.mappings);
|
|
3635
|
+
this.mappings = typeof properties.mappings === "string" ? properties.mappings : encode$1(properties.mappings);
|
|
3607
3636
|
if (typeof properties.x_google_ignoreList !== "undefined") this.x_google_ignoreList = properties.x_google_ignoreList;
|
|
3608
3637
|
if (typeof properties.debugId !== "undefined") this.debugId = properties.debugId;
|
|
3638
|
+
if (typeof properties.rangeMappings !== "undefined") {
|
|
3639
|
+
let shouldOutputRangeMapping = false;
|
|
3640
|
+
for (const line of properties.rangeMappings) if (line.length !== 0) {
|
|
3641
|
+
shouldOutputRangeMapping = true;
|
|
3642
|
+
break;
|
|
3643
|
+
}
|
|
3644
|
+
if (shouldOutputRangeMapping) this.rangeMappings = encodeRangeMappings(properties.rangeMappings);
|
|
3645
|
+
}
|
|
3609
3646
|
}
|
|
3610
3647
|
/**
|
|
3611
3648
|
* Returns the equivalent of `JSON.stringify(map)`
|
|
@@ -3622,12 +3659,8 @@ var SourceMap = class {
|
|
|
3622
3659
|
}
|
|
3623
3660
|
};
|
|
3624
3661
|
function getLocator(source) {
|
|
3625
|
-
const
|
|
3626
|
-
|
|
3627
|
-
for (let i = 0, pos = 0; i < originalLines.length; i++) {
|
|
3628
|
-
lineOffsets.push(pos);
|
|
3629
|
-
pos += originalLines[i].length + 1;
|
|
3630
|
-
}
|
|
3662
|
+
const lineOffsets = [0];
|
|
3663
|
+
for (let i = source.indexOf("\n"); i !== -1; i = source.indexOf("\n", i + 1)) lineOffsets.push(i + 1);
|
|
3631
3664
|
return function locate(index) {
|
|
3632
3665
|
let i = 0;
|
|
3633
3666
|
let j = lineOffsets.length;
|
|
@@ -3673,15 +3706,120 @@ const toString = Object.prototype.toString;
|
|
|
3673
3706
|
function isObject(thing) {
|
|
3674
3707
|
return toString.call(thing) === "[object Object]";
|
|
3675
3708
|
}
|
|
3676
|
-
const
|
|
3709
|
+
const BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
3710
|
+
const intToChar$1 = /* #__PURE__ */ (() => {
|
|
3711
|
+
const chars = /* @__PURE__ */ new Uint8Array(64);
|
|
3712
|
+
for (let i = 0; i < 64; i++) chars[i] = BASE64_CHARS.charCodeAt(i);
|
|
3713
|
+
return chars;
|
|
3714
|
+
})();
|
|
3715
|
+
const COMMA = 44;
|
|
3716
|
+
const SEMICOLON = 59;
|
|
3717
|
+
const BUFFER_SIZE = 16384;
|
|
3718
|
+
const FLUSH_THRESHOLD = 16348;
|
|
3719
|
+
const scratch = /* #__PURE__ */ new Uint8Array(BUFFER_SIZE);
|
|
3720
|
+
function writeVlq(pos, num) {
|
|
3721
|
+
num = num < 0 ? -num << 1 | 1 : num << 1;
|
|
3722
|
+
do {
|
|
3723
|
+
let clamped = num & 31;
|
|
3724
|
+
num >>>= 5;
|
|
3725
|
+
if (num > 0) clamped |= 32;
|
|
3726
|
+
scratch[pos++] = intToChar$1[clamped];
|
|
3727
|
+
} while (num > 0);
|
|
3728
|
+
return pos;
|
|
3729
|
+
}
|
|
3730
|
+
const decoder$1 = /* #__PURE__ */ new TextDecoder();
|
|
3731
|
+
var MappingsEncoder = class {
|
|
3732
|
+
constructor() {
|
|
3733
|
+
this.out = "";
|
|
3734
|
+
this.pos = 0;
|
|
3735
|
+
this.lines = [];
|
|
3736
|
+
this.buffered = 0;
|
|
3737
|
+
this.needsComma = false;
|
|
3738
|
+
this.prevGenColumn = 0;
|
|
3739
|
+
this.prevSourceIndex = 0;
|
|
3740
|
+
this.prevSourceLine = 0;
|
|
3741
|
+
this.prevSourceColumn = 0;
|
|
3742
|
+
this.prevNameIndex = 0;
|
|
3743
|
+
}
|
|
3744
|
+
endLine(segments) {
|
|
3745
|
+
this.lines.push(segments);
|
|
3746
|
+
this.buffered += segments.length + 1;
|
|
3747
|
+
if (this.buffered >= 4096) this.drain(null);
|
|
3748
|
+
}
|
|
3749
|
+
segments(segments) {
|
|
3750
|
+
this.drain(segments);
|
|
3751
|
+
}
|
|
3752
|
+
finish(segments) {
|
|
3753
|
+
this.drain(segments);
|
|
3754
|
+
this.flush();
|
|
3755
|
+
return this.out;
|
|
3756
|
+
}
|
|
3757
|
+
drain(trailing) {
|
|
3758
|
+
const lines = this.lines;
|
|
3759
|
+
const lineCount = lines.length;
|
|
3760
|
+
for (let l = 0; l <= lineCount; l++) {
|
|
3761
|
+
const line = l < lineCount ? lines[l] : trailing;
|
|
3762
|
+
if (line === null) break;
|
|
3763
|
+
for (let i = 0; i < line.length; i++) {
|
|
3764
|
+
if (this.pos > FLUSH_THRESHOLD) this.flush();
|
|
3765
|
+
const segment = line[i];
|
|
3766
|
+
if (this.needsComma) scratch[this.pos++] = COMMA;
|
|
3767
|
+
this.needsComma = true;
|
|
3768
|
+
this.pos = writeVlq(this.pos, segment[0] - this.prevGenColumn);
|
|
3769
|
+
this.prevGenColumn = segment[0];
|
|
3770
|
+
this.pos = writeVlq(this.pos, segment[1] - this.prevSourceIndex);
|
|
3771
|
+
this.prevSourceIndex = segment[1];
|
|
3772
|
+
this.pos = writeVlq(this.pos, segment[2] - this.prevSourceLine);
|
|
3773
|
+
this.prevSourceLine = segment[2];
|
|
3774
|
+
this.pos = writeVlq(this.pos, segment[3] - this.prevSourceColumn);
|
|
3775
|
+
this.prevSourceColumn = segment[3];
|
|
3776
|
+
if (segment.length === 5) {
|
|
3777
|
+
this.pos = writeVlq(this.pos, segment[4] - this.prevNameIndex);
|
|
3778
|
+
this.prevNameIndex = segment[4];
|
|
3779
|
+
}
|
|
3780
|
+
}
|
|
3781
|
+
if (l < lineCount) {
|
|
3782
|
+
if (this.pos > FLUSH_THRESHOLD) this.flush();
|
|
3783
|
+
scratch[this.pos++] = SEMICOLON;
|
|
3784
|
+
this.needsComma = false;
|
|
3785
|
+
this.prevGenColumn = 0;
|
|
3786
|
+
}
|
|
3787
|
+
}
|
|
3788
|
+
lines.length = 0;
|
|
3789
|
+
this.buffered = 0;
|
|
3790
|
+
this.flush();
|
|
3791
|
+
}
|
|
3792
|
+
flush() {
|
|
3793
|
+
this.out += decoder$1.decode(scratch.subarray(0, this.pos));
|
|
3794
|
+
this.pos = 0;
|
|
3795
|
+
}
|
|
3796
|
+
};
|
|
3797
|
+
const NEWLINE_CHAR$1 = 10;
|
|
3798
|
+
function isWordCode(code) {
|
|
3799
|
+
return code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57 || code === 95;
|
|
3800
|
+
}
|
|
3677
3801
|
var Mappings = class {
|
|
3678
|
-
constructor(hires) {
|
|
3802
|
+
constructor(hires, encoder = null) {
|
|
3679
3803
|
this.hires = hires;
|
|
3680
3804
|
this.generatedCodeLine = 0;
|
|
3681
3805
|
this.generatedCodeColumn = 0;
|
|
3682
3806
|
this.raw = [];
|
|
3683
3807
|
this.rawSegments = this.raw[this.generatedCodeLine] = [];
|
|
3684
|
-
this.
|
|
3808
|
+
this.rawRangeMappings = [];
|
|
3809
|
+
this.rawRangeMappingsIndices = this.rawRangeMappings[this.generatedCodeLine] = [];
|
|
3810
|
+
this.encoder = encoder;
|
|
3811
|
+
}
|
|
3812
|
+
nextLine() {
|
|
3813
|
+
if (this.encoder === null) {
|
|
3814
|
+
this.generatedCodeLine += 1;
|
|
3815
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
3816
|
+
} else {
|
|
3817
|
+
this.encoder.endLine(this.rawSegments);
|
|
3818
|
+
this.rawSegments = [];
|
|
3819
|
+
this.generatedCodeLine += 1;
|
|
3820
|
+
}
|
|
3821
|
+
this.generatedCodeColumn = 0;
|
|
3822
|
+
this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
|
|
3685
3823
|
}
|
|
3686
3824
|
addEdit(sourceIndex, content, loc, nameIndex) {
|
|
3687
3825
|
if (content.length) {
|
|
@@ -3697,9 +3835,7 @@ var Mappings = class {
|
|
|
3697
3835
|
];
|
|
3698
3836
|
if (nameIndex >= 0) segment.push(nameIndex);
|
|
3699
3837
|
this.rawSegments.push(segment);
|
|
3700
|
-
this.
|
|
3701
|
-
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
3702
|
-
this.generatedCodeColumn = 0;
|
|
3838
|
+
this.nextLine();
|
|
3703
3839
|
previousContentLineEnd = contentLineEnd;
|
|
3704
3840
|
contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
|
|
3705
3841
|
}
|
|
@@ -3712,63 +3848,122 @@ var Mappings = class {
|
|
|
3712
3848
|
if (nameIndex >= 0) segment.push(nameIndex);
|
|
3713
3849
|
this.rawSegments.push(segment);
|
|
3714
3850
|
this.advance(content.slice(previousContentLineEnd + 1));
|
|
3715
|
-
} else if (this.pending) {
|
|
3716
|
-
this.rawSegments.push(this.pending);
|
|
3717
|
-
this.advance(content);
|
|
3718
3851
|
}
|
|
3719
|
-
this.pending = null;
|
|
3720
3852
|
}
|
|
3721
3853
|
addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
|
|
3722
|
-
|
|
3723
|
-
let
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3854
|
+
const end = chunk.end;
|
|
3855
|
+
let i = chunk.start;
|
|
3856
|
+
if (this.hires) {
|
|
3857
|
+
const boundary = this.hires === "boundary";
|
|
3858
|
+
const experimentalRange = this.hires === "experimental-range";
|
|
3859
|
+
const encoder = experimentalRange ? null : this.encoder;
|
|
3860
|
+
let charInHiresBoundary = false;
|
|
3861
|
+
while (i < end) {
|
|
3862
|
+
if (encoder !== null && this.rawSegments.length >= 4096) {
|
|
3863
|
+
encoder.segments(this.rawSegments);
|
|
3864
|
+
this.rawSegments.length = 0;
|
|
3865
|
+
}
|
|
3866
|
+
if (experimentalRange && i + 1 >= end) this.rawSegments.push([
|
|
3867
|
+
this.generatedCodeColumn,
|
|
3868
|
+
sourceIndex,
|
|
3869
|
+
loc.line,
|
|
3870
|
+
loc.column
|
|
3871
|
+
]);
|
|
3872
|
+
const code = original.charCodeAt(i);
|
|
3873
|
+
if (code === NEWLINE_CHAR$1) {
|
|
3874
|
+
loc.line += 1;
|
|
3875
|
+
loc.column = 0;
|
|
3876
|
+
this.nextLine();
|
|
3877
|
+
charInHiresBoundary = false;
|
|
3878
|
+
} else {
|
|
3879
|
+
if (boundary) {
|
|
3880
|
+
if (isWordCode(code)) {
|
|
3881
|
+
if (!charInHiresBoundary) {
|
|
3882
|
+
this.rawSegments.push([
|
|
3883
|
+
this.generatedCodeColumn,
|
|
3884
|
+
sourceIndex,
|
|
3885
|
+
loc.line,
|
|
3886
|
+
loc.column
|
|
3887
|
+
]);
|
|
3888
|
+
charInHiresBoundary = true;
|
|
3889
|
+
}
|
|
3890
|
+
} else {
|
|
3891
|
+
this.rawSegments.push([
|
|
3892
|
+
this.generatedCodeColumn,
|
|
3893
|
+
sourceIndex,
|
|
3894
|
+
loc.line,
|
|
3895
|
+
loc.column
|
|
3896
|
+
]);
|
|
3897
|
+
charInHiresBoundary = false;
|
|
3898
|
+
}
|
|
3899
|
+
} else if (experimentalRange) {
|
|
3900
|
+
if (i === chunk.start) {
|
|
3901
|
+
this.rawRangeMappingsIndices.push(this.rawSegments.length);
|
|
3902
|
+
this.rawSegments.push([
|
|
3903
|
+
this.generatedCodeColumn,
|
|
3904
|
+
sourceIndex,
|
|
3905
|
+
loc.line,
|
|
3906
|
+
loc.column
|
|
3907
|
+
]);
|
|
3908
|
+
}
|
|
3909
|
+
} else this.rawSegments.push([
|
|
3737
3910
|
this.generatedCodeColumn,
|
|
3738
3911
|
sourceIndex,
|
|
3739
3912
|
loc.line,
|
|
3740
3913
|
loc.column
|
|
3741
|
-
];
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3914
|
+
]);
|
|
3915
|
+
loc.column += 1;
|
|
3916
|
+
this.generatedCodeColumn += 1;
|
|
3917
|
+
}
|
|
3918
|
+
i += 1;
|
|
3919
|
+
}
|
|
3920
|
+
} else {
|
|
3921
|
+
const bits = sourcemapLocations.bits;
|
|
3922
|
+
while (i < end) {
|
|
3923
|
+
let newline = original.indexOf("\n", i);
|
|
3924
|
+
if (newline === -1 || newline > end) newline = end;
|
|
3925
|
+
if (newline > i) {
|
|
3926
|
+
this.rawSegments.push([
|
|
3927
|
+
this.generatedCodeColumn,
|
|
3928
|
+
sourceIndex,
|
|
3929
|
+
loc.line,
|
|
3930
|
+
loc.column
|
|
3931
|
+
]);
|
|
3932
|
+
for (let w = i + 1 >> 5, last = newline - 1 >> 5; w <= last; w++) {
|
|
3933
|
+
let word = bits[w];
|
|
3934
|
+
if (!word) continue;
|
|
3935
|
+
const base = w << 5;
|
|
3936
|
+
while (word) {
|
|
3937
|
+
const lowest = word & -word;
|
|
3938
|
+
const index = base + 31 - Math.clz32(lowest);
|
|
3939
|
+
if (index > i && index < newline) {
|
|
3940
|
+
const offset = index - i;
|
|
3941
|
+
this.rawSegments.push([
|
|
3942
|
+
this.generatedCodeColumn + offset,
|
|
3943
|
+
sourceIndex,
|
|
3944
|
+
loc.line,
|
|
3945
|
+
loc.column + offset
|
|
3946
|
+
]);
|
|
3947
|
+
}
|
|
3948
|
+
word ^= lowest;
|
|
3746
3949
|
}
|
|
3747
|
-
} else {
|
|
3748
|
-
this.rawSegments.push(segment);
|
|
3749
|
-
charInHiresBoundary = false;
|
|
3750
3950
|
}
|
|
3751
|
-
|
|
3951
|
+
loc.column += newline - i;
|
|
3952
|
+
this.generatedCodeColumn += newline - i;
|
|
3752
3953
|
}
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3954
|
+
if (newline === end) break;
|
|
3955
|
+
loc.line += 1;
|
|
3956
|
+
loc.column = 0;
|
|
3957
|
+
this.nextLine();
|
|
3958
|
+
i = newline + 1;
|
|
3756
3959
|
}
|
|
3757
|
-
originalCharIndex += 1;
|
|
3758
3960
|
}
|
|
3759
|
-
this.pending = null;
|
|
3760
3961
|
}
|
|
3761
3962
|
advance(str) {
|
|
3762
3963
|
if (!str) return;
|
|
3763
|
-
const
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
this.generatedCodeLine++;
|
|
3767
|
-
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
3768
|
-
}
|
|
3769
|
-
this.generatedCodeColumn = 0;
|
|
3770
|
-
}
|
|
3771
|
-
this.generatedCodeColumn += lines[lines.length - 1].length;
|
|
3964
|
+
const lastNewline = str.lastIndexOf("\n");
|
|
3965
|
+
for (let i = str.indexOf("\n"); i !== -1; i = str.indexOf("\n", i + 1)) this.nextLine();
|
|
3966
|
+
this.generatedCodeColumn += str.length - lastNewline - 1;
|
|
3772
3967
|
}
|
|
3773
3968
|
};
|
|
3774
3969
|
const n$1 = "\n";
|
|
@@ -3779,6 +3974,63 @@ const warned = {
|
|
|
3779
3974
|
insertRight: false,
|
|
3780
3975
|
storeName: false
|
|
3781
3976
|
};
|
|
3977
|
+
/**
|
|
3978
|
+
* Expands the `$` substitution patterns that `String.prototype.replace` accepts
|
|
3979
|
+
* in a string replacement.
|
|
3980
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
|
|
3981
|
+
*
|
|
3982
|
+
* `captures` holds the capture groups in order, so `captures[0]` is `$1`.
|
|
3983
|
+
* `namedCaptures` is `undefined` when the pattern has no named groups, and
|
|
3984
|
+
* `$<name>` is then literal text - which is also the case for a string search
|
|
3985
|
+
* value, where there are no groups of either kind.
|
|
3986
|
+
*/
|
|
3987
|
+
function expandReplacement(replacement, matched, position, str, captures, namedCaptures) {
|
|
3988
|
+
if (!replacement.includes("$")) return replacement;
|
|
3989
|
+
let result = "";
|
|
3990
|
+
let index = 0;
|
|
3991
|
+
while (index < replacement.length) {
|
|
3992
|
+
const dollar = replacement.indexOf("$", index);
|
|
3993
|
+
if (dollar === -1) {
|
|
3994
|
+
result += replacement.slice(index);
|
|
3995
|
+
break;
|
|
3996
|
+
}
|
|
3997
|
+
result += replacement.slice(index, dollar);
|
|
3998
|
+
const char = replacement[dollar + 1];
|
|
3999
|
+
let expansion = "$";
|
|
4000
|
+
let consumed = 1;
|
|
4001
|
+
if (char === "$") consumed = 2;
|
|
4002
|
+
else if (char === "&") {
|
|
4003
|
+
expansion = matched;
|
|
4004
|
+
consumed = 2;
|
|
4005
|
+
} else if (char === "`") {
|
|
4006
|
+
expansion = str.slice(0, position);
|
|
4007
|
+
consumed = 2;
|
|
4008
|
+
} else if (char === "'") {
|
|
4009
|
+
expansion = str.slice(position + matched.length);
|
|
4010
|
+
consumed = 2;
|
|
4011
|
+
} else if (char === "<" && namedCaptures !== void 0) {
|
|
4012
|
+
const close = replacement.indexOf(">", dollar + 2);
|
|
4013
|
+
if (close !== -1) {
|
|
4014
|
+
expansion = namedCaptures[replacement.slice(dollar + 2, close)] ?? "";
|
|
4015
|
+
consumed = close + 1 - dollar;
|
|
4016
|
+
}
|
|
4017
|
+
} else if (char >= "0" && char <= "9") {
|
|
4018
|
+
const second = replacement[dollar + 2];
|
|
4019
|
+
const double = second >= "0" && second <= "9" ? Number(char + second) : NaN;
|
|
4020
|
+
const single = Number(char);
|
|
4021
|
+
if (double >= 1 && double <= captures.length) {
|
|
4022
|
+
expansion = captures[double - 1] ?? "";
|
|
4023
|
+
consumed = 3;
|
|
4024
|
+
} else if (single >= 1 && single <= captures.length) {
|
|
4025
|
+
expansion = captures[single - 1] ?? "";
|
|
4026
|
+
consumed = 2;
|
|
4027
|
+
}
|
|
4028
|
+
}
|
|
4029
|
+
result += expansion;
|
|
4030
|
+
index = dollar + consumed;
|
|
4031
|
+
}
|
|
4032
|
+
return result;
|
|
4033
|
+
}
|
|
3782
4034
|
var MagicString = class MagicString {
|
|
3783
4035
|
constructor(string, options = {}) {
|
|
3784
4036
|
const chunk = new Chunk(0, string.length, string);
|
|
@@ -3929,9 +4181,32 @@ var MagicString = class MagicString {
|
|
|
3929
4181
|
*/
|
|
3930
4182
|
generateDecodedMap(options) {
|
|
3931
4183
|
options = options || {};
|
|
4184
|
+
const mappings = new Mappings(options.hires);
|
|
4185
|
+
const names = this._generateMappings(mappings);
|
|
4186
|
+
return {
|
|
4187
|
+
...this._mapProperties(options, names),
|
|
4188
|
+
mappings: mappings.raw,
|
|
4189
|
+
rangeMappings: mappings.rawRangeMappings
|
|
4190
|
+
};
|
|
4191
|
+
}
|
|
4192
|
+
/**
|
|
4193
|
+
* Generates a version 3 sourcemap.
|
|
4194
|
+
*/
|
|
4195
|
+
generateMap(options) {
|
|
4196
|
+
options = options || {};
|
|
4197
|
+
const encoder = new MappingsEncoder();
|
|
4198
|
+
const mappings = new Mappings(options.hires, encoder);
|
|
4199
|
+
const names = this._generateMappings(mappings);
|
|
4200
|
+
return new SourceMap({
|
|
4201
|
+
...this._mapProperties(options, names),
|
|
4202
|
+
mappings: encoder.finish(mappings.rawSegments),
|
|
4203
|
+
rangeMappings: mappings.rawRangeMappings
|
|
4204
|
+
});
|
|
4205
|
+
}
|
|
4206
|
+
/** @internal */
|
|
4207
|
+
_generateMappings(mappings) {
|
|
3932
4208
|
const sourceIndex = 0;
|
|
3933
4209
|
const names = Object.keys(this.storedNames);
|
|
3934
|
-
const mappings = new Mappings(options.hires);
|
|
3935
4210
|
const locate = getLocator(this.original);
|
|
3936
4211
|
if (this.intro) mappings.advance(this.intro);
|
|
3937
4212
|
this.firstChunk.eachNext((chunk) => {
|
|
@@ -3942,21 +4217,18 @@ var MagicString = class MagicString {
|
|
|
3942
4217
|
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
3943
4218
|
});
|
|
3944
4219
|
if (this.outro) mappings.advance(this.outro);
|
|
4220
|
+
return names;
|
|
4221
|
+
}
|
|
4222
|
+
/** @internal */
|
|
4223
|
+
_mapProperties(options, names) {
|
|
3945
4224
|
return {
|
|
3946
4225
|
file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
|
|
3947
4226
|
sources: [options.source ? getRelativePath(options.file || "", options.source) : options.file || ""],
|
|
3948
4227
|
sourcesContent: options.includeContent ? [this.original] : void 0,
|
|
3949
4228
|
names,
|
|
3950
|
-
|
|
3951
|
-
x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
|
|
4229
|
+
x_google_ignoreList: this.ignoreList ? [0] : void 0
|
|
3952
4230
|
};
|
|
3953
4231
|
}
|
|
3954
|
-
/**
|
|
3955
|
-
* Generates a version 3 sourcemap.
|
|
3956
|
-
*/
|
|
3957
|
-
generateMap(options) {
|
|
3958
|
-
return new SourceMap(this.generateDecodedMap(options));
|
|
3959
|
-
}
|
|
3960
4232
|
/** @internal */
|
|
3961
4233
|
_ensureindentStr() {
|
|
3962
4234
|
if (this.indentStr === void 0) this.indentStr = guessIndent(this.original);
|
|
@@ -3988,17 +4260,18 @@ var MagicString = class MagicString {
|
|
|
3988
4260
|
for (let i = exclusion[0]; i < exclusion[1]; i += 1) isExcluded[i] = true;
|
|
3989
4261
|
});
|
|
3990
4262
|
let shouldIndentNextCharacter = options.indentStart !== false;
|
|
3991
|
-
const
|
|
3992
|
-
if (
|
|
3993
|
-
|
|
3994
|
-
|
|
4263
|
+
const indentPiece = (str) => {
|
|
4264
|
+
if (str === "") return str;
|
|
4265
|
+
const indented = str.replace(pattern, (match, offset) => offset > 0 || shouldIndentNextCharacter ? `${resolvedIndentStr}${match}` : match);
|
|
4266
|
+
shouldIndentNextCharacter = str[str.length - 1] === "\n";
|
|
4267
|
+
return indented;
|
|
3995
4268
|
};
|
|
3996
|
-
this.intro = this.intro
|
|
4269
|
+
this.intro = indentPiece(this.intro);
|
|
3997
4270
|
let charIndex = 0;
|
|
3998
4271
|
let chunk = this.firstChunk;
|
|
3999
4272
|
const indentAt = (index) => {
|
|
4000
4273
|
shouldIndentNextCharacter = false;
|
|
4001
|
-
if (index === chunk.start) chunk.
|
|
4274
|
+
if (index === chunk.start) chunk.appendRight(resolvedIndentStr);
|
|
4002
4275
|
else {
|
|
4003
4276
|
this._splitChunk(chunk, index);
|
|
4004
4277
|
chunk = chunk.next;
|
|
@@ -4007,11 +4280,9 @@ var MagicString = class MagicString {
|
|
|
4007
4280
|
};
|
|
4008
4281
|
while (chunk) {
|
|
4009
4282
|
const end = chunk.end;
|
|
4283
|
+
if (!isExcluded[chunk.start]) chunk.intro = indentPiece(chunk.intro);
|
|
4010
4284
|
if (chunk.edited) {
|
|
4011
|
-
if (!isExcluded[charIndex])
|
|
4012
|
-
chunk.content = chunk.content.replace(pattern, replacer);
|
|
4013
|
-
if (chunk.content.length) shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
|
|
4014
|
-
}
|
|
4285
|
+
if (!isExcluded[charIndex]) chunk.content = indentPiece(chunk.content);
|
|
4015
4286
|
} else if (options.exclude) {
|
|
4016
4287
|
charIndex = chunk.start;
|
|
4017
4288
|
while (charIndex < end) {
|
|
@@ -4041,10 +4312,11 @@ var MagicString = class MagicString {
|
|
|
4041
4312
|
charIndex += 1;
|
|
4042
4313
|
}
|
|
4043
4314
|
}
|
|
4315
|
+
if (!isExcluded[chunk.end - 1]) chunk.outro = indentPiece(chunk.outro);
|
|
4044
4316
|
charIndex = chunk.end;
|
|
4045
4317
|
chunk = chunk.next;
|
|
4046
4318
|
}
|
|
4047
|
-
this.outro = this.outro
|
|
4319
|
+
this.outro = indentPiece(this.outro);
|
|
4048
4320
|
return this;
|
|
4049
4321
|
}
|
|
4050
4322
|
/** @internal */
|
|
@@ -4069,8 +4341,14 @@ var MagicString = class MagicString {
|
|
|
4069
4341
|
}
|
|
4070
4342
|
/**
|
|
4071
4343
|
* Moves the characters from `start` and `end` to `index`.
|
|
4344
|
+
*
|
|
4345
|
+
* `affinity` controls where the range is anchored at `index`. With the
|
|
4346
|
+
* default `'right'`, it is inserted before the content that starts at `index`;
|
|
4347
|
+
* with `'left'`, it is inserted after the content that ends at `index`. The
|
|
4348
|
+
* two differ only when other content has already been moved to that boundary,
|
|
4349
|
+
* mirroring the `appendLeft`/`appendRight` distinction.
|
|
4072
4350
|
*/
|
|
4073
|
-
move(start, end, index) {
|
|
4351
|
+
move(start, end, index, affinity = "right") {
|
|
4074
4352
|
start = start + this.offset;
|
|
4075
4353
|
end = end + this.offset;
|
|
4076
4354
|
index = index + this.offset;
|
|
@@ -4090,9 +4368,27 @@ var MagicString = class MagicString {
|
|
|
4090
4368
|
}
|
|
4091
4369
|
const oldLeft = first.previous;
|
|
4092
4370
|
const oldRight = last.next;
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4371
|
+
let newLeft;
|
|
4372
|
+
let newRight;
|
|
4373
|
+
if (affinity === "left") {
|
|
4374
|
+
newLeft = this.byEnd.get(index) ?? null;
|
|
4375
|
+
if (!newLeft) {
|
|
4376
|
+
if (first === this.firstChunk) return this;
|
|
4377
|
+
newRight = this.firstChunk;
|
|
4378
|
+
} else {
|
|
4379
|
+
if (newLeft.next === first) return this;
|
|
4380
|
+
newRight = newLeft.next;
|
|
4381
|
+
}
|
|
4382
|
+
} else {
|
|
4383
|
+
newRight = this.byStart.get(index) ?? null;
|
|
4384
|
+
if (!newRight) {
|
|
4385
|
+
if (last === this.lastChunk) return this;
|
|
4386
|
+
newLeft = this.lastChunk;
|
|
4387
|
+
} else {
|
|
4388
|
+
if (newRight.previous === last) return this;
|
|
4389
|
+
newLeft = newRight.previous;
|
|
4390
|
+
}
|
|
4391
|
+
}
|
|
4096
4392
|
if (oldLeft) oldLeft.next = oldRight;
|
|
4097
4393
|
if (oldRight) oldRight.previous = oldLeft;
|
|
4098
4394
|
if (newLeft) newLeft.next = first;
|
|
@@ -4167,6 +4463,7 @@ var MagicString = class MagicString {
|
|
|
4167
4463
|
}
|
|
4168
4464
|
const first = this.byStart.get(start);
|
|
4169
4465
|
const last = this.byEnd.get(end);
|
|
4466
|
+
/* v8 ignore else -- unreachable: a valid start/end always yields a `first` chunk */
|
|
4170
4467
|
if (first) {
|
|
4171
4468
|
let chunk = first;
|
|
4172
4469
|
while (chunk !== last) {
|
|
@@ -4216,6 +4513,9 @@ var MagicString = class MagicString {
|
|
|
4216
4513
|
}
|
|
4217
4514
|
/**
|
|
4218
4515
|
* Removes the characters from `start` to `end` (of the original string, **not** the generated string).
|
|
4516
|
+
* Content appended or prepended at positions strictly inside the range is removed with it, while
|
|
4517
|
+
* content attached at `start` or `end` is preserved — use `s.overwrite(start, end, '')` to remove
|
|
4518
|
+
* the range including its edge inserts.
|
|
4219
4519
|
* Removing the same content twice, or making removals that partially overlap, will cause an error.
|
|
4220
4520
|
*/
|
|
4221
4521
|
remove(start, end) {
|
|
@@ -4232,9 +4532,9 @@ var MagicString = class MagicString {
|
|
|
4232
4532
|
this._split(end);
|
|
4233
4533
|
let chunk = this.byStart.get(start);
|
|
4234
4534
|
while (chunk) {
|
|
4235
|
-
chunk.intro = "";
|
|
4236
|
-
chunk.outro = "";
|
|
4237
|
-
chunk.edit("");
|
|
4535
|
+
if (chunk.start > start) chunk.intro = "";
|
|
4536
|
+
if (chunk.end < end) chunk.outro = "";
|
|
4537
|
+
chunk.edit("", false, true);
|
|
4238
4538
|
chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
|
|
4239
4539
|
}
|
|
4240
4540
|
return this;
|
|
@@ -4314,12 +4614,13 @@ var MagicString = class MagicString {
|
|
|
4314
4614
|
let result = "";
|
|
4315
4615
|
let chunk = this.firstChunk;
|
|
4316
4616
|
while (chunk && (chunk.start > start || chunk.end <= start)) {
|
|
4317
|
-
if (chunk.start < end && chunk.end >= end) return result;
|
|
4617
|
+
if (chunk.start < end && chunk.end >= end || end === 0 && chunk.start === 0) return result;
|
|
4318
4618
|
chunk = chunk.next;
|
|
4319
4619
|
}
|
|
4320
4620
|
if (chunk && chunk.edited && chunk.start !== start) throw new MagicStringError(`cannot use edited character ${start} as slice start anchor`);
|
|
4321
4621
|
const startChunk = chunk;
|
|
4322
4622
|
while (chunk) {
|
|
4623
|
+
if (end === 0 && chunk.start === 0) break;
|
|
4323
4624
|
if (chunk.intro && (startChunk !== chunk || chunk.start === start)) result += chunk.intro;
|
|
4324
4625
|
const containsEnd = chunk.start < end && chunk.end >= end;
|
|
4325
4626
|
if (containsEnd && chunk.edited && chunk.end !== end) throw new MagicStringError(`cannot use edited character ${end} as slice end anchor`);
|
|
@@ -4384,11 +4685,13 @@ var MagicString = class MagicString {
|
|
|
4384
4685
|
* Returns true if the resulting source is empty (disregarding white space).
|
|
4385
4686
|
*/
|
|
4386
4687
|
isEmpty() {
|
|
4688
|
+
if (this.intro.length && this.intro.trim()) return false;
|
|
4387
4689
|
let chunk = this.firstChunk;
|
|
4388
4690
|
while (chunk) {
|
|
4389
4691
|
if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim()) return false;
|
|
4390
4692
|
chunk = chunk.next;
|
|
4391
4693
|
}
|
|
4694
|
+
if (this.outro.length && this.outro.trim()) return false;
|
|
4392
4695
|
return true;
|
|
4393
4696
|
}
|
|
4394
4697
|
length() {
|
|
@@ -4430,7 +4733,8 @@ var MagicString = class MagicString {
|
|
|
4430
4733
|
if (aborted) return true;
|
|
4431
4734
|
chunk = chunk.previous;
|
|
4432
4735
|
} while (chunk);
|
|
4433
|
-
|
|
4736
|
+
this.intro = this.intro.replace(rx, "");
|
|
4737
|
+
return this.intro.length > 0;
|
|
4434
4738
|
}
|
|
4435
4739
|
/**
|
|
4436
4740
|
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end.
|
|
@@ -4457,7 +4761,8 @@ var MagicString = class MagicString {
|
|
|
4457
4761
|
if (aborted) return true;
|
|
4458
4762
|
chunk = chunk.next;
|
|
4459
4763
|
} while (chunk);
|
|
4460
|
-
|
|
4764
|
+
this.outro = this.outro.replace(rx, "");
|
|
4765
|
+
return this.outro.length > 0;
|
|
4461
4766
|
}
|
|
4462
4767
|
/**
|
|
4463
4768
|
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start.
|
|
@@ -4484,41 +4789,66 @@ var MagicString = class MagicString {
|
|
|
4484
4789
|
}
|
|
4485
4790
|
return outputIndex !== this.original.length;
|
|
4486
4791
|
}
|
|
4792
|
+
/**
|
|
4793
|
+
* Whether the original range [start, end) has had any of its characters
|
|
4794
|
+
* removed. `replace`/`replaceAll` search `original`, so a match can land on
|
|
4795
|
+
* text that is no longer in the output - overwriting it would resurrect the
|
|
4796
|
+
* removed characters, so such matches are skipped instead.
|
|
4797
|
+
*
|
|
4798
|
+
* @internal
|
|
4799
|
+
*/
|
|
4800
|
+
_hasRemovedContent(start, end) {
|
|
4801
|
+
let chunk = this.firstChunk;
|
|
4802
|
+
while (chunk) {
|
|
4803
|
+
if (chunk.content === "" && chunk.start < end && chunk.end > start) return true;
|
|
4804
|
+
chunk = chunk.next;
|
|
4805
|
+
}
|
|
4806
|
+
return false;
|
|
4807
|
+
}
|
|
4487
4808
|
/** @internal */
|
|
4488
4809
|
_replaceRegexp(searchValue, replacement) {
|
|
4489
4810
|
function getReplacement(match, str) {
|
|
4490
|
-
if (typeof replacement === "string") return replacement.
|
|
4491
|
-
|
|
4492
|
-
if (i === "&") return match[0];
|
|
4493
|
-
if (+i < match.length) return match[+i];
|
|
4494
|
-
return `$${i}`;
|
|
4495
|
-
});
|
|
4496
|
-
else return replacement(match[0], ...match.slice(1), match.index, str, match.groups);
|
|
4811
|
+
if (typeof replacement === "string") return expandReplacement(replacement, match[0], match.index, str, match.slice(1), match.groups);
|
|
4812
|
+
else return match.groups === void 0 ? replacement(match[0], ...match.slice(1), match.index, str) : replacement(match[0], ...match.slice(1), match.index, str, match.groups);
|
|
4497
4813
|
}
|
|
4498
4814
|
const replaceMatch = (match) => {
|
|
4499
|
-
|
|
4815
|
+
/* v8 ignore next 2 -- `match.index` is always defined for matches from `matchAll` */
|
|
4816
|
+
if (match.index == null) return false;
|
|
4817
|
+
if (this._hasRemovedContent(match.index, match.index + match[0].length)) return false;
|
|
4500
4818
|
const replacement = getReplacement(match, this.original);
|
|
4501
|
-
if (replacement === match[0]) return;
|
|
4819
|
+
if (replacement === match[0]) return true;
|
|
4502
4820
|
if (match[0].length === 0) this.appendRight(match.index, replacement);
|
|
4503
4821
|
else this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
4822
|
+
return true;
|
|
4504
4823
|
};
|
|
4505
4824
|
if (searchValue.global) {
|
|
4506
4825
|
searchValue.lastIndex = 0;
|
|
4507
4826
|
for (const match of this.original.matchAll(searchValue)) replaceMatch(match);
|
|
4508
4827
|
} else {
|
|
4509
4828
|
const match = this.original.match(searchValue);
|
|
4510
|
-
if (match
|
|
4829
|
+
if (match && !replaceMatch(match)) {
|
|
4830
|
+
const global = new RegExp(searchValue.source, `${searchValue.flags}g`);
|
|
4831
|
+
for (const next of this.original.matchAll(global)) if (replaceMatch(next)) break;
|
|
4832
|
+
}
|
|
4511
4833
|
}
|
|
4512
4834
|
return this;
|
|
4513
4835
|
}
|
|
4514
4836
|
/** @internal */
|
|
4515
4837
|
_replaceString(string, replacement) {
|
|
4516
4838
|
const { original } = this;
|
|
4517
|
-
|
|
4518
|
-
|
|
4839
|
+
let index = original.indexOf(string);
|
|
4840
|
+
while (index !== -1) {
|
|
4841
|
+
if (this._hasRemovedContent(index, index + string.length)) {
|
|
4842
|
+
index = original.indexOf(string, index + string.length);
|
|
4843
|
+
continue;
|
|
4844
|
+
}
|
|
4519
4845
|
if (typeof replacement === "function") replacement = replacement(string, index, original);
|
|
4520
|
-
|
|
4521
|
-
|
|
4846
|
+
else replacement = expandReplacement(replacement, string, index, original, [], void 0);
|
|
4847
|
+
if (string !== replacement) {
|
|
4848
|
+
if (string.length === 0) this.appendRight(index, replacement);
|
|
4849
|
+
else this.overwrite(index, index + string.length, replacement);
|
|
4850
|
+
}
|
|
4851
|
+
break;
|
|
4522
4852
|
}
|
|
4523
4853
|
return this;
|
|
4524
4854
|
}
|
|
@@ -4535,14 +4865,15 @@ var MagicString = class MagicString {
|
|
|
4535
4865
|
const stringLength = string.length;
|
|
4536
4866
|
if (stringLength === 0) {
|
|
4537
4867
|
for (let index = 0; index <= original.length; index += 1) {
|
|
4538
|
-
const _replacement = typeof replacement === "function" ? replacement("", index, original) : replacement;
|
|
4868
|
+
const _replacement = typeof replacement === "function" ? replacement("", index, original) : expandReplacement(replacement, "", index, original, [], void 0);
|
|
4539
4869
|
if (_replacement !== "") this.appendRight(index, _replacement);
|
|
4540
4870
|
}
|
|
4541
4871
|
return this;
|
|
4542
4872
|
}
|
|
4543
4873
|
for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
|
|
4874
|
+
if (this._hasRemovedContent(index, index + stringLength)) continue;
|
|
4544
4875
|
const previous = original.slice(index, index + stringLength);
|
|
4545
|
-
const _replacement = typeof replacement === "function" ? replacement(previous, index, original) : replacement;
|
|
4876
|
+
const _replacement = typeof replacement === "function" ? replacement(previous, index, original) : expandReplacement(replacement, previous, index, original, [], void 0);
|
|
4546
4877
|
if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
|
|
4547
4878
|
}
|
|
4548
4879
|
return this;
|
|
@@ -5755,7 +6086,7 @@ function perEnvironmentState(initial) {
|
|
|
5755
6086
|
};
|
|
5756
6087
|
}
|
|
5757
6088
|
//#endregion
|
|
5758
|
-
//#region ../../node_modules/.pnpm/artichokie@0.4.
|
|
6089
|
+
//#region ../../node_modules/.pnpm/artichokie@0.4.5/node_modules/artichokie/dist/index.js
|
|
5759
6090
|
const AsyncFunction = async function() {}.constructor;
|
|
5760
6091
|
const codeToDataUrl = (code) => `data:application/javascript,${encodeURIComponent(code + "\n//# sourceURL=[worker-eval(artichokie)]")}`;
|
|
5761
6092
|
const viteSsrDynamicImport = "__vite_ssr_dynamic_import__";
|
|
@@ -5790,7 +6121,14 @@ var Worker$1 = class {
|
|
|
5790
6121
|
return new Promise((resolve, reject) => {
|
|
5791
6122
|
worker.currentResolve = resolve;
|
|
5792
6123
|
worker.currentReject = reject;
|
|
5793
|
-
|
|
6124
|
+
try {
|
|
6125
|
+
worker.postMessage({ args });
|
|
6126
|
+
} catch (err) {
|
|
6127
|
+
worker.currentResolve = null;
|
|
6128
|
+
worker.currentReject = null;
|
|
6129
|
+
this._assignDoneWorker(worker);
|
|
6130
|
+
throw err;
|
|
6131
|
+
}
|
|
5794
6132
|
});
|
|
5795
6133
|
}
|
|
5796
6134
|
stop() {
|
|
@@ -5833,18 +6171,23 @@ var Worker$1 = class {
|
|
|
5833
6171
|
}
|
|
5834
6172
|
this._assignDoneWorker(worker);
|
|
5835
6173
|
});
|
|
5836
|
-
|
|
6174
|
+
const rejectWorker = (err) => {
|
|
5837
6175
|
worker.currentReject?.(err);
|
|
5838
6176
|
worker.currentReject = null;
|
|
5839
6177
|
parentFunctionResponder.close();
|
|
5840
|
-
}
|
|
6178
|
+
};
|
|
6179
|
+
worker.on("error", rejectWorker);
|
|
5841
6180
|
worker.on("exit", (code) => {
|
|
5842
6181
|
const i = this._pool.indexOf(worker);
|
|
5843
6182
|
if (i > -1) this._pool.splice(i, 1);
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
6183
|
+
const idleIndex = this._idlePool.indexOf(worker);
|
|
6184
|
+
if (idleIndex > -1) this._idlePool.splice(idleIndex, 1);
|
|
6185
|
+
if (code !== 0) {
|
|
6186
|
+
rejectWorker(/* @__PURE__ */ new Error(`Worker stopped with non-0 exit code ${code}`));
|
|
6187
|
+
if (this._queue.length) {
|
|
6188
|
+
const [resolve, reject] = this._queue.shift();
|
|
6189
|
+
this._getAvailableWorker().then(resolve, reject);
|
|
6190
|
+
}
|
|
5848
6191
|
}
|
|
5849
6192
|
});
|
|
5850
6193
|
this._pool.push(worker);
|
|
@@ -6441,7 +6784,7 @@ var require_src$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6441
6784
|
};
|
|
6442
6785
|
}));
|
|
6443
6786
|
//#endregion
|
|
6444
|
-
//#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.28_tsx@4.23.
|
|
6787
|
+
//#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.0/node_modules/postcss-load-config/src/req.js
|
|
6445
6788
|
var require_req = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6446
6789
|
const { createRequire: createRequire$1 } = __require("node:module");
|
|
6447
6790
|
const { fileURLToPath: fileURLToPath$1, pathToFileURL: pathToFileURL$1 } = __require("node:url");
|
|
@@ -6483,7 +6826,7 @@ var require_req = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6483
6826
|
module.exports = req;
|
|
6484
6827
|
}));
|
|
6485
6828
|
//#endregion
|
|
6486
|
-
//#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.28_tsx@4.23.
|
|
6829
|
+
//#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.0/node_modules/postcss-load-config/src/options.js
|
|
6487
6830
|
var require_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6488
6831
|
const req = require_req();
|
|
6489
6832
|
/**
|
|
@@ -6517,7 +6860,7 @@ var require_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6517
6860
|
module.exports = options;
|
|
6518
6861
|
}));
|
|
6519
6862
|
//#endregion
|
|
6520
|
-
//#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.28_tsx@4.23.
|
|
6863
|
+
//#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.0/node_modules/postcss-load-config/src/plugins.js
|
|
6521
6864
|
var require_plugins = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6522
6865
|
const req = require_req();
|
|
6523
6866
|
/**
|
|
@@ -6571,7 +6914,7 @@ var require_plugins = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6571
6914
|
module.exports = plugins;
|
|
6572
6915
|
}));
|
|
6573
6916
|
//#endregion
|
|
6574
|
-
//#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.28_tsx@4.23.
|
|
6917
|
+
//#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.0/node_modules/postcss-load-config/src/index.js
|
|
6575
6918
|
var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6576
6919
|
const { resolve: resolve$3 } = __require("node:path");
|
|
6577
6920
|
const config = require_src$1();
|
|
@@ -16414,6 +16757,26 @@ var NoopWatcher = class extends EventEmitter {
|
|
|
16414
16757
|
function createNoopWatcher(options) {
|
|
16415
16758
|
return new NoopWatcher(options);
|
|
16416
16759
|
}
|
|
16760
|
+
/**
|
|
16761
|
+
* Chokidar's `add()` reopens a closed watcher. It may be called after shutdown
|
|
16762
|
+
* starts from an in-flight plugin hook or directly through the exposed watcher.
|
|
16763
|
+
* This wrapper makes `close()` final so those calls cannot create new file
|
|
16764
|
+
* system handles.
|
|
16765
|
+
*/
|
|
16766
|
+
function makeWatcherCloseFinal(watcher) {
|
|
16767
|
+
let closed = false;
|
|
16768
|
+
const add = watcher.add;
|
|
16769
|
+
watcher.add = function(...args) {
|
|
16770
|
+
if (closed) return this;
|
|
16771
|
+
return add.apply(this, args);
|
|
16772
|
+
};
|
|
16773
|
+
const close = watcher.close;
|
|
16774
|
+
watcher.close = function(...args) {
|
|
16775
|
+
closed = true;
|
|
16776
|
+
return close.apply(this, args);
|
|
16777
|
+
};
|
|
16778
|
+
return watcher;
|
|
16779
|
+
}
|
|
16417
16780
|
//#endregion
|
|
16418
16781
|
//#region src/node/server/middlewares/base.ts
|
|
16419
16782
|
function baseMiddleware(rawBase, middlewareMode) {
|
|
@@ -17065,6 +17428,7 @@ async function computeSourceRoute(map, file) {
|
|
|
17065
17428
|
return sourceRoot;
|
|
17066
17429
|
}
|
|
17067
17430
|
async function injectSourcesContent(map, file, logger) {
|
|
17431
|
+
if (map.sourceRoot && isExternalUrl(map.sourceRoot)) return;
|
|
17068
17432
|
let sourceRootPromise;
|
|
17069
17433
|
const packageRoot = getNodeModulesPackageRoot(file);
|
|
17070
17434
|
const missingSources = [];
|
|
@@ -17072,7 +17436,7 @@ async function injectSourcesContent(map, file, logger) {
|
|
|
17072
17436
|
const sourcesContentPromises = [];
|
|
17073
17437
|
for (let index = 0; index < map.sources.length; index++) {
|
|
17074
17438
|
const sourcePath = map.sources[index];
|
|
17075
|
-
if (sourcesContent[index] == null && sourcePath && !virtualSourceRE.test(sourcePath)) sourcesContentPromises.push((async () => {
|
|
17439
|
+
if (sourcesContent[index] == null && sourcePath && !isExternalUrl(sourcePath) && !virtualSourceRE.test(sourcePath)) sourcesContentPromises.push((async () => {
|
|
17076
17440
|
sourceRootPromise ??= computeSourceRoute(map, file);
|
|
17077
17441
|
const sourceRoot = await sourceRootPromise;
|
|
17078
17442
|
let resolvedSourcePath = cleanUrl(decodeURI(sourcePath));
|
|
@@ -24285,12 +24649,12 @@ async function _createServer(inlineConfig = {}, options) {
|
|
|
24285
24649
|
const publicFiles = await initPublicFilesPromise;
|
|
24286
24650
|
const { publicDir } = config;
|
|
24287
24651
|
if (httpServer) setClientErrorHandler(httpServer, config.logger);
|
|
24288
|
-
const watcher = serverConfig.watch !== null ? import_chokidar.watch([
|
|
24652
|
+
const watcher = serverConfig.watch !== null ? makeWatcherCloseFinal(import_chokidar.watch([
|
|
24289
24653
|
...config.experimental.bundledDev ? [] : [root],
|
|
24290
24654
|
...config.configFileDependencies,
|
|
24291
24655
|
...getEnvFilesForMode(config.mode, config.envDir),
|
|
24292
24656
|
...publicDir && publicFiles ? [publicDir] : []
|
|
24293
|
-
], resolvedWatchOptions) : createNoopWatcher(resolvedWatchOptions);
|
|
24657
|
+
], resolvedWatchOptions)) : createNoopWatcher(resolvedWatchOptions);
|
|
24294
24658
|
const environments = {};
|
|
24295
24659
|
await Promise.all(Object.entries(config.environments).map(async ([name, environmentOptions]) => {
|
|
24296
24660
|
const environment = await environmentOptions.dev.createEnvironment(name, config, { ws });
|
|
@@ -25316,6 +25680,7 @@ function optimizedDepsPlugin() {
|
|
|
25316
25680
|
if (info) {
|
|
25317
25681
|
if (browserHash && info.browserHash !== browserHash && !environment.config.optimizeDeps.ignoreOutdatedRequests) throwOutdatedRequest(id);
|
|
25318
25682
|
try {
|
|
25683
|
+
if (info.processing && depsOptimizer.initState === "idle") debug$7?.(`transforming ${import_picocolors.default.cyan(file)} is waiting for the dependency optimizer to initialize`);
|
|
25319
25684
|
await info.processing;
|
|
25320
25685
|
} catch {
|
|
25321
25686
|
throwProcessingError(id);
|
|
@@ -25375,7 +25740,7 @@ function preAliasPlugin(config) {
|
|
|
25375
25740
|
const ssr = environment.config.consumer === "server";
|
|
25376
25741
|
const depsOptimizer = environment.depsOptimizer;
|
|
25377
25742
|
if (importer && depsOptimizer && bareImportRE.test(id) && !options.scan && id !== "@vite/client" && id !== "@vite/env") {
|
|
25378
|
-
if (findPatterns.
|
|
25743
|
+
if (findPatterns.some((pattern) => matches(pattern, id))) {
|
|
25379
25744
|
const optimizedId = await tryOptimizedResolve(depsOptimizer, id, importer, config.resolve.preserveSymlinks, config.packageCache);
|
|
25380
25745
|
if (optimizedId) return optimizedId;
|
|
25381
25746
|
if (depsOptimizer.options.noDiscovery) return;
|
|
@@ -27419,7 +27784,7 @@ function devToScanEnvironment(environment) {
|
|
|
27419
27784
|
}
|
|
27420
27785
|
const debug$5 = createDebugger("vite:deps");
|
|
27421
27786
|
const htmlTypesRE = /\.(?:html|vue|svelte|astro|imba)$/;
|
|
27422
|
-
const importsRE = /(?<!\/\/.*)(?<=^|;|\*\/)\s*import(?!\s+type)(?:[\w*{}\n\r\t, ]+from)?\s*("[^"]+"|'[^']+')\s*(?=$|;|\/\/|\/\*)/gm;
|
|
27787
|
+
const importsRE = /(?<!\/\/.*)(?<=^|;|\*\/)\s*import(?!\s+type\b)(?:[\w*{}\n\r\t, ]+from)?\s*("[^"]+"|'[^']+')\s*(?=$|;|\/\/|\/\*)/gm;
|
|
27423
27788
|
function scanImports(environment) {
|
|
27424
27789
|
const start = performance$1.now();
|
|
27425
27790
|
const { config } = environment;
|
|
@@ -33963,10 +34328,8 @@ function resolveRolldownOptions(environment, chunkMetadataMap) {
|
|
|
33963
34328
|
...options.rolldownOptions.resolve,
|
|
33964
34329
|
tsconfigFilename: void 0
|
|
33965
34330
|
} : options.rolldownOptions.resolve,
|
|
33966
|
-
output: options.rolldownOptions.output,
|
|
33967
34331
|
input,
|
|
33968
34332
|
plugins,
|
|
33969
|
-
external: options.rolldownOptions.external,
|
|
33970
34333
|
onLog(level, log) {
|
|
33971
34334
|
onRollupLog(level, log, environment);
|
|
33972
34335
|
},
|
|
@@ -34010,19 +34373,19 @@ function resolveRolldownOptions(environment, chunkMetadataMap) {
|
|
|
34010
34373
|
chunkFileNames: libOptions ? `[name]-[hash].${jsExt}` : path.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`),
|
|
34011
34374
|
assetFileNames: libOptions ? `[name].[ext]` : path.posix.join(options.assetsDir, `[name]-[hash].[ext]`),
|
|
34012
34375
|
codeSplitting: output.codeSplitting ?? (output.format === "umd" || output.format === "iife" || isSsrTargetWebworkerEnvironment && (typeof input === "string" || Object.keys(input).length === 1) ? false : void 0),
|
|
34013
|
-
comments: typeof output.comments === "boolean" ? output.comments : {
|
|
34014
|
-
annotation: !options.minify || libOptions && (format === "es" || format === "esm"),
|
|
34015
|
-
jsdoc: !options.minify,
|
|
34016
|
-
legal: !options.minify,
|
|
34017
|
-
...output.comments
|
|
34018
|
-
},
|
|
34019
34376
|
minify: options.minify === "oxc" ? libOptions && (format === "es" || format === "esm") ? {
|
|
34020
34377
|
compress: true,
|
|
34021
34378
|
mangle: true,
|
|
34022
34379
|
codegen: false
|
|
34023
34380
|
} : true : options.minify === false ? "dce-only" : false,
|
|
34024
34381
|
topLevelVar: true,
|
|
34025
|
-
...output
|
|
34382
|
+
...output,
|
|
34383
|
+
comments: typeof output.comments === "boolean" ? output.comments : {
|
|
34384
|
+
annotation: !options.minify || libOptions && (format === "es" || format === "esm"),
|
|
34385
|
+
jsdoc: !options.minify,
|
|
34386
|
+
legal: !options.minify,
|
|
34387
|
+
...output.comments
|
|
34388
|
+
}
|
|
34026
34389
|
};
|
|
34027
34390
|
};
|
|
34028
34391
|
const outputs = resolveBuildOutputs(options.rolldownOptions.output, libOptions, logger);
|
|
@@ -35120,6 +35483,7 @@ function createDepsOptimizer(environment) {
|
|
|
35120
35483
|
let metadata = initDepsOptimizerMetadata(environment, sessionTimestamp);
|
|
35121
35484
|
const depsOptimizer = {
|
|
35122
35485
|
init,
|
|
35486
|
+
initState: "idle",
|
|
35123
35487
|
metadata,
|
|
35124
35488
|
registerMissingImport,
|
|
35125
35489
|
run: () => debouncedProcessing(0),
|
|
@@ -35160,16 +35524,19 @@ function createDepsOptimizer(environment) {
|
|
|
35160
35524
|
let discover;
|
|
35161
35525
|
async function close() {
|
|
35162
35526
|
closed = true;
|
|
35527
|
+
if (debounceProcessingHandle) clearTimeout(debounceProcessingHandle);
|
|
35528
|
+
debounceProcessingHandle = void 0;
|
|
35163
35529
|
await Promise.allSettled([
|
|
35164
35530
|
discover?.cancel(),
|
|
35165
35531
|
depsOptimizer.scanProcessing,
|
|
35166
35532
|
optimizationResult?.cancel()
|
|
35167
35533
|
]);
|
|
35534
|
+
depOptimizationProcessing.resolve();
|
|
35535
|
+
resolveEnqueuedProcessingPromises();
|
|
35168
35536
|
}
|
|
35169
|
-
let initState = "idle";
|
|
35170
35537
|
async function init() {
|
|
35171
|
-
if (initState !== "idle") return;
|
|
35172
|
-
initState = "initializing";
|
|
35538
|
+
if (depsOptimizer.initState !== "idle") return;
|
|
35539
|
+
depsOptimizer.initState = "initializing";
|
|
35173
35540
|
const cachedMetadata = await loadCachedDepOptimizationMetadata(environment);
|
|
35174
35541
|
firstRunCalled = !!cachedMetadata;
|
|
35175
35542
|
metadata = depsOptimizer.metadata = cachedMetadata || initDepsOptimizerMetadata(environment, sessionTimestamp);
|
|
@@ -35226,7 +35593,7 @@ function createDepsOptimizer(environment) {
|
|
|
35226
35593
|
})();
|
|
35227
35594
|
});
|
|
35228
35595
|
}
|
|
35229
|
-
initState = "initialized";
|
|
35596
|
+
depsOptimizer.initState = "initialized";
|
|
35230
35597
|
}
|
|
35231
35598
|
function startNextDiscoveredBatch() {
|
|
35232
35599
|
newDepsDiscovered = false;
|
|
@@ -35250,8 +35617,6 @@ function createDepsOptimizer(environment) {
|
|
|
35250
35617
|
if (debounceProcessingHandle) clearTimeout(debounceProcessingHandle);
|
|
35251
35618
|
if (closed) {
|
|
35252
35619
|
currentlyProcessing = false;
|
|
35253
|
-
depOptimizationProcessing.resolve();
|
|
35254
|
-
resolveEnqueuedProcessingPromises();
|
|
35255
35620
|
return;
|
|
35256
35621
|
}
|
|
35257
35622
|
currentlyProcessing = true;
|
|
@@ -35268,7 +35633,6 @@ function createDepsOptimizer(environment) {
|
|
|
35268
35633
|
if (closed) {
|
|
35269
35634
|
currentlyProcessing = false;
|
|
35270
35635
|
processingResult.cancel();
|
|
35271
|
-
resolveEnqueuedProcessingPromises();
|
|
35272
35636
|
return;
|
|
35273
35637
|
}
|
|
35274
35638
|
const newData = processingResult.metadata;
|
|
@@ -35363,7 +35727,7 @@ function createDepsOptimizer(environment) {
|
|
|
35363
35727
|
let missing = metadata.discovered[id];
|
|
35364
35728
|
if (missing) return missing;
|
|
35365
35729
|
missing = addMissingDep(id, resolved);
|
|
35366
|
-
if (initState === "initialized" && !waitingForCrawlEnd) debouncedProcessing();
|
|
35730
|
+
if (depsOptimizer.initState === "initialized" && !waitingForCrawlEnd) debouncedProcessing();
|
|
35367
35731
|
return missing;
|
|
35368
35732
|
}
|
|
35369
35733
|
function addMissingDep(id, resolved) {
|
|
@@ -35440,6 +35804,7 @@ function createDepsOptimizer(environment) {
|
|
|
35440
35804
|
function createExplicitDepsOptimizer(environment) {
|
|
35441
35805
|
const depsOptimizer = {
|
|
35442
35806
|
metadata: initDepsOptimizerMetadata(environment),
|
|
35807
|
+
initState: "idle",
|
|
35443
35808
|
isOptimizedDepFile: createIsOptimizedDepFile(environment),
|
|
35444
35809
|
isOptimizedDepUrl: createIsOptimizedDepUrl(environment),
|
|
35445
35810
|
getOptimizedDepId: (depInfo) => `${depInfo.file}?v=${depInfo.browserHash}`,
|
|
@@ -35451,11 +35816,11 @@ function createExplicitDepsOptimizer(environment) {
|
|
|
35451
35816
|
close: async () => {},
|
|
35452
35817
|
options: environment.config.optimizeDeps
|
|
35453
35818
|
};
|
|
35454
|
-
let inited = false;
|
|
35455
35819
|
async function init() {
|
|
35456
|
-
if (
|
|
35457
|
-
|
|
35820
|
+
if (depsOptimizer.initState !== "idle") return;
|
|
35821
|
+
depsOptimizer.initState = "initializing";
|
|
35458
35822
|
depsOptimizer.metadata = await optimizeExplicitEnvironmentDeps(environment);
|
|
35823
|
+
depsOptimizer.initState = "initialized";
|
|
35459
35824
|
}
|
|
35460
35825
|
return depsOptimizer;
|
|
35461
35826
|
}
|