@pierre/diffs 1.6.0-beta.1 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dist/components/CodeView.d.ts +3 -2
  2. package/dist/components/CodeView.d.ts.map +1 -1
  3. package/dist/components/CodeView.js +18 -14
  4. package/dist/components/CodeView.js.map +1 -1
  5. package/dist/components/File.d.ts +31 -9
  6. package/dist/components/File.d.ts.map +1 -1
  7. package/dist/components/File.js +165 -84
  8. package/dist/components/File.js.map +1 -1
  9. package/dist/components/FileDiff.d.ts +32 -9
  10. package/dist/components/FileDiff.d.ts.map +1 -1
  11. package/dist/components/FileDiff.js +213 -124
  12. package/dist/components/FileDiff.js.map +1 -1
  13. package/dist/components/UnresolvedFile.d.ts +14 -4
  14. package/dist/components/UnresolvedFile.d.ts.map +1 -1
  15. package/dist/components/UnresolvedFile.js +35 -16
  16. package/dist/components/UnresolvedFile.js.map +1 -1
  17. package/dist/components/VirtualizedFile.d.ts +3 -2
  18. package/dist/components/VirtualizedFile.d.ts.map +1 -1
  19. package/dist/components/VirtualizedFile.js +28 -20
  20. package/dist/components/VirtualizedFile.js.map +1 -1
  21. package/dist/components/VirtualizedFileDiff.d.ts +3 -2
  22. package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
  23. package/dist/components/VirtualizedFileDiff.js +31 -24
  24. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  25. package/dist/constants.d.ts +2 -1
  26. package/dist/constants.d.ts.map +1 -1
  27. package/dist/constants.js +2 -1
  28. package/dist/constants.js.map +1 -1
  29. package/dist/editor/platform.d.ts +1 -1
  30. package/dist/editor/platform.js +5 -4
  31. package/dist/editor/platform.js.map +1 -1
  32. package/dist/editor/selection.d.ts +2 -2
  33. package/dist/editor/selection.d.ts.map +1 -1
  34. package/dist/editor/selection.js +31 -6
  35. package/dist/editor/selection.js.map +1 -1
  36. package/dist/highlighter/shared_highlighter.d.ts +2 -1
  37. package/dist/highlighter/shared_highlighter.d.ts.map +1 -1
  38. package/dist/highlighter/shared_highlighter.js +2 -2
  39. package/dist/highlighter/shared_highlighter.js.map +1 -1
  40. package/dist/index.d.ts +10 -5
  41. package/dist/index.js +8 -3
  42. package/dist/react/CodeView.d.ts +4 -3
  43. package/dist/react/CodeView.d.ts.map +1 -1
  44. package/dist/react/CodeView.js +48 -39
  45. package/dist/react/CodeView.js.map +1 -1
  46. package/dist/react/File.js +3 -3
  47. package/dist/react/File.js.map +1 -1
  48. package/dist/react/FileDiff.js +3 -3
  49. package/dist/react/FileDiff.js.map +1 -1
  50. package/dist/react/MultiFileDiff.js +2 -2
  51. package/dist/react/MultiFileDiff.js.map +1 -1
  52. package/dist/react/PatchDiff.js +3 -3
  53. package/dist/react/PatchDiff.js.map +1 -1
  54. package/dist/react/UnresolvedFile.js +2 -2
  55. package/dist/react/UnresolvedFile.js.map +1 -1
  56. package/dist/react/index.d.ts +2 -2
  57. package/dist/react/types.d.ts +4 -2
  58. package/dist/react/types.d.ts.map +1 -1
  59. package/dist/react/utils/renderDiffChildren.js +1 -1
  60. package/dist/react/utils/renderDiffChildren.js.map +1 -1
  61. package/dist/react/utils/renderFileChildren.js +1 -1
  62. package/dist/react/utils/renderFileChildren.js.map +1 -1
  63. package/dist/react/utils/useFileDiffInstance.d.ts +1 -0
  64. package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
  65. package/dist/react/utils/useFileDiffInstance.js +29 -24
  66. package/dist/react/utils/useFileDiffInstance.js.map +1 -1
  67. package/dist/react/utils/useFileInstance.d.ts +2 -0
  68. package/dist/react/utils/useFileInstance.d.ts.map +1 -1
  69. package/dist/react/utils/useFileInstance.js +38 -28
  70. package/dist/react/utils/useFileInstance.js.map +1 -1
  71. package/dist/react/utils/useForceUpdate.d.ts +5 -0
  72. package/dist/react/utils/useForceUpdate.d.ts.map +1 -0
  73. package/dist/react/utils/useForceUpdate.js +27 -0
  74. package/dist/react/utils/useForceUpdate.js.map +1 -0
  75. package/dist/react/utils/useNextRenderData.d.ts +9 -0
  76. package/dist/react/utils/useNextRenderData.d.ts.map +1 -0
  77. package/dist/react/utils/useNextRenderData.js +9 -0
  78. package/dist/react/utils/useNextRenderData.js.map +1 -0
  79. package/dist/react/utils/useUnresolvedFileInstance.d.ts +1 -0
  80. package/dist/react/utils/useUnresolvedFileInstance.d.ts.map +1 -1
  81. package/dist/react/utils/useUnresolvedFileInstance.js +26 -11
  82. package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
  83. package/dist/renderers/DiffHunksRenderer.d.ts +2 -1
  84. package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
  85. package/dist/renderers/DiffHunksRenderer.js +62 -32
  86. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  87. package/dist/renderers/FileRenderer.d.ts +4 -1
  88. package/dist/renderers/FileRenderer.d.ts.map +1 -1
  89. package/dist/renderers/FileRenderer.js +55 -30
  90. package/dist/renderers/FileRenderer.js.map +1 -1
  91. package/dist/renderers/UnresolvedFileHunksRenderer.d.ts.map +1 -1
  92. package/dist/renderers/UnresolvedFileHunksRenderer.js +1 -1
  93. package/dist/renderers/UnresolvedFileHunksRenderer.js.map +1 -1
  94. package/dist/ssr/FileDiffReact.js +1 -1
  95. package/dist/types.d.ts +10 -0
  96. package/dist/types.d.ts.map +1 -1
  97. package/dist/utils/canUseWASM.d.ts +13 -0
  98. package/dist/utils/canUseWASM.d.ts.map +1 -0
  99. package/dist/utils/canUseWASM.js +59 -0
  100. package/dist/utils/canUseWASM.js.map +1 -0
  101. package/dist/utils/getCodeViewItemRenderData.d.ts +10 -0
  102. package/dist/utils/getCodeViewItemRenderData.d.ts.map +1 -0
  103. package/dist/utils/getCodeViewItemRenderData.js +19 -0
  104. package/dist/utils/getCodeViewItemRenderData.js.map +1 -0
  105. package/dist/utils/hastToHtml.d.ts +2 -2
  106. package/dist/utils/hastToHtml.js +2 -2
  107. package/dist/utils/hastToHtml.js.map +1 -1
  108. package/dist/utils/hydratePartialDiff.js +4 -0
  109. package/dist/utils/hydratePartialDiff.js.map +1 -1
  110. package/dist/utils/parseMergeConflictDiffFromFile.d.ts.map +1 -1
  111. package/dist/utils/parseMergeConflictDiffFromFile.js +2 -0
  112. package/dist/utils/parseMergeConflictDiffFromFile.js.map +1 -1
  113. package/dist/utils/parsePatchFiles.d.ts.map +1 -1
  114. package/dist/utils/parsePatchFiles.js +24 -4
  115. package/dist/utils/parsePatchFiles.js.map +1 -1
  116. package/dist/utils/renderTokenLines.d.ts +6 -1
  117. package/dist/utils/renderTokenLines.d.ts.map +1 -1
  118. package/dist/utils/renderTokenLines.js +4 -0
  119. package/dist/utils/renderTokenLines.js.map +1 -1
  120. package/dist/utils/resolveRegion.js +20 -10
  121. package/dist/utils/resolveRegion.js.map +1 -1
  122. package/dist/utils/tokenStyle.d.ts +5 -1
  123. package/dist/utils/tokenStyle.d.ts.map +1 -1
  124. package/dist/utils/tokenStyle.js +5 -1
  125. package/dist/utils/tokenStyle.js.map +1 -1
  126. package/dist/utils/tokensToHtml.d.ts +5 -2
  127. package/dist/utils/tokensToHtml.d.ts.map +1 -1
  128. package/dist/utils/tokensToHtml.js +5 -2
  129. package/dist/utils/tokensToHtml.js.map +1 -1
  130. package/dist/utils/updateDiffHunks.d.ts +2 -2
  131. package/dist/utils/updateDiffHunks.d.ts.map +1 -1
  132. package/dist/utils/updateDiffHunks.js +7 -3
  133. package/dist/utils/updateDiffHunks.js.map +1 -1
  134. package/dist/worker/WorkerPoolManager.d.ts +12 -0
  135. package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
  136. package/dist/worker/WorkerPoolManager.js +99 -21
  137. package/dist/worker/WorkerPoolManager.js.map +1 -1
  138. package/dist/worker/{highlights-sAHlxqlf.js → highlights-CpZm9DAR.js} +2 -2
  139. package/dist/worker/{highlights-sAHlxqlf.js.map → highlights-CpZm9DAR.js.map} +1 -1
  140. package/dist/worker/{shiki-Bx2JpdqZ.js → shiki-Ci4cdHsM.js} +2 -2
  141. package/dist/worker/{shiki-Bx2JpdqZ.js.map → shiki-Ci4cdHsM.js.map} +1 -1
  142. package/dist/worker/{stream-tokenizer-YZ6M1qSx.js → stream-tokenizer-DK9xp5M5.js} +8 -5
  143. package/dist/worker/stream-tokenizer-DK9xp5M5.js.map +1 -0
  144. package/dist/worker/types.d.ts +11 -0
  145. package/dist/worker/types.d.ts.map +1 -1
  146. package/dist/worker/worker-portable.js +4 -4
  147. package/dist/worker/worker-portable.js.map +1 -1
  148. package/dist/worker/worker.js +12 -3
  149. package/dist/worker/worker.js.map +1 -1
  150. package/package.json +28 -30
  151. package/dist/worker/stream-tokenizer-YZ6M1qSx.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"shared_highlighter.js","names":[],"sources":["../../src/highlighter/shared_highlighter.ts"],"sourcesContent":["import type {\n DiffsHighlighter,\n DiffsThemeNames,\n HighlighterTypes,\n SupportedLanguages,\n ThemesType,\n} from '../types';\nimport {\n acquireHighlighterType,\n getHighlighterType,\n HighlighterDisposedError,\n releaseHighlighterType,\n resolveHighlighterType,\n} from './highlighterType';\nimport { cleanUpResolvedLanguages } from './languages/cleanUpResolvedLanguages';\nimport { areThemesAttached } from './themes/areThemesAttached';\nimport { cleanUpResolvedThemes } from './themes/cleanUpResolvedThemes';\n\nexport {\n getHighlighterType,\n HighlighterDisposedError,\n} from './highlighterType';\n\nlet highlighter: DiffsHighlighter | Promise<DiffsHighlighter> | undefined;\n\nexport interface HighlighterOptions {\n themes: DiffsThemeNames[];\n langs: SupportedLanguages[];\n preferredHighlighter?: HighlighterTypes;\n}\n\n/**\n * Creates an instance the caller must dispose. Defaults to the active type\n * or DEFAULT_HIGHLIGHTER; rejects if a different type is already active.\n */\nexport async function createHighlighter(\n type?: HighlighterTypes\n): Promise<DiffsHighlighter> {\n const resolvedType = resolveHighlighterType(type);\n // Reserve the type before importing to prevent concurrent backend loads.\n acquireHighlighterType(resolvedType);\n try {\n if (resolvedType === 'highlights') {\n const { HighlightsHighlighter } = await import('./backends/highlights');\n return new HighlightsHighlighter();\n }\n const { ShikiHighlighter } = await import('./backends/shiki');\n return await ShikiHighlighter.create(resolvedType);\n } finally {\n releaseHighlighterType();\n }\n}\n\nexport async function getSharedHighlighter({\n themes,\n langs,\n preferredHighlighter,\n}: HighlighterOptions): Promise<DiffsHighlighter> {\n dropDisposedHighlighter();\n const cached = (highlighter ??= createHighlighter(\n getHighlighterType() ?? preferredHighlighter\n ));\n let instance: DiffsHighlighter;\n try {\n instance = await cached;\n } catch (error) {\n // Allow retries without clearing a newer request.\n if (highlighter === cached) {\n highlighter = undefined;\n }\n throw error;\n }\n if (highlighter === cached) {\n highlighter = instance;\n }\n await Promise.all([\n instance.themeResolver.resolveThemes(themes),\n instance.loadLanguages(langs),\n ]);\n // disposeHighlighter() may run while themes and languages load.\n if (instance.isDisposed) {\n throw new HighlighterDisposedError();\n }\n return instance;\n}\n\n// Direct dispose() calls leave the shared reference pointing to a dead instance.\nfunction dropDisposedHighlighter(): void {\n if (\n highlighter != null &&\n !('then' in highlighter) &&\n highlighter.isDisposed\n ) {\n highlighter = undefined;\n }\n}\n\nexport function isHighlighterLoaded(): boolean {\n dropDisposedHighlighter();\n return highlighter != null && !('then' in highlighter);\n}\n\ninterface GetHighlighterIfLoadedProps {\n theme?: DiffsThemeNames | ThemesType;\n lang?: SupportedLanguages;\n}\n\n/**\n * Returns undefined if the theme or language is not loaded.\n */\nexport function getHighlighterIfLoaded({\n theme,\n lang,\n}: GetHighlighterIfLoadedProps = {}): DiffsHighlighter | undefined {\n dropDisposedHighlighter();\n const instance = highlighter;\n if (\n instance == null ||\n 'then' in instance ||\n (theme != null && !areThemesAttached(theme, instance)) ||\n (lang != null && !instance.hasLoadedLanguages([lang]))\n ) {\n return undefined;\n }\n return instance;\n}\n\nexport function isHighlighterLoading(): boolean {\n return highlighter != null && 'then' in highlighter;\n}\n\nexport function isHighlighterNull(): boolean {\n dropDisposedHighlighter();\n return highlighter == null;\n}\n\nexport async function preloadHighlighter(\n options: HighlighterOptions\n): Promise<void> {\n await getSharedHighlighter(options);\n}\n\n/**\n * Disposes an already loaded shared instance synchronously and clears caches.\n * Instances from createHighlighter() must be disposed separately before\n * switching types.\n */\nexport async function disposeHighlighter(): Promise<void> {\n const cached = highlighter;\n highlighter = undefined;\n cleanUpResolvedLanguages();\n cleanUpResolvedThemes();\n if (cached != null && 'then' in cached) {\n // A failed initialization has nothing to dispose.\n (await cached.catch(() => undefined))?.dispose();\n } else {\n cached?.dispose();\n }\n}\n"],"mappings":";;;;;AAuBA,IAAI;;;;;AAYJ,eAAsB,kBACpB,MAC2B;CAC3B,MAAM,eAAe,uBAAuB,IAAI;CAEhD,uBAAuB,YAAY;CACnC,IAAI;EACF,IAAI,iBAAiB,cAAc;GACjC,MAAM,EAAE,0BAA0B,MAAM,OAAO;GAC/C,OAAO,IAAI,sBAAsB;EACnC;EACA,MAAM,EAAE,qBAAqB,MAAM,OAAO;EAC1C,OAAO,MAAM,iBAAiB,OAAO,YAAY;CACnD,UAAU;EACR,uBAAuB;CACzB;AACF;AAEA,eAAsB,qBAAqB,EACzC,QACA,OACA,wBACgD;CAChD,wBAAwB;CACxB,MAAM,SAAU,gBAAgB,kBAC9B,mBAAmB,KAAK,oBAC1B;CACA,IAAI;CACJ,IAAI;EACF,WAAW,MAAM;CACnB,SAAS,OAAO;EAEd,IAAI,gBAAgB,QAClB,cAAc,KAAA;EAEhB,MAAM;CACR;CACA,IAAI,gBAAgB,QAClB,cAAc;CAEhB,MAAM,QAAQ,IAAI,CAChB,SAAS,cAAc,cAAc,MAAM,GAC3C,SAAS,cAAc,KAAK,CAC9B,CAAC;CAED,IAAI,SAAS,YACX,MAAM,IAAI,yBAAyB;CAErC,OAAO;AACT;AAGA,SAAS,0BAAgC;CACvC,IACE,eAAe,QACf,EAAE,UAAU,gBACZ,YAAY,YAEZ,cAAc,KAAA;AAElB;AAEA,SAAgB,sBAA+B;CAC7C,wBAAwB;CACxB,OAAO,eAAe,QAAQ,EAAE,UAAU;AAC5C;;;;AAUA,SAAgB,uBAAuB,EACrC,OACA,SAC+B,CAAC,GAAiC;CACjE,wBAAwB;CACxB,MAAM,WAAW;CACjB,IACE,YAAY,QACZ,UAAU,YACT,SAAS,QAAQ,CAAC,kBAAkB,OAAO,QAAQ,KACnD,QAAQ,QAAQ,CAAC,SAAS,mBAAmB,CAAC,IAAI,CAAC,GAEpD;CAEF,OAAO;AACT;AAEA,SAAgB,uBAAgC;CAC9C,OAAO,eAAe,QAAQ,UAAU;AAC1C;AAEA,SAAgB,oBAA6B;CAC3C,wBAAwB;CACxB,OAAO,eAAe;AACxB;AAEA,eAAsB,mBACpB,SACe;CACf,MAAM,qBAAqB,OAAO;AACpC;;;;;;AAOA,eAAsB,qBAAoC;CACxD,MAAM,SAAS;CACf,cAAc,KAAA;CACd,yBAAyB;CACzB,sBAAsB;CACtB,IAAI,UAAU,QAAQ,UAAU,QAE9B,CAAC,MAAM,OAAO,YAAY,KAAA,CAAS,EAAA,EAAI,QAAQ;MAE/C,QAAQ,QAAQ;AAEpB"}
