@pierre/diffs 1.1.0-beta.9 → 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.d.ts.map +1 -1
- 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 +145 -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,8 +66,7 @@ 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
|
|
@@ -98,8 +97,18 @@ var DiffHunksRenderer = class {
|
|
|
98
97
|
arr.push(annotation);
|
|
99
98
|
}
|
|
100
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
|
+
}
|
|
101
110
|
getOptionsWithDefaults() {
|
|
102
|
-
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;
|
|
103
112
|
return {
|
|
104
113
|
diffIndicators,
|
|
105
114
|
diffStyle,
|
|
@@ -107,6 +116,7 @@ var DiffHunksRenderer = class {
|
|
|
107
116
|
disableFileHeader,
|
|
108
117
|
disableLineNumbers,
|
|
109
118
|
disableVirtualizationBuffers,
|
|
119
|
+
collapsed,
|
|
110
120
|
expandUnchanged,
|
|
111
121
|
collapsedContextThreshold,
|
|
112
122
|
expansionLineCount,
|
|
@@ -215,7 +225,7 @@ var DiffHunksRenderer = class {
|
|
|
215
225
|
const { result } = await this.asyncHighlight(diff);
|
|
216
226
|
return this.processDiffResult(diff, renderRange, result);
|
|
217
227
|
}
|
|
218
|
-
createPreElement(split, totalLines, themeStyles, baseThemeType) {
|
|
228
|
+
createPreElement(split, totalLines, themeStyles, baseThemeType, customProperties) {
|
|
219
229
|
const { diffIndicators, disableBackground, disableLineNumbers, overflow, themeType } = this.getOptionsWithDefaults();
|
|
220
230
|
return createPreElement({
|
|
221
231
|
type: "diff",
|
|
@@ -226,7 +236,8 @@ var DiffHunksRenderer = class {
|
|
|
226
236
|
themeStyles,
|
|
227
237
|
split,
|
|
228
238
|
themeType: baseThemeType ?? themeType,
|
|
229
|
-
totalLines
|
|
239
|
+
totalLines,
|
|
240
|
+
customProperties
|
|
230
241
|
});
|
|
231
242
|
}
|
|
232
243
|
async asyncHighlight(diff) {
|
|
@@ -301,30 +312,35 @@ var DiffHunksRenderer = class {
|
|
|
301
312
|
}
|
|
302
313
|
};
|
|
303
314
|
const trailingRangeSize = calculateTrailingRangeSize(fileDiff);
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
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;
|
|
322
337
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
338
|
+
};
|
|
339
|
+
const pushGutterLineNumber = (type, lineType, lineNumber, lineIndex, gutterProperties) => {
|
|
340
|
+
context.pushToGutter(type, createGutterItem(lineType, lineNumber, lineIndex, gutterProperties));
|
|
341
|
+
};
|
|
326
342
|
function pushSeparators(props) {
|
|
327
|
-
|
|
343
|
+
pendingSplitContext.flush();
|
|
328
344
|
if (diffStyle === "unified") pushSeparator("unified", props, context);
|
|
329
345
|
else {
|
|
330
346
|
pushSeparator("deletions", props, context);
|
|
@@ -341,7 +357,7 @@ var DiffHunksRenderer = class {
|
|
|
341
357
|
callback: ({ hunkIndex, hunk, collapsedBefore, collapsedAfter, additionLine, deletionLine, type }) => {
|
|
342
358
|
const splitLineIndex = deletionLine != null ? deletionLine.splitLineIndex : additionLine.splitLineIndex;
|
|
343
359
|
const unifiedLineIndex = additionLine != null ? additionLine.unifiedLineIndex : deletionLine.unifiedLineIndex;
|
|
344
|
-
if (diffStyle === "split" && type !== "change")
|
|
360
|
+
if (diffStyle === "split" && type !== "change") pendingSplitContext.flush();
|
|
345
361
|
if (collapsedBefore > 0) pushSeparators({
|
|
346
362
|
hunkIndex,
|
|
347
363
|
collapsedLines: collapsedBefore,
|
|
@@ -352,26 +368,57 @@ var DiffHunksRenderer = class {
|
|
|
352
368
|
isExpandable: !fileDiff.isPartial
|
|
353
369
|
});
|
|
354
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
|
+
};
|
|
355
380
|
if (diffStyle === "unified") {
|
|
356
|
-
|
|
357
|
-
|
|
381
|
+
let deletionLineContent = deletionLine != null ? deletionLines[deletionLine.lineIndex] : void 0;
|
|
382
|
+
let additionLineContent = additionLine != null ? additionLines[additionLine.lineIndex] : void 0;
|
|
358
383
|
if (deletionLineContent == null && additionLineContent == null) {
|
|
359
384
|
const errorMessage = "DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";
|
|
360
385
|
console.error(errorMessage, { file: fileDiff.name });
|
|
361
386
|
throw new Error(errorMessage);
|
|
362
387
|
}
|
|
363
|
-
|
|
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);
|
|
364
398
|
pushLineWithAnnotation({
|
|
365
399
|
diffStyle: "unified",
|
|
366
400
|
type,
|
|
367
401
|
deletionLine: deletionLineContent,
|
|
368
402
|
additionLine: additionLineContent,
|
|
369
403
|
unifiedSpan: this.getAnnotations("unified", deletionLine?.lineNumber, additionLine?.lineNumber, hunkIndex, lineIndex),
|
|
404
|
+
createAnnotationElement: (span) => this.createAnnotationElement(span),
|
|
370
405
|
context
|
|
371
406
|
});
|
|
407
|
+
const inlineRows = this.getUnifiedInlineRowsForLine?.(renderedLineContext);
|
|
408
|
+
if (inlineRows != null) pushUnifiedInlineRows(inlineRows, context);
|
|
372
409
|
} else {
|
|
373
|
-
|
|
374
|
-
|
|
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
|
+
});
|
|
375
422
|
if (deletionLineContent == null && additionLineContent == null) {
|
|
376
423
|
const errorMessage = "DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";
|
|
377
424
|
console.error(errorMessage, { file: fileDiff.name });
|
|
@@ -384,22 +431,33 @@ var DiffHunksRenderer = class {
|
|
|
384
431
|
}
|
|
385
432
|
})();
|
|
386
433
|
if (missingSide != null) {
|
|
387
|
-
if (
|
|
388
|
-
|
|
389
|
-
|
|
434
|
+
if (pendingSplitContext.side != null && pendingSplitContext.side !== missingSide) throw new Error("DiffHunksRenderer.processDiffResult: iterateOverDiff, invalid pending splits");
|
|
435
|
+
pendingSplitContext.side = missingSide;
|
|
436
|
+
pendingSplitContext.increment();
|
|
390
437
|
}
|
|
391
438
|
const annotationSpans = this.getAnnotations("split", deletionLine?.lineNumber, additionLine?.lineNumber, hunkIndex, lineIndex);
|
|
392
|
-
if (annotationSpans != null &&
|
|
393
|
-
if (deletionLine != null)
|
|
394
|
-
|
|
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
|
+
}
|
|
395
450
|
pushLineWithAnnotation({
|
|
396
451
|
diffStyle: "split",
|
|
397
452
|
type,
|
|
398
453
|
additionLine: additionLineContent,
|
|
399
454
|
deletionLine: deletionLineContent,
|
|
400
455
|
...annotationSpans,
|
|
456
|
+
createAnnotationElement: (span) => this.createAnnotationElement(span),
|
|
401
457
|
context
|
|
402
458
|
});
|
|
459
|
+
const inlineRows = this.getSplitInlineRowsForLine?.(renderedLineContext);
|
|
460
|
+
if (inlineRows != null) pushSplitInlineRows(inlineRows, context, pendingSplitContext);
|
|
403
461
|
}
|
|
404
462
|
const noEOFCRDeletion = deletionLine?.noEOFCR ?? false;
|
|
405
463
|
const noEOFCRAddition = additionLine?.noEOFCR ?? false;
|
|
@@ -446,7 +504,7 @@ var DiffHunksRenderer = class {
|
|
|
446
504
|
context.incrementRowCount(1);
|
|
447
505
|
}
|
|
448
506
|
});
|
|
449
|
-
if (diffStyle === "split")
|
|
507
|
+
if (diffStyle === "split") pendingSplitContext.flush();
|
|
450
508
|
const totalLines = Math.max(getTotalLineCountFromHunks(fileDiff.hunks), fileDiff.additionLines.length ?? 0, fileDiff.deletionLines.length ?? 0);
|
|
451
509
|
const hasBuffer = renderRange.bufferBefore > 0 || renderRange.bufferAfter > 0;
|
|
452
510
|
const shouldIncludeAdditions = !unified && fileDiff.type !== "deleted";
|
|
@@ -484,6 +542,7 @@ var DiffHunksRenderer = class {
|
|
|
484
542
|
return [gutter, createContentColumn(contentAST, result.rowCount)];
|
|
485
543
|
}
|
|
486
544
|
renderFullAST(result, children = []) {
|
|
545
|
+
const containerSize = this.getOptionsWithDefaults().hunkSeparators === "line-info";
|
|
487
546
|
const unifiedAST = this.renderCodeAST("unified", result);
|
|
488
547
|
if (unifiedAST != null) {
|
|
489
548
|
children.push(createHastElement({
|
|
@@ -491,6 +550,7 @@ var DiffHunksRenderer = class {
|
|
|
491
550
|
children: unifiedAST,
|
|
492
551
|
properties: {
|
|
493
552
|
"data-code": "",
|
|
553
|
+
"data-container-size": containerSize ? "" : void 0,
|
|
494
554
|
"data-unified": ""
|
|
495
555
|
}
|
|
496
556
|
}));
|
|
@@ -505,6 +565,7 @@ var DiffHunksRenderer = class {
|
|
|
505
565
|
children: deletionsAST,
|
|
506
566
|
properties: {
|
|
507
567
|
"data-code": "",
|
|
568
|
+
"data-container-size": containerSize ? "" : void 0,
|
|
508
569
|
"data-deletions": ""
|
|
509
570
|
}
|
|
510
571
|
}));
|
|
@@ -514,6 +575,7 @@ var DiffHunksRenderer = class {
|
|
|
514
575
|
children: additionsAST,
|
|
515
576
|
properties: {
|
|
516
577
|
"data-code": "",
|
|
578
|
+
"data-container-size": containerSize ? "" : void 0,
|
|
517
579
|
"data-additions": ""
|
|
518
580
|
}
|
|
519
581
|
}));
|
|
@@ -532,6 +594,7 @@ var DiffHunksRenderer = class {
|
|
|
532
594
|
children,
|
|
533
595
|
properties: {
|
|
534
596
|
"data-code": "",
|
|
597
|
+
"data-container-size": this.getOptionsWithDefaults().hunkSeparators === "line-info" ? "" : void 0,
|
|
535
598
|
[`data-${columnType}`]: ""
|
|
536
599
|
}
|
|
537
600
|
}));
|
|
@@ -576,14 +639,41 @@ function areRenderOptionsEqual(optionsA, optionsB) {
|
|
|
576
639
|
function getModifiedLinesString(lines) {
|
|
577
640
|
return `${lines} unmodified line${lines > 1 ? "s" : ""}`;
|
|
578
641
|
}
|
|
579
|
-
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 }) {
|
|
580
670
|
let hasAnnotationRow = false;
|
|
581
671
|
if (diffStyle === "unified") {
|
|
582
672
|
if (additionLine != null) context.unifiedContentAST.push(additionLine);
|
|
583
673
|
else if (deletionLine != null) context.unifiedContentAST.push(deletionLine);
|
|
584
674
|
if (unifiedSpan != null) {
|
|
585
675
|
const lineType = type === "change" ? deletionLine != null ? "change-deletion" : "change-addition" : type;
|
|
586
|
-
context.unifiedContentAST.push(createAnnotationElement(unifiedSpan));
|
|
676
|
+
context.unifiedContentAST.push(createAnnotationElement$1(unifiedSpan));
|
|
587
677
|
context.pushToGutter("unified", createGutterGap(lineType, "annotation", 1));
|
|
588
678
|
hasAnnotationRow = true;
|
|
589
679
|
}
|
|
@@ -592,13 +682,13 @@ function pushLineWithAnnotation({ diffStyle, type, deletionLine, additionLine, u
|
|
|
592
682
|
if (additionLine != null) context.additionsContentAST.push(additionLine);
|
|
593
683
|
if (deletionSpan != null) {
|
|
594
684
|
const lineType = type === "change" ? deletionLine != null ? "change-deletion" : "context" : type;
|
|
595
|
-
context.deletionsContentAST.push(createAnnotationElement(deletionSpan));
|
|
685
|
+
context.deletionsContentAST.push(createAnnotationElement$1(deletionSpan));
|
|
596
686
|
context.pushToGutter("deletions", createGutterGap(lineType, "annotation", 1));
|
|
597
687
|
hasAnnotationRow = true;
|
|
598
688
|
}
|
|
599
689
|
if (additionSpan != null) {
|
|
600
690
|
const lineType = type === "change" ? additionLine != null ? "change-addition" : "context" : type;
|
|
601
|
-
context.additionsContentAST.push(createAnnotationElement(additionSpan));
|
|
691
|
+
context.additionsContentAST.push(createAnnotationElement$1(additionSpan));
|
|
602
692
|
context.pushToGutter("additions", createGutterGap(lineType, "annotation", 1));
|
|
603
693
|
hasAnnotationRow = true;
|
|
604
694
|
}
|
|
@@ -676,6 +766,16 @@ function pushSeparator(type, { hunkIndex, collapsedLines, rangeSize, hunkSpecs,
|
|
|
676
766
|
} : void 0
|
|
677
767
|
});
|
|
678
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
|
+
}
|
|
679
779
|
function calculateTrailingRangeSize(fileDiff) {
|
|
680
780
|
const lastHunk = fileDiff.hunks.at(-1);
|
|
681
781
|
if (lastHunk == null || fileDiff.isPartial || fileDiff.additionLines.length === 0 || fileDiff.deletionLines.length === 0) return 0;
|