storybook 10.2.0 → 10.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_node-chunks/{builder-manager-C463DWQN.js → builder-manager-Y7WDBY2S.js} +12 -12
- package/dist/_node-chunks/{camelcase-Y5LTSISE.js → camelcase-LCSBROGS.js} +7 -7
- package/dist/_node-chunks/chunk-5U7A7FRD.js +23 -0
- package/dist/_node-chunks/{chunk-4QVBTE7M.js → chunk-632PAV7G.js} +7 -7
- package/dist/_node-chunks/{chunk-REM65RTQ.js → chunk-6L4XZTSD.js} +6 -6
- package/dist/_node-chunks/{chunk-RJMXG4OO.js → chunk-AQXSSPXS.js} +6 -6
- package/dist/_node-chunks/{chunk-TRMGP5US.js → chunk-B66GDH5E.js} +7 -7
- package/dist/_node-chunks/{chunk-K53Q6JM5.js → chunk-EC6HAISG.js} +6 -6
- package/dist/_node-chunks/{chunk-OWZ2VX4F.js → chunk-F5VZNTJU.js} +7 -7
- package/dist/_node-chunks/{chunk-7LLBURFX.js → chunk-FFXDUKTP.js} +12 -12
- package/dist/_node-chunks/{chunk-7MGQ6XJD.js → chunk-FLT5MUVI.js} +9 -9
- package/dist/_node-chunks/chunk-GNB7JDQ6.js +61 -0
- package/dist/_node-chunks/{chunk-WGJXF6UC.js → chunk-HOWS7AD5.js} +7 -7
- package/dist/_node-chunks/{chunk-VYJ27OHZ.js → chunk-J3J4PSPT.js} +8 -8
- package/dist/_node-chunks/chunk-KMYEEIKB.js +18 -0
- package/dist/_node-chunks/{chunk-5T2PCIM6.js → chunk-KNMEGL7N.js} +16 -16
- package/dist/_node-chunks/{chunk-OXJURHEN.js → chunk-KYZVFZ4V.js} +7 -7
- package/dist/_node-chunks/{chunk-VONTSCH6.js → chunk-PZLHWGHT.js} +6 -6
- package/dist/_node-chunks/{chunk-GFKN7CEI.js → chunk-QBODOFYE.js} +10 -10
- package/dist/_node-chunks/{chunk-6QCIDOPJ.js → chunk-R3KAQRS5.js} +20 -20
- package/dist/_node-chunks/{chunk-P4K3OTNT.js → chunk-SEEMWADK.js} +6 -6
- package/dist/_node-chunks/{chunk-PDICEGYJ.js → chunk-T2BOJQA5.js} +6 -6
- package/dist/_node-chunks/{chunk-IMMBMNP7.js → chunk-TWGRJVH3.js} +7 -7
- package/dist/_node-chunks/{chunk-QA7GCRBP.js → chunk-ULROOZH7.js} +6 -6
- package/dist/_node-chunks/{chunk-YV4PGYQV.js → chunk-UYNE5BST.js} +13 -13
- package/dist/_node-chunks/{chunk-WJUD5QGU.js → chunk-V4QQTJHD.js} +6 -6
- package/dist/_node-chunks/{chunk-7FKTXNX7.js → chunk-V5SFXULX.js} +9 -9
- package/dist/_node-chunks/{chunk-JU7MZIRN.js → chunk-VNWEGP4S.js} +8 -8
- package/dist/_node-chunks/{chunk-HK3SJFH5.js → chunk-YNBNXSYI.js} +7 -7
- package/dist/_node-chunks/{chunk-ICMT47BJ.js → chunk-YRVTTAPQ.js} +7 -7
- package/dist/_node-chunks/{globby-PJBFMKYG.js → globby-MKVLNYKA.js} +9 -9
- package/dist/_node-chunks/{lib-JFMIKKXD.js → lib-LLKM6LMW.js} +7 -7
- package/dist/_node-chunks/{mdx-N42X6CFJ-BYGXNYNQ.js → mdx-N42X6CFJ-CLZ7QIRS.js} +8 -8
- package/dist/_node-chunks/{p-limit-VUZZ7QLP.js → p-limit-IAOFNB4G.js} +7 -7
- package/dist/babel/index.js +10 -10
- package/dist/bin/core.js +12 -12
- package/dist/bin/dispatcher.js +11 -11
- package/dist/bin/loader.js +9 -9
- package/dist/cli/index.js +18 -18
- package/dist/common/index.js +19 -19
- package/dist/core-server/index.js +35 -35
- package/dist/core-server/presets/common-override-preset.js +9 -9
- package/dist/core-server/presets/common-preset.js +25 -25
- package/dist/csf-tools/index.js +9 -9
- package/dist/manager/globals-runtime.js +1 -1
- package/dist/manager-api/index.d.ts +1 -1
- package/dist/manager-api/index.js +1 -1
- package/dist/mocking-utils/index.d.ts +7 -1
- package/dist/mocking-utils/index.js +161 -29
- package/dist/mocking-utils/mocker-runtime.js +1254 -0
- package/dist/node-logger/index.js +9 -9
- package/dist/preview-api/index.d.ts +68 -67
- package/dist/server-errors.js +11 -11
- package/dist/telemetry/index.js +23 -23
- package/package.json +3 -1
- package/assets/server/mocker-runtime.template.js +0 -89
- package/dist/_node-chunks/chunk-7DTTLDGY.js +0 -23
- package/dist/_node-chunks/chunk-QX2UDUQ6.js +0 -18
- package/dist/_node-chunks/chunk-TJR5UAMR.js +0 -61
|
@@ -0,0 +1,1254 @@
|
|
|
1
|
+
// ../../node_modules/@vitest/mocker/dist/chunk-registry.js
|
|
2
|
+
var MockerRegistry = class {
|
|
3
|
+
registryByUrl = /* @__PURE__ */ new Map();
|
|
4
|
+
registryById = /* @__PURE__ */ new Map();
|
|
5
|
+
clear() {
|
|
6
|
+
this.registryByUrl.clear(), this.registryById.clear();
|
|
7
|
+
}
|
|
8
|
+
keys() {
|
|
9
|
+
return this.registryByUrl.keys();
|
|
10
|
+
}
|
|
11
|
+
add(mock) {
|
|
12
|
+
this.registryByUrl.set(mock.url, mock), this.registryById.set(mock.id, mock);
|
|
13
|
+
}
|
|
14
|
+
register(typeOrEvent, raw, id, url, factoryOrRedirect) {
|
|
15
|
+
let type = typeof typeOrEvent == "object" ? typeOrEvent.type : typeOrEvent;
|
|
16
|
+
if (typeof typeOrEvent == "object") {
|
|
17
|
+
let event = typeOrEvent;
|
|
18
|
+
if (event instanceof AutomockedModule || event instanceof AutospiedModule || event instanceof ManualMockedModule || event instanceof RedirectedModule)
|
|
19
|
+
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.`);
|
|
20
|
+
if (event.type === "automock") {
|
|
21
|
+
let module = AutomockedModule.fromJSON(event);
|
|
22
|
+
return this.add(module), module;
|
|
23
|
+
} else if (event.type === "autospy") {
|
|
24
|
+
let module = AutospiedModule.fromJSON(event);
|
|
25
|
+
return this.add(module), module;
|
|
26
|
+
} else if (event.type === "redirect") {
|
|
27
|
+
let module = RedirectedModule.fromJSON(event);
|
|
28
|
+
return this.add(module), module;
|
|
29
|
+
} else throw event.type === "manual" ? new Error("Cannot set serialized manual mock. Define a factory function manually with `ManualMockedModule.fromJSON()`.") : new Error(`Unknown mock type: ${event.type}`);
|
|
30
|
+
}
|
|
31
|
+
if (typeof raw != "string")
|
|
32
|
+
throw new TypeError("[vitest] Mocks require a raw string.");
|
|
33
|
+
if (typeof url != "string")
|
|
34
|
+
throw new TypeError("[vitest] Mocks require a url string.");
|
|
35
|
+
if (typeof id != "string")
|
|
36
|
+
throw new TypeError("[vitest] Mocks require an id string.");
|
|
37
|
+
if (type === "manual") {
|
|
38
|
+
if (typeof factoryOrRedirect != "function")
|
|
39
|
+
throw new TypeError("[vitest] Manual mocks require a factory function.");
|
|
40
|
+
let mock = new ManualMockedModule(raw, id, url, factoryOrRedirect);
|
|
41
|
+
return this.add(mock), mock;
|
|
42
|
+
} else if (type === "automock" || type === "autospy") {
|
|
43
|
+
let mock = type === "automock" ? new AutomockedModule(raw, id, url) : new AutospiedModule(raw, id, url);
|
|
44
|
+
return this.add(mock), mock;
|
|
45
|
+
} else if (type === "redirect") {
|
|
46
|
+
if (typeof factoryOrRedirect != "string")
|
|
47
|
+
throw new TypeError("[vitest] Redirect mocks require a redirect string.");
|
|
48
|
+
let mock = new RedirectedModule(raw, id, url, factoryOrRedirect);
|
|
49
|
+
return this.add(mock), mock;
|
|
50
|
+
} else
|
|
51
|
+
throw new Error(`[vitest] Unknown mock type: ${type}`);
|
|
52
|
+
}
|
|
53
|
+
delete(id) {
|
|
54
|
+
this.registryByUrl.delete(id);
|
|
55
|
+
}
|
|
56
|
+
get(id) {
|
|
57
|
+
return this.registryByUrl.get(id);
|
|
58
|
+
}
|
|
59
|
+
getById(id) {
|
|
60
|
+
return this.registryById.get(id);
|
|
61
|
+
}
|
|
62
|
+
has(id) {
|
|
63
|
+
return this.registryByUrl.has(id);
|
|
64
|
+
}
|
|
65
|
+
}, AutomockedModule = class {
|
|
66
|
+
type = "automock";
|
|
67
|
+
constructor(raw, id, url) {
|
|
68
|
+
this.raw = raw, this.id = id, this.url = url;
|
|
69
|
+
}
|
|
70
|
+
static fromJSON(data) {
|
|
71
|
+
return new AutospiedModule(data.raw, data.id, data.url);
|
|
72
|
+
}
|
|
73
|
+
toJSON() {
|
|
74
|
+
return {
|
|
75
|
+
type: this.type,
|
|
76
|
+
url: this.url,
|
|
77
|
+
raw: this.raw,
|
|
78
|
+
id: this.id
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}, AutospiedModule = class _AutospiedModule {
|
|
82
|
+
type = "autospy";
|
|
83
|
+
constructor(raw, id, url) {
|
|
84
|
+
this.raw = raw, this.id = id, this.url = url;
|
|
85
|
+
}
|
|
86
|
+
static fromJSON(data) {
|
|
87
|
+
return new _AutospiedModule(data.raw, data.id, data.url);
|
|
88
|
+
}
|
|
89
|
+
toJSON() {
|
|
90
|
+
return {
|
|
91
|
+
type: this.type,
|
|
92
|
+
url: this.url,
|
|
93
|
+
id: this.id,
|
|
94
|
+
raw: this.raw
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}, RedirectedModule = class _RedirectedModule {
|
|
98
|
+
type = "redirect";
|
|
99
|
+
constructor(raw, id, url, redirect) {
|
|
100
|
+
this.raw = raw, this.id = id, this.url = url, this.redirect = redirect;
|
|
101
|
+
}
|
|
102
|
+
static fromJSON(data) {
|
|
103
|
+
return new _RedirectedModule(data.raw, data.id, data.url, data.redirect);
|
|
104
|
+
}
|
|
105
|
+
toJSON() {
|
|
106
|
+
return {
|
|
107
|
+
type: this.type,
|
|
108
|
+
url: this.url,
|
|
109
|
+
raw: this.raw,
|
|
110
|
+
id: this.id,
|
|
111
|
+
redirect: this.redirect
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}, ManualMockedModule = class _ManualMockedModule {
|
|
115
|
+
cache;
|
|
116
|
+
type = "manual";
|
|
117
|
+
constructor(raw, id, url, factory) {
|
|
118
|
+
this.raw = raw, this.id = id, this.url = url, this.factory = factory;
|
|
119
|
+
}
|
|
120
|
+
async resolve() {
|
|
121
|
+
if (this.cache)
|
|
122
|
+
return this.cache;
|
|
123
|
+
let exports;
|
|
124
|
+
try {
|
|
125
|
+
exports = await this.factory();
|
|
126
|
+
} catch (err) {
|
|
127
|
+
let 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');
|
|
128
|
+
throw vitestError.cause = err, vitestError;
|
|
129
|
+
}
|
|
130
|
+
if (exports === null || typeof exports != "object" || Array.isArray(exports))
|
|
131
|
+
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?`);
|
|
132
|
+
return this.cache = exports;
|
|
133
|
+
}
|
|
134
|
+
static fromJSON(data, factory) {
|
|
135
|
+
return new _ManualMockedModule(data.raw, data.id, data.url, factory);
|
|
136
|
+
}
|
|
137
|
+
toJSON() {
|
|
138
|
+
return {
|
|
139
|
+
type: this.type,
|
|
140
|
+
url: this.url,
|
|
141
|
+
id: this.id,
|
|
142
|
+
raw: this.raw
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// ../../node_modules/@vitest/mocker/dist/index.js
|
|
148
|
+
function mockObject(options, object, mockExports = {}) {
|
|
149
|
+
let finalizers = new Array(), refs = new RefTracker(), define = (container, key, value) => {
|
|
150
|
+
try {
|
|
151
|
+
return container[key] = value, !0;
|
|
152
|
+
} catch {
|
|
153
|
+
return !1;
|
|
154
|
+
}
|
|
155
|
+
}, mockPropertiesOf = (container, newContainer) => {
|
|
156
|
+
let containerType = getType(container), isModule = containerType === "Module" || !!container.__esModule;
|
|
157
|
+
for (let { key: property, descriptor } of getAllMockableProperties(container, isModule, options.globalConstructors)) {
|
|
158
|
+
if (!isModule && descriptor.get) {
|
|
159
|
+
try {
|
|
160
|
+
Object.defineProperty(newContainer, property, descriptor);
|
|
161
|
+
} catch {
|
|
162
|
+
}
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
if (isSpecialProp(property, containerType))
|
|
166
|
+
continue;
|
|
167
|
+
let value = container[property], refId = refs.getId(value);
|
|
168
|
+
if (refId !== void 0) {
|
|
169
|
+
finalizers.push(() => define(newContainer, property, refs.getMockedValue(refId)));
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
let type = getType(value);
|
|
173
|
+
if (Array.isArray(value)) {
|
|
174
|
+
define(newContainer, property, []);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
let isFunction = type.includes("Function") && typeof value == "function";
|
|
178
|
+
if ((!isFunction || value._isMockFunction) && type !== "Object" && type !== "Module") {
|
|
179
|
+
define(newContainer, property, value);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
if (define(newContainer, property, isFunction ? value : {})) {
|
|
183
|
+
if (isFunction) {
|
|
184
|
+
let mockFunction = function() {
|
|
185
|
+
if (this instanceof newContainer[property])
|
|
186
|
+
for (let { key, descriptor: descriptor2 } of getAllMockableProperties(this, !1, options.globalConstructors)) {
|
|
187
|
+
if (descriptor2.get)
|
|
188
|
+
continue;
|
|
189
|
+
let value2 = this[key];
|
|
190
|
+
if (getType(value2).includes("Function") && typeof value2 == "function") {
|
|
191
|
+
let original = this[key], mock2 = spyOn(this, key).mockImplementation(original), origMockReset = mock2.mockReset;
|
|
192
|
+
mock2.mockRestore = mock2.mockReset = () => (origMockReset.call(mock2), mock2.mockImplementation(original), mock2);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
if (!options.spyOn)
|
|
197
|
+
throw new Error("[@vitest/mocker] `spyOn` is not defined. This is a Vitest error. Please open a new issue with reproduction.");
|
|
198
|
+
let spyOn = options.spyOn, mock = spyOn(newContainer, property);
|
|
199
|
+
if (options.type === "automock") {
|
|
200
|
+
mock.mockImplementation(mockFunction);
|
|
201
|
+
let origMockReset = mock.mockReset;
|
|
202
|
+
mock.mockRestore = mock.mockReset = () => (origMockReset.call(mock), mock.mockImplementation(mockFunction), mock);
|
|
203
|
+
}
|
|
204
|
+
Object.defineProperty(newContainer[property], "length", { value: 0 });
|
|
205
|
+
}
|
|
206
|
+
refs.track(value, newContainer[property]), mockPropertiesOf(value, newContainer[property]);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}, mockedObject = mockExports;
|
|
210
|
+
mockPropertiesOf(object, mockedObject);
|
|
211
|
+
for (let finalizer of finalizers)
|
|
212
|
+
finalizer();
|
|
213
|
+
return mockedObject;
|
|
214
|
+
}
|
|
215
|
+
var RefTracker = class {
|
|
216
|
+
idMap = /* @__PURE__ */ new Map();
|
|
217
|
+
mockedValueMap = /* @__PURE__ */ new Map();
|
|
218
|
+
getId(value) {
|
|
219
|
+
return this.idMap.get(value);
|
|
220
|
+
}
|
|
221
|
+
getMockedValue(id) {
|
|
222
|
+
return this.mockedValueMap.get(id);
|
|
223
|
+
}
|
|
224
|
+
track(originalValue, mockedValue) {
|
|
225
|
+
let newId = this.idMap.size;
|
|
226
|
+
return this.idMap.set(originalValue, newId), this.mockedValueMap.set(newId, mockedValue), newId;
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
function getType(value) {
|
|
230
|
+
return Object.prototype.toString.apply(value).slice(8, -1);
|
|
231
|
+
}
|
|
232
|
+
function isSpecialProp(prop, parentType) {
|
|
233
|
+
return parentType.includes("Function") && typeof prop == "string" && [
|
|
234
|
+
"arguments",
|
|
235
|
+
"callee",
|
|
236
|
+
"caller",
|
|
237
|
+
"length",
|
|
238
|
+
"name"
|
|
239
|
+
].includes(prop);
|
|
240
|
+
}
|
|
241
|
+
function getAllMockableProperties(obj, isModule, constructors) {
|
|
242
|
+
let { Map: Map2, Object: Object2, Function: Function2, RegExp: RegExp2, Array: Array2 } = constructors, allProps = new Map2(), curr = obj;
|
|
243
|
+
do {
|
|
244
|
+
if (curr === Object2.prototype || curr === Function2.prototype || curr === RegExp2.prototype)
|
|
245
|
+
break;
|
|
246
|
+
collectOwnProperties(curr, (key) => {
|
|
247
|
+
let descriptor = Object2.getOwnPropertyDescriptor(curr, key);
|
|
248
|
+
descriptor && allProps.set(key, {
|
|
249
|
+
key,
|
|
250
|
+
descriptor
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
} while (curr = Object2.getPrototypeOf(curr));
|
|
254
|
+
if (isModule && !allProps.has("default") && "default" in obj) {
|
|
255
|
+
let descriptor = Object2.getOwnPropertyDescriptor(obj, "default");
|
|
256
|
+
descriptor && allProps.set("default", {
|
|
257
|
+
key: "default",
|
|
258
|
+
descriptor
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
return Array2.from(allProps.values());
|
|
262
|
+
}
|
|
263
|
+
function collectOwnProperties(obj, collector) {
|
|
264
|
+
let collect = typeof collector == "function" ? collector : (key) => collector.add(key);
|
|
265
|
+
Object.getOwnPropertyNames(obj).forEach(collect), Object.getOwnPropertySymbols(obj).forEach(collect);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// ../../node_modules/@vitest/mocker/dist/chunk-pathe.M-eThtNZ.js
|
|
269
|
+
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
270
|
+
function normalizeWindowsPath(input = "") {
|
|
271
|
+
return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
272
|
+
}
|
|
273
|
+
var _UNC_REGEX = /^[/\\]{2}/, _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/, _EXTNAME_RE = /.(\.[^./]+|\.)$/, normalize = function(path) {
|
|
274
|
+
if (path.length === 0)
|
|
275
|
+
return ".";
|
|
276
|
+
path = normalizeWindowsPath(path);
|
|
277
|
+
let isUNCPath = path.match(_UNC_REGEX), isPathAbsolute = isAbsolute(path), trailingSeparator = path[path.length - 1] === "/";
|
|
278
|
+
return path = normalizeString(path, !isPathAbsolute), path.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path += "/"), _DRIVE_LETTER_RE.test(path) && (path += "/"), isUNCPath ? isPathAbsolute ? `//${path}` : `//./${path}` : isPathAbsolute && !isAbsolute(path) ? `/${path}` : path);
|
|
279
|
+
}, join = function(...segments) {
|
|
280
|
+
let path = "";
|
|
281
|
+
for (let seg of segments)
|
|
282
|
+
if (seg)
|
|
283
|
+
if (path.length > 0) {
|
|
284
|
+
let pathTrailing = path[path.length - 1] === "/", segLeading = seg[0] === "/";
|
|
285
|
+
pathTrailing && segLeading ? path += seg.slice(1) : path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
286
|
+
} else
|
|
287
|
+
path += seg;
|
|
288
|
+
return normalize(path);
|
|
289
|
+
};
|
|
290
|
+
function normalizeString(path, allowAboveRoot) {
|
|
291
|
+
let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
|
|
292
|
+
for (let index2 = 0; index2 <= path.length; ++index2) {
|
|
293
|
+
if (index2 < path.length)
|
|
294
|
+
char = path[index2];
|
|
295
|
+
else {
|
|
296
|
+
if (char === "/")
|
|
297
|
+
break;
|
|
298
|
+
char = "/";
|
|
299
|
+
}
|
|
300
|
+
if (char === "/") {
|
|
301
|
+
if (!(lastSlash === index2 - 1 || dots === 1)) if (dots === 2) {
|
|
302
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
303
|
+
if (res.length > 2) {
|
|
304
|
+
let lastSlashIndex = res.lastIndexOf("/");
|
|
305
|
+
lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index2, dots = 0;
|
|
306
|
+
continue;
|
|
307
|
+
} else if (res.length > 0) {
|
|
308
|
+
res = "", lastSegmentLength = 0, lastSlash = index2, dots = 0;
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
|
|
313
|
+
} else
|
|
314
|
+
res.length > 0 ? res += `/${path.slice(lastSlash + 1, index2)}` : res = path.slice(lastSlash + 1, index2), lastSegmentLength = index2 - lastSlash - 1;
|
|
315
|
+
lastSlash = index2, dots = 0;
|
|
316
|
+
} else char === "." && dots !== -1 ? ++dots : dots = -1;
|
|
317
|
+
}
|
|
318
|
+
return res;
|
|
319
|
+
}
|
|
320
|
+
var isAbsolute = function(p2) {
|
|
321
|
+
return _IS_ABSOLUTE_RE.test(p2);
|
|
322
|
+
}, extname = function(p2) {
|
|
323
|
+
if (p2 === "..") return "";
|
|
324
|
+
let match = _EXTNAME_RE.exec(normalizeWindowsPath(p2));
|
|
325
|
+
return match && match[1] || "";
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
// ../../node_modules/@vitest/mocker/dist/chunk-mocker.js
|
|
329
|
+
var f = {
|
|
330
|
+
reset: [0, 0],
|
|
331
|
+
bold: [1, 22, "\x1B[22m\x1B[1m"],
|
|
332
|
+
dim: [2, 22, "\x1B[22m\x1B[2m"],
|
|
333
|
+
italic: [3, 23],
|
|
334
|
+
underline: [4, 24],
|
|
335
|
+
inverse: [7, 27],
|
|
336
|
+
hidden: [8, 28],
|
|
337
|
+
strikethrough: [9, 29],
|
|
338
|
+
black: [30, 39],
|
|
339
|
+
red: [31, 39],
|
|
340
|
+
green: [32, 39],
|
|
341
|
+
yellow: [33, 39],
|
|
342
|
+
blue: [34, 39],
|
|
343
|
+
magenta: [35, 39],
|
|
344
|
+
cyan: [36, 39],
|
|
345
|
+
white: [37, 39],
|
|
346
|
+
gray: [90, 39],
|
|
347
|
+
bgBlack: [40, 49],
|
|
348
|
+
bgRed: [41, 49],
|
|
349
|
+
bgGreen: [42, 49],
|
|
350
|
+
bgYellow: [43, 49],
|
|
351
|
+
bgBlue: [44, 49],
|
|
352
|
+
bgMagenta: [45, 49],
|
|
353
|
+
bgCyan: [46, 49],
|
|
354
|
+
bgWhite: [47, 49],
|
|
355
|
+
blackBright: [90, 39],
|
|
356
|
+
redBright: [91, 39],
|
|
357
|
+
greenBright: [92, 39],
|
|
358
|
+
yellowBright: [93, 39],
|
|
359
|
+
blueBright: [94, 39],
|
|
360
|
+
magentaBright: [95, 39],
|
|
361
|
+
cyanBright: [96, 39],
|
|
362
|
+
whiteBright: [97, 39],
|
|
363
|
+
bgBlackBright: [100, 49],
|
|
364
|
+
bgRedBright: [101, 49],
|
|
365
|
+
bgGreenBright: [102, 49],
|
|
366
|
+
bgYellowBright: [103, 49],
|
|
367
|
+
bgBlueBright: [104, 49],
|
|
368
|
+
bgMagentaBright: [105, 49],
|
|
369
|
+
bgCyanBright: [106, 49],
|
|
370
|
+
bgWhiteBright: [107, 49]
|
|
371
|
+
}, h = Object.entries(f);
|
|
372
|
+
function a(n) {
|
|
373
|
+
return String(n);
|
|
374
|
+
}
|
|
375
|
+
a.open = "";
|
|
376
|
+
a.close = "";
|
|
377
|
+
function C(n = !1) {
|
|
378
|
+
let e = typeof process < "u" ? process : void 0, i = e?.env || {}, g = e?.argv || [];
|
|
379
|
+
return !("NO_COLOR" in i || g.includes("--no-color")) && ("FORCE_COLOR" in i || g.includes("--color") || e?.platform === "win32" || n && i.TERM !== "dumb" || "CI" in i) || typeof window < "u" && !!window.chrome;
|
|
380
|
+
}
|
|
381
|
+
function p(n = !1) {
|
|
382
|
+
let e = C(n), i = (r, t, c, o) => {
|
|
383
|
+
let l = "", s = 0;
|
|
384
|
+
do
|
|
385
|
+
l += r.substring(s, o) + c, s = o + t.length, o = r.indexOf(t, s);
|
|
386
|
+
while (~o);
|
|
387
|
+
return l + r.substring(s);
|
|
388
|
+
}, g = (r, t, c = r) => {
|
|
389
|
+
let o = (l) => {
|
|
390
|
+
let s = String(l), b = s.indexOf(t, r.length);
|
|
391
|
+
return ~b ? r + i(s, t, c, b) + t : r + s + t;
|
|
392
|
+
};
|
|
393
|
+
return o.open = r, o.close = t, o;
|
|
394
|
+
}, u = {
|
|
395
|
+
isColorSupported: e
|
|
396
|
+
}, d = (r) => `\x1B[${r}m`;
|
|
397
|
+
for (let [r, t] of h)
|
|
398
|
+
u[r] = e ? g(
|
|
399
|
+
d(t[0]),
|
|
400
|
+
d(t[1]),
|
|
401
|
+
t[2]
|
|
402
|
+
) : a;
|
|
403
|
+
return u;
|
|
404
|
+
}
|
|
405
|
+
p();
|
|
406
|
+
function _mergeNamespaces(n, m) {
|
|
407
|
+
return m.forEach(function(e) {
|
|
408
|
+
e && typeof e != "string" && !Array.isArray(e) && Object.keys(e).forEach(function(k) {
|
|
409
|
+
if (k !== "default" && !(k in n)) {
|
|
410
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
411
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
412
|
+
enumerable: !0,
|
|
413
|
+
get: function() {
|
|
414
|
+
return e[k];
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
}), Object.freeze(n);
|
|
420
|
+
}
|
|
421
|
+
function getDefaultExportFromCjs(x) {
|
|
422
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x.default : x;
|
|
423
|
+
}
|
|
424
|
+
var reactIs$1 = { exports: {} }, reactIs_production = {};
|
|
425
|
+
var hasRequiredReactIs_production;
|
|
426
|
+
function requireReactIs_production() {
|
|
427
|
+
if (hasRequiredReactIs_production) return reactIs_production;
|
|
428
|
+
hasRequiredReactIs_production = 1;
|
|
429
|
+
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"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference");
|
|
430
|
+
function typeOf(object) {
|
|
431
|
+
if (typeof object == "object" && object !== null) {
|
|
432
|
+
var $$typeof = object.$$typeof;
|
|
433
|
+
switch ($$typeof) {
|
|
434
|
+
case REACT_ELEMENT_TYPE:
|
|
435
|
+
switch (object = object.type, object) {
|
|
436
|
+
case REACT_FRAGMENT_TYPE:
|
|
437
|
+
case REACT_PROFILER_TYPE:
|
|
438
|
+
case REACT_STRICT_MODE_TYPE:
|
|
439
|
+
case REACT_SUSPENSE_TYPE:
|
|
440
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
441
|
+
case REACT_VIEW_TRANSITION_TYPE:
|
|
442
|
+
return object;
|
|
443
|
+
default:
|
|
444
|
+
switch (object = object && object.$$typeof, object) {
|
|
445
|
+
case REACT_CONTEXT_TYPE:
|
|
446
|
+
case REACT_FORWARD_REF_TYPE:
|
|
447
|
+
case REACT_LAZY_TYPE:
|
|
448
|
+
case REACT_MEMO_TYPE:
|
|
449
|
+
return object;
|
|
450
|
+
case REACT_CONSUMER_TYPE:
|
|
451
|
+
return object;
|
|
452
|
+
default:
|
|
453
|
+
return $$typeof;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
case REACT_PORTAL_TYPE:
|
|
457
|
+
return $$typeof;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
return reactIs_production.ContextConsumer = REACT_CONSUMER_TYPE, reactIs_production.ContextProvider = REACT_CONTEXT_TYPE, reactIs_production.Element = REACT_ELEMENT_TYPE, reactIs_production.ForwardRef = REACT_FORWARD_REF_TYPE, reactIs_production.Fragment = REACT_FRAGMENT_TYPE, reactIs_production.Lazy = REACT_LAZY_TYPE, reactIs_production.Memo = REACT_MEMO_TYPE, reactIs_production.Portal = REACT_PORTAL_TYPE, reactIs_production.Profiler = REACT_PROFILER_TYPE, reactIs_production.StrictMode = REACT_STRICT_MODE_TYPE, reactIs_production.Suspense = REACT_SUSPENSE_TYPE, reactIs_production.SuspenseList = REACT_SUSPENSE_LIST_TYPE, reactIs_production.isContextConsumer = function(object) {
|
|
462
|
+
return typeOf(object) === REACT_CONSUMER_TYPE;
|
|
463
|
+
}, reactIs_production.isContextProvider = function(object) {
|
|
464
|
+
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
465
|
+
}, reactIs_production.isElement = function(object) {
|
|
466
|
+
return typeof object == "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
467
|
+
}, reactIs_production.isForwardRef = function(object) {
|
|
468
|
+
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
469
|
+
}, reactIs_production.isFragment = function(object) {
|
|
470
|
+
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
471
|
+
}, reactIs_production.isLazy = function(object) {
|
|
472
|
+
return typeOf(object) === REACT_LAZY_TYPE;
|
|
473
|
+
}, reactIs_production.isMemo = function(object) {
|
|
474
|
+
return typeOf(object) === REACT_MEMO_TYPE;
|
|
475
|
+
}, reactIs_production.isPortal = function(object) {
|
|
476
|
+
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
477
|
+
}, reactIs_production.isProfiler = function(object) {
|
|
478
|
+
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
479
|
+
}, reactIs_production.isStrictMode = function(object) {
|
|
480
|
+
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
481
|
+
}, reactIs_production.isSuspense = function(object) {
|
|
482
|
+
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
483
|
+
}, reactIs_production.isSuspenseList = function(object) {
|
|
484
|
+
return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
|
|
485
|
+
}, reactIs_production.isValidElementType = function(type) {
|
|
486
|
+
return typeof type == "string" || typeof type == "function" || type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type == "object" && type !== null && (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 || type.getModuleId !== void 0);
|
|
487
|
+
}, reactIs_production.typeOf = typeOf, reactIs_production;
|
|
488
|
+
}
|
|
489
|
+
var hasRequiredReactIs$1;
|
|
490
|
+
function requireReactIs$1() {
|
|
491
|
+
return hasRequiredReactIs$1 || (hasRequiredReactIs$1 = 1, reactIs$1.exports = requireReactIs_production()), reactIs$1.exports;
|
|
492
|
+
}
|
|
493
|
+
var reactIsExports$1 = requireReactIs$1(), index$1 = getDefaultExportFromCjs(reactIsExports$1), ReactIs19 = _mergeNamespaces({
|
|
494
|
+
__proto__: null,
|
|
495
|
+
default: index$1
|
|
496
|
+
}, [reactIsExports$1]), reactIs = { exports: {} }, reactIs_production_min = {};
|
|
497
|
+
var hasRequiredReactIs_production_min;
|
|
498
|
+
function requireReactIs_production_min() {
|
|
499
|
+
if (hasRequiredReactIs_production_min) return reactIs_production_min;
|
|
500
|
+
hasRequiredReactIs_production_min = 1;
|
|
501
|
+
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;
|
|
502
|
+
u = Symbol.for("react.module.reference");
|
|
503
|
+
function v(a2) {
|
|
504
|
+
if (typeof a2 == "object" && a2 !== null) {
|
|
505
|
+
var r = a2.$$typeof;
|
|
506
|
+
switch (r) {
|
|
507
|
+
case b:
|
|
508
|
+
switch (a2 = a2.type, a2) {
|
|
509
|
+
case d:
|
|
510
|
+
case f2:
|
|
511
|
+
case e:
|
|
512
|
+
case m:
|
|
513
|
+
case n:
|
|
514
|
+
return a2;
|
|
515
|
+
default:
|
|
516
|
+
switch (a2 = a2 && a2.$$typeof, a2) {
|
|
517
|
+
case k:
|
|
518
|
+
case h2:
|
|
519
|
+
case l:
|
|
520
|
+
case q:
|
|
521
|
+
case p2:
|
|
522
|
+
case g:
|
|
523
|
+
return a2;
|
|
524
|
+
default:
|
|
525
|
+
return r;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
case c:
|
|
529
|
+
return r;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
return reactIs_production_min.ContextConsumer = h2, reactIs_production_min.ContextProvider = g, reactIs_production_min.Element = b, reactIs_production_min.ForwardRef = l, reactIs_production_min.Fragment = d, reactIs_production_min.Lazy = q, reactIs_production_min.Memo = p2, reactIs_production_min.Portal = c, reactIs_production_min.Profiler = f2, reactIs_production_min.StrictMode = e, reactIs_production_min.Suspense = m, reactIs_production_min.SuspenseList = n, reactIs_production_min.isAsyncMode = function() {
|
|
534
|
+
return !1;
|
|
535
|
+
}, reactIs_production_min.isConcurrentMode = function() {
|
|
536
|
+
return !1;
|
|
537
|
+
}, reactIs_production_min.isContextConsumer = function(a2) {
|
|
538
|
+
return v(a2) === h2;
|
|
539
|
+
}, reactIs_production_min.isContextProvider = function(a2) {
|
|
540
|
+
return v(a2) === g;
|
|
541
|
+
}, reactIs_production_min.isElement = function(a2) {
|
|
542
|
+
return typeof a2 == "object" && a2 !== null && a2.$$typeof === b;
|
|
543
|
+
}, reactIs_production_min.isForwardRef = function(a2) {
|
|
544
|
+
return v(a2) === l;
|
|
545
|
+
}, reactIs_production_min.isFragment = function(a2) {
|
|
546
|
+
return v(a2) === d;
|
|
547
|
+
}, reactIs_production_min.isLazy = function(a2) {
|
|
548
|
+
return v(a2) === q;
|
|
549
|
+
}, reactIs_production_min.isMemo = function(a2) {
|
|
550
|
+
return v(a2) === p2;
|
|
551
|
+
}, reactIs_production_min.isPortal = function(a2) {
|
|
552
|
+
return v(a2) === c;
|
|
553
|
+
}, reactIs_production_min.isProfiler = function(a2) {
|
|
554
|
+
return v(a2) === f2;
|
|
555
|
+
}, reactIs_production_min.isStrictMode = function(a2) {
|
|
556
|
+
return v(a2) === e;
|
|
557
|
+
}, reactIs_production_min.isSuspense = function(a2) {
|
|
558
|
+
return v(a2) === m;
|
|
559
|
+
}, reactIs_production_min.isSuspenseList = function(a2) {
|
|
560
|
+
return v(a2) === n;
|
|
561
|
+
}, reactIs_production_min.isValidElementType = function(a2) {
|
|
562
|
+
return typeof a2 == "string" || typeof a2 == "function" || a2 === d || a2 === f2 || a2 === e || a2 === m || a2 === n || a2 === t || typeof a2 == "object" && a2 !== null && (a2.$$typeof === q || a2.$$typeof === p2 || a2.$$typeof === g || a2.$$typeof === h2 || a2.$$typeof === l || a2.$$typeof === u || a2.getModuleId !== void 0);
|
|
563
|
+
}, reactIs_production_min.typeOf = v, reactIs_production_min;
|
|
564
|
+
}
|
|
565
|
+
var hasRequiredReactIs;
|
|
566
|
+
function requireReactIs() {
|
|
567
|
+
return hasRequiredReactIs || (hasRequiredReactIs = 1, reactIs.exports = requireReactIs_production_min()), reactIs.exports;
|
|
568
|
+
}
|
|
569
|
+
var reactIsExports = requireReactIs(), index = getDefaultExportFromCjs(reactIsExports), ReactIs18 = _mergeNamespaces({
|
|
570
|
+
__proto__: null,
|
|
571
|
+
default: index
|
|
572
|
+
}, [reactIsExports]), reactIsMethods = [
|
|
573
|
+
"isAsyncMode",
|
|
574
|
+
"isConcurrentMode",
|
|
575
|
+
"isContextConsumer",
|
|
576
|
+
"isContextProvider",
|
|
577
|
+
"isElement",
|
|
578
|
+
"isForwardRef",
|
|
579
|
+
"isFragment",
|
|
580
|
+
"isLazy",
|
|
581
|
+
"isMemo",
|
|
582
|
+
"isPortal",
|
|
583
|
+
"isProfiler",
|
|
584
|
+
"isStrictMode",
|
|
585
|
+
"isSuspense",
|
|
586
|
+
"isSuspenseList",
|
|
587
|
+
"isValidElementType"
|
|
588
|
+
];
|
|
589
|
+
Object.fromEntries(reactIsMethods.map((m) => [m, (v) => ReactIs18[m](v) || ReactIs19[m](v)]));
|
|
590
|
+
var getPromiseValue = () => "Promise{\u2026}";
|
|
591
|
+
try {
|
|
592
|
+
let { getPromiseDetails, kPending, kRejected } = process.binding("util");
|
|
593
|
+
Array.isArray(getPromiseDetails(Promise.resolve())) && (getPromiseValue = (value, options) => {
|
|
594
|
+
let [state, innerValue] = getPromiseDetails(value);
|
|
595
|
+
return state === kPending ? "Promise{<pending>}" : `Promise${state === kRejected ? "!" : ""}{${options.inspect(innerValue, options)}}`;
|
|
596
|
+
});
|
|
597
|
+
} catch {
|
|
598
|
+
}
|
|
599
|
+
function createSimpleStackTrace(options) {
|
|
600
|
+
let { message = "$$stack trace error", stackTraceLimit = 1 } = options || {}, limit = Error.stackTraceLimit, prepareStackTrace = Error.prepareStackTrace;
|
|
601
|
+
Error.stackTraceLimit = stackTraceLimit, Error.prepareStackTrace = (e) => e.stack;
|
|
602
|
+
let stackTrace = new Error(message).stack || "";
|
|
603
|
+
return Error.prepareStackTrace = prepareStackTrace, Error.stackTraceLimit = limit, stackTrace;
|
|
604
|
+
}
|
|
605
|
+
var jsTokens_1, hasRequiredJsTokens;
|
|
606
|
+
function requireJsTokens() {
|
|
607
|
+
if (hasRequiredJsTokens) return jsTokens_1;
|
|
608
|
+
hasRequiredJsTokens = 1;
|
|
609
|
+
var Identifier, JSXIdentifier, JSXPunctuator, JSXString, JSXText, KeywordsWithExpressionAfter, KeywordsWithNoLineTerminatorAfter, LineTerminatorSequence, MultiLineComment, Newline, NumericLiteral, Punctuator, RegularExpressionLiteral, SingleLineComment, StringLiteral, Template, TokensNotPrecedingObjectLiteral, TokensPrecedingExpression, WhiteSpace;
|
|
610
|
+
return RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\\]).|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/uy, Punctuator = /--|\+\+|=>|\.{3}|\??\.(?!\d)|(?:&&|\|\||\?\?|[+\-%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\/(?![\/*]))=?|[?~,:;[\](){}]/y, Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/uy, StringLiteral = /(['"])(?:(?!\1)[^\\\n\r]|\\(?:\r\n|[^]))*(\1)?/y, 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, Template = /[`}](?:[^`\\$]|\\[^]|\$(?!\{))*(`|\$\{)?/y, WhiteSpace = /[\t\v\f\ufeff\p{Zs}]+/uy, LineTerminatorSequence = /\r?\n|[\r\u2028\u2029]/y, MultiLineComment = /\/\*(?:[^*]|\*(?!\/))*(\*\/)?/y, SingleLineComment = /\/\/.*/y, JSXPunctuator = /[<>.:={}]|\/(?![\/*])/y, JSXIdentifier = /[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}-]*/uy, JSXString = /(['"])(?:(?!\1)[^])*(\1)?/y, JSXText = /[^<>{}]+/y, TokensPrecedingExpression = /^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/, TokensNotPrecedingObjectLiteral = /^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/, KeywordsWithExpressionAfter = /^(?:await|case|default|delete|do|else|instanceof|new|return|throw|typeof|void|yield)$/, KeywordsWithNoLineTerminatorAfter = /^(?:return|throw|yield)$/, Newline = RegExp(LineTerminatorSequence.source), jsTokens_1 = function* (input, { jsx = !1 } = {}) {
|
|
611
|
+
var braces, firstCodePoint, isExpression, lastIndex, lastSignificantToken, length, match, mode, nextLastIndex, nextLastSignificantToken, parenNesting, postfixIncDec, punctuator, stack;
|
|
612
|
+
for ({ length } = input, lastIndex = 0, lastSignificantToken = "", stack = [{ tag: "JS" }], braces = [], parenNesting = 0, postfixIncDec = !1; lastIndex < length; ) {
|
|
613
|
+
switch (mode = stack[stack.length - 1], mode.tag) {
|
|
614
|
+
case "JS":
|
|
615
|
+
case "JSNonExpressionParen":
|
|
616
|
+
case "InterpolationInTemplate":
|
|
617
|
+
case "InterpolationInJSX":
|
|
618
|
+
if (input[lastIndex] === "/" && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken)) && (RegularExpressionLiteral.lastIndex = lastIndex, match = RegularExpressionLiteral.exec(input))) {
|
|
619
|
+
lastIndex = RegularExpressionLiteral.lastIndex, lastSignificantToken = match[0], postfixIncDec = !0, yield {
|
|
620
|
+
type: "RegularExpressionLiteral",
|
|
621
|
+
value: match[0],
|
|
622
|
+
closed: match[1] !== void 0 && match[1] !== "\\"
|
|
623
|
+
};
|
|
624
|
+
continue;
|
|
625
|
+
}
|
|
626
|
+
if (Punctuator.lastIndex = lastIndex, match = Punctuator.exec(input)) {
|
|
627
|
+
switch (punctuator = match[0], nextLastIndex = Punctuator.lastIndex, nextLastSignificantToken = punctuator, punctuator) {
|
|
628
|
+
case "(":
|
|
629
|
+
lastSignificantToken === "?NonExpressionParenKeyword" && stack.push({
|
|
630
|
+
tag: "JSNonExpressionParen",
|
|
631
|
+
nesting: parenNesting
|
|
632
|
+
}), parenNesting++, postfixIncDec = !1;
|
|
633
|
+
break;
|
|
634
|
+
case ")":
|
|
635
|
+
parenNesting--, postfixIncDec = !0, mode.tag === "JSNonExpressionParen" && parenNesting === mode.nesting && (stack.pop(), nextLastSignificantToken = "?NonExpressionParenEnd", postfixIncDec = !1);
|
|
636
|
+
break;
|
|
637
|
+
case "{":
|
|
638
|
+
Punctuator.lastIndex = 0, isExpression = !TokensNotPrecedingObjectLiteral.test(lastSignificantToken) && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken)), braces.push(isExpression), postfixIncDec = !1;
|
|
639
|
+
break;
|
|
640
|
+
case "}":
|
|
641
|
+
switch (mode.tag) {
|
|
642
|
+
case "InterpolationInTemplate":
|
|
643
|
+
if (braces.length === mode.nesting) {
|
|
644
|
+
Template.lastIndex = lastIndex, match = Template.exec(input), lastIndex = Template.lastIndex, lastSignificantToken = match[0], match[1] === "${" ? (lastSignificantToken = "?InterpolationInTemplate", postfixIncDec = !1, yield {
|
|
645
|
+
type: "TemplateMiddle",
|
|
646
|
+
value: match[0]
|
|
647
|
+
}) : (stack.pop(), postfixIncDec = !0, yield {
|
|
648
|
+
type: "TemplateTail",
|
|
649
|
+
value: match[0],
|
|
650
|
+
closed: match[1] === "`"
|
|
651
|
+
});
|
|
652
|
+
continue;
|
|
653
|
+
}
|
|
654
|
+
break;
|
|
655
|
+
case "InterpolationInJSX":
|
|
656
|
+
if (braces.length === mode.nesting) {
|
|
657
|
+
stack.pop(), lastIndex += 1, lastSignificantToken = "}", yield {
|
|
658
|
+
type: "JSXPunctuator",
|
|
659
|
+
value: "}"
|
|
660
|
+
};
|
|
661
|
+
continue;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
postfixIncDec = braces.pop(), nextLastSignificantToken = postfixIncDec ? "?ExpressionBraceEnd" : "}";
|
|
665
|
+
break;
|
|
666
|
+
case "]":
|
|
667
|
+
postfixIncDec = !0;
|
|
668
|
+
break;
|
|
669
|
+
case "++":
|
|
670
|
+
case "--":
|
|
671
|
+
nextLastSignificantToken = postfixIncDec ? "?PostfixIncDec" : "?UnaryIncDec";
|
|
672
|
+
break;
|
|
673
|
+
case "<":
|
|
674
|
+
if (jsx && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
|
|
675
|
+
stack.push({ tag: "JSXTag" }), lastIndex += 1, lastSignificantToken = "<", yield {
|
|
676
|
+
type: "JSXPunctuator",
|
|
677
|
+
value: punctuator
|
|
678
|
+
};
|
|
679
|
+
continue;
|
|
680
|
+
}
|
|
681
|
+
postfixIncDec = !1;
|
|
682
|
+
break;
|
|
683
|
+
default:
|
|
684
|
+
postfixIncDec = !1;
|
|
685
|
+
}
|
|
686
|
+
lastIndex = nextLastIndex, lastSignificantToken = nextLastSignificantToken, yield {
|
|
687
|
+
type: "Punctuator",
|
|
688
|
+
value: punctuator
|
|
689
|
+
};
|
|
690
|
+
continue;
|
|
691
|
+
}
|
|
692
|
+
if (Identifier.lastIndex = lastIndex, match = Identifier.exec(input)) {
|
|
693
|
+
switch (lastIndex = Identifier.lastIndex, nextLastSignificantToken = match[0], match[0]) {
|
|
694
|
+
case "for":
|
|
695
|
+
case "if":
|
|
696
|
+
case "while":
|
|
697
|
+
case "with":
|
|
698
|
+
lastSignificantToken !== "." && lastSignificantToken !== "?." && (nextLastSignificantToken = "?NonExpressionParenKeyword");
|
|
699
|
+
}
|
|
700
|
+
lastSignificantToken = nextLastSignificantToken, postfixIncDec = !KeywordsWithExpressionAfter.test(match[0]), yield {
|
|
701
|
+
type: match[1] === "#" ? "PrivateIdentifier" : "IdentifierName",
|
|
702
|
+
value: match[0]
|
|
703
|
+
};
|
|
704
|
+
continue;
|
|
705
|
+
}
|
|
706
|
+
if (StringLiteral.lastIndex = lastIndex, match = StringLiteral.exec(input)) {
|
|
707
|
+
lastIndex = StringLiteral.lastIndex, lastSignificantToken = match[0], postfixIncDec = !0, yield {
|
|
708
|
+
type: "StringLiteral",
|
|
709
|
+
value: match[0],
|
|
710
|
+
closed: match[2] !== void 0
|
|
711
|
+
};
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
if (NumericLiteral.lastIndex = lastIndex, match = NumericLiteral.exec(input)) {
|
|
715
|
+
lastIndex = NumericLiteral.lastIndex, lastSignificantToken = match[0], postfixIncDec = !0, yield {
|
|
716
|
+
type: "NumericLiteral",
|
|
717
|
+
value: match[0]
|
|
718
|
+
};
|
|
719
|
+
continue;
|
|
720
|
+
}
|
|
721
|
+
if (Template.lastIndex = lastIndex, match = Template.exec(input)) {
|
|
722
|
+
lastIndex = Template.lastIndex, lastSignificantToken = match[0], match[1] === "${" ? (lastSignificantToken = "?InterpolationInTemplate", stack.push({
|
|
723
|
+
tag: "InterpolationInTemplate",
|
|
724
|
+
nesting: braces.length
|
|
725
|
+
}), postfixIncDec = !1, yield {
|
|
726
|
+
type: "TemplateHead",
|
|
727
|
+
value: match[0]
|
|
728
|
+
}) : (postfixIncDec = !0, yield {
|
|
729
|
+
type: "NoSubstitutionTemplate",
|
|
730
|
+
value: match[0],
|
|
731
|
+
closed: match[1] === "`"
|
|
732
|
+
});
|
|
733
|
+
continue;
|
|
734
|
+
}
|
|
735
|
+
break;
|
|
736
|
+
case "JSXTag":
|
|
737
|
+
case "JSXTagEnd":
|
|
738
|
+
if (JSXPunctuator.lastIndex = lastIndex, match = JSXPunctuator.exec(input)) {
|
|
739
|
+
switch (lastIndex = JSXPunctuator.lastIndex, nextLastSignificantToken = match[0], match[0]) {
|
|
740
|
+
case "<":
|
|
741
|
+
stack.push({ tag: "JSXTag" });
|
|
742
|
+
break;
|
|
743
|
+
case ">":
|
|
744
|
+
stack.pop(), lastSignificantToken === "/" || mode.tag === "JSXTagEnd" ? (nextLastSignificantToken = "?JSX", postfixIncDec = !0) : stack.push({ tag: "JSXChildren" });
|
|
745
|
+
break;
|
|
746
|
+
case "{":
|
|
747
|
+
stack.push({
|
|
748
|
+
tag: "InterpolationInJSX",
|
|
749
|
+
nesting: braces.length
|
|
750
|
+
}), nextLastSignificantToken = "?InterpolationInJSX", postfixIncDec = !1;
|
|
751
|
+
break;
|
|
752
|
+
case "/":
|
|
753
|
+
lastSignificantToken === "<" && (stack.pop(), stack[stack.length - 1].tag === "JSXChildren" && stack.pop(), stack.push({ tag: "JSXTagEnd" }));
|
|
754
|
+
}
|
|
755
|
+
lastSignificantToken = nextLastSignificantToken, yield {
|
|
756
|
+
type: "JSXPunctuator",
|
|
757
|
+
value: match[0]
|
|
758
|
+
};
|
|
759
|
+
continue;
|
|
760
|
+
}
|
|
761
|
+
if (JSXIdentifier.lastIndex = lastIndex, match = JSXIdentifier.exec(input)) {
|
|
762
|
+
lastIndex = JSXIdentifier.lastIndex, lastSignificantToken = match[0], yield {
|
|
763
|
+
type: "JSXIdentifier",
|
|
764
|
+
value: match[0]
|
|
765
|
+
};
|
|
766
|
+
continue;
|
|
767
|
+
}
|
|
768
|
+
if (JSXString.lastIndex = lastIndex, match = JSXString.exec(input)) {
|
|
769
|
+
lastIndex = JSXString.lastIndex, lastSignificantToken = match[0], yield {
|
|
770
|
+
type: "JSXString",
|
|
771
|
+
value: match[0],
|
|
772
|
+
closed: match[2] !== void 0
|
|
773
|
+
};
|
|
774
|
+
continue;
|
|
775
|
+
}
|
|
776
|
+
break;
|
|
777
|
+
case "JSXChildren":
|
|
778
|
+
if (JSXText.lastIndex = lastIndex, match = JSXText.exec(input)) {
|
|
779
|
+
lastIndex = JSXText.lastIndex, lastSignificantToken = match[0], yield {
|
|
780
|
+
type: "JSXText",
|
|
781
|
+
value: match[0]
|
|
782
|
+
};
|
|
783
|
+
continue;
|
|
784
|
+
}
|
|
785
|
+
switch (input[lastIndex]) {
|
|
786
|
+
case "<":
|
|
787
|
+
stack.push({ tag: "JSXTag" }), lastIndex++, lastSignificantToken = "<", yield {
|
|
788
|
+
type: "JSXPunctuator",
|
|
789
|
+
value: "<"
|
|
790
|
+
};
|
|
791
|
+
continue;
|
|
792
|
+
case "{":
|
|
793
|
+
stack.push({
|
|
794
|
+
tag: "InterpolationInJSX",
|
|
795
|
+
nesting: braces.length
|
|
796
|
+
}), lastIndex++, lastSignificantToken = "?InterpolationInJSX", postfixIncDec = !1, yield {
|
|
797
|
+
type: "JSXPunctuator",
|
|
798
|
+
value: "{"
|
|
799
|
+
};
|
|
800
|
+
continue;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
if (WhiteSpace.lastIndex = lastIndex, match = WhiteSpace.exec(input)) {
|
|
804
|
+
lastIndex = WhiteSpace.lastIndex, yield {
|
|
805
|
+
type: "WhiteSpace",
|
|
806
|
+
value: match[0]
|
|
807
|
+
};
|
|
808
|
+
continue;
|
|
809
|
+
}
|
|
810
|
+
if (LineTerminatorSequence.lastIndex = lastIndex, match = LineTerminatorSequence.exec(input)) {
|
|
811
|
+
lastIndex = LineTerminatorSequence.lastIndex, postfixIncDec = !1, KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken) && (lastSignificantToken = "?NoLineTerminatorHere"), yield {
|
|
812
|
+
type: "LineTerminatorSequence",
|
|
813
|
+
value: match[0]
|
|
814
|
+
};
|
|
815
|
+
continue;
|
|
816
|
+
}
|
|
817
|
+
if (MultiLineComment.lastIndex = lastIndex, match = MultiLineComment.exec(input)) {
|
|
818
|
+
lastIndex = MultiLineComment.lastIndex, Newline.test(match[0]) && (postfixIncDec = !1, KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken) && (lastSignificantToken = "?NoLineTerminatorHere")), yield {
|
|
819
|
+
type: "MultiLineComment",
|
|
820
|
+
value: match[0],
|
|
821
|
+
closed: match[1] !== void 0
|
|
822
|
+
};
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
if (SingleLineComment.lastIndex = lastIndex, match = SingleLineComment.exec(input)) {
|
|
826
|
+
lastIndex = SingleLineComment.lastIndex, postfixIncDec = !1, yield {
|
|
827
|
+
type: "SingleLineComment",
|
|
828
|
+
value: match[0]
|
|
829
|
+
};
|
|
830
|
+
continue;
|
|
831
|
+
}
|
|
832
|
+
firstCodePoint = String.fromCodePoint(input.codePointAt(lastIndex)), lastIndex += firstCodePoint.length, lastSignificantToken = firstCodePoint, postfixIncDec = !1, yield {
|
|
833
|
+
type: mode.tag.startsWith("JSX") ? "JSXInvalid" : "Invalid",
|
|
834
|
+
value: firstCodePoint
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
}, jsTokens_1;
|
|
838
|
+
}
|
|
839
|
+
requireJsTokens();
|
|
840
|
+
var reservedWords = {
|
|
841
|
+
keyword: [
|
|
842
|
+
"break",
|
|
843
|
+
"case",
|
|
844
|
+
"catch",
|
|
845
|
+
"continue",
|
|
846
|
+
"debugger",
|
|
847
|
+
"default",
|
|
848
|
+
"do",
|
|
849
|
+
"else",
|
|
850
|
+
"finally",
|
|
851
|
+
"for",
|
|
852
|
+
"function",
|
|
853
|
+
"if",
|
|
854
|
+
"return",
|
|
855
|
+
"switch",
|
|
856
|
+
"throw",
|
|
857
|
+
"try",
|
|
858
|
+
"var",
|
|
859
|
+
"const",
|
|
860
|
+
"while",
|
|
861
|
+
"with",
|
|
862
|
+
"new",
|
|
863
|
+
"this",
|
|
864
|
+
"super",
|
|
865
|
+
"class",
|
|
866
|
+
"extends",
|
|
867
|
+
"export",
|
|
868
|
+
"import",
|
|
869
|
+
"null",
|
|
870
|
+
"true",
|
|
871
|
+
"false",
|
|
872
|
+
"in",
|
|
873
|
+
"instanceof",
|
|
874
|
+
"typeof",
|
|
875
|
+
"void",
|
|
876
|
+
"delete"
|
|
877
|
+
],
|
|
878
|
+
strict: [
|
|
879
|
+
"implements",
|
|
880
|
+
"interface",
|
|
881
|
+
"let",
|
|
882
|
+
"package",
|
|
883
|
+
"private",
|
|
884
|
+
"protected",
|
|
885
|
+
"public",
|
|
886
|
+
"static",
|
|
887
|
+
"yield"
|
|
888
|
+
]
|
|
889
|
+
};
|
|
890
|
+
new Set(reservedWords.keyword);
|
|
891
|
+
new Set(reservedWords.strict);
|
|
892
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", intToChar = new Uint8Array(64), charToInt = new Uint8Array(128);
|
|
893
|
+
for (let i = 0; i < chars.length; i++) {
|
|
894
|
+
let c = chars.charCodeAt(i);
|
|
895
|
+
intToChar[i] = c, charToInt[c] = i;
|
|
896
|
+
}
|
|
897
|
+
var UrlType;
|
|
898
|
+
(function(UrlType2) {
|
|
899
|
+
UrlType2[UrlType2.Empty = 1] = "Empty", UrlType2[UrlType2.Hash = 2] = "Hash", UrlType2[UrlType2.Query = 3] = "Query", UrlType2[UrlType2.RelativePath = 4] = "RelativePath", UrlType2[UrlType2.AbsolutePath = 5] = "AbsolutePath", UrlType2[UrlType2.SchemeRelative = 6] = "SchemeRelative", UrlType2[UrlType2.Absolute = 7] = "Absolute";
|
|
900
|
+
})(UrlType || (UrlType = {}));
|
|
901
|
+
var _DRIVE_LETTER_START_RE2 = /^[A-Za-z]:\//;
|
|
902
|
+
function normalizeWindowsPath2(input = "") {
|
|
903
|
+
return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE2, (r) => r.toUpperCase());
|
|
904
|
+
}
|
|
905
|
+
var _IS_ABSOLUTE_RE2 = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
906
|
+
function cwd() {
|
|
907
|
+
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
|
908
|
+
}
|
|
909
|
+
var resolve = function(...arguments_) {
|
|
910
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath2(argument));
|
|
911
|
+
let resolvedPath = "", resolvedAbsolute = !1;
|
|
912
|
+
for (let index2 = arguments_.length - 1; index2 >= -1 && !resolvedAbsolute; index2--) {
|
|
913
|
+
let path = index2 >= 0 ? arguments_[index2] : cwd();
|
|
914
|
+
!path || path.length === 0 || (resolvedPath = `${path}/${resolvedPath}`, resolvedAbsolute = isAbsolute2(path));
|
|
915
|
+
}
|
|
916
|
+
return resolvedPath = normalizeString2(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute2(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : ".";
|
|
917
|
+
};
|
|
918
|
+
function normalizeString2(path, allowAboveRoot) {
|
|
919
|
+
let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
|
|
920
|
+
for (let index2 = 0; index2 <= path.length; ++index2) {
|
|
921
|
+
if (index2 < path.length)
|
|
922
|
+
char = path[index2];
|
|
923
|
+
else {
|
|
924
|
+
if (char === "/")
|
|
925
|
+
break;
|
|
926
|
+
char = "/";
|
|
927
|
+
}
|
|
928
|
+
if (char === "/") {
|
|
929
|
+
if (!(lastSlash === index2 - 1 || dots === 1)) if (dots === 2) {
|
|
930
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
931
|
+
if (res.length > 2) {
|
|
932
|
+
let lastSlashIndex = res.lastIndexOf("/");
|
|
933
|
+
lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index2, dots = 0;
|
|
934
|
+
continue;
|
|
935
|
+
} else if (res.length > 0) {
|
|
936
|
+
res = "", lastSegmentLength = 0, lastSlash = index2, dots = 0;
|
|
937
|
+
continue;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
|
|
941
|
+
} else
|
|
942
|
+
res.length > 0 ? res += `/${path.slice(lastSlash + 1, index2)}` : res = path.slice(lastSlash + 1, index2), lastSegmentLength = index2 - lastSlash - 1;
|
|
943
|
+
lastSlash = index2, dots = 0;
|
|
944
|
+
} else char === "." && dots !== -1 ? ++dots : dots = -1;
|
|
945
|
+
}
|
|
946
|
+
return res;
|
|
947
|
+
}
|
|
948
|
+
var isAbsolute2 = function(p2) {
|
|
949
|
+
return _IS_ABSOLUTE_RE2.test(p2);
|
|
950
|
+
}, CHROME_IE_STACK_REGEXP = /^\s*at .*(?:\S:\d+|\(native\))/m, SAFARI_NATIVE_CODE_REGEXP = /^(?:eval@)?(?:\[native code\])?$/;
|
|
951
|
+
function extractLocation(urlLike) {
|
|
952
|
+
if (!urlLike.includes(":"))
|
|
953
|
+
return [urlLike];
|
|
954
|
+
let parts = /(.+?)(?::(\d+))?(?::(\d+))?$/.exec(urlLike.replace(/^\(|\)$/g, ""));
|
|
955
|
+
if (!parts)
|
|
956
|
+
return [urlLike];
|
|
957
|
+
let url = parts[1];
|
|
958
|
+
if (url.startsWith("async ") && (url = url.slice(6)), url.startsWith("http:") || url.startsWith("https:")) {
|
|
959
|
+
let urlObj = new URL(url);
|
|
960
|
+
urlObj.searchParams.delete("import"), urlObj.searchParams.delete("browserv"), url = urlObj.pathname + urlObj.hash + urlObj.search;
|
|
961
|
+
}
|
|
962
|
+
if (url.startsWith("/@fs/")) {
|
|
963
|
+
let isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
|
|
964
|
+
url = url.slice(isWindows ? 5 : 4);
|
|
965
|
+
}
|
|
966
|
+
return [
|
|
967
|
+
url,
|
|
968
|
+
parts[2] || void 0,
|
|
969
|
+
parts[3] || void 0
|
|
970
|
+
];
|
|
971
|
+
}
|
|
972
|
+
function parseSingleFFOrSafariStack(raw) {
|
|
973
|
+
let line = raw.trim();
|
|
974
|
+
if (SAFARI_NATIVE_CODE_REGEXP.test(line) || (line.includes(" > eval") && (line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1")), !line.includes("@") && !line.includes(":")))
|
|
975
|
+
return null;
|
|
976
|
+
let functionNameRegex = /((.*".+"[^@]*)?[^@]*)(@)/, matches = line.match(functionNameRegex), functionName = matches && matches[1] ? matches[1] : void 0, [url, lineNumber, columnNumber] = extractLocation(line.replace(functionNameRegex, ""));
|
|
977
|
+
return !url || !lineNumber || !columnNumber ? null : {
|
|
978
|
+
file: url,
|
|
979
|
+
method: functionName || "",
|
|
980
|
+
line: Number.parseInt(lineNumber),
|
|
981
|
+
column: Number.parseInt(columnNumber)
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
function parseSingleStack(raw) {
|
|
985
|
+
let line = raw.trim();
|
|
986
|
+
return CHROME_IE_STACK_REGEXP.test(line) ? parseSingleV8Stack(line) : parseSingleFFOrSafariStack(line);
|
|
987
|
+
}
|
|
988
|
+
function parseSingleV8Stack(raw) {
|
|
989
|
+
let line = raw.trim();
|
|
990
|
+
if (!CHROME_IE_STACK_REGEXP.test(line))
|
|
991
|
+
return null;
|
|
992
|
+
line.includes("(eval ") && (line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, ""));
|
|
993
|
+
let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, ""), location2 = sanitizedLine.match(/ (\(.+\)$)/);
|
|
994
|
+
sanitizedLine = location2 ? sanitizedLine.replace(location2[0], "") : sanitizedLine;
|
|
995
|
+
let [url, lineNumber, columnNumber] = extractLocation(location2 ? location2[1] : sanitizedLine), method = location2 && sanitizedLine || "", file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
|
|
996
|
+
return !file || !lineNumber || !columnNumber ? null : (method.startsWith("async ") && (method = method.slice(6)), file.startsWith("file://") && (file = file.slice(7)), file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve(file), method && (method = method.replace(/__vite_ssr_import_\d+__\./g, "")), {
|
|
997
|
+
method,
|
|
998
|
+
file,
|
|
999
|
+
line: Number.parseInt(lineNumber),
|
|
1000
|
+
column: Number.parseInt(columnNumber)
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
function createCompilerHints(options) {
|
|
1004
|
+
let globalThisAccessor = options?.globalThisKey || "__vitest_mocker__";
|
|
1005
|
+
function _mocker() {
|
|
1006
|
+
return typeof globalThis[globalThisAccessor] < "u" ? globalThis[globalThisAccessor] : new Proxy({}, { get(_, name) {
|
|
1007
|
+
throw new Error(`Vitest mocker was not initialized in this environment. vi.${String(name)}() is forbidden.`);
|
|
1008
|
+
} });
|
|
1009
|
+
}
|
|
1010
|
+
return {
|
|
1011
|
+
hoisted(factory) {
|
|
1012
|
+
if (typeof factory != "function")
|
|
1013
|
+
throw new TypeError(`vi.hoisted() expects a function, but received a ${typeof factory}`);
|
|
1014
|
+
return factory();
|
|
1015
|
+
},
|
|
1016
|
+
mock(path, factory) {
|
|
1017
|
+
if (typeof path != "string")
|
|
1018
|
+
throw new TypeError(`vi.mock() expects a string path, but received a ${typeof path}`);
|
|
1019
|
+
let importer = getImporter("mock");
|
|
1020
|
+
_mocker().queueMock(path, importer, typeof factory == "function" ? () => factory(() => _mocker().importActual(path, importer)) : factory);
|
|
1021
|
+
},
|
|
1022
|
+
unmock(path) {
|
|
1023
|
+
if (typeof path != "string")
|
|
1024
|
+
throw new TypeError(`vi.unmock() expects a string path, but received a ${typeof path}`);
|
|
1025
|
+
_mocker().queueUnmock(path, getImporter("unmock"));
|
|
1026
|
+
},
|
|
1027
|
+
doMock(path, factory) {
|
|
1028
|
+
if (typeof path != "string")
|
|
1029
|
+
throw new TypeError(`vi.doMock() expects a string path, but received a ${typeof path}`);
|
|
1030
|
+
let importer = getImporter("doMock");
|
|
1031
|
+
_mocker().queueMock(path, importer, typeof factory == "function" ? () => factory(() => _mocker().importActual(path, importer)) : factory);
|
|
1032
|
+
},
|
|
1033
|
+
doUnmock(path) {
|
|
1034
|
+
if (typeof path != "string")
|
|
1035
|
+
throw new TypeError(`vi.doUnmock() expects a string path, but received a ${typeof path}`);
|
|
1036
|
+
_mocker().queueUnmock(path, getImporter("doUnmock"));
|
|
1037
|
+
},
|
|
1038
|
+
async importActual(path) {
|
|
1039
|
+
return _mocker().importActual(path, getImporter("importActual"));
|
|
1040
|
+
},
|
|
1041
|
+
async importMock(path) {
|
|
1042
|
+
return _mocker().importMock(path, getImporter("importMock"));
|
|
1043
|
+
}
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
function getImporter(name) {
|
|
1047
|
+
let stackArray = createSimpleStackTrace({ stackTraceLimit: 5 }).split(`
|
|
1048
|
+
`), importerStackIndex = stackArray.findIndex((stack2) => stack2.includes(` at Object.${name}`) || stack2.includes(`${name}@`)), stack = parseSingleStack(stackArray[importerStackIndex + 1]);
|
|
1049
|
+
return stack?.file || "";
|
|
1050
|
+
}
|
|
1051
|
+
var hot = import.meta.hot || {
|
|
1052
|
+
on: warn,
|
|
1053
|
+
off: warn,
|
|
1054
|
+
send: warn
|
|
1055
|
+
};
|
|
1056
|
+
function warn() {
|
|
1057
|
+
console.warn("Vitest mocker cannot work if Vite didn't establish WS connection.");
|
|
1058
|
+
}
|
|
1059
|
+
var { now } = Date, ModuleMocker = class {
|
|
1060
|
+
registry = new MockerRegistry();
|
|
1061
|
+
queue = /* @__PURE__ */ new Set();
|
|
1062
|
+
mockedIds = /* @__PURE__ */ new Set();
|
|
1063
|
+
constructor(interceptor, rpc3, spyOn, config) {
|
|
1064
|
+
this.interceptor = interceptor, this.rpc = rpc3, this.spyOn = spyOn, this.config = config;
|
|
1065
|
+
}
|
|
1066
|
+
async prepare() {
|
|
1067
|
+
this.queue.size && await Promise.all([...this.queue.values()]);
|
|
1068
|
+
}
|
|
1069
|
+
async resolveFactoryModule(id) {
|
|
1070
|
+
let mock = this.registry.get(id);
|
|
1071
|
+
if (!mock || mock.type !== "manual")
|
|
1072
|
+
throw new Error(`Mock ${id} wasn't registered. This is probably a Vitest error. Please, open a new issue with reproduction.`);
|
|
1073
|
+
return await mock.resolve();
|
|
1074
|
+
}
|
|
1075
|
+
getFactoryModule(id) {
|
|
1076
|
+
let mock = this.registry.get(id);
|
|
1077
|
+
if (!mock || mock.type !== "manual")
|
|
1078
|
+
throw new Error(`Mock ${id} wasn't registered. This is probably a Vitest error. Please, open a new issue with reproduction.`);
|
|
1079
|
+
if (!mock.cache)
|
|
1080
|
+
throw new Error(`Mock ${id} wasn't resolved. This is probably a Vitest error. Please, open a new issue with reproduction.`);
|
|
1081
|
+
return mock.cache;
|
|
1082
|
+
}
|
|
1083
|
+
async invalidate() {
|
|
1084
|
+
let ids = Array.from(this.mockedIds);
|
|
1085
|
+
ids.length && (await this.rpc.invalidate(ids), await this.interceptor.invalidate(), this.registry.clear());
|
|
1086
|
+
}
|
|
1087
|
+
async importActual(id, importer) {
|
|
1088
|
+
let resolved = await this.rpc.resolveId(id, importer);
|
|
1089
|
+
if (resolved == null)
|
|
1090
|
+
throw new Error(`[vitest] Cannot resolve "${id}" imported from "${importer}"`);
|
|
1091
|
+
let ext = extname(resolved.id), url = new URL(resolved.url, location.href), query = `_vitest_original&ext${ext}`, actualUrl = `${url.pathname}${url.search ? `${url.search}&${query}` : `?${query}`}${url.hash}`;
|
|
1092
|
+
return this.wrapDynamicImport(() => import(
|
|
1093
|
+
/* @vite-ignore */
|
|
1094
|
+
actualUrl
|
|
1095
|
+
)).then((mod) => {
|
|
1096
|
+
if (!resolved.optimized || typeof mod.default > "u")
|
|
1097
|
+
return mod;
|
|
1098
|
+
let m = mod.default;
|
|
1099
|
+
return m?.__esModule ? m : {
|
|
1100
|
+
...typeof m == "object" && !Array.isArray(m) || typeof m == "function" ? m : {},
|
|
1101
|
+
default: m
|
|
1102
|
+
};
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
async importMock(rawId, importer) {
|
|
1106
|
+
await this.prepare();
|
|
1107
|
+
let { resolvedId, resolvedUrl, redirectUrl } = await this.rpc.resolveMock(rawId, importer, { mock: "auto" }), mockUrl = this.resolveMockPath(cleanVersion(resolvedUrl)), mock = this.registry.get(mockUrl);
|
|
1108
|
+
if (!mock)
|
|
1109
|
+
if (redirectUrl) {
|
|
1110
|
+
let resolvedRedirect = new URL(this.resolveMockPath(cleanVersion(redirectUrl)), location.href).toString();
|
|
1111
|
+
mock = new RedirectedModule(rawId, resolvedId, mockUrl, resolvedRedirect);
|
|
1112
|
+
} else
|
|
1113
|
+
mock = new AutomockedModule(rawId, resolvedId, mockUrl);
|
|
1114
|
+
if (mock.type === "manual")
|
|
1115
|
+
return await mock.resolve();
|
|
1116
|
+
if (mock.type === "automock" || mock.type === "autospy") {
|
|
1117
|
+
let url = new URL(`/@id/${resolvedId}`, location.href), query = url.search ? `${url.search}&t=${now()}` : `?t=${now()}`, moduleObject = await import(
|
|
1118
|
+
/* @vite-ignore */
|
|
1119
|
+
`${url.pathname}${query}&mock=${mock.type}${url.hash}`
|
|
1120
|
+
);
|
|
1121
|
+
return this.mockObject(moduleObject, mock.type);
|
|
1122
|
+
}
|
|
1123
|
+
return import(
|
|
1124
|
+
/* @vite-ignore */
|
|
1125
|
+
mock.redirect
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
mockObject(object, moduleType = "automock") {
|
|
1129
|
+
return mockObject({
|
|
1130
|
+
globalConstructors: {
|
|
1131
|
+
Object,
|
|
1132
|
+
Function,
|
|
1133
|
+
Array,
|
|
1134
|
+
Map,
|
|
1135
|
+
RegExp
|
|
1136
|
+
},
|
|
1137
|
+
spyOn: this.spyOn,
|
|
1138
|
+
type: moduleType
|
|
1139
|
+
}, object);
|
|
1140
|
+
}
|
|
1141
|
+
queueMock(rawId, importer, factoryOrOptions) {
|
|
1142
|
+
let promise = this.rpc.resolveMock(rawId, importer, { mock: typeof factoryOrOptions == "function" ? "factory" : factoryOrOptions?.spy ? "spy" : "auto" }).then(async ({ redirectUrl, resolvedId, resolvedUrl, needsInterop, mockType }) => {
|
|
1143
|
+
let mockUrl = this.resolveMockPath(cleanVersion(resolvedUrl));
|
|
1144
|
+
this.mockedIds.add(resolvedId);
|
|
1145
|
+
let factory = typeof factoryOrOptions == "function" ? async () => {
|
|
1146
|
+
let data = await factoryOrOptions();
|
|
1147
|
+
return needsInterop ? { default: data } : data;
|
|
1148
|
+
} : void 0, mockRedirect = typeof redirectUrl == "string" ? new URL(this.resolveMockPath(cleanVersion(redirectUrl)), location.href).toString() : null, module;
|
|
1149
|
+
mockType === "manual" ? module = this.registry.register("manual", rawId, resolvedId, mockUrl, factory) : mockType === "autospy" ? module = this.registry.register("autospy", rawId, resolvedId, mockUrl) : mockType === "redirect" ? module = this.registry.register("redirect", rawId, resolvedId, mockUrl, mockRedirect) : module = this.registry.register("automock", rawId, resolvedId, mockUrl), await this.interceptor.register(module);
|
|
1150
|
+
}).finally(() => {
|
|
1151
|
+
this.queue.delete(promise);
|
|
1152
|
+
});
|
|
1153
|
+
this.queue.add(promise);
|
|
1154
|
+
}
|
|
1155
|
+
queueUnmock(id, importer) {
|
|
1156
|
+
let promise = this.rpc.resolveId(id, importer).then(async (resolved) => {
|
|
1157
|
+
if (!resolved)
|
|
1158
|
+
return;
|
|
1159
|
+
let mockUrl = this.resolveMockPath(cleanVersion(resolved.url));
|
|
1160
|
+
this.mockedIds.add(resolved.id), this.registry.delete(mockUrl), await this.interceptor.delete(mockUrl);
|
|
1161
|
+
}).finally(() => {
|
|
1162
|
+
this.queue.delete(promise);
|
|
1163
|
+
});
|
|
1164
|
+
this.queue.add(promise);
|
|
1165
|
+
}
|
|
1166
|
+
// We need to await mock registration before importing the actual module
|
|
1167
|
+
// In case there is a mocked module in the import chain
|
|
1168
|
+
wrapDynamicImport(moduleFactory) {
|
|
1169
|
+
return typeof moduleFactory == "function" ? new Promise((resolve2, reject) => {
|
|
1170
|
+
this.prepare().finally(() => {
|
|
1171
|
+
moduleFactory().then(resolve2, reject);
|
|
1172
|
+
});
|
|
1173
|
+
}) : moduleFactory;
|
|
1174
|
+
}
|
|
1175
|
+
resolveMockPath(path) {
|
|
1176
|
+
let config = this.config, fsRoot = join("/@fs/", config.root);
|
|
1177
|
+
return path.startsWith(config.root) ? path.slice(config.root.length) : path.startsWith(fsRoot) ? path.slice(fsRoot.length) : path;
|
|
1178
|
+
}
|
|
1179
|
+
}, versionRegexp = /(\?|&)v=\w{8}/;
|
|
1180
|
+
function cleanVersion(url) {
|
|
1181
|
+
return url.replace(versionRegexp, "");
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
// src/mocking-utils/mocker-runtime.js
|
|
1185
|
+
var ModuleMockerInterceptor = class {
|
|
1186
|
+
// A registry for runtime mocks (e.g., `sb.mock('path', () => ({}))`)
|
|
1187
|
+
mocks = new MockerRegistry();
|
|
1188
|
+
constructor() {
|
|
1189
|
+
}
|
|
1190
|
+
/**
|
|
1191
|
+
* Called by ModuleMocker when `sb.mock()` is executed. We just store the mock in our registry.
|
|
1192
|
+
* The dynamic MSW handler will pick it up on the next relevant network request. Currently, we
|
|
1193
|
+
* don't use this.mocks in any way. Mocks will be registered in the user's preview file and live
|
|
1194
|
+
* until the end. There is no way to invalidate or delete them.
|
|
1195
|
+
*/
|
|
1196
|
+
async register(module) {
|
|
1197
|
+
this.mocks.add(module);
|
|
1198
|
+
}
|
|
1199
|
+
async delete(url) {
|
|
1200
|
+
this.mocks.delete(url);
|
|
1201
|
+
}
|
|
1202
|
+
async invalidate() {
|
|
1203
|
+
this.mocks.clear();
|
|
1204
|
+
}
|
|
1205
|
+
}, rpc2 = (method) => {
|
|
1206
|
+
switch (method) {
|
|
1207
|
+
case "resolveId":
|
|
1208
|
+
return Promise.resolve({
|
|
1209
|
+
id: "",
|
|
1210
|
+
url: "",
|
|
1211
|
+
optimized: !1
|
|
1212
|
+
});
|
|
1213
|
+
case "resolveMock":
|
|
1214
|
+
return Promise.resolve({
|
|
1215
|
+
mockType: "dummy",
|
|
1216
|
+
resolvedId: "",
|
|
1217
|
+
resolvedUrl: "",
|
|
1218
|
+
redirectUrl: "",
|
|
1219
|
+
needsInterop: !1
|
|
1220
|
+
});
|
|
1221
|
+
case "invalidate":
|
|
1222
|
+
return Promise.resolve();
|
|
1223
|
+
}
|
|
1224
|
+
}, BuildModuleMocker = class extends ModuleMocker {
|
|
1225
|
+
queueMock() {
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
function registerModuleMocker(interceptor) {
|
|
1229
|
+
let mocker = new BuildModuleMocker(
|
|
1230
|
+
interceptor("__vitest_mocker__"),
|
|
1231
|
+
{
|
|
1232
|
+
resolveId(id, importer) {
|
|
1233
|
+
return rpc2("resolveId", { id, importer });
|
|
1234
|
+
},
|
|
1235
|
+
resolveMock(id, importer, options) {
|
|
1236
|
+
return rpc2("resolveMock", { id, importer, options });
|
|
1237
|
+
},
|
|
1238
|
+
async invalidate(ids) {
|
|
1239
|
+
return rpc2("invalidate", { ids });
|
|
1240
|
+
}
|
|
1241
|
+
},
|
|
1242
|
+
(...args) => globalThis.__STORYBOOK_MODULE_TEST__.spyOn(...args),
|
|
1243
|
+
{
|
|
1244
|
+
root: ""
|
|
1245
|
+
}
|
|
1246
|
+
);
|
|
1247
|
+
return globalThis.__vitest_mocker__ = mocker, createCompilerHints({
|
|
1248
|
+
globalThisKey: "__vitest_mocker__"
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
globalThis.__STORYBOOK_MOCKER__ = registerModuleMocker(() => new ModuleMockerInterceptor());
|
|
1252
|
+
export {
|
|
1253
|
+
ModuleMockerInterceptor
|
|
1254
|
+
};
|