@ai-matrx/rich-content 0.2.3 → 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 (382) hide show
  1. package/CHANGELOG.md +22 -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/csv/CsvBlock.js +5 -1
  51. package/dist/display/blocks/diagram/DiagramLoadingVisualization.d.ts +6 -0
  52. package/dist/display/blocks/diagram/DiagramLoadingVisualization.js +190 -0
  53. package/dist/display/blocks/diagram/InteractiveDiagramBlock.d.ts +51 -0
  54. package/dist/display/blocks/diagram/InteractiveDiagramBlock.js +2415 -0
  55. package/dist/display/blocks/diagram/diagram-printer.d.ts +16 -0
  56. package/dist/display/blocks/diagram/diagram-printer.js +294 -0
  57. package/dist/display/blocks/diagram/diagram-visual-defaults.d.ts +116 -0
  58. package/dist/display/blocks/diagram/diagram-visual-defaults.js +400 -0
  59. package/dist/display/blocks/diagram/layout-utils.d.ts +90 -0
  60. package/dist/display/blocks/diagram/layout-utils.js +347 -0
  61. package/dist/display/blocks/diagram/parseDiagramJSON.d.ts +105 -0
  62. package/dist/display/blocks/diagram/parseDiagramJSON.js +296 -0
  63. package/dist/display/blocks/diagram/presentation-direction.d.ts +29 -0
  64. package/dist/display/blocks/diagram/presentation-direction.js +19 -0
  65. package/dist/display/blocks/diagram/ui-utils.d.ts +1 -0
  66. package/dist/display/blocks/diagram/ui-utils.js +18 -0
  67. package/dist/display/blocks/diff/DiffBlock.d.ts +10 -0
  68. package/dist/display/blocks/diff/DiffBlock.js +119 -0
  69. package/dist/display/blocks/diff/DiffCanvas.d.ts +15 -0
  70. package/dist/display/blocks/diff/DiffCanvas.js +20 -0
  71. package/dist/display/blocks/generic/GenericStructuredBlock.d.ts +24 -0
  72. package/dist/display/blocks/generic/GenericStructuredBlock.js +53 -0
  73. package/dist/display/blocks/generic/StructuredValueTabs.d.ts +21 -0
  74. package/dist/display/blocks/generic/StructuredValueTabs.js +124 -0
  75. package/dist/display/blocks/generic/tile-actions-slot.d.ts +39 -0
  76. package/dist/display/blocks/generic/tile-actions-slot.js +33 -0
  77. package/dist/display/blocks/images/ImageBlock.d.ts +8 -0
  78. package/dist/display/blocks/images/ImageBlock.js +265 -0
  79. package/dist/display/blocks/json/JsonBlock.d.ts +34 -0
  80. package/dist/display/blocks/json/JsonBlock.js +562 -0
  81. package/dist/display/blocks/json/JsonTableView.d.ts +10 -0
  82. package/dist/display/blocks/json/JsonTableView.js +173 -0
  83. package/dist/display/blocks/json/json-compact-stringify.d.ts +25 -0
  84. package/dist/display/blocks/json/json-compact-stringify.js +52 -0
  85. package/dist/display/blocks/json/json-tabular-utils.d.ts +65 -0
  86. package/dist/display/blocks/json/json-tabular-utils.js +121 -0
  87. package/dist/display/blocks/links/LinkComponent.d.ts +6 -0
  88. package/dist/display/blocks/links/LinkComponent.js +373 -0
  89. package/dist/display/blocks/links/LinkComponentWithFetch.d.ts +1 -0
  90. package/dist/display/blocks/links/LinkComponentWithFetch.js +0 -0
  91. package/dist/display/blocks/markdown/MarkdownKindBlock.d.ts +48 -0
  92. package/dist/display/blocks/markdown/MarkdownKindBlock.js +52 -0
  93. package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.d.ts +17 -0
  94. package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.js +70 -0
  95. package/dist/display/blocks/mermaid/MermaidBlock.d.ts +19 -0
  96. package/dist/display/blocks/mermaid/MermaidBlock.js +386 -0
  97. package/dist/display/blocks/search-replace/SearchReplaceBlock.d.ts +50 -0
  98. package/dist/display/blocks/search-replace/SearchReplaceBlock.js +71 -0
  99. package/dist/display/blocks/svg/SvgBlock.d.ts +8 -0
  100. package/dist/display/blocks/svg/SvgBlock.js +126 -0
  101. package/dist/display/blocks/table/StreamingTableRenderer.d.ts +53 -0
  102. package/dist/display/blocks/table/StreamingTableRenderer.js +907 -0
  103. package/dist/display/blocks/table/TableRenderPathDiagnostic.d.ts +21 -0
  104. package/dist/display/blocks/table/TableRenderPathDiagnostic.js +79 -0
  105. package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.d.ts +14 -0
  106. package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.js +15 -0
  107. package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.d.ts +13 -0
  108. package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.js +19 -0
  109. package/dist/display/blocks/thinking-reasoning/ThinkingTrace.d.ts +30 -0
  110. package/dist/display/blocks/thinking-reasoning/ThinkingTrace.js +75 -0
  111. package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.d.ts +13 -0
  112. package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.js +48 -0
  113. package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.d.ts +12 -0
  114. package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.js +19 -0
  115. package/dist/display/blocks/toml/TomlBlock.d.ts +7 -0
  116. package/dist/display/blocks/toml/TomlBlock.js +167 -0
  117. package/dist/display/blocks/tree/TreeBlock.d.ts +7 -0
  118. package/dist/display/blocks/tree/TreeBlock.js +163 -0
  119. package/dist/display/blocks/xml/XmlBlock.d.ts +23 -0
  120. package/dist/display/blocks/xml/XmlBlock.js +197 -0
  121. package/dist/display/blocks/xml/readXmlTag.d.ts +1 -0
  122. package/dist/display/blocks/xml/readXmlTag.js +1 -0
  123. package/dist/display/blocks/xml/xml-tokenize.d.ts +13 -0
  124. package/dist/display/blocks/xml/xml-tokenize.js +169 -0
  125. package/dist/display/blocks/yaml/YamlBlock.d.ts +7 -0
  126. package/dist/display/blocks/yaml/YamlBlock.js +191 -0
  127. package/dist/display/chat-markdown/BasicMarkdownContent.d.ts +29 -0
  128. package/dist/display/chat-markdown/BasicMarkdownContent.js +122 -0
  129. package/dist/display/chat-markdown/BlockRenderingContext.d.ts +23 -0
  130. package/dist/display/chat-markdown/BlockRenderingContext.js +17 -0
  131. package/dist/display/chat-markdown/ConfigurableMarkdownContent.d.ts +172 -0
  132. package/dist/display/chat-markdown/ConfigurableMarkdownContent.js +649 -0
  133. package/dist/display/chat-markdown/InlineCodeSnippet.d.ts +19 -0
  134. package/dist/display/chat-markdown/InlineCodeSnippet.js +146 -0
  135. package/dist/display/chat-markdown/InlineCodeSnippetKindGate.d.ts +11 -0
  136. package/dist/display/chat-markdown/InlineCodeSnippetKindGate.js +9 -0
  137. package/dist/display/chat-markdown/KindTextGate.d.ts +31 -0
  138. package/dist/display/chat-markdown/KindTextGate.js +60 -0
  139. package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.d.ts +6 -0
  140. package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.js +92 -0
  141. package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.d.ts +72 -0
  142. package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.js +94 -0
  143. package/dist/display/chat-markdown/block-registry/BlockRenderer.d.ts +126 -0
  144. package/dist/display/chat-markdown/block-registry/BlockRenderer.js +473 -0
  145. package/dist/display/chat-markdown/block-registry/block-dispatch.d.ts +410 -0
  146. package/dist/display/chat-markdown/block-registry/block-dispatch.js +495 -0
  147. package/dist/display/chat-markdown/block-registry/json-parse-utils.d.ts +13 -0
  148. package/dist/display/chat-markdown/block-registry/json-parse-utils.js +236 -0
  149. package/dist/display/chat-markdown/constants.d.ts +14 -0
  150. package/dist/display/chat-markdown/constants.js +317 -0
  151. package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.d.ts +31 -0
  152. package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.js +62 -0
  153. package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.d.ts +12 -0
  154. package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.js +18 -0
  155. package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.d.ts +22 -0
  156. package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.js +130 -0
  157. package/dist/display/chat-markdown/diff-blocks/diff-style-registry.d.ts +21 -0
  158. package/dist/display/chat-markdown/diff-blocks/diff-style-registry.js +91 -0
  159. package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.d.ts +26 -0
  160. package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.js +186 -0
  161. package/dist/display/chat-markdown/diff-blocks/types.d.ts +56 -0
  162. package/dist/display/chat-markdown/diff-blocks/types.js +0 -0
  163. package/dist/display/chat-markdown/internal-handlers/BlockFallback.d.ts +20 -0
  164. package/dist/display/chat-markdown/internal-handlers/BlockFallback.js +83 -0
  165. package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.d.ts +4 -0
  166. package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.js +16 -0
  167. package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.d.ts +17 -0
  168. package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.js +40 -0
  169. package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.d.ts +8 -0
  170. package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.js +91 -0
  171. package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.d.ts +20 -0
  172. package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.js +72 -0
  173. package/dist/display/chat-markdown/kind-source-view.d.ts +14 -0
  174. package/dist/display/chat-markdown/kind-source-view.js +14 -0
  175. package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.d.ts +28 -0
  176. package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.js +65 -0
  177. package/dist/display/chat-markdown/progressive-mount.d.ts +18 -0
  178. package/dist/display/chat-markdown/progressive-mount.js +90 -0
  179. package/dist/display/chat-markdown/render-block-to-content-block.d.ts +31 -0
  180. package/dist/display/chat-markdown/render-block-to-content-block.js +32 -0
  181. package/dist/display/chat-markdown/settle-stream-blocks.d.ts +50 -0
  182. package/dist/display/chat-markdown/settle-stream-blocks.js +26 -0
  183. package/dist/display/chat-markdown/stable-blocks.d.ts +15 -0
  184. package/dist/display/chat-markdown/stable-blocks.js +54 -0
  185. package/dist/display/chat-markdown/types.d.ts +11 -0
  186. package/dist/display/chat-markdown/types.js +26 -0
  187. package/dist/display/specimen/SpecimenContext.d.ts +26 -0
  188. package/dist/display/specimen/SpecimenContext.js +64 -0
  189. package/dist/display/tables/MarkdownTable.d.ts +23 -0
  190. package/dist/display/tables/MarkdownTable.js +769 -0
  191. package/dist/display/tables/MarkdownTableScrollArea.d.ts +12 -0
  192. package/dist/display/tables/MarkdownTableScrollArea.js +92 -0
  193. package/dist/display/tables/SendToGoogleSheetButton.d.ts +19 -0
  194. package/dist/display/tables/SendToGoogleSheetButton.js +93 -0
  195. package/dist/display/tables/SendToWorkbookButton.d.ts +24 -0
  196. package/dist/display/tables/SendToWorkbookButton.js +93 -0
  197. package/dist/display/tables/TableSaveToMenu.d.ts +16 -0
  198. package/dist/display/tables/TableSaveToMenu.js +98 -0
  199. package/dist/display/tables/TableWithSeparatedControls.d.ts +22 -0
  200. package/dist/display/tables/TableWithSeparatedControls.js +574 -0
  201. package/dist/display/tables/ViewTableModal.d.ts +14 -0
  202. package/dist/display/tables/ViewTableModal.js +67 -0
  203. package/dist/display/tables/editing/ColumnActionsMenu.d.ts +16 -0
  204. package/dist/display/tables/editing/ColumnActionsMenu.js +80 -0
  205. package/dist/display/tables/editing/RowActionsMenu.d.ts +16 -0
  206. package/dist/display/tables/editing/RowActionsMenu.js +80 -0
  207. package/dist/display/tables/editing/TableEditToolbar.d.ts +15 -0
  208. package/dist/display/tables/editing/TableEditToolbar.js +63 -0
  209. package/dist/display/tables/editing/tableMutations.d.ts +50 -0
  210. package/dist/display/tables/editing/tableMutations.js +148 -0
  211. package/dist/display/tables/editing/useDoubleClickEdit.d.ts +43 -0
  212. package/dist/display/tables/editing/useDoubleClickEdit.js +51 -0
  213. package/dist/display/tables/editing/useTableUndo.d.ts +25 -0
  214. package/dist/display/tables/editing/useTableUndo.js +17 -0
  215. package/dist/display/tables/table-action-row.d.ts +8 -0
  216. package/dist/display/tables/table-action-row.js +31 -0
  217. package/dist/display/tables/table-viewer.d.ts +13 -0
  218. package/dist/display/tables/table-viewer.js +18 -0
  219. package/dist/host/ErrorActions.d.ts +1 -1
  220. package/dist/host/ErrorNotice.d.ts +10 -0
  221. package/dist/host/ErrorNotice.js +19 -0
  222. package/dist/host/app-bindings.d.ts +155 -0
  223. package/dist/host/app-bindings.js +160 -0
  224. package/dist/host/diagnostics.d.ts +2 -2
  225. package/dist/host/diagnostics.js +2 -1
  226. package/dist/host/tables.d.ts +1 -6
  227. package/dist/host/types.d.ts +14 -7
  228. package/dist/levels/RichContent.d.ts +3 -0
  229. package/dist/levels/RichContent.js +102 -0
  230. package/dist/levels/RichContentInline.d.ts +28 -0
  231. package/dist/levels/RichContentInline.js +61 -0
  232. package/dist/levels/RichContentPreview.d.ts +12 -0
  233. package/dist/levels/RichContentPreview.js +39 -0
  234. package/dist/levels/RichContentStandardImpl.d.ts +12 -0
  235. package/dist/levels/RichContentStandardImpl.js +27 -0
  236. package/dist/levels/RichContentStaticProse.d.ts +46 -0
  237. package/dist/levels/RichContentStaticProse.js +100 -0
  238. package/dist/levels/depth.d.ts +18 -0
  239. package/dist/levels/depth.js +32 -0
  240. package/dist/levels/prose/inline-level-elements.d.ts +19 -0
  241. package/dist/levels/prose/inline-level-elements.js +103 -0
  242. package/dist/levels/prose/prose-block-elements.d.ts +25 -0
  243. package/dist/levels/prose/prose-block-elements.js +313 -0
  244. package/dist/levels/prose/prose-inline-elements.d.ts +13 -0
  245. package/dist/levels/prose/prose-inline-elements.js +143 -0
  246. package/dist/levels/prose/prose-prepare.d.ts +50 -0
  247. package/dist/levels/prose/prose-prepare.js +246 -0
  248. package/dist/levels/prose/remote-image-policy.d.ts +34 -0
  249. package/dist/levels/prose/remote-image-policy.js +153 -0
  250. package/dist/levels/prose/variant-root.d.ts +9 -0
  251. package/dist/levels/prose/variant-root.js +34 -0
  252. package/dist/levels/rich-content-types.d.ts +93 -0
  253. package/dist/levels/rich-content-types.js +4 -0
  254. package/dist/levels/server/DelimiterViolationReport.d.ts +7 -0
  255. package/dist/levels/server/DelimiterViolationReport.js +24 -0
  256. package/dist/levels/server/RichContentServer.d.ts +27 -0
  257. package/dist/levels/server/RichContentServer.js +97 -0
  258. package/dist/levels/standard/NestedRichContent.d.ts +7 -0
  259. package/dist/levels/standard/NestedRichContent.js +70 -0
  260. package/dist/levels/standard/StandardBlocks.d.ts +13 -0
  261. package/dist/levels/standard/StandardBlocks.js +239 -0
  262. package/dist/levels/standard/StandardKindRegion.d.ts +14 -0
  263. package/dist/levels/standard/StandardKindRegion.js +69 -0
  264. package/dist/levels/standard/standard-kind-region.d.ts +19 -0
  265. package/dist/levels/standard/standard-kind-region.js +21 -0
  266. package/dist/levels/standard/static-standard.d.ts +23 -0
  267. package/dist/levels/standard/static-standard.js +187 -0
  268. package/dist/levels/standard/stream-holdback.d.ts +2 -0
  269. package/dist/levels/standard/stream-holdback.js +77 -0
  270. package/dist/mermaid/MermaidFullscreen.d.ts +17 -0
  271. package/dist/mermaid/MermaidFullscreen.js +71 -0
  272. package/dist/mermaid/MermaidRenderer.d.ts +20 -0
  273. package/dist/mermaid/MermaidRenderer.js +267 -0
  274. package/dist/mermaid/MermaidView.d.ts +27 -0
  275. package/dist/mermaid/MermaidView.js +68 -0
  276. package/dist/mermaid/MermaidViewport.d.ts +75 -0
  277. package/dist/mermaid/MermaidViewport.js +286 -0
  278. package/dist/mermaid/adapters/er.d.ts +10 -0
  279. package/dist/mermaid/adapters/er.js +205 -0
  280. package/dist/mermaid/adapters/flowchart.d.ts +17 -0
  281. package/dist/mermaid/adapters/flowchart.js +634 -0
  282. package/dist/mermaid/adapters/journey.d.ts +9 -0
  283. package/dist/mermaid/adapters/journey.js +207 -0
  284. package/dist/mermaid/adapters/mindmap.d.ts +12 -0
  285. package/dist/mermaid/adapters/mindmap.js +252 -0
  286. package/dist/mermaid/adapters/pie.d.ts +7 -0
  287. package/dist/mermaid/adapters/pie.js +172 -0
  288. package/dist/mermaid/adapters/quadrant.d.ts +8 -0
  289. package/dist/mermaid/adapters/quadrant.js +231 -0
  290. package/dist/mermaid/adapters/register.d.ts +7 -0
  291. package/dist/mermaid/adapters/register.js +19 -0
  292. package/dist/mermaid/adapters/sequence.d.ts +8 -0
  293. package/dist/mermaid/adapters/sequence.js +251 -0
  294. package/dist/mermaid/adapters/state.d.ts +12 -0
  295. package/dist/mermaid/adapters/state.js +245 -0
  296. package/dist/mermaid/adapters/timeline.d.ts +8 -0
  297. package/dist/mermaid/adapters/timeline.js +245 -0
  298. package/dist/mermaid/catalog.d.ts +33 -0
  299. package/dist/mermaid/catalog.js +202 -0
  300. package/dist/mermaid/diagram-type.d.ts +39 -0
  301. package/dist/mermaid/diagram-type.js +89 -0
  302. package/dist/mermaid/export.d.ts +21 -0
  303. package/dist/mermaid/export.js +112 -0
  304. package/dist/mermaid/extract-fence.d.ts +15 -0
  305. package/dist/mermaid/extract-fence.js +22 -0
  306. package/dist/mermaid/lazy-draw.d.ts +40 -0
  307. package/dist/mermaid/lazy-draw.js +168 -0
  308. package/dist/mermaid/model/adapter.d.ts +28 -0
  309. package/dist/mermaid/model/adapter.js +16 -0
  310. package/dist/mermaid/model/ops.d.ts +282 -0
  311. package/dist/mermaid/model/ops.js +9 -0
  312. package/dist/mermaid/model/round-trip.d.ts +22 -0
  313. package/dist/mermaid/model/round-trip.js +45 -0
  314. package/dist/mermaid/model/types.d.ts +271 -0
  315. package/dist/mermaid/model/types.js +0 -0
  316. package/dist/mermaid/print-render.d.ts +9 -0
  317. package/dist/mermaid/print-render.js +39 -0
  318. package/dist/mermaid/runtime.d.ts +25 -0
  319. package/dist/mermaid/runtime.js +183 -0
  320. package/dist/mermaid/sanitize.d.ts +46 -0
  321. package/dist/mermaid/sanitize.js +234 -0
  322. package/dist/mermaid/types.d.ts +43 -0
  323. package/dist/mermaid/types.js +21 -0
  324. package/dist/mermaid/view/ViewModePane.d.ts +24 -0
  325. package/dist/mermaid/view/ViewModePane.js +9 -0
  326. package/dist/utils/client-lazy.d.ts +1 -1
  327. package/dist/utils/client-lazy.js +4 -1
  328. package/dist/utils/lifted/DiffView.d.ts +10 -0
  329. package/dist/utils/lifted/DiffView.js +26 -0
  330. package/dist/utils/lifted/IconButton.d.ts +24 -0
  331. package/dist/utils/lifted/IconButton.js +43 -0
  332. package/dist/utils/lifted/MatrxMiniLoader.d.ts +1 -0
  333. package/dist/utils/lifted/MatrxMiniLoader.js +8 -0
  334. package/dist/utils/lifted/ShimmerText.d.ts +5 -0
  335. package/dist/utils/lifted/ShimmerText.js +21 -0
  336. package/dist/utils/lifted/SuspenseLoader.d.ts +16 -0
  337. package/dist/utils/lifted/SuspenseLoader.js +42 -0
  338. package/dist/utils/lifted/Tooltip.d.ts +20 -0
  339. package/dist/utils/lifted/Tooltip.js +52 -0
  340. package/dist/utils/lifted/artifactId.d.ts +34 -0
  341. package/dist/utils/lifted/artifactId.js +15 -0
  342. package/dist/utils/lifted/canvasContent.d.ts +63 -0
  343. package/dist/utils/lifted/canvasContent.js +98 -0
  344. package/dist/utils/lifted/captureReactError.d.ts +24 -0
  345. package/dist/utils/lifted/captureReactError.js +28 -0
  346. package/dist/utils/lifted/chunk-load-recovery.d.ts +25 -0
  347. package/dist/utils/lifted/chunk-load-recovery.js +36 -0
  348. package/dist/utils/lifted/code-editor-agent-types.d.ts +6 -0
  349. package/dist/utils/lifted/code-editor-agent-types.js +0 -0
  350. package/dist/utils/lifted/code-editor-agents.d.ts +39 -0
  351. package/dist/utils/lifted/code-editor-agents.js +52 -0
  352. package/dist/utils/lifted/code-language-extension.d.ts +1 -0
  353. package/dist/utils/lifted/code-language-extension.js +60 -0
  354. package/dist/utils/lifted/custom-icons.d.ts +16 -0
  355. package/dist/utils/lifted/custom-icons.js +47 -0
  356. package/dist/utils/lifted/durability.d.ts +16 -0
  357. package/dist/utils/lifted/durability.js +45 -0
  358. package/dist/utils/lifted/errors.d.ts +30 -0
  359. package/dist/utils/lifted/errors.js +29 -0
  360. package/dist/utils/lifted/html-document.d.ts +1 -0
  361. package/dist/utils/lifted/html-document.js +12 -0
  362. package/dist/utils/lifted/languageOptions.d.ts +9 -0
  363. package/dist/utils/lifted/languageOptions.js +52 -0
  364. package/dist/utils/lifted/languages.d.ts +34 -0
  365. package/dist/utils/lifted/languages.js +175 -0
  366. package/dist/utils/lifted/loading-spinner.d.ts +18 -0
  367. package/dist/utils/lifted/loading-spinner.js +200 -0
  368. package/dist/utils/lifted/media-refs.d.ts +13 -0
  369. package/dist/utils/lifted/media-refs.js +27 -0
  370. package/dist/utils/lifted/scroll-root.d.ts +1 -0
  371. package/dist/utils/lifted/scroll-root.js +25 -0
  372. package/dist/utils/lifted/syntax-themes.d.ts +32 -0
  373. package/dist/utils/lifted/syntax-themes.js +100 -0
  374. package/dist/utils/lifted/url-utm.d.ts +24 -0
  375. package/dist/utils/lifted/url-utm.js +66 -0
  376. package/dist/utils/lifted/use-is-mounted.d.ts +24 -0
  377. package/dist/utils/lifted/use-is-mounted.js +21 -0
  378. package/dist/utils/lifted/useToastManager.d.ts +1 -0
  379. package/dist/utils/lifted/useToastManager.js +7 -0
  380. package/dist/utils/report-kind-at-raw-renderer.d.ts +19 -0
  381. package/dist/utils/report-kind-at-raw-renderer.js +32 -0
  382. package/package.json +32 -3
