@pierre/diffs 1.2.0-beta.3 → 1.2.0-beta.5

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 (71) hide show
  1. package/dist/components/CodeView.d.ts +18 -10
  2. package/dist/components/CodeView.d.ts.map +1 -1
  3. package/dist/components/CodeView.js +124 -32
  4. package/dist/components/CodeView.js.map +1 -1
  5. package/dist/components/File.d.ts +3 -2
  6. package/dist/components/File.d.ts.map +1 -1
  7. package/dist/components/File.js +13 -4
  8. package/dist/components/File.js.map +1 -1
  9. package/dist/components/FileDiff.d.ts +3 -2
  10. package/dist/components/FileDiff.d.ts.map +1 -1
  11. package/dist/components/FileDiff.js +13 -4
  12. package/dist/components/FileDiff.js.map +1 -1
  13. package/dist/components/FileStream.js +6 -3
  14. package/dist/components/FileStream.js.map +1 -1
  15. package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
  16. package/dist/components/web-components.js +4 -0
  17. package/dist/components/web-components.js.map +1 -1
  18. package/dist/constants.d.ts +6 -3
  19. package/dist/constants.d.ts.map +1 -1
  20. package/dist/constants.js +11 -2
  21. package/dist/constants.js.map +1 -1
  22. package/dist/index.d.ts +5 -5
  23. package/dist/index.js +3 -3
  24. package/dist/managers/InteractionManager.d.ts +22 -10
  25. package/dist/managers/InteractionManager.d.ts.map +1 -1
  26. package/dist/managers/InteractionManager.js +223 -28
  27. package/dist/managers/InteractionManager.js.map +1 -1
  28. package/dist/react/constants.d.ts.map +1 -1
  29. package/dist/react/constants.js +3 -1
  30. package/dist/react/constants.js.map +1 -1
  31. package/dist/react/index.d.ts +2 -2
  32. package/dist/react/jsx.d.ts.map +1 -1
  33. package/dist/react/types.d.ts +2 -2
  34. package/dist/react/types.d.ts.map +1 -1
  35. package/dist/react/utils/useFileDiffInstance.d.ts +2 -2
  36. package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
  37. package/dist/react/utils/useFileDiffInstance.js.map +1 -1
  38. package/dist/react/utils/useFileInstance.d.ts +2 -2
  39. package/dist/react/utils/useFileInstance.d.ts.map +1 -1
  40. package/dist/react/utils/useFileInstance.js.map +1 -1
  41. package/dist/react/utils/useUnresolvedFileInstance.d.ts +2 -2
  42. package/dist/react/utils/useUnresolvedFileInstance.d.ts.map +1 -1
  43. package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
  44. package/dist/ssr/index.d.ts +2 -2
  45. package/dist/style.js +1 -1
  46. package/dist/style.js.map +1 -1
  47. package/dist/types.d.ts +23 -9
  48. package/dist/types.d.ts.map +1 -1
  49. package/dist/utils/areSelectionsEqual.d.ts +1 -1
  50. package/dist/utils/areSelectionsEqual.d.ts.map +1 -1
  51. package/dist/utils/areSelectionsEqual.js.map +1 -1
  52. package/dist/utils/createGutterUtilityContentNode.js +1 -0
  53. package/dist/utils/createGutterUtilityContentNode.js.map +1 -1
  54. package/dist/utils/cssWrappers.d.ts +3 -2
  55. package/dist/utils/cssWrappers.d.ts.map +1 -1
  56. package/dist/utils/cssWrappers.js +13 -2
  57. package/dist/utils/cssWrappers.js.map +1 -1
  58. package/dist/utils/getFiletypeFromFileName.js +16 -0
  59. package/dist/utils/getFiletypeFromFileName.js.map +1 -1
  60. package/dist/utils/parsePatchFiles.js +15 -0
  61. package/dist/utils/parsePatchFiles.js.map +1 -1
  62. package/dist/utils/scrollbarGutter.d.ts +6 -0
  63. package/dist/utils/scrollbarGutter.d.ts.map +1 -0
  64. package/dist/utils/scrollbarGutter.js +28 -0
  65. package/dist/utils/scrollbarGutter.js.map +1 -0
  66. package/dist/worker/WorkerPoolManager.js.map +1 -1
  67. package/dist/worker/worker-portable.js +26 -1
  68. package/dist/worker/worker-portable.js.map +1 -1
  69. package/dist/worker/worker.js +23 -0
  70. package/dist/worker/worker.js.map +1 -1
  71. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"InteractionManager.js","names":["mode: TMode","options: InteractionManagerOptions<TMode>","reasons: string[]","nextRange: SelectedLineRange | null","lineType: LineTypes | undefined","codeElement: HTMLElement | undefined","lineElement: HTMLElement | undefined","lineIndexValue: string | undefined","numberElement: HTMLElement | undefined","tokenElement: HTMLElement | undefined","tokenInfo: TokenCache | undefined","expandInfo: ExpandCache | undefined","lineNumber: number | undefined","mergeConflictActionTarget: MergeConflictActionTarget | undefined"],"sources":["../../src/managers/InteractionManager.ts"],"sourcesContent":["import { toHtml } from 'hast-util-to-html';\n\nimport type {\n AnnotationSide,\n DiffLineEventBaseProps,\n DiffTokenEventBaseProps,\n ExpansionDirections,\n LineEventBaseProps,\n LineTypes,\n MergeConflictResolution,\n SelectionPoint,\n SelectionSide,\n TokenEventBase,\n} from '../types';\nimport { areSelectionPointsEqual } from '../utils/areSelectionPointsEqual';\nimport { areSelectionsEqual } from '../utils/areSelectionsEqual';\nimport { createGutterUtilityElement } from '../utils/createGutterUtilityElement';\n\ninterface TokenCache {\n tokenElement: HTMLElement;\n lineCharStart: number;\n lineCharEnd: number;\n tokenText: string;\n}\n\ninterface ExpandCache {\n hunkIndex: number | undefined;\n direction: ExpansionDirections;\n all: boolean;\n}\n\nexport type LogTypes = 'click' | 'move' | 'both' | 'none';\n\nexport type InteractionManagerMode = 'file' | 'diff';\n\nexport interface OnLineClickProps extends LineEventBaseProps {\n event: PointerEvent;\n}\n\nexport interface OnLineEnterLeaveProps extends LineEventBaseProps {\n event: PointerEvent;\n}\n\nexport interface OnDiffLineClickProps extends DiffLineEventBaseProps {\n event: PointerEvent;\n}\n\nexport interface OnDiffLineEnterLeaveProps extends DiffLineEventBaseProps {\n event: PointerEvent;\n}\n\nexport interface SelectedLineRange {\n start: number;\n side?: SelectionSide;\n end: number;\n endSide?: SelectionSide;\n}\n\nexport interface SelectionWriteOptions {\n notify?: boolean;\n}\n\nexport type GetLineIndexUtility = (\n lineNumber: number,\n side?: SelectionSide\n) => [number, number] | undefined;\n\ntype EventClickProps<TMode extends InteractionManagerMode> =\n TMode extends 'file' ? OnLineClickProps : OnDiffLineClickProps;\n\ntype PointerEventEnterLeaveProps<TMode extends InteractionManagerMode> =\n TMode extends 'file' ? OnLineEnterLeaveProps : OnDiffLineEnterLeaveProps;\n\ntype EventBaseProps<TMode extends InteractionManagerMode> = TMode extends 'file'\n ? LineEventBaseProps\n : DiffLineEventBaseProps;\n\nexport type OnTokenEventProps<TMode extends InteractionManagerMode> =\n TMode extends 'file' ? TokenEventBase : DiffTokenEventBaseProps;\n\ninterface ExpandoEventProps {\n type: 'line-info';\n hunkIndex: number;\n direction: ExpansionDirections;\n all: boolean;\n}\n\nexport type GetHoveredLineResult<TMode extends InteractionManagerMode> =\n TMode extends 'file'\n ? { lineNumber: number }\n : { lineNumber: number; side: AnnotationSide };\n\ninterface SelectionPointerInfo {\n lineNumber: number;\n eventSide: SelectionSide | undefined;\n lineIndex: number;\n}\n\ninterface ResolvedLineTarget<TMode extends InteractionManagerMode> {\n kind: 'line';\n lineType: LineTypes;\n lineElement: HTMLElement;\n lineNumber: number;\n numberColumn: boolean;\n numberElement: HTMLElement;\n side: TMode extends 'diff' ? AnnotationSide : undefined;\n splitLineIndex: number | undefined;\n}\n\ninterface ResolvedTokenTarget<TMode extends InteractionManagerMode> {\n kind: 'token';\n lineType: LineTypes;\n lineElement: HTMLElement;\n lineNumber: number;\n numberColumn: boolean;\n numberElement: HTMLElement;\n side: TMode extends 'diff' ? AnnotationSide : undefined;\n splitLineIndex: number | undefined;\n tokenElement: HTMLElement;\n tokenText: string;\n lineCharStart: number;\n lineCharEnd: number;\n}\n\nexport interface MergeConflictActionTarget {\n kind: 'merge-conflict-action';\n resolution: MergeConflictResolution;\n conflictIndex: number;\n}\n\ntype ResolvedPointerTarget<TMode extends InteractionManagerMode> =\n | ResolvedLineTarget<TMode>\n | ResolvedTokenTarget<TMode>\n | ExpandoEventProps\n | MergeConflictActionTarget;\n\ntype LinePointerTarget<TMode extends InteractionManagerMode> =\n ResolvedLineTarget<TMode>;\n\ntype TokenPointerTarget<TMode extends InteractionManagerMode> =\n ResolvedTokenTarget<TMode>;\n\ntype HoverableLinePointerTarget<TMode extends InteractionManagerMode> =\n | LinePointerTarget<TMode>\n | TokenPointerTarget<TMode>;\n\ninterface SessionIdle {\n mode: 'idle';\n}\n\ninterface SessionSelecting {\n mode: 'selecting';\n pointerId: number;\n}\n\ninterface SessionPendingSingleLineUnselect {\n mode: 'pendingSingleLineUnselect';\n pointerId: number;\n anchor: SelectionPoint;\n pending: SelectionPoint;\n}\n\ninterface SessionGutterSelecting {\n mode: 'gutterSelecting';\n pointerId: number;\n anchor: SelectionPoint;\n current: SelectionPoint;\n}\n\ntype PointerSession =\n | SessionIdle\n | SessionSelecting\n | SessionPendingSingleLineUnselect\n | SessionGutterSelecting;\n\nexport interface InteractionManagerBaseOptions<\n TMode extends InteractionManagerMode,\n> {\n lineHoverHighlight?: 'disabled' | 'both' | 'number' | 'line';\n enableTokenInteractionsOnWhitespace?: boolean;\n enableGutterUtility?: boolean;\n onGutterUtilityClick?(range: SelectedLineRange): unknown;\n onLineClick?(props: EventClickProps<TMode>): unknown;\n onLineNumberClick?(props: EventClickProps<TMode>): unknown;\n onLineEnter?(props: PointerEventEnterLeaveProps<TMode>): unknown;\n onLineLeave?(props: PointerEventEnterLeaveProps<TMode>): unknown;\n onTokenClick?(props: OnTokenEventProps<TMode>, event: MouseEvent): unknown;\n onTokenEnter?(props: OnTokenEventProps<TMode>, event: PointerEvent): unknown;\n onTokenLeave?(props: OnTokenEventProps<TMode>, event: PointerEvent): unknown;\n __debugPointerEvents?: LogTypes;\n enableLineSelection?: boolean;\n controlledSelection?: boolean;\n onLineSelected?: (range: SelectedLineRange | null) => void;\n onLineSelectionStart?: (range: SelectedLineRange | null) => void;\n onLineSelectionChange?: (range: SelectedLineRange | null) => void;\n onLineSelectionEnd?: (range: SelectedLineRange | null) => void;\n getLineIndex?: GetLineIndexUtility;\n}\n\nexport interface InteractionManagerOptions<\n TMode extends InteractionManagerMode,\n> extends InteractionManagerBaseOptions<TMode> {\n usesCustomGutterUtility?: boolean;\n onHunkExpand?(\n hunkIndex: number,\n direction: ExpansionDirections,\n expansionLineCountOverride?: number\n ): unknown;\n onMergeConflictActionClick?(target: MergeConflictActionTarget): void;\n}\n\ninterface HandlePointerEventProps {\n eventType: 'click' | 'move';\n event: PointerEvent | MouseEvent;\n}\n\nexport class InteractionManager<TMode extends InteractionManagerMode> {\n private hoveredLine: EventBaseProps<TMode> | undefined;\n private hoveredToken: OnTokenEventProps<TMode> | undefined;\n private pre: HTMLPreElement | undefined;\n\n private gutterUtilityContainer: HTMLDivElement | undefined;\n private gutterUtilityButton: HTMLButtonElement | undefined;\n private gutterUtilitySlot: HTMLSlotElement | undefined;\n\n private interactiveLinesAttr = false;\n private interactiveLineNumbersAttr = false;\n\n private hasPointerListeners = false;\n private hasDocumentPointerListeners = false;\n\n private selectedRange: SelectedLineRange | null = null;\n private proposedSelectedRange: SelectedLineRange | null | undefined;\n private renderedSelectionRange: SelectedLineRange | null | undefined;\n private selectionAnchor: SelectionPoint | undefined;\n private queuedSelectionRender: number | undefined;\n private pointerSession: PointerSession = { mode: 'idle' };\n\n constructor(\n private mode: TMode,\n private options: InteractionManagerOptions<TMode>\n ) {}\n\n setOptions(options: InteractionManagerOptions<TMode>): void {\n this.options = options;\n }\n\n cleanUp(): void {\n this.pre?.removeEventListener('click', this.handlePointerClick);\n this.pre?.removeEventListener('pointerdown', this.handlePointerDown);\n this.pre?.removeEventListener('pointermove', this.handlePointerMove);\n this.pre?.removeEventListener('pointerleave', this.handlePointerLeave);\n this.pre?.removeAttribute('data-interactive-lines');\n this.pre?.removeAttribute('data-interactive-line-numbers');\n this.pre = undefined;\n this.gutterUtilityContainer?.remove();\n this.gutterUtilityContainer = undefined;\n this.gutterUtilityButton = undefined;\n this.gutterUtilitySlot = undefined;\n this.clearHoveredLine();\n this.clearHoveredToken();\n this.detachDocumentPointerListeners();\n this.clearPointerSession();\n if (this.queuedSelectionRender != null) {\n cancelAnimationFrame(this.queuedSelectionRender);\n this.queuedSelectionRender = undefined;\n }\n this.interactiveLinesAttr = false;\n this.interactiveLineNumbersAttr = false;\n this.hasPointerListeners = false;\n }\n\n setup(pre: HTMLPreElement): void {\n this.setSelectionDirty();\n const { usesCustomGutterUtility = false, enableGutterUtility = false } =\n this.options;\n\n const newContainer = this.pre !== pre;\n if (newContainer) {\n this.cleanUp();\n this.pre = pre;\n }\n\n if (enableGutterUtility) {\n this.ensureGutterUtilityNode(usesCustomGutterUtility);\n } else if (this.gutterUtilityContainer != null) {\n this.gutterUtilityContainer.remove();\n this.gutterUtilityContainer = undefined;\n this.gutterUtilityButton = undefined;\n this.gutterUtilitySlot = undefined;\n if (this.pointerSession.mode === 'gutterSelecting') {\n this.clearPointerSession();\n this.detachDocumentPointerListeners();\n }\n }\n\n this.syncPointerListeners(pre);\n this.updateInteractiveLineAttributes();\n this.renderSelection();\n }\n\n setSelectionDirty(): void {\n this.renderedSelectionRange = undefined;\n }\n\n isSelectionDirty(): boolean {\n return this.renderedSelectionRange === null;\n }\n\n setSelection(\n range: SelectedLineRange | null,\n options?: SelectionWriteOptions\n ): void {\n const isRangeChange = !(\n range === this.selectedRange ||\n areSelectionsEqual(range ?? undefined, this.selectedRange ?? undefined)\n );\n if (!this.isSelectionDirty() && !isRangeChange) {\n return;\n }\n this.proposedSelectedRange = undefined;\n this.selectedRange = range;\n this.renderSelection();\n if (isRangeChange && options?.notify !== false) {\n this.notifySelectionCommitted();\n }\n }\n\n getSelection(): SelectedLineRange | null {\n return this.selectedRange;\n }\n\n getHoveredLine = (): GetHoveredLineResult<TMode> | undefined => {\n if (this.hoveredLine != null) {\n if (this.mode === 'diff' && this.hoveredLine.type === 'diff-line') {\n return {\n lineNumber: this.hoveredLine.lineNumber,\n side: this.hoveredLine.annotationSide,\n } as GetHoveredLineResult<TMode>;\n }\n if (this.mode === 'file' && this.hoveredLine.type === 'line') {\n return {\n lineNumber: this.hoveredLine.lineNumber,\n } as GetHoveredLineResult<TMode>;\n }\n }\n return undefined;\n };\n\n handlePointerClick = (event: MouseEvent): void => {\n const {\n onHunkExpand,\n onLineClick,\n onLineNumberClick,\n onTokenClick,\n onMergeConflictActionClick,\n } = this.options;\n if (\n onHunkExpand == null &&\n onLineClick == null &&\n onLineNumberClick == null &&\n onMergeConflictActionClick == null &&\n onTokenClick == null\n ) {\n return;\n }\n if (\n this.options.onGutterUtilityClick != null &&\n isGutterUtilityPointerPath(event.composedPath())\n ) {\n return;\n }\n debugLogIfEnabled(\n this.options.__debugPointerEvents,\n 'click',\n 'FileDiff.DEBUG.handlePointerClick:',\n event\n );\n this.handlePointerEvent({ eventType: 'click', event });\n };\n\n handlePointerMove = (event: PointerEvent): void => {\n const {\n lineHoverHighlight = 'disabled',\n onLineEnter,\n onLineLeave,\n onTokenEnter,\n onTokenLeave,\n enableGutterUtility = false,\n } = this.options;\n if (\n lineHoverHighlight === 'disabled' &&\n !enableGutterUtility &&\n onLineEnter == null &&\n onLineLeave == null &&\n onTokenEnter == null &&\n onTokenLeave == null\n ) {\n return;\n }\n debugLogIfEnabled(\n this.options.__debugPointerEvents,\n 'move',\n 'FileDiff.DEBUG.handlePointerMove:',\n event\n );\n // should we perhaps throttle this a bit because move can be fast as fuk\n // boiiii\n this.handlePointerEvent({ eventType: 'move', event });\n };\n\n handlePointerLeave = (event: PointerEvent): void => {\n const { __debugPointerEvents } = this.options;\n debugLogIfEnabled(\n __debugPointerEvents,\n 'move',\n 'FileDiff.DEBUG.handlePointerLeave: no event'\n );\n if (this.hoveredLine == null && this.hoveredToken == null) {\n debugLogIfEnabled(\n __debugPointerEvents,\n 'move',\n 'FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token'\n );\n return;\n }\n this.gutterUtilityContainer?.remove();\n if (this.hoveredToken != null) {\n this.options.onTokenLeave?.(this.hoveredToken, event);\n this.clearHoveredToken();\n }\n\n if (this.hoveredLine != null) {\n this.options.onLineLeave?.({\n ...this.hoveredLine,\n event,\n } as PointerEventEnterLeaveProps<TMode>);\n this.clearHoveredLine();\n }\n };\n\n private handlePointerEvent({ eventType, event }: HandlePointerEventProps) {\n const { __debugPointerEvents } = this.options;\n const composedPath = event.composedPath();\n debugLogIfEnabled(\n __debugPointerEvents,\n eventType,\n 'FileDiff.DEBUG.handlePointerEvent:',\n { eventType, composedPath }\n );\n const target = this.resolvePointerTarget(composedPath);\n debugLogIfEnabled(\n __debugPointerEvents,\n eventType,\n 'FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:',\n target\n );\n\n const {\n onLineClick,\n onLineNumberClick,\n onLineEnter,\n onLineLeave,\n onTokenClick,\n onTokenEnter,\n onTokenLeave,\n onHunkExpand,\n onMergeConflictActionClick,\n } = this.options;\n\n switch (eventType) {\n case 'move': {\n const sameLine =\n isHoverableLinePointerTarget(target) &&\n this.hoveredLine?.lineElement === target.lineElement;\n const sameToken =\n isTokenPointerTarget(target) &&\n this.hoveredToken?.tokenElement === target.tokenElement;\n\n // Handle token transitions\n if (!sameToken) {\n if (this.hoveredToken != null) {\n onTokenLeave?.(this.hoveredToken, event as PointerEvent);\n this.clearHoveredToken();\n }\n if (isTokenPointerTarget(target)) {\n this.setHoveredToken(this.toTokenEventBaseProps(target));\n onTokenEnter?.(\n this.hoveredToken as OnTokenEventProps<TMode>,\n event as PointerEvent\n );\n }\n }\n\n // Handle line transitions\n if (!sameLine) {\n if (this.hoveredLine != null) {\n this.gutterUtilityContainer?.remove();\n onLineLeave?.({\n ...this.hoveredLine,\n event: event as PointerEvent,\n } as PointerEventEnterLeaveProps<TMode>);\n this.clearHoveredLine();\n }\n if (isHoverableLinePointerTarget(target)) {\n this.setHoveredLine(this.toEventBaseProps(target));\n if (this.gutterUtilityContainer != null) {\n target.numberElement.appendChild(this.gutterUtilityContainer);\n }\n onLineEnter?.({\n ...this.hoveredLine,\n event: event as PointerEvent,\n } as PointerEventEnterLeaveProps<TMode>);\n }\n }\n break;\n }\n case 'click': {\n if (target == null) {\n break;\n }\n if (\n isMergeConflictActionPointerTarget(target) &&\n onMergeConflictActionClick != null\n ) {\n onMergeConflictActionClick(target);\n break;\n }\n if (isExpandoPointerTarget(target) && onHunkExpand != null) {\n onHunkExpand(\n target.hunkIndex,\n target.all || event.shiftKey ? 'both' : target.direction,\n target.all || event.shiftKey ? Number.POSITIVE_INFINITY : undefined\n );\n break;\n }\n\n if (!isHoverableLinePointerTarget(target)) {\n break;\n }\n\n if (isTokenPointerTarget(target) && onTokenClick != null) {\n onTokenClick(this.toTokenEventBaseProps(target), event as MouseEvent);\n }\n\n const eventBase = this.toEventBaseProps(target);\n if (onLineNumberClick != null && target.numberColumn) {\n onLineNumberClick({\n ...eventBase,\n event: event as PointerEvent,\n } as EventClickProps<TMode>);\n } else if (onLineClick != null) {\n onLineClick({\n ...eventBase,\n event: event as PointerEvent,\n } as EventClickProps<TMode>);\n }\n break;\n }\n }\n }\n\n private syncPointerListeners(pre: HTMLPreElement): void {\n const {\n __debugPointerEvents,\n lineHoverHighlight = 'disabled',\n onLineClick,\n onLineNumberClick,\n onLineEnter,\n onLineLeave,\n onTokenClick,\n onTokenEnter,\n onTokenLeave,\n onHunkExpand,\n onMergeConflictActionClick,\n enableGutterUtility = false,\n enableLineSelection = false,\n onGutterUtilityClick,\n } = this.options;\n const enableGutterSelection = onGutterUtilityClick != null;\n const shouldAttachPointerListeners =\n lineHoverHighlight !== 'disabled' ||\n onLineClick != null ||\n onLineNumberClick != null ||\n onLineEnter != null ||\n onLineLeave != null ||\n onTokenClick != null ||\n onTokenEnter != null ||\n onTokenLeave != null ||\n onHunkExpand != null ||\n onMergeConflictActionClick != null ||\n enableGutterUtility ||\n enableLineSelection ||\n enableGutterSelection;\n\n if (shouldAttachPointerListeners && !this.hasPointerListeners) {\n pre.addEventListener('click', this.handlePointerClick);\n pre.addEventListener('pointerdown', this.handlePointerDown);\n pre.addEventListener('pointermove', this.handlePointerMove);\n pre.addEventListener('pointerleave', this.handlePointerLeave);\n this.hasPointerListeners = true;\n\n debugLogIfEnabled(\n __debugPointerEvents,\n 'click',\n 'FileDiff.DEBUG.attachEventListeners: Attaching click events for:',\n (() => {\n const reasons: string[] = [];\n if (\n __debugPointerEvents === 'both' ||\n __debugPointerEvents === 'click'\n ) {\n if (onLineClick != null) {\n reasons.push('onLineClick');\n }\n if (onLineNumberClick != null) {\n reasons.push('onLineNumberClick');\n }\n if (onHunkExpand != null) {\n reasons.push('expandable hunk separators');\n }\n if (onMergeConflictActionClick != null) {\n reasons.push('merge conflict actions');\n }\n }\n return reasons;\n })()\n );\n debugLogIfEnabled(\n __debugPointerEvents,\n 'move',\n 'FileDiff.DEBUG.attachEventListeners: Attaching pointer move event'\n );\n debugLogIfEnabled(\n __debugPointerEvents,\n 'move',\n 'FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event'\n );\n } else if (!shouldAttachPointerListeners && this.hasPointerListeners) {\n pre.removeEventListener('click', this.handlePointerClick);\n pre.removeEventListener('pointerdown', this.handlePointerDown);\n pre.removeEventListener('pointermove', this.handlePointerMove);\n pre.removeEventListener('pointerleave', this.handlePointerLeave);\n this.hasPointerListeners = false;\n }\n\n const hasActiveLineSelectionSession =\n this.pointerSession.mode === 'selecting' ||\n this.pointerSession.mode === 'pendingSingleLineUnselect';\n const hasActiveGutterSelectionSession =\n this.pointerSession.mode === 'gutterSelecting';\n if (\n (!enableLineSelection && hasActiveLineSelectionSession) ||\n (!enableGutterSelection && hasActiveGutterSelectionSession)\n ) {\n this.clearPointerSession();\n this.detachDocumentPointerListeners();\n this.selectionAnchor = undefined;\n this.clearPendingSingleLineState();\n }\n }\n\n private updateInteractiveLineAttributes(): void {\n if (this.pre == null) {\n return;\n }\n\n const {\n onLineClick,\n onLineNumberClick,\n enableLineSelection = false,\n } = this.options;\n\n const shouldHaveInteractiveLines = onLineClick != null;\n const shouldHaveInteractiveLineNumbers =\n onLineNumberClick != null || enableLineSelection;\n\n if (shouldHaveInteractiveLines && !this.interactiveLinesAttr) {\n this.pre.setAttribute('data-interactive-lines', '');\n this.interactiveLinesAttr = true;\n } else if (!shouldHaveInteractiveLines && this.interactiveLinesAttr) {\n this.pre.removeAttribute('data-interactive-lines');\n this.interactiveLinesAttr = false;\n }\n\n if (shouldHaveInteractiveLineNumbers && !this.interactiveLineNumbersAttr) {\n this.pre.setAttribute('data-interactive-line-numbers', '');\n this.interactiveLineNumbersAttr = true;\n } else if (\n !shouldHaveInteractiveLineNumbers &&\n this.interactiveLineNumbersAttr\n ) {\n this.pre.removeAttribute('data-interactive-line-numbers');\n this.interactiveLineNumbersAttr = false;\n }\n }\n\n private handlePointerDown = (event: PointerEvent): void => {\n if (\n (event.pointerType === 'mouse' && event.button !== 0) ||\n this.pre == null ||\n this.pointerSession.mode !== 'idle'\n ) {\n return;\n }\n\n const path = event.composedPath();\n if (\n isGutterUtilityPointerPath(path) &&\n this.options.onGutterUtilityClick != null\n ) {\n this.startGutterSelectionFromPointerDown(event, path);\n } else {\n this.startLineSelectionFromPointerDown(event, path);\n }\n };\n\n private startLineSelectionFromPointerDown(\n event: PointerEvent,\n path: (EventTarget | undefined)[]\n ): void {\n const { enableLineSelection = false } = this.options;\n if (!enableLineSelection) {\n return;\n }\n\n const pointerInfo = this.getSelectionPointerInfo(path, true);\n if (pointerInfo == null) {\n return;\n }\n\n const { pre } = this;\n if (pre == null) {\n return;\n }\n\n event.preventDefault();\n const { lineNumber, eventSide, lineIndex } = pointerInfo;\n\n if (event.shiftKey && this.selectedRange != null) {\n const rowRange = this.getIndexesFromSelection(\n this.selectedRange,\n pre.getAttribute('data-diff-type') === 'split'\n );\n if (rowRange == null) {\n return;\n }\n const useStart =\n rowRange.start <= rowRange.end\n ? lineIndex >= rowRange.start\n : lineIndex <= rowRange.end;\n this.selectionAnchor = {\n lineNumber: useStart\n ? this.selectedRange.start\n : this.selectedRange.end,\n side: useStart\n ? this.selectedRange.side\n : (this.selectedRange.endSide ?? this.selectedRange.side),\n };\n this.updateSelection(lineNumber, eventSide, false);\n this.notifySelectionStart(this.getCurrentSelectionRange());\n this.pointerSession = { mode: 'selecting', pointerId: event.pointerId };\n this.attachDocumentPointerListeners();\n return;\n }\n\n if (\n this.selectedRange?.start === lineNumber &&\n this.selectedRange?.end === lineNumber\n ) {\n const point = { lineNumber, side: eventSide };\n this.selectionAnchor = point;\n this.pointerSession = {\n mode: 'pendingSingleLineUnselect',\n pointerId: event.pointerId,\n anchor: point,\n pending: point,\n };\n this.attachDocumentPointerListeners();\n return;\n }\n\n if (this.options.controlledSelection === true) {\n this.proposedSelectedRange = null;\n } else {\n this.selectedRange = null;\n }\n this.selectionAnchor = { lineNumber, side: eventSide };\n this.updateSelection(lineNumber, eventSide, false);\n this.notifySelectionStart(this.getCurrentSelectionRange());\n this.pointerSession = { mode: 'selecting', pointerId: event.pointerId };\n this.attachDocumentPointerListeners();\n }\n\n private startGutterSelectionFromPointerDown(\n event: PointerEvent,\n path: (EventTarget | undefined)[]\n ): void {\n const { enableLineSelection = false, onGutterUtilityClick } = this.options;\n if (onGutterUtilityClick == null) {\n return;\n }\n const point = this.getSelectionPointFromPath(path);\n if (point == null) {\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n this.pointerSession = {\n mode: 'gutterSelecting',\n pointerId: event.pointerId,\n anchor: point,\n current: point,\n };\n if (enableLineSelection) {\n this.selectionAnchor = {\n lineNumber: point.lineNumber,\n side: point.side,\n };\n this.updateSelection(point.lineNumber, point.side, false);\n this.notifySelectionStart(this.getCurrentSelectionRange());\n }\n this.attachDocumentPointerListeners();\n }\n\n private handleDocumentPointerMove = (event: PointerEvent): void => {\n const { enableLineSelection = false } = this.options;\n switch (this.pointerSession.mode) {\n case 'idle':\n return;\n case 'gutterSelecting': {\n if (event.pointerId !== this.pointerSession.pointerId) {\n return;\n }\n const point = this.getSelectionPointFromPath(event.composedPath());\n if (point == null) {\n return;\n }\n this.pointerSession.current = point;\n if (enableLineSelection === true) {\n this.updateSelection(point.lineNumber, point.side);\n }\n return;\n }\n case 'selecting': {\n if (event.pointerId !== this.pointerSession.pointerId) {\n return;\n }\n const pointerInfo = this.getSelectionPointerInfo(\n event.composedPath(),\n false\n );\n if (pointerInfo == null || this.selectionAnchor == null) {\n return;\n }\n this.updateSelection(pointerInfo.lineNumber, pointerInfo.eventSide);\n return;\n }\n case 'pendingSingleLineUnselect': {\n if (event.pointerId !== this.pointerSession.pointerId) {\n return;\n }\n const pointerInfo = this.getSelectionPointerInfo(\n event.composedPath(),\n false\n );\n if (pointerInfo == null || this.selectionAnchor == null) {\n return;\n }\n const point = {\n lineNumber: pointerInfo.lineNumber,\n side: pointerInfo.eventSide,\n };\n if (areSelectionPointsEqual(this.pointerSession.pending, point)) {\n return;\n }\n this.updateSelection(\n pointerInfo.lineNumber,\n pointerInfo.eventSide,\n false\n );\n this.notifySelectionStart(this.getCurrentSelectionRange());\n this.notifySelectionChangeDelta();\n this.pointerSession = {\n mode: 'selecting',\n pointerId: event.pointerId,\n };\n return;\n }\n }\n };\n\n private handleDocumentPointerUp = (event: PointerEvent): void => {\n const { enableLineSelection = false, onGutterUtilityClick } = this.options;\n switch (this.pointerSession.mode) {\n case 'idle':\n return;\n case 'gutterSelecting': {\n if (event.pointerId !== this.pointerSession.pointerId) {\n return;\n }\n const point = this.getSelectionPointFromPath(event.composedPath());\n if (point != null) {\n this.pointerSession.current = point;\n if (enableLineSelection) {\n this.updateSelection(point.lineNumber, point.side);\n }\n }\n onGutterUtilityClick?.(\n this.buildSelectedLineRange(\n this.pointerSession.anchor,\n this.pointerSession.current\n )\n );\n this.selectionAnchor = undefined;\n if (enableLineSelection) {\n this.notifySelectionEnd(this.getCurrentSelectionRange());\n this.notifySelectionCommitted();\n this.clearProposedSelection();\n }\n this.clearPointerSession();\n this.detachDocumentPointerListeners();\n return;\n }\n case 'pendingSingleLineUnselect': {\n if (event.pointerId !== this.pointerSession.pointerId) {\n return;\n }\n this.updateSelection(null, undefined, false);\n this.selectionAnchor = undefined;\n this.clearPendingSingleLineState();\n this.detachDocumentPointerListeners();\n this.notifySelectionEnd(this.getCurrentSelectionRange());\n this.notifySelectionCommitted();\n this.clearProposedSelection();\n return;\n }\n case 'selecting': {\n if (event.pointerId !== this.pointerSession.pointerId) {\n return;\n }\n this.selectionAnchor = undefined;\n this.detachDocumentPointerListeners();\n this.clearPointerSession();\n this.notifySelectionEnd(this.getCurrentSelectionRange());\n this.notifySelectionCommitted();\n this.clearProposedSelection();\n }\n }\n };\n\n private handleDocumentPointerCancel = (event: PointerEvent): void => {\n switch (this.pointerSession.mode) {\n case 'idle':\n return;\n case 'gutterSelecting':\n case 'selecting':\n case 'pendingSingleLineUnselect': {\n if ('pointerId' in this.pointerSession) {\n if (event.pointerId !== this.pointerSession.pointerId) {\n return;\n }\n }\n this.selectionAnchor = undefined;\n this.clearProposedSelection();\n this.clearPendingSingleLineState();\n this.clearPointerSession();\n this.detachDocumentPointerListeners();\n }\n }\n };\n\n private clearHoveredLine() {\n if (this.hoveredLine == null) {\n return;\n }\n this.hoveredLine.lineElement.removeAttribute('data-hovered');\n this.hoveredLine.numberElement.removeAttribute('data-hovered');\n this.hoveredLine = undefined;\n }\n\n private setHoveredLine(hoveredLine: EventBaseProps<TMode>) {\n const { lineHoverHighlight = 'disabled' } = this.options;\n if (this.hoveredLine != null) {\n this.clearHoveredLine();\n }\n this.hoveredLine = hoveredLine;\n if (lineHoverHighlight !== 'disabled') {\n if (lineHoverHighlight === 'both' || lineHoverHighlight === 'line') {\n this.hoveredLine.lineElement.setAttribute('data-hovered', '');\n }\n if (lineHoverHighlight === 'both' || lineHoverHighlight === 'number') {\n this.hoveredLine.numberElement.setAttribute('data-hovered', '');\n }\n }\n }\n\n private clearHoveredToken() {\n if (this.hoveredToken == null) {\n return;\n }\n this.hoveredToken = undefined;\n }\n\n private setHoveredToken(hoveredToken: OnTokenEventProps<TMode>) {\n if (this.hoveredToken != null) {\n this.clearHoveredToken();\n }\n this.hoveredToken = hoveredToken;\n }\n\n private ensureGutterUtilityNode(useCustomGutterUtility: boolean): void {\n if (this.gutterUtilityContainer == null) {\n this.gutterUtilityContainer = document.createElement('div');\n this.gutterUtilityContainer.setAttribute('data-gutter-utility-slot', '');\n }\n if (useCustomGutterUtility) {\n if (this.gutterUtilityButton != null) {\n this.gutterUtilityButton.remove();\n this.gutterUtilityButton = undefined;\n }\n if (this.gutterUtilitySlot == null) {\n this.gutterUtilitySlot = document.createElement('slot');\n this.gutterUtilitySlot.name = 'gutter-utility-slot';\n }\n if (this.gutterUtilitySlot.parentNode !== this.gutterUtilityContainer) {\n this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);\n }\n } else {\n this.gutterUtilitySlot?.remove();\n this.gutterUtilitySlot = undefined;\n if (this.gutterUtilityButton == null) {\n const tempDiv = document.createElement('div');\n tempDiv.innerHTML = toHtml(createGutterUtilityElement());\n const utilityButton = tempDiv.firstElementChild;\n if (!(utilityButton instanceof HTMLButtonElement)) {\n throw new Error(\n 'InteractionManager.ensureGutterUtilityNode: Node element should be a button'\n );\n }\n utilityButton.remove();\n this.gutterUtilityButton = utilityButton;\n }\n if (this.gutterUtilityButton.parentNode !== this.gutterUtilityContainer) {\n this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton);\n }\n }\n }\n\n private attachDocumentPointerListeners(): void {\n if (this.hasDocumentPointerListeners) {\n return;\n }\n document.addEventListener('pointermove', this.handleDocumentPointerMove);\n document.addEventListener('pointerup', this.handleDocumentPointerUp);\n document.addEventListener(\n 'pointercancel',\n this.handleDocumentPointerCancel\n );\n this.hasDocumentPointerListeners = true;\n }\n\n private detachDocumentPointerListeners(): void {\n if (!this.hasDocumentPointerListeners) {\n return;\n }\n document.removeEventListener('pointermove', this.handleDocumentPointerMove);\n document.removeEventListener('pointerup', this.handleDocumentPointerUp);\n document.removeEventListener(\n 'pointercancel',\n this.handleDocumentPointerCancel\n );\n this.hasDocumentPointerListeners = false;\n }\n\n private clearPointerSession(): void {\n this.pointerSession = { mode: 'idle' };\n }\n\n private clearPendingSingleLineState(): void {\n if (this.pointerSession.mode === 'pendingSingleLineUnselect') {\n this.pointerSession = { mode: 'idle' };\n }\n }\n\n private getSelectionPointerInfo(\n path: (EventTarget | undefined)[],\n requireNumberColumn: boolean\n ): SelectionPointerInfo | undefined {\n const target = this.resolvePointerTarget(path);\n if (!isLinePointerTarget(target)) {\n return undefined;\n }\n if (requireNumberColumn && !target.numberColumn) {\n return undefined;\n }\n if (target.splitLineIndex == null) {\n return undefined;\n }\n\n return {\n lineIndex: target.splitLineIndex,\n lineNumber: target.lineNumber,\n eventSide: this.mode === 'diff' ? target.side : undefined,\n };\n }\n\n private getSelectionPointFromPath(\n path: (EventTarget | undefined)[]\n ): SelectionPoint | undefined {\n const target = this.resolvePointerTarget(path);\n if (!isLinePointerTarget(target)) {\n return undefined;\n }\n return {\n lineNumber: target.lineNumber,\n side: this.mode === 'diff' ? target.side : undefined,\n };\n }\n\n private getLineIndex(\n lineNumber: number,\n side?: SelectionSide\n ): [number, number] | undefined {\n const { getLineIndex } = this.options;\n return getLineIndex != null\n ? getLineIndex(lineNumber, side)\n : [lineNumber - 1, lineNumber - 1];\n }\n\n private getCurrentSelectionRange(): SelectedLineRange | null {\n return this.proposedSelectedRange !== undefined\n ? this.proposedSelectedRange\n : this.selectedRange;\n }\n\n private clearProposedSelection(): void {\n this.proposedSelectedRange = undefined;\n }\n\n private updateSelection(\n currentLine: number | null,\n side?: SelectionSide,\n emitChange = true\n ): void {\n const previousRange = this.getCurrentSelectionRange();\n let nextRange: SelectedLineRange | null;\n if (currentLine == null) {\n nextRange = null;\n } else {\n const anchorSide = this.selectionAnchor?.side ?? side;\n const anchorLine = this.selectionAnchor?.lineNumber ?? currentLine;\n nextRange = this.buildSelectionRange(\n anchorLine,\n currentLine,\n anchorSide,\n side\n );\n }\n if (\n areSelectionsEqual(previousRange ?? undefined, nextRange ?? undefined)\n ) {\n return;\n }\n if (this.options.controlledSelection === true) {\n this.proposedSelectedRange = nextRange;\n } else {\n this.selectedRange = nextRange;\n this.queuedSelectionRender ??= requestAnimationFrame(\n this.renderSelection\n );\n }\n if (emitChange) {\n this.notifySelectionChangeDelta();\n }\n }\n\n private getIndexesFromSelection(\n selectedRange: SelectedLineRange,\n split: boolean\n ): { start: number; end: number } | undefined {\n if (this.pre == null) {\n return undefined;\n }\n const startIndexes = this.getLineIndex(\n selectedRange.start,\n selectedRange.side\n );\n const finalIndexes = this.getLineIndex(\n selectedRange.end,\n selectedRange.endSide ?? selectedRange.side\n );\n\n return startIndexes != null && finalIndexes != null\n ? {\n start: split ? startIndexes[1] : startIndexes[0],\n end: split ? finalIndexes[1] : finalIndexes[0],\n }\n : undefined;\n }\n\n private renderSelection = (): void => {\n if (this.queuedSelectionRender != null) {\n cancelAnimationFrame(this.queuedSelectionRender);\n this.queuedSelectionRender = undefined;\n }\n if (\n this.pre == null ||\n this.renderedSelectionRange === this.selectedRange\n ) {\n return;\n }\n\n const allSelected = this.pre.querySelectorAll('[data-selected-line]');\n for (const element of allSelected) {\n element.removeAttribute('data-selected-line');\n }\n\n this.renderedSelectionRange = this.selectedRange;\n if (this.selectedRange == null) {\n return;\n }\n\n const { children: codeElements } = this.pre;\n if (codeElements.length === 0) {\n return;\n }\n if (codeElements.length > 2) {\n console.error(codeElements);\n throw new Error(\n 'InteractionManager.renderSelection: Somehow there are more than 2 code elements...'\n );\n }\n const split = this.pre.getAttribute('data-diff-type') === 'split';\n const rowRange = this.getIndexesFromSelection(this.selectedRange, split);\n if (rowRange == null) {\n console.error({ rowRange, selectedRange: this.selectedRange });\n throw new Error('InteractionManager.renderSelection: No valid rowRange');\n }\n const isSingle = rowRange.start === rowRange.end;\n const first = Math.min(rowRange.start, rowRange.end);\n const last = Math.max(rowRange.start, rowRange.end);\n for (const code of codeElements) {\n const [gutter, content] = code.children;\n const len = content.children.length;\n if (len !== gutter.children.length) {\n throw new Error(\n 'InteractionManager.renderSelection: gutter and content children dont match, something is wrong'\n );\n }\n for (let i = 0; i < len; i++) {\n const contentElement = content.children[i];\n const gutterElement = gutter.children[i];\n if (\n !(contentElement instanceof HTMLElement) ||\n !(gutterElement instanceof HTMLElement)\n ) {\n continue;\n }\n\n const lineIndex = this.parseLineIndex(contentElement, split);\n if ((lineIndex ?? 0) > last) {\n break;\n }\n if (lineIndex == null || lineIndex < first) {\n continue;\n }\n let attributeValue = isSingle\n ? 'single'\n : lineIndex === first\n ? 'first'\n : lineIndex === last\n ? 'last'\n : '';\n contentElement.setAttribute('data-selected-line', attributeValue);\n gutterElement.setAttribute('data-selected-line', attributeValue);\n if (\n gutterElement.nextSibling instanceof HTMLElement &&\n contentElement.nextSibling instanceof HTMLElement &&\n (contentElement.nextSibling.hasAttribute('data-line-annotation') ||\n contentElement.nextSibling.hasAttribute(\n 'data-merge-conflict-actions'\n ))\n ) {\n if (isSingle) {\n attributeValue = 'last';\n contentElement.setAttribute('data-selected-line', 'first');\n } else if (lineIndex === first) {\n attributeValue = '';\n } else if (lineIndex === last) {\n contentElement.setAttribute('data-selected-line', '');\n }\n contentElement.nextSibling.setAttribute(\n 'data-selected-line',\n attributeValue\n );\n gutterElement.nextSibling.setAttribute(\n 'data-selected-line',\n attributeValue\n );\n }\n }\n }\n };\n\n private notifySelectionCommitted(): void {\n this.options.onLineSelected?.(this.getCurrentSelectionRange() ?? null);\n }\n\n private notifySelectionChangeDelta(): void {\n this.options.onLineSelectionChange?.(\n this.getCurrentSelectionRange() ?? null\n );\n }\n\n private notifySelectionStart(range: SelectedLineRange | null): void {\n this.options.onLineSelectionStart?.(range);\n }\n\n private notifySelectionEnd(range: SelectedLineRange | null): void {\n this.options.onLineSelectionEnd?.(range);\n }\n\n private toEventBaseProps(\n target: HoverableLinePointerTarget<TMode>\n ): EventBaseProps<TMode> {\n if (this.mode === 'file') {\n return {\n type: 'line',\n lineElement: target.lineElement,\n lineNumber: target.lineNumber,\n numberColumn: target.numberColumn,\n numberElement: target.numberElement,\n } as EventBaseProps<TMode>;\n }\n\n return {\n type: 'diff-line',\n annotationSide: target.side as AnnotationSide,\n lineType: target.lineType,\n lineElement: target.lineElement,\n numberElement: target.numberElement,\n lineNumber: target.lineNumber,\n numberColumn: target.numberColumn,\n } as EventBaseProps<TMode>;\n }\n\n private toTokenEventBaseProps({\n lineCharEnd,\n lineCharStart,\n lineNumber,\n side,\n tokenElement,\n tokenText,\n }: TokenPointerTarget<TMode>): OnTokenEventProps<TMode> {\n if (this.mode === 'file') {\n return {\n type: 'token',\n lineCharEnd,\n lineCharStart,\n lineNumber,\n tokenElement,\n tokenText,\n } as OnTokenEventProps<TMode>;\n }\n\n return {\n type: 'token',\n lineCharEnd,\n lineCharStart,\n lineNumber,\n side,\n tokenElement,\n tokenText,\n } as OnTokenEventProps<TMode>;\n }\n\n private buildSelectedLineRange(\n anchor: SelectionPoint,\n current: SelectionPoint\n ): SelectedLineRange {\n return this.buildSelectionRange(\n anchor.lineNumber,\n current.lineNumber,\n anchor.side,\n current.side\n );\n }\n\n private buildSelectionRange(\n start: number,\n end: number,\n side?: SelectionSide,\n endSide?: SelectionSide\n ): SelectedLineRange {\n return {\n start,\n end,\n ...(side != null ? { side } : {}),\n ...(side !== endSide && endSide != null ? { endSide } : {}),\n };\n }\n\n private resolvePointerTarget(\n path: (EventTarget | undefined)[]\n ): ResolvedPointerTarget<TMode> | undefined {\n let numberColumn = false;\n let lineType: LineTypes | undefined;\n let codeElement: HTMLElement | undefined;\n let lineElement: HTMLElement | undefined;\n let lineIndexValue: string | undefined;\n let numberElement: HTMLElement | undefined;\n let tokenElement: HTMLElement | undefined;\n let tokenInfo: TokenCache | undefined;\n let expandInfo: ExpandCache | undefined;\n let lineNumber: number | undefined;\n let mergeConflictActionTarget: MergeConflictActionTarget | undefined;\n\n for (const element of path) {\n if (!(element instanceof HTMLElement)) {\n continue;\n }\n\n if (\n mergeConflictActionTarget == null &&\n element.hasAttribute('data-merge-conflict-action')\n ) {\n const resolutionValue =\n element.getAttribute('data-merge-conflict-action') ?? undefined;\n const conflictIndexValue =\n element.getAttribute('data-merge-conflict-conflict-index') ??\n undefined;\n const conflictIndex =\n conflictIndexValue != null\n ? Number.parseInt(conflictIndexValue, 10)\n : Number.NaN;\n if (\n isMergeConflictResolution(resolutionValue) &&\n Number.isFinite(conflictIndex)\n ) {\n mergeConflictActionTarget = {\n kind: 'merge-conflict-action',\n resolution: resolutionValue,\n conflictIndex,\n };\n }\n }\n\n if (tokenElement == null && element.hasAttribute('data-char')) {\n tokenElement = element;\n const startAttr = element.getAttribute('data-char');\n\n if (startAttr != null) {\n const lineCharStart = Number.parseInt(startAttr, 10);\n if (!Number.isNaN(lineCharStart)) {\n const tokenText = element.textContent ?? '';\n const lineCharEnd = lineCharStart + tokenText.length;\n if (\n tokenText.trim() !== '' ||\n this.options.enableTokenInteractionsOnWhitespace === true\n ) {\n tokenInfo = {\n tokenElement,\n lineCharStart,\n lineCharEnd,\n tokenText,\n };\n }\n continue;\n }\n }\n }\n\n const columnNumber =\n numberElement == null\n ? (element.getAttribute('data-column-number') ?? undefined)\n : undefined;\n if (columnNumber != null) {\n numberElement = element;\n lineNumber = Number.parseInt(columnNumber, 10);\n numberColumn = true;\n lineType = getLineTypeFromElement(element);\n lineIndexValue = element.getAttribute('data-line-index') ?? undefined;\n continue;\n }\n\n const lineAttr =\n lineElement == null\n ? (element.getAttribute('data-line') ?? undefined)\n : undefined;\n if (lineAttr != null) {\n lineElement = element;\n lineNumber = Number.parseInt(lineAttr, 10);\n lineType = getLineTypeFromElement(element);\n lineIndexValue = element.getAttribute('data-line-index') ?? undefined;\n continue;\n }\n\n if (\n expandInfo == null &&\n (element.hasAttribute('data-expand-button') ||\n element.hasAttribute('data-unmodified-lines'))\n ) {\n expandInfo = {\n hunkIndex: undefined,\n direction: (() => {\n if (element.hasAttribute('data-expand-up')) {\n return 'up';\n }\n if (element.hasAttribute('data-expand-down')) {\n return 'down';\n }\n return 'both';\n })(),\n all: element.hasAttribute('data-expand-all-button'),\n };\n continue;\n }\n\n const expandIndexValue =\n expandInfo != null\n ? (element.getAttribute('data-expand-index') ?? undefined)\n : undefined;\n if (expandInfo != null && expandIndexValue != null) {\n const expandIndex = Number.parseInt(expandIndexValue, 10);\n if (!Number.isNaN(expandIndex)) {\n expandInfo.hunkIndex = expandIndex;\n }\n continue;\n }\n\n if (codeElement == null && element.hasAttribute('data-code')) {\n codeElement = element;\n break;\n }\n }\n\n if (mergeConflictActionTarget != null) {\n return mergeConflictActionTarget as ResolvedPointerTarget<TMode>;\n }\n\n if (expandInfo?.hunkIndex != null) {\n return {\n type: 'line-info',\n hunkIndex: expandInfo.hunkIndex,\n direction: expandInfo.direction,\n all: expandInfo.all,\n } as ResolvedPointerTarget<TMode>;\n }\n\n lineElement ??=\n lineIndexValue != null\n ? queryHTMLElement(\n codeElement,\n `[data-line][data-line-index=\"${lineIndexValue}\"]`\n )\n : undefined;\n numberElement ??=\n lineIndexValue != null\n ? queryHTMLElement(\n codeElement,\n `[data-column-number][data-line-index=\"${lineIndexValue}\"]`\n )\n : undefined;\n\n if (\n codeElement == null ||\n lineElement == null ||\n numberElement == null ||\n lineType == null ||\n lineNumber == null ||\n Number.isNaN(lineNumber)\n ) {\n return undefined;\n }\n\n const splitLineIndex = this.parseLineIndex(lineElement, this.isSplitDiff());\n\n if (tokenInfo != null) {\n if (this.mode === 'file') {\n return {\n kind: 'token',\n lineType,\n lineElement,\n lineNumber,\n numberColumn,\n numberElement,\n side: undefined,\n splitLineIndex,\n ...tokenInfo,\n } as ResolvedPointerTarget<TMode>;\n }\n\n return {\n kind: 'token',\n lineType,\n lineElement,\n lineNumber,\n numberColumn,\n numberElement,\n side: getAnnotationSide(lineType, codeElement),\n splitLineIndex,\n ...tokenInfo,\n } as ResolvedPointerTarget<TMode>;\n }\n\n // Otherwise return line target\n if (this.mode === 'file') {\n return {\n kind: 'line',\n lineType,\n lineElement,\n lineNumber,\n numberColumn,\n numberElement,\n side: undefined,\n splitLineIndex,\n } as ResolvedPointerTarget<TMode>;\n }\n\n return {\n kind: 'line',\n lineType,\n lineElement,\n lineNumber,\n numberColumn,\n numberElement,\n side: getAnnotationSide(lineType, codeElement),\n splitLineIndex,\n } as ResolvedPointerTarget<TMode>;\n }\n\n private isSplitDiff(): boolean {\n return this.pre?.getAttribute('data-diff-type') === 'split';\n }\n\n private parseLineIndex(\n element: HTMLElement,\n split: boolean\n ): number | undefined {\n const lineIndexes = (element.getAttribute('data-line-index') ?? '')\n .split(',')\n .map((value) => Number.parseInt(value, 10))\n .filter((value) => !Number.isNaN(value));\n\n if (split && lineIndexes.length === 2) {\n return lineIndexes[1];\n }\n if (!split) {\n return lineIndexes[0];\n }\n return undefined;\n }\n}\n\ntype InteractionPluckOptions<TMode extends InteractionManagerMode> =\n InteractionManagerBaseOptions<TMode> & {\n renderGutterUtility?(\n getHoveredRow: () => GetHoveredLineResult<TMode> | undefined\n ): HTMLElement | null | undefined;\n };\n\nexport function pluckInteractionOptions<TMode extends InteractionManagerMode>(\n {\n enableTokenInteractionsOnWhitespace,\n enableGutterUtility,\n lineHoverHighlight,\n onGutterUtilityClick,\n onLineClick,\n onLineEnter,\n onLineLeave,\n onLineNumberClick,\n onTokenClick,\n onTokenEnter,\n onTokenLeave,\n renderGutterUtility,\n __debugPointerEvents,\n enableLineSelection,\n controlledSelection,\n onLineSelected,\n onLineSelectionStart,\n onLineSelectionChange,\n onLineSelectionEnd,\n }: InteractionPluckOptions<TMode>,\n onHunkExpand?: (\n hunkIndex: number,\n direction: ExpansionDirections,\n expansionLineCountOverride?: number\n ) => unknown,\n getLineIndex?: GetLineIndexUtility,\n onMergeConflictActionClick?: (target: MergeConflictActionTarget) => void\n): InteractionManagerOptions<TMode> {\n return {\n enableTokenInteractionsOnWhitespace,\n enableGutterUtility: resolveEnableGutterUtilityOption({\n enableGutterUtility,\n renderGutterUtility,\n onGutterUtilityClick,\n }),\n usesCustomGutterUtility: renderGutterUtility != null,\n lineHoverHighlight,\n\n onGutterUtilityClick,\n onHunkExpand,\n onMergeConflictActionClick,\n onLineClick,\n onLineEnter,\n onLineLeave,\n onLineNumberClick,\n onTokenClick,\n onTokenEnter,\n onTokenLeave,\n __debugPointerEvents,\n\n enableLineSelection,\n controlledSelection,\n onLineSelected,\n onLineSelectionStart,\n onLineSelectionChange,\n onLineSelectionEnd,\n\n getLineIndex,\n };\n}\n\nfunction resolveEnableGutterUtilityOption<\n TMode extends InteractionManagerMode,\n>({\n enableGutterUtility,\n renderGutterUtility,\n onGutterUtilityClick,\n}: Pick<\n InteractionPluckOptions<TMode>,\n 'enableGutterUtility' | 'renderGutterUtility' | 'onGutterUtilityClick'\n>): boolean {\n if (onGutterUtilityClick != null && renderGutterUtility != null) {\n throw new Error(\n \"Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.\"\n );\n }\n return enableGutterUtility ?? false;\n}\n\nfunction isLinePointerTarget<TMode extends InteractionManagerMode>(\n target: ResolvedPointerTarget<TMode> | undefined\n): target is LinePointerTarget<TMode> {\n return target != null && 'kind' in target && target.kind === 'line';\n}\n\nfunction isTokenPointerTarget<TMode extends InteractionManagerMode>(\n target: ResolvedPointerTarget<TMode> | undefined\n): target is TokenPointerTarget<TMode> {\n return target != null && 'kind' in target && target.kind === 'token';\n}\n\nfunction isHoverableLinePointerTarget<TMode extends InteractionManagerMode>(\n target: ResolvedPointerTarget<TMode> | undefined\n): target is HoverableLinePointerTarget<TMode> {\n return isLinePointerTarget(target) || isTokenPointerTarget(target);\n}\n\nfunction isExpandoPointerTarget<TMode extends InteractionManagerMode>(\n target: ResolvedPointerTarget<TMode>\n): target is ExpandoEventProps {\n return 'type' in target && target.type === 'line-info';\n}\n\nfunction isMergeConflictActionPointerTarget<\n TMode extends InteractionManagerMode,\n>(target: ResolvedPointerTarget<TMode>): target is MergeConflictActionTarget {\n return 'kind' in target && target.kind === 'merge-conflict-action';\n}\n\nfunction isMergeConflictResolution(\n value: string | undefined\n): value is MergeConflictResolution {\n return value === 'current' || value === 'incoming' || value === 'both';\n}\n\nfunction queryHTMLElement(\n parent: HTMLElement | undefined,\n query: string\n): HTMLElement | undefined {\n const element = parent?.querySelector(query);\n return element instanceof HTMLElement ? element : undefined;\n}\n\nfunction getAnnotationSide(\n lineType: LineTypes,\n codeElement: HTMLElement\n): AnnotationSide {\n switch (lineType) {\n case 'change-deletion':\n return 'deletions';\n case 'change-addition':\n return 'additions';\n default:\n return codeElement.hasAttribute('data-deletions')\n ? 'deletions'\n : 'additions';\n }\n}\n\nfunction getLineTypeFromElement(element: HTMLElement): LineTypes | undefined {\n const lineType = element.getAttribute('data-line-type');\n if (lineType == null) {\n return undefined;\n }\n switch (lineType) {\n case 'change-deletion':\n case 'change-addition':\n case 'context':\n case 'context-expanded':\n return lineType;\n default:\n return undefined;\n }\n}\n\nfunction isGutterUtilityPointerPath(\n path: (EventTarget | undefined)[]\n): boolean {\n for (const element of path) {\n if (\n element instanceof HTMLElement &&\n element.hasAttribute('data-utility-button')\n ) {\n return true;\n }\n }\n return false;\n}\n\nfunction debugLogIfEnabled(\n debugLogType: LogTypes | undefined = 'none',\n logIfType: 'move' | 'click',\n ...args: unknown[]\n) {\n switch (debugLogType) {\n case 'none':\n return;\n case 'both':\n break;\n case 'click':\n if (logIfType !== 'click') {\n return;\n }\n break;\n case 'move':\n if (logIfType !== 'move') {\n return;\n }\n break;\n }\n console.log(...args);\n}\n"],"mappings":";;;;;;AAwNA,IAAa,qBAAb,MAAsE;CACpE,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,AAAQ,uBAAuB;CAC/B,AAAQ,6BAA6B;CAErC,AAAQ,sBAAsB;CAC9B,AAAQ,8BAA8B;CAEtC,AAAQ,gBAA0C;CAClD,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ,iBAAiC,EAAE,MAAM,QAAQ;CAEzD,YACE,AAAQA,MACR,AAAQC,SACR;EAFQ;EACA;;CAGV,WAAW,SAAiD;AAC1D,OAAK,UAAU;;CAGjB,UAAgB;AACd,OAAK,KAAK,oBAAoB,SAAS,KAAK,mBAAmB;AAC/D,OAAK,KAAK,oBAAoB,eAAe,KAAK,kBAAkB;AACpE,O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UAAU,QAAQ,cAAc,MAAM;AAC5C,QAAO,mBAAmB,cAAc,UAAU;;AAGpD,SAAS,kBACP,UACA,aACgB;AAChB,SAAQ,UAAR;EACE,KAAK,kBACH,QAAO;EACT,KAAK,kBACH,QAAO;EACT,QACE,QAAO,YAAY,aAAa,iBAAiB,GAC7C,cACA;;;AAIV,SAAS,uBAAuB,SAA6C;CAC3E,MAAM,WAAW,QAAQ,aAAa,iBAAiB;AACvD,KAAI,YAAY,KACd;AAEF,SAAQ,UAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,mBACH,QAAO;EACT,QACE;;;AAIN,SAAS,2BACP,MACS;AACT,MAAK,MAAM,WAAW,KACpB,KACE,mBAAmB,eACnB,QAAQ,aAAa,sBAAsB,CAE3C,QAAO;AAGX,QAAO;;AAGT,SAAS,kBACP,eAAqC,QACrC,WACA,GAAG,MACH;AACA,SAAQ,cAAR;EACE,KAAK,OACH;EACF,KAAK,OACH;EACF,KAAK;AACH,OAAI,cAAc,QAChB;AAEF;EACF,KAAK;AACH,OAAI,cAAc,OAChB;AAEF;;AAEJ,SAAQ,IAAI,GAAG,KAAK"}
