vite 6.3.5 → 7.0.0-beta.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/LICENSE.md +29 -0
- package/bin/vite.js +4 -4
- package/dist/client/client.mjs +793 -921
- package/dist/client/env.mjs +14 -19
- package/dist/node/chunks/dep-3PhSlasG.js +5 -0
- package/dist/node/chunks/dep-B4i1tHPo.js +30 -0
- package/dist/node/chunks/dep-BO5GbxpL.js +7345 -0
- package/dist/node/chunks/dep-BaSfMtGz.js +5 -0
- package/dist/node/chunks/dep-Bb92EWrU.js +5 -0
- package/dist/node/chunks/dep-C9KS6hrN.js +5 -0
- package/dist/node/chunks/dep-Ctugieod.js +150 -0
- package/dist/node/chunks/dep-D5HXLrlI.js +378 -0
- package/dist/node/chunks/dep-Da5Rc_CS.js +36548 -0
- package/dist/node/chunks/dep-Dg4W3IAQ.js +5597 -0
- package/dist/node/chunks/dep-uSUFJk9A.js +446 -0
- package/dist/node/cli.js +617 -865
- package/dist/node/constants.js +3 -148
- package/dist/node/index.d.ts +2724 -3124
- package/dist/node/index.js +25 -188
- package/dist/node/module-runner.d.ts +243 -234
- package/dist/node/module-runner.js +1043 -1172
- package/dist/node/moduleRunnerTransport-BWUZBVLX.d.ts +88 -0
- package/package.json +38 -41
- package/types/importGlob.d.ts +4 -0
- package/types/internal/cssPreprocessorOptions.d.ts +3 -22
- package/dist/node/chunks/dep-3RmXg9uo.js +0 -553
- package/dist/node/chunks/dep-AiMcmC_f.js +0 -822
- package/dist/node/chunks/dep-CvfTChi5.js +0 -8218
- package/dist/node/chunks/dep-DBxKXgDP.js +0 -49496
- package/dist/node/chunks/dep-SgSik2vo.js +0 -7113
- package/dist/node/moduleRunnerTransport.d-DJ_mE5sf.d.ts +0 -87
- package/dist/node-cjs/publicUtils.cjs +0 -3986
- package/index.cjs +0 -96
- package/index.d.cts +0 -6
@@ -1,1311 +1,1182 @@
|
|
1
|
+
/**
|
2
|
+
* Plugins that use 'virtual modules' (e.g. for helper functions), prefix the
|
3
|
+
* module ID with `\0`, a convention from the rollup ecosystem.
|
4
|
+
* This prevents other plugins from trying to process the id (like node resolution),
|
5
|
+
* and core features like sourcemaps can use this info to differentiate between
|
6
|
+
* virtual modules and regular files.
|
7
|
+
* `\0` is not a permitted char in import URLs so we have to replace them during
|
8
|
+
* import analysis. The id will be decoded back before entering the plugins pipeline.
|
9
|
+
* These encoded virtual ids are also prefixed by the VALID_ID_PREFIX, so virtual
|
10
|
+
* modules in the browser end up encoded as `/@id/__x00__{id}`
|
11
|
+
*/
|
1
12
|
const VALID_ID_PREFIX = "/@id/", NULL_BYTE_PLACEHOLDER = "__x00__";
|
2
13
|
let SOURCEMAPPING_URL = "sourceMa";
|
3
14
|
SOURCEMAPPING_URL += "ppingURL";
|
4
15
|
const ERR_OUTDATED_OPTIMIZED_DEP = "ERR_OUTDATED_OPTIMIZED_DEP", isWindows = typeof process < "u" && process.platform === "win32";
|
16
|
+
/**
|
17
|
+
* Undo {@link wrapId}'s `/@id/` and null byte replacements.
|
18
|
+
*/
|
5
19
|
function unwrapId(id) {
|
6
|
-
|
20
|
+
return id.startsWith(VALID_ID_PREFIX) ? id.slice(VALID_ID_PREFIX.length).replace(NULL_BYTE_PLACEHOLDER, "\0") : id;
|
7
21
|
}
|
8
22
|
const windowsSlashRE = /\\/g;
|
9
23
|
function slash(p) {
|
10
|
-
|
24
|
+
return p.replace(windowsSlashRE, "/");
|
11
25
|
}
|
12
26
|
const postfixRE = /[?#].*$/;
|
13
27
|
function cleanUrl(url) {
|
14
|
-
|
28
|
+
return url.replace(postfixRE, "");
|
15
29
|
}
|
16
30
|
function isPrimitive(value) {
|
17
|
-
|
31
|
+
return !value || typeof value != "object" && typeof value != "function";
|
18
32
|
}
|
19
|
-
const AsyncFunction = async function() {
|
20
|
-
}.constructor;
|
33
|
+
const AsyncFunction = async function() {}.constructor;
|
21
34
|
let asyncFunctionDeclarationPaddingLineCount;
|
22
35
|
function getAsyncFunctionDeclarationPaddingLineCount() {
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
return asyncFunctionDeclarationPaddingLineCount;
|
36
|
+
if (asyncFunctionDeclarationPaddingLineCount === void 0) {
|
37
|
+
let body = "/*code*/", source = new AsyncFunction("a", "b", body).toString();
|
38
|
+
asyncFunctionDeclarationPaddingLineCount = source.slice(0, source.indexOf(body)).split("\n").length - 1;
|
39
|
+
}
|
40
|
+
return asyncFunctionDeclarationPaddingLineCount;
|
29
41
|
}
|
30
42
|
function promiseWithResolvers() {
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
43
|
+
let resolve$1, reject, promise = new Promise((_resolve, _reject) => {
|
44
|
+
resolve$1 = _resolve, reject = _reject;
|
45
|
+
});
|
46
|
+
return {
|
47
|
+
promise,
|
48
|
+
resolve: resolve$1,
|
49
|
+
reject
|
50
|
+
};
|
35
51
|
}
|
36
52
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
37
53
|
function normalizeWindowsPath(input = "") {
|
38
|
-
|
54
|
+
return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
39
55
|
}
|
40
56
|
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
41
57
|
function cwd() {
|
42
|
-
|
58
|
+
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
43
59
|
}
|
44
60
|
const resolve = function(...arguments_) {
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
61
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
62
|
+
let resolvedPath = "", resolvedAbsolute = !1;
|
63
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
64
|
+
let path = index >= 0 ? arguments_[index] : cwd();
|
65
|
+
!path || path.length === 0 || (resolvedPath = `${path}/${resolvedPath}`, resolvedAbsolute = isAbsolute(path));
|
66
|
+
}
|
67
|
+
return resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : ".";
|
52
68
|
};
|
53
69
|
function normalizeString(path, allowAboveRoot) {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
res.length > 0 ? res += `/${path.slice(lastSlash + 1, index)}` : res = path.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
|
78
|
-
lastSlash = index, dots = 0;
|
79
|
-
} else char === "." && dots !== -1 ? ++dots : dots = -1;
|
80
|
-
}
|
81
|
-
return res;
|
70
|
+
let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
|
71
|
+
for (let index = 0; index <= path.length; ++index) {
|
72
|
+
if (index < path.length) char = path[index];
|
73
|
+
else if (char === "/") break;
|
74
|
+
else char = "/";
|
75
|
+
if (char === "/") {
|
76
|
+
if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
|
77
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
78
|
+
if (res.length > 2) {
|
79
|
+
let lastSlashIndex = res.lastIndexOf("/");
|
80
|
+
lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
|
81
|
+
continue;
|
82
|
+
} else if (res.length > 0) {
|
83
|
+
res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
|
84
|
+
continue;
|
85
|
+
}
|
86
|
+
}
|
87
|
+
allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
|
88
|
+
} else res.length > 0 ? res += `/${path.slice(lastSlash + 1, index)}` : res = path.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
|
89
|
+
lastSlash = index, dots = 0;
|
90
|
+
} else char === "." && dots !== -1 ? ++dots : dots = -1;
|
91
|
+
}
|
92
|
+
return res;
|
82
93
|
}
|
83
94
|
const isAbsolute = function(p) {
|
84
|
-
|
95
|
+
return _IS_ABSOLUTE_RE.test(p);
|
85
96
|
}, dirname = function(p) {
|
86
|
-
|
87
|
-
|
97
|
+
let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
98
|
+
return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
88
99
|
}, decodeBase64 = typeof atob < "u" ? atob : (str) => Buffer.from(str, "base64").toString("utf-8"), CHAR_FORWARD_SLASH = 47, CHAR_BACKWARD_SLASH = 92, percentRegEx = /%/g, backslashRegEx = /\\/g, newlineRegEx = /\n/g, carriageReturnRegEx = /\r/g, tabRegEx = /\t/g, questionRegex = /\?/g, hashRegex = /#/g;
|
89
100
|
function encodePathChars(filepath) {
|
90
|
-
|
91
|
-
`) !== -1 && (filepath = filepath.replace(newlineRegEx, "%0A")), filepath.indexOf("\r") !== -1 && (filepath = filepath.replace(carriageReturnRegEx, "%0D")), filepath.indexOf(" ") !== -1 && (filepath = filepath.replace(tabRegEx, "%09")), filepath;
|
101
|
+
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;
|
92
102
|
}
|
93
103
|
const posixDirname = dirname, posixResolve = resolve;
|
94
104
|
function posixPathToFileHref(posixPath) {
|
95
|
-
|
96
|
-
|
97
|
-
return (filePathLast === CHAR_FORWARD_SLASH || isWindows && filePathLast === CHAR_BACKWARD_SLASH) && 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;
|
105
|
+
let resolved = posixResolve(posixPath), filePathLast = posixPath.charCodeAt(posixPath.length - 1);
|
106
|
+
return (filePathLast === CHAR_FORWARD_SLASH || isWindows && filePathLast === CHAR_BACKWARD_SLASH) && 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;
|
98
107
|
}
|
99
108
|
function toWindowsPath(path) {
|
100
|
-
|
109
|
+
return path.replace(/\//g, "\\");
|
101
110
|
}
|
102
|
-
const comma = 44, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", intToChar = new Uint8Array(64), charToInt = new Uint8Array(128);
|
111
|
+
const comma = 44, semicolon = 59, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", intToChar = new Uint8Array(64), charToInt = new Uint8Array(128);
|
103
112
|
for (let i = 0; i < chars.length; i++) {
|
104
|
-
|
105
|
-
|
113
|
+
let c = chars.charCodeAt(i);
|
114
|
+
intToChar[i] = c, charToInt[c] = i;
|
106
115
|
}
|
107
116
|
function decodeInteger(reader, relative) {
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
117
|
+
let value = 0, shift = 0, integer = 0;
|
118
|
+
do {
|
119
|
+
let c = reader.next();
|
120
|
+
integer = charToInt[c], value |= (integer & 31) << shift, shift += 5;
|
121
|
+
} while (integer & 32);
|
122
|
+
let shouldNegate = value & 1;
|
123
|
+
return value >>>= 1, shouldNegate && (value = -2147483648 | -value), relative + value;
|
115
124
|
}
|
116
125
|
function hasMoreVlq(reader, max) {
|
117
|
-
|
118
|
-
}
|
119
|
-
class StringReader {
|
120
|
-
constructor(buffer) {
|
121
|
-
this.pos = 0, this.buffer = buffer;
|
122
|
-
}
|
123
|
-
next() {
|
124
|
-
return this.buffer.charCodeAt(this.pos++);
|
125
|
-
}
|
126
|
-
peek() {
|
127
|
-
return this.buffer.charCodeAt(this.pos);
|
128
|
-
}
|
129
|
-
indexOf(char) {
|
130
|
-
const { buffer, pos } = this, idx = buffer.indexOf(char, pos);
|
131
|
-
return idx === -1 ? buffer.length : idx;
|
132
|
-
}
|
126
|
+
return reader.pos >= max ? !1 : reader.peek() !== comma;
|
133
127
|
}
|
128
|
+
const bufLength = 1024 * 16;
|
129
|
+
var StringReader = class {
|
130
|
+
constructor(buffer) {
|
131
|
+
this.pos = 0, this.buffer = buffer;
|
132
|
+
}
|
133
|
+
next() {
|
134
|
+
return this.buffer.charCodeAt(this.pos++);
|
135
|
+
}
|
136
|
+
peek() {
|
137
|
+
return this.buffer.charCodeAt(this.pos);
|
138
|
+
}
|
139
|
+
indexOf(char) {
|
140
|
+
let { buffer, pos } = this, idx = buffer.indexOf(char, pos);
|
141
|
+
return idx === -1 ? buffer.length : idx;
|
142
|
+
}
|
143
|
+
};
|
134
144
|
function decode(mappings) {
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
145
|
+
let { length } = mappings, reader = new StringReader(mappings), decoded = [], genColumn = 0, sourcesIndex = 0, sourceLine = 0, sourceColumn = 0, namesIndex = 0;
|
146
|
+
do {
|
147
|
+
let semi = reader.indexOf(";"), line = [], sorted = !0, lastCol = 0;
|
148
|
+
for (genColumn = 0; reader.pos < semi;) {
|
149
|
+
let seg;
|
150
|
+
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 = [
|
151
|
+
genColumn,
|
152
|
+
sourcesIndex,
|
153
|
+
sourceLine,
|
154
|
+
sourceColumn,
|
155
|
+
namesIndex
|
156
|
+
]) : seg = [
|
157
|
+
genColumn,
|
158
|
+
sourcesIndex,
|
159
|
+
sourceLine,
|
160
|
+
sourceColumn
|
161
|
+
]) : seg = [genColumn], line.push(seg), reader.pos++;
|
162
|
+
}
|
163
|
+
sorted || sort(line), decoded.push(line), reader.pos = semi + 1;
|
164
|
+
} while (reader.pos <= length);
|
165
|
+
return decoded;
|
147
166
|
}
|
148
167
|
function sort(line) {
|
149
|
-
|
168
|
+
line.sort(sortComparator);
|
150
169
|
}
|
151
170
|
function sortComparator(a, b) {
|
152
|
-
|
171
|
+
return a[0] - b[0];
|
153
172
|
}
|
154
173
|
const COLUMN = 0, SOURCES_INDEX = 1, SOURCE_LINE = 2, SOURCE_COLUMN = 3, NAMES_INDEX = 4;
|
155
174
|
let found = !1;
|
175
|
+
/**
|
176
|
+
* A binary search implementation that returns the index if a match is found.
|
177
|
+
* If no match is found, then the left-index (the index associated with the item that comes just
|
178
|
+
* before the desired index) is returned. To maintain proper sort order, a splice would happen at
|
179
|
+
* the next index:
|
180
|
+
*
|
181
|
+
* ```js
|
182
|
+
* const array = [1, 3];
|
183
|
+
* const needle = 2;
|
184
|
+
* const index = binarySearch(array, needle, (item, needle) => item - needle);
|
185
|
+
*
|
186
|
+
* assert.equal(index, 0);
|
187
|
+
* array.splice(index + 1, 0, needle);
|
188
|
+
* assert.deepEqual(array, [1, 2, 3]);
|
189
|
+
* ```
|
190
|
+
*/
|
156
191
|
function binarySearch(haystack, needle, low, high) {
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
return found = !1, low - 1;
|
192
|
+
for (; low <= high;) {
|
193
|
+
let mid = low + (high - low >> 1), cmp = haystack[mid][COLUMN] - needle;
|
194
|
+
if (cmp === 0) return found = !0, mid;
|
195
|
+
cmp < 0 ? low = mid + 1 : high = mid - 1;
|
196
|
+
}
|
197
|
+
return found = !1, low - 1;
|
164
198
|
}
|
165
199
|
function upperBound(haystack, needle, index) {
|
166
|
-
|
167
|
-
|
168
|
-
return index;
|
200
|
+
for (let i = index + 1; i < haystack.length && haystack[i][COLUMN] === needle; index = i++);
|
201
|
+
return index;
|
169
202
|
}
|
170
203
|
function lowerBound(haystack, needle, index) {
|
171
|
-
|
172
|
-
|
173
|
-
return index;
|
204
|
+
for (let i = index - 1; i >= 0 && haystack[i][COLUMN] === needle; index = i--);
|
205
|
+
return index;
|
174
206
|
}
|
207
|
+
/**
|
208
|
+
* This overly complicated beast is just to record the last tested line/column and the resulting
|
209
|
+
* index, allowing us to skip a few tests if mappings are monotonically increasing.
|
210
|
+
*/
|
175
211
|
function memoizedBinarySearch(haystack, needle, state, key) {
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
}
|
183
|
-
return state.lastKey = key, state.lastNeedle = needle, state.lastIndex = binarySearch(haystack, needle, low, high);
|
212
|
+
let { lastKey, lastNeedle, lastIndex } = state, low = 0, high = haystack.length - 1;
|
213
|
+
if (key === lastKey) {
|
214
|
+
if (needle === lastNeedle) return found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle, lastIndex;
|
215
|
+
needle >= lastNeedle ? low = lastIndex === -1 ? 0 : lastIndex : high = lastIndex;
|
216
|
+
}
|
217
|
+
return state.lastKey = key, state.lastNeedle = needle, state.lastIndex = binarySearch(haystack, needle, low, high);
|
184
218
|
}
|
185
219
|
const 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;
|
220
|
+
/**
|
221
|
+
* Typescript doesn't allow friend access to private fields, so this just casts the map into a type
|
222
|
+
* with public access modifiers.
|
223
|
+
*/
|
186
224
|
function cast(map) {
|
187
|
-
|
225
|
+
return map;
|
188
226
|
}
|
227
|
+
/**
|
228
|
+
* Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
|
229
|
+
*/
|
189
230
|
function decodedMappings(map) {
|
190
|
-
|
191
|
-
|
231
|
+
var _a;
|
232
|
+
return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
|
192
233
|
}
|
234
|
+
/**
|
235
|
+
* A higher-level API to find the source/line/column associated with a generated line/column
|
236
|
+
* (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
|
237
|
+
* `source-map` library.
|
238
|
+
*/
|
193
239
|
function originalPositionFor(map, needle) {
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
const segment = segments[index];
|
206
|
-
if (segment.length === 1)
|
207
|
-
return OMapping(null, null, null, null);
|
208
|
-
const { names, resolvedSources } = map;
|
209
|
-
return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
|
240
|
+
let { line, column, bias } = needle;
|
241
|
+
if (line--, line < 0) throw Error(LINE_GTR_ZERO);
|
242
|
+
if (column < 0) throw Error(COL_GTR_EQ_ZERO);
|
243
|
+
let decoded = decodedMappings(map);
|
244
|
+
if (line >= decoded.length) return OMapping(null, null, null, null);
|
245
|
+
let segments = decoded[line], index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
|
246
|
+
if (index === -1) return OMapping(null, null, null, null);
|
247
|
+
let segment = segments[index];
|
248
|
+
if (segment.length === 1) return OMapping(null, null, null, null);
|
249
|
+
let { names, resolvedSources } = map;
|
250
|
+
return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
|
210
251
|
}
|
211
252
|
function OMapping(source, line, column, name) {
|
212
|
-
|
253
|
+
return {
|
254
|
+
source,
|
255
|
+
line,
|
256
|
+
column,
|
257
|
+
name
|
258
|
+
};
|
213
259
|
}
|
214
260
|
function traceSegmentInternal(segments, memo, line, column, bias) {
|
215
|
-
|
216
|
-
|
217
|
-
}
|
218
|
-
class DecodedMap {
|
219
|
-
constructor(map, from) {
|
220
|
-
this.map = map;
|
221
|
-
const { mappings, names, sources } = map;
|
222
|
-
this.version = map.version, this.names = names || [], this._encoded = mappings || "", this._decodedMemo = memoizedState(), this.url = from, this.resolvedSources = (sources || []).map(
|
223
|
-
(s) => posixResolve(s || "", from)
|
224
|
-
);
|
225
|
-
}
|
226
|
-
_encoded;
|
227
|
-
_decoded;
|
228
|
-
_decodedMemo;
|
229
|
-
url;
|
230
|
-
version;
|
231
|
-
names = [];
|
232
|
-
resolvedSources;
|
261
|
+
let index = memoizedBinarySearch(segments, column, memo, line);
|
262
|
+
return found ? index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index) : bias === LEAST_UPPER_BOUND && index++, index === -1 || index === segments.length ? -1 : index;
|
233
263
|
}
|
264
|
+
var DecodedMap = class {
|
265
|
+
_encoded;
|
266
|
+
_decoded;
|
267
|
+
_decodedMemo;
|
268
|
+
url;
|
269
|
+
version;
|
270
|
+
names = [];
|
271
|
+
resolvedSources;
|
272
|
+
constructor(map, from) {
|
273
|
+
this.map = map;
|
274
|
+
let { mappings, names, sources } = map;
|
275
|
+
this.version = map.version, this.names = names || [], this._encoded = mappings || "", this._decodedMemo = memoizedState(), this.url = from, this.resolvedSources = (sources || []).map((s) => posixResolve(s || "", from));
|
276
|
+
}
|
277
|
+
};
|
234
278
|
function memoizedState() {
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
279
|
+
return {
|
280
|
+
lastKey: -1,
|
281
|
+
lastNeedle: -1,
|
282
|
+
lastIndex: -1
|
283
|
+
};
|
240
284
|
}
|
241
285
|
function getOriginalPosition(map, needle) {
|
242
|
-
|
243
|
-
|
286
|
+
let result = originalPositionFor(map, needle);
|
287
|
+
return result.column == null ? null : result;
|
244
288
|
}
|
245
|
-
const MODULE_RUNNER_SOURCEMAPPING_REGEXP =
|
246
|
-
|
247
|
-
);
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
const prefixedBuiltins = /* @__PURE__ */ new Set([
|
332
|
-
"node:sea",
|
333
|
-
"node:sqlite",
|
334
|
-
"node:test",
|
335
|
-
"node:test/reporters"
|
289
|
+
const MODULE_RUNNER_SOURCEMAPPING_REGEXP = RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json;base64,(.+)`);
|
290
|
+
var EvaluatedModuleNode = class {
|
291
|
+
importers = /* @__PURE__ */ new Set();
|
292
|
+
imports = /* @__PURE__ */ new Set();
|
293
|
+
evaluated = !1;
|
294
|
+
meta;
|
295
|
+
promise;
|
296
|
+
exports;
|
297
|
+
file;
|
298
|
+
map;
|
299
|
+
constructor(id, url) {
|
300
|
+
this.id = id, this.url = url, this.file = cleanUrl(id);
|
301
|
+
}
|
302
|
+
}, EvaluatedModules = class {
|
303
|
+
idToModuleMap = /* @__PURE__ */ new Map();
|
304
|
+
fileToModulesMap = /* @__PURE__ */ new Map();
|
305
|
+
urlToIdModuleMap = /* @__PURE__ */ new Map();
|
306
|
+
/**
|
307
|
+
* Returns the module node by the resolved module ID. Usually, module ID is
|
308
|
+
* the file system path with query and/or hash. It can also be a virtual module.
|
309
|
+
*
|
310
|
+
* Module runner graph will have 1 to 1 mapping with the server module graph.
|
311
|
+
* @param id Resolved module ID
|
312
|
+
*/
|
313
|
+
getModuleById(id) {
|
314
|
+
return this.idToModuleMap.get(id);
|
315
|
+
}
|
316
|
+
/**
|
317
|
+
* Returns all modules related to the file system path. Different modules
|
318
|
+
* might have different query parameters or hash, so it's possible to have
|
319
|
+
* multiple modules for the same file.
|
320
|
+
* @param file The file system path of the module
|
321
|
+
*/
|
322
|
+
getModulesByFile(file) {
|
323
|
+
return this.fileToModulesMap.get(file);
|
324
|
+
}
|
325
|
+
/**
|
326
|
+
* Returns the module node by the URL that was used in the import statement.
|
327
|
+
* Unlike module graph on the server, the URL is not resolved and is used as is.
|
328
|
+
* @param url Server URL that was used in the import statement
|
329
|
+
*/
|
330
|
+
getModuleByUrl(url) {
|
331
|
+
return this.urlToIdModuleMap.get(unwrapId(url));
|
332
|
+
}
|
333
|
+
/**
|
334
|
+
* Ensure that module is in the graph. If the module is already in the graph,
|
335
|
+
* it will return the existing module node. Otherwise, it will create a new
|
336
|
+
* module node and add it to the graph.
|
337
|
+
* @param id Resolved module ID
|
338
|
+
* @param url URL that was used in the import statement
|
339
|
+
*/
|
340
|
+
ensureModule(id, url) {
|
341
|
+
if (id = normalizeModuleId(id), this.idToModuleMap.has(id)) {
|
342
|
+
let moduleNode$1 = this.idToModuleMap.get(id);
|
343
|
+
return this.urlToIdModuleMap.set(url, moduleNode$1), moduleNode$1;
|
344
|
+
}
|
345
|
+
let moduleNode = new EvaluatedModuleNode(id, url);
|
346
|
+
this.idToModuleMap.set(id, moduleNode), this.urlToIdModuleMap.set(url, moduleNode);
|
347
|
+
let fileModules = this.fileToModulesMap.get(moduleNode.file) || /* @__PURE__ */ new Set();
|
348
|
+
return fileModules.add(moduleNode), this.fileToModulesMap.set(moduleNode.file, fileModules), moduleNode;
|
349
|
+
}
|
350
|
+
invalidateModule(node) {
|
351
|
+
node.evaluated = !1, node.meta = void 0, node.map = void 0, node.promise = void 0, node.exports = void 0, node.imports.clear();
|
352
|
+
}
|
353
|
+
/**
|
354
|
+
* Extracts the inlined source map from the module code and returns the decoded
|
355
|
+
* source map. If the source map is not inlined, it will return null.
|
356
|
+
* @param id Resolved module ID
|
357
|
+
*/
|
358
|
+
getModuleSourceMapById(id) {
|
359
|
+
let mod = this.getModuleById(id);
|
360
|
+
if (!mod) return null;
|
361
|
+
if (mod.map) return mod.map;
|
362
|
+
if (!mod.meta || !("code" in mod.meta)) return null;
|
363
|
+
let mapString = MODULE_RUNNER_SOURCEMAPPING_REGEXP.exec(mod.meta.code)?.[1];
|
364
|
+
return mapString ? (mod.map = new DecodedMap(JSON.parse(decodeBase64(mapString)), mod.file), mod.map) : null;
|
365
|
+
}
|
366
|
+
clear() {
|
367
|
+
this.idToModuleMap.clear(), this.fileToModulesMap.clear(), this.urlToIdModuleMap.clear();
|
368
|
+
}
|
369
|
+
};
|
370
|
+
const prefixedBuiltins = new Set([
|
371
|
+
"node:sea",
|
372
|
+
"node:sqlite",
|
373
|
+
"node:test",
|
374
|
+
"node:test/reporters"
|
336
375
|
]);
|
337
376
|
function normalizeModuleId(file) {
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
constructor(hmrClient, ownerPath) {
|
342
|
-
this.hmrClient = hmrClient, this.ownerPath = ownerPath, hmrClient.dataMap.has(ownerPath) || hmrClient.dataMap.set(ownerPath, {});
|
343
|
-
const mod = hmrClient.hotModulesMap.get(ownerPath);
|
344
|
-
mod && (mod.callbacks = []);
|
345
|
-
const staleListeners = hmrClient.ctxToListenersMap.get(ownerPath);
|
346
|
-
if (staleListeners)
|
347
|
-
for (const [event, staleFns] of staleListeners) {
|
348
|
-
const listeners = hmrClient.customListenersMap.get(event);
|
349
|
-
listeners && hmrClient.customListenersMap.set(
|
350
|
-
event,
|
351
|
-
listeners.filter((l) => !staleFns.includes(l))
|
352
|
-
);
|
353
|
-
}
|
354
|
-
this.newListeners = /* @__PURE__ */ new Map(), hmrClient.ctxToListenersMap.set(ownerPath, this.newListeners);
|
355
|
-
}
|
356
|
-
newListeners;
|
357
|
-
get data() {
|
358
|
-
return this.hmrClient.dataMap.get(this.ownerPath);
|
359
|
-
}
|
360
|
-
accept(deps, callback) {
|
361
|
-
if (typeof deps == "function" || !deps)
|
362
|
-
this.acceptDeps([this.ownerPath], ([mod]) => deps?.(mod));
|
363
|
-
else if (typeof deps == "string")
|
364
|
-
this.acceptDeps([deps], ([mod]) => callback?.(mod));
|
365
|
-
else if (Array.isArray(deps))
|
366
|
-
this.acceptDeps(deps, callback);
|
367
|
-
else
|
368
|
-
throw new Error("invalid hot.accept() usage.");
|
369
|
-
}
|
370
|
-
// export names (first arg) are irrelevant on the client side, they're
|
371
|
-
// extracted in the server for propagation
|
372
|
-
acceptExports(_, callback) {
|
373
|
-
this.acceptDeps([this.ownerPath], ([mod]) => callback?.(mod));
|
374
|
-
}
|
375
|
-
dispose(cb) {
|
376
|
-
this.hmrClient.disposeMap.set(this.ownerPath, cb);
|
377
|
-
}
|
378
|
-
prune(cb) {
|
379
|
-
this.hmrClient.pruneMap.set(this.ownerPath, cb);
|
380
|
-
}
|
381
|
-
// Kept for backward compatibility (#11036)
|
382
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
383
|
-
decline() {
|
384
|
-
}
|
385
|
-
invalidate(message) {
|
386
|
-
const firstInvalidatedBy = this.hmrClient.currentFirstInvalidatedBy ?? this.ownerPath;
|
387
|
-
this.hmrClient.notifyListeners("vite:invalidate", {
|
388
|
-
path: this.ownerPath,
|
389
|
-
message,
|
390
|
-
firstInvalidatedBy
|
391
|
-
}), this.send("vite:invalidate", {
|
392
|
-
path: this.ownerPath,
|
393
|
-
message,
|
394
|
-
firstInvalidatedBy
|
395
|
-
}), this.hmrClient.logger.debug(
|
396
|
-
`invalidate ${this.ownerPath}${message ? `: ${message}` : ""}`
|
397
|
-
);
|
398
|
-
}
|
399
|
-
on(event, cb) {
|
400
|
-
const addToMap = (map) => {
|
401
|
-
const existing = map.get(event) || [];
|
402
|
-
existing.push(cb), map.set(event, existing);
|
403
|
-
};
|
404
|
-
addToMap(this.hmrClient.customListenersMap), addToMap(this.newListeners);
|
405
|
-
}
|
406
|
-
off(event, cb) {
|
407
|
-
const removeFromMap = (map) => {
|
408
|
-
const existing = map.get(event);
|
409
|
-
if (existing === void 0)
|
410
|
-
return;
|
411
|
-
const pruned = existing.filter((l) => l !== cb);
|
412
|
-
if (pruned.length === 0) {
|
413
|
-
map.delete(event);
|
414
|
-
return;
|
415
|
-
}
|
416
|
-
map.set(event, pruned);
|
417
|
-
};
|
418
|
-
removeFromMap(this.hmrClient.customListenersMap), removeFromMap(this.newListeners);
|
419
|
-
}
|
420
|
-
send(event, data) {
|
421
|
-
this.hmrClient.send({ type: "custom", event, data });
|
422
|
-
}
|
423
|
-
acceptDeps(deps, callback = () => {
|
424
|
-
}) {
|
425
|
-
const mod = this.hmrClient.hotModulesMap.get(this.ownerPath) || {
|
426
|
-
id: this.ownerPath,
|
427
|
-
callbacks: []
|
428
|
-
};
|
429
|
-
mod.callbacks.push({
|
430
|
-
deps,
|
431
|
-
fn: callback
|
432
|
-
}), this.hmrClient.hotModulesMap.set(this.ownerPath, mod);
|
433
|
-
}
|
434
|
-
}
|
435
|
-
class HMRClient {
|
436
|
-
constructor(logger, transport, importUpdatedModule) {
|
437
|
-
this.logger = logger, this.transport = transport, this.importUpdatedModule = importUpdatedModule;
|
438
|
-
}
|
439
|
-
hotModulesMap = /* @__PURE__ */ new Map();
|
440
|
-
disposeMap = /* @__PURE__ */ new Map();
|
441
|
-
pruneMap = /* @__PURE__ */ new Map();
|
442
|
-
dataMap = /* @__PURE__ */ new Map();
|
443
|
-
customListenersMap = /* @__PURE__ */ new Map();
|
444
|
-
ctxToListenersMap = /* @__PURE__ */ new Map();
|
445
|
-
currentFirstInvalidatedBy;
|
446
|
-
async notifyListeners(event, data) {
|
447
|
-
const cbs = this.customListenersMap.get(event);
|
448
|
-
cbs && await Promise.allSettled(cbs.map((cb) => cb(data)));
|
449
|
-
}
|
450
|
-
send(payload) {
|
451
|
-
this.transport.send(payload).catch((err) => {
|
452
|
-
this.logger.error(err);
|
453
|
-
});
|
454
|
-
}
|
455
|
-
clear() {
|
456
|
-
this.hotModulesMap.clear(), this.disposeMap.clear(), this.pruneMap.clear(), this.dataMap.clear(), this.customListenersMap.clear(), this.ctxToListenersMap.clear();
|
457
|
-
}
|
458
|
-
// After an HMR update, some modules are no longer imported on the page
|
459
|
-
// but they may have left behind side effects that need to be cleaned up
|
460
|
-
// (e.g. style injections)
|
461
|
-
async prunePaths(paths) {
|
462
|
-
await Promise.all(
|
463
|
-
paths.map((path) => {
|
464
|
-
const disposer = this.disposeMap.get(path);
|
465
|
-
if (disposer) return disposer(this.dataMap.get(path));
|
466
|
-
})
|
467
|
-
), paths.forEach((path) => {
|
468
|
-
const fn = this.pruneMap.get(path);
|
469
|
-
fn && fn(this.dataMap.get(path));
|
470
|
-
});
|
471
|
-
}
|
472
|
-
warnFailedUpdate(err, path) {
|
473
|
-
(!(err instanceof Error) || !err.message.includes("fetch")) && this.logger.error(err), this.logger.error(
|
474
|
-
`Failed to reload ${path}. This could be due to syntax errors or importing non-existent modules. (see errors above)`
|
475
|
-
);
|
476
|
-
}
|
477
|
-
updateQueue = [];
|
478
|
-
pendingUpdateQueue = !1;
|
479
|
-
/**
|
480
|
-
* buffer multiple hot updates triggered by the same src change
|
481
|
-
* so that they are invoked in the same order they were sent.
|
482
|
-
* (otherwise the order may be inconsistent because of the http request round trip)
|
483
|
-
*/
|
484
|
-
async queueUpdate(payload) {
|
485
|
-
if (this.updateQueue.push(this.fetchUpdate(payload)), !this.pendingUpdateQueue) {
|
486
|
-
this.pendingUpdateQueue = !0, await Promise.resolve(), this.pendingUpdateQueue = !1;
|
487
|
-
const loading = [...this.updateQueue];
|
488
|
-
this.updateQueue = [], (await Promise.all(loading)).forEach((fn) => fn && fn());
|
489
|
-
}
|
490
|
-
}
|
491
|
-
async fetchUpdate(update) {
|
492
|
-
const { path, acceptedPath, firstInvalidatedBy } = update, mod = this.hotModulesMap.get(path);
|
493
|
-
if (!mod)
|
494
|
-
return;
|
495
|
-
let fetchedModule;
|
496
|
-
const isSelfUpdate = path === acceptedPath, qualifiedCallbacks = mod.callbacks.filter(
|
497
|
-
({ deps }) => deps.includes(acceptedPath)
|
498
|
-
);
|
499
|
-
if (isSelfUpdate || qualifiedCallbacks.length > 0) {
|
500
|
-
const disposer = this.disposeMap.get(acceptedPath);
|
501
|
-
disposer && await disposer(this.dataMap.get(acceptedPath));
|
502
|
-
try {
|
503
|
-
fetchedModule = await this.importUpdatedModule(update);
|
504
|
-
} catch (e) {
|
505
|
-
this.warnFailedUpdate(e, acceptedPath);
|
506
|
-
}
|
507
|
-
}
|
508
|
-
return () => {
|
509
|
-
try {
|
510
|
-
this.currentFirstInvalidatedBy = firstInvalidatedBy;
|
511
|
-
for (const { deps, fn } of qualifiedCallbacks)
|
512
|
-
fn(
|
513
|
-
deps.map(
|
514
|
-
(dep) => dep === acceptedPath ? fetchedModule : void 0
|
515
|
-
)
|
516
|
-
);
|
517
|
-
const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
|
518
|
-
this.logger.debug(`hot updated: ${loggedPath}`);
|
519
|
-
} finally {
|
520
|
-
this.currentFirstInvalidatedBy = void 0;
|
521
|
-
}
|
522
|
-
};
|
523
|
-
}
|
377
|
+
if (prefixedBuiltins.has(file)) return file;
|
378
|
+
let unixFile = slash(file).replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^node:/, "").replace(/^\/+/, "/");
|
379
|
+
return unixFile.replace(/^file:\//, "/");
|
524
380
|
}
|
381
|
+
var HMRContext = class {
|
382
|
+
newListeners;
|
383
|
+
constructor(hmrClient, ownerPath) {
|
384
|
+
this.hmrClient = hmrClient, this.ownerPath = ownerPath, hmrClient.dataMap.has(ownerPath) || hmrClient.dataMap.set(ownerPath, {});
|
385
|
+
let mod = hmrClient.hotModulesMap.get(ownerPath);
|
386
|
+
mod && (mod.callbacks = []);
|
387
|
+
let staleListeners = hmrClient.ctxToListenersMap.get(ownerPath);
|
388
|
+
if (staleListeners) for (let [event, staleFns] of staleListeners) {
|
389
|
+
let listeners = hmrClient.customListenersMap.get(event);
|
390
|
+
listeners && hmrClient.customListenersMap.set(event, listeners.filter((l) => !staleFns.includes(l)));
|
391
|
+
}
|
392
|
+
this.newListeners = /* @__PURE__ */ new Map(), hmrClient.ctxToListenersMap.set(ownerPath, this.newListeners);
|
393
|
+
}
|
394
|
+
get data() {
|
395
|
+
return this.hmrClient.dataMap.get(this.ownerPath);
|
396
|
+
}
|
397
|
+
accept(deps, callback) {
|
398
|
+
if (typeof deps == "function" || !deps) this.acceptDeps([this.ownerPath], ([mod]) => deps?.(mod));
|
399
|
+
else if (typeof deps == "string") this.acceptDeps([deps], ([mod]) => callback?.(mod));
|
400
|
+
else if (Array.isArray(deps)) this.acceptDeps(deps, callback);
|
401
|
+
else throw Error("invalid hot.accept() usage.");
|
402
|
+
}
|
403
|
+
acceptExports(_, callback) {
|
404
|
+
this.acceptDeps([this.ownerPath], ([mod]) => callback?.(mod));
|
405
|
+
}
|
406
|
+
dispose(cb) {
|
407
|
+
this.hmrClient.disposeMap.set(this.ownerPath, cb);
|
408
|
+
}
|
409
|
+
prune(cb) {
|
410
|
+
this.hmrClient.pruneMap.set(this.ownerPath, cb);
|
411
|
+
}
|
412
|
+
decline() {}
|
413
|
+
invalidate(message) {
|
414
|
+
let firstInvalidatedBy = this.hmrClient.currentFirstInvalidatedBy ?? this.ownerPath;
|
415
|
+
this.hmrClient.notifyListeners("vite:invalidate", {
|
416
|
+
path: this.ownerPath,
|
417
|
+
message,
|
418
|
+
firstInvalidatedBy
|
419
|
+
}), this.send("vite:invalidate", {
|
420
|
+
path: this.ownerPath,
|
421
|
+
message,
|
422
|
+
firstInvalidatedBy
|
423
|
+
}), this.hmrClient.logger.debug(`invalidate ${this.ownerPath}${message ? `: ${message}` : ""}`);
|
424
|
+
}
|
425
|
+
on(event, cb) {
|
426
|
+
let addToMap = (map) => {
|
427
|
+
let existing = map.get(event) || [];
|
428
|
+
existing.push(cb), map.set(event, existing);
|
429
|
+
};
|
430
|
+
addToMap(this.hmrClient.customListenersMap), addToMap(this.newListeners);
|
431
|
+
}
|
432
|
+
off(event, cb) {
|
433
|
+
let removeFromMap = (map) => {
|
434
|
+
let existing = map.get(event);
|
435
|
+
if (existing === void 0) return;
|
436
|
+
let pruned = existing.filter((l) => l !== cb);
|
437
|
+
if (pruned.length === 0) {
|
438
|
+
map.delete(event);
|
439
|
+
return;
|
440
|
+
}
|
441
|
+
map.set(event, pruned);
|
442
|
+
};
|
443
|
+
removeFromMap(this.hmrClient.customListenersMap), removeFromMap(this.newListeners);
|
444
|
+
}
|
445
|
+
send(event, data) {
|
446
|
+
this.hmrClient.send({
|
447
|
+
type: "custom",
|
448
|
+
event,
|
449
|
+
data
|
450
|
+
});
|
451
|
+
}
|
452
|
+
acceptDeps(deps, callback = () => {}) {
|
453
|
+
let mod = this.hmrClient.hotModulesMap.get(this.ownerPath) || {
|
454
|
+
id: this.ownerPath,
|
455
|
+
callbacks: []
|
456
|
+
};
|
457
|
+
mod.callbacks.push({
|
458
|
+
deps,
|
459
|
+
fn: callback
|
460
|
+
}), this.hmrClient.hotModulesMap.set(this.ownerPath, mod);
|
461
|
+
}
|
462
|
+
}, HMRClient = class {
|
463
|
+
hotModulesMap = /* @__PURE__ */ new Map();
|
464
|
+
disposeMap = /* @__PURE__ */ new Map();
|
465
|
+
pruneMap = /* @__PURE__ */ new Map();
|
466
|
+
dataMap = /* @__PURE__ */ new Map();
|
467
|
+
customListenersMap = /* @__PURE__ */ new Map();
|
468
|
+
ctxToListenersMap = /* @__PURE__ */ new Map();
|
469
|
+
currentFirstInvalidatedBy;
|
470
|
+
constructor(logger, transport, importUpdatedModule) {
|
471
|
+
this.logger = logger, this.transport = transport, this.importUpdatedModule = importUpdatedModule;
|
472
|
+
}
|
473
|
+
async notifyListeners(event, data) {
|
474
|
+
let cbs = this.customListenersMap.get(event);
|
475
|
+
cbs && await Promise.allSettled(cbs.map((cb) => cb(data)));
|
476
|
+
}
|
477
|
+
send(payload) {
|
478
|
+
this.transport.send(payload).catch((err) => {
|
479
|
+
this.logger.error(err);
|
480
|
+
});
|
481
|
+
}
|
482
|
+
clear() {
|
483
|
+
this.hotModulesMap.clear(), this.disposeMap.clear(), this.pruneMap.clear(), this.dataMap.clear(), this.customListenersMap.clear(), this.ctxToListenersMap.clear();
|
484
|
+
}
|
485
|
+
async prunePaths(paths) {
|
486
|
+
await Promise.all(paths.map((path) => {
|
487
|
+
let disposer = this.disposeMap.get(path);
|
488
|
+
if (disposer) return disposer(this.dataMap.get(path));
|
489
|
+
})), paths.forEach((path) => {
|
490
|
+
let fn = this.pruneMap.get(path);
|
491
|
+
fn && fn(this.dataMap.get(path));
|
492
|
+
});
|
493
|
+
}
|
494
|
+
warnFailedUpdate(err, path) {
|
495
|
+
(!(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)`);
|
496
|
+
}
|
497
|
+
updateQueue = [];
|
498
|
+
pendingUpdateQueue = !1;
|
499
|
+
/**
|
500
|
+
* buffer multiple hot updates triggered by the same src change
|
501
|
+
* so that they are invoked in the same order they were sent.
|
502
|
+
* (otherwise the order may be inconsistent because of the http request round trip)
|
503
|
+
*/
|
504
|
+
async queueUpdate(payload) {
|
505
|
+
if (this.updateQueue.push(this.fetchUpdate(payload)), !this.pendingUpdateQueue) {
|
506
|
+
this.pendingUpdateQueue = !0, await Promise.resolve(), this.pendingUpdateQueue = !1;
|
507
|
+
let loading = [...this.updateQueue];
|
508
|
+
this.updateQueue = [], (await Promise.all(loading)).forEach((fn) => fn && fn());
|
509
|
+
}
|
510
|
+
}
|
511
|
+
async fetchUpdate(update) {
|
512
|
+
let { path, acceptedPath, firstInvalidatedBy } = update, mod = this.hotModulesMap.get(path);
|
513
|
+
if (!mod) return;
|
514
|
+
let fetchedModule, isSelfUpdate = path === acceptedPath, qualifiedCallbacks = mod.callbacks.filter(({ deps }) => deps.includes(acceptedPath));
|
515
|
+
if (isSelfUpdate || qualifiedCallbacks.length > 0) {
|
516
|
+
let disposer = this.disposeMap.get(acceptedPath);
|
517
|
+
disposer && await disposer(this.dataMap.get(acceptedPath));
|
518
|
+
try {
|
519
|
+
fetchedModule = await this.importUpdatedModule(update);
|
520
|
+
} catch (e) {
|
521
|
+
this.warnFailedUpdate(e, acceptedPath);
|
522
|
+
}
|
523
|
+
}
|
524
|
+
return () => {
|
525
|
+
try {
|
526
|
+
this.currentFirstInvalidatedBy = firstInvalidatedBy;
|
527
|
+
for (let { deps, fn } of qualifiedCallbacks) fn(deps.map((dep) => dep === acceptedPath ? fetchedModule : void 0));
|
528
|
+
let loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
|
529
|
+
this.logger.debug(`hot updated: ${loggedPath}`);
|
530
|
+
} finally {
|
531
|
+
this.currentFirstInvalidatedBy = void 0;
|
532
|
+
}
|
533
|
+
};
|
534
|
+
}
|
535
|
+
};
|
536
|
+
/**
|
537
|
+
* Vite converts `import { } from 'foo'` to `const _ = __vite_ssr_import__('foo')`.
|
538
|
+
* Top-level imports and dynamic imports work slightly differently in Node.js.
|
539
|
+
* This function normalizes the differences so it matches prod behaviour.
|
540
|
+
*/
|
525
541
|
function analyzeImportedModDifference(mod, rawId, moduleType, metadata) {
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
) : new SyntaxError(`[vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
|
542
|
+
if (!metadata?.isDynamicImport && metadata?.importedNames?.length) {
|
543
|
+
let missingBindings = metadata.importedNames.filter((s) => !(s in mod));
|
544
|
+
if (missingBindings.length) {
|
545
|
+
let lastBinding = missingBindings[missingBindings.length - 1];
|
546
|
+
throw moduleType === "module" ? SyntaxError(`[vite] The requested module '${rawId}' does not provide an export named '${lastBinding}'`) : SyntaxError(`\
|
547
|
+
[vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
|
533
548
|
CommonJS modules can always be imported via the default export, for example using:
|
534
549
|
|
535
550
|
import pkg from '${rawId}';
|
536
551
|
const {${missingBindings.join(", ")}} = pkg;
|
537
552
|
`);
|
538
|
-
|
539
|
-
|
553
|
+
}
|
554
|
+
}
|
540
555
|
}
|
541
556
|
let urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", nanoid = (size = 21) => {
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
return id;
|
557
|
+
let id = "", i = size | 0;
|
558
|
+
for (; i--;) id += urlAlphabet[Math.random() * 64 | 0];
|
559
|
+
return id;
|
546
560
|
};
|
547
561
|
function reviveInvokeError(e) {
|
548
|
-
|
549
|
-
|
550
|
-
// pass the whole error instead of just the stacktrace
|
551
|
-
// so that it gets formatted nicely with console.log
|
552
|
-
runnerError: new Error("RunnerError")
|
553
|
-
}), error;
|
562
|
+
let error = Error(e.message || "Unknown invoke error");
|
563
|
+
return Object.assign(error, e, { runnerError: Error("RunnerError") }), error;
|
554
564
|
}
|
555
565
|
const createInvokeableTransport = (transport) => {
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
clearTimeout(timeoutId), rpcPromises.delete(promiseId), reject(err);
|
631
|
-
});
|
632
|
-
try {
|
633
|
-
return await promise;
|
634
|
-
} catch (err) {
|
635
|
-
throw reviveInvokeError(err);
|
636
|
-
}
|
637
|
-
}
|
638
|
-
};
|
566
|
+
if (transport.invoke) return {
|
567
|
+
...transport,
|
568
|
+
async invoke(name, data) {
|
569
|
+
let result = await transport.invoke({
|
570
|
+
type: "custom",
|
571
|
+
event: "vite:invoke",
|
572
|
+
data: {
|
573
|
+
id: "send",
|
574
|
+
name,
|
575
|
+
data
|
576
|
+
}
|
577
|
+
});
|
578
|
+
if ("error" in result) throw reviveInvokeError(result.error);
|
579
|
+
return result.result;
|
580
|
+
}
|
581
|
+
};
|
582
|
+
if (!transport.send || !transport.connect) throw Error("transport must implement send and connect when invoke is not implemented");
|
583
|
+
let rpcPromises = /* @__PURE__ */ new Map();
|
584
|
+
return {
|
585
|
+
...transport,
|
586
|
+
connect({ onMessage, onDisconnection }) {
|
587
|
+
return transport.connect({
|
588
|
+
onMessage(payload) {
|
589
|
+
if (payload.type === "custom" && payload.event === "vite:invoke") {
|
590
|
+
let data = payload.data;
|
591
|
+
if (data.id.startsWith("response:")) {
|
592
|
+
let invokeId = data.id.slice(9), promise = rpcPromises.get(invokeId);
|
593
|
+
if (!promise) return;
|
594
|
+
promise.timeoutId && clearTimeout(promise.timeoutId), rpcPromises.delete(invokeId);
|
595
|
+
let { error, result } = data.data;
|
596
|
+
error ? promise.reject(error) : promise.resolve(result);
|
597
|
+
return;
|
598
|
+
}
|
599
|
+
}
|
600
|
+
onMessage(payload);
|
601
|
+
},
|
602
|
+
onDisconnection
|
603
|
+
});
|
604
|
+
},
|
605
|
+
disconnect() {
|
606
|
+
return rpcPromises.forEach((promise) => {
|
607
|
+
promise.reject(Error(`transport was disconnected, cannot call ${JSON.stringify(promise.name)}`));
|
608
|
+
}), rpcPromises.clear(), transport.disconnect?.();
|
609
|
+
},
|
610
|
+
send(data) {
|
611
|
+
return transport.send(data);
|
612
|
+
},
|
613
|
+
async invoke(name, data) {
|
614
|
+
let promiseId = nanoid(), wrappedData = {
|
615
|
+
type: "custom",
|
616
|
+
event: "vite:invoke",
|
617
|
+
data: {
|
618
|
+
name,
|
619
|
+
id: `send:${promiseId}`,
|
620
|
+
data
|
621
|
+
}
|
622
|
+
}, sendPromise = transport.send(wrappedData), { promise, resolve: resolve$1, reject } = promiseWithResolvers(), timeout = transport.timeout ?? 6e4, timeoutId;
|
623
|
+
timeout > 0 && (timeoutId = setTimeout(() => {
|
624
|
+
rpcPromises.delete(promiseId), reject(Error(`transport invoke timed out after ${timeout}ms (data: ${JSON.stringify(wrappedData)})`));
|
625
|
+
}, timeout), timeoutId?.unref?.()), rpcPromises.set(promiseId, {
|
626
|
+
resolve: resolve$1,
|
627
|
+
reject,
|
628
|
+
name,
|
629
|
+
timeoutId
|
630
|
+
}), sendPromise && sendPromise.catch((err) => {
|
631
|
+
clearTimeout(timeoutId), rpcPromises.delete(promiseId), reject(err);
|
632
|
+
});
|
633
|
+
try {
|
634
|
+
return await promise;
|
635
|
+
} catch (err) {
|
636
|
+
throw reviveInvokeError(err);
|
637
|
+
}
|
638
|
+
}
|
639
|
+
};
|
639
640
|
}, normalizeModuleRunnerTransport = (transport) => {
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
await invokeableTransport.send(data);
|
674
|
-
}
|
675
|
-
},
|
676
|
-
async invoke(name, data) {
|
677
|
-
if (!isConnected)
|
678
|
-
if (connectingPromise)
|
679
|
-
await connectingPromise;
|
680
|
-
else
|
681
|
-
throw new Error("invoke was called before connect");
|
682
|
-
return invokeableTransport.invoke(name, data);
|
683
|
-
}
|
684
|
-
};
|
641
|
+
let invokeableTransport = createInvokeableTransport(transport), isConnected = !invokeableTransport.connect, connectingPromise;
|
642
|
+
return {
|
643
|
+
...transport,
|
644
|
+
...invokeableTransport.connect ? { async connect(onMessage) {
|
645
|
+
if (isConnected) return;
|
646
|
+
if (connectingPromise) {
|
647
|
+
await connectingPromise;
|
648
|
+
return;
|
649
|
+
}
|
650
|
+
let maybePromise = invokeableTransport.connect({
|
651
|
+
onMessage: onMessage ?? (() => {}),
|
652
|
+
onDisconnection() {
|
653
|
+
isConnected = !1;
|
654
|
+
}
|
655
|
+
});
|
656
|
+
maybePromise && (connectingPromise = maybePromise, await connectingPromise, connectingPromise = void 0), isConnected = !0;
|
657
|
+
} } : {},
|
658
|
+
...invokeableTransport.disconnect ? { async disconnect() {
|
659
|
+
isConnected && (connectingPromise && await connectingPromise, isConnected = !1, await invokeableTransport.disconnect());
|
660
|
+
} } : {},
|
661
|
+
async send(data) {
|
662
|
+
if (invokeableTransport.send) {
|
663
|
+
if (!isConnected) if (connectingPromise) await connectingPromise;
|
664
|
+
else throw Error("send was called before connect");
|
665
|
+
await invokeableTransport.send(data);
|
666
|
+
}
|
667
|
+
},
|
668
|
+
async invoke(name, data) {
|
669
|
+
if (!isConnected) if (connectingPromise) await connectingPromise;
|
670
|
+
else throw Error("invoke was called before connect");
|
671
|
+
return invokeableTransport.invoke(name, data);
|
672
|
+
}
|
673
|
+
};
|
685
674
|
}, createWebSocketModuleRunnerTransport = (options) => {
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
}
|
727
|
-
};
|
728
|
-
}, ssrModuleExportsKey = "__vite_ssr_exports__", ssrImportKey = "__vite_ssr_import__", ssrDynamicImportKey = "__vite_ssr_dynamic_import__", ssrExportAllKey = "__vite_ssr_exportAll__", ssrImportMetaKey = "__vite_ssr_import_meta__", noop = () => {
|
729
|
-
}, silentConsole = {
|
730
|
-
debug: noop,
|
731
|
-
error: noop
|
675
|
+
let pingInterval = options.pingInterval ?? 3e4, ws, pingIntervalId;
|
676
|
+
return {
|
677
|
+
async connect({ onMessage, onDisconnection }) {
|
678
|
+
let socket = options.createConnection();
|
679
|
+
socket.addEventListener("message", async ({ data }) => {
|
680
|
+
onMessage(JSON.parse(data));
|
681
|
+
});
|
682
|
+
let isOpened = socket.readyState === socket.OPEN;
|
683
|
+
isOpened || await new Promise((resolve$1, reject) => {
|
684
|
+
socket.addEventListener("open", () => {
|
685
|
+
isOpened = !0, resolve$1();
|
686
|
+
}, { once: !0 }), socket.addEventListener("close", async () => {
|
687
|
+
if (!isOpened) {
|
688
|
+
reject(Error("WebSocket closed without opened."));
|
689
|
+
return;
|
690
|
+
}
|
691
|
+
onMessage({
|
692
|
+
type: "custom",
|
693
|
+
event: "vite:ws:disconnect",
|
694
|
+
data: { webSocket: socket }
|
695
|
+
}), onDisconnection();
|
696
|
+
});
|
697
|
+
}), onMessage({
|
698
|
+
type: "custom",
|
699
|
+
event: "vite:ws:connect",
|
700
|
+
data: { webSocket: socket }
|
701
|
+
}), ws = socket, pingIntervalId = setInterval(() => {
|
702
|
+
socket.readyState === socket.OPEN && socket.send(JSON.stringify({ type: "ping" }));
|
703
|
+
}, pingInterval);
|
704
|
+
},
|
705
|
+
disconnect() {
|
706
|
+
clearInterval(pingIntervalId), ws?.close();
|
707
|
+
},
|
708
|
+
send(data) {
|
709
|
+
ws.send(JSON.stringify(data));
|
710
|
+
}
|
711
|
+
};
|
712
|
+
}, 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 = {
|
713
|
+
debug: noop,
|
714
|
+
error: noop
|
732
715
|
}, hmrLogger = {
|
733
|
-
|
734
|
-
|
716
|
+
debug: (...msg) => console.log("[vite]", ...msg),
|
717
|
+
error: (error) => console.log("[vite]", error)
|
735
718
|
};
|
736
719
|
function createHMRHandler(handler) {
|
737
|
-
|
738
|
-
|
739
|
-
}
|
740
|
-
class Queue {
|
741
|
-
queue = [];
|
742
|
-
pending = !1;
|
743
|
-
enqueue(promise) {
|
744
|
-
return new Promise((resolve2, reject) => {
|
745
|
-
this.queue.push({
|
746
|
-
promise,
|
747
|
-
resolve: resolve2,
|
748
|
-
reject
|
749
|
-
}), this.dequeue();
|
750
|
-
});
|
751
|
-
}
|
752
|
-
dequeue() {
|
753
|
-
if (this.pending)
|
754
|
-
return !1;
|
755
|
-
const item = this.queue.shift();
|
756
|
-
return item ? (this.pending = !0, item.promise().then(item.resolve).catch(item.reject).finally(() => {
|
757
|
-
this.pending = !1, this.dequeue();
|
758
|
-
}), !0) : !1;
|
759
|
-
}
|
720
|
+
let queue = new Queue();
|
721
|
+
return (payload) => queue.enqueue(() => handler(payload));
|
760
722
|
}
|
723
|
+
var Queue = class {
|
724
|
+
queue = [];
|
725
|
+
pending = !1;
|
726
|
+
enqueue(promise) {
|
727
|
+
return new Promise((resolve$1, reject) => {
|
728
|
+
this.queue.push({
|
729
|
+
promise,
|
730
|
+
resolve: resolve$1,
|
731
|
+
reject
|
732
|
+
}), this.dequeue();
|
733
|
+
});
|
734
|
+
}
|
735
|
+
dequeue() {
|
736
|
+
if (this.pending) return !1;
|
737
|
+
let item = this.queue.shift();
|
738
|
+
return item ? (this.pending = !0, item.promise().then(item.resolve).catch(item.reject).finally(() => {
|
739
|
+
this.pending = !1, this.dequeue();
|
740
|
+
}), !0) : !1;
|
741
|
+
}
|
742
|
+
};
|
761
743
|
function createHMRHandlerForRunner(runner) {
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
case "error": {
|
805
|
-
await hmrClient.notifyListeners("vite:error", payload);
|
806
|
-
const err = payload.err;
|
807
|
-
hmrClient.logger.error(
|
808
|
-
`Internal Server Error
|
809
|
-
${err.message}
|
810
|
-
${err.stack}`
|
811
|
-
);
|
812
|
-
break;
|
813
|
-
}
|
814
|
-
case "ping":
|
815
|
-
break;
|
816
|
-
default:
|
817
|
-
return payload;
|
818
|
-
}
|
819
|
-
});
|
744
|
+
return createHMRHandler(async (payload) => {
|
745
|
+
let hmrClient = runner.hmrClient;
|
746
|
+
if (!(!hmrClient || runner.isClosed())) switch (payload.type) {
|
747
|
+
case "connected":
|
748
|
+
hmrClient.logger.debug("connected.");
|
749
|
+
break;
|
750
|
+
case "update":
|
751
|
+
await hmrClient.notifyListeners("vite:beforeUpdate", payload), await Promise.all(payload.updates.map(async (update) => {
|
752
|
+
if (update.type === "js-update") return update.acceptedPath = unwrapId(update.acceptedPath), update.path = unwrapId(update.path), hmrClient.queueUpdate(update);
|
753
|
+
hmrClient.logger.error("css hmr is not supported in runner mode.");
|
754
|
+
})), await hmrClient.notifyListeners("vite:afterUpdate", payload);
|
755
|
+
break;
|
756
|
+
case "custom":
|
757
|
+
await hmrClient.notifyListeners(payload.event, payload.data);
|
758
|
+
break;
|
759
|
+
case "full-reload": {
|
760
|
+
let { triggeredBy } = payload, clearEntrypointUrls = triggeredBy ? getModulesEntrypoints(runner, getModulesByFile(runner, slash(triggeredBy))) : findAllEntrypoints(runner);
|
761
|
+
if (!clearEntrypointUrls.size) break;
|
762
|
+
hmrClient.logger.debug("program reload"), await hmrClient.notifyListeners("vite:beforeFullReload", payload), runner.evaluatedModules.clear();
|
763
|
+
for (let url of clearEntrypointUrls) try {
|
764
|
+
await runner.import(url);
|
765
|
+
} catch (err) {
|
766
|
+
err.code !== ERR_OUTDATED_OPTIMIZED_DEP && hmrClient.logger.error(`An error happened during full reload\n${err.message}\n${err.stack}`);
|
767
|
+
}
|
768
|
+
break;
|
769
|
+
}
|
770
|
+
case "prune":
|
771
|
+
await hmrClient.notifyListeners("vite:beforePrune", payload), await hmrClient.prunePaths(payload.paths);
|
772
|
+
break;
|
773
|
+
case "error": {
|
774
|
+
await hmrClient.notifyListeners("vite:error", payload);
|
775
|
+
let err = payload.err;
|
776
|
+
hmrClient.logger.error(`Internal Server Error\n${err.message}\n${err.stack}`);
|
777
|
+
break;
|
778
|
+
}
|
779
|
+
case "ping": break;
|
780
|
+
default: {
|
781
|
+
let check = payload;
|
782
|
+
return check;
|
783
|
+
}
|
784
|
+
}
|
785
|
+
});
|
820
786
|
}
|
821
787
|
function getModulesByFile(runner, file) {
|
822
|
-
|
823
|
-
|
788
|
+
let nodes = runner.evaluatedModules.getModulesByFile(file);
|
789
|
+
return nodes ? [...nodes].map((node) => node.id) : [];
|
824
790
|
}
|
825
791
|
function getModulesEntrypoints(runner, modules, visited = /* @__PURE__ */ new Set(), entrypoints = /* @__PURE__ */ new Set()) {
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
}
|
839
|
-
return entrypoints;
|
792
|
+
for (let moduleId of modules) {
|
793
|
+
if (visited.has(moduleId)) continue;
|
794
|
+
visited.add(moduleId);
|
795
|
+
let module = runner.evaluatedModules.getModuleById(moduleId);
|
796
|
+
if (!module) continue;
|
797
|
+
if (!module.importers.size) {
|
798
|
+
entrypoints.add(module.url);
|
799
|
+
continue;
|
800
|
+
}
|
801
|
+
for (let importer of module.importers) getModulesEntrypoints(runner, [importer], visited, entrypoints);
|
802
|
+
}
|
803
|
+
return entrypoints;
|
840
804
|
}
|
841
805
|
function findAllEntrypoints(runner, entrypoints = /* @__PURE__ */ new Set()) {
|
842
|
-
|
843
|
-
|
844
|
-
return entrypoints;
|
806
|
+
for (let mod of runner.evaluatedModules.idToModuleMap.values()) mod.importers.size || entrypoints.add(mod.url);
|
807
|
+
return entrypoints;
|
845
808
|
}
|
846
809
|
const sourceMapCache = {}, fileContentsCache = {}, evaluatedModulesCache = /* @__PURE__ */ new Set(), retrieveFileHandlers = /* @__PURE__ */ new Set(), retrieveSourceMapHandlers = /* @__PURE__ */ new Set(), createExecHandlers = (handlers) => (...args) => {
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
}, retrieveFileFromHandlers = createExecHandlers(retrieveFileHandlers), retrieveSourceMapFromHandlers = createExecHandlers(
|
853
|
-
retrieveSourceMapHandlers
|
854
|
-
);
|
810
|
+
for (let handler of handlers) {
|
811
|
+
let result = handler(...args);
|
812
|
+
if (result) return result;
|
813
|
+
}
|
814
|
+
return null;
|
815
|
+
}, retrieveFileFromHandlers = createExecHandlers(retrieveFileHandlers), retrieveSourceMapFromHandlers = createExecHandlers(retrieveSourceMapHandlers);
|
855
816
|
let overridden = !1;
|
856
817
|
const originalPrepare = Error.prepareStackTrace;
|
857
818
|
function resetInterceptor(runner, options) {
|
858
|
-
|
819
|
+
evaluatedModulesCache.delete(runner.evaluatedModules), options.retrieveFile && retrieveFileHandlers.delete(options.retrieveFile), options.retrieveSourceMap && retrieveSourceMapHandlers.delete(options.retrieveSourceMap), evaluatedModulesCache.size === 0 && (Error.prepareStackTrace = originalPrepare, overridden = !1);
|
859
820
|
}
|
860
821
|
function interceptStackTrace(runner, options = {}) {
|
861
|
-
|
822
|
+
return overridden || (Error.prepareStackTrace = prepareStackTrace, overridden = !0), evaluatedModulesCache.add(runner.evaluatedModules), options.retrieveFile && retrieveFileHandlers.add(options.retrieveFile), options.retrieveSourceMap && retrieveSourceMapHandlers.add(options.retrieveSourceMap), () => resetInterceptor(runner, options);
|
862
823
|
}
|
863
824
|
function supportRelativeURL(file, url) {
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
const startPath = dir.slice(protocol.length);
|
868
|
-
return protocol && /^\/\w:/.test(startPath) ? (protocol += "/", protocol + slash(posixResolve(startPath, url))) : protocol + posixResolve(startPath, url);
|
825
|
+
if (!file) return url;
|
826
|
+
let dir = posixDirname(slash(file)), match = /^\w+:\/\/[^/]*/.exec(dir), protocol = match ? match[0] : "", startPath = dir.slice(protocol.length);
|
827
|
+
return protocol && /^\/\w:/.test(startPath) ? (protocol += "/", protocol + slash(posixResolve(startPath, url))) : protocol + posixResolve(startPath, url);
|
869
828
|
}
|
870
829
|
function getRunnerSourceMap(position) {
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
return null;
|
830
|
+
for (let moduleGraph of evaluatedModulesCache) {
|
831
|
+
let sourceMap = moduleGraph.getModuleSourceMapById(position.source);
|
832
|
+
if (sourceMap) return {
|
833
|
+
url: position.source,
|
834
|
+
map: sourceMap,
|
835
|
+
vite: !0
|
836
|
+
};
|
837
|
+
}
|
838
|
+
return null;
|
881
839
|
}
|
882
840
|
function retrieveFile(path) {
|
883
|
-
|
884
|
-
|
885
|
-
|
841
|
+
if (path in fileContentsCache) return fileContentsCache[path];
|
842
|
+
let content = retrieveFileFromHandlers(path);
|
843
|
+
return typeof content == "string" ? (fileContentsCache[path] = content, content) : null;
|
886
844
|
}
|
887
845
|
function retrieveSourceMapURL(source) {
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
return lastMatch ? lastMatch[1] : null;
|
846
|
+
let fileData = retrieveFile(source);
|
847
|
+
if (!fileData) return null;
|
848
|
+
let re = /\/\/[@#]\s*sourceMappingURL=([^\s'"]+)\s*$|\/\*[@#]\s*sourceMappingURL=[^\s*'"]+\s*\*\/\s*$/gm, lastMatch, match;
|
849
|
+
for (; match = re.exec(fileData);) lastMatch = match;
|
850
|
+
return lastMatch ? lastMatch[1] : null;
|
894
851
|
}
|
895
852
|
const reSourceMap = /^data:application\/json[^,]+base64,/;
|
896
853
|
function retrieveSourceMap(source) {
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
} : null;
|
854
|
+
let urlAndMap = retrieveSourceMapFromHandlers(source);
|
855
|
+
if (urlAndMap) return urlAndMap;
|
856
|
+
let sourceMappingURL = retrieveSourceMapURL(source);
|
857
|
+
if (!sourceMappingURL) return null;
|
858
|
+
let sourceMapData;
|
859
|
+
if (reSourceMap.test(sourceMappingURL)) {
|
860
|
+
let rawData = sourceMappingURL.slice(sourceMappingURL.indexOf(",") + 1);
|
861
|
+
sourceMapData = Buffer.from(rawData, "base64").toString(), sourceMappingURL = source;
|
862
|
+
} else sourceMappingURL = supportRelativeURL(source, sourceMappingURL), sourceMapData = retrieveFile(sourceMappingURL);
|
863
|
+
return sourceMapData ? {
|
864
|
+
url: sourceMappingURL,
|
865
|
+
map: sourceMapData
|
866
|
+
} : null;
|
911
867
|
}
|
912
868
|
function mapSourcePosition(position) {
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
const originalPosition = getOriginalPosition(sourceMap.map, position);
|
942
|
-
if (originalPosition && originalPosition.source != null)
|
943
|
-
return originalPosition.source = supportRelativeURL(
|
944
|
-
sourceMap.url,
|
945
|
-
originalPosition.source
|
946
|
-
), sourceMap.vite && (originalPosition._vite = !0), originalPosition;
|
947
|
-
}
|
948
|
-
return position;
|
869
|
+
if (!position.source) return position;
|
870
|
+
let sourceMap = getRunnerSourceMap(position);
|
871
|
+
if (sourceMap ||= sourceMapCache[position.source], !sourceMap) {
|
872
|
+
let urlAndMap = retrieveSourceMap(position.source);
|
873
|
+
if (urlAndMap && urlAndMap.map) {
|
874
|
+
let url = urlAndMap.url;
|
875
|
+
sourceMap = sourceMapCache[position.source] = {
|
876
|
+
url,
|
877
|
+
map: new DecodedMap(typeof urlAndMap.map == "string" ? JSON.parse(urlAndMap.map) : urlAndMap.map, url)
|
878
|
+
};
|
879
|
+
let contents = sourceMap.map?.map.sourcesContent;
|
880
|
+
sourceMap.map && contents && sourceMap.map.resolvedSources.forEach((source, i) => {
|
881
|
+
let content = contents[i];
|
882
|
+
if (content && source && url) {
|
883
|
+
let contentUrl = supportRelativeURL(url, source);
|
884
|
+
fileContentsCache[contentUrl] = content;
|
885
|
+
}
|
886
|
+
});
|
887
|
+
} else sourceMap = sourceMapCache[position.source] = {
|
888
|
+
url: null,
|
889
|
+
map: null
|
890
|
+
};
|
891
|
+
}
|
892
|
+
if (sourceMap.map && sourceMap.url) {
|
893
|
+
let originalPosition = getOriginalPosition(sourceMap.map, position);
|
894
|
+
if (originalPosition && originalPosition.source != null) return originalPosition.source = supportRelativeURL(sourceMap.url, originalPosition.source), sourceMap.vite && (originalPosition._vite = !0), originalPosition;
|
895
|
+
}
|
896
|
+
return position;
|
949
897
|
}
|
950
898
|
function mapEvalOrigin(origin) {
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
899
|
+
let match = /^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(origin);
|
900
|
+
if (match) {
|
901
|
+
let position = mapSourcePosition({
|
902
|
+
name: null,
|
903
|
+
source: match[2],
|
904
|
+
line: +match[3],
|
905
|
+
column: match[4] - 1
|
906
|
+
});
|
907
|
+
return `eval at ${match[1]} (${position.source}:${position.line}:${position.column + 1})`;
|
908
|
+
}
|
909
|
+
return match = /^eval at ([^(]+) \((.+)\)$/.exec(origin), match ? `eval at ${match[1]} (${mapEvalOrigin(match[2])})` : origin;
|
962
910
|
}
|
963
911
|
function CallSiteToString() {
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
let typeName = this.getTypeName();
|
984
|
-
typeName === "[object Object]" && (typeName = "null");
|
985
|
-
const methodName = this.getMethodName();
|
986
|
-
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>"}`;
|
987
|
-
}
|
988
|
-
return addSuffix && (line += ` (${fileLocation})`), line;
|
912
|
+
let fileName, fileLocation = "";
|
913
|
+
if (this.isNative()) fileLocation = "native";
|
914
|
+
else {
|
915
|
+
fileName = this.getScriptNameOrSourceURL(), !fileName && this.isEval() && (fileLocation = this.getEvalOrigin(), fileLocation += ", "), fileName ? fileLocation += fileName : fileLocation += "<anonymous>";
|
916
|
+
let lineNumber = this.getLineNumber();
|
917
|
+
if (lineNumber != null) {
|
918
|
+
fileLocation += `:${lineNumber}`;
|
919
|
+
let columnNumber = this.getColumnNumber();
|
920
|
+
columnNumber && (fileLocation += `:${columnNumber}`);
|
921
|
+
}
|
922
|
+
}
|
923
|
+
let line = "", functionName = this.getFunctionName(), addSuffix = !0, isConstructor = this.isConstructor(), isMethodCall = !(this.isToplevel() || isConstructor);
|
924
|
+
if (isMethodCall) {
|
925
|
+
let typeName = this.getTypeName();
|
926
|
+
typeName === "[object Object]" && (typeName = "null");
|
927
|
+
let methodName = this.getMethodName();
|
928
|
+
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>"}`;
|
929
|
+
} else isConstructor ? line += `new ${functionName || "<anonymous>"}` : functionName ? line += functionName : (line += fileLocation, addSuffix = !1);
|
930
|
+
return addSuffix && (line += ` (${fileLocation})`), line;
|
989
931
|
}
|
990
932
|
function cloneCallSite(frame) {
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
933
|
+
let object = {};
|
934
|
+
return Object.getOwnPropertyNames(Object.getPrototypeOf(frame)).forEach((name) => {
|
935
|
+
let key = name;
|
936
|
+
object[key] = /^(?:is|get)/.test(name) ? function() {
|
937
|
+
return frame[key].call(frame);
|
938
|
+
} : frame[key];
|
939
|
+
}), object.toString = CallSiteToString, object;
|
998
940
|
}
|
999
941
|
function wrapCallSite(frame, state) {
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
942
|
+
if (state === void 0 && (state = {
|
943
|
+
nextPosition: null,
|
944
|
+
curPosition: null
|
945
|
+
}), frame.isNative()) return state.curPosition = null, frame;
|
946
|
+
let source = frame.getFileName() || frame.getScriptNameOrSourceURL();
|
947
|
+
if (source) {
|
948
|
+
let line = frame.getLineNumber(), column = frame.getColumnNumber() - 1, headerLength = 62;
|
949
|
+
line === 1 && column > headerLength && !frame.isEval() && (column -= headerLength);
|
950
|
+
let position = mapSourcePosition({
|
951
|
+
name: null,
|
952
|
+
source,
|
953
|
+
line,
|
954
|
+
column
|
955
|
+
});
|
956
|
+
state.curPosition = position, frame = cloneCallSite(frame);
|
957
|
+
let originalFunctionName = frame.getFunctionName;
|
958
|
+
return frame.getFunctionName = function() {
|
959
|
+
let name = (() => state.nextPosition == null ? originalFunctionName() : state.nextPosition.name || originalFunctionName())();
|
960
|
+
return name === "eval" && "_vite" in position ? null : name;
|
961
|
+
}, frame.getFileName = function() {
|
962
|
+
return position.source ?? null;
|
963
|
+
}, frame.getLineNumber = function() {
|
964
|
+
return position.line;
|
965
|
+
}, frame.getColumnNumber = function() {
|
966
|
+
return position.column + 1;
|
967
|
+
}, frame.getScriptNameOrSourceURL = function() {
|
968
|
+
return position.source;
|
969
|
+
}, frame;
|
970
|
+
}
|
971
|
+
let origin = frame.isEval() && frame.getEvalOrigin();
|
972
|
+
return origin ? (origin = mapEvalOrigin(origin), frame = cloneCallSite(frame), frame.getEvalOrigin = function() {
|
973
|
+
return origin || void 0;
|
974
|
+
}, frame) : frame;
|
1033
975
|
}
|
1034
976
|
function prepareStackTrace(error, stack) {
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
977
|
+
let name = error.name || "Error", message = error.message || "", errorString = `${name}: ${message}`, state = {
|
978
|
+
nextPosition: null,
|
979
|
+
curPosition: null
|
980
|
+
}, processedStack = [];
|
981
|
+
for (let i = stack.length - 1; i >= 0; i--) processedStack.push(`\n at ${wrapCallSite(stack[i], state)}`), state.nextPosition = state.curPosition;
|
982
|
+
return state.curPosition = state.nextPosition = null, errorString + processedStack.reverse().join("");
|
1040
983
|
}
|
1041
984
|
function enableSourceMapSupport(runner) {
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
`Cannot use "sourcemapInterceptor: 'node'" because "process.setSourceMapsEnabled" function is not available. Please use Node >= 16.6.0.`
|
1050
|
-
);
|
1051
|
-
const isEnabledAlready = process.sourceMapsEnabled ?? !1;
|
1052
|
-
return process.setSourceMapsEnabled(!0), () => !isEnabledAlready && process.setSourceMapsEnabled(!1);
|
1053
|
-
}
|
1054
|
-
return interceptStackTrace(
|
1055
|
-
runner,
|
1056
|
-
typeof runner.options.sourcemapInterceptor == "object" ? runner.options.sourcemapInterceptor : void 0
|
1057
|
-
);
|
1058
|
-
}
|
1059
|
-
class ESModulesEvaluator {
|
1060
|
-
startOffset = getAsyncFunctionDeclarationPaddingLineCount();
|
1061
|
-
async runInlinedModule(context, code) {
|
1062
|
-
await new AsyncFunction(
|
1063
|
-
ssrModuleExportsKey,
|
1064
|
-
ssrImportMetaKey,
|
1065
|
-
ssrImportKey,
|
1066
|
-
ssrDynamicImportKey,
|
1067
|
-
ssrExportAllKey,
|
1068
|
-
// source map should already be inlined by Vite
|
1069
|
-
'"use strict";' + code
|
1070
|
-
)(
|
1071
|
-
context[ssrModuleExportsKey],
|
1072
|
-
context[ssrImportMetaKey],
|
1073
|
-
context[ssrImportKey],
|
1074
|
-
context[ssrDynamicImportKey],
|
1075
|
-
context[ssrExportAllKey]
|
1076
|
-
), Object.seal(context[ssrModuleExportsKey]);
|
1077
|
-
}
|
1078
|
-
runExternalModule(filepath) {
|
1079
|
-
return import(filepath);
|
1080
|
-
}
|
1081
|
-
}
|
1082
|
-
class ModuleRunner {
|
1083
|
-
constructor(options, evaluator = new ESModulesEvaluator(), debug) {
|
1084
|
-
if (this.options = options, this.evaluator = evaluator, this.debug = debug, this.evaluatedModules = options.evaluatedModules ?? new EvaluatedModules(), this.transport = normalizeModuleRunnerTransport(options.transport), options.hmr !== !1) {
|
1085
|
-
const optionsHmr = options.hmr ?? !0, resolvedHmrLogger = optionsHmr === !0 || optionsHmr.logger === void 0 ? hmrLogger : optionsHmr.logger === !1 ? silentConsole : optionsHmr.logger;
|
1086
|
-
if (this.hmrClient = new HMRClient(
|
1087
|
-
resolvedHmrLogger,
|
1088
|
-
this.transport,
|
1089
|
-
({ acceptedPath }) => this.import(acceptedPath)
|
1090
|
-
), !this.transport.connect)
|
1091
|
-
throw new Error(
|
1092
|
-
"HMR is not supported by this runner transport, but `hmr` option was set to true"
|
1093
|
-
);
|
1094
|
-
this.transport.connect(createHMRHandlerForRunner(this));
|
1095
|
-
} else
|
1096
|
-
this.transport.connect?.();
|
1097
|
-
options.sourcemapInterceptor !== !1 && (this.resetSourceMapSupport = enableSourceMapSupport(this));
|
1098
|
-
}
|
1099
|
-
evaluatedModules;
|
1100
|
-
hmrClient;
|
1101
|
-
envProxy = new Proxy({}, {
|
1102
|
-
get(_, p) {
|
1103
|
-
throw new Error(
|
1104
|
-
`[module runner] Dynamic access of "import.meta.env" is not supported. Please, use "import.meta.env.${String(p)}" instead.`
|
1105
|
-
);
|
1106
|
-
}
|
1107
|
-
});
|
1108
|
-
transport;
|
1109
|
-
resetSourceMapSupport;
|
1110
|
-
concurrentModuleNodePromises = /* @__PURE__ */ new Map();
|
1111
|
-
closed = !1;
|
1112
|
-
/**
|
1113
|
-
* URL to execute. Accepts file path, server path or id relative to the root.
|
1114
|
-
*/
|
1115
|
-
async import(url) {
|
1116
|
-
const fetchedModule = await this.cachedModule(url);
|
1117
|
-
return await this.cachedRequest(url, fetchedModule);
|
1118
|
-
}
|
1119
|
-
/**
|
1120
|
-
* Clear all caches including HMR listeners.
|
1121
|
-
*/
|
1122
|
-
clearCache() {
|
1123
|
-
this.evaluatedModules.clear(), this.hmrClient?.clear();
|
1124
|
-
}
|
1125
|
-
/**
|
1126
|
-
* Clears all caches, removes all HMR listeners, and resets source map support.
|
1127
|
-
* This method doesn't stop the HMR connection.
|
1128
|
-
*/
|
1129
|
-
async close() {
|
1130
|
-
this.resetSourceMapSupport?.(), this.clearCache(), this.hmrClient = void 0, this.closed = !0, await this.transport.disconnect?.();
|
1131
|
-
}
|
1132
|
-
/**
|
1133
|
-
* Returns `true` if the runtime has been closed by calling `close()` method.
|
1134
|
-
*/
|
1135
|
-
isClosed() {
|
1136
|
-
return this.closed;
|
1137
|
-
}
|
1138
|
-
processImport(exports, fetchResult, metadata) {
|
1139
|
-
if (!("externalize" in fetchResult))
|
1140
|
-
return exports;
|
1141
|
-
const { url, type } = fetchResult;
|
1142
|
-
return type !== "module" && type !== "commonjs" || analyzeImportedModDifference(exports, url, type, metadata), exports;
|
1143
|
-
}
|
1144
|
-
isCircularModule(mod) {
|
1145
|
-
for (const importedFile of mod.imports)
|
1146
|
-
if (mod.importers.has(importedFile))
|
1147
|
-
return !0;
|
1148
|
-
return !1;
|
1149
|
-
}
|
1150
|
-
isCircularImport(importers, moduleUrl, visited = /* @__PURE__ */ new Set()) {
|
1151
|
-
for (const importer of importers) {
|
1152
|
-
if (visited.has(importer))
|
1153
|
-
continue;
|
1154
|
-
if (visited.add(importer), importer === moduleUrl)
|
1155
|
-
return !0;
|
1156
|
-
const mod = this.evaluatedModules.getModuleById(importer);
|
1157
|
-
if (mod && mod.importers.size && this.isCircularImport(mod.importers, moduleUrl, visited))
|
1158
|
-
return !0;
|
1159
|
-
}
|
1160
|
-
return !1;
|
1161
|
-
}
|
1162
|
-
async cachedRequest(url, mod, callstack = [], metadata) {
|
1163
|
-
const meta = mod.meta, moduleId = meta.id, { importers } = mod, importee = callstack[callstack.length - 1];
|
1164
|
-
if (importee && importers.add(importee), (callstack.includes(moduleId) || this.isCircularModule(mod) || this.isCircularImport(importers, moduleId)) && mod.exports)
|
1165
|
-
return this.processImport(mod.exports, meta, metadata);
|
1166
|
-
let debugTimer;
|
1167
|
-
this.debug && (debugTimer = setTimeout(() => {
|
1168
|
-
const getStack = () => `stack:
|
1169
|
-
${[...callstack, moduleId].reverse().map((p) => ` - ${p}`).join(`
|
1170
|
-
`)}`;
|
1171
|
-
this.debug(
|
1172
|
-
`[module runner] module ${moduleId} takes over 2s to load.
|
1173
|
-
${getStack()}`
|
1174
|
-
);
|
1175
|
-
}, 2e3));
|
1176
|
-
try {
|
1177
|
-
if (mod.promise)
|
1178
|
-
return this.processImport(await mod.promise, meta, metadata);
|
1179
|
-
const promise = this.directRequest(url, mod, callstack);
|
1180
|
-
return mod.promise = promise, mod.evaluated = !1, this.processImport(await promise, meta, metadata);
|
1181
|
-
} finally {
|
1182
|
-
mod.evaluated = !0, debugTimer && clearTimeout(debugTimer);
|
1183
|
-
}
|
1184
|
-
}
|
1185
|
-
async cachedModule(url, importer) {
|
1186
|
-
let cached = this.concurrentModuleNodePromises.get(url);
|
1187
|
-
if (cached)
|
1188
|
-
this.debug?.("[module runner] using cached module info for", url);
|
1189
|
-
else {
|
1190
|
-
const cachedModule = this.evaluatedModules.getModuleByUrl(url);
|
1191
|
-
cached = this.getModuleInformation(url, importer, cachedModule).finally(
|
1192
|
-
() => {
|
1193
|
-
this.concurrentModuleNodePromises.delete(url);
|
1194
|
-
}
|
1195
|
-
), this.concurrentModuleNodePromises.set(url, cached);
|
1196
|
-
}
|
1197
|
-
return cached;
|
1198
|
-
}
|
1199
|
-
async getModuleInformation(url, importer, cachedModule) {
|
1200
|
-
if (this.closed)
|
1201
|
-
throw new Error("Vite module runner has been closed.");
|
1202
|
-
this.debug?.("[module runner] fetching", url);
|
1203
|
-
const isCached = !!(typeof cachedModule == "object" && cachedModule.meta), fetchedModule = (
|
1204
|
-
// fast return for established externalized pattern
|
1205
|
-
url.startsWith("data:") ? { externalize: url, type: "builtin" } : await this.transport.invoke("fetchModule", [
|
1206
|
-
url,
|
1207
|
-
importer,
|
1208
|
-
{
|
1209
|
-
cached: isCached,
|
1210
|
-
startOffset: this.evaluator.startOffset
|
1211
|
-
}
|
1212
|
-
])
|
1213
|
-
);
|
1214
|
-
if ("cache" in fetchedModule) {
|
1215
|
-
if (!cachedModule || !cachedModule.meta)
|
1216
|
-
throw new Error(
|
1217
|
-
`Module "${url}" was mistakenly invalidated during fetch phase.`
|
1218
|
-
);
|
1219
|
-
return cachedModule;
|
1220
|
-
}
|
1221
|
-
const moduleId = "externalize" in fetchedModule ? fetchedModule.externalize : fetchedModule.id, moduleUrl = "url" in fetchedModule ? fetchedModule.url : url, module = this.evaluatedModules.ensureModule(moduleId, moduleUrl);
|
1222
|
-
return "invalidate" in fetchedModule && fetchedModule.invalidate && this.evaluatedModules.invalidateModule(module), fetchedModule.url = moduleUrl, fetchedModule.id = moduleId, module.meta = fetchedModule, module;
|
1223
|
-
}
|
1224
|
-
// override is allowed, consider this a public API
|
1225
|
-
async directRequest(url, mod, _callstack) {
|
1226
|
-
const fetchResult = mod.meta, moduleId = fetchResult.id, callstack = [..._callstack, moduleId], request = async (dep, metadata) => {
|
1227
|
-
const importer = "file" in fetchResult && fetchResult.file || moduleId, depMod = await this.cachedModule(dep, importer);
|
1228
|
-
return depMod.importers.add(moduleId), mod.imports.add(depMod.id), this.cachedRequest(dep, depMod, callstack, metadata);
|
1229
|
-
}, dynamicRequest = async (dep) => (dep = String(dep), dep[0] === "." && (dep = posixResolve(posixDirname(url), dep)), request(dep, { isDynamicImport: !0 }));
|
1230
|
-
if ("externalize" in fetchResult) {
|
1231
|
-
const { externalize } = fetchResult;
|
1232
|
-
this.debug?.("[module runner] externalizing", externalize);
|
1233
|
-
const exports2 = await this.evaluator.runExternalModule(externalize);
|
1234
|
-
return mod.exports = exports2, exports2;
|
1235
|
-
}
|
1236
|
-
const { code, file } = fetchResult;
|
1237
|
-
if (code == null) {
|
1238
|
-
const importer = callstack[callstack.length - 2];
|
1239
|
-
throw new Error(
|
1240
|
-
`[module runner] Failed to load "${url}"${importer ? ` imported from ${importer}` : ""}`
|
1241
|
-
);
|
1242
|
-
}
|
1243
|
-
const modulePath = cleanUrl(file || moduleId), href = posixPathToFileHref(modulePath), filename = modulePath, dirname2 = posixDirname(modulePath), meta = {
|
1244
|
-
filename: isWindows ? toWindowsPath(filename) : filename,
|
1245
|
-
dirname: isWindows ? toWindowsPath(dirname2) : dirname2,
|
1246
|
-
url: href,
|
1247
|
-
env: this.envProxy,
|
1248
|
-
resolve(_id, _parent) {
|
1249
|
-
throw new Error(
|
1250
|
-
'[module runner] "import.meta.resolve" is not supported.'
|
1251
|
-
);
|
1252
|
-
},
|
1253
|
-
// should be replaced during transformation
|
1254
|
-
glob() {
|
1255
|
-
throw new Error(
|
1256
|
-
'[module runner] "import.meta.glob" is statically replaced during file transformation. Make sure to reference it by the full name.'
|
1257
|
-
);
|
1258
|
-
}
|
1259
|
-
}, exports = /* @__PURE__ */ Object.create(null);
|
1260
|
-
Object.defineProperty(exports, Symbol.toStringTag, {
|
1261
|
-
value: "Module",
|
1262
|
-
enumerable: !1,
|
1263
|
-
configurable: !1
|
1264
|
-
}), mod.exports = exports;
|
1265
|
-
let hotContext;
|
1266
|
-
this.hmrClient && Object.defineProperty(meta, "hot", {
|
1267
|
-
enumerable: !0,
|
1268
|
-
get: () => {
|
1269
|
-
if (!this.hmrClient)
|
1270
|
-
throw new Error("[module runner] HMR client was closed.");
|
1271
|
-
return this.debug?.("[module runner] creating hmr context for", mod.url), hotContext ||= new HMRContext(this.hmrClient, mod.url), hotContext;
|
1272
|
-
},
|
1273
|
-
set: (value) => {
|
1274
|
-
hotContext = value;
|
1275
|
-
}
|
1276
|
-
});
|
1277
|
-
const context = {
|
1278
|
-
[ssrImportKey]: request,
|
1279
|
-
[ssrDynamicImportKey]: dynamicRequest,
|
1280
|
-
[ssrModuleExportsKey]: exports,
|
1281
|
-
[ssrExportAllKey]: (obj) => exportAll(exports, obj),
|
1282
|
-
[ssrImportMetaKey]: meta
|
1283
|
-
};
|
1284
|
-
return this.debug?.("[module runner] executing", href), await this.evaluator.runInlinedModule(context, code, mod), exports;
|
1285
|
-
}
|
985
|
+
if (runner.options.sourcemapInterceptor === "node") {
|
986
|
+
if (typeof process > "u") throw TypeError("Cannot use \"sourcemapInterceptor: 'node'\" because global \"process\" variable is not available.");
|
987
|
+
if (typeof process.setSourceMapsEnabled != "function") throw TypeError("Cannot use \"sourcemapInterceptor: 'node'\" because \"process.setSourceMapsEnabled\" function is not available. Please use Node >= 16.6.0.");
|
988
|
+
let isEnabledAlready = process.sourceMapsEnabled ?? !1;
|
989
|
+
return process.setSourceMapsEnabled(!0), () => !isEnabledAlready && process.setSourceMapsEnabled(!1);
|
990
|
+
}
|
991
|
+
return interceptStackTrace(runner, typeof runner.options.sourcemapInterceptor == "object" ? runner.options.sourcemapInterceptor : void 0);
|
1286
992
|
}
|
993
|
+
var ESModulesEvaluator = class {
|
994
|
+
startOffset = getAsyncFunctionDeclarationPaddingLineCount();
|
995
|
+
async runInlinedModule(context, code) {
|
996
|
+
let initModule = new AsyncFunction(ssrModuleExportsKey, ssrImportMetaKey, ssrImportKey, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, "\"use strict\";" + code);
|
997
|
+
await initModule(context[ssrModuleExportsKey], context[ssrImportMetaKey], context[ssrImportKey], context[ssrDynamicImportKey], context[ssrExportAllKey], context[ssrExportNameKey]), Object.seal(context[ssrModuleExportsKey]);
|
998
|
+
}
|
999
|
+
runExternalModule(filepath) {
|
1000
|
+
return import(filepath);
|
1001
|
+
}
|
1002
|
+
}, ModuleRunner = class {
|
1003
|
+
evaluatedModules;
|
1004
|
+
hmrClient;
|
1005
|
+
envProxy = new Proxy({}, { get(_, p) {
|
1006
|
+
throw Error(`[module runner] Dynamic access of "import.meta.env" is not supported. Please, use "import.meta.env.${String(p)}" instead.`);
|
1007
|
+
} });
|
1008
|
+
transport;
|
1009
|
+
resetSourceMapSupport;
|
1010
|
+
concurrentModuleNodePromises = /* @__PURE__ */ new Map();
|
1011
|
+
closed = !1;
|
1012
|
+
constructor(options, evaluator = new ESModulesEvaluator(), debug) {
|
1013
|
+
if (this.options = options, this.evaluator = evaluator, this.debug = debug, this.evaluatedModules = options.evaluatedModules ?? new EvaluatedModules(), this.transport = normalizeModuleRunnerTransport(options.transport), options.hmr !== !1) {
|
1014
|
+
let optionsHmr = options.hmr ?? !0, resolvedHmrLogger = optionsHmr === !0 || optionsHmr.logger === void 0 ? hmrLogger : optionsHmr.logger === !1 ? silentConsole : optionsHmr.logger;
|
1015
|
+
if (this.hmrClient = new HMRClient(resolvedHmrLogger, 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");
|
1016
|
+
this.transport.connect(createHMRHandlerForRunner(this));
|
1017
|
+
} else this.transport.connect?.();
|
1018
|
+
options.sourcemapInterceptor !== !1 && (this.resetSourceMapSupport = enableSourceMapSupport(this));
|
1019
|
+
}
|
1020
|
+
/**
|
1021
|
+
* URL to execute. Accepts file path, server path or id relative to the root.
|
1022
|
+
*/
|
1023
|
+
async import(url) {
|
1024
|
+
let fetchedModule = await this.cachedModule(url);
|
1025
|
+
return await this.cachedRequest(url, fetchedModule);
|
1026
|
+
}
|
1027
|
+
/**
|
1028
|
+
* Clear all caches including HMR listeners.
|
1029
|
+
*/
|
1030
|
+
clearCache() {
|
1031
|
+
this.evaluatedModules.clear(), this.hmrClient?.clear();
|
1032
|
+
}
|
1033
|
+
/**
|
1034
|
+
* Clears all caches, removes all HMR listeners, and resets source map support.
|
1035
|
+
* This method doesn't stop the HMR connection.
|
1036
|
+
*/
|
1037
|
+
async close() {
|
1038
|
+
this.resetSourceMapSupport?.(), this.clearCache(), this.hmrClient = void 0, this.closed = !0, await this.transport.disconnect?.();
|
1039
|
+
}
|
1040
|
+
/**
|
1041
|
+
* Returns `true` if the runtime has been closed by calling `close()` method.
|
1042
|
+
*/
|
1043
|
+
isClosed() {
|
1044
|
+
return this.closed;
|
1045
|
+
}
|
1046
|
+
processImport(exports, fetchResult, metadata) {
|
1047
|
+
if (!("externalize" in fetchResult)) return exports;
|
1048
|
+
let { url, type } = fetchResult;
|
1049
|
+
return type !== "module" && type !== "commonjs" || analyzeImportedModDifference(exports, url, type, metadata), exports;
|
1050
|
+
}
|
1051
|
+
isCircularModule(mod) {
|
1052
|
+
for (let importedFile of mod.imports) if (mod.importers.has(importedFile)) return !0;
|
1053
|
+
return !1;
|
1054
|
+
}
|
1055
|
+
isCircularImport(importers, moduleUrl, visited = /* @__PURE__ */ new Set()) {
|
1056
|
+
for (let importer of importers) {
|
1057
|
+
if (visited.has(importer)) continue;
|
1058
|
+
if (visited.add(importer), importer === moduleUrl) return !0;
|
1059
|
+
let mod = this.evaluatedModules.getModuleById(importer);
|
1060
|
+
if (mod && mod.importers.size && this.isCircularImport(mod.importers, moduleUrl, visited)) return !0;
|
1061
|
+
}
|
1062
|
+
return !1;
|
1063
|
+
}
|
1064
|
+
async cachedRequest(url, mod, callstack = [], metadata) {
|
1065
|
+
let meta = mod.meta, moduleId = meta.id, { importers } = mod, importee = callstack[callstack.length - 1];
|
1066
|
+
if (importee && importers.add(importee), (callstack.includes(moduleId) || this.isCircularModule(mod) || this.isCircularImport(importers, moduleId)) && mod.exports) return this.processImport(mod.exports, meta, metadata);
|
1067
|
+
let debugTimer;
|
1068
|
+
this.debug && (debugTimer = setTimeout(() => {
|
1069
|
+
let getStack = () => `stack:\n${[...callstack, moduleId].reverse().map((p) => ` - ${p}`).join("\n")}`;
|
1070
|
+
this.debug(`[module runner] module ${moduleId} takes over 2s to load.\n${getStack()}`);
|
1071
|
+
}, 2e3));
|
1072
|
+
try {
|
1073
|
+
if (mod.promise) return this.processImport(await mod.promise, meta, metadata);
|
1074
|
+
let promise = this.directRequest(url, mod, callstack);
|
1075
|
+
return mod.promise = promise, mod.evaluated = !1, this.processImport(await promise, meta, metadata);
|
1076
|
+
} finally {
|
1077
|
+
mod.evaluated = !0, debugTimer && clearTimeout(debugTimer);
|
1078
|
+
}
|
1079
|
+
}
|
1080
|
+
async cachedModule(url, importer) {
|
1081
|
+
let cached = this.concurrentModuleNodePromises.get(url);
|
1082
|
+
if (cached) this.debug?.("[module runner] using cached module info for", url);
|
1083
|
+
else {
|
1084
|
+
let cachedModule = this.evaluatedModules.getModuleByUrl(url);
|
1085
|
+
cached = this.getModuleInformation(url, importer, cachedModule).finally(() => {
|
1086
|
+
this.concurrentModuleNodePromises.delete(url);
|
1087
|
+
}), this.concurrentModuleNodePromises.set(url, cached);
|
1088
|
+
}
|
1089
|
+
return cached;
|
1090
|
+
}
|
1091
|
+
async getModuleInformation(url, importer, cachedModule) {
|
1092
|
+
if (this.closed) throw Error("Vite module runner has been closed.");
|
1093
|
+
this.debug?.("[module runner] fetching", url);
|
1094
|
+
let isCached = !!(typeof cachedModule == "object" && cachedModule.meta), fetchedModule = url.startsWith("data:") ? {
|
1095
|
+
externalize: url,
|
1096
|
+
type: "builtin"
|
1097
|
+
} : await this.transport.invoke("fetchModule", [
|
1098
|
+
url,
|
1099
|
+
importer,
|
1100
|
+
{
|
1101
|
+
cached: isCached,
|
1102
|
+
startOffset: this.evaluator.startOffset
|
1103
|
+
}
|
1104
|
+
]);
|
1105
|
+
if ("cache" in fetchedModule) {
|
1106
|
+
if (!cachedModule || !cachedModule.meta) throw Error(`Module "${url}" was mistakenly invalidated during fetch phase.`);
|
1107
|
+
return cachedModule;
|
1108
|
+
}
|
1109
|
+
let moduleId = "externalize" in fetchedModule ? fetchedModule.externalize : fetchedModule.id, moduleUrl = "url" in fetchedModule ? fetchedModule.url : url, module = this.evaluatedModules.ensureModule(moduleId, moduleUrl);
|
1110
|
+
return "invalidate" in fetchedModule && fetchedModule.invalidate && this.evaluatedModules.invalidateModule(module), fetchedModule.url = moduleUrl, fetchedModule.id = moduleId, module.meta = fetchedModule, module;
|
1111
|
+
}
|
1112
|
+
async directRequest(url, mod, _callstack) {
|
1113
|
+
let fetchResult = mod.meta, moduleId = fetchResult.id, callstack = [..._callstack, moduleId], request = async (dep, metadata) => {
|
1114
|
+
let importer = "file" in fetchResult && fetchResult.file || moduleId, depMod = await this.cachedModule(dep, importer);
|
1115
|
+
return depMod.importers.add(moduleId), mod.imports.add(depMod.id), this.cachedRequest(dep, depMod, callstack, metadata);
|
1116
|
+
}, dynamicRequest = async (dep) => (dep = String(dep), dep[0] === "." && (dep = posixResolve(posixDirname(url), dep)), request(dep, { isDynamicImport: !0 }));
|
1117
|
+
if ("externalize" in fetchResult) {
|
1118
|
+
let { externalize } = fetchResult;
|
1119
|
+
this.debug?.("[module runner] externalizing", externalize);
|
1120
|
+
let exports$1 = await this.evaluator.runExternalModule(externalize);
|
1121
|
+
return mod.exports = exports$1, exports$1;
|
1122
|
+
}
|
1123
|
+
let { code, file } = fetchResult;
|
1124
|
+
if (code == null) {
|
1125
|
+
let importer = callstack[callstack.length - 2];
|
1126
|
+
throw Error(`[module runner] Failed to load "${url}"${importer ? ` imported from ${importer}` : ""}`);
|
1127
|
+
}
|
1128
|
+
let modulePath = cleanUrl(file || moduleId), href = posixPathToFileHref(modulePath), filename = modulePath, dirname$1 = posixDirname(modulePath), meta = {
|
1129
|
+
filename: isWindows ? toWindowsPath(filename) : filename,
|
1130
|
+
dirname: isWindows ? toWindowsPath(dirname$1) : dirname$1,
|
1131
|
+
url: href,
|
1132
|
+
env: this.envProxy,
|
1133
|
+
resolve(_id, _parent) {
|
1134
|
+
throw Error("[module runner] \"import.meta.resolve\" is not supported.");
|
1135
|
+
},
|
1136
|
+
glob() {
|
1137
|
+
throw Error("[module runner] \"import.meta.glob\" is statically replaced during file transformation. Make sure to reference it by the full name.");
|
1138
|
+
}
|
1139
|
+
}, exports = Object.create(null);
|
1140
|
+
Object.defineProperty(exports, Symbol.toStringTag, {
|
1141
|
+
value: "Module",
|
1142
|
+
enumerable: !1,
|
1143
|
+
configurable: !1
|
1144
|
+
}), mod.exports = exports;
|
1145
|
+
let hotContext;
|
1146
|
+
this.hmrClient && Object.defineProperty(meta, "hot", {
|
1147
|
+
enumerable: !0,
|
1148
|
+
get: () => {
|
1149
|
+
if (!this.hmrClient) throw Error("[module runner] HMR client was closed.");
|
1150
|
+
return this.debug?.("[module runner] creating hmr context for", mod.url), hotContext ||= new HMRContext(this.hmrClient, mod.url), hotContext;
|
1151
|
+
},
|
1152
|
+
set: (value) => {
|
1153
|
+
hotContext = value;
|
1154
|
+
}
|
1155
|
+
});
|
1156
|
+
let context = {
|
1157
|
+
[ssrImportKey]: request,
|
1158
|
+
[ssrDynamicImportKey]: dynamicRequest,
|
1159
|
+
[ssrModuleExportsKey]: exports,
|
1160
|
+
[ssrExportAllKey]: (obj) => exportAll(exports, obj),
|
1161
|
+
[ssrExportNameKey]: (name, getter) => Object.defineProperty(exports, name, {
|
1162
|
+
enumerable: !0,
|
1163
|
+
configurable: !0,
|
1164
|
+
get: getter
|
1165
|
+
}),
|
1166
|
+
[ssrImportMetaKey]: meta
|
1167
|
+
};
|
1168
|
+
return this.debug?.("[module runner] executing", href), await this.evaluator.runInlinedModule(context, code, mod), exports;
|
1169
|
+
}
|
1170
|
+
};
|
1287
1171
|
function exportAll(exports, sourceModule) {
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
} catch {
|
1298
|
-
}
|
1299
|
-
}
|
1172
|
+
if (exports !== sourceModule && !(isPrimitive(sourceModule) || Array.isArray(sourceModule) || sourceModule instanceof Promise)) {
|
1173
|
+
for (let key in sourceModule) if (key !== "default" && key !== "__esModule" && !(key in exports)) try {
|
1174
|
+
Object.defineProperty(exports, key, {
|
1175
|
+
enumerable: !0,
|
1176
|
+
configurable: !0,
|
1177
|
+
get: () => sourceModule[key]
|
1178
|
+
});
|
1179
|
+
} catch {}
|
1180
|
+
}
|
1300
1181
|
}
|
1301
|
-
export {
|
1302
|
-
ESModulesEvaluator,
|
1303
|
-
EvaluatedModules,
|
1304
|
-
ModuleRunner,
|
1305
|
-
createWebSocketModuleRunnerTransport,
|
1306
|
-
ssrDynamicImportKey,
|
1307
|
-
ssrExportAllKey,
|
1308
|
-
ssrImportKey,
|
1309
|
-
ssrImportMetaKey,
|
1310
|
-
ssrModuleExportsKey
|
1311
|
-
};
|
1182
|
+
export { ESModulesEvaluator, EvaluatedModules, ModuleRunner, createWebSocketModuleRunnerTransport, ssrDynamicImportKey, ssrExportAllKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
|