@seed-ship/mcp-ui-solid 6.25.1 → 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.
Files changed (236) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +14 -0
  3. package/dist/adapters/connector.cjs +3 -3
  4. package/dist/adapters/connector.cjs.map +1 -1
  5. package/dist/adapters/connector.d.cts +108 -0
  6. package/dist/adapters/connector.d.ts +1 -2
  7. package/dist/adapters/connector.js +3 -3
  8. package/dist/adapters/connector.js.map +1 -1
  9. package/dist/adapters/index.d.cts +21 -0
  10. package/dist/adapters/index.d.ts +6 -7
  11. package/dist/adapters/macro-run.d.cts +99 -0
  12. package/dist/adapters/macro-run.d.ts +1 -2
  13. package/dist/adapters/presentation.d.cts +1 -2
  14. package/dist/adapters/presentation.d.ts +1 -2
  15. package/dist/adapters.d.cts +1 -1
  16. package/dist/adapters.d.ts +1 -1
  17. package/dist/components/ActionGroupRenderer.d.cts +38 -0
  18. package/dist/components/ActionGroupRenderer.d.ts +1 -2
  19. package/dist/components/ActionRenderer.d.cts +9 -0
  20. package/dist/components/ActionRenderer.d.ts +0 -1
  21. package/dist/components/AgentCard.d.cts +19 -0
  22. package/dist/components/AgentCard.d.ts +1 -2
  23. package/dist/components/AgentHandoff.d.cts +11 -0
  24. package/dist/components/AgentHandoff.d.ts +1 -2
  25. package/dist/components/ArtifactRenderer.d.cts +11 -0
  26. package/dist/components/ArtifactRenderer.d.ts +0 -1
  27. package/dist/components/AutocompleteDropdown.d.cts +70 -0
  28. package/dist/components/AutocompleteDropdown.d.ts +1 -2
  29. package/dist/components/AutocompleteFormField.d.cts +51 -0
  30. package/dist/components/AutocompleteFormField.d.ts +1 -2
  31. package/dist/components/BriefingDiff.d.cts +11 -0
  32. package/dist/components/BriefingDiff.d.ts +1 -2
  33. package/dist/components/CarouselRenderer.d.cts +12 -0
  34. package/dist/components/CarouselRenderer.d.ts +1 -2
  35. package/dist/components/ChartJSRenderer.d.cts +62 -0
  36. package/dist/components/ChartJSRenderer.d.ts +1 -2
  37. package/dist/components/ChatPrompt.d.cts +69 -0
  38. package/dist/components/ChatPrompt.d.ts +1 -2
  39. package/dist/components/CodeBlockRenderer.d.cts +23 -0
  40. package/dist/components/CodeBlockRenderer.d.ts +1 -2
  41. package/dist/components/ComponentToolbar.d.cts +46 -0
  42. package/dist/components/ComponentToolbar.d.ts +0 -1
  43. package/dist/components/DataPreviewSection.d.cts +11 -0
  44. package/dist/components/DataPreviewSection.d.ts +1 -2
  45. package/dist/components/DegradedFallback.d.cts +43 -0
  46. package/dist/components/DegradedFallback.d.ts +0 -1
  47. package/dist/components/DraggableGridItem.d.cts +94 -0
  48. package/dist/components/DraggableGridItem.d.ts +1 -2
  49. package/dist/components/EditableLayoutContext.d.cts +4 -0
  50. package/dist/components/EditableLayoutContext.d.ts +0 -1
  51. package/dist/components/EditableUIResourceRenderer.d.cts +42 -0
  52. package/dist/components/EditableUIResourceRenderer.d.ts +1 -2
  53. package/dist/components/ElicitationForm.d.cts +67 -0
  54. package/dist/components/ElicitationForm.d.ts +1 -2
  55. package/dist/components/ExpandableWrapper.d.cts +49 -0
  56. package/dist/components/ExpandableWrapper.d.ts +0 -1
  57. package/dist/components/FeedbackInline.d.cts +70 -0
  58. package/dist/components/FeedbackInline.d.ts +0 -1
  59. package/dist/components/FooterRenderer.d.cts +15 -0
  60. package/dist/components/FooterRenderer.d.ts +0 -1
  61. package/dist/components/FormFieldRenderer.d.cts +19 -0
  62. package/dist/components/FormFieldRenderer.d.ts +1 -2
  63. package/dist/components/FormRenderer.d.cts +14 -0
  64. package/dist/components/FormRenderer.d.ts +1 -2
  65. package/dist/components/GenerativeUIErrorBoundary.d.cts +58 -0
  66. package/dist/components/GenerativeUIErrorBoundary.d.ts +1 -2
  67. package/dist/components/GenerativeUIErrorBoundary.default.d.cts +1 -0
  68. package/dist/components/GenerativeUIErrorBoundary.default.d.ts +1 -2
  69. package/dist/components/GhostText.d.cts +112 -0
  70. package/dist/components/GhostText.d.ts +0 -1
  71. package/dist/components/GraphRenderer.d.cts +66 -0
  72. package/dist/components/GraphRenderer.d.ts +1 -2
  73. package/dist/components/GridRenderer.d.cts +49 -0
  74. package/dist/components/GridRenderer.d.ts +1 -2
  75. package/dist/components/IframeFallbackLink.d.cts +22 -0
  76. package/dist/components/IframeFallbackLink.d.ts +0 -1
  77. package/dist/components/ImageGalleryRenderer.d.cts +22 -0
  78. package/dist/components/ImageGalleryRenderer.d.ts +1 -2
  79. package/dist/components/LightboxOverlay.d.cts +31 -0
  80. package/dist/components/LightboxOverlay.d.ts +1 -2
  81. package/dist/components/MapRenderer.d.cts +77 -0
  82. package/dist/components/MapRenderer.d.ts +1 -2
  83. package/dist/components/MissingValue.d.cts +26 -0
  84. package/dist/components/MissingValue.d.ts +0 -1
  85. package/dist/components/ModalRenderer.d.cts +66 -0
  86. package/dist/components/ModalRenderer.d.ts +1 -2
  87. package/dist/components/PortalDropdownMenu.d.cts +55 -0
  88. package/dist/components/PortalDropdownMenu.d.ts +0 -1
  89. package/dist/components/PresentationFeedback.d.cts +112 -0
  90. package/dist/components/PresentationFeedback.d.ts +0 -1
  91. package/dist/components/RenderContext.d.cts +41 -0
  92. package/dist/components/RenderContext.d.ts +1 -2
  93. package/dist/components/ResizeHandle.d.cts +49 -0
  94. package/dist/components/ResizeHandle.d.ts +0 -1
  95. package/dist/components/SafeHtml.d.cts +45 -0
  96. package/dist/components/SafeHtml.d.ts +0 -1
  97. package/dist/components/ScratchpadPanel.d.cts +34 -0
  98. package/dist/components/ScratchpadPanel.d.ts +1 -2
  99. package/dist/components/SplitStepper.d.cts +11 -0
  100. package/dist/components/SplitStepper.d.ts +1 -2
  101. package/dist/components/StreamingUIRenderer.d.cts +58 -0
  102. package/dist/components/StreamingUIRenderer.d.ts +3 -4
  103. package/dist/components/UIResourceRenderer.d.cts +181 -0
  104. package/dist/components/UIResourceRenderer.d.ts +3 -4
  105. package/dist/components/UIResourceRenderer.default.d.cts +1 -0
  106. package/dist/components/UIResourceRenderer.default.d.ts +1 -2
  107. package/dist/components/VerifiedText.d.cts +22 -0
  108. package/dist/components/VerifiedText.d.ts +1 -2
  109. package/dist/components/VideoRenderer.d.cts +41 -0
  110. package/dist/components/VideoRenderer.d.ts +1 -2
  111. package/dist/components/chart-data-table.d.cts +68 -0
  112. package/dist/components/chart-data-table.d.ts +0 -1
  113. package/dist/components/chart-missing-plugin.d.cts +128 -0
  114. package/dist/components/chart-missing-plugin.d.ts +1 -2
  115. package/dist/components/index.d.cts +62 -0
  116. package/dist/components/index.d.ts +57 -58
  117. package/dist/components.d.cts +2 -2
  118. package/dist/components.d.ts +2 -2
  119. package/dist/context/AutocompleteContext.d.cts +76 -0
  120. package/dist/context/AutocompleteContext.d.ts +1 -2
  121. package/dist/context/MCPActionContext.d.cts +169 -0
  122. package/dist/context/MCPActionContext.d.ts +0 -1
  123. package/dist/context/MCPUIConfigContext.d.cts +201 -0
  124. package/dist/context/MCPUIConfigContext.d.ts +1 -2
  125. package/dist/context/MCPUIMathContext.d.cts +17 -0
  126. package/dist/context/MCPUIMathContext.d.ts +0 -1
  127. package/dist/context/MCPUIStringsContext.d.cts +802 -0
  128. package/dist/context/MCPUIStringsContext.d.ts +1 -2
  129. package/dist/context/MCPUITelemetryContext.d.cts +35 -0
  130. package/dist/context/MCPUITelemetryContext.d.ts +1 -2
  131. package/dist/context/index.d.cts +7 -0
  132. package/dist/context/index.d.ts +2 -3
  133. package/dist/hooks/createResponsiveGrid.d.cts +5 -0
  134. package/dist/hooks/createResponsiveGrid.d.ts +0 -1
  135. package/dist/hooks/index.d.cts +25 -0
  136. package/dist/hooks/index.d.ts +20 -21
  137. package/dist/hooks/useAction.d.cts +164 -0
  138. package/dist/hooks/useAction.d.ts +2 -3
  139. package/dist/hooks/useAutocomplete.d.cts +118 -0
  140. package/dist/hooks/useAutocomplete.d.ts +1 -2
  141. package/dist/hooks/useChatBus.d.cts +55 -0
  142. package/dist/hooks/useChatBus.d.ts +1 -2
  143. package/dist/hooks/useConditionalField.d.cts +34 -0
  144. package/dist/hooks/useConditionalField.d.ts +1 -2
  145. package/dist/hooks/useDataValidator.d.cts +41 -0
  146. package/dist/hooks/useDataValidator.d.ts +1 -2
  147. package/dist/hooks/useDragDrop.d.cts +99 -0
  148. package/dist/hooks/useDragDrop.d.ts +1 -2
  149. package/dist/hooks/useFormPersistence.d.cts +80 -0
  150. package/dist/hooks/useFormPersistence.d.ts +0 -1
  151. package/dist/hooks/useModal.d.cts +106 -0
  152. package/dist/hooks/useModal.d.ts +0 -1
  153. package/dist/hooks/useResize.d.cts +86 -0
  154. package/dist/hooks/useResize.d.ts +1 -2
  155. package/dist/hooks/useStreamingUI.d.cts +117 -0
  156. package/dist/hooks/useStreamingUI.d.ts +1 -2
  157. package/dist/hooks.d.cts +1 -1
  158. package/dist/hooks.d.ts +1 -1
  159. package/dist/index.d.cts +91 -92
  160. package/dist/index.d.ts +91 -92
  161. package/dist/plugins/duckdb.d.cts +1 -2
  162. package/dist/plugins/duckdb.d.ts +1 -2
  163. package/dist/plugins/groq.d.cts +12 -0
  164. package/dist/plugins/groq.d.ts +1 -2
  165. package/dist/plugins/index.d.cts +9 -0
  166. package/dist/plugins/index.d.ts +3 -4
  167. package/dist/plugins/katex.d.cts +1 -2
  168. package/dist/plugins/katex.d.ts +1 -2
  169. package/dist/plugins/rest.d.cts +12 -0
  170. package/dist/plugins/rest.d.ts +1 -2
  171. package/dist/plugins/supabase.d.cts +12 -0
  172. package/dist/plugins/supabase.d.ts +1 -2
  173. package/dist/services/chat-bus.d.cts +100 -0
  174. package/dist/services/chat-bus.d.ts +1 -2
  175. package/dist/services/chat-prompt-controller.d.cts +92 -0
  176. package/dist/services/chat-prompt-controller.d.ts +1 -2
  177. package/dist/services/component-registry.d.cts +119 -0
  178. package/dist/services/component-registry.d.ts +1 -2
  179. package/dist/services/data-validator.d.cts +27 -0
  180. package/dist/services/data-validator.d.ts +1 -2
  181. package/dist/services/index.d.cts +9 -0
  182. package/dist/services/index.d.ts +4 -5
  183. package/dist/services/telemetry.d.cts +86 -0
  184. package/dist/services/telemetry.d.ts +1 -2
  185. package/dist/services/validation.d.cts +169 -0
  186. package/dist/services/validation.d.ts +1 -2
  187. package/dist/stores/scratchpad-store.d.cts +109 -0
  188. package/dist/stores/scratchpad-store.d.ts +1 -2
  189. package/dist/stores/server-capabilities-store.d.cts +171 -0
  190. package/dist/stores/server-capabilities-store.d.ts +0 -1
  191. package/dist/test-setup.d.cts +5 -0
  192. package/dist/test-setup.d.ts +0 -1
  193. package/dist/testing/index.d.cts +34 -0
  194. package/dist/testing/index.d.ts +1 -2
  195. package/dist/types/chat-bus.d.cts +783 -0
  196. package/dist/types/chat-bus.d.ts +4 -5
  197. package/dist/types/index.d.cts +1616 -0
  198. package/dist/types/index.d.ts +0 -1
  199. package/dist/types-export.d.cts +1 -2
  200. package/dist/types-export.d.ts +1 -2
  201. package/dist/types.d.cts +1 -1
  202. package/dist/types.d.ts +1 -1
  203. package/dist/utils/degraded-projections.d.cts +119 -0
  204. package/dist/utils/degraded-projections.d.ts +0 -1
  205. package/dist/utils/duplicate-mount-registry.d.cts +83 -0
  206. package/dist/utils/duplicate-mount-registry.d.ts +0 -1
  207. package/dist/utils/escape-html.d.cts +12 -0
  208. package/dist/utils/escape-html.d.ts +0 -1
  209. package/dist/utils/format-string.d.cts +25 -0
  210. package/dist/utils/format-string.d.ts +0 -1
  211. package/dist/utils/iframe-coep.d.cts +53 -0
  212. package/dist/utils/iframe-coep.d.ts +1 -2
  213. package/dist/utils/logger.d.cts +57 -0
  214. package/dist/utils/logger.d.ts +0 -1
  215. package/dist/utils/math-markdown.d.cts +15 -0
  216. package/dist/utils/math-markdown.d.ts +1 -2
  217. package/dist/utils/missing-value.d.cts +78 -0
  218. package/dist/utils/missing-value.d.ts +0 -1
  219. package/dist/utils/pan-zoom.d.cts +234 -0
  220. package/dist/utils/pan-zoom.d.ts +0 -1
  221. package/dist/utils/perf.d.cts +18 -0
  222. package/dist/utils/perf.d.ts +0 -1
  223. package/dist/utils/safe-url.d.cts +33 -0
  224. package/dist/utils/safe-url.d.ts +0 -1
  225. package/dist/utils/sanitize-html.d.cts +142 -0
  226. package/dist/utils/sanitize-html.d.ts +0 -1
  227. package/dist/utils/stable-key.d.cts +32 -0
  228. package/dist/utils/stable-key.d.ts +0 -1
  229. package/dist/utils/theme.d.cts +10 -0
  230. package/dist/utils/theme.d.ts +0 -1
  231. package/dist/validation.d.cts +3 -4
  232. package/dist/validation.d.ts +3 -4
  233. package/docs/SECURITY-DEPENDENCIES.md +129 -1
  234. package/docs/ZOD4-STABLE-MIGRATION-2026-10-26.md +181 -0
  235. package/package.json +8 -7
  236. package/src/adapters/connector.ts +3 -3
