vitest 4.0.0-beta.10 → 4.0.0-beta.11

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.
Files changed (61) hide show
  1. package/LICENSE.md +81 -0
  2. package/dist/browser.d.ts +9 -5
  3. package/dist/browser.js +8 -5
  4. package/dist/chunks/{benchmark.CJUa-Hsa.js → benchmark.LXhJ0F0X.js} +2 -2
  5. package/dist/chunks/{browser.d.yFAklsD1.d.ts → browser.d.Dx7DO_Ce.d.ts} +1 -1
  6. package/dist/chunks/{cac.DCxo_nSu.js → cac.elvK37c9.js} +8 -8
  7. package/dist/chunks/{cli-api.BJJXh9BV.js → cli-api.C7plPyhs.js} +64 -34
  8. package/dist/chunks/{console.7h5kHUIf.js → console.CiTi59Jy.js} +2 -2
  9. package/dist/chunks/{coverage.BCU-r2QL.js → coverage.CG6Uhorw.js} +14 -18
  10. package/dist/chunks/{globals.DG-S3xFe.js → globals.BjvYA-AD.js} +7 -5
  11. package/dist/chunks/{index.CMfqw92x.js → index.AZOjjqWP.js} +2 -2
  12. package/dist/chunks/{index.BjKEiSn0.js → index.BhY64fF0.js} +3 -3
  13. package/dist/chunks/{index.BIP7prJq.js → index.BwBttQPf.js} +67 -71
  14. package/dist/chunks/{moduleRunner.d.D9nBoC4p.d.ts → moduleRunner.d.BNa-CL9e.d.ts} +1 -1
  15. package/dist/chunks/{node.CyipiPvJ.js → node.BsdMi6DV.js} +2 -2
  16. package/dist/chunks/{plugin.d.BMVSnsGV.d.ts → plugin.d.C5phQR6o.d.ts} +1 -1
  17. package/dist/chunks/{reporters.d.BUWjmRYq.d.ts → reporters.d.CVzhsTvK.d.ts} +16 -11
  18. package/dist/chunks/{resolveSnapshotEnvironment.Bkht6Yor.js → resolveSnapshotEnvironment.DQVamkje.js} +5 -5
  19. package/dist/chunks/{rpc.BKr6mtxz.js → rpc.jKGRSXIH.js} +2 -2
  20. package/dist/chunks/{setup-common.uiMcU3cv.js → setup-common.NAWRuMRP.js} +3 -3
  21. package/dist/chunks/{startModuleRunner.p67gbNo9.js → startModuleRunner.oAuCu1yL.js} +27 -10
  22. package/dist/chunks/{test.BiqSKISg.js → test.KC5tH8hC.js} +6 -6
  23. package/dist/chunks/{typechecker.DB-fIMaH.js → typechecker.gXq-5P3n.js} +640 -7
  24. package/dist/chunks/{utils.D2R2NiOH.js → utils.DGKhod2J.js} +1 -1
  25. package/dist/chunks/{vi.ZPgvtBao.js → vi.CiJ0Laa6.js} +4 -2
  26. package/dist/chunks/{worker.d.BDsXGkwh.d.ts → worker.d.B_Fd9M_w.d.ts} +1 -76
  27. package/dist/{worker.js → chunks/worker.rPGLlbkW.js} +65 -32
  28. package/dist/cli.js +7 -5
  29. package/dist/config.d.ts +5 -5
  30. package/dist/coverage.d.ts +3 -3
  31. package/dist/coverage.js +3 -4
  32. package/dist/index.d.ts +4 -4
  33. package/dist/index.js +7 -5
  34. package/dist/module-evaluator.d.ts +2 -2
  35. package/dist/module-evaluator.js +1 -1
  36. package/dist/module-runner.js +5 -5
  37. package/dist/node.d.ts +12 -9
  38. package/dist/node.js +16 -12
  39. package/dist/reporters.d.ts +3 -3
  40. package/dist/reporters.js +7 -5
  41. package/dist/runners.js +8 -6
  42. package/dist/snapshot.js +3 -3
  43. package/dist/suite.js +4 -3
  44. package/dist/{chunks/base.Cjha6usc.js → worker-base.js} +88 -14
  45. package/dist/{chunks/vm.Ca0Y0W5f.js → worker-vm.js} +69 -8
  46. package/dist/workers/runVmTests.js +12 -9
  47. package/package.json +20 -19
  48. package/browser.d.ts +0 -1
  49. package/dist/chunks/moduleTransport.I-bgQy0S.js +0 -19
  50. package/dist/chunks/resolver.Bx6lE0iq.js +0 -119
  51. package/dist/chunks/utils.C2YI6McM.js +0 -52
  52. package/dist/chunks/worker.d.BNcX_2mH.d.ts +0 -8
  53. package/dist/workers/forks.js +0 -67
  54. package/dist/workers/threads.js +0 -55
  55. package/dist/workers/vmForks.js +0 -48
  56. package/dist/workers/vmThreads.js +0 -38
  57. package/dist/workers.d.ts +0 -38
  58. package/dist/workers.js +0 -48
  59. package/execute.d.ts +0 -1
  60. package/utils.d.ts +0 -1
  61. package/workers.d.ts +0 -1
