@pierre/diffs 1.2.0-beta.6 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/components/CodeView.d.ts +16 -4
  2. package/dist/components/CodeView.d.ts.map +1 -1
  3. package/dist/components/CodeView.js +108 -31
  4. package/dist/components/CodeView.js.map +1 -1
  5. package/dist/components/File.d.ts +5 -0
  6. package/dist/components/File.d.ts.map +1 -1
  7. package/dist/components/File.js +54 -10
  8. package/dist/components/File.js.map +1 -1
  9. package/dist/components/FileDiff.d.ts +5 -1
  10. package/dist/components/FileDiff.d.ts.map +1 -1
  11. package/dist/components/FileDiff.js +56 -14
  12. package/dist/components/FileDiff.js.map +1 -1
  13. package/dist/components/FileStream.js +1 -0
  14. package/dist/components/FileStream.js.map +1 -1
  15. package/dist/components/UnresolvedFile.d.ts.map +1 -1
  16. package/dist/components/UnresolvedFile.js +1 -1
  17. package/dist/components/VirtualizedFileDiff.js +2 -2
  18. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  19. package/dist/components/Virtualizer.js +1 -1
  20. package/dist/components/Virtualizer.js.map +1 -1
  21. package/dist/constants.d.ts.map +1 -1
  22. package/dist/highlighter/shared_highlighter.js +14 -0
  23. package/dist/highlighter/shared_highlighter.js.map +1 -1
  24. package/dist/index.d.ts +5 -1
  25. package/dist/index.js +7 -3
  26. package/dist/renderers/DiffHunksRenderer.d.ts +2 -0
  27. package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
  28. package/dist/renderers/DiffHunksRenderer.js +34 -21
  29. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  30. package/dist/renderers/FileRenderer.d.ts +3 -0
  31. package/dist/renderers/FileRenderer.d.ts.map +1 -1
  32. package/dist/renderers/FileRenderer.js +37 -23
  33. package/dist/renderers/FileRenderer.js.map +1 -1
  34. package/dist/style.js +1 -1
  35. package/dist/style.js.map +1 -1
  36. package/dist/types.d.ts +1 -1
  37. package/dist/types.d.ts.map +1 -1
  38. package/dist/utils/areDiffTargetsEqual.d.ts +7 -0
  39. package/dist/utils/areDiffTargetsEqual.d.ts.map +1 -0
  40. package/dist/utils/areDiffTargetsEqual.js +8 -0
  41. package/dist/utils/areDiffTargetsEqual.js.map +1 -0
  42. package/dist/utils/areFileRenderOptionsEqual.d.ts +7 -0
  43. package/dist/utils/areFileRenderOptionsEqual.d.ts.map +1 -0
  44. package/dist/utils/areFileRenderOptionsEqual.js +10 -0
  45. package/dist/utils/areFileRenderOptionsEqual.js.map +1 -0
  46. package/dist/utils/areWorkerStatsEqual.js +1 -1
  47. package/dist/utils/areWorkerStatsEqual.js.map +1 -1
  48. package/dist/utils/detachString.d.ts +2 -1
  49. package/dist/utils/detachString.d.ts.map +1 -1
  50. package/dist/utils/detachString.js +12 -10
  51. package/dist/utils/detachString.js.map +1 -1
  52. package/dist/utils/isStyleNode.d.ts +5 -0
  53. package/dist/utils/isStyleNode.d.ts.map +1 -0
  54. package/dist/utils/isStyleNode.js +10 -0
  55. package/dist/utils/isStyleNode.js.map +1 -0
  56. package/dist/utils/parsePatchFiles.d.ts +1 -7
  57. package/dist/utils/parsePatchFiles.d.ts.map +1 -1
  58. package/dist/utils/parsePatchFiles.js +18 -4
  59. package/dist/utils/parsePatchFiles.js.map +1 -1
  60. package/dist/utils/prefersReducedMotion.d.ts +5 -0
  61. package/dist/utils/prefersReducedMotion.d.ts.map +1 -0
  62. package/dist/utils/prefersReducedMotion.js +9 -0
  63. package/dist/utils/prefersReducedMotion.js.map +1 -0
  64. package/dist/worker/WorkerPoolManager.d.ts +33 -5
  65. package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
  66. package/dist/worker/WorkerPoolManager.js +278 -79
  67. package/dist/worker/WorkerPoolManager.js.map +1 -1
  68. package/dist/worker/types.d.ts +7 -3
  69. package/dist/worker/types.d.ts.map +1 -1
  70. package/dist/worker/worker-portable.js +9 -9
  71. package/dist/worker/worker-portable.js.map +1 -1
  72. package/dist/worker/worker.js +3 -0
  73. package/dist/worker/worker.js.map +1 -1
  74. package/package.json +2 -6
