@pierre/diffs 1.3.0 → 1.3.2

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.
Files changed (76) hide show
  1. package/dist/components/CodeView.d.ts +4 -1
  2. package/dist/components/CodeView.d.ts.map +1 -1
  3. package/dist/components/CodeView.js +60 -26
  4. package/dist/components/CodeView.js.map +1 -1
  5. package/dist/components/File.d.ts +1 -0
  6. package/dist/components/File.d.ts.map +1 -1
  7. package/dist/components/File.js +18 -9
  8. package/dist/components/File.js.map +1 -1
  9. package/dist/components/FileDiff.d.ts +4 -0
  10. package/dist/components/FileDiff.d.ts.map +1 -1
  11. package/dist/components/FileDiff.js +48 -21
  12. package/dist/components/FileDiff.js.map +1 -1
  13. package/dist/components/VirtualizedFile.d.ts +1 -0
  14. package/dist/components/VirtualizedFile.d.ts.map +1 -1
  15. package/dist/components/VirtualizedFile.js +3 -0
  16. package/dist/components/VirtualizedFile.js.map +1 -1
  17. package/dist/components/VirtualizedFileDiff.d.ts +1 -0
  18. package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
  19. package/dist/components/VirtualizedFileDiff.js +3 -0
  20. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  21. package/dist/edit/index.d.ts +4 -3
  22. package/dist/editor/command.d.ts +10 -2
  23. package/dist/editor/command.d.ts.map +1 -1
  24. package/dist/editor/command.js +113 -39
  25. package/dist/editor/command.js.map +1 -1
  26. package/dist/editor/editStack.d.ts +2 -2
  27. package/dist/editor/editStack.d.ts.map +1 -1
  28. package/dist/editor/editStack.js.map +1 -1
  29. package/dist/editor/editor.d.ts +5 -2
  30. package/dist/editor/editor.d.ts.map +1 -1
  31. package/dist/editor/editor.js +49 -29
  32. package/dist/editor/editor.js.map +1 -1
  33. package/dist/editor/pieceTable.d.ts +1 -2
  34. package/dist/editor/pieceTable.d.ts.map +1 -1
  35. package/dist/editor/pieceTable.js.map +1 -1
  36. package/dist/editor/platform.d.ts +3 -11
  37. package/dist/editor/platform.d.ts.map +1 -1
  38. package/dist/editor/platform.js +2 -28
  39. package/dist/editor/platform.js.map +1 -1
  40. package/dist/editor/searchPanel.d.ts +2 -1
  41. package/dist/editor/searchPanel.d.ts.map +1 -1
  42. package/dist/editor/searchPanel.js.map +1 -1
  43. package/dist/editor/selection.d.ts +2 -2
  44. package/dist/editor/selection.d.ts.map +1 -1
  45. package/dist/editor/selection.js.map +1 -1
  46. package/dist/editor/selectionAction.d.ts +2 -1
  47. package/dist/editor/selectionAction.d.ts.map +1 -1
  48. package/dist/editor/selectionAction.js +3 -1
  49. package/dist/editor/selectionAction.js.map +1 -1
  50. package/dist/editor/textDocument.d.ts +4 -14
  51. package/dist/editor/textDocument.d.ts.map +1 -1
  52. package/dist/editor/textDocument.js +7 -0
  53. package/dist/editor/textDocument.js.map +1 -1
  54. package/dist/index.d.ts +2 -2
  55. package/dist/react/CodeView.d.ts +1 -0
  56. package/dist/react/CodeView.d.ts.map +1 -1
  57. package/dist/react/CodeView.js +9 -0
  58. package/dist/react/CodeView.js.map +1 -1
  59. package/dist/react/index.d.ts +2 -2
  60. package/dist/ssr/index.d.ts +2 -2
  61. package/dist/types.d.ts +22 -2
  62. package/dist/types.d.ts.map +1 -1
  63. package/dist/utils/areManagedSnapshotsEqual.js +1 -1
  64. package/dist/utils/areManagedSnapshotsEqual.js.map +1 -1
  65. package/dist/utils/guardWebKitScrollDuringRebuild.d.ts +20 -0
  66. package/dist/utils/guardWebKitScrollDuringRebuild.d.ts.map +1 -0
  67. package/dist/utils/guardWebKitScrollDuringRebuild.js +34 -0
  68. package/dist/utils/guardWebKitScrollDuringRebuild.js.map +1 -0
  69. package/dist/utils/platform.d.ts +14 -0
  70. package/dist/utils/platform.d.ts.map +1 -0
  71. package/dist/utils/platform.js +32 -0
  72. package/dist/utils/platform.js.map +1 -0
  73. package/dist/worker/wasm-B9ZqxnKj.js.map +1 -1
  74. package/dist/worker/worker-portable.js +13 -12
  75. package/dist/worker/worker-portable.js.map +1 -1
  76. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"FileDiff.js","names":[],"sources":["../../src/components/FileDiff.ts"],"sourcesContent":["import type { ElementContent, Element as HASTElement } from 'hast';\nimport { toHtml } from 'hast-util-to-html';\n\nimport {\n CUSTOM_HEADER_SLOT_ID,\n DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n DEFAULT_THEMES,\n DEFAULT_TOKENIZE_MAX_LENGTH,\n DIFFS_TAG_NAME,\n EMPTY_RENDER_RANGE,\n HEADER_FILENAME_SUFFIX_SLOT_ID,\n HEADER_METADATA_SLOT_ID,\n HEADER_PREFIX_SLOT_ID,\n THEME_CSS_ATTRIBUTE,\n UNSAFE_CSS_ATTRIBUTE,\n} from '../constants';\nimport {\n type GetHoveredLineResult,\n type GetLineIndexUtility,\n InteractionManager,\n type InteractionManagerBaseOptions,\n pluckInteractionOptions,\n type SelectionWriteOptions,\n} from '../managers/InteractionManager';\nimport { ResizeManager } from '../managers/ResizeManager';\nimport { ScrollSyncManager } from '../managers/ScrollSyncManager';\nimport {\n dequeueRender,\n queueRender,\n} from '../managers/UniversalRenderingManager';\nimport {\n DiffHunksRenderer,\n type DiffHunksRendererOptions,\n type HunksRenderResult,\n} from '../renderers/DiffHunksRenderer';\nimport { SVGSpriteSheet } from '../sprite';\nimport type {\n AppliedThemeStyleCache,\n BaseCodeOptions,\n BaseDiffOptions,\n CustomPreProperties,\n DiffLineAnnotation,\n DiffsEditableComponent,\n DiffsEditor,\n DiffsTextDocument,\n EditorActiveLineOptions,\n ExpansionDirections,\n FileContents,\n FileDiffMetadata,\n HighlightedToken,\n HunkData,\n HunkSeparators,\n MaybeDiffFileInput,\n PostRenderPhase,\n PrePropertiesConfig,\n RenderHeaderFilenameSuffixCallback,\n RenderHeaderMetadataCallback,\n RenderHeaderPrefixCallback,\n RenderRange,\n SelectedLineRange,\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 { areThemesEqual } from '../utils/areThemesEqual';\nimport { awaitWithTimeout } from '../utils/awaitWithTimeout';\nimport { createAnnotationWrapperNode } from '../utils/createAnnotationWrapperNode';\nimport { createGutterUtilityContentNode } from '../utils/createGutterUtilityContentNode';\nimport { createUnsafeCSSStyleNode } from '../utils/createUnsafeCSSStyleNode';\nimport {\n patchScrollbarGutterSize,\n wrapThemeCSS,\n wrapUnsafeCSS,\n} from '../utils/cssWrappers';\nimport {\n captureExpansionAnchors,\n finishEditSessionForDiff,\n rebuildExpansionFromAnchors,\n} from '../utils/editSessionHunks';\nimport { getDiffFileInput } from '../utils/getDiffFileInput';\nimport { getDiffHunksRendererOptions } from '../utils/getDiffHunksRendererOptions';\nimport { getHunkSideStartBoundary } from '../utils/getHunkSideBoundaries';\nimport { getLineAnnotationName } from '../utils/getLineAnnotationName';\nimport { getOrCreateCodeNode } from '../utils/getOrCreateCodeNode';\nimport { upsertHostThemeStyle } from '../utils/hostTheme';\nimport { hydratePartialDiff } from '../utils/hydratePartialDiff';\nimport { isDefaultRenderRange } from '../utils/isDefaultRenderRange';\nimport { isDiffPlainText } from '../utils/isDiffPlainText';\nimport { isStyleNode } from '../utils/isStyleNode';\nimport { iterateOverDiff } from '../utils/iterateOverDiff';\nimport { parseDiffFromFile } from '../utils/parseDiffFromFile';\nimport { prerenderHTMLIfNecessary } from '../utils/prerenderHTMLIfNecessary';\nimport { getMeasuredScrollbarGutter } from '../utils/scrollbarGutter';\nimport { setPreNodeProperties } from '../utils/setWrapperNodeProps';\nimport {\n getExpandedRegion,\n getHunkAdditionLineRange,\n getNearestRenderableAdditionLine,\n getTrailingExpandedRegion,\n isAdditionLineRenderable,\n} from '../utils/virtualDiffLayout';\nimport type { WorkerPoolManager } from '../worker';\nimport { DiffsContainerLoaded } from './web-components';\n\ntype LoadedPartialDiffContents = Awaited<\n ReturnType<NonNullable<BaseDiffOptions['loadDiffFiles']>>\n>;\n\ntype DeferredSelectedLinesWrite = [\n range: SelectedLineRange | null,\n options: SelectionWriteOptions | undefined,\n];\n\ntype DeferredEditorActiveLineWrite = [\n lineNumber: number | null,\n options: EditorActiveLineOptions | undefined,\n];\n\nfunction canHydrateDiff(fileDiff: FileDiffMetadata): boolean {\n return (\n fileDiff.isPartial &&\n (fileDiff.type === 'change' ||\n fileDiff.type === 'rename-changed' ||\n fileDiff.type === 'rename-pure')\n );\n}\n\nexport interface FileDiffRenderBaseProps<LAnnotation> {\n fileDiff?: FileDiffMetadata;\n deferManagers?: boolean;\n forceRender?: boolean;\n preventEmit?: boolean;\n fileContainer?: HTMLElement;\n containerWrapper?: HTMLElement;\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[];\n renderRange?: RenderRange;\n}\n\nexport type FileDiffRenderProps<LAnnotation> =\n FileDiffRenderBaseProps<LAnnotation> & MaybeDiffFileInput;\n\nexport type FileDiffHydrationProps<LAnnotation> = Omit<\n FileDiffRenderBaseProps<LAnnotation>,\n 'fileContainer'\n> &\n MaybeDiffFileInput & {\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n };\n\nexport type FileDiffType = 'file-diff' | 'unresolved-file';\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 renderHeaderPrefix?: RenderHeaderPrefixCallback;\n renderHeaderFilenameSuffix?: RenderHeaderFilenameSuffixCallback;\n renderHeaderMetadata?: RenderHeaderMetadataCallback;\n renderCustomHeader?: 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 onPostRender?(\n node: HTMLElement,\n instance: FileDiff<LAnnotation>,\n phase: PostRenderPhase\n ): unknown;\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\ninterface PendingFileLoad {\n fileDiff: FileDiffMetadata;\n promise: Promise<void>;\n}\n\ntype HydrationSetup<LAnnotation> = {\n fileDiff: FileDiffMetadata | undefined;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n} & MaybeDiffFileInput;\n\nlet instanceId = -1;\n\nexport class FileDiff<\n LAnnotation = undefined,\n> implements DiffsEditableComponent<LAnnotation> {\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 readonly type: FileDiffType = 'file-diff';\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 themeCSSStyle: HTMLStyleElement | undefined;\n protected appliedThemeCSS: AppliedThemeStyleCache | undefined;\n protected hasAdoptedThemeCSS = false;\n protected unsafeCSSStyle: HTMLStyleElement | undefined;\n protected appliedUnsafeCSS: string | undefined;\n protected gutterUtilityContent: HTMLElement | undefined;\n\n protected headerElement: HTMLElement | undefined;\n protected headerPrefix: HTMLElement | undefined;\n protected headerFilenameSuffix: HTMLElement | undefined;\n protected headerMetadata: HTMLElement | undefined;\n protected headerCustom: 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 protected managersDirty = false;\n\n protected deletionFile?: FileContents | null;\n protected additionFile?: FileContents | null;\n public fileDiff: FileDiffMetadata | undefined;\n protected renderRange: RenderRange | undefined;\n protected pendingFiles: PendingFileLoad | undefined;\n protected appliedPreAttributes: PrePropertiesConfig | undefined;\n protected lastRenderedHeaderHTML: string | undefined;\n protected cachedHeaderHTML: string | undefined;\n protected lastRowCount: number | undefined;\n private mounted = false;\n\n protected enabled = true;\n\n protected editor: DiffsEditor<LAnnotation> | undefined;\n protected refreshViewTimeout: ReturnType<typeof setTimeout> | undefined;\n // Defer selected-line and editor active-line writes while a refresh rebuilds\n // the diff rows. This is separate from the timeout because the refresh can\n // escalate to a full rerender without one.\n protected lineStateRefreshPending = false;\n protected deferredSelectedLines: DeferredSelectedLinesWrite | undefined;\n protected deferredEditorActiveLine: DeferredEditorActiveLineWrite | undefined;\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 ): DiffHunksRendererOptions {\n return getDiffHunksRendererOptions(options);\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 // use the fileDiff from the hunksRenderer if it exists, it maybe updated\n // by the host\n const fileDiff = this.fileDiffCache;\n if (fileDiff == null) {\n return undefined;\n }\n const lastHunk = fileDiff.hunks.at(-1);\n let targetUnifiedIndex: number | undefined;\n let targetSplitIndex: number | undefined;\n hunkIterator: for (const hunk of fileDiff.hunks) {\n const hunkStart =\n side === 'deletions' ? hunk.deletionStart : hunk.additionStart;\n const hunkCount =\n side === 'deletions' ? hunk.deletionCount : hunk.additionCount;\n let currentLineNumber =\n getHunkSideStartBoundary(hunkStart, hunkCount) + 1;\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.cachedHeaderHTML = undefined;\n this.hunksRenderer.setOptions(this.getHunksRendererOptions(options));\n this.syncInteractionOptions();\n }\n\n protected syncInteractionOptions(): void {\n this.interactionManager.setOptions(\n pluckInteractionOptions(\n this.options,\n typeof this.options.hunkSeparators === 'function' ||\n (this.options.hunkSeparators ?? 'line-info') === 'line-info' ||\n this.options.hunkSeparators === 'line-info-basic'\n ? this.handleExpandHunk\n : undefined,\n this.getLineIndex\n )\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.applyCachedThemeState(themeType);\n }\n\n private applyCachedThemeState(themeType: ThemeTypes): boolean {\n if (\n typeof this.options.theme === 'string' ||\n this.fileContainer == null ||\n this.appliedThemeCSS == null\n ) {\n return false;\n }\n const effectiveThemeType = this.appliedThemeCSS.baseThemeType ?? themeType;\n if (this.appliedThemeCSS.themeType === effectiveThemeType) {\n return false;\n }\n this.applyThemeState(\n this.fileContainer,\n this.appliedThemeCSS.themeStyles,\n themeType,\n this.appliedThemeCSS.baseThemeType\n );\n return true;\n }\n\n private hasThemeChanged(): boolean {\n return (\n this.appliedThemeCSS != null &&\n !areThemesEqual(\n this.appliedThemeCSS.theme,\n this.options.theme ?? DEFAULT_THEMES\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(\n range: SelectedLineRange | null,\n options?: SelectionWriteOptions\n ): void {\n if (this.lineStateRefreshPending) {\n this.deferredSelectedLines = [range, options];\n } else {\n this.interactionManager.setSelection(range, options);\n }\n }\n\n public setEditorActiveLine(\n lineNumber: number | null,\n options?: EditorActiveLineOptions\n ): void {\n if (this.lineStateRefreshPending) {\n this.deferredEditorActiveLine = [lineNumber, options];\n } else {\n this.interactionManager.setEditorActiveLine(lineNumber, {\n lineNumberOnly: options?.lineNumberOnly,\n side: options?.side ?? 'additions',\n });\n }\n }\n\n // A refresh can receive selected-lines and editor active-line writes in either\n // order. Apply the latest value from each after the rows are stable.\n protected flushDeferredLineState(): void {\n const {\n deferredEditorActiveLine: editorActiveLine,\n deferredSelectedLines: selectedLines,\n } = this;\n this.lineStateRefreshPending = false;\n this.deferredEditorActiveLine = undefined;\n this.deferredSelectedLines = undefined;\n\n if (editorActiveLine != null) {\n this.setEditorActiveLine(...editorActiveLine);\n }\n if (selectedLines != null) {\n this.interactionManager.setSelection(...selectedLines);\n }\n }\n\n public flushManagers(): void {\n if (!this.managersDirty || this.pre == null) {\n this.managersDirty = false;\n return;\n }\n\n const { diffStyle = 'split', overflow = 'scroll' } = this.options;\n this.interactionManager.setup(this.pre);\n this.resizeManager.setup(this.pre, {\n disableAnnotations: overflow === 'wrap',\n columnVariables: this.shouldApplyColumnVariables(overflow)\n ? 'apply'\n : 'measure',\n });\n if (overflow === 'scroll' && diffStyle === 'split') {\n this.scrollSyncManager.setup(\n this.pre,\n this.codeDeletions,\n this.codeAdditions\n );\n } else {\n this.scrollSyncManager.cleanUp();\n }\n this.managersDirty = false;\n }\n\n protected shouldApplyColumnVariables(overflow: 'scroll' | 'wrap'): boolean {\n if (typeof this.options.hunkSeparators === 'function') {\n return true;\n }\n return (\n overflow === 'scroll' &&\n (this.lineAnnotations.length > 0 ||\n this.pre?.hasAttribute('data-has-merge-conflict') === true)\n );\n }\n\n public getCodeScrollLeft(): number {\n return Math.max(\n this.codeUnified?.scrollLeft ?? 0,\n this.codeDeletions?.scrollLeft ?? 0,\n this.codeAdditions?.scrollLeft ?? 0\n );\n }\n\n public setCodeScrollLeft(position: number): void {\n if (this.codeUnified != null) {\n this.codeUnified.scrollLeft = position;\n }\n if (this.codeAdditions != null) {\n this.codeAdditions.scrollLeft = position;\n }\n if (this.codeDeletions != null) {\n this.codeDeletions.scrollLeft = position;\n }\n }\n\n public __getEffectiveCodeOptions(): BaseCodeOptions {\n return { ...this.options, ...this.hunksRenderer.getEffectiveCodeOptions() };\n }\n\n public cleanUp(recycle: boolean = false): void {\n dequeueRender(this.handleEditSessionRender);\n this.emitPostRender(true);\n // Persist editor state while the code scrollers still exist.\n this.editor?.cleanUp(recycle);\n this.editor = undefined;\n this.resizeManager.cleanUp();\n this.interactionManager.cleanUp();\n this.scrollSyncManager.cleanUp();\n this.managersDirty = false;\n this.workerManager?.unsubscribeToThemeChanges(this);\n this.renderRange = undefined;\n this.pendingFiles = undefined;\n\n // Clean up the elements\n if (!this.isContainerManaged) {\n this.fileContainer?.remove();\n }\n this.fileContainer = undefined;\n this.mounted = false;\n if (!recycle) {\n this.lineAnnotations = [];\n }\n this.clearAuxiliaryNodes();\n this.annotationCache.clear();\n this.pre = undefined;\n this.codeUnified = undefined;\n this.codeDeletions = undefined;\n this.codeAdditions = undefined;\n this.bufferBefore?.remove();\n this.bufferBefore = undefined;\n this.bufferAfter?.remove();\n this.bufferAfter = undefined;\n this.appliedPreAttributes = undefined;\n this.headerElement = undefined;\n this.headerPrefix = undefined;\n this.headerFilenameSuffix = undefined;\n this.headerMetadata = undefined;\n this.headerCustom = undefined;\n this.placeHolder?.remove();\n this.placeHolder = undefined;\n this.lastRenderedHeaderHTML = undefined;\n if (!recycle) {\n this.cachedHeaderHTML = undefined;\n }\n this.errorWrapper?.remove();\n this.errorWrapper = undefined;\n this.spriteSVG = undefined;\n this.lastRowCount = undefined;\n this.themeCSSStyle = undefined;\n this.appliedThemeCSS = undefined;\n this.hasAdoptedThemeCSS = false;\n this.unsafeCSSStyle = undefined;\n this.appliedUnsafeCSS = 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 if (this.refreshViewTimeout != null) {\n clearTimeout(this.refreshViewTimeout);\n this.refreshViewTimeout = undefined;\n }\n this.lineStateRefreshPending = false;\n this.deferredEditorActiveLine = undefined;\n this.deferredSelectedLines = undefined;\n this.enabled = false;\n }\n\n public virtualizedSetup(): void {\n this.enabled = true;\n this.workerManager?.subscribeToThemeChanges(this);\n }\n\n public hydrate({\n fileContainer,\n prerenderedHTML,\n preventEmit = false,\n lineAnnotations,\n fileDiff,\n ...fileInputProps\n }: FileDiffHydrationProps<LAnnotation>): void {\n if (!this.enabled) {\n throw new Error(\n 'FileDiff.hydrate: attempting to call hydrate after cleaned up'\n );\n }\n if (this.fileContainer != null) {\n throw new Error(\n 'FileDiff.hydrate: hydrate can only be called before the instance has rendered or hydrated'\n );\n }\n const fileInput = getDiffFileInput(fileInputProps, 'FileDiff.hydrate');\n const oldFile = fileInput?.oldFile;\n const newFile = fileInput?.newFile;\n this.hydrateElements(fileContainer, prerenderedHTML);\n if (\n shouldRenderCode(\n this.pre,\n hasDiffContent({ fileDiff, oldFile, newFile }),\n this.options.collapsed\n ) ||\n shouldRenderHeader(\n this.headerElement,\n hasDiffHeaderContent({ fileDiff, oldFile, newFile }),\n this.options.disableFileHeader\n )\n ) {\n this.render({\n ...fileInputProps,\n fileContainer,\n lineAnnotations,\n fileDiff,\n preventEmit: true,\n });\n }\n // Otherwise orchestrate our setup\n else {\n this.hydrationSetup({\n fileDiff,\n lineAnnotations,\n ...fileInput,\n });\n }\n if (!preventEmit) {\n this.emitPostRender();\n }\n }\n\n protected hydrateElements(\n fileContainer: HTMLElement,\n prerenderedHTML: string | undefined\n ): void {\n if (this.fileContainer !== fileContainer) {\n this.emitPostRender(true);\n }\n prerenderHTMLIfNecessary(fileContainer, prerenderedHTML);\n for (const element of fileContainer.shadowRoot?.children ?? []) {\n if (element instanceof SVGElement) {\n this.spriteSVG = element;\n continue;\n }\n if (!(element instanceof HTMLElement)) {\n continue;\n }\n if (element instanceof HTMLPreElement) {\n this.pre = element;\n for (const code of element.children) {\n if (\n !(code instanceof HTMLElement) ||\n code.tagName.toLowerCase() !== 'code'\n ) {\n continue;\n }\n if ('deletions' in code.dataset) {\n this.codeDeletions = code;\n }\n if ('additions' in code.dataset) {\n this.codeAdditions = code;\n }\n if ('unified' in code.dataset) {\n this.codeUnified = code;\n }\n }\n continue;\n }\n if ('diffsHeader' in element.dataset) {\n this.headerElement = element;\n continue;\n }\n if (\n element instanceof HTMLStyleElement &&\n element.hasAttribute(THEME_CSS_ATTRIBUTE)\n ) {\n this.themeCSSStyle = element;\n continue;\n }\n if (\n element instanceof HTMLStyleElement &&\n element.hasAttribute(UNSAFE_CSS_ATTRIBUTE)\n ) {\n this.unsafeCSSStyle = element;\n this.appliedUnsafeCSS = element.textContent;\n continue;\n }\n }\n if (this.pre != null) {\n this.syncCodeNodesFromPre(this.pre);\n this.pre.removeAttribute('data-dehydrated');\n }\n this.fileContainer = fileContainer;\n this.hydrateMeasuredScrollbar();\n }\n\n protected hydrationSetup({\n fileDiff,\n oldFile,\n newFile,\n lineAnnotations,\n }: HydrationSetup<LAnnotation>): void {\n // It's possible we are hydrating a pure-rename and therefore there will be\n // no pre element\n this.lineAnnotations = lineAnnotations ?? this.lineAnnotations;\n this.additionFile = newFile;\n this.deletionFile = oldFile;\n this.fileDiff =\n fileDiff ??\n (oldFile !== undefined && newFile !== undefined\n ? parseDiffFromFile(oldFile, newFile, this.options.parseDiffOptions)\n : undefined);\n\n if (this.pre == null) {\n return;\n }\n\n this.syncInteractionOptions();\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.managersDirty = true;\n this.flushManagers();\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 public onThemeChange(): void {\n this.hunksRenderer.clearRenderCache();\n this.rerender();\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.loadFilesIfNecessary();\n this.rerender();\n };\n\n protected loadFilesIfNecessary(): void {\n const {\n fileDiff,\n options: { loadDiffFiles },\n } = this;\n if (\n fileDiff == null ||\n loadDiffFiles == null ||\n !canHydrateDiff(fileDiff) ||\n this.pendingFiles?.fileDiff === fileDiff\n ) {\n return;\n }\n\n this.pendingFiles = {\n fileDiff,\n promise: this.loadFilesForDiff(fileDiff, loadDiffFiles),\n };\n }\n\n private async loadFilesForDiff(\n fileDiff: FileDiffMetadata,\n loadDiffFiles: NonNullable<BaseDiffOptions['loadDiffFiles']>\n ): Promise<void> {\n try {\n const files = await loadDiffFiles(fileDiff);\n if (!this.enabled || this.fileDiff !== fileDiff) {\n return;\n }\n\n await this.handleFilesLoaded(fileDiff, files);\n } catch (error: unknown) {\n if (this.options.disableErrorHandling === true) {\n throw error;\n }\n console.error(error);\n } finally {\n if (this.pendingFiles?.fileDiff === fileDiff) {\n this.pendingFiles = undefined;\n }\n }\n }\n\n protected async handleFilesLoaded(\n expectedDiff: FileDiffMetadata,\n files: LoadedPartialDiffContents\n ): Promise<void> {\n if (this.fileDiff !== expectedDiff || !expectedDiff.isPartial) {\n return;\n }\n hydratePartialDiff('merge', expectedDiff, files);\n this.setHydratedState(files);\n await awaitWithTimeout(() => this.primeHighlightCache(expectedDiff));\n if (!this.enabled || this.fileDiff !== expectedDiff) {\n return;\n }\n this.rerender();\n }\n\n protected setHydratedState(files: LoadedPartialDiffContents): void {\n this.deletionFile = files.oldFile;\n this.additionFile = files.newFile;\n this.workerManager?.cleanUpTasks(this.hunksRenderer);\n this.hunksRenderer.clearRenderCache();\n }\n\n public render({\n fileDiff,\n deferManagers = false,\n forceRender = false,\n preventEmit = false,\n lineAnnotations,\n fileContainer,\n containerWrapper,\n renderRange,\n ...fileInputProps\n }: FileDiffRenderProps<LAnnotation>): boolean {\n const fileInput = getDiffFileInput(fileInputProps, 'FileDiff.render');\n const oldFile = fileInput?.oldFile;\n const newFile = fileInput?.newFile;\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\n // use the file name as the cache key if it is not set\n if (fileDiff != null && fileDiff.cacheKey === undefined) {\n fileDiff.cacheKey =\n fileDiff.prevName != null\n ? fileDiff.prevName + ':' + fileDiff.name\n : fileDiff.name;\n }\n\n // postpone background tokenizing to next frame for avoiding UI freeze\n // during render\n this.editor?.__postponeBgTokenizeToNextFrame();\n\n const {\n collapsed = false,\n themeType = 'system',\n expandUnchanged = false,\n } = this.options;\n const nextRenderRange = collapsed ? undefined : renderRange;\n const themeChanged = this.hasThemeChanged();\n const hasFileInput = fileInput != null;\n const filesDidChange =\n hasFileInput &&\n (!areOptionalFilesEqual(oldFile, this.deletionFile) ||\n !areOptionalFilesEqual(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 !themeChanged &&\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 this.applyCachedThemeState(themeType);\n }\n\n let nextParsedFileDiff: FileDiffMetadata | undefined;\n if (\n fileDiff == null &&\n hasFileInput &&\n (filesDidChange || this.fileDiff == null)\n ) {\n nextParsedFileDiff = parseDiffFromFile(\n fileInput.oldFile,\n fileInput.newFile,\n this.options.parseDiffOptions\n );\n }\n\n const { renderRange: previousRenderRange } = this;\n this.renderRange = nextRenderRange;\n // Store files only when this render actually carried a file input:\n // internal rerenders pass none, and wiping the pair here would defeat the\n // oldFile/newFile early-return on every later host render. An explicit\n // fileDiff input supersedes a previously parsed pair, so clear it then.\n if (hasFileInput) {\n this.deletionFile = oldFile;\n this.additionFile = newFile;\n } else if (fileDiff != null) {\n this.deletionFile = undefined;\n this.additionFile = undefined;\n }\n\n if (fileDiff != null) {\n this.fileDiff = fileDiff;\n } else if (nextParsedFileDiff != null) {\n diffDidChange = true;\n this.fileDiff = nextParsedFileDiff;\n }\n if (diffDidChange) {\n this.cachedHeaderHTML = undefined;\n }\n\n if (lineAnnotations != null) {\n this.setLineAnnotations(lineAnnotations);\n }\n if (this.fileDiff == null) {\n return false;\n }\n // Backstop for sessions that ended without their exit hook running (e.g.\n // session-shaped metadata reused after a host teardown): restore\n // recompute-shaped hunks before rendering.\n if (\n this.fileDiff.editSessionDirty === true &&\n this.shouldSelfHealEditSession()\n ) {\n finishEditSessionForDiff(this.fileDiff, this.options.parseDiffOptions);\n void this.hunksRenderer.refreshHighlightedResult();\n }\n if (expandUnchanged) {\n this.loadFilesIfNecessary();\n }\n this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options));\n this.syncInteractionOptions();\n\n this.hunksRenderer.setLineAnnotations(this.lineAnnotations);\n\n const { disableErrorHandling = false, disableFileHeader = false } =\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 this.clearHeaderSlots();\n }\n fileContainer = this.getOrCreateFileContainer(\n fileContainer,\n containerWrapper\n );\n this.applyCachedThemeState(themeType);\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 != null) {\n this.applyThemeState(\n fileContainer,\n hunksResult.themeStyles,\n themeType,\n hunksResult.baseThemeType\n );\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 if (!preventEmit) {\n this.emitPostRender();\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 || themeChanged\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 this.applyThemeState(\n fileContainer,\n hunksResult.themeStyles,\n themeType,\n hunksResult.baseThemeType\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 this.applyBuffers(pre, nextRenderRange);\n this.injectUnsafeCSS();\n this.renderAnnotations();\n this.renderGutterUtility();\n\n this.managersDirty = true;\n if (!deferManagers) {\n this.flushManagers();\n }\n\n if (this.editor != null) {\n this.syncRenderViewToEditor();\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 if (!preventEmit) {\n this.emitPostRender();\n }\n return true;\n }\n\n protected emitPostRender(unmount = false): void {\n const {\n fileContainer,\n options: { onPostRender },\n } = this;\n\n if (unmount) {\n if (!this.mounted) {\n return;\n }\n this.mounted = false;\n if (fileContainer == null) {\n return;\n }\n this.options.onPostRender?.(fileContainer, this, 'unmount');\n return;\n }\n\n if (fileContainer == null) {\n return;\n }\n\n const phase: PostRenderPhase = this.mounted ? 'update' : 'mount';\n this.mounted = true;\n onPostRender?.(fileContainer, this, phase);\n }\n\n protected get fileDiffCache(): FileDiffMetadata | undefined {\n return this.hunksRenderer.diffCache ?? this.fileDiff;\n }\n\n private syncRenderViewToEditor(): void {\n const editor = this.editor;\n const fileContainer = this.fileContainer;\n const fileDiff = this.fileDiffCache;\n const lineAnnotations = this.lineAnnotations;\n const renderRange = this.computeEditorRenderRange(this.renderRange);\n if (\n editor != null &&\n fileContainer != null &&\n fileDiff != null &&\n !fileDiff.isPartial\n ) {\n void this.hunksRenderer.initializeHighlighter().then((highlighter) => {\n if (\n !this.enabled ||\n this.editor !== editor ||\n this.fileContainer !== fileContainer ||\n this.fileDiffCache !== fileDiff\n ) {\n return;\n }\n editor.__syncRenderView(\n highlighter,\n fileContainer,\n fileDiff,\n lineAnnotations,\n renderRange\n );\n });\n }\n }\n\n // The stored render range is in rendered-row units for the windowed AST\n // pipeline, but the editor consumes render ranges in document-line units.\n // Derive the addition-side document window covered by the rendered rows:\n // startingLine = first addition line with a row in the window, totalLines =\n // last such line - first + 1, and 0 when the window holds no addition rows\n // (e.g. a pure-deletion run taller than the viewport).\n private computeEditorRenderRange(\n renderRange: RenderRange | undefined\n ): RenderRange | undefined {\n const fileDiff = this.fileDiffCache;\n if (\n renderRange == null ||\n fileDiff == null ||\n isDefaultRenderRange(renderRange)\n ) {\n return renderRange;\n }\n const {\n diffStyle = 'split',\n expandUnchanged = false,\n collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n } = this.options;\n let firstLineNumber: number | undefined;\n let lastLineNumber: number | undefined;\n iterateOverDiff({\n diff: fileDiff,\n diffStyle,\n startingLine: renderRange.startingLine,\n totalLines: renderRange.totalLines,\n expandedHunks: expandUnchanged\n ? true\n : this.hunksRenderer.getExpandedHunksMap(),\n collapsedContextThreshold,\n callback: ({ additionLine }) => {\n if (additionLine != null) {\n firstLineNumber ??= additionLine.lineNumber;\n lastLineNumber = additionLine.lineNumber;\n }\n },\n });\n if (firstLineNumber == null || lastLineNumber == null) {\n return { ...renderRange, startingLine: 0, totalLines: 0 };\n }\n return {\n ...renderRange,\n startingLine: firstLineNumber - 1,\n totalLines: lastLineNumber - firstLineNumber + 1,\n };\n }\n\n public attachEditor(\n editor: DiffsEditor<LAnnotation>\n ): (recycle?: boolean) => void {\n // Editing is a plain file-diff concern only. Subclasses with their own\n // hunk semantics (UnresolvedFile) are not editable, so an editor must\n // never attach to them.\n if (this.type !== 'file-diff') {\n throw new Error(\n `FileDiff.attachEditor: cannot attach an editor to a \"${this.type}\" diff`\n );\n }\n this.editor?.cleanUp();\n this.editor = editor;\n this.hunksRenderer.beginEditSession();\n // The editor sync below refuses partial diffs (it needs the full file\n // contents); kick off hydration so the loaded re-render re-runs it.\n if (this.fileDiff?.isPartial === true) {\n this.loadFilesIfNecessary();\n }\n if (this.hunksRenderer.editorRenderReady()) {\n this.syncRenderViewToEditor();\n } else {\n // The current markup is missing the editor's token metadata, or its\n // highlight is still pending: render through the session, which also\n // syncs the render view once it paints.\n this.rerender();\n }\n return (recycle?: boolean) => {\n this.editor = undefined;\n // A recycle detach is a virtualized unmount mid-session: the session\n // continues on remount, so hunks stay session-shaped. Only a genuine\n // end runs the exit recompute.\n if (recycle !== true) {\n this.finishEditSession();\n }\n };\n }\n\n // Genuine session exit for the live detach path.\n private finishEditSession(): void {\n this.hunksRenderer.endEditSession();\n this.completeEditSession();\n }\n\n /**\n * Run the genuine session-end recompute: restore recompute-shaped hunks (a\n * context-only region collapses away, boundaries re-derive), preserve\n * expansion state best-effort via old-side anchors, and repaint through\n * the session render path — which also invalidates virtualized layout,\n * since nothing else does at exit now that editing does not flip\n * expandUnchanged. Marker-guarded and idempotent; CodeView also calls this\n * when reaping a session whose detach closure was consumed by a recycle.\n * Safe on a cleaned-up instance: the recompute is pure metadata work and\n * the deferred rerender is enabled-guarded. Returns true when a recompute\n * ran.\n */\n public completeEditSession(): boolean {\n const fileDiff = this.fileDiffCache;\n if (fileDiff == null || fileDiff.editSessionDirty !== true) {\n return false;\n }\n const { collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD } =\n this.options;\n const anchors = captureExpansionAnchors(\n fileDiff,\n this.hunksRenderer.getExpandedHunksMap(),\n collapsedContextThreshold\n );\n finishEditSessionForDiff(fileDiff, this.options.parseDiffOptions);\n this.hunksRenderer.setExpandedHunksMap(\n rebuildExpansionFromAnchors(fileDiff, anchors)\n );\n void this.hunksRenderer.refreshHighlightedResult();\n this.escalateEditSessionRender();\n return true;\n }\n\n // normally triggered by the host when the document line count changes\n public applyDocumentChange(\n textDocument: DiffsTextDocument,\n newLineAnnotations?: DiffLineAnnotation<LAnnotation>[]\n ): void {\n this.hunksRenderer.applyDocumentChange(textDocument);\n const fileDiff = this.hunksRenderer.diffCache;\n if (fileDiff != null) {\n const cacheKey = this.fileDiff?.cacheKey;\n if (cacheKey != null && fileDiff.cacheKey == null) {\n fileDiff.cacheKey = cacheKey;\n }\n this.fileDiff = fileDiff;\n }\n if (\n newLineAnnotations !== undefined &&\n newLineAnnotations !== this.lineAnnotations\n ) {\n this.setLineAnnotations(newLineAnnotations);\n this.hunksRenderer.setLineAnnotations(this.lineAnnotations);\n this.renderAnnotations();\n }\n this.rerender();\n this.interactionManager.setSelectionDirty();\n }\n\n public updateRenderCache(\n dirtyLines: Map<number, Array<HighlightedToken>>,\n themeType: 'dark' | 'light',\n options: {\n shouldRefreshDiffsView?: boolean;\n lineCountChangeInFlight?: boolean;\n } = {}\n ): void {\n const { shouldRefreshDiffsView, lineCountChangeInFlight } = options;\n const regionsChanged = this.hunksRenderer.updateRenderCache(\n dirtyLines,\n themeType,\n lineCountChangeInFlight\n );\n // A same-line-count edit that reshaped the session regions (an edit into\n // a collapsed gap) changes the rendered row set, which the debounced\n // line-type refresh below cannot express. Escalate to a deferred full\n // re-render — never a synchronous one, since this runs mid-editor-pass\n // and rebuilding rows the editor is about to touch detaches its geometry\n // caches.\n if (regionsChanged) {\n if (this.refreshViewTimeout != null) {\n clearTimeout(this.refreshViewTimeout);\n this.refreshViewTimeout = undefined;\n }\n this.lineStateRefreshPending = true;\n this.escalateEditSessionRender();\n return;\n }\n if (shouldRefreshDiffsView === true) {\n if (this.refreshViewTimeout != null) {\n clearTimeout(this.refreshViewTimeout);\n }\n this.lineStateRefreshPending = true;\n this.refreshViewTimeout = setTimeout(() => {\n this.refreshViewTimeout = undefined;\n if (this.options.diffStyle === 'split') {\n this.refreshSplitDiffView();\n } else {\n this.refreshUnifiedDiffView();\n }\n this.flushDeferredLineState();\n }, 150);\n }\n }\n\n // Editor-facing visibility oracle: whether a one-based new-file line has\n // (or will have on scroll) a rendered row under the current expansion\n // state. See isAdditionLineRenderable.\n public isLineRenderable(lineNumber: number): boolean {\n const fileDiff = this.fileDiffCache;\n if (fileDiff == null) {\n return true;\n }\n const {\n expandUnchanged = false,\n collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n } = this.options;\n return isAdditionLineRenderable({\n fileDiff,\n lineNumber,\n expandedHunks: expandUnchanged\n ? true\n : this.hunksRenderer.getExpandedHunksMap(),\n collapsedContextThreshold,\n });\n }\n\n // Fold-skip companion to isLineRenderable: the nearest renderable one-based\n // new-file line at or beyond lineNumber in the given direction.\n public getNearestRenderableLine(\n lineNumber: number,\n direction: 'up' | 'down'\n ): number | undefined {\n const fileDiff = this.fileDiffCache;\n if (fileDiff == null) {\n return lineNumber;\n }\n const {\n expandUnchanged = false,\n collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n } = this.options;\n return getNearestRenderableAdditionLine({\n fileDiff,\n lineNumber,\n direction,\n expandedHunks: expandUnchanged\n ? true\n : this.hunksRenderer.getExpandedHunksMap(),\n collapsedContextThreshold,\n });\n }\n\n // Expand collapsed context so a one-based new-file line can render: one\n // deterministic expansion from the nearest gap edge, sized to reach the\n // target plus the normal expansion step (clamped to the gap at render).\n // Routed through expandHunk so subclass expansion flows (CodeView's\n // deferred pendingExpansions) apply.\n public revealLine(lineNumber: number): boolean {\n const fileDiff = this.fileDiffCache;\n const {\n expandUnchanged = false,\n collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n expansionLineCount = 100,\n } = this.options;\n if (fileDiff == null || fileDiff.isPartial || expandUnchanged) {\n return false;\n }\n const expandedHunks = this.hunksRenderer.getExpandedHunksMap();\n\n for (const [hunkIndex, hunk] of fileDiff.hunks.entries()) {\n const [hunkStart, hunkEnd] = getHunkAdditionLineRange(hunk);\n if (lineNumber < hunkStart) {\n const region = getExpandedRegion({\n isPartial: fileDiff.isPartial,\n rangeSize: hunk.collapsedBefore,\n expandedHunks,\n hunkIndex,\n collapsedContextThreshold,\n });\n const gapStart = hunkStart - region.rangeSize;\n if (\n region.renderAll ||\n lineNumber < gapStart + region.fromStart ||\n lineNumber >= hunkStart - region.fromEnd\n ) {\n return false;\n }\n const fromStartDistance =\n lineNumber - (gapStart + region.fromStart) + 1;\n const fromEndDistance = hunkStart - region.fromEnd - lineNumber;\n if (fromStartDistance <= fromEndDistance) {\n this.expandHunk(\n hunkIndex,\n 'up',\n fromStartDistance + expansionLineCount\n );\n } else {\n this.expandHunk(\n hunkIndex,\n 'down',\n fromEndDistance + expansionLineCount\n );\n }\n return true;\n }\n if (lineNumber < hunkEnd) {\n return false;\n }\n }\n\n const trailingRegion = getTrailingExpandedRegion({\n fileDiff,\n hunkIndex: fileDiff.hunks.length - 1,\n expandedHunks,\n collapsedContextThreshold,\n errorPrefix: 'FileDiff.revealLine',\n });\n if (trailingRegion == null || trailingRegion.renderAll) {\n return false;\n }\n const lastHunk = fileDiff.hunks[fileDiff.hunks.length - 1];\n const [, trailingStart] = getHunkAdditionLineRange(lastHunk);\n if (\n lineNumber < trailingStart + trailingRegion.fromStart ||\n lineNumber >= trailingStart + trailingRegion.rangeSize\n ) {\n return false;\n }\n this.expandHunk(\n fileDiff.hunks.length,\n 'up',\n lineNumber -\n (trailingStart + trailingRegion.fromStart) +\n 1 +\n expansionLineCount\n );\n return true;\n }\n\n // Whether render() may run the session-exit recompute on dirty metadata.\n // False while an editor is attached (the session is live). CodeView-managed\n // instances override this: their sessions survive recycling with no editor\n // attached, and CodeView runs the exit recompute itself when it reaps a\n // session.\n protected shouldSelfHealEditSession(): boolean {\n return this.editor == null;\n }\n\n // Deferred full re-render for session region changes. The subsequent\n // render() ends in syncRenderViewToEditor, which resets the editor's\n // geometry caches against the rebuilt rows. VirtualizedFileDiff overrides\n // this to also invalidate its layout caches.\n protected escalateEditSessionRender(): void {\n queueRender(this.handleEditSessionRender);\n }\n\n private handleEditSessionRender = (): void => {\n this.rerender();\n this.flushDeferredLineState();\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.emitPostRender(true);\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 public async primeHighlightCache(\n fileDiff: FileDiffMetadata | undefined = this.fileDiff\n ): Promise<void> {\n const { workerManager } = this;\n if (\n fileDiff == null ||\n workerManager == null ||\n !workerManager.isWorkingPool() ||\n fileDiff.cacheKey == null ||\n isDiffPlainText(fileDiff)\n ) {\n return;\n }\n const tokenizeMaxLength =\n this.options.tokenizeMaxLength ?? DEFAULT_TOKENIZE_MAX_LENGTH;\n if (\n Math.max(fileDiff.additionLines.length, fileDiff.deletionLines.length) >\n tokenizeMaxLength\n ) {\n return;\n }\n\n await workerManager\n .primeDiffHighlightCache(fileDiff)\n .catch((error: unknown) => {\n console.error(error);\n });\n }\n\n private cleanChildNodes() {\n this.resizeManager.cleanUp();\n this.scrollSyncManager.cleanUp();\n this.interactionManager.cleanUp();\n this.clearAuxiliaryNodes();\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.headerPrefix?.remove();\n this.headerFilenameSuffix?.remove();\n this.headerMetadata?.remove();\n this.headerCustom?.remove();\n this.pre?.remove();\n this.spriteSVG?.remove();\n this.themeCSSStyle?.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.headerPrefix = undefined;\n this.headerFilenameSuffix = undefined;\n this.headerMetadata = undefined;\n this.headerCustom = undefined;\n this.pre = undefined;\n this.spriteSVG = undefined;\n this.themeCSSStyle = undefined;\n this.appliedThemeCSS = undefined;\n this.hasAdoptedThemeCSS = false;\n this.unsafeCSSStyle = undefined;\n this.appliedUnsafeCSS = undefined;\n\n this.lastRenderedHeaderHTML = undefined;\n this.lastRowCount = undefined;\n this.mounted = false;\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 protected 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 protected renderGutterUtility(): void {\n const { renderGutterUtility } = this.options;\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 { fileContainer: previousContainer } = this;\n const nextContainer =\n fileContainer ??\n previousContainer ??\n document.createElement(DIFFS_TAG_NAME);\n const containerChanged = previousContainer !== nextContainer;\n if (previousContainer != null && containerChanged) {\n this.editor?.__captureFocusForDOMReplacement();\n }\n if (containerChanged) {\n this.emitPostRender(true);\n }\n this.fileContainer = nextContainer;\n if (previousContainer != null && containerChanged) {\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 (containerChanged) {\n this.adoptReusableShellElements(this.fileContainer);\n }\n this.ensureSpriteSVG(this.fileContainer);\n return this.fileContainer;\n }\n\n // NOTE(amadeus): Technically this method is not safe for use outside of\n // the CodeView component, however I don't think in practice it really\n // should matter, but maybe there's some system we need in place to prevent\n // this from running outside of that environment?\n //\n // It's making very specific assumptions that all the elements will have the\n // correct content based on CodeView global options\n private adoptReusableShellElements(fileContainer: HTMLElement): void {\n const { shadowRoot } = fileContainer;\n if (shadowRoot == null) {\n return;\n }\n\n for (const element of shadowRoot.children) {\n if (element instanceof SVGElement) {\n this.spriteSVG ??= element;\n } else if (\n isStyleNode(element) &&\n element.hasAttribute(THEME_CSS_ATTRIBUTE)\n ) {\n this.themeCSSStyle ??= element;\n this.hasAdoptedThemeCSS = true;\n } else if (\n isStyleNode(element) &&\n element.hasAttribute(UNSAFE_CSS_ATTRIBUTE)\n ) {\n this.unsafeCSSStyle ??= element;\n this.appliedUnsafeCSS ??= this.options.unsafeCSS ?? undefined;\n }\n }\n }\n\n private ensureSpriteSVG(fileContainer: HTMLElement): void {\n const shadowRoot =\n fileContainer.shadowRoot ?? fileContainer.attachShadow({ mode: 'open' });\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 }\n }\n if (this.spriteSVG != null && this.spriteSVG.parentNode !== shadowRoot) {\n shadowRoot.appendChild(this.spriteSVG);\n }\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 this.editor?.__captureFocusForDOMReplacement();\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 protected 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 (child.hasAttribute('data-unified')) {\n this.codeUnified = child;\n } else if (child.hasAttribute('data-deletions')) {\n this.codeDeletions = child;\n } else if (child.hasAttribute('data-additions')) {\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 { fileDiff } = this;\n const headerHTML = this.cachedHeaderHTML ?? toHtml(headerAST);\n this.cachedHeaderHTML = headerHTML;\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 || fileDiff == null) {\n return;\n }\n\n const {\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderFilenameSuffix,\n renderHeaderMetadata,\n } = this.options;\n\n if (renderCustomHeader != null) {\n const content = renderCustomHeader(fileDiff) ?? undefined;\n this.headerCustom = this.upsertHeaderSlotElement(\n container,\n this.headerCustom,\n CUSTOM_HEADER_SLOT_ID,\n content\n );\n this.headerPrefix?.remove();\n this.headerFilenameSuffix?.remove();\n this.headerMetadata?.remove();\n this.headerPrefix = undefined;\n this.headerFilenameSuffix = undefined;\n this.headerMetadata = undefined;\n return;\n }\n\n const prefix = renderHeaderPrefix?.(fileDiff) ?? undefined;\n const suffix = renderHeaderFilenameSuffix?.(fileDiff) ?? undefined;\n const content = renderHeaderMetadata?.(fileDiff) ?? undefined;\n this.headerPrefix = this.upsertHeaderSlotElement(\n container,\n this.headerPrefix,\n HEADER_PREFIX_SLOT_ID,\n prefix\n );\n this.headerFilenameSuffix = this.upsertHeaderSlotElement(\n container,\n this.headerFilenameSuffix,\n HEADER_FILENAME_SUFFIX_SLOT_ID,\n suffix\n );\n this.headerMetadata = this.upsertHeaderSlotElement(\n container,\n this.headerMetadata,\n HEADER_METADATA_SLOT_ID,\n content\n );\n this.headerCustom?.remove();\n this.headerCustom = undefined;\n }\n\n private clearHeaderSlots(): void {\n this.headerPrefix?.remove();\n this.headerFilenameSuffix?.remove();\n this.headerMetadata?.remove();\n this.headerCustom?.remove();\n this.headerPrefix = undefined;\n this.headerFilenameSuffix = undefined;\n this.headerMetadata = undefined;\n this.headerCustom = undefined;\n }\n\n // Header slot callbacks are presence-based render hooks, not reactive views.\n private upsertHeaderSlotElement(\n container: HTMLElement,\n current: HTMLElement | undefined,\n slot: string,\n content: Element | string | number | undefined\n ): HTMLElement | undefined {\n if (content == null) {\n current?.remove();\n return undefined;\n }\n const element = current ?? this.createHeaderSlotElement(slot);\n if (current == null) {\n container.appendChild(element);\n }\n this.replaceHeaderSlotContent(element, content);\n return element;\n }\n\n private replaceHeaderSlotContent(\n element: HTMLElement,\n content: Element | string | number\n ): void {\n element.replaceChildren();\n if (content instanceof Element) {\n element.appendChild(content);\n } else {\n element.innerText = `${content}`;\n }\n }\n\n private createHeaderSlotElement(slot: string): HTMLElement {\n const element = document.createElement('div');\n element.slot = slot;\n return element;\n }\n\n protected injectUnsafeCSS(): void {\n const { unsafeCSS } = this.options;\n const shadowRoot = this.fileContainer?.shadowRoot;\n if (shadowRoot == null) {\n return;\n }\n\n if (unsafeCSS == null || unsafeCSS === '') {\n if (this.unsafeCSSStyle != null) {\n this.unsafeCSSStyle.remove();\n this.unsafeCSSStyle = undefined;\n }\n this.appliedUnsafeCSS = undefined;\n return;\n }\n\n if (\n this.unsafeCSSStyle?.parentNode === shadowRoot &&\n this.appliedUnsafeCSS === unsafeCSS\n ) {\n return;\n }\n\n // Create or update the style element\n this.unsafeCSSStyle ??= createUnsafeCSSStyleNode();\n if (this.unsafeCSSStyle.parentNode !== shadowRoot) {\n shadowRoot.appendChild(this.unsafeCSSStyle);\n }\n // Wrap in @layer unsafe to match SSR behavior\n this.unsafeCSSStyle.textContent = wrapUnsafeCSS(unsafeCSS);\n this.appliedUnsafeCSS = unsafeCSS;\n }\n\n private applyThemeState(\n container: HTMLElement,\n themeStyles: string,\n themeType: ThemeTypes,\n baseThemeType?: 'light' | 'dark'\n ): void {\n const shadowRoot =\n container.shadowRoot ?? container.attachShadow({ mode: 'open' });\n const effectiveThemeType = baseThemeType ?? themeType;\n const currentTheme = this.options.theme ?? DEFAULT_THEMES;\n const theme =\n typeof currentTheme === 'string' ? currentTheme : { ...currentTheme };\n const scrollbarGutter = getMeasuredScrollbarGutter(shadowRoot);\n if (\n this.themeCSSStyle?.parentNode === shadowRoot &&\n this.appliedThemeCSS?.themeStyles === themeStyles &&\n this.appliedThemeCSS.themeType === effectiveThemeType &&\n this.appliedThemeCSS.scrollbarGutter === scrollbarGutter\n ) {\n this.appliedThemeCSS.theme = theme;\n return;\n }\n if (\n this.hasAdoptedThemeCSS &&\n this.themeCSSStyle?.parentNode === shadowRoot\n ) {\n this.hasAdoptedThemeCSS = false;\n this.appliedThemeCSS = {\n theme,\n themeStyles,\n themeType: effectiveThemeType,\n baseThemeType,\n scrollbarGutter,\n };\n return;\n }\n this.themeCSSStyle = upsertHostThemeStyle({\n shadowRoot,\n currentNode: this.themeCSSStyle,\n themeCSS: wrapThemeCSS(themeStyles, effectiveThemeType, scrollbarGutter),\n });\n this.appliedThemeCSS =\n this.themeCSSStyle != null\n ? {\n theme,\n themeStyles,\n themeType: effectiveThemeType,\n baseThemeType,\n scrollbarGutter,\n }\n : undefined;\n }\n\n private hydrateMeasuredScrollbar(): void {\n const shadowRoot = this.fileContainer?.shadowRoot;\n if (shadowRoot == null || this.themeCSSStyle == null) {\n return;\n }\n this.themeCSSStyle.textContent = patchScrollbarGutterSize(\n this.themeCSSStyle.textContent ?? '',\n getMeasuredScrollbarGutter(shadowRoot)\n );\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 this.editor?.__captureFocusForDOMReplacement();\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('FileDiff.applyPartialRender: failed to trim to overlap');\n }\n\n if (this.lastRowCount < trimResult) {\n throw new Error(\n 'FileDiff.applyPartialRender: trimmed beyond DOM row count'\n );\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 // fast refresh diff view via updating the `data-line-type` after an edit.\n // only for split view.\n private refreshSplitDiffView(): void {\n if (this.options.diffStyle !== 'split') {\n return;\n }\n\n const hunksResult = this.hunksRenderer.renderDiff(\n this.fileDiff,\n this.renderRange\n );\n if (hunksResult == null) {\n return;\n }\n\n const columns = this.getCodeColumns(\n 'split',\n this.codeUnified,\n this.codeDeletions,\n this.codeAdditions\n );\n if (!Array.isArray(columns)) {\n return;\n }\n\n const applyLineType = (\n type: 'deletions' | 'additions',\n column: ColumnElements | undefined\n ) => {\n if (column == null) {\n return;\n }\n const ast = this.hunksRenderer.renderCodeAST(type, hunksResult);\n const gutterChildren = getElementChildren(ast?.[0]);\n const contentChildren = getElementChildren(ast?.[1]);\n for (const [el, astChildren] of [\n [column.gutter, gutterChildren],\n [column.content, contentChildren],\n ] as const) {\n if (\n astChildren != null &&\n el.childElementCount === astChildren.length\n ) {\n for (let i = 0; i < astChildren.length; i++) {\n const gutterElement = el.children[i] as HTMLElement;\n const gutterChild = astChildren[i] as HASTElement;\n const lineType = gutterChild.properties['data-line-type'] as\n | string\n | undefined;\n if (\n lineType != null &&\n gutterElement.dataset.lineType !== lineType\n ) {\n gutterElement.dataset.lineType = lineType;\n }\n }\n }\n }\n };\n\n applyLineType('deletions', columns[0]);\n applyLineType('additions', columns[1]);\n }\n\n // full diff view re-rendering\n // only for unified view.\n private refreshUnifiedDiffView(): void {\n if (this.options.diffStyle !== 'unified') {\n return;\n }\n\n const hunksResult = this.hunksRenderer.renderDiff(\n this.fileDiff,\n this.renderRange\n );\n if (hunksResult == null) {\n return;\n }\n\n const columns = this.getCodeColumns(\n 'unified',\n this.codeUnified,\n this.codeDeletions,\n this.codeAdditions\n );\n if (columns == null || Array.isArray(columns)) {\n return;\n }\n\n const ast = this.hunksRenderer.renderCodeAST('unified', hunksResult);\n const gutterChildren = getElementChildren(ast?.[0]);\n const contentChildren = getElementChildren(ast?.[1]);\n for (const [el, astChildren] of [\n [columns.gutter, gutterChildren],\n [columns.content, contentChildren],\n ] as const) {\n if (astChildren != null) {\n el.innerHTML = toHtml(astChildren);\n }\n }\n\n if (hunksResult.rowCount !== this.lastRowCount) {\n this.applyRowSpan('unified', columns, hunksResult.rowCount);\n this.lastRowCount = hunksResult.rowCount;\n }\n this.renderSeparators(hunksResult.hunkData);\n\n this.managersDirty = true;\n this.flushManagers();\n\n // sync the render view to the editor\n this.syncRenderViewToEditor();\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 if (preTrimCount === 0 && newSize === 0) {\n pendingMetadataTrim = true;\n }\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 protected updateBuffers(renderRange: RenderRange): void {\n if (this.pre != null) {\n this.applyBuffers(this.pre, renderRange);\n }\n }\n\n private applyBuffers(\n pre: HTMLPreElement,\n renderRange: RenderRange | undefined\n ) {\n if (renderRange == null || this.shouldDisableVirtualizationBuffers()) {\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 shouldDisableVirtualizationBuffers(): boolean {\n return this.options.disableVirtualizationBuffers ?? false;\n }\n\n protected applyPreNodeAttributes(\n pre: HTMLPreElement,\n { additionsContentAST, deletionsContentAST, totalLines }: HunksRenderResult,\n customProperties?: CustomPreProperties\n ): void {\n const {\n diffIndicators = 'bars',\n disableBackground = false,\n disableLineNumbers = false,\n overflow = 'scroll',\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 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 this.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.textContent = '';\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\ninterface HasContentProps {\n fileDiff: FileDiffMetadata | undefined;\n oldFile: FileContents | null | undefined;\n newFile: FileContents | null | undefined;\n}\n\nfunction areOptionalFilesEqual(\n fileA: FileContents | null | undefined,\n fileB: FileContents | null | undefined\n): boolean {\n if (fileA == null || fileB == null) {\n return fileA == null && fileB == null;\n }\n return areFilesEqual(fileA, fileB);\n}\n\nfunction hasDiffContent({\n fileDiff,\n oldFile,\n newFile,\n}: HasContentProps): boolean {\n return (\n (fileDiff != null && fileDiff.hunks.length > 0) ||\n oldFile != null ||\n newFile != null\n );\n}\n\nfunction hasDiffHeaderContent({\n fileDiff,\n oldFile,\n newFile,\n}: HasContentProps): boolean {\n return fileDiff != null || oldFile != null || newFile != null;\n}\n\nfunction shouldRenderCode(\n pre: HTMLPreElement | undefined,\n hasContent: boolean,\n collapsed = false\n): boolean {\n return !collapsed && pre == null && hasContent;\n}\n\nfunction shouldRenderHeader(\n headerElement: HTMLElement | undefined,\n hasContent: boolean,\n disableFileHeader = false\n): boolean {\n return headerElement == null && hasContent && !disableFileHeader;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0HA,SAAS,eAAe,UAAqC;CAC3D,OACE,SAAS,cACR,SAAS,SAAS,YACjB,SAAS,SAAS,oBAClB,SAAS,SAAS;AAExB;AA2GA,IAAI,aAAa;AAEjB,IAAa,WAAb,MAEiD;CAiEtC;CACG;CACA;CAhEZ,OAAO,wBAAA;CAEP,OAAwB,aAAa,EAAE;CACvC,OAA8B;CAE9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,qBAA+B;CAC/B;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA,iCAAgE,IAAI,IAAI;CACxE;CACA;CAEA;CACA;CACA;CACA;CAEA,kCACE,IAAI,IAAI;CACV,kBAA+D,CAAC;CAChE,gBAA0B;CAE1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,UAAkB;CAElB,UAAoB;CAEpB;CACA;CAIA,0BAAoC;CACpC;CACA;CAEA,YACE,UAA+C,EAAE,OAAO,eAAe,GACvE,eACA,qBAA+B,OAC/B;EAHO,KAAA,UAAA;EACG,KAAA,gBAAA;EACA,KAAA,qBAAA;EAEV,KAAK,gBAAgB,KAAK,oBAAoB,OAAO;EACrD,KAAK,gBAAgB,IAAI,cAAc;EACvC,KAAK,oBAAoB,IAAI,kBAAkB;EAC/C,KAAK,qBAAqB,IAAI,mBAC5B,QACA,wBACE,SACA,OAAO,QAAQ,mBAAmB,eAC/B,QAAQ,kBAAkB,iBAAiB,eAC5C,QAAQ,mBAAmB,oBACzB,KAAK,mBACL,KAAA,GACJ,KAAK,YACP,CACF;EACA,KAAK,eAAe,wBAAwB,IAAI;EAChD,KAAK,UAAU;CACjB;CAEA,8BAA8C;EAC5C,KAAK,SAAS;CAChB;CAEA,wBACE,SAC0B;EAC1B,OAAO,4BAA4B,OAAO;CAC5C;CAEA,oBACE,SACgC;EAChC,OAAO,IAA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IAAI,QAAQ,QAAQ,KAAK,SAAS,WAChC;CAEF,OAAO,KAAK,YAAY,CAAC;AAC3B"}
