@pierre/diffs 1.1.0-beta.17 → 1.1.0-beta.19

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 (65) hide show
  1. package/dist/components/File.d.ts +3 -5
  2. package/dist/components/File.d.ts.map +1 -1
  3. package/dist/components/File.js +12 -21
  4. package/dist/components/File.js.map +1 -1
  5. package/dist/components/FileDiff.d.ts +5 -6
  6. package/dist/components/FileDiff.d.ts.map +1 -1
  7. package/dist/components/FileDiff.js +21 -22
  8. package/dist/components/FileDiff.js.map +1 -1
  9. package/dist/components/VirtualizedFileDiff.d.ts +1 -0
  10. package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
  11. package/dist/components/VirtualizedFileDiff.js +6 -0
  12. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  13. package/dist/index.d.ts +3 -4
  14. package/dist/index.js +2 -3
  15. package/dist/managers/InteractionManager.d.ts +140 -0
  16. package/dist/managers/InteractionManager.d.ts.map +1 -0
  17. package/dist/managers/InteractionManager.js +789 -0
  18. package/dist/managers/InteractionManager.js.map +1 -0
  19. package/dist/managers/ResizeManager.d.ts +0 -2
  20. package/dist/managers/ResizeManager.d.ts.map +1 -1
  21. package/dist/managers/ResizeManager.js +43 -32
  22. package/dist/managers/ResizeManager.js.map +1 -1
  23. package/dist/react/index.d.ts +2 -2
  24. package/dist/react/jsx.d.ts.map +1 -1
  25. package/dist/react/types.d.ts +1 -2
  26. package/dist/react/types.d.ts.map +1 -1
  27. package/dist/react/utils/renderDiffChildren.d.ts +1 -1
  28. package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
  29. package/dist/react/utils/renderDiffChildren.js.map +1 -1
  30. package/dist/react/utils/renderFileChildren.d.ts +1 -1
  31. package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
  32. package/dist/react/utils/renderFileChildren.js.map +1 -1
  33. package/dist/react/utils/useFileDiffInstance.d.ts +1 -2
  34. package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
  35. package/dist/react/utils/useFileDiffInstance.js.map +1 -1
  36. package/dist/react/utils/useFileInstance.d.ts +1 -2
  37. package/dist/react/utils/useFileInstance.d.ts.map +1 -1
  38. package/dist/react/utils/useFileInstance.js.map +1 -1
  39. package/dist/renderers/DiffHunksRenderer.d.ts +1 -0
  40. package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
  41. package/dist/renderers/DiffHunksRenderer.js +7 -0
  42. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  43. package/dist/ssr/index.d.ts +2 -2
  44. package/dist/style.js +1 -1
  45. package/dist/style.js.map +1 -1
  46. package/dist/types.d.ts +5 -1
  47. package/dist/types.d.ts.map +1 -1
  48. package/dist/utils/areSelectionPointsEqual.d.ts +7 -0
  49. package/dist/utils/areSelectionPointsEqual.d.ts.map +1 -0
  50. package/dist/utils/areSelectionPointsEqual.js +8 -0
  51. package/dist/utils/areSelectionPointsEqual.js.map +1 -0
  52. package/dist/utils/areSelectionsEqual.d.ts +1 -1
  53. package/dist/utils/areSelectionsEqual.d.ts.map +1 -1
  54. package/dist/utils/areSelectionsEqual.js.map +1 -1
  55. package/dist/worker/worker-portable.js +9 -6
  56. package/dist/worker/worker-portable.js.map +1 -1
  57. package/package.json +1 -1
  58. package/dist/managers/LineSelectionManager.d.ts +0 -64
  59. package/dist/managers/LineSelectionManager.d.ts.map +0 -1
  60. package/dist/managers/LineSelectionManager.js +0 -270
  61. package/dist/managers/LineSelectionManager.js.map +0 -1
  62. package/dist/managers/MouseEventManager.d.ts +0 -86
  63. package/dist/managers/MouseEventManager.d.ts.map +0 -1
  64. package/dist/managers/MouseEventManager.js +0 -424
  65. package/dist/managers/MouseEventManager.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualizedFileDiff.js","names":["hunkOffsets: number[]","firstVisibleHunk: number | undefined","centerHunk: number | undefined","overflowCounter: number | undefined","lineHeight"],"sources":["../../src/components/VirtualizedFileDiff.ts"],"sourcesContent":["import { DEFAULT_COLLAPSED_CONTEXT_THRESHOLD } from '../constants';\nimport type {\n ExpansionDirections,\n FileDiffMetadata,\n RenderRange,\n RenderWindow,\n VirtualFileMetrics,\n} from '../types';\nimport { iterateOverDiff } from '../utils/iterateOverDiff';\nimport { parseDiffFromFile } from '../utils/parseDiffFromFile';\nimport { resolveVirtualFileMetrics } from '../utils/resolveVirtualFileMetrics';\nimport type { WorkerPoolManager } from '../worker';\nimport {\n FileDiff,\n type FileDiffOptions,\n type FileDiffRenderProps,\n} from './FileDiff';\nimport type { Virtualizer } from './Virtualizer';\n\ninterface ExpandedRegionSpecs {\n fromStart: number;\n fromEnd: number;\n collapsedLines: number;\n renderAll: boolean;\n}\n\nlet instanceId = -1;\n\nexport class VirtualizedFileDiff<\n LAnnotation = undefined,\n> extends FileDiff<LAnnotation> {\n override readonly __id: string = `little-virtualized-file-diff:${++instanceId}`;\n\n public top: number | undefined;\n public height: number = 0;\n private metrics: VirtualFileMetrics;\n // Sparse map: view-specific line index -> measured height\n // Only stores lines that differ what is returned from `getLineHeight`\n private heightCache: Map<number, number> = new Map();\n private isVisible: boolean = false;\n private virtualizer: Virtualizer;\n\n constructor(\n options: FileDiffOptions<LAnnotation> | undefined,\n virtualizer: Virtualizer,\n metrics?: Partial<VirtualFileMetrics>,\n workerManager?: WorkerPoolManager,\n isContainerManaged = false\n ) {\n super(options, workerManager, isContainerManaged);\n const { hunkSeparators = 'line-info' } = this.options;\n this.virtualizer = virtualizer;\n this.metrics = resolveVirtualFileMetrics(\n typeof hunkSeparators === 'function' ? 'custom' : hunkSeparators,\n metrics\n );\n }\n\n // Get the height for a line, using cached value if available.\n // If not cached and hasMetadataLine is true, adds lineHeight for the metadata.\n private getLineHeight(lineIndex: number, hasMetadataLine = false): number {\n const cached = this.heightCache.get(lineIndex);\n if (cached != null) {\n return cached;\n }\n const multiplier = hasMetadataLine ? 2 : 1;\n return this.metrics.lineHeight * multiplier;\n }\n\n // Override setOptions to clear height cache when diffStyle changes\n override setOptions(options: FileDiffOptions<LAnnotation> | undefined): void {\n if (options == null) return;\n const previousDiffStyle = this.options.diffStyle;\n const previousOverflow = this.options.overflow;\n const previousCollapsed = this.options.collapsed;\n\n super.setOptions(options);\n\n if (\n previousDiffStyle !== this.options.diffStyle ||\n previousOverflow !== this.options.overflow ||\n previousCollapsed !== this.options.collapsed\n ) {\n this.heightCache.clear();\n this.computeApproximateSize();\n this.renderRange = undefined;\n }\n this.virtualizer.instanceChanged(this);\n }\n\n // Measure rendered lines and update height cache.\n // Called after render to reconcile estimated vs actual heights.\n // Definitely need to optimize this in cases where there aren't any custom\n // line heights or in cases of extremely large files...\n public reconcileHeights(): void {\n const { overflow = 'scroll' } = this.options;\n if (this.fileContainer != null) {\n this.top = this.virtualizer.getOffsetInScrollContainer(\n this.fileContainer\n );\n }\n if (this.fileContainer == null || this.fileDiff == null) {\n this.height = 0;\n return;\n }\n // NOTE(amadeus): We can probably be a lot smarter about this, and we\n // should be thinking about ways to improve this\n // If the file has no annotations and we are using the scroll variant, then\n // we can probably skip everything\n if (\n overflow === 'scroll' &&\n this.lineAnnotations.length === 0 &&\n !this.virtualizer.config.resizeDebugging\n ) {\n return;\n }\n const diffStyle = this.getDiffStyle();\n let hasLineHeightChange = false;\n const codeGroups =\n diffStyle === 'split'\n ? [this.codeDeletions, this.codeAdditions]\n : [this.codeUnified];\n\n for (const codeGroup of codeGroups) {\n if (codeGroup == null) continue;\n const content = codeGroup.children[1];\n if (!(content instanceof HTMLElement)) continue;\n for (const line of content.children) {\n if (!(line instanceof HTMLElement)) continue;\n\n const lineIndexAttr = line.dataset.lineIndex;\n if (lineIndexAttr == null) continue;\n\n const lineIndex = parseLineIndex(lineIndexAttr, diffStyle);\n let measuredHeight = line.getBoundingClientRect().height;\n let hasMetadata = false;\n // Annotations or noNewline metadata increase the size of the their\n // attached line\n if (\n line.nextElementSibling instanceof HTMLElement &&\n ('lineAnnotation' in line.nextElementSibling.dataset ||\n 'noNewline' in line.nextElementSibling.dataset)\n ) {\n if ('noNewline' in line.nextElementSibling.dataset) {\n hasMetadata = true;\n }\n measuredHeight +=\n line.nextElementSibling.getBoundingClientRect().height;\n }\n const expectedHeight = this.getLineHeight(lineIndex, hasMetadata);\n\n if (measuredHeight === expectedHeight) {\n continue;\n }\n\n hasLineHeightChange = true;\n // Line is back to standard height (e.g., after window resize)\n // Remove from cache\n if (\n measuredHeight ===\n this.metrics.lineHeight * (hasMetadata ? 2 : 1)\n ) {\n this.heightCache.delete(lineIndex);\n }\n // Non-standard height, cache it\n else {\n this.heightCache.set(lineIndex, measuredHeight);\n }\n }\n }\n\n if (hasLineHeightChange || this.virtualizer.config.resizeDebugging) {\n this.computeApproximateSize();\n }\n }\n\n public onRender = (dirty: boolean): boolean => {\n if (this.fileContainer == null) {\n return false;\n }\n if (dirty) {\n this.top = this.virtualizer.getOffsetInScrollContainer(\n this.fileContainer\n );\n }\n return this.render();\n };\n\n override cleanUp(): void {\n if (this.fileContainer != null) {\n this.virtualizer.disconnect(this.fileContainer);\n }\n super.cleanUp();\n }\n\n override expandHunk(hunkIndex: number, direction: ExpansionDirections): void {\n this.hunksRenderer.expandHunk(hunkIndex, direction);\n this.computeApproximateSize();\n this.renderRange = undefined;\n this.virtualizer.instanceChanged(this);\n // NOTE(amadeus): We should probably defer to the virtualizer to re-render\n // this.rerender();\n }\n\n public setVisibility(visible: boolean): void {\n if (this.fileContainer == null) {\n return;\n }\n this.renderRange = undefined;\n if (visible && !this.isVisible) {\n this.top = this.virtualizer.getOffsetInScrollContainer(\n this.fileContainer\n );\n this.isVisible = true;\n } else if (!visible && this.isVisible) {\n this.isVisible = false;\n this.rerender();\n }\n }\n\n // Compute the approximate size of the file using cached line heights.\n // Uses lineHeight for lines without cached measurements.\n // We should probably optimize this if there are no custom line heights...\n // The reason we refer to this as `approximate size` is because heights my\n // dynamically change for a number of reasons so we can never be fully sure\n // if the height is 100% accurate\n private computeApproximateSize(): void {\n const isFirstCompute = this.height === 0;\n this.height = 0;\n if (this.fileDiff == null) {\n return;\n }\n\n const {\n disableFileHeader = false,\n expandUnchanged = false,\n collapsed = false,\n collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n hunkSeparators = 'line-info',\n } = this.options;\n const { diffHeaderHeight, fileGap, hunkSeparatorHeight } = this.metrics;\n const diffStyle = this.getDiffStyle();\n const separatorGap =\n hunkSeparators !== 'simple' &&\n hunkSeparators !== 'metadata' &&\n hunkSeparators !== 'line-info-basic'\n ? fileGap\n : 0;\n\n // Header or initial padding\n if (!disableFileHeader) {\n this.height += diffHeaderHeight;\n } else if (hunkSeparators !== 'simple' && hunkSeparators !== 'metadata') {\n this.height += fileGap;\n }\n if (collapsed) {\n return;\n }\n\n iterateOverDiff({\n diff: this.fileDiff,\n diffStyle,\n expandedHunks: expandUnchanged\n ? true\n : this.hunksRenderer.getExpandedHunksMap(),\n collapsedContextThreshold,\n callback: ({\n hunkIndex,\n collapsedBefore,\n collapsedAfter,\n deletionLine,\n additionLine,\n }) => {\n const splitLineIndex =\n additionLine != null\n ? additionLine.splitLineIndex\n : deletionLine.splitLineIndex;\n const unifiedLineIndex =\n additionLine != null\n ? additionLine.unifiedLineIndex\n : deletionLine.unifiedLineIndex;\n const hasMetadata =\n (additionLine?.noEOFCR ?? false) || (deletionLine?.noEOFCR ?? false);\n if (collapsedBefore > 0) {\n if (hunkIndex > 0) {\n this.height += separatorGap;\n }\n this.height += hunkSeparatorHeight + separatorGap;\n }\n\n this.height += this.getLineHeight(\n diffStyle === 'split' ? splitLineIndex : unifiedLineIndex,\n hasMetadata\n );\n\n if (collapsedAfter > 0 && hunkSeparators !== 'simple') {\n this.height += separatorGap + hunkSeparatorHeight;\n }\n },\n });\n\n // Bottom padding\n if (this.fileDiff.hunks.length > 0) {\n this.height += fileGap;\n }\n\n if (\n this.fileContainer != null &&\n this.virtualizer.config.resizeDebugging &&\n !isFirstCompute\n ) {\n const rect = this.fileContainer.getBoundingClientRect();\n if (rect.height !== this.height) {\n console.log(\n 'VirtualizedFileDiff.computeApproximateSize: computed height doesnt match',\n {\n name: this.fileDiff.name,\n elementHeight: rect.height,\n computedHeight: this.height,\n }\n );\n } else {\n console.log(\n 'VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT'\n );\n }\n }\n }\n\n override render({\n fileContainer,\n oldFile,\n newFile,\n fileDiff,\n ...props\n }: FileDiffRenderProps<LAnnotation> = {}): boolean {\n // NOTE(amadeus): Probably not the safest way to determine first render...\n // but for now...\n const isFirstRender = this.fileContainer == null;\n\n this.fileDiff ??=\n fileDiff ??\n (oldFile != null && newFile != null\n ? // NOTE(amadeus): We might be forcing ourselves to double up the\n // computation of fileDiff (in the super.render() call), so we might want\n // to figure out a way to avoid that. That also could be just as simple as\n // passing through fileDiff though... so maybe we good?\n parseDiffFromFile(oldFile, newFile)\n : undefined);\n\n fileContainer = this.getOrCreateFileContainer(fileContainer);\n\n if (this.fileDiff == null) {\n console.error(\n 'VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data'\n );\n return false;\n }\n\n if (isFirstRender) {\n this.computeApproximateSize();\n this.virtualizer.connect(fileContainer, this);\n this.top ??= this.virtualizer.getOffsetInScrollContainer(fileContainer);\n this.isVisible = this.virtualizer.isInstanceVisible(\n this.top,\n this.height\n );\n } else {\n this.top ??= this.virtualizer.getOffsetInScrollContainer(fileContainer);\n }\n\n if (!this.isVisible) {\n return this.renderPlaceholder(this.height);\n }\n\n const windowSpecs = this.virtualizer.getWindowSpecs();\n const renderRange = this.computeRenderRangeFromWindow(\n this.fileDiff,\n this.top,\n windowSpecs\n );\n return super.render({\n fileDiff: this.fileDiff,\n fileContainer,\n renderRange,\n oldFile,\n newFile,\n ...props,\n });\n }\n\n private getDiffStyle(): 'split' | 'unified' {\n return this.options.diffStyle ?? 'split';\n }\n\n private getExpandedRegion(\n isPartial: boolean,\n hunkIndex: number,\n rangeSize: number\n ): ExpandedRegionSpecs {\n if (rangeSize <= 0 || isPartial) {\n return {\n fromStart: 0,\n fromEnd: 0,\n collapsedLines: Math.max(rangeSize, 0),\n renderAll: false,\n };\n }\n const {\n expandUnchanged = false,\n collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n } = this.options;\n if (expandUnchanged || rangeSize <= collapsedContextThreshold) {\n return {\n fromStart: rangeSize,\n fromEnd: 0,\n collapsedLines: 0,\n renderAll: true,\n };\n }\n const region = this.hunksRenderer.getExpandedHunk(hunkIndex);\n const fromStart = Math.min(Math.max(region.fromStart, 0), rangeSize);\n const fromEnd = Math.min(Math.max(region.fromEnd, 0), rangeSize);\n const expandedCount = fromStart + fromEnd;\n const renderAll = expandedCount >= rangeSize;\n return {\n fromStart,\n fromEnd,\n collapsedLines: Math.max(rangeSize - expandedCount, 0),\n renderAll,\n };\n }\n\n private getExpandedLineCount(\n fileDiff: FileDiffMetadata,\n diffStyle: 'split' | 'unified'\n ): number {\n let count = 0;\n if (fileDiff.isPartial) {\n for (const hunk of fileDiff.hunks) {\n count +=\n diffStyle === 'split' ? hunk.splitLineCount : hunk.unifiedLineCount;\n }\n return count;\n }\n\n for (const [hunkIndex, hunk] of fileDiff.hunks.entries()) {\n const hunkCount =\n diffStyle === 'split' ? hunk.splitLineCount : hunk.unifiedLineCount;\n count += hunkCount;\n const collapsedBefore = Math.max(hunk.collapsedBefore, 0);\n const { fromStart, fromEnd, renderAll } = this.getExpandedRegion(\n fileDiff.isPartial,\n hunkIndex,\n collapsedBefore\n );\n if (collapsedBefore > 0) {\n count += renderAll ? collapsedBefore : fromStart + fromEnd;\n }\n }\n\n const lastHunk = fileDiff.hunks.at(-1);\n if (lastHunk != null && hasFinalHunk(fileDiff)) {\n const additionRemaining =\n fileDiff.additionLines.length -\n (lastHunk.additionLineIndex + lastHunk.additionCount);\n const deletionRemaining =\n fileDiff.deletionLines.length -\n (lastHunk.deletionLineIndex + lastHunk.deletionCount);\n if (lastHunk != null && additionRemaining !== deletionRemaining) {\n throw new Error(\n `VirtualizedFileDiff: trailing context mismatch (additions=${additionRemaining}, deletions=${deletionRemaining}) for ${fileDiff.name}`\n );\n }\n const trailingRangeSize = Math.min(additionRemaining, deletionRemaining);\n if (lastHunk != null && trailingRangeSize > 0) {\n const { fromStart, renderAll } = this.getExpandedRegion(\n fileDiff.isPartial,\n fileDiff.hunks.length,\n trailingRangeSize\n );\n count += renderAll ? trailingRangeSize : fromStart;\n }\n }\n\n return count;\n }\n\n private computeRenderRangeFromWindow(\n fileDiff: FileDiffMetadata,\n fileTop: number,\n { top, bottom }: RenderWindow\n ): RenderRange {\n const {\n disableFileHeader = false,\n expandUnchanged = false,\n collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n hunkSeparators = 'line-info',\n } = this.options;\n const {\n diffHeaderHeight,\n fileGap,\n hunkLineCount,\n hunkSeparatorHeight,\n lineHeight,\n } = this.metrics;\n const diffStyle = this.getDiffStyle();\n const fileHeight = this.height;\n const lineCount = this.getExpandedLineCount(fileDiff, diffStyle);\n\n // Calculate headerRegion before early returns\n const headerRegion = disableFileHeader ? fileGap : diffHeaderHeight;\n\n // File is outside render window\n if (fileTop < top - fileHeight || fileTop > bottom) {\n return {\n startingLine: 0,\n totalLines: 0,\n bufferBefore: 0,\n bufferAfter:\n fileHeight -\n headerRegion -\n // This last file gap represents the bottom padding that buffers\n // should not account for\n fileGap,\n };\n }\n\n // Whole file is under hunkLineCount, just render it all\n if (lineCount <= hunkLineCount || fileDiff.hunks.length === 0) {\n return {\n startingLine: 0,\n totalLines: hunkLineCount,\n bufferBefore: 0,\n bufferAfter: 0,\n };\n }\n const estimatedTargetLines = Math.ceil(\n Math.max(bottom - top, 0) / lineHeight\n );\n const totalLines =\n Math.ceil(estimatedTargetLines / hunkLineCount) * hunkLineCount +\n hunkLineCount;\n const totalHunks = totalLines / hunkLineCount;\n const overflowHunks = totalHunks;\n const hunkOffsets: number[] = [];\n // Halfway between top & bottom, represented as an absolute position\n const viewportCenter = (top + bottom) / 2;\n const separatorGap =\n hunkSeparators === 'simple' ||\n hunkSeparators === 'metadata' ||\n hunkSeparators === 'line-info-basic'\n ? 0\n : fileGap;\n\n let absoluteLineTop = fileTop + headerRegion;\n let currentLine = 0;\n let firstVisibleHunk: number | undefined;\n let centerHunk: number | undefined;\n let overflowCounter: number | undefined;\n\n iterateOverDiff({\n diff: fileDiff,\n diffStyle,\n expandedHunks: expandUnchanged\n ? true\n : this.hunksRenderer.getExpandedHunksMap(),\n collapsedContextThreshold,\n callback: ({\n hunkIndex,\n collapsedBefore,\n collapsedAfter,\n deletionLine,\n additionLine,\n }) => {\n const splitLineIndex =\n additionLine != null\n ? additionLine.splitLineIndex\n : deletionLine.splitLineIndex;\n const unifiedLineIndex =\n additionLine != null\n ? additionLine.unifiedLineIndex\n : deletionLine.unifiedLineIndex;\n const hasMetadata =\n (additionLine?.noEOFCR ?? false) || (deletionLine?.noEOFCR ?? false);\n let gapAdjustment =\n collapsedBefore > 0\n ? hunkSeparatorHeight +\n separatorGap +\n (hunkIndex > 0 ? separatorGap : 0)\n : 0;\n if (hunkIndex === 0 && hunkSeparators === 'simple') {\n gapAdjustment = 0;\n }\n\n absoluteLineTop += gapAdjustment;\n\n const isAtHunkBoundary = currentLine % hunkLineCount === 0;\n\n // Track the boundary positional offset at a hunk\n if (isAtHunkBoundary) {\n hunkOffsets.push(\n absoluteLineTop - (fileTop + headerRegion + gapAdjustment)\n );\n\n // Check if we should bail (overflow complete)\n if (overflowCounter != null) {\n if (overflowCounter <= 0) {\n return true;\n }\n overflowCounter--;\n }\n }\n\n const lineHeight = this.getLineHeight(\n diffStyle === 'split' ? splitLineIndex : unifiedLineIndex,\n hasMetadata\n );\n\n const currentHunk = Math.floor(currentLine / hunkLineCount);\n\n // Track visible region\n if (absoluteLineTop > top - lineHeight && absoluteLineTop < bottom) {\n firstVisibleHunk ??= currentHunk;\n }\n\n // Track which hunk contains the viewport center\n // If viewport center is above this line and we haven't set centerHunk yet,\n // this is the first line at or past the center\n if (\n centerHunk == null &&\n absoluteLineTop + lineHeight > viewportCenter\n ) {\n centerHunk = currentHunk;\n }\n\n // Start overflow when we are out of the viewport at a hunk boundary\n if (\n overflowCounter == null &&\n absoluteLineTop >= bottom &&\n isAtHunkBoundary\n ) {\n overflowCounter = overflowHunks;\n }\n\n currentLine++;\n absoluteLineTop += lineHeight;\n\n if (collapsedAfter > 0 && hunkSeparators !== 'simple') {\n absoluteLineTop += hunkSeparatorHeight + separatorGap;\n }\n\n return false;\n },\n });\n\n // No visible lines found\n if (firstVisibleHunk == null) {\n return {\n startingLine: 0,\n totalLines: 0,\n bufferBefore: 0,\n bufferAfter:\n fileHeight -\n headerRegion -\n // We gotta subtract the bottom padding off of the buffer\n fileGap,\n };\n }\n\n // Calculate balanced startingLine centered around the viewport center\n // Fall back to firstVisibleHunk if center wasn't found (e.g., center in a gap)\n const collectedHunks = hunkOffsets.length;\n centerHunk ??= firstVisibleHunk;\n const idealStartHunk = Math.round(centerHunk - totalHunks / 2);\n\n // Clamp startHunk: at the beginning, reduce totalLines; at the end, shift startHunk back\n const maxStartHunk = Math.max(0, collectedHunks - totalHunks);\n const startHunk = Math.max(0, Math.min(idealStartHunk, maxStartHunk));\n const startingLine = startHunk * hunkLineCount;\n\n // If we wanted to start before 0, reduce totalLines by the clamped amount\n const clampedTotalLines =\n idealStartHunk < 0\n ? totalLines + idealStartHunk * hunkLineCount\n : totalLines;\n\n // Use hunkOffsets array for efficient buffer calculations\n const bufferBefore = hunkOffsets[startHunk] ?? 0;\n\n // Calculate bufferAfter using hunkOffset if available, otherwise use cumulative height\n const finalHunkIndex = startHunk + clampedTotalLines / hunkLineCount;\n const bufferAfter =\n finalHunkIndex < hunkOffsets.length\n ? fileHeight -\n headerRegion -\n hunkOffsets[finalHunkIndex] -\n // We gotta subtract the bottom padding off of the buffer\n fileGap\n : // We stopped early, calculate from current position\n fileHeight -\n (absoluteLineTop - fileTop) -\n // We gotta subtract the bottom padding off of the buffer\n fileGap;\n\n return {\n startingLine,\n totalLines: clampedTotalLines,\n bufferBefore,\n bufferAfter,\n };\n }\n}\n\nfunction hasFinalHunk(fileDiff: FileDiffMetadata): boolean {\n const lastHunk = fileDiff.hunks.at(-1);\n if (\n lastHunk == null ||\n fileDiff.isPartial ||\n fileDiff.additionLines.length === 0 ||\n fileDiff.deletionLines.length === 0\n ) {\n return false;\n }\n\n return (\n lastHunk.additionLineIndex + lastHunk.additionCount <\n fileDiff.additionLines.length ||\n lastHunk.deletionLineIndex + lastHunk.deletionCount <\n fileDiff.deletionLines.length\n );\n}\n\n// Extracts the view-specific line index from the data-line-index attribute.\n// Format is \"unifiedIndex,splitIndex\"\nfunction parseLineIndex(\n lineIndexAttr: string,\n diffStyle: 'split' | 'unified'\n): number {\n const [unifiedIndex, splitIndex] = lineIndexAttr.split(',').map(Number);\n return diffStyle === 'split' ? splitIndex : unifiedIndex;\n}\n"],"mappings":";;;;;;;AA0BA,IAAI,aAAa;AAEjB,IAAa,sBAAb,cAEU,SAAsB;CAC9B,AAAkB,OAAe,gCAAgC,EAAE;CAEnE,AAAO;CACP,AAAO,SAAiB;CACxB,AAAQ;CAGR,AAAQ,8BAAmC,IAAI,KAAK;CACpD,AAAQ,YAAqB;CAC7B,AAAQ;CAER,YACE,SACA,aACA,SACA,eACA,qBAAqB,OACrB;AACA,QAAM,SAAS,eAAe,mBAAmB;EACjD,MAAM,EAAE,iBAAiB,gBAAgB,KAAK;AAC9C,OAAK,cAAc;AACnB,OAAK,UAAU,0BACb,OAAO,mBAAmB,aAAa,WAAW,gBAClD,QACD;;CAKH,AAAQ,cAAc,WAAmB,kBAAkB,OAAe;EACxE,MAAM,SAAS,KAAK,YAAY,IAAI,UAAU;AAC9C,MAAI,UAAU,KACZ,QAAO;EAET,MAAM,aAAa,kBAAkB,IAAI;AACzC,SAAO,KAAK,QAAQ,aAAa;;CAInC,AAAS,WAAW,SAAyD;AAC3E,MAAI,WAAW,KAAM;EACrB,MAAM,oBAAoB,KAAK,QAAQ;EACvC,MAAM,mBAAmB,KAAK,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 {"version":3,"file":"VirtualizedFileDiff.js","names":["hunkOffsets: number[]","firstVisibleHunk: number | undefined","centerHunk: number | undefined","overflowCounter: number | undefined","lineHeight"],"sources":["../../src/components/VirtualizedFileDiff.ts"],"sourcesContent":["import { DEFAULT_COLLAPSED_CONTEXT_THRESHOLD } from '../constants';\nimport type {\n ExpansionDirections,\n FileDiffMetadata,\n RenderRange,\n RenderWindow,\n VirtualFileMetrics,\n} from '../types';\nimport { iterateOverDiff } from '../utils/iterateOverDiff';\nimport { parseDiffFromFile } from '../utils/parseDiffFromFile';\nimport { resolveVirtualFileMetrics } from '../utils/resolveVirtualFileMetrics';\nimport type { WorkerPoolManager } from '../worker';\nimport {\n FileDiff,\n type FileDiffOptions,\n type FileDiffRenderProps,\n} from './FileDiff';\nimport type { Virtualizer } from './Virtualizer';\n\ninterface ExpandedRegionSpecs {\n fromStart: number;\n fromEnd: number;\n collapsedLines: number;\n renderAll: boolean;\n}\n\nlet instanceId = -1;\n\nexport class VirtualizedFileDiff<\n LAnnotation = undefined,\n> extends FileDiff<LAnnotation> {\n override readonly __id: string = `little-virtualized-file-diff:${++instanceId}`;\n\n public top: number | undefined;\n public height: number = 0;\n private metrics: VirtualFileMetrics;\n // Sparse map: view-specific line index -> measured height\n // Only stores lines that differ what is returned from `getLineHeight`\n private heightCache: Map<number, number> = new Map();\n private isVisible: boolean = false;\n private virtualizer: Virtualizer;\n\n constructor(\n options: FileDiffOptions<LAnnotation> | undefined,\n virtualizer: Virtualizer,\n metrics?: Partial<VirtualFileMetrics>,\n workerManager?: WorkerPoolManager,\n isContainerManaged = false\n ) {\n super(options, workerManager, isContainerManaged);\n const { hunkSeparators = 'line-info' } = this.options;\n this.virtualizer = virtualizer;\n this.metrics = resolveVirtualFileMetrics(\n typeof hunkSeparators === 'function' ? 'custom' : hunkSeparators,\n metrics\n );\n }\n\n // Get the height for a line, using cached value if available.\n // If not cached and hasMetadataLine is true, adds lineHeight for the metadata.\n private getLineHeight(lineIndex: number, hasMetadataLine = false): number {\n const cached = this.heightCache.get(lineIndex);\n if (cached != null) {\n return cached;\n }\n const multiplier = hasMetadataLine ? 2 : 1;\n return this.metrics.lineHeight * multiplier;\n }\n\n // Override setOptions to clear height cache when diffStyle changes\n override setOptions(options: FileDiffOptions<LAnnotation> | undefined): void {\n if (options == null) return;\n const previousDiffStyle = this.options.diffStyle;\n const previousOverflow = this.options.overflow;\n const previousCollapsed = this.options.collapsed;\n\n super.setOptions(options);\n\n if (\n previousDiffStyle !== this.options.diffStyle ||\n previousOverflow !== this.options.overflow ||\n previousCollapsed !== this.options.collapsed\n ) {\n this.heightCache.clear();\n this.computeApproximateSize();\n this.renderRange = undefined;\n }\n this.virtualizer.instanceChanged(this);\n }\n\n // Measure rendered lines and update height cache.\n // Called after render to reconcile estimated vs actual heights.\n // Definitely need to optimize this in cases where there aren't any custom\n // line heights or in cases of extremely large files...\n public reconcileHeights(): void {\n const { overflow = 'scroll' } = this.options;\n if (this.fileContainer != null) {\n this.top = this.virtualizer.getOffsetInScrollContainer(\n this.fileContainer\n );\n }\n if (this.fileContainer == null || this.fileDiff == null) {\n this.height = 0;\n return;\n }\n // NOTE(amadeus): We can probably be a lot smarter about this, and we\n // should be thinking about ways to improve this\n // If the file has no annotations and we are using the scroll variant, then\n // we can probably skip everything\n if (\n overflow === 'scroll' &&\n this.lineAnnotations.length === 0 &&\n !this.virtualizer.config.resizeDebugging\n ) {\n return;\n }\n const diffStyle = this.getDiffStyle();\n let hasLineHeightChange = false;\n const codeGroups =\n diffStyle === 'split'\n ? [this.codeDeletions, this.codeAdditions]\n : [this.codeUnified];\n\n for (const codeGroup of codeGroups) {\n if (codeGroup == null) continue;\n const content = codeGroup.children[1];\n if (!(content instanceof HTMLElement)) continue;\n for (const line of content.children) {\n if (!(line instanceof HTMLElement)) continue;\n\n const lineIndexAttr = line.dataset.lineIndex;\n if (lineIndexAttr == null) continue;\n\n const lineIndex = parseLineIndex(lineIndexAttr, diffStyle);\n let measuredHeight = line.getBoundingClientRect().height;\n let hasMetadata = false;\n // Annotations or noNewline metadata increase the size of the their\n // attached line\n if (\n line.nextElementSibling instanceof HTMLElement &&\n ('lineAnnotation' in line.nextElementSibling.dataset ||\n 'noNewline' in line.nextElementSibling.dataset)\n ) {\n if ('noNewline' in line.nextElementSibling.dataset) {\n hasMetadata = true;\n }\n measuredHeight +=\n line.nextElementSibling.getBoundingClientRect().height;\n }\n const expectedHeight = this.getLineHeight(lineIndex, hasMetadata);\n\n if (measuredHeight === expectedHeight) {\n continue;\n }\n\n hasLineHeightChange = true;\n // Line is back to standard height (e.g., after window resize)\n // Remove from cache\n if (\n measuredHeight ===\n this.metrics.lineHeight * (hasMetadata ? 2 : 1)\n ) {\n this.heightCache.delete(lineIndex);\n }\n // Non-standard height, cache it\n else {\n this.heightCache.set(lineIndex, measuredHeight);\n }\n }\n }\n\n if (hasLineHeightChange || this.virtualizer.config.resizeDebugging) {\n this.computeApproximateSize();\n }\n }\n\n public onRender = (dirty: boolean): boolean => {\n if (this.fileContainer == null) {\n return false;\n }\n if (dirty) {\n this.top = this.virtualizer.getOffsetInScrollContainer(\n this.fileContainer\n );\n }\n return this.render();\n };\n\n override cleanUp(): void {\n if (this.fileContainer != null) {\n this.virtualizer.disconnect(this.fileContainer);\n }\n super.cleanUp();\n }\n\n override expandHunk(hunkIndex: number, direction: ExpansionDirections): void {\n this.hunksRenderer.expandHunk(hunkIndex, direction);\n this.computeApproximateSize();\n this.renderRange = undefined;\n this.virtualizer.instanceChanged(this);\n // NOTE(amadeus): We should probably defer to the virtualizer to re-render\n // this.rerender();\n }\n\n override expandHunkFully(hunkIndex: number): void {\n this.hunksRenderer.expandHunkFully(hunkIndex);\n this.computeApproximateSize();\n this.renderRange = undefined;\n this.virtualizer.instanceChanged(this);\n }\n\n public setVisibility(visible: boolean): void {\n if (this.fileContainer == null) {\n return;\n }\n this.renderRange = undefined;\n if (visible && !this.isVisible) {\n this.top = this.virtualizer.getOffsetInScrollContainer(\n this.fileContainer\n );\n this.isVisible = true;\n } else if (!visible && this.isVisible) {\n this.isVisible = false;\n this.rerender();\n }\n }\n\n // Compute the approximate size of the file using cached line heights.\n // Uses lineHeight for lines without cached measurements.\n // We should probably optimize this if there are no custom line heights...\n // The reason we refer to this as `approximate size` is because heights my\n // dynamically change for a number of reasons so we can never be fully sure\n // if the height is 100% accurate\n private computeApproximateSize(): void {\n const isFirstCompute = this.height === 0;\n this.height = 0;\n if (this.fileDiff == null) {\n return;\n }\n\n const {\n disableFileHeader = false,\n expandUnchanged = false,\n collapsed = false,\n collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n hunkSeparators = 'line-info',\n } = this.options;\n const { diffHeaderHeight, fileGap, hunkSeparatorHeight } = this.metrics;\n const diffStyle = this.getDiffStyle();\n const separatorGap =\n hunkSeparators !== 'simple' &&\n hunkSeparators !== 'metadata' &&\n hunkSeparators !== 'line-info-basic'\n ? fileGap\n : 0;\n\n // Header or initial padding\n if (!disableFileHeader) {\n this.height += diffHeaderHeight;\n } else if (hunkSeparators !== 'simple' && hunkSeparators !== 'metadata') {\n this.height += fileGap;\n }\n if (collapsed) {\n return;\n }\n\n iterateOverDiff({\n diff: this.fileDiff,\n diffStyle,\n expandedHunks: expandUnchanged\n ? true\n : this.hunksRenderer.getExpandedHunksMap(),\n collapsedContextThreshold,\n callback: ({\n hunkIndex,\n collapsedBefore,\n collapsedAfter,\n deletionLine,\n additionLine,\n }) => {\n const splitLineIndex =\n additionLine != null\n ? additionLine.splitLineIndex\n : deletionLine.splitLineIndex;\n const unifiedLineIndex =\n additionLine != null\n ? additionLine.unifiedLineIndex\n : deletionLine.unifiedLineIndex;\n const hasMetadata =\n (additionLine?.noEOFCR ?? false) || (deletionLine?.noEOFCR ?? false);\n if (collapsedBefore > 0) {\n if (hunkIndex > 0) {\n this.height += separatorGap;\n }\n this.height += hunkSeparatorHeight + separatorGap;\n }\n\n this.height += this.getLineHeight(\n diffStyle === 'split' ? splitLineIndex : unifiedLineIndex,\n hasMetadata\n );\n\n if (collapsedAfter > 0 && hunkSeparators !== 'simple') {\n this.height += separatorGap + hunkSeparatorHeight;\n }\n },\n });\n\n // Bottom padding\n if (this.fileDiff.hunks.length > 0) {\n this.height += fileGap;\n }\n\n if (\n this.fileContainer != null &&\n this.virtualizer.config.resizeDebugging &&\n !isFirstCompute\n ) {\n const rect = this.fileContainer.getBoundingClientRect();\n if (rect.height !== this.height) {\n console.log(\n 'VirtualizedFileDiff.computeApproximateSize: computed height doesnt match',\n {\n name: this.fileDiff.name,\n elementHeight: rect.height,\n computedHeight: this.height,\n }\n );\n } else {\n console.log(\n 'VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT'\n );\n }\n }\n }\n\n override render({\n fileContainer,\n oldFile,\n newFile,\n fileDiff,\n ...props\n }: FileDiffRenderProps<LAnnotation> = {}): boolean {\n // NOTE(amadeus): Probably not the safest way to determine first render...\n // but for now...\n const isFirstRender = this.fileContainer == null;\n\n this.fileDiff ??=\n fileDiff ??\n (oldFile != null && newFile != null\n ? // NOTE(amadeus): We might be forcing ourselves to double up the\n // computation of fileDiff (in the super.render() call), so we might want\n // to figure out a way to avoid that. That also could be just as simple as\n // passing through fileDiff though... so maybe we good?\n parseDiffFromFile(oldFile, newFile)\n : undefined);\n\n fileContainer = this.getOrCreateFileContainer(fileContainer);\n\n if (this.fileDiff == null) {\n console.error(\n 'VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data'\n );\n return false;\n }\n\n if (isFirstRender) {\n this.computeApproximateSize();\n this.virtualizer.connect(fileContainer, this);\n this.top ??= this.virtualizer.getOffsetInScrollContainer(fileContainer);\n this.isVisible = this.virtualizer.isInstanceVisible(\n this.top,\n this.height\n );\n } else {\n this.top ??= this.virtualizer.getOffsetInScrollContainer(fileContainer);\n }\n\n if (!this.isVisible) {\n return this.renderPlaceholder(this.height);\n }\n\n const windowSpecs = this.virtualizer.getWindowSpecs();\n const renderRange = this.computeRenderRangeFromWindow(\n this.fileDiff,\n this.top,\n windowSpecs\n );\n return super.render({\n fileDiff: this.fileDiff,\n fileContainer,\n renderRange,\n oldFile,\n newFile,\n ...props,\n });\n }\n\n private getDiffStyle(): 'split' | 'unified' {\n return this.options.diffStyle ?? 'split';\n }\n\n private getExpandedRegion(\n isPartial: boolean,\n hunkIndex: number,\n rangeSize: number\n ): ExpandedRegionSpecs {\n if (rangeSize <= 0 || isPartial) {\n return {\n fromStart: 0,\n fromEnd: 0,\n collapsedLines: Math.max(rangeSize, 0),\n renderAll: false,\n };\n }\n const {\n expandUnchanged = false,\n collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n } = this.options;\n if (expandUnchanged || rangeSize <= collapsedContextThreshold) {\n return {\n fromStart: rangeSize,\n fromEnd: 0,\n collapsedLines: 0,\n renderAll: true,\n };\n }\n const region = this.hunksRenderer.getExpandedHunk(hunkIndex);\n const fromStart = Math.min(Math.max(region.fromStart, 0), rangeSize);\n const fromEnd = Math.min(Math.max(region.fromEnd, 0), rangeSize);\n const expandedCount = fromStart + fromEnd;\n const renderAll = expandedCount >= rangeSize;\n return {\n fromStart,\n fromEnd,\n collapsedLines: Math.max(rangeSize - expandedCount, 0),\n renderAll,\n };\n }\n\n private getExpandedLineCount(\n fileDiff: FileDiffMetadata,\n diffStyle: 'split' | 'unified'\n ): number {\n let count = 0;\n if (fileDiff.isPartial) {\n for (const hunk of fileDiff.hunks) {\n count +=\n diffStyle === 'split' ? hunk.splitLineCount : hunk.unifiedLineCount;\n }\n return count;\n }\n\n for (const [hunkIndex, hunk] of fileDiff.hunks.entries()) {\n const hunkCount =\n diffStyle === 'split' ? hunk.splitLineCount : hunk.unifiedLineCount;\n count += hunkCount;\n const collapsedBefore = Math.max(hunk.collapsedBefore, 0);\n const { fromStart, fromEnd, renderAll } = this.getExpandedRegion(\n fileDiff.isPartial,\n hunkIndex,\n collapsedBefore\n );\n if (collapsedBefore > 0) {\n count += renderAll ? collapsedBefore : fromStart + fromEnd;\n }\n }\n\n const lastHunk = fileDiff.hunks.at(-1);\n if (lastHunk != null && hasFinalHunk(fileDiff)) {\n const additionRemaining =\n fileDiff.additionLines.length -\n (lastHunk.additionLineIndex + lastHunk.additionCount);\n const deletionRemaining =\n fileDiff.deletionLines.length -\n (lastHunk.deletionLineIndex + lastHunk.deletionCount);\n if (lastHunk != null && additionRemaining !== deletionRemaining) {\n throw new Error(\n `VirtualizedFileDiff: trailing context mismatch (additions=${additionRemaining}, deletions=${deletionRemaining}) for ${fileDiff.name}`\n );\n }\n const trailingRangeSize = Math.min(additionRemaining, deletionRemaining);\n if (lastHunk != null && trailingRangeSize > 0) {\n const { fromStart, renderAll } = this.getExpandedRegion(\n fileDiff.isPartial,\n fileDiff.hunks.length,\n trailingRangeSize\n );\n count += renderAll ? trailingRangeSize : fromStart;\n }\n }\n\n return count;\n }\n\n private computeRenderRangeFromWindow(\n fileDiff: FileDiffMetadata,\n fileTop: number,\n { top, bottom }: RenderWindow\n ): RenderRange {\n const {\n disableFileHeader = false,\n expandUnchanged = false,\n collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n hunkSeparators = 'line-info',\n } = this.options;\n const {\n diffHeaderHeight,\n fileGap,\n hunkLineCount,\n hunkSeparatorHeight,\n lineHeight,\n } = this.metrics;\n const diffStyle = this.getDiffStyle();\n const fileHeight = this.height;\n const lineCount = this.getExpandedLineCount(fileDiff, diffStyle);\n\n // Calculate headerRegion before early returns\n const headerRegion = disableFileHeader ? fileGap : diffHeaderHeight;\n\n // File is outside render window\n if (fileTop < top - fileHeight || fileTop > bottom) {\n return {\n startingLine: 0,\n totalLines: 0,\n bufferBefore: 0,\n bufferAfter:\n fileHeight -\n headerRegion -\n // This last file gap represents the bottom padding that buffers\n // should not account for\n fileGap,\n };\n }\n\n // Whole file is under hunkLineCount, just render it all\n if (lineCount <= hunkLineCount || fileDiff.hunks.length === 0) {\n return {\n startingLine: 0,\n totalLines: hunkLineCount,\n bufferBefore: 0,\n bufferAfter: 0,\n };\n }\n const estimatedTargetLines = Math.ceil(\n Math.max(bottom - top, 0) / lineHeight\n );\n const totalLines =\n Math.ceil(estimatedTargetLines / hunkLineCount) * hunkLineCount +\n hunkLineCount;\n const totalHunks = totalLines / hunkLineCount;\n const overflowHunks = totalHunks;\n const hunkOffsets: number[] = [];\n // Halfway between top & bottom, represented as an absolute position\n const viewportCenter = (top + bottom) / 2;\n const separatorGap =\n hunkSeparators === 'simple' ||\n hunkSeparators === 'metadata' ||\n hunkSeparators === 'line-info-basic'\n ? 0\n : fileGap;\n\n let absoluteLineTop = fileTop + headerRegion;\n let currentLine = 0;\n let firstVisibleHunk: number | undefined;\n let centerHunk: number | undefined;\n let overflowCounter: number | undefined;\n\n iterateOverDiff({\n diff: fileDiff,\n diffStyle,\n expandedHunks: expandUnchanged\n ? true\n : this.hunksRenderer.getExpandedHunksMap(),\n collapsedContextThreshold,\n callback: ({\n hunkIndex,\n collapsedBefore,\n collapsedAfter,\n deletionLine,\n additionLine,\n }) => {\n const splitLineIndex =\n additionLine != null\n ? additionLine.splitLineIndex\n : deletionLine.splitLineIndex;\n const unifiedLineIndex =\n additionLine != null\n ? additionLine.unifiedLineIndex\n : deletionLine.unifiedLineIndex;\n const hasMetadata =\n (additionLine?.noEOFCR ?? false) || (deletionLine?.noEOFCR ?? false);\n let gapAdjustment =\n collapsedBefore > 0\n ? hunkSeparatorHeight +\n separatorGap +\n (hunkIndex > 0 ? separatorGap : 0)\n : 0;\n if (hunkIndex === 0 && hunkSeparators === 'simple') {\n gapAdjustment = 0;\n }\n\n absoluteLineTop += gapAdjustment;\n\n const isAtHunkBoundary = currentLine % hunkLineCount === 0;\n\n // Track the boundary positional offset at a hunk\n if (isAtHunkBoundary) {\n hunkOffsets.push(\n absoluteLineTop - (fileTop + headerRegion + gapAdjustment)\n );\n\n // Check if we should bail (overflow complete)\n if (overflowCounter != null) {\n if (overflowCounter <= 0) {\n return true;\n }\n overflowCounter--;\n }\n }\n\n const lineHeight = this.getLineHeight(\n diffStyle === 'split' ? splitLineIndex : unifiedLineIndex,\n hasMetadata\n );\n\n const currentHunk = Math.floor(currentLine / hunkLineCount);\n\n // Track visible region\n if (absoluteLineTop > top - lineHeight && absoluteLineTop < bottom) {\n firstVisibleHunk ??= currentHunk;\n }\n\n // Track which hunk contains the viewport center\n // If viewport center is above this line and we haven't set centerHunk yet,\n // this is the first line at or past the center\n if (\n centerHunk == null &&\n absoluteLineTop + lineHeight > viewportCenter\n ) {\n centerHunk = currentHunk;\n }\n\n // Start overflow when we are out of the viewport at a hunk boundary\n if (\n overflowCounter == null &&\n absoluteLineTop >= bottom &&\n isAtHunkBoundary\n ) {\n overflowCounter = overflowHunks;\n }\n\n currentLine++;\n absoluteLineTop += lineHeight;\n\n if (collapsedAfter > 0 && hunkSeparators !== 'simple') {\n absoluteLineTop += hunkSeparatorHeight + separatorGap;\n }\n\n return false;\n },\n });\n\n // No visible lines found\n if (firstVisibleHunk == null) {\n return {\n startingLine: 0,\n totalLines: 0,\n bufferBefore: 0,\n bufferAfter:\n fileHeight -\n headerRegion -\n // We gotta subtract the bottom padding off of the buffer\n fileGap,\n };\n }\n\n // Calculate balanced startingLine centered around the viewport center\n // Fall back to firstVisibleHunk if center wasn't found (e.g., center in a gap)\n const collectedHunks = hunkOffsets.length;\n centerHunk ??= firstVisibleHunk;\n const idealStartHunk = Math.round(centerHunk - totalHunks / 2);\n\n // Clamp startHunk: at the beginning, reduce totalLines; at the end, shift startHunk back\n const maxStartHunk = Math.max(0, collectedHunks - totalHunks);\n const startHunk = Math.max(0, Math.min(idealStartHunk, maxStartHunk));\n const startingLine = startHunk * hunkLineCount;\n\n // If we wanted to start before 0, reduce totalLines by the clamped amount\n const clampedTotalLines =\n idealStartHunk < 0\n ? totalLines + idealStartHunk * hunkLineCount\n : totalLines;\n\n // Use hunkOffsets array for efficient buffer calculations\n const bufferBefore = hunkOffsets[startHunk] ?? 0;\n\n // Calculate bufferAfter using hunkOffset if available, otherwise use cumulative height\n const finalHunkIndex = startHunk + clampedTotalLines / hunkLineCount;\n const bufferAfter =\n finalHunkIndex < hunkOffsets.length\n ? fileHeight -\n headerRegion -\n hunkOffsets[finalHunkIndex] -\n // We gotta subtract the bottom padding off of the buffer\n fileGap\n : // We stopped early, calculate from current position\n fileHeight -\n (absoluteLineTop - fileTop) -\n // We gotta subtract the bottom padding off of the buffer\n fileGap;\n\n return {\n startingLine,\n totalLines: clampedTotalLines,\n bufferBefore,\n bufferAfter,\n };\n }\n}\n\nfunction hasFinalHunk(fileDiff: FileDiffMetadata): boolean {\n const lastHunk = fileDiff.hunks.at(-1);\n if (\n lastHunk == null ||\n fileDiff.isPartial ||\n fileDiff.additionLines.length === 0 ||\n fileDiff.deletionLines.length === 0\n ) {\n return false;\n }\n\n return (\n lastHunk.additionLineIndex + lastHunk.additionCount <\n fileDiff.additionLines.length ||\n lastHunk.deletionLineIndex + lastHunk.deletionCount <\n fileDiff.deletionLines.length\n );\n}\n\n// Extracts the view-specific line index from the data-line-index attribute.\n// Format is \"unifiedIndex,splitIndex\"\nfunction parseLineIndex(\n lineIndexAttr: string,\n diffStyle: 'split' | 'unified'\n): number {\n const [unifiedIndex, splitIndex] = lineIndexAttr.split(',').map(Number);\n return diffStyle === 'split' ? splitIndex : unifiedIndex;\n}\n"],"mappings":";;;;;;;AA0BA,IAAI,aAAa;AAEjB,IAAa,sBAAb,cAEU,SAAsB;CAC9B,AAAkB,OAAe,gCAAgC,EAAE;CAEnE,AAAO;CACP,AAAO,SAAiB;CACxB,AAAQ;CAGR,AAAQ,8BAAmC,IAAI,KAAK;CACpD,AAAQ,YAAqB;CAC7B,AAAQ;CAER,YACE,SACA,aACA,SACA,eACA,qBAAqB,OACrB;AACA,QAAM,SAAS,eAAe,mBAAmB;EACjD,MAAM,EAAE,iBAAiB,gBAAgB,KAAK;AAC9C,OAAK,cAAc;AACnB,OAAK,UAAU,0BACb,OAAO,mBAAmB,aAAa,WAAW,gBAClD,QACD;;CAKH,AAAQ,cAAc,WAA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kB,WAEnB;GAOL;;;AAIL,SAAS,aAAa,UAAqC;CACzD,MAAM,WAAW,SAAS,MAAM,GAAG,GAAG;AACtC,KACE,YAAY,QACZ,SAAS,aACT,SAAS,cAAc,WAAW,KAClC,SAAS,cAAc,WAAW,EAElC,QAAO;AAGT,QACE,SAAS,oBAAoB,SAAS,gBACpC,SAAS,cAAc,UACzB,SAAS,oBAAoB,SAAS,gBACpC,SAAS,cAAc;;AAM7B,SAAS,eACP,eACA,WACQ;CACR,MAAM,CAAC,cAAc,cAAc,cAAc,MAAM,IAAI,CAAC,IAAI,OAAO;AACvE,QAAO,cAAc,UAAU,aAAa"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { AnnotationLineMap, AnnotationSide, AnnotationSpan, BaseCodeOptions, BaseDiffOptions, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, ContextContent, DecorationItem, DiffLineAnnotation, DiffLineEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderMetadataProps, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionSide, SharedRenderState, ShikiTransformer, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, VirtualFileMetrics, VirtualWindowSpecs } from "./types.js";
2
- import { GetLineIndexUtility, LineSelectionManager, LineSelectionOptions, SelectedLineRange, pluckLineSelectionOptions } from "./managers/LineSelectionManager.js";
3
- import { GetHoveredLineResult, LogTypes, MouseEventManager, MouseEventManagerBaseOptions, MouseEventManagerMode, MouseEventManagerOptions, OnDiffLineClickProps, OnDiffLineEnterLeaveProps, OnLineClickProps, OnLineEnterLeaveProps, pluckMouseEventOptions } from "./managers/MouseEventManager.js";
1
+ import { AnnotationLineMap, AnnotationSide, AnnotationSpan, BaseCodeOptions, BaseDiffOptions, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, ContextContent, DecorationItem, DiffLineAnnotation, DiffLineEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderMetadataProps, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, VirtualFileMetrics, VirtualWindowSpecs } from "./types.js";
2
+ import { GetHoveredLineResult, GetLineIndexUtility, InteractionManager, InteractionManagerBaseOptions, InteractionManagerMode, InteractionManagerOptions, LogTypes, OnDiffLineClickProps, OnDiffLineEnterLeaveProps, OnLineClickProps, OnLineEnterLeaveProps, SelectedLineRange, pluckInteractionOptions } from "./managers/InteractionManager.js";
4
3
  import { ResizeManager } from "./managers/ResizeManager.js";
5
4
  import { FileRenderResult, FileRenderer, FileRendererOptions } from "./renderers/FileRenderer.js";
6
5
  import { File, FileHyrdateProps, FileOptions, FileRenderProps } from "./components/File.js";
@@ -97,4 +96,4 @@ import { setPreNodeProperties } from "./utils/setWrapperNodeProps.js";
97
96
  import { trimPatchContext } from "./utils/trimPatchContext.js";
98
97
  import { FileDiff, FileDiffHydrationProps, FileDiffOptions, FileDiffRenderProps } from "./components/FileDiff.js";
99
98
  import { codeToHtml, createCssVariablesTheme as createCSSVariablesTheme } from "shiki";
100
- export { ALTERNATE_FILE_NAMES_GIT, AnnotationLineMap, AnnotationSide, AnnotationSpan, AttachedLanguages, AttachedThemes, BaseCodeOptions, BaseDiffOptions, BundledLanguage, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_EXTENSION_TO_FILE_FORMAT, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeToTokenTransformStream, CodeToTokenTransformStreamOptions, ContextContent, CreateFileHeaderElementProps, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_TAG_NAME, DecorationItem, DiffHunksRenderer, DiffLineAnnotation, DiffLineEventBaseProps, DiffsHighlighter, DiffsThemeNames, EMPTY_RENDER_RANGE, EXTENSION_TO_FILE_FORMAT, ExpansionDirections, ExtensionFormatMap, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, File, FileContents, FileDiff, FileDiffHydrationProps, FileDiffMetadata, FileDiffOptions, FileDiffRenderProps, FileHyrdateProps, FileOptions, FileRenderProps, FileRenderResult, FileRenderer, FileRendererOptions, FileStream, FileStreamOptions, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GIT_DIFF_FILE_BREAK_REGEX, GapSpan, GetHoveredLineResult, GetLineIndexUtility, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, HunksRenderResult, INDEX_LINE_METADATA, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSelectionManager, LineSelectionOptions, LineSpans, LineTypes, LogTypes, MouseEventManager, MouseEventManagerBaseOptions, MouseEventManagerMode, MouseEventManagerOptions, ObservedAnnotationNodes, ObservedGridNodes, OnDiffLineClickProps, OnDiffLineEnterLeaveProps, OnLineClickProps, OnLineEnterLeaveProps, ParsedLine, ParsedPatch, PrePropertiesConfig, RecallToken, RegisteredCustomLanguages, RegisteredCustomThemes, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderMetadataProps, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, ResizeManager, ResolvedLanguages, ResolvedThemes, ResolvingLanguages, ResolvingThemes, SPLIT_WITH_NEWLINES, SVGSpriteNames, SVGSpriteSheet, ScrollSyncManager, SelectedLineRange, SelectionSide, SharedRenderState, ShikiStreamTokenizer, ShikiStreamTokenizerEnqueueResult, ShikiStreamTokenizerOptions, ShikiTransformer, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE, VirtualFileMetrics, VirtualWindowSpecs, VirtualizedFile, VirtualizedFileDiff, Virtualizer, VirtualizerConfig, areDiffLineAnnotationsEqual, areFilesEqual, areHunkDataEqual, areLanguagesAttached, areLineAnnotationsEqual, areObjectsEqual, areOptionsEqual, arePrePropertiesEqual, areRenderRangesEqual, areSelectionsEqual, areThemesAttached, areThemesEqual, areVirtualWindowSpecsEqual, areWorkerStatsEqual, attachResolvedLanguages, attachResolvedThemes, cleanLastNewline, cleanUpResolvedLanguages, cleanUpResolvedThemes, codeToHtml, createAnnotationElement, createAnnotationWrapperNode, createCSSVariablesTheme, createDiffSpanDecoration, createEmptyRowBuffer, createFileHeaderElement, createGutterGap, createGutterItem, createGutterUtilityContentNode, createGutterUtilityElement, createGutterWrapper, createHastElement, createIconElement, createNoNewlineElement, createPreElement, createPreWrapperProperties, createRowNodes, createSeparator, createSpanFromToken, createStyleElement, createTextNodeElement, createTransformerWithState, createUnsafeCSSStyleNode, createWindowFromScrollPosition, diffAcceptRejectHunk, disposeHighlighter, extendFileFormatMap, findCodeElement, formatCSSVariablePrefix, getFiletypeFromFileName, getHighlighterIfLoaded, getHighlighterOptions, getHighlighterThemeStyles, getHunkSeparatorSlotName, getIconForType, getLineAnnotationName, getLineEndingType, getLineNodes, getOrCreateCodeNode, getResolvedLanguages, getResolvedOrResolveLanguage, getResolvedOrResolveTheme, getResolvedThemes, getSharedHighlighter, getSingularPatch, getThemes, getTotalLineCountFromHunks, hasResolvedLanguages, hasResolvedThemes, isDefaultRenderRange, isHighlighterLoaded, isHighlighterLoading, isHighlighterNull, isWorkerContext, parseDiffFromFile, parseLineType, parsePatchFiles, pluckLineSelectionOptions, pluckMouseEventOptions, preloadHighlighter, prerenderHTMLIfNecessary, processFile, processLine, processPatch, pushOrJoinSpan, queueRender, registerCustomCSSVariableTheme, registerCustomLanguage, registerCustomTheme, renderDiffWithHighlighter, renderFileWithHighlighter, resolveLanguage, resolveLanguages, resolveTheme, resolveThemes, setLanguageOverride, setPreNodeProperties, trimPatchContext, wrapCoreCSS, wrapUnsafeCSS };
99
+ export { ALTERNATE_FILE_NAMES_GIT, AnnotationLineMap, AnnotationSide, AnnotationSpan, AttachedLanguages, AttachedThemes, BaseCodeOptions, BaseDiffOptions, BundledLanguage, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_EXTENSION_TO_FILE_FORMAT, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeToTokenTransformStream, CodeToTokenTransformStreamOptions, ContextContent, CreateFileHeaderElementProps, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_TAG_NAME, DecorationItem, DiffHunksRenderer, DiffLineAnnotation, DiffLineEventBaseProps, DiffsHighlighter, DiffsThemeNames, EMPTY_RENDER_RANGE, EXTENSION_TO_FILE_FORMAT, ExpansionDirections, ExtensionFormatMap, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, File, FileContents, FileDiff, FileDiffHydrationProps, FileDiffMetadata, FileDiffOptions, FileDiffRenderProps, FileHyrdateProps, FileOptions, FileRenderProps, FileRenderResult, FileRenderer, FileRendererOptions, FileStream, FileStreamOptions, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GIT_DIFF_FILE_BREAK_REGEX, GapSpan, GetHoveredLineResult, GetLineIndexUtility, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, HunksRenderResult, INDEX_LINE_METADATA, InteractionManager, InteractionManagerBaseOptions, InteractionManagerMode, InteractionManagerOptions, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, LogTypes, ObservedAnnotationNodes, ObservedGridNodes, OnDiffLineClickProps, OnDiffLineEnterLeaveProps, OnLineClickProps, OnLineEnterLeaveProps, ParsedLine, ParsedPatch, PrePropertiesConfig, RecallToken, RegisteredCustomLanguages, RegisteredCustomThemes, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderMetadataProps, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, ResizeManager, ResolvedLanguages, ResolvedThemes, ResolvingLanguages, ResolvingThemes, SPLIT_WITH_NEWLINES, SVGSpriteNames, SVGSpriteSheet, ScrollSyncManager, SelectedLineRange, SelectionPoint, SelectionSide, SharedRenderState, ShikiStreamTokenizer, ShikiStreamTokenizerEnqueueResult, ShikiStreamTokenizerOptions, ShikiTransformer, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE, VirtualFileMetrics, VirtualWindowSpecs, VirtualizedFile, VirtualizedFileDiff, Virtualizer, VirtualizerConfig, areDiffLineAnnotationsEqual, areFilesEqual, areHunkDataEqual, areLanguagesAttached, areLineAnnotationsEqual, areObjectsEqual, areOptionsEqual, arePrePropertiesEqual, areRenderRangesEqual, areSelectionsEqual, areThemesAttached, areThemesEqual, areVirtualWindowSpecsEqual, areWorkerStatsEqual, attachResolvedLanguages, attachResolvedThemes, cleanLastNewline, cleanUpResolvedLanguages, cleanUpResolvedThemes, codeToHtml, createAnnotationElement, createAnnotationWrapperNode, createCSSVariablesTheme, createDiffSpanDecoration, createEmptyRowBuffer, createFileHeaderElement, createGutterGap, createGutterItem, createGutterUtilityContentNode, createGutterUtilityElement, createGutterWrapper, createHastElement, createIconElement, createNoNewlineElement, createPreElement, createPreWrapperProperties, createRowNodes, createSeparator, createSpanFromToken, createStyleElement, createTextNodeElement, createTransformerWithState, createUnsafeCSSStyleNode, createWindowFromScrollPosition, diffAcceptRejectHunk, disposeHighlighter, extendFileFormatMap, findCodeElement, formatCSSVariablePrefix, getFiletypeFromFileName, getHighlighterIfLoaded, getHighlighterOptions, getHighlighterThemeStyles, getHunkSeparatorSlotName, getIconForType, getLineAnnotationName, getLineEndingType, getLineNodes, getOrCreateCodeNode, getResolvedLanguages, getResolvedOrResolveLanguage, getResolvedOrResolveTheme, getResolvedThemes, getSharedHighlighter, getSingularPatch, getThemes, getTotalLineCountFromHunks, hasResolvedLanguages, hasResolvedThemes, isDefaultRenderRange, isHighlighterLoaded, isHighlighterLoading, isHighlighterNull, isWorkerContext, parseDiffFromFile, parseLineType, parsePatchFiles, pluckInteractionOptions, preloadHighlighter, prerenderHTMLIfNecessary, processFile, processLine, processPatch, pushOrJoinSpan, queueRender, registerCustomCSSVariableTheme, registerCustomLanguage, registerCustomTheme, renderDiffWithHighlighter, renderFileWithHighlighter, resolveLanguage, resolveLanguages, resolveTheme, resolveThemes, setLanguageOverride, setPreNodeProperties, trimPatchContext, wrapCoreCSS, wrapUnsafeCSS };
package/dist/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import { ALTERNATE_FILE_NAMES_GIT, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, SPLIT_WITH_NEWLINES, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE } from "./constants.js";
2
2
  import { areSelectionsEqual } from "./utils/areSelectionsEqual.js";
3
- import { LineSelectionManager, pluckLineSelectionOptions } from "./managers/LineSelectionManager.js";
4
3
  import { createGutterGap, createGutterItem, createGutterWrapper, createHastElement, createIconElement, createTextNodeElement, findCodeElement } from "./utils/hast_utils.js";
5
4
  import { createGutterUtilityElement } from "./utils/createGutterUtilityElement.js";
6
- import { MouseEventManager, pluckMouseEventOptions } from "./managers/MouseEventManager.js";
5
+ import { InteractionManager, pluckInteractionOptions } from "./managers/InteractionManager.js";
7
6
  import { ResizeManager } from "./managers/ResizeManager.js";
8
7
  import { AttachedLanguages, RegisteredCustomLanguages, ResolvedLanguages, ResolvingLanguages } from "./highlighter/languages/constants.js";
9
8
  import { areLanguagesAttached } from "./highlighter/languages/areLanguagesAttached.js";
@@ -96,4 +95,4 @@ import { setLanguageOverride } from "./utils/setLanguageOverride.js";
96
95
  import { trimPatchContext } from "./utils/trimPatchContext.js";
97
96
  import { codeToHtml, createCssVariablesTheme as createCSSVariablesTheme } from "shiki";
98
97
 
99
- export { ALTERNATE_FILE_NAMES_GIT, AttachedLanguages, AttachedThemes, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_EXTENSION_TO_FILE_FORMAT, CodeToTokenTransformStream, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_TAG_NAME, DiffHunksRenderer, EMPTY_RENDER_RANGE, EXTENSION_TO_FILE_FORMAT, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, File, FileDiff, FileRenderer, FileStream, GIT_DIFF_FILE_BREAK_REGEX, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, LineSelectionManager, MouseEventManager, RegisteredCustomLanguages, RegisteredCustomThemes, ResizeManager, ResolvedLanguages, ResolvedThemes, ResolvingLanguages, ResolvingThemes, SPLIT_WITH_NEWLINES, SVGSpriteSheet, ScrollSyncManager, ShikiStreamTokenizer, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE, VirtualizedFile, VirtualizedFileDiff, Virtualizer, areDiffLineAnnotationsEqual, areFilesEqual, areHunkDataEqual, areLanguagesAttached, areLineAnnotationsEqual, areObjectsEqual, areOptionsEqual, arePrePropertiesEqual, areRenderRangesEqual, areSelectionsEqual, areThemesAttached, areThemesEqual, areVirtualWindowSpecsEqual, areWorkerStatsEqual, attachResolvedLanguages, attachResolvedThemes, cleanLastNewline, cleanUpResolvedLanguages, cleanUpResolvedThemes, codeToHtml, createAnnotationElement, createAnnotationWrapperNode, createCSSVariablesTheme, createDiffSpanDecoration, createEmptyRowBuffer, createFileHeaderElement, createGutterGap, createGutterItem, createGutterUtilityContentNode, createGutterUtilityElement, createGutterWrapper, createHastElement, createIconElement, createNoNewlineElement, createPreElement, createPreWrapperProperties, createRowNodes, createSeparator, createSpanFromToken, createStyleElement, createTextNodeElement, createTransformerWithState, createUnsafeCSSStyleNode, createWindowFromScrollPosition, diffAcceptRejectHunk, disposeHighlighter, extendFileFormatMap, findCodeElement, formatCSSVariablePrefix, getFiletypeFromFileName, getHighlighterIfLoaded, getHighlighterOptions, getHighlighterThemeStyles, getHunkSeparatorSlotName, getIconForType, getLineAnnotationName, getLineEndingType, getLineNodes, getOrCreateCodeNode, getResolvedLanguages, getResolvedOrResolveLanguage, getResolvedOrResolveTheme, getResolvedThemes, getSharedHighlighter, getSingularPatch, getThemes, getTotalLineCountFromHunks, hasResolvedLanguages, hasResolvedThemes, isDefaultRenderRange, isHighlighterLoaded, isHighlighterLoading, isHighlighterNull, isWorkerContext, parseDiffFromFile, parseLineType, parsePatchFiles, pluckLineSelectionOptions, pluckMouseEventOptions, preloadHighlighter, prerenderHTMLIfNecessary, processFile, processLine, processPatch, pushOrJoinSpan, queueRender, registerCustomCSSVariableTheme, registerCustomLanguage, registerCustomTheme, renderDiffWithHighlighter, renderFileWithHighlighter, resolveLanguage, resolveLanguages, resolveTheme, resolveThemes, setLanguageOverride, setPreNodeProperties, trimPatchContext, wrapCoreCSS, wrapUnsafeCSS };
98
+ export { ALTERNATE_FILE_NAMES_GIT, AttachedLanguages, AttachedThemes, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_EXTENSION_TO_FILE_FORMAT, CodeToTokenTransformStream, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_TAG_NAME, DiffHunksRenderer, EMPTY_RENDER_RANGE, EXTENSION_TO_FILE_FORMAT, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, File, FileDiff, FileRenderer, FileStream, GIT_DIFF_FILE_BREAK_REGEX, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, InteractionManager, RegisteredCustomLanguages, RegisteredCustomThemes, ResizeManager, ResolvedLanguages, ResolvedThemes, ResolvingLanguages, ResolvingThemes, SPLIT_WITH_NEWLINES, SVGSpriteSheet, ScrollSyncManager, ShikiStreamTokenizer, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE, VirtualizedFile, VirtualizedFileDiff, Virtualizer, areDiffLineAnnotationsEqual, areFilesEqual, areHunkDataEqual, areLanguagesAttached, areLineAnnotationsEqual, areObjectsEqual, areOptionsEqual, arePrePropertiesEqual, areRenderRangesEqual, areSelectionsEqual, areThemesAttached, areThemesEqual, areVirtualWindowSpecsEqual, areWorkerStatsEqual, attachResolvedLanguages, attachResolvedThemes, cleanLastNewline, cleanUpResolvedLanguages, cleanUpResolvedThemes, codeToHtml, createAnnotationElement, createAnnotationWrapperNode, createCSSVariablesTheme, createDiffSpanDecoration, createEmptyRowBuffer, createFileHeaderElement, createGutterGap, createGutterItem, createGutterUtilityContentNode, createGutterUtilityElement, createGutterWrapper, createHastElement, createIconElement, createNoNewlineElement, createPreElement, createPreWrapperProperties, createRowNodes, createSeparator, createSpanFromToken, createStyleElement, createTextNodeElement, createTransformerWithState, createUnsafeCSSStyleNode, createWindowFromScrollPosition, diffAcceptRejectHunk, disposeHighlighter, extendFileFormatMap, findCodeElement, formatCSSVariablePrefix, getFiletypeFromFileName, getHighlighterIfLoaded, getHighlighterOptions, getHighlighterThemeStyles, getHunkSeparatorSlotName, getIconForType, getLineAnnotationName, getLineEndingType, getLineNodes, getOrCreateCodeNode, getResolvedLanguages, getResolvedOrResolveLanguage, getResolvedOrResolveTheme, getResolvedThemes, getSharedHighlighter, getSingularPatch, getThemes, getTotalLineCountFromHunks, hasResolvedLanguages, hasResolvedThemes, isDefaultRenderRange, isHighlighterLoaded, isHighlighterLoading, isHighlighterNull, isWorkerContext, parseDiffFromFile, parseLineType, parsePatchFiles, pluckInteractionOptions, preloadHighlighter, prerenderHTMLIfNecessary, processFile, processLine, processPatch, pushOrJoinSpan, queueRender, registerCustomCSSVariableTheme, registerCustomLanguage, registerCustomTheme, renderDiffWithHighlighter, renderFileWithHighlighter, resolveLanguage, resolveLanguages, resolveTheme, resolveThemes, setLanguageOverride, setPreNodeProperties, trimPatchContext, wrapCoreCSS, wrapUnsafeCSS };
@@ -0,0 +1,140 @@
1
+ import { AnnotationSide, DiffLineEventBaseProps, ExpansionDirections, LineEventBaseProps, SelectionSide } from "../types.js";
2
+
3
+ //#region src/managers/InteractionManager.d.ts
4
+ type LogTypes = 'click' | 'move' | 'both' | 'none';
5
+ type InteractionManagerMode = 'file' | 'diff';
6
+ interface OnLineClickProps extends LineEventBaseProps {
7
+ event: PointerEvent;
8
+ }
9
+ interface OnLineEnterLeaveProps extends LineEventBaseProps {
10
+ event: PointerEvent;
11
+ }
12
+ interface OnDiffLineClickProps extends DiffLineEventBaseProps {
13
+ event: PointerEvent;
14
+ }
15
+ interface OnDiffLineEnterLeaveProps extends DiffLineEventBaseProps {
16
+ event: PointerEvent;
17
+ }
18
+ interface SelectedLineRange {
19
+ start: number;
20
+ side?: SelectionSide;
21
+ end: number;
22
+ endSide?: SelectionSide;
23
+ }
24
+ type GetLineIndexUtility = (lineNumber: number, side?: SelectionSide) => [number, number] | undefined;
25
+ type EventClickProps<TMode extends InteractionManagerMode> = TMode extends 'file' ? OnLineClickProps : OnDiffLineClickProps;
26
+ type PointerEventEnterLeaveProps<TMode extends InteractionManagerMode> = TMode extends 'file' ? OnLineEnterLeaveProps : OnDiffLineEnterLeaveProps;
27
+ type GetHoveredLineResult<TMode extends InteractionManagerMode> = TMode extends 'file' ? {
28
+ lineNumber: number;
29
+ } : {
30
+ lineNumber: number;
31
+ side: AnnotationSide;
32
+ };
33
+ interface InteractionManagerBaseOptions<TMode extends InteractionManagerMode> {
34
+ lineHoverHighlight?: 'disabled' | 'both' | 'number' | 'line';
35
+ enableGutterUtility?: boolean;
36
+ onGutterUtilityClick?(range: SelectedLineRange): unknown;
37
+ onLineClick?(props: EventClickProps<TMode>): unknown;
38
+ onLineNumberClick?(props: EventClickProps<TMode>): unknown;
39
+ onLineEnter?(props: PointerEventEnterLeaveProps<TMode>): unknown;
40
+ onLineLeave?(props: PointerEventEnterLeaveProps<TMode>): unknown;
41
+ __debugPointerEvents?: LogTypes;
42
+ enableLineSelection?: boolean;
43
+ onLineSelected?: (range: SelectedLineRange | null) => void;
44
+ onLineSelectionStart?: (range: SelectedLineRange | null) => void;
45
+ onLineSelectionChange?: (range: SelectedLineRange | null) => void;
46
+ onLineSelectionEnd?: (range: SelectedLineRange | null) => void;
47
+ getLineIndex?: GetLineIndexUtility;
48
+ }
49
+ interface InteractionManagerOptions<TMode extends InteractionManagerMode> extends InteractionManagerBaseOptions<TMode> {
50
+ usesCustomGutterUtility?: boolean;
51
+ onHunkExpand?(hunkIndex: number, direction: ExpansionDirections, expandFully?: boolean): unknown;
52
+ }
53
+ declare class InteractionManager<TMode extends InteractionManagerMode> {
54
+ private mode;
55
+ private options;
56
+ private hoveredLine;
57
+ private pre;
58
+ private gutterUtilityContainer;
59
+ private gutterUtilityButton;
60
+ private gutterUtilitySlot;
61
+ private interactiveLinesAttr;
62
+ private interactiveLineNumbersAttr;
63
+ private hasPointerListeners;
64
+ private hasDocumentPointerListeners;
65
+ private selectedRange;
66
+ private renderedSelectionRange;
67
+ private selectionAnchor;
68
+ private queuedSelectionRender;
69
+ private pointerSession;
70
+ constructor(mode: TMode, options: InteractionManagerOptions<TMode>);
71
+ setOptions(options: InteractionManagerOptions<TMode>): void;
72
+ cleanUp(): void;
73
+ setup(pre: HTMLPreElement): void;
74
+ setSelectionDirty(): void;
75
+ isSelectionDirty(): boolean;
76
+ setSelection(range: SelectedLineRange | null): void;
77
+ getSelection(): SelectedLineRange | null;
78
+ getHoveredLine: () => GetHoveredLineResult<TMode> | undefined;
79
+ handlePointerClick: (event: MouseEvent) => void;
80
+ handlePointerMove: (event: PointerEvent) => void;
81
+ handlePointerLeave: (event: PointerEvent) => void;
82
+ private handlePointerEvent;
83
+ private syncPointerListeners;
84
+ private updateInteractiveLineAttributes;
85
+ private handlePointerDown;
86
+ private startLineSelectionFromPointerDown;
87
+ private startGutterSelectionFromPointerDown;
88
+ private handleDocumentPointerMove;
89
+ private handleDocumentPointerUp;
90
+ private handleDocumentPointerCancel;
91
+ private clearHoveredLine;
92
+ private setHoveredLine;
93
+ private ensureGutterUtilityNode;
94
+ private attachDocumentPointerListeners;
95
+ private detachDocumentPointerListeners;
96
+ private clearPointerSession;
97
+ private clearPendingSingleLineState;
98
+ private getSelectionPointerInfo;
99
+ private getSelectionPointFromPath;
100
+ private getLineIndex;
101
+ private updateSelection;
102
+ private getIndexesFromSelection;
103
+ private renderSelection;
104
+ private notifySelectionCommitted;
105
+ private notifySelectionChangeDelta;
106
+ private notifySelectionStart;
107
+ private notifySelectionEnd;
108
+ private toEventBaseProps;
109
+ private buildSelectedLineRange;
110
+ private buildSelectionRange;
111
+ private resolvePointerTarget;
112
+ private isSplitDiff;
113
+ private parseLineIndex;
114
+ }
115
+ type InteractionPluckOptions<TMode extends InteractionManagerMode> = InteractionManagerBaseOptions<TMode> & {
116
+ enableHoverUtility?: boolean;
117
+ renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<TMode> | undefined): HTMLElement | null;
118
+ renderHoverUtility?(getHoveredRow: () => GetHoveredLineResult<TMode> | undefined): HTMLElement | null;
119
+ };
120
+ declare function pluckInteractionOptions<TMode extends InteractionManagerMode>({
121
+ enableGutterUtility,
122
+ enableHoverUtility,
123
+ lineHoverHighlight,
124
+ onGutterUtilityClick,
125
+ onLineClick,
126
+ onLineEnter,
127
+ onLineLeave,
128
+ onLineNumberClick,
129
+ renderGutterUtility,
130
+ renderHoverUtility,
131
+ __debugPointerEvents,
132
+ enableLineSelection,
133
+ onLineSelected,
134
+ onLineSelectionStart,
135
+ onLineSelectionChange,
136
+ onLineSelectionEnd
137
+ }: InteractionPluckOptions<TMode>, onHunkExpand?: (hunkIndex: number, direction: ExpansionDirections, expandFully?: boolean) => unknown, getLineIndex?: GetLineIndexUtility): InteractionManagerOptions<TMode>;
138
+ //#endregion
139
+ export { GetHoveredLineResult, GetLineIndexUtility, InteractionManager, InteractionManagerBaseOptions, InteractionManagerMode, InteractionManagerOptions, LogTypes, OnDiffLineClickProps, OnDiffLineEnterLeaveProps, OnLineClickProps, OnLineEnterLeaveProps, SelectedLineRange, pluckInteractionOptions };
140
+ //# sourceMappingURL=InteractionManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InteractionManager.d.ts","names":["AnnotationSide","DiffLineEventBaseProps","ExpansionDirections","LineEventBaseProps","SelectionSide","LogTypes","InteractionManagerMode","OnLineClickProps","PointerEvent","OnLineEnterLeaveProps","OnDiffLineClickProps","OnDiffLineEnterLeaveProps","SelectedLineRange","GetLineIndexUtility","EventClickProps","TMode","PointerEventEnterLeaveProps","GetHoveredLineResult","InteractionManagerBaseOptions","InteractionManagerOptions","InteractionManager","HTMLPreElement","MouseEvent","InteractionPluckOptions","HTMLElement","pluckInteractionOptions","enableGutterUtility","enableHoverUtility","lineHoverHighlight","onGutterUtilityClick","onLineClick","onLineEnter","onLineLeave","onLineNumberClick","renderGutterUtility","renderHoverUtility","__debugPointerEvents","enableLineSelection","onLineSelected","onLineSelectionStart","onLineSelectionChange","onLineSelectionEnd"],"sources":["../../src/managers/InteractionManager.d.ts"],"sourcesContent":["import type { AnnotationSide, DiffLineEventBaseProps, ExpansionDirections, LineEventBaseProps, SelectionSide } from '../types';\nexport type LogTypes = 'click' | 'move' | 'both' | 'none';\nexport type InteractionManagerMode = 'file' | 'diff';\nexport interface OnLineClickProps extends LineEventBaseProps {\n event: PointerEvent;\n}\nexport interface OnLineEnterLeaveProps extends LineEventBaseProps {\n event: PointerEvent;\n}\nexport interface OnDiffLineClickProps extends DiffLineEventBaseProps {\n event: PointerEvent;\n}\nexport interface OnDiffLineEnterLeaveProps extends DiffLineEventBaseProps {\n event: PointerEvent;\n}\nexport interface SelectedLineRange {\n start: number;\n side?: SelectionSide;\n end: number;\n endSide?: SelectionSide;\n}\nexport type GetLineIndexUtility = (lineNumber: number, side?: SelectionSide) => [number, number] | undefined;\ntype EventClickProps<TMode extends InteractionManagerMode> = TMode extends 'file' ? OnLineClickProps : OnDiffLineClickProps;\ntype PointerEventEnterLeaveProps<TMode extends InteractionManagerMode> = TMode extends 'file' ? OnLineEnterLeaveProps : OnDiffLineEnterLeaveProps;\nexport type GetHoveredLineResult<TMode extends InteractionManagerMode> = TMode extends 'file' ? {\n lineNumber: number;\n} : {\n lineNumber: number;\n side: AnnotationSide;\n};\nexport interface InteractionManagerBaseOptions<TMode extends InteractionManagerMode> {\n lineHoverHighlight?: 'disabled' | 'both' | 'number' | 'line';\n enableGutterUtility?: boolean;\n onGutterUtilityClick?(range: SelectedLineRange): unknown;\n onLineClick?(props: EventClickProps<TMode>): unknown;\n onLineNumberClick?(props: EventClickProps<TMode>): unknown;\n onLineEnter?(props: PointerEventEnterLeaveProps<TMode>): unknown;\n onLineLeave?(props: PointerEventEnterLeaveProps<TMode>): unknown;\n __debugPointerEvents?: LogTypes;\n enableLineSelection?: boolean;\n onLineSelected?: (range: SelectedLineRange | null) => void;\n onLineSelectionStart?: (range: SelectedLineRange | null) => void;\n onLineSelectionChange?: (range: SelectedLineRange | null) => void;\n onLineSelectionEnd?: (range: SelectedLineRange | null) => void;\n getLineIndex?: GetLineIndexUtility;\n}\nexport interface InteractionManagerOptions<TMode extends InteractionManagerMode> extends InteractionManagerBaseOptions<TMode> {\n usesCustomGutterUtility?: boolean;\n onHunkExpand?(hunkIndex: number, direction: ExpansionDirections, expandFully?: boolean): unknown;\n}\nexport declare class InteractionManager<TMode extends InteractionManagerMode> {\n private mode;\n private options;\n private hoveredLine;\n private pre;\n private gutterUtilityContainer;\n private gutterUtilityButton;\n private gutterUtilitySlot;\n private interactiveLinesAttr;\n private interactiveLineNumbersAttr;\n private hasPointerListeners;\n private hasDocumentPointerListeners;\n private selectedRange;\n private renderedSelectionRange;\n private selectionAnchor;\n private queuedSelectionRender;\n private pointerSession;\n constructor(mode: TMode, options: InteractionManagerOptions<TMode>);\n setOptions(options: InteractionManagerOptions<TMode>): void;\n cleanUp(): void;\n setup(pre: HTMLPreElement): void;\n setSelectionDirty(): void;\n isSelectionDirty(): boolean;\n setSelection(range: SelectedLineRange | null): void;\n getSelection(): SelectedLineRange | null;\n getHoveredLine: () => GetHoveredLineResult<TMode> | undefined;\n handlePointerClick: (event: MouseEvent) => void;\n handlePointerMove: (event: PointerEvent) => void;\n handlePointerLeave: (event: PointerEvent) => void;\n private handlePointerEvent;\n private syncPointerListeners;\n private updateInteractiveLineAttributes;\n private handlePointerDown;\n private startLineSelectionFromPointerDown;\n private startGutterSelectionFromPointerDown;\n private handleDocumentPointerMove;\n private handleDocumentPointerUp;\n private handleDocumentPointerCancel;\n private clearHoveredLine;\n private setHoveredLine;\n private ensureGutterUtilityNode;\n private attachDocumentPointerListeners;\n private detachDocumentPointerListeners;\n private clearPointerSession;\n private clearPendingSingleLineState;\n private getSelectionPointerInfo;\n private getSelectionPointFromPath;\n private getLineIndex;\n private updateSelection;\n private getIndexesFromSelection;\n private renderSelection;\n private notifySelectionCommitted;\n private notifySelectionChangeDelta;\n private notifySelectionStart;\n private notifySelectionEnd;\n private toEventBaseProps;\n private buildSelectedLineRange;\n private buildSelectionRange;\n private resolvePointerTarget;\n private isSplitDiff;\n private parseLineIndex;\n}\ntype InteractionPluckOptions<TMode extends InteractionManagerMode> = InteractionManagerBaseOptions<TMode> & {\n enableHoverUtility?: boolean;\n renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<TMode> | undefined): HTMLElement | null;\n renderHoverUtility?(getHoveredRow: () => GetHoveredLineResult<TMode> | undefined): HTMLElement | null;\n};\nexport declare function pluckInteractionOptions<TMode extends InteractionManagerMode>({ enableGutterUtility, enableHoverUtility, lineHoverHighlight, onGutterUtilityClick, onLineClick, onLineEnter, onLineLeave, onLineNumberClick, renderGutterUtility, renderHoverUtility, __debugPointerEvents, enableLineSelection, onLineSelected, onLineSelectionStart, onLineSelectionChange, onLineSelectionEnd }: InteractionPluckOptions<TMode>, onHunkExpand?: (hunkIndex: number, direction: ExpansionDirections, expandFully?: boolean) => unknown, getLineIndex?: GetLineIndexUtility): InteractionManagerOptions<TMode>;\nexport {};\n//# sourceMappingURL=InteractionManager.d.ts.map"],"mappings":";;;KACYK,QAAAA;KACAC,sBAAAA;AADAD,UAEKE,gBAAAA,SAAyBJ,kBAFtB,CAAA;EACRG,KAAAA,EAEDE,YAFCF;AACZ;AAGiBG,UAAAA,qBAAAA,SAA8BN,kBAAAA,CAAAA;EAG9BO,KAAAA,EAFNF,YAEME;AAGjB;AAGiBE,UANAF,oBAAAA,SAA6BT,sBAUnB,CAAA;EAEfY,KAAAA,EAXDL,YAWCK;AAAiG;AAC1EP,UAVlBK,yBAAAA,SAAkCV,sBAUhBK,CAAAA;EAA0BS,KAAAA,EATlDP,YASkDO;;AAA0CL,UAPtFE,iBAAAA,CAOsFF;EAAoB,KAAA,EAAA,MAAA;EACtHM,IAAAA,CAAAA,EANMZ,aAMNY;EAA0CV,GAAAA,EAAAA,MAAAA;EAA0BS,OAAAA,CAAAA,EAJ3DX,aAI2DW;;AAA+CJ,KAF5GE,mBAAAA,GAE4GF,CAAAA,UAAAA,EAAAA,MAAAA,EAAAA,IAAAA,CAAAA,EAF1DP,aAE0DO,EAAAA,GAAAA,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA,GAAAA,SAAAA;KADnHG,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