@pierre/diffs 1.1.19 → 1.2.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CodeView.d.ts +324 -0
- package/dist/components/CodeView.d.ts.map +1 -0
- package/dist/components/CodeView.js +1245 -0
- package/dist/components/CodeView.js.map +1 -0
- package/dist/components/File.d.ts +13 -12
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +68 -28
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +9 -10
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +57 -30
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/FileStream.js +9 -3
- package/dist/components/FileStream.js.map +1 -1
- package/dist/components/VirtualizedFile.d.ts +28 -5
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +225 -45
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +28 -5
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +285 -49
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/components/Virtualizer.d.ts +6 -3
- package/dist/components/Virtualizer.d.ts.map +1 -1
- package/dist/components/Virtualizer.js +4 -6
- package/dist/components/Virtualizer.js.map +1 -1
- package/dist/components/VirtulizerDevelopment.d.ts +2 -2
- package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
- package/dist/constants.d.ts +6 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +17 -2
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +11 -10
- package/dist/managers/InteractionManager.d.ts +11 -7
- package/dist/managers/InteractionManager.d.ts.map +1 -1
- package/dist/managers/InteractionManager.js +38 -25
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/managers/ResizeManager.d.ts +4 -4
- package/dist/managers/ResizeManager.d.ts.map +1 -1
- package/dist/managers/ResizeManager.js +89 -54
- package/dist/managers/ResizeManager.js.map +1 -1
- package/dist/managers/UniversalRenderingManager.d.ts +2 -1
- package/dist/managers/UniversalRenderingManager.d.ts.map +1 -1
- package/dist/managers/UniversalRenderingManager.js +13 -16
- package/dist/managers/UniversalRenderingManager.js.map +1 -1
- package/dist/react/CodeView.d.ts +45 -0
- package/dist/react/CodeView.d.ts.map +1 -0
- package/dist/react/CodeView.js +241 -0
- package/dist/react/CodeView.js.map +1 -0
- package/dist/react/File.d.ts +0 -1
- package/dist/react/File.d.ts.map +1 -1
- package/dist/react/File.js +2 -3
- package/dist/react/File.js.map +1 -1
- package/dist/react/FileDiff.d.ts +0 -1
- package/dist/react/FileDiff.d.ts.map +1 -1
- package/dist/react/FileDiff.js +3 -4
- package/dist/react/FileDiff.js.map +1 -1
- package/dist/react/MultiFileDiff.d.ts +0 -1
- package/dist/react/MultiFileDiff.d.ts.map +1 -1
- package/dist/react/MultiFileDiff.js +3 -4
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/PatchDiff.d.ts +0 -1
- package/dist/react/PatchDiff.d.ts.map +1 -1
- package/dist/react/PatchDiff.js +3 -4
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/UnresolvedFile.d.ts +0 -1
- package/dist/react/UnresolvedFile.d.ts.map +1 -1
- package/dist/react/UnresolvedFile.js +3 -4
- package/dist/react/UnresolvedFile.js.map +1 -1
- package/dist/react/index.d.ts +3 -2
- package/dist/react/index.js +5 -4
- package/dist/react/jsx.d.ts.map +1 -1
- package/dist/react/types.d.ts +0 -8
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.d.ts +0 -2
- package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.js +3 -4
- package/dist/react/utils/renderDiffChildren.js.map +1 -1
- package/dist/react/utils/renderFileChildren.d.ts +0 -2
- package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
- package/dist/react/utils/renderFileChildren.js +3 -4
- package/dist/react/utils/renderFileChildren.js.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js +12 -7
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.js +12 -7
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.js +6 -2
- package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +2 -1
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +35 -20
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.d.ts +2 -1
- package/dist/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/renderers/FileRenderer.js +34 -20
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/preloadDiffs.js +1 -1
- package/dist/style.js +1 -1
- package/dist/style.js.map +1 -1
- package/dist/types.d.ts +98 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/areManagedSnapshotsEqual.d.ts +7 -0
- package/dist/utils/areManagedSnapshotsEqual.d.ts.map +1 -0
- package/dist/utils/areManagedSnapshotsEqual.js +15 -0
- package/dist/utils/areManagedSnapshotsEqual.js.map +1 -0
- package/dist/utils/areOptionsEqual.d.ts +2 -1
- package/dist/utils/areOptionsEqual.d.ts.map +1 -1
- package/dist/utils/areOptionsEqual.js +1 -1
- package/dist/utils/areOptionsEqual.js.map +1 -1
- package/dist/utils/createFileHeaderElement.d.ts +3 -1
- package/dist/utils/createFileHeaderElement.d.ts.map +1 -1
- package/dist/utils/createFileHeaderElement.js +3 -2
- package/dist/utils/createFileHeaderElement.js.map +1 -1
- package/dist/utils/createWindowFromScrollPosition.d.ts +3 -3
- package/dist/utils/createWindowFromScrollPosition.d.ts.map +1 -1
- package/dist/utils/createWindowFromScrollPosition.js +6 -6
- package/dist/utils/createWindowFromScrollPosition.js.map +1 -1
- package/dist/utils/iterateOverDiff.d.ts +2 -1
- package/dist/utils/iterateOverDiff.d.ts.map +1 -1
- package/dist/utils/iterateOverDiff.js +135 -7
- package/dist/utils/iterateOverDiff.js.map +1 -1
- package/dist/utils/parsePatchFiles.js +2 -2
- package/dist/utils/parsePatchFiles.js.map +1 -1
- package/dist/utils/renderFileWithHighlighter.js +1 -1
- package/dist/utils/resolveVirtualFileMetrics.d.ts +4 -1
- package/dist/utils/resolveVirtualFileMetrics.d.ts.map +1 -1
- package/dist/utils/resolveVirtualFileMetrics.js +11 -1
- package/dist/utils/resolveVirtualFileMetrics.js.map +1 -1
- package/dist/utils/roundToDevicePixel.d.ts +14 -0
- package/dist/utils/roundToDevicePixel.d.ts.map +1 -0
- package/dist/utils/roundToDevicePixel.js +18 -0
- package/dist/utils/roundToDevicePixel.js.map +1 -0
- package/dist/worker/worker-portable.js +195 -14
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +146 -7
- package/dist/worker/worker.js.map +1 -1
- package/package.json +10 -1
- package/dist/components/AdvancedVirtualizedFileDiff.d.ts +0 -40
- package/dist/components/AdvancedVirtualizedFileDiff.d.ts.map +0 -1
- package/dist/components/AdvancedVirtualizedFileDiff.js +0 -140
- package/dist/components/AdvancedVirtualizedFileDiff.js.map +0 -1
- package/dist/components/AdvancedVirtualizer.d.ts +0 -38
- package/dist/components/AdvancedVirtualizer.d.ts.map +0 -1
- package/dist/components/AdvancedVirtualizer.js +0 -201
- package/dist/components/AdvancedVirtualizer.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeView.js","names":["renderedItems: CodeViewRenderedItem<LAnnotation>[]","nextItems: CodeViewContextItem<LAnnotation>[]","nextIdToItem: Map<\n string,\n CodeViewContextItem<LAnnotation>\n >","nextInstanceToItem: Map<\n VirtualizedFileDiff<LAnnotation> | VirtualizedFile<LAnnotation>,\n CodeViewContextItem<LAnnotation>\n >","firstDirtyIndex: number | undefined","prevElement: HTMLElement | undefined","slotSnapshot: CodeViewRenderedItem<LAnnotation>[]"],"sources":["../../src/components/CodeView.ts"],"sourcesContent":["import {\n DEFAULT_CODE_VIEW_FILE_METRICS,\n DEFAULT_CODE_VIEW_METRICS,\n DEFAULT_SMOOTH_SCROLL_SETTINGS,\n DEFAULT_THEMES,\n DIFFS_TAG_NAME,\n} from '../constants';\nimport type {\n SelectedLineRange,\n SelectionWriteOptions,\n} from '../managers/InteractionManager';\nimport {\n dequeueRender,\n queueRender,\n} from '../managers/UniversalRenderingManager';\nimport type {\n CodeViewDiffItem,\n CodeViewFileItem,\n CodeViewItem,\n CodeViewItemScrollTarget,\n CodeViewItemVersion,\n CodeViewLineScrollTarget,\n CodeViewMetrics,\n CodeViewPositionScrollTarget,\n CodeViewScrollBehavior,\n CodeViewScrollTarget,\n HunkSeparators,\n SelectionSide,\n SmoothScrollSettings,\n VirtualFileMetrics,\n VirtualWindowSpecs,\n} from '../types';\nimport { areObjectsEqual } from '../utils/areObjectsEqual';\nimport { areSelectionsEqual } from '../utils/areSelectionsEqual';\nimport { createWindowFromScrollPosition } from '../utils/createWindowFromScrollPosition';\nimport { roundToDevicePixel } from '../utils/roundToDevicePixel';\nimport type { WorkerPoolManager } from '../worker';\nimport type { FileOptions } from './File';\nimport type { FileDiffOptions } from './FileDiff';\nimport { VirtualizedFile } from './VirtualizedFile';\nimport { VirtualizedFileDiff } from './VirtualizedFileDiff';\nimport type { VirtualizerConfig } from './Virtualizer';\n\n// When re-rendering content of the virtualizer, it's important that we\n// maintain a visual anchor, usually this is the first fully visible element,\n// whether it's an Item (a file or diff header), or a specific line. If the\n// rendered content ever ends up shifting things around, we'll need to reset\n// the new position back to the viewportOffset, relative to where that element\n// currently is\ninterface ItemAnchor {\n type: 'item';\n id: string;\n viewportOffset: number;\n}\n\ninterface LineAnchor {\n type: 'line';\n id: string;\n lineNumber: number;\n side: SelectionSide | undefined;\n viewportOffset: number;\n}\n\ntype ScrollAnchor = ItemAnchor | LineAnchor;\n\ninterface LineScrollPosition {\n top: number;\n height: number;\n}\n\ninterface AdvancedVirtualizedBaseItem {\n /** Current index of this record in the ordered items array. */\n index: number;\n /** Absolute top offset of this item inside the scroll content. */\n top: number;\n /** Total measured height reserved for this item. */\n height: number;\n /** Root <diffs-container> node currently mounted for this item, only exists\n * when rendered. */\n element: HTMLElement | undefined;\n /** Last controlled version observed for this record. */\n version: CodeViewItemVersion | undefined;\n}\n\ninterface CodeViewDiffItemContext<\n LAnnotation,\n> extends AdvancedVirtualizedBaseItem {\n type: 'diff';\n /** Latest item snapshot for this record. Controlled updates can replace it. */\n item: CodeViewDiffItem<LAnnotation>;\n /** Virtualized diff instance responsible for rendering this item. */\n instance: VirtualizedFileDiff<LAnnotation>;\n}\n\ninterface CodeViewFileItemContext<\n LAnnotation,\n> extends AdvancedVirtualizedBaseItem {\n type: 'file';\n /** Latest item snapshot for this record. Controlled updates can replace it. */\n item: CodeViewFileItem<LAnnotation>;\n /** Virtualized file instance responsible for rendering this item. */\n instance: VirtualizedFile<LAnnotation>;\n}\n\ntype CodeViewContextItem<LAnnotation> =\n | CodeViewDiffItemContext<LAnnotation>\n | CodeViewFileItemContext<LAnnotation>;\n\nexport interface CodeViewRenderedDiffItem<LAnnotation> {\n id: string;\n type: 'diff';\n item: CodeViewDiffItem<LAnnotation>;\n version: CodeViewItemVersion | undefined;\n element: HTMLElement;\n instance: VirtualizedFileDiff<LAnnotation>;\n}\n\nexport interface CodeViewRenderedFileItem<LAnnotation> {\n id: string;\n type: 'file';\n item: CodeViewFileItem<LAnnotation>;\n version: CodeViewItemVersion | undefined;\n element: HTMLElement;\n instance: VirtualizedFile<LAnnotation>;\n}\n\nexport type CodeViewRenderedItem<LAnnotation> =\n | CodeViewRenderedDiffItem<LAnnotation>\n | CodeViewRenderedFileItem<LAnnotation>;\n\nexport interface CodeViewLineSelection {\n id: string;\n range: SelectedLineRange;\n}\n\nexport interface CodeViewCoordinator<LAnnotation> {\n hasHeaderRenderers: boolean;\n hasAnnotationRenderer: boolean;\n hasGutterRenderer: boolean;\n onSnapshotChange(\n snapshot: CodeViewRenderedItem<LAnnotation>[] | undefined\n ): void;\n}\n\nexport type CodeViewScrollListener<LAnnotation> = (\n scrollTop: number,\n viewer: CodeView<LAnnotation>\n) => void;\n\ntype OverloadCallbackArgs<TCallback> = TCallback extends (\n ...args: infer TArgs\n) => unknown\n ? TArgs\n : never;\n\ntype CallbackReturn<TCallback> = TCallback extends (\n ...args: never[]\n) => infer TReturn\n ? TReturn\n : never;\n\ntype OverloadFileCallbackArgs<\n LAnnotation,\n TKey extends keyof FileOptions<LAnnotation>,\n> = OverloadCallbackArgs<NonNullable<FileOptions<LAnnotation>[TKey]>>;\n\ntype OverloadDiffCallbackArgs<\n LAnnotation,\n TKey extends keyof FileDiffOptions<LAnnotation>,\n> = OverloadCallbackArgs<NonNullable<FileDiffOptions<LAnnotation>[TKey]>>;\n\ntype CodeViewFileOptionCallback<\n LAnnotation,\n TKey extends keyof FileOptions<LAnnotation>,\n> = (\n ...args: [\n ...OverloadFileCallbackArgs<LAnnotation, TKey>,\n context: CodeViewFileItemContext<LAnnotation>,\n ]\n) => CallbackReturn<NonNullable<FileOptions<LAnnotation>[TKey]>>;\n\ntype CodeViewDiffOptionCallback<\n LAnnotation,\n TKey extends keyof FileDiffOptions<LAnnotation>,\n> = (\n ...args: [\n ...OverloadDiffCallbackArgs<LAnnotation, TKey>,\n context: CodeViewDiffItemContext<LAnnotation>,\n ]\n) => CallbackReturn<NonNullable<FileDiffOptions<LAnnotation>[TKey]>>;\n\ntype CodeViewOptionCallback<\n LAnnotation,\n TKey extends keyof FileOptions<LAnnotation> &\n keyof FileDiffOptions<LAnnotation>,\n> = {\n (\n ...args: [\n ...OverloadFileCallbackArgs<LAnnotation, TKey>,\n context: CodeViewFileItemContext<LAnnotation>,\n ]\n ): CallbackReturn<NonNullable<FileOptions<LAnnotation>[TKey]>>;\n (\n ...args: [\n ...OverloadDiffCallbackArgs<LAnnotation, TKey>,\n context: CodeViewDiffItemContext<LAnnotation>,\n ]\n ): CallbackReturn<NonNullable<FileDiffOptions<LAnnotation>[TKey]>>;\n};\n\nconst CODE_VIEW_DIFF_OPTION_KEYS = [\n 'theme',\n 'disableLineNumbers',\n 'overflow',\n 'themeType',\n 'disableFileHeader',\n 'disableVirtualizationBuffers',\n 'preferredHighlighter',\n 'useCSSClasses',\n 'useTokenTransformer',\n 'tokenizeMaxLineLength',\n 'tokenizeMaxLength',\n 'unsafeCSS',\n 'diffStyle',\n 'diffIndicators',\n 'disableBackground',\n 'expandUnchanged',\n 'collapsedContextThreshold',\n 'lineDiffType',\n 'maxLineDiffLength',\n 'expansionLineCount',\n 'lineHoverHighlight',\n 'enableTokenInteractionsOnWhitespace',\n 'enableGutterUtility',\n '__debugPointerEvents',\n 'enableLineSelection',\n 'controlledSelection',\n 'disableErrorHandling',\n] as const;\n\ntype CodeViewDiffOptionKeys = (typeof CODE_VIEW_DIFF_OPTION_KEYS)[number];\n\nconst CODE_VIEW_FILE_OPTION_KEYS = [\n 'theme',\n 'disableLineNumbers',\n 'overflow',\n 'themeType',\n 'disableFileHeader',\n 'disableVirtualizationBuffers',\n 'preferredHighlighter',\n 'useCSSClasses',\n 'useTokenTransformer',\n 'tokenizeMaxLineLength',\n 'tokenizeMaxLength',\n 'unsafeCSS',\n 'lineHoverHighlight',\n 'enableTokenInteractionsOnWhitespace',\n 'enableGutterUtility',\n '__debugPointerEvents',\n 'enableLineSelection',\n 'controlledSelection',\n 'disableErrorHandling',\n] as const;\n\ntype CodeViewPassThroughOptions<LAnnotation> = Pick<\n FileDiffOptions<LAnnotation>,\n CodeViewDiffOptionKeys\n>;\n\ntype CodeViewMode = 'file' | 'diff';\n\ntype CodeViewModeItemContext<\n LAnnotation,\n TMode extends CodeViewMode,\n> = TMode extends 'file'\n ? CodeViewFileItemContext<LAnnotation>\n : CodeViewDiffItemContext<LAnnotation>;\n\ntype CodeViewModeOptionCallback<\n LAnnotation,\n TMode extends CodeViewMode,\n TKey extends CodeViewSharedCallbackKeys | CodeViewSelectionCallbackKeys,\n> = TMode extends 'file'\n ? CodeViewFileOptionCallback<LAnnotation, TKey>\n : CodeViewDiffOptionCallback<LAnnotation, TKey>;\n\ntype CodeViewModeInternalOptionCallback<\n LAnnotation,\n TMode extends CodeViewMode,\n TKey extends CodeViewSharedCallbackKeys | CodeViewSelectionCallbackKeys,\n> = (\n ...args: [\n ...OverloadCallbackArgs<\n NonNullable<CodeViewModeOptions<LAnnotation, TMode>[TKey]>\n >,\n CodeViewModeItemContext<LAnnotation, TMode>,\n ]\n) => CallbackReturn<NonNullable<CodeViewModeOptions<LAnnotation, TMode>[TKey]>>;\n\ntype CodeViewModeOptions<\n LAnnotation,\n TMode extends CodeViewMode,\n> = TMode extends 'file'\n ? FileOptions<LAnnotation>\n : FileDiffOptions<LAnnotation>;\n\nconst CODE_VIEW_SHARED_CALLBACK_KEYS = [\n 'renderCustomHeader',\n 'renderHeaderPrefix',\n 'renderHeaderMetadata',\n 'renderAnnotation',\n 'renderGutterUtility',\n 'onPostRender',\n 'onGutterUtilityClick',\n 'onLineClick',\n 'onLineNumberClick',\n 'onLineEnter',\n 'onLineLeave',\n 'onTokenClick',\n 'onTokenEnter',\n 'onTokenLeave',\n] as const;\n\nconst CODE_VIEW_SELECTION_CALLBACK_KEYS = [\n 'onLineSelected',\n 'onLineSelectionStart',\n 'onLineSelectionChange',\n 'onLineSelectionEnd',\n] as const;\n\ntype CodeViewSharedCallbackKeys =\n (typeof CODE_VIEW_SHARED_CALLBACK_KEYS)[number];\n\ntype CodeViewSelectionCallbackKeys =\n (typeof CODE_VIEW_SELECTION_CALLBACK_KEYS)[number];\n\ntype CodeViewSharedCallbackOptions<LAnnotation> = {\n [TKey in CodeViewSharedCallbackKeys]?: CodeViewOptionCallback<\n LAnnotation,\n TKey\n >;\n};\n\ntype CodeViewSelectionCallbackOptions<LAnnotation> = {\n [TKey in CodeViewSelectionCallbackKeys]?: CodeViewOptionCallback<\n LAnnotation,\n TKey\n >;\n};\n\nexport interface CodeViewOptions<LAnnotation>\n extends\n CodeViewPassThroughOptions<LAnnotation>,\n CodeViewSharedCallbackOptions<LAnnotation>,\n CodeViewSelectionCallbackOptions<LAnnotation> {\n hunkSeparators?: Exclude<HunkSeparators, 'custom'>;\n itemMetrics?: VirtualFileMetrics;\n pointerEventsOnScroll?: boolean;\n smoothScrollSettings?: SmoothScrollSettings;\n stickyHeaders?: boolean;\n controlledSelection?: boolean;\n onSelectedLinesChange?(selection: CodeViewLineSelection | null): void;\n viewerMetrics?: CodeViewMetrics;\n}\n\nconst DEFAULT_POINTER_EVENTS_RESTORE_DELAY_MS = 120;\n\ninterface ScrollToAnimation {\n position: number;\n velocity: number;\n lastTimestamp: number;\n}\n\ninterface SpringStepResult {\n position: number;\n velocity: number;\n}\n\ntype PendingAlignTypes = Exclude<CodeViewLineScrollTarget['align'], 'nearest'>;\n\ninterface PendingLineTarget extends Omit<CodeViewLineScrollTarget, 'align'> {\n align?: PendingAlignTypes;\n}\n\ninterface PendingItemTarget extends Omit<CodeViewItemScrollTarget, 'align'> {\n align?: PendingAlignTypes;\n}\n\ntype PendingScrollTarget =\n | CodeViewPositionScrollTarget\n | PendingLineTarget\n | PendingItemTarget;\n\nexport class CodeView<LAnnotation = undefined> {\n static __STOP = false;\n static __lastScrollPosition = 0;\n\n public type = 'advanced' as const;\n public readonly config: VirtualizerConfig = {\n overscrollSize: 200,\n intersectionObserverMargin: 0,\n resizeDebugging: false,\n };\n private items: CodeViewContextItem<LAnnotation>[] = [];\n private idToItem: Map<string, CodeViewContextItem<LAnnotation>> = new Map();\n private selectedLines: CodeViewLineSelection | null = null;\n // NOTE(amadeus): We should probably attach an id to instances and use that\n // for lookups, instead of maintaining this map...\n private instanceToItem: Map<\n VirtualizedFileDiff<LAnnotation> | VirtualizedFile<LAnnotation>,\n CodeViewContextItem<LAnnotation>\n > = new Map();\n private layoutDirtyIndex: number | undefined;\n private slotCoordinator: CodeViewCoordinator<LAnnotation> | undefined;\n private slotSnapshot: CodeViewRenderedItem<LAnnotation>[] | undefined;\n private scrollListeners: Set<CodeViewScrollListener<LAnnotation>> = new Set();\n private scrollHeight = 0;\n private lastContainerHeight = -1;\n private scrollTop: number = 0;\n private scrollDirty = true;\n private pointerEventsRestoreTimer: ReturnType<typeof setTimeout> | undefined;\n private pointerEventsDisabled = false;\n private height: number = 0;\n private heightDirty = true;\n private windowSpecs: VirtualWindowSpecs = { top: 0, bottom: 0 };\n private renderState = {\n scrollTop: -1,\n firstIndex: -1,\n lastIndex: -1,\n stickyHeight: 0,\n stickyTop: -1,\n stickyBottom: -1,\n };\n // Pending scroll target, either instant or smooth. The next render cycle\n // will attempt to resolve it's position instantly or as part of a dynamic\n // animation.\n //\n // - 'item' / 'line' targets stay here until isPendingTargetSettled returns\n // true. Their destination top is re-derived from live layout every frame,\n // absorbing async measurement (annotations, line wrap) that shifts the\n // target mid-flight.\n // - 'position' targets settle on the first frame that applies their\n // scrollTop — there is no layout-dependent destination to chase.\n private pendingScrollTarget: PendingScrollTarget | undefined;\n private pendingLayoutAnchor: ScrollAnchor | undefined;\n\n // Active smooth-scroll animation state. Only populated while a scrollTo\n // with `behavior: 'smooth'` is in flight; cleared on settle (position +\n // velocity within epsilon of the destination) or on user-input abort.\n //\n // - position: current interpolated scrollTop, in CSS pixels.\n // - velocity: rate of change, in CSS pixels per millisecond.\n // - lastTimestamp: High Resolution Time (same clock as RAF timestamps)\n // of the previous integration step.\n private scrollAnimation: ScrollToAnimation | undefined;\n\n private root: HTMLElement | undefined;\n private resizeObserver: ResizeObserver | undefined;\n\n private container: HTMLDivElement | undefined = document.createElement('div');\n private stickyContainer = document.createElement('div');\n private stickyOffset = document.createElement('div');\n private options: CodeViewOptions<LAnnotation>;\n private workerManager: WorkerPoolManager | undefined;\n private isContainerManaged: boolean;\n\n constructor(\n options: CodeViewOptions<LAnnotation> = { theme: DEFAULT_THEMES },\n workerManager?: WorkerPoolManager | undefined,\n isContainerManaged = false\n ) {\n this.options = options;\n this.workerManager = workerManager;\n this.isContainerManaged = isContainerManaged;\n\n this.stickyOffset.style.contain = 'layout size';\n this.stickyContainer.style.position = 'sticky';\n this.stickyContainer.style.width = '100%';\n this.stickyContainer.style.contain = 'layout style inline-size';\n this.stickyContainer.style.isolation = 'isolate';\n this.stickyContainer.style.display = 'flex';\n this.stickyContainer.style.flexDirection = 'column';\n }\n\n private getViewerMetrics(): CodeViewMetrics {\n return this.options.viewerMetrics ?? DEFAULT_CODE_VIEW_METRICS;\n }\n\n private getItemMetrics(): VirtualFileMetrics {\n return this.options.itemMetrics ?? DEFAULT_CODE_VIEW_FILE_METRICS;\n }\n\n private getSmoothScrollSettings(): SmoothScrollSettings {\n return this.options.smoothScrollSettings ?? DEFAULT_SMOOTH_SCROLL_SETTINGS;\n }\n\n private shouldDisablePointerEvents(): boolean {\n return this.options.pointerEventsOnScroll !== true;\n }\n\n private clearPointerEventsTimer(): void {\n if (this.pointerEventsRestoreTimer != null) {\n clearTimeout(this.pointerEventsRestoreTimer);\n this.pointerEventsRestoreTimer = undefined;\n }\n }\n\n private suspendPointerEvents(): void {\n if (!this.shouldDisablePointerEvents()) {\n return;\n }\n\n this.clearPointerEventsTimer();\n if (!this.pointerEventsDisabled) {\n this.stickyContainer.style.pointerEvents = 'none';\n this.pointerEventsDisabled = true;\n }\n this.pointerEventsRestoreTimer = setTimeout(\n this.restorePointerEvents,\n DEFAULT_POINTER_EVENTS_RESTORE_DELAY_MS\n );\n }\n\n private restorePointerEvents = (): void => {\n this.clearPointerEventsTimer();\n if (!this.pointerEventsDisabled) {\n return;\n }\n this.stickyContainer.style.removeProperty('pointer-events');\n this.pointerEventsDisabled = false;\n };\n\n private syncViewerMetrics(): void {\n const { gap, paddingBottom, paddingTop } = this.getViewerMetrics();\n this.stickyContainer.style.gap = `${gap}px`;\n this.container?.style.setProperty('margin-top', `${paddingTop}px`);\n this.container?.style.setProperty('margin-bottom', `${paddingBottom}px`);\n }\n\n public setup(root: HTMLElement): void {\n if (this.root != null) {\n throw new Error('CodeView.setup: already setup');\n }\n this.root = root;\n this.container ??= document.createElement('div');\n this.container.style.contain = 'layout size style';\n this.syncViewerMetrics();\n this.container.appendChild(this.stickyOffset);\n this.container.appendChild(this.stickyContainer);\n this.root.appendChild(this.container);\n this.scrollDirty = true;\n this.heightDirty = true;\n this.resizeObserver = new ResizeObserver(this.handleResize);\n this.resizeObserver.observe(this.stickyContainer);\n this.root.addEventListener('scroll', this.handleScroll, {\n passive: true,\n });\n // Any user-driven scroll intent cancels an in-flight programmatic scroll.\n // pointerdown catches scrollbar drag (the scrollbar belongs to root);\n // wheel / touchstart cover trackpad + touch scroll; keydown covers arrow\n // keys, PgUp/PgDn, Home/End on a focused scroll container.\n this.root.addEventListener('wheel', this.clearPendingScroll, {\n passive: true,\n });\n this.root.addEventListener('touchstart', this.clearPendingScroll, {\n passive: true,\n });\n this.root.addEventListener('pointerdown', this.clearPendingScroll, {\n passive: true,\n });\n this.root.addEventListener('keydown', this.clearPendingScroll, {\n passive: true,\n });\n this.resizeObserver.observe(this.root);\n this.render(true);\n\n // FIXME(amadeus): Remove me before release\n window.__INSTANCE = this;\n window.__TOGGLE = () => {\n if (CodeView.__STOP) {\n CodeView.__STOP = false;\n this.scrollTo({\n type: 'position',\n position: CodeView.__lastScrollPosition,\n behavior: 'instant',\n });\n } else {\n CodeView.__lastScrollPosition = this.getScrollTop();\n CodeView.__STOP = true;\n }\n };\n }\n\n public reset(): void {\n this.restorePointerEvents();\n this.cleanAllRenderedItems();\n this.selectedLines = null;\n this.items.length = 0;\n this.idToItem.clear();\n this.instanceToItem.clear();\n this.layoutDirtyIndex = undefined;\n this.stickyContainer.textContent = '';\n this.stickyOffset.style.height = '';\n this.container?.style.removeProperty('height');\n this.windowSpecs = { top: 0, bottom: 0 };\n this.pendingLayoutAnchor = undefined;\n this.height = 0;\n this.scrollTop = 0;\n this.scrollHeight = 0;\n this.scrollDirty = true;\n this.heightDirty = true;\n this.resetRenderState();\n // NOTE(amadeus): Container managed CodeView controls when flushing\n // occurs. This is mostly to make imperative vanilla js api easier to work\n // with\n if (!this.isContainerManaged) {\n this.flushSlotCoordinator();\n }\n }\n\n public cleanUp(): void {\n this.reset();\n this.restorePointerEvents();\n this.resizeObserver?.disconnect();\n this.resizeObserver = undefined;\n this.root?.removeEventListener('scroll', this.handleScroll);\n this.root?.removeEventListener('wheel', this.clearPendingScroll);\n this.root?.removeEventListener('touchstart', this.clearPendingScroll);\n this.root?.removeEventListener('pointerdown', this.clearPendingScroll);\n this.root?.removeEventListener('keydown', this.clearPendingScroll);\n this.container?.remove();\n this.stickyOffset.remove();\n this.stickyContainer.remove();\n this.stickyContainer.textContent = '';\n this.root = undefined;\n this.container = undefined;\n }\n\n private cleanAllRenderedItems() {\n if (this.renderState.firstIndex === -1) {\n return;\n }\n for (\n let index = this.renderState.firstIndex;\n index <= this.renderState.lastIndex;\n index++\n ) {\n const item = this.items[index];\n if (item == null) {\n throw new Error(\n `CodeView.cleanAllRenderedItems: Item does not exist at index: ${index}`\n );\n }\n cleanRenderedItem(item);\n }\n }\n\n private resolveEffectiveScrollBehavior(\n target: CodeViewScrollTarget,\n destination: number\n ): Exclude<CodeViewScrollBehavior, 'smooth-auto'> {\n if (target.behavior !== 'smooth-auto') {\n return target.behavior ?? 'instant';\n }\n\n return Math.abs(destination - this.getScrollTop()) <= this.getHeight() * 10\n ? 'smooth'\n : 'instant';\n }\n\n public scrollTo(target: CodeViewScrollTarget): void {\n if (this.root == null) {\n return;\n }\n\n const pendingTarget = this.normalizeScrollTarget(target);\n if (pendingTarget == null) {\n return;\n }\n\n const destination = this.resolveScrollTargetTop(pendingTarget);\n if (destination == null) {\n return;\n }\n\n const behavior = this.resolveEffectiveScrollBehavior(\n pendingTarget,\n destination\n );\n if (behavior === 'smooth') {\n // Use ??= so if we have an animation in progress it will be smoothly\n // transitioned into the new target and not reset\n this.scrollAnimation ??= {\n position: this.getScrollTop(),\n velocity: 0,\n // Since we kick off a render to requestAnimationFrame, by initializing\n // lastTimestamp as performance.now() it means we can begin animating\n // on the next render call and not wait a frame to get frame time\n lastTimestamp: performance.now(),\n };\n } else {\n this.scrollAnimation = undefined;\n }\n\n // We'll attempt to scroll to this new target on the next render frame\n this.suspendPointerEvents();\n this.pendingLayoutAnchor = undefined;\n this.pendingScrollTarget = pendingTarget;\n this.render();\n }\n\n public setSelectedLines(\n selection: CodeViewLineSelection | null,\n options?: SelectionWriteOptions\n ): void {\n this.applySelectedLines(selection, options);\n }\n\n public getSelectedLines(): CodeViewLineSelection | null {\n return this.selectedLines;\n }\n\n public clearSelectedLines(options?: SelectionWriteOptions): void {\n this.applySelectedLines(null, options);\n }\n\n public addItem(input: CodeViewItem<LAnnotation>): void {\n this.addItems([input]);\n this.syncSelection();\n }\n\n public addItems(inputs: readonly CodeViewItem<LAnnotation>[]): void {\n this.appendItemsInternal(inputs);\n this.syncSelection();\n }\n\n public setItems(items: readonly CodeViewItem<LAnnotation>[]): void {\n if (items.length === 0) {\n this.reset();\n } else if (this.items.length === 0) {\n this.appendItemsInternal(items);\n } else if (!this.tryAppendItems(items)) {\n this.reconcileItems(items);\n }\n this.syncSelection();\n }\n\n /**\n * Append new records to the viewer while preserving existing layout state.\n * This is the shared path for imperative adds and the append-only reconcile\n * fast path, so it measures new items immediately and only triggers render\n * once at the end.\n */\n private appendItemsInternal(\n inputs: readonly CodeViewItem<LAnnotation>[],\n render = true\n ): void {\n if (inputs.length === 0) {\n return;\n }\n\n const viewerMetrics = this.getViewerMetrics();\n let nextTop =\n this.items.length === 0 ? 0 : this.scrollHeight + viewerMetrics.gap;\n for (let index = 0; index < inputs.length; index++) {\n const input = inputs[index];\n if (input == null) {\n throw new Error('CodeView.appendItemsInternal: missing input item');\n }\n if (this.idToItem.has(input.id)) {\n throw new Error(`CodeView.addItem: duplicate id \"${input.id}\"`);\n }\n\n const item = this.createItem(input, this.items.length, nextTop);\n this.items.push(item);\n this.idToItem.set(item.item.id, item);\n this.instanceToItem.set(item.instance, item);\n item.height = prepareItemInstance(item);\n nextTop += item.height + viewerMetrics.gap;\n }\n\n this.scrollHeight = nextTop - viewerMetrics.gap;\n this.scrollDirty = true;\n if (render) {\n this.render();\n }\n }\n\n public setOptions(options: CodeViewOptions<LAnnotation> | undefined): void {\n if (options == null) {\n return;\n }\n\n this.capturePendingLayoutAnchor();\n const previousViewerMetrics = this.getViewerMetrics();\n const previousItemMetrics = this.getItemMetrics();\n\n // NOTE(amadeus): This is also something that's probably ridiculously\n // expensive to pull off, and we should probably figure out some way to\n // incrementally version/render stuff\n this.options = options;\n const nextItemMetrics = this.getItemMetrics();\n const itemMetricsChanged = !areObjectsEqual(\n previousItemMetrics,\n nextItemMetrics\n );\n if (!areObjectsEqual(previousViewerMetrics, this.getViewerMetrics())) {\n this.syncViewerMetrics();\n }\n for (let index = 0; index < this.items.length; index++) {\n const item = this.items[index];\n if (item == null) {\n throw new Error('CodeView.setOptions: invalid item index');\n }\n\n if (itemMetricsChanged) {\n item.instance.setMetrics(nextItemMetrics, true);\n }\n if (item.type === 'diff') {\n item.instance.setOptions(this.createOptions(item.item));\n } else {\n item.instance.setOptions(this.createOptions(item.item));\n }\n }\n\n this.markLayoutDirtyFromIndex(0);\n this.scrollDirty = true;\n if (!this.isContainerManaged && this.items.length > 0) {\n this.render();\n }\n }\n\n private capturePendingLayoutAnchor(): void {\n if (\n this.root == null ||\n this.items.length === 0 ||\n this.pendingScrollTarget != null\n ) {\n return;\n }\n\n this.pendingLayoutAnchor = this.getScrollAnchor(this.getScrollTop());\n }\n\n public render(immediate = false): void {\n if (CodeView.__STOP) {\n return;\n }\n if (immediate) {\n dequeueRender(this.computeRenderRangeAndEmit);\n this.computeRenderRangeAndEmit();\n } else {\n queueRender(this.computeRenderRangeAndEmit);\n }\n }\n\n public instanceChanged(\n instance: VirtualizedFile<LAnnotation> | VirtualizedFileDiff<LAnnotation>,\n layoutDirty: boolean\n ): void {\n // NOTE(amadeus): This is technically broken at the moment. What we\n // probably SHOULD do to fix is, it push the instance to some sort of\n // instance changed set, then iterate through all items and re-compute\n // everything to get new tops?\n const item = this.instanceToItem.get(instance);\n if (item == null) {\n throw new Error(\n 'CodeView.instanceChanged: An instance has changed that is not registered'\n );\n }\n if (layoutDirty) {\n this.markItemLayoutDirty(item);\n }\n this.render();\n }\n\n public getWindowSpecs(): VirtualWindowSpecs {\n return this.windowSpecs;\n }\n\n public getContainerElement(): HTMLElement | undefined {\n return this.root;\n }\n\n public getRenderedItems(): CodeViewRenderedItem<LAnnotation>[] {\n const { firstIndex, lastIndex } = this.renderState;\n if (firstIndex === -1 || lastIndex === -1 || lastIndex < firstIndex) {\n return [];\n }\n\n const renderedItems: CodeViewRenderedItem<LAnnotation>[] = [];\n\n for (let index = firstIndex; index <= lastIndex; index++) {\n const item = this.items[index];\n if (item?.element == null) {\n continue;\n }\n\n if (item.type === 'diff') {\n renderedItems.push({\n id: item.item.id,\n type: 'diff',\n item: item.item,\n version: item.version,\n element: item.element,\n instance: item.instance,\n });\n } else {\n renderedItems.push({\n id: item.item.id,\n type: 'file',\n item: item.item,\n version: item.version,\n element: item.element,\n instance: item.instance,\n });\n }\n }\n\n return renderedItems;\n }\n\n public setSlotCoordinator(\n coordinator?: CodeViewCoordinator<LAnnotation>\n ): boolean {\n if (coordinator === this.slotCoordinator) {\n return false;\n }\n this.slotCoordinator = coordinator;\n this.slotSnapshot = undefined;\n return true;\n }\n\n public getSlotSnapshot(\n coordinator: CodeViewCoordinator<LAnnotation>\n ): CodeViewRenderedItem<LAnnotation>[] | undefined {\n return getSlotSnapshot(this.getRenderedItems(), coordinator);\n }\n\n public subscribeToScroll(\n listener: CodeViewScrollListener<LAnnotation>\n ): () => void {\n this.scrollListeners.add(listener);\n return () => {\n this.scrollListeners.delete(listener);\n };\n }\n\n public getTopForInstance(\n instance: VirtualizedFile<LAnnotation> | VirtualizedFileDiff<LAnnotation>\n ): number {\n const item = this.instanceToItem.get(instance);\n if (item == null) {\n throw new Error(\n 'CodeView.getTopForInstance: unknown virtualized instance'\n );\n }\n return item.top;\n }\n\n public getTopForItem(id: string): number | undefined {\n const item = this.idToItem.get(id);\n if (item == null) {\n return undefined;\n }\n return item.top;\n }\n\n private createItem(\n input: CodeViewItem<LAnnotation>,\n index: number,\n top: number\n ): CodeViewContextItem<LAnnotation> {\n const itemMetrics = this.getItemMetrics();\n if (input.type === 'diff') {\n return {\n type: 'diff',\n item: input,\n version: input.version,\n index,\n instance: new VirtualizedFileDiff<LAnnotation>(\n this.createOptions(input),\n this,\n itemMetrics,\n this.workerManager,\n this.isContainerManaged\n ),\n top,\n height: 0,\n element: undefined,\n } satisfies CodeViewDiffItemContext<LAnnotation>;\n }\n\n return {\n type: 'file',\n item: input,\n version: input.version,\n index,\n instance: new VirtualizedFile<LAnnotation>(\n this.createOptions(input),\n this,\n itemMetrics,\n this.workerManager,\n this.isContainerManaged\n ),\n top,\n height: 0,\n element: undefined,\n } satisfies CodeViewFileItemContext<LAnnotation>;\n }\n\n private getItemById(\n itemId: string\n ): CodeViewContextItem<LAnnotation> | undefined {\n const item = this.idToItem.get(itemId);\n if (item == null) {\n console.error(`CodeView.getItemById: unknown item id \"${itemId}\"`);\n }\n return item;\n }\n\n private getItemByMode<TMode extends CodeViewMode>(\n itemId: string,\n mode: TMode\n ): CodeViewModeItemContext<LAnnotation, TMode> | undefined {\n const item = this.getItemById(itemId);\n if (item == null) {\n return undefined;\n }\n if (item.type !== mode) {\n console.error(\n `CodeView.getItemByMode: item id \"${itemId}\" is not a ${mode}`\n );\n return undefined;\n }\n return item as CodeViewModeItemContext<LAnnotation, TMode>;\n }\n\n private applySelectedLines(\n selection: CodeViewLineSelection | null,\n options?: SelectionWriteOptions\n ): void {\n const { selectedLines: prevSelection } = this;\n if (\n (selection == null && prevSelection == null) ||\n (selection != null &&\n prevSelection?.id === selection.id &&\n areSelectionsEqual(prevSelection.range, selection.range))\n ) {\n return;\n }\n\n // If we are selecting a new element and had a previous selection, null out\n // the current selection, otherwise if it's a selection on the same item\n // the next selection will take care of that for us\n if (prevSelection != null && prevSelection.id !== selection?.id) {\n this.idToItem\n .get(prevSelection.id)\n ?.instance.setSelectedLines(null, { notify: false });\n }\n\n this.selectedLines = selection;\n this.idToItem\n .get(selection?.id ?? '')\n ?.instance.setSelectedLines(selection?.range ?? null, options);\n }\n\n private syncSelection(): void {\n if (this.selectedLines == null) {\n return;\n }\n\n const item = this.idToItem.get(this.selectedLines.id);\n if (item == null) {\n this.selectedLines = null;\n return;\n }\n\n item.instance.setSelectedLines(this.selectedLines.range, { notify: false });\n }\n\n private wrapCallbackWithContext<\n TMode extends CodeViewMode,\n TArgs extends unknown[],\n TResult,\n >(\n mode: TMode,\n itemId: string,\n callback: (\n ...args: [...TArgs, CodeViewModeItemContext<LAnnotation, TMode>]\n ) => TResult\n ): (...args: TArgs) => TResult | undefined {\n return (...args: TArgs) => {\n const item = this.getItemByMode(itemId, mode);\n if (item == null) {\n return undefined;\n }\n return callback(...args, item);\n };\n }\n\n private getWrappedOptionCallback<\n TMode extends CodeViewMode,\n TKey extends CodeViewSharedCallbackKeys,\n >(\n mode: TMode,\n key: TKey,\n itemId: string\n ): CodeViewModeOptions<LAnnotation, TMode>[TKey] | undefined {\n const callback = this.options[key] as\n | CodeViewModeOptionCallback<LAnnotation, TMode, TKey>\n | undefined;\n if (callback == null) {\n return undefined;\n }\n return this.wrapCallbackWithContext(\n mode,\n itemId,\n callback as CodeViewModeInternalOptionCallback<LAnnotation, TMode, TKey>\n ) as CodeViewModeOptions<LAnnotation, TMode>[TKey] | undefined;\n }\n\n private getWrappedSelectionOptionCallback<\n TMode extends CodeViewMode,\n TKey extends CodeViewSelectionCallbackKeys,\n >(\n mode: TMode,\n key: TKey,\n itemId: string\n ): CodeViewModeOptions<LAnnotation, TMode>[TKey] | undefined {\n if (this.options.enableLineSelection !== true) {\n return undefined;\n }\n const callback = this.options[key] as\n | ((\n range: SelectedLineRange | null,\n context: CodeViewModeItemContext<LAnnotation, TMode>\n ) => unknown)\n | undefined;\n return ((range: SelectedLineRange | null) => {\n const item = this.getItemByMode(itemId, mode);\n if (item == null) {\n return undefined;\n }\n const selection = range == null ? null : { id: itemId, range };\n if (this.options.controlledSelection !== true) {\n if (range != null || this.selectedLines?.id === itemId) {\n this.applySelectedLines(selection, { notify: false });\n }\n }\n this.options.onSelectedLinesChange?.(selection);\n return callback?.(range, item);\n }) as CodeViewModeOptions<LAnnotation, TMode>[TKey] | undefined;\n }\n\n private createOptions(\n item: CodeViewFileItem<LAnnotation>\n ): FileOptions<LAnnotation>;\n private createOptions(\n item: CodeViewDiffItem<LAnnotation>\n ): FileDiffOptions<LAnnotation>;\n private createOptions(\n item: CodeViewItem<LAnnotation>\n ): FileOptions<LAnnotation> | FileDiffOptions<LAnnotation> {\n const { id: itemId, type: mode } = item;\n const options =\n mode === 'file'\n ? ({\n stickyHeader: this.options.stickyHeaders,\n } satisfies FileOptions<LAnnotation>)\n : ({\n stickyHeader: this.options.stickyHeaders,\n hunkSeparators: this.options.hunkSeparators,\n } satisfies FileDiffOptions<LAnnotation>);\n // NOTE(amadeus): Hacks on hacks...\n const target = options as Record<string, unknown>;\n const passThroughKeys =\n mode === 'file' ? CODE_VIEW_FILE_OPTION_KEYS : CODE_VIEW_DIFF_OPTION_KEYS;\n\n for (const key of passThroughKeys) {\n const value = this.options[key];\n if (value !== undefined) {\n target[key] = value;\n }\n }\n target.collapsed = item.collapsed === true;\n\n for (const key of CODE_VIEW_SHARED_CALLBACK_KEYS) {\n const callback = this.getWrappedOptionCallback(mode, key, itemId);\n if (callback !== undefined) {\n target[key] = callback;\n }\n }\n\n for (const key of CODE_VIEW_SELECTION_CALLBACK_KEYS) {\n const callback = this.getWrappedSelectionOptionCallback(\n mode,\n key,\n itemId\n );\n if (callback !== undefined) {\n target[key] = callback;\n }\n }\n\n return options;\n }\n\n /**\n * Track the earliest index whose measured layout may now be stale. Later\n * render passes relayout from this point forward so we do not have to rebuild\n * positions for the whole list after every change.\n */\n private markLayoutDirtyFromIndex(index: number): void {\n this.layoutDirtyIndex = Math.min(this.layoutDirtyIndex ?? index, index);\n }\n\n /**\n * Mark the earliest affected item as layout-dirty after an imperative change.\n * Each record carries its current array index so this stays O(1) even when\n * the viewer holds a very large number of items.\n */\n private markItemLayoutDirty(item: CodeViewContextItem<LAnnotation>): void {\n if (this.items[item.index] !== item) {\n throw new Error(\n `CodeView.markItemLayoutDirty: unknown item id \"${item.item.id}\"`\n );\n }\n\n this.markLayoutDirtyFromIndex(item.index);\n }\n\n /**\n * Detect the common controlled-update case where the new list simply extends\n * the existing ordered prefix. When that happens we can reuse every current\n * record in place, sync any versioned payload changes, and append only the new\n * tail instead of rebuilding the whole list.\n */\n private tryAppendItems(items: readonly CodeViewItem<LAnnotation>[]): boolean {\n if (items.length <= this.items.length) {\n return false;\n }\n\n for (let index = 0; index < this.items.length; index++) {\n const existingItem = this.items[index];\n if (existingItem == null) {\n throw new Error('CodeView.tryAppendItems: missing existing item');\n }\n const nextItem = items[index];\n if (\n nextItem == null ||\n existingItem.item.id !== nextItem.id ||\n existingItem.type !== nextItem.type\n ) {\n return false;\n }\n }\n\n for (let index = 0; index < this.items.length; index++) {\n const existingItem = this.items[index];\n if (existingItem == null) {\n throw new Error('CodeView.tryAppendItems: missing existing item');\n }\n const nextItem = items[index];\n if (nextItem == null) {\n throw new Error(\n 'CodeView.tryAppendItems: append candidate missing prefix item'\n );\n }\n if (this.syncItemRecord(existingItem, nextItem)) {\n this.markLayoutDirtyFromIndex(index);\n }\n }\n\n this.appendItemsInternal(items.slice(this.items.length), false);\n this.scrollDirty = true;\n this.render();\n return true;\n }\n\n /**\n * Reconcile a new controlled item list against the existing records by id.\n * This reuses records and instances when type matches, cleans up removed\n * records, rebuilds the lookup maps, and marks layout dirty whenever order,\n * membership, or versioned item data changes.\n */\n private reconcileItems(items: readonly CodeViewItem<LAnnotation>[]): void {\n const { items: previousItems, idToItem: previousById } = this;\n const removedItems = new Set(previousItems);\n const nextItems: CodeViewContextItem<LAnnotation>[] = [];\n const nextIdToItem: Map<\n string,\n CodeViewContextItem<LAnnotation>\n > = new Map();\n const nextInstanceToItem: Map<\n VirtualizedFileDiff<LAnnotation> | VirtualizedFile<LAnnotation>,\n CodeViewContextItem<LAnnotation>\n > = new Map();\n let firstDirtyIndex: number | undefined;\n\n for (let index = 0; index < items.length; index++) {\n const input = items[index];\n if (input == null) {\n throw new Error('CodeView.reconcileItems: missing input item');\n }\n if (nextIdToItem.has(input.id)) {\n throw new Error(`CodeView.setItems: duplicate id \"${input.id}\"`);\n }\n\n const previousItem = previousById.get(input.id);\n const item =\n previousItem != null && previousItem.type === input.type\n ? previousItem\n : this.createItem(input, index, 0);\n\n item.index = index;\n\n if (previousItem != null && previousItem.type === input.type) {\n removedItems.delete(previousItem);\n if (this.syncItemRecord(item, input)) {\n firstDirtyIndex = Math.min(firstDirtyIndex ?? index, index);\n }\n } else {\n firstDirtyIndex = Math.min(firstDirtyIndex ?? index, index);\n }\n\n if (previousItems[index] !== item) {\n firstDirtyIndex = Math.min(firstDirtyIndex ?? index, index);\n }\n\n nextItems.push(item);\n nextIdToItem.set(input.id, item);\n nextInstanceToItem.set(item.instance, item);\n }\n\n for (let index = 0; index < previousItems.length; index++) {\n const removedItem = previousItems[index];\n if (removedItem == null || !removedItems.has(removedItem)) {\n continue;\n }\n cleanRenderedItem(removedItem);\n const dirtyIndex = Math.max(nextItems.length - 1, 0);\n firstDirtyIndex = Math.min(firstDirtyIndex ?? dirtyIndex, dirtyIndex);\n }\n\n if (firstDirtyIndex == null) {\n return;\n }\n\n this.items = nextItems;\n this.idToItem = nextIdToItem;\n this.instanceToItem = nextInstanceToItem;\n\n if (this.renderState.firstIndex >= nextItems.length) {\n this.resetRenderState();\n } else if (this.renderState.lastIndex >= nextItems.length) {\n this.renderState.lastIndex = nextItems.length - 1;\n }\n\n this.markLayoutDirtyFromIndex(firstDirtyIndex);\n this.scrollDirty = true;\n this.render();\n }\n\n /**\n * Update a reused record from the latest controlled item only when its item\n * version changes. Matching versions mean CodeView keeps the current record\n * snapshot, which lets imperative updates remain in place until the caller\n * intentionally publishes a newer version.\n */\n private syncItemRecord(\n item: CodeViewContextItem<LAnnotation>,\n nextItem: CodeViewItem<LAnnotation>\n ): boolean {\n if (item.type !== nextItem.type) {\n throw new Error(\n `CodeView.syncItemRecord: type mismatch for id \"${nextItem.id}\"`\n );\n }\n\n if (item.version === nextItem.version) {\n return false;\n }\n\n item.item = nextItem;\n item.version = nextItem.version;\n if (item.type === 'diff') {\n item.instance.setOptions(this.createOptions(item.item));\n } else {\n item.instance.setOptions(this.createOptions(item.item));\n }\n return true;\n }\n\n /**\n * Clamps a scroll position to the min/max allowable scroll range based on\n * the computed total height\n */\n private clampScrollTop(value: number): number {\n const { paddingBottom, paddingTop } = this.getViewerMetrics();\n const maxScroll = Math.max(\n paddingTop + this.getScrollHeight() + paddingBottom - this.getHeight(),\n 0\n );\n return Math.max(0, Math.min(value, maxScroll));\n }\n\n private getStickyHeaderOffset(): number {\n return this.options.stickyHeaders === true &&\n this.options.disableFileHeader !== true\n ? this.getItemMetrics().diffHeaderHeight\n : 0;\n }\n\n private getScrollTargetRect(\n target: CodeViewItemScrollTarget | CodeViewLineScrollTarget\n ): { top: number; height: number } | undefined {\n const item = this.idToItem.get(target.id);\n if (item == null) {\n console.warn(`CodeView.scrollTo: unknown item id \"${target.id}\"`);\n return undefined;\n }\n\n if (target.type === 'item') {\n return { top: item.top, height: item.height };\n }\n\n const linePosition = this.getLineScrollPosition(item, target);\n if (linePosition == null) {\n console.warn(\n `CodeView.scrollTo: unable to resolve line ${target.lineNumber} for item \"${target.id}\"`\n );\n return undefined;\n }\n\n return {\n top: item.top + linePosition.top,\n height: linePosition.height,\n };\n }\n\n private normalizeScrollTarget(\n target: CodeViewScrollTarget\n ): PendingScrollTarget | undefined {\n if (target.type === 'position' || target.align !== 'nearest') {\n return target as PendingScrollTarget;\n }\n\n const rect = this.getScrollTargetRect(target);\n if (rect == null) {\n return undefined;\n }\n\n // Determine a stable scrollTo target for `nearest` alignment. This is to\n // ensure that we don't experience any scroll bouncing\n const offset = target.offset ?? 0;\n const targetTop = this.getViewerMetrics().paddingTop + rect.top;\n const targetBottom = targetTop + rect.height;\n const currentTop = this.getScrollTop();\n const visibleTop =\n currentTop + (target.type === 'line' ? this.getStickyHeaderOffset() : 0);\n const visibleBottom = currentTop + this.getHeight();\n\n // If the item is spanning beyond the full viewport,\n // do nothing as it's already in view\n if (\n targetTop - offset <= visibleTop &&\n targetBottom + offset >= visibleBottom\n ) {\n return undefined;\n }\n\n // Let's use the top as the target\n if (targetTop - offset < visibleTop) {\n return { ...target, align: 'start' };\n }\n\n // Let's use the top as the target\n if (targetBottom + offset > visibleBottom) {\n return { ...target, align: 'end' };\n }\n\n // The element is already in view, nothing to do.\n return undefined;\n }\n\n /**\n * Resolve a target's scroll position\n\n * Returns `undefined` when we can't resolve a target for whatever reason\n */\n private resolveScrollTargetTop(\n target: PendingScrollTarget\n ): number | undefined {\n if (target.type === 'position') {\n const clampedPosition = this.clampScrollTop(target.position);\n return clampedPosition !== target.position\n ? // If our position was clamped, we we shouldn't apply the sticky offset\n clampedPosition\n : this.clampScrollTop(target.position - this.getStickyHeaderOffset());\n }\n\n const item = this.idToItem.get(target.id);\n if (item == null) {\n console.warn(`CodeView.scrollTo: unknown item id \"${target.id}\"`);\n return undefined;\n }\n\n if (target.type === 'item') {\n return this.clampScrollTop(\n this.resolveAlignedScrollPosition(\n item.top,\n item.height,\n target.align,\n target.offset\n )\n );\n }\n\n const linePosition = this.getLineScrollPosition(item, target);\n if (linePosition == null) {\n console.warn(\n `CodeView.scrollTo: unable to resolve line ${target.lineNumber} for item \"${target.id}\"`\n );\n return undefined;\n }\n\n return this.clampScrollTop(\n this.resolveAlignedScrollPosition(\n item.top + linePosition.top,\n linePosition.height,\n target.align,\n target.offset,\n this.getStickyHeaderOffset()\n )\n );\n }\n\n /**\n * Given an existing scroll target (scroll top and height), figure out the\n * correct scroll position to target based on the desired alignment, offset\n * and stickyOffset if necessary\n */\n private resolveAlignedScrollPosition(\n // REVIEW: lets turn this into a named interface object, essentially named\n // arguments that can't be confused/reversed\n targetTop: number,\n targetHeight: number,\n align: PendingAlignTypes,\n offset = 0,\n stickyOffset = 0\n ): number {\n targetTop += this.getViewerMetrics().paddingTop;\n const viewportHeight = this.getHeight();\n // If the item + offset is bigger than the viewport, we'll fall back to\n // 'start'\n if (align === 'center' && targetHeight + offset < viewportHeight) {\n return targetTop - (viewportHeight - targetHeight) / 2 + offset;\n }\n if (align === 'end') {\n return targetTop - (viewportHeight - targetHeight) + offset;\n }\n // 'start', the default\n return targetTop - stickyOffset - offset;\n }\n\n private getLineScrollPosition(\n item: CodeViewContextItem<LAnnotation>,\n target: CodeViewLineScrollTarget\n ): LineScrollPosition | undefined {\n if (item.type === 'diff') {\n return item.instance.getLinePosition(target.lineNumber, target.side);\n }\n\n return item.instance.getLinePosition(target.lineNumber);\n }\n\n /**\n * Determine target scroll position for current frame.\n *\n * If there's no pendingScrollTarget then we just return the current scroll\n * position\n *\n * If there's a pendingScrollTarget then we depend on whether there's a\n * smooth scroll animation or not. If not just return the destination, or\n * compute next position given the smooth scroll spring physics\n */\n private computeFrameScrollTop(\n scrollTop: number,\n frameTimestamp: number\n ): number {\n if (this.pendingScrollTarget == null) {\n return scrollTop;\n }\n const destination = this.resolveScrollTargetTop(this.pendingScrollTarget);\n if (destination == null) {\n return scrollTop;\n }\n const { scrollAnimation } = this;\n if (scrollAnimation == null) {\n return destination;\n }\n return this.computeSpringStep(scrollAnimation, destination, frameTimestamp)\n .position;\n }\n\n /**\n * Closed-form critical-damped ODE step.\n *\n * Stable at any dt (Euler would blow up once ω·dt ≳ 1), so this survives\n * big RAF gaps (tab-wake, offscreen frames) and resize-driven ticks that\n * fire outside the normal RAF cadence.\n */\n private computeSpringStep(\n animation: ScrollToAnimation,\n destination: number,\n frameTimestamp: number\n ): SpringStepResult {\n const dt = Math.max(0, frameTimestamp - animation.lastTimestamp);\n const { omega } = this.getSmoothScrollSettings();\n const decay = Math.exp(-omega * dt);\n const displacement = animation.position - destination;\n const springCoeff = animation.velocity + omega * displacement;\n const position = destination + (displacement + springCoeff * dt) * decay;\n const velocity =\n (springCoeff * (1 - omega * dt) - omega * displacement) * decay;\n return { position, velocity };\n }\n\n /**\n * For any given pendingScrollTarget, updates any in flight smooth scroll\n * animations and returns the target scrollTop to move towards\n *\n * Resolves the animation based on frame time and adopts any necessary scroll\n * anchoring corrections if necessary\n */\n private advanceScrollAnimation(\n frameTimestamp: number,\n anchorDelta: number\n ): number | undefined {\n if (this.pendingScrollTarget == null) {\n return undefined;\n }\n const destination = this.resolveScrollTargetTop(this.pendingScrollTarget);\n if (destination == null) {\n this.pendingScrollTarget = undefined;\n this.scrollAnimation = undefined;\n return undefined;\n }\n const animation = this.scrollAnimation;\n if (animation == null) {\n return destination;\n }\n\n animation.position += anchorDelta;\n\n const { position, velocity } = this.computeSpringStep(\n animation,\n destination,\n frameTimestamp\n );\n animation.lastTimestamp = frameTimestamp;\n animation.position = position;\n animation.velocity = velocity;\n\n const { positionEpsilon, velocityEpsilon } = this.getSmoothScrollSettings();\n if (\n Math.abs(destination - position) <= positionEpsilon &&\n Math.abs(velocity) <= velocityEpsilon\n ) {\n animation.position = destination;\n animation.velocity = 0;\n this.scrollAnimation = undefined;\n return destination;\n }\n\n return animation.position;\n }\n\n private computeRenderRangeAndEmit = (\n timestamp: number = performance.now()\n ): void => {\n if (CodeView.__STOP || this.container == null) {\n return;\n }\n const height = this.getHeight();\n let currentScrollTop = this.getScrollTop();\n const currentRootScrollTop = currentScrollTop;\n // This boolean tracks whether we are expecting some sort of major layout\n // change, which means we need to re-calculate our window from a new\n // anchor computed position after we re-compute the layout\n let recomputeScrollTop = this.pendingLayoutAnchor != null;\n // We need to grab the anchor before we re-compute any layout updates, or\n // else we'll get invalid anchor reference data\n let anchor = this.getScrollAnchor(currentScrollTop);\n\n // If any part of the layout is dirty, we should re-compute everything and\n // force a contextualization\n if (this.layoutDirtyIndex != null) {\n this.recomputeLayout(this.layoutDirtyIndex);\n this.layoutDirtyIndex = undefined;\n recomputeScrollTop = true;\n }\n\n // If we have an anchor and are expecting some sort of layout shift, let's\n // compute a new current window position from that estimated layout change\n if (recomputeScrollTop && anchor != null) {\n const newScrollTop = this.resolveAnchoredScrollTop(anchor);\n if (newScrollTop != null) {\n const delta = newScrollTop - currentScrollTop;\n currentScrollTop = newScrollTop;\n if (this.scrollAnimation != null) {\n // If we have a delta measurement adjustment, we have to pass that\n // change onto the scroll animation to ensure the animation remains\n // stable, later on\n this.scrollAnimation.position += delta;\n }\n }\n }\n // Recomputing layout can shrink the scroll range, for example when items\n // collapse, so clamp before deriving the render window for this frame.\n if (recomputeScrollTop) {\n currentScrollTop = this.clampScrollTop(currentScrollTop);\n }\n\n // From our currentScrollTop, we should compute where we might be headed\n // towards, if we have a pending scroll target and/or animation in progress\n const frameScrollTop = this.computeFrameScrollTop(\n currentScrollTop,\n timestamp\n );\n\n // When performing very large scroll jumps, we should attempt to render the\n // bare minimum to ensure we can paint quickly. We'll queue up a another\n // render at the end to fill things out on the next tick. If we had to\n // recomputeScrollTop then we should not fitPerfectly because there's\n // a good chance we'll be re-rendering everything again\n const fitPerfectly =\n !recomputeScrollTop &&\n (this.renderState.scrollTop === -1 ||\n Math.abs(frameScrollTop - this.renderState.scrollTop) >\n height + this.config.overscrollSize * 2);\n\n let appliedScrollTop = currentRootScrollTop;\n if (\n this.pendingScrollTarget != null &&\n frameScrollTop !== appliedScrollTop\n ) {\n // Programmatic scrolls render the target window. Apply the target scroll\n // before DOM window mutations so the browser does not have to reconcile\n // a large virtualized DOM change against an old scrollTop.\n this.applyScrollFix(frameScrollTop, appliedScrollTop);\n appliedScrollTop = frameScrollTop;\n }\n\n // If we are doing a fitPerfectly render than we should not attempt to anchor\n if (fitPerfectly) {\n anchor = undefined;\n }\n\n this.windowSpecs = createWindowFromScrollPosition({\n scrollTop: frameScrollTop,\n height,\n scrollHeight: this.getScrollHeight(),\n fitPerfectly,\n fitPerfectlyOverscroll: this.getFitPerfectlyOverscroll(),\n overscrollSize: this.config.overscrollSize,\n });\n\n const { top, bottom } = this.windowSpecs;\n const { firstIndex, lastIndex } = this.renderState;\n if (firstIndex >= 0) {\n for (let index = firstIndex; index <= lastIndex; index++) {\n const item = this.items[index];\n if (item == null) {\n throw new Error(\n `CodeView.computeRenderRangeAndEmit: No item at index: ${index}`\n );\n }\n const renderedTop = item.top;\n const renderedHeight = item.height;\n // If not visible, we should unmount it\n if (!(renderedTop > top - renderedHeight && renderedTop <= bottom)) {\n cleanRenderedItem(item);\n }\n }\n }\n\n let prevElement: HTMLElement | undefined;\n const updatedItems = new Set<CodeViewContextItem<LAnnotation>>();\n const startingIndex = this.findFirstVisibleIndex(top);\n const lastRenderedIndex = this.findLastVisibleIndex(bottom);\n\n for (\n let itemIndex = startingIndex;\n itemIndex <= lastRenderedIndex;\n itemIndex++\n ) {\n const item = this.items[itemIndex];\n if (item == null) {\n throw new Error(`CodeView.computeRenderRangeAndEmit: missing item`);\n }\n const { instance } = item;\n // If the item isn't rendered yet, we need to create a wrapper element\n // for it and render it\n if (item.element == null) {\n item.element = document.createElement(DIFFS_TAG_NAME);\n syncRenderedItemOrder(this.stickyContainer, item.element, prevElement);\n instance.virtualizedSetup();\n if (renderItem(item, item.element)) {\n updatedItems.add(item);\n }\n prevElement = item.element;\n }\n // Otherwise kick off a render as necessary\n else {\n syncRenderedItemOrder(this.stickyContainer, item.element, prevElement);\n if (renderItem(item)) {\n updatedItems.add(item);\n }\n prevElement = item.element;\n }\n }\n\n this.renderState.firstIndex =\n startingIndex <= lastRenderedIndex ? startingIndex : -1;\n this.renderState.lastIndex = lastRenderedIndex;\n\n this.flushSlotCoordinator();\n this.reconcileRenderedItems(updatedItems);\n this.updateStickyPositioning();\n\n // Now that the dom has been flushed and we've computed our updated\n // item/line metrics, we should attempt to resolve any scroll anchors and\n // scroll animations\n //\n // - No pending target → resolve the captured anchor and apply\n // the absolute anchored scrollTop directly if needed (idle / user-driven\n // layout settling, e.g. annotations finishing measurement).\n // - Instant pending target → apply the post-reconcile resolved\n // destination that we've rendered.\n // - Smooth pending target → rebase the spring to the anchored scrollTop\n // and update the spring based on frameTime as needed\n const anchoredScrollTop =\n anchor != null ? this.resolveAnchoredScrollTop(anchor) : undefined;\n if (anchor === this.pendingLayoutAnchor) {\n this.pendingLayoutAnchor = undefined;\n }\n // The amount of computed layout shift from the render\n const anchorScrollDelta =\n anchoredScrollTop != null ? anchoredScrollTop - currentScrollTop : 0;\n\n let renderedScrollTop = frameScrollTop;\n if (this.pendingScrollTarget == null) {\n renderedScrollTop = anchoredScrollTop ?? frameScrollTop;\n if (renderedScrollTop !== appliedScrollTop) {\n this.applyScrollFix(renderedScrollTop, appliedScrollTop);\n }\n } else if (this.pendingScrollTarget != null) {\n const targetScrollTop = this.advanceScrollAnimation(\n timestamp,\n anchorScrollDelta\n );\n if (targetScrollTop != null) {\n if (targetScrollTop !== appliedScrollTop) {\n this.applyScrollFix(targetScrollTop, appliedScrollTop);\n }\n renderedScrollTop = targetScrollTop;\n if (\n this.pendingScrollTarget != null &&\n this.isPendingTargetSettled(this.pendingScrollTarget)\n ) {\n this.pendingScrollTarget = undefined;\n this.scrollAnimation = undefined;\n }\n }\n // If something bad happened with our pending scroll target, then we'd\n // fall back here. Unlikely to happen in practice, but we need to reset\n // the scrollTop if so\n else {\n renderedScrollTop = currentScrollTop;\n }\n }\n this.renderState.scrollTop = roundToDevicePixel(renderedScrollTop);\n\n const totalScrollHeight = this.getScrollHeight();\n if (this.lastContainerHeight !== totalScrollHeight) {\n this.container.style.height = `${totalScrollHeight}px`;\n this.lastContainerHeight = totalScrollHeight;\n }\n this.flushManagers(updatedItems);\n\n // If we are hitting a fitPerfectly heuristic, we should queue up another\n // render to fill out content. If we are performing a scroll animation\n // we'll need another render to continue\n if (fitPerfectly || this.scrollAnimation != null) {\n this.render();\n }\n };\n\n private flushManagers(\n updatedItems: Set<CodeViewContextItem<LAnnotation>>\n ): void {\n for (const item of updatedItems) {\n item.instance.flushManagers();\n }\n }\n\n private reconcileRenderedItems(\n updatedItems?: Set<CodeViewContextItem<LAnnotation>>\n ): void {\n const { firstIndex, lastIndex } = this.renderState;\n if (firstIndex === -1) {\n return;\n }\n\n let currentTop = -1;\n let heightChanged = false;\n // Iterate through the rendered items to reconcile height. If a height\n // has changed, we'll have to iterate all the way till the end to update\n // all appropriate heights\n for (let index = firstIndex; index < this.items.length; index++) {\n // If we've incurred no height changes and ended, we can abort\n if (!heightChanged && index > lastIndex) {\n break;\n }\n const item = this.items[index];\n if (item == null) {\n throw new Error('CodeView.reconcileRenderedItems: Invalid item');\n }\n if (currentTop === -1) {\n currentTop = item.top;\n } else if (item.top !== currentTop) {\n item.top = currentTop;\n item.instance.syncVirtualizedTop();\n heightChanged = true;\n }\n // If updatedInstances provided, only reconcile those. If not provided\n // (resize path), reconcile all rendered items.\n if (updatedItems == null ? index <= lastIndex : updatedItems.has(item)) {\n if (item.instance.reconcileHeights()) {\n heightChanged = true;\n item.height = item.instance.getVirtualizedHeight();\n }\n }\n currentTop += item.instance.getVirtualizedHeight();\n if (index < this.items.length - 1) {\n currentTop += this.getViewerMetrics().gap;\n }\n }\n\n if (heightChanged && currentTop != null) {\n this.scrollDirty = true;\n this.scrollHeight = currentTop;\n }\n }\n\n private updateStickyPositioning(): void {\n const { firstIndex, lastIndex } = this.renderState;\n const firstStickySpecs =\n this.items[firstIndex]?.instance.getAdvancedStickySpecs();\n const lastStickySpecs =\n this.items[lastIndex]?.instance.getAdvancedStickySpecs();\n if (firstStickySpecs == null || lastStickySpecs == null) {\n return;\n }\n\n const height = this.getHeight();\n const itemMetrics = this.getItemMetrics();\n const stickyTop = Math.max(firstStickySpecs.topOffset, 0);\n const stickyBottom = lastStickySpecs.topOffset + lastStickySpecs.height;\n const stickyContainerHeight = stickyBottom - stickyTop;\n\n if (\n stickyContainerHeight === this.renderState.stickyHeight &&\n stickyTop === this.renderState.stickyTop &&\n stickyBottom === this.renderState.stickyBottom\n ) {\n return;\n }\n\n this.renderState.stickyHeight = stickyContainerHeight;\n this.renderState.stickyTop = stickyTop;\n this.renderState.stickyBottom = stickyBottom;\n\n this.stickyOffset.style.height = `${stickyTop}px`;\n // NOTE(amadeus): Wee polish lad -- when dragging the scrollbar up or\n // down quickly, this prevents the laggy scroll view from lining up with\n // the numbers exactly\n const randomOffset = ((Math.random() * itemMetrics.lineHeight) >> 0) * -1;\n const stickyJitter =\n -Math.max(stickyContainerHeight + randomOffset, 0) + height;\n this.stickyContainer.style.top = `${stickyJitter}px`;\n this.stickyContainer.style.bottom = `${stickyJitter + itemMetrics.diffHeaderHeight}px`;\n }\n\n private handleScroll = (): void => {\n if (CodeView.__STOP) {\n return;\n }\n this.suspendPointerEvents();\n this.scrollDirty = true;\n this.notifyScroll();\n this.render();\n };\n\n // Abort any in-flight programmatic scroll when the user takes over.\n // Attached to root as a passive listener for wheel / touchstart /\n // pointerdown / keydown; we never mutate the event, just drop our state.\n private clearPendingScroll = (): void => {\n this.pendingScrollTarget = undefined;\n this.pendingLayoutAnchor = undefined;\n this.scrollAnimation = undefined;\n };\n\n private handleResize = (entries: ResizeObserverEntry[]) => {\n for (const entry of entries) {\n // If the sticky container resizes (could be from a render, which it will\n // probably ignore) or if an annotation or line wrap triggers a resize\n if (entry.target === this.stickyContainer) {\n const blockSize = entry.borderBoxSize[0].blockSize;\n // If the height of the sticky container was already known, there's\n // nothing for us to do\n if (blockSize !== this.renderState.stickyHeight) {\n // If content resizes above the viewport, we want to be sure that it\n // doesn't cause things to jump within the viewport\n const currentScrollTop = this.getScrollTop();\n const anchor = this.getScrollAnchor(currentScrollTop);\n\n this.reconcileRenderedItems();\n this.updateStickyPositioning();\n\n const anchoredScrollTop =\n anchor != null ? this.resolveAnchoredScrollTop(anchor) : undefined;\n if (anchoredScrollTop != null) {\n const resizeAnchorDelta = anchoredScrollTop - currentScrollTop;\n this.applyScrollFix(anchoredScrollTop, currentScrollTop);\n if (this.scrollAnimation != null) {\n // if we had to apply a scroll fix then we should make sure to\n // match the scroll fix delta to the scrollAnimation position to\n // ensure the animation continues smoothly as if the scroll fix\n // never happened\n this.scrollAnimation.position += resizeAnchorDelta;\n }\n }\n if (\n this.pendingScrollTarget != null &&\n this.isPendingTargetSettled(this.pendingScrollTarget)\n ) {\n this.pendingScrollTarget = undefined;\n this.scrollAnimation = undefined;\n }\n }\n }\n // Root element resize (element-mode only)\n else {\n this.scrollDirty = true;\n this.heightDirty = true;\n this.render();\n }\n }\n };\n\n /**\n * Figure out scrollTop accounting for sticky header if enabled and\n * necessary\n */\n private getScrollAnchorViewportTop(\n absoluteItemTop: number,\n scrollTop: number\n ): number {\n return absoluteItemTop < scrollTop\n ? scrollTop + this.getStickyHeaderOffset()\n : scrollTop;\n }\n\n /**\n * Attempt to find a scroll anchor based on build in metrics of the existing\n * rendered files/diff.\n *\n * A scroll anchor represents the first fully visible element (in other\n * words, the first file or first line who's top is fully in the viewport).\n */\n private getScrollAnchor(scrollTop: number): ScrollAnchor | undefined {\n // If we already have a pendingLayoutAnchor, let's use that.\n if (this.pendingLayoutAnchor != null) {\n return this.pendingLayoutAnchor;\n }\n\n const { firstIndex, lastIndex, stickyTop, stickyBottom } = this.renderState;\n if (firstIndex === -1 || lastIndex === -1) {\n return undefined;\n }\n\n const viewportHeight = this.getHeight();\n // If we have no previoius frame, we shouldn't scroll anchor\n if (stickyTop === -1 || stickyBottom === -1) {\n return undefined;\n }\n\n for (let index = firstIndex; index <= lastIndex; index++) {\n const item = this.items[index];\n if (item == null) {\n continue;\n }\n\n const absoluteItemTop = this.getViewerMetrics().paddingTop + item.top;\n const absoluteItemBottom = absoluteItemTop + item.height;\n // Skip items entirely above the viewport since we can't see it\n if (absoluteItemBottom <= scrollTop) {\n continue;\n }\n // If the item starts below the viewport bottom we are done searching.\n if (absoluteItemTop >= scrollTop + viewportHeight) {\n break;\n }\n\n if (absoluteItemTop >= scrollTop) {\n return {\n type: 'item',\n id: item.item.id,\n viewportOffset: absoluteItemTop - scrollTop,\n };\n }\n\n // First attempt to grab a the first fully visible line\n const anchorViewportTop = this.getScrollAnchorViewportTop(\n absoluteItemTop,\n scrollTop\n );\n const localViewportTop = anchorViewportTop - absoluteItemTop;\n const lineAnchor = item.instance.getNumericScrollAnchor(localViewportTop);\n if (lineAnchor != null) {\n const absoluteLineTop = absoluteItemTop + lineAnchor.top;\n return {\n type: 'line',\n id: item.item.id,\n lineNumber: lineAnchor.lineNumber,\n side: lineAnchor.side,\n viewportOffset: absoluteLineTop - scrollTop,\n };\n }\n }\n\n // I don't think we'll ever make it this far...\n return undefined;\n }\n\n /**\n * Given a scroll anchor, attempt to resolve a newly updated (and clamped)\n * scroll position to keep the anchored element in place.\n *\n * If we can't resolve a position for whatever reason, we'll return\n * undefined.\n */\n private resolveAnchoredScrollTop(anchor: ScrollAnchor): number | undefined {\n const item = this.idToItem.get(anchor.id);\n if (item == null) {\n return undefined;\n }\n\n const { paddingTop } = this.getViewerMetrics();\n if (anchor.type === 'item') {\n const absoluteItemTop = paddingTop + item.top;\n return this.clampScrollTop(absoluteItemTop - anchor.viewportOffset);\n }\n\n const linePosition =\n item.type === 'diff'\n ? item.instance.getLinePosition(anchor.lineNumber, anchor.side)\n : item.instance.getLinePosition(anchor.lineNumber);\n if (linePosition == null) {\n return undefined;\n }\n const absoluteLineTop = paddingTop + item.top + linePosition.top;\n return this.clampScrollTop(absoluteLineTop - anchor.viewportOffset);\n }\n\n /**\n * Apply a device-pixel-rounded scroll position if it differs from the last\n * rendered/applied scrollTop we've already recorded in renderState.\n */\n private applyScrollFix(target: number, currentScrollTop?: number): void {\n if (this.root == null) {\n return;\n }\n const rounded = roundToDevicePixel(this.clampScrollTop(target));\n const roundedCurrentScrollTop = roundToDevicePixel(\n currentScrollTop ?? this.scrollTop\n );\n if (\n rounded === this.renderState.scrollTop &&\n rounded === roundedCurrentScrollTop\n ) {\n return;\n }\n this.suspendPointerEvents();\n if (rounded !== roundedCurrentScrollTop) {\n this.root.scrollTo({ top: rounded, behavior: 'instant' });\n }\n // Keep cached scroll state in sync with writes we performed ourselves, so\n // later reads do not need to touch layout just to discover the same value.\n this.renderState.scrollTop = rounded;\n this.scrollTop = rounded;\n this.scrollDirty = false;\n }\n\n /**\n * Decide whether a pending programmatic scroll has reached its\n * destination and should be cleared.\n */\n private isPendingTargetSettled(target: PendingScrollTarget): boolean {\n const top = this.resolveScrollTargetTop(target);\n if (top == null) {\n return true;\n }\n return roundToDevicePixel(this.getScrollTop()) === roundToDevicePixel(top);\n }\n\n public getScrollTop(): number {\n if (!this.scrollDirty) {\n return this.scrollTop;\n }\n this.scrollDirty = false;\n this.scrollTop = this.clampScrollTop(this.root?.scrollTop ?? 0);\n return this.scrollTop;\n }\n\n public getHeight(): number {\n if (!this.heightDirty) {\n return this.height;\n }\n this.heightDirty = false;\n this.height = this.root?.getBoundingClientRect().height ?? 0;\n return this.height;\n }\n\n public getScrollHeight(): number {\n return this.scrollHeight;\n }\n\n private flushSlotCoordinator(): void {\n if (this.slotCoordinator == null) {\n return;\n }\n const { onSnapshotChange } = this.slotCoordinator;\n\n const slotSnapshot = getSlotSnapshot(\n this.getRenderedItems(),\n this.slotCoordinator\n );\n\n if (areSlotSnapshotsEqual(this.slotSnapshot, slotSnapshot)) {\n return;\n }\n\n this.slotSnapshot = slotSnapshot;\n onSnapshotChange(slotSnapshot);\n }\n\n private notifyScroll(): void {\n // Avoid DOM thrash of checking scroll position if we don't need it\n if (this.scrollListeners.size === 0) {\n return;\n }\n const scrollTop = this.getScrollTop();\n for (const listener of this.scrollListeners) {\n listener(scrollTop, this);\n }\n }\n\n /**\n * Find the first item whose bottom edge crosses into the viewport window.\n * This lets scroll-time rendering jump directly near the visible range instead\n * of linearly scanning from the start of very large item lists.\n */\n private findFirstVisibleIndex(top: number): number {\n let low = 0;\n let high = this.items.length - 1;\n let result = this.items.length;\n\n while (low <= high) {\n const mid = (low + high) >> 1;\n const item = this.items[mid];\n if (item == null) {\n throw new Error('CodeView.findFirstVisibleIndex: invalid item index');\n }\n\n if (item.top + item.height > top) {\n result = mid;\n high = mid - 1;\n } else {\n low = mid + 1;\n }\n }\n\n return result;\n }\n\n /**\n * Find the last item whose top edge is still within the viewport window.\n * Paired with findFirstVisibleIndex, this bounds the render loop to only the\n * slice of items that can actually intersect the current scroll range.\n */\n private findLastVisibleIndex(bottom: number): number {\n let low = 0;\n let high = this.items.length - 1;\n let result = -1;\n\n while (low <= high) {\n const mid = (low + high) >> 1;\n const item = this.items[mid];\n if (item == null) {\n throw new Error('CodeView.findLastVisibleIndex: invalid item index');\n }\n\n if (item.top <= bottom) {\n result = mid;\n low = mid + 1;\n } else {\n high = mid - 1;\n }\n }\n\n return result;\n }\n\n /**\n * Recompute measured tops and heights starting from the earliest dirty item.\n * Earlier items keep their existing layout, while everything from startIndex\n * onward is remeasured so downstream positions and total scroll height stay\n * consistent after inserts, removals, or versioned item updates.\n */\n private recomputeLayout(startIndex = 0): void {\n if (this.items.length === 0) {\n this.scrollHeight = 0;\n return;\n }\n\n const viewerMetrics = this.getViewerMetrics();\n let runningTop = 0;\n if (startIndex > 0) {\n const previousItem = this.items[startIndex - 1];\n if (previousItem == null) {\n throw new Error('CodeView.recomputeLayout: invalid dirty index');\n }\n runningTop = previousItem.top + previousItem.height + viewerMetrics.gap;\n }\n\n for (let index = startIndex; index < this.items.length; index++) {\n const item = this.items[index];\n if (item == null) {\n throw new Error('CodeView.recomputeLayout: invalid item index');\n }\n item.top = runningTop;\n if (item.type === 'diff') {\n item.height = item.instance.prepareVirtualizedItem(item.item.fileDiff);\n } else {\n item.height = item.instance.prepareVirtualizedItem(item.item.file);\n }\n runningTop += item.height;\n if (index < this.items.length - 1) {\n runningTop += viewerMetrics.gap;\n }\n }\n\n if (runningTop !== this.scrollHeight) {\n this.scrollDirty = true;\n }\n this.scrollHeight = runningTop;\n }\n\n private resetRenderState() {\n this.renderState.scrollTop = -1;\n this.renderState.firstIndex = -1;\n this.renderState.lastIndex = -1;\n this.renderState.stickyHeight = 0;\n this.renderState.stickyTop = -1;\n this.renderState.stickyBottom = -1;\n }\n\n // We actually need a bit of overscroll even when attempting to fit perfectly\n // because we rounde to the nearest container and we may need to render the\n // gaps before and after a perfectly fit element to include the spacing\n // between. We do this by adding the the gap and header height above and\n // below the viewport\n private getFitPerfectlyOverscroll() {\n return this.getViewerMetrics().gap + this.getItemMetrics().diffHeaderHeight;\n }\n}\n\nfunction cleanRenderedItem<LAnnotation>(\n item: CodeViewContextItem<LAnnotation>\n) {\n item.instance.cleanUp(true);\n item.element?.remove();\n item.element = undefined;\n}\n\nfunction prepareItemInstance<LAnnotation>(\n item: CodeViewContextItem<LAnnotation>\n): number {\n item.instance.cleanUp(true);\n if (item.type === 'diff') {\n return item.instance.prepareVirtualizedItem(item.item.fileDiff);\n } else {\n return item.instance.prepareVirtualizedItem(item.item.file);\n }\n}\n\nfunction renderItem<LAnnotation>(\n item: CodeViewContextItem<LAnnotation>,\n fileContainer?: HTMLElement\n): boolean {\n if (item.type === 'diff') {\n return item.instance.render({\n deferManagers: true,\n fileContainer,\n fileDiff: item.item.fileDiff,\n lineAnnotations: item.item.annotations,\n });\n } else {\n return item.instance.render({\n deferManagers: true,\n fileContainer,\n file: item.item.file,\n lineAnnotations: item.item.annotations,\n });\n }\n}\n\n/**\n * Keep the rendered DOM order aligned with the current record order even when\n * we reuse existing elements. Reused items may already be mounted elsewhere in\n * the sticky container, so this moves them into the correct sibling position\n * before rendering updates.\n */\nfunction syncRenderedItemOrder(\n container: HTMLElement,\n element: HTMLElement,\n prevElement: HTMLElement | undefined\n): void {\n if (prevElement == null) {\n if (container.firstChild !== element) {\n container.prepend(element);\n }\n return;\n }\n\n if (prevElement.nextSibling !== element) {\n prevElement.after(element);\n }\n}\n\nfunction hasAnnotations<LAnnotation>(item: CodeViewItem<LAnnotation>): boolean {\n return (item.annotations?.length ?? 0) > 0;\n}\n\nfunction getSlotSnapshot<LAnnotation>(\n renderedItems: CodeViewRenderedItem<LAnnotation>[],\n {\n hasHeaderRenderers,\n hasAnnotationRenderer,\n hasGutterRenderer,\n }: CodeViewCoordinator<LAnnotation>\n): CodeViewRenderedItem<LAnnotation>[] | undefined {\n if (renderedItems.length === 0) {\n return undefined;\n }\n\n if (hasHeaderRenderers || hasGutterRenderer) {\n return renderedItems;\n }\n\n if (!hasAnnotationRenderer) {\n return undefined;\n }\n\n const slotSnapshot: CodeViewRenderedItem<LAnnotation>[] = [];\n\n for (const renderedItem of renderedItems) {\n if (hasAnnotations(renderedItem.item)) {\n slotSnapshot.push(renderedItem);\n }\n }\n\n return slotSnapshot.length > 0 ? slotSnapshot : undefined;\n}\n\nfunction areSlotSnapshotsEqual<LAnnotation>(\n previous: CodeViewRenderedItem<LAnnotation>[] | undefined,\n next: CodeViewRenderedItem<LAnnotation>[] | undefined\n): boolean {\n if (previous == null || next == null) {\n return previous === next;\n }\n\n if (previous.length !== next.length) {\n return false;\n }\n\n for (let index = 0; index < previous.length; index++) {\n const previousItem = previous[index];\n const nextItem = next[index];\n if (\n previousItem == null ||\n nextItem == null ||\n previousItem.id !== nextItem.id ||\n previousItem.type !== nextItem.type ||\n previousItem.element !== nextItem.element ||\n previousItem.version !== nextItem.version\n ) {\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":";;;;;;;;;;AAkNA,MAAM,6BAA6B;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAID,MAAM,6BAA6B;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AA4CD,MAAM,iCAAiC;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;A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1
|
import { AppliedThemeStyleCache, BaseCodeOptions, FileContents, LineAnnotation, PrePropertiesConfig, RenderFileMetadata, RenderRange, ThemeTypes } from "../types.js";
|
|
2
|
+
import { GetHoveredLineResult, InteractionManager, InteractionManagerBaseOptions, SelectedLineRange, SelectionWriteOptions } from "../managers/InteractionManager.js";
|
|
2
3
|
import { WorkerPoolManager } from "../worker/WorkerPoolManager.js";
|
|
3
4
|
import "../worker/index.js";
|
|
4
|
-
import { GetHoveredLineResult, InteractionManager, InteractionManagerBaseOptions, SelectedLineRange } from "../managers/InteractionManager.js";
|
|
5
5
|
import { ResizeManager } from "../managers/ResizeManager.js";
|
|
6
6
|
import { FileRenderer } from "../renderers/FileRenderer.js";
|
|
7
7
|
|
|
@@ -10,6 +10,7 @@ interface FileRenderProps<LAnnotation> {
|
|
|
10
10
|
file: FileContents;
|
|
11
11
|
fileContainer?: HTMLElement;
|
|
12
12
|
containerWrapper?: HTMLElement;
|
|
13
|
+
deferManagers?: boolean;
|
|
13
14
|
forceRender?: boolean;
|
|
14
15
|
preventEmit?: boolean;
|
|
15
16
|
lineAnnotations?: LineAnnotation<LAnnotation>[];
|
|
@@ -21,12 +22,8 @@ interface FileHydrateProps<LAnnotation> extends Omit<FileRenderProps<LAnnotation
|
|
|
21
22
|
}
|
|
22
23
|
interface FileOptions<LAnnotation> extends BaseCodeOptions, InteractionManagerBaseOptions<'file'> {
|
|
23
24
|
disableFileHeader?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated Use `enableGutterUtility` instead.
|
|
26
|
-
*/
|
|
27
|
-
enableHoverUtility?: boolean;
|
|
28
25
|
renderHeaderPrefix?: RenderFileMetadata;
|
|
29
|
-
|
|
26
|
+
renderHeaderMetadata?: RenderFileMetadata;
|
|
30
27
|
renderCustomHeader?: RenderFileMetadata;
|
|
31
28
|
/**
|
|
32
29
|
* When true, errors during rendering are rethrown instead of being caught
|
|
@@ -36,10 +33,6 @@ interface FileOptions<LAnnotation> extends BaseCodeOptions, InteractionManagerBa
|
|
|
36
33
|
disableErrorHandling?: boolean;
|
|
37
34
|
renderAnnotation?(annotation: LineAnnotation<LAnnotation>): HTMLElement | undefined;
|
|
38
35
|
renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null | undefined;
|
|
39
|
-
/**
|
|
40
|
-
* @deprecated Use `renderGutterUtility` instead.
|
|
41
|
-
*/
|
|
42
|
-
renderHoverUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null | undefined;
|
|
43
36
|
onPostRender?(node: HTMLElement, instance: File<LAnnotation>): unknown;
|
|
44
37
|
}
|
|
45
38
|
interface AnnotationElementCache<LAnnotation> {
|
|
@@ -81,20 +74,26 @@ declare class File<LAnnotation = undefined> {
|
|
|
81
74
|
protected interactionManager: InteractionManager<'file'>;
|
|
82
75
|
protected annotationCache: Map<string, AnnotationElementCache<LAnnotation>>;
|
|
83
76
|
protected lineAnnotations: LineAnnotation<LAnnotation>[];
|
|
77
|
+
protected managersDirty: boolean;
|
|
84
78
|
protected file: FileContents | undefined;
|
|
85
79
|
protected renderRange: RenderRange | undefined;
|
|
80
|
+
protected enabled: boolean;
|
|
86
81
|
constructor(options?: FileOptions<LAnnotation>, workerManager?: WorkerPoolManager | undefined, isContainerManaged?: boolean);
|
|
87
82
|
private handleHighlightRender;
|
|
88
83
|
rerender(): void;
|
|
89
84
|
setOptions(options: FileOptions<LAnnotation> | undefined): void;
|
|
90
85
|
private mergeOptions;
|
|
91
86
|
setThemeType(themeType: ThemeTypes): void;
|
|
87
|
+
private applyCachedThemeState;
|
|
88
|
+
private hasThemeChanged;
|
|
92
89
|
getHoveredLine: () => {
|
|
93
90
|
lineNumber: number;
|
|
94
91
|
} | undefined;
|
|
95
92
|
setLineAnnotations(lineAnnotations: LineAnnotation<LAnnotation>[]): void;
|
|
96
|
-
setSelectedLines(range: SelectedLineRange | null): void;
|
|
97
|
-
|
|
93
|
+
setSelectedLines(range: SelectedLineRange | null, options?: SelectionWriteOptions): void;
|
|
94
|
+
flushManagers(): void;
|
|
95
|
+
cleanUp(recycle?: boolean): void;
|
|
96
|
+
virtualizedSetup(): void;
|
|
98
97
|
hydrate(props: FileHydrateProps<LAnnotation>): void;
|
|
99
98
|
protected hydrateElements(fileContainer: HTMLElement, prerenderedHTML: string | undefined): void;
|
|
100
99
|
protected hydrationSetup({
|
|
@@ -108,6 +107,7 @@ declare class File<LAnnotation = undefined> {
|
|
|
108
107
|
forceRender,
|
|
109
108
|
preventEmit,
|
|
110
109
|
containerWrapper,
|
|
110
|
+
deferManagers,
|
|
111
111
|
lineAnnotations,
|
|
112
112
|
renderRange
|
|
113
113
|
}: FileRenderProps<LAnnotation>): boolean;
|
|
@@ -128,6 +128,7 @@ declare class File<LAnnotation = undefined> {
|
|
|
128
128
|
private getDOMBoundaryIndices;
|
|
129
129
|
private getLineIndexFromDOMNode;
|
|
130
130
|
private applyBuffers;
|
|
131
|
+
protected shouldDisableVirtualizationBuffers(): boolean;
|
|
131
132
|
private applyHeaderToDOM;
|
|
132
133
|
private clearHeaderSlots;
|
|
133
134
|
private upsertHeaderSlotElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"File.d.ts","names":["GetHoveredLineResult","InteractionManager","InteractionManagerBaseOptions","SelectedLineRange","ResizeManager","FileRenderer","AppliedThemeStyleCache","BaseCodeOptions","FileContents","LineAnnotation","PrePropertiesConfig","RenderFileMetadata","RenderRange","ThemeTypes","WorkerPoolManager","FileRenderProps","LAnnotation","HTMLElement","FileHydrateProps","Omit","FileOptions","File","AnnotationElementCache","HydrationSetup","SVGElement","HTMLPreElement","HTMLStyleElement","Map","file","lineAnnotations","fileContainer","forceRender","preventEmit","containerWrapper","renderRange"],"sources":["../../src/components/File.d.ts"],"sourcesContent":["import { type GetHoveredLineResult, InteractionManager, type InteractionManagerBaseOptions, type SelectedLineRange } from '../managers/InteractionManager';\nimport { ResizeManager } from '../managers/ResizeManager';\nimport { FileRenderer } from '../renderers/FileRenderer';\nimport type { AppliedThemeStyleCache, BaseCodeOptions, FileContents, LineAnnotation, PrePropertiesConfig, RenderFileMetadata, RenderRange, ThemeTypes } from '../types';\nimport type { WorkerPoolManager } from '../worker';\nexport interface FileRenderProps<LAnnotation> {\n file: FileContents;\n fileContainer?: HTMLElement;\n containerWrapper?: HTMLElement;\n forceRender?: boolean;\n preventEmit?: boolean;\n lineAnnotations?: LineAnnotation<LAnnotation>[];\n renderRange?: RenderRange;\n}\nexport interface FileHydrateProps<LAnnotation> extends Omit<FileRenderProps<LAnnotation>, 'fileContainer'> {\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\nexport interface FileOptions<LAnnotation> extends BaseCodeOptions, InteractionManagerBaseOptions<'file'> {\n disableFileHeader?: boolean;\n /**\n * @deprecated Use `enableGutterUtility` instead.\n */\n enableHoverUtility?: boolean;\n renderHeaderPrefix?: RenderFileMetadata;\n renderCustomMetadata?: RenderFileMetadata;\n renderCustomHeader?: RenderFileMetadata;\n /**\n * When true, errors during rendering are rethrown instead of being caught\n * and displayed in the DOM. Useful for testing or when you want to handle\n * errors yourself.\n */\n disableErrorHandling?: boolean;\n renderAnnotation?(annotation: LineAnnotation<LAnnotation>): HTMLElement | undefined;\n renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null | undefined;\n /**\n * @deprecated Use `renderGutterUtility` instead.\n */\n renderHoverUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null | undefined;\n onPostRender?(node: HTMLElement, instance: File<LAnnotation>): unknown;\n}\ninterface AnnotationElementCache<LAnnotation> {\n element: HTMLElement;\n annotation: LineAnnotation<LAnnotation>;\n}\ninterface HydrationSetup<LAnnotation> {\n file: FileContents;\n lineAnnotations: LineAnnotation<LAnnotation>[] | undefined;\n}\nexport declare class File<LAnnotation = undefined> {\n options: FileOptions<LAnnotation>;\n private workerManager?;\n private isContainerManaged;\n static LoadedCustomComponent: boolean;\n readonly __id: string;\n protected fileContainer: HTMLElement | undefined;\n protected spriteSVG: SVGElement | undefined;\n protected pre: HTMLPreElement | undefined;\n protected code: HTMLElement | undefined;\n protected bufferBefore: HTMLElement | undefined;\n protected bufferAfter: HTMLElement | undefined;\n protected themeCSSStyle: HTMLStyleElement | undefined;\n protected appliedThemeCSS: AppliedThemeStyleCache | undefined;\n protected unsafeCSSStyle: HTMLStyleElement | undefined;\n protected appliedUnsafeCSS: string | undefined;\n protected gutterUtilityContent: HTMLElement | undefined;\n protected errorWrapper: HTMLElement | undefined;\n protected placeHolder: HTMLElement | undefined;\n protected lastRenderedHeaderHTML: string | undefined;\n protected appliedPreAttributes: PrePropertiesConfig | undefined;\n protected lastRowCount: number | undefined;\n protected headerElement: HTMLElement | undefined;\n protected headerCustom: HTMLElement | undefined;\n protected headerPrefix: HTMLElement | undefined;\n protected headerMetadata: HTMLElement | undefined;\n protected fileRenderer: FileRenderer<LAnnotation>;\n protected resizeManager: ResizeManager;\n protected interactionManager: InteractionManager<'file'>;\n protected annotationCache: Map<string, AnnotationElementCache<LAnnotation>>;\n protected lineAnnotations: LineAnnotation<LAnnotation>[];\n protected file: FileContents | undefined;\n protected renderRange: RenderRange | undefined;\n constructor(options?: FileOptions<LAnnotation>, workerManager?: WorkerPoolManager | undefined, isContainerManaged?: boolean);\n private handleHighlightRender;\n rerender(): void;\n setOptions(options: FileOptions<LAnnotation> | undefined): void;\n private mergeOptions;\n setThemeType(themeType: ThemeTypes): void;\n getHoveredLine: () => {\n lineNumber: number;\n } | undefined;\n setLineAnnotations(lineAnnotations: LineAnnotation<LAnnotation>[]): void;\n setSelectedLines(range: SelectedLineRange | null): void;\n cleanUp(): void;\n hydrate(props: FileHydrateProps<LAnnotation>): void;\n protected hydrateElements(fileContainer: HTMLElement, prerenderedHTML: string | undefined): void;\n protected hydrationSetup({ file, lineAnnotations }: HydrationSetup<LAnnotation>): void;\n getOrCreateLineCache(file?: FileContents | undefined): string[];\n render({ file, fileContainer, forceRender, preventEmit, containerWrapper, lineAnnotations, renderRange }: FileRenderProps<LAnnotation>): boolean;\n private emitPostRender;\n private removeRenderedCode;\n private clearAuxiliaryNodes;\n private canPartiallyRender;\n renderPlaceholder(height: number): boolean;\n private cleanChildNodes;\n private renderAnnotations;\n private renderGutterUtility;\n private injectUnsafeCSS;\n private applyThemeState;\n private applyFullRender;\n private applyPartialRender;\n private getColumns;\n private trimDOMToOverlap;\n private getDOMBoundaryIndices;\n private getLineIndexFromDOMNode;\n private applyBuffers;\n private applyHeaderToDOM;\n private clearHeaderSlots;\n private upsertHeaderSlotElement;\n private replaceHeaderSlotContent;\n private createHeaderSlotElement;\n protected getOrCreateFileContainerNode(fileContainer?: HTMLElement, parentNode?: HTMLElement): HTMLElement;\n private getOrCreatePreNode;\n private syncCodeNodeFromPre;\n private applyPreNodeAttributes;\n private applyErrorToDOM;\n private cleanupErrorWrapper;\n}\nexport {};\n//# sourceMappingURL=File.d.ts.map"],"mappings":";;;;;;;;UAKiBe;QACPP;kBACUS;EAFHF,gBAAAA,CAAAA,EAGME,WAHSD;EACtBR,WAAAA,CAAAA,EAAAA,OAAAA;EACUS,WAAAA,CAAAA,EAAAA,OAAAA;EACGA,eAAAA,CAAAA,EAGDR,cAHCQ,CAGcD,WAHdC,CAAAA,EAAAA;EAGcD,WAAAA,CAAAA,EACnBJ,WADmBI;;AACnBJ,UAEDM,gBAFCN,CAAAA,WAAAA,CAAAA,SAEqCO,IAFrCP,CAE0CG,eAF1CH,CAE0DI,WAF1DJ,CAAAA,EAAAA,eAAAA,CAAAA,CAAAA;EAAW,aAAA,EAGVK,WAHU;EAEZC,eAAAA,CAAAA,EAAAA,MAAgB;;AAA2BH,UAI3CK,WAJ2CL,CAAAA,WAAAA,CAAAA,SAIVR,eAJUQ,EAIOb,6BAJPa,CAAAA,MAAAA,CAAAA,CAAAA;EACzCE,iBAAAA,CAAAA,EAAAA,OAAAA;EADoCE;;AAIvD;EAMyBR,kBAAAA,CAAAA,EAAAA,OAA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AA,CAAAA,IAAAA,CAAAA,EADmBpB,YACnBoB,GAAAA,SAAAA,CAAAA,EAAAA,MAAAA,EAAAA;EAAME,MAAAA,CAAAA;IAAAA,IAAAA;IAAAA,aAAAA;IAAAA,WAAAA;IAAAA,WAAAA;IAAAA,gBAAAA;IAAAA,eAAAA;IAAAA;EAAAA,CAAAA,EAA2Ff,eAA3Fe,CAA2Gd,WAA3Gc,CAAAA,CAAAA,EAAAA,OAAAA;EAAeC,QAAAA,cAAAA;EAAaC,QAAAA,kBAAAA;EAAaC,QAAAA,mBAAAA;EAAkBJ,QAAAA,kBAAAA;EAAiBK,iBAAAA,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAAAA,OAAAA;EAA+BlB,QAAAA,eAAAA;EAAhBD,QAAAA,iBAAAA;EAuBnDE,QAAAA,mBAAAA;EAA0BA,QAAAA,eAAAA;EAAcA,QAAAA,eAAAA;EAAW,QAAA,eAAA;;;;;;;;;;;;yDAAnDA,0BAA0BA,cAAcA"}
|
|
1
|
+
{"version":3,"file":"File.d.ts","names":["GetHoveredLineResult","InteractionManager","InteractionManagerBaseOptions","SelectedLineRange","SelectionWriteOptions","ResizeManager","FileRenderer","AppliedThemeStyleCache","BaseCodeOptions","FileContents","LineAnnotation","PrePropertiesConfig","RenderFileMetadata","RenderRange","ThemeTypes","WorkerPoolManager","FileRenderProps","LAnnotation","HTMLElement","FileHydrateProps","Omit","FileOptions","File","AnnotationElementCache","HydrationSetup","SVGElement","HTMLPreElement","HTMLStyleElement","Map","file","lineAnnotations","fileContainer","forceRender","preventEmit","containerWrapper","deferManagers","renderRange"],"sources":["../../src/components/File.d.ts"],"sourcesContent":["import { type GetHoveredLineResult, InteractionManager, type InteractionManagerBaseOptions, type SelectedLineRange, type SelectionWriteOptions } from '../managers/InteractionManager';\nimport { ResizeManager } from '../managers/ResizeManager';\nimport { FileRenderer } from '../renderers/FileRenderer';\nimport type { AppliedThemeStyleCache, BaseCodeOptions, FileContents, LineAnnotation, PrePropertiesConfig, RenderFileMetadata, RenderRange, ThemeTypes } from '../types';\nimport type { WorkerPoolManager } from '../worker';\nexport interface FileRenderProps<LAnnotation> {\n file: FileContents;\n fileContainer?: HTMLElement;\n containerWrapper?: HTMLElement;\n deferManagers?: boolean;\n forceRender?: boolean;\n preventEmit?: boolean;\n lineAnnotations?: LineAnnotation<LAnnotation>[];\n renderRange?: RenderRange;\n}\nexport interface FileHydrateProps<LAnnotation> extends Omit<FileRenderProps<LAnnotation>, 'fileContainer'> {\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\nexport interface FileOptions<LAnnotation> extends BaseCodeOptions, InteractionManagerBaseOptions<'file'> {\n disableFileHeader?: boolean;\n renderHeaderPrefix?: RenderFileMetadata;\n renderHeaderMetadata?: RenderFileMetadata;\n renderCustomHeader?: RenderFileMetadata;\n /**\n * When true, errors during rendering are rethrown instead of being caught\n * and displayed in the DOM. Useful for testing or when you want to handle\n * errors yourself.\n */\n disableErrorHandling?: boolean;\n renderAnnotation?(annotation: LineAnnotation<LAnnotation>): HTMLElement | undefined;\n renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null | undefined;\n onPostRender?(node: HTMLElement, instance: File<LAnnotation>): unknown;\n}\ninterface AnnotationElementCache<LAnnotation> {\n element: HTMLElement;\n annotation: LineAnnotation<LAnnotation>;\n}\ninterface HydrationSetup<LAnnotation> {\n file: FileContents;\n lineAnnotations: LineAnnotation<LAnnotation>[] | undefined;\n}\nexport declare class File<LAnnotation = undefined> {\n options: FileOptions<LAnnotation>;\n private workerManager?;\n private isContainerManaged;\n static LoadedCustomComponent: boolean;\n readonly __id: string;\n protected fileContainer: HTMLElement | undefined;\n protected spriteSVG: SVGElement | undefined;\n protected pre: HTMLPreElement | undefined;\n protected code: HTMLElement | undefined;\n protected bufferBefore: HTMLElement | undefined;\n protected bufferAfter: HTMLElement | undefined;\n protected themeCSSStyle: HTMLStyleElement | undefined;\n protected appliedThemeCSS: AppliedThemeStyleCache | undefined;\n protected unsafeCSSStyle: HTMLStyleElement | undefined;\n protected appliedUnsafeCSS: string | undefined;\n protected gutterUtilityContent: HTMLElement | undefined;\n protected errorWrapper: HTMLElement | undefined;\n protected placeHolder: HTMLElement | undefined;\n protected lastRenderedHeaderHTML: string | undefined;\n protected appliedPreAttributes: PrePropertiesConfig | undefined;\n protected lastRowCount: number | undefined;\n protected headerElement: HTMLElement | undefined;\n protected headerCustom: HTMLElement | undefined;\n protected headerPrefix: HTMLElement | undefined;\n protected headerMetadata: HTMLElement | undefined;\n protected fileRenderer: FileRenderer<LAnnotation>;\n protected resizeManager: ResizeManager;\n protected interactionManager: InteractionManager<'file'>;\n protected annotationCache: Map<string, AnnotationElementCache<LAnnotation>>;\n protected lineAnnotations: LineAnnotation<LAnnotation>[];\n protected managersDirty: boolean;\n protected file: FileContents | undefined;\n protected renderRange: RenderRange | undefined;\n protected enabled: boolean;\n constructor(options?: FileOptions<LAnnotation>, workerManager?: WorkerPoolManager | undefined, isContainerManaged?: boolean);\n private handleHighlightRender;\n rerender(): void;\n setOptions(options: FileOptions<LAnnotation> | undefined): void;\n private mergeOptions;\n setThemeType(themeType: ThemeTypes): void;\n private applyCachedThemeState;\n private hasThemeChanged;\n getHoveredLine: () => {\n lineNumber: number;\n } | undefined;\n setLineAnnotations(lineAnnotations: LineAnnotation<LAnnotation>[]): void;\n setSelectedLines(range: SelectedLineRange | null, options?: SelectionWriteOptions): void;\n flushManagers(): void;\n cleanUp(recycle?: boolean): void;\n virtualizedSetup(): void;\n hydrate(props: FileHydrateProps<LAnnotation>): void;\n protected hydrateElements(fileContainer: HTMLElement, prerenderedHTML: string | undefined): void;\n protected hydrationSetup({ file, lineAnnotations }: HydrationSetup<LAnnotation>): void;\n getOrCreateLineCache(file?: FileContents | undefined): string[];\n render({ file, fileContainer, forceRender, preventEmit, containerWrapper, deferManagers, lineAnnotations, renderRange }: FileRenderProps<LAnnotation>): boolean;\n private emitPostRender;\n private removeRenderedCode;\n private clearAuxiliaryNodes;\n private canPartiallyRender;\n renderPlaceholder(height: number): boolean;\n private cleanChildNodes;\n private renderAnnotations;\n private renderGutterUtility;\n private injectUnsafeCSS;\n private applyThemeState;\n private applyFullRender;\n private applyPartialRender;\n private getColumns;\n private trimDOMToOverlap;\n private getDOMBoundaryIndices;\n private getLineIndexFromDOMNode;\n private applyBuffers;\n protected shouldDisableVirtualizationBuffers(): boolean;\n private applyHeaderToDOM;\n private clearHeaderSlots;\n private upsertHeaderSlotElement;\n private replaceHeaderSlotContent;\n private createHeaderSlotElement;\n protected getOrCreateFileContainerNode(fileContainer?: HTMLElement, parentNode?: HTMLElement): HTMLElement;\n private getOrCreatePreNode;\n private syncCodeNodeFromPre;\n private applyPreNodeAttributes;\n private applyErrorToDOM;\n private cleanupErrorWrapper;\n}\nexport {};\n//# sourceMappingURL=File.d.ts.map"],"mappings":";;;;;;;;UAKiBgB;QACPP;kBACUS;EAFHF,gBAAAA,CAAAA,EAGME,WAHSD;EACtBR,aAAAA,CAAAA,EAAAA,OAAAA;EACUS,WAAAA,CAAAA,EAAAA,OAAAA;EACGA,WAAAA,CAAAA,EAAAA,OAAAA;EAIcD,eAAAA,CAAAA,EAAfP,cAAeO,CAAAA,WAAAA,CAAAA,EAAAA;EAAfP,WAAAA,CAAAA,EACJG,WADIH;;AACO,UAEZS,gBAFY,CAAA,WAAA,CAAA,SAE0BC,IAF1B,CAE+BJ,eAF/B,CAE+CC,WAF/C,CAAA,EAAA,eAAA,CAAA,CAAA;EAEZE,aAAAA,EACED,WADcD;EAA2CA,eAAAA,CAAAA,EAAAA,MAAAA;;AACzDC,UAGFG,WAHEH,CAAAA,WAAAA,CAAAA,SAG+BV,eAH/BU,EAGgDhB,6BAHhDgB,CAAAA,MAAAA,CAAAA,CAAAA;EADoCE,iBAAAA,CAAAA,EAAAA,OAAAA;EAAI,kBAAA,CAAA,EAMlCR,kBANkC;EAI1CS,oBAAW,CAAAJ,EAGDL,kBAHC;EAEHA,kBAAAA,CA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