@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,163 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useClipboard } from "@ai-matrx/kit/clipboard";
|
|
4
|
+
import { toast } from "../../../host/toast.js";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { cn } from "@ai-matrx/design-system";
|
|
7
|
+
import { Copy, Check } from "lucide-react";
|
|
8
|
+
import { useCanvasPresentation } from "@ai-matrx/canvas/react";
|
|
9
|
+
import { treeWrapsLines } from "../canvas-adaptive.js";
|
|
10
|
+
import { Button } from "@ai-matrx/design-system/controls";
|
|
11
|
+
const CONNECTORS = [
|
|
12
|
+
"\u251C\u2500",
|
|
13
|
+
"\u2514\u2500",
|
|
14
|
+
"\u2502",
|
|
15
|
+
"\u251C\u2500\u2500",
|
|
16
|
+
"\u2514\u2500\u2500",
|
|
17
|
+
"\u251C\u2500 ",
|
|
18
|
+
"\u2514\u2500 ",
|
|
19
|
+
"+--",
|
|
20
|
+
"|--",
|
|
21
|
+
"| ",
|
|
22
|
+
"+- ",
|
|
23
|
+
"|- "
|
|
24
|
+
];
|
|
25
|
+
const ARROW = /\s*[→➜➔\->]+\s*/;
|
|
26
|
+
function parseTreeLines(content) {
|
|
27
|
+
return content.split("\n").map((line) => {
|
|
28
|
+
if (!line.trim()) {
|
|
29
|
+
return {
|
|
30
|
+
text: line,
|
|
31
|
+
depth: 0,
|
|
32
|
+
connector: "",
|
|
33
|
+
label: line,
|
|
34
|
+
hasHighlight: false
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
let depth = 0;
|
|
38
|
+
let pos = 0;
|
|
39
|
+
let connector = "";
|
|
40
|
+
while (pos < line.length) {
|
|
41
|
+
const rest = line.slice(pos);
|
|
42
|
+
let foundConnector = false;
|
|
43
|
+
for (const c of CONNECTORS) {
|
|
44
|
+
if (rest.startsWith(c)) {
|
|
45
|
+
if (c === "\u2502" || c === "| " || c === "|") {
|
|
46
|
+
depth++;
|
|
47
|
+
pos += c.length;
|
|
48
|
+
foundConnector = true;
|
|
49
|
+
break;
|
|
50
|
+
} else {
|
|
51
|
+
connector = c;
|
|
52
|
+
pos += c.length;
|
|
53
|
+
foundConnector = true;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!foundConnector) {
|
|
59
|
+
if (rest[0] === " " || rest[0] === " ") {
|
|
60
|
+
pos++;
|
|
61
|
+
} else {
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (connector) break;
|
|
66
|
+
}
|
|
67
|
+
const label = line.slice(pos).trim();
|
|
68
|
+
const arrowMatch = label.match(ARROW);
|
|
69
|
+
let hasHighlight = false;
|
|
70
|
+
let highlightText;
|
|
71
|
+
if (arrowMatch) {
|
|
72
|
+
const afterArrow = label.slice(arrowMatch.index + arrowMatch[0].length).trim();
|
|
73
|
+
if (afterArrow.startsWith("**") && afterArrow.endsWith("**")) {
|
|
74
|
+
hasHighlight = true;
|
|
75
|
+
highlightText = afterArrow.slice(2, -2);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return { text: line, depth, connector, label, hasHighlight, highlightText };
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const DEPTH_COLORS = [
|
|
82
|
+
"text-blue-500 dark:text-blue-400",
|
|
83
|
+
"text-green-500 dark:text-green-400",
|
|
84
|
+
"text-amber-500 dark:text-amber-400",
|
|
85
|
+
"text-purple-500 dark:text-purple-400",
|
|
86
|
+
"text-cyan-500 dark:text-cyan-400",
|
|
87
|
+
"text-rose-500 dark:text-rose-400"
|
|
88
|
+
];
|
|
89
|
+
const TreeBlock = ({ content, className }) => {
|
|
90
|
+
const { copyText } = useClipboard({
|
|
91
|
+
notify: (message, kind) => kind === "error" ? toast.error(message) : toast.success(message)
|
|
92
|
+
});
|
|
93
|
+
const [copied, setCopied] = useState(false);
|
|
94
|
+
const lines = parseTreeLines(content);
|
|
95
|
+
const wrap = treeWrapsLines(useCanvasPresentation());
|
|
96
|
+
const handleCopy = async () => {
|
|
97
|
+
await copyText(content);
|
|
98
|
+
setCopied(true);
|
|
99
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
100
|
+
};
|
|
101
|
+
return /* @__PURE__ */ jsxs(
|
|
102
|
+
"div",
|
|
103
|
+
{
|
|
104
|
+
className: cn(
|
|
105
|
+
"my-3 rounded-lg border border-border bg-card overflow-hidden",
|
|
106
|
+
className
|
|
107
|
+
),
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-3 py-1.5 border-b border-border/50 bg-muted/30", children: [
|
|
110
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-mono font-semibold text-teal-600 dark:text-teal-400", children: "Tree" }),
|
|
111
|
+
/* @__PURE__ */ jsx(Button, { variant: "quiet", icon: copied ? /* @__PURE__ */ jsx(Check, {}) : /* @__PURE__ */ jsx(Copy, {}), glyphTone: copied ? "success" : void 0, onClick: handleCopy, "aria-label": "Copy" })
|
|
112
|
+
] }),
|
|
113
|
+
/* @__PURE__ */ jsx(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
"data-tree-wrap": wrap ? "wrap" : "scroll",
|
|
117
|
+
className: cn(
|
|
118
|
+
"px-4 py-3 font-mono text-sm leading-relaxed",
|
|
119
|
+
wrap ? "overflow-x-hidden" : "overflow-x-auto"
|
|
120
|
+
),
|
|
121
|
+
children: lines.map((line, idx) => {
|
|
122
|
+
if (!line.text.trim()) {
|
|
123
|
+
return /* @__PURE__ */ jsx("div", { className: "h-2" }, idx);
|
|
124
|
+
}
|
|
125
|
+
const depthColor = DEPTH_COLORS[line.depth % DEPTH_COLORS.length];
|
|
126
|
+
const raw = line.text;
|
|
127
|
+
const labelStart = raw.indexOf(line.label);
|
|
128
|
+
if (labelStart <= 0) {
|
|
129
|
+
return /* @__PURE__ */ jsx("div", { className: "text-foreground font-semibold", children: line.label }, idx);
|
|
130
|
+
}
|
|
131
|
+
const prefix = raw.slice(0, labelStart);
|
|
132
|
+
const arrowMatch = line.label.match(ARROW);
|
|
133
|
+
return /* @__PURE__ */ jsxs(
|
|
134
|
+
"div",
|
|
135
|
+
{
|
|
136
|
+
className: cn(
|
|
137
|
+
"hover:bg-muted/20 rounded-sm transition-colors",
|
|
138
|
+
wrap ? "whitespace-pre-wrap break-words [overflow-wrap:anywhere]" : "whitespace-pre"
|
|
139
|
+
),
|
|
140
|
+
children: [
|
|
141
|
+
/* @__PURE__ */ jsx("span", { className: cn("select-none", depthColor), children: prefix }),
|
|
142
|
+
arrowMatch ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
143
|
+
/* @__PURE__ */ jsx("span", { className: "text-foreground", children: line.label.slice(0, arrowMatch.index) }),
|
|
144
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: arrowMatch[0] }),
|
|
145
|
+
line.hasHighlight && line.highlightText ? /* @__PURE__ */ jsx("span", { className: "font-semibold text-primary-ink bg-primary/10 px-1 rounded", children: line.highlightText }) : /* @__PURE__ */ jsx("span", { className: "text-foreground", children: line.label.slice(
|
|
146
|
+
arrowMatch.index + arrowMatch[0].length
|
|
147
|
+
) })
|
|
148
|
+
] }) : /* @__PURE__ */ jsx("span", { className: "text-foreground", children: line.label })
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
idx
|
|
152
|
+
);
|
|
153
|
+
})
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
};
|
|
160
|
+
var TreeBlock_default = TreeBlock;
|
|
161
|
+
export {
|
|
162
|
+
TreeBlock_default as default
|
|
163
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface XmlBlockProps {
|
|
3
|
+
content: string;
|
|
4
|
+
language?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Prose segments ALREADY RENDERED by a static root (server level / SSR'd
|
|
8
|
+
* share leaf), keyed by token index from the shared tokenizer
|
|
9
|
+
* (xml-tokenize.ts), so a card's text is in the server HTML. Missing keys
|
|
10
|
+
* render client-side through NestedRichContent, as before.
|
|
11
|
+
*/
|
|
12
|
+
renderedProse?: Record<number, React.ReactNode>;
|
|
13
|
+
/**
|
|
14
|
+
* Whether this card SHOWS SOURCE — a ```xml fence, the model quoting source
|
|
15
|
+
* (ruling (a)): a kind in its prose stays as written. False for an XML TAG
|
|
16
|
+
* the model wrapped content in (`isQuotedSourceXmlBlock`, ruling (b)): its
|
|
17
|
+
* prose is data and a kind there renders as the kind. Default true — a
|
|
18
|
+
* caller that cannot tell keeps the source view.
|
|
19
|
+
*/
|
|
20
|
+
quotedSource?: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare const XmlBlock: React.FC<XmlBlockProps>;
|
|
23
|
+
export default XmlBlock;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useClipboard } from "@ai-matrx/kit/clipboard";
|
|
4
|
+
import { toast } from "../../../host/toast.js";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { ChevronRight, ChevronDown, Copy, Check } from "lucide-react";
|
|
7
|
+
import { NestedRichContent } from "../../../levels/standard/NestedRichContent.js";
|
|
8
|
+
import { KindSourceView } from "../../chat-markdown/KindTextGate.js";
|
|
9
|
+
import { cn } from "@ai-matrx/design-system";
|
|
10
|
+
import { tokenizeXml } from "./xml-tokenize.js";
|
|
11
|
+
import { useMarkdownStreaming } from "../../../markdown-core/streaming-context.js";
|
|
12
|
+
import { Button } from "@ai-matrx/design-system/controls";
|
|
13
|
+
function renderAttributes(attrs) {
|
|
14
|
+
return attrs.map((attr, i) => /* @__PURE__ */ jsxs("span", { children: [
|
|
15
|
+
" ",
|
|
16
|
+
/* @__PURE__ */ jsx("span", { className: "text-amber-600 dark:text-amber-400", children: attr.name }),
|
|
17
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "=" }),
|
|
18
|
+
/* @__PURE__ */ jsxs("span", { className: "text-green-600 dark:text-green-400", children: [
|
|
19
|
+
'"',
|
|
20
|
+
attr.value,
|
|
21
|
+
'"'
|
|
22
|
+
] })
|
|
23
|
+
] }, i));
|
|
24
|
+
}
|
|
25
|
+
const XmlBlock = ({
|
|
26
|
+
content,
|
|
27
|
+
language = "xml",
|
|
28
|
+
className,
|
|
29
|
+
renderedProse,
|
|
30
|
+
quotedSource = true
|
|
31
|
+
}) => {
|
|
32
|
+
const { copyText } = useClipboard({
|
|
33
|
+
notify: (message, kind) => kind === "error" ? toast.error(message) : toast.success(message)
|
|
34
|
+
});
|
|
35
|
+
const [copied, setCopied] = useState(false);
|
|
36
|
+
const [collapsed, setCollapsed] = useState(/* @__PURE__ */ new Set());
|
|
37
|
+
const [cardCollapsed, setCardCollapsed] = useState(false);
|
|
38
|
+
const tokens = tokenizeXml(content);
|
|
39
|
+
const isStreaming = useMarkdownStreaming();
|
|
40
|
+
const handleCopy = async () => {
|
|
41
|
+
await copyText(content);
|
|
42
|
+
setCopied(true);
|
|
43
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
44
|
+
};
|
|
45
|
+
const toggleCollapse = (idx) => {
|
|
46
|
+
setCollapsed((prev) => {
|
|
47
|
+
const next = new Set(prev);
|
|
48
|
+
if (next.has(idx)) next.delete(idx);
|
|
49
|
+
else next.add(idx);
|
|
50
|
+
return next;
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const findMatchingClose = (openIdx) => {
|
|
54
|
+
const openToken = tokens[openIdx];
|
|
55
|
+
if (openToken.type !== "open" || !openToken.tagName) return null;
|
|
56
|
+
let depth = 1;
|
|
57
|
+
for (let j = openIdx + 1; j < tokens.length; j++) {
|
|
58
|
+
const t = tokens[j];
|
|
59
|
+
if (t.type === "open" && t.tagName === openToken.tagName) depth++;
|
|
60
|
+
if (t.type === "close" && t.tagName === openToken.tagName) {
|
|
61
|
+
depth--;
|
|
62
|
+
if (depth === 0) return j;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
};
|
|
67
|
+
const rootOpenIndex = tokens.findIndex(
|
|
68
|
+
(token) => token.type === "open" || token.type === "selfClose"
|
|
69
|
+
);
|
|
70
|
+
const rootCloseIndex = rootOpenIndex === -1 ? null : findMatchingClose(rootOpenIndex);
|
|
71
|
+
const rootTagName = rootOpenIndex === -1 ? void 0 : tokens[rootOpenIndex]?.tagName;
|
|
72
|
+
const hasCardBody = tokens.some(
|
|
73
|
+
(_, idx) => idx !== rootOpenIndex && idx !== rootCloseIndex
|
|
74
|
+
);
|
|
75
|
+
const hiddenRanges = /* @__PURE__ */ new Set();
|
|
76
|
+
for (const idx of collapsed) {
|
|
77
|
+
const end = findMatchingClose(idx);
|
|
78
|
+
for (let j = idx + 1; j < (end ?? tokens.length); j++) {
|
|
79
|
+
hiddenRanges.add(j);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (!tokens.some((token) => token.type !== "markdown")) {
|
|
83
|
+
if (isStreaming) return null;
|
|
84
|
+
return /* @__PURE__ */ jsx(
|
|
85
|
+
"div",
|
|
86
|
+
{
|
|
87
|
+
"data-xml-fragment": true,
|
|
88
|
+
className: cn("my-2 whitespace-pre-wrap break-words", className),
|
|
89
|
+
children: content
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
return /* @__PURE__ */ jsxs(
|
|
94
|
+
"div",
|
|
95
|
+
{
|
|
96
|
+
className: cn(
|
|
97
|
+
"my-3 rounded-lg border border-border bg-card overflow-hidden",
|
|
98
|
+
className
|
|
99
|
+
),
|
|
100
|
+
children: [
|
|
101
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-3 py-1.5 border-b border-border/50 bg-muted/30", children: [
|
|
102
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
103
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-mono font-semibold text-orange-600 dark:text-orange-400", children: language.toUpperCase() }),
|
|
104
|
+
rootTagName ? hasCardBody ? /* @__PURE__ */ jsx(Button, { variant: "quiet", icon: cardCollapsed ? /* @__PURE__ */ jsx(ChevronRight, {}) : /* @__PURE__ */ jsx(ChevronDown, {}), "aria-label": `${cardCollapsed ? "Expand" : "Collapse"} ${rootTagName}`, "aria-expanded": !cardCollapsed, onClick: () => setCardCollapsed((previous) => !previous), className: "size-11 min-w-0 lg:size-auto", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: rootTagName }) }) : /* @__PURE__ */ jsx(
|
|
105
|
+
"span",
|
|
106
|
+
{
|
|
107
|
+
"data-xml-root-name": true,
|
|
108
|
+
className: "truncate font-mono text-sm text-blue-600 dark:text-blue-400",
|
|
109
|
+
children: rootTagName
|
|
110
|
+
}
|
|
111
|
+
) : null
|
|
112
|
+
] }),
|
|
113
|
+
/* @__PURE__ */ jsx(Button, { variant: "quiet", icon: copied ? /* @__PURE__ */ jsx(Check, {}) : /* @__PURE__ */ jsx(Copy, {}), glyphTone: copied ? "success" : void 0, "aria-label": "Copy XML", onClick: handleCopy, className: "size-11 lg:size-auto" })
|
|
114
|
+
] }),
|
|
115
|
+
!cardCollapsed && /* @__PURE__ */ jsx(
|
|
116
|
+
"div",
|
|
117
|
+
{
|
|
118
|
+
"data-xml-card-body": true,
|
|
119
|
+
className: "px-3 py-2 font-mono text-sm leading-relaxed overflow-x-auto",
|
|
120
|
+
children: tokens.map((token, idx) => {
|
|
121
|
+
if (idx === rootOpenIndex || idx === rootCloseIndex) return null;
|
|
122
|
+
if (hiddenRanges.has(idx)) return null;
|
|
123
|
+
const style = { paddingLeft: token.indent * 8 };
|
|
124
|
+
if (token.type === "markdown" && !token.text?.trim()) {
|
|
125
|
+
return /* @__PURE__ */ jsx("div", { className: "h-3" }, idx);
|
|
126
|
+
}
|
|
127
|
+
if (token.type === "comment") {
|
|
128
|
+
return /* @__PURE__ */ jsx(
|
|
129
|
+
"div",
|
|
130
|
+
{
|
|
131
|
+
className: "text-muted-foreground italic",
|
|
132
|
+
style,
|
|
133
|
+
children: token.text
|
|
134
|
+
},
|
|
135
|
+
idx
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
if (token.type === "declaration" || token.type === "cdata") {
|
|
139
|
+
return /* @__PURE__ */ jsx("div", { className: "text-muted-foreground", style, children: token.text }, idx);
|
|
140
|
+
}
|
|
141
|
+
if (token.type === "markdown") {
|
|
142
|
+
return /* @__PURE__ */ jsx(
|
|
143
|
+
"div",
|
|
144
|
+
{
|
|
145
|
+
className: "xml-markdown-content prose prose-sm max-w-none overflow-x-auto font-sans text-foreground dark:prose-invert",
|
|
146
|
+
style,
|
|
147
|
+
children: renderedProse && idx in renderedProse && !isStreaming ? renderedProse[idx] : quotedSource ? /* @__PURE__ */ jsx(KindSourceView, { children: /* @__PURE__ */ jsx(NestedRichContent, { source: token.text ?? "" }) }) : /* @__PURE__ */ jsx(NestedRichContent, { source: token.text ?? "", isStreaming })
|
|
148
|
+
},
|
|
149
|
+
idx
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
if (token.type === "close") {
|
|
153
|
+
return /* @__PURE__ */ jsxs("div", { style, children: [
|
|
154
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "</" }),
|
|
155
|
+
/* @__PURE__ */ jsx("span", { className: "text-red-600 dark:text-red-400", children: token.tagName }),
|
|
156
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: ">" })
|
|
157
|
+
] }, idx);
|
|
158
|
+
}
|
|
159
|
+
if (token.type === "selfClose") {
|
|
160
|
+
return /* @__PURE__ */ jsxs("div", { style, children: [
|
|
161
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "<" }),
|
|
162
|
+
/* @__PURE__ */ jsx("span", { className: "text-blue-600 dark:text-blue-400", children: token.tagName }),
|
|
163
|
+
token.attributes && renderAttributes(token.attributes),
|
|
164
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: " />" })
|
|
165
|
+
] }, idx);
|
|
166
|
+
}
|
|
167
|
+
const isCollapsed = collapsed.has(idx);
|
|
168
|
+
const hasChildren = idx + 1 < tokens.length && tokens[idx + 1].type !== "close";
|
|
169
|
+
return /* @__PURE__ */ jsxs(
|
|
170
|
+
"div",
|
|
171
|
+
{
|
|
172
|
+
className: "flex items-start group/line hover:bg-muted/30 rounded-sm -mx-1 px-1",
|
|
173
|
+
style,
|
|
174
|
+
children: [
|
|
175
|
+
hasChildren ? /* @__PURE__ */ jsx(Button, { variant: "quiet", icon: isCollapsed ? /* @__PURE__ */ jsx(ChevronRight, {}) : /* @__PURE__ */ jsx(ChevronDown, {}), "aria-label": `${isCollapsed ? "Expand" : "Collapse"} ${token.tagName}`, onClick: () => toggleCollapse(idx), className: "mr-1 size-11 lg:mt-0.5 lg:size-auto" }) : /* @__PURE__ */ jsx("span", { className: "w-[18px] flex-shrink-0" }),
|
|
176
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
177
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "<" }),
|
|
178
|
+
/* @__PURE__ */ jsx("span", { className: "text-blue-600 dark:text-blue-400", children: token.tagName }),
|
|
179
|
+
token.attributes && renderAttributes(token.attributes),
|
|
180
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: ">" }),
|
|
181
|
+
isCollapsed && /* @__PURE__ */ jsx("span", { className: "ml-1 text-xs text-muted-foreground bg-muted px-1.5 py-0.5 rounded", children: "..." })
|
|
182
|
+
] })
|
|
183
|
+
]
|
|
184
|
+
},
|
|
185
|
+
idx
|
|
186
|
+
);
|
|
187
|
+
})
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
);
|
|
193
|
+
};
|
|
194
|
+
var XmlBlock_default = XmlBlock;
|
|
195
|
+
export {
|
|
196
|
+
XmlBlock_default as default
|
|
197
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@ai-matrx/content-ir/source";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@ai-matrx/content-ir/source";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface XmlToken {
|
|
2
|
+
type: "open" | "close" | "selfClose" | "markdown" | "comment" | "declaration" | "cdata";
|
|
3
|
+
tagName?: string;
|
|
4
|
+
attributes?: Array<{
|
|
5
|
+
name: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}>;
|
|
8
|
+
text?: string;
|
|
9
|
+
raw: string;
|
|
10
|
+
indent: number;
|
|
11
|
+
}
|
|
12
|
+
/** Lex XML chrome without parsing or executing the text between tags. */
|
|
13
|
+
export declare function tokenizeXml(content: string): XmlToken[];
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { readXmlTag } from "./readXmlTag.js";
|
|
2
|
+
function indentAt(content, offset) {
|
|
3
|
+
const lineStart = content.lastIndexOf("\n", offset - 1) + 1;
|
|
4
|
+
return content.slice(lineStart, offset).search(/\S|$/);
|
|
5
|
+
}
|
|
6
|
+
function fenceAtLineStart(content, offset) {
|
|
7
|
+
if (offset !== 0 && content[offset - 1] !== "\n") return null;
|
|
8
|
+
let markerStart = offset;
|
|
9
|
+
while (content[markerStart] === " " || content[markerStart] === " ")
|
|
10
|
+
markerStart++;
|
|
11
|
+
const markerCharacter = content[markerStart];
|
|
12
|
+
if (markerCharacter !== "`" && markerCharacter !== "~") return null;
|
|
13
|
+
let markerEnd = markerStart;
|
|
14
|
+
while (content[markerEnd] === markerCharacter) markerEnd++;
|
|
15
|
+
if (markerEnd - markerStart < 3) return null;
|
|
16
|
+
const lineEnd = content.indexOf("\n", markerEnd);
|
|
17
|
+
return {
|
|
18
|
+
marker: content.slice(markerStart, markerEnd),
|
|
19
|
+
contentStart: lineEnd === -1 ? content.length : lineEnd + 1
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function fenceEnd(content, start, marker) {
|
|
23
|
+
const closing = new RegExp(
|
|
24
|
+
`^[ \\t]*${marker[0]}{${marker.length},}[ \\t]*(?:\\n|$)`,
|
|
25
|
+
"m"
|
|
26
|
+
);
|
|
27
|
+
const match = closing.exec(content.slice(start));
|
|
28
|
+
return match ? start + match.index + match[0].length : content.length;
|
|
29
|
+
}
|
|
30
|
+
function normalizeMarkdownIndentation(raw) {
|
|
31
|
+
const lines = raw.split("\n");
|
|
32
|
+
let indent;
|
|
33
|
+
for (const line of lines) {
|
|
34
|
+
if (!line.trim()) continue;
|
|
35
|
+
const current = line.match(/^[ \t]*/)?.[0].length ?? 0;
|
|
36
|
+
indent = indent === void 0 ? current : Math.min(indent, current);
|
|
37
|
+
}
|
|
38
|
+
const resolvedIndent = indent ?? 0;
|
|
39
|
+
if (!resolvedIndent) return { text: raw, indent: 0 };
|
|
40
|
+
return {
|
|
41
|
+
text: lines.map((line) => line.slice(resolvedIndent)).join("\n"),
|
|
42
|
+
indent: resolvedIndent
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function isEscaped(content, offset) {
|
|
46
|
+
let slashCount = 0;
|
|
47
|
+
for (let index = offset - 1; content[index] === "\\"; index--) slashCount++;
|
|
48
|
+
return slashCount % 2 === 1;
|
|
49
|
+
}
|
|
50
|
+
function inlineCodeEnd(content, start) {
|
|
51
|
+
if (isEscaped(content, start)) return null;
|
|
52
|
+
let markerEnd = start;
|
|
53
|
+
while (content[markerEnd] === "`") markerEnd++;
|
|
54
|
+
const markerLength = markerEnd - start;
|
|
55
|
+
for (let index = markerEnd; index < content.length; ) {
|
|
56
|
+
if (content[index] !== "`") {
|
|
57
|
+
index++;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
let runEnd = index;
|
|
61
|
+
while (content[runEnd] === "`") runEnd++;
|
|
62
|
+
if (runEnd - index === markerLength) return runEnd;
|
|
63
|
+
index = runEnd;
|
|
64
|
+
}
|
|
65
|
+
return markerEnd;
|
|
66
|
+
}
|
|
67
|
+
function tokenizeXml(content) {
|
|
68
|
+
const tokens = [];
|
|
69
|
+
let textStart = 0;
|
|
70
|
+
let cursor = 0;
|
|
71
|
+
let scannedRegionStart = -1;
|
|
72
|
+
let scannedLineEnd = 0;
|
|
73
|
+
let baseIndent;
|
|
74
|
+
let cachedLineStart = -1;
|
|
75
|
+
let cachedLineEnd = -1;
|
|
76
|
+
let currentIndent = 0;
|
|
77
|
+
const isIndentedMarkdownCode = (offset) => {
|
|
78
|
+
if (offset > cachedLineEnd) {
|
|
79
|
+
cachedLineStart = content.lastIndexOf("\n", offset - 1) + 1;
|
|
80
|
+
const nextNewline = content.indexOf("\n", offset);
|
|
81
|
+
cachedLineEnd = nextNewline === -1 ? content.length : nextNewline;
|
|
82
|
+
currentIndent = 0;
|
|
83
|
+
while (content[cachedLineStart + currentIndent] === " " || content[cachedLineStart + currentIndent] === " ")
|
|
84
|
+
currentIndent++;
|
|
85
|
+
}
|
|
86
|
+
const lineStart = cachedLineStart;
|
|
87
|
+
if (scannedRegionStart !== textStart) {
|
|
88
|
+
scannedRegionStart = textStart;
|
|
89
|
+
scannedLineEnd = textStart;
|
|
90
|
+
baseIndent = void 0;
|
|
91
|
+
}
|
|
92
|
+
while (scannedLineEnd < lineStart) {
|
|
93
|
+
const end = content.indexOf("\n", scannedLineEnd);
|
|
94
|
+
const line = content.slice(scannedLineEnd, end);
|
|
95
|
+
if (line.trim()) {
|
|
96
|
+
const indent = line.match(/^[ \t]*/)?.[0].length ?? 0;
|
|
97
|
+
baseIndent = baseIndent === void 0 ? indent : Math.min(baseIndent, indent);
|
|
98
|
+
}
|
|
99
|
+
scannedLineEnd = end + 1;
|
|
100
|
+
}
|
|
101
|
+
return baseIndent !== void 0 && currentIndent >= baseIndent + 4;
|
|
102
|
+
};
|
|
103
|
+
const pushMarkdown = (end) => {
|
|
104
|
+
if (end <= textStart) return;
|
|
105
|
+
const raw = content.slice(textStart, end);
|
|
106
|
+
const markdown = normalizeMarkdownIndentation(raw);
|
|
107
|
+
tokens.push({
|
|
108
|
+
type: "markdown",
|
|
109
|
+
text: markdown.text,
|
|
110
|
+
raw,
|
|
111
|
+
indent: markdown.indent
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
while (cursor < content.length) {
|
|
115
|
+
const fence = fenceAtLineStart(content, cursor);
|
|
116
|
+
if (fence) {
|
|
117
|
+
cursor = fenceEnd(content, fence.contentStart, fence.marker);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (content[cursor] === "`") {
|
|
121
|
+
cursor = inlineCodeEnd(content, cursor) ?? cursor + 1;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (content.startsWith("<!--", cursor) || content.startsWith("<![CDATA[", cursor) || content.startsWith("<?", cursor)) {
|
|
125
|
+
const [kind, terminator, afterStart] = content.startsWith("<!--", cursor) ? ["comment", "-->", 4] : content.startsWith("<![CDATA[", cursor) ? ["cdata", "]]>", 9] : ["declaration", "?>", 2];
|
|
126
|
+
const endMarker = content.indexOf(terminator, cursor + afterStart);
|
|
127
|
+
const end = endMarker === -1 ? content.length : endMarker + terminator.length;
|
|
128
|
+
pushMarkdown(cursor);
|
|
129
|
+
const raw = content.slice(cursor, end);
|
|
130
|
+
tokens.push({
|
|
131
|
+
type: kind,
|
|
132
|
+
text: raw,
|
|
133
|
+
raw,
|
|
134
|
+
indent: indentAt(content, cursor)
|
|
135
|
+
});
|
|
136
|
+
cursor = end;
|
|
137
|
+
textStart = end;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (content[cursor] !== "<") {
|
|
141
|
+
cursor++;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (isIndentedMarkdownCode(cursor)) {
|
|
145
|
+
cursor++;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
const tag = readXmlTag(content, cursor);
|
|
149
|
+
if (!tag) {
|
|
150
|
+
cursor++;
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
pushMarkdown(cursor);
|
|
154
|
+
tokens.push({
|
|
155
|
+
type: tag.isClosing ? "close" : tag.isSelfClosing ? "selfClose" : "open",
|
|
156
|
+
tagName: tag.tagName,
|
|
157
|
+
attributes: tag.attributes,
|
|
158
|
+
raw: tag.raw,
|
|
159
|
+
indent: indentAt(content, cursor)
|
|
160
|
+
});
|
|
161
|
+
cursor += tag.raw.length;
|
|
162
|
+
textStart = cursor;
|
|
163
|
+
}
|
|
164
|
+
pushMarkdown(content.length);
|
|
165
|
+
return tokens;
|
|
166
|
+
}
|
|
167
|
+
export {
|
|
168
|
+
tokenizeXml
|
|
169
|
+
};
|