@pierre/diffs 1.3.0-beta.6 → 1.3.0-beta.8
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 +90 -5
- package/dist/components/CodeView.d.ts.map +1 -1
- package/dist/components/CodeView.js +291 -38
- package/dist/components/CodeView.js.map +1 -1
- package/dist/components/File.d.ts +1 -0
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +20 -6
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +38 -23
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +144 -61
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/UnresolvedFile.d.ts +3 -2
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/UnresolvedFile.js +4 -2
- package/dist/components/UnresolvedFile.js.map +1 -1
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +6 -8
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +13 -5
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +192 -55
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/components/Virtualizer.d.ts +2 -0
- package/dist/components/Virtualizer.d.ts.map +1 -1
- package/dist/components/Virtualizer.js +16 -3
- 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 +3 -1
- package/dist/constants.js.map +1 -1
- package/dist/editor/command.d.ts +1 -1
- package/dist/editor/command.d.ts.map +1 -1
- package/dist/editor/command.js +8 -0
- package/dist/editor/command.js.map +1 -1
- package/dist/editor/editor.d.ts +10 -3
- package/dist/editor/editor.d.ts.map +1 -1
- package/dist/editor/editor.js +325 -135
- package/dist/editor/editor.js.map +1 -1
- package/dist/editor/editor2.js +1 -1
- package/dist/editor/lineAnnotations.d.ts.map +1 -1
- package/dist/editor/lineAnnotations.js +84 -12
- package/dist/editor/lineAnnotations.js.map +1 -1
- package/dist/editor/marker.d.ts +5 -3
- package/dist/editor/marker.d.ts.map +1 -1
- package/dist/editor/marker.js +35 -12
- package/dist/editor/marker.js.map +1 -1
- package/dist/editor/matchBrackets.d.ts +8 -0
- package/dist/editor/matchBrackets.d.ts.map +1 -0
- package/dist/editor/matchBrackets.js +146 -0
- package/dist/editor/matchBrackets.js.map +1 -0
- package/dist/editor/popover.d.ts +45 -0
- package/dist/editor/popover.d.ts.map +1 -0
- package/dist/editor/popover.js +145 -0
- package/dist/editor/popover.js.map +1 -0
- package/dist/editor/selection.d.ts +14 -2
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/selection.js +142 -41
- package/dist/editor/selection.js.map +1 -1
- package/dist/editor/selectionAction.d.ts +20 -3
- package/dist/editor/selectionAction.d.ts.map +1 -1
- package/dist/editor/selectionAction.js +41 -10
- package/dist/editor/selectionAction.js.map +1 -1
- package/dist/editor/textDocument.d.ts +2 -0
- package/dist/editor/textDocument.d.ts.map +1 -1
- package/dist/editor/textDocument.js +22 -6
- package/dist/editor/textDocument.js.map +1 -1
- package/dist/editor/textMeasure.d.ts.map +1 -1
- package/dist/editor/textMeasure.js +25 -7
- package/dist/editor/textMeasure.js.map +1 -1
- package/dist/editor/tokenzier.d.ts +6 -7
- package/dist/editor/tokenzier.d.ts.map +1 -1
- package/dist/editor/tokenzier.js +83 -34
- package/dist/editor/tokenzier.js.map +1 -1
- package/dist/editor/utils.d.ts +3 -1
- package/dist/editor/utils.d.ts.map +1 -1
- package/dist/editor/utils.js +14 -1
- package/dist/editor/utils.js.map +1 -1
- package/dist/index.d.ts +9 -7
- package/dist/index.js +6 -4
- package/dist/managers/InteractionManager.d.ts.map +1 -1
- package/dist/managers/InteractionManager.js +0 -1
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/managers/ResizeManager.d.ts +10 -2
- package/dist/managers/ResizeManager.d.ts.map +1 -1
- package/dist/managers/ResizeManager.js +33 -13
- package/dist/managers/ResizeManager.js.map +1 -1
- package/dist/react/CodeView.d.ts +25 -1
- package/dist/react/CodeView.d.ts.map +1 -1
- package/dist/react/CodeView.js +76 -17
- package/dist/react/CodeView.js.map +1 -1
- package/dist/react/EditorContext.d.ts +2 -2
- package/dist/react/EditorContext.d.ts.map +1 -1
- package/dist/react/EditorContext.js.map +1 -1
- package/dist/react/MultiFileDiff.d.ts +3 -4
- package/dist/react/MultiFileDiff.d.ts.map +1 -1
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/utils/useFileDiffInstance.js +14 -15
- package/dist/react/utils/useFileDiffInstance.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 +45 -23
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.d.ts +2 -1
- package/dist/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/renderers/FileRenderer.js +58 -38
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/preloadDiffs.d.ts +11 -10
- package/dist/ssr/preloadDiffs.d.ts.map +1 -1
- package/dist/ssr/preloadDiffs.js +14 -6
- package/dist/ssr/preloadDiffs.js.map +1 -1
- package/dist/types.d.ts +100 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/applyLineTextWithNewline.d.ts +5 -0
- package/dist/utils/applyLineTextWithNewline.d.ts.map +1 -0
- package/dist/utils/applyLineTextWithNewline.js +11 -0
- package/dist/utils/applyLineTextWithNewline.js.map +1 -0
- package/dist/utils/areHunkDataEqual.js +1 -1
- package/dist/utils/areHunkDataEqual.js.map +1 -1
- package/dist/utils/areManagedSnapshotsEqual.d.ts +2 -2
- package/dist/utils/areManagedSnapshotsEqual.d.ts.map +1 -1
- package/dist/utils/areManagedSnapshotsEqual.js +5 -0
- package/dist/utils/areManagedSnapshotsEqual.js.map +1 -1
- package/dist/utils/awaitWithTimeout.d.ts +5 -0
- package/dist/utils/awaitWithTimeout.d.ts.map +1 -0
- package/dist/utils/awaitWithTimeout.js +15 -0
- package/dist/utils/awaitWithTimeout.js.map +1 -0
- package/dist/utils/cloneFileDiffMetadata.d.ts +7 -0
- package/dist/utils/cloneFileDiffMetadata.d.ts.map +1 -0
- package/dist/utils/cloneFileDiffMetadata.js +16 -0
- package/dist/utils/cloneFileDiffMetadata.js.map +1 -0
- package/dist/utils/computeEstimatedDiffHeights.d.ts +3 -1
- package/dist/utils/computeEstimatedDiffHeights.d.ts.map +1 -1
- package/dist/utils/computeEstimatedDiffHeights.js +8 -1
- package/dist/utils/computeEstimatedDiffHeights.js.map +1 -1
- package/dist/utils/createCodeViewHeaderFooterHostElement.d.ts +5 -0
- package/dist/utils/createCodeViewHeaderFooterHostElement.d.ts.map +1 -0
- package/dist/utils/createCodeViewHeaderFooterHostElement.js +19 -0
- package/dist/utils/createCodeViewHeaderFooterHostElement.js.map +1 -0
- package/dist/utils/createPreElement.js +0 -1
- package/dist/utils/createPreElement.js.map +1 -1
- package/dist/utils/getDiffFileInput.d.ts +14 -0
- package/dist/utils/getDiffFileInput.d.ts.map +1 -0
- package/dist/utils/getDiffFileInput.js +24 -0
- package/dist/utils/getDiffFileInput.js.map +1 -0
- package/dist/utils/getDiffHunksRendererOptions.js +1 -0
- package/dist/utils/getDiffHunksRendererOptions.js.map +1 -1
- package/dist/utils/getFiletypeFromFileName.d.ts.map +1 -1
- package/dist/utils/getFiletypeFromFileName.js +2 -0
- package/dist/utils/getFiletypeFromFileName.js.map +1 -1
- package/dist/utils/hydratePartialDiff.d.ts +10 -0
- package/dist/utils/hydratePartialDiff.d.ts.map +1 -0
- package/dist/utils/hydratePartialDiff.js +140 -0
- package/dist/utils/hydratePartialDiff.js.map +1 -0
- package/dist/utils/iterateOverDiff.js +3 -3
- package/dist/utils/iterateOverDiff.js.map +1 -1
- package/dist/utils/parseDiffFromFile.d.ts +1 -1
- package/dist/utils/parseDiffFromFile.d.ts.map +1 -1
- package/dist/utils/parseDiffFromFile.js +26 -5
- package/dist/utils/parseDiffFromFile.js.map +1 -1
- package/dist/utils/setWrapperNodeProps.js +0 -1
- package/dist/utils/setWrapperNodeProps.js.map +1 -1
- package/dist/utils/updateDiffHunks.d.ts +5 -1
- package/dist/utils/updateDiffHunks.d.ts.map +1 -1
- package/dist/utils/updateDiffHunks.js +48 -4
- package/dist/utils/updateDiffHunks.js.map +1 -1
- package/dist/worker/WorkerPoolManager.d.ts +7 -2
- package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
- package/dist/worker/WorkerPoolManager.js +78 -15
- package/dist/worker/WorkerPoolManager.js.map +1 -1
- package/dist/worker/index.d.ts +2 -2
- package/dist/worker/types.d.ts +7 -1
- package/dist/worker/types.d.ts.map +1 -1
- package/dist/worker/worker-portable.js +5 -3
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +5 -3
- package/dist/worker/worker.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileDiff.d.ts","names":[],"sources":["../../src/components/FileDiff.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"FileDiff.d.ts","names":[],"sources":["../../src/components/FileDiff.ts"],"mappings":";;;;;;;;KAsFK,yBAAA,GAA4B,OAAA,CAC/B,UAAA,CAAW,WAAA,CAAY,eAAA;AAAA,UAYR,uBAAA;EACf,QAAA,GAAW,gBAAA;EACX,aAAA;EACA,OAAA;EACA,WAAA;EACA,WAAA;EACA,aAAA,GAAgB,WAAA;EAChB,gBAAA,GAAmB,WAAA;EACnB,eAAA,GAAkB,kBAAA,CAAmB,WAAA;EACrC,WAAA,GAAc,WAAA;AAAA;AAAA,KAGJ,mBAAA,gBACV,uBAAA,CAAwB,WAAA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sDA,uBAAA;EAAA,QA6BA,YAAA;EAAA,QAwBA,cAAA;EAAA,QA6KA,WAAA;EAAA,QA2DA,aAAA;EAAA,QAKA,gBAAA;EAAA,QAMA,cAAA;EAAA,UAuCE,aAAA,CAAc,WAAA,EAAa,WAAA;EAAA,QAM7B,YAAA;EAAA,UAkDE,kCAAA;EAAA,UAIA,sBAAA,CACR,GAAA,EAAK,cAAA;IACH,mBAAA;IAAqB,mBAAA;IAAqB;EAAA,GAAc,iBAAA,EAC1D,gBAAA,GAAmB,mBAAA;EAAA,QA6Bb,eAAA;EAAA,QAqBA,mBAAA;AAAA"}
|
|
@@ -18,6 +18,9 @@ import { upsertHostThemeStyle } from "../utils/hostTheme.js";
|
|
|
18
18
|
import { prerenderHTMLIfNecessary } from "../utils/prerenderHTMLIfNecessary.js";
|
|
19
19
|
import { setPreNodeProperties } from "../utils/setWrapperNodeProps.js";
|
|
20
20
|
import "./web-components.js";
|
|
21
|
+
import { awaitWithTimeout } from "../utils/awaitWithTimeout.js";
|
|
22
|
+
import { getDiffFileInput } from "../utils/getDiffFileInput.js";
|
|
23
|
+
import { hydratePartialDiff } from "../utils/hydratePartialDiff.js";
|
|
21
24
|
import { parseDiffFromFile } from "../utils/parseDiffFromFile.js";
|
|
22
25
|
import { ScrollSyncManager } from "../managers/ScrollSyncManager.js";
|
|
23
26
|
import { isDiffPlainText } from "../utils/isDiffPlainText.js";
|
|
@@ -27,6 +30,9 @@ import { areHunkDataEqual } from "../utils/areHunkDataEqual.js";
|
|
|
27
30
|
import { getDiffHunksRendererOptions } from "../utils/getDiffHunksRendererOptions.js";
|
|
28
31
|
import { toHtml } from "hast-util-to-html";
|
|
29
32
|
//#region src/components/FileDiff.ts
|
|
33
|
+
function canHydrateDiff(fileDiff) {
|
|
34
|
+
return fileDiff.isPartial && (fileDiff.type === "change" || fileDiff.type === "rename-changed" || fileDiff.type === "rename-pure");
|
|
35
|
+
}
|
|
30
36
|
let instanceId = -1;
|
|
31
37
|
var FileDiff = class {
|
|
32
38
|
options;
|
|
@@ -68,6 +74,7 @@ var FileDiff = class {
|
|
|
68
74
|
additionFile;
|
|
69
75
|
fileDiff;
|
|
70
76
|
renderRange;
|
|
77
|
+
pendingFiles;
|
|
71
78
|
appliedPreAttributes;
|
|
72
79
|
lastRenderedHeaderHTML;
|
|
73
80
|
cachedHeaderHTML;
|
|
@@ -75,7 +82,8 @@ var FileDiff = class {
|
|
|
75
82
|
mounted = false;
|
|
76
83
|
enabled = true;
|
|
77
84
|
editor;
|
|
78
|
-
|
|
85
|
+
refreshViewTimeout;
|
|
86
|
+
deferSetSelection;
|
|
79
87
|
constructor(options = { theme: DEFAULT_THEMES }, workerManager, isContainerManaged = false) {
|
|
80
88
|
this.options = options;
|
|
81
89
|
this.workerManager = workerManager;
|
|
@@ -97,7 +105,7 @@ var FileDiff = class {
|
|
|
97
105
|
return new DiffHunksRenderer(this.getHunksRendererOptions(options), this.handleHighlightRender, this.workerManager);
|
|
98
106
|
}
|
|
99
107
|
getLineIndex = (lineNumber, side = "additions") => {
|
|
100
|
-
const fileDiff = this.
|
|
108
|
+
const fileDiff = this.fileDiffCache;
|
|
101
109
|
if (fileDiff == null) return;
|
|
102
110
|
const lastHunk = fileDiff.hunks.at(-1);
|
|
103
111
|
let targetUnifiedIndex;
|
|
@@ -192,7 +200,8 @@ var FileDiff = class {
|
|
|
192
200
|
return true;
|
|
193
201
|
}
|
|
194
202
|
setSelectedLines(range, options) {
|
|
195
|
-
this.
|
|
203
|
+
if (this.refreshViewTimeout != null) this.deferSetSelection = [range, options];
|
|
204
|
+
else this.interactionManager.setSelection(range, options);
|
|
196
205
|
}
|
|
197
206
|
flushManagers() {
|
|
198
207
|
if (!this.managersDirty || this.pre == null) {
|
|
@@ -201,11 +210,18 @@ var FileDiff = class {
|
|
|
201
210
|
}
|
|
202
211
|
const { diffStyle = "split", overflow = "scroll" } = this.options;
|
|
203
212
|
this.interactionManager.setup(this.pre);
|
|
204
|
-
this.resizeManager.setup(this.pre,
|
|
213
|
+
this.resizeManager.setup(this.pre, {
|
|
214
|
+
disableAnnotations: overflow === "wrap",
|
|
215
|
+
columnVariables: this.shouldApplyColumnVariables(overflow) ? "apply" : "measure"
|
|
216
|
+
});
|
|
205
217
|
if (overflow === "scroll" && diffStyle === "split") this.scrollSyncManager.setup(this.pre, this.codeDeletions, this.codeAdditions);
|
|
206
218
|
else this.scrollSyncManager.cleanUp();
|
|
207
219
|
this.managersDirty = false;
|
|
208
220
|
}
|
|
221
|
+
shouldApplyColumnVariables(overflow) {
|
|
222
|
+
if (typeof this.options.hunkSeparators === "function") return true;
|
|
223
|
+
return overflow === "scroll" && (this.lineAnnotations.length > 0 || this.pre?.hasAttribute("data-has-merge-conflict") === true);
|
|
224
|
+
}
|
|
209
225
|
cleanUp(recycle = false) {
|
|
210
226
|
this.emitPostRender(true);
|
|
211
227
|
this.resizeManager.cleanUp();
|
|
@@ -214,6 +230,7 @@ var FileDiff = class {
|
|
|
214
230
|
this.managersDirty = false;
|
|
215
231
|
this.workerManager?.unsubscribeToThemeChanges(this);
|
|
216
232
|
this.renderRange = void 0;
|
|
233
|
+
this.pendingFiles = void 0;
|
|
217
234
|
if (!this.isContainerManaged) this.fileContainer?.remove();
|
|
218
235
|
this.fileContainer = void 0;
|
|
219
236
|
this.mounted = false;
|
|
@@ -234,9 +251,11 @@ var FileDiff = class {
|
|
|
234
251
|
this.headerFilenameSuffix = void 0;
|
|
235
252
|
this.headerMetadata = void 0;
|
|
236
253
|
this.headerCustom = void 0;
|
|
254
|
+
this.placeHolder?.remove();
|
|
237
255
|
this.placeHolder = void 0;
|
|
238
256
|
this.lastRenderedHeaderHTML = void 0;
|
|
239
257
|
if (!recycle) this.cachedHeaderHTML = void 0;
|
|
258
|
+
this.errorWrapper?.remove();
|
|
240
259
|
this.errorWrapper = void 0;
|
|
241
260
|
this.spriteSVG = void 0;
|
|
242
261
|
this.lastRowCount = void 0;
|
|
@@ -254,19 +273,23 @@ var FileDiff = class {
|
|
|
254
273
|
this.additionFile = void 0;
|
|
255
274
|
}
|
|
256
275
|
this.enabled = false;
|
|
257
|
-
this.editor?.cleanUp();
|
|
276
|
+
this.editor?.cleanUp(recycle);
|
|
258
277
|
this.editor = void 0;
|
|
259
|
-
if (this.
|
|
260
|
-
clearTimeout(this.
|
|
261
|
-
this.
|
|
278
|
+
if (this.refreshViewTimeout != null) {
|
|
279
|
+
clearTimeout(this.refreshViewTimeout);
|
|
280
|
+
this.refreshViewTimeout = void 0;
|
|
262
281
|
}
|
|
263
282
|
}
|
|
264
283
|
virtualizedSetup() {
|
|
265
284
|
this.enabled = true;
|
|
266
285
|
this.workerManager?.subscribeToThemeChanges(this);
|
|
267
286
|
}
|
|
268
|
-
hydrate(
|
|
269
|
-
|
|
287
|
+
hydrate({ fileContainer, prerenderedHTML, preventEmit = false, lineAnnotations, fileDiff, ...fileInputProps }) {
|
|
288
|
+
if (!this.enabled) throw new Error("FileDiff.hydrate: attempting to call hydrate after cleaned up");
|
|
289
|
+
if (this.fileContainer != null) throw new Error("FileDiff.hydrate: hydrate can only be called before the instance has rendered or hydrated");
|
|
290
|
+
const fileInput = getDiffFileInput(fileInputProps, "FileDiff.hydrate");
|
|
291
|
+
const oldFile = fileInput?.oldFile;
|
|
292
|
+
const newFile = fileInput?.newFile;
|
|
270
293
|
this.hydrateElements(fileContainer, prerenderedHTML);
|
|
271
294
|
if (shouldRenderCode(this.pre, hasDiffContent({
|
|
272
295
|
fileDiff,
|
|
@@ -277,14 +300,16 @@ var FileDiff = class {
|
|
|
277
300
|
oldFile,
|
|
278
301
|
newFile
|
|
279
302
|
}), this.options.disableFileHeader)) this.render({
|
|
280
|
-
...
|
|
303
|
+
...fileInputProps,
|
|
304
|
+
fileContainer,
|
|
305
|
+
lineAnnotations,
|
|
306
|
+
fileDiff,
|
|
281
307
|
preventEmit: true
|
|
282
308
|
});
|
|
283
309
|
else this.hydrationSetup({
|
|
284
310
|
fileDiff,
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
lineAnnotations
|
|
311
|
+
lineAnnotations,
|
|
312
|
+
...fileInput
|
|
288
313
|
});
|
|
289
314
|
if (!preventEmit) this.emitPostRender();
|
|
290
315
|
}
|
|
@@ -332,7 +357,7 @@ var FileDiff = class {
|
|
|
332
357
|
this.lineAnnotations = lineAnnotations ?? this.lineAnnotations;
|
|
333
358
|
this.additionFile = newFile;
|
|
334
359
|
this.deletionFile = oldFile;
|
|
335
|
-
this.fileDiff = fileDiff ?? (oldFile
|
|
360
|
+
this.fileDiff = fileDiff ?? (oldFile !== void 0 && newFile !== void 0 ? parseDiffFromFile(oldFile, newFile, this.options.parseDiffOptions) : void 0);
|
|
336
361
|
if (this.pre == null) return;
|
|
337
362
|
this.syncInteractionOptions();
|
|
338
363
|
this.hunksRenderer.hydrate(this.fileDiff);
|
|
@@ -358,30 +383,73 @@ var FileDiff = class {
|
|
|
358
383
|
};
|
|
359
384
|
expandHunk = (hunkIndex, direction, expansionLineCountOverride) => {
|
|
360
385
|
this.hunksRenderer.expandHunk(hunkIndex, direction, expansionLineCountOverride);
|
|
386
|
+
this.loadFilesIfNecessary();
|
|
361
387
|
this.rerender();
|
|
362
388
|
};
|
|
363
|
-
|
|
389
|
+
loadFilesIfNecessary() {
|
|
390
|
+
const { fileDiff, options: { loadDiffFiles } } = this;
|
|
391
|
+
if (fileDiff == null || loadDiffFiles == null || !canHydrateDiff(fileDiff) || this.pendingFiles?.fileDiff === fileDiff) return;
|
|
392
|
+
this.pendingFiles = {
|
|
393
|
+
fileDiff,
|
|
394
|
+
promise: this.loadFilesForDiff(fileDiff, loadDiffFiles)
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
async loadFilesForDiff(fileDiff, loadDiffFiles) {
|
|
398
|
+
try {
|
|
399
|
+
const files = await loadDiffFiles(fileDiff);
|
|
400
|
+
if (!this.enabled || this.fileDiff !== fileDiff) return;
|
|
401
|
+
await this.handleFilesLoaded(fileDiff, files);
|
|
402
|
+
} catch (error) {
|
|
403
|
+
if (this.options.disableErrorHandling === true) throw error;
|
|
404
|
+
console.error(error);
|
|
405
|
+
} finally {
|
|
406
|
+
if (this.pendingFiles?.fileDiff === fileDiff) this.pendingFiles = void 0;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
async handleFilesLoaded(expectedDiff, files) {
|
|
410
|
+
if (this.fileDiff !== expectedDiff || !expectedDiff.isPartial) return;
|
|
411
|
+
hydratePartialDiff("merge", expectedDiff, files);
|
|
412
|
+
this.setHydratedState(files);
|
|
413
|
+
await awaitWithTimeout(() => this.primeHighlightCache(expectedDiff));
|
|
414
|
+
if (!this.enabled || this.fileDiff !== expectedDiff) return;
|
|
415
|
+
this.rerender();
|
|
416
|
+
}
|
|
417
|
+
setHydratedState(files) {
|
|
418
|
+
this.deletionFile = files.oldFile;
|
|
419
|
+
this.additionFile = files.newFile;
|
|
420
|
+
this.workerManager?.cleanUpTasks(this.hunksRenderer);
|
|
421
|
+
this.hunksRenderer.clearRenderCache();
|
|
422
|
+
}
|
|
423
|
+
render({ fileDiff, deferManagers = false, forceRender = false, preventEmit = false, lineAnnotations, fileContainer, containerWrapper, renderRange, ...fileInputProps }) {
|
|
424
|
+
const fileInput = getDiffFileInput(fileInputProps, "FileDiff.render");
|
|
425
|
+
const oldFile = fileInput?.oldFile;
|
|
426
|
+
const newFile = fileInput?.newFile;
|
|
364
427
|
if (!this.enabled) throw new Error("FileDiff.render: attempting to call render after cleaned up");
|
|
365
|
-
|
|
366
|
-
|
|
428
|
+
if (fileDiff != null && fileDiff.cacheKey === void 0) fileDiff.cacheKey = fileDiff.prevName != null ? fileDiff.prevName + ":" + fileDiff.name : fileDiff.name;
|
|
429
|
+
this.editor?.__postponeBgTokenizeToNextFrame();
|
|
430
|
+
const { collapsed = false, themeType = "system", expandUnchanged = false } = this.options;
|
|
367
431
|
const nextRenderRange = collapsed ? void 0 : renderRange;
|
|
368
432
|
const themeChanged = this.hasThemeChanged();
|
|
369
|
-
const
|
|
433
|
+
const hasFileInput = fileInput != null;
|
|
434
|
+
const filesDidChange = hasFileInput && (!areOptionalFilesEqual(oldFile, this.deletionFile) || !areOptionalFilesEqual(newFile, this.additionFile));
|
|
370
435
|
let diffDidChange = fileDiff != null && fileDiff !== this.fileDiff;
|
|
371
436
|
const annotationsChanged = lineAnnotations != null && (lineAnnotations.length > 0 || this.lineAnnotations.length > 0) ? lineAnnotations !== this.lineAnnotations : false;
|
|
372
437
|
if (!collapsed && areRenderRangesEqual(nextRenderRange, this.renderRange) && !forceRender && !annotationsChanged && !themeChanged && (fileDiff != null && fileDiff === this.fileDiff || fileDiff == null && !filesDidChange)) return this.applyCachedThemeState(themeType);
|
|
438
|
+
let nextParsedFileDiff;
|
|
439
|
+
if (fileDiff == null && hasFileInput && (filesDidChange || this.fileDiff == null)) nextParsedFileDiff = parseDiffFromFile(fileInput.oldFile, fileInput.newFile, this.options.parseDiffOptions);
|
|
373
440
|
const { renderRange: previousRenderRange } = this;
|
|
374
441
|
this.renderRange = nextRenderRange;
|
|
375
442
|
this.deletionFile = oldFile;
|
|
376
443
|
this.additionFile = newFile;
|
|
377
444
|
if (fileDiff != null) this.fileDiff = fileDiff;
|
|
378
|
-
else if (
|
|
445
|
+
else if (nextParsedFileDiff != null) {
|
|
379
446
|
diffDidChange = true;
|
|
380
|
-
this.fileDiff =
|
|
447
|
+
this.fileDiff = nextParsedFileDiff;
|
|
381
448
|
}
|
|
382
449
|
if (diffDidChange) this.cachedHeaderHTML = void 0;
|
|
383
450
|
if (lineAnnotations != null) this.setLineAnnotations(lineAnnotations);
|
|
384
451
|
if (this.fileDiff == null) return false;
|
|
452
|
+
if (expandUnchanged) this.loadFilesIfNecessary();
|
|
385
453
|
this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options));
|
|
386
454
|
this.syncInteractionOptions();
|
|
387
455
|
this.hunksRenderer.setLineAnnotations(this.lineAnnotations);
|
|
@@ -462,12 +530,18 @@ var FileDiff = class {
|
|
|
462
530
|
this.mounted = true;
|
|
463
531
|
onPostRender?.(fileContainer, this, phase);
|
|
464
532
|
}
|
|
533
|
+
get fileDiffCache() {
|
|
534
|
+
return this.hunksRenderer.diffCache ?? this.fileDiff;
|
|
535
|
+
}
|
|
465
536
|
syncRenderViewToEditor() {
|
|
466
537
|
const editor = this.editor;
|
|
467
538
|
const fileContainer = this.fileContainer;
|
|
468
|
-
const fileDiff = this.
|
|
539
|
+
const fileDiff = this.fileDiffCache;
|
|
540
|
+
const lineAnnotations = this.lineAnnotations;
|
|
541
|
+
const renderRange = this.renderRange;
|
|
469
542
|
if (editor != null && fileContainer != null && fileDiff != null && !fileDiff.isPartial) this.hunksRenderer.initializeHighlighter().then((highlighter) => {
|
|
470
|
-
editor.
|
|
543
|
+
if (!this.enabled || this.editor !== editor || this.fileContainer !== fileContainer || this.fileDiffCache !== fileDiff) return;
|
|
544
|
+
editor.__syncRenderView(highlighter, fileContainer, fileDiff, lineAnnotations, renderRange);
|
|
471
545
|
});
|
|
472
546
|
}
|
|
473
547
|
attachEditor(editor) {
|
|
@@ -482,32 +556,34 @@ var FileDiff = class {
|
|
|
482
556
|
}
|
|
483
557
|
applyDocumentChange(textDocument, newLineAnnotations) {
|
|
484
558
|
this.hunksRenderer.applyDocumentChange(textDocument);
|
|
485
|
-
const
|
|
486
|
-
if (
|
|
487
|
-
|
|
488
|
-
|
|
559
|
+
const fileDiff = this.hunksRenderer.diffCache;
|
|
560
|
+
if (fileDiff != null) {
|
|
561
|
+
const cacheKey = this.fileDiff?.cacheKey;
|
|
562
|
+
if (cacheKey != null && fileDiff.cacheKey == null) fileDiff.cacheKey = cacheKey;
|
|
563
|
+
this.fileDiff = fileDiff;
|
|
564
|
+
}
|
|
489
565
|
if (newLineAnnotations !== void 0 && newLineAnnotations !== this.lineAnnotations) {
|
|
490
566
|
this.setLineAnnotations(newLineAnnotations);
|
|
491
567
|
this.hunksRenderer.setLineAnnotations(this.lineAnnotations);
|
|
492
568
|
this.renderAnnotations();
|
|
493
569
|
}
|
|
494
|
-
}
|
|
495
|
-
rerenderFromDocument(textDocument) {
|
|
496
|
-
this.hunksRenderer.applyDocumentChange(textDocument);
|
|
497
|
-
const renderDiff = this.hunksRenderer.getRenderDiff();
|
|
498
|
-
if (renderDiff != null) this.fileDiff = renderDiff;
|
|
499
|
-
this.hunksRenderer.clearRenderCache();
|
|
500
570
|
this.rerender();
|
|
571
|
+
this.interactionManager.setSelectionDirty();
|
|
501
572
|
}
|
|
502
|
-
updateRenderCache(dirtyLines, themeType, shouldRefreshView
|
|
503
|
-
this.hunksRenderer.updateRenderCache(dirtyLines, themeType
|
|
504
|
-
if (shouldRefreshView
|
|
505
|
-
if (this.
|
|
506
|
-
this.
|
|
507
|
-
this.
|
|
508
|
-
this.
|
|
509
|
-
|
|
510
|
-
|
|
573
|
+
updateRenderCache(dirtyLines, themeType, shouldRefreshView) {
|
|
574
|
+
this.hunksRenderer.updateRenderCache(dirtyLines, themeType);
|
|
575
|
+
if (shouldRefreshView) {
|
|
576
|
+
if (this.refreshViewTimeout != null) clearTimeout(this.refreshViewTimeout);
|
|
577
|
+
this.refreshViewTimeout = setTimeout(() => {
|
|
578
|
+
this.refreshViewTimeout = void 0;
|
|
579
|
+
if (this.options.diffStyle === "split") this.refreshSplitDiffView();
|
|
580
|
+
else this.refreshUnifiedDiffView();
|
|
581
|
+
if (this.deferSetSelection != null) {
|
|
582
|
+
this.interactionManager.setSelection(...this.deferSetSelection);
|
|
583
|
+
this.deferSetSelection = void 0;
|
|
584
|
+
}
|
|
585
|
+
}, 150);
|
|
586
|
+
}
|
|
511
587
|
}
|
|
512
588
|
removeRenderedCode() {
|
|
513
589
|
this.resizeManager.cleanUp();
|
|
@@ -549,12 +625,14 @@ var FileDiff = class {
|
|
|
549
625
|
this.placeHolder.style.setProperty("height", `${height}px`);
|
|
550
626
|
return true;
|
|
551
627
|
}
|
|
552
|
-
primeHighlightCache() {
|
|
553
|
-
const {
|
|
554
|
-
if (fileDiff == null || workerManager == null || isDiffPlainText(fileDiff)) return;
|
|
628
|
+
async primeHighlightCache(fileDiff = this.fileDiff) {
|
|
629
|
+
const { workerManager } = this;
|
|
630
|
+
if (fileDiff == null || workerManager == null || !workerManager.isWorkingPool() || fileDiff.cacheKey == null || isDiffPlainText(fileDiff)) return;
|
|
555
631
|
const tokenizeMaxLength = this.options.tokenizeMaxLength ?? 1e5;
|
|
556
632
|
if (Math.max(fileDiff.additionLines.length, fileDiff.deletionLines.length) > tokenizeMaxLength) return;
|
|
557
|
-
workerManager.primeDiffHighlightCache(fileDiff)
|
|
633
|
+
await workerManager.primeDiffHighlightCache(fileDiff).catch((error) => {
|
|
634
|
+
console.error(error);
|
|
635
|
+
});
|
|
558
636
|
}
|
|
559
637
|
cleanChildNodes() {
|
|
560
638
|
this.resizeManager.cleanUp();
|
|
@@ -1006,7 +1084,7 @@ var FileDiff = class {
|
|
|
1006
1084
|
this.renderPartialColumn(columns[1], additionsAST, insertPosition);
|
|
1007
1085
|
} else throw new Error("FileDiff.insertPartialHTML: Invalid argument composition");
|
|
1008
1086
|
}
|
|
1009
|
-
|
|
1087
|
+
refreshSplitDiffView() {
|
|
1010
1088
|
if (this.options.diffStyle !== "split") return;
|
|
1011
1089
|
const hunksResult = this.hunksRenderer.renderDiff(this.fileDiff, this.renderRange);
|
|
1012
1090
|
if (hunksResult == null) return;
|
|
@@ -1026,22 +1104,23 @@ var FileDiff = class {
|
|
|
1026
1104
|
applyLineType("deletions", columns[0]);
|
|
1027
1105
|
applyLineType("additions", columns[1]);
|
|
1028
1106
|
}
|
|
1029
|
-
|
|
1107
|
+
refreshUnifiedDiffView() {
|
|
1108
|
+
if (this.options.diffStyle !== "unified") return;
|
|
1030
1109
|
const hunksResult = this.hunksRenderer.renderDiff(this.fileDiff, this.renderRange);
|
|
1031
1110
|
if (hunksResult == null) return;
|
|
1032
|
-
const columns = this.getCodeColumns(
|
|
1033
|
-
if (columns == null) return;
|
|
1034
|
-
const
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1111
|
+
const columns = this.getCodeColumns("unified", this.codeUnified, this.codeDeletions, this.codeAdditions);
|
|
1112
|
+
if (columns == null || Array.isArray(columns)) return;
|
|
1113
|
+
const ast = this.hunksRenderer.renderCodeAST("unified", hunksResult);
|
|
1114
|
+
const gutterChildren = getElementChildren(ast?.[0]);
|
|
1115
|
+
const contentChildren = getElementChildren(ast?.[1]);
|
|
1116
|
+
for (const [el, astChildren] of [[columns.gutter, gutterChildren], [columns.content, contentChildren]]) if (astChildren != null) el.innerHTML = toHtml(astChildren);
|
|
1117
|
+
if (hunksResult.rowCount !== this.lastRowCount) {
|
|
1118
|
+
this.applyRowSpan("unified", columns, hunksResult.rowCount);
|
|
1119
|
+
this.lastRowCount = hunksResult.rowCount;
|
|
1120
|
+
}
|
|
1121
|
+
this.renderSeparators(hunksResult.hunkData);
|
|
1122
|
+
this.managersDirty = true;
|
|
1123
|
+
this.flushManagers();
|
|
1045
1124
|
this.syncRenderViewToEditor();
|
|
1046
1125
|
}
|
|
1047
1126
|
renderPartialColumn(column, ast, insertPosition) {
|
|
@@ -1326,6 +1405,10 @@ var FileDiff = class {
|
|
|
1326
1405
|
this.errorWrapper = void 0;
|
|
1327
1406
|
}
|
|
1328
1407
|
};
|
|
1408
|
+
function areOptionalFilesEqual(fileA, fileB) {
|
|
1409
|
+
if (fileA == null || fileB == null) return fileA == null && fileB == null;
|
|
1410
|
+
return areFilesEqual(fileA, fileB);
|
|
1411
|
+
}
|
|
1329
1412
|
function hasDiffContent({ fileDiff, oldFile, newFile }) {
|
|
1330
1413
|
return fileDiff != null && fileDiff.hunks.length > 0 || oldFile != null || newFile != null;
|
|
1331
1414
|
}
|