1
+ {"version":3,"file":"InteractionManager.js","names":["mode: TMode","options: InteractionManagerOptions<TMode>","reasons: string[]","start: SelectionPoint","end: SelectionPoint","nextRange: SelectedLineRange | null","lineType: LineTypes | undefined","codeElement: HTMLElement | undefined","lineElement: HTMLElement | undefined","lineIndexValue: string | undefined","numberElement: HTMLElement | undefined","tokenElement: HTMLElement | undefined","tokenInfo: TokenCache | undefined","expandInfo: ExpandCache | undefined","lineNumber: number | undefined","mergeConflictActionTarget: MergeConflictActionTarget | undefined","path: EventTarget[]","current: Node | null"],"sources":["../../src/managers/InteractionManager.ts"],"sourcesContent":["import { toHtml } from 'hast-util-to-html';\n\nimport type {\n AnnotationSide,\n DiffLineEventBaseProps,\n DiffTokenEventBaseProps,\n ExpansionDirections,\n LineEventBaseProps,\n LineTypes,\n MergeConflictResolution,\n SelectedLineRange,\n SelectionPoint,\n SelectionSide,\n TokenEventBase,\n} from '../types';\nimport { areSelectionPointsEqual } from '../utils/areSelectionPointsEqual';\nimport { areSelectionsEqual } from '../utils/areSelectionsEqual';\nimport { createGutterUtilityElement } from '../utils/createGutterUtilityElement';\n\ninterface TokenCache {\n tokenElement: HTMLElement;\n lineCharStart: number;\n lineCharEnd: number;\n tokenText: string;\n}\n\ninterface ExpandCache {\n hunkIndex: number | undefined;\n direction: ExpansionDirections;\n all: boolean;\n}\n\nexport type LogTypes = 'click' | 'move' | 'both' | 'none';\n\nexport type InteractionManagerMode = 'file' | 'diff';\n\nexport interface OnLineClickProps extends LineEventBaseProps {\n event: PointerEvent;\n}\n\nexport interface OnLineEnterLeaveProps extends LineEventBaseProps {\n event: PointerEvent;\n}\n\nexport interface OnDiffLineClickProps extends DiffLineEventBaseProps {\n event: PointerEvent;\n}\n\nexport interface OnDiffLineEnterLeaveProps extends DiffLineEventBaseProps {\n event: PointerEvent;\n}\n\nexport interface SelectionWriteOptions {\n notify?: boolean;\n}\n\nexport type GetLineIndexUtility = (\n lineNumber: number,\n side?: SelectionSide\n) => [number, number] | undefined;\n\ntype EventClickProps<TMode extends InteractionManagerMode> =\n TMode extends 'file' ? OnLineClickProps : OnDiffLineClickProps;\n\ntype PointerEventEnterLeaveProps<TMode extends InteractionManagerMode> =\n TMode extends 'file' ? OnLineEnterLeaveProps : OnDiffLineEnterLeaveProps;\n\ntype EventBaseProps<TMode extends InteractionManagerMode> = TMode extends 'file'\n ? LineEventBaseProps\n : DiffLineEventBaseProps;\n\nexport type OnTokenEventProps<TMode extends InteractionManagerMode> =\n TMode extends 'file' ? TokenEventBase : DiffTokenEventBaseProps;\n\ninterface ExpandoEventProps {\n type: 'line-info';\n hunkIndex: number;\n direction: ExpansionDirections;\n all: boolean;\n}\n\nexport type GetHoveredLineResult<TMode extends InteractionManagerMode> =\n TMode extends 'file'\n ? { lineNumber: number }\n : { lineNumber: number; side: AnnotationSide };\n\ninterface SelectionInfo {\n lineNumber: number;\n eventSide: SelectionSide | undefined;\n lineIndex: number;\n}\n\ntype SelectionHitSource = 'event-path' | 'coordinates-first';\n\ninterface SelectionHitOptions {\n source: SelectionHitSource;\n excludeUtility?: boolean;\n}\n\ninterface SelectionInfoOptions extends SelectionHitOptions {\n requireNumberColumn: boolean;\n}\n\ninterface SelectionEnds {\n top: SelectionPoint;\n bottom: SelectionPoint;\n}\n\ninterface ResolvedLineTarget<TMode extends InteractionManagerMode> {\n kind: 'line';\n lineType: LineTypes;\n lineElement: HTMLElement;\n lineNumber: number;\n numberColumn: boolean;\n numberElement: HTMLElement;\n side: TMode extends 'diff' ? AnnotationSide : undefined;\n splitLineIndex: number | undefined;\n}\n\ninterface ResolvedTokenTarget<TMode extends InteractionManagerMode> {\n kind: 'token';\n lineType: LineTypes;\n lineElement: HTMLElement;\n lineNumber: number;\n numberColumn: boolean;\n numberElement: HTMLElement;\n side: TMode extends 'diff' ? AnnotationSide : undefined;\n splitLineIndex: number | undefined;\n tokenElement: HTMLElement;\n tokenText: string;\n lineCharStart: number;\n lineCharEnd: number;\n}\n\nexport interface MergeConflictActionTarget {\n kind: 'merge-conflict-action';\n resolution: MergeConflictResolution;\n conflictIndex: number;\n}\n\ntype ResolvedPointerTarget<TMode extends InteractionManagerMode> =\n | ResolvedLineTarget<TMode>\n | ResolvedTokenTarget<TMode>\n | ExpandoEventProps\n | MergeConflictActionTarget;\n\ntype LinePointerTarget<TMode extends InteractionManagerMode> =\n ResolvedLineTarget<TMode>;\n\ntype TokenPointerTarget<TMode extends InteractionManagerMode> =\n ResolvedTokenTarget<TMode>;\n\ntype HoverableLinePointerTarget<TMode extends InteractionManagerMode> =\n | LinePointerTarget<TMode>\n | TokenPointerTarget<TMode>;\n\ninterface SessionIdle {\n mode: 'idle';\n}\n\ninterface SessionSelecting {\n mode: 'selecting';\n pointerId: number;\n}\n\ninterface SessionPendingSingleLineUnselect {\n mode: 'pendingSingleLineUnselect';\n pointerId: number;\n anchor: SelectionPoint;\n pending: SelectionPoint;\n}\n\ninterface SessionGutterSelecting {\n mode: 'gutterSelecting';\n pointerId: number;\n anchor: SelectionPoint;\n current: SelectionPoint;\n}\n\ntype PointerSession =\n | SessionIdle\n | SessionSelecting\n | SessionPendingSingleLineUnselect\n | SessionGutterSelecting;\n\nexport interface InteractionManagerBaseOptions<\n TMode extends InteractionManagerMode,\n> {\n lineHoverHighlight?: 'disabled' | 'both' | 'number' | 'line';\n enableTokenInteractionsOnWhitespace?: boolean;\n enableGutterUtility?: boolean;\n onGutterUtilityClick?(range: SelectedLineRange): unknown;\n onLineClick?(props: EventClickProps<TMode>): unknown;\n onLineNumberClick?(props: EventClickProps<TMode>): unknown;\n onLineEnter?(props: PointerEventEnterLeaveProps<TMode>): unknown;\n onLineLeave?(props: PointerEventEnterLeaveProps<TMode>): unknown;\n onTokenClick?(props: OnTokenEventProps<TMode>, event: MouseEvent): unknown;\n onTokenEnter?(props: OnTokenEventProps<TMode>, event: PointerEvent): unknown;\n onTokenLeave?(props: OnTokenEventProps<TMode>, event: PointerEvent): unknown;\n __debugPointerEvents?: LogTypes;\n enableLineSelection?: boolean;\n controlledSelection?: boolean;\n onLineSelected?: (range: SelectedLineRange | null) => void;\n onLineSelectionStart?: (range: SelectedLineRange | null) => void;\n onLineSelectionChange?: (range: SelectedLineRange | null) => void;\n onLineSelectionEnd?: (range: SelectedLineRange | null) => void;\n getLineIndex?: GetLineIndexUtility;\n}\n\nexport interface InteractionManagerOptions<\n TMode extends InteractionManagerMode,\n> extends InteractionManagerBaseOptions<TMode> {\n usesCustomGutterUtility?: boolean;\n onHunkExpand?(\n hunkIndex: number,\n direction: ExpansionDirections,\n expansionLineCountOverride?: number\n ): unknown;\n onMergeConflictActionClick?(target: MergeConflictActionTarget): void;\n}\n\ninterface HandlePointerEventProps {\n eventType: 'click' | 'move';\n event: PointerEvent | MouseEvent;\n}\n\nexport class InteractionManager<TMode extends InteractionManagerMode> {\n private hoveredLine: EventBaseProps<TMode> | undefined;\n private hoveredToken: OnTokenEventProps<TMode> | undefined;\n private pre: HTMLPreElement | undefined;\n\n private gutterUtilityLine: EventBaseProps<TMode> | undefined;\n private gutterUtilityContainer: HTMLDivElement | undefined;\n private gutterUtilityButton: HTMLButtonElement | undefined;\n private gutterUtilitySlot: HTMLSlotElement | undefined;\n\n private interactiveLinesAttr = false;\n private interactiveLineNumbersAttr = false;\n\n private hasPointerListeners = false;\n private hasDocumentPointerListeners = false;\n\n private selectedRange: SelectedLineRange | null = null;\n private proposedSelectedRange: SelectedLineRange | null | undefined;\n private renderedSelectionRange: SelectedLineRange | null | undefined;\n private selectionAnchor: SelectionPoint | undefined;\n private queuedSelectionRender: number | undefined;\n private pointerSession: PointerSession = { mode: 'idle' };\n\n constructor(\n private mode: TMode,\n private options: InteractionManagerOptions<TMode>\n ) {}\n\n setOptions(options: InteractionManagerOptions<TMode>): void {\n this.options = options;\n }\n\n cleanUp(): void {\n this.pre?.removeEventListener('click', this.handlePointerClick);\n this.pre?.removeEventListener('pointerdown', this.handlePointerDown);\n this.pre?.removeEventListener('pointermove', this.handlePointerMove);\n this.pre?.removeEventListener('pointerleave', this.handlePointerLeave);\n this.pre?.removeAttribute('data-interactive-lines');\n this.pre?.removeAttribute('data-interactive-line-numbers');\n this.pre = undefined;\n this.gutterUtilityContainer?.remove();\n this.gutterUtilityLine = undefined;\n this.gutterUtilityContainer = undefined;\n this.gutterUtilityButton = undefined;\n this.gutterUtilitySlot = undefined;\n this.clearHoveredLine();\n this.clearHoveredToken();\n this.detachDocumentPointerListeners();\n this.clearPointerSession();\n if (this.queuedSelectionRender != null) {\n cancelAnimationFrame(this.queuedSelectionRender);\n this.queuedSelectionRender = undefined;\n }\n this.interactiveLinesAttr = false;\n this.interactiveLineNumbersAttr = false;\n this.hasPointerListeners = false;\n }\n\n setup(pre: HTMLPreElement): void {\n this.setSelectionDirty();\n const { usesCustomGutterUtility = false, enableGutterUtility = false } =\n this.options;\n\n const newContainer = this.pre !== pre;\n if (newContainer) {\n this.cleanUp();\n this.pre = pre;\n }\n\n if (enableGutterUtility) {\n this.ensureGutterUtilityNode(usesCustomGutterUtility);\n } else if (this.gutterUtilityContainer != null) {\n this.gutterUtilityContainer.remove();\n this.gutterUtilityLine = undefined;\n this.gutterUtilityContainer = undefined;\n this.gutterUtilityButton = undefined;\n this.gutterUtilitySlot = undefined;\n if (this.pointerSession.mode === 'gutterSelecting') {\n this.clearPointerSession();\n this.detachDocumentPointerListeners();\n }\n }\n\n this.syncPointerListeners(pre);\n this.updateInteractiveLineAttributes();\n this.renderSelection();\n this.placeUtility();\n }\n\n setSelectionDirty(): void {\n this.renderedSelectionRange = undefined;\n }\n\n isSelectionDirty(): boolean {\n return this.renderedSelectionRange === null;\n }\n\n setSelection(\n range: SelectedLineRange | null,\n options?: SelectionWriteOptions\n ): void {\n const isRangeChange = !(\n range === this.selectedRange ||\n areSelectionsEqual(range ?? undefined, this.selectedRange ?? undefined)\n );\n if (!this.isSelectionDirty() && !isRangeChange) {\n return;\n }\n this.proposedSelectedRange = undefined;\n this.selectedRange = range;\n this.renderSelection();\n this.placeUtility();\n if (isRangeChange && options?.notify !== false) {\n this.notifySelectionCommitted();\n }\n }\n\n getSelection(): SelectedLineRange | null {\n return this.selectedRange;\n }\n\n getHoveredLine = (): GetHoveredLineResult<TMode> | undefined => {\n const gutterUtilityLine = this.gutterUtilityLine ?? this.hoveredLine;\n if (gutterUtilityLine != null) {\n if (this.mode === 'diff' && gutterUtilityLine.type === 'diff-line') {\n return {\n lineNumber: gutterUtilityLine.lineNumber,\n side: gutterUtilityLine.annotationSide,\n } as GetHoveredLineResult<TMode>;\n }\n if (this.mode === 'file' && gutterUtilityLine.type === 'line') {\n return {\n lineNumber: gutterUtilityLine.lineNumber,\n } as GetHoveredLineResult<TMode>;\n }\n }\n return undefined;\n };\n\n handlePointerClick = (event: MouseEvent): void => {\n const {\n onHunkExpand,\n onLineClick,\n onLineNumberClick,\n onTokenClick,\n onMergeConflictActionClick,\n } = this.options;\n if (\n onHunkExpand == null &&\n onLineClick == null &&\n onLineNumberClick == null &&\n onMergeConflictActionClick == null &&\n onTokenClick == null\n ) {\n return;\n }\n if (\n this.options.onGutterUtilityClick != null &&\n isGutterUtilityPath(event.composedPath())\n ) {\n return;\n }\n debugLogIfEnabled(\n this.options.__debugPointerEvents,\n 'click',\n 'FileDiff.DEBUG.handlePointerClick:',\n event\n );\n this.handlePointerEvent({ eventType: 'click', event });\n };\n\n handlePointerMove = (event: PointerEvent): void => {\n // Touch and pen moves are active drag/scroll gestures, not hover. Keeping\n // hover mouse-only prevents content scrolls from leaving stale utilities.\n if (event.pointerType !== 'mouse') {\n return;\n }\n\n const {\n lineHoverHighlight = 'disabled',\n onLineEnter,\n onLineLeave,\n onTokenEnter,\n onTokenLeave,\n enableGutterUtility = false,\n } = this.options;\n if (\n lineHoverHighlight === 'disabled' &&\n !enableGutterUtility &&\n onLineEnter == null &&\n onLineLeave == null &&\n onTokenEnter == null &&\n onTokenLeave == null\n ) {\n return;\n }\n debugLogIfEnabled(\n this.options.__debugPointerEvents,\n 'move',\n 'FileDiff.DEBUG.handlePointerMove:',\n event\n );\n // should we perhaps throttle this a bit because move can be fast as fuk\n // boiiii\n this.handlePointerEvent({ eventType: 'move', event });\n };\n\n handlePointerLeave = (event: PointerEvent): void => {\n const { __debugPointerEvents } = this.options;\n debugLogIfEnabled(\n __debugPointerEvents,\n 'move',\n 'FileDiff.DEBUG.handlePointerLeave: no event'\n );\n if (this.hoveredLine == null && this.hoveredToken == null) {\n debugLogIfEnabled(\n __debugPointerEvents,\n 'move',\n 'FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token'\n );\n return;\n }\n if (this.hoveredToken != null) {\n this.options.onTokenLeave?.(this.hoveredToken, event);\n this.clearHoveredToken();\n }\n\n if (this.hoveredLine != null) {\n this.options.onLineLeave?.({\n ...this.hoveredLine,\n event,\n } as PointerEventEnterLeaveProps<TMode>);\n this.clearHoveredLine();\n }\n this.placeUtility();\n };\n\n private handlePointerEvent({ eventType, event }: HandlePointerEventProps) {\n const { __debugPointerEvents } = this.options;\n const composedPath = event.composedPath();\n debugLogIfEnabled(\n __debugPointerEvents,\n eventType,\n 'FileDiff.DEBUG.handlePointerEvent:',\n { eventType, composedPath }\n );\n const target = this.resolvePointerTarget(composedPath);\n debugLogIfEnabled(\n __debugPointerEvents,\n eventType,\n 'FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:',\n target\n );\n\n const {\n onLineClick,\n onLineNumberClick,\n onLineEnter,\n onLineLeave,\n onTokenClick,\n onTokenEnter,\n onTokenLeave,\n onHunkExpand,\n onMergeConflictActionClick,\n } = this.options;\n\n switch (eventType) {\n case 'move': {\n const sameLine =\n isHoverableLinePointerTarget(target) &&\n this.hoveredLine?.lineElement === target.lineElement;\n const sameToken =\n isTokenPointerTarget(target) &&\n this.hoveredToken?.tokenElement === target.tokenElement;\n\n // Handle token transitions\n if (!sameToken) {\n if (this.hoveredToken != null) {\n onTokenLeave?.(this.hoveredToken, event as PointerEvent);\n this.clearHoveredToken();\n }\n if (isTokenPointerTarget(target)) {\n this.setHoveredToken(this.toTokenEventBaseProps(target));\n onTokenEnter?.(\n this.hoveredToken as OnTokenEventProps<TMode>,\n event as PointerEvent\n );\n }\n }\n\n // Handle line transitions\n if (!sameLine) {\n if (this.hoveredLine != null) {\n onLineLeave?.({\n ...this.hoveredLine,\n event: event as PointerEvent,\n } as PointerEventEnterLeaveProps<TMode>);\n this.clearHoveredLine();\n }\n if (isHoverableLinePointerTarget(target)) {\n this.setHoveredLine(this.toEventBaseProps(target));\n this.placeUtility();\n onLineEnter?.({\n ...this.hoveredLine,\n event: event as PointerEvent,\n } as PointerEventEnterLeaveProps<TMode>);\n } else {\n this.placeUtility();\n }\n }\n break;\n }\n case 'click': {\n if (target == null) {\n break;\n }\n if (\n isMergeConflictActionPointerTarget(target) &&\n onMergeConflictActionClick != null\n ) {\n onMergeConflictActionClick(target);\n break;\n }\n if (isExpandoPointerTarget(target) && onHunkExpand != null) {\n onHunkExpand(\n target.hunkIndex,\n target.all || event.shiftKey ? 'both' : target.direction,\n target.all || event.shiftKey ? Number.POSITIVE_INFINITY : undefined\n );\n break;\n }\n\n if (!isHoverableLinePointerTarget(target)) {\n break;\n }\n\n if (isTokenPointerTarget(target) && onTokenClick != null) {\n onTokenClick(this.toTokenEventBaseProps(target), event as MouseEvent);\n }\n\n const eventBase = this.toEventBaseProps(target);\n if (onLineNumberClick != null && target.numberColumn) {\n onLineNumberClick({\n ...eventBase,\n event: event as PointerEvent,\n } as EventClickProps<TMode>);\n } else if (onLineClick != null) {\n onLineClick({\n ...eventBase,\n event: event as PointerEvent,\n } as EventClickProps<TMode>);\n }\n break;\n }\n }\n }\n\n private syncPointerListeners(pre: HTMLPreElement): void {\n const {\n __debugPointerEvents,\n lineHoverHighlight = 'disabled',\n onLineClick,\n onLineNumberClick,\n onLineEnter,\n onLineLeave,\n onTokenClick,\n onTokenEnter,\n onTokenLeave,\n onHunkExpand,\n onMergeConflictActionClick,\n enableGutterUtility = false,\n enableLineSelection = false,\n onGutterUtilityClick,\n } = this.options;\n const enableGutterSelection = onGutterUtilityClick != null;\n const shouldAttachPointerListeners =\n lineHoverHighlight !== 'disabled' ||\n onLineClick != null ||\n onLineNumberClick != null ||\n onLineEnter != null ||\n onLineLeave != null ||\n onTokenClick != null ||\n onTokenEnter != null ||\n onTokenLeave != null ||\n onHunkExpand != null ||\n onMergeConflictActionClick != null ||\n enableGutterUtility ||\n enableLineSelection ||\n enableGutterSelection;\n\n if (shouldAttachPointerListeners && !this.hasPointerListeners) {\n pre.addEventListener('click', this.handlePointerClick);\n pre.addEventListener('pointerdown', this.handlePointerDown);\n pre.addEventListener('pointermove', this.handlePointerMove);\n pre.addEventListener('pointerleave', this.handlePointerLeave);\n this.hasPointerListeners = true;\n\n debugLogIfEnabled(\n __debugPointerEvents,\n 'click',\n 'FileDiff.DEBUG.attachEventListeners: Attaching click events for:',\n (() => {\n const reasons: string[] = [];\n if (\n __debugPointerEvents === 'both' ||\n __debugPointerEvents === 'click'\n ) {\n if (onLineClick != null) {\n reasons.push('onLineClick');\n }\n if (onLineNumberClick != null) {\n reasons.push('onLineNumberClick');\n }\n if (onHunkExpand != null) {\n reasons.push('expandable hunk separators');\n }\n if (onMergeConflictActionClick != null) {\n reasons.push('merge conflict actions');\n }\n }\n return reasons;\n })()\n );\n debugLogIfEnabled(\n __debugPointerEvents,\n 'move',\n 'FileDiff.DEBUG.attachEventListeners: Attaching pointer move event'\n );\n debugLogIfEnabled(\n __debugPointerEvents,\n 'move',\n 'FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event'\n );\n } else if (!shouldAttachPointerListeners && this.hasPointerListeners) {\n pre.removeEventListener('click', this.handlePointerClick);\n pre.removeEventListener('pointerdown', this.handlePointerDown);\n pre.removeEventListener('pointermove', this.handlePointerMove);\n pre.removeEventListener('pointerleave', this.handlePointerLeave);\n this.hasPointerListeners = false;\n }\n\n const hasActiveLineSelectionSession =\n this.pointerSession.mode === 'selecting' ||\n this.pointerSession.mode === 'pendingSingleLineUnselect';\n const hasActiveGutterSelectionSession =\n this.pointerSession.mode === 'gutterSelecting';\n if (\n (!enableLineSelection && hasActiveLineSelectionSession) ||\n (!enableGutterSelection && hasActiveGutterSelectionSession)\n ) {\n this.clearPointerSession();\n this.detachDocumentPointerListeners();\n this.selectionAnchor = undefined;\n this.clearPendingSingleLineState();\n }\n }\n\n private updateInteractiveLineAttributes(): void {\n if (this.pre == null) {\n return;\n }\n\n const {\n onLineClick,\n onLineNumberClick,\n enableLineSelection = false,\n } = this.options;\n\n const shouldHaveInteractiveLines = onLineClick != null;\n const shouldHaveInteractiveLineNumbers =\n onLineNumberClick != null || enableLineSelection;\n\n if (shouldHaveInteractiveLines && !this.interactiveLinesAttr) {\n this.pre.setAttribute('data-interactive-lines', '');\n this.interactiveLinesAttr = true;\n } else if (!shouldHaveInteractiveLines && this.interactiveLinesAttr) {\n this.pre.removeAttribute('data-interactive-lines');\n this.interactiveLinesAttr = false;\n }\n\n if (shouldHaveInteractiveLineNumbers && !this.interactiveLineNumbersAttr) {\n this.pre.setAttribute('data-interactive-line-numbers', '');\n this.interactiveLineNumbersAttr = true;\n } else if (\n !shouldHaveInteractiveLineNumbers &&\n this.interactiveLineNumbersAttr\n ) {\n this.pre.removeAttribute('data-interactive-line-numbers');\n this.interactiveLineNumbersAttr = false;\n }\n }\n\n private handlePointerDown = (event: PointerEvent): void => {\n if (\n (event.pointerType === 'mouse' && event.button !== 0) ||\n this.pre == null ||\n this.pointerSession.mode !== 'idle'\n ) {\n return;\n }\n\n const path = event.composedPath();\n if (\n isGutterUtilityPath(path) &&\n this.options.onGutterUtilityClick != null\n ) {\n this.startGutterSelectionFromPointerDown(event);\n } else {\n if (event.pointerType !== 'mouse') {\n this.revealUtilityFromGutterPath(path);\n }\n this.startLineSelectionFromPointerDown(event);\n }\n };\n\n private startLineSelectionFromPointerDown(event: PointerEvent): void {\n const { enableLineSelection = false } = this.options;\n if (!enableLineSelection) {\n return;\n }\n\n const pointerInfo = this.resolveSelectionInfo(event, {\n source: 'event-path',\n requireNumberColumn: true,\n });\n if (pointerInfo == null) {\n return;\n }\n\n const { pre } = this;\n if (pre == null) {\n return;\n }\n\n event.preventDefault();\n const { lineNumber, eventSide, lineIndex } = pointerInfo;\n\n if (event.shiftKey && this.selectedRange != null) {\n const rowRange = this.getIndexesFromSelection(\n this.selectedRange,\n pre.getAttribute('data-diff-type') === 'split'\n );\n if (rowRange == null) {\n return;\n }\n const useStart =\n rowRange.start <= rowRange.end\n ? lineIndex >= rowRange.start\n : lineIndex <= rowRange.end;\n this.selectionAnchor = {\n lineNumber: useStart\n ? this.selectedRange.start\n : this.selectedRange.end,\n side: useStart\n ? this.selectedRange.side\n : (this.selectedRange.endSide ?? this.selectedRange.side),\n };\n this.updateSelection(lineNumber, eventSide, false);\n this.notifySelectionStart(this.getCurrentSelectionRange());\n this.pointerSession = { mode: 'selecting', pointerId: event.pointerId };\n this.attachDocumentPointerListeners();\n return;\n }\n\n if (\n this.selectedRange?.start === lineNumber &&\n this.selectedRange?.end === lineNumber\n ) {\n const point = { lineNumber, side: eventSide };\n this.selectionAnchor = point;\n this.pointerSession = {\n mode: 'pendingSingleLineUnselect',\n pointerId: event.pointerId,\n anchor: point,\n pending: point,\n };\n this.attachDocumentPointerListeners();\n return;\n }\n\n if (this.options.controlledSelection === true) {\n this.proposedSelectedRange = null;\n } else {\n this.selectedRange = null;\n }\n this.placeUtility();\n this.selectionAnchor = { lineNumber, side: eventSide };\n this.updateSelection(lineNumber, eventSide, false);\n this.notifySelectionStart(this.getCurrentSelectionRange());\n this.pointerSession = { mode: 'selecting', pointerId: event.pointerId };\n this.attachDocumentPointerListeners();\n }\n\n private startGutterSelectionFromPointerDown(event: PointerEvent): void {\n const { enableLineSelection = false, onGutterUtilityClick } = this.options;\n if (onGutterUtilityClick == null) {\n return;\n }\n // If a selection already exists, the utility represents that whole range.\n // Dragging should start from the visual top and extend from the visual\n // bottom, regardless of the direction the range was originally created.\n const selectedEndpoints = this.currentSelectionEnds();\n const point =\n selectedEndpoints?.bottom ??\n this.resolveSelectionPoint(event, {\n source: 'event-path',\n excludeUtility: false,\n });\n const anchor = selectedEndpoints?.top ?? point;\n if (point == null || anchor == null) {\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n this.pointerSession = {\n mode: 'gutterSelecting',\n pointerId: event.pointerId,\n anchor,\n current: point,\n };\n if (enableLineSelection) {\n this.selectionAnchor = {\n lineNumber: anchor.lineNumber,\n side: anchor.side,\n };\n this.updateSelection(point.lineNumber, point.side, false);\n this.notifySelectionStart(this.getCurrentSelectionRange());\n }\n this.attachDocumentPointerListeners();\n }\n\n private handleDocumentPointerMove = (event: PointerEvent): void => {\n const { enableLineSelection = false } = this.options;\n switch (this.pointerSession.mode) {\n case 'idle':\n return;\n case 'gutterSelecting': {\n if (event.pointerId !== this.pointerSession.pointerId) {\n return;\n }\n event.preventDefault();\n const point = this.resolveSelectionPoint(event, {\n source: 'coordinates-first',\n });\n if (point == null) {\n return;\n }\n this.pointerSession.current = point;\n if (enableLineSelection === true) {\n this.updateSelection(point.lineNumber, point.side);\n }\n return;\n }\n case 'selecting': {\n if (event.pointerId !== this.pointerSession.pointerId) {\n return;\n }\n event.preventDefault();\n const pointerInfo = this.resolveSelectionInfo(event, {\n source: 'coordinates-first',\n requireNumberColumn: false,\n });\n if (pointerInfo == null || this.selectionAnchor == null) {\n return;\n }\n this.updateSelection(pointerInfo.lineNumber, pointerInfo.eventSide);\n return;\n }\n case 'pendingSingleLineUnselect': {\n if (event.pointerId !== this.pointerSession.pointerId) {\n return;\n }\n event.preventDefault();\n const pointerInfo = this.resolveSelectionInfo(event, {\n source: 'coordinates-first',\n requireNumberColumn: false,\n });\n if (pointerInfo == null || this.selectionAnchor == null) {\n return;\n }\n const point = {\n lineNumber: pointerInfo.lineNumber,\n side: pointerInfo.eventSide,\n };\n if (areSelectionPointsEqual(this.pointerSession.pending, point)) {\n return;\n }\n this.updateSelection(\n pointerInfo.lineNumber,\n pointerInfo.eventSide,\n false\n );\n this.notifySelectionStart(this.getCurrentSelectionRange());\n this.notifySelectionChangeDelta();\n this.pointerSession = {\n mode: 'selecting',\n pointerId: event.pointerId,\n };\n return;\n }\n }\n };\n\n private handleDocumentPointerUp = (event: PointerEvent): void => {\n const { enableLineSelection = false, onGutterUtilityClick } = this.options;\n switch (this.pointerSession.mode) {\n case 'idle':\n return;\n case 'gutterSelecting': {\n if (event.pointerId !== this.pointerSession.pointerId) {\n return;\n }\n event.preventDefault();\n const point = this.resolveSelectionPoint(event, {\n source: 'coordinates-first',\n });\n if (point != null) {\n this.pointerSession.current = point;\n if (enableLineSelection) {\n this.updateSelection(point.lineNumber, point.side);\n }\n }\n onGutterUtilityClick?.(\n this.buildSelectedLineRange(\n this.pointerSession.anchor,\n this.pointerSession.current\n )\n );\n this.selectionAnchor = undefined;\n if (enableLineSelection) {\n this.notifySelectionEnd(this.getCurrentSelectionRange());\n this.notifySelectionCommitted();\n this.clearProposedSelection();\n }\n this.clearPointerSession();\n this.detachDocumentPointerListeners();\n return;\n }\n case 'pendingSingleLineUnselect': {\n if (event.pointerId !== this.pointerSession.pointerId) {\n return;\n }\n event.preventDefault();\n this.updateSelection(null, undefined, false);\n this.selectionAnchor = undefined;\n this.clearPendingSingleLineState();\n this.detachDocumentPointerListeners();\n this.notifySelectionEnd(this.getCurrentSelectionRange());\n this.notifySelectionCommitted();\n this.clearProposedSelection();\n return;\n }\n case 'selecting': {\n if (event.pointerId !== this.pointerSession.pointerId) {\n return;\n }\n event.preventDefault();\n this.selectionAnchor = undefined;\n this.detachDocumentPointerListeners();\n this.clearPointerSession();\n this.notifySelectionEnd(this.getCurrentSelectionRange());\n this.notifySelectionCommitted();\n this.clearProposedSelection();\n }\n }\n };\n\n private handleDocumentPointerCancel = (event: PointerEvent): void => {\n switch (this.pointerSession.mode) {\n case 'idle':\n return;\n case 'gutterSelecting':\n case 'selecting':\n case 'pendingSingleLineUnselect': {\n if ('pointerId' in this.pointerSession) {\n if (event.pointerId !== this.pointerSession.pointerId) {\n return;\n }\n }\n this.selectionAnchor = undefined;\n this.clearProposedSelection();\n this.clearPendingSingleLineState();\n this.clearPointerSession();\n this.detachDocumentPointerListeners();\n }\n }\n };\n\n private clearHoveredLine() {\n if (this.hoveredLine == null) {\n return;\n }\n this.hoveredLine.lineElement.removeAttribute('data-hovered');\n this.hoveredLine.numberElement.removeAttribute('data-hovered');\n this.hoveredLine = undefined;\n }\n\n private setHoveredLine(hoveredLine: EventBaseProps<TMode>) {\n const { lineHoverHighlight = 'disabled' } = this.options;\n if (this.hoveredLine != null) {\n this.clearHoveredLine();\n }\n this.hoveredLine = hoveredLine;\n if (lineHoverHighlight !== 'disabled') {\n if (lineHoverHighlight === 'both' || lineHoverHighlight === 'line') {\n this.hoveredLine.lineElement.setAttribute('data-hovered', '');\n }\n if (lineHoverHighlight === 'both' || lineHoverHighlight === 'number') {\n this.hoveredLine.numberElement.setAttribute('data-hovered', '');\n }\n }\n }\n\n private clearHoveredToken() {\n if (this.hoveredToken == null) {\n return;\n }\n this.hoveredToken = undefined;\n }\n\n private setHoveredToken(hoveredToken: OnTokenEventProps<TMode>) {\n if (this.hoveredToken != null) {\n this.clearHoveredToken();\n }\n this.hoveredToken = hoveredToken;\n }\n\n private ensureGutterUtilityNode(useCustomGutterUtility: boolean): void {\n if (this.gutterUtilityContainer == null) {\n this.gutterUtilityContainer = document.createElement('div');\n this.gutterUtilityContainer.setAttribute('data-gutter-utility-slot', '');\n }\n if (useCustomGutterUtility) {\n if (this.gutterUtilityButton != null) {\n this.gutterUtilityButton.remove();\n this.gutterUtilityButton = undefined;\n }\n if (this.gutterUtilitySlot == null) {\n this.gutterUtilitySlot = document.createElement('slot');\n this.gutterUtilitySlot.name = 'gutter-utility-slot';\n }\n if (this.gutterUtilitySlot.parentNode !== this.gutterUtilityContainer) {\n this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);\n }\n } else {\n this.gutterUtilitySlot?.remove();\n this.gutterUtilitySlot = undefined;\n if (this.gutterUtilityButton == null) {\n const tempDiv = document.createElement('div');\n tempDiv.innerHTML = toHtml(createGutterUtilityElement());\n const utilityButton = tempDiv.firstElementChild;\n if (!(utilityButton instanceof HTMLButtonElement)) {\n throw new Error(\n 'InteractionManager.ensureGutterUtilityNode: Node element should be a button'\n );\n }\n utilityButton.remove();\n this.gutterUtilityButton = utilityButton;\n }\n if (this.gutterUtilityButton.parentNode !== this.gutterUtilityContainer) {\n this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton);\n }\n }\n }\n\n private revealUtilityFromGutterPath(path: (EventTarget | undefined)[]): void {\n if (this.placeUtilityFromSelection()) {\n return;\n }\n const target = this.resolvePointerTarget(path);\n if (isLinePointerTarget(target) && target.numberColumn) {\n this.showUtilityOnLine(this.toEventBaseProps(target));\n }\n }\n\n // The gutter utility follows the active selection first because a selected\n // range is more stable than transient hover/touch state. Without a\n // selection, desktop hover and mobile tap reveal can still place it on a\n // single row.\n private placeUtility(): void {\n if (this.placeUtilityFromSelection()) {\n return;\n }\n if (this.hoveredLine != null) {\n this.showUtilityOnLine(this.hoveredLine);\n return;\n }\n this.hideUtility();\n }\n\n private placeUtilityFromSelection(): boolean {\n const endpoints = this.currentSelectionEnds();\n if (endpoints == null) {\n return false;\n }\n const target = this.targetForSelectionPoint(endpoints.bottom);\n if (target == null) {\n this.hideUtility();\n } else {\n this.showUtilityOnLine(this.toEventBaseProps(target));\n }\n return true;\n }\n\n private showUtilityOnLine(line: EventBaseProps<TMode>): void {\n if (this.gutterUtilityContainer == null) {\n return;\n }\n this.gutterUtilityLine = line;\n line.numberElement.appendChild(this.gutterUtilityContainer);\n }\n\n private hideUtility(): void {\n this.gutterUtilityContainer?.remove();\n this.gutterUtilityLine = undefined;\n }\n\n // Selection ranges preserve drag direction, so compare rendered row indexes to\n // find the visually top-most and bottom-most endpoints.\n private currentSelectionEnds(): SelectionEnds | undefined {\n const range = this.getCurrentSelectionRange();\n return range == null ? undefined : this.selectionEnds(range);\n }\n\n private selectionEnds(range: SelectedLineRange): SelectionEnds | undefined {\n const start: SelectionPoint = {\n lineNumber: range.start,\n side: range.side,\n };\n const end: SelectionPoint = {\n lineNumber: range.end,\n side: range.endSide ?? range.side,\n };\n const startIndex = this.selectionPointRowIndex(start);\n const endIndex = this.selectionPointRowIndex(end);\n if (startIndex == null || endIndex == null) {\n return undefined;\n }\n return startIndex > endIndex\n ? { top: end, bottom: start }\n : { top: start, bottom: end };\n }\n\n private selectionPointRowIndex(point: SelectionPoint): number | undefined {\n const indexes = this.getLineIndex(point.lineNumber, point.side);\n if (indexes == null) {\n return undefined;\n }\n return this.isSplitDiff() ? indexes[1] : indexes[0];\n }\n\n private targetForSelectionPoint(\n point: SelectionPoint\n ): LinePointerTarget<TMode> | undefined {\n if (this.pre == null) {\n return undefined;\n }\n const indexes = this.getLineIndex(point.lineNumber, point.side);\n if (indexes == null) {\n return undefined;\n }\n const lineIndex =\n this.mode === 'diff' ? `${indexes[0]},${indexes[1]}` : `${indexes[0]}`;\n // Rebuild the real gutter-row target from the selection point so the\n // utility can anchor to the visible row even when the point came from\n // controlled state rather than a pointer event.\n const candidates = this.pre.querySelectorAll(\n `[data-column-number=\"${point.lineNumber}\"][data-line-index=\"${lineIndex}\"]`\n );\n for (const element of candidates) {\n if (!(element instanceof HTMLElement)) {\n continue;\n }\n const target = this.resolvePointerTarget(getElementPath(element));\n if (!isLinePointerTarget(target)) {\n continue;\n }\n if (\n this.mode === 'diff' &&\n point.side != null &&\n target.side !== point.side\n ) {\n continue;\n }\n return target;\n }\n return undefined;\n }\n\n private attachDocumentPointerListeners(): void {\n if (this.hasDocumentPointerListeners) {\n return;\n }\n document.addEventListener('pointermove', this.handleDocumentPointerMove);\n document.addEventListener('pointerup', this.handleDocumentPointerUp);\n document.addEventListener(\n 'pointercancel',\n this.handleDocumentPointerCancel\n );\n this.hasDocumentPointerListeners = true;\n }\n\n private detachDocumentPointerListeners(): void {\n if (!this.hasDocumentPointerListeners) {\n return;\n }\n document.removeEventListener('pointermove', this.handleDocumentPointerMove);\n document.removeEventListener('pointerup', this.handleDocumentPointerUp);\n document.removeEventListener(\n 'pointercancel',\n this.handleDocumentPointerCancel\n );\n this.hasDocumentPointerListeners = false;\n }\n\n private clearPointerSession(): void {\n this.pointerSession = { mode: 'idle' };\n }\n\n private clearPendingSingleLineState(): void {\n if (this.pointerSession.mode === 'pendingSingleLineUnselect') {\n this.pointerSession = { mode: 'idle' };\n }\n }\n\n private selectionInfoFromPath(\n path: (EventTarget | undefined)[],\n requireNumberColumn: boolean\n ): SelectionInfo | undefined {\n const target = this.resolvePointerTarget(path);\n if (!isLinePointerTarget(target)) {\n return undefined;\n }\n if (requireNumberColumn && !target.numberColumn) {\n return undefined;\n }\n if (target.splitLineIndex == null) {\n return undefined;\n }\n\n return {\n lineIndex: target.splitLineIndex,\n lineNumber: target.lineNumber,\n eventSide: this.mode === 'diff' ? target.side : undefined,\n };\n }\n\n private resolveSelectionInfo(\n event: PointerEvent,\n options: SelectionInfoOptions\n ): SelectionInfo | undefined {\n const path = this.resolveSelectionPath(event, options);\n return path != null\n ? this.selectionInfoFromPath(path, options.requireNumberColumn)\n : undefined;\n }\n\n private selectionPointFromPath(\n path: (EventTarget | undefined)[]\n ): SelectionPoint | undefined {\n const target = this.resolvePointerTarget(path);\n if (!isLinePointerTarget(target)) {\n return undefined;\n }\n return {\n lineNumber: target.lineNumber,\n side: this.mode === 'diff' ? target.side : undefined,\n };\n }\n\n private resolveSelectionPoint(\n event: PointerEvent,\n options: SelectionHitOptions\n ): SelectionPoint | undefined {\n const path = this.resolveSelectionPath(event, options);\n return path != null ? this.selectionPointFromPath(path) : undefined;\n }\n\n private resolveSelectionPath(\n event: PointerEvent,\n options: SelectionHitOptions\n ): (EventTarget | undefined)[] | undefined {\n const excludeUtility = options.excludeUtility !== false;\n switch (options.source) {\n case 'event-path':\n return this.pathFromEventPath(event.composedPath(), excludeUtility);\n case 'coordinates-first': {\n // Touch pointers can keep dispatching move/up events to the element\n // where the drag began. Prefer the row currently under the finger,\n // then fall back only when coordinate hit-testing is unavailable.\n const coordinatePath = this.pathFromCoordinates(event, excludeUtility);\n if (coordinatePath !== undefined) {\n return coordinatePath ?? undefined;\n }\n return this.pathFromEventPath(event.composedPath(), excludeUtility);\n }\n }\n }\n\n private pathFromCoordinates(\n event: PointerEvent,\n excludeUtility: boolean\n ): (EventTarget | undefined)[] | null | undefined {\n const coordinateTarget = this.hitTest(event);\n if (coordinateTarget === undefined) {\n return undefined;\n }\n if (coordinateTarget === null) {\n return null;\n }\n // A coordinate hit can be a token span, line-number span, utility overlay,\n // or separator. Normalize valid descendants back to their row; invalid\n // hits intentionally return null so the last selected row stays sticky.\n return this.pathFromElement(coordinateTarget, excludeUtility) ?? null;\n }\n\n private pathFromEventPath(\n path: (EventTarget | undefined)[],\n excludeUtility: boolean\n ): (EventTarget | undefined)[] | undefined {\n if (excludeUtility && isGutterUtilityPath(path)) {\n return undefined;\n }\n for (const element of path) {\n if (element instanceof Element) {\n return this.pathFromElement(element, excludeUtility);\n }\n }\n return undefined;\n }\n\n private pathFromElement(\n element: Element,\n excludeUtility: boolean\n ): (EventTarget | undefined)[] | undefined {\n const path = getElementPath(element);\n if (excludeUtility && isGutterUtilityPath(path)) {\n return undefined;\n }\n // Selection is row-based, not child-element-based. Lateral movement over\n // tokens, annotations, or line-number text should still update to the\n // nearest content or gutter row; anything else is ignored by returning\n // undefined.\n const row = closestSelectableRow(element);\n if (row != null) {\n return getElementPath(row);\n }\n return this.pathFromAnnotationSlot(element);\n }\n\n private pathFromAnnotationSlot(\n element: Element\n ): (EventTarget | undefined)[] | undefined {\n const point = selectionPointFromAnnotationSlotName(\n getAnnotationSlotName(element)\n );\n if (point == null) {\n return undefined;\n }\n const target = this.targetForSelectionPoint(point);\n return target != null ? getElementPath(target.lineElement) : undefined;\n }\n\n private hitTest(event: PointerEvent): Element | null | undefined {\n // Return undefined when coordinate hit-testing cannot run at all, which\n // allows callers to fall back to the event path for tests and older DOMs.\n // Return null when hit-testing ran but found no element, so active drags\n // keep their previous endpoint instead of using a stale captured target.\n if (!Number.isFinite(event.clientX) || !Number.isFinite(event.clientY)) {\n return undefined;\n }\n const root = this.pre?.getRootNode();\n const elementFromPointRoot = hasElementFromPoint(root)\n ? root\n : hasElementFromPoint(document)\n ? document\n : undefined;\n if (elementFromPointRoot == null) {\n return undefined;\n }\n const element = elementFromPointRoot.elementFromPoint(\n event.clientX,\n event.clientY\n );\n return element;\n }\n\n private getLineIndex(\n lineNumber: number,\n side?: SelectionSide\n ): [number, number] | undefined {\n const { getLineIndex } = this.options;\n return getLineIndex != null\n ? getLineIndex(lineNumber, side)\n : [lineNumber - 1, lineNumber - 1];\n }\n\n private getCurrentSelectionRange(): SelectedLineRange | null {\n return this.proposedSelectedRange !== undefined\n ? this.proposedSelectedRange\n : this.selectedRange;\n }\n\n private clearProposedSelection(): void {\n this.proposedSelectedRange = undefined;\n }\n\n private updateSelection(\n currentLine: number | null,\n side?: SelectionSide,\n emitChange = true\n ): void {\n const previousRange = this.getCurrentSelectionRange();\n let nextRange: SelectedLineRange | null;\n if (currentLine == null) {\n nextRange = null;\n } else {\n const anchorSide = this.selectionAnchor?.side ?? side;\n const anchorLine = this.selectionAnchor?.lineNumber ?? currentLine;\n nextRange = this.buildSelectionRange(\n anchorLine,\n currentLine,\n anchorSide,\n side\n );\n }\n if (\n areSelectionsEqual(previousRange ?? undefined, nextRange ?? undefined)\n ) {\n return;\n }\n if (this.options.controlledSelection === true) {\n this.proposedSelectedRange = nextRange;\n } else {\n this.selectedRange = nextRange;\n this.queuedSelectionRender ??= requestAnimationFrame(\n this.renderSelection\n );\n }\n this.placeUtility();\n if (emitChange) {\n this.notifySelectionChangeDelta();\n }\n }\n\n private getIndexesFromSelection(\n selectedRange: SelectedLineRange,\n split: boolean\n ): { start: number; end: number } | undefined {\n if (this.pre == null) {\n return undefined;\n }\n const startIndexes = this.getLineIndex(\n selectedRange.start,\n selectedRange.side\n );\n const finalIndexes = this.getLineIndex(\n selectedRange.end,\n selectedRange.endSide ?? selectedRange.side\n );\n\n return startIndexes != null && finalIndexes != null\n ? {\n start: split ? startIndexes[1] : startIndexes[0],\n end: split ? finalIndexes[1] : finalIndexes[0],\n }\n : undefined;\n }\n\n private renderSelection = (): void => {\n if (this.queuedSelectionRender != null) {\n cancelAnimationFrame(this.queuedSelectionRender);\n this.queuedSelectionRender = undefined;\n }\n if (\n this.pre == null ||\n this.renderedSelectionRange === this.selectedRange\n ) {\n return;\n }\n\n const allSelected = this.pre.querySelectorAll('[data-selected-line]');\n for (const element of allSelected) {\n element.removeAttribute('data-selected-line');\n }\n\n this.renderedSelectionRange = this.selectedRange;\n if (this.selectedRange == null) {\n return;\n }\n\n const { children: codeElements } = this.pre;\n if (codeElements.length === 0) {\n return;\n }\n if (codeElements.length > 2) {\n console.error(codeElements);\n throw new Error(\n 'InteractionManager.renderSelection: Somehow there are more than 2 code elements...'\n );\n }\n const split = this.pre.getAttribute('data-diff-type') === 'split';\n const rowRange = this.getIndexesFromSelection(this.selectedRange, split);\n if (rowRange == null) {\n console.error({ rowRange, selectedRange: this.selectedRange });\n throw new Error('InteractionManager.renderSelection: No valid rowRange');\n }\n const isSingle = rowRange.start === rowRange.end;\n const first = Math.min(rowRange.start, rowRange.end);\n const last = Math.max(rowRange.start, rowRange.end);\n for (const code of codeElements) {\n const [gutter, content] = code.children;\n const len = content.children.length;\n if (len !== gutter.children.length) {\n throw new Error(\n 'InteractionManager.renderSelection: gutter and content children dont match, something is wrong'\n );\n }\n for (let i = 0; i < len; i++) {\n const contentElement = content.children[i];\n const gutterElement = gutter.children[i];\n if (\n !(contentElement instanceof HTMLElement) ||\n !(gutterElement instanceof HTMLElement)\n ) {\n continue;\n }\n\n const lineIndex = this.parseLineIndex(contentElement, split);\n if ((lineIndex ?? 0) > last) {\n break;\n }\n if (lineIndex == null || lineIndex < first) {\n continue;\n }\n let attributeValue = isSingle\n ? 'single'\n : lineIndex === first\n ? 'first'\n : lineIndex === last\n ? 'last'\n : '';\n contentElement.setAttribute('data-selected-line', attributeValue);\n gutterElement.setAttribute('data-selected-line', attributeValue);\n if (\n gutterElement.nextSibling instanceof HTMLElement &&\n contentElement.nextSibling instanceof HTMLElement &&\n (contentElement.nextSibling.hasAttribute('data-line-annotation') ||\n contentElement.nextSibling.hasAttribute(\n 'data-merge-conflict-actions'\n ))\n ) {\n if (isSingle) {\n attributeValue = 'last';\n contentElement.setAttribute('data-selected-line', 'first');\n } else if (lineIndex === first) {\n attributeValue = '';\n } else if (lineIndex === last) {\n contentElement.setAttribute('data-selected-line', '');\n }\n contentElement.nextSibling.setAttribute(\n 'data-selected-line',\n attributeValue\n );\n gutterElement.nextSibling.setAttribute(\n 'data-selected-line',\n attributeValue\n );\n }\n }\n }\n };\n\n private notifySelectionCommitted(): void {\n this.options.onLineSelected?.(this.getCurrentSelectionRange() ?? null);\n }\n\n private notifySelectionChangeDelta(): void {\n this.options.onLineSelectionChange?.(\n this.getCurrentSelectionRange() ?? null\n );\n }\n\n private notifySelectionStart(range: SelectedLineRange | null): void {\n this.options.onLineSelectionStart?.(range);\n }\n\n private notifySelectionEnd(range: SelectedLineRange | null): void {\n this.options.onLineSelectionEnd?.(range);\n }\n\n private toEventBaseProps(\n target: HoverableLinePointerTarget<TMode>\n ): EventBaseProps<TMode> {\n if (this.mode === 'file') {\n return {\n type: 'line',\n lineElement: target.lineElement,\n lineNumber: target.lineNumber,\n numberColumn: target.numberColumn,\n numberElement: target.numberElement,\n } as EventBaseProps<TMode>;\n }\n\n return {\n type: 'diff-line',\n annotationSide: target.side as AnnotationSide,\n lineType: target.lineType,\n lineElement: target.lineElement,\n numberElement: target.numberElement,\n lineNumber: target.lineNumber,\n numberColumn: target.numberColumn,\n } as EventBaseProps<TMode>;\n }\n\n private toTokenEventBaseProps({\n lineCharEnd,\n lineCharStart,\n lineNumber,\n side,\n tokenElement,\n tokenText,\n }: TokenPointerTarget<TMode>): OnTokenEventProps<TMode> {\n if (this.mode === 'file') {\n return {\n type: 'token',\n lineCharEnd,\n lineCharStart,\n lineNumber,\n tokenElement,\n tokenText,\n } as OnTokenEventProps<TMode>;\n }\n\n return {\n type: 'token',\n lineCharEnd,\n lineCharStart,\n lineNumber,\n side,\n tokenElement,\n tokenText,\n } as OnTokenEventProps<TMode>;\n }\n\n private buildSelectedLineRange(\n anchor: SelectionPoint,\n current: SelectionPoint\n ): SelectedLineRange {\n return this.buildSelectionRange(\n anchor.lineNumber,\n current.lineNumber,\n anchor.side,\n current.side\n );\n }\n\n private buildSelectionRange(\n start: number,\n end: number,\n side?: SelectionSide,\n endSide?: SelectionSide\n ): SelectedLineRange {\n return {\n start,\n end,\n ...(side != null ? { side } : {}),\n ...(side !== endSide && endSide != null ? { endSide } : {}),\n };\n }\n\n private resolvePointerTarget(\n path: (EventTarget | undefined)[]\n ): ResolvedPointerTarget<TMode> | undefined {\n let numberColumn = false;\n let lineType: LineTypes | undefined;\n let codeElement: HTMLElement | undefined;\n let lineElement: HTMLElement | undefined;\n let lineIndexValue: string | undefined;\n let numberElement: HTMLElement | undefined;\n let tokenElement: HTMLElement | undefined;\n let tokenInfo: TokenCache | undefined;\n let expandInfo: ExpandCache | undefined;\n let lineNumber: number | undefined;\n let mergeConflictActionTarget: MergeConflictActionTarget | undefined;\n\n for (const element of path) {\n if (!(element instanceof HTMLElement)) {\n continue;\n }\n\n if (\n mergeConflictActionTarget == null &&\n element.hasAttribute('data-merge-conflict-action')\n ) {\n const resolutionValue =\n element.getAttribute('data-merge-conflict-action') ?? undefined;\n const conflictIndexValue =\n element.getAttribute('data-merge-conflict-conflict-index') ??\n undefined;\n const conflictIndex =\n conflictIndexValue != null\n ? Number.parseInt(conflictIndexValue, 10)\n : Number.NaN;\n if (\n isMergeConflictResolution(resolutionValue) &&\n Number.isFinite(conflictIndex)\n ) {\n mergeConflictActionTarget = {\n kind: 'merge-conflict-action',\n resolution: resolutionValue,\n conflictIndex,\n };\n }\n }\n\n if (tokenElement == null && element.hasAttribute('data-char')) {\n tokenElement = element;\n const startAttr = element.getAttribute('data-char');\n\n if (startAttr != null) {\n const lineCharStart = Number.parseInt(startAttr, 10);\n if (!Number.isNaN(lineCharStart)) {\n const tokenText = element.textContent ?? '';\n const lineCharEnd = lineCharStart + tokenText.length;\n if (\n tokenText.trim() !== '' ||\n this.options.enableTokenInteractionsOnWhitespace === true\n ) {\n tokenInfo = {\n tokenElement,\n lineCharStart,\n lineCharEnd,\n tokenText,\n };\n }\n continue;\n }\n }\n }\n\n const columnNumber =\n numberElement == null\n ? (element.getAttribute('data-column-number') ?? undefined)\n : undefined;\n if (columnNumber != null) {\n numberElement = element;\n lineNumber = Number.parseInt(columnNumber, 10);\n numberColumn = true;\n lineType = getLineTypeFromElement(element);\n lineIndexValue = element.getAttribute('data-line-index') ?? undefined;\n continue;\n }\n\n const lineAttr =\n lineElement == null\n ? (element.getAttribute('data-line') ?? undefined)\n : undefined;\n if (lineAttr != null) {\n lineElement = element;\n lineNumber = Number.parseInt(lineAttr, 10);\n lineType = getLineTypeFromElement(element);\n lineIndexValue = element.getAttribute('data-line-index') ?? undefined;\n continue;\n }\n\n if (\n expandInfo == null &&\n (element.hasAttribute('data-expand-button') ||\n element.hasAttribute('data-unmodified-lines'))\n ) {\n expandInfo = {\n hunkIndex: undefined,\n direction: (() => {\n if (element.hasAttribute('data-expand-up')) {\n return 'up';\n }\n if (element.hasAttribute('data-expand-down')) {\n return 'down';\n }\n return 'both';\n })(),\n all: element.hasAttribute('data-expand-all-button'),\n };\n continue;\n }\n\n const expandIndexValue =\n expandInfo != null\n ? (element.getAttribute('data-expand-index') ?? undefined)\n : undefined;\n if (expandInfo != null && expandIndexValue != null) {\n const expandIndex = Number.parseInt(expandIndexValue, 10);\n if (!Number.isNaN(expandIndex)) {\n expandInfo.hunkIndex = expandIndex;\n }\n continue;\n }\n\n if (codeElement == null && element.hasAttribute('data-code')) {\n codeElement = element;\n break;\n }\n }\n\n if (mergeConflictActionTarget != null) {\n return mergeConflictActionTarget as ResolvedPointerTarget<TMode>;\n }\n\n if (expandInfo?.hunkIndex != null) {\n return {\n type: 'line-info',\n hunkIndex: expandInfo.hunkIndex,\n direction: expandInfo.direction,\n all: expandInfo.all,\n } as ResolvedPointerTarget<TMode>;\n }\n\n lineElement ??=\n lineIndexValue != null\n ? queryHTMLElement(\n codeElement,\n `[data-line][data-line-index=\"${lineIndexValue}\"]`\n )\n : undefined;\n numberElement ??=\n lineIndexValue != null\n ? queryHTMLElement(\n codeElement,\n `[data-column-number][data-line-index=\"${lineIndexValue}\"]`\n )\n : undefined;\n\n if (\n codeElement == null ||\n lineElement == null ||\n numberElement == null ||\n lineType == null ||\n lineNumber == null ||\n Number.isNaN(lineNumber)\n ) {\n return undefined;\n }\n\n const splitLineIndex = this.parseLineIndex(lineElement, this.isSplitDiff());\n\n if (tokenInfo != null) {\n if (this.mode === 'file') {\n return {\n kind: 'token',\n lineType,\n lineElement,\n lineNumber,\n numberColumn,\n numberElement,\n side: undefined,\n splitLineIndex,\n ...tokenInfo,\n } as ResolvedPointerTarget<TMode>;\n }\n\n return {\n kind: 'token',\n lineType,\n lineElement,\n lineNumber,\n numberColumn,\n numberElement,\n side: getAnnotationSide(lineType, codeElement),\n splitLineIndex,\n ...tokenInfo,\n } as ResolvedPointerTarget<TMode>;\n }\n\n // Otherwise return line target\n if (this.mode === 'file') {\n return {\n kind: 'line',\n lineType,\n lineElement,\n lineNumber,\n numberColumn,\n numberElement,\n side: undefined,\n splitLineIndex,\n } as ResolvedPointerTarget<TMode>;\n }\n\n return {\n kind: 'line',\n lineType,\n lineElement,\n lineNumber,\n numberColumn,\n numberElement,\n side: getAnnotationSide(lineType, codeElement),\n splitLineIndex,\n } as ResolvedPointerTarget<TMode>;\n }\n\n private isSplitDiff(): boolean {\n return this.pre?.getAttribute('data-diff-type') === 'split';\n }\n\n private parseLineIndex(\n element: HTMLElement,\n split: boolean\n ): number | undefined {\n const lineIndexes = (element.getAttribute('data-line-index') ?? '')\n .split(',')\n .map((value) => Number.parseInt(value, 10))\n .filter((value) => !Number.isNaN(value));\n\n if (split && lineIndexes.length === 2) {\n return lineIndexes[1];\n }\n if (!split) {\n return lineIndexes[0];\n }\n return undefined;\n }\n}\n\ntype InteractionPluckOptions<TMode extends InteractionManagerMode> =\n InteractionManagerBaseOptions<TMode> & {\n renderGutterUtility?(\n getHoveredRow: () => GetHoveredLineResult<TMode> | undefined\n ): HTMLElement | null | undefined;\n };\n\nexport function pluckInteractionOptions<TMode extends InteractionManagerMode>(\n {\n enableTokenInteractionsOnWhitespace,\n enableGutterUtility,\n lineHoverHighlight,\n onGutterUtilityClick,\n onLineClick,\n onLineEnter,\n onLineLeave,\n onLineNumberClick,\n onTokenClick,\n onTokenEnter,\n onTokenLeave,\n renderGutterUtility,\n __debugPointerEvents,\n enableLineSelection,\n controlledSelection,\n onLineSelected,\n onLineSelectionStart,\n onLineSelectionChange,\n onLineSelectionEnd,\n }: InteractionPluckOptions<TMode>,\n onHunkExpand?: (\n hunkIndex: number,\n direction: ExpansionDirections,\n expansionLineCountOverride?: number\n ) => unknown,\n getLineIndex?: GetLineIndexUtility,\n onMergeConflictActionClick?: (target: MergeConflictActionTarget) => void\n): InteractionManagerOptions<TMode> {\n return {\n enableTokenInteractionsOnWhitespace,\n enableGutterUtility: resolveEnableGutterUtilityOption({\n enableGutterUtility,\n renderGutterUtility,\n onGutterUtilityClick,\n }),\n usesCustomGutterUtility: renderGutterUtility != null,\n lineHoverHighlight,\n\n onGutterUtilityClick,\n onHunkExpand,\n onMergeConflictActionClick,\n onLineClick,\n onLineEnter,\n onLineLeave,\n onLineNumberClick,\n onTokenClick,\n onTokenEnter,\n onTokenLeave,\n __debugPointerEvents,\n\n enableLineSelection,\n controlledSelection,\n onLineSelected,\n onLineSelectionStart,\n onLineSelectionChange,\n onLineSelectionEnd,\n\n getLineIndex,\n };\n}\n\nfunction resolveEnableGutterUtilityOption<\n TMode extends InteractionManagerMode,\n>({\n enableGutterUtility,\n renderGutterUtility,\n onGutterUtilityClick,\n}: Pick<\n InteractionPluckOptions<TMode>,\n 'enableGutterUtility' | 'renderGutterUtility' | 'onGutterUtilityClick'\n>): boolean {\n if (onGutterUtilityClick != null && renderGutterUtility != null) {\n throw new Error(\n \"Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.\"\n );\n }\n return enableGutterUtility ?? false;\n}\n\nfunction isLinePointerTarget<TMode extends InteractionManagerMode>(\n target: ResolvedPointerTarget<TMode> | undefined\n): target is LinePointerTarget<TMode> {\n return target != null && 'kind' in target && target.kind === 'line';\n}\n\nfunction isTokenPointerTarget<TMode extends InteractionManagerMode>(\n target: ResolvedPointerTarget<TMode> | undefined\n): target is TokenPointerTarget<TMode> {\n return target != null && 'kind' in target && target.kind === 'token';\n}\n\nfunction isHoverableLinePointerTarget<TMode extends InteractionManagerMode>(\n target: ResolvedPointerTarget<TMode> | undefined\n): target is HoverableLinePointerTarget<TMode> {\n return isLinePointerTarget(target) || isTokenPointerTarget(target);\n}\n\nfunction isExpandoPointerTarget<TMode extends InteractionManagerMode>(\n target: ResolvedPointerTarget<TMode>\n): target is ExpandoEventProps {\n return 'type' in target && target.type === 'line-info';\n}\n\nfunction isMergeConflictActionPointerTarget<\n TMode extends InteractionManagerMode,\n>(target: ResolvedPointerTarget<TMode>): target is MergeConflictActionTarget {\n return 'kind' in target && target.kind === 'merge-conflict-action';\n}\n\nfunction isMergeConflictResolution(\n value: string | undefined\n): value is MergeConflictResolution {\n return value === 'current' || value === 'incoming' || value === 'both';\n}\n\nfunction queryHTMLElement(\n parent: HTMLElement | undefined,\n query: string\n): HTMLElement | undefined {\n const element = parent?.querySelector(query);\n return element instanceof HTMLElement ? element : undefined;\n}\n\nfunction getElementPath(element: Node): EventTarget[] {\n const path: EventTarget[] = [];\n let current: Node | null = element;\n while (current != null) {\n path.push(current);\n current = current.parentNode;\n }\n return path;\n}\n\n// Pointer hits often land on text/token descendants. This normalizes those\n// hits back to the row elements InteractionManager knows how to resolve.\nfunction closestSelectableRow(element: Element): HTMLElement | undefined {\n const row = element.closest('[data-line], [data-column-number]');\n if (row instanceof HTMLElement) {\n return row;\n }\n\n const annotationRow = element.closest(\n '[data-line-annotation], [data-gutter-buffer=\"annotation\"]'\n );\n if (!(annotationRow instanceof HTMLElement)) {\n return undefined;\n }\n\n const previousRow = annotationRow.previousElementSibling;\n return previousRow instanceof HTMLElement &&\n (previousRow.hasAttribute('data-line') ||\n previousRow.hasAttribute('data-column-number'))\n ? previousRow\n : undefined;\n}\n\nfunction getAnnotationSlotName(element: Element): string | undefined {\n const slottedElement = element.closest('[slot^=\"annotation-\"]');\n if (slottedElement instanceof HTMLElement) {\n return slottedElement.getAttribute('slot') ?? undefined;\n }\n\n if (element instanceof HTMLElement) {\n const slotName = element.getAttribute('name') ?? undefined;\n return slotName != null && slotName.startsWith('annotation-')\n ? slotName\n : undefined;\n }\n\n return undefined;\n}\n\nfunction selectionPointFromAnnotationSlotName(\n slotName: string | undefined\n): SelectionPoint | undefined {\n if (slotName == null) {\n return undefined;\n }\n\n const match = /^annotation-(?:(additions|deletions)-)?(\\d+)$/.exec(slotName);\n if (match == null) {\n return undefined;\n }\n\n const lineNumber = Number.parseInt(match[2], 10);\n if (!Number.isFinite(lineNumber)) {\n return undefined;\n }\n\n const side = match[1] as SelectionSide | undefined;\n return { lineNumber, side };\n}\n\ninterface ElementFromPointRoot {\n elementFromPoint(x: number, y: number): Element | null;\n}\n\nfunction hasElementFromPoint(\n value: Node | undefined\n): value is Node & ElementFromPointRoot {\n return (\n value != null &&\n typeof (value as Partial<ElementFromPointRoot>).elementFromPoint ===\n 'function'\n );\n}\n\nfunction getAnnotationSide(\n lineType: LineTypes,\n codeElement: HTMLElement\n): AnnotationSide {\n switch (lineType) {\n case 'change-deletion':\n return 'deletions';\n case 'change-addition':\n return 'additions';\n default:\n return codeElement.hasAttribute('data-deletions')\n ? 'deletions'\n : 'additions';\n }\n}\n\nfunction getLineTypeFromElement(element: HTMLElement): LineTypes | undefined {\n const lineType = element.getAttribute('data-line-type');\n if (lineType == null) {\n return undefined;\n }\n switch (lineType) {\n case 'change-deletion':\n case 'change-addition':\n case 'context':\n case 'context-expanded':\n return lineType;\n default:\n return undefined;\n }\n}\n\nfunction isGutterUtilityPath(path: (EventTarget | undefined)[]): boolean {\n for (const element of path) {\n if (!(element instanceof HTMLElement)) {\n continue;\n }\n if (\n element.hasAttribute('data-utility-button') ||\n element.hasAttribute('data-gutter-utility-slot') ||\n // Custom React/DOM utilities are slotted into the same utility surface,\n // so treat both the assigned content and the slot node itself as\n // utility hits.\n element.getAttribute('slot') === 'gutter-utility-slot' ||\n element.getAttribute('name') === 'gutter-utility-slot'\n ) {\n return true;\n }\n }\n return false;\n}\n\nfunction debugLogIfEnabled(\n debugLogType: LogTypes | undefined = 'none',\n logIfType: 'move' | 'click',\n ...args: unknown[]\n) {\n switch (debugLogType) {\n case 'none':\n return;\n case 'both':\n break;\n case 'click':\n if (logIfType !== 'click') {\n return;\n }\n break;\n case 'move':\n if (logIfType !== 'move') {\n return;\n }\n break;\n }\n console.log(...args);\n}\n"],"mappings":";;;;;;AAkOA,IAAa,qBAAb,MAAsE;CACpE,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,AAAQ,uBAAuB;CAC/B,AAAQ,6BAA6B;CAErC,AAAQ,sBAAsB;CAC9B,AAAQ,8BAA8B;CAEtC,AAAQ,gBAA0C;CAClD,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ,iBAAiC,EAAE,MAAM,QAAQ;CAEzD,YACE,AAAQA,MACR,AAAQC,SACR;EAFQ;EACA;;CAGV,WAAW,SAAiD;AAC1D,OAAK,UAAU;;CAGjB,UAAgB;AACd,OAAK,KAAK,oBAAoB,SAAS,KAAK,mBAAmB;AAC/D,OAAK,KAAK,oBAAoB,eAAe,KAAK,kBAAkB;AACpE,OAAK,KAAK,oBAAoB,eAAe,KAAK,kBAAkB;AACpE,OAAK,KAAK,oBAAoB,gBAAgB,KAAK,mBAAmB;AACtE,OAAK,KAAK,gBAAgB,yBAAyB;AACnD,OAAK,KAAK,gBAAgB,gCAAgC;AAC1D,OAAK,MAAM;AACX,OAAK,wBAAwB,QAAQ;AACrC,OAAK,oBAAoB;AACzB,OAAK,yBAAyB;AAC9B,OAAK,sBAAsB;AAC3B,OAAK,oBAAoB;AACzB,OAAK,kBAAkB;AACvB,OAAK,mBAAmB;AACxB,OAAK,gCAAgC;AACrC,OAAK,qBAAqB;AAC1B,MAAI,KAAK,yBAAyB,MAAM;AACtC,wBAAqB,KAAK,sBAAsB;AAChD,QAAK,wBAAwB;;AAE/B,OAAK,uBAAuB;AAC5B,OAAK,6BAA6B;AAClC,OAAK,sBAAsB;;CAG7B,MAAM,KAA2B;AAC/B,OAAK,mBAAmB;EACxB,MAAM,EAAE,0BAA0B,OAAO,sBAAs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AAM,WAAW,MAAM;AAC1B,MAAI,EAAE,mBAAmB,aACvB;AAEF,MACE,QAAQ,aAAa,sBAAsB,IAC3C,QAAQ,aAAa,2BAA2B,IAIhD,QAAQ,aAAa,OAAO,KAAK,yBACjC,QAAQ,aAAa,OAAO,KAAK,sBAEjC,QAAO;;AAGX,QAAO;;AAGT,SAAS,kBACP,eAAqC,QACrC,WACA,GAAG,MACH;AACA,SAAQ,cAAR;EACE,KAAK,OACH;EACF,KAAK,OACH;EACF,KAAK;AACH,OAAI,cAAc,QAChB;AAEF;EACF,KAAK;AACH,OAAI,cAAc,OAChB;AAEF;;AAEJ,SAAQ,IAAI,GAAG,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","names":["CSSProperties","GutterUtilitySlotStyles","MergeConflictSlotStyles","noopRender"],"sources":["../../src/react/constants.d.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\nexport declare const GutterUtilitySlotStyles: CSSProperties;\nexport declare const MergeConflictSlotStyles: CSSProperties;\nexport declare function noopRender(): null;\n//# sourceMappingURL=constants.d.ts.map"],"mappings":";;;cACqBC,yBAAyBD;cACzBE,yBAAyBF;AADzBC,iBAEGE,UAAAA,CAAAA,CAFmC,EAAA,IAAA"}
1
+ {"version":3,"file":"constants.d.ts","names":["CSSProperties","GutterUtilitySlotStyles","MergeConflictSlotStyles","noopRender"],"sources":["../../src/react/constants.d.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\nexport declare const GutterUtilitySlotStyles: CSSProperties;\nexport declare const MergeConflictSlotStyles: CSSProperties;\nexport declare function noopRender(): null;\n//# sourceMappingURL=constants.d.ts.map"],"mappings":";;;cACqBC,yBAAyBD;cACzBE,yBAAyBF;AADzBC,iBAEGE,UAAAA,CAAAA,CAFmC,EAAA,IAAbH"}
@@ -3,7 +3,9 @@ const GutterUtilitySlotStyles = {
3
3
  position: "absolute",
4
4
  top: 0,
5
5
  bottom: 0,
6
- textAlign: "center"
6
+ textAlign: "center",
7
+ whiteSpace: "normal",
8
+ touchAction: "none"
7
9
  };
