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