vite 8.3.0-beta.1 → 8.3.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.
- 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 +616 -228
- package/dist/node/index.d.ts +4 -3
- package/dist/node/module-runner.js +10 -8
- package/package.json +10 -10
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
|
-
|
|
865
|
-
|
|
866
|
-
return
|
|
863
|
+
return value;
|
|
864
|
+
}
|
|
865
|
+
function decodeSign(num) {
|
|
866
|
+
return num & 1 ? -2147483648 | -(num >>> 1) : num >>> 1;
|
|
867
867
|
}
|
|
868
|
-
function encodeInteger(builder, num
|
|
869
|
-
let delta = num - relative;
|
|
870
|
-
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
|
|
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();
|
|
@@ -2057,8 +2077,9 @@ function isNodeBuiltin(id) {
|
|
|
2057
2077
|
if (id.startsWith(NODE_BUILTIN_NAMESPACE)) return true;
|
|
2058
2078
|
return nodeBuiltins.includes(id);
|
|
2059
2079
|
}
|
|
2080
|
+
const inNodeModulesRE = /(?:^|[\\/])node_modules(?:[\\/]|$)/;
|
|
2060
2081
|
function isInNodeModules(id) {
|
|
2061
|
-
return
|
|
2082
|
+
return inNodeModulesRE.test(id);
|
|
2062
2083
|
}
|
|
2063
2084
|
function moduleListContains(moduleList, id) {
|
|
2064
2085
|
return moduleList?.some((m) => m === id || id.startsWith(withTrailingSlash(m)));
|
|
@@ -2253,6 +2274,13 @@ function isFilePathFormatExplicit(filePath, packageCache) {
|
|
|
2253
2274
|
}
|
|
2254
2275
|
const splitRE = /\r?\n/g;
|
|
2255
2276
|
const range = 2;
|
|
2277
|
+
/**
|
|
2278
|
+
* `splitRE` treats both LF and CRLF as a line terminator, so the terminator
|
|
2279
|
+
* following a line is 2 characters long when the source uses CRLF.
|
|
2280
|
+
*/
|
|
2281
|
+
function lineTerminatorLengthAt(source, index) {
|
|
2282
|
+
return source[index] === "\r" ? 2 : 1;
|
|
2283
|
+
}
|
|
2256
2284
|
function pad(source, n = 2) {
|
|
2257
2285
|
return source.split(splitRE).map((l) => ` `.repeat(n) + l).join(`\n`);
|
|
2258
2286
|
}
|
|
@@ -2261,7 +2289,10 @@ function posToNumber(source, pos) {
|
|
|
2261
2289
|
const lines = source.split(splitRE);
|
|
2262
2290
|
const { line, column } = pos;
|
|
2263
2291
|
let start = 0;
|
|
2264
|
-
for (let i = 0; i < line - 1 && i < lines.length; i++)
|
|
2292
|
+
for (let i = 0; i < line - 1 && i < lines.length; i++) {
|
|
2293
|
+
start += lines[i].length;
|
|
2294
|
+
start += lineTerminatorLengthAt(source, start);
|
|
2295
|
+
}
|
|
2265
2296
|
return start + column;
|
|
2266
2297
|
}
|
|
2267
2298
|
function numberToPos(source, offset) {
|
|
@@ -2319,12 +2350,12 @@ function generateCodeFrame(source, start = 0, end) {
|
|
|
2319
2350
|
const underline = "^".repeat(Math.min(length, MAX_DISPLAY_LEN));
|
|
2320
2351
|
res.push(`${" ".repeat(lineNumberWidth)}| ` + underline);
|
|
2321
2352
|
}
|
|
2322
|
-
count +=
|
|
2353
|
+
count += lineTerminatorLengthAt(source, count) + lineLength;
|
|
2323
2354
|
}
|
|
2324
2355
|
}
|
|
2325
2356
|
break;
|
|
2326
2357
|
}
|
|
2327
|
-
count
|
|
2358
|
+
count += lineTerminatorLengthAt(source, count);
|
|
2328
2359
|
}
|
|
2329
2360
|
return res.join("\n");
|
|
2330
2361
|
}
|
|
@@ -2796,7 +2827,10 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
|
|
|
2796
2827
|
const merged = { ...defaults };
|
|
2797
2828
|
if (rollupOptionsRootPaths.has(rootPath)) setupRollupOptionCompat(merged, rootPath);
|
|
2798
2829
|
if (rootPath === "server") setupHmrWsOptionCompat(merged);
|
|
2799
|
-
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
|
+
}
|
|
2800
2834
|
for (const key in overrides) {
|
|
2801
2835
|
const value = overrides[key];
|
|
2802
2836
|
if (value == null) continue;
|
|
@@ -3426,7 +3460,7 @@ function alias$1(options = {}) {
|
|
|
3426
3460
|
};
|
|
3427
3461
|
}
|
|
3428
3462
|
//#endregion
|
|
3429
|
-
//#region ../../node_modules/.pnpm/magic-string@1.
|
|
3463
|
+
//#region ../../node_modules/.pnpm/magic-string@1.4.1/node_modules/magic-string/dist/index.mjs
|
|
3430
3464
|
var BitSet = class BitSet {
|
|
3431
3465
|
constructor(arg) {
|
|
3432
3466
|
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
@@ -3537,8 +3571,10 @@ var Chunk = class Chunk {
|
|
|
3537
3571
|
if (this.outro.length) return true;
|
|
3538
3572
|
const trimmed = this.content.replace(rx, "");
|
|
3539
3573
|
if (trimmed.length) {
|
|
3540
|
-
if (trimmed !== this.content)
|
|
3541
|
-
|
|
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
|
+
}
|
|
3542
3578
|
return true;
|
|
3543
3579
|
} else {
|
|
3544
3580
|
this.edit("", void 0, true);
|
|
@@ -3551,10 +3587,12 @@ var Chunk = class Chunk {
|
|
|
3551
3587
|
if (this.intro.length) return true;
|
|
3552
3588
|
const trimmed = this.content.replace(rx, "");
|
|
3553
3589
|
if (trimmed.length) {
|
|
3554
|
-
if (trimmed !== this.content)
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
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
|
+
}
|
|
3558
3596
|
}
|
|
3559
3597
|
return true;
|
|
3560
3598
|
} else {
|
|
@@ -3577,12 +3615,14 @@ var MagicStringError = class extends Error {
|
|
|
3577
3615
|
}
|
|
3578
3616
|
};
|
|
3579
3617
|
function getBtoa() {
|
|
3618
|
+
/* v8 ignore next -- environment fallback, unreachable when `btoa` is present */
|
|
3580
3619
|
if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
|
|
3581
3620
|
const buffer = globalThis["Buffer"];
|
|
3582
3621
|
if (buffer) return (str) => buffer.from(str, "utf-8").toString("base64");
|
|
3583
3622
|
return () => {
|
|
3584
3623
|
throw new MagicStringError("unsupported environment: `btoa` or `Buffer` is required");
|
|
3585
3624
|
};
|
|
3625
|
+
/* v8 ignore stop */
|
|
3586
3626
|
}
|
|
3587
3627
|
const btoa$1 = /* #__PURE__ */ getBtoa();
|
|
3588
3628
|
var SourceMap = class {
|
|
@@ -3592,9 +3632,17 @@ var SourceMap = class {
|
|
|
3592
3632
|
this.sources = properties.sources;
|
|
3593
3633
|
this.sourcesContent = properties.sourcesContent;
|
|
3594
3634
|
this.names = properties.names;
|
|
3595
|
-
this.mappings = encode$1(properties.mappings);
|
|
3635
|
+
this.mappings = typeof properties.mappings === "string" ? properties.mappings : encode$1(properties.mappings);
|
|
3596
3636
|
if (typeof properties.x_google_ignoreList !== "undefined") this.x_google_ignoreList = properties.x_google_ignoreList;
|
|
3597
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
|
+
}
|
|
3598
3646
|
}
|
|
3599
3647
|
/**
|
|
3600
3648
|
* Returns the equivalent of `JSON.stringify(map)`
|
|
@@ -3611,12 +3659,8 @@ var SourceMap = class {
|
|
|
3611
3659
|
}
|
|
3612
3660
|
};
|
|
3613
3661
|
function getLocator(source) {
|
|
3614
|
-
const
|
|
3615
|
-
|
|
3616
|
-
for (let i = 0, pos = 0; i < originalLines.length; i++) {
|
|
3617
|
-
lineOffsets.push(pos);
|
|
3618
|
-
pos += originalLines[i].length + 1;
|
|
3619
|
-
}
|
|
3662
|
+
const lineOffsets = [0];
|
|
3663
|
+
for (let i = source.indexOf("\n"); i !== -1; i = source.indexOf("\n", i + 1)) lineOffsets.push(i + 1);
|
|
3620
3664
|
return function locate(index) {
|
|
3621
3665
|
let i = 0;
|
|
3622
3666
|
let j = lineOffsets.length;
|
|
@@ -3662,15 +3706,120 @@ const toString = Object.prototype.toString;
|
|
|
3662
3706
|
function isObject(thing) {
|
|
3663
3707
|
return toString.call(thing) === "[object Object]";
|
|
3664
3708
|
}
|
|
3665
|
-
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
|
+
}
|
|
3666
3801
|
var Mappings = class {
|
|
3667
|
-
constructor(hires) {
|
|
3802
|
+
constructor(hires, encoder = null) {
|
|
3668
3803
|
this.hires = hires;
|
|
3669
3804
|
this.generatedCodeLine = 0;
|
|
3670
3805
|
this.generatedCodeColumn = 0;
|
|
3671
3806
|
this.raw = [];
|
|
3672
3807
|
this.rawSegments = this.raw[this.generatedCodeLine] = [];
|
|
3673
|
-
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 = [];
|
|
3674
3823
|
}
|
|
3675
3824
|
addEdit(sourceIndex, content, loc, nameIndex) {
|
|
3676
3825
|
if (content.length) {
|
|
@@ -3686,9 +3835,7 @@ var Mappings = class {
|
|
|
3686
3835
|
];
|
|
3687
3836
|
if (nameIndex >= 0) segment.push(nameIndex);
|
|
3688
3837
|
this.rawSegments.push(segment);
|
|
3689
|
-
this.
|
|
3690
|
-
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
3691
|
-
this.generatedCodeColumn = 0;
|
|
3838
|
+
this.nextLine();
|
|
3692
3839
|
previousContentLineEnd = contentLineEnd;
|
|
3693
3840
|
contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
|
|
3694
3841
|
}
|
|
@@ -3701,63 +3848,122 @@ var Mappings = class {
|
|
|
3701
3848
|
if (nameIndex >= 0) segment.push(nameIndex);
|
|
3702
3849
|
this.rawSegments.push(segment);
|
|
3703
3850
|
this.advance(content.slice(previousContentLineEnd + 1));
|
|
3704
|
-
} else if (this.pending) {
|
|
3705
|
-
this.rawSegments.push(this.pending);
|
|
3706
|
-
this.advance(content);
|
|
3707
3851
|
}
|
|
3708
|
-
this.pending = null;
|
|
3709
3852
|
}
|
|
3710
3853
|
addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
|
|
3711
|
-
|
|
3712
|
-
let
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
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([
|
|
3726
3910
|
this.generatedCodeColumn,
|
|
3727
3911
|
sourceIndex,
|
|
3728
3912
|
loc.line,
|
|
3729
3913
|
loc.column
|
|
3730
|
-
];
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
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;
|
|
3735
3949
|
}
|
|
3736
|
-
} else {
|
|
3737
|
-
this.rawSegments.push(segment);
|
|
3738
|
-
charInHiresBoundary = false;
|
|
3739
3950
|
}
|
|
3740
|
-
|
|
3951
|
+
loc.column += newline - i;
|
|
3952
|
+
this.generatedCodeColumn += newline - i;
|
|
3741
3953
|
}
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3954
|
+
if (newline === end) break;
|
|
3955
|
+
loc.line += 1;
|
|
3956
|
+
loc.column = 0;
|
|
3957
|
+
this.nextLine();
|
|
3958
|
+
i = newline + 1;
|
|
3745
3959
|
}
|
|
3746
|
-
originalCharIndex += 1;
|
|
3747
3960
|
}
|
|
3748
|
-
this.pending = null;
|
|
3749
3961
|
}
|
|
3750
3962
|
advance(str) {
|
|
3751
3963
|
if (!str) return;
|
|
3752
|
-
const
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
this.generatedCodeLine++;
|
|
3756
|
-
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
3757
|
-
}
|
|
3758
|
-
this.generatedCodeColumn = 0;
|
|
3759
|
-
}
|
|
3760
|
-
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;
|
|
3761
3967
|
}
|
|
3762
3968
|
};
|
|
3763
3969
|
const n$1 = "\n";
|
|
@@ -3768,6 +3974,63 @@ const warned = {
|
|
|
3768
3974
|
insertRight: false,
|
|
3769
3975
|
storeName: false
|
|
3770
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
|
+
}
|
|
3771
4034
|
var MagicString = class MagicString {
|
|
3772
4035
|
constructor(string, options = {}) {
|
|
3773
4036
|
const chunk = new Chunk(0, string.length, string);
|
|
@@ -3918,9 +4181,32 @@ var MagicString = class MagicString {
|
|
|
3918
4181
|
*/
|
|
3919
4182
|
generateDecodedMap(options) {
|
|
3920
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) {
|
|
3921
4208
|
const sourceIndex = 0;
|
|
3922
4209
|
const names = Object.keys(this.storedNames);
|
|
3923
|
-
const mappings = new Mappings(options.hires);
|
|
3924
4210
|
const locate = getLocator(this.original);
|
|
3925
4211
|
if (this.intro) mappings.advance(this.intro);
|
|
3926
4212
|
this.firstChunk.eachNext((chunk) => {
|
|
@@ -3931,21 +4217,18 @@ var MagicString = class MagicString {
|
|
|
3931
4217
|
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
3932
4218
|
});
|
|
3933
4219
|
if (this.outro) mappings.advance(this.outro);
|
|
4220
|
+
return names;
|
|
4221
|
+
}
|
|
4222
|
+
/** @internal */
|
|
4223
|
+
_mapProperties(options, names) {
|
|
3934
4224
|
return {
|
|
3935
4225
|
file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
|
|
3936
4226
|
sources: [options.source ? getRelativePath(options.file || "", options.source) : options.file || ""],
|
|
3937
4227
|
sourcesContent: options.includeContent ? [this.original] : void 0,
|
|
3938
4228
|
names,
|
|
3939
|
-
|
|
3940
|
-
x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
|
|
4229
|
+
x_google_ignoreList: this.ignoreList ? [0] : void 0
|
|
3941
4230
|
};
|
|
3942
4231
|
}
|
|
3943
|
-
/**
|
|
3944
|
-
* Generates a version 3 sourcemap.
|
|
3945
|
-
*/
|
|
3946
|
-
generateMap(options) {
|
|
3947
|
-
return new SourceMap(this.generateDecodedMap(options));
|
|
3948
|
-
}
|
|
3949
4232
|
/** @internal */
|
|
3950
4233
|
_ensureindentStr() {
|
|
3951
4234
|
if (this.indentStr === void 0) this.indentStr = guessIndent(this.original);
|
|
@@ -3977,17 +4260,18 @@ var MagicString = class MagicString {
|
|
|
3977
4260
|
for (let i = exclusion[0]; i < exclusion[1]; i += 1) isExcluded[i] = true;
|
|
3978
4261
|
});
|
|
3979
4262
|
let shouldIndentNextCharacter = options.indentStart !== false;
|
|
3980
|
-
const
|
|
3981
|
-
if (
|
|
3982
|
-
|
|
3983
|
-
|
|
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;
|
|
3984
4268
|
};
|
|
3985
|
-
this.intro = this.intro
|
|
4269
|
+
this.intro = indentPiece(this.intro);
|
|
3986
4270
|
let charIndex = 0;
|
|
3987
4271
|
let chunk = this.firstChunk;
|
|
3988
4272
|
const indentAt = (index) => {
|
|
3989
4273
|
shouldIndentNextCharacter = false;
|
|
3990
|
-
if (index === chunk.start) chunk.
|
|
4274
|
+
if (index === chunk.start) chunk.appendRight(resolvedIndentStr);
|
|
3991
4275
|
else {
|
|
3992
4276
|
this._splitChunk(chunk, index);
|
|
3993
4277
|
chunk = chunk.next;
|
|
@@ -3996,11 +4280,9 @@ var MagicString = class MagicString {
|
|
|
3996
4280
|
};
|
|
3997
4281
|
while (chunk) {
|
|
3998
4282
|
const end = chunk.end;
|
|
4283
|
+
if (!isExcluded[chunk.start]) chunk.intro = indentPiece(chunk.intro);
|
|
3999
4284
|
if (chunk.edited) {
|
|
4000
|
-
if (!isExcluded[charIndex])
|
|
4001
|
-
chunk.content = chunk.content.replace(pattern, replacer);
|
|
4002
|
-
if (chunk.content.length) shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
|
|
4003
|
-
}
|
|
4285
|
+
if (!isExcluded[charIndex]) chunk.content = indentPiece(chunk.content);
|
|
4004
4286
|
} else if (options.exclude) {
|
|
4005
4287
|
charIndex = chunk.start;
|
|
4006
4288
|
while (charIndex < end) {
|
|
@@ -4030,10 +4312,11 @@ var MagicString = class MagicString {
|
|
|
4030
4312
|
charIndex += 1;
|
|
4031
4313
|
}
|
|
4032
4314
|
}
|
|
4315
|
+
if (!isExcluded[chunk.end - 1]) chunk.outro = indentPiece(chunk.outro);
|
|
4033
4316
|
charIndex = chunk.end;
|
|
4034
4317
|
chunk = chunk.next;
|
|
4035
4318
|
}
|
|
4036
|
-
this.outro = this.outro
|
|
4319
|
+
this.outro = indentPiece(this.outro);
|
|
4037
4320
|
return this;
|
|
4038
4321
|
}
|
|
4039
4322
|
/** @internal */
|
|
@@ -4058,8 +4341,14 @@ var MagicString = class MagicString {
|
|
|
4058
4341
|
}
|
|
4059
4342
|
/**
|
|
4060
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.
|
|
4061
4350
|
*/
|
|
4062
|
-
move(start, end, index) {
|
|
4351
|
+
move(start, end, index, affinity = "right") {
|
|
4063
4352
|
start = start + this.offset;
|
|
4064
4353
|
end = end + this.offset;
|
|
4065
4354
|
index = index + this.offset;
|
|
@@ -4079,9 +4368,27 @@ var MagicString = class MagicString {
|
|
|
4079
4368
|
}
|
|
4080
4369
|
const oldLeft = first.previous;
|
|
4081
4370
|
const oldRight = last.next;
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
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
|
+
}
|
|
4085
4392
|
if (oldLeft) oldLeft.next = oldRight;
|
|
4086
4393
|
if (oldRight) oldRight.previous = oldLeft;
|
|
4087
4394
|
if (newLeft) newLeft.next = first;
|
|
@@ -4156,6 +4463,7 @@ var MagicString = class MagicString {
|
|
|
4156
4463
|
}
|
|
4157
4464
|
const first = this.byStart.get(start);
|
|
4158
4465
|
const last = this.byEnd.get(end);
|
|
4466
|
+
/* v8 ignore else -- unreachable: a valid start/end always yields a `first` chunk */
|
|
4159
4467
|
if (first) {
|
|
4160
4468
|
let chunk = first;
|
|
4161
4469
|
while (chunk !== last) {
|
|
@@ -4205,6 +4513,9 @@ var MagicString = class MagicString {
|
|
|
4205
4513
|
}
|
|
4206
4514
|
/**
|
|
4207
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.
|
|
4208
4519
|
* Removing the same content twice, or making removals that partially overlap, will cause an error.
|
|
4209
4520
|
*/
|
|
4210
4521
|
remove(start, end) {
|
|
@@ -4221,9 +4532,9 @@ var MagicString = class MagicString {
|
|
|
4221
4532
|
this._split(end);
|
|
4222
4533
|
let chunk = this.byStart.get(start);
|
|
4223
4534
|
while (chunk) {
|
|
4224
|
-
chunk.intro = "";
|
|
4225
|
-
chunk.outro = "";
|
|
4226
|
-
chunk.edit("");
|
|
4535
|
+
if (chunk.start > start) chunk.intro = "";
|
|
4536
|
+
if (chunk.end < end) chunk.outro = "";
|
|
4537
|
+
chunk.edit("", false, true);
|
|
4227
4538
|
chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
|
|
4228
4539
|
}
|
|
4229
4540
|
return this;
|
|
@@ -4303,12 +4614,13 @@ var MagicString = class MagicString {
|
|
|
4303
4614
|
let result = "";
|
|
4304
4615
|
let chunk = this.firstChunk;
|
|
4305
4616
|
while (chunk && (chunk.start > start || chunk.end <= start)) {
|
|
4306
|
-
if (chunk.start < end && chunk.end >= end) return result;
|
|
4617
|
+
if (chunk.start < end && chunk.end >= end || end === 0 && chunk.start === 0) return result;
|
|
4307
4618
|
chunk = chunk.next;
|
|
4308
4619
|
}
|
|
4309
4620
|
if (chunk && chunk.edited && chunk.start !== start) throw new MagicStringError(`cannot use edited character ${start} as slice start anchor`);
|
|
4310
4621
|
const startChunk = chunk;
|
|
4311
4622
|
while (chunk) {
|
|
4623
|
+
if (end === 0 && chunk.start === 0) break;
|
|
4312
4624
|
if (chunk.intro && (startChunk !== chunk || chunk.start === start)) result += chunk.intro;
|
|
4313
4625
|
const containsEnd = chunk.start < end && chunk.end >= end;
|
|
4314
4626
|
if (containsEnd && chunk.edited && chunk.end !== end) throw new MagicStringError(`cannot use edited character ${end} as slice end anchor`);
|
|
@@ -4373,11 +4685,13 @@ var MagicString = class MagicString {
|
|
|
4373
4685
|
* Returns true if the resulting source is empty (disregarding white space).
|
|
4374
4686
|
*/
|
|
4375
4687
|
isEmpty() {
|
|
4688
|
+
if (this.intro.length && this.intro.trim()) return false;
|
|
4376
4689
|
let chunk = this.firstChunk;
|
|
4377
4690
|
while (chunk) {
|
|
4378
4691
|
if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim()) return false;
|
|
4379
4692
|
chunk = chunk.next;
|
|
4380
4693
|
}
|
|
4694
|
+
if (this.outro.length && this.outro.trim()) return false;
|
|
4381
4695
|
return true;
|
|
4382
4696
|
}
|
|
4383
4697
|
length() {
|
|
@@ -4419,7 +4733,8 @@ var MagicString = class MagicString {
|
|
|
4419
4733
|
if (aborted) return true;
|
|
4420
4734
|
chunk = chunk.previous;
|
|
4421
4735
|
} while (chunk);
|
|
4422
|
-
|
|
4736
|
+
this.intro = this.intro.replace(rx, "");
|
|
4737
|
+
return this.intro.length > 0;
|
|
4423
4738
|
}
|
|
4424
4739
|
/**
|
|
4425
4740
|
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end.
|
|
@@ -4446,7 +4761,8 @@ var MagicString = class MagicString {
|
|
|
4446
4761
|
if (aborted) return true;
|
|
4447
4762
|
chunk = chunk.next;
|
|
4448
4763
|
} while (chunk);
|
|
4449
|
-
|
|
4764
|
+
this.outro = this.outro.replace(rx, "");
|
|
4765
|
+
return this.outro.length > 0;
|
|
4450
4766
|
}
|
|
4451
4767
|
/**
|
|
4452
4768
|
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start.
|
|
@@ -4473,41 +4789,66 @@ var MagicString = class MagicString {
|
|
|
4473
4789
|
}
|
|
4474
4790
|
return outputIndex !== this.original.length;
|
|
4475
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
|
+
}
|
|
4476
4808
|
/** @internal */
|
|
4477
4809
|
_replaceRegexp(searchValue, replacement) {
|
|
4478
4810
|
function getReplacement(match, str) {
|
|
4479
|
-
if (typeof replacement === "string") return replacement.
|
|
4480
|
-
|
|
4481
|
-
if (i === "&") return match[0];
|
|
4482
|
-
if (+i < match.length) return match[+i];
|
|
4483
|
-
return `$${i}`;
|
|
4484
|
-
});
|
|
4485
|
-
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);
|
|
4486
4813
|
}
|
|
4487
4814
|
const replaceMatch = (match) => {
|
|
4488
|
-
|
|
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;
|
|
4489
4818
|
const replacement = getReplacement(match, this.original);
|
|
4490
|
-
if (replacement === match[0]) return;
|
|
4819
|
+
if (replacement === match[0]) return true;
|
|
4491
4820
|
if (match[0].length === 0) this.appendRight(match.index, replacement);
|
|
4492
4821
|
else this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
4822
|
+
return true;
|
|
4493
4823
|
};
|
|
4494
4824
|
if (searchValue.global) {
|
|
4495
4825
|
searchValue.lastIndex = 0;
|
|
4496
4826
|
for (const match of this.original.matchAll(searchValue)) replaceMatch(match);
|
|
4497
4827
|
} else {
|
|
4498
4828
|
const match = this.original.match(searchValue);
|
|
4499
|
-
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
|
+
}
|
|
4500
4833
|
}
|
|
4501
4834
|
return this;
|
|
4502
4835
|
}
|
|
4503
4836
|
/** @internal */
|
|
4504
4837
|
_replaceString(string, replacement) {
|
|
4505
4838
|
const { original } = this;
|
|
4506
|
-
|
|
4507
|
-
|
|
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
|
+
}
|
|
4508
4845
|
if (typeof replacement === "function") replacement = replacement(string, index, original);
|
|
4509
|
-
|
|
4510
|
-
|
|
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;
|
|
4511
4852
|
}
|
|
4512
4853
|
return this;
|
|
4513
4854
|
}
|
|
@@ -4524,14 +4865,15 @@ var MagicString = class MagicString {
|
|
|
4524
4865
|
const stringLength = string.length;
|
|
4525
4866
|
if (stringLength === 0) {
|
|
4526
4867
|
for (let index = 0; index <= original.length; index += 1) {
|
|
4527
|
-
const _replacement = typeof replacement === "function" ? replacement("", index, original) : replacement;
|
|
4868
|
+
const _replacement = typeof replacement === "function" ? replacement("", index, original) : expandReplacement(replacement, "", index, original, [], void 0);
|
|
4528
4869
|
if (_replacement !== "") this.appendRight(index, _replacement);
|
|
4529
4870
|
}
|
|
4530
4871
|
return this;
|
|
4531
4872
|
}
|
|
4532
4873
|
for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
|
|
4874
|
+
if (this._hasRemovedContent(index, index + stringLength)) continue;
|
|
4533
4875
|
const previous = original.slice(index, index + stringLength);
|
|
4534
|
-
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);
|
|
4535
4877
|
if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
|
|
4536
4878
|
}
|
|
4537
4879
|
return this;
|
|
@@ -5744,7 +6086,7 @@ function perEnvironmentState(initial) {
|
|
|
5744
6086
|
};
|
|
5745
6087
|
}
|
|
5746
6088
|
//#endregion
|
|
5747
|
-
//#region ../../node_modules/.pnpm/artichokie@0.4.
|
|
6089
|
+
//#region ../../node_modules/.pnpm/artichokie@0.4.5/node_modules/artichokie/dist/index.js
|
|
5748
6090
|
const AsyncFunction = async function() {}.constructor;
|
|
5749
6091
|
const codeToDataUrl = (code) => `data:application/javascript,${encodeURIComponent(code + "\n//# sourceURL=[worker-eval(artichokie)]")}`;
|
|
5750
6092
|
const viteSsrDynamicImport = "__vite_ssr_dynamic_import__";
|
|
@@ -5779,7 +6121,14 @@ var Worker$1 = class {
|
|
|
5779
6121
|
return new Promise((resolve, reject) => {
|
|
5780
6122
|
worker.currentResolve = resolve;
|
|
5781
6123
|
worker.currentReject = reject;
|
|
5782
|
-
|
|
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
|
+
}
|
|
5783
6132
|
});
|
|
5784
6133
|
}
|
|
5785
6134
|
stop() {
|
|
@@ -5822,18 +6171,23 @@ var Worker$1 = class {
|
|
|
5822
6171
|
}
|
|
5823
6172
|
this._assignDoneWorker(worker);
|
|
5824
6173
|
});
|
|
5825
|
-
|
|
6174
|
+
const rejectWorker = (err) => {
|
|
5826
6175
|
worker.currentReject?.(err);
|
|
5827
6176
|
worker.currentReject = null;
|
|
5828
6177
|
parentFunctionResponder.close();
|
|
5829
|
-
}
|
|
6178
|
+
};
|
|
6179
|
+
worker.on("error", rejectWorker);
|
|
5830
6180
|
worker.on("exit", (code) => {
|
|
5831
6181
|
const i = this._pool.indexOf(worker);
|
|
5832
6182
|
if (i > -1) this._pool.splice(i, 1);
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
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
|
+
}
|
|
5837
6191
|
}
|
|
5838
6192
|
});
|
|
5839
6193
|
this._pool.push(worker);
|
|
@@ -6430,7 +6784,7 @@ var require_src$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6430
6784
|
};
|
|
6431
6785
|
}));
|
|
6432
6786
|
//#endregion
|
|
6433
|
-
//#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
|
|
6434
6788
|
var require_req = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6435
6789
|
const { createRequire: createRequire$1 } = __require("node:module");
|
|
6436
6790
|
const { fileURLToPath: fileURLToPath$1, pathToFileURL: pathToFileURL$1 } = __require("node:url");
|
|
@@ -6472,7 +6826,7 @@ var require_req = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6472
6826
|
module.exports = req;
|
|
6473
6827
|
}));
|
|
6474
6828
|
//#endregion
|
|
6475
|
-
//#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
|
|
6476
6830
|
var require_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6477
6831
|
const req = require_req();
|
|
6478
6832
|
/**
|
|
@@ -6506,7 +6860,7 @@ var require_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6506
6860
|
module.exports = options;
|
|
6507
6861
|
}));
|
|
6508
6862
|
//#endregion
|
|
6509
|
-
//#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
|
|
6510
6864
|
var require_plugins = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6511
6865
|
const req = require_req();
|
|
6512
6866
|
/**
|
|
@@ -6560,7 +6914,7 @@ var require_plugins = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6560
6914
|
module.exports = plugins;
|
|
6561
6915
|
}));
|
|
6562
6916
|
//#endregion
|
|
6563
|
-
//#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
|
|
6564
6918
|
var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6565
6919
|
const { resolve: resolve$3 } = __require("node:path");
|
|
6566
6920
|
const config = require_src$1();
|
|
@@ -16403,6 +16757,26 @@ var NoopWatcher = class extends EventEmitter {
|
|
|
16403
16757
|
function createNoopWatcher(options) {
|
|
16404
16758
|
return new NoopWatcher(options);
|
|
16405
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
|
+
}
|
|
16406
16780
|
//#endregion
|
|
16407
16781
|
//#region src/node/server/middlewares/base.ts
|
|
16408
16782
|
function baseMiddleware(rawBase, middlewareMode) {
|
|
@@ -17054,6 +17428,7 @@ async function computeSourceRoute(map, file) {
|
|
|
17054
17428
|
return sourceRoot;
|
|
17055
17429
|
}
|
|
17056
17430
|
async function injectSourcesContent(map, file, logger) {
|
|
17431
|
+
if (map.sourceRoot && isExternalUrl(map.sourceRoot)) return;
|
|
17057
17432
|
let sourceRootPromise;
|
|
17058
17433
|
const packageRoot = getNodeModulesPackageRoot(file);
|
|
17059
17434
|
const missingSources = [];
|
|
@@ -17061,7 +17436,7 @@ async function injectSourcesContent(map, file, logger) {
|
|
|
17061
17436
|
const sourcesContentPromises = [];
|
|
17062
17437
|
for (let index = 0; index < map.sources.length; index++) {
|
|
17063
17438
|
const sourcePath = map.sources[index];
|
|
17064
|
-
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 () => {
|
|
17065
17440
|
sourceRootPromise ??= computeSourceRoute(map, file);
|
|
17066
17441
|
const sourceRoot = await sourceRootPromise;
|
|
17067
17442
|
let resolvedSourcePath = cleanUrl(decodeURI(sourcePath));
|
|
@@ -19349,6 +19724,13 @@ const rewriteOriginHeader = (proxyReq, options, config) => {
|
|
|
19349
19724
|
}
|
|
19350
19725
|
}
|
|
19351
19726
|
};
|
|
19727
|
+
function createProxyContextMatcher(context) {
|
|
19728
|
+
if (context[0] === "^") {
|
|
19729
|
+
const regex = new RegExp(context);
|
|
19730
|
+
return (url) => regex.test(url);
|
|
19731
|
+
}
|
|
19732
|
+
return (url) => url.startsWith(context);
|
|
19733
|
+
}
|
|
19352
19734
|
function proxyMiddleware(httpServer, options, config) {
|
|
19353
19735
|
const proxies = {};
|
|
19354
19736
|
Object.keys(options).forEach((context) => {
|
|
@@ -19384,72 +19766,77 @@ function proxyMiddleware(httpServer, options, config) {
|
|
|
19384
19766
|
});
|
|
19385
19767
|
});
|
|
19386
19768
|
});
|
|
19387
|
-
proxies[context] =
|
|
19769
|
+
proxies[context] = {
|
|
19770
|
+
proxy,
|
|
19771
|
+
options: { ...opts },
|
|
19772
|
+
match: createProxyContextMatcher(context)
|
|
19773
|
+
};
|
|
19388
19774
|
});
|
|
19389
19775
|
if (httpServer) httpServer.on("upgrade", async (req, socket, head) => {
|
|
19390
19776
|
const url = req.url;
|
|
19391
|
-
for (const context in proxies)
|
|
19392
|
-
const
|
|
19393
|
-
if (
|
|
19394
|
-
if (opts.
|
|
19395
|
-
|
|
19396
|
-
|
|
19397
|
-
|
|
19398
|
-
|
|
19399
|
-
|
|
19400
|
-
|
|
19401
|
-
|
|
19402
|
-
|
|
19403
|
-
|
|
19777
|
+
for (const context in proxies) {
|
|
19778
|
+
const { proxy, options: opts, match } = proxies[context];
|
|
19779
|
+
if (match(url)) {
|
|
19780
|
+
if (opts.ws || opts.target?.toString().startsWith("ws:") || opts.target?.toString().startsWith("wss:")) {
|
|
19781
|
+
if (opts.bypass) try {
|
|
19782
|
+
const bypassResult = await opts.bypass(req, void 0, opts);
|
|
19783
|
+
if (typeof bypassResult === "string") {
|
|
19784
|
+
debug$8?.(`bypass: ${req.url} -> ${bypassResult}`);
|
|
19785
|
+
req.url = bypassResult;
|
|
19786
|
+
return;
|
|
19787
|
+
}
|
|
19788
|
+
if (bypassResult === false) {
|
|
19789
|
+
debug$8?.(`bypass: ${req.url} -> 404`);
|
|
19790
|
+
socket.end("HTTP/1.1 404 Not Found\r\n\r\n", "");
|
|
19791
|
+
return;
|
|
19792
|
+
}
|
|
19793
|
+
} catch (err) {
|
|
19794
|
+
config.logger.error(`${import_picocolors.default.red(`ws proxy bypass error:`)}\n${err.stack}`, {
|
|
19795
|
+
timestamp: true,
|
|
19796
|
+
error: err
|
|
19797
|
+
});
|
|
19404
19798
|
return;
|
|
19405
19799
|
}
|
|
19406
|
-
|
|
19407
|
-
|
|
19408
|
-
|
|
19409
|
-
error: err
|
|
19410
|
-
});
|
|
19800
|
+
if (opts.rewrite) req.url = opts.rewrite(url);
|
|
19801
|
+
debug$8?.(`${req.url} -> ws ${opts.target}`);
|
|
19802
|
+
proxy.ws(req, socket, head);
|
|
19411
19803
|
return;
|
|
19412
19804
|
}
|
|
19413
|
-
if (opts.rewrite) req.url = opts.rewrite(url);
|
|
19414
|
-
debug$8?.(`${req.url} -> ws ${opts.target}`);
|
|
19415
|
-
proxy.ws(req, socket, head);
|
|
19416
|
-
return;
|
|
19417
19805
|
}
|
|
19418
19806
|
}
|
|
19419
19807
|
});
|
|
19420
19808
|
return async function viteProxyMiddleware(req, res, next) {
|
|
19421
19809
|
const url = req.url;
|
|
19422
|
-
for (const context in proxies)
|
|
19423
|
-
const
|
|
19424
|
-
|
|
19425
|
-
|
|
19426
|
-
|
|
19427
|
-
|
|
19428
|
-
|
|
19429
|
-
|
|
19430
|
-
|
|
19431
|
-
|
|
19432
|
-
|
|
19433
|
-
|
|
19434
|
-
|
|
19435
|
-
|
|
19436
|
-
|
|
19810
|
+
for (const context in proxies) {
|
|
19811
|
+
const { proxy, options: opts, match } = proxies[context];
|
|
19812
|
+
if (match(url)) {
|
|
19813
|
+
const options = {};
|
|
19814
|
+
if (opts.bypass) try {
|
|
19815
|
+
const bypassResult = await opts.bypass(req, res, opts);
|
|
19816
|
+
if (typeof bypassResult === "string") {
|
|
19817
|
+
debug$8?.(`bypass: ${req.url} -> ${bypassResult}`);
|
|
19818
|
+
req.url = bypassResult;
|
|
19819
|
+
if (res.writableEnded) return;
|
|
19820
|
+
return next();
|
|
19821
|
+
}
|
|
19822
|
+
if (bypassResult === false) {
|
|
19823
|
+
debug$8?.(`bypass: ${req.url} -> 404`);
|
|
19824
|
+
res.statusCode = 404;
|
|
19825
|
+
return res.end();
|
|
19826
|
+
}
|
|
19827
|
+
} catch (e) {
|
|
19828
|
+
debug$8?.(`bypass: ${req.url} -> ${e}`);
|
|
19829
|
+
return next(e);
|
|
19437
19830
|
}
|
|
19438
|
-
|
|
19439
|
-
|
|
19440
|
-
|
|
19831
|
+
debug$8?.(`${req.url} -> ${opts.target || opts.forward}`);
|
|
19832
|
+
if (opts.rewrite) req.url = opts.rewrite(req.url);
|
|
19833
|
+
proxy.web(req, res, options);
|
|
19834
|
+
return;
|
|
19441
19835
|
}
|
|
19442
|
-
debug$8?.(`${req.url} -> ${opts.target || opts.forward}`);
|
|
19443
|
-
if (opts.rewrite) req.url = opts.rewrite(req.url);
|
|
19444
|
-
proxy.web(req, res, options);
|
|
19445
|
-
return;
|
|
19446
19836
|
}
|
|
19447
19837
|
next();
|
|
19448
19838
|
};
|
|
19449
19839
|
}
|
|
19450
|
-
function doesProxyContextMatchUrl(context, url) {
|
|
19451
|
-
return context[0] === "^" && new RegExp(context).test(url) || url.startsWith(context);
|
|
19452
|
-
}
|
|
19453
19840
|
//#endregion
|
|
19454
19841
|
//#region src/node/server/middlewares/rejectInvalidRequest.ts
|
|
19455
19842
|
/**
|
|
@@ -24262,12 +24649,12 @@ async function _createServer(inlineConfig = {}, options) {
|
|
|
24262
24649
|
const publicFiles = await initPublicFilesPromise;
|
|
24263
24650
|
const { publicDir } = config;
|
|
24264
24651
|
if (httpServer) setClientErrorHandler(httpServer, config.logger);
|
|
24265
|
-
const watcher = serverConfig.watch !== null ? import_chokidar.watch([
|
|
24652
|
+
const watcher = serverConfig.watch !== null ? makeWatcherCloseFinal(import_chokidar.watch([
|
|
24266
24653
|
...config.experimental.bundledDev ? [] : [root],
|
|
24267
24654
|
...config.configFileDependencies,
|
|
24268
24655
|
...getEnvFilesForMode(config.mode, config.envDir),
|
|
24269
24656
|
...publicDir && publicFiles ? [publicDir] : []
|
|
24270
|
-
], resolvedWatchOptions) : createNoopWatcher(resolvedWatchOptions);
|
|
24657
|
+
], resolvedWatchOptions)) : createNoopWatcher(resolvedWatchOptions);
|
|
24271
24658
|
const environments = {};
|
|
24272
24659
|
await Promise.all(Object.entries(config.environments).map(async ([name, environmentOptions]) => {
|
|
24273
24660
|
const environment = await environmentOptions.dev.createEnvironment(name, config, { ws });
|
|
@@ -25293,6 +25680,7 @@ function optimizedDepsPlugin() {
|
|
|
25293
25680
|
if (info) {
|
|
25294
25681
|
if (browserHash && info.browserHash !== browserHash && !environment.config.optimizeDeps.ignoreOutdatedRequests) throwOutdatedRequest(id);
|
|
25295
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`);
|
|
25296
25684
|
await info.processing;
|
|
25297
25685
|
} catch {
|
|
25298
25686
|
throwProcessingError(id);
|
|
@@ -25352,7 +25740,7 @@ function preAliasPlugin(config) {
|
|
|
25352
25740
|
const ssr = environment.config.consumer === "server";
|
|
25353
25741
|
const depsOptimizer = environment.depsOptimizer;
|
|
25354
25742
|
if (importer && depsOptimizer && bareImportRE.test(id) && !options.scan && id !== "@vite/client" && id !== "@vite/env") {
|
|
25355
|
-
if (findPatterns.
|
|
25743
|
+
if (findPatterns.some((pattern) => matches(pattern, id))) {
|
|
25356
25744
|
const optimizedId = await tryOptimizedResolve(depsOptimizer, id, importer, config.resolve.preserveSymlinks, config.packageCache);
|
|
25357
25745
|
if (optimizedId) return optimizedId;
|
|
25358
25746
|
if (depsOptimizer.options.noDiscovery) return;
|
|
@@ -26412,7 +26800,7 @@ function preload(baseModule, deps, importerUrl) {
|
|
|
26412
26800
|
link.addEventListener("load", res);
|
|
26413
26801
|
link.addEventListener("error", () => rej(/* @__PURE__ */ new Error(`Unable to preload CSS for ${dep}`)));
|
|
26414
26802
|
});
|
|
26415
|
-
}));
|
|
26803
|
+
}).filter((p) => p !== void 0));
|
|
26416
26804
|
}
|
|
26417
26805
|
function handlePreloadError(err) {
|
|
26418
26806
|
const e = new Event("vite:preloadError", { cancelable: true });
|
|
@@ -27396,7 +27784,7 @@ function devToScanEnvironment(environment) {
|
|
|
27396
27784
|
}
|
|
27397
27785
|
const debug$5 = createDebugger("vite:deps");
|
|
27398
27786
|
const htmlTypesRE = /\.(?:html|vue|svelte|astro|imba)$/;
|
|
27399
|
-
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;
|
|
27400
27788
|
function scanImports(environment) {
|
|
27401
27789
|
const start = performance$1.now();
|
|
27402
27790
|
const { config } = environment;
|
|
@@ -33940,10 +34328,8 @@ function resolveRolldownOptions(environment, chunkMetadataMap) {
|
|
|
33940
34328
|
...options.rolldownOptions.resolve,
|
|
33941
34329
|
tsconfigFilename: void 0
|
|
33942
34330
|
} : options.rolldownOptions.resolve,
|
|
33943
|
-
output: options.rolldownOptions.output,
|
|
33944
34331
|
input,
|
|
33945
34332
|
plugins,
|
|
33946
|
-
external: options.rolldownOptions.external,
|
|
33947
34333
|
onLog(level, log) {
|
|
33948
34334
|
onRollupLog(level, log, environment);
|
|
33949
34335
|
},
|
|
@@ -33987,19 +34373,19 @@ function resolveRolldownOptions(environment, chunkMetadataMap) {
|
|
|
33987
34373
|
chunkFileNames: libOptions ? `[name]-[hash].${jsExt}` : path.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`),
|
|
33988
34374
|
assetFileNames: libOptions ? `[name].[ext]` : path.posix.join(options.assetsDir, `[name]-[hash].[ext]`),
|
|
33989
34375
|
codeSplitting: output.codeSplitting ?? (output.format === "umd" || output.format === "iife" || isSsrTargetWebworkerEnvironment && (typeof input === "string" || Object.keys(input).length === 1) ? false : void 0),
|
|
33990
|
-
comments: typeof output.comments === "boolean" ? output.comments : {
|
|
33991
|
-
annotation: !options.minify || libOptions && (format === "es" || format === "esm"),
|
|
33992
|
-
jsdoc: !options.minify,
|
|
33993
|
-
legal: !options.minify,
|
|
33994
|
-
...output.comments
|
|
33995
|
-
},
|
|
33996
34376
|
minify: options.minify === "oxc" ? libOptions && (format === "es" || format === "esm") ? {
|
|
33997
34377
|
compress: true,
|
|
33998
34378
|
mangle: true,
|
|
33999
34379
|
codegen: false
|
|
34000
34380
|
} : true : options.minify === false ? "dce-only" : false,
|
|
34001
34381
|
topLevelVar: true,
|
|
34002
|
-
...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
|
+
}
|
|
34003
34389
|
};
|
|
34004
34390
|
};
|
|
34005
34391
|
const outputs = resolveBuildOutputs(options.rolldownOptions.output, libOptions, logger);
|
|
@@ -35097,6 +35483,7 @@ function createDepsOptimizer(environment) {
|
|
|
35097
35483
|
let metadata = initDepsOptimizerMetadata(environment, sessionTimestamp);
|
|
35098
35484
|
const depsOptimizer = {
|
|
35099
35485
|
init,
|
|
35486
|
+
initState: "idle",
|
|
35100
35487
|
metadata,
|
|
35101
35488
|
registerMissingImport,
|
|
35102
35489
|
run: () => debouncedProcessing(0),
|
|
@@ -35137,16 +35524,19 @@ function createDepsOptimizer(environment) {
|
|
|
35137
35524
|
let discover;
|
|
35138
35525
|
async function close() {
|
|
35139
35526
|
closed = true;
|
|
35527
|
+
if (debounceProcessingHandle) clearTimeout(debounceProcessingHandle);
|
|
35528
|
+
debounceProcessingHandle = void 0;
|
|
35140
35529
|
await Promise.allSettled([
|
|
35141
35530
|
discover?.cancel(),
|
|
35142
35531
|
depsOptimizer.scanProcessing,
|
|
35143
35532
|
optimizationResult?.cancel()
|
|
35144
35533
|
]);
|
|
35534
|
+
depOptimizationProcessing.resolve();
|
|
35535
|
+
resolveEnqueuedProcessingPromises();
|
|
35145
35536
|
}
|
|
35146
|
-
let initState = "idle";
|
|
35147
35537
|
async function init() {
|
|
35148
|
-
if (initState !== "idle") return;
|
|
35149
|
-
initState = "initializing";
|
|
35538
|
+
if (depsOptimizer.initState !== "idle") return;
|
|
35539
|
+
depsOptimizer.initState = "initializing";
|
|
35150
35540
|
const cachedMetadata = await loadCachedDepOptimizationMetadata(environment);
|
|
35151
35541
|
firstRunCalled = !!cachedMetadata;
|
|
35152
35542
|
metadata = depsOptimizer.metadata = cachedMetadata || initDepsOptimizerMetadata(environment, sessionTimestamp);
|
|
@@ -35203,7 +35593,7 @@ function createDepsOptimizer(environment) {
|
|
|
35203
35593
|
})();
|
|
35204
35594
|
});
|
|
35205
35595
|
}
|
|
35206
|
-
initState = "initialized";
|
|
35596
|
+
depsOptimizer.initState = "initialized";
|
|
35207
35597
|
}
|
|
35208
35598
|
function startNextDiscoveredBatch() {
|
|
35209
35599
|
newDepsDiscovered = false;
|
|
@@ -35227,8 +35617,6 @@ function createDepsOptimizer(environment) {
|
|
|
35227
35617
|
if (debounceProcessingHandle) clearTimeout(debounceProcessingHandle);
|
|
35228
35618
|
if (closed) {
|
|
35229
35619
|
currentlyProcessing = false;
|
|
35230
|
-
depOptimizationProcessing.resolve();
|
|
35231
|
-
resolveEnqueuedProcessingPromises();
|
|
35232
35620
|
return;
|
|
35233
35621
|
}
|
|
35234
35622
|
currentlyProcessing = true;
|
|
@@ -35245,7 +35633,6 @@ function createDepsOptimizer(environment) {
|
|
|
35245
35633
|
if (closed) {
|
|
35246
35634
|
currentlyProcessing = false;
|
|
35247
35635
|
processingResult.cancel();
|
|
35248
|
-
resolveEnqueuedProcessingPromises();
|
|
35249
35636
|
return;
|
|
35250
35637
|
}
|
|
35251
35638
|
const newData = processingResult.metadata;
|
|
@@ -35340,7 +35727,7 @@ function createDepsOptimizer(environment) {
|
|
|
35340
35727
|
let missing = metadata.discovered[id];
|
|
35341
35728
|
if (missing) return missing;
|
|
35342
35729
|
missing = addMissingDep(id, resolved);
|
|
35343
|
-
if (initState === "initialized" && !waitingForCrawlEnd) debouncedProcessing();
|
|
35730
|
+
if (depsOptimizer.initState === "initialized" && !waitingForCrawlEnd) debouncedProcessing();
|
|
35344
35731
|
return missing;
|
|
35345
35732
|
}
|
|
35346
35733
|
function addMissingDep(id, resolved) {
|
|
@@ -35417,6 +35804,7 @@ function createDepsOptimizer(environment) {
|
|
|
35417
35804
|
function createExplicitDepsOptimizer(environment) {
|
|
35418
35805
|
const depsOptimizer = {
|
|
35419
35806
|
metadata: initDepsOptimizerMetadata(environment),
|
|
35807
|
+
initState: "idle",
|
|
35420
35808
|
isOptimizedDepFile: createIsOptimizedDepFile(environment),
|
|
35421
35809
|
isOptimizedDepUrl: createIsOptimizedDepUrl(environment),
|
|
35422
35810
|
getOptimizedDepId: (depInfo) => `${depInfo.file}?v=${depInfo.browserHash}`,
|
|
@@ -35428,11 +35816,11 @@ function createExplicitDepsOptimizer(environment) {
|
|
|
35428
35816
|
close: async () => {},
|
|
35429
35817
|
options: environment.config.optimizeDeps
|
|
35430
35818
|
};
|
|
35431
|
-
let inited = false;
|
|
35432
35819
|
async function init() {
|
|
35433
|
-
if (
|
|
35434
|
-
|
|
35820
|
+
if (depsOptimizer.initState !== "idle") return;
|
|
35821
|
+
depsOptimizer.initState = "initializing";
|
|
35435
35822
|
depsOptimizer.metadata = await optimizeExplicitEnvironmentDeps(environment);
|
|
35823
|
+
depsOptimizer.initState = "initialized";
|
|
35436
35824
|
}
|
|
35437
35825
|
return depsOptimizer;
|
|
35438
35826
|
}
|