1
+ {"version":3,"file":"FileDiff.js","names":[],"sources":["../../src/components/FileDiff.ts"],"sourcesContent":["import type { ElementContent, Element as HASTElement } from 'hast';\nimport { toHtml } from 'hast-util-to-html';\n\nimport {\n CUSTOM_HEADER_SLOT_ID,\n DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n DEFAULT_THEMES,\n DEFAULT_TOKENIZE_MAX_LENGTH,\n DIFFS_TAG_NAME,\n EMPTY_RENDER_RANGE,\n HEADER_FILENAME_SUFFIX_SLOT_ID,\n HEADER_METADATA_SLOT_ID,\n HEADER_PREFIX_SLOT_ID,\n THEME_CSS_ATTRIBUTE,\n UNSAFE_CSS_ATTRIBUTE,\n} from '../constants';\nimport {\n type GetHoveredLineResult,\n type GetLineIndexUtility,\n InteractionManager,\n type InteractionManagerBaseOptions,\n pluckInteractionOptions,\n type SelectionWriteOptions,\n} from '../managers/InteractionManager';\nimport { ResizeManager } from '../managers/ResizeManager';\nimport { ScrollSyncManager } from '../managers/ScrollSyncManager';\nimport {\n dequeueRender,\n queueRender,\n} from '../managers/UniversalRenderingManager';\nimport {\n DiffHunksRenderer,\n type DiffHunksRendererOptions,\n type HunksRenderResult,\n} from '../renderers/DiffHunksRenderer';\nimport { SVGSpriteSheet } from '../sprite';\nimport type {\n AppliedThemeStyleCache,\n BaseCodeOptions,\n BaseDiffOptions,\n CustomPreProperties,\n DiffLineAnnotation,\n DiffsEditableComponent,\n DiffsEditor,\n DiffsTextDocument,\n EditorActiveLineOptions,\n ExpansionDirections,\n FileContents,\n FileDiffMetadata,\n HighlightedToken,\n HunkData,\n HunkSeparators,\n MaybeDiffFileInput,\n PostRenderPhase,\n PrePropertiesConfig,\n RenderHeaderFilenameSuffixCallback,\n RenderHeaderMetadataCallback,\n RenderHeaderPrefixCallback,\n RenderRange,\n SelectedLineRange,\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 { areThemesEqual } from '../utils/areThemesEqual';\nimport { awaitWithTimeout } from '../utils/awaitWithTimeout';\nimport { createAnnotationWrapperNode } from '../utils/createAnnotationWrapperNode';\nimport { createGutterUtilityContentNode } from '../utils/createGutterUtilityContentNode';\nimport { createUnsafeCSSStyleNode } from '../utils/createUnsafeCSSStyleNode';\nimport {\n patchScrollbarGutterSize,\n wrapThemeCSS,\n wrapUnsafeCSS,\n} from '../utils/cssWrappers';\nimport {\n captureExpansionAnchors,\n finishEditSessionForDiff,\n rebuildExpansionFromAnchors,\n} from '../utils/editSessionHunks';\nimport { getDiffFileInput } from '../utils/getDiffFileInput';\nimport { getDiffHunksRendererOptions } from '../utils/getDiffHunksRendererOptions';\nimport { getHunkSideStartBoundary } from '../utils/getHunkSideBoundaries';\nimport { getLineAnnotationName } from '../utils/getLineAnnotationName';\nimport { getOrCreateCodeNode } from '../utils/getOrCreateCodeNode';\nimport { guardWebKitScrollDuringRebuild } from '../utils/guardWebKitScrollDuringRebuild';\nimport { upsertHostThemeStyle } from '../utils/hostTheme';\nimport { hydratePartialDiff } from '../utils/hydratePartialDiff';\nimport { isDefaultRenderRange } from '../utils/isDefaultRenderRange';\nimport { isDiffPlainText } from '../utils/isDiffPlainText';\nimport { isStyleNode } from '../utils/isStyleNode';\nimport { iterateOverDiff } from '../utils/iterateOverDiff';\nimport { parseDiffFromFile } from '../utils/parseDiffFromFile';\nimport { isSafari } from '../utils/platform';\nimport { prerenderHTMLIfNecessary } from '../utils/prerenderHTMLIfNecessary';\nimport { getMeasuredScrollbarGutter } from '../utils/scrollbarGutter';\nimport { setPreNodeProperties } from '../utils/setWrapperNodeProps';\nimport {\n getExpandedRegion,\n getHunkAdditionLineRange,\n getNearestRenderableAdditionLine,\n getTrailingExpandedRegion,\n isAdditionLineRenderable,\n} from '../utils/virtualDiffLayout';\nimport type { WorkerPoolManager } from '../worker';\nimport { DiffsContainerLoaded } from './web-components';\n\ntype LoadedPartialDiffContents = Awaited<\n ReturnType<NonNullable<BaseDiffOptions['loadDiffFiles']>>\n>;\n\ntype DeferredSelectedLinesWrite = [\n range: SelectedLineRange | null,\n options: SelectionWriteOptions | undefined,\n];\n\ntype DeferredEditorActiveLineWrite = [\n lineNumber: number | null,\n options: EditorActiveLineOptions | undefined,\n];\n\nfunction canHydrateDiff(fileDiff: FileDiffMetadata): boolean {\n return (\n fileDiff.isPartial &&\n (fileDiff.type === 'change' ||\n fileDiff.type === 'rename-changed' ||\n fileDiff.type === 'rename-pure')\n );\n}\n\nexport interface FileDiffRenderBaseProps<LAnnotation> {\n fileDiff?: FileDiffMetadata;\n deferManagers?: boolean;\n forceRender?: boolean;\n preventEmit?: boolean;\n fileContainer?: HTMLElement;\n containerWrapper?: HTMLElement;\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[];\n renderRange?: RenderRange;\n}\n\nexport type FileDiffRenderProps<LAnnotation> =\n FileDiffRenderBaseProps<LAnnotation> & MaybeDiffFileInput;\n\nexport type FileDiffHydrationProps<LAnnotation> = Omit<\n FileDiffRenderBaseProps<LAnnotation>,\n 'fileContainer'\n> &\n MaybeDiffFileInput & {\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n };\n\nexport type FileDiffType = 'file-diff' | 'unresolved-file';\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 renderHeaderPrefix?: RenderHeaderPrefixCallback;\n renderHeaderFilenameSuffix?: RenderHeaderFilenameSuffixCallback;\n renderHeaderMetadata?: RenderHeaderMetadataCallback;\n renderCustomHeader?: 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 onPostRender?(\n node: HTMLElement,\n instance: FileDiff<LAnnotation>,\n phase: PostRenderPhase\n ): unknown;\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\ninterface PendingFileLoad {\n fileDiff: FileDiffMetadata;\n promise: Promise<void>;\n}\n\ntype HydrationSetup<LAnnotation> = {\n fileDiff: FileDiffMetadata | undefined;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n} & MaybeDiffFileInput;\n\nlet instanceId = -1;\n\nexport class FileDiff<\n LAnnotation = undefined,\n> implements DiffsEditableComponent<LAnnotation> {\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 readonly type: FileDiffType = 'file-diff';\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 themeCSSStyle: HTMLStyleElement | undefined;\n protected appliedThemeCSS: AppliedThemeStyleCache | undefined;\n protected hasAdoptedThemeCSS = false;\n protected unsafeCSSStyle: HTMLStyleElement | undefined;\n protected appliedUnsafeCSS: string | undefined;\n protected gutterUtilityContent: HTMLElement | undefined;\n\n protected headerElement: HTMLElement | undefined;\n protected headerPrefix: HTMLElement | undefined;\n protected headerFilenameSuffix: HTMLElement | undefined;\n protected headerMetadata: HTMLElement | undefined;\n protected headerCustom: 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 protected managersDirty = false;\n\n protected deletionFile?: FileContents | null;\n protected additionFile?: FileContents | null;\n public fileDiff: FileDiffMetadata | undefined;\n protected renderRange: RenderRange | undefined;\n protected pendingFiles: PendingFileLoad | undefined;\n protected appliedPreAttributes: PrePropertiesConfig | undefined;\n protected lastRenderedHeaderHTML: string | undefined;\n protected cachedHeaderHTML: string | undefined;\n protected lastRowCount: number | undefined;\n private mounted = false;\n\n protected enabled = true;\n\n protected editor: DiffsEditor<LAnnotation> | undefined;\n protected refreshViewTimeout: ReturnType<typeof setTimeout> | undefined;\n // Defer selected-line and editor active-line writes while a refresh rebuilds\n // the diff rows. This is separate from the timeout because the refresh can\n // escalate to a full rerender without one.\n protected lineStateRefreshPending = false;\n protected deferredSelectedLines: DeferredSelectedLinesWrite | undefined;\n protected deferredEditorActiveLine: DeferredEditorActiveLineWrite | undefined;\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 ): DiffHunksRendererOptions {\n return getDiffHunksRendererOptions(options);\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 // use the fileDiff from the hunksRenderer if it exists, it maybe updated\n // by the host\n const fileDiff = this.fileDiffCache;\n if (fileDiff == null) {\n return undefined;\n }\n const lastHunk = fileDiff.hunks.at(-1);\n let targetUnifiedIndex: number | undefined;\n let targetSplitIndex: number | undefined;\n hunkIterator: for (const hunk of fileDiff.hunks) {\n const hunkStart =\n side === 'deletions' ? hunk.deletionStart : hunk.additionStart;\n const hunkCount =\n side === 'deletions' ? hunk.deletionCount : hunk.additionCount;\n let currentLineNumber =\n getHunkSideStartBoundary(hunkStart, hunkCount) + 1;\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.cachedHeaderHTML = undefined;\n this.hunksRenderer.setOptions(this.getHunksRendererOptions(options));\n this.syncInteractionOptions();\n }\n\n protected syncInteractionOptions(): void {\n this.interactionManager.setOptions(\n pluckInteractionOptions(\n this.options,\n typeof this.options.hunkSeparators === 'function' ||\n (this.options.hunkSeparators ?? 'line-info') === 'line-info' ||\n this.options.hunkSeparators === 'line-info-basic'\n ? this.handleExpandHunk\n : undefined,\n this.getLineIndex\n )\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.applyCachedThemeState(themeType);\n }\n\n private applyCachedThemeState(themeType: ThemeTypes): boolean {\n if (\n typeof this.options.theme === 'string' ||\n this.fileContainer == null ||\n this.appliedThemeCSS == null\n ) {\n return false;\n }\n const effectiveThemeType = this.appliedThemeCSS.baseThemeType ?? themeType;\n if (this.appliedThemeCSS.themeType === effectiveThemeType) {\n return false;\n }\n this.applyThemeState(\n this.fileContainer,\n this.appliedThemeCSS.themeStyles,\n themeType,\n this.appliedThemeCSS.baseThemeType\n );\n return true;\n }\n\n private hasThemeChanged(): boolean {\n return (\n this.appliedThemeCSS != null &&\n !areThemesEqual(\n this.appliedThemeCSS.theme,\n this.options.theme ?? DEFAULT_THEMES\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(\n range: SelectedLineRange | null,\n options?: SelectionWriteOptions\n ): void {\n if (this.lineStateRefreshPending) {\n this.deferredSelectedLines = [range, options];\n } else {\n this.interactionManager.setSelection(range, options);\n }\n }\n\n public setEditorActiveLine(\n lineNumber: number | null,\n options?: EditorActiveLineOptions\n ): void {\n if (this.lineStateRefreshPending) {\n this.deferredEditorActiveLine = [lineNumber, options];\n } else {\n this.interactionManager.setEditorActiveLine(lineNumber, {\n lineNumberOnly: options?.lineNumberOnly,\n side: options?.side ?? 'additions',\n });\n }\n }\n\n // A refresh can receive selected-lines and editor active-line writes in either\n // order. Apply the latest value from each after the rows are stable.\n protected flushDeferredLineState(): void {\n const {\n deferredEditorActiveLine: editorActiveLine,\n deferredSelectedLines: selectedLines,\n } = this;\n this.lineStateRefreshPending = false;\n this.deferredEditorActiveLine = undefined;\n this.deferredSelectedLines = undefined;\n\n if (editorActiveLine != null) {\n this.setEditorActiveLine(...editorActiveLine);\n }\n if (selectedLines != null) {\n this.interactionManager.setSelection(...selectedLines);\n }\n }\n\n public flushManagers(): void {\n if (!this.managersDirty || this.pre == null) {\n this.managersDirty = false;\n return;\n }\n\n const { diffStyle = 'split', overflow = 'scroll' } = this.options;\n this.interactionManager.setup(this.pre);\n this.resizeManager.setup(this.pre, {\n disableAnnotations: overflow === 'wrap',\n columnVariables: this.shouldApplyColumnVariables(overflow)\n ? 'apply'\n : 'measure',\n });\n if (overflow === 'scroll' && diffStyle === 'split') {\n this.scrollSyncManager.setup(\n this.pre,\n this.codeDeletions,\n this.codeAdditions\n );\n } else {\n this.scrollSyncManager.cleanUp();\n }\n this.managersDirty = false;\n }\n\n protected shouldApplyColumnVariables(overflow: 'scroll' | 'wrap'): boolean {\n if (typeof this.options.hunkSeparators === 'function') {\n return true;\n }\n return (\n overflow === 'scroll' &&\n (this.lineAnnotations.length > 0 ||\n this.pre?.hasAttribute('data-has-merge-conflict') === true)\n );\n }\n\n public getCodeScrollLeft(): number {\n return Math.max(\n this.codeUnified?.scrollLeft ?? 0,\n this.codeDeletions?.scrollLeft ?? 0,\n this.codeAdditions?.scrollLeft ?? 0\n );\n }\n\n public setCodeScrollLeft(position: number): void {\n if (this.codeUnified != null) {\n this.codeUnified.scrollLeft = position;\n }\n if (this.codeAdditions != null) {\n this.codeAdditions.scrollLeft = position;\n }\n if (this.codeDeletions != null) {\n this.codeDeletions.scrollLeft = position;\n }\n }\n\n public __getEffectiveCodeOptions(): BaseCodeOptions {\n return { ...this.options, ...this.hunksRenderer.getEffectiveCodeOptions() };\n }\n\n public cleanUp(recycle: boolean = false): void {\n dequeueRender(this.handleEditSessionRender);\n this.emitPostRender(true);\n // Persist editor state while the code scrollers still exist.\n this.editor?.cleanUp(recycle);\n this.editor = undefined;\n this.resizeManager.cleanUp();\n this.interactionManager.cleanUp();\n this.scrollSyncManager.cleanUp();\n this.managersDirty = false;\n this.workerManager?.unsubscribeToThemeChanges(this);\n this.renderRange = undefined;\n this.pendingFiles = undefined;\n\n // Clean up the elements\n if (!this.isContainerManaged) {\n this.fileContainer?.remove();\n }\n this.fileContainer = undefined;\n this.mounted = false;\n if (!recycle) {\n this.lineAnnotations = [];\n }\n this.clearAuxiliaryNodes();\n this.annotationCache.clear();\n this.pre = undefined;\n this.codeUnified = undefined;\n this.codeDeletions = undefined;\n this.codeAdditions = undefined;\n this.bufferBefore?.remove();\n this.bufferBefore = undefined;\n this.bufferAfter?.remove();\n this.bufferAfter = undefined;\n this.appliedPreAttributes = undefined;\n this.headerElement = undefined;\n this.headerPrefix = undefined;\n this.headerFilenameSuffix = undefined;\n this.headerMetadata = undefined;\n this.headerCustom = undefined;\n this.placeHolder?.remove();\n this.placeHolder = undefined;\n this.lastRenderedHeaderHTML = undefined;\n if (!recycle) {\n this.cachedHeaderHTML = undefined;\n }\n this.errorWrapper?.remove();\n this.errorWrapper = undefined;\n this.spriteSVG = undefined;\n this.lastRowCount = undefined;\n this.themeCSSStyle = undefined;\n this.appliedThemeCSS = undefined;\n this.hasAdoptedThemeCSS = false;\n this.unsafeCSSStyle = undefined;\n this.appliedUnsafeCSS = 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 if (this.refreshViewTimeout != null) {\n clearTimeout(this.refreshViewTimeout);\n this.refreshViewTimeout = undefined;\n }\n this.lineStateRefreshPending = false;\n this.deferredEditorActiveLine = undefined;\n this.deferredSelectedLines = undefined;\n this.enabled = false;\n }\n\n public virtualizedSetup(): void {\n this.enabled = true;\n this.workerManager?.subscribeToThemeChanges(this);\n }\n\n public hydrate({\n fileContainer,\n prerenderedHTML,\n preventEmit = false,\n lineAnnotations,\n fileDiff,\n ...fileInputProps\n }: FileDiffHydrationProps<LAnnotation>): void {\n if (!this.enabled) {\n throw new Error(\n 'FileDiff.hydrate: attempting to call hydrate after cleaned up'\n );\n }\n if (this.fileContainer != null) {\n throw new Error(\n 'FileDiff.hydrate: hydrate can only be called before the instance has rendered or hydrated'\n );\n }\n const fileInput = getDiffFileInput(fileInputProps, 'FileDiff.hydrate');\n const oldFile = fileInput?.oldFile;\n const newFile = fileInput?.newFile;\n this.hydrateElements(fileContainer, prerenderedHTML);\n if (\n shouldRenderCode(\n this.pre,\n hasDiffContent({ fileDiff, oldFile, newFile }),\n this.options.collapsed\n ) ||\n shouldRenderHeader(\n this.headerElement,\n hasDiffHeaderContent({ fileDiff, oldFile, newFile }),\n this.options.disableFileHeader\n )\n ) {\n this.render({\n ...fileInputProps,\n fileContainer,\n lineAnnotations,\n fileDiff,\n preventEmit: true,\n });\n }\n // Otherwise orchestrate our setup\n else {\n this.hydrationSetup({\n fileDiff,\n lineAnnotations,\n ...fileInput,\n });\n }\n if (!preventEmit) {\n this.emitPostRender();\n }\n }\n\n protected hydrateElements(\n fileContainer: HTMLElement,\n prerenderedHTML: string | undefined\n ): void {\n if (this.fileContainer !== fileContainer) {\n this.emitPostRender(true);\n }\n prerenderHTMLIfNecessary(fileContainer, prerenderedHTML);\n for (const element of fileContainer.shadowRoot?.children ?? []) {\n if (element instanceof SVGElement) {\n this.spriteSVG = element;\n continue;\n }\n if (!(element instanceof HTMLElement)) {\n continue;\n }\n if (element instanceof HTMLPreElement) {\n this.pre = element;\n for (const code of element.children) {\n if (\n !(code instanceof HTMLElement) ||\n code.tagName.toLowerCase() !== 'code'\n ) {\n continue;\n }\n if ('deletions' in code.dataset) {\n this.codeDeletions = code;\n }\n if ('additions' in code.dataset) {\n this.codeAdditions = code;\n }\n if ('unified' in code.dataset) {\n this.codeUnified = code;\n }\n }\n continue;\n }\n if ('diffsHeader' in element.dataset) {\n this.headerElement = element;\n continue;\n }\n if (\n element instanceof HTMLStyleElement &&\n element.hasAttribute(THEME_CSS_ATTRIBUTE)\n ) {\n this.themeCSSStyle = element;\n continue;\n }\n if (\n element instanceof HTMLStyleElement &&\n element.hasAttribute(UNSAFE_CSS_ATTRIBUTE)\n ) {\n this.unsafeCSSStyle = element;\n this.appliedUnsafeCSS = element.textContent;\n continue;\n }\n }\n if (this.pre != null) {\n this.syncCodeNodesFromPre(this.pre);\n this.pre.removeAttribute('data-dehydrated');\n }\n this.fileContainer = fileContainer;\n this.hydrateMeasuredScrollbar();\n }\n\n protected hydrationSetup({\n fileDiff,\n oldFile,\n newFile,\n lineAnnotations,\n }: HydrationSetup<LAnnotation>): void {\n // It's possible we are hydrating a pure-rename and therefore there will be\n // no pre element\n this.lineAnnotations = lineAnnotations ?? this.lineAnnotations;\n this.additionFile = newFile;\n this.deletionFile = oldFile;\n this.fileDiff =\n fileDiff ??\n (oldFile !== undefined && newFile !== undefined\n ? parseDiffFromFile(oldFile, newFile, this.options.parseDiffOptions)\n : undefined);\n\n if (this.pre == null) {\n return;\n }\n\n this.syncInteractionOptions();\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.managersDirty = true;\n this.flushManagers();\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 public onThemeChange(): void {\n this.hunksRenderer.clearRenderCache();\n this.rerender();\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.loadFilesIfNecessary();\n this.rerender();\n };\n\n protected loadFilesIfNecessary(): void {\n const {\n fileDiff,\n options: { loadDiffFiles },\n } = this;\n if (\n fileDiff == null ||\n loadDiffFiles == null ||\n !canHydrateDiff(fileDiff) ||\n this.pendingFiles?.fileDiff === fileDiff\n ) {\n return;\n }\n\n this.pendingFiles = {\n fileDiff,\n promise: this.loadFilesForDiff(fileDiff, loadDiffFiles),\n };\n }\n\n private async loadFilesForDiff(\n fileDiff: FileDiffMetadata,\n loadDiffFiles: NonNullable<BaseDiffOptions['loadDiffFiles']>\n ): Promise<void> {\n try {\n const files = await loadDiffFiles(fileDiff);\n if (!this.enabled || this.fileDiff !== fileDiff) {\n return;\n }\n\n await this.handleFilesLoaded(fileDiff, files);\n } catch (error: unknown) {\n if (this.options.disableErrorHandling === true) {\n throw error;\n }\n console.error(error);\n } finally {\n if (this.pendingFiles?.fileDiff === fileDiff) {\n this.pendingFiles = undefined;\n }\n }\n }\n\n protected async handleFilesLoaded(\n expectedDiff: FileDiffMetadata,\n files: LoadedPartialDiffContents\n ): Promise<void> {\n if (this.fileDiff !== expectedDiff || !expectedDiff.isPartial) {\n return;\n }\n hydratePartialDiff('merge', expectedDiff, files);\n this.setHydratedState(files);\n await awaitWithTimeout(() => this.primeHighlightCache(expectedDiff));\n if (!this.enabled || this.fileDiff !== expectedDiff) {\n return;\n }\n this.rerender();\n }\n\n protected setHydratedState(files: LoadedPartialDiffContents): void {\n this.deletionFile = files.oldFile;\n this.additionFile = files.newFile;\n this.workerManager?.cleanUpTasks(this.hunksRenderer);\n this.hunksRenderer.clearRenderCache();\n }\n\n public render({\n fileDiff,\n deferManagers = false,\n forceRender = false,\n preventEmit = false,\n lineAnnotations,\n fileContainer,\n containerWrapper,\n renderRange,\n ...fileInputProps\n }: FileDiffRenderProps<LAnnotation>): boolean {\n const fileInput = getDiffFileInput(fileInputProps, 'FileDiff.render');\n const oldFile = fileInput?.oldFile;\n const newFile = fileInput?.newFile;\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\n // use the file name as the cache key if it is not set\n if (fileDiff != null && fileDiff.cacheKey === undefined) {\n fileDiff.cacheKey =\n fileDiff.prevName != null\n ? fileDiff.prevName + ':' + fileDiff.name\n : fileDiff.name;\n }\n\n // postpone background tokenizing to next frame for avoiding UI freeze\n // during render\n this.editor?.__postponeBgTokenizeToNextFrame();\n\n const {\n collapsed = false,\n themeType = 'system',\n expandUnchanged = false,\n } = this.options;\n const nextRenderRange = collapsed ? undefined : renderRange;\n const themeChanged = this.hasThemeChanged();\n const hasFileInput = fileInput != null;\n const filesDidChange =\n hasFileInput &&\n (!areOptionalFilesEqual(oldFile, this.deletionFile) ||\n !areOptionalFilesEqual(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 !themeChanged &&\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 this.applyCachedThemeState(themeType);\n }\n\n let nextParsedFileDiff: FileDiffMetadata | undefined;\n if (\n fileDiff == null &&\n hasFileInput &&\n (filesDidChange || this.fileDiff == null)\n ) {\n nextParsedFileDiff = parseDiffFromFile(\n fileInput.oldFile,\n fileInput.newFile,\n this.options.parseDiffOptions\n );\n }\n\n const { renderRange: previousRenderRange } = this;\n this.renderRange = nextRenderRange;\n // Store files only when this render actually carried a file input:\n // internal rerenders pass none, and wiping the pair here would defeat the\n // oldFile/newFile early-return on every later host render. An explicit\n // fileDiff input supersedes a previously parsed pair, so clear it then.\n if (hasFileInput) {\n this.deletionFile = oldFile;\n this.additionFile = newFile;\n } else if (fileDiff != null) {\n this.deletionFile = undefined;\n this.additionFile = undefined;\n }\n\n if (fileDiff != null) {\n this.fileDiff = fileDiff;\n } else if (nextParsedFileDiff != null) {\n diffDidChange = true;\n this.fileDiff = nextParsedFileDiff;\n }\n if (diffDidChange) {\n this.cachedHeaderHTML = undefined;\n }\n\n if (lineAnnotations != null) {\n this.setLineAnnotations(lineAnnotations);\n }\n if (this.fileDiff == null) {\n return false;\n }\n // Backstop for sessions that ended without their exit hook running (e.g.\n // session-shaped metadata reused after a host teardown): restore\n // recompute-shaped hunks before rendering.\n if (\n this.fileDiff.editSessionDirty === true &&\n this.shouldSelfHealEditSession()\n ) {\n finishEditSessionForDiff(this.fileDiff, this.options.parseDiffOptions);\n void this.hunksRenderer.refreshHighlightedResult();\n }\n if (expandUnchanged) {\n this.loadFilesIfNecessary();\n }\n this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options));\n this.syncInteractionOptions();\n\n this.hunksRenderer.setLineAnnotations(this.lineAnnotations);\n\n const { disableErrorHandling = false, disableFileHeader = false } =\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 this.clearHeaderSlots();\n }\n fileContainer = this.getOrCreateFileContainer(\n fileContainer,\n containerWrapper\n );\n this.applyCachedThemeState(themeType);\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 != null) {\n this.applyThemeState(\n fileContainer,\n hunksResult.themeStyles,\n themeType,\n hunksResult.baseThemeType\n );\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 if (!preventEmit) {\n this.emitPostRender();\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 || themeChanged\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 this.applyThemeState(\n fileContainer,\n hunksResult.themeStyles,\n themeType,\n hunksResult.baseThemeType\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 this.applyBuffers(pre, nextRenderRange);\n this.injectUnsafeCSS();\n this.renderAnnotations();\n this.renderGutterUtility();\n\n this.managersDirty = true;\n if (!deferManagers) {\n this.flushManagers();\n }\n\n if (this.editor != null) {\n this.syncRenderViewToEditor();\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 if (!preventEmit) {\n this.emitPostRender();\n }\n return true;\n }\n\n protected emitPostRender(unmount = false): void {\n const {\n fileContainer,\n options: { onPostRender },\n } = this;\n\n if (unmount) {\n if (!this.mounted) {\n return;\n }\n this.mounted = false;\n if (fileContainer == null) {\n return;\n }\n this.options.onPostRender?.(fileContainer, this, 'unmount');\n return;\n }\n\n if (fileContainer == null) {\n return;\n }\n\n const phase: PostRenderPhase = this.mounted ? 'update' : 'mount';\n this.mounted = true;\n onPostRender?.(fileContainer, this, phase);\n }\n\n protected get fileDiffCache(): FileDiffMetadata | undefined {\n return this.hunksRenderer.diffCache ?? this.fileDiff;\n }\n\n private syncRenderViewToEditor(): void {\n const editor = this.editor;\n const fileContainer = this.fileContainer;\n const fileDiff = this.fileDiffCache;\n const lineAnnotations = this.lineAnnotations;\n const renderRange = this.computeEditorRenderRange(this.renderRange);\n if (\n editor != null &&\n fileContainer != null &&\n fileDiff != null &&\n !fileDiff.isPartial\n ) {\n void this.hunksRenderer.initializeHighlighter().then((highlighter) => {\n if (\n !this.enabled ||\n this.editor !== editor ||\n this.fileContainer !== fileContainer ||\n this.fileDiffCache !== fileDiff\n ) {\n return;\n }\n editor.__syncRenderView(\n highlighter,\n fileContainer,\n fileDiff,\n lineAnnotations,\n renderRange\n );\n });\n }\n }\n\n // The stored render range is in rendered-row units for the windowed AST\n // pipeline, but the editor consumes render ranges in document-line units.\n // Derive the addition-side document window covered by the rendered rows:\n // startingLine = first addition line with a row in the window, totalLines =\n // last such line - first + 1, and 0 when the window holds no addition rows\n // (e.g. a pure-deletion run taller than the viewport).\n private computeEditorRenderRange(\n renderRange: RenderRange | undefined\n ): RenderRange | undefined {\n const fileDiff = this.fileDiffCache;\n if (\n renderRange == null ||\n fileDiff == null ||\n isDefaultRenderRange(renderRange)\n ) {\n return renderRange;\n }\n const {\n diffStyle = 'split',\n expandUnchanged = false,\n collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n } = this.options;\n let firstLineNumber: number | undefined;\n let lastLineNumber: number | undefined;\n iterateOverDiff({\n diff: fileDiff,\n diffStyle,\n startingLine: renderRange.startingLine,\n totalLines: renderRange.totalLines,\n expandedHunks: expandUnchanged\n ? true\n : this.hunksRenderer.getExpandedHunksMap(),\n collapsedContextThreshold,\n callback: ({ additionLine }) => {\n if (additionLine != null) {\n firstLineNumber ??= additionLine.lineNumber;\n lastLineNumber = additionLine.lineNumber;\n }\n },\n });\n if (firstLineNumber == null || lastLineNumber == null) {\n return { ...renderRange, startingLine: 0, totalLines: 0 };\n }\n return {\n ...renderRange,\n startingLine: firstLineNumber - 1,\n totalLines: lastLineNumber - firstLineNumber + 1,\n };\n }\n\n public attachEditor(\n editor: DiffsEditor<LAnnotation>\n ): (recycle?: boolean) => void {\n // Editing is a plain file-diff concern only. Subclasses with their own\n // hunk semantics (UnresolvedFile) are not editable, so an editor must\n // never attach to them.\n if (this.type !== 'file-diff') {\n throw new Error(\n `FileDiff.attachEditor: cannot attach an editor to a \"${this.type}\" diff`\n );\n }\n this.editor?.cleanUp();\n this.editor = editor;\n this.hunksRenderer.beginEditSession();\n // The editor sync below refuses partial diffs (it needs the full file\n // contents); kick off hydration so the loaded re-render re-runs it.\n if (this.fileDiff?.isPartial === true) {\n this.loadFilesIfNecessary();\n }\n if (this.hunksRenderer.editorRenderReady()) {\n this.syncRenderViewToEditor();\n } else {\n // The current markup is missing the editor's token metadata, or its\n // highlight is still pending: render through the session, which also\n // syncs the render view once it paints.\n this.rerender();\n }\n return (recycle?: boolean) => {\n this.editor = undefined;\n // A recycle detach is a virtualized unmount mid-session: the session\n // continues on remount, so hunks stay session-shaped. Only a genuine\n // end runs the exit recompute.\n if (recycle !== true) {\n this.finishEditSession();\n }\n };\n }\n\n // Genuine session exit for the live detach path.\n private finishEditSession(): void {\n this.hunksRenderer.endEditSession();\n this.completeEditSession();\n }\n\n /**\n * Run the genuine session-end recompute: restore recompute-shaped hunks (a\n * context-only region collapses away, boundaries re-derive), preserve\n * expansion state best-effort via old-side anchors, and repaint through\n * the session render path — which also invalidates virtualized layout,\n * since nothing else does at exit now that editing does not flip\n * expandUnchanged. Marker-guarded and idempotent; CodeView also calls this\n * when reaping a session whose detach closure was consumed by a recycle.\n * Safe on a cleaned-up instance: the recompute is pure metadata work and\n * the deferred rerender is enabled-guarded. Returns true when a recompute\n * ran.\n */\n public completeEditSession(): boolean {\n const fileDiff = this.fileDiffCache;\n if (fileDiff == null || fileDiff.editSessionDirty !== true) {\n return false;\n }\n const { collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD } =\n this.options;\n const anchors = captureExpansionAnchors(\n fileDiff,\n this.hunksRenderer.getExpandedHunksMap(),\n collapsedContextThreshold\n );\n finishEditSessionForDiff(fileDiff, this.options.parseDiffOptions);\n this.hunksRenderer.setExpandedHunksMap(\n rebuildExpansionFromAnchors(fileDiff, anchors)\n );\n void this.hunksRenderer.refreshHighlightedResult();\n this.escalateEditSessionRender();\n return true;\n }\n\n // normally triggered by the host when the document line count changes\n public applyDocumentChange(\n textDocument: DiffsTextDocument,\n newLineAnnotations?: DiffLineAnnotation<LAnnotation>[]\n ): void {\n this.hunksRenderer.applyDocumentChange(textDocument);\n const fileDiff = this.hunksRenderer.diffCache;\n if (fileDiff != null) {\n const cacheKey = this.fileDiff?.cacheKey;\n if (cacheKey != null && fileDiff.cacheKey == null) {\n fileDiff.cacheKey = cacheKey;\n }\n this.fileDiff = fileDiff;\n }\n if (\n newLineAnnotations !== undefined &&\n newLineAnnotations !== this.lineAnnotations\n ) {\n this.setLineAnnotations(newLineAnnotations);\n this.hunksRenderer.setLineAnnotations(this.lineAnnotations);\n this.renderAnnotations();\n }\n this.rerender();\n this.interactionManager.setSelectionDirty();\n }\n\n public updateRenderCache(\n dirtyLines: Map<number, Array<HighlightedToken>>,\n themeType: 'dark' | 'light',\n options: {\n shouldRefreshDiffsView?: boolean;\n lineCountChangeInFlight?: boolean;\n } = {}\n ): void {\n const { shouldRefreshDiffsView, lineCountChangeInFlight } = options;\n const regionsChanged = this.hunksRenderer.updateRenderCache(\n dirtyLines,\n themeType,\n lineCountChangeInFlight\n );\n // A same-line-count edit that reshaped the session regions (an edit into\n // a collapsed gap) changes the rendered row set, which the debounced\n // line-type refresh below cannot express. Escalate to a deferred full\n // re-render — never a synchronous one, since this runs mid-editor-pass\n // and rebuilding rows the editor is about to touch detaches its geometry\n // caches.\n if (regionsChanged) {\n if (this.refreshViewTimeout != null) {\n clearTimeout(this.refreshViewTimeout);\n this.refreshViewTimeout = undefined;\n }\n this.lineStateRefreshPending = true;\n this.escalateEditSessionRender();\n return;\n }\n if (shouldRefreshDiffsView === true) {\n if (this.refreshViewTimeout != null) {\n clearTimeout(this.refreshViewTimeout);\n }\n this.lineStateRefreshPending = true;\n this.refreshViewTimeout = setTimeout(() => {\n this.refreshViewTimeout = undefined;\n if (this.options.diffStyle === 'split') {\n this.refreshSplitDiffView();\n } else {\n this.refreshUnifiedDiffView();\n }\n this.flushDeferredLineState();\n }, 150);\n }\n }\n\n // Editor-facing visibility oracle: whether a one-based new-file line has\n // (or will have on scroll) a rendered row under the current expansion\n // state. See isAdditionLineRenderable.\n public isLineRenderable(lineNumber: number): boolean {\n const fileDiff = this.fileDiffCache;\n if (fileDiff == null) {\n return true;\n }\n const {\n expandUnchanged = false,\n collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n } = this.options;\n return isAdditionLineRenderable({\n fileDiff,\n lineNumber,\n expandedHunks: expandUnchanged\n ? true\n : this.hunksRenderer.getExpandedHunksMap(),\n collapsedContextThreshold,\n });\n }\n\n // Fold-skip companion to isLineRenderable: the nearest renderable one-based\n // new-file line at or beyond lineNumber in the given direction.\n public getNearestRenderableLine(\n lineNumber: number,\n direction: 'up' | 'down'\n ): number | undefined {\n const fileDiff = this.fileDiffCache;\n if (fileDiff == null) {\n return lineNumber;\n }\n const {\n expandUnchanged = false,\n collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n } = this.options;\n return getNearestRenderableAdditionLine({\n fileDiff,\n lineNumber,\n direction,\n expandedHunks: expandUnchanged\n ? true\n : this.hunksRenderer.getExpandedHunksMap(),\n collapsedContextThreshold,\n });\n }\n\n // Expand collapsed context so a one-based new-file line can render: one\n // deterministic expansion from the nearest gap edge, sized to reach the\n // target plus the normal expansion step (clamped to the gap at render).\n // Routed through expandHunk so subclass expansion flows (CodeView's\n // deferred pendingExpansions) apply.\n public revealLine(lineNumber: number): boolean {\n const fileDiff = this.fileDiffCache;\n const {\n expandUnchanged = false,\n collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n expansionLineCount = 100,\n } = this.options;\n if (fileDiff == null || fileDiff.isPartial || expandUnchanged) {\n return false;\n }\n const expandedHunks = this.hunksRenderer.getExpandedHunksMap();\n\n for (const [hunkIndex, hunk] of fileDiff.hunks.entries()) {\n const [hunkStart, hunkEnd] = getHunkAdditionLineRange(hunk);\n if (lineNumber < hunkStart) {\n const region = getExpandedRegion({\n isPartial: fileDiff.isPartial,\n rangeSize: hunk.collapsedBefore,\n expandedHunks,\n hunkIndex,\n collapsedContextThreshold,\n });\n const gapStart = hunkStart - region.rangeSize;\n if (\n region.renderAll ||\n lineNumber < gapStart + region.fromStart ||\n lineNumber >= hunkStart - region.fromEnd\n ) {\n return false;\n }\n const fromStartDistance =\n lineNumber - (gapStart + region.fromStart) + 1;\n const fromEndDistance = hunkStart - region.fromEnd - lineNumber;\n if (fromStartDistance <= fromEndDistance) {\n this.expandHunk(\n hunkIndex,\n 'up',\n fromStartDistance + expansionLineCount\n );\n } else {\n this.expandHunk(\n hunkIndex,\n 'down',\n fromEndDistance + expansionLineCount\n );\n }\n return true;\n }\n if (lineNumber < hunkEnd) {\n return false;\n }\n }\n\n const trailingRegion = getTrailingExpandedRegion({\n fileDiff,\n hunkIndex: fileDiff.hunks.length - 1,\n expandedHunks,\n collapsedContextThreshold,\n errorPrefix: 'FileDiff.revealLine',\n });\n if (trailingRegion == null || trailingRegion.renderAll) {\n return false;\n }\n const lastHunk = fileDiff.hunks[fileDiff.hunks.length - 1];\n const [, trailingStart] = getHunkAdditionLineRange(lastHunk);\n if (\n lineNumber < trailingStart + trailingRegion.fromStart ||\n lineNumber >= trailingStart + trailingRegion.rangeSize\n ) {\n return false;\n }\n this.expandHunk(\n fileDiff.hunks.length,\n 'up',\n lineNumber -\n (trailingStart + trailingRegion.fromStart) +\n 1 +\n expansionLineCount\n );\n return true;\n }\n\n // Whether render() may run the session-exit recompute on dirty metadata.\n // False while an editor is attached (the session is live). CodeView-managed\n // instances override this: their sessions survive recycling with no editor\n // attached, and CodeView runs the exit recompute itself when it reaps a\n // session.\n protected shouldSelfHealEditSession(): boolean {\n return this.editor == null;\n }\n\n // Deferred full re-render for session region changes. The subsequent\n // render() ends in syncRenderViewToEditor, which resets the editor's\n // geometry caches against the rebuilt rows. VirtualizedFileDiff overrides\n // this to also invalidate its layout caches.\n protected escalateEditSessionRender(): void {\n queueRender(this.handleEditSessionRender);\n }\n\n private handleEditSessionRender = (): void => {\n this.rerender();\n this.flushDeferredLineState();\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.emitPostRender(true);\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 public async primeHighlightCache(\n fileDiff: FileDiffMetadata | undefined = this.fileDiff\n ): Promise<void> {\n const { workerManager } = this;\n if (\n fileDiff == null ||\n workerManager == null ||\n !workerManager.isWorkingPool() ||\n fileDiff.cacheKey == null ||\n isDiffPlainText(fileDiff)\n ) {\n return;\n }\n const tokenizeMaxLength =\n this.options.tokenizeMaxLength ?? DEFAULT_TOKENIZE_MAX_LENGTH;\n if (\n Math.max(fileDiff.additionLines.length, fileDiff.deletionLines.length) >\n tokenizeMaxLength\n ) {\n return;\n }\n\n await workerManager\n .primeDiffHighlightCache(fileDiff)\n .catch((error: unknown) => {\n console.error(error);\n });\n }\n\n private cleanChildNodes() {\n this.resizeManager.cleanUp();\n this.scrollSyncManager.cleanUp();\n this.interactionManager.cleanUp();\n this.clearAuxiliaryNodes();\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.headerPrefix?.remove();\n this.headerFilenameSuffix?.remove();\n this.headerMetadata?.remove();\n this.headerCustom?.remove();\n this.pre?.remove();\n this.spriteSVG?.remove();\n this.themeCSSStyle?.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.headerPrefix = undefined;\n this.headerFilenameSuffix = undefined;\n this.headerMetadata = undefined;\n this.headerCustom = undefined;\n this.pre = undefined;\n this.spriteSVG = undefined;\n this.themeCSSStyle = undefined;\n this.appliedThemeCSS = undefined;\n this.hasAdoptedThemeCSS = false;\n this.unsafeCSSStyle = undefined;\n this.appliedUnsafeCSS = undefined;\n\n this.lastRenderedHeaderHTML = undefined;\n this.lastRowCount = undefined;\n this.mounted = false;\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 protected 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 protected renderGutterUtility(): void {\n const { renderGutterUtility } = this.options;\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 { fileContainer: previousContainer } = this;\n const nextContainer =\n fileContainer ??\n previousContainer ??\n document.createElement(DIFFS_TAG_NAME);\n const containerChanged = previousContainer !== nextContainer;\n if (previousContainer != null && containerChanged) {\n this.editor?.__captureFocusForDOMReplacement();\n }\n if (containerChanged) {\n this.emitPostRender(true);\n }\n this.fileContainer = nextContainer;\n if (previousContainer != null && containerChanged) {\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 (containerChanged) {\n this.adoptReusableShellElements(this.fileContainer);\n }\n this.ensureSpriteSVG(this.fileContainer);\n return this.fileContainer;\n }\n\n // NOTE(amadeus): Technically this method is not safe for use outside of\n // the CodeView component, however I don't think in practice it really\n // should matter, but maybe there's some system we need in place to prevent\n // this from running outside of that environment?\n //\n // It's making very specific assumptions that all the elements will have the\n // correct content based on CodeView global options\n private adoptReusableShellElements(fileContainer: HTMLElement): void {\n const { shadowRoot } = fileContainer;\n if (shadowRoot == null) {\n return;\n }\n\n for (const element of shadowRoot.children) {\n if (element instanceof SVGElement) {\n this.spriteSVG ??= element;\n } else if (\n isStyleNode(element) &&\n element.hasAttribute(THEME_CSS_ATTRIBUTE)\n ) {\n this.themeCSSStyle ??= element;\n this.hasAdoptedThemeCSS = true;\n } else if (\n isStyleNode(element) &&\n element.hasAttribute(UNSAFE_CSS_ATTRIBUTE)\n ) {\n this.unsafeCSSStyle ??= element;\n this.appliedUnsafeCSS ??= this.options.unsafeCSS ?? undefined;\n }\n }\n }\n\n private ensureSpriteSVG(fileContainer: HTMLElement): void {\n const shadowRoot =\n fileContainer.shadowRoot ?? fileContainer.attachShadow({ mode: 'open' });\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 }\n }\n if (this.spriteSVG != null && this.spriteSVG.parentNode !== shadowRoot) {\n shadowRoot.appendChild(this.spriteSVG);\n }\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 this.editor?.__captureFocusForDOMReplacement();\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 protected 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 (child.hasAttribute('data-unified')) {\n this.codeUnified = child;\n } else if (child.hasAttribute('data-deletions')) {\n this.codeDeletions = child;\n } else if (child.hasAttribute('data-additions')) {\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 { fileDiff } = this;\n const headerHTML = this.cachedHeaderHTML ?? toHtml(headerAST);\n this.cachedHeaderHTML = headerHTML;\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 || fileDiff == null) {\n return;\n }\n\n const {\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderFilenameSuffix,\n renderHeaderMetadata,\n } = this.options;\n\n if (renderCustomHeader != null) {\n const content = renderCustomHeader(fileDiff) ?? undefined;\n this.headerCustom = this.upsertHeaderSlotElement(\n container,\n this.headerCustom,\n CUSTOM_HEADER_SLOT_ID,\n content\n );\n this.headerPrefix?.remove();\n this.headerFilenameSuffix?.remove();\n this.headerMetadata?.remove();\n this.headerPrefix = undefined;\n this.headerFilenameSuffix = undefined;\n this.headerMetadata = undefined;\n return;\n }\n\n const prefix = renderHeaderPrefix?.(fileDiff) ?? undefined;\n const suffix = renderHeaderFilenameSuffix?.(fileDiff) ?? undefined;\n const content = renderHeaderMetadata?.(fileDiff) ?? undefined;\n this.headerPrefix = this.upsertHeaderSlotElement(\n container,\n this.headerPrefix,\n HEADER_PREFIX_SLOT_ID,\n prefix\n );\n this.headerFilenameSuffix = this.upsertHeaderSlotElement(\n container,\n this.headerFilenameSuffix,\n HEADER_FILENAME_SUFFIX_SLOT_ID,\n suffix\n );\n this.headerMetadata = this.upsertHeaderSlotElement(\n container,\n this.headerMetadata,\n HEADER_METADATA_SLOT_ID,\n content\n );\n this.headerCustom?.remove();\n this.headerCustom = undefined;\n }\n\n private clearHeaderSlots(): void {\n this.headerPrefix?.remove();\n this.headerFilenameSuffix?.remove();\n this.headerMetadata?.remove();\n this.headerCustom?.remove();\n this.headerPrefix = undefined;\n this.headerFilenameSuffix = undefined;\n this.headerMetadata = undefined;\n this.headerCustom = undefined;\n }\n\n // Header slot callbacks are presence-based render hooks, not reactive views.\n private upsertHeaderSlotElement(\n container: HTMLElement,\n current: HTMLElement | undefined,\n slot: string,\n content: Element | string | number | undefined\n ): HTMLElement | undefined {\n if (content == null) {\n current?.remove();\n return undefined;\n }\n const element = current ?? this.createHeaderSlotElement(slot);\n if (current == null) {\n container.appendChild(element);\n }\n this.replaceHeaderSlotContent(element, content);\n return element;\n }\n\n private replaceHeaderSlotContent(\n element: HTMLElement,\n content: Element | string | number\n ): void {\n element.replaceChildren();\n if (content instanceof Element) {\n element.appendChild(content);\n } else {\n element.innerText = `${content}`;\n }\n }\n\n private createHeaderSlotElement(slot: string): HTMLElement {\n const element = document.createElement('div');\n element.slot = slot;\n return element;\n }\n\n protected injectUnsafeCSS(): void {\n const { unsafeCSS } = this.options;\n const shadowRoot = this.fileContainer?.shadowRoot;\n if (shadowRoot == null) {\n return;\n }\n\n if (unsafeCSS == null || unsafeCSS === '') {\n if (this.unsafeCSSStyle != null) {\n this.unsafeCSSStyle.remove();\n this.unsafeCSSStyle = undefined;\n }\n this.appliedUnsafeCSS = undefined;\n return;\n }\n\n if (\n this.unsafeCSSStyle?.parentNode === shadowRoot &&\n this.appliedUnsafeCSS === unsafeCSS\n ) {\n return;\n }\n\n // Create or update the style element\n this.unsafeCSSStyle ??= createUnsafeCSSStyleNode();\n if (this.unsafeCSSStyle.parentNode !== shadowRoot) {\n shadowRoot.appendChild(this.unsafeCSSStyle);\n }\n // Wrap in @layer unsafe to match SSR behavior\n this.unsafeCSSStyle.textContent = wrapUnsafeCSS(unsafeCSS);\n this.appliedUnsafeCSS = unsafeCSS;\n }\n\n private applyThemeState(\n container: HTMLElement,\n themeStyles: string,\n themeType: ThemeTypes,\n baseThemeType?: 'light' | 'dark'\n ): void {\n const shadowRoot =\n container.shadowRoot ?? container.attachShadow({ mode: 'open' });\n const effectiveThemeType = baseThemeType ?? themeType;\n const currentTheme = this.options.theme ?? DEFAULT_THEMES;\n const theme =\n typeof currentTheme === 'string' ? currentTheme : { ...currentTheme };\n const scrollbarGutter = getMeasuredScrollbarGutter(shadowRoot);\n if (\n this.themeCSSStyle?.parentNode === shadowRoot &&\n this.appliedThemeCSS?.themeStyles === themeStyles &&\n this.appliedThemeCSS.themeType === effectiveThemeType &&\n this.appliedThemeCSS.scrollbarGutter === scrollbarGutter\n ) {\n this.appliedThemeCSS.theme = theme;\n return;\n }\n if (\n this.hasAdoptedThemeCSS &&\n this.themeCSSStyle?.parentNode === shadowRoot\n ) {\n this.hasAdoptedThemeCSS = false;\n this.appliedThemeCSS = {\n theme,\n themeStyles,\n themeType: effectiveThemeType,\n baseThemeType,\n scrollbarGutter,\n };\n return;\n }\n this.themeCSSStyle = upsertHostThemeStyle({\n shadowRoot,\n currentNode: this.themeCSSStyle,\n themeCSS: wrapThemeCSS(themeStyles, effectiveThemeType, scrollbarGutter),\n });\n this.appliedThemeCSS =\n this.themeCSSStyle != null\n ? {\n theme,\n themeStyles,\n themeType: effectiveThemeType,\n baseThemeType,\n scrollbarGutter,\n }\n : undefined;\n }\n\n private hydrateMeasuredScrollbar(): void {\n const shadowRoot = this.fileContainer?.shadowRoot;\n if (shadowRoot == null || this.themeCSSStyle == null) {\n return;\n }\n this.themeCSSStyle.textContent = patchScrollbarGutterSize(\n this.themeCSSStyle.textContent ?? '',\n getMeasuredScrollbarGutter(shadowRoot)\n );\n }\n\n // A boolean check to ensure that edit mode in WebKit doesn't cause potential\n // scroll jumps to due bugs with WebKit. The workarounds have performance\n // implications so we avoid running the workarounds on browsers or scenarios\n // where they are not applicable\n protected shouldGuardRebuildScroll(): boolean {\n return this.editor != null && isSafari();\n }\n\n private applyHunksToDOM(\n pre: HTMLPreElement,\n result: HunksRenderResult\n ): void {\n if (this.shouldGuardRebuildScroll()) {\n guardWebKitScrollDuringRebuild(pre, () =>\n this.replaceCodeColumns(pre, result)\n );\n } else {\n this.replaceCodeColumns(pre, result);\n }\n }\n\n // Renders a code column's AST into an existing elements without replacing\n // the gutter and content parents. Identity matters in edit mode: the content\n // element is the focused contenteditable, and replacing it ends the\n // browser's editing session — focus tears down and restores, and iOS\n // answers every session restart with an animated caret reveal.\n //\n // Returns false when the element has no column pair yet (initial render,\n // or a diff-style switch built a fresh element); the caller then assigns\n // the full innerHTML.\n private applyCodeColumnsInPlace(\n code: HTMLElement,\n ast: ElementContent[],\n rowCount: number\n ): boolean {\n const columns = this.getColumnPair(code);\n if (columns == null) {\n return false;\n }\n const gutterChildren = getElementChildren(ast[0]);\n const contentChildren = getElementChildren(ast[1]);\n if (gutterChildren == null || contentChildren == null) {\n return false;\n }\n columns.gutter.innerHTML = toHtml(gutterChildren);\n columns.content.innerHTML = toHtml(contentChildren);\n if (rowCount !== this.lastRowCount) {\n columns.gutter.style.setProperty('grid-row', `span ${rowCount}`);\n columns.content.style.setProperty('grid-row', `span ${rowCount}`);\n }\n return true;\n }\n\n private replaceCodeColumns(\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 this.editor?.__captureFocusForDOMReplacement();\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 if (\n !this.applyCodeColumnsInPlace(\n this.codeUnified,\n unifiedAST,\n result.rowCount\n )\n ) {\n this.codeUnified.innerHTML =\n this.hunksRenderer.renderPartialHTML(unifiedAST);\n }\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 if (\n !this.applyCodeColumnsInPlace(\n this.codeDeletions,\n deletionsAST,\n result.rowCount\n )\n ) {\n this.codeDeletions.innerHTML =\n this.hunksRenderer.renderPartialHTML(deletionsAST);\n }\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 if (\n !this.applyCodeColumnsInPlace(\n this.codeAdditions,\n additionsAST,\n result.rowCount\n )\n ) {\n this.codeAdditions.innerHTML =\n this.hunksRenderer.renderPartialHTML(additionsAST);\n }\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('FileDiff.applyPartialRender: failed to trim to overlap');\n }\n\n if (this.lastRowCount < trimResult) {\n throw new Error(\n 'FileDiff.applyPartialRender: trimmed beyond DOM row count'\n );\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 // fast refresh diff view via updating the `data-line-type` after an edit.\n // only for split view.\n private refreshSplitDiffView(): void {\n if (this.options.diffStyle !== 'split') {\n return;\n }\n\n const hunksResult = this.hunksRenderer.renderDiff(\n this.fileDiff,\n this.renderRange\n );\n if (hunksResult == null) {\n return;\n }\n\n const columns = this.getCodeColumns(\n 'split',\n this.codeUnified,\n this.codeDeletions,\n this.codeAdditions\n );\n if (!Array.isArray(columns)) {\n return;\n }\n\n const applyLineType = (\n type: 'deletions' | 'additions',\n column: ColumnElements | undefined\n ) => {\n if (column == null) {\n return;\n }\n const ast = this.hunksRenderer.renderCodeAST(type, hunksResult);\n const gutterChildren = getElementChildren(ast?.[0]);\n const contentChildren = getElementChildren(ast?.[1]);\n for (const [el, astChildren] of [\n [column.gutter, gutterChildren],\n [column.content, contentChildren],\n ] as const) {\n if (\n astChildren != null &&\n el.childElementCount === astChildren.length\n ) {\n for (let i = 0; i < astChildren.length; i++) {\n const gutterElement = el.children[i] as HTMLElement;\n const gutterChild = astChildren[i] as HASTElement;\n const lineType = gutterChild.properties['data-line-type'] as\n | string\n | undefined;\n if (\n lineType != null &&\n gutterElement.dataset.lineType !== lineType\n ) {\n gutterElement.dataset.lineType = lineType;\n }\n }\n }\n }\n };\n\n applyLineType('deletions', columns[0]);\n applyLineType('additions', columns[1]);\n }\n\n // full diff view re-rendering\n // only for unified view.\n private refreshUnifiedDiffView(): void {\n if (this.options.diffStyle !== 'unified') {\n return;\n }\n\n const hunksResult = this.hunksRenderer.renderDiff(\n this.fileDiff,\n this.renderRange\n );\n if (hunksResult == null) {\n return;\n }\n\n const columns = this.getCodeColumns(\n 'unified',\n this.codeUnified,\n this.codeDeletions,\n this.codeAdditions\n );\n if (columns == null || Array.isArray(columns)) {\n return;\n }\n\n const ast = this.hunksRenderer.renderCodeAST('unified', hunksResult);\n const gutterChildren = getElementChildren(ast?.[0]);\n const contentChildren = getElementChildren(ast?.[1]);\n const applyColumns = () => {\n for (const [el, astChildren] of [\n [columns.gutter, gutterChildren],\n [columns.content, contentChildren],\n ] as const) {\n if (astChildren != null) {\n el.innerHTML = toHtml(astChildren);\n }\n }\n\n if (hunksResult.rowCount !== this.lastRowCount) {\n this.applyRowSpan('unified', columns, hunksResult.rowCount);\n this.lastRowCount = hunksResult.rowCount;\n }\n };\n if (this.shouldGuardRebuildScroll()) {\n guardWebKitScrollDuringRebuild(this.pre, applyColumns);\n } else {\n applyColumns();\n }\n this.renderSeparators(hunksResult.hunkData);\n\n this.managersDirty = true;\n this.flushManagers();\n\n // sync the render view to the editor\n this.syncRenderViewToEditor();\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 if (preTrimCount === 0 && newSize === 0) {\n pendingMetadataTrim = true;\n }\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 getColumnPair(\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 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 if (diffStyle === 'unified') {\n return this.getColumnPair(codeUnified);\n } else {\n const deletions = this.getColumnPair(codeDeletions);\n const additions = this.getColumnPair(codeAdditions);\n return deletions != null || additions != null\n ? [deletions, additions]\n : undefined;\n }\n }\n\n protected updateBuffers(renderRange: RenderRange): void {\n if (this.pre != null) {\n this.applyBuffers(this.pre, renderRange);\n }\n }\n\n private applyBuffers(\n pre: HTMLPreElement,\n renderRange: RenderRange | undefined\n ) {\n if (renderRange == null || this.shouldDisableVirtualizationBuffers()) {\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 shouldDisableVirtualizationBuffers(): boolean {\n return this.options.disableVirtualizationBuffers ?? false;\n }\n\n protected applyPreNodeAttributes(\n pre: HTMLPreElement,\n { additionsContentAST, deletionsContentAST, totalLines }: HunksRenderResult,\n customProperties?: CustomPreProperties\n ): void {\n const {\n diffIndicators = 'bars',\n disableBackground = false,\n disableLineNumbers = false,\n overflow = 'scroll',\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 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 this.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.textContent = '';\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\ninterface HasContentProps {\n fileDiff: FileDiffMetadata | undefined;\n oldFile: FileContents | null | undefined;\n newFile: FileContents | null | undefined;\n}\n\nfunction areOptionalFilesEqual(\n fileA: FileContents | null | undefined,\n fileB: FileContents | null | undefined\n): boolean {\n if (fileA == null || fileB == null) {\n return fileA == null && fileB == null;\n }\n return areFilesEqual(fileA, fileB);\n}\n\nfunction hasDiffContent({\n fileDiff,\n oldFile,\n newFile,\n}: HasContentProps): boolean {\n return (\n (fileDiff != null && fileDiff.hunks.length > 0) ||\n oldFile != null ||\n newFile != null\n );\n}\n\nfunction hasDiffHeaderContent({\n fileDiff,\n oldFile,\n newFile,\n}: HasContentProps): boolean {\n return fileDiff != null || oldFile != null || newFile != null;\n}\n\nfunction shouldRenderCode(\n pre: HTMLPreElement | undefined,\n hasContent: boolean,\n collapsed = false\n): boolean {\n return !collapsed && pre == null && hasContent;\n}\n\nfunction shouldRenderHeader(\n headerElement: HTMLElement | undefined,\n hasContent: boolean,\n disableFileHeader = false\n): boolean {\n return headerElement == null && hasContent && !disableFileHeader;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4HA,SAAS,eAAe,UAAqC;CAC3D,OACE,SAAS,cACR,SAAS,SAAS,YACjB,SAAS,SAAS,oBAClB,SAAS,SAAS;AAExB;AA2GA,IAAI,aAAa;AAEjB,IAAa,WAAb,MAEiD;CAiEtC;CACG;CACA;CAhEZ,OAAO,wBAAA;CAEP,OAAwB,aAAa,EAAE;CACvC,OAA8B;CAE9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,qBAA+B;CAC/B;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA,iCAAgE,IAAI,IAAI;CACxE;CACA;CAEA;CACA;CACA;CACA;CAEA,kCACE,IAAI,IAAI;CACV,kBAA+D,CAAC;CAChE,gBAA0B;CAE1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,UAAkB;CAElB,UAAoB;CAEpB;CACA;CAIA,0BAAoC;CACpC;CACA;CAEA,YACE,UAA+C,EAAE,OAAO,eAAe,GACvE,eACA,qBAA+B,OAC/B;EAHO,KAAA,UAAA;EACG,KAAA,gBAAA;EACA,KAAA,qBAAA;EAEV,KAAK,gBAAgB,KAAK,oBAAoB,OAAO;EACrD,KAAK,gBAAgB,IAAI,cAAc;EACvC,KAAK,oBAAoB,IAAI,kBAAkB;EAC/C,KAAK,qBAAqB,IAAI,mBAC5B,QACA,wBACE,SACA,OAAO,QAAQ,mBAAmB,eAC/B,QAAQ,kBAAkB,iBAAiB,eAC5C,QAAQ,mBAAmB,oBACzB,KAAK,mBACL,KAAA,GACJ,KAAK,YACP,CACF;EACA,KAAK,eAAe,wBAAwB,IAAI;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