@vitest/snapshot 4.0.0-beta.8 → 4.0.0
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/index.d.ts +0 -7
- package/dist/index.js +163 -976
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -20,11 +20,6 @@ declare class DefaultMap<
|
|
|
20
20
|
}
|
|
21
21
|
declare class CounterMap<K> extends DefaultMap<K, number> {
|
|
22
22
|
constructor();
|
|
23
|
-
// compat for jest-image-snapshot https://github.com/vitest-dev/vitest/issues/7322
|
|
24
|
-
// `valueOf` and `Snapshot.added` setter allows
|
|
25
|
-
// snapshotState.added = snapshotState.added + 1
|
|
26
|
-
// to function as
|
|
27
|
-
// snapshotState.added.total_ = snapshotState.added.total() + 1
|
|
28
23
|
_total: number | undefined;
|
|
29
24
|
valueOf(): number;
|
|
30
25
|
increment(key: K): void;
|
|
@@ -59,8 +54,6 @@ declare class SnapshotState {
|
|
|
59
54
|
private _environment;
|
|
60
55
|
private _fileExists;
|
|
61
56
|
expand: boolean;
|
|
62
|
-
// getter/setter for jest-image-snapshot compat
|
|
63
|
-
// https://github.com/vitest-dev/vitest/issues/7322
|
|
64
57
|
private _added;
|
|
65
58
|
private _matched;
|
|
66
59
|
private _unmatched;
|
package/dist/index.js
CHANGED
|
@@ -1,364 +1,107 @@
|
|
|
1
|
-
import { resolve
|
|
1
|
+
import { resolve } from 'pathe';
|
|
2
2
|
import { plugins, format } from '@vitest/pretty-format';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
// src/vlq.ts
|
|
5
|
+
var comma = ",".charCodeAt(0);
|
|
6
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
7
|
+
var intToChar = new Uint8Array(64);
|
|
8
|
+
var charToInt = new Uint8Array(128);
|
|
8
9
|
for (let i = 0; i < chars.length; i++) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const c = chars.charCodeAt(i);
|
|
11
|
+
intToChar[i] = c;
|
|
12
|
+
charToInt[c] = i;
|
|
12
13
|
}
|
|
13
14
|
function decodeInteger(reader, relative) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
let value = 0;
|
|
16
|
+
let shift = 0;
|
|
17
|
+
let integer = 0;
|
|
18
|
+
do {
|
|
19
|
+
const c = reader.next();
|
|
20
|
+
integer = charToInt[c];
|
|
21
|
+
value |= (integer & 31) << shift;
|
|
22
|
+
shift += 5;
|
|
23
|
+
} while (integer & 32);
|
|
24
|
+
const shouldNegate = value & 1;
|
|
25
|
+
value >>>= 1;
|
|
26
|
+
if (shouldNegate) {
|
|
27
|
+
value = -2147483648 | -value;
|
|
28
|
+
}
|
|
29
|
+
return relative + value;
|
|
29
30
|
}
|
|
30
31
|
function hasMoreVlq(reader, max) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return reader.peek() !== comma;
|
|
34
|
-
}
|
|
35
|
-
class StringReader {
|
|
36
|
-
constructor(buffer) {
|
|
37
|
-
this.pos = 0;
|
|
38
|
-
this.buffer = buffer;
|
|
39
|
-
}
|
|
40
|
-
next() {
|
|
41
|
-
return this.buffer.charCodeAt(this.pos++);
|
|
42
|
-
}
|
|
43
|
-
peek() {
|
|
44
|
-
return this.buffer.charCodeAt(this.pos);
|
|
45
|
-
}
|
|
46
|
-
indexOf(char) {
|
|
47
|
-
const { buffer, pos } = this;
|
|
48
|
-
const idx = buffer.indexOf(char, pos);
|
|
49
|
-
return idx === -1 ? buffer.length : idx;
|
|
50
|
-
}
|
|
32
|
+
if (reader.pos >= max) return false;
|
|
33
|
+
return reader.peek() !== comma;
|
|
51
34
|
}
|
|
35
|
+
var StringReader = class {
|
|
36
|
+
constructor(buffer) {
|
|
37
|
+
this.pos = 0;
|
|
38
|
+
this.buffer = buffer;
|
|
39
|
+
}
|
|
40
|
+
next() {
|
|
41
|
+
return this.buffer.charCodeAt(this.pos++);
|
|
42
|
+
}
|
|
43
|
+
peek() {
|
|
44
|
+
return this.buffer.charCodeAt(this.pos);
|
|
45
|
+
}
|
|
46
|
+
indexOf(char) {
|
|
47
|
+
const { buffer, pos } = this;
|
|
48
|
+
const idx = buffer.indexOf(char, pos);
|
|
49
|
+
return idx === -1 ? buffer.length : idx;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
52
|
|
|
53
|
+
// src/sourcemap-codec.ts
|
|
53
54
|
function decode(mappings) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
else {
|
|
83
|
-
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
seg = [genColumn];
|
|
88
|
-
}
|
|
89
|
-
line.push(seg);
|
|
90
|
-
reader.pos++;
|
|
55
|
+
const { length } = mappings;
|
|
56
|
+
const reader = new StringReader(mappings);
|
|
57
|
+
const decoded = [];
|
|
58
|
+
let genColumn = 0;
|
|
59
|
+
let sourcesIndex = 0;
|
|
60
|
+
let sourceLine = 0;
|
|
61
|
+
let sourceColumn = 0;
|
|
62
|
+
let namesIndex = 0;
|
|
63
|
+
do {
|
|
64
|
+
const semi = reader.indexOf(";");
|
|
65
|
+
const line = [];
|
|
66
|
+
let sorted = true;
|
|
67
|
+
let lastCol = 0;
|
|
68
|
+
genColumn = 0;
|
|
69
|
+
while (reader.pos < semi) {
|
|
70
|
+
let seg;
|
|
71
|
+
genColumn = decodeInteger(reader, genColumn);
|
|
72
|
+
if (genColumn < lastCol) sorted = false;
|
|
73
|
+
lastCol = genColumn;
|
|
74
|
+
if (hasMoreVlq(reader, semi)) {
|
|
75
|
+
sourcesIndex = decodeInteger(reader, sourcesIndex);
|
|
76
|
+
sourceLine = decodeInteger(reader, sourceLine);
|
|
77
|
+
sourceColumn = decodeInteger(reader, sourceColumn);
|
|
78
|
+
if (hasMoreVlq(reader, semi)) {
|
|
79
|
+
namesIndex = decodeInteger(reader, namesIndex);
|
|
80
|
+
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
|
|
81
|
+
} else {
|
|
82
|
+
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
|
91
83
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return decoded;
|
|
98
|
-
}
|
|
99
|
-
function sort(line) {
|
|
100
|
-
line.sort(sortComparator$1);
|
|
101
|
-
}
|
|
102
|
-
function sortComparator$1(a, b) {
|
|
103
|
-
return a[0] - b[0];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Matches the scheme of a URL, eg "http://"
|
|
107
|
-
const schemeRegex = /^[\w+.-]+:\/\//;
|
|
108
|
-
/**
|
|
109
|
-
* Matches the parts of a URL:
|
|
110
|
-
* 1. Scheme, including ":", guaranteed.
|
|
111
|
-
* 2. User/password, including "@", optional.
|
|
112
|
-
* 3. Host, guaranteed.
|
|
113
|
-
* 4. Port, including ":", optional.
|
|
114
|
-
* 5. Path, including "/", optional.
|
|
115
|
-
* 6. Query, including "?", optional.
|
|
116
|
-
* 7. Hash, including "#", optional.
|
|
117
|
-
*/
|
|
118
|
-
const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
|
|
119
|
-
/**
|
|
120
|
-
* File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start
|
|
121
|
-
* with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).
|
|
122
|
-
*
|
|
123
|
-
* 1. Host, optional.
|
|
124
|
-
* 2. Path, which may include "/", guaranteed.
|
|
125
|
-
* 3. Query, including "?", optional.
|
|
126
|
-
* 4. Hash, including "#", optional.
|
|
127
|
-
*/
|
|
128
|
-
const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
|
|
129
|
-
var UrlType;
|
|
130
|
-
(function (UrlType) {
|
|
131
|
-
UrlType[UrlType["Empty"] = 1] = "Empty";
|
|
132
|
-
UrlType[UrlType["Hash"] = 2] = "Hash";
|
|
133
|
-
UrlType[UrlType["Query"] = 3] = "Query";
|
|
134
|
-
UrlType[UrlType["RelativePath"] = 4] = "RelativePath";
|
|
135
|
-
UrlType[UrlType["AbsolutePath"] = 5] = "AbsolutePath";
|
|
136
|
-
UrlType[UrlType["SchemeRelative"] = 6] = "SchemeRelative";
|
|
137
|
-
UrlType[UrlType["Absolute"] = 7] = "Absolute";
|
|
138
|
-
})(UrlType || (UrlType = {}));
|
|
139
|
-
function isAbsoluteUrl(input) {
|
|
140
|
-
return schemeRegex.test(input);
|
|
141
|
-
}
|
|
142
|
-
function isSchemeRelativeUrl(input) {
|
|
143
|
-
return input.startsWith('//');
|
|
144
|
-
}
|
|
145
|
-
function isAbsolutePath(input) {
|
|
146
|
-
return input.startsWith('/');
|
|
147
|
-
}
|
|
148
|
-
function isFileUrl(input) {
|
|
149
|
-
return input.startsWith('file:');
|
|
150
|
-
}
|
|
151
|
-
function isRelative(input) {
|
|
152
|
-
return /^[.?#]/.test(input);
|
|
153
|
-
}
|
|
154
|
-
function parseAbsoluteUrl(input) {
|
|
155
|
-
const match = urlRegex.exec(input);
|
|
156
|
-
return makeUrl(match[1], match[2] || '', match[3], match[4] || '', match[5] || '/', match[6] || '', match[7] || '');
|
|
157
|
-
}
|
|
158
|
-
function parseFileUrl(input) {
|
|
159
|
-
const match = fileRegex.exec(input);
|
|
160
|
-
const path = match[2];
|
|
161
|
-
return makeUrl('file:', '', match[1] || '', '', isAbsolutePath(path) ? path : '/' + path, match[3] || '', match[4] || '');
|
|
162
|
-
}
|
|
163
|
-
function makeUrl(scheme, user, host, port, path, query, hash) {
|
|
164
|
-
return {
|
|
165
|
-
scheme,
|
|
166
|
-
user,
|
|
167
|
-
host,
|
|
168
|
-
port,
|
|
169
|
-
path,
|
|
170
|
-
query,
|
|
171
|
-
hash,
|
|
172
|
-
type: UrlType.Absolute,
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
function parseUrl(input) {
|
|
176
|
-
if (isSchemeRelativeUrl(input)) {
|
|
177
|
-
const url = parseAbsoluteUrl('http:' + input);
|
|
178
|
-
url.scheme = '';
|
|
179
|
-
url.type = UrlType.SchemeRelative;
|
|
180
|
-
return url;
|
|
181
|
-
}
|
|
182
|
-
if (isAbsolutePath(input)) {
|
|
183
|
-
const url = parseAbsoluteUrl('http://foo.com' + input);
|
|
184
|
-
url.scheme = '';
|
|
185
|
-
url.host = '';
|
|
186
|
-
url.type = UrlType.AbsolutePath;
|
|
187
|
-
return url;
|
|
84
|
+
} else {
|
|
85
|
+
seg = [genColumn];
|
|
86
|
+
}
|
|
87
|
+
line.push(seg);
|
|
88
|
+
reader.pos++;
|
|
188
89
|
}
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
url.scheme = '';
|
|
195
|
-
url.host = '';
|
|
196
|
-
url.type = input
|
|
197
|
-
? input.startsWith('?')
|
|
198
|
-
? UrlType.Query
|
|
199
|
-
: input.startsWith('#')
|
|
200
|
-
? UrlType.Hash
|
|
201
|
-
: UrlType.RelativePath
|
|
202
|
-
: UrlType.Empty;
|
|
203
|
-
return url;
|
|
90
|
+
if (!sorted) sort(line);
|
|
91
|
+
decoded.push(line);
|
|
92
|
+
reader.pos = semi + 1;
|
|
93
|
+
} while (reader.pos <= length);
|
|
94
|
+
return decoded;
|
|
204
95
|
}
|
|
205
|
-
function
|
|
206
|
-
|
|
207
|
-
// paths. It's not a file, so we can't strip it.
|
|
208
|
-
if (path.endsWith('/..'))
|
|
209
|
-
return path;
|
|
210
|
-
const index = path.lastIndexOf('/');
|
|
211
|
-
return path.slice(0, index + 1);
|
|
212
|
-
}
|
|
213
|
-
function mergePaths(url, base) {
|
|
214
|
-
normalizePath(base, base.type);
|
|
215
|
-
// If the path is just a "/", then it was an empty path to begin with (remember, we're a relative
|
|
216
|
-
// path).
|
|
217
|
-
if (url.path === '/') {
|
|
218
|
-
url.path = base.path;
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
// Resolution happens relative to the base path's directory, not the file.
|
|
222
|
-
url.path = stripPathFilename(base.path) + url.path;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* The path can have empty directories "//", unneeded parents "foo/..", or current directory
|
|
227
|
-
* "foo/.". We need to normalize to a standard representation.
|
|
228
|
-
*/
|
|
229
|
-
function normalizePath(url, type) {
|
|
230
|
-
const rel = type <= UrlType.RelativePath;
|
|
231
|
-
const pieces = url.path.split('/');
|
|
232
|
-
// We need to preserve the first piece always, so that we output a leading slash. The item at
|
|
233
|
-
// pieces[0] is an empty string.
|
|
234
|
-
let pointer = 1;
|
|
235
|
-
// Positive is the number of real directories we've output, used for popping a parent directory.
|
|
236
|
-
// Eg, "foo/bar/.." will have a positive 2, and we can decrement to be left with just "foo".
|
|
237
|
-
let positive = 0;
|
|
238
|
-
// We need to keep a trailing slash if we encounter an empty directory (eg, splitting "foo/" will
|
|
239
|
-
// generate `["foo", ""]` pieces). And, if we pop a parent directory. But once we encounter a
|
|
240
|
-
// real directory, we won't need to append, unless the other conditions happen again.
|
|
241
|
-
let addTrailingSlash = false;
|
|
242
|
-
for (let i = 1; i < pieces.length; i++) {
|
|
243
|
-
const piece = pieces[i];
|
|
244
|
-
// An empty directory, could be a trailing slash, or just a double "//" in the path.
|
|
245
|
-
if (!piece) {
|
|
246
|
-
addTrailingSlash = true;
|
|
247
|
-
continue;
|
|
248
|
-
}
|
|
249
|
-
// If we encounter a real directory, then we don't need to append anymore.
|
|
250
|
-
addTrailingSlash = false;
|
|
251
|
-
// A current directory, which we can always drop.
|
|
252
|
-
if (piece === '.')
|
|
253
|
-
continue;
|
|
254
|
-
// A parent directory, we need to see if there are any real directories we can pop. Else, we
|
|
255
|
-
// have an excess of parents, and we'll need to keep the "..".
|
|
256
|
-
if (piece === '..') {
|
|
257
|
-
if (positive) {
|
|
258
|
-
addTrailingSlash = true;
|
|
259
|
-
positive--;
|
|
260
|
-
pointer--;
|
|
261
|
-
}
|
|
262
|
-
else if (rel) {
|
|
263
|
-
// If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute
|
|
264
|
-
// URL, protocol relative URL, or an absolute path, we don't need to keep excess.
|
|
265
|
-
pieces[pointer++] = piece;
|
|
266
|
-
}
|
|
267
|
-
continue;
|
|
268
|
-
}
|
|
269
|
-
// We've encountered a real directory. Move it to the next insertion pointer, which accounts for
|
|
270
|
-
// any popped or dropped directories.
|
|
271
|
-
pieces[pointer++] = piece;
|
|
272
|
-
positive++;
|
|
273
|
-
}
|
|
274
|
-
let path = '';
|
|
275
|
-
for (let i = 1; i < pointer; i++) {
|
|
276
|
-
path += '/' + pieces[i];
|
|
277
|
-
}
|
|
278
|
-
if (!path || (addTrailingSlash && !path.endsWith('/..'))) {
|
|
279
|
-
path += '/';
|
|
280
|
-
}
|
|
281
|
-
url.path = path;
|
|
96
|
+
function sort(line) {
|
|
97
|
+
line.sort(sortComparator);
|
|
282
98
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
*/
|
|
286
|
-
function resolve(input, base) {
|
|
287
|
-
if (!input && !base)
|
|
288
|
-
return '';
|
|
289
|
-
const url = parseUrl(input);
|
|
290
|
-
let inputType = url.type;
|
|
291
|
-
if (base && inputType !== UrlType.Absolute) {
|
|
292
|
-
const baseUrl = parseUrl(base);
|
|
293
|
-
const baseType = baseUrl.type;
|
|
294
|
-
switch (inputType) {
|
|
295
|
-
case UrlType.Empty:
|
|
296
|
-
url.hash = baseUrl.hash;
|
|
297
|
-
// fall through
|
|
298
|
-
case UrlType.Hash:
|
|
299
|
-
url.query = baseUrl.query;
|
|
300
|
-
// fall through
|
|
301
|
-
case UrlType.Query:
|
|
302
|
-
case UrlType.RelativePath:
|
|
303
|
-
mergePaths(url, baseUrl);
|
|
304
|
-
// fall through
|
|
305
|
-
case UrlType.AbsolutePath:
|
|
306
|
-
// The host, user, and port are joined, you can't copy one without the others.
|
|
307
|
-
url.user = baseUrl.user;
|
|
308
|
-
url.host = baseUrl.host;
|
|
309
|
-
url.port = baseUrl.port;
|
|
310
|
-
// fall through
|
|
311
|
-
case UrlType.SchemeRelative:
|
|
312
|
-
// The input doesn't have a schema at least, so we need to copy at least that over.
|
|
313
|
-
url.scheme = baseUrl.scheme;
|
|
314
|
-
}
|
|
315
|
-
if (baseType > inputType)
|
|
316
|
-
inputType = baseType;
|
|
317
|
-
}
|
|
318
|
-
normalizePath(url, inputType);
|
|
319
|
-
const queryHash = url.query + url.hash;
|
|
320
|
-
switch (inputType) {
|
|
321
|
-
// This is impossible, because of the empty checks at the start of the function.
|
|
322
|
-
// case UrlType.Empty:
|
|
323
|
-
case UrlType.Hash:
|
|
324
|
-
case UrlType.Query:
|
|
325
|
-
return queryHash;
|
|
326
|
-
case UrlType.RelativePath: {
|
|
327
|
-
// The first char is always a "/", and we need it to be relative.
|
|
328
|
-
const path = url.path.slice(1);
|
|
329
|
-
if (!path)
|
|
330
|
-
return queryHash || '.';
|
|
331
|
-
if (isRelative(base || input) && !isRelative(path)) {
|
|
332
|
-
// If base started with a leading ".", or there is no base and input started with a ".",
|
|
333
|
-
// then we need to ensure that the relative path starts with a ".". We don't know if
|
|
334
|
-
// relative starts with a "..", though, so check before prepending.
|
|
335
|
-
return './' + path + queryHash;
|
|
336
|
-
}
|
|
337
|
-
return path + queryHash;
|
|
338
|
-
}
|
|
339
|
-
case UrlType.AbsolutePath:
|
|
340
|
-
return url.path + queryHash;
|
|
341
|
-
default:
|
|
342
|
-
return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;
|
|
343
|
-
}
|
|
99
|
+
function sortComparator(a, b) {
|
|
100
|
+
return a[0] - b[0];
|
|
344
101
|
}
|
|
345
102
|
|
|
346
103
|
// src/trace-mapping.ts
|
|
347
104
|
|
|
348
|
-
// src/strip-filename.ts
|
|
349
|
-
function stripFilename(path) {
|
|
350
|
-
if (!path) return "";
|
|
351
|
-
const index = path.lastIndexOf("/");
|
|
352
|
-
return path.slice(0, index + 1);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// src/resolve.ts
|
|
356
|
-
function resolver(mapUrl, sourceRoot) {
|
|
357
|
-
const from = stripFilename(mapUrl);
|
|
358
|
-
const prefix = sourceRoot ? sourceRoot + "/" : "";
|
|
359
|
-
return (source) => resolve(prefix + (source || ""), from);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
105
|
// src/sourcemap-segment.ts
|
|
363
106
|
var COLUMN = 0;
|
|
364
107
|
var SOURCES_INDEX = 1;
|
|
@@ -366,38 +109,6 @@ var SOURCE_LINE = 2;
|
|
|
366
109
|
var SOURCE_COLUMN = 3;
|
|
367
110
|
var NAMES_INDEX = 4;
|
|
368
111
|
|
|
369
|
-
// src/sort.ts
|
|
370
|
-
function maybeSort(mappings, owned) {
|
|
371
|
-
const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
|
|
372
|
-
if (unsortedIndex === mappings.length) return mappings;
|
|
373
|
-
if (!owned) mappings = mappings.slice();
|
|
374
|
-
for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
|
|
375
|
-
mappings[i] = sortSegments(mappings[i], owned);
|
|
376
|
-
}
|
|
377
|
-
return mappings;
|
|
378
|
-
}
|
|
379
|
-
function nextUnsortedSegmentLine(mappings, start) {
|
|
380
|
-
for (let i = start; i < mappings.length; i++) {
|
|
381
|
-
if (!isSorted(mappings[i])) return i;
|
|
382
|
-
}
|
|
383
|
-
return mappings.length;
|
|
384
|
-
}
|
|
385
|
-
function isSorted(line) {
|
|
386
|
-
for (let j = 1; j < line.length; j++) {
|
|
387
|
-
if (line[j][COLUMN] < line[j - 1][COLUMN]) {
|
|
388
|
-
return false;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
return true;
|
|
392
|
-
}
|
|
393
|
-
function sortSegments(line, owned) {
|
|
394
|
-
if (!owned) line = line.slice();
|
|
395
|
-
return line.sort(sortComparator);
|
|
396
|
-
}
|
|
397
|
-
function sortComparator(a, b) {
|
|
398
|
-
return a[COLUMN] - b[COLUMN];
|
|
399
|
-
}
|
|
400
|
-
|
|
401
112
|
// src/binary-search.ts
|
|
402
113
|
var found = false;
|
|
403
114
|
function binarySearch(haystack, needle, low, high) {
|
|
@@ -429,13 +140,6 @@ function lowerBound(haystack, needle, index) {
|
|
|
429
140
|
}
|
|
430
141
|
return index;
|
|
431
142
|
}
|
|
432
|
-
function memoizedState() {
|
|
433
|
-
return {
|
|
434
|
-
lastKey: -1,
|
|
435
|
-
lastNeedle: -1,
|
|
436
|
-
lastIndex: -1
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
143
|
function memoizedBinarySearch(haystack, needle, state, key) {
|
|
440
144
|
const { lastKey, lastNeedle, lastIndex } = state;
|
|
441
145
|
let low = 0;
|
|
@@ -456,48 +160,11 @@ function memoizedBinarySearch(haystack, needle, state, key) {
|
|
|
456
160
|
return state.lastIndex = binarySearch(haystack, needle, low, high);
|
|
457
161
|
}
|
|
458
162
|
|
|
459
|
-
// src/types.ts
|
|
460
|
-
function parse(map) {
|
|
461
|
-
return typeof map === "string" ? JSON.parse(map) : map;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
163
|
// src/trace-mapping.ts
|
|
465
164
|
var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
|
|
466
165
|
var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
|
|
467
166
|
var LEAST_UPPER_BOUND = -1;
|
|
468
167
|
var GREATEST_LOWER_BOUND = 1;
|
|
469
|
-
var TraceMap = class {
|
|
470
|
-
constructor(map, mapUrl) {
|
|
471
|
-
const isString = typeof map === "string";
|
|
472
|
-
if (!isString && map._decodedMemo) return map;
|
|
473
|
-
const parsed = parse(map);
|
|
474
|
-
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
|
475
|
-
this.version = version;
|
|
476
|
-
this.file = file;
|
|
477
|
-
this.names = names || [];
|
|
478
|
-
this.sourceRoot = sourceRoot;
|
|
479
|
-
this.sources = sources;
|
|
480
|
-
this.sourcesContent = sourcesContent;
|
|
481
|
-
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
|
|
482
|
-
const resolve = resolver(mapUrl, sourceRoot);
|
|
483
|
-
this.resolvedSources = sources.map(resolve);
|
|
484
|
-
const { mappings } = parsed;
|
|
485
|
-
if (typeof mappings === "string") {
|
|
486
|
-
this._encoded = mappings;
|
|
487
|
-
this._decoded = void 0;
|
|
488
|
-
} else if (Array.isArray(mappings)) {
|
|
489
|
-
this._encoded = void 0;
|
|
490
|
-
this._decoded = maybeSort(mappings, isString);
|
|
491
|
-
} else if (parsed.sections) {
|
|
492
|
-
throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
|
|
493
|
-
} else {
|
|
494
|
-
throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
|
|
495
|
-
}
|
|
496
|
-
this._decodedMemo = memoizedState();
|
|
497
|
-
this._bySources = void 0;
|
|
498
|
-
this._bySourceMemos = void 0;
|
|
499
|
-
}
|
|
500
|
-
};
|
|
501
168
|
function cast(map) {
|
|
502
169
|
return map;
|
|
503
170
|
}
|
|
@@ -602,10 +269,7 @@ const stackIgnorePatterns = [
|
|
|
602
269
|
/\/@vitest\/\w+\/dist\//,
|
|
603
270
|
"/vitest/dist/",
|
|
604
271
|
"/vitest/src/",
|
|
605
|
-
"/vite-node/dist/",
|
|
606
|
-
"/vite-node/src/",
|
|
607
272
|
"/node_modules/chai/",
|
|
608
|
-
"/node_modules/tinypool/",
|
|
609
273
|
"/node_modules/tinyspy/",
|
|
610
274
|
"/vite/dist/node/module-runner",
|
|
611
275
|
"/rolldown-vite/dist/node/module-runner",
|
|
@@ -613,6 +277,9 @@ const stackIgnorePatterns = [
|
|
|
613
277
|
"/deps/@vitest",
|
|
614
278
|
"/deps/loupe",
|
|
615
279
|
"/deps/chai",
|
|
280
|
+
"/browser-playwright/dist/locators.js",
|
|
281
|
+
"/browser-webdriverio/dist/locators.js",
|
|
282
|
+
"/browser-preview/dist/locators.js",
|
|
616
283
|
/node:\w+/,
|
|
617
284
|
/__vitest_test__/,
|
|
618
285
|
/__vitest_browser__/,
|
|
@@ -656,14 +323,35 @@ function parseSingleFFOrSafariStack(raw) {
|
|
|
656
323
|
if (line.includes(" > eval")) {
|
|
657
324
|
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
|
|
658
325
|
}
|
|
659
|
-
|
|
326
|
+
// Early return for lines that don't look like Firefox/Safari stack traces
|
|
327
|
+
// Firefox/Safari stack traces must contain '@' and should have location info after it
|
|
328
|
+
if (!line.includes("@")) {
|
|
660
329
|
return null;
|
|
661
330
|
}
|
|
662
|
-
//
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
331
|
+
// Find the correct @ that separates function name from location
|
|
332
|
+
// For cases like '@https://@fs/path' or 'functionName@https://@fs/path'
|
|
333
|
+
// we need to find the first @ that precedes a valid location (containing :)
|
|
334
|
+
let atIndex = -1;
|
|
335
|
+
let locationPart = "";
|
|
336
|
+
let functionName;
|
|
337
|
+
// Try each @ from left to right to find the one that gives us a valid location
|
|
338
|
+
for (let i = 0; i < line.length; i++) {
|
|
339
|
+
if (line[i] === "@") {
|
|
340
|
+
const candidateLocation = line.slice(i + 1);
|
|
341
|
+
// Minimum length 3 for valid location: 1 for filename + 1 for colon + 1 for line number (e.g., "a:1")
|
|
342
|
+
if (candidateLocation.includes(":") && candidateLocation.length >= 3) {
|
|
343
|
+
atIndex = i;
|
|
344
|
+
locationPart = candidateLocation;
|
|
345
|
+
functionName = i > 0 ? line.slice(0, i) : undefined;
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
// Validate we found a valid location with minimum length (filename:line format)
|
|
351
|
+
if (atIndex === -1 || !locationPart.includes(":") || locationPart.length < 3) {
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
const [url, lineNumber, columnNumber] = extractLocation(locationPart);
|
|
667
355
|
if (!url || !lineNumber || !columnNumber) {
|
|
668
356
|
return null;
|
|
669
357
|
}
|
|
@@ -705,9 +393,9 @@ function parseSingleV8Stack(raw) {
|
|
|
705
393
|
file = file.slice(7);
|
|
706
394
|
}
|
|
707
395
|
// normalize Windows path (\ -> /)
|
|
708
|
-
file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve
|
|
396
|
+
file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve(file);
|
|
709
397
|
if (method) {
|
|
710
|
-
method = method.replace(/__vite_ssr_import_\d+__\./g, "");
|
|
398
|
+
method = method.replace(/__vite_ssr_import_\d+__\./g, "").replace(/(Object\.)?__vite_ssr_export_default__\s?/g, "");
|
|
711
399
|
}
|
|
712
400
|
return {
|
|
713
401
|
method,
|
|
@@ -728,17 +416,15 @@ function parseStacktrace(stack, options = {}) {
|
|
|
728
416
|
if (!map || typeof map !== "object" || !map.version) {
|
|
729
417
|
return shouldFilter(ignoreStackEntries, stack.file) ? null : stack;
|
|
730
418
|
}
|
|
731
|
-
const traceMap = new
|
|
732
|
-
const
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
file = file.slice(1);
|
|
741
|
-
}
|
|
419
|
+
const traceMap = new DecodedMap(map, stack.file);
|
|
420
|
+
const position = getOriginalPosition(traceMap, stack);
|
|
421
|
+
if (!position) {
|
|
422
|
+
return stack;
|
|
423
|
+
}
|
|
424
|
+
const { line, column, source, name } = position;
|
|
425
|
+
let file = source || stack.file;
|
|
426
|
+
if (file.match(/\/\w:\//)) {
|
|
427
|
+
file = file.slice(1);
|
|
742
428
|
}
|
|
743
429
|
if (shouldFilter(ignoreStackEntries, file)) {
|
|
744
430
|
return null;
|
|
@@ -789,544 +475,40 @@ function parseErrorStacktrace(e, options = {}) {
|
|
|
789
475
|
e.stacks = stackFrames;
|
|
790
476
|
return stackFrames;
|
|
791
477
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
478
|
+
class DecodedMap {
|
|
479
|
+
_encoded;
|
|
480
|
+
_decoded;
|
|
481
|
+
_decodedMemo;
|
|
482
|
+
url;
|
|
483
|
+
version;
|
|
484
|
+
names = [];
|
|
485
|
+
resolvedSources;
|
|
486
|
+
constructor(map, from) {
|
|
487
|
+
this.map = map;
|
|
488
|
+
const { mappings, names, sources } = map;
|
|
489
|
+
this.version = map.version;
|
|
490
|
+
this.names = names || [];
|
|
491
|
+
this._encoded = mappings || "";
|
|
492
|
+
this._decodedMemo = memoizedState();
|
|
493
|
+
this.url = from;
|
|
494
|
+
this.resolvedSources = (sources || []).map((s) => resolve(s || "", from));
|
|
495
|
+
}
|
|
797
496
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
if (hasRequiredJsTokens) return jsTokens_1;
|
|
804
|
-
hasRequiredJsTokens = 1;
|
|
805
|
-
// Copyright 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Simon Lydell
|
|
806
|
-
// License: MIT.
|
|
807
|
-
var Identifier, JSXIdentifier, JSXPunctuator, JSXString, JSXText, KeywordsWithExpressionAfter, KeywordsWithNoLineTerminatorAfter, LineTerminatorSequence, MultiLineComment, Newline, NumericLiteral, Punctuator, RegularExpressionLiteral, SingleLineComment, StringLiteral, Template, TokensNotPrecedingObjectLiteral, TokensPrecedingExpression, WhiteSpace;
|
|
808
|
-
RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\\]).|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/yu;
|
|
809
|
-
Punctuator = /--|\+\+|=>|\.{3}|\??\.(?!\d)|(?:&&|\|\||\?\?|[+\-%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\/(?![\/*]))=?|[?~,:;[\](){}]/y;
|
|
810
|
-
Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/yu;
|
|
811
|
-
StringLiteral = /(['"])(?:(?!\1)[^\\\n\r]|\\(?:\r\n|[^]))*(\1)?/y;
|
|
812
|
-
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;
|
|
813
|
-
Template = /[`}](?:[^`\\$]|\\[^]|\$(?!\{))*(`|\$\{)?/y;
|
|
814
|
-
WhiteSpace = /[\t\v\f\ufeff\p{Zs}]+/yu;
|
|
815
|
-
LineTerminatorSequence = /\r?\n|[\r\u2028\u2029]/y;
|
|
816
|
-
MultiLineComment = /\/\*(?:[^*]|\*(?!\/))*(\*\/)?/y;
|
|
817
|
-
SingleLineComment = /\/\/.*/y;
|
|
818
|
-
JSXPunctuator = /[<>.:={}]|\/(?![\/*])/y;
|
|
819
|
-
JSXIdentifier = /[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}-]*/yu;
|
|
820
|
-
JSXString = /(['"])(?:(?!\1)[^])*(\1)?/y;
|
|
821
|
-
JSXText = /[^<>{}]+/y;
|
|
822
|
-
TokensPrecedingExpression = /^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/;
|
|
823
|
-
TokensNotPrecedingObjectLiteral = /^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/;
|
|
824
|
-
KeywordsWithExpressionAfter = /^(?:await|case|default|delete|do|else|instanceof|new|return|throw|typeof|void|yield)$/;
|
|
825
|
-
KeywordsWithNoLineTerminatorAfter = /^(?:return|throw|yield)$/;
|
|
826
|
-
Newline = RegExp(LineTerminatorSequence.source);
|
|
827
|
-
jsTokens_1 = function*(input, {jsx = false} = {}) {
|
|
828
|
-
var braces, firstCodePoint, isExpression, lastIndex, lastSignificantToken, length, match, mode, nextLastIndex, nextLastSignificantToken, parenNesting, postfixIncDec, punctuator, stack;
|
|
829
|
-
({length} = input);
|
|
830
|
-
lastIndex = 0;
|
|
831
|
-
lastSignificantToken = "";
|
|
832
|
-
stack = [
|
|
833
|
-
{tag: "JS"}
|
|
834
|
-
];
|
|
835
|
-
braces = [];
|
|
836
|
-
parenNesting = 0;
|
|
837
|
-
postfixIncDec = false;
|
|
838
|
-
while (lastIndex < length) {
|
|
839
|
-
mode = stack[stack.length - 1];
|
|
840
|
-
switch (mode.tag) {
|
|
841
|
-
case "JS":
|
|
842
|
-
case "JSNonExpressionParen":
|
|
843
|
-
case "InterpolationInTemplate":
|
|
844
|
-
case "InterpolationInJSX":
|
|
845
|
-
if (input[lastIndex] === "/" && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
|
|
846
|
-
RegularExpressionLiteral.lastIndex = lastIndex;
|
|
847
|
-
if (match = RegularExpressionLiteral.exec(input)) {
|
|
848
|
-
lastIndex = RegularExpressionLiteral.lastIndex;
|
|
849
|
-
lastSignificantToken = match[0];
|
|
850
|
-
postfixIncDec = true;
|
|
851
|
-
yield ({
|
|
852
|
-
type: "RegularExpressionLiteral",
|
|
853
|
-
value: match[0],
|
|
854
|
-
closed: match[1] !== void 0 && match[1] !== "\\"
|
|
855
|
-
});
|
|
856
|
-
continue;
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
Punctuator.lastIndex = lastIndex;
|
|
860
|
-
if (match = Punctuator.exec(input)) {
|
|
861
|
-
punctuator = match[0];
|
|
862
|
-
nextLastIndex = Punctuator.lastIndex;
|
|
863
|
-
nextLastSignificantToken = punctuator;
|
|
864
|
-
switch (punctuator) {
|
|
865
|
-
case "(":
|
|
866
|
-
if (lastSignificantToken === "?NonExpressionParenKeyword") {
|
|
867
|
-
stack.push({
|
|
868
|
-
tag: "JSNonExpressionParen",
|
|
869
|
-
nesting: parenNesting
|
|
870
|
-
});
|
|
871
|
-
}
|
|
872
|
-
parenNesting++;
|
|
873
|
-
postfixIncDec = false;
|
|
874
|
-
break;
|
|
875
|
-
case ")":
|
|
876
|
-
parenNesting--;
|
|
877
|
-
postfixIncDec = true;
|
|
878
|
-
if (mode.tag === "JSNonExpressionParen" && parenNesting === mode.nesting) {
|
|
879
|
-
stack.pop();
|
|
880
|
-
nextLastSignificantToken = "?NonExpressionParenEnd";
|
|
881
|
-
postfixIncDec = false;
|
|
882
|
-
}
|
|
883
|
-
break;
|
|
884
|
-
case "{":
|
|
885
|
-
Punctuator.lastIndex = 0;
|
|
886
|
-
isExpression = !TokensNotPrecedingObjectLiteral.test(lastSignificantToken) && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken));
|
|
887
|
-
braces.push(isExpression);
|
|
888
|
-
postfixIncDec = false;
|
|
889
|
-
break;
|
|
890
|
-
case "}":
|
|
891
|
-
switch (mode.tag) {
|
|
892
|
-
case "InterpolationInTemplate":
|
|
893
|
-
if (braces.length === mode.nesting) {
|
|
894
|
-
Template.lastIndex = lastIndex;
|
|
895
|
-
match = Template.exec(input);
|
|
896
|
-
lastIndex = Template.lastIndex;
|
|
897
|
-
lastSignificantToken = match[0];
|
|
898
|
-
if (match[1] === "${") {
|
|
899
|
-
lastSignificantToken = "?InterpolationInTemplate";
|
|
900
|
-
postfixIncDec = false;
|
|
901
|
-
yield ({
|
|
902
|
-
type: "TemplateMiddle",
|
|
903
|
-
value: match[0]
|
|
904
|
-
});
|
|
905
|
-
} else {
|
|
906
|
-
stack.pop();
|
|
907
|
-
postfixIncDec = true;
|
|
908
|
-
yield ({
|
|
909
|
-
type: "TemplateTail",
|
|
910
|
-
value: match[0],
|
|
911
|
-
closed: match[1] === "`"
|
|
912
|
-
});
|
|
913
|
-
}
|
|
914
|
-
continue;
|
|
915
|
-
}
|
|
916
|
-
break;
|
|
917
|
-
case "InterpolationInJSX":
|
|
918
|
-
if (braces.length === mode.nesting) {
|
|
919
|
-
stack.pop();
|
|
920
|
-
lastIndex += 1;
|
|
921
|
-
lastSignificantToken = "}";
|
|
922
|
-
yield ({
|
|
923
|
-
type: "JSXPunctuator",
|
|
924
|
-
value: "}"
|
|
925
|
-
});
|
|
926
|
-
continue;
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
postfixIncDec = braces.pop();
|
|
930
|
-
nextLastSignificantToken = postfixIncDec ? "?ExpressionBraceEnd" : "}";
|
|
931
|
-
break;
|
|
932
|
-
case "]":
|
|
933
|
-
postfixIncDec = true;
|
|
934
|
-
break;
|
|
935
|
-
case "++":
|
|
936
|
-
case "--":
|
|
937
|
-
nextLastSignificantToken = postfixIncDec ? "?PostfixIncDec" : "?UnaryIncDec";
|
|
938
|
-
break;
|
|
939
|
-
case "<":
|
|
940
|
-
if (jsx && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
|
|
941
|
-
stack.push({tag: "JSXTag"});
|
|
942
|
-
lastIndex += 1;
|
|
943
|
-
lastSignificantToken = "<";
|
|
944
|
-
yield ({
|
|
945
|
-
type: "JSXPunctuator",
|
|
946
|
-
value: punctuator
|
|
947
|
-
});
|
|
948
|
-
continue;
|
|
949
|
-
}
|
|
950
|
-
postfixIncDec = false;
|
|
951
|
-
break;
|
|
952
|
-
default:
|
|
953
|
-
postfixIncDec = false;
|
|
954
|
-
}
|
|
955
|
-
lastIndex = nextLastIndex;
|
|
956
|
-
lastSignificantToken = nextLastSignificantToken;
|
|
957
|
-
yield ({
|
|
958
|
-
type: "Punctuator",
|
|
959
|
-
value: punctuator
|
|
960
|
-
});
|
|
961
|
-
continue;
|
|
962
|
-
}
|
|
963
|
-
Identifier.lastIndex = lastIndex;
|
|
964
|
-
if (match = Identifier.exec(input)) {
|
|
965
|
-
lastIndex = Identifier.lastIndex;
|
|
966
|
-
nextLastSignificantToken = match[0];
|
|
967
|
-
switch (match[0]) {
|
|
968
|
-
case "for":
|
|
969
|
-
case "if":
|
|
970
|
-
case "while":
|
|
971
|
-
case "with":
|
|
972
|
-
if (lastSignificantToken !== "." && lastSignificantToken !== "?.") {
|
|
973
|
-
nextLastSignificantToken = "?NonExpressionParenKeyword";
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
lastSignificantToken = nextLastSignificantToken;
|
|
977
|
-
postfixIncDec = !KeywordsWithExpressionAfter.test(match[0]);
|
|
978
|
-
yield ({
|
|
979
|
-
type: match[1] === "#" ? "PrivateIdentifier" : "IdentifierName",
|
|
980
|
-
value: match[0]
|
|
981
|
-
});
|
|
982
|
-
continue;
|
|
983
|
-
}
|
|
984
|
-
StringLiteral.lastIndex = lastIndex;
|
|
985
|
-
if (match = StringLiteral.exec(input)) {
|
|
986
|
-
lastIndex = StringLiteral.lastIndex;
|
|
987
|
-
lastSignificantToken = match[0];
|
|
988
|
-
postfixIncDec = true;
|
|
989
|
-
yield ({
|
|
990
|
-
type: "StringLiteral",
|
|
991
|
-
value: match[0],
|
|
992
|
-
closed: match[2] !== void 0
|
|
993
|
-
});
|
|
994
|
-
continue;
|
|
995
|
-
}
|
|
996
|
-
NumericLiteral.lastIndex = lastIndex;
|
|
997
|
-
if (match = NumericLiteral.exec(input)) {
|
|
998
|
-
lastIndex = NumericLiteral.lastIndex;
|
|
999
|
-
lastSignificantToken = match[0];
|
|
1000
|
-
postfixIncDec = true;
|
|
1001
|
-
yield ({
|
|
1002
|
-
type: "NumericLiteral",
|
|
1003
|
-
value: match[0]
|
|
1004
|
-
});
|
|
1005
|
-
continue;
|
|
1006
|
-
}
|
|
1007
|
-
Template.lastIndex = lastIndex;
|
|
1008
|
-
if (match = Template.exec(input)) {
|
|
1009
|
-
lastIndex = Template.lastIndex;
|
|
1010
|
-
lastSignificantToken = match[0];
|
|
1011
|
-
if (match[1] === "${") {
|
|
1012
|
-
lastSignificantToken = "?InterpolationInTemplate";
|
|
1013
|
-
stack.push({
|
|
1014
|
-
tag: "InterpolationInTemplate",
|
|
1015
|
-
nesting: braces.length
|
|
1016
|
-
});
|
|
1017
|
-
postfixIncDec = false;
|
|
1018
|
-
yield ({
|
|
1019
|
-
type: "TemplateHead",
|
|
1020
|
-
value: match[0]
|
|
1021
|
-
});
|
|
1022
|
-
} else {
|
|
1023
|
-
postfixIncDec = true;
|
|
1024
|
-
yield ({
|
|
1025
|
-
type: "NoSubstitutionTemplate",
|
|
1026
|
-
value: match[0],
|
|
1027
|
-
closed: match[1] === "`"
|
|
1028
|
-
});
|
|
1029
|
-
}
|
|
1030
|
-
continue;
|
|
1031
|
-
}
|
|
1032
|
-
break;
|
|
1033
|
-
case "JSXTag":
|
|
1034
|
-
case "JSXTagEnd":
|
|
1035
|
-
JSXPunctuator.lastIndex = lastIndex;
|
|
1036
|
-
if (match = JSXPunctuator.exec(input)) {
|
|
1037
|
-
lastIndex = JSXPunctuator.lastIndex;
|
|
1038
|
-
nextLastSignificantToken = match[0];
|
|
1039
|
-
switch (match[0]) {
|
|
1040
|
-
case "<":
|
|
1041
|
-
stack.push({tag: "JSXTag"});
|
|
1042
|
-
break;
|
|
1043
|
-
case ">":
|
|
1044
|
-
stack.pop();
|
|
1045
|
-
if (lastSignificantToken === "/" || mode.tag === "JSXTagEnd") {
|
|
1046
|
-
nextLastSignificantToken = "?JSX";
|
|
1047
|
-
postfixIncDec = true;
|
|
1048
|
-
} else {
|
|
1049
|
-
stack.push({tag: "JSXChildren"});
|
|
1050
|
-
}
|
|
1051
|
-
break;
|
|
1052
|
-
case "{":
|
|
1053
|
-
stack.push({
|
|
1054
|
-
tag: "InterpolationInJSX",
|
|
1055
|
-
nesting: braces.length
|
|
1056
|
-
});
|
|
1057
|
-
nextLastSignificantToken = "?InterpolationInJSX";
|
|
1058
|
-
postfixIncDec = false;
|
|
1059
|
-
break;
|
|
1060
|
-
case "/":
|
|
1061
|
-
if (lastSignificantToken === "<") {
|
|
1062
|
-
stack.pop();
|
|
1063
|
-
if (stack[stack.length - 1].tag === "JSXChildren") {
|
|
1064
|
-
stack.pop();
|
|
1065
|
-
}
|
|
1066
|
-
stack.push({tag: "JSXTagEnd"});
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
lastSignificantToken = nextLastSignificantToken;
|
|
1070
|
-
yield ({
|
|
1071
|
-
type: "JSXPunctuator",
|
|
1072
|
-
value: match[0]
|
|
1073
|
-
});
|
|
1074
|
-
continue;
|
|
1075
|
-
}
|
|
1076
|
-
JSXIdentifier.lastIndex = lastIndex;
|
|
1077
|
-
if (match = JSXIdentifier.exec(input)) {
|
|
1078
|
-
lastIndex = JSXIdentifier.lastIndex;
|
|
1079
|
-
lastSignificantToken = match[0];
|
|
1080
|
-
yield ({
|
|
1081
|
-
type: "JSXIdentifier",
|
|
1082
|
-
value: match[0]
|
|
1083
|
-
});
|
|
1084
|
-
continue;
|
|
1085
|
-
}
|
|
1086
|
-
JSXString.lastIndex = lastIndex;
|
|
1087
|
-
if (match = JSXString.exec(input)) {
|
|
1088
|
-
lastIndex = JSXString.lastIndex;
|
|
1089
|
-
lastSignificantToken = match[0];
|
|
1090
|
-
yield ({
|
|
1091
|
-
type: "JSXString",
|
|
1092
|
-
value: match[0],
|
|
1093
|
-
closed: match[2] !== void 0
|
|
1094
|
-
});
|
|
1095
|
-
continue;
|
|
1096
|
-
}
|
|
1097
|
-
break;
|
|
1098
|
-
case "JSXChildren":
|
|
1099
|
-
JSXText.lastIndex = lastIndex;
|
|
1100
|
-
if (match = JSXText.exec(input)) {
|
|
1101
|
-
lastIndex = JSXText.lastIndex;
|
|
1102
|
-
lastSignificantToken = match[0];
|
|
1103
|
-
yield ({
|
|
1104
|
-
type: "JSXText",
|
|
1105
|
-
value: match[0]
|
|
1106
|
-
});
|
|
1107
|
-
continue;
|
|
1108
|
-
}
|
|
1109
|
-
switch (input[lastIndex]) {
|
|
1110
|
-
case "<":
|
|
1111
|
-
stack.push({tag: "JSXTag"});
|
|
1112
|
-
lastIndex++;
|
|
1113
|
-
lastSignificantToken = "<";
|
|
1114
|
-
yield ({
|
|
1115
|
-
type: "JSXPunctuator",
|
|
1116
|
-
value: "<"
|
|
1117
|
-
});
|
|
1118
|
-
continue;
|
|
1119
|
-
case "{":
|
|
1120
|
-
stack.push({
|
|
1121
|
-
tag: "InterpolationInJSX",
|
|
1122
|
-
nesting: braces.length
|
|
1123
|
-
});
|
|
1124
|
-
lastIndex++;
|
|
1125
|
-
lastSignificantToken = "?InterpolationInJSX";
|
|
1126
|
-
postfixIncDec = false;
|
|
1127
|
-
yield ({
|
|
1128
|
-
type: "JSXPunctuator",
|
|
1129
|
-
value: "{"
|
|
1130
|
-
});
|
|
1131
|
-
continue;
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
WhiteSpace.lastIndex = lastIndex;
|
|
1135
|
-
if (match = WhiteSpace.exec(input)) {
|
|
1136
|
-
lastIndex = WhiteSpace.lastIndex;
|
|
1137
|
-
yield ({
|
|
1138
|
-
type: "WhiteSpace",
|
|
1139
|
-
value: match[0]
|
|
1140
|
-
});
|
|
1141
|
-
continue;
|
|
1142
|
-
}
|
|
1143
|
-
LineTerminatorSequence.lastIndex = lastIndex;
|
|
1144
|
-
if (match = LineTerminatorSequence.exec(input)) {
|
|
1145
|
-
lastIndex = LineTerminatorSequence.lastIndex;
|
|
1146
|
-
postfixIncDec = false;
|
|
1147
|
-
if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) {
|
|
1148
|
-
lastSignificantToken = "?NoLineTerminatorHere";
|
|
1149
|
-
}
|
|
1150
|
-
yield ({
|
|
1151
|
-
type: "LineTerminatorSequence",
|
|
1152
|
-
value: match[0]
|
|
1153
|
-
});
|
|
1154
|
-
continue;
|
|
1155
|
-
}
|
|
1156
|
-
MultiLineComment.lastIndex = lastIndex;
|
|
1157
|
-
if (match = MultiLineComment.exec(input)) {
|
|
1158
|
-
lastIndex = MultiLineComment.lastIndex;
|
|
1159
|
-
if (Newline.test(match[0])) {
|
|
1160
|
-
postfixIncDec = false;
|
|
1161
|
-
if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) {
|
|
1162
|
-
lastSignificantToken = "?NoLineTerminatorHere";
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
yield ({
|
|
1166
|
-
type: "MultiLineComment",
|
|
1167
|
-
value: match[0],
|
|
1168
|
-
closed: match[1] !== void 0
|
|
1169
|
-
});
|
|
1170
|
-
continue;
|
|
1171
|
-
}
|
|
1172
|
-
SingleLineComment.lastIndex = lastIndex;
|
|
1173
|
-
if (match = SingleLineComment.exec(input)) {
|
|
1174
|
-
lastIndex = SingleLineComment.lastIndex;
|
|
1175
|
-
postfixIncDec = false;
|
|
1176
|
-
yield ({
|
|
1177
|
-
type: "SingleLineComment",
|
|
1178
|
-
value: match[0]
|
|
1179
|
-
});
|
|
1180
|
-
continue;
|
|
1181
|
-
}
|
|
1182
|
-
firstCodePoint = String.fromCodePoint(input.codePointAt(lastIndex));
|
|
1183
|
-
lastIndex += firstCodePoint.length;
|
|
1184
|
-
lastSignificantToken = firstCodePoint;
|
|
1185
|
-
postfixIncDec = false;
|
|
1186
|
-
yield ({
|
|
1187
|
-
type: mode.tag.startsWith("JSX") ? "JSXInvalid" : "Invalid",
|
|
1188
|
-
value: firstCodePoint
|
|
1189
|
-
});
|
|
1190
|
-
}
|
|
1191
|
-
return void 0;
|
|
497
|
+
function memoizedState() {
|
|
498
|
+
return {
|
|
499
|
+
lastKey: -1,
|
|
500
|
+
lastNeedle: -1,
|
|
501
|
+
lastIndex: -1
|
|
1192
502
|
};
|
|
1193
|
-
return jsTokens_1;
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
requireJsTokens();
|
|
1197
|
-
|
|
1198
|
-
// src/index.ts
|
|
1199
|
-
var reservedWords = {
|
|
1200
|
-
keyword: [
|
|
1201
|
-
"break",
|
|
1202
|
-
"case",
|
|
1203
|
-
"catch",
|
|
1204
|
-
"continue",
|
|
1205
|
-
"debugger",
|
|
1206
|
-
"default",
|
|
1207
|
-
"do",
|
|
1208
|
-
"else",
|
|
1209
|
-
"finally",
|
|
1210
|
-
"for",
|
|
1211
|
-
"function",
|
|
1212
|
-
"if",
|
|
1213
|
-
"return",
|
|
1214
|
-
"switch",
|
|
1215
|
-
"throw",
|
|
1216
|
-
"try",
|
|
1217
|
-
"var",
|
|
1218
|
-
"const",
|
|
1219
|
-
"while",
|
|
1220
|
-
"with",
|
|
1221
|
-
"new",
|
|
1222
|
-
"this",
|
|
1223
|
-
"super",
|
|
1224
|
-
"class",
|
|
1225
|
-
"extends",
|
|
1226
|
-
"export",
|
|
1227
|
-
"import",
|
|
1228
|
-
"null",
|
|
1229
|
-
"true",
|
|
1230
|
-
"false",
|
|
1231
|
-
"in",
|
|
1232
|
-
"instanceof",
|
|
1233
|
-
"typeof",
|
|
1234
|
-
"void",
|
|
1235
|
-
"delete"
|
|
1236
|
-
],
|
|
1237
|
-
strict: [
|
|
1238
|
-
"implements",
|
|
1239
|
-
"interface",
|
|
1240
|
-
"let",
|
|
1241
|
-
"package",
|
|
1242
|
-
"private",
|
|
1243
|
-
"protected",
|
|
1244
|
-
"public",
|
|
1245
|
-
"static",
|
|
1246
|
-
"yield"
|
|
1247
|
-
]
|
|
1248
|
-
}; new Set(reservedWords.keyword); new Set(reservedWords.strict);
|
|
1249
|
-
|
|
1250
|
-
// src/index.ts
|
|
1251
|
-
var f = {
|
|
1252
|
-
reset: [0, 0],
|
|
1253
|
-
bold: [1, 22, "\x1B[22m\x1B[1m"],
|
|
1254
|
-
dim: [2, 22, "\x1B[22m\x1B[2m"],
|
|
1255
|
-
italic: [3, 23],
|
|
1256
|
-
underline: [4, 24],
|
|
1257
|
-
inverse: [7, 27],
|
|
1258
|
-
hidden: [8, 28],
|
|
1259
|
-
strikethrough: [9, 29],
|
|
1260
|
-
black: [30, 39],
|
|
1261
|
-
red: [31, 39],
|
|
1262
|
-
green: [32, 39],
|
|
1263
|
-
yellow: [33, 39],
|
|
1264
|
-
blue: [34, 39],
|
|
1265
|
-
magenta: [35, 39],
|
|
1266
|
-
cyan: [36, 39],
|
|
1267
|
-
white: [37, 39],
|
|
1268
|
-
gray: [90, 39],
|
|
1269
|
-
bgBlack: [40, 49],
|
|
1270
|
-
bgRed: [41, 49],
|
|
1271
|
-
bgGreen: [42, 49],
|
|
1272
|
-
bgYellow: [43, 49],
|
|
1273
|
-
bgBlue: [44, 49],
|
|
1274
|
-
bgMagenta: [45, 49],
|
|
1275
|
-
bgCyan: [46, 49],
|
|
1276
|
-
bgWhite: [47, 49],
|
|
1277
|
-
blackBright: [90, 39],
|
|
1278
|
-
redBright: [91, 39],
|
|
1279
|
-
greenBright: [92, 39],
|
|
1280
|
-
yellowBright: [93, 39],
|
|
1281
|
-
blueBright: [94, 39],
|
|
1282
|
-
magentaBright: [95, 39],
|
|
1283
|
-
cyanBright: [96, 39],
|
|
1284
|
-
whiteBright: [97, 39],
|
|
1285
|
-
bgBlackBright: [100, 49],
|
|
1286
|
-
bgRedBright: [101, 49],
|
|
1287
|
-
bgGreenBright: [102, 49],
|
|
1288
|
-
bgYellowBright: [103, 49],
|
|
1289
|
-
bgBlueBright: [104, 49],
|
|
1290
|
-
bgMagentaBright: [105, 49],
|
|
1291
|
-
bgCyanBright: [106, 49],
|
|
1292
|
-
bgWhiteBright: [107, 49]
|
|
1293
|
-
}, h = Object.entries(f);
|
|
1294
|
-
function a(n) {
|
|
1295
|
-
return String(n);
|
|
1296
|
-
}
|
|
1297
|
-
a.open = "";
|
|
1298
|
-
a.close = "";
|
|
1299
|
-
function C(n = false) {
|
|
1300
|
-
let e = typeof process != "undefined" ? process : void 0, i = (e == null ? void 0 : e.env) || {}, g = (e == null ? void 0 : e.argv) || [];
|
|
1301
|
-
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;
|
|
1302
503
|
}
|
|
1303
|
-
function
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
return l + r.substring(s);
|
|
1310
|
-
}, g = (r, t, c = r) => {
|
|
1311
|
-
let o = (l) => {
|
|
1312
|
-
let s = String(l), b = s.indexOf(t, r.length);
|
|
1313
|
-
return ~b ? r + i(s, t, c, b) + t : r + s + t;
|
|
1314
|
-
};
|
|
1315
|
-
return o.open = r, o.close = t, o;
|
|
1316
|
-
}, u = {
|
|
1317
|
-
isColorSupported: e
|
|
1318
|
-
}, d = (r) => `\x1B[${r}m`;
|
|
1319
|
-
for (let [r, t] of h)
|
|
1320
|
-
u[r] = e ? g(
|
|
1321
|
-
d(t[0]),
|
|
1322
|
-
d(t[1]),
|
|
1323
|
-
t[2]
|
|
1324
|
-
) : a;
|
|
1325
|
-
return u;
|
|
504
|
+
function getOriginalPosition(map, needle) {
|
|
505
|
+
const result = originalPositionFor(map, needle);
|
|
506
|
+
if (result.column == null) {
|
|
507
|
+
return null;
|
|
508
|
+
}
|
|
509
|
+
return result;
|
|
1326
510
|
}
|
|
1327
511
|
|
|
1328
|
-
p();
|
|
1329
|
-
|
|
1330
512
|
const lineSplitRE = /\r?\n/;
|
|
1331
513
|
function positionToOffset(source, lineNumber, columnNumber) {
|
|
1332
514
|
const lines = source.split(lineSplitRE);
|
|
@@ -1475,6 +657,7 @@ function replaceInlineSnap(code, s, currentIndex, newSnap) {
|
|
|
1475
657
|
}
|
|
1476
658
|
const INDENTATION_REGEX = /^([^\S\n]*)\S/m;
|
|
1477
659
|
function stripSnapshotIndentation(inlineSnapshot) {
|
|
660
|
+
var _lines$at;
|
|
1478
661
|
// Find indentation if exists.
|
|
1479
662
|
const match = inlineSnapshot.match(INDENTATION_REGEX);
|
|
1480
663
|
if (!match || !match[1]) {
|
|
@@ -1487,7 +670,7 @@ function stripSnapshotIndentation(inlineSnapshot) {
|
|
|
1487
670
|
// Must be at least 3 lines.
|
|
1488
671
|
return inlineSnapshot;
|
|
1489
672
|
}
|
|
1490
|
-
if (lines[0].trim() !== "" || lines
|
|
673
|
+
if (lines[0].trim() !== "" || ((_lines$at = lines.at(-1)) === null || _lines$at === void 0 ? void 0 : _lines$at.trim()) !== "") {
|
|
1491
674
|
// If not blank first and last lines, abort.
|
|
1492
675
|
return inlineSnapshot;
|
|
1493
676
|
}
|
|
@@ -1518,6 +701,10 @@ async function saveRawSnapshots(environment, snapshots) {
|
|
|
1518
701
|
}));
|
|
1519
702
|
}
|
|
1520
703
|
|
|
704
|
+
function getDefaultExportFromCjs (x) {
|
|
705
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
706
|
+
}
|
|
707
|
+
|
|
1521
708
|
var naturalCompare$1 = {exports: {}};
|
|
1522
709
|
|
|
1523
710
|
var hasRequiredNaturalCompare;
|
|
@@ -1663,7 +850,7 @@ function addExtraLineBreaks(string) {
|
|
|
1663
850
|
// Instead of trim, which can remove additional newlines or spaces
|
|
1664
851
|
// at beginning or end of the content from a custom serializer.
|
|
1665
852
|
function removeExtraLineBreaks(string) {
|
|
1666
|
-
return string.length > 2 && string
|
|
853
|
+
return string.length > 2 && string[0] === "\n" && string.endsWith("\n") ? string.slice(1, -1) : string;
|
|
1667
854
|
}
|
|
1668
855
|
// export const removeLinesBeforeExternalMatcherTrap = (stack: string): string => {
|
|
1669
856
|
// const lines = stack.split('\n')
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/snapshot",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0
|
|
4
|
+
"version": "4.0.0",
|
|
5
5
|
"description": "Vitest snapshot manager",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -38,17 +38,17 @@
|
|
|
38
38
|
"dist"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"magic-string": "^0.30.
|
|
41
|
+
"magic-string": "^0.30.19",
|
|
42
42
|
"pathe": "^2.0.3",
|
|
43
|
-
"@vitest/pretty-format": "4.0.0
|
|
43
|
+
"@vitest/pretty-format": "4.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/natural-compare": "^1.4.3",
|
|
47
47
|
"natural-compare": "^1.4.0",
|
|
48
|
-
"@vitest/utils": "4.0.0
|
|
48
|
+
"@vitest/utils": "4.0.0"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
|
-
"build": "
|
|
51
|
+
"build": "premove dist && rollup -c",
|
|
52
52
|
"dev": "rollup -c --watch"
|
|
53
53
|
}
|
|
54
54
|
}
|