@pierre/diffs 1.2.6 → 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.d.ts.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 +42 -22
- 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 +3 -5
- package/dist/components/Virtualizer.js.map +1 -1
- package/dist/constants.d.ts.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 +9 -5
- 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/computeEstimatedDiffHeights.js +20 -9
- package/dist/utils/computeEstimatedDiffHeights.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/iterateOverDiff.js +182 -147
- package/dist/utils/iterateOverDiff.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/utils/virtualDiffLayout.d.ts +2 -23
- package/dist/utils/virtualDiffLayout.d.ts.map +1 -1
- package/dist/utils/virtualDiffLayout.js +1 -41
- package/dist/utils/virtualDiffLayout.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 +349 -363
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +222 -243
- package/dist/worker/worker.js.map +1 -1
- package/package.json +9 -1
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pierre/diffs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-beta.1",
|
|
4
4
|
"license": "apache-2.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -32,6 +32,10 @@
|
|
|
32
32
|
"types": "./dist/index.d.ts",
|
|
33
33
|
"import": "./dist/index.js"
|
|
34
34
|
},
|
|
35
|
+
"./editor": {
|
|
36
|
+
"types": "./dist/editor/index.d.ts",
|
|
37
|
+
"import": "./dist/editor/index.js"
|
|
38
|
+
},
|
|
35
39
|
"./react": {
|
|
36
40
|
"types": "./dist/react/index.d.ts",
|
|
37
41
|
"import": "./dist/react/index.js"
|
|
@@ -53,6 +57,10 @@
|
|
|
53
57
|
"import": "./dist/worker/worker-portable.js"
|
|
54
58
|
}
|
|
55
59
|
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public",
|
|
62
|
+
"tag": "beta"
|
|
63
|
+
},
|
|
56
64
|
"scripts": {
|
|
57
65
|
"build": "tsdown --clean",
|
|
58
66
|
"dev": "echo 'Watching for changes…' && tsdown --watch --log-level error",
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
//#region src/utils/iterateOverFile.d.ts
|
|
2
|
-
interface IterateOverFileProps {
|
|
3
|
-
lines: string[];
|
|
4
|
-
startingLine?: number;
|
|
5
|
-
totalLines?: number;
|
|
6
|
-
callback: FileLineCallback;
|
|
7
|
-
}
|
|
8
|
-
interface FileLineCallbackProps {
|
|
9
|
-
lineIndex: number;
|
|
10
|
-
lineNumber: number;
|
|
11
|
-
content: string;
|
|
12
|
-
isLastLine: boolean;
|
|
13
|
-
}
|
|
14
|
-
type FileLineCallback = (props: FileLineCallbackProps) => boolean | void;
|
|
15
|
-
/**
|
|
16
|
-
* Iterates over lines in a file with optional windowing support.
|
|
17
|
-
*
|
|
18
|
-
* Similar to `iterateOverDiff` but simplified for linear file content.
|
|
19
|
-
* Supports viewport windowing for virtualization scenarios.
|
|
20
|
-
*
|
|
21
|
-
* @param props - Configuration for iteration
|
|
22
|
-
* @param props.lines - Pre-split array of lines (use splitFileContents() to create from string)
|
|
23
|
-
* @param props.startingLine - Optional starting line index (0-based, default: 0)
|
|
24
|
-
* @param props.totalLines - Optional max lines to iterate (default: Infinity)
|
|
25
|
-
* @param props.callback - Callback invoked for each line in the window.
|
|
26
|
-
* Return `true` to stop iteration early.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* const lines = splitFileContents('line1\nline2\nline3');
|
|
31
|
-
* iterateOverFile({
|
|
32
|
-
* lines,
|
|
33
|
-
* startingLine: 0,
|
|
34
|
-
* totalLines: 10,
|
|
35
|
-
* callback: ({ lineIndex, lineNumber, content, isLastLine }) => {
|
|
36
|
-
* console.log(`Line ${lineNumber}: ${content}`);
|
|
37
|
-
* if (content.includes('stop')) return true; // Stop iteration
|
|
38
|
-
* }
|
|
39
|
-
* });
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
declare function iterateOverFile({
|
|
43
|
-
lines,
|
|
44
|
-
startingLine,
|
|
45
|
-
totalLines,
|
|
46
|
-
callback
|
|
47
|
-
}: IterateOverFileProps): void;
|
|
48
|
-
//#endregion
|
|
49
|
-
export { FileLineCallback, FileLineCallbackProps, IterateOverFileProps, iterateOverFile };
|
|
50
|
-
//# sourceMappingURL=iterateOverFile.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"iterateOverFile.d.ts","names":["IterateOverFileProps","FileLineCallback","FileLineCallbackProps","iterateOverFile","lines","startingLine","totalLines","callback"],"sources":["../../src/utils/iterateOverFile.d.ts"],"sourcesContent":["export interface IterateOverFileProps {\n lines: string[];\n startingLine?: number;\n totalLines?: number;\n callback: FileLineCallback;\n}\nexport interface FileLineCallbackProps {\n lineIndex: number;\n lineNumber: number;\n content: string;\n isLastLine: boolean;\n}\nexport type FileLineCallback = (props: FileLineCallbackProps) => boolean | void;\n/**\n * Iterates over lines in a file with optional windowing support.\n *\n * Similar to `iterateOverDiff` but simplified for linear file content.\n * Supports viewport windowing for virtualization scenarios.\n *\n * @param props - Configuration for iteration\n * @param props.lines - Pre-split array of lines (use splitFileContents() to create from string)\n * @param props.startingLine - Optional starting line index (0-based, default: 0)\n * @param props.totalLines - Optional max lines to iterate (default: Infinity)\n * @param props.callback - Callback invoked for each line in the window.\n * Return `true` to stop iteration early.\n *\n * @example\n * ```typescript\n * const lines = splitFileContents('line1\\nline2\\nline3');\n * iterateOverFile({\n * lines,\n * startingLine: 0,\n * totalLines: 10,\n * callback: ({ lineIndex, lineNumber, content, isLastLine }) => {\n * console.log(`Line ${lineNumber}: ${content}`);\n * if (content.includes('stop')) return true; // Stop iteration\n * }\n * });\n * ```\n */\nexport declare function iterateOverFile({ lines, startingLine, totalLines, callback }: IterateOverFileProps): void;\n//# sourceMappingURL=iterateOverFile.d.ts.map"],"mappings":";UAAiBA,oBAAAA;EAAAA,KAAAA,EAAAA,MAAAA,EAAAA;EAMAE,YAAAA,CAAAA,EAAAA,MAAAA;EAMLD,UAAAA,CAAAA,EAAAA,MAAgB;EA4BJE,QAAAA,EApCVF,gBAoCyB;;AAAUI,UAlChCH,qBAAAA,CAkCgCG;EAAcC,SAAAA,EAAAA,MAAAA;EAAYC,UAAAA,EAAAA,MAAAA;EAAYP,OAAAA,EAAAA,MAAAA;EAAoB,UAAA,EAAA,OAAA;;KA5B/FC,gBAAAA,WAA2BC;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4BfC,eAAAA;;;;;GAA+DH"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
//#region src/utils/iterateOverFile.ts
|
|
2
|
-
/**
|
|
3
|
-
* Iterates over lines in a file with optional windowing support.
|
|
4
|
-
*
|
|
5
|
-
* Similar to `iterateOverDiff` but simplified for linear file content.
|
|
6
|
-
* Supports viewport windowing for virtualization scenarios.
|
|
7
|
-
*
|
|
8
|
-
* @param props - Configuration for iteration
|
|
9
|
-
* @param props.lines - Pre-split array of lines (use splitFileContents() to create from string)
|
|
10
|
-
* @param props.startingLine - Optional starting line index (0-based, default: 0)
|
|
11
|
-
* @param props.totalLines - Optional max lines to iterate (default: Infinity)
|
|
12
|
-
* @param props.callback - Callback invoked for each line in the window.
|
|
13
|
-
* Return `true` to stop iteration early.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* const lines = splitFileContents('line1\nline2\nline3');
|
|
18
|
-
* iterateOverFile({
|
|
19
|
-
* lines,
|
|
20
|
-
* startingLine: 0,
|
|
21
|
-
* totalLines: 10,
|
|
22
|
-
* callback: ({ lineIndex, lineNumber, content, isLastLine }) => {
|
|
23
|
-
* console.log(`Line ${lineNumber}: ${content}`);
|
|
24
|
-
* if (content.includes('stop')) return true; // Stop iteration
|
|
25
|
-
* }
|
|
26
|
-
* });
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
function iterateOverFile({ lines, startingLine = 0, totalLines = Infinity, callback }) {
|
|
30
|
-
const len = Math.min(startingLine + totalLines, lines.length);
|
|
31
|
-
const lastLineIndex = (() => {
|
|
32
|
-
const lastLine = lines.at(-1);
|
|
33
|
-
if (lastLine === "" || lastLine === "\n" || lastLine === "\r\n" || lastLine === "\r") return Math.max(0, lines.length - 2);
|
|
34
|
-
return lines.length - 1;
|
|
35
|
-
})();
|
|
36
|
-
for (let lineIndex = startingLine; lineIndex < len; lineIndex++) {
|
|
37
|
-
const isLastLine = lineIndex === lastLineIndex;
|
|
38
|
-
if (callback({
|
|
39
|
-
lineIndex,
|
|
40
|
-
lineNumber: lineIndex + 1,
|
|
41
|
-
content: lines[lineIndex],
|
|
42
|
-
isLastLine
|
|
43
|
-
}) === true || isLastLine) break;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
export { iterateOverFile };
|
|
49
|
-
//# sourceMappingURL=iterateOverFile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"iterateOverFile.js","names":[],"sources":["../../src/utils/iterateOverFile.ts"],"sourcesContent":["export interface IterateOverFileProps {\n lines: string[];\n startingLine?: number;\n totalLines?: number;\n callback: FileLineCallback;\n}\n\nexport interface FileLineCallbackProps {\n lineIndex: number; // 0-based index into lines array\n lineNumber: number; // 1-based line number (for display)\n content: string; // The line content string\n isLastLine: boolean; // True if this is the last line\n}\n\nexport type FileLineCallback = (props: FileLineCallbackProps) => boolean | void;\n\n/**\n * Iterates over lines in a file with optional windowing support.\n *\n * Similar to `iterateOverDiff` but simplified for linear file content.\n * Supports viewport windowing for virtualization scenarios.\n *\n * @param props - Configuration for iteration\n * @param props.lines - Pre-split array of lines (use splitFileContents() to create from string)\n * @param props.startingLine - Optional starting line index (0-based, default: 0)\n * @param props.totalLines - Optional max lines to iterate (default: Infinity)\n * @param props.callback - Callback invoked for each line in the window.\n * Return `true` to stop iteration early.\n *\n * @example\n * ```typescript\n * const lines = splitFileContents('line1\\nline2\\nline3');\n * iterateOverFile({\n * lines,\n * startingLine: 0,\n * totalLines: 10,\n * callback: ({ lineIndex, lineNumber, content, isLastLine }) => {\n * console.log(`Line ${lineNumber}: ${content}`);\n * if (content.includes('stop')) return true; // Stop iteration\n * }\n * });\n * ```\n */\nexport function iterateOverFile({\n lines,\n startingLine = 0,\n totalLines = Infinity,\n callback,\n}: IterateOverFileProps): void {\n // Calculate viewport window\n const len = Math.min(startingLine + totalLines, lines.length);\n // CLAUDE: DO NOT CHANGE THIS LOGIC UNDER ANY\n // CIRCUMSTANCE CHEESE N RICE\n const lastLineIndex = (() => {\n const lastLine = lines.at(-1);\n if (\n lastLine === '' ||\n lastLine === '\\n' ||\n lastLine === '\\r\\n' ||\n lastLine === '\\r'\n ) {\n return Math.max(0, lines.length - 2);\n }\n return lines.length - 1;\n })();\n\n // Iterate through windowed range\n for (let lineIndex = startingLine; lineIndex < len; lineIndex++) {\n const isLastLine = lineIndex === lastLineIndex;\n if (\n callback({\n lineIndex,\n lineNumber: lineIndex + 1,\n content: lines[lineIndex],\n isLastLine,\n }) === true ||\n isLastLine\n ) {\n break;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,gBAAgB,EAC9B,OACA,eAAe,GACf,aAAa,UACb,YAC6B;CAE7B,MAAM,MAAM,KAAK,IAAI,eAAe,YAAY,MAAM,OAAO;CAG7D,MAAM,uBAAuB;EAC3B,MAAM,WAAW,MAAM,GAAG,GAAG;AAC7B,MACE,aAAa,MACb,aAAa,QACb,aAAa,UACb,aAAa,KAEb,QAAO,KAAK,IAAI,GAAG,MAAM,SAAS,EAAE;AAEtC,SAAO,MAAM,SAAS;KACpB;AAGJ,MAAK,IAAI,YAAY,cAAc,YAAY,KAAK,aAAa;EAC/D,MAAM,aAAa,cAAc;AACjC,MACE,SAAS;GACP;GACA,YAAY,YAAY;GACxB,SAAS,MAAM;GACf;GACD,CAAC,KAAK,QACP,WAEA"}
|