@pierre/diffs 1.1.3 → 1.1.5

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.
@@ -1 +1 @@
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,IAAAA,EAGYG,WAHc,EAAA,QAAAF,EAGSC,cAHT,CAGwBD,WAHxB,CAAA,CAAA,EAAA,OAAA;EAAyBN,wBAAAA,CAAAA,EAIhCU,8BAJgCV,CAIDM,WAJCN,CAAAA;EAAkDM,qBAAAA,EAAAA,OAAAA,EAK7ET,0BAL6ES,EAAAA,QAAAA,EAKvCC,cALuCD,CAKxBA,WALwBA,CAAAA,CAAAA,EAAAA,IAAAA;EAAfC,sBAAAA,EAAAA,IAAAA,EAMhEZ,YANgEY,EAAAA,OAAAA,EAMzCV,0BANyCU,CAAAA,EAAAA,IAAAA;EAAgCC,eAAAA,CAAAA,EAAAA,MAAAA;;AAA8B,UAS/IK,yBAT+I,CAAA,WAAA,CAAA,SAShGD,IATgG,CAS3FR,mBAT2F,CASvEE,WATuE,CAAA,EAAA,SAAA,GAAA,SAAA,CAAA,CAAA;EACpJI,IAAAA,CAAAA,EASDf,YATCe;EACKC,OAAAA,CAAAA,EAAAA,CASFX,uBATuBM,GAAAA,SAAAA,CAAA,EAAA;EAA2CA,UAAAA,CAAAA,EAUhER,sBAVgEQ,EAAAA;;AACzDE,UAWPM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AxBhJK,CAAAA,CAAAA,EAwB+JjB,kCAxB/JiB"}
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,IAAAA,EAGYG,WAHc,EAAA,QAAAF,EAGSC,cAHT,CAGwBD,WAHxB,CAAA,CAAA,EAAA,OAAA;EAAyBN,wBAAAA,CAAAA,EAIhCU,8BAJgCV,CAIDM,WAJCN,CAAAA;EAAkDM,qBAAAA,EAAAA,OAAAA,EAK7ET,0BAL6ES,EAAAA,QAAAA,EAKvCC,cALuCD,CAKxBA,WALwBA,CAAAA,CAAAA,EAAAA,IAAAA;EAAfC,sBAAAA,EAAAA,IAAAA,EAMhEZ,YANgEY,EAAAA,OAAAA,EAMzCV,0BANyCU,CAAAA,EAAAA,IAAAA;EAAgCC,eAAAA,CAAAA,EAAAA,MAAAA;;AAA8B,UAS/IK,yBAT+I,CAAA,WAAA,CAAA,SAShGD,IATgG,CAS3FR,mBAT2F,CASvEE,WATuE,CAAA,EAAA,SAAA,GAAA,SAAA,CAAA,CAAA;EACpJI,IAAAA,CAAAA,EASDf,YATCe;EACKC,OAAAA,CAAAA,EAAAA,CASFX,uBATuBM,GAAAA,SAAA,CAAA,EAAA;EAA2CA,UAAAA,CAAAA,EAUhER,sBAVgEQ,EAAAA;;AACzDE,UAWPM,4BAXON,CAAAA,WAAAA,CAAAA,SAW2CI,IAX3CJ,CAWgDK,yBAXhDL,CAW0EF,WA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FAULT_THEMES } from "../constants.js";
1
+ import { DEFAULT_THEMES, UNSAFE_CSS_ATTRIBUTE } from "../constants.js";
2
2
  import { pluckInteractionOptions } from "../managers/InteractionManager.js";
3
3
  import { splitFileContents } from "../utils/splitFileContents.js";
4
4
  import { areFilesEqual } from "../utils/areFilesEqual.js";
5
5
  import { createAnnotationWrapperNode } from "../utils/createAnnotationWrapperNode.js";
6
+ import { prerenderHTMLIfNecessary } from "../utils/prerenderHTMLIfNecessary.js";
6
7
  import { FileDiff } from "./FileDiff.js";
7
8
  import { getMergeConflictActionSlotName } from "../utils/getMergeConflictActionSlotName.js";
8
9
  import { buildMergeConflictMarkerRows, getMergeConflictActionAnchor, parseMergeConflictDiffFromFile } from "../utils/parseMergeConflictDiffFromFile.js";
@@ -115,21 +116,59 @@ var UnresolvedFile = class extends FileDiff {
115
116
  };
116
117
  }
