@pierre/diffs 1.2.5 → 1.3.0-beta.1
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/components/CodeView.d.ts +0 -1
- package/dist/components/CodeView.d.ts.map +1 -1
- package/dist/components/CodeView.js +0 -23
- package/dist/components/CodeView.js.map +1 -1
- package/dist/components/File.d.ts +7 -2
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +36 -2
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +8 -2
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +73 -1
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/UnresolvedFile.js +2 -2
- package/dist/components/VirtualizedFile.d.ts +2 -1
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +48 -48
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +1 -6
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/components/Virtualizer.d.ts +1 -1
- package/dist/components/Virtualizer.d.ts.map +1 -1
- package/dist/components/Virtualizer.js.map +1 -1
- package/dist/editor/command.d.ts +6 -0
- package/dist/editor/command.d.ts.map +1 -0
- package/dist/editor/command.js +31 -0
- package/dist/editor/command.js.map +1 -0
- package/dist/editor/css.d.ts +6 -0
- package/dist/editor/css.d.ts.map +1 -0
- package/dist/editor/css.js +218 -0
- package/dist/editor/css.js.map +1 -0
- package/dist/editor/editStack.d.ts +66 -0
- package/dist/editor/editStack.d.ts.map +1 -0
- package/dist/editor/editStack.js +218 -0
- package/dist/editor/editStack.js.map +1 -0
- package/dist/editor/editor.d.ts +22 -0
- package/dist/editor/editor.d.ts.map +1 -0
- package/dist/editor/editor.js +1323 -0
- package/dist/editor/editor.js.map +1 -0
- package/dist/editor/index.d.ts +3 -0
- package/dist/editor/index.js +4 -0
- package/dist/editor/lineAnnotations.d.ts +8 -0
- package/dist/editor/lineAnnotations.d.ts.map +1 -0
- package/dist/editor/lineAnnotations.js +32 -0
- package/dist/editor/lineAnnotations.js.map +1 -0
- package/dist/editor/pieceTable.d.ts +33 -0
- package/dist/editor/pieceTable.d.ts.map +1 -0
- package/dist/editor/pieceTable.js +590 -0
- package/dist/editor/pieceTable.js.map +1 -0
- package/dist/editor/platform.d.ts +12 -0
- package/dist/editor/platform.d.ts.map +1 -0
- package/dist/editor/platform.js +44 -0
- package/dist/editor/platform.js.map +1 -0
- package/dist/editor/quickEdit.d.ts +29 -0
- package/dist/editor/quickEdit.d.ts.map +1 -0
- package/dist/editor/quickEdit.js +81 -0
- package/dist/editor/quickEdit.js.map +1 -0
- package/dist/editor/searchPanel.d.ts +30 -0
- package/dist/editor/searchPanel.d.ts.map +1 -0
- package/dist/editor/searchPanel.js +219 -0
- package/dist/editor/searchPanel.js.map +1 -0
- package/dist/editor/selection.d.ts +126 -0
- package/dist/editor/selection.d.ts.map +1 -0
- package/dist/editor/selection.js +900 -0
- package/dist/editor/selection.js.map +1 -0
- package/dist/editor/textDocument.d.ts +139 -0
- package/dist/editor/textDocument.d.ts.map +1 -0
- package/dist/editor/textDocument.js +202 -0
- package/dist/editor/textDocument.js.map +1 -0
- package/dist/editor/textMeasure.d.ts +32 -0
- package/dist/editor/textMeasure.d.ts.map +1 -0
- package/dist/editor/textMeasure.js +108 -0
- package/dist/editor/textMeasure.js.map +1 -0
- package/dist/editor/tokenzier.d.ts +37 -0
- package/dist/editor/tokenzier.d.ts.map +1 -0
- package/dist/editor/tokenzier.js +348 -0
- package/dist/editor/tokenzier.js.map +1 -0
- package/dist/editor/utils.d.ts +16 -0
- package/dist/editor/utils.d.ts.map +1 -0
- package/dist/editor/utils.js +37 -0
- package/dist/editor/utils.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/react/EditorContext.d.ts +16 -0
- package/dist/react/EditorContext.d.ts.map +1 -0
- package/dist/react/EditorContext.js +26 -0
- package/dist/react/EditorContext.js.map +1 -0
- package/dist/react/File.d.ts +2 -1
- package/dist/react/File.d.ts.map +1 -1
- package/dist/react/File.js +3 -2
- package/dist/react/File.js.map +1 -1
- package/dist/react/FileDiff.d.ts +3 -1
- package/dist/react/FileDiff.d.ts.map +1 -1
- package/dist/react/FileDiff.js +3 -2
- package/dist/react/FileDiff.js.map +1 -1
- package/dist/react/MultiFileDiff.d.ts +3 -1
- package/dist/react/MultiFileDiff.d.ts.map +1 -1
- package/dist/react/MultiFileDiff.js +3 -2
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/PatchDiff.d.ts +3 -1
- package/dist/react/PatchDiff.d.ts.map +1 -1
- package/dist/react/PatchDiff.js +3 -2
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/index.d.ts +3 -2
- package/dist/react/index.js +2 -1
- package/dist/react/jsx.d.ts +0 -1
- package/dist/react/jsx.d.ts.map +1 -1
- package/dist/react/types.d.ts +1 -0
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/types.js +0 -1
- package/dist/react/utils/useFileDiffInstance.d.ts +3 -1
- package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js +31 -5
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.d.ts +4 -1
- package/dist/react/utils/useFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileInstance.js +30 -5
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +2 -2
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.d.ts +5 -1
- package/dist/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/renderers/FileRenderer.js +108 -41
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/style.js +1 -1
- package/dist/style.js.map +1 -1
- package/dist/types.d.ts +45 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/cleanLastNewline.js +6 -1
- package/dist/utils/cleanLastNewline.js.map +1 -1
- package/dist/utils/computeFileOffsets.d.ts +13 -0
- package/dist/utils/computeFileOffsets.d.ts.map +1 -0
- package/dist/utils/computeFileOffsets.js +33 -0
- package/dist/utils/computeFileOffsets.js.map +1 -0
- package/dist/utils/createTransformerWithState.js +9 -0
- package/dist/utils/createTransformerWithState.js.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.js +1 -1
- package/dist/utils/renderFileWithHighlighter.js +5 -14
- package/dist/utils/renderFileWithHighlighter.js.map +1 -1
- package/dist/worker/WorkerPoolManager.js +1 -1
- package/dist/worker/{wasm-BaDzIkIn.js → wasm-D4DU5jgR.js} +2 -2
- package/dist/worker/wasm-D4DU5jgR.js.map +1 -0
- package/dist/worker/worker-portable.js +138 -153
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +41 -64
- package/dist/worker/worker.js.map +1 -1
- package/package.json +28 -20
- package/dist/utils/iterateOverFile.d.ts +0 -50
- package/dist/utils/iterateOverFile.d.ts.map +0 -1
- package/dist/utils/iterateOverFile.js +0 -49
- package/dist/utils/iterateOverFile.js.map +0 -1
- package/dist/worker/wasm-BaDzIkIn.js.map +0 -1
package/dist/worker/worker.js
CHANGED
|
@@ -12,7 +12,6 @@ const DIFFS_DEVELOPMENT_BUILD = (() => {
|
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
14
|
})();
|
|
15
|
-
const SPLIT_WITH_NEWLINES = /(?<=\n)/;
|
|
16
15
|
const DEFAULT_THEMES = {
|
|
17
16
|
dark: "pierre-dark",
|
|
18
17
|
light: "pierre-light"
|
|
@@ -454,7 +453,12 @@ function replaceCustomExtensions(version, map) {
|
|
|
454
453
|
//#endregion
|
|
455
454
|
//#region src/utils/cleanLastNewline.ts
|
|
456
455
|
function cleanLastNewline(contents) {
|
|
457
|
-
|
|
456
|
+
let end = contents.length;
|
|
457
|
+
if (contents.charCodeAt(end - 1) === 10) {
|
|
458
|
+
end--;
|
|
459
|
+
if (contents.charCodeAt(end - 1) === 13) end--;
|
|
460
|
+
}
|
|
461
|
+
return contents.slice(0, end);
|
|
458
462
|
}
|
|
459
463
|
|
|
460
464
|
//#endregion
|
|
@@ -631,6 +635,15 @@ function createTransformerWithState(useTokenTransformer = false, useCSSClasses =
|
|
|
631
635
|
} : null
|
|
632
636
|
}];
|
|
633
637
|
if (useCSSClasses) transformers.push(tokenStyleNormalizer, toClass);
|
|
638
|
+
if (useTokenTransformer) transformers.push({ line: (node) => {
|
|
639
|
+
if (node.type === "element" && node.children.length === 0) node.children.push({
|
|
640
|
+
type: "element",
|
|
641
|
+
tagName: "br",
|
|
642
|
+
properties: {},
|
|
643
|
+
children: []
|
|
644
|
+
});
|
|
645
|
+
return node;
|
|
646
|
+
} });
|
|
634
647
|
return {
|
|
635
648
|
state,
|
|
636
649
|
transformers,
|
|
@@ -1542,63 +1555,34 @@ function renderTwoFiles({ deletionFile, additionFile, deletionInfo, additionInfo
|
|
|
1542
1555
|
}
|
|
1543
1556
|
|
|
1544
1557
|
//#endregion
|
|
1545
|
-
//#region src/utils/
|
|
1558
|
+
//#region src/utils/computeFileOffsets.ts
|
|
1559
|
+
const LINE_FEED = 10;
|
|
1560
|
+
const CARRIAGE_RETURN = 13;
|
|
1546
1561
|
/**
|
|
1547
|
-
*
|
|
1548
|
-
*
|
|
1549
|
-
* Similar to `iterateOverDiff` but simplified for linear file content.
|
|
1550
|
-
* Supports viewport windowing for virtualization scenarios.
|
|
1551
|
-
*
|
|
1552
|
-
* @param props - Configuration for iteration
|
|
1553
|
-
* @param props.lines - Pre-split array of lines (use splitFileContents() to create from string)
|
|
1554
|
-
* @param props.startingLine - Optional starting line index (0-based, default: 0)
|
|
1555
|
-
* @param props.totalLines - Optional max lines to iterate (default: Infinity)
|
|
1556
|
-
* @param props.callback - Callback invoked for each line in the window.
|
|
1557
|
-
* Return `true` to stop iteration early.
|
|
1558
|
-
*
|
|
1559
|
-
* @example
|
|
1560
|
-
* ```typescript
|
|
1561
|
-
* const lines = splitFileContents('line1\nline2\nline3');
|
|
1562
|
-
* iterateOverFile({
|
|
1563
|
-
* lines,
|
|
1564
|
-
* startingLine: 0,
|
|
1565
|
-
* totalLines: 10,
|
|
1566
|
-
* callback: ({ lineIndex, lineNumber, content, isLastLine }) => {
|
|
1567
|
-
* console.log(`Line ${lineNumber}: ${content}`);
|
|
1568
|
-
* if (content.includes('stop')) return true; // Stop iteration
|
|
1569
|
-
* }
|
|
1570
|
-
* });
|
|
1571
|
-
* ```
|
|
1562
|
+
* Computes line start offsets for a string.
|
|
1572
1563
|
*/
|
|
1573
|
-
function
|
|
1574
|
-
const
|
|
1575
|
-
|
|
1576
|
-
const
|
|
1577
|
-
if (
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
const isLastLine = lineIndex === lastLineIndex;
|
|
1582
|
-
if (callback({
|
|
1583
|
-
lineIndex,
|
|
1584
|
-
lineNumber: lineIndex + 1,
|
|
1585
|
-
content: lines[lineIndex],
|
|
1586
|
-
isLastLine
|
|
1587
|
-
}) === true || isLastLine) break;
|
|
1564
|
+
function computeLineOffsets(contents) {
|
|
1565
|
+
const offsets = [0];
|
|
1566
|
+
for (let i = 0; i < contents.length; i++) {
|
|
1567
|
+
const char = contents.charCodeAt(i);
|
|
1568
|
+
if (char === LINE_FEED || char === CARRIAGE_RETURN) {
|
|
1569
|
+
if (char === CARRIAGE_RETURN && i + 1 < contents.length && contents.charCodeAt(i + 1) === LINE_FEED) i++;
|
|
1570
|
+
offsets.push(i + 1);
|
|
1571
|
+
}
|
|
1588
1572
|
}
|
|
1573
|
+
return offsets;
|
|
1589
1574
|
}
|
|
1590
|
-
|
|
1591
|
-
//#endregion
|
|
1592
|
-
//#region src/utils/splitFileContents.ts
|
|
1593
1575
|
/**
|
|
1594
|
-
* Splits file contents into lines
|
|
1595
|
-
*
|
|
1596
|
-
*
|
|
1597
|
-
* @param contents - The raw file contents string
|
|
1598
|
-
* @returns Array of lines with newlines preserved
|
|
1576
|
+
* Splits file contents into lines aligned with {@link computeLineOffsets}.
|
|
1577
|
+
* Unlike splitFileContents, a trailing newline produces a final empty line.
|
|
1599
1578
|
*/
|
|
1600
|
-
function
|
|
1601
|
-
|
|
1579
|
+
function linesFromFileContents(contents) {
|
|
1580
|
+
const offsets = computeLineOffsets(contents);
|
|
1581
|
+
return Array.from({ length: offsets.length }, (_, i) => {
|
|
1582
|
+
const start = offsets[i];
|
|
1583
|
+
const end = offsets[i + 1] ?? contents.length;
|
|
1584
|
+
return contents.slice(start, end);
|
|
1585
|
+
});
|
|
1602
1586
|
}
|
|
1603
1587
|
|
|
1604
1588
|
//#endregion
|
|
@@ -1643,7 +1627,7 @@ function renderFileWithHighlighter(file, highlighter$1, { theme = DEFAULT_THEMES
|
|
|
1643
1627
|
tokenizeMaxLineLength
|
|
1644
1628
|
};
|
|
1645
1629
|
})();
|
|
1646
|
-
const highlightedLines = getLineNodes(highlighter$1.codeToHast(isWindowedHighlight ? extractWindowedFileContent(lines ??
|
|
1630
|
+
const highlightedLines = getLineNodes(highlighter$1.codeToHast(isWindowedHighlight ? extractWindowedFileContent(lines ?? linesFromFileContents(file.contents), startingLine, totalLines) : file.contents, hastConfig));
|
|
1647
1631
|
const code = isWindowedHighlight ? new Array(startingLine) : highlightedLines;
|
|
1648
1632
|
if (isWindowedHighlight) code.push(...highlightedLines);
|
|
1649
1633
|
return {
|
|
@@ -1653,16 +1637,9 @@ function renderFileWithHighlighter(file, highlighter$1, { theme = DEFAULT_THEMES
|
|
|
1653
1637
|
};
|
|
1654
1638
|
}
|
|
1655
1639
|
function extractWindowedFileContent(lines, startingLine, totalLines) {
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
startingLine,
|
|
1660
|
-
totalLines,
|
|
1661
|
-
callback({ content }) {
|
|
1662
|
-
windowContent += content;
|
|
1663
|
-
}
|
|
1664
|
-
});
|
|
1665
|
-
return windowContent;
|
|
1640
|
+
if (lines.length === 0) return "";
|
|
1641
|
+
const endLine = Math.min(startingLine + totalLines, lines.length);
|
|
1642
|
+
return lines.slice(startingLine, endLine).join("");
|
|
1666
1643
|
}
|
|
1667
1644
|
|
|
1668
1645
|
//#endregion
|