@@ -1,11 +1,10 @@
1
1
  import nodeos__default from 'node:os';
2
2
  import { performance } from 'node:perf_hooks';
3
- import { TraceMap, generatedPositionFor, eachMapping } from '@vitest/utils/source-map';
4
- import { relative, basename, resolve, join } from 'pathe';
3
+ import { relative, basename, resolve as resolve$1, join } from 'pathe';
5
4
  import { x } from 'tinyexec';
6
5
  import { distDir } from '../path.js';
7
6
  import { getTests, generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes } from '@vitest/runner/utils';
8
- import '@vitest/utils';
7
+ import '@vitest/utils/helpers';
9
8
  import { parseAstAsync } from 'vite';
10
9
 
11
10
  const REGEXP_WRAP_PREFIX = "$$vitest:";
@@ -123,6 +122,640 @@ function convertTasksToEvents(file, onTask) {
123
122
  };
124
123
  }
125
124
 
125
+ // src/vlq.ts
126
+ var comma = ",".charCodeAt(0);
127
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
128
+ var intToChar = new Uint8Array(64);
129
+ var charToInt = new Uint8Array(128);
130
+ for (let i = 0; i < chars.length; i++) {
131
+ const c = chars.charCodeAt(i);
132
+ intToChar[i] = c;
133
+ charToInt[c] = i;
134
+ }
135
+ function decodeInteger(reader, relative) {
136
+ let value = 0;
137
+ let shift = 0;
138
+ let integer = 0;
139
+ do {
140
+ const c = reader.next();
141
+ integer = charToInt[c];
142
+ value |= (integer & 31) << shift;
143
+ shift += 5;
144
+ } while (integer & 32);
145
+ const shouldNegate = value & 1;
146
+ value >>>= 1;
147
+ if (shouldNegate) {
148
+ value = -2147483648 | -value;
149
+ }
150
+ return relative + value;
151
+ }
152
+ function hasMoreVlq(reader, max) {
153
+ if (reader.pos >= max) return false;
154
+ return reader.peek() !== comma;
155
+ }
156
+ var StringReader = class {
157
+ constructor(buffer) {
158
+ this.pos = 0;
159
+ this.buffer = buffer;
160
+ }
161
+ next() {
162
+ return this.buffer.charCodeAt(this.pos++);
163
+ }
164
+ peek() {
165
+ return this.buffer.charCodeAt(this.pos);
166
+ }
167
+ indexOf(char) {
168
+ const { buffer, pos } = this;
169
+ const idx = buffer.indexOf(char, pos);
170
+ return idx === -1 ? buffer.length : idx;
171
+ }
172
+ };
173
+
174
+ // src/sourcemap-codec.ts
175
+ function decode(mappings) {
176
+ const { length } = mappings;
177
+ const reader = new StringReader(mappings);
178
+ const decoded = [];
179
+ let genColumn = 0;
180
+ let sourcesIndex = 0;
181
+ let sourceLine = 0;
182
+ let sourceColumn = 0;
183
+ let namesIndex = 0;
184
+ do {
185
+ const semi = reader.indexOf(";");
186
+ const line = [];
187
+ let sorted = true;
188
+ let lastCol = 0;
189
+ genColumn = 0;
190
+ while (reader.pos < semi) {
191
+ let seg;
192
+ genColumn = decodeInteger(reader, genColumn);
193
+ if (genColumn < lastCol) sorted = false;
194
+ lastCol = genColumn;
195
+ if (hasMoreVlq(reader, semi)) {
196
+ sourcesIndex = decodeInteger(reader, sourcesIndex);
197
+ sourceLine = decodeInteger(reader, sourceLine);
198
+ sourceColumn = decodeInteger(reader, sourceColumn);
199
+ if (hasMoreVlq(reader, semi)) {
200
+ namesIndex = decodeInteger(reader, namesIndex);
201
+ seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
202
+ } else {
203
+ seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
204
+ }
205
+ } else {
206
+ seg = [genColumn];
207
+ }
208
+ line.push(seg);
209
+ reader.pos++;
210
+ }
211
+ if (!sorted) sort(line);
212
+ decoded.push(line);
213
+ reader.pos = semi + 1;
214
+ } while (reader.pos <= length);
215
+ return decoded;
216
+ }
217
+ function sort(line) {
218
+ line.sort(sortComparator$1);
219
+ }
220
+ function sortComparator$1(a, b) {
221
+ return a[0] - b[0];
222
+ }
223
+
224
+ // Matches the scheme of a URL, eg "http://"
225
+ const schemeRegex = /^[\w+.-]+:\/\//;
226
+ /**
227
+ * Matches the parts of a URL:
228
+ * 1. Scheme, including ":", guaranteed.
229
+ * 2. User/password, including "@", optional.
230
+ * 3. Host, guaranteed.
231
+ * 4. Port, including ":", optional.
232
+ * 5. Path, including "/", optional.
233
+ * 6. Query, including "?", optional.
234
+ * 7. Hash, including "#", optional.
235
+ */
236
+ const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
237
+ /**
238
+ * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start
239
+ * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).
240
+ *
241
+ * 1. Host, optional.
242
+ * 2. Path, which may include "/", guaranteed.
243
+ * 3. Query, including "?", optional.
244
+ * 4. Hash, including "#", optional.
245
+ */
246
+ const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
247
+ var UrlType;
248
+ (function (UrlType) {
249
+ UrlType[UrlType["Empty"] = 1] = "Empty";
250
+ UrlType[UrlType["Hash"] = 2] = "Hash";
251
+ UrlType[UrlType["Query"] = 3] = "Query";
252
+ UrlType[UrlType["RelativePath"] = 4] = "RelativePath";
253
+ UrlType[UrlType["AbsolutePath"] = 5] = "AbsolutePath";
254
+ UrlType[UrlType["SchemeRelative"] = 6] = "SchemeRelative";
255
+ UrlType[UrlType["Absolute"] = 7] = "Absolute";
256
+ })(UrlType || (UrlType = {}));
257
+ function isAbsoluteUrl(input) {
258
+ return schemeRegex.test(input);
259
+ }
260
+ function isSchemeRelativeUrl(input) {
261
+ return input.startsWith('//');
262
+ }
263
+ function isAbsolutePath(input) {
264
+ return input.startsWith('/');
265
+ }
266
+ function isFileUrl(input) {
267
+ return input.startsWith('file:');
268
+ }
269
+ function isRelative(input) {
270
+ return /^[.?#]/.test(input);
271
+ }
272
+ function parseAbsoluteUrl(input) {
273
+ const match = urlRegex.exec(input);
274
+ return makeUrl(match[1], match[2] || '', match[3], match[4] || '', match[5] || '/', match[6] || '', match[7] || '');
275
+ }
276
+ function parseFileUrl(input) {
277
+ const match = fileRegex.exec(input);
278
+ const path = match[2];
279
+ return makeUrl('file:', '', match[1] || '', '', isAbsolutePath(path) ? path : '/' + path, match[3] || '', match[4] || '');
280
+ }
281
+ function makeUrl(scheme, user, host, port, path, query, hash) {
282
+ return {
283
+ scheme,
284
+ user,
285
+ host,
286
+ port,
287
+ path,
288
+ query,
289
+ hash,
290
+ type: UrlType.Absolute,
291
+ };
292
+ }
293
+ function parseUrl(input) {
294
+ if (isSchemeRelativeUrl(input)) {
295
+ const url = parseAbsoluteUrl('http:' + input);
296
+ url.scheme = '';
297
+ url.type = UrlType.SchemeRelative;
298
+ return url;
299
+ }
300
+ if (isAbsolutePath(input)) {
301
+ const url = parseAbsoluteUrl('http://foo.com' + input);
302
+ url.scheme = '';
303
+ url.host = '';
304
+ url.type = UrlType.AbsolutePath;
305
+ return url;
306
+ }
307
+ if (isFileUrl(input))
308
+ return parseFileUrl(input);
309
+ if (isAbsoluteUrl(input))
310
+ return parseAbsoluteUrl(input);
311
+ const url = parseAbsoluteUrl('http://foo.com/' + input);
312
+ url.scheme = '';
313
+ url.host = '';
314
+ url.type = input
315
+ ? input.startsWith('?')
316
+ ? UrlType.Query
317
+ : input.startsWith('#')
318
+ ? UrlType.Hash
319
+ : UrlType.RelativePath
320
+ : UrlType.Empty;
321
+ return url;
322
+ }
323
+ function stripPathFilename(path) {
324
+ // If a path ends with a parent directory "..", then it's a relative path with excess parent
325
+ // paths. It's not a file, so we can't strip it.
326
+ if (path.endsWith('/..'))
327
+ return path;
328
+ const index = path.lastIndexOf('/');
329
+ return path.slice(0, index + 1);
330
+ }
331
+ function mergePaths(url, base) {
332
+ normalizePath(base, base.type);
333
+ // If the path is just a "/", then it was an empty path to begin with (remember, we're a relative
334
+ // path).
335
+ if (url.path === '/') {
336
+ url.path = base.path;
337
+ }
338
+ else {
339
+ // Resolution happens relative to the base path's directory, not the file.
340
+ url.path = stripPathFilename(base.path) + url.path;
341
+ }
342
+ }
343
+ /**
344
+ * The path can have empty directories "//", unneeded parents "foo/..", or current directory
345
+ * "foo/.". We need to normalize to a standard representation.
346
+ */
347
+ function normalizePath(url, type) {
348
+ const rel = type <= UrlType.RelativePath;
349
+ const pieces = url.path.split('/');
350
+ // We need to preserve the first piece always, so that we output a leading slash. The item at
351
+ // pieces[0] is an empty string.
352
+ let pointer = 1;
353
+ // Positive is the number of real directories we've output, used for popping a parent directory.
354
+ // Eg, "foo/bar/.." will have a positive 2, and we can decrement to be left with just "foo".
355
+ let positive = 0;
356
+ // We need to keep a trailing slash if we encounter an empty directory (eg, splitting "foo/" will
357
+ // generate `["foo", ""]` pieces). And, if we pop a parent directory. But once we encounter a
358
+ // real directory, we won't need to append, unless the other conditions happen again.
359
+ let addTrailingSlash = false;
360
+ for (let i = 1; i < pieces.length; i++) {
361
+ const piece = pieces[i];
362
+ // An empty directory, could be a trailing slash, or just a double "//" in the path.
363
+ if (!piece) {
364
+ addTrailingSlash = true;
365
+ continue;
366
+ }
367
+ // If we encounter a real directory, then we don't need to append anymore.
368
+ addTrailingSlash = false;
369
+ // A current directory, which we can always drop.
370
+ if (piece === '.')
371
+ continue;
372
+ // A parent directory, we need to see if there are any real directories we can pop. Else, we
373
+ // have an excess of parents, and we'll need to keep the "..".
374
+ if (piece === '..') {
375
+ if (positive) {
376
+ addTrailingSlash = true;
377
+ positive--;
378
+ pointer--;
379
+ }
380
+ else if (rel) {
381
+ // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute
382
+ // URL, protocol relative URL, or an absolute path, we don't need to keep excess.
383
+ pieces[pointer++] = piece;
384
+ }
385
+ continue;
386
+ }
387
+ // We've encountered a real directory. Move it to the next insertion pointer, which accounts for
388
+ // any popped or dropped directories.
389
+ pieces[pointer++] = piece;
390
+ positive++;
391
+ }
392
+ let path = '';
393
+ for (let i = 1; i < pointer; i++) {
394
+ path += '/' + pieces[i];
395
+ }
396
+ if (!path || (addTrailingSlash && !path.endsWith('/..'))) {
397
+ path += '/';
398
+ }
399
+ url.path = path;
400
+ }
401
+ /**
402
+ * Attempts to resolve `input` URL/path relative to `base`.
403
+ */
404
+ function resolve(input, base) {
405
+ if (!input && !base)
406
+ return '';
407
+ const url = parseUrl(input);
408
+ let inputType = url.type;
409
+ if (base && inputType !== UrlType.Absolute) {
410
+ const baseUrl = parseUrl(base);
411
+ const baseType = baseUrl.type;
412
+ switch (inputType) {
413
+ case UrlType.Empty:
414
+ url.hash = baseUrl.hash;
415
+ // fall through
416
+ case UrlType.Hash:
417
+ url.query = baseUrl.query;
418
+ // fall through
419
+ case UrlType.Query:
420
+ case UrlType.RelativePath:
421
+ mergePaths(url, baseUrl);
422
+ // fall through
423
+ case UrlType.AbsolutePath:
424
+ // The host, user, and port are joined, you can't copy one without the others.
425
+ url.user = baseUrl.user;
426
+ url.host = baseUrl.host;
427
+ url.port = baseUrl.port;
428
+ // fall through
429
+ case UrlType.SchemeRelative:
430
+ // The input doesn't have a schema at least, so we need to copy at least that over.
431
+ url.scheme = baseUrl.scheme;
432
+ }
433
+ if (baseType > inputType)
434
+ inputType = baseType;
435
+ }
436
+ normalizePath(url, inputType);
437
+ const queryHash = url.query + url.hash;
438
+ switch (inputType) {
439
+ // This is impossible, because of the empty checks at the start of the function.
440
+ // case UrlType.Empty:
441
+ case UrlType.Hash:
442
+ case UrlType.Query:
443
+ return queryHash;
444
+ case UrlType.RelativePath: {
445
+ // The first char is always a "/", and we need it to be relative.
446
+ const path = url.path.slice(1);
447
+ if (!path)
448
+ return queryHash || '.';
449
+ if (isRelative(base || input) && !isRelative(path)) {
450
+ // If base started with a leading ".", or there is no base and input started with a ".",
451
+ // then we need to ensure that the relative path starts with a ".". We don't know if
452
+ // relative starts with a "..", though, so check before prepending.
453
+ return './' + path + queryHash;
454
+ }
455
+ return path + queryHash;
456
+ }
457
+ case UrlType.AbsolutePath:
458
+ return url.path + queryHash;
459
+ default:
460
+ return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;
461
+ }
462
+ }
463
+
464
+ // src/trace-mapping.ts
465
+
466
+ // src/strip-filename.ts
467
+ function stripFilename(path) {
468
+ if (!path) return "";
469
+ const index = path.lastIndexOf("/");
470
+ return path.slice(0, index + 1);
471
+ }
472
+
473
+ // src/resolve.ts
474
+ function resolver(mapUrl, sourceRoot) {
475
+ const from = stripFilename(mapUrl);
476
+ const prefix = sourceRoot ? sourceRoot + "/" : "";
477
+ return (source) => resolve(prefix + (source || ""), from);
478
+ }
479
+
480
+ // src/sourcemap-segment.ts
481
+ var COLUMN = 0;
482
+ var SOURCES_INDEX = 1;
483
+ var SOURCE_LINE = 2;
484
+ var SOURCE_COLUMN = 3;
485
+ var NAMES_INDEX = 4;
486
+ var REV_GENERATED_LINE = 1;
487
+ var REV_GENERATED_COLUMN = 2;
488
+
489
+ // src/sort.ts
490
+ function maybeSort(mappings, owned) {
491
+ const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
492
+ if (unsortedIndex === mappings.length) return mappings;
493
+ if (!owned) mappings = mappings.slice();
494
+ for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
495
+ mappings[i] = sortSegments(mappings[i], owned);
496
+ }
497
+ return mappings;
498
+ }
499
+ function nextUnsortedSegmentLine(mappings, start) {
500
+ for (let i = start; i < mappings.length; i++) {
501
+ if (!isSorted(mappings[i])) return i;
502
+ }
503
+ return mappings.length;
504
+ }
505
+ function isSorted(line) {
506
+ for (let j = 1; j < line.length; j++) {
507
+ if (line[j][COLUMN] < line[j - 1][COLUMN]) {
508
+ return false;
509
+ }
510
+ }
511
+ return true;
512
+ }
513
+ function sortSegments(line, owned) {
514
+ if (!owned) line = line.slice();
515
+ return line.sort(sortComparator);
516
+ }
517
+ function sortComparator(a, b) {
518
+ return a[COLUMN] - b[COLUMN];
519
+ }
520
+
521
+ // src/binary-search.ts
522
+ var found = false;
523
+ function binarySearch(haystack, needle, low, high) {
524
+ while (low <= high) {
525
+ const mid = low + (high - low >> 1);
526
+ const cmp = haystack[mid][COLUMN] - needle;
527
+ if (cmp === 0) {
528
+ found = true;
529
+ return mid;
530
+ }
531
+ if (cmp < 0) {
532
+ low = mid + 1;
533
+ } else {
534
+ high = mid - 1;
535
+ }
536
+ }
537
+ found = false;
538
+ return low - 1;
539
+ }
540
+ function upperBound(haystack, needle, index) {
541
+ for (let i = index + 1; i < haystack.length; index = i++) {
542
+ if (haystack[i][COLUMN] !== needle) break;
543
+ }
544
+ return index;
545
+ }
546
+ function lowerBound(haystack, needle, index) {
547
+ for (let i = index - 1; i >= 0; index = i--) {
548
+ if (haystack[i][COLUMN] !== needle) break;
549
+ }
550
+ return index;
551
+ }
552
+ function memoizedState() {
553
+ return {
554
+ lastKey: -1,
555
+ lastNeedle: -1,
556
+ lastIndex: -1
557
+ };
558
+ }
559
+ function memoizedBinarySearch(haystack, needle, state, key) {
560
+ const { lastKey, lastNeedle, lastIndex } = state;
561
+ let low = 0;
562
+ let high = haystack.length - 1;
563
+ if (key === lastKey) {
564
+ if (needle === lastNeedle) {
565
+ found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
566
+ return lastIndex;
567
+ }
568
+ if (needle >= lastNeedle) {
569
+ low = lastIndex === -1 ? 0 : lastIndex;
570
+ } else {
571
+ high = lastIndex;
572
+ }
573
+ }
574
+ state.lastKey = key;
575
+ state.lastNeedle = needle;
576
+ return state.lastIndex = binarySearch(haystack, needle, low, high);
577
+ }
578
+
579
+ // src/by-source.ts
580
+ function buildBySources(decoded, memos) {
581
+ const sources = memos.map(buildNullArray);
582
+ for (let i = 0; i < decoded.length; i++) {
583
+ const line = decoded[i];
584
+ for (let j = 0; j < line.length; j++) {
585
+ const seg = line[j];
586
+ if (seg.length === 1) continue;
587
+ const sourceIndex2 = seg[SOURCES_INDEX];
588
+ const sourceLine = seg[SOURCE_LINE];
589
+ const sourceColumn = seg[SOURCE_COLUMN];
590
+ const originalSource = sources[sourceIndex2];
591
+ const originalLine = originalSource[sourceLine] || (originalSource[sourceLine] = []);
592
+ const memo = memos[sourceIndex2];
593
+ let index = upperBound(
594
+ originalLine,
595
+ sourceColumn,
596
+ memoizedBinarySearch(originalLine, sourceColumn, memo, sourceLine)
597
+ );
598
+ memo.lastIndex = ++index;
599
+ insert(originalLine, index, [sourceColumn, i, seg[COLUMN]]);
600
+ }
601
+ }
602
+ return sources;
603
+ }
604
+ function insert(array, index, value) {
605
+ for (let i = array.length; i > index; i--) {
606
+ array[i] = array[i - 1];
607
+ }
608
+ array[index] = value;
609
+ }
610
+ function buildNullArray() {
611
+ return { __proto__: null };
612
+ }
613
+
614
+ // src/types.ts
615
+ function parse(map) {
616
+ return typeof map === "string" ? JSON.parse(map) : map;
617
+ }
618
+
619
+ // src/trace-mapping.ts
620
+ var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
621
+ var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
622
+ var LEAST_UPPER_BOUND = -1;
623
+ var GREATEST_LOWER_BOUND = 1;
624
+ var TraceMap = class {
625
+ constructor(map, mapUrl) {
626
+ const isString = typeof map === "string";
627
+ if (!isString && map._decodedMemo) return map;
628
+ const parsed = parse(map);
629
+ const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
630
+ this.version = version;
631
+ this.file = file;
632
+ this.names = names || [];
633
+ this.sourceRoot = sourceRoot;
634
+ this.sources = sources;
635
+ this.sourcesContent = sourcesContent;
636
+ this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
637
+ const resolve = resolver(mapUrl, sourceRoot);
638
+ this.resolvedSources = sources.map(resolve);
639
+ const { mappings } = parsed;
640
+ if (typeof mappings === "string") {
641
+ this._encoded = mappings;
642
+ this._decoded = void 0;
643
+ } else if (Array.isArray(mappings)) {
644
+ this._encoded = void 0;
645
+ this._decoded = maybeSort(mappings, isString);
646
+ } else if (parsed.sections) {
647
+ throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
648
+ } else {
649
+ throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
650
+ }
651
+ this._decodedMemo = memoizedState();
652
+ this._bySources = void 0;
653
+ this._bySourceMemos = void 0;
654
+ }
655
+ };
656
+ function cast(map) {
657
+ return map;
658
+ }
659
+ function decodedMappings(map) {
660
+ var _a;
661
+ return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
662
+ }
663
+ function originalPositionFor(map, needle) {
664
+ let { line, column, bias } = needle;
665
+ line--;
666
+ if (line < 0) throw new Error(LINE_GTR_ZERO);
667
+ if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
668
+ const decoded = decodedMappings(map);
669
+ if (line >= decoded.length) return OMapping(null, null, null, null);
670
+ const segments = decoded[line];
671
+ const index = traceSegmentInternal(
672
+ segments,
673
+ cast(map)._decodedMemo,
674
+ line,
675
+ column,
676
+ bias || GREATEST_LOWER_BOUND
677
+ );
678
+ if (index === -1) return OMapping(null, null, null, null);
679
+ const segment = segments[index];
680
+ if (segment.length === 1) return OMapping(null, null, null, null);
681
+ const { names, resolvedSources } = map;
682
+ return OMapping(
683
+ resolvedSources[segment[SOURCES_INDEX]],
684
+ segment[SOURCE_LINE] + 1,
685
+ segment[SOURCE_COLUMN],
686
+ segment.length === 5 ? names[segment[NAMES_INDEX]] : null
687
+ );
688
+ }
689
+ function generatedPositionFor(map, needle) {
690
+ const { source, line, column, bias } = needle;
691
+ return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false);
692
+ }
693
+ function eachMapping(map, cb) {
694
+ const decoded = decodedMappings(map);
695
+ const { names, resolvedSources } = map;
696
+ for (let i = 0; i < decoded.length; i++) {
697
+ const line = decoded[i];
698
+ for (let j = 0; j < line.length; j++) {
699
+ const seg = line[j];
700
+ const generatedLine = i + 1;
701
+ const generatedColumn = seg[0];
702
+ let source = null;
703
+ let originalLine = null;
704
+ let originalColumn = null;
705
+ let name = null;
706
+ if (seg.length !== 1) {
707
+ source = resolvedSources[seg[1]];
708
+ originalLine = seg[2] + 1;
709
+ originalColumn = seg[3];
710
+ }
711
+ if (seg.length === 5) name = names[seg[4]];
712
+ cb({
713
+ generatedLine,
714
+ generatedColumn,
715
+ source,
716
+ originalLine,
717
+ originalColumn,
718
+ name
719
+ });
720
+ }
721
+ }
722
+ }
723
+ function OMapping(source, line, column, name) {
724
+ return { source, line, column, name };
725
+ }
726
+ function GMapping(line, column) {
727
+ return { line, column };
728
+ }
729
+ function traceSegmentInternal(segments, memo, line, column, bias) {
730
+ let index = memoizedBinarySearch(segments, column, memo, line);
731
+ if (found) {
732
+ index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
733
+ } else if (bias === LEAST_UPPER_BOUND) index++;
734
+ if (index === -1 || index === segments.length) return -1;
735
+ return index;
736
+ }
737
+ function generatedPosition(map, source, line, column, bias, all) {
738
+ var _a;
739
+ line--;
740
+ if (line < 0) throw new Error(LINE_GTR_ZERO);
741
+ if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
742
+ const { sources, resolvedSources } = map;
743
+ let sourceIndex2 = sources.indexOf(source);
744
+ if (sourceIndex2 === -1) sourceIndex2 = resolvedSources.indexOf(source);
745
+ if (sourceIndex2 === -1) return all ? [] : GMapping(null, null);
746
+ const generated = (_a = cast(map))._bySources || (_a._bySources = buildBySources(
747
+ decodedMappings(map),
748
+ cast(map)._bySourceMemos = sources.map(memoizedState)
749
+ ));
750
+ const segments = generated[sourceIndex2][line];
751
+ if (segments == null) return all ? [] : GMapping(null, null);
752
+ const memo = cast(map)._bySourceMemos[sourceIndex2];
753
+ const index = traceSegmentInternal(segments, memo, line, column, bias);
754
+ if (index === -1) return GMapping(null, null);
755
+ const segment = segments[index];
756
+ return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);
757
+ }
758
+
126
759
  // AST walker module for ESTree compatible trees
