@ai-matrx/rich-content 0.2.4 → 0.2.7
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 +25 -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 +48 -10
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
import { splitFrontmatter } from "../diagram-type.js";
|
|
2
|
+
import { MermaidOpError } from "../model/ops.js";
|
|
3
|
+
const SHAPE_BRACKETS = {
|
|
4
|
+
stadium: ["([", "])"],
|
|
5
|
+
subroutine: ["[[", "]]"],
|
|
6
|
+
cylinder: ["[(", ")]"],
|
|
7
|
+
circle: ["((", "))"],
|
|
8
|
+
hexagon: ["{{", "}}"],
|
|
9
|
+
rect: ["[", "]"],
|
|
10
|
+
rounded: ["(", ")"],
|
|
11
|
+
diamond: ["{", "}"]
|
|
12
|
+
};
|
|
13
|
+
const OPEN_TOKENS = [
|
|
14
|
+
["([", "stadium"],
|
|
15
|
+
["[[", "subroutine"],
|
|
16
|
+
["[(", "cylinder"],
|
|
17
|
+
["((", "circle"],
|
|
18
|
+
["{{", "hexagon"],
|
|
19
|
+
["[", "rect"],
|
|
20
|
+
["(", "rounded"],
|
|
21
|
+
["{", "diamond"]
|
|
22
|
+
];
|
|
23
|
+
const FLOW_PALETTE = {
|
|
24
|
+
blue: { classDef: "fill:#dbeafe,stroke:#3b82f6,color:#1e3a8a", swatch: "#3b82f6", label: "Blue" },
|
|
25
|
+
green: { classDef: "fill:#dcfce7,stroke:#22c55e,color:#14532d", swatch: "#22c55e", label: "Green" },
|
|
26
|
+
amber: { classDef: "fill:#fef3c7,stroke:#f59e0b,color:#78350f", swatch: "#f59e0b", label: "Amber" },
|
|
27
|
+
rose: { classDef: "fill:#ffe4e6,stroke:#f43f5e,color:#881337", swatch: "#f43f5e", label: "Rose" },
|
|
28
|
+
violet: { classDef: "fill:#ede9fe,stroke:#8b5cf6,color:#4c1d95", swatch: "#8b5cf6", label: "Violet" },
|
|
29
|
+
slate: { classDef: "fill:#f1f5f9,stroke:#64748b,color:#0f172a", swatch: "#64748b", label: "Slate" }
|
|
30
|
+
};
|
|
31
|
+
const PALETTE_PREFIX = "mmdp_";
|
|
32
|
+
const ID_RE = /^[A-Za-z][A-Za-z0-9_-]*$/;
|
|
33
|
+
const HEADER_RE = /^(flowchart|graph)\s+(TB|TD|LR|RL|BT)\s*$/;
|
|
34
|
+
const PASSTHROUGH_RE = /^(classDef\b|class\b|linkStyle\b|style\b|click\b|accTitle\b|accDescr\b|direction\s+(TB|TD|LR|RL|BT)\s*$)/;
|
|
35
|
+
function parseNodeToken(token) {
|
|
36
|
+
let rest = token.trim();
|
|
37
|
+
const classes = [];
|
|
38
|
+
for (; ; ) {
|
|
39
|
+
const m = /^(.*?):::([A-Za-z][A-Za-z0-9_-]*)$/.exec(rest);
|
|
40
|
+
if (!m) break;
|
|
41
|
+
classes.unshift(m[2]);
|
|
42
|
+
rest = m[1].trim();
|
|
43
|
+
}
|
|
44
|
+
let paletteKey;
|
|
45
|
+
const extraClasses = [];
|
|
46
|
+
for (const c of classes) {
|
|
47
|
+
if (c.startsWith(PALETTE_PREFIX) && FLOW_PALETTE[c.slice(PALETTE_PREFIX.length)]) {
|
|
48
|
+
paletteKey = c.slice(PALETTE_PREFIX.length);
|
|
49
|
+
} else {
|
|
50
|
+
extraClasses.push(c);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const idMatch = /^([A-Za-z][A-Za-z0-9_-]*)/.exec(rest);
|
|
54
|
+
if (!idMatch) return null;
|
|
55
|
+
const id = idMatch[1];
|
|
56
|
+
let after = rest.slice(id.length);
|
|
57
|
+
if (!after.trim()) {
|
|
58
|
+
return { id, extraClasses, paletteKey };
|
|
59
|
+
}
|
|
60
|
+
after = after.trim();
|
|
61
|
+
for (const [open, shape] of OPEN_TOKENS) {
|
|
62
|
+
if (after.startsWith(open)) {
|
|
63
|
+
const close = SHAPE_BRACKETS[shape][1];
|
|
64
|
+
if (!after.endsWith(close)) return null;
|
|
65
|
+
let label = after.slice(open.length, after.length - close.length).trim();
|
|
66
|
+
if (label.startsWith('"') && label.endsWith('"') && label.length >= 2) {
|
|
67
|
+
label = label.slice(1, -1);
|
|
68
|
+
}
|
|
69
|
+
return { id, label, shape, paletteKey, extraClasses };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
function scanEdgeLine(line) {
|
|
75
|
+
const tokens = [];
|
|
76
|
+
const connectors = [];
|
|
77
|
+
let buf = "";
|
|
78
|
+
let depth = 0;
|
|
79
|
+
let inQuote = false;
|
|
80
|
+
let i = 0;
|
|
81
|
+
const tryConnector = () => {
|
|
82
|
+
const rest = line.slice(i);
|
|
83
|
+
let m;
|
|
84
|
+
if (m = /^--\s+([^>]*?)\s+--+>/.exec(rest)) {
|
|
85
|
+
i += m[0].length;
|
|
86
|
+
return { style: "arrow", label: m[1].trim() };
|
|
87
|
+
}
|
|
88
|
+
if (m = /^-\.\s+(.*?)\s+\.->/.exec(rest)) {
|
|
89
|
+
i += m[0].length;
|
|
90
|
+
return { style: "dotted", label: m[1].trim() };
|
|
91
|
+
}
|
|
92
|
+
if (m = /^==\s+(.*?)\s+==+>/.exec(rest)) {
|
|
93
|
+
i += m[0].length;
|
|
94
|
+
return { style: "thick", label: m[1].trim() };
|
|
95
|
+
}
|
|
96
|
+
if (m = /^-\.+->/.exec(rest)) {
|
|
97
|
+
i += m[0].length;
|
|
98
|
+
return { style: "dotted" };
|
|
99
|
+
}
|
|
100
|
+
if (m = /^={2,}>/.exec(rest)) {
|
|
101
|
+
i += m[0].length;
|
|
102
|
+
return { style: "thick" };
|
|
103
|
+
}
|
|
104
|
+
if (m = /^-{2,}>/.exec(rest)) {
|
|
105
|
+
i += m[0].length;
|
|
106
|
+
return { style: "arrow" };
|
|
107
|
+
}
|
|
108
|
+
if (m = /^-{3,}(?!>)/.exec(rest)) {
|
|
109
|
+
i += m[0].length;
|
|
110
|
+
return { style: "open" };
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
};
|
|
114
|
+
while (i < line.length) {
|
|
115
|
+
const ch = line[i];
|
|
116
|
+
if (inQuote) {
|
|
117
|
+
buf += ch;
|
|
118
|
+
if (ch === '"') inQuote = false;
|
|
119
|
+
i++;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (ch === '"') {
|
|
123
|
+
buf += ch;
|
|
124
|
+
inQuote = true;
|
|
125
|
+
i++;
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if ("[({".includes(ch)) depth++;
|
|
129
|
+
if ("])}".includes(ch)) depth--;
|
|
130
|
+
if (depth === 0 && (ch === "-" || ch === "=")) {
|
|
131
|
+
const conn = tryConnector();
|
|
132
|
+
if (conn) {
|
|
133
|
+
if (!buf.trim()) return null;
|
|
134
|
+
tokens.push(buf.trim());
|
|
135
|
+
buf = "";
|
|
136
|
+
const labelMatch = /^\s*\|([^|]*)\|/.exec(line.slice(i));
|
|
137
|
+
if (labelMatch) {
|
|
138
|
+
conn.label = labelMatch[1].trim();
|
|
139
|
+
i += labelMatch[0].length;
|
|
140
|
+
}
|
|
141
|
+
connectors.push(conn);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
buf += ch;
|
|
146
|
+
i++;
|
|
147
|
+
}
|
|
148
|
+
if (inQuote || depth !== 0) return null;
|
|
149
|
+
if (connectors.length === 0) return null;
|
|
150
|
+
if (!buf.trim()) return null;
|
|
151
|
+
tokens.push(buf.trim());
|
|
152
|
+
if (tokens.length !== connectors.length + 1) return null;
|
|
153
|
+
return { tokens, connectors };
|
|
154
|
+
}
|
|
155
|
+
function splitFanout(segment) {
|
|
156
|
+
const parts = [];
|
|
157
|
+
let buf = "";
|
|
158
|
+
let depth = 0;
|
|
159
|
+
let inQuote = false;
|
|
160
|
+
for (const ch of segment) {
|
|
161
|
+
if (inQuote) {
|
|
162
|
+
buf += ch;
|
|
163
|
+
if (ch === '"') inQuote = false;
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
if (ch === '"') {
|
|
167
|
+
buf += ch;
|
|
168
|
+
inQuote = true;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if ("[({".includes(ch)) depth++;
|
|
172
|
+
if ("])}".includes(ch)) depth--;
|
|
173
|
+
if (ch === "&" && depth === 0) {
|
|
174
|
+
parts.push(buf.trim());
|
|
175
|
+
buf = "";
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
buf += ch;
|
|
179
|
+
}
|
|
180
|
+
parts.push(buf.trim());
|
|
181
|
+
return parts.filter(Boolean);
|
|
182
|
+
}
|
|
183
|
+
function parse(source) {
|
|
184
|
+
const { bodyStartIndex, lines } = splitFrontmatter(source);
|
|
185
|
+
const frontmatter = lines.slice(0, bodyStartIndex);
|
|
186
|
+
const body = lines.slice(bodyStartIndex);
|
|
187
|
+
const doc = {
|
|
188
|
+
kind: "flowchart",
|
|
189
|
+
diagramType: "flowchart",
|
|
190
|
+
direction: "TB",
|
|
191
|
+
frontmatter,
|
|
192
|
+
sourceLines: [],
|
|
193
|
+
warnings: [],
|
|
194
|
+
nodes: [],
|
|
195
|
+
edges: [],
|
|
196
|
+
subgraphs: [],
|
|
197
|
+
edgeGroups: {}
|
|
198
|
+
};
|
|
199
|
+
const nodeById = /* @__PURE__ */ new Map();
|
|
200
|
+
let edgeCounter = 0;
|
|
201
|
+
let groupCounter = 0;
|
|
202
|
+
let headerSeen = false;
|
|
203
|
+
let currentSubgraph = null;
|
|
204
|
+
let subgraphDepth = 0;
|
|
205
|
+
const diagnostics = [];
|
|
206
|
+
const ensureNode = (token, rawLineForDecl) => {
|
|
207
|
+
let node = nodeById.get(token.id);
|
|
208
|
+
if (!node) {
|
|
209
|
+
node = {
|
|
210
|
+
id: token.id,
|
|
211
|
+
label: token.label ?? token.id,
|
|
212
|
+
shape: token.shape ?? "rect",
|
|
213
|
+
paletteKey: token.paletteKey,
|
|
214
|
+
extraClasses: token.extraClasses.length ? token.extraClasses : void 0,
|
|
215
|
+
raw: rawLineForDecl ?? void 0
|
|
216
|
+
};
|
|
217
|
+
doc.nodes.push(node);
|
|
218
|
+
nodeById.set(node.id, node);
|
|
219
|
+
} else if (token.label !== void 0) {
|
|
220
|
+
node.label = token.label;
|
|
221
|
+
if (token.shape) node.shape = token.shape;
|
|
222
|
+
if (token.paletteKey) node.paletteKey = token.paletteKey;
|
|
223
|
+
if (token.extraClasses.length) node.extraClasses = token.extraClasses;
|
|
224
|
+
if (rawLineForDecl) node.raw = rawLineForDecl;
|
|
225
|
+
}
|
|
226
|
+
if (currentSubgraph && !currentSubgraph.nodeIds.includes(node.id)) {
|
|
227
|
+
currentSubgraph.nodeIds.push(node.id);
|
|
228
|
+
}
|
|
229
|
+
return node;
|
|
230
|
+
};
|
|
231
|
+
const codeOnly = (lineNo, reason) => ({
|
|
232
|
+
status: "code-only",
|
|
233
|
+
reason,
|
|
234
|
+
diagnostics: [
|
|
235
|
+
...diagnostics,
|
|
236
|
+
{ line: lineNo, message: reason, severity: "warning" }
|
|
237
|
+
]
|
|
238
|
+
});
|
|
239
|
+
for (let li = 0; li < body.length; li++) {
|
|
240
|
+
const rawLine = body[li];
|
|
241
|
+
const trimmed = rawLine.trim();
|
|
242
|
+
const lineNo = bodyStartIndex + li + 1;
|
|
243
|
+
if (!trimmed || trimmed.startsWith("%%") || PASSTHROUGH_RE.test(trimmed)) {
|
|
244
|
+
doc.sourceLines.push({ text: rawLine });
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
if (!headerSeen) {
|
|
248
|
+
const header = HEADER_RE.exec(trimmed);
|
|
249
|
+
if (!header) return codeOnly(lineNo, "unrecognized flowchart header");
|
|
250
|
+
headerSeen = true;
|
|
251
|
+
doc.direction = header[2];
|
|
252
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "header", id: "header" } });
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
if (/^subgraph\b/.test(trimmed)) {
|
|
256
|
+
if (subgraphDepth >= 1) {
|
|
257
|
+
return codeOnly(lineNo, "nested subgraphs aren't supported by structural editing yet");
|
|
258
|
+
}
|
|
259
|
+
let id;
|
|
260
|
+
let title;
|
|
261
|
+
const withBracket = /^subgraph\s+([A-Za-z][A-Za-z0-9_-]*)\s*\[(.+)\]\s*$/.exec(trimmed);
|
|
262
|
+
if (withBracket) {
|
|
263
|
+
id = withBracket[1];
|
|
264
|
+
title = withBracket[2].trim().replace(/^"|"$/g, "");
|
|
265
|
+
} else {
|
|
266
|
+
const bare = /^subgraph\s+(.+)$/.exec(trimmed);
|
|
267
|
+
if (!bare) return codeOnly(lineNo, "unrecognized subgraph syntax");
|
|
268
|
+
title = bare[1].trim().replace(/^"|"$/g, "");
|
|
269
|
+
id = title;
|
|
270
|
+
}
|
|
271
|
+
const subgraph = { id, title, nodeIds: [], raw: rawLine };
|
|
272
|
+
doc.subgraphs.push(subgraph);
|
|
273
|
+
currentSubgraph = subgraph;
|
|
274
|
+
subgraphDepth++;
|
|
275
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "subgraphOpen", id } });
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (/^end\s*$/.test(trimmed)) {
|
|
279
|
+
if (subgraphDepth === 0) {
|
|
280
|
+
return codeOnly(lineNo, "unbalanced subgraph end");
|
|
281
|
+
}
|
|
282
|
+
subgraphDepth--;
|
|
283
|
+
currentSubgraph = null;
|
|
284
|
+
doc.sourceLines.push({ text: rawLine });
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
const scan = scanEdgeLine(trimmed);
|
|
288
|
+
if (scan) {
|
|
289
|
+
const segments = scan.tokens.map(splitFanout);
|
|
290
|
+
const parsedSegments = [];
|
|
291
|
+
for (const seg of segments) {
|
|
292
|
+
const parsed = [];
|
|
293
|
+
for (const tok of seg) {
|
|
294
|
+
const p = parseNodeToken(tok);
|
|
295
|
+
if (!p || !ID_RE.test(p.id)) {
|
|
296
|
+
return codeOnly(lineNo, "edge syntax outside the supported subset");
|
|
297
|
+
}
|
|
298
|
+
parsed.push(p);
|
|
299
|
+
}
|
|
300
|
+
if (parsed.length === 0) {
|
|
301
|
+
return codeOnly(lineNo, "edge syntax outside the supported subset");
|
|
302
|
+
}
|
|
303
|
+
parsedSegments.push(parsed);
|
|
304
|
+
}
|
|
305
|
+
const lineEdgeIds = [];
|
|
306
|
+
for (let c = 0; c < scan.connectors.length; c++) {
|
|
307
|
+
const fromTokens = parsedSegments[c];
|
|
308
|
+
const toTokens = parsedSegments[c + 1];
|
|
309
|
+
for (const ft of fromTokens) {
|
|
310
|
+
const fromNode = ensureNode(ft, null);
|
|
311
|
+
for (const tt of toTokens) {
|
|
312
|
+
const toNode = ensureNode(tt, null);
|
|
313
|
+
const edge = {
|
|
314
|
+
id: `e${++edgeCounter}`,
|
|
315
|
+
from: fromNode.id,
|
|
316
|
+
to: toNode.id,
|
|
317
|
+
label: scan.connectors[c].label || void 0,
|
|
318
|
+
style: scan.connectors[c].style,
|
|
319
|
+
inlineFrom: ft.label !== void 0,
|
|
320
|
+
inlineTo: tt.label !== void 0,
|
|
321
|
+
raw: rawLine
|
|
322
|
+
};
|
|
323
|
+
doc.edges.push(edge);
|
|
324
|
+
lineEdgeIds.push(edge.id);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
if (lineEdgeIds.length === 1) {
|
|
329
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "edge", id: lineEdgeIds[0] } });
|
|
330
|
+
} else {
|
|
331
|
+
const groupId = `g${++groupCounter}`;
|
|
332
|
+
doc.edgeGroups[groupId] = lineEdgeIds;
|
|
333
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "edgeGroup", id: groupId } });
|
|
334
|
+
}
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
const nodeToken = parseNodeToken(trimmed);
|
|
338
|
+
if (nodeToken && ID_RE.test(nodeToken.id) && nodeToken.label !== void 0) {
|
|
339
|
+
ensureNode(nodeToken, rawLine);
|
|
340
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "node", id: nodeToken.id } });
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
return codeOnly(lineNo, `unrecognized statement: "${trimmed.slice(0, 40)}"`);
|
|
344
|
+
}
|
|
345
|
+
if (subgraphDepth !== 0) {
|
|
346
|
+
return codeOnly(body.length, "unclosed subgraph");
|
|
347
|
+
}
|
|
348
|
+
if (!headerSeen) {
|
|
349
|
+
return { status: "invalid", diagnostics: [{ line: 1, message: "missing flowchart header", severity: "error" }] };
|
|
350
|
+
}
|
|
351
|
+
doc.warnings = diagnostics;
|
|
352
|
+
return { status: "ok", doc };
|
|
353
|
+
}
|
|
354
|
+
function quoteLabel(label) {
|
|
355
|
+
if (/[(){}[\];:#&|<>"]/.test(label) || /^\s|\s$/.test(label)) {
|
|
356
|
+
return `"${label.replace(/"/g, "#quot;")}"`;
|
|
357
|
+
}
|
|
358
|
+
return label;
|
|
359
|
+
}
|
|
360
|
+
function nodeDecl(node) {
|
|
361
|
+
const [open, close] = SHAPE_BRACKETS[node.shape];
|
|
362
|
+
const classes = [
|
|
363
|
+
...node.paletteKey ? [`${PALETTE_PREFIX}${node.paletteKey}`] : [],
|
|
364
|
+
...node.extraClasses ?? []
|
|
365
|
+
];
|
|
366
|
+
const suffix = classes.length ? `:::${classes.join(":::")}` : "";
|
|
367
|
+
return `${node.id}${open}${quoteLabel(node.label)}${close}${suffix}`;
|
|
368
|
+
}
|
|
369
|
+
function connectorText(edge) {
|
|
370
|
+
const label = edge.label ? `|${edge.label.replace(/\|/g, "/")}|` : "";
|
|
371
|
+
switch (edge.style) {
|
|
372
|
+
case "arrow":
|
|
373
|
+
return `-->${label}`;
|
|
374
|
+
case "dotted":
|
|
375
|
+
return `-.->${label}`;
|
|
376
|
+
case "thick":
|
|
377
|
+
return `==>${label}`;
|
|
378
|
+
case "open":
|
|
379
|
+
return label ? `---${label}` : "---";
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
function edgeLine(edge, nodeById) {
|
|
383
|
+
const fromNode = nodeById.get(edge.from);
|
|
384
|
+
const toNode = nodeById.get(edge.to);
|
|
385
|
+
const fromToken = edge.inlineFrom && fromNode ? nodeDecl(fromNode) : edge.from;
|
|
386
|
+
const toToken = edge.inlineTo && toNode ? nodeDecl(toNode) : edge.to;
|
|
387
|
+
return `${fromToken} ${connectorText(edge)} ${toToken}`;
|
|
388
|
+
}
|
|
389
|
+
function indentOf(text) {
|
|
390
|
+
return /^(\s*)/.exec(text)?.[1] ?? "";
|
|
391
|
+
}
|
|
392
|
+
function serialize(doc) {
|
|
393
|
+
const nodeById = new Map(doc.nodes.map((n) => [n.id, n]));
|
|
394
|
+
const edgeById = new Map(doc.edges.map((e) => [e.id, e]));
|
|
395
|
+
const subgraphById = new Map(doc.subgraphs.map((s) => [s.id, s]));
|
|
396
|
+
const emittedNodeIds = /* @__PURE__ */ new Set();
|
|
397
|
+
const emittedEdgeIds = /* @__PURE__ */ new Set();
|
|
398
|
+
const edgeNeedsRegen = (edge) => {
|
|
399
|
+
if (edge.dirty) return true;
|
|
400
|
+
if (edge.inlineFrom && nodeById.get(edge.from)?.dirty) return true;
|
|
401
|
+
if (edge.inlineTo && nodeById.get(edge.to)?.dirty) return true;
|
|
402
|
+
return false;
|
|
403
|
+
};
|
|
404
|
+
const out = [...doc.frontmatter];
|
|
405
|
+
for (const line of doc.sourceLines) {
|
|
406
|
+
if (!line.ref) {
|
|
407
|
+
out.push(line.text);
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
const indent = indentOf(line.text);
|
|
411
|
+
switch (line.ref.entity) {
|
|
412
|
+
case "header": {
|
|
413
|
+
out.push(`${indent}flowchart ${doc.direction}`);
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
case "node": {
|
|
417
|
+
const node = nodeById.get(line.ref.id);
|
|
418
|
+
if (!node) break;
|
|
419
|
+
emittedNodeIds.add(node.id);
|
|
420
|
+
out.push(node.dirty ? `${indent}${nodeDecl(node)}` : line.text);
|
|
421
|
+
break;
|
|
422
|
+
}
|
|
423
|
+
case "edge": {
|
|
424
|
+
const edge = edgeById.get(line.ref.id);
|
|
425
|
+
if (!edge) break;
|
|
426
|
+
emittedEdgeIds.add(edge.id);
|
|
427
|
+
if (edge.inlineFrom) emittedNodeIds.add(edge.from);
|
|
428
|
+
if (edge.inlineTo) emittedNodeIds.add(edge.to);
|
|
429
|
+
out.push(edgeNeedsRegen(edge) ? `${indent}${edgeLine(edge, nodeById)}` : line.text);
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
case "edgeGroup": {
|
|
433
|
+
const memberIds = doc.edgeGroups[line.ref.id] ?? [];
|
|
434
|
+
const members = memberIds.map((id) => edgeById.get(id)).filter((e) => Boolean(e));
|
|
435
|
+
for (const edge of members) {
|
|
436
|
+
emittedEdgeIds.add(edge.id);
|
|
437
|
+
if (edge.inlineFrom) emittedNodeIds.add(edge.from);
|
|
438
|
+
if (edge.inlineTo) emittedNodeIds.add(edge.to);
|
|
439
|
+
}
|
|
440
|
+
const anyChange = members.length !== memberIds.length || members.some(edgeNeedsRegen);
|
|
441
|
+
if (!anyChange) {
|
|
442
|
+
out.push(line.text);
|
|
443
|
+
} else {
|
|
444
|
+
for (const edge of members) {
|
|
445
|
+
out.push(`${indent}${edgeLine(edge, nodeById)}`);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
450
|
+
case "subgraphOpen": {
|
|
451
|
+
const subgraph = subgraphById.get(line.ref.id);
|
|
452
|
+
if (!subgraph || !subgraphDirty(subgraph)) {
|
|
453
|
+
out.push(line.text);
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
out.push(`${indent}subgraph ${subgraph.id}[${quoteLabel(subgraph.title)}]`);
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
default:
|
|
460
|
+
out.push(line.text);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
const additions = [];
|
|
464
|
+
for (const node of doc.nodes) {
|
|
465
|
+
const declaredInline = doc.edges.some(
|
|
466
|
+
(e) => e.inlineFrom && e.from === node.id || e.inlineTo && e.to === node.id
|
|
467
|
+
);
|
|
468
|
+
const hasLine = emittedNodeIds.has(node.id) || Boolean(node.raw);
|
|
469
|
+
if ((node.added || node.dirty && !hasLine && !declaredInline) && !emittedViaAddition(additions, node.id)) {
|
|
470
|
+
additions.push(` ${nodeDecl(node)}`);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
for (const edge of doc.edges) {
|
|
474
|
+
if (edge.added && !emittedEdgeIds.has(edge.id)) {
|
|
475
|
+
additions.push(` ${edgeLine(edge, nodeById)}`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
const usedPalette = new Set(
|
|
479
|
+
doc.nodes.map((n) => n.paletteKey).filter((k) => Boolean(k))
|
|
480
|
+
);
|
|
481
|
+
if (usedPalette.size > 0) {
|
|
482
|
+
const existing = new Set(
|
|
483
|
+
doc.sourceLines.map((l) => /^\s*classDef\s+(\S+)/.exec(l.text)?.[1]).filter(Boolean)
|
|
484
|
+
);
|
|
485
|
+
for (const key of usedPalette) {
|
|
486
|
+
const className = `${PALETTE_PREFIX}${key}`;
|
|
487
|
+
if (!existing.has(className)) {
|
|
488
|
+
additions.push(` classDef ${className} ${FLOW_PALETTE[key].classDef}`);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return [...out, ...additions].join("\n");
|
|
493
|
+
}
|
|
494
|
+
function emittedViaAddition(additions, nodeId) {
|
|
495
|
+
return additions.some((a) => a.trimStart().startsWith(nodeId));
|
|
496
|
+
}
|
|
497
|
+
function subgraphDirty(subgraph) {
|
|
498
|
+
return Boolean(subgraph.dirty);
|
|
499
|
+
}
|
|
500
|
+
function nextNodeId(doc) {
|
|
501
|
+
const taken = new Set(doc.nodes.map((n) => n.id));
|
|
502
|
+
let i = doc.nodes.length;
|
|
503
|
+
let id = `n${++i}`;
|
|
504
|
+
while (taken.has(id)) id = `n${++i}`;
|
|
505
|
+
return id;
|
|
506
|
+
}
|
|
507
|
+
function applyOp(doc, op) {
|
|
508
|
+
const next = structuredClone(doc);
|
|
509
|
+
const flowOp = op;
|
|
510
|
+
const node = (id) => {
|
|
511
|
+
const found = next.nodes.find((n) => n.id === id);
|
|
512
|
+
if (!found) throw new MermaidOpError(`That step no longer exists`);
|
|
513
|
+
return found;
|
|
514
|
+
};
|
|
515
|
+
const edge = (id) => {
|
|
516
|
+
const found = next.edges.find((e) => e.id === id);
|
|
517
|
+
if (!found) throw new MermaidOpError(`That connection no longer exists`);
|
|
518
|
+
return found;
|
|
519
|
+
};
|
|
520
|
+
switch (flowOp.type) {
|
|
521
|
+
case "addNode": {
|
|
522
|
+
const id = nextNodeId(next);
|
|
523
|
+
next.nodes.push({
|
|
524
|
+
id,
|
|
525
|
+
label: flowOp.label,
|
|
526
|
+
shape: flowOp.shape ?? "rect",
|
|
527
|
+
added: true,
|
|
528
|
+
dirty: true
|
|
529
|
+
});
|
|
530
|
+
if (flowOp.connectFrom) {
|
|
531
|
+
node(flowOp.connectFrom);
|
|
532
|
+
next.edges.push({
|
|
533
|
+
id: `e${next.edges.length + 1}_a`,
|
|
534
|
+
from: flowOp.connectFrom,
|
|
535
|
+
to: id,
|
|
536
|
+
style: "arrow",
|
|
537
|
+
added: true,
|
|
538
|
+
dirty: true
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
return next;
|
|
542
|
+
}
|
|
543
|
+
case "renameNode": {
|
|
544
|
+
const n = node(flowOp.id);
|
|
545
|
+
n.label = flowOp.label;
|
|
546
|
+
n.dirty = true;
|
|
547
|
+
return next;
|
|
548
|
+
}
|
|
549
|
+
case "deleteNode": {
|
|
550
|
+
node(flowOp.id);
|
|
551
|
+
next.nodes = next.nodes.filter((n) => n.id !== flowOp.id);
|
|
552
|
+
next.edges = next.edges.filter((e) => e.from !== flowOp.id && e.to !== flowOp.id);
|
|
553
|
+
for (const sg of next.subgraphs) {
|
|
554
|
+
sg.nodeIds = sg.nodeIds.filter((id) => id !== flowOp.id);
|
|
555
|
+
}
|
|
556
|
+
return next;
|
|
557
|
+
}
|
|
558
|
+
case "setNodeShape": {
|
|
559
|
+
const n = node(flowOp.id);
|
|
560
|
+
n.shape = flowOp.shape;
|
|
561
|
+
n.dirty = true;
|
|
562
|
+
return next;
|
|
563
|
+
}
|
|
564
|
+
case "setNodePalette": {
|
|
565
|
+
const n = node(flowOp.id);
|
|
566
|
+
n.paletteKey = flowOp.paletteKey ?? void 0;
|
|
567
|
+
n.dirty = true;
|
|
568
|
+
return next;
|
|
569
|
+
}
|
|
570
|
+
case "connectNodes": {
|
|
571
|
+
node(flowOp.from);
|
|
572
|
+
node(flowOp.to);
|
|
573
|
+
next.edges.push({
|
|
574
|
+
id: `e${next.edges.length + 1}_a`,
|
|
575
|
+
from: flowOp.from,
|
|
576
|
+
to: flowOp.to,
|
|
577
|
+
label: flowOp.label || void 0,
|
|
578
|
+
style: "arrow",
|
|
579
|
+
added: true,
|
|
580
|
+
dirty: true
|
|
581
|
+
});
|
|
582
|
+
return next;
|
|
583
|
+
}
|
|
584
|
+
case "deleteEdge": {
|
|
585
|
+
edge(flowOp.id);
|
|
586
|
+
next.edges = next.edges.filter((e) => e.id !== flowOp.id);
|
|
587
|
+
return next;
|
|
588
|
+
}
|
|
589
|
+
case "setEdgeLabel": {
|
|
590
|
+
const e = edge(flowOp.id);
|
|
591
|
+
e.label = flowOp.label || void 0;
|
|
592
|
+
e.dirty = true;
|
|
593
|
+
return next;
|
|
594
|
+
}
|
|
595
|
+
case "setEdgeStyle": {
|
|
596
|
+
const e = edge(flowOp.id);
|
|
597
|
+
e.style = flowOp.style;
|
|
598
|
+
e.dirty = true;
|
|
599
|
+
return next;
|
|
600
|
+
}
|
|
601
|
+
case "reverseEdge": {
|
|
602
|
+
const e = edge(flowOp.id);
|
|
603
|
+
const wasInlineFrom = e.inlineFrom;
|
|
604
|
+
[e.from, e.to] = [e.to, e.from];
|
|
605
|
+
[e.inlineFrom, e.inlineTo] = [e.inlineTo, wasInlineFrom];
|
|
606
|
+
e.dirty = true;
|
|
607
|
+
return next;
|
|
608
|
+
}
|
|
609
|
+
case "setDirection": {
|
|
610
|
+
next.direction = flowOp.direction;
|
|
611
|
+
return next;
|
|
612
|
+
}
|
|
613
|
+
case "renameSubgraph": {
|
|
614
|
+
const sg = next.subgraphs.find((s) => s.id === flowOp.id);
|
|
615
|
+
if (!sg) throw new MermaidOpError("That group no longer exists");
|
|
616
|
+
sg.title = flowOp.title;
|
|
617
|
+
sg.dirty = true;
|
|
618
|
+
return next;
|
|
619
|
+
}
|
|
620
|
+
default:
|
|
621
|
+
throw new MermaidOpError("Unsupported operation for flowcharts");
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
const flowchartAdapter = {
|
|
625
|
+
diagramType: "flowchart",
|
|
626
|
+
parse,
|
|
627
|
+
serialize,
|
|
628
|
+
applyOp,
|
|
629
|
+
vocabulary: { node: "Step", addNode: "Add step", edge: "Connection" }
|
|
630
|
+
};
|
|
631
|
+
export {
|
|
632
|
+
FLOW_PALETTE,
|
|
633
|
+
flowchartAdapter
|
|
634
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User Journey adapter. Sections group tasks; each task is
|
|
3
|
+
* `Name: score: actor, actor`. Edits are per-line; structural inserts/deletes
|
|
4
|
+
* regenerate the body (content-preserving, formatting-normalizing) — the same
|
|
5
|
+
* shape as the timeline adapter.
|
|
6
|
+
*/
|
|
7
|
+
import type { MermaidAdapter } from "../model/adapter.js";
|
|
8
|
+
import type { JourneyDoc } from "../model/types.js";
|
|
9
|
+
export declare const journeyAdapter: MermaidAdapter<JourneyDoc>;
|