@ai-matrx/rich-content 0.2.4 → 0.2.6

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 (381) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/code-block/CodeBlock.d.ts +44 -0
  3. package/dist/code-block/CodeBlock.js +449 -0
  4. package/dist/code-block/CodeBlockHeader.d.ts +63 -0
  5. package/dist/code-block/CodeBlockHeader.js +472 -0
  6. package/dist/code-block/CodeEditorLoading.d.ts +3 -0
  7. package/dist/code-block/CodeEditorLoading.js +34 -0
  8. package/dist/code-block/LanguageDisplay.d.ts +28 -0
  9. package/dist/code-block/LanguageDisplay.js +279 -0
  10. package/dist/code-block/SmallCodeEditor.d.ts +30 -0
  11. package/dist/code-block/SmallCodeEditor.js +22 -0
  12. package/dist/code-block/StickyButtons.d.ts +35 -0
  13. package/dist/code-block/StickyButtons.js +88 -0
  14. package/dist/code-block/highlight/ShikiCodeView.d.ts +26 -0
  15. package/dist/code-block/highlight/ShikiCodeView.js +134 -0
  16. package/dist/code-block/highlight/shiki-highlighter.d.ts +14 -0
  17. package/dist/code-block/highlight/shiki-highlighter.js +126 -0
  18. package/dist/code-block/highlight/useHighlightedLines.d.ts +18 -0
  19. package/dist/code-block/highlight/useHighlightedLines.js +142 -0
  20. package/dist/code-block/sticky-inset.d.ts +6 -0
  21. package/dist/code-block/sticky-inset.js +10 -0
  22. package/dist/display/block-interaction.d.ts +33 -0
  23. package/dist/display/block-interaction.js +13 -0
  24. package/dist/display/blocks/ChatCollapsibleWrapper.d.ts +13 -0
  25. package/dist/display/blocks/ChatCollapsibleWrapper.js +56 -0
  26. package/dist/display/blocks/buildMediaSource.d.ts +25 -0
  27. package/dist/display/blocks/buildMediaSource.js +43 -0
  28. package/dist/display/blocks/canvas-adaptive.d.ts +118 -0
  29. package/dist/display/blocks/canvas-adaptive.js +127 -0
  30. package/dist/display/blocks/canvas-fit.d.ts +24 -0
  31. package/dist/display/blocks/canvas-fit.js +19 -0
  32. package/dist/display/blocks/chart/ChartBlock.d.ts +8 -0
  33. package/dist/display/blocks/chart/ChartBlock.js +125 -0
  34. package/dist/display/blocks/chart/ChartCanvas.d.ts +18 -0
  35. package/dist/display/blocks/chart/ChartCanvas.js +159 -0
  36. package/dist/display/blocks/chart/TableChart.d.ts +25 -0
  37. package/dist/display/blocks/chart/TableChart.js +97 -0
  38. package/dist/display/blocks/chart/chart-spec.d.ts +39 -0
  39. package/dist/display/blocks/chart/chart-spec.js +128 -0
  40. package/dist/display/blocks/chart/labels.d.ts +20 -0
  41. package/dist/display/blocks/chart/labels.js +7 -0
  42. package/dist/display/blocks/chart/table-chart.d.ts +37 -0
  43. package/dist/display/blocks/chart/table-chart.js +231 -0
  44. package/dist/display/blocks/common/BlockHeaderWrapper.d.ts +56 -0
  45. package/dist/display/blocks/common/BlockHeaderWrapper.js +310 -0
  46. package/dist/display/blocks/common/ContentBlockWrapper.d.ts +40 -0
  47. package/dist/display/blocks/common/ContentBlockWrapper.js +214 -0
  48. package/dist/display/blocks/common/SandboxedHtml.d.ts +27 -0
  49. package/dist/display/blocks/common/SandboxedHtml.js +26 -0
  50. package/dist/display/blocks/diagram/DiagramLoadingVisualization.d.ts +6 -0
  51. package/dist/display/blocks/diagram/DiagramLoadingVisualization.js +190 -0
  52. package/dist/display/blocks/diagram/InteractiveDiagramBlock.d.ts +51 -0
  53. package/dist/display/blocks/diagram/InteractiveDiagramBlock.js +2415 -0
  54. package/dist/display/blocks/diagram/diagram-printer.d.ts +16 -0
  55. package/dist/display/blocks/diagram/diagram-printer.js +294 -0
  56. package/dist/display/blocks/diagram/diagram-visual-defaults.d.ts +116 -0
  57. package/dist/display/blocks/diagram/diagram-visual-defaults.js +400 -0
  58. package/dist/display/blocks/diagram/layout-utils.d.ts +90 -0
  59. package/dist/display/blocks/diagram/layout-utils.js +347 -0
  60. package/dist/display/blocks/diagram/parseDiagramJSON.d.ts +105 -0
  61. package/dist/display/blocks/diagram/parseDiagramJSON.js +296 -0
  62. package/dist/display/blocks/diagram/presentation-direction.d.ts +29 -0
  63. package/dist/display/blocks/diagram/presentation-direction.js +19 -0
  64. package/dist/display/blocks/diagram/ui-utils.d.ts +1 -0
  65. package/dist/display/blocks/diagram/ui-utils.js +18 -0
  66. package/dist/display/blocks/diff/DiffBlock.d.ts +10 -0
  67. package/dist/display/blocks/diff/DiffBlock.js +119 -0
  68. package/dist/display/blocks/diff/DiffCanvas.d.ts +15 -0
  69. package/dist/display/blocks/diff/DiffCanvas.js +20 -0
  70. package/dist/display/blocks/generic/GenericStructuredBlock.d.ts +24 -0
  71. package/dist/display/blocks/generic/GenericStructuredBlock.js +53 -0
  72. package/dist/display/blocks/generic/StructuredValueTabs.d.ts +21 -0
  73. package/dist/display/blocks/generic/StructuredValueTabs.js +124 -0
  74. package/dist/display/blocks/generic/tile-actions-slot.d.ts +39 -0
  75. package/dist/display/blocks/generic/tile-actions-slot.js +33 -0
  76. package/dist/display/blocks/images/ImageBlock.d.ts +8 -0
  77. package/dist/display/blocks/images/ImageBlock.js +265 -0
  78. package/dist/display/blocks/json/JsonBlock.d.ts +34 -0
  79. package/dist/display/blocks/json/JsonBlock.js +562 -0
  80. package/dist/display/blocks/json/JsonTableView.d.ts +10 -0
  81. package/dist/display/blocks/json/JsonTableView.js +173 -0
  82. package/dist/display/blocks/json/json-compact-stringify.d.ts +25 -0
  83. package/dist/display/blocks/json/json-compact-stringify.js +52 -0
  84. package/dist/display/blocks/json/json-tabular-utils.d.ts +65 -0
  85. package/dist/display/blocks/json/json-tabular-utils.js +121 -0
  86. package/dist/display/blocks/links/LinkComponent.d.ts +6 -0
  87. package/dist/display/blocks/links/LinkComponent.js +373 -0
  88. package/dist/display/blocks/links/LinkComponentWithFetch.d.ts +1 -0
  89. package/dist/display/blocks/links/LinkComponentWithFetch.js +0 -0
  90. package/dist/display/blocks/markdown/MarkdownKindBlock.d.ts +48 -0
  91. package/dist/display/blocks/markdown/MarkdownKindBlock.js +52 -0
  92. package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.d.ts +17 -0
  93. package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.js +70 -0
  94. package/dist/display/blocks/mermaid/MermaidBlock.d.ts +19 -0
  95. package/dist/display/blocks/mermaid/MermaidBlock.js +386 -0
  96. package/dist/display/blocks/search-replace/SearchReplaceBlock.d.ts +50 -0
  97. package/dist/display/blocks/search-replace/SearchReplaceBlock.js +71 -0
  98. package/dist/display/blocks/svg/SvgBlock.d.ts +8 -0
  99. package/dist/display/blocks/svg/SvgBlock.js +126 -0
  100. package/dist/display/blocks/table/StreamingTableRenderer.d.ts +53 -0
  101. package/dist/display/blocks/table/StreamingTableRenderer.js +907 -0
  102. package/dist/display/blocks/table/TableRenderPathDiagnostic.d.ts +21 -0
  103. package/dist/display/blocks/table/TableRenderPathDiagnostic.js +79 -0
  104. package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.d.ts +14 -0
  105. package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.js +15 -0
  106. package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.d.ts +13 -0
  107. package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.js +19 -0
  108. package/dist/display/blocks/thinking-reasoning/ThinkingTrace.d.ts +30 -0
  109. package/dist/display/blocks/thinking-reasoning/ThinkingTrace.js +75 -0
  110. package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.d.ts +13 -0
  111. package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.js +48 -0
  112. package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.d.ts +12 -0
  113. package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.js +19 -0
  114. package/dist/display/blocks/toml/TomlBlock.d.ts +7 -0
  115. package/dist/display/blocks/toml/TomlBlock.js +167 -0
  116. package/dist/display/blocks/tree/TreeBlock.d.ts +7 -0
  117. package/dist/display/blocks/tree/TreeBlock.js +163 -0
  118. package/dist/display/blocks/xml/XmlBlock.d.ts +23 -0
  119. package/dist/display/blocks/xml/XmlBlock.js +197 -0
  120. package/dist/display/blocks/xml/readXmlTag.d.ts +1 -0
  121. package/dist/display/blocks/xml/readXmlTag.js +1 -0
  122. package/dist/display/blocks/xml/xml-tokenize.d.ts +13 -0
  123. package/dist/display/blocks/xml/xml-tokenize.js +169 -0
  124. package/dist/display/blocks/yaml/YamlBlock.d.ts +7 -0
  125. package/dist/display/blocks/yaml/YamlBlock.js +191 -0
  126. package/dist/display/chat-markdown/BasicMarkdownContent.d.ts +29 -0
  127. package/dist/display/chat-markdown/BasicMarkdownContent.js +122 -0
  128. package/dist/display/chat-markdown/BlockRenderingContext.d.ts +23 -0
  129. package/dist/display/chat-markdown/BlockRenderingContext.js +17 -0
  130. package/dist/display/chat-markdown/ConfigurableMarkdownContent.d.ts +172 -0
  131. package/dist/display/chat-markdown/ConfigurableMarkdownContent.js +649 -0
  132. package/dist/display/chat-markdown/InlineCodeSnippet.d.ts +19 -0
  133. package/dist/display/chat-markdown/InlineCodeSnippet.js +146 -0
  134. package/dist/display/chat-markdown/InlineCodeSnippetKindGate.d.ts +11 -0
  135. package/dist/display/chat-markdown/InlineCodeSnippetKindGate.js +9 -0
  136. package/dist/display/chat-markdown/KindTextGate.d.ts +31 -0
  137. package/dist/display/chat-markdown/KindTextGate.js +60 -0
  138. package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.d.ts +6 -0
  139. package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.js +92 -0
  140. package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.d.ts +72 -0
  141. package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.js +94 -0
  142. package/dist/display/chat-markdown/block-registry/BlockRenderer.d.ts +126 -0
  143. package/dist/display/chat-markdown/block-registry/BlockRenderer.js +473 -0
  144. package/dist/display/chat-markdown/block-registry/block-dispatch.d.ts +410 -0
  145. package/dist/display/chat-markdown/block-registry/block-dispatch.js +495 -0
  146. package/dist/display/chat-markdown/block-registry/json-parse-utils.d.ts +13 -0
  147. package/dist/display/chat-markdown/block-registry/json-parse-utils.js +236 -0
  148. package/dist/display/chat-markdown/constants.d.ts +14 -0
  149. package/dist/display/chat-markdown/constants.js +317 -0
  150. package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.d.ts +31 -0
  151. package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.js +62 -0
  152. package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.d.ts +12 -0
  153. package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.js +18 -0
  154. package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.d.ts +22 -0
  155. package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.js +130 -0
  156. package/dist/display/chat-markdown/diff-blocks/diff-style-registry.d.ts +21 -0
  157. package/dist/display/chat-markdown/diff-blocks/diff-style-registry.js +91 -0
  158. package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.d.ts +26 -0
  159. package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.js +186 -0
  160. package/dist/display/chat-markdown/diff-blocks/types.d.ts +56 -0
  161. package/dist/display/chat-markdown/diff-blocks/types.js +0 -0
  162. package/dist/display/chat-markdown/internal-handlers/BlockFallback.d.ts +20 -0
  163. package/dist/display/chat-markdown/internal-handlers/BlockFallback.js +83 -0
  164. package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.d.ts +4 -0
  165. package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.js +16 -0
  166. package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.d.ts +17 -0
  167. package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.js +40 -0
  168. package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.d.ts +8 -0
  169. package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.js +91 -0
  170. package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.d.ts +20 -0
  171. package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.js +72 -0
  172. package/dist/display/chat-markdown/kind-source-view.d.ts +14 -0
  173. package/dist/display/chat-markdown/kind-source-view.js +14 -0
  174. package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.d.ts +28 -0
  175. package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.js +65 -0
  176. package/dist/display/chat-markdown/progressive-mount.d.ts +18 -0
  177. package/dist/display/chat-markdown/progressive-mount.js +90 -0
  178. package/dist/display/chat-markdown/render-block-to-content-block.d.ts +31 -0
  179. package/dist/display/chat-markdown/render-block-to-content-block.js +32 -0
  180. package/dist/display/chat-markdown/settle-stream-blocks.d.ts +50 -0
  181. package/dist/display/chat-markdown/settle-stream-blocks.js +26 -0
  182. package/dist/display/chat-markdown/stable-blocks.d.ts +15 -0
  183. package/dist/display/chat-markdown/stable-blocks.js +54 -0
  184. package/dist/display/chat-markdown/types.d.ts +11 -0
  185. package/dist/display/chat-markdown/types.js +26 -0
  186. package/dist/display/specimen/SpecimenContext.d.ts +26 -0
  187. package/dist/display/specimen/SpecimenContext.js +64 -0
  188. package/dist/display/tables/MarkdownTable.d.ts +23 -0
  189. package/dist/display/tables/MarkdownTable.js +769 -0
  190. package/dist/display/tables/MarkdownTableScrollArea.d.ts +12 -0
  191. package/dist/display/tables/MarkdownTableScrollArea.js +92 -0
  192. package/dist/display/tables/SendToGoogleSheetButton.d.ts +19 -0
  193. package/dist/display/tables/SendToGoogleSheetButton.js +93 -0
  194. package/dist/display/tables/SendToWorkbookButton.d.ts +24 -0
  195. package/dist/display/tables/SendToWorkbookButton.js +93 -0
  196. package/dist/display/tables/TableSaveToMenu.d.ts +16 -0
  197. package/dist/display/tables/TableSaveToMenu.js +98 -0
  198. package/dist/display/tables/TableWithSeparatedControls.d.ts +22 -0
  199. package/dist/display/tables/TableWithSeparatedControls.js +574 -0
  200. package/dist/display/tables/ViewTableModal.d.ts +14 -0
  201. package/dist/display/tables/ViewTableModal.js +67 -0
  202. package/dist/display/tables/editing/ColumnActionsMenu.d.ts +16 -0
  203. package/dist/display/tables/editing/ColumnActionsMenu.js +80 -0
  204. package/dist/display/tables/editing/RowActionsMenu.d.ts +16 -0
  205. package/dist/display/tables/editing/RowActionsMenu.js +80 -0
  206. package/dist/display/tables/editing/TableEditToolbar.d.ts +15 -0
  207. package/dist/display/tables/editing/TableEditToolbar.js +63 -0
  208. package/dist/display/tables/editing/tableMutations.d.ts +50 -0
  209. package/dist/display/tables/editing/tableMutations.js +148 -0
  210. package/dist/display/tables/editing/useDoubleClickEdit.d.ts +43 -0
  211. package/dist/display/tables/editing/useDoubleClickEdit.js +51 -0
  212. package/dist/display/tables/editing/useTableUndo.d.ts +25 -0
  213. package/dist/display/tables/editing/useTableUndo.js +17 -0
  214. package/dist/display/tables/table-action-row.d.ts +8 -0
  215. package/dist/display/tables/table-action-row.js +31 -0
  216. package/dist/display/tables/table-viewer.d.ts +13 -0
  217. package/dist/display/tables/table-viewer.js +18 -0
  218. package/dist/host/ErrorActions.d.ts +1 -1
  219. package/dist/host/ErrorNotice.d.ts +10 -0
  220. package/dist/host/ErrorNotice.js +19 -0
  221. package/dist/host/app-bindings.d.ts +155 -0
  222. package/dist/host/app-bindings.js +160 -0
  223. package/dist/host/diagnostics.d.ts +2 -2
  224. package/dist/host/diagnostics.js +2 -1
  225. package/dist/host/tables.d.ts +1 -6
  226. package/dist/host/types.d.ts +14 -7
  227. package/dist/levels/RichContent.d.ts +3 -0
  228. package/dist/levels/RichContent.js +102 -0
  229. package/dist/levels/RichContentInline.d.ts +28 -0
  230. package/dist/levels/RichContentInline.js +61 -0
  231. package/dist/levels/RichContentPreview.d.ts +12 -0
  232. package/dist/levels/RichContentPreview.js +39 -0
  233. package/dist/levels/RichContentStandardImpl.d.ts +12 -0
  234. package/dist/levels/RichContentStandardImpl.js +27 -0
  235. package/dist/levels/RichContentStaticProse.d.ts +46 -0
  236. package/dist/levels/RichContentStaticProse.js +100 -0
  237. package/dist/levels/depth.d.ts +18 -0
  238. package/dist/levels/depth.js +32 -0
  239. package/dist/levels/prose/inline-level-elements.d.ts +19 -0
  240. package/dist/levels/prose/inline-level-elements.js +103 -0
  241. package/dist/levels/prose/prose-block-elements.d.ts +25 -0
  242. package/dist/levels/prose/prose-block-elements.js +313 -0
  243. package/dist/levels/prose/prose-inline-elements.d.ts +13 -0
  244. package/dist/levels/prose/prose-inline-elements.js +143 -0
  245. package/dist/levels/prose/prose-prepare.d.ts +50 -0
  246. package/dist/levels/prose/prose-prepare.js +246 -0
  247. package/dist/levels/prose/remote-image-policy.d.ts +34 -0
  248. package/dist/levels/prose/remote-image-policy.js +153 -0
  249. package/dist/levels/prose/variant-root.d.ts +9 -0
  250. package/dist/levels/prose/variant-root.js +34 -0
  251. package/dist/levels/rich-content-types.d.ts +93 -0
  252. package/dist/levels/rich-content-types.js +4 -0
  253. package/dist/levels/server/DelimiterViolationReport.d.ts +7 -0
  254. package/dist/levels/server/DelimiterViolationReport.js +24 -0
  255. package/dist/levels/server/RichContentServer.d.ts +27 -0
  256. package/dist/levels/server/RichContentServer.js +97 -0
  257. package/dist/levels/standard/NestedRichContent.d.ts +7 -0
  258. package/dist/levels/standard/NestedRichContent.js +70 -0
  259. package/dist/levels/standard/StandardBlocks.d.ts +13 -0
  260. package/dist/levels/standard/StandardBlocks.js +239 -0
  261. package/dist/levels/standard/StandardKindRegion.d.ts +14 -0
  262. package/dist/levels/standard/StandardKindRegion.js +69 -0
  263. package/dist/levels/standard/standard-kind-region.d.ts +19 -0
  264. package/dist/levels/standard/standard-kind-region.js +21 -0
  265. package/dist/levels/standard/static-standard.d.ts +23 -0
  266. package/dist/levels/standard/static-standard.js +187 -0
  267. package/dist/levels/standard/stream-holdback.d.ts +2 -0
  268. package/dist/levels/standard/stream-holdback.js +77 -0
  269. package/dist/mermaid/MermaidFullscreen.d.ts +17 -0
  270. package/dist/mermaid/MermaidFullscreen.js +71 -0
  271. package/dist/mermaid/MermaidRenderer.d.ts +20 -0
  272. package/dist/mermaid/MermaidRenderer.js +267 -0
  273. package/dist/mermaid/MermaidView.d.ts +27 -0
  274. package/dist/mermaid/MermaidView.js +68 -0
  275. package/dist/mermaid/MermaidViewport.d.ts +75 -0
  276. package/dist/mermaid/MermaidViewport.js +286 -0
  277. package/dist/mermaid/adapters/er.d.ts +10 -0
  278. package/dist/mermaid/adapters/er.js +205 -0
  279. package/dist/mermaid/adapters/flowchart.d.ts +17 -0
  280. package/dist/mermaid/adapters/flowchart.js +634 -0
  281. package/dist/mermaid/adapters/journey.d.ts +9 -0
  282. package/dist/mermaid/adapters/journey.js +207 -0
  283. package/dist/mermaid/adapters/mindmap.d.ts +12 -0
  284. package/dist/mermaid/adapters/mindmap.js +252 -0
  285. package/dist/mermaid/adapters/pie.d.ts +7 -0
  286. package/dist/mermaid/adapters/pie.js +172 -0
  287. package/dist/mermaid/adapters/quadrant.d.ts +8 -0
  288. package/dist/mermaid/adapters/quadrant.js +231 -0
  289. package/dist/mermaid/adapters/register.d.ts +7 -0
  290. package/dist/mermaid/adapters/register.js +19 -0
  291. package/dist/mermaid/adapters/sequence.d.ts +8 -0
  292. package/dist/mermaid/adapters/sequence.js +251 -0
  293. package/dist/mermaid/adapters/state.d.ts +12 -0
  294. package/dist/mermaid/adapters/state.js +245 -0
  295. package/dist/mermaid/adapters/timeline.d.ts +8 -0
  296. package/dist/mermaid/adapters/timeline.js +245 -0
  297. package/dist/mermaid/catalog.d.ts +33 -0
  298. package/dist/mermaid/catalog.js +202 -0
  299. package/dist/mermaid/diagram-type.d.ts +39 -0
  300. package/dist/mermaid/diagram-type.js +89 -0
  301. package/dist/mermaid/export.d.ts +21 -0
  302. package/dist/mermaid/export.js +112 -0
  303. package/dist/mermaid/extract-fence.d.ts +15 -0
  304. package/dist/mermaid/extract-fence.js +22 -0
  305. package/dist/mermaid/lazy-draw.d.ts +40 -0
  306. package/dist/mermaid/lazy-draw.js +168 -0
  307. package/dist/mermaid/model/adapter.d.ts +28 -0
  308. package/dist/mermaid/model/adapter.js +16 -0
  309. package/dist/mermaid/model/ops.d.ts +282 -0
  310. package/dist/mermaid/model/ops.js +9 -0
  311. package/dist/mermaid/model/round-trip.d.ts +22 -0
  312. package/dist/mermaid/model/round-trip.js +45 -0
  313. package/dist/mermaid/model/types.d.ts +271 -0
  314. package/dist/mermaid/model/types.js +0 -0
  315. package/dist/mermaid/print-render.d.ts +9 -0
  316. package/dist/mermaid/print-render.js +39 -0
  317. package/dist/mermaid/runtime.d.ts +25 -0
  318. package/dist/mermaid/runtime.js +183 -0
  319. package/dist/mermaid/sanitize.d.ts +46 -0
  320. package/dist/mermaid/sanitize.js +234 -0
  321. package/dist/mermaid/types.d.ts +43 -0
  322. package/dist/mermaid/types.js +21 -0
  323. package/dist/mermaid/view/ViewModePane.d.ts +24 -0
  324. package/dist/mermaid/view/ViewModePane.js +9 -0
  325. package/dist/utils/client-lazy.d.ts +1 -1
  326. package/dist/utils/client-lazy.js +4 -1
  327. package/dist/utils/lifted/DiffView.d.ts +10 -0
  328. package/dist/utils/lifted/DiffView.js +26 -0
  329. package/dist/utils/lifted/IconButton.d.ts +24 -0
  330. package/dist/utils/lifted/IconButton.js +43 -0
  331. package/dist/utils/lifted/MatrxMiniLoader.d.ts +1 -0
  332. package/dist/utils/lifted/MatrxMiniLoader.js +8 -0
  333. package/dist/utils/lifted/ShimmerText.d.ts +5 -0
  334. package/dist/utils/lifted/ShimmerText.js +21 -0
  335. package/dist/utils/lifted/SuspenseLoader.d.ts +16 -0
  336. package/dist/utils/lifted/SuspenseLoader.js +42 -0
  337. package/dist/utils/lifted/Tooltip.d.ts +20 -0
  338. package/dist/utils/lifted/Tooltip.js +52 -0
  339. package/dist/utils/lifted/artifactId.d.ts +34 -0
  340. package/dist/utils/lifted/artifactId.js +15 -0
  341. package/dist/utils/lifted/canvasContent.d.ts +63 -0
  342. package/dist/utils/lifted/canvasContent.js +98 -0
  343. package/dist/utils/lifted/captureReactError.d.ts +24 -0
  344. package/dist/utils/lifted/captureReactError.js +28 -0
  345. package/dist/utils/lifted/chunk-load-recovery.d.ts +25 -0
  346. package/dist/utils/lifted/chunk-load-recovery.js +36 -0
  347. package/dist/utils/lifted/code-editor-agent-types.d.ts +6 -0
  348. package/dist/utils/lifted/code-editor-agent-types.js +0 -0
  349. package/dist/utils/lifted/code-editor-agents.d.ts +39 -0
  350. package/dist/utils/lifted/code-editor-agents.js +52 -0
  351. package/dist/utils/lifted/code-language-extension.d.ts +1 -0
  352. package/dist/utils/lifted/code-language-extension.js +60 -0
  353. package/dist/utils/lifted/custom-icons.d.ts +16 -0
  354. package/dist/utils/lifted/custom-icons.js +47 -0
  355. package/dist/utils/lifted/durability.d.ts +16 -0
  356. package/dist/utils/lifted/durability.js +45 -0
  357. package/dist/utils/lifted/errors.d.ts +30 -0
  358. package/dist/utils/lifted/errors.js +29 -0
  359. package/dist/utils/lifted/html-document.d.ts +1 -0
  360. package/dist/utils/lifted/html-document.js +12 -0
  361. package/dist/utils/lifted/languageOptions.d.ts +9 -0
  362. package/dist/utils/lifted/languageOptions.js +52 -0
  363. package/dist/utils/lifted/languages.d.ts +34 -0
  364. package/dist/utils/lifted/languages.js +175 -0
  365. package/dist/utils/lifted/loading-spinner.d.ts +18 -0
  366. package/dist/utils/lifted/loading-spinner.js +200 -0
  367. package/dist/utils/lifted/media-refs.d.ts +13 -0
  368. package/dist/utils/lifted/media-refs.js +27 -0
  369. package/dist/utils/lifted/scroll-root.d.ts +1 -0
  370. package/dist/utils/lifted/scroll-root.js +25 -0
  371. package/dist/utils/lifted/syntax-themes.d.ts +32 -0
  372. package/dist/utils/lifted/syntax-themes.js +100 -0
  373. package/dist/utils/lifted/url-utm.d.ts +24 -0
  374. package/dist/utils/lifted/url-utm.js +66 -0
  375. package/dist/utils/lifted/use-is-mounted.d.ts +24 -0
  376. package/dist/utils/lifted/use-is-mounted.js +21 -0
  377. package/dist/utils/lifted/useToastManager.d.ts +1 -0
  378. package/dist/utils/lifted/useToastManager.js +7 -0
  379. package/dist/utils/report-kind-at-raw-renderer.d.ts +19 -0
  380. package/dist/utils/report-kind-at-raw-renderer.js +32 -0
  381. package/package.json +32 -3