127
760
 
128
761
 
@@ -549,7 +1182,7 @@ async function makeTscErrorInfo(errInfo) {
549
1182
  async function getRawErrsMapFromTsCompile(tscErrorStdout) {
550
1183
  const rawErrsMap = /* @__PURE__ */ new Map(), infos = await Promise.all(tscErrorStdout.split(newLineRegExp).reduce((prev, next) => {
551
1184
  if (!next) return prev;
552
- if (!next.startsWith(" ")) prev.push(next);
1185
+ if (next[0] !== " ") prev.push(next);
553
1186
  else prev[prev.length - 1] += `\n${next}`;
554
1187
  return prev;
555
1188
  }, []).map((errInfoLine) => makeTscErrorInfo(errInfoLine)));
@@ -663,7 +1296,7 @@ class Typechecker {
663
1296
  async parseTscLikeOutput(output) {
664
1297
  const errorsMap = await getRawErrsMapFromTsCompile(output), typesErrors = /* @__PURE__ */ new Map();
665
1298
  return errorsMap.forEach((errors, path) => {
666
- const filepath = resolve(this.project.config.root, path), suiteErrors = errors.map((info) => {
1299
+ const filepath = resolve$1(this.project.config.root, path), suiteErrors = errors.map((info) => {
667
1300
  const limit = Error.stackTraceLimit;
668
1301
  Error.stackTraceLimit = 0;
669
1302
  // Some expect-type errors have the most useful information on the second line e.g. `This expression is not callable.\n Type 'ExpectString<number>' has no call signatures.`
@@ -712,7 +1345,7 @@ class Typechecker {
712
1345
  // use builtin watcher because it's faster
713
1346
  if (watch) args.push("--watch");
714
1347
  if (typecheck.allowJs) args.push("--allowJs", "--checkJs");
715
- if (typecheck.tsconfig) args.push("-p", resolve(root, typecheck.tsconfig));
1348
+ if (typecheck.tsconfig) args.push("-p", resolve$1(root, typecheck.tsconfig));
716
1349
  this._output = "", this._startTime = performance.now();
717
1350
  const child = x(typecheck.checker, args, {
718
1351
  nodeOptions: {
@@ -802,4 +1435,4 @@ function findGeneratedPosition(traceMap, { line, column, source }) {
802
1435
  };
803
1436
  }
804
1437
 
805
- export { TypeCheckError as T, Typechecker as a, ancestor as b, createDefinesScript as c, convertTasksToEvents as d, getOutputFile as g, hasFailedSnapshot as h, wrapSerializableConfig as w };
1438
+ export { TypeCheckError as T, Typechecker as a, TraceMap as b, ancestor as c, createDefinesScript as d, convertTasksToEvents as e, getOutputFile as g, hasFailedSnapshot as h, originalPositionFor as o, wrapSerializableConfig as w };
@@ -1,4 +1,4 @@
1
- import { getSafeTimers } from '@vitest/utils';
1
+ import { getSafeTimers } from '@vitest/utils/timers';
2
2
 
3
3
  const NAME_WORKER_STATE = "__vitest_worker__";
4
4
  function getWorkerState() {