@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,168 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { nearestScrollRoot } from "../utils/lifted/scroll-root.js";
|
|
3
|
+
import { useEffect, useState, useSyncExternalStore } from "react";
|
|
4
|
+
const DRAW_MARGIN = "1200px 0px";
|
|
5
|
+
let renderAllPasses = 0;
|
|
6
|
+
let renderAll = false;
|
|
7
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
8
|
+
const pending = /* @__PURE__ */ new Set();
|
|
9
|
+
const drawnWaiters = /* @__PURE__ */ new Set();
|
|
10
|
+
const sleepers = /* @__PURE__ */ new Map();
|
|
11
|
+
const drawing = /* @__PURE__ */ new Set();
|
|
12
|
+
const IDLE_BATCH = 1;
|
|
13
|
+
let idleScheduled = false;
|
|
14
|
+
function scheduleIdleDraws() {
|
|
15
|
+
if (idleScheduled || typeof window === "undefined") return;
|
|
16
|
+
idleScheduled = true;
|
|
17
|
+
const run = () => {
|
|
18
|
+
idleScheduled = false;
|
|
19
|
+
if (drawing.size > 0) {
|
|
20
|
+
if (sleepers.size > 0) setTimeout(scheduleIdleDraws, 150);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
let woken = 0;
|
|
24
|
+
for (const [token, wake] of sleepers) {
|
|
25
|
+
if (woken >= IDLE_BATCH) break;
|
|
26
|
+
sleepers.delete(token);
|
|
27
|
+
drawing.add(token);
|
|
28
|
+
wake();
|
|
29
|
+
woken++;
|
|
30
|
+
}
|
|
31
|
+
if (sleepers.size > 0) setTimeout(scheduleIdleDraws, 150);
|
|
32
|
+
};
|
|
33
|
+
const ric = window.requestIdleCallback;
|
|
34
|
+
if (ric) ric(run);
|
|
35
|
+
else setTimeout(run, 200);
|
|
36
|
+
}
|
|
37
|
+
function emit() {
|
|
38
|
+
for (const l of listeners) l();
|
|
39
|
+
}
|
|
40
|
+
function subscribe(listener) {
|
|
41
|
+
listeners.add(listener);
|
|
42
|
+
return () => listeners.delete(listener);
|
|
43
|
+
}
|
|
44
|
+
function setRenderAll() {
|
|
45
|
+
const next = renderAllPasses > 0;
|
|
46
|
+
if (next === renderAll) return;
|
|
47
|
+
renderAll = next;
|
|
48
|
+
emit();
|
|
49
|
+
}
|
|
50
|
+
function beginRenderAllPass() {
|
|
51
|
+
renderAllPasses++;
|
|
52
|
+
setRenderAll();
|
|
53
|
+
let open = true;
|
|
54
|
+
return () => {
|
|
55
|
+
if (!open) return;
|
|
56
|
+
open = false;
|
|
57
|
+
renderAllPasses = Math.max(0, renderAllPasses - 1);
|
|
58
|
+
setRenderAll();
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (typeof window !== "undefined") {
|
|
62
|
+
let browserPrint = null;
|
|
63
|
+
window.addEventListener("beforeprint", () => {
|
|
64
|
+
browserPrint ??= beginRenderAllPass();
|
|
65
|
+
});
|
|
66
|
+
window.addEventListener("afterprint", () => {
|
|
67
|
+
browserPrint?.();
|
|
68
|
+
browserPrint = null;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function isRenderAllActive() {
|
|
72
|
+
return renderAll;
|
|
73
|
+
}
|
|
74
|
+
async function renderAllDiagrams(timeoutMs = 2e4) {
|
|
75
|
+
const release = beginRenderAllPass();
|
|
76
|
+
const result = await waitForAllDrawn(timeoutMs);
|
|
77
|
+
return { ...result, release };
|
|
78
|
+
}
|
|
79
|
+
async function waitForAllDrawn(timeoutMs) {
|
|
80
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
81
|
+
if (pending.size === 0) return { pending: 0 };
|
|
82
|
+
return new Promise((resolve) => {
|
|
83
|
+
const done = () => {
|
|
84
|
+
if (pending.size > 0) return;
|
|
85
|
+
clearTimeout(timer);
|
|
86
|
+
drawnWaiters.delete(done);
|
|
87
|
+
resolve({ pending: 0 });
|
|
88
|
+
};
|
|
89
|
+
const timer = setTimeout(() => {
|
|
90
|
+
drawnWaiters.delete(done);
|
|
91
|
+
resolve({ pending: pending.size });
|
|
92
|
+
}, timeoutMs);
|
|
93
|
+
drawnWaiters.add(done);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async function printLivePage() {
|
|
97
|
+
const { pending: missing, release } = await renderAllDiagrams();
|
|
98
|
+
const close = () => {
|
|
99
|
+
window.removeEventListener("afterprint", close);
|
|
100
|
+
release();
|
|
101
|
+
};
|
|
102
|
+
window.addEventListener("afterprint", close);
|
|
103
|
+
if (missing > 0) {
|
|
104
|
+
const { toast } = await import("../host/toast.js");
|
|
105
|
+
toast.warning(
|
|
106
|
+
`${missing} diagram${missing === 1 ? " is" : "s are"} still drawing \u2014 they may print as placeholders. Try again in a moment.`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
window.print();
|
|
110
|
+
}
|
|
111
|
+
function useRenderAllRequested() {
|
|
112
|
+
return useSyncExternalStore(subscribe, () => renderAll, () => false);
|
|
113
|
+
}
|
|
114
|
+
function useDrawWhenNear(ref) {
|
|
115
|
+
const all = useRenderAllRequested();
|
|
116
|
+
const [near, setNear] = useState(false);
|
|
117
|
+
const [token] = useState(() => /* @__PURE__ */ Symbol("diagram"));
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
pending.add(token);
|
|
120
|
+
sleepers.set(token, () => setNear(true));
|
|
121
|
+
scheduleIdleDraws();
|
|
122
|
+
return () => {
|
|
123
|
+
pending.delete(token);
|
|
124
|
+
sleepers.delete(token);
|
|
125
|
+
drawing.delete(token);
|
|
126
|
+
for (const w of [...drawnWaiters]) w();
|
|
127
|
+
};
|
|
128
|
+
}, [token]);
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
if ((near || all) && sleepers.delete(token)) drawing.add(token);
|
|
131
|
+
}, [near, all, token]);
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
if (near || all) return void 0;
|
|
134
|
+
const el = ref.current;
|
|
135
|
+
if (!el || typeof IntersectionObserver === "undefined") {
|
|
136
|
+
setNear(true);
|
|
137
|
+
return void 0;
|
|
138
|
+
}
|
|
139
|
+
const io = new IntersectionObserver(
|
|
140
|
+
(entries) => {
|
|
141
|
+
if (entries.some((e) => e.isIntersecting)) setNear(true);
|
|
142
|
+
},
|
|
143
|
+
// Its own scroller, so the margin holds inside a panel or drawer too.
|
|
144
|
+
{ root: nearestScrollRoot(el), rootMargin: DRAW_MARGIN }
|
|
145
|
+
);
|
|
146
|
+
io.observe(el);
|
|
147
|
+
return () => io.disconnect();
|
|
148
|
+
}, [near, all, ref]);
|
|
149
|
+
const markDrawn = () => {
|
|
150
|
+
setNear(true);
|
|
151
|
+
drawing.delete(token);
|
|
152
|
+
sleepers.delete(token);
|
|
153
|
+
if (!pending.delete(token)) return;
|
|
154
|
+
for (const w of [...drawnWaiters]) w();
|
|
155
|
+
if (sleepers.size > 0) scheduleIdleDraws();
|
|
156
|
+
};
|
|
157
|
+
return { shouldDraw: all || near, markDrawn };
|
|
158
|
+
}
|
|
159
|
+
export {
|
|
160
|
+
DRAW_MARGIN,
|
|
161
|
+
IDLE_BATCH,
|
|
162
|
+
beginRenderAllPass,
|
|
163
|
+
isRenderAllActive,
|
|
164
|
+
printLivePage,
|
|
165
|
+
renderAllDiagrams,
|
|
166
|
+
useDrawWhenNear,
|
|
167
|
+
useRenderAllRequested
|
|
168
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter contract + registry. One adapter per structurally-editable diagram
|
|
3
|
+
* type. Types without an adapter still get render + code + AI editing — the
|
|
4
|
+
* workbench's structural modes simply show a graceful "use Code or AI" state.
|
|
5
|
+
*/
|
|
6
|
+
import type { MermaidDiagramType } from "../diagram-type.js";
|
|
7
|
+
import type { MermaidOp } from "./ops.js";
|
|
8
|
+
import type { MermaidDoc, ParseOutcome } from "./types.js";
|
|
9
|
+
export interface AdapterVocabulary {
|
|
10
|
+
/** What a "node" is called for humans ("Step", "Topic", "Slice", …). */
|
|
11
|
+
node: string;
|
|
12
|
+
/** Label for the primary add action ("Add step", "Add topic", …). */
|
|
13
|
+
addNode: string;
|
|
14
|
+
/** What a connection is called, when the type has them. */
|
|
15
|
+
edge?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface MermaidAdapter<D extends MermaidDoc = MermaidDoc> {
|
|
18
|
+
diagramType: MermaidDiagramType;
|
|
19
|
+
parse(source: string): ParseOutcome;
|
|
20
|
+
/** Deterministic serialization; untouched entities re-emit `raw` verbatim. */
|
|
21
|
+
serialize(doc: D): string;
|
|
22
|
+
/** Pure; throws MermaidOpError on invalid targets. */
|
|
23
|
+
applyOp(doc: D, op: MermaidOp): D;
|
|
24
|
+
vocabulary: AdapterVocabulary;
|
|
25
|
+
}
|
|
26
|
+
export declare function registerAdapter<D extends MermaidDoc>(adapter: MermaidAdapter<D>): void;
|
|
27
|
+
export declare function getAdapterForType(type: MermaidDiagramType): MermaidAdapter | null;
|
|
28
|
+
export declare function getAdapter(source: string): MermaidAdapter | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { detectDiagramType } from "../diagram-type.js";
|
|
2
|
+
const registry = /* @__PURE__ */ new Map();
|
|
3
|
+
function registerAdapter(adapter) {
|
|
4
|
+
registry.set(adapter.diagramType, adapter);
|
|
5
|
+
}
|
|
6
|
+
function getAdapterForType(type) {
|
|
7
|
+
return registry.get(type) ?? null;
|
|
8
|
+
}
|
|
9
|
+
function getAdapter(source) {
|
|
10
|
+
return getAdapterForType(detectDiagramType(source));
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
getAdapter,
|
|
14
|
+
getAdapterForType,
|
|
15
|
+
registerAdapter
|
|
16
|
+
};
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edit operations per diagram type — the ONLY way structural modes (visual /
|
|
3
|
+
* outline) mutate a document. Adapters implement applyOp as a pure function:
|
|
4
|
+
* (doc, op) → new doc. Ops throw MermaidOpError on an invalid target; the
|
|
5
|
+
* editor surfaces that as a friendly toast, never a crash.
|
|
6
|
+
*/
|
|
7
|
+
import type { FlowDirection, FlowEdgeStyle, FlowShape, MindmapShape, SequenceArrow } from "./types.js";
|
|
8
|
+
export declare class MermaidOpError extends Error {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
export type FlowchartOp = {
|
|
12
|
+
type: "addNode";
|
|
13
|
+
label: string;
|
|
14
|
+
shape?: FlowShape;
|
|
15
|
+
connectFrom?: string;
|
|
16
|
+
} | {
|
|
17
|
+
type: "renameNode";
|
|
18
|
+
id: string;
|
|
19
|
+
label: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "deleteNode";
|
|
22
|
+
id: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: "setNodeShape";
|
|
25
|
+
id: string;
|
|
26
|
+
shape: FlowShape;
|
|
27
|
+
} | {
|
|
28
|
+
type: "setNodePalette";
|
|
29
|
+
id: string;
|
|
30
|
+
paletteKey: string | null;
|
|
31
|
+
} | {
|
|
32
|
+
type: "connectNodes";
|
|
33
|
+
from: string;
|
|
34
|
+
to: string;
|
|
35
|
+
label?: string;
|
|
36
|
+
} | {
|
|
37
|
+
type: "deleteEdge";
|
|
38
|
+
id: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: "setEdgeLabel";
|
|
41
|
+
id: string;
|
|
42
|
+
label: string;
|
|
43
|
+
} | {
|
|
44
|
+
type: "setEdgeStyle";
|
|
45
|
+
id: string;
|
|
46
|
+
style: FlowEdgeStyle;
|
|
47
|
+
} | {
|
|
48
|
+
type: "reverseEdge";
|
|
49
|
+
id: string;
|
|
50
|
+
} | {
|
|
51
|
+
type: "setDirection";
|
|
52
|
+
direction: FlowDirection;
|
|
53
|
+
} | {
|
|
54
|
+
type: "renameSubgraph";
|
|
55
|
+
id: string;
|
|
56
|
+
title: string;
|
|
57
|
+
};
|
|
58
|
+
export type MindmapOp = {
|
|
59
|
+
type: "addChild";
|
|
60
|
+
parentId: string;
|
|
61
|
+
label: string;
|
|
62
|
+
} | {
|
|
63
|
+
type: "renameNode";
|
|
64
|
+
id: string;
|
|
65
|
+
label: string;
|
|
66
|
+
} | {
|
|
67
|
+
type: "deleteNode";
|
|
68
|
+
id: string;
|
|
69
|
+
} | {
|
|
70
|
+
type: "setShape";
|
|
71
|
+
id: string;
|
|
72
|
+
shape: MindmapShape;
|
|
73
|
+
} | {
|
|
74
|
+
type: "indent";
|
|
75
|
+
id: string;
|
|
76
|
+
} | {
|
|
77
|
+
type: "outdent";
|
|
78
|
+
id: string;
|
|
79
|
+
} | {
|
|
80
|
+
type: "moveBefore";
|
|
81
|
+
id: string;
|
|
82
|
+
siblingId: string;
|
|
83
|
+
};
|
|
84
|
+
export type SequenceOp = {
|
|
85
|
+
type: "addParticipant";
|
|
86
|
+
label: string;
|
|
87
|
+
isActor?: boolean;
|
|
88
|
+
} | {
|
|
89
|
+
type: "renameParticipant";
|
|
90
|
+
id: string;
|
|
91
|
+
label: string;
|
|
92
|
+
} | {
|
|
93
|
+
type: "deleteParticipant";
|
|
94
|
+
id: string;
|
|
95
|
+
} | {
|
|
96
|
+
type: "addMessage";
|
|
97
|
+
from: string;
|
|
98
|
+
to: string;
|
|
99
|
+
text: string;
|
|
100
|
+
arrow?: SequenceArrow;
|
|
101
|
+
} | {
|
|
102
|
+
type: "editMessage";
|
|
103
|
+
id: string;
|
|
104
|
+
from?: string;
|
|
105
|
+
to?: string;
|
|
106
|
+
text?: string;
|
|
107
|
+
arrow?: SequenceArrow;
|
|
108
|
+
} | {
|
|
109
|
+
type: "deleteMessage";
|
|
110
|
+
id: string;
|
|
111
|
+
} | {
|
|
112
|
+
type: "moveMessage";
|
|
113
|
+
id: string;
|
|
114
|
+
direction: "up" | "down";
|
|
115
|
+
} | {
|
|
116
|
+
type: "setAutonumber";
|
|
117
|
+
enabled: boolean;
|
|
118
|
+
};
|
|
119
|
+
export type PieOp = {
|
|
120
|
+
type: "setTitle";
|
|
121
|
+
title: string;
|
|
122
|
+
} | {
|
|
123
|
+
type: "setShowData";
|
|
124
|
+
enabled: boolean;
|
|
125
|
+
} | {
|
|
126
|
+
type: "addSlice";
|
|
127
|
+
label: string;
|
|
128
|
+
value: number;
|
|
129
|
+
} | {
|
|
130
|
+
type: "editSlice";
|
|
131
|
+
id: string;
|
|
132
|
+
label?: string;
|
|
133
|
+
value?: number;
|
|
134
|
+
} | {
|
|
135
|
+
type: "deleteSlice";
|
|
136
|
+
id: string;
|
|
137
|
+
};
|
|
138
|
+
export type TimelineOp = {
|
|
139
|
+
type: "setTitle";
|
|
140
|
+
title: string;
|
|
141
|
+
} | {
|
|
142
|
+
type: "addSection";
|
|
143
|
+
title: string;
|
|
144
|
+
} | {
|
|
145
|
+
type: "renameSection";
|
|
146
|
+
id: string;
|
|
147
|
+
title: string;
|
|
148
|
+
} | {
|
|
149
|
+
type: "deleteSection";
|
|
150
|
+
id: string;
|
|
151
|
+
} | {
|
|
152
|
+
type: "addRow";
|
|
153
|
+
sectionId: string;
|
|
154
|
+
period: string;
|
|
155
|
+
event?: string;
|
|
156
|
+
} | {
|
|
157
|
+
type: "editRow";
|
|
158
|
+
id: string;
|
|
159
|
+
period?: string;
|
|
160
|
+
} | {
|
|
161
|
+
type: "addEvent";
|
|
162
|
+
rowId: string;
|
|
163
|
+
text: string;
|
|
164
|
+
} | {
|
|
165
|
+
type: "editEvent";
|
|
166
|
+
rowId: string;
|
|
167
|
+
eventIndex: number;
|
|
168
|
+
text: string;
|
|
169
|
+
} | {
|
|
170
|
+
type: "deleteEvent";
|
|
171
|
+
rowId: string;
|
|
172
|
+
eventIndex: number;
|
|
173
|
+
} | {
|
|
174
|
+
type: "deleteRow";
|
|
175
|
+
id: string;
|
|
176
|
+
};
|
|
177
|
+
export type JourneyOp = {
|
|
178
|
+
type: "setTitle";
|
|
179
|
+
title: string;
|
|
180
|
+
} | {
|
|
181
|
+
type: "addSection";
|
|
182
|
+
title: string;
|
|
183
|
+
} | {
|
|
184
|
+
type: "renameSection";
|
|
185
|
+
id: string;
|
|
186
|
+
title: string;
|
|
187
|
+
} | {
|
|
188
|
+
type: "deleteSection";
|
|
189
|
+
id: string;
|
|
190
|
+
} | {
|
|
191
|
+
type: "addTask";
|
|
192
|
+
sectionId: string;
|
|
193
|
+
name: string;
|
|
194
|
+
score?: number;
|
|
195
|
+
actors?: string[];
|
|
196
|
+
} | {
|
|
197
|
+
type: "editTask";
|
|
198
|
+
id: string;
|
|
199
|
+
name?: string;
|
|
200
|
+
score?: number;
|
|
201
|
+
actors?: string[];
|
|
202
|
+
} | {
|
|
203
|
+
type: "deleteTask";
|
|
204
|
+
id: string;
|
|
205
|
+
};
|
|
206
|
+
export type QuadrantOp = {
|
|
207
|
+
type: "setTitle";
|
|
208
|
+
title: string;
|
|
209
|
+
} | {
|
|
210
|
+
type: "setXAxis";
|
|
211
|
+
text: string;
|
|
212
|
+
} | {
|
|
213
|
+
type: "setYAxis";
|
|
214
|
+
text: string;
|
|
215
|
+
} | {
|
|
216
|
+
type: "setQuadrantLabel";
|
|
217
|
+
index: number;
|
|
218
|
+
text: string;
|
|
219
|
+
} | {
|
|
220
|
+
type: "addPoint";
|
|
221
|
+
label: string;
|
|
222
|
+
x?: number;
|
|
223
|
+
y?: number;
|
|
224
|
+
} | {
|
|
225
|
+
type: "editPoint";
|
|
226
|
+
id: string;
|
|
227
|
+
label?: string;
|
|
228
|
+
x?: number;
|
|
229
|
+
y?: number;
|
|
230
|
+
} | {
|
|
231
|
+
type: "deletePoint";
|
|
232
|
+
id: string;
|
|
233
|
+
};
|
|
234
|
+
export type StateOp = {
|
|
235
|
+
type: "addState";
|
|
236
|
+
name: string;
|
|
237
|
+
} | {
|
|
238
|
+
type: "setStateDescription";
|
|
239
|
+
id: string;
|
|
240
|
+
description: string;
|
|
241
|
+
} | {
|
|
242
|
+
type: "deleteState";
|
|
243
|
+
id: string;
|
|
244
|
+
} | {
|
|
245
|
+
type: "addTransition";
|
|
246
|
+
from: string;
|
|
247
|
+
to: string;
|
|
248
|
+
label?: string;
|
|
249
|
+
} | {
|
|
250
|
+
type: "setTransitionLabel";
|
|
251
|
+
id: string;
|
|
252
|
+
label: string;
|
|
253
|
+
} | {
|
|
254
|
+
type: "reverseTransition";
|
|
255
|
+
id: string;
|
|
256
|
+
} | {
|
|
257
|
+
type: "deleteTransition";
|
|
258
|
+
id: string;
|
|
259
|
+
};
|
|
260
|
+
export type ErOp = {
|
|
261
|
+
type: "addRelationship";
|
|
262
|
+
left: string;
|
|
263
|
+
right: string;
|
|
264
|
+
label?: string;
|
|
265
|
+
} | {
|
|
266
|
+
type: "setRelationshipLabel";
|
|
267
|
+
id: string;
|
|
268
|
+
label: string;
|
|
269
|
+
} | {
|
|
270
|
+
type: "setRelationshipCardinality";
|
|
271
|
+
id: string;
|
|
272
|
+
leftCard?: string;
|
|
273
|
+
rightCard?: string;
|
|
274
|
+
identifying?: boolean;
|
|
275
|
+
} | {
|
|
276
|
+
type: "reverseRelationship";
|
|
277
|
+
id: string;
|
|
278
|
+
} | {
|
|
279
|
+
type: "deleteRelationship";
|
|
280
|
+
id: string;
|
|
281
|
+
};
|
|
282
|
+
export type MermaidOp = FlowchartOp | MindmapOp | SequenceOp | PieOp | TimelineOp | JourneyOp | QuadrantOp | StateOp | ErOp;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The round-trip fidelity gate — the hard guarantee behind structural editing.
|
|
3
|
+
*
|
|
4
|
+
* Structural modes (visual/outline) are enabled ONLY when the adapter has
|
|
5
|
+
* PROVEN lossless round-trip on this exact document: serialize(parse(s)) must
|
|
6
|
+
* equal s up to declared-safe normalization (trailing whitespace, blank-line
|
|
7
|
+
* collapse). Anything else downgrades to code-only BEFORE the user can edit —
|
|
8
|
+
* silent content destruction is structurally impossible, not just unlikely.
|
|
9
|
+
*/
|
|
10
|
+
import type { MermaidAdapter } from "./adapter.js";
|
|
11
|
+
import type { ParseOutcome } from "./types.js";
|
|
12
|
+
/** Declared-safe normalization: per-line trailing whitespace + blank runs. */
|
|
13
|
+
export declare function normalizeForComparison(source: string): string;
|
|
14
|
+
export interface GatedParseResult {
|
|
15
|
+
outcome: ParseOutcome;
|
|
16
|
+
/** Present when the gate fired — what serialize produced vs the original. */
|
|
17
|
+
roundTripDiff?: {
|
|
18
|
+
expected: string;
|
|
19
|
+
actual: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare function parseWithFidelityGate(adapter: MermaidAdapter, source: string): GatedParseResult;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
function normalizeForComparison(source) {
|
|
2
|
+
return source.replace(/\r\n?/g, "\n").split("\n").map((line) => line.replace(/\s+$/, "")).join("\n").replace(/\n{3,}/g, "\n\n").replace(/^\n+|\n+$/g, "");
|
|
3
|
+
}
|
|
4
|
+
function parseWithFidelityGate(adapter, source) {
|
|
5
|
+
const outcome = adapter.parse(source);
|
|
6
|
+
if (outcome.status !== "ok") return { outcome };
|
|
7
|
+
let serialized;
|
|
8
|
+
try {
|
|
9
|
+
serialized = adapter.serialize(outcome.doc);
|
|
10
|
+
} catch (err) {
|
|
11
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
12
|
+
console.warn(
|
|
13
|
+
`[MermaidFidelityGate] ${adapter.diagramType} serialize threw during gate \u2014 downgrading to code-only`,
|
|
14
|
+
err
|
|
15
|
+
);
|
|
16
|
+
return {
|
|
17
|
+
outcome: {
|
|
18
|
+
status: "code-only",
|
|
19
|
+
reason: `the ${adapter.diagramType} structural editor hit an internal error (${detail}) \u2014 please report it`,
|
|
20
|
+
diagnostics: [{ line: 1, message: `serialize failed: ${detail}`, severity: "error" }]
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const expected = normalizeForComparison(source);
|
|
25
|
+
const actual = normalizeForComparison(serialized);
|
|
26
|
+
if (expected !== actual) {
|
|
27
|
+
console.warn(
|
|
28
|
+
`[MermaidFidelityGate] ${adapter.diagramType} round-trip mismatch \u2014 structural editing disabled for this document`,
|
|
29
|
+
{ expected, actual }
|
|
30
|
+
);
|
|
31
|
+
return {
|
|
32
|
+
outcome: {
|
|
33
|
+
status: "code-only",
|
|
34
|
+
reason: "this diagram uses syntax that structural editing can't preserve yet",
|
|
35
|
+
diagnostics: []
|
|
36
|
+
},
|
|
37
|
+
roundTripDiff: { expected, actual }
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return { outcome };
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
normalizeForComparison,
|
|
44
|
+
parseWithFidelityGate
|
|
45
|
+
};
|