@pierre/diffs 1.3.6 → 1.4.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/dist/components/CodeView.d.ts +113 -68
- package/dist/components/CodeView.d.ts.map +1 -1
- package/dist/components/CodeView.js +153 -58
- package/dist/components/CodeView.js.map +1 -1
- package/dist/components/File.d.ts +75 -15
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +223 -62
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +97 -21
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +400 -100
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/UnresolvedFile.d.ts +2 -2
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/UnresolvedFile.js +2 -2
- package/dist/components/UnresolvedFile.js.map +1 -1
- package/dist/components/VirtualizedFile.d.ts +16 -7
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +140 -51
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +14 -8
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +183 -93
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/components/VirtulizerDevelopment.d.ts +1 -1
- package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
- package/dist/edit/index.d.ts +7 -4
- package/dist/edit/index.js +5 -1
- package/dist/editor/EditStateManager.d.ts +56 -0
- package/dist/editor/EditStateManager.d.ts.map +1 -0
- package/dist/editor/EditStateManager.js +135 -0
- package/dist/editor/EditStateManager.js.map +1 -0
- package/dist/editor/cloneRetainedDiffSessionSnapshot.d.ts +7 -0
- package/dist/editor/cloneRetainedDiffSessionSnapshot.d.ts.map +1 -0
- package/dist/editor/cloneRetainedDiffSessionSnapshot.js +16 -0
- package/dist/editor/cloneRetainedDiffSessionSnapshot.js.map +1 -0
- package/dist/editor/editPrediction.d.ts +76 -0
- package/dist/editor/editPrediction.d.ts.map +1 -0
- package/dist/editor/editPrediction.js +365 -0
- package/dist/editor/editPrediction.js.map +1 -0
- package/dist/editor/editStack.d.ts +19 -40
- package/dist/editor/editStack.d.ts.map +1 -1
- package/dist/editor/editStack.js +67 -4
- package/dist/editor/editStack.js.map +1 -1
- package/dist/editor/editor.d.ts +118 -29
- package/dist/editor/editor.d.ts.map +1 -1
- package/dist/editor/editor.js +1103 -383
- package/dist/editor/editor.js.map +1 -1
- package/dist/editor/editor2.js +1 -1
- package/dist/editor/languages.d.ts +3 -3
- package/dist/editor/languages.d.ts.map +1 -1
- package/dist/editor/languages.js.map +1 -1
- package/dist/editor/lineAnnotations.d.ts +3 -3
- package/dist/editor/lineAnnotations.d.ts.map +1 -1
- package/dist/editor/lineAnnotations.js +16 -7
- package/dist/editor/lineAnnotations.js.map +1 -1
- package/dist/editor/marker.d.ts +2 -2
- package/dist/editor/marker.d.ts.map +1 -1
- package/dist/editor/marker.js.map +1 -1
- package/dist/editor/matchBrackets.d.ts +2 -2
- package/dist/editor/matchBrackets.d.ts.map +1 -1
- package/dist/editor/matchBrackets.js.map +1 -1
- package/dist/editor/pieceTable.d.ts +1 -1
- package/dist/editor/pieceTable.js.map +1 -1
- package/dist/editor/searchPanel.d.ts +2 -2
- package/dist/editor/searchPanel.js +1 -1
- package/dist/editor/searchPanel.js.map +1 -1
- package/dist/editor/selection.d.ts +32 -23
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/selection.js +3 -3
- package/dist/editor/selection.js.map +1 -1
- package/dist/editor/selectionAction.d.ts +3 -3
- package/dist/editor/selectionAction.d.ts.map +1 -1
- package/dist/editor/selectionAction.js.map +1 -1
- package/dist/editor/textDocument.d.ts +11 -8
- package/dist/editor/textDocument.d.ts.map +1 -1
- package/dist/editor/textDocument.js +28 -5
- package/dist/editor/textDocument.js.map +1 -1
- package/dist/editor/textDocumentChangeTransaction.d.ts +15 -0
- package/dist/editor/textDocumentChangeTransaction.d.ts.map +1 -0
- package/dist/editor/textDocumentChangeTransaction.js +12 -0
- package/dist/editor/textDocumentChangeTransaction.js.map +1 -0
- package/dist/editor/textMeasure.d.ts +5 -0
- package/dist/editor/textMeasure.d.ts.map +1 -1
- package/dist/editor/textMeasure.js +10 -0
- package/dist/editor/textMeasure.js.map +1 -1
- package/dist/editor/tokenizer.d.ts +1 -1
- package/dist/editor/tokenizer.js.map +1 -1
- package/dist/editor/types.d.ts +267 -0
- package/dist/editor/types.d.ts.map +1 -0
- package/dist/editor/types.js +0 -0
- package/dist/editor/utils.d.ts +2 -1
- package/dist/editor/utils.d.ts.map +1 -1
- package/dist/editor/utils.js +4 -1
- package/dist/editor/utils.js.map +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.js +9 -8
- package/dist/managers/InteractionManager.d.ts.map +1 -1
- package/dist/managers/InteractionManager.js +7 -0
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/react/CodeView.d.ts +36 -25
- package/dist/react/CodeView.d.ts.map +1 -1
- package/dist/react/CodeView.js +15 -14
- package/dist/react/CodeView.js.map +1 -1
- package/dist/react/EditContext.d.ts +8 -11
- package/dist/react/EditContext.d.ts.map +1 -1
- package/dist/react/EditContext.js +2 -9
- package/dist/react/EditContext.js.map +1 -1
- package/dist/react/File.d.ts +10 -6
- package/dist/react/File.d.ts.map +1 -1
- package/dist/react/File.js +8 -4
- package/dist/react/File.js.map +1 -1
- package/dist/react/FileDiff.d.ts +10 -5
- package/dist/react/FileDiff.d.ts.map +1 -1
- package/dist/react/FileDiff.js +8 -4
- package/dist/react/FileDiff.js.map +1 -1
- package/dist/react/MultiFileDiff.d.ts +8 -5
- package/dist/react/MultiFileDiff.d.ts.map +1 -1
- package/dist/react/MultiFileDiff.js +8 -12
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/PatchDiff.d.ts +7 -4
- package/dist/react/PatchDiff.d.ts.map +1 -1
- package/dist/react/PatchDiff.js +8 -4
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/UnresolvedFile.d.ts +3 -3
- package/dist/react/UnresolvedFile.d.ts.map +1 -1
- package/dist/react/UnresolvedFile.js.map +1 -1
- package/dist/react/index.d.ts +8 -5
- package/dist/react/types.d.ts +46 -9
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.d.ts +14 -12
- package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.js +2 -2
- package/dist/react/utils/renderDiffChildren.js.map +1 -1
- package/dist/react/utils/renderFileChildren.d.ts +14 -12
- package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
- package/dist/react/utils/renderFileChildren.js +2 -2
- package/dist/react/utils/renderFileChildren.js.map +1 -1
- package/dist/react/utils/useFileDiffInstance.d.ts +22 -10
- package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js +112 -22
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.d.ts +15 -9
- package/dist/react/utils/useFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileInstance.js +84 -25
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +30 -15
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +172 -108
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.d.ts +27 -11
- package/dist/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/renderers/FileRenderer.js +138 -64
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts +2 -2
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.js +2 -2
- package/dist/renderers/UnresolvedFileHunksRenderer.js.map +1 -1
- package/dist/shiki-stream/tokenizer.d.ts.map +1 -1
- package/dist/shiki-stream/tokenizer.js +2 -1
- package/dist/shiki-stream/tokenizer.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/preloadDiffs.d.ts +21 -21
- package/dist/ssr/preloadDiffs.d.ts.map +1 -1
- package/dist/ssr/preloadDiffs.js +1 -1
- package/dist/ssr/preloadDiffs.js.map +1 -1
- package/dist/ssr/preloadFile.d.ts +6 -6
- package/dist/ssr/preloadFile.d.ts.map +1 -1
- package/dist/ssr/preloadFile.js.map +1 -1
- package/dist/ssr/preloadPatchFile.d.ts +4 -4
- package/dist/ssr/preloadPatchFile.d.ts.map +1 -1
- package/dist/ssr/preloadPatchFile.js.map +1 -1
- package/dist/style.js +1 -1
- package/dist/types.d.ts +13 -263
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/appendItems.d.ts +5 -0
- package/dist/utils/appendItems.d.ts.map +1 -0
- package/dist/utils/appendItems.js +8 -0
- package/dist/utils/appendItems.js.map +1 -0
- package/dist/utils/areDiffTargetsEqual.js +1 -1
- package/dist/utils/areDiffTargetsEqual.js.map +1 -1
- package/dist/utils/areFileTargetsEqual.d.ts +7 -0
- package/dist/utils/areFileTargetsEqual.d.ts.map +1 -0
- package/dist/utils/areFileTargetsEqual.js +8 -0
- package/dist/utils/areFileTargetsEqual.js.map +1 -0
- package/dist/utils/areManagedSnapshotsEqual.d.ts +1 -1
- package/dist/utils/areManagedSnapshotsEqual.d.ts.map +1 -1
- package/dist/utils/areManagedSnapshotsEqual.js.map +1 -1
- package/dist/utils/areOptionsEqual.d.ts +3 -3
- package/dist/utils/areOptionsEqual.d.ts.map +1 -1
- package/dist/utils/areOptionsEqual.js.map +1 -1
- package/dist/utils/cloneFileDiffMetadata.d.ts +3 -2
- package/dist/utils/cloneFileDiffMetadata.d.ts.map +1 -1
- package/dist/utils/cloneFileDiffMetadata.js +8 -5
- package/dist/utils/cloneFileDiffMetadata.js.map +1 -1
- package/dist/utils/composeCacheKey.d.ts +6 -0
- package/dist/utils/composeCacheKey.d.ts.map +1 -0
- package/dist/utils/composeCacheKey.js +10 -0
- package/dist/utils/composeCacheKey.js.map +1 -0
- package/dist/utils/editSessionAnnotations.d.ts +69 -0
- package/dist/utils/editSessionAnnotations.d.ts.map +1 -0
- package/dist/utils/editSessionAnnotations.js +64 -0
- package/dist/utils/editSessionAnnotations.js.map +1 -0
- package/dist/utils/editSessionHunks.d.ts +5 -3
- package/dist/utils/editSessionHunks.d.ts.map +1 -1
- package/dist/utils/editSessionHunks.js +7 -5
- package/dist/utils/editSessionHunks.js.map +1 -1
- package/dist/utils/getDiffHunksRendererOptions.d.ts +1 -1
- package/dist/utils/getDiffHunksRendererOptions.d.ts.map +1 -1
- package/dist/utils/getDiffHunksRendererOptions.js.map +1 -1
- package/dist/utils/getFileRendererOptions.d.ts +1 -1
- package/dist/utils/getFileRendererOptions.d.ts.map +1 -1
- package/dist/utils/getFileRendererOptions.js.map +1 -1
- package/dist/utils/hydratePartialDiff.d.ts.map +1 -1
- package/dist/utils/hydratePartialDiff.js +2 -1
- package/dist/utils/hydratePartialDiff.js.map +1 -1
- package/dist/utils/lineAnnotationIdentity.d.ts +16 -0
- package/dist/utils/lineAnnotationIdentity.d.ts.map +1 -0
- package/dist/utils/lineAnnotationIdentity.js +17 -0
- package/dist/utils/lineAnnotationIdentity.js.map +1 -0
- package/dist/utils/parseDiffFromFile.d.ts +2 -2
- package/dist/utils/parseDiffFromFile.d.ts.map +1 -1
- package/dist/utils/parseDiffFromFile.js +6 -6
- package/dist/utils/parseDiffFromFile.js.map +1 -1
- package/dist/utils/parsePatchFiles.d.ts +6 -3
- package/dist/utils/parsePatchFiles.d.ts.map +1 -1
- package/dist/utils/parsePatchFiles.js +34 -9
- package/dist/utils/parsePatchFiles.js.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.d.ts.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.js +6 -5
- package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
- package/dist/utils/renderFileWithHighlighter.d.ts.map +1 -1
- package/dist/utils/renderFileWithHighlighter.js +7 -4
- package/dist/utils/renderFileWithHighlighter.js.map +1 -1
- package/dist/utils/trimPatchContext.d.ts.map +1 -1
- package/dist/utils/trimPatchContext.js +3 -2
- package/dist/utils/trimPatchContext.js.map +1 -1
- package/dist/utils/updateDiffHunks.js +1 -1
- package/dist/utils/virtualDiffLayout.js +1 -1
- package/dist/worker/WorkerPoolManager.d.ts +4 -3
- package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
- package/dist/worker/WorkerPoolManager.js +33 -4
- package/dist/worker/WorkerPoolManager.js.map +1 -1
- package/dist/worker/types.d.ts +5 -0
- package/dist/worker/types.d.ts.map +1 -1
- package/dist/worker/worker-portable.js +14 -6
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +14 -6
- package/dist/worker/worker.js.map +1 -1
- package/package.json +9 -1
- package/dist/editor/stateStorage.d.ts +0 -15
- package/dist/editor/stateStorage.d.ts.map +0 -1
- package/dist/editor/stateStorage.js +0 -65
- package/dist/editor/stateStorage.js.map +0 -1
|
@@ -8,7 +8,7 @@ import { UnresolvedFileHunksRenderer, UnresolvedFileHunksRendererOptions } from
|
|
|
8
8
|
//#region src/components/UnresolvedFile.d.ts
|
|
9
9
|
type RenderMergeConflictActions<LAnnotation> = (action: MergeConflictDiffAction, instance: UnresolvedFile<LAnnotation>) => HTMLElement | DocumentFragment | null | undefined;
|
|
10
10
|
type MergeConflictActionsTypeOption<LAnnotation> = 'none' | 'default' | RenderMergeConflictActions<LAnnotation>;
|
|
11
|
-
interface UnresolvedFileOptions<LAnnotation> extends Omit<FileDiffOptions<LAnnotation>, 'diffStyle' | 'onPostRender'> {
|
|
11
|
+
interface UnresolvedFileOptions<LAnnotation> extends Omit<FileDiffOptions<LAnnotation, undefined>, 'diffStyle' | 'onPostRender'> {
|
|
12
12
|
onPostRender?(node: HTMLElement, instance: UnresolvedFile<LAnnotation>, phase: PostRenderPhase): unknown;
|
|
13
13
|
mergeConflictActionsType?: MergeConflictActionsTypeOption<LAnnotation>;
|
|
14
14
|
onMergeConflictAction?(payload: MergeConflictActionPayload, instance: UnresolvedFile<LAnnotation>): void;
|
|
@@ -38,7 +38,7 @@ interface ResolveConflictReturn {
|
|
|
38
38
|
markerRows: MergeConflictMarkerRow[];
|
|
39
39
|
}
|
|
40
40
|
type UnresolvedFileDataCache = GetOrComputeDiffProps;
|
|
41
|
-
declare class UnresolvedFile<LAnnotation = undefined> extends FileDiff<LAnnotation> {
|
|
41
|
+
declare class UnresolvedFile<LAnnotation = undefined> extends FileDiff<LAnnotation, undefined> {
|
|
42
42
|
options: UnresolvedFileOptions<LAnnotation>;
|
|
43
43
|
readonly __id: string;
|
|
44
44
|
readonly type = "unresolved-file";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnresolvedFile.d.ts","names":[],"sources":["../../src/components/UnresolvedFile.ts"],"mappings":";;;;;;;;KAqCY,0BAAA,iBACV,MAAA,EAAQ,uBAAA,EACR,QAAA,EAAU,cAAA,CAAe,WAAA,MACtB,WAAA,GAAc,gBAAA;AAAA,KAEP,8BAAA,qCAGR,0BAA0B,CAAC,WAAA;AAAA,UAEd,qBAAA,sBAA2C,IAAA,CAC1D,eAAA,CAAgB,WAAA;EAGhB,YAAA,EACE,IAAA,EAAM,WAAA,EACN,QAAA,EAAU,cAAA,CAAe,WAAA,GACzB,KAAA,EAAO,eAAA;EAET,wBAAA,GAA2B,8BAAA,CAA+B,WAAA;EAC1D,qBAAA,EACE,OAAA,EAAS,0BAAA,EACT,QAAA,EAAU,cAAA,CAAe,WAAA;EAE3B,sBAAA,EACE,IAAA,EAAM,YAAA,EACN,OAAA,EAAS,0BAAA;EAEX,eAAA;AAAA;AAAA,UAGe,yBAAA,sBAEP,uBAAA,CAAwB,WAAA;EAChC,IAAA,GAAO,YAAA;EACP,OAAA,IAAW,uBAAA;EACX,UAAA,GAAa,sBAAA;AAAA;A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BAAA;EAAA,QAyBA,6BAAA;AAAA;AAAA,iBAyNM,qCAAA,cACd,OAAA,GAAU,qBAAA,CAAsB,WAAA,GAChC,WAAA,GAAc,qBAAA,CAAsB,WAAA,IACnC,kCAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DEFAULT_THEMES } from "../constants.js";
|
|
2
|
-
import { areFilesEqual } from "../utils/areFilesEqual.js";
|
|
3
2
|
import { pluckInteractionOptions } from "../managers/InteractionManager.js";
|
|
4
3
|
import { createAnnotationWrapperNode } from "../utils/createAnnotationWrapperNode.js";
|
|
5
4
|
import { shouldUseTokenTransformer } from "../utils/shouldUseTokenTransformer.js";
|
|
5
|
+
import { areFilesEqual } from "../utils/areFilesEqual.js";
|
|
6
6
|
import { splitFileContents } from "../utils/splitFileContents.js";
|
|
7
7
|
import { FileDiff } from "./FileDiff.js";
|
|
8
8
|
import { getMergeConflictActionSlotName } from "../utils/getMergeConflictActionSlotName.js";
|
|
@@ -41,7 +41,7 @@ var UnresolvedFile = class extends FileDiff {
|
|
|
41
41
|
this.interactionManager.setOptions(pluckInteractionOptions(this.options, typeof this.options.hunkSeparators === "function" || (this.options.hunkSeparators ?? "line-info") === "line-info" || this.options.hunkSeparators === "line-info-basic" ? this.handleExpandHunk : void 0, this.getLineIndex, this.handleMergeConflictActionClick));
|
|
42
42
|
}
|
|
43
43
|
createHunksRenderer(options) {
|
|
44
|
-
return new UnresolvedFileHunksRenderer(this.getHunksRendererOptions(options), this.handleHighlightRender, this.workerManager);
|
|
44
|
+
return new UnresolvedFileHunksRenderer(this.getHunksRendererOptions(options), this.getAnnotationSlotName, this.handleHighlightRender, this.workerManager);
|
|
45
45
|
}
|
|
46
46
|
getHunksRendererOptions(options) {
|
|
47
47
|
return getUnresolvedDiffHunksRendererOptions(options, this.options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnresolvedFile.js","names":["resolveConflictDiff"],"sources":["../../src/components/UnresolvedFile.ts"],"sourcesContent":["import { DEFAULT_THEMES } from '../constants';\nimport type { MergeConflictActionTarget } from '../managers/InteractionManager';\nimport { pluckInteractionOptions } from '../managers/InteractionManager';\nimport type { HunksRenderResult } from '../renderers/DiffHunksRenderer';\nimport {\n UnresolvedFileHunksRenderer,\n type UnresolvedFileHunksRendererOptions,\n} from '../renderers/UnresolvedFileHunksRenderer';\nimport type {\n FileContents,\n FileDiffMetadata,\n MergeConflictActionPayload,\n MergeConflictMarkerRow,\n MergeConflictRegion,\n MergeConflictResolution,\n PostRenderPhase,\n} from '../types';\nimport { areFilesEqual } from '../utils/areFilesEqual';\nimport { areMergeConflictActionsEqual } from '../utils/areMergeConflictActionsEqual';\nimport { createAnnotationWrapperNode } from '../utils/createAnnotationWrapperNode';\nimport { getMergeConflictActionSlotName } from '../utils/getMergeConflictActionSlotName';\nimport {\n buildMergeConflictMarkerRows,\n getMergeConflictActionAnchor,\n type MergeConflictDiffAction,\n parseMergeConflictDiffFromFile,\n} from '../utils/parseMergeConflictDiffFromFile';\nimport { resolveConflict as resolveConflictDiff } from '../utils/resolveConflict';\nimport { shouldUseTokenTransformer } from '../utils/shouldUseTokenTransformer';\nimport { splitFileContents } from '../utils/splitFileContents';\nimport type { WorkerPoolManager } from '../worker';\nimport {\n FileDiff,\n type FileDiffOptions,\n type FileDiffRenderBaseProps,\n} from './FileDiff';\n\nexport type RenderMergeConflictActions<LAnnotation> = (\n action: MergeConflictDiffAction,\n instance: UnresolvedFile<LAnnotation>\n) => HTMLElement | DocumentFragment | null | undefined;\n\nexport type MergeConflictActionsTypeOption<LAnnotation> =\n | 'none'\n | 'default'\n | RenderMergeConflictActions<LAnnotation>;\n\nexport interface UnresolvedFileOptions<LAnnotation> extends Omit<\n FileDiffOptions<LAnnotation>,\n 'diffStyle' | 'onPostRender'\n> {\n onPostRender?(\n node: HTMLElement,\n instance: UnresolvedFile<LAnnotation>,\n phase: PostRenderPhase\n ): unknown;\n mergeConflictActionsType?: MergeConflictActionsTypeOption<LAnnotation>;\n onMergeConflictAction?(\n payload: MergeConflictActionPayload,\n instance: UnresolvedFile<LAnnotation>\n ): void;\n onMergeConflictResolve?(\n file: FileContents,\n payload: MergeConflictActionPayload\n ): void;\n maxContextLines?: number;\n}\n\nexport interface UnresolvedFileRenderProps<\n LAnnotation,\n> extends FileDiffRenderBaseProps<LAnnotation> {\n file?: FileContents;\n actions?: (MergeConflictDiffAction | undefined)[];\n markerRows?: MergeConflictMarkerRow[];\n}\n\nexport interface UnresolvedFileHydrationProps<LAnnotation> extends Omit<\n UnresolvedFileRenderProps<LAnnotation>,\n 'file'\n> {\n file?: FileContents;\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\n\ninterface MergeConflictActionElementCache {\n element: HTMLElement;\n action: MergeConflictDiffAction;\n}\n\ninterface GetOrComputeDiffProps {\n file: FileContents | undefined;\n fileDiff: FileDiffMetadata | undefined;\n actions: (MergeConflictDiffAction | undefined)[] | undefined;\n markerRows: MergeConflictMarkerRow[] | undefined;\n}\n\ninterface GetOrComputeDiffResult {\n fileDiff: FileDiffMetadata;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n}\n\ninterface ResolveConflictReturn {\n file: FileContents;\n fileDiff: FileDiffMetadata;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n}\n\ntype UnresolvedFileDataCache = GetOrComputeDiffProps;\n\nlet instanceId = -1;\n\nexport class UnresolvedFile<\n LAnnotation = undefined,\n> extends FileDiff<LAnnotation> {\n override readonly __id: string = `unresolved-file:${++instanceId}`;\n override readonly type = 'unresolved-file';\n\n protected computedCache: UnresolvedFileDataCache = {\n file: undefined,\n fileDiff: undefined,\n actions: undefined,\n markerRows: undefined,\n };\n private conflictActions: (MergeConflictDiffAction | undefined)[] = [];\n private markerRows: MergeConflictMarkerRow[] = [];\n private conflictActionCache: Map<string, MergeConflictActionElementCache> =\n new Map();\n\n constructor(\n public override options: UnresolvedFileOptions<LAnnotation> = {\n theme: DEFAULT_THEMES,\n },\n workerManager?: WorkerPoolManager | undefined,\n isContainerManaged = false\n ) {\n super(undefined, workerManager, isContainerManaged);\n this.setOptions(options);\n }\n\n override setOptions(\n options: UnresolvedFileOptions<LAnnotation> | undefined\n ): void {\n if (options == null) {\n return;\n }\n\n if (\n options.onMergeConflictAction != null &&\n options.onMergeConflictResolve != null\n ) {\n throw new Error(\n 'UnresolvedFile: onMergeConflictAction and onMergeConflictResolve are mutually exclusive. Use only one callback.'\n );\n }\n\n this.options = options;\n this.hunksRenderer.setOptions(this.getHunksRendererOptions(options));\n this.syncInteractionOptions();\n }\n\n // UnresolvedFile adds a merge-conflict-action click handler to the\n // InteractionManager. FileDiff.syncInteractionOptions() re-runs on every\n // re-render and during hydration; without this override it would rebuild the\n // interaction options without that handler, so resolving one conflict (which\n // re-renders the diff) would silently disable every remaining action button.\n protected override syncInteractionOptions(): void {\n this.interactionManager.setOptions(\n pluckInteractionOptions(\n this.options,\n typeof this.options.hunkSeparators === 'function' ||\n (this.options.hunkSeparators ?? 'line-info') === 'line-info' ||\n this.options.hunkSeparators === 'line-info-basic'\n ? this.handleExpandHunk\n : undefined,\n this.getLineIndex,\n this.handleMergeConflictActionClick\n )\n );\n }\n\n protected override createHunksRenderer(\n options: UnresolvedFileOptions<LAnnotation>\n ): UnresolvedFileHunksRenderer<LAnnotation> {\n const renderer = new UnresolvedFileHunksRenderer<LAnnotation>(\n this.getHunksRendererOptions(options),\n this.handleHighlightRender,\n this.workerManager\n );\n return renderer;\n }\n\n protected override getHunksRendererOptions(\n options: UnresolvedFileOptions<LAnnotation>\n ): UnresolvedFileHunksRendererOptions {\n return getUnresolvedDiffHunksRendererOptions(options, this.options);\n }\n\n protected override applyPreNodeAttributes(\n pre: HTMLPreElement,\n result: HunksRenderResult\n ): void {\n super.applyPreNodeAttributes(pre, result, {\n 'data-has-merge-conflict': '',\n });\n }\n\n override cleanUp(): void {\n this.emitPostRender(true);\n this.clearMergeConflictActionCache();\n this.computedCache = {\n file: undefined,\n fileDiff: undefined,\n actions: undefined,\n markerRows: undefined,\n };\n this.conflictActions = [];\n super.cleanUp();\n }\n\n private getOrComputeDiff({\n file,\n fileDiff,\n actions,\n markerRows,\n }: GetOrComputeDiffProps): GetOrComputeDiffResult | undefined {\n const { maxContextLines, onMergeConflictAction } = this.options;\n wrapper: {\n // We are dealing with a controlled component\n if (onMergeConflictAction != null) {\n const hasFileDiff = fileDiff != null;\n const hasActions = actions != null;\n const hasMarkerRows = markerRows != null;\n if (hasFileDiff !== hasActions || hasFileDiff !== hasMarkerRows) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows must be passed together'\n );\n }\n // If we were provided a new fileDiff/actions/markerRows, we are a FULLY\n // controlled component, which means we will not do any computation\n if (fileDiff != null && actions != null && markerRows != null) {\n this.computedCache = {\n file: file ?? this.computedCache.file,\n fileDiff,\n actions,\n markerRows,\n };\n break wrapper;\n }\n // If we were provided a new file, we should attempt to parse out a new\n // diff/actions if we haven't computed it before. Once we initialize from\n // a file, later updates must flow through fileDiff/actions instead of\n // reparsing from a new file input.\n else if (file != null || this.computedCache.file != null) {\n if (\n file != null &&\n this.computedCache.file != null &&\n !areFilesEqual(file, this.computedCache.file) &&\n this.computedCache.fileDiff != null &&\n this.computedCache.actions != null\n ) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: file can only be used to initialize unresolved state once. Pass fileDiff and actions for subsequent updates.'\n );\n }\n file ??= this.computedCache.file;\n if (file == null) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: file is null, should be impossible'\n );\n }\n if (\n !areFilesEqual(file, this.computedCache.file) ||\n this.computedCache.fileDiff == null ||\n this.computedCache.actions == null\n ) {\n const computed = parseMergeConflictDiffFromFile(\n file,\n maxContextLines\n );\n this.computedCache = {\n file,\n fileDiff: computed.fileDiff,\n actions: computed.actions,\n markerRows: computed.markerRows,\n };\n }\n fileDiff = this.computedCache.fileDiff;\n actions = this.computedCache.actions;\n markerRows = this.computedCache.markerRows;\n break wrapper;\n }\n // Otherwise we should fall through and try to use the cache if it exists\n else {\n fileDiff = this.computedCache.fileDiff;\n actions = this.computedCache.actions;\n markerRows = this.computedCache.markerRows;\n break wrapper;\n }\n }\n // If we are uncontrolled we only rely on the file and only use the first\n // version. After that, the cached diff/action pair is the source of\n // truth and we should not accept a new file input.\n else {\n if (fileDiff != null || actions != null || markerRows != null) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows are only usable in controlled mode, you must pass in `onMergeConflictAction`'\n );\n }\n if (\n file != null &&\n this.computedCache.file != null &&\n !areFilesEqual(file, this.computedCache.file)\n ) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: uncontrolled unresolved files parse the file only once. Later updates must come from the cached diff state.'\n );\n }\n this.computedCache.file ??= file;\n if (\n this.computedCache.fileDiff == null &&\n this.computedCache.file != null\n ) {\n const computed = parseMergeConflictDiffFromFile(\n this.computedCache.file,\n maxContextLines\n );\n this.computedCache.fileDiff = computed.fileDiff;\n this.computedCache.actions = computed.actions;\n this.computedCache.markerRows = computed.markerRows;\n }\n // Because we are uncontrolled, the source of truth is the\n // computedCache\n fileDiff = this.computedCache.fileDiff;\n actions = this.computedCache.actions;\n markerRows = this.computedCache.markerRows;\n break wrapper;\n }\n }\n if (fileDiff == null || actions == null || markerRows == null) {\n return undefined;\n }\n return { fileDiff, actions, markerRows };\n }\n\n override hydrate(props: UnresolvedFileHydrationProps<LAnnotation>): void {\n const {\n file,\n fileDiff,\n actions,\n markerRows,\n lineAnnotations,\n fileContainer,\n prerenderedHTML,\n preventEmit = false,\n } = props;\n const source = this.getOrComputeDiff({\n file,\n fileDiff,\n actions,\n markerRows,\n });\n if (source == null) {\n return;\n }\n this.hydrateElements(fileContainer, prerenderedHTML);\n this.setActiveMergeConflictState(source.actions, source.markerRows);\n // If necessary hydration elements don't exist, we should assume a full\n // render\n if (\n shouldRenderCode(this.pre, source.fileDiff, this.options.collapsed) ||\n shouldRenderHeader(\n this.headerElement,\n source.fileDiff,\n this.options.disableFileHeader\n )\n ) {\n this.render({ ...props, preventEmit: true });\n }\n // Otherwise orchestrate our setup\n else {\n this.hydrationSetup({ fileDiff: source.fileDiff, lineAnnotations });\n if (this.pre != null) {\n this.renderMergeConflictActionSlots();\n }\n }\n if (!preventEmit) {\n this.emitPostRender();\n }\n }\n\n override rerender(): void {\n if (!this.enabled || this.fileDiff == null) {\n return;\n }\n this.render({ forceRender: true, renderRange: this.renderRange });\n }\n\n override render(props: UnresolvedFileRenderProps<LAnnotation> = {}): boolean {\n const {\n file,\n fileDiff,\n actions,\n markerRows,\n lineAnnotations,\n preventEmit = false,\n ...rest\n } = props;\n const source = this.getOrComputeDiff({\n file,\n fileDiff,\n actions,\n markerRows,\n });\n if (source == null) {\n return false;\n }\n this.setActiveMergeConflictState(source.actions, source.markerRows);\n const didRender = super.render({\n ...rest,\n fileDiff: source.fileDiff,\n lineAnnotations,\n preventEmit: true,\n });\n if (didRender) {\n this.renderMergeConflictActionSlots();\n if (!preventEmit) {\n this.emitPostRender();\n }\n }\n return didRender;\n }\n\n public resolveConflict(\n conflictIndex: number,\n resolution: MergeConflictResolution,\n fileDiff: FileDiffMetadata | undefined = this.computedCache.fileDiff\n ): ResolveConflictReturn | undefined {\n const action = this.conflictActions[conflictIndex];\n if (fileDiff == null || action == null) {\n return undefined;\n }\n\n if (action.conflictIndex !== conflictIndex) {\n console.error({ conflictIndex, action });\n throw new Error(\n \"UnresolvedFile.resolveConflict: conflictIndex and conflictAction don't match\"\n );\n }\n\n const newFileDiff = resolveConflictDiff(fileDiff, action, resolution);\n const previousFile = this.computedCache.file;\n const { file, actions, markerRows } = rebuildFileAndActions({\n fileDiff: newFileDiff,\n previousActions: this.conflictActions,\n resolvedConflictIndex: conflictIndex,\n previousFile,\n resolution,\n });\n\n return {\n file,\n fileDiff: newFileDiff,\n actions,\n markerRows,\n };\n }\n\n private resolveConflictAndRender(\n conflictIndex: number,\n resolution: MergeConflictResolution\n ): void {\n const action = this.conflictActions[conflictIndex];\n if (action == null) {\n return;\n }\n if (action.conflictIndex !== conflictIndex) {\n console.error({ conflictIndex, action });\n throw new Error(\n \"UnresolvedFile.resolveConflictAndRender: conflictIndex and conflictAction don't match\"\n );\n }\n const payload: MergeConflictActionPayload = {\n resolution,\n conflict: action.conflict,\n };\n const { file, fileDiff, actions, markerRows } =\n this.resolveConflict(conflictIndex, resolution) ?? {};\n if (\n file == null ||\n fileDiff == null ||\n actions == null ||\n markerRows == null\n ) {\n return;\n }\n\n this.computedCache = { file, fileDiff, actions, markerRows };\n this.setActiveMergeConflictState(actions, markerRows);\n // NOTE(amadeus): This is a bit jank, but helps to ensure we don't see a\n // bunch of jittery re-renders as things resolve out. In a more perfect\n // world we would have a more elegant way to kick off a render to the\n // highlighter and then resolve actions in a cleaner way, but time is short\n // right now. Can't let perfect be the enemy of good\n if (this.workerManager != null) {\n // Because we are using a workerManager, if we fire off the renderDiff\n // call, it will eventually get back to us in a callback which will\n // trigger a re-render\n this.hunksRenderer.renderDiff(fileDiff);\n } else {\n this.render({ forceRender: true });\n }\n this.options.onMergeConflictResolve?.(file, payload);\n }\n\n private setActiveMergeConflictState(\n actions: (MergeConflictDiffAction | undefined)[] = this.conflictActions,\n markerRows: MergeConflictMarkerRow[] = this.markerRows\n ): void {\n this.conflictActions = actions;\n this.markerRows = markerRows;\n if (\n this.computedCache.fileDiff != null &&\n this.hunksRenderer instanceof UnresolvedFileHunksRenderer\n ) {\n this.hunksRenderer.setConflictState(\n this.options.mergeConflictActionsType === 'none' ? [] : actions,\n markerRows,\n this.computedCache.fileDiff\n );\n }\n }\n\n private handleMergeConflictActionClick = (\n target: MergeConflictActionTarget\n ): void => {\n const action = this.conflictActions[target.conflictIndex];\n if (action == null) {\n return;\n }\n if (action.conflictIndex !== target.conflictIndex) {\n console.error({ conflictIndex: target.conflictIndex, action });\n throw new Error(\n \"UnresolvedFile.handleMergeConflictActionClick: conflictIndex and conflictAction don't match\"\n );\n }\n const payload: MergeConflictActionPayload = {\n resolution: target.resolution,\n conflict: action.conflict,\n };\n if (this.options.onMergeConflictAction != null) {\n this.options.onMergeConflictAction(payload, this);\n return;\n }\n this.resolveConflictAndRender(target.conflictIndex, target.resolution);\n };\n\n private renderMergeConflictActionSlots(): void {\n const { fileDiff } = this.computedCache;\n if (\n this.isContainerManaged ||\n this.fileContainer == null ||\n typeof this.options.mergeConflictActionsType !== 'function' ||\n this.conflictActions.length === 0 ||\n fileDiff == null\n ) {\n this.clearMergeConflictActionCache();\n return;\n }\n const staleActions = new Map(this.conflictActionCache);\n for (\n let actionIndex = 0;\n actionIndex < this.conflictActions.length;\n actionIndex++\n ) {\n const action = this.conflictActions[actionIndex];\n if (action == null) {\n continue;\n }\n if (action.conflictIndex !== actionIndex) {\n console.error({ conflictIndex: actionIndex, action });\n throw new Error(\n \"UnresolvedFile.renderMergeConflictActionSlots: conflictIndex and conflictAction don't match\"\n );\n }\n const anchor = getMergeConflictActionAnchor(action, fileDiff);\n if (anchor == null) {\n continue;\n }\n const conflictIndex = action.conflictIndex;\n const slotName = getMergeConflictActionSlotName({\n hunkIndex: anchor.hunkIndex,\n lineIndex: anchor.lineIndex,\n conflictIndex,\n });\n const id = `${actionIndex}-${slotName}`;\n let cache = this.conflictActionCache.get(id);\n if (\n cache == null ||\n !areMergeConflictActionsEqual(cache.action, action)\n ) {\n cache?.element.remove();\n const rendered = this.renderMergeConflictAction(action);\n if (rendered == null) {\n continue;\n }\n const element = createAnnotationWrapperNode(slotName);\n element.appendChild(rendered);\n this.fileContainer.appendChild(element);\n cache = { element, action };\n this.conflictActionCache.set(id, cache);\n }\n staleActions.delete(id);\n }\n for (const [id, { element }] of staleActions.entries()) {\n this.conflictActionCache.delete(id);\n element.remove();\n }\n }\n\n private renderMergeConflictAction(\n action: MergeConflictDiffAction\n ): HTMLElement | undefined {\n if (typeof this.options.mergeConflictActionsType !== 'function') {\n return undefined;\n }\n const rendered = this.options.mergeConflictActionsType(action, this);\n if (rendered == null) {\n return undefined;\n }\n if (rendered instanceof HTMLElement) {\n return rendered;\n }\n if (\n typeof DocumentFragment !== 'undefined' &&\n rendered instanceof DocumentFragment\n ) {\n const wrapper = document.createElement('div');\n wrapper.style.display = 'contents';\n wrapper.appendChild(rendered);\n return wrapper;\n }\n return undefined;\n }\n\n private clearMergeConflictActionCache(): void {\n for (const { element } of this.conflictActionCache.values()) {\n element.remove();\n }\n this.conflictActionCache.clear();\n }\n}\n\ninterface RebuildFileAndActionsProps {\n fileDiff: FileDiffMetadata;\n previousActions: (MergeConflictDiffAction | undefined)[];\n resolvedConflictIndex: number;\n // FIXME: Probably should remove this...\n // additionOffset: number;\n // deletionOffset: number;\n previousFile: FileContents | undefined;\n resolution: MergeConflictResolution;\n}\n\n// Rebuild the emitted unresolved file contents and remaining action anchors in\n// one pass over the post-resolution diff state.\nfunction rebuildFileAndActions({\n fileDiff,\n previousActions,\n resolvedConflictIndex,\n previousFile,\n resolution,\n}: RebuildFileAndActionsProps): Pick<\n ResolveConflictReturn,\n 'file' | 'actions' | 'markerRows'\n> {\n const resolvedAction = previousActions[resolvedConflictIndex];\n if (resolvedAction == null) {\n throw new Error(\n 'rebuildFileAndActions: missing resolved action for unresolved file rebuild'\n );\n }\n\n const actions = updateConflictActionsAfterResolution(\n previousActions,\n resolvedConflictIndex,\n resolvedAction,\n resolution\n );\n const markerRows = buildMergeConflictMarkerRows(fileDiff, actions);\n\n const file = rebuildUnresolvedFile({\n fileDiff,\n resolvedAction,\n resolvedConflictIndex,\n previousFile,\n resolution,\n });\n\n return {\n file,\n actions,\n markerRows,\n };\n}\n\ninterface RebuildUnresolvedFileProps {\n fileDiff: FileDiffMetadata;\n resolvedAction: MergeConflictDiffAction;\n resolvedConflictIndex: number;\n previousFile: FileContents | undefined;\n resolution: MergeConflictResolution;\n}\n\n// Rebuild the unresolved file text from the previous unresolved source so we\n// preserve remaining marker blocks exactly while the diff state stays in-place.\nfunction rebuildUnresolvedFile({\n resolvedAction,\n resolvedConflictIndex,\n previousFile,\n fileDiff,\n resolution,\n}: RebuildUnresolvedFileProps): FileContents {\n const previousContents = previousFile?.contents ?? '';\n const lines = splitFileContents(previousContents);\n const { conflict } = resolvedAction;\n const replacementLines = getResolvedConflictReplacementLines(\n lines,\n conflict,\n resolution\n );\n const contents = [\n ...lines.slice(0, conflict.startLineIndex),\n ...replacementLines,\n ...lines.slice(conflict.endLineIndex + 1),\n ].join('');\n\n return {\n name: previousFile?.name ?? fileDiff.name,\n contents,\n cacheKey:\n previousFile?.cacheKey != null\n ? `${previousFile.cacheKey}:mc-${resolvedConflictIndex}-${resolution}`\n : undefined,\n };\n}\n\nfunction getResolvedConflictReplacementLines(\n lines: string[],\n conflict: MergeConflictDiffAction['conflict'],\n resolution: MergeConflictResolution\n): string[] {\n const currentLines = lines.slice(\n conflict.startLineIndex + 1,\n conflict.baseMarkerLineIndex ?? conflict.separatorLineIndex\n );\n const incomingLines = lines.slice(\n conflict.separatorLineIndex + 1,\n conflict.endLineIndex\n );\n\n if (resolution === 'current') {\n return currentLines;\n }\n if (resolution === 'incoming') {\n return incomingLines;\n }\n return [...currentLines, ...incomingLines];\n}\n\n// The diff resolver keeps hunk/content group indexes stable, so the only\n// follow-up update we need here is shifting unresolved source-region line\n// numbers for later conflicts in the rebuilt file text.\nfunction updateConflictActionsAfterResolution(\n previousActions: (MergeConflictDiffAction | undefined)[],\n resolvedConflictIndex: number,\n resolvedAction: MergeConflictDiffAction,\n resolution: MergeConflictResolution\n): (MergeConflictDiffAction | undefined)[] {\n const lineDelta = getResolvedConflictLineDelta(\n resolvedAction.conflict,\n resolution\n );\n\n return previousActions.map((action, index) => {\n if (index === resolvedConflictIndex) {\n return undefined;\n }\n if (action == null) {\n return undefined;\n }\n if (action.conflict.startLineIndex > resolvedAction.conflict.endLineIndex) {\n return {\n ...action,\n conflict: shiftMergeConflictRegion(action.conflict, lineDelta),\n };\n }\n return action;\n });\n}\n\nfunction getResolvedConflictLineDelta(\n conflict: MergeConflictRegion,\n resolution: MergeConflictResolution\n): number {\n const currentLineCount =\n (conflict.baseMarkerLineIndex ?? conflict.separatorLineIndex) -\n conflict.startLineIndex -\n 1;\n const incomingLineCount =\n conflict.endLineIndex - conflict.separatorLineIndex - 1;\n const replacementLineCount =\n resolution === 'current'\n ? currentLineCount\n : resolution === 'incoming'\n ? incomingLineCount\n : currentLineCount + incomingLineCount;\n const conflictLineCount = conflict.endLineIndex - conflict.startLineIndex + 1;\n return replacementLineCount - conflictLineCount;\n}\n\nfunction shiftMergeConflictRegion(\n conflict: MergeConflictRegion,\n lineDelta: number\n): MergeConflictRegion {\n return {\n ...conflict,\n startLineIndex: conflict.startLineIndex + lineDelta,\n startLineNumber: conflict.startLineNumber + lineDelta,\n separatorLineIndex: conflict.separatorLineIndex + lineDelta,\n separatorLineNumber: conflict.separatorLineNumber + lineDelta,\n endLineIndex: conflict.endLineIndex + lineDelta,\n endLineNumber: conflict.endLineNumber + lineDelta,\n baseMarkerLineIndex:\n conflict.baseMarkerLineIndex != null\n ? conflict.baseMarkerLineIndex + lineDelta\n : undefined,\n baseMarkerLineNumber:\n conflict.baseMarkerLineNumber != null\n ? conflict.baseMarkerLineNumber + lineDelta\n : undefined,\n };\n}\n\nfunction shouldRenderCode(\n pre: HTMLPreElement | undefined,\n fileDiff: FileDiffMetadata | undefined,\n collapsed = false\n): boolean {\n return !collapsed && pre == null && fileDiff != null;\n}\n\nfunction shouldRenderHeader(\n headerElement: HTMLElement | undefined,\n fileDiff: FileDiffMetadata | undefined,\n disableFileHeader = false\n): boolean {\n return headerElement == null && fileDiff != null && !disableFileHeader;\n}\n\n// NOTE(amadeus): Should probably pull this out into a util, and make variants\n// for all component types\nexport function getUnresolvedDiffHunksRendererOptions<LAnnotation>(\n options?: UnresolvedFileOptions<LAnnotation>,\n baseOptions?: UnresolvedFileOptions<LAnnotation>\n): UnresolvedFileHunksRendererOptions {\n const merged = { ...baseOptions, ...options };\n return {\n ...merged,\n useTokenTransformer: shouldUseTokenTransformer<'diff'>(merged),\n hunkSeparators:\n typeof options?.hunkSeparators === 'function'\n ? 'custom'\n : options?.hunkSeparators,\n mergeConflictActionsType:\n typeof options?.mergeConflictActionsType === 'function'\n ? 'custom'\n : options?.mergeConflictActionsType,\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAgHA,IAAI,aAAa;AAEjB,IAAa,iBAAb,cAEU,SAAsB;CAgBZ;CAflB,OAAiC,mBAAmB,EAAE;CACtD,OAAyB;CAEzB,gBAAmD;EACjD,MAAM,KAAA;EACN,UAAU,KAAA;EACV,SAAS,KAAA;EACT,YAAY,KAAA;CACd;CACA,kBAAmE,CAAC;CACpE,aAA+C,CAAC;CAChD,sCACE,IAAI,IAAI;CAEV,YACE,UAA8D,EAC5D,OAAO,eACT,GACA,eACA,qBAAqB,OACrB;EACA,MAAM,KAAA,GAAW,eAAe,kBAAkB;EANlC,KAAA,UAAA;EAOhB,KAAK,WAAW,OAAO;CACzB;CAEA,WACE,SACM;EACN,IAAI,WAAW,MACb;EAGF,IACE,QAAQ,yBAAyB,QACjC,QAAQ,0BAA0B,MAElC,MAAM,IAAI,MACR,iHACF;EAGF,KAAK,UAAU;EACf,KAAK,cAAc,WAAW,KAAK,wBAAwB,OAAO,CAAC;EACnE,KAAK,uBAAuB;CAC9B;CAOA,yBAAkD;EAChD,KAAK,mBAAmB,WACtB,wBACE,KAAK,SACL,OAAO,KAAK,QAAQ,mBAAmB,eACpC,KAAK,QAAQ,kBAAkB,iBAAiB,eACjD,KAAK,QAAQ,mBAAmB,oBAC9B,KAAK,mBACL,KAAA,GACJ,KAAK,cACL,KAAK,8BACP,CACF;CACF;CAEA,oBACE,SAC0C;EAM1C,OAAO,IALc,4BACnB,KAAK,wBAAwB,OAAO,GACpC,KAAK,uBACL,KAAK,aAEO;CAChB;CAEA,wBACE,SACoC;EACpC,OAAO,sCAAsC,SAAS,KAAK,OAAO;CACpE;CAEA,uBACE,KACA,QACM;EACN,MAAM,uBAAuB,K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AM;EAC7D,gBACE,OAAO,SAAS,mBAAmB,aAC/B,WACA,SAAS;EACf,0BACE,OAAO,SAAS,6BAA6B,aACzC,WACA,SAAS;CACjB;AACF"}
|
|
1
|
+
{"version":3,"file":"UnresolvedFile.js","names":["resolveConflictDiff"],"sources":["../../src/components/UnresolvedFile.ts"],"sourcesContent":["import { DEFAULT_THEMES } from '../constants';\nimport type { MergeConflictActionTarget } from '../managers/InteractionManager';\nimport { pluckInteractionOptions } from '../managers/InteractionManager';\nimport type { HunksRenderResult } from '../renderers/DiffHunksRenderer';\nimport {\n UnresolvedFileHunksRenderer,\n type UnresolvedFileHunksRendererOptions,\n} from '../renderers/UnresolvedFileHunksRenderer';\nimport type {\n FileContents,\n FileDiffMetadata,\n MergeConflictActionPayload,\n MergeConflictMarkerRow,\n MergeConflictRegion,\n MergeConflictResolution,\n PostRenderPhase,\n} from '../types';\nimport { areFilesEqual } from '../utils/areFilesEqual';\nimport { areMergeConflictActionsEqual } from '../utils/areMergeConflictActionsEqual';\nimport { createAnnotationWrapperNode } from '../utils/createAnnotationWrapperNode';\nimport { getMergeConflictActionSlotName } from '../utils/getMergeConflictActionSlotName';\nimport {\n buildMergeConflictMarkerRows,\n getMergeConflictActionAnchor,\n type MergeConflictDiffAction,\n parseMergeConflictDiffFromFile,\n} from '../utils/parseMergeConflictDiffFromFile';\nimport { resolveConflict as resolveConflictDiff } from '../utils/resolveConflict';\nimport { shouldUseTokenTransformer } from '../utils/shouldUseTokenTransformer';\nimport { splitFileContents } from '../utils/splitFileContents';\nimport type { WorkerPoolManager } from '../worker';\nimport {\n FileDiff,\n type FileDiffOptions,\n type FileDiffRenderBaseProps,\n} from './FileDiff';\n\nexport type RenderMergeConflictActions<LAnnotation> = (\n action: MergeConflictDiffAction,\n instance: UnresolvedFile<LAnnotation>\n) => HTMLElement | DocumentFragment | null | undefined;\n\nexport type MergeConflictActionsTypeOption<LAnnotation> =\n | 'none'\n | 'default'\n | RenderMergeConflictActions<LAnnotation>;\n\nexport interface UnresolvedFileOptions<LAnnotation> extends Omit<\n FileDiffOptions<LAnnotation, undefined>,\n 'diffStyle' | 'onPostRender'\n> {\n onPostRender?(\n node: HTMLElement,\n instance: UnresolvedFile<LAnnotation>,\n phase: PostRenderPhase\n ): unknown;\n mergeConflictActionsType?: MergeConflictActionsTypeOption<LAnnotation>;\n onMergeConflictAction?(\n payload: MergeConflictActionPayload,\n instance: UnresolvedFile<LAnnotation>\n ): void;\n onMergeConflictResolve?(\n file: FileContents,\n payload: MergeConflictActionPayload\n ): void;\n maxContextLines?: number;\n}\n\nexport interface UnresolvedFileRenderProps<\n LAnnotation,\n> extends FileDiffRenderBaseProps<LAnnotation> {\n file?: FileContents;\n actions?: (MergeConflictDiffAction | undefined)[];\n markerRows?: MergeConflictMarkerRow[];\n}\n\nexport interface UnresolvedFileHydrationProps<LAnnotation> extends Omit<\n UnresolvedFileRenderProps<LAnnotation>,\n 'file'\n> {\n file?: FileContents;\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\n\ninterface MergeConflictActionElementCache {\n element: HTMLElement;\n action: MergeConflictDiffAction;\n}\n\ninterface GetOrComputeDiffProps {\n file: FileContents | undefined;\n fileDiff: FileDiffMetadata | undefined;\n actions: (MergeConflictDiffAction | undefined)[] | undefined;\n markerRows: MergeConflictMarkerRow[] | undefined;\n}\n\ninterface GetOrComputeDiffResult {\n fileDiff: FileDiffMetadata;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n}\n\ninterface ResolveConflictReturn {\n file: FileContents;\n fileDiff: FileDiffMetadata;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n}\n\ntype UnresolvedFileDataCache = GetOrComputeDiffProps;\n\nlet instanceId = -1;\n\nexport class UnresolvedFile<LAnnotation = undefined> extends FileDiff<\n LAnnotation,\n undefined\n> {\n override readonly __id: string = `unresolved-file:${++instanceId}`;\n override readonly type = 'unresolved-file';\n\n protected computedCache: UnresolvedFileDataCache = {\n file: undefined,\n fileDiff: undefined,\n actions: undefined,\n markerRows: undefined,\n };\n private conflictActions: (MergeConflictDiffAction | undefined)[] = [];\n private markerRows: MergeConflictMarkerRow[] = [];\n private conflictActionCache: Map<string, MergeConflictActionElementCache> =\n new Map();\n\n constructor(\n public override options: UnresolvedFileOptions<LAnnotation> = {\n theme: DEFAULT_THEMES,\n },\n workerManager?: WorkerPoolManager | undefined,\n isContainerManaged = false\n ) {\n super(undefined, workerManager, isContainerManaged);\n this.setOptions(options);\n }\n\n override setOptions(\n options: UnresolvedFileOptions<LAnnotation> | undefined\n ): void {\n if (options == null) {\n return;\n }\n\n if (\n options.onMergeConflictAction != null &&\n options.onMergeConflictResolve != null\n ) {\n throw new Error(\n 'UnresolvedFile: onMergeConflictAction and onMergeConflictResolve are mutually exclusive. Use only one callback.'\n );\n }\n\n this.options = options;\n this.hunksRenderer.setOptions(this.getHunksRendererOptions(options));\n this.syncInteractionOptions();\n }\n\n // UnresolvedFile adds a merge-conflict-action click handler to the\n // InteractionManager. FileDiff.syncInteractionOptions() re-runs on every\n // re-render and during hydration; without this override it would rebuild the\n // interaction options without that handler, so resolving one conflict (which\n // re-renders the diff) would silently disable every remaining action button.\n protected override syncInteractionOptions(): void {\n this.interactionManager.setOptions(\n pluckInteractionOptions(\n this.options,\n typeof this.options.hunkSeparators === 'function' ||\n (this.options.hunkSeparators ?? 'line-info') === 'line-info' ||\n this.options.hunkSeparators === 'line-info-basic'\n ? this.handleExpandHunk\n : undefined,\n this.getLineIndex,\n this.handleMergeConflictActionClick\n )\n );\n }\n\n protected override createHunksRenderer(\n options: UnresolvedFileOptions<LAnnotation>\n ): UnresolvedFileHunksRenderer<LAnnotation> {\n const renderer = new UnresolvedFileHunksRenderer<LAnnotation>(\n this.getHunksRendererOptions(options),\n this.getAnnotationSlotName,\n this.handleHighlightRender,\n this.workerManager\n );\n return renderer;\n }\n\n protected override getHunksRendererOptions(\n options: UnresolvedFileOptions<LAnnotation>\n ): UnresolvedFileHunksRendererOptions {\n return getUnresolvedDiffHunksRendererOptions(options, this.options);\n }\n\n protected override applyPreNodeAttributes(\n pre: HTMLPreElement,\n result: HunksRenderResult\n ): void {\n super.applyPreNodeAttributes(pre, result, {\n 'data-has-merge-conflict': '',\n });\n }\n\n override cleanUp(): void {\n this.emitPostRender(true);\n this.clearMergeConflictActionCache();\n this.computedCache = {\n file: undefined,\n fileDiff: undefined,\n actions: undefined,\n markerRows: undefined,\n };\n this.conflictActions = [];\n super.cleanUp();\n }\n\n private getOrComputeDiff({\n file,\n fileDiff,\n actions,\n markerRows,\n }: GetOrComputeDiffProps): GetOrComputeDiffResult | undefined {\n const { maxContextLines, onMergeConflictAction } = this.options;\n wrapper: {\n // We are dealing with a controlled component\n if (onMergeConflictAction != null) {\n const hasFileDiff = fileDiff != null;\n const hasActions = actions != null;\n const hasMarkerRows = markerRows != null;\n if (hasFileDiff !== hasActions || hasFileDiff !== hasMarkerRows) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows must be passed together'\n );\n }\n // If we were provided a new fileDiff/actions/markerRows, we are a FULLY\n // controlled component, which means we will not do any computation\n if (fileDiff != null && actions != null && markerRows != null) {\n this.computedCache = {\n file: file ?? this.computedCache.file,\n fileDiff,\n actions,\n markerRows,\n };\n break wrapper;\n }\n // If we were provided a new file, we should attempt to parse out a new\n // diff/actions if we haven't computed it before. Once we initialize from\n // a file, later updates must flow through fileDiff/actions instead of\n // reparsing from a new file input.\n else if (file != null || this.computedCache.file != null) {\n if (\n file != null &&\n this.computedCache.file != null &&\n !areFilesEqual(file, this.computedCache.file) &&\n this.computedCache.fileDiff != null &&\n this.computedCache.actions != null\n ) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: file can only be used to initialize unresolved state once. Pass fileDiff and actions for subsequent updates.'\n );\n }\n file ??= this.computedCache.file;\n if (file == null) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: file is null, should be impossible'\n );\n }\n if (\n !areFilesEqual(file, this.computedCache.file) ||\n this.computedCache.fileDiff == null ||\n this.computedCache.actions == null\n ) {\n const computed = parseMergeConflictDiffFromFile(\n file,\n maxContextLines\n );\n this.computedCache = {\n file,\n fileDiff: computed.fileDiff,\n actions: computed.actions,\n markerRows: computed.markerRows,\n };\n }\n fileDiff = this.computedCache.fileDiff;\n actions = this.computedCache.actions;\n markerRows = this.computedCache.markerRows;\n break wrapper;\n }\n // Otherwise we should fall through and try to use the cache if it exists\n else {\n fileDiff = this.computedCache.fileDiff;\n actions = this.computedCache.actions;\n markerRows = this.computedCache.markerRows;\n break wrapper;\n }\n }\n // If we are uncontrolled we only rely on the file and only use the first\n // version. After that, the cached diff/action pair is the source of\n // truth and we should not accept a new file input.\n else {\n if (fileDiff != null || actions != null || markerRows != null) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows are only usable in controlled mode, you must pass in `onMergeConflictAction`'\n );\n }\n if (\n file != null &&\n this.computedCache.file != null &&\n !areFilesEqual(file, this.computedCache.file)\n ) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: uncontrolled unresolved files parse the file only once. Later updates must come from the cached diff state.'\n );\n }\n this.computedCache.file ??= file;\n if (\n this.computedCache.fileDiff == null &&\n this.computedCache.file != null\n ) {\n const computed = parseMergeConflictDiffFromFile(\n this.computedCache.file,\n maxContextLines\n );\n this.computedCache.fileDiff = computed.fileDiff;\n this.computedCache.actions = computed.actions;\n this.computedCache.markerRows = computed.markerRows;\n }\n // Because we are uncontrolled, the source of truth is the\n // computedCache\n fileDiff = this.computedCache.fileDiff;\n actions = this.computedCache.actions;\n markerRows = this.computedCache.markerRows;\n break wrapper;\n }\n }\n if (fileDiff == null || actions == null || markerRows == null) {\n return undefined;\n }\n return { fileDiff, actions, markerRows };\n }\n\n override hydrate(props: UnresolvedFileHydrationProps<LAnnotation>): void {\n const {\n file,\n fileDiff,\n actions,\n markerRows,\n lineAnnotations,\n fileContainer,\n prerenderedHTML,\n preventEmit = false,\n } = props;\n const source = this.getOrComputeDiff({\n file,\n fileDiff,\n actions,\n markerRows,\n });\n if (source == null) {\n return;\n }\n this.hydrateElements(fileContainer, prerenderedHTML);\n this.setActiveMergeConflictState(source.actions, source.markerRows);\n // If necessary hydration elements don't exist, we should assume a full\n // render\n if (\n shouldRenderCode(this.pre, source.fileDiff, this.options.collapsed) ||\n shouldRenderHeader(\n this.headerElement,\n source.fileDiff,\n this.options.disableFileHeader\n )\n ) {\n this.render({ ...props, preventEmit: true });\n }\n // Otherwise orchestrate our setup\n else {\n this.hydrationSetup({ fileDiff: source.fileDiff, lineAnnotations });\n if (this.pre != null) {\n this.renderMergeConflictActionSlots();\n }\n }\n if (!preventEmit) {\n this.emitPostRender();\n }\n }\n\n override rerender(): void {\n if (!this.enabled || this.fileDiff == null) {\n return;\n }\n this.render({ forceRender: true, renderRange: this.renderRange });\n }\n\n override render(props: UnresolvedFileRenderProps<LAnnotation> = {}): boolean {\n const {\n file,\n fileDiff,\n actions,\n markerRows,\n lineAnnotations,\n preventEmit = false,\n ...rest\n } = props;\n const source = this.getOrComputeDiff({\n file,\n fileDiff,\n actions,\n markerRows,\n });\n if (source == null) {\n return false;\n }\n this.setActiveMergeConflictState(source.actions, source.markerRows);\n const didRender = super.render({\n ...rest,\n fileDiff: source.fileDiff,\n lineAnnotations,\n preventEmit: true,\n });\n if (didRender) {\n this.renderMergeConflictActionSlots();\n if (!preventEmit) {\n this.emitPostRender();\n }\n }\n return didRender;\n }\n\n public resolveConflict(\n conflictIndex: number,\n resolution: MergeConflictResolution,\n fileDiff: FileDiffMetadata | undefined = this.computedCache.fileDiff\n ): ResolveConflictReturn | undefined {\n const action = this.conflictActions[conflictIndex];\n if (fileDiff == null || action == null) {\n return undefined;\n }\n\n if (action.conflictIndex !== conflictIndex) {\n console.error({ conflictIndex, action });\n throw new Error(\n \"UnresolvedFile.resolveConflict: conflictIndex and conflictAction don't match\"\n );\n }\n\n const newFileDiff = resolveConflictDiff(fileDiff, action, resolution);\n const previousFile = this.computedCache.file;\n const { file, actions, markerRows } = rebuildFileAndActions({\n fileDiff: newFileDiff,\n previousActions: this.conflictActions,\n resolvedConflictIndex: conflictIndex,\n previousFile,\n resolution,\n });\n\n return {\n file,\n fileDiff: newFileDiff,\n actions,\n markerRows,\n };\n }\n\n private resolveConflictAndRender(\n conflictIndex: number,\n resolution: MergeConflictResolution\n ): void {\n const action = this.conflictActions[conflictIndex];\n if (action == null) {\n return;\n }\n if (action.conflictIndex !== conflictIndex) {\n console.error({ conflictIndex, action });\n throw new Error(\n \"UnresolvedFile.resolveConflictAndRender: conflictIndex and conflictAction don't match\"\n );\n }\n const payload: MergeConflictActionPayload = {\n resolution,\n conflict: action.conflict,\n };\n const { file, fileDiff, actions, markerRows } =\n this.resolveConflict(conflictIndex, resolution) ?? {};\n if (\n file == null ||\n fileDiff == null ||\n actions == null ||\n markerRows == null\n ) {\n return;\n }\n\n this.computedCache = { file, fileDiff, actions, markerRows };\n this.setActiveMergeConflictState(actions, markerRows);\n // NOTE(amadeus): This is a bit jank, but helps to ensure we don't see a\n // bunch of jittery re-renders as things resolve out. In a more perfect\n // world we would have a more elegant way to kick off a render to the\n // highlighter and then resolve actions in a cleaner way, but time is short\n // right now. Can't let perfect be the enemy of good\n if (this.workerManager != null) {\n // Because we are using a workerManager, if we fire off the renderDiff\n // call, it will eventually get back to us in a callback which will\n // trigger a re-render\n this.hunksRenderer.renderDiff(fileDiff);\n } else {\n this.render({ forceRender: true });\n }\n this.options.onMergeConflictResolve?.(file, payload);\n }\n\n private setActiveMergeConflictState(\n actions: (MergeConflictDiffAction | undefined)[] = this.conflictActions,\n markerRows: MergeConflictMarkerRow[] = this.markerRows\n ): void {\n this.conflictActions = actions;\n this.markerRows = markerRows;\n if (\n this.computedCache.fileDiff != null &&\n this.hunksRenderer instanceof UnresolvedFileHunksRenderer\n ) {\n this.hunksRenderer.setConflictState(\n this.options.mergeConflictActionsType === 'none' ? [] : actions,\n markerRows,\n this.computedCache.fileDiff\n );\n }\n }\n\n private handleMergeConflictActionClick = (\n target: MergeConflictActionTarget\n ): void => {\n const action = this.conflictActions[target.conflictIndex];\n if (action == null) {\n return;\n }\n if (action.conflictIndex !== target.conflictIndex) {\n console.error({ conflictIndex: target.conflictIndex, action });\n throw new Error(\n \"UnresolvedFile.handleMergeConflictActionClick: conflictIndex and conflictAction don't match\"\n );\n }\n const payload: MergeConflictActionPayload = {\n resolution: target.resolution,\n conflict: action.conflict,\n };\n if (this.options.onMergeConflictAction != null) {\n this.options.onMergeConflictAction(payload, this);\n return;\n }\n this.resolveConflictAndRender(target.conflictIndex, target.resolution);\n };\n\n private renderMergeConflictActionSlots(): void {\n const { fileDiff } = this.computedCache;\n if (\n this.isContainerManaged ||\n this.fileContainer == null ||\n typeof this.options.mergeConflictActionsType !== 'function' ||\n this.conflictActions.length === 0 ||\n fileDiff == null\n ) {\n this.clearMergeConflictActionCache();\n return;\n }\n const staleActions = new Map(this.conflictActionCache);\n for (\n let actionIndex = 0;\n actionIndex < this.conflictActions.length;\n actionIndex++\n ) {\n const action = this.conflictActions[actionIndex];\n if (action == null) {\n continue;\n }\n if (action.conflictIndex !== actionIndex) {\n console.error({ conflictIndex: actionIndex, action });\n throw new Error(\n \"UnresolvedFile.renderMergeConflictActionSlots: conflictIndex and conflictAction don't match\"\n );\n }\n const anchor = getMergeConflictActionAnchor(action, fileDiff);\n if (anchor == null) {\n continue;\n }\n const conflictIndex = action.conflictIndex;\n const slotName = getMergeConflictActionSlotName({\n hunkIndex: anchor.hunkIndex,\n lineIndex: anchor.lineIndex,\n conflictIndex,\n });\n const id = `${actionIndex}-${slotName}`;\n let cache = this.conflictActionCache.get(id);\n if (\n cache == null ||\n !areMergeConflictActionsEqual(cache.action, action)\n ) {\n cache?.element.remove();\n const rendered = this.renderMergeConflictAction(action);\n if (rendered == null) {\n continue;\n }\n const element = createAnnotationWrapperNode(slotName);\n element.appendChild(rendered);\n this.fileContainer.appendChild(element);\n cache = { element, action };\n this.conflictActionCache.set(id, cache);\n }\n staleActions.delete(id);\n }\n for (const [id, { element }] of staleActions.entries()) {\n this.conflictActionCache.delete(id);\n element.remove();\n }\n }\n\n private renderMergeConflictAction(\n action: MergeConflictDiffAction\n ): HTMLElement | undefined {\n if (typeof this.options.mergeConflictActionsType !== 'function') {\n return undefined;\n }\n const rendered = this.options.mergeConflictActionsType(action, this);\n if (rendered == null) {\n return undefined;\n }\n if (rendered instanceof HTMLElement) {\n return rendered;\n }\n if (\n typeof DocumentFragment !== 'undefined' &&\n rendered instanceof DocumentFragment\n ) {\n const wrapper = document.createElement('div');\n wrapper.style.display = 'contents';\n wrapper.appendChild(rendered);\n return wrapper;\n }\n return undefined;\n }\n\n private clearMergeConflictActionCache(): void {\n for (const { element } of this.conflictActionCache.values()) {\n element.remove();\n }\n this.conflictActionCache.clear();\n }\n}\n\ninterface RebuildFileAndActionsProps {\n fileDiff: FileDiffMetadata;\n previousActions: (MergeConflictDiffAction | undefined)[];\n resolvedConflictIndex: number;\n // FIXME: Probably should remove this...\n // additionOffset: number;\n // deletionOffset: number;\n previousFile: FileContents | undefined;\n resolution: MergeConflictResolution;\n}\n\n// Rebuild the emitted unresolved file contents and remaining action anchors in\n// one pass over the post-resolution diff state.\nfunction rebuildFileAndActions({\n fileDiff,\n previousActions,\n resolvedConflictIndex,\n previousFile,\n resolution,\n}: RebuildFileAndActionsProps): Pick<\n ResolveConflictReturn,\n 'file' | 'actions' | 'markerRows'\n> {\n const resolvedAction = previousActions[resolvedConflictIndex];\n if (resolvedAction == null) {\n throw new Error(\n 'rebuildFileAndActions: missing resolved action for unresolved file rebuild'\n );\n }\n\n const actions = updateConflictActionsAfterResolution(\n previousActions,\n resolvedConflictIndex,\n resolvedAction,\n resolution\n );\n const markerRows = buildMergeConflictMarkerRows(fileDiff, actions);\n\n const file = rebuildUnresolvedFile({\n fileDiff,\n resolvedAction,\n resolvedConflictIndex,\n previousFile,\n resolution,\n });\n\n return {\n file,\n actions,\n markerRows,\n };\n}\n\ninterface RebuildUnresolvedFileProps {\n fileDiff: FileDiffMetadata;\n resolvedAction: MergeConflictDiffAction;\n resolvedConflictIndex: number;\n previousFile: FileContents | undefined;\n resolution: MergeConflictResolution;\n}\n\n// Rebuild the unresolved file text from the previous unresolved source so we\n// preserve remaining marker blocks exactly while the diff state stays in-place.\nfunction rebuildUnresolvedFile({\n resolvedAction,\n resolvedConflictIndex,\n previousFile,\n fileDiff,\n resolution,\n}: RebuildUnresolvedFileProps): FileContents {\n const previousContents = previousFile?.contents ?? '';\n const lines = splitFileContents(previousContents);\n const { conflict } = resolvedAction;\n const replacementLines = getResolvedConflictReplacementLines(\n lines,\n conflict,\n resolution\n );\n const contents = [\n ...lines.slice(0, conflict.startLineIndex),\n ...replacementLines,\n ...lines.slice(conflict.endLineIndex + 1),\n ].join('');\n\n return {\n name: previousFile?.name ?? fileDiff.name,\n contents,\n cacheKey:\n previousFile?.cacheKey != null\n ? `${previousFile.cacheKey}:mc-${resolvedConflictIndex}-${resolution}`\n : undefined,\n };\n}\n\nfunction getResolvedConflictReplacementLines(\n lines: string[],\n conflict: MergeConflictDiffAction['conflict'],\n resolution: MergeConflictResolution\n): string[] {\n const currentLines = lines.slice(\n conflict.startLineIndex + 1,\n conflict.baseMarkerLineIndex ?? conflict.separatorLineIndex\n );\n const incomingLines = lines.slice(\n conflict.separatorLineIndex + 1,\n conflict.endLineIndex\n );\n\n if (resolution === 'current') {\n return currentLines;\n }\n if (resolution === 'incoming') {\n return incomingLines;\n }\n return [...currentLines, ...incomingLines];\n}\n\n// The diff resolver keeps hunk/content group indexes stable, so the only\n// follow-up update we need here is shifting unresolved source-region line\n// numbers for later conflicts in the rebuilt file text.\nfunction updateConflictActionsAfterResolution(\n previousActions: (MergeConflictDiffAction | undefined)[],\n resolvedConflictIndex: number,\n resolvedAction: MergeConflictDiffAction,\n resolution: MergeConflictResolution\n): (MergeConflictDiffAction | undefined)[] {\n const lineDelta = getResolvedConflictLineDelta(\n resolvedAction.conflict,\n resolution\n );\n\n return previousActions.map((action, index) => {\n if (index === resolvedConflictIndex) {\n return undefined;\n }\n if (action == null) {\n return undefined;\n }\n if (action.conflict.startLineIndex > resolvedAction.conflict.endLineIndex) {\n return {\n ...action,\n conflict: shiftMergeConflictRegion(action.conflict, lineDelta),\n };\n }\n return action;\n });\n}\n\nfunction getResolvedConflictLineDelta(\n conflict: MergeConflictRegion,\n resolution: MergeConflictResolution\n): number {\n const currentLineCount =\n (conflict.baseMarkerLineIndex ?? conflict.separatorLineIndex) -\n conflict.startLineIndex -\n 1;\n const incomingLineCount =\n conflict.endLineIndex - conflict.separatorLineIndex - 1;\n const replacementLineCount =\n resolution === 'current'\n ? currentLineCount\n : resolution === 'incoming'\n ? incomingLineCount\n : currentLineCount + incomingLineCount;\n const conflictLineCount = conflict.endLineIndex - conflict.startLineIndex + 1;\n return replacementLineCount - conflictLineCount;\n}\n\nfunction shiftMergeConflictRegion(\n conflict: MergeConflictRegion,\n lineDelta: number\n): MergeConflictRegion {\n return {\n ...conflict,\n startLineIndex: conflict.startLineIndex + lineDelta,\n startLineNumber: conflict.startLineNumber + lineDelta,\n separatorLineIndex: conflict.separatorLineIndex + lineDelta,\n separatorLineNumber: conflict.separatorLineNumber + lineDelta,\n endLineIndex: conflict.endLineIndex + lineDelta,\n endLineNumber: conflict.endLineNumber + lineDelta,\n baseMarkerLineIndex:\n conflict.baseMarkerLineIndex != null\n ? conflict.baseMarkerLineIndex + lineDelta\n : undefined,\n baseMarkerLineNumber:\n conflict.baseMarkerLineNumber != null\n ? conflict.baseMarkerLineNumber + lineDelta\n : undefined,\n };\n}\n\nfunction shouldRenderCode(\n pre: HTMLPreElement | undefined,\n fileDiff: FileDiffMetadata | undefined,\n collapsed = false\n): boolean {\n return !collapsed && pre == null && fileDiff != null;\n}\n\nfunction shouldRenderHeader(\n headerElement: HTMLElement | undefined,\n fileDiff: FileDiffMetadata | undefined,\n disableFileHeader = false\n): boolean {\n return headerElement == null && fileDiff != null && !disableFileHeader;\n}\n\n// NOTE(amadeus): Should probably pull this out into a util, and make variants\n// for all component types\nexport function getUnresolvedDiffHunksRendererOptions<LAnnotation>(\n options?: UnresolvedFileOptions<LAnnotation>,\n baseOptions?: UnresolvedFileOptions<LAnnotation>\n): UnresolvedFileHunksRendererOptions {\n const merged = { ...baseOptions, ...options };\n return {\n ...merged,\n useTokenTransformer: shouldUseTokenTransformer<'diff'>(merged),\n hunkSeparators:\n typeof options?.hunkSeparators === 'function'\n ? 'custom'\n : options?.hunkSeparators,\n mergeConflictActionsType:\n typeof options?.mergeConflictActionsType === 'function'\n ? 'custom'\n : options?.mergeConflictActionsType,\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAgHA,IAAI,aAAa;AAEjB,IAAa,iBAAb,cAA6D,SAG3D;CAgBkB;CAflB,OAAiC,mBAAmB,EAAE;CACtD,OAAyB;CAEzB,gBAAmD;EACjD,MAAM,KAAA;EACN,UAAU,KAAA;EACV,SAAS,KAAA;EACT,YAAY,KAAA;CACd;CACA,kBAAmE,CAAC;CACpE,aAA+C,CAAC;CAChD,sCACE,IAAI,IAAI;CAEV,YACE,UAA8D,EAC5D,OAAO,eACT,GACA,eACA,qBAAqB,OACrB;EACA,MAAM,KAAA,GAAW,eAAe,kBAAkB;EANlC,KAAA,UAAA;EAOhB,KAAK,WAAW,OAAO;CACzB;CAEA,WACE,SACM;EACN,IAAI,WAAW,MACb;EAGF,IACE,QAAQ,yBAAyB,QACjC,QAAQ,0BAA0B,MAElC,MAAM,IAAI,MACR,iHACF;EAGF,KAAK,UAAU;EACf,KAAK,cAAc,WAAW,KAAK,wBAAwB,OAAO,CAAC;EACnE,KAAK,uBAAuB;CAC9B;CAOA,yBAAkD;EAChD,KAAK,mBAAmB,WACtB,wBACE,KAAK,SACL,OAAO,KAAK,QAAQ,mBAAmB,eACpC,KAAK,QAAQ,kBAAkB,iBAAiB,eACjD,KAAK,QAAQ,mBAAmB,oBAC9B,KAAK,mBACL,KAAA,GACJ,KA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a,OAAO,QAAQ,YAAY;AAClD;AAEA,SAAS,mBACP,eACA,UACA,oBAAoB,OACX;CACT,OAAO,iBAAiB,QAAQ,YAAY,QAAQ,CAAC;AACvD;AAIA,SAAgB,sCACd,SACA,aACoC;CACpC,MAAM,SAAS;EAAE,GAAG;EAAa,GAAG;CAAQ;CAC5C,OAAO;EACL,GAAG;EACH,qBAAqB,0BAAkC,MAAM;EAC7D,gBACE,OAAO,SAAS,mBAAmB,aAC/B,WACA,SAAS;EACf,0BACE,OAAO,SAAS,6BAA6B,aACzC,WACA,SAAS;CACjB;AACF"}
|
|
@@ -1,34 +1,41 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileContents, LineAnnotation, NumericScrollLineAnchor, PendingCodeViewLayoutReset, RenderWindow, StickySpecs, ThemeTypes, VirtualFileMetrics } from "../types.js";
|
|
2
|
+
import { TextDocument } from "../editor/textDocument.js";
|
|
2
3
|
import { WorkerPoolManager } from "../worker/WorkerPoolManager.js";
|
|
3
4
|
import { File, FileOptions, FileRenderProps } from "./File.js";
|
|
4
5
|
import { Virtualizer } from "./Virtualizer.js";
|
|
5
6
|
import { CodeView } from "./CodeView.js";
|
|
6
7
|
|
|
7
8
|
//#region src/components/VirtualizedFile.d.ts
|
|
8
|
-
declare class VirtualizedFile<LAnnotation = undefined> extends File<LAnnotation> {
|
|
9
|
+
declare class VirtualizedFile<LAnnotation = undefined, Caret = undefined> extends File<LAnnotation, Caret> {
|
|
9
10
|
private virtualizer;
|
|
10
11
|
private metrics;
|
|
11
12
|
readonly __id: string;
|
|
13
|
+
readonly renderType = "virtualized";
|
|
12
14
|
top: number | undefined;
|
|
13
15
|
height: number;
|
|
14
16
|
private cache;
|
|
17
|
+
private pendingRender;
|
|
15
18
|
private isVisible;
|
|
16
19
|
private isSetup;
|
|
17
20
|
private layoutDirty;
|
|
18
21
|
private forceRenderOverride;
|
|
19
22
|
private currentCollapsed;
|
|
20
|
-
constructor(options: FileOptions<LAnnotation> | undefined, virtualizer: Virtualizer | CodeView<LAnnotation>, metrics?: VirtualFileMetrics, workerManager?: WorkerPoolManager, isContainerManaged?: boolean);
|
|
23
|
+
constructor(options: FileOptions<LAnnotation, Caret> | undefined, virtualizer: Virtualizer | CodeView<LAnnotation, Caret>, metrics?: VirtualFileMetrics, workerManager?: WorkerPoolManager, isContainerManaged?: boolean);
|
|
21
24
|
setMetrics(metrics?: Partial<VirtualFileMetrics>, force?: boolean): void;
|
|
22
25
|
setLineAnnotations(lineAnnotations: LineAnnotation<LAnnotation>[]): void;
|
|
23
26
|
private syncLineAnnotations;
|
|
27
|
+
protected syncEditSessionAnnotationsFromEditor(lineAnnotations: LineAnnotation<LAnnotation>[]): boolean;
|
|
24
28
|
private hasLineAnnotations;
|
|
29
|
+
private hasUniformLineHeights;
|
|
25
30
|
getLineHeight(lineIndex: number, hasMetadataLine?: boolean): number;
|
|
26
|
-
setOptions(options: FileOptions<LAnnotation> | undefined): void;
|
|
31
|
+
setOptions(options: FileOptions<LAnnotation, Caret> | undefined): void;
|
|
27
32
|
setThemeType(themeType: ThemeTypes): void;
|
|
28
33
|
private resetLayoutCache;
|
|
34
|
+
private applyGhostTextRows;
|
|
29
35
|
reconcileHeights(): boolean;
|
|
30
36
|
onRender: (dirty: boolean) => boolean;
|
|
31
|
-
|
|
37
|
+
updateCodeViewLayout(file: FileContents, top: number, reset?: PendingCodeViewLayoutReset, lineAnnotations?: LineAnnotation<LAnnotation>[]): number;
|
|
38
|
+
private getLayoutFile;
|
|
32
39
|
getLinePosition(lineNumber: number): {
|
|
33
40
|
top: number;
|
|
34
41
|
height: number;
|
|
@@ -41,14 +48,16 @@ declare class VirtualizedFile<LAnnotation = undefined> extends File<LAnnotation>
|
|
|
41
48
|
private computeApproximateSize;
|
|
42
49
|
setVisibility(visible: boolean): void;
|
|
43
50
|
rerender(): void;
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
syncGhostTextRows(): void;
|
|
52
|
+
applyDocumentChange(textDocument: TextDocument<'file', LAnnotation>, newLineAnnotations?: LineAnnotation<LAnnotation>[], shouldUpdateBuffer?: boolean): void;
|
|
53
|
+
render({
|
|
46
54
|
fileContainer,
|
|
47
55
|
file,
|
|
48
56
|
forceRender,
|
|
49
57
|
lineAnnotations,
|
|
50
58
|
...props
|
|
51
59
|
}: FileRenderProps<LAnnotation>): boolean;
|
|
60
|
+
private updatePendingRender;
|
|
52
61
|
syncVirtualizedTop(): void;
|
|
53
62
|
protected shouldDisableVirtualizationBuffers(): boolean;
|
|
54
63
|
protected shouldGuardRebuildScroll(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualizedFile.d.ts","names":[],"sources":["../../src/components/VirtualizedFile.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"VirtualizedFile.d.ts","names":[],"sources":["../../src/components/VirtualizedFile.ts"],"mappings":";;;;;;;;cA8Ea,eAAA,qDAGH,IAAA,CAAK,WAAA,EAAa,KAAA;EAAA,QAqBhB,WAAA;EAAA,QACA,OAAA;EAAA,SArBQ,IAAA;EAAA,SACF,UAAA;EAET,GAAA;EACA,MAAA;EAAA,QACC,KAAA;EAAA,QAMA,aAAA;EAAA,QACA,SAAA;EAAA,QACA,OAAA;EAAA,QACA,WAAA;EAAA,QACA,mBAAA;EAAA,QACA,gBAAA;EAER,WAAA,CACE,OAAA,EAAS,WAAA,CAAY,WAAA,EAAa,KAAA,eAC1B,WAAA,EAAa,WAAA,GAAc,QAAA,CAAS,WAAA,EAAa,KAAA,GACjD,OAAA,GAAS,kBAAA,EACjB,aAAA,GAAgB,iBAAA,EAChB,kBAAA;EAKK,UAAA,CACL,OAAA,GAAU,OAAA,CAAQ,kBAAA,GAClB,KAAA;EAWO,kBAAA,CACP,eAAA,EAAiB,cAAA,CAAe,WAAA;EAAA,QAO1B,mBAAA;EAAA,UAiBW,oCAAA,CACjB,eAAA,EAAiB,cAAA,CAAe,WAAA;EAAA,QAS1B,kBAAA;EAAA,QASA,qBAAA;EAYD,aAAA,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