@@ -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;
@@ -232,4 +232,3 @@ export declare function zoomAtAnchor(state: PanZoomState, nextScale: number, anc
232
232
  * ```
233
233
  */
234
234
  export declare function createPanZoom(options?: PanZoomOptions): PanZoomController;
235
- //# sourceMappingURL=pan-zoom.d.ts.map
@@ -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;
@@ -16,4 +16,3 @@
16
16
  export declare const PERF_PREFIX = "mcp-ui:component:";
17
17
  export declare function markRenderStart(componentId: string): void;
18
18
  export declare function markRenderEnd(componentId: string): void;
19
- //# sourceMappingURL=perf.d.ts.map
@@ -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 — `[![x](https://ok/1.png)](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;
@@ -31,4 +31,3 @@ export interface SafeUrlOptions {
31
31
  * against the document, not against the internal parse base.
32
32
  */
33
33
  export declare function safeUrl(url: string, opts?: SafeUrlOptions): string | undefined;
34
- //# sourceMappingURL=safe-url.d.ts.map
@@ -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;
@@ -140,4 +140,3 @@ export declare function canSanitizeHtml(): boolean;
140
140
  * or whenever DOMPurify cannot run.
141
141
  */
142
142
  export declare function sanitizeHtml(html: string, config?: SanitizeConfig): string;
143
- //# sourceMappingURL=sanitize-html.d.ts.map
@@ -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;
@@ -30,4 +30,3 @@
30
30
  * MCP-UI emits in practice.
31
31
  */
32
32
  export declare function getUiResourceStableKey(input: unknown): string;
33
- //# sourceMappingURL=stable-key.d.ts.map
@@ -0,0 +1,10 @@
1
+ /** Read only explicitly supplied host tokens; blank values retain engine defaults. */
2
+ export declare function readThemeTokens(element: Element | undefined, names: readonly string[]): Record<string, string | undefined>;
3
+ /** Observe inherited theme changes, including moving a mounted renderer into a portal. */
4
+ export declare function observeTheme(element: HTMLElement, callback: () => void): () => void;
5
+ /**
6
+ * A body portal cannot inherit a local host theme. Copy only our effective
7
+ * custom properties and dark state from its stationary anchor, and keep them
8
+ * synchronized for the lifetime of the Solid owner. Geometry stays unchanged.
9
+ */
10
+ export declare function bindPortalTheme(portal: HTMLElement, source: () => HTMLElement | undefined): void;
@@ -8,4 +8,3 @@ export declare function observeTheme(element: HTMLElement, callback: () => void)
8
8
  * synchronized for the lifetime of the Solid owner. Geometry stays unchanged.
9
9
  */
10
10
  export declare function bindPortalTheme(portal: HTMLElement, source: () => HTMLElement | undefined): void;
11
- //# sourceMappingURL=theme.d.ts.map
@@ -9,7 +9,6 @@
9
9
  * import { validateLayout } from '@seed-ship/mcp-ui-solid/validation'
10
10
  * ```
11
11
  */
12
- export { validateComponent, validateLayout, validateGridPosition, validateChartComponent, validateTableComponent, validatePayloadSize, validateIframeDomain, getIframeSandbox, isTrustedIframeDomain, sanitizeString, DEFAULT_RESOURCE_LIMITS, validateFieldValue, validateFormData, DEFAULT_VALIDATION_MESSAGES, } from './services/validation';
13
- export type { FormValidationMessages } from './services/validation';
14
- export type { UIComponent, UILayout, GridPosition, ComponentType, ChartComponentParams, TableComponentParams, MetricComponentParams, TextComponentParams, ValidationResult, ResourceLimits, } from './types';
15
- //# sourceMappingURL=validation.d.ts.map
12
+ export { validateComponent, validateLayout, validateGridPosition, validateChartComponent, validateTableComponent, validatePayloadSize, validateIframeDomain, getIframeSandbox, isTrustedIframeDomain, sanitizeString, DEFAULT_RESOURCE_LIMITS, validateFieldValue, validateFormData, DEFAULT_VALIDATION_MESSAGES, } from "./services/validation.cjs";
13
+ export type { FormValidationMessages } from "./services/validation.cjs";
14
+ export type { UIComponent, UILayout, GridPosition, ComponentType, ChartComponentParams, TableComponentParams, MetricComponentParams, TextComponentParams, ValidationResult, ResourceLimits, } from "./types.cjs";
@@ -9,7 +9,6 @@
9
9
  * import { validateLayout } from '@seed-ship/mcp-ui-solid/validation'
10
10
  * ```
11
11
  */
12
- export { validateComponent, validateLayout, validateGridPosition, validateChartComponent, validateTableComponent, validatePayloadSize, validateIframeDomain, getIframeSandbox, isTrustedIframeDomain, sanitizeString, DEFAULT_RESOURCE_LIMITS, validateFieldValue, validateFormData, DEFAULT_VALIDATION_MESSAGES, } from './services/validation';
13
- export type { FormValidationMessages } from './services/validation';
14
- export type { UIComponent, UILayout, GridPosition, ComponentType, ChartComponentParams, TableComponentParams, MetricComponentParams, TextComponentParams, ValidationResult, ResourceLimits, } from './types';
15
- //# sourceMappingURL=validation.d.ts.map
12
+ export { validateComponent, validateLayout, validateGridPosition, validateChartComponent, validateTableComponent, validatePayloadSize, validateIframeDomain, getIframeSandbox, isTrustedIframeDomain, sanitizeString, DEFAULT_RESOURCE_LIMITS, validateFieldValue, validateFormData, DEFAULT_VALIDATION_MESSAGES, } from "./services/validation.js";
13
+ export type { FormValidationMessages } from "./services/validation.js";
14
+ export type { UIComponent, UILayout, GridPosition, ComponentType, ChartComponentParams, TableComponentParams, MetricComponentParams, TextComponentParams, ValidationResult, ResourceLimits, } from "./types.js";