8
10
  const MergeConflictSlotStyles = { display: "contents" };
9
11
  function noopRender() {
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["GutterUtilitySlotStyles: CSSProperties","MergeConflictSlotStyles: CSSProperties"],"sources":["../../src/react/constants.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nexport const GutterUtilitySlotStyles: CSSProperties = {\n position: 'absolute',\n top: 0,\n bottom: 0,\n textAlign: 'center',\n};\n\nexport const MergeConflictSlotStyles: CSSProperties = {\n display: 'contents',\n};\n\nexport function noopRender() {\n return null;\n}\n"],"mappings":";AAEA,MAAaA,0BAAyC;CACpD,UAAU;CACV,KAAK;CACL,QAAQ;CACR,WAAW;CACZ;AAED,MAAaC,0BAAyC,EACpD,SAAS,YACV;AAED,SAAgB,aAAa;AAC3B,QAAO"}
1
+ {"version":3,"file":"constants.js","names":["GutterUtilitySlotStyles: CSSProperties","MergeConflictSlotStyles: CSSProperties"],"sources":["../../src/react/constants.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nexport const GutterUtilitySlotStyles: CSSProperties = {\n position: 'absolute',\n top: 0,\n bottom: 0,\n textAlign: 'center',\n whiteSpace: 'normal',\n touchAction: 'none',\n};\n\nexport const MergeConflictSlotStyles: CSSProperties = {\n display: 'contents',\n};\n\nexport function noopRender() {\n return null;\n}\n"],"mappings":";AAEA,MAAaA,0BAAyC;CACpD,UAAU;CACV,KAAK;CACL,QAAQ;CACR,WAAW;CACX,YAAY;CACZ,aAAa;CACd;AAED,MAAaC,0BAAyC,EACpD,SAAS,YACV;AAED,SAAgB,aAAa;AAC3B,QAAO"}
@@ -1,4 +1,4 @@
1
- import { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewItemVersion, CodeViewLineScrollTarget, CodeViewMetrics, CodeViewPositionScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs } from "../types.js";
1
+ import { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectedLineRange, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs } from "../types.js";
2
2
  import { WorkerInitializationRenderOptions, WorkerPoolOptions } from "../worker/types.js";
