@pierre/diffs 1.1.19 → 1.2.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/dist/components/CodeView.d.ts +324 -0
  2. package/dist/components/CodeView.d.ts.map +1 -0
  3. package/dist/components/CodeView.js +1245 -0
  4. package/dist/components/CodeView.js.map +1 -0
  5. package/dist/components/File.d.ts +13 -12
  6. package/dist/components/File.d.ts.map +1 -1
  7. package/dist/components/File.js +68 -28
  8. package/dist/components/File.js.map +1 -1
  9. package/dist/components/FileDiff.d.ts +9 -10
  10. package/dist/components/FileDiff.d.ts.map +1 -1
  11. package/dist/components/FileDiff.js +57 -30
  12. package/dist/components/FileDiff.js.map +1 -1
  13. package/dist/components/FileStream.js +9 -3
  14. package/dist/components/FileStream.js.map +1 -1
  15. package/dist/components/VirtualizedFile.d.ts +28 -5
  16. package/dist/components/VirtualizedFile.d.ts.map +1 -1
  17. package/dist/components/VirtualizedFile.js +225 -45
  18. package/dist/components/VirtualizedFile.js.map +1 -1
  19. package/dist/components/VirtualizedFileDiff.d.ts +28 -5
  20. package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
  21. package/dist/components/VirtualizedFileDiff.js +285 -49
  22. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  23. package/dist/components/Virtualizer.d.ts +6 -3
  24. package/dist/components/Virtualizer.d.ts.map +1 -1
  25. package/dist/components/Virtualizer.js +4 -6
  26. package/dist/components/Virtualizer.js.map +1 -1
  27. package/dist/components/VirtulizerDevelopment.d.ts +2 -2
  28. package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
  29. package/dist/constants.d.ts +6 -2
  30. package/dist/constants.d.ts.map +1 -1
  31. package/dist/constants.js +17 -2
  32. package/dist/constants.js.map +1 -1
  33. package/dist/index.d.ts +6 -5
  34. package/dist/index.js +11 -10
  35. package/dist/managers/InteractionManager.d.ts +11 -7
  36. package/dist/managers/InteractionManager.d.ts.map +1 -1
  37. package/dist/managers/InteractionManager.js +38 -25
  38. package/dist/managers/InteractionManager.js.map +1 -1
  39. package/dist/managers/ResizeManager.d.ts +4 -4
  40. package/dist/managers/ResizeManager.d.ts.map +1 -1
  41. package/dist/managers/ResizeManager.js +89 -54
  42. package/dist/managers/ResizeManager.js.map +1 -1
  43. package/dist/managers/UniversalRenderingManager.d.ts +2 -1
  44. package/dist/managers/UniversalRenderingManager.d.ts.map +1 -1
  45. package/dist/managers/UniversalRenderingManager.js +13 -16
  46. package/dist/managers/UniversalRenderingManager.js.map +1 -1
  47. package/dist/react/CodeView.d.ts +45 -0
  48. package/dist/react/CodeView.d.ts.map +1 -0
  49. package/dist/react/CodeView.js +241 -0
  50. package/dist/react/CodeView.js.map +1 -0
  51. package/dist/react/File.d.ts +0 -1
  52. package/dist/react/File.d.ts.map +1 -1
  53. package/dist/react/File.js +2 -3
  54. package/dist/react/File.js.map +1 -1
  55. package/dist/react/FileDiff.d.ts +0 -1
  56. package/dist/react/FileDiff.d.ts.map +1 -1
  57. package/dist/react/FileDiff.js +3 -4
  58. package/dist/react/FileDiff.js.map +1 -1
  59. package/dist/react/MultiFileDiff.d.ts +0 -1
  60. package/dist/react/MultiFileDiff.d.ts.map +1 -1
  61. package/dist/react/MultiFileDiff.js +3 -4
  62. package/dist/react/MultiFileDiff.js.map +1 -1
  63. package/dist/react/PatchDiff.d.ts +0 -1
  64. package/dist/react/PatchDiff.d.ts.map +1 -1
  65. package/dist/react/PatchDiff.js +3 -4
  66. package/dist/react/PatchDiff.js.map +1 -1
  67. package/dist/react/UnresolvedFile.d.ts +0 -1
  68. package/dist/react/UnresolvedFile.d.ts.map +1 -1
  69. package/dist/react/UnresolvedFile.js +3 -4
  70. package/dist/react/UnresolvedFile.js.map +1 -1
  71. package/dist/react/index.d.ts +3 -2
  72. package/dist/react/index.js +5 -4
  73. package/dist/react/jsx.d.ts.map +1 -1
  74. package/dist/react/types.d.ts +0 -8
  75. package/dist/react/types.d.ts.map +1 -1
  76. package/dist/react/utils/renderDiffChildren.d.ts +0 -2
  77. package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
  78. package/dist/react/utils/renderDiffChildren.js +3 -4
  79. package/dist/react/utils/renderDiffChildren.js.map +1 -1
  80. package/dist/react/utils/renderFileChildren.d.ts +0 -2
  81. package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
  82. package/dist/react/utils/renderFileChildren.js +3 -4
  83. package/dist/react/utils/renderFileChildren.js.map +1 -1
  84. package/dist/react/utils/useFileDiffInstance.js +12 -7
  85. package/dist/react/utils/useFileDiffInstance.js.map +1 -1
  86. package/dist/react/utils/useFileInstance.js +12 -7
  87. package/dist/react/utils/useFileInstance.js.map +1 -1
  88. package/dist/react/utils/useUnresolvedFileInstance.js +6 -2
  89. package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
  90. package/dist/renderers/DiffHunksRenderer.d.ts +2 -1
  91. package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
  92. package/dist/renderers/DiffHunksRenderer.js +35 -20
  93. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  94. package/dist/renderers/FileRenderer.d.ts +2 -1
  95. package/dist/renderers/FileRenderer.d.ts.map +1 -1
  96. package/dist/renderers/FileRenderer.js +34 -20
  97. package/dist/renderers/FileRenderer.js.map +1 -1
  98. package/dist/ssr/index.d.ts +2 -2
  99. package/dist/ssr/preloadDiffs.js +1 -1
  100. package/dist/style.js +1 -1
  101. package/dist/style.js.map +1 -1
  102. package/dist/types.d.ts +98 -3
  103. package/dist/types.d.ts.map +1 -1
  104. package/dist/utils/areManagedSnapshotsEqual.d.ts +7 -0
  105. package/dist/utils/areManagedSnapshotsEqual.d.ts.map +1 -0
  106. package/dist/utils/areManagedSnapshotsEqual.js +15 -0
  107. package/dist/utils/areManagedSnapshotsEqual.js.map +1 -0
  108. package/dist/utils/areOptionsEqual.d.ts +2 -1
  109. package/dist/utils/areOptionsEqual.d.ts.map +1 -1
  110. package/dist/utils/areOptionsEqual.js +1 -1
  111. package/dist/utils/areOptionsEqual.js.map +1 -1
  112. package/dist/utils/createFileHeaderElement.d.ts +3 -1
  113. package/dist/utils/createFileHeaderElement.d.ts.map +1 -1
  114. package/dist/utils/createFileHeaderElement.js +3 -2
  115. package/dist/utils/createFileHeaderElement.js.map +1 -1
  116. package/dist/utils/createWindowFromScrollPosition.d.ts +3 -3
  117. package/dist/utils/createWindowFromScrollPosition.d.ts.map +1 -1
  118. package/dist/utils/createWindowFromScrollPosition.js +6 -6
  119. package/dist/utils/createWindowFromScrollPosition.js.map +1 -1
  120. package/dist/utils/iterateOverDiff.d.ts +2 -1
  121. package/dist/utils/iterateOverDiff.d.ts.map +1 -1
  122. package/dist/utils/iterateOverDiff.js +135 -7
  123. package/dist/utils/iterateOverDiff.js.map +1 -1
  124. package/dist/utils/parsePatchFiles.js +2 -2
  125. package/dist/utils/parsePatchFiles.js.map +1 -1
  126. package/dist/utils/renderFileWithHighlighter.js +1 -1
  127. package/dist/utils/resolveVirtualFileMetrics.d.ts +4 -1
  128. package/dist/utils/resolveVirtualFileMetrics.d.ts.map +1 -1
  129. package/dist/utils/resolveVirtualFileMetrics.js +11 -1
  130. package/dist/utils/resolveVirtualFileMetrics.js.map +1 -1
  131. package/dist/utils/roundToDevicePixel.d.ts +14 -0
  132. package/dist/utils/roundToDevicePixel.d.ts.map +1 -0
  133. package/dist/utils/roundToDevicePixel.js +18 -0
  134. package/dist/utils/roundToDevicePixel.js.map +1 -0
  135. package/dist/worker/worker-portable.js +195 -14
  136. package/dist/worker/worker-portable.js.map +1 -1
  137. package/dist/worker/worker.js +146 -7
  138. package/dist/worker/worker.js.map +1 -1
  139. package/package.json +10 -1
  140. package/dist/components/AdvancedVirtualizedFileDiff.d.ts +0 -40
  141. package/dist/components/AdvancedVirtualizedFileDiff.d.ts.map +0 -1
  142. package/dist/components/AdvancedVirtualizedFileDiff.js +0 -140
  143. package/dist/components/AdvancedVirtualizedFileDiff.js.map +0 -1
  144. package/dist/components/AdvancedVirtualizer.d.ts +0 -38
  145. package/dist/components/AdvancedVirtualizer.d.ts.map +0 -1
  146. package/dist/components/AdvancedVirtualizer.js +0 -201
  147. package/dist/components/AdvancedVirtualizer.js.map +0 -1
@@ -2,13 +2,13 @@
2
2
 
3
3
 
4
4
  import { DIFFS_TAG_NAME } from "../constants.js";
5
- import { templateRender } from "./utils/templateRender.js";
6
5
  import { renderDiffChildren } from "./utils/renderDiffChildren.js";
6
+ import { templateRender } from "./utils/templateRender.js";
7
7
  import { useUnresolvedFileInstance } from "./utils/useUnresolvedFileInstance.js";
8
8
  import { jsx } from "react/jsx-runtime";
9
9
 
10
10
  //#region src/react/UnresolvedFile.tsx
