@pierre/diffs 1.3.6 → 1.4.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 (254) hide show
  1. package/dist/components/CodeView.d.ts +113 -68
  2. package/dist/components/CodeView.d.ts.map +1 -1
  3. package/dist/components/CodeView.js +153 -58
  4. package/dist/components/CodeView.js.map +1 -1
  5. package/dist/components/File.d.ts +75 -15
  6. package/dist/components/File.d.ts.map +1 -1
  7. package/dist/components/File.js +223 -62
  8. package/dist/components/File.js.map +1 -1
  9. package/dist/components/FileDiff.d.ts +97 -21
  10. package/dist/components/FileDiff.d.ts.map +1 -1
  11. package/dist/components/FileDiff.js +400 -100
  12. package/dist/components/FileDiff.js.map +1 -1
  13. package/dist/components/UnresolvedFile.d.ts +2 -2
  14. package/dist/components/UnresolvedFile.d.ts.map +1 -1
  15. package/dist/components/UnresolvedFile.js +2 -2
  16. package/dist/components/UnresolvedFile.js.map +1 -1
  17. package/dist/components/VirtualizedFile.d.ts +16 -7
  18. package/dist/components/VirtualizedFile.d.ts.map +1 -1
  19. package/dist/components/VirtualizedFile.js +140 -51
  20. package/dist/components/VirtualizedFile.js.map +1 -1
  21. package/dist/components/VirtualizedFileDiff.d.ts +14 -8
  22. package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
  23. package/dist/components/VirtualizedFileDiff.js +183 -93
  24. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  25. package/dist/components/VirtulizerDevelopment.d.ts +1 -1
  26. package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
  27. package/dist/edit/index.d.ts +7 -4
  28. package/dist/edit/index.js +5 -1
  29. package/dist/editor/EditStateManager.d.ts +56 -0
  30. package/dist/editor/EditStateManager.d.ts.map +1 -0
  31. package/dist/editor/EditStateManager.js +135 -0
  32. package/dist/editor/EditStateManager.js.map +1 -0
  33. package/dist/editor/cloneRetainedDiffSessionSnapshot.d.ts +7 -0
  34. package/dist/editor/cloneRetainedDiffSessionSnapshot.d.ts.map +1 -0
  35. package/dist/editor/cloneRetainedDiffSessionSnapshot.js +16 -0
  36. package/dist/editor/cloneRetainedDiffSessionSnapshot.js.map +1 -0
  37. package/dist/editor/editPrediction.d.ts +76 -0
  38. package/dist/editor/editPrediction.d.ts.map +1 -0
  39. package/dist/editor/editPrediction.js +365 -0
  40. package/dist/editor/editPrediction.js.map +1 -0
  41. package/dist/editor/editStack.d.ts +19 -40
  42. package/dist/editor/editStack.d.ts.map +1 -1
  43. package/dist/editor/editStack.js +67 -4
  44. package/dist/editor/editStack.js.map +1 -1
  45. package/dist/editor/editor.d.ts +118 -29
  46. package/dist/editor/editor.d.ts.map +1 -1
  47. package/dist/editor/editor.js +1103 -383
  48. package/dist/editor/editor.js.map +1 -1
  49. package/dist/editor/editor2.js +1 -1
  50. package/dist/editor/languages.d.ts +3 -3
  51. package/dist/editor/languages.d.ts.map +1 -1
  52. package/dist/editor/languages.js.map +1 -1
  53. package/dist/editor/lineAnnotations.d.ts +3 -3
  54. package/dist/editor/lineAnnotations.d.ts.map +1 -1
  55. package/dist/editor/lineAnnotations.js +16 -7
  56. package/dist/editor/lineAnnotations.js.map +1 -1
  57. package/dist/editor/marker.d.ts +2 -2
  58. package/dist/editor/marker.d.ts.map +1 -1
  59. package/dist/editor/marker.js.map +1 -1
  60. package/dist/editor/matchBrackets.d.ts +2 -2
  61. package/dist/editor/matchBrackets.d.ts.map +1 -1
  62. package/dist/editor/matchBrackets.js.map +1 -1
  63. package/dist/editor/pieceTable.d.ts +1 -1
  64. package/dist/editor/pieceTable.js.map +1 -1
  65. package/dist/editor/searchPanel.d.ts +2 -2
  66. package/dist/editor/searchPanel.js +1 -1
  67. package/dist/editor/searchPanel.js.map +1 -1
  68. package/dist/editor/selection.d.ts +32 -23
  69. package/dist/editor/selection.d.ts.map +1 -1
  70. package/dist/editor/selection.js +3 -3
  71. package/dist/editor/selection.js.map +1 -1
  72. package/dist/editor/selectionAction.d.ts +3 -3
  73. package/dist/editor/selectionAction.d.ts.map +1 -1
  74. package/dist/editor/selectionAction.js.map +1 -1
  75. package/dist/editor/textDocument.d.ts +11 -8
  76. package/dist/editor/textDocument.d.ts.map +1 -1
  77. package/dist/editor/textDocument.js +28 -5
  78. package/dist/editor/textDocument.js.map +1 -1
  79. package/dist/editor/textDocumentChangeTransaction.d.ts +15 -0
  80. package/dist/editor/textDocumentChangeTransaction.d.ts.map +1 -0
  81. package/dist/editor/textDocumentChangeTransaction.js +12 -0
  82. package/dist/editor/textDocumentChangeTransaction.js.map +1 -0
  83. package/dist/editor/textMeasure.d.ts +5 -0
  84. package/dist/editor/textMeasure.d.ts.map +1 -1
  85. package/dist/editor/textMeasure.js +10 -0
  86. package/dist/editor/textMeasure.js.map +1 -1
  87. package/dist/editor/tokenizer.d.ts +1 -1
  88. package/dist/editor/tokenizer.js.map +1 -1
  89. package/dist/editor/types.d.ts +267 -0
  90. package/dist/editor/types.d.ts.map +1 -0
  91. package/dist/editor/types.js +0 -0
  92. package/dist/editor/utils.d.ts +2 -1
  93. package/dist/editor/utils.d.ts.map +1 -1
  94. package/dist/editor/utils.js +4 -1
  95. package/dist/editor/utils.js.map +1 -1
  96. package/dist/index.d.ts +8 -6
  97. package/dist/index.js +9 -8
  98. package/dist/managers/InteractionManager.d.ts.map +1 -1
  99. package/dist/managers/InteractionManager.js +7 -0
  100. package/dist/managers/InteractionManager.js.map +1 -1
  101. package/dist/react/CodeView.d.ts +36 -25
  102. package/dist/react/CodeView.d.ts.map +1 -1
  103. package/dist/react/CodeView.js +15 -14
  104. package/dist/react/CodeView.js.map +1 -1
  105. package/dist/react/EditContext.d.ts +8 -11
  106. package/dist/react/EditContext.d.ts.map +1 -1
  107. package/dist/react/EditContext.js +2 -9
  108. package/dist/react/EditContext.js.map +1 -1
  109. package/dist/react/File.d.ts +10 -6
  110. package/dist/react/File.d.ts.map +1 -1
  111. package/dist/react/File.js +8 -4
  112. package/dist/react/File.js.map +1 -1
  113. package/dist/react/FileDiff.d.ts +10 -5
  114. package/dist/react/FileDiff.d.ts.map +1 -1
  115. package/dist/react/FileDiff.js +8 -4
  116. package/dist/react/FileDiff.js.map +1 -1
  117. package/dist/react/MultiFileDiff.d.ts +8 -5
  118. package/dist/react/MultiFileDiff.d.ts.map +1 -1
  119. package/dist/react/MultiFileDiff.js +8 -12
  120. package/dist/react/MultiFileDiff.js.map +1 -1
  121. package/dist/react/PatchDiff.d.ts +7 -4
  122. package/dist/react/PatchDiff.d.ts.map +1 -1
  123. package/dist/react/PatchDiff.js +8 -4
  124. package/dist/react/PatchDiff.js.map +1 -1
  125. package/dist/react/UnresolvedFile.d.ts +3 -3
  126. package/dist/react/UnresolvedFile.d.ts.map +1 -1
  127. package/dist/react/UnresolvedFile.js.map +1 -1
  128. package/dist/react/index.d.ts +8 -5
  129. package/dist/react/types.d.ts +46 -9
  130. package/dist/react/types.d.ts.map +1 -1
  131. package/dist/react/utils/renderDiffChildren.d.ts +14 -12
  132. package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
  133. package/dist/react/utils/renderDiffChildren.js +2 -2
  134. package/dist/react/utils/renderDiffChildren.js.map +1 -1
  135. package/dist/react/utils/renderFileChildren.d.ts +14 -12
  136. package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
  137. package/dist/react/utils/renderFileChildren.js +2 -2
  138. package/dist/react/utils/renderFileChildren.js.map +1 -1
  139. package/dist/react/utils/useFileDiffInstance.d.ts +22 -10
  140. package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
  141. package/dist/react/utils/useFileDiffInstance.js +112 -22
  142. package/dist/react/utils/useFileDiffInstance.js.map +1 -1
  143. package/dist/react/utils/useFileInstance.d.ts +15 -9
  144. package/dist/react/utils/useFileInstance.d.ts.map +1 -1
  145. package/dist/react/utils/useFileInstance.js +84 -25
  146. package/dist/react/utils/useFileInstance.js.map +1 -1
  147. package/dist/renderers/DiffHunksRenderer.d.ts +30 -15
  148. package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
  149. package/dist/renderers/DiffHunksRenderer.js +172 -108
  150. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  151. package/dist/renderers/FileRenderer.d.ts +27 -11
  152. package/dist/renderers/FileRenderer.d.ts.map +1 -1
  153. package/dist/renderers/FileRenderer.js +138 -64
  154. package/dist/renderers/FileRenderer.js.map +1 -1
  155. package/dist/renderers/UnresolvedFileHunksRenderer.d.ts +2 -2
  156. package/dist/renderers/UnresolvedFileHunksRenderer.d.ts.map +1 -1
  157. package/dist/renderers/UnresolvedFileHunksRenderer.js +2 -2
  158. package/dist/renderers/UnresolvedFileHunksRenderer.js.map +1 -1
  159. package/dist/shiki-stream/tokenizer.d.ts.map +1 -1
  160. package/dist/shiki-stream/tokenizer.js +2 -1
  161. package/dist/shiki-stream/tokenizer.js.map +1 -1
  162. package/dist/ssr/index.d.ts +2 -2
  163. package/dist/ssr/preloadDiffs.d.ts +21 -21
  164. package/dist/ssr/preloadDiffs.d.ts.map +1 -1
  165. package/dist/ssr/preloadDiffs.js +1 -1
  166. package/dist/ssr/preloadDiffs.js.map +1 -1
  167. package/dist/ssr/preloadFile.d.ts +6 -6
  168. package/dist/ssr/preloadFile.d.ts.map +1 -1
  169. package/dist/ssr/preloadFile.js.map +1 -1
  170. package/dist/ssr/preloadPatchFile.d.ts +4 -4
  171. package/dist/ssr/preloadPatchFile.d.ts.map +1 -1
  172. package/dist/ssr/preloadPatchFile.js.map +1 -1
  173. package/dist/style.js +1 -1
  174. package/dist/types.d.ts +13 -263
  175. package/dist/types.d.ts.map +1 -1
  176. package/dist/utils/appendItems.d.ts +5 -0
  177. package/dist/utils/appendItems.d.ts.map +1 -0
  178. package/dist/utils/appendItems.js +8 -0
  179. package/dist/utils/appendItems.js.map +1 -0
  180. package/dist/utils/areDiffTargetsEqual.js +1 -1
  181. package/dist/utils/areDiffTargetsEqual.js.map +1 -1
  182. package/dist/utils/areFileTargetsEqual.d.ts +7 -0
  183. package/dist/utils/areFileTargetsEqual.d.ts.map +1 -0
  184. package/dist/utils/areFileTargetsEqual.js +8 -0
  185. package/dist/utils/areFileTargetsEqual.js.map +1 -0
  186. package/dist/utils/areManagedSnapshotsEqual.d.ts +1 -1
  187. package/dist/utils/areManagedSnapshotsEqual.d.ts.map +1 -1
  188. package/dist/utils/areManagedSnapshotsEqual.js.map +1 -1
  189. package/dist/utils/areOptionsEqual.d.ts +3 -3
  190. package/dist/utils/areOptionsEqual.d.ts.map +1 -1
  191. package/dist/utils/areOptionsEqual.js.map +1 -1
  192. package/dist/utils/cloneFileDiffMetadata.d.ts +3 -2
  193. package/dist/utils/cloneFileDiffMetadata.d.ts.map +1 -1
  194. package/dist/utils/cloneFileDiffMetadata.js +8 -5
  195. package/dist/utils/cloneFileDiffMetadata.js.map +1 -1
  196. package/dist/utils/composeCacheKey.d.ts +6 -0
  197. package/dist/utils/composeCacheKey.d.ts.map +1 -0
  198. package/dist/utils/composeCacheKey.js +10 -0
  199. package/dist/utils/composeCacheKey.js.map +1 -0
  200. package/dist/utils/editSessionAnnotations.d.ts +69 -0
  201. package/dist/utils/editSessionAnnotations.d.ts.map +1 -0
  202. package/dist/utils/editSessionAnnotations.js +64 -0
  203. package/dist/utils/editSessionAnnotations.js.map +1 -0
  204. package/dist/utils/editSessionHunks.d.ts +5 -3
  205. package/dist/utils/editSessionHunks.d.ts.map +1 -1
  206. package/dist/utils/editSessionHunks.js +7 -5
  207. package/dist/utils/editSessionHunks.js.map +1 -1
  208. package/dist/utils/getDiffHunksRendererOptions.d.ts +1 -1
  209. package/dist/utils/getDiffHunksRendererOptions.d.ts.map +1 -1
  210. package/dist/utils/getDiffHunksRendererOptions.js.map +1 -1
  211. package/dist/utils/getFileRendererOptions.d.ts +1 -1
  212. package/dist/utils/getFileRendererOptions.d.ts.map +1 -1
  213. package/dist/utils/getFileRendererOptions.js.map +1 -1
  214. package/dist/utils/hydratePartialDiff.d.ts.map +1 -1
  215. package/dist/utils/hydratePartialDiff.js +2 -1
  216. package/dist/utils/hydratePartialDiff.js.map +1 -1
  217. package/dist/utils/lineAnnotationIdentity.d.ts +16 -0
  218. package/dist/utils/lineAnnotationIdentity.d.ts.map +1 -0
  219. package/dist/utils/lineAnnotationIdentity.js +17 -0
  220. package/dist/utils/lineAnnotationIdentity.js.map +1 -0
  221. package/dist/utils/parseDiffFromFile.d.ts +2 -2
  222. package/dist/utils/parseDiffFromFile.d.ts.map +1 -1
  223. package/dist/utils/parseDiffFromFile.js +6 -6
  224. package/dist/utils/parseDiffFromFile.js.map +1 -1
  225. package/dist/utils/parsePatchFiles.d.ts +6 -3
  226. package/dist/utils/parsePatchFiles.d.ts.map +1 -1
  227. package/dist/utils/parsePatchFiles.js +34 -9
  228. package/dist/utils/parsePatchFiles.js.map +1 -1
  229. package/dist/utils/renderDiffWithHighlighter.d.ts.map +1 -1
  230. package/dist/utils/renderDiffWithHighlighter.js +6 -5
  231. package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
  232. package/dist/utils/renderFileWithHighlighter.d.ts.map +1 -1
  233. package/dist/utils/renderFileWithHighlighter.js +7 -4
  234. package/dist/utils/renderFileWithHighlighter.js.map +1 -1
  235. package/dist/utils/trimPatchContext.d.ts.map +1 -1
  236. package/dist/utils/trimPatchContext.js +3 -2
  237. package/dist/utils/trimPatchContext.js.map +1 -1
  238. package/dist/utils/updateDiffHunks.js +1 -1
  239. package/dist/utils/virtualDiffLayout.js +1 -1
  240. package/dist/worker/WorkerPoolManager.d.ts +4 -3
  241. package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
  242. package/dist/worker/WorkerPoolManager.js +33 -4
  243. package/dist/worker/WorkerPoolManager.js.map +1 -1
  244. package/dist/worker/types.d.ts +5 -0
  245. package/dist/worker/types.d.ts.map +1 -1
  246. package/dist/worker/worker-portable.js +14 -6
  247. package/dist/worker/worker-portable.js.map +1 -1
  248. package/dist/worker/worker.js +14 -6
  249. package/dist/worker/worker.js.map +1 -1
  250. package/package.json +9 -1
  251. package/dist/editor/stateStorage.d.ts +0 -15
  252. package/dist/editor/stateStorage.d.ts.map +0 -1
  253. package/dist/editor/stateStorage.js +0 -65
  254. package/dist/editor/stateStorage.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"FileRenderer.js","names":[],"sources":["../../src/renderers/FileRenderer.ts"],"sourcesContent":["import type { ElementContent, Element as HASTElement } from 'hast';\nimport { toHtml } from 'hast-util-to-html';\n\nimport {\n DEFAULT_RENDER_RANGE,\n DEFAULT_THEMES,\n DEFAULT_TOKENIZE_MAX_LENGTH,\n} from '../constants';\nimport { areLanguagesAttached } from '../highlighter/languages/areLanguagesAttached';\nimport {\n getHighlighterIfLoaded,\n getSharedHighlighter,\n} from '../highlighter/shared_highlighter';\nimport { areThemesAttached } from '../highlighter/themes/areThemesAttached';\nimport { hasResolvedThemes } from '../highlighter/themes/hasResolvedThemes';\nimport type {\n BaseCodeOptions,\n DiffsHighlighter,\n DiffsTextDocument,\n FileContents,\n FileHeaderRenderMode,\n HighlightedToken,\n LineAnnotation,\n RenderedFileASTCache,\n RenderFileOptions,\n RenderFileResult,\n RenderRange,\n SupportedLanguages,\n ThemedFileResult,\n} from '../types';\nimport { applyLineTextWithNewline } from '../utils/applyLineTextWithNewline';\nimport { areFileRenderOptionsEqual } from '../utils/areFileRenderOptionsEqual';\nimport { areFilesEqual } from '../utils/areFilesEqual';\nimport { areRenderRangesEqual } from '../utils/areRenderRangesEqual';\nimport { linesFromFileContents } from '../utils/computeFileOffsets';\nimport { createAnnotationElement } from '../utils/createAnnotationElement';\nimport { createContentColumn } from '../utils/createContentColumn';\nimport { createFileHeaderElement } from '../utils/createFileHeaderElement';\nimport { createPreElement } from '../utils/createPreElement';\nimport { getFiletypeFromFileName } from '../utils/getFiletypeFromFileName';\nimport { getHighlighterOptions } from '../utils/getHighlighterOptions';\nimport { getLineAnnotationName } from '../utils/getLineAnnotationName';\nimport { getThemes } from '../utils/getThemes';\nimport {\n createGutterGap,\n createGutterItem,\n createGutterWrapper,\n createHastElement,\n} from '../utils/hast_utils';\nimport {\n FILE_ANNOTATION_HUNK_INDEX,\n FILE_ANNOTATION_LINE_INDEX,\n getFileAnnotations,\n shouldRenderFileAnnotations,\n} from '../utils/includesFileAnnotations';\nimport { isFilePlainText } from '../utils/isFilePlainText';\nimport { renderFileWithHighlighter } from '../utils/renderFileWithHighlighter';\nimport type { WorkerPoolManager } from '../worker';\n\ntype AnnotationLineMap<LAnnotation> = Record<\n number,\n LineAnnotation<LAnnotation>[] | undefined\n>;\n\ninterface GetRenderOptionsReturn {\n options: RenderFileOptions;\n forceHighlight: boolean;\n}\n\nexport interface FileRenderResult {\n gutterAST: ElementContent[];\n contentAST: ElementContent[];\n preAST: HASTElement;\n headerAST: HASTElement | undefined;\n css: string;\n totalLines: number;\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n rowCount: number;\n bufferBefore: number;\n bufferAfter: number;\n}\n\ninterface LineCache {\n cacheKey: string | undefined;\n file: FileContents;\n sourceContents: string;\n lines: string[];\n}\n\n// Explicit keys may share cached lines across equivalent file objects. Unkeyed\n// files stay isolated by object identity while still supporting edit recycle.\nfunction isLineCacheForFile(lineCache: LineCache, file: FileContents): boolean {\n return file.cacheKey == null\n ? lineCache.file === file && lineCache.sourceContents === file.contents\n : lineCache.cacheKey === file.cacheKey;\n}\n\nexport interface FileRendererOptions extends BaseCodeOptions {\n headerRenderMode?: FileHeaderRenderMode;\n}\n\nlet instanceId = -1;\n\nexport class FileRenderer<LAnnotation = undefined> {\n readonly __id: string = `file-renderer:${++instanceId}`;\n\n private highlighter: DiffsHighlighter | undefined;\n private renderCache: RenderedFileASTCache | undefined;\n private computedLang: SupportedLanguages = 'text';\n private lineAnnotations: AnnotationLineMap<LAnnotation> = {};\n private lineCache: LineCache | undefined;\n private pendingStructuralRows: Map<number, HASTElement> | undefined;\n private textDocumentCache = new WeakMap<FileContents, DiffsTextDocument>();\n\n // Edit-session state: while active, this renderer stays on the main thread\n // with editor-compatible token markup — the editor's caret/selection\n // mapping needs the token transformer, and the pool's global options are\n // not guaranteed to produce it. The pool keeps serving every surface\n // without a session.\n private editSessionActive = false;\n\n constructor(\n public options: FileRendererOptions = { theme: DEFAULT_THEMES },\n private onRenderUpdate?: () => unknown,\n private workerManager?: WorkerPoolManager | undefined\n ) {\n if (workerManager?.isWorkingPool() !== true) {\n this.highlighter = areThemesAttached(options.theme ?? DEFAULT_THEMES)\n ? getHighlighterIfLoaded()\n : undefined;\n }\n }\n\n public setOptions(options: FileRendererOptions): void {\n this.options = options;\n }\n\n public mergeOptions(options: Partial<FileRendererOptions>): void {\n this.options = { ...this.options, ...options };\n }\n\n public setLineAnnotations(\n lineAnnotations: LineAnnotation<LAnnotation>[]\n ): void {\n this.lineAnnotations = {};\n for (const annotation of lineAnnotations) {\n const arr = this.lineAnnotations[annotation.lineNumber] ?? [];\n this.lineAnnotations[annotation.lineNumber] = arr;\n arr.push(annotation);\n }\n }\n\n public cleanUp(): void {\n this.recycle();\n this.workerManager = undefined;\n this.onRenderUpdate = undefined;\n }\n\n /**\n * Enter edit-session mode: rendering happens locally with the token\n * transformer forced on, and worker-pool requests/results are suspended\n * for this renderer. Called on every editor attach, including a re-attach\n * after recycle.\n */\n public beginEditSession(): void {\n this.editSessionActive = true;\n }\n\n /** Leave edit-session mode. Rendering returns to the pool when one works. */\n public endEditSession(): void {\n this.editSessionActive = false;\n }\n\n /**\n * Ensures that the DOM is compatible with editor render updates\n */\n public editorRenderReady(): boolean {\n return (\n this.renderCache?.options.useTokenTransformer === true &&\n this.renderCache.highlighted &&\n this.renderCache.result != null\n );\n }\n\n public recycle(): void {\n this.clearRenderCache();\n this.highlighter = undefined;\n this.workerManager?.cleanUpTasks(this);\n this.lineCache = undefined;\n // The session flag re-seeds on the next editor attach (beginEditSession).\n this.endEditSession();\n // The edited-document cache is only coherent alongside the render cache\n // it patched. Keeping it across a recycle would let getLineCount report\n // edit-session line counts (keyed by the long-lived file object) against\n // a result rebuilt from the file's own contents, which processFileResult\n // treats as a missing-line error.\n this.textDocumentCache = new WeakMap();\n }\n\n // An edit session patches the render caches in place but never rewrites\n // `file.contents`, so a recycled host would otherwise rebuild from the\n // pre-edit text while the editor resumes its retained (edited) document.\n // Diffs don't have this problem because DiffHunksRenderer keeps\n // `diff.additionLines` in sync during the session; the file equivalent is\n // joining the session-synced line cache back into the file object before\n // the caches are dropped.\n private syncEditedContentsToFile(): void {\n const { renderCache, lineCache } = this;\n if (\n renderCache?.isDirty !== true ||\n lineCache == null ||\n !isLineCacheForFile(lineCache, renderCache.file)\n ) {\n return;\n }\n renderCache.file.contents = lineCache.lines.join('');\n }\n\n // Unkeyed files use object identity, so compare the retained source text to\n // detect in-place mutations that an aliased file object cannot reveal.\n public hasUnkeyedFileContentsChanged(file: FileContents): boolean {\n const { lineCache } = this;\n return (\n file.cacheKey == null &&\n lineCache != null &&\n lineCache.file === file &&\n lineCache.sourceContents !== file.contents\n );\n }\n\n private invalidateChangedUnkeyedFile(file: FileContents): void {\n if (!this.hasUnkeyedFileContentsChanged(file)) return;\n this.workerManager?.cleanUpTasks(this);\n this.clearRenderCache();\n this.lineCache = undefined;\n this.textDocumentCache = new WeakMap();\n }\n\n public clearRenderCache(): void {\n this.syncEditedContentsToFile();\n this.pendingStructuralRows = undefined;\n const renderCache = this.renderCache;\n this.renderCache = undefined;\n if (\n renderCache != null &&\n renderCache.isDirty === true &&\n renderCache.file.cacheKey != null\n ) {\n // The render cache has been updated by the host, let's purge it\n // from the worker manager cache.\n this.workerManager?.evictFileFromCache(renderCache.file.cacheKey);\n }\n }\n\n public hydrate(file: FileContents): void {\n const { options } = this.getRenderOptions(file);\n const lines = this.getOrCreateLineCache(file);\n const massiveFile = isFileMassive(\n lines.length,\n this.getTokenizeMaxLength()\n );\n let cache = this.workerManager?.getFileResultCache(file);\n if (cache != null && !areFileRenderOptionsEqual(options, cache.options)) {\n cache = undefined;\n }\n this.renderCache ??= {\n file,\n options,\n highlighted: !massiveFile && !isFilePlainText(file),\n result: massiveFile ? undefined : cache?.result,\n // FIXME(amadeus): Add support for renderRanges\n renderRange: undefined,\n };\n if (\n !this.editSessionActive &&\n this.workerManager?.isWorkingPool() === true\n ) {\n if (this.renderCache.result == null && !massiveFile) {\n // We should only kick off a preload of the AST if we have a WorkerPool\n this.workerManager.highlightFileAST(this, file);\n }\n }\n // Lets attempt to get the highlighter/languages ready immediately\n else if (this.highlighter == null) {\n this.computedLang = file.lang ?? getFiletypeFromFileName(file.name);\n void this.initializeHighlighter();\n }\n }\n\n private getLocalHighlightTheme(): RenderFileOptions['theme'] {\n return (\n this.workerManager?.getFileRenderOptions().theme ??\n this.options.theme ??\n DEFAULT_THEMES\n );\n }\n\n public getEffectiveCodeOptions(): Pick<\n BaseCodeOptions,\n 'theme' | 'tokenizeMaxLineLength'\n > {\n const poolOptions =\n this.workerManager?.isWorkingPool() === true\n ? this.workerManager.getFileRenderOptions()\n : undefined;\n return {\n theme: this.getLocalHighlightTheme(),\n tokenizeMaxLineLength:\n poolOptions?.tokenizeMaxLineLength ??\n this.options.tokenizeMaxLineLength,\n };\n }\n\n private getRenderOptions(file: FileContents): GetRenderOptionsReturn {\n const options: RenderFileOptions = (() => {\n if (this.workerManager?.isWorkingPool() === true) {\n const poolOptions = this.workerManager.getFileRenderOptions();\n // Active edit sessions require `useTokenTransformer: true`\n if (\n this.editSessionActive &&\n poolOptions.useTokenTransformer !== true\n ) {\n return { ...poolOptions, useTokenTransformer: true };\n }\n return poolOptions;\n }\n const { tokenizeMaxLineLength = 1000 } = this.options;\n return {\n theme: this.getLocalHighlightTheme(),\n useTokenTransformer:\n this.editSessionActive || this.options.useTokenTransformer === true,\n tokenizeMaxLineLength,\n };\n })();\n const { renderCache } = this;\n if (renderCache?.result == null) {\n return { options, forceHighlight: true };\n }\n if (\n !areFilesEqual(file, renderCache.file) ||\n !areFileRenderOptionsEqual(options, renderCache.options)\n ) {\n return { options, forceHighlight: true };\n }\n return { options, forceHighlight: false };\n }\n\n public getOrCreateLineCache(file: FileContents): string[] {\n this.invalidateChangedUnkeyedFile(file);\n let { lineCache } = this;\n if (lineCache == null || !isLineCacheForFile(lineCache, file)) {\n lineCache = {\n cacheKey: file.cacheKey,\n file,\n sourceContents: file.contents,\n lines: linesFromFileContents(file.contents),\n };\n }\n this.lineCache = lineCache;\n return lineCache.lines;\n }\n\n // when a emitLineCountChange is called,\n // calculate the line count using the cached text document\n public getLineCount(file: FileContents): number {\n const lines = this.getOrCreateLineCache(file);\n return this.textDocumentCache.get(file)?.lineCount ?? lines.length;\n }\n\n public updateRenderCache(\n dirtyLines: Map<number, Array<HighlightedToken>>,\n themeType: 'dark' | 'light',\n lineCountChangeInFlight = false\n ): void {\n this.pendingStructuralRows = undefined;\n if (this.renderCache == null) {\n return;\n }\n const { file, result } = this.renderCache;\n if (result == null) {\n return;\n }\n const pendingStructuralRows = lineCountChangeInFlight\n ? new Map<number, HASTElement>()\n : undefined;\n this.pendingStructuralRows = pendingStructuralRows;\n // Same-line edits can update the document cache immediately. Structural\n // rows use post-edit indexes, so hold them until applyDocumentChange has\n // shifted the old cache; writing now would overwrite rows that must move.\n const lineCache =\n this.lineCache != null && isLineCacheForFile(this.lineCache, file)\n ? this.lineCache\n : undefined;\n for (const [line, tokens] of dirtyLines) {\n if (\n pendingStructuralRows === undefined &&\n lineCache != null &&\n line < lineCache.lines.length\n ) {\n const lineText = tokens.map((token) => token[2]).join('');\n lineCache.lines[line] = applyLineTextWithNewline(\n lineCache.lines[line] ?? '',\n lineText\n );\n }\n const row: HASTElement = {\n type: 'element',\n tagName: 'div',\n properties: {\n 'data-line': line + 1,\n 'data-line-type': 'context',\n 'data-line-index': line,\n },\n children: tokens.map(([char, fg, text]) => {\n if (char === 0 && fg === '') {\n if (text === '') {\n return {\n type: 'element',\n tagName: 'br',\n properties: {},\n children: [],\n };\n }\n return { type: 'text', value: text };\n }\n return {\n type: 'element',\n tagName: 'span',\n properties: {\n 'data-char': char,\n style: `color:${fg};`,\n },\n children: [{ type: 'text', value: text }],\n };\n }),\n };\n if (pendingStructuralRows !== undefined) {\n pendingStructuralRows.set(line, row);\n } else {\n result.code[line] = row;\n }\n }\n\n result.baseThemeType = themeType;\n this.renderCache.isDirty = true;\n }\n\n // normally triggered by the host when the document line count changes\n public applyDocumentChange(textDocument: DiffsTextDocument): void {\n const pendingStructuralRows = this.pendingStructuralRows;\n this.pendingStructuralRows = undefined;\n if (this.renderCache == null) {\n return undefined;\n }\n const { file, result } = this.renderCache;\n // Without a result there is nothing to reconcile the document against, so\n // do not record it either: the document cache must never claim line\n // counts the (possibly still highlighting) result cannot back, or the\n // async highlight pass would process lines that do not exist.\n if (result == null) {\n return undefined;\n }\n // Structural edits renumber cached HAST rows. Keep the unchanged prefix\n // and suffix, and plain-fill only the window that still needs tokenizing.\n const previousLines =\n this.lineCache != null && isLineCacheForFile(this.lineCache, file)\n ? this.lineCache.lines\n : linesFromFileContents(file.contents);\n const nextLines = linesFromFileContents(textDocument.getText());\n if (previousLines.length !== nextLines.length) {\n const maxShared = Math.min(previousLines.length, nextLines.length);\n let prefix = 0;\n while (\n prefix < maxShared &&\n previousLines[prefix] === nextLines[prefix]\n ) {\n prefix++;\n }\n let suffix = 0;\n while (\n suffix < maxShared - prefix &&\n previousLines[previousLines.length - 1 - suffix] ===\n nextLines[nextLines.length - 1 - suffix]\n ) {\n suffix++;\n }\n\n const previousCode = result.code;\n result.code = new Array(nextLines.length);\n for (let i = 0; i < prefix; i++) {\n result.code[i] = previousCode[i];\n }\n for (let i = 0; i < suffix; i++) {\n result.code[nextLines.length - 1 - i] =\n previousCode[previousLines.length - 1 - i];\n }\n if (pendingStructuralRows !== undefined) {\n for (const [line, row] of pendingStructuralRows) {\n if (line < nextLines.length) {\n result.code[line] = row;\n }\n }\n }\n for (let i = prefix; i < nextLines.length - suffix; i++) {\n result.code[i] ??= {\n type: 'element',\n tagName: 'div',\n properties: {\n 'data-line': i + 1,\n 'data-line-type': 'context',\n 'data-line-index': i,\n },\n children: [\n {\n type: 'element',\n tagName: 'span',\n properties: {\n 'data-char': 0,\n },\n children: [\n {\n type: 'text',\n value: textDocument.getLineText(i),\n },\n ],\n },\n ],\n };\n }\n for (let i = 0; i < result.code.length; i++) {\n const line = result.code[i];\n if (line?.type === 'element') {\n line.properties['data-line'] = i + 1;\n line.properties['data-line-index'] = i;\n }\n }\n this.renderCache.isDirty = true;\n }\n // Replace the old split-line cache with the authoritative edited document.\n this.lineCache = {\n cacheKey: file.cacheKey,\n file,\n sourceContents: file.contents,\n lines: nextLines,\n };\n this.textDocumentCache.set(file, textDocument);\n }\n\n public renderFile(\n file: FileContents | undefined = this.renderCache?.file,\n renderRange: RenderRange = DEFAULT_RENDER_RANGE\n ): FileRenderResult | undefined {\n if (file == null) {\n return undefined;\n }\n this.invalidateChangedUnkeyedFile(file);\n if (\n this.renderCache?.isDirty === true &&\n !areFilesEqual(file, this.renderCache.file)\n ) {\n this.clearRenderCache();\n this.lineCache = undefined;\n this.textDocumentCache = new WeakMap();\n }\n let { options, forceHighlight } = this.getRenderOptions(file);\n // A dirty edit-session cache must not be superseded by a render with\n // different options (e.g. a session ending and returning to pool\n // options): persist the session text into the file and evict the stale\n // pool cache entry first (clearRenderCache does both) so the rebuild\n // below uses the edited contents instead of resurrecting pre-edit\n // markup.\n if (\n this.renderCache?.isDirty === true &&\n !areFileRenderOptionsEqual(options, this.renderCache.options)\n ) {\n this.clearRenderCache();\n }\n const cache = this.getMatchingWorkerResultCache(file, options);\n if (cache != null && !this.hasHighlightedRenderCache(file, options)) {\n this.renderCache = {\n file,\n highlighted: true,\n renderRange: undefined,\n ...cache,\n };\n forceHighlight = false;\n }\n this.renderCache ??= {\n file,\n highlighted: false,\n options,\n result: undefined,\n renderRange: undefined,\n };\n const lines = this.getOrCreateLineCache(file);\n const hasContent = file.contents.length > 0;\n const forcePlainText =\n !hasContent ||\n isFilePlainText(file) ||\n isFileMassive(lines.length, this.getTokenizeMaxLength());\n const newContent = !areFilesEqual(file, this.renderCache.file);\n const newRenderRange = !areRenderRangesEqual(\n this.renderCache.renderRange,\n renderRange\n );\n if (\n !this.editSessionActive &&\n this.workerManager?.isWorkingPool() === true\n ) {\n // Cache invalidation based on renderRange comparison\n if (\n forcePlainText ||\n this.renderCache.result == null ||\n (!this.renderCache.highlighted && (newContent || newRenderRange))\n ) {\n this.renderCache.file = file;\n this.renderCache.options = options;\n this.renderCache.highlighted = false;\n if (\n this.renderCache.result == null ||\n newContent ||\n newRenderRange ||\n forceHighlight\n ) {\n this.renderCache.result = this.workerManager.getPlainFileAST(\n file,\n renderRange.startingLine,\n renderRange.totalLines,\n lines\n );\n }\n this.renderCache.renderRange = renderRange;\n }\n\n if (\n !forcePlainText &&\n hasContent &&\n (!this.renderCache.highlighted || forceHighlight)\n ) {\n this.workerManager.highlightFileAST(this, file);\n }\n } else {\n this.computedLang = file.lang ?? getFiletypeFromFileName(file.name);\n const hasThemes =\n this.highlighter != null && areThemesAttached(options.theme);\n const hasLangs =\n this.highlighter != null && areLanguagesAttached(this.computedLang);\n const canHighlight = !forcePlainText && hasLangs;\n\n // If we have any semblance of a highlighter with the correct theme(s)\n // attached, we can kick off some form of rendering. If we don't have\n // the correct language, then we can render plain text and after kick off\n // an async job to get the highlighted AST\n if (\n this.highlighter != null &&\n hasThemes &&\n (forceHighlight ||\n forcePlainText ||\n (!this.renderCache.highlighted && canHighlight) ||\n this.renderCache.result == null)\n ) {\n const { result, options } = this.renderFileWithHighlighter(\n file,\n this.highlighter,\n forcePlainText || !hasLangs\n );\n this.renderCache = {\n file,\n options,\n highlighted: canHighlight,\n result,\n renderRange: undefined,\n };\n }\n\n // If we get in here it means we'll have to kick off an async highlight\n // process which will involve initializing the highlighter with new themes\n // and languages\n if (!hasThemes || (!forcePlainText && !hasLangs)) {\n void this.asyncHighlight(file).then(({ result, options }) => {\n // In this case we need to force a re-render, so we can do that by\n // reaching into renderCache\n if (this.renderCache != null) {\n this.renderCache.highlighted = false;\n }\n this.applyHighlightResult(file, result, options, !forcePlainText);\n });\n }\n }\n\n return this.renderCache.result != null\n ? this.processFileResult(\n this.renderCache.file,\n renderRange,\n this.renderCache.result\n )\n : undefined;\n }\n\n async asyncRender(\n file: FileContents,\n renderRange: RenderRange = DEFAULT_RENDER_RANGE\n ): Promise<FileRenderResult> {\n const { result } = await this.asyncHighlight(file);\n return this.processFileResult(file, renderRange, result);\n }\n\n private async asyncHighlight(file: FileContents): Promise<RenderFileResult> {\n const lines = this.getOrCreateLineCache(file);\n const forcePlainText = isFileMassive(\n lines.length,\n this.getTokenizeMaxLength()\n );\n this.computedLang = forcePlainText\n ? 'text'\n : (file.lang ?? getFiletypeFromFileName(file.name));\n const hasThemes =\n this.highlighter != null &&\n hasResolvedThemes(getThemes(this.getLocalHighlightTheme()));\n const hasLangs =\n forcePlainText ||\n (this.highlighter != null && areLanguagesAttached(this.computedLang));\n // If we don't have the required langs or themes, then we need to\n // initialize the highlighter to load the appropriate languages and themes\n if (this.highlighter == null || !hasThemes || !hasLangs) {\n this.highlighter = await this.initializeHighlighter();\n }\n return this.renderFileWithHighlighter(\n file,\n this.highlighter,\n forcePlainText\n );\n }\n\n private renderFileWithHighlighter(\n file: FileContents,\n highlighter: DiffsHighlighter,\n forcePlainText = false\n ): RenderFileResult {\n const { options } = this.getRenderOptions(file);\n const result = renderFileWithHighlighter(file, highlighter, options, {\n forcePlainText,\n });\n return { result, options };\n }\n\n private processFileResult(\n file: FileContents,\n renderRange: RenderRange,\n { code, themeStyles, baseThemeType }: ThemedFileResult\n ): FileRenderResult {\n const totalLines = this.getLineCount(file);\n const { disableFileHeader = false } = this.options;\n const contentArray: ElementContent[] = [];\n const gutter = createGutterWrapper();\n const endLine = Math.min(\n renderRange.startingLine + renderRange.totalLines,\n totalLines\n );\n let rowCount = 0;\n\n const fileLevelAnnotations = shouldRenderFileAnnotations(renderRange)\n ? getFileAnnotations(this.lineAnnotations)\n : undefined;\n if (fileLevelAnnotations != null) {\n gutter.children.push(createGutterGap('context', 'annotation', 1));\n contentArray.push(\n createAnnotationElement({\n type: 'annotation',\n hunkIndex: FILE_ANNOTATION_HUNK_INDEX,\n lineIndex: FILE_ANNOTATION_LINE_INDEX,\n annotations: fileLevelAnnotations.map((annotation) =>\n getLineAnnotationName(annotation)\n ),\n })\n );\n rowCount++;\n }\n\n for (\n let lineIndex = renderRange.startingLine;\n lineIndex < endLine;\n lineIndex++\n ) {\n const lineNumber = lineIndex + 1;\n\n // Sparse array - directly indexed by lineIndex\n const line = code[lineIndex];\n if (line == null) {\n const message = 'FileRenderer.processFileResult: Line doesnt exist';\n console.error(message, {\n name: file.name,\n lineIndex,\n lineNumber,\n });\n throw new Error(message);\n }\n\n // Add gutter line number\n gutter.children.push(\n createGutterItem('context', lineNumber, `${lineIndex}`)\n );\n contentArray.push(line);\n rowCount++;\n\n // Check annotations using ACTUAL line number from file\n const annotations = this.lineAnnotations[lineNumber];\n if (annotations != null) {\n gutter.children.push(createGutterGap('context', 'annotation', 1));\n contentArray.push(\n createAnnotationElement({\n type: 'annotation',\n hunkIndex: 0,\n lineIndex: lineNumber,\n annotations: annotations.map((annotation) =>\n getLineAnnotationName(annotation)\n ),\n })\n );\n rowCount++;\n }\n }\n\n // Finalize: wrap gutter and content\n gutter.properties.style = `grid-row: span ${rowCount}`;\n return {\n gutterAST: gutter.children ?? [],\n contentAST: contentArray,\n preAST: this.createPreElement(totalLines),\n headerAST: !disableFileHeader ? this.renderHeader(file) : undefined,\n totalLines: totalLines,\n rowCount,\n themeStyles: themeStyles,\n baseThemeType,\n bufferBefore: renderRange.bufferBefore,\n bufferAfter: renderRange.bufferAfter,\n css: '',\n };\n }\n\n private renderHeader(file: FileContents) {\n const { headerRenderMode = 'default', stickyHeader = false } = this.options;\n return createFileHeaderElement({\n fileOrDiff: file,\n mode: headerRenderMode,\n stickyHeader,\n });\n }\n\n public renderFullHTML(result: FileRenderResult): string {\n return toHtml(this.renderFullAST(result));\n }\n\n public renderFullAST(\n result: FileRenderResult,\n children: ElementContent[] = []\n ): HASTElement {\n children.push(\n createHastElement({\n tagName: 'code',\n children: this.renderCodeAST(result),\n properties: { 'data-code': '' },\n })\n );\n return { ...result.preAST, children };\n }\n\n public renderCodeAST(result: FileRenderResult): ElementContent[] {\n const gutter = createGutterWrapper();\n gutter.children = result.gutterAST;\n gutter.properties.style = `grid-row: span ${result.rowCount}`;\n const contentColumn = createContentColumn(\n result.contentAST,\n result.rowCount\n );\n return [gutter, contentColumn];\n }\n\n public renderPartialHTML(\n children: ElementContent[],\n includeCodeNode: boolean = false\n ): string {\n if (!includeCodeNode) {\n return toHtml(children);\n }\n return toHtml(\n createHastElement({\n tagName: 'code',\n children,\n properties: { 'data-code': '' },\n })\n );\n }\n\n public async initializeHighlighter(): Promise<DiffsHighlighter> {\n this.highlighter = await getSharedHighlighter(\n getHighlighterOptions(this.computedLang, {\n theme: this.getLocalHighlightTheme(),\n preferredHighlighter:\n this.workerManager?.getPreferredHighlighter() ??\n this.options.preferredHighlighter,\n })\n );\n return this.highlighter;\n }\n\n public onHighlightSuccess(\n file: FileContents,\n result: ThemedFileResult,\n options: RenderFileOptions,\n highlighted = true\n ): void {\n if (this.editSessionActive) {\n return;\n }\n this.applyHighlightResult(file, result, options, highlighted);\n }\n\n private applyHighlightResult(\n file: FileContents,\n result: ThemedFileResult,\n options: RenderFileOptions,\n highlighted = true\n ): void {\n if (this.renderCache == null) {\n return;\n }\n const triggerRenderUpdate =\n !areFilesEqual(file, this.renderCache.file) ||\n !this.renderCache.highlighted ||\n !areFileRenderOptionsEqual(options, this.renderCache.options);\n\n this.renderCache = {\n file,\n options,\n highlighted,\n result,\n renderRange: undefined,\n };\n\n if (triggerRenderUpdate) {\n this.onRenderUpdate?.();\n }\n }\n\n private getMatchingWorkerResultCache(\n file: FileContents,\n options: RenderFileOptions\n ): RenderFileResult | undefined {\n if (this.editSessionActive) {\n return undefined;\n }\n const cache = this.workerManager?.getFileResultCache(file);\n if (cache == null || !areFileRenderOptionsEqual(options, cache.options)) {\n return undefined;\n }\n return cache;\n }\n\n private hasHighlightedRenderCache(\n file: FileContents,\n options: RenderFileOptions\n ): boolean {\n const { renderCache } = this;\n return (\n renderCache?.result != null &&\n renderCache.highlighted &&\n areFilesEqual(file, renderCache.file) &&\n areFileRenderOptionsEqual(options, renderCache.options)\n );\n }\n\n public onHighlightError(error: unknown): void {\n console.error(error);\n }\n\n private getTokenizeMaxLength(): number {\n return this.options.tokenizeMaxLength ?? DEFAULT_TOKENIZE_MAX_LENGTH;\n }\n\n private createPreElement(totalLines: number): HASTElement {\n const { disableLineNumbers = false, overflow = 'scroll' } = this.options;\n return createPreElement({\n type: 'file',\n diffIndicators: 'none',\n disableBackground: true,\n disableLineNumbers,\n overflow,\n split: false,\n totalLines,\n });\n }\n}\n\nfunction isFileMassive(lineCount: number, tokenizeMaxLength: number): boolean {\n return lineCount > tokenizeMaxLength;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4FA,SAAS,mBAAmB,WAAsB,MAA6B;CAC7E,OAAO,KAAK,YAAY,OACpB,UAAU,SAAS,QAAQ,UAAU,mBAAmB,KAAK,WAC7D,UAAU,aAAa,KAAK;AAClC;AAMA,IAAI,aAAa;AAEjB,IAAa,eAAb,MAAmD;CAmBxC;CACC;CACA;CApBV,OAAwB,iBAAiB,EAAE;CAE3C;CACA;CACA,eAA2C;CAC3C,kBAA0D,CAAC;CAC3D;CACA;CACA,oCAA4B,IAAI,QAAyC;CAOzE,oBAA4B;CAE5B,YACE,UAAsC,EAAE,OAAO,eAAe,GAC9D,gBACA,eACA;EAHO,KAAA,UAAA;EACC,KAAA,iBAAA;EACA,KAAA,gBAAA;EAER,IAAI,eAAe,cAAc,MAAM,MACrC,KAAK,cAAc,kBAAkB,QAAQ,SAAS,cAAc,IAChE,uBAAuB,IACvB,KAAA;CAER;CAEA,WAAkB,SAAoC;EACpD,KAAK,UAAU;CACjB;CAEA,aAAoB,SAA6C;EAC/D,KAAK,UAAU;GAAE,GAAG,KAAK;GAAS,GAAG;EAAQ;CAC/C;CAEA,mBACE,iBACM;EACN,KAAK,kB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AAK;EACjE,OAAO,iBAAiB;GACtB,MAAM;GACN,gBAAgB;GAChB,mBAAmB;GACnB;GACA;GACA,OAAO;GACP;EACF,CAAC;CACH;AACF;AAEA,SAAS,cAAc,WAAmB,mBAAoC;CAC5E,OAAO,YAAY;AACrB"}
