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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/README.md +6 -6
  2. package/dist/components/CodeView.js +6 -6
  3. package/dist/components/CodeView.js.map +1 -1
  4. package/dist/components/File.d.ts +3 -2
  5. package/dist/components/File.d.ts.map +1 -1
  6. package/dist/components/File.js +35 -21
  7. package/dist/components/File.js.map +1 -1
  8. package/dist/components/FileDiff.d.ts +8 -4
  9. package/dist/components/FileDiff.d.ts.map +1 -1
  10. package/dist/components/FileDiff.js +66 -56
  11. package/dist/components/FileDiff.js.map +1 -1
  12. package/dist/components/FileStream.js +4 -2
  13. package/dist/components/FileStream.js.map +1 -1
  14. package/dist/components/UnresolvedFile.js +1 -1
  15. package/dist/components/VirtualizedFile.d.ts +6 -2
  16. package/dist/components/VirtualizedFile.d.ts.map +1 -1
  17. package/dist/components/VirtualizedFile.js +89 -24
  18. package/dist/components/VirtualizedFile.js.map +1 -1
  19. package/dist/components/VirtualizedFileDiff.d.ts +8 -2
  20. package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
  21. package/dist/components/VirtualizedFileDiff.js +91 -15
  22. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  23. package/dist/editor/command.d.ts +1 -1
  24. package/dist/editor/command.d.ts.map +1 -1
  25. package/dist/editor/command.js +3 -3
  26. package/dist/editor/command.js.map +1 -1
  27. package/dist/editor/editStack.d.ts +1 -1
  28. package/dist/editor/editor.d.ts +37 -9
  29. package/dist/editor/editor.d.ts.map +1 -1
  30. package/dist/editor/editor.js +558 -449
  31. package/dist/editor/editor.js.map +1 -1
  32. package/dist/editor/editor2.js +1 -1
  33. package/dist/editor/editor2.js.map +1 -1
  34. package/dist/editor/index.d.ts +2 -2
  35. package/dist/editor/lineAnnotations.d.ts +2 -1
  36. package/dist/editor/lineAnnotations.d.ts.map +1 -1
  37. package/dist/editor/lineAnnotations.js +111 -1
  38. package/dist/editor/lineAnnotations.js.map +1 -1
  39. package/dist/editor/marker.d.ts +33 -0
  40. package/dist/editor/marker.d.ts.map +1 -0
  41. package/dist/editor/marker.js +185 -0
  42. package/dist/editor/marker.js.map +1 -0
  43. package/dist/editor/pieceTable.d.ts +8 -3
  44. package/dist/editor/pieceTable.d.ts.map +1 -1
  45. package/dist/editor/pieceTable.js +74 -12
  46. package/dist/editor/pieceTable.js.map +1 -1
  47. package/dist/editor/searchPanel.d.ts +12 -3
  48. package/dist/editor/searchPanel.d.ts.map +1 -1
  49. package/dist/editor/searchPanel.js +168 -54
  50. package/dist/editor/searchPanel.js.map +1 -1
  51. package/dist/editor/selection.d.ts +19 -3
  52. package/dist/editor/selection.d.ts.map +1 -1
  53. package/dist/editor/selection.js +188 -37
  54. package/dist/editor/selection.js.map +1 -1
  55. package/dist/editor/{quickEdit.d.ts → selectionAction.d.ts} +8 -8
  56. package/dist/editor/selectionAction.d.ts.map +1 -0
  57. package/dist/editor/{quickEdit.js → selectionAction.js} +18 -18
  58. package/dist/editor/selectionAction.js.map +1 -0
  59. package/dist/editor/sprite.d.ts +4 -3
  60. package/dist/editor/sprite.d.ts.map +1 -1
  61. package/dist/editor/sprite.js +19 -5
  62. package/dist/editor/sprite.js.map +1 -1
  63. package/dist/editor/textDocument.d.ts +4 -4
  64. package/dist/editor/textDocument.d.ts.map +1 -1
  65. package/dist/editor/textDocument.js +7 -7
  66. package/dist/editor/textDocument.js.map +1 -1
  67. package/dist/editor/textMeasure.d.ts +1 -0
  68. package/dist/editor/textMeasure.d.ts.map +1 -1
  69. package/dist/editor/textMeasure.js +6 -0
  70. package/dist/editor/textMeasure.js.map +1 -1
  71. package/dist/editor/tokenzier.js +20 -9
  72. package/dist/editor/tokenzier.js.map +1 -1
  73. package/dist/editor/utils.d.ts +3 -1
  74. package/dist/editor/utils.d.ts.map +1 -1
  75. package/dist/editor/utils.js +16 -1
  76. package/dist/editor/utils.js.map +1 -1
  77. package/dist/highlighter/shared_highlighter.js +3 -29
  78. package/dist/highlighter/shared_highlighter.js.map +1 -1
  79. package/dist/highlighter/themes/attachResolvedThemes.js +4 -3
  80. package/dist/highlighter/themes/attachResolvedThemes.js.map +1 -1
  81. package/dist/highlighter/themes/cleanUpResolvedThemes.js +3 -2
  82. package/dist/highlighter/themes/cleanUpResolvedThemes.js.map +1 -1
  83. package/dist/highlighter/themes/constants.d.ts +1 -7
  84. package/dist/highlighter/themes/constants.d.ts.map +1 -1
  85. package/dist/highlighter/themes/constants.js +1 -4
  86. package/dist/highlighter/themes/constants.js.map +1 -1
  87. package/dist/highlighter/themes/getResolvedOrResolveTheme.js +2 -2
  88. package/dist/highlighter/themes/getResolvedOrResolveTheme.js.map +1 -1
  89. package/dist/highlighter/themes/getResolvedThemes.js +2 -8
  90. package/dist/highlighter/themes/getResolvedThemes.js.map +1 -1
  91. package/dist/highlighter/themes/hasResolvedThemes.js +2 -3
  92. package/dist/highlighter/themes/hasResolvedThemes.js.map +1 -1
  93. package/dist/highlighter/themes/registerCustomCSSVariableTheme.js +1 -1
  94. package/dist/highlighter/themes/registerCustomTheme.d.ts +5 -3
  95. package/dist/highlighter/themes/registerCustomTheme.d.ts.map +1 -1
  96. package/dist/highlighter/themes/registerCustomTheme.js +15 -5
  97. package/dist/highlighter/themes/registerCustomTheme.js.map +1 -1
  98. package/dist/highlighter/themes/resolveTheme.js +6 -27
  99. package/dist/highlighter/themes/resolveTheme.js.map +1 -1
  100. package/dist/highlighter/themes/resolveThemes.js +5 -12
  101. package/dist/highlighter/themes/resolveThemes.js.map +1 -1
  102. package/dist/highlighter/themes/themeResolution.d.ts +8 -0
  103. package/dist/highlighter/themes/themeResolution.d.ts.map +1 -0
  104. package/dist/highlighter/themes/themeResolution.js +22 -0
  105. package/dist/highlighter/themes/themeResolution.js.map +1 -0
  106. package/dist/highlighter/themes/themeResolver.d.ts +8 -0
  107. package/dist/highlighter/themes/themeResolver.d.ts.map +1 -0
  108. package/dist/highlighter/themes/themeResolver.js +8 -0
  109. package/dist/highlighter/themes/themeResolver.js.map +1 -0
  110. package/dist/index.d.ts +4 -4
  111. package/dist/index.js +3 -3
  112. package/dist/managers/InteractionManager.js +1 -1
  113. package/dist/managers/InteractionManager.js.map +1 -1
  114. package/dist/managers/ResizeManager.js +1 -1
  115. package/dist/managers/ResizeManager.js.map +1 -1
  116. package/dist/react/CodeView.js +1 -1
  117. package/dist/react/index.d.ts +2 -2
  118. package/dist/react/utils/useFileDiffInstance.js +1 -0
  119. package/dist/react/utils/useFileDiffInstance.js.map +1 -1
  120. package/dist/renderers/DiffHunksRenderer.d.ts +6 -2
  121. package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
  122. package/dist/renderers/DiffHunksRenderer.js +183 -12
  123. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  124. package/dist/renderers/FileRenderer.d.ts +2 -2
  125. package/dist/renderers/FileRenderer.d.ts.map +1 -1
  126. package/dist/renderers/FileRenderer.js +17 -5
  127. package/dist/renderers/FileRenderer.js.map +1 -1
  128. package/dist/ssr/FileDiffReact.js +1 -1
  129. package/dist/ssr/index.d.ts +2 -2
  130. package/dist/types.d.ts +25 -8
  131. package/dist/types.d.ts.map +1 -1
  132. package/dist/utils/getHighlighterThemeStyles.js +16 -12
  133. package/dist/utils/getHighlighterThemeStyles.js.map +1 -1
  134. package/dist/utils/includesFileAnnotations.d.ts +17 -0
  135. package/dist/utils/includesFileAnnotations.d.ts.map +1 -0
  136. package/dist/utils/includesFileAnnotations.js +19 -0
  137. package/dist/utils/includesFileAnnotations.js.map +1 -0
  138. package/dist/utils/parseMergeConflictDiffFromFile.js.map +1 -1
  139. package/dist/utils/parsePatchFiles.js +93 -4
  140. package/dist/utils/parsePatchFiles.js.map +1 -1
  141. package/dist/utils/renderDiffWithHighlighter.js +4 -2
  142. package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
  143. package/dist/utils/renderFileWithHighlighter.js +4 -2
  144. package/dist/utils/renderFileWithHighlighter.js.map +1 -1
  145. package/dist/utils/updateDiffHunks.d.ts +13 -0
  146. package/dist/utils/updateDiffHunks.d.ts.map +1 -0
  147. package/dist/utils/updateDiffHunks.js +171 -0
  148. package/dist/utils/updateDiffHunks.js.map +1 -0
  149. package/dist/utils/virtualDiffLayout.d.ts +2 -1
  150. package/dist/utils/virtualDiffLayout.d.ts.map +1 -1
  151. package/dist/utils/virtualDiffLayout.js +9 -1
  152. package/dist/utils/virtualDiffLayout.js.map +1 -1
  153. package/dist/worker/{wasm-BaDzIkIn.js → wasm-qE0LgnY3.js} +2 -2
  154. package/dist/worker/{wasm-BaDzIkIn.js.map → wasm-qE0LgnY3.js.map} +1 -1
  155. package/dist/worker/worker-portable.js +1016 -275
  156. package/dist/worker/worker-portable.js.map +1 -1
  157. package/dist/worker/worker.js +31 -19
  158. package/dist/worker/worker.js.map +1 -1
  159. package/package.json +5 -10
  160. package/dist/editor/quickEdit.d.ts.map +0 -1
  161. package/dist/editor/quickEdit.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsBaseComponent, DiffsComponentOptions, DiffsEditableComponent, DiffsEditor, DiffsEditorSelection, DiffsHighlighter, DiffsTextDocument, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlightedToken, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PendingCodeViewLayoutReset, PostRenderPhase, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectedLineRange, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs } from "../types.js";
