@seed-ship/mcp-ui-solid 6.24.0 → 7.0.0
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 +64 -0
- package/README.md +61 -0
- package/dist/adapters/connector.cjs +3 -3
- package/dist/adapters/connector.cjs.map +1 -1
- package/dist/adapters/connector.d.cts +108 -0
- package/dist/adapters/connector.d.ts +1 -2
- package/dist/adapters/connector.js +3 -3
- package/dist/adapters/connector.js.map +1 -1
- package/dist/adapters/index.d.cts +21 -0
- package/dist/adapters/index.d.ts +6 -7
- package/dist/adapters/macro-run.d.cts +99 -0
- package/dist/adapters/macro-run.d.ts +1 -2
- package/dist/adapters/presentation.d.cts +1 -2
- package/dist/adapters/presentation.d.ts +1 -2
- package/dist/adapters.d.cts +1 -1
- package/dist/adapters.d.ts +1 -1
- package/dist/components/ActionGroupRenderer.cjs +6 -6
- package/dist/components/ActionGroupRenderer.cjs.map +1 -1
- package/dist/components/ActionGroupRenderer.d.cts +38 -0
- package/dist/components/ActionGroupRenderer.d.ts +1 -2
- package/dist/components/ActionGroupRenderer.js +6 -6
- package/dist/components/ActionGroupRenderer.js.map +1 -1
- package/dist/components/ActionRenderer.d.cts +9 -0
- package/dist/components/ActionRenderer.d.ts +0 -1
- package/dist/components/AgentCard.d.cts +19 -0
- package/dist/components/AgentCard.d.ts +1 -2
- package/dist/components/AgentHandoff.d.cts +11 -0
- package/dist/components/AgentHandoff.d.ts +1 -2
- package/dist/components/ArtifactRenderer.d.cts +11 -0
- package/dist/components/ArtifactRenderer.d.ts +0 -1
- package/dist/components/AutocompleteDropdown.cjs +6 -6
- package/dist/components/AutocompleteDropdown.cjs.map +1 -1
- package/dist/components/AutocompleteDropdown.d.cts +70 -0
- package/dist/components/AutocompleteDropdown.d.ts +1 -2
- package/dist/components/AutocompleteDropdown.js +6 -6
- package/dist/components/AutocompleteDropdown.js.map +1 -1
- package/dist/components/AutocompleteFormField.cjs +6 -5
- package/dist/components/AutocompleteFormField.cjs.map +1 -1
- package/dist/components/AutocompleteFormField.d.cts +51 -0
- package/dist/components/AutocompleteFormField.d.ts +1 -2
- package/dist/components/AutocompleteFormField.d.ts.map +1 -1
- package/dist/components/AutocompleteFormField.js +6 -5
- package/dist/components/AutocompleteFormField.js.map +1 -1
- package/dist/components/BriefingDiff.d.cts +11 -0
- package/dist/components/BriefingDiff.d.ts +1 -2
- package/dist/components/CarouselRenderer.d.cts +12 -0
- package/dist/components/CarouselRenderer.d.ts +1 -2
- package/dist/components/ChartJSRenderer.cjs +216 -6
- package/dist/components/ChartJSRenderer.cjs.map +1 -1
- package/dist/components/ChartJSRenderer.d.cts +62 -0
- package/dist/components/ChartJSRenderer.d.ts +1 -2
- package/dist/components/ChartJSRenderer.d.ts.map +1 -1
- package/dist/components/ChartJSRenderer.js +217 -7
- package/dist/components/ChartJSRenderer.js.map +1 -1
- package/dist/components/ChatPrompt.cjs +5 -5
- package/dist/components/ChatPrompt.cjs.map +1 -1
- package/dist/components/ChatPrompt.d.cts +69 -0
- package/dist/components/ChatPrompt.d.ts +1 -2
- package/dist/components/ChatPrompt.js +5 -5
- package/dist/components/ChatPrompt.js.map +1 -1
- package/dist/components/CodeBlockRenderer.d.cts +23 -0
- package/dist/components/CodeBlockRenderer.d.ts +1 -2
- package/dist/components/ComponentToolbar.cjs +5 -5
- package/dist/components/ComponentToolbar.cjs.map +1 -1
- package/dist/components/ComponentToolbar.d.cts +46 -0
- package/dist/components/ComponentToolbar.d.ts +0 -1
- package/dist/components/ComponentToolbar.js +5 -5
- package/dist/components/ComponentToolbar.js.map +1 -1
- package/dist/components/DataPreviewSection.d.cts +11 -0
- package/dist/components/DataPreviewSection.d.ts +1 -2
- package/dist/components/DegradedFallback.cjs +1 -1
- package/dist/components/DegradedFallback.cjs.map +1 -1
- package/dist/components/DegradedFallback.d.cts +43 -0
- package/dist/components/DegradedFallback.d.ts +0 -1
- package/dist/components/DegradedFallback.js +1 -1
- package/dist/components/DegradedFallback.js.map +1 -1
- package/dist/components/DraggableGridItem.d.cts +94 -0
- package/dist/components/DraggableGridItem.d.ts +1 -2
- package/dist/components/EditableLayoutContext.d.cts +4 -0
- package/dist/components/EditableLayoutContext.d.ts +0 -1
- package/dist/components/EditableUIResourceRenderer.d.cts +42 -0
- package/dist/components/EditableUIResourceRenderer.d.ts +1 -2
- package/dist/components/ElicitationForm.d.cts +67 -0
- package/dist/components/ElicitationForm.d.ts +1 -2
- package/dist/components/ExpandableWrapper.cjs +10 -7
- package/dist/components/ExpandableWrapper.cjs.map +1 -1
- package/dist/components/ExpandableWrapper.d.cts +49 -0
- package/dist/components/ExpandableWrapper.d.ts +0 -1
- package/dist/components/ExpandableWrapper.d.ts.map +1 -1
- package/dist/components/ExpandableWrapper.js +10 -7
- package/dist/components/ExpandableWrapper.js.map +1 -1
- package/dist/components/FeedbackInline.d.cts +70 -0
- package/dist/components/FeedbackInline.d.ts +0 -1
- package/dist/components/FooterRenderer.d.cts +15 -0
- package/dist/components/FooterRenderer.d.ts +0 -1
- package/dist/components/FormFieldRenderer.cjs +13 -12
- package/dist/components/FormFieldRenderer.cjs.map +1 -1
- package/dist/components/FormFieldRenderer.d.cts +19 -0
- package/dist/components/FormFieldRenderer.d.ts +1 -2
- package/dist/components/FormFieldRenderer.d.ts.map +1 -1
- package/dist/components/FormFieldRenderer.js +13 -12
- package/dist/components/FormFieldRenderer.js.map +1 -1
- package/dist/components/FormRenderer.cjs +1 -1
- package/dist/components/FormRenderer.cjs.map +1 -1
- package/dist/components/FormRenderer.d.cts +14 -0
- package/dist/components/FormRenderer.d.ts +1 -2
- package/dist/components/FormRenderer.js +1 -1
- package/dist/components/FormRenderer.js.map +1 -1
- package/dist/components/GenerativeUIErrorBoundary.cjs +1 -1
- package/dist/components/GenerativeUIErrorBoundary.cjs.map +1 -1
- package/dist/components/GenerativeUIErrorBoundary.d.cts +58 -0
- package/dist/components/GenerativeUIErrorBoundary.d.ts +1 -2
- package/dist/components/GenerativeUIErrorBoundary.default.d.cts +1 -0
- package/dist/components/GenerativeUIErrorBoundary.default.d.ts +1 -2
- package/dist/components/GenerativeUIErrorBoundary.js +1 -1
- package/dist/components/GenerativeUIErrorBoundary.js.map +1 -1
- package/dist/components/GhostText.cjs +2 -2
- package/dist/components/GhostText.cjs.map +1 -1
- package/dist/components/GhostText.d.cts +112 -0
- package/dist/components/GhostText.d.ts +0 -1
- package/dist/components/GhostText.js +2 -2
- package/dist/components/GhostText.js.map +1 -1
- package/dist/components/GraphRenderer.cjs +100 -29
- package/dist/components/GraphRenderer.cjs.map +1 -1
- package/dist/components/GraphRenderer.d.cts +66 -0
- package/dist/components/GraphRenderer.d.ts +2 -3
- package/dist/components/GraphRenderer.d.ts.map +1 -1
- package/dist/components/GraphRenderer.js +100 -29
- package/dist/components/GraphRenderer.js.map +1 -1
- package/dist/components/GridRenderer.d.cts +49 -0
- package/dist/components/GridRenderer.d.ts +1 -2
- package/dist/components/IframeFallbackLink.d.cts +22 -0
- package/dist/components/IframeFallbackLink.d.ts +0 -1
- package/dist/components/ImageGalleryRenderer.d.cts +22 -0
- package/dist/components/ImageGalleryRenderer.d.ts +1 -2
- package/dist/components/LightboxOverlay.d.cts +31 -0
- package/dist/components/LightboxOverlay.d.ts +1 -2
- package/dist/components/MapRenderer.d.cts +77 -0
- package/dist/components/MapRenderer.d.ts +1 -2
- package/dist/components/MissingValue.cjs +2 -2
- package/dist/components/MissingValue.cjs.map +1 -1
- package/dist/components/MissingValue.d.cts +26 -0
- package/dist/components/MissingValue.d.ts +0 -1
- package/dist/components/MissingValue.js +2 -2
- package/dist/components/MissingValue.js.map +1 -1
- package/dist/components/ModalRenderer.cjs +39 -31
- package/dist/components/ModalRenderer.cjs.map +1 -1
- package/dist/components/ModalRenderer.d.cts +66 -0
- package/dist/components/ModalRenderer.d.ts +1 -2
- package/dist/components/ModalRenderer.d.ts.map +1 -1
- package/dist/components/ModalRenderer.js +40 -32
- package/dist/components/ModalRenderer.js.map +1 -1
- package/dist/components/PortalDropdownMenu.cjs +6 -3
- package/dist/components/PortalDropdownMenu.cjs.map +1 -1
- package/dist/components/PortalDropdownMenu.d.cts +55 -0
- package/dist/components/PortalDropdownMenu.d.ts +0 -1
- package/dist/components/PortalDropdownMenu.d.ts.map +1 -1
- package/dist/components/PortalDropdownMenu.js +7 -4
- package/dist/components/PortalDropdownMenu.js.map +1 -1
- package/dist/components/PresentationFeedback.d.cts +112 -0
- package/dist/components/PresentationFeedback.d.ts +0 -1
- package/dist/components/RenderContext.d.cts +41 -0
- package/dist/components/RenderContext.d.ts +1 -2
- package/dist/components/ResizeHandle.d.cts +49 -0
- package/dist/components/ResizeHandle.d.ts +0 -1
- package/dist/components/SafeHtml.d.cts +45 -0
- package/dist/components/SafeHtml.d.ts +0 -1
- package/dist/components/ScratchpadPanel.cjs +38 -44
- package/dist/components/ScratchpadPanel.cjs.map +1 -1
- package/dist/components/ScratchpadPanel.d.cts +34 -0
- package/dist/components/ScratchpadPanel.d.ts +1 -2
- package/dist/components/ScratchpadPanel.d.ts.map +1 -1
- package/dist/components/ScratchpadPanel.js +38 -44
- package/dist/components/ScratchpadPanel.js.map +1 -1
- package/dist/components/SplitStepper.d.cts +11 -0
- package/dist/components/SplitStepper.d.ts +1 -2
- package/dist/components/StreamingUIRenderer.d.cts +58 -0
- package/dist/components/StreamingUIRenderer.d.ts +3 -4
- package/dist/components/UIResourceRenderer.cjs +20 -20
- package/dist/components/UIResourceRenderer.cjs.map +1 -1
- package/dist/components/UIResourceRenderer.d.cts +181 -0
- package/dist/components/UIResourceRenderer.d.ts +3 -4
- package/dist/components/UIResourceRenderer.default.d.cts +1 -0
- package/dist/components/UIResourceRenderer.default.d.ts +1 -2
- package/dist/components/UIResourceRenderer.js +20 -20
- package/dist/components/UIResourceRenderer.js.map +1 -1
- package/dist/components/VerifiedText.d.cts +22 -0
- package/dist/components/VerifiedText.d.ts +1 -2
- package/dist/components/VideoRenderer.d.cts +41 -0
- package/dist/components/VideoRenderer.d.ts +1 -2
- package/dist/components/chart-data-table.d.cts +68 -0
- package/dist/components/chart-data-table.d.ts +0 -1
- package/dist/components/chart-missing-plugin.cjs +4 -4
- package/dist/components/chart-missing-plugin.cjs.map +1 -1
- package/dist/components/chart-missing-plugin.d.cts +128 -0
- package/dist/components/chart-missing-plugin.d.ts +4 -3
- package/dist/components/chart-missing-plugin.d.ts.map +1 -1
- package/dist/components/chart-missing-plugin.js +4 -4
- package/dist/components/chart-missing-plugin.js.map +1 -1
- package/dist/components/index.d.cts +62 -0
- package/dist/components/index.d.ts +57 -58
- package/dist/components.d.cts +2 -2
- package/dist/components.d.ts +2 -2
- package/dist/context/AutocompleteContext.d.cts +76 -0
- package/dist/context/AutocompleteContext.d.ts +1 -2
- package/dist/context/MCPActionContext.d.cts +169 -0
- package/dist/context/MCPActionContext.d.ts +0 -1
- package/dist/context/MCPUIConfigContext.d.cts +201 -0
- package/dist/context/MCPUIConfigContext.d.ts +1 -2
- package/dist/context/MCPUIMathContext.d.cts +17 -0
- package/dist/context/MCPUIMathContext.d.ts +0 -1
- package/dist/context/MCPUIStringsContext.d.cts +802 -0
- package/dist/context/MCPUIStringsContext.d.ts +1 -2
- package/dist/context/MCPUITelemetryContext.d.cts +35 -0
- package/dist/context/MCPUITelemetryContext.d.ts +1 -2
- package/dist/context/index.d.cts +7 -0
- package/dist/context/index.d.ts +2 -3
- package/dist/hooks/createResponsiveGrid.d.cts +5 -0
- package/dist/hooks/createResponsiveGrid.d.ts +0 -1
- package/dist/hooks/index.d.cts +25 -0
- package/dist/hooks/index.d.ts +20 -21
- package/dist/hooks/useAction.d.cts +164 -0
- package/dist/hooks/useAction.d.ts +2 -3
- package/dist/hooks/useAutocomplete.d.cts +118 -0
- package/dist/hooks/useAutocomplete.d.ts +1 -2
- package/dist/hooks/useChatBus.d.cts +55 -0
- package/dist/hooks/useChatBus.d.ts +1 -2
- package/dist/hooks/useConditionalField.d.cts +34 -0
- package/dist/hooks/useConditionalField.d.ts +1 -2
- package/dist/hooks/useDataValidator.d.cts +41 -0
- package/dist/hooks/useDataValidator.d.ts +1 -2
- package/dist/hooks/useDragDrop.d.cts +99 -0
- package/dist/hooks/useDragDrop.d.ts +1 -2
- package/dist/hooks/useFormPersistence.d.cts +80 -0
- package/dist/hooks/useFormPersistence.d.ts +0 -1
- package/dist/hooks/useModal.d.cts +106 -0
- package/dist/hooks/useModal.d.ts +0 -1
- package/dist/hooks/useResize.d.cts +86 -0
- package/dist/hooks/useResize.d.ts +1 -2
- package/dist/hooks/useStreamingUI.d.cts +117 -0
- package/dist/hooks/useStreamingUI.d.ts +1 -2
- package/dist/hooks.d.cts +1 -1
- package/dist/hooks.d.ts +1 -1
- package/dist/index.d.cts +91 -92
- package/dist/index.d.ts +91 -92
- package/dist/plugins/duckdb.d.cts +1 -2
- package/dist/plugins/duckdb.d.ts +1 -2
- package/dist/plugins/groq.d.cts +12 -0
- package/dist/plugins/groq.d.ts +1 -2
- package/dist/plugins/index.d.cts +9 -0
- package/dist/plugins/index.d.ts +3 -4
- package/dist/plugins/katex.d.cts +1 -2
- package/dist/plugins/katex.d.ts +1 -2
- package/dist/plugins/rest.d.cts +12 -0
- package/dist/plugins/rest.d.ts +1 -2
- package/dist/plugins/supabase.d.cts +12 -0
- package/dist/plugins/supabase.d.ts +1 -2
- package/dist/services/chat-bus.d.cts +100 -0
- package/dist/services/chat-bus.d.ts +1 -2
- package/dist/services/chat-prompt-controller.d.cts +92 -0
- package/dist/services/chat-prompt-controller.d.ts +1 -2
- package/dist/services/component-registry.d.cts +119 -0
- package/dist/services/component-registry.d.ts +1 -2
- package/dist/services/data-validator.d.cts +27 -0
- package/dist/services/data-validator.d.ts +1 -2
- package/dist/services/index.d.cts +9 -0
- package/dist/services/index.d.ts +4 -5
- package/dist/services/telemetry.d.cts +86 -0
- package/dist/services/telemetry.d.ts +1 -2
- package/dist/services/validation.d.cts +169 -0
- package/dist/services/validation.d.ts +1 -2
- package/dist/stores/scratchpad-store.d.cts +109 -0
- package/dist/stores/scratchpad-store.d.ts +1 -2
- package/dist/stores/server-capabilities-store.d.cts +171 -0
- package/dist/stores/server-capabilities-store.d.ts +0 -1
- package/dist/test-setup.d.cts +5 -0
- package/dist/test-setup.d.ts +0 -1
- package/dist/testing/index.d.cts +34 -0
- package/dist/testing/index.d.ts +1 -2
- package/dist/types/chat-bus.d.cts +783 -0
- package/dist/types/chat-bus.d.ts +4 -5
- package/dist/types/index.d.cts +1616 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types-export.d.cts +1 -2
- package/dist/types-export.d.ts +1 -2
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/degraded-projections.d.cts +119 -0
- package/dist/utils/degraded-projections.d.ts +0 -1
- package/dist/utils/duplicate-mount-registry.d.cts +83 -0
- package/dist/utils/duplicate-mount-registry.d.ts +0 -1
- package/dist/utils/escape-html.d.cts +12 -0
- package/dist/utils/escape-html.d.ts +0 -1
- package/dist/utils/format-string.d.cts +25 -0
- package/dist/utils/format-string.d.ts +0 -1
- package/dist/utils/iframe-coep.d.cts +53 -0
- package/dist/utils/iframe-coep.d.ts +1 -2
- package/dist/utils/logger.d.cts +57 -0
- package/dist/utils/logger.d.ts +0 -1
- package/dist/utils/math-markdown.cjs +1 -1
- package/dist/utils/math-markdown.cjs.map +1 -1
- package/dist/utils/math-markdown.d.cts +15 -0
- package/dist/utils/math-markdown.d.ts +1 -2
- package/dist/utils/math-markdown.js +1 -1
- package/dist/utils/math-markdown.js.map +1 -1
- package/dist/utils/missing-value.d.cts +78 -0
- package/dist/utils/missing-value.d.ts +0 -1
- package/dist/utils/pan-zoom.d.cts +234 -0
- package/dist/utils/pan-zoom.d.ts +0 -1
- package/dist/utils/perf.d.cts +18 -0
- package/dist/utils/perf.d.ts +0 -1
- package/dist/utils/safe-url.d.cts +33 -0
- package/dist/utils/safe-url.d.ts +0 -1
- package/dist/utils/sanitize-html.d.cts +142 -0
- package/dist/utils/sanitize-html.d.ts +0 -1
- package/dist/utils/stable-key.d.cts +32 -0
- package/dist/utils/stable-key.d.ts +0 -1
- package/dist/utils/theme.cjs +91 -0
- package/dist/utils/theme.cjs.map +1 -0
- package/dist/utils/theme.d.cts +10 -0
- package/dist/utils/theme.d.ts +10 -0
- package/dist/utils/theme.d.ts.map +1 -0
- package/dist/utils/theme.js +91 -0
- package/dist/utils/theme.js.map +1 -0
- package/dist/validation.d.cts +3 -4
- package/dist/validation.d.ts +3 -4
- package/docs/SECURITY-DEPENDENCIES.md +209 -0
- package/docs/THEMING.md +205 -0
- package/docs/ZOD4-STABLE-MIGRATION-2026-10-26.md +181 -0
- package/package.json +12 -9
- package/src/adapters/connector.ts +3 -3
- package/src/components/ActionGroupRenderer.tsx +6 -6
- package/src/components/AutocompleteDropdown.tsx +17 -17
- package/src/components/AutocompleteFormField.tsx +10 -9
- package/src/components/ChartJSRenderer.tsx +483 -239
- package/src/components/ChatPrompt.tsx +16 -16
- package/src/components/ComponentToolbar.tsx +5 -5
- package/src/components/DegradedFallback.tsx +9 -9
- package/src/components/ExpandableWrapper.tsx +15 -11
- package/src/components/FormFieldRenderer.tsx +52 -51
- package/src/components/FormRenderer.tsx +12 -12
- package/src/components/GenerativeUIErrorBoundary.tsx +6 -6
- package/src/components/GhostText.tsx +7 -7
- package/src/components/GraphRenderer.tsx +83 -67
- package/src/components/MissingValue.tsx +2 -2
- package/src/components/ModalRenderer.tsx +11 -5
- package/src/components/PortalDropdownMenu.tsx +6 -2
- package/src/components/ScratchpadPanel.tsx +144 -141
- package/src/components/UIResourceRenderer.tsx +101 -101
- package/src/components/chart-missing-plugin.ts +5 -3
- package/src/styles/autocomplete.css +53 -53
- package/src/utils/math-markdown.ts +1 -1
- package/src/utils/theme.ts +101 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Missing values — one definition shared by tables, chart data views,
|
|
3
|
+
* degraded projections, chart validation and the chart renderer.
|
|
4
|
+
*
|
|
5
|
+
* @since v6.24.0
|
|
6
|
+
*
|
|
7
|
+
* A missing value is a value the payload says EXISTS but was not observed:
|
|
8
|
+
* `null` in a chart dataset (or as a point's `y`), `null` / `undefined` in a
|
|
9
|
+
* table cell. It is not a zero, and it is not the absence of a row or of a
|
|
10
|
+
* label: every view keeps its slot and marks it.
|
|
11
|
+
*
|
|
12
|
+
* Runtime-free on purpose (no `solid-js`): the pure projections in
|
|
13
|
+
* `chart-data-table.ts` and `degraded-projections.ts`, and `validation.ts`
|
|
14
|
+
* (published as the `/validation` subpath), import it.
|
|
15
|
+
*/
|
|
16
|
+
/** The glyph a table cell shows for a missing value — `renderCellValue`'s historical `-`. */
|
|
17
|
+
export declare const MISSING_VALUE_MARKER = "-";
|
|
18
|
+
/**
|
|
19
|
+
* Chart types that encode a value as a share of a whole (or, for polar area,
|
|
20
|
+
* as a wedge whose emptiness reads as zero). Chart.js parses a `null` share
|
|
21
|
+
* as `0`, so these types refuse missing values instead of drawing them.
|
|
22
|
+
*/
|
|
23
|
+
export declare const PART_TO_WHOLE_CHART_TYPES: ReadonlySet<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Whether a raw TABLE cell value is displayed as {@link MISSING_VALUE_MARKER}.
|
|
26
|
+
*
|
|
27
|
+
* Mirrors the rules `renderCellValue` applies before any formatting — `null`,
|
|
28
|
+
* `undefined`, and a string that is empty or the word `undefined` once the
|
|
29
|
+
* backend's `"X – undefined"` debris is stripped — plus the literal marker
|
|
30
|
+
* itself (whitespace around it aside, which a table cell does not render),
|
|
31
|
+
* since it looks identical on screen and so must read identically.
|
|
32
|
+
*
|
|
33
|
+
* Objects are never missing here: `renderCellValue` renders them (link,
|
|
34
|
+
* name, or escaped JSON).
|
|
35
|
+
*/
|
|
36
|
+
export declare function isMissingCellValue(value: unknown): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Removes the `"Text – undefined"` / `"undefined – Text"` debris some
|
|
39
|
+
* backends concatenate. Shared with `renderCellValue` so both apply the very
|
|
40
|
+
* same cleanup.
|
|
41
|
+
*/
|
|
42
|
+
export declare function stripUndefinedDebris(value: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Whether one CHART data entry is missing: `null` / `undefined`, a non-finite
|
|
45
|
+
* number (Chart.js parses those to `null` too), or a point whose `y` is.
|
|
46
|
+
*/
|
|
47
|
+
export declare function isMissingChartValue(value: unknown): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* What a chart's missing values amount to.
|
|
50
|
+
*
|
|
51
|
+
* Only ENTRIES count: an explicit `null` (or non-finite number, or a point
|
|
52
|
+
* whose `y` is one). A dataset with no entry at all (`data: []`) is not
|
|
53
|
+
* "missing" — it is how 6.23.0 and earlier payloads said "nothing yet", e.g.
|
|
54
|
+
* while streaming, and it keeps rendering exactly as it did then.
|
|
55
|
+
*/
|
|
56
|
+
export interface ChartMissingSummary {
|
|
57
|
+
/** At least one entry of one dataset is missing. */
|
|
58
|
+
hasMissing: boolean;
|
|
59
|
+
/** Per dataset, in order: it has entries and every one of them is missing. */
|
|
60
|
+
fullyMissing: boolean[];
|
|
61
|
+
/**
|
|
62
|
+
* Per dataset, in order: at least one observed value AND at least one
|
|
63
|
+
* missing entry — the series a reader actually sees broken.
|
|
64
|
+
*/
|
|
65
|
+
partiallyMissing: boolean[];
|
|
66
|
+
/** Something is missing and no dataset has a single observed value: nothing to plot. */
|
|
67
|
+
allMissing: boolean;
|
|
68
|
+
}
|
|
69
|
+
interface ChartDataLike {
|
|
70
|
+
data?: {
|
|
71
|
+
datasets?: Array<{
|
|
72
|
+
data?: unknown[];
|
|
73
|
+
} | null | undefined>;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** Summarises the missing values of a chart payload. Never throws on a malformed payload. */
|
|
77
|
+
export declare function summarizeChartMissing(params: ChartDataLike | null | undefined): ChartMissingSummary;
|
|
78
|
+
export {};
|
|
@@ -76,4 +76,3 @@ interface ChartDataLike {
|
|
|
76
76
|
/** Summarises the missing values of a chart payload. Never throws on a malformed payload. */
|
|
77
77
|
export declare function summarizeChartMissing(params: ChartDataLike | null | undefined): ChartMissingSummary;
|
|
78
78
|
export {};
|
|
79
|
-
//# sourceMappingURL=missing-value.d.ts.map
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createPanZoom` — cursor-anchored zoom + drag-pan for one CSS-transformed
|
|
3
|
+
* element. Dependency-free, SSR-safe.
|
|
4
|
+
*
|
|
5
|
+
* @since v6.22.0
|
|
6
|
+
*
|
|
7
|
+
* ## Why a primitive and not a library
|
|
8
|
+
*
|
|
9
|
+
* The surfaces that need this (the image lightbox, the expanded modal) already
|
|
10
|
+
* own their viewport and their own event wiring; what they lack is the small
|
|
11
|
+
* amount of arithmetic that keeps the point under the cursor *under the
|
|
12
|
+
* cursor* while the scale changes. A pan/zoom library would bring its own
|
|
13
|
+
* DOM ownership, its own listeners and its own lifecycle into a tree where
|
|
14
|
+
* `ExpandableWrapper` physically reparents nodes between an inline slot and a
|
|
15
|
+
* modal slot — so this module owns numbers only, never nodes: it holds a
|
|
16
|
+
* scale + a translation and hands them back as one `transform` string. It
|
|
17
|
+
* attaches no listener of its own; the caller binds the handlers in JSX,
|
|
18
|
+
* which is what makes it survive a reparent.
|
|
19
|
+
*
|
|
20
|
+
* ## The contract with the DOM
|
|
21
|
+
*
|
|
22
|
+
* The element that carries the `transform` MUST also carry
|
|
23
|
+
* `transform-origin: 0 0` — {@link PanZoomController.contentStyle} sets both,
|
|
24
|
+
* and the anchoring maths assumes it. With that origin, `translate(t) scale(s)`
|
|
25
|
+
* maps a point `p` of the element's own (untransformed) coordinate space to
|
|
26
|
+
* `t + s·p`, measured from the element's untransformed top-left corner. The
|
|
27
|
+
* two spaces this module talks about are therefore:
|
|
28
|
+
*
|
|
29
|
+
* - a **content point** — px from that corner, in the element's own
|
|
30
|
+
* untransformed space. It names a pixel of the image/chart/graph itself and
|
|
31
|
+
* does not move when the user zooms.
|
|
32
|
+
* - a **viewport point** — px from that same corner, in the *parent's*
|
|
33
|
+
* unscaled space. `event.clientX - originX` is one. It names a place on
|
|
34
|
+
* screen and does not move when the user zooms.
|
|
35
|
+
*
|
|
36
|
+
* Zooming "at the cursor" is then one line: take the content point currently
|
|
37
|
+
* under a viewport point, and choose the translation that puts it back under
|
|
38
|
+
* the same viewport point at the new scale ({@link zoomAtAnchor}).
|
|
39
|
+
*
|
|
40
|
+
* ## Gestures
|
|
41
|
+
*
|
|
42
|
+
* One pointer drags (only while zoomed — at the fitted size there is nothing
|
|
43
|
+
* to move); two pointers pinch. The pinch is served here rather than left to
|
|
44
|
+
* the browser because the surface must set `touch-action: none` for the
|
|
45
|
+
* one-finger drag to work at all: a UA that is allowed to claim the contact
|
|
46
|
+
* for its own visual-viewport zoom would claim it for scrolling too. Taking
|
|
47
|
+
* `none` therefore obliges this module to give the second finger back, which
|
|
48
|
+
* it does through the same anchored maths — the content point under the
|
|
49
|
+
* contacts' midpoint stays under that midpoint, so a pinch zooms and pans in
|
|
50
|
+
* one motion.
|
|
51
|
+
*
|
|
52
|
+
* ## Gesture lifetime
|
|
53
|
+
*
|
|
54
|
+
* Nothing here listens on `window` or `document`, so a gesture's lifetime is
|
|
55
|
+
* the SURFACE's, not the controller's. A surface that can disappear mid-drag —
|
|
56
|
+
* a lightbox whose `<Show>` unmounts while a button is still held — takes the
|
|
57
|
+
* `pointerup` with it, and the gesture would otherwise never end. Two things
|
|
58
|
+
* close that hole: the caller calls {@link PanZoomController.cancelGesture}
|
|
59
|
+
* when its surface goes away, and the handlers themselves drop a gesture whose
|
|
60
|
+
* surface has left the document. `onCleanup` only covers the narrower case
|
|
61
|
+
* where the whole component is disposed.
|
|
62
|
+
*
|
|
63
|
+
* ## SSR
|
|
64
|
+
*
|
|
65
|
+
* Creating the controller touches no browser global — it only creates signals.
|
|
66
|
+
* Every DOM read (`getBoundingClientRect`, pointer capture) happens inside an
|
|
67
|
+
* event handler, i.e. never on the server and never during render, so SSR
|
|
68
|
+
* markup and the hydrated markup agree: both start at `min` scale, no offset.
|
|
69
|
+
*/
|
|
70
|
+
import { type Accessor, type JSX } from 'solid-js';
|
|
71
|
+
/** A point in one of the two spaces described above. Plain data, no units. */
|
|
72
|
+
export interface PanZoomPoint {
|
|
73
|
+
x: number;
|
|
74
|
+
y: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The whole state of a pan/zoom surface: a scale, and a translation in the
|
|
78
|
+
* parent's unscaled pixels (the translation is NOT multiplied by the scale —
|
|
79
|
+
* in `translate(t) scale(s)` the translate is applied to the unscaled
|
|
80
|
+
* coordinate system, which is why a drag adds screen pixels to it directly).
|
|
81
|
+
*/
|
|
82
|
+
export interface PanZoomState {
|
|
83
|
+
scale: number;
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
}
|
|
87
|
+
export interface PanZoomOptions {
|
|
88
|
+
/** Lowest scale, and the scale `reset()` returns to. Default `1`. */
|
|
89
|
+
min?: number;
|
|
90
|
+
/** Highest scale. Default `8`. */
|
|
91
|
+
max?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Wheel sensitivity. One wheel event multiplies the scale by
|
|
94
|
+
* `exp(-deltaY * step)`, so the zoom is exponential (every notch is the same
|
|
95
|
+
* *ratio*, whatever the current scale) and symmetric (a notch back undoes a
|
|
96
|
+
* notch forward exactly). Default `0.0015` — one 100px notch is ≈ ±16%.
|
|
97
|
+
*/
|
|
98
|
+
step?: number;
|
|
99
|
+
/**
|
|
100
|
+
* The element that carries the transform, when the handlers are bound
|
|
101
|
+
* somewhere else — typically a fullscreen backdrop wrapping the `<img>`.
|
|
102
|
+
* Without it the handlers use their own `currentTarget`, which is then
|
|
103
|
+
* assumed to be the transformed element.
|
|
104
|
+
*
|
|
105
|
+
* An accessor, not an element: the ref is still `undefined` when the
|
|
106
|
+
* controller is created.
|
|
107
|
+
*/
|
|
108
|
+
target?: () => HTMLElement | null | undefined;
|
|
109
|
+
}
|
|
110
|
+
/** Cursor for the surface the handlers are bound to. */
|
|
111
|
+
export type PanZoomCursor = 'auto' | 'grab' | 'grabbing';
|
|
112
|
+
export interface PanZoomController {
|
|
113
|
+
/** Current scale, clamped to `[min, max]`. Starts at `min`. */
|
|
114
|
+
scale: Accessor<number>;
|
|
115
|
+
/** Current translation, in the parent's unscaled pixels. Starts at `{0, 0}`. */
|
|
116
|
+
offset: Accessor<PanZoomPoint>;
|
|
117
|
+
/** `{ scale, x, y }` in one read — the shape the pure helpers take. */
|
|
118
|
+
state: Accessor<PanZoomState>;
|
|
119
|
+
/** Value for CSS `transform`: `translate(Xpx, Ypx) scale(S)`. */
|
|
120
|
+
transform: Accessor<string>;
|
|
121
|
+
/**
|
|
122
|
+
* Style for the TRANSFORMED element: the transform, the `0 0` origin the
|
|
123
|
+
* maths depends on, and `will-change` while a gesture is worth promoting.
|
|
124
|
+
*/
|
|
125
|
+
contentStyle: Accessor<JSX.CSSProperties>;
|
|
126
|
+
/**
|
|
127
|
+
* Style for the element the handlers are bound to: the grab cursor, and
|
|
128
|
+
* `touch-action: none`.
|
|
129
|
+
*
|
|
130
|
+
* `none` is not about page scrolling — the surfaces that use this own their
|
|
131
|
+
* viewport and have already locked the document. It is about the contact
|
|
132
|
+
* itself: anything other than `none` lets the UA claim a touch for its own
|
|
133
|
+
* pan or pinch and send `pointercancel` instead of the move stream, which
|
|
134
|
+
* would leave one-finger panning dead. The price is that the browser's own
|
|
135
|
+
* pinch-zoom is off, which is why {@link PanZoomController.onPointerDown}
|
|
136
|
+
* implements the two-finger gesture rather than leaving it to the platform.
|
|
137
|
+
*/
|
|
138
|
+
surfaceStyle: Accessor<JSX.CSSProperties>;
|
|
139
|
+
/** `'grabbing'` mid-drag, `'grab'` while pannable, `'auto'` otherwise. */
|
|
140
|
+
cursor: Accessor<PanZoomCursor>;
|
|
141
|
+
/** `scale() > min` — the surface is showing something other than its reset state. */
|
|
142
|
+
isZoomed: Accessor<boolean>;
|
|
143
|
+
/** A drag is in progress right now. */
|
|
144
|
+
isPanning: Accessor<boolean>;
|
|
145
|
+
/**
|
|
146
|
+
* The pointer travelled since the last `pointerdown` — a drag, not a click.
|
|
147
|
+
* Set whether or not the surface could actually pan, and stays true until
|
|
148
|
+
* the next `pointerdown`, so a `click` handler that fires after a drag —
|
|
149
|
+
* the lightbox backdrop's "click to close", typically — can bail out on it.
|
|
150
|
+
*/
|
|
151
|
+
wasDragged: Accessor<boolean>;
|
|
152
|
+
/** `scale()` as a whole percentage, for `strings.zoomLevel`. */
|
|
153
|
+
percent: Accessor<number>;
|
|
154
|
+
/** The configured bounds, so callers can disable a button at the limit. */
|
|
155
|
+
min: number;
|
|
156
|
+
max: number;
|
|
157
|
+
/**
|
|
158
|
+
* Multiplies the scale by `factor` (`> 1` zooms in), clamped to the bounds.
|
|
159
|
+
* Without an anchor the element's own centre stays put, which is what a
|
|
160
|
+
* toolbar button should do.
|
|
161
|
+
*/
|
|
162
|
+
zoomBy: (factor: number, anchor?: PanZoomPoint) => void;
|
|
163
|
+
/** Same, with an absolute target scale. */
|
|
164
|
+
zoomTo: (scale: number, anchor?: PanZoomPoint) => void;
|
|
165
|
+
/** Back to `min` scale and no offset. */
|
|
166
|
+
reset: () => void;
|
|
167
|
+
/**
|
|
168
|
+
* Drops every gesture in flight — the drag, the pinch, the contacts they are
|
|
169
|
+
* made of — and releases any pointer capture, WITHOUT touching the transform.
|
|
170
|
+
*
|
|
171
|
+
* Call it when the surface the handlers are bound to goes away while a
|
|
172
|
+
* pointer may still be down: `<Show>` disposing a portal, a modal closing on
|
|
173
|
+
* Escape mid-drag. The `pointerup` that would normally end the gesture is
|
|
174
|
+
* delivered to the element under the pointer, so once the surface is
|
|
175
|
+
* detached it never arrives — {@link PanZoomController.isPanning} would stay
|
|
176
|
+
* `true` for good, the cursor would stay `grabbing`, and the next press
|
|
177
|
+
* would be read as the second finger of a pinch with a phantom first one.
|
|
178
|
+
*/
|
|
179
|
+
cancelGesture: () => void;
|
|
180
|
+
/** Cursor-anchored wheel zoom. Calls `preventDefault()` — bind it only on a surface that owns its viewport. */
|
|
181
|
+
onWheel: (event: WheelEvent) => void;
|
|
182
|
+
/**
|
|
183
|
+
* Starts a drag-pan (if the surface is zoomed), or — on the second
|
|
184
|
+
* simultaneous contact — a pinch, which zooms whatever the current scale.
|
|
185
|
+
*/
|
|
186
|
+
onPointerDown: (event: PointerEvent) => void;
|
|
187
|
+
onPointerMove: (event: PointerEvent) => void;
|
|
188
|
+
onPointerUp: (event: PointerEvent) => void;
|
|
189
|
+
onPointerCancel: (event: PointerEvent) => void;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Clamps a scale into `[min, max]`. `NaN` — the result of dividing by a zero
|
|
193
|
+
* scale somewhere upstream — resolves to `min` rather than poisoning the
|
|
194
|
+
* transform; `±Infinity` simply hits the nearer bound.
|
|
195
|
+
*/
|
|
196
|
+
export declare function clampScale(scale: number, min: number, max: number): number;
|
|
197
|
+
/**
|
|
198
|
+
* The content point currently shown at `viewport` — the inverse of
|
|
199
|
+
* {@link viewportPointOf}. Pure; exported for the anchoring tests.
|
|
200
|
+
*/
|
|
201
|
+
export declare function contentPointAt(state: PanZoomState, viewport: PanZoomPoint): PanZoomPoint;
|
|
202
|
+
/** Where `content` currently shows up, as a viewport point. Pure. */
|
|
203
|
+
export declare function viewportPointOf(state: PanZoomState, content: PanZoomPoint): PanZoomPoint;
|
|
204
|
+
/**
|
|
205
|
+
* Changes the scale while keeping whatever is under `anchor` under `anchor`.
|
|
206
|
+
*
|
|
207
|
+
* This is the whole feature: `viewportPointOf(zoomAtAnchor(s, k, a), contentPointAt(s, a))`
|
|
208
|
+
* is `a` again, for every scale, every offset and every anchor. Pure — no
|
|
209
|
+
* clamping, no DOM; the controller clamps around it.
|
|
210
|
+
*/
|
|
211
|
+
export declare function zoomAtAnchor(state: PanZoomState, nextScale: number, anchor: PanZoomPoint): PanZoomState;
|
|
212
|
+
/**
|
|
213
|
+
* Creates a pan/zoom controller. Call it in a component body (it registers an
|
|
214
|
+
* `onCleanup`); bind the handlers on the surface that owns the viewport.
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```tsx
|
|
218
|
+
* let image: HTMLImageElement | undefined
|
|
219
|
+
* const panZoom = createPanZoom({ min: 1, max: 8, target: () => image })
|
|
220
|
+
*
|
|
221
|
+
* <div
|
|
222
|
+
* style={panZoom.surfaceStyle()}
|
|
223
|
+
* onWheel={panZoom.onWheel}
|
|
224
|
+
* onPointerDown={panZoom.onPointerDown}
|
|
225
|
+
* onPointerMove={panZoom.onPointerMove}
|
|
226
|
+
* onPointerUp={panZoom.onPointerUp}
|
|
227
|
+
* onPointerCancel={panZoom.onPointerCancel}
|
|
228
|
+
* onClick={() => { if (!panZoom.wasDragged()) close() }}
|
|
229
|
+
* >
|
|
230
|
+
* <img ref={image} style={panZoom.contentStyle()} src={src} />
|
|
231
|
+
* </div>
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
export declare function createPanZoom(options?: PanZoomOptions): PanZoomController;
|
package/dist/utils/pan-zoom.d.ts
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance markers for component renders (v5.4.0)
|
|
3
|
+
*
|
|
4
|
+
* Emits `performance.mark()` entries that show up automatically in Chrome
|
|
5
|
+
* DevTools "Performance" panel under user timings. Consumers can also
|
|
6
|
+
* query them via `performance.getEntriesByName(...)` for custom tracing.
|
|
7
|
+
*
|
|
8
|
+
* Naming convention :
|
|
9
|
+
* `mcp-ui:component:<id>:render-start`
|
|
10
|
+
* `mcp-ui:component:<id>:render-end`
|
|
11
|
+
* `mcp-ui:component:<id>:render` (a `measure` between the two)
|
|
12
|
+
*
|
|
13
|
+
* Always-on: marks are cheap (sub-microsecond) and only matter when a
|
|
14
|
+
* profiler is recording. SSR-safe (`performance` is guarded).
|
|
15
|
+
*/
|
|
16
|
+
export declare const PERF_PREFIX = "mcp-ui:component:";
|
|
17
|
+
export declare function markRenderStart(componentId: string): void;
|
|
18
|
+
export declare function markRenderEnd(componentId: string): void;
|
package/dist/utils/perf.d.ts
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL allow-list for attributes that the browser *navigates* or *fetches*
|
|
3
|
+
* (`href`, `src`).
|
|
4
|
+
*
|
|
5
|
+
* `sanitizeHtml` only protects `innerHTML` sinks. Values that are bound into
|
|
6
|
+
* a JSX attribute never touch DOMPurify, so an LLM-authored URL reaches the
|
|
7
|
+
* DOM verbatim — `[](javascript:alert(1)) *credit*` used
|
|
8
|
+
* to produce a clickable `javascript:` anchor in `TextRenderer`'s image
|
|
9
|
+
* branch.
|
|
10
|
+
*
|
|
11
|
+
* This module is an **allow-list**, not a blocklist: anything that is not
|
|
12
|
+
* provably one of the permitted forms is rejected.
|
|
13
|
+
*/
|
|
14
|
+
export interface SafeUrlOptions {
|
|
15
|
+
/** Also allow `data:image/(png|jpeg|jpg|gif|webp);base64,…` (for `<img src>`). */
|
|
16
|
+
allowDataImage?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Return `url` unchanged when it is safe to bind into `href`/`src`, or
|
|
20
|
+
* `undefined` when it is not.
|
|
21
|
+
*
|
|
22
|
+
* Allowed: relative URLs (`/`, `./`, `../`, `#`, `?` and bare paths) and
|
|
23
|
+
* absolute URLs whose scheme is `http:`, `https:`, `mailto:` or `tel:` —
|
|
24
|
+
* plus base64 `data:` images when `allowDataImage` is set.
|
|
25
|
+
*
|
|
26
|
+
* Rejected: `javascript:`, `data:text/html`, `vbscript:`, `file:`, `blob:`,
|
|
27
|
+
* anything unparseable, and any string containing control characters or
|
|
28
|
+
* newlines (`java\nscript:` normalizes back to `javascript:` in a browser).
|
|
29
|
+
*
|
|
30
|
+
* The original (trimmed) string is returned so relative URLs keep resolving
|
|
31
|
+
* against the document, not against the internal parse base.
|
|
32
|
+
*/
|
|
33
|
+
export declare function safeUrl(url: string, opts?: SafeUrlOptions): string | undefined;
|
package/dist/utils/safe-url.d.ts
CHANGED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSR-safe HTML sanitizer — the single entry point for every value that this
|
|
3
|
+
* package binds into an `innerHTML` sink.
|
|
4
|
+
*
|
|
5
|
+
* ## Why this module exists (the SSR contract)
|
|
6
|
+
*
|
|
7
|
+
* `dompurify` is a DOM-bound library. When it is loaded in an environment
|
|
8
|
+
* without a real `window.document` (Node / SSR), `createDOMPurify()` bails out
|
|
9
|
+
* early: it sets `DOMPurify.isSupported = false` and returns a *factory*
|
|
10
|
+
* object on which **`sanitize` is not even defined** (dompurify 3.4.x,
|
|
11
|
+
* `purify.es.mjs` ~L370). Depending on the version that means the call either
|
|
12
|
+
* throws (`sanitize is not a function`) or silently returns the input
|
|
13
|
+
* unchanged — neither is acceptable:
|
|
14
|
+
*
|
|
15
|
+
* - Solid's SSR renderer writes an `innerHTML` prop **raw** into the HTML
|
|
16
|
+
* response, so an unsanitized string becomes live markup in the document.
|
|
17
|
+
* - `solid-js/web`'s `setProperty(node, 'innerHTML', v)` returns early while
|
|
18
|
+
* hydrating (`if (isHydrating(node)) return`), so whatever the server
|
|
19
|
+
* emitted survives hydration untouched until the value changes.
|
|
20
|
+
*
|
|
21
|
+
* The contract implemented here:
|
|
22
|
+
*
|
|
23
|
+
* - **Server (or any environment where DOMPurify cannot run):** never emit
|
|
24
|
+
* markup — return `escapeHtml(input)` and nothing else. Nothing is
|
|
25
|
+
* stripped: the previous `stripTags()` pre-pass deleted legitimate prose
|
|
26
|
+
* (`values < 10 and > 5` rendered as `values 5`), and it was never the
|
|
27
|
+
* security boundary — `escapeHtml` always was. Tags therefore survive the
|
|
28
|
+
* server pass as visible, escaped text.
|
|
29
|
+
* - **Client:** run the real DOMPurify with the caller's profile, and let
|
|
30
|
+
* `<SafeHtml>` re-apply the rich version after hydration (its `onMount`
|
|
31
|
+
* patches `el.innerHTML` when the hydrated DOM differs from the current
|
|
32
|
+
* value, covering the skipped `setProperty`).
|
|
33
|
+
*
|
|
34
|
+
* Net effect: the server ships escaped plain text. **Block structure is lost
|
|
35
|
+
* on that first paint** — a markdown table or list arrives as one run of
|
|
36
|
+
* literal text, and the region reflows when the client swaps in the sanitized
|
|
37
|
+
* rich HTML on mount. That reflow is the accepted cost of never emitting
|
|
38
|
+
* unsanitized markup; call sites that can show a nicer degradation should
|
|
39
|
+
* branch on `canSanitizeHtml()` (see `TextRenderer`, which falls back to the
|
|
40
|
+
* escaped markdown *source* rather than escaped `marked` output).
|
|
41
|
+
*
|
|
42
|
+
* ## What this module does NOT cover
|
|
43
|
+
*
|
|
44
|
+
* Every sink that carries untrusted markup goes through here: `text`
|
|
45
|
+
* component content, table cells, and `ui://` rawHtml resources. One sink is
|
|
46
|
+
* deliberately outside it: `CodeBlockRenderer` binds highlight.js output — or
|
|
47
|
+
* `escapeHtml(code)` when highlight.js is missing or `highlight()` throws —
|
|
48
|
+
* straight into its `<code innerHTML>`. That string is markup-safe by
|
|
49
|
+
* construction (hljs emits only `<span class="hljs-*">` wrappers around
|
|
50
|
+
* escaped text), so it never reaches `sanitizeHtml`.
|
|
51
|
+
*
|
|
52
|
+
* @see ./escape-html for the escaper
|
|
53
|
+
* @see ../components/SafeHtml for the hydration fix-up
|
|
54
|
+
* @see ../components/CodeBlockRenderer for the one sink outside this module
|
|
55
|
+
*/
|
|
56
|
+
import { type Config } from 'dompurify';
|
|
57
|
+
/** DOMPurify configuration object (re-exported so call sites need not import dompurify). */
|
|
58
|
+
export type SanitizeConfig = Config;
|
|
59
|
+
/**
|
|
60
|
+
* Named DOMPurify profiles used across the package.
|
|
61
|
+
*
|
|
62
|
+
* `cellLink` / `cellMarkdown` / `cellHtml` are the *exact* configs that lived
|
|
63
|
+
* inline in `renderCellValue` — table-cell behaviour (citation chips rely on
|
|
64
|
+
* `data-citation-*`, `<button>`, `<svg>`, `<path>`) must not drift.
|
|
65
|
+
*/
|
|
66
|
+
export declare const SANITIZE_PROFILES: {
|
|
67
|
+
/**
|
|
68
|
+
* Rich prose for `TextRenderer` (markdown output *and* raw `content`).
|
|
69
|
+
*
|
|
70
|
+
* Starts from DOMPurify's default HTML profile so markdown tables, images,
|
|
71
|
+
* `<hr>`, `<del>`, `<sup>`/`<sub>` and task-list checkboxes survive, then
|
|
72
|
+
* removes the tags/attributes that have no business in LLM-authored prose.
|
|
73
|
+
*
|
|
74
|
+
* `<input>` is intentionally left allowed: DOMPurify's default attribute
|
|
75
|
+
* allow-list keeps `type` / `checked` / `disabled` (what `marked` emits for
|
|
76
|
+
* task lists) and drops every event handler, and `<form>` is forbidden here
|
|
77
|
+
* so nothing can be submitted. See `sanitize-html.test.ts`.
|
|
78
|
+
*/
|
|
79
|
+
prose: {
|
|
80
|
+
ADD_ATTR: string[];
|
|
81
|
+
FORBID_TAGS: string[];
|
|
82
|
+
FORBID_ATTR: string[];
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Markdown-link rewrite inside a table cell (`[text](url)` → `<a>`).
|
|
86
|
+
*
|
|
87
|
+
* The *label* of a link-like cell value is attacker-controlled, so the bare
|
|
88
|
+
* DOMPurify defaults are not enough: a name of
|
|
89
|
+
* `<svg><style>body *{visibility:hidden}</style></svg>` used to smuggle a
|
|
90
|
+
* document-wide stylesheet through this profile. `<style>` and the inline
|
|
91
|
+
* `style` attribute are forbidden here for that reason; `target`/`rel` stay
|
|
92
|
+
* allowed because the rewritten anchor carries them.
|
|
93
|
+
*/
|
|
94
|
+
cellLink: {
|
|
95
|
+
ADD_ATTR: string[];
|
|
96
|
+
FORBID_TAGS: string[];
|
|
97
|
+
FORBID_ATTR: string[];
|
|
98
|
+
};
|
|
99
|
+
/** `marked` output inside a table cell. */
|
|
100
|
+
cellMarkdown: {
|
|
101
|
+
ALLOWED_TAGS: string[];
|
|
102
|
+
ALLOWED_ATTR: string[];
|
|
103
|
+
ADD_ATTR: string[];
|
|
104
|
+
};
|
|
105
|
+
/** Raw HTML found in a table cell value. */
|
|
106
|
+
cellHtml: {
|
|
107
|
+
ALLOWED_TAGS: string[];
|
|
108
|
+
ALLOWED_ATTR: string[];
|
|
109
|
+
ADD_ATTR: string[];
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* `UIResourceHtmlRenderer` — DOMPurify defaults *plus* the same
|
|
113
|
+
* presentation/interaction lockdown as `prose`.
|
|
114
|
+
*
|
|
115
|
+
* `ui://` `rawHtml` is LLM- or tool-authored and lands in the host page's
|
|
116
|
+
* own document, so bare defaults let it restyle the whole app (`<style>`,
|
|
117
|
+
* `style=`) or stage a credential-phishing `<form>`. Rich structural markup
|
|
118
|
+
* (headings, tables, lists, links, images, classes) still survives.
|
|
119
|
+
*/
|
|
120
|
+
resource: {
|
|
121
|
+
FORBID_TAGS: string[];
|
|
122
|
+
FORBID_ATTR: string[];
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* `true` when a real DOMPurify run is possible in this environment.
|
|
127
|
+
*
|
|
128
|
+
* `false` on the server and in any client where dompurify bailed out, i.e.
|
|
129
|
+
* exactly when `sanitizeHtml` degrades to `escapeHtml`. Call sites that hold
|
|
130
|
+
* a nicer *source* form of their value (markdown source vs `marked` output)
|
|
131
|
+
* branch on this to avoid shipping escaped HTML tags as visible text.
|
|
132
|
+
*/
|
|
133
|
+
export declare function canSanitizeHtml(): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Sanitize `html` for binding into an `innerHTML` sink.
|
|
136
|
+
*
|
|
137
|
+
* @param html Untrusted markup (LLM output, tool payload, user input).
|
|
138
|
+
* @param config A `SANITIZE_PROFILES` entry, or an ad-hoc DOMPurify config.
|
|
139
|
+
* @returns Sanitized markup on the client; escaped plain text on the server
|
|
140
|
+
* or whenever DOMPurify cannot run.
|
|
141
|
+
*/
|
|
142
|
+
export declare function sanitizeHtml(html: string, config?: SanitizeConfig): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable identity key for UIResource payloads (v6.5.0).
|
|
3
|
+
*
|
|
4
|
+
* Consumers need a way to derive a deterministic key from a layout/component
|
|
5
|
+
* payload — for `<For>` keys, dedup detection, telemetry correlation, etc.
|
|
6
|
+
*
|
|
7
|
+
* Spec semantics : `UILayout.id` and `UIComponent.id` are obligatoires for
|
|
8
|
+
* any well-formed payload. When they are present and non-empty, this helper
|
|
9
|
+
* returns them as-is. When they are missing (e.g. consumer passing a "bare"
|
|
10
|
+
* chart payload `{ type: 'chart', params: {...} }` without wrapping it in
|
|
11
|
+
* a layout), the helper derives a stable key from the *content* — never
|
|
12
|
+
* from a timestamp or counter.
|
|
13
|
+
*
|
|
14
|
+
* The hash is FNV-1a 32-bit on a deterministically stringified form of the
|
|
15
|
+
* payload (sorted keys, undefined entries skipped). This is intentionally
|
|
16
|
+
* synchronous and dependency-free so consumers can call it inside a Solid
|
|
17
|
+
* memo or render function without ceremony.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Returns a stable identity key for a UIResource payload.
|
|
21
|
+
*
|
|
22
|
+
* - If `input.id` is a non-empty string, returns it verbatim. This is the
|
|
23
|
+
* path taken by well-formed payloads (cf. spec §Identity).
|
|
24
|
+
* - Otherwise, returns a 7-char base36 FNV-1a hash of the normalized
|
|
25
|
+
* content. Stable across renders, identical for structurally identical
|
|
26
|
+
* payloads.
|
|
27
|
+
*
|
|
28
|
+
* The hash is NOT cryptographic ; it's a dedup/correlation key. Collisions
|
|
29
|
+
* are theoretically possible but vanishingly rare for the payload shapes
|
|
30
|
+
* MCP-UI emits in practice.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getUiResourceStableKey(input: unknown): string;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const solidJs = require("solid-js");
|
|
4
|
+
const THEME_PREFIX = "--mcp-ui-";
|
|
5
|
+
function readThemeTokens(element, names) {
|
|
6
|
+
const result = {};
|
|
7
|
+
const view = element == null ? void 0 : element.ownerDocument.defaultView;
|
|
8
|
+
const style = element && view ? view.getComputedStyle(element) : void 0;
|
|
9
|
+
for (const name of names) result[name] = (style == null ? void 0 : style.getPropertyValue(name).trim()) || void 0;
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
function observeTheme(element, callback) {
|
|
13
|
+
const view = element.ownerDocument.defaultView;
|
|
14
|
+
if (!(view == null ? void 0 : view.MutationObserver)) return () => {
|
|
15
|
+
};
|
|
16
|
+
let stopped = false;
|
|
17
|
+
let pending = false;
|
|
18
|
+
const schedule = () => {
|
|
19
|
+
if (pending || stopped) return;
|
|
20
|
+
pending = true;
|
|
21
|
+
queueMicrotask(() => {
|
|
22
|
+
pending = false;
|
|
23
|
+
if (!stopped) callback();
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
const observer = new view.MutationObserver((records) => {
|
|
27
|
+
if (records.some((record) => {
|
|
28
|
+
if (record.type === "attributes") {
|
|
29
|
+
return record.target instanceof view.Element && record.target.contains(element);
|
|
30
|
+
}
|
|
31
|
+
return [...record.addedNodes, ...record.removedNodes].some(
|
|
32
|
+
(node) => node === element || node.contains(element)
|
|
33
|
+
);
|
|
34
|
+
})) schedule();
|
|
35
|
+
});
|
|
36
|
+
observer.observe(element.ownerDocument.documentElement, {
|
|
37
|
+
attributes: true,
|
|
38
|
+
childList: true,
|
|
39
|
+
subtree: true
|
|
40
|
+
});
|
|
41
|
+
return () => {
|
|
42
|
+
stopped = true;
|
|
43
|
+
observer.disconnect();
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function bindPortalTheme(portal, source) {
|
|
47
|
+
solidJs.createEffect(() => {
|
|
48
|
+
const anchor = source();
|
|
49
|
+
const view = anchor == null ? void 0 : anchor.ownerDocument.defaultView;
|
|
50
|
+
if (!anchor || !view) return;
|
|
51
|
+
const copied = /* @__PURE__ */ new Set();
|
|
52
|
+
const sync = () => {
|
|
53
|
+
const style = view.getComputedStyle(anchor);
|
|
54
|
+
const inherited = portal.parentElement ? view.getComputedStyle(portal.parentElement) : void 0;
|
|
55
|
+
const names = new Set(copied);
|
|
56
|
+
for (const computed of [style, inherited]) {
|
|
57
|
+
if (!computed) continue;
|
|
58
|
+
for (let index = 0; index < computed.length; index++) {
|
|
59
|
+
const name = computed.item(index);
|
|
60
|
+
if (name.startsWith(THEME_PREFIX)) names.add(name);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const values = /* @__PURE__ */ new Map();
|
|
64
|
+
for (const name of names) {
|
|
65
|
+
const value = style.getPropertyValue(name).trim();
|
|
66
|
+
if (value) values.set(name, value);
|
|
67
|
+
else if (inherited == null ? void 0 : inherited.getPropertyValue(name).trim()) values.set(name, "initial");
|
|
68
|
+
}
|
|
69
|
+
for (const name of copied) {
|
|
70
|
+
if (!values.has(name)) portal.style.removeProperty(name);
|
|
71
|
+
}
|
|
72
|
+
copied.clear();
|
|
73
|
+
for (const [name, value] of values) {
|
|
74
|
+
if (portal.style.getPropertyValue(name) !== value) portal.style.setProperty(name, value);
|
|
75
|
+
copied.add(name);
|
|
76
|
+
}
|
|
77
|
+
portal.classList.toggle("dark", anchor.closest(".dark") !== null);
|
|
78
|
+
};
|
|
79
|
+
sync();
|
|
80
|
+
const stop = observeTheme(anchor, sync);
|
|
81
|
+
solidJs.onCleanup(() => {
|
|
82
|
+
stop();
|
|
83
|
+
for (const name of copied) portal.style.removeProperty(name);
|
|
84
|
+
portal.classList.remove("dark");
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
exports.bindPortalTheme = bindPortalTheme;
|
|
89
|
+
exports.observeTheme = observeTheme;
|
|
90
|
+
exports.readThemeTokens = readThemeTokens;
|
|
91
|
+
//# sourceMappingURL=theme.cjs.map
|