@vitest/snapshot 2.1.0-beta.6 → 2.1.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.js +65 -47
- package/package.json +3 -3
package/dist/index.js
CHANGED
@@ -501,74 +501,92 @@ for (let i = 0; i < chars.length; i++) {
|
|
501
501
|
intToChar[i] = c;
|
502
502
|
charToInt[c] = i;
|
503
503
|
}
|
504
|
+
function decodeInteger(reader, relative) {
|
505
|
+
let value = 0;
|
506
|
+
let shift = 0;
|
507
|
+
let integer = 0;
|
508
|
+
do {
|
509
|
+
const c = reader.next();
|
510
|
+
integer = charToInt[c];
|
511
|
+
value |= (integer & 31) << shift;
|
512
|
+
shift += 5;
|
513
|
+
} while (integer & 32);
|
514
|
+
const shouldNegate = value & 1;
|
515
|
+
value >>>= 1;
|
516
|
+
if (shouldNegate) {
|
517
|
+
value = -0x80000000 | -value;
|
518
|
+
}
|
519
|
+
return relative + value;
|
520
|
+
}
|
521
|
+
function hasMoreVlq(reader, max) {
|
522
|
+
if (reader.pos >= max)
|
523
|
+
return false;
|
524
|
+
return reader.peek() !== comma;
|
525
|
+
}
|
526
|
+
class StringReader {
|
527
|
+
constructor(buffer) {
|
528
|
+
this.pos = 0;
|
529
|
+
this.buffer = buffer;
|
530
|
+
}
|
531
|
+
next() {
|
532
|
+
return this.buffer.charCodeAt(this.pos++);
|
533
|
+
}
|
534
|
+
peek() {
|
535
|
+
return this.buffer.charCodeAt(this.pos);
|
536
|
+
}
|
537
|
+
indexOf(char) {
|
538
|
+
const { buffer, pos } = this;
|
539
|
+
const idx = buffer.indexOf(char, pos);
|
540
|
+
return idx === -1 ? buffer.length : idx;
|
541
|
+
}
|
542
|
+
}
|
543
|
+
|
504
544
|
function decode(mappings) {
|
505
|
-
const
|
545
|
+
const { length } = mappings;
|
546
|
+
const reader = new StringReader(mappings);
|
506
547
|
const decoded = [];
|
507
|
-
let
|
548
|
+
let genColumn = 0;
|
549
|
+
let sourcesIndex = 0;
|
550
|
+
let sourceLine = 0;
|
551
|
+
let sourceColumn = 0;
|
552
|
+
let namesIndex = 0;
|
508
553
|
do {
|
509
|
-
const semi = indexOf(
|
554
|
+
const semi = reader.indexOf(';');
|
510
555
|
const line = [];
|
511
556
|
let sorted = true;
|
512
557
|
let lastCol = 0;
|
513
|
-
|
514
|
-
|
558
|
+
genColumn = 0;
|
559
|
+
while (reader.pos < semi) {
|
515
560
|
let seg;
|
516
|
-
|
517
|
-
|
518
|
-
if (col < lastCol)
|
561
|
+
genColumn = decodeInteger(reader, genColumn);
|
562
|
+
if (genColumn < lastCol)
|
519
563
|
sorted = false;
|
520
|
-
lastCol =
|
521
|
-
if (hasMoreVlq(
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
if (hasMoreVlq(
|
526
|
-
|
527
|
-
seg = [
|
564
|
+
lastCol = genColumn;
|
565
|
+
if (hasMoreVlq(reader, semi)) {
|
566
|
+
sourcesIndex = decodeInteger(reader, sourcesIndex);
|
567
|
+
sourceLine = decodeInteger(reader, sourceLine);
|
568
|
+
sourceColumn = decodeInteger(reader, sourceColumn);
|
569
|
+
if (hasMoreVlq(reader, semi)) {
|
570
|
+
namesIndex = decodeInteger(reader, namesIndex);
|
571
|
+
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
|
528
572
|
}
|
529
573
|
else {
|
530
|
-
seg = [
|
574
|
+
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
531
575
|
}
|
532
576
|
}
|
533
577
|
else {
|
534
|
-
seg = [
|
578
|
+
seg = [genColumn];
|
535
579
|
}
|
536
580
|
line.push(seg);
|
581
|
+
reader.pos++;
|
537
582
|
}
|
538
583
|
if (!sorted)
|
539
584
|
sort(line);
|
540
585
|
decoded.push(line);
|
541
|
-
|
542
|
-
} while (
|
586
|
+
reader.pos = semi + 1;
|
587
|
+
} while (reader.pos <= length);
|
543
588
|
return decoded;
|
544
589
|
}
|
545
|
-
function indexOf(mappings, index) {
|
546
|
-
const idx = mappings.indexOf(';', index);
|
547
|
-
return idx === -1 ? mappings.length : idx;
|
548
|
-
}
|
549
|
-
function decodeInteger(mappings, pos, state, j) {
|
550
|
-
let value = 0;
|
551
|
-
let shift = 0;
|
552
|
-
let integer = 0;
|
553
|
-
do {
|
554
|
-
const c = mappings.charCodeAt(pos++);
|
555
|
-
integer = charToInt[c];
|
556
|
-
value |= (integer & 31) << shift;
|
557
|
-
shift += 5;
|
558
|
-
} while (integer & 32);
|
559
|
-
const shouldNegate = value & 1;
|
560
|
-
value >>>= 1;
|
561
|
-
if (shouldNegate) {
|
562
|
-
value = -0x80000000 | -value;
|
563
|
-
}
|
564
|
-
state[j] += value;
|
565
|
-
return pos;
|
566
|
-
}
|
567
|
-
function hasMoreVlq(mappings, i, length) {
|
568
|
-
if (i >= length)
|
569
|
-
return false;
|
570
|
-
return mappings.charCodeAt(i) !== comma;
|
571
|
-
}
|
572
590
|
function sort(line) {
|
573
591
|
line.sort(sortComparator$1);
|
574
592
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitest/snapshot",
|
3
3
|
"type": "module",
|
4
|
-
"version": "2.1.0
|
4
|
+
"version": "2.1.0",
|
5
5
|
"description": "Vitest snapshot manager",
|
6
6
|
"license": "MIT",
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
@@ -40,12 +40,12 @@
|
|
40
40
|
"dependencies": {
|
41
41
|
"magic-string": "^0.30.11",
|
42
42
|
"pathe": "^1.1.2",
|
43
|
-
"@vitest/pretty-format": "2.1.0
|
43
|
+
"@vitest/pretty-format": "2.1.0"
|
44
44
|
},
|
45
45
|
"devDependencies": {
|
46
46
|
"@types/natural-compare": "^1.4.3",
|
47
47
|
"natural-compare": "^1.4.0",
|
48
|
-
"@vitest/utils": "2.1.0
|
48
|
+
"@vitest/utils": "2.1.0"
|
49
49
|
},
|
50
50
|
"scripts": {
|
51
51
|
"build": "rimraf dist && rollup -c",
|