@@ -113,8 +113,9 @@ declare class CodeView<LAnnotation = undefined> {
113
113
  private scrollTop;
114
114
  private scrollPageOffset;
115
115
  private scrollDirty;
116
- private pointerEventsRestoreTimer;
116
+ private scrollInteractionFixTimer;
117
117
  private pointerEventsDisabled;
118
+ private codeOverflowFix;
118
119
  private height;
119
120
  private heightDirty;
120
121
  private windowSpecs;
@@ -128,6 +129,8 @@ declare class CodeView<LAnnotation = undefined> {
128
129
  private container;
129
130
  private stickyContainer;
130
131
  private stickyOffset;
132
+ private elementPool;
133
+ private pendingElementPool;
131
134
  private options;
132
135
  private workerManager;
133
136
  private isContainerManaged;
@@ -138,14 +141,23 @@ declare class CodeView<LAnnotation = undefined> {
138
141
  private shouldDisablePointerEvents;
139
142
  private shouldValidateItemHeights;
140
143
  private validateRenderedItemHeight;
141
- private clearPointerEventsTimer;
142
- private suspendPointerEvents;
143
- private restorePointerEvents;
144
+ private clearScrollInteractionTimer;
145
+ private suspendScrollInteractions;
146
+ private restoreScrollInteractions;
144
147
  private syncLayout;
145
148
  setup(root: HTMLElement): void;
146
149
  reset(): void;
147
150
  cleanUp(): void;
148
151
  private cleanAllRenderedItems;
152
+ private primeScrollTarget;
153
+ private acquireElement;
154
+ private releaseRenderedItem;
155
+ private cleanElementForPool;
156
+ private queueElementForPool;
157
+ private promotePendingPooledElements;
158
+ private isElementClean;
159
+ private getElementPoolSize;
160
+ private clearElementPool;
149
161
  private resolveEffectiveScrollBehavior;
150
162
  scrollTo(target: CodeViewScrollTarget): void;
151
163
  setSelectedLines(selection: CodeViewLineSelection | null, options?: SelectionWriteOptions): void;
@@ -1 +1 @@
1
- {"version":3,"file":"CodeView.d.ts","names":["SelectionWriteOptions","CodeViewDiffItem","CodeViewFileItem","CodeViewItem","CodeViewLayout","CodeViewScrollTarget","HunkSeparators","SelectedLineRange","SmoothScrollSettings","VirtualFileMetrics","VirtualWindowSpecs","WorkerPoolManager","FileOptions","FileDiffOptions","VirtualizedFile","VirtualizedFileDiff","VirtualizerConfig","AdvancedVirtualizedBaseItem","HTMLElement","CodeViewDiffItemContext","LAnnotation","CodeViewFileItemContext","CodeViewRenderedDiffItem","CodeViewRenderedFileItem","CodeViewRenderedItem","CodeViewLineSelection","CodeViewCoordinator","CodeViewScrollListener","CodeView","OverloadCallbackArgs","TCallback","TArgs","CallbackReturn","TReturn","OverloadFileCallbackArgs","TKey","NonNullable","OverloadDiffCallbackArgs","CodeViewOptionCallback","CODE_VIEW_DIFF_OPTION_KEYS","CodeViewDiffOptionKeys","CodeViewPassThroughOptions","Pick","CODE_VIEW_SHARED_CALLBACK_KEYS","CODE_VIEW_SELECTION_CALLBACK_KEYS","CodeViewSharedCallbackKeys","CodeViewSelectionCallbackKeys","CodeViewSharedCallbackOptions","CodeViewSelectionCallbackOptions","CodeViewOptions","Exclude","Partial"],"sources":["../../src/components/CodeView.d.ts"],"sourcesContent":["import type { SelectionWriteOptions } from '../managers/InteractionManager';\nimport type { CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewLayout, CodeViewScrollTarget, HunkSeparators, SelectedLineRange, SmoothScrollSettings, VirtualFileMetrics, VirtualWindowSpecs } from '../types';\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';\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: number | undefined;\n}\ninterface CodeViewDiffItemContext<LAnnotation> 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}\ninterface CodeViewFileItemContext<LAnnotation> 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}\nexport interface CodeViewRenderedDiffItem<LAnnotation> {\n id: string;\n type: 'diff';\n item: CodeViewDiffItem<LAnnotation>;\n version: number | undefined;\n element: HTMLElement;\n instance: VirtualizedFileDiff<LAnnotation>;\n}\nexport interface CodeViewRenderedFileItem<LAnnotation> {\n id: string;\n type: 'file';\n item: CodeViewFileItem<LAnnotation>;\n version: number | undefined;\n element: HTMLElement;\n instance: VirtualizedFile<LAnnotation>;\n}\nexport type CodeViewRenderedItem<LAnnotation> = CodeViewRenderedDiffItem<LAnnotation> | CodeViewRenderedFileItem<LAnnotation>;\nexport interface CodeViewLineSelection {\n id: string;\n range: SelectedLineRange;\n}\nexport interface CodeViewCoordinator<LAnnotation> {\n hasHeaderRenderers: boolean;\n hasAnnotationRenderer: boolean;\n hasGutterRenderer: boolean;\n onSnapshotChange(snapshot: CodeViewRenderedItem<LAnnotation>[] | undefined): void;\n}\nexport type CodeViewScrollListener<LAnnotation> = (scrollTop: number, viewer: CodeView<LAnnotation>) => void;\ntype OverloadCallbackArgs<TCallback> = TCallback extends (...args: infer TArgs) => unknown ? TArgs : never;\ntype CallbackReturn<TCallback> = TCallback extends (...args: never[]) => infer TReturn ? TReturn : never;\ntype OverloadFileCallbackArgs<LAnnotation, TKey extends keyof FileOptions<LAnnotation>> = OverloadCallbackArgs<NonNullable<FileOptions<LAnnotation>[TKey]>>;\ntype OverloadDiffCallbackArgs<LAnnotation, TKey extends keyof FileDiffOptions<LAnnotation>> = OverloadCallbackArgs<NonNullable<FileDiffOptions<LAnnotation>[TKey]>>;\ntype CodeViewOptionCallback<LAnnotation, TKey extends keyof FileOptions<LAnnotation> & keyof FileDiffOptions<LAnnotation>> = {\n (...args: [\n ...OverloadFileCallbackArgs<LAnnotation, TKey>,\n context: CodeViewFileItemContext<LAnnotation>\n ]): CallbackReturn<NonNullable<FileOptions<LAnnotation>[TKey]>>;\n (...args: [\n ...OverloadDiffCallbackArgs<LAnnotation, TKey>,\n context: CodeViewDiffItemContext<LAnnotation>\n ]): CallbackReturn<NonNullable<FileDiffOptions<LAnnotation>[TKey]>>;\n};\ndeclare const CODE_VIEW_DIFF_OPTION_KEYS: readonly [\"theme\", \"disableLineNumbers\", \"overflow\", \"themeType\", \"disableFileHeader\", \"disableVirtualizationBuffers\", \"preferredHighlighter\", \"useCSSClasses\", \"useTokenTransformer\", \"tokenizeMaxLineLength\", \"tokenizeMaxLength\", \"unsafeCSS\", \"diffStyle\", \"diffIndicators\", \"disableBackground\", \"expandUnchanged\", \"collapsedContextThreshold\", \"lineDiffType\", \"maxLineDiffLength\", \"expansionLineCount\", \"lineHoverHighlight\", \"enableTokenInteractionsOnWhitespace\", \"enableGutterUtility\", \"__debugPointerEvents\", \"enableLineSelection\", \"controlledSelection\", \"disableErrorHandling\"];\ntype CodeViewDiffOptionKeys = (typeof CODE_VIEW_DIFF_OPTION_KEYS)[number];\ntype CodeViewPassThroughOptions<LAnnotation> = Pick<FileDiffOptions<LAnnotation>, CodeViewDiffOptionKeys>;\ndeclare const CODE_VIEW_SHARED_CALLBACK_KEYS: readonly [\"renderCustomHeader\", \"renderHeaderPrefix\", \"renderHeaderMetadata\", \"renderAnnotation\", \"renderGutterUtility\", \"onPostRender\", \"onGutterUtilityClick\", \"onLineClick\", \"onLineNumberClick\", \"onLineEnter\", \"onLineLeave\", \"onTokenClick\", \"onTokenEnter\", \"onTokenLeave\"];\ndeclare const CODE_VIEW_SELECTION_CALLBACK_KEYS: readonly [\"onLineSelected\", \"onLineSelectionStart\", \"onLineSelectionChange\", \"onLineSelectionEnd\"];\ntype CodeViewSharedCallbackKeys = (typeof CODE_VIEW_SHARED_CALLBACK_KEYS)[number];\ntype CodeViewSelectionCallbackKeys = (typeof CODE_VIEW_SELECTION_CALLBACK_KEYS)[number];\ntype CodeViewSharedCallbackOptions<LAnnotation> = {\n [TKey in CodeViewSharedCallbackKeys]?: CodeViewOptionCallback<LAnnotation, TKey>;\n};\ntype CodeViewSelectionCallbackOptions<LAnnotation> = {\n [TKey in CodeViewSelectionCallbackKeys]?: CodeViewOptionCallback<LAnnotation, TKey>;\n};\nexport interface CodeViewOptions<LAnnotation> extends CodeViewPassThroughOptions<LAnnotation>, CodeViewSharedCallbackOptions<LAnnotation>, CodeViewSelectionCallbackOptions<LAnnotation> {\n hunkSeparators?: Exclude<HunkSeparators, 'custom'>;\n itemMetrics?: Partial<VirtualFileMetrics>;\n pointerEventsOnScroll?: boolean;\n smoothScrollSettings?: SmoothScrollSettings;\n stickyHeaders?: boolean;\n controlledSelection?: boolean;\n onSelectedLinesChange?(selection: CodeViewLineSelection | null): void;\n layout?: CodeViewLayout;\n /** Internal dev-only check to ensure your `itemMetrics` are correct. Its\n * automatically disabled in a production build because it will hurt\n * performance fairly significantly */\n __devOnlyValidateItemHeights?: boolean;\n}\nexport declare class CodeView<LAnnotation = undefined> {\n static __STOP: boolean;\n static __lastScrollPosition: number;\n type: \"advanced\";\n readonly config: VirtualizerConfig;\n private items;\n private idToItem;\n private selectedLines;\n private instanceToItem;\n private layoutDirtyIndex;\n private slotCoordinator;\n private slotSnapshot;\n private scrollListeners;\n private scrollHeight;\n private containerHeight;\n private scrollTop;\n private scrollPageOffset;\n private scrollDirty;\n private pointerEventsRestoreTimer;\n private pointerEventsDisabled;\n private height;\n private heightDirty;\n private windowSpecs;\n private renderState;\n private itemMetricsCache;\n private pendingScrollTarget;\n private pendingLayoutAnchor;\n private scrollAnimation;\n private root;\n private resizeObserver;\n private container;\n private stickyContainer;\n private stickyOffset;\n private options;\n private workerManager;\n private isContainerManaged;\n constructor(options?: CodeViewOptions<LAnnotation>, workerManager?: WorkerPoolManager | undefined, isContainerManaged?: boolean);\n private getLayout;\n private computeMetricsCache;\n private getSmoothScrollSettings;\n private shouldDisablePointerEvents;\n private shouldValidateItemHeights;\n private validateRenderedItemHeight;\n private clearPointerEventsTimer;\n private suspendPointerEvents;\n private restorePointerEvents;\n private syncLayout;\n setup(root: HTMLElement): void;\n reset(): void;\n cleanUp(): void;\n private cleanAllRenderedItems;\n private resolveEffectiveScrollBehavior;\n scrollTo(target: CodeViewScrollTarget): void;\n setSelectedLines(selection: CodeViewLineSelection | null, options?: SelectionWriteOptions): void;\n getSelectedLines(): CodeViewLineSelection | null;\n clearSelectedLines(options?: SelectionWriteOptions): void;\n getItem(itemId: string): CodeViewItem<LAnnotation> | undefined;\n updateItem(input: CodeViewItem<LAnnotation>): boolean;\n updateItemId(oldId: string, newId: string): boolean;\n addItem(input: CodeViewItem<LAnnotation>): void;\n addItems(inputs: readonly CodeViewItem<LAnnotation>[]): void;\n setItems(items: readonly CodeViewItem<LAnnotation>[]): void;\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 private canSkipRenderForAppend;\n setOptions(options: CodeViewOptions<LAnnotation> | undefined): void;\n private capturePendingLayoutAnchor;\n render(immediate?: boolean): void;\n instanceChanged(instance: VirtualizedFile<LAnnotation> | VirtualizedFileDiff<LAnnotation>, layoutDirty: boolean): void;\n getWindowSpecs(): VirtualWindowSpecs;\n getContainerElement(): HTMLElement | undefined;\n getRenderedItems(): CodeViewRenderedItem<LAnnotation>[];\n setSlotCoordinator(coordinator?: CodeViewCoordinator<LAnnotation>): boolean;\n getSlotSnapshot(coordinator: CodeViewCoordinator<LAnnotation>): CodeViewRenderedItem<LAnnotation>[] | undefined;\n subscribeToScroll(listener: CodeViewScrollListener<LAnnotation>): () => void;\n getLocalTopForInstance(instance: VirtualizedFile<LAnnotation> | VirtualizedFileDiff<LAnnotation>): number;\n getTopForItem(id: string): number | undefined;\n private createItem;\n private getItemById;\n private getItemByMode;\n private applySelectedLines;\n private syncSelection;\n private renamePendingScrollTarget;\n private renamePendingLayoutAnchor;\n private wrapCallbackWithContext;\n private getWrappedOptionCallback;\n private getWrappedSelectionOptionCallback;\n private createOptions;\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;\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;\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;\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;\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 private getMaxScrollTopForHeight;\n private getMaxScrollTop;\n private shouldRebaseScroll;\n private getPagedScrollHeight;\n private getMaxPagedScrollTop;\n private clampPagedScrollTop;\n /**\n * Clamps a logical scroll position to the min/max allowable scroll range\n * based on the full computed content height.\n */\n private clampScrollTop;\n private getMaxScrollPageOffset;\n private clampScrollPageOffset;\n private resolveScrollPageWindow;\n /**\n * Resolve how a logical scrollTop maps onto the reusable paged scroll window\n * without mutating the current page offset.\n */\n private resolvePagedScrollPosition;\n private needsScrollPageUpdate;\n private getPagedLayoutTop;\n private getStickyHeaderOffset;\n private getScrollTargetRect;\n private normalizeScrollTarget;\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 /**\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 private getLineScrollPosition;\n private getRangeScrollPosition;\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 computeTargetScrollTopForFrame;\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 /**\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 private computeRenderRangeAndEmit;\n private flushManagers;\n private syncContainerHeight;\n private getStickyBounds;\n private applyStickyPositioning;\n private syncPagedScrollScaffolding;\n private reconcileRenderedItems;\n private updateStickyPositioning;\n private handleScroll;\n private clearPendingScroll;\n private handleResize;\n /**\n * Figure out scrollTop accounting for sticky header if enabled and\n * necessary\n */\n private getScrollAnchorViewportTop;\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;\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;\n /**\n * Apply a device-pixel-rounded scroll position if it differs from the last\n * logical scrollTop synchronized into the paged scroll scaffold.\n */\n private applyScrollFix;\n /**\n * Decide whether a pending programmatic scroll has reached its\n * destination and should be cleared.\n */\n private isPendingTargetSettled;\n getScrollTop(): number;\n getHeight(): number;\n getScrollHeight(): number;\n private flushSlotCoordinator;\n private notifyScroll;\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;\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;\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;\n private resetRenderState;\n private getFitPerfectlyOverscroll;\n}\nexport {};\n//# sourceMappingURL=CodeView.d.ts.map"],"mappings":";;;;;;;;;;;UAQUiB,2BAAAA;;;EAAAA;EAaAE,GAAAA,EAAAA,MAAAA;EAGiBC;EAAjBnB,MAAAA,EAAAA,MAAAA;EAEwBmB;;EALqBH,OAAAA,EAJ1CC,WAI0CD,GAAAA,SAAAA;EAA2B;EAOxEI,OAAAA,EAAAA,MAAAA,GAAAA,SAAuB;;UAPvBF,uBAUAjB,CAAAA,WAAAA,CAAAA,SAV6Ce,2BAU7Cf,CAAAA;EAEoBkB,IAAAA,EAAAA,MAAAA;EAAhBN;EALyCG,IAAAA,EAJ7ChB,gBAI6CgB,CAJ5BG,WAI4BH,CAAAA;EAA2B;EAOjEK,QAAAA,EATHP,mBAS2B,CATPK,WASOA,CAAAA;;UAP/BC,uBAUApB,CAAAA,WAAAA,CAAAA,SAV6CgB,2BAU7ChB,CAAAA;EAEGiB,IAAAA,EAAAA,MAAAA;EACqBE;EAApBL,IAAAA,EAVJb,gBAUIa,CAVaK,WAUbL,CAAAA;EAAmB;EAEhBQ,QAAAA,EAVHT,eAUGS,CAVaH,WAUWA,CAAAA;;AAG/BlB,UA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EAAmDM,QAAAA,0BAAAA;EAApBL,MAAAA,CAAAA,SAAAA,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,IAAAA;EAAmB,eAAA,CAAA,QAAA,EAPzDD,eAOyD,CAPzCM,WAOyC,CAAA,GAP1BL,mBAO0B,CAPNK,WAOM,CAAA,EAAA,WAAA,EAAA,OAAA,CAAA,EAAA,IAAA;oBANjEV;yBACKQ;sBACHM,qBAAqBJ;mCACRM,oBAAoBN;+BACxBM,oBAAoBN,eAAeI,qBAAqBJ;8BACzDO,uBAAuBP;mCAClBN,gBAAgBM,eAAeL,oBAAoBK"}
1
+ {"version":3,"file":"CodeView.d.ts","names":["SelectionWriteOptions","CodeViewDiffItem","CodeViewFileItem","CodeViewItem","CodeViewLayout","CodeViewScrollTarget","HunkSeparators","SelectedLineRange","SmoothScrollSettings","VirtualFileMetrics","VirtualWindowSpecs","WorkerPoolManager","FileOptions","FileDiffOptions","VirtualizedFile","VirtualizedFileDiff","VirtualizerConfig","AdvancedVirtualizedBaseItem","HTMLElement","CodeViewDiffItemContext","LAnnotation","CodeViewFileItemContext","CodeViewRenderedDiffItem","CodeViewRenderedFileItem","CodeViewRenderedItem","CodeViewLineSelection","CodeViewCoordinator","CodeViewScrollListener","CodeView","OverloadCallbackArgs","TCallback","TArgs","CallbackReturn","TReturn","OverloadFileCallbackArgs","TKey","NonNullable","OverloadDiffCallbackArgs","CodeViewOptionCallback","CODE_VIEW_DIFF_OPTION_KEYS","CodeViewDiffOptionKeys","CodeViewPassThroughOptions","Pick","CODE_VIEW_SHARED_CALLBACK_KEYS","CODE_VIEW_SELECTION_CALLBACK_KEYS","CodeViewSharedCallbackKeys","CodeViewSelectionCallbackKeys","CodeViewSharedCallbackOptions","CodeViewSelectionCallbackOptions","CodeViewOptions","Exclude","Partial"],"sources":["../../src/components/CodeView.d.ts"],"sourcesContent":["import type { SelectionWriteOptions } from '../managers/InteractionManager';\nimport type { CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewLayout, CodeViewScrollTarget, HunkSeparators, SelectedLineRange, SmoothScrollSettings, VirtualFileMetrics, VirtualWindowSpecs } from '../types';\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';\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: number | undefined;\n}\ninterface CodeViewDiffItemContext<LAnnotation> 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}\ninterface CodeViewFileItemContext<LAnnotation> 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}\nexport interface CodeViewRenderedDiffItem<LAnnotation> {\n id: string;\n type: 'diff';\n item: CodeViewDiffItem<LAnnotation>;\n version: number | undefined;\n element: HTMLElement;\n instance: VirtualizedFileDiff<LAnnotation>;\n}\nexport interface CodeViewRenderedFileItem<LAnnotation> {\n id: string;\n type: 'file';\n item: CodeViewFileItem<LAnnotation>;\n version: number | undefined;\n element: HTMLElement;\n instance: VirtualizedFile<LAnnotation>;\n}\nexport type CodeViewRenderedItem<LAnnotation> = CodeViewRenderedDiffItem<LAnnotation> | CodeViewRenderedFileItem<LAnnotation>;\nexport interface CodeViewLineSelection {\n id: string;\n range: SelectedLineRange;\n}\nexport interface CodeViewCoordinator<LAnnotation> {\n hasHeaderRenderers: boolean;\n hasAnnotationRenderer: boolean;\n hasGutterRenderer: boolean;\n onSnapshotChange(snapshot: CodeViewRenderedItem<LAnnotation>[] | undefined): void;\n}\nexport type CodeViewScrollListener<LAnnotation> = (scrollTop: number, viewer: CodeView<LAnnotation>) => void;\ntype OverloadCallbackArgs<TCallback> = TCallback extends (...args: infer TArgs) => unknown ? TArgs : never;\ntype CallbackReturn<TCallback> = TCallback extends (...args: never[]) => infer TReturn ? TReturn : never;\ntype OverloadFileCallbackArgs<LAnnotation, TKey extends keyof FileOptions<LAnnotation>> = OverloadCallbackArgs<NonNullable<FileOptions<LAnnotation>[TKey]>>;\ntype OverloadDiffCallbackArgs<LAnnotation, TKey extends keyof FileDiffOptions<LAnnotation>> = OverloadCallbackArgs<NonNullable<FileDiffOptions<LAnnotation>[TKey]>>;\ntype CodeViewOptionCallback<LAnnotation, TKey extends keyof FileOptions<LAnnotation> & keyof FileDiffOptions<LAnnotation>> = {\n (...args: [\n ...OverloadFileCallbackArgs<LAnnotation, TKey>,\n context: CodeViewFileItemContext<LAnnotation>\n ]): CallbackReturn<NonNullable<FileOptions<LAnnotation>[TKey]>>;\n (...args: [\n ...OverloadDiffCallbackArgs<LAnnotation, TKey>,\n context: CodeViewDiffItemContext<LAnnotation>\n ]): CallbackReturn<NonNullable<FileDiffOptions<LAnnotation>[TKey]>>;\n};\ndeclare const CODE_VIEW_DIFF_OPTION_KEYS: readonly [\"theme\", \"disableLineNumbers\", \"overflow\", \"themeType\", \"disableFileHeader\", \"disableVirtualizationBuffers\", \"preferredHighlighter\", \"useCSSClasses\", \"useTokenTransformer\", \"tokenizeMaxLineLength\", \"tokenizeMaxLength\", \"unsafeCSS\", \"diffStyle\", \"diffIndicators\", \"disableBackground\", \"expandUnchanged\", \"collapsedContextThreshold\", \"lineDiffType\", \"maxLineDiffLength\", \"expansionLineCount\", \"lineHoverHighlight\", \"enableTokenInteractionsOnWhitespace\", \"enableGutterUtility\", \"__debugPointerEvents\", \"enableLineSelection\", \"controlledSelection\", \"disableErrorHandling\"];\ntype CodeViewDiffOptionKeys = (typeof CODE_VIEW_DIFF_OPTION_KEYS)[number];\ntype CodeViewPassThroughOptions<LAnnotation> = Pick<FileDiffOptions<LAnnotation>, CodeViewDiffOptionKeys>;\ndeclare const CODE_VIEW_SHARED_CALLBACK_KEYS: readonly [\"renderCustomHeader\", \"renderHeaderPrefix\", \"renderHeaderMetadata\", \"renderAnnotation\", \"renderGutterUtility\", \"onPostRender\", \"onGutterUtilityClick\", \"onLineClick\", \"onLineNumberClick\", \"onLineEnter\", \"onLineLeave\", \"onTokenClick\", \"onTokenEnter\", \"onTokenLeave\"];\ndeclare const CODE_VIEW_SELECTION_CALLBACK_KEYS: readonly [\"onLineSelected\", \"onLineSelectionStart\", \"onLineSelectionChange\", \"onLineSelectionEnd\"];\ntype CodeViewSharedCallbackKeys = (typeof CODE_VIEW_SHARED_CALLBACK_KEYS)[number];\ntype CodeViewSelectionCallbackKeys = (typeof CODE_VIEW_SELECTION_CALLBACK_KEYS)[number];\ntype CodeViewSharedCallbackOptions<LAnnotation> = {\n [TKey in CodeViewSharedCallbackKeys]?: CodeViewOptionCallback<LAnnotation, TKey>;\n};\ntype CodeViewSelectionCallbackOptions<LAnnotation> = {\n [TKey in CodeViewSelectionCallbackKeys]?: CodeViewOptionCallback<LAnnotation, TKey>;\n};\nexport interface CodeViewOptions<LAnnotation> extends CodeViewPassThroughOptions<LAnnotation>, CodeViewSharedCallbackOptions<LAnnotation>, CodeViewSelectionCallbackOptions<LAnnotation> {\n hunkSeparators?: Exclude<HunkSeparators, 'custom'>;\n itemMetrics?: Partial<VirtualFileMetrics>;\n pointerEventsOnScroll?: boolean;\n smoothScrollSettings?: SmoothScrollSettings;\n stickyHeaders?: boolean;\n controlledSelection?: boolean;\n onSelectedLinesChange?(selection: CodeViewLineSelection | null): void;\n layout?: CodeViewLayout;\n /** Internal dev-only check to ensure your `itemMetrics` are correct. Its\n * automatically disabled in a production build because it will hurt\n * performance fairly significantly */\n __devOnlyValidateItemHeights?: boolean;\n}\nexport declare class CodeView<LAnnotation = undefined> {\n static __STOP: boolean;\n static __lastScrollPosition: number;\n type: \"advanced\";\n readonly config: VirtualizerConfig;\n private items;\n private idToItem;\n private selectedLines;\n private instanceToItem;\n private layoutDirtyIndex;\n private slotCoordinator;\n private slotSnapshot;\n private scrollListeners;\n private scrollHeight;\n private containerHeight;\n private scrollTop;\n private scrollPageOffset;\n private scrollDirty;\n private scrollInteractionFixTimer;\n private pointerEventsDisabled;\n private codeOverflowFix;\n private height;\n private heightDirty;\n private windowSpecs;\n private renderState;\n private itemMetricsCache;\n private pendingScrollTarget;\n private pendingLayoutAnchor;\n private scrollAnimation;\n private root;\n private resizeObserver;\n private container;\n private stickyContainer;\n private stickyOffset;\n private elementPool;\n private pendingElementPool;\n private options;\n private workerManager;\n private isContainerManaged;\n constructor(options?: CodeViewOptions<LAnnotation>, workerManager?: WorkerPoolManager | undefined, isContainerManaged?: boolean);\n private getLayout;\n private computeMetricsCache;\n private getSmoothScrollSettings;\n private shouldDisablePointerEvents;\n private shouldValidateItemHeights;\n private validateRenderedItemHeight;\n private clearScrollInteractionTimer;\n private suspendScrollInteractions;\n private restoreScrollInteractions;\n private syncLayout;\n setup(root: HTMLElement): void;\n reset(): void;\n cleanUp(): void;\n private cleanAllRenderedItems;\n private primeScrollTarget;\n private acquireElement;\n private releaseRenderedItem;\n private cleanElementForPool;\n private queueElementForPool;\n private promotePendingPooledElements;\n private isElementClean;\n private getElementPoolSize;\n private clearElementPool;\n private resolveEffectiveScrollBehavior;\n scrollTo(target: CodeViewScrollTarget): void;\n setSelectedLines(selection: CodeViewLineSelection | null, options?: SelectionWriteOptions): void;\n getSelectedLines(): CodeViewLineSelection | null;\n clearSelectedLines(options?: SelectionWriteOptions): void;\n getItem(itemId: string): CodeViewItem<LAnnotation> | undefined;\n updateItem(input: CodeViewItem<LAnnotation>): boolean;\n updateItemId(oldId: string, newId: string): boolean;\n addItem(input: CodeViewItem<LAnnotation>): void;\n addItems(inputs: readonly CodeViewItem<LAnnotation>[]): void;\n setItems(items: readonly CodeViewItem<LAnnotation>[]): void;\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 private canSkipRenderForAppend;\n setOptions(options: CodeViewOptions<LAnnotation> | undefined): void;\n private capturePendingLayoutAnchor;\n render(immediate?: boolean): void;\n instanceChanged(instance: VirtualizedFile<LAnnotation> | VirtualizedFileDiff<LAnnotation>, layoutDirty: boolean): void;\n getWindowSpecs(): VirtualWindowSpecs;\n getContainerElement(): HTMLElement | undefined;\n getRenderedItems(): CodeViewRenderedItem<LAnnotation>[];\n setSlotCoordinator(coordinator?: CodeViewCoordinator<LAnnotation>): boolean;\n getSlotSnapshot(coordinator: CodeViewCoordinator<LAnnotation>): CodeViewRenderedItem<LAnnotation>[] | undefined;\n subscribeToScroll(listener: CodeViewScrollListener<LAnnotation>): () => void;\n getLocalTopForInstance(instance: VirtualizedFile<LAnnotation> | VirtualizedFileDiff<LAnnotation>): number;\n getTopForItem(id: string): number | undefined;\n private createItem;\n private getItemById;\n private getItemByMode;\n private applySelectedLines;\n private syncSelection;\n private renamePendingScrollTarget;\n private renamePendingLayoutAnchor;\n private wrapCallbackWithContext;\n private getWrappedOptionCallback;\n private getWrappedSelectionOptionCallback;\n private createOptions;\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;\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;\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;\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;\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 private getMaxScrollTopForHeight;\n private getMaxScrollTop;\n private shouldRebaseScroll;\n private getPagedScrollHeight;\n private getMaxPagedScrollTop;\n private clampPagedScrollTop;\n /**\n * Clamps a logical scroll position to the min/max allowable scroll range\n * based on the full computed content height.\n */\n private clampScrollTop;\n private getMaxScrollPageOffset;\n private clampScrollPageOffset;\n private resolveScrollPageWindow;\n /**\n * Resolve how a logical scrollTop maps onto the reusable paged scroll window\n * without mutating the current page offset.\n */\n private resolvePagedScrollPosition;\n private needsScrollPageUpdate;\n private getPagedLayoutTop;\n private getStickyHeaderOffset;\n private getScrollTargetRect;\n private normalizeScrollTarget;\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 /**\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 private getLineScrollPosition;\n private getRangeScrollPosition;\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 computeTargetScrollTopForFrame;\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 /**\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 private computeRenderRangeAndEmit;\n private flushManagers;\n private syncContainerHeight;\n private getStickyBounds;\n private applyStickyPositioning;\n private syncPagedScrollScaffolding;\n private reconcileRenderedItems;\n private updateStickyPositioning;\n private handleScroll;\n private clearPendingScroll;\n private handleResize;\n /**\n * Figure out scrollTop accounting for sticky header if enabled and\n * necessary\n */\n private getScrollAnchorViewportTop;\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;\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;\n /**\n * Apply a device-pixel-rounded scroll position if it differs from the last\n * logical scrollTop synchronized into the paged scroll scaffold.\n */\n private applyScrollFix;\n /**\n * Decide whether a pending programmatic scroll has reached its\n * destination and should be cleared.\n */\n private isPendingTargetSettled;\n getScrollTop(): number;\n getHeight(): number;\n getScrollHeight(): number;\n private flushSlotCoordinator;\n private notifyScroll;\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;\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;\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;\n private resetRenderState;\n private getFitPerfectlyOverscroll;\n}\nexport {};\n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TRIBUTE, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DIFFS_DEVELOPMENT_BUILD, DIFFS_TAG_NAME, THEME_CSS_ATTRIBUTE, UNSAFE_CSS_ATTRIBUTE } from "../constants.js";
2
2
  import { dequeueRender, queueRender } from "../managers/UniversalRenderingManager.js";
3
3
  import { areObjectsEqual } from "../utils/areObjectsEqual.js";
4
4
  import { areSelectionsEqual } from "../utils/areSelectionsEqual.js";
5
+ import { areThemesEqual } from "../utils/areThemesEqual.js";
5
6
  import { createWindowFromScrollPosition } from "../utils/createWindowFromScrollPosition.js";
7
+ import { isStyleNode } from "../utils/isStyleNode.js";
8
+ import { prefersReducedMotion } from "../utils/prefersReducedMotion.js";
6
9
  import { roundToDevicePixel } from "../utils/roundToDevicePixel.js";
7
10
  import { VirtualizedFile } from "./VirtualizedFile.js";
8
11
  import { VirtualizedFileDiff } from "./VirtualizedFileDiff.js";
@@ -80,12 +83,21 @@ const CODE_VIEW_SELECTION_CALLBACK_KEYS = [
80
83
  "onLineSelectionChange",
81
84
  "onLineSelectionEnd"
82
85
  ];
83
- const DEFAULT_POINTER_EVENTS_RESTORE_DELAY_MS = 120;
86
+ const DEFAULT_SCROLL_INTERACTION_RESTORE_DELAY_MS = 120;
87
+ const SCROLLING_CODE_OVERFLOW_FIX_VARIABLE = "--diffs-overflow-override";
84
88
  const SCROLL_REBASE_CONTAINER_HEIGHT = 12e6;
85
89
  const SCROLL_REBASE_TRIGGER_TOP = 1e6;
86
90
  const SCROLL_REBASE_TARGET_TOP = 2e6;
87
91
  const SCROLL_REBASE_TARGET_BOTTOM = SCROLL_REBASE_CONTAINER_HEIGHT - SCROLL_REBASE_TARGET_TOP;
88
92
  const SCROLL_REBASE_THRESHOLD = SCROLL_REBASE_CONTAINER_HEIGHT - SCROLL_REBASE_TRIGGER_TOP;
93
+ const CODE_VIEW_ELEMENT_POOL_LIMIT = 32;
94
+ const MOBILE_SAFARI = (() => {
95
+ const { navigator } = globalThis;
96
+ const userAgent = navigator.userAgent;
97
+ const isIOS = /iP(?:hone|ad|od)/.test(userAgent);
98
+ const isIPadOS = navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
99
+ return (isIOS || isIPadOS) && /AppleWebKit/.test(userAgent) && /Safari/.test(userAgent) && !/(CriOS|FxiOS|EdgiOS|OPiOS)/.test(userAgent);
100
+ })();
89
101
  var CodeView = class CodeView {
90
102
  static __STOP = false;
91
103
  static __lastScrollPosition = 0;
@@ -108,8 +120,9 @@ var CodeView = class CodeView {
108
120
  scrollTop = 0;
109
121
  scrollPageOffset = 0;
110
122
  scrollDirty = true;
111
- pointerEventsRestoreTimer;
123
+ scrollInteractionFixTimer;
112
124
  pointerEventsDisabled = false;
125
+ codeOverflowFix = false;
113
126
  height = 0;
114
127
  heightDirty = true;
115
128
  windowSpecs = {
@@ -133,6 +146,8 @@ var CodeView = class CodeView {
133
146
  container = document.createElement("div");
134
147
  stickyContainer = document.createElement("div");
135
148
  stickyOffset = document.createElement("div");
149
+ elementPool = [];
150
+ pendingElementPool = [];
136
151
  options;
137
152
  workerManager;
138
153
  isContainerManaged;
@@ -197,26 +212,34 @@ var CodeView = class CodeView {
197
212
  instance: item.instance
198
213
  });
199
214
  }
200
- clearPointerEventsTimer() {
201
- if (this.pointerEventsRestoreTimer != null) {
202
- clearTimeout(this.pointerEventsRestoreTimer);
203
- this.pointerEventsRestoreTimer = void 0;
215
+ clearScrollInteractionTimer() {
216
+ if (this.scrollInteractionFixTimer != null) {
217
+ clearTimeout(this.scrollInteractionFixTimer);
218
+ this.scrollInteractionFixTimer = void 0;
204
219
  }
205
220
  }
206
- suspendPointerEvents() {
207
- if (!this.shouldDisablePointerEvents()) return;
208
- this.clearPointerEventsTimer();
209
- if (!this.pointerEventsDisabled) {
221
+ suspendScrollInteractions() {
222
+ this.clearScrollInteractionTimer();
223
+ if (this.shouldDisablePointerEvents() && !this.pointerEventsDisabled) {
210
224
  this.stickyContainer.style.pointerEvents = "none";
211
225
  this.pointerEventsDisabled = true;
212
226
  }
213
- this.pointerEventsRestoreTimer = setTimeout(this.restorePointerEvents, DEFAULT_POINTER_EVENTS_RESTORE_DELAY_MS);
227
+ if (MOBILE_SAFARI && !this.codeOverflowFix) {
228
+ this.stickyContainer.style.setProperty(SCROLLING_CODE_OVERFLOW_FIX_VARIABLE, "hidden");
229
+ this.codeOverflowFix = true;
230
+ }
231
+ this.scrollInteractionFixTimer = setTimeout(this.restoreScrollInteractions, DEFAULT_SCROLL_INTERACTION_RESTORE_DELAY_MS);
214
232
  }
215
- restorePointerEvents = () => {
216
- this.clearPointerEventsTimer();
217
- if (!this.pointerEventsDisabled) return;
218
- this.stickyContainer.style.removeProperty("pointer-events");
219
- this.pointerEventsDisabled = false;
233
+ restoreScrollInteractions = () => {
234
+ this.clearScrollInteractionTimer();
235
+ if (this.pointerEventsDisabled) {
236
+ this.stickyContainer.style.removeProperty("pointer-events");
237
+ this.pointerEventsDisabled = false;
238
+ }
239
+ if (this.codeOverflowFix) {
240
+ this.stickyContainer.style.setProperty(SCROLLING_CODE_OVERFLOW_FIX_VARIABLE, "auto");
241
+ this.codeOverflowFix = false;
242
+ }
220
243
  };
221
244
  syncLayout() {
222
245
  const { gap, paddingBottom, paddingTop } = this.getLayout();
@@ -261,7 +284,7 @@ var CodeView = class CodeView {
261
284
  };
262
285
  }
263
286
  reset() {
264
- this.restorePointerEvents();
287
+ this.restoreScrollInteractions();
265
288
  this.cleanAllRenderedItems();
266
289
  this.selectedLines = null;
267
290
  this.items.length = 0;
@@ -288,7 +311,8 @@ var CodeView = class CodeView {
288
311
  }
289
312
  cleanUp() {
290
313
  this.reset();
291
- this.restorePointerEvents();
314
+ this.clearElementPool();
315
+ this.restoreScrollInteractions();
292
316
  this.resizeObserver?.disconnect();
293
317
  this.resizeObserver = void 0;
294
318
  this.root?.removeEventListener("scroll", this.handleScroll);
@@ -309,10 +333,59 @@ var CodeView = class CodeView {
309
333
  for (let index = this.renderState.firstIndex; index <= this.renderState.lastIndex; index++) {
310
334
  const item = this.items[index];
311
335
  if (item == null) throw new Error(`CodeView.cleanAllRenderedItems: Item does not exist at index: ${index}`);
312
- cleanRenderedItem(item);
336
+ this.releaseRenderedItem(item);
337
+ }
338
+ }
339
+ primeScrollTarget(target) {
340
+ if (target.type === "position") return;
341
+ const item = this.idToItem.get(target.id);
342
+ if (item == null) return;
343
+ item.instance.primeHighlightCache();
344
+ }
345
+ acquireElement() {
346
+ this.promotePendingPooledElements();
347
+ return this.elementPool.pop() ?? document.createElement(DIFFS_TAG_NAME);
348
+ }
349
+ releaseRenderedItem(item) {
350
+ const { element } = item;
351
+ item.instance.cleanUp(true);
352
+ item.element = void 0;
353
+ if (element == null) return;
354
+ element.remove();
355
+ this.cleanElementForPool(element);
356
+ this.queueElementForPool(element);
357
+ }
358
+ cleanElementForPool(element) {
359
+ const { shadowRoot } = element;
360
+ if (shadowRoot != null) {
361
+ for (const child of Array.from(shadowRoot.children)) if (!isPooledShadowChild(child)) child.remove();
313
362
  }
363
+ if (!this.isContainerManaged) element.replaceChildren();
364
+ }
365
+ queueElementForPool(element) {
366
+ if (this.getElementPoolSize() >= CODE_VIEW_ELEMENT_POOL_LIMIT) return;
367
+ if (this.isElementClean(element)) this.elementPool.push(element);
368
+ else this.pendingElementPool.push(element);
369
+ }
370
+ promotePendingPooledElements() {
371
+ if (this.pendingElementPool.length === 0) return;
372
+ const { pendingElementPool: pendingElements } = this;
373
+ this.pendingElementPool = [];
374
+ for (const element of pendingElements) if (this.isElementClean(element) && this.elementPool.length < CODE_VIEW_ELEMENT_POOL_LIMIT) this.elementPool.push(element);
375
+ else if (this.getElementPoolSize() < CODE_VIEW_ELEMENT_POOL_LIMIT) this.pendingElementPool.push(element);
376
+ }
377
+ isElementClean(element) {
378
+ return element.childNodes.length === 0;
379
+ }
380
+ getElementPoolSize() {
381
+ return this.elementPool.length + this.pendingElementPool.length;
382
+ }
383
+ clearElementPool() {
384
+ this.elementPool.length = 0;
385
+ this.pendingElementPool.length = 0;
314
386
  }
315
387
  resolveEffectiveScrollBehavior(target, destination) {
388
+ if (prefersReducedMotion()) return "instant";
316
389
  if (target.behavior !== "smooth-auto") return target.behavior ?? "instant";
317
390
  return Math.abs(destination - this.getScrollTop()) <= this.getHeight() * 10 ? "smooth" : "instant";
318
391
  }
@@ -322,13 +395,14 @@ var CodeView = class CodeView {
322
395
  if (pendingTarget == null) return;
323
396
  const destination = this.resolveScrollTargetTop(pendingTarget);
324
397
  if (destination == null) return;
398
+ this.primeScrollTarget(pendingTarget);
325
399
  if (this.resolveEffectiveScrollBehavior(pendingTarget, destination) === "smooth") this.scrollAnimation ??= {
326
400
  position: this.getScrollTop(),
327
401
  velocity: 0,
328
402
  lastTimestamp: performance.now()
329
403
  };
330
404
  else this.scrollAnimation = void 0;
331
- this.suspendPointerEvents();
405
+ this.suspendScrollInteractions();
332
406
  this.pendingLayoutAnchor = void 0;
333
407
  this.pendingScrollTarget = pendingTarget;
334
408
  this.render();
@@ -435,6 +509,7 @@ var CodeView = class CodeView {
435
509
  this.capturePendingLayoutAnchor();
436
510
  const previousLayout = this.getLayout();
437
511
  const { itemMetricsCache: previousItemMetrics } = this;
512
+ if (shouldClearPool(this.options, options)) this.clearElementPool();
438
513
  this.options = options;
439
514
  const nextItemMetrics = this.computeMetricsCache(options.itemMetrics);
440
515
  const itemMetricsChanged = !areObjectsEqual(previousItemMetrics, nextItemMetrics);
@@ -715,7 +790,7 @@ var CodeView = class CodeView {
715
790
  for (let index = 0; index < previousItems.length; index++) {
716
791
  const removedItem = previousItems[index];
717
792
  if (removedItem == null || !removedItems.has(removedItem)) continue;
718
- cleanRenderedItem(removedItem);
793
+ this.releaseRenderedItem(removedItem);
719
794
  const dirtyIndex = Math.max(nextItems.length - 1, 0);
720
795
  firstDirtyIndex = Math.min(firstDirtyIndex ?? dirtyIndex, dirtyIndex);
721
796
  }
@@ -1057,7 +1132,7 @@ var CodeView = class CodeView {
1057
1132
  if (firstIndex >= 0) for (let index = firstIndex; index <= lastIndex; index++) {
1058
1133
  const item = this.items[index];
1059
1134
  if (item == null) throw new Error(`CodeView.computeRenderRangeAndEmit: No item at index: ${index}`);
1060
- if (!(item.top > top - item.height && item.top <= bottom)) cleanRenderedItem(item);
1135
+ if (!(item.top > top - item.height && item.top <= bottom)) this.releaseRenderedItem(item);
1061
1136
  }
1062
1137
  let prevElement;
1063
1138
  const updatedItems = /* @__PURE__ */ new Set();
@@ -1068,7 +1143,7 @@ var CodeView = class CodeView {
1068
1143
  if (item == null) throw new Error(`CodeView.computeRenderRangeAndEmit: missing item`);
1069
1144
  const { instance } = item;
1070
1145
  if (item.element == null) {
1071
- item.element = document.createElement(DIFFS_TAG_NAME);
1146
+ item.element = this.acquireElement();
1072
1147
  syncRenderedItemOrder(this.stickyContainer, item.element, prevElement);
1073
1148
  instance.virtualizedSetup();
1074
1149
  if (renderItem(item, item.element)) updatedItems.add(item);
@@ -1190,7 +1265,7 @@ var CodeView = class CodeView {
1190
1265
  }
1191
1266
  handleScroll = () => {
1192
1267
  if (CodeView.__STOP) return;
1193
- this.suspendPointerEvents();
1268
+ this.suspendScrollInteractions();
1194
1269
  this.scrollDirty = true;
1195
1270
  this.notifyScroll();
1196
1271
  this.render();
@@ -1303,7 +1378,7 @@ var CodeView = class CodeView {
1303
1378
  const targetPagedScrollTop = pagedScrollTop;
1304
1379
  const rebaseChanged = previousPageOffset !== scrollPageOffset;
1305
1380
  if (roundedTargetScrollTop === this.renderState.scrollTop && roundedTargetScrollTop === roundedSyncedScrollTop && targetPagedScrollTop === syncedPagedScrollTop && !rebaseChanged) return;
1306
- this.suspendPointerEvents();
1381
+ this.suspendScrollInteractions();
1307
1382
  if (targetPagedScrollTop !== syncedPagedScrollTop || rebaseChanged) {
1308
1383
  this.scrollPageOffset = scrollPageOffset;
1309
1384
  this.syncPagedScrollScaffolding(windowSpecs);
@@ -1436,16 +1511,18 @@ var CodeView = class CodeView {
1436
1511
  return this.getLayout().gap + this.itemMetricsCache.diffHeaderHeight;
1437
1512
  }
1438
1513
  };
1439
- function cleanRenderedItem(item) {
1440
- item.instance.cleanUp(true);
1441
- item.element?.remove();
1442
- item.element = void 0;
1443
- }
1444
1514
  function prepareItemInstance(item) {
1445
1515
  item.instance.cleanUp(true);
1446
1516
  if (item.type === "diff") return item.instance.prepareVirtualizedItem(item.item.fileDiff);
1447
1517
  else return item.instance.prepareVirtualizedItem(item.item.file);
1448
1518
  }
1519
+ function shouldClearPool(previousOptions, nextOptions) {
1520
+ return !areThemesEqual(previousOptions.theme ?? DEFAULT_THEMES, nextOptions.theme ?? DEFAULT_THEMES) || (previousOptions.themeType ?? "system") !== (nextOptions.themeType ?? "system") || previousOptions.unsafeCSS !== nextOptions.unsafeCSS;
1521
+ }
1522
+ function isPooledShadowChild(child) {
1523
+ if (child instanceof SVGElement) return true;
1524
+ return isStyleNode(child) && (child.hasAttribute(CORE_CSS_ATTRIBUTE) || child.hasAttribute(THEME_CSS_ATTRIBUTE) || child.hasAttribute(UNSAFE_CSS_ATTRIBUTE));
1525
+ }
1449
1526
  function formatSelectedLineRange(range) {
1450
1527
  const start = formatSelectedLinePoint(range.start, range.side);
1451
1528
  const end = formatSelectedLinePoint(range.end, range.endSide ?? range.side);