@@ -0,0 +1,279 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import {
3
+ FileCode,
4
+ Coffee,
5
+ Hash,
6
+ Globe,
7
+ File,
8
+ Code2,
9
+ Terminal,
10
+ FileText,
11
+ Braces,
12
+ GitCompare
13
+ } from "lucide-react";
14
+ import { cn } from "@ai-matrx/design-system";
15
+ import {
16
+ SiKotlin,
17
+ SiSwift,
18
+ SiDocker,
19
+ SiGraphql,
20
+ SiRuby,
21
+ SiGo,
22
+ SiRust,
23
+ SiR
24
+ } from "react-icons/si";
25
+ import { SiJavascript } from "react-icons/si";
26
+ import { SiTypescript } from "react-icons/si";
27
+ import { PiFileSqlBold } from "react-icons/pi";
28
+ import { TwoColorPythonIcon } from "../utils/lifted/custom-icons.js";
29
+ const DEFAULT_ICON_SIZE = 18;
30
+ const MOBILE_ICON_SIZE = 14;
31
+ const languageMap = {
32
+ code: {
33
+ name: "Code",
34
+ icon: (props) => /* @__PURE__ */ jsx(Code2, { ...props }),
35
+ color: "text-blue-500",
36
+ size: DEFAULT_ICON_SIZE
37
+ },
38
+ diff: {
39
+ name: "Diff",
40
+ icon: (props) => /* @__PURE__ */ jsx(GitCompare, { ...props }),
41
+ color: "text-emerald-500",
42
+ size: DEFAULT_ICON_SIZE
43
+ },
44
+ javascript: {
45
+ name: "JavaScript",
46
+ icon: (props) => /* @__PURE__ */ jsx(SiJavascript, { ...props }),
47
+ color: "text-yellow-500",
48
+ size: DEFAULT_ICON_SIZE
49
+ },
50
+ typescript: {
51
+ name: "TypeScript",
52
+ icon: (props) => /* @__PURE__ */ jsx(SiTypescript, { ...props }),
53
+ color: "text-blue-500",
54
+ size: DEFAULT_ICON_SIZE
55
+ },
56
+ jsx: {
57
+ name: "JavaScript",
58
+ icon: (props) => /* @__PURE__ */ jsx(SiJavascript, { ...props }),
59
+ color: "text-yellow-500",
60
+ size: DEFAULT_ICON_SIZE
61
+ },
62
+ tsx: {
63
+ name: "TypeScript",
64
+ icon: (props) => /* @__PURE__ */ jsx(SiTypescript, { ...props }),
65
+ color: "text-blue-500",
66
+ size: DEFAULT_ICON_SIZE
67
+ },
68
+ python: {
69
+ name: "Python",
70
+ icon: () => /* @__PURE__ */ jsx(TwoColorPythonIcon, {}),
71
+ // Python icon already has perfect size
72
+ color: "text-green-500",
73
+ size: null
74
+ // null means use the icon's default size
75
+ },
76
+ java: {
77
+ name: "Java",
78
+ icon: (props) => /* @__PURE__ */ jsx(Coffee, { ...props }),
79
+ color: "text-red-500",
80
+ size: DEFAULT_ICON_SIZE
81
+ },
82
+ csharp: {
83
+ name: "C#",
84
+ icon: (props) => /* @__PURE__ */ jsx(Hash, { ...props }),
85
+ color: "text-purple-500",
86
+ size: DEFAULT_ICON_SIZE
87
+ },
88
+ cpp: {
89
+ name: "C++",
90
+ icon: (props) => /* @__PURE__ */ jsx(Code2, { ...props }),
91
+ color: "text-blue-600",
92
+ size: DEFAULT_ICON_SIZE
93
+ },
94
+ sql: {
95
+ name: "SQL",
96
+ icon: (props) => /* @__PURE__ */ jsx(PiFileSqlBold, { ...props }),
97
+ color: "text-orange-500",
98
+ size: DEFAULT_ICON_SIZE
99
+ },
100
+ html: {
101
+ name: "HTML",
102
+ icon: (props) => /* @__PURE__ */ jsx(Globe, { ...props }),
103
+ color: "text-orange-600",
104
+ size: DEFAULT_ICON_SIZE
105
+ },
106
+ css: {
107
+ name: "CSS",
108
+ icon: (props) => /* @__PURE__ */ jsx(FileCode, { ...props }),
109
+ color: "text-blue-400",
110
+ size: DEFAULT_ICON_SIZE
111
+ },
112
+ php: {
113
+ name: "PHP",
114
+ icon: (props) => /* @__PURE__ */ jsx(File, { ...props }),
115
+ color: "text-indigo-500",
116
+ size: DEFAULT_ICON_SIZE
117
+ },
118
+ bash: {
119
+ name: "Bash",
120
+ icon: (props) => /* @__PURE__ */ jsx(Terminal, { ...props }),
121
+ color: "text-green-600",
122
+ size: DEFAULT_ICON_SIZE
123
+ },
124
+ shell: {
125
+ name: "Shell",
126
+ icon: (props) => /* @__PURE__ */ jsx(Terminal, { ...props }),
127
+ color: "text-gray-500",
128
+ size: DEFAULT_ICON_SIZE
129
+ },
130
+ powershell: {
131
+ name: "PowerShell",
132
+ icon: (props) => /* @__PURE__ */ jsx(Terminal, { ...props }),
133
+ color: "text-blue-700",
134
+ size: DEFAULT_ICON_SIZE
135
+ },
136
+ ruby: {
137
+ name: "Ruby",
138
+ icon: (props) => /* @__PURE__ */ jsx(SiRuby, { ...props }),
139
+ color: "text-red-600",
140
+ size: DEFAULT_ICON_SIZE
141
+ },
142
+ go: {
143
+ name: "Go",
144
+ icon: (props) => /* @__PURE__ */ jsx(SiGo, { ...props }),
145
+ color: "text-cyan-500",
146
+ size: DEFAULT_ICON_SIZE
147
+ },
148
+ rust: {
149
+ name: "Rust",
150
+ icon: (props) => /* @__PURE__ */ jsx(SiRust, { ...props }),
151
+ color: "text-orange-700",
152
+ size: DEFAULT_ICON_SIZE
153
+ },
154
+ json: {
155
+ name: "JSON",
156
+ icon: (props) => /* @__PURE__ */ jsx(Braces, { ...props }),
157
+ color: "text-yellow-600",
158
+ size: DEFAULT_ICON_SIZE
159
+ },
160
+ yaml: {
161
+ name: "YAML",
162
+ icon: (props) => /* @__PURE__ */ jsx(FileText, { ...props }),
163
+ color: "text-purple-400",
164
+ size: DEFAULT_ICON_SIZE
165
+ },
166
+ xml: {
167
+ name: "XML",
168
+ icon: (props) => /* @__PURE__ */ jsx(FileCode, { ...props }),
169
+ color: "text-blue-300",
170
+ size: DEFAULT_ICON_SIZE
171
+ },
172
+ markdown: {
173
+ name: "Markdown",
174
+ icon: (props) => /* @__PURE__ */ jsx(FileText, { ...props }),
175
+ color: "text-gray-600",
176
+ size: DEFAULT_ICON_SIZE
177
+ },
178
+ r: {
179
+ name: "R",
180
+ icon: (props) => /* @__PURE__ */ jsx(SiR, { ...props }),
181
+ color: "text-blue-800",
182
+ size: DEFAULT_ICON_SIZE
183
+ },
184
+ swift: {
185
+ name: "Swift",
186
+ icon: (props) => /* @__PURE__ */ jsx(SiSwift, { ...props }),
187
+ color: "text-orange-500",
188
+ size: DEFAULT_ICON_SIZE
189
+ },
190
+ kotlin: {
191
+ name: "Kotlin",
192
+ icon: (props) => /* @__PURE__ */ jsx(SiKotlin, { ...props }),
193
+ color: "text-purple-600",
194
+ size: DEFAULT_ICON_SIZE
195
+ },
196
+ docker: {
197
+ name: "Dockerfile",
198
+ icon: (props) => /* @__PURE__ */ jsx(SiDocker, { ...props }),
199
+ color: "text-blue-500",
200
+ size: DEFAULT_ICON_SIZE
201
+ },
202
+ graphql: {
203
+ name: "GraphQL",
204
+ icon: (props) => /* @__PURE__ */ jsx(SiGraphql, { ...props }),
205
+ color: "text-pink-600",
206
+ size: DEFAULT_ICON_SIZE
207
+ }
208
+ };
209
+ const LANGUAGE_ALIASES = {
210
+ ts: "typescript",
211
+ mts: "typescript",
212
+ cts: "typescript",
213
+ js: "javascript",
214
+ mjs: "javascript",
215
+ cjs: "javascript",
216
+ py: "python",
217
+ python3: "python",
218
+ rb: "ruby",
219
+ golang: "go",
220
+ rs: "rust",
221
+ cs: "csharp",
222
+ "c#": "csharp",
223
+ "c++": "cpp",
224
+ sh: "bash",
225
+ zsh: "bash",
226
+ console: "shell",
227
+ terminal: "shell",
228
+ ps1: "powershell",
229
+ pwsh: "powershell",
230
+ yml: "yaml",
231
+ md: "markdown",
232
+ dockerfile: "docker",
233
+ kt: "kotlin",
234
+ gql: "graphql",
235
+ patch: "diff",
236
+ udiff: "diff",
237
+ htm: "html"
238
+ };
239
+ function resolveLanguageInfo(language) {
240
+ const lower = language.trim().toLowerCase();
241
+ const key = LANGUAGE_ALIASES[lower] ?? lower;
242
+ const known = languageMap[key];
243
+ if (known) return known;
244
+ if (!lower || lower === "code" || lower === "text" || lower === "plaintext") {
245
+ return languageMap.code;
246
+ }
247
+ return { ...languageMap.code, name: language.trim() };
248
+ }
249
+ function getLanguageIconNode(language, compact = false, iconOverride) {
250
+ if (iconOverride) return iconOverride;
251
+ const langInfo = resolveLanguageInfo(language);
252
+ const Icon = langInfo.icon;
253
+ const size = compact ? 14 : 16;
254
+ if (langInfo.size === null) {
255
+ return /* @__PURE__ */ jsx(Icon, { className: cn(langInfo.color) });
256
+ }
257
+ return /* @__PURE__ */ jsx(Icon, { size, className: cn(langInfo.color) });
258
+ }
259
+ const LanguageDisplay = ({
260
+ language = "code",
261
+ className,
262
+ iconSize,
263
+ isMobile
264
+ }) => {
265
+ const langInfo = resolveLanguageInfo(language);
266
+ const Icon = langInfo.icon;
267
+ const size = isMobile ? MOBILE_ICON_SIZE : iconSize || langInfo.size || DEFAULT_ICON_SIZE;
268
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-1.5", className), children: [
269
+ langInfo.size === null ? /* @__PURE__ */ jsx(Icon, { className: cn(langInfo.color) }) : /* @__PURE__ */ jsx(Icon, { size, className: cn(langInfo.color) }),
270
+ /* @__PURE__ */ jsx("span", { className: "whitespace-nowrap text-sm text-neutral-800 dark:text-neutral-200 font-mono", children: langInfo.name })
271
+ ] });
272
+ };
273
+ var LanguageDisplay_default = LanguageDisplay;
274
+ export {
275
+ LanguageDisplay_default as default,
276
+ getLanguageIconNode,
277
+ languageMap,
278
+ resolveLanguageInfo
279
+ };
@@ -0,0 +1,30 @@
1
+ export interface CodeEditorProps {
2
+ language?: string;
3
+ initialCode?: string;
4
+ path?: string;
5
+ onChange?: (value: string | undefined) => void;
6
+ runCode?: () => void;
7
+ mode?: "dark" | "light";
8
+ showFormatButton?: boolean;
9
+ showCopyButton?: boolean;
10
+ showResetButton?: boolean;
11
+ showWordWrapToggle?: boolean;
12
+ showMinimapToggle?: boolean;
13
+ autoFormat?: boolean;
14
+ defaultWordWrap?: "on" | "off";
15
+ height?: string;
16
+ readOnly?: boolean;
17
+ formatTrigger?: number;
18
+ controlledWordWrap?: "on" | "off";
19
+ controlledMinimap?: boolean;
20
+ fileExtension?: string;
21
+ /**
22
+ * Called once with the live Monaco instance when it mounts (and with `null`
23
+ * on unmount). Lets an owner reach the real editor — selection, cursor, and
24
+ * the undoable edit stack — without forking this component. Used by the
25
+ * Smart Code Editor to wire its surface write targets onto the SAME edit
26
+ * stack the user's typing uses.
27
+ */
28
+ onEditorMount?: (editor: unknown) => void;
29
+ }
30
+ export default function SmallCodeEditor(props: CodeEditorProps): import("react").FunctionComponentElement<CodeEditorProps>;
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { createElement } from "react";
3
+ import { BARE_HOST_ATTR, announceBareHost, hostCapability } from "../host/registry.js";
4
+ function PlainCodeEditor(props) {
5
+ return createElement("textarea", {
6
+ ...BARE_HOST_ATTR,
7
+ className: "h-full min-h-24 w-full resize-y rounded-md border border-border bg-background p-2 font-mono text-sm",
8
+ defaultValue: props.initialCode ?? "",
9
+ readOnly: props.readOnly,
10
+ spellCheck: false,
11
+ onChange: (e) => props.onChange?.(e.target.value)
12
+ });
13
+ }
14
+ function SmallCodeEditor(props) {
15
+ const Impl = hostCapability("app")?.SmallCodeEditor;
16
+ if (Impl) return createElement(Impl, props);
17
+ announceBareHost("app.SmallCodeEditor", "code is edited in a plain text area");
18
+ return createElement(PlainCodeEditor, props);
19
+ }
20
+ export {
21
+ SmallCodeEditor as default
22
+ };
@@ -0,0 +1,35 @@
1
+ import React from "react";
2
+ interface StickyButtonsProps {
3
+ linesCount: number;
4
+ isCollapsed: boolean;
5
+ isCopied: boolean;
6
+ handleCopy: (e: React.MouseEvent) => void;
7
+ toggleCollapse?: (e?: React.MouseEvent) => void;
8
+ }
9
+ /**
10
+ * Quick Collapse/Copy toolbar shown once the code block's own header has
11
+ * scrolled away. It is `position: sticky` inside the code block, so it pins to
12
+ * the top of whatever scroll container the block lives in (page, chat message
13
+ * list, window panel) — never to the viewport. A viewport-`fixed` toolbar
14
+ * parked itself over the (core) shell header from any scrolled panel (D153).
15
+ *
16
+ * The outer box is zero-height so it consumes no layout space; the buttons
17
+ * hang inside it absolutely. Sticky stops at the code block's bottom edge
18
+ * because the block is the sticky element's containing block.
19
+ *
20
+ * One offset is needed. `.shell-main` is pulled up by `-(--shell-header-h)` so
21
+ * (core) content scrolls BEHIND the transparent glass header — and any pane
22
+ * that fills it (`/chat`'s conversation column is `absolute inset-0` inside it)
23
+ * inherits that: the scrollport's top edge sits UNDER the header, not below it.
24
+ * So `top: 0` there would pin the toolbar right back onto the header, which is
25
+ * the whole defect.
26
+ *
27
+ * Rather than name the containers that do this — the first version of this fix
28
+ * checked for `.shell-main` and missed /chat exactly this way — measure it: how
29
+ * much of the fixed header actually overlaps our scrollport. Panes that start
30
+ * below the header overlap by nothing and get `top: 0`. Measured once when the
31
+ * toolbar mounts; the header is a fixed height and the scrollport's top edge
32
+ * does not move under it, so there is nothing to re-measure on resize.
33
+ */
34
+ declare const StickyButtons: React.FC<StickyButtonsProps>;
35
+ export default StickyButtons;
@@ -0,0 +1,88 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { STICKY_CHROME_SELECTOR, stickyRestInset } from "./sticky-inset.js";
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { Copy, Check } from "lucide-react";
5
+ import { BsChevronBarContract, BsChevronBarExpand } from "react-icons/bs";
6
+ import { cn } from "@ai-matrx/design-system";
7
+ const StickyButtons = ({
8
+ linesCount,
9
+ isCollapsed,
10
+ isCopied,
11
+ handleCopy,
12
+ toggleCollapse
13
+ }) => {
14
+ const canCollapse = linesCount > 5;
15
+ const rootRef = useRef(null);
16
+ const [topInset, setTopInset] = useState(0);
17
+ useEffect(() => {
18
+ let restTop = 0;
19
+ let scroller = null;
20
+ let node = rootRef.current?.parentElement ?? null;
21
+ while (node) {
22
+ const style = getComputedStyle(node);
23
+ if (style.overflowY === "auto" || style.overflowY === "scroll") {
24
+ restTop = node.getBoundingClientRect().top + node.clientTop + (parseFloat(style.paddingTop) || 0);
25
+ scroller = node;
26
+ break;
27
+ }
28
+ node = node.parentElement;
29
+ }
30
+ const headerBottom = document.querySelector(".shell-header")?.getBoundingClientRect().bottom ?? 0;
31
+ const chromeHeights = Array.from(
32
+ (scroller ?? document).querySelectorAll(STICKY_CHROME_SELECTOR)
33
+ ).map((el) => el.offsetHeight);
34
+ setTopInset(stickyRestInset({ headerBottom, restTop, chromeHeights }));
35
+ }, []);
36
+ const buttonClass = cn(
37
+ "py-2 px-3 rounded-lg bg-zinc-300 dark:bg-zinc-700",
38
+ "text-neutral-700 dark:text-neutral-300",
39
+ "hover:text-neutral-900 dark:hover:text-neutral-100",
40
+ "hover:bg-zinc-200 dark:hover:bg-zinc-600",
41
+ "transition-colors shadow-sm backdrop-blur-sm",
42
+ "flex items-center gap-1 text-xs"
43
+ );
44
+ return /* @__PURE__ */ jsx(
45
+ "div",
46
+ {
47
+ ref: rootRef,
48
+ className: "sticky z-20 h-0",
49
+ style: { top: topInset },
50
+ children: /* @__PURE__ */ jsxs("div", { className: "absolute right-2 top-2 flex items-center space-x-2", children: [
51
+ canCollapse && toggleCollapse && /* @__PURE__ */ jsxs(
52
+ "button",
53
+ {
54
+ onClick: (e) => {
55
+ e.stopPropagation();
56
+ toggleCollapse(e);
57
+ },
58
+ className: buttonClass,
59
+ title: isCollapsed ? "Expand code" : "Collapse code",
60
+ children: [
61
+ isCollapsed ? /* @__PURE__ */ jsx(BsChevronBarExpand, { size: 16 }) : /* @__PURE__ */ jsx(BsChevronBarContract, { size: 16 }),
62
+ /* @__PURE__ */ jsx("span", { children: isCollapsed ? "Expand" : "Collapse" })
63
+ ]
64
+ }
65
+ ),
66
+ /* @__PURE__ */ jsxs(
67
+ "button",
68
+ {
69
+ onClick: (e) => {
70
+ e.stopPropagation();
71
+ handleCopy(e);
72
+ },
73
+ className: buttonClass,
74
+ title: isCopied ? "Copied!" : "Copy code",
75
+ children: [
76
+ isCopied ? /* @__PURE__ */ jsx(Check, { size: 16 }) : /* @__PURE__ */ jsx(Copy, { size: 16 }),
77
+ /* @__PURE__ */ jsx("span", { children: "Copy" })
78
+ ]
79
+ }
80
+ )
81
+ ] })
82
+ }
83
+ );
84
+ };
85
+ var StickyButtons_default = StickyButtons;
86
+ export {
87
+ StickyButtons_default as default
88
+ };
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ export interface ShikiCodeViewProps {
3
+ code: string;
4
+ /** The fence language as written (`ts`, `python`, `diff`, …). */
5
+ language: string | undefined;
6
+ mode: "light" | "dark";
7
+ showLineNumbers?: boolean;
8
+ /** Number shown on the first line (fence `showLineNumbers{10}`). */
9
+ startLine?: number;
10
+ wrapLines?: boolean;
11
+ fontSize?: number;
12
+ /** 1-based source line numbers to highlight. */
13
+ highlightLines?: readonly number[];
14
+ /**
15
+ * "theme" paints the theme's own background (a standalone code surface);
16
+ * "transparent" sits on the host's surface (compact snippets, previews).
17
+ */
18
+ surface?: "theme" | "transparent";
19
+ /** Vertical/horizontal padding in rem (default 1 / 1). */
20
+ padding?: {
21
+ y: number;
22
+ x: number;
23
+ };
24
+ className?: string;
25
+ }
26
+ export declare function ShikiCodeView({ code, language, mode, showLineNumbers, startLine, wrapLines, fontSize, highlightLines, surface, padding, className, }: ShikiCodeViewProps): React.JSX.Element;
@@ -0,0 +1,134 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { cn } from "@ai-matrx/design-system";
4
+ import {
5
+ useHighlightedLines
6
+ } from "./useHighlightedLines.js";
7
+ const DIFF_LANGUAGES = /* @__PURE__ */ new Set(["diff", "patch", "udiff"]);
8
+ function diffKind(text) {
9
+ if (text.startsWith("+++") || text.startsWith("---")) return null;
10
+ if (text.startsWith("+")) return "add";
11
+ if (text.startsWith("-")) return "remove";
12
+ if (text.startsWith("@@")) return "hunk";
13
+ return null;
14
+ }
15
+ const DIFF_CLASS = {
16
+ add: "bg-emerald-500/15 dark:bg-emerald-400/15",
17
+ remove: "bg-red-500/15 dark:bg-red-400/15",
18
+ hunk: "bg-sky-500/10 dark:bg-sky-400/10"
19
+ };
20
+ function plainLines(text) {
21
+ return text.split("\n").map((line) => line ? [{ content: line }] : []);
22
+ }
23
+ function mergeTail(lines, tail) {
24
+ if (!tail) return lines;
25
+ const merged = lines.map((line) => [...line]);
26
+ const [first, ...rest] = tail.split("\n");
27
+ if (first) merged[merged.length - 1].push({ content: first });
28
+ for (const line of rest) merged.push(line ? [{ content: line }] : []);
29
+ return merged;
30
+ }
31
+ function tokenStyle(token, mode) {
32
+ const color = mode === "dark" ? token.dark : token.light;
33
+ const style = token.fontStyle ?? 0;
34
+ if (!color && !style) return void 0;
35
+ return {
36
+ color,
37
+ fontStyle: style & 1 ? "italic" : void 0,
38
+ fontWeight: style & 2 ? 600 : void 0,
39
+ textDecoration: style & 4 ? "underline" : void 0
40
+ };
41
+ }
42
+ function ShikiCodeView({
43
+ code,
44
+ language,
45
+ mode,
46
+ showLineNumbers = false,
47
+ startLine = 1,
48
+ wrapLines = true,
49
+ fontSize = 12,
50
+ highlightLines,
51
+ surface = "theme",
52
+ padding = { y: 1, x: 1 },
53
+ className
54
+ }) {
55
+ const highlighted = useHighlightedLines(code, language);
56
+ const lines = highlighted.lines && code.startsWith(highlighted.source) ? mergeTail(highlighted.lines, code.slice(highlighted.source.length)) : plainLines(code);
57
+ const background = surface === "transparent" ? "transparent" : highlighted.background?.[mode] ?? (mode === "dark" ? "#1e1e1e" : "#ffffff");
58
+ const foreground = surface === "transparent" ? void 0 : mode === "dark" ? "#d4d4d4" : "#000000";
59
+ const highlightSet = new Set(highlightLines ?? []);
60
+ const isDiff = DIFF_LANGUAGES.has((language ?? "").toLowerCase());
61
+ const lastNumber = startLine + lines.length - 1;
62
+ const gutterWidth = `${String(lastNumber).length + 1}ch`;
63
+ const whiteSpace = wrapLines ? "pre-wrap" : "pre";
64
+ return /* @__PURE__ */ jsx(
65
+ "pre",
66
+ {
67
+ className: cn("m-0 font-mono leading-[1.5]", className),
68
+ "data-language": language ?? "text",
69
+ style: {
70
+ background,
71
+ color: foreground,
72
+ fontSize: `${fontSize}px`,
73
+ padding: `${padding.y}rem 0`,
74
+ overflowX: wrapLines ? "hidden" : "auto",
75
+ maxWidth: "100%"
76
+ },
77
+ children: /* @__PURE__ */ jsx(
78
+ "code",
79
+ {
80
+ className: `language-${language ?? "text"} block`,
81
+ style: { minWidth: wrapLines ? void 0 : "max-content" },
82
+ children: lines.map((tokens, index) => {
83
+ const lineNumber = startLine + index;
84
+ const sourceLine = index + 1;
85
+ const text = isDiff ? tokens.map((t) => t.content).join("") : "";
86
+ const kind = isDiff ? diffKind(text) : null;
87
+ const marked = highlightSet.has(sourceLine);
88
+ return /* @__PURE__ */ jsxs(
89
+ "span",
90
+ {
91
+ "data-line": sourceLine,
92
+ "data-highlighted": marked || void 0,
93
+ "data-diff": kind ?? void 0,
94
+ style: { paddingInline: `${padding.x}rem` },
95
+ className: cn(
96
+ "flex",
97
+ kind && DIFF_CLASS[kind],
98
+ marked && "bg-primary/10 shadow-[inset_3px_0_0_hsl(var(--primary))]"
99
+ ),
100
+ children: [
101
+ showLineNumbers && /* @__PURE__ */ jsx(
102
+ "span",
103
+ {
104
+ "aria-hidden": "true",
105
+ className: "shrink-0 select-none pr-4 text-right opacity-45",
106
+ style: { minWidth: gutterWidth },
107
+ children: lineNumber
108
+ }
109
+ ),
110
+ /* @__PURE__ */ jsx(
111
+ "span",
112
+ {
113
+ className: "min-w-0 flex-1",
114
+ style: {
115
+ whiteSpace,
116
+ overflowWrap: wrapLines ? "anywhere" : "normal",
117
+ minHeight: "1.5em"
118
+ },
119
+ children: tokens.map((token, t) => /* @__PURE__ */ jsx("span", { style: tokenStyle(token, mode), children: token.content }, t))
120
+ }
121
+ )
122
+ ]
123
+ },
124
+ index
125
+ );
126
+ })
127
+ }
128
+ )
129
+ }
130
+ );
131
+ }
132
+ export {
133
+ ShikiCodeView
134
+ };
@@ -0,0 +1,14 @@
1
+ import { type HighlighterCore } from "shiki/core";
2
+ export declare const SHIKI_THEME: {
3
+ readonly light: "matrx-light";
4
+ readonly dark: "matrx-dark";
5
+ };
6
+ /** The shared highlighter (created once, on first use). */
7
+ export declare function getHighlighter(): Promise<HighlighterCore>;
8
+ /**
9
+ * The Shiki language id for a fence language, or "text" when Shiki has no
10
+ * grammar for it (the block then renders as plain, readable text).
11
+ */
12
+ export declare function resolveShikiLanguage(raw: string | undefined | null): string;
13
+ /** Load a language grammar into the shared highlighter (once). */
14
+ export declare function ensureLanguage(highlighter: HighlighterCore, language: string): Promise<void>;