@pierre/diffs 1.1.0-beta.8 → 1.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/README.md +7 -18
- package/dist/components/AdvancedVirtualizedFileDiff.js +2 -7
- package/dist/components/AdvancedVirtualizedFileDiff.js.map +1 -1
- package/dist/components/AdvancedVirtualizer.js +1 -1
- package/dist/components/AdvancedVirtualizer.js.map +1 -1
- package/dist/components/File.d.ts +17 -7
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +111 -54
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +32 -14
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +156 -81
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/UnresolvedFile.d.ts +60 -0
- package/dist/components/UnresolvedFile.d.ts.map +1 -0
- package/dist/components/UnresolvedFile.js +280 -0
- package/dist/components/UnresolvedFile.js.map +1 -0
- package/dist/components/VirtualizedFile.js +8 -5
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +15 -11
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/components/Virtualizer.d.ts +3 -1
- package/dist/components/Virtualizer.d.ts.map +1 -1
- package/dist/components/Virtualizer.js +50 -24
- package/dist/components/Virtualizer.js.map +1 -1
- package/dist/constants.d.ts +3 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +8 -1
- package/dist/constants.js.map +1 -1
- package/dist/highlighter/shared_highlighter.d.ts +4 -2
- package/dist/highlighter/shared_highlighter.d.ts.map +1 -1
- package/dist/highlighter/shared_highlighter.js +15 -7
- package/dist/highlighter/shared_highlighter.js.map +1 -1
- package/dist/index.d.ts +9 -7
- package/dist/index.js +8 -6
- package/dist/managers/InteractionManager.d.ts +146 -0
- package/dist/managers/InteractionManager.d.ts.map +1 -0
- package/dist/managers/InteractionManager.js +813 -0
- package/dist/managers/InteractionManager.js.map +1 -0
- package/dist/managers/ResizeManager.d.ts +0 -2
- package/dist/managers/ResizeManager.d.ts.map +1 -1
- package/dist/managers/ResizeManager.js +43 -32
- package/dist/managers/ResizeManager.js.map +1 -1
- package/dist/react/File.d.ts +2 -0
- package/dist/react/File.d.ts.map +1 -1
- package/dist/react/File.js +3 -1
- package/dist/react/File.js.map +1 -1
- package/dist/react/FileDiff.d.ts +2 -0
- package/dist/react/FileDiff.d.ts.map +1 -1
- package/dist/react/FileDiff.js +3 -1
- package/dist/react/FileDiff.js.map +1 -1
- package/dist/react/MultiFileDiff.d.ts +2 -0
- package/dist/react/MultiFileDiff.d.ts.map +1 -1
- package/dist/react/MultiFileDiff.js +3 -1
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/PatchDiff.d.ts +2 -0
- package/dist/react/PatchDiff.d.ts.map +1 -1
- package/dist/react/PatchDiff.js +3 -1
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/UnresolvedFile.d.ts +36 -0
- package/dist/react/UnresolvedFile.d.ts.map +1 -0
- package/dist/react/UnresolvedFile.js +42 -0
- package/dist/react/UnresolvedFile.js.map +1 -0
- package/dist/react/constants.d.ts +3 -2
- package/dist/react/constants.d.ts.map +1 -1
- package/dist/react/constants.js +3 -2
- package/dist/react/constants.js.map +1 -1
- package/dist/react/index.d.ts +4 -3
- package/dist/react/index.js +3 -2
- package/dist/react/types.d.ts +11 -2
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.d.ts +16 -5
- package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.js +34 -7
- package/dist/react/utils/renderDiffChildren.js.map +1 -1
- package/dist/react/utils/renderFileChildren.d.ts +5 -1
- package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
- package/dist/react/utils/renderFileChildren.js +13 -7
- package/dist/react/utils/renderFileChildren.js.map +1 -1
- package/dist/react/utils/useFileDiffInstance.d.ts +1 -2
- package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js +2 -2
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.d.ts +1 -2
- package/dist/react/utils/useFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.d.ts +33 -0
- package/dist/react/utils/useUnresolvedFileInstance.d.ts.map +1 -0
- package/dist/react/utils/useUnresolvedFileInstance.js +87 -0
- package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -0
- package/dist/renderers/DiffHunksRenderer.d.ts +50 -6
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +146 -45
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.js +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts +46 -0
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts.map +1 -0
- package/dist/renderers/UnresolvedFileHunksRenderer.js +207 -0
- package/dist/renderers/UnresolvedFileHunksRenderer.js.map +1 -0
- package/dist/shiki-stream/stream.d.ts +1 -1
- package/dist/shiki-stream/stream.d.ts.map +1 -1
- package/dist/shiki-stream/stream.js.map +1 -1
- package/dist/shiki-stream/tokenizer.d.ts +1 -1
- package/dist/shiki-stream/tokenizer.d.ts.map +1 -1
- package/dist/shiki-stream/tokenizer.js.map +1 -1
- package/dist/shiki-stream/types.d.ts +1 -1
- package/dist/shiki-stream/types.d.ts.map +1 -1
- package/dist/sprite.d.ts +2 -2
- package/dist/sprite.d.ts.map +1 -1
- package/dist/sprite.js +3 -0
- package/dist/sprite.js.map +1 -1
- package/dist/ssr/index.d.ts +3 -3
- package/dist/ssr/index.js +2 -2
- package/dist/ssr/preloadDiffs.d.ts +23 -14
- package/dist/ssr/preloadDiffs.d.ts.map +1 -1
- package/dist/ssr/preloadDiffs.js +40 -14
- package/dist/ssr/preloadDiffs.js.map +1 -1
- package/dist/style.js +1 -1
- package/dist/style.js.map +1 -1
- package/dist/types.d.ts +29 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/areMergeConflictActionsEqual.d.ts +7 -0
- package/dist/utils/areMergeConflictActionsEqual.d.ts.map +1 -0
- package/dist/utils/areMergeConflictActionsEqual.js +11 -0
- package/dist/utils/areMergeConflictActionsEqual.js.map +1 -0
- package/dist/utils/arePrePropertiesEqual.js +10 -1
- package/dist/utils/arePrePropertiesEqual.js.map +1 -1
- package/dist/utils/areSelectionPointsEqual.d.ts +7 -0
- package/dist/utils/areSelectionPointsEqual.d.ts.map +1 -0
- package/dist/utils/areSelectionPointsEqual.js +8 -0
- package/dist/utils/areSelectionPointsEqual.js.map +1 -0
- package/dist/utils/areSelectionsEqual.d.ts +1 -1
- package/dist/utils/areSelectionsEqual.d.ts.map +1 -1
- package/dist/utils/areSelectionsEqual.js.map +1 -1
- package/dist/utils/createFileHeaderElement.js +5 -2
- package/dist/utils/createFileHeaderElement.js.map +1 -1
- package/dist/utils/createGutterUtilityContentNode.d.ts +5 -0
- package/dist/utils/createGutterUtilityContentNode.d.ts.map +1 -0
- package/dist/utils/createGutterUtilityContentNode.js +15 -0
- package/dist/utils/createGutterUtilityContentNode.js.map +1 -0
- package/dist/utils/createGutterUtilityElement.d.ts +7 -0
- package/dist/utils/createGutterUtilityElement.d.ts.map +1 -0
- package/dist/utils/createGutterUtilityElement.js +20 -0
- package/dist/utils/createGutterUtilityElement.js.map +1 -0
- package/dist/utils/createPreElement.d.ts +2 -1
- package/dist/utils/createPreElement.d.ts.map +1 -1
- package/dist/utils/createPreElement.js +2 -1
- package/dist/utils/createPreElement.js.map +1 -1
- package/dist/utils/createSeparator.js +1 -1
- package/dist/utils/createSeparator.js.map +1 -1
- package/dist/utils/createWindowFromScrollPosition.js +12 -11
- package/dist/utils/createWindowFromScrollPosition.js.map +1 -1
- package/dist/utils/getHighlighterOptions.d.ts +7 -2
- package/dist/utils/getHighlighterOptions.d.ts.map +1 -1
- package/dist/utils/getHighlighterOptions.js +3 -2
- package/dist/utils/getHighlighterOptions.js.map +1 -1
- package/dist/utils/getMergeConflictActionSlotName.d.ts +16 -0
- package/dist/utils/getMergeConflictActionSlotName.d.ts.map +1 -0
- package/dist/utils/getMergeConflictActionSlotName.js +8 -0
- package/dist/utils/getMergeConflictActionSlotName.js.map +1 -0
- package/dist/utils/getMergeConflictLineTypes.d.ts +15 -0
- package/dist/utils/getMergeConflictLineTypes.d.ts.map +1 -0
- package/dist/utils/getMergeConflictLineTypes.js +81 -0
- package/dist/utils/getMergeConflictLineTypes.js.map +1 -0
- package/dist/utils/getOrCreateCodeNode.d.ts +3 -1
- package/dist/utils/getOrCreateCodeNode.d.ts.map +1 -1
- package/dist/utils/getOrCreateCodeNode.js +5 -3
- package/dist/utils/getOrCreateCodeNode.js.map +1 -1
- package/dist/utils/hast_utils.d.ts +2 -2
- package/dist/utils/hast_utils.d.ts.map +1 -1
- package/dist/utils/hast_utils.js +3 -2
- package/dist/utils/hast_utils.js.map +1 -1
- package/dist/utils/parseMergeConflictDiffFromFile.d.ts +26 -0
- package/dist/utils/parseMergeConflictDiffFromFile.d.ts.map +1 -0
- package/dist/utils/parseMergeConflictDiffFromFile.js +143 -0
- package/dist/utils/parseMergeConflictDiffFromFile.js.map +1 -0
- package/dist/utils/resolveMergeConflict.d.ts +7 -0
- package/dist/utils/resolveMergeConflict.d.ts.map +1 -0
- package/dist/utils/resolveMergeConflict.js +30 -0
- package/dist/utils/resolveMergeConflict.js.map +1 -0
- package/dist/utils/resolveVirtualFileMetrics.js +1 -0
- package/dist/utils/resolveVirtualFileMetrics.js.map +1 -1
- package/dist/utils/setWrapperNodeProps.d.ts +2 -1
- package/dist/utils/setWrapperNodeProps.d.ts.map +1 -1
- package/dist/utils/setWrapperNodeProps.js +5 -1
- package/dist/utils/setWrapperNodeProps.js.map +1 -1
- package/dist/worker/WorkerPoolManager.d.ts +4 -2
- package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
- package/dist/worker/WorkerPoolManager.js +16 -9
- package/dist/worker/WorkerPoolManager.js.map +1 -1
- package/dist/worker/types.d.ts +3 -1
- package/dist/worker/types.d.ts.map +1 -1
- package/dist/worker/wasm-BlUZCxHM.js +10 -0
- package/dist/worker/wasm-BlUZCxHM.js.map +1 -0
- package/dist/worker/worker-portable.js +10546 -10106
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +27 -19
- package/dist/worker/worker.js.map +1 -1
- package/package.json +3 -7
- package/dist/managers/LineSelectionManager.d.ts +0 -64
- package/dist/managers/LineSelectionManager.d.ts.map +0 -1
- package/dist/managers/LineSelectionManager.js +0 -270
- package/dist/managers/LineSelectionManager.js.map +0 -1
- package/dist/managers/MouseEventManager.d.ts +0 -71
- package/dist/managers/MouseEventManager.d.ts.map +0 -1
- package/dist/managers/MouseEventManager.js +0 -358
- package/dist/managers/MouseEventManager.js.map +0 -1
- package/dist/themes/pierre-dark.js +0 -1328
- package/dist/themes/pierre-dark.js.map +0 -1
- package/dist/themes/pierre-light.js +0 -1328
- package/dist/themes/pierre-light.js.map +0 -1
- package/dist/utils/createHoverContentNode.d.ts +0 -5
- package/dist/utils/createHoverContentNode.d.ts.map +0 -1
- package/dist/utils/createHoverContentNode.js +0 -15
- package/dist/utils/createHoverContentNode.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES } from "../constants.js";
|
|
2
|
+
import { createGutterGap, createGutterItem, createGutterWrapper, createHastElement } from "../utils/hast_utils.js";
|
|
2
3
|
import { areLanguagesAttached } from "../highlighter/languages/areLanguagesAttached.js";
|
|
3
4
|
import { getHighlighterIfLoaded, getSharedHighlighter } from "../highlighter/shared_highlighter.js";
|
|
4
5
|
import { areThemesAttached } from "../highlighter/themes/areThemesAttached.js";
|
|
5
6
|
import { areRenderRangesEqual } from "../utils/areRenderRangesEqual.js";
|
|
6
7
|
import { areThemesEqual } from "../utils/areThemesEqual.js";
|
|
7
|
-
import { createGutterGap, createGutterItem, createGutterWrapper, createHastElement } from "../utils/hast_utils.js";
|
|
8
8
|
import { createAnnotationElement } from "../utils/createAnnotationElement.js";
|
|
9
9
|
import { createContentColumn } from "../utils/createContentColumn.js";
|
|
10
10
|
import { createFileHeaderElement } from "../utils/createFileHeaderElement.js";
|
|
@@ -66,14 +66,14 @@ var DiffHunksRenderer = class {
|
|
|
66
66
|
if (this.getOptionsWithDefaults().themeType === themeType) return;
|
|
67
67
|
this.mergeOptions({ themeType });
|
|
68
68
|
}
|
|
69
|
-
expandHunk(index, direction) {
|
|
70
|
-
const { expansionLineCount } = this.getOptionsWithDefaults();
|
|
69
|
+
expandHunk(index, direction, expansionLineCount = this.getOptionsWithDefaults().expansionLineCount) {
|
|
71
70
|
const region = { ...this.expandedHunks.get(index) ?? {
|
|
72
71
|
fromStart: 0,
|
|
73
72
|
fromEnd: 0
|
|
74
73
|
} };
|
|
75
74
|
if (direction === "up" || direction === "both") region.fromStart += expansionLineCount;
|
|
76
75
|
if (direction === "down" || direction === "both") region.fromEnd += expansionLineCount;
|
|
76
|
+
if (this.renderCache?.highlighted !== true) this.renderCache = void 0;
|
|
77
77
|
this.expandedHunks.set(index, region);
|
|
78
78
|
}
|
|
79
79
|
getExpandedHunk(hunkIndex) {
|
|
@@ -97,8 +97,18 @@ var DiffHunksRenderer = class {
|
|
|
97
97
|
arr.push(annotation);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
+
getUnifiedLineDecoration({ lineType }) {
|
|
101
|
+
return { gutterLineType: lineType };
|
|
102
|
+
}
|
|
103
|
+
getSplitLineDecoration({ side, type }) {
|
|
104
|
+
if (type !== "change") return { gutterLineType: type };
|
|
105
|
+
return { gutterLineType: side === "deletions" ? "change-deletion" : "change-addition" };
|
|
106
|
+
}
|
|
107
|
+
createAnnotationElement(span) {
|
|
108
|
+
return createAnnotationElement(span);
|
|
109
|
+
}
|
|
100
110
|
getOptionsWithDefaults() {
|
|
101
|
-
const { diffIndicators = "bars", diffStyle = "split", disableBackground = false, disableFileHeader = false, disableLineNumbers = false, disableVirtualizationBuffers = false, expandUnchanged = false, collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, expansionLineCount = 100, hunkSeparators = "line-info", lineDiffType = "word-alt", maxLineDiffLength = 1e3, overflow = "scroll", theme = DEFAULT_THEMES, themeType = "system", tokenizeMaxLineLength = 1e3, useCSSClasses = false } = this.options;
|
|
111
|
+
const { diffIndicators = "bars", diffStyle = "split", disableBackground = false, disableFileHeader = false, disableLineNumbers = false, disableVirtualizationBuffers = false, collapsed = false, expandUnchanged = false, collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, expansionLineCount = 100, hunkSeparators = "line-info", lineDiffType = "word-alt", maxLineDiffLength = 1e3, overflow = "scroll", theme = DEFAULT_THEMES, themeType = "system", tokenizeMaxLineLength = 1e3, useCSSClasses = false } = this.options;
|
|
102
112
|
return {
|
|
103
113
|
diffIndicators,
|
|
104
114
|
diffStyle,
|
|
@@ -106,6 +116,7 @@ var DiffHunksRenderer = class {
|
|
|
106
116
|
disableFileHeader,
|
|
107
117
|
disableLineNumbers,
|
|
108
118
|
disableVirtualizationBuffers,
|
|
119
|
+
collapsed,
|
|
109
120
|
expandUnchanged,
|
|
110
121
|
collapsedContextThreshold,
|
|
111
122
|
expansionLineCount,
|
|
@@ -214,7 +225,7 @@ var DiffHunksRenderer = class {
|
|
|
214
225
|
const { result } = await this.asyncHighlight(diff);
|
|
215
226
|
return this.processDiffResult(diff, renderRange, result);
|
|
216
227
|
}
|
|
217
|
-
createPreElement(split, totalLines, themeStyles, baseThemeType) {
|
|
228
|
+
createPreElement(split, totalLines, themeStyles, baseThemeType, customProperties) {
|
|
218
229
|
const { diffIndicators, disableBackground, disableLineNumbers, overflow, themeType } = this.getOptionsWithDefaults();
|
|
219
230
|
return createPreElement({
|
|
220
231
|
type: "diff",
|
|
@@ -225,7 +236,8 @@ var DiffHunksRenderer = class {
|
|
|
225
236
|
themeStyles,
|
|
226
237
|
split,
|
|
227
238
|
themeType: baseThemeType ?? themeType,
|
|
228
|
-
totalLines
|
|
239
|
+
totalLines,
|
|
240
|
+
customProperties
|
|
229
241
|
});
|
|
230
242
|
}
|
|
231
243
|
async asyncHighlight(diff) {
|
|
@@ -300,30 +312,35 @@ var DiffHunksRenderer = class {
|
|
|
300
312
|
}
|
|
301
313
|
};
|
|
302
314
|
const trailingRangeSize = calculateTrailingRangeSize(fileDiff);
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
315
|
+
const pendingSplitContext = {
|
|
316
|
+
size: 0,
|
|
317
|
+
side: void 0,
|
|
318
|
+
increment() {
|
|
319
|
+
this.size += 1;
|
|
320
|
+
},
|
|
321
|
+
flush() {
|
|
322
|
+
if (diffStyle === "unified") return;
|
|
323
|
+
if (this.size <= 0 || this.side == null) {
|
|
324
|
+
this.side = void 0;
|
|
325
|
+
this.size = 0;
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
if (this.side === "additions") {
|
|
329
|
+
context.pushToGutter("additions", createGutterGap(void 0, "buffer", this.size));
|
|
330
|
+
additionsContentAST?.push(createEmptyRowBuffer(this.size));
|
|
331
|
+
} else {
|
|
332
|
+
context.pushToGutter("deletions", createGutterGap(void 0, "buffer", this.size));
|
|
333
|
+
deletionsContentAST?.push(createEmptyRowBuffer(this.size));
|
|
334
|
+
}
|
|
335
|
+
this.size = 0;
|
|
336
|
+
this.side = void 0;
|
|
321
337
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
338
|
+
};
|
|
339
|
+
const pushGutterLineNumber = (type, lineType, lineNumber, lineIndex, gutterProperties) => {
|
|
340
|
+
context.pushToGutter(type, createGutterItem(lineType, lineNumber, lineIndex, gutterProperties));
|
|
341
|
+
};
|
|
325
342
|
function pushSeparators(props) {
|
|
326
|
-
|
|
343
|
+
pendingSplitContext.flush();
|
|
327
344
|
if (diffStyle === "unified") pushSeparator("unified", props, context);
|
|
328
345
|
else {
|
|
329
346
|
pushSeparator("deletions", props, context);
|
|
@@ -340,7 +357,7 @@ var DiffHunksRenderer = class {
|
|
|
340
357
|
callback: ({ hunkIndex, hunk, collapsedBefore, collapsedAfter, additionLine, deletionLine, type }) => {
|
|
341
358
|
const splitLineIndex = deletionLine != null ? deletionLine.splitLineIndex : additionLine.splitLineIndex;
|
|
342
359
|
const unifiedLineIndex = additionLine != null ? additionLine.unifiedLineIndex : deletionLine.unifiedLineIndex;
|
|
343
|
-
if (diffStyle === "split" && type !== "change")
|
|
360
|
+
if (diffStyle === "split" && type !== "change") pendingSplitContext.flush();
|
|
344
361
|
if (collapsedBefore > 0) pushSeparators({
|
|
345
362
|
hunkIndex,
|
|
346
363
|
collapsedLines: collapsedBefore,
|
|
@@ -351,26 +368,57 @@ var DiffHunksRenderer = class {
|
|
|
351
368
|
isExpandable: !fileDiff.isPartial
|
|
352
369
|
});
|
|
353
370
|
const lineIndex = diffStyle === "unified" ? unifiedLineIndex : splitLineIndex;
|
|
371
|
+
const renderedLineContext = {
|
|
372
|
+
type,
|
|
373
|
+
hunkIndex,
|
|
374
|
+
lineIndex,
|
|
375
|
+
unifiedLineIndex,
|
|
376
|
+
splitLineIndex,
|
|
377
|
+
deletionLine,
|
|
378
|
+
additionLine
|
|
379
|
+
};
|
|
354
380
|
if (diffStyle === "unified") {
|
|
355
|
-
|
|
356
|
-
|
|
381
|
+
let deletionLineContent = deletionLine != null ? deletionLines[deletionLine.lineIndex] : void 0;
|
|
382
|
+
let additionLineContent = additionLine != null ? additionLines[additionLine.lineIndex] : void 0;
|
|
357
383
|
if (deletionLineContent == null && additionLineContent == null) {
|
|
358
384
|
const errorMessage = "DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";
|
|
359
385
|
console.error(errorMessage, { file: fileDiff.name });
|
|
360
386
|
throw new Error(errorMessage);
|
|
361
387
|
}
|
|
362
|
-
|
|
388
|
+
const lineType = type === "change" ? additionLine != null ? "change-addition" : "change-deletion" : type;
|
|
389
|
+
const lineDecoration = this.getUnifiedLineDecoration({
|
|
390
|
+
type,
|
|
391
|
+
lineType,
|
|
392
|
+
additionLineIndex: additionLine?.lineIndex,
|
|
393
|
+
deletionLineIndex: deletionLine?.lineIndex
|
|
394
|
+
});
|
|
395
|
+
pushGutterLineNumber("unified", lineDecoration.gutterLineType, additionLine != null ? additionLine.lineNumber : deletionLine.lineNumber, `${unifiedLineIndex},${splitLineIndex}`, lineDecoration.gutterProperties);
|
|
396
|
+
if (additionLineContent != null) additionLineContent = withContentProperties(additionLineContent, lineDecoration.contentProperties);
|
|
397
|
+
else if (deletionLineContent != null) deletionLineContent = withContentProperties(deletionLineContent, lineDecoration.contentProperties);
|
|
363
398
|
pushLineWithAnnotation({
|
|
364
399
|
diffStyle: "unified",
|
|
365
400
|
type,
|
|
366
401
|
deletionLine: deletionLineContent,
|
|
367
402
|
additionLine: additionLineContent,
|
|
368
403
|
unifiedSpan: this.getAnnotations("unified", deletionLine?.lineNumber, additionLine?.lineNumber, hunkIndex, lineIndex),
|
|
404
|
+
createAnnotationElement: (span) => this.createAnnotationElement(span),
|
|
369
405
|
context
|
|
370
406
|
});
|
|
407
|
+
const inlineRows = this.getUnifiedInlineRowsForLine?.(renderedLineContext);
|
|
408
|
+
if (inlineRows != null) pushUnifiedInlineRows(inlineRows, context);
|
|
371
409
|
} else {
|
|
372
|
-
|
|
373
|
-
|
|
410
|
+
let deletionLineContent = deletionLine != null ? deletionLines[deletionLine.lineIndex] : void 0;
|
|
411
|
+
let additionLineContent = additionLine != null ? additionLines[additionLine.lineIndex] : void 0;
|
|
412
|
+
const deletionLineDecoration = this.getSplitLineDecoration({
|
|
413
|
+
side: "deletions",
|
|
414
|
+
type,
|
|
415
|
+
lineIndex: deletionLine?.lineIndex
|
|
416
|
+
});
|
|
417
|
+
const additionLineDecoration = this.getSplitLineDecoration({
|
|
418
|
+
side: "additions",
|
|
419
|
+
type,
|
|
420
|
+
lineIndex: additionLine?.lineIndex
|
|
421
|
+
});
|
|
374
422
|
if (deletionLineContent == null && additionLineContent == null) {
|
|
375
423
|
const errorMessage = "DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";
|
|
376
424
|
console.error(errorMessage, { file: fileDiff.name });
|
|
@@ -383,22 +431,33 @@ var DiffHunksRenderer = class {
|
|
|
383
431
|
}
|
|
384
432
|
})();
|
|
385
433
|
if (missingSide != null) {
|
|
386
|
-
if (
|
|
387
|
-
|
|
388
|
-
|
|
434
|
+
if (pendingSplitContext.side != null && pendingSplitContext.side !== missingSide) throw new Error("DiffHunksRenderer.processDiffResult: iterateOverDiff, invalid pending splits");
|
|
435
|
+
pendingSplitContext.side = missingSide;
|
|
436
|
+
pendingSplitContext.increment();
|
|
389
437
|
}
|
|
390
438
|
const annotationSpans = this.getAnnotations("split", deletionLine?.lineNumber, additionLine?.lineNumber, hunkIndex, lineIndex);
|
|
391
|
-
if (annotationSpans != null &&
|
|
392
|
-
if (deletionLine != null)
|
|
393
|
-
|
|
439
|
+
if (annotationSpans != null && pendingSplitContext.size > 0) pendingSplitContext.flush();
|
|
440
|
+
if (deletionLine != null) {
|
|
441
|
+
const deletionLineDecorated = withContentProperties(deletionLineContent, deletionLineDecoration.contentProperties);
|
|
442
|
+
pushGutterLineNumber("deletions", deletionLineDecoration.gutterLineType, deletionLine.lineNumber, `${deletionLine.unifiedLineIndex},${splitLineIndex}`, deletionLineDecoration.gutterProperties);
|
|
443
|
+
if (deletionLineDecorated != null) deletionLineContent = deletionLineDecorated;
|
|
444
|
+
}
|
|
445
|
+
if (additionLine != null) {
|
|
446
|
+
const additionLineDecorated = withContentProperties(additionLineContent, additionLineDecoration.contentProperties);
|
|
447
|
+
pushGutterLineNumber("additions", additionLineDecoration.gutterLineType, additionLine.lineNumber, `${additionLine.unifiedLineIndex},${splitLineIndex}`, additionLineDecoration.gutterProperties);
|
|
448
|
+
if (additionLineDecorated != null) additionLineContent = additionLineDecorated;
|
|
449
|
+
}
|
|
394
450
|
pushLineWithAnnotation({
|
|
395
451
|
diffStyle: "split",
|
|
396
452
|
type,
|
|
397
453
|
additionLine: additionLineContent,
|
|
398
454
|
deletionLine: deletionLineContent,
|
|
399
455
|
...annotationSpans,
|
|
456
|
+
createAnnotationElement: (span) => this.createAnnotationElement(span),
|
|
400
457
|
context
|
|
401
458
|
});
|
|
459
|
+
const inlineRows = this.getSplitInlineRowsForLine?.(renderedLineContext);
|
|
460
|
+
if (inlineRows != null) pushSplitInlineRows(inlineRows, context, pendingSplitContext);
|
|
402
461
|
}
|
|
403
462
|
const noEOFCRDeletion = deletionLine?.noEOFCR ?? false;
|
|
404
463
|
const noEOFCRAddition = additionLine?.noEOFCR ?? false;
|
|
@@ -445,7 +504,7 @@ var DiffHunksRenderer = class {
|
|
|
445
504
|
context.incrementRowCount(1);
|
|
446
505
|
}
|
|
447
506
|
});
|
|
448
|
-
if (diffStyle === "split")
|
|
507
|
+
if (diffStyle === "split") pendingSplitContext.flush();
|
|
449
508
|
const totalLines = Math.max(getTotalLineCountFromHunks(fileDiff.hunks), fileDiff.additionLines.length ?? 0, fileDiff.deletionLines.length ?? 0);
|
|
450
509
|
const hasBuffer = renderRange.bufferBefore > 0 || renderRange.bufferAfter > 0;
|
|
451
510
|
const shouldIncludeAdditions = !unified && fileDiff.type !== "deleted";
|
|
@@ -483,6 +542,7 @@ var DiffHunksRenderer = class {
|
|
|
483
542
|
return [gutter, createContentColumn(contentAST, result.rowCount)];
|
|
484
543
|
}
|
|
485
544
|
renderFullAST(result, children = []) {
|
|
545
|
+
const containerSize = this.getOptionsWithDefaults().hunkSeparators === "line-info";
|
|
486
546
|
const unifiedAST = this.renderCodeAST("unified", result);
|
|
487
547
|
if (unifiedAST != null) {
|
|
488
548
|
children.push(createHastElement({
|
|
@@ -490,6 +550,7 @@ var DiffHunksRenderer = class {
|
|
|
490
550
|
children: unifiedAST,
|
|
491
551
|
properties: {
|
|
492
552
|
"data-code": "",
|
|
553
|
+
"data-container-size": containerSize ? "" : void 0,
|
|
493
554
|
"data-unified": ""
|
|
494
555
|
}
|
|
495
556
|
}));
|
|
@@ -504,6 +565,7 @@ var DiffHunksRenderer = class {
|
|
|
504
565
|
children: deletionsAST,
|
|
505
566
|
properties: {
|
|
506
567
|
"data-code": "",
|
|
568
|
+
"data-container-size": containerSize ? "" : void 0,
|
|
507
569
|
"data-deletions": ""
|
|
508
570
|
}
|
|
509
571
|
}));
|
|
@@ -513,6 +575,7 @@ var DiffHunksRenderer = class {
|
|
|
513
575
|
children: additionsAST,
|
|
514
576
|
properties: {
|
|
515
577
|
"data-code": "",
|
|
578
|
+
"data-container-size": containerSize ? "" : void 0,
|
|
516
579
|
"data-additions": ""
|
|
517
580
|
}
|
|
518
581
|
}));
|
|
@@ -531,6 +594,7 @@ var DiffHunksRenderer = class {
|
|
|
531
594
|
children,
|
|
532
595
|
properties: {
|
|
533
596
|
"data-code": "",
|
|
597
|
+
"data-container-size": this.getOptionsWithDefaults().hunkSeparators === "line-info" ? "" : void 0,
|
|
534
598
|
[`data-${columnType}`]: ""
|
|
535
599
|
}
|
|
536
600
|
}));
|
|
@@ -575,14 +639,41 @@ function areRenderOptionsEqual(optionsA, optionsB) {
|
|
|
575
639
|
function getModifiedLinesString(lines) {
|
|
576
640
|
return `${lines} unmodified line${lines > 1 ? "s" : ""}`;
|
|
577
641
|
}
|
|
578
|
-
function
|
|
642
|
+
function pushUnifiedInlineRows(rows, context) {
|
|
643
|
+
for (const row of rows) {
|
|
644
|
+
context.unifiedContentAST.push(row.content);
|
|
645
|
+
context.pushToGutter("unified", row.gutter);
|
|
646
|
+
context.incrementRowCount(1);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
function pushSplitInlineRows(rows, context, pendingSplitContext) {
|
|
650
|
+
for (const { deletion, addition } of rows) {
|
|
651
|
+
if (deletion == null && addition == null) continue;
|
|
652
|
+
const missingSide = deletion != null && addition != null ? void 0 : deletion == null ? "deletions" : "additions";
|
|
653
|
+
if (missingSide == null || pendingSplitContext.side !== missingSide) pendingSplitContext.flush();
|
|
654
|
+
if (deletion != null) {
|
|
655
|
+
context.deletionsContentAST.push(deletion.content);
|
|
656
|
+
context.pushToGutter("deletions", deletion.gutter);
|
|
657
|
+
}
|
|
658
|
+
if (addition != null) {
|
|
659
|
+
context.additionsContentAST.push(addition.content);
|
|
660
|
+
context.pushToGutter("additions", addition.gutter);
|
|
661
|
+
}
|
|
662
|
+
if (missingSide != null) {
|
|
663
|
+
pendingSplitContext.side = missingSide;
|
|
664
|
+
pendingSplitContext.increment();
|
|
665
|
+
}
|
|
666
|
+
context.incrementRowCount(1);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
function pushLineWithAnnotation({ diffStyle, type, deletionLine, additionLine, unifiedSpan, deletionSpan, additionSpan, createAnnotationElement: createAnnotationElement$1, context }) {
|
|
579
670
|
let hasAnnotationRow = false;
|
|
580
671
|
if (diffStyle === "unified") {
|
|
581
672
|
if (additionLine != null) context.unifiedContentAST.push(additionLine);
|
|
582
673
|
else if (deletionLine != null) context.unifiedContentAST.push(deletionLine);
|
|
583
674
|
if (unifiedSpan != null) {
|
|
584
675
|
const lineType = type === "change" ? deletionLine != null ? "change-deletion" : "change-addition" : type;
|
|
585
|
-
context.unifiedContentAST.push(createAnnotationElement(unifiedSpan));
|
|
676
|
+
context.unifiedContentAST.push(createAnnotationElement$1(unifiedSpan));
|
|
586
677
|
context.pushToGutter("unified", createGutterGap(lineType, "annotation", 1));
|
|
587
678
|
hasAnnotationRow = true;
|
|
588
679
|
}
|
|
@@ -591,13 +682,13 @@ function pushLineWithAnnotation({ diffStyle, type, deletionLine, additionLine, u
|
|
|
591
682
|
if (additionLine != null) context.additionsContentAST.push(additionLine);
|
|
592
683
|
if (deletionSpan != null) {
|
|
593
684
|
const lineType = type === "change" ? deletionLine != null ? "change-deletion" : "context" : type;
|
|
594
|
-
context.deletionsContentAST.push(createAnnotationElement(deletionSpan));
|
|
685
|
+
context.deletionsContentAST.push(createAnnotationElement$1(deletionSpan));
|
|
595
686
|
context.pushToGutter("deletions", createGutterGap(lineType, "annotation", 1));
|
|
596
687
|
hasAnnotationRow = true;
|
|
597
688
|
}
|
|
598
689
|
if (additionSpan != null) {
|
|
599
690
|
const lineType = type === "change" ? additionLine != null ? "change-addition" : "context" : type;
|
|
600
|
-
context.additionsContentAST.push(createAnnotationElement(additionSpan));
|
|
691
|
+
context.additionsContentAST.push(createAnnotationElement$1(additionSpan));
|
|
601
692
|
context.pushToGutter("additions", createGutterGap(lineType, "annotation", 1));
|
|
602
693
|
hasAnnotationRow = true;
|
|
603
694
|
}
|
|
@@ -675,6 +766,16 @@ function pushSeparator(type, { hunkIndex, collapsedLines, rangeSize, hunkSpecs,
|
|
|
675
766
|
} : void 0
|
|
676
767
|
});
|
|
677
768
|
}
|
|
769
|
+
function withContentProperties(lineNode, contentProperties) {
|
|
770
|
+
if (lineNode == null || lineNode.type !== "element" || contentProperties == null) return lineNode;
|
|
771
|
+
return {
|
|
772
|
+
...lineNode,
|
|
773
|
+
properties: {
|
|
774
|
+
...lineNode.properties,
|
|
775
|
+
...contentProperties
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
}
|
|
678
779
|
function calculateTrailingRangeSize(fileDiff) {
|
|
679
780
|
const lastHunk = fileDiff.hunks.at(-1);
|
|
680
781
|
if (lastHunk == null || fileDiff.isPartial || fileDiff.additionLines.length === 0 || fileDiff.deletionLines.length === 0) return 0;
|