3
3
  import { FileOptions } from "../components/File.js";
4
4
  import { CodeView, CodeViewHandle, CodeViewProps, ControlledCodeViewProps, UncontrolledCodeViewProps } from "./CodeView.js";
@@ -17,4 +17,4 @@ import { templateRender } from "./utils/templateRender.js";
17
17
  import { useFileDiffInstance } from "./utils/useFileDiffInstance.js";
18
18
  import { useFileInstance } from "./utils/useFileInstance.js";
19
19
  import { useStableCallback } from "./utils/useStableCallback.js";
20
- export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeView, CodeViewDiffItem, CodeViewFileItem, CodeViewHandle, CodeViewItem, CodeViewItemScrollTarget, CodeViewItemVersion, CodeViewLineScrollTarget, CodeViewMetrics, CodeViewPositionScrollTarget, CodeViewProps, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, ControlledCodeViewProps, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffBasePropsReact, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, File, FileContents, FileDiff, FileDiffMetadata, FileDiffProps, FileHeaderRenderMode, FileOptions, FileProps, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, GutterUtilitySlotStyles, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictActionsTypeOption, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, MergeConflictSlotStyles, MultiFileDiff, MultiFileDiffProps, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PatchDiff, PatchDiffProps, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderMergeConflictActionContext, RenderMergeConflictActions, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, UncontrolledCodeViewProps, UnresolvedFile, UnresolvedFileProps, UnresolvedFileReactOptions, VirtualFileMetrics, VirtualWindowSpecs, Virtualizer, VirtualizerContext, WorkerInitializationRenderOptions, WorkerPoolContext, WorkerPoolContextProvider, WorkerPoolOptions, noopRender, renderDiffChildren, renderFileChildren, templateRender, useFileDiffInstance, useFileInstance, useStableCallback, useVirtualizer, useWorkerPool };
20
+ export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeView, CodeViewDiffItem, CodeViewFileItem, CodeViewHandle, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewProps, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, ControlledCodeViewProps, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffBasePropsReact, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, File, FileContents, FileDiff, FileDiffMetadata, FileDiffProps, FileHeaderRenderMode, FileOptions, FileProps, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, GutterUtilitySlotStyles, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictActionsTypeOption, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, MergeConflictSlotStyles, MultiFileDiff, MultiFileDiffProps, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PatchDiff, PatchDiffProps, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderMergeConflictActionContext, RenderMergeConflictActions, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectedLineRange, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, UncontrolledCodeViewProps, UnresolvedFile, UnresolvedFileProps, UnresolvedFileReactOptions, VirtualFileMetrics, VirtualWindowSpecs, Virtualizer, VirtualizerContext, WorkerInitializationRenderOptions, WorkerPoolContext, WorkerPoolContextProvider, WorkerPoolOptions, noopRender, renderDiffChildren, renderFileChildren, templateRender, useFileDiffInstance, useFileInstance, useStableCallback, useVirtualizer, useWorkerPool };
@@ -1 +1 @@
1
- {"version":3,"file":"jsx.d.ts","names":["DIFFS_TAG_NAME","_0","HTMLElement","React","HTMLAttributes","DetailedHTMLProps","sideEffect"],"sources":["../../src/react/jsx.d.ts"],"sourcesContent":["import 'react';\nimport type { DIFFS_TAG_NAME } from '../constants';\n\ndeclare module 'react' {\n namespace JSX {\n interface IntrinsicElements {\n [DIFFS_TAG_NAME]: React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLElement>,\n HTMLElement\n >;\n }\n }\n}\n"],"mappings":";;;;;EACmD,UAAA,GAAA,CAAA;IAAA,UAAA,iBAAA,CAAA;OAK5CA,cAAAA,CAL4C,EAK3BG,KAAAA,CAAME,iBALqB,CAM3CF,KAAAA,CAAMC,cAAeF,CAAAA,WAAAA,CAAAA,EACrBA,WADME,CACNF;IAFgBC;EAAjBH"}
1
+ {"version":3,"file":"jsx.d.ts","names":["DIFFS_TAG_NAME","_1","HTMLElement","React","HTMLAttributes","DetailedHTMLProps","sideEffect"],"sources":["../../src/react/jsx.d.ts"],"sourcesContent":["import 'react';\nimport type { DIFFS_TAG_NAME } from '../constants';\n\ndeclare module 'react' {\n namespace JSX {\n interface IntrinsicElements {\n [DIFFS_TAG_NAME]: React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLElement>,\n HTMLElement\n >;\n }\n }\n}\n"],"mappings":";;;;;EACmD,UAAA,GAAA,CAAA;IAAA,UAAA,iBAAA,CAAA;OAK5CA,cAAAA,CAL4C,EAK3BG,KAAAA,CAAME,iBALqB,CAM3CF,KAAAA,CAAMC,cAAeF,CAAAA,WAAAA,CAAAA,EACrBA,WADME,CACNF;IAFgBC;EAAjBH"}
@@ -1,5 +1,5 @@
1
- import { DiffLineAnnotation, FileContents, FileDiffMetadata, LineAnnotation, VirtualFileMetrics } from "../types.js";
2
- import { GetHoveredLineResult, SelectedLineRange } from "../managers/InteractionManager.js";
1
+ import { DiffLineAnnotation, FileContents, FileDiffMetadata, LineAnnotation, SelectedLineRange, VirtualFileMetrics } from "../types.js";
2
+ import { GetHoveredLineResult } from "../managers/InteractionManager.js";
3
3
  import { FileOptions } from "../components/File.js";
