@ai-matrx/rich-content 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/code-block/CodeBlock.d.ts +44 -0
- package/dist/code-block/CodeBlock.js +449 -0
- package/dist/code-block/CodeBlockHeader.d.ts +63 -0
- package/dist/code-block/CodeBlockHeader.js +472 -0
- package/dist/code-block/CodeEditorLoading.d.ts +3 -0
- package/dist/code-block/CodeEditorLoading.js +34 -0
- package/dist/code-block/LanguageDisplay.d.ts +28 -0
- package/dist/code-block/LanguageDisplay.js +279 -0
- package/dist/code-block/SmallCodeEditor.d.ts +30 -0
- package/dist/code-block/SmallCodeEditor.js +22 -0
- package/dist/code-block/StickyButtons.d.ts +35 -0
- package/dist/code-block/StickyButtons.js +88 -0
- package/dist/code-block/highlight/ShikiCodeView.d.ts +26 -0
- package/dist/code-block/highlight/ShikiCodeView.js +134 -0
- package/dist/code-block/highlight/shiki-highlighter.d.ts +14 -0
- package/dist/code-block/highlight/shiki-highlighter.js +126 -0
- package/dist/code-block/highlight/useHighlightedLines.d.ts +18 -0
- package/dist/code-block/highlight/useHighlightedLines.js +142 -0
- package/dist/code-block/sticky-inset.d.ts +6 -0
- package/dist/code-block/sticky-inset.js +10 -0
- package/dist/display/block-interaction.d.ts +33 -0
- package/dist/display/block-interaction.js +13 -0
- package/dist/display/blocks/ChatCollapsibleWrapper.d.ts +13 -0
- package/dist/display/blocks/ChatCollapsibleWrapper.js +56 -0
- package/dist/display/blocks/buildMediaSource.d.ts +25 -0
- package/dist/display/blocks/buildMediaSource.js +43 -0
- package/dist/display/blocks/canvas-adaptive.d.ts +118 -0
- package/dist/display/blocks/canvas-adaptive.js +127 -0
- package/dist/display/blocks/canvas-fit.d.ts +24 -0
- package/dist/display/blocks/canvas-fit.js +19 -0
- package/dist/display/blocks/chart/ChartBlock.d.ts +8 -0
- package/dist/display/blocks/chart/ChartBlock.js +125 -0
- package/dist/display/blocks/chart/ChartCanvas.d.ts +18 -0
- package/dist/display/blocks/chart/ChartCanvas.js +159 -0
- package/dist/display/blocks/chart/TableChart.d.ts +25 -0
- package/dist/display/blocks/chart/TableChart.js +97 -0
- package/dist/display/blocks/chart/chart-spec.d.ts +39 -0
- package/dist/display/blocks/chart/chart-spec.js +128 -0
- package/dist/display/blocks/chart/labels.d.ts +20 -0
- package/dist/display/blocks/chart/labels.js +7 -0
- package/dist/display/blocks/chart/table-chart.d.ts +37 -0
- package/dist/display/blocks/chart/table-chart.js +231 -0
- package/dist/display/blocks/common/BlockHeaderWrapper.d.ts +56 -0
- package/dist/display/blocks/common/BlockHeaderWrapper.js +310 -0
- package/dist/display/blocks/common/ContentBlockWrapper.d.ts +40 -0
- package/dist/display/blocks/common/ContentBlockWrapper.js +214 -0
- package/dist/display/blocks/common/SandboxedHtml.d.ts +27 -0
- package/dist/display/blocks/common/SandboxedHtml.js +26 -0
- package/dist/display/blocks/diagram/DiagramLoadingVisualization.d.ts +6 -0
- package/dist/display/blocks/diagram/DiagramLoadingVisualization.js +190 -0
- package/dist/display/blocks/diagram/InteractiveDiagramBlock.d.ts +51 -0
- package/dist/display/blocks/diagram/InteractiveDiagramBlock.js +2415 -0
- package/dist/display/blocks/diagram/diagram-printer.d.ts +16 -0
- package/dist/display/blocks/diagram/diagram-printer.js +294 -0
- package/dist/display/blocks/diagram/diagram-visual-defaults.d.ts +116 -0
- package/dist/display/blocks/diagram/diagram-visual-defaults.js +400 -0
- package/dist/display/blocks/diagram/layout-utils.d.ts +90 -0
- package/dist/display/blocks/diagram/layout-utils.js +347 -0
- package/dist/display/blocks/diagram/parseDiagramJSON.d.ts +105 -0
- package/dist/display/blocks/diagram/parseDiagramJSON.js +296 -0
- package/dist/display/blocks/diagram/presentation-direction.d.ts +29 -0
- package/dist/display/blocks/diagram/presentation-direction.js +19 -0
- package/dist/display/blocks/diagram/ui-utils.d.ts +1 -0
- package/dist/display/blocks/diagram/ui-utils.js +18 -0
- package/dist/display/blocks/diff/DiffBlock.d.ts +10 -0
- package/dist/display/blocks/diff/DiffBlock.js +119 -0
- package/dist/display/blocks/diff/DiffCanvas.d.ts +15 -0
- package/dist/display/blocks/diff/DiffCanvas.js +20 -0
- package/dist/display/blocks/generic/GenericStructuredBlock.d.ts +24 -0
- package/dist/display/blocks/generic/GenericStructuredBlock.js +53 -0
- package/dist/display/blocks/generic/StructuredValueTabs.d.ts +21 -0
- package/dist/display/blocks/generic/StructuredValueTabs.js +124 -0
- package/dist/display/blocks/generic/tile-actions-slot.d.ts +39 -0
- package/dist/display/blocks/generic/tile-actions-slot.js +33 -0
- package/dist/display/blocks/images/ImageBlock.d.ts +8 -0
- package/dist/display/blocks/images/ImageBlock.js +265 -0
- package/dist/display/blocks/json/JsonBlock.d.ts +34 -0
- package/dist/display/blocks/json/JsonBlock.js +562 -0
- package/dist/display/blocks/json/JsonTableView.d.ts +10 -0
- package/dist/display/blocks/json/JsonTableView.js +173 -0
- package/dist/display/blocks/json/json-compact-stringify.d.ts +25 -0
- package/dist/display/blocks/json/json-compact-stringify.js +52 -0
- package/dist/display/blocks/json/json-tabular-utils.d.ts +65 -0
- package/dist/display/blocks/json/json-tabular-utils.js +121 -0
- package/dist/display/blocks/links/LinkComponent.d.ts +6 -0
- package/dist/display/blocks/links/LinkComponent.js +373 -0
- package/dist/display/blocks/links/LinkComponentWithFetch.d.ts +1 -0
- package/dist/display/blocks/links/LinkComponentWithFetch.js +0 -0
- package/dist/display/blocks/markdown/MarkdownKindBlock.d.ts +48 -0
- package/dist/display/blocks/markdown/MarkdownKindBlock.js +52 -0
- package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.d.ts +17 -0
- package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.js +70 -0
- package/dist/display/blocks/mermaid/MermaidBlock.d.ts +19 -0
- package/dist/display/blocks/mermaid/MermaidBlock.js +386 -0
- package/dist/display/blocks/search-replace/SearchReplaceBlock.d.ts +50 -0
- package/dist/display/blocks/search-replace/SearchReplaceBlock.js +71 -0
- package/dist/display/blocks/svg/SvgBlock.d.ts +8 -0
- package/dist/display/blocks/svg/SvgBlock.js +126 -0
- package/dist/display/blocks/table/StreamingTableRenderer.d.ts +53 -0
- package/dist/display/blocks/table/StreamingTableRenderer.js +907 -0
- package/dist/display/blocks/table/TableRenderPathDiagnostic.d.ts +21 -0
- package/dist/display/blocks/table/TableRenderPathDiagnostic.js +79 -0
- package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.d.ts +14 -0
- package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.js +15 -0
- package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.d.ts +13 -0
- package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.js +19 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTrace.d.ts +30 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTrace.js +75 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.d.ts +13 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.js +48 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.d.ts +12 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.js +19 -0
- package/dist/display/blocks/toml/TomlBlock.d.ts +7 -0
- package/dist/display/blocks/toml/TomlBlock.js +167 -0
- package/dist/display/blocks/tree/TreeBlock.d.ts +7 -0
- package/dist/display/blocks/tree/TreeBlock.js +163 -0
- package/dist/display/blocks/xml/XmlBlock.d.ts +23 -0
- package/dist/display/blocks/xml/XmlBlock.js +197 -0
- package/dist/display/blocks/xml/readXmlTag.d.ts +1 -0
- package/dist/display/blocks/xml/readXmlTag.js +1 -0
- package/dist/display/blocks/xml/xml-tokenize.d.ts +13 -0
- package/dist/display/blocks/xml/xml-tokenize.js +169 -0
- package/dist/display/blocks/yaml/YamlBlock.d.ts +7 -0
- package/dist/display/blocks/yaml/YamlBlock.js +191 -0
- package/dist/display/chat-markdown/BasicMarkdownContent.d.ts +29 -0
- package/dist/display/chat-markdown/BasicMarkdownContent.js +122 -0
- package/dist/display/chat-markdown/BlockRenderingContext.d.ts +23 -0
- package/dist/display/chat-markdown/BlockRenderingContext.js +17 -0
- package/dist/display/chat-markdown/ConfigurableMarkdownContent.d.ts +172 -0
- package/dist/display/chat-markdown/ConfigurableMarkdownContent.js +649 -0
- package/dist/display/chat-markdown/InlineCodeSnippet.d.ts +19 -0
- package/dist/display/chat-markdown/InlineCodeSnippet.js +146 -0
- package/dist/display/chat-markdown/InlineCodeSnippetKindGate.d.ts +11 -0
- package/dist/display/chat-markdown/InlineCodeSnippetKindGate.js +9 -0
- package/dist/display/chat-markdown/KindTextGate.d.ts +31 -0
- package/dist/display/chat-markdown/KindTextGate.js +60 -0
- package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.d.ts +6 -0
- package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.js +92 -0
- package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.d.ts +72 -0
- package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.js +94 -0
- package/dist/display/chat-markdown/block-registry/BlockRenderer.d.ts +126 -0
- package/dist/display/chat-markdown/block-registry/BlockRenderer.js +473 -0
- package/dist/display/chat-markdown/block-registry/block-dispatch.d.ts +410 -0
- package/dist/display/chat-markdown/block-registry/block-dispatch.js +495 -0
- package/dist/display/chat-markdown/block-registry/json-parse-utils.d.ts +13 -0
- package/dist/display/chat-markdown/block-registry/json-parse-utils.js +236 -0
- package/dist/display/chat-markdown/constants.d.ts +14 -0
- package/dist/display/chat-markdown/constants.js +317 -0
- package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.d.ts +31 -0
- package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.js +62 -0
- package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.d.ts +12 -0
- package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.js +18 -0
- package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.d.ts +22 -0
- package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.js +130 -0
- package/dist/display/chat-markdown/diff-blocks/diff-style-registry.d.ts +21 -0
- package/dist/display/chat-markdown/diff-blocks/diff-style-registry.js +91 -0
- package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.d.ts +26 -0
- package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.js +186 -0
- package/dist/display/chat-markdown/diff-blocks/types.d.ts +56 -0
- package/dist/display/chat-markdown/diff-blocks/types.js +0 -0
- package/dist/display/chat-markdown/internal-handlers/BlockFallback.d.ts +20 -0
- package/dist/display/chat-markdown/internal-handlers/BlockFallback.js +83 -0
- package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.d.ts +4 -0
- package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.js +16 -0
- package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.d.ts +17 -0
- package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.js +40 -0
- package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.d.ts +8 -0
- package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.js +91 -0
- package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.d.ts +20 -0
- package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.js +72 -0
- package/dist/display/chat-markdown/kind-source-view.d.ts +14 -0
- package/dist/display/chat-markdown/kind-source-view.js +14 -0
- package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.d.ts +28 -0
- package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.js +65 -0
- package/dist/display/chat-markdown/progressive-mount.d.ts +18 -0
- package/dist/display/chat-markdown/progressive-mount.js +90 -0
- package/dist/display/chat-markdown/render-block-to-content-block.d.ts +31 -0
- package/dist/display/chat-markdown/render-block-to-content-block.js +32 -0
- package/dist/display/chat-markdown/settle-stream-blocks.d.ts +50 -0
- package/dist/display/chat-markdown/settle-stream-blocks.js +26 -0
- package/dist/display/chat-markdown/stable-blocks.d.ts +15 -0
- package/dist/display/chat-markdown/stable-blocks.js +54 -0
- package/dist/display/chat-markdown/types.d.ts +11 -0
- package/dist/display/chat-markdown/types.js +26 -0
- package/dist/display/specimen/SpecimenContext.d.ts +26 -0
- package/dist/display/specimen/SpecimenContext.js +64 -0
- package/dist/display/tables/MarkdownTable.d.ts +23 -0
- package/dist/display/tables/MarkdownTable.js +769 -0
- package/dist/display/tables/MarkdownTableScrollArea.d.ts +12 -0
- package/dist/display/tables/MarkdownTableScrollArea.js +92 -0
- package/dist/display/tables/SendToGoogleSheetButton.d.ts +19 -0
- package/dist/display/tables/SendToGoogleSheetButton.js +93 -0
- package/dist/display/tables/SendToWorkbookButton.d.ts +24 -0
- package/dist/display/tables/SendToWorkbookButton.js +93 -0
- package/dist/display/tables/TableSaveToMenu.d.ts +16 -0
- package/dist/display/tables/TableSaveToMenu.js +98 -0
- package/dist/display/tables/TableWithSeparatedControls.d.ts +22 -0
- package/dist/display/tables/TableWithSeparatedControls.js +574 -0
- package/dist/display/tables/ViewTableModal.d.ts +14 -0
- package/dist/display/tables/ViewTableModal.js +67 -0
- package/dist/display/tables/editing/ColumnActionsMenu.d.ts +16 -0
- package/dist/display/tables/editing/ColumnActionsMenu.js +80 -0
- package/dist/display/tables/editing/RowActionsMenu.d.ts +16 -0
- package/dist/display/tables/editing/RowActionsMenu.js +80 -0
- package/dist/display/tables/editing/TableEditToolbar.d.ts +15 -0
- package/dist/display/tables/editing/TableEditToolbar.js +63 -0
- package/dist/display/tables/editing/tableMutations.d.ts +50 -0
- package/dist/display/tables/editing/tableMutations.js +148 -0
- package/dist/display/tables/editing/useDoubleClickEdit.d.ts +43 -0
- package/dist/display/tables/editing/useDoubleClickEdit.js +51 -0
- package/dist/display/tables/editing/useTableUndo.d.ts +25 -0
- package/dist/display/tables/editing/useTableUndo.js +17 -0
- package/dist/display/tables/table-action-row.d.ts +8 -0
- package/dist/display/tables/table-action-row.js +31 -0
- package/dist/display/tables/table-viewer.d.ts +13 -0
- package/dist/display/tables/table-viewer.js +18 -0
- package/dist/host/ErrorActions.d.ts +1 -1
- package/dist/host/ErrorNotice.d.ts +10 -0
- package/dist/host/ErrorNotice.js +19 -0
- package/dist/host/app-bindings.d.ts +155 -0
- package/dist/host/app-bindings.js +160 -0
- package/dist/host/diagnostics.d.ts +2 -2
- package/dist/host/diagnostics.js +2 -1
- package/dist/host/tables.d.ts +1 -6
- package/dist/host/types.d.ts +14 -7
- package/dist/levels/RichContent.d.ts +3 -0
- package/dist/levels/RichContent.js +102 -0
- package/dist/levels/RichContentInline.d.ts +28 -0
- package/dist/levels/RichContentInline.js +61 -0
- package/dist/levels/RichContentPreview.d.ts +12 -0
- package/dist/levels/RichContentPreview.js +39 -0
- package/dist/levels/RichContentStandardImpl.d.ts +12 -0
- package/dist/levels/RichContentStandardImpl.js +27 -0
- package/dist/levels/RichContentStaticProse.d.ts +46 -0
- package/dist/levels/RichContentStaticProse.js +100 -0
- package/dist/levels/depth.d.ts +18 -0
- package/dist/levels/depth.js +32 -0
- package/dist/levels/prose/inline-level-elements.d.ts +19 -0
- package/dist/levels/prose/inline-level-elements.js +103 -0
- package/dist/levels/prose/prose-block-elements.d.ts +25 -0
- package/dist/levels/prose/prose-block-elements.js +313 -0
- package/dist/levels/prose/prose-inline-elements.d.ts +13 -0
- package/dist/levels/prose/prose-inline-elements.js +143 -0
- package/dist/levels/prose/prose-prepare.d.ts +50 -0
- package/dist/levels/prose/prose-prepare.js +246 -0
- package/dist/levels/prose/remote-image-policy.d.ts +34 -0
- package/dist/levels/prose/remote-image-policy.js +153 -0
- package/dist/levels/prose/variant-root.d.ts +9 -0
- package/dist/levels/prose/variant-root.js +34 -0
- package/dist/levels/rich-content-types.d.ts +93 -0
- package/dist/levels/rich-content-types.js +4 -0
- package/dist/levels/server/DelimiterViolationReport.d.ts +7 -0
- package/dist/levels/server/DelimiterViolationReport.js +24 -0
- package/dist/levels/server/RichContentServer.d.ts +27 -0
- package/dist/levels/server/RichContentServer.js +97 -0
- package/dist/levels/standard/NestedRichContent.d.ts +7 -0
- package/dist/levels/standard/NestedRichContent.js +70 -0
- package/dist/levels/standard/StandardBlocks.d.ts +13 -0
- package/dist/levels/standard/StandardBlocks.js +239 -0
- package/dist/levels/standard/StandardKindRegion.d.ts +14 -0
- package/dist/levels/standard/StandardKindRegion.js +69 -0
- package/dist/levels/standard/standard-kind-region.d.ts +19 -0
- package/dist/levels/standard/standard-kind-region.js +21 -0
- package/dist/levels/standard/static-standard.d.ts +23 -0
- package/dist/levels/standard/static-standard.js +187 -0
- package/dist/levels/standard/stream-holdback.d.ts +2 -0
- package/dist/levels/standard/stream-holdback.js +77 -0
- package/dist/mermaid/MermaidFullscreen.d.ts +17 -0
- package/dist/mermaid/MermaidFullscreen.js +71 -0
- package/dist/mermaid/MermaidRenderer.d.ts +20 -0
- package/dist/mermaid/MermaidRenderer.js +267 -0
- package/dist/mermaid/MermaidView.d.ts +27 -0
- package/dist/mermaid/MermaidView.js +68 -0
- package/dist/mermaid/MermaidViewport.d.ts +75 -0
- package/dist/mermaid/MermaidViewport.js +286 -0
- package/dist/mermaid/adapters/er.d.ts +10 -0
- package/dist/mermaid/adapters/er.js +205 -0
- package/dist/mermaid/adapters/flowchart.d.ts +17 -0
- package/dist/mermaid/adapters/flowchart.js +634 -0
- package/dist/mermaid/adapters/journey.d.ts +9 -0
- package/dist/mermaid/adapters/journey.js +207 -0
- package/dist/mermaid/adapters/mindmap.d.ts +12 -0
- package/dist/mermaid/adapters/mindmap.js +252 -0
- package/dist/mermaid/adapters/pie.d.ts +7 -0
- package/dist/mermaid/adapters/pie.js +172 -0
- package/dist/mermaid/adapters/quadrant.d.ts +8 -0
- package/dist/mermaid/adapters/quadrant.js +231 -0
- package/dist/mermaid/adapters/register.d.ts +7 -0
- package/dist/mermaid/adapters/register.js +19 -0
- package/dist/mermaid/adapters/sequence.d.ts +8 -0
- package/dist/mermaid/adapters/sequence.js +251 -0
- package/dist/mermaid/adapters/state.d.ts +12 -0
- package/dist/mermaid/adapters/state.js +245 -0
- package/dist/mermaid/adapters/timeline.d.ts +8 -0
- package/dist/mermaid/adapters/timeline.js +245 -0
- package/dist/mermaid/catalog.d.ts +33 -0
- package/dist/mermaid/catalog.js +202 -0
- package/dist/mermaid/diagram-type.d.ts +39 -0
- package/dist/mermaid/diagram-type.js +89 -0
- package/dist/mermaid/export.d.ts +21 -0
- package/dist/mermaid/export.js +112 -0
- package/dist/mermaid/extract-fence.d.ts +15 -0
- package/dist/mermaid/extract-fence.js +22 -0
- package/dist/mermaid/lazy-draw.d.ts +40 -0
- package/dist/mermaid/lazy-draw.js +168 -0
- package/dist/mermaid/model/adapter.d.ts +28 -0
- package/dist/mermaid/model/adapter.js +16 -0
- package/dist/mermaid/model/ops.d.ts +282 -0
- package/dist/mermaid/model/ops.js +9 -0
- package/dist/mermaid/model/round-trip.d.ts +22 -0
- package/dist/mermaid/model/round-trip.js +45 -0
- package/dist/mermaid/model/types.d.ts +271 -0
- package/dist/mermaid/model/types.js +0 -0
- package/dist/mermaid/print-render.d.ts +9 -0
- package/dist/mermaid/print-render.js +39 -0
- package/dist/mermaid/runtime.d.ts +25 -0
- package/dist/mermaid/runtime.js +183 -0
- package/dist/mermaid/sanitize.d.ts +46 -0
- package/dist/mermaid/sanitize.js +234 -0
- package/dist/mermaid/types.d.ts +43 -0
- package/dist/mermaid/types.js +21 -0
- package/dist/mermaid/view/ViewModePane.d.ts +24 -0
- package/dist/mermaid/view/ViewModePane.js +9 -0
- package/dist/utils/client-lazy.d.ts +1 -1
- package/dist/utils/client-lazy.js +4 -1
- package/dist/utils/lifted/DiffView.d.ts +10 -0
- package/dist/utils/lifted/DiffView.js +26 -0
- package/dist/utils/lifted/IconButton.d.ts +24 -0
- package/dist/utils/lifted/IconButton.js +43 -0
- package/dist/utils/lifted/MatrxMiniLoader.d.ts +1 -0
- package/dist/utils/lifted/MatrxMiniLoader.js +8 -0
- package/dist/utils/lifted/ShimmerText.d.ts +5 -0
- package/dist/utils/lifted/ShimmerText.js +21 -0
- package/dist/utils/lifted/SuspenseLoader.d.ts +16 -0
- package/dist/utils/lifted/SuspenseLoader.js +42 -0
- package/dist/utils/lifted/Tooltip.d.ts +20 -0
- package/dist/utils/lifted/Tooltip.js +52 -0
- package/dist/utils/lifted/artifactId.d.ts +34 -0
- package/dist/utils/lifted/artifactId.js +15 -0
- package/dist/utils/lifted/canvasContent.d.ts +63 -0
- package/dist/utils/lifted/canvasContent.js +98 -0
- package/dist/utils/lifted/captureReactError.d.ts +24 -0
- package/dist/utils/lifted/captureReactError.js +28 -0
- package/dist/utils/lifted/chunk-load-recovery.d.ts +25 -0
- package/dist/utils/lifted/chunk-load-recovery.js +36 -0
- package/dist/utils/lifted/code-editor-agent-types.d.ts +6 -0
- package/dist/utils/lifted/code-editor-agent-types.js +0 -0
- package/dist/utils/lifted/code-editor-agents.d.ts +39 -0
- package/dist/utils/lifted/code-editor-agents.js +52 -0
- package/dist/utils/lifted/code-language-extension.d.ts +1 -0
- package/dist/utils/lifted/code-language-extension.js +60 -0
- package/dist/utils/lifted/custom-icons.d.ts +16 -0
- package/dist/utils/lifted/custom-icons.js +47 -0
- package/dist/utils/lifted/durability.d.ts +16 -0
- package/dist/utils/lifted/durability.js +45 -0
- package/dist/utils/lifted/errors.d.ts +30 -0
- package/dist/utils/lifted/errors.js +29 -0
- package/dist/utils/lifted/html-document.d.ts +1 -0
- package/dist/utils/lifted/html-document.js +12 -0
- package/dist/utils/lifted/languageOptions.d.ts +9 -0
- package/dist/utils/lifted/languageOptions.js +52 -0
- package/dist/utils/lifted/languages.d.ts +34 -0
- package/dist/utils/lifted/languages.js +175 -0
- package/dist/utils/lifted/loading-spinner.d.ts +18 -0
- package/dist/utils/lifted/loading-spinner.js +200 -0
- package/dist/utils/lifted/media-refs.d.ts +13 -0
- package/dist/utils/lifted/media-refs.js +27 -0
- package/dist/utils/lifted/scroll-root.d.ts +1 -0
- package/dist/utils/lifted/scroll-root.js +25 -0
- package/dist/utils/lifted/syntax-themes.d.ts +32 -0
- package/dist/utils/lifted/syntax-themes.js +100 -0
- package/dist/utils/lifted/url-utm.d.ts +24 -0
- package/dist/utils/lifted/url-utm.js +66 -0
- package/dist/utils/lifted/use-is-mounted.d.ts +24 -0
- package/dist/utils/lifted/use-is-mounted.js +21 -0
- package/dist/utils/lifted/useToastManager.d.ts +1 -0
- package/dist/utils/lifted/useToastManager.js +7 -0
- package/dist/utils/report-kind-at-raw-renderer.d.ts +19 -0
- package/dist/utils/report-kind-at-raw-renderer.js +32 -0
- package/package.json +32 -3
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
NO_SPLITTER_ENVELOPES,
|
|
4
|
+
splitContentIntoBlocksWith
|
|
5
|
+
} from "../../display/markdown-classification/processors/utils/content-splitter-core.js";
|
|
6
|
+
import { RichContentDepthProvider } from "../depth.js";
|
|
7
|
+
import { fenceNestsInnerFences } from "@ai-matrx/content-ir/source";
|
|
8
|
+
import MarkdownPreviewBlock from "../../display/blocks/markdown-preview/MarkdownPreviewBlock.js";
|
|
9
|
+
import { StandardBlock } from "./StandardBlocks.js";
|
|
10
|
+
import XmlBlock from "../../display/blocks/xml/XmlBlock.js";
|
|
11
|
+
import { isQuotedSourceXmlBlock } from "@ai-matrx/content-ir/surfaces";
|
|
12
|
+
import { tokenizeXml } from "../../display/blocks/xml/xml-tokenize.js";
|
|
13
|
+
import {
|
|
14
|
+
computeDocumentNumbering,
|
|
15
|
+
documentFootnoteSource
|
|
16
|
+
} from "../../markdown-core/syntax/document-numbering.js";
|
|
17
|
+
import { DocumentNumberingProvider } from "../../markdown-core/syntax/elements/DocumentNumbering.js";
|
|
18
|
+
import { RemoteImageGate } from "../prose/remote-image-policy.js";
|
|
19
|
+
const SECTION_TYPES = /* @__PURE__ */ new Set([
|
|
20
|
+
"info",
|
|
21
|
+
"task",
|
|
22
|
+
"plan",
|
|
23
|
+
"database",
|
|
24
|
+
"private",
|
|
25
|
+
"event",
|
|
26
|
+
"tool",
|
|
27
|
+
"thinking",
|
|
28
|
+
"reasoning",
|
|
29
|
+
"consolidated_reasoning"
|
|
30
|
+
]);
|
|
31
|
+
const XML_LANGUAGES = /* @__PURE__ */ new Set(["xml", "svg"]);
|
|
32
|
+
const MUTED_SECTIONS = /* @__PURE__ */ new Set([
|
|
33
|
+
"thinking",
|
|
34
|
+
"reasoning",
|
|
35
|
+
"consolidated_reasoning"
|
|
36
|
+
]);
|
|
37
|
+
function StaticBlock({
|
|
38
|
+
block,
|
|
39
|
+
depth,
|
|
40
|
+
cap,
|
|
41
|
+
Prose,
|
|
42
|
+
numbering
|
|
43
|
+
}) {
|
|
44
|
+
const { type, content } = block;
|
|
45
|
+
if (type === "text" || type === "table") {
|
|
46
|
+
if (!content.trim()) return null;
|
|
47
|
+
return /* @__PURE__ */ jsx(
|
|
48
|
+
Prose,
|
|
49
|
+
{
|
|
50
|
+
content,
|
|
51
|
+
numbering,
|
|
52
|
+
renderNested: depth + 1 <= cap ? (source) => /* @__PURE__ */ jsx(
|
|
53
|
+
StaticStandard,
|
|
54
|
+
{
|
|
55
|
+
source,
|
|
56
|
+
depth: depth + 1,
|
|
57
|
+
cap,
|
|
58
|
+
Prose,
|
|
59
|
+
numbering
|
|
60
|
+
}
|
|
61
|
+
) : void 0
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
if (SECTION_TYPES.has(type) && depth + 1 <= cap) {
|
|
66
|
+
if (!content.trim()) return null;
|
|
67
|
+
return /* @__PURE__ */ jsx(
|
|
68
|
+
"div",
|
|
69
|
+
{
|
|
70
|
+
"data-rich-content-section": type,
|
|
71
|
+
className: MUTED_SECTIONS.has(type) ? "my-2 border-l-2 border-border pl-3 text-muted-foreground" : "my-2",
|
|
72
|
+
children: /* @__PURE__ */ jsx(StaticStandard, { source: content, depth: depth + 1, cap, Prose, numbering })
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
if (type === "code" && fenceNestsInnerFences(block.language?.toLowerCase()) && depth + 1 <= cap) {
|
|
77
|
+
return /* @__PURE__ */ jsx(RichContentDepthProvider, { depth, cap, children: /* @__PURE__ */ jsx(
|
|
78
|
+
MarkdownPreviewBlock,
|
|
79
|
+
{
|
|
80
|
+
content,
|
|
81
|
+
renderedPreview: /* @__PURE__ */ jsx(StaticStandard, { source: content, depth: depth + 1, cap, Prose, numbering })
|
|
82
|
+
}
|
|
83
|
+
) });
|
|
84
|
+
}
|
|
85
|
+
const xmlLanguage = type === "svg" ? "svg" : type === "code" ? block.language?.toLowerCase() : void 0;
|
|
86
|
+
if (xmlLanguage && XML_LANGUAGES.has(xmlLanguage) && depth + 1 <= cap) {
|
|
87
|
+
const renderedProse = {};
|
|
88
|
+
tokenizeXml(content).forEach((token, idx) => {
|
|
89
|
+
if (token.type === "markdown" && token.text?.trim()) {
|
|
90
|
+
renderedProse[idx] = /* @__PURE__ */ jsx(
|
|
91
|
+
StaticStandard,
|
|
92
|
+
{
|
|
93
|
+
source: token.text,
|
|
94
|
+
depth: depth + 1,
|
|
95
|
+
cap,
|
|
96
|
+
Prose,
|
|
97
|
+
numbering
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
return /* @__PURE__ */ jsx(RichContentDepthProvider, { depth, cap, children: /* @__PURE__ */ jsx(
|
|
103
|
+
XmlBlock,
|
|
104
|
+
{
|
|
105
|
+
content,
|
|
106
|
+
language: xmlLanguage,
|
|
107
|
+
renderedProse,
|
|
108
|
+
quotedSource: isQuotedSourceXmlBlock(block)
|
|
109
|
+
}
|
|
110
|
+
) });
|
|
111
|
+
}
|
|
112
|
+
if (type === "image" && block.src) {
|
|
113
|
+
return /* @__PURE__ */ jsx(RemoteImageGate, { src: block.src, alt: block.alt, block: true, children: /* @__PURE__ */ jsx(
|
|
114
|
+
"img",
|
|
115
|
+
{
|
|
116
|
+
src: block.src,
|
|
117
|
+
alt: block.alt || "",
|
|
118
|
+
referrerPolicy: "no-referrer",
|
|
119
|
+
className: "my-2 h-auto max-w-full rounded-md object-contain"
|
|
120
|
+
}
|
|
121
|
+
) });
|
|
122
|
+
}
|
|
123
|
+
if (type === "accent-divider" || type === "heavy-divider") {
|
|
124
|
+
return /* @__PURE__ */ jsx("hr", { className: "my-4 border-border" });
|
|
125
|
+
}
|
|
126
|
+
return /* @__PURE__ */ jsx(RichContentDepthProvider, { depth, cap, children: /* @__PURE__ */ jsx(
|
|
127
|
+
StandardBlock,
|
|
128
|
+
{
|
|
129
|
+
block: {
|
|
130
|
+
type,
|
|
131
|
+
content,
|
|
132
|
+
language: block.language,
|
|
133
|
+
src: block.src,
|
|
134
|
+
alt: block.alt,
|
|
135
|
+
// The fence meta (title, highlighted lines) — fence-meta.ts.
|
|
136
|
+
metadata: block.metadata
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
) });
|
|
140
|
+
}
|
|
141
|
+
function StaticStandard({
|
|
142
|
+
source,
|
|
143
|
+
depth,
|
|
144
|
+
cap,
|
|
145
|
+
className,
|
|
146
|
+
Prose,
|
|
147
|
+
numbering
|
|
148
|
+
}) {
|
|
149
|
+
const blocks = splitContentIntoBlocksWith(source, NO_SPLITTER_ENVELOPES);
|
|
150
|
+
const isRoot = numbering === void 0;
|
|
151
|
+
const docNumbering = numbering ?? computeDocumentNumbering(source);
|
|
152
|
+
const body = /* @__PURE__ */ jsxs(
|
|
153
|
+
"div",
|
|
154
|
+
{
|
|
155
|
+
"data-rich-content": "standard",
|
|
156
|
+
"data-matrx-doc-root": "",
|
|
157
|
+
className: className ?? "min-w-0",
|
|
158
|
+
children: [
|
|
159
|
+
blocks.map((block, index) => /* @__PURE__ */ jsx(
|
|
160
|
+
StaticBlock,
|
|
161
|
+
{
|
|
162
|
+
block,
|
|
163
|
+
depth,
|
|
164
|
+
cap,
|
|
165
|
+
Prose,
|
|
166
|
+
numbering: docNumbering
|
|
167
|
+
},
|
|
168
|
+
index
|
|
169
|
+
)),
|
|
170
|
+
isRoot && documentFootnoteSource(docNumbering) ? /* @__PURE__ */ jsx(
|
|
171
|
+
StaticBlock,
|
|
172
|
+
{
|
|
173
|
+
block: { type: "text", content: documentFootnoteSource(docNumbering) },
|
|
174
|
+
depth,
|
|
175
|
+
cap,
|
|
176
|
+
Prose,
|
|
177
|
+
numbering: docNumbering
|
|
178
|
+
}
|
|
179
|
+
) : null
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
return isRoot ? /* @__PURE__ */ jsx(DocumentNumberingProvider, { source, children: body }) : body;
|
|
184
|
+
}
|
|
185
|
+
export {
|
|
186
|
+
StaticStandard
|
|
187
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { fenceLineKinds } from "@ai-matrx/content-ir/source";
|
|
2
|
+
import {
|
|
3
|
+
isGfmDelimiterRow,
|
|
4
|
+
startsLikeTableRow,
|
|
5
|
+
trailingTableStart
|
|
6
|
+
} from "../../display/markdown-classification/processors/utils/gfm-table-lines.js";
|
|
7
|
+
const TEX_SIGNAL = /\\[A-Za-z]+|[\\^_{}]/;
|
|
8
|
+
function openFenceStart(source) {
|
|
9
|
+
const kinds = fenceLineKinds(source);
|
|
10
|
+
let open = -1;
|
|
11
|
+
let openAt = -1;
|
|
12
|
+
let offset = 0;
|
|
13
|
+
source.split("\n").forEach((line, i) => {
|
|
14
|
+
if (kinds[i] === "open") {
|
|
15
|
+
open = i;
|
|
16
|
+
openAt = offset;
|
|
17
|
+
} else if (kinds[i] !== "body") open = -1;
|
|
18
|
+
offset += line.length + 1;
|
|
19
|
+
});
|
|
20
|
+
return open === -1 ? -1 : openAt;
|
|
21
|
+
}
|
|
22
|
+
function holdBackTable(text) {
|
|
23
|
+
const lines = text.split("\n");
|
|
24
|
+
let end = lines.length;
|
|
25
|
+
while (end > 0 && lines[end - 1].trim() === "") end--;
|
|
26
|
+
const start = trailingTableStart(lines, end);
|
|
27
|
+
if (start === end) return text;
|
|
28
|
+
const rows = lines.slice(start, end);
|
|
29
|
+
const hasDelimiter = rows.some((row) => isGfmDelimiterRow(row));
|
|
30
|
+
if (!hasDelimiter) {
|
|
31
|
+
return lines.slice(0, start).join("\n");
|
|
32
|
+
}
|
|
33
|
+
const last = rows[rows.length - 1].trimEnd();
|
|
34
|
+
if (end === lines.length && startsLikeTableRow(rows[0]) && !last.endsWith("|")) {
|
|
35
|
+
return lines.slice(0, end - 1).join("\n");
|
|
36
|
+
}
|
|
37
|
+
return text;
|
|
38
|
+
}
|
|
39
|
+
function holdBackMath(text) {
|
|
40
|
+
const displays = [...text.matchAll(/\$\$/g)];
|
|
41
|
+
if (displays.length % 2 === 1) {
|
|
42
|
+
return text.slice(0, displays[displays.length - 1].index);
|
|
43
|
+
}
|
|
44
|
+
for (const [open, close] of [
|
|
45
|
+
["\\[", "\\]"],
|
|
46
|
+
["\\(", "\\)"]
|
|
47
|
+
]) {
|
|
48
|
+
const at = text.lastIndexOf(open);
|
|
49
|
+
if (at !== -1 && text.indexOf(close, at + open.length) === -1) {
|
|
50
|
+
return text.slice(0, at);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const lineStart = text.lastIndexOf("\n") + 1;
|
|
54
|
+
const lastLine = text.slice(lineStart).replace(/\$\$/g, " ");
|
|
55
|
+
const dollars = [...lastLine.matchAll(/(?<!\\)\$/g)];
|
|
56
|
+
if (dollars.length % 2 === 1) {
|
|
57
|
+
const at = dollars[dollars.length - 1].index;
|
|
58
|
+
if (TEX_SIGNAL.test(lastLine.slice(at + 1))) {
|
|
59
|
+
return text.slice(0, lineStart + at);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return text;
|
|
63
|
+
}
|
|
64
|
+
function healStreamingTail(source) {
|
|
65
|
+
const lastNewline = source.lastIndexOf("\n");
|
|
66
|
+
const lastLine = source.slice(lastNewline + 1);
|
|
67
|
+
if (/^\s*`{1,2}\s*$/.test(lastLine)) return source.slice(0, lastNewline + 1);
|
|
68
|
+
const partialTag = /<\/?[A-Za-z][\w:-]*(?:\s[^<>]*)?$/.exec(lastLine);
|
|
69
|
+
if (partialTag) {
|
|
70
|
+
return source.slice(0, lastNewline + 1 + partialTag.index);
|
|
71
|
+
}
|
|
72
|
+
if (openFenceStart(source) !== -1) return source;
|
|
73
|
+
return holdBackMath(holdBackTable(source));
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
healStreamingTail
|
|
77
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MermaidFullscreen — a full-viewport overlay that shows a diagram large, with
|
|
3
|
+
* the renderer's pan/zoom. Rendered through a portal to document.body so it
|
|
4
|
+
* escapes any chat/canvas overflow clipping. Esc or the close button exits;
|
|
5
|
+
* clicking the empty margin also exits. Reused by the chat block header and any
|
|
6
|
+
* other surface that wants a "view fullscreen" affordance.
|
|
7
|
+
*/
|
|
8
|
+
import React from "react";
|
|
9
|
+
import type { MermaidRenderOptions } from "./types.js";
|
|
10
|
+
interface MermaidFullscreenProps {
|
|
11
|
+
source: string;
|
|
12
|
+
options: MermaidRenderOptions;
|
|
13
|
+
title?: string | null;
|
|
14
|
+
onClose: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function MermaidFullscreen({ source, options, title, onClose, }: MermaidFullscreenProps): React.ReactPortal | null;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { X } from "lucide-react";
|
|
6
|
+
import { SimpleTooltip } from "../utils/lifted/Tooltip.js";
|
|
7
|
+
console.log(
|
|
8
|
+
"%c[MERMAID IMPORT TEST] components/mermaid/MermaidFullscreen.tsx",
|
|
9
|
+
"color: #fff; background: #7c3aed; font-weight: bold; padding: 2px 6px; border-radius: 3px;"
|
|
10
|
+
);
|
|
11
|
+
import { cn } from "@ai-matrx/design-system";
|
|
12
|
+
import { MermaidRenderer } from "./MermaidRenderer.js";
|
|
13
|
+
function MermaidFullscreen({
|
|
14
|
+
source,
|
|
15
|
+
options,
|
|
16
|
+
title,
|
|
17
|
+
onClose
|
|
18
|
+
}) {
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const onKey = (e) => {
|
|
21
|
+
if (e.key === "Escape") onClose();
|
|
22
|
+
};
|
|
23
|
+
window.addEventListener("keydown", onKey);
|
|
24
|
+
const prevOverflow = document.body.style.overflow;
|
|
25
|
+
document.body.style.overflow = "hidden";
|
|
26
|
+
return () => {
|
|
27
|
+
window.removeEventListener("keydown", onKey);
|
|
28
|
+
document.body.style.overflow = prevOverflow;
|
|
29
|
+
};
|
|
30
|
+
}, [onClose]);
|
|
31
|
+
if (typeof document === "undefined") return null;
|
|
32
|
+
return createPortal(
|
|
33
|
+
/* @__PURE__ */ jsxs(
|
|
34
|
+
"div",
|
|
35
|
+
{
|
|
36
|
+
className: "fixed inset-0 z-[120] flex flex-col bg-background/98 backdrop-blur-sm",
|
|
37
|
+
role: "dialog",
|
|
38
|
+
"aria-modal": "true",
|
|
39
|
+
"aria-label": title ?? "Diagram (fullscreen)",
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b border-border px-4 py-2 pt-safe", children: [
|
|
42
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium text-foreground", children: title ?? "Diagram" }),
|
|
43
|
+
/* @__PURE__ */ jsx(SimpleTooltip, { text: "Exit fullscreen (Esc)", children: /* @__PURE__ */ jsx(
|
|
44
|
+
"button",
|
|
45
|
+
{
|
|
46
|
+
type: "button",
|
|
47
|
+
"aria-label": "Exit fullscreen",
|
|
48
|
+
onClick: onClose,
|
|
49
|
+
className: "rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
|
|
50
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
|
|
51
|
+
}
|
|
52
|
+
) })
|
|
53
|
+
] }),
|
|
54
|
+
/* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-hidden p-4", children: /* @__PURE__ */ jsx(
|
|
55
|
+
MermaidRenderer,
|
|
56
|
+
{
|
|
57
|
+
source,
|
|
58
|
+
options,
|
|
59
|
+
fillHeight: true,
|
|
60
|
+
className: cn("h-full w-full")
|
|
61
|
+
}
|
|
62
|
+
) })
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
document.body
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
MermaidFullscreen
|
|
71
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type LadderResult } from "./sanitize.js";
|
|
3
|
+
import type { MermaidRenderOptions } from "./types.js";
|
|
4
|
+
interface MermaidRendererProps {
|
|
5
|
+
source: string;
|
|
6
|
+
options: MermaidRenderOptions;
|
|
7
|
+
isStreamActive?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
hideViewportControls?: boolean;
|
|
10
|
+
/** Receives the live SVG element after each injection (visual-mode hook). */
|
|
11
|
+
onSvgMounted?: (el: SVGSVGElement | null) => void;
|
|
12
|
+
/** Called whenever a ladder pass finishes (diagnostics for editors). */
|
|
13
|
+
onLadderResult?: (result: LadderResult) => void;
|
|
14
|
+
/** Px cap on the diagram frame height (inline/chat). See MermaidViewport. */
|
|
15
|
+
viewportMaxHeight?: number;
|
|
16
|
+
/** Frame fills its parent's height (canvas workbench, fullscreen). */
|
|
17
|
+
fillHeight?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function MermaidRenderer({ source, options: baseOptions, isStreamActive, className, hideViewportControls, onSvgMounted, onLadderResult, viewportMaxHeight, fillHeight, }: MermaidRendererProps): React.JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useClipboard } from "@ai-matrx/kit/clipboard";
|
|
4
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
5
|
+
console.log(
|
|
6
|
+
"%c[MERMAID IMPORT TEST] components/mermaid/MermaidRenderer.tsx",
|
|
7
|
+
"color: #fff; background: #7c3aed; font-weight: bold; padding: 2px 6px; border-radius: 3px;"
|
|
8
|
+
);
|
|
9
|
+
import { useDrawWhenNear } from "./lazy-draw.js";
|
|
10
|
+
import { Copy, TriangleAlert } from "lucide-react";
|
|
11
|
+
import { toast } from "../host/toast.js";
|
|
12
|
+
import { Skeleton } from "@ai-matrx/design-system";
|
|
13
|
+
import { cn } from "@ai-matrx/design-system";
|
|
14
|
+
import { detectDiagramType, extractMermaidTitle } from "./diagram-type.js";
|
|
15
|
+
import { getCatalogEntry } from "./catalog.js";
|
|
16
|
+
import { MermaidViewport } from "./MermaidViewport.js";
|
|
17
|
+
import {
|
|
18
|
+
MermaidRenderSupersededError,
|
|
19
|
+
preloadMermaid,
|
|
20
|
+
renderMermaid,
|
|
21
|
+
supersedeMermaidRender,
|
|
22
|
+
validateMermaid
|
|
23
|
+
} from "./runtime.js";
|
|
24
|
+
import {
|
|
25
|
+
humanizeMermaidError,
|
|
26
|
+
parseWithLadder
|
|
27
|
+
} from "./sanitize.js";
|
|
28
|
+
import { renderOptionsKey } from "./types.js";
|
|
29
|
+
import { ErrorAlchemyMenu } from "../host/ErrorActions.js";
|
|
30
|
+
const STREAMING_DEBOUNCE_MS = 300;
|
|
31
|
+
const SETTLED_DEBOUNCE_MS = 250;
|
|
32
|
+
const PIE_LEGEND_STACK_BELOW_PX = 520;
|
|
33
|
+
function MermaidRenderer({
|
|
34
|
+
source,
|
|
35
|
+
options: baseOptions,
|
|
36
|
+
isStreamActive = false,
|
|
37
|
+
className,
|
|
38
|
+
hideViewportControls,
|
|
39
|
+
onSvgMounted,
|
|
40
|
+
onLadderResult,
|
|
41
|
+
viewportMaxHeight,
|
|
42
|
+
fillHeight
|
|
43
|
+
}) {
|
|
44
|
+
const [lastGoodSvg, setLastGoodSvg] = useState(null);
|
|
45
|
+
const [failure, setFailure] = useState(null);
|
|
46
|
+
const epochRef = useRef(0);
|
|
47
|
+
const rendererId = useId();
|
|
48
|
+
const onLadderResultRef = useRef(onLadderResult);
|
|
49
|
+
const frameRef = useRef(null);
|
|
50
|
+
const { shouldDraw, markDrawn } = useDrawWhenNear(frameRef);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
onLadderResultRef.current = onLadderResult;
|
|
53
|
+
});
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
preloadMermaid();
|
|
56
|
+
}, []);
|
|
57
|
+
const isPie = detectDiagramType(source) === "pie";
|
|
58
|
+
const [frameEl, setFrameEl] = useState(null);
|
|
59
|
+
const [narrowFrame, setNarrowFrame] = useState(false);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (!isPie || !frameEl) return void 0;
|
|
62
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
63
|
+
const width = entry?.contentRect.width ?? 0;
|
|
64
|
+
if (width > 0) setNarrowFrame(width < PIE_LEGEND_STACK_BELOW_PX);
|
|
65
|
+
});
|
|
66
|
+
observer.observe(frameEl);
|
|
67
|
+
return () => observer.disconnect();
|
|
68
|
+
}, [isPie, frameEl]);
|
|
69
|
+
const options = isPie ? { ...baseOptions, pieLegend: narrowFrame ? "bottom" : "right" } : baseOptions;
|
|
70
|
+
const optionsKey = renderOptionsKey(options);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
const trimmed = source.trim();
|
|
73
|
+
if (!shouldDraw) return void 0;
|
|
74
|
+
if (!trimmed) {
|
|
75
|
+
return void 0;
|
|
76
|
+
}
|
|
77
|
+
const epoch = ++epochRef.current;
|
|
78
|
+
const timer = setTimeout(
|
|
79
|
+
async () => {
|
|
80
|
+
try {
|
|
81
|
+
if (!isStreamActive) {
|
|
82
|
+
let directRenderError;
|
|
83
|
+
try {
|
|
84
|
+
const { svg } = await renderMermaid(trimmed, options, rendererId);
|
|
85
|
+
if (epoch !== epochRef.current) return;
|
|
86
|
+
setLastGoodSvg(svg);
|
|
87
|
+
setFailure(null);
|
|
88
|
+
return;
|
|
89
|
+
} catch (err) {
|
|
90
|
+
directRenderError = err;
|
|
91
|
+
}
|
|
92
|
+
const validation = await validateMermaid(trimmed);
|
|
93
|
+
if (epoch !== epochRef.current) return;
|
|
94
|
+
if (validation.ok) throw directRenderError;
|
|
95
|
+
}
|
|
96
|
+
const ladder = await parseWithLadder(trimmed, validateMermaid, {
|
|
97
|
+
streaming: isStreamActive
|
|
98
|
+
});
|
|
99
|
+
if (epoch !== epochRef.current) return;
|
|
100
|
+
onLadderResultRef.current?.(ladder);
|
|
101
|
+
if (ladder.valid) {
|
|
102
|
+
const { svg } = await renderMermaid(
|
|
103
|
+
ladder.source,
|
|
104
|
+
options,
|
|
105
|
+
rendererId
|
|
106
|
+
);
|
|
107
|
+
if (epoch !== epochRef.current) return;
|
|
108
|
+
setLastGoodSvg(svg);
|
|
109
|
+
setFailure(null);
|
|
110
|
+
} else if (!isStreamActive) {
|
|
111
|
+
setFailure(ladder);
|
|
112
|
+
}
|
|
113
|
+
} catch (err) {
|
|
114
|
+
if (err instanceof MermaidRenderSupersededError) return;
|
|
115
|
+
if (epoch !== epochRef.current) return;
|
|
116
|
+
if (!isStreamActive) {
|
|
117
|
+
console.warn(
|
|
118
|
+
"[MermaidRenderer] render threw after validation passed:",
|
|
119
|
+
err
|
|
120
|
+
);
|
|
121
|
+
setFailure({
|
|
122
|
+
source: trimmed,
|
|
123
|
+
valid: false,
|
|
124
|
+
fixes: [],
|
|
125
|
+
error: humanizeMermaidError(
|
|
126
|
+
err instanceof Error ? err.message : String(err)
|
|
127
|
+
)
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
isStreamActive ? STREAMING_DEBOUNCE_MS : SETTLED_DEBOUNCE_MS
|
|
133
|
+
);
|
|
134
|
+
return () => {
|
|
135
|
+
clearTimeout(timer);
|
|
136
|
+
supersedeMermaidRender(rendererId);
|
|
137
|
+
};
|
|
138
|
+
}, [source, optionsKey, isStreamActive, rendererId, shouldDraw]);
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
if (lastGoodSvg || failure) markDrawn();
|
|
141
|
+
});
|
|
142
|
+
const diagramType = detectDiagramType(source);
|
|
143
|
+
const label = getCatalogEntry(diagramType).label;
|
|
144
|
+
const title = extractMermaidTitle(source);
|
|
145
|
+
const hasSource = source.trim().length > 0;
|
|
146
|
+
const showSvg = hasSource ? lastGoodSvg : null;
|
|
147
|
+
const showFailure = hasSource ? failure : null;
|
|
148
|
+
if (showFailure && !isStreamActive && !showSvg) {
|
|
149
|
+
return /* @__PURE__ */ jsx(
|
|
150
|
+
MermaidErrorCard,
|
|
151
|
+
{
|
|
152
|
+
failure: showFailure,
|
|
153
|
+
originalSource: source,
|
|
154
|
+
className
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
if (!showSvg) {
|
|
159
|
+
return /* @__PURE__ */ jsxs(
|
|
160
|
+
"div",
|
|
161
|
+
{
|
|
162
|
+
ref: (el) => {
|
|
163
|
+
frameRef.current = el;
|
|
164
|
+
setFrameEl(el);
|
|
165
|
+
},
|
|
166
|
+
className: cn("space-y-2 p-3", fillHeight && "h-full", className),
|
|
167
|
+
"aria-busy": "true",
|
|
168
|
+
"aria-label": shouldDraw ? "Drawing the diagram" : "Diagram \u2014 drawn when it scrolls into view",
|
|
169
|
+
children: [
|
|
170
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/3" }),
|
|
171
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-32 w-full" })
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
return /* @__PURE__ */ jsxs(
|
|
177
|
+
"figure",
|
|
178
|
+
{
|
|
179
|
+
ref: (el) => {
|
|
180
|
+
frameRef.current = el;
|
|
181
|
+
setFrameEl(el);
|
|
182
|
+
},
|
|
183
|
+
role: "img",
|
|
184
|
+
"aria-label": title ?? `${label} diagram`,
|
|
185
|
+
className: cn("m-0", fillHeight && "flex h-full flex-col", className),
|
|
186
|
+
children: [
|
|
187
|
+
/* @__PURE__ */ jsx(
|
|
188
|
+
MermaidViewport,
|
|
189
|
+
{
|
|
190
|
+
svg: showSvg,
|
|
191
|
+
className: fillHeight ? "min-h-0 flex-1" : void 0,
|
|
192
|
+
hideControls: hideViewportControls,
|
|
193
|
+
onSvgMounted,
|
|
194
|
+
maxFrameHeight: viewportMaxHeight,
|
|
195
|
+
fillHeight
|
|
196
|
+
}
|
|
197
|
+
),
|
|
198
|
+
showFailure && !isStreamActive && // The final source failed but a partial render succeeded earlier —
|
|
199
|
+
// keep the diagram visible and surface the problem under it.
|
|
200
|
+
/* @__PURE__ */ jsx("figcaption", { className: "mt-1", children: /* @__PURE__ */ jsx(MermaidErrorCard, { failure: showFailure, originalSource: source }) })
|
|
201
|
+
]
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
function MermaidErrorCard({
|
|
206
|
+
failure,
|
|
207
|
+
originalSource,
|
|
208
|
+
className
|
|
209
|
+
}) {
|
|
210
|
+
const { copyText } = useClipboard({
|
|
211
|
+
notify: (message, kind) => kind === "error" ? toast.error(message) : toast.success(message)
|
|
212
|
+
});
|
|
213
|
+
const [showSource, setShowSource] = useState(false);
|
|
214
|
+
const copyOriginal = async () => {
|
|
215
|
+
await copyText(originalSource, "Diagram source copied");
|
|
216
|
+
};
|
|
217
|
+
return /* @__PURE__ */ jsxs(
|
|
218
|
+
"div",
|
|
219
|
+
{
|
|
220
|
+
className: cn(
|
|
221
|
+
"rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm",
|
|
222
|
+
className
|
|
223
|
+
),
|
|
224
|
+
children: [
|
|
225
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
226
|
+
/* @__PURE__ */ jsx(TriangleAlert, { className: "mt-0.5 h-4 w-4 shrink-0 text-destructive" }),
|
|
227
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-1.5", children: [
|
|
228
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium text-foreground", children: "This diagram could not be drawn" }),
|
|
229
|
+
humanizeMermaidError(failure.error) && /* @__PURE__ */ jsx("p", { className: "break-words text-xs text-muted-foreground", children: humanizeMermaidError(failure.error) }),
|
|
230
|
+
failure.fixes.length > 0 && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
231
|
+
"Attempted repairs: ",
|
|
232
|
+
failure.fixes.map((f) => f.rule).join(", ")
|
|
233
|
+
] }),
|
|
234
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 pt-0.5", children: [
|
|
235
|
+
/* @__PURE__ */ jsx(
|
|
236
|
+
"button",
|
|
237
|
+
{
|
|
238
|
+
type: "button",
|
|
239
|
+
className: "text-xs font-medium text-primary hover:underline",
|
|
240
|
+
onClick: () => setShowSource((v) => !v),
|
|
241
|
+
children: showSource ? "Hide source" : "Show source"
|
|
242
|
+
}
|
|
243
|
+
),
|
|
244
|
+
/* @__PURE__ */ jsxs(
|
|
245
|
+
"button",
|
|
246
|
+
{
|
|
247
|
+
type: "button",
|
|
248
|
+
className: "inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline",
|
|
249
|
+
onClick: copyOriginal,
|
|
250
|
+
children: [
|
|
251
|
+
/* @__PURE__ */ jsx(Copy, { className: "h-3 w-3" }),
|
|
252
|
+
"Copy source"
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
)
|
|
256
|
+
] }),
|
|
257
|
+
showSource && /* @__PURE__ */ jsx("pre", { className: "mt-1 max-h-64 overflow-auto rounded bg-muted p-2 text-xs text-muted-foreground", children: originalSource })
|
|
258
|
+
] })
|
|
259
|
+
] }),
|
|
260
|
+
/* @__PURE__ */ jsx(ErrorAlchemyMenu, {})
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
export {
|
|
266
|
+
MermaidRenderer
|
|
267
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin chrome-free views over MermaidRenderer (no card, no toolbar):
|
|
3
|
+
*
|
|
4
|
+
* - MermaidView — Redux-connected: user preferences + app theme,
|
|
5
|
+
* with per-artifact metadata overrides. For app
|
|
6
|
+
* surfaces (artifact wrapper, canvas, demos).
|
|
7
|
+
* - StandaloneMermaidView — Defaults + painted DOM theme via useThemeMode().
|
|
8
|
+
* For public share pages whose tree has no store.
|
|
9
|
+
*/
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { type MermaidArtifactMetadata } from "./types.js";
|
|
12
|
+
interface MermaidViewProps {
|
|
13
|
+
source: string;
|
|
14
|
+
/** Per-artifact overrides (canvas_items.content.metadata shape). */
|
|
15
|
+
metadata?: MermaidArtifactMetadata | null;
|
|
16
|
+
isStreamActive?: boolean;
|
|
17
|
+
className?: string;
|
|
18
|
+
hideViewportControls?: boolean;
|
|
19
|
+
onSvgMounted?: (el: SVGSVGElement | null) => void;
|
|
20
|
+
/** Px cap on the diagram frame height (inline/chat). See MermaidViewport. */
|
|
21
|
+
viewportMaxHeight?: number;
|
|
22
|
+
/** Frame fills its parent's height (canvas workbench, fullscreen). */
|
|
23
|
+
fillHeight?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare function MermaidView({ source, metadata, isStreamActive, className, hideViewportControls, onSvgMounted, viewportMaxHeight, fillHeight, }: MermaidViewProps): React.JSX.Element;
|
|
26
|
+
export declare function StandaloneMermaidView({ source, metadata, className, viewportMaxHeight, fillHeight, }: Pick<MermaidViewProps, "source" | "metadata" | "className" | "viewportMaxHeight" | "fillHeight">): React.JSX.Element;
|
|
27
|
+
export {};
|