@@ -0,0 +1,202 @@
1
+ import {
2
+ ArrowRightLeft,
3
+ BarChart3,
4
+ Blocks,
5
+ Boxes,
6
+ CalendarRange,
7
+ ChartPie,
8
+ Columns3,
9
+ Database,
10
+ Footprints,
11
+ GitBranch,
12
+ Grid2x2,
13
+ Hexagon,
14
+ History,
15
+ Landmark,
16
+ ListChecks,
17
+ Network,
18
+ Radar,
19
+ Workflow
20
+ } from "lucide-react";
21
+ const MERMAID_CATALOG = {
22
+ flowchart: {
23
+ label: "Flowchart",
24
+ icon: Workflow,
25
+ description: "Steps, decisions, and arrows \u2014 processes and logic flows.",
26
+ starterTemplate: "flowchart TD\n A[Start] --> B{Decision}\n B -->|Yes| C[Do the thing]\n B -->|No| D[Do something else]\n C --> E[Done]\n D --> E",
27
+ support: "full",
28
+ featured: true
29
+ },
30
+ mindmap: {
31
+ label: "Mind Map",
32
+ icon: Network,
33
+ description: "A central idea branching into topics and subtopics.",
34
+ starterTemplate: "mindmap\n root((Main Idea))\n Topic One\n Detail A\n Detail B\n Topic Two\n Detail C",
35
+ support: "full",
36
+ featured: true
37
+ },
38
+ sequence: {
39
+ label: "Sequence Diagram",
40
+ icon: ArrowRightLeft,
41
+ description: "Who talks to whom, in what order \u2014 interactions over time.",
42
+ starterTemplate: "sequenceDiagram\n participant U as User\n participant S as System\n U->>S: Request\n S-->>U: Response",
43
+ support: "full",
44
+ featured: true
45
+ },
46
+ pie: {
47
+ label: "Pie Chart",
48
+ icon: ChartPie,
49
+ description: "Proportions of a whole, as labeled slices.",
50
+ starterTemplate: 'pie title Breakdown\n "Category A" : 45\n "Category B" : 30\n "Category C" : 25',
51
+ support: "full",
52
+ featured: true
53
+ },
54
+ timeline: {
55
+ label: "Timeline",
56
+ icon: History,
57
+ description: "Events laid out chronologically by period.",
58
+ starterTemplate: "timeline\n title Project Timeline\n 2024 : Kickoff\n 2025 : Launch : Growth\n 2026 : Expansion",
59
+ support: "full",
60
+ featured: true
61
+ },
62
+ state: {
63
+ label: "State Diagram",
64
+ icon: Boxes,
65
+ description: "States and the transitions between them.",
66
+ starterTemplate: "stateDiagram-v2\n [*] --> Idle\n Idle --> Running : start\n Running --> Idle : stop\n Running --> [*] : finish",
67
+ support: "full",
68
+ featured: true
69
+ },
70
+ er: {
71
+ label: "Entity Relationship",
72
+ icon: Database,
73
+ description: "Data entities and how they relate.",
74
+ starterTemplate: "erDiagram\n CUSTOMER ||--o{ ORDER : places\n ORDER ||--|{ LINE_ITEM : contains",
75
+ support: "full",
76
+ featured: true
77
+ },
78
+ gantt: {
79
+ label: "Gantt Chart",
80
+ icon: CalendarRange,
81
+ description: "Tasks scheduled across time, with sections and dependencies.",
82
+ starterTemplate: "gantt\n title Plan\n dateFormat YYYY-MM-DD\n section Phase 1\n Research :a1, 2026-06-01, 7d\n Build :after a1, 14d",
83
+ support: "code-only",
84
+ featured: true
85
+ },
86
+ journey: {
87
+ label: "User Journey",
88
+ icon: Footprints,
89
+ description: "A user's experience through a process, step by step.",
90
+ starterTemplate: "journey\n title My Day\n section Morning\n Wake up: 5: Me\n Coffee: 5: Me\n section Work\n Meetings: 2: Me, Team",
91
+ support: "full"
92
+ },
93
+ class: {
94
+ label: "Class Diagram",
95
+ icon: Blocks,
96
+ description: "Classes, fields, methods, and relationships.",
97
+ starterTemplate: "classDiagram\n class Animal {\n +String name\n +makeSound()\n }\n Animal <|-- Dog",
98
+ support: "code-only"
99
+ },
100
+ quadrant: {
101
+ label: "Quadrant Chart",
102
+ icon: Grid2x2,
103
+ description: "Items plotted across four quadrants.",
104
+ starterTemplate: "quadrantChart\n title Reach vs Effort\n x-axis Low Effort --> High Effort\n y-axis Low Reach --> High Reach\n Item A: [0.3, 0.8]\n Item B: [0.7, 0.4]",
105
+ support: "full"
106
+ },
107
+ git: {
108
+ label: "Git Graph",
109
+ icon: GitBranch,
110
+ description: "Branches, commits, and merges.",
111
+ starterTemplate: "gitGraph\n commit\n branch develop\n commit\n checkout main\n merge develop",
112
+ support: "code-only"
113
+ },
114
+ c4: {
115
+ label: "C4 Architecture",
116
+ icon: Landmark,
117
+ description: "System context and container architecture views.",
118
+ starterTemplate: 'C4Context\n title System Context\n Person(user, "User")\n System(app, "Application")\n Rel(user, app, "Uses")',
119
+ support: "code-only"
120
+ },
121
+ sankey: {
122
+ label: "Sankey Diagram",
123
+ icon: Columns3,
124
+ description: "Flows and their magnitudes between stages.",
125
+ starterTemplate: "sankey-beta\nSource,Target,10\nSource,Other,5",
126
+ support: "code-only"
127
+ },
128
+ xychart: {
129
+ label: "XY Chart",
130
+ icon: BarChart3,
131
+ description: "Bar and line charts on X/Y axes.",
132
+ starterTemplate: 'xychart-beta\n title "Revenue"\n x-axis [Q1, Q2, Q3, Q4]\n y-axis "USD" 0 --> 100\n bar [20, 45, 60, 80]',
133
+ support: "code-only"
134
+ },
135
+ block: {
136
+ label: "Block Diagram",
137
+ icon: Boxes,
138
+ description: "Free-form block layouts.",
139
+ starterTemplate: "block-beta\n columns 3\n a b c",
140
+ support: "code-only"
141
+ },
142
+ packet: {
143
+ label: "Packet Diagram",
144
+ icon: Hexagon,
145
+ description: "Network packet structure by bit ranges.",
146
+ starterTemplate: 'packet-beta\n 0-15: "Source Port"\n 16-31: "Destination Port"',
147
+ support: "code-only"
148
+ },
149
+ kanban: {
150
+ label: "Kanban Board",
151
+ icon: ListChecks,
152
+ description: "Work items organized in status columns.",
153
+ starterTemplate: "kanban\n Todo\n Task one\n In Progress\n Task two\n Done\n Task three",
154
+ support: "code-only"
155
+ },
156
+ architecture: {
157
+ label: "Architecture Diagram",
158
+ icon: Landmark,
159
+ description: "Services, groups, and connections in a system.",
160
+ starterTemplate: "architecture-beta\n group api(cloud)[API]\n service db(database)[Database] in api\n service server(server)[Server] in api\n db:L -- R:server",
161
+ support: "code-only"
162
+ },
163
+ radar: {
164
+ label: "Radar Chart",
165
+ icon: Radar,
166
+ description: "Multi-axis comparison on a radial grid.",
167
+ starterTemplate: 'radar-beta\n title Skills\n axis a["Speed"], b["Quality"], c["Cost"]\n curve mycurve["Team"]{4, 5, 3}',
168
+ support: "code-only"
169
+ },
170
+ requirement: {
171
+ label: "Requirement Diagram",
172
+ icon: ListChecks,
173
+ description: "Requirements and the elements that satisfy them.",
174
+ starterTemplate: "requirementDiagram\n requirement r1 {\n id: 1\n text: must be fast\n }\n element app {\n type: system\n }\n app - satisfies -> r1",
175
+ support: "code-only"
176
+ },
177
+ zenuml: {
178
+ label: "ZenUML Diagram",
179
+ icon: ArrowRightLeft,
180
+ description: "Sequence diagrams in ZenUML syntax.",
181
+ starterTemplate: "zenuml\n A.method() {\n B.call()\n }",
182
+ support: "code-only"
183
+ },
184
+ unknown: {
185
+ label: "Diagram",
186
+ icon: Workflow,
187
+ description: "A mermaid diagram.",
188
+ starterTemplate: "flowchart TD\n A[Start] --> B[End]",
189
+ support: "code-only"
190
+ }
191
+ };
192
+ function getCatalogEntry(type) {
193
+ return MERMAID_CATALOG[type] ?? MERMAID_CATALOG.unknown;
194
+ }
195
+ function getFeaturedCatalogEntries() {
196
+ return Object.keys(MERMAID_CATALOG).filter((t) => MERMAID_CATALOG[t].featured).map((t) => ({ type: t, ...MERMAID_CATALOG[t] }));
197
+ }
198
+ export {
199
+ MERMAID_CATALOG,
200
+ getCatalogEntry,
201
+ getFeaturedCatalogEntries
202
+ };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Diagram-type detection from raw mermaid source.
3
+ *
4
+ * TS twin of the Python `_HEADERS` table in aidream
5
+ * packages/matrx-ai/matrx_ai/processing/blocks/parsers/mermaid_parser.py —
6
+ * keep the two in lockstep. Used before the mermaid engine loads (streaming
7
+ * labels) and for catalog lookups, so it must stay dependency-free.
8
+ */
9
+ export type MermaidDiagramType = "flowchart" | "sequence" | "class" | "state" | "er" | "journey" | "gantt" | "pie" | "mindmap" | "timeline" | "quadrant" | "git" | "c4" | "sankey" | "xychart" | "block" | "packet" | "kanban" | "architecture" | "radar" | "requirement" | "zenuml" | "unknown";
10
+ /**
11
+ * Returns the body lines with YAML frontmatter stripped, plus the extracted
12
+ * frontmatter title (if any). Tolerates an unterminated frontmatter block
13
+ * (mid-stream) by treating everything after `---` as frontmatter-in-progress.
14
+ */
15
+ export declare function splitFrontmatter(source: string): {
16
+ title: string | null;
17
+ bodyStartIndex: number;
18
+ lines: string[];
19
+ };
20
+ /**
21
+ * Every diagram type `detectDiagramType` can recognize, in header-table order.
22
+ * Derived from HEADERS so the vocabulary can never drift from the detector —
23
+ * the surface manifest spells this list out for agents (write targets).
24
+ */
25
+ export declare const DETECTABLE_DIAGRAM_TYPES: MermaidDiagramType[];
26
+ /** Detect the diagram type from the first significant line of the source. */
27
+ export declare function detectDiagramType(source: string): MermaidDiagramType;
28
+ /** Extract the frontmatter title from mermaid source, if present. */
29
+ export declare function extractMermaidTitle(source: string): string | null;
30
+ /**
31
+ * Write-twin of `extractMermaidTitle` — returns `source` with its YAML
32
+ * frontmatter `title:` set to `title`, adding a frontmatter block when the
33
+ * diagram has none. Every other frontmatter key is preserved untouched.
34
+ *
35
+ * Throws when the title cannot round-trip through `extractMermaidTitle`
36
+ * (quotes/newlines) or when the existing frontmatter block is unterminated —
37
+ * a caller with a bad value must hear about it, never get a silent no-op.
38
+ */
39
+ export declare function setMermaidTitle(source: string, title: string): string;
@@ -0,0 +1,89 @@
1
+ const HEADERS = [
2
+ [/^(flowchart|graph)\b/, "flowchart"],
3
+ [/^sequenceDiagram\b/, "sequence"],
4
+ [/^classDiagram/, "class"],
5
+ [/^stateDiagram/, "state"],
6
+ [/^erDiagram/, "er"],
7
+ [/^journey\b/, "journey"],
8
+ [/^gantt\b/, "gantt"],
9
+ [/^pie\b/, "pie"],
10
+ [/^mindmap\b/, "mindmap"],
11
+ [/^timeline\b/, "timeline"],
12
+ [/^quadrantChart\b/, "quadrant"],
13
+ [/^gitGraph\b/, "git"],
14
+ [/^C4(Context|Container|Component|Dynamic|Deployment)\b/, "c4"],
15
+ [/^sankey(-beta)?\b/, "sankey"],
16
+ [/^xychart(-beta)?\b/, "xychart"],
17
+ [/^block(-beta)?\b/, "block"],
18
+ [/^packet(-beta)?\b/, "packet"],
19
+ [/^kanban\b/, "kanban"],
20
+ [/^architecture(-beta)?\b/, "architecture"],
21
+ [/^radar(-beta)?\b/, "radar"],
22
+ [/^requirementDiagram\b/, "requirement"],
23
+ [/^zenuml\b/, "zenuml"]
24
+ ];
25
+ function splitFrontmatter(source) {
26
+ const lines = source.split("\n");
27
+ let title = null;
28
+ let bodyStartIndex = 0;
29
+ if (lines.length > 0 && lines[0].trim() === "---") {
30
+ bodyStartIndex = lines.length;
31
+ for (let j = 1; j < Math.min(lines.length, 30); j++) {
32
+ const s = lines[j].trim();
33
+ if (s === "---") {
34
+ bodyStartIndex = j + 1;
35
+ break;
36
+ }
37
+ const m = /^title:\s*(.+)$/.exec(s);
38
+ if (m) title = m[1].trim().replace(/^["']|["']$/g, "");
39
+ }
40
+ }
41
+ return { title, bodyStartIndex, lines };
42
+ }
43
+ const DETECTABLE_DIAGRAM_TYPES = HEADERS.map(
44
+ ([, type]) => type
45
+ );
46
+ function detectDiagramType(source) {
47
+ const { bodyStartIndex, lines } = splitFrontmatter(source);
48
+ for (let i = bodyStartIndex; i < lines.length; i++) {
49
+ const s = lines[i].trim();
50
+ if (!s || s.startsWith("%%")) continue;
51
+ for (const [pattern, type] of HEADERS) {
52
+ if (pattern.test(s)) return type;
53
+ }
54
+ return "unknown";
55
+ }
56
+ return "unknown";
57
+ }
58
+ function extractMermaidTitle(source) {
59
+ return splitFrontmatter(source).title;
60
+ }
61
+ function setMermaidTitle(source, title) {
62
+ const clean = title.trim();
63
+ if (!clean) throw new Error("A diagram title cannot be empty.");
64
+ if (/[\n\r]/.test(clean))
65
+ throw new Error("A diagram title must be a single line.");
66
+ if (/["']/.test(clean))
67
+ throw new Error(
68
+ "A diagram title cannot contain quote characters \u2014 mermaid frontmatter is YAML and would not read it back."
69
+ );
70
+ const { lines, bodyStartIndex } = splitFrontmatter(source);
71
+ const entry = `title: ${/[:#]/.test(clean) ? `"${clean}"` : clean}`;
72
+ if (lines.length === 0 || lines[0].trim() !== "---")
73
+ return ["---", entry, "---", ...lines].join("\n");
74
+ if (bodyStartIndex >= lines.length)
75
+ throw new Error(
76
+ "This diagram opens a `---` frontmatter block that is never closed \u2014 fix the source before setting a title."
77
+ );
78
+ const otherKeys = lines.slice(1, bodyStartIndex - 1).filter((line) => !/^\s*title\s*:/.test(line));
79
+ return ["---", entry, ...otherKeys, "---", ...lines.slice(bodyStartIndex)].join(
80
+ "\n"
81
+ );
82
+ }
83
+ export {
84
+ DETECTABLE_DIAGRAM_TYPES,
85
+ detectDiagramType,
86
+ extractMermaidTitle,
87
+ setMermaidTitle,
88
+ splitFrontmatter
89
+ };
@@ -0,0 +1,21 @@
1
+ import type { NormalizedFile } from "@ai-matrx/media/files/engine/handler/types";
2
+ export declare function copyMermaidSource(source: string): Promise<void>;
3
+ /** Copies the SVG markup as text — the universally pasteable form. */
4
+ export declare function copyMermaidSvg(svg: string): Promise<void>;
5
+ export declare function downloadMermaidSvg(svg: string, title?: string | null): void;
6
+ export declare function downloadMermaidSource(source: string, title?: string | null): void;
7
+ /** Rasterize the SVG to PNG at `scale`x and download it. */
8
+ export declare function downloadMermaidPng(svg: string, title?: string | null, scale?: number): Promise<void>;
9
+ /**
10
+ * Save the diagram into the user's cloud file system (Diagrams folder):
11
+ * the rendered SVG plus the .mmd source as a sibling, so the diagram is both
12
+ * viewable anywhere and re-editable later.
13
+ */
14
+ export declare function saveMermaidToWorkspace(args: {
15
+ svg: string;
16
+ source: string;
17
+ title?: string | null;
18
+ }): Promise<{
19
+ svgFile: NormalizedFile;
20
+ sourceFile: NormalizedFile;
21
+ }>;
@@ -0,0 +1,112 @@
1
+ "use client";
2
+ import { fileHandler } from "@ai-matrx/media/files/engine/handler/handler";
3
+ function svgBlob(svg) {
4
+ return new Blob([svg], { type: "image/svg+xml;charset=utf-8" });
5
+ }
6
+ function triggerDownload(blob, fileName) {
7
+ const url = URL.createObjectURL(blob);
8
+ const a = document.createElement("a");
9
+ a.href = url;
10
+ a.download = fileName;
11
+ a.click();
12
+ URL.revokeObjectURL(url);
13
+ }
14
+ function safeFileName(title, extension) {
15
+ const base = (title || "diagram").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60);
16
+ return `${base || "diagram"}.${extension}`;
17
+ }
18
+ async function copyMermaidSource(source) {
19
+ await navigator.clipboard.writeText(source);
20
+ }
21
+ async function copyMermaidSvg(svg) {
22
+ await navigator.clipboard.writeText(svg);
23
+ }
24
+ function downloadMermaidSvg(svg, title) {
25
+ triggerDownload(svgBlob(svg), safeFileName(title, "svg"));
26
+ }
27
+ function downloadMermaidSource(source, title) {
28
+ triggerDownload(new Blob([source], { type: "text/plain;charset=utf-8" }), safeFileName(title, "mmd"));
29
+ }
30
+ async function downloadMermaidPng(svg, title, scale = 2) {
31
+ const blob = await rasterizeSvgToPng(svg, scale);
32
+ triggerDownload(blob, safeFileName(title, "png"));
33
+ }
34
+ async function rasterizeSvgToPng(svg, scale) {
35
+ const dimensions = readSvgDimensions(svg);
36
+ const image = await loadImage(svgDataUrl(xmlSafeSvg(svg)));
37
+ const width = Math.max(1, Math.round((dimensions?.width ?? image.naturalWidth ?? 800) * scale));
38
+ const height = Math.max(1, Math.round((dimensions?.height ?? image.naturalHeight ?? 600) * scale));
39
+ const canvas = document.createElement("canvas");
40
+ canvas.width = width;
41
+ canvas.height = height;
42
+ const ctx = canvas.getContext("2d");
43
+ if (!ctx) throw new Error("Canvas 2D context unavailable");
44
+ ctx.drawImage(image, 0, 0, width, height);
45
+ return await new Promise((resolve, reject) => {
46
+ canvas.toBlob(
47
+ (b) => b ? resolve(b) : reject(new Error("PNG encoding failed")),
48
+ "image/png"
49
+ );
50
+ });
51
+ }
52
+ function svgDataUrl(svg) {
53
+ const utf8Bytes = encodeURIComponent(svg).replace(
54
+ /%([0-9A-F]{2})/g,
55
+ (_encodedByte, hex) => String.fromCharCode(Number.parseInt(hex, 16))
56
+ );
57
+ return `data:image/svg+xml;base64,${btoa(utf8Bytes)}`;
58
+ }
59
+ function xmlSafeSvg(svg) {
60
+ return svg.replace(
61
+ /<(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)(\b[^>]*)>/gi,
62
+ (match, tag, attributes) => attributes.trimEnd().endsWith("/") ? match : `<${tag}${attributes}/>`
63
+ );
64
+ }
65
+ function readSvgDimensions(svg) {
66
+ const viewBox = /viewBox="([\d.\s-]+)"/.exec(svg);
67
+ if (viewBox) {
68
+ const parts = viewBox[1].trim().split(/\s+/).map(Number);
69
+ if (parts.length === 4 && parts[2] > 0 && parts[3] > 0) {
70
+ return { width: parts[2], height: parts[3] };
71
+ }
72
+ }
73
+ return null;
74
+ }
75
+ function loadImage(url) {
76
+ return new Promise((resolve, reject) => {
77
+ const img = new Image();
78
+ img.onload = () => resolve(img);
79
+ img.onerror = () => reject(new Error("SVG image decode failed"));
80
+ img.src = url;
81
+ });
82
+ }
83
+ async function saveMermaidToWorkspace(args) {
84
+ const { svg, source, title } = args;
85
+ const svgFile = await fileHandler.upload(
86
+ { kind: "blob", blob: svgBlob(svg), fileName: safeFileName(title, "svg") },
87
+ {
88
+ folderPath: "Diagrams",
89
+ metadata: { source: "mermaid-block", title: title ?? void 0 }
90
+ }
91
+ );
92
+ const sourceFile = await fileHandler.upload(
93
+ {
94
+ kind: "blob",
95
+ blob: new Blob([source], { type: "text/plain;charset=utf-8" }),
96
+ fileName: safeFileName(title, "mmd")
97
+ },
98
+ {
99
+ folderPath: "Diagrams",
100
+ metadata: { source: "mermaid-block", title: title ?? void 0 }
101
+ }
102
+ );
103
+ return { svgFile, sourceFile };
104
+ }
105
+ export {
106
+ copyMermaidSource,
107
+ copyMermaidSvg,
108
+ downloadMermaidPng,
109
+ downloadMermaidSource,
110
+ downloadMermaidSvg,
111
+ saveMermaidToWorkspace
112
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Extract the mermaid diagram an agent produced from its streamed output.
3
+ *
4
+ * Agents are taught (the mermaid skill) to return ONE full ```mermaid fence.
5
+ * We take the LAST complete fence (handles a model that narrates then emits),
6
+ * and as a forgiving fallback accept an unfenced whole-output diagram when the
7
+ * text itself parses as a diagram type.
8
+ */
9
+ export declare function extractMermaidFromOutput(output: string): string | null;
10
+ /**
11
+ * True once the streamed output contains a complete mermaid fence — lets the
12
+ * workbench show a live preview the moment the diagram seals, before the
13
+ * agent finishes any trailing prose.
14
+ */
15
+ export declare function hasCompleteMermaidFence(output: string): boolean;
@@ -0,0 +1,22 @@
1
+ import { detectDiagramType } from "./diagram-type.js";
2
+ const FENCE_RE = /```(?:mermaid|mmd)\s*\n([\s\S]*?)```/gi;
3
+ function extractMermaidFromOutput(output) {
4
+ if (!output.trim()) return null;
5
+ let last = null;
6
+ for (const match of output.matchAll(FENCE_RE)) {
7
+ const body = match[1].replace(/\s+$/, "");
8
+ if (body.trim()) last = body;
9
+ }
10
+ if (last) return last;
11
+ const trimmed = output.trim();
12
+ if (detectDiagramType(trimmed) !== "unknown") return trimmed;
13
+ return null;
14
+ }
15
+ function hasCompleteMermaidFence(output) {
16
+ FENCE_RE.lastIndex = 0;
17
+ return FENCE_RE.test(output);
18
+ }
19
+ export {
20
+ extractMermaidFromOutput,
21
+ hasCompleteMermaidFence
22
+ };
@@ -0,0 +1,40 @@
1
+ import { type RefObject } from "react";
2
+ /** How far outside the viewport a diagram starts drawing. */
3
+ export declare const DRAW_MARGIN = "1200px 0px";
4
+ /**
5
+ * Diagrams the idle queue wakes per idle period. One: a diagram is a single
6
+ * long task (mermaid measures every label), so two at once doubled the stall.
7
+ */
8
+ export declare const IDLE_BATCH = 1;
9
+ /**
10
+ * Open a render-all pass; call the returned function when the print or
11
+ * capture is over (idempotent). Diagrams drawn during the pass stay drawn.
12
+ */
13
+ export declare function beginRenderAllPass(): () => void;
14
+ /** Test seam: whether a render-all pass is open. */
15
+ export declare function isRenderAllActive(): boolean;
16
+ /**
17
+ * Draw every diagram now. Resolves when all mounted diagrams have drawn, or
18
+ * after `timeoutMs` with the number still pending (never silently).
19
+ */
20
+ export declare function renderAllDiagrams(timeoutMs?: number): Promise<{
21
+ pending: number;
22
+ release: () => void;
23
+ }>;
24
+ /** Print the live page with every diagram drawn. */
25
+ export declare function printLivePage(): Promise<void>;
26
+ /**
27
+ * True once a print or page capture asked for EVERYTHING to render (the
28
+ * render-all switch). Anything that renders lazily — diagrams, a long list
29
+ * mounting in slices — follows it, so a print never shows a placeholder or a
30
+ * "Showing 600 of N" cut.
31
+ */
32
+ export declare function useRenderAllRequested(): boolean;
33
+ /**
34
+ * True once this diagram should draw: it came near the viewport, a render-all
35
+ * was requested, or the browser cannot tell (no IntersectionObserver).
36
+ */
37
+ export declare function useDrawWhenNear(ref: RefObject<HTMLElement | null>): {
38
+ shouldDraw: boolean;
39
+ markDrawn: () => void;
40
+ };