@pierre/diffs 1.1.2 → 1.1.3
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/File.d.ts.map +1 -1
- package/dist/components/UnresolvedFile.d.ts +18 -9
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/UnresolvedFile.js +155 -52
- package/dist/components/UnresolvedFile.js.map +1 -1
- package/dist/constants.d.ts +5 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +5 -4
- package/dist/react/UnresolvedFile.d.ts +3 -1
- package/dist/react/UnresolvedFile.d.ts.map +1 -1
- package/dist/react/UnresolvedFile.js.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/utils/renderDiffChildren.d.ts +1 -1
- package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.js +6 -4
- package/dist/react/utils/renderDiffChildren.js.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.d.ts +3 -2
- package/dist/react/utils/useUnresolvedFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.js +15 -12
- package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +15 -7
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +9 -7
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts +11 -16
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.js +68 -75
- package/dist/renderers/UnresolvedFileHunksRenderer.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/preloadDiffs.d.ts +2 -2
- package/dist/ssr/preloadDiffs.d.ts.map +1 -1
- package/dist/ssr/preloadDiffs.js +4 -3
- package/dist/ssr/preloadDiffs.js.map +1 -1
- package/dist/style.js +1 -1
- package/dist/style.js.map +1 -1
- package/dist/types.d.ts +41 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/areMergeConflictActionsEqual.js +1 -1
- package/dist/utils/areMergeConflictActionsEqual.js.map +1 -1
- package/dist/utils/diffAcceptRejectHunk.d.ts +3 -2
- package/dist/utils/diffAcceptRejectHunk.d.ts.map +1 -1
- package/dist/utils/diffAcceptRejectHunk.js +24 -89
- package/dist/utils/diffAcceptRejectHunk.js.map +1 -1
- package/dist/utils/getMergeConflictActionSlotName.d.ts +4 -6
- package/dist/utils/getMergeConflictActionSlotName.d.ts.map +1 -1
- package/dist/utils/getMergeConflictActionSlotName.js +2 -2
- package/dist/utils/getMergeConflictActionSlotName.js.map +1 -1
- package/dist/utils/getMergeConflictLineTypes.d.ts +1 -2
- package/dist/utils/getMergeConflictLineTypes.d.ts.map +1 -1
- package/dist/utils/getMergeConflictLineTypes.js +7 -12
- package/dist/utils/getMergeConflictLineTypes.js.map +1 -1
- package/dist/utils/normalizeDiffResolution.d.ts +7 -0
- package/dist/utils/normalizeDiffResolution.d.ts.map +1 -0
- package/dist/utils/normalizeDiffResolution.js +11 -0
- package/dist/utils/normalizeDiffResolution.js.map +1 -0
- package/dist/utils/parseMergeConflictDiffFromFile.d.ts +16 -12
- package/dist/utils/parseMergeConflictDiffFromFile.d.ts.map +1 -1
- package/dist/utils/parseMergeConflictDiffFromFile.js +474 -117
- package/dist/utils/parseMergeConflictDiffFromFile.js.map +1 -1
- package/dist/utils/resolveConflict.d.ts +7 -0
- package/dist/utils/resolveConflict.d.ts.map +1 -0
- package/dist/utils/resolveConflict.js +23 -0
- package/dist/utils/resolveConflict.js.map +1 -0
- package/dist/utils/resolveRegion.d.ts +14 -0
- package/dist/utils/resolveRegion.d.ts.map +1 -0
- package/dist/utils/resolveRegion.js +215 -0
- package/dist/utils/resolveRegion.js.map +1 -0
- package/dist/utils/trimPatchContext.js +19 -20
- package/dist/utils/trimPatchContext.js.map +1 -1
- package/dist/worker/worker-portable.js +4 -0
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js.map +1 -1
- package/package.json +2 -1
- package/dist/utils/resolveMergeConflict.d.ts +0 -7
- package/dist/utils/resolveMergeConflict.d.ts.map +0 -1
- package/dist/utils/resolveMergeConflict.js +0 -30
- package/dist/utils/resolveMergeConflict.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"File.d.ts","names":["GetHoveredLineResult","InteractionManager","InteractionManagerBaseOptions","SelectedLineRange","ResizeManager","FileRenderer","BaseCodeOptions","FileContents","LineAnnotation","PrePropertiesConfig","RenderFileMetadata","RenderRange","ThemeTypes","WorkerPoolManager","FileRenderProps","LAnnotation","HTMLElement","FileHydrateProps","Omit","FileOptions","File","AnnotationElementCache","SVGElement","HTMLPreElement","HTMLStyleElement","Map","file","fileContainer","forceRender","preventEmit","containerWrapper","lineAnnotations","renderRange"],"sources":["../../src/components/File.d.ts"],"sourcesContent":["import { type GetHoveredLineResult, InteractionManager, type InteractionManagerBaseOptions, type SelectedLineRange } from '../managers/InteractionManager';\nimport { ResizeManager } from '../managers/ResizeManager';\nimport { FileRenderer } from '../renderers/FileRenderer';\nimport type { BaseCodeOptions, FileContents, LineAnnotation, PrePropertiesConfig, RenderFileMetadata, RenderRange, ThemeTypes } from '../types';\nimport type { WorkerPoolManager } from '../worker';\nexport interface FileRenderProps<LAnnotation> {\n file: FileContents;\n fileContainer?: HTMLElement;\n containerWrapper?: HTMLElement;\n forceRender?: boolean;\n preventEmit?: boolean;\n lineAnnotations?: LineAnnotation<LAnnotation>[];\n renderRange?: RenderRange;\n}\nexport interface FileHydrateProps<LAnnotation> extends Omit<FileRenderProps<LAnnotation>, 'fileContainer'> {\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\nexport interface FileOptions<LAnnotation> extends BaseCodeOptions, InteractionManagerBaseOptions<'file'> {\n disableFileHeader?: boolean;\n /**\n * @deprecated Use `enableGutterUtility` instead.\n */\n enableHoverUtility?: boolean;\n renderHeaderPrefix?: RenderFileMetadata;\n renderCustomMetadata?: RenderFileMetadata;\n /**\n * When true, errors during rendering are rethrown instead of being caught\n * and displayed in the DOM. Useful for testing or when you want to handle\n * errors yourself.\n */\n disableErrorHandling?: boolean;\n renderAnnotation?(annotation: LineAnnotation<LAnnotation>): HTMLElement | undefined;\n renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null | undefined;\n /**\n * @deprecated Use `renderGutterUtility` instead.\n */\n renderHoverUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null | undefined;\n onPostRender?(node: HTMLElement, instance: File<LAnnotation>): unknown;\n}\ninterface AnnotationElementCache<LAnnotation> {\n element: HTMLElement;\n annotation: LineAnnotation<LAnnotation>;\n}\nexport declare class File<LAnnotation = undefined> {\n options: FileOptions<LAnnotation>;\n private workerManager?;\n private isContainerManaged;\n static LoadedCustomComponent: boolean;\n readonly __id: string;\n protected fileContainer: HTMLElement | undefined;\n protected spriteSVG: SVGElement | undefined;\n protected pre: HTMLPreElement | undefined;\n protected code: HTMLElement | undefined;\n protected bufferBefore: HTMLElement | undefined;\n protected bufferAfter: HTMLElement | undefined;\n protected unsafeCSSStyle: HTMLStyleElement | undefined;\n protected gutterUtilityContent: HTMLElement | undefined;\n protected errorWrapper: HTMLElement | undefined;\n protected placeHolder: HTMLElement | undefined;\n protected lastRenderedHeaderHTML: string | undefined;\n protected appliedPreAttributes: PrePropertiesConfig | undefined;\n protected lastRowCount: number | undefined;\n protected headerElement: HTMLElement | undefined;\n protected headerPrefix: HTMLElement | undefined;\n protected headerMetadata: HTMLElement | undefined;\n protected fileRenderer: FileRenderer<LAnnotation>;\n protected resizeManager: ResizeManager;\n protected interactionManager: InteractionManager<'file'>;\n protected annotationCache: Map<string, AnnotationElementCache<LAnnotation>>;\n protected lineAnnotations: LineAnnotation<LAnnotation>[];\n protected file: FileContents | undefined;\n protected renderRange: RenderRange | undefined;\n constructor(options?: FileOptions<LAnnotation>, workerManager?: WorkerPoolManager | undefined, isContainerManaged?: boolean);\n private handleHighlightRender;\n rerender(): void;\n setOptions(options: FileOptions<LAnnotation> | undefined): void;\n private mergeOptions;\n setThemeType(themeType: ThemeTypes): void;\n getHoveredLine: () => {\n lineNumber: number;\n } | undefined;\n setLineAnnotations(lineAnnotations: LineAnnotation<LAnnotation>[]): void;\n setSelectedLines(range: SelectedLineRange | null): void;\n cleanUp(): void;\n hydrate(props: FileHydrateProps<LAnnotation>): void;\n getOrCreateLineCache(file?: FileContents | undefined): string[];\n render({ file, fileContainer, forceRender, preventEmit, containerWrapper, lineAnnotations, renderRange }: FileRenderProps<LAnnotation>): boolean;\n private emitPostRender;\n private removeRenderedCode;\n private clearAuxiliaryNodes;\n private canPartiallyRender;\n renderPlaceholder(height: number): boolean;\n private cleanChildNodes;\n private renderAnnotations;\n private renderGutterUtility;\n private injectUnsafeCSS;\n private applyFullRender;\n private applyPartialRender;\n private getColumns;\n private trimDOMToOverlap;\n private getDOMBoundaryIndices;\n private getLineIndexFromDOMNode;\n private applyBuffers;\n private applyHeaderToDOM;\n protected getOrCreateFileContainerNode(fileContainer?: HTMLElement, parentNode?: HTMLElement): HTMLElement;\n private getOrCreatePreNode;\n private applyPreNodeAttributes;\n private applyErrorToDOM;\n private cleanupErrorWrapper;\n}\nexport {};\n//# sourceMappingURL=File.d.ts.map"],"mappings":";;;;;;;;UAKiBc;QACPP;kBACUS;EAFHF,gBAAAA,CAAAA,EAGME,WAHSD;EACtBR,WAAAA,CAAAA,EAAAA,OAAAA;EACUS,WAAAA,CAAAA,EAAAA,OAAAA;EACGA,eAAAA,CAAAA,EAGDR,cAHCQ,CAGcD,WAHdC,CAAAA,EAAAA;EAGcD,WAAAA,CAAAA,EACnBJ,WADmBI;;AACnBJ,UAEDM,gBAFCN,CAAAA,WAAAA,CAAAA,SAEqCO,IAFrCP,CAE0CG,eAF1CH,CAE0DI,WAF1DJ,CAAAA,EAAAA,eAAAA,CAAAA,CAAAA;EAAW,aAAA,EAGVK,WAHU;EAEZC,eAAAA,CAAAA,EAAAA,MAAgB;;AAA2BH,UAI3CK,WAJ2CL,CAAAA,WAAAA,CAAAA,SAIVR,eAJUQ,EAIOZ,6BAJPY,CAAAA,MAAAA,CAAAA,CAAAA;EACzCE,iBAAAA,CAAAA,EAAAA,OAAAA;EADoCE;;AAIvD;EAMyBR,kBAAAA,CAAAA,EAAAA,OAAAA;EACEA,kBAAAA,CAAAA,EADFA,kBACEA;EAOsBK,oBAAAA,CAAAA,EAPtBL,kBAOsBK;EAAfP;;;;;EAKsDQ,oBAAAA,CAAAA,EAAAA,OAAAA;EAChEA,gBAAAA,EAAAA,UAAAA,EANUR,cAMVQ,CANyBD,WAMzBC,CAAAA,CAAAA,EANwCA,WAMxCA,GAAAA,SAAAA;EAA4BD,mBAAAA,EAAAA,aAAAA,EAAAA,GAAAA,GALNf,oBAKMe,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA,CAAAA,EALqCC,WAKrCD,GAAAA,IAAAA,GAAAA,SAAAA;EAALK;;;EApBiD,kBAAA,EAAA,aAAA,EAAA,GAAA,GAmBnDpB,oBAnBmD,CAAA,MAAA,CAAA,GAAA,SAAA,CAAA,EAmBRgB,WAnBQ,GAAA,IAAA,GAAA,SAAA;EAsBtFK,YAAAA,EAAAA,IAAAA,EAFcL,
|
|
1
|
+
{"version":3,"file":"File.d.ts","names":["GetHoveredLineResult","InteractionManager","InteractionManagerBaseOptions","SelectedLineRange","ResizeManager","FileRenderer","BaseCodeOptions","FileContents","LineAnnotation","PrePropertiesConfig","RenderFileMetadata","RenderRange","ThemeTypes","WorkerPoolManager","FileRenderProps","LAnnotation","HTMLElement","FileHydrateProps","Omit","FileOptions","File","AnnotationElementCache","SVGElement","HTMLPreElement","HTMLStyleElement","Map","file","fileContainer","forceRender","preventEmit","containerWrapper","lineAnnotations","renderRange"],"sources":["../../src/components/File.d.ts"],"sourcesContent":["import { type GetHoveredLineResult, InteractionManager, type InteractionManagerBaseOptions, type SelectedLineRange } from '../managers/InteractionManager';\nimport { ResizeManager } from '../managers/ResizeManager';\nimport { FileRenderer } from '../renderers/FileRenderer';\nimport type { BaseCodeOptions, FileContents, LineAnnotation, PrePropertiesConfig, RenderFileMetadata, RenderRange, ThemeTypes } from '../types';\nimport type { WorkerPoolManager } from '../worker';\nexport interface FileRenderProps<LAnnotation> {\n file: FileContents;\n fileContainer?: HTMLElement;\n containerWrapper?: HTMLElement;\n forceRender?: boolean;\n preventEmit?: boolean;\n lineAnnotations?: LineAnnotation<LAnnotation>[];\n renderRange?: RenderRange;\n}\nexport interface FileHydrateProps<LAnnotation> extends Omit<FileRenderProps<LAnnotation>, 'fileContainer'> {\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\nexport interface FileOptions<LAnnotation> extends BaseCodeOptions, InteractionManagerBaseOptions<'file'> {\n disableFileHeader?: boolean;\n /**\n * @deprecated Use `enableGutterUtility` instead.\n */\n enableHoverUtility?: boolean;\n renderHeaderPrefix?: RenderFileMetadata;\n renderCustomMetadata?: RenderFileMetadata;\n /**\n * When true, errors during rendering are rethrown instead of being caught\n * and displayed in the DOM. Useful for testing or when you want to handle\n * errors yourself.\n */\n disableErrorHandling?: boolean;\n renderAnnotation?(annotation: LineAnnotation<LAnnotation>): HTMLElement | undefined;\n renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null | undefined;\n /**\n * @deprecated Use `renderGutterUtility` instead.\n */\n renderHoverUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null | undefined;\n onPostRender?(node: HTMLElement, instance: File<LAnnotation>): unknown;\n}\ninterface AnnotationElementCache<LAnnotation> {\n element: HTMLElement;\n annotation: LineAnnotation<LAnnotation>;\n}\nexport declare class File<LAnnotation = undefined> {\n options: FileOptions<LAnnotation>;\n private workerManager?;\n private isContainerManaged;\n static LoadedCustomComponent: boolean;\n readonly __id: string;\n protected fileContainer: HTMLElement | undefined;\n protected spriteSVG: SVGElement | undefined;\n protected pre: HTMLPreElement | undefined;\n protected code: HTMLElement | undefined;\n protected bufferBefore: HTMLElement | undefined;\n protected bufferAfter: HTMLElement | undefined;\n protected unsafeCSSStyle: HTMLStyleElement | undefined;\n protected gutterUtilityContent: HTMLElement | undefined;\n protected errorWrapper: HTMLElement | undefined;\n protected placeHolder: HTMLElement | undefined;\n protected lastRenderedHeaderHTML: string | undefined;\n protected appliedPreAttributes: PrePropertiesConfig | undefined;\n protected lastRowCount: number | undefined;\n protected headerElement: HTMLElement | undefined;\n protected headerPrefix: HTMLElement | undefined;\n protected headerMetadata: HTMLElement | undefined;\n protected fileRenderer: FileRenderer<LAnnotation>;\n protected resizeManager: ResizeManager;\n protected interactionManager: InteractionManager<'file'>;\n protected annotationCache: Map<string, AnnotationElementCache<LAnnotation>>;\n protected lineAnnotations: LineAnnotation<LAnnotation>[];\n protected file: FileContents | undefined;\n protected renderRange: RenderRange | undefined;\n constructor(options?: FileOptions<LAnnotation>, workerManager?: WorkerPoolManager | undefined, isContainerManaged?: boolean);\n private handleHighlightRender;\n rerender(): void;\n setOptions(options: FileOptions<LAnnotation> | undefined): void;\n private mergeOptions;\n setThemeType(themeType: ThemeTypes): void;\n getHoveredLine: () => {\n lineNumber: number;\n } | undefined;\n setLineAnnotations(lineAnnotations: LineAnnotation<LAnnotation>[]): void;\n setSelectedLines(range: SelectedLineRange | null): void;\n cleanUp(): void;\n hydrate(props: FileHydrateProps<LAnnotation>): void;\n getOrCreateLineCache(file?: FileContents | undefined): string[];\n render({ file, fileContainer, forceRender, preventEmit, containerWrapper, lineAnnotations, renderRange }: FileRenderProps<LAnnotation>): boolean;\n private emitPostRender;\n private removeRenderedCode;\n private clearAuxiliaryNodes;\n private canPartiallyRender;\n renderPlaceholder(height: number): boolean;\n private cleanChildNodes;\n private renderAnnotations;\n private renderGutterUtility;\n private injectUnsafeCSS;\n private applyFullRender;\n private applyPartialRender;\n private getColumns;\n private trimDOMToOverlap;\n private getDOMBoundaryIndices;\n private getLineIndexFromDOMNode;\n private applyBuffers;\n private applyHeaderToDOM;\n protected getOrCreateFileContainerNode(fileContainer?: HTMLElement, parentNode?: HTMLElement): HTMLElement;\n private getOrCreatePreNode;\n private applyPreNodeAttributes;\n private applyErrorToDOM;\n private cleanupErrorWrapper;\n}\nexport {};\n//# sourceMappingURL=File.d.ts.map"],"mappings":";;;;;;;;UAKiBc;QACPP;kBACUS;EAFHF,gBAAAA,CAAAA,EAGME,WAHSD;EACtBR,WAAAA,CAAAA,EAAAA,OAAAA;EACUS,WAAAA,CAAAA,EAAAA,OAAAA;EACGA,eAAAA,CAAAA,EAGDR,cAHCQ,CAGcD,WAHdC,CAAAA,EAAAA;EAGcD,WAAAA,CAAAA,EACnBJ,WADmBI;;AACnBJ,UAEDM,gBAFCN,CAAAA,WAAAA,CAAAA,SAEqCO,IAFrCP,CAE0CG,eAF1CH,CAE0DI,WAF1DJ,CAAAA,EAAAA,eAAAA,CAAAA,CAAAA;EAAW,aAAA,EAGVK,WAHU;EAEZC,eAAAA,CAAAA,EAAAA,MAAgB;;AAA2BH,UAI3CK,WAJ2CL,CAAAA,WAAAA,CAAAA,SAIVR,eAJUQ,EAIOZ,6BAJPY,CAAAA,MAAAA,CAAAA,CAAAA;EACzCE,iBAAAA,CAAAA,EAAAA,OAAAA;EADoCE;;AAIvD;EAMyBR,kBAAAA,CAAAA,EAAAA,OAAAA;EACEA,kBAAAA,CAAAA,EADFA,kBACEA;EAOsBK,oBAAAA,CAAAA,EAPtBL,kBAOsBK;EAAfP;;;;;EAKsDQ,oBAAAA,CAAAA,EAAAA,OAAAA;EAChEA,gBAAAA,EAAAA,UAAAA,EANUR,cAMVQ,CANyBD,WAMzBC,CAAAA,CAAAA,EANwCA,WAMxCA,GAAAA,SAAAA;EAA4BD,mBAAAA,EAAAA,aAAAA,EAAAA,G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EACaV,kBAAAA,CAAAA,eAAAA,EAJQC,cAIRD,CAJuBQ,WAIvBR,CAAAA,EAAAA,CAAAA,EAAAA,IAAAA;EACnBmB,gBAAAA,CAAAA,KAAAA,EAJevB,iBAIfuB,GAAAA,IAAAA,CAAAA,EAAAA,IAAAA;EAAMC,OAAAA,CAAAA,CAAAA,EAAAA,IAAAA;EAAeC,OAAAA,CAAAA,KAAAA,EAFfX,gBAEeW,CAFEb,WAEFa,CAAAA,CAAAA,EAAAA,IAAAA;EAAaC,oBAAAA,CAAAA,IAAAA,CAAAA,EADftB,YACesB,GAAAA,SAAAA,CAAAA,EAAAA,MAAAA,EAAAA;EAAaC,MAAAA,CAAAA;IAAAA,IAAAA;IAAAA,aAAAA;IAAAA,WAAAA;IAAAA,WAAAA;IAAAA,gBAAAA;IAAAA,eAAAA;IAAAA;EAAAA,CAAAA,EAAkDhB,eAAlDgB,CAAkEf,WAAlEe,CAAAA,CAAAA,EAAAA,OAAAA;EAAkBC,QAAAA,cAAAA;EAAiBC,QAAAA,kBAAAA;EAA+BjB,QAAAA,mBAAAA;EAAhBD,QAAAA,kBAAAA;EAkBnDE,iBAAAA,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAAAA,OAAAA;EAA0BA,QAAAA,eAAAA;EAAcA,QAAAA,iBAAAA;EAAW,QAAA,mBAAA;;;;;;;;;;yDAAnDA,0BAA0BA,cAAcA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FileContents, FileDiffMetadata, MergeConflictActionPayload, MergeConflictResolution } from "../types.js";
|
|
1
|
+
import { FileContents, FileDiffMetadata, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictResolution } from "../types.js";
|
|
2
2
|
import { WorkerPoolManager } from "../worker/WorkerPoolManager.js";
|
|
3
3
|
import "../worker/index.js";
|
|
4
4
|
import { HunksRenderResult } from "../renderers/DiffHunksRenderer.js";
|
|
@@ -9,27 +9,34 @@ import { FileDiff, FileDiffOptions, FileDiffRenderProps } from "./FileDiff.js";
|
|
|
9
9
|
//#region src/components/UnresolvedFile.d.ts
|
|
10
10
|
type RenderMergeConflictActions<LAnnotation> = (action: MergeConflictDiffAction, instance: UnresolvedFile<LAnnotation>) => HTMLElement | DocumentFragment | null | undefined;
|
|
11
11
|
type MergeConflictActionsTypeOption<LAnnotation> = 'none' | 'default' | RenderMergeConflictActions<LAnnotation>;
|
|
12
|
-
interface UnresolvedFileOptions<LAnnotation> extends FileDiffOptions<LAnnotation> {
|
|
12
|
+
interface UnresolvedFileOptions<LAnnotation> extends Omit<FileDiffOptions<LAnnotation>, 'diffStyle'> {
|
|
13
13
|
onPostRender?(node: HTMLElement, instance: UnresolvedFile<LAnnotation>): unknown;
|
|
14
14
|
mergeConflictActionsType?: MergeConflictActionsTypeOption<LAnnotation>;
|
|
15
15
|
onMergeConflictAction?(payload: MergeConflictActionPayload, instance: UnresolvedFile<LAnnotation>): void;
|
|
16
16
|
onMergeConflictResolve?(file: FileContents, payload: MergeConflictActionPayload): void;
|
|
17
|
+
maxContextLines?: number;
|
|
17
18
|
}
|
|
18
19
|
interface UnresolvedFileRenderProps<LAnnotation> extends Omit<FileDiffRenderProps<LAnnotation>, 'oldFile' | 'newFile'> {
|
|
19
20
|
file?: FileContents;
|
|
20
|
-
actions?: MergeConflictDiffAction[];
|
|
21
|
+
actions?: (MergeConflictDiffAction | undefined)[];
|
|
22
|
+
markerRows?: MergeConflictMarkerRow[];
|
|
21
23
|
}
|
|
22
24
|
interface UnresolvedFileHydrationProps<LAnnotation> extends Omit<UnresolvedFileRenderProps<LAnnotation>, 'file'> {
|
|
23
25
|
file?: FileContents;
|
|
24
|
-
fileDiff?: FileDiffMetadata;
|
|
25
|
-
actions?: MergeConflictDiffAction[];
|
|
26
26
|
fileContainer: HTMLElement;
|
|
27
27
|
prerenderedHTML?: string;
|
|
28
28
|
}
|
|
29
29
|
interface GetOrComputeDiffProps {
|
|
30
30
|
file: FileContents | undefined;
|
|
31
31
|
fileDiff: FileDiffMetadata | undefined;
|
|
32
|
-
actions: MergeConflictDiffAction[] | undefined;
|
|
32
|
+
actions: (MergeConflictDiffAction | undefined)[] | undefined;
|
|
33
|
+
markerRows: MergeConflictMarkerRow[] | undefined;
|
|
34
|
+
}
|
|
35
|
+
interface ResolveConflictReturn {
|
|
36
|
+
file: FileContents;
|
|
37
|
+
fileDiff: FileDiffMetadata;
|
|
38
|
+
actions: (MergeConflictDiffAction | undefined)[];
|
|
39
|
+
markerRows: MergeConflictMarkerRow[];
|
|
33
40
|
}
|
|
34
41
|
type UnresolvedFileDataCache = GetOrComputeDiffProps;
|
|
35
42
|
declare class UnresolvedFile<LAnnotation = undefined> extends FileDiff<LAnnotation> {
|
|
@@ -37,6 +44,7 @@ declare class UnresolvedFile<LAnnotation = undefined> extends FileDiff<LAnnotati
|
|
|
37
44
|
readonly __id: string;
|
|
38
45
|
protected computedCache: UnresolvedFileDataCache;
|
|
39
46
|
private conflictActions;
|
|
47
|
+
private markerRows;
|
|
40
48
|
private conflictActionCache;
|
|
41
49
|
constructor(options?: UnresolvedFileOptions<LAnnotation>, workerManager?: WorkerPoolManager | undefined, isContainerManaged?: boolean);
|
|
42
50
|
setOptions(options: UnresolvedFileOptions<LAnnotation> | undefined): void;
|
|
@@ -48,14 +56,15 @@ declare class UnresolvedFile<LAnnotation = undefined> extends FileDiff<LAnnotati
|
|
|
48
56
|
hydrate(props: UnresolvedFileHydrationProps<LAnnotation>): void;
|
|
49
57
|
rerender(): void;
|
|
50
58
|
render(props?: UnresolvedFileRenderProps<LAnnotation>): boolean;
|
|
51
|
-
resolveConflict(conflictIndex: number, resolution: MergeConflictResolution,
|
|
59
|
+
resolveConflict(conflictIndex: number, resolution: MergeConflictResolution, fileDiff?: FileDiffMetadata | undefined): ResolveConflictReturn | undefined;
|
|
52
60
|
private resolveConflictAndRender;
|
|
53
|
-
private
|
|
61
|
+
private setActiveMergeConflictState;
|
|
54
62
|
private handleMergeConflictActionClick;
|
|
55
63
|
private renderMergeConflictActionSlots;
|
|
56
64
|
private renderMergeConflictAction;
|
|
57
65
|
private clearMergeConflictActionCache;
|
|
58
66
|
}
|
|
67
|
+
declare function getUnresolvedDiffHunksRendererOptions<LAnnotation>(options?: UnresolvedFileOptions<LAnnotation>, baseOptions?: UnresolvedFileOptions<LAnnotation>): UnresolvedFileHunksRendererOptions;
|
|
59
68
|
//#endregion
|
|
60
|
-
export { MergeConflictActionsTypeOption, RenderMergeConflictActions, UnresolvedFile, UnresolvedFileHydrationProps, UnresolvedFileOptions, UnresolvedFileRenderProps };
|
|
69
|
+
export { MergeConflictActionsTypeOption, RenderMergeConflictActions, UnresolvedFile, UnresolvedFileHydrationProps, UnresolvedFileOptions, UnresolvedFileRenderProps, getUnresolvedDiffHunksRendererOptions };
|
|
61
70
|
//# sourceMappingURL=UnresolvedFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnresolvedFile.d.ts","names":["HunksRenderResult","UnresolvedFileHunksRenderer","UnresolvedFileHunksRendererOptions","FileContents","FileDiffMetadata","MergeConflictActionPayload","MergeConflictResolution","MergeConflictDiffAction","WorkerPoolManager","FileDiff","FileDiffOptions","FileDiffRenderProps","RenderMergeConflictActions","LAnnotation","UnresolvedFile","HTMLElement","DocumentFragment","MergeConflictActionsTypeOption","UnresolvedFileOptions","
|
|
1
|
+
{"version":3,"file":"UnresolvedFile.d.ts","names":["HunksRenderResult","UnresolvedFileHunksRenderer","UnresolvedFileHunksRendererOptions","FileContents","FileDiffMetadata","MergeConflictActionPayload","MergeConflictMarkerRow","MergeConflictResolution","MergeConflictDiffAction","WorkerPoolManager","FileDiff","FileDiffOptions","FileDiffRenderProps","RenderMergeConflictActions","LAnnotation","UnresolvedFile","HTMLElement","DocumentFragment","MergeConflictActionsTypeOption","UnresolvedFileOptions","Omit","UnresolvedFileRenderProps","UnresolvedFileHydrationProps","GetOrComputeDiffProps","ResolveConflictReturn","UnresolvedFileDataCache","HTMLPreElement","getUnresolvedDiffHunksRendererOptions"],"sources":["../../src/components/UnresolvedFile.d.ts"],"sourcesContent":["import type { HunksRenderResult } from '../renderers/DiffHunksRenderer';\nimport { UnresolvedFileHunksRenderer, type UnresolvedFileHunksRendererOptions } from '../renderers/UnresolvedFileHunksRenderer';\nimport type { FileContents, FileDiffMetadata, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictResolution } from '../types';\nimport { type MergeConflictDiffAction } from '../utils/parseMergeConflictDiffFromFile';\nimport type { WorkerPoolManager } from '../worker';\nimport { FileDiff, type FileDiffOptions, type FileDiffRenderProps } from './FileDiff';\nexport type RenderMergeConflictActions<LAnnotation> = (action: MergeConflictDiffAction, instance: UnresolvedFile<LAnnotation>) => HTMLElement | DocumentFragment | null | undefined;\nexport type MergeConflictActionsTypeOption<LAnnotation> = 'none' | 'default' | RenderMergeConflictActions<LAnnotation>;\nexport interface UnresolvedFileOptions<LAnnotation> extends Omit<FileDiffOptions<LAnnotation>, 'diffStyle'> {\n onPostRender?(node: HTMLElement, instance: UnresolvedFile<LAnnotation>): unknown;\n mergeConflictActionsType?: MergeConflictActionsTypeOption<LAnnotation>;\n onMergeConflictAction?(payload: MergeConflictActionPayload, instance: UnresolvedFile<LAnnotation>): void;\n onMergeConflictResolve?(file: FileContents, payload: MergeConflictActionPayload): void;\n maxContextLines?: number;\n}\nexport interface UnresolvedFileRenderProps<LAnnotation> extends Omit<FileDiffRenderProps<LAnnotation>, 'oldFile' | 'newFile'> {\n file?: FileContents;\n actions?: (MergeConflictDiffAction | undefined)[];\n markerRows?: MergeConflictMarkerRow[];\n}\nexport interface UnresolvedFileHydrationProps<LAnnotation> extends Omit<UnresolvedFileRenderProps<LAnnotation>, 'file'> {\n file?: FileContents;\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\ninterface GetOrComputeDiffProps {\n file: FileContents | undefined;\n fileDiff: FileDiffMetadata | undefined;\n actions: (MergeConflictDiffAction | undefined)[] | undefined;\n markerRows: MergeConflictMarkerRow[] | undefined;\n}\ninterface ResolveConflictReturn {\n file: FileContents;\n fileDiff: FileDiffMetadata;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n}\ntype UnresolvedFileDataCache = GetOrComputeDiffProps;\nexport declare class UnresolvedFile<LAnnotation = undefined> extends FileDiff<LAnnotation> {\n options: UnresolvedFileOptions<LAnnotation>;\n readonly __id: string;\n protected computedCache: UnresolvedFileDataCache;\n private conflictActions;\n private markerRows;\n private conflictActionCache;\n constructor(options?: UnresolvedFileOptions<LAnnotation>, workerManager?: WorkerPoolManager | undefined, isContainerManaged?: boolean);\n setOptions(options: UnresolvedFileOptions<LAnnotation> | undefined): void;\n protected createHunksRenderer(options: UnresolvedFileOptions<LAnnotation>): UnresolvedFileHunksRenderer<LAnnotation>;\n protected getHunksRendererOptions(options: UnresolvedFileOptions<LAnnotation>): UnresolvedFileHunksRendererOptions;\n protected applyPreNodeAttributes(pre: HTMLPreElement, result: HunksRenderResult): void;\n cleanUp(): void;\n private getOrComputeDiff;\n hydrate(props: UnresolvedFileHydrationProps<LAnnotation>): void;\n rerender(): void;\n render(props?: UnresolvedFileRenderProps<LAnnotation>): boolean;\n resolveConflict(conflictIndex: number, resolution: MergeConflictResolution, fileDiff?: FileDiffMetadata | undefined): ResolveConflictReturn | undefined;\n private resolveConflictAndRender;\n private setActiveMergeConflictState;\n private handleMergeConflictActionClick;\n private renderMergeConflictActionSlots;\n private renderMergeConflictAction;\n private clearMergeConflictActionCache;\n}\nexport declare function getUnresolvedDiffHunksRendererOptions<LAnnotation>(options?: UnresolvedFileOptions<LAnnotation>, baseOptions?: UnresolvedFileOptions<LAnnotation>): UnresolvedFileHunksRendererOptions;\nexport {};\n//# sourceMappingURL=UnresolvedFile.d.ts.map"],"mappings":";;;;;;;;;KAMYa,mDAAmDL,mCAAmCO,eAAeD,iBAAiBE,cAAcC;KACpIC,mEAAmEL,2BAA2BC;UACzFK,2CAA2CC,KAAKT,gBAAgBG;EAFrED,YAAAA,EAAAA,I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CAAA,KAAA,EAuBnBgB,4BAvBmB,CAuBUR,WAvBV,CAAA,CAAA,EAAA,IAAA;EAE5BU,QAAAA,CAAAA,CAAAA,EAAAA,IAAAA;EACArB,MAAAA,CAAAA,KAAAA,CAAAA,EAsBSkB,yBAtBTlB,CAsBmCW,WAtBnCX,CAAAA,CAAAA,EAAAA,OAAAA;EACIC,eAAAA,CAAAA,aAAAA,EAAAA,MAAAA,EAAAA,UAAAA,EAsByCG,uBAtBzCH,EAAAA,QAAAA,CAAAA,EAsB6EA,gBAtB7EA,GAAAA,SAAAA,CAAAA,EAsB4GoB,qBAtB5GpB,GAAAA,SAAAA;EACAI,QAAAA,wBAAAA;EACEF,QAAAA,2BAAAA;EAAsB,QAAA,8BAAA;EAEjCmB,QAAAA,8BAAuB;EACPV,QAAAA,yBAAcD;EAA2CA,QAAAA,6BAAAA;;AACjEK,iBAwBWQ,qCAxBXR,CAAAA,WAAAA,CAAAA,CAAAA,OAAAA,CAAAA,EAwBwEA,qBAxBxEA,CAwB8FL,WAxB9FK,CAAAA,EAAAA,WAAAA,CAAAA,EAwB0HA,qBAxB1HA,CAwBgJL,WAxBhJK,CAAAA,CAAAA,EAwB+JjB,kCAxB/JiB"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { DEFAULT_THEMES } from "../constants.js";
|
|
2
2
|
import { pluckInteractionOptions } from "../managers/InteractionManager.js";
|
|
3
|
+
import { splitFileContents } from "../utils/splitFileContents.js";
|
|
3
4
|
import { areFilesEqual } from "../utils/areFilesEqual.js";
|
|
4
5
|
import { createAnnotationWrapperNode } from "../utils/createAnnotationWrapperNode.js";
|
|
5
6
|
import { FileDiff } from "./FileDiff.js";
|
|
6
7
|
import { getMergeConflictActionSlotName } from "../utils/getMergeConflictActionSlotName.js";
|
|
7
|
-
import { getMergeConflictActionAnchor, parseMergeConflictDiffFromFile } from "../utils/parseMergeConflictDiffFromFile.js";
|
|
8
|
+
import { buildMergeConflictMarkerRows, getMergeConflictActionAnchor, parseMergeConflictDiffFromFile } from "../utils/parseMergeConflictDiffFromFile.js";
|
|
8
9
|
import { UnresolvedFileHunksRenderer } from "../renderers/UnresolvedFileHunksRenderer.js";
|
|
9
10
|
import { areMergeConflictActionsEqual } from "../utils/areMergeConflictActionsEqual.js";
|
|
10
|
-
import {
|
|
11
|
+
import { resolveConflict } from "../utils/resolveConflict.js";
|
|
11
12
|
|
|
12
13
|
//#region src/components/UnresolvedFile.ts
|
|
13
14
|
let instanceId = -1;
|
|
@@ -16,9 +17,11 @@ var UnresolvedFile = class extends FileDiff {
|
|
|
16
17
|
computedCache = {
|
|
17
18
|
file: void 0,
|
|
18
19
|
fileDiff: void 0,
|
|
19
|
-
actions: void 0
|
|
20
|
+
actions: void 0,
|
|
21
|
+
markerRows: void 0
|
|
20
22
|
};
|
|
21
23
|
conflictActions = [];
|
|
24
|
+
markerRows = [];
|
|
22
25
|
conflictActionCache = /* @__PURE__ */ new Map();
|
|
23
26
|
constructor(options = { theme: DEFAULT_THEMES }, workerManager, isContainerManaged = false) {
|
|
24
27
|
super(void 0, workerManager, isContainerManaged);
|
|
@@ -37,11 +40,7 @@ var UnresolvedFile = class extends FileDiff {
|
|
|
37
40
|
return new UnresolvedFileHunksRenderer(this.getHunksRendererOptions(options), this.handleHighlightRender, this.workerManager);
|
|
38
41
|
}
|
|
39
42
|
getHunksRendererOptions(options) {
|
|
40
|
-
return
|
|
41
|
-
...this.options,
|
|
42
|
-
hunkSeparators: typeof options.hunkSeparators === "function" ? "custom" : options.hunkSeparators,
|
|
43
|
-
mergeConflictActionsType: typeof options.mergeConflictActionsType === "function" ? "custom" : options.mergeConflictActionsType
|
|
44
|
-
};
|
|
43
|
+
return getUnresolvedDiffHunksRendererOptions(options, this.options);
|
|
45
44
|
}
|
|
46
45
|
applyPreNodeAttributes(pre, result) {
|
|
47
46
|
super.applyPreNodeAttributes(pre, result, { "data-has-merge-conflict": "" });
|
|
@@ -51,67 +50,80 @@ var UnresolvedFile = class extends FileDiff {
|
|
|
51
50
|
this.computedCache = {
|
|
52
51
|
file: void 0,
|
|
53
52
|
fileDiff: void 0,
|
|
54
|
-
actions: void 0
|
|
53
|
+
actions: void 0,
|
|
54
|
+
markerRows: void 0
|
|
55
55
|
};
|
|
56
56
|
this.conflictActions = [];
|
|
57
57
|
super.cleanUp();
|
|
58
58
|
}
|
|
59
|
-
getOrComputeDiff({ file, fileDiff, actions }) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
getOrComputeDiff({ file, fileDiff, actions, markerRows }) {
|
|
60
|
+
const { maxContextLines, onMergeConflictAction } = this.options;
|
|
61
|
+
wrapper: if (onMergeConflictAction != null) {
|
|
62
|
+
const hasFileDiff = fileDiff != null;
|
|
63
|
+
if (hasFileDiff !== (actions != null) || hasFileDiff !== (markerRows != null)) throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows must be passed together");
|
|
64
|
+
if (fileDiff != null && actions != null && markerRows != null) {
|
|
63
65
|
this.computedCache = {
|
|
64
66
|
file: file ?? this.computedCache.file,
|
|
65
67
|
fileDiff,
|
|
66
|
-
actions
|
|
68
|
+
actions,
|
|
69
|
+
markerRows
|
|
67
70
|
};
|
|
68
71
|
break wrapper;
|
|
69
72
|
} else if (file != null || this.computedCache.file != null) {
|
|
73
|
+
if (file != null && this.computedCache.file != null && !areFilesEqual(file, this.computedCache.file) && this.computedCache.fileDiff != null && this.computedCache.actions != null) throw new Error("UnresolvedFile.getOrComputeDiff: file can only be used to initialize unresolved state once. Pass fileDiff and actions for subsequent updates.");
|
|
70
74
|
file ??= this.computedCache.file;
|
|
71
75
|
if (file == null) throw new Error("UnresolvedFile.getOrComputeDiff: file is null, should be impossible");
|
|
72
76
|
if (!areFilesEqual(file, this.computedCache.file) || this.computedCache.fileDiff == null || this.computedCache.actions == null) {
|
|
73
|
-
const computed = parseMergeConflictDiffFromFile(file);
|
|
77
|
+
const computed = parseMergeConflictDiffFromFile(file, maxContextLines);
|
|
74
78
|
this.computedCache = {
|
|
75
79
|
file,
|
|
76
80
|
fileDiff: computed.fileDiff,
|
|
77
|
-
actions: computed.actions
|
|
81
|
+
actions: computed.actions,
|
|
82
|
+
markerRows: computed.markerRows
|
|
78
83
|
};
|
|
79
84
|
}
|
|
80
85
|
fileDiff = this.computedCache.fileDiff;
|
|
81
86
|
actions = this.computedCache.actions;
|
|
87
|
+
markerRows = this.computedCache.markerRows;
|
|
82
88
|
break wrapper;
|
|
83
89
|
} else {
|
|
84
90
|
fileDiff = this.computedCache.fileDiff;
|
|
85
91
|
actions = this.computedCache.actions;
|
|
92
|
+
markerRows = this.computedCache.markerRows;
|
|
86
93
|
break wrapper;
|
|
87
94
|
}
|
|
88
95
|
} else {
|
|
89
|
-
if (fileDiff != null || actions != null) throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff and
|
|
96
|
+
if (fileDiff != null || actions != null || markerRows != null) throw new Error("UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows are only usable in controlled mode, you must pass in `onMergeConflictAction`");
|
|
97
|
+
if (file != null && this.computedCache.file != null && !areFilesEqual(file, this.computedCache.file)) throw new Error("UnresolvedFile.getOrComputeDiff: uncontrolled unresolved files parse the file only once. Later updates must come from the cached diff state.");
|
|
90
98
|
this.computedCache.file ??= file;
|
|
91
99
|
if (this.computedCache.fileDiff == null && this.computedCache.file != null) {
|
|
92
|
-
const computed = parseMergeConflictDiffFromFile(this.computedCache.file);
|
|
100
|
+
const computed = parseMergeConflictDiffFromFile(this.computedCache.file, maxContextLines);
|
|
93
101
|
this.computedCache.fileDiff = computed.fileDiff;
|
|
94
102
|
this.computedCache.actions = computed.actions;
|
|
103
|
+
this.computedCache.markerRows = computed.markerRows;
|
|
95
104
|
}
|
|
96
105
|
fileDiff = this.computedCache.fileDiff;
|
|
97
106
|
actions = this.computedCache.actions;
|
|
107
|
+
markerRows = this.computedCache.markerRows;
|
|
98
108
|
break wrapper;
|
|
99
109
|
}
|
|
100
|
-
if (fileDiff == null || actions == null) return;
|
|
110
|
+
if (fileDiff == null || actions == null || markerRows == null) return;
|
|
101
111
|
return {
|
|
102
112
|
fileDiff,
|
|
103
|
-
actions
|
|
113
|
+
actions,
|
|
114
|
+
markerRows
|
|
104
115
|
};
|
|
105
116
|
}
|
|
106
117
|
hydrate(props) {
|
|
107
|
-
const { file, fileDiff, actions, lineAnnotations, preventEmit = false,...rest } = props;
|
|
118
|
+
const { file, fileDiff, actions, markerRows, lineAnnotations, preventEmit = false,...rest } = props;
|
|
108
119
|
const source = this.getOrComputeDiff({
|
|
109
120
|
file,
|
|
110
121
|
fileDiff,
|
|
111
|
-
actions
|
|
122
|
+
actions,
|
|
123
|
+
markerRows
|
|
112
124
|
});
|
|
113
125
|
if (source == null) return;
|
|
114
|
-
this.
|
|
126
|
+
this.setActiveMergeConflictState(source.actions, source.markerRows);
|
|
115
127
|
super.hydrate({
|
|
116
128
|
...rest,
|
|
117
129
|
fileDiff: source.fileDiff,
|
|
@@ -129,27 +141,30 @@ var UnresolvedFile = class extends FileDiff {
|
|
|
129
141
|
});
|
|
130
142
|
}
|
|
131
143
|
render(props = {}) {
|
|
132
|
-
let { file, fileDiff, actions, lineAnnotations, preventEmit = false,...rest } = props;
|
|
144
|
+
let { file, fileDiff, actions, markerRows, lineAnnotations, preventEmit = false,...rest } = props;
|
|
133
145
|
const source = this.getOrComputeDiff({
|
|
134
146
|
file,
|
|
135
147
|
fileDiff,
|
|
136
|
-
actions
|
|
148
|
+
actions,
|
|
149
|
+
markerRows
|
|
137
150
|
});
|
|
138
151
|
if (source == null) return false;
|
|
139
|
-
this.
|
|
152
|
+
this.setActiveMergeConflictState(source.actions, source.markerRows);
|
|
140
153
|
const didRender = super.render({
|
|
141
154
|
...rest,
|
|
142
155
|
fileDiff: source.fileDiff,
|
|
143
156
|
lineAnnotations,
|
|
144
157
|
preventEmit: true
|
|
145
158
|
});
|
|
146
|
-
|
|
147
|
-
|
|
159
|
+
if (didRender) {
|
|
160
|
+
this.renderMergeConflictActionSlots();
|
|
161
|
+
if (!preventEmit) this.emitPostRender();
|
|
162
|
+
}
|
|
148
163
|
return didRender;
|
|
149
164
|
}
|
|
150
|
-
resolveConflict(conflictIndex, resolution,
|
|
165
|
+
resolveConflict(conflictIndex, resolution, fileDiff = this.computedCache.fileDiff) {
|
|
151
166
|
const action = this.conflictActions[conflictIndex];
|
|
152
|
-
if (
|
|
167
|
+
if (fileDiff == null || action == null) return;
|
|
153
168
|
if (action.conflictIndex !== conflictIndex) {
|
|
154
169
|
console.error({
|
|
155
170
|
conflictIndex,
|
|
@@ -157,15 +172,20 @@ var UnresolvedFile = class extends FileDiff {
|
|
|
157
172
|
});
|
|
158
173
|
throw new Error("UnresolvedFile.resolveConflict: conflictIndex and conflictAction don't match");
|
|
159
174
|
}
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
175
|
+
const newFileDiff = resolveConflict(fileDiff, action, resolution);
|
|
176
|
+
const previousFile = this.computedCache.file;
|
|
177
|
+
const { file, actions, markerRows } = rebuildFileAndActions({
|
|
178
|
+
fileDiff: newFileDiff,
|
|
179
|
+
previousActions: this.conflictActions,
|
|
180
|
+
resolvedConflictIndex: conflictIndex,
|
|
181
|
+
previousFile,
|
|
182
|
+
resolution
|
|
163
183
|
});
|
|
164
|
-
if (contents === file.contents) return;
|
|
165
184
|
return {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
185
|
+
file,
|
|
186
|
+
fileDiff: newFileDiff,
|
|
187
|
+
actions,
|
|
188
|
+
markerRows
|
|
169
189
|
};
|
|
170
190
|
}
|
|
171
191
|
resolveConflictAndRender(conflictIndex, resolution) {
|
|
@@ -182,18 +202,23 @@ var UnresolvedFile = class extends FileDiff {
|
|
|
182
202
|
resolution,
|
|
183
203
|
conflict: action.conflict
|
|
184
204
|
};
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
187
|
-
this.computedCache
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
205
|
+
const { file, fileDiff, actions, markerRows } = this.resolveConflict(conflictIndex, resolution) ?? {};
|
|
206
|
+
if (file == null || fileDiff == null || actions == null || markerRows == null) return;
|
|
207
|
+
this.computedCache = {
|
|
208
|
+
file,
|
|
209
|
+
fileDiff,
|
|
210
|
+
actions,
|
|
211
|
+
markerRows
|
|
212
|
+
};
|
|
213
|
+
this.setActiveMergeConflictState(actions, markerRows);
|
|
214
|
+
if (this.workerManager != null) this.hunksRenderer.renderDiff(fileDiff);
|
|
215
|
+
else this.render({ forceRender: true });
|
|
216
|
+
this.options.onMergeConflictResolve?.(file, payload);
|
|
193
217
|
}
|
|
194
|
-
|
|
218
|
+
setActiveMergeConflictState(actions = this.conflictActions, markerRows = this.markerRows) {
|
|
195
219
|
this.conflictActions = actions;
|
|
196
|
-
|
|
220
|
+
this.markerRows = markerRows;
|
|
221
|
+
if (this.computedCache.fileDiff != null && this.hunksRenderer instanceof UnresolvedFileHunksRenderer) this.hunksRenderer.setConflictState(this.options.mergeConflictActionsType === "none" ? [] : actions, markerRows, this.computedCache.fileDiff);
|
|
197
222
|
}
|
|
198
223
|
handleMergeConflictActionClick = (target) => {
|
|
199
224
|
const action = this.conflictActions[target.conflictIndex];
|
|
@@ -216,7 +241,8 @@ var UnresolvedFile = class extends FileDiff {
|
|
|
216
241
|
this.resolveConflictAndRender(target.conflictIndex, target.resolution);
|
|
217
242
|
};
|
|
218
243
|
renderMergeConflictActionSlots() {
|
|
219
|
-
|
|
244
|
+
const { fileDiff } = this.computedCache;
|
|
245
|
+
if (this.isContainerManaged || this.fileContainer == null || typeof this.options.mergeConflictActionsType !== "function" || this.conflictActions.length === 0 || fileDiff == null) {
|
|
220
246
|
this.clearMergeConflictActionCache();
|
|
221
247
|
return;
|
|
222
248
|
}
|
|
@@ -231,12 +257,12 @@ var UnresolvedFile = class extends FileDiff {
|
|
|
231
257
|
});
|
|
232
258
|
throw new Error("UnresolvedFile.renderMergeConflictActionSlots: conflictIndex and conflictAction don't match");
|
|
233
259
|
}
|
|
234
|
-
const anchor = getMergeConflictActionAnchor(action);
|
|
260
|
+
const anchor = getMergeConflictActionAnchor(action, fileDiff);
|
|
235
261
|
if (anchor == null) continue;
|
|
236
262
|
const conflictIndex = action.conflictIndex;
|
|
237
263
|
const slotName = getMergeConflictActionSlotName({
|
|
238
|
-
|
|
239
|
-
|
|
264
|
+
hunkIndex: anchor.hunkIndex,
|
|
265
|
+
lineIndex: anchor.lineIndex,
|
|
240
266
|
conflictIndex
|
|
241
267
|
});
|
|
242
268
|
const id = `${actionIndex}-${slotName}`;
|
|
@@ -278,7 +304,84 @@ var UnresolvedFile = class extends FileDiff {
|
|
|
278
304
|
this.conflictActionCache.clear();
|
|
279
305
|
}
|
|
280
306
|
};
|
|
307
|
+
function rebuildFileAndActions({ fileDiff, previousActions, resolvedConflictIndex, previousFile, resolution }) {
|
|
308
|
+
const resolvedAction = previousActions[resolvedConflictIndex];
|
|
309
|
+
if (resolvedAction == null) throw new Error("rebuildFileAndActions: missing resolved action for unresolved file rebuild");
|
|
310
|
+
const actions = updateConflictActionsAfterResolution(previousActions, resolvedConflictIndex, resolvedAction, resolution);
|
|
311
|
+
const markerRows = buildMergeConflictMarkerRows(fileDiff, actions);
|
|
312
|
+
return {
|
|
313
|
+
file: rebuildUnresolvedFile({
|
|
314
|
+
fileDiff,
|
|
315
|
+
resolvedAction,
|
|
316
|
+
resolvedConflictIndex,
|
|
317
|
+
previousFile,
|
|
318
|
+
resolution
|
|
319
|
+
}),
|
|
320
|
+
actions,
|
|
321
|
+
markerRows
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function rebuildUnresolvedFile({ resolvedAction, resolvedConflictIndex, previousFile, fileDiff, resolution }) {
|
|
325
|
+
const lines = splitFileContents(previousFile?.contents ?? "");
|
|
326
|
+
const { conflict } = resolvedAction;
|
|
327
|
+
const replacementLines = getResolvedConflictReplacementLines(lines, conflict, resolution);
|
|
328
|
+
const contents = [
|
|
329
|
+
...lines.slice(0, conflict.startLineIndex),
|
|
330
|
+
...replacementLines,
|
|
331
|
+
...lines.slice(conflict.endLineIndex + 1)
|
|
332
|
+
].join("");
|
|
333
|
+
return {
|
|
334
|
+
name: previousFile?.name ?? fileDiff.name,
|
|
335
|
+
contents,
|
|
336
|
+
cacheKey: previousFile?.cacheKey != null ? `${previousFile.cacheKey}:mc-${resolvedConflictIndex}-${resolution}` : void 0
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function getResolvedConflictReplacementLines(lines, conflict, resolution) {
|
|
340
|
+
const currentLines = lines.slice(conflict.startLineIndex + 1, conflict.baseMarkerLineIndex ?? conflict.separatorLineIndex);
|
|
341
|
+
const incomingLines = lines.slice(conflict.separatorLineIndex + 1, conflict.endLineIndex);
|
|
342
|
+
if (resolution === "current") return currentLines;
|
|
343
|
+
if (resolution === "incoming") return incomingLines;
|
|
344
|
+
return [...currentLines, ...incomingLines];
|
|
345
|
+
}
|
|
346
|
+
function updateConflictActionsAfterResolution(previousActions, resolvedConflictIndex, resolvedAction, resolution) {
|
|
347
|
+
const lineDelta = getResolvedConflictLineDelta(resolvedAction.conflict, resolution);
|
|
348
|
+
return previousActions.map((action, index) => {
|
|
349
|
+
if (index === resolvedConflictIndex) return;
|
|
350
|
+
if (action == null) return;
|
|
351
|
+
if (action.conflict.startLineIndex > resolvedAction.conflict.endLineIndex) return {
|
|
352
|
+
...action,
|
|
353
|
+
conflict: shiftMergeConflictRegion(action.conflict, lineDelta)
|
|
354
|
+
};
|
|
355
|
+
return action;
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
function getResolvedConflictLineDelta(conflict, resolution) {
|
|
359
|
+
const currentLineCount = (conflict.baseMarkerLineIndex ?? conflict.separatorLineIndex) - conflict.startLineIndex - 1;
|
|
360
|
+
const incomingLineCount = conflict.endLineIndex - conflict.separatorLineIndex - 1;
|
|
361
|
+
return (resolution === "current" ? currentLineCount : resolution === "incoming" ? incomingLineCount : currentLineCount + incomingLineCount) - (conflict.endLineIndex - conflict.startLineIndex + 1);
|
|
362
|
+
}
|
|
363
|
+
function shiftMergeConflictRegion(conflict, lineDelta) {
|
|
364
|
+
return {
|
|
365
|
+
...conflict,
|
|
366
|
+
startLineIndex: conflict.startLineIndex + lineDelta,
|
|
367
|
+
startLineNumber: conflict.startLineNumber + lineDelta,
|
|
368
|
+
separatorLineIndex: conflict.separatorLineIndex + lineDelta,
|
|
369
|
+
separatorLineNumber: conflict.separatorLineNumber + lineDelta,
|
|
370
|
+
endLineIndex: conflict.endLineIndex + lineDelta,
|
|
371
|
+
endLineNumber: conflict.endLineNumber + lineDelta,
|
|
372
|
+
baseMarkerLineIndex: conflict.baseMarkerLineIndex != null ? conflict.baseMarkerLineIndex + lineDelta : void 0,
|
|
373
|
+
baseMarkerLineNumber: conflict.baseMarkerLineNumber != null ? conflict.baseMarkerLineNumber + lineDelta : void 0
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
function getUnresolvedDiffHunksRendererOptions(options, baseOptions) {
|
|
377
|
+
return {
|
|
378
|
+
...baseOptions,
|
|
379
|
+
...options,
|
|
380
|
+
hunkSeparators: typeof options?.hunkSeparators === "function" ? "custom" : options?.hunkSeparators,
|
|
381
|
+
mergeConflictActionsType: typeof options?.mergeConflictActionsType === "function" ? "custom" : options?.mergeConflictActionsType
|
|
382
|
+
};
|
|
383
|
+
}
|
|
281
384
|
|
|
282
385
|
//#endregion
|
|
283
|
-
export { UnresolvedFile };
|
|
386
|
+
export { UnresolvedFile, getUnresolvedDiffHunksRendererOptions };
|
|
284
387
|
//# sourceMappingURL=UnresolvedFile.js.map
|