117
118
  hydrate(props) {
118
- const { file, fileDiff, actions, markerRows, lineAnnotations, preventEmit = false,...rest } = props;
119
+ const { file, fileDiff, actions, markerRows, lineAnnotations, fileContainer, prerenderedHTML, preventEmit = false } = props;
119
120
  const source = this.getOrComputeDiff({
120
121
  file,
121
122
  fileDiff,
122
123
  actions,
123
124
  markerRows
124
125
  });
126
+ const { overflow = "scroll" } = this.options;
125
127
  if (source == null) return;
128
+ prerenderHTMLIfNecessary(fileContainer, prerenderedHTML);
129
+ for (const element of fileContainer.shadowRoot?.children ?? []) {
130
+ if (element instanceof SVGElement) {
131
+ this.spriteSVG = element;
132
+ continue;
133
+ }
134
+ if (!(element instanceof HTMLElement)) continue;
135
+ if (element instanceof HTMLPreElement) {
136
+ this.pre = element;
137
+ for (const code of element.children) {
138
+ if (!(code instanceof HTMLElement) || code.tagName.toLowerCase() !== "code") continue;
139
+ if ("deletions" in code.dataset) this.codeDeletions = code;
140
+ if ("additions" in code.dataset) this.codeAdditions = code;
141
+ if ("unified" in code.dataset) this.codeUnified = code;
142
+ }
143
+ continue;
144
+ }
145
+ if ("diffsHeader" in element.dataset) {
146
+ this.headerElement = element;
147
+ continue;
148
+ }
149
+ if (element instanceof HTMLStyleElement && element.hasAttribute(UNSAFE_CSS_ATTRIBUTE)) {
150
+ this.unsafeCSSStyle = element;
151
+ continue;
152
+ }
153
+ }
154
+ if (this.pre != null) this.syncCodeNodesFromPre(this.pre);
126
155
  this.setActiveMergeConflictState(source.actions, source.markerRows);
127
- super.hydrate({
128
- ...rest,
129
- fileDiff: source.fileDiff,
130
- lineAnnotations,
156
+ if (this.pre == null) this.render({
157
+ ...props,
131
158
  preventEmit: true
132
159
  });
160
+ else {
161
+ this.fileContainer = fileContainer;
162
+ delete this.pre.dataset.dehydrated;
163
+ this.lineAnnotations = lineAnnotations ?? this.lineAnnotations;
164
+ this.fileDiff = source.fileDiff;
165
+ this.hunksRenderer.hydrate(this.fileDiff);
166
+ this.renderAnnotations();
167
+ this.renderGutterUtility();
168
+ this.injectUnsafeCSS();
169
+ this.interactionManager.setup(this.pre);
170
+ this.resizeManager.setup(this.pre, overflow === "wrap");
171
+ }
133
172
  this.renderMergeConflictActionSlots();
134
173
  if (!preventEmit) this.emitPostRender();
135
174
  }
@@ -1 +1 @@
1
- {"version":3,"file":"UnresolvedFile.js","names":["options: UnresolvedFileOptions<LAnnotation>","resolveConflictDiff","payload: MergeConflictActionPayload"],"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} 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 { splitFileContents } from '../utils/splitFileContents';\nimport type { WorkerPoolManager } from '../worker';\nimport {\n FileDiff,\n type FileDiffOptions,\n type FileDiffRenderProps,\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'\n> {\n onPostRender?(\n node: HTMLElement,\n instance: UnresolvedFile<LAnnotation>\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<LAnnotation> extends Omit<\n FileDiffRenderProps<LAnnotation>,\n 'oldFile' | 'newFile'\n> {\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 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\n const hunkSeparators = this.options.hunkSeparators ?? 'line-info';\n this.interactionManager.setOptions(\n pluckInteractionOptions(\n this.options,\n typeof hunkSeparators === 'function' ||\n hunkSeparators === 'line-info' ||\n hunkSeparators === 'line-info-basic'\n ? this.expandHunk\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.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 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;\n }\n this.setActiveMergeConflictState(source.actions, source.markerRows);\n super.hydrate({\n ...rest,\n fileDiff: source.fileDiff,\n lineAnnotations,\n preventEmit: true,\n });\n this.renderMergeConflictActionSlots();\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 let {\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 undefined;\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 undefined;\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\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 return {\n ...baseOptions,\n ...options,\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":";;;;;;;;;;;;;AA8GA,IAAI,aAAa;AAEjB,IAAa,iBAAb,cAEU,SAAsB;CAC9B,AAAkB,OAAe,mBAAmB,EAAE;CACtD,AAAU,gBAAyC;EACjD,MAAM;EACN,UAAU;EACV,SAAS;EACT,YAAY;EACb;CACD,AAAQ,kBAA2D,EAAE;CACrE,AAAQ,aAAuC,EAAE;CACjD,AAAQ,sCACN,IAAI,KAAK;CAEX,YACE,AAAgBA,UAA8C,EAC5D,OAAO,gBACR,EACD,eACA,qBAAqB,OACrB;AACA,QAAM,QAAW,eAAe,mBAAmB;EANnC;AAOhB,OAAK,WAAW,QAAQ;;CAG1B,AAAS,WACP,SACM;AACN,MAAI,WAAW,KACb;AAGF,MACE,QAAQ,yBAAyB,QACjC,QAAQ,0BAA0B,KAElC,OAAM,IAAI,MACR,kHACD;AAGH,OAAK,UAAU;AACf,OAAK,cAAc,WAAW,KAAK,wBAAwB,QAAQ,CAAC;EAEpE,MAAM,iBAAiB,KAAK,QAAQ,kBAAkB;AACtD,OAAK,mBAAmB,WACtB,wBACE,KAAK,SACL,OAAO,mBAAmB,cACxB,mBAAmB,eACnB,mBAAmB,oBACjB,KAAK,aACL,QACJ,KAAK,cACL,KAAK,+BACN,CACF;;CAGH,AAAmB,oBACjB,SAC0C;AAM1C,SALiB,IAAI,4BACnB,KAAK,wBAAwB,QAAQ,EACrC,KAAK,uBACL,KAAK,cACN;;CAIH,AAAmB,wBACjB,SACoC;AACpC,SAAO,sCAAsC,SAAS,KAAK,QAAQ;;CAGrE,AAAmB,uBACjB,KACA,QACM;AACN,QAAM,uBAAuB,KAAK,QAAQ,EACxC,2BAA2B,IAC5B,C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GJ,SAAS,6BACP,UACA,YACQ;CACR,MAAM,oBACH,SAAS,uBAAuB,SAAS,sBAC1C,SAAS,iBACT;CACF,MAAM,oBACJ,SAAS,eAAe,SAAS,qBAAqB;AAQxD,SANE,eAAe,YACX,mBACA,eAAe,aACb,oBACA,mBAAmB,sBACD,SAAS,eAAe,SAAS,iBAAiB;;AAI9E,SAAS,yBACP,UACA,WACqB;AACrB,QAAO;EACL,GAAG;EACH,gBAAgB,SAAS,iBAAiB;EAC1C,iBAAiB,SAAS,kBAAkB;EAC5C,oBAAoB,SAAS,qBAAqB;EAClD,qBAAqB,SAAS,sBAAsB;EACpD,cAAc,SAAS,eAAe;EACtC,eAAe,SAAS,gBAAgB;EACxC,qBACE,SAAS,uBAAuB,OAC5B,SAAS,sBAAsB,YAC/B;EACN,sBACE,SAAS,wBAAwB,OAC7B,SAAS,uBAAuB,YAChC;EACP;;AAKH,SAAgB,sCACd,SACA,aACoC;AACpC,QAAO;EACL,GAAG;EACH,GAAG;EACH,gBACE,OAAO,SAAS,mBAAmB,aAC/B,WACA,SAAS;EACf,0BACE,OAAO,SAAS,6BAA6B,aACzC,WACA,SAAS;EAChB"}
1
+ {"version":3,"file":"UnresolvedFile.js","names":["options: UnresolvedFileOptions<LAnnotation>","resolveConflictDiff","payload: MergeConflictActionPayload"],"sources":["../../src/components/UnresolvedFile.ts"],"sourcesContent":["import { DEFAULT_THEMES, UNSAFE_CSS_ATTRIBUTE } 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} 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 { prerenderHTMLIfNecessary } from '../utils/prerenderHTMLIfNecessary';\nimport { resolveConflict as resolveConflictDiff } from '../utils/resolveConflict';\nimport { splitFileContents } from '../utils/splitFileContents';\nimport type { WorkerPoolManager } from '../worker';\nimport {\n FileDiff,\n type FileDiffOptions,\n type FileDiffRenderProps,\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'\n> {\n onPostRender?(\n node: HTMLElement,\n instance: UnresolvedFile<LAnnotation>\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<LAnnotation> extends Omit<\n FileDiffRenderProps<LAnnotation>,\n 'oldFile' | 'newFile'\n> {\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 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\n const hunkSeparators = this.options.hunkSeparators ?? 'line-info';\n this.interactionManager.setOptions(\n pluckInteractionOptions(\n this.options,\n typeof hunkSeparators === 'function' ||\n hunkSeparators === 'line-info' ||\n hunkSeparators === 'line-info-basic'\n ? this.expandHunk\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.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 const { overflow = 'scroll' } = this.options;\n if (source == null) {\n return;\n }\n prerenderHTMLIfNecessary(fileContainer, prerenderedHTML);\n for (const element of fileContainer.shadowRoot?.children ?? []) {\n if (element instanceof SVGElement) {\n this.spriteSVG = element;\n continue;\n }\n if (!(element instanceof HTMLElement)) {\n continue;\n }\n if (element instanceof HTMLPreElement) {\n this.pre = element;\n for (const code of element.children) {\n if (\n !(code instanceof HTMLElement) ||\n code.tagName.toLowerCase() !== 'code'\n ) {\n continue;\n }\n if ('deletions' in code.dataset) {\n this.codeDeletions = code;\n }\n if ('additions' in code.dataset) {\n this.codeAdditions = code;\n }\n if ('unified' in code.dataset) {\n this.codeUnified = code;\n }\n }\n continue;\n }\n if ('diffsHeader' in element.dataset) {\n this.headerElement = element;\n continue;\n }\n if (\n element instanceof HTMLStyleElement &&\n element.hasAttribute(UNSAFE_CSS_ATTRIBUTE)\n ) {\n this.unsafeCSSStyle = element;\n continue;\n }\n }\n if (this.pre != null) {\n this.syncCodeNodesFromPre(this.pre);\n }\n this.setActiveMergeConflictState(source.actions, source.markerRows);\n // If we have no pre tag, then we should render\n if (this.pre == null) {\n this.render({ ...props, preventEmit: true });\n }\n // Otherwise orchestrate our setup\n else {\n this.fileContainer = fileContainer;\n delete this.pre.dataset.dehydrated;\n\n this.lineAnnotations = lineAnnotations ?? this.lineAnnotations;\n this.fileDiff = source.fileDiff;\n\n this.hunksRenderer.hydrate(this.fileDiff);\n this.renderAnnotations();\n this.renderGutterUtility();\n this.injectUnsafeCSS();\n this.interactionManager.setup(this.pre);\n this.resizeManager.setup(this.pre, overflow === 'wrap');\n }\n\n this.renderMergeConflictActionSlots();\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 let {\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 undefined;\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 undefined;\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\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 return {\n ...baseOptions,\n ...options,\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":";;;;;;;;;;;;;;AA+GA,IAAI,aAAa;AAEjB,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,SAAS,sBAAsB,YAC/B;EACN,sBACE,SAAS,wBAAwB,OAC7B,SAAS,uBAAuB,YAChC;EACP;;AAKH,SAAgB,sCACd,SACA,aACoC;AACpC,QAAO;EACL,GAAG;EACH,GAAG;EACH,gBACE,OAAO,SAAS,mBAAmB,aAC/B,WACA,SAAS;EACf,0BACE,OAAO,SAAS,6BAA6B,aACzC,WACA,SAAS;EAChB"}
@@ -1 +1 @@
1
- {"version":3,"file":"VirtulizerDevelopment.d.ts","names":["AdvancedVirtualizer","Virtualizer","_1","sideEffect"],"sources":["../../src/components/VirtulizerDevelopment.d.ts"],"sourcesContent":["import type { AdvancedVirtualizer } from './AdvancedVirtualizer';\nimport type { Virtualizer } from './Virtualizer';\n\n// FIXME(amadeus): REMOVE ME AFTER RELEASING VIRTUALIZATION\ndeclare global {\n interface Window {\n // oxlint-disable-next-line typescript/no-explicit-any\n __INSTANCE?: AdvancedVirtualizer<any> | Virtualizer;\n __TOGGLE?: () => void;\n __LOG?: boolean;\n }\n}\n"],"mappings":";;;;;AACiD,QAAAE,MAAA,CAAA;EAAA,UAAA,MAAA,CAAA;;IAMMC,UAAAD,CAAA,EAAtCF,mBAAsC,CAAA,GAAA,CAAA,GAAXC,WAAW;IAAA,QAAA,CAAA,EAAA,GAAA,GAAA,IAAA"}
1
+ {"version":3,"file":"VirtulizerDevelopment.d.ts","names":["AdvancedVirtualizer","Virtualizer","_0","sideEffect"],"sources":["../../src/components/VirtulizerDevelopment.d.ts"],"sourcesContent":["import type { AdvancedVirtualizer } from './AdvancedVirtualizer';\nimport type { Virtualizer } from './Virtualizer';\n\n// FIXME(amadeus): REMOVE ME AFTER RELEASING VIRTUALIZATION\ndeclare global {\n interface Window {\n // oxlint-disable-next-line typescript/no-explicit-any\n __INSTANCE?: AdvancedVirtualizer<any> | Virtualizer;\n __TOGGLE?: () => void;\n __LOG?: boolean;\n }\n}\n"],"mappings":";;;;;AACiD,QAAAE,MAAA,CAAA;EAAA,UAAA,MAAA,CAAA;;IAMMC,UAAAD,CAAA,EAAtCF,mBAAsC,CAAA,GAAA,CAAA,GAAXC,WAAW;IAAA,QAAA,CAAA,EAAA,GAAA,GAAA,IAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"jsx.d.ts","names":["DIFFS_TAG_NAME","_0","HTMLElement","React","HTMLAttributes","DetailedHTMLProps","sideEffect"],"sources":["../../src/react/jsx.d.ts"],"sourcesContent":["import 'react';\nimport type { DIFFS_TAG_NAME } from '../constants';\n\ndeclare module 'react' {\n namespace JSX {\n interface IntrinsicElements {\n [DIFFS_TAG_NAME]: React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLElement>,\n HTMLElement\n >;\n }\n }\n}\n"],"mappings":";;;;;EACmD,UAAA,GAAA,CAAA;IAAA,UAAA,iBAAA,CAAA;OAK5CA,cAAAA,CAL4C,EAK3BG,KAAAA,CAAME,iBALqB,CAM3CF,KAAAA,CAAMC,cAAeF,CAAAA,WAAAA,CAAAA,EACrBA,WADME,CACNF;IAFgBC;EAAjBH"}
1
+ {"version":3,"file":"jsx.d.ts","names":["DIFFS_TAG_NAME","_1","HTMLElement","React","HTMLAttributes","DetailedHTMLProps","sideEffect"],"sources":["../../src/react/jsx.d.ts"],"sourcesContent":["import 'react';\nimport type { DIFFS_TAG_NAME } from '../constants';\n\ndeclare module 'react' {\n namespace JSX {\n interface IntrinsicElements {\n [DIFFS_TAG_NAME]: React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLElement>,\n HTMLElement\n >;\n }\n }\n}\n"],"mappings":";;;;;EACmD,UAAA,GAAA,CAAA;IAAA,UAAA,iBAAA,CAAA;OAK5CA,cAAAA,CAL4C,EAK3BG,KAAAA,CAAME,iBALqB,CAM3CF,KAAAA,CAAMC,cAAeF,CAAAA,WAAAA,CAAAA,EACrBA,WADME,CACNF;IAFgBC;EAAjBH"}
@@ -1,13 +1,13 @@
1
1
  import { DiffLineAnnotation, FileContents, FileDiffMetadata, MergeConflictMarkerRow } from "../../types.js";
2
2
  import { GetHoveredLineResult, SelectedLineRange } from "../../managers/InteractionManager.js";
3
3
  import { MergeConflictDiffAction } from "../../utils/parseMergeConflictDiffFromFile.js";
4
- import { UnresolvedFileHunksRendererOptions } from "../../renderers/UnresolvedFileHunksRenderer.js";
5
4
  import { UnresolvedFile } from "../../components/UnresolvedFile.js";
5
+ import { UnresolvedFileReactOptions } from "../UnresolvedFile.js";
6
6
 
7
7
  //#region src/react/utils/useUnresolvedFileInstance.d.ts
8
8
  interface UseUnresolvedFileInstanceProps<LAnnotation> {
9
9
  file: FileContents;
10
- options?: Omit<UnresolvedFileHunksRendererOptions, 'onMergeConflictAction'>;
10
+ options?: UnresolvedFileReactOptions<LAnnotation>;
11
11
  lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;
12
12
  selectedLines: SelectedLineRange | null | undefined;
13
13
  prerenderedHTML: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"useUnresolvedFileInstance.d.ts","names":["UnresolvedFile","GetHoveredLineResult","SelectedLineRange","UnresolvedFileHunksRendererOptions","DiffLineAnnotation","FileContents","FileDiffMetadata","MergeConflictMarkerRow","MergeConflictDiffAction","UseUnresolvedFileInstanceProps","LAnnotation","Omit","UseUnresolvedFileInstanceReturn","HTMLElement","useUnresolvedFileInstance","file","options","lineAnnotations","selectedLines","prerenderedHTML","hasConflictUtility","hasGutterRenderUtility"],"sources":["../../../src/react/utils/useUnresolvedFileInstance.d.ts"],"sourcesContent":["import { UnresolvedFile } from '../../components/UnresolvedFile';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../../managers/InteractionManager';\nimport type { UnresolvedFileHunksRendererOptions } from '../../renderers/UnresolvedFileHunksRenderer';\nimport type { DiffLineAnnotation, FileContents, FileDiffMetadata, MergeConflictMarkerRow } from '../../types';\nimport { type MergeConflictDiffAction } from '../../utils/parseMergeConflictDiffFromFile';\ninterface UseUnresolvedFileInstanceProps<LAnnotation> {\n file: FileContents;\n options?: Omit<UnresolvedFileHunksRendererOptions, 'onMergeConflictAction'>;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n hasConflictUtility: boolean;\n hasGutterRenderUtility: boolean;\n}\ninterface UseUnresolvedFileInstanceReturn<LAnnotation> {\n fileDiff: FileDiffMetadata;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance(): UnresolvedFile<LAnnotation> | undefined;\n}\nexport declare function useUnresolvedFileInstance<LAnnotation>({ file, options, lineAnnotations, selectedLines, prerenderedHTML, hasConflictUtility, hasGutterRenderUtility }: UseUnresolvedFileInstanceProps<LAnnotation>): UseUnresolvedFileInstanceReturn<LAnnotation>;\nexport {};\n//# sourceMappingURL=useUnresolvedFileInstance.d.ts.map"],"mappings":";;;;;;;UAKUS;QACAJ;EADAI,OAAAA,CAAAA,EAEIE,IAFJF,CAESN,kCAFqBO,EAAAA,uBAAA,CAAA;EAC9BL,eAAAA,EAEWD,kBAFXC,CAE8BK,WAF9BL,CAAAA,EAAAA,GAAAA,SAAAA;EACSF,aAAAA,EAEAD,iBAFAC,GAAAA,IAAAA,GAAAA,SAAAA;EAALQ,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAC0BD,kBAAAA,EAAAA,OAAAA;EAAnBN,sBAAAA,EAAAA,OAAAA;;UAMXQ,+BAL0B,CAAA,WAAA,CAAA,CAAA;EAK1BA,QAAAA,EACIN,gBADJM;EACIN,OAAAA,EAAAA,CACAE,uBADAF,GAAAA,SAAAA,CAAAA,EAAAA;EACAE,UAAAA,EACED,sBADFC,EAAAA;EACED,GAAAA,CAAAA,IAAAA,EACFM,WADEN,GAAAA,IAAAA,CAAAA,EAAAA,IAAAA;EACFM,cAAAA,EAAAA,EACQZ,oBADRY,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;EACQZ,WAAAA,EAAAA,EACHD,cADGC,CACYS,WADZT,CAAAA,GAAAA,SAAAA;;AACHD,iBAEKc,yBAFLd,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,IAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,eAAAA;EAAAA,kBAAAA;EAAAA;AAAAA,CAAAA,EAE4JS,8BAF5JT,CAE2LU,WAF3LV,CAAAA,CAAAA,EAE0MY,+BAF1MZ,CAE0OU,WAF1OV,CAAAA"}
1
+ {"version":3,"file":"useUnresolvedFileInstance.d.ts","names":["UnresolvedFile","GetHoveredLineResult","SelectedLineRange","DiffLineAnnotation","FileContents","FileDiffMetadata","MergeConflictMarkerRow","MergeConflictDiffAction","UnresolvedFileReactOptions","UseUnresolvedFileInstanceProps","LAnnotation","UseUnresolvedFileInstanceReturn","HTMLElement","useUnresolvedFileInstance","file","options","lineAnnotations","selectedLines","prerenderedHTML","hasConflictUtility","hasGutterRenderUtility"],"sources":["../../../src/react/utils/useUnresolvedFileInstance.d.ts"],"sourcesContent":["import { UnresolvedFile } from '../../components/UnresolvedFile';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../../managers/InteractionManager';\nimport type { DiffLineAnnotation, FileContents, FileDiffMetadata, MergeConflictMarkerRow } from '../../types';\nimport { type MergeConflictDiffAction } from '../../utils/parseMergeConflictDiffFromFile';\nimport type { UnresolvedFileReactOptions } from '../UnresolvedFile';\ninterface UseUnresolvedFileInstanceProps<LAnnotation> {\n file: FileContents;\n options?: UnresolvedFileReactOptions<LAnnotation>;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n hasConflictUtility: boolean;\n hasGutterRenderUtility: boolean;\n}\ninterface UseUnresolvedFileInstanceReturn<LAnnotation> {\n fileDiff: FileDiffMetadata;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance(): UnresolvedFile<LAnnotation> | undefined;\n}\nexport declare function useUnresolvedFileInstance<LAnnotation>({ file, options, lineAnnotations, selectedLines, prerenderedHTML, hasConflictUtility, hasGutterRenderUtility }: UseUnresolvedFileInstanceProps<LAnnotation>): UseUnresolvedFileInstanceReturn<LAnnotation>;\nexport {};\n//# sourceMappingURL=useUnresolvedFileInstance.d.ts.map"],"mappings":";;;;;;;UAKUS;QACAL;EADAK,OAAAA,CAAAA,EAEID,0BAF0B,CAECE,WAFDA,CAAAA;EAC9BN,eAAAA,EAEWD,kBAFXC,CAE8BM,WAF9BN,CAAAA,EAAAA,GAAAA,SAAAA;EAC+BM,aAAAA,EAEtBR,iBAFsBQ,GAAAA,IAAAA,GAAAA,SAAAA;EAA3BF,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAC0BE,kBAAAA,EAAAA,OAAAA;EAAnBP,sBAAAA,EAAAA,OAAAA;;UAMXQ,+BAL0B,CAAA,WAAA,CAAA,CAAA;EAK1BA,QAAAA,EACIN,gBADJM;EACIN,OAAAA,EAAAA,CACAE,uBADAF,GAAAA,SAAAA,CAAAA,EAAAA;EACAE,UAAAA,EACED,sBADFC,EAAAA;EACED,GAAAA,CAAAA,IAAAA,EACFM,WADEN,GAAAA,IAAAA,CAAAA,EAAAA,IAAAA;EACFM,cAAAA,EAAAA,EACQX,oBADRW,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;EACQX,WAAAA,EAAAA,EACHD,cADGC,CACYS,WADZT,CAAAA,GAAAA,SAAAA;;AACHD,iBAEKa,yBAFLb,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,IAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,eAAAA;EAAAA,kBAAAA;EAAAA;AAAAA,CAAAA,EAE4JS,8BAF5JT,CAE2LU,WAF3LV,CAAAA,CAAAA,EAE0MW,+BAF1MX,CAE0OU,WAF1OV,CAAAA"}
@@ -10,7 +10,7 @@ import { useCallback, useContext, useEffect, useLayoutEffect, useRef, useState }
10
10
  const useIsometricEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
11
11
  function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLines, prerenderedHTML, hasConflictUtility, hasGutterRenderUtility }) {
12
12
  const [{ fileDiff, actions, markerRows }, setState] = useState(() => {
13
- const { fileDiff: fileDiff$1, actions: actions$1, markerRows: markerRows$1 } = parseMergeConflictDiffFromFile(file);
13
+ const { fileDiff: fileDiff$1, actions: actions$1, markerRows: markerRows$1 } = parseMergeConflictDiffFromFile(file, options?.maxContextLines);
14
14
  return {
15
15
  fileDiff: fileDiff$1,
16
16
  actions: actions$1,
@@ -1 +1 @@
1
- {"version":3,"file":"useUnresolvedFileInstance.js","names":["fileDiff","actions","markerRows","UnresolvedFileClass"],"sources":["../../../src/react/utils/useUnresolvedFileInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport {\n UnresolvedFile,\n UnresolvedFile as UnresolvedFileClass,\n type UnresolvedFileOptions,\n} from '../../components/UnresolvedFile';\nimport type {\n GetHoveredLineResult,\n SelectedLineRange,\n} from '../../managers/InteractionManager';\nimport type { UnresolvedFileHunksRendererOptions } from '../../renderers/UnresolvedFileHunksRenderer';\nimport type {\n DiffLineAnnotation,\n FileContents,\n FileDiffMetadata,\n MergeConflictActionPayload,\n MergeConflictMarkerRow,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport {\n type MergeConflictDiffAction,\n parseMergeConflictDiffFromFile,\n} from '../../utils/parseMergeConflictDiffFromFile';\nimport { noopRender } from '../constants';\nimport { WorkerPoolContext } from '../WorkerPoolContext';\nimport { useStableCallback } from './useStableCallback';\n\nconst useIsometricEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface UseUnresolvedFileInstanceProps<LAnnotation> {\n file: FileContents;\n options?: Omit<UnresolvedFileHunksRendererOptions, 'onMergeConflictAction'>;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n hasConflictUtility: boolean;\n hasGutterRenderUtility: boolean;\n}\n\ninterface UseUnresolvedFileInstanceReturn<LAnnotation> {\n fileDiff: FileDiffMetadata;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance(): UnresolvedFile<LAnnotation> | undefined;\n}\n\nexport function useUnresolvedFileInstance<LAnnotation>({\n file,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n hasConflictUtility,\n hasGutterRenderUtility,\n}: UseUnresolvedFileInstanceProps<LAnnotation>): UseUnresolvedFileInstanceReturn<LAnnotation> {\n const [{ fileDiff, actions, markerRows }, setState] = useState(() => {\n const { fileDiff, actions, markerRows } =\n parseMergeConflictDiffFromFile(file);\n return { fileDiff, actions, markerRows };\n });\n // UnresolvedFile is intentionally uncontrolled in React. Keep an internal\n // source-of-truth file so sequential conflict actions apply to the latest\n // resolved contents rather than the initial prop value.\n const onMergeConflictAction = useStableCallback(\n (\n payload: MergeConflictActionPayload,\n instance: UnresolvedFile<LAnnotation>\n ) => {\n setState((prevState) => {\n const { fileDiff, actions, markerRows } =\n instance.resolveConflict(\n payload.conflict.conflictIndex,\n payload.resolution,\n prevState.fileDiff\n ) ?? {};\n if (fileDiff == null || actions == null || markerRows == null) {\n return prevState;\n } else {\n return { fileDiff, actions, markerRows };\n }\n });\n }\n );\n const poolManager = useContext(WorkerPoolContext);\n const instanceRef = useRef<UnresolvedFileClass<LAnnotation> | null>(null);\n const ref = useStableCallback((fileContainer: HTMLElement | null) => {\n if (fileContainer != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'useUnresolvedFileInstance: An instance should not already exist when a node is created'\n );\n }\n instanceRef.current = new UnresolvedFileClass(\n mergeUnresolvedOptions(\n options,\n onMergeConflictAction,\n hasConflictUtility,\n hasGutterRenderUtility\n ),\n poolManager,\n true\n );\n void instanceRef.current.hydrate({\n fileDiff,\n actions,\n markerRows,\n fileContainer,\n lineAnnotations,\n prerenderedHTML,\n });\n } else {\n if (instanceRef.current == null) {\n throw new Error(\n 'useUnresolvedFileInstance: A UnresolvedFile instance should exist when unmounting'\n );\n }\n instanceRef.current.cleanUp();\n instanceRef.current = null;\n }\n });\n\n useIsometricEffect(() => {\n if (instanceRef.current == null) return;\n const instance = instanceRef.current;\n const newOptions = mergeUnresolvedOptions(\n options,\n onMergeConflictAction,\n hasConflictUtility,\n hasGutterRenderUtility\n );\n const forceRender = !areOptionsEqual(instance.options, newOptions);\n instance.setOptions(newOptions);\n void instance.render({\n fileDiff,\n actions,\n markerRows,\n lineAnnotations,\n forceRender,\n });\n if (selectedLines !== undefined) {\n instance.setSelectedLines(selectedLines);\n }\n });\n\n const getHoveredLine = useCallback(():\n | GetHoveredLineResult<'diff'>\n | undefined => {\n return instanceRef.current?.getHoveredLine();\n }, []);\n\n const getInstance = useCallback(() => {\n return instanceRef.current ?? undefined;\n }, []);\n\n return { ref, getHoveredLine, fileDiff, actions, markerRows, getInstance };\n}\n\nfunction mergeUnresolvedOptions<LAnnotation>(\n options: UnresolvedFileHunksRendererOptions | undefined,\n onMergeConflictAction: UnresolvedFileOptions<LAnnotation>['onMergeConflictAction'],\n hasConflictUtility: boolean,\n hasGutterRenderUtility: boolean\n): UnresolvedFileOptions<LAnnotation> {\n return {\n ...options,\n onMergeConflictAction,\n hunkSeparators:\n options?.hunkSeparators === 'custom'\n ? noopRender\n : options?.hunkSeparators,\n // Add a placeholder type for the custom render\n mergeConflictActionsType:\n hasConflictUtility || options?.mergeConflictActionsType === 'custom'\n ? noopRender\n : options?.mergeConflictActionsType,\n renderGutterUtility: hasGutterRenderUtility ? noopRender : undefined,\n };\n}\n"],"mappings":";;;;;;;;;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kBAAkB,OACpB,UAAS,iBAAiB,cAAc;GAE1C;AAYF,QAAO;EAAE;EAAK,gBAVS,kBAEN;AACf,UAAO,YAAY,SAAS,gBAAgB;KAC3C,EAAE,CAAC;EAMwB;EAAU;EAAS;EAAY,aAJzC,kBAAkB;AACpC,UAAO,YAAY,WAAW;KAC7B,EAAE,CAAC;EAEoE;;AAG5E,SAAS,uBACP,SACA,uBACA,oBACA,wBACoC;AACpC,QAAO;EACL,GAAG;EACH;EACA,gBACE,SAAS,mBAAmB,WACxB,aACA,SAAS;EAEf,0BACE,sBAAsB,SAAS,6BAA6B,WACxD,aACA,SAAS;EACf,qBAAqB,yBAAyB,aAAa;EAC5D"}
1
+ {"version":3,"file":"useUnresolvedFileInstance.js","names":["fileDiff","actions","markerRows","UnresolvedFileClass"],"sources":["../../../src/react/utils/useUnresolvedFileInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport {\n UnresolvedFile,\n UnresolvedFile as UnresolvedFileClass,\n type UnresolvedFileOptions,\n} from '../../components/UnresolvedFile';\nimport type {\n GetHoveredLineResult,\n SelectedLineRange,\n} from '../../managers/InteractionManager';\nimport type {\n DiffLineAnnotation,\n FileContents,\n FileDiffMetadata,\n MergeConflictActionPayload,\n MergeConflictMarkerRow,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport {\n type MergeConflictDiffAction,\n parseMergeConflictDiffFromFile,\n} from '../../utils/parseMergeConflictDiffFromFile';\nimport { noopRender } from '../constants';\nimport type { UnresolvedFileReactOptions } from '../UnresolvedFile';\nimport { WorkerPoolContext } from '../WorkerPoolContext';\nimport { useStableCallback } from './useStableCallback';\n\nconst useIsometricEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface UseUnresolvedFileInstanceProps<LAnnotation> {\n file: FileContents;\n options?: UnresolvedFileReactOptions<LAnnotation>;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n hasConflictUtility: boolean;\n hasGutterRenderUtility: boolean;\n}\n\ninterface UseUnresolvedFileInstanceReturn<LAnnotation> {\n fileDiff: FileDiffMetadata;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance(): UnresolvedFile<LAnnotation> | undefined;\n}\n\nexport function useUnresolvedFileInstance<LAnnotation>({\n file,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n hasConflictUtility,\n hasGutterRenderUtility,\n}: UseUnresolvedFileInstanceProps<LAnnotation>): UseUnresolvedFileInstanceReturn<LAnnotation> {\n const [{ fileDiff, actions, markerRows }, setState] = useState(() => {\n const { fileDiff, actions, markerRows } = parseMergeConflictDiffFromFile(\n file,\n options?.maxContextLines\n );\n return { fileDiff, actions, markerRows };\n });\n // UnresolvedFile is intentionally uncontrolled in React. Keep an internal\n // source-of-truth file so sequential conflict actions apply to the latest\n // resolved contents rather than the initial prop value.\n const onMergeConflictAction = useStableCallback(\n (\n payload: MergeConflictActionPayload,\n instance: UnresolvedFile<LAnnotation>\n ) => {\n setState((prevState) => {\n const { fileDiff, actions, markerRows } =\n instance.resolveConflict(\n payload.conflict.conflictIndex,\n payload.resolution,\n prevState.fileDiff\n ) ?? {};\n if (fileDiff == null || actions == null || markerRows == null) {\n return prevState;\n } else {\n return { fileDiff, actions, markerRows };\n }\n });\n }\n );\n const poolManager = useContext(WorkerPoolContext);\n const instanceRef = useRef<UnresolvedFileClass<LAnnotation> | null>(null);\n const ref = useStableCallback((fileContainer: HTMLElement | null) => {\n if (fileContainer != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'useUnresolvedFileInstance: An instance should not already exist when a node is created'\n );\n }\n instanceRef.current = new UnresolvedFileClass(\n mergeUnresolvedOptions(\n options,\n onMergeConflictAction,\n hasConflictUtility,\n hasGutterRenderUtility\n ),\n poolManager,\n true\n );\n void instanceRef.current.hydrate({\n fileDiff,\n actions,\n markerRows,\n fileContainer,\n lineAnnotations,\n prerenderedHTML,\n });\n } else {\n if (instanceRef.current == null) {\n throw new Error(\n 'useUnresolvedFileInstance: A UnresolvedFile instance should exist when unmounting'\n );\n }\n instanceRef.current.cleanUp();\n instanceRef.current = null;\n }\n });\n\n useIsometricEffect(() => {\n if (instanceRef.current == null) return;\n const instance = instanceRef.current;\n const newOptions = mergeUnresolvedOptions(\n options,\n onMergeConflictAction,\n hasConflictUtility,\n hasGutterRenderUtility\n );\n const forceRender = !areOptionsEqual(instance.options, newOptions);\n instance.setOptions(newOptions);\n void instance.render({\n fileDiff,\n actions,\n markerRows,\n lineAnnotations,\n forceRender,\n });\n if (selectedLines !== undefined) {\n instance.setSelectedLines(selectedLines);\n }\n });\n\n const getHoveredLine = useCallback(():\n | GetHoveredLineResult<'diff'>\n | undefined => {\n return instanceRef.current?.getHoveredLine();\n }, []);\n\n const getInstance = useCallback(() => {\n return instanceRef.current ?? undefined;\n }, []);\n\n return { ref, getHoveredLine, fileDiff, actions, markerRows, getInstance };\n}\n\nfunction mergeUnresolvedOptions<LAnnotation>(\n options: UnresolvedFileReactOptions<LAnnotation> | undefined,\n onMergeConflictAction: UnresolvedFileOptions<LAnnotation>['onMergeConflictAction'],\n hasConflictUtility: boolean,\n hasGutterRenderUtility: boolean\n): UnresolvedFileOptions<LAnnotation> {\n return {\n ...options,\n onMergeConflictAction,\n hunkSeparators:\n options?.hunkSeparators === 'custom'\n ? noopRender\n : options?.hunkSeparators,\n // Add a placeholder type for the custom render\n mergeConflictActionsType:\n hasConflictUtility || options?.mergeConflictActionsType === 'custom'\n ? noopRender\n : options?.mergeConflictActionsType,\n renderGutterUtility: hasGutterRenderUtility ? noopRender : undefined,\n };\n}\n"],"mappings":";;;;;;;;;AAmCA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAqB9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AAYF,QAAO;EAAE;EAAK,gBAVS,kBAEN;AACf,UAAO,YAAY,SAAS,gBAAgB;KAC3C,EAAE,CAAC;EAMwB;EAAU;EAAS;EAAY,aAJzC,kBAAkB;AACpC,UAAO,YAAY,WAAW;KAC7B,EAAE,CAAC;EAEoE;;AAG5E,SAAS,uBACP,SACA,uBACA,oBACA,wBACoC;AACpC,QAAO;EACL,GAAG;EACH;EACA,gBACE,SAAS,mBAAmB,WACxB,aACA,SAAS;EAEf,0BACE,sBAAsB,SAAS,6BAA6B,WACxD,aACA,SAAS;EACf,qBAAqB,yBAAyB,aAAa;EAC5D"}
@@ -29,14 +29,9 @@ function resolveRegion(diff, target) {
29
29
  unifiedLineCount: 0
30
30
  };
31
31
  const updatesEOFState = hunkIndex === hunks.length - 1 && endContentIndex === currentHunk.hunkContent.length - 1;
32
+ const shouldProcessCollapsedContext = !diff.isPartial;
32
33
  for (const [index, hunk] of hunks.entries()) {
33
- pushCollapsedContextLines(resolvedDiff, deletionLines, additionLines, hunk.deletionLineIndex - hunk.collapsedBefore, hunk.additionLineIndex - hunk.collapsedBefore, hunk.collapsedBefore);
34
- cursor.nextAdditionLineIndex += hunk.collapsedBefore;
35
- cursor.nextDeletionLineIndex += hunk.collapsedBefore;
36
- cursor.nextAdditionStart += hunk.collapsedBefore;
37
- cursor.nextDeletionStart += hunk.collapsedBefore;
38
- cursor.splitLineCount += hunk.collapsedBefore;
39
- cursor.unifiedLineCount += hunk.collapsedBefore;
34
+ processCollapsedContext(diff, resolvedDiff, cursor, hunk.deletionLineIndex - hunk.collapsedBefore, hunk.additionLineIndex - hunk.collapsedBefore, hunk.collapsedBefore, shouldProcessCollapsedContext);
40
35
  const newHunk = {
41
36
  ...hunk,
42
37
  hunkContent: [],
@@ -110,6 +105,18 @@ function pushCollapsedContextLines(diff, deletionLines, additionLines, deletionL
110
105
  diff.additionLines.push(additionLine);
111
106
  }
112
107
  }
108
+ function processCollapsedContext(sourceDiff, resolvedDiff, cursor, deletionLineIndex, additionLineIndex, lineCount, shouldProcessContent) {
109
+ if (lineCount <= 0) return;
110
+ if (shouldProcessContent) {
111
+ pushCollapsedContextLines(resolvedDiff, sourceDiff.deletionLines, sourceDiff.additionLines, deletionLineIndex, additionLineIndex, lineCount);
112
+ cursor.nextAdditionLineIndex += lineCount;
113
+ cursor.nextDeletionLineIndex += lineCount;
114
+ }
115
+ cursor.nextAdditionStart += lineCount;
116
+ cursor.nextDeletionStart += lineCount;
117
+ cursor.splitLineCount += lineCount;
118
+ cursor.unifiedLineCount += lineCount;
119
+ }
113
120
  function pushContentLinesToDiff(content, diff, deletionLines, additionLines) {
114
121
  if (content.type === "context") for (let i = 0; i < content.lines; i++) {
115
122
  const line = additionLines[content.additionLineIndex + i];
@@ -1 +1 @@
1
- {"version":3,"file":"resolveRegion.js","names":["resolvedDiff: FileDiffMetadata","cursor: CursorState","newHunk: Hunk","newContent: ContextContent"],"sources":["../../src/utils/resolveRegion.ts"],"sourcesContent":["import type {\n ChangeContent,\n ContextContent,\n FileDiffMetadata,\n Hunk,\n} from '../types';\n\ninterface RegionResolutionTarget {\n hunkIndex: number;\n startContentIndex: number;\n endContentIndex: number;\n resolution: 'deletions' | 'additions' | 'both';\n indexesToDelete?: Set<number>;\n}\n\ninterface CursorState {\n nextAdditionLineIndex: number;\n nextDeletionLineIndex: number;\n nextAdditionStart: number;\n nextDeletionStart: number;\n splitLineCount: number;\n unifiedLineCount: number;\n}\n\nexport function resolveRegion(\n diff: FileDiffMetadata,\n target: RegionResolutionTarget\n): FileDiffMetadata {\n const {\n resolution,\n hunkIndex,\n startContentIndex,\n endContentIndex,\n indexesToDelete = new Set(),\n } = target;\n const currentHunk = diff.hunks[hunkIndex];\n if (currentHunk == null) {\n console.error({ diff, hunkIndex });\n throw new Error(`resolveRegion: Invalid hunk index: ${hunkIndex}`);\n }\n\n if (\n startContentIndex < 0 ||\n endContentIndex >= currentHunk.hunkContent.length ||\n startContentIndex > endContentIndex\n ) {\n throw new Error(\n `resolveRegion: Invalid content range, ${startContentIndex}, ${endContentIndex}`\n );\n }\n\n const { hunks, additionLines, deletionLines } = diff;\n const resolvedDiff: FileDiffMetadata = {\n ...diff,\n hunks: [],\n deletionLines: [],\n additionLines: [],\n splitLineCount: 0,\n unifiedLineCount: 0,\n cacheKey:\n diff.cacheKey != null\n ? `${diff.cacheKey}:${resolution[0]}-${hunkIndex}:${startContentIndex}-${endContentIndex}`\n : undefined,\n };\n\n const cursor: CursorState = {\n nextAdditionLineIndex: 0,\n nextDeletionLineIndex: 0,\n nextAdditionStart: 1,\n nextDeletionStart: 1,\n splitLineCount: 0,\n unifiedLineCount: 0,\n };\n const updatesEOFState =\n hunkIndex === hunks.length - 1 &&\n endContentIndex === currentHunk.hunkContent.length - 1;\n\n for (const [index, hunk] of hunks.entries()) {\n pushCollapsedContextLines(\n resolvedDiff,\n deletionLines,\n additionLines,\n hunk.deletionLineIndex - hunk.collapsedBefore,\n hunk.additionLineIndex - hunk.collapsedBefore,\n hunk.collapsedBefore\n );\n cursor.nextAdditionLineIndex += hunk.collapsedBefore;\n cursor.nextDeletionLineIndex += hunk.collapsedBefore;\n cursor.nextAdditionStart += hunk.collapsedBefore;\n cursor.nextDeletionStart += hunk.collapsedBefore;\n cursor.splitLineCount += hunk.collapsedBefore;\n cursor.unifiedLineCount += hunk.collapsedBefore;\n\n const newHunk: Hunk = {\n ...hunk,\n hunkContent: [],\n additionStart: cursor.nextAdditionStart,\n deletionStart: cursor.nextDeletionStart,\n additionLineIndex: cursor.nextAdditionLineIndex,\n deletionLineIndex: cursor.nextDeletionLineIndex,\n additionCount: 0,\n deletionCount: 0,\n deletionLines: 0,\n additionLines: 0,\n splitLineStart: cursor.splitLineCount,\n unifiedLineStart: cursor.unifiedLineCount,\n splitLineCount: 0,\n unifiedLineCount: 0,\n };\n\n for (const [contentIndex, content] of hunk.hunkContent.entries()) {\n // If we are outside of the targeted hunk or content region\n if (\n index !== hunkIndex ||\n contentIndex < startContentIndex ||\n contentIndex > endContentIndex\n ) {\n pushContentLinesToDiff(\n content,\n resolvedDiff,\n deletionLines,\n additionLines\n );\n const newContent = {\n ...content,\n additionLineIndex: cursor.nextAdditionLineIndex,\n deletionLineIndex: cursor.nextDeletionLineIndex,\n };\n newHunk.hunkContent.push(newContent);\n advanceCursor(newContent, cursor, newHunk);\n }\n // If we are at an index to delete, replace with an empty context node\n else if (indexesToDelete.has(contentIndex)) {\n newHunk.hunkContent.push({\n type: 'context',\n lines: 0,\n deletionLineIndex: cursor.nextDeletionLineIndex,\n additionLineIndex: cursor.nextAdditionLineIndex,\n });\n }\n // There's nothing to `resolve` with context nodes, so just push them as\n // they are\n else if (content.type === 'context') {\n pushContentLinesToDiff(\n content,\n resolvedDiff,\n deletionLines,\n additionLines\n );\n const newContent: ContextContent = {\n ...content,\n deletionLineIndex: cursor.nextDeletionLineIndex,\n additionLineIndex: cursor.nextAdditionLineIndex,\n };\n newHunk.hunkContent.push(newContent);\n advanceCursor(newContent, cursor, newHunk);\n }\n // Looks like we have a change to resolve and push\n else {\n pushResolveLinesToDiff(\n resolution,\n content,\n resolvedDiff,\n deletionLines,\n additionLines\n );\n const newContent: ContextContent = {\n type: 'context',\n lines:\n resolution === 'deletions'\n ? content.deletions\n : resolution === 'additions'\n ? content.additions\n : content.deletions + content.additions,\n deletionLineIndex: cursor.nextDeletionLineIndex,\n additionLineIndex: cursor.nextAdditionLineIndex,\n };\n newHunk.hunkContent.push(newContent);\n advanceCursor(newContent, cursor, newHunk);\n }\n }\n\n if (index === hunkIndex && updatesEOFState) {\n const noEOFCR =\n resolution === 'deletions'\n ? hunk.noEOFCRDeletions\n : hunk.noEOFCRAdditions;\n newHunk.noEOFCRAdditions = noEOFCR;\n newHunk.noEOFCRDeletions = noEOFCR;\n }\n\n resolvedDiff.hunks.push(newHunk);\n }\n\n const finalHunk = hunks.at(-1);\n if (finalHunk != null && !diff.isPartial) {\n pushCollapsedContextLines(\n resolvedDiff,\n deletionLines,\n additionLines,\n finalHunk.deletionLineIndex + finalHunk.deletionCount,\n finalHunk.additionLineIndex + finalHunk.additionCount,\n Math.min(\n deletionLines.length -\n (finalHunk.deletionLineIndex + finalHunk.deletionCount),\n additionLines.length -\n (finalHunk.additionLineIndex + finalHunk.additionCount)\n )\n );\n }\n\n resolvedDiff.splitLineCount = cursor.splitLineCount;\n resolvedDiff.unifiedLineCount = cursor.unifiedLineCount;\n\n return resolvedDiff;\n}\n\nfunction pushCollapsedContextLines(\n diff: FileDiffMetadata,\n deletionLines: string[],\n additionLines: string[],\n deletionLineIndex: number,\n additionLineIndex: number,\n lineCount: number\n) {\n for (let index = 0; index < lineCount; index++) {\n const deletionLine = deletionLines[deletionLineIndex + index];\n const additionLine = additionLines[additionLineIndex + index];\n if (deletionLine == null || additionLine == null) {\n throw new Error(\n 'pushCollapsedContextLines: missing collapsed context line'\n );\n }\n diff.deletionLines.push(deletionLine);\n diff.additionLines.push(additionLine);\n }\n}\n\nfunction pushContentLinesToDiff(\n content: ContextContent | ChangeContent,\n diff: FileDiffMetadata,\n deletionLines: string[],\n additionLines: string[]\n) {\n if (content.type === 'context') {\n for (let i = 0; i < content.lines; i++) {\n const line = additionLines[content.additionLineIndex + i];\n if (line == null) {\n console.error({ additionLines, content, i });\n throw new Error('pushContentLinesToDiff: Context line does not exist');\n }\n diff.deletionLines.push(line);\n diff.additionLines.push(line);\n }\n } else {\n const len = Math.max(content.deletions, content.additions);\n for (let i = 0; i < len; i++) {\n if (i < content.deletions) {\n const line = deletionLines[content.deletionLineIndex + i];\n if (line == null) {\n console.error({ deletionLines, content, i });\n throw new Error(\n 'pushContentLinesToDiff: Deletion line does not exist'\n );\n }\n diff.deletionLines.push(line);\n }\n if (i < content.additions) {\n const line = additionLines[content.additionLineIndex + i];\n if (line == null) {\n console.error({ additionLines, content, i });\n throw new Error(\n 'pushContentLinesToDiff: Addition line does not exist'\n );\n }\n diff.additionLines.push(line);\n }\n }\n }\n}\n\nfunction pushResolveLinesToDiff(\n resolution: 'deletions' | 'additions' | 'both',\n content: ChangeContent,\n diff: FileDiffMetadata,\n deletionLines: string[],\n additionLines: string[]\n) {\n if (resolution === 'deletions' || resolution === 'both') {\n for (let i = 0; i < content.deletions; i++) {\n const line = deletionLines[content.deletionLineIndex + i];\n if (line == null) {\n console.error({ deletionLines, content, i });\n throw new Error('pushResolveLinesToDiff: Deletion line does not exist');\n }\n diff.deletionLines.push(line);\n diff.additionLines.push(line);\n }\n }\n if (resolution === 'additions' || resolution === 'both') {\n for (let i = 0; i < content.additions; i++) {\n const line = additionLines[content.additionLineIndex + i];\n if (line == null) {\n console.error({ additionLines, content, i });\n throw new Error('pushResolveLinesToDiff: Addition line does not exist');\n }\n diff.deletionLines.push(line);\n diff.additionLines.push(line);\n }\n }\n}\n\nfunction advanceCursor(\n content: ChangeContent | ContextContent,\n cursor: CursorState,\n hunk: Hunk\n) {\n if (content.type === 'context') {\n cursor.nextAdditionLineIndex += content.lines;\n cursor.nextDeletionLineIndex += content.lines;\n cursor.nextAdditionStart += content.lines;\n cursor.nextDeletionStart += content.lines;\n cursor.splitLineCount += content.lines;\n cursor.unifiedLineCount += content.lines;\n\n hunk.additionCount += content.lines;\n hunk.deletionCount += content.lines;\n hunk.splitLineCount += content.lines;\n hunk.unifiedLineCount += content.lines;\n } else {\n cursor.nextAdditionLineIndex += content.additions;\n cursor.nextDeletionLineIndex += content.deletions;\n cursor.nextAdditionStart += content.additions;\n cursor.nextDeletionStart += content.deletions;\n cursor.splitLineCount += Math.max(content.deletions, content.additions);\n cursor.unifiedLineCount += content.deletions + content.additions;\n\n hunk.deletionCount += content.deletions;\n hunk.deletionLines += content.deletions;\n hunk.additionCount += content.additions;\n hunk.additionLines += content.additions;\n hunk.splitLineCount += Math.max(content.deletions, content.additions);\n hunk.unifiedLineCount += content.deletions + content.additions;\n }\n}\n"],"mappings":";AAwBA,SAAgB,cACd,MACA,QACkB;CAClB,MAAM,EACJ,YACA,WACA,mBACA,iBACA,kCAAkB,IAAI,KAAK,KACzB;CACJ,M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,oBAAoB,QAAQ,YAAY,QAAQ;AAEvD,OAAK,iBAAiB,QAAQ;AAC9B,OAAK,iBAAiB,QAAQ;AAC9B,OAAK,iBAAiB,QAAQ;AAC9B,OAAK,iBAAiB,QAAQ;AAC9B,OAAK,kBAAkB,KAAK,IAAI,QAAQ,WAAW,QAAQ,UAAU;AACrE,OAAK,oBAAoB,QAAQ,YAAY,QAAQ"}
1
+ {"version":3,"file":"resolveRegion.js","names":["resolvedDiff: FileDiffMetadata","cursor: CursorState","newHunk: Hunk","newContent: ContextContent"],"sources":["../../src/utils/resolveRegion.ts"],"sourcesContent":["import type {\n ChangeContent,\n ContextContent,\n FileDiffMetadata,\n Hunk,\n} from '../types';\n\ninterface RegionResolutionTarget {\n hunkIndex: number;\n startContentIndex: number;\n endContentIndex: number;\n resolution: 'deletions' | 'additions' | 'both';\n indexesToDelete?: Set<number>;\n}\n\ninterface CursorState {\n nextAdditionLineIndex: number;\n nextDeletionLineIndex: number;\n nextAdditionStart: number;\n nextDeletionStart: number;\n splitLineCount: number;\n unifiedLineCount: number;\n}\n\nexport function resolveRegion(\n diff: FileDiffMetadata,\n target: RegionResolutionTarget\n): FileDiffMetadata {\n const {\n resolution,\n hunkIndex,\n startContentIndex,\n endContentIndex,\n indexesToDelete = new Set(),\n } = target;\n const currentHunk = diff.hunks[hunkIndex];\n if (currentHunk == null) {\n console.error({ diff, hunkIndex });\n throw new Error(`resolveRegion: Invalid hunk index: ${hunkIndex}`);\n }\n\n if (\n startContentIndex < 0 ||\n endContentIndex >= currentHunk.hunkContent.length ||\n startContentIndex > endContentIndex\n ) {\n throw new Error(\n `resolveRegion: Invalid content range, ${startContentIndex}, ${endContentIndex}`\n );\n }\n\n const { hunks, additionLines, deletionLines } = diff;\n const resolvedDiff: FileDiffMetadata = {\n ...diff,\n hunks: [],\n deletionLines: [],\n additionLines: [],\n splitLineCount: 0,\n unifiedLineCount: 0,\n cacheKey:\n diff.cacheKey != null\n ? `${diff.cacheKey}:${resolution[0]}-${hunkIndex}:${startContentIndex}-${endContentIndex}`\n : undefined,\n };\n\n const cursor: CursorState = {\n nextAdditionLineIndex: 0,\n nextDeletionLineIndex: 0,\n nextAdditionStart: 1,\n nextDeletionStart: 1,\n splitLineCount: 0,\n unifiedLineCount: 0,\n };\n const updatesEOFState =\n hunkIndex === hunks.length - 1 &&\n endContentIndex === currentHunk.hunkContent.length - 1;\n const shouldProcessCollapsedContext = !diff.isPartial;\n\n for (const [index, hunk] of hunks.entries()) {\n processCollapsedContext(\n diff,\n resolvedDiff,\n cursor,\n hunk.deletionLineIndex - hunk.collapsedBefore,\n hunk.additionLineIndex - hunk.collapsedBefore,\n hunk.collapsedBefore,\n shouldProcessCollapsedContext\n );\n\n const newHunk: Hunk = {\n ...hunk,\n hunkContent: [],\n additionStart: cursor.nextAdditionStart,\n deletionStart: cursor.nextDeletionStart,\n additionLineIndex: cursor.nextAdditionLineIndex,\n deletionLineIndex: cursor.nextDeletionLineIndex,\n additionCount: 0,\n deletionCount: 0,\n deletionLines: 0,\n additionLines: 0,\n splitLineStart: cursor.splitLineCount,\n unifiedLineStart: cursor.unifiedLineCount,\n splitLineCount: 0,\n unifiedLineCount: 0,\n };\n\n for (const [contentIndex, content] of hunk.hunkContent.entries()) {\n // If we are outside of the targeted hunk or content region\n if (\n index !== hunkIndex ||\n contentIndex < startContentIndex ||\n contentIndex > endContentIndex\n ) {\n pushContentLinesToDiff(\n content,\n resolvedDiff,\n deletionLines,\n additionLines\n );\n const newContent = {\n ...content,\n additionLineIndex: cursor.nextAdditionLineIndex,\n deletionLineIndex: cursor.nextDeletionLineIndex,\n };\n newHunk.hunkContent.push(newContent);\n advanceCursor(newContent, cursor, newHunk);\n }\n // If we are at an index to delete, replace with an empty context node\n else if (indexesToDelete.has(contentIndex)) {\n newHunk.hunkContent.push({\n type: 'context',\n lines: 0,\n deletionLineIndex: cursor.nextDeletionLineIndex,\n additionLineIndex: cursor.nextAdditionLineIndex,\n });\n }\n // There's nothing to `resolve` with context nodes, so just push them as\n // they are\n else if (content.type === 'context') {\n pushContentLinesToDiff(\n content,\n resolvedDiff,\n deletionLines,\n additionLines\n );\n const newContent: ContextContent = {\n ...content,\n deletionLineIndex: cursor.nextDeletionLineIndex,\n additionLineIndex: cursor.nextAdditionLineIndex,\n };\n newHunk.hunkContent.push(newContent);\n advanceCursor(newContent, cursor, newHunk);\n }\n // Looks like we have a change to resolve and push\n else {\n pushResolveLinesToDiff(\n resolution,\n content,\n resolvedDiff,\n deletionLines,\n additionLines\n );\n const newContent: ContextContent = {\n type: 'context',\n lines:\n resolution === 'deletions'\n ? content.deletions\n : resolution === 'additions'\n ? content.additions\n : content.deletions + content.additions,\n deletionLineIndex: cursor.nextDeletionLineIndex,\n additionLineIndex: cursor.nextAdditionLineIndex,\n };\n newHunk.hunkContent.push(newContent);\n advanceCursor(newContent, cursor, newHunk);\n }\n }\n\n if (index === hunkIndex && updatesEOFState) {\n const noEOFCR =\n resolution === 'deletions'\n ? hunk.noEOFCRDeletions\n : hunk.noEOFCRAdditions;\n newHunk.noEOFCRAdditions = noEOFCR;\n newHunk.noEOFCRDeletions = noEOFCR;\n }\n\n resolvedDiff.hunks.push(newHunk);\n }\n\n const finalHunk = hunks.at(-1);\n if (finalHunk != null && !diff.isPartial) {\n pushCollapsedContextLines(\n resolvedDiff,\n deletionLines,\n additionLines,\n finalHunk.deletionLineIndex + finalHunk.deletionCount,\n finalHunk.additionLineIndex + finalHunk.additionCount,\n Math.min(\n deletionLines.length -\n (finalHunk.deletionLineIndex + finalHunk.deletionCount),\n additionLines.length -\n (finalHunk.additionLineIndex + finalHunk.additionCount)\n )\n );\n }\n\n resolvedDiff.splitLineCount = cursor.splitLineCount;\n resolvedDiff.unifiedLineCount = cursor.unifiedLineCount;\n\n return resolvedDiff;\n}\n\nfunction pushCollapsedContextLines(\n diff: FileDiffMetadata,\n deletionLines: string[],\n additionLines: string[],\n deletionLineIndex: number,\n additionLineIndex: number,\n lineCount: number\n) {\n for (let index = 0; index < lineCount; index++) {\n const deletionLine = deletionLines[deletionLineIndex + index];\n const additionLine = additionLines[additionLineIndex + index];\n if (deletionLine == null || additionLine == null) {\n throw new Error(\n 'pushCollapsedContextLines: missing collapsed context line'\n );\n }\n diff.deletionLines.push(deletionLine);\n diff.additionLines.push(additionLine);\n }\n}\n\n// Partial patches track omitted context in `collapsedBefore`, but those lines do\n// not exist in the diff's line arrays. Keep the virtual row counts and file\n// positions in sync without inventing hidden lines.\nfunction processCollapsedContext(\n sourceDiff: FileDiffMetadata,\n resolvedDiff: FileDiffMetadata,\n cursor: CursorState,\n deletionLineIndex: number,\n additionLineIndex: number,\n lineCount: number,\n shouldProcessContent: boolean\n) {\n if (lineCount <= 0) {\n return;\n }\n\n if (shouldProcessContent) {\n pushCollapsedContextLines(\n resolvedDiff,\n sourceDiff.deletionLines,\n sourceDiff.additionLines,\n deletionLineIndex,\n additionLineIndex,\n lineCount\n );\n cursor.nextAdditionLineIndex += lineCount;\n cursor.nextDeletionLineIndex += lineCount;\n }\n\n cursor.nextAdditionStart += lineCount;\n cursor.nextDeletionStart += lineCount;\n cursor.splitLineCount += lineCount;\n cursor.unifiedLineCount += lineCount;\n}\n\nfunction pushContentLinesToDiff(\n content: ContextContent | ChangeContent,\n diff: FileDiffMetadata,\n deletionLines: string[],\n additionLines: string[]\n) {\n if (content.type === 'context') {\n for (let i = 0; i < content.lines; i++) {\n const line = additionLines[content.additionLineIndex + i];\n if (line == null) {\n console.error({ additionLines, content, i });\n throw new Error('pushContentLinesToDiff: Context line does not exist');\n }\n diff.deletionLines.push(line);\n diff.additionLines.push(line);\n }\n } else {\n const len = Math.max(content.deletions, content.additions);\n for (let i = 0; i < len; i++) {\n if (i < content.deletions) {\n const line = deletionLines[content.deletionLineIndex + i];\n if (line == null) {\n console.error({ deletionLines, content, i });\n throw new Error(\n 'pushContentLinesToDiff: Deletion line does not exist'\n );\n }\n diff.deletionLines.push(line);\n }\n if (i < content.additions) {\n const line = additionLines[content.additionLineIndex + i];\n if (line == null) {\n console.error({ additionLines, content, i });\n throw new Error(\n 'pushContentLinesToDiff: Addition line does not exist'\n );\n }\n diff.additionLines.push(line);\n }\n }\n }\n}\n\nfunction pushResolveLinesToDiff(\n resolution: 'deletions' | 'additions' | 'both',\n content: ChangeContent,\n diff: FileDiffMetadata,\n deletionLines: string[],\n additionLines: string[]\n) {\n if (resolution === 'deletions' || resolution === 'both') {\n for (let i = 0; i < content.deletions; i++) {\n const line = deletionLines[content.deletionLineIndex + i];\n if (line == null) {\n console.error({ deletionLines, content, i });\n throw new Error('pushResolveLinesToDiff: Deletion line does not exist');\n }\n diff.deletionLines.push(line);\n diff.additionLines.push(line);\n }\n }\n if (resolution === 'additions' || resolution === 'both') {\n for (let i = 0; i < content.additions; i++) {\n const line = additionLines[content.additionLineIndex + i];\n if (line == null) {\n console.error({ additionLines, content, i });\n throw new Error('pushResolveLinesToDiff: Addition line does not exist');\n }\n diff.deletionLines.push(line);\n diff.additionLines.push(line);\n }\n }\n}\n\nfunction advanceCursor(\n content: ChangeContent | ContextContent,\n cursor: CursorState,\n hunk: Hunk\n) {\n if (content.type === 'context') {\n cursor.nextAdditionLineIndex += content.lines;\n cursor.nextDeletionLineIndex += content.lines;\n cursor.nextAdditionStart += content.lines;\n cursor.nextDeletionStart += content.lines;\n cursor.splitLineCount += content.lines;\n cursor.unifiedLineCount += content.lines;\n\n hunk.additionCount += content.lines;\n hunk.deletionCount += content.lines;\n hunk.splitLineCount += content.lines;\n hunk.unifiedLineCount += content.lines;\n } else {\n cursor.nextAdditionLineIndex += content.additions;\n cursor.nextDeletionLineIndex += content.deletions;\n cursor.nextAdditionStart += content.additions;\n cursor.nextDeletionStart += content.deletions;\n cursor.splitLineCount += Math.max(content.deletions, content.additions);\n cursor.unifiedLineCount += content.deletions + content.additions;\n\n hunk.deletionCount += content.deletions;\n hunk.deletionLines += content.deletions;\n hunk.additionCount += content.additions;\n hunk.additionLines += content.additions;\n hunk.splitLineCount += Math.max(content.deletions, content.additions);\n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