@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,246 @@
1
+ import { ALLOWED_RAW_HTML_TAGS } from "../../display/chat-markdown/rehypeSafeRawHtml.js";
2
+ import { splitFrontmatter } from "../../markdown-core/syntax/frontmatter.js";
3
+ import { fenceLineKinds, lineIndent, opensStrippedHtmlBlock } from "@ai-matrx/content-ir/source";
4
+ import { fromMarkdown } from "mdast-util-from-markdown";
5
+ import { gfmFromMarkdown } from "mdast-util-gfm";
6
+ import { gfm } from "micromark-extension-gfm";
7
+ import { findTableEnd, tableStartsAt } from "../../display/markdown-classification/processors/utils/gfm-table-lines.js";
8
+ const THICK_HR_SENTINEL = "\uE000THICK_HR\uE000";
9
+ function isolateThickHorizontalRules(source) {
10
+ const lines = source.split("\n");
11
+ const kinds = fenceLineKinds(source);
12
+ const out = lines.map(
13
+ (line, i) => kinds[i] === "prose" && /^[ \t]*={3,}[ \t]*$/.test(line) ? THICK_HR_SENTINEL : line
14
+ );
15
+ return out.join("\n").replace(
16
+ new RegExp(`([^\\n])\\n+(${THICK_HR_SENTINEL})`, "g"),
17
+ "$1\n\n$2"
18
+ ).replace(
19
+ new RegExp(`(${THICK_HR_SENTINEL})\\n+([^\\n])`, "g"),
20
+ "$1\n\n$2"
21
+ );
22
+ }
23
+ const RTL_CHAR = /[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF\u200F\u202E]/;
24
+ function isRtlCode(c) {
25
+ return c >= 1424 && c <= 1791 || c >= 1872 && c <= 1919 || c >= 2208 && c <= 2303 || c >= 64336 && c <= 65023 || c >= 65136 && c <= 65279 || c === 8207 || c === 8238;
26
+ }
27
+ const detectTextDirection = (text) => {
28
+ if (!RTL_CHAR.test(text)) return "ltr";
29
+ let rtlCount = 0;
30
+ let ltrCount = 0;
31
+ for (let i = 0; i < text.length; i++) {
32
+ const c = text.charCodeAt(i);
33
+ if (isRtlCode(c)) rtlCount++;
34
+ else if (c >= 65 && c <= 90 || c >= 97 && c <= 122) ltrCount++;
35
+ }
36
+ const totalAlphabetic = rtlCount + ltrCount;
37
+ if (totalAlphabetic === 0) return "ltr";
38
+ return rtlCount / totalAlphabetic > 0.1 ? "rtl" : "ltr";
39
+ };
40
+ const getDirectionClasses = (direction) => {
41
+ return direction === "rtl" ? "text-right rtl" : "text-left ltr";
42
+ };
43
+ const getDirectionFontSize = (direction) => {
44
+ return direction === "rtl" ? "text-base" : "text-sm";
45
+ };
46
+ const FENCE_TOKEN = /\uE001F(\d+)\uE001/g;
47
+ function protectFencedCode(source) {
48
+ if (!source.includes("```") && !source.includes("~~~")) return null;
49
+ const lines = source.split("\n");
50
+ const kinds = fenceLineKinds(source);
51
+ const out = [];
52
+ const fences = [];
53
+ for (let i = 0; i < lines.length; ) {
54
+ if (kinds[i] !== "open") {
55
+ out.push(lines[i]);
56
+ i += 1;
57
+ continue;
58
+ }
59
+ const region = [lines[i]];
60
+ i += 1;
61
+ while (i < lines.length && (kinds[i] === "body" || kinds[i] === "close")) {
62
+ const closes = kinds[i] === "close";
63
+ region.push(lines[i]);
64
+ i += 1;
65
+ if (closes) break;
66
+ }
67
+ const indent = /^[ \t]*/.exec(region[0])?.[0] ?? "";
68
+ region[0] = region[0].slice(indent.length);
69
+ out.push(`${indent}\uE001F${fences.length}\uE001`);
70
+ fences.push(region.join("\n"));
71
+ }
72
+ if (fences.length === 0) return null;
73
+ return {
74
+ text: out.join("\n"),
75
+ restore: (s) => s.replace(FENCE_TOKEN, (_m, n) => fences[Number(n)] ?? "")
76
+ };
77
+ }
78
+ const LIST_ITEM_LINE = /^[ \t]*(?:[*+-]|\d+[.)])[ \t]/;
79
+ const INDENT_RUN = /^( +)(?! |[*+-][ \t]|\d+[.)][ \t])/;
80
+ function preserveIndentation(source) {
81
+ let inList = false;
82
+ let changed = false;
83
+ const raw = source.split("\n");
84
+ const tableLine = /* @__PURE__ */ new Set();
85
+ if (source.includes("|")) {
86
+ for (let i = 0; i + 1 < raw.length; i += 1) {
87
+ if (!tableStartsAt(raw, i)) continue;
88
+ const end = findTableEnd(raw, i);
89
+ for (let k = i; k < end; k += 1) tableLine.add(k);
90
+ i = end - 1;
91
+ }
92
+ }
93
+ const lines = raw.map((line, index) => {
94
+ if (tableLine.has(index)) return line;
95
+ if (LIST_ITEM_LINE.test(line)) {
96
+ inList = true;
97
+ return line;
98
+ }
99
+ if (!line.trim()) return line;
100
+ if (!/^[ \t]/.test(line)) {
101
+ inList = false;
102
+ return line;
103
+ }
104
+ if (inList) return line;
105
+ const m = INDENT_RUN.exec(line);
106
+ if (!m) return line;
107
+ changed = true;
108
+ return "\xA0\xA0".repeat(m[1].length) + line.slice(m[1].length);
109
+ });
110
+ return changed ? lines.join("\n") : source;
111
+ }
112
+ function prepareInlineProse(rawContent) {
113
+ let processed = rawContent;
114
+ processed = processed.replace(
115
+ /(`+)([\s\S]*?)\1|<(thinking|think|reasoning)>([^\n<>]*?)<\/\3>/g,
116
+ (match, backticks, _code, _tag, aside) => backticks !== void 0 ? match : aside?.trim() ? `<i>${aside.trim()}</i>` : ""
117
+ );
118
+ processed = processed.replace(
119
+ /(`+)([\s\S]*?)\1|<(\/?[\w][\w-]*)([^>]*?)>/g,
120
+ (match, backticks, _codeContent, tagName, tagAttrs) => {
121
+ if (backticks !== void 0) return match;
122
+ const bareTag = String(tagName).replace(/^\//, "").toLowerCase();
123
+ if (ALLOWED_RAW_HTML_TAGS.has(bareTag)) return match;
124
+ return `&lt;${tagName}${tagAttrs}&gt;`;
125
+ }
126
+ );
127
+ return processed;
128
+ }
129
+ function linkBracketedUrls(processed) {
130
+ return processed.replace(
131
+ /\[(https?:\/\/[^\]\s]+)\](?!\()/g,
132
+ "[$1]($1)"
133
+ );
134
+ }
135
+ function preprocessCellProse(rawContent) {
136
+ return linkBracketedUrls(prepareInlineProse(rawContent));
137
+ }
138
+ function endStrippedHtmlBlocks(text) {
139
+ if (!text.includes("<")) return text;
140
+ const lines = text.split("\n");
141
+ const out = [];
142
+ lines.forEach((line, i) => {
143
+ out.push(line);
144
+ const next = lines[i + 1];
145
+ if (next !== void 0 && next.trim() && lineIndent(line) < 4 && opensStrippedHtmlBlock(line.trim())) out.push("");
146
+ });
147
+ return out.length === lines.length ? text : out.join("\n");
148
+ }
149
+ function gfmStructure(markdown) {
150
+ const tree = fromMarkdown(markdown, { extensions: [gfm()], mdastExtensions: [gfmFromMarkdown()] });
151
+ const out = [];
152
+ const walk = (node) => {
153
+ if (node.type === "list") out.push(`${node.ordered ? "ol" : "ul"}${node.children?.length ?? 0}`);
154
+ else if (node.type === "table") out.push(`table${node.children?.length ?? 0}`);
155
+ else if (node.type === "blockquote") out.push("quote");
156
+ else if (node.type === "heading") out.push(`h${node.depth ?? 0}`);
157
+ else if (node.type === "footnoteDefinition") out.push(`note${node.children?.length ?? 0}`);
158
+ (node.children ?? []).forEach(walk);
159
+ };
160
+ walk(tree);
161
+ return out.join(" ");
162
+ }
163
+ function keepGfmStructure(before, after) {
164
+ if (after === before) return after;
165
+ return gfmStructure(after) === gfmStructure(before) ? after : before;
166
+ }
167
+ const LIST_MARKER_LINE = /^\s*(?:[-+*]|\d{1,9}[.)])(?:[ \t]|$)/;
168
+ const SETEXT_UNDERLINE = /^ {0,3}(?:=+|-+)[ \t]*$/;
169
+ const ENDS_IN_EMPHASIS = /(?:\*\*[^*]+\*\*|\*[^*]+\*)$/;
170
+ const ONLY_ITALIC = /^\*[^*]+\*$/;
171
+ function inListOrQuote(lines, i) {
172
+ for (let k = i; k >= 0; k -= 1) {
173
+ const line = lines[k] ?? "";
174
+ if (!line.trim()) return false;
175
+ if (LIST_MARKER_LINE.test(line) || /^\s*>/.test(line) || /^[ \t]/.test(line)) return true;
176
+ }
177
+ return false;
178
+ }
179
+ function mayBreakAfter(lines, i) {
180
+ const next = lines[i + 1] ?? "";
181
+ if (!next.trim() || !(lines[i] ?? "").trim()) return false;
182
+ if (/^\s/.test(next) || LIST_MARKER_LINE.test(next) || SETEXT_UNDERLINE.test(next)) return false;
183
+ return !inListOrQuote(lines, i);
184
+ }
185
+ function spaceEmphasisLines(text) {
186
+ if (!text.includes("*")) return text;
187
+ const lines = text.split("\n");
188
+ const breakAfter = /* @__PURE__ */ new Set();
189
+ lines.forEach((line, i) => {
190
+ if (i + 1 >= lines.length) return;
191
+ if (ENDS_IN_EMPHASIS.test(line) && !/^[*-]/.test(lines[i + 1] ?? "") && mayBreakAfter(lines, i)) breakAfter.add(i);
192
+ if (i > 0 && ONLY_ITALIC.test(line) && !LIST_MARKER_LINE.test(line) && mayBreakAfter(lines, i - 1) && mayBreakAfter(lines, i)) {
193
+ breakAfter.add(i - 1);
194
+ breakAfter.add(i);
195
+ }
196
+ });
197
+ if (breakAfter.size === 0) return text;
198
+ return lines.map((line, i) => breakAfter.has(i) ? `${line}
199
+ ` : line).join("\n");
200
+ }
201
+ function separateSetextUnderlines(text) {
202
+ if (!text.includes("\n---")) return text;
203
+ const lines = text.split("\n");
204
+ const out = [];
205
+ lines.forEach((line, i) => {
206
+ if (i > 0 && line.startsWith("---") && lines[i - 1] !== "" && !tableStartsAt(lines, i - 1)) out.push("");
207
+ out.push(line);
208
+ });
209
+ return out.join("\n");
210
+ }
211
+ function preprocessProse(rawContent) {
212
+ if (rawContent.charCodeAt(0) === 65279) return preprocessProse(rawContent.slice(1));
213
+ const frontmatter = splitFrontmatter(rawContent);
214
+ if (frontmatter) return frontmatter.raw + preprocessProse(frontmatter.body);
215
+ const guarded = protectFencedCode(rawContent);
216
+ if (guarded) return guarded.restore(preprocessProse(guarded.text));
217
+ let processed = rawContent;
218
+ processed = endStrippedHtmlBlocks(processed);
219
+ processed = prepareInlineProse(processed);
220
+ processed = keepGfmStructure(processed, preserveIndentation(processed));
221
+ processed = linkBracketedUrls(processed);
222
+ processed = processed.replace(/^(\s*)\*([ \t]+)/gm, "$1-$2");
223
+ processed = processed.replace(
224
+ /(^[ \t]*-[ \t]+[^\n]+)\n\n(\*\*\d)/gm,
225
+ "$1\n\n&nbsp;\n\n$2"
226
+ );
227
+ processed = separateSetextUnderlines(processed);
228
+ processed = isolateThickHorizontalRules(processed);
229
+ processed = keepGfmStructure(processed, spaceEmphasisLines(processed));
230
+ processed = processed.replace(/\n{2,}/g, (match) => {
231
+ const blankLines = Math.min(match.length - 2, 2);
232
+ return "\n\n" + "&nbsp;\n\n".repeat(blankLines);
233
+ });
234
+ return processed;
235
+ }
236
+ export {
237
+ THICK_HR_SENTINEL,
238
+ detectTextDirection,
239
+ getDirectionClasses,
240
+ getDirectionFontSize,
241
+ isolateThickHorizontalRules,
242
+ preprocessCellProse,
243
+ preprocessProse,
244
+ preserveIndentation,
245
+ protectFencedCode
246
+ };
@@ -0,0 +1,34 @@
1
+ import React, { type ReactNode } from "react";
2
+ /** Who wrote the text being rendered: the viewer, someone else, or an AI model. */
3
+ export type ImagePolicy = "self" | "other" | "ai";
4
+ /**
5
+ * What a render site declares: who wrote it, or "inherit" for a render nested
6
+ * INSIDE a surface that already declared (a kind block or tool renderer inside a
7
+ * chat answer) — it takes the enclosing declaration.
8
+ */
9
+ export type ImagePolicyDeclaration = ImagePolicy | "inherit";
10
+ /** Wrap `node` in the declaration's provider; "inherit" and undefined add none. */
11
+ export declare function withImagePolicy(declaration: ImagePolicyDeclaration | undefined, node: ReactNode): ReactNode;
12
+ /** "self" when the viewer wrote it, otherwise "other" — for records that can be either. */
13
+ export declare function authoredBy(authorId: string | null | undefined, viewerId: string | null | undefined): ImagePolicy;
14
+ export declare const REMOTE_IMAGE_KNOB_FEATURE = "rich_content.remote_images";
15
+ /** What each authorship does when the knob has not answered (and on anonymous pages). */
16
+ export declare const REMOTE_IMAGE_DEFAULTS: Record<ImagePolicy, boolean>;
17
+ export declare function ImagePolicyProvider({ value, children }: {
18
+ value: ImagePolicy;
19
+ children: ReactNode;
20
+ }): React.JSX.Element;
21
+ /** The declared authorship, or null when no host declared one. */
22
+ export declare function useImagePolicy(): ImagePolicy | null;
23
+ /** The remote host a URL would contact, or null when drawing it reaches no third party. */
24
+ export declare function remoteImageHost(src: string): string | null;
25
+ /**
26
+ * Renders `children` (the real image) when it may load; otherwise the
27
+ * click-to-load placeholder. `block` lays the placeholder out as a line.
28
+ */
29
+ export declare function RemoteImageGate({ src, alt, block, children, }: {
30
+ src: string;
31
+ alt?: string;
32
+ block?: boolean;
33
+ children: ReactNode;
34
+ }): React.JSX.Element;
@@ -0,0 +1,153 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { createContext, useContext, useState } from "react";
4
+ import { ImageOff } from "lucide-react";
5
+ import { recognizeOurFileUrl } from "@ai-matrx/media/files/engine/media/our-file-sources";
6
+ import { imageKnobPrincipals as sessionKnobPrincipals, setImageKnobMapEntry as setUserKnobMapEntry, useImageKnob as useEffectiveKnob } from "../../host/app-bindings.js";
7
+ import { ErrorNotice } from "../../host/ErrorNotice.js";
8
+ function withImagePolicy(declaration, node) {
9
+ return declaration && declaration !== "inherit" ? /* @__PURE__ */ jsx(ImagePolicyProvider, { value: declaration, children: node }) : node;
10
+ }
11
+ function authoredBy(authorId, viewerId) {
12
+ return authorId && viewerId && authorId === viewerId ? "self" : "other";
13
+ }
14
+ const REMOTE_IMAGE_KNOB_FEATURE = "rich_content.remote_images";
15
+ const REMOTE_IMAGE_DEFAULTS = { self: true, other: false, ai: false };
16
+ const ImagePolicyContext = createContext(null);
17
+ function ImagePolicyProvider({ value, children }) {
18
+ return /* @__PURE__ */ jsx(ImagePolicyContext.Provider, { value, children });
19
+ }
20
+ function useImagePolicy() {
21
+ return useContext(ImagePolicyContext);
22
+ }
23
+ let warnedUndeclared = false;
24
+ function warnUndeclared(host) {
25
+ if (warnedUndeclared || false) return;
26
+ warnedUndeclared = true;
27
+ console.warn(
28
+ `[rich-content] A remote image (${host}) rendered where no surface declared who wrote the text, so it waits for a click. Pass imagePolicy="self" | "other" | "ai" on the RichContent / RichDocument / MarkdownStream that renders it (components/rich-content/prose/remote-image-policy.tsx).`
29
+ );
30
+ }
31
+ function remoteImageHost(src) {
32
+ const s = src.trim();
33
+ if (!s) return null;
34
+ if (/^(data:image\/|blob:)/i.test(s)) return null;
35
+ if (s.startsWith("/") && !s.startsWith("//")) return null;
36
+ if (recognizeOurFileUrl(s)) return null;
37
+ let url;
38
+ try {
39
+ const base = typeof window !== "undefined" ? window.location.href : "https://localhost/";
40
+ url = new URL(s, base);
41
+ } catch {
42
+ return null;
43
+ }
44
+ if (typeof window !== "undefined" && url.origin === window.location.origin) return null;
45
+ return url.host || null;
46
+ }
47
+ function asHostMap(v) {
48
+ return v && typeof v === "object" && !Array.isArray(v) ? v : {};
49
+ }
50
+ function RemoteImageGate({
51
+ src,
52
+ alt,
53
+ block = false,
54
+ children
55
+ }) {
56
+ const declared = useImagePolicy();
57
+ const authorship = declared ?? "other";
58
+ const { organizationId, userId } = sessionKnobPrincipals();
59
+ const autoload = useEffectiveKnob(organizationId, userId, { feature: REMOTE_IMAGE_KNOB_FEATURE, key: `autoload_${authorship}` });
60
+ const trusted = asHostMap(useEffectiveKnob(organizationId, userId, { feature: REMOTE_IMAGE_KNOB_FEATURE, key: "trusted_hosts" }));
61
+ const [shown, setShown] = useState(false);
62
+ const [trusting, setTrusting] = useState("idle");
63
+ const host = remoteImageHost(src);
64
+ if (!host) return /* @__PURE__ */ jsx(Fragment, { children });
65
+ if (!declared) warnUndeclared(host);
66
+ const loadsByItself = typeof autoload === "boolean" ? autoload : REMOTE_IMAGE_DEFAULTS[authorship];
67
+ if (shown || loadsByItself || trusted[host] === true) return /* @__PURE__ */ jsx(Fragment, { children });
68
+ const why = authorship === "ai" ? "written by AI" : "written by someone else";
69
+ const canTrust = !!organizationId && !!userId;
70
+ return /* @__PURE__ */ jsxs(
71
+ "span",
72
+ {
73
+ "data-content-chrome": "",
74
+ "data-rc-remote-image": host,
75
+ role: "group",
76
+ "aria-label": alt ? `Image \u201C${alt}\u201D from ${host}, not loaded` : `Image from ${host}, not loaded`,
77
+ className: (block ? "my-2 flex w-full " : "mx-0.5 inline-flex max-w-full ") + // wraps in a narrow column: the host name gives way, the controls never get cut
78
+ "flex-wrap items-center gap-x-1.5 gap-y-0.5 rounded-md border border-dashed border-border bg-muted/40 px-2 py-1 align-middle text-xs text-muted-foreground",
79
+ children: [
80
+ /* @__PURE__ */ jsxs("span", { className: "inline-flex min-w-0 max-w-full items-center gap-1.5", title: `Images from other websites in text ${why} wait for you to show them.`, children: [
81
+ /* @__PURE__ */ jsx(ImageOff, { className: "h-3.5 w-3.5 shrink-0", "aria-hidden": true }),
82
+ /* @__PURE__ */ jsxs("span", { className: "min-w-0 truncate", children: [
83
+ alt ? `\u201C${alt}\u201D \u2014 ` : "",
84
+ "image from ",
85
+ host
86
+ ] })
87
+ ] }),
88
+ /* @__PURE__ */ jsx(
89
+ "button",
90
+ {
91
+ type: "button",
92
+ onClick: () => setShown(true),
93
+ className: "shrink-0 rounded px-1 font-medium text-primary hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring",
94
+ children: "Show image"
95
+ }
96
+ ),
97
+ canTrust ? /* @__PURE__ */ jsx(
98
+ "button",
99
+ {
100
+ type: "button",
101
+ disabled: trusting === "saving",
102
+ onClick: async () => {
103
+ setTrusting("saving");
104
+ try {
105
+ const r = await setUserKnobMapEntry({
106
+ feature: REMOTE_IMAGE_KNOB_FEATURE,
107
+ key: "trusted_hosts",
108
+ entryKey: host,
109
+ entryValue: true,
110
+ userId,
111
+ organizationId,
112
+ note: "Always show images from this website (image placeholder)"
113
+ });
114
+ if (r.ok) {
115
+ setShown(true);
116
+ setTrusting("idle");
117
+ } else setTrusting(r.reason);
118
+ } catch (e) {
119
+ console.error("[rich-content] saving a trusted image host failed", e);
120
+ setTrusting("That choice could not be saved. Show image still works for this one.");
121
+ }
122
+ },
123
+ title: `Always show images from ${host}`,
124
+ className: "shrink-0 rounded px-1 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring",
125
+ children: trusting === "saving" ? "Saving\u2026" : "Always show"
126
+ }
127
+ ) : null,
128
+ /* @__PURE__ */ jsx(
129
+ "a",
130
+ {
131
+ href: src,
132
+ target: "_blank",
133
+ rel: "noopener noreferrer nofollow",
134
+ referrerPolicy: "no-referrer",
135
+ className: "shrink-0 rounded px-1 hover:underline",
136
+ children: "Open"
137
+ }
138
+ ),
139
+ trusting !== "idle" && trusting !== "saving" ? /* @__PURE__ */ jsx(ErrorNotice, { size: "inline", className: "basis-full", message: trusting }) : null
140
+ ]
141
+ }
142
+ );
143
+ }
144
+ export {
145
+ ImagePolicyProvider,
146
+ REMOTE_IMAGE_DEFAULTS,
147
+ REMOTE_IMAGE_KNOB_FEATURE,
148
+ RemoteImageGate,
149
+ authoredBy,
150
+ remoteImageHost,
151
+ useImagePolicy,
152
+ withImagePolicy
153
+ };
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from "react";
2
+ import type { RichContentVariant } from "../rich-content-types.js";
3
+ /** The reading variant's scoped, unlayered stylesheet. */
4
+ export declare const READING_VARIANT_CSS = "\n[data-rc-variant=\"reading\"]{font-size:1.125rem;max-width:70ch;margin-inline:auto;color:hsl(var(--foreground));}\n[data-rc-variant=\"reading\"] .math-content-wrapper{margin-block:0;}\n[data-rc-variant=\"reading\"] p,[data-rc-variant=\"reading\"] li{font-size:1.125rem;line-height:1.75;}\n[data-rc-variant=\"reading\"] p{margin-bottom:1.15em;}\n[data-rc-variant=\"reading\"] li{margin-bottom:0.35em;}\n[data-rc-variant=\"reading\"] ul,[data-rc-variant=\"reading\"] ol{margin-bottom:1.15em;}\n[data-rc-variant=\"reading\"] blockquote{font-size:1.125rem;line-height:1.7;margin-block:1.5em;}\n[data-rc-variant=\"reading\"] blockquote p{margin-bottom:0.5em;}\n[data-rc-variant=\"reading\"] h1,[data-rc-variant=\"reading\"] h2,[data-rc-variant=\"reading\"] h3,[data-rc-variant=\"reading\"] h4{color:hsl(var(--foreground));font-weight:700;letter-spacing:-0.01em;}\n[data-rc-variant=\"reading\"] h1{font-size:2rem;line-height:1.2;margin:2.2em 0 0.6em;}\n[data-rc-variant=\"reading\"] h2{font-size:1.5rem;line-height:1.3;margin:2em 0 0.6em;}\n[data-rc-variant=\"reading\"] h3{font-size:1.25rem;line-height:1.4;margin:1.6em 0 0.5em;}\n[data-rc-variant=\"reading\"] h4{font-size:1.125rem;line-height:1.5;margin:1.4em 0 0.4em;}\n[data-rc-variant=\"reading\"] > :first-child h1:first-child,[data-rc-variant=\"reading\"] > :first-child h2:first-child{margin-top:0;}\n[data-rc-variant=\"reading\"] table{font-size:1rem;}\n[data-rc-variant=\"reading\"] hr{margin-block:2.5em;}\n";
5
+ /** Wraps a level's output in its variant. `default` adds nothing. */
6
+ export declare function RichContentVariantRoot({ variant, children, }: {
7
+ variant?: RichContentVariant;
8
+ children: ReactNode;
9
+ }): import("react").JSX.Element;
@@ -0,0 +1,34 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ const R = '[data-rc-variant="reading"]';
3
+ const READING_VARIANT_CSS = `
4
+ ${R}{font-size:1.125rem;max-width:70ch;margin-inline:auto;color:hsl(var(--foreground));}
5
+ ${R} .math-content-wrapper{margin-block:0;}
6
+ ${R} p,${R} li{font-size:1.125rem;line-height:1.75;}
7
+ ${R} p{margin-bottom:1.15em;}
8
+ ${R} li{margin-bottom:0.35em;}
9
+ ${R} ul,${R} ol{margin-bottom:1.15em;}
10
+ ${R} blockquote{font-size:1.125rem;line-height:1.7;margin-block:1.5em;}
11
+ ${R} blockquote p{margin-bottom:0.5em;}
12
+ ${R} h1,${R} h2,${R} h3,${R} h4{color:hsl(var(--foreground));font-weight:700;letter-spacing:-0.01em;}
13
+ ${R} h1{font-size:2rem;line-height:1.2;margin:2.2em 0 0.6em;}
14
+ ${R} h2{font-size:1.5rem;line-height:1.3;margin:2em 0 0.6em;}
15
+ ${R} h3{font-size:1.25rem;line-height:1.4;margin:1.6em 0 0.5em;}
16
+ ${R} h4{font-size:1.125rem;line-height:1.5;margin:1.4em 0 0.4em;}
17
+ ${R} > :first-child h1:first-child,${R} > :first-child h2:first-child{margin-top:0;}
18
+ ${R} table{font-size:1rem;}
19
+ ${R} hr{margin-block:2.5em;}
20
+ `;
21
+ function RichContentVariantRoot({
22
+ variant = "default",
23
+ children
24
+ }) {
25
+ if (variant !== "reading") return /* @__PURE__ */ jsx(Fragment, { children });
26
+ return /* @__PURE__ */ jsxs("div", { "data-rc-variant": "reading", children: [
27
+ /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: READING_VARIANT_CSS } }),
28
+ children
29
+ ] });
30
+ }
31
+ export {
32
+ READING_VARIANT_CSS,
33
+ RichContentVariantRoot
34
+ };
@@ -0,0 +1,93 @@
1
+ /**
2
+ * `<RichContent level>` — the ONE entry for rendering any text that is more
3
+ * than plain text. Types live here (the shell) so a consumer's graph never
4
+ * pulls an implementation to name a prop.
5
+ *
6
+ * Levels — the same core, the same plugin rules, the same prose preparation;
7
+ * a level only decides how much of the block pipeline is mounted:
8
+ *
9
+ * - `inline` markdown + math, NO blocks. Renders phrasing elements only
10
+ * (spans), so it is valid inside a `<p>`, a `<button>`, a table
11
+ * cell, a title. Card faces, quiz prompts, previews, terms.
12
+ * - `standard` + code, tables, mermaid, XML sections, ```markdown fences and
13
+ * other nested blocks — depth-bounded. No kinds, no actions.
14
+ * - `full` the whole chat pipeline (MarkdownStream → block registry →
15
+ * kinds, interactive blocks, actions).
16
+ *
17
+ * Plan: common-docs/projects/rich-content-unification/PLAN.md decisions 1, 2, 9.
18
+ */
19
+ import type { MarkdownStreamProps } from "../host/app-bindings.js";
20
+ export type RichContentLevel = "inline" | "standard" | "full";
21
+ /**
22
+ * How many nested content levels render formatted before falling back to
23
+ * plain text with an "open" affordance. Depth 0 is the content itself; an
24
+ * `<info>` inside it is depth 1; a ```markdown fence inside that is depth 2 …
25
+ *
26
+ * Default for the `depthCap` knob (prop / provider). Chosen 2026-09-23: three
27
+ * levels covers every nesting seen in real assistant output (a section → a
28
+ * document → its own section) while bounding adversarial or runaway nesting.
29
+ */
30
+ export declare const DEFAULT_RICH_CONTENT_DEPTH_CAP = 3;
31
+ /**
32
+ * Typography variant — never a second renderer (prose/variant-root.tsx).
33
+ * - `default` chat density.
34
+ * - `reading` long-form reading: larger body, ~70ch measure, comfortable
35
+ * line-height, heading scale. For learn articles, share pages,
36
+ * public resources.
37
+ */
38
+ export type RichContentVariant = "default" | "reading";
39
+ export interface RichContentProps {
40
+ /** The source text — markdown, math, XML sections, fences. */
41
+ source: string;
42
+ level: RichContentLevel;
43
+ /**
44
+ * True while the source is still streaming in. Inline: heal half-arrived
45
+ * syntax (omit to inherit a live stream; `false` for whole text).
46
+ */
47
+ isStreaming?: boolean;
48
+ className?: string;
49
+ /** Nested-rendering depth cap (standard / full). */
50
+ depthCap?: number;
51
+ /** Typography variant (standard / full); default `default`. */
52
+ variant?: RichContentVariant;
53
+ /**
54
+ * Inline only: `text` renders markdown links as their formatted text, for
55
+ * content that already sits inside a link (card previews). Default `link`.
56
+ */
57
+ links?: "link" | "text";
58
+ /**
59
+ * Standard / full: heading hover anchors ("#" links to a section). Pass
60
+ * `false` in preview contexts (clamped cards, collapsed panels) where the
61
+ * section is not on screen. Default `true`; the inline level never has them.
62
+ */
63
+ headingAnchors?: boolean;
64
+ /**
65
+ * WHO WROTE this text — "self" (the viewer), "other" (someone else) or "ai"
66
+ * (a model). Decides whether remote images load by themselves, per the
67
+ * `rich_content.remote_images.autoload_*` knobs (remote-image-policy.tsx).
68
+ * REQUIRED in practice at the full level (guard:
69
+ * __tests__/image-policy-declared.test.ts); omitted = inherit, and with no
70
+ * declaration anywhere remote images wait for a click.
71
+ */
72
+ imagePolicy?: "self" | "other" | "ai" | "inherit";
73
+ /**
74
+ * Inline only: the source is ONE GFM table cell. It is read the way GFM reads
75
+ * a cell — inline constructs only (`> 90%`, `- n/a`, `# 3` are text, never a
76
+ * quote/list/heading) and `\|` shows as `|` (the one cell-pipe rule). Pass the
77
+ * cell's source text as stored. verify-RC-B4 R6-1.
78
+ */
79
+ gfmCell?: boolean;
80
+ /**
81
+ * Full level only — the engine's host hooks, forwarded as given to the chat
82
+ * pipeline (MarkdownStream). `onContentChange` receives an in-block edit
83
+ * (JSON reformat, code edit, table edit) so the host can persist it;
84
+ * `applyLocalEdits={false}` keeps the shown text tied to `source`.
85
+ */
86
+ onContentChange?: MarkdownStreamProps["onContentChange"];
87
+ applyLocalEdits?: boolean;
88
+ analysisData?: unknown;
89
+ messageId?: string;
90
+ conversationId?: string;
91
+ allowFullScreenEditor?: boolean;
92
+ hideCopyButton?: boolean;
93
+ }
@@ -0,0 +1,4 @@
1
+ const DEFAULT_RICH_CONTENT_DEPTH_CAP = 3;
2
+ export {
3
+ DEFAULT_RICH_CONTENT_DEPTH_CAP
4
+ };
@@ -0,0 +1,7 @@
1
+ import { type guardMarkdownDelimiters } from "@ai-matrx/kit/delimiter-guard";
2
+ type Violations = ReturnType<typeof guardMarkdownDelimiters>["violations"];
3
+ export declare function DelimiterViolationReport({ violations, renderPath, }: {
4
+ violations: Violations;
5
+ renderPath: string;
6
+ }): null;
7
+ export default DelimiterViolationReport;
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { useEffect } from "react";
3
+ import {
4
+ reportDelimiterViolations
5
+ } from "@ai-matrx/kit/delimiter-guard";
6
+ import { captureError } from "../../host/diagnostics.js";
7
+ function DelimiterViolationReport({
8
+ violations,
9
+ renderPath
10
+ }) {
11
+ useEffect(() => {
12
+ if (violations.length === 0) return;
13
+ reportDelimiterViolations(violations, {
14
+ renderPath,
15
+ capture: (input) => captureError({ ...input })
16
+ });
17
+ }, [violations, renderPath]);
18
+ return null;
19
+ }
20
+ var DelimiterViolationReport_default = DelimiterViolationReport;
21
+ export {
22
+ DelimiterViolationReport,
23
+ DelimiterViolationReport_default as default
24
+ };
@@ -0,0 +1,27 @@
1
+ import "server-only";
2
+ import type { ReactNode } from "react";
3
+ import type { DocumentNumbering } from "../../markdown-core/syntax/document-numbering.js";
4
+ import { type RichContentVariant } from "../rich-content-types.js";
5
+ import { type InlineLinks } from "../prose/inline-level-elements.js";
6
+ export type RichContentServerLevel = "inline" | "standard";
7
+ export interface RichContentServerProps {
8
+ source: string;
9
+ level: RichContentServerLevel;
10
+ className?: string;
11
+ /** Nested-rendering depth cap (standard). */
12
+ depthCap?: number;
13
+ /** Typography variant (standard); `reading` for long-form public pages. */
14
+ variant?: RichContentVariant;
15
+ /** Inline only: `text` when the content sits inside a link (card previews). */
16
+ links?: InlineLinks;
17
+ }
18
+ /** The server twin of BasicMarkdownContent's static markup (same frame, same map). */
19
+ export declare function ProseServer({ content, numbering, renderNested, }: {
20
+ content: string;
21
+ /** The whole document's numbering (from the static root); none for a lone leaf. */
22
+ numbering?: DocumentNumbering | null;
23
+ /** Block bodies of directive containers, rendered by the static root. */
24
+ renderNested?: (source: string) => ReactNode;
25
+ }): import("react").JSX.Element;
26
+ export declare function RichContentServer({ source, level, className, depthCap, variant, links, }: RichContentServerProps): import("react").JSX.Element;
27
+ export default RichContentServer;