1
+ {"version":3,"file":"FileRenderer.js","names":[],"sources":["../../src/renderers/FileRenderer.ts"],"sourcesContent":["import type { ElementContent, Element as HASTElement } from 'hast';\nimport { toHtml } from 'hast-util-to-html';\n\nimport {\n DEFAULT_RENDER_RANGE,\n DEFAULT_THEMES,\n DEFAULT_TOKENIZE_MAX_LENGTH,\n} from '../constants';\nimport type { TextDocument } from '../editor/textDocument';\nimport { areLanguagesAttached } from '../highlighter/languages/areLanguagesAttached';\nimport {\n getHighlighterIfLoaded,\n getSharedHighlighter,\n} from '../highlighter/shared_highlighter';\nimport { areThemesAttached } from '../highlighter/themes/areThemesAttached';\nimport { hasResolvedThemes } from '../highlighter/themes/hasResolvedThemes';\nimport type {\n BaseCodeOptions,\n DiffsHighlighter,\n FileContents,\n FileHeaderRenderMode,\n HighlightedToken,\n LineAnnotation,\n RenderedFileASTCache,\n RenderFileOptions,\n RenderFileResult,\n RenderRange,\n SupportedLanguages,\n ThemedFileResult,\n} from '../types';\nimport { applyLineTextWithNewline } from '../utils/applyLineTextWithNewline';\nimport { areFileRenderOptionsEqual } from '../utils/areFileRenderOptionsEqual';\nimport { areFileTargetsEqual } from '../utils/areFileTargetsEqual';\nimport { areRenderRangesEqual } from '../utils/areRenderRangesEqual';\nimport { linesFromFileContents } from '../utils/computeFileOffsets';\nimport { createAnnotationElement } from '../utils/createAnnotationElement';\nimport { createContentColumn } from '../utils/createContentColumn';\nimport { createFileHeaderElement } from '../utils/createFileHeaderElement';\nimport { createPreElement } from '../utils/createPreElement';\nimport { getFiletypeFromFileName } from '../utils/getFiletypeFromFileName';\nimport { getHighlighterOptions } from '../utils/getHighlighterOptions';\nimport { getLineAnnotationName } from '../utils/getLineAnnotationName';\nimport { getThemes } from '../utils/getThemes';\nimport {\n createGutterGap,\n createGutterItem,\n createGutterWrapper,\n createHastElement,\n} from '../utils/hast_utils';\nimport {\n FILE_ANNOTATION_HUNK_INDEX,\n FILE_ANNOTATION_LINE_INDEX,\n getFileAnnotations,\n shouldRenderFileAnnotations,\n} from '../utils/includesFileAnnotations';\nimport { isDefaultRenderRange } from '../utils/isDefaultRenderRange';\nimport { isFilePlainText } from '../utils/isFilePlainText';\nimport { renderFileWithHighlighter } from '../utils/renderFileWithHighlighter';\nimport type { WorkerPoolManager } from '../worker';\n\ntype AnnotationLineMap<LAnnotation> = Record<\n number,\n LineAnnotation<LAnnotation>[] | undefined\n>;\n\ninterface GetRenderOptionsReturn {\n options: RenderFileOptions;\n forceHighlight: boolean;\n}\n\ninterface PendingHighlightResult extends RenderFileResult {\n file: FileContents;\n highlighted: boolean;\n}\n\ninterface FileRenderCache extends RenderedFileASTCache {\n // hydrate() describes DOM that already exists, even when no reusable AST\n // was available for that server-rendered content.\n hydrated?: boolean;\n}\n\nexport interface FileRenderResult {\n file: FileContents;\n gutterAST: ElementContent[];\n contentAST: ElementContent[];\n preAST: HASTElement;\n headerAST: HASTElement | undefined;\n css: string;\n totalLines: number;\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n rowCount: number;\n bufferBefore: number;\n bufferAfter: number;\n}\n\ninterface LineCache {\n cacheKey: string | undefined;\n file: FileContents;\n sourceContents: string;\n lines: string[];\n}\n\n// Explicit keys may share cached lines across equivalent file objects. Unkeyed\n// files stay isolated by object identity while still supporting edit recycle.\nfunction isLineCacheForFile(lineCache: LineCache, file: FileContents): boolean {\n return file.cacheKey == null\n ? lineCache.file === file && lineCache.sourceContents === file.contents\n : lineCache.cacheKey === file.cacheKey;\n}\n\nexport interface FileRendererOptions extends BaseCodeOptions {\n headerRenderMode?: FileHeaderRenderMode;\n}\n\nlet instanceId = -1;\n\nexport class FileRenderer<LAnnotation = undefined> {\n readonly __id: string = `file-renderer:${++instanceId}`;\n\n private highlighter: DiffsHighlighter | undefined;\n // The latest file requested by the component. The render cache may\n // intentionally keep displaying an older highlighted file while this one\n // is highlighted in the background.\n private file: FileContents | undefined;\n\n private renderCache: FileRenderCache | undefined;\n // Completed background work waits here until the next render can update its\n // DOM and layout together.\n private pendingHighlightResult: PendingHighlightResult | undefined;\n\n private computedLang: SupportedLanguages = 'text';\n private lineAnnotations: AnnotationLineMap<LAnnotation> = {};\n private lineCache: LineCache | undefined;\n private pendingStructuralRows: Map<number, HASTElement> | undefined;\n private textDocumentCache = new WeakMap<\n FileContents,\n TextDocument<'file', LAnnotation>\n >();\n\n // Edit-session state: while active, this renderer stays on the main thread\n // with editor-compatible token markup — the editor's caret/selection\n // mapping needs the token transformer, and the pool's global options are\n // not guaranteed to produce it. The pool keeps serving every surface\n // without a session.\n private editSessionActive = false;\n\n public get fileCache(): FileContents | undefined {\n return this.renderCache?.file;\n }\n\n constructor(\n public options: FileRendererOptions = { theme: DEFAULT_THEMES },\n private annotationSlotName: (\n annotation: LineAnnotation<LAnnotation>\n ) => string = getLineAnnotationName,\n private onRenderUpdate?: () => unknown,\n private workerManager?: WorkerPoolManager | undefined\n ) {\n if (workerManager?.isWorkingPool() !== true) {\n this.highlighter = areThemesAttached(options.theme ?? DEFAULT_THEMES)\n ? getHighlighterIfLoaded()\n : undefined;\n }\n }\n\n public setOptions(options: FileRendererOptions): void {\n this.options = options;\n }\n\n public mergeOptions(options: Partial<FileRendererOptions>): void {\n this.options = { ...this.options, ...options };\n }\n\n public setLineAnnotations(\n lineAnnotations: LineAnnotation<LAnnotation>[]\n ): void {\n this.lineAnnotations = {};\n for (const annotation of lineAnnotations) {\n const arr = this.lineAnnotations[annotation.lineNumber] ?? [];\n this.lineAnnotations[annotation.lineNumber] = arr;\n arr.push(annotation);\n }\n }\n\n public cleanUp(): void {\n this.recycle();\n this.workerManager = undefined;\n this.onRenderUpdate = undefined;\n }\n\n /**\n * Enter edit-session mode: rendering happens locally with the token\n * transformer forced on, and worker-pool requests/results are suspended\n * for this renderer. Called on initial editor association and whenever its\n * rendering resumes after recycle.\n */\n public beginEditSession(\n file?: FileContents,\n externalFile?: FileContents\n ): void {\n const { editSessionActive: wasAlreadyActive, renderCache } = this;\n this.editSessionActive = true;\n if (!wasAlreadyActive) {\n this.pendingHighlightResult = undefined;\n }\n if (file == null) {\n return;\n }\n\n this.file = file;\n if (renderCache == null) {\n return;\n }\n // Edit updates call this again before each write. That cache is already\n // private and must retain plain-text session results.\n if (wasAlreadyActive && renderCache.file === file) {\n return;\n }\n const { options } = this.getRenderOptions(file);\n const cacheBelongsToSession = renderCache.file === file;\n const cacheBelongsToExternal =\n externalFile != null &&\n areFileTargetsEqual(renderCache.file, externalFile);\n const { result } = renderCache;\n if (\n !renderCache.highlighted ||\n result == null ||\n !areFileRenderOptionsEqual(renderCache.options, options) ||\n (!cacheBelongsToSession && !cacheBelongsToExternal)\n ) {\n this.clearRenderCache();\n this.lineCache = undefined;\n this.textDocumentCache = new WeakMap();\n return;\n }\n if (cacheBelongsToSession) {\n return;\n }\n\n this.renderCache = {\n ...renderCache,\n file,\n result: {\n ...result,\n code: [...result.code],\n },\n };\n const { lineCache } = this;\n if (\n lineCache != null &&\n externalFile != null &&\n isLineCacheForFile(lineCache, externalFile)\n ) {\n this.lineCache = {\n cacheKey: undefined,\n file,\n sourceContents: file.contents,\n lines: lineCache.lines,\n };\n } else {\n this.lineCache = undefined;\n }\n }\n\n /**\n * Leave edit-session mode. Rendering returns to the pool when one works.\n * When `settledFile` has the content the cache already shows, the cache\n * adopts it as its identity so the next render treats it as current\n * instead of a new file.\n */\n public endEditSession(settledFile?: FileContents): void {\n this.editSessionActive = false;\n this.pendingHighlightResult = undefined;\n const { renderCache } = this;\n if (\n settledFile == null ||\n renderCache == null ||\n renderCache.file === settledFile ||\n !areFileTargetsEqual(renderCache.file, settledFile)\n ) {\n return;\n }\n renderCache.file = settledFile;\n }\n\n /**\n * Ensures that the DOM is compatible with editor render updates\n */\n public editorRenderReady(): boolean {\n return (\n this.renderCache?.options.useTokenTransformer === true &&\n this.renderCache.highlighted &&\n this.renderCache.result != null\n );\n }\n\n public recycle(): void {\n this.clearRenderCache();\n this.highlighter = undefined;\n this.workerManager?.cleanUpTasks(this);\n this.lineCache = undefined;\n this.file = undefined;\n // The session flag re-seeds on the next editor attach (beginEditSession).\n this.endEditSession();\n // The edited-document cache is only coherent alongside the render cache\n // it patched. Keeping it across a recycle would let getLineCount report\n // edit-session line counts (keyed by the long-lived file object) against\n // a result rebuilt from the file's own contents, which processFileResult\n // treats as a missing-line error.\n this.textDocumentCache = new WeakMap();\n }\n\n public clearRenderCache(): void {\n this.pendingStructuralRows = undefined;\n this.renderCache = undefined;\n this.pendingHighlightResult = undefined;\n }\n\n public hydrate(file: FileContents): void {\n this.file = file;\n const { options } = this.getRenderOptions(file);\n const lines = this.getOrCreateLineCache(file);\n const massiveFile = isFileMassive(\n lines.length,\n this.getTokenizeMaxLength()\n );\n let cache = this.workerManager?.getFileResultCache(file);\n if (cache != null && !areFileRenderOptionsEqual(options, cache.options)) {\n cache = undefined;\n }\n this.renderCache ??= {\n file,\n hydrated: true,\n options,\n highlighted: !massiveFile && !isFilePlainText(file),\n result: massiveFile ? undefined : cache?.result,\n // FIXME(amadeus): Add support for renderRanges\n renderRange: undefined,\n };\n if (\n !this.editSessionActive &&\n this.workerManager?.isWorkingPool() === true\n ) {\n if (this.renderCache.result == null && !massiveFile) {\n // We should only kick off a preload of the AST if we have a WorkerPool\n this.workerManager.highlightFileAST(this, file);\n }\n }\n // Lets attempt to get the highlighter/languages ready immediately\n else if (this.highlighter == null) {\n this.computedLang = file.lang ?? getFiletypeFromFileName(file.name);\n void this.initializeHighlighter();\n }\n }\n\n private getLocalHighlightTheme(): RenderFileOptions['theme'] {\n return (\n this.workerManager?.getFileRenderOptions().theme ??\n this.options.theme ??\n DEFAULT_THEMES\n );\n }\n\n public getEffectiveCodeOptions(): Pick<\n BaseCodeOptions,\n 'theme' | 'tokenizeMaxLineLength'\n > {\n const poolOptions =\n this.workerManager?.isWorkingPool() === true\n ? this.workerManager.getFileRenderOptions()\n : undefined;\n return {\n theme: this.getLocalHighlightTheme(),\n tokenizeMaxLineLength:\n poolOptions?.tokenizeMaxLineLength ??\n this.options.tokenizeMaxLineLength,\n };\n }\n\n private getRenderOptions(file: FileContents): GetRenderOptionsReturn {\n const options: RenderFileOptions = (() => {\n if (this.workerManager?.isWorkingPool() === true) {\n const poolOptions = this.workerManager.getFileRenderOptions();\n // Active edit sessions require `useTokenTransformer: true`\n if (\n this.editSessionActive &&\n poolOptions.useTokenTransformer !== true\n ) {\n return { ...poolOptions, useTokenTransformer: true };\n }\n return poolOptions;\n }\n const { tokenizeMaxLineLength = 1000 } = this.options;\n return {\n theme: this.getLocalHighlightTheme(),\n useTokenTransformer:\n this.editSessionActive || this.options.useTokenTransformer === true,\n tokenizeMaxLineLength,\n };\n })();\n const { renderCache } = this;\n if (renderCache?.result == null) {\n return { options, forceHighlight: true };\n }\n if (\n !areFileTargetsEqual(file, renderCache.file) ||\n !areFileRenderOptionsEqual(options, renderCache.options)\n ) {\n return { options, forceHighlight: true };\n }\n return { options, forceHighlight: false };\n }\n\n /**\n * Returns the file that the next synchronous render can commit without\n * changing the current render cache. Virtualized layouts use this to stay\n * aligned with the DOM while a replacement highlight is still pending.\n */\n public getFileForNextRender(file: FileContents): FileContents {\n const { options } = this.getRenderOptions(file);\n if (this.getReadyRenderResult(file, options) != null) {\n return file;\n }\n\n const { renderCache } = this;\n if (renderCache == null) {\n return file;\n }\n if (areFileTargetsEqual(renderCache.file, file)) {\n return renderCache.file;\n }\n\n const lines = linesFromFileContents(file.contents);\n const forcePlainText =\n file.contents.length === 0 ||\n isFilePlainText(file) ||\n isFileMassive(lines.length, this.getTokenizeMaxLength());\n\n return this.canRenderFile(file, options, forcePlainText)\n ? file\n : renderCache.file;\n }\n\n private canRenderFile(\n file: FileContents,\n options: RenderFileOptions,\n forcePlainText: boolean\n ): boolean {\n const { renderCache } = this;\n if (renderCache == null || areFileTargetsEqual(renderCache.file, file)) {\n return true;\n }\n if (forcePlainText) {\n return (\n (renderCache.result == null && renderCache.hydrated !== true) ||\n this.workerManager?.isWorkingPool() === true ||\n (this.highlighter != null && areThemesAttached(options.theme))\n );\n }\n // Hydration has highlighted DOM without a local AST. It is still active\n // rendered content and must remain visible while a non-plain replacement\n // is prepared.\n if (renderCache.result == null && renderCache.hydrated !== true) {\n return true;\n }\n\n if (\n !this.editSessionActive &&\n this.workerManager?.isWorkingPool() === true\n ) {\n return !renderCache.highlighted;\n }\n\n return this.highlighter != null && areThemesAttached(options.theme);\n }\n\n public getOrCreateLineCache(file: FileContents): string[] {\n let { lineCache } = this;\n if (lineCache == null || !isLineCacheForFile(lineCache, file)) {\n lineCache = {\n cacheKey: file.cacheKey,\n file,\n sourceContents: file.contents,\n lines: linesFromFileContents(file.contents),\n };\n }\n this.lineCache = lineCache;\n return lineCache.lines;\n }\n\n // when a emitLineCountChange is called,\n // calculate the line count using the cached text document\n public getLineCount(file: FileContents): number {\n const lines = this.getOrCreateLineCache(file);\n return this.textDocumentCache.get(file)?.lineCount ?? lines.length;\n }\n\n public updateRenderCache(\n dirtyLines: Map<number, Array<HighlightedToken>>,\n themeType: 'dark' | 'light',\n lineCountChangeInFlight = false\n ): void {\n this.pendingStructuralRows = undefined;\n const { renderCache } = this;\n if (renderCache == null) {\n return;\n }\n const { file, result } = renderCache;\n if (result == null) {\n return;\n }\n const pendingStructuralRows = lineCountChangeInFlight\n ? new Map<number, HASTElement>()\n : undefined;\n this.pendingStructuralRows = pendingStructuralRows;\n // Same-line edits can update the document cache immediately. Structural\n // rows use post-edit indexes, so hold them until applyDocumentChange has\n // shifted the old cache; writing now would overwrite rows that must move.\n const lineCache =\n this.lineCache != null && isLineCacheForFile(this.lineCache, file)\n ? this.lineCache\n : undefined;\n for (const [line, tokens] of dirtyLines) {\n if (\n pendingStructuralRows == null &&\n lineCache != null &&\n line < lineCache.lines.length\n ) {\n const lineText = tokens.map((token) => token[2]).join('');\n lineCache.lines[line] = applyLineTextWithNewline(\n lineCache.lines[line] ?? '',\n lineText\n );\n }\n const row: HASTElement = {\n type: 'element',\n tagName: 'div',\n properties: {\n 'data-line': line + 1,\n 'data-line-type': 'context',\n 'data-line-index': line,\n },\n children: tokens.map(([char, fg, text]) => {\n if (char === 0 && fg === '') {\n if (text === '') {\n return {\n type: 'element',\n tagName: 'br',\n properties: {},\n children: [],\n };\n }\n return { type: 'text', value: text };\n }\n return {\n type: 'element',\n tagName: 'span',\n properties: {\n 'data-char': char,\n style: `color:${fg};`,\n },\n children: [{ type: 'text', value: text }],\n };\n }),\n };\n if (pendingStructuralRows != null) {\n pendingStructuralRows.set(line, row);\n } else {\n result.code[line] = row;\n }\n }\n\n result.baseThemeType = themeType;\n renderCache.isDirty = true;\n if (pendingStructuralRows == null && lineCache != null) {\n file.contents = lineCache.lines.join('');\n lineCache.sourceContents = file.contents;\n }\n }\n\n // normally triggered by the host when the document line count changes\n public applyDocumentChange(\n textDocument: TextDocument<'file', LAnnotation>\n ): void {\n const { pendingStructuralRows, renderCache } = this;\n this.pendingStructuralRows = undefined;\n if (renderCache == null) {\n return;\n }\n const { file, result } = renderCache;\n // Without a result there is nothing to reconcile the document against, so\n // do not record it either: the document cache must never claim line\n // counts the (possibly still highlighting) result cannot back, or the\n // async highlight pass would process lines that do not exist.\n if (result == null) {\n return undefined;\n }\n // Structural edits renumber cached HAST rows. Keep the unchanged prefix\n // and suffix, and plain-fill only the window that still needs tokenizing.\n const previousLines =\n this.lineCache != null && isLineCacheForFile(this.lineCache, file)\n ? this.lineCache.lines\n : linesFromFileContents(file.contents);\n const nextLines = linesFromFileContents(textDocument.getText());\n if (previousLines.length !== nextLines.length) {\n const maxShared = Math.min(previousLines.length, nextLines.length);\n let prefix = 0;\n while (\n prefix < maxShared &&\n previousLines[prefix] === nextLines[prefix]\n ) {\n prefix++;\n }\n let suffix = 0;\n while (\n suffix < maxShared - prefix &&\n previousLines[previousLines.length - 1 - suffix] ===\n nextLines[nextLines.length - 1 - suffix]\n ) {\n suffix++;\n }\n\n const previousCode = result.code;\n result.code = new Array(nextLines.length);\n for (let i = 0; i < prefix; i++) {\n result.code[i] = previousCode[i];\n }\n for (let i = 0; i < suffix; i++) {\n result.code[nextLines.length - 1 - i] =\n previousCode[previousLines.length - 1 - i];\n }\n if (pendingStructuralRows !== undefined) {\n for (const [line, row] of pendingStructuralRows) {\n if (line < nextLines.length) {\n result.code[line] = row;\n }\n }\n }\n for (let i = prefix; i < nextLines.length - suffix; i++) {\n result.code[i] ??= {\n type: 'element',\n tagName: 'div',\n properties: {\n 'data-line': i + 1,\n 'data-line-type': 'context',\n 'data-line-index': i,\n },\n children: [\n {\n type: 'element',\n tagName: 'span',\n properties: {\n 'data-char': 0,\n },\n children: [\n {\n type: 'text',\n value: textDocument.getLineText(i),\n },\n ],\n },\n ],\n };\n }\n for (let i = 0; i < result.code.length; i++) {\n const line = result.code[i];\n if (line?.type === 'element') {\n line.properties['data-line'] = i + 1;\n line.properties['data-line-index'] = i;\n }\n }\n renderCache.isDirty = true;\n }\n // Replace the old split-line cache with the authoritative edited document.\n this.lineCache = {\n cacheKey: file.cacheKey,\n file,\n sourceContents: file.contents,\n lines: nextLines,\n };\n this.textDocumentCache.set(file, textDocument);\n file.contents = textDocument.getText();\n }\n\n public renderFile(\n file: FileContents | undefined = this.file,\n renderRange: RenderRange = DEFAULT_RENDER_RANGE\n ): FileRenderResult | undefined {\n this.file = file;\n if (file == null) {\n this.pendingHighlightResult = undefined;\n return undefined;\n }\n let { options, forceHighlight } = this.getRenderOptions(file);\n const readyResult = this.getReadyRenderResult(file, options);\n this.pendingHighlightResult = undefined;\n if (readyResult != null) {\n this.renderCache = {\n ...readyResult,\n file,\n renderRange: undefined,\n };\n forceHighlight = false;\n }\n this.renderCache ??= {\n file,\n highlighted: false,\n options,\n result: undefined,\n renderRange: undefined,\n };\n const lines = this.getOrCreateLineCache(file);\n const hasContent = file.contents.length > 0;\n const forcePlainText =\n !hasContent ||\n isFilePlainText(file) ||\n isFileMassive(lines.length, this.getTokenizeMaxLength());\n const canRenderFile = this.canRenderFile(file, options, forcePlainText);\n const newContent = !areFileTargetsEqual(file, this.renderCache.file);\n const newRenderRange = !areRenderRangesEqual(\n this.renderCache.renderRange,\n renderRange\n );\n if (\n !this.editSessionActive &&\n this.workerManager?.isWorkingPool() === true\n ) {\n // Hydration has highlighted DOM but no local AST. Keep that DOM until\n // its corresponding worker result is ready.\n const preserveHydratedContent =\n this.renderCache.result == null &&\n this.renderCache.highlighted &&\n !forcePlainText &&\n !newContent &&\n isDefaultRenderRange(renderRange);\n if (\n canRenderFile &&\n !preserveHydratedContent &&\n (forcePlainText ||\n this.renderCache.result == null ||\n (!this.renderCache.highlighted && (newContent || newRenderRange)))\n ) {\n this.renderCache.file = file;\n this.renderCache.options = options;\n this.renderCache.highlighted = false;\n if (\n this.renderCache.result == null ||\n newContent ||\n newRenderRange ||\n forceHighlight\n ) {\n this.renderCache.result = this.workerManager.getPlainFileAST(\n file,\n renderRange.startingLine,\n renderRange.totalLines,\n lines\n );\n }\n this.renderCache.renderRange = renderRange;\n }\n\n if (\n !forcePlainText &&\n hasContent &&\n (!this.renderCache.highlighted || forceHighlight)\n ) {\n this.workerManager.highlightFileAST(this, file);\n }\n } else {\n this.computedLang = file.lang ?? getFiletypeFromFileName(file.name);\n const hasThemes =\n this.highlighter != null && areThemesAttached(options.theme);\n const hasLangs =\n this.highlighter != null && areLanguagesAttached(this.computedLang);\n const canHighlight = !forcePlainText && hasLangs;\n\n // If we have any semblance of a highlighter with the correct theme(s)\n // attached, we can kick off some form of rendering. If we don't have\n // the correct language, then we can render plain text and after kick off\n // an async job to get the highlighted AST\n if (\n canRenderFile &&\n this.highlighter != null &&\n hasThemes &&\n (forceHighlight ||\n forcePlainText ||\n (!this.renderCache.highlighted && canHighlight) ||\n this.renderCache.result == null)\n ) {\n const { result, options } = this.renderFileWithHighlighter(\n file,\n this.highlighter,\n forcePlainText || !hasLangs\n );\n this.renderCache = {\n file,\n options,\n highlighted: canHighlight,\n result,\n renderRange: undefined,\n };\n }\n\n // If we get in here it means we'll have to kick off an async highlight\n // process which will involve initializing the highlighter with new themes\n // and languages\n if (!hasThemes || (!forcePlainText && !hasLangs)) {\n void this.asyncHighlight(file).then(({ result, options }) => {\n this.applyHighlightResult(file, result, options, !forcePlainText);\n });\n }\n }\n\n return this.renderCache.result != null\n ? this.processFileResult(\n this.renderCache.file,\n renderRange,\n this.renderCache.result\n )\n : undefined;\n }\n\n async asyncRender(\n file: FileContents,\n renderRange: RenderRange = DEFAULT_RENDER_RANGE\n ): Promise<FileRenderResult> {\n this.file = file;\n const { result } = await this.asyncHighlight(file);\n return this.processFileResult(file, renderRange, result);\n }\n\n private async asyncHighlight(file: FileContents): Promise<RenderFileResult> {\n const lines = this.getOrCreateLineCache(file);\n const forcePlainText = isFileMassive(\n lines.length,\n this.getTokenizeMaxLength()\n );\n this.computedLang = forcePlainText\n ? 'text'\n : (file.lang ?? getFiletypeFromFileName(file.name));\n const hasThemes =\n this.highlighter != null &&\n hasResolvedThemes(getThemes(this.getLocalHighlightTheme()));\n const hasLangs =\n forcePlainText ||\n (this.highlighter != null && areLanguagesAttached(this.computedLang));\n // If we don't have the required langs or themes, then we need to\n // initialize the highlighter to load the appropriate languages and themes\n if (this.highlighter == null || !hasThemes || !hasLangs) {\n this.highlighter = await this.initializeHighlighter();\n }\n return this.renderFileWithHighlighter(\n file,\n this.highlighter,\n forcePlainText\n );\n }\n\n private renderFileWithHighlighter(\n file: FileContents,\n highlighter: DiffsHighlighter,\n forcePlainText = false\n ): RenderFileResult {\n const { options } = this.getRenderOptions(file);\n const result = renderFileWithHighlighter(file, highlighter, options, {\n forcePlainText,\n });\n return { result, options };\n }\n\n private processFileResult(\n file: FileContents,\n renderRange: RenderRange,\n { code, themeStyles, baseThemeType }: ThemedFileResult\n ): FileRenderResult {\n const totalLines = this.getLineCount(file);\n const { disableFileHeader = false } = this.options;\n const contentArray: ElementContent[] = [];\n const gutter = createGutterWrapper();\n const endLine = Math.min(\n renderRange.startingLine + renderRange.totalLines,\n totalLines\n );\n let rowCount = 0;\n\n const fileLevelAnnotations = shouldRenderFileAnnotations(renderRange)\n ? getFileAnnotations(this.lineAnnotations)\n : undefined;\n if (fileLevelAnnotations != null) {\n gutter.children.push(createGutterGap('context', 'annotation', 1));\n contentArray.push(\n createAnnotationElement({\n type: 'annotation',\n hunkIndex: FILE_ANNOTATION_HUNK_INDEX,\n lineIndex: FILE_ANNOTATION_LINE_INDEX,\n annotations: fileLevelAnnotations.map((annotation) =>\n this.annotationSlotName(annotation)\n ),\n })\n );\n rowCount++;\n }\n\n for (\n let lineIndex = renderRange.startingLine;\n lineIndex < endLine;\n lineIndex++\n ) {\n const lineNumber = lineIndex + 1;\n\n // Sparse array - directly indexed by lineIndex\n const line = code[lineIndex];\n if (line == null) {\n const message = 'FileRenderer.processFileResult: Line doesnt exist';\n console.error(message, {\n name: file.name,\n lineIndex,\n lineNumber,\n });\n throw new Error(message);\n }\n\n // Add gutter line number\n gutter.children.push(\n createGutterItem('context', lineNumber, `${lineIndex}`)\n );\n contentArray.push(line);\n rowCount++;\n\n // Check annotations using ACTUAL line number from file\n const annotations = this.lineAnnotations[lineNumber];\n if (annotations != null) {\n gutter.children.push(createGutterGap('context', 'annotation', 1));\n contentArray.push(\n createAnnotationElement({\n type: 'annotation',\n hunkIndex: 0,\n lineIndex: lineNumber,\n annotations: annotations.map((annotation) =>\n this.annotationSlotName(annotation)\n ),\n })\n );\n rowCount++;\n }\n }\n\n // Finalize: wrap gutter and content\n gutter.properties.style = `grid-row: span ${rowCount}`;\n return {\n file,\n gutterAST: gutter.children ?? [],\n contentAST: contentArray,\n preAST: this.createPreElement(totalLines),\n headerAST: !disableFileHeader ? this.renderHeader(file) : undefined,\n totalLines: totalLines,\n rowCount,\n themeStyles: themeStyles,\n baseThemeType,\n bufferBefore: renderRange.bufferBefore,\n bufferAfter: renderRange.bufferAfter,\n css: '',\n };\n }\n\n private renderHeader(file: FileContents) {\n const { headerRenderMode = 'default', stickyHeader = false } = this.options;\n return createFileHeaderElement({\n fileOrDiff: file,\n mode: headerRenderMode,\n stickyHeader,\n });\n }\n\n public renderFullHTML(result: FileRenderResult): string {\n return toHtml(this.renderFullAST(result));\n }\n\n public renderFullAST(\n result: FileRenderResult,\n children: ElementContent[] = []\n ): HASTElement {\n children.push(\n createHastElement({\n tagName: 'code',\n children: this.renderCodeAST(result),\n properties: { 'data-code': '' },\n })\n );\n return { ...result.preAST, children };\n }\n\n public renderCodeAST(result: FileRenderResult): ElementContent[] {\n const gutter = createGutterWrapper();\n gutter.children = result.gutterAST;\n gutter.properties.style = `grid-row: span ${result.rowCount}`;\n const contentColumn = createContentColumn(\n result.contentAST,\n result.rowCount\n );\n return [gutter, contentColumn];\n }\n\n public renderPartialHTML(\n children: ElementContent[],\n includeCodeNode: boolean = false\n ): string {\n if (!includeCodeNode) {\n return toHtml(children);\n }\n return toHtml(\n createHastElement({\n tagName: 'code',\n children,\n properties: { 'data-code': '' },\n })\n );\n }\n\n public async initializeHighlighter(): Promise<DiffsHighlighter> {\n this.highlighter = await getSharedHighlighter(\n getHighlighterOptions(this.computedLang, {\n theme: this.getLocalHighlightTheme(),\n preferredHighlighter:\n this.workerManager?.getPreferredHighlighter() ??\n this.options.preferredHighlighter,\n })\n );\n return this.highlighter;\n }\n\n public onHighlightSuccess(\n file: FileContents,\n result: ThemedFileResult,\n options: RenderFileOptions,\n highlighted = true\n ): void {\n if (this.editSessionActive) {\n return;\n }\n this.applyHighlightResult(file, result, options, highlighted);\n }\n\n private applyHighlightResult(\n file: FileContents,\n result: ThemedFileResult,\n options: RenderFileOptions,\n highlighted = true\n ): void {\n const { file: currentFile, renderCache } = this;\n if (\n currentFile == null ||\n renderCache == null ||\n !areFileTargetsEqual(file, currentFile) ||\n !areFileRenderOptionsEqual(\n options,\n this.getRenderOptions(currentFile).options\n )\n ) {\n return;\n }\n\n const triggerRender =\n renderCache.result == null ||\n !renderCache.highlighted ||\n !areFileRenderOptionsEqual(renderCache.options, options) ||\n !areFileTargetsEqual(renderCache.file, currentFile);\n if (!triggerRender) {\n return;\n }\n\n this.pendingHighlightResult = {\n file: currentFile,\n options,\n highlighted,\n result,\n };\n this.onRenderUpdate?.();\n }\n\n private getMatchingWorkerResultCache(\n file: FileContents,\n options: RenderFileOptions\n ): RenderFileResult | undefined {\n if (this.editSessionActive) {\n return undefined;\n }\n const cache = this.workerManager?.getFileResultCache(file);\n if (cache == null || !areFileRenderOptionsEqual(options, cache.options)) {\n return undefined;\n }\n return cache;\n }\n\n // Returns completed background work that can replace the rendered AST on\n // the next render. Reading it does not promote or discard pending work.\n private getReadyRenderResult(\n file: FileContents,\n options: RenderFileOptions\n ): PendingHighlightResult | undefined {\n const { pendingHighlightResult } = this;\n if (\n pendingHighlightResult != null &&\n areFileTargetsEqual(pendingHighlightResult.file, file) &&\n areFileRenderOptionsEqual(pendingHighlightResult.options, options)\n ) {\n return pendingHighlightResult;\n }\n\n const workerCache = this.getMatchingWorkerResultCache(file, options);\n if (workerCache == null || this.hasHighlightedRenderCache(file, options)) {\n return undefined;\n }\n return { file, highlighted: true, ...workerCache };\n }\n\n private hasHighlightedRenderCache(\n file: FileContents,\n options: RenderFileOptions\n ): boolean {\n const { renderCache } = this;\n return (\n renderCache?.result != null &&\n renderCache.highlighted &&\n areFileTargetsEqual(file, renderCache.file) &&\n areFileRenderOptionsEqual(options, renderCache.options)\n );\n }\n\n public onHighlightError(error: unknown): void {\n console.error(error);\n }\n\n private getTokenizeMaxLength(): number {\n return this.options.tokenizeMaxLength ?? DEFAULT_TOKENIZE_MAX_LENGTH;\n }\n\n private createPreElement(totalLines: number): HASTElement {\n const { disableLineNumbers = false, overflow = 'scroll' } = this.options;\n return createPreElement({\n type: 'file',\n diffIndicators: 'none',\n disableBackground: true,\n disableLineNumbers,\n overflow,\n split: false,\n totalLines,\n });\n }\n}\n\nfunction isFileMassive(l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AAoB,MAAM,YAAY,IAAI,KAC1C,0BAA0B,SAAS,YAAY,OAAO;CAE1D;CAEA,iBAAwB,OAAsB;EAC5C,QAAQ,MAAM,KAAK;CACrB;CAEA,uBAAuC;EACrC,OAAO,KAAK,QAAQ,qBAAA;CACtB;CAEA,iBAAyB,YAAiC;EACxD,MAAM,EAAE,qBAAqB,OAAO,WAAW,aAAa,KAAK;EACjE,OAAO,iBAAiB;GACtB,MAAM;GACN,gBAAgB;GAChB,mBAAmB;GACnB;GACA;GACA,OAAO;GACP;EACF,CAAC;CACH;AACF;AAEA,SAAS,cAAc,WAAmB,mBAAoC;CAC5E,OAAO,YAAY;AACrB"}
@@ -1,5 +1,5 @@
1
1
  import { Element } from "../node_modules/.pnpm/@types_hast@3.0.4/node_modules/@types/hast/index.js";
2
- import { FileDiffMetadata, MergeConflictMarkerRow, RenderRange } from "../types.js";
2
+ import { DiffLineAnnotation, FileDiffMetadata, MergeConflictMarkerRow, RenderRange } from "../types.js";
3
3
  import { WorkerPoolManager } from "../worker/WorkerPoolManager.js";
4
4
  import { DiffHunksRenderer, DiffHunksRendererOptions, DiffHunksRendererOptionsWithDefaults, HunksRenderResult, LineDecoration, RenderedLineContext, SplitLineDecorationProps, UnifiedInjectedRowPlacement, UnifiedLineDecorationProps } from "./DiffHunksRenderer.js";
5
5
  import { MergeConflictDiffAction } from "../utils/parseMergeConflictDiffFromFile.js";
@@ -17,7 +17,7 @@ declare class UnresolvedFileHunksRenderer<LAnnotation = undefined> extends DiffH
17
17
  private pendingMarkerRows;
18
18
  private injectedRows;
19
19
  options: UnresolvedFileHunksRendererOptions;
20
- constructor(options?: UnresolvedFileHunksRendererOptions, onRenderUpdate?: () => unknown, workerManager?: WorkerPoolManager | undefined);
20
+ constructor(options?: UnresolvedFileHunksRendererOptions, annotationSlotName?: (annotation: DiffLineAnnotation<LAnnotation>) => string, onRenderUpdate?: () => unknown, workerManager?: WorkerPoolManager | undefined);
21
21
  setConflictState(conflictActions: (MergeConflictDiffAction | undefined)[], markerRows: MergeConflictMarkerRow[], diff: FileDiffMetadata): void;
22
22
  private syncInjectedRows;
23
23
  private addInjectedRow;
@@ -1 +1 @@
1
- {"version":3,"file":"UnresolvedFileHunksRenderer.d.ts","names":[],"sources":["../../src/renderers/UnresolvedFileHunksRenderer.ts"],"mappings":";;;;;;;UA8DU,iCAAA,SAA0C,oCAAoC;EACtF,wBAAA,EAA0B,wBAAA;AAAA;AAAA,KAGvB,wBAAA;AAAA,UAEY,kCAAA,SAA2C,wBAAwB;EAClF,wBAAA,GAA2B,wBAAA;AAAA;AAAA,cAGhB,2BAAA,kCAEH,iBAAA,CAAkB,WAAA;EAAA,QAClB,sBAAA;EAAA,QACA,iBAAA;EAAA,QACA,YAAA;EACQ,OAAA,EAAS,kCAAA;EAEzB,WAAA,CACE,OAAA,GAAS,kCAAA,EAGT,cAAA,kBACA,aAAA,GAAgB,iBAAA;EAWX,gBAAA,CACL,eAAA,GAAkB,uBAAA,iBAClB,UAAA,EAAY,sBAAA,IACZ,IAAA,EAAM,gBAAA;EAAA,QAOA,gBAAA;EAAA,QA0BA,cAAA;EAUQ,UAAA,CACd,IAAA,GAAO,gBAAA,cACP,WAAA,GAAa,WAAA,GACZ,iBAAA;EAWmB,WAAA,CACpB,IAAA,EAAM,gBAAA,EACN,WAAA,GAAa,WAAA,GACZ,OAAA,CAAQ,iBAAA;EAAA,UASQ,gBAAA,CACjB,KAAA,WACA,UAAA,WACC,OAAA;EAAA,UAMgB,wBAAA;IACjB,IAAA;IACA;EAAA,GACC,0BAAA,GAA6B,cAAA;EAAA,UAiBb,sBAAA;IACjB,IAAA;IACA;EAAA,GACC,wBAAA,GAA2B,cAAA;EAAA,UAiBX,6BAAA,GAA6B,GAAA,EACzC,mBAAA,KACJ,2BAAA;EAAA,UAgCgB,sBAAA,IAA0B,iCAAA;AAAA"}
1
+ {"version":3,"file":"UnresolvedFileHunksRenderer.d.ts","names":[],"sources":["../../src/renderers/UnresolvedFileHunksRenderer.ts"],"mappings":";;;;;;;UA+DU,iCAAA,SAA0C,oCAAoC;EACtF,wBAAA,EAA0B,wBAAA;AAAA;AAAA,KAGvB,wBAAA;AAAA,UAEY,kCAAA,SAA2C,wBAAwB;EAClF,wBAAA,GAA2B,wBAAA;AAAA;AAAA,cAGhB,2BAAA,kCAEH,iBAAA,CAAkB,WAAA;EAAA,QAClB,sBAAA;EAAA,QACA,iBAAA;EAAA,QACA,YAAA;EACQ,OAAA,EAAS,kCAAA;EAEzB,WAAA,CACE,OAAA,GAAS,kCAAA,EAGT,kBAAA,IACE,UAAA,EAAY,kBAAA,CAAmB,WAAA,cAEjC,cAAA,kBACA,aAAA,GAAgB,iBAAA;EAWX,gBAAA,CACL,eAAA,GAAkB,uBAAA,iBAClB,UAAA,EAAY,sBAAA,IACZ,IAAA,EAAM,gBAAA;EAAA,QAOA,gBAAA;EAAA,QA0BA,cAAA;EAUQ,UAAA,CACd,IAAA,GAAO,gBAAA,cACP,WAAA,GAAa,WAAA,GACZ,iBAAA;EAWmB,WAAA,CACpB,IAAA,EAAM,gBAAA,EACN,WAAA,GAAa,WAAA,GACZ,OAAA,CAAQ,iBAAA;EAAA,UASQ,gBAAA,CACjB,KAAA,WACA,UAAA,WACC,OAAA;EAAA,UAMgB,wBAAA;IACjB,IAAA;IACA;EAAA,GACC,0BAAA,GAA6B,cAAA;EAAA,UAiBb,sBAAA;IACjB,IAAA;IACA;EAAA,GACC,wBAAA,GAA2B,cAAA;EAAA,UAiBX,6BAAA,GAA6B,GAAA,EACzC,mBAAA,KACJ,2BAAA;EAAA,UAgCgB,sBAAA,IAA0B,iCAAA;AAAA"}
@@ -9,8 +9,8 @@ var UnresolvedFileHunksRenderer = class extends DiffHunksRenderer {
9
9
  pendingMarkerRows = [];
10
10
  injectedRows = /* @__PURE__ */ new Map();
11
11
  options;
12
- constructor(options = { theme: DEFAULT_THEMES }, onRenderUpdate, workerManager) {
13
- super(void 0, onRenderUpdate, workerManager);
12
+ constructor(options = { theme: DEFAULT_THEMES }, annotationSlotName, onRenderUpdate, workerManager) {
13
+ super(void 0, annotationSlotName, onRenderUpdate, workerManager);
14
14
  this.options = options;
15
15
  }
16
16
  setConflictState(conflictActions, markerRows, diff) {
@@ -1 +1 @@
1
- {"version":3,"file":"UnresolvedFileHunksRenderer.js","names":[],"sources":["../../src/renderers/UnresolvedFileHunksRenderer.ts"],"sourcesContent":["import type { Element as HASTElement, Properties } from 'hast';\n\nimport { DEFAULT_RENDER_RANGE, DEFAULT_THEMES } from '../constants';\nimport type {\n FileDiffMetadata,\n MergeConflictMarkerRow,\n MergeConflictResolution,\n RenderRange,\n} from '../types';\nimport { getMergeConflictActionSlotName } from '../utils/getMergeConflictActionSlotName';\nimport {\n createGutterGap,\n createHastElement,\n createTextNodeElement,\n} from '../utils/hast_utils';\nimport {\n getMergeConflictActionAnchor,\n type MergeConflictDiffAction,\n} from '../utils/parseMergeConflictDiffFromFile';\nimport type { WorkerPoolManager } from '../worker';\nimport {\n DiffHunksRenderer,\n type DiffHunksRendererOptions,\n type DiffHunksRendererOptionsWithDefaults,\n type HunksRenderResult,\n type InjectedRow,\n type LineDecoration,\n type RenderedLineContext,\n type SplitLineDecorationProps,\n type UnifiedInjectedRowPlacement,\n type UnifiedLineDecorationProps,\n} from './DiffHunksRenderer';\n\ntype MergeConflictMarkerType =\n | 'marker-start'\n | 'marker-base'\n | 'marker-separator'\n | 'marker-end'\n | 'current'\n | 'incoming';\n\ninterface MergeConflictActionRowData {\n hunkIndex: number;\n lineIndex: number;\n conflictIndex: number;\n}\n\ninterface MergeConflictMarkerInjectedRow extends MergeConflictMarkerRow {\n type: Extract<\n MergeConflictMarkerRow['type'],\n 'marker-start' | 'marker-base' | 'marker-separator' | 'marker-end'\n >;\n lineText: string;\n lineIndex: number;\n}\n\n// NOTE(amadeus): Don't love this, should probably rework into an\n// interface/extender\ntype MergeConflictInjectedRowData =\n | ({ type: 'actions' } & MergeConflictActionRowData)\n | MergeConflictMarkerInjectedRow;\n\ninterface BaseUnresolvedOptionsWithDefaults extends DiffHunksRendererOptionsWithDefaults {\n mergeConflictActionsType: MergeConflictActionsType;\n}\n\ntype MergeConflictActionsType = 'none' | 'default' | 'custom';\n\nexport interface UnresolvedFileHunksRendererOptions extends DiffHunksRendererOptions {\n mergeConflictActionsType?: MergeConflictActionsType;\n}\n\nexport class UnresolvedFileHunksRenderer<\n LAnnotation = undefined,\n> extends DiffHunksRenderer<LAnnotation> {\n private pendingConflictActions: (MergeConflictDiffAction | undefined)[] = [];\n private pendingMarkerRows: MergeConflictMarkerRow[] = [];\n private injectedRows = new Map<string, MergeConflictInjectedRowData[]>();\n public override options: UnresolvedFileHunksRendererOptions;\n\n constructor(\n options: UnresolvedFileHunksRendererOptions = {\n theme: DEFAULT_THEMES,\n },\n onRenderUpdate?: () => unknown,\n workerManager?: WorkerPoolManager | undefined\n ) {\n super(undefined, onRenderUpdate, workerManager);\n this.options = options;\n }\n\n // SELF_REVIEW: I don't love how this is hooked up with `renderDiff` right\n // now, so we definitely need to figure out what the fuck we are gonna do\n // about it...\n // I think at the very least we should keep it like annotations, and just\n // sorta assume there's a disconnect there\n public setConflictState(\n conflictActions: (MergeConflictDiffAction | undefined)[],\n markerRows: MergeConflictMarkerRow[],\n diff: FileDiffMetadata\n ): void {\n this.pendingConflictActions = conflictActions;\n this.pendingMarkerRows = markerRows;\n this.syncInjectedRows(conflictActions, markerRows, diff);\n }\n\n private syncInjectedRows(\n conflictActions: (MergeConflictDiffAction | undefined)[],\n markerRows: MergeConflictMarkerRow[],\n diff: FileDiffMetadata\n ): void {\n this.injectedRows.clear();\n for (const action of conflictActions) {\n const anchor =\n action != null ? getMergeConflictActionAnchor(action, diff) : undefined;\n if (action == null || anchor == null) {\n continue;\n }\n const row: MergeConflictInjectedRowData = {\n type: 'actions',\n hunkIndex: anchor.hunkIndex,\n lineIndex: anchor.lineIndex,\n conflictIndex: action.conflictIndex,\n };\n this.addInjectedRow(row);\n }\n\n for (const row of markerRows) {\n this.addInjectedRow(row);\n }\n }\n\n private addInjectedRow(row: MergeConflictInjectedRowData): void {\n const key = `${row.hunkIndex}:${row.lineIndex}`;\n const rows = this.injectedRows.get(key);\n if (rows == null) {\n this.injectedRows.set(key, [row]);\n } else {\n rows.push(row);\n }\n }\n\n public override renderDiff(\n diff?: FileDiffMetadata | undefined,\n renderRange: RenderRange = DEFAULT_RENDER_RANGE\n ): HunksRenderResult | undefined {\n if (diff != null) {\n this.syncInjectedRows(\n this.pendingConflictActions,\n this.pendingMarkerRows,\n diff\n );\n }\n return super.renderDiff(diff, renderRange);\n }\n\n public override async asyncRender(\n diff: FileDiffMetadata,\n renderRange: RenderRange = DEFAULT_RENDER_RANGE\n ): Promise<HunksRenderResult> {\n this.syncInjectedRows(\n this.pendingConflictActions,\n this.pendingMarkerRows,\n diff\n );\n return super.asyncRender(diff, renderRange);\n }\n\n protected override createPreElement(\n split: boolean,\n totalLines: number\n ): HASTElement {\n return super.createPreElement(split, totalLines, {\n 'data-has-merge-conflict': '',\n });\n }\n\n protected override getUnifiedLineDecoration({\n type,\n lineType,\n }: UnifiedLineDecorationProps): LineDecoration {\n const mergeConflictType =\n type === 'change'\n ? lineType === 'change-deletion'\n ? 'current'\n : 'incoming'\n : undefined;\n return {\n gutterLineType: type === 'change' ? 'context' : lineType,\n gutterProperties: getMergeConflictGutterProperties(mergeConflictType),\n contentProperties: getMergeConflictContentProperties(\n type,\n mergeConflictType\n ),\n };\n }\n\n protected override getSplitLineDecoration({\n side,\n type,\n }: SplitLineDecorationProps): LineDecoration {\n const mergeConflictType =\n type === 'change'\n ? side === 'deletions'\n ? 'current'\n : 'incoming'\n : undefined;\n return {\n gutterLineType: type === 'change' ? 'context' : type,\n gutterProperties: getMergeConflictGutterProperties(mergeConflictType),\n contentProperties: getMergeConflictContentProperties(\n type,\n mergeConflictType\n ),\n };\n }\n\n protected override getUnifiedInjectedRowsForLine = (\n ctx: RenderedLineContext\n ): UnifiedInjectedRowPlacement | undefined => {\n const rows = this.injectedRows.get(`${ctx.hunkIndex}:${ctx.lineIndex}`);\n if (rows == null || rows.length === 0) {\n return undefined;\n }\n const { mergeConflictActionsType } = this.getOptionsWithDefaults();\n const before: InjectedRow[] = [];\n const after: InjectedRow[] = [];\n for (const row of rows) {\n if (row.type === 'actions') {\n before.push({\n content: createMergeConflictActionsRowElement({\n row,\n includeDefaultActions: mergeConflictActionsType === 'default',\n includeSlot: true,\n }),\n gutter: createMergeConflictGutterGap('action'),\n });\n continue;\n }\n const target = row.type === 'marker-end' ? after : before;\n target.push({\n content: createMergeConflictMarkerRowElement(row),\n gutter: createMergeConflictGutterGap('marker', row.type),\n });\n }\n return {\n before: before.length > 0 ? before : undefined,\n after: after.length > 0 ? after : undefined,\n };\n };\n\n protected override getOptionsWithDefaults(): BaseUnresolvedOptionsWithDefaults {\n const options = super.getOptionsWithDefaults();\n options.diffStyle = 'unified';\n options.lineDiffType = 'none';\n // NOTE(amadeus): Aint nobody got time for a spread\n (options as BaseUnresolvedOptionsWithDefaults).mergeConflictActionsType =\n this.options.mergeConflictActionsType ?? 'default';\n return options as BaseUnresolvedOptionsWithDefaults;\n }\n}\n\nfunction getMergeConflictGutterProperties(\n mergeConflictType: MergeConflictMarkerType | undefined\n): Properties | undefined {\n return mergeConflictType != null\n ? { 'data-merge-conflict': mergeConflictType }\n : undefined;\n}\n\nfunction getMergeConflictContentProperties(\n type: 'change' | 'context' | 'context-expanded',\n mergeConflictType: MergeConflictMarkerType | undefined\n): Properties | undefined {\n if (mergeConflictType == null) {\n return undefined;\n }\n if (type === 'change') {\n if (mergeConflictType === 'current' || mergeConflictType === 'incoming') {\n return {\n 'data-line-type': 'context',\n 'data-merge-conflict': mergeConflictType,\n };\n }\n return undefined;\n }\n if (\n mergeConflictType === 'marker-start' ||\n mergeConflictType === 'marker-base' ||\n mergeConflictType === 'marker-separator' ||\n mergeConflictType === 'marker-end'\n ) {\n return { 'data-merge-conflict': mergeConflictType };\n }\n return undefined;\n}\n\nfunction createMergeConflictGutterGap(\n type: 'action' | 'marker',\n markerType?: MergeConflictMarkerInjectedRow['type']\n): HASTElement {\n const gap = createGutterGap(undefined, 'annotation', 1);\n gap.properties['data-gutter-buffer'] =\n type === 'action'\n ? 'merge-conflict-action'\n : `merge-conflict-${markerType ?? 'marker'}`;\n return gap;\n}\n\ninterface CreateMergeConflictActionsRowElementProps {\n row: MergeConflictActionRowData;\n includeDefaultActions: boolean;\n includeSlot: boolean;\n}\n\nfunction createMergeConflictActionsRowElement({\n row,\n includeDefaultActions,\n includeSlot,\n}: CreateMergeConflictActionsRowElementProps): HASTElement {\n const contentChildren: HASTElement[] = includeDefaultActions\n ? createMergeConflictActionsContent(row.conflictIndex)\n : [];\n if (includeSlot) {\n contentChildren.push(\n createHastElement({\n tagName: 'slot',\n properties: {\n name: getMergeConflictActionSlotName({\n hunkIndex: row.hunkIndex,\n lineIndex: row.lineIndex,\n conflictIndex: row.conflictIndex,\n }),\n 'data-merge-conflict-action-slot': '',\n },\n })\n );\n }\n return createHastElement({\n tagName: 'div',\n properties: {\n 'data-merge-conflict-actions': '',\n },\n children: [\n createHastElement({\n tagName: 'div',\n properties: { 'data-merge-conflict-actions-content': '' },\n children: contentChildren,\n }),\n ],\n });\n}\n\nfunction createMergeConflictMarkerRowElement(\n row: MergeConflictMarkerInjectedRow\n): HASTElement {\n return createHastElement({\n tagName: 'div',\n properties: {\n 'data-merge-conflict': row.type,\n 'data-merge-conflict-marker-row': '',\n },\n children: [\n createTextNodeElement(row.lineText.replace(/(?:\\r\\n|\\n|\\r)$/, '')),\n ],\n });\n}\n\nfunction createMergeConflictActionsContent(\n conflictIndex: number\n): HASTElement[] {\n return [\n createMergeConflictActionButton({\n resolution: 'current',\n label: 'Accept current change',\n conflictIndex,\n }),\n createMergeConflictActionSeparator(),\n createMergeConflictActionButton({\n resolution: 'incoming',\n label: 'Accept incoming change',\n conflictIndex,\n }),\n createMergeConflictActionSeparator(),\n createMergeConflictActionButton({\n resolution: 'both',\n label: 'Accept both',\n conflictIndex,\n }),\n ];\n}\n\ninterface CreateMergeConflictActionButtonProps {\n resolution: MergeConflictResolution;\n label: string;\n conflictIndex: number;\n}\n\nfunction createMergeConflictActionButton({\n resolution,\n label,\n conflictIndex,\n}: CreateMergeConflictActionButtonProps): HASTElement {\n return createHastElement({\n tagName: 'button',\n properties: {\n type: 'button',\n 'data-merge-conflict-action': resolution,\n 'data-merge-conflict-conflict-index': `${conflictIndex}`,\n },\n children: [createTextNodeElement(label)],\n });\n}\n\nfunction createMergeConflictActionSeparator(): HASTElement {\n return createHastElement({\n tagName: 'span',\n properties: { 'data-merge-conflict-action-separator': '' },\n children: [createTextNodeElement('|')],\n });\n}\n"],"mappings":";;;;;;AAwEA,IAAa,8BAAb,cAEU,kBAA+B;CACvC,yBAA0E,CAAC;CAC3E,oBAAsD,CAAC;CACvD,+BAAuB,IAAI,IAA4C;CACvE;CAEA,YACE,UAA8C,EAC5C,OAAO,eACT,GACA,gBACA,eACA;EACA,MAAM,KAAA,GAAW,gBAAgB,aAAa;EAC9C,KAAK,UAAU;CACjB;CAOA,iBACE,iBACA,YACA,MACM;EACN,KAAK,yBAAyB;EAC9B,KAAK,oBAAoB;EACzB,KAAK,iBAAiB,iBAAiB,YAAY,IAAI;CACzD;CAEA,iBACE,iBACA,YACA,MACM;EACN,KAAK,aAAa,MAAM;EACxB,KAAK,MAAM,UAAU,iBAAiB;GACpC,MAAM,SACJ,UAAU,OAAO,6BAA6B,QAAQ,IAAI,IAAI,KAAA;GAChE,IAAI,UAAU,QAAQ,UAAU,MAC9B;GAEF,MAAM,MAAoC;IACxC,MAAM;IACN,WAAW,OAAO;IAClB,WAAW,OAAO;IAClB,eAAe,OAAO;GACxB;GACA,KAAK,eAAe,GAAG;EACzB;EAEA,KAAK,MAAM,OAAO,YAChB,KAAK,eAAe,GAAG;CAE3B;CAEA,eAAuB,KAAyC;EAC9D,MAAM,MAAM,GAAG,IAAI,UAAU,GAAG,IAAI;EACpC,MAAM,OAAO,KAAK,aAAa,IA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,IAAI;GACrB,CAAC;GACD,mCAAmC;EACrC;CACF,CAAC,CACH;CAEF,OAAO,kBAAkB;EACvB,SAAS;EACT,YAAY,EACV,+BAA+B,GACjC;EACA,UAAU,CACR,kBAAkB;GAChB,SAAS;GACT,YAAY,EAAE,uCAAuC,GAAG;GACxD,UAAU;EACZ,CAAC,CACH;CACF,CAAC;AACH;AAEA,SAAS,oCACP,KACa;CACb,OAAO,kBAAkB;EACvB,SAAS;EACT,YAAY;GACV,uBAAuB,IAAI;GAC3B,kCAAkC;EACpC;EACA,UAAU,CACR,sBAAsB,IAAI,SAAS,QAAQ,mBAAmB,EAAE,CAAC,CACnE;CACF,CAAC;AACH;AAEA,SAAS,kCACP,eACe;CACf,OAAO;EACL,gCAAgC;GAC9B,YAAY;GACZ,OAAO;GACP;EACF,CAAC;EACD,mCAAmC;EACnC,gCAAgC;GAC9B,YAAY;GACZ,OAAO;GACP;EACF,CAAC;EACD,mCAAmC;EACnC,gCAAgC;GAC9B,YAAY;GACZ,OAAO;GACP;EACF,CAAC;CACH;AACF;AAQA,SAAS,gCAAgC,EACvC,YACA,OACA,iBACoD;CACpD,OAAO,kBAAkB;EACvB,SAAS;EACT,YAAY;GACV,MAAM;GACN,8BAA8B;GAC9B,sCAAsC,GAAG;EAC3C;EACA,UAAU,CAAC,sBAAsB,KAAK,CAAC;CACzC,CAAC;AACH;AAEA,SAAS,qCAAkD;CACzD,OAAO,kBAAkB;EACvB,SAAS;EACT,YAAY,EAAE,wCAAwC,GAAG;EACzD,UAAU,CAAC,sBAAsB,GAAG,CAAC;CACvC,CAAC;AACH"}
1
+ {"version":3,"file":"UnresolvedFileHunksRenderer.js","names":[],"sources":["../../src/renderers/UnresolvedFileHunksRenderer.ts"],"sourcesContent":["import type { Element as HASTElement, Properties } from 'hast';\n\nimport { DEFAULT_RENDER_RANGE, DEFAULT_THEMES } from '../constants';\nimport type {\n DiffLineAnnotation,\n FileDiffMetadata,\n MergeConflictMarkerRow,\n MergeConflictResolution,\n RenderRange,\n} from '../types';\nimport { getMergeConflictActionSlotName } from '../utils/getMergeConflictActionSlotName';\nimport {\n createGutterGap,\n createHastElement,\n createTextNodeElement,\n} from '../utils/hast_utils';\nimport {\n getMergeConflictActionAnchor,\n type MergeConflictDiffAction,\n} from '../utils/parseMergeConflictDiffFromFile';\nimport type { WorkerPoolManager } from '../worker';\nimport {\n DiffHunksRenderer,\n type DiffHunksRendererOptions,\n type DiffHunksRendererOptionsWithDefaults,\n type HunksRenderResult,\n type InjectedRow,\n type LineDecoration,\n type RenderedLineContext,\n type SplitLineDecorationProps,\n type UnifiedInjectedRowPlacement,\n type UnifiedLineDecorationProps,\n} from './DiffHunksRenderer';\n\ntype MergeConflictMarkerType =\n | 'marker-start'\n | 'marker-base'\n | 'marker-separator'\n | 'marker-end'\n | 'current'\n | 'incoming';\n\ninterface MergeConflictActionRowData {\n hunkIndex: number;\n lineIndex: number;\n conflictIndex: number;\n}\n\ninterface MergeConflictMarkerInjectedRow extends MergeConflictMarkerRow {\n type: Extract<\n MergeConflictMarkerRow['type'],\n 'marker-start' | 'marker-base' | 'marker-separator' | 'marker-end'\n >;\n lineText: string;\n lineIndex: number;\n}\n\n// NOTE(amadeus): Don't love this, should probably rework into an\n// interface/extender\ntype MergeConflictInjectedRowData =\n | ({ type: 'actions' } & MergeConflictActionRowData)\n | MergeConflictMarkerInjectedRow;\n\ninterface BaseUnresolvedOptionsWithDefaults extends DiffHunksRendererOptionsWithDefaults {\n mergeConflictActionsType: MergeConflictActionsType;\n}\n\ntype MergeConflictActionsType = 'none' | 'default' | 'custom';\n\nexport interface UnresolvedFileHunksRendererOptions extends DiffHunksRendererOptions {\n mergeConflictActionsType?: MergeConflictActionsType;\n}\n\nexport class UnresolvedFileHunksRenderer<\n LAnnotation = undefined,\n> extends DiffHunksRenderer<LAnnotation> {\n private pendingConflictActions: (MergeConflictDiffAction | undefined)[] = [];\n private pendingMarkerRows: MergeConflictMarkerRow[] = [];\n private injectedRows = new Map<string, MergeConflictInjectedRowData[]>();\n public override options: UnresolvedFileHunksRendererOptions;\n\n constructor(\n options: UnresolvedFileHunksRendererOptions = {\n theme: DEFAULT_THEMES,\n },\n annotationSlotName?: (\n annotation: DiffLineAnnotation<LAnnotation>\n ) => string,\n onRenderUpdate?: () => unknown,\n workerManager?: WorkerPoolManager | undefined\n ) {\n super(undefined, annotationSlotName, onRenderUpdate, workerManager);\n this.options = options;\n }\n\n // SELF_REVIEW: I don't love how this is hooked up with `renderDiff` right\n // now, so we definitely need to figure out what the fuck we are gonna do\n // about it...\n // I think at the very least we should keep it like annotations, and just\n // sorta assume there's a disconnect there\n public setConflictState(\n conflictActions: (MergeConflictDiffAction | undefined)[],\n markerRows: MergeConflictMarkerRow[],\n diff: FileDiffMetadata\n ): void {\n this.pendingConflictActions = conflictActions;\n this.pendingMarkerRows = markerRows;\n this.syncInjectedRows(conflictActions, markerRows, diff);\n }\n\n private syncInjectedRows(\n conflictActions: (MergeConflictDiffAction | undefined)[],\n markerRows: MergeConflictMarkerRow[],\n diff: FileDiffMetadata\n ): void {\n this.injectedRows.clear();\n for (const action of conflictActions) {\n const anchor =\n action != null ? getMergeConflictActionAnchor(action, diff) : undefined;\n if (action == null || anchor == null) {\n continue;\n }\n const row: MergeConflictInjectedRowData = {\n type: 'actions',\n hunkIndex: anchor.hunkIndex,\n lineIndex: anchor.lineIndex,\n conflictIndex: action.conflictIndex,\n };\n this.addInjectedRow(row);\n }\n\n for (const row of markerRows) {\n this.addInjectedRow(row);\n }\n }\n\n private addInjectedRow(row: MergeConflictInjectedRowData): void {\n const key = `${row.hunkIndex}:${row.lineIndex}`;\n const rows = this.injectedRows.get(key);\n if (rows == null) {\n this.injectedRows.set(key, [row]);\n } else {\n rows.push(row);\n }\n }\n\n public override renderDiff(\n diff?: FileDiffMetadata | undefined,\n renderRange: RenderRange = DEFAULT_RENDER_RANGE\n ): HunksRenderResult | undefined {\n if (diff != null) {\n this.syncInjectedRows(\n this.pendingConflictActions,\n this.pendingMarkerRows,\n diff\n );\n }\n return super.renderDiff(diff, renderRange);\n }\n\n public override async asyncRender(\n diff: FileDiffMetadata,\n renderRange: RenderRange = DEFAULT_RENDER_RANGE\n ): Promise<HunksRenderResult> {\n this.syncInjectedRows(\n this.pendingConflictActions,\n this.pendingMarkerRows,\n diff\n );\n return super.asyncRender(diff, renderRange);\n }\n\n protected override createPreElement(\n split: boolean,\n totalLines: number\n ): HASTElement {\n return super.createPreElement(split, totalLines, {\n 'data-has-merge-conflict': '',\n });\n }\n\n protected override getUnifiedLineDecoration({\n type,\n lineType,\n }: UnifiedLineDecorationProps): LineDecoration {\n const mergeConflictType =\n type === 'change'\n ? lineType === 'change-deletion'\n ? 'current'\n : 'incoming'\n : undefined;\n return {\n gutterLineType: type === 'change' ? 'context' : lineType,\n gutterProperties: getMergeConflictGutterProperties(mergeConflictType),\n contentProperties: getMergeConflictContentProperties(\n type,\n mergeConflictType\n ),\n };\n }\n\n protected override getSplitLineDecoration({\n side,\n type,\n }: SplitLineDecorationProps): LineDecoration {\n const mergeConflictType =\n type === 'change'\n ? side === 'deletions'\n ? 'current'\n : 'incoming'\n : undefined;\n return {\n gutterLineType: type === 'change' ? 'context' : type,\n gutterProperties: getMergeConflictGutterProperties(mergeConflictType),\n contentProperties: getMergeConflictContentProperties(\n type,\n mergeConflictType\n ),\n };\n }\n\n protected override getUnifiedInjectedRowsForLine = (\n ctx: RenderedLineContext\n ): UnifiedInjectedRowPlacement | undefined => {\n const rows = this.injectedRows.get(`${ctx.hunkIndex}:${ctx.lineIndex}`);\n if (rows == null || rows.length === 0) {\n return undefined;\n }\n const { mergeConflictActionsType } = this.getOptionsWithDefaults();\n const before: InjectedRow[] = [];\n const after: InjectedRow[] = [];\n for (const row of rows) {\n if (row.type === 'actions') {\n before.push({\n content: createMergeConflictActionsRowElement({\n row,\n includeDefaultActions: mergeConflictActionsType === 'default',\n includeSlot: true,\n }),\n gutter: createMergeConflictGutterGap('action'),\n });\n continue;\n }\n const target = row.type === 'marker-end' ? after : before;\n target.push({\n content: createMergeConflictMarkerRowElement(row),\n gutter: createMergeConflictGutterGap('marker', row.type),\n });\n }\n return {\n before: before.length > 0 ? before : undefined,\n after: after.length > 0 ? after : undefined,\n };\n };\n\n protected override getOptionsWithDefaults(): BaseUnresolvedOptionsWithDefaults {\n const options = super.getOptionsWithDefaults();\n options.diffStyle = 'unified';\n options.lineDiffType = 'none';\n // NOTE(amadeus): Aint nobody got time for a spread\n (options as BaseUnresolvedOptionsWithDefaults).mergeConflictActionsType =\n this.options.mergeConflictActionsType ?? 'default';\n return options as BaseUnresolvedOptionsWithDefaults;\n }\n}\n\nfunction getMergeConflictGutterProperties(\n mergeConflictType: MergeConflictMarkerType | undefined\n): Properties | undefined {\n return mergeConflictType != null\n ? { 'data-merge-conflict': mergeConflictType }\n : undefined;\n}\n\nfunction getMergeConflictContentProperties(\n type: 'change' | 'context' | 'context-expanded',\n mergeConflictType: MergeConflictMarkerType | undefined\n): Properties | undefined {\n if (mergeConflictType == null) {\n return undefined;\n }\n if (type === 'change') {\n if (mergeConflictType === 'current' || mergeConflictType === 'incoming') {\n return {\n 'data-line-type': 'context',\n 'data-merge-conflict': mergeConflictType,\n };\n }\n return undefined;\n }\n if (\n mergeConflictType === 'marker-start' ||\n mergeConflictType === 'marker-base' ||\n mergeConflictType === 'marker-separator' ||\n mergeConflictType === 'marker-end'\n ) {\n return { 'data-merge-conflict': mergeConflictType };\n }\n return undefined;\n}\n\nfunction createMergeConflictGutterGap(\n type: 'action' | 'marker',\n markerType?: MergeConflictMarkerInjectedRow['type']\n): HASTElement {\n const gap = createGutterGap(undefined, 'annotation', 1);\n gap.properties['data-gutter-buffer'] =\n type === 'action'\n ? 'merge-conflict-action'\n : `merge-conflict-${markerType ?? 'marker'}`;\n return gap;\n}\n\ninterface CreateMergeConflictActionsRowElementProps {\n row: MergeConflictActionRowData;\n includeDefaultActions: boolean;\n includeSlot: boolean;\n}\n\nfunction createMergeConflictActionsRowElement({\n row,\n includeDefaultActions,\n includeSlot,\n}: CreateMergeConflictActionsRowElementProps): HASTElement {\n const contentChildren: HASTElement[] = includeDefaultActions\n ? createMergeConflictActionsContent(row.conflictIndex)\n : [];\n if (includeSlot) {\n contentChildren.push(\n createHastElement({\n tagName: 'slot',\n properties: {\n name: getMergeConflictActionSlotName({\n hunkIndex: row.hunkIndex,\n lineIndex: row.lineIndex,\n conflictIndex: row.conflictIndex,\n }),\n 'data-merge-conflict-action-slot': '',\n },\n })\n );\n }\n return createHastElement({\n tagName: 'div',\n properties: {\n 'data-merge-conflict-actions': '',\n },\n children: [\n createHastElement({\n tagName: 'div',\n properties: { 'data-merge-conflict-actions-content': '' },\n children: contentChildren,\n }),\n ],\n });\n}\n\nfunction createMergeConflictMarkerRowElement(\n row: MergeConflictMarkerInjectedRow\n): HASTElement {\n return createHastElement({\n tagName: 'div',\n properties: {\n 'data-merge-conflict': row.type,\n 'data-merge-conflict-marker-row': '',\n },\n children: [\n createTextNodeElement(row.lineText.replace(/(?:\\r\\n|\\n|\\r)$/, '')),\n ],\n });\n}\n\nfunction createMergeConflictActionsContent(\n conflictIndex: number\n): HASTElement[] {\n return [\n createMergeConflictActionButton({\n resolution: 'current',\n label: 'Accept current change',\n conflictIndex,\n }),\n createMergeConflictActionSeparator(),\n createMergeConflictActionButton({\n resolution: 'incoming',\n label: 'Accept incoming change',\n conflictIndex,\n }),\n createMergeConflictActionSeparator(),\n createMergeConflictActionButton({\n resolution: 'both',\n label: 'Accept both',\n conflictIndex,\n }),\n ];\n}\n\ninterface CreateMergeConflictActionButtonProps {\n resolution: MergeConflictResolution;\n label: string;\n conflictIndex: number;\n}\n\nfunction createMergeConflictActionButton({\n resolution,\n label,\n conflictIndex,\n}: CreateMergeConflictActionButtonProps): HASTElement {\n return createHastElement({\n tagName: 'button',\n properties: {\n type: 'button',\n 'data-merge-conflict-action': resolution,\n 'data-merge-conflict-conflict-index': `${conflictIndex}`,\n },\n children: [createTextNodeElement(label)],\n });\n}\n\nfunction createMergeConflictActionSeparator(): HASTElement {\n return createHastElement({\n tagName: 'span',\n properties: { 'data-merge-conflict-action-separator': '' },\n children: [createTextNodeElement('|')],\n });\n}\n"],"mappings":";;;;;;AAyEA,IAAa,8BAAb,cAEU,kBAA+B;CACvC,yBAA0E,CAAC;CAC3E,oBAAsD,CAAC;CACvD,+BAAuB,IAAI,IAA4C;CACvE;CAEA,YACE,UAA8C,EAC5C,OAAO,eACT,GACA,oBAGA,gBACA,eACA;EACA,MAAM,KAAA,GAAW,oBAAoB,gBAAgB,aAAa;EAClE,KAAK,UAAU;CACjB;CAOA,iBACE,iBACA,YACA,MACM;EACN,KAAK,yBAAyB;EAC9B,KAAK,oBAAoB;EACzB,KAAK,iBAAiB,iBAAiB,YAAY,IAAI;CACzD;CAEA,iBACE,iBACA,YACA,MACM;EACN,KAAK,aAAa,MAAM;EACxB,KAAK,MAAM,UAAU,iBAAiB;GACpC,MAAM,SACJ,UAAU,OAAO,6BAA6B,QAAQ,IAAI,IAAI,KAAA;GAChE,IAAI,UAAU,QAAQ,UAAU,MAC9B;GAEF,MAAM,MAAoC;IACxC,MAAM;IACN,WAAW,OAAO;IAClB,WAAW,OAAO;IAClB,eAAe,OAAO;GACxB;GACA,KAAK,eAAe,GAAG;EACzB;EAEA,KAAK,MAAM,OAAO,YAChB,KAAK,eAAe,GAAG;CAE3B;CAEA,eAAuB,KAAyC;EAC9D,MAAM,MAAM,GAAG,IAAI,UAAU,GAAG,IAAI;EACpC,MAAM,OAAO,KAAK,aAAa,IAAI,GAAG;EACtC,IAAI,QAAQ,MACV,KAAK,aAAa,IAAI,KAAK,CAAC,GAAG,CAAC;OAEhC,KAAK,KAAK,GAAG;CAEjB;CAEA,WACE,MACA,cAA2B,sBACI;EAC/B,IAAI,QAAQ,MACV,KAAK,iBACH,KAAK,wBACL,KAAK,mBACL,IACF;EAEF,OAAO,MAAM,WAAW,MAAM,WAAW;CAC3C;CAEA,MAAsB,YACpB,MACA,cAA2B,sBACC;EAC5B,KAAK,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,uBAAuB,IAAI;GAC3B,kCAAkC;EACpC;EACA,UAAU,CACR,sBAAsB,IAAI,SAAS,QAAQ,mBAAmB,EAAE,CAAC,CACnE;CACF,CAAC;AACH;AAEA,SAAS,kCACP,eACe;CACf,OAAO;EACL,gCAAgC;GAC9B,YAAY;GACZ,OAAO;GACP;EACF,CAAC;EACD,mCAAmC;EACnC,gCAAgC;GAC9B,YAAY;GACZ,OAAO;GACP;EACF,CAAC;EACD,mCAAmC;EACnC,gCAAgC;GAC9B,YAAY;GACZ,OAAO;GACP;EACF,CAAC;CACH;AACF;AAQA,SAAS,gCAAgC,EACvC,YACA,OACA,iBACoD;CACpD,OAAO,kBAAkB;EACvB,SAAS;EACT,YAAY;GACV,MAAM;GACN,8BAA8B;GAC9B,sCAAsC,GAAG;EAC3C;EACA,UAAU,CAAC,sBAAsB,KAAK,CAAC;CACzC,CAAC;AACH;AAEA,SAAS,qCAAkD;CACzD,OAAO,kBAAkB;EACvB,SAAS;EACT,YAAY,EAAE,wCAAwC,GAAG;EACzD,UAAU,CAAC,sBAAsB,GAAG,CAAC;CACvC,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"tokenizer.d.ts","names":[],"sources":["../../src/shiki-stream/tokenizer.ts"],"mappings":";;;;cAOa,oBAAA;EAAA,SACK,OAAA,EAAS,2BAAA;EAElB,YAAA,EAAc,WAAA;EACd,cAAA,EAAgB,WAAA;EAEhB,qBAAA;EACA,sBAAA,EAAwB,YAAA;EAE/B,WAAA,CAAY,OAAA,EAAS,2BAAA;EALE;;;EAajB,OAAA,CAAQ,KAAA,WAAgB,OAAA,CAAQ,iCAAA;EAoCtC,KAAA;IAAW,MAAA,EAAQ,WAAA;EAAA;EAUnB,KAAA;EAOA,KAAA,IAAS,oBAAA;AAAA"}
1
+ {"version":3,"file":"tokenizer.d.ts","names":[],"sources":["../../src/shiki-stream/tokenizer.ts"],"mappings":";;;;cAQa,oBAAA;EAAA,SACK,OAAA,EAAS,2BAAA;EAElB,YAAA,EAAc,WAAA;EACd,cAAA,EAAgB,WAAA;EAEhB,qBAAA;EACA,sBAAA,EAAwB,YAAA;EAE/B,WAAA,CAAY,OAAA,EAAS,2BAAA;EALE;;;EAajB,OAAA,CAAQ,KAAA,WAAgB,OAAA,CAAQ,iCAAA;EAoCtC,KAAA;IAAW,MAAA,EAAQ,WAAA;EAAA;EAUnB,KAAA;EAOA,KAAA,IAAS,oBAAA;AAAA"}
@@ -1,3 +1,4 @@
1
+ import { appendItems } from "../utils/appendItems.js";
1
2
  //#region src/shiki-stream/tokenizer.ts
2
3
  var ShikiStreamTokenizer = class ShikiStreamTokenizer {
3
4
  options;
@@ -35,7 +36,7 @@ var ShikiStreamTokenizer = class ShikiStreamTokenizer {
35
36
  this.lastUnstableCodeChunk = line;
36
37
  }
37
38
  });
38
- this.tokensStable.push(...stable);
39
+ appendItems(this.tokensStable, stable);
39
40
  this.tokensUnstable = unstable;
40
41
  return {
41
42
  recall,
@@ -1 +1 @@
1
- {"version":3,"file":"tokenizer.js","names":[],"sources":["../../src/shiki-stream/tokenizer.ts"],"sourcesContent":["import type { GrammarState, ThemedToken } from 'shiki/core';\n\nimport type {\n ShikiStreamTokenizerEnqueueResult,\n ShikiStreamTokenizerOptions,\n} from './types';\n\nexport class ShikiStreamTokenizer {\n public readonly options: ShikiStreamTokenizerOptions;\n\n public tokensStable: ThemedToken[] = [];\n public tokensUnstable: ThemedToken[] = [];\n\n public lastUnstableCodeChunk: string = '';\n public lastStableGrammarState: GrammarState | undefined;\n\n constructor(options: ShikiStreamTokenizerOptions) {\n this.options = options;\n }\n\n /**\n * Enqueue a chunk of code to the buffer.\n */\n // oxlint-disable-next-line typescript/require-await\n async enqueue(chunk: string): Promise<ShikiStreamTokenizerEnqueueResult> {\n const chunkLines = (this.lastUnstableCodeChunk + chunk).split('\\n');\n\n const stable: ThemedToken[] = [];\n let unstable: ThemedToken[] = [];\n const recall = this.tokensUnstable.length;\n\n chunkLines.forEach((line, i) => {\n const isLastLine = i === chunkLines.length - 1;\n\n const result = this.options.highlighter.codeToTokens(line, {\n ...this.options,\n grammarState: this.lastStableGrammarState,\n });\n const tokens = result.tokens[0]; // only one line\n if (!isLastLine) tokens.push({ content: '\\n', offset: 0 });\n\n if (!isLastLine) {\n this.lastStableGrammarState = result.grammarState;\n stable.push(...tokens);\n } else {\n unstable = tokens;\n this.lastUnstableCodeChunk = line;\n }\n });\n\n this.tokensStable.push(...stable);\n this.tokensUnstable = unstable;\n\n return {\n recall,\n stable,\n unstable,\n };\n }\n\n close(): { stable: ThemedToken[] } {\n const stable = this.tokensUnstable;\n this.tokensUnstable = [];\n this.lastUnstableCodeChunk = '';\n this.lastStableGrammarState = undefined;\n return {\n stable,\n };\n }\n\n clear(): void {\n this.tokensStable = [];\n this.tokensUnstable = [];\n this.lastUnstableCodeChunk = '';\n this.lastStableGrammarState = undefined;\n }\n\n clone(): ShikiStreamTokenizer {\n const clone = new ShikiStreamTokenizer(this.options);\n clone.lastUnstableCodeChunk = this.lastUnstableCodeChunk;\n clone.tokensUnstable = this.tokensUnstable;\n clone.tokensStable = this.tokensStable;\n clone.lastStableGrammarState = this.lastStableGrammarState;\n return clone;\n }\n}\n"],"mappings":";AAOA,IAAa,uBAAb,MAAa,qBAAqB;CAChC;CAEA,eAAqC,CAAC;CACtC,iBAAuC,CAAC;CAExC,wBAAuC;CACvC;CAEA,YAAY,SAAsC;EAChD,KAAK,UAAU;CACjB;;;;CAMA,MAAM,QAAQ,OAA2D;EACvE,MAAM,cAAc,KAAK,wBAAwB,MAAA,CAAO,MAAM,IAAI;EAElE,MAAM,SAAwB,CAAC;EAC/B,IAAI,WAA0B,CAAC;EAC/B,MAAM,SAAS,KAAK,eAAe;EAEnC,WAAW,SAAS,MAAM,MAAM;GAC9B,MAAM,aAAa,MAAM,WAAW,SAAS;GAE7C,MAAM,SAAS,KAAK,QAAQ,YAAY,aAAa,MAAM;IACzD,GAAG,KAAK;IACR,cAAc,KAAK;GACrB,CAAC;GACD,MAAM,SAAS,OAAO,OAAO;GAC7B,IAAI,CAAC,YAAY,OAAO,KAAK;IAAE,SAAS;IAAM,QAAQ;GAAE,CAAC;GAEzD,IAAI,CAAC,YAAY;IACf,KAAK,yBAAyB,OAAO;IACrC,OAAO,KAAK,GAAG,MAAM;GACvB,OAAO;IACL,WAAW;IACX,KAAK,wBAAwB;GAC/B;EACF,CAAC;EAED,KAAK,aAAa,KAAK,GAAG,MAAM;EAChC,KAAK,iBAAiB;EAEtB,OAAO;GACL;GACA;GACA;EACF;CACF;CAEA,QAAmC;EACjC,MAAM,SAAS,KAAK;EACpB,KAAK,iBAAiB,CAAC;EACvB,KAAK,wBAAwB;EAC7B,KAAK,yBAAyB,KAAA;EAC9B,OAAO,EACL,OACF;CACF;CAEA,QAAc;EACZ,KAAK,eAAe,CAAC;EACrB,KAAK,iBAAiB,CAAC;EACvB,KAAK,wBAAwB;EAC7B,KAAK,yBAAyB,KAAA;CAChC;CAEA,QAA8B;EAC5B,MAAM,QAAQ,IAAI,qBAAqB,KAAK,OAAO;EACnD,MAAM,wBAAwB,KAAK;EACnC,MAAM,iBAAiB,KAAK;EAC5B,MAAM,eAAe,KAAK;EAC1B,MAAM,yBAAyB,KAAK;EACpC,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"tokenizer.js","names":[],"sources":["../../src/shiki-stream/tokenizer.ts"],"sourcesContent":["import type { GrammarState, ThemedToken } from 'shiki/core';\n\nimport { appendItems } from '../utils/appendItems';\nimport type {\n ShikiStreamTokenizerEnqueueResult,\n ShikiStreamTokenizerOptions,\n} from './types';\n\nexport class ShikiStreamTokenizer {\n public readonly options: ShikiStreamTokenizerOptions;\n\n public tokensStable: ThemedToken[] = [];\n public tokensUnstable: ThemedToken[] = [];\n\n public lastUnstableCodeChunk: string = '';\n public lastStableGrammarState: GrammarState | undefined;\n\n constructor(options: ShikiStreamTokenizerOptions) {\n this.options = options;\n }\n\n /**\n * Enqueue a chunk of code to the buffer.\n */\n // oxlint-disable-next-line typescript/require-await\n async enqueue(chunk: string): Promise<ShikiStreamTokenizerEnqueueResult> {\n const chunkLines = (this.lastUnstableCodeChunk + chunk).split('\\n');\n\n const stable: ThemedToken[] = [];\n let unstable: ThemedToken[] = [];\n const recall = this.tokensUnstable.length;\n\n chunkLines.forEach((line, i) => {\n const isLastLine = i === chunkLines.length - 1;\n\n const result = this.options.highlighter.codeToTokens(line, {\n ...this.options,\n grammarState: this.lastStableGrammarState,\n });\n const tokens = result.tokens[0]; // only one line\n if (!isLastLine) tokens.push({ content: '\\n', offset: 0 });\n\n if (!isLastLine) {\n this.lastStableGrammarState = result.grammarState;\n stable.push(...tokens);\n } else {\n unstable = tokens;\n this.lastUnstableCodeChunk = line;\n }\n });\n\n appendItems(this.tokensStable, stable);\n this.tokensUnstable = unstable;\n\n return {\n recall,\n stable,\n unstable,\n };\n }\n\n close(): { stable: ThemedToken[] } {\n const stable = this.tokensUnstable;\n this.tokensUnstable = [];\n this.lastUnstableCodeChunk = '';\n this.lastStableGrammarState = undefined;\n return {\n stable,\n };\n }\n\n clear(): void {\n this.tokensStable = [];\n this.tokensUnstable = [];\n this.lastUnstableCodeChunk = '';\n this.lastStableGrammarState = undefined;\n }\n\n clone(): ShikiStreamTokenizer {\n const clone = new ShikiStreamTokenizer(this.options);\n clone.lastUnstableCodeChunk = this.lastUnstableCodeChunk;\n clone.tokensUnstable = this.tokensUnstable;\n clone.tokensStable = this.tokensStable;\n clone.lastStableGrammarState = this.lastStableGrammarState;\n return clone;\n }\n}\n"],"mappings":";;AAQA,IAAa,uBAAb,MAAa,qBAAqB;CAChC;CAEA,eAAqC,CAAC;CACtC,iBAAuC,CAAC;CAExC,wBAAuC;CACvC;CAEA,YAAY,SAAsC;EAChD,KAAK,UAAU;CACjB;;;;CAMA,MAAM,QAAQ,OAA2D;EACvE,MAAM,cAAc,KAAK,wBAAwB,MAAA,CAAO,MAAM,IAAI;EAElE,MAAM,SAAwB,CAAC;EAC/B,IAAI,WAA0B,CAAC;EAC/B,MAAM,SAAS,KAAK,eAAe;EAEnC,WAAW,SAAS,MAAM,MAAM;GAC9B,MAAM,aAAa,MAAM,WAAW,SAAS;GAE7C,MAAM,SAAS,KAAK,QAAQ,YAAY,aAAa,MAAM;IACzD,GAAG,KAAK;IACR,cAAc,KAAK;GACrB,CAAC;GACD,MAAM,SAAS,OAAO,OAAO;GAC7B,IAAI,CAAC,YAAY,OAAO,KAAK;IAAE,SAAS;IAAM,QAAQ;GAAE,CAAC;GAEzD,IAAI,CAAC,YAAY;IACf,KAAK,yBAAyB,OAAO;IACrC,OAAO,KAAK,GAAG,MAAM;GACvB,OAAO;IACL,WAAW;IACX,KAAK,wBAAwB;GAC/B;EACF,CAAC;EAED,YAAY,KAAK,cAAc,MAAM;EACrC,KAAK,iBAAiB;EAEtB,OAAO;GACL;GACA;GACA;EACF;CACF;CAEA,QAAmC;EACjC,MAAM,SAAS,KAAK;EACpB,KAAK,iBAAiB,CAAC;EACvB,KAAK,wBAAwB;EAC7B,KAAK,yBAAyB,KAAA;EAC9B,OAAO,EACL,OACF;CACF;CAEA,QAAc;EACZ,KAAK,eAAe,CAAC;EACrB,KAAK,iBAAiB,CAAC;EACvB,KAAK,wBAAwB;EAC7B,KAAK,yBAAyB,KAAA;CAChC;CAEA,QAA8B;EAC5B,MAAM,QAAQ,IAAI,qBAAqB,KAAK,OAAO;EACnD,MAAM,wBAAwB,KAAK;EACnC,MAAM,iBAAiB,KAAK;EAC5B,MAAM,eAAe,KAAK;EAC1B,MAAM,yBAAyB,KAAK;EACpC,OAAO;CACT;AACF"}
@@ -1,6 +1,6 @@
1
- import { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeViewCreateEditorOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffFileInput, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsBaseComponent, DiffsComponentOptions, DiffsEditableComponent, DiffsEditor, DiffsHighlighter, DiffsTextDocument, DiffsThemeNames, EditableInstance, EditorActiveLineOptions, EditorChange, EditorChangeEvent, EditorSelection, EditorState, EditorViewState, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffContentsLoader, FileDiffLoadedChangedFiles, FileDiffLoadedFiles, FileDiffLoadedPureRenamedFile, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlightedToken, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MaybeDiffFileInput, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PendingCodeViewLayoutReset, Position, PostRenderPhase, PrePropertiesConfig, ProcessFileConflictData, Range, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderFilenameSuffixCallback, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, ResolvedTextEdit, SelectedLineRange, SelectionDirection, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, TextEdit, ThemeRegistration, 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, DiffFileInput, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffContentsLoader, FileDiffLoadedChangedFiles, FileDiffLoadedFiles, FileDiffLoadedPureRenamedFile, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlightedToken, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MaybeDiffFileInput, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PendingCodeViewLayoutReset, PostRenderPhase, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderFilenameSuffixCallback, 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 { PreloadDiffOptions, PreloadFileDiffOptions, PreloadFileDiffResult, PreloadMultiFileDiffOptions, PreloadMultiFileDiffResult, PreloadPatchDiffOptions, PreloadPatchDiffResult, PreloadUnresolvedFileOptions, PreloadUnresolvedFileResult, preloadDiffHTML, preloadFileDiff, preloadMultiFileDiff, preloadPatchDiff, preloadUnresolvedFile, preloadUnresolvedFileHTML } from "./preloadDiffs.js";
3
3
  import { PreloadFileOptions, PreloadedFileResult, preloadFile } from "./preloadFile.js";
4
4
  import { PreloadPatchFileOptions, preloadPatchFile } from "./preloadPatchFile.js";
5
5
  import { renderHTML } from "./renderHTML.js";
6
- export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, type BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, type CodeToHastOptions, CodeViewCreateEditorOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, type CreatePatchOptionsNonabortable, CustomPreProperties, type DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffFileInput, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsBaseComponent, DiffsComponentOptions, DiffsEditableComponent, DiffsEditor, DiffsHighlighter, DiffsTextDocument, DiffsThemeNames, EditableInstance, EditorActiveLineOptions, EditorChange, EditorChangeEvent, EditorSelection, EditorState, EditorViewState, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffContentsLoader, FileDiffLoadedChangedFiles, FileDiffLoadedFiles, FileDiffLoadedPureRenamedFile, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlightedToken, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, type LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MaybeDiffFileInput, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PendingCodeViewLayoutReset, Position, PostRenderPhase, PrePropertiesConfig, PreloadDiffOptions, PreloadFileDiffOptions, PreloadFileDiffResult, PreloadFileOptions, PreloadMultiFileDiffOptions, PreloadMultiFileDiffResult, PreloadPatchDiffOptions, PreloadPatchDiffResult, PreloadPatchFileOptions, PreloadUnresolvedFileOptions, PreloadUnresolvedFileResult, PreloadedFileResult, ProcessFileConflictData, Range, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderFilenameSuffixCallback, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, ResolvedTextEdit, SelectedLineRange, SelectionDirection, SelectionPoint, SelectionSide, SharedRenderState, type ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, TextEdit, type ThemeRegistration, type ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, type ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs, preloadDiffHTML, preloadFile, preloadFileDiff, preloadMultiFileDiff, preloadPatchDiff, preloadPatchFile, preloadUnresolvedFile, preloadUnresolvedFileHTML, renderHTML };
6
+ export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, type BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, type CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, type CreatePatchOptionsNonabortable, CustomPreProperties, type DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffFileInput, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffContentsLoader, FileDiffLoadedChangedFiles, FileDiffLoadedFiles, FileDiffLoadedPureRenamedFile, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlightedToken, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, type LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MaybeDiffFileInput, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PendingCodeViewLayoutReset, PostRenderPhase, PrePropertiesConfig, PreloadDiffOptions, PreloadFileDiffOptions, PreloadFileDiffResult, PreloadFileOptions, PreloadMultiFileDiffOptions, PreloadMultiFileDiffResult, PreloadPatchDiffOptions, PreloadPatchDiffResult, PreloadPatchFileOptions, PreloadUnresolvedFileOptions, PreloadUnresolvedFileResult, PreloadedFileResult, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderFilenameSuffixCallback, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectedLineRange, SelectionPoint, SelectionSide, SharedRenderState, type ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, type ThemeRegistration, type ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, type ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs, preloadDiffHTML, preloadFile, preloadFileDiff, preloadMultiFileDiff, preloadPatchDiff, preloadPatchFile, preloadUnresolvedFile, preloadUnresolvedFileHTML, renderHTML };
@@ -3,54 +3,54 @@ import { FileDiffOptions } from "../components/FileDiff.js";
3
3
  import { UnresolvedFileOptions } from "../components/UnresolvedFile.js";
4
4
 
5
5
  //#region src/ssr/preloadDiffs.d.ts
6
- interface PreloadDiffBaseOptions<LAnnotation> {
7
- options?: FileDiffOptions<LAnnotation>;
6
+ interface PreloadDiffBaseOptions<LAnnotation, Caret> {
7
+ options?: FileDiffOptions<LAnnotation, Caret>;
8
8
  annotations?: DiffLineAnnotation<LAnnotation>[];
9
9
  }
10
- type PreloadDiffOptions<LAnnotation> = PreloadDiffBaseOptions<LAnnotation> & (({
10
+ type PreloadDiffOptions<LAnnotation, Caret> = PreloadDiffBaseOptions<LAnnotation, Caret> & (({
11
11
  fileDiff: FileDiffMetadata;
12
12
  } & MaybeDiffFileInput) | ({
13
13
  fileDiff?: undefined;
14
14
  } & DiffFileInput));
15
- declare function preloadDiffHTML<LAnnotation = undefined>({
15
+ declare function preloadDiffHTML<LAnnotation = undefined, Caret = undefined>({
16
16
  fileDiff,
17
17
  oldFile,
18
18
  newFile,
19
19
  options,
20
20
  annotations
21
- }: PreloadDiffOptions<LAnnotation>): Promise<string>;
21
+ }: PreloadDiffOptions<LAnnotation, Caret>): Promise<string>;
22
22
  declare function preloadUnresolvedFileHTML<LAnnotation = undefined>({
23
23
  file,
24
24
  options,
25
25
  annotations
26
26
  }: PreloadUnresolvedFileOptions<LAnnotation>): Promise<string>;
27
- interface PreloadMultiFileDiffBaseOptions<LAnnotation> {
28
- options?: FileDiffOptions<LAnnotation>;
27
+ interface PreloadMultiFileDiffBaseOptions<LAnnotation, Caret> {
28
+ options?: FileDiffOptions<LAnnotation, Caret>;
29
29
  annotations?: DiffLineAnnotation<LAnnotation>[];
30
30
  }
31
- type PreloadMultiFileDiffOptions<LAnnotation> = PreloadMultiFileDiffBaseOptions<LAnnotation> & DiffFileInput;
32
- type PreloadMultiFileDiffResult<LAnnotation> = PreloadMultiFileDiffOptions<LAnnotation> & {
31
+ type PreloadMultiFileDiffOptions<LAnnotation, Caret> = PreloadMultiFileDiffBaseOptions<LAnnotation, Caret> & DiffFileInput;
32
+ type PreloadMultiFileDiffResult<LAnnotation, Caret> = PreloadMultiFileDiffOptions<LAnnotation, Caret> & {
33
33
  prerenderedHTML: string;
34
34
  };
35
- declare function preloadMultiFileDiff<LAnnotation = undefined>({
35
+ declare function preloadMultiFileDiff<LAnnotation = undefined, Caret = undefined>({
36
36
  oldFile,
37
37
  newFile,
38
38
  options,
39
39
  annotations
40
- }: PreloadMultiFileDiffOptions<LAnnotation>): Promise<PreloadMultiFileDiffResult<LAnnotation>>;
41
- interface PreloadFileDiffOptions<LAnnotation> {
40
+ }: PreloadMultiFileDiffOptions<LAnnotation, Caret>): Promise<PreloadMultiFileDiffResult<LAnnotation, Caret>>;
41
+ interface PreloadFileDiffOptions<LAnnotation, Caret> {
42
42
  fileDiff: FileDiffMetadata;
43
- options?: FileDiffOptions<LAnnotation>;
43
+ options?: FileDiffOptions<LAnnotation, Caret>;
44
44
  annotations?: DiffLineAnnotation<LAnnotation>[];
45
45
  }
46
- interface PreloadFileDiffResult<LAnnotation> extends PreloadFileDiffOptions<LAnnotation> {
46
+ interface PreloadFileDiffResult<LAnnotation, Caret> extends PreloadFileDiffOptions<LAnnotation, Caret> {
47
47
  prerenderedHTML: string;
48
48
  }
49
- declare function preloadFileDiff<LAnnotation = undefined>({
49
+ declare function preloadFileDiff<LAnnotation = undefined, Caret = undefined>({
50
50
  fileDiff,
51
51
  options,
52
52
  annotations
53
- }: PreloadFileDiffOptions<LAnnotation>): Promise<PreloadFileDiffResult<LAnnotation>>;
53
+ }: PreloadFileDiffOptions<LAnnotation, Caret>): Promise<PreloadFileDiffResult<LAnnotation, Caret>>;
54
54
  interface PreloadUnresolvedFileOptions<LAnnotation> {
55
55
  file: FileContents;
56
56
  options?: Omit<UnresolvedFileOptions<LAnnotation>, 'onMergeConflictAction' | 'onMergeConflictResolve' | 'onPostRender'>;
@@ -64,19 +64,19 @@ declare function preloadUnresolvedFile<LAnnotation = undefined>({
64
64
  options,
65
65
  annotations
66
66
  }: PreloadUnresolvedFileOptions<LAnnotation>): Promise<PreloadUnresolvedFileResult<LAnnotation>>;
67
- interface PreloadPatchDiffOptions<LAnnotation> {
67
+ interface PreloadPatchDiffOptions<LAnnotation, Caret> {
68
68
  patch: string;
69
- options?: FileDiffOptions<LAnnotation>;
69
+ options?: FileDiffOptions<LAnnotation, Caret>;
70
70
  annotations?: DiffLineAnnotation<LAnnotation>[];
71
71
  }
72
- interface PreloadPatchDiffResult<LAnnotation> extends PreloadPatchDiffOptions<LAnnotation> {
72
+ interface PreloadPatchDiffResult<LAnnotation, Caret> extends PreloadPatchDiffOptions<LAnnotation, Caret> {
73
73
  prerenderedHTML: string;
74
74
  }
75
- declare function preloadPatchDiff<LAnnotation = undefined>({
75
+ declare function preloadPatchDiff<LAnnotation = undefined, Caret = undefined>({
76
76
  patch,
77
77
  options,
78
78
  annotations
79
- }: PreloadPatchDiffOptions<LAnnotation>): Promise<PreloadPatchDiffResult<LAnnotation>>;
79
+ }: PreloadPatchDiffOptions<LAnnotation, Caret>): Promise<PreloadPatchDiffResult<LAnnotation, Caret>>;
80
80
  //#endregion
81
81
  export { PreloadDiffOptions, PreloadFileDiffOptions, PreloadFileDiffResult, PreloadMultiFileDiffOptions, PreloadMultiFileDiffResult, PreloadPatchDiffOptions, PreloadPatchDiffResult, PreloadUnresolvedFileOptions, PreloadUnresolvedFileResult, preloadDiffHTML, preloadFileDiff, preloadMultiFileDiff, preloadPatchDiff, preloadUnresolvedFile, preloadUnresolvedFileHTML };
82
82
  //# sourceMappingURL=preloadDiffs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"preloadDiffs.d.ts","names":[],"sources":["../../src/ssr/preloadDiffs.ts"],"mappings":";;;;;UA8BU,sBAAA;EACR,OAAA,GAAU,eAAA,CAAgB,WAAA;EAC1B,WAAA,GAAc,kBAAA,CAAmB,WAAA;AAAA;AAAA,KAGvB,kBAAA,gBACV,sBAAA,CAAuB,WAAA;EAEd,QAAA,EAAU,gBAAA;AAAA,IAAqB,kBAAA;EAC/B,QAAA;AAAA,IAAyB,aAAA;AAAA,iBAGd,eAAA;EACpB,QAAA;EACA,OAAA;EACA,OAAA;EACA,OAAA;EACA;AAAA,GACC,kBAAA,CAAmB,WAAA,IAAe,OAAA;AAAA,iBA8Bf,yBAAA;EACpB,IAAA;EACA,OAAA;EACA;AAAA,GACC,4BAAA,CAA6B,WAAA,IAAe,OAAA;AAAA,UAsBrC,+BAAA;EACR,OAAA,GAAU,eAAA,CAAgB,WAAA;EAC1B,WAAA,GAAc,kBAAA,CAAmB,WAAA;AAAA;AAAA,KAGvB,2BAAA,gBACV,+BAAA,CAAgC,WAAA,IAAe,aAAA;AAAA,KAErC,0BAAA,gBACV,2BAA2B,CAAC,WAAA;EAC1B,eAAA;AAAA;AAAA,iBAGkB,oBAAA;EACpB,OAAA;EACA,OAAA;EACA,OAAA;EACA;AAAA,GACC,2BAAA,CAA4B,WAAA,IAAe,OAAA,CAC5C,0BAAA,CAA2B,WAAA;AAAA,UAuBZ,sBAAA;EACf,QAAA,EAAU,gBAAA;EACV,OAAA,GAAU,eAAA,CAAgB,WAAA;EAC1B,WAAA,GAAc,kBAAA,CAAmB,WAAA;AAAA;AAAA,UAGlB,qBAAA,sBAEP,sBAAsB,CAAC,WAAA;EAC/B,eAAA;AAAA;AAAA,iBAGoB,eAAA;EACpB,QA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AmB,WAAA;AAAA;AAAA,UAGlB,sBAAA,6BAGP,uBAAA,CAAwB,WAAA,EAAa,KAAA;EAC7C,eAAA;AAAA;AAAA,iBAGoB,gBAAA;EAIpB,KAAA;EACA,OAAA;EACA;AAAA,GACC,uBAAA,CAAwB,WAAA,EAAa,KAAA,IAAS,OAAA,CAC/C,sBAAA,CAAuB,WAAA,EAAa,KAAA"}
@@ -1,7 +1,7 @@
1
- import { parseDiffFromFile } from "../utils/parseDiffFromFile.js";
2
1
  import { wrapThemeCSS } from "../utils/cssWrappers.js";
3
2
  import { shouldUseTokenTransformer } from "../utils/shouldUseTokenTransformer.js";
4
3
  import { getDiffFileInput } from "../utils/getDiffFileInput.js";
4
+ import { parseDiffFromFile } from "../utils/parseDiffFromFile.js";
5
5
  import { DiffHunksRenderer } from "../renderers/DiffHunksRenderer.js";
6
6
  import { parseMergeConflictDiffFromFile } from "../utils/parseMergeConflictDiffFromFile.js";
7
7
  import { UnresolvedFileHunksRenderer } from "../renderers/UnresolvedFileHunksRenderer.js";