1
+ {"version":3,"file":"shared_highlighter.js","names":[],"sources":["../../src/highlighter/shared_highlighter.ts"],"sourcesContent":["import type {\n DiffsHighlighter,\n DiffsThemeNames,\n HighlighterTypes,\n SupportedLanguages,\n ThemesType,\n} from '../types';\nimport {\n acquireHighlighterType,\n getHighlighterType,\n HighlighterDisposedError,\n releaseHighlighterType,\n resolveHighlighterType,\n} from './highlighterType';\nimport { cleanUpResolvedLanguages } from './languages/cleanUpResolvedLanguages';\nimport { areThemesAttached } from './themes/areThemesAttached';\nimport { cleanUpResolvedThemes } from './themes/cleanUpResolvedThemes';\n\nexport {\n getHighlighterType,\n HighlighterDisposedError,\n} from './highlighterType';\n\nlet highlighter: DiffsHighlighter | Promise<DiffsHighlighter> | undefined;\n\nexport interface HighlighterOptions {\n themes: DiffsThemeNames[];\n langs: SupportedLanguages[];\n preferredHighlighter?: HighlighterTypes;\n}\n\n/**\n * Creates an instance the caller must dispose. Defaults to the active type\n * or DEFAULT_HIGHLIGHTER; rejects if a different type is already active.\n */\nexport async function createHighlighter(\n type?: HighlighterTypes\n): Promise<DiffsHighlighter> {\n const resolvedType = resolveHighlighterType(type);\n // Reserve the type before importing to prevent concurrent backend loads.\n acquireHighlighterType(resolvedType);\n try {\n if (resolvedType === 'highlights') {\n const { HighlightsHighlighter } = await import('./backends/highlights');\n return new HighlightsHighlighter();\n }\n const { ShikiHighlighter } = await import('./backends/shiki');\n return await ShikiHighlighter.create(resolvedType);\n } finally {\n releaseHighlighterType();\n }\n}\n\nexport async function getSharedHighlighter({\n themes,\n langs,\n preferredHighlighter,\n}: HighlighterOptions): Promise<DiffsHighlighter> {\n dropDisposedHighlighter();\n const cached = (highlighter ??= createHighlighter(\n getHighlighterType() ?? preferredHighlighter\n ));\n let instance: DiffsHighlighter;\n try {\n instance = await cached;\n } catch (error) {\n // Allow retries without clearing a newer request.\n if (highlighter === cached) {\n highlighter = undefined;\n }\n throw error;\n }\n if (highlighter === cached) {\n highlighter = instance;\n }\n await Promise.all([\n instance.themeResolver.resolveThemes(themes),\n instance.loadLanguages(langs),\n ]);\n // disposeHighlighter() may run while themes and languages load.\n if (instance.isDisposed) {\n throw new HighlighterDisposedError();\n }\n return instance;\n}\n\n// Direct dispose() calls leave the shared reference pointing to a dead instance.\nfunction dropDisposedHighlighter(): void {\n if (\n highlighter != null &&\n !('then' in highlighter) &&\n highlighter.isDisposed\n ) {\n highlighter = undefined;\n }\n}\n\nexport function isHighlighterLoaded(): boolean {\n dropDisposedHighlighter();\n return highlighter != null && !('then' in highlighter);\n}\n\ninterface GetHighlighterIfLoadedProps {\n theme?: DiffsThemeNames | ThemesType;\n lang?: SupportedLanguages;\n langs?: SupportedLanguages[];\n}\n\n/**\n * Returns undefined if the theme or language is not loaded.\n */\nexport function getHighlighterIfLoaded({\n theme,\n lang,\n langs,\n}: GetHighlighterIfLoadedProps = {}): DiffsHighlighter | undefined {\n dropDisposedHighlighter();\n const instance = highlighter;\n if (\n instance == null ||\n 'then' in instance ||\n (theme != null && !areThemesAttached(theme, instance)) ||\n ((lang != null || langs != null) &&\n !instance.hasLoadedLanguages([\n ...(lang != null ? [lang] : []),\n ...(langs ?? []),\n ]))\n ) {\n return undefined;\n }\n return instance;\n}\n\nexport function isHighlighterLoading(): boolean {\n return highlighter != null && 'then' in highlighter;\n}\n\nexport function isHighlighterNull(): boolean {\n dropDisposedHighlighter();\n return highlighter == null;\n}\n\nexport async function preloadHighlighter(\n options: HighlighterOptions\n): Promise<void> {\n await getSharedHighlighter(options);\n}\n\n/**\n * Disposes an already loaded shared instance synchronously and clears caches.\n * Instances from createHighlighter() must be disposed separately before\n * switching types.\n */\nexport async function disposeHighlighter(): Promise<void> {\n const cached = highlighter;\n highlighter = undefined;\n cleanUpResolvedLanguages();\n cleanUpResolvedThemes();\n if (cached != null && 'then' in cached) {\n // A failed initialization has nothing to dispose.\n (await cached.catch(() => undefined))?.dispose();\n } else {\n cached?.dispose();\n }\n}\n"],"mappings":";;;;;AAuBA,IAAI;;;;;AAYJ,eAAsB,kBACpB,MAC2B;CAC3B,MAAM,eAAe,uBAAuB,IAAI;CAEhD,uBAAuB,YAAY;CACnC,IAAI;EACF,IAAI,iBAAiB,cAAc;GACjC,MAAM,EAAE,0BAA0B,MAAM,OAAO;GAC/C,OAAO,IAAI,sBAAsB;EACnC;EACA,MAAM,EAAE,qBAAqB,MAAM,OAAO;EAC1C,OAAO,MAAM,iBAAiB,OAAO,YAAY;CACnD,UAAU;EACR,uBAAuB;CACzB;AACF;AAEA,eAAsB,qBAAqB,EACzC,QACA,OACA,wBACgD;CAChD,wBAAwB;CACxB,MAAM,SAAU,gBAAgB,kBAC9B,mBAAmB,KAAK,oBAC1B;CACA,IAAI;CACJ,IAAI;EACF,WAAW,MAAM;CACnB,SAAS,OAAO;EAEd,IAAI,gBAAgB,QAClB,cAAc,KAAA;EAEhB,MAAM;CACR;CACA,IAAI,gBAAgB,QAClB,cAAc;CAEhB,MAAM,QAAQ,IAAI,CAChB,SAAS,cAAc,cAAc,MAAM,GAC3C,SAAS,cAAc,KAAK,CAC9B,CAAC;CAED,IAAI,SAAS,YACX,MAAM,IAAI,yBAAyB;CAErC,OAAO;AACT;AAGA,SAAS,0BAAgC;CACvC,IACE,eAAe,QACf,EAAE,UAAU,gBACZ,YAAY,YAEZ,cAAc,KAAA;AAElB;AAEA,SAAgB,sBAA+B;CAC7C,wBAAwB;CACxB,OAAO,eAAe,QAAQ,EAAE,UAAU;AAC5C;;;;AAWA,SAAgB,uBAAuB,EACrC,OACA,MACA,UAC+B,CAAC,GAAiC;CACjE,wBAAwB;CACxB,MAAM,WAAW;CACjB,IACE,YAAY,QACZ,UAAU,YACT,SAAS,QAAQ,CAAC,kBAAkB,OAAO,QAAQ,MAClD,QAAQ,QAAQ,SAAS,SACzB,CAAC,SAAS,mBAAmB,CAC3B,GAAI,QAAQ,OAAO,CAAC,IAAI,IAAI,CAAC,GAC7B,GAAI,SAAS,CAAC,CAChB,CAAC,GAEH;CAEF,OAAO;AACT;AAEA,SAAgB,uBAAgC;CAC9C,OAAO,eAAe,QAAQ,UAAU;AAC1C;AAEA,SAAgB,oBAA6B;CAC3C,wBAAwB;CACxB,OAAO,eAAe;AACxB;AAEA,eAAsB,mBACpB,SACe;CACf,MAAM,qBAAqB,OAAO;AACpC;;;;;;AAOA,eAAsB,qBAAoC;CACxD,MAAM,SAAS;CACf,cAAc,KAAA;CACd,yBAAyB;CACzB,sBAAsB;CACtB,IAAI,UAAU,QAAQ,UAAU,QAE9B,CAAC,MAAM,OAAO,YAAY,KAAA,CAAS,EAAA,EAAI,QAAQ;MAE/C,QAAQ,QAAQ;AAEpB"}
package/dist/index.d.ts CHANGED
@@ -8,20 +8,20 @@ import { FileDiffEditCompleteEvent, FileEditCompleteEvent } from "./editor/types
8
8
  import { GetHoveredLineResult, GetLineIndexUtility, InteractionManager, InteractionManagerBaseOptions, InteractionManagerMode, InteractionManagerOptions, LogTypes, MergeConflictActionTarget, OnDiffLineClickProps, OnDiffLineEnterLeaveProps, OnLineClickProps, OnLineEnterLeaveProps, OnTokenEventProps, SelectionWriteOptions, pluckInteractionOptions } from "./managers/InteractionManager.js";
9
9
  import { ResizeManager, ResizeManagerColumnVariableMode, ResizeManagerSetupOptions } from "./managers/ResizeManager.js";
10
10
  import { FileRenderResult, FileRenderer, FileRendererOptions } from "./renderers/FileRenderer.js";
11
- import { File, FileEditChangeHandler, FileEditCompleteHandler, FileHydrateProps, FileOptions, FileRenderProps } from "./components/File.js";
11
+ import { File, FileEditChangeHandler, FileEditCompleteHandler, FileHydrateProps, FileOptions, FileRenderData, FileRenderInput, FileRenderProps } from "./components/File.js";
12
12
  import { ScrollSyncManager } from "./managers/ScrollSyncManager.js";
13
13
  import { DiffHunksRenderer, DiffHunksRendererOptions, DiffHunksRendererOptionsWithDefaults, HunksRenderResult, InjectedRow, LineDecoration, RenderedLineContext, SplitInjectedRow, SplitInjectedRowPlacement, SplitLineDecorationProps, UnifiedInjectedRowPlacement, UnifiedLineDecorationProps } from "./renderers/DiffHunksRenderer.js";
14
- import { FileDiff, FileDiffEditChangeHandler, FileDiffEditCompleteHandler, FileDiffHydrationProps, FileDiffOptions, FileDiffRenderBaseProps, FileDiffRenderProps, FileDiffType } from "./components/FileDiff.js";
14
+ import { FileDiff, FileDiffEditChangeHandler, FileDiffEditCompleteHandler, FileDiffHydrationProps, FileDiffOptions, FileDiffRenderBaseProps, FileDiffRenderData, FileDiffRenderInput, FileDiffRenderProps, FileDiffType } from "./components/FileDiff.js";
15
15
  import { Virtualizer, VirtualizerConfig, VirtualizerScrollOptions } from "./components/Virtualizer.js";
16
16
  import { VirtualizedFile } from "./components/VirtualizedFile.js";
17
17
  import { VIRTUALIZED_FILE_DIFF_LAYOUT_CHECKPOINT_INTERVAL, VirtualizedFileDiff } from "./components/VirtualizedFileDiff.js";
18
18
  import { CODE_VIEW_DIFF_OPTION_KEYS, CODE_VIEW_FILE_OPTION_KEYS, CodeView, CodeViewCoordinator, CodeViewCreateEditorOptions, CodeViewItemEditCompleteEventMap, CodeViewItemEditCompleteHandler, CodeViewLineSelection, CodeViewMode, CodeViewModeItemMap, CodeViewOptions, CodeViewRenderedDiffItem, CodeViewRenderedFileItem, CodeViewRenderedItem, CodeViewScrollListener, CodeViewSlotSnapshot } from "./components/CodeView.js";
19
- import { CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_HIGHLIGHTER, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, SPLIT_WITH_NEWLINES, THEME_CSS_ATTRIBUTE, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE } from "./constants.js";
19
+ import { CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_HIGHLIGHTER, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, EMPTY_LINE_ANNOTATIONS, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, SPLIT_WITH_NEWLINES, THEME_CSS_ATTRIBUTE, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE } from "./constants.js";
20
20
  import { CodeToTokenTransformStreamOptions } from "./shiki-stream/types.js";
21
21
  import { CodeToTokenTransformStream } from "./shiki-stream/stream.js";
22
22
  import "./shiki-stream/index.js";
23
23
  import { FileStream, FileStreamOptions } from "./components/FileStream.js";
24
- import { MergeConflictActionsTypeOption, RenderMergeConflictActions, UnresolvedFile, UnresolvedFileHydrationProps, UnresolvedFileOptions, UnresolvedFileRenderProps, getUnresolvedDiffHunksRendererOptions } from "./components/UnresolvedFile.js";
24
+ import { MergeConflictActionsTypeOption, RenderMergeConflictActions, UnresolvedFile, UnresolvedFileHydrationProps, UnresolvedFileOptions, UnresolvedFileRenderData, UnresolvedFileRenderInput, UnresolvedFileRenderProps, getUnresolvedDiffHunksRendererOptions } from "./components/UnresolvedFile.js";
25
25
  import { LineAnnotationPosition, getLineAnnotationSource, recordLineAnnotationSource } from "./utils/lineAnnotationIdentity.js";
26
26
  import { HighlighterDisposedError, getHighlighterType } from "./highlighter/highlighterType.js";
27
27
  import { areLanguagesAttached } from "./highlighter/languages/areLanguagesAttached.js";
@@ -65,6 +65,7 @@ import { areSelectionsEqual } from "./utils/areSelectionsEqual.js";
65
65
  import { areThemesEqual } from "./utils/areThemesEqual.js";
66
66
  import { areVirtualWindowSpecsEqual } from "./utils/areVirtualWindowSpecsEqual.js";
67
67
  import { areWorkerStatsEqual } from "./utils/areWorkerStatsEqual.js";
68
+ import { canUseWASM } from "./utils/canUseWASM.js";
68
69
  import { cleanLastNewline } from "./utils/cleanLastNewline.js";
69
70
  import { cloneFileDiffMetadata, cloneHunks } from "./utils/cloneFileDiffMetadata.js";
70
71
  import { createAnnotationElement } from "./utils/createAnnotationElement.js";
@@ -97,6 +98,7 @@ import { getOrCreateCodeNode } from "./utils/getOrCreateCodeNode.js";
97
98
  import { getSingularPatch } from "./utils/getSingularPatch.js";
98
99
  import { getThemes } from "./utils/getThemes.js";
99
100
  import { getTotalLineCountFromHunks } from "./utils/getTotalLineCountFromHunks.js";
101
+ import { hastToHtml } from "./utils/hastToHtml.js";
100
102
  import { createGutterGap, createGutterItem, createGutterWrapper, createHastElement, createIconElement, createTextNodeElement, findCodeElement } from "./utils/hast_utils.js";
101
103
  import { hydratePartialDiff } from "./utils/hydratePartialDiff.js";
102
104
  import { isDefaultRenderRange } from "./utils/isDefaultRenderRange.js";
@@ -110,9 +112,12 @@ import { prerenderHTMLIfNecessary } from "./utils/prerenderHTMLIfNecessary.js";
110
112
  import { processLine } from "./utils/processLine.js";
111
113
  import { renderDiffWithHighlighter } from "./utils/renderDiffWithHighlighter.js";
112
114
  import { renderFileWithHighlighter } from "./utils/renderFileWithHighlighter.js";
115
+ import { RenderTokenLinesOptions, renderTokenLines } from "./utils/renderTokenLines.js";
113
116
  import { resolveConflict } from "./utils/resolveConflict.js";
114
117
  import { resolveRegion } from "./utils/resolveRegion.js";
115
118
  import { setLanguageOverride } from "./utils/setLanguageOverride.js";
116
119
  import { setPreNodeProperties } from "./utils/setWrapperNodeProps.js";
120
+ import { tokenStyle } from "./utils/tokenStyle.js";
121
+ import { tokensToHtml } from "./utils/tokensToHtml.js";
117
122
  import { trimPatchContext } from "./utils/trimPatchContext.js";
