@pierre/diffs 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AdvancedVirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/File.d.ts +2 -2
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +3 -3
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/UnresolvedFile.d.ts +1 -1
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/UnresolvedFile.js.map +1 -1
- package/dist/managers/InteractionManager.d.ts +2 -2
- package/dist/managers/InteractionManager.d.ts.map +1 -1
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/react/File.js +2 -1
- package/dist/react/File.js.map +1 -1
- package/dist/react/FileDiff.js +2 -1
- package/dist/react/FileDiff.js.map +1 -1
- package/dist/react/MultiFileDiff.js +2 -1
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/PatchDiff.js +2 -1
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/UnresolvedFile.js +2 -1
- package/dist/react/UnresolvedFile.js.map +1 -1
- package/dist/react/constants.d.ts +2 -1
- package/dist/react/constants.d.ts.map +1 -1
- package/dist/react/constants.js +4 -1
- package/dist/react/constants.js.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +2 -2
- package/dist/react/jsx.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.d.ts +3 -1
- package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js +14 -5
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.d.ts +3 -1
- package/dist/react/utils/useFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileInstance.js +14 -5
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.d.ts +3 -1
- package/dist/react/utils/useUnresolvedFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.js +8 -7
- package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileDiff.js","names":["options: FileDiffOptions<LAnnotation>","workerManager?: WorkerPoolManager | undefined","targetUnifiedIndex: number | undefined","targetSplitIndex: number | undefined","error: unknown","codeElements: HTMLElement[]","preProperties: PrePropertiesConfig"],"sources":["../../src/components/FileDiff.ts"],"sourcesContent":["import type { ElementContent, Element as HASTElement } from 'hast';\nimport { toHtml } from 'hast-util-to-html';\n\nimport {\n DEFAULT_THEMES,\n DIFFS_TAG_NAME,\n EMPTY_RENDER_RANGE,\n HEADER_METADATA_SLOT_ID,\n HEADER_PREFIX_SLOT_ID,\n UNSAFE_CSS_ATTRIBUTE,\n} from '../constants';\nimport {\n type GetHoveredLineResult,\n type GetLineIndexUtility,\n InteractionManager,\n type InteractionManagerBaseOptions,\n pluckInteractionOptions,\n type SelectedLineRange,\n} from '../managers/InteractionManager';\nimport { ResizeManager } from '../managers/ResizeManager';\nimport { ScrollSyncManager } from '../managers/ScrollSyncManager';\nimport {\n DiffHunksRenderer,\n type HunksRenderResult,\n} from '../renderers/DiffHunksRenderer';\nimport { SVGSpriteSheet } from '../sprite';\nimport type {\n BaseDiffOptions,\n CustomPreProperties,\n DiffLineAnnotation,\n ExpansionDirections,\n FileContents,\n FileDiffMetadata,\n HunkData,\n HunkSeparators,\n PrePropertiesConfig,\n RenderHeaderMetadataCallback,\n RenderHeaderPrefixCallback,\n RenderRange,\n SelectionSide,\n ThemeTypes,\n} from '../types';\nimport { areDiffLineAnnotationsEqual } from '../utils/areDiffLineAnnotationsEqual';\nimport { areFilesEqual } from '../utils/areFilesEqual';\nimport { areHunkDataEqual } from '../utils/areHunkDataEqual';\nimport { arePrePropertiesEqual } from '../utils/arePrePropertiesEqual';\nimport { areRenderRangesEqual } from '../utils/areRenderRangesEqual';\nimport { createAnnotationWrapperNode } from '../utils/createAnnotationWrapperNode';\nimport { createGutterUtilityContentNode } from '../utils/createGutterUtilityContentNode';\nimport { createUnsafeCSSStyleNode } from '../utils/createUnsafeCSSStyleNode';\nimport { wrapUnsafeCSS } from '../utils/cssWrappers';\nimport { getLineAnnotationName } from '../utils/getLineAnnotationName';\nimport { getOrCreateCodeNode } from '../utils/getOrCreateCodeNode';\nimport { parseDiffFromFile } from '../utils/parseDiffFromFile';\nimport { prerenderHTMLIfNecessary } from '../utils/prerenderHTMLIfNecessary';\nimport { setPreNodeProperties } from '../utils/setWrapperNodeProps';\nimport type { WorkerPoolManager } from '../worker';\nimport { DiffsContainerLoaded } from './web-components';\n\nexport interface FileDiffRenderProps<LAnnotation> {\n fileDiff?: FileDiffMetadata;\n oldFile?: FileContents;\n newFile?: FileContents;\n forceRender?: boolean;\n fileContainer?: HTMLElement;\n containerWrapper?: HTMLElement;\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[];\n renderRange?: RenderRange;\n}\n\nexport interface FileDiffHydrationProps<LAnnotation> extends Omit<\n FileDiffRenderProps<LAnnotation>,\n 'fileContainer'\n> {\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\n\nexport interface FileDiffOptions<LAnnotation>\n extends\n Omit<BaseDiffOptions, 'hunkSeparators'>,\n InteractionManagerBaseOptions<'diff'> {\n hunkSeparators?:\n | Exclude<HunkSeparators, 'custom'> /**\n * @deprecated Custom hunk separator functions are deprecated and will be\n * removed in a future version.\n */\n | ((\n hunk: HunkData,\n instance: FileDiff<LAnnotation>\n ) => HTMLElement | DocumentFragment | undefined);\n disableFileHeader?: boolean;\n /**\n * @deprecated Use `enableGutterUtility` instead.\n */\n enableHoverUtility?: boolean;\n renderHeaderPrefix?: RenderHeaderPrefixCallback;\n renderHeaderMetadata?: RenderHeaderMetadataCallback;\n /**\n * When true, errors during rendering are rethrown instead of being caught\n * and displayed in the DOM. Useful for testing or when you want to handle\n * errors yourself.\n */\n disableErrorHandling?: boolean;\n renderAnnotation?(\n annotation: DiffLineAnnotation<LAnnotation>\n ): HTMLElement | undefined;\n renderGutterUtility?(\n getHoveredRow: () => GetHoveredLineResult<'diff'> | undefined\n ): HTMLElement | null;\n /**\n * @deprecated Use `renderGutterUtility` instead.\n */\n renderHoverUtility?(\n getHoveredRow: () => GetHoveredLineResult<'diff'> | undefined\n ): HTMLElement | null;\n}\n\ninterface AnnotationElementCache<LAnnotation> {\n element: HTMLElement;\n annotation: DiffLineAnnotation<LAnnotation>;\n}\n\ninterface CustomHunkElementCache {\n element: HTMLElement;\n hunkData: HunkData;\n}\n\ninterface ColumnElements {\n gutter: HTMLElement;\n content: HTMLElement;\n}\n\ninterface TrimColumnsToOverlapProps {\n columns:\n | [ColumnElements | undefined, ColumnElements | undefined]\n | ColumnElements;\n diffStyle: 'split' | 'unified';\n overlapEnd: number;\n overlapStart: number;\n previousStart: number;\n trimEnd: number;\n trimStart: number;\n}\n\ninterface ApplyPartialRenderProps {\n previousRenderRange: RenderRange | undefined;\n renderRange: RenderRange | undefined;\n}\n\nlet instanceId = -1;\n\nexport class FileDiff<LAnnotation = undefined> {\n // NOTE(amadeus): We sorta need this to ensure the web-component file is\n // properly loaded\n static LoadedCustomComponent: boolean = DiffsContainerLoaded;\n\n readonly __id: string = `file-diff:${++instanceId}`;\n\n protected fileContainer: HTMLElement | undefined;\n protected spriteSVG: SVGElement | undefined;\n protected pre: HTMLPreElement | undefined;\n protected codeUnified: HTMLElement | undefined;\n protected codeDeletions: HTMLElement | undefined;\n protected codeAdditions: HTMLElement | undefined;\n protected bufferBefore: HTMLElement | undefined;\n protected bufferAfter: HTMLElement | undefined;\n protected unsafeCSSStyle: HTMLStyleElement | undefined;\n protected gutterUtilityContent: HTMLElement | undefined;\n\n protected headerElement: HTMLElement | undefined;\n protected headerPrefix: HTMLElement | undefined;\n protected headerMetadata: HTMLElement | undefined;\n protected separatorCache: Map<string, CustomHunkElementCache> = new Map();\n protected errorWrapper: HTMLElement | undefined;\n protected placeHolder: HTMLElement | undefined;\n\n protected hunksRenderer: DiffHunksRenderer<LAnnotation>;\n protected resizeManager: ResizeManager;\n protected scrollSyncManager: ScrollSyncManager;\n protected interactionManager: InteractionManager<'diff'>;\n\n protected annotationCache: Map<string, AnnotationElementCache<LAnnotation>> =\n new Map();\n protected lineAnnotations: DiffLineAnnotation<LAnnotation>[] = [];\n\n protected deletionFile: FileContents | undefined;\n protected additionFile: FileContents | undefined;\n protected fileDiff: FileDiffMetadata | undefined;\n protected renderRange: RenderRange | undefined;\n protected appliedPreAttributes: PrePropertiesConfig | undefined;\n protected lastRenderedHeaderHTML: string | undefined;\n protected lastRowCount: number | undefined;\n\n protected enabled = true;\n\n constructor(\n public options: FileDiffOptions<LAnnotation> = { theme: DEFAULT_THEMES },\n protected workerManager?: WorkerPoolManager | undefined,\n protected isContainerManaged = false\n ) {\n this.hunksRenderer = this.createHunksRenderer(options);\n this.resizeManager = new ResizeManager();\n this.scrollSyncManager = new ScrollSyncManager();\n this.interactionManager = new InteractionManager(\n 'diff',\n pluckInteractionOptions(\n options,\n typeof options.hunkSeparators === 'function' ||\n (options.hunkSeparators ?? 'line-info') === 'line-info' ||\n options.hunkSeparators === 'line-info-basic'\n ? this.handleExpandHunk\n : undefined,\n this.getLineIndex\n )\n );\n this.workerManager?.subscribeToThemeChanges(this);\n this.enabled = true;\n }\n\n protected handleHighlightRender = (): void => {\n this.rerender();\n };\n\n protected getHunksRendererOptions(\n options: FileDiffOptions<LAnnotation>\n ): BaseDiffOptions {\n return {\n ...options,\n hunkSeparators:\n typeof options.hunkSeparators === 'function'\n ? 'custom'\n : options.hunkSeparators,\n };\n }\n\n protected createHunksRenderer(\n options: FileDiffOptions<LAnnotation>\n ): DiffHunksRenderer<LAnnotation> {\n return new DiffHunksRenderer(\n this.getHunksRendererOptions(options),\n this.handleHighlightRender,\n this.workerManager\n );\n }\n\n public getLineIndex: GetLineIndexUtility = (\n lineNumber: number,\n side: SelectionSide = 'additions'\n ) => {\n if (this.fileDiff == null) {\n return undefined;\n }\n const lastHunk = this.fileDiff.hunks.at(-1);\n let targetUnifiedIndex: number | undefined;\n let targetSplitIndex: number | undefined;\n hunkIterator: for (const hunk of this.fileDiff.hunks) {\n let currentLineNumber =\n side === 'deletions' ? hunk.deletionStart : hunk.additionStart;\n const hunkCount =\n side === 'deletions' ? hunk.deletionCount : hunk.additionCount;\n let splitIndex = hunk.splitLineStart;\n let unifiedIndex = hunk.unifiedLineStart;\n\n // If we've selected a line between or before a hunk,\n // we should grab its index here\n if (lineNumber < currentLineNumber) {\n const difference = currentLineNumber - lineNumber;\n targetUnifiedIndex = Math.max(unifiedIndex - difference, 0);\n targetSplitIndex = Math.max(splitIndex - difference, 0);\n break hunkIterator;\n }\n\n if (lineNumber >= currentLineNumber + hunkCount) {\n if (hunk === lastHunk) {\n const difference = lineNumber - (currentLineNumber + hunkCount);\n targetUnifiedIndex =\n unifiedIndex + hunk.unifiedLineCount + difference;\n targetSplitIndex = splitIndex + hunk.splitLineCount + difference;\n break hunkIterator;\n }\n continue;\n }\n\n for (const content of hunk.hunkContent) {\n if (content.type === 'context') {\n if (lineNumber < currentLineNumber + content.lines) {\n const difference = lineNumber - currentLineNumber;\n targetSplitIndex = splitIndex + difference;\n targetUnifiedIndex = unifiedIndex + difference;\n break hunkIterator;\n } else {\n currentLineNumber += content.lines;\n splitIndex += content.lines;\n unifiedIndex += content.lines;\n }\n } else {\n const sideCount =\n side === 'deletions' ? content.deletions : content.additions;\n if (lineNumber < currentLineNumber + sideCount) {\n const indexDifference = lineNumber - currentLineNumber;\n targetUnifiedIndex =\n unifiedIndex +\n (side === 'additions' ? content.deletions : 0) +\n indexDifference;\n targetSplitIndex = splitIndex + indexDifference;\n\n break hunkIterator;\n } else {\n currentLineNumber += sideCount;\n splitIndex += Math.max(content.deletions, content.additions);\n unifiedIndex += content.deletions + content.additions;\n }\n }\n }\n\n break hunkIterator;\n }\n\n if (targetUnifiedIndex == null || targetSplitIndex == null) {\n return undefined;\n }\n return [targetUnifiedIndex, targetSplitIndex];\n };\n\n // FIXME(amadeus): This is a bit of a looming issue that I'll need to resolve:\n // * Do we publicly allow merging of options or do we have individualized setters?\n // * When setting new options, we need to figure out what settings require a\n // re-render and which can just be applied more elegantly\n // * There's also an issue of options that live here on the File class and\n // those that live on the Hunk class, and it's a bit of an issue with passing\n // settings down and mirroring them (not great...)\n public setOptions(options: FileDiffOptions<LAnnotation> | undefined): void {\n if (options == null) return;\n this.options = options;\n this.hunksRenderer.setOptions(this.getHunksRendererOptions(options));\n this.interactionManager.setOptions(\n pluckInteractionOptions(\n options,\n typeof options.hunkSeparators === 'function' ||\n (options.hunkSeparators ?? 'line-info') === 'line-info' ||\n options.hunkSeparators === 'line-info-basic'\n ? this.handleExpandHunk\n : undefined,\n this.getLineIndex\n )\n );\n }\n\n private mergeOptions(options: Partial<FileDiffOptions<LAnnotation>>): void {\n this.options = { ...this.options, ...options };\n }\n\n public setThemeType(themeType: ThemeTypes): void {\n if ((this.options.themeType ?? 'system') === themeType) {\n return;\n }\n this.mergeOptions({ themeType });\n this.hunksRenderer.setThemeType(themeType);\n\n if (this.headerElement != null) {\n if (themeType === 'system') {\n delete this.headerElement.dataset.themeType;\n } else {\n this.headerElement.dataset.themeType = themeType;\n }\n }\n\n // Update pre element theme mode\n if (this.pre != null) {\n switch (themeType) {\n case 'system':\n delete this.pre.dataset.themeType;\n break;\n case 'light':\n case 'dark':\n this.pre.dataset.themeType = themeType;\n break;\n }\n }\n }\n\n public getHoveredLine = (): GetHoveredLineResult<'diff'> | undefined => {\n return this.interactionManager.getHoveredLine();\n };\n\n public setLineAnnotations(\n lineAnnotations: DiffLineAnnotation<LAnnotation>[]\n ): void {\n this.lineAnnotations = lineAnnotations;\n }\n\n private canPartiallyRender(\n forceRender: boolean,\n annotationsChanged: boolean,\n didContentChange: boolean\n ): boolean {\n if (\n forceRender ||\n annotationsChanged ||\n didContentChange ||\n typeof this.options.hunkSeparators === 'function'\n ) {\n return false;\n }\n return true;\n }\n\n public setSelectedLines(range: SelectedLineRange | null): void {\n this.interactionManager.setSelection(range);\n }\n\n public cleanUp(recycle: boolean = false): void {\n this.resizeManager.cleanUp();\n this.interactionManager.cleanUp();\n this.scrollSyncManager.cleanUp();\n this.workerManager?.unsubscribeToThemeChanges(this);\n this.renderRange = undefined;\n\n // Clean up the elements\n if (!this.isContainerManaged) {\n this.fileContainer?.remove();\n }\n if (this.fileContainer?.shadowRoot != null) {\n // Manually help garbage collection\n this.fileContainer.shadowRoot.innerHTML = '';\n }\n this.fileContainer = undefined;\n // Manually help garbage collection\n if (this.pre != null) {\n this.pre.innerHTML = '';\n this.pre = undefined;\n }\n this.codeUnified = undefined;\n this.codeDeletions = undefined;\n this.codeAdditions = undefined;\n this.bufferBefore = undefined;\n this.bufferAfter = undefined;\n this.appliedPreAttributes = undefined;\n this.headerElement = undefined;\n this.headerPrefix = undefined;\n this.headerMetadata = undefined;\n this.lastRenderedHeaderHTML = undefined;\n this.errorWrapper = undefined;\n this.spriteSVG = undefined;\n this.lastRowCount = undefined;\n\n if (recycle) {\n this.hunksRenderer.recycle();\n } else {\n this.hunksRenderer.cleanUp();\n this.workerManager = undefined;\n // Clean up the data\n this.fileDiff = undefined;\n this.deletionFile = undefined;\n this.additionFile = undefined;\n }\n\n this.enabled = false;\n }\n\n public virtualizedSetup(): void {\n this.enabled = true;\n this.workerManager?.subscribeToThemeChanges(this);\n }\n\n public hydrate(props: FileDiffHydrationProps<LAnnotation>): void {\n const { overflow = 'scroll', diffStyle = 'split' } = this.options;\n const { fileContainer, prerenderedHTML } = props;\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 // If we have no pre tag, then we should render\n if (this.pre == null) {\n this.render(props);\n }\n // Otherwise orchestrate our setup\n else {\n const { lineAnnotations, oldFile, newFile, fileDiff } = props;\n this.fileContainer = fileContainer;\n delete this.pre.dataset.dehydrated;\n\n this.lineAnnotations = lineAnnotations ?? this.lineAnnotations;\n this.additionFile = newFile;\n this.deletionFile = oldFile;\n this.fileDiff =\n fileDiff ??\n (oldFile != null && newFile != null\n ? parseDiffFromFile(oldFile, newFile)\n : undefined);\n\n this.hunksRenderer.hydrate(this.fileDiff);\n // FIXME(amadeus): not sure how to handle this yet...\n // this.renderSeparators();\n this.renderAnnotations();\n this.renderGutterUtility();\n this.injectUnsafeCSS();\n this.interactionManager.setup(this.pre);\n this.resizeManager.setup(this.pre, overflow === 'wrap');\n if (overflow === 'scroll' && diffStyle === 'split') {\n this.scrollSyncManager.setup(\n this.pre,\n this.codeDeletions,\n this.codeAdditions\n );\n }\n }\n }\n\n public rerender(): void {\n if (\n !this.enabled ||\n (this.fileDiff == null &&\n this.additionFile == null &&\n this.deletionFile == null)\n ) {\n return;\n }\n this.render({ forceRender: true, renderRange: this.renderRange });\n }\n\n // This wrapper must stay separate from `expandHunk` because subclasses like\n // `VirtualizedFileDiff` replace `expandHunk` with their own instance field\n // after `super()` returns. `InteractionManager` is created in this base\n // constructor, so it needs a stable callback that resolves `this.expandHunk`\n // at click time instead of capturing the base implementation too early.\n public handleExpandHunk = (\n hunkIndex: number,\n direction: ExpansionDirections,\n expansionLineCountOverride?: number\n ): void => {\n this.expandHunk(hunkIndex, direction, expansionLineCountOverride);\n };\n\n public expandHunk = (\n hunkIndex: number,\n direction: ExpansionDirections,\n expansionLineCountOverride?: number\n ): void => {\n this.hunksRenderer.expandHunk(\n hunkIndex,\n direction,\n expansionLineCountOverride\n );\n this.rerender();\n };\n\n public render({\n oldFile,\n newFile,\n fileDiff,\n forceRender = false,\n lineAnnotations,\n fileContainer,\n containerWrapper,\n renderRange,\n }: FileDiffRenderProps<LAnnotation>): boolean {\n if (!this.enabled) {\n // NOTE(amadeus): May need to be a silent failure? Making it loud for now\n // to better understand it\n throw new Error(\n 'FileDiff.render: attempting to call render after cleaned up'\n );\n }\n const { collapsed = false } = this.options;\n const nextRenderRange = collapsed ? undefined : renderRange;\n const filesDidChange =\n oldFile != null &&\n newFile != null &&\n (!areFilesEqual(oldFile, this.deletionFile) ||\n !areFilesEqual(newFile, this.additionFile));\n let diffDidChange = fileDiff != null && fileDiff !== this.fileDiff;\n const annotationsChanged =\n lineAnnotations != null &&\n (lineAnnotations.length > 0 || this.lineAnnotations.length > 0)\n ? lineAnnotations !== this.lineAnnotations\n : false;\n\n if (\n !collapsed &&\n areRenderRangesEqual(nextRenderRange, this.renderRange) &&\n !forceRender &&\n !annotationsChanged &&\n // If using the fileDiff API, lets check to see if they are equal to\n // avoid doing work\n ((fileDiff != null && fileDiff === this.fileDiff) ||\n // If using the oldFile/newFile API then lets check to see if they are\n // equal\n (fileDiff == null && !filesDidChange))\n ) {\n return false;\n }\n\n const { renderRange: previousRenderRange } = this;\n this.renderRange = nextRenderRange;\n this.deletionFile = oldFile;\n this.additionFile = newFile;\n\n if (fileDiff != null) {\n this.fileDiff = fileDiff;\n } else if (oldFile != null && newFile != null && filesDidChange) {\n diffDidChange = true;\n this.fileDiff = parseDiffFromFile(oldFile, newFile);\n }\n\n if (lineAnnotations != null) {\n this.setLineAnnotations(lineAnnotations);\n }\n if (this.fileDiff == null) {\n return false;\n }\n this.hunksRenderer.setOptions({\n ...this.options,\n hunkSeparators:\n typeof this.options.hunkSeparators === 'function'\n ? 'custom'\n : this.options.hunkSeparators,\n });\n\n this.hunksRenderer.setLineAnnotations(this.lineAnnotations);\n\n const {\n diffStyle = 'split',\n disableErrorHandling = false,\n disableFileHeader = false,\n overflow = 'scroll',\n } = this.options;\n\n if (disableFileHeader) {\n // Remove existing header from DOM\n if (this.headerElement != null) {\n this.headerElement.remove();\n this.headerElement = undefined;\n this.lastRenderedHeaderHTML = undefined;\n }\n if (this.headerPrefix != null) {\n this.headerPrefix.remove();\n this.headerPrefix = undefined;\n }\n if (this.headerMetadata != null) {\n this.headerMetadata.remove();\n this.headerMetadata = undefined;\n }\n }\n fileContainer = this.getOrCreateFileContainer(\n fileContainer,\n containerWrapper\n );\n\n if (collapsed) {\n this.removeRenderedCode();\n this.clearAuxiliaryNodes();\n\n try {\n const hunksResult = this.hunksRenderer.renderDiff(\n this.fileDiff,\n EMPTY_RENDER_RANGE\n );\n if (hunksResult?.headerElement != null) {\n this.applyHeaderToDOM(hunksResult.headerElement, fileContainer);\n }\n this.renderSeparators([]);\n this.injectUnsafeCSS();\n } catch (error: unknown) {\n if (disableErrorHandling) {\n throw error;\n }\n console.error(error);\n if (error instanceof Error) {\n this.applyErrorToDOM(error, fileContainer);\n }\n }\n return true;\n }\n\n try {\n const pre = this.getOrCreatePreNode(fileContainer);\n\n // Attempt to partially render\n const didPartiallyRender =\n this.canPartiallyRender(\n forceRender,\n annotationsChanged,\n filesDidChange || diffDidChange\n ) &&\n this.applyPartialRender({\n previousRenderRange,\n renderRange: nextRenderRange,\n });\n\n // If we were unable to partially render, perform a full render\n if (!didPartiallyRender) {\n const hunksResult = this.hunksRenderer.renderDiff(\n this.fileDiff,\n nextRenderRange\n );\n if (hunksResult == null) {\n // FIXME(amadeus): I don't think we actually need this check, as\n // DiffHunksRenderer should probably take care of it for us?\n if (this.workerManager?.isInitialized() === false) {\n void this.workerManager.initialize().then(() => this.rerender());\n }\n return false;\n }\n\n if (hunksResult.headerElement != null) {\n this.applyHeaderToDOM(hunksResult.headerElement, fileContainer);\n }\n if (\n hunksResult.additionsContentAST != null ||\n hunksResult.deletionsContentAST != null ||\n hunksResult.unifiedContentAST != null\n ) {\n this.applyHunksToDOM(pre, hunksResult);\n } else if (this.pre != null) {\n this.pre.remove();\n this.pre = undefined;\n }\n this.renderSeparators(hunksResult.hunkData);\n }\n\n this.applyBuffers(pre, nextRenderRange);\n this.injectUnsafeCSS();\n this.renderAnnotations();\n this.renderGutterUtility();\n\n this.interactionManager.setup(pre);\n this.resizeManager.setup(pre, overflow === 'wrap');\n if (overflow === 'scroll' && diffStyle === 'split') {\n this.scrollSyncManager.setup(\n pre,\n this.codeDeletions,\n this.codeAdditions\n );\n } else {\n this.scrollSyncManager.cleanUp();\n }\n } catch (error: unknown) {\n if (disableErrorHandling) {\n throw error;\n }\n console.error(error);\n if (error instanceof Error) {\n this.applyErrorToDOM(error, fileContainer);\n }\n }\n return true;\n }\n\n private removeRenderedCode(): void {\n this.resizeManager.cleanUp();\n this.scrollSyncManager.cleanUp();\n this.interactionManager.cleanUp();\n\n this.bufferBefore?.remove();\n this.bufferBefore = undefined;\n this.bufferAfter?.remove();\n this.bufferAfter = undefined;\n\n this.codeUnified?.remove();\n this.codeUnified = undefined;\n this.codeDeletions?.remove();\n this.codeDeletions = undefined;\n this.codeAdditions?.remove();\n this.codeAdditions = undefined;\n\n this.pre?.remove();\n this.pre = undefined;\n\n this.appliedPreAttributes = undefined;\n this.lastRowCount = undefined;\n }\n\n private clearAuxiliaryNodes(): void {\n for (const { element } of this.separatorCache.values()) {\n element.remove();\n }\n this.separatorCache.clear();\n\n for (const { element } of this.annotationCache.values()) {\n element.remove();\n }\n this.annotationCache.clear();\n\n this.gutterUtilityContent?.remove();\n this.gutterUtilityContent = undefined;\n }\n\n public renderPlaceholder(height: number): boolean {\n if (this.fileContainer == null) {\n return false;\n }\n this.cleanChildNodes();\n\n if (this.placeHolder == null) {\n const shadowRoot =\n this.fileContainer.shadowRoot ??\n this.fileContainer.attachShadow({ mode: 'open' });\n this.placeHolder = document.createElement('div');\n this.placeHolder.dataset.placeholder = '';\n shadowRoot.appendChild(this.placeHolder);\n }\n this.placeHolder.style.setProperty('height', `${height}px`);\n return true;\n }\n\n private cleanChildNodes() {\n this.resizeManager.cleanUp();\n this.scrollSyncManager.cleanUp();\n this.interactionManager.cleanUp();\n\n this.bufferAfter?.remove();\n this.bufferBefore?.remove();\n this.codeAdditions?.remove();\n this.codeDeletions?.remove();\n this.codeUnified?.remove();\n this.errorWrapper?.remove();\n this.headerElement?.remove();\n this.gutterUtilityContent?.remove();\n this.headerPrefix?.remove();\n this.headerMetadata?.remove();\n this.pre?.remove();\n this.spriteSVG?.remove();\n this.unsafeCSSStyle?.remove();\n\n this.bufferAfter = undefined;\n this.bufferBefore = undefined;\n this.codeAdditions = undefined;\n this.codeDeletions = undefined;\n this.codeUnified = undefined;\n this.errorWrapper = undefined;\n this.headerElement = undefined;\n this.gutterUtilityContent = undefined;\n this.headerPrefix = undefined;\n this.headerMetadata = undefined;\n this.pre = undefined;\n this.spriteSVG = undefined;\n this.unsafeCSSStyle = undefined;\n\n this.lastRenderedHeaderHTML = undefined;\n this.lastRowCount = undefined;\n }\n\n private renderSeparators(hunkData: HunkData[]): void {\n const { hunkSeparators } = this.options;\n if (\n this.isContainerManaged ||\n this.fileContainer == null ||\n typeof hunkSeparators !== 'function'\n ) {\n for (const { element } of this.separatorCache.values()) {\n element.remove();\n }\n this.separatorCache.clear();\n return;\n }\n const staleSeparators = new Map(this.separatorCache);\n for (const hunk of hunkData) {\n const id = hunk.slotName;\n let cache = this.separatorCache.get(id);\n if (cache == null || !areHunkDataEqual(hunk, cache.hunkData)) {\n cache?.element.remove();\n const element = document.createElement('div');\n element.style.display = 'contents';\n element.slot = hunk.slotName;\n const child = hunkSeparators(hunk, this);\n if (child != null) {\n element.appendChild(child);\n }\n this.fileContainer.appendChild(element);\n cache = { element, hunkData: hunk };\n this.separatorCache.set(id, cache);\n }\n staleSeparators.delete(id);\n }\n for (const [id, { element }] of staleSeparators.entries()) {\n this.separatorCache.delete(id);\n element.remove();\n }\n }\n\n private renderAnnotations(): void {\n if (this.isContainerManaged || this.fileContainer == null) {\n for (const { element } of this.annotationCache.values()) {\n element.remove();\n }\n this.annotationCache.clear();\n return;\n }\n const staleAnnotations = new Map(this.annotationCache);\n const { renderAnnotation } = this.options;\n if (renderAnnotation != null && this.lineAnnotations.length > 0) {\n for (const [index, annotation] of this.lineAnnotations.entries()) {\n const id = `${index}-${getLineAnnotationName(annotation)}`;\n let cache = this.annotationCache.get(id);\n if (\n cache == null ||\n !areDiffLineAnnotationsEqual(annotation, cache.annotation)\n ) {\n cache?.element.remove();\n const content = renderAnnotation(annotation);\n // If we can't render anything, then we should not render anything\n // and clear the annotation cache if necessary.\n if (content == null) {\n continue;\n }\n cache = {\n element: createAnnotationWrapperNode(\n getLineAnnotationName(annotation)\n ),\n annotation,\n };\n cache.element.appendChild(content);\n this.fileContainer.appendChild(cache.element);\n this.annotationCache.set(id, cache);\n }\n staleAnnotations.delete(id);\n }\n }\n for (const [id, { element }] of staleAnnotations.entries()) {\n this.annotationCache.delete(id);\n element.remove();\n }\n }\n\n private renderGutterUtility() {\n const renderGutterUtility =\n this.options.renderGutterUtility ?? this.options.renderHoverUtility;\n if (this.fileContainer == null || renderGutterUtility == null) {\n this.gutterUtilityContent?.remove();\n this.gutterUtilityContent = undefined;\n return;\n }\n const element = renderGutterUtility(this.interactionManager.getHoveredLine);\n if (element != null && this.gutterUtilityContent != null) {\n return;\n } else if (element == null) {\n this.gutterUtilityContent?.remove();\n this.gutterUtilityContent = undefined;\n return;\n }\n const gutterUtilityContent = createGutterUtilityContentNode();\n gutterUtilityContent.appendChild(element);\n this.fileContainer.appendChild(gutterUtilityContent);\n this.gutterUtilityContent = gutterUtilityContent;\n }\n\n protected getOrCreateFileContainer(\n fileContainer?: HTMLElement,\n parentNode?: HTMLElement\n ): HTMLElement {\n const previousContainer = this.fileContainer;\n this.fileContainer =\n fileContainer ??\n this.fileContainer ??\n document.createElement(DIFFS_TAG_NAME);\n // NOTE(amadeus): If the container changes, we should reset the rendered\n // HTML\n if (previousContainer != null && previousContainer !== this.fileContainer) {\n this.lastRenderedHeaderHTML = undefined;\n this.headerElement = undefined;\n }\n if (parentNode != null && this.fileContainer.parentNode !== parentNode) {\n parentNode.appendChild(this.fileContainer);\n }\n if (this.spriteSVG == null) {\n const fragment = document.createElement('div');\n fragment.innerHTML = SVGSpriteSheet;\n const firstChild = fragment.firstChild;\n if (firstChild instanceof SVGElement) {\n this.spriteSVG = firstChild;\n this.fileContainer.shadowRoot?.appendChild(this.spriteSVG);\n }\n }\n return this.fileContainer;\n }\n\n protected getFileContainer(): HTMLElement | undefined {\n return this.fileContainer;\n }\n\n private getOrCreatePreNode(container: HTMLElement): HTMLPreElement {\n const shadowRoot =\n container.shadowRoot ?? container.attachShadow({ mode: 'open' });\n // If we haven't created a pre element yet, lets go ahead and do that\n if (this.pre == null) {\n this.pre = document.createElement('pre');\n this.appliedPreAttributes = undefined;\n this.codeUnified = undefined;\n this.codeDeletions = undefined;\n this.codeAdditions = undefined;\n shadowRoot.appendChild(this.pre);\n }\n // If we have a new parent container for the pre element, lets go ahead and\n // move it into the new container\n else if (this.pre.parentNode !== shadowRoot) {\n shadowRoot.appendChild(this.pre);\n this.appliedPreAttributes = undefined;\n }\n\n this.placeHolder?.remove();\n this.placeHolder = undefined;\n\n return this.pre;\n }\n\n private syncCodeNodesFromPre(pre: HTMLPreElement): void {\n this.codeUnified = undefined;\n this.codeDeletions = undefined;\n this.codeAdditions = undefined;\n for (const child of Array.from(pre.children)) {\n if (!(child instanceof HTMLElement)) {\n continue;\n }\n if ('unified' in child.dataset) {\n this.codeUnified = child;\n } else if ('deletions' in child.dataset) {\n this.codeDeletions = child;\n } else if ('additions' in child.dataset) {\n this.codeAdditions = child;\n }\n }\n }\n\n private applyHeaderToDOM(\n headerAST: HASTElement,\n container: HTMLElement\n ): void {\n this.cleanupErrorWrapper();\n this.placeHolder?.remove();\n this.placeHolder = undefined;\n const headerHTML = toHtml(headerAST);\n if (headerHTML !== this.lastRenderedHeaderHTML) {\n const tempDiv = document.createElement('div');\n tempDiv.innerHTML = headerHTML;\n const newHeader = tempDiv.firstElementChild;\n if (!(newHeader instanceof HTMLElement)) {\n return;\n }\n if (this.headerElement != null) {\n container.shadowRoot?.replaceChild(newHeader, this.headerElement);\n } else {\n container.shadowRoot?.prepend(newHeader);\n }\n this.headerElement = newHeader;\n this.lastRenderedHeaderHTML = headerHTML;\n }\n\n if (this.isContainerManaged) return;\n\n const { renderHeaderPrefix, renderHeaderMetadata } = this.options;\n if (this.headerPrefix != null) {\n this.headerPrefix.remove();\n }\n if (this.headerMetadata != null) {\n this.headerMetadata.remove();\n }\n const prefix =\n renderHeaderPrefix?.({\n deletionFile: this.deletionFile,\n additionFile: this.additionFile,\n fileDiff: this.fileDiff,\n }) ?? undefined;\n const content =\n renderHeaderMetadata?.({\n deletionFile: this.deletionFile,\n additionFile: this.additionFile,\n fileDiff: this.fileDiff,\n }) ?? undefined;\n if (prefix != null) {\n this.headerPrefix = document.createElement('div');\n this.headerPrefix.slot = HEADER_PREFIX_SLOT_ID;\n if (prefix instanceof Element) {\n this.headerPrefix.appendChild(prefix);\n } else {\n this.headerPrefix.innerText = `${prefix}`;\n }\n container.appendChild(this.headerPrefix);\n }\n if (content != null) {\n this.headerMetadata = document.createElement('div');\n this.headerMetadata.slot = HEADER_METADATA_SLOT_ID;\n if (content instanceof Element) {\n this.headerMetadata.appendChild(content);\n } else {\n this.headerMetadata.innerText = `${content}`;\n }\n container.appendChild(this.headerMetadata);\n }\n }\n\n private injectUnsafeCSS(): void {\n if (this.fileContainer?.shadowRoot == null) {\n return;\n }\n const { unsafeCSS } = this.options;\n\n if (unsafeCSS == null || unsafeCSS === '') {\n return;\n }\n\n // Create or update the style element\n if (this.unsafeCSSStyle == null) {\n this.unsafeCSSStyle = createUnsafeCSSStyleNode();\n this.fileContainer.shadowRoot.appendChild(this.unsafeCSSStyle);\n }\n // Wrap in @layer unsafe to match SSR behavior\n this.unsafeCSSStyle.innerText = wrapUnsafeCSS(unsafeCSS);\n }\n\n private applyHunksToDOM(\n pre: HTMLPreElement,\n result: HunksRenderResult\n ): void {\n const { overflow = 'scroll' } = this.options;\n const containerSize =\n (this.options.hunkSeparators ?? 'line-info') === 'line-info';\n const rowSpan = overflow === 'wrap' ? result.rowCount : undefined;\n this.cleanupErrorWrapper();\n this.applyPreNodeAttributes(pre, result);\n\n let shouldReplace = false;\n // Create code elements and insert HTML content\n const codeElements: HTMLElement[] = [];\n const unifiedAST = this.hunksRenderer.renderCodeAST('unified', result);\n const deletionsAST = this.hunksRenderer.renderCodeAST('deletions', result);\n const additionsAST = this.hunksRenderer.renderCodeAST('additions', result);\n if (unifiedAST != null) {\n shouldReplace =\n this.codeUnified == null ||\n this.codeAdditions != null ||\n this.codeDeletions != null;\n\n // Clean up addition/deletion elements if necessary\n this.codeDeletions?.remove();\n this.codeDeletions = undefined;\n this.codeAdditions?.remove();\n this.codeAdditions = undefined;\n\n this.codeUnified = getOrCreateCodeNode({\n code: this.codeUnified,\n columnType: 'unified',\n rowSpan,\n containerSize,\n });\n this.codeUnified.innerHTML =\n this.hunksRenderer.renderPartialHTML(unifiedAST);\n codeElements.push(this.codeUnified);\n } else if (deletionsAST != null || additionsAST != null) {\n if (deletionsAST != null) {\n shouldReplace = this.codeDeletions == null || this.codeUnified != null;\n\n // Clean up unified column if necessary\n this.codeUnified?.remove();\n this.codeUnified = undefined;\n\n this.codeDeletions = getOrCreateCodeNode({\n code: this.codeDeletions,\n columnType: 'deletions',\n rowSpan,\n containerSize,\n });\n this.codeDeletions.innerHTML =\n this.hunksRenderer.renderPartialHTML(deletionsAST);\n codeElements.push(this.codeDeletions);\n } else {\n // If we have no deletion column, lets clean it up if it exists\n this.codeDeletions?.remove();\n this.codeDeletions = undefined;\n }\n\n if (additionsAST != null) {\n shouldReplace =\n shouldReplace ||\n this.codeAdditions == null ||\n this.codeUnified != null;\n\n // Clean up unified column if necessary\n this.codeUnified?.remove();\n this.codeUnified = undefined;\n\n this.codeAdditions = getOrCreateCodeNode({\n code: this.codeAdditions,\n columnType: 'additions',\n rowSpan,\n containerSize,\n });\n this.codeAdditions.innerHTML =\n this.hunksRenderer.renderPartialHTML(additionsAST);\n codeElements.push(this.codeAdditions);\n } else {\n // If we have no addition column, lets clean it up if it exists\n this.codeAdditions?.remove();\n this.codeAdditions = undefined;\n }\n } else {\n // if we get in here, there's no content to render, so lets just clean\n // everything up\n this.codeUnified?.remove();\n this.codeUnified = undefined;\n this.codeDeletions?.remove();\n this.codeDeletions = undefined;\n this.codeAdditions?.remove();\n this.codeAdditions = undefined;\n }\n\n if (codeElements.length === 0) {\n pre.textContent = '';\n } else if (shouldReplace) {\n pre.replaceChildren(...codeElements);\n }\n\n this.lastRowCount = result.rowCount;\n }\n\n private applyPartialRender({\n previousRenderRange,\n renderRange,\n }: ApplyPartialRenderProps): boolean {\n const {\n pre,\n codeUnified,\n codeAdditions,\n codeDeletions,\n options: { diffStyle = 'split' },\n } = this;\n if (\n pre == null ||\n // We must have a current and previous render range to do a partial render\n previousRenderRange == null ||\n renderRange == null ||\n // Neither render range may be infinite\n !Number.isFinite(previousRenderRange.totalLines) ||\n !Number.isFinite(renderRange.totalLines) ||\n this.lastRowCount == null\n ) {\n return false;\n }\n const codeElements = this.getCodeColumns(\n diffStyle,\n codeUnified,\n codeDeletions,\n codeAdditions\n );\n if (codeElements == null) {\n return false;\n }\n\n const previousStart = previousRenderRange.startingLine;\n const nextStart = renderRange.startingLine;\n const previousEnd = previousStart + previousRenderRange.totalLines;\n const nextEnd = nextStart + renderRange.totalLines;\n\n const overlapStart = Math.max(previousStart, nextStart);\n const overlapEnd = Math.min(previousEnd, nextEnd);\n if (overlapEnd <= overlapStart) {\n return false;\n }\n\n const trimStart = Math.max(0, overlapStart - previousStart);\n const trimEnd = Math.max(0, previousEnd - overlapEnd);\n\n const trimResult = this.trimColumns({\n columns: codeElements,\n trimStart,\n trimEnd,\n previousStart,\n overlapStart,\n overlapEnd,\n diffStyle,\n });\n if (trimResult < 0) {\n throw new Error('applyPartialRender: failed to trim to overlap');\n }\n\n if (this.lastRowCount < trimResult) {\n throw new Error('applyPartialRender: trimmed beyond DOM row count');\n }\n\n let rowCount = this.lastRowCount - trimResult;\n const renderChunk = (\n startingLine: number,\n totalLines: number\n ): HunksRenderResult | undefined => {\n if (totalLines <= 0 || this.fileDiff == null) {\n return undefined;\n }\n return this.hunksRenderer.renderDiff(this.fileDiff, {\n startingLine,\n totalLines,\n bufferBefore: 0,\n bufferAfter: 0,\n });\n };\n\n const prependResult = renderChunk(\n nextStart,\n Math.max(overlapStart - nextStart, 0)\n );\n if (prependResult == null && nextStart < overlapStart) {\n return false;\n }\n\n const appendResult = renderChunk(\n overlapEnd,\n Math.max(nextEnd - overlapEnd, 0)\n );\n if (appendResult == null && nextEnd > overlapEnd) {\n return false;\n }\n\n const applyChunk = (\n result: HunksRenderResult | undefined,\n insertPosition: 'afterbegin' | 'beforeend'\n ) => {\n if (result == null) {\n return;\n }\n if (diffStyle === 'unified' && !Array.isArray(codeElements)) {\n this.insertPartialHTML(diffStyle, codeElements, result, insertPosition);\n } else if (diffStyle === 'split' && Array.isArray(codeElements)) {\n this.insertPartialHTML(diffStyle, codeElements, result, insertPosition);\n } else {\n throw new Error(\n 'FileDiff.applyPartialRender.applyChunk: invalid chunk application'\n );\n }\n rowCount += result.rowCount;\n };\n\n this.cleanupErrorWrapper();\n applyChunk(prependResult, 'afterbegin');\n applyChunk(appendResult, 'beforeend');\n\n if (this.lastRowCount !== rowCount) {\n this.applyRowSpan(diffStyle, codeElements, rowCount);\n this.lastRowCount = rowCount;\n }\n\n return true;\n }\n\n private insertPartialHTML(\n diffStyle: 'unified',\n columns: ColumnElements,\n result: HunksRenderResult,\n insertPosition: 'afterbegin' | 'beforeend'\n ): void;\n private insertPartialHTML(\n diffStyle: 'split',\n columns: [ColumnElements | undefined, ColumnElements | undefined],\n result: HunksRenderResult,\n insertPosition: 'afterbegin' | 'beforeend'\n ): void;\n private insertPartialHTML(\n diffStyle: 'split' | 'unified',\n columns:\n | [ColumnElements | undefined, ColumnElements | undefined]\n | ColumnElements,\n result: HunksRenderResult,\n insertPosition: 'afterbegin' | 'beforeend'\n ): void {\n if (diffStyle === 'unified' && !Array.isArray(columns)) {\n const unifiedAST = this.hunksRenderer.renderCodeAST('unified', result);\n this.renderPartialColumn(columns, unifiedAST, insertPosition);\n } else if (diffStyle === 'split' && Array.isArray(columns)) {\n const deletionsAST = this.hunksRenderer.renderCodeAST(\n 'deletions',\n result\n );\n const additionsAST = this.hunksRenderer.renderCodeAST(\n 'additions',\n result\n );\n this.renderPartialColumn(columns[0], deletionsAST, insertPosition);\n this.renderPartialColumn(columns[1], additionsAST, insertPosition);\n } else {\n throw new Error(\n 'FileDiff.insertPartialHTML: Invalid argument composition'\n );\n }\n }\n\n private renderPartialColumn(\n column: ColumnElements | undefined,\n ast: ElementContent[] | undefined,\n insertPosition: 'afterbegin' | 'beforeend'\n ) {\n if (column == null || ast == null) {\n return;\n }\n const gutterChildren = getElementChildren(ast[0]);\n const contentChildren = getElementChildren(ast[1]);\n if (gutterChildren == null || contentChildren == null) {\n throw new Error('FileDiff.insertPartialHTML: Unexpected AST structure');\n }\n const firstHASTElement = contentChildren.at(0);\n if (\n insertPosition === 'beforeend' &&\n firstHASTElement?.type === 'element' &&\n typeof firstHASTElement.properties['data-buffer-size'] === 'number'\n ) {\n this.mergeBuffersIfNecessary(\n firstHASTElement.properties['data-buffer-size'],\n column.content.children[column.content.children.length - 1],\n column.gutter.children[column.gutter.children.length - 1],\n gutterChildren,\n contentChildren,\n true\n );\n }\n const lastHASTElement = contentChildren.at(-1);\n if (\n insertPosition === 'afterbegin' &&\n lastHASTElement?.type === 'element' &&\n typeof lastHASTElement.properties['data-buffer-size'] === 'number'\n ) {\n this.mergeBuffersIfNecessary(\n lastHASTElement.properties['data-buffer-size'],\n column.content.children[0],\n column.gutter.children[0],\n gutterChildren,\n contentChildren,\n false\n );\n }\n\n column.gutter.insertAdjacentHTML(\n insertPosition,\n this.hunksRenderer.renderPartialHTML(gutterChildren)\n );\n column.content.insertAdjacentHTML(\n insertPosition,\n this.hunksRenderer.renderPartialHTML(contentChildren)\n );\n }\n\n private mergeBuffersIfNecessary(\n adjustmentSize: number,\n contentElement: Element,\n gutterElement: Element,\n gutterChildren: ElementContent[],\n contentChildren: ElementContent[],\n fromStart: boolean\n ) {\n if (\n !(contentElement instanceof HTMLElement) ||\n !(gutterElement instanceof HTMLElement)\n ) {\n return;\n }\n const currentSize = this.getBufferSize(contentElement.dataset);\n if (currentSize == null) {\n return;\n }\n if (fromStart) {\n gutterChildren.shift();\n contentChildren.shift();\n } else {\n gutterChildren.pop();\n contentChildren.pop();\n }\n this.updateBufferSize(contentElement, currentSize + adjustmentSize);\n this.updateBufferSize(gutterElement, currentSize + adjustmentSize);\n }\n\n private applyRowSpan(\n diffStyle: 'split' | 'unified',\n columns:\n | [ColumnElements | undefined, ColumnElements | undefined]\n | ColumnElements,\n rowCount: number\n ): void {\n const applySpan = (column: ColumnElements | undefined) => {\n if (column == null) {\n return;\n }\n column.gutter.style.setProperty('grid-row', `span ${rowCount}`);\n column.content.style.setProperty('grid-row', `span ${rowCount}`);\n };\n if (diffStyle === 'unified' && !Array.isArray(columns)) {\n applySpan(columns);\n } else if (diffStyle === 'split' && Array.isArray(columns)) {\n applySpan(columns[0]);\n applySpan(columns[1]);\n } else {\n throw new Error('dun fuuuuked up');\n }\n }\n\n private trimColumnRows(\n columns: ColumnElements | undefined,\n preTrimCount: number,\n postTrimStart: number\n ): number {\n let visibleLineIndex = 0;\n let rowCount = 0;\n let rowIndex = 0;\n let pendingMetadataTrim = false;\n const hasPostTrim = postTrimStart >= 0;\n\n if (columns == null) {\n return 0;\n }\n const contentChildren = Array.from(columns.content.children);\n const gutterChildren = Array.from(columns.gutter.children);\n if (contentChildren.length !== gutterChildren.length) {\n throw new Error('FileDiff.trimColumnRows: columns do not match');\n }\n\n while (rowIndex < contentChildren.length) {\n if (preTrimCount <= 0 && !hasPostTrim && !pendingMetadataTrim) {\n break;\n }\n const gutterElement = gutterChildren[rowIndex];\n const contentElement = contentChildren[rowIndex];\n rowIndex++;\n\n if (\n !(gutterElement instanceof HTMLElement) ||\n !(contentElement instanceof HTMLElement)\n ) {\n console.error({ gutterElement, contentElement });\n throw new Error('FileDiff.trimColumnRows: invalid row elements');\n }\n\n if (pendingMetadataTrim) {\n pendingMetadataTrim = false;\n if (\n (gutterElement.dataset.gutterBuffer === 'annotation' &&\n 'lineAnnotation' in contentElement.dataset) ||\n (gutterElement.dataset.gutterBuffer === 'metadata' &&\n 'noNewline' in contentElement.dataset)\n ) {\n gutterElement.remove();\n contentElement.remove();\n rowCount++;\n continue;\n }\n }\n\n // If we found a line element, lets trim it if necessary\n if (\n 'lineIndex' in gutterElement.dataset &&\n 'lineIndex' in contentElement.dataset\n ) {\n if (\n preTrimCount > 0 ||\n (hasPostTrim && visibleLineIndex >= postTrimStart)\n ) {\n gutterElement.remove();\n contentElement.remove();\n if (preTrimCount > 0) {\n preTrimCount--;\n if (preTrimCount === 0) {\n pendingMetadataTrim = true;\n }\n }\n rowCount++;\n }\n visibleLineIndex++;\n continue;\n }\n\n // Separators should be removed, but don't count towards line indices\n if (\n 'separator' in gutterElement.dataset &&\n 'separator' in contentElement.dataset\n ) {\n if (\n preTrimCount > 0 ||\n (hasPostTrim && visibleLineIndex >= postTrimStart)\n ) {\n gutterElement.remove();\n contentElement.remove();\n rowCount++;\n }\n continue;\n }\n\n // Annotations should be removed, but don't count towards line indices\n if (\n gutterElement.dataset.gutterBuffer === 'annotation' &&\n 'lineAnnotation' in contentElement.dataset\n ) {\n if (\n preTrimCount > 0 ||\n (hasPostTrim && visibleLineIndex >= postTrimStart)\n ) {\n gutterElement.remove();\n contentElement.remove();\n rowCount++;\n }\n continue;\n }\n\n if (\n gutterElement.dataset.gutterBuffer === 'metadata' &&\n 'noNewline' in contentElement.dataset\n ) {\n if (\n preTrimCount > 0 ||\n (hasPostTrim && visibleLineIndex >= postTrimStart)\n ) {\n gutterElement.remove();\n contentElement.remove();\n rowCount++;\n }\n continue;\n }\n\n if (\n gutterElement.dataset.gutterBuffer === 'buffer' &&\n 'contentBuffer' in contentElement.dataset\n ) {\n const totalRows = this.getBufferSize(contentElement.dataset);\n if (totalRows == null) {\n throw new Error('FileDiff.trimColumnRows: invalid element');\n }\n if (preTrimCount > 0) {\n const rowsToRemove = Math.min(preTrimCount, totalRows);\n const newSize = totalRows - rowsToRemove;\n if (newSize > 0) {\n this.updateBufferSize(gutterElement, newSize);\n this.updateBufferSize(contentElement, newSize);\n rowCount += rowsToRemove;\n } else {\n gutterElement.remove();\n contentElement.remove();\n rowCount += totalRows;\n }\n preTrimCount -= rowsToRemove;\n }\n // If we are in a post clip era...\n else if (hasPostTrim) {\n const bufferStart = visibleLineIndex;\n const bufferEnd = visibleLineIndex + totalRows - 1;\n if (postTrimStart <= bufferStart) {\n gutterElement.remove();\n contentElement.remove();\n rowCount += totalRows;\n } else if (postTrimStart <= bufferEnd) {\n const rowsToRemove = bufferEnd - postTrimStart + 1;\n const newSize = totalRows - rowsToRemove;\n this.updateBufferSize(gutterElement, newSize);\n this.updateBufferSize(contentElement, newSize);\n rowCount += rowsToRemove;\n }\n }\n visibleLineIndex += totalRows;\n continue;\n }\n\n console.error({ gutterElement, contentElement });\n throw new Error('FileDiff.trimColumnRows: unknown row elements');\n }\n\n return rowCount;\n }\n\n private trimColumns({\n columns,\n diffStyle,\n overlapEnd,\n overlapStart,\n previousStart,\n trimEnd,\n trimStart,\n // NOTE(amadeus): If we return -1 it means something went wrong\n // with the trim...\n // oxlint-disable-next-line no-redundant-type-constituents\n }: TrimColumnsToOverlapProps): number | -1 {\n const preTrimCount = Math.max(0, overlapStart - previousStart);\n const postTrimStart = overlapEnd - previousStart;\n if (postTrimStart < 0) {\n throw new Error('FileDiff.trimColumns: overlap ends before previous');\n }\n const shouldTrimStart = trimStart > 0;\n const shouldTrimEnd = trimEnd > 0;\n if (!shouldTrimStart && !shouldTrimEnd) {\n return 0;\n }\n const effectivePreTrimCount = shouldTrimStart ? preTrimCount : 0;\n const effectivePostTrimStart = shouldTrimEnd ? postTrimStart : -1;\n\n if (diffStyle === 'unified' && !Array.isArray(columns)) {\n const removedRows = this.trimColumnRows(\n columns,\n effectivePreTrimCount,\n effectivePostTrimStart\n );\n return removedRows;\n } else if (diffStyle === 'split' && Array.isArray(columns)) {\n const deletionsTrim = this.trimColumnRows(\n columns[0],\n effectivePreTrimCount,\n effectivePostTrimStart\n );\n const additionsTrim = this.trimColumnRows(\n columns[1],\n effectivePreTrimCount,\n effectivePostTrimStart\n );\n // We should avoid the trim validation if we are split but\n // there's only one side\n if (\n columns[0] != null &&\n columns[1] != null &&\n deletionsTrim !== additionsTrim\n ) {\n throw new Error('FileDiff.trimColumns: split columns out of sync');\n }\n return columns[0] != null ? deletionsTrim : additionsTrim;\n } else {\n console.error({ diffStyle, columns });\n throw new Error('FileDiff.trimColumns: Invalid columns for diffType');\n }\n }\n\n private getBufferSize(properties: DOMStringMap): number | undefined {\n const parsed = Number.parseInt(properties?.bufferSize ?? '', 10);\n return Number.isNaN(parsed) ? undefined : parsed;\n }\n\n private updateBufferSize(element: HTMLElement, size: number): void {\n element.dataset.bufferSize = `${size}`;\n element.style.setProperty('grid-row', `span ${size}`);\n element.style.setProperty('min-height', `calc(${size} * 1lh)`);\n }\n\n private getCodeColumns(\n diffStyle: 'split' | 'unified',\n codeUnified: HTMLElement | undefined,\n codeDeletions: HTMLElement | undefined,\n codeAdditions: HTMLElement | undefined\n ):\n | [ColumnElements | undefined, ColumnElements | undefined]\n | ColumnElements\n | undefined {\n function getColumns(\n code: HTMLElement | undefined\n ): ColumnElements | undefined {\n if (code == null) {\n return undefined;\n }\n const gutter = code.children[0];\n const content = code.children[1];\n if (\n !(gutter instanceof HTMLElement) ||\n !(content instanceof HTMLElement) ||\n gutter.dataset.gutter == null ||\n content.dataset.content == null\n ) {\n return undefined;\n }\n return { gutter, content };\n }\n\n if (diffStyle === 'unified') {\n return getColumns(codeUnified);\n } else {\n const deletions = getColumns(codeDeletions);\n const additions = getColumns(codeAdditions);\n return deletions != null || additions != null\n ? [deletions, additions]\n : undefined;\n }\n }\n\n private applyBuffers(\n pre: HTMLPreElement,\n renderRange: RenderRange | undefined\n ) {\n const { disableVirtualizationBuffers = false } = this.options;\n if (disableVirtualizationBuffers || renderRange == null) {\n if (this.bufferBefore != null) {\n this.bufferBefore.remove();\n this.bufferBefore = undefined;\n }\n if (this.bufferAfter != null) {\n this.bufferAfter.remove();\n this.bufferAfter = undefined;\n }\n return;\n }\n // NOTE(amadeus): A very hacky pass at buffers outside the pre elements...\n // i may need to improve this...\n if (renderRange.bufferBefore > 0) {\n if (this.bufferBefore == null) {\n this.bufferBefore = document.createElement('div');\n this.bufferBefore.dataset.virtualizerBuffer = 'before';\n pre.before(this.bufferBefore);\n }\n this.bufferBefore.style.setProperty(\n 'height',\n `${renderRange.bufferBefore}px`\n );\n this.bufferBefore.style.setProperty('contain', 'strict');\n } else if (this.bufferBefore != null) {\n this.bufferBefore.remove();\n this.bufferBefore = undefined;\n }\n\n if (renderRange.bufferAfter > 0) {\n if (this.bufferAfter == null) {\n this.bufferAfter = document.createElement('div');\n this.bufferAfter.dataset.virtualizerBuffer = 'after';\n pre.after(this.bufferAfter);\n }\n this.bufferAfter.style.setProperty(\n 'height',\n `${renderRange.bufferAfter}px`\n );\n this.bufferAfter.style.setProperty('contain', 'strict');\n } else if (this.bufferAfter != null) {\n this.bufferAfter.remove();\n this.bufferAfter = undefined;\n }\n }\n\n protected applyPreNodeAttributes(\n pre: HTMLPreElement,\n {\n themeStyles,\n baseThemeType,\n additionsContentAST,\n deletionsContentAST,\n totalLines,\n }: HunksRenderResult,\n customProperties?: CustomPreProperties\n ): void {\n const {\n diffIndicators = 'bars',\n disableBackground = false,\n disableLineNumbers = false,\n overflow = 'scroll',\n themeType = 'system',\n diffStyle = 'split',\n } = this.options;\n const preProperties: PrePropertiesConfig = {\n type: 'diff',\n diffIndicators,\n disableBackground,\n disableLineNumbers,\n overflow,\n split:\n diffStyle === 'unified'\n ? false\n : additionsContentAST != null && deletionsContentAST != null,\n themeStyles,\n themeType: baseThemeType ?? themeType,\n totalLines,\n customProperties,\n };\n if (arePrePropertiesEqual(preProperties, this.appliedPreAttributes)) {\n return;\n }\n setPreNodeProperties(pre, preProperties);\n this.appliedPreAttributes = preProperties;\n }\n\n private applyErrorToDOM(error: Error, container: HTMLElement) {\n this.cleanupErrorWrapper();\n const pre = this.getOrCreatePreNode(container);\n pre.innerHTML = '';\n pre.remove();\n this.pre = undefined;\n this.appliedPreAttributes = undefined;\n const shadowRoot =\n container.shadowRoot ?? container.attachShadow({ mode: 'open' });\n this.errorWrapper ??= document.createElement('div');\n this.errorWrapper.dataset.errorWrapper = '';\n this.errorWrapper.innerHTML = '';\n shadowRoot.appendChild(this.errorWrapper);\n const errorMessage = document.createElement('div');\n errorMessage.dataset.errorMessage = '';\n errorMessage.innerText = error.message;\n this.errorWrapper.appendChild(errorMessage);\n const errorStack = document.createElement('pre');\n errorStack.dataset.errorStack = '';\n errorStack.innerText = error.stack ?? 'No Error Stack';\n this.errorWrapper.appendChild(errorStack);\n }\n\n private cleanupErrorWrapper() {\n this.errorWrapper?.remove();\n this.errorWrapper = undefined;\n }\n}\n\nfunction getElementChildren(\n node: ElementContent | undefined\n): ElementContent[] | undefined {\n if (node == null || node.type !== 'element') {\n return undefined;\n }\n return node.children ?? [];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsJA,IAAI,aAAa;AAEjB,IAAa,WAAb,MAA+C;CAG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C9B,KAAI,QAAQ,QAAQ,KAAK,SAAS,UAChC;AAEF,QAAO,KAAK,YAAY,EAAE"}
|
|
1
|
+
{"version":3,"file":"FileDiff.js","names":["options: FileDiffOptions<LAnnotation>","workerManager?: WorkerPoolManager | undefined","targetUnifiedIndex: number | undefined","targetSplitIndex: number | undefined","error: unknown","codeElements: HTMLElement[]","preProperties: PrePropertiesConfig"],"sources":["../../src/components/FileDiff.ts"],"sourcesContent":["import type { ElementContent, Element as HASTElement } from 'hast';\nimport { toHtml } from 'hast-util-to-html';\n\nimport {\n DEFAULT_THEMES,\n DIFFS_TAG_NAME,\n EMPTY_RENDER_RANGE,\n HEADER_METADATA_SLOT_ID,\n HEADER_PREFIX_SLOT_ID,\n UNSAFE_CSS_ATTRIBUTE,\n} from '../constants';\nimport {\n type GetHoveredLineResult,\n type GetLineIndexUtility,\n InteractionManager,\n type InteractionManagerBaseOptions,\n pluckInteractionOptions,\n type SelectedLineRange,\n} from '../managers/InteractionManager';\nimport { ResizeManager } from '../managers/ResizeManager';\nimport { ScrollSyncManager } from '../managers/ScrollSyncManager';\nimport {\n DiffHunksRenderer,\n type HunksRenderResult,\n} from '../renderers/DiffHunksRenderer';\nimport { SVGSpriteSheet } from '../sprite';\nimport type {\n BaseDiffOptions,\n CustomPreProperties,\n DiffLineAnnotation,\n ExpansionDirections,\n FileContents,\n FileDiffMetadata,\n HunkData,\n HunkSeparators,\n PrePropertiesConfig,\n RenderHeaderMetadataCallback,\n RenderHeaderPrefixCallback,\n RenderRange,\n SelectionSide,\n ThemeTypes,\n} from '../types';\nimport { areDiffLineAnnotationsEqual } from '../utils/areDiffLineAnnotationsEqual';\nimport { areFilesEqual } from '../utils/areFilesEqual';\nimport { areHunkDataEqual } from '../utils/areHunkDataEqual';\nimport { arePrePropertiesEqual } from '../utils/arePrePropertiesEqual';\nimport { areRenderRangesEqual } from '../utils/areRenderRangesEqual';\nimport { createAnnotationWrapperNode } from '../utils/createAnnotationWrapperNode';\nimport { createGutterUtilityContentNode } from '../utils/createGutterUtilityContentNode';\nimport { createUnsafeCSSStyleNode } from '../utils/createUnsafeCSSStyleNode';\nimport { wrapUnsafeCSS } from '../utils/cssWrappers';\nimport { getLineAnnotationName } from '../utils/getLineAnnotationName';\nimport { getOrCreateCodeNode } from '../utils/getOrCreateCodeNode';\nimport { parseDiffFromFile } from '../utils/parseDiffFromFile';\nimport { prerenderHTMLIfNecessary } from '../utils/prerenderHTMLIfNecessary';\nimport { setPreNodeProperties } from '../utils/setWrapperNodeProps';\nimport type { WorkerPoolManager } from '../worker';\nimport { DiffsContainerLoaded } from './web-components';\n\nexport interface FileDiffRenderProps<LAnnotation> {\n fileDiff?: FileDiffMetadata;\n oldFile?: FileContents;\n newFile?: FileContents;\n forceRender?: boolean;\n fileContainer?: HTMLElement;\n containerWrapper?: HTMLElement;\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[];\n renderRange?: RenderRange;\n}\n\nexport interface FileDiffHydrationProps<LAnnotation> extends Omit<\n FileDiffRenderProps<LAnnotation>,\n 'fileContainer'\n> {\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\n\nexport interface FileDiffOptions<LAnnotation>\n extends\n Omit<BaseDiffOptions, 'hunkSeparators'>,\n InteractionManagerBaseOptions<'diff'> {\n hunkSeparators?:\n | Exclude<HunkSeparators, 'custom'> /**\n * @deprecated Custom hunk separator functions are deprecated and will be\n * removed in a future version.\n */\n | ((\n hunk: HunkData,\n instance: FileDiff<LAnnotation>\n ) => HTMLElement | DocumentFragment | null | undefined);\n disableFileHeader?: boolean;\n /**\n * @deprecated Use `enableGutterUtility` instead.\n */\n enableHoverUtility?: boolean;\n renderHeaderPrefix?: RenderHeaderPrefixCallback;\n renderHeaderMetadata?: RenderHeaderMetadataCallback;\n /**\n * When true, errors during rendering are rethrown instead of being caught\n * and displayed in the DOM. Useful for testing or when you want to handle\n * errors yourself.\n */\n disableErrorHandling?: boolean;\n renderAnnotation?(\n annotation: DiffLineAnnotation<LAnnotation>\n ): HTMLElement | undefined;\n renderGutterUtility?(\n getHoveredRow: () => GetHoveredLineResult<'diff'> | undefined\n ): HTMLElement | null | undefined;\n /**\n * @deprecated Use `renderGutterUtility` instead.\n */\n renderHoverUtility?(\n getHoveredRow: () => GetHoveredLineResult<'diff'> | undefined\n ): HTMLElement | null | undefined;\n}\n\ninterface AnnotationElementCache<LAnnotation> {\n element: HTMLElement;\n annotation: DiffLineAnnotation<LAnnotation>;\n}\n\ninterface CustomHunkElementCache {\n element: HTMLElement;\n hunkData: HunkData;\n}\n\ninterface ColumnElements {\n gutter: HTMLElement;\n content: HTMLElement;\n}\n\ninterface TrimColumnsToOverlapProps {\n columns:\n | [ColumnElements | undefined, ColumnElements | undefined]\n | ColumnElements;\n diffStyle: 'split' | 'unified';\n overlapEnd: number;\n overlapStart: number;\n previousStart: number;\n trimEnd: number;\n trimStart: number;\n}\n\ninterface ApplyPartialRenderProps {\n previousRenderRange: RenderRange | undefined;\n renderRange: RenderRange | undefined;\n}\n\nlet instanceId = -1;\n\nexport class FileDiff<LAnnotation = undefined> {\n // NOTE(amadeus): We sorta need this to ensure the web-component file is\n // properly loaded\n static LoadedCustomComponent: boolean = DiffsContainerLoaded;\n\n readonly __id: string = `file-diff:${++instanceId}`;\n\n protected fileContainer: HTMLElement | undefined;\n protected spriteSVG: SVGElement | undefined;\n protected pre: HTMLPreElement | undefined;\n protected codeUnified: HTMLElement | undefined;\n protected codeDeletions: HTMLElement | undefined;\n protected codeAdditions: HTMLElement | undefined;\n protected bufferBefore: HTMLElement | undefined;\n protected bufferAfter: HTMLElement | undefined;\n protected unsafeCSSStyle: HTMLStyleElement | undefined;\n protected gutterUtilityContent: HTMLElement | undefined;\n\n protected headerElement: HTMLElement | undefined;\n protected headerPrefix: HTMLElement | undefined;\n protected headerMetadata: HTMLElement | undefined;\n protected separatorCache: Map<string, CustomHunkElementCache> = new Map();\n protected errorWrapper: HTMLElement | undefined;\n protected placeHolder: HTMLElement | undefined;\n\n protected hunksRenderer: DiffHunksRenderer<LAnnotation>;\n protected resizeManager: ResizeManager;\n protected scrollSyncManager: ScrollSyncManager;\n protected interactionManager: InteractionManager<'diff'>;\n\n protected annotationCache: Map<string, AnnotationElementCache<LAnnotation>> =\n new Map();\n protected lineAnnotations: DiffLineAnnotation<LAnnotation>[] = [];\n\n protected deletionFile: FileContents | undefined;\n protected additionFile: FileContents | undefined;\n protected fileDiff: FileDiffMetadata | undefined;\n protected renderRange: RenderRange | undefined;\n protected appliedPreAttributes: PrePropertiesConfig | undefined;\n protected lastRenderedHeaderHTML: string | undefined;\n protected lastRowCount: number | undefined;\n\n protected enabled = true;\n\n constructor(\n public options: FileDiffOptions<LAnnotation> = { theme: DEFAULT_THEMES },\n protected workerManager?: WorkerPoolManager | undefined,\n protected isContainerManaged = false\n ) {\n this.hunksRenderer = this.createHunksRenderer(options);\n this.resizeManager = new ResizeManager();\n this.scrollSyncManager = new ScrollSyncManager();\n this.interactionManager = new InteractionManager(\n 'diff',\n pluckInteractionOptions(\n options,\n typeof options.hunkSeparators === 'function' ||\n (options.hunkSeparators ?? 'line-info') === 'line-info' ||\n options.hunkSeparators === 'line-info-basic'\n ? this.handleExpandHunk\n : undefined,\n this.getLineIndex\n )\n );\n this.workerManager?.subscribeToThemeChanges(this);\n this.enabled = true;\n }\n\n protected handleHighlightRender = (): void => {\n this.rerender();\n };\n\n protected getHunksRendererOptions(\n options: FileDiffOptions<LAnnotation>\n ): BaseDiffOptions {\n return {\n ...options,\n hunkSeparators:\n typeof options.hunkSeparators === 'function'\n ? 'custom'\n : options.hunkSeparators,\n };\n }\n\n protected createHunksRenderer(\n options: FileDiffOptions<LAnnotation>\n ): DiffHunksRenderer<LAnnotation> {\n return new DiffHunksRenderer(\n this.getHunksRendererOptions(options),\n this.handleHighlightRender,\n this.workerManager\n );\n }\n\n public getLineIndex: GetLineIndexUtility = (\n lineNumber: number,\n side: SelectionSide = 'additions'\n ) => {\n if (this.fileDiff == null) {\n return undefined;\n }\n const lastHunk = this.fileDiff.hunks.at(-1);\n let targetUnifiedIndex: number | undefined;\n let targetSplitIndex: number | undefined;\n hunkIterator: for (const hunk of this.fileDiff.hunks) {\n let currentLineNumber =\n side === 'deletions' ? hunk.deletionStart : hunk.additionStart;\n const hunkCount =\n side === 'deletions' ? hunk.deletionCount : hunk.additionCount;\n let splitIndex = hunk.splitLineStart;\n let unifiedIndex = hunk.unifiedLineStart;\n\n // If we've selected a line between or before a hunk,\n // we should grab its index here\n if (lineNumber < currentLineNumber) {\n const difference = currentLineNumber - lineNumber;\n targetUnifiedIndex = Math.max(unifiedIndex - difference, 0);\n targetSplitIndex = Math.max(splitIndex - difference, 0);\n break hunkIterator;\n }\n\n if (lineNumber >= currentLineNumber + hunkCount) {\n if (hunk === lastHunk) {\n const difference = lineNumber - (currentLineNumber + hunkCount);\n targetUnifiedIndex =\n unifiedIndex + hunk.unifiedLineCount + difference;\n targetSplitIndex = splitIndex + hunk.splitLineCount + difference;\n break hunkIterator;\n }\n continue;\n }\n\n for (const content of hunk.hunkContent) {\n if (content.type === 'context') {\n if (lineNumber < currentLineNumber + content.lines) {\n const difference = lineNumber - currentLineNumber;\n targetSplitIndex = splitIndex + difference;\n targetUnifiedIndex = unifiedIndex + difference;\n break hunkIterator;\n } else {\n currentLineNumber += content.lines;\n splitIndex += content.lines;\n unifiedIndex += content.lines;\n }\n } else {\n const sideCount =\n side === 'deletions' ? content.deletions : content.additions;\n if (lineNumber < currentLineNumber + sideCount) {\n const indexDifference = lineNumber - currentLineNumber;\n targetUnifiedIndex =\n unifiedIndex +\n (side === 'additions' ? content.deletions : 0) +\n indexDifference;\n targetSplitIndex = splitIndex + indexDifference;\n\n break hunkIterator;\n } else {\n currentLineNumber += sideCount;\n splitIndex += Math.max(content.deletions, content.additions);\n unifiedIndex += content.deletions + content.additions;\n }\n }\n }\n\n break hunkIterator;\n }\n\n if (targetUnifiedIndex == null || targetSplitIndex == null) {\n return undefined;\n }\n return [targetUnifiedIndex, targetSplitIndex];\n };\n\n // FIXME(amadeus): This is a bit of a looming issue that I'll need to resolve:\n // * Do we publicly allow merging of options or do we have individualized setters?\n // * When setting new options, we need to figure out what settings require a\n // re-render and which can just be applied more elegantly\n // * There's also an issue of options that live here on the File class and\n // those that live on the Hunk class, and it's a bit of an issue with passing\n // settings down and mirroring them (not great...)\n public setOptions(options: FileDiffOptions<LAnnotation> | undefined): void {\n if (options == null) return;\n this.options = options;\n this.hunksRenderer.setOptions(this.getHunksRendererOptions(options));\n this.interactionManager.setOptions(\n pluckInteractionOptions(\n options,\n typeof options.hunkSeparators === 'function' ||\n (options.hunkSeparators ?? 'line-info') === 'line-info' ||\n options.hunkSeparators === 'line-info-basic'\n ? this.handleExpandHunk\n : undefined,\n this.getLineIndex\n )\n );\n }\n\n private mergeOptions(options: Partial<FileDiffOptions<LAnnotation>>): void {\n this.options = { ...this.options, ...options };\n }\n\n public setThemeType(themeType: ThemeTypes): void {\n if ((this.options.themeType ?? 'system') === themeType) {\n return;\n }\n this.mergeOptions({ themeType });\n this.hunksRenderer.setThemeType(themeType);\n\n if (this.headerElement != null) {\n if (themeType === 'system') {\n delete this.headerElement.dataset.themeType;\n } else {\n this.headerElement.dataset.themeType = themeType;\n }\n }\n\n // Update pre element theme mode\n if (this.pre != null) {\n switch (themeType) {\n case 'system':\n delete this.pre.dataset.themeType;\n break;\n case 'light':\n case 'dark':\n this.pre.dataset.themeType = themeType;\n break;\n }\n }\n }\n\n public getHoveredLine = (): GetHoveredLineResult<'diff'> | undefined => {\n return this.interactionManager.getHoveredLine();\n };\n\n public setLineAnnotations(\n lineAnnotations: DiffLineAnnotation<LAnnotation>[]\n ): void {\n this.lineAnnotations = lineAnnotations;\n }\n\n private canPartiallyRender(\n forceRender: boolean,\n annotationsChanged: boolean,\n didContentChange: boolean\n ): boolean {\n if (\n forceRender ||\n annotationsChanged ||\n didContentChange ||\n typeof this.options.hunkSeparators === 'function'\n ) {\n return false;\n }\n return true;\n }\n\n public setSelectedLines(range: SelectedLineRange | null): void {\n this.interactionManager.setSelection(range);\n }\n\n public cleanUp(recycle: boolean = false): void {\n this.resizeManager.cleanUp();\n this.interactionManager.cleanUp();\n this.scrollSyncManager.cleanUp();\n this.workerManager?.unsubscribeToThemeChanges(this);\n this.renderRange = undefined;\n\n // Clean up the elements\n if (!this.isContainerManaged) {\n this.fileContainer?.remove();\n }\n if (this.fileContainer?.shadowRoot != null) {\n // Manually help garbage collection\n this.fileContainer.shadowRoot.innerHTML = '';\n }\n this.fileContainer = undefined;\n // Manually help garbage collection\n if (this.pre != null) {\n this.pre.innerHTML = '';\n this.pre = undefined;\n }\n this.codeUnified = undefined;\n this.codeDeletions = undefined;\n this.codeAdditions = undefined;\n this.bufferBefore = undefined;\n this.bufferAfter = undefined;\n this.appliedPreAttributes = undefined;\n this.headerElement = undefined;\n this.headerPrefix = undefined;\n this.headerMetadata = undefined;\n this.lastRenderedHeaderHTML = undefined;\n this.errorWrapper = undefined;\n this.spriteSVG = undefined;\n this.lastRowCount = undefined;\n\n if (recycle) {\n this.hunksRenderer.recycle();\n } else {\n this.hunksRenderer.cleanUp();\n this.workerManager = undefined;\n // Clean up the data\n this.fileDiff = undefined;\n this.deletionFile = undefined;\n this.additionFile = undefined;\n }\n\n this.enabled = false;\n }\n\n public virtualizedSetup(): void {\n this.enabled = true;\n this.workerManager?.subscribeToThemeChanges(this);\n }\n\n public hydrate(props: FileDiffHydrationProps<LAnnotation>): void {\n const { overflow = 'scroll', diffStyle = 'split' } = this.options;\n const { fileContainer, prerenderedHTML } = props;\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 // If we have no pre tag, then we should render\n if (this.pre == null) {\n this.render(props);\n }\n // Otherwise orchestrate our setup\n else {\n const { lineAnnotations, oldFile, newFile, fileDiff } = props;\n this.fileContainer = fileContainer;\n delete this.pre.dataset.dehydrated;\n\n this.lineAnnotations = lineAnnotations ?? this.lineAnnotations;\n this.additionFile = newFile;\n this.deletionFile = oldFile;\n this.fileDiff =\n fileDiff ??\n (oldFile != null && newFile != null\n ? parseDiffFromFile(oldFile, newFile)\n : undefined);\n\n this.hunksRenderer.hydrate(this.fileDiff);\n // FIXME(amadeus): not sure how to handle this yet...\n // this.renderSeparators();\n this.renderAnnotations();\n this.renderGutterUtility();\n this.injectUnsafeCSS();\n this.interactionManager.setup(this.pre);\n this.resizeManager.setup(this.pre, overflow === 'wrap');\n if (overflow === 'scroll' && diffStyle === 'split') {\n this.scrollSyncManager.setup(\n this.pre,\n this.codeDeletions,\n this.codeAdditions\n );\n }\n }\n }\n\n public rerender(): void {\n if (\n !this.enabled ||\n (this.fileDiff == null &&\n this.additionFile == null &&\n this.deletionFile == null)\n ) {\n return;\n }\n this.render({ forceRender: true, renderRange: this.renderRange });\n }\n\n // This wrapper must stay separate from `expandHunk` because subclasses like\n // `VirtualizedFileDiff` replace `expandHunk` with their own instance field\n // after `super()` returns. `InteractionManager` is created in this base\n // constructor, so it needs a stable callback that resolves `this.expandHunk`\n // at click time instead of capturing the base implementation too early.\n public handleExpandHunk = (\n hunkIndex: number,\n direction: ExpansionDirections,\n expansionLineCountOverride?: number\n ): void => {\n this.expandHunk(hunkIndex, direction, expansionLineCountOverride);\n };\n\n public expandHunk = (\n hunkIndex: number,\n direction: ExpansionDirections,\n expansionLineCountOverride?: number\n ): void => {\n this.hunksRenderer.expandHunk(\n hunkIndex,\n direction,\n expansionLineCountOverride\n );\n this.rerender();\n };\n\n public render({\n oldFile,\n newFile,\n fileDiff,\n forceRender = false,\n lineAnnotations,\n fileContainer,\n containerWrapper,\n renderRange,\n }: FileDiffRenderProps<LAnnotation>): boolean {\n if (!this.enabled) {\n // NOTE(amadeus): May need to be a silent failure? Making it loud for now\n // to better understand it\n throw new Error(\n 'FileDiff.render: attempting to call render after cleaned up'\n );\n }\n const { collapsed = false } = this.options;\n const nextRenderRange = collapsed ? undefined : renderRange;\n const filesDidChange =\n oldFile != null &&\n newFile != null &&\n (!areFilesEqual(oldFile, this.deletionFile) ||\n !areFilesEqual(newFile, this.additionFile));\n let diffDidChange = fileDiff != null && fileDiff !== this.fileDiff;\n const annotationsChanged =\n lineAnnotations != null &&\n (lineAnnotations.length > 0 || this.lineAnnotations.length > 0)\n ? lineAnnotations !== this.lineAnnotations\n : false;\n\n if (\n !collapsed &&\n areRenderRangesEqual(nextRenderRange, this.renderRange) &&\n !forceRender &&\n !annotationsChanged &&\n // If using the fileDiff API, lets check to see if they are equal to\n // avoid doing work\n ((fileDiff != null && fileDiff === this.fileDiff) ||\n // If using the oldFile/newFile API then lets check to see if they are\n // equal\n (fileDiff == null && !filesDidChange))\n ) {\n return false;\n }\n\n const { renderRange: previousRenderRange } = this;\n this.renderRange = nextRenderRange;\n this.deletionFile = oldFile;\n this.additionFile = newFile;\n\n if (fileDiff != null) {\n this.fileDiff = fileDiff;\n } else if (oldFile != null && newFile != null && filesDidChange) {\n diffDidChange = true;\n this.fileDiff = parseDiffFromFile(oldFile, newFile);\n }\n\n if (lineAnnotations != null) {\n this.setLineAnnotations(lineAnnotations);\n }\n if (this.fileDiff == null) {\n return false;\n }\n this.hunksRenderer.setOptions({\n ...this.options,\n hunkSeparators:\n typeof this.options.hunkSeparators === 'function'\n ? 'custom'\n : this.options.hunkSeparators,\n });\n\n this.hunksRenderer.setLineAnnotations(this.lineAnnotations);\n\n const {\n diffStyle = 'split',\n disableErrorHandling = false,\n disableFileHeader = false,\n overflow = 'scroll',\n } = this.options;\n\n if (disableFileHeader) {\n // Remove existing header from DOM\n if (this.headerElement != null) {\n this.headerElement.remove();\n this.headerElement = undefined;\n this.lastRenderedHeaderHTML = undefined;\n }\n if (this.headerPrefix != null) {\n this.headerPrefix.remove();\n this.headerPrefix = undefined;\n }\n if (this.headerMetadata != null) {\n this.headerMetadata.remove();\n this.headerMetadata = undefined;\n }\n }\n fileContainer = this.getOrCreateFileContainer(\n fileContainer,\n containerWrapper\n );\n\n if (collapsed) {\n this.removeRenderedCode();\n this.clearAuxiliaryNodes();\n\n try {\n const hunksResult = this.hunksRenderer.renderDiff(\n this.fileDiff,\n EMPTY_RENDER_RANGE\n );\n if (hunksResult?.headerElement != null) {\n this.applyHeaderToDOM(hunksResult.headerElement, fileContainer);\n }\n this.renderSeparators([]);\n this.injectUnsafeCSS();\n } catch (error: unknown) {\n if (disableErrorHandling) {\n throw error;\n }\n console.error(error);\n if (error instanceof Error) {\n this.applyErrorToDOM(error, fileContainer);\n }\n }\n return true;\n }\n\n try {\n const pre = this.getOrCreatePreNode(fileContainer);\n\n // Attempt to partially render\n const didPartiallyRender =\n this.canPartiallyRender(\n forceRender,\n annotationsChanged,\n filesDidChange || diffDidChange\n ) &&\n this.applyPartialRender({\n previousRenderRange,\n renderRange: nextRenderRange,\n });\n\n // If we were unable to partially render, perform a full render\n if (!didPartiallyRender) {\n const hunksResult = this.hunksRenderer.renderDiff(\n this.fileDiff,\n nextRenderRange\n );\n if (hunksResult == null) {\n // FIXME(amadeus): I don't think we actually need this check, as\n // DiffHunksRenderer should probably take care of it for us?\n if (this.workerManager?.isInitialized() === false) {\n void this.workerManager.initialize().then(() => this.rerender());\n }\n return false;\n }\n\n if (hunksResult.headerElement != null) {\n this.applyHeaderToDOM(hunksResult.headerElement, fileContainer);\n }\n if (\n hunksResult.additionsContentAST != null ||\n hunksResult.deletionsContentAST != null ||\n hunksResult.unifiedContentAST != null\n ) {\n this.applyHunksToDOM(pre, hunksResult);\n } else if (this.pre != null) {\n this.pre.remove();\n this.pre = undefined;\n }\n this.renderSeparators(hunksResult.hunkData);\n }\n\n this.applyBuffers(pre, nextRenderRange);\n this.injectUnsafeCSS();\n this.renderAnnotations();\n this.renderGutterUtility();\n\n this.interactionManager.setup(pre);\n this.resizeManager.setup(pre, overflow === 'wrap');\n if (overflow === 'scroll' && diffStyle === 'split') {\n this.scrollSyncManager.setup(\n pre,\n this.codeDeletions,\n this.codeAdditions\n );\n } else {\n this.scrollSyncManager.cleanUp();\n }\n } catch (error: unknown) {\n if (disableErrorHandling) {\n throw error;\n }\n console.error(error);\n if (error instanceof Error) {\n this.applyErrorToDOM(error, fileContainer);\n }\n }\n return true;\n }\n\n private removeRenderedCode(): void {\n this.resizeManager.cleanUp();\n this.scrollSyncManager.cleanUp();\n this.interactionManager.cleanUp();\n\n this.bufferBefore?.remove();\n this.bufferBefore = undefined;\n this.bufferAfter?.remove();\n this.bufferAfter = undefined;\n\n this.codeUnified?.remove();\n this.codeUnified = undefined;\n this.codeDeletions?.remove();\n this.codeDeletions = undefined;\n this.codeAdditions?.remove();\n this.codeAdditions = undefined;\n\n this.pre?.remove();\n this.pre = undefined;\n\n this.appliedPreAttributes = undefined;\n this.lastRowCount = undefined;\n }\n\n private clearAuxiliaryNodes(): void {\n for (const { element } of this.separatorCache.values()) {\n element.remove();\n }\n this.separatorCache.clear();\n\n for (const { element } of this.annotationCache.values()) {\n element.remove();\n }\n this.annotationCache.clear();\n\n this.gutterUtilityContent?.remove();\n this.gutterUtilityContent = undefined;\n }\n\n public renderPlaceholder(height: number): boolean {\n if (this.fileContainer == null) {\n return false;\n }\n this.cleanChildNodes();\n\n if (this.placeHolder == null) {\n const shadowRoot =\n this.fileContainer.shadowRoot ??\n this.fileContainer.attachShadow({ mode: 'open' });\n this.placeHolder = document.createElement('div');\n this.placeHolder.dataset.placeholder = '';\n shadowRoot.appendChild(this.placeHolder);\n }\n this.placeHolder.style.setProperty('height', `${height}px`);\n return true;\n }\n\n private cleanChildNodes() {\n this.resizeManager.cleanUp();\n this.scrollSyncManager.cleanUp();\n this.interactionManager.cleanUp();\n\n this.bufferAfter?.remove();\n this.bufferBefore?.remove();\n this.codeAdditions?.remove();\n this.codeDeletions?.remove();\n this.codeUnified?.remove();\n this.errorWrapper?.remove();\n this.headerElement?.remove();\n this.gutterUtilityContent?.remove();\n this.headerPrefix?.remove();\n this.headerMetadata?.remove();\n this.pre?.remove();\n this.spriteSVG?.remove();\n this.unsafeCSSStyle?.remove();\n\n this.bufferAfter = undefined;\n this.bufferBefore = undefined;\n this.codeAdditions = undefined;\n this.codeDeletions = undefined;\n this.codeUnified = undefined;\n this.errorWrapper = undefined;\n this.headerElement = undefined;\n this.gutterUtilityContent = undefined;\n this.headerPrefix = undefined;\n this.headerMetadata = undefined;\n this.pre = undefined;\n this.spriteSVG = undefined;\n this.unsafeCSSStyle = undefined;\n\n this.lastRenderedHeaderHTML = undefined;\n this.lastRowCount = undefined;\n }\n\n private renderSeparators(hunkData: HunkData[]): void {\n const { hunkSeparators } = this.options;\n if (\n this.isContainerManaged ||\n this.fileContainer == null ||\n typeof hunkSeparators !== 'function'\n ) {\n for (const { element } of this.separatorCache.values()) {\n element.remove();\n }\n this.separatorCache.clear();\n return;\n }\n const staleSeparators = new Map(this.separatorCache);\n for (const hunk of hunkData) {\n const id = hunk.slotName;\n let cache = this.separatorCache.get(id);\n if (cache == null || !areHunkDataEqual(hunk, cache.hunkData)) {\n cache?.element.remove();\n const element = document.createElement('div');\n element.style.display = 'contents';\n element.slot = hunk.slotName;\n const child = hunkSeparators(hunk, this);\n if (child != null) {\n element.appendChild(child);\n }\n this.fileContainer.appendChild(element);\n cache = { element, hunkData: hunk };\n this.separatorCache.set(id, cache);\n }\n staleSeparators.delete(id);\n }\n for (const [id, { element }] of staleSeparators.entries()) {\n this.separatorCache.delete(id);\n element.remove();\n }\n }\n\n private renderAnnotations(): void {\n if (this.isContainerManaged || this.fileContainer == null) {\n for (const { element } of this.annotationCache.values()) {\n element.remove();\n }\n this.annotationCache.clear();\n return;\n }\n const staleAnnotations = new Map(this.annotationCache);\n const { renderAnnotation } = this.options;\n if (renderAnnotation != null && this.lineAnnotations.length > 0) {\n for (const [index, annotation] of this.lineAnnotations.entries()) {\n const id = `${index}-${getLineAnnotationName(annotation)}`;\n let cache = this.annotationCache.get(id);\n if (\n cache == null ||\n !areDiffLineAnnotationsEqual(annotation, cache.annotation)\n ) {\n cache?.element.remove();\n const content = renderAnnotation(annotation);\n // If we can't render anything, then we should not render anything\n // and clear the annotation cache if necessary.\n if (content == null) {\n continue;\n }\n cache = {\n element: createAnnotationWrapperNode(\n getLineAnnotationName(annotation)\n ),\n annotation,\n };\n cache.element.appendChild(content);\n this.fileContainer.appendChild(cache.element);\n this.annotationCache.set(id, cache);\n }\n staleAnnotations.delete(id);\n }\n }\n for (const [id, { element }] of staleAnnotations.entries()) {\n this.annotationCache.delete(id);\n element.remove();\n }\n }\n\n private renderGutterUtility() {\n const renderGutterUtility =\n this.options.renderGutterUtility ?? this.options.renderHoverUtility;\n if (this.fileContainer == null || renderGutterUtility == null) {\n this.gutterUtilityContent?.remove();\n this.gutterUtilityContent = undefined;\n return;\n }\n const element = renderGutterUtility(this.interactionManager.getHoveredLine);\n if (element != null && this.gutterUtilityContent != null) {\n return;\n } else if (element == null) {\n this.gutterUtilityContent?.remove();\n this.gutterUtilityContent = undefined;\n return;\n }\n const gutterUtilityContent = createGutterUtilityContentNode();\n gutterUtilityContent.appendChild(element);\n this.fileContainer.appendChild(gutterUtilityContent);\n this.gutterUtilityContent = gutterUtilityContent;\n }\n\n protected getOrCreateFileContainer(\n fileContainer?: HTMLElement,\n parentNode?: HTMLElement\n ): HTMLElement {\n const previousContainer = this.fileContainer;\n this.fileContainer =\n fileContainer ??\n this.fileContainer ??\n document.createElement(DIFFS_TAG_NAME);\n // NOTE(amadeus): If the container changes, we should reset the rendered\n // HTML\n if (previousContainer != null && previousContainer !== this.fileContainer) {\n this.lastRenderedHeaderHTML = undefined;\n this.headerElement = undefined;\n }\n if (parentNode != null && this.fileContainer.parentNode !== parentNode) {\n parentNode.appendChild(this.fileContainer);\n }\n if (this.spriteSVG == null) {\n const fragment = document.createElement('div');\n fragment.innerHTML = SVGSpriteSheet;\n const firstChild = fragment.firstChild;\n if (firstChild instanceof SVGElement) {\n this.spriteSVG = firstChild;\n this.fileContainer.shadowRoot?.appendChild(this.spriteSVG);\n }\n }\n return this.fileContainer;\n }\n\n protected getFileContainer(): HTMLElement | undefined {\n return this.fileContainer;\n }\n\n private getOrCreatePreNode(container: HTMLElement): HTMLPreElement {\n const shadowRoot =\n container.shadowRoot ?? container.attachShadow({ mode: 'open' });\n // If we haven't created a pre element yet, lets go ahead and do that\n if (this.pre == null) {\n this.pre = document.createElement('pre');\n this.appliedPreAttributes = undefined;\n this.codeUnified = undefined;\n this.codeDeletions = undefined;\n this.codeAdditions = undefined;\n shadowRoot.appendChild(this.pre);\n }\n // If we have a new parent container for the pre element, lets go ahead and\n // move it into the new container\n else if (this.pre.parentNode !== shadowRoot) {\n shadowRoot.appendChild(this.pre);\n this.appliedPreAttributes = undefined;\n }\n\n this.placeHolder?.remove();\n this.placeHolder = undefined;\n\n return this.pre;\n }\n\n private syncCodeNodesFromPre(pre: HTMLPreElement): void {\n this.codeUnified = undefined;\n this.codeDeletions = undefined;\n this.codeAdditions = undefined;\n for (const child of Array.from(pre.children)) {\n if (!(child instanceof HTMLElement)) {\n continue;\n }\n if ('unified' in child.dataset) {\n this.codeUnified = child;\n } else if ('deletions' in child.dataset) {\n this.codeDeletions = child;\n } else if ('additions' in child.dataset) {\n this.codeAdditions = child;\n }\n }\n }\n\n private applyHeaderToDOM(\n headerAST: HASTElement,\n container: HTMLElement\n ): void {\n this.cleanupErrorWrapper();\n this.placeHolder?.remove();\n this.placeHolder = undefined;\n const headerHTML = toHtml(headerAST);\n if (headerHTML !== this.lastRenderedHeaderHTML) {\n const tempDiv = document.createElement('div');\n tempDiv.innerHTML = headerHTML;\n const newHeader = tempDiv.firstElementChild;\n if (!(newHeader instanceof HTMLElement)) {\n return;\n }\n if (this.headerElement != null) {\n container.shadowRoot?.replaceChild(newHeader, this.headerElement);\n } else {\n container.shadowRoot?.prepend(newHeader);\n }\n this.headerElement = newHeader;\n this.lastRenderedHeaderHTML = headerHTML;\n }\n\n if (this.isContainerManaged) return;\n\n const { renderHeaderPrefix, renderHeaderMetadata } = this.options;\n if (this.headerPrefix != null) {\n this.headerPrefix.remove();\n }\n if (this.headerMetadata != null) {\n this.headerMetadata.remove();\n }\n const prefix =\n renderHeaderPrefix?.({\n deletionFile: this.deletionFile,\n additionFile: this.additionFile,\n fileDiff: this.fileDiff,\n }) ?? undefined;\n const content =\n renderHeaderMetadata?.({\n deletionFile: this.deletionFile,\n additionFile: this.additionFile,\n fileDiff: this.fileDiff,\n }) ?? undefined;\n if (prefix != null) {\n this.headerPrefix = document.createElement('div');\n this.headerPrefix.slot = HEADER_PREFIX_SLOT_ID;\n if (prefix instanceof Element) {\n this.headerPrefix.appendChild(prefix);\n } else {\n this.headerPrefix.innerText = `${prefix}`;\n }\n container.appendChild(this.headerPrefix);\n }\n if (content != null) {\n this.headerMetadata = document.createElement('div');\n this.headerMetadata.slot = HEADER_METADATA_SLOT_ID;\n if (content instanceof Element) {\n this.headerMetadata.appendChild(content);\n } else {\n this.headerMetadata.innerText = `${content}`;\n }\n container.appendChild(this.headerMetadata);\n }\n }\n\n private injectUnsafeCSS(): void {\n if (this.fileContainer?.shadowRoot == null) {\n return;\n }\n const { unsafeCSS } = this.options;\n\n if (unsafeCSS == null || unsafeCSS === '') {\n return;\n }\n\n // Create or update the style element\n if (this.unsafeCSSStyle == null) {\n this.unsafeCSSStyle = createUnsafeCSSStyleNode();\n this.fileContainer.shadowRoot.appendChild(this.unsafeCSSStyle);\n }\n // Wrap in @layer unsafe to match SSR behavior\n this.unsafeCSSStyle.innerText = wrapUnsafeCSS(unsafeCSS);\n }\n\n private applyHunksToDOM(\n pre: HTMLPreElement,\n result: HunksRenderResult\n ): void {\n const { overflow = 'scroll' } = this.options;\n const containerSize =\n (this.options.hunkSeparators ?? 'line-info') === 'line-info';\n const rowSpan = overflow === 'wrap' ? result.rowCount : undefined;\n this.cleanupErrorWrapper();\n this.applyPreNodeAttributes(pre, result);\n\n let shouldReplace = false;\n // Create code elements and insert HTML content\n const codeElements: HTMLElement[] = [];\n const unifiedAST = this.hunksRenderer.renderCodeAST('unified', result);\n const deletionsAST = this.hunksRenderer.renderCodeAST('deletions', result);\n const additionsAST = this.hunksRenderer.renderCodeAST('additions', result);\n if (unifiedAST != null) {\n shouldReplace =\n this.codeUnified == null ||\n this.codeAdditions != null ||\n this.codeDeletions != null;\n\n // Clean up addition/deletion elements if necessary\n this.codeDeletions?.remove();\n this.codeDeletions = undefined;\n this.codeAdditions?.remove();\n this.codeAdditions = undefined;\n\n this.codeUnified = getOrCreateCodeNode({\n code: this.codeUnified,\n columnType: 'unified',\n rowSpan,\n containerSize,\n });\n this.codeUnified.innerHTML =\n this.hunksRenderer.renderPartialHTML(unifiedAST);\n codeElements.push(this.codeUnified);\n } else if (deletionsAST != null || additionsAST != null) {\n if (deletionsAST != null) {\n shouldReplace = this.codeDeletions == null || this.codeUnified != null;\n\n // Clean up unified column if necessary\n this.codeUnified?.remove();\n this.codeUnified = undefined;\n\n this.codeDeletions = getOrCreateCodeNode({\n code: this.codeDeletions,\n columnType: 'deletions',\n rowSpan,\n containerSize,\n });\n this.codeDeletions.innerHTML =\n this.hunksRenderer.renderPartialHTML(deletionsAST);\n codeElements.push(this.codeDeletions);\n } else {\n // If we have no deletion column, lets clean it up if it exists\n this.codeDeletions?.remove();\n this.codeDeletions = undefined;\n }\n\n if (additionsAST != null) {\n shouldReplace =\n shouldReplace ||\n this.codeAdditions == null ||\n this.codeUnified != null;\n\n // Clean up unified column if necessary\n this.codeUnified?.remove();\n this.codeUnified = undefined;\n\n this.codeAdditions = getOrCreateCodeNode({\n code: this.codeAdditions,\n columnType: 'additions',\n rowSpan,\n containerSize,\n });\n this.codeAdditions.innerHTML =\n this.hunksRenderer.renderPartialHTML(additionsAST);\n codeElements.push(this.codeAdditions);\n } else {\n // If we have no addition column, lets clean it up if it exists\n this.codeAdditions?.remove();\n this.codeAdditions = undefined;\n }\n } else {\n // if we get in here, there's no content to render, so lets just clean\n // everything up\n this.codeUnified?.remove();\n this.codeUnified = undefined;\n this.codeDeletions?.remove();\n this.codeDeletions = undefined;\n this.codeAdditions?.remove();\n this.codeAdditions = undefined;\n }\n\n if (codeElements.length === 0) {\n pre.textContent = '';\n } else if (shouldReplace) {\n pre.replaceChildren(...codeElements);\n }\n\n this.lastRowCount = result.rowCount;\n }\n\n private applyPartialRender({\n previousRenderRange,\n renderRange,\n }: ApplyPartialRenderProps): boolean {\n const {\n pre,\n codeUnified,\n codeAdditions,\n codeDeletions,\n options: { diffStyle = 'split' },\n } = this;\n if (\n pre == null ||\n // We must have a current and previous render range to do a partial render\n previousRenderRange == null ||\n renderRange == null ||\n // Neither render range may be infinite\n !Number.isFinite(previousRenderRange.totalLines) ||\n !Number.isFinite(renderRange.totalLines) ||\n this.lastRowCount == null\n ) {\n return false;\n }\n const codeElements = this.getCodeColumns(\n diffStyle,\n codeUnified,\n codeDeletions,\n codeAdditions\n );\n if (codeElements == null) {\n return false;\n }\n\n const previousStart = previousRenderRange.startingLine;\n const nextStart = renderRange.startingLine;\n const previousEnd = previousStart + previousRenderRange.totalLines;\n const nextEnd = nextStart + renderRange.totalLines;\n\n const overlapStart = Math.max(previousStart, nextStart);\n const overlapEnd = Math.min(previousEnd, nextEnd);\n if (overlapEnd <= overlapStart) {\n return false;\n }\n\n const trimStart = Math.max(0, overlapStart - previousStart);\n const trimEnd = Math.max(0, previousEnd - overlapEnd);\n\n const trimResult = this.trimColumns({\n columns: codeElements,\n trimStart,\n trimEnd,\n previousStart,\n overlapStart,\n overlapEnd,\n diffStyle,\n });\n if (trimResult < 0) {\n throw new Error('applyPartialRender: failed to trim to overlap');\n }\n\n if (this.lastRowCount < trimResult) {\n throw new Error('applyPartialRender: trimmed beyond DOM row count');\n }\n\n let rowCount = this.lastRowCount - trimResult;\n const renderChunk = (\n startingLine: number,\n totalLines: number\n ): HunksRenderResult | undefined => {\n if (totalLines <= 0 || this.fileDiff == null) {\n return undefined;\n }\n return this.hunksRenderer.renderDiff(this.fileDiff, {\n startingLine,\n totalLines,\n bufferBefore: 0,\n bufferAfter: 0,\n });\n };\n\n const prependResult = renderChunk(\n nextStart,\n Math.max(overlapStart - nextStart, 0)\n );\n if (prependResult == null && nextStart < overlapStart) {\n return false;\n }\n\n const appendResult = renderChunk(\n overlapEnd,\n Math.max(nextEnd - overlapEnd, 0)\n );\n if (appendResult == null && nextEnd > overlapEnd) {\n return false;\n }\n\n const applyChunk = (\n result: HunksRenderResult | undefined,\n insertPosition: 'afterbegin' | 'beforeend'\n ) => {\n if (result == null) {\n return;\n }\n if (diffStyle === 'unified' && !Array.isArray(codeElements)) {\n this.insertPartialHTML(diffStyle, codeElements, result, insertPosition);\n } else if (diffStyle === 'split' && Array.isArray(codeElements)) {\n this.insertPartialHTML(diffStyle, codeElements, result, insertPosition);\n } else {\n throw new Error(\n 'FileDiff.applyPartialRender.applyChunk: invalid chunk application'\n );\n }\n rowCount += result.rowCount;\n };\n\n this.cleanupErrorWrapper();\n applyChunk(prependResult, 'afterbegin');\n applyChunk(appendResult, 'beforeend');\n\n if (this.lastRowCount !== rowCount) {\n this.applyRowSpan(diffStyle, codeElements, rowCount);\n this.lastRowCount = rowCount;\n }\n\n return true;\n }\n\n private insertPartialHTML(\n diffStyle: 'unified',\n columns: ColumnElements,\n result: HunksRenderResult,\n insertPosition: 'afterbegin' | 'beforeend'\n ): void;\n private insertPartialHTML(\n diffStyle: 'split',\n columns: [ColumnElements | undefined, ColumnElements | undefined],\n result: HunksRenderResult,\n insertPosition: 'afterbegin' | 'beforeend'\n ): void;\n private insertPartialHTML(\n diffStyle: 'split' | 'unified',\n columns:\n | [ColumnElements | undefined, ColumnElements | undefined]\n | ColumnElements,\n result: HunksRenderResult,\n insertPosition: 'afterbegin' | 'beforeend'\n ): void {\n if (diffStyle === 'unified' && !Array.isArray(columns)) {\n const unifiedAST = this.hunksRenderer.renderCodeAST('unified', result);\n this.renderPartialColumn(columns, unifiedAST, insertPosition);\n } else if (diffStyle === 'split' && Array.isArray(columns)) {\n const deletionsAST = this.hunksRenderer.renderCodeAST(\n 'deletions',\n result\n );\n const additionsAST = this.hunksRenderer.renderCodeAST(\n 'additions',\n result\n );\n this.renderPartialColumn(columns[0], deletionsAST, insertPosition);\n this.renderPartialColumn(columns[1], additionsAST, insertPosition);\n } else {\n throw new Error(\n 'FileDiff.insertPartialHTML: Invalid argument composition'\n );\n }\n }\n\n private renderPartialColumn(\n column: ColumnElements | undefined,\n ast: ElementContent[] | undefined,\n insertPosition: 'afterbegin' | 'beforeend'\n ) {\n if (column == null || ast == null) {\n return;\n }\n const gutterChildren = getElementChildren(ast[0]);\n const contentChildren = getElementChildren(ast[1]);\n if (gutterChildren == null || contentChildren == null) {\n throw new Error('FileDiff.insertPartialHTML: Unexpected AST structure');\n }\n const firstHASTElement = contentChildren.at(0);\n if (\n insertPosition === 'beforeend' &&\n firstHASTElement?.type === 'element' &&\n typeof firstHASTElement.properties['data-buffer-size'] === 'number'\n ) {\n this.mergeBuffersIfNecessary(\n firstHASTElement.properties['data-buffer-size'],\n column.content.children[column.content.children.length - 1],\n column.gutter.children[column.gutter.children.length - 1],\n gutterChildren,\n contentChildren,\n true\n );\n }\n const lastHASTElement = contentChildren.at(-1);\n if (\n insertPosition === 'afterbegin' &&\n lastHASTElement?.type === 'element' &&\n typeof lastHASTElement.properties['data-buffer-size'] === 'number'\n ) {\n this.mergeBuffersIfNecessary(\n lastHASTElement.properties['data-buffer-size'],\n column.content.children[0],\n column.gutter.children[0],\n gutterChildren,\n contentChildren,\n false\n );\n }\n\n column.gutter.insertAdjacentHTML(\n insertPosition,\n this.hunksRenderer.renderPartialHTML(gutterChildren)\n );\n column.content.insertAdjacentHTML(\n insertPosition,\n this.hunksRenderer.renderPartialHTML(contentChildren)\n );\n }\n\n private mergeBuffersIfNecessary(\n adjustmentSize: number,\n contentElement: Element,\n gutterElement: Element,\n gutterChildren: ElementContent[],\n contentChildren: ElementContent[],\n fromStart: boolean\n ) {\n if (\n !(contentElement instanceof HTMLElement) ||\n !(gutterElement instanceof HTMLElement)\n ) {\n return;\n }\n const currentSize = this.getBufferSize(contentElement.dataset);\n if (currentSize == null) {\n return;\n }\n if (fromStart) {\n gutterChildren.shift();\n contentChildren.shift();\n } else {\n gutterChildren.pop();\n contentChildren.pop();\n }\n this.updateBufferSize(contentElement, currentSize + adjustmentSize);\n this.updateBufferSize(gutterElement, currentSize + adjustmentSize);\n }\n\n private applyRowSpan(\n diffStyle: 'split' | 'unified',\n columns:\n | [ColumnElements | undefined, ColumnElements | undefined]\n | ColumnElements,\n rowCount: number\n ): void {\n const applySpan = (column: ColumnElements | undefined) => {\n if (column == null) {\n return;\n }\n column.gutter.style.setProperty('grid-row', `span ${rowCount}`);\n column.content.style.setProperty('grid-row', `span ${rowCount}`);\n };\n if (diffStyle === 'unified' && !Array.isArray(columns)) {\n applySpan(columns);\n } else if (diffStyle === 'split' && Array.isArray(columns)) {\n applySpan(columns[0]);\n applySpan(columns[1]);\n } else {\n throw new Error('dun fuuuuked up');\n }\n }\n\n private trimColumnRows(\n columns: ColumnElements | undefined,\n preTrimCount: number,\n postTrimStart: number\n ): number {\n let visibleLineIndex = 0;\n let rowCount = 0;\n let rowIndex = 0;\n let pendingMetadataTrim = false;\n const hasPostTrim = postTrimStart >= 0;\n\n if (columns == null) {\n return 0;\n }\n const contentChildren = Array.from(columns.content.children);\n const gutterChildren = Array.from(columns.gutter.children);\n if (contentChildren.length !== gutterChildren.length) {\n throw new Error('FileDiff.trimColumnRows: columns do not match');\n }\n\n while (rowIndex < contentChildren.length) {\n if (preTrimCount <= 0 && !hasPostTrim && !pendingMetadataTrim) {\n break;\n }\n const gutterElement = gutterChildren[rowIndex];\n const contentElement = contentChildren[rowIndex];\n rowIndex++;\n\n if (\n !(gutterElement instanceof HTMLElement) ||\n !(contentElement instanceof HTMLElement)\n ) {\n console.error({ gutterElement, contentElement });\n throw new Error('FileDiff.trimColumnRows: invalid row elements');\n }\n\n if (pendingMetadataTrim) {\n pendingMetadataTrim = false;\n if (\n (gutterElement.dataset.gutterBuffer === 'annotation' &&\n 'lineAnnotation' in contentElement.dataset) ||\n (gutterElement.dataset.gutterBuffer === 'metadata' &&\n 'noNewline' in contentElement.dataset)\n ) {\n gutterElement.remove();\n contentElement.remove();\n rowCount++;\n continue;\n }\n }\n\n // If we found a line element, lets trim it if necessary\n if (\n 'lineIndex' in gutterElement.dataset &&\n 'lineIndex' in contentElement.dataset\n ) {\n if (\n preTrimCount > 0 ||\n (hasPostTrim && visibleLineIndex >= postTrimStart)\n ) {\n gutterElement.remove();\n contentElement.remove();\n if (preTrimCount > 0) {\n preTrimCount--;\n if (preTrimCount === 0) {\n pendingMetadataTrim = true;\n }\n }\n rowCount++;\n }\n visibleLineIndex++;\n continue;\n }\n\n // Separators should be removed, but don't count towards line indices\n if (\n 'separator' in gutterElement.dataset &&\n 'separator' in contentElement.dataset\n ) {\n if (\n preTrimCount > 0 ||\n (hasPostTrim && visibleLineIndex >= postTrimStart)\n ) {\n gutterElement.remove();\n contentElement.remove();\n rowCount++;\n }\n continue;\n }\n\n // Annotations should be removed, but don't count towards line indices\n if (\n gutterElement.dataset.gutterBuffer === 'annotation' &&\n 'lineAnnotation' in contentElement.dataset\n ) {\n if (\n preTrimCount > 0 ||\n (hasPostTrim && visibleLineIndex >= postTrimStart)\n ) {\n gutterElement.remove();\n contentElement.remove();\n rowCount++;\n }\n continue;\n }\n\n if (\n gutterElement.dataset.gutterBuffer === 'metadata' &&\n 'noNewline' in contentElement.dataset\n ) {\n if (\n preTrimCount > 0 ||\n (hasPostTrim && visibleLineIndex >= postTrimStart)\n ) {\n gutterElement.remove();\n contentElement.remove();\n rowCount++;\n }\n continue;\n }\n\n if (\n gutterElement.dataset.gutterBuffer === 'buffer' &&\n 'contentBuffer' in contentElement.dataset\n ) {\n const totalRows = this.getBufferSize(contentElement.dataset);\n if (totalRows == null) {\n throw new Error('FileDiff.trimColumnRows: invalid element');\n }\n if (preTrimCount > 0) {\n const rowsToRemove = Math.min(preTrimCount, totalRows);\n const newSize = totalRows - rowsToRemove;\n if (newSize > 0) {\n this.updateBufferSize(gutterElement, newSize);\n this.updateBufferSize(contentElement, newSize);\n rowCount += rowsToRemove;\n } else {\n gutterElement.remove();\n contentElement.remove();\n rowCount += totalRows;\n }\n preTrimCount -= rowsToRemove;\n }\n // If we are in a post clip era...\n else if (hasPostTrim) {\n const bufferStart = visibleLineIndex;\n const bufferEnd = visibleLineIndex + totalRows - 1;\n if (postTrimStart <= bufferStart) {\n gutterElement.remove();\n contentElement.remove();\n rowCount += totalRows;\n } else if (postTrimStart <= bufferEnd) {\n const rowsToRemove = bufferEnd - postTrimStart + 1;\n const newSize = totalRows - rowsToRemove;\n this.updateBufferSize(gutterElement, newSize);\n this.updateBufferSize(contentElement, newSize);\n rowCount += rowsToRemove;\n }\n }\n visibleLineIndex += totalRows;\n continue;\n }\n\n console.error({ gutterElement, contentElement });\n throw new Error('FileDiff.trimColumnRows: unknown row elements');\n }\n\n return rowCount;\n }\n\n private trimColumns({\n columns,\n diffStyle,\n overlapEnd,\n overlapStart,\n previousStart,\n trimEnd,\n trimStart,\n // NOTE(amadeus): If we return -1 it means something went wrong\n // with the trim...\n // oxlint-disable-next-line no-redundant-type-constituents\n }: TrimColumnsToOverlapProps): number | -1 {\n const preTrimCount = Math.max(0, overlapStart - previousStart);\n const postTrimStart = overlapEnd - previousStart;\n if (postTrimStart < 0) {\n throw new Error('FileDiff.trimColumns: overlap ends before previous');\n }\n const shouldTrimStart = trimStart > 0;\n const shouldTrimEnd = trimEnd > 0;\n if (!shouldTrimStart && !shouldTrimEnd) {\n return 0;\n }\n const effectivePreTrimCount = shouldTrimStart ? preTrimCount : 0;\n const effectivePostTrimStart = shouldTrimEnd ? postTrimStart : -1;\n\n if (diffStyle === 'unified' && !Array.isArray(columns)) {\n const removedRows = this.trimColumnRows(\n columns,\n effectivePreTrimCount,\n effectivePostTrimStart\n );\n return removedRows;\n } else if (diffStyle === 'split' && Array.isArray(columns)) {\n const deletionsTrim = this.trimColumnRows(\n columns[0],\n effectivePreTrimCount,\n effectivePostTrimStart\n );\n const additionsTrim = this.trimColumnRows(\n columns[1],\n effectivePreTrimCount,\n effectivePostTrimStart\n );\n // We should avoid the trim validation if we are split but\n // there's only one side\n if (\n columns[0] != null &&\n columns[1] != null &&\n deletionsTrim !== additionsTrim\n ) {\n throw new Error('FileDiff.trimColumns: split columns out of sync');\n }\n return columns[0] != null ? deletionsTrim : additionsTrim;\n } else {\n console.error({ diffStyle, columns });\n throw new Error('FileDiff.trimColumns: Invalid columns for diffType');\n }\n }\n\n private getBufferSize(properties: DOMStringMap): number | undefined {\n const parsed = Number.parseInt(properties?.bufferSize ?? '', 10);\n return Number.isNaN(parsed) ? undefined : parsed;\n }\n\n private updateBufferSize(element: HTMLElement, size: number): void {\n element.dataset.bufferSize = `${size}`;\n element.style.setProperty('grid-row', `span ${size}`);\n element.style.setProperty('min-height', `calc(${size} * 1lh)`);\n }\n\n private getCodeColumns(\n diffStyle: 'split' | 'unified',\n codeUnified: HTMLElement | undefined,\n codeDeletions: HTMLElement | undefined,\n codeAdditions: HTMLElement | undefined\n ):\n | [ColumnElements | undefined, ColumnElements | undefined]\n | ColumnElements\n | undefined {\n function getColumns(\n code: HTMLElement | undefined\n ): ColumnElements | undefined {\n if (code == null) {\n return undefined;\n }\n const gutter = code.children[0];\n const content = code.children[1];\n if (\n !(gutter instanceof HTMLElement) ||\n !(content instanceof HTMLElement) ||\n gutter.dataset.gutter == null ||\n content.dataset.content == null\n ) {\n return undefined;\n }\n return { gutter, content };\n }\n\n if (diffStyle === 'unified') {\n return getColumns(codeUnified);\n } else {\n const deletions = getColumns(codeDeletions);\n const additions = getColumns(codeAdditions);\n return deletions != null || additions != null\n ? [deletions, additions]\n : undefined;\n }\n }\n\n private applyBuffers(\n pre: HTMLPreElement,\n renderRange: RenderRange | undefined\n ) {\n const { disableVirtualizationBuffers = false } = this.options;\n if (disableVirtualizationBuffers || renderRange == null) {\n if (this.bufferBefore != null) {\n this.bufferBefore.remove();\n this.bufferBefore = undefined;\n }\n if (this.bufferAfter != null) {\n this.bufferAfter.remove();\n this.bufferAfter = undefined;\n }\n return;\n }\n // NOTE(amadeus): A very hacky pass at buffers outside the pre elements...\n // i may need to improve this...\n if (renderRange.bufferBefore > 0) {\n if (this.bufferBefore == null) {\n this.bufferBefore = document.createElement('div');\n this.bufferBefore.dataset.virtualizerBuffer = 'before';\n pre.before(this.bufferBefore);\n }\n this.bufferBefore.style.setProperty(\n 'height',\n `${renderRange.bufferBefore}px`\n );\n this.bufferBefore.style.setProperty('contain', 'strict');\n } else if (this.bufferBefore != null) {\n this.bufferBefore.remove();\n this.bufferBefore = undefined;\n }\n\n if (renderRange.bufferAfter > 0) {\n if (this.bufferAfter == null) {\n this.bufferAfter = document.createElement('div');\n this.bufferAfter.dataset.virtualizerBuffer = 'after';\n pre.after(this.bufferAfter);\n }\n this.bufferAfter.style.setProperty(\n 'height',\n `${renderRange.bufferAfter}px`\n );\n this.bufferAfter.style.setProperty('contain', 'strict');\n } else if (this.bufferAfter != null) {\n this.bufferAfter.remove();\n this.bufferAfter = undefined;\n }\n }\n\n protected applyPreNodeAttributes(\n pre: HTMLPreElement,\n {\n themeStyles,\n baseThemeType,\n additionsContentAST,\n deletionsContentAST,\n totalLines,\n }: HunksRenderResult,\n customProperties?: CustomPreProperties\n ): void {\n const {\n diffIndicators = 'bars',\n disableBackground = false,\n disableLineNumbers = false,\n overflow = 'scroll',\n themeType = 'system',\n diffStyle = 'split',\n } = this.options;\n const preProperties: PrePropertiesConfig = {\n type: 'diff',\n diffIndicators,\n disableBackground,\n disableLineNumbers,\n overflow,\n split:\n diffStyle === 'unified'\n ? false\n : additionsContentAST != null && deletionsContentAST != null,\n themeStyles,\n themeType: baseThemeType ?? themeType,\n totalLines,\n customProperties,\n };\n if (arePrePropertiesEqual(preProperties, this.appliedPreAttributes)) {\n return;\n }\n setPreNodeProperties(pre, preProperties);\n this.appliedPreAttributes = preProperties;\n }\n\n private applyErrorToDOM(error: Error, container: HTMLElement) {\n this.cleanupErrorWrapper();\n const pre = this.getOrCreatePreNode(container);\n pre.innerHTML = '';\n pre.remove();\n this.pre = undefined;\n this.appliedPreAttributes = undefined;\n const shadowRoot =\n container.shadowRoot ?? container.attachShadow({ mode: 'open' });\n this.errorWrapper ??= document.createElement('div');\n this.errorWrapper.dataset.errorWrapper = '';\n this.errorWrapper.innerHTML = '';\n shadowRoot.appendChild(this.errorWrapper);\n const errorMessage = document.createElement('div');\n errorMessage.dataset.errorMessage = '';\n errorMessage.innerText = error.message;\n this.errorWrapper.appendChild(errorMessage);\n const errorStack = document.createElement('pre');\n errorStack.dataset.errorStack = '';\n errorStack.innerText = error.stack ?? 'No Error Stack';\n this.errorWrapper.appendChild(errorStack);\n }\n\n private cleanupErrorWrapper() {\n this.errorWrapper?.remove();\n this.errorWrapper = undefined;\n }\n}\n\nfunction getElementChildren(\n node: ElementContent | undefined\n): ElementContent[] | undefined {\n if (node == null || node.type !== 'element') {\n return undefined;\n }\n return node.children ?? [];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsJA,IAAI,aAAa;AAEjB,IAAa,WAAb,MAA+C;CAG7C,OAAO,wBAAiC;CAExC,AAAS,OAAe,aAAa,EAAE;CAEvC,AAAU;CACV,AAAU;CACV,AAAU;CACV,AAAU;CACV,AAAU;CACV,AAAU;CACV,AAAU;CACV,A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unksRendererOptions } from
|
|
|
7
7
|
import { FileDiff, FileDiffOptions, FileDiffRenderProps } from "./FileDiff.js";
|
|
8
8
|
|
|
9
9
|
//#region src/components/UnresolvedFile.d.ts
|
|
10
|
-
type RenderMergeConflictActions<LAnnotation> = (action: MergeConflictDiffAction, instance: UnresolvedFile<LAnnotation>) => HTMLElement | DocumentFragment | undefined;
|
|
10
|
+
type RenderMergeConflictActions<LAnnotation> = (action: MergeConflictDiffAction, instance: UnresolvedFile<LAnnotation>) => HTMLElement | DocumentFragment | null | undefined;
|
|
11
11
|
type MergeConflictActionsTypeOption<LAnnotation> = 'none' | 'default' | RenderMergeConflictActions<LAnnotation>;
|
|
12
12
|
interface UnresolvedFileOptions<LAnnotation> extends FileDiffOptions<LAnnotation> {
|
|
13
13
|
mergeConflictActionsType?: MergeConflictActionsTypeOption<LAnnotation>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnresolvedFile.d.ts","names":["HunksRenderResult","UnresolvedFileHunksRenderer","UnresolvedFileHunksRendererOptions","FileContents","FileDiffMetadata","MergeConflictActionPayload","MergeConflictResolution","MergeConflictDiffAction","WorkerPoolManager","FileDiff","FileDiffOptions","FileDiffRenderProps","RenderMergeConflictActions","LAnnotation","UnresolvedFile","HTMLElement","DocumentFragment","MergeConflictActionsTypeOption","UnresolvedFileOptions","UnresolvedFileRenderProps","Omit","UnresolvedFileHydrationProps","GetOrComputeDiffProps","UnresolvedFileDataCache","HTMLPreElement"],"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, 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 | undefined;\nexport type MergeConflictActionsTypeOption<LAnnotation> = 'none' | 'default' | RenderMergeConflictActions<LAnnotation>;\nexport interface UnresolvedFileOptions<LAnnotation> extends FileDiffOptions<LAnnotation> {\n mergeConflictActionsType?: MergeConflictActionsTypeOption<LAnnotation>;\n onMergeConflictAction?(payload: MergeConflictActionPayload, instance: UnresolvedFile<LAnnotation>): void;\n onMergeConflictResolve?(file: FileContents, payload: MergeConflictActionPayload): void;\n}\nexport interface UnresolvedFileRenderProps<LAnnotation> extends Omit<FileDiffRenderProps<LAnnotation>, 'oldFile' | 'newFile'> {\n file?: FileContents;\n actions?: MergeConflictDiffAction[];\n}\nexport interface UnresolvedFileHydrationProps<LAnnotation> extends Omit<UnresolvedFileRenderProps<LAnnotation>, 'file'> {\n file?: FileContents;\n fileDiff?: FileDiffMetadata;\n actions?: MergeConflictDiffAction[];\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\ninterface GetOrComputeDiffProps {\n file: FileContents | undefined;\n fileDiff: FileDiffMetadata | undefined;\n actions: MergeConflictDiffAction[] | undefined;\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 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, file?: FileContents | undefined): FileContents | undefined;\n private resolveConflictAndRender;\n private setActiveMergeConflictActions;\n private handleMergeConflictActionClick;\n private renderMergeConflictActionSlots;\n private renderMergeConflictAction;\n private clearMergeConflictActionCache;\n}\nexport {};\n//# sourceMappingURL=UnresolvedFile.d.ts.map"],"mappings":";;;;;;;;;KAMYY,mDAAmDL,mCAAmCO,eAAeD,iBAAiBE,cAAcC;KACpIC,mEAAmEL,2BAA2BC;UACzFK,2CAA2CR,gBAAgBG;EAFhED,wBAAAA,CAAAA,EAGmBK,8BAHO,CAGwBJ,WAHxB,CAAA;EAAyBN,qBAAAA,EAAAA,OAAAA,EAI3BF,0BAJ2BE,EAAAA,QAAAA,EAIWO,cAJXP,CAI0BM,WAJ1BN,CAAAA,CAAAA,EAAAA,IAAAA;EAAkDM,sBAAAA,EAAAA,IAAAA,EAK/EV,YAL+EU,EAAAA,OAAAA,EAKxDR,0BALwDQ,CAAAA,EAAAA,IAAAA;;AAAiBE,UAOjHI,yBAPiHJ,CAAAA,WAAAA,CAAAA,SAOlEK,IAPkEL,CAO7DJ,mBAP6DI,CAOzCF,WAPyCE,CAAAA,EAAAA,SAAAA,GAAAA,SAAAA,CAAAA,CAAAA;EAAcC,IAAAA,CAAAA,EAQrIb,YARqIa;EAAgB,OAAA,CAAA,EASlJT,uBATkJ,EAAA;AAChK;AACiBW,UASAG,4BATqBR,CAAAA,WAAA,CAAA,SAS6BO,IAT7B,CASkCD,yBATlC,CAS4DN,WAT5D,CAAA,EAAA,MAAA,CAAA,CAAA;EAAsCA,IAAAA,CAAAA,EAUjEV,YAViEU;EACdA,QAAAA,CAAAA,EAU/CT,gBAV+CS;EAA/BI,OAAAA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EAAAA,IAAAA;EACKQ,OAAAA,CAAAA,CAAAA,EAAAA,IAAAA;EAJgDK,QAAAA,gBAAAA;EAAI,OAAA,CAAA,KAAA,EA0BpDC,4BA1BoD,CA0BvBR,WA1BuB,CAAA,CAAA,EAAA,IAAA;EAO7DS,QAAAA,CAAAA,CAAAA,EAAAA,IAAAA;EACAnB,MAAAA,CAAAA,KAAAA,CAAAA,EAoBSgB,yBApBThB,CAoBmCU,WApBnCV,CAAAA,CAAAA,EAAAA,OAAAA;EACIC,eAAAA,CAAAA,aAAAA,EAAAA,MAAAA,EAAAA,UAAAA,EAoByCE,uBApBzCF,EAAAA,IAAAA,CAAAA,EAoByED,YApBzEC,GAAAA,SAAAA,CAAAA,EAoBoGD,YApBpGC,GAAAA,SAAAA;EACDG,QAAAA,wBAAAA;EAAuB,QAAA,6BAAA;EAE/BgB,QAAAA,8BAAuB;EACPT,QAAAA,8BAAcD;EAA2CA,QAAAA,yBAAAA;EAC3CA,QAAAA,6BAAAA"}
|
|
1
|
+
{"version":3,"file":"UnresolvedFile.d.ts","names":["HunksRenderResult","UnresolvedFileHunksRenderer","UnresolvedFileHunksRendererOptions","FileContents","FileDiffMetadata","MergeConflictActionPayload","MergeConflictResolution","MergeConflictDiffAction","WorkerPoolManager","FileDiff","FileDiffOptions","FileDiffRenderProps","RenderMergeConflictActions","LAnnotation","UnresolvedFile","HTMLElement","DocumentFragment","MergeConflictActionsTypeOption","UnresolvedFileOptions","UnresolvedFileRenderProps","Omit","UnresolvedFileHydrationProps","GetOrComputeDiffProps","UnresolvedFileDataCache","HTMLPreElement"],"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, 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 FileDiffOptions<LAnnotation> {\n mergeConflictActionsType?: MergeConflictActionsTypeOption<LAnnotation>;\n onMergeConflictAction?(payload: MergeConflictActionPayload, instance: UnresolvedFile<LAnnotation>): void;\n onMergeConflictResolve?(file: FileContents, payload: MergeConflictActionPayload): void;\n}\nexport interface UnresolvedFileRenderProps<LAnnotation> extends Omit<FileDiffRenderProps<LAnnotation>, 'oldFile' | 'newFile'> {\n file?: FileContents;\n actions?: MergeConflictDiffAction[];\n}\nexport interface UnresolvedFileHydrationProps<LAnnotation> extends Omit<UnresolvedFileRenderProps<LAnnotation>, 'file'> {\n file?: FileContents;\n fileDiff?: FileDiffMetadata;\n actions?: MergeConflictDiffAction[];\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\ninterface GetOrComputeDiffProps {\n file: FileContents | undefined;\n fileDiff: FileDiffMetadata | undefined;\n actions: MergeConflictDiffAction[] | undefined;\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 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, file?: FileContents | undefined): FileContents | undefined;\n private resolveConflictAndRender;\n private setActiveMergeConflictActions;\n private handleMergeConflictActionClick;\n private renderMergeConflictActionSlots;\n private renderMergeConflictAction;\n private clearMergeConflictActionCache;\n}\nexport {};\n//# sourceMappingURL=UnresolvedFile.d.ts.map"],"mappings":";;;;;;;;;KAMYY,mDAAmDL,mCAAmCO,eAAeD,iBAAiBE,cAAcC;KACpIC,mEAAmEL,2BAA2BC;UACzFK,2CAA2CR,gBAAgBG;EAFhED,wBAAAA,CAAAA,EAGmBK,8BAHO,CAGwBJ,WAHxB,CAAA;EAAyBN,qBAAAA,EAAAA,OAAAA,EAI3BF,0BAJ2BE,EAAAA,QAAAA,EAIWO,cAJXP,CAI0BM,WAJ1BN,CAAAA,CAAAA,EAAAA,IAAAA;EAAkDM,sBAAAA,EAAAA,IAAAA,EAK/EV,YAL+EU,EAAAA,OAAAA,EAKxDR,0BALwDQ,CAAAA,EAAAA,IAAAA;;AAAiBE,UAOjHI,yBAPiHJ,CAAAA,WAAAA,CAAAA,SAOlEK,IAPkEL,CAO7DJ,mBAP6DI,CAOzCF,WAPyCE,CAAAA,EAAAA,SAAAA,GAAAA,SAAAA,CAAAA,CAAAA;EAAcC,IAAAA,CAAAA,EAQrIb,YARqIa;EAAgB,OAAA,CAAA,EASlJT,uBATkJ,EAAA;AAChK;AACiBW,UASAG,4BATqBR,CAAAA,WAAA,CAAA,SAS6BO,IAT7B,CASkCD,yBATlC,CAS4DN,WAT5D,CAAA,EAAA,MAAA,CAAA,CAAA;EAAsCA,IAAAA,CAAAA,E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AAAA,EAoB4BiB,cApB5BjB,EAAAA,MAAAA,EAoBoDP,iBApBpDO,CAAAA,EAAAA,IAAAA;EACKQ,OAAAA,CAAAA,CAAAA,EAAAA,IAAAA;EAJgDK,QAAAA,gBAAAA;EAAI,OAAA,CAAA,KAAA,EA0BpDC,4BA1BoD,CA0BvBR,WA1BuB,CAAA,CAAA,EAAA,IAAA;EAO7DS,QAAAA,CAAAA,CAAAA,EAAAA,IAAAA;EACAnB,MAAAA,CAAAA,KAAAA,CAAAA,EAoBSgB,yBApBThB,CAoBmCU,WApBnCV,CAAAA,CAAAA,EAAAA,OAAAA;EACIC,eAAAA,CAAAA,aAAAA,EAAAA,MAAAA,EAAAA,UAAAA,EAoByCE,uBApBzCF,EAAAA,IAAAA,CAAAA,EAoByED,YApBzEC,GAAAA,SAAAA,CAAAA,EAoBoGD,YApBpGC,GAAAA,SAAAA;EACDG,QAAAA,wBAAAA;EAAuB,QAAA,6BAAA;EAE/BgB,QAAAA,8BAAuB;EACPT,QAAAA,8BAAcD;EAA2CA,QAAAA,yBAAAA;EAC3CA,QAAAA,6BAAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnresolvedFile.js","names":["options: UnresolvedFileOptions<LAnnotation>","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 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 getMergeConflictActionAnchor,\n type MergeConflictDiffAction,\n parseMergeConflictDiffFromFile,\n} from '../utils/parseMergeConflictDiffFromFile';\nimport { resolveMergeConflict } from '../utils/resolveMergeConflict';\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 | undefined;\n\nexport type MergeConflictActionsTypeOption<LAnnotation> =\n | 'none'\n | 'default'\n | RenderMergeConflictActions<LAnnotation>;\n\nexport interface UnresolvedFileOptions<\n LAnnotation,\n> extends FileDiffOptions<LAnnotation> {\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}\n\nexport interface UnresolvedFileRenderProps<LAnnotation> extends Omit<\n FileDiffRenderProps<LAnnotation>,\n 'oldFile' | 'newFile'\n> {\n file?: FileContents;\n actions?: MergeConflictDiffAction[];\n}\n\nexport interface UnresolvedFileHydrationProps<LAnnotation> extends Omit<\n UnresolvedFileRenderProps<LAnnotation>,\n 'file'\n> {\n file?: FileContents;\n fileDiff?: FileDiffMetadata;\n actions?: MergeConflictDiffAction[];\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;\n}\n\ninterface GetOrComputeDiffResult {\n fileDiff: FileDiffMetadata;\n actions: MergeConflictDiffAction[];\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 };\n private conflictActions: MergeConflictDiffAction[] = [];\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 {\n ...this.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\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 };\n this.conflictActions = [];\n super.cleanUp();\n }\n\n private getOrComputeDiff({\n file,\n fileDiff,\n actions,\n }: GetOrComputeDiffProps): GetOrComputeDiffResult | undefined {\n wrapper: {\n // We are dealing with a controlled component\n if (this.options.onMergeConflictAction != null) {\n const hasFileDiff = fileDiff != null;\n const hasActions = actions != null;\n if (hasFileDiff !== hasActions) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: fileDiff and actions must be passed together'\n );\n }\n // If we were provided a new fileDiff and actions, we are a FULLY\n // controlled component, which means we will not do any computation\n if (fileDiff != null && actions != null) {\n this.computedCache = {\n file: file ?? this.computedCache.file,\n fileDiff,\n actions,\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\n else if (file != null || this.computedCache.file != null) {\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(file);\n this.computedCache = {\n file,\n fileDiff: computed.fileDiff,\n actions: computed.actions,\n };\n }\n fileDiff = this.computedCache.fileDiff;\n actions = this.computedCache.actions;\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 break wrapper;\n }\n }\n // If we are uncontrolled we only rely on the file and only use the first\n // version, otherwise utilize the cached version\n else {\n if (fileDiff != null || actions != null) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: fileDiff and actions are only usable in controlled mode, you must pass in `onMergeConflictAction`'\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 );\n this.computedCache.fileDiff = computed.fileDiff;\n this.computedCache.actions = computed.actions;\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 break wrapper;\n }\n }\n if (fileDiff == null || actions == null) {\n return undefined;\n }\n return { fileDiff, actions };\n }\n\n override hydrate(props: UnresolvedFileHydrationProps<LAnnotation>): void {\n const { file, fileDiff, actions, lineAnnotations, ...rest } = props;\n const source = this.getOrComputeDiff({ file, fileDiff, actions });\n if (source == null) {\n return;\n }\n this.setActiveMergeConflictActions(source.actions);\n super.hydrate({\n ...rest,\n fileDiff: source.fileDiff,\n lineAnnotations,\n });\n this.renderMergeConflictActionSlots();\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 { file, fileDiff, actions, lineAnnotations, ...rest } = props;\n const source = this.getOrComputeDiff({ file, fileDiff, actions });\n if (source == null) {\n return false;\n }\n this.setActiveMergeConflictActions(source.actions);\n const didRender = super.render({\n ...rest,\n fileDiff: source.fileDiff,\n lineAnnotations,\n });\n this.renderMergeConflictActionSlots();\n return didRender;\n }\n\n public resolveConflict(\n conflictIndex: number,\n resolution: MergeConflictResolution,\n file: FileContents | undefined = this.computedCache.file\n ): FileContents | undefined {\n const action = this.conflictActions[conflictIndex];\n if (file == 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 contents = resolveMergeConflict(file.contents, {\n resolution,\n conflict: action.conflict,\n });\n if (contents === file.contents) {\n return undefined;\n }\n\n return {\n ...file,\n contents,\n cacheKey:\n file.cacheKey != null\n ? `${file.cacheKey}:mc-${conflictIndex}-${resolution}`\n : undefined,\n };\n }\n\n private resolveConflictAndRender(\n conflictIndex: number,\n resolution: MergeConflictResolution\n ): FileContents | undefined {\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 nextFile = this.resolveConflict(conflictIndex, resolution);\n if (nextFile == null) {\n return undefined;\n }\n\n this.computedCache.file = nextFile;\n // Clear out the diff cache to force a new compute next render\n this.computedCache.fileDiff = undefined;\n this.computedCache.actions = undefined;\n this.render();\n this.options.onMergeConflictResolve?.(nextFile, payload);\n return nextFile;\n }\n\n private setActiveMergeConflictActions(\n actions: MergeConflictDiffAction[]\n ): void {\n this.conflictActions = actions;\n if (this.hunksRenderer instanceof UnresolvedFileHunksRenderer) {\n this.hunksRenderer.setConflictActions(\n this.options.mergeConflictActionsType === 'none' ? [] : actions\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 if (\n this.isContainerManaged ||\n this.fileContainer == null ||\n typeof this.options.mergeConflictActionsType !== 'function' ||\n this.conflictActions.length === 0\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);\n if (anchor == null) {\n continue;\n }\n const conflictIndex = action.conflictIndex;\n const slotName = getMergeConflictActionSlotName({\n side: anchor.side,\n lineNumber: anchor.lineNumber,\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"],"mappings":";;;;;;;;;;;;AA4FA,IAAI,aAAa;AAEjB,IAAa,iBAAb,cAEU,SAAsB;CAC9B,AAAkB,OAAe,mBAAmB,EAAE;CACtD,AAAU,gBAAyC;EACjD,MAAM;EACN,UAAU;EACV,SAAS;EACV;CACD,AAAQ,kBAA6C,EAAE;CACvD,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;GACL,GAAG,KAAK;GACR,gBACE,OAAO,QAAQ,mBAAmB,aAC9B,WACA,QAAQ;GACd,0BACE,OAAO,QAAQ,6BAA6B,aACxC,WACA,QAAQ;GACf;;CAGH,AAAmB,uBACjB,KACA,QACM;AACN,QAAM,uBAAuB,KAAK,QAAQ,EACxC,2BAA2B,IAC5B,CAAC;;CAGJ,AAAS,UAAgB;AACvB,OAAK,+BAA+B;AACpC,OAAK,gBA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AoB,QAAQ,CACzD,SAAQ,QAAQ;AAElB,OAAK,oBAAoB,OAAO"}
|
|
1
|
+
{"version":3,"file":"UnresolvedFile.js","names":["options: UnresolvedFileOptions<LAnnotation>","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 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 getMergeConflictActionAnchor,\n type MergeConflictDiffAction,\n parseMergeConflictDiffFromFile,\n} from '../utils/parseMergeConflictDiffFromFile';\nimport { resolveMergeConflict } from '../utils/resolveMergeConflict';\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<\n LAnnotation,\n> extends FileDiffOptions<LAnnotation> {\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}\n\nexport interface UnresolvedFileRenderProps<LAnnotation> extends Omit<\n FileDiffRenderProps<LAnnotation>,\n 'oldFile' | 'newFile'\n> {\n file?: FileContents;\n actions?: MergeConflictDiffAction[];\n}\n\nexport interface UnresolvedFileHydrationProps<LAnnotation> extends Omit<\n UnresolvedFileRenderProps<LAnnotation>,\n 'file'\n> {\n file?: FileContents;\n fileDiff?: FileDiffMetadata;\n actions?: MergeConflictDiffAction[];\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;\n}\n\ninterface GetOrComputeDiffResult {\n fileDiff: FileDiffMetadata;\n actions: MergeConflictDiffAction[];\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 };\n private conflictActions: MergeConflictDiffAction[] = [];\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 {\n ...this.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\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 };\n this.conflictActions = [];\n super.cleanUp();\n }\n\n private getOrComputeDiff({\n file,\n fileDiff,\n actions,\n }: GetOrComputeDiffProps): GetOrComputeDiffResult | undefined {\n wrapper: {\n // We are dealing with a controlled component\n if (this.options.onMergeConflictAction != null) {\n const hasFileDiff = fileDiff != null;\n const hasActions = actions != null;\n if (hasFileDiff !== hasActions) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: fileDiff and actions must be passed together'\n );\n }\n // If we were provided a new fileDiff and actions, we are a FULLY\n // controlled component, which means we will not do any computation\n if (fileDiff != null && actions != null) {\n this.computedCache = {\n file: file ?? this.computedCache.file,\n fileDiff,\n actions,\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\n else if (file != null || this.computedCache.file != null) {\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(file);\n this.computedCache = {\n file,\n fileDiff: computed.fileDiff,\n actions: computed.actions,\n };\n }\n fileDiff = this.computedCache.fileDiff;\n actions = this.computedCache.actions;\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 break wrapper;\n }\n }\n // If we are uncontrolled we only rely on the file and only use the first\n // version, otherwise utilize the cached version\n else {\n if (fileDiff != null || actions != null) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: fileDiff and actions are only usable in controlled mode, you must pass in `onMergeConflictAction`'\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 );\n this.computedCache.fileDiff = computed.fileDiff;\n this.computedCache.actions = computed.actions;\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 break wrapper;\n }\n }\n if (fileDiff == null || actions == null) {\n return undefined;\n }\n return { fileDiff, actions };\n }\n\n override hydrate(props: UnresolvedFileHydrationProps<LAnnotation>): void {\n const { file, fileDiff, actions, lineAnnotations, ...rest } = props;\n const source = this.getOrComputeDiff({ file, fileDiff, actions });\n if (source == null) {\n return;\n }\n this.setActiveMergeConflictActions(source.actions);\n super.hydrate({\n ...rest,\n fileDiff: source.fileDiff,\n lineAnnotations,\n });\n this.renderMergeConflictActionSlots();\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 { file, fileDiff, actions, lineAnnotations, ...rest } = props;\n const source = this.getOrComputeDiff({ file, fileDiff, actions });\n if (source == null) {\n return false;\n }\n this.setActiveMergeConflictActions(source.actions);\n const didRender = super.render({\n ...rest,\n fileDiff: source.fileDiff,\n lineAnnotations,\n });\n this.renderMergeConflictActionSlots();\n return didRender;\n }\n\n public resolveConflict(\n conflictIndex: number,\n resolution: MergeConflictResolution,\n file: FileContents | undefined = this.computedCache.file\n ): FileContents | undefined {\n const action = this.conflictActions[conflictIndex];\n if (file == 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 contents = resolveMergeConflict(file.contents, {\n resolution,\n conflict: action.conflict,\n });\n if (contents === file.contents) {\n return undefined;\n }\n\n return {\n ...file,\n contents,\n cacheKey:\n file.cacheKey != null\n ? `${file.cacheKey}:mc-${conflictIndex}-${resolution}`\n : undefined,\n };\n }\n\n private resolveConflictAndRender(\n conflictIndex: number,\n resolution: MergeConflictResolution\n ): FileContents | undefined {\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 nextFile = this.resolveConflict(conflictIndex, resolution);\n if (nextFile == null) {\n return undefined;\n }\n\n this.computedCache.file = nextFile;\n // Clear out the diff cache to force a new compute next render\n this.computedCache.fileDiff = undefined;\n this.computedCache.actions = undefined;\n this.render();\n this.options.onMergeConflictResolve?.(nextFile, payload);\n return nextFile;\n }\n\n private setActiveMergeConflictActions(\n actions: MergeConflictDiffAction[]\n ): void {\n this.conflictActions = actions;\n if (this.hunksRenderer instanceof UnresolvedFileHunksRenderer) {\n this.hunksRenderer.setConflictActions(\n this.options.mergeConflictActionsType === 'none' ? [] : actions\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 if (\n this.isContainerManaged ||\n this.fileContainer == null ||\n typeof this.options.mergeConflictActionsType !== 'function' ||\n this.conflictActions.length === 0\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);\n if (anchor == null) {\n continue;\n }\n const conflictIndex = action.conflictIndex;\n const slotName = getMergeConflictActionSlotName({\n side: anchor.side,\n lineNumber: anchor.lineNumber,\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"],"mappings":";;;;;;;;;;;;AA4FA,IAAI,aAAa;AAEjB,IAAa,iBAAb,cAEU,SAAsB;CAC9B,AAAkB,OAAe,mBAAmB,EAAE;CACtD,AAAU,gBAAyC;EACjD,MAAM;EACN,UAAU;EACV,SAAS;EACV;CACD,AAAQ,kBAA6C,EAAE;CACvD,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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AS;KAAQ;AAC3B,SAAK,oBAAoB,IAAI,IAAI,MAAM;;AAEzC,gBAAa,OAAO,GAAG;;AAEzB,OAAK,MAAM,CAAC,IAAI,EAAE,cAAc,aAAa,SAAS,EAAE;AACtD,QAAK,oBAAoB,OAAO,GAAG;AACnC,WAAQ,QAAQ;;;CAIpB,AAAQ,0BACN,QACyB;AACzB,MAAI,OAAO,KAAK,QAAQ,6BAA6B,WACnD;EAEF,MAAM,WAAW,KAAK,QAAQ,yBAAyB,QAAQ,KAAK;AACpE,MAAI,YAAY,KACd;AAEF,MAAI,oBAAoB,YACtB,QAAO;AAET,MACE,OAAO,qBAAqB,eAC5B,oBAAoB,kBACpB;GACA,MAAM,UAAU,SAAS,cAAc,MAAM;AAC7C,WAAQ,MAAM,UAAU;AACxB,WAAQ,YAAY,SAAS;AAC7B,UAAO;;;CAKX,AAAQ,gCAAsC;AAC5C,OAAK,MAAM,EAAE,aAAa,KAAK,oBAAoB,QAAQ,CACzD,SAAQ,QAAQ;AAElB,OAAK,oBAAoB,OAAO"}
|
|
@@ -120,8 +120,8 @@ declare class InteractionManager<TMode extends InteractionManagerMode> {
|
|
|
120
120
|
}
|
|
121
121
|
type InteractionPluckOptions<TMode extends InteractionManagerMode> = InteractionManagerBaseOptions<TMode> & {
|
|
122
122
|
enableHoverUtility?: boolean;
|
|
123
|
-
renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<TMode> | undefined): HTMLElement | null;
|
|
124
|
-
renderHoverUtility?(getHoveredRow: () => GetHoveredLineResult<TMode> | undefined): HTMLElement | null;
|
|
123
|
+
renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<TMode> | undefined): HTMLElement | null | undefined;
|
|
124
|
+
renderHoverUtility?(getHoveredRow: () => GetHoveredLineResult<TMode> | undefined): HTMLElement | null | undefined;
|
|
125
125
|
};
|
|
126
126
|
declare function pluckInteractionOptions<TMode extends InteractionManagerMode>({
|
|
127
127
|
enableGutterUtility,
|