@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,231 @@
|
|
|
1
|
+
import { splitFrontmatter } from "../diagram-type.js";
|
|
2
|
+
import { MermaidOpError } from "../model/ops.js";
|
|
3
|
+
const TITLE_RE = /^title\s+(.+)$/;
|
|
4
|
+
const XAXIS_RE = /^x-axis\s+(.+)$/;
|
|
5
|
+
const YAXIS_RE = /^y-axis\s+(.+)$/;
|
|
6
|
+
const QUADRANT_RE = /^quadrant-([1-4])\s+(.+)$/;
|
|
7
|
+
const POINT_RE = /^(.+?):\s*\[\s*([0-9]*\.?[0-9]+)\s*,\s*([0-9]*\.?[0-9]+)\s*\]\s*$/;
|
|
8
|
+
function parse(source) {
|
|
9
|
+
const { bodyStartIndex, lines } = splitFrontmatter(source);
|
|
10
|
+
const doc = {
|
|
11
|
+
kind: "quadrant",
|
|
12
|
+
diagramType: "quadrant",
|
|
13
|
+
frontmatter: lines.slice(0, bodyStartIndex),
|
|
14
|
+
sourceLines: [],
|
|
15
|
+
warnings: [],
|
|
16
|
+
quadrantLabels: [void 0, void 0, void 0, void 0],
|
|
17
|
+
points: [],
|
|
18
|
+
dirty: {},
|
|
19
|
+
present: /* @__PURE__ */ new Set()
|
|
20
|
+
};
|
|
21
|
+
let headerSeen = false;
|
|
22
|
+
let counter = 0;
|
|
23
|
+
for (const rawLine of lines.slice(bodyStartIndex)) {
|
|
24
|
+
const trimmed = rawLine.trim();
|
|
25
|
+
if (!trimmed || trimmed.startsWith("%%")) {
|
|
26
|
+
doc.sourceLines.push({ text: rawLine });
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (!headerSeen) {
|
|
30
|
+
if (!/^quadrantChart\s*$/.test(trimmed)) {
|
|
31
|
+
return { status: "code-only", reason: "unrecognized quadrant header", diagnostics: [] };
|
|
32
|
+
}
|
|
33
|
+
headerSeen = true;
|
|
34
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "header", id: "header" } });
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const title = TITLE_RE.exec(trimmed);
|
|
38
|
+
if (title && doc.title === void 0) {
|
|
39
|
+
doc.title = title[1].trim();
|
|
40
|
+
doc.present.add("title");
|
|
41
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "title", id: "title" } });
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const xaxis = XAXIS_RE.exec(trimmed);
|
|
45
|
+
if (xaxis && doc.xAxis === void 0) {
|
|
46
|
+
doc.xAxis = xaxis[1].trim();
|
|
47
|
+
doc.present.add("xAxis");
|
|
48
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "xAxis", id: "xAxis" } });
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const yaxis = YAXIS_RE.exec(trimmed);
|
|
52
|
+
if (yaxis && doc.yAxis === void 0) {
|
|
53
|
+
doc.yAxis = yaxis[1].trim();
|
|
54
|
+
doc.present.add("yAxis");
|
|
55
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "yAxis", id: "yAxis" } });
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const quad = QUADRANT_RE.exec(trimmed);
|
|
59
|
+
if (quad) {
|
|
60
|
+
const idx = Number(quad[1]) - 1;
|
|
61
|
+
if (doc.quadrantLabels[idx] === void 0) {
|
|
62
|
+
doc.quadrantLabels[idx] = quad[2].trim();
|
|
63
|
+
doc.present.add(`q${idx}`);
|
|
64
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "quadrant", id: String(idx) } });
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const point = POINT_RE.exec(trimmed);
|
|
69
|
+
if (point) {
|
|
70
|
+
const p = {
|
|
71
|
+
id: `q${++counter}`,
|
|
72
|
+
label: point[1].trim(),
|
|
73
|
+
x: Number(point[2]),
|
|
74
|
+
y: Number(point[3]),
|
|
75
|
+
raw: rawLine
|
|
76
|
+
};
|
|
77
|
+
doc.points.push(p);
|
|
78
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "point", id: p.id } });
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
status: "code-only",
|
|
83
|
+
reason: `unrecognized statement: "${trimmed.slice(0, 40)}"`,
|
|
84
|
+
diagnostics: []
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (!headerSeen) {
|
|
88
|
+
return { status: "invalid", diagnostics: [{ line: 1, message: "missing quadrantChart header", severity: "error" }] };
|
|
89
|
+
}
|
|
90
|
+
return { status: "ok", doc };
|
|
91
|
+
}
|
|
92
|
+
function pointLine(p) {
|
|
93
|
+
return `${p.label}: [${p.x}, ${p.y}]`;
|
|
94
|
+
}
|
|
95
|
+
function serialize(doc) {
|
|
96
|
+
const qdoc = doc;
|
|
97
|
+
const out = [...doc.frontmatter];
|
|
98
|
+
const pointById = new Map(doc.points.map((p) => [p.id, p]));
|
|
99
|
+
const emitted = /* @__PURE__ */ new Set();
|
|
100
|
+
let singletonAnchor = -1;
|
|
101
|
+
for (const line of doc.sourceLines) {
|
|
102
|
+
const indent = /^(\s*)/.exec(line.text)?.[1] ?? "";
|
|
103
|
+
if (!line.ref) {
|
|
104
|
+
out.push(line.text);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
switch (line.ref.entity) {
|
|
108
|
+
case "header":
|
|
109
|
+
out.push(line.text);
|
|
110
|
+
singletonAnchor = out.length - 1;
|
|
111
|
+
break;
|
|
112
|
+
case "title":
|
|
113
|
+
if (doc.title === void 0) break;
|
|
114
|
+
out.push(qdoc.dirty.title ? `${indent}title ${doc.title}` : line.text);
|
|
115
|
+
singletonAnchor = out.length - 1;
|
|
116
|
+
break;
|
|
117
|
+
case "xAxis":
|
|
118
|
+
if (doc.xAxis === void 0) break;
|
|
119
|
+
out.push(qdoc.dirty.xAxis ? `${indent}x-axis ${doc.xAxis}` : line.text);
|
|
120
|
+
singletonAnchor = out.length - 1;
|
|
121
|
+
break;
|
|
122
|
+
case "yAxis":
|
|
123
|
+
if (doc.yAxis === void 0) break;
|
|
124
|
+
out.push(qdoc.dirty.yAxis ? `${indent}y-axis ${doc.yAxis}` : line.text);
|
|
125
|
+
singletonAnchor = out.length - 1;
|
|
126
|
+
break;
|
|
127
|
+
case "quadrant": {
|
|
128
|
+
const idx = Number(line.ref.id);
|
|
129
|
+
const label = doc.quadrantLabels[idx];
|
|
130
|
+
if (label === void 0) break;
|
|
131
|
+
const dirtyKey = `q${idx}`;
|
|
132
|
+
out.push(qdoc.dirty[dirtyKey] ? `${indent}quadrant-${idx + 1} ${label}` : line.text);
|
|
133
|
+
singletonAnchor = out.length - 1;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case "point": {
|
|
137
|
+
const p = pointById.get(line.ref.id);
|
|
138
|
+
if (!p) break;
|
|
139
|
+
emitted.add(p.id);
|
|
140
|
+
out.push(p.dirty ? `${indent}${pointLine(p)}` : line.text);
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
default:
|
|
144
|
+
out.push(line.text);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const inserts = [];
|
|
148
|
+
if (doc.title !== void 0 && !qdoc.present.has("title")) inserts.push(` title ${doc.title}`);
|
|
149
|
+
if (doc.xAxis !== void 0 && !qdoc.present.has("xAxis")) inserts.push(` x-axis ${doc.xAxis}`);
|
|
150
|
+
if (doc.yAxis !== void 0 && !qdoc.present.has("yAxis")) inserts.push(` y-axis ${doc.yAxis}`);
|
|
151
|
+
for (let i = 0; i < 4; i++) {
|
|
152
|
+
if (doc.quadrantLabels[i] !== void 0 && !qdoc.present.has(`q${i}`)) {
|
|
153
|
+
inserts.push(` quadrant-${i + 1} ${doc.quadrantLabels[i]}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (inserts.length > 0 && singletonAnchor >= 0) out.splice(singletonAnchor + 1, 0, ...inserts);
|
|
157
|
+
const additions = [];
|
|
158
|
+
for (const p of doc.points) {
|
|
159
|
+
if (!emitted.has(p.id) && !p.raw) additions.push(` ${pointLine(p)}`);
|
|
160
|
+
}
|
|
161
|
+
return [...out, ...additions].join("\n");
|
|
162
|
+
}
|
|
163
|
+
function clamp01(n) {
|
|
164
|
+
return Math.max(0, Math.min(1, n));
|
|
165
|
+
}
|
|
166
|
+
function applyOp(doc, op) {
|
|
167
|
+
const next = structuredClone(doc);
|
|
168
|
+
const qop = op;
|
|
169
|
+
const findPoint = (id) => {
|
|
170
|
+
const p = next.points.find((x) => x.id === id);
|
|
171
|
+
if (!p) throw new MermaidOpError("That point no longer exists");
|
|
172
|
+
return p;
|
|
173
|
+
};
|
|
174
|
+
switch (qop.type) {
|
|
175
|
+
case "setTitle": {
|
|
176
|
+
next.title = qop.title || void 0;
|
|
177
|
+
next.dirty.title = true;
|
|
178
|
+
return next;
|
|
179
|
+
}
|
|
180
|
+
case "setXAxis": {
|
|
181
|
+
next.xAxis = qop.text || void 0;
|
|
182
|
+
next.dirty.xAxis = true;
|
|
183
|
+
return next;
|
|
184
|
+
}
|
|
185
|
+
case "setYAxis": {
|
|
186
|
+
next.yAxis = qop.text || void 0;
|
|
187
|
+
next.dirty.yAxis = true;
|
|
188
|
+
return next;
|
|
189
|
+
}
|
|
190
|
+
case "setQuadrantLabel": {
|
|
191
|
+
if (qop.index < 0 || qop.index > 3) throw new MermaidOpError("Quadrant index out of range");
|
|
192
|
+
next.quadrantLabels[qop.index] = qop.text || void 0;
|
|
193
|
+
next.dirty[`q${qop.index}`] = true;
|
|
194
|
+
return next;
|
|
195
|
+
}
|
|
196
|
+
case "addPoint": {
|
|
197
|
+
next.points.push({
|
|
198
|
+
id: `q_a${next.points.length + 1}`,
|
|
199
|
+
label: qop.label,
|
|
200
|
+
x: clamp01(qop.x ?? 0.5),
|
|
201
|
+
y: clamp01(qop.y ?? 0.5)
|
|
202
|
+
});
|
|
203
|
+
return next;
|
|
204
|
+
}
|
|
205
|
+
case "editPoint": {
|
|
206
|
+
const p = findPoint(qop.id);
|
|
207
|
+
if (qop.label !== void 0) p.label = qop.label;
|
|
208
|
+
if (qop.x !== void 0) p.x = clamp01(qop.x);
|
|
209
|
+
if (qop.y !== void 0) p.y = clamp01(qop.y);
|
|
210
|
+
p.dirty = true;
|
|
211
|
+
return next;
|
|
212
|
+
}
|
|
213
|
+
case "deletePoint": {
|
|
214
|
+
findPoint(qop.id);
|
|
215
|
+
next.points = next.points.filter((p) => p.id !== qop.id);
|
|
216
|
+
return next;
|
|
217
|
+
}
|
|
218
|
+
default:
|
|
219
|
+
throw new MermaidOpError("Unsupported operation for quadrant charts");
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
const quadrantAdapter = {
|
|
223
|
+
diagramType: "quadrant",
|
|
224
|
+
parse,
|
|
225
|
+
serialize,
|
|
226
|
+
applyOp,
|
|
227
|
+
vocabulary: { node: "Point", addNode: "Add point" }
|
|
228
|
+
};
|
|
229
|
+
export {
|
|
230
|
+
quadrantAdapter
|
|
231
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter registration — import this module once (the workbench does) to make
|
|
3
|
+
* all structural-editing adapters available via getAdapter()/getAdapterForType().
|
|
4
|
+
* Import from source per house rule; this is a registration side-effect module,
|
|
5
|
+
* not a barrel re-export.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { registerAdapter } from "../model/adapter.js";
|
|
2
|
+
import { erAdapter } from "./er.js";
|
|
3
|
+
import { flowchartAdapter } from "./flowchart.js";
|
|
4
|
+
import { journeyAdapter } from "./journey.js";
|
|
5
|
+
import { mindmapAdapter } from "./mindmap.js";
|
|
6
|
+
import { pieAdapter } from "./pie.js";
|
|
7
|
+
import { quadrantAdapter } from "./quadrant.js";
|
|
8
|
+
import { sequenceAdapter } from "./sequence.js";
|
|
9
|
+
import { stateAdapter } from "./state.js";
|
|
10
|
+
import { timelineAdapter } from "./timeline.js";
|
|
11
|
+
registerAdapter(flowchartAdapter);
|
|
12
|
+
registerAdapter(mindmapAdapter);
|
|
13
|
+
registerAdapter(sequenceAdapter);
|
|
14
|
+
registerAdapter(pieAdapter);
|
|
15
|
+
registerAdapter(timelineAdapter);
|
|
16
|
+
registerAdapter(journeyAdapter);
|
|
17
|
+
registerAdapter(quadrantAdapter);
|
|
18
|
+
registerAdapter(stateAdapter);
|
|
19
|
+
registerAdapter(erAdapter);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sequence adapter. Messages and participants edit per-line; blocks (loop,
|
|
3
|
+
* alt, notes, activations) are locked passthrough rows preserved verbatim.
|
|
4
|
+
* Reorders and inserts regenerate the body wholesale (content-preserving).
|
|
5
|
+
*/
|
|
6
|
+
import type { MermaidAdapter } from "../model/adapter.js";
|
|
7
|
+
import type { SequenceDoc } from "../model/types.js";
|
|
8
|
+
export declare const sequenceAdapter: MermaidAdapter<SequenceDoc>;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { splitFrontmatter } from "../diagram-type.js";
|
|
2
|
+
import { MermaidOpError } from "../model/ops.js";
|
|
3
|
+
const ARROWS = ["-->>", "->>", "--x", "-x", "--)", "-)", "-->", "->"];
|
|
4
|
+
const MESSAGE_RE = new RegExp(
|
|
5
|
+
`^([A-Za-z0-9_]+)\\s*(${ARROWS.map((a) => a.replace(/[-)>(x]/g, (c) => `\\${c}`)).join("|")})\\s*([A-Za-z0-9_]+)\\s*:\\s*(.*)$`
|
|
6
|
+
);
|
|
7
|
+
const PARTICIPANT_RE = /^(participant|actor)\s+([A-Za-z0-9_]+)(?:\s+as\s+(.+))?$/;
|
|
8
|
+
const BLOCK_RE = /^(note\b|loop\b|alt\b|else\b|opt\b|par\b|and\b|critical\b|option\b|break\b|rect\b|end\s*$|activate\b|deactivate\b|box\b|create\b|destroy\b|link\b|links\b|properties\b|title\b|autonumber\s+\S)/i;
|
|
9
|
+
function parse(source) {
|
|
10
|
+
const { bodyStartIndex, lines } = splitFrontmatter(source);
|
|
11
|
+
const doc = {
|
|
12
|
+
kind: "sequence",
|
|
13
|
+
diagramType: "sequence",
|
|
14
|
+
frontmatter: lines.slice(0, bodyStartIndex),
|
|
15
|
+
sourceLines: [],
|
|
16
|
+
warnings: [],
|
|
17
|
+
autonumber: false,
|
|
18
|
+
participants: [],
|
|
19
|
+
items: []
|
|
20
|
+
};
|
|
21
|
+
let headerSeen = false;
|
|
22
|
+
let counter = 0;
|
|
23
|
+
for (const rawLine of lines.slice(bodyStartIndex)) {
|
|
24
|
+
const trimmed = rawLine.trim();
|
|
25
|
+
if (!trimmed || trimmed.startsWith("%%")) {
|
|
26
|
+
doc.sourceLines.push({ text: rawLine });
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (!headerSeen) {
|
|
30
|
+
if (!/^sequenceDiagram\s*$/.test(trimmed)) {
|
|
31
|
+
return { status: "code-only", reason: "unrecognized sequence header", diagnostics: [] };
|
|
32
|
+
}
|
|
33
|
+
headerSeen = true;
|
|
34
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "header", id: "header" } });
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (/^autonumber\s*$/.test(trimmed)) {
|
|
38
|
+
doc.autonumber = true;
|
|
39
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "autonumber", id: "autonumber" } });
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const participant = PARTICIPANT_RE.exec(trimmed);
|
|
43
|
+
if (participant) {
|
|
44
|
+
const p = {
|
|
45
|
+
id: participant[2],
|
|
46
|
+
alias: participant[3]?.trim(),
|
|
47
|
+
isActor: participant[1] === "actor",
|
|
48
|
+
raw: rawLine
|
|
49
|
+
};
|
|
50
|
+
doc.participants.push(p);
|
|
51
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "participant", id: p.id } });
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const message = MESSAGE_RE.exec(trimmed);
|
|
55
|
+
if (message && !/[+-]\s*:/.test(trimmed.split(":")[0] + ":")) {
|
|
56
|
+
const item = {
|
|
57
|
+
kind: "message",
|
|
58
|
+
id: `s${++counter}`,
|
|
59
|
+
from: message[1],
|
|
60
|
+
to: message[3],
|
|
61
|
+
text: message[4],
|
|
62
|
+
arrow: message[2],
|
|
63
|
+
raw: rawLine
|
|
64
|
+
};
|
|
65
|
+
doc.items.push(item);
|
|
66
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "item", id: item.id } });
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (BLOCK_RE.test(trimmed) || message) {
|
|
70
|
+
const item = { kind: "passthrough", id: `s${++counter}`, raw: rawLine };
|
|
71
|
+
doc.items.push(item);
|
|
72
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "item", id: item.id } });
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
status: "code-only",
|
|
77
|
+
reason: `unrecognized statement: "${trimmed.slice(0, 40)}"`,
|
|
78
|
+
diagnostics: []
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (!headerSeen) {
|
|
82
|
+
return { status: "invalid", diagnostics: [{ line: 1, message: "missing sequenceDiagram header", severity: "error" }] };
|
|
83
|
+
}
|
|
84
|
+
return { status: "ok", doc };
|
|
85
|
+
}
|
|
86
|
+
function participantLine(p) {
|
|
87
|
+
const kind = p.isActor ? "actor" : "participant";
|
|
88
|
+
return p.alias ? `${kind} ${p.id} as ${p.alias}` : `${kind} ${p.id}`;
|
|
89
|
+
}
|
|
90
|
+
function messageLine(item) {
|
|
91
|
+
return `${item.from}${item.arrow}${item.to}: ${item.text}`;
|
|
92
|
+
}
|
|
93
|
+
function serialize(doc) {
|
|
94
|
+
const sdoc = doc;
|
|
95
|
+
const out = [...doc.frontmatter];
|
|
96
|
+
if (sdoc.regenerateAll) {
|
|
97
|
+
const comments = doc.sourceLines.filter((l) => !l.ref && l.text.trim().startsWith("%%")).map((l) => l.text);
|
|
98
|
+
out.push("sequenceDiagram", ...comments);
|
|
99
|
+
if (doc.autonumber) out.push(" autonumber");
|
|
100
|
+
for (const p of doc.participants) out.push(` ${participantLine(p)}`);
|
|
101
|
+
for (const item of doc.items) {
|
|
102
|
+
if (item.kind === "passthrough") out.push(item.raw);
|
|
103
|
+
else out.push(` ${messageLine(item)}`);
|
|
104
|
+
}
|
|
105
|
+
return out.join("\n");
|
|
106
|
+
}
|
|
107
|
+
const participantById = new Map(doc.participants.map((p) => [p.id, p]));
|
|
108
|
+
const itemById = new Map(doc.items.map((i) => [i.id, i]));
|
|
109
|
+
const emittedParticipants = /* @__PURE__ */ new Set();
|
|
110
|
+
const emittedItems = /* @__PURE__ */ new Set();
|
|
111
|
+
for (const line of doc.sourceLines) {
|
|
112
|
+
const indent = /^(\s*)/.exec(line.text)?.[1] ?? "";
|
|
113
|
+
if (!line.ref) {
|
|
114
|
+
out.push(line.text);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
switch (line.ref.entity) {
|
|
118
|
+
case "autonumber":
|
|
119
|
+
if (doc.autonumber) out.push(line.text);
|
|
120
|
+
break;
|
|
121
|
+
case "participant": {
|
|
122
|
+
const p = participantById.get(line.ref.id);
|
|
123
|
+
if (!p) break;
|
|
124
|
+
emittedParticipants.add(p.id);
|
|
125
|
+
out.push(p.dirty ? `${indent}${participantLine(p)}` : line.text);
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case "item": {
|
|
129
|
+
const item = itemById.get(line.ref.id);
|
|
130
|
+
if (!item) break;
|
|
131
|
+
emittedItems.add(item.id);
|
|
132
|
+
if (item.kind === "passthrough" || !item.dirty) out.push(line.text);
|
|
133
|
+
else out.push(`${indent}${messageLine(item)}`);
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
default:
|
|
137
|
+
out.push(line.text);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const additions = [];
|
|
141
|
+
if (doc.autonumber && !doc.sourceLines.some((l) => l.ref?.entity === "autonumber")) {
|
|
142
|
+
additions.push(" autonumber");
|
|
143
|
+
}
|
|
144
|
+
for (const p of doc.participants) {
|
|
145
|
+
if (!emittedParticipants.has(p.id) && !p.raw) additions.push(` ${participantLine(p)}`);
|
|
146
|
+
}
|
|
147
|
+
for (const item of doc.items) {
|
|
148
|
+
if (item.kind === "message" && !emittedItems.has(item.id) && !item.raw) {
|
|
149
|
+
additions.push(` ${messageLine(item)}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return [...out, ...additions].join("\n");
|
|
153
|
+
}
|
|
154
|
+
function applyOp(doc, op) {
|
|
155
|
+
const next = structuredClone(doc);
|
|
156
|
+
const sop = op;
|
|
157
|
+
const participant = (id) => {
|
|
158
|
+
const p = next.participants.find((x) => x.id === id);
|
|
159
|
+
if (!p) throw new MermaidOpError("That participant no longer exists");
|
|
160
|
+
return p;
|
|
161
|
+
};
|
|
162
|
+
const message = (id) => {
|
|
163
|
+
const m = next.items.find((x) => x.id === id);
|
|
164
|
+
if (!m || m.kind !== "message") throw new MermaidOpError("That message no longer exists");
|
|
165
|
+
return m;
|
|
166
|
+
};
|
|
167
|
+
switch (sop.type) {
|
|
168
|
+
case "addParticipant": {
|
|
169
|
+
const base = sop.label.replace(/[^A-Za-z0-9_]/g, "") || "P";
|
|
170
|
+
let id = base;
|
|
171
|
+
let n = 1;
|
|
172
|
+
while (next.participants.some((p) => p.id === id)) id = `${base}${++n}`;
|
|
173
|
+
next.participants.push({
|
|
174
|
+
id,
|
|
175
|
+
alias: sop.label === id ? void 0 : sop.label,
|
|
176
|
+
isActor: Boolean(sop.isActor)
|
|
177
|
+
});
|
|
178
|
+
return next;
|
|
179
|
+
}
|
|
180
|
+
case "renameParticipant": {
|
|
181
|
+
const p = participant(sop.id);
|
|
182
|
+
p.alias = sop.label === p.id ? void 0 : sop.label;
|
|
183
|
+
p.dirty = true;
|
|
184
|
+
return next;
|
|
185
|
+
}
|
|
186
|
+
case "deleteParticipant": {
|
|
187
|
+
participant(sop.id);
|
|
188
|
+
const used = next.items.some(
|
|
189
|
+
(i) => i.kind === "message" && (i.from === sop.id || i.to === sop.id)
|
|
190
|
+
);
|
|
191
|
+
if (used) {
|
|
192
|
+
throw new MermaidOpError("Remove this participant's messages first");
|
|
193
|
+
}
|
|
194
|
+
next.participants = next.participants.filter((p) => p.id !== sop.id);
|
|
195
|
+
next.regenerateAll = true;
|
|
196
|
+
return next;
|
|
197
|
+
}
|
|
198
|
+
case "addMessage": {
|
|
199
|
+
participant(sop.from);
|
|
200
|
+
participant(sop.to);
|
|
201
|
+
next.items.push({
|
|
202
|
+
kind: "message",
|
|
203
|
+
id: `s_a${next.items.length + 1}`,
|
|
204
|
+
from: sop.from,
|
|
205
|
+
to: sop.to,
|
|
206
|
+
text: sop.text,
|
|
207
|
+
arrow: sop.arrow ?? "->>"
|
|
208
|
+
});
|
|
209
|
+
return next;
|
|
210
|
+
}
|
|
211
|
+
case "editMessage": {
|
|
212
|
+
const m = message(sop.id);
|
|
213
|
+
if (sop.from) m.from = sop.from;
|
|
214
|
+
if (sop.to) m.to = sop.to;
|
|
215
|
+
if (sop.text !== void 0) m.text = sop.text;
|
|
216
|
+
if (sop.arrow) m.arrow = sop.arrow;
|
|
217
|
+
m.dirty = true;
|
|
218
|
+
return next;
|
|
219
|
+
}
|
|
220
|
+
case "deleteMessage": {
|
|
221
|
+
message(sop.id);
|
|
222
|
+
next.items = next.items.filter((i) => i.id !== sop.id);
|
|
223
|
+
return next;
|
|
224
|
+
}
|
|
225
|
+
case "moveMessage": {
|
|
226
|
+
const idx = next.items.findIndex((i) => i.id === sop.id);
|
|
227
|
+
if (idx === -1) throw new MermaidOpError("That message no longer exists");
|
|
228
|
+
const target = sop.direction === "up" ? idx - 1 : idx + 1;
|
|
229
|
+
if (target < 0 || target >= next.items.length) return next;
|
|
230
|
+
[next.items[idx], next.items[target]] = [next.items[target], next.items[idx]];
|
|
231
|
+
next.regenerateAll = true;
|
|
232
|
+
return next;
|
|
233
|
+
}
|
|
234
|
+
case "setAutonumber": {
|
|
235
|
+
next.autonumber = sop.enabled;
|
|
236
|
+
return next;
|
|
237
|
+
}
|
|
238
|
+
default:
|
|
239
|
+
throw new MermaidOpError("Unsupported operation for sequence diagrams");
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const sequenceAdapter = {
|
|
243
|
+
diagramType: "sequence",
|
|
244
|
+
parse,
|
|
245
|
+
serialize,
|
|
246
|
+
applyOp,
|
|
247
|
+
vocabulary: { node: "Participant", addNode: "Add participant", edge: "Message" }
|
|
248
|
+
};
|
|
249
|
+
export {
|
|
250
|
+
sequenceAdapter
|
|
251
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State diagram adapter (flat stateDiagram / stateDiagram-v2).
|
|
3
|
+
*
|
|
4
|
+
* Supports transitions (`A --> B : label`) and state descriptions
|
|
5
|
+
* (`A : desc` or `state "desc" as A`). Composite states (`{ … }`), notes,
|
|
6
|
+
* concurrency (`--`), and fork/choice/join (`<<…>>`) are NOT structurally
|
|
7
|
+
* editable — like flowchart's nested-subgraph rule, those downgrade the whole
|
|
8
|
+
* document to code-only rather than risk guessing.
|
|
9
|
+
*/
|
|
10
|
+
import type { MermaidAdapter } from "../model/adapter.js";
|
|
11
|
+
import type { StateDoc } from "../model/types.js";
|
|
12
|
+
export declare const stateAdapter: MermaidAdapter<StateDoc>;
|