@voidzero-dev/vite-plus-core 0.0.0-0bfcc90f.20260209-0731
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/LICENSE +41 -0
- package/dist/pluginutils/filter/composable-filters.d.ts +90 -0
- package/dist/pluginutils/filter/composable-filters.js +256 -0
- package/dist/pluginutils/filter/filter-vite-plugins.d.ts +28 -0
- package/dist/pluginutils/filter/filter-vite-plugins.js +75 -0
- package/dist/pluginutils/filter/index.d.ts +3 -0
- package/dist/pluginutils/filter/index.js +3 -0
- package/dist/pluginutils/filter/simple-filters.d.ts +71 -0
- package/dist/pluginutils/filter/simple-filters.js +70 -0
- package/dist/pluginutils/index.d.ts +1 -0
- package/dist/pluginutils/index.js +1 -0
- package/dist/pluginutils/utils.d.ts +2 -0
- package/dist/pluginutils/utils.js +17 -0
- package/dist/rolldown/cli-setup.d.mts +1 -0
- package/dist/rolldown/cli-setup.mjs +17 -0
- package/dist/rolldown/cli.d.mts +1 -0
- package/dist/rolldown/cli.mjs +608 -0
- package/dist/rolldown/config.d.mts +7 -0
- package/dist/rolldown/config.mjs +10 -0
- package/dist/rolldown/experimental-index.d.mts +194 -0
- package/dist/rolldown/experimental-index.mjs +291 -0
- package/dist/rolldown/experimental-runtime-types.d.ts +98 -0
- package/dist/rolldown/filter-index.d.mts +197 -0
- package/dist/rolldown/filter-index.mjs +369 -0
- package/dist/rolldown/get-log-filter.d.mts +7 -0
- package/dist/rolldown/get-log-filter.mjs +47 -0
- package/dist/rolldown/index.d.mts +4 -0
- package/dist/rolldown/index.mjs +57 -0
- package/dist/rolldown/parallel-plugin-worker.d.mts +1 -0
- package/dist/rolldown/parallel-plugin-worker.mjs +32 -0
- package/dist/rolldown/parallel-plugin.d.mts +14 -0
- package/dist/rolldown/parallel-plugin.mjs +7 -0
- package/dist/rolldown/parse-ast-index.d.mts +8 -0
- package/dist/rolldown/parse-ast-index.mjs +47 -0
- package/dist/rolldown/plugins-index.d.mts +30 -0
- package/dist/rolldown/plugins-index.mjs +40 -0
- package/dist/rolldown/shared/binding-D-XMzSaG.d.mts +1665 -0
- package/dist/rolldown/shared/binding-DuOSzYPt.mjs +587 -0
- package/dist/rolldown/shared/bindingify-input-options-Bu6nUTgS.mjs +2257 -0
- package/dist/rolldown/shared/constructors-DZVRHTli.mjs +61 -0
- package/dist/rolldown/shared/constructors-KD7LvxpN.d.mts +28 -0
- package/dist/rolldown/shared/define-config-BVG4QvnP.mjs +7 -0
- package/dist/rolldown/shared/define-config-U4pj0ZDn.d.mts +3616 -0
- package/dist/rolldown/shared/load-config-O1K_tT_z.mjs +114 -0
- package/dist/rolldown/shared/logging-CE90D8JR.d.mts +50 -0
- package/dist/rolldown/shared/logs-NH298mHo.mjs +183 -0
- package/dist/rolldown/shared/misc-CCZIsXVO.mjs +22 -0
- package/dist/rolldown/shared/normalize-string-or-regex-DeZqg15i.mjs +61 -0
- package/dist/rolldown/shared/parse-DLraxqjd.mjs +56 -0
- package/dist/rolldown/shared/prompt-DeISmFRp.mjs +847 -0
- package/dist/rolldown/shared/rolldown-O0UKbTKf.mjs +42 -0
- package/dist/rolldown/shared/rolldown-build-BIs7C4B_.mjs +3354 -0
- package/dist/rolldown/shared/watch-DQXGaDjx.mjs +379 -0
- package/dist/tsdown/build-l5WhXg4M-BBPqZr0m.js +4933 -0
- package/dist/tsdown/chunk-CdeBBKNj.js +44 -0
- package/dist/tsdown/debug-Cb_Nqpo4-BueIRvg1.js +18 -0
- package/dist/tsdown/detect-CCATtVj7-B86m8IqW.js +165 -0
- package/dist/tsdown/dist-BUOkzr_P.js +201 -0
- package/dist/tsdown/dist-BVMGwPdF.js +32363 -0
- package/dist/tsdown/dist-dc0X0G6b.js +742 -0
- package/dist/tsdown/filename-7rlgePeo.js +31 -0
- package/dist/tsdown/index-node-BjDys8jy--sqPE5mM.js +251 -0
- package/dist/tsdown/index-types.d.ts +2163 -0
- package/dist/tsdown/index.js +14 -0
- package/dist/tsdown/main-d9yZSQqW.js +926 -0
- package/dist/tsdown/node-Cb5OsnKg.js +271 -0
- package/dist/tsdown/npm_cjs_chunk_chunk.cjs +11 -0
- package/dist/tsdown/npm_cjs_chunk_range.cjs +484 -0
- package/dist/tsdown/npm_cjs_chunk_semver.cjs +362 -0
- package/dist/tsdown/npm_entry_picomatch.cjs +1676 -0
- package/dist/tsdown/npm_entry_semver_functions_coerce.cjs +52 -0
- package/dist/tsdown/npm_entry_semver_functions_satisfies.cjs +23 -0
- package/dist/tsdown/npm_entry_semver_ranges_min-version.cjs +48 -0
- package/dist/tsdown/npm_entry_tree-kill.cjs +103 -0
- package/dist/tsdown/resolver-j7HY1N36-CIu_7LX6.js +20 -0
- package/dist/tsdown/run.js +537 -0
- package/dist/tsdown/tsc-context-BNYuT3cE.js +25 -0
- package/dist/tsdown/tsc-reo6aLWc.js +423 -0
- package/dist/vite/client/client.mjs +1140 -0
- package/dist/vite/client/env.mjs +19 -0
- package/dist/vite/client.d.ts +279 -0
- package/dist/vite/misc/false.d.ts +2 -0
- package/dist/vite/misc/false.js +1 -0
- package/dist/vite/misc/true.d.ts +2 -0
- package/dist/vite/misc/true.js +1 -0
- package/dist/vite/node/chunks/build2.js +5538 -0
- package/dist/vite/node/chunks/chunk.js +45 -0
- package/dist/vite/node/chunks/dist.js +6758 -0
- package/dist/vite/node/chunks/dist2.js +6651 -0
- package/dist/vite/node/chunks/fetchableEnvironments.js +41395 -0
- package/dist/vite/node/chunks/lib.js +377 -0
- package/dist/vite/node/chunks/logger.js +332 -0
- package/dist/vite/node/chunks/moduleRunnerTransport.d.ts +96 -0
- package/dist/vite/node/chunks/postcss-import.js +479 -0
- package/dist/vite/node/cli.js +699 -0
- package/dist/vite/node/index.d.ts +3807 -0
- package/dist/vite/node/index.js +15 -0
- package/dist/vite/node/internal.d.ts +2 -0
- package/dist/vite/node/internal.js +3 -0
- package/dist/vite/node/module-runner.d.ts +311 -0
- package/dist/vite/node/module-runner.js +1159 -0
- package/dist/vite/types/customEvent.d.ts +52 -0
- package/dist/vite/types/hmrPayload.d.ts +80 -0
- package/dist/vite/types/hot.d.ts +39 -0
- package/dist/vite/types/import-meta.d.ts +5 -0
- package/dist/vite/types/importGlob.d.ts +89 -0
- package/dist/vite/types/importMeta.d.ts +30 -0
- package/dist/vite/types/internal/cssPreprocessorOptions.d.ts +44 -0
- package/dist/vite/types/internal/esbuildOptions.d.ts +28 -0
- package/dist/vite/types/internal/lightningcssOptions.d.ts +18 -0
- package/dist/vite/types/internal/rollupTypeCompat.d.ts +24 -0
- package/dist/vite/types/internal/terserOptions.d.ts +11 -0
- package/dist/vite/types/metadata.d.ts +47 -0
- package/package.json +204 -0
|
@@ -0,0 +1,1159 @@
|
|
|
1
|
+
let SOURCEMAPPING_URL = "sourceMa";
|
|
2
|
+
SOURCEMAPPING_URL += "ppingURL";
|
|
3
|
+
const isWindows = typeof process < "u" && process.platform === "win32";
|
|
4
|
+
function unwrapId(id) {
|
|
5
|
+
return id.startsWith("/@id/") ? id.slice(5).replace("__x00__", "\0") : id;
|
|
6
|
+
}
|
|
7
|
+
const windowsSlashRE = /\\/g;
|
|
8
|
+
function slash(p) {
|
|
9
|
+
return p.replace(windowsSlashRE, "/");
|
|
10
|
+
}
|
|
11
|
+
const postfixRE = /[?#].*$/;
|
|
12
|
+
function cleanUrl(url) {
|
|
13
|
+
return url.replace(postfixRE, "");
|
|
14
|
+
}
|
|
15
|
+
function isPrimitive(value) {
|
|
16
|
+
return !value || typeof value != "object" && typeof value != "function";
|
|
17
|
+
}
|
|
18
|
+
const AsyncFunction = async function() {}.constructor;
|
|
19
|
+
let asyncFunctionDeclarationPaddingLineCount;
|
|
20
|
+
function getAsyncFunctionDeclarationPaddingLineCount() {
|
|
21
|
+
if (asyncFunctionDeclarationPaddingLineCount === void 0) {
|
|
22
|
+
let body = "/*code*/", source = new AsyncFunction("a", "b", body).toString();
|
|
23
|
+
asyncFunctionDeclarationPaddingLineCount = source.slice(0, source.indexOf(body)).split("\n").length - 1;
|
|
24
|
+
}
|
|
25
|
+
return asyncFunctionDeclarationPaddingLineCount;
|
|
26
|
+
}
|
|
27
|
+
function promiseWithResolvers() {
|
|
28
|
+
let resolve, reject;
|
|
29
|
+
return {
|
|
30
|
+
promise: new Promise((_resolve, _reject) => {
|
|
31
|
+
resolve = _resolve, reject = _reject;
|
|
32
|
+
}),
|
|
33
|
+
resolve,
|
|
34
|
+
reject
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
38
|
+
function normalizeWindowsPath(input = "") {
|
|
39
|
+
return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
40
|
+
}
|
|
41
|
+
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
42
|
+
function cwd() {
|
|
43
|
+
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
|
44
|
+
}
|
|
45
|
+
const resolve = function(...arguments_) {
|
|
46
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
47
|
+
let resolvedPath = "", resolvedAbsolute = !1;
|
|
48
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
49
|
+
let path = index >= 0 ? arguments_[index] : cwd();
|
|
50
|
+
!path || path.length === 0 || (resolvedPath = `${path}/${resolvedPath}`, resolvedAbsolute = isAbsolute(path));
|
|
51
|
+
}
|
|
52
|
+
return resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : ".";
|
|
53
|
+
};
|
|
54
|
+
function normalizeString(path, allowAboveRoot) {
|
|
55
|
+
let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
|
|
56
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
57
|
+
if (index < path.length) char = path[index];
|
|
58
|
+
else if (char === "/") break;
|
|
59
|
+
else char = "/";
|
|
60
|
+
if (char === "/") {
|
|
61
|
+
if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
|
|
62
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
63
|
+
if (res.length > 2) {
|
|
64
|
+
let lastSlashIndex = res.lastIndexOf("/");
|
|
65
|
+
lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
|
|
66
|
+
continue;
|
|
67
|
+
} else if (res.length > 0) {
|
|
68
|
+
res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
|
|
73
|
+
} else res.length > 0 ? res += `/${path.slice(lastSlash + 1, index)}` : res = path.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
|
|
74
|
+
lastSlash = index, dots = 0;
|
|
75
|
+
} else char === "." && dots !== -1 ? ++dots : dots = -1;
|
|
76
|
+
}
|
|
77
|
+
return res;
|
|
78
|
+
}
|
|
79
|
+
const isAbsolute = function(p) {
|
|
80
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
81
|
+
}, dirname = function(p) {
|
|
82
|
+
let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
83
|
+
return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
84
|
+
}, decodeBase64 = typeof atob < "u" ? atob : (str) => Buffer.from(str, "base64").toString("utf-8"), percentRegEx = /%/g, backslashRegEx = /\\/g, newlineRegEx = /\n/g, carriageReturnRegEx = /\r/g, tabRegEx = /\t/g, questionRegex = /\?/g, hashRegex = /#/g;
|
|
85
|
+
function encodePathChars(filepath) {
|
|
86
|
+
return filepath.indexOf("%") !== -1 && (filepath = filepath.replace(percentRegEx, "%25")), !isWindows && filepath.indexOf("\\") !== -1 && (filepath = filepath.replace(backslashRegEx, "%5C")), filepath.indexOf("\n") !== -1 && (filepath = filepath.replace(newlineRegEx, "%0A")), filepath.indexOf("\r") !== -1 && (filepath = filepath.replace(carriageReturnRegEx, "%0D")), filepath.indexOf(" ") !== -1 && (filepath = filepath.replace(tabRegEx, "%09")), filepath;
|
|
87
|
+
}
|
|
88
|
+
const posixDirname = dirname, posixResolve = resolve;
|
|
89
|
+
function posixPathToFileHref(posixPath) {
|
|
90
|
+
let resolved = posixResolve(posixPath), filePathLast = posixPath.charCodeAt(posixPath.length - 1);
|
|
91
|
+
return (filePathLast === 47 || isWindows && filePathLast === 92) && resolved[resolved.length - 1] !== "/" && (resolved += "/"), resolved = encodePathChars(resolved), resolved.indexOf("?") !== -1 && (resolved = resolved.replace(questionRegex, "%3F")), resolved.indexOf("#") !== -1 && (resolved = resolved.replace(hashRegex, "%23")), new URL(`file://${resolved}`).href;
|
|
92
|
+
}
|
|
93
|
+
function toWindowsPath(path) {
|
|
94
|
+
return path.replace(/\//g, "\\");
|
|
95
|
+
}
|
|
96
|
+
var comma = 44, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", intToChar = new Uint8Array(64), charToInt = new Uint8Array(128);
|
|
97
|
+
for (let i = 0; i < chars.length; i++) {
|
|
98
|
+
let c = chars.charCodeAt(i);
|
|
99
|
+
intToChar[i] = c, charToInt[c] = i;
|
|
100
|
+
}
|
|
101
|
+
function decodeInteger(reader, relative) {
|
|
102
|
+
let value = 0, shift = 0, integer = 0;
|
|
103
|
+
do
|
|
104
|
+
integer = charToInt[reader.next()], value |= (integer & 31) << shift, shift += 5;
|
|
105
|
+
while (integer & 32);
|
|
106
|
+
let shouldNegate = value & 1;
|
|
107
|
+
return value >>>= 1, shouldNegate && (value = -2147483648 | -value), relative + value;
|
|
108
|
+
}
|
|
109
|
+
function hasMoreVlq(reader, max) {
|
|
110
|
+
return reader.pos >= max ? !1 : reader.peek() !== comma;
|
|
111
|
+
}
|
|
112
|
+
var StringReader = class {
|
|
113
|
+
constructor(buffer) {
|
|
114
|
+
this.pos = 0, this.buffer = buffer;
|
|
115
|
+
}
|
|
116
|
+
next() {
|
|
117
|
+
return this.buffer.charCodeAt(this.pos++);
|
|
118
|
+
}
|
|
119
|
+
peek() {
|
|
120
|
+
return this.buffer.charCodeAt(this.pos);
|
|
121
|
+
}
|
|
122
|
+
indexOf(char) {
|
|
123
|
+
let { buffer, pos } = this, idx = buffer.indexOf(char, pos);
|
|
124
|
+
return idx === -1 ? buffer.length : idx;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
function decode(mappings) {
|
|
128
|
+
let { length } = mappings, reader = new StringReader(mappings), decoded = [], genColumn = 0, sourcesIndex = 0, sourceLine = 0, sourceColumn = 0, namesIndex = 0;
|
|
129
|
+
do {
|
|
130
|
+
let semi = reader.indexOf(";"), line = [], sorted = !0, lastCol = 0;
|
|
131
|
+
for (genColumn = 0; reader.pos < semi;) {
|
|
132
|
+
let seg;
|
|
133
|
+
genColumn = decodeInteger(reader, genColumn), genColumn < lastCol && (sorted = !1), lastCol = genColumn, hasMoreVlq(reader, semi) ? (sourcesIndex = decodeInteger(reader, sourcesIndex), sourceLine = decodeInteger(reader, sourceLine), sourceColumn = decodeInteger(reader, sourceColumn), hasMoreVlq(reader, semi) ? (namesIndex = decodeInteger(reader, namesIndex), seg = [
|
|
134
|
+
genColumn,
|
|
135
|
+
sourcesIndex,
|
|
136
|
+
sourceLine,
|
|
137
|
+
sourceColumn,
|
|
138
|
+
namesIndex
|
|
139
|
+
]) : seg = [
|
|
140
|
+
genColumn,
|
|
141
|
+
sourcesIndex,
|
|
142
|
+
sourceLine,
|
|
143
|
+
sourceColumn
|
|
144
|
+
]) : seg = [genColumn], line.push(seg), reader.pos++;
|
|
145
|
+
}
|
|
146
|
+
sorted || sort(line), decoded.push(line), reader.pos = semi + 1;
|
|
147
|
+
} while (reader.pos <= length);
|
|
148
|
+
return decoded;
|
|
149
|
+
}
|
|
150
|
+
function sort(line) {
|
|
151
|
+
line.sort(sortComparator);
|
|
152
|
+
}
|
|
153
|
+
function sortComparator(a, b) {
|
|
154
|
+
return a[0] - b[0];
|
|
155
|
+
}
|
|
156
|
+
var COLUMN = 0, SOURCES_INDEX = 1, SOURCE_LINE = 2, SOURCE_COLUMN = 3, NAMES_INDEX = 4, found = !1;
|
|
157
|
+
function binarySearch(haystack, needle, low, high) {
|
|
158
|
+
for (; low <= high;) {
|
|
159
|
+
let mid = low + (high - low >> 1), cmp = haystack[mid][COLUMN] - needle;
|
|
160
|
+
if (cmp === 0) return found = !0, mid;
|
|
161
|
+
cmp < 0 ? low = mid + 1 : high = mid - 1;
|
|
162
|
+
}
|
|
163
|
+
return found = !1, low - 1;
|
|
164
|
+
}
|
|
165
|
+
function upperBound(haystack, needle, index) {
|
|
166
|
+
for (let i = index + 1; i < haystack.length && haystack[i][COLUMN] === needle; index = i++);
|
|
167
|
+
return index;
|
|
168
|
+
}
|
|
169
|
+
function lowerBound(haystack, needle, index) {
|
|
170
|
+
for (let i = index - 1; i >= 0 && haystack[i][COLUMN] === needle; index = i--);
|
|
171
|
+
return index;
|
|
172
|
+
}
|
|
173
|
+
function memoizedBinarySearch(haystack, needle, state, key) {
|
|
174
|
+
let { lastKey, lastNeedle, lastIndex } = state, low = 0, high = haystack.length - 1;
|
|
175
|
+
if (key === lastKey) {
|
|
176
|
+
if (needle === lastNeedle) return found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle, lastIndex;
|
|
177
|
+
needle >= lastNeedle ? low = lastIndex === -1 ? 0 : lastIndex : high = lastIndex;
|
|
178
|
+
}
|
|
179
|
+
return state.lastKey = key, state.lastNeedle = needle, state.lastIndex = binarySearch(haystack, needle, low, high);
|
|
180
|
+
}
|
|
181
|
+
var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)", COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)", LEAST_UPPER_BOUND = -1, GREATEST_LOWER_BOUND = 1;
|
|
182
|
+
function cast(map) {
|
|
183
|
+
return map;
|
|
184
|
+
}
|
|
185
|
+
function decodedMappings(map) {
|
|
186
|
+
var _a;
|
|
187
|
+
return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
|
|
188
|
+
}
|
|
189
|
+
function originalPositionFor(map, needle) {
|
|
190
|
+
let { line, column, bias } = needle;
|
|
191
|
+
if (line--, line < 0) throw Error(LINE_GTR_ZERO);
|
|
192
|
+
if (column < 0) throw Error(COL_GTR_EQ_ZERO);
|
|
193
|
+
let decoded = decodedMappings(map);
|
|
194
|
+
if (line >= decoded.length) return OMapping(null, null, null, null);
|
|
195
|
+
let segments = decoded[line], index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
|
|
196
|
+
if (index === -1) return OMapping(null, null, null, null);
|
|
197
|
+
let segment = segments[index];
|
|
198
|
+
if (segment.length === 1) return OMapping(null, null, null, null);
|
|
199
|
+
let { names, resolvedSources } = map;
|
|
200
|
+
return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
|
|
201
|
+
}
|
|
202
|
+
function OMapping(source, line, column, name) {
|
|
203
|
+
return {
|
|
204
|
+
source,
|
|
205
|
+
line,
|
|
206
|
+
column,
|
|
207
|
+
name
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
211
|
+
let index = memoizedBinarySearch(segments, column, memo, line);
|
|
212
|
+
return found ? index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index) : bias === LEAST_UPPER_BOUND && index++, index === -1 || index === segments.length ? -1 : index;
|
|
213
|
+
}
|
|
214
|
+
var DecodedMap = class {
|
|
215
|
+
_encoded;
|
|
216
|
+
_decoded;
|
|
217
|
+
_decodedMemo;
|
|
218
|
+
url;
|
|
219
|
+
file;
|
|
220
|
+
version;
|
|
221
|
+
names = [];
|
|
222
|
+
resolvedSources;
|
|
223
|
+
constructor(map, from) {
|
|
224
|
+
this.map = map;
|
|
225
|
+
let { mappings, names, sources } = map;
|
|
226
|
+
this.version = map.version, this.names = names || [], this._encoded = mappings || "", this._decodedMemo = memoizedState(), this.url = from, this.file = from;
|
|
227
|
+
let originDir = posixDirname(from);
|
|
228
|
+
this.resolvedSources = (sources || []).map((s) => posixResolve(originDir, s || ""));
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
function memoizedState() {
|
|
232
|
+
return {
|
|
233
|
+
lastKey: -1,
|
|
234
|
+
lastNeedle: -1,
|
|
235
|
+
lastIndex: -1
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function getOriginalPosition(map, needle) {
|
|
239
|
+
let result = originalPositionFor(map, needle);
|
|
240
|
+
return result.column == null ? null : result;
|
|
241
|
+
}
|
|
242
|
+
const MODULE_RUNNER_SOURCEMAPPING_REGEXP = RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json;base64,(.+)`);
|
|
243
|
+
var EvaluatedModuleNode = class {
|
|
244
|
+
importers = /* @__PURE__ */ new Set();
|
|
245
|
+
imports = /* @__PURE__ */ new Set();
|
|
246
|
+
evaluated = !1;
|
|
247
|
+
meta;
|
|
248
|
+
promise;
|
|
249
|
+
exports;
|
|
250
|
+
file;
|
|
251
|
+
map;
|
|
252
|
+
constructor(id, url) {
|
|
253
|
+
this.id = id, this.url = url, this.file = cleanUrl(id);
|
|
254
|
+
}
|
|
255
|
+
}, EvaluatedModules = class {
|
|
256
|
+
idToModuleMap = /* @__PURE__ */ new Map();
|
|
257
|
+
fileToModulesMap = /* @__PURE__ */ new Map();
|
|
258
|
+
urlToIdModuleMap = /* @__PURE__ */ new Map();
|
|
259
|
+
getModuleById(id) {
|
|
260
|
+
return this.idToModuleMap.get(id);
|
|
261
|
+
}
|
|
262
|
+
getModulesByFile(file) {
|
|
263
|
+
return this.fileToModulesMap.get(file);
|
|
264
|
+
}
|
|
265
|
+
getModuleByUrl(url) {
|
|
266
|
+
return this.urlToIdModuleMap.get(unwrapId(url));
|
|
267
|
+
}
|
|
268
|
+
ensureModule(id, url) {
|
|
269
|
+
if (id = normalizeModuleId(id), this.idToModuleMap.has(id)) {
|
|
270
|
+
let moduleNode = this.idToModuleMap.get(id);
|
|
271
|
+
return this.urlToIdModuleMap.set(url, moduleNode), moduleNode;
|
|
272
|
+
}
|
|
273
|
+
let moduleNode = new EvaluatedModuleNode(id, url);
|
|
274
|
+
this.idToModuleMap.set(id, moduleNode), this.urlToIdModuleMap.set(url, moduleNode);
|
|
275
|
+
let fileModules = this.fileToModulesMap.get(moduleNode.file) || /* @__PURE__ */ new Set();
|
|
276
|
+
return fileModules.add(moduleNode), this.fileToModulesMap.set(moduleNode.file, fileModules), moduleNode;
|
|
277
|
+
}
|
|
278
|
+
invalidateModule(node) {
|
|
279
|
+
node.evaluated = !1, node.meta = void 0, node.map = void 0, node.promise = void 0, node.exports = void 0, node.imports.clear();
|
|
280
|
+
}
|
|
281
|
+
getModuleSourceMapById(id) {
|
|
282
|
+
let mod = this.getModuleById(id);
|
|
283
|
+
if (!mod) return null;
|
|
284
|
+
if (mod.map) return mod.map;
|
|
285
|
+
if (!mod.meta || !("code" in mod.meta)) return null;
|
|
286
|
+
let pattern = `//# ${SOURCEMAPPING_URL}=data:application/json;base64,`, lastIndex = mod.meta.code.lastIndexOf(pattern);
|
|
287
|
+
if (lastIndex === -1) return null;
|
|
288
|
+
let mapString = MODULE_RUNNER_SOURCEMAPPING_REGEXP.exec(mod.meta.code.slice(lastIndex))?.[1];
|
|
289
|
+
return mapString ? (mod.map = new DecodedMap(JSON.parse(decodeBase64(mapString)), mod.file), mod.map) : null;
|
|
290
|
+
}
|
|
291
|
+
clear() {
|
|
292
|
+
this.idToModuleMap.clear(), this.fileToModulesMap.clear(), this.urlToIdModuleMap.clear();
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
const prefixedBuiltins = new Set([
|
|
296
|
+
"node:sea",
|
|
297
|
+
"node:sqlite",
|
|
298
|
+
"node:test",
|
|
299
|
+
"node:test/reporters"
|
|
300
|
+
]);
|
|
301
|
+
function normalizeModuleId(file) {
|
|
302
|
+
return prefixedBuiltins.has(file) ? file : slash(file).replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^node:/, "").replace(/^\/+/, "/").replace(/^file:\/+/, isWindows ? "" : "/");
|
|
303
|
+
}
|
|
304
|
+
var HMRContext = class {
|
|
305
|
+
newListeners;
|
|
306
|
+
constructor(hmrClient, ownerPath) {
|
|
307
|
+
this.hmrClient = hmrClient, this.ownerPath = ownerPath, hmrClient.dataMap.has(ownerPath) || hmrClient.dataMap.set(ownerPath, {});
|
|
308
|
+
let mod = hmrClient.hotModulesMap.get(ownerPath);
|
|
309
|
+
mod && (mod.callbacks = []);
|
|
310
|
+
let staleListeners = hmrClient.ctxToListenersMap.get(ownerPath);
|
|
311
|
+
if (staleListeners) for (let [event, staleFns] of staleListeners) {
|
|
312
|
+
let listeners = hmrClient.customListenersMap.get(event);
|
|
313
|
+
listeners && hmrClient.customListenersMap.set(event, listeners.filter((l) => !staleFns.includes(l)));
|
|
314
|
+
}
|
|
315
|
+
this.newListeners = /* @__PURE__ */ new Map(), hmrClient.ctxToListenersMap.set(ownerPath, this.newListeners);
|
|
316
|
+
}
|
|
317
|
+
get data() {
|
|
318
|
+
return this.hmrClient.dataMap.get(this.ownerPath);
|
|
319
|
+
}
|
|
320
|
+
accept(deps, callback) {
|
|
321
|
+
if (typeof deps == "function" || !deps) this.acceptDeps([this.ownerPath], ([mod]) => deps?.(mod));
|
|
322
|
+
else if (typeof deps == "string") this.acceptDeps([deps], ([mod]) => callback?.(mod));
|
|
323
|
+
else if (Array.isArray(deps)) this.acceptDeps(deps, callback);
|
|
324
|
+
else throw Error("invalid hot.accept() usage.");
|
|
325
|
+
}
|
|
326
|
+
acceptExports(_, callback) {
|
|
327
|
+
this.acceptDeps([this.ownerPath], ([mod]) => callback?.(mod));
|
|
328
|
+
}
|
|
329
|
+
dispose(cb) {
|
|
330
|
+
this.hmrClient.disposeMap.set(this.ownerPath, cb);
|
|
331
|
+
}
|
|
332
|
+
prune(cb) {
|
|
333
|
+
this.hmrClient.pruneMap.set(this.ownerPath, cb);
|
|
334
|
+
}
|
|
335
|
+
decline() {}
|
|
336
|
+
invalidate(message) {
|
|
337
|
+
let firstInvalidatedBy = this.hmrClient.currentFirstInvalidatedBy ?? this.ownerPath;
|
|
338
|
+
this.hmrClient.notifyListeners("vite:invalidate", {
|
|
339
|
+
path: this.ownerPath,
|
|
340
|
+
message,
|
|
341
|
+
firstInvalidatedBy
|
|
342
|
+
}), this.send("vite:invalidate", {
|
|
343
|
+
path: this.ownerPath,
|
|
344
|
+
message,
|
|
345
|
+
firstInvalidatedBy
|
|
346
|
+
}), this.hmrClient.logger.debug(`invalidate ${this.ownerPath}${message ? `: ${message}` : ""}`);
|
|
347
|
+
}
|
|
348
|
+
on(event, cb) {
|
|
349
|
+
let addToMap = (map) => {
|
|
350
|
+
let existing = map.get(event) || [];
|
|
351
|
+
existing.push(cb), map.set(event, existing);
|
|
352
|
+
};
|
|
353
|
+
addToMap(this.hmrClient.customListenersMap), addToMap(this.newListeners);
|
|
354
|
+
}
|
|
355
|
+
off(event, cb) {
|
|
356
|
+
let removeFromMap = (map) => {
|
|
357
|
+
let existing = map.get(event);
|
|
358
|
+
if (existing === void 0) return;
|
|
359
|
+
let pruned = existing.filter((l) => l !== cb);
|
|
360
|
+
if (pruned.length === 0) {
|
|
361
|
+
map.delete(event);
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
map.set(event, pruned);
|
|
365
|
+
};
|
|
366
|
+
removeFromMap(this.hmrClient.customListenersMap), removeFromMap(this.newListeners);
|
|
367
|
+
}
|
|
368
|
+
send(event, data) {
|
|
369
|
+
this.hmrClient.send({
|
|
370
|
+
type: "custom",
|
|
371
|
+
event,
|
|
372
|
+
data
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
acceptDeps(deps, callback = () => {}) {
|
|
376
|
+
let mod = this.hmrClient.hotModulesMap.get(this.ownerPath) || {
|
|
377
|
+
id: this.ownerPath,
|
|
378
|
+
callbacks: []
|
|
379
|
+
};
|
|
380
|
+
mod.callbacks.push({
|
|
381
|
+
deps,
|
|
382
|
+
fn: callback
|
|
383
|
+
}), this.hmrClient.hotModulesMap.set(this.ownerPath, mod);
|
|
384
|
+
}
|
|
385
|
+
}, HMRClient = class {
|
|
386
|
+
hotModulesMap = /* @__PURE__ */ new Map();
|
|
387
|
+
disposeMap = /* @__PURE__ */ new Map();
|
|
388
|
+
pruneMap = /* @__PURE__ */ new Map();
|
|
389
|
+
dataMap = /* @__PURE__ */ new Map();
|
|
390
|
+
customListenersMap = /* @__PURE__ */ new Map();
|
|
391
|
+
ctxToListenersMap = /* @__PURE__ */ new Map();
|
|
392
|
+
currentFirstInvalidatedBy;
|
|
393
|
+
constructor(logger, transport, importUpdatedModule) {
|
|
394
|
+
this.logger = logger, this.transport = transport, this.importUpdatedModule = importUpdatedModule;
|
|
395
|
+
}
|
|
396
|
+
async notifyListeners(event, data) {
|
|
397
|
+
let cbs = this.customListenersMap.get(event);
|
|
398
|
+
cbs && await Promise.allSettled(cbs.map((cb) => cb(data)));
|
|
399
|
+
}
|
|
400
|
+
send(payload) {
|
|
401
|
+
this.transport.send(payload).catch((err) => {
|
|
402
|
+
this.logger.error(err);
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
clear() {
|
|
406
|
+
this.hotModulesMap.clear(), this.disposeMap.clear(), this.pruneMap.clear(), this.dataMap.clear(), this.customListenersMap.clear(), this.ctxToListenersMap.clear();
|
|
407
|
+
}
|
|
408
|
+
async prunePaths(paths) {
|
|
409
|
+
await Promise.all(paths.map((path) => {
|
|
410
|
+
let disposer = this.disposeMap.get(path);
|
|
411
|
+
if (disposer) return disposer(this.dataMap.get(path));
|
|
412
|
+
})), await Promise.all(paths.map((path) => {
|
|
413
|
+
let fn = this.pruneMap.get(path);
|
|
414
|
+
if (fn) return fn(this.dataMap.get(path));
|
|
415
|
+
}));
|
|
416
|
+
}
|
|
417
|
+
warnFailedUpdate(err, path) {
|
|
418
|
+
(!(err instanceof Error) || !err.message.includes("fetch")) && this.logger.error(err), this.logger.error(`Failed to reload ${path}. This could be due to syntax errors or importing non-existent modules. (see errors above)`);
|
|
419
|
+
}
|
|
420
|
+
updateQueue = [];
|
|
421
|
+
pendingUpdateQueue = !1;
|
|
422
|
+
async queueUpdate(payload) {
|
|
423
|
+
if (this.updateQueue.push(this.fetchUpdate(payload)), !this.pendingUpdateQueue) {
|
|
424
|
+
this.pendingUpdateQueue = !0, await Promise.resolve(), this.pendingUpdateQueue = !1;
|
|
425
|
+
let loading = [...this.updateQueue];
|
|
426
|
+
this.updateQueue = [], (await Promise.all(loading)).forEach((fn) => fn && fn());
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
async fetchUpdate(update) {
|
|
430
|
+
let { path, acceptedPath, firstInvalidatedBy } = update, mod = this.hotModulesMap.get(path);
|
|
431
|
+
if (!mod) return;
|
|
432
|
+
let fetchedModule, isSelfUpdate = path === acceptedPath, qualifiedCallbacks = mod.callbacks.filter(({ deps }) => deps.includes(acceptedPath));
|
|
433
|
+
if (isSelfUpdate || qualifiedCallbacks.length > 0) {
|
|
434
|
+
let disposer = this.disposeMap.get(acceptedPath);
|
|
435
|
+
disposer && await disposer(this.dataMap.get(acceptedPath));
|
|
436
|
+
try {
|
|
437
|
+
fetchedModule = await this.importUpdatedModule(update);
|
|
438
|
+
} catch (e) {
|
|
439
|
+
this.warnFailedUpdate(e, acceptedPath);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
return () => {
|
|
443
|
+
try {
|
|
444
|
+
this.currentFirstInvalidatedBy = firstInvalidatedBy;
|
|
445
|
+
for (let { deps, fn } of qualifiedCallbacks) fn(deps.map((dep) => dep === acceptedPath ? fetchedModule : void 0));
|
|
446
|
+
let loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
|
|
447
|
+
this.logger.debug(`hot updated: ${loggedPath}`);
|
|
448
|
+
} finally {
|
|
449
|
+
this.currentFirstInvalidatedBy = void 0;
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
function analyzeImportedModDifference(mod, rawId, moduleType, metadata) {
|
|
455
|
+
if (!metadata?.isDynamicImport && metadata?.importedNames?.length) {
|
|
456
|
+
let missingBindings = metadata.importedNames.filter((s) => !(s in mod));
|
|
457
|
+
if (missingBindings.length) {
|
|
458
|
+
let lastBinding = missingBindings[missingBindings.length - 1];
|
|
459
|
+
throw moduleType === "module" ? SyntaxError(`[vite] The requested module '${rawId}' does not provide an export named '${lastBinding}'`) : SyntaxError(`\
|
|
460
|
+
[vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
|
|
461
|
+
CommonJS modules can always be imported via the default export, for example using:
|
|
462
|
+
|
|
463
|
+
import pkg from '${rawId}';
|
|
464
|
+
const {${missingBindings.join(", ")}} = pkg;
|
|
465
|
+
`);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
let nanoid = (size = 21) => {
|
|
470
|
+
let id = "", i = size | 0;
|
|
471
|
+
for (; i--;) id += "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[Math.random() * 64 | 0];
|
|
472
|
+
return id;
|
|
473
|
+
};
|
|
474
|
+
function reviveInvokeError(e) {
|
|
475
|
+
let error = Error(e.message || "Unknown invoke error");
|
|
476
|
+
return Object.assign(error, e, { runnerError: /* @__PURE__ */ Error("RunnerError") }), error;
|
|
477
|
+
}
|
|
478
|
+
const createInvokeableTransport = (transport) => {
|
|
479
|
+
if (transport.invoke) return {
|
|
480
|
+
...transport,
|
|
481
|
+
async invoke(name, data) {
|
|
482
|
+
let result = await transport.invoke({
|
|
483
|
+
type: "custom",
|
|
484
|
+
event: "vite:invoke",
|
|
485
|
+
data: {
|
|
486
|
+
id: "send",
|
|
487
|
+
name,
|
|
488
|
+
data
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
if ("error" in result) throw reviveInvokeError(result.error);
|
|
492
|
+
return result.result;
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
if (!transport.send || !transport.connect) throw Error("transport must implement send and connect when invoke is not implemented");
|
|
496
|
+
let rpcPromises = /* @__PURE__ */ new Map();
|
|
497
|
+
return {
|
|
498
|
+
...transport,
|
|
499
|
+
connect({ onMessage, onDisconnection }) {
|
|
500
|
+
return transport.connect({
|
|
501
|
+
onMessage(payload) {
|
|
502
|
+
if (payload.type === "custom" && payload.event === "vite:invoke") {
|
|
503
|
+
let data = payload.data;
|
|
504
|
+
if (data.id.startsWith("response:")) {
|
|
505
|
+
let invokeId = data.id.slice(9), promise = rpcPromises.get(invokeId);
|
|
506
|
+
if (!promise) return;
|
|
507
|
+
promise.timeoutId && clearTimeout(promise.timeoutId), rpcPromises.delete(invokeId);
|
|
508
|
+
let { error, result } = data.data;
|
|
509
|
+
error ? promise.reject(error) : promise.resolve(result);
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
onMessage(payload);
|
|
514
|
+
},
|
|
515
|
+
onDisconnection
|
|
516
|
+
});
|
|
517
|
+
},
|
|
518
|
+
disconnect() {
|
|
519
|
+
return rpcPromises.forEach((promise) => {
|
|
520
|
+
promise.reject(/* @__PURE__ */ Error(`transport was disconnected, cannot call ${JSON.stringify(promise.name)}`));
|
|
521
|
+
}), rpcPromises.clear(), transport.disconnect?.();
|
|
522
|
+
},
|
|
523
|
+
send(data) {
|
|
524
|
+
return transport.send(data);
|
|
525
|
+
},
|
|
526
|
+
async invoke(name, data) {
|
|
527
|
+
let promiseId = nanoid(), wrappedData = {
|
|
528
|
+
type: "custom",
|
|
529
|
+
event: "vite:invoke",
|
|
530
|
+
data: {
|
|
531
|
+
name,
|
|
532
|
+
id: `send:${promiseId}`,
|
|
533
|
+
data
|
|
534
|
+
}
|
|
535
|
+
}, sendPromise = transport.send(wrappedData), { promise, resolve, reject } = promiseWithResolvers(), timeout = transport.timeout ?? 6e4, timeoutId;
|
|
536
|
+
timeout > 0 && (timeoutId = setTimeout(() => {
|
|
537
|
+
rpcPromises.delete(promiseId), reject(/* @__PURE__ */ Error(`transport invoke timed out after ${timeout}ms (data: ${JSON.stringify(wrappedData)})`));
|
|
538
|
+
}, timeout), timeoutId?.unref?.()), rpcPromises.set(promiseId, {
|
|
539
|
+
resolve,
|
|
540
|
+
reject,
|
|
541
|
+
name,
|
|
542
|
+
timeoutId
|
|
543
|
+
}), sendPromise && sendPromise.catch((err) => {
|
|
544
|
+
clearTimeout(timeoutId), rpcPromises.delete(promiseId), reject(err);
|
|
545
|
+
});
|
|
546
|
+
try {
|
|
547
|
+
return await promise;
|
|
548
|
+
} catch (err) {
|
|
549
|
+
throw reviveInvokeError(err);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
}, normalizeModuleRunnerTransport = (transport) => {
|
|
554
|
+
let invokeableTransport = createInvokeableTransport(transport), isConnected = !invokeableTransport.connect, connectingPromise;
|
|
555
|
+
return {
|
|
556
|
+
...transport,
|
|
557
|
+
...invokeableTransport.connect ? { async connect(onMessage) {
|
|
558
|
+
if (isConnected) return;
|
|
559
|
+
if (connectingPromise) {
|
|
560
|
+
await connectingPromise;
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
let maybePromise = invokeableTransport.connect({
|
|
564
|
+
onMessage: onMessage ?? (() => {}),
|
|
565
|
+
onDisconnection() {
|
|
566
|
+
isConnected = !1;
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
maybePromise && (connectingPromise = maybePromise, await connectingPromise, connectingPromise = void 0), isConnected = !0;
|
|
570
|
+
} } : {},
|
|
571
|
+
...invokeableTransport.disconnect ? { async disconnect() {
|
|
572
|
+
isConnected && (connectingPromise && await connectingPromise, isConnected = !1, await invokeableTransport.disconnect());
|
|
573
|
+
} } : {},
|
|
574
|
+
async send(data) {
|
|
575
|
+
if (invokeableTransport.send) {
|
|
576
|
+
if (!isConnected) if (connectingPromise) await connectingPromise;
|
|
577
|
+
else throw Error("send was called before connect");
|
|
578
|
+
await invokeableTransport.send(data);
|
|
579
|
+
}
|
|
580
|
+
},
|
|
581
|
+
async invoke(name, data) {
|
|
582
|
+
if (!isConnected) if (connectingPromise) await connectingPromise;
|
|
583
|
+
else throw Error("invoke was called before connect");
|
|
584
|
+
return invokeableTransport.invoke(name, data);
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
}, createWebSocketModuleRunnerTransport = (options) => {
|
|
588
|
+
let pingInterval = options.pingInterval ?? 3e4, ws, pingIntervalId;
|
|
589
|
+
return {
|
|
590
|
+
async connect({ onMessage, onDisconnection }) {
|
|
591
|
+
let socket = options.createConnection();
|
|
592
|
+
socket.addEventListener("message", async ({ data }) => {
|
|
593
|
+
onMessage(JSON.parse(data));
|
|
594
|
+
});
|
|
595
|
+
let isOpened = socket.readyState === socket.OPEN;
|
|
596
|
+
isOpened || await new Promise((resolve, reject) => {
|
|
597
|
+
socket.addEventListener("open", () => {
|
|
598
|
+
isOpened = !0, resolve();
|
|
599
|
+
}, { once: !0 }), socket.addEventListener("close", async () => {
|
|
600
|
+
if (!isOpened) {
|
|
601
|
+
reject(/* @__PURE__ */ Error("WebSocket closed without opened."));
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
onMessage({
|
|
605
|
+
type: "custom",
|
|
606
|
+
event: "vite:ws:disconnect",
|
|
607
|
+
data: { webSocket: socket }
|
|
608
|
+
}), onDisconnection();
|
|
609
|
+
});
|
|
610
|
+
}), onMessage({
|
|
611
|
+
type: "custom",
|
|
612
|
+
event: "vite:ws:connect",
|
|
613
|
+
data: { webSocket: socket }
|
|
614
|
+
}), ws = socket, pingIntervalId = setInterval(() => {
|
|
615
|
+
socket.readyState === socket.OPEN && socket.send(JSON.stringify({ type: "ping" }));
|
|
616
|
+
}, pingInterval);
|
|
617
|
+
},
|
|
618
|
+
disconnect() {
|
|
619
|
+
clearInterval(pingIntervalId), ws?.close();
|
|
620
|
+
},
|
|
621
|
+
send(data) {
|
|
622
|
+
ws.send(JSON.stringify(data));
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
};
|
|
626
|
+
function createIsBuiltin(builtins) {
|
|
627
|
+
let plainBuiltinsSet = new Set(builtins.filter((builtin) => typeof builtin == "string")), regexBuiltins = builtins.filter((builtin) => typeof builtin != "string");
|
|
628
|
+
return (id) => plainBuiltinsSet.has(id) || regexBuiltins.some((regexp) => regexp.test(id));
|
|
629
|
+
}
|
|
630
|
+
const ssrModuleExportsKey = "__vite_ssr_exports__", ssrImportKey = "__vite_ssr_import__", ssrDynamicImportKey = "__vite_ssr_dynamic_import__", ssrExportAllKey = "__vite_ssr_exportAll__", ssrExportNameKey = "__vite_ssr_exportName__", ssrImportMetaKey = "__vite_ssr_import_meta__", noop = () => {}, silentConsole = {
|
|
631
|
+
debug: noop,
|
|
632
|
+
error: noop
|
|
633
|
+
}, hmrLogger = {
|
|
634
|
+
debug: (...msg) => console.log("[vite]", ...msg),
|
|
635
|
+
error: (error) => console.log("[vite]", error)
|
|
636
|
+
};
|
|
637
|
+
function createHMRHandler(handler) {
|
|
638
|
+
let queue = new Queue();
|
|
639
|
+
return (payload) => queue.enqueue(() => handler(payload));
|
|
640
|
+
}
|
|
641
|
+
var Queue = class {
|
|
642
|
+
queue = [];
|
|
643
|
+
pending = !1;
|
|
644
|
+
enqueue(promise) {
|
|
645
|
+
return new Promise((resolve, reject) => {
|
|
646
|
+
this.queue.push({
|
|
647
|
+
promise,
|
|
648
|
+
resolve,
|
|
649
|
+
reject
|
|
650
|
+
}), this.dequeue();
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
dequeue() {
|
|
654
|
+
if (this.pending) return !1;
|
|
655
|
+
let item = this.queue.shift();
|
|
656
|
+
return item ? (this.pending = !0, item.promise().then(item.resolve).catch(item.reject).finally(() => {
|
|
657
|
+
this.pending = !1, this.dequeue();
|
|
658
|
+
}), !0) : !1;
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
function createHMRHandlerForRunner(runner) {
|
|
662
|
+
return createHMRHandler(async (payload) => {
|
|
663
|
+
let hmrClient = runner.hmrClient;
|
|
664
|
+
if (!(!hmrClient || runner.isClosed())) switch (payload.type) {
|
|
665
|
+
case "connected":
|
|
666
|
+
hmrClient.logger.debug("connected.");
|
|
667
|
+
break;
|
|
668
|
+
case "update":
|
|
669
|
+
await hmrClient.notifyListeners("vite:beforeUpdate", payload), await Promise.all(payload.updates.map(async (update) => {
|
|
670
|
+
if (update.type === "js-update") return update.acceptedPath = unwrapId(update.acceptedPath), update.path = unwrapId(update.path), hmrClient.queueUpdate(update);
|
|
671
|
+
hmrClient.logger.error("css hmr is not supported in runner mode.");
|
|
672
|
+
})), await hmrClient.notifyListeners("vite:afterUpdate", payload);
|
|
673
|
+
break;
|
|
674
|
+
case "custom":
|
|
675
|
+
await hmrClient.notifyListeners(payload.event, payload.data);
|
|
676
|
+
break;
|
|
677
|
+
case "full-reload": {
|
|
678
|
+
let { triggeredBy } = payload, clearEntrypointUrls = triggeredBy ? getModulesEntrypoints(runner, getModulesByFile(runner, slash(triggeredBy))) : findAllEntrypoints(runner);
|
|
679
|
+
if (!clearEntrypointUrls.size) break;
|
|
680
|
+
hmrClient.logger.debug("program reload"), await hmrClient.notifyListeners("vite:beforeFullReload", payload), runner.evaluatedModules.clear();
|
|
681
|
+
for (let url of clearEntrypointUrls) try {
|
|
682
|
+
await runner.import(url);
|
|
683
|
+
} catch (err) {
|
|
684
|
+
err.code !== "ERR_OUTDATED_OPTIMIZED_DEP" && hmrClient.logger.error(`An error happened during full reload\n${err.message}\n${err.stack}`);
|
|
685
|
+
}
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
case "prune":
|
|
689
|
+
await hmrClient.notifyListeners("vite:beforePrune", payload), await hmrClient.prunePaths(payload.paths);
|
|
690
|
+
break;
|
|
691
|
+
case "error": {
|
|
692
|
+
await hmrClient.notifyListeners("vite:error", payload);
|
|
693
|
+
let err = payload.err;
|
|
694
|
+
hmrClient.logger.error(`Internal Server Error\n${err.message}\n${err.stack}`);
|
|
695
|
+
break;
|
|
696
|
+
}
|
|
697
|
+
case "ping": break;
|
|
698
|
+
default: return payload;
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
function getModulesByFile(runner, file) {
|
|
703
|
+
let nodes = runner.evaluatedModules.getModulesByFile(file);
|
|
704
|
+
return nodes ? [...nodes].map((node) => node.id) : [];
|
|
705
|
+
}
|
|
706
|
+
function getModulesEntrypoints(runner, modules, visited = /* @__PURE__ */ new Set(), entrypoints = /* @__PURE__ */ new Set()) {
|
|
707
|
+
for (let moduleId of modules) {
|
|
708
|
+
if (visited.has(moduleId)) continue;
|
|
709
|
+
visited.add(moduleId);
|
|
710
|
+
let module = runner.evaluatedModules.getModuleById(moduleId);
|
|
711
|
+
if (module) {
|
|
712
|
+
if (!module.importers.size) {
|
|
713
|
+
entrypoints.add(module.url);
|
|
714
|
+
continue;
|
|
715
|
+
}
|
|
716
|
+
for (let importer of module.importers) getModulesEntrypoints(runner, [importer], visited, entrypoints);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
return entrypoints;
|
|
720
|
+
}
|
|
721
|
+
function findAllEntrypoints(runner, entrypoints = /* @__PURE__ */ new Set()) {
|
|
722
|
+
for (let mod of runner.evaluatedModules.idToModuleMap.values()) mod.importers.size || entrypoints.add(mod.url);
|
|
723
|
+
return entrypoints;
|
|
724
|
+
}
|
|
725
|
+
const sourceMapCache = {}, fileContentsCache = {}, evaluatedModulesCache = /* @__PURE__ */ new Set(), retrieveFileHandlers = /* @__PURE__ */ new Set(), retrieveSourceMapHandlers = /* @__PURE__ */ new Set(), createExecHandlers = (handlers) => ((...args) => {
|
|
726
|
+
for (let handler of handlers) {
|
|
727
|
+
let result = handler(...args);
|
|
728
|
+
if (result) return result;
|
|
729
|
+
}
|
|
730
|
+
return null;
|
|
731
|
+
}), retrieveFileFromHandlers = createExecHandlers(retrieveFileHandlers), retrieveSourceMapFromHandlers = createExecHandlers(retrieveSourceMapHandlers);
|
|
732
|
+
let overridden = !1;
|
|
733
|
+
const originalPrepare = Error.prepareStackTrace;
|
|
734
|
+
function resetInterceptor(runner, options) {
|
|
735
|
+
evaluatedModulesCache.delete(runner.evaluatedModules), options.retrieveFile && retrieveFileHandlers.delete(options.retrieveFile), options.retrieveSourceMap && retrieveSourceMapHandlers.delete(options.retrieveSourceMap), evaluatedModulesCache.size === 0 && (Error.prepareStackTrace = originalPrepare, overridden = !1);
|
|
736
|
+
}
|
|
737
|
+
function interceptStackTrace(runner, options = {}) {
|
|
738
|
+
return overridden ||= (Error.prepareStackTrace = prepareStackTrace, !0), evaluatedModulesCache.add(runner.evaluatedModules), options.retrieveFile && retrieveFileHandlers.add(options.retrieveFile), options.retrieveSourceMap && retrieveSourceMapHandlers.add(options.retrieveSourceMap), () => resetInterceptor(runner, options);
|
|
739
|
+
}
|
|
740
|
+
function supportRelativeURL(file, url) {
|
|
741
|
+
if (!file) return url;
|
|
742
|
+
let dir = posixDirname(slash(file)), match = /^\w+:\/\/[^/]*/.exec(dir), protocol = match ? match[0] : "", startPath = dir.slice(protocol.length);
|
|
743
|
+
return protocol && /^\/\w:/.test(startPath) ? (protocol += "/", protocol + slash(posixResolve(startPath, url))) : protocol + posixResolve(startPath, url);
|
|
744
|
+
}
|
|
745
|
+
function getRunnerSourceMap(position) {
|
|
746
|
+
for (let moduleGraph of evaluatedModulesCache) {
|
|
747
|
+
let sourceMap = moduleGraph.getModuleSourceMapById(position.source);
|
|
748
|
+
if (sourceMap) return {
|
|
749
|
+
url: position.source,
|
|
750
|
+
map: sourceMap,
|
|
751
|
+
vite: !0
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
return null;
|
|
755
|
+
}
|
|
756
|
+
function retrieveFile(path) {
|
|
757
|
+
if (path in fileContentsCache) return fileContentsCache[path];
|
|
758
|
+
let content = retrieveFileFromHandlers(path);
|
|
759
|
+
return typeof content == "string" ? (fileContentsCache[path] = content, content) : null;
|
|
760
|
+
}
|
|
761
|
+
function retrieveSourceMapURL(source) {
|
|
762
|
+
let fileData = retrieveFile(source);
|
|
763
|
+
if (!fileData) return null;
|
|
764
|
+
let re = /\/\/[@#]\s*sourceMappingURL=([^\s'"]+)\s*$|\/\*[@#]\s*sourceMappingURL=[^\s*'"]+\s*\*\/\s*$/gm, lastMatch, match;
|
|
765
|
+
for (; match = re.exec(fileData);) lastMatch = match;
|
|
766
|
+
return lastMatch ? lastMatch[1] : null;
|
|
767
|
+
}
|
|
768
|
+
const reSourceMap = /^data:application\/json[^,]+base64,/;
|
|
769
|
+
function retrieveSourceMap(source) {
|
|
770
|
+
let urlAndMap = retrieveSourceMapFromHandlers(source);
|
|
771
|
+
if (urlAndMap) return urlAndMap;
|
|
772
|
+
let sourceMappingURL = retrieveSourceMapURL(source);
|
|
773
|
+
if (!sourceMappingURL) return null;
|
|
774
|
+
let sourceMapData;
|
|
775
|
+
if (reSourceMap.test(sourceMappingURL)) {
|
|
776
|
+
let rawData = sourceMappingURL.slice(sourceMappingURL.indexOf(",") + 1);
|
|
777
|
+
sourceMapData = Buffer.from(rawData, "base64").toString(), sourceMappingURL = source;
|
|
778
|
+
} else sourceMappingURL = supportRelativeURL(source, sourceMappingURL), sourceMapData = retrieveFile(sourceMappingURL);
|
|
779
|
+
return sourceMapData ? {
|
|
780
|
+
url: sourceMappingURL,
|
|
781
|
+
map: sourceMapData
|
|
782
|
+
} : null;
|
|
783
|
+
}
|
|
784
|
+
function mapSourcePosition(position) {
|
|
785
|
+
if (!position.source) return position;
|
|
786
|
+
let sourceMap = getRunnerSourceMap(position);
|
|
787
|
+
if (sourceMap ||= sourceMapCache[position.source], !sourceMap) {
|
|
788
|
+
let urlAndMap = retrieveSourceMap(position.source);
|
|
789
|
+
if (urlAndMap && urlAndMap.map) {
|
|
790
|
+
let url = urlAndMap.url;
|
|
791
|
+
sourceMap = sourceMapCache[position.source] = {
|
|
792
|
+
url,
|
|
793
|
+
map: new DecodedMap(typeof urlAndMap.map == "string" ? JSON.parse(urlAndMap.map) : urlAndMap.map, url)
|
|
794
|
+
};
|
|
795
|
+
let contents = sourceMap.map?.map.sourcesContent;
|
|
796
|
+
sourceMap.map && contents && sourceMap.map.resolvedSources.forEach((source, i) => {
|
|
797
|
+
let content = contents[i];
|
|
798
|
+
if (content && source && url) {
|
|
799
|
+
let contentUrl = supportRelativeURL(url, source);
|
|
800
|
+
fileContentsCache[contentUrl] = content;
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
} else sourceMap = sourceMapCache[position.source] = {
|
|
804
|
+
url: null,
|
|
805
|
+
map: null
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
if (sourceMap.map && sourceMap.url) {
|
|
809
|
+
let originalPosition = getOriginalPosition(sourceMap.map, position);
|
|
810
|
+
if (originalPosition && originalPosition.source != null) return originalPosition.source = supportRelativeURL(sourceMap.url, originalPosition.source), sourceMap.vite && (originalPosition._vite = !0), originalPosition;
|
|
811
|
+
}
|
|
812
|
+
return position;
|
|
813
|
+
}
|
|
814
|
+
function mapEvalOrigin(origin) {
|
|
815
|
+
let match = /^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(origin);
|
|
816
|
+
if (match) {
|
|
817
|
+
let position = mapSourcePosition({
|
|
818
|
+
name: null,
|
|
819
|
+
source: match[2],
|
|
820
|
+
line: +match[3],
|
|
821
|
+
column: match[4] - 1
|
|
822
|
+
});
|
|
823
|
+
return `eval at ${match[1]} (${position.source}:${position.line}:${position.column + 1})`;
|
|
824
|
+
}
|
|
825
|
+
return match = /^eval at ([^(]+) \((.+)\)$/.exec(origin), match ? `eval at ${match[1]} (${mapEvalOrigin(match[2])})` : origin;
|
|
826
|
+
}
|
|
827
|
+
function CallSiteToString() {
|
|
828
|
+
let fileName, fileLocation = "";
|
|
829
|
+
if (this.isNative()) fileLocation = "native";
|
|
830
|
+
else {
|
|
831
|
+
fileName = this.getScriptNameOrSourceURL(), !fileName && this.isEval() && (fileLocation = this.getEvalOrigin(), fileLocation += ", "), fileName ? fileLocation += fileName : fileLocation += "<anonymous>";
|
|
832
|
+
let lineNumber = this.getLineNumber();
|
|
833
|
+
if (lineNumber != null) {
|
|
834
|
+
fileLocation += `:${lineNumber}`;
|
|
835
|
+
let columnNumber = this.getColumnNumber();
|
|
836
|
+
columnNumber && (fileLocation += `:${columnNumber}`);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
let line = "", functionName = this.getFunctionName(), addSuffix = !0, isConstructor = this.isConstructor();
|
|
840
|
+
if (this.isToplevel() || isConstructor) isConstructor ? line += `new ${functionName || "<anonymous>"}` : functionName ? line += functionName : (line += fileLocation, addSuffix = !1);
|
|
841
|
+
else {
|
|
842
|
+
let typeName = this.getTypeName();
|
|
843
|
+
typeName === "[object Object]" && (typeName = "null");
|
|
844
|
+
let methodName = this.getMethodName();
|
|
845
|
+
functionName ? (typeName && functionName.indexOf(typeName) !== 0 && (line += `${typeName}.`), line += functionName, methodName && functionName.indexOf(`.${methodName}`) !== functionName.length - methodName.length - 1 && (line += ` [as ${methodName}]`)) : line += `${typeName}.${methodName || "<anonymous>"}`;
|
|
846
|
+
}
|
|
847
|
+
return addSuffix && (line += ` (${fileLocation})`), line;
|
|
848
|
+
}
|
|
849
|
+
function cloneCallSite(frame) {
|
|
850
|
+
let object = {};
|
|
851
|
+
return Object.getOwnPropertyNames(Object.getPrototypeOf(frame)).forEach((name) => {
|
|
852
|
+
let key = name;
|
|
853
|
+
object[key] = /^(?:is|get)/.test(name) ? function() {
|
|
854
|
+
return frame[key].call(frame);
|
|
855
|
+
} : frame[key];
|
|
856
|
+
}), object.toString = CallSiteToString, object;
|
|
857
|
+
}
|
|
858
|
+
function wrapCallSite(frame, state) {
|
|
859
|
+
if (state === void 0 && (state = {
|
|
860
|
+
nextPosition: null,
|
|
861
|
+
curPosition: null
|
|
862
|
+
}), frame.isNative()) return state.curPosition = null, frame;
|
|
863
|
+
let source = frame.getFileName() || frame.getScriptNameOrSourceURL();
|
|
864
|
+
if (source) {
|
|
865
|
+
let line = frame.getLineNumber(), column = frame.getColumnNumber() - 1;
|
|
866
|
+
line === 1 && column > 62 && !frame.isEval() && (column -= 62);
|
|
867
|
+
let position = mapSourcePosition({
|
|
868
|
+
name: null,
|
|
869
|
+
source,
|
|
870
|
+
line,
|
|
871
|
+
column
|
|
872
|
+
});
|
|
873
|
+
state.curPosition = position, frame = cloneCallSite(frame);
|
|
874
|
+
let originalFunctionName = frame.getFunctionName;
|
|
875
|
+
return frame.getFunctionName = function() {
|
|
876
|
+
let name = state.nextPosition == null ? originalFunctionName() : state.nextPosition.name || originalFunctionName();
|
|
877
|
+
return name === "eval" && "_vite" in position ? null : name;
|
|
878
|
+
}, frame.getFileName = function() {
|
|
879
|
+
return position.source ?? null;
|
|
880
|
+
}, frame.getLineNumber = function() {
|
|
881
|
+
return position.line;
|
|
882
|
+
}, frame.getColumnNumber = function() {
|
|
883
|
+
return position.column + 1;
|
|
884
|
+
}, frame.getScriptNameOrSourceURL = function() {
|
|
885
|
+
return position.source;
|
|
886
|
+
}, frame;
|
|
887
|
+
}
|
|
888
|
+
let origin = frame.isEval() && frame.getEvalOrigin();
|
|
889
|
+
return origin ? (origin = mapEvalOrigin(origin), frame = cloneCallSite(frame), frame.getEvalOrigin = function() {
|
|
890
|
+
return origin || void 0;
|
|
891
|
+
}, frame) : frame;
|
|
892
|
+
}
|
|
893
|
+
function prepareStackTrace(error, stack) {
|
|
894
|
+
let errorString = `${error.name || "Error"}: ${error.message || ""}`, state = {
|
|
895
|
+
nextPosition: null,
|
|
896
|
+
curPosition: null
|
|
897
|
+
}, processedStack = [];
|
|
898
|
+
for (let i = stack.length - 1; i >= 0; i--) processedStack.push(`\n at ${wrapCallSite(stack[i], state)}`), state.nextPosition = state.curPosition;
|
|
899
|
+
return state.curPosition = state.nextPosition = null, errorString + processedStack.reverse().join("");
|
|
900
|
+
}
|
|
901
|
+
function enableSourceMapSupport(runner) {
|
|
902
|
+
if (runner.options.sourcemapInterceptor === "node") {
|
|
903
|
+
if (typeof process > "u") throw TypeError("Cannot use \"sourcemapInterceptor: 'node'\" because global \"process\" variable is not available.");
|
|
904
|
+
if (typeof process.setSourceMapsEnabled != "function") throw TypeError("Cannot use \"sourcemapInterceptor: 'node'\" because \"process.setSourceMapsEnabled\" function is not available. Please use Node >= 16.6.0.");
|
|
905
|
+
let isEnabledAlready = process.sourceMapsEnabled ?? !1;
|
|
906
|
+
return process.setSourceMapsEnabled(!0), () => !isEnabledAlready && process.setSourceMapsEnabled(!1);
|
|
907
|
+
}
|
|
908
|
+
return interceptStackTrace(runner, typeof runner.options.sourcemapInterceptor == "object" ? runner.options.sourcemapInterceptor : void 0);
|
|
909
|
+
}
|
|
910
|
+
var ESModulesEvaluator = class {
|
|
911
|
+
startOffset = getAsyncFunctionDeclarationPaddingLineCount();
|
|
912
|
+
async runInlinedModule(context, code) {
|
|
913
|
+
await new AsyncFunction(ssrModuleExportsKey, ssrImportMetaKey, ssrImportKey, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, "\"use strict\";" + code)(context[ssrModuleExportsKey], context[ssrImportMetaKey], context[ssrImportKey], context[ssrDynamicImportKey], context[ssrExportAllKey], context[ssrExportNameKey]), Object.seal(context[ssrModuleExportsKey]);
|
|
914
|
+
}
|
|
915
|
+
runExternalModule(filepath) {
|
|
916
|
+
return import(filepath);
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
const customizationHookNamespace = "vite-module-runner:import-meta-resolve/v1/", customizationHooksModule = `
|
|
920
|
+
|
|
921
|
+
export async function resolve(specifier, context, nextResolve) {
|
|
922
|
+
if (specifier.startsWith(${JSON.stringify(customizationHookNamespace)})) {
|
|
923
|
+
const data = specifier.slice(${JSON.stringify(customizationHookNamespace)}.length)
|
|
924
|
+
const [parsedSpecifier, parsedImporter] = JSON.parse(data)
|
|
925
|
+
specifier = parsedSpecifier
|
|
926
|
+
context.parentURL = parsedImporter
|
|
927
|
+
}
|
|
928
|
+
return nextResolve(specifier, context)
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
`;
|
|
932
|
+
function customizationHookResolve(specifier, context, nextResolve) {
|
|
933
|
+
if (specifier.startsWith(customizationHookNamespace)) {
|
|
934
|
+
let data = specifier.slice(42), [parsedSpecifier, parsedImporter] = JSON.parse(data);
|
|
935
|
+
specifier = parsedSpecifier, context.parentURL = parsedImporter;
|
|
936
|
+
}
|
|
937
|
+
return nextResolve(specifier, context);
|
|
938
|
+
}
|
|
939
|
+
let isHookRegistered = !1;
|
|
940
|
+
function createImportMetaResolver() {
|
|
941
|
+
if (isHookRegistered) return importMetaResolveWithCustomHook;
|
|
942
|
+
let module;
|
|
943
|
+
try {
|
|
944
|
+
module = typeof process < "u" ? process.getBuiltinModule("node:module").Module : void 0;
|
|
945
|
+
} catch {
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
if (module) {
|
|
949
|
+
if (module.registerHooks) return module.registerHooks({ resolve: customizationHookResolve }), isHookRegistered = !0, importMetaResolveWithCustomHook;
|
|
950
|
+
if (module.register) {
|
|
951
|
+
try {
|
|
952
|
+
let hookModuleContent = `data:text/javascript,${encodeURI(customizationHooksModule)}`;
|
|
953
|
+
module.register(hookModuleContent);
|
|
954
|
+
} catch (e) {
|
|
955
|
+
if ("code" in e && e.code === "ERR_NETWORK_IMPORT_DISALLOWED") return;
|
|
956
|
+
throw e;
|
|
957
|
+
}
|
|
958
|
+
return isHookRegistered = !0, importMetaResolveWithCustomHook;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
function importMetaResolveWithCustomHook(specifier, importer) {
|
|
963
|
+
return import.meta.resolve(`${customizationHookNamespace}${JSON.stringify([specifier, importer])}`);
|
|
964
|
+
}
|
|
965
|
+
`${customizationHookNamespace}`;
|
|
966
|
+
const envProxy = new Proxy({}, { get(_, p) {
|
|
967
|
+
throw Error(`[module runner] Dynamic access of "import.meta.env" is not supported. Please, use "import.meta.env.${String(p)}" instead.`);
|
|
968
|
+
} });
|
|
969
|
+
function createDefaultImportMeta(modulePath) {
|
|
970
|
+
let href = posixPathToFileHref(modulePath), filename = modulePath, dirname = posixDirname(modulePath);
|
|
971
|
+
return {
|
|
972
|
+
filename: isWindows ? toWindowsPath(filename) : filename,
|
|
973
|
+
dirname: isWindows ? toWindowsPath(dirname) : dirname,
|
|
974
|
+
url: href,
|
|
975
|
+
env: envProxy,
|
|
976
|
+
resolve(_id, _parent) {
|
|
977
|
+
throw Error("[module runner] \"import.meta.resolve\" is not supported.");
|
|
978
|
+
},
|
|
979
|
+
glob() {
|
|
980
|
+
throw Error("[module runner] \"import.meta.glob\" is statically replaced during file transformation. Make sure to reference it by the full name.");
|
|
981
|
+
}
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
function createNodeImportMeta(modulePath) {
|
|
985
|
+
let defaultMeta = createDefaultImportMeta(modulePath), href = defaultMeta.url, importMetaResolver = createImportMetaResolver();
|
|
986
|
+
return {
|
|
987
|
+
...defaultMeta,
|
|
988
|
+
main: !1,
|
|
989
|
+
resolve(id, parent) {
|
|
990
|
+
return (importMetaResolver ?? defaultMeta.resolve)(id, parent ?? href);
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
var ModuleRunner = class {
|
|
995
|
+
evaluatedModules;
|
|
996
|
+
hmrClient;
|
|
997
|
+
transport;
|
|
998
|
+
resetSourceMapSupport;
|
|
999
|
+
concurrentModuleNodePromises = /* @__PURE__ */ new Map();
|
|
1000
|
+
isBuiltin;
|
|
1001
|
+
builtinsPromise;
|
|
1002
|
+
closed = !1;
|
|
1003
|
+
constructor(options, evaluator = new ESModulesEvaluator(), debug) {
|
|
1004
|
+
if (this.options = options, this.evaluator = evaluator, this.debug = debug, this.evaluatedModules = options.evaluatedModules ?? new EvaluatedModules(), this.transport = normalizeModuleRunnerTransport(options.transport), options.hmr !== !1) {
|
|
1005
|
+
let optionsHmr = options.hmr ?? !0;
|
|
1006
|
+
if (this.hmrClient = new HMRClient(optionsHmr === !0 || optionsHmr.logger === void 0 ? hmrLogger : optionsHmr.logger === !1 ? silentConsole : optionsHmr.logger, this.transport, ({ acceptedPath }) => this.import(acceptedPath)), !this.transport.connect) throw Error("HMR is not supported by this runner transport, but `hmr` option was set to true");
|
|
1007
|
+
this.transport.connect(createHMRHandlerForRunner(this));
|
|
1008
|
+
} else this.transport.connect?.();
|
|
1009
|
+
options.sourcemapInterceptor !== !1 && (this.resetSourceMapSupport = enableSourceMapSupport(this));
|
|
1010
|
+
}
|
|
1011
|
+
async import(url) {
|
|
1012
|
+
let fetchedModule = await this.cachedModule(url);
|
|
1013
|
+
return await this.cachedRequest(url, fetchedModule);
|
|
1014
|
+
}
|
|
1015
|
+
clearCache() {
|
|
1016
|
+
this.evaluatedModules.clear(), this.hmrClient?.clear();
|
|
1017
|
+
}
|
|
1018
|
+
async close() {
|
|
1019
|
+
this.resetSourceMapSupport?.(), this.clearCache(), this.hmrClient = void 0, this.closed = !0, await this.transport.disconnect?.();
|
|
1020
|
+
}
|
|
1021
|
+
isClosed() {
|
|
1022
|
+
return this.closed;
|
|
1023
|
+
}
|
|
1024
|
+
processImport(exports, fetchResult, metadata) {
|
|
1025
|
+
if (!("externalize" in fetchResult)) return exports;
|
|
1026
|
+
let { url, type } = fetchResult;
|
|
1027
|
+
return type !== "module" && type !== "commonjs" || analyzeImportedModDifference(exports, url, type, metadata), exports;
|
|
1028
|
+
}
|
|
1029
|
+
isCircularModule(mod) {
|
|
1030
|
+
for (let importedFile of mod.imports) if (mod.importers.has(importedFile)) return !0;
|
|
1031
|
+
return !1;
|
|
1032
|
+
}
|
|
1033
|
+
isCircularImport(importers, moduleUrl, visited = /* @__PURE__ */ new Set()) {
|
|
1034
|
+
for (let importer of importers) {
|
|
1035
|
+
if (visited.has(importer)) continue;
|
|
1036
|
+
if (visited.add(importer), importer === moduleUrl) return !0;
|
|
1037
|
+
let mod = this.evaluatedModules.getModuleById(importer);
|
|
1038
|
+
if (mod && mod.importers.size && this.isCircularImport(mod.importers, moduleUrl, visited)) return !0;
|
|
1039
|
+
}
|
|
1040
|
+
return !1;
|
|
1041
|
+
}
|
|
1042
|
+
async cachedRequest(url, mod, callstack = [], metadata) {
|
|
1043
|
+
let meta = mod.meta, moduleId = meta.id, { importers } = mod, importee = callstack[callstack.length - 1];
|
|
1044
|
+
if (importee && importers.add(importee), (callstack.includes(moduleId) || this.isCircularModule(mod) || this.isCircularImport(importers, moduleId)) && mod.exports) return this.processImport(mod.exports, meta, metadata);
|
|
1045
|
+
let debugTimer;
|
|
1046
|
+
this.debug && (debugTimer = setTimeout(() => {
|
|
1047
|
+
this.debug(`[module runner] module ${moduleId} takes over 2s to load.\n${`stack:\n${[...callstack, moduleId].reverse().map((p) => ` - ${p}`).join("\n")}`}`);
|
|
1048
|
+
}, 2e3));
|
|
1049
|
+
try {
|
|
1050
|
+
if (mod.promise) return this.processImport(await mod.promise, meta, metadata);
|
|
1051
|
+
let promise = this.directRequest(url, mod, callstack);
|
|
1052
|
+
return mod.promise = promise, mod.evaluated = !1, this.processImport(await promise, meta, metadata);
|
|
1053
|
+
} finally {
|
|
1054
|
+
mod.evaluated = !0, debugTimer && clearTimeout(debugTimer);
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
async cachedModule(url, importer) {
|
|
1058
|
+
let cached = this.concurrentModuleNodePromises.get(url);
|
|
1059
|
+
if (cached) this.debug?.("[module runner] using cached module info for", url);
|
|
1060
|
+
else {
|
|
1061
|
+
let cachedModule = this.evaluatedModules.getModuleByUrl(url);
|
|
1062
|
+
cached = this.getModuleInformation(url, importer, cachedModule).finally(() => {
|
|
1063
|
+
this.concurrentModuleNodePromises.delete(url);
|
|
1064
|
+
}), this.concurrentModuleNodePromises.set(url, cached);
|
|
1065
|
+
}
|
|
1066
|
+
return cached;
|
|
1067
|
+
}
|
|
1068
|
+
ensureBuiltins() {
|
|
1069
|
+
if (!this.isBuiltin) return this.builtinsPromise ??= (async () => {
|
|
1070
|
+
try {
|
|
1071
|
+
this.debug?.("[module runner] fetching builtins from server");
|
|
1072
|
+
let builtins = (await this.transport.invoke("getBuiltins", [])).map((builtin) => typeof builtin == "object" && builtin && "type" in builtin ? builtin.type === "string" ? builtin.value : new RegExp(builtin.source, builtin.flags) : builtin);
|
|
1073
|
+
this.isBuiltin = createIsBuiltin(builtins), this.debug?.("[module runner] builtins loaded:", builtins);
|
|
1074
|
+
} finally {
|
|
1075
|
+
this.builtinsPromise = void 0;
|
|
1076
|
+
}
|
|
1077
|
+
})(), this.builtinsPromise;
|
|
1078
|
+
}
|
|
1079
|
+
async getModuleInformation(url, importer, cachedModule) {
|
|
1080
|
+
if (this.closed) throw Error("Vite module runner has been closed.");
|
|
1081
|
+
await this.ensureBuiltins(), this.debug?.("[module runner] fetching", url);
|
|
1082
|
+
let isCached = !!(typeof cachedModule == "object" && cachedModule.meta), fetchedModule = url.startsWith("data:") || this.isBuiltin?.(url) ? {
|
|
1083
|
+
externalize: url,
|
|
1084
|
+
type: "builtin"
|
|
1085
|
+
} : await this.transport.invoke("fetchModule", [
|
|
1086
|
+
url,
|
|
1087
|
+
importer,
|
|
1088
|
+
{
|
|
1089
|
+
cached: isCached,
|
|
1090
|
+
startOffset: this.evaluator.startOffset
|
|
1091
|
+
}
|
|
1092
|
+
]);
|
|
1093
|
+
if ("cache" in fetchedModule) {
|
|
1094
|
+
if (!cachedModule || !cachedModule.meta) throw Error(`Module "${url}" was mistakenly invalidated during fetch phase.`);
|
|
1095
|
+
return cachedModule;
|
|
1096
|
+
}
|
|
1097
|
+
let moduleId = "externalize" in fetchedModule ? fetchedModule.externalize : fetchedModule.id, moduleUrl = "url" in fetchedModule ? fetchedModule.url : url, module = this.evaluatedModules.ensureModule(moduleId, moduleUrl);
|
|
1098
|
+
return "invalidate" in fetchedModule && fetchedModule.invalidate && this.evaluatedModules.invalidateModule(module), fetchedModule.url = moduleUrl, fetchedModule.id = moduleId, module.meta = fetchedModule, module;
|
|
1099
|
+
}
|
|
1100
|
+
async directRequest(url, mod, _callstack) {
|
|
1101
|
+
let fetchResult = mod.meta, moduleId = fetchResult.id, callstack = [..._callstack, moduleId], request = async (dep, metadata) => {
|
|
1102
|
+
let importer = "file" in fetchResult && fetchResult.file || moduleId, depMod = await this.cachedModule(dep, importer);
|
|
1103
|
+
return depMod.importers.add(moduleId), mod.imports.add(depMod.id), this.cachedRequest(dep, depMod, callstack, metadata);
|
|
1104
|
+
}, dynamicRequest = async (dep) => (dep = String(dep), dep[0] === "." && (dep = posixResolve(posixDirname(url), dep)), request(dep, { isDynamicImport: !0 }));
|
|
1105
|
+
if ("externalize" in fetchResult) {
|
|
1106
|
+
let { externalize } = fetchResult;
|
|
1107
|
+
this.debug?.("[module runner] externalizing", externalize);
|
|
1108
|
+
let exports = await this.evaluator.runExternalModule(externalize);
|
|
1109
|
+
return mod.exports = exports, exports;
|
|
1110
|
+
}
|
|
1111
|
+
let { code, file } = fetchResult;
|
|
1112
|
+
if (code == null) {
|
|
1113
|
+
let importer = callstack[callstack.length - 2];
|
|
1114
|
+
throw Error(`[module runner] Failed to load "${url}"${importer ? ` imported from ${importer}` : ""}`);
|
|
1115
|
+
}
|
|
1116
|
+
let createImportMeta = this.options.createImportMeta ?? createDefaultImportMeta, modulePath = cleanUrl(file || moduleId), href = posixPathToFileHref(modulePath), meta = await createImportMeta(modulePath), exports = Object.create(null);
|
|
1117
|
+
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
1118
|
+
value: "Module",
|
|
1119
|
+
enumerable: !1,
|
|
1120
|
+
configurable: !1
|
|
1121
|
+
}), mod.exports = exports;
|
|
1122
|
+
let hotContext;
|
|
1123
|
+
this.hmrClient && Object.defineProperty(meta, "hot", {
|
|
1124
|
+
enumerable: !0,
|
|
1125
|
+
get: () => {
|
|
1126
|
+
if (!this.hmrClient) throw Error("[module runner] HMR client was closed.");
|
|
1127
|
+
return this.debug?.("[module runner] creating hmr context for", mod.url), hotContext ||= new HMRContext(this.hmrClient, mod.url), hotContext;
|
|
1128
|
+
},
|
|
1129
|
+
set: (value) => {
|
|
1130
|
+
hotContext = value;
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
let context = {
|
|
1134
|
+
[ssrImportKey]: request,
|
|
1135
|
+
[ssrDynamicImportKey]: dynamicRequest,
|
|
1136
|
+
[ssrModuleExportsKey]: exports,
|
|
1137
|
+
[ssrExportAllKey]: (obj) => exportAll(exports, obj),
|
|
1138
|
+
[ssrExportNameKey]: (name, getter) => Object.defineProperty(exports, name, {
|
|
1139
|
+
enumerable: !0,
|
|
1140
|
+
configurable: !0,
|
|
1141
|
+
get: getter
|
|
1142
|
+
}),
|
|
1143
|
+
[ssrImportMetaKey]: meta
|
|
1144
|
+
};
|
|
1145
|
+
return this.debug?.("[module runner] executing", href), await this.evaluator.runInlinedModule(context, code, mod), exports;
|
|
1146
|
+
}
|
|
1147
|
+
};
|
|
1148
|
+
function exportAll(exports, sourceModule) {
|
|
1149
|
+
if (exports !== sourceModule && !(isPrimitive(sourceModule) || Array.isArray(sourceModule) || sourceModule instanceof Promise)) {
|
|
1150
|
+
for (let key in sourceModule) if (key !== "default" && key !== "__esModule" && !(key in exports)) try {
|
|
1151
|
+
Object.defineProperty(exports, key, {
|
|
1152
|
+
enumerable: !0,
|
|
1153
|
+
configurable: !0,
|
|
1154
|
+
get: () => sourceModule[key]
|
|
1155
|
+
});
|
|
1156
|
+
} catch {}
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
export { ESModulesEvaluator, EvaluatedModules, ModuleRunner, createDefaultImportMeta, createNodeImportMeta, createWebSocketModuleRunnerTransport, normalizeModuleId, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
|