1
+ import { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsBaseComponent, DiffsComponentOptions, DiffsEditableComponent, DiffsEditor, DiffsEditorSelection, DiffsHighlighter, DiffsTextDocument, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlightedToken, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PendingCodeViewLayoutReset, PostRenderPhase, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectedLineRange, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistration, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs } from "../types.js";
2
2
  import { WorkerInitializationRenderOptions, WorkerPoolOptions } from "../worker/types.js";
3
3
  import { FileOptions } from "../components/File.js";
4
4
  import { CodeView, CodeViewHandle, CodeViewProps, ControlledCodeViewProps, UncontrolledCodeViewProps } from "./CodeView.js";
@@ -18,4 +18,4 @@ import { templateRender } from "./utils/templateRender.js";
18
18
  import { useFileDiffInstance } from "./utils/useFileDiffInstance.js";
19
19
  import { useFileInstance } from "./utils/useFileInstance.js";
20
20
  import { useStableCallback } from "./utils/useStableCallback.js";
21
- export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeView, CodeViewDiffItem, CodeViewFileItem, CodeViewHandle, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewProps, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, ControlledCodeViewProps, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffBasePropsReact, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsBaseComponent, DiffsComponentOptions, DiffsEditableComponent, DiffsEditor, DiffsEditorSelection, DiffsHighlighter, DiffsTextDocument, DiffsThemeNames, EditorContext, EditorProvider, ExpansionDirections, ExtensionFormatMap, File, FileContents, FileDiff, FileDiffMetadata, FileDiffProps, FileHeaderRenderMode, FileOptions, FileProps, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, GutterUtilitySlotStyles, HighlightedToken, 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, PendingCodeViewLayoutReset, PostRenderPhase, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderMergeConflictActionContext, RenderMergeConflictActions, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectedLineRange, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, UncontrolledCodeViewProps, UnresolvedFile, UnresolvedFileProps, UnresolvedFileReactOptions, VirtualFileMetrics, VirtualWindowSpecs, Virtualizer, VirtualizerContext, WorkerInitializationRenderOptions, WorkerPoolContext, WorkerPoolContextProvider, WorkerPoolOptions, noopRender, renderDiffChildren, renderFileChildren, templateRender, useEditor, useFileDiffInstance, useFileInstance, useStableCallback, useVirtualizer, useWorkerPool };
21
+ export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeView, CodeViewDiffItem, CodeViewFileItem, CodeViewHandle, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewProps, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, ControlledCodeViewProps, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffBasePropsReact, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsBaseComponent, DiffsComponentOptions, DiffsEditableComponent, DiffsEditor, DiffsEditorSelection, DiffsHighlighter, DiffsTextDocument, DiffsThemeNames, EditorContext, EditorProvider, ExpansionDirections, ExtensionFormatMap, File, FileContents, FileDiff, FileDiffMetadata, FileDiffProps, FileHeaderRenderMode, FileOptions, FileProps, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, GutterUtilitySlotStyles, HighlightedToken, 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, PendingCodeViewLayoutReset, PostRenderPhase, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderMergeConflictActionContext, RenderMergeConflictActions, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectedLineRange, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistration, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, UncontrolledCodeViewProps, UnresolvedFile, UnresolvedFileProps, UnresolvedFileReactOptions, VirtualFileMetrics, VirtualWindowSpecs, Virtualizer, VirtualizerContext, WorkerInitializationRenderOptions, WorkerPoolContext, WorkerPoolContextProvider, WorkerPoolOptions, noopRender, renderDiffChildren, renderFileChildren, templateRender, useEditor, useFileDiffInstance, useFileInstance, useStableCallback, useVirtualizer, useWorkerPool };
@@ -97,6 +97,7 @@ function mergeFileDiffOptions({ options, controlledSelection, contentEditable, h
97
97
  enableGutterUtility: false,
98
98
  enableLineSelection: false,
99
99
  expandUnchanged: true,
100
+ diffStyle: "split",
100
101
  lineHoverHighlight: "disabled"
101
102
  };
102
103
  return merged;
@@ -1 +1 @@
1
- {"version":3,"file":"useFileDiffInstance.js","names":["merged: FileDiffOptions<LAnnotation>"],"sources":["../../../src/react/utils/useFileDiffInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n} from 'react';\n\nimport { FileDiff, type FileDiffOptions } from '../../components/FileDiff';\nimport { VirtualizedFileDiff } from '../../components/VirtualizedFileDiff';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type {\n DiffLineAnnotation,\n FileDiffMetadata,\n SelectedLineRange,\n VirtualFileMetrics,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport { noopRender } from '../constants';\nimport { useEditor } from '../EditorContext';\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 contentEditable: 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 contentEditable,\n}: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn {\n const simpleVirtualizer = useVirtualizer();\n const controlledSelection = selectedLines !== undefined;\n const poolManager = useContext(WorkerPoolContext);\n const editor = useEditor<LAnnotation>();\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 contentEditable,\n hasCustomHeader,\n hasEditor: editor !== undefined,\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 contentEditable,\n hasCustomHeader,\n hasEditor: editor !== undefined,\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 contentEditable,\n hasCustomHeader,\n hasEditor: editor !== undefined,\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 useIsometricEffect(() => {\n if (contentEditable && instanceRef.current != null) {\n if (editor === undefined) {\n throw new Error('FileDiff: Editor is not attached');\n }\n return editor.edit(instanceRef.current);\n }\n return undefined;\n }, [contentEditable, editor]);\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 contentEditable: boolean;\n hasEditor: boolean;\n hasCustomHeader: boolean;\n hasGutterRenderUtility: boolean;\n options: FileDiffOptions<LAnnotation> | undefined;\n}\n\nfunction mergeFileDiffOptions<LAnnotation>({\n options,\n controlledSelection,\n contentEditable,\n hasCustomHeader,\n hasEditor,\n hasGutterRenderUtility,\n}: MergeFileDiffOptionsProps<LAnnotation>):\n | FileDiffOptions<LAnnotation>\n | undefined {\n const needsEditorOptions = contentEditable && hasEditor;\n const needsReactOverrides =\n controlledSelection || hasGutterRenderUtility || hasCustomHeader;\n\n if (!needsReactOverrides && !needsEditorOptions) {\n return options;\n }\n\n let merged: FileDiffOptions<LAnnotation> = { ...options };\n\n if (needsReactOverrides) {\n merged = {\n ...merged,\n controlledSelection,\n renderCustomHeader: hasCustomHeader\n ? noopRender\n : options?.renderCustomHeader,\n renderGutterUtility: hasGutterRenderUtility\n ? noopRender\n : options?.renderGutterUtility,\n };\n }\n\n if (needsEditorOptions) {\n merged = {\n ...merged,\n useTokenTransformer: true,\n enableGutterUtility: false,\n enableLineSelection: false,\n expandUnchanged: true,\n lineHoverHighlight: 'disabled',\n };\n }\n\n return merged;\n}\n"],"mappings":";;;;;;;;;;;AAwBA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAoB9C,SAAgB,oBAAiC,EAC/C,UACA,SACA,iBACA,eACA,iBACA,SACA,wBACA,iBACA,mBACA,mBACmE;CACnE,MAAM,oBAAoB,gBAAgB;CAC1C,MAAM,sBAAsB,kBAAkB;CAC9C,MAAM,cAAc,WAAW,kBAAkB;CACjD,MAAM,SAAS,WAAwB;CACvC,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,WAAW,WAAW;IACtB;IACA;IACD,CAAC,EACF,mBACA,SACA,CAAC,oBAAoB,cAAc,QACnC,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AGH,KAAI,mBACF,UAAS;EACP,GAAG;EACH,qBAAqB;EACrB,qBAAqB;EACrB,qBAAqB;EACrB,iBAAiB;EACjB,oBAAoB;EACrB;AAGH,QAAO"}
1
+ {"version":3,"file":"useFileDiffInstance.js","names":["merged: FileDiffOptions<LAnnotation>"],"sources":["../../../src/react/utils/useFileDiffInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n} from 'react';\n\nimport { FileDiff, type FileDiffOptions } from '../../components/FileDiff';\nimport { VirtualizedFileDiff } from '../../components/VirtualizedFileDiff';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type {\n DiffLineAnnotation,\n FileDiffMetadata,\n SelectedLineRange,\n VirtualFileMetrics,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport { noopRender } from '../constants';\nimport { useEditor } from '../EditorContext';\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 contentEditable: 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 contentEditable,\n}: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn {\n const simpleVirtualizer = useVirtualizer();\n const controlledSelection = selectedLines !== undefined;\n const poolManager = useContext(WorkerPoolContext);\n const editor = useEditor<LAnnotation>();\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 contentEditable,\n hasCustomHeader,\n hasEditor: editor !== undefined,\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 contentEditable,\n hasCustomHeader,\n hasEditor: editor !== undefined,\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 contentEditable,\n hasCustomHeader,\n hasEditor: editor !== undefined,\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 useIsometricEffect(() => {\n if (contentEditable && instanceRef.current != null) {\n if (editor === undefined) {\n throw new Error('FileDiff: Editor is not attached');\n }\n return editor.edit(instanceRef.current);\n }\n return undefined;\n }, [contentEditable, editor]);\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 contentEditable: boolean;\n hasEditor: boolean;\n hasCustomHeader: boolean;\n hasGutterRenderUtility: boolean;\n options: FileDiffOptions<LAnnotation> | undefined;\n}\n\nfunction mergeFileDiffOptions<LAnnotation>({\n options,\n controlledSelection,\n contentEditable,\n hasCustomHeader,\n hasEditor,\n hasGutterRenderUtility,\n}: MergeFileDiffOptionsProps<LAnnotation>):\n | FileDiffOptions<LAnnotation>\n | undefined {\n const needsEditorOptions = contentEditable && hasEditor;\n const needsReactOverrides =\n controlledSelection || hasGutterRenderUtility || hasCustomHeader;\n\n if (!needsReactOverrides && !needsEditorOptions) {\n return options;\n }\n\n let merged: FileDiffOptions<LAnnotation> = { ...options };\n\n if (needsReactOverrides) {\n merged = {\n ...merged,\n controlledSelection,\n renderCustomHeader: hasCustomHeader\n ? noopRender\n : options?.renderCustomHeader,\n renderGutterUtility: hasGutterRenderUtility\n ? noopRender\n : options?.renderGutterUtility,\n };\n }\n\n if (needsEditorOptions) {\n merged = {\n ...merged,\n useTokenTransformer: true,\n enableGutterUtility: false,\n enableLineSelection: false,\n expandUnchanged: true,\n diffStyle: 'split',\n lineHoverHighlight: 'disabled',\n };\n }\n\n return merged;\n}\n"],"mappings":";;;;;;;;;;;AAwBA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAoB9C,SAAgB,oBAAiC,EAC/C,UACA,SACA,iBACA,eACA,iBACA,SACA,wBACA,iBACA,mBACA,mBACmE;CACnE,MAAM,oBAAoB,gBAAgB;CAC1C,MAAM,sBAAsB,kBAAkB;CAC9C,MAAM,cAAc,WAAW,kBAAkB;CACjD,MAAM,SAAS,WAAwB;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C,SACA,qBACA,iBACA,iBACA,WACA,0BAGY;CACZ,MAAM,qBAAqB,mBAAmB;CAC9C,MAAM,sBACJ,uBAAuB,0BAA0B;AAEnD,KAAI,CAAC,uBAAuB,CAAC,mBAC3B,QAAO;CAGT,IAAIA,SAAuC,EAAE,GAAG,SAAS;AAEzD,KAAI,oBACF,UAAS;EACP,GAAG;EACH;EACA,oBAAoB,kBAChB,aACA,SAAS;EACb,qBAAqB,yBACjB,aACA,SAAS;EACd;AAGH,KAAI,mBACF,UAAS;EACP,GAAG;EACH,qBAAqB;EACrB,qBAAqB;EACrB,qBAAqB;EACrB,iBAAiB;EACjB,WAAW;EACX,oBAAoB;EACrB;AAGH,QAAO"}
@@ -1,4 +1,4 @@
1
- import { AnnotationSpan, BaseDiffOptions, BaseDiffOptionsWithDefaults, CustomPreProperties, DiffLineAnnotation, DiffsHighlighter, ExpansionDirections, FileDiffMetadata, FileHeaderRenderMode, HunkData, HunkExpansionRegion, LineTypes, RenderDiffOptions, RenderRange, ThemedDiffResult } from "../types.js";
1
+ import { BaseDiffOptions, BaseDiffOptionsWithDefaults, CustomPreProperties, DiffLineAnnotation, DiffsHighlighter, DiffsTextDocument, ExpansionDirections, FileDiffMetadata, FileHeaderRenderMode, HighlightedToken, HunkData, HunkExpansionRegion, LineTypes, RenderDiffOptions, RenderRange, ThemedDiffResult } from "../types.js";
2
2
  import { WorkerPoolManager } from "../worker/WorkerPoolManager.js";
3
3
  import "../worker/index.js";
4
4
  import { DiffLineMetadata } from "../utils/iterateOverDiff.js";
@@ -85,6 +85,7 @@ declare class DiffHunksRenderer<LAnnotation = undefined> {
85
85
  constructor(options?: DiffHunksRendererOptions, onRenderUpdate?: (() => unknown) | undefined, workerManager?: WorkerPoolManager | undefined);
86
86
  cleanUp(): void;
87
87
  recycle(): void;
88
+ getRenderDiff(): FileDiffMetadata | undefined;
88
89
  clearRenderCache(): void;
89
90
  setOptions(options: DiffHunksRendererOptions): void;
90
91
  mergeOptions(options: Partial<DiffHunksRendererOptions>): void;
@@ -92,6 +93,8 @@ declare class DiffHunksRenderer<LAnnotation = undefined> {
92
93
  getExpandedHunk(hunkIndex: number): HunkExpansionRegion;
93
94
  getExpandedHunksMap(): Map<number, HunkExpansionRegion>;
94
95
  setLineAnnotations(lineAnnotations: DiffLineAnnotation<LAnnotation>[]): void;
96
+ updateRenderCache(dirtyLines: Map<number, Array<HighlightedToken>>, themeType: 'dark' | 'light'): void;
97
+ applyDocumentChange(textDocument: DiffsTextDocument): void;
95
98
  protected getUnifiedLineDecoration({
96
99
  lineType
97
100
  }: UnifiedLineDecorationProps): LineDecoration;
@@ -99,7 +102,7 @@ declare class DiffHunksRenderer<LAnnotation = undefined> {
99
102
  side,
100
103
  type
101
104
  }: SplitLineDecorationProps): LineDecoration;
102
- protected createAnnotationElement(span: AnnotationSpan): Element;
105
+ private createAnnotationElement;
103
106
  protected getUnifiedInjectedRowsForLine?: (ctx: RenderedLineContext) => UnifiedInjectedRowPlacement | undefined;
104
107
  protected getSplitInjectedRowsForLine?: (ctx: RenderedLineContext) => SplitInjectedRowPlacement | undefined;
105
108
  protected getOptionsWithDefaults(): DiffHunksRendererOptionsWithDefaults;
@@ -121,6 +124,7 @@ declare class DiffHunksRenderer<LAnnotation = undefined> {
121
124
  renderFullAST(result: HunksRenderResult, children?: ElementContent[]): Element;
122
125
  renderFullHTML(result: HunksRenderResult, tempChildren?: ElementContent[]): string;
123
126
  renderPartialHTML(children: ElementContent[], columnType?: 'unified' | 'deletions' | 'additions'): string;
127
+ private pushFileLevelAnnotations;
124
128
  private getAnnotations;
125
129
  private renderHeader;
126
130
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DiffHunksRenderer.d.ts","names":["ElementContent","Element","HASTElement","Properties","AnnotationSpan","BaseDiffOptions","BaseDiffOptionsWithDefaults","CustomPreProperties","DiffLineAnnotation","DiffsHighlighter","ExpansionDirections","FileDiffMetadata","FileHeaderRenderMode","HunkData","HunkExpansionRegion","LineTypes","RenderDiffOptions","RenderRange","ThemedDiffResult","DiffLineMetadata","WorkerPoolManager","DiffHunksRendererOptions","DiffHunksRendererOptionsWithDefaults","Omit","UnifiedLineDecorationProps","SplitLineDecorationProps","LineDecoration","RenderedLineContext","InjectedRow","SplitInjectedRow","UnifiedInjectedRowPlacement","SplitInjectedRowPlacement","HunksRenderResult","DiffHunksRenderer","LAnnotation","Partial","Map","lineType","side","type","Promise"],"sources":["../../src/renderers/DiffHunksRenderer.d.ts"],"sourcesContent":["import type { ElementContent, Element as HASTElement, Properties } from 'hast';\nimport type { AnnotationSpan, BaseDiffOptions, BaseDiffOptionsWithDefaults, CustomPreProperties, DiffLineAnnotation, DiffsHighlighter, ExpansionDirections, FileDiffMetadata, FileHeaderRenderMode, HunkData, HunkExpansionRegion, LineTypes, RenderDiffOptions, RenderRange, ThemedDiffResult } from '../types';\nimport type { DiffLineMetadata } from '../utils/iterateOverDiff';\nimport type { WorkerPoolManager } from '../worker';\nexport interface DiffHunksRendererOptions extends BaseDiffOptions {\n headerRenderMode?: FileHeaderRenderMode;\n}\nexport interface DiffHunksRendererOptionsWithDefaults extends Omit<BaseDiffOptionsWithDefaults, 'themeType'> {\n headerRenderMode: FileHeaderRenderMode;\n}\nexport interface UnifiedLineDecorationProps {\n type: 'context' | 'context-expanded' | 'change';\n lineType: LineTypes;\n additionLineIndex: number | undefined;\n deletionLineIndex: number | undefined;\n}\nexport interface SplitLineDecorationProps {\n side: 'deletions' | 'additions';\n type: 'context' | 'context-expanded' | 'change';\n lineIndex: number | undefined;\n}\nexport interface LineDecoration {\n gutterLineType: LineTypes;\n gutterProperties?: Properties;\n contentProperties?: Properties;\n}\nexport interface RenderedLineContext {\n type: 'context' | 'context-expanded' | 'change';\n hunkIndex: number;\n lineIndex: number;\n unifiedLineIndex: number;\n splitLineIndex: number;\n deletionLine?: DiffLineMetadata;\n additionLine?: DiffLineMetadata;\n}\nexport interface InjectedRow {\n content: HASTElement;\n gutter: HASTElement;\n}\nexport interface SplitInjectedRow {\n deletion: InjectedRow | undefined;\n addition: InjectedRow | undefined;\n}\nexport interface UnifiedInjectedRowPlacement {\n before?: InjectedRow[];\n after?: InjectedRow[];\n}\nexport interface SplitInjectedRowPlacement {\n before?: SplitInjectedRow[];\n after?: SplitInjectedRow[];\n}\nexport interface HunksRenderResult {\n unifiedGutterAST: ElementContent[] | undefined;\n unifiedContentAST: ElementContent[] | undefined;\n deletionsGutterAST: ElementContent[] | undefined;\n deletionsContentAST: ElementContent[] | undefined;\n additionsGutterAST: ElementContent[] | undefined;\n additionsContentAST: ElementContent[] | undefined;\n hunkData: HunkData[];\n css: string;\n preNode: HASTElement;\n headerElement: HASTElement | undefined;\n totalLines: number;\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n rowCount: number;\n bufferBefore: number;\n bufferAfter: number;\n}\nexport declare class DiffHunksRenderer<LAnnotation = undefined> {\n options: DiffHunksRendererOptions;\n private onRenderUpdate?;\n private workerManager?;\n readonly __id: string;\n private highlighter;\n private diff;\n private expandedHunks;\n private deletionAnnotations;\n private additionAnnotations;\n private computedLang;\n private renderCache;\n constructor(options?: DiffHunksRendererOptions, onRenderUpdate?: (() => unknown) | undefined, workerManager?: WorkerPoolManager | undefined);\n cleanUp(): void;\n recycle(): void;\n clearRenderCache(): void;\n setOptions(options: DiffHunksRendererOptions): void;\n mergeOptions(options: Partial<DiffHunksRendererOptions>): void;\n expandHunk(index: number, direction: ExpansionDirections, expansionLineCount?: number): void;\n getExpandedHunk(hunkIndex: number): HunkExpansionRegion;\n getExpandedHunksMap(): Map<number, HunkExpansionRegion>;\n setLineAnnotations(lineAnnotations: DiffLineAnnotation<LAnnotation>[]): void;\n protected getUnifiedLineDecoration({ lineType }: UnifiedLineDecorationProps): LineDecoration;\n protected getSplitLineDecoration({ side, type }: SplitLineDecorationProps): LineDecoration;\n protected createAnnotationElement(span: AnnotationSpan): HASTElement;\n protected getUnifiedInjectedRowsForLine?: (ctx: RenderedLineContext) => UnifiedInjectedRowPlacement | undefined;\n protected getSplitInjectedRowsForLine?: (ctx: RenderedLineContext) => SplitInjectedRowPlacement | undefined;\n protected getOptionsWithDefaults(): DiffHunksRendererOptionsWithDefaults;\n initializeHighlighter(): Promise<DiffsHighlighter>;\n hydrate(diff: FileDiffMetadata | undefined): void;\n private getRenderOptions;\n renderDiff(diff?: FileDiffMetadata | undefined, renderRange?: RenderRange): HunksRenderResult | undefined;\n asyncRender(diff: FileDiffMetadata, renderRange?: RenderRange): Promise<HunksRenderResult>;\n protected createPreElement(split: boolean, totalLines: number, customProperties?: CustomPreProperties): HASTElement;\n private asyncHighlight;\n private renderDiffWithHighlighter;\n onHighlightSuccess(diff: FileDiffMetadata, result: ThemedDiffResult, options: RenderDiffOptions, highlighted?: boolean): void;\n private getMatchingWorkerResultCache;\n private hasHighlightedRenderCache;\n onHighlightError(error: unknown): void;\n private getTokenizeMaxLength;\n private processDiffResult;\n renderCodeAST(type: 'unified' | 'deletions' | 'additions', result: HunksRenderResult): ElementContent[] | undefined;\n renderFullAST(result: HunksRenderResult, children?: ElementContent[]): HASTElement;\n renderFullHTML(result: HunksRenderResult, tempChildren?: ElementContent[]): string;\n renderPartialHTML(children: ElementContent[], columnType?: 'unified' | 'deletions' | 'additions'): string;\n private getAnnotations;\n private renderHeader;\n}\n//# sourceMappingURL=DiffHunksRenderer.d.ts.map"],"mappings":";;;;;;;UAIiBqB,wBAAAA,SAAiChB;qBAC3BO;;AADNS,UAGAC,oCAAAA,SAA6CC,IAHZlB,CAGiBC,2BAHF,EAAA,WAAA,CAAA,CAAA;EAGhDgB,gBAAAA,EACKV,oBADLU;;AACKV,UAELY,0BAAAA,CAFKZ;EADwCW,IAAAA,EAAAA,SAAAA,GAAAA,kBAAAA,GAAAA,QAAAA;EAAI,QAAA,EAKpDR,SALoD;EAGjDS,iBAAAA,EAAAA,MAAAA,GAAAA,SAA0B;EAM1BC,iBAAAA,EAAAA,MAAAA,GAAwB,SAAA;AAKzC;AACoBV,UANHU,wBAAAA,CAMGV;EAC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AAA,IAAAA;EAAkChC,gBAAAA,CAAAA,CAAAA,EAAAA,IAAAA;EAC7BA,UAAAA,CAAAA,OAAAA,EA7BRqB,wBA6BQrB,CAAAA,EAAAA,IAAAA;EAAc,YAAA,CAAA,OAAA,EA5BpBmC,OA4BoB,CA5BZd,wBA4BY,CAAA,CAAA,EAAA,IAAA;uCA3BLX;sCACDI;yBACbsB,YAAYtB;sCACCN,mBAAmB0B;;;KACNV,6BAA6BE;;;;KAC7BD,2BAA2BC;0CACpCtB,iBAAiBF;kDACTyB,wBAAwBG;gDAC1BH,wBAAwBI;sCAClCT;2BACXkB,QAAQ/B;gBACnBE;;oBAEIA,4CAA4CM,cAAce;oBAC1DrB,gCAAgCM,cAAcuB,QAAQR;oFACUzB,sBAAsBL;;;2BAG/ES,0BAA0BO,2BAA2BF;;;;;;qEAMXgB,oBAAoBhC;wBACjEgC,8BAA8BhC,mBAAmBE;yBAChD8B,kCAAkChC;8BAC7BA"}
1
+ {"version":3,"file":"DiffHunksRenderer.d.ts","names":["ElementContent","Element","HASTElement","Properties","BaseDiffOptions","BaseDiffOptionsWithDefaults","CustomPreProperties","DiffLineAnnotation","DiffsHighlighter","DiffsTextDocument","ExpansionDirections","FileDiffMetadata","FileHeaderRenderMode","HighlightedToken","HunkData","HunkExpansionRegion","LineTypes","RenderDiffOptions","RenderRange","ThemedDiffResult","DiffLineMetadata","WorkerPoolManager","DiffHunksRendererOptions","DiffHunksRendererOptionsWithDefaults","Omit","UnifiedLineDecorationProps","SplitLineDecorationProps","LineDecoration","RenderedLineContext","InjectedRow","SplitInjectedRow","UnifiedInjectedRowPlacement","SplitInjectedRowPlacement","HunksRenderResult","DiffHunksRenderer","LAnnotation","Partial","Map","Array","lineType","side","type","Promise"],"sources":["../../src/renderers/DiffHunksRenderer.d.ts"],"sourcesContent":["import type { ElementContent, Element as HASTElement, Properties } from 'hast';\nimport type { BaseDiffOptions, BaseDiffOptionsWithDefaults, CustomPreProperties, DiffLineAnnotation, DiffsHighlighter, DiffsTextDocument, ExpansionDirections, FileDiffMetadata, FileHeaderRenderMode, HighlightedToken, HunkData, HunkExpansionRegion, LineTypes, RenderDiffOptions, RenderRange, ThemedDiffResult } from '../types';\nimport type { DiffLineMetadata } from '../utils/iterateOverDiff';\nimport type { WorkerPoolManager } from '../worker';\nexport interface DiffHunksRendererOptions extends BaseDiffOptions {\n headerRenderMode?: FileHeaderRenderMode;\n}\nexport interface DiffHunksRendererOptionsWithDefaults extends Omit<BaseDiffOptionsWithDefaults, 'themeType'> {\n headerRenderMode: FileHeaderRenderMode;\n}\nexport interface UnifiedLineDecorationProps {\n type: 'context' | 'context-expanded' | 'change';\n lineType: LineTypes;\n additionLineIndex: number | undefined;\n deletionLineIndex: number | undefined;\n}\nexport interface SplitLineDecorationProps {\n side: 'deletions' | 'additions';\n type: 'context' | 'context-expanded' | 'change';\n lineIndex: number | undefined;\n}\nexport interface LineDecoration {\n gutterLineType: LineTypes;\n gutterProperties?: Properties;\n contentProperties?: Properties;\n}\nexport interface RenderedLineContext {\n type: 'context' | 'context-expanded' | 'change';\n hunkIndex: number;\n lineIndex: number;\n unifiedLineIndex: number;\n splitLineIndex: number;\n deletionLine?: DiffLineMetadata;\n additionLine?: DiffLineMetadata;\n}\nexport interface InjectedRow {\n content: HASTElement;\n gutter: HASTElement;\n}\nexport interface SplitInjectedRow {\n deletion: InjectedRow | undefined;\n addition: InjectedRow | undefined;\n}\nexport interface UnifiedInjectedRowPlacement {\n before?: InjectedRow[];\n after?: InjectedRow[];\n}\nexport interface SplitInjectedRowPlacement {\n before?: SplitInjectedRow[];\n after?: SplitInjectedRow[];\n}\nexport interface HunksRenderResult {\n unifiedGutterAST: ElementContent[] | undefined;\n unifiedContentAST: ElementContent[] | undefined;\n deletionsGutterAST: ElementContent[] | undefined;\n deletionsContentAST: ElementContent[] | undefined;\n additionsGutterAST: ElementContent[] | undefined;\n additionsContentAST: ElementContent[] | undefined;\n hunkData: HunkData[];\n css: string;\n preNode: HASTElement;\n headerElement: HASTElement | undefined;\n totalLines: number;\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n rowCount: number;\n bufferBefore: number;\n bufferAfter: number;\n}\nexport declare class DiffHunksRenderer<LAnnotation = undefined> {\n options: DiffHunksRendererOptions;\n private onRenderUpdate?;\n private workerManager?;\n readonly __id: string;\n private highlighter;\n private diff;\n private expandedHunks;\n private deletionAnnotations;\n private additionAnnotations;\n private computedLang;\n private renderCache;\n constructor(options?: DiffHunksRendererOptions, onRenderUpdate?: (() => unknown) | undefined, workerManager?: WorkerPoolManager | undefined);\n cleanUp(): void;\n recycle(): void;\n getRenderDiff(): FileDiffMetadata | undefined;\n clearRenderCache(): void;\n setOptions(options: DiffHunksRendererOptions): void;\n mergeOptions(options: Partial<DiffHunksRendererOptions>): void;\n expandHunk(index: number, direction: ExpansionDirections, expansionLineCount?: number): void;\n getExpandedHunk(hunkIndex: number): HunkExpansionRegion;\n getExpandedHunksMap(): Map<number, HunkExpansionRegion>;\n setLineAnnotations(lineAnnotations: DiffLineAnnotation<LAnnotation>[]): void;\n updateRenderCache(dirtyLines: Map<number, Array<HighlightedToken>>, themeType: 'dark' | 'light'): void;\n applyDocumentChange(textDocument: DiffsTextDocument): void;\n protected getUnifiedLineDecoration({ lineType }: UnifiedLineDecorationProps): LineDecoration;\n protected getSplitLineDecoration({ side, type }: SplitLineDecorationProps): LineDecoration;\n private createAnnotationElement;\n protected getUnifiedInjectedRowsForLine?: (ctx: RenderedLineContext) => UnifiedInjectedRowPlacement | undefined;\n protected getSplitInjectedRowsForLine?: (ctx: RenderedLineContext) => SplitInjectedRowPlacement | undefined;\n protected getOptionsWithDefaults(): DiffHunksRendererOptionsWithDefaults;\n initializeHighlighter(): Promise<DiffsHighlighter>;\n hydrate(diff: FileDiffMetadata | undefined): void;\n private getRenderOptions;\n renderDiff(diff?: FileDiffMetadata | undefined, renderRange?: RenderRange): HunksRenderResult | undefined;\n asyncRender(diff: FileDiffMetadata, renderRange?: RenderRange): Promise<HunksRenderResult>;\n protected createPreElement(split: boolean, totalLines: number, customProperties?: CustomPreProperties): HASTElement;\n private asyncHighlight;\n private renderDiffWithHighlighter;\n onHighlightSuccess(diff: FileDiffMetadata, result: ThemedDiffResult, options: RenderDiffOptions, highlighted?: boolean): void;\n private getMatchingWorkerResultCache;\n private hasHighlightedRenderCache;\n onHighlightError(error: unknown): void;\n private getTokenizeMaxLength;\n private processDiffResult;\n renderCodeAST(type: 'unified' | 'deletions' | 'additions', result: HunksRenderResult): ElementContent[] | undefined;\n renderFullAST(result: HunksRenderResult, children?: ElementContent[]): HASTElement;\n renderFullHTML(result: HunksRenderResult, tempChildren?: ElementContent[]): string;\n renderPartialHTML(children: ElementContent[], columnType?: 'unified' | 'deletions' | 'additions'): string;\n private pushFileLevelAnnotations;\n private getAnnotations;\n private renderHeader;\n}\n//# sourceMappingURL=DiffHunksRenderer.d.ts.map"],"mappings":";;;;;;;UAIiBsB,wBAAAA,SAAiClB;qBAC3BQ;;AADNU,UAGAC,oCAAAA,SAA6CC,IAHZpB,CAGiBC,2BAHF,EAAA,WAAA,CAAA,CAAA;EAGhDkB,gBAAAA,EACKX,oBADLW;;AACKX,UAELa,0BAAAA,CAFKb;EADwCY,IAAAA,EAAAA,SAAAA,GAAAA,kBAAAA,GAAAA,QAAAA;EAAI,QAAA,EAKpDR,SALoD;EAGjDS,iBAAAA,EAAAA,MAAAA,GAAAA,SAA0B;EAM1BC,iBAAAA,EAAAA,MAAAA,GAAwB,SAAA;AAKzC;AACoBV,UANHU,wBAAAA,CAMGV;EACGb,IAAAA,EAAAA,WAAAA,GAAAA,WAAAA;EACCA,IAAAA,EAAAA,SAAAA,GAAAA,kBAAAA,GAAAA,QAAAA;EAAU,SAAA,EAAA,MAAA,GAAA,SAAA;AAElC;AASiB0B,UAdAF,cAAAA,CAeJzB;EAGI4B,cAAAA,EAjBGd,SAiBa;EAIhBe,gBAAAA,CAAAA,EApBM5B,UAoBN4B;EAIAC,iBAAAA,CAAAA,EA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AAAA,IAAAA;EAC7BA,UAAAA,CAAAA,KAAAA,EAAAA,MAAAA,EAAAA,SAAAA,EA7BSU,mBA6BTV,EAAAA,kBAAAA,CAAAA,EAAAA,MAAAA,CAAAA,EAAAA,IAAAA;EAAc,eAAA,CAAA,SAAA,EAAA,MAAA,CAAA,EA5BNe,mBA4BM;yBA3BnBsB,YAAYtB;sCACCR,mBAAmB4B;gCACzBE,YAAYC,MAAMzB;oCACdJ;;;KACegB,6BAA6BE;;;;KAC7BD,2BAA2BC;;kDAE5BC,wBAAwBG;gDAC1BH,wBAAwBI;sCAClCT;2BACXmB,QAAQlC;gBACnBG;;oBAEIA,4CAA4CO,cAAce;oBAC1DtB,gCAAgCO,cAAcwB,QAAQT;oFACU3B,sBAAsBJ;;;2BAG/ES,0BAA0BQ,2BAA2BF;;;;;;qEAMXgB,oBAAoBjC;wBACjEiC,8BAA8BjC,mBAAmBE;yBAChD+B,kCAAkCjC;8BAC7BA"}
@@ -1,4 +1,5 @@
1
1
  import { DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH } from "../constants.js";
2
+ import { FILE_ANNOTATION_HUNK_INDEX, FILE_ANNOTATION_LINE_INDEX, getFileAnnotations, shouldRenderFileAnnotations } from "../utils/includesFileAnnotations.js";
2
3
  import { createGutterGap, createGutterItem, createGutterWrapper, createHastElement } from "../utils/hast_utils.js";
3
4
  import { areLanguagesAttached } from "../highlighter/languages/areLanguagesAttached.js";
4
5
  import { getHighlighterIfLoaded, getSharedHighlighter } from "../highlighter/shared_highlighter.js";
@@ -15,6 +16,7 @@ import { shouldUseTokenTransformer } from "../utils/shouldUseTokenTransformer.js
15
16
  import { areDiffTargetsEqual } from "../utils/areDiffTargetsEqual.js";
16
17
  import { getTrailingContextRangeSize } from "../utils/virtualDiffLayout.js";
17
18
  import { iterateOverDiff } from "../utils/iterateOverDiff.js";
19
+ import { cleanLastNewline } from "../utils/cleanLastNewline.js";
18
20
  import { areDiffRenderOptionsEqual } from "../utils/areDiffRenderOptionsEqual.js";
19
21
  import { createEmptyRowBuffer } from "../utils/createEmptyRowBuffer.js";
20
22
  import { createNoNewlineElement } from "../utils/createNoNewlineElement.js";
@@ -24,6 +26,8 @@ import { getTotalLineCountFromHunks } from "../utils/getTotalLineCountFromHunks.
24
26
  import { isDefaultRenderRange } from "../utils/isDefaultRenderRange.js";
25
27
  import { isDiffPlainText } from "../utils/isDiffPlainText.js";
26
28
  import { renderDiffWithHighlighter } from "../utils/renderDiffWithHighlighter.js";
29
+ import { splitFileContents } from "../utils/splitFileContents.js";
30
+ import { recomputeDiffHunks, updateDiffHunks } from "../utils/updateDiffHunks.js";
27
31
  import { toHtml } from "hast-util-to-html";
28
32
 
29
33
  //#region src/renderers/DiffHunksRenderer.ts
@@ -57,8 +61,13 @@ var DiffHunksRenderer = class {
57
61
  this.deletionAnnotations = {};
58
62
  this.workerManager?.cleanUpTasks(this);
59
63
  }
64
+ getRenderDiff() {
65
+ return this.renderCache?.diff ?? this.diff;
66
+ }
60
67
  clearRenderCache() {
68
+ const renderCache = this.renderCache;
61
69
  this.renderCache = void 0;
70
+ if (renderCache != null && renderCache.isDirty === true && renderCache.diff.cacheKey != null) this.workerManager?.evictDiffFromCache(renderCache.diff.cacheKey);
62
71
  }
63
72
  setOptions(options) {
64
73
  this.options = options;
@@ -100,16 +109,92 @@ var DiffHunksRenderer = class {
100
109
  arr.push(annotation);
101
110
  }
102
111
  }
112
+ updateRenderCache(dirtyLines, themeType) {
113
+ if (this.renderCache == null) return;
114
+ const { result, diff } = this.renderCache;
115
+ if (result == null) return;
116
+ if (diff.isPartial) throw new Error("Could not update render cache for partial diff");
117
+ const hastLines = result.code.additionLines;
118
+ const changedAdditionLines = [];
119
+ for (const [line, tokens] of dirtyLines) {
120
+ const prevProps = hastLines[line]?.properties ?? {};
121
+ const lineText = tokens.map((a) => a[2]).join("");
122
+ const canSyncDiffLine = line < diff.additionLines.length;
123
+ const prevLine = canSyncDiffLine ? diff.additionLines[line] ?? "" : "";
124
+ const prevText = cleanLastNewline(prevLine);
125
+ if (canSyncDiffLine) {
126
+ diff.additionLines[line] = applyLineTextWithNewline(prevLine, lineText);
127
+ if (prevText !== lineText) changedAdditionLines.push(line);
128
+ }
129
+ hastLines[line] = {
130
+ type: "element",
131
+ tagName: "div",
132
+ properties: {
133
+ "data-line": prevProps["data-line"] ?? line + 1,
134
+ "data-line-index": prevProps["data-line-index"] ?? line,
135
+ "data-line-type": prevProps["data-line-type"] ?? "context"
136
+ },
137
+ children: tokens.map(([char, fg, text]) => {
138
+ if (char === 0 && fg === "") {
139
+ if (text === "") return {
140
+ type: "element",
141
+ tagName: "br",
142
+ properties: {},
143
+ children: []
144
+ };
145
+ return {
146
+ type: "text",
147
+ value: text
148
+ };
149
+ }
150
+ return {
151
+ type: "element",
152
+ tagName: "span",
153
+ properties: {
154
+ "data-char": char,
155
+ style: `--diffs-token-${themeType}:${fg};`
156
+ },
157
+ children: [{
158
+ type: "text",
159
+ value: text
160
+ }]
161
+ };
162
+ })
163
+ };
164
+ }
165
+ if (changedAdditionLines.length > 0) Object.assign(diff, updateDiffHunks(diff, changedAdditionLines, this.options.parseDiffOptions));
166
+ result.baseThemeType = themeType;
167
+ this.renderCache.isDirty = true;
168
+ }
169
+ applyDocumentChange(textDocument) {
170
+ if (this.renderCache == null) return;
171
+ const { diff, result } = this.renderCache;
172
+ if (result == null) return;
173
+ diff.additionLines = splitFileContents(textDocument.getText());
174
+ const newLength = diff.additionLines.length;
175
+ const additionHastLines = result.code.additionLines;
176
+ const prevLen = additionHastLines.length;
177
+ if (newLength < prevLen) additionHastLines.length = newLength;
178
+ for (let i = prevLen; i < newLength; i++) additionHastLines[i] ??= createPlainAdditionLineElement(i, textDocument);
179
+ if (!diff.isPartial) Object.assign(diff, recomputeDiffHunks(diff, this.options.parseDiffOptions));
180
+ this.renderCache.isDirty = true;
181
+ }
103
182
  getUnifiedLineDecoration({ lineType }) {
104
- return { gutterLineType: lineType };
183
+ return {
184
+ gutterLineType: lineType,
185
+ contentProperties: { "data-line-type": lineType }
186
+ };
105
187
  }
106
188
  getSplitLineDecoration({ side, type }) {
107
- if (type !== "change") return { gutterLineType: type };
108
- return { gutterLineType: side === "deletions" ? "change-deletion" : "change-addition" };
189
+ const lineType = type === "change" ? side === "deletions" ? "change-deletion" : "change-addition" : type;
190
+ return {
191
+ gutterLineType: lineType,
192
+ contentProperties: { "data-line-type": lineType }
193
+ };
109
194
  }
110
- createAnnotationElement(span) {
195
+ createAnnotationElement = (span) => {
111
196
  return createAnnotationElement(span);
112
- }
197
+ };
113
198
  getOptionsWithDefaults() {
114
199
  const { diffIndicators = "bars", diffStyle = "split", disableBackground = false, disableFileHeader = false, disableLineNumbers = false, disableVirtualizationBuffers = false, collapsed = false, expandUnchanged = false, collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, expansionLineCount = 100, hunkSeparators = "line-info", lineDiffType = "word-alt", maxLineDiffLength = 1e3, overflow = "scroll", stickyHeader = false, theme = DEFAULT_THEMES, headerRenderMode = "default", tokenizeMaxLineLength = 1e3, tokenizeMaxLength = DEFAULT_TOKENIZE_MAX_LENGTH, useTokenTransformer = false, useCSSClasses = false } = this.options;
115
200
  return {
@@ -310,6 +395,7 @@ var DiffHunksRenderer = class {
310
395
  }
311
396
  processDiffResult(fileDiff, renderRange, { code, themeStyles, baseThemeType }) {
312
397
  const { diffStyle, disableFileHeader, expandUnchanged, expansionLineCount, collapsedContextThreshold, hunkSeparators } = this.getOptionsWithDefaults();
398
+ const isRenderCacheDirty = this.renderCache?.isDirty ?? false;
313
399
  this.diff = fileDiff;
314
400
  const unified = diffStyle === "unified";
315
401
  let additionsContentAST = [];
@@ -384,6 +470,7 @@ var DiffHunksRenderer = class {
384
470
  pushSeparator("additions", props, context);
385
471
  }
386
472
  }
473
+ this.pushFileLevelAnnotations(fileDiff, diffStyle, renderRange, context);
387
474
  iterateOverDiff({
388
475
  diff: fileDiff,
389
476
  diffStyle,
@@ -432,8 +519,14 @@ var DiffHunksRenderer = class {
432
519
  deletionLineIndex: deletionLine?.lineIndex
433
520
  });
434
521
  pushGutterLineNumber("unified", lineDecoration.gutterLineType, additionLine != null ? additionLine.lineNumber : deletionLine.lineNumber, `${unifiedLineIndex},${splitLineIndex}`, lineDecoration.gutterProperties);
435
- if (additionLineContent != null) additionLineContent = withContentProperties(additionLineContent, lineDecoration.contentProperties);
436
- else if (deletionLineContent != null) deletionLineContent = withContentProperties(deletionLineContent, lineDecoration.contentProperties);
522
+ if (additionLineContent != null) additionLineContent = withContentProperties(additionLineContent, lineDecoration.contentProperties, isRenderCacheDirty && additionLine != null ? {
523
+ "data-line": additionLine.lineNumber,
524
+ "data-line-index": `${unifiedLineIndex},${splitLineIndex}`
525
+ } : void 0);
526
+ else if (deletionLineContent != null) deletionLineContent = withContentProperties(deletionLineContent, lineDecoration.contentProperties, isRenderCacheDirty && deletionLine != null ? {
527
+ "data-line": deletionLine.lineNumber,
528
+ "data-line-index": `${unifiedLineIndex},${splitLineIndex}`
529
+ } : void 0);
437
530
  pushLineWithAnnotation({
438
531
  diffStyle: "unified",
439
532
  type,
@@ -478,12 +571,18 @@ var DiffHunksRenderer = class {
478
571
  const annotationSpans = this.getAnnotations("split", deletionLine?.lineNumber, additionLine?.lineNumber, hunkIndex, lineIndex);
479
572
  if (annotationSpans != null && pendingSplitContext.size > 0) pendingSplitContext.flush();
480
573
  if (deletionLine != null) {
481
- const deletionLineDecorated = withContentProperties(deletionLineContent, deletionLineDecoration.contentProperties);
574
+ const deletionLineDecorated = withContentProperties(deletionLineContent, deletionLineDecoration.contentProperties, isRenderCacheDirty ? {
575
+ "data-line": deletionLine.lineNumber,
576
+ "data-line-index": `${deletionLine.unifiedLineIndex},${splitLineIndex}`
577
+ } : void 0);
482
578
  pushGutterLineNumber("deletions", deletionLineDecoration.gutterLineType, deletionLine.lineNumber, `${deletionLine.unifiedLineIndex},${splitLineIndex}`, deletionLineDecoration.gutterProperties);
483
579
  if (deletionLineDecorated != null) deletionLineContent = deletionLineDecorated;
484
580
  }
485
581
  if (additionLine != null) {
486
- const additionLineDecorated = withContentProperties(additionLineContent, additionLineDecoration.contentProperties);
582
+ const additionLineDecorated = withContentProperties(additionLineContent, additionLineDecoration.contentProperties, isRenderCacheDirty ? {
583
+ "data-line": additionLine.lineNumber,
584
+ "data-line-index": `${additionLine.unifiedLineIndex},${splitLineIndex}`
585
+ } : void 0);
487
586
  pushGutterLineNumber("additions", additionLineDecoration.gutterLineType, additionLine.lineNumber, `${additionLine.unifiedLineIndex},${splitLineIndex}`, additionLineDecoration.gutterProperties);
488
587
  if (additionLineDecorated != null) additionLineContent = additionLineDecorated;
489
588
  }
@@ -642,6 +741,48 @@ var DiffHunksRenderer = class {
642
741
  }
643
742
  }));
644
743
  }
744
+ pushFileLevelAnnotations(fileDiff, diffStyle, renderRange, context) {
745
+ if (!shouldRenderFileAnnotations(renderRange)) return;
746
+ const deletionAnnotationNames = fileDiff.type !== "new" ? getAnnotationNames(getFileAnnotations(this.deletionAnnotations)) : [];
747
+ const additionAnnotationNames = fileDiff.type !== "deleted" ? getAnnotationNames(getFileAnnotations(this.additionAnnotations)) : [];
748
+ if (deletionAnnotationNames.length === 0 && additionAnnotationNames.length === 0) return;
749
+ const hunkIndex = FILE_ANNOTATION_HUNK_INDEX;
750
+ const lineIndex = FILE_ANNOTATION_LINE_INDEX;
751
+ const { createAnnotationElement: createAnnotationElement$1 } = this;
752
+ if (diffStyle === "unified") {
753
+ pushLineWithAnnotation({
754
+ diffStyle,
755
+ type: "context",
756
+ unifiedSpan: {
757
+ type: "annotation",
758
+ hunkIndex,
759
+ lineIndex,
760
+ annotations: deletionAnnotationNames.concat(additionAnnotationNames)
761
+ },
762
+ createAnnotationElement: createAnnotationElement$1,
763
+ context
764
+ });
765
+ return;
766
+ }
767
+ pushLineWithAnnotation({
768
+ diffStyle,
769
+ type: "context",
770
+ deletionSpan: {
771
+ type: "annotation",
772
+ hunkIndex,
773
+ lineIndex,
774
+ annotations: deletionAnnotationNames
775
+ },
776
+ additionSpan: {
777
+ type: "annotation",
778
+ hunkIndex,
779
+ lineIndex,
780
+ annotations: additionAnnotationNames
781
+ },
782
+ createAnnotationElement: createAnnotationElement$1,
783
+ context
784
+ });
785
+ }
645
786
  getAnnotations(type, deletionLineNumber, additionLineNumber, hunkIndex, lineIndex) {
646
787
  const deletionSpan = {
647
788
  type: "annotation",
@@ -676,6 +817,9 @@ var DiffHunksRenderer = class {
676
817
  });
677
818
  }
678
819
  };
820
+ function getAnnotationNames(annotations) {
821
+ return annotations?.map((annotation) => getLineAnnotationName(annotation)) ?? [];
822
+ }
679
823
  function getModifiedLinesString(lines) {
680
824
  return `${lines} unmodified line${lines > 1 ? "s" : ""}`;
681
825
  }
@@ -806,16 +950,43 @@ function pushSeparator(type, { hunkIndex, collapsedLines, rangeSize, hunkSpecs,
806
950
  } : void 0
807
951
  });
808
952
  }
809
- function withContentProperties(lineNode, contentProperties) {
810
- if (lineNode == null || lineNode.type !== "element" || contentProperties == null) return lineNode;
953
+ function withContentProperties(lineNode, contentProperties, extendProperties) {
954
+ if (lineNode == null || lineNode.type !== "element" || contentProperties == null && extendProperties == null) return lineNode;
811
955
  return {
812
956
  ...lineNode,
813
957
  properties: {
814
958
  ...lineNode.properties,
815
- ...contentProperties
959
+ ...contentProperties,
960
+ ...extendProperties
816
961
  }
817
962
  };
818
963
  }
964
+ function createPlainAdditionLineElement(lineIndex, textDocument) {
965
+ return {
966
+ type: "element",
967
+ tagName: "div",
968
+ properties: {
969
+ "data-line": lineIndex + 1,
970
+ "data-line-index": `${lineIndex},${lineIndex}`,
971
+ "data-line-type": "context"
972
+ },
973
+ children: [{
974
+ type: "element",
975
+ tagName: "span",
976
+ properties: { "data-char": 0 },
977
+ children: [{
978
+ type: "text",
979
+ value: textDocument.getLineText(lineIndex)
980
+ }]
981
+ }]
982
+ };
983
+ }
984
+ function applyLineTextWithNewline(line, lineText) {
985
+ if (line.endsWith("\r\n")) return lineText + "\r\n";
986
+ if (line.endsWith("\r")) return lineText + "\r";
987
+ if (line.endsWith("\n")) return lineText + "\n";
988
+ return lineText;
989
+ }
819
990
  function isDiffMassive(diff, tokenizeMaxLength) {
820
991
  return Math.max(diff.additionLines.length, diff.deletionLines.length) > tokenizeMaxLength;
821
992
  }