@pierre/diffs 1.0.0-beta.1 → 1.0.0-beta.3
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/README.md +2 -1
- package/dist/managers/LineSelectionManager.d.ts +1 -0
- package/dist/managers/LineSelectionManager.d.ts.map +1 -1
- package/dist/managers/LineSelectionManager.js +21 -15
- package/dist/managers/LineSelectionManager.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/parseLineType.d.ts.map +1 -1
- package/dist/utils/processLine.js +1 -1
- package/dist/utils/processLine.js.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.js +34 -18
- package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
- package/dist/worker/worker-portable.js +35 -20
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +35 -19
- package/dist/worker/worker.js.map +1 -1
- package/package.json +19 -19
|
@@ -13850,7 +13850,7 @@ function processLine(node, line, state) {
|
|
|
13850
13850
|
"data-line": lineInfo.lineNumber,
|
|
13851
13851
|
"data-alt-line": lineInfo.altLineNumber,
|
|
13852
13852
|
"data-line-type": lineInfo.type,
|
|
13853
|
-
"data-line-index": lineInfo.lineIndex
|
|
13853
|
+
"data-line-index": lineInfo.lineIndex
|
|
13854
13854
|
}
|
|
13855
13855
|
});
|
|
13856
13856
|
}
|
|
@@ -14411,14 +14411,15 @@ function renderDiffWithHighlighter(diff, highlighter$1, options, forcePlainText
|
|
|
14411
14411
|
};
|
|
14412
14412
|
}
|
|
14413
14413
|
const hunks = [];
|
|
14414
|
-
let
|
|
14414
|
+
let splitLineIndex = 0;
|
|
14415
|
+
let unifiedLineIndex = 0;
|
|
14415
14416
|
for (const hunk of diff.hunks) {
|
|
14416
|
-
const
|
|
14417
|
+
const { oldContent, newContent, oldInfo, newInfo, oldDecorations, newDecorations, splitLineIndex: newSplitLineIndex, unifiedLineIndex: newUnifiedLineIndex } = processLines({
|
|
14417
14418
|
hunks: [hunk],
|
|
14418
|
-
|
|
14419
|
+
splitLineIndex,
|
|
14420
|
+
unifiedLineIndex,
|
|
14419
14421
|
lineDiffType: options.lineDiffType
|
|
14420
14422
|
});
|
|
14421
|
-
const { oldContent, newContent, oldInfo, newInfo, oldDecorations, newDecorations, lineIndex: newLineIndex } = result;
|
|
14422
14423
|
const oldFile = {
|
|
14423
14424
|
name: diff.prevName ?? diff.name,
|
|
14424
14425
|
contents: oldContent
|
|
@@ -14438,7 +14439,8 @@ function renderDiffWithHighlighter(diff, highlighter$1, options, forcePlainText
|
|
|
14438
14439
|
options,
|
|
14439
14440
|
languageOverride: forcePlainText ? "text" : diff.lang
|
|
14440
14441
|
}));
|
|
14441
|
-
|
|
14442
|
+
splitLineIndex = newSplitLineIndex;
|
|
14443
|
+
unifiedLineIndex = newUnifiedLineIndex;
|
|
14442
14444
|
}
|
|
14443
14445
|
const code = (() => {
|
|
14444
14446
|
if (hunks.length <= 1) {
|
|
@@ -14524,7 +14526,7 @@ function computeLineDiffDecorations({ oldLine, newLine, oldLineIndex, newLineInd
|
|
|
14524
14526
|
spanIndex += span[1].length;
|
|
14525
14527
|
}
|
|
14526
14528
|
}
|
|
14527
|
-
function processLines({ hunks, oldLines, newLines,
|
|
14529
|
+
function processLines({ hunks, oldLines, newLines, splitLineIndex = 0, unifiedLineIndex = 0, lineDiffType }) {
|
|
14528
14530
|
const oldInfo = {};
|
|
14529
14531
|
const newInfo = {};
|
|
14530
14532
|
const oldDecorations = [];
|
|
@@ -14540,12 +14542,14 @@ function processLines({ hunks, oldLines, newLines, lineIndex = 0, lineDiffType }
|
|
|
14540
14542
|
oldInfo[oldLineIndex] = {
|
|
14541
14543
|
type: "context-expanded",
|
|
14542
14544
|
lineNumber: oldLineNumber,
|
|
14543
|
-
|
|
14545
|
+
altLineNumber: newLineNumber,
|
|
14546
|
+
lineIndex: `${unifiedLineIndex},${splitLineIndex}`
|
|
14544
14547
|
};
|
|
14545
14548
|
newInfo[newLineIndex] = {
|
|
14546
14549
|
type: "context-expanded",
|
|
14547
14550
|
lineNumber: newLineNumber,
|
|
14548
|
-
|
|
14551
|
+
altLineNumber: oldLineNumber,
|
|
14552
|
+
lineIndex: `${unifiedLineIndex},${splitLineIndex}`
|
|
14549
14553
|
};
|
|
14550
14554
|
oldContent += oldLines[oldLineIndex - 1];
|
|
14551
14555
|
newContent += newLines[newLineIndex - 1];
|
|
@@ -14553,7 +14557,8 @@ function processLines({ hunks, oldLines, newLines, lineIndex = 0, lineDiffType }
|
|
|
14553
14557
|
newLineIndex++;
|
|
14554
14558
|
oldLineNumber++;
|
|
14555
14559
|
newLineNumber++;
|
|
14556
|
-
|
|
14560
|
+
splitLineIndex++;
|
|
14561
|
+
unifiedLineIndex++;
|
|
14557
14562
|
}
|
|
14558
14563
|
oldLineNumber = hunk.deletionStart;
|
|
14559
14564
|
newLineNumber = hunk.additionStart;
|
|
@@ -14563,12 +14568,14 @@ function processLines({ hunks, oldLines, newLines, lineIndex = 0, lineDiffType }
|
|
|
14563
14568
|
oldInfo[oldLineIndex] = {
|
|
14564
14569
|
type: "context",
|
|
14565
14570
|
lineNumber: oldLineNumber,
|
|
14566
|
-
|
|
14571
|
+
altLineNumber: newLineNumber,
|
|
14572
|
+
lineIndex: `${unifiedLineIndex},${splitLineIndex}`
|
|
14567
14573
|
};
|
|
14568
14574
|
newInfo[newLineIndex] = {
|
|
14569
14575
|
type: "context",
|
|
14570
14576
|
lineNumber: newLineNumber,
|
|
14571
|
-
|
|
14577
|
+
altLineNumber: oldLineNumber,
|
|
14578
|
+
lineIndex: `${unifiedLineIndex},${splitLineIndex}`
|
|
14572
14579
|
};
|
|
14573
14580
|
oldContent += line;
|
|
14574
14581
|
newContent += line;
|
|
@@ -14576,11 +14583,13 @@ function processLines({ hunks, oldLines, newLines, lineIndex = 0, lineDiffType }
|
|
|
14576
14583
|
newLineIndex++;
|
|
14577
14584
|
newLineNumber++;
|
|
14578
14585
|
oldLineNumber++;
|
|
14579
|
-
|
|
14586
|
+
splitLineIndex++;
|
|
14587
|
+
unifiedLineIndex++;
|
|
14580
14588
|
}
|
|
14581
14589
|
} else {
|
|
14582
14590
|
const len = Math.max(hunkContent.additions.length, hunkContent.deletions.length);
|
|
14583
14591
|
let i$2 = 0;
|
|
14592
|
+
let _unifiedLineIndex = unifiedLineIndex;
|
|
14584
14593
|
while (i$2 < len) {
|
|
14585
14594
|
const oldLine = hunkContent.deletions[i$2];
|
|
14586
14595
|
const newLine = hunkContent.additions[i$2];
|
|
@@ -14597,7 +14606,7 @@ function processLines({ hunks, oldLines, newLines, lineIndex = 0, lineDiffType }
|
|
|
14597
14606
|
oldInfo[oldLineIndex] = {
|
|
14598
14607
|
type: "change-deletion",
|
|
14599
14608
|
lineNumber: oldLineNumber,
|
|
14600
|
-
lineIndex
|
|
14609
|
+
lineIndex: `${_unifiedLineIndex},${splitLineIndex}`
|
|
14601
14610
|
};
|
|
14602
14611
|
oldContent += oldLine;
|
|
14603
14612
|
oldLineIndex++;
|
|
@@ -14607,15 +14616,17 @@ function processLines({ hunks, oldLines, newLines, lineIndex = 0, lineDiffType }
|
|
|
14607
14616
|
newInfo[newLineIndex] = {
|
|
14608
14617
|
type: "change-addition",
|
|
14609
14618
|
lineNumber: newLineNumber,
|
|
14610
|
-
lineIndex
|
|
14619
|
+
lineIndex: `${_unifiedLineIndex + hunkContent.deletions.length},${splitLineIndex}`
|
|
14611
14620
|
};
|
|
14612
14621
|
newContent += newLine;
|
|
14613
14622
|
newLineIndex++;
|
|
14614
14623
|
newLineNumber++;
|
|
14615
14624
|
}
|
|
14616
|
-
|
|
14625
|
+
splitLineIndex++;
|
|
14626
|
+
_unifiedLineIndex++;
|
|
14617
14627
|
i$2++;
|
|
14618
14628
|
}
|
|
14629
|
+
unifiedLineIndex += hunkContent.additions.length + hunkContent.deletions.length;
|
|
14619
14630
|
}
|
|
14620
14631
|
}
|
|
14621
14632
|
if (oldLines == null || newLines == null || hunk !== hunks[hunks.length - 1]) continue;
|
|
@@ -14629,7 +14640,8 @@ function processLines({ hunks, oldLines, newLines, lineIndex = 0, lineDiffType }
|
|
|
14629
14640
|
oldInfo[oldLineIndex] = {
|
|
14630
14641
|
type: "context-expanded",
|
|
14631
14642
|
lineNumber: oldLineNumber,
|
|
14632
|
-
|
|
14643
|
+
altLineNumber: newLineNumber,
|
|
14644
|
+
lineIndex: `${unifiedLineIndex},${splitLineIndex}`
|
|
14633
14645
|
};
|
|
14634
14646
|
oldContent += oldLine;
|
|
14635
14647
|
oldLineIndex++;
|
|
@@ -14639,13 +14651,15 @@ function processLines({ hunks, oldLines, newLines, lineIndex = 0, lineDiffType }
|
|
|
14639
14651
|
newInfo[newLineIndex] = {
|
|
14640
14652
|
type: "context-expanded",
|
|
14641
14653
|
lineNumber: newLineNumber,
|
|
14642
|
-
|
|
14654
|
+
altLineNumber: oldLineNumber,
|
|
14655
|
+
lineIndex: `${unifiedLineIndex},${splitLineIndex}`
|
|
14643
14656
|
};
|
|
14644
14657
|
newContent += newLine;
|
|
14645
14658
|
newLineIndex++;
|
|
14646
14659
|
newLineNumber++;
|
|
14647
14660
|
}
|
|
14648
|
-
|
|
14661
|
+
splitLineIndex++;
|
|
14662
|
+
unifiedLineIndex++;
|
|
14649
14663
|
}
|
|
14650
14664
|
}
|
|
14651
14665
|
return {
|
|
@@ -14655,7 +14669,8 @@ function processLines({ hunks, oldLines, newLines, lineIndex = 0, lineDiffType }
|
|
|
14655
14669
|
newInfo,
|
|
14656
14670
|
oldDecorations,
|
|
14657
14671
|
newDecorations,
|
|
14658
|
-
|
|
14672
|
+
splitLineIndex,
|
|
14673
|
+
unifiedLineIndex
|
|
14659
14674
|
};
|
|
14660
14675
|
}
|
|
14661
14676
|
function renderTwoFiles({ oldFile, newFile, oldInfo, newInfo, highlighter: highlighter$1, oldDecorations, newDecorations, languageOverride, options: { theme: themeOrThemes = DEFAULT_THEMES,...options } }) {
|