@vitest/utils 4.0.0-beta.1 → 4.0.0-beta.10
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/LICENSE +1 -1
- package/dist/chunk-helpers.js +329 -0
- package/dist/chunk-pathe.M-eThtNZ.js +156 -0
- package/dist/diff.d.ts +2 -13
- package/dist/diff.js +3 -2
- package/dist/error.d.ts +0 -1
- package/dist/error.js +1 -1
- package/dist/helpers.d.ts +17 -4
- package/dist/helpers.js +1 -251
- package/dist/index.d.ts +24 -6
- package/dist/index.js +1 -1
- package/dist/resolver.d.ts +7 -0
- package/dist/resolver.js +71 -0
- package/dist/source-map.d.ts +9 -4
- package/dist/source-map.js +243 -386
- package/dist/types.d.ts +1 -1
- package/package.json +7 -10
package/dist/source-map.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { isPrimitive, notNullish } from './helpers.js';
|
|
1
|
+
import { i as isPrimitive, n as notNullish } from './chunk-helpers.js';
|
|
2
|
+
import { r as resolve$1 } from './chunk-pathe.M-eThtNZ.js';
|
|
2
3
|
|
|
3
4
|
const comma = ','.charCodeAt(0);
|
|
4
5
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
@@ -282,7 +283,7 @@ function normalizePath(url, type) {
|
|
|
282
283
|
/**
|
|
283
284
|
* Attempts to resolve `input` URL/path relative to `base`.
|
|
284
285
|
*/
|
|
285
|
-
function resolve
|
|
286
|
+
function resolve(input, base) {
|
|
286
287
|
if (!input && !base)
|
|
287
288
|
return '';
|
|
288
289
|
const url = parseUrl(input);
|
|
@@ -342,447 +343,301 @@ function resolve$2(input, base) {
|
|
|
342
343
|
}
|
|
343
344
|
}
|
|
344
345
|
|
|
345
|
-
|
|
346
|
-
// The base is always treated as a directory, if it's not empty.
|
|
347
|
-
// https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327
|
|
348
|
-
// https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401
|
|
349
|
-
if (base && !base.endsWith('/'))
|
|
350
|
-
base += '/';
|
|
351
|
-
return resolve$2(input, base);
|
|
352
|
-
}
|
|
346
|
+
// src/trace-mapping.ts
|
|
353
347
|
|
|
354
|
-
|
|
355
|
-
* Removes everything after the last "/", but leaves the slash.
|
|
356
|
-
*/
|
|
348
|
+
// src/strip-filename.ts
|
|
357
349
|
function stripFilename(path) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
return path.slice(0, index + 1);
|
|
350
|
+
if (!path) return "";
|
|
351
|
+
const index = path.lastIndexOf("/");
|
|
352
|
+
return path.slice(0, index + 1);
|
|
362
353
|
}
|
|
363
354
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
const
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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
|
+
// src/sourcemap-segment.ts
|
|
363
|
+
var COLUMN = 0;
|
|
364
|
+
var SOURCES_INDEX = 1;
|
|
365
|
+
var SOURCE_LINE = 2;
|
|
366
|
+
var SOURCE_COLUMN = 3;
|
|
367
|
+
var NAMES_INDEX = 4;
|
|
368
|
+
var REV_GENERATED_LINE = 1;
|
|
369
|
+
var REV_GENERATED_COLUMN = 2;
|
|
371
370
|
|
|
371
|
+
// src/sort.ts
|
|
372
372
|
function maybeSort(mappings, owned) {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
|
|
381
|
-
mappings[i] = sortSegments(mappings[i], owned);
|
|
382
|
-
}
|
|
383
|
-
return mappings;
|
|
373
|
+
const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
|
|
374
|
+
if (unsortedIndex === mappings.length) return mappings;
|
|
375
|
+
if (!owned) mappings = mappings.slice();
|
|
376
|
+
for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
|
|
377
|
+
mappings[i] = sortSegments(mappings[i], owned);
|
|
378
|
+
}
|
|
379
|
+
return mappings;
|
|
384
380
|
}
|
|
385
381
|
function nextUnsortedSegmentLine(mappings, start) {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
return mappings.length;
|
|
382
|
+
for (let i = start; i < mappings.length; i++) {
|
|
383
|
+
if (!isSorted(mappings[i])) return i;
|
|
384
|
+
}
|
|
385
|
+
return mappings.length;
|
|
391
386
|
}
|
|
392
387
|
function isSorted(line) {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
388
|
+
for (let j = 1; j < line.length; j++) {
|
|
389
|
+
if (line[j][COLUMN] < line[j - 1][COLUMN]) {
|
|
390
|
+
return false;
|
|
397
391
|
}
|
|
398
|
-
|
|
392
|
+
}
|
|
393
|
+
return true;
|
|
399
394
|
}
|
|
400
395
|
function sortSegments(line, owned) {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
return line.sort(sortComparator);
|
|
396
|
+
if (!owned) line = line.slice();
|
|
397
|
+
return line.sort(sortComparator);
|
|
404
398
|
}
|
|
405
399
|
function sortComparator(a, b) {
|
|
406
|
-
|
|
400
|
+
return a[COLUMN] - b[COLUMN];
|
|
407
401
|
}
|
|
408
402
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
* A binary search implementation that returns the index if a match is found.
|
|
412
|
-
* If no match is found, then the left-index (the index associated with the item that comes just
|
|
413
|
-
* before the desired index) is returned. To maintain proper sort order, a splice would happen at
|
|
414
|
-
* the next index:
|
|
415
|
-
*
|
|
416
|
-
* ```js
|
|
417
|
-
* const array = [1, 3];
|
|
418
|
-
* const needle = 2;
|
|
419
|
-
* const index = binarySearch(array, needle, (item, needle) => item - needle);
|
|
420
|
-
*
|
|
421
|
-
* assert.equal(index, 0);
|
|
422
|
-
* array.splice(index + 1, 0, needle);
|
|
423
|
-
* assert.deepEqual(array, [1, 2, 3]);
|
|
424
|
-
* ```
|
|
425
|
-
*/
|
|
403
|
+
// src/binary-search.ts
|
|
404
|
+
var found = false;
|
|
426
405
|
function binarySearch(haystack, needle, low, high) {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
high = mid - 1;
|
|
439
|
-
}
|
|
406
|
+
while (low <= high) {
|
|
407
|
+
const mid = low + (high - low >> 1);
|
|
408
|
+
const cmp = haystack[mid][COLUMN] - needle;
|
|
409
|
+
if (cmp === 0) {
|
|
410
|
+
found = true;
|
|
411
|
+
return mid;
|
|
412
|
+
}
|
|
413
|
+
if (cmp < 0) {
|
|
414
|
+
low = mid + 1;
|
|
415
|
+
} else {
|
|
416
|
+
high = mid - 1;
|
|
440
417
|
}
|
|
441
|
-
|
|
442
|
-
|
|
418
|
+
}
|
|
419
|
+
found = false;
|
|
420
|
+
return low - 1;
|
|
443
421
|
}
|
|
444
422
|
function upperBound(haystack, needle, index) {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
return index;
|
|
423
|
+
for (let i = index + 1; i < haystack.length; index = i++) {
|
|
424
|
+
if (haystack[i][COLUMN] !== needle) break;
|
|
425
|
+
}
|
|
426
|
+
return index;
|
|
450
427
|
}
|
|
451
428
|
function lowerBound(haystack, needle, index) {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
return index;
|
|
429
|
+
for (let i = index - 1; i >= 0; index = i--) {
|
|
430
|
+
if (haystack[i][COLUMN] !== needle) break;
|
|
431
|
+
}
|
|
432
|
+
return index;
|
|
457
433
|
}
|
|
458
434
|
function memoizedState() {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
435
|
+
return {
|
|
436
|
+
lastKey: -1,
|
|
437
|
+
lastNeedle: -1,
|
|
438
|
+
lastIndex: -1
|
|
439
|
+
};
|
|
464
440
|
}
|
|
465
|
-
/**
|
|
466
|
-
* This overly complicated beast is just to record the last tested line/column and the resulting
|
|
467
|
-
* index, allowing us to skip a few tests if mappings are monotonically increasing.
|
|
468
|
-
*/
|
|
469
441
|
function memoizedBinarySearch(haystack, needle, state, key) {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
else {
|
|
483
|
-
high = lastIndex;
|
|
484
|
-
}
|
|
442
|
+
const { lastKey, lastNeedle, lastIndex } = state;
|
|
443
|
+
let low = 0;
|
|
444
|
+
let high = haystack.length - 1;
|
|
445
|
+
if (key === lastKey) {
|
|
446
|
+
if (needle === lastNeedle) {
|
|
447
|
+
found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
|
|
448
|
+
return lastIndex;
|
|
449
|
+
}
|
|
450
|
+
if (needle >= lastNeedle) {
|
|
451
|
+
low = lastIndex === -1 ? 0 : lastIndex;
|
|
452
|
+
} else {
|
|
453
|
+
high = lastIndex;
|
|
485
454
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
455
|
+
}
|
|
456
|
+
state.lastKey = key;
|
|
457
|
+
state.lastNeedle = needle;
|
|
458
|
+
return state.lastIndex = binarySearch(haystack, needle, low, high);
|
|
489
459
|
}
|
|
490
460
|
|
|
491
|
-
//
|
|
492
|
-
// of generated line/column.
|
|
461
|
+
// src/by-source.ts
|
|
493
462
|
function buildBySources(decoded, memos) {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
insert(originalLine, index, [sourceColumn, i, seg[COLUMN]]);
|
|
514
|
-
}
|
|
463
|
+
const sources = memos.map(buildNullArray);
|
|
464
|
+
for (let i = 0; i < decoded.length; i++) {
|
|
465
|
+
const line = decoded[i];
|
|
466
|
+
for (let j = 0; j < line.length; j++) {
|
|
467
|
+
const seg = line[j];
|
|
468
|
+
if (seg.length === 1) continue;
|
|
469
|
+
const sourceIndex2 = seg[SOURCES_INDEX];
|
|
470
|
+
const sourceLine = seg[SOURCE_LINE];
|
|
471
|
+
const sourceColumn = seg[SOURCE_COLUMN];
|
|
472
|
+
const originalSource = sources[sourceIndex2];
|
|
473
|
+
const originalLine = originalSource[sourceLine] || (originalSource[sourceLine] = []);
|
|
474
|
+
const memo = memos[sourceIndex2];
|
|
475
|
+
let index = upperBound(
|
|
476
|
+
originalLine,
|
|
477
|
+
sourceColumn,
|
|
478
|
+
memoizedBinarySearch(originalLine, sourceColumn, memo, sourceLine)
|
|
479
|
+
);
|
|
480
|
+
memo.lastIndex = ++index;
|
|
481
|
+
insert(originalLine, index, [sourceColumn, i, seg[COLUMN]]);
|
|
515
482
|
}
|
|
516
|
-
|
|
483
|
+
}
|
|
484
|
+
return sources;
|
|
517
485
|
}
|
|
518
486
|
function insert(array, index, value) {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
487
|
+
for (let i = array.length; i > index; i--) {
|
|
488
|
+
array[i] = array[i - 1];
|
|
489
|
+
}
|
|
490
|
+
array[index] = value;
|
|
523
491
|
}
|
|
524
|
-
// Null arrays allow us to use ordered index keys without actually allocating contiguous memory like
|
|
525
|
-
// a real array. We use a null-prototype object to avoid prototype pollution and deoptimizations.
|
|
526
|
-
// Numeric properties on objects are magically sorted in ascending order by the engine regardless of
|
|
527
|
-
// the insertion order. So, by setting any numeric keys, even out of order, we'll get ascending
|
|
528
|
-
// order when iterating with for-in.
|
|
529
492
|
function buildNullArray() {
|
|
530
|
-
|
|
493
|
+
return { __proto__: null };
|
|
531
494
|
}
|
|
532
495
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
const GREATEST_LOWER_BOUND = 1;
|
|
537
|
-
class TraceMap {
|
|
538
|
-
constructor(map, mapUrl) {
|
|
539
|
-
const isString = typeof map === 'string';
|
|
540
|
-
if (!isString && map._decodedMemo)
|
|
541
|
-
return map;
|
|
542
|
-
const parsed = (isString ? JSON.parse(map) : map);
|
|
543
|
-
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
|
544
|
-
this.version = version;
|
|
545
|
-
this.file = file;
|
|
546
|
-
this.names = names || [];
|
|
547
|
-
this.sourceRoot = sourceRoot;
|
|
548
|
-
this.sources = sources;
|
|
549
|
-
this.sourcesContent = sourcesContent;
|
|
550
|
-
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined;
|
|
551
|
-
const from = resolve$1(sourceRoot || '', stripFilename(mapUrl));
|
|
552
|
-
this.resolvedSources = sources.map((s) => resolve$1(s || '', from));
|
|
553
|
-
const { mappings } = parsed;
|
|
554
|
-
if (typeof mappings === 'string') {
|
|
555
|
-
this._encoded = mappings;
|
|
556
|
-
this._decoded = undefined;
|
|
557
|
-
}
|
|
558
|
-
else {
|
|
559
|
-
this._encoded = undefined;
|
|
560
|
-
this._decoded = maybeSort(mappings, isString);
|
|
561
|
-
}
|
|
562
|
-
this._decodedMemo = memoizedState();
|
|
563
|
-
this._bySources = undefined;
|
|
564
|
-
this._bySourceMemos = undefined;
|
|
565
|
-
}
|
|
496
|
+
// src/types.ts
|
|
497
|
+
function parse(map) {
|
|
498
|
+
return typeof map === "string" ? JSON.parse(map) : map;
|
|
566
499
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
500
|
+
|
|
501
|
+
// src/trace-mapping.ts
|
|
502
|
+
var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
|
|
503
|
+
var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
|
|
504
|
+
var LEAST_UPPER_BOUND = -1;
|
|
505
|
+
var GREATEST_LOWER_BOUND = 1;
|
|
506
|
+
var TraceMap = class {
|
|
507
|
+
constructor(map, mapUrl) {
|
|
508
|
+
const isString = typeof map === "string";
|
|
509
|
+
if (!isString && map._decodedMemo) return map;
|
|
510
|
+
const parsed = parse(map);
|
|
511
|
+
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
|
512
|
+
this.version = version;
|
|
513
|
+
this.file = file;
|
|
514
|
+
this.names = names || [];
|
|
515
|
+
this.sourceRoot = sourceRoot;
|
|
516
|
+
this.sources = sources;
|
|
517
|
+
this.sourcesContent = sourcesContent;
|
|
518
|
+
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
|
|
519
|
+
const resolve = resolver(mapUrl, sourceRoot);
|
|
520
|
+
this.resolvedSources = sources.map(resolve);
|
|
521
|
+
const { mappings } = parsed;
|
|
522
|
+
if (typeof mappings === "string") {
|
|
523
|
+
this._encoded = mappings;
|
|
524
|
+
this._decoded = void 0;
|
|
525
|
+
} else if (Array.isArray(mappings)) {
|
|
526
|
+
this._encoded = void 0;
|
|
527
|
+
this._decoded = maybeSort(mappings, isString);
|
|
528
|
+
} else if (parsed.sections) {
|
|
529
|
+
throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
|
|
530
|
+
} else {
|
|
531
|
+
throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
|
|
532
|
+
}
|
|
533
|
+
this._decodedMemo = memoizedState();
|
|
534
|
+
this._bySources = void 0;
|
|
535
|
+
this._bySourceMemos = void 0;
|
|
536
|
+
}
|
|
537
|
+
};
|
|
571
538
|
function cast(map) {
|
|
572
|
-
|
|
539
|
+
return map;
|
|
573
540
|
}
|
|
574
|
-
/**
|
|
575
|
-
* Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
|
|
576
|
-
*/
|
|
577
541
|
function decodedMappings(map) {
|
|
578
|
-
|
|
579
|
-
|
|
542
|
+
var _a;
|
|
543
|
+
return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
|
|
580
544
|
}
|
|
581
|
-
/**
|
|
582
|
-
* A higher-level API to find the source/line/column associated with a generated line/column
|
|
583
|
-
* (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
|
|
584
|
-
* `source-map` library.
|
|
585
|
-
*/
|
|
586
545
|
function originalPositionFor(map, needle) {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
546
|
+
let { line, column, bias } = needle;
|
|
547
|
+
line--;
|
|
548
|
+
if (line < 0) throw new Error(LINE_GTR_ZERO);
|
|
549
|
+
if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
|
|
550
|
+
const decoded = decodedMappings(map);
|
|
551
|
+
if (line >= decoded.length) return OMapping(null, null, null, null);
|
|
552
|
+
const segments = decoded[line];
|
|
553
|
+
const index = traceSegmentInternal(
|
|
554
|
+
segments,
|
|
555
|
+
cast(map)._decodedMemo,
|
|
556
|
+
line,
|
|
557
|
+
column,
|
|
558
|
+
bias || GREATEST_LOWER_BOUND
|
|
559
|
+
);
|
|
560
|
+
if (index === -1) return OMapping(null, null, null, null);
|
|
561
|
+
const segment = segments[index];
|
|
562
|
+
if (segment.length === 1) return OMapping(null, null, null, null);
|
|
563
|
+
const { names, resolvedSources } = map;
|
|
564
|
+
return OMapping(
|
|
565
|
+
resolvedSources[segment[SOURCES_INDEX]],
|
|
566
|
+
segment[SOURCE_LINE] + 1,
|
|
567
|
+
segment[SOURCE_COLUMN],
|
|
568
|
+
segment.length === 5 ? names[segment[NAMES_INDEX]] : null
|
|
569
|
+
);
|
|
607
570
|
}
|
|
608
|
-
/**
|
|
609
|
-
* Finds the generated line/column position of the provided source/line/column source position.
|
|
610
|
-
*/
|
|
611
571
|
function generatedPositionFor(map, needle) {
|
|
612
|
-
|
|
613
|
-
|
|
572
|
+
const { source, line, column, bias } = needle;
|
|
573
|
+
return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false);
|
|
614
574
|
}
|
|
615
|
-
/**
|
|
616
|
-
* Iterates each mapping in generated position order.
|
|
617
|
-
*/
|
|
618
575
|
function eachMapping(map, cb) {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
});
|
|
646
|
-
}
|
|
576
|
+
const decoded = decodedMappings(map);
|
|
577
|
+
const { names, resolvedSources } = map;
|
|
578
|
+
for (let i = 0; i < decoded.length; i++) {
|
|
579
|
+
const line = decoded[i];
|
|
580
|
+
for (let j = 0; j < line.length; j++) {
|
|
581
|
+
const seg = line[j];
|
|
582
|
+
const generatedLine = i + 1;
|
|
583
|
+
const generatedColumn = seg[0];
|
|
584
|
+
let source = null;
|
|
585
|
+
let originalLine = null;
|
|
586
|
+
let originalColumn = null;
|
|
587
|
+
let name = null;
|
|
588
|
+
if (seg.length !== 1) {
|
|
589
|
+
source = resolvedSources[seg[1]];
|
|
590
|
+
originalLine = seg[2] + 1;
|
|
591
|
+
originalColumn = seg[3];
|
|
592
|
+
}
|
|
593
|
+
if (seg.length === 5) name = names[seg[4]];
|
|
594
|
+
cb({
|
|
595
|
+
generatedLine,
|
|
596
|
+
generatedColumn,
|
|
597
|
+
source,
|
|
598
|
+
originalLine,
|
|
599
|
+
originalColumn,
|
|
600
|
+
name
|
|
601
|
+
});
|
|
647
602
|
}
|
|
603
|
+
}
|
|
648
604
|
}
|
|
649
605
|
function OMapping(source, line, column, name) {
|
|
650
|
-
|
|
606
|
+
return { source, line, column, name };
|
|
651
607
|
}
|
|
652
608
|
function GMapping(line, column) {
|
|
653
|
-
|
|
609
|
+
return { line, column };
|
|
654
610
|
}
|
|
655
611
|
function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
if (index === -1 || index === segments.length)
|
|
663
|
-
return -1;
|
|
664
|
-
return index;
|
|
612
|
+
let index = memoizedBinarySearch(segments, column, memo, line);
|
|
613
|
+
if (found) {
|
|
614
|
+
index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
|
|
615
|
+
} else if (bias === LEAST_UPPER_BOUND) index++;
|
|
616
|
+
if (index === -1 || index === segments.length) return -1;
|
|
617
|
+
return index;
|
|
665
618
|
}
|
|
666
619
|
function generatedPosition(map, source, line, column, bias, all) {
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
return GMapping(null, null);
|
|
687
|
-
const segment = segments[index];
|
|
688
|
-
return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);
|
|
620
|
+
var _a;
|
|
621
|
+
line--;
|
|
622
|
+
if (line < 0) throw new Error(LINE_GTR_ZERO);
|
|
623
|
+
if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
|
|
624
|
+
const { sources, resolvedSources } = map;
|
|
625
|
+
let sourceIndex2 = sources.indexOf(source);
|
|
626
|
+
if (sourceIndex2 === -1) sourceIndex2 = resolvedSources.indexOf(source);
|
|
627
|
+
if (sourceIndex2 === -1) return all ? [] : GMapping(null, null);
|
|
628
|
+
const generated = (_a = cast(map))._bySources || (_a._bySources = buildBySources(
|
|
629
|
+
decodedMappings(map),
|
|
630
|
+
cast(map)._bySourceMemos = sources.map(memoizedState)
|
|
631
|
+
));
|
|
632
|
+
const segments = generated[sourceIndex2][line];
|
|
633
|
+
if (segments == null) return all ? [] : GMapping(null, null);
|
|
634
|
+
const memo = cast(map)._bySourceMemos[sourceIndex2];
|
|
635
|
+
const index = traceSegmentInternal(segments, memo, line, column, bias);
|
|
636
|
+
if (index === -1) return GMapping(null, null);
|
|
637
|
+
const segment = segments[index];
|
|
638
|
+
return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);
|
|
689
639
|
}
|
|
690
640
|
|
|
691
|
-
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
692
|
-
function normalizeWindowsPath(input = "") {
|
|
693
|
-
if (!input) {
|
|
694
|
-
return input;
|
|
695
|
-
}
|
|
696
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
697
|
-
}
|
|
698
|
-
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
699
|
-
function cwd() {
|
|
700
|
-
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
701
|
-
return process.cwd().replace(/\\/g, "/");
|
|
702
|
-
}
|
|
703
|
-
return "/";
|
|
704
|
-
}
|
|
705
|
-
const resolve = function(...arguments_) {
|
|
706
|
-
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
707
|
-
let resolvedPath = "";
|
|
708
|
-
let resolvedAbsolute = false;
|
|
709
|
-
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
710
|
-
const path = index >= 0 ? arguments_[index] : cwd();
|
|
711
|
-
if (!path || path.length === 0) {
|
|
712
|
-
continue;
|
|
713
|
-
}
|
|
714
|
-
resolvedPath = `${path}/${resolvedPath}`;
|
|
715
|
-
resolvedAbsolute = isAbsolute(path);
|
|
716
|
-
}
|
|
717
|
-
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
718
|
-
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
719
|
-
return `/${resolvedPath}`;
|
|
720
|
-
}
|
|
721
|
-
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
722
|
-
};
|
|
723
|
-
function normalizeString(path, allowAboveRoot) {
|
|
724
|
-
let res = "";
|
|
725
|
-
let lastSegmentLength = 0;
|
|
726
|
-
let lastSlash = -1;
|
|
727
|
-
let dots = 0;
|
|
728
|
-
let char = null;
|
|
729
|
-
for (let index = 0; index <= path.length; ++index) {
|
|
730
|
-
if (index < path.length) {
|
|
731
|
-
char = path[index];
|
|
732
|
-
} else if (char === "/") {
|
|
733
|
-
break;
|
|
734
|
-
} else {
|
|
735
|
-
char = "/";
|
|
736
|
-
}
|
|
737
|
-
if (char === "/") {
|
|
738
|
-
if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) {
|
|
739
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
740
|
-
if (res.length > 2) {
|
|
741
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
742
|
-
if (lastSlashIndex === -1) {
|
|
743
|
-
res = "";
|
|
744
|
-
lastSegmentLength = 0;
|
|
745
|
-
} else {
|
|
746
|
-
res = res.slice(0, lastSlashIndex);
|
|
747
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
748
|
-
}
|
|
749
|
-
lastSlash = index;
|
|
750
|
-
dots = 0;
|
|
751
|
-
continue;
|
|
752
|
-
} else if (res.length > 0) {
|
|
753
|
-
res = "";
|
|
754
|
-
lastSegmentLength = 0;
|
|
755
|
-
lastSlash = index;
|
|
756
|
-
dots = 0;
|
|
757
|
-
continue;
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
if (allowAboveRoot) {
|
|
761
|
-
res += res.length > 0 ? "/.." : "..";
|
|
762
|
-
lastSegmentLength = 2;
|
|
763
|
-
}
|
|
764
|
-
} else {
|
|
765
|
-
if (res.length > 0) {
|
|
766
|
-
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
767
|
-
} else {
|
|
768
|
-
res = path.slice(lastSlash + 1, index);
|
|
769
|
-
}
|
|
770
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
771
|
-
}
|
|
772
|
-
lastSlash = index;
|
|
773
|
-
dots = 0;
|
|
774
|
-
} else if (char === "." && dots !== -1) {
|
|
775
|
-
++dots;
|
|
776
|
-
} else {
|
|
777
|
-
dots = -1;
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
return res;
|
|
781
|
-
}
|
|
782
|
-
const isAbsolute = function(p) {
|
|
783
|
-
return _IS_ABSOLUTE_RE.test(p);
|
|
784
|
-
};
|
|
785
|
-
|
|
786
641
|
const CHROME_IE_STACK_REGEXP = /^\s*at .*(?:\S:\d+|\(native\))/m;
|
|
787
642
|
const SAFARI_NATIVE_CODE_REGEXP = /^(?:eval@)?(?:\[native code\])?$/;
|
|
788
643
|
const stackIgnorePatterns = [
|
|
@@ -796,6 +651,8 @@ const stackIgnorePatterns = [
|
|
|
796
651
|
"/node_modules/chai/",
|
|
797
652
|
"/node_modules/tinypool/",
|
|
798
653
|
"/node_modules/tinyspy/",
|
|
654
|
+
"/vite/dist/node/module-runner",
|
|
655
|
+
"/rolldown-vite/dist/node/module-runner",
|
|
799
656
|
"/deps/chunk-",
|
|
800
657
|
"/deps/@vitest",
|
|
801
658
|
"/deps/loupe",
|
|
@@ -899,7 +756,7 @@ function parseSingleV8Stack(raw) {
|
|
|
899
756
|
file = file.slice(7);
|
|
900
757
|
}
|
|
901
758
|
// normalize Windows path (\ -> /)
|
|
902
|
-
file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve(file);
|
|
759
|
+
file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve$1(file);
|
|
903
760
|
if (method) {
|
|
904
761
|
method = method.replace(/__vite_ssr_import_\d+__\./g, "");
|
|
905
762
|
}
|
|
@@ -993,4 +850,4 @@ function parseErrorStacktrace(e, options = {}) {
|
|
|
993
850
|
return stackFrames;
|
|
994
851
|
}
|
|
995
852
|
|
|
996
|
-
export { TraceMap, createStackString, eachMapping, generatedPositionFor, originalPositionFor, parseErrorStacktrace, parseSingleFFOrSafariStack, parseSingleStack, parseSingleV8Stack, parseStacktrace };
|
|
853
|
+
export { TraceMap, createStackString, stackIgnorePatterns as defaultStackIgnorePatterns, eachMapping, generatedPositionFor, originalPositionFor, parseErrorStacktrace, parseSingleFFOrSafariStack, parseSingleStack, parseSingleV8Stack, parseStacktrace };
|