118
- export { type AnnotationLineMap, type AnnotationSide, type AnnotationSpan, type AppliedThemeStyleCache, AttachedLanguages, type BaseCodeOptions, type BaseDiffOptions, type BaseDiffOptionsWithDefaults, CODE_VIEW_DIFF_OPTION_KEYS, CODE_VIEW_FILE_OPTION_KEYS, CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, type CSSVariablesThemeOptions, CUSTOM_HEADER_SLOT_ID, type ChangeContent, type ChangeTypes, type CodeColumnType, type CodeToHtmlOptions, CodeToTokenTransformStream, CodeToTokenTransformStreamOptions, type CodeToTokensOptions, CodeView, CodeViewCoordinator, CodeViewCreateEditorOptions, type CodeViewDiffItem, type CodeViewFileItem, type CodeViewItem, CodeViewItemEditCompleteEventMap, CodeViewItemEditCompleteHandler, type CodeViewItemScrollTarget, type CodeViewLayout, type CodeViewLineScrollTarget, CodeViewLineSelection, CodeViewMode, CodeViewModeItemMap, CodeViewOptions, type CodeViewPositionScrollTarget, type CodeViewRangeScrollTarget, CodeViewRenderedDiffItem, CodeViewRenderedFileItem, CodeViewRenderedItem, type CodeViewScrollBehavior, CodeViewScrollListener, type CodeViewScrollTarget, CodeViewSlotSnapshot, type ConflictResolverTypes, type ContextContent, CreateFileHeaderElementProps, type CreatePatchOptionsNonabortable, type CustomPreProperties, type CustomThemeLoader, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_HIGHLIGHTER, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, type DecorationItem, type DiffAcceptRejectHunkConfig, type DiffAcceptRejectHunkType, type DiffFileInput, DiffHunksRenderer, DiffHunksRendererOptions, DiffHunksRendererOptionsWithDefaults, type DiffIndicators, type DiffLineAnnotation, type DiffLineEventBaseProps, type DiffTokenEventBaseProps, type DiffsEditorTokenizer, type DiffsEditorTokenizerOptions, type DiffsHighlighter, type DiffsStreamTokenizer, type DiffsTheme, type DiffsThemeNames, EMPTY_RENDER_RANGE, EXTENSION_TO_FILE_FORMAT, type ExpansionDirections, type ExtensionFormatMap, FILENAME_HEADER_REGEX, FILE_CONTEXT_BLOB, File, type FileContents, FileDiff, type FileDiffContentsLoader, FileDiffEditChangeHandler, type FileDiffEditCompleteEvent, FileDiffEditCompleteHandler, FileDiffHydrationProps, type FileDiffLoadedChangedFiles, type FileDiffLoadedFiles, type FileDiffLoadedPureRenamedFile, type FileDiffMetadata, FileDiffOptions, FileDiffRenderBaseProps, FileDiffRenderProps, FileDiffType, FileEditChangeHandler, type FileEditCompleteEvent, FileEditCompleteHandler, type FileHeaderRenderMode, FileHydrateProps, FileOptions, FileRenderProps, FileRenderResult, FileRenderer, FileRendererOptions, FileStream, FileStreamOptions, type ForceDiffPlainTextOptions, type ForceFilePlainTextOptions, GIT_DIFF_FILE_BREAK_REGEX, type GapSpan, GetHoveredLineResult, GetLineIndexUtility, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, type HighlightedToken, HighlighterDisposedError, HighlighterOptions, type HighlighterTypes, type Hunk, type HunkData, type HunkExpansionRegion, type HunkLineType, type HunkSeparators, HunksRenderResult, INDEX_LINE_METADATA, InjectedRow, InteractionManager, InteractionManagerBaseOptions, InteractionManagerMode, InteractionManagerOptions, type LineAnnotation, LineAnnotationPosition, LineDecoration, type LineDiffTypes, type LineEventBaseProps, type LineInfo, type LineSpans, type LineTypes, LogTypes, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, type MaybeDiffFileInput, type MergeConflictActionPayload, MergeConflictActionTarget, MergeConflictActionsTypeOption, type MergeConflictMarkerRow, type MergeConflictMarkerRowType, type MergeConflictRegion, type MergeConflictResolution, type NumericScrollLineAnchor, type ObservedAnnotationNodes, type ObservedGridNodes, OnDiffLineClickProps, OnDiffLineEnterLeaveProps, OnLineClickProps, OnLineEnterLeaveProps, OnTokenEventProps, ParsedLine, type ParsedPatch, type PendingCodeViewLayoutReset, type PostRenderPhase, type PrePropertiesConfig, type ProcessFileConflictData, type RecallToken, RegisteredCustomLanguages, type RenderDiffFilesResult, type RenderDiffOptions, type RenderDiffResult, type RenderFileMetadata, type RenderFileOptions, type RenderFileResult, type RenderHeaderFilenameSuffixCallback, type RenderHeaderMetadataCallback, type RenderHeaderPrefixCallback, RenderMergeConflictActions, type RenderRange, type RenderWindow, type RenderedDiffASTCache, type RenderedFileASTCache, RenderedLineContext, ResizeManager, ResizeManagerColumnVariableMode, ResizeManagerSetupOptions, ResolvedLanguages, ResolvingLanguages, SPLIT_WITH_NEWLINES, SVGSpriteNames, SVGSpriteSheet, ScrollSyncManager, type SelectedLineRange, type SelectionPoint, type SelectionSide, SelectionWriteOptions, type SharedRenderState, type SmoothScrollSettings, SplitInjectedRow, SplitInjectedRowPlacement, SplitLineDecorationProps, type StickySpecs, type SupportedLanguages, THEME_CSS_ATTRIBUTE, type ThemeTypes, type ThemedDiffResult, type ThemedFileResult, type ThemedToken, type ThemesType, type TokenEventBase, type TokensResult, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE, UnifiedInjectedRowPlacement, UnifiedLineDecorationProps, UnresolvedFile, UnresolvedFileHydrationProps, UnresolvedFileOptions, UnresolvedFileRenderProps, VIRTUALIZED_FILE_DIFF_LAYOUT_CHECKPOINT_INTERVAL, type VirtualFileMetrics, type VirtualWindowSpecs, VirtualizedFile, VirtualizedFileDiff, Virtualizer, VirtualizerConfig, VirtualizerScrollOptions, areDiffLineAnnotationsEqual, areDiffRenderOptionsEqual, areDiffTargetsEqual, areFileRenderOptionsEqual, areFilesEqual, areHunkDataEqual, areLanguagesAttached, areLineAnnotationsEqual, areObjectsEqual, areOptionsEqual, arePrePropertiesEqual, areRenderRangesEqual, areSelectionsEqual, areThemesAttached, areThemesEqual, areVirtualWindowSpecsEqual, areWorkerStatsEqual, attachResolvedLanguages, attachResolvedThemes, cleanLastNewline, cleanUpResolvedLanguages, cleanUpResolvedThemes, clearRenderQueue, cloneFileDiffMetadata, cloneHunks, createAnnotationElement, createAnnotationWrapperNode, createCSSVariablesTheme, createDiffSpanDecoration, createEmptyRowBuffer, createFileHeaderElement, createGutterGap, createGutterItem, createGutterUtilityContentNode, createGutterUtilityElement, createGutterWrapper, createHastElement, createHighlighter, createIconElement, createNoNewlineElement, createPreElement, createPreWrapperProperties, createRowNodes, createSeparator, createSpanFromToken, createStyleElement, createTextNodeElement, createThemeStyleElement, createUnsafeCSSStyleNode, createWindowFromScrollPosition, dequeueRender, detachString, diffAcceptRejectHunk, disposeHighlighter, findCodeElement, formatCSSVariablePrefix, getCustomExtensionsMap, getCustomExtensionsVersion, getFiletypeFromFileName, getHighlighterIfLoaded, getHighlighterOptions, getHighlighterThemeStyles, getHighlighterType, getHunkSeparatorSlotName, getIconForType, getLineAnnotationName, getLineAnnotationSource, getLineEndingType, getLineNodes, getOrCreateCodeNode, getResolvedLanguages, getResolvedOrResolveLanguage, getResolvedOrResolveTheme, getResolvedThemes, getSharedHighlighter, getSingularPatch, getThemes, getTotalLineCountFromHunks, getUnresolvedDiffHunksRendererOptions, hasResolvedLanguages, hasResolvedThemes, hydratePartialDiff, isDefaultRenderRange, isDiffAnnotation, isDiffAnnotationCollection, isFileAnnotation, isFileAnnotationCollection, isHighlighterLoaded, isHighlighterLoading, isHighlighterNull, isWorkerContext, parseDiffFromFile, parseLineType, parsePatchFiles, patchScrollbarGutterSize, pluckInteractionOptions, prefersReducedMotion, preloadHighlighter, prerenderHTMLIfNecessary, processFile, processLine, processPatch, pushOrJoinSpan, queueRender, recordLineAnnotationSource, registerCustomCSSVariableTheme, registerCustomLanguage, registerCustomTheme, releaseStringDetachBuffer, renderDiffWithHighlighter, renderFileWithHighlighter, replaceCustomExtensions, resolveConflict, resolveLanguage, resolveLanguages, resolveRegion, resolveTheme, resolveThemes, setCustomExtension, setLanguageOverride, setPreNodeProperties, trimPatchContext, wrapCoreCSS, wrapThemeCSS, wrapUnsafeCSS };
123
+ export { type AnnotationLineMap, type AnnotationSide, type AnnotationSpan, type AppliedThemeStyleCache, AttachedLanguages, type BaseCodeOptions, type BaseDiffOptions, type BaseDiffOptionsWithDefaults, CODE_VIEW_DIFF_OPTION_KEYS, CODE_VIEW_FILE_OPTION_KEYS, CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, type CSSVariablesThemeOptions, CUSTOM_HEADER_SLOT_ID, type ChangeContent, type ChangeTypes, type CodeColumnType, type CodeToHtmlOptions, CodeToTokenTransformStream, CodeToTokenTransformStreamOptions, type CodeToTokensOptions, CodeView, CodeViewCoordinator, CodeViewCreateEditorOptions, type CodeViewDiffItem, type CodeViewFileItem, type CodeViewItem, CodeViewItemEditCompleteEventMap, CodeViewItemEditCompleteHandler, type CodeViewItemScrollTarget, type CodeViewLayout, type CodeViewLineScrollTarget, CodeViewLineSelection, CodeViewMode, CodeViewModeItemMap, CodeViewOptions, type CodeViewPositionScrollTarget, type CodeViewRangeScrollTarget, CodeViewRenderedDiffItem, CodeViewRenderedFileItem, CodeViewRenderedItem, type CodeViewScrollBehavior, CodeViewScrollListener, type CodeViewScrollTarget, CodeViewSlotSnapshot, type ConflictResolverTypes, type ContextContent, CreateFileHeaderElementProps, type CreatePatchOptionsNonabortable, type CustomPreProperties, type CustomThemeLoader, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_HIGHLIGHTER, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, type DecorationItem, type DiffAcceptRejectHunkConfig, type DiffAcceptRejectHunkType, type DiffFileInput, DiffHunksRenderer, DiffHunksRendererOptions, DiffHunksRendererOptionsWithDefaults, type DiffIndicators, type DiffLineAnnotation, type DiffLineEventBaseProps, type DiffTokenEventBaseProps, type DiffsEditorTokenizer, type DiffsEditorTokenizerOptions, type DiffsHighlighter, type DiffsStreamTokenizer, type DiffsTheme, type DiffsThemeNames, EMPTY_LINE_ANNOTATIONS, EMPTY_RENDER_RANGE, EXTENSION_TO_FILE_FORMAT, type ExpansionDirections, type ExtensionFormatMap, FILENAME_HEADER_REGEX, FILE_CONTEXT_BLOB, File, type FileContents, FileDiff, type FileDiffContentsLoader, FileDiffEditChangeHandler, type FileDiffEditCompleteEvent, FileDiffEditCompleteHandler, FileDiffHydrationProps, type FileDiffLoadedChangedFiles, type FileDiffLoadedFiles, type FileDiffLoadedPureRenamedFile, type FileDiffMetadata, FileDiffOptions, FileDiffRenderBaseProps, FileDiffRenderData, FileDiffRenderInput, FileDiffRenderProps, FileDiffType, FileEditChangeHandler, type FileEditCompleteEvent, FileEditCompleteHandler, type FileHeaderRenderMode, FileHydrateProps, FileOptions, FileRenderData, FileRenderInput, FileRenderProps, FileRenderResult, FileRenderer, FileRendererOptions, FileStream, FileStreamOptions, type ForceDiffPlainTextOptions, type ForceFilePlainTextOptions, GIT_DIFF_FILE_BREAK_REGEX, type GapSpan, GetHoveredLineResult, GetLineIndexUtility, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, type HighlightedToken, HighlighterDisposedError, HighlighterOptions, type HighlighterTypes, type Hunk, type HunkData, type HunkExpansionRegion, type HunkLineType, type HunkSeparators, HunksRenderResult, INDEX_LINE_METADATA, InjectedRow, InteractionManager, InteractionManagerBaseOptions, InteractionManagerMode, InteractionManagerOptions, type LineAnnotation, LineAnnotationPosition, LineDecoration, type LineDiffTypes, type LineEventBaseProps, type LineInfo, type LineSpans, type LineTypes, LogTypes, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, type MaybeDiffFileInput, type MergeConflictActionPayload, MergeConflictActionTarget, MergeConflictActionsTypeOption, type MergeConflictMarkerRow, type MergeConflictMarkerRowType, type MergeConflictRegion, type MergeConflictResolution, type NumericScrollLineAnchor, type ObservedAnnotationNodes, type ObservedGridNodes, OnDiffLineClickProps, OnDiffLineEnterLeaveProps, OnLineClickProps, OnLineEnterLeaveProps, OnTokenEventProps, ParsedLine, type ParsedPatch, type PendingCodeViewLayoutReset, type PostRenderPhase, type PrePropertiesConfig, type ProcessFileConflictData, type RecallToken, RegisteredCustomLanguages, type RenderDiffFilesResult, type RenderDiffOptions, type RenderDiffResult, type RenderFileMetadata, type RenderFileOptions, type RenderFileResult, type RenderHeaderFilenameSuffixCallback, type RenderHeaderMetadataCallback, type RenderHeaderPrefixCallback, RenderMergeConflictActions, type RenderRange, RenderTokenLinesOptions, type RenderWindow, type RenderedDiffASTCache, type RenderedFileASTCache, RenderedLineContext, ResizeManager, ResizeManagerColumnVariableMode, ResizeManagerSetupOptions, ResolvedLanguages, ResolvingLanguages, SPLIT_WITH_NEWLINES, SVGSpriteNames, SVGSpriteSheet, ScrollSyncManager, type SelectedLineRange, type SelectionPoint, type SelectionSide, SelectionWriteOptions, type SharedRenderState, type SmoothScrollSettings, SplitInjectedRow, SplitInjectedRowPlacement, SplitLineDecorationProps, type StickySpecs, type SupportedLanguages, THEME_CSS_ATTRIBUTE, type ThemeTypes, type ThemedDiffResult, type ThemedFileResult, type ThemedToken, type ThemesType, type TokenEventBase, type TokensResult, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE, UnifiedInjectedRowPlacement, UnifiedLineDecorationProps, UnresolvedFile, UnresolvedFileHydrationProps, UnresolvedFileOptions, UnresolvedFileRenderData, UnresolvedFileRenderInput, UnresolvedFileRenderProps, VIRTUALIZED_FILE_DIFF_LAYOUT_CHECKPOINT_INTERVAL, type VirtualFileMetrics, type VirtualWindowSpecs, VirtualizedFile, VirtualizedFileDiff, Virtualizer, VirtualizerConfig, VirtualizerScrollOptions, areDiffLineAnnotationsEqual, areDiffRenderOptionsEqual, areDiffTargetsEqual, areFileRenderOptionsEqual, areFilesEqual, areHunkDataEqual, areLanguagesAttached, areLineAnnotationsEqual, areObjectsEqual, areOptionsEqual, arePrePropertiesEqual, areRenderRangesEqual, areSelectionsEqual, areThemesAttached, areThemesEqual, areVirtualWindowSpecsEqual, areWorkerStatsEqual, attachResolvedLanguages, attachResolvedThemes, canUseWASM, cleanLastNewline, cleanUpResolvedLanguages, cleanUpResolvedThemes, clearRenderQueue, cloneFileDiffMetadata, cloneHunks, createAnnotationElement, createAnnotationWrapperNode, createCSSVariablesTheme, createDiffSpanDecoration, createEmptyRowBuffer, createFileHeaderElement, createGutterGap, createGutterItem, createGutterUtilityContentNode, createGutterUtilityElement, createGutterWrapper, createHastElement, createHighlighter, createIconElement, createNoNewlineElement, createPreElement, createPreWrapperProperties, createRowNodes, createSeparator, createSpanFromToken, createStyleElement, createTextNodeElement, createThemeStyleElement, createUnsafeCSSStyleNode, createWindowFromScrollPosition, dequeueRender, detachString, diffAcceptRejectHunk, disposeHighlighter, findCodeElement, formatCSSVariablePrefix, getCustomExtensionsMap, getCustomExtensionsVersion, getFiletypeFromFileName, getHighlighterIfLoaded, getHighlighterOptions, getHighlighterThemeStyles, getHighlighterType, getHunkSeparatorSlotName, getIconForType, getLineAnnotationName, getLineAnnotationSource, getLineEndingType, getLineNodes, getOrCreateCodeNode, getResolvedLanguages, getResolvedOrResolveLanguage, getResolvedOrResolveTheme, getResolvedThemes, getSharedHighlighter, getSingularPatch, getThemes, getTotalLineCountFromHunks, getUnresolvedDiffHunksRendererOptions, hasResolvedLanguages, hasResolvedThemes, hastToHtml, hydratePartialDiff, isDefaultRenderRange, isDiffAnnotation, isDiffAnnotationCollection, isFileAnnotation, isFileAnnotationCollection, isHighlighterLoaded, isHighlighterLoading, isHighlighterNull, isWorkerContext, parseDiffFromFile, parseLineType, parsePatchFiles, patchScrollbarGutterSize, pluckInteractionOptions, prefersReducedMotion, preloadHighlighter, prerenderHTMLIfNecessary, processFile, processLine, processPatch, pushOrJoinSpan, queueRender, recordLineAnnotationSource, registerCustomCSSVariableTheme, registerCustomLanguage, registerCustomTheme, releaseStringDetachBuffer, renderDiffWithHighlighter, renderFileWithHighlighter, renderTokenLines, replaceCustomExtensions, resolveConflict, resolveLanguage, resolveLanguages, resolveRegion, resolveTheme, resolveThemes, setCustomExtension, setLanguageOverride, setPreNodeProperties, tokenStyle, tokensToHtml, trimPatchContext, wrapCoreCSS, wrapThemeCSS, wrapUnsafeCSS };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_HIGHLIGHTER, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, SPLIT_WITH_NEWLINES, THEME_CSS_ATTRIBUTE, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE } from "./constants.js";
1
+ import { CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_HIGHLIGHTER, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, EMPTY_LINE_ANNOTATIONS, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, SPLIT_WITH_NEWLINES, THEME_CSS_ATTRIBUTE, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE } from "./constants.js";
2
2
  import { HighlighterDisposedError, getHighlighterType } from "./highlighter/highlighterType.js";
3
3
  import { AttachedLanguages, RegisteredCustomLanguages, ResolvedLanguages, ResolvingLanguages } from "./highlighter/languages/constants.js";
4
4
  import { cleanUpResolvedLanguages } from "./highlighter/languages/cleanUpResolvedLanguages.js";
@@ -16,6 +16,7 @@ import { createWindowFromScrollPosition } from "./utils/createWindowFromScrollPo
16
16
  import { prefersReducedMotion } from "./utils/prefersReducedMotion.js";
17
17
  import { createGutterGap, createGutterItem, createGutterWrapper, createHastElement, createIconElement, createTextNodeElement, findCodeElement } from "./utils/hast_utils.js";
18
18
  import { createGutterUtilityElement } from "./utils/createGutterUtilityElement.js";
19
+ import { hastToHtml } from "./utils/hastToHtml.js";
19
20
  import { InteractionManager, pluckInteractionOptions } from "./managers/InteractionManager.js";
20
21
  import { ResizeManager } from "./managers/ResizeManager.js";
21
22
  import { areLanguagesAttached } from "./highlighter/languages/areLanguagesAttached.js";
@@ -32,6 +33,8 @@ import { isDefaultRenderRange } from "./utils/isDefaultRenderRange.js";
32
33
  import { formatCSSVariablePrefix } from "./utils/formatCSSVariablePrefix.js";
33
34
  import { getHighlighterThemeStyles } from "./utils/getHighlighterThemeStyles.js";
34
35
  import { processLine } from "./utils/processLine.js";
36
+ import { tokenStyle } from "./utils/tokenStyle.js";
37
+ import { renderTokenLines } from "./utils/renderTokenLines.js";
35
38
  import { renderFileWithHighlighter } from "./utils/renderFileWithHighlighter.js";
36
39
  import { FileRenderer } from "./renderers/FileRenderer.js";
37
40
  import { SVGSpriteSheet } from "./sprite.js";
@@ -86,16 +89,17 @@ import { hasResolvedLanguages } from "./highlighter/languages/hasResolvedLanguag
86
89
  import { registerCustomLanguage } from "./highlighter/languages/registerCustomLanguage.js";
87
90
  import { resolveLanguages } from "./highlighter/languages/resolveLanguages.js";
88
91
  import { attachResolvedThemes } from "./highlighter/themes/attachResolvedThemes.js";
92
+ import { createCSSVariablesTheme } from "./highlighter/themes/createCSSVariablesTheme.js";
89
93
  import { getResolvedOrResolveTheme } from "./highlighter/themes/getResolvedOrResolveTheme.js";
90
94
  import { getResolvedThemes } from "./highlighter/themes/getResolvedThemes.js";
91
95
  import { hasResolvedThemes } from "./highlighter/themes/hasResolvedThemes.js";
92
- import { createCSSVariablesTheme } from "./highlighter/themes/createCSSVariablesTheme.js";
93
96
  import { registerCustomTheme } from "./highlighter/themes/registerCustomTheme.js";
94
97
  import { registerCustomCSSVariableTheme } from "./highlighter/themes/registerCustomCSSVariableTheme.js";
95
98
  import { resolveTheme } from "./highlighter/themes/resolveTheme.js";
96
99
  import { resolveThemes } from "./highlighter/themes/resolveThemes.js";
97
100
  import { isDiffAnnotation, isDiffAnnotationCollection, isFileAnnotation, isFileAnnotationCollection } from "./utils/annotationHelpers.js";
98
101
  import { areWorkerStatsEqual } from "./utils/areWorkerStatsEqual.js";
102
+ import { canUseWASM } from "./utils/canUseWASM.js";
99
103
  import { createRowNodes } from "./utils/createRowNodes.js";
100
104
  import { createStyleElement, createThemeStyleElement } from "./utils/createStyleElement.js";