11
- function UnresolvedFile({ file, options, lineAnnotations, selectedLines, className, style, prerenderedHTML, renderAnnotation, renderCustomHeader, renderHeaderPrefix, renderHeaderMetadata, renderGutterUtility, renderHoverUtility, renderMergeConflictUtility, disableWorkerPool = false }) {
11
+ function UnresolvedFile({ file, options, lineAnnotations, selectedLines, className, style, prerenderedHTML, renderAnnotation, renderCustomHeader, renderHeaderPrefix, renderHeaderMetadata, renderGutterUtility, renderMergeConflictUtility, disableWorkerPool = false }) {
12
12
  const { ref, getHoveredLine, fileDiff, actions, getInstance } = useUnresolvedFileInstance({
13
13
  file,
14
14
  options,
@@ -16,7 +16,7 @@ function UnresolvedFile({ file, options, lineAnnotations, selectedLines, classNa
16
16
  selectedLines,
17
17
  prerenderedHTML,
18
18
  hasConflictUtility: renderMergeConflictUtility != null,
19
- hasGutterRenderUtility: renderGutterUtility != null || renderHoverUtility != null,
19
+ hasGutterRenderUtility: renderGutterUtility != null,
20
20
  hasCustomHeader: renderCustomHeader != null,
21
21
  disableWorkerPool
22
22
  });
@@ -31,7 +31,6 @@ function UnresolvedFile({ file, options, lineAnnotations, selectedLines, classNa
31
31
  renderHeaderMetadata,
32
32
  renderAnnotation,
33
33
  renderGutterUtility,
34
- renderHoverUtility,
35
34
  lineAnnotations,
36
35
  getHoveredLine,
37
36
  actions,
@@ -1 +1 @@
1
- {"version":3,"file":"UnresolvedFile.js","names":[],"sources":["../../src/react/UnresolvedFile.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\n\nimport type { FileDiffOptions } from '../components/FileDiff';\nimport type { UnresolvedFile as UnresolvedFileClass } from '../components/UnresolvedFile';\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { UnresolvedFileHunksRendererOptions } from '../renderers/UnresolvedFileHunksRenderer';\nimport type {\n FileContents,\n HunkSeparators,\n MergeConflictResolution,\n} from '../types';\nimport { type MergeConflictDiffAction } from '../utils/parseMergeConflictDiffFromFile';\nimport type { FileDiffProps } from './FileDiff';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useUnresolvedFileInstance } from './utils/useUnresolvedFileInstance';\n\nexport interface RenderMergeConflictActionContext {\n resolveConflict(resolution: MergeConflictResolution): void;\n}\n\nexport type RenderMergeConflictActions = (\n action: MergeConflictDiffAction,\n context: RenderMergeConflictActionContext\n) => ReactNode;\n\nexport type MergeConflictActionsTypeOption =\n | 'none'\n | 'default'\n | RenderMergeConflictActions;\n\nexport interface UnresolvedFileReactOptions<LAnnotation>\n extends\n Omit<\n FileDiffOptions<LAnnotation>,\n 'hunkSeparators' | 'diffStyle' | 'onMergeConflictAction' | 'onPostRender'\n >,\n UnresolvedFileHunksRendererOptions {\n hunkSeparators?: HunkSeparators;\n onPostRender?(\n node: HTMLElement,\n instance: UnresolvedFileClass<LAnnotation>\n ): unknown;\n maxContextLines?: number;\n}\n\nexport interface UnresolvedFileProps<LAnnotation> extends Omit<\n FileDiffProps<LAnnotation>,\n 'fileDiff' | 'options'\n> {\n file: FileContents;\n options?: UnresolvedFileReactOptions<LAnnotation>;\n renderMergeConflictUtility?(\n action: MergeConflictDiffAction,\n getInstance: () => UnresolvedFileClass<LAnnotation> | undefined\n ): ReactNode;\n disableWorkerPool?: boolean;\n}\n\nexport function UnresolvedFile<LAnnotation = undefined>({\n file,\n options,\n lineAnnotations,\n selectedLines,\n className,\n style,\n prerenderedHTML,\n renderAnnotation,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderGutterUtility,\n renderHoverUtility,\n renderMergeConflictUtility,\n disableWorkerPool = false,\n}: UnresolvedFileProps<LAnnotation>): React.JSX.Element {\n const { ref, getHoveredLine, fileDiff, actions, getInstance } =\n useUnresolvedFileInstance({\n file,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n hasConflictUtility: renderMergeConflictUtility != null,\n hasGutterRenderUtility:\n renderGutterUtility != null || renderHoverUtility != null,\n hasCustomHeader: renderCustomHeader != null,\n disableWorkerPool,\n });\n const children = renderDiffChildren({\n fileDiff,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n renderHoverUtility,\n lineAnnotations,\n getHoveredLine,\n actions,\n renderMergeConflictUtility,\n getInstance,\n });\n return (\n <DIFFS_TAG_NAME ref={ref} className={className} style={style}>\n {templateRender(children, prerenderedHTML)}\n </DIFFS_TAG_NAME>\n );\n}\n"],"mappings":";;;;;;;;;;AA6DA,SAAgB,eAAwC,EACtD,MACA,SACA,iBACA,eACA,WACA,OACA,iBACA,kBACA,oBACA,oBACA,sBACA,qBACA,oBACA,4BACA,oBAAoB,SACkC;CACtD,MAAM,EAAE,KAAK,gBAAgB,UAAU,SAAS,gBAC9C,0BAA0B;EACxB;EACA;EACA;EACA;EACA;EACA,oBAAoB,8BAA8B;EAClD,wBACE,uBAAuB,QAAQ,sBAAsB;EACvD,iBAAiB,sBAAsB;EACvC;EACD,CAAC;AAeJ,QACE,oBAAC;EAAoB;EAAgB;EAAkB;YACpD,eAhBY,mBAAmB;GAClC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,EAG4B,gBAAgB;GAC3B"}
1
+ {"version":3,"file":"UnresolvedFile.js","names":[],"sources":["../../src/react/UnresolvedFile.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\n\nimport type { FileDiffOptions } from '../components/FileDiff';\nimport type { UnresolvedFile as UnresolvedFileClass } from '../components/UnresolvedFile';\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { UnresolvedFileHunksRendererOptions } from '../renderers/UnresolvedFileHunksRenderer';\nimport type {\n FileContents,\n HunkSeparators,\n MergeConflictResolution,\n} from '../types';\nimport { type MergeConflictDiffAction } from '../utils/parseMergeConflictDiffFromFile';\nimport type { FileDiffProps } from './FileDiff';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useUnresolvedFileInstance } from './utils/useUnresolvedFileInstance';\n\nexport interface RenderMergeConflictActionContext {\n resolveConflict(resolution: MergeConflictResolution): void;\n}\n\nexport type RenderMergeConflictActions = (\n action: MergeConflictDiffAction,\n context: RenderMergeConflictActionContext\n) => ReactNode;\n\nexport type MergeConflictActionsTypeOption =\n | 'none'\n | 'default'\n | RenderMergeConflictActions;\n\nexport interface UnresolvedFileReactOptions<LAnnotation>\n extends\n Omit<\n FileDiffOptions<LAnnotation>,\n 'hunkSeparators' | 'diffStyle' | 'onMergeConflictAction' | 'onPostRender'\n >,\n UnresolvedFileHunksRendererOptions {\n hunkSeparators?: HunkSeparators;\n onPostRender?(\n node: HTMLElement,\n instance: UnresolvedFileClass<LAnnotation>\n ): unknown;\n maxContextLines?: number;\n}\n\nexport interface UnresolvedFileProps<LAnnotation> extends Omit<\n FileDiffProps<LAnnotation>,\n 'fileDiff' | 'options'\n> {\n file: FileContents;\n options?: UnresolvedFileReactOptions<LAnnotation>;\n renderMergeConflictUtility?(\n action: MergeConflictDiffAction,\n getInstance: () => UnresolvedFileClass<LAnnotation> | undefined\n ): ReactNode;\n disableWorkerPool?: boolean;\n}\n\nexport function UnresolvedFile<LAnnotation = undefined>({\n file,\n options,\n lineAnnotations,\n selectedLines,\n className,\n style,\n prerenderedHTML,\n renderAnnotation,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderGutterUtility,\n renderMergeConflictUtility,\n disableWorkerPool = false,\n}: UnresolvedFileProps<LAnnotation>): React.JSX.Element {\n const { ref, getHoveredLine, fileDiff, actions, getInstance } =\n useUnresolvedFileInstance({\n file,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n hasConflictUtility: renderMergeConflictUtility != null,\n hasGutterRenderUtility: renderGutterUtility != null,\n hasCustomHeader: renderCustomHeader != null,\n disableWorkerPool,\n });\n const children = renderDiffChildren({\n fileDiff,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n lineAnnotations,\n getHoveredLine,\n actions,\n renderMergeConflictUtility,\n getInstance,\n });\n return (\n <DIFFS_TAG_NAME ref={ref} className={className} style={style}>\n {templateRender(children, prerenderedHTML)}\n </DIFFS_TAG_NAME>\n );\n}\n"],"mappings":";;;;;;;;;;AA6DA,SAAgB,eAAwC,EACtD,MACA,SACA,iBACA,eACA,WACA,OACA,iBACA,kBACA,oBACA,oBACA,sBACA,qBACA,4BACA,oBAAoB,SACkC;CACtD,MAAM,EAAE,KAAK,gBAAgB,UAAU,SAAS,gBAC9C,0BAA0B;EACxB;EACA;EACA;EACA;EACA;EACA,oBAAoB,8BAA8B;EAClD,wBAAwB,uBAAuB;EAC/C,iBAAiB,sBAAsB;EACvC;EACD,CAAC;AAcJ,QACE,oBAAC;EAAoB;EAAgB;EAAkB;YACpD,eAfY,mBAAmB;GAClC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,EAG4B,gBAAgB;GAC3B"}
@@ -1,6 +1,7 @@
1
- import { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, ConflictResolverTypes, ContextContent, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, 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, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, 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, CodeViewItemVersion, CodeViewLineScrollTarget, CodeViewMetrics, CodeViewPositionScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, 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";
2
2
  import { WorkerInitializationRenderOptions, WorkerPoolOptions } from "../worker/types.js";
3
3
  import { FileOptions } from "../components/File.js";
4
+ import { CodeView, CodeViewHandle, CodeViewProps, ControlledCodeViewProps, UncontrolledCodeViewProps } from "./CodeView.js";
4
5
  import { DiffBasePropsReact, FileProps } from "./types.js";
5
6
  import { File } from "./File.js";
6
7
  import { FileDiff, FileDiffProps } from "./FileDiff.js";
@@ -16,4 +17,4 @@ import { templateRender } from "./utils/templateRender.js";
16
17
  import { useFileDiffInstance } from "./utils/useFileDiffInstance.js";
17
18
  import { useFileInstance } from "./utils/useFileInstance.js";
18
19
  import { useStableCallback } from "./utils/useStableCallback.js";
19
- export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, ConflictResolverTypes, ContextContent, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffBasePropsReact, 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, 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, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, 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, CodeViewItemVersion, CodeViewLineScrollTarget, CodeViewMetrics, CodeViewPositionScrollTarget, CodeViewProps, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, ControlledCodeViewProps, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffBasePropsReact, 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 };
@@ -1,16 +1,17 @@
1
1
  import { GutterUtilitySlotStyles, MergeConflictSlotStyles, noopRender } from "./constants.js";
2
+ import { renderDiffChildren } from "./utils/renderDiffChildren.js";
2
3
  import { renderFileChildren } from "./utils/renderFileChildren.js";
4
+ import { useStableCallback } from "./utils/useStableCallback.js";
5
+ import { WorkerPoolContext, WorkerPoolContextProvider, useWorkerPool } from "./WorkerPoolContext.js";
6
+ import { CodeView } from "./CodeView.js";
3
7
  import { templateRender } from "./utils/templateRender.js";
4
8
  import { Virtualizer, VirtualizerContext, useVirtualizer } from "./Virtualizer.js";
5
- import { WorkerPoolContext, WorkerPoolContextProvider, useWorkerPool } from "./WorkerPoolContext.js";
6
- import { useStableCallback } from "./utils/useStableCallback.js";
7
9
  import { useFileInstance } from "./utils/useFileInstance.js";
8
10
  import { File } from "./File.js";
9
- import { renderDiffChildren } from "./utils/renderDiffChildren.js";
10
11
  import { useFileDiffInstance } from "./utils/useFileDiffInstance.js";
11
12
  import { FileDiff } from "./FileDiff.js";
12
13
  import { MultiFileDiff } from "./MultiFileDiff.js";
13
14
  import { PatchDiff } from "./PatchDiff.js";
14
15
  import { UnresolvedFile } from "./UnresolvedFile.js";
15
16
 
16
- export { File, FileDiff, GutterUtilitySlotStyles, MergeConflictSlotStyles, MultiFileDiff, PatchDiff, UnresolvedFile, Virtualizer, VirtualizerContext, WorkerPoolContext, WorkerPoolContextProvider, noopRender, renderDiffChildren, renderFileChildren, templateRender, useFileDiffInstance, useFileInstance, useStableCallback, useVirtualizer, useWorkerPool };
17
+ export { CodeView, File, FileDiff, GutterUtilitySlotStyles, MergeConflictSlotStyles, MultiFileDiff, PatchDiff, UnresolvedFile, Virtualizer, VirtualizerContext, WorkerPoolContext, WorkerPoolContextProvider, noopRender, renderDiffChildren, renderFileChildren, templateRender, useFileDiffInstance, useFileInstance, useStableCallback, useVirtualizer, useWorkerPool };
@@ -1 +1 @@
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
+ {"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"}
@@ -15,10 +15,6 @@ interface DiffBasePropsReact<LAnnotation> {
15
15
  renderHeaderPrefix?(fileDiff: FileDiffMetadata): ReactNode;
16
16
  renderHeaderMetadata?(fileDiff: FileDiffMetadata): ReactNode;
17
17
  renderGutterUtility?(getHoveredLine: () => GetHoveredLineResult<'diff'> | undefined): ReactNode;
18
- /**
19
- * @deprecated Use `renderGutterUtility` instead.
20
- */
21
- renderHoverUtility?(getHoveredLine: () => GetHoveredLineResult<'diff'> | undefined): ReactNode;
22
18
  className?: string;
23
19
  style?: CSSProperties;
24
20
  prerenderedHTML?: string;
@@ -34,10 +30,6 @@ interface FileProps<LAnnotation> {
34
30
  renderHeaderPrefix?(file: FileContents): ReactNode;
35
31
  renderHeaderMetadata?(file: FileContents): ReactNode;
36
32
  renderGutterUtility?(getHoveredLine: () => GetHoveredLineResult<'file'> | undefined): ReactNode;
37
- /**
38
- * @deprecated Use `renderGutterUtility` instead.
39
- */
40
- renderHoverUtility?(getHoveredLine: () => GetHoveredLineResult<'file'> | undefined): ReactNode;
41
33
  className?: string;
42
34
  style?: CSSProperties;
43
35
  prerenderedHTML?: string;
@@ -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 /**\n * @deprecated Use `renderGutterUtility` instead.\n */\n renderHoverUtility?(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 /**\n * @deprecated Use `renderGutterUtility` instead.\n */\n renderHoverUtility?(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,EAGPJ,gBAHOI,CAAAA,EAGYX,SAHZW;EAAnBN,kBAAAA,EAAAA,QAAAA,EAIYE,gBAJZF,CAAAA,EAI+BL,SAJ/BK;EACFD,oBAAAA,EAAAA,QAAAA,EAIgBG,gBAJhBH,CAAAA,EAImCJ,SAJnCI;EACkCO,mBAAAA,EAAAA,cAAAA,EAAAA,GAAAA,GAIPR,oBAJOQ,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA,CAAAA,EAIoCX,SAJpCW;EAAnBN;;;EACkBL,kBAAAA,EAAAA,cAAAA,EAAAA,GAAAA,GAOPG,oBAPOH,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA,CAAAA,EAOoCA,SAPpCA;EACnBO,SAAAA,CAAAA,EAAAA,MAAAA;EAAmBP,KAAAA,CAAAA,EAQzCD,aARyCC;EACjBO,eAAAA,CAAAA,EAAAA,MAAAA;;AACWJ,UAS9BS,SAT8BT,CAAAA,WAAAA,CAAAA,CAAAA;EAA2CH,IAAAA,EAUhFM,YAVgFN;EAI5CG,OAAAA,CAAAA,EAOhCF,WAPgCE,CAOpBQ,WAPoBR,CAAAA;EAA2CH,OAAAA,CAAAA,EAQ3ES,kBAR2ET;EAE7ED,eAAAA,CAAAA,EAOUS,cAPVT,CAOyBY,WAPzBZ,CAAAA,EAAAA;EAAa,aAAA,CAAA,EAQLK,iBARK,GAAA,IAAA;EAGRQ,gBAAS,EAAA,WAAAD,EAMSH,cANT,CAMwBG,WANxB,CAAA,CAAA,EAMuCX,SANvC;EAChBM,kBAAAA,EAAAA,IAAAA,EAMoBA,YANpBA,CAAAA,EAMmCN,SANnCM;EACgBK,kBAAAA,EAAAA,IAAAA,EAMIL,YANJK,CAAAA,EAMmBX,SANnBW;EAAZV,oBAAAA,EAAAA,IAAAA,EAOkBK,YAPlBL,CAAAA,EAOiCD,SAPjCC;EACAQ,mBAAAA,EAAAA,cAAAA,EAAAA,GAAAA,GAOiCN,oBAPjCM,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA,CAAAA,EAO4ET,SAP5ES;EACuBE;;;EAEaA,kBAAAA,EAAAA,cAAAA,EAAAA,GAAAA,GAQJR,oBARIQ,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA,CAAAA,EAQuCX,SARvCW;EAAfH,SAAAA,CAAAA,EAAAA,MAAAA;EAA8BR,KAAAA,CAAAA,EAUrDD,aAVqDC;EACnCM,eAAAA,CAAAA,EAAAA,MAAAA;EAAeN,iBAAAA,CAAAA,EAAAA,OAAAA"}
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,EAGPJ,gBAHOI,CAAAA,EAGYX,SAHZW;EAAnBN,kBAAAA,EAAAA,QAAAA,EAIYE,gBAJZF,CAAAA,EAI+BL,SAJ/BK;EACFD,oBAAAA,EAAAA,QAAAA,EAIgBG,gBAJhBH,CAAAA,EAImCJ,SAJnCI;EACkCO,mBAAAA,EAAAA,cAAAA,EAAAA,GAAAA,GAIPR,oBAJOQ,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA,CAAAA,EAIoCX,SAJpCW;EAAnBN,SAAAA,CAAAA,EAAAA,MAAAA;EAAkCL,KAAAA,CAAAA,EAMzDD,aANyDC;EACnCO,eAAAA,CAAAA,EAAAA,MAAAA;;AACAA,UAOjBK,SAPiBL,CAAAA,WAAAA,CAAAA,CAAAA;EAAmBP,IAAAA,EAQ3CM,YAR2CN;EACjBO,OAAAA,CAAAA,EAQtBN,WARsBM,CAQVI,WARUJ,CAAAA;EAAmBP,OAAAA,CAAAA,EASzCS,kBATyCT;EACRG,eAAAA,CAAAA,EASzBK,cATyBL,CASVQ,WATUR,CAAAA,EAAAA;EAA2CH,aAAAA,CAAAA,EAUtEI,iBAVsEJ,GAAAA,IAAAA;EAE9ED,gBAAAA,EAAAA,WAAAA,EASuBS,cATvBT,CASsCY,WATtCZ,CAAAA,CAAAA,EASqDC,SATrDD;EAAa,kBAAA,EAAA,IAAA,EAUKO,YAVL,CAAA,EAUoBN,SAVpB;EAGRY,kBAAS,EAAAD,IAAAA,EAQIL,YARJ,CAAA,EAQmBN,SARnB;EAChBM,oBAAAA,EAAAA,IAAAA,EAQsBA,YARtBA,CAAAA,EAQqCN,SARrCM;EACgBK,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;EAAfH,iBAAAA,CAAAA,EAAAA,OAAAA"}
@@ -13,7 +13,6 @@ interface RenderDiffChildrenProps<LAnnotation, T> {
13
13
  renderHeaderMetadata: DiffBasePropsReact<LAnnotation>['renderHeaderMetadata'];
14
14
  renderAnnotation: DiffBasePropsReact<LAnnotation>['renderAnnotation'];
15
15
  renderGutterUtility: DiffBasePropsReact<LAnnotation>['renderGutterUtility'];
16
- renderHoverUtility: DiffBasePropsReact<LAnnotation>['renderHoverUtility'];
17
16
  renderMergeConflictUtility?(action: MergeConflictDiffAction, getInstance: () => T | undefined): ReactNode;
18
17
  lineAnnotations: DiffBasePropsReact<LAnnotation>['lineAnnotations'];
19
18
  getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;
@@ -27,7 +26,6 @@ declare function renderDiffChildren<LAnnotation, T>({
27
26
  renderHeaderMetadata,
28
27
  renderAnnotation,
29
28
  renderGutterUtility,
30
- renderHoverUtility,
31
29
  renderMergeConflictUtility,
32
30
  lineAnnotations,
33
31
  getHoveredLine,
@@ -1 +1 @@
1
- {"version":3,"file":"renderDiffChildren.d.ts","names":["ReactNode","GetHoveredLineResult","FileDiffMetadata","MergeConflictDiffAction","DiffBasePropsReact","RenderDiffChildrenProps","LAnnotation","T","renderDiffChildren","fileDiff","actions","renderCustomHeader","renderHeaderPrefix","renderHeaderMetadata","renderAnnotation","renderGutterUtility","renderHoverUtility","renderMergeConflictUtility","lineAnnotations","getHoveredLine","getInstance"],"sources":["../../../src/react/utils/renderDiffChildren.d.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileDiffMetadata } from '../../types';\nimport { type MergeConflictDiffAction } from '../../utils/parseMergeConflictDiffFromFile';\nimport type { DiffBasePropsReact } from '../types';\ninterface RenderDiffChildrenProps<LAnnotation, T> {\n fileDiff: FileDiffMetadata;\n actions?: (MergeConflictDiffAction | undefined)[];\n renderCustomHeader: DiffBasePropsReact<LAnnotation>['renderCustomHeader'];\n renderHeaderPrefix: DiffBasePropsReact<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: DiffBasePropsReact<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: DiffBasePropsReact<LAnnotation>['renderAnnotation'];\n renderGutterUtility: DiffBasePropsReact<LAnnotation>['renderGutterUtility'];\n renderHoverUtility: DiffBasePropsReact<LAnnotation>['renderHoverUtility'];\n renderMergeConflictUtility?(action: MergeConflictDiffAction, getInstance: () => T | undefined): ReactNode;\n lineAnnotations: DiffBasePropsReact<LAnnotation>['lineAnnotations'];\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance?(): T | undefined;\n}\nexport declare function renderDiffChildren<LAnnotation, T>({ fileDiff, actions, renderCustomHeader, renderHeaderPrefix, renderHeaderMetadata, renderAnnotation, renderGutterUtility, renderHoverUtility, renderMergeConflictUtility, lineAnnotations, getHoveredLine, getInstance }: RenderDiffChildrenProps<LAnnotation, T>): ReactNode;\nexport {};\n//# sourceMappingURL=renderDiffChildren.d.ts.map"],"mappings":";;;;;;;UAKUK;YACIH;EADJG,OAAAA,CAAAA,EAAAA,CAEKF,uBAFkBG,GAAAA,SAAAC,CAAAA,EAAAA;EACnBL,kBAAAA,EAEUE,kBAFVF,CAE6BI,WAF7BJ,CAAAA,CAAAA,oBAAAA,CAAAA;EACCC,kBAAAA,EAESC,kBAFTD,CAE4BG,WAF5BH,CAAAA,CAAAA,oBAAAA,CAAAA;EAC4BG,oBAAAA,EAEjBF,kBAFiBE,CAEEA,WAFFA,CAAAA,CAAAA,sBAAAA,CAAAA;EAAnBF,gBAAAA,EAGFA,kBAHEA,CAGiBE,WAHjBF,CAAAA,CAAAA,kBAAAA,CAAAA;EACmBE,mBAAAA,EAGlBF,kBAHkBE,CAGCA,WAHDA,CAAAA,CAAAA,qBAAAA,CAAAA;EAAnBF,kBAAAA,EAIAA,kBAJAA,CAImBE,WAJnBF,CAAAA,CAAAA,oBAAAA,CAAAA;EACqBE,0BAAAA,EAAAA,MAAAA,EAILH,uBAJKG,EAAAA,WAAAA,EAAAA,GAAAA,GAIuCC,CAJvCD,GAAAA,SAAAA,CAAAA,EAIuDN,SAJvDM;EAAnBF,eAAAA,EAKLA,kBALKA,CAKcE,WALdF,CAAAA,CAAAA,iBAAAA,CAAAA;EACeE,cAAAA,EAAAA,EAKnBL,oBALmBK,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;EAAnBF,WAAAA,GAAAA,EAMFG,CANEH,GAAAA,SAAAA;;AACGA,iBAODI,kBAPCJ,CAAAA,WAAAA,EAAAA,CAAAA,CAAAA,CAAAA;EAAAA,QAAAA;EAAAA,OAAAA;EAAAA,kBAAAA;EAAAA,kBAAAA;EAAAA,oBAAAA;EAAAA,gBAAAA;EAAAA,mBAAAA;EAAAA,kBAAAA;EAAAA,0BAAAA;EAAAA,eAAAA;EAAAA,cAAAA;EAAAA;AAAAA,CAAAA,EAO4PC,uBAP5PD,CAOoRE,WAPpRF,EAOiSG,CAPjSH,CAAAA,CAAAA,EAOsSJ,SAPtSI"}
1
+ {"version":3,"file":"renderDiffChildren.d.ts","names":["ReactNode","GetHoveredLineResult","FileDiffMetadata","MergeConflictDiffAction","DiffBasePropsReact","RenderDiffChildrenProps","LAnnotation","T","renderDiffChildren","fileDiff","actions","renderCustomHeader","renderHeaderPrefix","renderHeaderMetadata","renderAnnotation","renderGutterUtility","renderMergeConflictUtility","lineAnnotations","getHoveredLine","getInstance"],"sources":["../../../src/react/utils/renderDiffChildren.d.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileDiffMetadata } from '../../types';\nimport { type MergeConflictDiffAction } from '../../utils/parseMergeConflictDiffFromFile';\nimport type { DiffBasePropsReact } from '../types';\ninterface RenderDiffChildrenProps<LAnnotation, T> {\n fileDiff: FileDiffMetadata;\n actions?: (MergeConflictDiffAction | undefined)[];\n renderCustomHeader: DiffBasePropsReact<LAnnotation>['renderCustomHeader'];\n renderHeaderPrefix: DiffBasePropsReact<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: DiffBasePropsReact<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: DiffBasePropsReact<LAnnotation>['renderAnnotation'];\n renderGutterUtility: DiffBasePropsReact<LAnnotation>['renderGutterUtility'];\n renderMergeConflictUtility?(action: MergeConflictDiffAction, getInstance: () => T | undefined): ReactNode;\n lineAnnotations: DiffBasePropsReact<LAnnotation>['lineAnnotations'];\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance?(): T | undefined;\n}\nexport declare function renderDiffChildren<LAnnotation, T>({ fileDiff, actions, renderCustomHeader, renderHeaderPrefix, renderHeaderMetadata, renderAnnotation, renderGutterUtility, renderMergeConflictUtility, lineAnnotations, getHoveredLine, getInstance }: RenderDiffChildrenProps<LAnnotation, T>): ReactNode;\nexport {};\n//# sourceMappingURL=renderDiffChildren.d.ts.map"],"mappings":";;;;;;;UAKUK;YACIH;EADJG,OAAAA,CAAAA,EAAAA,CAEKF,uBAFkBG,GAAAA,SAAAC,CAAAA,EAAAA;EACnBL,kBAAAA,EAEUE,kBAFVF,CAE6BI,WAF7BJ,CAAAA,CAAAA,oBAAAA,CAAAA;EACCC,kBAAAA,EAESC,kBAFTD,CAE4BG,WAF5BH,CAAAA,CAAAA,oBAAAA,CAAAA;EAC4BG,oBAAAA,EAEjBF,kBAFiBE,CAEEA,WAFFA,CAAAA,CAAAA,sBAAAA,CAAAA;EAAnBF,gBAAAA,EAGFA,kBAHEA,CAGiBE,WAHjBF,CAAAA,CAAAA,kBAAAA,CAAAA;EACmBE,mBAAAA,EAGlBF,kBAHkBE,CAGCA,WAHDA,CAAAA,CAAAA,qBAAAA,CAAAA;EAAnBF,0BAAAA,EAAAA,MAAAA,EAIgBD,uBAJhBC,EAAAA,WAAAA,EAAAA,GAAAA,GAI4DG,CAJ5DH,GAAAA,SAAAA,CAAAA,EAI4EJ,SAJ5EI;EACqBE,eAAAA,EAIxBF,kBAJwBE,CAILA,WAJKA,CAAAA,CAAAA,iBAAAA,CAAAA;EAAnBF,cAAAA,EAAAA,EAKJH,oBALIG,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;EACeE,WAAAA,GAAAA,EAKrBC,CALqBD,GAAAA,SAAAA;;AACGA,iBAMpBE,kBANoBF,CAAAA,WAAAA,EAAAA,CAAAA,CAAAA,CAAAA;EAAAA,QAAAA;EAAAA,OAAAA;EAAAA,kBAAAA;EAAAA,kBAAAA;EAAAA,oBAAAA;EAAAA,gBAAAA;EAAAA,mBAAAA;EAAAA,0BAAAA;EAAAA,eAAAA;EAAAA,cAAAA;EAAAA;AAAAA,CAAAA,EAMqND,uBANrNC,CAM6OA,WAN7OA,EAM0PC,CAN1PD,CAAAA,CAAAA,EAM+PN,SAN/PM"}
@@ -6,8 +6,7 @@ import { GutterUtilitySlotStyles, MergeConflictSlotStyles } from "../constants.j
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
7
 
8
8
  //#region src/react/utils/renderDiffChildren.tsx
9
- function renderDiffChildren({ fileDiff, actions, renderCustomHeader, renderHeaderPrefix, renderHeaderMetadata, renderAnnotation, renderGutterUtility, renderHoverUtility, renderMergeConflictUtility, lineAnnotations, getHoveredLine, getInstance }) {
10
- const gutterUtility = renderGutterUtility ?? renderHoverUtility;
9
+ function renderDiffChildren({ fileDiff, actions, renderCustomHeader, renderHeaderPrefix, renderHeaderMetadata, renderAnnotation, renderGutterUtility, renderMergeConflictUtility, lineAnnotations, getHoveredLine, getInstance }) {
11
10
  const customHeader = renderCustomHeader?.(fileDiff);
12
11
  const prefix = renderHeaderPrefix?.(fileDiff);
13
12
  const metadata = renderHeaderMetadata?.(fileDiff);
@@ -35,10 +34,10 @@ function renderDiffChildren({ fileDiff, actions, renderCustomHeader, renderHeade
35
34
  children: renderMergeConflictUtility(action, getInstance)
36
35
  }, slot);
37
36
  }),
38
- gutterUtility != null && /* @__PURE__ */ jsx("div", {
37
+ renderGutterUtility != null && /* @__PURE__ */ jsx("div", {
39
38
  slot: "gutter-utility-slot",
40
39
  style: GutterUtilitySlotStyles,
41
- children: gutterUtility(getHoveredLine)
40
+ children: renderGutterUtility(getHoveredLine)
42
41
  })
43
42
  ] });
44
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"renderDiffChildren.js","names":[],"sources":["../../../src/react/utils/renderDiffChildren.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport {\n CUSTOM_HEADER_SLOT_ID,\n HEADER_METADATA_SLOT_ID,\n HEADER_PREFIX_SLOT_ID,\n} from '../../constants';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileDiffMetadata } from '../../types';\nimport { getLineAnnotationName } from '../../utils/getLineAnnotationName';\nimport { getMergeConflictActionSlotName } from '../../utils/getMergeConflictActionSlotName';\nimport {\n getMergeConflictActionAnchor,\n type MergeConflictDiffAction,\n} from '../../utils/parseMergeConflictDiffFromFile';\nimport { GutterUtilitySlotStyles, MergeConflictSlotStyles } from '../constants';\nimport type { DiffBasePropsReact } from '../types';\n\ninterface RenderDiffChildrenProps<LAnnotation, T> {\n fileDiff: FileDiffMetadata;\n actions?: (MergeConflictDiffAction | undefined)[];\n renderCustomHeader: DiffBasePropsReact<LAnnotation>['renderCustomHeader'];\n renderHeaderPrefix: DiffBasePropsReact<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: DiffBasePropsReact<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: DiffBasePropsReact<LAnnotation>['renderAnnotation'];\n renderGutterUtility: DiffBasePropsReact<LAnnotation>['renderGutterUtility'];\n renderHoverUtility: DiffBasePropsReact<LAnnotation>['renderHoverUtility'];\n renderMergeConflictUtility?(\n action: MergeConflictDiffAction,\n getInstance: () => T | undefined\n ): ReactNode;\n lineAnnotations: DiffBasePropsReact<LAnnotation>['lineAnnotations'];\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance?(): T | undefined;\n}\n\nexport function renderDiffChildren<LAnnotation, T>({\n fileDiff,\n actions,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n renderHoverUtility,\n renderMergeConflictUtility,\n lineAnnotations,\n getHoveredLine,\n getInstance,\n}: RenderDiffChildrenProps<LAnnotation, T>): ReactNode {\n const gutterUtility = renderGutterUtility ?? renderHoverUtility;\n const customHeader = renderCustomHeader?.(fileDiff);\n const prefix = renderHeaderPrefix?.(fileDiff);\n const metadata = renderHeaderMetadata?.(fileDiff);\n return (\n <>\n {customHeader != null ? (\n <div slot={CUSTOM_HEADER_SLOT_ID}>{customHeader}</div>\n ) : (\n <>\n {prefix != null && <div slot={HEADER_PREFIX_SLOT_ID}>{prefix}</div>}\n {metadata != null && (\n <div slot={HEADER_METADATA_SLOT_ID}>{metadata}</div>\n )}\n </>\n )}\n {renderAnnotation != null &&\n lineAnnotations?.map((annotation, index) => (\n <div key={index} slot={getLineAnnotationName(annotation)}>\n {renderAnnotation(annotation)}\n </div>\n ))}\n {actions != null &&\n renderMergeConflictUtility != null &&\n getInstance != null &&\n actions.map((action) => {\n if (action == null) {\n return undefined;\n }\n const slot = getSlotName(action, fileDiff);\n return (\n <div key={slot} slot={slot} style={MergeConflictSlotStyles}>\n {renderMergeConflictUtility(action, getInstance)}\n </div>\n );\n })}\n {gutterUtility != null && (\n <div slot=\"gutter-utility-slot\" style={GutterUtilitySlotStyles}>\n {gutterUtility(getHoveredLine)}\n </div>\n )}\n </>\n );\n}\n\nfunction getSlotName(\n action: MergeConflictDiffAction,\n fileDiff: FileDiffMetadata\n): string | undefined {\n const anchor = getMergeConflictActionAnchor(action, fileDiff);\n return anchor != null\n ? getMergeConflictActionSlotName({\n hunkIndex: anchor.hunkIndex,\n lineIndex: anchor.lineIndex,\n conflictIndex: action.conflictIndex,\n })\n : undefined;\n}\n"],"mappings":";;;;;;;;AAoCA,SAAgB,mBAAmC,EACjD,UACA,SACA,oBACA,oBACA,sBACA,kBACA,qBACA,oBACA,4BACA,iBACA,gBACA,eACqD;CACrD,MAAM,gBAAgB,uBAAuB;CAC7C,MAAM,eAAe,qBAAqB,SAAS;CACnD,MAAM,SAAS,qBAAqB,SAAS;CAC7C,MAAM,WAAW,uBAAuB,SAAS;AACjD,QACE;EACG,gBAAgB,OACf,oBAAC;GAAI,MAAM;aAAwB;IAAmB,GAEtD,4CACG,UAAU,QAAQ,oBAAC;GAAI,MAAM;aAAwB;IAAa,EAClE,YAAY,QACX,oBAAC;GAAI,MAAM;aAA0B;IAAe,IAErD;EAEJ,oBAAoB,QACnB,iBAAiB,KAAK,YAAY,UAChC,oBAAC;GAAgB,MAAM,sBAAsB,WAAW;aACrD,iBAAiB,WAAW;KADrB,MAEJ,CACN;EACH,WAAW,QACV,8BAA8B,QAC9B,eAAe,QACf,QAAQ,KAAK,WAAW;AACtB,OAAI,UAAU,KACZ;GAEF,MAAM,OAAO,YAAY,QAAQ,SAAS;AAC1C,UACE,oBAAC;IAAqB;IAAM,OAAO;cAChC,2BAA2B,QAAQ,YAAY;MADxC,KAEJ;IAER;EACH,iBAAiB,QAChB,oBAAC;GAAI,MAAK;GAAsB,OAAO;aACpC,cAAc,eAAe;IAC1B;KAEP;;AAIP,SAAS,YACP,QACA,UACoB;CACpB,MAAM,SAAS,6BAA6B,QAAQ,SAAS;AAC7D,QAAO,UAAU,OACb,+BAA+B;EAC7B,WAAW,OAAO;EAClB,WAAW,OAAO;EAClB,eAAe,OAAO;EACvB,CAAC,GACF"}
1
+ {"version":3,"file":"renderDiffChildren.js","names":[],"sources":["../../../src/react/utils/renderDiffChildren.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport {\n CUSTOM_HEADER_SLOT_ID,\n HEADER_METADATA_SLOT_ID,\n HEADER_PREFIX_SLOT_ID,\n} from '../../constants';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileDiffMetadata } from '../../types';\nimport { getLineAnnotationName } from '../../utils/getLineAnnotationName';\nimport { getMergeConflictActionSlotName } from '../../utils/getMergeConflictActionSlotName';\nimport {\n getMergeConflictActionAnchor,\n type MergeConflictDiffAction,\n} from '../../utils/parseMergeConflictDiffFromFile';\nimport { GutterUtilitySlotStyles, MergeConflictSlotStyles } from '../constants';\nimport type { DiffBasePropsReact } from '../types';\n\ninterface RenderDiffChildrenProps<LAnnotation, T> {\n fileDiff: FileDiffMetadata;\n actions?: (MergeConflictDiffAction | undefined)[];\n renderCustomHeader: DiffBasePropsReact<LAnnotation>['renderCustomHeader'];\n renderHeaderPrefix: DiffBasePropsReact<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: DiffBasePropsReact<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: DiffBasePropsReact<LAnnotation>['renderAnnotation'];\n renderGutterUtility: DiffBasePropsReact<LAnnotation>['renderGutterUtility'];\n renderMergeConflictUtility?(\n action: MergeConflictDiffAction,\n getInstance: () => T | undefined\n ): ReactNode;\n lineAnnotations: DiffBasePropsReact<LAnnotation>['lineAnnotations'];\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance?(): T | undefined;\n}\n\nexport function renderDiffChildren<LAnnotation, T>({\n fileDiff,\n actions,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n renderMergeConflictUtility,\n lineAnnotations,\n getHoveredLine,\n getInstance,\n}: RenderDiffChildrenProps<LAnnotation, T>): ReactNode {\n const customHeader = renderCustomHeader?.(fileDiff);\n const prefix = renderHeaderPrefix?.(fileDiff);\n const metadata = renderHeaderMetadata?.(fileDiff);\n return (\n <>\n {customHeader != null ? (\n <div slot={CUSTOM_HEADER_SLOT_ID}>{customHeader}</div>\n ) : (\n <>\n {prefix != null && <div slot={HEADER_PREFIX_SLOT_ID}>{prefix}</div>}\n {metadata != null && (\n <div slot={HEADER_METADATA_SLOT_ID}>{metadata}</div>\n )}\n </>\n )}\n {renderAnnotation != null &&\n lineAnnotations?.map((annotation, index) => (\n <div key={index} slot={getLineAnnotationName(annotation)}>\n {renderAnnotation(annotation)}\n </div>\n ))}\n {actions != null &&\n renderMergeConflictUtility != null &&\n getInstance != null &&\n actions.map((action) => {\n if (action == null) {\n return undefined;\n }\n const slot = getSlotName(action, fileDiff);\n return (\n <div key={slot} slot={slot} style={MergeConflictSlotStyles}>\n {renderMergeConflictUtility(action, getInstance)}\n </div>\n );\n })}\n {renderGutterUtility != null && (\n <div slot=\"gutter-utility-slot\" style={GutterUtilitySlotStyles}>\n {renderGutterUtility(getHoveredLine)}\n </div>\n )}\n </>\n );\n}\n\nfunction getSlotName(\n action: MergeConflictDiffAction,\n fileDiff: FileDiffMetadata\n): string | undefined {\n const anchor = getMergeConflictActionAnchor(action, fileDiff);\n return anchor != null\n ? getMergeConflictActionSlotName({\n hunkIndex: anchor.hunkIndex,\n lineIndex: anchor.lineIndex,\n conflictIndex: action.conflictIndex,\n })\n : undefined;\n}\n"],"mappings":";;;;;;;;AAmCA,SAAgB,mBAAmC,EACjD,UACA,SACA,oBACA,oBACA,sBACA,kBACA,qBACA,4BACA,iBACA,gBACA,eACqD;CACrD,MAAM,eAAe,qBAAqB,SAAS;CACnD,MAAM,SAAS,qBAAqB,SAAS;CAC7C,MAAM,WAAW,uBAAuB,SAAS;AACjD,QACE;EACG,gBAAgB,OACf,oBAAC;GAAI,MAAM;aAAwB;IAAmB,GAEtD,4CACG,UAAU,QAAQ,oBAAC;GAAI,MAAM;aAAwB;IAAa,EAClE,YAAY,QACX,oBAAC;GAAI,MAAM;aAA0B;IAAe,IAErD;EAEJ,oBAAoB,QACnB,iBAAiB,KAAK,YAAY,UAChC,oBAAC;GAAgB,MAAM,sBAAsB,WAAW;aACrD,iBAAiB,WAAW;KADrB,MAEJ,CACN;EACH,WAAW,QACV,8BAA8B,QAC9B,eAAe,QACf,QAAQ,KAAK,WAAW;AACtB,OAAI,UAAU,KACZ;GAEF,MAAM,OAAO,YAAY,QAAQ,SAAS;AAC1C,UACE,oBAAC;IAAqB;IAAM,OAAO;cAChC,2BAA2B,QAAQ,YAAY;MADxC,KAEJ;IAER;EACH,uBAAuB,QACtB,oBAAC;GAAI,MAAK;GAAsB,OAAO;aACpC,oBAAoB,eAAe;IAChC;KAEP;;AAIP,SAAS,YACP,QACA,UACoB;CACpB,MAAM,SAAS,6BAA6B,QAAQ,SAAS;AAC7D,QAAO,UAAU,OACb,+BAA+B;EAC7B,WAAW,OAAO;EAClB,WAAW,OAAO;EAClB,eAAe,OAAO;EACvB,CAAC,GACF"}
@@ -12,7 +12,6 @@ interface RenderFileChildrenProps<LAnnotation> {
12
12
  renderAnnotation: FileProps<LAnnotation>['renderAnnotation'];
13
13
  lineAnnotations: FileProps<LAnnotation>['lineAnnotations'];
14
14
  renderGutterUtility: FileProps<LAnnotation>['renderGutterUtility'];
15
- renderHoverUtility: FileProps<LAnnotation>['renderHoverUtility'];
16
15
  getHoveredLine(): GetHoveredLineResult<'file'> | undefined;
17
16
  }
18
17
  declare function renderFileChildren<LAnnotation>({
@@ -23,7 +22,6 @@ declare function renderFileChildren<LAnnotation>({
23
22
  renderAnnotation,
24
23
  lineAnnotations,
25
24
  renderGutterUtility,
26
- renderHoverUtility,
27
25
  getHoveredLine
28
26
  }: RenderFileChildrenProps<LAnnotation>): ReactNode;
29
27
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"renderFileChildren.d.ts","names":["ReactNode","GetHoveredLineResult","FileContents","FileProps","RenderFileChildrenProps","LAnnotation","renderFileChildren","file","renderCustomHeader","renderHeaderPrefix","renderHeaderMetadata","renderAnnotation","lineAnnotations","renderGutterUtility","renderHoverUtility","getHoveredLine"],"sources":["../../../src/react/utils/renderFileChildren.d.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileContents } from '../../types';\nimport type { FileProps } from '../types';\ninterface RenderFileChildrenProps<LAnnotation> {\n file: FileContents;\n renderCustomHeader: FileProps<LAnnotation>['renderCustomHeader'];\n renderHeaderPrefix: FileProps<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: FileProps<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: FileProps<LAnnotation>['renderAnnotation'];\n lineAnnotations: FileProps<LAnnotation>['lineAnnotations'];\n renderGutterUtility: FileProps<LAnnotation>['renderGutterUtility'];\n renderHoverUtility: FileProps<LAnnotation>['renderHoverUtility'];\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\nexport declare function renderFileChildren<LAnnotation>({ file, renderCustomHeader, renderHeaderPrefix, renderHeaderMetadata, renderAnnotation, lineAnnotations, renderGutterUtility, renderHoverUtility, getHoveredLine }: RenderFileChildrenProps<LAnnotation>): ReactNode;\nexport {};\n//# sourceMappingURL=renderFileChildren.d.ts.map"],"mappings":";;;;;;UAIUI;QACAF;EADAE,kBAAAA,EAEcD,SAFS,CAECE,WAFDA,CAAAA,CAAAA,oBAAA,CAAA;EACvBH,kBAAAA,EAEcC,SAFdD,CAEwBG,WAFxBH,CAAAA,CAAAA,oBAAAA,CAAAA;EACwBG,oBAAAA,EAERF,SAFQE,CAEEA,WAFFA,CAAAA,CAAAA,sBAAAA,CAAAA;EAAVF,gBAAAA,EAGFA,SAHEA,CAGQE,WAHRF,CAAAA,CAAAA,kBAAAA,CAAAA;EACUE,eAAAA,EAGbF,SAHaE,CAGHA,WAHGA,CAAAA,CAAAA,iBAAAA,CAAAA;EAAVF,mBAAAA,EAICA,SAJDA,CAIWE,WAJXF,CAAAA,CAAAA,qBAAAA,CAAAA;EACYE,kBAAAA,EAIZF,SAJYE,CAIFA,WAJEA,CAAAA,CAAAA,oBAAAA,CAAAA;EAAVF,cAAAA,EAAAA,EAKJF,oBALIE,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;;AACJA,iBAMEG,kBANFH,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,IAAAA;EAAAA,kBAAAA;EAAAA,kBAAAA;EAAAA,oBAAAA;EAAAA,gBAAAA;EAAAA,eAAAA;EAAAA,mBAAAA;EAAAA,kBAAAA;EAAAA;AAAAA,CAAAA,EAMsMC,uBANtMD,CAM8NE,WAN9NF,CAAAA,CAAAA,EAM6OH,SAN7OG"}
1
+ {"version":3,"file":"renderFileChildren.d.ts","names":["ReactNode","GetHoveredLineResult","FileContents","FileProps","RenderFileChildrenProps","LAnnotation","renderFileChildren","file","renderCustomHeader","renderHeaderPrefix","renderHeaderMetadata","renderAnnotation","lineAnnotations","renderGutterUtility","getHoveredLine"],"sources":["../../../src/react/utils/renderFileChildren.d.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileContents } from '../../types';\nimport type { FileProps } from '../types';\ninterface RenderFileChildrenProps<LAnnotation> {\n file: FileContents;\n renderCustomHeader: FileProps<LAnnotation>['renderCustomHeader'];\n renderHeaderPrefix: FileProps<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: FileProps<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: FileProps<LAnnotation>['renderAnnotation'];\n lineAnnotations: FileProps<LAnnotation>['lineAnnotations'];\n renderGutterUtility: FileProps<LAnnotation>['renderGutterUtility'];\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\nexport declare function renderFileChildren<LAnnotation>({ file, renderCustomHeader, renderHeaderPrefix, renderHeaderMetadata, renderAnnotation, lineAnnotations, renderGutterUtility, getHoveredLine }: RenderFileChildrenProps<LAnnotation>): ReactNode;\nexport {};\n//# sourceMappingURL=renderFileChildren.d.ts.map"],"mappings":";;;;;;UAIUI;QACAF;EADAE,kBAAAA,EAEcD,SAFS,CAECE,WAFDA,CAAAA,CAAAA,oBAAA,CAAA;EACvBH,kBAAAA,EAEcC,SAFdD,CAEwBG,WAFxBH,CAAAA,CAAAA,oBAAAA,CAAAA;EACwBG,oBAAAA,EAERF,SAFQE,CAEEA,WAFFA,CAAAA,CAAAA,sBAAAA,CAAAA;EAAVF,gBAAAA,EAGFA,SAHEA,CAGQE,WAHRF,CAAAA,CAAAA,kBAAAA,CAAAA;EACUE,eAAAA,EAGbF,SAHaE,CAGHA,WAHGA,CAAAA,CAAAA,iBAAAA,CAAAA;EAAVF,mBAAAA,EAICA,SAJDA,CAIWE,WAJXF,CAAAA,CAAAA,qBAAAA,CAAAA;EACYE,cAAAA,EAAAA,EAIdJ,oBAJcI,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;;AACJA,iBAKRC,kBALQD,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,IAAAA;EAAAA,kBAAAA;EAAAA,kBAAAA;EAAAA,oBAAAA;EAAAA,gBAAAA;EAAAA,eAAAA;EAAAA,mBAAAA;EAAAA;AAAAA,CAAAA,EAKwKD,uBALxKC,CAKgMA,WALhMA,CAAAA,CAAAA,EAK+ML,SAL/MK"}
@@ -4,8 +4,7 @@ import { GutterUtilitySlotStyles } from "../constants.js";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
 
6
6
  //#region src/react/utils/renderFileChildren.tsx
7
- function renderFileChildren({ file, renderCustomHeader, renderHeaderPrefix, renderHeaderMetadata, renderAnnotation, lineAnnotations, renderGutterUtility, renderHoverUtility, getHoveredLine }) {
8
- const gutterUtility = renderGutterUtility ?? renderHoverUtility;
7
+ function renderFileChildren({ file, renderCustomHeader, renderHeaderPrefix, renderHeaderMetadata, renderAnnotation, lineAnnotations, renderGutterUtility, getHoveredLine }) {
9
8
  const customHeader = renderCustomHeader?.(file);
10
9
  const prefix = renderHeaderPrefix?.(file);
11
10
  const metadata = renderHeaderMetadata?.(file);
@@ -24,10 +23,10 @@ function renderFileChildren({ file, renderCustomHeader, renderHeaderPrefix, rend
24
23
  slot: getLineAnnotationName(annotation),
25
24
  children: renderAnnotation(annotation)
26
25
  }, index)),
27
- gutterUtility != null && /* @__PURE__ */ jsx("div", {
26
+ renderGutterUtility != null && /* @__PURE__ */ jsx("div", {
28
27
  slot: "gutter-utility-slot",
29
28
  style: GutterUtilitySlotStyles,
30
- children: gutterUtility(getHoveredLine)
29
+ children: renderGutterUtility(getHoveredLine)
31
30
  })
32
31
  ] });
33
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"renderFileChildren.js","names":[],"sources":["../../../src/react/utils/renderFileChildren.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport {\n CUSTOM_HEADER_SLOT_ID,\n HEADER_METADATA_SLOT_ID,\n HEADER_PREFIX_SLOT_ID,\n} from '../../constants';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileContents } from '../../types';\nimport { getLineAnnotationName } from '../../utils/getLineAnnotationName';\nimport { GutterUtilitySlotStyles } from '../constants';\nimport type { FileProps } from '../types';\n\ninterface RenderFileChildrenProps<LAnnotation> {\n file: FileContents;\n renderCustomHeader: FileProps<LAnnotation>['renderCustomHeader'];\n renderHeaderPrefix: FileProps<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: FileProps<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: FileProps<LAnnotation>['renderAnnotation'];\n lineAnnotations: FileProps<LAnnotation>['lineAnnotations'];\n renderGutterUtility: FileProps<LAnnotation>['renderGutterUtility'];\n renderHoverUtility: FileProps<LAnnotation>['renderHoverUtility'];\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\n\nexport function renderFileChildren<LAnnotation>({\n file,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n lineAnnotations,\n renderGutterUtility,\n renderHoverUtility,\n getHoveredLine,\n}: RenderFileChildrenProps<LAnnotation>): ReactNode {\n const gutterUtility = renderGutterUtility ?? renderHoverUtility;\n const customHeader = renderCustomHeader?.(file);\n const prefix = renderHeaderPrefix?.(file);\n const metadata = renderHeaderMetadata?.(file);\n return (\n <>\n {customHeader != null ? (\n <div slot={CUSTOM_HEADER_SLOT_ID}>{customHeader}</div>\n ) : (\n <>\n {prefix != null && <div slot={HEADER_PREFIX_SLOT_ID}>{prefix}</div>}\n {metadata != null && (\n <div slot={HEADER_METADATA_SLOT_ID}>{metadata}</div>\n )}\n </>\n )}\n {renderAnnotation != null &&\n lineAnnotations?.map((annotation, index) => (\n <div key={index} slot={getLineAnnotationName(annotation)}>\n {renderAnnotation(annotation)}\n </div>\n ))}\n {gutterUtility != null && (\n <div slot=\"gutter-utility-slot\" style={GutterUtilitySlotStyles}>\n {gutterUtility(getHoveredLine)}\n </div>\n )}\n </>\n );\n}\n"],"mappings":";;;;;;AAyBA,SAAgB,mBAAgC,EAC9C,MACA,oBACA,oBACA,sBACA,kBACA,iBACA,qBACA,oBACA,kBACkD;CAClD,MAAM,gBAAgB,uBAAuB;CAC7C,MAAM,eAAe,qBAAqB,KAAK;CAC/C,MAAM,SAAS,qBAAqB,KAAK;CACzC,MAAM,WAAW,uBAAuB,KAAK;AAC7C,QACE;EACG,gBAAgB,OACf,oBAAC;GAAI,MAAM;aAAwB;IAAmB,GAEtD,4CACG,UAAU,QAAQ,oBAAC;GAAI,MAAM;aAAwB;IAAa,EAClE,YAAY,QACX,oBAAC;GAAI,MAAM;aAA0B;IAAe,IAErD;EAEJ,oBAAoB,QACnB,iBAAiB,KAAK,YAAY,UAChC,oBAAC;GAAgB,MAAM,sBAAsB,WAAW;aACrD,iBAAiB,WAAW;KADrB,MAEJ,CACN;EACH,iBAAiB,QAChB,oBAAC;GAAI,MAAK;GAAsB,OAAO;aACpC,cAAc,eAAe;IAC1B;KAEP"}
1
+ {"version":3,"file":"renderFileChildren.js","names":[],"sources":["../../../src/react/utils/renderFileChildren.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport {\n CUSTOM_HEADER_SLOT_ID,\n HEADER_METADATA_SLOT_ID,\n HEADER_PREFIX_SLOT_ID,\n} from '../../constants';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileContents } from '../../types';\nimport { getLineAnnotationName } from '../../utils/getLineAnnotationName';\nimport { GutterUtilitySlotStyles } from '../constants';\nimport type { FileProps } from '../types';\n\ninterface RenderFileChildrenProps<LAnnotation> {\n file: FileContents;\n renderCustomHeader: FileProps<LAnnotation>['renderCustomHeader'];\n renderHeaderPrefix: FileProps<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: FileProps<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: FileProps<LAnnotation>['renderAnnotation'];\n lineAnnotations: FileProps<LAnnotation>['lineAnnotations'];\n renderGutterUtility: FileProps<LAnnotation>['renderGutterUtility'];\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\n\nexport function renderFileChildren<LAnnotation>({\n file,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n lineAnnotations,\n renderGutterUtility,\n getHoveredLine,\n}: RenderFileChildrenProps<LAnnotation>): ReactNode {\n const customHeader = renderCustomHeader?.(file);\n const prefix = renderHeaderPrefix?.(file);\n const metadata = renderHeaderMetadata?.(file);\n return (\n <>\n {customHeader != null ? (\n <div slot={CUSTOM_HEADER_SLOT_ID}>{customHeader}</div>\n ) : (\n <>\n {prefix != null && <div slot={HEADER_PREFIX_SLOT_ID}>{prefix}</div>}\n {metadata != null && (\n <div slot={HEADER_METADATA_SLOT_ID}>{metadata}</div>\n )}\n </>\n )}\n {renderAnnotation != null &&\n lineAnnotations?.map((annotation, index) => (\n <div key={index} slot={getLineAnnotationName(annotation)}>\n {renderAnnotation(annotation)}\n </div>\n ))}\n {renderGutterUtility != null && (\n <div slot=\"gutter-utility-slot\" style={GutterUtilitySlotStyles}>\n {renderGutterUtility(getHoveredLine)}\n </div>\n )}\n </>\n );\n}\n"],"mappings":";;;;;;AAwBA,SAAgB,mBAAgC,EAC9C,MACA,oBACA,oBACA,sBACA,kBACA,iBACA,qBACA,kBACkD;CAClD,MAAM,eAAe,qBAAqB,KAAK;CAC/C,MAAM,SAAS,qBAAqB,KAAK;CACzC,MAAM,WAAW,uBAAuB,KAAK;AAC7C,QACE;EACG,gBAAgB,OACf,oBAAC;GAAI,MAAM;aAAwB;IAAmB,GAEtD,4CACG,UAAU,QAAQ,oBAAC;GAAI,MAAM;aAAwB;IAAa,EAClE,YAAY,QACX,oBAAC;GAAI,MAAM;aAA0B;IAAe,IAErD;EAEJ,oBAAoB,QACnB,iBAAiB,KAAK,YAAY,UAChC,oBAAC;GAAgB,MAAM,sBAAsB,WAAW;aACrD,iBAAiB,WAAW;KADrB,MAEJ,CACN;EACH,uBAAuB,QACtB,oBAAC;GAAI,MAAK;GAAsB,OAAO;aACpC,oBAAoB,eAAe;IAChC;KAEP"}
@@ -2,26 +2,29 @@ import { FileDiff } from "../../components/FileDiff.js";
2
2
  import { VirtualizedFileDiff } from "../../components/VirtualizedFileDiff.js";
3
3
  import { areOptionsEqual } from "../../utils/areOptionsEqual.js";
4
4
  import { noopRender } from "../constants.js";
5
- import { useVirtualizer } from "../Virtualizer.js";
6
- import { WorkerPoolContext } from "../WorkerPoolContext.js";
7
5
  import { useStableCallback } from "./useStableCallback.js";
6
+ import { WorkerPoolContext } from "../WorkerPoolContext.js";
7
+ import { useVirtualizer } from "../Virtualizer.js";
8
8
  import { useCallback, useContext, useEffect, useLayoutEffect, useRef } from "react";
9
9
 
10
10
  //#region src/react/utils/useFileDiffInstance.ts
11
11
  const useIsometricEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
12
12
  function useFileDiffInstance({ fileDiff, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility, hasCustomHeader, disableWorkerPool }) {
13
13
  const simpleVirtualizer = useVirtualizer();
14
+ const controlledSelection = selectedLines !== void 0;
14
15
  const poolManager = useContext(WorkerPoolContext);
15
16
  const instanceRef = useRef(null);
16
17
  const ref = useStableCallback((fileContainer) => {
17
18
  if (fileContainer != null) {
18
19
  if (instanceRef.current != null) throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");
19
20
  if (simpleVirtualizer != null) instanceRef.current = new VirtualizedFileDiff(mergeFileDiffOptions({
21
+ controlledSelection,
20
22
  hasCustomHeader,
21
23
  hasGutterRenderUtility,
22
24
  options
23
25
  }), simpleVirtualizer, metrics, !disableWorkerPool ? poolManager : void 0, true);
24
26
  else instanceRef.current = new FileDiff(mergeFileDiffOptions({
27
+ controlledSelection,
25
28
  hasCustomHeader,
26
29
  hasGutterRenderUtility,
27
30
  options
@@ -42,6 +45,7 @@ function useFileDiffInstance({ fileDiff, options, lineAnnotations, selectedLines
42
45
  const { current: instance } = instanceRef;
43
46
  if (instance == null) return;
44
47
  const newOptions = mergeFileDiffOptions({
48
+ controlledSelection,
45
49
  hasCustomHeader,
46
50
  hasGutterRenderUtility,
47
51
  options
@@ -62,13 +66,14 @@ function useFileDiffInstance({ fileDiff, options, lineAnnotations, selectedLines
62
66
  }, [])
63
67
  };
64
68
  }
65
- function mergeFileDiffOptions({ options, hasCustomHeader, hasGutterRenderUtility }) {
66
- if (hasGutterRenderUtility || hasCustomHeader) return {
69
+ function mergeFileDiffOptions({ options, controlledSelection, hasCustomHeader, hasGutterRenderUtility }) {
70
+ if (!controlledSelection && !hasGutterRenderUtility && !hasCustomHeader) return options;
71
+ return {
67
72
  ...options,
68
- renderCustomHeader: hasCustomHeader ? noopRender : void 0,
69
- renderGutterUtility: hasGutterRenderUtility ? noopRender : void 0
73
+ controlledSelection,
74
+ renderCustomHeader: hasCustomHeader ? noopRender : options?.renderCustomHeader,
75
+ renderGutterUtility: hasGutterRenderUtility ? noopRender : options?.renderGutterUtility
70
76
  };
71
- return options;
72
77
  }
73
78
 
74
79
  //#endregion
@@ -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 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 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 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 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 hasCustomHeader: boolean;\n hasGutterRenderUtility: boolean;\n options: FileDiffOptions<LAnnotation> | undefined;\n}\n\nfunction mergeFileDiffOptions<LAnnotation>({\n options,\n hasCustomHeader,\n hasGutterRenderUtility,\n}: MergeFileDiffOptionsProps<LAnnotation>):\n | FileDiffOptions<LAnnotation>\n | undefined {\n if (hasGutterRenderUtility || hasCustomHeader) {\n return {\n ...options,\n renderCustomHeader: hasCustomHeader ? noopRender : undefined,\n renderGutterUtility: hasGutterRenderUtility ? noopRender : undefined,\n };\n }\n return options;\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,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;IACD,CAAC,EACF,mBACA,SACA,CAAC,oBAAoB,cAAc,QACnC,KACD;OAED,aAAY,UAAU,IAAI,SACxB,qBAAqB;IACnB;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;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;;AAShC,SAAS,qBAAkC,EACzC,SACA,iBACA,0BAGY;AACZ,KAAI,0BAA0B,gBAC5B,QAAO;EACL,GAAG;EACH,oBAAoB,kBAAkB,aAAa;EACnD,qBAAqB,yBAAyB,aAAa;EAC5D;AAEH,QAAO"}
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"}
@@ -2,26 +2,29 @@ import { File } from "../../components/File.js";
2
2
  import { VirtualizedFile } from "../../components/VirtualizedFile.js";
3
3
  import { areOptionsEqual } from "../../utils/areOptionsEqual.js";
4
4
  import { noopRender } from "../constants.js";
5
- import { useVirtualizer } from "../Virtualizer.js";
6
- import { WorkerPoolContext } from "../WorkerPoolContext.js";
7
5
  import { useStableCallback } from "./useStableCallback.js";
6
+ import { WorkerPoolContext } from "../WorkerPoolContext.js";
7
+ import { useVirtualizer } from "../Virtualizer.js";
8
8
  import { useCallback, useContext, useEffect, useLayoutEffect, useRef } from "react";
9
9
 
10
10
  //#region src/react/utils/useFileInstance.ts
11
11
  const useIsometricEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
12
12
  function useFileInstance({ file, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility, hasCustomHeader, disableWorkerPool }) {
13
13
  const simpleVirtualizer = useVirtualizer();
14
+ const controlledSelection = selectedLines !== void 0;
14
15
  const poolManager = useContext(WorkerPoolContext);
15
16
  const instanceRef = useRef(null);
16
17
  const ref = useStableCallback((node) => {
17
18
  if (node != null) {
18
19
  if (instanceRef.current != null) throw new Error("File: An instance should not already exist when a node is created");
19
20
  if (simpleVirtualizer != null) instanceRef.current = new VirtualizedFile(mergeFileOptions({
21
+ controlledSelection,
20
22
  hasCustomHeader,
21
23
  hasGutterRenderUtility,
22
24
  options
23
25
  }), simpleVirtualizer, metrics, !disableWorkerPool ? poolManager : void 0, true);
24
26
  else instanceRef.current = new File(mergeFileOptions({
27
+ controlledSelection,
25
28
  hasCustomHeader,
26
29
  hasGutterRenderUtility,
27
30
  options
@@ -41,6 +44,7 @@ function useFileInstance({ file, options, lineAnnotations, selectedLines, preren
41
44
  useIsometricEffect(() => {
42
45
  if (instanceRef.current == null) return;
43
46
  const newOptions = mergeFileOptions({
47
+ controlledSelection,
44
48
  hasCustomHeader,
45
49
  hasGutterRenderUtility,
46
50
  options
@@ -61,13 +65,14 @@ function useFileInstance({ file, options, lineAnnotations, selectedLines, preren
61
65
  }, [])
62
66
  };
63
67
  }
64
- function mergeFileOptions({ options, hasCustomHeader, hasGutterRenderUtility }) {
65
- if (hasGutterRenderUtility || hasCustomHeader) return {
68
+ function mergeFileOptions({ options, controlledSelection, hasCustomHeader, hasGutterRenderUtility }) {
69
+ if (!controlledSelection && !hasGutterRenderUtility && !hasCustomHeader) return options;
70
+ return {
66
71
  ...options,
67
- renderCustomHeader: hasCustomHeader ? noopRender : void 0,
68
- renderGutterUtility: hasGutterRenderUtility ? noopRender : void 0
72
+ controlledSelection,
73
+ renderCustomHeader: hasCustomHeader ? noopRender : options?.renderCustomHeader,
74
+ renderGutterUtility: hasGutterRenderUtility ? noopRender : options?.renderGutterUtility
69
75
  };
70
- return options;
71
76
  }
72
77
 
73
78
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useFileInstance.js","names":[],"sources":["../../../src/react/utils/useFileInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n} from 'react';\n\nimport { File, type FileOptions } from '../../components/File';\nimport { VirtualizedFile } from '../../components/VirtualizedFile';\nimport type {\n GetHoveredLineResult,\n SelectedLineRange,\n} from '../../managers/InteractionManager';\nimport type {\n FileContents,\n LineAnnotation,\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 UseFileInstanceProps<LAnnotation> {\n file: FileContents;\n options: FileOptions<LAnnotation> | undefined;\n lineAnnotations: LineAnnotation<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 UseFileInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\n\nexport function useFileInstance<LAnnotation>({\n file,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n metrics,\n hasGutterRenderUtility,\n hasCustomHeader,\n disableWorkerPool,\n}: UseFileInstanceProps<LAnnotation>): UseFileInstanceReturn {\n const simpleVirtualizer = useVirtualizer();\n const poolManager = useContext(WorkerPoolContext);\n const instanceRef = useRef<\n File<LAnnotation> | VirtualizedFile<LAnnotation> | null\n >(null);\n const ref = useStableCallback((node: HTMLElement | null) => {\n if (node != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'File: An instance should not already exist when a node is created'\n );\n }\n if (simpleVirtualizer != null) {\n instanceRef.current = new VirtualizedFile(\n mergeFileOptions({\n hasCustomHeader,\n hasGutterRenderUtility,\n options,\n }),\n simpleVirtualizer,\n metrics,\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n } else {\n instanceRef.current = new File(\n mergeFileOptions({\n hasCustomHeader,\n hasGutterRenderUtility,\n options,\n }),\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n }\n void instanceRef.current.hydrate({\n file,\n fileContainer: node,\n lineAnnotations,\n prerenderedHTML,\n });\n } else {\n if (instanceRef.current == null) {\n throw new Error('File: A File instance should exist when unmounting');\n }\n instanceRef.current.cleanUp();\n instanceRef.current = null;\n }\n });\n\n useIsometricEffect(() => {\n if (instanceRef.current == null) return;\n const newOptions = mergeFileOptions({\n hasCustomHeader,\n hasGutterRenderUtility,\n options,\n });\n const forceRender = !areOptionsEqual(\n instanceRef.current.options,\n newOptions\n );\n instanceRef.current.setOptions(newOptions);\n void instanceRef.current.render({ file, lineAnnotations, forceRender });\n if (selectedLines !== undefined) {\n instanceRef.current.setSelectedLines(selectedLines);\n }\n });\n\n const getHoveredLine = useCallback(():\n | GetHoveredLineResult<'file'>\n | undefined => {\n return instanceRef.current?.getHoveredLine();\n }, []);\n return { ref, getHoveredLine };\n}\n\ninterface MergeFileOptionsProps<LAnnotation> {\n options: FileOptions<LAnnotation> | undefined;\n hasGutterRenderUtility: boolean;\n hasCustomHeader: boolean;\n}\n\nfunction mergeFileOptions<LAnnotation>({\n options,\n hasCustomHeader,\n hasGutterRenderUtility,\n}: MergeFileOptionsProps<LAnnotation>): FileOptions<LAnnotation> | undefined {\n if (hasGutterRenderUtility || hasCustomHeader) {\n return {\n ...options,\n renderCustomHeader: hasCustomHeader ? noopRender : undefined,\n renderGutterUtility: hasGutterRenderUtility ? noopRender : undefined,\n };\n }\n return options;\n}\n"],"mappings":";;;;;;;;;;AAyBA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAmB9C,SAAgB,gBAA6B,EAC3C,MACA,SACA,iBACA,eACA,iBACA,SACA,wBACA,iBACA,qBAC2D;CAC3D,MAAM,oBAAoB,gBAAgB;CAC1C,MAAM,cAAc,WAAW,kBAAkB;CACjD,MAAM,cAAc,OAElB,KAAK;CACP,MAAM,MAAM,mBAAmB,SAA6B;AAC1D,MAAI,QAAQ,MAAM;AAChB,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MACR,oEACD;AAEH,OAAI,qBAAqB,KACvB,aAAY,UAAU,IAAI,gBACxB,iBAAiB;IACf;IACA;IACA;IACD,CAAC,EACF,mBACA,SACA,CAAC,oBAAoB,cAAc,QACnC,KACD;OAED,aAAY,UAAU,IAAI,KACxB,iBAAiB;IACf;IACA;IACA;IACD,CAAC,EACF,CAAC,oBAAoB,cAAc,QACnC,KACD;AAEH,GAAK,YAAY,QAAQ,QAAQ;IAC/B;IACA,eAAe;IACf;IACA;IACD,CAAC;SACG;AACL,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MAAM,qDAAqD;AAEvE,eAAY,QAAQ,SAAS;AAC7B,eAAY,UAAU;;GAExB;AAEF,0BAAyB;AACvB,MAAI,YAAY,WAAW,KAAM;EACjC,MAAM,aAAa,iBAAiB;GAClC;GACA;GACA;GACD,CAAC;EACF,MAAM,cAAc,CAAC,gBACnB,YAAY,QAAQ,SACpB,WACD;AACD,cAAY,QAAQ,WAAW,WAAW;AAC1C,EAAK,YAAY,QAAQ,OAAO;GAAE;GAAM;GAAiB;GAAa,CAAC;AACvE,MAAI,kBAAkB,OACpB,aAAY,QAAQ,iBAAiB,cAAc;GAErD;AAOF,QAAO;EAAE;EAAK,gBALS,kBAEN;AACf,UAAO,YAAY,SAAS,gBAAgB;KAC3C,EAAE,CAAC;EACwB;;AAShC,SAAS,iBAA8B,EACrC,SACA,iBACA,0BAC2E;AAC3E,KAAI,0BAA0B,gBAC5B,QAAO;EACL,GAAG;EACH,oBAAoB,kBAAkB,aAAa;EACnD,qBAAqB,yBAAyB,aAAa;EAC5D;AAEH,QAAO"}
1
+ {"version":3,"file":"useFileInstance.js","names":[],"sources":["../../../src/react/utils/useFileInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n} from 'react';\n\nimport { File, type FileOptions } from '../../components/File';\nimport { VirtualizedFile } from '../../components/VirtualizedFile';\nimport type {\n GetHoveredLineResult,\n SelectedLineRange,\n} from '../../managers/InteractionManager';\nimport type {\n FileContents,\n LineAnnotation,\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 UseFileInstanceProps<LAnnotation> {\n file: FileContents;\n options: FileOptions<LAnnotation> | undefined;\n lineAnnotations: LineAnnotation<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 UseFileInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\n\nexport function useFileInstance<LAnnotation>({\n file,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n metrics,\n hasGutterRenderUtility,\n hasCustomHeader,\n disableWorkerPool,\n}: UseFileInstanceProps<LAnnotation>): UseFileInstanceReturn {\n const simpleVirtualizer = useVirtualizer();\n const controlledSelection = selectedLines !== undefined;\n const poolManager = useContext(WorkerPoolContext);\n const instanceRef = useRef<\n File<LAnnotation> | VirtualizedFile<LAnnotation> | null\n >(null);\n const ref = useStableCallback((node: HTMLElement | null) => {\n if (node != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'File: An instance should not already exist when a node is created'\n );\n }\n if (simpleVirtualizer != null) {\n instanceRef.current = new VirtualizedFile(\n mergeFileOptions({\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 File(\n mergeFileOptions({\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n options,\n }),\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n }\n void instanceRef.current.hydrate({\n file,\n fileContainer: node,\n lineAnnotations,\n prerenderedHTML,\n });\n } else {\n if (instanceRef.current == null) {\n throw new Error('File: A File instance should exist when unmounting');\n }\n instanceRef.current.cleanUp();\n instanceRef.current = null;\n }\n });\n\n useIsometricEffect(() => {\n if (instanceRef.current == null) return;\n const newOptions = mergeFileOptions({\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n options,\n });\n const forceRender = !areOptionsEqual(\n instanceRef.current.options,\n newOptions\n );\n instanceRef.current.setOptions(newOptions);\n void instanceRef.current.render({ file, lineAnnotations, forceRender });\n if (selectedLines !== undefined) {\n instanceRef.current.setSelectedLines(selectedLines);\n }\n });\n\n const getHoveredLine = useCallback(():\n | GetHoveredLineResult<'file'>\n | undefined => {\n return instanceRef.current?.getHoveredLine();\n }, []);\n return { ref, getHoveredLine };\n}\n\ninterface MergeFileOptionsProps<LAnnotation> {\n options: FileOptions<LAnnotation> | undefined;\n controlledSelection: boolean;\n hasGutterRenderUtility: boolean;\n hasCustomHeader: boolean;\n}\n\nfunction mergeFileOptions<LAnnotation>({\n options,\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n}: MergeFileOptionsProps<LAnnotation>): FileOptions<LAnnotation> | 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,gBAA6B,EAC3C,MACA,SACA,iBACA,eACA,iBACA,SACA,wBACA,iBACA,qBAC2D;CAC3D,MAAM,oBAAoB,gBAAgB;CAC1C,MAAM,sBAAsB,kBAAkB;CAC9C,MAAM,cAAc,WAAW,kBAAkB;CACjD,MAAM,cAAc,OAElB,KAAK;CACP,MAAM,MAAM,mBAAmB,SAA6B;AAC1D,MAAI,QAAQ,MAAM;AAChB,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MACR,oEACD;AAEH,OAAI,qBAAqB,KACvB,aAAY,UAAU,IAAI,gBACxB,iBAAiB;IACf;IACA;IACA;IACA;IACD,CAAC,EACF,mBACA,SACA,CAAC,oBAAoB,cAAc,QACnC,KACD;OAED,aAAY,UAAU,IAAI,KACxB,iBAAiB;IACf;IACA;IACA;IACA;IACD,CAAC,EACF,CAAC,oBAAoB,cAAc,QACnC,KACD;AAEH,GAAK,YAAY,QAAQ,QAAQ;IAC/B;IACA,eAAe;IACf;IACA;IACD,CAAC;SACG;AACL,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MAAM,qDAAqD;AAEvE,eAAY,QAAQ,SAAS;AAC7B,eAAY,UAAU;;GAExB;AAEF,0BAAyB;AACvB,MAAI,YAAY,WAAW,KAAM;EACjC,MAAM,aAAa,iBAAiB;GAClC;GACA;GACA;GACA;GACD,CAAC;EACF,MAAM,cAAc,CAAC,gBACnB,YAAY,QAAQ,SACpB,WACD;AACD,cAAY,QAAQ,WAAW,WAAW;AAC1C,EAAK,YAAY,QAAQ,OAAO;GAAE;GAAM;GAAiB;GAAa,CAAC;AACvE,MAAI,kBAAkB,OACpB,aAAY,QAAQ,iBAAiB,cAAc;GAErD;AAOF,QAAO;EAAE;EAAK,gBALS,kBAEN;AACf,UAAO,YAAY,SAAS,gBAAgB;KAC3C,EAAE,CAAC;EACwB;;AAUhC,SAAS,iBAA8B,EACrC,SACA,qBACA,iBACA,0BAC2E;AAC3E,KAAI,CAAC,uBAAuB,CAAC,0BAA0B,CAAC,gBACtD,QAAO;AAET,QAAO;EACL,GAAG;EACH;EACA,oBAAoB,kBAChB,aACA,SAAS;EACb,qBAAqB,yBACjB,aACA,SAAS;EACd"}
@@ -2,8 +2,8 @@ import { parseMergeConflictDiffFromFile } from "../../utils/parseMergeConflictDi
2
2
  import { UnresolvedFile } from "../../components/UnresolvedFile.js";
3
3
  import { areOptionsEqual } from "../../utils/areOptionsEqual.js";
4
4
  import { noopRender } from "../constants.js";
5
- import { WorkerPoolContext } from "../WorkerPoolContext.js";
6
5
  import { useStableCallback } from "./useStableCallback.js";
6
+ import { WorkerPoolContext } from "../WorkerPoolContext.js";
7
7
  import { useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
8
8
 
9
9
  //#region src/react/utils/useUnresolvedFileInstance.ts
@@ -28,12 +28,14 @@ function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLin
28
28
  };
29
29
  });
30
30
  });
31
+ const controlledSelection = selectedLines !== void 0;
31
32
  const poolManager = useContext(WorkerPoolContext);
32
33
  const instanceRef = useRef(null);
33
34
  const ref = useStableCallback((fileContainer) => {
34
35
  if (fileContainer != null) {
35
36
  if (instanceRef.current != null) throw new Error("useUnresolvedFileInstance: An instance should not already exist when a node is created");
36
37
  instanceRef.current = new UnresolvedFile(mergeUnresolvedOptions({
38
+ controlledSelection,
37
39
  hasConflictUtility,
38
40
  hasCustomHeader,
39
41
  hasGutterRenderUtility,
@@ -58,6 +60,7 @@ function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLin
58
60
  if (instanceRef.current == null) return;
59
61
  const instance = instanceRef.current;
60
62
  const newOptions = mergeUnresolvedOptions({
63
+ controlledSelection,
61
64
  hasConflictUtility,
62
65
  hasCustomHeader,
63
66
  hasGutterRenderUtility,
@@ -88,9 +91,10 @@ function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLin
88
91
  }, [])
89
92
  };
90
93
  }
91
- function mergeUnresolvedOptions({ options, onMergeConflictAction, hasConflictUtility, hasCustomHeader, hasGutterRenderUtility }) {
94
+ function mergeUnresolvedOptions({ options, controlledSelection, onMergeConflictAction, hasConflictUtility, hasCustomHeader, hasGutterRenderUtility }) {
92
95
  return {
93
96
  ...options,
97
+ controlledSelection,
94
98
  onMergeConflictAction,
95
99
  hunkSeparators: options?.hunkSeparators === "custom" ? noopRender : options?.hunkSeparators,
96
100
  mergeConflictActionsType: hasConflictUtility || options?.mergeConflictActionsType === "custom" ? noopRender : options?.mergeConflictActionsType,