4
4
  import { FileDiffOptions } from "../components/FileDiff.js";
5
5
  import { CSSProperties, ReactNode } from "react";
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":["CSSProperties","ReactNode","FileOptions","FileDiffOptions","GetHoveredLineResult","SelectedLineRange","DiffLineAnnotation","FileContents","FileDiffMetadata","LineAnnotation","VirtualFileMetrics","DiffBasePropsReact","LAnnotation","FileProps"],"sources":["../../src/react/types.d.ts"],"sourcesContent":["import { type CSSProperties, type ReactNode } from 'react';\nimport type { FileOptions } from '../components/File';\nimport type { FileDiffOptions } from '../components/FileDiff';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../managers/InteractionManager';\nimport type { DiffLineAnnotation, FileContents, FileDiffMetadata, LineAnnotation, VirtualFileMetrics } from '../types';\nexport interface DiffBasePropsReact<LAnnotation> {\n options?: FileDiffOptions<LAnnotation>;\n metrics?: VirtualFileMetrics;\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[];\n selectedLines?: SelectedLineRange | null;\n renderAnnotation?(annotations: DiffLineAnnotation<LAnnotation>): ReactNode;\n renderCustomHeader?(fileDiff: FileDiffMetadata): ReactNode;\n renderHeaderPrefix?(fileDiff: FileDiffMetadata): ReactNode;\n renderHeaderMetadata?(fileDiff: FileDiffMetadata): ReactNode;\n renderGutterUtility?(getHoveredLine: () => GetHoveredLineResult<'diff'> | undefined): ReactNode;\n className?: string;\n style?: CSSProperties;\n prerenderedHTML?: string;\n}\nexport interface FileProps<LAnnotation> {\n file: FileContents;\n options?: FileOptions<LAnnotation>;\n metrics?: VirtualFileMetrics;\n lineAnnotations?: LineAnnotation<LAnnotation>[];\n selectedLines?: SelectedLineRange | null;\n renderAnnotation?(annotations: LineAnnotation<LAnnotation>): ReactNode;\n renderCustomHeader?(file: FileContents): ReactNode;\n renderHeaderPrefix?(file: FileContents): ReactNode;\n renderHeaderMetadata?(file: FileContents): ReactNode;\n renderGutterUtility?(getHoveredLine: () => GetHoveredLineResult<'file'> | undefined): ReactNode;\n className?: string;\n style?: CSSProperties;\n prerenderedHTML?: string;\n disableWorkerPool?: boolean;\n}\n//# sourceMappingURL=types.d.ts.map"],"mappings":";;;;;;;UAKiBW;YACHR,gBAAgBS;EADbD,OAAAA,CAAAA,EAEHD,kBAFqBE;EACLA,eAAAA,CAAAA,EAERN,kBAFQM,CAEWA,WAFXA,CAAAA,EAAAA;EAAhBT,aAAAA,CAAAA,EAGME,iBAHNF,GAAAA,IAAAA;EACAO,gBAAAA,EAAAA,WAAAA,EAGqBJ,kBAHrBI,CAGwCE,WAHxCF,CAAAA,CAAAA,EAGuDT,SAHvDS;EAC2BE,kBAAAA,EAAAA,QAAAA,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H,iBAAAA,CAAAA,EAAAA,OAAAA"}
1
+ {"version":3,"file":"types.d.ts","names":["CSSProperties","ReactNode","FileOptions","FileDiffOptions","GetHoveredLineResult","DiffLineAnnotation","FileContents","FileDiffMetadata","LineAnnotation","SelectedLineRange","VirtualFileMetrics","DiffBasePropsReact","LAnnotation","FileProps"],"sources":["../../src/react/types.d.ts"],"sourcesContent":["import { type CSSProperties, type ReactNode } from 'react';\nimport type { FileOptions } from '../components/File';\nimport type { FileDiffOptions } from '../components/FileDiff';\nimport type { GetHoveredLineResult } from '../managers/InteractionManager';\nimport type { DiffLineAnnotation, FileContents, FileDiffMetadata, LineAnnotation, SelectedLineRange, VirtualFileMetrics } from '../types';\nexport interface DiffBasePropsReact<LAnnotation> {\n options?: FileDiffOptions<LAnnotation>;\n metrics?: VirtualFileMetrics;\n lineAnnotations?: DiffLineAnnotation<LAnnotation>[];\n selectedLines?: SelectedLineRange | null;\n renderAnnotation?(annotations: DiffLineAnnotation<LAnnotation>): ReactNode;\n renderCustomHeader?(fileDiff: FileDiffMetadata): ReactNode;\n renderHeaderPrefix?(fileDiff: FileDiffMetadata): ReactNode;\n renderHeaderMetadata?(fileDiff: FileDiffMetadata): ReactNode;\n renderGutterUtility?(getHoveredLine: () => GetHoveredLineResult<'diff'> | undefined): ReactNode;\n className?: string;\n style?: CSSProperties;\n prerenderedHTML?: string;\n}\nexport interface FileProps<LAnnotation> {\n file: FileContents;\n options?: FileOptions<LAnnotation>;\n metrics?: VirtualFileMetrics;\n lineAnnotations?: LineAnnotation<LAnnotation>[];\n selectedLines?: SelectedLineRange | null;\n renderAnnotation?(annotations: LineAnnotation<LAnnotation>): ReactNode;\n renderCustomHeader?(file: FileContents): ReactNode;\n renderHeaderPrefix?(file: FileContents): ReactNode;\n renderHeaderMetadata?(file: FileContents): ReactNode;\n renderGutterUtility?(getHoveredLine: () => GetHoveredLineResult<'file'> | undefined): ReactNode;\n className?: string;\n style?: CSSProperties;\n prerenderedHTML?: string;\n disableWork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AGRY,kBAAS,EAAAD,IAAAA,EAQIN,YARJ,CAAA,EAQmBL,SARnB;EAChBK,oBAAAA,EAAAA,IAAAA,EAQsBA,YARtBA,CAAAA,EAQqCL,SARrCK;EACgBM,mBAAAA,EAAAA,cAAAA,EAAAA,GAAAA,GAQqBR,oBARrBQ,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA,CAAAA,EAQgEX,SARhEW;EAAZV,SAAAA,CAAAA,EAAAA,MAAAA;EACAQ,KAAAA,CAAAA,EASFV,aATEU;EACuBE,eAAAA,CAAAA,EAAAA,MAAAA;EAAfJ,iBAAAA,CAAAA,EAAAA,OAAAA"}
@@ -1,5 +1,5 @@
1
- import { DiffLineAnnotation, FileDiffMetadata, VirtualFileMetrics } from "../../types.js";
2
- import { GetHoveredLineResult, SelectedLineRange } from "../../managers/InteractionManager.js";
1
+ import { DiffLineAnnotation, FileDiffMetadata, SelectedLineRange, VirtualFileMetrics } from "../../types.js";
2
+ import { GetHoveredLineResult } from "../../managers/InteractionManager.js";
3
3
  import { FileDiffOptions } from "../../components/FileDiff.js";
4
4
 
5
5
  //#region src/react/utils/useFileDiffInstance.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"useFileDiffInstance.d.ts","names":["FileDiffOptions","GetHoveredLineResult","SelectedLineRange","DiffLineAnnotation","FileDiffMetadata","VirtualFileMetrics","UseFileDiffInstanceProps","LAnnotation","UseFileDiffInstanceReturn","HTMLElement","useFileDiffInstance","fileDiff","options","lineAnnotations","selectedLines","prerenderedHTML","metrics","hasGutterRenderUtility","hasCustomHeader","disableWorkerPool"],"sources":["../../../src/react/utils/useFileDiffInstance.d.ts"],"sourcesContent":["import { type FileDiffOptions } from '../../components/FileDiff';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../../managers/InteractionManager';\nimport type { DiffLineAnnotation, FileDiffMetadata, VirtualFileMetrics } from '../../types';\ninterface UseFileDiffInstanceProps<LAnnotation> {\n fileDiff: FileDiffMetadata;\n options: FileDiffOptions<LAnnotation> | undefined;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n hasGutterRenderUtility: boolean;\n hasCustomHeader: boolean;\n disableWorkerPool: boolean;\n}\ninterface UseFileDiffInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n}\nexport declare function useFileDiffInstance<LAnnotation>({ fileDiff, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility, hasCustomHeader, disableWorkerPool }: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn;\nexport {};\n//# sourceMappingURL=useFileDiffInstance.d.ts.map"],"mappings":";;;;;UAGUM;YACIF;EADJE,OAAAA,EAEGN,eAFHM,CAEmBC,WAFKA,CAAAA,GAAAA,SAAAA;EACpBH,eAAAA,EAEOD,kBAFPC,CAE0BG,WAF1BH,CAAAA,EAAAA,GAAAA,SAAAA;EACeG,aAAAA,EAEVL,iBAFUK,GAAAA,IAAAA,GAAAA,SAAAA;EAAhBP,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAC2BO,OAAAA,CAAAA,EAG1BF,kBAH0BE;EAAnBJ,sBAAAA,EAAAA,OAAAA;EACFD,eAAAA,EAAAA,OAAAA;EAELG,iBAAAA,EAAAA,OAAAA;;AAAkB,UAKtBG,yBAAAA,CAAyB;EAIXE,GAAAA,CAAAA,IAAAA,EAHVD,WAGUC,GAAmB,IAAA,CAAAH,EAAAA,IAAAA;EAAgBI,cAAAA,EAAAA,EAFrCV,oBAEqCU,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;;AAAmBE,iBAAtDH,mBAAsDG,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,QAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,eAAAA;EAAAA,OAAAA;EAAAA,sBAAAA;EAAAA,eAAAA;EAAAA;AAAAA,CAAAA,EAAwHP,wBAAxHO,CAAiJN,WAAjJM,CAAAA,CAAAA,EAAgKL,yBAAhKK"}
1
+ {"version":3,"file":"useFileDiffInstance.d.ts","names":["FileDiffOptions","GetHoveredLineResult","DiffLineAnnotation","FileDiffMetadata","SelectedLineRange","VirtualFileMetrics","UseFileDiffInstanceProps","LAnnotation","UseFileDiffInstanceReturn","HTMLElement","useFileDiffInstance","fileDiff","options","lineAnnotations","selectedLines","prerenderedHTML","metrics","hasGutterRenderUtility","hasCustomHeader","disableWorkerPool"],"sources":["../../../src/react/utils/useFileDiffInstance.d.ts"],"sourcesContent":["import { type FileDiffOptions } from '../../components/FileDiff';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { DiffLineAnnotation, FileDiffMetadata, SelectedLineRange, VirtualFileMetrics } from '../../types';\ninterface UseFileDiffInstanceProps<LAnnotation> {\n fileDiff: FileDiffMetadata;\n options: FileDiffOptions<LAnnotation> | undefined;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n hasGutterRenderUtility: boolean;\n hasCustomHeader: boolean;\n disableWorkerPool: boolean;\n}\ninterface UseFileDiffInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n}\nexport declare function useFileDiffInstance<LAnnotation>({ fileDiff, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility, hasCustomHeader, disableWorkerPool }: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn;\nexport {};\n//# sourceMappingURL=useFileDiffInstance.d.ts.map"],"mappings":";;;;;UAGUM;YACIH;EADJG,OAAAA,EAEGN,eAFHM,CAEmBC,WAFKA,CAAAA,GAAAA,SAAAA;EACpBJ,eAAAA,EAEOD,kBAFPC,CAE0BI,WAF1BJ,CAAAA,EAAAA,GAAAA,SAAAA;EACeI,aAAAA,EAEVH,iBAFUG,GAAAA,IAAAA,GAAAA,SAAAA;EAAhBP,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAC2BO,OAAAA,CAAAA,EAG1BF,kBAH0BE;EAAnBL,sBAAAA,EAAAA,OAAAA;EACFE,eAAAA,EAAAA,OAAAA;EAELC,iBAAAA,EAAAA,OAAAA;;AAAkB,UAKtBG,yBAAAA,CAAyB;EAIXE,GAAAA,CAAAA,IAAAA,EAHVD,WAGUC,GAAmB,IAAA,CAAAH,EAAAA,IAAAA;EAAgBI,cAAAA,EAAAA,EAFrCV,oBAEqCU,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;;AAAmBE,iBAAtDH,mBAAsDG,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,QAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,eAAAA;EAAAA,OAAAA;EAAAA,sBAAAA;EAAAA,eAAAA;EAAAA;AAAAA,CAAAA,EAAwHP,wBAAxHO,CAAiJN,WAAjJM,CAAAA,CAAAA,EAAgKL,yBAAhKK"}
@@ -1 +1 @@
1
- {"version":3,"file":"useFileDiffInstance.js","names":[],"sources":["../../../src/react/utils/useFileDiffInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n} from 'react';\n\nimport { FileDiff, type FileDiffOptions } from '../../components/FileDiff';\nimport { VirtualizedFileDiff } from '../../components/VirtualizedFileDiff';\nimport type {\n GetHoveredLineResult,\n SelectedLineRange,\n} from '../../managers/InteractionManager';\nimport type {\n DiffLineAnnotation,\n FileDiffMetadata,\n VirtualFileMetrics,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport { noopRender } from '../constants';\nimport { useVirtualizer } from '../Virtualizer';\nimport { WorkerPoolContext } from '../WorkerPoolContext';\nimport { useStableCallback } from './useStableCallback';\n\nconst useIsometricEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface UseFileDiffInstanceProps<LAnnotation> {\n fileDiff: FileDiffMetadata;\n options: FileDiffOptions<LAnnotation> | undefined;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n hasGutterRenderUtility: boolean;\n hasCustomHeader: boolean;\n disableWorkerPool: boolean;\n}\n\ninterface UseFileDiffInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n}\n\nexport function useFileDiffInstance<LAnnotation>({\n fileDiff,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n metrics,\n hasGutterRenderUtility,\n hasCustomHeader,\n disableWorkerPool,\n}: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn {\n const simpleVirtualizer = useVirtualizer();\n const controlledSelection = selectedLines !== undefined;\n const poolManager = useContext(WorkerPoolContext);\n const instanceRef = useRef<\n FileDiff<LAnnotation> | VirtualizedFileDiff<LAnnotation> | null\n >(null);\n const ref = useStableCallback((fileContainer: HTMLElement | null) => {\n if (fileContainer != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'useFileDiffInstance: An instance should not already exist when a node is created'\n );\n }\n if (simpleVirtualizer != null) {\n instanceRef.current = new VirtualizedFileDiff(\n mergeFileDiffOptions({\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n options,\n }),\n simpleVirtualizer,\n metrics,\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n } else {\n instanceRef.current = new FileDiff(\n mergeFileDiffOptions({\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n options,\n }),\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n }\n void instanceRef.current.hydrate({\n fileDiff,\n fileContainer,\n lineAnnotations,\n prerenderedHTML,\n });\n } else {\n if (instanceRef.current == null) {\n throw new Error(\n 'useFileDiffInstance: A FileDiff instance should exist when unmounting'\n );\n }\n instanceRef.current.cleanUp();\n instanceRef.current = null;\n }\n });\n\n useIsometricEffect(() => {\n const { current: instance } = instanceRef;\n if (instance == null) return;\n const newOptions = mergeFileDiffOptions({\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n options,\n });\n const forceRender = !areOptionsEqual(instance.options, newOptions);\n instance.setOptions(newOptions);\n void instance.render({\n forceRender,\n fileDiff,\n lineAnnotations,\n });\n if (selectedLines !== undefined) {\n instance.setSelectedLines(selectedLines);\n }\n });\n\n const getHoveredLine = useCallback(():\n | GetHoveredLineResult<'diff'>\n | undefined => {\n return instanceRef.current?.getHoveredLine();\n }, []);\n\n return { ref, getHoveredLine };\n}\n\ninterface MergeFileDiffOptionsProps<LAnnotation> {\n controlledSelection: boolean;\n hasCustomHeader: boolean;\n hasGutterRenderUtility: boolean;\n options: FileDiffOptions<LAnnotation> | undefined;\n}\n\nfunction mergeFileDiffOptions<LAnnotation>({\n options,\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n}: MergeFileDiffOptionsProps<LAnnotation>):\n | FileDiffOptions<LAnnotation>\n | undefined {\n if (!controlledSelection && !hasGutterRenderUtility && !hasCustomHeader) {\n return options;\n }\n return {\n ...options,\n controlledSelection,\n renderCustomHeader: hasCustomHeader\n ? noopRender\n : options?.renderCustomHeader,\n renderGutterUtility: hasGutterRenderUtility\n ? noopRender\n : options?.renderGutterUtility,\n };\n}\n"],"mappings":";;;;;;;;;;AAyBA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAmB9C,SAAgB,oBAAiC,EAC/C,UACA,SACA,iBACA,eACA,iBACA,SACA,wBACA,iBACA,qBACmE;CACnE,MAAM,oBAAoB,gBAAgB;CAC1C,MAAM,sBAAsB,kBAAkB;CAC9C,MAAM,cAAc,WAAW,kBAAkB;CACjD,MAAM,cAAc,OAElB,KAAK;CACP,MAAM,MAAM,mBAAmB,kBAAsC;AACnE,MAAI,iBAAiB,MAAM;AACzB,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MACR,mFACD;AAEH,OAAI,qBAAqB,KACvB,aAAY,UAAU,IAAI,oBACxB,qBAAqB;IACnB;IACA;IACA;IACA;IACD,CAAC,EACF,mBACA,SACA,CAAC,oBAAoB,cAAc,QACnC,KACD;OAED,aAAY,UAAU,IAAI,SACxB,qBAAqB;IACnB;IACA;IACA;IACA;IACD,CAAC,EACF,CAAC,oBAAoB,cAAc,QACnC,KACD;AAEH,GAAK,YAAY,QAAQ,QAAQ;IAC/B;IACA;IACA;IACA;IACD,CAAC;SACG;AACL,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MACR,wEACD;AAEH,eAAY,QAAQ,SAAS;AAC7B,eAAY,UAAU;;GAExB;AAEF,0BAAyB;EACvB,MAAM,EAAE,SAAS,aAAa;AAC9B,MAAI,YAAY,KAAM;EACtB,MAAM,aAAa,qBAAqB;GACtC;GACA;GACA;GACA;GACD,CAAC;EACF,MAAM,cAAc,CAAC,gBAAgB,SAAS,SAAS,WAAW;AAClE,WAAS,WAAW,WAAW;AAC/B,EAAK,SAAS,OAAO;GACnB;GACA;GACA;GACD,CAAC;AACF,MAAI,kBAAkB,OACpB,UAAS,iBAAiB,cAAc;GAE1C;AAQF,QAAO;EAAE;EAAK,gBANS,kBAEN;AACf,UAAO,YAAY,SAAS,gBAAgB;KAC3C,EAAE,CAAC;EAEwB;;AAUhC,SAAS,qBAAkC,EACzC,SACA,qBACA,iBACA,0BAGY;AACZ,KAAI,CAAC,uBAAuB,CAAC,0BAA0B,CAAC,gBACtD,QAAO;AAET,QAAO;EACL,GAAG;EACH;EACA,oBAAoB,kBAChB,aACA,SAAS;EACb,qBAAqB,yBACjB,aACA,SAAS;EACd"}
1
+ {"version":3,"file":"useFileDiffInstance.js","names":[],"sources":["../../../src/react/utils/useFileDiffInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n} from 'react';\n\nimport { FileDiff, type FileDiffOptions } from '../../components/FileDiff';\nimport { VirtualizedFileDiff } from '../../components/VirtualizedFileDiff';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type {\n DiffLineAnnotation,\n FileDiffMetadata,\n SelectedLineRange,\n VirtualFileMetrics,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport { noopRender } from '../constants';\nimport { useVirtualizer } from '../Virtualizer';\nimport { WorkerPoolContext } from '../WorkerPoolContext';\nimport { useStableCallback } from './useStableCallback';\n\nconst useIsometricEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface UseFileDiffInstanceProps<LAnnotation> {\n fileDiff: FileDiffMetadata;\n options: FileDiffOptions<LAnnotation> | undefined;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n hasGutterRenderUtility: boolean;\n hasCustomHeader: boolean;\n disableWorkerPool: boolean;\n}\n\ninterface UseFileDiffInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n}\n\nexport function useFileDiffInstance<LAnnotation>({\n fileDiff,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n metrics,\n hasGutterRenderUtility,\n hasCustomHeader,\n disableWorkerPool,\n}: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn {\n const simpleVirtualizer = useVirtualizer();\n const controlledSelection = selectedLines !== undefined;\n const poolManager = useContext(WorkerPoolContext);\n const instanceRef = useRef<\n FileDiff<LAnnotation> | VirtualizedFileDiff<LAnnotation> | null\n >(null);\n const ref = useStableCallback((fileContainer: HTMLElement | null) => {\n if (fileContainer != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'useFileDiffInstance: An instance should not already exist when a node is created'\n );\n }\n if (simpleVirtualizer != null) {\n instanceRef.current = new VirtualizedFileDiff(\n mergeFileDiffOptions({\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n options,\n }),\n simpleVirtualizer,\n metrics,\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n } else {\n instanceRef.current = new FileDiff(\n mergeFileDiffOptions({\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n options,\n }),\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n }\n void instanceRef.current.hydrate({\n fileDiff,\n fileContainer,\n lineAnnotations,\n prerenderedHTML,\n });\n } else {\n if (instanceRef.current == null) {\n throw new Error(\n 'useFileDiffInstance: A FileDiff instance should exist when unmounting'\n );\n }\n instanceRef.current.cleanUp();\n instanceRef.current = null;\n }\n });\n\n useIsometricEffect(() => {\n const { current: instance } = instanceRef;\n if (instance == null) return;\n const newOptions = mergeFileDiffOptions({\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n options,\n });\n const forceRender = !areOptionsEqual(instance.options, newOptions);\n instance.setOptions(newOptions);\n void instance.render({\n forceRender,\n fileDiff,\n lineAnnotations,\n });\n if (selectedLines !== undefined) {\n instance.setSelectedLines(selectedLines);\n }\n });\n\n const getHoveredLine = useCallback(():\n | GetHoveredLineResult<'diff'>\n | undefined => {\n return instanceRef.current?.getHoveredLine();\n }, []);\n\n return { ref, getHoveredLine };\n}\n\ninterface MergeFileDiffOptionsProps<LAnnotation> {\n controlledSelection: boolean;\n hasCustomHeader: boolean;\n hasGutterRenderUtility: boolean;\n options: FileDiffOptions<LAnnotation> | undefined;\n}\n\nfunction mergeFileDiffOptions<LAnnotation>({\n options,\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n}: MergeFileDiffOptionsProps<LAnnotation>):\n | FileDiffOptions<LAnnotation>\n | undefined {\n if (!controlledSelection && !hasGutterRenderUtility && !hasCustomHeader) {\n return options;\n }\n return {\n ...options,\n controlledSelection,\n renderCustomHeader: hasCustomHeader\n ? noopRender\n : options?.renderCustomHeader,\n renderGutterUtility: hasGutterRenderUtility\n ? noop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AUhC,SAAS,qBAAkC,EACzC,SACA,qBACA,iBACA,0BAGY;AACZ,KAAI,CAAC,uBAAuB,CAAC,0BAA0B,CAAC,gBACtD,QAAO;AAET,QAAO;EACL,GAAG;EACH;EACA,oBAAoB,kBAChB,aACA,SAAS;EACb,qBAAqB,yBACjB,aACA,SAAS;EACd"}
@@ -1,5 +1,5 @@
1
- import { FileContents, LineAnnotation, VirtualFileMetrics } from "../../types.js";
2
- import { GetHoveredLineResult, SelectedLineRange } from "../../managers/InteractionManager.js";
1
+ import { FileContents, LineAnnotation, SelectedLineRange, VirtualFileMetrics } from "../../types.js";
2
+ import { GetHoveredLineResult } from "../../managers/InteractionManager.js";
3
3
  import { FileOptions } from "../../components/File.js";
4
4
 
5
5
  //#region src/react/utils/useFileInstance.d.ts