@ai-matrx/rich-content 0.2.4 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/code-block/CodeBlock.d.ts +44 -0
- package/dist/code-block/CodeBlock.js +449 -0
- package/dist/code-block/CodeBlockHeader.d.ts +63 -0
- package/dist/code-block/CodeBlockHeader.js +472 -0
- package/dist/code-block/CodeEditorLoading.d.ts +3 -0
- package/dist/code-block/CodeEditorLoading.js +34 -0
- package/dist/code-block/LanguageDisplay.d.ts +28 -0
- package/dist/code-block/LanguageDisplay.js +279 -0
- package/dist/code-block/SmallCodeEditor.d.ts +30 -0
- package/dist/code-block/SmallCodeEditor.js +22 -0
- package/dist/code-block/StickyButtons.d.ts +35 -0
- package/dist/code-block/StickyButtons.js +88 -0
- package/dist/code-block/highlight/ShikiCodeView.d.ts +26 -0
- package/dist/code-block/highlight/ShikiCodeView.js +134 -0
- package/dist/code-block/highlight/shiki-highlighter.d.ts +14 -0
- package/dist/code-block/highlight/shiki-highlighter.js +126 -0
- package/dist/code-block/highlight/useHighlightedLines.d.ts +18 -0
- package/dist/code-block/highlight/useHighlightedLines.js +142 -0
- package/dist/code-block/sticky-inset.d.ts +6 -0
- package/dist/code-block/sticky-inset.js +10 -0
- package/dist/display/block-interaction.d.ts +33 -0
- package/dist/display/block-interaction.js +13 -0
- package/dist/display/blocks/ChatCollapsibleWrapper.d.ts +13 -0
- package/dist/display/blocks/ChatCollapsibleWrapper.js +56 -0
- package/dist/display/blocks/buildMediaSource.d.ts +25 -0
- package/dist/display/blocks/buildMediaSource.js +43 -0
- package/dist/display/blocks/canvas-adaptive.d.ts +118 -0
- package/dist/display/blocks/canvas-adaptive.js +127 -0
- package/dist/display/blocks/canvas-fit.d.ts +24 -0
- package/dist/display/blocks/canvas-fit.js +19 -0
- package/dist/display/blocks/chart/ChartBlock.d.ts +8 -0
- package/dist/display/blocks/chart/ChartBlock.js +125 -0
- package/dist/display/blocks/chart/ChartCanvas.d.ts +18 -0
- package/dist/display/blocks/chart/ChartCanvas.js +159 -0
- package/dist/display/blocks/chart/TableChart.d.ts +25 -0
- package/dist/display/blocks/chart/TableChart.js +97 -0
- package/dist/display/blocks/chart/chart-spec.d.ts +39 -0
- package/dist/display/blocks/chart/chart-spec.js +128 -0
- package/dist/display/blocks/chart/labels.d.ts +20 -0
- package/dist/display/blocks/chart/labels.js +7 -0
- package/dist/display/blocks/chart/table-chart.d.ts +37 -0
- package/dist/display/blocks/chart/table-chart.js +231 -0
- package/dist/display/blocks/common/BlockHeaderWrapper.d.ts +56 -0
- package/dist/display/blocks/common/BlockHeaderWrapper.js +310 -0
- package/dist/display/blocks/common/ContentBlockWrapper.d.ts +40 -0
- package/dist/display/blocks/common/ContentBlockWrapper.js +214 -0
- package/dist/display/blocks/common/SandboxedHtml.d.ts +27 -0
- package/dist/display/blocks/common/SandboxedHtml.js +26 -0
- package/dist/display/blocks/diagram/DiagramLoadingVisualization.d.ts +6 -0
- package/dist/display/blocks/diagram/DiagramLoadingVisualization.js +190 -0
- package/dist/display/blocks/diagram/InteractiveDiagramBlock.d.ts +51 -0
- package/dist/display/blocks/diagram/InteractiveDiagramBlock.js +2415 -0
- package/dist/display/blocks/diagram/diagram-printer.d.ts +16 -0
- package/dist/display/blocks/diagram/diagram-printer.js +294 -0
- package/dist/display/blocks/diagram/diagram-visual-defaults.d.ts +116 -0
- package/dist/display/blocks/diagram/diagram-visual-defaults.js +400 -0
- package/dist/display/blocks/diagram/layout-utils.d.ts +90 -0
- package/dist/display/blocks/diagram/layout-utils.js +347 -0
- package/dist/display/blocks/diagram/parseDiagramJSON.d.ts +105 -0
- package/dist/display/blocks/diagram/parseDiagramJSON.js +296 -0
- package/dist/display/blocks/diagram/presentation-direction.d.ts +29 -0
- package/dist/display/blocks/diagram/presentation-direction.js +19 -0
- package/dist/display/blocks/diagram/ui-utils.d.ts +1 -0
- package/dist/display/blocks/diagram/ui-utils.js +18 -0
- package/dist/display/blocks/diff/DiffBlock.d.ts +10 -0
- package/dist/display/blocks/diff/DiffBlock.js +119 -0
- package/dist/display/blocks/diff/DiffCanvas.d.ts +15 -0
- package/dist/display/blocks/diff/DiffCanvas.js +20 -0
- package/dist/display/blocks/generic/GenericStructuredBlock.d.ts +24 -0
- package/dist/display/blocks/generic/GenericStructuredBlock.js +53 -0
- package/dist/display/blocks/generic/StructuredValueTabs.d.ts +21 -0
- package/dist/display/blocks/generic/StructuredValueTabs.js +124 -0
- package/dist/display/blocks/generic/tile-actions-slot.d.ts +39 -0
- package/dist/display/blocks/generic/tile-actions-slot.js +33 -0
- package/dist/display/blocks/images/ImageBlock.d.ts +8 -0
- package/dist/display/blocks/images/ImageBlock.js +265 -0
- package/dist/display/blocks/json/JsonBlock.d.ts +34 -0
- package/dist/display/blocks/json/JsonBlock.js +562 -0
- package/dist/display/blocks/json/JsonTableView.d.ts +10 -0
- package/dist/display/blocks/json/JsonTableView.js +173 -0
- package/dist/display/blocks/json/json-compact-stringify.d.ts +25 -0
- package/dist/display/blocks/json/json-compact-stringify.js +52 -0
- package/dist/display/blocks/json/json-tabular-utils.d.ts +65 -0
- package/dist/display/blocks/json/json-tabular-utils.js +121 -0
- package/dist/display/blocks/links/LinkComponent.d.ts +6 -0
- package/dist/display/blocks/links/LinkComponent.js +373 -0
- package/dist/display/blocks/links/LinkComponentWithFetch.d.ts +1 -0
- package/dist/display/blocks/links/LinkComponentWithFetch.js +0 -0
- package/dist/display/blocks/markdown/MarkdownKindBlock.d.ts +48 -0
- package/dist/display/blocks/markdown/MarkdownKindBlock.js +52 -0
- package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.d.ts +17 -0
- package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.js +70 -0
- package/dist/display/blocks/mermaid/MermaidBlock.d.ts +19 -0
- package/dist/display/blocks/mermaid/MermaidBlock.js +386 -0
- package/dist/display/blocks/search-replace/SearchReplaceBlock.d.ts +50 -0
- package/dist/display/blocks/search-replace/SearchReplaceBlock.js +71 -0
- package/dist/display/blocks/svg/SvgBlock.d.ts +8 -0
- package/dist/display/blocks/svg/SvgBlock.js +126 -0
- package/dist/display/blocks/table/StreamingTableRenderer.d.ts +53 -0
- package/dist/display/blocks/table/StreamingTableRenderer.js +907 -0
- package/dist/display/blocks/table/TableRenderPathDiagnostic.d.ts +21 -0
- package/dist/display/blocks/table/TableRenderPathDiagnostic.js +79 -0
- package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.d.ts +14 -0
- package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.js +15 -0
- package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.d.ts +13 -0
- package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.js +19 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTrace.d.ts +30 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTrace.js +75 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.d.ts +13 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.js +48 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.d.ts +12 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.js +19 -0
- package/dist/display/blocks/toml/TomlBlock.d.ts +7 -0
- package/dist/display/blocks/toml/TomlBlock.js +167 -0
- package/dist/display/blocks/tree/TreeBlock.d.ts +7 -0
- package/dist/display/blocks/tree/TreeBlock.js +163 -0
- package/dist/display/blocks/xml/XmlBlock.d.ts +23 -0
- package/dist/display/blocks/xml/XmlBlock.js +197 -0
- package/dist/display/blocks/xml/readXmlTag.d.ts +1 -0
- package/dist/display/blocks/xml/readXmlTag.js +1 -0
- package/dist/display/blocks/xml/xml-tokenize.d.ts +13 -0
- package/dist/display/blocks/xml/xml-tokenize.js +169 -0
- package/dist/display/blocks/yaml/YamlBlock.d.ts +7 -0
- package/dist/display/blocks/yaml/YamlBlock.js +191 -0
- package/dist/display/chat-markdown/BasicMarkdownContent.d.ts +29 -0
- package/dist/display/chat-markdown/BasicMarkdownContent.js +122 -0
- package/dist/display/chat-markdown/BlockRenderingContext.d.ts +23 -0
- package/dist/display/chat-markdown/BlockRenderingContext.js +17 -0
- package/dist/display/chat-markdown/ConfigurableMarkdownContent.d.ts +172 -0
- package/dist/display/chat-markdown/ConfigurableMarkdownContent.js +649 -0
- package/dist/display/chat-markdown/InlineCodeSnippet.d.ts +19 -0
- package/dist/display/chat-markdown/InlineCodeSnippet.js +146 -0
- package/dist/display/chat-markdown/InlineCodeSnippetKindGate.d.ts +11 -0
- package/dist/display/chat-markdown/InlineCodeSnippetKindGate.js +9 -0
- package/dist/display/chat-markdown/KindTextGate.d.ts +31 -0
- package/dist/display/chat-markdown/KindTextGate.js +60 -0
- package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.d.ts +6 -0
- package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.js +92 -0
- package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.d.ts +72 -0
- package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.js +94 -0
- package/dist/display/chat-markdown/block-registry/BlockRenderer.d.ts +126 -0
- package/dist/display/chat-markdown/block-registry/BlockRenderer.js +473 -0
- package/dist/display/chat-markdown/block-registry/block-dispatch.d.ts +410 -0
- package/dist/display/chat-markdown/block-registry/block-dispatch.js +495 -0
- package/dist/display/chat-markdown/block-registry/json-parse-utils.d.ts +13 -0
- package/dist/display/chat-markdown/block-registry/json-parse-utils.js +236 -0
- package/dist/display/chat-markdown/constants.d.ts +14 -0
- package/dist/display/chat-markdown/constants.js +317 -0
- package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.d.ts +31 -0
- package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.js +62 -0
- package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.d.ts +12 -0
- package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.js +18 -0
- package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.d.ts +22 -0
- package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.js +130 -0
- package/dist/display/chat-markdown/diff-blocks/diff-style-registry.d.ts +21 -0
- package/dist/display/chat-markdown/diff-blocks/diff-style-registry.js +91 -0
- package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.d.ts +26 -0
- package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.js +186 -0
- package/dist/display/chat-markdown/diff-blocks/types.d.ts +56 -0
- package/dist/display/chat-markdown/diff-blocks/types.js +0 -0
- package/dist/display/chat-markdown/internal-handlers/BlockFallback.d.ts +20 -0
- package/dist/display/chat-markdown/internal-handlers/BlockFallback.js +83 -0
- package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.d.ts +4 -0
- package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.js +16 -0
- package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.d.ts +17 -0
- package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.js +40 -0
- package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.d.ts +8 -0
- package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.js +91 -0
- package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.d.ts +20 -0
- package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.js +72 -0
- package/dist/display/chat-markdown/kind-source-view.d.ts +14 -0
- package/dist/display/chat-markdown/kind-source-view.js +14 -0
- package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.d.ts +28 -0
- package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.js +65 -0
- package/dist/display/chat-markdown/progressive-mount.d.ts +18 -0
- package/dist/display/chat-markdown/progressive-mount.js +90 -0
- package/dist/display/chat-markdown/render-block-to-content-block.d.ts +31 -0
- package/dist/display/chat-markdown/render-block-to-content-block.js +32 -0
- package/dist/display/chat-markdown/settle-stream-blocks.d.ts +50 -0
- package/dist/display/chat-markdown/settle-stream-blocks.js +26 -0
- package/dist/display/chat-markdown/stable-blocks.d.ts +15 -0
- package/dist/display/chat-markdown/stable-blocks.js +54 -0
- package/dist/display/chat-markdown/types.d.ts +11 -0
- package/dist/display/chat-markdown/types.js +26 -0
- package/dist/display/specimen/SpecimenContext.d.ts +26 -0
- package/dist/display/specimen/SpecimenContext.js +64 -0
- package/dist/display/tables/MarkdownTable.d.ts +23 -0
- package/dist/display/tables/MarkdownTable.js +769 -0
- package/dist/display/tables/MarkdownTableScrollArea.d.ts +12 -0
- package/dist/display/tables/MarkdownTableScrollArea.js +92 -0
- package/dist/display/tables/SendToGoogleSheetButton.d.ts +19 -0
- package/dist/display/tables/SendToGoogleSheetButton.js +93 -0
- package/dist/display/tables/SendToWorkbookButton.d.ts +24 -0
- package/dist/display/tables/SendToWorkbookButton.js +93 -0
- package/dist/display/tables/TableSaveToMenu.d.ts +16 -0
- package/dist/display/tables/TableSaveToMenu.js +98 -0
- package/dist/display/tables/TableWithSeparatedControls.d.ts +22 -0
- package/dist/display/tables/TableWithSeparatedControls.js +574 -0
- package/dist/display/tables/ViewTableModal.d.ts +14 -0
- package/dist/display/tables/ViewTableModal.js +67 -0
- package/dist/display/tables/editing/ColumnActionsMenu.d.ts +16 -0
- package/dist/display/tables/editing/ColumnActionsMenu.js +80 -0
- package/dist/display/tables/editing/RowActionsMenu.d.ts +16 -0
- package/dist/display/tables/editing/RowActionsMenu.js +80 -0
- package/dist/display/tables/editing/TableEditToolbar.d.ts +15 -0
- package/dist/display/tables/editing/TableEditToolbar.js +63 -0
- package/dist/display/tables/editing/tableMutations.d.ts +50 -0
- package/dist/display/tables/editing/tableMutations.js +148 -0
- package/dist/display/tables/editing/useDoubleClickEdit.d.ts +43 -0
- package/dist/display/tables/editing/useDoubleClickEdit.js +51 -0
- package/dist/display/tables/editing/useTableUndo.d.ts +25 -0
- package/dist/display/tables/editing/useTableUndo.js +17 -0
- package/dist/display/tables/table-action-row.d.ts +8 -0
- package/dist/display/tables/table-action-row.js +31 -0
- package/dist/display/tables/table-viewer.d.ts +13 -0
- package/dist/display/tables/table-viewer.js +18 -0
- package/dist/host/ErrorActions.d.ts +1 -1
- package/dist/host/ErrorNotice.d.ts +10 -0
- package/dist/host/ErrorNotice.js +19 -0
- package/dist/host/app-bindings.d.ts +155 -0
- package/dist/host/app-bindings.js +160 -0
- package/dist/host/diagnostics.d.ts +2 -2
- package/dist/host/diagnostics.js +2 -1
- package/dist/host/tables.d.ts +1 -6
- package/dist/host/types.d.ts +14 -7
- package/dist/levels/RichContent.d.ts +3 -0
- package/dist/levels/RichContent.js +102 -0
- package/dist/levels/RichContentInline.d.ts +28 -0
- package/dist/levels/RichContentInline.js +61 -0
- package/dist/levels/RichContentPreview.d.ts +12 -0
- package/dist/levels/RichContentPreview.js +39 -0
- package/dist/levels/RichContentStandardImpl.d.ts +12 -0
- package/dist/levels/RichContentStandardImpl.js +27 -0
- package/dist/levels/RichContentStaticProse.d.ts +46 -0
- package/dist/levels/RichContentStaticProse.js +100 -0
- package/dist/levels/depth.d.ts +18 -0
- package/dist/levels/depth.js +32 -0
- package/dist/levels/prose/inline-level-elements.d.ts +19 -0
- package/dist/levels/prose/inline-level-elements.js +103 -0
- package/dist/levels/prose/prose-block-elements.d.ts +25 -0
- package/dist/levels/prose/prose-block-elements.js +313 -0
- package/dist/levels/prose/prose-inline-elements.d.ts +13 -0
- package/dist/levels/prose/prose-inline-elements.js +143 -0
- package/dist/levels/prose/prose-prepare.d.ts +50 -0
- package/dist/levels/prose/prose-prepare.js +246 -0
- package/dist/levels/prose/remote-image-policy.d.ts +34 -0
- package/dist/levels/prose/remote-image-policy.js +153 -0
- package/dist/levels/prose/variant-root.d.ts +9 -0
- package/dist/levels/prose/variant-root.js +34 -0
- package/dist/levels/rich-content-types.d.ts +93 -0
- package/dist/levels/rich-content-types.js +4 -0
- package/dist/levels/server/DelimiterViolationReport.d.ts +7 -0
- package/dist/levels/server/DelimiterViolationReport.js +24 -0
- package/dist/levels/server/RichContentServer.d.ts +27 -0
- package/dist/levels/server/RichContentServer.js +97 -0
- package/dist/levels/standard/NestedRichContent.d.ts +7 -0
- package/dist/levels/standard/NestedRichContent.js +70 -0
- package/dist/levels/standard/StandardBlocks.d.ts +13 -0
- package/dist/levels/standard/StandardBlocks.js +239 -0
- package/dist/levels/standard/StandardKindRegion.d.ts +14 -0
- package/dist/levels/standard/StandardKindRegion.js +69 -0
- package/dist/levels/standard/standard-kind-region.d.ts +19 -0
- package/dist/levels/standard/standard-kind-region.js +21 -0
- package/dist/levels/standard/static-standard.d.ts +23 -0
- package/dist/levels/standard/static-standard.js +187 -0
- package/dist/levels/standard/stream-holdback.d.ts +2 -0
- package/dist/levels/standard/stream-holdback.js +77 -0
- package/dist/mermaid/MermaidFullscreen.d.ts +17 -0
- package/dist/mermaid/MermaidFullscreen.js +71 -0
- package/dist/mermaid/MermaidRenderer.d.ts +20 -0
- package/dist/mermaid/MermaidRenderer.js +267 -0
- package/dist/mermaid/MermaidView.d.ts +27 -0
- package/dist/mermaid/MermaidView.js +68 -0
- package/dist/mermaid/MermaidViewport.d.ts +75 -0
- package/dist/mermaid/MermaidViewport.js +286 -0
- package/dist/mermaid/adapters/er.d.ts +10 -0
- package/dist/mermaid/adapters/er.js +205 -0
- package/dist/mermaid/adapters/flowchart.d.ts +17 -0
- package/dist/mermaid/adapters/flowchart.js +634 -0
- package/dist/mermaid/adapters/journey.d.ts +9 -0
- package/dist/mermaid/adapters/journey.js +207 -0
- package/dist/mermaid/adapters/mindmap.d.ts +12 -0
- package/dist/mermaid/adapters/mindmap.js +252 -0
- package/dist/mermaid/adapters/pie.d.ts +7 -0
- package/dist/mermaid/adapters/pie.js +172 -0
- package/dist/mermaid/adapters/quadrant.d.ts +8 -0
- package/dist/mermaid/adapters/quadrant.js +231 -0
- package/dist/mermaid/adapters/register.d.ts +7 -0
- package/dist/mermaid/adapters/register.js +19 -0
- package/dist/mermaid/adapters/sequence.d.ts +8 -0
- package/dist/mermaid/adapters/sequence.js +251 -0
- package/dist/mermaid/adapters/state.d.ts +12 -0
- package/dist/mermaid/adapters/state.js +245 -0
- package/dist/mermaid/adapters/timeline.d.ts +8 -0
- package/dist/mermaid/adapters/timeline.js +245 -0
- package/dist/mermaid/catalog.d.ts +33 -0
- package/dist/mermaid/catalog.js +202 -0
- package/dist/mermaid/diagram-type.d.ts +39 -0
- package/dist/mermaid/diagram-type.js +89 -0
- package/dist/mermaid/export.d.ts +21 -0
- package/dist/mermaid/export.js +112 -0
- package/dist/mermaid/extract-fence.d.ts +15 -0
- package/dist/mermaid/extract-fence.js +22 -0
- package/dist/mermaid/lazy-draw.d.ts +40 -0
- package/dist/mermaid/lazy-draw.js +168 -0
- package/dist/mermaid/model/adapter.d.ts +28 -0
- package/dist/mermaid/model/adapter.js +16 -0
- package/dist/mermaid/model/ops.d.ts +282 -0
- package/dist/mermaid/model/ops.js +9 -0
- package/dist/mermaid/model/round-trip.d.ts +22 -0
- package/dist/mermaid/model/round-trip.js +45 -0
- package/dist/mermaid/model/types.d.ts +271 -0
- package/dist/mermaid/model/types.js +0 -0
- package/dist/mermaid/print-render.d.ts +9 -0
- package/dist/mermaid/print-render.js +39 -0
- package/dist/mermaid/runtime.d.ts +25 -0
- package/dist/mermaid/runtime.js +183 -0
- package/dist/mermaid/sanitize.d.ts +46 -0
- package/dist/mermaid/sanitize.js +234 -0
- package/dist/mermaid/types.d.ts +43 -0
- package/dist/mermaid/types.js +21 -0
- package/dist/mermaid/view/ViewModePane.d.ts +24 -0
- package/dist/mermaid/view/ViewModePane.js +9 -0
- package/dist/utils/client-lazy.d.ts +1 -1
- package/dist/utils/client-lazy.js +4 -1
- package/dist/utils/lifted/DiffView.d.ts +10 -0
- package/dist/utils/lifted/DiffView.js +26 -0
- package/dist/utils/lifted/IconButton.d.ts +24 -0
- package/dist/utils/lifted/IconButton.js +43 -0
- package/dist/utils/lifted/MatrxMiniLoader.d.ts +1 -0
- package/dist/utils/lifted/MatrxMiniLoader.js +8 -0
- package/dist/utils/lifted/ShimmerText.d.ts +5 -0
- package/dist/utils/lifted/ShimmerText.js +21 -0
- package/dist/utils/lifted/SuspenseLoader.d.ts +16 -0
- package/dist/utils/lifted/SuspenseLoader.js +42 -0
- package/dist/utils/lifted/Tooltip.d.ts +20 -0
- package/dist/utils/lifted/Tooltip.js +52 -0
- package/dist/utils/lifted/artifactId.d.ts +34 -0
- package/dist/utils/lifted/artifactId.js +15 -0
- package/dist/utils/lifted/canvasContent.d.ts +63 -0
- package/dist/utils/lifted/canvasContent.js +98 -0
- package/dist/utils/lifted/captureReactError.d.ts +24 -0
- package/dist/utils/lifted/captureReactError.js +28 -0
- package/dist/utils/lifted/chunk-load-recovery.d.ts +25 -0
- package/dist/utils/lifted/chunk-load-recovery.js +36 -0
- package/dist/utils/lifted/code-editor-agent-types.d.ts +6 -0
- package/dist/utils/lifted/code-editor-agent-types.js +0 -0
- package/dist/utils/lifted/code-editor-agents.d.ts +39 -0
- package/dist/utils/lifted/code-editor-agents.js +52 -0
- package/dist/utils/lifted/code-language-extension.d.ts +1 -0
- package/dist/utils/lifted/code-language-extension.js +60 -0
- package/dist/utils/lifted/custom-icons.d.ts +16 -0
- package/dist/utils/lifted/custom-icons.js +47 -0
- package/dist/utils/lifted/durability.d.ts +16 -0
- package/dist/utils/lifted/durability.js +45 -0
- package/dist/utils/lifted/errors.d.ts +30 -0
- package/dist/utils/lifted/errors.js +29 -0
- package/dist/utils/lifted/html-document.d.ts +1 -0
- package/dist/utils/lifted/html-document.js +12 -0
- package/dist/utils/lifted/languageOptions.d.ts +9 -0
- package/dist/utils/lifted/languageOptions.js +52 -0
- package/dist/utils/lifted/languages.d.ts +34 -0
- package/dist/utils/lifted/languages.js +175 -0
- package/dist/utils/lifted/loading-spinner.d.ts +18 -0
- package/dist/utils/lifted/loading-spinner.js +200 -0
- package/dist/utils/lifted/media-refs.d.ts +13 -0
- package/dist/utils/lifted/media-refs.js +27 -0
- package/dist/utils/lifted/scroll-root.d.ts +1 -0
- package/dist/utils/lifted/scroll-root.js +25 -0
- package/dist/utils/lifted/syntax-themes.d.ts +32 -0
- package/dist/utils/lifted/syntax-themes.js +100 -0
- package/dist/utils/lifted/url-utm.d.ts +24 -0
- package/dist/utils/lifted/url-utm.js +66 -0
- package/dist/utils/lifted/use-is-mounted.d.ts +24 -0
- package/dist/utils/lifted/use-is-mounted.js +21 -0
- package/dist/utils/lifted/useToastManager.d.ts +1 -0
- package/dist/utils/lifted/useToastManager.js +7 -0
- package/dist/utils/report-kind-at-raw-renderer.d.ts +19 -0
- package/dist/utils/report-kind-at-raw-renderer.js +32 -0
- package/package.json +48 -10
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming Diff Block
|
|
3
|
+
*
|
|
4
|
+
* Main component that handles streaming diff content with multiple styles.
|
|
5
|
+
* Optimized for performance with thousands of streaming chunks.
|
|
6
|
+
*
|
|
7
|
+
* State Machine:
|
|
8
|
+
* detecting → buffering → streaming → complete
|
|
9
|
+
* ↘ fallback (if unrecognized)
|
|
10
|
+
*/
|
|
11
|
+
import React from "react";
|
|
12
|
+
export interface StreamingDiffBlockProps {
|
|
13
|
+
content: string;
|
|
14
|
+
language?: string;
|
|
15
|
+
isStreamActive?: boolean;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Main StreamingDiffBlock component
|
|
20
|
+
* Highly optimized for streaming performance
|
|
21
|
+
*/
|
|
22
|
+
export declare const StreamingDiffBlock: React.FC<StreamingDiffBlockProps>;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import React, { useMemo } from "react";
|
|
4
|
+
import { detectDiffStyle, getDiffStyleHandler } from "./diff-style-registry.js";
|
|
5
|
+
import { SearchReplaceDiffRenderer } from "./renderers/SearchReplaceDiffRenderer.js";
|
|
6
|
+
import { DiffLoadingIndicator } from "./DiffLoadingIndicator.js";
|
|
7
|
+
import CodeBlock from "../../../code-block/CodeBlock.js";
|
|
8
|
+
import { cn } from "@ai-matrx/design-system";
|
|
9
|
+
function useStreamingState(content, isStreamActive) {
|
|
10
|
+
return useMemo(() => {
|
|
11
|
+
if (!content || content.trim().length < 15) {
|
|
12
|
+
return { state: "detecting", style: "unknown", confidence: 0 };
|
|
13
|
+
}
|
|
14
|
+
const detection = detectDiffStyle(content);
|
|
15
|
+
if (detection.confidence < 0.6) {
|
|
16
|
+
if (isStreamActive) {
|
|
17
|
+
return {
|
|
18
|
+
state: "detecting",
|
|
19
|
+
style: "unknown",
|
|
20
|
+
confidence: detection.confidence
|
|
21
|
+
};
|
|
22
|
+
} else {
|
|
23
|
+
return {
|
|
24
|
+
state: "fallback",
|
|
25
|
+
style: "unknown",
|
|
26
|
+
confidence: detection.confidence
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (isStreamActive) {
|
|
31
|
+
return {
|
|
32
|
+
state: "streaming",
|
|
33
|
+
style: detection.style,
|
|
34
|
+
confidence: detection.confidence
|
|
35
|
+
};
|
|
36
|
+
} else {
|
|
37
|
+
return {
|
|
38
|
+
state: "complete",
|
|
39
|
+
style: detection.style,
|
|
40
|
+
confidence: detection.confidence
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}, [content, isStreamActive]);
|
|
44
|
+
}
|
|
45
|
+
const StreamingDiffBlock = React.memo(
|
|
46
|
+
({ content, language = "typescript", isStreamActive = false, className }) => {
|
|
47
|
+
const { state, style, confidence } = useStreamingState(
|
|
48
|
+
content,
|
|
49
|
+
isStreamActive
|
|
50
|
+
);
|
|
51
|
+
const handler = useMemo(() => {
|
|
52
|
+
if (style === "unknown") return null;
|
|
53
|
+
return getDiffStyleHandler(style);
|
|
54
|
+
}, [style]);
|
|
55
|
+
const parsedData = useMemo(() => {
|
|
56
|
+
if (!handler) return null;
|
|
57
|
+
return handler.parse(content);
|
|
58
|
+
}, [handler, content]);
|
|
59
|
+
switch (state) {
|
|
60
|
+
case "detecting":
|
|
61
|
+
return /* @__PURE__ */ jsx(
|
|
62
|
+
"div",
|
|
63
|
+
{
|
|
64
|
+
className: cn(
|
|
65
|
+
"rounded-lg border border-neutral-200 dark:border-neutral-700 bg-muted/30",
|
|
66
|
+
className
|
|
67
|
+
),
|
|
68
|
+
children: /* @__PURE__ */ jsx(DiffLoadingIndicator, { message: "Identifying code to target..." })
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
case "fallback":
|
|
72
|
+
return /* @__PURE__ */ jsx(
|
|
73
|
+
CodeBlock,
|
|
74
|
+
{
|
|
75
|
+
showSource: true,
|
|
76
|
+
code: content,
|
|
77
|
+
language: "diff",
|
|
78
|
+
showLineNumbers: true,
|
|
79
|
+
className
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
case "streaming":
|
|
83
|
+
case "complete":
|
|
84
|
+
return renderDiffByStyle(
|
|
85
|
+
style,
|
|
86
|
+
parsedData,
|
|
87
|
+
language,
|
|
88
|
+
isStreamActive,
|
|
89
|
+
className
|
|
90
|
+
);
|
|
91
|
+
default:
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
StreamingDiffBlock.displayName = "StreamingDiffBlock";
|
|
97
|
+
function renderDiffByStyle(style, parsedData, language, isStreamActive, className) {
|
|
98
|
+
switch (style) {
|
|
99
|
+
case "search-replace":
|
|
100
|
+
return /* @__PURE__ */ jsx(
|
|
101
|
+
SearchReplaceDiffRenderer,
|
|
102
|
+
{
|
|
103
|
+
data: parsedData,
|
|
104
|
+
language,
|
|
105
|
+
isStreamActive,
|
|
106
|
+
className
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
// Add more style renderers here as needed
|
|
110
|
+
// case 'unified':
|
|
111
|
+
// return <UnifiedDiffRenderer data={parsedData} ... />;
|
|
112
|
+
case "unknown":
|
|
113
|
+
default: {
|
|
114
|
+
const fallbackData = parsedData;
|
|
115
|
+
return /* @__PURE__ */ jsx(
|
|
116
|
+
CodeBlock,
|
|
117
|
+
{
|
|
118
|
+
showSource: true,
|
|
119
|
+
code: fallbackData?.search || fallbackData?.replace || "// Unknown diff format",
|
|
120
|
+
language: "diff",
|
|
121
|
+
showLineNumbers: true,
|
|
122
|
+
className
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
export {
|
|
129
|
+
StreamingDiffBlock
|
|
130
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diff Style Registry
|
|
3
|
+
*
|
|
4
|
+
* Extensible system for detecting and handling different diff formats
|
|
5
|
+
* Optimized for streaming content with partial detection
|
|
6
|
+
*/
|
|
7
|
+
import { DiffStyle, DiffStyleDetection, DiffStyleHandler } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Detect the style of diff from streaming content
|
|
10
|
+
* Optimized for partial content - returns best guess so far
|
|
11
|
+
*/
|
|
12
|
+
export declare function detectDiffStyle(content: string): DiffStyleDetection;
|
|
13
|
+
/**
|
|
14
|
+
* Get handler for a specific style
|
|
15
|
+
*/
|
|
16
|
+
export declare function getDiffStyleHandler(style: DiffStyle): DiffStyleHandler | null;
|
|
17
|
+
/**
|
|
18
|
+
* Quick check if content looks like any diff format
|
|
19
|
+
* Used to decide whether to use StreamingDiffBlock or regular code block
|
|
20
|
+
*/
|
|
21
|
+
export declare function looksLikeDiff(content: string): boolean;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const searchReplaceHandler = {
|
|
2
|
+
name: "search-replace",
|
|
3
|
+
canShowPartial: false,
|
|
4
|
+
// We buffer SEARCH, stream REPLACE
|
|
5
|
+
detect: (content) => {
|
|
6
|
+
const hasSearch = /SEARCH:/i.test(content);
|
|
7
|
+
const hasReplace = /REPLACE:/i.test(content);
|
|
8
|
+
const hasDelimiters = /<{1,3}/.test(content) && />{1,3}/.test(content);
|
|
9
|
+
let confidence = 0;
|
|
10
|
+
if (hasSearch) confidence += 0.4;
|
|
11
|
+
if (hasReplace) confidence += 0.4;
|
|
12
|
+
if (hasDelimiters) confidence += 0.2;
|
|
13
|
+
if (hasSearch && hasDelimiters) confidence = Math.max(confidence, 0.8);
|
|
14
|
+
return {
|
|
15
|
+
style: "search-replace",
|
|
16
|
+
confidence,
|
|
17
|
+
metadata: {
|
|
18
|
+
hasSearchKeyword: hasSearch,
|
|
19
|
+
hasReplaceKeyword: hasReplace,
|
|
20
|
+
hasDelimiters
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
parse: (content) => {
|
|
25
|
+
const searchMatch = content.match(/SEARCH:\s*\n\s*<<<\s*\n([\s\S]*?)(?:\n\s*>>>|$)/i);
|
|
26
|
+
const replaceMatch = content.match(/REPLACE:\s*\n\s*<<<\s*\n([\s\S]*?)(?:\n\s*>>>|$)/i);
|
|
27
|
+
const searchContent = searchMatch ? searchMatch[1] : "";
|
|
28
|
+
const replaceContent = replaceMatch ? replaceMatch[1] : "";
|
|
29
|
+
const searchComplete = !!content.match(/SEARCH:\s*\n\s*<<<\s*\n[\s\S]*?\n\s*>>>/i);
|
|
30
|
+
const replaceComplete = !!content.match(/REPLACE:\s*\n\s*<<<\s*\n[\s\S]*?\n\s*>>>/i);
|
|
31
|
+
return {
|
|
32
|
+
search: searchContent.trim(),
|
|
33
|
+
replace: replaceContent.trim(),
|
|
34
|
+
searchComplete,
|
|
35
|
+
replaceComplete,
|
|
36
|
+
isComplete: searchComplete && replaceComplete
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const unifiedDiffHandler = {
|
|
41
|
+
name: "unified",
|
|
42
|
+
canShowPartial: true,
|
|
43
|
+
// Can show line by line
|
|
44
|
+
detect: (content) => {
|
|
45
|
+
const hasDiffMarkers = /^[+-](?!--)/.test(content);
|
|
46
|
+
const hasMultipleMarkers = (content.match(/^[+-]/gm) || []).length > 1;
|
|
47
|
+
let confidence = 0;
|
|
48
|
+
if (hasDiffMarkers) confidence += 0.5;
|
|
49
|
+
if (hasMultipleMarkers) confidence += 0.3;
|
|
50
|
+
return {
|
|
51
|
+
style: "unified",
|
|
52
|
+
confidence,
|
|
53
|
+
metadata: {
|
|
54
|
+
hasDiffMarkers
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
parse: (content) => {
|
|
59
|
+
return { lines: content.split("\n") };
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const DIFF_STYLE_HANDLERS = [
|
|
63
|
+
searchReplaceHandler
|
|
64
|
+
// unifiedDiffHandler, // Add when ready
|
|
65
|
+
// Add more handlers here as needed
|
|
66
|
+
];
|
|
67
|
+
function detectDiffStyle(content) {
|
|
68
|
+
if (!content || content.trim().length < 5) {
|
|
69
|
+
return { style: "unknown", confidence: 0 };
|
|
70
|
+
}
|
|
71
|
+
let bestMatch = { style: "unknown", confidence: 0 };
|
|
72
|
+
for (const handler of DIFF_STYLE_HANDLERS) {
|
|
73
|
+
const detection = handler.detect(content);
|
|
74
|
+
if (detection.confidence > bestMatch.confidence) {
|
|
75
|
+
bestMatch = detection;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return bestMatch;
|
|
79
|
+
}
|
|
80
|
+
function getDiffStyleHandler(style) {
|
|
81
|
+
return DIFF_STYLE_HANDLERS.find((h) => h.name === style) || null;
|
|
82
|
+
}
|
|
83
|
+
function looksLikeDiff(content) {
|
|
84
|
+
if (!content || content.trim().length < 5) return false;
|
|
85
|
+
return /SEARCH:/i.test(content) || /^[+-](?!--)/m.test(content) || /^diff --git/m.test(content) || /<{2,3}.*>{2,3}/s.test(content);
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
detectDiffStyle,
|
|
89
|
+
getDiffStyleHandler,
|
|
90
|
+
looksLikeDiff
|
|
91
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SEARCH/REPLACE Diff Renderer
|
|
3
|
+
*
|
|
4
|
+
* Handles the streaming illusion for SEARCH/REPLACE blocks:
|
|
5
|
+
* 1. Buffer SEARCH silently (show loading)
|
|
6
|
+
* 2. Stream REPLACE as code
|
|
7
|
+
* 3. Switch to diff view when complete
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - Collapsed preview (4 lines) when complete
|
|
11
|
+
* - Diff statistics (+/- counts)
|
|
12
|
+
* - Smooth expand/collapse with fade effect
|
|
13
|
+
*/
|
|
14
|
+
import React from "react";
|
|
15
|
+
import type { SearchReplaceBlock } from "../types.js";
|
|
16
|
+
interface SearchReplaceDiffRendererProps {
|
|
17
|
+
data: SearchReplaceBlock;
|
|
18
|
+
language?: string;
|
|
19
|
+
isStreamActive?: boolean;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Efficiently render SEARCH/REPLACE diff with streaming support
|
|
24
|
+
*/
|
|
25
|
+
export declare const SearchReplaceDiffRenderer: React.FC<SearchReplaceDiffRendererProps>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
4
|
+
import { computeLineChanges } from "@ai-matrx/diff/text";
|
|
5
|
+
import { DiffView } from "../../../../utils/lifted/DiffView.js";
|
|
6
|
+
import CodeBlock from "../../../../code-block/CodeBlock.js";
|
|
7
|
+
import { DiffLoadingIndicator } from "../DiffLoadingIndicator.js";
|
|
8
|
+
import { DiffCollapsible } from "../DiffCollapsible.js";
|
|
9
|
+
import { GitCompare } from "lucide-react";
|
|
10
|
+
import { cn } from "@ai-matrx/design-system";
|
|
11
|
+
import { useThemeMode } from "../../../../host/app-bindings.js";
|
|
12
|
+
import { ShikiCodeView } from "../../../../code-block/highlight/ShikiCodeView.js";
|
|
13
|
+
const DiffPreview = ({ lines, language, maxLines = 4 }) => {
|
|
14
|
+
const mode = useThemeMode();
|
|
15
|
+
const previewLines = lines.slice(0, maxLines);
|
|
16
|
+
const getDiffLineStyle = (type) => {
|
|
17
|
+
if (type === "added") {
|
|
18
|
+
return mode === "dark" ? "bg-green-900/60 border-l-4 border-green-500" : "bg-green-100 border-l-4 border-green-600";
|
|
19
|
+
}
|
|
20
|
+
if (type === "removed") {
|
|
21
|
+
return mode === "dark" ? "bg-red-900/60 border-l-4 border-red-500" : "bg-red-100 border-l-4 border-red-600";
|
|
22
|
+
}
|
|
23
|
+
return mode === "dark" ? "bg-transparent" : "bg-transparent";
|
|
24
|
+
};
|
|
25
|
+
const getDiffLinePrefix = (type) => {
|
|
26
|
+
if (type === "added") return "+ ";
|
|
27
|
+
if (type === "removed") return "- ";
|
|
28
|
+
return " ";
|
|
29
|
+
};
|
|
30
|
+
const getDiffLinePrefixColor = (type) => {
|
|
31
|
+
if (type === "added") {
|
|
32
|
+
return mode === "dark" ? "text-green-400" : "text-green-700";
|
|
33
|
+
}
|
|
34
|
+
if (type === "removed") {
|
|
35
|
+
return mode === "dark" ? "text-red-400" : "text-red-700";
|
|
36
|
+
}
|
|
37
|
+
return mode === "dark" ? "text-gray-500" : "text-gray-600";
|
|
38
|
+
};
|
|
39
|
+
return /* @__PURE__ */ jsx(
|
|
40
|
+
"div",
|
|
41
|
+
{
|
|
42
|
+
className: cn(
|
|
43
|
+
"font-mono text-xs",
|
|
44
|
+
mode === "dark" ? "bg-zinc-900" : "bg-white"
|
|
45
|
+
),
|
|
46
|
+
children: previewLines.map((line, index) => /* @__PURE__ */ jsxs(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
className: cn("flex items-center", getDiffLineStyle(line.type)),
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ jsx(
|
|
52
|
+
"div",
|
|
53
|
+
{
|
|
54
|
+
className: cn(
|
|
55
|
+
"shrink-0 w-10 text-right pr-2 select-none",
|
|
56
|
+
mode === "dark" ? "text-gray-500" : "text-gray-400"
|
|
57
|
+
),
|
|
58
|
+
children: line.lineNumber
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
/* @__PURE__ */ jsx(
|
|
62
|
+
"div",
|
|
63
|
+
{
|
|
64
|
+
className: cn(
|
|
65
|
+
"shrink-0 w-4 select-none font-bold",
|
|
66
|
+
getDiffLinePrefixColor(line.type)
|
|
67
|
+
),
|
|
68
|
+
children: getDiffLinePrefix(line.type)
|
|
69
|
+
}
|
|
70
|
+
),
|
|
71
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 pr-2 overflow-x-auto", children: /* @__PURE__ */ jsx(
|
|
72
|
+
ShikiCodeView,
|
|
73
|
+
{
|
|
74
|
+
code: line.content || " ",
|
|
75
|
+
language,
|
|
76
|
+
mode: mode === "dark" ? "dark" : "light",
|
|
77
|
+
surface: "transparent",
|
|
78
|
+
padding: { y: 0, x: 0 },
|
|
79
|
+
wrapLines: false,
|
|
80
|
+
fontSize: 12
|
|
81
|
+
}
|
|
82
|
+
) })
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
index
|
|
86
|
+
))
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
const SearchReplaceDiffRenderer = ({ data, language = "typescript", isStreamActive = false, className }) => {
|
|
91
|
+
const { search, replace, searchComplete, replaceComplete, isComplete } = data;
|
|
92
|
+
const diffData = useMemo(() => {
|
|
93
|
+
if (!isComplete || !search || !replace) return null;
|
|
94
|
+
return computeLineChanges(search, replace);
|
|
95
|
+
}, [isComplete, search, replace]);
|
|
96
|
+
const streamScrollRef = useRef(null);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
const el = streamScrollRef.current;
|
|
99
|
+
if (el) {
|
|
100
|
+
el.scrollTop = el.scrollHeight;
|
|
101
|
+
}
|
|
102
|
+
}, [replace]);
|
|
103
|
+
if (!searchComplete) {
|
|
104
|
+
return /* @__PURE__ */ jsx(
|
|
105
|
+
"div",
|
|
106
|
+
{
|
|
107
|
+
className: cn(
|
|
108
|
+
"rounded-lg border border-neutral-200 dark:border-neutral-700 bg-muted/30",
|
|
109
|
+
className
|
|
110
|
+
),
|
|
111
|
+
children: /* @__PURE__ */ jsx(DiffLoadingIndicator, { message: "Analyzing code..." })
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
if (searchComplete && !replaceComplete) {
|
|
116
|
+
return /* @__PURE__ */ jsx("div", { className: cn("space-y-2", className), children: replace && /* @__PURE__ */ jsx(
|
|
117
|
+
"div",
|
|
118
|
+
{
|
|
119
|
+
ref: streamScrollRef,
|
|
120
|
+
className: "max-h-[140px] overflow-y-auto",
|
|
121
|
+
children: /* @__PURE__ */ jsx(
|
|
122
|
+
CodeBlock,
|
|
123
|
+
{
|
|
124
|
+
showSource: true,
|
|
125
|
+
code: replace,
|
|
126
|
+
language,
|
|
127
|
+
showLineNumbers: true,
|
|
128
|
+
isStreamActive
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
) });
|
|
133
|
+
}
|
|
134
|
+
if (diffData) {
|
|
135
|
+
return /* @__PURE__ */ jsx(
|
|
136
|
+
DiffCollapsible,
|
|
137
|
+
{
|
|
138
|
+
icon: /* @__PURE__ */ jsx(GitCompare, { className: "h-3.5 w-3.5 text-emerald-500" }),
|
|
139
|
+
title: "Code Updates",
|
|
140
|
+
initialOpen: false,
|
|
141
|
+
className,
|
|
142
|
+
additions: diffData.additions,
|
|
143
|
+
deletions: diffData.deletions,
|
|
144
|
+
showPreview: true,
|
|
145
|
+
previewContent: /* @__PURE__ */ jsx(
|
|
146
|
+
DiffPreview,
|
|
147
|
+
{
|
|
148
|
+
lines: diffData.lines,
|
|
149
|
+
language,
|
|
150
|
+
maxLines: 4
|
|
151
|
+
}
|
|
152
|
+
),
|
|
153
|
+
children: /* @__PURE__ */ jsx(
|
|
154
|
+
DiffView,
|
|
155
|
+
{
|
|
156
|
+
originalCode: search,
|
|
157
|
+
modifiedCode: replace,
|
|
158
|
+
language,
|
|
159
|
+
showLineNumbers: true
|
|
160
|
+
}
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
return /* @__PURE__ */ jsx(
|
|
166
|
+
"div",
|
|
167
|
+
{
|
|
168
|
+
className: cn(
|
|
169
|
+
"rounded-lg border border-neutral-200 dark:border-neutral-700",
|
|
170
|
+
className
|
|
171
|
+
),
|
|
172
|
+
children: /* @__PURE__ */ jsx(
|
|
173
|
+
CodeBlock,
|
|
174
|
+
{
|
|
175
|
+
showSource: true,
|
|
176
|
+
code: replace || search || "// No content",
|
|
177
|
+
language,
|
|
178
|
+
showLineNumbers: true
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
export {
|
|
185
|
+
SearchReplaceDiffRenderer
|
|
186
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming Diff Block Types
|
|
3
|
+
*
|
|
4
|
+
* Defines types for different streaming diff styles and their states
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Different styles of diffs we support
|
|
8
|
+
*/
|
|
9
|
+
export type DiffStyle = 'search-replace' | 'unified' | 'git' | 'inline' | 'unknown';
|
|
10
|
+
/**
|
|
11
|
+
* Streaming state for diff rendering
|
|
12
|
+
*/
|
|
13
|
+
export type StreamingDiffState = 'detecting' | 'buffering' | 'streaming' | 'complete' | 'fallback';
|
|
14
|
+
/**
|
|
15
|
+
* Parsed SEARCH/REPLACE block (streaming-aware — tracks per-block completion)
|
|
16
|
+
*/
|
|
17
|
+
export interface SearchReplaceBlock {
|
|
18
|
+
search: string;
|
|
19
|
+
replace: string;
|
|
20
|
+
searchComplete: boolean;
|
|
21
|
+
replaceComplete: boolean;
|
|
22
|
+
isComplete: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Parsed unified diff (line-based) block
|
|
26
|
+
*/
|
|
27
|
+
export interface UnifiedDiffBlock {
|
|
28
|
+
lines: string[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Union of every shape a diff style handler's parse() can return.
|
|
32
|
+
* Extend this when a new DiffStyleHandler is added.
|
|
33
|
+
*/
|
|
34
|
+
export type ParsedDiffBlock = SearchReplaceBlock | UnifiedDiffBlock;
|
|
35
|
+
/**
|
|
36
|
+
* Result of diff style detection
|
|
37
|
+
*/
|
|
38
|
+
export interface DiffStyleDetection {
|
|
39
|
+
style: DiffStyle;
|
|
40
|
+
confidence: number;
|
|
41
|
+
metadata?: {
|
|
42
|
+
hasSearchKeyword?: boolean;
|
|
43
|
+
hasReplaceKeyword?: boolean;
|
|
44
|
+
hasDelimiters?: boolean;
|
|
45
|
+
hasDiffMarkers?: boolean;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Configuration for a diff style handler
|
|
50
|
+
*/
|
|
51
|
+
export interface DiffStyleHandler {
|
|
52
|
+
name: string;
|
|
53
|
+
detect: (content: string) => DiffStyleDetection;
|
|
54
|
+
parse: (content: string) => ParsedDiffBlock;
|
|
55
|
+
canShowPartial: boolean;
|
|
56
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { RenderBlock } from "../block-registry/BlockRenderer.js";
|
|
3
|
+
interface BlockFallbackProps {
|
|
4
|
+
block: RenderBlock;
|
|
5
|
+
isStreamActive?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Tiered fallback for a block whose rich renderer crashed.
|
|
9
|
+
*
|
|
10
|
+
* Ladder (each rung guarded by its own boundary):
|
|
11
|
+
* structured renderer (already failed, handled by the caller)
|
|
12
|
+
* → pretty JSON / code block
|
|
13
|
+
* → plain text <pre>
|
|
14
|
+
*
|
|
15
|
+
* This replaces the old "dump raw content in a yellow warning box" behavior so
|
|
16
|
+
* a `presentation` / `quiz` / `diagram` / code block that fails to render still
|
|
17
|
+
* shows readable JSON (or code) instead of an ugly crash banner.
|
|
18
|
+
*/
|
|
19
|
+
export declare const BlockFallback: React.FC<BlockFallbackProps>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Suspense, lazy } from "react";
|
|
4
|
+
import { MarkdownErrorBoundary } from "./MarkdownErrorBoundary.js";
|
|
5
|
+
import {
|
|
6
|
+
isKindJsonText,
|
|
7
|
+
rootKindSlug,
|
|
8
|
+
valueCarriesKind
|
|
9
|
+
} from "@ai-matrx/content-ir/surfaces";
|
|
10
|
+
const CodeBlock = lazy(
|
|
11
|
+
() => import("../../../code-block/CodeBlock.js")
|
|
12
|
+
);
|
|
13
|
+
const StructuredValueView = lazy(
|
|
14
|
+
() => import("../../../host/app-bindings.js").then((m) => ({ default: m.StructuredValueView }))
|
|
15
|
+
);
|
|
16
|
+
const PlainTextFallback = ({ content }) => /* @__PURE__ */ jsx("pre", { className: "my-2 px-3 py-2 text-sm text-neutral-700 dark:text-neutral-300 whitespace-pre-wrap break-words rounded-md border border-neutral-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-900/40 overflow-x-auto", children: content || "[empty block]" });
|
|
17
|
+
function tryPrettyJson(content) {
|
|
18
|
+
const trimmed = content.trim();
|
|
19
|
+
if (!trimmed) return null;
|
|
20
|
+
const first = trimmed[0];
|
|
21
|
+
if (first !== "{" && first !== "[") return null;
|
|
22
|
+
try {
|
|
23
|
+
const parsed = JSON.parse(trimmed);
|
|
24
|
+
if (parsed && typeof parsed === "object") {
|
|
25
|
+
return JSON.stringify(parsed, null, 2);
|
|
26
|
+
}
|
|
27
|
+
} catch {
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
function resolveCodeFallback(block) {
|
|
32
|
+
const content = block.content ?? "";
|
|
33
|
+
const pretty = tryPrettyJson(content);
|
|
34
|
+
if (pretty !== null) {
|
|
35
|
+
return { code: pretty, language: "json" };
|
|
36
|
+
}
|
|
37
|
+
if (block.language === "json" || block.language === "yaml") {
|
|
38
|
+
return { code: content, language: block.language };
|
|
39
|
+
}
|
|
40
|
+
return { code: content, language: block.language || "" };
|
|
41
|
+
}
|
|
42
|
+
function crashedKindValue(block, isStreamActive) {
|
|
43
|
+
if (isStreamActive) return null;
|
|
44
|
+
const content = (block.content ?? "").trim();
|
|
45
|
+
if (!isKindJsonText(content)) return null;
|
|
46
|
+
try {
|
|
47
|
+
const value = JSON.parse(content);
|
|
48
|
+
if (!valueCarriesKind(value)) return null;
|
|
49
|
+
return { value, slug: rootKindSlug(value) };
|
|
50
|
+
} catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const BlockFallback = ({
|
|
55
|
+
block,
|
|
56
|
+
isStreamActive
|
|
57
|
+
}) => {
|
|
58
|
+
const { code, language } = resolveCodeFallback(block);
|
|
59
|
+
const crashedKind = crashedKindValue(block, isStreamActive);
|
|
60
|
+
if (crashedKind) {
|
|
61
|
+
return /* @__PURE__ */ jsx(MarkdownErrorBoundary, { fallback: /* @__PURE__ */ jsx(PlainTextFallback, { content: code }), children: /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx("div", { className: "my-3", children: /* @__PURE__ */ jsx(
|
|
62
|
+
StructuredValueView,
|
|
63
|
+
{
|
|
64
|
+
value: crashedKind.value,
|
|
65
|
+
kind: crashedKind.slug ?? void 0,
|
|
66
|
+
note: "its view hit an error"
|
|
67
|
+
}
|
|
68
|
+
) }) }) });
|
|
69
|
+
}
|
|
70
|
+
return /* @__PURE__ */ jsx(MarkdownErrorBoundary, { fallback: /* @__PURE__ */ jsx(PlainTextFallback, { content: code }), children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(PlainTextFallback, { content: code }), children: /* @__PURE__ */ jsx(
|
|
71
|
+
CodeBlock,
|
|
72
|
+
{
|
|
73
|
+
code,
|
|
74
|
+
language: language || "text",
|
|
75
|
+
fontSize: 14,
|
|
76
|
+
className: "my-3",
|
|
77
|
+
isStreamActive
|
|
78
|
+
}
|
|
79
|
+
) }) });
|
|
80
|
+
};
|
|
81
|
+
export {
|
|
82
|
+
BlockFallback
|
|
83
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
const InlineStatusIndicator = ({
|
|
3
|
+
label
|
|
4
|
+
}) => /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 py-2", children: /* @__PURE__ */ jsx(
|
|
5
|
+
"span",
|
|
6
|
+
{
|
|
7
|
+
className: "inline-block text-sm bg-clip-text text-transparent bg-[length:200%_100%] animate-shimmer",
|
|
8
|
+
style: {
|
|
9
|
+
backgroundImage: "linear-gradient(90deg, hsl(var(--muted-foreground) / 0.3) 0%, hsl(var(--foreground)) 50%, hsl(var(--muted-foreground) / 0.3) 100%)"
|
|
10
|
+
},
|
|
11
|
+
children: label
|
|
12
|
+
}
|
|
13
|
+
) });
|
|
14
|
+
export {
|
|
15
|
+
InlineStatusIndicator
|
|
16
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { ErrorInfo } from "react";
|
|
2
|
+
interface MarkdownErrorBoundaryProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
fallback: React.ReactNode;
|
|
5
|
+
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare class MarkdownErrorBoundary extends React.Component<MarkdownErrorBoundaryProps, {
|
|
8
|
+
hasError: boolean;
|
|
9
|
+
}> {
|
|
10
|
+
constructor(props: MarkdownErrorBoundaryProps);
|
|
11
|
+
static getDerivedStateFromError(_: Error): {
|
|
12
|
+
hasError: boolean;
|
|
13
|
+
};
|
|
14
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
15
|
+
render(): React.ReactNode;
|
|
16
|
+
}
|
|
17
|
+
export {};
|