@vitest/browser 4.0.0-beta.9 → 4.0.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/README.md +6 -14
- package/context.d.ts +86 -29
- package/context.js +3 -2
- package/dist/client/.vite/manifest.json +6 -6
- package/dist/client/__vitest__/assets/index-COTh6lXR.css +1 -0
- package/dist/client/__vitest__/assets/index-DOkKC3NI.js +53 -0
- package/dist/client/__vitest__/index.html +2 -2
- package/dist/client/__vitest_browser__/orchestrator-CFVVvVT1.js +313 -0
- package/dist/client/__vitest_browser__/tester-BNxij3za.js +2133 -0
- package/dist/client/__vitest_browser__/{utils-FY_Qin7d.js → utils-uxqdqUz8.js} +48 -24
- package/dist/client/orchestrator.html +2 -2
- package/dist/client/tester/tester.html +2 -2
- package/dist/client.js +1 -1
- package/dist/context.js +80 -19
- package/dist/expect-element.js +14 -14
- package/dist/index-BnLTaCRv.js +6 -0
- package/dist/index.d.ts +64 -165
- package/dist/index.js +572 -1431
- package/dist/{locators/index.d.ts → locators.d.ts} +27 -3
- package/dist/locators.js +1 -0
- package/dist/state.js +0 -1
- package/dist/types.d.ts +0 -1
- package/jest-dom.d.ts +5 -5
- package/matchers.d.ts +2 -2
- package/package.json +18 -54
- package/utils.d.ts +5 -5
- package/dist/client/__vitest__/assets/index-CBcuRGkf.js +0 -57
- package/dist/client/__vitest__/assets/index-KbpJLW--.css +0 -1
- package/dist/client/__vitest_browser__/orchestrator-C2rrmv36.js +0 -3198
- package/dist/client/__vitest_browser__/tester-mSVktQ7a.js +0 -3282
- package/dist/index-B7Hfmz-h.js +0 -1
- package/dist/locators/index.js +0 -1
- package/dist/locators/playwright.js +0 -1
- package/dist/locators/preview.js +0 -1
- package/dist/locators/webdriverio.js +0 -1
- package/dist/providers.js +0 -47
- package/dist/public-utils-Kx5DUGWa.js +0 -6
- package/dist/utils.js +0 -1
- package/dist/webdriver-AHRa6U3j.js +0 -517
- package/providers/playwright.d.ts +0 -97
- package/providers/webdriverio.d.ts +0 -35
- package/providers.d.ts +0 -7
|
@@ -1,3282 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { g as getDefaultExportFromCjs$1, c as resolve, m as moduleRunner, d as getWorkerState, b as getConfig, a as getBrowserState } from "./utils-FY_Qin7d.js";
|
|
5
|
-
import { onCancel, globalChannel, channel, client } from "@vitest/browser/client";
|
|
6
|
-
import { userEvent, page, server } from "@vitest/browser/context";
|
|
7
|
-
import { getSafeTimers, TraceMap as TraceMap$1, originalPositionFor as originalPositionFor$1, loadDiffConfig, loadSnapshotSerializers, takeCoverageInsideWorker, stringify, format, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, startTests, collectTests, SpyModule } from "vitest/internal/browser";
|
|
8
|
-
import { VitestTestRunner, NodeBenchmarkRunner } from "vitest/runners";
|
|
9
|
-
const scriptRel = "modulepreload";
|
|
10
|
-
const assetsURL = function(dep) {
|
|
11
|
-
return "/" + dep;
|
|
12
|
-
};
|
|
13
|
-
const seen = {};
|
|
14
|
-
const __vitePreload = function preload(baseModule, deps, importerUrl) {
|
|
15
|
-
let promise = Promise.resolve();
|
|
16
|
-
if (deps && deps.length > 0) {
|
|
17
|
-
let allSettled2 = function(promises2) {
|
|
18
|
-
return Promise.all(
|
|
19
|
-
promises2.map(
|
|
20
|
-
(p2) => Promise.resolve(p2).then(
|
|
21
|
-
(value) => ({ status: "fulfilled", value }),
|
|
22
|
-
(reason) => ({ status: "rejected", reason })
|
|
23
|
-
)
|
|
24
|
-
)
|
|
25
|
-
);
|
|
26
|
-
};
|
|
27
|
-
document.getElementsByTagName("link");
|
|
28
|
-
const cspNonceMeta = document.querySelector(
|
|
29
|
-
"meta[property=csp-nonce]"
|
|
30
|
-
);
|
|
31
|
-
const cspNonce = (cspNonceMeta == null ? void 0 : cspNonceMeta.nonce) || (cspNonceMeta == null ? void 0 : cspNonceMeta.getAttribute("nonce"));
|
|
32
|
-
promise = allSettled2(
|
|
33
|
-
deps.map((dep) => {
|
|
34
|
-
dep = assetsURL(dep);
|
|
35
|
-
if (dep in seen) return;
|
|
36
|
-
seen[dep] = true;
|
|
37
|
-
const isCss = dep.endsWith(".css");
|
|
38
|
-
const cssSelector = isCss ? '[rel="stylesheet"]' : "";
|
|
39
|
-
if (document.querySelector(`link[href="${dep}"]${cssSelector}`)) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const link = document.createElement("link");
|
|
43
|
-
link.rel = isCss ? "stylesheet" : scriptRel;
|
|
44
|
-
if (!isCss) {
|
|
45
|
-
link.as = "script";
|
|
46
|
-
}
|
|
47
|
-
link.crossOrigin = "";
|
|
48
|
-
link.href = dep;
|
|
49
|
-
if (cspNonce) {
|
|
50
|
-
link.setAttribute("nonce", cspNonce);
|
|
51
|
-
}
|
|
52
|
-
document.head.appendChild(link);
|
|
53
|
-
if (isCss) {
|
|
54
|
-
return new Promise((res, rej) => {
|
|
55
|
-
link.addEventListener("load", res);
|
|
56
|
-
link.addEventListener(
|
|
57
|
-
"error",
|
|
58
|
-
() => rej(new Error(`Unable to preload CSS for ${dep}`))
|
|
59
|
-
);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
function handlePreloadError(err) {
|
|
66
|
-
const e = new Event("vite:preloadError", {
|
|
67
|
-
cancelable: true
|
|
68
|
-
});
|
|
69
|
-
e.payload = err;
|
|
70
|
-
window.dispatchEvent(e);
|
|
71
|
-
if (!e.defaultPrevented) {
|
|
72
|
-
throw err;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return promise.then((res) => {
|
|
76
|
-
for (const item of res || []) {
|
|
77
|
-
if (item.status !== "rejected") continue;
|
|
78
|
-
handlePreloadError(item.reason);
|
|
79
|
-
}
|
|
80
|
-
return baseModule().catch(handlePreloadError);
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
const { parse: $parse } = JSON;
|
|
84
|
-
const { keys } = Object;
|
|
85
|
-
const Primitive = String;
|
|
86
|
-
const primitive = "string";
|
|
87
|
-
const ignore = {};
|
|
88
|
-
const object = "object";
|
|
89
|
-
const noop = (_, value) => value;
|
|
90
|
-
const primitives = (value) => value instanceof Primitive ? Primitive(value) : value;
|
|
91
|
-
const Primitives = (_, value) => typeof value === primitive ? new Primitive(value) : value;
|
|
92
|
-
const revive = (input, parsed, output, $) => {
|
|
93
|
-
const lazy = [];
|
|
94
|
-
for (let ke = keys(output), { length } = ke, y = 0; y < length; y++) {
|
|
95
|
-
const k = ke[y];
|
|
96
|
-
const value = output[k];
|
|
97
|
-
if (value instanceof Primitive) {
|
|
98
|
-
const tmp = input[value];
|
|
99
|
-
if (typeof tmp === object && !parsed.has(tmp)) {
|
|
100
|
-
parsed.add(tmp);
|
|
101
|
-
output[k] = ignore;
|
|
102
|
-
lazy.push({ k, a: [input, parsed, tmp, $] });
|
|
103
|
-
} else
|
|
104
|
-
output[k] = $.call(output, k, tmp);
|
|
105
|
-
} else if (output[k] !== ignore)
|
|
106
|
-
output[k] = $.call(output, k, value);
|
|
107
|
-
}
|
|
108
|
-
for (let { length } = lazy, i = 0; i < length; i++) {
|
|
109
|
-
const { k, a: a2 } = lazy[i];
|
|
110
|
-
output[k] = $.call(output, k, revive.apply(null, a2));
|
|
111
|
-
}
|
|
112
|
-
return output;
|
|
113
|
-
};
|
|
114
|
-
const parse$1 = (text, reviver) => {
|
|
115
|
-
const input = $parse(text, Primitives).map(primitives);
|
|
116
|
-
const value = input[0];
|
|
117
|
-
const $ = noop;
|
|
118
|
-
const tmp = typeof value === object && value ? revive(input, /* @__PURE__ */ new Set(), value, $) : value;
|
|
119
|
-
return $.call({ "": tmp }, "", tmp);
|
|
120
|
-
};
|
|
121
|
-
function showPopupWarning(name, value, defaultValue) {
|
|
122
|
-
return (...params) => {
|
|
123
|
-
const formattedParams = params.map((p2) => JSON.stringify(p2)).join(", ");
|
|
124
|
-
console.warn(`Vitest encountered a \`${name}(${formattedParams})\` call that it cannot handle by default, so it returned \`${value}\`. Read more in https://vitest.dev/guide/browser/#thread-blocking-dialogs.
|
|
125
|
-
If needed, mock the \`${name}\` call manually like:
|
|
126
|
-
|
|
127
|
-
\`\`\`
|
|
128
|
-
import { expect, vi } from "vitest"
|
|
129
|
-
|
|
130
|
-
vi.spyOn(window, "${name}")${defaultValue ? `.mockReturnValue(${JSON.stringify(defaultValue)})` : ""}
|
|
131
|
-
${name}(${formattedParams})
|
|
132
|
-
expect(${name}).toHaveBeenCalledWith(${formattedParams})
|
|
133
|
-
\`\`\``);
|
|
134
|
-
return value;
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
function setupDialogsSpy() {
|
|
138
|
-
globalThis.alert = showPopupWarning("alert", void 0);
|
|
139
|
-
globalThis.confirm = showPopupWarning("confirm", false, true);
|
|
140
|
-
globalThis.prompt = showPopupWarning("prompt", null, "your value");
|
|
141
|
-
}
|
|
142
|
-
const { get } = Reflect;
|
|
143
|
-
function withSafeTimers(getTimers, fn) {
|
|
144
|
-
const { setTimeout, clearTimeout } = getTimers();
|
|
145
|
-
const currentSetTimeout = globalThis.setTimeout;
|
|
146
|
-
const currentClearTimeout = globalThis.clearTimeout;
|
|
147
|
-
try {
|
|
148
|
-
globalThis.setTimeout = setTimeout;
|
|
149
|
-
globalThis.clearTimeout = clearTimeout;
|
|
150
|
-
const result = fn();
|
|
151
|
-
return result;
|
|
152
|
-
} finally {
|
|
153
|
-
globalThis.setTimeout = currentSetTimeout;
|
|
154
|
-
globalThis.clearTimeout = currentClearTimeout;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
const promises = /* @__PURE__ */ new Set();
|
|
158
|
-
function createSafeRpc(client2) {
|
|
159
|
-
return new Proxy(client2.rpc, {
|
|
160
|
-
get(target, p2, handler) {
|
|
161
|
-
if (p2 === "then") {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const sendCall = get(target, p2, handler);
|
|
165
|
-
const safeSendCall = (...args) => withSafeTimers(getSafeTimers, async () => {
|
|
166
|
-
const result = sendCall(...args);
|
|
167
|
-
promises.add(result);
|
|
168
|
-
try {
|
|
169
|
-
return await result;
|
|
170
|
-
} finally {
|
|
171
|
-
promises.delete(result);
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
safeSendCall.asEvent = sendCall.asEvent;
|
|
175
|
-
return safeSendCall;
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
function rpc$2() {
|
|
180
|
-
return globalThis.__vitest_worker__.rpc;
|
|
181
|
-
}
|
|
182
|
-
var sourcemapCodec_umd$1 = { exports: {} };
|
|
183
|
-
var sourcemapCodec_umd = sourcemapCodec_umd$1.exports;
|
|
184
|
-
var hasRequiredSourcemapCodec_umd;
|
|
185
|
-
function requireSourcemapCodec_umd() {
|
|
186
|
-
if (hasRequiredSourcemapCodec_umd) return sourcemapCodec_umd$1.exports;
|
|
187
|
-
hasRequiredSourcemapCodec_umd = 1;
|
|
188
|
-
(function(module, exports) {
|
|
189
|
-
(function(global, factory) {
|
|
190
|
-
factory(exports);
|
|
191
|
-
})(sourcemapCodec_umd, function(exports2) {
|
|
192
|
-
const comma = ",".charCodeAt(0);
|
|
193
|
-
const semicolon = ";".charCodeAt(0);
|
|
194
|
-
const chars2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
195
|
-
const intToChar2 = new Uint8Array(64);
|
|
196
|
-
const charToInt2 = new Uint8Array(128);
|
|
197
|
-
for (let i = 0; i < chars2.length; i++) {
|
|
198
|
-
const c = chars2.charCodeAt(i);
|
|
199
|
-
intToChar2[i] = c;
|
|
200
|
-
charToInt2[c] = i;
|
|
201
|
-
}
|
|
202
|
-
function decodeInteger(reader, relative) {
|
|
203
|
-
let value = 0;
|
|
204
|
-
let shift = 0;
|
|
205
|
-
let integer = 0;
|
|
206
|
-
do {
|
|
207
|
-
const c = reader.next();
|
|
208
|
-
integer = charToInt2[c];
|
|
209
|
-
value |= (integer & 31) << shift;
|
|
210
|
-
shift += 5;
|
|
211
|
-
} while (integer & 32);
|
|
212
|
-
const shouldNegate = value & 1;
|
|
213
|
-
value >>>= 1;
|
|
214
|
-
if (shouldNegate) {
|
|
215
|
-
value = -2147483648 | -value;
|
|
216
|
-
}
|
|
217
|
-
return relative + value;
|
|
218
|
-
}
|
|
219
|
-
function encodeInteger(builder, num, relative) {
|
|
220
|
-
let delta = num - relative;
|
|
221
|
-
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
|
|
222
|
-
do {
|
|
223
|
-
let clamped = delta & 31;
|
|
224
|
-
delta >>>= 5;
|
|
225
|
-
if (delta > 0)
|
|
226
|
-
clamped |= 32;
|
|
227
|
-
builder.write(intToChar2[clamped]);
|
|
228
|
-
} while (delta > 0);
|
|
229
|
-
return num;
|
|
230
|
-
}
|
|
231
|
-
function hasMoreVlq(reader, max) {
|
|
232
|
-
if (reader.pos >= max)
|
|
233
|
-
return false;
|
|
234
|
-
return reader.peek() !== comma;
|
|
235
|
-
}
|
|
236
|
-
const bufLength = 1024 * 16;
|
|
237
|
-
const td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
|
|
238
|
-
decode(buf) {
|
|
239
|
-
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
240
|
-
return out.toString();
|
|
241
|
-
}
|
|
242
|
-
} : {
|
|
243
|
-
decode(buf) {
|
|
244
|
-
let out = "";
|
|
245
|
-
for (let i = 0; i < buf.length; i++) {
|
|
246
|
-
out += String.fromCharCode(buf[i]);
|
|
247
|
-
}
|
|
248
|
-
return out;
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
class StringWriter {
|
|
252
|
-
constructor() {
|
|
253
|
-
this.pos = 0;
|
|
254
|
-
this.out = "";
|
|
255
|
-
this.buffer = new Uint8Array(bufLength);
|
|
256
|
-
}
|
|
257
|
-
write(v) {
|
|
258
|
-
const { buffer } = this;
|
|
259
|
-
buffer[this.pos++] = v;
|
|
260
|
-
if (this.pos === bufLength) {
|
|
261
|
-
this.out += td.decode(buffer);
|
|
262
|
-
this.pos = 0;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
flush() {
|
|
266
|
-
const { buffer, out, pos } = this;
|
|
267
|
-
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
class StringReader {
|
|
271
|
-
constructor(buffer) {
|
|
272
|
-
this.pos = 0;
|
|
273
|
-
this.buffer = buffer;
|
|
274
|
-
}
|
|
275
|
-
next() {
|
|
276
|
-
return this.buffer.charCodeAt(this.pos++);
|
|
277
|
-
}
|
|
278
|
-
peek() {
|
|
279
|
-
return this.buffer.charCodeAt(this.pos);
|
|
280
|
-
}
|
|
281
|
-
indexOf(char) {
|
|
282
|
-
const { buffer, pos } = this;
|
|
283
|
-
const idx = buffer.indexOf(char, pos);
|
|
284
|
-
return idx === -1 ? buffer.length : idx;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
const EMPTY = [];
|
|
288
|
-
function decodeOriginalScopes(input) {
|
|
289
|
-
const { length } = input;
|
|
290
|
-
const reader = new StringReader(input);
|
|
291
|
-
const scopes = [];
|
|
292
|
-
const stack = [];
|
|
293
|
-
let line = 0;
|
|
294
|
-
for (; reader.pos < length; reader.pos++) {
|
|
295
|
-
line = decodeInteger(reader, line);
|
|
296
|
-
const column = decodeInteger(reader, 0);
|
|
297
|
-
if (!hasMoreVlq(reader, length)) {
|
|
298
|
-
const last = stack.pop();
|
|
299
|
-
last[2] = line;
|
|
300
|
-
last[3] = column;
|
|
301
|
-
continue;
|
|
302
|
-
}
|
|
303
|
-
const kind = decodeInteger(reader, 0);
|
|
304
|
-
const fields = decodeInteger(reader, 0);
|
|
305
|
-
const hasName = fields & 1;
|
|
306
|
-
const scope = hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind];
|
|
307
|
-
let vars = EMPTY;
|
|
308
|
-
if (hasMoreVlq(reader, length)) {
|
|
309
|
-
vars = [];
|
|
310
|
-
do {
|
|
311
|
-
const varsIndex = decodeInteger(reader, 0);
|
|
312
|
-
vars.push(varsIndex);
|
|
313
|
-
} while (hasMoreVlq(reader, length));
|
|
314
|
-
}
|
|
315
|
-
scope.vars = vars;
|
|
316
|
-
scopes.push(scope);
|
|
317
|
-
stack.push(scope);
|
|
318
|
-
}
|
|
319
|
-
return scopes;
|
|
320
|
-
}
|
|
321
|
-
function encodeOriginalScopes(scopes) {
|
|
322
|
-
const writer = new StringWriter();
|
|
323
|
-
for (let i = 0; i < scopes.length; ) {
|
|
324
|
-
i = _encodeOriginalScopes(scopes, i, writer, [0]);
|
|
325
|
-
}
|
|
326
|
-
return writer.flush();
|
|
327
|
-
}
|
|
328
|
-
function _encodeOriginalScopes(scopes, index2, writer, state) {
|
|
329
|
-
const scope = scopes[index2];
|
|
330
|
-
const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope;
|
|
331
|
-
if (index2 > 0)
|
|
332
|
-
writer.write(comma);
|
|
333
|
-
state[0] = encodeInteger(writer, startLine, state[0]);
|
|
334
|
-
encodeInteger(writer, startColumn, 0);
|
|
335
|
-
encodeInteger(writer, kind, 0);
|
|
336
|
-
const fields = scope.length === 6 ? 1 : 0;
|
|
337
|
-
encodeInteger(writer, fields, 0);
|
|
338
|
-
if (scope.length === 6)
|
|
339
|
-
encodeInteger(writer, scope[5], 0);
|
|
340
|
-
for (const v of vars) {
|
|
341
|
-
encodeInteger(writer, v, 0);
|
|
342
|
-
}
|
|
343
|
-
for (index2++; index2 < scopes.length; ) {
|
|
344
|
-
const next = scopes[index2];
|
|
345
|
-
const { 0: l, 1: c } = next;
|
|
346
|
-
if (l > endLine || l === endLine && c >= endColumn) {
|
|
347
|
-
break;
|
|
348
|
-
}
|
|
349
|
-
index2 = _encodeOriginalScopes(scopes, index2, writer, state);
|
|
350
|
-
}
|
|
351
|
-
writer.write(comma);
|
|
352
|
-
state[0] = encodeInteger(writer, endLine, state[0]);
|
|
353
|
-
encodeInteger(writer, endColumn, 0);
|
|
354
|
-
return index2;
|
|
355
|
-
}
|
|
356
|
-
function decodeGeneratedRanges(input) {
|
|
357
|
-
const { length } = input;
|
|
358
|
-
const reader = new StringReader(input);
|
|
359
|
-
const ranges = [];
|
|
360
|
-
const stack = [];
|
|
361
|
-
let genLine = 0;
|
|
362
|
-
let definitionSourcesIndex = 0;
|
|
363
|
-
let definitionScopeIndex = 0;
|
|
364
|
-
let callsiteSourcesIndex = 0;
|
|
365
|
-
let callsiteLine = 0;
|
|
366
|
-
let callsiteColumn = 0;
|
|
367
|
-
let bindingLine = 0;
|
|
368
|
-
let bindingColumn = 0;
|
|
369
|
-
do {
|
|
370
|
-
const semi = reader.indexOf(";");
|
|
371
|
-
let genColumn = 0;
|
|
372
|
-
for (; reader.pos < semi; reader.pos++) {
|
|
373
|
-
genColumn = decodeInteger(reader, genColumn);
|
|
374
|
-
if (!hasMoreVlq(reader, semi)) {
|
|
375
|
-
const last = stack.pop();
|
|
376
|
-
last[2] = genLine;
|
|
377
|
-
last[3] = genColumn;
|
|
378
|
-
continue;
|
|
379
|
-
}
|
|
380
|
-
const fields = decodeInteger(reader, 0);
|
|
381
|
-
const hasDefinition = fields & 1;
|
|
382
|
-
const hasCallsite = fields & 2;
|
|
383
|
-
const hasScope = fields & 4;
|
|
384
|
-
let callsite = null;
|
|
385
|
-
let bindings = EMPTY;
|
|
386
|
-
let range;
|
|
387
|
-
if (hasDefinition) {
|
|
388
|
-
const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex);
|
|
389
|
-
definitionScopeIndex = decodeInteger(reader, definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0);
|
|
390
|
-
definitionSourcesIndex = defSourcesIndex;
|
|
391
|
-
range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex];
|
|
392
|
-
} else {
|
|
393
|
-
range = [genLine, genColumn, 0, 0];
|
|
394
|
-
}
|
|
395
|
-
range.isScope = !!hasScope;
|
|
396
|
-
if (hasCallsite) {
|
|
397
|
-
const prevCsi = callsiteSourcesIndex;
|
|
398
|
-
const prevLine = callsiteLine;
|
|
399
|
-
callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex);
|
|
400
|
-
const sameSource = prevCsi === callsiteSourcesIndex;
|
|
401
|
-
callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0);
|
|
402
|
-
callsiteColumn = decodeInteger(reader, sameSource && prevLine === callsiteLine ? callsiteColumn : 0);
|
|
403
|
-
callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn];
|
|
404
|
-
}
|
|
405
|
-
range.callsite = callsite;
|
|
406
|
-
if (hasMoreVlq(reader, semi)) {
|
|
407
|
-
bindings = [];
|
|
408
|
-
do {
|
|
409
|
-
bindingLine = genLine;
|
|
410
|
-
bindingColumn = genColumn;
|
|
411
|
-
const expressionsCount = decodeInteger(reader, 0);
|
|
412
|
-
let expressionRanges;
|
|
413
|
-
if (expressionsCount < -1) {
|
|
414
|
-
expressionRanges = [[decodeInteger(reader, 0)]];
|
|
415
|
-
for (let i = -1; i > expressionsCount; i--) {
|
|
416
|
-
const prevBl = bindingLine;
|
|
417
|
-
bindingLine = decodeInteger(reader, bindingLine);
|
|
418
|
-
bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0);
|
|
419
|
-
const expression = decodeInteger(reader, 0);
|
|
420
|
-
expressionRanges.push([expression, bindingLine, bindingColumn]);
|
|
421
|
-
}
|
|
422
|
-
} else {
|
|
423
|
-
expressionRanges = [[expressionsCount]];
|
|
424
|
-
}
|
|
425
|
-
bindings.push(expressionRanges);
|
|
426
|
-
} while (hasMoreVlq(reader, semi));
|
|
427
|
-
}
|
|
428
|
-
range.bindings = bindings;
|
|
429
|
-
ranges.push(range);
|
|
430
|
-
stack.push(range);
|
|
431
|
-
}
|
|
432
|
-
genLine++;
|
|
433
|
-
reader.pos = semi + 1;
|
|
434
|
-
} while (reader.pos < length);
|
|
435
|
-
return ranges;
|
|
436
|
-
}
|
|
437
|
-
function encodeGeneratedRanges(ranges) {
|
|
438
|
-
if (ranges.length === 0)
|
|
439
|
-
return "";
|
|
440
|
-
const writer = new StringWriter();
|
|
441
|
-
for (let i = 0; i < ranges.length; ) {
|
|
442
|
-
i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]);
|
|
443
|
-
}
|
|
444
|
-
return writer.flush();
|
|
445
|
-
}
|
|
446
|
-
function _encodeGeneratedRanges(ranges, index2, writer, state) {
|
|
447
|
-
const range = ranges[index2];
|
|
448
|
-
const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, isScope, callsite, bindings } = range;
|
|
449
|
-
if (state[0] < startLine) {
|
|
450
|
-
catchupLine(writer, state[0], startLine);
|
|
451
|
-
state[0] = startLine;
|
|
452
|
-
state[1] = 0;
|
|
453
|
-
} else if (index2 > 0) {
|
|
454
|
-
writer.write(comma);
|
|
455
|
-
}
|
|
456
|
-
state[1] = encodeInteger(writer, range[1], state[1]);
|
|
457
|
-
const fields = (range.length === 6 ? 1 : 0) | (callsite ? 2 : 0) | (isScope ? 4 : 0);
|
|
458
|
-
encodeInteger(writer, fields, 0);
|
|
459
|
-
if (range.length === 6) {
|
|
460
|
-
const { 4: sourcesIndex, 5: scopesIndex } = range;
|
|
461
|
-
if (sourcesIndex !== state[2]) {
|
|
462
|
-
state[3] = 0;
|
|
463
|
-
}
|
|
464
|
-
state[2] = encodeInteger(writer, sourcesIndex, state[2]);
|
|
465
|
-
state[3] = encodeInteger(writer, scopesIndex, state[3]);
|
|
466
|
-
}
|
|
467
|
-
if (callsite) {
|
|
468
|
-
const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite;
|
|
469
|
-
if (sourcesIndex !== state[4]) {
|
|
470
|
-
state[5] = 0;
|
|
471
|
-
state[6] = 0;
|
|
472
|
-
} else if (callLine !== state[5]) {
|
|
473
|
-
state[6] = 0;
|
|
474
|
-
}
|
|
475
|
-
state[4] = encodeInteger(writer, sourcesIndex, state[4]);
|
|
476
|
-
state[5] = encodeInteger(writer, callLine, state[5]);
|
|
477
|
-
state[6] = encodeInteger(writer, callColumn, state[6]);
|
|
478
|
-
}
|
|
479
|
-
if (bindings) {
|
|
480
|
-
for (const binding of bindings) {
|
|
481
|
-
if (binding.length > 1)
|
|
482
|
-
encodeInteger(writer, -binding.length, 0);
|
|
483
|
-
const expression = binding[0][0];
|
|
484
|
-
encodeInteger(writer, expression, 0);
|
|
485
|
-
let bindingStartLine = startLine;
|
|
486
|
-
let bindingStartColumn = startColumn;
|
|
487
|
-
for (let i = 1; i < binding.length; i++) {
|
|
488
|
-
const expRange = binding[i];
|
|
489
|
-
bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine);
|
|
490
|
-
bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn);
|
|
491
|
-
encodeInteger(writer, expRange[0], 0);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
for (index2++; index2 < ranges.length; ) {
|
|
496
|
-
const next = ranges[index2];
|
|
497
|
-
const { 0: l, 1: c } = next;
|
|
498
|
-
if (l > endLine || l === endLine && c >= endColumn) {
|
|
499
|
-
break;
|
|
500
|
-
}
|
|
501
|
-
index2 = _encodeGeneratedRanges(ranges, index2, writer, state);
|
|
502
|
-
}
|
|
503
|
-
if (state[0] < endLine) {
|
|
504
|
-
catchupLine(writer, state[0], endLine);
|
|
505
|
-
state[0] = endLine;
|
|
506
|
-
state[1] = 0;
|
|
507
|
-
} else {
|
|
508
|
-
writer.write(comma);
|
|
509
|
-
}
|
|
510
|
-
state[1] = encodeInteger(writer, endColumn, state[1]);
|
|
511
|
-
return index2;
|
|
512
|
-
}
|
|
513
|
-
function catchupLine(writer, lastLine, line) {
|
|
514
|
-
do {
|
|
515
|
-
writer.write(semicolon);
|
|
516
|
-
} while (++lastLine < line);
|
|
517
|
-
}
|
|
518
|
-
function decode(mappings) {
|
|
519
|
-
const { length } = mappings;
|
|
520
|
-
const reader = new StringReader(mappings);
|
|
521
|
-
const decoded = [];
|
|
522
|
-
let genColumn = 0;
|
|
523
|
-
let sourcesIndex = 0;
|
|
524
|
-
let sourceLine = 0;
|
|
525
|
-
let sourceColumn = 0;
|
|
526
|
-
let namesIndex = 0;
|
|
527
|
-
do {
|
|
528
|
-
const semi = reader.indexOf(";");
|
|
529
|
-
const line = [];
|
|
530
|
-
let sorted = true;
|
|
531
|
-
let lastCol = 0;
|
|
532
|
-
genColumn = 0;
|
|
533
|
-
while (reader.pos < semi) {
|
|
534
|
-
let seg;
|
|
535
|
-
genColumn = decodeInteger(reader, genColumn);
|
|
536
|
-
if (genColumn < lastCol)
|
|
537
|
-
sorted = false;
|
|
538
|
-
lastCol = genColumn;
|
|
539
|
-
if (hasMoreVlq(reader, semi)) {
|
|
540
|
-
sourcesIndex = decodeInteger(reader, sourcesIndex);
|
|
541
|
-
sourceLine = decodeInteger(reader, sourceLine);
|
|
542
|
-
sourceColumn = decodeInteger(reader, sourceColumn);
|
|
543
|
-
if (hasMoreVlq(reader, semi)) {
|
|
544
|
-
namesIndex = decodeInteger(reader, namesIndex);
|
|
545
|
-
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
|
|
546
|
-
} else {
|
|
547
|
-
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
|
548
|
-
}
|
|
549
|
-
} else {
|
|
550
|
-
seg = [genColumn];
|
|
551
|
-
}
|
|
552
|
-
line.push(seg);
|
|
553
|
-
reader.pos++;
|
|
554
|
-
}
|
|
555
|
-
if (!sorted)
|
|
556
|
-
sort(line);
|
|
557
|
-
decoded.push(line);
|
|
558
|
-
reader.pos = semi + 1;
|
|
559
|
-
} while (reader.pos <= length);
|
|
560
|
-
return decoded;
|
|
561
|
-
}
|
|
562
|
-
function sort(line) {
|
|
563
|
-
line.sort(sortComparator2);
|
|
564
|
-
}
|
|
565
|
-
function sortComparator2(a2, b) {
|
|
566
|
-
return a2[0] - b[0];
|
|
567
|
-
}
|
|
568
|
-
function encode(decoded) {
|
|
569
|
-
const writer = new StringWriter();
|
|
570
|
-
let sourcesIndex = 0;
|
|
571
|
-
let sourceLine = 0;
|
|
572
|
-
let sourceColumn = 0;
|
|
573
|
-
let namesIndex = 0;
|
|
574
|
-
for (let i = 0; i < decoded.length; i++) {
|
|
575
|
-
const line = decoded[i];
|
|
576
|
-
if (i > 0)
|
|
577
|
-
writer.write(semicolon);
|
|
578
|
-
if (line.length === 0)
|
|
579
|
-
continue;
|
|
580
|
-
let genColumn = 0;
|
|
581
|
-
for (let j = 0; j < line.length; j++) {
|
|
582
|
-
const segment = line[j];
|
|
583
|
-
if (j > 0)
|
|
584
|
-
writer.write(comma);
|
|
585
|
-
genColumn = encodeInteger(writer, segment[0], genColumn);
|
|
586
|
-
if (segment.length === 1)
|
|
587
|
-
continue;
|
|
588
|
-
sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
|
|
589
|
-
sourceLine = encodeInteger(writer, segment[2], sourceLine);
|
|
590
|
-
sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
|
|
591
|
-
if (segment.length === 4)
|
|
592
|
-
continue;
|
|
593
|
-
namesIndex = encodeInteger(writer, segment[4], namesIndex);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
return writer.flush();
|
|
597
|
-
}
|
|
598
|
-
exports2.decode = decode;
|
|
599
|
-
exports2.decodeGeneratedRanges = decodeGeneratedRanges;
|
|
600
|
-
exports2.decodeOriginalScopes = decodeOriginalScopes;
|
|
601
|
-
exports2.encode = encode;
|
|
602
|
-
exports2.encodeGeneratedRanges = encodeGeneratedRanges;
|
|
603
|
-
exports2.encodeOriginalScopes = encodeOriginalScopes;
|
|
604
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
605
|
-
});
|
|
606
|
-
})(sourcemapCodec_umd$1, sourcemapCodec_umd$1.exports);
|
|
607
|
-
return sourcemapCodec_umd$1.exports;
|
|
608
|
-
}
|
|
609
|
-
var sourcemapCodec_umdExports = requireSourcemapCodec_umd();
|
|
610
|
-
var resolveUri_umd$1 = { exports: {} };
|
|
611
|
-
var resolveUri_umd = resolveUri_umd$1.exports;
|
|
612
|
-
var hasRequiredResolveUri_umd;
|
|
613
|
-
function requireResolveUri_umd() {
|
|
614
|
-
if (hasRequiredResolveUri_umd) return resolveUri_umd$1.exports;
|
|
615
|
-
hasRequiredResolveUri_umd = 1;
|
|
616
|
-
(function(module, exports) {
|
|
617
|
-
(function(global, factory) {
|
|
618
|
-
module.exports = factory();
|
|
619
|
-
})(resolveUri_umd, function() {
|
|
620
|
-
const schemeRegex = /^[\w+.-]+:\/\//;
|
|
621
|
-
const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
|
|
622
|
-
const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
|
|
623
|
-
var UrlType2;
|
|
624
|
-
(function(UrlType3) {
|
|
625
|
-
UrlType3[UrlType3["Empty"] = 1] = "Empty";
|
|
626
|
-
UrlType3[UrlType3["Hash"] = 2] = "Hash";
|
|
627
|
-
UrlType3[UrlType3["Query"] = 3] = "Query";
|
|
628
|
-
UrlType3[UrlType3["RelativePath"] = 4] = "RelativePath";
|
|
629
|
-
UrlType3[UrlType3["AbsolutePath"] = 5] = "AbsolutePath";
|
|
630
|
-
UrlType3[UrlType3["SchemeRelative"] = 6] = "SchemeRelative";
|
|
631
|
-
UrlType3[UrlType3["Absolute"] = 7] = "Absolute";
|
|
632
|
-
})(UrlType2 || (UrlType2 = {}));
|
|
633
|
-
function isAbsoluteUrl(input) {
|
|
634
|
-
return schemeRegex.test(input);
|
|
635
|
-
}
|
|
636
|
-
function isSchemeRelativeUrl(input) {
|
|
637
|
-
return input.startsWith("//");
|
|
638
|
-
}
|
|
639
|
-
function isAbsolutePath(input) {
|
|
640
|
-
return input.startsWith("/");
|
|
641
|
-
}
|
|
642
|
-
function isFileUrl(input) {
|
|
643
|
-
return input.startsWith("file:");
|
|
644
|
-
}
|
|
645
|
-
function isRelative(input) {
|
|
646
|
-
return /^[.?#]/.test(input);
|
|
647
|
-
}
|
|
648
|
-
function parseAbsoluteUrl(input) {
|
|
649
|
-
const match = urlRegex.exec(input);
|
|
650
|
-
return makeUrl(match[1], match[2] || "", match[3], match[4] || "", match[5] || "/", match[6] || "", match[7] || "");
|
|
651
|
-
}
|
|
652
|
-
function parseFileUrl(input) {
|
|
653
|
-
const match = fileRegex.exec(input);
|
|
654
|
-
const path = match[2];
|
|
655
|
-
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path) ? path : "/" + path, match[3] || "", match[4] || "");
|
|
656
|
-
}
|
|
657
|
-
function makeUrl(scheme, user, host, port, path, query, hash) {
|
|
658
|
-
return {
|
|
659
|
-
scheme,
|
|
660
|
-
user,
|
|
661
|
-
host,
|
|
662
|
-
port,
|
|
663
|
-
path,
|
|
664
|
-
query,
|
|
665
|
-
hash,
|
|
666
|
-
type: UrlType2.Absolute
|
|
667
|
-
};
|
|
668
|
-
}
|
|
669
|
-
function parseUrl(input) {
|
|
670
|
-
if (isSchemeRelativeUrl(input)) {
|
|
671
|
-
const url3 = parseAbsoluteUrl("http:" + input);
|
|
672
|
-
url3.scheme = "";
|
|
673
|
-
url3.type = UrlType2.SchemeRelative;
|
|
674
|
-
return url3;
|
|
675
|
-
}
|
|
676
|
-
if (isAbsolutePath(input)) {
|
|
677
|
-
const url3 = parseAbsoluteUrl("http://foo.com" + input);
|
|
678
|
-
url3.scheme = "";
|
|
679
|
-
url3.host = "";
|
|
680
|
-
url3.type = UrlType2.AbsolutePath;
|
|
681
|
-
return url3;
|
|
682
|
-
}
|
|
683
|
-
if (isFileUrl(input))
|
|
684
|
-
return parseFileUrl(input);
|
|
685
|
-
if (isAbsoluteUrl(input))
|
|
686
|
-
return parseAbsoluteUrl(input);
|
|
687
|
-
const url2 = parseAbsoluteUrl("http://foo.com/" + input);
|
|
688
|
-
url2.scheme = "";
|
|
689
|
-
url2.host = "";
|
|
690
|
-
url2.type = input ? input.startsWith("?") ? UrlType2.Query : input.startsWith("#") ? UrlType2.Hash : UrlType2.RelativePath : UrlType2.Empty;
|
|
691
|
-
return url2;
|
|
692
|
-
}
|
|
693
|
-
function stripPathFilename(path) {
|
|
694
|
-
if (path.endsWith("/.."))
|
|
695
|
-
return path;
|
|
696
|
-
const index2 = path.lastIndexOf("/");
|
|
697
|
-
return path.slice(0, index2 + 1);
|
|
698
|
-
}
|
|
699
|
-
function mergePaths(url2, base) {
|
|
700
|
-
normalizePath(base, base.type);
|
|
701
|
-
if (url2.path === "/") {
|
|
702
|
-
url2.path = base.path;
|
|
703
|
-
} else {
|
|
704
|
-
url2.path = stripPathFilename(base.path) + url2.path;
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
function normalizePath(url2, type) {
|
|
708
|
-
const rel = type <= UrlType2.RelativePath;
|
|
709
|
-
const pieces = url2.path.split("/");
|
|
710
|
-
let pointer = 1;
|
|
711
|
-
let positive = 0;
|
|
712
|
-
let addTrailingSlash = false;
|
|
713
|
-
for (let i = 1; i < pieces.length; i++) {
|
|
714
|
-
const piece = pieces[i];
|
|
715
|
-
if (!piece) {
|
|
716
|
-
addTrailingSlash = true;
|
|
717
|
-
continue;
|
|
718
|
-
}
|
|
719
|
-
addTrailingSlash = false;
|
|
720
|
-
if (piece === ".")
|
|
721
|
-
continue;
|
|
722
|
-
if (piece === "..") {
|
|
723
|
-
if (positive) {
|
|
724
|
-
addTrailingSlash = true;
|
|
725
|
-
positive--;
|
|
726
|
-
pointer--;
|
|
727
|
-
} else if (rel) {
|
|
728
|
-
pieces[pointer++] = piece;
|
|
729
|
-
}
|
|
730
|
-
continue;
|
|
731
|
-
}
|
|
732
|
-
pieces[pointer++] = piece;
|
|
733
|
-
positive++;
|
|
734
|
-
}
|
|
735
|
-
let path = "";
|
|
736
|
-
for (let i = 1; i < pointer; i++) {
|
|
737
|
-
path += "/" + pieces[i];
|
|
738
|
-
}
|
|
739
|
-
if (!path || addTrailingSlash && !path.endsWith("/..")) {
|
|
740
|
-
path += "/";
|
|
741
|
-
}
|
|
742
|
-
url2.path = path;
|
|
743
|
-
}
|
|
744
|
-
function resolve2(input, base) {
|
|
745
|
-
if (!input && !base)
|
|
746
|
-
return "";
|
|
747
|
-
const url2 = parseUrl(input);
|
|
748
|
-
let inputType = url2.type;
|
|
749
|
-
if (base && inputType !== UrlType2.Absolute) {
|
|
750
|
-
const baseUrl = parseUrl(base);
|
|
751
|
-
const baseType = baseUrl.type;
|
|
752
|
-
switch (inputType) {
|
|
753
|
-
case UrlType2.Empty:
|
|
754
|
-
url2.hash = baseUrl.hash;
|
|
755
|
-
// fall through
|
|
756
|
-
case UrlType2.Hash:
|
|
757
|
-
url2.query = baseUrl.query;
|
|
758
|
-
// fall through
|
|
759
|
-
case UrlType2.Query:
|
|
760
|
-
case UrlType2.RelativePath:
|
|
761
|
-
mergePaths(url2, baseUrl);
|
|
762
|
-
// fall through
|
|
763
|
-
case UrlType2.AbsolutePath:
|
|
764
|
-
url2.user = baseUrl.user;
|
|
765
|
-
url2.host = baseUrl.host;
|
|
766
|
-
url2.port = baseUrl.port;
|
|
767
|
-
// fall through
|
|
768
|
-
case UrlType2.SchemeRelative:
|
|
769
|
-
url2.scheme = baseUrl.scheme;
|
|
770
|
-
}
|
|
771
|
-
if (baseType > inputType)
|
|
772
|
-
inputType = baseType;
|
|
773
|
-
}
|
|
774
|
-
normalizePath(url2, inputType);
|
|
775
|
-
const queryHash = url2.query + url2.hash;
|
|
776
|
-
switch (inputType) {
|
|
777
|
-
// This is impossible, because of the empty checks at the start of the function.
|
|
778
|
-
// case UrlType.Empty:
|
|
779
|
-
case UrlType2.Hash:
|
|
780
|
-
case UrlType2.Query:
|
|
781
|
-
return queryHash;
|
|
782
|
-
case UrlType2.RelativePath: {
|
|
783
|
-
const path = url2.path.slice(1);
|
|
784
|
-
if (!path)
|
|
785
|
-
return queryHash || ".";
|
|
786
|
-
if (isRelative(base || input) && !isRelative(path)) {
|
|
787
|
-
return "./" + path + queryHash;
|
|
788
|
-
}
|
|
789
|
-
return path + queryHash;
|
|
790
|
-
}
|
|
791
|
-
case UrlType2.AbsolutePath:
|
|
792
|
-
return url2.path + queryHash;
|
|
793
|
-
default:
|
|
794
|
-
return url2.scheme + "//" + url2.user + url2.host + url2.port + url2.path + queryHash;
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
return resolve2;
|
|
798
|
-
});
|
|
799
|
-
})(resolveUri_umd$1);
|
|
800
|
-
return resolveUri_umd$1.exports;
|
|
801
|
-
}
|
|
802
|
-
var resolveUri_umdExports = requireResolveUri_umd();
|
|
803
|
-
const resolveUri = /* @__PURE__ */ getDefaultExportFromCjs$1(resolveUri_umdExports);
|
|
804
|
-
function stripFilename(path) {
|
|
805
|
-
if (!path) return "";
|
|
806
|
-
const index2 = path.lastIndexOf("/");
|
|
807
|
-
return path.slice(0, index2 + 1);
|
|
808
|
-
}
|
|
809
|
-
function resolver(mapUrl, sourceRoot) {
|
|
810
|
-
const from = stripFilename(mapUrl);
|
|
811
|
-
const prefix = sourceRoot ? sourceRoot + "/" : "";
|
|
812
|
-
return (source) => resolveUri(prefix + (source || ""), from);
|
|
813
|
-
}
|
|
814
|
-
var COLUMN = 0;
|
|
815
|
-
var SOURCES_INDEX = 1;
|
|
816
|
-
var SOURCE_LINE = 2;
|
|
817
|
-
var SOURCE_COLUMN = 3;
|
|
818
|
-
var NAMES_INDEX = 4;
|
|
819
|
-
function maybeSort(mappings, owned) {
|
|
820
|
-
const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
|
|
821
|
-
if (unsortedIndex === mappings.length) return mappings;
|
|
822
|
-
if (!owned) mappings = mappings.slice();
|
|
823
|
-
for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
|
|
824
|
-
mappings[i] = sortSegments(mappings[i], owned);
|
|
825
|
-
}
|
|
826
|
-
return mappings;
|
|
827
|
-
}
|
|
828
|
-
function nextUnsortedSegmentLine(mappings, start) {
|
|
829
|
-
for (let i = start; i < mappings.length; i++) {
|
|
830
|
-
if (!isSorted(mappings[i])) return i;
|
|
831
|
-
}
|
|
832
|
-
return mappings.length;
|
|
833
|
-
}
|
|
834
|
-
function isSorted(line) {
|
|
835
|
-
for (let j = 1; j < line.length; j++) {
|
|
836
|
-
if (line[j][COLUMN] < line[j - 1][COLUMN]) {
|
|
837
|
-
return false;
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
return true;
|
|
841
|
-
}
|
|
842
|
-
function sortSegments(line, owned) {
|
|
843
|
-
if (!owned) line = line.slice();
|
|
844
|
-
return line.sort(sortComparator);
|
|
845
|
-
}
|
|
846
|
-
function sortComparator(a2, b) {
|
|
847
|
-
return a2[COLUMN] - b[COLUMN];
|
|
848
|
-
}
|
|
849
|
-
var found = false;
|
|
850
|
-
function binarySearch(haystack, needle, low, high) {
|
|
851
|
-
while (low <= high) {
|
|
852
|
-
const mid = low + (high - low >> 1);
|
|
853
|
-
const cmp = haystack[mid][COLUMN] - needle;
|
|
854
|
-
if (cmp === 0) {
|
|
855
|
-
found = true;
|
|
856
|
-
return mid;
|
|
857
|
-
}
|
|
858
|
-
if (cmp < 0) {
|
|
859
|
-
low = mid + 1;
|
|
860
|
-
} else {
|
|
861
|
-
high = mid - 1;
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
found = false;
|
|
865
|
-
return low - 1;
|
|
866
|
-
}
|
|
867
|
-
function upperBound(haystack, needle, index2) {
|
|
868
|
-
for (let i = index2 + 1; i < haystack.length; index2 = i++) {
|
|
869
|
-
if (haystack[i][COLUMN] !== needle) break;
|
|
870
|
-
}
|
|
871
|
-
return index2;
|
|
872
|
-
}
|
|
873
|
-
function lowerBound(haystack, needle, index2) {
|
|
874
|
-
for (let i = index2 - 1; i >= 0; index2 = i--) {
|
|
875
|
-
if (haystack[i][COLUMN] !== needle) break;
|
|
876
|
-
}
|
|
877
|
-
return index2;
|
|
878
|
-
}
|
|
879
|
-
function memoizedState() {
|
|
880
|
-
return {
|
|
881
|
-
lastKey: -1,
|
|
882
|
-
lastNeedle: -1,
|
|
883
|
-
lastIndex: -1
|
|
884
|
-
};
|
|
885
|
-
}
|
|
886
|
-
function memoizedBinarySearch(haystack, needle, state, key) {
|
|
887
|
-
const { lastKey, lastNeedle, lastIndex } = state;
|
|
888
|
-
let low = 0;
|
|
889
|
-
let high = haystack.length - 1;
|
|
890
|
-
if (key === lastKey) {
|
|
891
|
-
if (needle === lastNeedle) {
|
|
892
|
-
found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
|
|
893
|
-
return lastIndex;
|
|
894
|
-
}
|
|
895
|
-
if (needle >= lastNeedle) {
|
|
896
|
-
low = lastIndex === -1 ? 0 : lastIndex;
|
|
897
|
-
} else {
|
|
898
|
-
high = lastIndex;
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
state.lastKey = key;
|
|
902
|
-
state.lastNeedle = needle;
|
|
903
|
-
return state.lastIndex = binarySearch(haystack, needle, low, high);
|
|
904
|
-
}
|
|
905
|
-
function parse(map) {
|
|
906
|
-
return typeof map === "string" ? JSON.parse(map) : map;
|
|
907
|
-
}
|
|
908
|
-
var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
|
|
909
|
-
var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
|
|
910
|
-
var LEAST_UPPER_BOUND = -1;
|
|
911
|
-
var GREATEST_LOWER_BOUND = 1;
|
|
912
|
-
var TraceMap = class {
|
|
913
|
-
constructor(map, mapUrl) {
|
|
914
|
-
const isString = typeof map === "string";
|
|
915
|
-
if (!isString && map._decodedMemo) return map;
|
|
916
|
-
const parsed = parse(map);
|
|
917
|
-
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
|
918
|
-
this.version = version;
|
|
919
|
-
this.file = file;
|
|
920
|
-
this.names = names || [];
|
|
921
|
-
this.sourceRoot = sourceRoot;
|
|
922
|
-
this.sources = sources;
|
|
923
|
-
this.sourcesContent = sourcesContent;
|
|
924
|
-
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
|
|
925
|
-
const resolve2 = resolver(mapUrl, sourceRoot);
|
|
926
|
-
this.resolvedSources = sources.map(resolve2);
|
|
927
|
-
const { mappings } = parsed;
|
|
928
|
-
if (typeof mappings === "string") {
|
|
929
|
-
this._encoded = mappings;
|
|
930
|
-
this._decoded = void 0;
|
|
931
|
-
} else if (Array.isArray(mappings)) {
|
|
932
|
-
this._encoded = void 0;
|
|
933
|
-
this._decoded = maybeSort(mappings, isString);
|
|
934
|
-
} else if (parsed.sections) {
|
|
935
|
-
throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
|
|
936
|
-
} else {
|
|
937
|
-
throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
|
|
938
|
-
}
|
|
939
|
-
this._decodedMemo = memoizedState();
|
|
940
|
-
this._bySources = void 0;
|
|
941
|
-
this._bySourceMemos = void 0;
|
|
942
|
-
}
|
|
943
|
-
};
|
|
944
|
-
function cast(map) {
|
|
945
|
-
return map;
|
|
946
|
-
}
|
|
947
|
-
function decodedMappings(map) {
|
|
948
|
-
var _a;
|
|
949
|
-
return (_a = cast(map))._decoded || (_a._decoded = sourcemapCodec_umdExports.decode(cast(map)._encoded));
|
|
950
|
-
}
|
|
951
|
-
function originalPositionFor(map, needle) {
|
|
952
|
-
let { line, column, bias } = needle;
|
|
953
|
-
line--;
|
|
954
|
-
if (line < 0) throw new Error(LINE_GTR_ZERO);
|
|
955
|
-
if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
|
|
956
|
-
const decoded = decodedMappings(map);
|
|
957
|
-
if (line >= decoded.length) return OMapping(null, null, null, null);
|
|
958
|
-
const segments = decoded[line];
|
|
959
|
-
const index2 = traceSegmentInternal(
|
|
960
|
-
segments,
|
|
961
|
-
cast(map)._decodedMemo,
|
|
962
|
-
line,
|
|
963
|
-
column,
|
|
964
|
-
bias || GREATEST_LOWER_BOUND
|
|
965
|
-
);
|
|
966
|
-
if (index2 === -1) return OMapping(null, null, null, null);
|
|
967
|
-
const segment = segments[index2];
|
|
968
|
-
if (segment.length === 1) return OMapping(null, null, null, null);
|
|
969
|
-
const { names, resolvedSources } = map;
|
|
970
|
-
return OMapping(
|
|
971
|
-
resolvedSources[segment[SOURCES_INDEX]],
|
|
972
|
-
segment[SOURCE_LINE] + 1,
|
|
973
|
-
segment[SOURCE_COLUMN],
|
|
974
|
-
segment.length === 5 ? names[segment[NAMES_INDEX]] : null
|
|
975
|
-
);
|
|
976
|
-
}
|
|
977
|
-
function OMapping(source, line, column, name) {
|
|
978
|
-
return { source, line, column, name };
|
|
979
|
-
}
|
|
980
|
-
function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
981
|
-
let index2 = memoizedBinarySearch(segments, column, memo, line);
|
|
982
|
-
if (found) {
|
|
983
|
-
index2 = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index2);
|
|
984
|
-
} else if (bias === LEAST_UPPER_BOUND) index2++;
|
|
985
|
-
if (index2 === -1 || index2 === segments.length) return -1;
|
|
986
|
-
return index2;
|
|
987
|
-
}
|
|
988
|
-
function notNullish(v) {
|
|
989
|
-
return v != null;
|
|
990
|
-
}
|
|
991
|
-
const CHROME_IE_STACK_REGEXP = /^\s*at .*(?:\S:\d+|\(native\))/m;
|
|
992
|
-
const SAFARI_NATIVE_CODE_REGEXP = /^(?:eval@)?(?:\[native code\])?$/;
|
|
993
|
-
const stackIgnorePatterns = [
|
|
994
|
-
"node:internal",
|
|
995
|
-
/\/packages\/\w+\/dist\//,
|
|
996
|
-
/\/@vitest\/\w+\/dist\//,
|
|
997
|
-
"/vitest/dist/",
|
|
998
|
-
"/vitest/src/",
|
|
999
|
-
"/vite-node/dist/",
|
|
1000
|
-
"/vite-node/src/",
|
|
1001
|
-
"/node_modules/chai/",
|
|
1002
|
-
"/node_modules/tinypool/",
|
|
1003
|
-
"/node_modules/tinyspy/",
|
|
1004
|
-
"/vite/dist/node/module-runner",
|
|
1005
|
-
"/rolldown-vite/dist/node/module-runner",
|
|
1006
|
-
// browser related deps
|
|
1007
|
-
"/deps/chunk-",
|
|
1008
|
-
"/deps/@vitest",
|
|
1009
|
-
"/deps/loupe",
|
|
1010
|
-
"/deps/chai",
|
|
1011
|
-
/node:\w+/,
|
|
1012
|
-
/__vitest_test__/,
|
|
1013
|
-
/__vitest_browser__/,
|
|
1014
|
-
/\/deps\/vitest_/
|
|
1015
|
-
];
|
|
1016
|
-
function extractLocation(urlLike) {
|
|
1017
|
-
if (!urlLike.includes(":")) {
|
|
1018
|
-
return [urlLike];
|
|
1019
|
-
}
|
|
1020
|
-
const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
|
|
1021
|
-
const parts = regExp.exec(urlLike.replace(/^\(|\)$/g, ""));
|
|
1022
|
-
if (!parts) {
|
|
1023
|
-
return [urlLike];
|
|
1024
|
-
}
|
|
1025
|
-
let url2 = parts[1];
|
|
1026
|
-
if (url2.startsWith("async ")) {
|
|
1027
|
-
url2 = url2.slice(6);
|
|
1028
|
-
}
|
|
1029
|
-
if (url2.startsWith("http:") || url2.startsWith("https:")) {
|
|
1030
|
-
const urlObj = new URL(url2);
|
|
1031
|
-
urlObj.searchParams.delete("import");
|
|
1032
|
-
urlObj.searchParams.delete("browserv");
|
|
1033
|
-
url2 = urlObj.pathname + urlObj.hash + urlObj.search;
|
|
1034
|
-
}
|
|
1035
|
-
if (url2.startsWith("/@fs/")) {
|
|
1036
|
-
const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url2);
|
|
1037
|
-
url2 = url2.slice(isWindows ? 5 : 4);
|
|
1038
|
-
}
|
|
1039
|
-
return [url2, parts[2] || void 0, parts[3] || void 0];
|
|
1040
|
-
}
|
|
1041
|
-
function parseSingleFFOrSafariStack(raw) {
|
|
1042
|
-
let line = raw.trim();
|
|
1043
|
-
if (SAFARI_NATIVE_CODE_REGEXP.test(line)) {
|
|
1044
|
-
return null;
|
|
1045
|
-
}
|
|
1046
|
-
if (line.includes(" > eval")) {
|
|
1047
|
-
line = line.replace(
|
|
1048
|
-
/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,
|
|
1049
|
-
":$1"
|
|
1050
|
-
);
|
|
1051
|
-
}
|
|
1052
|
-
if (!line.includes("@") && !line.includes(":")) {
|
|
1053
|
-
return null;
|
|
1054
|
-
}
|
|
1055
|
-
const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(@)/;
|
|
1056
|
-
const matches = line.match(functionNameRegex);
|
|
1057
|
-
const functionName = matches && matches[1] ? matches[1] : void 0;
|
|
1058
|
-
const [url2, lineNumber, columnNumber] = extractLocation(
|
|
1059
|
-
line.replace(functionNameRegex, "")
|
|
1060
|
-
);
|
|
1061
|
-
if (!url2 || !lineNumber || !columnNumber) {
|
|
1062
|
-
return null;
|
|
1063
|
-
}
|
|
1064
|
-
return {
|
|
1065
|
-
file: url2,
|
|
1066
|
-
method: functionName || "",
|
|
1067
|
-
line: Number.parseInt(lineNumber),
|
|
1068
|
-
column: Number.parseInt(columnNumber)
|
|
1069
|
-
};
|
|
1070
|
-
}
|
|
1071
|
-
function parseSingleV8Stack(raw) {
|
|
1072
|
-
let line = raw.trim();
|
|
1073
|
-
if (!CHROME_IE_STACK_REGEXP.test(line)) {
|
|
1074
|
-
return null;
|
|
1075
|
-
}
|
|
1076
|
-
if (line.includes("(eval ")) {
|
|
1077
|
-
line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
|
|
1078
|
-
}
|
|
1079
|
-
let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
|
|
1080
|
-
const location2 = sanitizedLine.match(/ (\(.+\)$)/);
|
|
1081
|
-
sanitizedLine = location2 ? sanitizedLine.replace(location2[0], "") : sanitizedLine;
|
|
1082
|
-
const [url2, lineNumber, columnNumber] = extractLocation(
|
|
1083
|
-
location2 ? location2[1] : sanitizedLine
|
|
1084
|
-
);
|
|
1085
|
-
let method = location2 && sanitizedLine || "";
|
|
1086
|
-
let file = url2 && ["eval", "<anonymous>"].includes(url2) ? void 0 : url2;
|
|
1087
|
-
if (!file || !lineNumber || !columnNumber) {
|
|
1088
|
-
return null;
|
|
1089
|
-
}
|
|
1090
|
-
if (method.startsWith("async ")) {
|
|
1091
|
-
method = method.slice(6);
|
|
1092
|
-
}
|
|
1093
|
-
if (file.startsWith("file://")) {
|
|
1094
|
-
file = file.slice(7);
|
|
1095
|
-
}
|
|
1096
|
-
file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve(file);
|
|
1097
|
-
if (method) {
|
|
1098
|
-
method = method.replace(/__vite_ssr_import_\d+__\./g, "");
|
|
1099
|
-
}
|
|
1100
|
-
return {
|
|
1101
|
-
method,
|
|
1102
|
-
file,
|
|
1103
|
-
line: Number.parseInt(lineNumber),
|
|
1104
|
-
column: Number.parseInt(columnNumber)
|
|
1105
|
-
};
|
|
1106
|
-
}
|
|
1107
|
-
function createStackString(stacks) {
|
|
1108
|
-
return stacks.map((stack) => {
|
|
1109
|
-
const line = `${stack.file}:${stack.line}:${stack.column}`;
|
|
1110
|
-
if (stack.method) {
|
|
1111
|
-
return ` at ${stack.method}(${line})`;
|
|
1112
|
-
}
|
|
1113
|
-
return ` at ${line}`;
|
|
1114
|
-
}).join("\n");
|
|
1115
|
-
}
|
|
1116
|
-
function parseStacktrace(stack, options = {}) {
|
|
1117
|
-
const { ignoreStackEntries = stackIgnorePatterns } = options;
|
|
1118
|
-
const stacks = !CHROME_IE_STACK_REGEXP.test(stack) ? parseFFOrSafariStackTrace(stack) : parseV8Stacktrace(stack);
|
|
1119
|
-
return stacks.map((stack2) => {
|
|
1120
|
-
var _a;
|
|
1121
|
-
if (options.getUrlId) {
|
|
1122
|
-
stack2.file = options.getUrlId(stack2.file);
|
|
1123
|
-
}
|
|
1124
|
-
const map = (_a = options.getSourceMap) == null ? void 0 : _a.call(options, stack2.file);
|
|
1125
|
-
if (!map || typeof map !== "object" || !map.version) {
|
|
1126
|
-
return shouldFilter(ignoreStackEntries, stack2.file) ? null : stack2;
|
|
1127
|
-
}
|
|
1128
|
-
const traceMap = new TraceMap(map);
|
|
1129
|
-
const { line, column, source, name } = originalPositionFor(traceMap, stack2);
|
|
1130
|
-
let file = stack2.file;
|
|
1131
|
-
if (source) {
|
|
1132
|
-
const fileUrl = stack2.file.startsWith("file://") ? stack2.file : `file://${stack2.file}`;
|
|
1133
|
-
const sourceRootUrl = map.sourceRoot ? new URL(map.sourceRoot, fileUrl) : fileUrl;
|
|
1134
|
-
file = new URL(source, sourceRootUrl).pathname;
|
|
1135
|
-
if (file.match(/\/\w:\//)) {
|
|
1136
|
-
file = file.slice(1);
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
if (shouldFilter(ignoreStackEntries, file)) {
|
|
1140
|
-
return null;
|
|
1141
|
-
}
|
|
1142
|
-
if (line != null && column != null) {
|
|
1143
|
-
return {
|
|
1144
|
-
line,
|
|
1145
|
-
column,
|
|
1146
|
-
file,
|
|
1147
|
-
method: name || stack2.method
|
|
1148
|
-
};
|
|
1149
|
-
}
|
|
1150
|
-
return stack2;
|
|
1151
|
-
}).filter((s) => s != null);
|
|
1152
|
-
}
|
|
1153
|
-
function shouldFilter(ignoreStackEntries, file) {
|
|
1154
|
-
return ignoreStackEntries.some((p2) => file.match(p2));
|
|
1155
|
-
}
|
|
1156
|
-
function parseFFOrSafariStackTrace(stack) {
|
|
1157
|
-
return stack.split("\n").map((line) => parseSingleFFOrSafariStack(line)).filter(notNullish);
|
|
1158
|
-
}
|
|
1159
|
-
function parseV8Stacktrace(stack) {
|
|
1160
|
-
return stack.split("\n").map((line) => parseSingleV8Stack(line)).filter(notNullish);
|
|
1161
|
-
}
|
|
1162
|
-
class VitestBrowserSnapshotEnvironment {
|
|
1163
|
-
constructor() {
|
|
1164
|
-
__publicField(this, "sourceMaps", /* @__PURE__ */ new Map());
|
|
1165
|
-
__publicField(this, "traceMaps", /* @__PURE__ */ new Map());
|
|
1166
|
-
}
|
|
1167
|
-
addSourceMap(filepath, map) {
|
|
1168
|
-
this.sourceMaps.set(filepath, map);
|
|
1169
|
-
}
|
|
1170
|
-
getVersion() {
|
|
1171
|
-
return "1";
|
|
1172
|
-
}
|
|
1173
|
-
getHeader() {
|
|
1174
|
-
return `// Vitest Snapshot v${this.getVersion()}, https://vitest.dev/guide/snapshot.html`;
|
|
1175
|
-
}
|
|
1176
|
-
readSnapshotFile(filepath) {
|
|
1177
|
-
return rpc$1().readSnapshotFile(filepath);
|
|
1178
|
-
}
|
|
1179
|
-
saveSnapshotFile(filepath, snapshot) {
|
|
1180
|
-
return rpc$1().saveSnapshotFile(filepath, snapshot);
|
|
1181
|
-
}
|
|
1182
|
-
resolvePath(filepath) {
|
|
1183
|
-
return rpc$1().resolveSnapshotPath(filepath);
|
|
1184
|
-
}
|
|
1185
|
-
resolveRawPath(testPath, rawPath) {
|
|
1186
|
-
return rpc$1().resolveSnapshotRawPath(testPath, rawPath);
|
|
1187
|
-
}
|
|
1188
|
-
removeSnapshotFile(filepath) {
|
|
1189
|
-
return rpc$1().removeSnapshotFile(filepath);
|
|
1190
|
-
}
|
|
1191
|
-
processStackTrace(stack) {
|
|
1192
|
-
const map = this.sourceMaps.get(stack.file);
|
|
1193
|
-
if (!map) {
|
|
1194
|
-
return stack;
|
|
1195
|
-
}
|
|
1196
|
-
let traceMap = this.traceMaps.get(stack.file);
|
|
1197
|
-
if (!traceMap) {
|
|
1198
|
-
traceMap = new TraceMap$1(map);
|
|
1199
|
-
this.traceMaps.set(stack.file, traceMap);
|
|
1200
|
-
}
|
|
1201
|
-
const { line, column } = originalPositionFor$1(traceMap, stack);
|
|
1202
|
-
if (line != null && column != null) {
|
|
1203
|
-
return { ...stack, line, column };
|
|
1204
|
-
}
|
|
1205
|
-
return stack;
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
function rpc$1() {
|
|
1209
|
-
return globalThis.__vitest_worker__.rpc;
|
|
1210
|
-
}
|
|
1211
|
-
const browserHashMap = /* @__PURE__ */ new Map();
|
|
1212
|
-
function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
|
|
1213
|
-
return class BrowserTestRunner extends runnerClass {
|
|
1214
|
-
constructor(options) {
|
|
1215
|
-
super(options.config);
|
|
1216
|
-
__publicField(this, "config");
|
|
1217
|
-
__publicField(this, "hashMap", browserHashMap);
|
|
1218
|
-
__publicField(this, "sourceMapCache", /* @__PURE__ */ new Map());
|
|
1219
|
-
__publicField(this, "method", "run");
|
|
1220
|
-
__publicField(this, "onBeforeTryTask", async (...args) => {
|
|
1221
|
-
var _a;
|
|
1222
|
-
await userEvent.cleanup();
|
|
1223
|
-
await ((_a = super.onBeforeTryTask) == null ? void 0 : _a.call(this, ...args));
|
|
1224
|
-
});
|
|
1225
|
-
__publicField(this, "onAfterRunTask", async (task) => {
|
|
1226
|
-
var _a, _b;
|
|
1227
|
-
await ((_a = super.onAfterRunTask) == null ? void 0 : _a.call(this, task));
|
|
1228
|
-
if (this.config.bail && ((_b = task.result) == null ? void 0 : _b.state) === "fail") {
|
|
1229
|
-
const previousFailures = await rpc$2().getCountOfFailedTests();
|
|
1230
|
-
const currentFailures = 1 + previousFailures;
|
|
1231
|
-
if (currentFailures >= this.config.bail) {
|
|
1232
|
-
rpc$2().cancelCurrentRun("test-failure");
|
|
1233
|
-
this.cancel("test-failure");
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
});
|
|
1237
|
-
__publicField(this, "onTaskFinished", async (task) => {
|
|
1238
|
-
var _a, _b;
|
|
1239
|
-
if (this.config.browser.screenshotFailures && document.body.clientHeight > 0 && ((_a = task.result) == null ? void 0 : _a.state) === "fail") {
|
|
1240
|
-
const screenshot = await page.screenshot(
|
|
1241
|
-
{
|
|
1242
|
-
timeout: ((_b = this.config.browser.providerOptions) == null ? void 0 : _b.actionTimeout) ?? 5e3
|
|
1243
|
-
}
|
|
1244
|
-
/** TODO */
|
|
1245
|
-
).catch((err) => {
|
|
1246
|
-
console.error("[vitest] Failed to take a screenshot", err);
|
|
1247
|
-
});
|
|
1248
|
-
if (screenshot) {
|
|
1249
|
-
task.meta.failScreenshotPath = screenshot;
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
});
|
|
1253
|
-
__publicField(this, "cancel", (reason) => {
|
|
1254
|
-
var _a;
|
|
1255
|
-
(_a = super.cancel) == null ? void 0 : _a.call(this, reason);
|
|
1256
|
-
globalChannel.postMessage({ type: "cancel", reason });
|
|
1257
|
-
});
|
|
1258
|
-
__publicField(this, "onBeforeRunSuite", async (suite) => {
|
|
1259
|
-
var _a;
|
|
1260
|
-
await Promise.all([
|
|
1261
|
-
(_a = super.onBeforeRunSuite) == null ? void 0 : _a.call(this, suite),
|
|
1262
|
-
(async () => {
|
|
1263
|
-
if ("filepath" in suite) {
|
|
1264
|
-
const map = await rpc$2().getBrowserFileSourceMap(suite.filepath);
|
|
1265
|
-
this.sourceMapCache.set(suite.filepath, map);
|
|
1266
|
-
const snapshotEnvironment = this.config.snapshotOptions.snapshotEnvironment;
|
|
1267
|
-
if (snapshotEnvironment instanceof VitestBrowserSnapshotEnvironment) {
|
|
1268
|
-
snapshotEnvironment.addSourceMap(suite.filepath, map);
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
})()
|
|
1272
|
-
]);
|
|
1273
|
-
});
|
|
1274
|
-
__publicField(this, "onAfterRunFiles", async (files) => {
|
|
1275
|
-
var _a, _b;
|
|
1276
|
-
const [coverage] = await Promise.all([
|
|
1277
|
-
(_a = coverageModule == null ? void 0 : coverageModule.takeCoverage) == null ? void 0 : _a.call(coverageModule),
|
|
1278
|
-
mocker.invalidate(),
|
|
1279
|
-
(_b = super.onAfterRunFiles) == null ? void 0 : _b.call(this, files)
|
|
1280
|
-
]);
|
|
1281
|
-
if (coverage) {
|
|
1282
|
-
await rpc$2().onAfterSuiteRun({
|
|
1283
|
-
coverage,
|
|
1284
|
-
testFiles: files.map((file) => file.name),
|
|
1285
|
-
environment: "__browser__",
|
|
1286
|
-
projectName: this.config.name
|
|
1287
|
-
});
|
|
1288
|
-
}
|
|
1289
|
-
});
|
|
1290
|
-
__publicField(this, "onCollectStart", (file) => {
|
|
1291
|
-
return rpc$2().onQueued(this.method, file);
|
|
1292
|
-
});
|
|
1293
|
-
__publicField(this, "onCollected", async (files) => {
|
|
1294
|
-
files.forEach((file) => {
|
|
1295
|
-
file.prepareDuration = state.durations.prepare;
|
|
1296
|
-
file.environmentLoad = state.durations.environment;
|
|
1297
|
-
state.durations.prepare = 0;
|
|
1298
|
-
state.durations.environment = 0;
|
|
1299
|
-
});
|
|
1300
|
-
if (this.config.includeTaskLocation) {
|
|
1301
|
-
try {
|
|
1302
|
-
await updateTestFilesLocations(files, this.sourceMapCache);
|
|
1303
|
-
} catch {
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
return rpc$2().onCollected(this.method, files);
|
|
1307
|
-
});
|
|
1308
|
-
__publicField(this, "onTestAnnotate", (test, annotation) => {
|
|
1309
|
-
if (annotation.location) {
|
|
1310
|
-
const map = this.sourceMapCache.get(annotation.location.file);
|
|
1311
|
-
if (!map) {
|
|
1312
|
-
return rpc$2().onTaskAnnotate(test.id, annotation);
|
|
1313
|
-
}
|
|
1314
|
-
const traceMap = new TraceMap$1(map);
|
|
1315
|
-
const { line, column, source } = originalPositionFor$1(traceMap, annotation.location);
|
|
1316
|
-
if (line != null && column != null && source != null) {
|
|
1317
|
-
let file = annotation.location.file;
|
|
1318
|
-
if (source) {
|
|
1319
|
-
const fileUrl = annotation.location.file.startsWith("file://") ? annotation.location.file : `file://${annotation.location.file}`;
|
|
1320
|
-
const sourceRootUrl = map.sourceRoot ? new URL(map.sourceRoot, fileUrl) : fileUrl;
|
|
1321
|
-
file = new URL(source, sourceRootUrl).pathname;
|
|
1322
|
-
}
|
|
1323
|
-
annotation.location = {
|
|
1324
|
-
line,
|
|
1325
|
-
column: column + 1,
|
|
1326
|
-
// if the file path is on windows, we need to remove the starting slash
|
|
1327
|
-
file: file.match(/\/\w:\//) ? file.slice(1) : file
|
|
1328
|
-
};
|
|
1329
|
-
}
|
|
1330
|
-
}
|
|
1331
|
-
return rpc$2().onTaskAnnotate(test.id, annotation);
|
|
1332
|
-
});
|
|
1333
|
-
__publicField(this, "onTaskUpdate", (task, events) => {
|
|
1334
|
-
return rpc$2().onTaskUpdate(this.method, task, events);
|
|
1335
|
-
});
|
|
1336
|
-
__publicField(this, "importFile", async (filepath) => {
|
|
1337
|
-
let hash = this.hashMap.get(filepath);
|
|
1338
|
-
if (!hash) {
|
|
1339
|
-
hash = Date.now().toString();
|
|
1340
|
-
this.hashMap.set(filepath, hash);
|
|
1341
|
-
}
|
|
1342
|
-
const prefix = `/${/^\w:/.test(filepath) ? "@fs/" : ""}`;
|
|
1343
|
-
const query = `browserv=${hash}`;
|
|
1344
|
-
const importpath = `${prefix}${filepath}?${query}`.replace(/\/+/g, "/");
|
|
1345
|
-
try {
|
|
1346
|
-
await import(
|
|
1347
|
-
/* @vite-ignore */
|
|
1348
|
-
importpath
|
|
1349
|
-
);
|
|
1350
|
-
} catch (err) {
|
|
1351
|
-
throw new Error(`Failed to import test file ${filepath}`, { cause: err });
|
|
1352
|
-
}
|
|
1353
|
-
});
|
|
1354
|
-
this.config = options.config;
|
|
1355
|
-
}
|
|
1356
|
-
setMethod(method) {
|
|
1357
|
-
this.method = method;
|
|
1358
|
-
}
|
|
1359
|
-
};
|
|
1360
|
-
}
|
|
1361
|
-
let cachedRunner = null;
|
|
1362
|
-
function getBrowserRunner() {
|
|
1363
|
-
return cachedRunner;
|
|
1364
|
-
}
|
|
1365
|
-
async function initiateRunner(state, mocker, config) {
|
|
1366
|
-
if (cachedRunner) {
|
|
1367
|
-
return cachedRunner;
|
|
1368
|
-
}
|
|
1369
|
-
const runnerClass = config.mode === "test" ? VitestTestRunner : NodeBenchmarkRunner;
|
|
1370
|
-
const BrowserRunner = createBrowserRunner(runnerClass, mocker, state, {
|
|
1371
|
-
takeCoverage: () => takeCoverageInsideWorker(config.coverage, moduleRunner)
|
|
1372
|
-
});
|
|
1373
|
-
if (!config.snapshotOptions.snapshotEnvironment) {
|
|
1374
|
-
config.snapshotOptions.snapshotEnvironment = new VitestBrowserSnapshotEnvironment();
|
|
1375
|
-
}
|
|
1376
|
-
const runner = new BrowserRunner({
|
|
1377
|
-
config
|
|
1378
|
-
});
|
|
1379
|
-
cachedRunner = runner;
|
|
1380
|
-
onCancel.then((reason) => {
|
|
1381
|
-
var _a;
|
|
1382
|
-
(_a = runner.cancel) == null ? void 0 : _a.call(runner, reason);
|
|
1383
|
-
});
|
|
1384
|
-
const [diffOptions] = await Promise.all([
|
|
1385
|
-
loadDiffConfig(config, moduleRunner),
|
|
1386
|
-
loadSnapshotSerializers(config, moduleRunner)
|
|
1387
|
-
]);
|
|
1388
|
-
runner.config.diffOptions = diffOptions;
|
|
1389
|
-
getWorkerState().onFilterStackTrace = (stack) => {
|
|
1390
|
-
const stacks = parseStacktrace(stack, {
|
|
1391
|
-
getSourceMap(file) {
|
|
1392
|
-
return runner.sourceMapCache.get(file);
|
|
1393
|
-
}
|
|
1394
|
-
});
|
|
1395
|
-
return createStackString(stacks);
|
|
1396
|
-
};
|
|
1397
|
-
return runner;
|
|
1398
|
-
}
|
|
1399
|
-
async function getTraceMap(file, sourceMaps) {
|
|
1400
|
-
const result = sourceMaps.get(file) || await rpc$2().getBrowserFileSourceMap(file).then((map) => {
|
|
1401
|
-
sourceMaps.set(file, map);
|
|
1402
|
-
return map;
|
|
1403
|
-
});
|
|
1404
|
-
if (!result) {
|
|
1405
|
-
return null;
|
|
1406
|
-
}
|
|
1407
|
-
return new TraceMap$1(result);
|
|
1408
|
-
}
|
|
1409
|
-
async function updateTestFilesLocations(files, sourceMaps) {
|
|
1410
|
-
const promises2 = files.map(async (file) => {
|
|
1411
|
-
const traceMap = await getTraceMap(file.filepath, sourceMaps);
|
|
1412
|
-
if (!traceMap) {
|
|
1413
|
-
return null;
|
|
1414
|
-
}
|
|
1415
|
-
const updateLocation = (task) => {
|
|
1416
|
-
if (task.location) {
|
|
1417
|
-
const { line, column } = originalPositionFor$1(traceMap, task.location);
|
|
1418
|
-
if (line != null && column != null) {
|
|
1419
|
-
task.location = { line, column: task.each ? column : column + 1 };
|
|
1420
|
-
}
|
|
1421
|
-
}
|
|
1422
|
-
if ("tasks" in task) {
|
|
1423
|
-
task.tasks.forEach(updateLocation);
|
|
1424
|
-
}
|
|
1425
|
-
};
|
|
1426
|
-
file.tasks.forEach(updateLocation);
|
|
1427
|
-
return null;
|
|
1428
|
-
});
|
|
1429
|
-
await Promise.all(promises2);
|
|
1430
|
-
}
|
|
1431
|
-
const { Date: Date$1, console: console$1, performance: performance$1 } = globalThis;
|
|
1432
|
-
function setupConsoleLogSpy() {
|
|
1433
|
-
const {
|
|
1434
|
-
log,
|
|
1435
|
-
info,
|
|
1436
|
-
error,
|
|
1437
|
-
dir,
|
|
1438
|
-
dirxml,
|
|
1439
|
-
trace,
|
|
1440
|
-
time,
|
|
1441
|
-
timeEnd,
|
|
1442
|
-
timeLog,
|
|
1443
|
-
warn,
|
|
1444
|
-
debug: debug2,
|
|
1445
|
-
count,
|
|
1446
|
-
countReset
|
|
1447
|
-
} = console$1;
|
|
1448
|
-
console$1.log = stdout(log);
|
|
1449
|
-
console$1.debug = stdout(debug2);
|
|
1450
|
-
console$1.info = stdout(info);
|
|
1451
|
-
console$1.error = stderr(error);
|
|
1452
|
-
console$1.warn = stderr(warn);
|
|
1453
|
-
console$1.dir = (item, options) => {
|
|
1454
|
-
dir(item, options);
|
|
1455
|
-
sendLog("stdout", formatInput(item));
|
|
1456
|
-
};
|
|
1457
|
-
console$1.dirxml = (...args) => {
|
|
1458
|
-
dirxml(...args);
|
|
1459
|
-
sendLog("stdout", processLog(args));
|
|
1460
|
-
};
|
|
1461
|
-
console$1.trace = (...args) => {
|
|
1462
|
-
var _a;
|
|
1463
|
-
trace(...args);
|
|
1464
|
-
const content = processLog(args);
|
|
1465
|
-
const error2 = new Error("$$Trace");
|
|
1466
|
-
const processor = ((_a = globalThis.__vitest_worker__) == null ? void 0 : _a.onFilterStackTrace) || ((s) => s || "");
|
|
1467
|
-
const stack = processor(error2.stack || "");
|
|
1468
|
-
sendLog("stderr", `${content}
|
|
1469
|
-
${stack}`, true);
|
|
1470
|
-
};
|
|
1471
|
-
const timeLabels = {};
|
|
1472
|
-
console$1.time = (label = "default") => {
|
|
1473
|
-
time(label);
|
|
1474
|
-
const now2 = performance$1.now();
|
|
1475
|
-
timeLabels[label] = now2;
|
|
1476
|
-
};
|
|
1477
|
-
console$1.timeLog = (label = "default") => {
|
|
1478
|
-
timeLog(label);
|
|
1479
|
-
if (!(label in timeLabels)) {
|
|
1480
|
-
sendLog("stderr", `Timer "${label}" does not exist`);
|
|
1481
|
-
} else {
|
|
1482
|
-
sendLog("stdout", `${label}: ${timeLabels[label]} ms`);
|
|
1483
|
-
}
|
|
1484
|
-
};
|
|
1485
|
-
console$1.timeEnd = (label = "default") => {
|
|
1486
|
-
timeEnd(label);
|
|
1487
|
-
const end = performance$1.now();
|
|
1488
|
-
const start = timeLabels[label];
|
|
1489
|
-
if (!(label in timeLabels)) {
|
|
1490
|
-
sendLog("stderr", `Timer "${label}" does not exist`);
|
|
1491
|
-
} else if (typeof start !== "undefined") {
|
|
1492
|
-
const duration = end - start;
|
|
1493
|
-
sendLog("stdout", `${label}: ${duration} ms`);
|
|
1494
|
-
}
|
|
1495
|
-
};
|
|
1496
|
-
const countLabels = {};
|
|
1497
|
-
console$1.count = (label = "default") => {
|
|
1498
|
-
count(label);
|
|
1499
|
-
const counter = (countLabels[label] ?? 0) + 1;
|
|
1500
|
-
countLabels[label] = counter;
|
|
1501
|
-
sendLog("stdout", `${label}: ${counter}`);
|
|
1502
|
-
};
|
|
1503
|
-
console$1.countReset = (label = "default") => {
|
|
1504
|
-
countReset(label);
|
|
1505
|
-
countLabels[label] = 0;
|
|
1506
|
-
};
|
|
1507
|
-
}
|
|
1508
|
-
function stdout(base) {
|
|
1509
|
-
return (...args) => {
|
|
1510
|
-
base(...args);
|
|
1511
|
-
if (args[0] === "[WDIO]") {
|
|
1512
|
-
if (args[1] === "newShadowRoot" || args[1] === "removeShadowRoot") {
|
|
1513
|
-
return;
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1516
|
-
sendLog("stdout", processLog(args));
|
|
1517
|
-
};
|
|
1518
|
-
}
|
|
1519
|
-
function stderr(base) {
|
|
1520
|
-
return (...args) => {
|
|
1521
|
-
base(...args);
|
|
1522
|
-
sendLog("stderr", processLog(args));
|
|
1523
|
-
};
|
|
1524
|
-
}
|
|
1525
|
-
function formatInput(input) {
|
|
1526
|
-
if (typeof input === "object") {
|
|
1527
|
-
return stringify(input, void 0, {
|
|
1528
|
-
printBasicPrototype: false,
|
|
1529
|
-
escapeString: false
|
|
1530
|
-
});
|
|
1531
|
-
}
|
|
1532
|
-
return format(input);
|
|
1533
|
-
}
|
|
1534
|
-
function processLog(args) {
|
|
1535
|
-
return args.map(formatInput).join(" ");
|
|
1536
|
-
}
|
|
1537
|
-
function sendLog(type, content, disableStack) {
|
|
1538
|
-
var _a, _b, _c;
|
|
1539
|
-
if (content.startsWith("[vite]")) {
|
|
1540
|
-
return;
|
|
1541
|
-
}
|
|
1542
|
-
const unknownTestId = "__vitest__unknown_test__";
|
|
1543
|
-
const taskId = ((_b = (_a = globalThis.__vitest_worker__) == null ? void 0 : _a.current) == null ? void 0 : _b.id) ?? unknownTestId;
|
|
1544
|
-
const origin = getConfig().printConsoleTrace && !disableStack ? (_c = new Error("STACK_TRACE").stack) == null ? void 0 : _c.split("\n").slice(1).join("\n") : void 0;
|
|
1545
|
-
const runner = getBrowserRunner();
|
|
1546
|
-
rpc$2().sendLog((runner == null ? void 0 : runner.method) || "run", {
|
|
1547
|
-
origin,
|
|
1548
|
-
content,
|
|
1549
|
-
browser: true,
|
|
1550
|
-
time: Date$1.now(),
|
|
1551
|
-
taskId,
|
|
1552
|
-
type,
|
|
1553
|
-
size: content.length
|
|
1554
|
-
});
|
|
1555
|
-
}
|
|
1556
|
-
class MockerRegistry {
|
|
1557
|
-
constructor() {
|
|
1558
|
-
__publicField(this, "registryByUrl", /* @__PURE__ */ new Map());
|
|
1559
|
-
__publicField(this, "registryById", /* @__PURE__ */ new Map());
|
|
1560
|
-
}
|
|
1561
|
-
clear() {
|
|
1562
|
-
this.registryByUrl.clear();
|
|
1563
|
-
this.registryById.clear();
|
|
1564
|
-
}
|
|
1565
|
-
keys() {
|
|
1566
|
-
return this.registryByUrl.keys();
|
|
1567
|
-
}
|
|
1568
|
-
add(mock) {
|
|
1569
|
-
this.registryByUrl.set(mock.url, mock);
|
|
1570
|
-
this.registryById.set(mock.id, mock);
|
|
1571
|
-
}
|
|
1572
|
-
register(typeOrEvent, raw, id, url2, factoryOrRedirect) {
|
|
1573
|
-
const type = typeof typeOrEvent === "object" ? typeOrEvent.type : typeOrEvent;
|
|
1574
|
-
if (typeof typeOrEvent === "object") {
|
|
1575
|
-
const event = typeOrEvent;
|
|
1576
|
-
if (event instanceof AutomockedModule || event instanceof AutospiedModule || event instanceof ManualMockedModule || event instanceof RedirectedModule) {
|
|
1577
|
-
throw new TypeError(`[vitest] Cannot register a mock that is already defined. Expected a JSON representation from \`MockedModule.toJSON\`, instead got "${event.type}". Use "registry.add()" to update a mock instead.`);
|
|
1578
|
-
}
|
|
1579
|
-
if (event.type === "automock") {
|
|
1580
|
-
const module = AutomockedModule.fromJSON(event);
|
|
1581
|
-
this.add(module);
|
|
1582
|
-
return module;
|
|
1583
|
-
} else if (event.type === "autospy") {
|
|
1584
|
-
const module = AutospiedModule.fromJSON(event);
|
|
1585
|
-
this.add(module);
|
|
1586
|
-
return module;
|
|
1587
|
-
} else if (event.type === "redirect") {
|
|
1588
|
-
const module = RedirectedModule.fromJSON(event);
|
|
1589
|
-
this.add(module);
|
|
1590
|
-
return module;
|
|
1591
|
-
} else if (event.type === "manual") {
|
|
1592
|
-
throw new Error(`Cannot set serialized manual mock. Define a factory function manually with \`ManualMockedModule.fromJSON()\`.`);
|
|
1593
|
-
} else {
|
|
1594
|
-
throw new Error(`Unknown mock type: ${event.type}`);
|
|
1595
|
-
}
|
|
1596
|
-
}
|
|
1597
|
-
if (typeof raw !== "string") {
|
|
1598
|
-
throw new TypeError("[vitest] Mocks require a raw string.");
|
|
1599
|
-
}
|
|
1600
|
-
if (typeof url2 !== "string") {
|
|
1601
|
-
throw new TypeError("[vitest] Mocks require a url string.");
|
|
1602
|
-
}
|
|
1603
|
-
if (typeof id !== "string") {
|
|
1604
|
-
throw new TypeError("[vitest] Mocks require an id string.");
|
|
1605
|
-
}
|
|
1606
|
-
if (type === "manual") {
|
|
1607
|
-
if (typeof factoryOrRedirect !== "function") {
|
|
1608
|
-
throw new TypeError("[vitest] Manual mocks require a factory function.");
|
|
1609
|
-
}
|
|
1610
|
-
const mock = new ManualMockedModule(raw, id, url2, factoryOrRedirect);
|
|
1611
|
-
this.add(mock);
|
|
1612
|
-
return mock;
|
|
1613
|
-
} else if (type === "automock" || type === "autospy") {
|
|
1614
|
-
const mock = type === "automock" ? new AutomockedModule(raw, id, url2) : new AutospiedModule(raw, id, url2);
|
|
1615
|
-
this.add(mock);
|
|
1616
|
-
return mock;
|
|
1617
|
-
} else if (type === "redirect") {
|
|
1618
|
-
if (typeof factoryOrRedirect !== "string") {
|
|
1619
|
-
throw new TypeError("[vitest] Redirect mocks require a redirect string.");
|
|
1620
|
-
}
|
|
1621
|
-
const mock = new RedirectedModule(raw, id, url2, factoryOrRedirect);
|
|
1622
|
-
this.add(mock);
|
|
1623
|
-
return mock;
|
|
1624
|
-
} else {
|
|
1625
|
-
throw new Error(`[vitest] Unknown mock type: ${type}`);
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
delete(id) {
|
|
1629
|
-
this.registryByUrl.delete(id);
|
|
1630
|
-
}
|
|
1631
|
-
deleteById(id) {
|
|
1632
|
-
this.registryById.delete(id);
|
|
1633
|
-
}
|
|
1634
|
-
get(id) {
|
|
1635
|
-
return this.registryByUrl.get(id);
|
|
1636
|
-
}
|
|
1637
|
-
getById(id) {
|
|
1638
|
-
return this.registryById.get(id);
|
|
1639
|
-
}
|
|
1640
|
-
has(id) {
|
|
1641
|
-
return this.registryByUrl.has(id);
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
class AutomockedModule {
|
|
1645
|
-
constructor(raw, id, url2) {
|
|
1646
|
-
__publicField(this, "type", "automock");
|
|
1647
|
-
this.raw = raw;
|
|
1648
|
-
this.id = id;
|
|
1649
|
-
this.url = url2;
|
|
1650
|
-
}
|
|
1651
|
-
static fromJSON(data) {
|
|
1652
|
-
return new AutospiedModule(data.raw, data.id, data.url);
|
|
1653
|
-
}
|
|
1654
|
-
toJSON() {
|
|
1655
|
-
return {
|
|
1656
|
-
type: this.type,
|
|
1657
|
-
url: this.url,
|
|
1658
|
-
raw: this.raw,
|
|
1659
|
-
id: this.id
|
|
1660
|
-
};
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1663
|
-
class AutospiedModule {
|
|
1664
|
-
constructor(raw, id, url2) {
|
|
1665
|
-
__publicField(this, "type", "autospy");
|
|
1666
|
-
this.raw = raw;
|
|
1667
|
-
this.id = id;
|
|
1668
|
-
this.url = url2;
|
|
1669
|
-
}
|
|
1670
|
-
static fromJSON(data) {
|
|
1671
|
-
return new AutospiedModule(data.raw, data.id, data.url);
|
|
1672
|
-
}
|
|
1673
|
-
toJSON() {
|
|
1674
|
-
return {
|
|
1675
|
-
type: this.type,
|
|
1676
|
-
url: this.url,
|
|
1677
|
-
id: this.id,
|
|
1678
|
-
raw: this.raw
|
|
1679
|
-
};
|
|
1680
|
-
}
|
|
1681
|
-
}
|
|
1682
|
-
class RedirectedModule {
|
|
1683
|
-
constructor(raw, id, url2, redirect) {
|
|
1684
|
-
__publicField(this, "type", "redirect");
|
|
1685
|
-
this.raw = raw;
|
|
1686
|
-
this.id = id;
|
|
1687
|
-
this.url = url2;
|
|
1688
|
-
this.redirect = redirect;
|
|
1689
|
-
}
|
|
1690
|
-
static fromJSON(data) {
|
|
1691
|
-
return new RedirectedModule(data.raw, data.id, data.url, data.redirect);
|
|
1692
|
-
}
|
|
1693
|
-
toJSON() {
|
|
1694
|
-
return {
|
|
1695
|
-
type: this.type,
|
|
1696
|
-
url: this.url,
|
|
1697
|
-
raw: this.raw,
|
|
1698
|
-
id: this.id,
|
|
1699
|
-
redirect: this.redirect
|
|
1700
|
-
};
|
|
1701
|
-
}
|
|
1702
|
-
}
|
|
1703
|
-
class ManualMockedModule {
|
|
1704
|
-
constructor(raw, id, url2, factory) {
|
|
1705
|
-
__publicField(this, "cache");
|
|
1706
|
-
__publicField(this, "type", "manual");
|
|
1707
|
-
this.raw = raw;
|
|
1708
|
-
this.id = id;
|
|
1709
|
-
this.url = url2;
|
|
1710
|
-
this.factory = factory;
|
|
1711
|
-
}
|
|
1712
|
-
async resolve() {
|
|
1713
|
-
if (this.cache) {
|
|
1714
|
-
return this.cache;
|
|
1715
|
-
}
|
|
1716
|
-
let exports;
|
|
1717
|
-
try {
|
|
1718
|
-
exports = await this.factory();
|
|
1719
|
-
} catch (err) {
|
|
1720
|
-
const vitestError = new Error('[vitest] There was an error when mocking a module. If you are using "vi.mock" factory, make sure there are no top level variables inside, since this call is hoisted to top of the file. Read more: https://vitest.dev/api/vi.html#vi-mock');
|
|
1721
|
-
vitestError.cause = err;
|
|
1722
|
-
throw vitestError;
|
|
1723
|
-
}
|
|
1724
|
-
if (exports === null || typeof exports !== "object" || Array.isArray(exports)) {
|
|
1725
|
-
throw new TypeError(`[vitest] vi.mock("${this.raw}", factory?: () => unknown) is not returning an object. Did you mean to return an object with a "default" key?`);
|
|
1726
|
-
}
|
|
1727
|
-
return this.cache = exports;
|
|
1728
|
-
}
|
|
1729
|
-
static fromJSON(data, factory) {
|
|
1730
|
-
return new ManualMockedModule(data.raw, data.id, data.url, factory);
|
|
1731
|
-
}
|
|
1732
|
-
toJSON() {
|
|
1733
|
-
return {
|
|
1734
|
-
type: this.type,
|
|
1735
|
-
url: this.url,
|
|
1736
|
-
id: this.id,
|
|
1737
|
-
raw: this.raw
|
|
1738
|
-
};
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
function mockObject(options, object2, mockExports = {}) {
|
|
1742
|
-
const finalizers = new Array();
|
|
1743
|
-
const refs = new RefTracker();
|
|
1744
|
-
const define = (container, key, value) => {
|
|
1745
|
-
try {
|
|
1746
|
-
container[key] = value;
|
|
1747
|
-
return true;
|
|
1748
|
-
} catch {
|
|
1749
|
-
return false;
|
|
1750
|
-
}
|
|
1751
|
-
};
|
|
1752
|
-
const createMock = (currentValue) => {
|
|
1753
|
-
if (!options.createMockInstance) {
|
|
1754
|
-
throw new Error("[@vitest/mocker] `createMockInstance` is not defined. This is a Vitest error. Please open a new issue with reproduction.");
|
|
1755
|
-
}
|
|
1756
|
-
const createMockInstance = options.createMockInstance;
|
|
1757
|
-
const prototypeMembers = currentValue.prototype ? collectFunctionProperties(currentValue.prototype) : [];
|
|
1758
|
-
return createMockInstance({
|
|
1759
|
-
name: currentValue.name,
|
|
1760
|
-
prototypeMembers,
|
|
1761
|
-
originalImplementation: options.type === "autospy" ? currentValue : void 0,
|
|
1762
|
-
keepMembersImplementation: options.type === "autospy"
|
|
1763
|
-
});
|
|
1764
|
-
};
|
|
1765
|
-
const mockPropertiesOf = (container, newContainer) => {
|
|
1766
|
-
const containerType = getType(container);
|
|
1767
|
-
const isModule = containerType === "Module" || !!container.__esModule;
|
|
1768
|
-
for (const { key: property, descriptor } of getAllMockableProperties(container, isModule, options.globalConstructors)) {
|
|
1769
|
-
if (!isModule && descriptor.get) {
|
|
1770
|
-
try {
|
|
1771
|
-
if (options.type === "autospy") {
|
|
1772
|
-
Object.defineProperty(newContainer, property, descriptor);
|
|
1773
|
-
} else {
|
|
1774
|
-
Object.defineProperty(newContainer, property, {
|
|
1775
|
-
configurable: descriptor.configurable,
|
|
1776
|
-
enumerable: descriptor.enumerable,
|
|
1777
|
-
get: () => {
|
|
1778
|
-
},
|
|
1779
|
-
set: descriptor.set ? () => {
|
|
1780
|
-
} : void 0
|
|
1781
|
-
});
|
|
1782
|
-
}
|
|
1783
|
-
} catch {
|
|
1784
|
-
}
|
|
1785
|
-
continue;
|
|
1786
|
-
}
|
|
1787
|
-
if (isReadonlyProp(container[property], property)) {
|
|
1788
|
-
continue;
|
|
1789
|
-
}
|
|
1790
|
-
const value = container[property];
|
|
1791
|
-
const refId = refs.getId(value);
|
|
1792
|
-
if (refId !== void 0) {
|
|
1793
|
-
finalizers.push(() => define(newContainer, property, refs.getMockedValue(refId)));
|
|
1794
|
-
continue;
|
|
1795
|
-
}
|
|
1796
|
-
const type = getType(value);
|
|
1797
|
-
if (Array.isArray(value)) {
|
|
1798
|
-
if (options.type === "automock") {
|
|
1799
|
-
define(newContainer, property, []);
|
|
1800
|
-
} else {
|
|
1801
|
-
const array = value.map((value2) => {
|
|
1802
|
-
if (value2 && typeof value2 === "object") {
|
|
1803
|
-
const newObject = {};
|
|
1804
|
-
mockPropertiesOf(value2, newObject);
|
|
1805
|
-
return newObject;
|
|
1806
|
-
}
|
|
1807
|
-
if (typeof value2 === "function") {
|
|
1808
|
-
return createMock(value2);
|
|
1809
|
-
}
|
|
1810
|
-
return value2;
|
|
1811
|
-
});
|
|
1812
|
-
define(newContainer, property, array);
|
|
1813
|
-
}
|
|
1814
|
-
continue;
|
|
1815
|
-
}
|
|
1816
|
-
const isFunction = type.includes("Function") && typeof value === "function";
|
|
1817
|
-
if ((!isFunction || value._isMockFunction) && type !== "Object" && type !== "Module") {
|
|
1818
|
-
define(newContainer, property, value);
|
|
1819
|
-
continue;
|
|
1820
|
-
}
|
|
1821
|
-
if (!define(newContainer, property, isFunction || options.type === "autospy" ? value : {})) {
|
|
1822
|
-
continue;
|
|
1823
|
-
}
|
|
1824
|
-
if (isFunction) {
|
|
1825
|
-
const mock = createMock(newContainer[property]);
|
|
1826
|
-
newContainer[property] = mock;
|
|
1827
|
-
}
|
|
1828
|
-
refs.track(value, newContainer[property]);
|
|
1829
|
-
mockPropertiesOf(value, newContainer[property]);
|
|
1830
|
-
}
|
|
1831
|
-
};
|
|
1832
|
-
const mockedObject = mockExports;
|
|
1833
|
-
mockPropertiesOf(object2, mockedObject);
|
|
1834
|
-
for (const finalizer of finalizers) {
|
|
1835
|
-
finalizer();
|
|
1836
|
-
}
|
|
1837
|
-
return mockedObject;
|
|
1838
|
-
}
|
|
1839
|
-
class RefTracker {
|
|
1840
|
-
constructor() {
|
|
1841
|
-
__publicField(this, "idMap", /* @__PURE__ */ new Map());
|
|
1842
|
-
__publicField(this, "mockedValueMap", /* @__PURE__ */ new Map());
|
|
1843
|
-
}
|
|
1844
|
-
getId(value) {
|
|
1845
|
-
return this.idMap.get(value);
|
|
1846
|
-
}
|
|
1847
|
-
getMockedValue(id) {
|
|
1848
|
-
return this.mockedValueMap.get(id);
|
|
1849
|
-
}
|
|
1850
|
-
track(originalValue, mockedValue) {
|
|
1851
|
-
const newId = this.idMap.size;
|
|
1852
|
-
this.idMap.set(originalValue, newId);
|
|
1853
|
-
this.mockedValueMap.set(newId, mockedValue);
|
|
1854
|
-
return newId;
|
|
1855
|
-
}
|
|
1856
|
-
}
|
|
1857
|
-
function getType(value) {
|
|
1858
|
-
return Object.prototype.toString.apply(value).slice(8, -1);
|
|
1859
|
-
}
|
|
1860
|
-
function isReadonlyProp(object2, prop) {
|
|
1861
|
-
if (prop === "arguments" || prop === "caller" || prop === "callee" || prop === "name" || prop === "length") {
|
|
1862
|
-
const typeName = getType(object2);
|
|
1863
|
-
return typeName === "Function" || typeName === "AsyncFunction" || typeName === "GeneratorFunction" || typeName === "AsyncGeneratorFunction";
|
|
1864
|
-
}
|
|
1865
|
-
if (prop === "source" || prop === "global" || prop === "ignoreCase" || prop === "multiline") {
|
|
1866
|
-
return getType(object2) === "RegExp";
|
|
1867
|
-
}
|
|
1868
|
-
return false;
|
|
1869
|
-
}
|
|
1870
|
-
function getAllMockableProperties(obj, isModule, constructors) {
|
|
1871
|
-
const { Map: Map2, Object: Object2, Function: Function2, RegExp: RegExp2, Array: Array2 } = constructors;
|
|
1872
|
-
const allProps = new Map2();
|
|
1873
|
-
let curr = obj;
|
|
1874
|
-
do {
|
|
1875
|
-
if (curr === Object2.prototype || curr === Function2.prototype || curr === RegExp2.prototype) {
|
|
1876
|
-
break;
|
|
1877
|
-
}
|
|
1878
|
-
collectOwnProperties(curr, (key) => {
|
|
1879
|
-
const descriptor = Object2.getOwnPropertyDescriptor(curr, key);
|
|
1880
|
-
if (descriptor) {
|
|
1881
|
-
allProps.set(key, {
|
|
1882
|
-
key,
|
|
1883
|
-
descriptor
|
|
1884
|
-
});
|
|
1885
|
-
}
|
|
1886
|
-
});
|
|
1887
|
-
} while (curr = Object2.getPrototypeOf(curr));
|
|
1888
|
-
if (isModule && !allProps.has("default") && "default" in obj) {
|
|
1889
|
-
const descriptor = Object2.getOwnPropertyDescriptor(obj, "default");
|
|
1890
|
-
if (descriptor) {
|
|
1891
|
-
allProps.set("default", {
|
|
1892
|
-
key: "default",
|
|
1893
|
-
descriptor
|
|
1894
|
-
});
|
|
1895
|
-
}
|
|
1896
|
-
}
|
|
1897
|
-
return Array2.from(allProps.values());
|
|
1898
|
-
}
|
|
1899
|
-
function collectOwnProperties(obj, collector) {
|
|
1900
|
-
const collect = typeof collector === "function" ? collector : (key) => collector.add(key);
|
|
1901
|
-
Object.getOwnPropertyNames(obj).forEach(collect);
|
|
1902
|
-
Object.getOwnPropertySymbols(obj).forEach(collect);
|
|
1903
|
-
}
|
|
1904
|
-
function collectFunctionProperties(prototype) {
|
|
1905
|
-
const properties = /* @__PURE__ */ new Set();
|
|
1906
|
-
collectOwnProperties(prototype, (prop) => {
|
|
1907
|
-
const descriptor = Object.getOwnPropertyDescriptor(prototype, prop);
|
|
1908
|
-
if (!descriptor || descriptor.get) {
|
|
1909
|
-
return;
|
|
1910
|
-
}
|
|
1911
|
-
const type = getType(descriptor.value);
|
|
1912
|
-
if (type.includes("Function") && !isReadonlyProp(descriptor.value, prop)) {
|
|
1913
|
-
properties.add(prop);
|
|
1914
|
-
}
|
|
1915
|
-
});
|
|
1916
|
-
return Array.from(properties);
|
|
1917
|
-
}
|
|
1918
|
-
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
1919
|
-
function normalizeWindowsPath(input = "") {
|
|
1920
|
-
if (!input) {
|
|
1921
|
-
return input;
|
|
1922
|
-
}
|
|
1923
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
1924
|
-
}
|
|
1925
|
-
const _UNC_REGEX = /^[/\\]{2}/;
|
|
1926
|
-
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
1927
|
-
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
1928
|
-
const _EXTNAME_RE = /.(\.[^./]+|\.)$/;
|
|
1929
|
-
const normalize = function(path) {
|
|
1930
|
-
if (path.length === 0) {
|
|
1931
|
-
return ".";
|
|
1932
|
-
}
|
|
1933
|
-
path = normalizeWindowsPath(path);
|
|
1934
|
-
const isUNCPath = path.match(_UNC_REGEX);
|
|
1935
|
-
const isPathAbsolute = isAbsolute(path);
|
|
1936
|
-
const trailingSeparator = path[path.length - 1] === "/";
|
|
1937
|
-
path = normalizeString(path, !isPathAbsolute);
|
|
1938
|
-
if (path.length === 0) {
|
|
1939
|
-
if (isPathAbsolute) {
|
|
1940
|
-
return "/";
|
|
1941
|
-
}
|
|
1942
|
-
return trailingSeparator ? "./" : ".";
|
|
1943
|
-
}
|
|
1944
|
-
if (trailingSeparator) {
|
|
1945
|
-
path += "/";
|
|
1946
|
-
}
|
|
1947
|
-
if (_DRIVE_LETTER_RE.test(path)) {
|
|
1948
|
-
path += "/";
|
|
1949
|
-
}
|
|
1950
|
-
if (isUNCPath) {
|
|
1951
|
-
if (!isPathAbsolute) {
|
|
1952
|
-
return `//./${path}`;
|
|
1953
|
-
}
|
|
1954
|
-
return `//${path}`;
|
|
1955
|
-
}
|
|
1956
|
-
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
1957
|
-
};
|
|
1958
|
-
const join = function(...segments) {
|
|
1959
|
-
let path = "";
|
|
1960
|
-
for (const seg of segments) {
|
|
1961
|
-
if (!seg) {
|
|
1962
|
-
continue;
|
|
1963
|
-
}
|
|
1964
|
-
if (path.length > 0) {
|
|
1965
|
-
const pathTrailing = path[path.length - 1] === "/";
|
|
1966
|
-
const segLeading = seg[0] === "/";
|
|
1967
|
-
const both = pathTrailing && segLeading;
|
|
1968
|
-
if (both) {
|
|
1969
|
-
path += seg.slice(1);
|
|
1970
|
-
} else {
|
|
1971
|
-
path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
1972
|
-
}
|
|
1973
|
-
} else {
|
|
1974
|
-
path += seg;
|
|
1975
|
-
}
|
|
1976
|
-
}
|
|
1977
|
-
return normalize(path);
|
|
1978
|
-
};
|
|
1979
|
-
function normalizeString(path, allowAboveRoot) {
|
|
1980
|
-
let res = "";
|
|
1981
|
-
let lastSegmentLength = 0;
|
|
1982
|
-
let lastSlash = -1;
|
|
1983
|
-
let dots = 0;
|
|
1984
|
-
let char = null;
|
|
1985
|
-
for (let index2 = 0; index2 <= path.length; ++index2) {
|
|
1986
|
-
if (index2 < path.length) {
|
|
1987
|
-
char = path[index2];
|
|
1988
|
-
} else if (char === "/") {
|
|
1989
|
-
break;
|
|
1990
|
-
} else {
|
|
1991
|
-
char = "/";
|
|
1992
|
-
}
|
|
1993
|
-
if (char === "/") {
|
|
1994
|
-
if (lastSlash === index2 - 1 || dots === 1) ;
|
|
1995
|
-
else if (dots === 2) {
|
|
1996
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
1997
|
-
if (res.length > 2) {
|
|
1998
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
1999
|
-
if (lastSlashIndex === -1) {
|
|
2000
|
-
res = "";
|
|
2001
|
-
lastSegmentLength = 0;
|
|
2002
|
-
} else {
|
|
2003
|
-
res = res.slice(0, lastSlashIndex);
|
|
2004
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
2005
|
-
}
|
|
2006
|
-
lastSlash = index2;
|
|
2007
|
-
dots = 0;
|
|
2008
|
-
continue;
|
|
2009
|
-
} else if (res.length > 0) {
|
|
2010
|
-
res = "";
|
|
2011
|
-
lastSegmentLength = 0;
|
|
2012
|
-
lastSlash = index2;
|
|
2013
|
-
dots = 0;
|
|
2014
|
-
continue;
|
|
2015
|
-
}
|
|
2016
|
-
}
|
|
2017
|
-
if (allowAboveRoot) {
|
|
2018
|
-
res += res.length > 0 ? "/.." : "..";
|
|
2019
|
-
lastSegmentLength = 2;
|
|
2020
|
-
}
|
|
2021
|
-
} else {
|
|
2022
|
-
if (res.length > 0) {
|
|
2023
|
-
res += `/${path.slice(lastSlash + 1, index2)}`;
|
|
2024
|
-
} else {
|
|
2025
|
-
res = path.slice(lastSlash + 1, index2);
|
|
2026
|
-
}
|
|
2027
|
-
lastSegmentLength = index2 - lastSlash - 1;
|
|
2028
|
-
}
|
|
2029
|
-
lastSlash = index2;
|
|
2030
|
-
dots = 0;
|
|
2031
|
-
} else if (char === "." && dots !== -1) {
|
|
2032
|
-
++dots;
|
|
2033
|
-
} else {
|
|
2034
|
-
dots = -1;
|
|
2035
|
-
}
|
|
2036
|
-
}
|
|
2037
|
-
return res;
|
|
2038
|
-
}
|
|
2039
|
-
const isAbsolute = function(p2) {
|
|
2040
|
-
return _IS_ABSOLUTE_RE.test(p2);
|
|
2041
|
-
};
|
|
2042
|
-
const extname = function(p2) {
|
|
2043
|
-
if (p2 === "..") return "";
|
|
2044
|
-
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p2));
|
|
2045
|
-
return match && match[1] || "";
|
|
2046
|
-
};
|
|
2047
|
-
var f = {
|
|
2048
|
-
reset: [0, 0],
|
|
2049
|
-
bold: [1, 22, "\x1B[22m\x1B[1m"],
|
|
2050
|
-
dim: [2, 22, "\x1B[22m\x1B[2m"],
|
|
2051
|
-
italic: [3, 23],
|
|
2052
|
-
underline: [4, 24],
|
|
2053
|
-
inverse: [7, 27],
|
|
2054
|
-
hidden: [8, 28],
|
|
2055
|
-
strikethrough: [9, 29],
|
|
2056
|
-
black: [30, 39],
|
|
2057
|
-
red: [31, 39],
|
|
2058
|
-
green: [32, 39],
|
|
2059
|
-
yellow: [33, 39],
|
|
2060
|
-
blue: [34, 39],
|
|
2061
|
-
magenta: [35, 39],
|
|
2062
|
-
cyan: [36, 39],
|
|
2063
|
-
white: [37, 39],
|
|
2064
|
-
gray: [90, 39],
|
|
2065
|
-
bgBlack: [40, 49],
|
|
2066
|
-
bgRed: [41, 49],
|
|
2067
|
-
bgGreen: [42, 49],
|
|
2068
|
-
bgYellow: [43, 49],
|
|
2069
|
-
bgBlue: [44, 49],
|
|
2070
|
-
bgMagenta: [45, 49],
|
|
2071
|
-
bgCyan: [46, 49],
|
|
2072
|
-
bgWhite: [47, 49],
|
|
2073
|
-
blackBright: [90, 39],
|
|
2074
|
-
redBright: [91, 39],
|
|
2075
|
-
greenBright: [92, 39],
|
|
2076
|
-
yellowBright: [93, 39],
|
|
2077
|
-
blueBright: [94, 39],
|
|
2078
|
-
magentaBright: [95, 39],
|
|
2079
|
-
cyanBright: [96, 39],
|
|
2080
|
-
whiteBright: [97, 39],
|
|
2081
|
-
bgBlackBright: [100, 49],
|
|
2082
|
-
bgRedBright: [101, 49],
|
|
2083
|
-
bgGreenBright: [102, 49],
|
|
2084
|
-
bgYellowBright: [103, 49],
|
|
2085
|
-
bgBlueBright: [104, 49],
|
|
2086
|
-
bgMagentaBright: [105, 49],
|
|
2087
|
-
bgCyanBright: [106, 49],
|
|
2088
|
-
bgWhiteBright: [107, 49]
|
|
2089
|
-
}, h = Object.entries(f);
|
|
2090
|
-
function a(n) {
|
|
2091
|
-
return String(n);
|
|
2092
|
-
}
|
|
2093
|
-
a.open = "";
|
|
2094
|
-
a.close = "";
|
|
2095
|
-
function C(n = false) {
|
|
2096
|
-
let e = typeof process != "undefined" ? process : void 0, i = (e == null ? void 0 : e.env) || {}, g = (e == null ? void 0 : e.argv) || [];
|
|
2097
|
-
return !("NO_COLOR" in i || g.includes("--no-color")) && ("FORCE_COLOR" in i || g.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || n && i.TERM !== "dumb" || "CI" in i) || typeof window != "undefined" && !!window.chrome;
|
|
2098
|
-
}
|
|
2099
|
-
function p(n = false) {
|
|
2100
|
-
let e = C(n), i = (r, t, c, o) => {
|
|
2101
|
-
let l = "", s = 0;
|
|
2102
|
-
do
|
|
2103
|
-
l += r.substring(s, o) + c, s = o + t.length, o = r.indexOf(t, s);
|
|
2104
|
-
while (~o);
|
|
2105
|
-
return l + r.substring(s);
|
|
2106
|
-
}, g = (r, t, c = r) => {
|
|
2107
|
-
let o = (l) => {
|
|
2108
|
-
let s = String(l), b = s.indexOf(t, r.length);
|
|
2109
|
-
return ~b ? r + i(s, t, c, b) + t : r + s + t;
|
|
2110
|
-
};
|
|
2111
|
-
return o.open = r, o.close = t, o;
|
|
2112
|
-
}, u = {
|
|
2113
|
-
isColorSupported: e
|
|
2114
|
-
}, d = (r) => `\x1B[${r}m`;
|
|
2115
|
-
for (let [r, t] of h)
|
|
2116
|
-
u[r] = e ? g(
|
|
2117
|
-
d(t[0]),
|
|
2118
|
-
d(t[1]),
|
|
2119
|
-
t[2]
|
|
2120
|
-
) : a;
|
|
2121
|
-
return u;
|
|
2122
|
-
}
|
|
2123
|
-
p();
|
|
2124
|
-
function _mergeNamespaces(n, m) {
|
|
2125
|
-
m.forEach(function(e) {
|
|
2126
|
-
e && typeof e !== "string" && !Array.isArray(e) && Object.keys(e).forEach(function(k) {
|
|
2127
|
-
if (k !== "default" && !(k in n)) {
|
|
2128
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
2129
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
2130
|
-
enumerable: true,
|
|
2131
|
-
get: function() {
|
|
2132
|
-
return e[k];
|
|
2133
|
-
}
|
|
2134
|
-
});
|
|
2135
|
-
}
|
|
2136
|
-
});
|
|
2137
|
-
});
|
|
2138
|
-
return Object.freeze(n);
|
|
2139
|
-
}
|
|
2140
|
-
function getDefaultExportFromCjs(x) {
|
|
2141
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
2142
|
-
}
|
|
2143
|
-
var reactIs$1 = { exports: {} };
|
|
2144
|
-
var reactIs_production = {};
|
|
2145
|
-
/**
|
|
2146
|
-
* @license React
|
|
2147
|
-
* react-is.production.js
|
|
2148
|
-
*
|
|
2149
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2150
|
-
*
|
|
2151
|
-
* This source code is licensed under the MIT license found in the
|
|
2152
|
-
* LICENSE file in the root directory of this source tree.
|
|
2153
|
-
*/
|
|
2154
|
-
var hasRequiredReactIs_production;
|
|
2155
|
-
function requireReactIs_production() {
|
|
2156
|
-
if (hasRequiredReactIs_production) return reactIs_production;
|
|
2157
|
-
hasRequiredReactIs_production = 1;
|
|
2158
|
-
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
|
2159
|
-
var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference");
|
|
2160
|
-
function typeOf(object2) {
|
|
2161
|
-
if ("object" === typeof object2 && null !== object2) {
|
|
2162
|
-
var $$typeof = object2.$$typeof;
|
|
2163
|
-
switch ($$typeof) {
|
|
2164
|
-
case REACT_ELEMENT_TYPE:
|
|
2165
|
-
switch (object2 = object2.type, object2) {
|
|
2166
|
-
case REACT_FRAGMENT_TYPE:
|
|
2167
|
-
case REACT_PROFILER_TYPE:
|
|
2168
|
-
case REACT_STRICT_MODE_TYPE:
|
|
2169
|
-
case REACT_SUSPENSE_TYPE:
|
|
2170
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
|
2171
|
-
case REACT_VIEW_TRANSITION_TYPE:
|
|
2172
|
-
return object2;
|
|
2173
|
-
default:
|
|
2174
|
-
switch (object2 = object2 && object2.$$typeof, object2) {
|
|
2175
|
-
case REACT_CONTEXT_TYPE:
|
|
2176
|
-
case REACT_FORWARD_REF_TYPE:
|
|
2177
|
-
case REACT_LAZY_TYPE:
|
|
2178
|
-
case REACT_MEMO_TYPE:
|
|
2179
|
-
return object2;
|
|
2180
|
-
case REACT_CONSUMER_TYPE:
|
|
2181
|
-
return object2;
|
|
2182
|
-
default:
|
|
2183
|
-
return $$typeof;
|
|
2184
|
-
}
|
|
2185
|
-
}
|
|
2186
|
-
case REACT_PORTAL_TYPE:
|
|
2187
|
-
return $$typeof;
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
|
-
}
|
|
2191
|
-
reactIs_production.ContextConsumer = REACT_CONSUMER_TYPE;
|
|
2192
|
-
reactIs_production.ContextProvider = REACT_CONTEXT_TYPE;
|
|
2193
|
-
reactIs_production.Element = REACT_ELEMENT_TYPE;
|
|
2194
|
-
reactIs_production.ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
2195
|
-
reactIs_production.Fragment = REACT_FRAGMENT_TYPE;
|
|
2196
|
-
reactIs_production.Lazy = REACT_LAZY_TYPE;
|
|
2197
|
-
reactIs_production.Memo = REACT_MEMO_TYPE;
|
|
2198
|
-
reactIs_production.Portal = REACT_PORTAL_TYPE;
|
|
2199
|
-
reactIs_production.Profiler = REACT_PROFILER_TYPE;
|
|
2200
|
-
reactIs_production.StrictMode = REACT_STRICT_MODE_TYPE;
|
|
2201
|
-
reactIs_production.Suspense = REACT_SUSPENSE_TYPE;
|
|
2202
|
-
reactIs_production.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
|
|
2203
|
-
reactIs_production.isContextConsumer = function(object2) {
|
|
2204
|
-
return typeOf(object2) === REACT_CONSUMER_TYPE;
|
|
2205
|
-
};
|
|
2206
|
-
reactIs_production.isContextProvider = function(object2) {
|
|
2207
|
-
return typeOf(object2) === REACT_CONTEXT_TYPE;
|
|
2208
|
-
};
|
|
2209
|
-
reactIs_production.isElement = function(object2) {
|
|
2210
|
-
return "object" === typeof object2 && null !== object2 && object2.$$typeof === REACT_ELEMENT_TYPE;
|
|
2211
|
-
};
|
|
2212
|
-
reactIs_production.isForwardRef = function(object2) {
|
|
2213
|
-
return typeOf(object2) === REACT_FORWARD_REF_TYPE;
|
|
2214
|
-
};
|
|
2215
|
-
reactIs_production.isFragment = function(object2) {
|
|
2216
|
-
return typeOf(object2) === REACT_FRAGMENT_TYPE;
|
|
2217
|
-
};
|
|
2218
|
-
reactIs_production.isLazy = function(object2) {
|
|
2219
|
-
return typeOf(object2) === REACT_LAZY_TYPE;
|
|
2220
|
-
};
|
|
2221
|
-
reactIs_production.isMemo = function(object2) {
|
|
2222
|
-
return typeOf(object2) === REACT_MEMO_TYPE;
|
|
2223
|
-
};
|
|
2224
|
-
reactIs_production.isPortal = function(object2) {
|
|
2225
|
-
return typeOf(object2) === REACT_PORTAL_TYPE;
|
|
2226
|
-
};
|
|
2227
|
-
reactIs_production.isProfiler = function(object2) {
|
|
2228
|
-
return typeOf(object2) === REACT_PROFILER_TYPE;
|
|
2229
|
-
};
|
|
2230
|
-
reactIs_production.isStrictMode = function(object2) {
|
|
2231
|
-
return typeOf(object2) === REACT_STRICT_MODE_TYPE;
|
|
2232
|
-
};
|
|
2233
|
-
reactIs_production.isSuspense = function(object2) {
|
|
2234
|
-
return typeOf(object2) === REACT_SUSPENSE_TYPE;
|
|
2235
|
-
};
|
|
2236
|
-
reactIs_production.isSuspenseList = function(object2) {
|
|
2237
|
-
return typeOf(object2) === REACT_SUSPENSE_LIST_TYPE;
|
|
2238
|
-
};
|
|
2239
|
-
reactIs_production.isValidElementType = function(type) {
|
|
2240
|
-
return "string" === typeof type || "function" === typeof type || type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || "object" === typeof type && null !== type && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_CONSUMER_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_CLIENT_REFERENCE || void 0 !== type.getModuleId) ? true : false;
|
|
2241
|
-
};
|
|
2242
|
-
reactIs_production.typeOf = typeOf;
|
|
2243
|
-
return reactIs_production;
|
|
2244
|
-
}
|
|
2245
|
-
var hasRequiredReactIs$1;
|
|
2246
|
-
function requireReactIs$1() {
|
|
2247
|
-
if (hasRequiredReactIs$1) return reactIs$1.exports;
|
|
2248
|
-
hasRequiredReactIs$1 = 1;
|
|
2249
|
-
{
|
|
2250
|
-
reactIs$1.exports = requireReactIs_production();
|
|
2251
|
-
}
|
|
2252
|
-
return reactIs$1.exports;
|
|
2253
|
-
}
|
|
2254
|
-
var reactIsExports$1 = requireReactIs$1();
|
|
2255
|
-
var index$1 = /* @__PURE__ */ getDefaultExportFromCjs(reactIsExports$1);
|
|
2256
|
-
var ReactIs19 = /* @__PURE__ */ _mergeNamespaces({
|
|
2257
|
-
__proto__: null,
|
|
2258
|
-
default: index$1
|
|
2259
|
-
}, [reactIsExports$1]);
|
|
2260
|
-
var reactIs = { exports: {} };
|
|
2261
|
-
var reactIs_production_min = {};
|
|
2262
|
-
/**
|
|
2263
|
-
* @license React
|
|
2264
|
-
* react-is.production.min.js
|
|
2265
|
-
*
|
|
2266
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
2267
|
-
*
|
|
2268
|
-
* This source code is licensed under the MIT license found in the
|
|
2269
|
-
* LICENSE file in the root directory of this source tree.
|
|
2270
|
-
*/
|
|
2271
|
-
var hasRequiredReactIs_production_min;
|
|
2272
|
-
function requireReactIs_production_min() {
|
|
2273
|
-
if (hasRequiredReactIs_production_min) return reactIs_production_min;
|
|
2274
|
-
hasRequiredReactIs_production_min = 1;
|
|
2275
|
-
var b = Symbol.for("react.element"), c = Symbol.for("react.portal"), d = Symbol.for("react.fragment"), e = Symbol.for("react.strict_mode"), f2 = Symbol.for("react.profiler"), g = Symbol.for("react.provider"), h2 = Symbol.for("react.context"), k = Symbol.for("react.server_context"), l = Symbol.for("react.forward_ref"), m = Symbol.for("react.suspense"), n = Symbol.for("react.suspense_list"), p2 = Symbol.for("react.memo"), q = Symbol.for("react.lazy"), t = Symbol.for("react.offscreen"), u;
|
|
2276
|
-
u = Symbol.for("react.module.reference");
|
|
2277
|
-
function v(a2) {
|
|
2278
|
-
if ("object" === typeof a2 && null !== a2) {
|
|
2279
|
-
var r = a2.$$typeof;
|
|
2280
|
-
switch (r) {
|
|
2281
|
-
case b:
|
|
2282
|
-
switch (a2 = a2.type, a2) {
|
|
2283
|
-
case d:
|
|
2284
|
-
case f2:
|
|
2285
|
-
case e:
|
|
2286
|
-
case m:
|
|
2287
|
-
case n:
|
|
2288
|
-
return a2;
|
|
2289
|
-
default:
|
|
2290
|
-
switch (a2 = a2 && a2.$$typeof, a2) {
|
|
2291
|
-
case k:
|
|
2292
|
-
case h2:
|
|
2293
|
-
case l:
|
|
2294
|
-
case q:
|
|
2295
|
-
case p2:
|
|
2296
|
-
case g:
|
|
2297
|
-
return a2;
|
|
2298
|
-
default:
|
|
2299
|
-
return r;
|
|
2300
|
-
}
|
|
2301
|
-
}
|
|
2302
|
-
case c:
|
|
2303
|
-
return r;
|
|
2304
|
-
}
|
|
2305
|
-
}
|
|
2306
|
-
}
|
|
2307
|
-
reactIs_production_min.ContextConsumer = h2;
|
|
2308
|
-
reactIs_production_min.ContextProvider = g;
|
|
2309
|
-
reactIs_production_min.Element = b;
|
|
2310
|
-
reactIs_production_min.ForwardRef = l;
|
|
2311
|
-
reactIs_production_min.Fragment = d;
|
|
2312
|
-
reactIs_production_min.Lazy = q;
|
|
2313
|
-
reactIs_production_min.Memo = p2;
|
|
2314
|
-
reactIs_production_min.Portal = c;
|
|
2315
|
-
reactIs_production_min.Profiler = f2;
|
|
2316
|
-
reactIs_production_min.StrictMode = e;
|
|
2317
|
-
reactIs_production_min.Suspense = m;
|
|
2318
|
-
reactIs_production_min.SuspenseList = n;
|
|
2319
|
-
reactIs_production_min.isAsyncMode = function() {
|
|
2320
|
-
return false;
|
|
2321
|
-
};
|
|
2322
|
-
reactIs_production_min.isConcurrentMode = function() {
|
|
2323
|
-
return false;
|
|
2324
|
-
};
|
|
2325
|
-
reactIs_production_min.isContextConsumer = function(a2) {
|
|
2326
|
-
return v(a2) === h2;
|
|
2327
|
-
};
|
|
2328
|
-
reactIs_production_min.isContextProvider = function(a2) {
|
|
2329
|
-
return v(a2) === g;
|
|
2330
|
-
};
|
|
2331
|
-
reactIs_production_min.isElement = function(a2) {
|
|
2332
|
-
return "object" === typeof a2 && null !== a2 && a2.$$typeof === b;
|
|
2333
|
-
};
|
|
2334
|
-
reactIs_production_min.isForwardRef = function(a2) {
|
|
2335
|
-
return v(a2) === l;
|
|
2336
|
-
};
|
|
2337
|
-
reactIs_production_min.isFragment = function(a2) {
|
|
2338
|
-
return v(a2) === d;
|
|
2339
|
-
};
|
|
2340
|
-
reactIs_production_min.isLazy = function(a2) {
|
|
2341
|
-
return v(a2) === q;
|
|
2342
|
-
};
|
|
2343
|
-
reactIs_production_min.isMemo = function(a2) {
|
|
2344
|
-
return v(a2) === p2;
|
|
2345
|
-
};
|
|
2346
|
-
reactIs_production_min.isPortal = function(a2) {
|
|
2347
|
-
return v(a2) === c;
|
|
2348
|
-
};
|
|
2349
|
-
reactIs_production_min.isProfiler = function(a2) {
|
|
2350
|
-
return v(a2) === f2;
|
|
2351
|
-
};
|
|
2352
|
-
reactIs_production_min.isStrictMode = function(a2) {
|
|
2353
|
-
return v(a2) === e;
|
|
2354
|
-
};
|
|
2355
|
-
reactIs_production_min.isSuspense = function(a2) {
|
|
2356
|
-
return v(a2) === m;
|
|
2357
|
-
};
|
|
2358
|
-
reactIs_production_min.isSuspenseList = function(a2) {
|
|
2359
|
-
return v(a2) === n;
|
|
2360
|
-
};
|
|
2361
|
-
reactIs_production_min.isValidElementType = function(a2) {
|
|
2362
|
-
return "string" === typeof a2 || "function" === typeof a2 || a2 === d || a2 === f2 || a2 === e || a2 === m || a2 === n || a2 === t || "object" === typeof a2 && null !== a2 && (a2.$$typeof === q || a2.$$typeof === p2 || a2.$$typeof === g || a2.$$typeof === h2 || a2.$$typeof === l || a2.$$typeof === u || void 0 !== a2.getModuleId) ? true : false;
|
|
2363
|
-
};
|
|
2364
|
-
reactIs_production_min.typeOf = v;
|
|
2365
|
-
return reactIs_production_min;
|
|
2366
|
-
}
|
|
2367
|
-
var hasRequiredReactIs;
|
|
2368
|
-
function requireReactIs() {
|
|
2369
|
-
if (hasRequiredReactIs) return reactIs.exports;
|
|
2370
|
-
hasRequiredReactIs = 1;
|
|
2371
|
-
{
|
|
2372
|
-
reactIs.exports = requireReactIs_production_min();
|
|
2373
|
-
}
|
|
2374
|
-
return reactIs.exports;
|
|
2375
|
-
}
|
|
2376
|
-
var reactIsExports = requireReactIs();
|
|
2377
|
-
var index = /* @__PURE__ */ getDefaultExportFromCjs(reactIsExports);
|
|
2378
|
-
var ReactIs18 = /* @__PURE__ */ _mergeNamespaces({
|
|
2379
|
-
__proto__: null,
|
|
2380
|
-
default: index
|
|
2381
|
-
}, [reactIsExports]);
|
|
2382
|
-
const reactIsMethods = [
|
|
2383
|
-
"isAsyncMode",
|
|
2384
|
-
"isConcurrentMode",
|
|
2385
|
-
"isContextConsumer",
|
|
2386
|
-
"isContextProvider",
|
|
2387
|
-
"isElement",
|
|
2388
|
-
"isForwardRef",
|
|
2389
|
-
"isFragment",
|
|
2390
|
-
"isLazy",
|
|
2391
|
-
"isMemo",
|
|
2392
|
-
"isPortal",
|
|
2393
|
-
"isProfiler",
|
|
2394
|
-
"isStrictMode",
|
|
2395
|
-
"isSuspense",
|
|
2396
|
-
"isSuspenseList",
|
|
2397
|
-
"isValidElementType"
|
|
2398
|
-
];
|
|
2399
|
-
Object.fromEntries(reactIsMethods.map((m) => [m, (v) => ReactIs18[m](v) || ReactIs19[m](v)]));
|
|
2400
|
-
var jsTokens_1;
|
|
2401
|
-
var hasRequiredJsTokens;
|
|
2402
|
-
function requireJsTokens() {
|
|
2403
|
-
if (hasRequiredJsTokens) return jsTokens_1;
|
|
2404
|
-
hasRequiredJsTokens = 1;
|
|
2405
|
-
var Identifier, JSXIdentifier, JSXPunctuator, JSXString, JSXText, KeywordsWithExpressionAfter, KeywordsWithNoLineTerminatorAfter, LineTerminatorSequence, MultiLineComment, Newline, NumericLiteral, Punctuator, RegularExpressionLiteral, SingleLineComment, StringLiteral, Template, TokensNotPrecedingObjectLiteral, TokensPrecedingExpression, WhiteSpace;
|
|
2406
|
-
RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\\]).|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/uy;
|
|
2407
|
-
Punctuator = /--|\+\+|=>|\.{3}|\??\.(?!\d)|(?:&&|\|\||\?\?|[+\-%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\/(?![\/*]))=?|[?~,:;[\](){}]/y;
|
|
2408
|
-
Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/uy;
|
|
2409
|
-
StringLiteral = /(['"])(?:(?!\1)[^\\\n\r]|\\(?:\r\n|[^]))*(\1)?/y;
|
|
2410
|
-
NumericLiteral = /(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|0n|[1-9](?:_?\d)*n|(?:(?:0(?!\d)|0\d*[89]\d*|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?|0[0-7]+/y;
|
|
2411
|
-
Template = /[`}](?:[^`\\$]|\\[^]|\$(?!\{))*(`|\$\{)?/y;
|
|
2412
|
-
WhiteSpace = /[\t\v\f\ufeff\p{Zs}]+/uy;
|
|
2413
|
-
LineTerminatorSequence = /\r?\n|[\r\u2028\u2029]/y;
|
|
2414
|
-
MultiLineComment = /\/\*(?:[^*]|\*(?!\/))*(\*\/)?/y;
|
|
2415
|
-
SingleLineComment = /\/\/.*/y;
|
|
2416
|
-
JSXPunctuator = /[<>.:={}]|\/(?![\/*])/y;
|
|
2417
|
-
JSXIdentifier = /[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}-]*/uy;
|
|
2418
|
-
JSXString = /(['"])(?:(?!\1)[^])*(\1)?/y;
|
|
2419
|
-
JSXText = /[^<>{}]+/y;
|
|
2420
|
-
TokensPrecedingExpression = /^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/;
|
|
2421
|
-
TokensNotPrecedingObjectLiteral = /^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/;
|
|
2422
|
-
KeywordsWithExpressionAfter = /^(?:await|case|default|delete|do|else|instanceof|new|return|throw|typeof|void|yield)$/;
|
|
2423
|
-
KeywordsWithNoLineTerminatorAfter = /^(?:return|throw|yield)$/;
|
|
2424
|
-
Newline = RegExp(LineTerminatorSequence.source);
|
|
2425
|
-
jsTokens_1 = function* (input, { jsx = false } = {}) {
|
|
2426
|
-
var braces, firstCodePoint, isExpression, lastIndex, lastSignificantToken, length, match, mode, nextLastIndex, nextLastSignificantToken, parenNesting, postfixIncDec, punctuator, stack;
|
|
2427
|
-
({ length } = input);
|
|
2428
|
-
lastIndex = 0;
|
|
2429
|
-
lastSignificantToken = "";
|
|
2430
|
-
stack = [{ tag: "JS" }];
|
|
2431
|
-
braces = [];
|
|
2432
|
-
parenNesting = 0;
|
|
2433
|
-
postfixIncDec = false;
|
|
2434
|
-
while (lastIndex < length) {
|
|
2435
|
-
mode = stack[stack.length - 1];
|
|
2436
|
-
switch (mode.tag) {
|
|
2437
|
-
case "JS":
|
|
2438
|
-
case "JSNonExpressionParen":
|
|
2439
|
-
case "InterpolationInTemplate":
|
|
2440
|
-
case "InterpolationInJSX":
|
|
2441
|
-
if (input[lastIndex] === "/" && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
|
|
2442
|
-
RegularExpressionLiteral.lastIndex = lastIndex;
|
|
2443
|
-
if (match = RegularExpressionLiteral.exec(input)) {
|
|
2444
|
-
lastIndex = RegularExpressionLiteral.lastIndex;
|
|
2445
|
-
lastSignificantToken = match[0];
|
|
2446
|
-
postfixIncDec = true;
|
|
2447
|
-
yield {
|
|
2448
|
-
type: "RegularExpressionLiteral",
|
|
2449
|
-
value: match[0],
|
|
2450
|
-
closed: match[1] !== void 0 && match[1] !== "\\"
|
|
2451
|
-
};
|
|
2452
|
-
continue;
|
|
2453
|
-
}
|
|
2454
|
-
}
|
|
2455
|
-
Punctuator.lastIndex = lastIndex;
|
|
2456
|
-
if (match = Punctuator.exec(input)) {
|
|
2457
|
-
punctuator = match[0];
|
|
2458
|
-
nextLastIndex = Punctuator.lastIndex;
|
|
2459
|
-
nextLastSignificantToken = punctuator;
|
|
2460
|
-
switch (punctuator) {
|
|
2461
|
-
case "(":
|
|
2462
|
-
if (lastSignificantToken === "?NonExpressionParenKeyword") {
|
|
2463
|
-
stack.push({
|
|
2464
|
-
tag: "JSNonExpressionParen",
|
|
2465
|
-
nesting: parenNesting
|
|
2466
|
-
});
|
|
2467
|
-
}
|
|
2468
|
-
parenNesting++;
|
|
2469
|
-
postfixIncDec = false;
|
|
2470
|
-
break;
|
|
2471
|
-
case ")":
|
|
2472
|
-
parenNesting--;
|
|
2473
|
-
postfixIncDec = true;
|
|
2474
|
-
if (mode.tag === "JSNonExpressionParen" && parenNesting === mode.nesting) {
|
|
2475
|
-
stack.pop();
|
|
2476
|
-
nextLastSignificantToken = "?NonExpressionParenEnd";
|
|
2477
|
-
postfixIncDec = false;
|
|
2478
|
-
}
|
|
2479
|
-
break;
|
|
2480
|
-
case "{":
|
|
2481
|
-
Punctuator.lastIndex = 0;
|
|
2482
|
-
isExpression = !TokensNotPrecedingObjectLiteral.test(lastSignificantToken) && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken));
|
|
2483
|
-
braces.push(isExpression);
|
|
2484
|
-
postfixIncDec = false;
|
|
2485
|
-
break;
|
|
2486
|
-
case "}":
|
|
2487
|
-
switch (mode.tag) {
|
|
2488
|
-
case "InterpolationInTemplate":
|
|
2489
|
-
if (braces.length === mode.nesting) {
|
|
2490
|
-
Template.lastIndex = lastIndex;
|
|
2491
|
-
match = Template.exec(input);
|
|
2492
|
-
lastIndex = Template.lastIndex;
|
|
2493
|
-
lastSignificantToken = match[0];
|
|
2494
|
-
if (match[1] === "${") {
|
|
2495
|
-
lastSignificantToken = "?InterpolationInTemplate";
|
|
2496
|
-
postfixIncDec = false;
|
|
2497
|
-
yield {
|
|
2498
|
-
type: "TemplateMiddle",
|
|
2499
|
-
value: match[0]
|
|
2500
|
-
};
|
|
2501
|
-
} else {
|
|
2502
|
-
stack.pop();
|
|
2503
|
-
postfixIncDec = true;
|
|
2504
|
-
yield {
|
|
2505
|
-
type: "TemplateTail",
|
|
2506
|
-
value: match[0],
|
|
2507
|
-
closed: match[1] === "`"
|
|
2508
|
-
};
|
|
2509
|
-
}
|
|
2510
|
-
continue;
|
|
2511
|
-
}
|
|
2512
|
-
break;
|
|
2513
|
-
case "InterpolationInJSX":
|
|
2514
|
-
if (braces.length === mode.nesting) {
|
|
2515
|
-
stack.pop();
|
|
2516
|
-
lastIndex += 1;
|
|
2517
|
-
lastSignificantToken = "}";
|
|
2518
|
-
yield {
|
|
2519
|
-
type: "JSXPunctuator",
|
|
2520
|
-
value: "}"
|
|
2521
|
-
};
|
|
2522
|
-
continue;
|
|
2523
|
-
}
|
|
2524
|
-
}
|
|
2525
|
-
postfixIncDec = braces.pop();
|
|
2526
|
-
nextLastSignificantToken = postfixIncDec ? "?ExpressionBraceEnd" : "}";
|
|
2527
|
-
break;
|
|
2528
|
-
case "]":
|
|
2529
|
-
postfixIncDec = true;
|
|
2530
|
-
break;
|
|
2531
|
-
case "++":
|
|
2532
|
-
case "--":
|
|
2533
|
-
nextLastSignificantToken = postfixIncDec ? "?PostfixIncDec" : "?UnaryIncDec";
|
|
2534
|
-
break;
|
|
2535
|
-
case "<":
|
|
2536
|
-
if (jsx && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
|
|
2537
|
-
stack.push({ tag: "JSXTag" });
|
|
2538
|
-
lastIndex += 1;
|
|
2539
|
-
lastSignificantToken = "<";
|
|
2540
|
-
yield {
|
|
2541
|
-
type: "JSXPunctuator",
|
|
2542
|
-
value: punctuator
|
|
2543
|
-
};
|
|
2544
|
-
continue;
|
|
2545
|
-
}
|
|
2546
|
-
postfixIncDec = false;
|
|
2547
|
-
break;
|
|
2548
|
-
default:
|
|
2549
|
-
postfixIncDec = false;
|
|
2550
|
-
}
|
|
2551
|
-
lastIndex = nextLastIndex;
|
|
2552
|
-
lastSignificantToken = nextLastSignificantToken;
|
|
2553
|
-
yield {
|
|
2554
|
-
type: "Punctuator",
|
|
2555
|
-
value: punctuator
|
|
2556
|
-
};
|
|
2557
|
-
continue;
|
|
2558
|
-
}
|
|
2559
|
-
Identifier.lastIndex = lastIndex;
|
|
2560
|
-
if (match = Identifier.exec(input)) {
|
|
2561
|
-
lastIndex = Identifier.lastIndex;
|
|
2562
|
-
nextLastSignificantToken = match[0];
|
|
2563
|
-
switch (match[0]) {
|
|
2564
|
-
case "for":
|
|
2565
|
-
case "if":
|
|
2566
|
-
case "while":
|
|
2567
|
-
case "with":
|
|
2568
|
-
if (lastSignificantToken !== "." && lastSignificantToken !== "?.") {
|
|
2569
|
-
nextLastSignificantToken = "?NonExpressionParenKeyword";
|
|
2570
|
-
}
|
|
2571
|
-
}
|
|
2572
|
-
lastSignificantToken = nextLastSignificantToken;
|
|
2573
|
-
postfixIncDec = !KeywordsWithExpressionAfter.test(match[0]);
|
|
2574
|
-
yield {
|
|
2575
|
-
type: match[1] === "#" ? "PrivateIdentifier" : "IdentifierName",
|
|
2576
|
-
value: match[0]
|
|
2577
|
-
};
|
|
2578
|
-
continue;
|
|
2579
|
-
}
|
|
2580
|
-
StringLiteral.lastIndex = lastIndex;
|
|
2581
|
-
if (match = StringLiteral.exec(input)) {
|
|
2582
|
-
lastIndex = StringLiteral.lastIndex;
|
|
2583
|
-
lastSignificantToken = match[0];
|
|
2584
|
-
postfixIncDec = true;
|
|
2585
|
-
yield {
|
|
2586
|
-
type: "StringLiteral",
|
|
2587
|
-
value: match[0],
|
|
2588
|
-
closed: match[2] !== void 0
|
|
2589
|
-
};
|
|
2590
|
-
continue;
|
|
2591
|
-
}
|
|
2592
|
-
NumericLiteral.lastIndex = lastIndex;
|
|
2593
|
-
if (match = NumericLiteral.exec(input)) {
|
|
2594
|
-
lastIndex = NumericLiteral.lastIndex;
|
|
2595
|
-
lastSignificantToken = match[0];
|
|
2596
|
-
postfixIncDec = true;
|
|
2597
|
-
yield {
|
|
2598
|
-
type: "NumericLiteral",
|
|
2599
|
-
value: match[0]
|
|
2600
|
-
};
|
|
2601
|
-
continue;
|
|
2602
|
-
}
|
|
2603
|
-
Template.lastIndex = lastIndex;
|
|
2604
|
-
if (match = Template.exec(input)) {
|
|
2605
|
-
lastIndex = Template.lastIndex;
|
|
2606
|
-
lastSignificantToken = match[0];
|
|
2607
|
-
if (match[1] === "${") {
|
|
2608
|
-
lastSignificantToken = "?InterpolationInTemplate";
|
|
2609
|
-
stack.push({
|
|
2610
|
-
tag: "InterpolationInTemplate",
|
|
2611
|
-
nesting: braces.length
|
|
2612
|
-
});
|
|
2613
|
-
postfixIncDec = false;
|
|
2614
|
-
yield {
|
|
2615
|
-
type: "TemplateHead",
|
|
2616
|
-
value: match[0]
|
|
2617
|
-
};
|
|
2618
|
-
} else {
|
|
2619
|
-
postfixIncDec = true;
|
|
2620
|
-
yield {
|
|
2621
|
-
type: "NoSubstitutionTemplate",
|
|
2622
|
-
value: match[0],
|
|
2623
|
-
closed: match[1] === "`"
|
|
2624
|
-
};
|
|
2625
|
-
}
|
|
2626
|
-
continue;
|
|
2627
|
-
}
|
|
2628
|
-
break;
|
|
2629
|
-
case "JSXTag":
|
|
2630
|
-
case "JSXTagEnd":
|
|
2631
|
-
JSXPunctuator.lastIndex = lastIndex;
|
|
2632
|
-
if (match = JSXPunctuator.exec(input)) {
|
|
2633
|
-
lastIndex = JSXPunctuator.lastIndex;
|
|
2634
|
-
nextLastSignificantToken = match[0];
|
|
2635
|
-
switch (match[0]) {
|
|
2636
|
-
case "<":
|
|
2637
|
-
stack.push({ tag: "JSXTag" });
|
|
2638
|
-
break;
|
|
2639
|
-
case ">":
|
|
2640
|
-
stack.pop();
|
|
2641
|
-
if (lastSignificantToken === "/" || mode.tag === "JSXTagEnd") {
|
|
2642
|
-
nextLastSignificantToken = "?JSX";
|
|
2643
|
-
postfixIncDec = true;
|
|
2644
|
-
} else {
|
|
2645
|
-
stack.push({ tag: "JSXChildren" });
|
|
2646
|
-
}
|
|
2647
|
-
break;
|
|
2648
|
-
case "{":
|
|
2649
|
-
stack.push({
|
|
2650
|
-
tag: "InterpolationInJSX",
|
|
2651
|
-
nesting: braces.length
|
|
2652
|
-
});
|
|
2653
|
-
nextLastSignificantToken = "?InterpolationInJSX";
|
|
2654
|
-
postfixIncDec = false;
|
|
2655
|
-
break;
|
|
2656
|
-
case "/":
|
|
2657
|
-
if (lastSignificantToken === "<") {
|
|
2658
|
-
stack.pop();
|
|
2659
|
-
if (stack[stack.length - 1].tag === "JSXChildren") {
|
|
2660
|
-
stack.pop();
|
|
2661
|
-
}
|
|
2662
|
-
stack.push({ tag: "JSXTagEnd" });
|
|
2663
|
-
}
|
|
2664
|
-
}
|
|
2665
|
-
lastSignificantToken = nextLastSignificantToken;
|
|
2666
|
-
yield {
|
|
2667
|
-
type: "JSXPunctuator",
|
|
2668
|
-
value: match[0]
|
|
2669
|
-
};
|
|
2670
|
-
continue;
|
|
2671
|
-
}
|
|
2672
|
-
JSXIdentifier.lastIndex = lastIndex;
|
|
2673
|
-
if (match = JSXIdentifier.exec(input)) {
|
|
2674
|
-
lastIndex = JSXIdentifier.lastIndex;
|
|
2675
|
-
lastSignificantToken = match[0];
|
|
2676
|
-
yield {
|
|
2677
|
-
type: "JSXIdentifier",
|
|
2678
|
-
value: match[0]
|
|
2679
|
-
};
|
|
2680
|
-
continue;
|
|
2681
|
-
}
|
|
2682
|
-
JSXString.lastIndex = lastIndex;
|
|
2683
|
-
if (match = JSXString.exec(input)) {
|
|
2684
|
-
lastIndex = JSXString.lastIndex;
|
|
2685
|
-
lastSignificantToken = match[0];
|
|
2686
|
-
yield {
|
|
2687
|
-
type: "JSXString",
|
|
2688
|
-
value: match[0],
|
|
2689
|
-
closed: match[2] !== void 0
|
|
2690
|
-
};
|
|
2691
|
-
continue;
|
|
2692
|
-
}
|
|
2693
|
-
break;
|
|
2694
|
-
case "JSXChildren":
|
|
2695
|
-
JSXText.lastIndex = lastIndex;
|
|
2696
|
-
if (match = JSXText.exec(input)) {
|
|
2697
|
-
lastIndex = JSXText.lastIndex;
|
|
2698
|
-
lastSignificantToken = match[0];
|
|
2699
|
-
yield {
|
|
2700
|
-
type: "JSXText",
|
|
2701
|
-
value: match[0]
|
|
2702
|
-
};
|
|
2703
|
-
continue;
|
|
2704
|
-
}
|
|
2705
|
-
switch (input[lastIndex]) {
|
|
2706
|
-
case "<":
|
|
2707
|
-
stack.push({ tag: "JSXTag" });
|
|
2708
|
-
lastIndex++;
|
|
2709
|
-
lastSignificantToken = "<";
|
|
2710
|
-
yield {
|
|
2711
|
-
type: "JSXPunctuator",
|
|
2712
|
-
value: "<"
|
|
2713
|
-
};
|
|
2714
|
-
continue;
|
|
2715
|
-
case "{":
|
|
2716
|
-
stack.push({
|
|
2717
|
-
tag: "InterpolationInJSX",
|
|
2718
|
-
nesting: braces.length
|
|
2719
|
-
});
|
|
2720
|
-
lastIndex++;
|
|
2721
|
-
lastSignificantToken = "?InterpolationInJSX";
|
|
2722
|
-
postfixIncDec = false;
|
|
2723
|
-
yield {
|
|
2724
|
-
type: "JSXPunctuator",
|
|
2725
|
-
value: "{"
|
|
2726
|
-
};
|
|
2727
|
-
continue;
|
|
2728
|
-
}
|
|
2729
|
-
}
|
|
2730
|
-
WhiteSpace.lastIndex = lastIndex;
|
|
2731
|
-
if (match = WhiteSpace.exec(input)) {
|
|
2732
|
-
lastIndex = WhiteSpace.lastIndex;
|
|
2733
|
-
yield {
|
|
2734
|
-
type: "WhiteSpace",
|
|
2735
|
-
value: match[0]
|
|
2736
|
-
};
|
|
2737
|
-
continue;
|
|
2738
|
-
}
|
|
2739
|
-
LineTerminatorSequence.lastIndex = lastIndex;
|
|
2740
|
-
if (match = LineTerminatorSequence.exec(input)) {
|
|
2741
|
-
lastIndex = LineTerminatorSequence.lastIndex;
|
|
2742
|
-
postfixIncDec = false;
|
|
2743
|
-
if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) {
|
|
2744
|
-
lastSignificantToken = "?NoLineTerminatorHere";
|
|
2745
|
-
}
|
|
2746
|
-
yield {
|
|
2747
|
-
type: "LineTerminatorSequence",
|
|
2748
|
-
value: match[0]
|
|
2749
|
-
};
|
|
2750
|
-
continue;
|
|
2751
|
-
}
|
|
2752
|
-
MultiLineComment.lastIndex = lastIndex;
|
|
2753
|
-
if (match = MultiLineComment.exec(input)) {
|
|
2754
|
-
lastIndex = MultiLineComment.lastIndex;
|
|
2755
|
-
if (Newline.test(match[0])) {
|
|
2756
|
-
postfixIncDec = false;
|
|
2757
|
-
if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) {
|
|
2758
|
-
lastSignificantToken = "?NoLineTerminatorHere";
|
|
2759
|
-
}
|
|
2760
|
-
}
|
|
2761
|
-
yield {
|
|
2762
|
-
type: "MultiLineComment",
|
|
2763
|
-
value: match[0],
|
|
2764
|
-
closed: match[1] !== void 0
|
|
2765
|
-
};
|
|
2766
|
-
continue;
|
|
2767
|
-
}
|
|
2768
|
-
SingleLineComment.lastIndex = lastIndex;
|
|
2769
|
-
if (match = SingleLineComment.exec(input)) {
|
|
2770
|
-
lastIndex = SingleLineComment.lastIndex;
|
|
2771
|
-
postfixIncDec = false;
|
|
2772
|
-
yield {
|
|
2773
|
-
type: "SingleLineComment",
|
|
2774
|
-
value: match[0]
|
|
2775
|
-
};
|
|
2776
|
-
continue;
|
|
2777
|
-
}
|
|
2778
|
-
firstCodePoint = String.fromCodePoint(input.codePointAt(lastIndex));
|
|
2779
|
-
lastIndex += firstCodePoint.length;
|
|
2780
|
-
lastSignificantToken = firstCodePoint;
|
|
2781
|
-
postfixIncDec = false;
|
|
2782
|
-
yield {
|
|
2783
|
-
type: mode.tag.startsWith("JSX") ? "JSXInvalid" : "Invalid",
|
|
2784
|
-
value: firstCodePoint
|
|
2785
|
-
};
|
|
2786
|
-
}
|
|
2787
|
-
return void 0;
|
|
2788
|
-
};
|
|
2789
|
-
return jsTokens_1;
|
|
2790
|
-
}
|
|
2791
|
-
requireJsTokens();
|
|
2792
|
-
var reservedWords = {
|
|
2793
|
-
keyword: [
|
|
2794
|
-
"break",
|
|
2795
|
-
"case",
|
|
2796
|
-
"catch",
|
|
2797
|
-
"continue",
|
|
2798
|
-
"debugger",
|
|
2799
|
-
"default",
|
|
2800
|
-
"do",
|
|
2801
|
-
"else",
|
|
2802
|
-
"finally",
|
|
2803
|
-
"for",
|
|
2804
|
-
"function",
|
|
2805
|
-
"if",
|
|
2806
|
-
"return",
|
|
2807
|
-
"switch",
|
|
2808
|
-
"throw",
|
|
2809
|
-
"try",
|
|
2810
|
-
"var",
|
|
2811
|
-
"const",
|
|
2812
|
-
"while",
|
|
2813
|
-
"with",
|
|
2814
|
-
"new",
|
|
2815
|
-
"this",
|
|
2816
|
-
"super",
|
|
2817
|
-
"class",
|
|
2818
|
-
"extends",
|
|
2819
|
-
"export",
|
|
2820
|
-
"import",
|
|
2821
|
-
"null",
|
|
2822
|
-
"true",
|
|
2823
|
-
"false",
|
|
2824
|
-
"in",
|
|
2825
|
-
"instanceof",
|
|
2826
|
-
"typeof",
|
|
2827
|
-
"void",
|
|
2828
|
-
"delete"
|
|
2829
|
-
],
|
|
2830
|
-
strict: [
|
|
2831
|
-
"implements",
|
|
2832
|
-
"interface",
|
|
2833
|
-
"let",
|
|
2834
|
-
"package",
|
|
2835
|
-
"private",
|
|
2836
|
-
"protected",
|
|
2837
|
-
"public",
|
|
2838
|
-
"static",
|
|
2839
|
-
"yield"
|
|
2840
|
-
]
|
|
2841
|
-
};
|
|
2842
|
-
new Set(reservedWords.keyword);
|
|
2843
|
-
new Set(reservedWords.strict);
|
|
2844
|
-
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
2845
|
-
const intToChar = new Uint8Array(64);
|
|
2846
|
-
const charToInt = new Uint8Array(128);
|
|
2847
|
-
for (let i = 0; i < chars.length; i++) {
|
|
2848
|
-
const c = chars.charCodeAt(i);
|
|
2849
|
-
intToChar[i] = c;
|
|
2850
|
-
charToInt[c] = i;
|
|
2851
|
-
}
|
|
2852
|
-
var UrlType;
|
|
2853
|
-
(function(UrlType2) {
|
|
2854
|
-
UrlType2[UrlType2["Empty"] = 1] = "Empty";
|
|
2855
|
-
UrlType2[UrlType2["Hash"] = 2] = "Hash";
|
|
2856
|
-
UrlType2[UrlType2["Query"] = 3] = "Query";
|
|
2857
|
-
UrlType2[UrlType2["RelativePath"] = 4] = "RelativePath";
|
|
2858
|
-
UrlType2[UrlType2["AbsolutePath"] = 5] = "AbsolutePath";
|
|
2859
|
-
UrlType2[UrlType2["SchemeRelative"] = 6] = "SchemeRelative";
|
|
2860
|
-
UrlType2[UrlType2["Absolute"] = 7] = "Absolute";
|
|
2861
|
-
})(UrlType || (UrlType = {}));
|
|
2862
|
-
const { now } = Date;
|
|
2863
|
-
class ModuleMocker {
|
|
2864
|
-
constructor(interceptor, rpc2, createMockInstance, config) {
|
|
2865
|
-
__publicField(this, "registry", new MockerRegistry());
|
|
2866
|
-
__publicField(this, "queue", /* @__PURE__ */ new Set());
|
|
2867
|
-
__publicField(this, "mockedIds", /* @__PURE__ */ new Set());
|
|
2868
|
-
this.interceptor = interceptor;
|
|
2869
|
-
this.rpc = rpc2;
|
|
2870
|
-
this.createMockInstance = createMockInstance;
|
|
2871
|
-
this.config = config;
|
|
2872
|
-
}
|
|
2873
|
-
async prepare() {
|
|
2874
|
-
if (!this.queue.size) {
|
|
2875
|
-
return;
|
|
2876
|
-
}
|
|
2877
|
-
await Promise.all([...this.queue.values()]);
|
|
2878
|
-
}
|
|
2879
|
-
async resolveFactoryModule(id) {
|
|
2880
|
-
const mock = this.registry.get(id);
|
|
2881
|
-
if (!mock || mock.type !== "manual") {
|
|
2882
|
-
throw new Error(`Mock ${id} wasn't registered. This is probably a Vitest error. Please, open a new issue with reproduction.`);
|
|
2883
|
-
}
|
|
2884
|
-
const result = await mock.resolve();
|
|
2885
|
-
return result;
|
|
2886
|
-
}
|
|
2887
|
-
getFactoryModule(id) {
|
|
2888
|
-
const mock = this.registry.get(id);
|
|
2889
|
-
if (!mock || mock.type !== "manual") {
|
|
2890
|
-
throw new Error(`Mock ${id} wasn't registered. This is probably a Vitest error. Please, open a new issue with reproduction.`);
|
|
2891
|
-
}
|
|
2892
|
-
if (!mock.cache) {
|
|
2893
|
-
throw new Error(`Mock ${id} wasn't resolved. This is probably a Vitest error. Please, open a new issue with reproduction.`);
|
|
2894
|
-
}
|
|
2895
|
-
return mock.cache;
|
|
2896
|
-
}
|
|
2897
|
-
async invalidate() {
|
|
2898
|
-
const ids = Array.from(this.mockedIds);
|
|
2899
|
-
if (!ids.length) {
|
|
2900
|
-
return;
|
|
2901
|
-
}
|
|
2902
|
-
await this.rpc.invalidate(ids);
|
|
2903
|
-
await this.interceptor.invalidate();
|
|
2904
|
-
this.registry.clear();
|
|
2905
|
-
}
|
|
2906
|
-
async importActual(id, importer) {
|
|
2907
|
-
const resolved = await this.rpc.resolveId(id, importer);
|
|
2908
|
-
if (resolved == null) {
|
|
2909
|
-
throw new Error(`[vitest] Cannot resolve "${id}" imported from "${importer}"`);
|
|
2910
|
-
}
|
|
2911
|
-
const ext = extname(resolved.id);
|
|
2912
|
-
const url2 = new URL(resolved.url, location.href);
|
|
2913
|
-
const query = `_vitest_original&ext${ext}`;
|
|
2914
|
-
const actualUrl = `${url2.pathname}${url2.search ? `${url2.search}&${query}` : `?${query}`}${url2.hash}`;
|
|
2915
|
-
return this.wrapDynamicImport(() => import(
|
|
2916
|
-
/* @vite-ignore */
|
|
2917
|
-
actualUrl
|
|
2918
|
-
)).then((mod) => {
|
|
2919
|
-
if (!resolved.optimized || typeof mod.default === "undefined") {
|
|
2920
|
-
return mod;
|
|
2921
|
-
}
|
|
2922
|
-
const m = mod.default;
|
|
2923
|
-
return (m === null || m === void 0 ? void 0 : m.__esModule) ? m : {
|
|
2924
|
-
...typeof m === "object" && !Array.isArray(m) || typeof m === "function" ? m : {},
|
|
2925
|
-
default: m
|
|
2926
|
-
};
|
|
2927
|
-
});
|
|
2928
|
-
}
|
|
2929
|
-
async importMock(rawId, importer) {
|
|
2930
|
-
await this.prepare();
|
|
2931
|
-
const { resolvedId, resolvedUrl, redirectUrl } = await this.rpc.resolveMock(rawId, importer, { mock: "auto" });
|
|
2932
|
-
const mockUrl = this.resolveMockPath(cleanVersion(resolvedUrl));
|
|
2933
|
-
let mock = this.registry.get(mockUrl);
|
|
2934
|
-
if (!mock) {
|
|
2935
|
-
if (redirectUrl) {
|
|
2936
|
-
const resolvedRedirect = new URL(this.resolveMockPath(cleanVersion(redirectUrl)), location.href).toString();
|
|
2937
|
-
mock = new RedirectedModule(rawId, resolvedId, mockUrl, resolvedRedirect);
|
|
2938
|
-
} else {
|
|
2939
|
-
mock = new AutomockedModule(rawId, resolvedId, mockUrl);
|
|
2940
|
-
}
|
|
2941
|
-
}
|
|
2942
|
-
if (mock.type === "manual") {
|
|
2943
|
-
return await mock.resolve();
|
|
2944
|
-
}
|
|
2945
|
-
if (mock.type === "automock" || mock.type === "autospy") {
|
|
2946
|
-
const url2 = new URL(`/@id/${resolvedId}`, location.href);
|
|
2947
|
-
const query = url2.search ? `${url2.search}&t=${now()}` : `?t=${now()}`;
|
|
2948
|
-
const moduleObject = await __vitePreload(() => import(
|
|
2949
|
-
/* @vite-ignore */
|
|
2950
|
-
`${url2.pathname}${query}&mock=${mock.type}${url2.hash}`
|
|
2951
|
-
), true ? [] : void 0);
|
|
2952
|
-
return this.mockObject(moduleObject, mock.type);
|
|
2953
|
-
}
|
|
2954
|
-
return import(
|
|
2955
|
-
/* @vite-ignore */
|
|
2956
|
-
mock.redirect
|
|
2957
|
-
);
|
|
2958
|
-
}
|
|
2959
|
-
mockObject(object2, moduleType = "automock") {
|
|
2960
|
-
return mockObject({
|
|
2961
|
-
globalConstructors: {
|
|
2962
|
-
Object,
|
|
2963
|
-
Function,
|
|
2964
|
-
Array,
|
|
2965
|
-
Map,
|
|
2966
|
-
RegExp
|
|
2967
|
-
},
|
|
2968
|
-
createMockInstance: this.createMockInstance,
|
|
2969
|
-
type: moduleType
|
|
2970
|
-
}, object2);
|
|
2971
|
-
}
|
|
2972
|
-
queueMock(rawId, importer, factoryOrOptions) {
|
|
2973
|
-
const promise = this.rpc.resolveMock(rawId, importer, { mock: typeof factoryOrOptions === "function" ? "factory" : (factoryOrOptions === null || factoryOrOptions === void 0 ? void 0 : factoryOrOptions.spy) ? "spy" : "auto" }).then(async ({ redirectUrl, resolvedId, resolvedUrl, needsInterop, mockType }) => {
|
|
2974
|
-
const mockUrl = this.resolveMockPath(cleanVersion(resolvedUrl));
|
|
2975
|
-
this.mockedIds.add(resolvedId);
|
|
2976
|
-
const factory = typeof factoryOrOptions === "function" ? async () => {
|
|
2977
|
-
const data = await factoryOrOptions();
|
|
2978
|
-
return needsInterop ? { default: data } : data;
|
|
2979
|
-
} : void 0;
|
|
2980
|
-
const mockRedirect = typeof redirectUrl === "string" ? new URL(this.resolveMockPath(cleanVersion(redirectUrl)), location.href).toString() : null;
|
|
2981
|
-
let module;
|
|
2982
|
-
if (mockType === "manual") {
|
|
2983
|
-
module = this.registry.register("manual", rawId, resolvedId, mockUrl, factory);
|
|
2984
|
-
} else if (mockType === "autospy") {
|
|
2985
|
-
module = this.registry.register("autospy", rawId, resolvedId, mockUrl);
|
|
2986
|
-
} else if (mockType === "redirect") {
|
|
2987
|
-
module = this.registry.register("redirect", rawId, resolvedId, mockUrl, mockRedirect);
|
|
2988
|
-
} else {
|
|
2989
|
-
module = this.registry.register("automock", rawId, resolvedId, mockUrl);
|
|
2990
|
-
}
|
|
2991
|
-
await this.interceptor.register(module);
|
|
2992
|
-
}).finally(() => {
|
|
2993
|
-
this.queue.delete(promise);
|
|
2994
|
-
});
|
|
2995
|
-
this.queue.add(promise);
|
|
2996
|
-
}
|
|
2997
|
-
queueUnmock(id, importer) {
|
|
2998
|
-
const promise = this.rpc.resolveId(id, importer).then(async (resolved) => {
|
|
2999
|
-
if (!resolved) {
|
|
3000
|
-
return;
|
|
3001
|
-
}
|
|
3002
|
-
const mockUrl = this.resolveMockPath(cleanVersion(resolved.url));
|
|
3003
|
-
this.mockedIds.add(resolved.id);
|
|
3004
|
-
this.registry.delete(mockUrl);
|
|
3005
|
-
await this.interceptor.delete(mockUrl);
|
|
3006
|
-
}).finally(() => {
|
|
3007
|
-
this.queue.delete(promise);
|
|
3008
|
-
});
|
|
3009
|
-
this.queue.add(promise);
|
|
3010
|
-
}
|
|
3011
|
-
// We need to await mock registration before importing the actual module
|
|
3012
|
-
// In case there is a mocked module in the import chain
|
|
3013
|
-
wrapDynamicImport(moduleFactory) {
|
|
3014
|
-
if (typeof moduleFactory === "function") {
|
|
3015
|
-
const promise = new Promise((resolve2, reject) => {
|
|
3016
|
-
this.prepare().finally(() => {
|
|
3017
|
-
moduleFactory().then(resolve2, reject);
|
|
3018
|
-
});
|
|
3019
|
-
});
|
|
3020
|
-
return promise;
|
|
3021
|
-
}
|
|
3022
|
-
return moduleFactory;
|
|
3023
|
-
}
|
|
3024
|
-
resolveMockPath(path) {
|
|
3025
|
-
const config = this.config;
|
|
3026
|
-
const fsRoot = join("/@fs/", config.root);
|
|
3027
|
-
if (path.startsWith(config.root)) {
|
|
3028
|
-
return path.slice(config.root.length);
|
|
3029
|
-
}
|
|
3030
|
-
if (path.startsWith(fsRoot)) {
|
|
3031
|
-
return path.slice(fsRoot.length);
|
|
3032
|
-
}
|
|
3033
|
-
return path;
|
|
3034
|
-
}
|
|
3035
|
-
}
|
|
3036
|
-
const versionRegexp = /(\?|&)v=\w{8}/;
|
|
3037
|
-
function cleanVersion(url2) {
|
|
3038
|
-
return url2.replace(versionRegexp, "");
|
|
3039
|
-
}
|
|
3040
|
-
class VitestBrowserClientMocker extends ModuleMocker {
|
|
3041
|
-
// default "vi" utility tries to access mock context to avoid circular dependencies
|
|
3042
|
-
getMockContext() {
|
|
3043
|
-
return { callstack: null };
|
|
3044
|
-
}
|
|
3045
|
-
wrapDynamicImport(moduleFactory) {
|
|
3046
|
-
return getBrowserState().wrapModule(moduleFactory);
|
|
3047
|
-
}
|
|
3048
|
-
}
|
|
3049
|
-
function createModuleMockerInterceptor() {
|
|
3050
|
-
return {
|
|
3051
|
-
async register(module) {
|
|
3052
|
-
const state = getBrowserState();
|
|
3053
|
-
await rpc().registerMock(state.sessionId, module.toJSON());
|
|
3054
|
-
},
|
|
3055
|
-
async delete(id) {
|
|
3056
|
-
const state = getBrowserState();
|
|
3057
|
-
await rpc().unregisterMock(state.sessionId, id);
|
|
3058
|
-
},
|
|
3059
|
-
async invalidate() {
|
|
3060
|
-
const state = getBrowserState();
|
|
3061
|
-
await rpc().clearMocks(state.sessionId);
|
|
3062
|
-
}
|
|
3063
|
-
};
|
|
3064
|
-
}
|
|
3065
|
-
function rpc() {
|
|
3066
|
-
return getWorkerState().rpc;
|
|
3067
|
-
}
|
|
3068
|
-
getBrowserState().provider;
|
|
3069
|
-
class CommandsManager {
|
|
3070
|
-
constructor() {
|
|
3071
|
-
__publicField(this, "_listeners", []);
|
|
3072
|
-
}
|
|
3073
|
-
onCommand(listener) {
|
|
3074
|
-
this._listeners.push(listener);
|
|
3075
|
-
}
|
|
3076
|
-
async triggerCommand(command, args, clientError = new Error("empty")) {
|
|
3077
|
-
var _a, _b;
|
|
3078
|
-
const state = getWorkerState();
|
|
3079
|
-
const rpc2 = state.rpc;
|
|
3080
|
-
const { sessionId } = getBrowserState();
|
|
3081
|
-
const filepath = state.filepath || ((_b = (_a = state.current) == null ? void 0 : _a.file) == null ? void 0 : _b.filepath);
|
|
3082
|
-
args = args.filter((arg) => arg !== void 0);
|
|
3083
|
-
if (this._listeners.length) {
|
|
3084
|
-
await Promise.all(this._listeners.map((listener) => listener(command, args)));
|
|
3085
|
-
}
|
|
3086
|
-
return rpc2.triggerCommand(sessionId, command, filepath, args).catch((err) => {
|
|
3087
|
-
var _a2;
|
|
3088
|
-
clientError.message = err.message;
|
|
3089
|
-
clientError.name = err.name;
|
|
3090
|
-
clientError.stack = (_a2 = clientError.stack) == null ? void 0 : _a2.replace(clientError.message, err.message);
|
|
3091
|
-
throw clientError;
|
|
3092
|
-
});
|
|
3093
|
-
}
|
|
3094
|
-
}
|
|
3095
|
-
const __vite_import_meta_env__ = { "BASE_URL": "/", "DEV": false, "MODE": "production", "PROD": true, "SSR": false, "VITE_TEST_WATCHER_DEBUG": "false" };
|
|
3096
|
-
const debugVar = getConfig().env.VITEST_BROWSER_DEBUG;
|
|
3097
|
-
const debug = debugVar && debugVar !== "false" ? (...args) => {
|
|
3098
|
-
var _a, _b;
|
|
3099
|
-
return (_b = (_a = client.rpc).debug) == null ? void 0 : _b.call(_a, ...args.map(String));
|
|
3100
|
-
} : void 0;
|
|
3101
|
-
channel.addEventListener("message", async (e) => {
|
|
3102
|
-
await client.waitForConnection();
|
|
3103
|
-
const data = e.data;
|
|
3104
|
-
debug == null ? void 0 : debug("event from orchestrator", JSON.stringify(e.data));
|
|
3105
|
-
if (!isEvent(data)) {
|
|
3106
|
-
const error = new Error(`Unknown message: ${JSON.stringify(e.data)}`);
|
|
3107
|
-
unhandledError(error, "Unknown Iframe Message");
|
|
3108
|
-
return;
|
|
3109
|
-
}
|
|
3110
|
-
if (!("iframeId" in data) || data.iframeId !== getBrowserState().iframeId) {
|
|
3111
|
-
return;
|
|
3112
|
-
}
|
|
3113
|
-
switch (data.event) {
|
|
3114
|
-
case "execute": {
|
|
3115
|
-
const { method, files, context } = data;
|
|
3116
|
-
const state = getWorkerState();
|
|
3117
|
-
const parsedContext = parse$1(context);
|
|
3118
|
-
state.ctx.providedContext = parsedContext;
|
|
3119
|
-
state.providedContext = parsedContext;
|
|
3120
|
-
if (method === "collect") {
|
|
3121
|
-
await executeTests("collect", files).catch((err) => unhandledError(err, "Collect Error"));
|
|
3122
|
-
} else {
|
|
3123
|
-
await executeTests("run", files).catch((err) => unhandledError(err, "Run Error"));
|
|
3124
|
-
}
|
|
3125
|
-
break;
|
|
3126
|
-
}
|
|
3127
|
-
case "cleanup": {
|
|
3128
|
-
await cleanup().catch((err) => unhandledError(err, "Cleanup Error"));
|
|
3129
|
-
break;
|
|
3130
|
-
}
|
|
3131
|
-
case "prepare": {
|
|
3132
|
-
await prepare(data).catch((err) => unhandledError(err, "Prepare Error"));
|
|
3133
|
-
break;
|
|
3134
|
-
}
|
|
3135
|
-
case "viewport:done":
|
|
3136
|
-
case "viewport:fail":
|
|
3137
|
-
case "viewport": {
|
|
3138
|
-
break;
|
|
3139
|
-
}
|
|
3140
|
-
default: {
|
|
3141
|
-
const error = new Error(`Unknown event: ${data.event}`);
|
|
3142
|
-
unhandledError(error, "Unknown Event");
|
|
3143
|
-
}
|
|
3144
|
-
}
|
|
3145
|
-
channel.postMessage({
|
|
3146
|
-
event: `response:${data.event}`,
|
|
3147
|
-
iframeId: getBrowserState().iframeId
|
|
3148
|
-
});
|
|
3149
|
-
});
|
|
3150
|
-
const url = new URL(location.href);
|
|
3151
|
-
const reloadStart = url.searchParams.get("__reloadStart");
|
|
3152
|
-
const iframeId = url.searchParams.get("iframeId");
|
|
3153
|
-
const commands = new CommandsManager();
|
|
3154
|
-
getBrowserState().commands = commands;
|
|
3155
|
-
getBrowserState().iframeId = iframeId;
|
|
3156
|
-
let contextSwitched = false;
|
|
3157
|
-
async function prepareTestEnvironment(options) {
|
|
3158
|
-
debug == null ? void 0 : debug("trying to resolve runner", `${reloadStart}`);
|
|
3159
|
-
const config = getConfig();
|
|
3160
|
-
const rpc2 = createSafeRpc(client);
|
|
3161
|
-
const state = getWorkerState();
|
|
3162
|
-
state.metaEnv = __vite_import_meta_env__;
|
|
3163
|
-
state.onCancel = onCancel;
|
|
3164
|
-
state.rpc = rpc2;
|
|
3165
|
-
const interceptor = createModuleMockerInterceptor();
|
|
3166
|
-
const mocker = new VitestBrowserClientMocker(
|
|
3167
|
-
interceptor,
|
|
3168
|
-
rpc2,
|
|
3169
|
-
SpyModule.createMockInstance,
|
|
3170
|
-
{
|
|
3171
|
-
root: getBrowserState().viteConfig.root
|
|
3172
|
-
}
|
|
3173
|
-
);
|
|
3174
|
-
globalThis.__vitest_mocker__ = mocker;
|
|
3175
|
-
setupConsoleLogSpy();
|
|
3176
|
-
setupDialogsSpy();
|
|
3177
|
-
const runner = await initiateRunner(state, mocker, config);
|
|
3178
|
-
getBrowserState().runner = runner;
|
|
3179
|
-
if (server.provider === "webdriverio") {
|
|
3180
|
-
let switchPromise = null;
|
|
3181
|
-
commands.onCommand(async () => {
|
|
3182
|
-
if (switchPromise) {
|
|
3183
|
-
await switchPromise;
|
|
3184
|
-
}
|
|
3185
|
-
if (!contextSwitched) {
|
|
3186
|
-
switchPromise = rpc2.wdioSwitchContext("iframe").finally(() => {
|
|
3187
|
-
switchPromise = null;
|
|
3188
|
-
contextSwitched = true;
|
|
3189
|
-
});
|
|
3190
|
-
await switchPromise;
|
|
3191
|
-
}
|
|
3192
|
-
});
|
|
3193
|
-
}
|
|
3194
|
-
state.durations.prepare = performance.now() - options.startTime;
|
|
3195
|
-
return {
|
|
3196
|
-
runner,
|
|
3197
|
-
config,
|
|
3198
|
-
state
|
|
3199
|
-
};
|
|
3200
|
-
}
|
|
3201
|
-
let preparedData;
|
|
3202
|
-
async function executeTests(method, files) {
|
|
3203
|
-
if (!preparedData) {
|
|
3204
|
-
throw new Error(`Data was not properly initialized. This is a bug in Vitest. Please, open a new issue with reproduction.`);
|
|
3205
|
-
}
|
|
3206
|
-
debug == null ? void 0 : debug("runner resolved successfully");
|
|
3207
|
-
const { runner, state } = preparedData;
|
|
3208
|
-
state.ctx.files = files;
|
|
3209
|
-
runner.setMethod(method);
|
|
3210
|
-
const version = url.searchParams.get("browserv") || "";
|
|
3211
|
-
files.forEach((filename) => {
|
|
3212
|
-
const currentVersion = browserHashMap.get(filename);
|
|
3213
|
-
if (!currentVersion || currentVersion[1] !== version) {
|
|
3214
|
-
browserHashMap.set(filename, version);
|
|
3215
|
-
}
|
|
3216
|
-
});
|
|
3217
|
-
debug == null ? void 0 : debug("prepare time", state.durations.prepare, "ms");
|
|
3218
|
-
for (const file of files) {
|
|
3219
|
-
state.filepath = file;
|
|
3220
|
-
if (method === "run") {
|
|
3221
|
-
await startTests([file], runner);
|
|
3222
|
-
} else {
|
|
3223
|
-
await collectTests([file], runner);
|
|
3224
|
-
}
|
|
3225
|
-
}
|
|
3226
|
-
}
|
|
3227
|
-
async function prepare(options) {
|
|
3228
|
-
preparedData = await prepareTestEnvironment(options);
|
|
3229
|
-
debug == null ? void 0 : debug("runner resolved successfully");
|
|
3230
|
-
const { config, state } = preparedData;
|
|
3231
|
-
state.durations.prepare = performance.now() - state.durations.prepare;
|
|
3232
|
-
debug == null ? void 0 : debug("prepare time", state.durations.prepare, "ms");
|
|
3233
|
-
await Promise.all([
|
|
3234
|
-
setupCommonEnv(config),
|
|
3235
|
-
startCoverageInsideWorker(config.coverage, moduleRunner, { isolate: config.browser.isolate }),
|
|
3236
|
-
(async () => {
|
|
3237
|
-
const VitestIndex = await __vitePreload(() => import("vitest"), true ? [] : void 0);
|
|
3238
|
-
Object.defineProperty(window, "__vitest_index__", {
|
|
3239
|
-
value: VitestIndex,
|
|
3240
|
-
enumerable: false
|
|
3241
|
-
});
|
|
3242
|
-
})()
|
|
3243
|
-
]);
|
|
3244
|
-
if (!config.browser.trackUnhandledErrors) {
|
|
3245
|
-
getBrowserState().disposeExceptionTracker();
|
|
3246
|
-
}
|
|
3247
|
-
}
|
|
3248
|
-
async function cleanup() {
|
|
3249
|
-
const state = getWorkerState();
|
|
3250
|
-
const config = getConfig();
|
|
3251
|
-
const rpc2 = state.rpc;
|
|
3252
|
-
const cleanupSymbol = Symbol.for("vitest:component-cleanup");
|
|
3253
|
-
if (cleanupSymbol in page) {
|
|
3254
|
-
try {
|
|
3255
|
-
await page[cleanupSymbol]();
|
|
3256
|
-
} catch (error) {
|
|
3257
|
-
await unhandledError(error, "Cleanup Error");
|
|
3258
|
-
}
|
|
3259
|
-
}
|
|
3260
|
-
await userEvent.cleanup().catch((error) => unhandledError(error, "Cleanup Error"));
|
|
3261
|
-
await Promise.all(
|
|
3262
|
-
getBrowserState().cleanups.map((fn) => fn())
|
|
3263
|
-
).catch((error) => unhandledError(error, "Cleanup Error"));
|
|
3264
|
-
if (contextSwitched) {
|
|
3265
|
-
await rpc2.wdioSwitchContext("parent").catch((error) => unhandledError(error, "Cleanup Error"));
|
|
3266
|
-
}
|
|
3267
|
-
state.environmentTeardownRun = true;
|
|
3268
|
-
await stopCoverageInsideWorker(config.coverage, moduleRunner, { isolate: config.browser.isolate }).catch((error) => {
|
|
3269
|
-
return unhandledError(error, "Coverage Error");
|
|
3270
|
-
});
|
|
3271
|
-
}
|
|
3272
|
-
function unhandledError(e, type) {
|
|
3273
|
-
return client.rpc.onUnhandledError({
|
|
3274
|
-
name: e.name,
|
|
3275
|
-
message: e.message,
|
|
3276
|
-
stack: e.stack
|
|
3277
|
-
}, type).catch(() => {
|
|
3278
|
-
});
|
|
3279
|
-
}
|
|
3280
|
-
function isEvent(data) {
|
|
3281
|
-
return typeof data === "object" && !!data && "event" in data;
|
|
3282
|
-
}
|