@ai-matrx/rich-content 0.2.3 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -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/csv/CsvBlock.js +5 -1
- 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,126 @@
|
|
|
1
|
+
import type { AnswerEditRemarkMeta } from "../../block-interaction.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { resolveProvisionalKindRender } from "../../../kinds/react/partial-kind-route.js";
|
|
4
|
+
import { type CanonicalBlockIR } from "@ai-matrx/content-ir";
|
|
5
|
+
import { type RenderBlock } from "./block-dispatch.js";
|
|
6
|
+
export type { RenderBlock } from "./block-dispatch.js";
|
|
7
|
+
interface BlockRendererProps {
|
|
8
|
+
requestId?: string;
|
|
9
|
+
block: RenderBlock;
|
|
10
|
+
index: number;
|
|
11
|
+
isStreamActive?: boolean;
|
|
12
|
+
onContentChange?: (newContent: string) => void;
|
|
13
|
+
/** Owning message context forwarded to canonical artifact renderers. */
|
|
14
|
+
conversationId?: string;
|
|
15
|
+
messageId?: string;
|
|
16
|
+
taskId?: string;
|
|
17
|
+
isLastReasoningBlock?: boolean;
|
|
18
|
+
/** Generic handler: replaces `original` substring with `replacement` in the full content string. */
|
|
19
|
+
replaceBlockContent: (original: string, replacement: string, remark?: AnswerEditRemarkMeta) => void;
|
|
20
|
+
handleOpenEditor: () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Streaming partial kinds ONLY. Set on the recursive render of a
|
|
23
|
+
* PROVISIONAL block so the loading gates below (which exist to hide a
|
|
24
|
+
* half-arrived payload) stand down and the real kind component renders the
|
|
25
|
+
* provisional value. Never set by an ordinary caller.
|
|
26
|
+
*/
|
|
27
|
+
suppressLoadingGate?: boolean;
|
|
28
|
+
outputSchema?: unknown | null;
|
|
29
|
+
}
|
|
30
|
+
export declare function pendingStructuredEnvelope(block: {
|
|
31
|
+
type: string;
|
|
32
|
+
content?: string | null;
|
|
33
|
+
language?: string;
|
|
34
|
+
metadata?: Record<string, unknown>;
|
|
35
|
+
isStreamingBlock?: boolean;
|
|
36
|
+
}): CanonicalBlockIR | null;
|
|
37
|
+
/**
|
|
38
|
+
* The terminal envelope for a settled block that arrived without one: reload
|
|
39
|
+
* has only the original text when an interrupted run could not stamp a
|
|
40
|
+
* COMPLETE persistence envelope, so the stream's parser runs at this terminal
|
|
41
|
+
* boundary — never on a live prefix — and keeps its error status intact.
|
|
42
|
+
*/
|
|
43
|
+
export declare function withTerminalEnvelope<T extends {
|
|
44
|
+
content?: string | null;
|
|
45
|
+
language?: string;
|
|
46
|
+
metadata?: Record<string, unknown>;
|
|
47
|
+
isStreamingBlock?: boolean;
|
|
48
|
+
}>(block: T, isStreamActive: boolean | undefined): T;
|
|
49
|
+
/**
|
|
50
|
+
* A SETTLED json region that names its kind in its text while the parser
|
|
51
|
+
* could not name it — the payload broke before (or around) its `__kind`, or
|
|
52
|
+
* no envelope exists at all — is that kind's BROKEN state, never the raw JSON
|
|
53
|
+
* card (A10, the never-raw law). The route takes it with `kindState: "raw"`
|
|
54
|
+
* (the kernel's "checked and failed" word, FEATURE.md), which is the
|
|
55
|
+
* broken-instance floor. A complete kindless envelope is genuine JSON (its
|
|
56
|
+
* nested kinds are the recovery pass's), and a streaming block is the pending
|
|
57
|
+
* gate's.
|
|
58
|
+
*/
|
|
59
|
+
export declare function settleBrokenKindRoute<T extends {
|
|
60
|
+
type: string;
|
|
61
|
+
content?: string | null;
|
|
62
|
+
language?: string;
|
|
63
|
+
metadata?: Record<string, unknown>;
|
|
64
|
+
isStreamingBlock?: boolean;
|
|
65
|
+
}>(block: T): T;
|
|
66
|
+
/**
|
|
67
|
+
* What the renderer shows in place of the block's own dispatch while its kind
|
|
68
|
+
* is still arriving: the provisional render (Stage 1.5), or a kind loader
|
|
69
|
+
* (Stages 1.6, 2, 2.5 and the kind half of Stage 3). Null → the block is
|
|
70
|
+
* dispatched by its routed type.
|
|
71
|
+
*/
|
|
72
|
+
export type BlockRenderGate = {
|
|
73
|
+
kind: "provisional";
|
|
74
|
+
provisional: NonNullable<ReturnType<typeof resolveProvisionalKindRender<RenderBlock>>>;
|
|
75
|
+
} | {
|
|
76
|
+
kind: "loader";
|
|
77
|
+
envelope: CanonicalBlockIR;
|
|
78
|
+
} | null;
|
|
79
|
+
export interface BlockRenderDecision {
|
|
80
|
+
/** The input with its terminal envelope (settled blocks of a settled message). */
|
|
81
|
+
rawBlock: RenderBlock;
|
|
82
|
+
/** The routed block — what the dispatch registry receives. */
|
|
83
|
+
block: RenderBlock;
|
|
84
|
+
gate: BlockRenderGate;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* THE DECISION BlockRenderer makes, as a pure function (V5): terminal
|
|
88
|
+
* envelope, kind route, broken-kind settle, then the loading gates in order.
|
|
89
|
+
* BlockRenderer calls it; so does the frame judge (`draws-raw-kind-json.ts`),
|
|
90
|
+
* so a guard can never drift from what the reader sees. `isStreamActive` is
|
|
91
|
+
* the MESSAGE's stream state, exactly as the renderer receives it — a settled
|
|
92
|
+
* block inside a still-streaming message is judged the way it is drawn.
|
|
93
|
+
* `route` is the kind route at a registry version (BlockRenderer passes its
|
|
94
|
+
* versioned, memoised route; pure callers take the uncached one).
|
|
95
|
+
*/
|
|
96
|
+
export declare function decideBlockRender(inputBlock: RenderBlock, { isStreamActive, suppressLoadingGate, route, }?: {
|
|
97
|
+
isStreamActive?: boolean;
|
|
98
|
+
suppressLoadingGate?: boolean;
|
|
99
|
+
route?: (block: RenderBlock) => RenderBlock;
|
|
100
|
+
}): BlockRenderDecision;
|
|
101
|
+
/**
|
|
102
|
+
* Renders individual content blocks through four ordered stages:
|
|
103
|
+
*
|
|
104
|
+
* 1. KIND ROUTE (Shape blocks, first-class) — `applyIrKindRoute`: a block
|
|
105
|
+
* whose `metadata.__ir` envelope resolved a REGISTERED kind routes through
|
|
106
|
+
* the kind registry (`resolveComponent` / legacy bridge) before any
|
|
107
|
+
* type-keyed dispatch. This is how bare/fenced JSON `flashcard_set` —
|
|
108
|
+
* which the legacy detectors can only call "code" — becomes real
|
|
109
|
+
* flashcards, live while streaming.
|
|
110
|
+
* 1.5 PROVISIONAL KIND (streaming partial kinds) — a block carrying a
|
|
111
|
+
* `metadata.__ir_partial` `partial` event for an opted-in kind renders
|
|
112
|
+
* that provisional value through the SAME component the final value uses,
|
|
113
|
+
* marked "still arriving". Terminal events produce nothing here, so the
|
|
114
|
+
* final value replaces the provisional render in one frame.
|
|
115
|
+
* 2. PENDING SKELETON — a still-streaming JSON region with an unresolved
|
|
116
|
+
* kind shows a neutral skeleton instead of flashing raw text.
|
|
117
|
+
* 3. UNIFIED ARTIFACT RENDERER — standalone materializable blocks render
|
|
118
|
+
* through the single shared artifact path (chat/canvas/artifact identical).
|
|
119
|
+
* 4. DISPATCH REGISTRY — the declarative, crosswalk-classified table in
|
|
120
|
+
* block-dispatch.tsx (protocol / scalar_generic / shape / opaque). An
|
|
121
|
+
* unregistered type SCREAMS (reportUnregisteredBlockType) and renders as
|
|
122
|
+
* basic markdown — never a silent default.
|
|
123
|
+
*
|
|
124
|
+
* Components are lazy-loaded (see BlockComponentRegistry) for code splitting.
|
|
125
|
+
*/
|
|
126
|
+
export declare const BlockRenderer: React.FC<BlockRendererProps>;
|
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { durableRecordId } from "@ai-matrx/kit/ids";
|
|
4
|
+
import React, { useCallback } from "react";
|
|
5
|
+
import { BlockComponents, LoadingComponents } from "./BlockComponentRegistry.js";
|
|
6
|
+
import { resolveArtifactDef } from "../../../host/app-bindings.js";
|
|
7
|
+
import {
|
|
8
|
+
ArtifactRender,
|
|
9
|
+
hasArtifactRenderer
|
|
10
|
+
} from "../../../host/app-bindings.js";
|
|
11
|
+
import { useMachineFramesVisible, useHideReasoning, useHideToolResults } from "../../../host/app-bindings.js";
|
|
12
|
+
import { GENERIC_STRUCTURED_COMPONENT_KEY } from "../../../kinds/react/kind-route.js";
|
|
13
|
+
import {
|
|
14
|
+
routeBlockAtRegistryVersion,
|
|
15
|
+
routeBlockNow
|
|
16
|
+
} from "../../../kinds/react/route-at-version.js";
|
|
17
|
+
import { useContentIrKindVersion } from "../../../kinds/react/use-registry-repaint.js";
|
|
18
|
+
import { useEnsureKindRenderable } from "../../../kinds/react/ensure-kind-renderable.js";
|
|
19
|
+
import { resolveKindLoadingComponent } from "../../../kinds/react/loading/kind-loading-registry.js";
|
|
20
|
+
import { resolveLoadingSlugForKind } from "../../../kinds/react/loading/resolve-loading-slug.js";
|
|
21
|
+
import { earlyKeysFromValue } from "../../../kinds/react/loading/kind-loading.types.js";
|
|
22
|
+
import { readEnvelope } from "../../../kinds/redux/render-block-envelope.js";
|
|
23
|
+
import {
|
|
24
|
+
firstKindSlug,
|
|
25
|
+
hasKindKey,
|
|
26
|
+
isJsonFenceLanguage,
|
|
27
|
+
isJson5Language,
|
|
28
|
+
kindObjectProseBreak,
|
|
29
|
+
isKindSlug,
|
|
30
|
+
json5AsJson,
|
|
31
|
+
jsonKindSignal,
|
|
32
|
+
withoutLeadingJsonComments
|
|
33
|
+
} from "@ai-matrx/content-ir/surfaces";
|
|
34
|
+
import { withIrEnvelope } from "../../../kinds/registry/region-envelope-memo.js";
|
|
35
|
+
import {
|
|
36
|
+
resolveAnnouncedKindLoading,
|
|
37
|
+
resolveProvisionalKindRender
|
|
38
|
+
} from "../../../kinds/react/partial-kind-route.js";
|
|
39
|
+
import {
|
|
40
|
+
ProvisionalKindBoundary,
|
|
41
|
+
ProvisionalKindFrame
|
|
42
|
+
} from "../../../kinds/react/ProvisionalKindBoundary.js";
|
|
43
|
+
import { applyIrKindRoute } from "../../../kinds/react/kind-route.js";
|
|
44
|
+
import { componentRegistry } from "../../../host/component-registry.js";
|
|
45
|
+
import {
|
|
46
|
+
IR_ENVELOPE_KEY,
|
|
47
|
+
IR_VERSION,
|
|
48
|
+
readPartialKindEvent,
|
|
49
|
+
reconstructRegionValue
|
|
50
|
+
} from "@ai-matrx/content-ir";
|
|
51
|
+
import {
|
|
52
|
+
KindRecordChrome,
|
|
53
|
+
kindHasRecordChrome
|
|
54
|
+
} from "../../../host/app-bindings.js";
|
|
55
|
+
import {
|
|
56
|
+
isBlockLoading,
|
|
57
|
+
resolveBlockDispatch,
|
|
58
|
+
reportUnregisteredBlockType
|
|
59
|
+
} from "./block-dispatch.js";
|
|
60
|
+
const ARTIFACT_LOADING_COMPONENTS = {
|
|
61
|
+
quiz: LoadingComponents.QuizLoading,
|
|
62
|
+
presentation: LoadingComponents.PresentationLoading,
|
|
63
|
+
recipe: LoadingComponents.RecipeLoading,
|
|
64
|
+
timeline: LoadingComponents.TimelineLoading,
|
|
65
|
+
research: LoadingComponents.ResearchLoading,
|
|
66
|
+
resources: LoadingComponents.ResourcesLoading,
|
|
67
|
+
progress: LoadingComponents.ProgressLoading,
|
|
68
|
+
comparison: LoadingComponents.ComparisonLoading,
|
|
69
|
+
troubleshooting: LoadingComponents.TroubleshootingLoading,
|
|
70
|
+
"decision-tree": LoadingComponents.DecisionTreeLoading,
|
|
71
|
+
diagram: LoadingComponents.DiagramLoading,
|
|
72
|
+
math_problem: LoadingComponents.MathProblemLoading
|
|
73
|
+
};
|
|
74
|
+
function readRecordValue(block) {
|
|
75
|
+
const envelope = readEnvelope(block.metadata);
|
|
76
|
+
const value = envelope ? reconstructRegionValue(envelope) : (() => {
|
|
77
|
+
try {
|
|
78
|
+
return JSON.parse(block.content ?? "");
|
|
79
|
+
} catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
})();
|
|
83
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
84
|
+
}
|
|
85
|
+
function pendingStructuredEnvelope(block) {
|
|
86
|
+
if (block.type !== "code") return null;
|
|
87
|
+
const envelope = readEnvelope(block.metadata);
|
|
88
|
+
if (!envelope) return unparsedKindPendingEnvelope(block);
|
|
89
|
+
if (envelope.root.status !== "streaming") {
|
|
90
|
+
if (envelope.root.kind) {
|
|
91
|
+
if (block.isStreamingBlock) return envelope;
|
|
92
|
+
return componentRegistry.hasSettled() ? null : envelope;
|
|
93
|
+
}
|
|
94
|
+
return unparsedKindPendingEnvelope(block);
|
|
95
|
+
}
|
|
96
|
+
if (envelope.root.kind) {
|
|
97
|
+
return envelope;
|
|
98
|
+
}
|
|
99
|
+
return jsonKindSignal(block.content, { json5: isJson5Language(block.language) }) === "not_kind" ? null : envelope;
|
|
100
|
+
}
|
|
101
|
+
function withTerminalEnvelope(block, isStreamActive) {
|
|
102
|
+
const settled = block.isStreamingBlock === false || !isStreamActive && !block.isStreamingBlock;
|
|
103
|
+
if (!settled || readEnvelope(block.metadata)) {
|
|
104
|
+
return block;
|
|
105
|
+
}
|
|
106
|
+
if (block.type === "text" && kindObjectProseBreak((block.content ?? "").trimStart()) !== null) {
|
|
107
|
+
return block;
|
|
108
|
+
}
|
|
109
|
+
const source = isJson5Language(block.language) ? json5AsJson(block.content ?? "") ?? block.content ?? "" : block.content ?? "";
|
|
110
|
+
const metadata = withIrEnvelope(source, block.metadata, {
|
|
111
|
+
allowTerminalError: true
|
|
112
|
+
});
|
|
113
|
+
return metadata !== block.metadata ? { ...block, metadata } : block;
|
|
114
|
+
}
|
|
115
|
+
function settleBrokenKindRoute(block) {
|
|
116
|
+
if (block.type !== "code" || block.isStreamingBlock) return block;
|
|
117
|
+
const slug = firstKindSlug(block.content ?? "", { json5: isJson5Language(block.language) });
|
|
118
|
+
if (!slug) return settleUnnamedKindRoute(block);
|
|
119
|
+
const envelope = readEnvelope(block.metadata);
|
|
120
|
+
if (envelope?.root.kind || envelope?.root.status === "complete") return block;
|
|
121
|
+
const broken = {
|
|
122
|
+
v: IR_VERSION,
|
|
123
|
+
engine: "fe-kind-parser",
|
|
124
|
+
fingerprint: "broken-kind-text",
|
|
125
|
+
root: {
|
|
126
|
+
role: "structured",
|
|
127
|
+
kind: slug,
|
|
128
|
+
kindState: "raw",
|
|
129
|
+
discriminator: { format: "json", key: "__kind" },
|
|
130
|
+
status: "error",
|
|
131
|
+
path: [],
|
|
132
|
+
value: {},
|
|
133
|
+
residue: null
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
return applyIrKindRoute({
|
|
137
|
+
...block,
|
|
138
|
+
metadata: { ...block.metadata ?? {}, [IR_ENVELOPE_KEY]: broken }
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function settleUnnamedKindRoute(block) {
|
|
142
|
+
const content = block.content ?? "";
|
|
143
|
+
if (!isJsonFenceLanguage(block.language) || !hasKindKey(content, { json5: isJson5Language(block.language) })) {
|
|
144
|
+
return block;
|
|
145
|
+
}
|
|
146
|
+
if (isKindSlug(readEnvelope(block.metadata)?.root.kind)) return block;
|
|
147
|
+
const broken = {
|
|
148
|
+
v: IR_VERSION,
|
|
149
|
+
engine: "fe-kind-parser",
|
|
150
|
+
fingerprint: "broken-unnamed-kind",
|
|
151
|
+
root: {
|
|
152
|
+
role: "structured",
|
|
153
|
+
kind: "",
|
|
154
|
+
kindState: "raw",
|
|
155
|
+
discriminator: { format: "json", key: "__kind" },
|
|
156
|
+
status: "error",
|
|
157
|
+
path: [],
|
|
158
|
+
value: {},
|
|
159
|
+
residue: {
|
|
160
|
+
extra: null,
|
|
161
|
+
optionalMissing: null,
|
|
162
|
+
notices: [
|
|
163
|
+
{
|
|
164
|
+
code: "parse_error",
|
|
165
|
+
message: "Broken structured output: its __kind is missing or unreadable."
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
return {
|
|
172
|
+
...block,
|
|
173
|
+
type: GENERIC_STRUCTURED_COMPONENT_KEY,
|
|
174
|
+
metadata: { ...block.metadata ?? {}, [IR_ENVELOPE_KEY]: broken }
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function unparsedKindPendingEnvelope(block) {
|
|
178
|
+
if (!block.isStreamingBlock) return null;
|
|
179
|
+
const text = block.content ?? "";
|
|
180
|
+
const leadingComment = /^\s*\/[/*]/.test(text);
|
|
181
|
+
if (leadingComment && !isJsonFenceLanguage(block.language)) return null;
|
|
182
|
+
const body = leadingComment ? withoutLeadingJsonComments(text) : text;
|
|
183
|
+
if (!/^\s*[[{]/.test(body) && !(leadingComment && !body.trim())) return null;
|
|
184
|
+
const json5 = { json5: isJson5Language(block.language) };
|
|
185
|
+
if (jsonKindSignal(text, json5) === "not_kind") return null;
|
|
186
|
+
return {
|
|
187
|
+
v: IR_VERSION,
|
|
188
|
+
engine: "fe-kind-parser",
|
|
189
|
+
fingerprint: "first-key-signal",
|
|
190
|
+
root: {
|
|
191
|
+
role: "structured",
|
|
192
|
+
kind: firstKindSlug(text, json5) ?? "",
|
|
193
|
+
kindState: "pending_kind",
|
|
194
|
+
discriminator: { format: "json", key: "__kind" },
|
|
195
|
+
status: "streaming",
|
|
196
|
+
path: [],
|
|
197
|
+
value: {},
|
|
198
|
+
residue: null
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function decideBlockRender(inputBlock, {
|
|
203
|
+
isStreamActive,
|
|
204
|
+
suppressLoadingGate = false,
|
|
205
|
+
route = routeBlockNow
|
|
206
|
+
} = {}) {
|
|
207
|
+
const rawBlock = withTerminalEnvelope(inputBlock, isStreamActive);
|
|
208
|
+
const block = settleBrokenKindRoute(route(rawBlock));
|
|
209
|
+
const decided = (gate) => ({
|
|
210
|
+
rawBlock,
|
|
211
|
+
block,
|
|
212
|
+
gate
|
|
213
|
+
});
|
|
214
|
+
const provisional = suppressLoadingGate ? null : resolveProvisionalKindRender(rawBlock, { streamActive: isStreamActive });
|
|
215
|
+
if (provisional) return decided({ kind: "provisional", provisional });
|
|
216
|
+
const announced = suppressLoadingGate ? null : resolveAnnouncedKindLoading(rawBlock, { streamActive: isStreamActive });
|
|
217
|
+
if (announced) return decided({ kind: "loader", envelope: announced.envelope });
|
|
218
|
+
const pendingEnvelope = pendingStructuredEnvelope(block);
|
|
219
|
+
if (pendingEnvelope) return decided({ kind: "loader", envelope: pendingEnvelope });
|
|
220
|
+
if (block.type === GENERIC_STRUCTURED_COMPONENT_KEY && !suppressLoadingGate) {
|
|
221
|
+
const genericEnvelope = readEnvelope(block.metadata);
|
|
222
|
+
if (genericEnvelope?.root.kind && genericEnvelope.root.status === "streaming") {
|
|
223
|
+
return decided({ kind: "loader", envelope: genericEnvelope });
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (block.type !== "artifact" && !suppressLoadingGate) {
|
|
227
|
+
const def = resolveArtifactDef(block.type);
|
|
228
|
+
if (def && hasArtifactRenderer(def.canvasType) && isBlockLoading(block)) {
|
|
229
|
+
const kindEnvelope = readEnvelope(block.metadata);
|
|
230
|
+
if (kindEnvelope?.root.kind && block.serverData === void 0) {
|
|
231
|
+
return decided({ kind: "loader", envelope: kindEnvelope });
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return decided(null);
|
|
236
|
+
}
|
|
237
|
+
const PendingStructuredBlock = ({
|
|
238
|
+
envelope
|
|
239
|
+
}) => {
|
|
240
|
+
const kind = envelope.root.kind || void 0;
|
|
241
|
+
const slug = resolveLoadingSlugForKind(kind).slug;
|
|
242
|
+
const early = earlyKeysFromValue(envelope.root.value, kind);
|
|
243
|
+
return React.createElement(resolveKindLoadingComponent(slug), {
|
|
244
|
+
...early,
|
|
245
|
+
value: envelope.root.value ?? null
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
const BlockRenderer = ({
|
|
249
|
+
requestId,
|
|
250
|
+
block: inputBlock,
|
|
251
|
+
index,
|
|
252
|
+
isStreamActive,
|
|
253
|
+
onContentChange,
|
|
254
|
+
conversationId,
|
|
255
|
+
messageId,
|
|
256
|
+
taskId,
|
|
257
|
+
isLastReasoningBlock,
|
|
258
|
+
replaceBlockContent,
|
|
259
|
+
handleOpenEditor,
|
|
260
|
+
suppressLoadingGate = false,
|
|
261
|
+
outputSchema = null
|
|
262
|
+
}) => {
|
|
263
|
+
const durableMessageId = durableRecordId(messageId) ?? void 0;
|
|
264
|
+
const terminalBlock = withTerminalEnvelope(inputBlock, isStreamActive);
|
|
265
|
+
const partialEvent = readPartialKindEvent(terminalBlock.metadata);
|
|
266
|
+
const announcedKind = partialEvent?.state === "partial" ? partialEvent.root.kind : partialEvent?.kind;
|
|
267
|
+
const envelopeKind = readEnvelope(terminalBlock.metadata)?.root.kind ?? announcedKind ?? null;
|
|
268
|
+
const kindRouteVersion = useContentIrKindVersion(envelopeKind);
|
|
269
|
+
useEnsureKindRenderable(envelopeKind);
|
|
270
|
+
const decision = decideBlockRender(inputBlock, {
|
|
271
|
+
isStreamActive,
|
|
272
|
+
suppressLoadingGate,
|
|
273
|
+
route: (b) => routeBlockAtRegistryVersion(b, kindRouteVersion)
|
|
274
|
+
});
|
|
275
|
+
const block = decision.block;
|
|
276
|
+
const interruptedEnvelope = readEnvelope(block.metadata);
|
|
277
|
+
const hasInterruptedKind = Boolean(
|
|
278
|
+
!isStreamActive && interruptedEnvelope?.root.kind && interruptedEnvelope.root.status === "error"
|
|
279
|
+
);
|
|
280
|
+
const hideReasoning = Boolean(useHideReasoning(conversationId ?? null));
|
|
281
|
+
const hideToolResults = Boolean(useHideToolResults(conversationId ?? null));
|
|
282
|
+
const machineFramesVisible = useMachineFramesVisible();
|
|
283
|
+
const recordChromeKind = envelopeKind && !suppressLoadingGate && (kindHasRecordChrome(envelopeKind) || Boolean(durableMessageId)) ? envelopeKind : null;
|
|
284
|
+
const withRecordChrome = (el) => {
|
|
285
|
+
if (el && hasInterruptedKind) {
|
|
286
|
+
return /* @__PURE__ */ jsxs("div", { "data-incomplete-kind": interruptedEnvelope?.root.kind, children: [
|
|
287
|
+
/* @__PURE__ */ jsx(
|
|
288
|
+
"p",
|
|
289
|
+
{
|
|
290
|
+
role: "status",
|
|
291
|
+
className: "mb-2 rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-xs text-amber-800 dark:text-amber-200",
|
|
292
|
+
children: "This response is incomplete. The content received so far is shown below."
|
|
293
|
+
}
|
|
294
|
+
),
|
|
295
|
+
el
|
|
296
|
+
] }, index);
|
|
297
|
+
}
|
|
298
|
+
if (!el || !recordChromeKind || isStreamActive || isBlockLoading(block) || readEnvelope(block.metadata)?.root.status !== "complete") {
|
|
299
|
+
return el;
|
|
300
|
+
}
|
|
301
|
+
return /* @__PURE__ */ jsxs("div", { "data-kind-record-host": recordChromeKind, children: [
|
|
302
|
+
el,
|
|
303
|
+
/* @__PURE__ */ jsx(
|
|
304
|
+
KindRecordChrome,
|
|
305
|
+
{
|
|
306
|
+
kind: recordChromeKind,
|
|
307
|
+
durableMessageId,
|
|
308
|
+
conversationId,
|
|
309
|
+
value: readRecordValue(block),
|
|
310
|
+
fingerprint: readEnvelope(block.metadata)?.fingerprint ?? null
|
|
311
|
+
}
|
|
312
|
+
)
|
|
313
|
+
] }, index);
|
|
314
|
+
};
|
|
315
|
+
const renderFallbackContent = useCallback(
|
|
316
|
+
(content, language = "json") => {
|
|
317
|
+
return /* @__PURE__ */ jsx(
|
|
318
|
+
BlockComponents.CodeBlock,
|
|
319
|
+
{
|
|
320
|
+
code: content,
|
|
321
|
+
language,
|
|
322
|
+
fontSize: 16,
|
|
323
|
+
className: "my-3",
|
|
324
|
+
isStreamActive
|
|
325
|
+
},
|
|
326
|
+
index
|
|
327
|
+
);
|
|
328
|
+
},
|
|
329
|
+
[index, isStreamActive]
|
|
330
|
+
);
|
|
331
|
+
const blockType = String(block.type);
|
|
332
|
+
const renderBasicMarkdown = useCallback(
|
|
333
|
+
(content) => {
|
|
334
|
+
return /* @__PURE__ */ jsx(
|
|
335
|
+
BlockComponents.BasicMarkdownContent,
|
|
336
|
+
{
|
|
337
|
+
content,
|
|
338
|
+
isStreamActive,
|
|
339
|
+
onEditRequest: onContentChange ? handleOpenEditor : void 0,
|
|
340
|
+
messageId,
|
|
341
|
+
showCopyButton: false,
|
|
342
|
+
tableRenderDiagnostic: {
|
|
343
|
+
blockType,
|
|
344
|
+
conversationId,
|
|
345
|
+
messageId,
|
|
346
|
+
requestId
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
index
|
|
350
|
+
);
|
|
351
|
+
},
|
|
352
|
+
[
|
|
353
|
+
index,
|
|
354
|
+
isStreamActive,
|
|
355
|
+
onContentChange,
|
|
356
|
+
handleOpenEditor,
|
|
357
|
+
messageId,
|
|
358
|
+
blockType,
|
|
359
|
+
conversationId,
|
|
360
|
+
requestId
|
|
361
|
+
]
|
|
362
|
+
);
|
|
363
|
+
if (decision.gate?.kind === "provisional") {
|
|
364
|
+
const provisional = decision.gate.provisional;
|
|
365
|
+
return /* @__PURE__ */ jsx(
|
|
366
|
+
ProvisionalKindBoundary,
|
|
367
|
+
{
|
|
368
|
+
kind: provisional.kind,
|
|
369
|
+
fallback: /* @__PURE__ */ jsx(PendingStructuredBlock, { envelope: provisional.envelope }),
|
|
370
|
+
children: /* @__PURE__ */ jsx(ProvisionalKindFrame, { children: /* @__PURE__ */ jsx(
|
|
371
|
+
BlockRenderer,
|
|
372
|
+
{
|
|
373
|
+
requestId,
|
|
374
|
+
block: provisional.block,
|
|
375
|
+
index,
|
|
376
|
+
isStreamActive,
|
|
377
|
+
onContentChange,
|
|
378
|
+
conversationId,
|
|
379
|
+
messageId,
|
|
380
|
+
taskId,
|
|
381
|
+
isLastReasoningBlock,
|
|
382
|
+
replaceBlockContent,
|
|
383
|
+
handleOpenEditor,
|
|
384
|
+
suppressLoadingGate: true,
|
|
385
|
+
outputSchema
|
|
386
|
+
}
|
|
387
|
+
) })
|
|
388
|
+
},
|
|
389
|
+
index
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
if (decision.gate?.kind === "loader") {
|
|
393
|
+
return /* @__PURE__ */ jsx(PendingStructuredBlock, { envelope: decision.gate.envelope }, index);
|
|
394
|
+
}
|
|
395
|
+
if (block.type !== "artifact") {
|
|
396
|
+
const _def = resolveArtifactDef(block.type);
|
|
397
|
+
if (_def && hasArtifactRenderer(_def.canvasType)) {
|
|
398
|
+
const loading = !suppressLoadingGate && isBlockLoading(block);
|
|
399
|
+
const kindEnvelope = loading ? readEnvelope(block.metadata) : null;
|
|
400
|
+
if (loading && !kindEnvelope?.root.kind) {
|
|
401
|
+
const Loader = ARTIFACT_LOADING_COMPONENTS[_def.canvasType];
|
|
402
|
+
if (Loader) {
|
|
403
|
+
return /* @__PURE__ */ jsx(Loader, {}, index);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
return withRecordChrome(
|
|
407
|
+
/* @__PURE__ */ jsx(
|
|
408
|
+
ArtifactRender,
|
|
409
|
+
{
|
|
410
|
+
canvasType: _def.canvasType,
|
|
411
|
+
mode: "inline",
|
|
412
|
+
raw: block.content,
|
|
413
|
+
serverData: block.serverData,
|
|
414
|
+
metadata: block.metadata,
|
|
415
|
+
taskId,
|
|
416
|
+
conversationId,
|
|
417
|
+
messageId,
|
|
418
|
+
blockIndex: index,
|
|
419
|
+
isStreamActive: loading,
|
|
420
|
+
onContentChange: !loading && replaceBlockContent ? (updated) => replaceBlockContent(block.content, updated, { origin: "kind" }) : void 0
|
|
421
|
+
},
|
|
422
|
+
index
|
|
423
|
+
)
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
const ctx = {
|
|
428
|
+
block,
|
|
429
|
+
index,
|
|
430
|
+
isStreamActive,
|
|
431
|
+
conversationId,
|
|
432
|
+
messageId,
|
|
433
|
+
durableMessageId,
|
|
434
|
+
taskId,
|
|
435
|
+
requestId,
|
|
436
|
+
isLastReasoningBlock,
|
|
437
|
+
hideReasoning,
|
|
438
|
+
hideToolResults,
|
|
439
|
+
machineFramesVisible,
|
|
440
|
+
replaceBlockContent,
|
|
441
|
+
renderBasicMarkdown,
|
|
442
|
+
outputSchema
|
|
443
|
+
};
|
|
444
|
+
const dispatch = resolveBlockDispatch(block.type);
|
|
445
|
+
if (dispatch) {
|
|
446
|
+
return withRecordChrome(dispatch(ctx));
|
|
447
|
+
}
|
|
448
|
+
reportUnregisteredBlockType(block.type, {
|
|
449
|
+
conversationId,
|
|
450
|
+
messageId,
|
|
451
|
+
requestId
|
|
452
|
+
});
|
|
453
|
+
if (block.content) return renderBasicMarkdown(block.content);
|
|
454
|
+
const UnknownDataEventBlock = BlockComponents.UnknownDataEventBlock;
|
|
455
|
+
if (!UnknownDataEventBlock) return renderBasicMarkdown("```json\n" + JSON.stringify({ type: block.type, data: block.serverData ?? null }, null, 2) + "\n```");
|
|
456
|
+
return /* @__PURE__ */ jsx(
|
|
457
|
+
UnknownDataEventBlock,
|
|
458
|
+
{
|
|
459
|
+
dataType: block.type,
|
|
460
|
+
data: block.serverData ?? {},
|
|
461
|
+
conversationId,
|
|
462
|
+
messageId
|
|
463
|
+
},
|
|
464
|
+
index
|
|
465
|
+
);
|
|
466
|
+
};
|
|
467
|
+
export {
|
|
468
|
+
BlockRenderer,
|
|
469
|
+
decideBlockRender,
|
|
470
|
+
pendingStructuredEnvelope,
|
|
471
|
+
settleBrokenKindRoute,
|
|
472
|
+
withTerminalEnvelope
|
|
473
|
+
};
|