101
105
  import { diffAcceptRejectHunk } from "./utils/diffAcceptRejectHunk.js";
@@ -104,5 +108,6 @@ import { getLineNodes } from "./utils/getLineNodes.js";
104
108
  import { getSingularPatch } from "./utils/getSingularPatch.js";
105
109
  import { parseLineType } from "./utils/parseLineType.js";
106
110
  import { setLanguageOverride } from "./utils/setLanguageOverride.js";
111
+ import { tokensToHtml } from "./utils/tokensToHtml.js";
107
112
  import { trimPatchContext } from "./utils/trimPatchContext.js";
108
- export { AttachedLanguages, CODE_VIEW_DIFF_OPTION_KEYS, CODE_VIEW_FILE_OPTION_KEYS, CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, CodeToTokenTransformStream, CodeView, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_HIGHLIGHTER, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, DiffHunksRenderer, EMPTY_RENDER_RANGE, EXTENSION_TO_FILE_FORMAT, FILENAME_HEADER_REGEX, FILE_CONTEXT_BLOB, File, FileDiff, FileRenderer, FileStream, GIT_DIFF_FILE_BREAK_REGEX, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, HighlighterDisposedError, INDEX_LINE_METADATA, InteractionManager, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, RegisteredCustomLanguages, ResizeManager, ResolvedLanguages, ResolvingLanguages, SPLIT_WITH_NEWLINES, SVGSpriteSheet, ScrollSyncManager, THEME_CSS_ATTRIBUTE, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE, UnresolvedFile, VIRTUALIZED_FILE_DIFF_LAYOUT_CHECKPOINT_INTERVAL, VirtualizedFile, VirtualizedFileDiff, Virtualizer, areDiffLineAnnotationsEqual, areDiffRenderOptionsEqual, areDiffTargetsEqual, areFileRenderOptionsEqual, areFilesEqual, areHunkDataEqual, areLanguagesAttached, areLineAnnotationsEqual, areObjectsEqual, areOptionsEqual, arePrePropertiesEqual, areRenderRangesEqual, areSelectionsEqual, areThemesAttached, areThemesEqual, areVirtualWindowSpecsEqual, areWorkerStatsEqual, attachResolvedLanguages, attachResolvedThemes, cleanLastNewline, cleanUpResolvedLanguages, cleanUpResolvedThemes, clearRenderQueue, cloneFileDiffMetadata, cloneHunks, createAnnotationElement, createAnnotationWrapperNode, createCSSVariablesTheme, createDiffSpanDecoration, createEmptyRowBuffer, createFileHeaderElement, createGutterGap, createGutterItem, createGutterUtilityContentNode, createGutterUtilityElement, createGutterWrapper, createHastElement, createHighlighter, createIconElement, createNoNewlineElement, createPreElement, createPreWrapperProperties, createRowNodes, createSeparator, createSpanFromToken, createStyleElement, createTextNodeElement, createThemeStyleElement, createUnsafeCSSStyleNode, createWindowFromScrollPosition, dequeueRender, detachString, diffAcceptRejectHunk, disposeHighlighter, findCodeElement, formatCSSVariablePrefix, getCustomExtensionsMap, getCustomExtensionsVersion, getFiletypeFromFileName, getHighlighterIfLoaded, getHighlighterOptions, getHighlighterThemeStyles, getHighlighterType, getHunkSeparatorSlotName, getIconForType, getLineAnnotationName, getLineAnnotationSource, getLineEndingType, getLineNodes, getOrCreateCodeNode, getResolvedLanguages, getResolvedOrResolveLanguage, getResolvedOrResolveTheme, getResolvedThemes, getSharedHighlighter, getSingularPatch, getThemes, getTotalLineCountFromHunks, getUnresolvedDiffHunksRendererOptions, hasResolvedLanguages, hasResolvedThemes, hydratePartialDiff, isDefaultRenderRange, isDiffAnnotation, isDiffAnnotationCollection, isFileAnnotation, isFileAnnotationCollection, isHighlighterLoaded, isHighlighterLoading, isHighlighterNull, isWorkerContext, parseDiffFromFile, parseLineType, parsePatchFiles, patchScrollbarGutterSize, pluckInteractionOptions, prefersReducedMotion, preloadHighlighter, prerenderHTMLIfNecessary, processFile, processLine, processPatch, pushOrJoinSpan, queueRender, recordLineAnnotationSource, registerCustomCSSVariableTheme, registerCustomLanguage, registerCustomTheme, releaseStringDetachBuffer, renderDiffWithHighlighter, renderFileWithHighlighter, replaceCustomExtensions, resolveConflict, resolveLanguage, resolveLanguages, resolveRegion, resolveTheme, resolveThemes, setCustomExtension, setLanguageOverride, setPreNodeProperties, trimPatchContext, wrapCoreCSS, wrapThemeCSS, wrapUnsafeCSS };
113
+ export { AttachedLanguages, CODE_VIEW_DIFF_OPTION_KEYS, CODE_VIEW_FILE_OPTION_KEYS, CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, CodeToTokenTransformStream, CodeView, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_HIGHLIGHTER, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, DiffHunksRenderer, EMPTY_LINE_ANNOTATIONS, EMPTY_RENDER_RANGE, EXTENSION_TO_FILE_FORMAT, FILENAME_HEADER_REGEX, FILE_CONTEXT_BLOB, File, FileDiff, FileRenderer, FileStream, GIT_DIFF_FILE_BREAK_REGEX, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, HighlighterDisposedError, INDEX_LINE_METADATA, InteractionManager, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, RegisteredCustomLanguages, ResizeManager, ResolvedLanguages, ResolvingLanguages, SPLIT_WITH_NEWLINES, SVGSpriteSheet, ScrollSyncManager, THEME_CSS_ATTRIBUTE, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE, UnresolvedFile, VIRTUALIZED_FILE_DIFF_LAYOUT_CHECKPOINT_INTERVAL, VirtualizedFile, VirtualizedFileDiff, Virtualizer, areDiffLineAnnotationsEqual, areDiffRenderOptionsEqual, areDiffTargetsEqual, areFileRenderOptionsEqual, areFilesEqual, areHunkDataEqual, areLanguagesAttached, areLineAnnotationsEqual, areObjectsEqual, areOptionsEqual, arePrePropertiesEqual, areRenderRangesEqual, areSelectionsEqual, areThemesAttached, areThemesEqual, areVirtualWindowSpecsEqual, areWorkerStatsEqual, attachResolvedLanguages, attachResolvedThemes, canUseWASM, cleanLastNewline, cleanUpResolvedLanguages, cleanUpResolvedThemes, clearRenderQueue, cloneFileDiffMetadata, cloneHunks, createAnnotationElement, createAnnotationWrapperNode, createCSSVariablesTheme, createDiffSpanDecoration, createEmptyRowBuffer, createFileHeaderElement, createGutterGap, createGutterItem, createGutterUtilityContentNode, createGutterUtilityElement, createGutterWrapper, createHastElement, createHighlighter, createIconElement, createNoNewlineElement, createPreElement, createPreWrapperProperties, createRowNodes, createSeparator, createSpanFromToken, createStyleElement, createTextNodeElement, createThemeStyleElement, createUnsafeCSSStyleNode, createWindowFromScrollPosition, dequeueRender, detachString, diffAcceptRejectHunk, disposeHighlighter, findCodeElement, formatCSSVariablePrefix, getCustomExtensionsMap, getCustomExtensionsVersion, getFiletypeFromFileName, getHighlighterIfLoaded, getHighlighterOptions, getHighlighterThemeStyles, getHighlighterType, getHunkSeparatorSlotName, getIconForType, getLineAnnotationName, getLineAnnotationSource, getLineEndingType, getLineNodes, getOrCreateCodeNode, getResolvedLanguages, getResolvedOrResolveLanguage, getResolvedOrResolveTheme, getResolvedThemes, getSharedHighlighter, getSingularPatch, getThemes, getTotalLineCountFromHunks, getUnresolvedDiffHunksRendererOptions, hasResolvedLanguages, hasResolvedThemes, hastToHtml, hydratePartialDiff, isDefaultRenderRange, isDiffAnnotation, isDiffAnnotationCollection, isFileAnnotation, isFileAnnotationCollection, isHighlighterLoaded, isHighlighterLoading, isHighlighterNull, isWorkerContext, parseDiffFromFile, parseLineType, parsePatchFiles, patchScrollbarGutterSize, pluckInteractionOptions, prefersReducedMotion, preloadHighlighter, prerenderHTMLIfNecessary, processFile, processLine, processPatch, pushOrJoinSpan, queueRender, recordLineAnnotationSource, registerCustomCSSVariableTheme, registerCustomLanguage, registerCustomTheme, releaseStringDetachBuffer, renderDiffWithHighlighter, renderFileWithHighlighter, renderTokenLines, replaceCustomExtensions, resolveConflict, resolveLanguage, resolveLanguages, resolveRegion, resolveTheme, resolveThemes, setCustomExtension, setLanguageOverride, setPreNodeProperties, tokenStyle, tokensToHtml, trimPatchContext, wrapCoreCSS, wrapThemeCSS, wrapUnsafeCSS };
@@ -1,4 +1,4 @@
1
- import { CodeViewItem, CodeViewScrollTarget, DiffLineAnnotation, LineAnnotation } from "../types.js";
1
+ import { CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewScrollTarget, DiffLineAnnotation, FileContents, FileDiffMetadata, LineAnnotation } from "../types.js";
2
2
  import { EditorChangeEvent, EditorType } from "../editor/types.js";
3
3
  import { GetHoveredLineResult } from "../managers/InteractionManager.js";
4
4
  import { Editor, EditorOptions } from "../editor/editor.js";
@@ -8,6 +8,7 @@ import "../index.js";
8
8
  import { CSSProperties, ReactNode, Ref } from "react";
9
9
  //#region src/react/CodeView.d.ts
10
10
  type CodeViewGutterUtilityGetter = (() => GetHoveredLineResult<'file'> | undefined) | (() => GetHoveredLineResult<'diff'> | undefined);
11
+ type CodeViewAnnotationArgs<LAnnotation> = [annotation: LineAnnotation<LAnnotation>, file: FileContents, item: CodeViewFileItem<LAnnotation>] | [annotation: DiffLineAnnotation<LAnnotation>, fileDiff: FileDiffMetadata, item: CodeViewDiffItem<LAnnotation>];
11
12
  type CodeViewReactOptions<LAnnotation, Caret> = Omit<CodeViewOptions<LAnnotation, Caret>, 'controlledSelection' | 'createEditor' | 'onSelectedLinesChange'>;
12
13
  interface CodeViewBaseProps<LAnnotation, Caret> {
13
14
  options?: CodeViewReactOptions<LAnnotation, Caret>;
@@ -60,7 +61,7 @@ interface CodeViewBaseProps<LAnnotation, Caret> {
60
61
  renderHeaderPrefix?(item: CodeViewItem<LAnnotation>): ReactNode;
61
62
  renderHeaderFilenameSuffix?(item: CodeViewItem<LAnnotation>): ReactNode;
62
63
  renderHeaderMetadata?(item: CodeViewItem<LAnnotation>): ReactNode;
63
- renderAnnotation?(annotation: LineAnnotation<LAnnotation> | DiffLineAnnotation<LAnnotation>, item: CodeViewItem<LAnnotation>): ReactNode;
64
+ renderAnnotation?(...args: CodeViewAnnotationArgs<LAnnotation>): ReactNode;
64
65
  renderGutterUtility?(getHoveredLine: CodeViewGutterUtilityGetter, item: CodeViewItem<LAnnotation>): ReactNode;
65
66
  }
66
67
  interface ControlledCodeViewProps<LAnnotation, Caret> extends CodeViewBaseProps<LAnnotation, Caret> {
@@ -90,5 +91,5 @@ type CodeViewComponent = <LAnnotation = undefined, Caret = undefined>(props: Cod
90
91
  }) => React.JSX.Element;
91
92
  declare const CodeView: CodeViewComponent;
92
93
  //#endregion
93
- export { CodeView, CodeViewHandle, type CodeViewItemEditCompleteHandler, CodeViewProps, CodeViewReactOptions, ControlledCodeViewProps, UncontrolledCodeViewProps };
94
+ export { CodeView, CodeViewAnnotationArgs, CodeViewHandle, type CodeViewItemEditCompleteHandler, CodeViewProps, CodeViewReactOptions, ControlledCodeViewProps, UncontrolledCodeViewProps };
94
95
  //# sourceMappingURL=CodeView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeView.d.ts","names":[],"sources":["../../src/react/CodeView.tsx"],"mappings":";;;;;;;;;KAyDK,qCACM,mDACA;KAEC,qBAAqB,aAAa,SAAS,KACrD,gBAAgB,aAAa;UAIrB,kBAAkB,aAAa;EACvC,UAAU,qBAAqB,aAAa;;;;;EAK5C,gBAAgB,KACd,cAAc,YAAY,aAAa;;EAIzC,iBAAiB,MAAM,aAAa;EACpC;EACA,QAAQ;;;;;;;;EAQR,eAAe,IAAI;EACnB;EACA,gBAAgB;EAChB,uBAAuB,WAAW;EAClC,UAAU,mBAAmB,QAAQ,WAAc,aAAa;;;EAGhE,yBAAyB;;;EAGzB,yBAAyB;;;;;;EAMzB,kBACE,OAAO,kBAAkB,YAAY,aAAa,QAClD,MAAM,aAAa;;;;;;;;;;;;EAarB,qBAAqB,gCAAgC,aAAa;EAClE,oBAAoB,MAAM,aAAa,eAAe;EACtD,oBAAoB,MAAM,aAAa,eAAe;EACtD,4BAA4B,MAAM,aAAa,eAAe;EAC9D,sBAAsB,MAAM,aAAa,eAAe;EACxD,kBACE,YAAY,eAAe,eAAe,mBAAmB,cAC7D,MAAM,aAAa,eAClB;EACH,qBACE,gBAAgB,6BAChB,MAAM,aAAa,eAClB;;UAGY,wBACf,aACA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M,aAAa,eAAe;EACtD,oBAAoB,MAAM,aAAa,eAAe;EACtD,4BAA4B,MAAM,aAAa,eAAe;EAC9D,sBAAsB,MAAM,aAAa,eAAe;EACxD,qBAAqB,MAAM,uBAAuB,eAAe;EACjE,qBACE,gBAAgB,6BAChB,MAAM,aAAa,eAClB;;UAGY,wBACf,aACA,eACQ,kBAAkB,aAAa;EACvC,gBAAgB,aAAa;EAC7B;;UAGe,0BACf,aACA,eACQ,kBAAkB,aAAa;EAGvC,wBAAwB,aAAa;EACrC;;KAGU,cAAc,aAAa,SACnC,wBAAwB,aAAa,SACrC,0BAA0B,aAAa;UAE1B,eAAe,aAAa;EAC3C,SAAS,gBAAgB,aAAa;EACtC,QAAQ,aAAa,aAAa;EAClC,WAAW;EACX,WAAW,MAAM,aAAa;EAC9B,aAAa,eAAe;EAC5B,SAAS,QAAQ;EACjB,iBAAiB,WAAW;EAC5B,oBAAoB;EACpB;EACA,UACE,aAEE,eAAe,aAAa,SAC5B,oBAAoB,aAAa;EAErC,eAAe,WAAc,aAAa;;KAGvC,qBAAqB,yBAAyB,mBACjD,OAAO,cAAc,aAAa;EAChC,MAAM,MAAM,IAAI,eAAe,aAAa;MAE3C,MAAM,IAAI;cA2eF,UAAwC"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { areManagedSnapshotsEqual } from "../utils/areManagedSnapshotsEqual.js";
3
2
  import { areOptionsEqual } from "../utils/areOptionsEqual.js";
3
+ import { getCodeViewItemRenderData } from "../utils/getCodeViewItemRenderData.js";
4
4
  import { CodeView as CodeView$1 } from "../components/CodeView.js";
5
5
  import { useStableCallback } from "./utils/useStableCallback.js";
6
6
  import { useCreateEditor } from "./EditContext.js";
@@ -9,8 +9,8 @@ import { renderDiffChildren } from "./utils/renderDiffChildren.js";
9
9
  import { renderFileChildren } from "./utils/renderFileChildren.js";
10
10
  import { WorkerPoolContext } from "./WorkerPoolContext.js";
11
11
  import { forwardRef, memo, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
12
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
12
  import { createPortal, flushSync } from "react-dom";
13
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
14
14
  //#region src/react/CodeView.tsx
15
15
  const useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
16
16
  function createDefaultCache(controlled) {
@@ -290,7 +290,7 @@ function createSlotContentStore() {
290
290
  return snapshot;
291
291
  },
292
292
  publish(nextSnapshot) {
293
- if (areManagedSnapshotsEqual(snapshot, nextSnapshot)) return;
293
+ if (snapshot === nextSnapshot) return;
294
294
  snapshot = nextSnapshot;
295
295
  for (const listener of listeners) listener();
296
296
  },
@@ -323,17 +323,29 @@ const SlotPortals = memo(function SlotPortals({ managedContentStore, renderCusto
323
323
  const subscribe = useStableCallback((listener) => managedContentStore.subscribe(listener));
324
324
  const getSnapshot = useStableCallback(() => managedContentStore.getSnapshot());
325
325
  const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
326
- let itemKeys = "";
327
- for (const item of snapshot?.items ?? []) itemKeys += `${item.id}:${item.version}:${item.type}`;
328
326
  const renderedItems = useMemo(() => {
329
- return snapshot?.items?.map((renderedItem) => createPortal(renderCodeViewItemChildren({
330
- renderedItem,
327
+ const renderers = {
331
328
  renderCustomHeader,
332
329
  renderHeaderPrefix,
333
330
  renderHeaderFilenameSuffix,
334
331
  renderHeaderMetadata,
335
332
  renderAnnotation,
336
333
  renderGutterUtility
334
+ };
335
+ return snapshot?.items?.map((renderedItem) => createPortal(renderedItem.type === "diff" ? /* @__PURE__ */ jsx(DiffItemSlots, {
336
+ version: renderedItem.version ?? 0,
337
+ item: renderedItem.item,
338
+ getHoveredLine: renderedItem.instance.getHoveredLine,
339
+ getAnnotationSlotName: renderedItem.instance.getAnnotationSlotName,
340
+ ...getCodeViewItemRenderData(renderedItem),
341
+ ...renderers
342
+ }) : /* @__PURE__ */ jsx(FileItemSlots, {
343
+ version: renderedItem.version ?? 0,
344
+ item: renderedItem.item,
345
+ getHoveredLine: renderedItem.instance.getHoveredLine,
346
+ getAnnotationSlotName: renderedItem.instance.getAnnotationSlotName,
347
+ ...getCodeViewItemRenderData(renderedItem),
348
+ ...renderers
337
349
  }), renderedItem.element, renderedItem.id));
338
350
  }, [
339
351
  renderCustomHeader,
@@ -342,7 +354,7 @@ const SlotPortals = memo(function SlotPortals({ managedContentStore, renderCusto
342
354
  renderHeaderMetadata,
343
355
  renderAnnotation,
344
356
  renderGutterUtility,
345
- itemKeys
357
+ snapshot?.items
346
358
  ]);
347
359
  const renderedHeader = useMemo(() => {
348
360
  return renderCodeViewHeader != null && snapshot?.header != null ? createPortal(renderCodeViewHeader(), snapshot.header) : null;
@@ -356,37 +368,34 @@ const SlotPortals = memo(function SlotPortals({ managedContentStore, renderCusto
356
368
  renderedFooter
357
369
  ] });
358
370
  });
359
- function renderCodeViewItemChildren({ renderedItem, renderCustomHeader, renderHeaderPrefix, renderHeaderFilenameSuffix, renderHeaderMetadata, renderAnnotation, renderGutterUtility }) {
360
- if (renderedItem.type === "diff") {
361
- const { item, instance } = renderedItem;
362
- return renderDiffChildren({
363
- fileDiff: item.fileDiff,
364
- renderCustomHeader: renderCustomHeader != null ? () => renderCustomHeader(item) : void 0,
365
- renderHeaderPrefix: renderHeaderPrefix != null ? () => renderHeaderPrefix(item) : void 0,
366
- renderHeaderFilenameSuffix: renderHeaderFilenameSuffix != null ? () => renderHeaderFilenameSuffix(item) : void 0,
367
- renderHeaderMetadata: renderHeaderMetadata != null ? () => renderHeaderMetadata(item) : void 0,
368
- renderAnnotation: renderAnnotation != null ? (annotation) => renderAnnotation(annotation, item) : void 0,
369
- lineAnnotations: item.annotations,
370
- renderGutterUtility: renderGutterUtility != null ? (getHoveredLine) => renderGutterUtility(getHoveredLine, item) : void 0,
371
- getHoveredLine: instance.getHoveredLine,
372
- getAnnotationSlotName: instance.getAnnotationSlotName
373
- });
374
- } else {
375
- const { item, instance } = renderedItem;
376
- return renderFileChildren({
377
- file: item.file,
378
- renderCustomHeader: renderCustomHeader != null ? () => renderCustomHeader(item) : void 0,
379
- renderHeaderPrefix: renderHeaderPrefix != null ? () => renderHeaderPrefix(item) : void 0,
380
- renderHeaderFilenameSuffix: renderHeaderFilenameSuffix != null ? () => renderHeaderFilenameSuffix(item) : void 0,
381
- renderHeaderMetadata: renderHeaderMetadata != null ? () => renderHeaderMetadata(item) : void 0,
382
- renderAnnotation: renderAnnotation != null ? (annotation) => renderAnnotation(annotation, item) : void 0,
383
- lineAnnotations: item.annotations,
384
- renderGutterUtility: renderGutterUtility != null ? (getHoveredLine) => renderGutterUtility(getHoveredLine, item) : void 0,
385
- getHoveredLine: instance.getHoveredLine,
386
- getAnnotationSlotName: instance.getAnnotationSlotName
387
- });
388
- }
389
- }
371
+ const DiffItemSlots = memo(function DiffItemSlots({ item, fileDiff, lineAnnotations, getHoveredLine, getAnnotationSlotName, renderCustomHeader, renderHeaderPrefix, renderHeaderFilenameSuffix, renderHeaderMetadata, renderAnnotation, renderGutterUtility }) {
372
+ return renderDiffChildren({
373
+ fileDiff,
374
+ renderCustomHeader: renderCustomHeader != null ? () => renderCustomHeader(item) : void 0,
375
+ renderHeaderPrefix: renderHeaderPrefix != null ? () => renderHeaderPrefix(item) : void 0,
376
+ renderHeaderFilenameSuffix: renderHeaderFilenameSuffix != null ? () => renderHeaderFilenameSuffix(item) : void 0,
377
+ renderHeaderMetadata: renderHeaderMetadata != null ? () => renderHeaderMetadata(item) : void 0,
378
+ renderAnnotation: renderAnnotation != null ? (annotation, fileDiff) => renderAnnotation(annotation, fileDiff, item) : void 0,
379
+ lineAnnotations,
380
+ renderGutterUtility: renderGutterUtility != null ? (getHoveredLine) => renderGutterUtility(getHoveredLine, item) : void 0,
381
+ getHoveredLine,
382
+ getAnnotationSlotName
383
+ });
384
+ });
385
+ const FileItemSlots = memo(function FileItemSlots({ item, file, lineAnnotations, getHoveredLine, getAnnotationSlotName, renderCustomHeader, renderHeaderPrefix, renderHeaderFilenameSuffix, renderHeaderMetadata, renderAnnotation, renderGutterUtility }) {
386
+ return renderFileChildren({
387
+ file,
388
+ renderCustomHeader: renderCustomHeader != null ? () => renderCustomHeader(item) : void 0,
389
+ renderHeaderPrefix: renderHeaderPrefix != null ? () => renderHeaderPrefix(item) : void 0,
390
+ renderHeaderFilenameSuffix: renderHeaderFilenameSuffix != null ? () => renderHeaderFilenameSuffix(item) : void 0,
391
+ renderHeaderMetadata: renderHeaderMetadata != null ? () => renderHeaderMetadata(item) : void 0,
392
+ renderAnnotation: renderAnnotation != null ? (annotation, file) => renderAnnotation(annotation, file, item) : void 0,
393
+ lineAnnotations,
394
+ renderGutterUtility: renderGutterUtility != null ? (getHoveredLine) => renderGutterUtility(getHoveredLine, item) : void 0,
395
+ getHoveredLine,
396
+ getAnnotationSlotName
397
+ });
398
+ });
390
399
  function noopRender() {}
391
400
  //#endregion
392
401
  export { CodeView };
@@ -1 +1 @@
1
- {"version":3,"file":"CodeView.js","names":["CodeViewClass"],"sources":["../../src/react/CodeView.tsx"],"sourcesContent":["'use client';\n\nimport {\n type CSSProperties,\n forwardRef,\n memo,\n type ReactNode,\n type Ref,\n useContext,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport { createPortal, flushSync } from 'react-dom';\n\nimport type {\n Editor,\n EditorChangeEvent,\n EditorOptions,\n EditorType,\n} from '../edit';\nimport {\n areOptionsEqual,\n CodeView as CodeViewClass,\n type CodeViewCoordinator,\n type CodeViewCreateEditorOptions,\n type CodeViewItem,\n type CodeViewItemEditCompleteEventMap,\n type CodeViewItemEditCompleteHandler,\n type CodeViewLineSelection,\n type CodeViewMode,\n type CodeViewModeItemMap,\n type CodeViewOptions,\n type CodeViewRenderedItem,\n type CodeViewScrollTarget,\n type CodeViewSlotSnapshot,\n type DiffLineAnnotation,\n type GetHoveredLineResult,\n type LineAnnotation,\n} from '../index';\nimport { areManagedSnapshotsEqual } from '../utils/areManagedSnapshotsEqual';\nimport { useCreateEditor } from './EditContext';\nimport { assignRef } from './utils/assignRef';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { renderFileChildren } from './utils/renderFileChildren';\nimport { useStableCallback } from './utils/useStableCallback';\nimport { WorkerPoolContext } from './WorkerPoolContext';\n\nexport type { CodeViewItemEditCompleteHandler };\n\nconst useIsomorphicLayoutEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ntype CodeViewGutterUtilityGetter =\n | (() => GetHoveredLineResult<'file'> | undefined)\n | (() => GetHoveredLineResult<'diff'> | undefined);\n\nexport type CodeViewReactOptions<LAnnotation, Caret> = Omit<\n CodeViewOptions<LAnnotation, Caret>,\n 'controlledSelection' | 'createEditor' | 'onSelectedLinesChange'\n>;\n\ninterface CodeViewBaseProps<LAnnotation, Caret> {\n options?: CodeViewReactOptions<LAnnotation, Caret>;\n /**\n * Creation-time options passed to the nearest EditProvider factory.\n * CodeView supplies its item-specific change callback.\n */\n editorOptions?: Omit<\n EditorOptions<EditorType, LAnnotation, Caret>,\n 'onChange'\n >;\n /** Resolve an in-memory retention key for an item's draft and undo history. */\n getEditStateKey?(item: CodeViewItem<LAnnotation>): string | undefined;\n className?: string;\n style?: CSSProperties;\n /**\n * Ref to the scroll container element. A callback ref follows the React 18\n * protocol: it is called with the element on mount and with `null` on\n * unmount. A cleanup function returned from the callback (the React 19\n * form) is ignored, so release resources on the `null` call or use a ref\n * object.\n */\n containerRef?: Ref<HTMLDivElement>;\n disableWorkerPool?: boolean;\n selectedLines?: CodeViewLineSelection | null;\n onSelectedLinesChange?(selection: CodeViewLineSelection | null): void;\n onScroll?(scrollTop: number, viewer: CodeViewClass<LAnnotation, Caret>): void;\n /** Render a non-virtualized node at the very start of the scroll content,\n * before the first item. Always rendered; scrolls with the content. */\n renderCodeViewHeader?(): ReactNode;\n /** Render a non-virtualized node at the very end of the scroll content, after\n * the last item. Always rendered; scrolls with the content. */\n renderCodeViewFooter?(): ReactNode;\n /**\n * Called with the editor's `EditorChangeEvent` and the owning item on every\n * document change. Do not feed it directly back into the controlled item,\n * which can create update loops.\n */\n onItemEditChange?(\n event: EditorChangeEvent<EditorType, LAnnotation, Caret>,\n item: CodeViewItem<LAnnotation>\n ): void;\n /**\n * Called once when an edit session ends: edit turned off, the item removed,\n * or the CodeView unmounted (where the result is not installed). Collapse\n * suspends the session instead of completing it. `nextItem` is the accepted\n * replacement CodeView built from `item`: the event's completed\n * `file`/`fileDiff` and annotations, `edit: false`, and a bumped `version`.\n * Return `'accept'` to install the edit — CodeView applies `nextItem` through\n * the item update path when the item still exists, and a controlled owner\n * puts the same `nextItem` into its state — or `'reject'` to revert. The event\n * is frozen; re-key the accepted value in place before accepting.\n */\n onItemEditComplete?: CodeViewItemEditCompleteHandler<LAnnotation, Caret>;\n renderCustomHeader?(item: CodeViewItem<LAnnotation>): ReactNode;\n renderHeaderPrefix?(item: CodeViewItem<LAnnotation>): ReactNode;\n renderHeaderFilenameSuffix?(item: CodeViewItem<LAnnotation>): ReactNode;\n renderHeaderMetadata?(item: CodeViewItem<LAnnotation>): ReactNode;\n renderAnnotation?(\n annotation: LineAnnotation<LAnnotation> | DiffLineAnnotation<LAnnotation>,\n item: CodeViewItem<LAnnotation>\n ): ReactNode;\n renderGutterUtility?(\n getHoveredLine: CodeViewGutterUtilityGetter,\n item: CodeViewItem<LAnnotation>\n ): ReactNode;\n}\n\nexport interface ControlledCodeViewProps<\n LAnnotation,\n Caret,\n> extends CodeViewBaseProps<LAnnotation, Caret> {\n items: readonly CodeViewItem<LAnnotation>[];\n initialItems?: never;\n}\n\nexport interface UncontrolledCodeViewProps<\n LAnnotation,\n Caret,\n> extends CodeViewBaseProps<LAnnotation, Caret> {\n // Seeds the imperative CodeView instance once. Later item changes should go\n // through the ref API instead of being reconciled from React props.\n initialItems?: readonly CodeViewItem<LAnnotation>[];\n items?: never;\n}\n\nexport type CodeViewProps<LAnnotation, Caret> =\n | ControlledCodeViewProps<LAnnotation, Caret>\n | UncontrolledCodeViewProps<LAnnotation, Caret>;\n\nexport interface CodeViewHandle<LAnnotation, Caret> {\n addItems(items: readonly CodeViewItem<LAnnotation>[]): void;\n getItem(id: string): CodeViewItem<LAnnotation> | undefined;\n removeItem(id: string): boolean;\n updateItem(item: CodeViewItem<LAnnotation>): boolean;\n updateItemId(oldId: string, newId: string): boolean;\n scrollTo(target: CodeViewScrollTarget): void;\n setSelectedLines(selection: CodeViewLineSelection | null): void;\n getSelectedLines(): CodeViewLineSelection | null;\n clearSelectedLines(): void;\n getEditor(\n id: string\n ):\n | Editor<'file', LAnnotation, Caret>\n | Editor<'file-diff', LAnnotation, Caret>\n | undefined;\n getInstance(): CodeViewClass<LAnnotation, Caret> | undefined;\n}\n\ntype CodeViewComponent = <LAnnotation = undefined, Caret = undefined>(\n props: CodeViewProps<LAnnotation, Caret> & {\n ref?: React.Ref<CodeViewHandle<LAnnotation, Caret>>;\n }\n) => React.JSX.Element;\n\ntype SlotPortalsComponent = <LAnnotation, Caret>(\n props: SlotPortalsProps<LAnnotation, Caret>\n) => React.JSX.Element;\n\ninterface ManagedContentStore<LAnnotation, Caret> {\n getSnapshot(): CodeViewSlotSnapshot<LAnnotation, Caret> | undefined;\n publish(snapshot: CodeViewSlotSnapshot<LAnnotation, Caret> | undefined): void;\n subscribe(listener: () => void): () => void;\n}\n\ninterface CachedDataRef<LAnnotation, Caret> {\n instance: CodeViewClass<LAnnotation, Caret> | undefined;\n items: readonly CodeViewItem<LAnnotation>[] | undefined;\n controlled: boolean;\n managedOptions: CodeViewOptions<LAnnotation, Caret> | undefined;\n disableFlushSync: boolean;\n slotCoordinator: CodeViewCoordinator<LAnnotation, Caret> | undefined;\n}\n\nfunction createDefaultCache<LAnnotation, Caret>(\n controlled: boolean\n): CachedDataRef<LAnnotation, Caret> {\n return {\n instance: undefined,\n items: undefined,\n controlled,\n managedOptions: undefined,\n disableFlushSync: false,\n slotCoordinator: undefined,\n };\n}\n\nfunction CodeViewInner<LAnnotation = undefined, Caret = undefined>(\n props: CodeViewProps<LAnnotation, Caret>,\n ref: React.ForwardedRef<CodeViewHandle<LAnnotation, Caret>>\n): React.JSX.Element {\n const {\n className,\n containerRef,\n disableWorkerPool = false,\n editorOptions,\n getEditStateKey,\n initialItems,\n items: controlledItems,\n onItemEditChange,\n onItemEditComplete,\n onScroll,\n onSelectedLinesChange,\n options,\n renderAnnotation,\n renderCodeViewFooter,\n renderCodeViewHeader,\n renderCustomHeader,\n renderGutterUtility,\n renderHeaderFilenameSuffix,\n renderHeaderMetadata,\n renderHeaderPrefix,\n selectedLines,\n style,\n } = props;\n const controlled = controlledItems !== undefined;\n const contextCreateEditor = useCreateEditor<LAnnotation, Caret>();\n const poolManager = useContext(WorkerPoolContext);\n const cachedDataRef = useRef<CachedDataRef<LAnnotation, Caret>>(\n createDefaultCache<LAnnotation, Caret>(controlled)\n );\n const hasCustomHeader = renderCustomHeader != null;\n const hasAnnotationRenderer = renderAnnotation != null;\n const hasGutterRenderer = renderGutterUtility != null;\n const hasHeaderRenderers =\n hasCustomHeader ||\n renderHeaderPrefix != null ||\n renderHeaderFilenameSuffix != null ||\n renderHeaderMetadata != null;\n const hasRenderers =\n hasHeaderRenderers || hasAnnotationRenderer || hasGutterRenderer;\n const hasCodeViewHeader = renderCodeViewHeader != null;\n const hasCodeViewFooter = renderCodeViewFooter != null;\n const emitSelectedLinesChange = useStableCallback(\n (selection: CodeViewLineSelection | null) => {\n onSelectedLinesChange?.(selection);\n }\n );\n const controlledSelection = selectedLines !== undefined;\n\n // Keep the adapter stable so provider and editor-option changes affect the\n // next item edit session without forcing CodeView to reconcile active editors.\n const createEditor = useStableCallback(\n <EType extends EditorType>(\n editorType: EType,\n options: CodeViewCreateEditorOptions<EType, LAnnotation, Caret>,\n editStateKey?: string\n ): Editor<EType, LAnnotation, Caret> => {\n if (contextCreateEditor == null) {\n throw new Error('CodeView: EditContext is not attached');\n }\n\n const resolvedOptions = {\n ...editorOptions,\n ...options,\n } as EditorOptions<EType, LAnnotation, Caret>;\n const editor = contextCreateEditor(\n editorType,\n resolvedOptions,\n editStateKey\n );\n return editor;\n }\n );\n const emitItemEditChange = useStableCallback(\n (\n event: EditorChangeEvent<EditorType, LAnnotation, Caret>,\n item: CodeViewItem<LAnnotation>\n ) => {\n onItemEditChange?.(event, item);\n }\n );\n const emitItemEditComplete = useStableCallback(\n <TMode extends CodeViewMode>(\n event: CodeViewItemEditCompleteEventMap<LAnnotation, Caret>[TMode],\n item: CodeViewModeItemMap<LAnnotation>[TMode],\n nextItem: CodeViewModeItemMap<LAnnotation>[TMode]\n ) => onItemEditComplete?.(event, item, nextItem) ?? 'reject'\n );\n\n const managedOptions = useMemo(\n () =>\n createManagedCodeViewOptions({\n options,\n hasCustomHeader,\n hasGutterRenderer,\n hasCodeViewHeader,\n hasCodeViewFooter,\n onSelectedLinesChange:\n onSelectedLinesChange != null ? emitSelectedLinesChange : undefined,\n controlledSelection,\n getEditStateKey,\n createEditor: contextCreateEditor != null ? createEditor : undefined,\n onItemEditChange:\n onItemEditChange != null ? emitItemEditChange : undefined,\n onItemEditComplete:\n onItemEditComplete != null ? emitItemEditComplete : undefined,\n }),\n [\n contextCreateEditor,\n controlledSelection,\n createEditor,\n emitItemEditChange,\n emitItemEditComplete,\n emitSelectedLinesChange,\n hasCodeViewFooter,\n hasCodeViewHeader,\n hasCustomHeader,\n hasGutterRenderer,\n getEditStateKey,\n onItemEditChange,\n onItemEditComplete,\n onSelectedLinesChange,\n options,\n ]\n );\n\n const [slotContentStore] = useState<ManagedContentStore<LAnnotation, Caret>>(\n () => createSlotContentStore()\n );\n const [, forceUpdate] = useState<unknown>({});\n\n const nodeRef = useStableCallback((node: HTMLDivElement | null) => {\n // If we have a pre-existing instance and there's no node or the node being\n // passed in is NOT the same as before, then we need to clean up and\n // garbage collect the old instance\n if (\n cachedDataRef.current.instance != null &&\n (node == null ||\n node !== cachedDataRef.current.instance.getContainerElement())\n ) {\n cachedDataRef.current.instance.cleanUp();\n slotContentStore.publish(undefined);\n cachedDataRef.current = createDefaultCache<LAnnotation, Caret>(\n controlled\n );\n }\n\n // If our node matches the existing node then we should not attempt to\n // setup. This is a case that should never be possible to hit, but just in\n // case, lets make sure we don't re-setup an instance that is already setup\n // properly\n if (\n node != null &&\n node !== cachedDataRef.current.instance?.getContainerElement()\n ) {\n cachedDataRef.current.instance = new CodeViewClass<LAnnotation, Caret>(\n managedOptions,\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n cachedDataRef.current.instance.setup(node);\n }\n\n assignRef(containerRef, node);\n });\n\n const onSnapshotChange = useStableCallback(\n (snapshot: CodeViewSlotSnapshot<LAnnotation, Caret> | undefined) => {\n if (cachedDataRef.current.disableFlushSync) {\n slotContentStore.publish(snapshot);\n } else {\n flushSync(() => {\n slotContentStore.publish(snapshot);\n });\n }\n }\n );\n\n const slotCoordinator: CodeViewCoordinator<LAnnotation, Caret> | undefined =\n useMemo(() => {\n // A coordinator is needed whenever React portals anything — per-item\n // slots and codeview header and footer\n if (\n !hasHeaderRenderers &&\n !hasAnnotationRenderer &&\n !hasGutterRenderer &&\n !hasCodeViewHeader &&\n !hasCodeViewFooter\n ) {\n return undefined;\n } else {\n return {\n hasHeaderRenderers,\n hasAnnotationRenderer,\n hasGutterRenderer,\n onSnapshotChange,\n };\n }\n }, [\n onSnapshotChange,\n hasAnnotationRenderer,\n hasGutterRenderer,\n hasHeaderRenderers,\n hasCodeViewHeader,\n hasCodeViewFooter,\n ]);\n\n useIsomorphicLayoutEffect(() => {\n return onScroll != null\n ? cachedDataRef.current.instance?.subscribeToScroll(onScroll)\n : undefined;\n });\n\n useIsomorphicLayoutEffect(() => {\n const {\n instance,\n controlled: prevControlled,\n items: prevItems,\n managedOptions: prevManagedOptions,\n slotCoordinator: prevSlotCoordinator,\n } = cachedDataRef.current;\n if (instance == null) {\n return;\n }\n\n try {\n cachedDataRef.current.disableFlushSync = true;\n let shouldRender = false;\n\n if (!areOptionsEqual(managedOptions, prevManagedOptions)) {\n cachedDataRef.current.managedOptions = managedOptions;\n instance.setOptions(managedOptions);\n shouldRender = true;\n }\n\n if (prevControlled !== controlled) {\n console.error(\n 'CodeView: cannot switch between controlled and uncontrolled modes. Remount with a new key instead.'\n );\n return;\n }\n\n if (controlled) {\n if (controlledItems !== prevItems) {\n if (areItemListsEqual(prevItems, controlledItems)) {\n cachedDataRef.current.items = controlledItems;\n } else if (isAppendOnlyItemUpdate(prevItems, controlledItems)) {\n cachedDataRef.current.items = controlledItems;\n instance.addItems(controlledItems.slice(prevItems.length));\n } else {\n cachedDataRef.current.items = controlledItems;\n instance.setItems(controlledItems);\n shouldRender = true;\n }\n }\n }\n // If uncontrolled, we should only ever set items once, and just depend\n // on imperative instance changes going forward\n else if (prevItems == null) {\n const seedItems = initialItems ?? [];\n cachedDataRef.current.items = seedItems;\n if (seedItems.length > 0) {\n instance.setItems(seedItems);\n shouldRender = true;\n }\n }\n\n if (selectedLines !== undefined) {\n instance.setSelectedLines(selectedLines, { notify: false });\n }\n\n const slotPublish = instance.setSlotCoordinator(slotCoordinator);\n let forceInlinePublish = false;\n if (slotCoordinator !== prevSlotCoordinator) {\n if (slotCoordinator == null || prevSlotCoordinator == null) {\n forceInlinePublish = true;\n }\n cachedDataRef.current.slotCoordinator = slotCoordinator;\n }\n\n if (shouldRender || slotPublish) {\n instance.render(true);\n }\n\n // FIXME(amadeus): This feels kinda bad and flakey with regards to how\n // other things are working... it makes me think that we should\n // re-architect the slotCoordinator a bit, and maybe DON'T make it an\n // undefineable thing...\n if (slotPublish && slotCoordinator == null) {\n slotContentStore.publish(undefined);\n }\n\n if (forceInlinePublish) {\n forceUpdate({});\n }\n } finally {\n cachedDataRef.current.disableFlushSync = false;\n }\n });\n\n // Setup the ref handler\n useImperativeHandle(\n ref,\n (): CodeViewHandle<LAnnotation, Caret> => ({\n addItems(items) {\n const { controlled, instance } = cachedDataRef.current;\n assertUncontrolledCodeViewAction(controlled, 'addItems');\n if (instance == null) {\n console.error(\n 'CodeView.addItems: no valid instance to append items with',\n items\n );\n } else {\n instance.addItems(items);\n }\n },\n getItem(id) {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error('CodeView.getItem: no valid instance exists', id);\n return undefined;\n } else {\n return instance.getItem(id);\n }\n },\n removeItem(id) {\n const { controlled, instance } = cachedDataRef.current;\n assertUncontrolledCodeViewAction(controlled, 'removeItem');\n if (instance == null) {\n console.error(\n 'CodeView.removeItem: no valid instance to remove item from',\n id\n );\n return false;\n }\n\n return instance.removeItem(id);\n },\n updateItem(item) {\n const { controlled, instance } = cachedDataRef.current;\n assertUncontrolledCodeViewAction(controlled, 'updateItem');\n if (instance == null) {\n console.error(\n 'CodeView.updateItem: no valid instance to update item with',\n item\n );\n return false;\n }\n\n return instance.updateItem(item);\n },\n updateItemId(oldId, newId) {\n const { controlled, instance } = cachedDataRef.current;\n assertUncontrolledCodeViewAction(controlled, 'updateItemId');\n if (instance == null) {\n console.error(\n 'CodeView.updateItemId: no valid instance to update item id with',\n oldId,\n newId\n );\n return false;\n }\n\n return instance.updateItemId(oldId, newId);\n },\n scrollTo(target) {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error(\n 'CodeView.scrollTo: no valid instance to scroll with',\n target\n );\n } else {\n instance.scrollTo(target);\n }\n },\n setSelectedLines(selection) {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error(\n 'CodeView.setSelectedLines: no valid instance to update selection with',\n selection\n );\n } else {\n instance.setSelectedLines(selection, { notify: false });\n emitSelectedLinesChange(selection);\n }\n },\n getSelectedLines() {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error('CodeView.getSelectedLines: no valid instance exists');\n return null;\n } else {\n return instance.getSelectedLines();\n }\n },\n clearSelectedLines() {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error(\n 'CodeView.clearSelectedLines: no valid instance to update selection with'\n );\n } else {\n instance.clearSelectedLines({ notify: false });\n emitSelectedLinesChange(null);\n }\n },\n getEditor(id) {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error('CodeView.getEditor: no valid instance exists', id);\n return undefined;\n }\n\n return instance.getEditor(id);\n },\n getInstance() {\n return cachedDataRef.current.instance;\n },\n }),\n [emitSelectedLinesChange]\n );\n\n return (\n <>\n <div ref={nodeRef} className={className} style={style} />\n {(hasRenderers || hasCodeViewHeader || hasCodeViewFooter) && (\n <SlotPortals<LAnnotation, Caret>\n managedContentStore={slotContentStore}\n renderCustomHeader={renderCustomHeader}\n renderHeaderPrefix={renderHeaderPrefix}\n renderHeaderFilenameSuffix={renderHeaderFilenameSuffix}\n renderHeaderMetadata={renderHeaderMetadata}\n renderAnnotation={renderAnnotation}\n renderGutterUtility={renderGutterUtility}\n renderCodeViewHeader={renderCodeViewHeader}\n renderCodeViewFooter={renderCodeViewFooter}\n />\n )}\n </>\n );\n}\n\n// React was a mistake\nexport const CodeView = forwardRef(CodeViewInner) as CodeViewComponent;\n\nfunction isAppendOnlyItemUpdate<LAnnotation>(\n previousItems: readonly CodeViewItem<LAnnotation>[] | undefined,\n nextItems: readonly CodeViewItem<LAnnotation>[]\n): previousItems is readonly CodeViewItem<LAnnotation>[] {\n if (previousItems == null || nextItems.length <= previousItems.length) {\n return false;\n }\n\n if (previousItems.length === 0) {\n return true;\n }\n\n for (let index = 0; index < previousItems.length; index++) {\n if (nextItems[index] !== previousItems[index]) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction areItemListsEqual<LAnnotation>(\n previousItems: readonly CodeViewItem<LAnnotation>[] | undefined,\n nextItems: readonly CodeViewItem<LAnnotation>[]\n): boolean {\n if (previousItems == null || previousItems.length !== nextItems.length) {\n return false;\n }\n\n for (let index = 0; index < previousItems.length; index++) {\n if (previousItems[index] !== nextItems[index]) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction assertUncontrolledCodeViewAction(\n controlled: boolean,\n action: string\n): void {\n if (!controlled) {\n return;\n }\n\n throw new Error(\n `CodeView.${action} cannot be used when CodeView is controlled. Use initialItems for imperative item updates.`\n );\n}\n\nfunction createSlotContentStore<LAnnotation, Caret>(): ManagedContentStore<\n LAnnotation,\n Caret\n> {\n let snapshot: CodeViewSlotSnapshot<LAnnotation, Caret> | undefined;\n const listeners = new Set<() => void>();\n\n return {\n getSnapshot() {\n return snapshot;\n },\n publish(nextSnapshot) {\n if (areManagedSnapshotsEqual(snapshot, nextSnapshot)) {\n return;\n }\n\n snapshot = nextSnapshot;\n for (const listener of listeners) {\n listener();\n }\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n\ninterface CreateManagedCodeViewOptionsProps<LAnnotation, Caret> {\n options: CodeViewReactOptions<LAnnotation, Caret> | undefined;\n hasCustomHeader: boolean;\n hasGutterRenderer: boolean;\n hasCodeViewHeader: boolean;\n hasCodeViewFooter: boolean;\n onSelectedLinesChange?(selection: CodeViewLineSelection | null): void;\n controlledSelection: boolean;\n getEditStateKey: CodeViewOptions<LAnnotation, Caret>['getEditStateKey'];\n createEditor: CodeViewOptions<LAnnotation, Caret>['createEditor'];\n onItemEditChange: CodeViewOptions<LAnnotation, Caret>['onItemEditChange'];\n onItemEditComplete: CodeViewOptions<LAnnotation, Caret>['onItemEditComplete'];\n}\n\nfunction createManagedCodeViewOptions<LAnnotation, Caret>({\n options,\n hasCustomHeader,\n hasGutterRenderer,\n hasCodeViewHeader,\n hasCodeViewFooter,\n onSelectedLinesChange,\n controlledSelection,\n getEditStateKey,\n createEditor,\n onItemEditChange,\n onItemEditComplete,\n}: CreateManagedCodeViewOptionsProps<LAnnotation, Caret>): CodeViewOptions<\n LAnnotation,\n Caret\n> {\n const managedOptions: CodeViewOptions<LAnnotation, Caret> = {\n ...options,\n controlledSelection,\n onSelectedLinesChange,\n createEditor,\n };\n\n if (getEditStateKey != null) {\n managedOptions.getEditStateKey = getEditStateKey;\n }\n\n // Prop-level editor callbacks win over their options-object counterparts,\n // but an absent prop must not clobber a value provided via `options`.\n if (onItemEditChange != null) {\n managedOptions.onItemEditChange = onItemEditChange;\n }\n if (onItemEditComplete != null) {\n managedOptions.onItemEditComplete = onItemEditComplete;\n }\n\n // The imperative CodeView adapters use this callback's presence to\n // switch file and diff headers into custom-slot mode. React portals\n // provide the actual header content, so this placeholder\n // intentionally returns nothing.\n if (hasCustomHeader) {\n managedOptions.renderCustomHeader = noopRender;\n }\n\n // The imperative CodeView adapters use this callback's presence to\n // create the custom gutter utility slot. React portals provide the\n // actual content, so this placeholder intentionally returns nothing.\n if (hasGutterRenderer) {\n managedOptions.renderGutterUtility = noopRender;\n }\n\n // The imperative CodeView adapters use these callbacks' presence to create the\n // header/footer host elements. React portals the actual content into them (via\n // the slot snapshot), so these placeholders intentionally return nothing.\n if (hasCodeViewHeader) {\n managedOptions.renderCodeViewHeader = noopRender;\n }\n if (hasCodeViewFooter) {\n managedOptions.renderCodeViewFooter = noopRender;\n }\n\n return managedOptions;\n}\n\ninterface RenderCodeViewItemChildrenProps<LAnnotation, Caret> {\n renderedItem: CodeViewRenderedItem<LAnnotation, Caret>;\n renderCustomHeader: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderCustomHeader'];\n renderHeaderPrefix: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderHeaderPrefix'];\n renderHeaderFilenameSuffix: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderHeaderFilenameSuffix'];\n renderHeaderMetadata: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderHeaderMetadata'];\n renderAnnotation: CodeViewBaseProps<LAnnotation, Caret>['renderAnnotation'];\n renderGutterUtility: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderGutterUtility'];\n}\n\ninterface SlotPortalsProps<LAnnotation, Caret> {\n managedContentStore: ManagedContentStore<LAnnotation, Caret>;\n renderCustomHeader: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderCustomHeader'];\n renderHeaderPrefix: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderHeaderPrefix'];\n renderHeaderFilenameSuffix: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderHeaderFilenameSuffix'];\n renderHeaderMetadata: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderHeaderMetadata'];\n renderAnnotation: CodeViewBaseProps<LAnnotation, Caret>['renderAnnotation'];\n renderGutterUtility: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderGutterUtility'];\n renderCodeViewHeader: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderCodeViewHeader'];\n renderCodeViewFooter: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderCodeViewFooter'];\n}\n\nconst SlotPortals = memo(function SlotPortals<LAnnotation, Caret>({\n managedContentStore,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderFilenameSuffix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n renderCodeViewHeader,\n renderCodeViewFooter,\n}: SlotPortalsProps<LAnnotation, Caret>) {\n 'use no memo';\n const subscribe = useStableCallback((listener: () => void) =>\n managedContentStore.subscribe(listener)\n );\n const getSnapshot = useStableCallback(() =>\n managedContentStore.getSnapshot()\n );\n const snapshot = useSyncExternalStore<\n CodeViewSlotSnapshot<LAnnotation, Caret> | undefined\n >(subscribe, getSnapshot, getSnapshot);\n let itemKeys = '';\n for (const item of snapshot?.items ?? []) {\n itemKeys += `${item.id}:${item.version}:${item.type}`;\n }\n // NOTE(amadeus): And just like that, the react compiler do be failing us\n // lol... we need to pre-render everything for items, headers and footers to\n // not trigger needless renders while scrolling\n const renderedItems = useMemo(\n () => {\n return snapshot?.items?.map((renderedItem) =>\n createPortal(\n renderCodeViewItemChildren({\n renderedItem,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderFilenameSuffix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n }),\n renderedItem.element,\n renderedItem.id\n )\n );\n },\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n [\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderFilenameSuffix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n itemKeys,\n ]\n );\n const renderedHeader = useMemo(() => {\n return renderCodeViewHeader != null && snapshot?.header != null\n ? createPortal(renderCodeViewHeader(), snapshot.header)\n : null;\n }, [renderCodeViewHeader, snapshot?.header]);\n const renderedFooter = useMemo(() => {\n return renderCodeViewFooter != null && snapshot?.footer != null\n ? createPortal(renderCodeViewFooter(), snapshot.footer)\n : null;\n }, [renderCodeViewFooter, snapshot?.footer]);\n return (\n <>\n {renderedItems}\n {renderedHeader}\n {renderedFooter}\n </>\n );\n}) as SlotPortalsComponent;\n\nfunction renderCodeViewItemChildren<LAnnotation, Caret>({\n renderedItem,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderFilenameSuffix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n}: RenderCodeViewItemChildrenProps<LAnnotation, Caret>): ReactNode {\n if (renderedItem.type === 'diff') {\n const { item, instance } = renderedItem;\n return renderDiffChildren({\n fileDiff: item.fileDiff,\n renderCustomHeader:\n renderCustomHeader != null ? () => renderCustomHeader(item) : undefined,\n renderHeaderPrefix:\n renderHeaderPrefix != null ? () => renderHeaderPrefix(item) : undefined,\n renderHeaderFilenameSuffix:\n renderHeaderFilenameSuffix != null\n ? () => renderHeaderFilenameSuffix(item)\n : undefined,\n renderHeaderMetadata:\n renderHeaderMetadata != null\n ? () => renderHeaderMetadata(item)\n : undefined,\n renderAnnotation:\n renderAnnotation != null\n ? (annotation) => renderAnnotation(annotation, item)\n : undefined,\n lineAnnotations: item.annotations,\n renderGutterUtility:\n renderGutterUtility != null\n ? (getHoveredLine) => renderGutterUtility(getHoveredLine, item)\n : undefined,\n getHoveredLine: instance.getHoveredLine,\n getAnnotationSlotName: instance.getAnnotationSlotName,\n });\n } else {\n const { item, instance } = renderedItem;\n return renderFileChildren({\n file: item.file,\n renderCustomHeader:\n renderCustomHeader != null ? () => renderCustomHeader(item) : undefined,\n renderHeaderPrefix:\n renderHeaderPrefix != null ? () => renderHeaderPrefix(item) : undefined,\n renderHeaderFilenameSuffix:\n renderHeaderFilenameSuffix != null\n ? () => renderHeaderFilenameSuffix(item)\n : undefined,\n renderHeaderMetadata:\n renderHeaderMetadata != null\n ? () => renderHeaderMetadata(item)\n : undefined,\n renderAnnotation:\n renderAnnotation != null\n ? (annotation) => renderAnnotation(annotation, item)\n : undefined,\n lineAnnotations: item.annotations,\n renderGutterUtility:\n renderGutterUtility != null\n ? (getHoveredLine) => renderGutterUtility(getHoveredLine, item)\n : undefined,\n getHoveredLine: instance.getHoveredLine,\n getAnnotationSlotName: instance.getAnnotationSlotName,\n });\n }\n}\n\nfunction noopRender() {\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;AAsDA,MAAM,4BACJ,OAAO,WAAW,cAAc,YAAY;AAgJ9C,SAAS,mBACP,YACmC;CACnC,OAAO;EACL,UAAU,KAAA;EACV,OAAO,KAAA;EACP;EACA,gBAAgB,KAAA;EAChB,kBAAkB;EAClB,iBAAiB,KAAA;CACnB;AACF;AAEA,SAAS,cACP,OACA,KACmB;CACnB,MAAM,EACJ,WACA,cACA,oBAAoB,OACpB,eACA,iBACA,cACA,OAAO,iBACP,kBACA,oBACA,UACA,uBACA,SACA,kBACA,sBACA,sBACA,oBACA,qBACA,4BACA,sBACA,oBACA,eACA,UACE;CACJ,MAAM,aAAa,oBAAoB,KAAA;CACvC,MAAM,sBAAsB,gBAAoC;CAChE,MAAM,cAAc,WAAW,iBAAiB;CAChD,MAAM,gBAAgB,OACpB,mBAAuC,UAAU,CACnD;CACA,MAAM,kBAAkB,sBAAsB;CAC9C,MAAM,wBAAwB,oBAAoB;CAClD,MAAM,oBAAoB,uBAAuB;CACjD,MAAM,qBACJ,mBACA,sBAAsB,QACtB,8BAA8B,QAC9B,wBAAwB;CAC1B,MAAM,eACJ,sBAAsB,yBAAyB;CACjD,MAAM,oBAAoB,wBAAwB;CAClD,MAAM,oBAAoB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C,MAAM,EAAE,MAAM,aAAa;EAC3B,OAAO,mBAAmB;GACxB,UAAU,KAAK;GACf,oBACE,sBAAsB,aAAa,mBAAmB,IAAI,IAAI,KAAA;GAChE,oBACE,sBAAsB,aAAa,mBAAmB,IAAI,IAAI,KAAA;GAChE,4BACE,8BAA8B,aACpB,2BAA2B,IAAI,IACrC,KAAA;GACN,sBACE,wBAAwB,aACd,qBAAqB,IAAI,IAC/B,KAAA;GACN,kBACE,oBAAoB,QACf,eAAe,iBAAiB,YAAY,IAAI,IACjD,KAAA;GACN,iBAAiB,KAAK;GACtB,qBACE,uBAAuB,QAClB,mBAAmB,oBAAoB,gBAAgB,IAAI,IAC5D,KAAA;GACN,gBAAgB,SAAS;GACzB,uBAAuB,SAAS;EAClC,CAAC;CACH,OAAO;EACL,MAAM,EAAE,MAAM,aAAa;EAC3B,OAAO,mBAAmB;GACxB,MAAM,KAAK;GACX,oBACE,sBAAsB,aAAa,mBAAmB,IAAI,IAAI,KAAA;GAChE,oBACE,sBAAsB,aAAa,mBAAmB,IAAI,IAAI,KAAA;GAChE,4BACE,8BAA8B,aACpB,2BAA2B,IAAI,IACrC,KAAA;GACN,sBACE,wBAAwB,aACd,qBAAqB,IAAI,IAC/B,KAAA;GACN,kBACE,oBAAoB,QACf,eAAe,iBAAiB,YAAY,IAAI,IACjD,KAAA;GACN,iBAAiB,KAAK;GACtB,qBACE,uBAAuB,QAClB,mBAAmB,oBAAoB,gBAAgB,IAAI,IAC5D,KAAA;GACN,gBAAgB,SAAS;GACzB,uBAAuB,SAAS;EAClC,CAAC;CACH;AACF;AAEA,SAAS,aAAa,CAEtB"}
1
+ {"version":3,"file":"CodeView.js","names":["CodeViewClass"],"sources":["../../src/react/CodeView.tsx"],"sourcesContent":["'use client';\n\nimport {\n type CSSProperties,\n forwardRef,\n memo,\n type ReactNode,\n type Ref,\n useContext,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport { createPortal, flushSync } from 'react-dom';\n\nimport type {\n Editor,\n EditorChangeEvent,\n EditorOptions,\n EditorType,\n} from '../edit';\nimport {\n areOptionsEqual,\n CodeView as CodeViewClass,\n type CodeViewCoordinator,\n type CodeViewCreateEditorOptions,\n type CodeViewDiffItem,\n type CodeViewFileItem,\n type CodeViewItem,\n type CodeViewItemEditCompleteEventMap,\n type CodeViewItemEditCompleteHandler,\n type CodeViewLineSelection,\n type CodeViewMode,\n type CodeViewModeItemMap,\n type CodeViewOptions,\n type CodeViewScrollTarget,\n type CodeViewSlotSnapshot,\n type DiffLineAnnotation,\n type FileContents,\n type FileDiffMetadata,\n type GetHoveredLineResult,\n type LineAnnotation,\n} from '../index';\nimport { getCodeViewItemRenderData } from '../utils/getCodeViewItemRenderData';\nimport { useCreateEditor } from './EditContext';\nimport { assignRef } from './utils/assignRef';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { renderFileChildren } from './utils/renderFileChildren';\nimport { useStableCallback } from './utils/useStableCallback';\nimport { WorkerPoolContext } from './WorkerPoolContext';\n\nexport type { CodeViewItemEditCompleteHandler };\n\nconst useIsomorphicLayoutEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ntype CodeViewGutterUtilityGetter =\n | (() => GetHoveredLineResult<'file'> | undefined)\n | (() => GetHoveredLineResult<'diff'> | undefined);\n\nexport type CodeViewAnnotationArgs<LAnnotation> =\n | [\n annotation: LineAnnotation<LAnnotation>,\n file: FileContents,\n item: CodeViewFileItem<LAnnotation>,\n ]\n | [\n annotation: DiffLineAnnotation<LAnnotation>,\n fileDiff: FileDiffMetadata,\n item: CodeViewDiffItem<LAnnotation>,\n ];\n\nexport type CodeViewReactOptions<LAnnotation, Caret> = Omit<\n CodeViewOptions<LAnnotation, Caret>,\n 'controlledSelection' | 'createEditor' | 'onSelectedLinesChange'\n>;\n\ninterface CodeViewBaseProps<LAnnotation, Caret> {\n options?: CodeViewReactOptions<LAnnotation, Caret>;\n /**\n * Creation-time options passed to the nearest EditProvider factory.\n * CodeView supplies its item-specific change callback.\n */\n editorOptions?: Omit<\n EditorOptions<EditorType, LAnnotation, Caret>,\n 'onChange'\n >;\n /** Resolve an in-memory retention key for an item's draft and undo history. */\n getEditStateKey?(item: CodeViewItem<LAnnotation>): string | undefined;\n className?: string;\n style?: CSSProperties;\n /**\n * Ref to the scroll container element. A callback ref follows the React 18\n * protocol: it is called with the element on mount and with `null` on\n * unmount. A cleanup function returned from the callback (the React 19\n * form) is ignored, so release resources on the `null` call or use a ref\n * object.\n */\n containerRef?: Ref<HTMLDivElement>;\n disableWorkerPool?: boolean;\n selectedLines?: CodeViewLineSelection | null;\n onSelectedLinesChange?(selection: CodeViewLineSelection | null): void;\n onScroll?(scrollTop: number, viewer: CodeViewClass<LAnnotation, Caret>): void;\n /** Render a non-virtualized node at the very start of the scroll content,\n * before the first item. Always rendered; scrolls with the content. */\n renderCodeViewHeader?(): ReactNode;\n /** Render a non-virtualized node at the very end of the scroll content, after\n * the last item. Always rendered; scrolls with the content. */\n renderCodeViewFooter?(): ReactNode;\n /**\n * Called with the editor's `EditorChangeEvent` and the owning item on every\n * document change. Do not feed it directly back into the controlled item,\n * which can create update loops.\n */\n onItemEditChange?(\n event: EditorChangeEvent<EditorType, LAnnotation, Caret>,\n item: CodeViewItem<LAnnotation>\n ): void;\n /**\n * Called once when an edit session ends: edit turned off, the item removed,\n * or the CodeView unmounted (where the result is not installed). Collapse\n * suspends the session instead of completing it. `nextItem` is the accepted\n * replacement CodeView built from `item`: the event's completed\n * `file`/`fileDiff` and annotations, `edit: false`, and a bumped `version`.\n * Return `'accept'` to install the edit — CodeView applies `nextItem` through\n * the item update path when the item still exists, and a controlled owner\n * puts the same `nextItem` into its state — or `'reject'` to revert. The event\n * is frozen; re-key the accepted value in place before accepting.\n */\n onItemEditComplete?: CodeViewItemEditCompleteHandler<LAnnotation, Caret>;\n renderCustomHeader?(item: CodeViewItem<LAnnotation>): ReactNode;\n renderHeaderPrefix?(item: CodeViewItem<LAnnotation>): ReactNode;\n renderHeaderFilenameSuffix?(item: CodeViewItem<LAnnotation>): ReactNode;\n renderHeaderMetadata?(item: CodeViewItem<LAnnotation>): ReactNode;\n renderAnnotation?(...args: CodeViewAnnotationArgs<LAnnotation>): ReactNode;\n renderGutterUtility?(\n getHoveredLine: CodeViewGutterUtilityGetter,\n item: CodeViewItem<LAnnotation>\n ): ReactNode;\n}\n\nexport interface ControlledCodeViewProps<\n LAnnotation,\n Caret,\n> extends CodeViewBaseProps<LAnnotation, Caret> {\n items: readonly CodeViewItem<LAnnotation>[];\n initialItems?: never;\n}\n\nexport interface UncontrolledCodeViewProps<\n LAnnotation,\n Caret,\n> extends CodeViewBaseProps<LAnnotation, Caret> {\n // Seeds the imperative CodeView instance once. Later item changes should go\n // through the ref API instead of being reconciled from React props.\n initialItems?: readonly CodeViewItem<LAnnotation>[];\n items?: never;\n}\n\nexport type CodeViewProps<LAnnotation, Caret> =\n | ControlledCodeViewProps<LAnnotation, Caret>\n | UncontrolledCodeViewProps<LAnnotation, Caret>;\n\nexport interface CodeViewHandle<LAnnotation, Caret> {\n addItems(items: readonly CodeViewItem<LAnnotation>[]): void;\n getItem(id: string): CodeViewItem<LAnnotation> | undefined;\n removeItem(id: string): boolean;\n updateItem(item: CodeViewItem<LAnnotation>): boolean;\n updateItemId(oldId: string, newId: string): boolean;\n scrollTo(target: CodeViewScrollTarget): void;\n setSelectedLines(selection: CodeViewLineSelection | null): void;\n getSelectedLines(): CodeViewLineSelection | null;\n clearSelectedLines(): void;\n getEditor(\n id: string\n ):\n | Editor<'file', LAnnotation, Caret>\n | Editor<'file-diff', LAnnotation, Caret>\n | undefined;\n getInstance(): CodeViewClass<LAnnotation, Caret> | undefined;\n}\n\ntype CodeViewComponent = <LAnnotation = undefined, Caret = undefined>(\n props: CodeViewProps<LAnnotation, Caret> & {\n ref?: React.Ref<CodeViewHandle<LAnnotation, Caret>>;\n }\n) => React.JSX.Element;\n\ntype SlotPortalsComponent = <LAnnotation, Caret>(\n props: SlotPortalsProps<LAnnotation, Caret>\n) => React.JSX.Element;\n\ntype DiffItemSlotsComponent = <LAnnotation, Caret>(\n props: DiffItemSlotsProps<LAnnotation, Caret>\n) => ReactNode;\n\ntype FileItemSlotsComponent = <LAnnotation, Caret>(\n props: FileItemSlotsProps<LAnnotation, Caret>\n) => ReactNode;\n\ninterface ManagedContentStore<LAnnotation, Caret> {\n getSnapshot(): CodeViewSlotSnapshot<LAnnotation, Caret> | undefined;\n publish(snapshot: CodeViewSlotSnapshot<LAnnotation, Caret> | undefined): void;\n subscribe(listener: () => void): () => void;\n}\n\ninterface CachedDataRef<LAnnotation, Caret> {\n instance: CodeViewClass<LAnnotation, Caret> | undefined;\n items: readonly CodeViewItem<LAnnotation>[] | undefined;\n controlled: boolean;\n managedOptions: CodeViewOptions<LAnnotation, Caret> | undefined;\n disableFlushSync: boolean;\n slotCoordinator: CodeViewCoordinator<LAnnotation, Caret> | undefined;\n}\n\nfunction createDefaultCache<LAnnotation, Caret>(\n controlled: boolean\n): CachedDataRef<LAnnotation, Caret> {\n return {\n instance: undefined,\n items: undefined,\n controlled,\n managedOptions: undefined,\n disableFlushSync: false,\n slotCoordinator: undefined,\n };\n}\n\nfunction CodeViewInner<LAnnotation = undefined, Caret = undefined>(\n props: CodeViewProps<LAnnotation, Caret>,\n ref: React.ForwardedRef<CodeViewHandle<LAnnotation, Caret>>\n): React.JSX.Element {\n const {\n className,\n containerRef,\n disableWorkerPool = false,\n editorOptions,\n getEditStateKey,\n initialItems,\n items: controlledItems,\n onItemEditChange,\n onItemEditComplete,\n onScroll,\n onSelectedLinesChange,\n options,\n renderAnnotation,\n renderCodeViewFooter,\n renderCodeViewHeader,\n renderCustomHeader,\n renderGutterUtility,\n renderHeaderFilenameSuffix,\n renderHeaderMetadata,\n renderHeaderPrefix,\n selectedLines,\n style,\n } = props;\n const controlled = controlledItems !== undefined;\n const contextCreateEditor = useCreateEditor<LAnnotation, Caret>();\n const poolManager = useContext(WorkerPoolContext);\n const cachedDataRef = useRef<CachedDataRef<LAnnotation, Caret>>(\n createDefaultCache<LAnnotation, Caret>(controlled)\n );\n const hasCustomHeader = renderCustomHeader != null;\n const hasAnnotationRenderer = renderAnnotation != null;\n const hasGutterRenderer = renderGutterUtility != null;\n const hasHeaderRenderers =\n hasCustomHeader ||\n renderHeaderPrefix != null ||\n renderHeaderFilenameSuffix != null ||\n renderHeaderMetadata != null;\n const hasRenderers =\n hasHeaderRenderers || hasAnnotationRenderer || hasGutterRenderer;\n const hasCodeViewHeader = renderCodeViewHeader != null;\n const hasCodeViewFooter = renderCodeViewFooter != null;\n const emitSelectedLinesChange = useStableCallback(\n (selection: CodeViewLineSelection | null) => {\n onSelectedLinesChange?.(selection);\n }\n );\n const controlledSelection = selectedLines !== undefined;\n\n // Keep the adapter stable so provider and editor-option changes affect the\n // next item edit session without forcing CodeView to reconcile active editors.\n const createEditor = useStableCallback(\n <EType extends EditorType>(\n editorType: EType,\n options: CodeViewCreateEditorOptions<EType, LAnnotation, Caret>,\n editStateKey?: string\n ): Editor<EType, LAnnotation, Caret> => {\n if (contextCreateEditor == null) {\n throw new Error('CodeView: EditContext is not attached');\n }\n\n const resolvedOptions = {\n ...editorOptions,\n ...options,\n } as EditorOptions<EType, LAnnotation, Caret>;\n const editor = contextCreateEditor(\n editorType,\n resolvedOptions,\n editStateKey\n );\n return editor;\n }\n );\n const emitItemEditChange = useStableCallback(\n (\n event: EditorChangeEvent<EditorType, LAnnotation, Caret>,\n item: CodeViewItem<LAnnotation>\n ) => {\n onItemEditChange?.(event, item);\n }\n );\n const emitItemEditComplete = useStableCallback(\n <TMode extends CodeViewMode>(\n event: CodeViewItemEditCompleteEventMap<LAnnotation, Caret>[TMode],\n item: CodeViewModeItemMap<LAnnotation>[TMode],\n nextItem: CodeViewModeItemMap<LAnnotation>[TMode]\n ) => onItemEditComplete?.(event, item, nextItem) ?? 'reject'\n );\n\n const managedOptions = useMemo(\n () =>\n createManagedCodeViewOptions({\n options,\n hasCustomHeader,\n hasGutterRenderer,\n hasCodeViewHeader,\n hasCodeViewFooter,\n onSelectedLinesChange:\n onSelectedLinesChange != null ? emitSelectedLinesChange : undefined,\n controlledSelection,\n getEditStateKey,\n createEditor: contextCreateEditor != null ? createEditor : undefined,\n onItemEditChange:\n onItemEditChange != null ? emitItemEditChange : undefined,\n onItemEditComplete:\n onItemEditComplete != null ? emitItemEditComplete : undefined,\n }),\n [\n contextCreateEditor,\n controlledSelection,\n createEditor,\n emitItemEditChange,\n emitItemEditComplete,\n emitSelectedLinesChange,\n hasCodeViewFooter,\n hasCodeViewHeader,\n hasCustomHeader,\n hasGutterRenderer,\n getEditStateKey,\n onItemEditChange,\n onItemEditComplete,\n onSelectedLinesChange,\n options,\n ]\n );\n\n const [slotContentStore] = useState<ManagedContentStore<LAnnotation, Caret>>(\n () => createSlotContentStore()\n );\n const [, forceUpdate] = useState<unknown>({});\n\n const nodeRef = useStableCallback((node: HTMLDivElement | null) => {\n // If we have a pre-existing instance and there's no node or the node being\n // passed in is NOT the same as before, then we need to clean up and\n // garbage collect the old instance\n if (\n cachedDataRef.current.instance != null &&\n (node == null ||\n node !== cachedDataRef.current.instance.getContainerElement())\n ) {\n cachedDataRef.current.instance.cleanUp();\n slotContentStore.publish(undefined);\n cachedDataRef.current = createDefaultCache<LAnnotation, Caret>(\n controlled\n );\n }\n\n // If our node matches the existing node then we should not attempt to\n // setup. This is a case that should never be possible to hit, but just in\n // case, lets make sure we don't re-setup an instance that is already setup\n // properly\n if (\n node != null &&\n node !== cachedDataRef.current.instance?.getContainerElement()\n ) {\n cachedDataRef.current.instance = new CodeViewClass<LAnnotation, Caret>(\n managedOptions,\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n cachedDataRef.current.instance.setup(node);\n }\n\n assignRef(containerRef, node);\n });\n\n const onSnapshotChange = useStableCallback(\n (snapshot: CodeViewSlotSnapshot<LAnnotation, Caret> | undefined) => {\n if (cachedDataRef.current.disableFlushSync) {\n slotContentStore.publish(snapshot);\n } else {\n flushSync(() => {\n slotContentStore.publish(snapshot);\n });\n }\n }\n );\n\n const slotCoordinator: CodeViewCoordinator<LAnnotation, Caret> | undefined =\n useMemo(() => {\n // A coordinator is needed whenever React portals anything — per-item\n // slots and codeview header and footer\n if (\n !hasHeaderRenderers &&\n !hasAnnotationRenderer &&\n !hasGutterRenderer &&\n !hasCodeViewHeader &&\n !hasCodeViewFooter\n ) {\n return undefined;\n } else {\n return {\n hasHeaderRenderers,\n hasAnnotationRenderer,\n hasGutterRenderer,\n onSnapshotChange,\n };\n }\n }, [\n onSnapshotChange,\n hasAnnotationRenderer,\n hasGutterRenderer,\n hasHeaderRenderers,\n hasCodeViewHeader,\n hasCodeViewFooter,\n ]);\n\n useIsomorphicLayoutEffect(() => {\n return onScroll != null\n ? cachedDataRef.current.instance?.subscribeToScroll(onScroll)\n : undefined;\n });\n\n useIsomorphicLayoutEffect(() => {\n const {\n instance,\n controlled: prevControlled,\n items: prevItems,\n managedOptions: prevManagedOptions,\n slotCoordinator: prevSlotCoordinator,\n } = cachedDataRef.current;\n if (instance == null) {\n return;\n }\n\n try {\n cachedDataRef.current.disableFlushSync = true;\n let shouldRender = false;\n\n if (!areOptionsEqual(managedOptions, prevManagedOptions)) {\n cachedDataRef.current.managedOptions = managedOptions;\n instance.setOptions(managedOptions);\n shouldRender = true;\n }\n\n if (prevControlled !== controlled) {\n console.error(\n 'CodeView: cannot switch between controlled and uncontrolled modes. Remount with a new key instead.'\n );\n return;\n }\n\n if (controlled) {\n if (controlledItems !== prevItems) {\n if (areItemListsEqual(prevItems, controlledItems)) {\n cachedDataRef.current.items = controlledItems;\n } else if (isAppendOnlyItemUpdate(prevItems, controlledItems)) {\n cachedDataRef.current.items = controlledItems;\n instance.addItems(controlledItems.slice(prevItems.length));\n } else {\n cachedDataRef.current.items = controlledItems;\n instance.setItems(controlledItems);\n shouldRender = true;\n }\n }\n }\n // If uncontrolled, we should only ever set items once, and just depend\n // on imperative instance changes going forward\n else if (prevItems == null) {\n const seedItems = initialItems ?? [];\n cachedDataRef.current.items = seedItems;\n if (seedItems.length > 0) {\n instance.setItems(seedItems);\n shouldRender = true;\n }\n }\n\n if (selectedLines !== undefined) {\n instance.setSelectedLines(selectedLines, { notify: false });\n }\n\n const slotPublish = instance.setSlotCoordinator(slotCoordinator);\n let forceInlinePublish = false;\n if (slotCoordinator !== prevSlotCoordinator) {\n if (slotCoordinator == null || prevSlotCoordinator == null) {\n forceInlinePublish = true;\n }\n cachedDataRef.current.slotCoordinator = slotCoordinator;\n }\n\n if (shouldRender || slotPublish) {\n instance.render(true);\n }\n\n // FIXME(amadeus): This feels kinda bad and flakey with regards to how\n // other things are working... it makes me think that we should\n // re-architect the slotCoordinator a bit, and maybe DON'T make it an\n // undefineable thing...\n if (slotPublish && slotCoordinator == null) {\n slotContentStore.publish(undefined);\n }\n\n if (forceInlinePublish) {\n forceUpdate({});\n }\n } finally {\n cachedDataRef.current.disableFlushSync = false;\n }\n });\n\n // Setup the ref handler\n useImperativeHandle(\n ref,\n (): CodeViewHandle<LAnnotation, Caret> => ({\n addItems(items) {\n const { controlled, instance } = cachedDataRef.current;\n assertUncontrolledCodeViewAction(controlled, 'addItems');\n if (instance == null) {\n console.error(\n 'CodeView.addItems: no valid instance to append items with',\n items\n );\n } else {\n instance.addItems(items);\n }\n },\n getItem(id) {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error('CodeView.getItem: no valid instance exists', id);\n return undefined;\n } else {\n return instance.getItem(id);\n }\n },\n removeItem(id) {\n const { controlled, instance } = cachedDataRef.current;\n assertUncontrolledCodeViewAction(controlled, 'removeItem');\n if (instance == null) {\n console.error(\n 'CodeView.removeItem: no valid instance to remove item from',\n id\n );\n return false;\n }\n\n return instance.removeItem(id);\n },\n updateItem(item) {\n const { controlled, instance } = cachedDataRef.current;\n assertUncontrolledCodeViewAction(controlled, 'updateItem');\n if (instance == null) {\n console.error(\n 'CodeView.updateItem: no valid instance to update item with',\n item\n );\n return false;\n }\n\n return instance.updateItem(item);\n },\n updateItemId(oldId, newId) {\n const { controlled, instance } = cachedDataRef.current;\n assertUncontrolledCodeViewAction(controlled, 'updateItemId');\n if (instance == null) {\n console.error(\n 'CodeView.updateItemId: no valid instance to update item id with',\n oldId,\n newId\n );\n return false;\n }\n\n return instance.updateItemId(oldId, newId);\n },\n scrollTo(target) {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error(\n 'CodeView.scrollTo: no valid instance to scroll with',\n target\n );\n } else {\n instance.scrollTo(target);\n }\n },\n setSelectedLines(selection) {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error(\n 'CodeView.setSelectedLines: no valid instance to update selection with',\n selection\n );\n } else {\n instance.setSelectedLines(selection, { notify: false });\n emitSelectedLinesChange(selection);\n }\n },\n getSelectedLines() {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error('CodeView.getSelectedLines: no valid instance exists');\n return null;\n } else {\n return instance.getSelectedLines();\n }\n },\n clearSelectedLines() {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error(\n 'CodeView.clearSelectedLines: no valid instance to update selection with'\n );\n } else {\n instance.clearSelectedLines({ notify: false });\n emitSelectedLinesChange(null);\n }\n },\n getEditor(id) {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error('CodeView.getEditor: no valid instance exists', id);\n return undefined;\n }\n\n return instance.getEditor(id);\n },\n getInstance() {\n return cachedDataRef.current.instance;\n },\n }),\n [emitSelectedLinesChange]\n );\n\n return (\n <>\n <div ref={nodeRef} className={className} style={style} />\n {(hasRenderers || hasCodeViewHeader || hasCodeViewFooter) && (\n <SlotPortals<LAnnotation, Caret>\n managedContentStore={slotContentStore}\n renderCustomHeader={renderCustomHeader}\n renderHeaderPrefix={renderHeaderPrefix}\n renderHeaderFilenameSuffix={renderHeaderFilenameSuffix}\n renderHeaderMetadata={renderHeaderMetadata}\n renderAnnotation={renderAnnotation}\n renderGutterUtility={renderGutterUtility}\n renderCodeViewHeader={renderCodeViewHeader}\n renderCodeViewFooter={renderCodeViewFooter}\n />\n )}\n </>\n );\n}\n\n// React was a mistake\nexport const CodeView = forwardRef(CodeViewInner) as CodeViewComponent;\n\nfunction isAppendOnlyItemUpdate<LAnnotation>(\n previousItems: readonly CodeViewItem<LAnnotation>[] | undefined,\n nextItems: readonly CodeViewItem<LAnnotation>[]\n): previousItems is readonly CodeViewItem<LAnnotation>[] {\n if (previousItems == null || nextItems.length <= previousItems.length) {\n return false;\n }\n\n if (previousItems.length === 0) {\n return true;\n }\n\n for (let index = 0; index < previousItems.length; index++) {\n if (nextItems[index] !== previousItems[index]) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction areItemListsEqual<LAnnotation>(\n previousItems: readonly CodeViewItem<LAnnotation>[] | undefined,\n nextItems: readonly CodeViewItem<LAnnotation>[]\n): boolean {\n if (previousItems == null || previousItems.length !== nextItems.length) {\n return false;\n }\n\n for (let index = 0; index < previousItems.length; index++) {\n if (previousItems[index] !== nextItems[index]) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction assertUncontrolledCodeViewAction(\n controlled: boolean,\n action: string\n): void {\n if (!controlled) {\n return;\n }\n\n throw new Error(\n `CodeView.${action} cannot be used when CodeView is controlled. Use initialItems for imperative item updates.`\n );\n}\n\nfunction createSlotContentStore<LAnnotation, Caret>(): ManagedContentStore<\n LAnnotation,\n Caret\n> {\n let snapshot: CodeViewSlotSnapshot<LAnnotation, Caret> | undefined;\n const listeners = new Set<() => void>();\n\n return {\n getSnapshot() {\n return snapshot;\n },\n publish(nextSnapshot) {\n if (snapshot === nextSnapshot) {\n return;\n }\n\n snapshot = nextSnapshot;\n for (const listener of listeners) {\n listener();\n }\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n\ninterface CreateManagedCodeViewOptionsProps<LAnnotation, Caret> {\n options: CodeViewReactOptions<LAnnotation, Caret> | undefined;\n hasCustomHeader: boolean;\n hasGutterRenderer: boolean;\n hasCodeViewHeader: boolean;\n hasCodeViewFooter: boolean;\n onSelectedLinesChange?(selection: CodeViewLineSelection | null): void;\n controlledSelection: boolean;\n getEditStateKey: CodeViewOptions<LAnnotation, Caret>['getEditStateKey'];\n createEditor: CodeViewOptions<LAnnotation, Caret>['createEditor'];\n onItemEditChange: CodeViewOptions<LAnnotation, Caret>['onItemEditChange'];\n onItemEditComplete: CodeViewOptions<LAnnotation, Caret>['onItemEditComplete'];\n}\n\nfunction createManagedCodeViewOptions<LAnnotation, Caret>({\n options,\n hasCustomHeader,\n hasGutterRenderer,\n hasCodeViewHeader,\n hasCodeViewFooter,\n onSelectedLinesChange,\n controlledSelection,\n getEditStateKey,\n createEditor,\n onItemEditChange,\n onItemEditComplete,\n}: CreateManagedCodeViewOptionsProps<LAnnotation, Caret>): CodeViewOptions<\n LAnnotation,\n Caret\n> {\n const managedOptions: CodeViewOptions<LAnnotation, Caret> = {\n ...options,\n controlledSelection,\n onSelectedLinesChange,\n createEditor,\n };\n\n if (getEditStateKey != null) {\n managedOptions.getEditStateKey = getEditStateKey;\n }\n\n // Prop-level editor callbacks win over their options-object counterparts,\n // but an absent prop must not clobber a value provided via `options`.\n if (onItemEditChange != null) {\n managedOptions.onItemEditChange = onItemEditChange;\n }\n if (onItemEditComplete != null) {\n managedOptions.onItemEditComplete = onItemEditComplete;\n }\n\n // The imperative CodeView adapters use this callback's presence to\n // switch file and diff headers into custom-slot mode. React portals\n // provide the actual header content, so this placeholder\n // intentionally returns nothing.\n if (hasCustomHeader) {\n managedOptions.renderCustomHeader = noopRender;\n }\n\n // The imperative CodeView adapters use this callback's presence to\n // create the custom gutter utility slot. React portals provide the\n // actual content, so this placeholder intentionally returns nothing.\n if (hasGutterRenderer) {\n managedOptions.renderGutterUtility = noopRender;\n }\n\n // The imperative CodeView adapters use these callbacks' presence to create the\n // header/footer host elements. React portals the actual content into them (via\n // the slot snapshot), so these placeholders intentionally return nothing.\n if (hasCodeViewHeader) {\n managedOptions.renderCodeViewHeader = noopRender;\n }\n if (hasCodeViewFooter) {\n managedOptions.renderCodeViewFooter = noopRender;\n }\n\n return managedOptions;\n}\n\ninterface CodeViewItemRenderers<LAnnotation, Caret> {\n renderCustomHeader: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderCustomHeader'];\n renderHeaderPrefix: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderHeaderPrefix'];\n renderHeaderFilenameSuffix: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderHeaderFilenameSuffix'];\n renderHeaderMetadata: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderHeaderMetadata'];\n renderAnnotation: CodeViewBaseProps<LAnnotation, Caret>['renderAnnotation'];\n renderGutterUtility: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderGutterUtility'];\n}\n\ninterface DiffItemSlotsProps<LAnnotation, Caret> extends CodeViewItemRenderers<\n LAnnotation,\n Caret\n> {\n version: number;\n item: CodeViewDiffItem<LAnnotation>;\n fileDiff: FileDiffMetadata;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[];\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getAnnotationSlotName(annotation: DiffLineAnnotation<LAnnotation>): string;\n}\n\ninterface FileItemSlotsProps<LAnnotation, Caret> extends CodeViewItemRenderers<\n LAnnotation,\n Caret\n> {\n version: number;\n item: CodeViewFileItem<LAnnotation>;\n file: FileContents;\n lineAnnotations: LineAnnotation<LAnnotation>[];\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n getAnnotationSlotName(annotation: LineAnnotation<LAnnotation>): string;\n}\n\ninterface SlotPortalsProps<LAnnotation, Caret> {\n managedContentStore: ManagedContentStore<LAnnotation, Caret>;\n renderCustomHeader: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderCustomHeader'];\n renderHeaderPrefix: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderHeaderPrefix'];\n renderHeaderFilenameSuffix: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderHeaderFilenameSuffix'];\n renderHeaderMetadata: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderHeaderMetadata'];\n renderAnnotation: CodeViewBaseProps<LAnnotation, Caret>['renderAnnotation'];\n renderGutterUtility: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderGutterUtility'];\n renderCodeViewHeader: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderCodeViewHeader'];\n renderCodeViewFooter: CodeViewBaseProps<\n LAnnotation,\n Caret\n >['renderCodeViewFooter'];\n}\n\nconst SlotPortals = memo(function SlotPortals<LAnnotation, Caret>({\n managedContentStore,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderFilenameSuffix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n renderCodeViewHeader,\n renderCodeViewFooter,\n}: SlotPortalsProps<LAnnotation, Caret>) {\n 'use no memo';\n const subscribe = useStableCallback((listener: () => void) =>\n managedContentStore.subscribe(listener)\n );\n const getSnapshot = useStableCallback(() =>\n managedContentStore.getSnapshot()\n );\n const snapshot = useSyncExternalStore<\n CodeViewSlotSnapshot<LAnnotation, Caret> | undefined\n >(subscribe, getSnapshot, getSnapshot);\n // NOTE(amadeus): And just like that, the react compiler do be failing us\n // lol... we need to pre-render everything for items, headers and footers to\n // not trigger needless renders while scrolling\n const renderedItems = useMemo(\n () => {\n const renderers = {\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderFilenameSuffix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n };\n return snapshot?.items?.map((renderedItem) =>\n createPortal(\n renderedItem.type === 'diff' ? (\n <DiffItemSlots\n version={renderedItem.version ?? 0}\n item={renderedItem.item}\n getHoveredLine={renderedItem.instance.getHoveredLine}\n getAnnotationSlotName={\n renderedItem.instance.getAnnotationSlotName\n }\n {...getCodeViewItemRenderData(renderedItem)}\n {...renderers}\n />\n ) : (\n <FileItemSlots\n version={renderedItem.version ?? 0}\n item={renderedItem.item}\n getHoveredLine={renderedItem.instance.getHoveredLine}\n getAnnotationSlotName={\n renderedItem.instance.getAnnotationSlotName\n }\n {...getCodeViewItemRenderData(renderedItem)}\n {...renderers}\n />\n ),\n renderedItem.element,\n renderedItem.id\n )\n );\n },\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n [\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderFilenameSuffix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n snapshot?.items,\n ]\n );\n const renderedHeader = useMemo(() => {\n return renderCodeViewHeader != null && snapshot?.header != null\n ? createPortal(renderCodeViewHeader(), snapshot.header)\n : null;\n }, [renderCodeViewHeader, snapshot?.header]);\n const renderedFooter = useMemo(() => {\n return renderCodeViewFooter != null && snapshot?.footer != null\n ? createPortal(renderCodeViewFooter(), snapshot.footer)\n : null;\n }, [renderCodeViewFooter, snapshot?.footer]);\n return (\n <>\n {renderedItems}\n {renderedHeader}\n {renderedFooter}\n </>\n );\n}) as SlotPortalsComponent;\n\n// Each item's slot content is its own memoized component, so republishing the\n// slot snapshot only rerenders items whose displayed data changed. An item in\n// an edit session keeps the same data while the editor moves its rows.\nconst DiffItemSlots = memo(function DiffItemSlots<LAnnotation, Caret>({\n item,\n fileDiff,\n lineAnnotations,\n getHoveredLine,\n getAnnotationSlotName,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderFilenameSuffix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n}: DiffItemSlotsProps<LAnnotation, Caret>): ReactNode {\n return renderDiffChildren({\n fileDiff,\n renderCustomHeader:\n renderCustomHeader != null ? () => renderCustomHeader(item) : undefined,\n renderHeaderPrefix:\n renderHeaderPrefix != null ? () => renderHeaderPrefix(item) : undefined,\n renderHeaderFilenameSuffix:\n renderHeaderFilenameSuffix != null\n ? () => renderHeaderFilenameSuffix(item)\n : undefined,\n renderHeaderMetadata:\n renderHeaderMetadata != null\n ? () => renderHeaderMetadata(item)\n : undefined,\n renderAnnotation:\n renderAnnotation != null\n ? (annotation, fileDiff) => renderAnnotation(annotation, fileDiff, item)\n : undefined,\n lineAnnotations,\n renderGutterUtility:\n renderGutterUtility != null\n ? (getHoveredLine) => renderGutterUtility(getHoveredLine, item)\n : undefined,\n getHoveredLine,\n getAnnotationSlotName,\n });\n}) as DiffItemSlotsComponent;\n\nconst FileItemSlots = memo(function FileItemSlots<LAnnotation, Caret>({\n item,\n file,\n lineAnnotations,\n getHoveredLine,\n getAnnotationSlotName,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderFilenameSuffix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n}: FileItemSlotsProps<LAnnotation, Caret>): ReactNode {\n return renderFileChildren({\n file,\n renderCustomHeader:\n renderCustomHeader != null ? () => renderCustomHeader(item) : undefined,\n renderHeaderPrefix:\n renderHeaderPrefix != null ? () => renderHeaderPrefix(item) : undefined,\n renderHeaderFilenameSuffix:\n renderHeaderFilenameSuffix != null\n ? () => renderHeaderFilenameSuffix(item)\n : undefined,\n renderHeaderMetadata:\n renderHeaderMetadata != null\n ? () => renderHeaderMetadata(item)\n : undefined,\n renderAnnotation:\n renderAnnotation != null\n ? (annotation, file) => renderAnnotation(annotation, file, item)\n : undefined,\n lineAnnotations,\n renderGutterUtility:\n renderGutterUtility != null\n ? (getHoveredLine) => renderGutterUtility(getHoveredLine, item)\n : undefined,\n getHoveredLine,\n getAnnotationSlotName,\n });\n}) as FileItemSlotsComponent;\n\nfunction noopRender() {\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;AAyDA,MAAM,4BACJ,OAAO,WAAW,cAAc,YAAY;AAiK9C,SAAS,mBACP,YACmC;CACnC,OAAO;EACL,UAAU,KAAA;EACV,OAAO,KAAA;EACP;EACA,gBAAgB,KAAA;EAChB,kBAAkB;EAClB,iBAAiB,KAAA;CACnB;AACF;AAEA,SAAS,cACP,OACA,KACmB;CACnB,MAAM,EACJ,WACA,cACA,oBAAoB,OACpB,eACA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