@xemahq/ui-kernel 0.8.0 → 0.9.1

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 (544) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +6 -21
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/biome-host/agent-validation.js +5 -9
  6. package/dist/lib/biome-host/agent-validation.js.map +1 -1
  7. package/dist/lib/biome-host/biome-builders.js +5 -9
  8. package/dist/lib/biome-host/biome-builders.js.map +1 -1
  9. package/dist/lib/biome-host/biome-mode.js +1 -2
  10. package/dist/lib/biome-host/biome-navigation.js +6 -10
  11. package/dist/lib/biome-host/biome-navigation.js.map +1 -1
  12. package/dist/lib/biome-host/biome-registry.d.ts.map +1 -1
  13. package/dist/lib/biome-host/biome-registry.js +27 -29
  14. package/dist/lib/biome-host/biome-registry.js.map +1 -1
  15. package/dist/lib/biome-host/biome-scope.js +9 -14
  16. package/dist/lib/biome-host/biome-scope.js.map +1 -1
  17. package/dist/lib/biome-host/biome-scoped-query.js +8 -13
  18. package/dist/lib/biome-host/biome-scoped-query.js.map +1 -1
  19. package/dist/lib/biome-host/create-biome-orval-config.js +1 -4
  20. package/dist/lib/biome-host/create-biome-orval-config.js.map +1 -1
  21. package/dist/lib/biome-host/define-web-biome.js +3 -6
  22. package/dist/lib/biome-host/define-web-biome.js.map +1 -1
  23. package/dist/lib/biome-host/errors.js +1 -4
  24. package/dist/lib/biome-host/errors.js.map +1 -1
  25. package/dist/lib/biome-host/frontend-biome.js +3 -6
  26. package/dist/lib/biome-host/frontend-biome.js.map +1 -1
  27. package/dist/lib/biome-host/host-bridge.js +5 -9
  28. package/dist/lib/biome-host/host-bridge.js.map +1 -1
  29. package/dist/lib/biome-host/host-sources.js +1 -2
  30. package/dist/lib/biome-host/i18n-hooks.js +5 -9
  31. package/dist/lib/biome-host/i18n-hooks.js.map +1 -1
  32. package/dist/lib/biome-host/i18n-port.js +1 -4
  33. package/dist/lib/biome-host/i18n-port.js.map +1 -1
  34. package/dist/lib/biome-host/index.js +22 -38
  35. package/dist/lib/biome-host/index.js.map +1 -1
  36. package/dist/lib/biome-host/realtime-hooks.js +7 -12
  37. package/dist/lib/biome-host/realtime-hooks.js.map +1 -1
  38. package/dist/lib/biome-host/realtime-port.js +1 -2
  39. package/dist/lib/biome-host/response-envelope.js +2 -6
  40. package/dist/lib/biome-host/response-envelope.js.map +1 -1
  41. package/dist/lib/biome-host/session-contributions.js +1 -2
  42. package/dist/lib/biome-host/session-profiles.js +7 -11
  43. package/dist/lib/biome-host/session-profiles.js.map +1 -1
  44. package/dist/lib/biome-host/use-mutation-with-error-toast.js +7 -10
  45. package/dist/lib/biome-host/use-mutation-with-error-toast.js.map +1 -1
  46. package/dist/lib/biome-host/use-page-state.js +16 -21
  47. package/dist/lib/biome-host/use-page-state.js.map +1 -1
  48. package/dist/lib/capabilities/capability-provider.js +11 -15
  49. package/dist/lib/capabilities/capability-provider.js.map +1 -1
  50. package/dist/lib/capabilities/index.js +3 -19
  51. package/dist/lib/capabilities/index.js.map +1 -1
  52. package/dist/lib/capabilities/types.js +1 -2
  53. package/dist/lib/capabilities/use-capability.js +5 -9
  54. package/dist/lib/capabilities/use-capability.js.map +1 -1
  55. package/dist/lib/contribution-registry/contribution-registry.d.ts +24 -0
  56. package/dist/lib/contribution-registry/contribution-registry.d.ts.map +1 -0
  57. package/dist/lib/contribution-registry/contribution-registry.js +67 -0
  58. package/dist/lib/contribution-registry/contribution-registry.js.map +1 -0
  59. package/dist/lib/contribution-registry/index.d.ts +3 -0
  60. package/dist/lib/contribution-registry/index.d.ts.map +1 -0
  61. package/dist/lib/contribution-registry/index.js +3 -0
  62. package/dist/lib/contribution-registry/index.js.map +1 -0
  63. package/dist/lib/contribution-registry/renderable-registry.d.ts +33 -0
  64. package/dist/lib/contribution-registry/renderable-registry.d.ts.map +1 -0
  65. package/dist/lib/contribution-registry/renderable-registry.js +51 -0
  66. package/dist/lib/contribution-registry/renderable-registry.js.map +1 -0
  67. package/dist/lib/system-bus/capability-invoke.js +1 -2
  68. package/dist/lib/system-bus/deeplink.js +12 -17
  69. package/dist/lib/system-bus/deeplink.js.map +1 -1
  70. package/dist/lib/system-bus/enums.js +10 -13
  71. package/dist/lib/system-bus/enums.js.map +1 -1
  72. package/dist/lib/system-bus/host-ports.js +1 -2
  73. package/dist/lib/system-bus/index.js +10 -26
  74. package/dist/lib/system-bus/index.js.map +1 -1
  75. package/dist/lib/system-bus/intent-registry.js +6 -10
  76. package/dist/lib/system-bus/intent-registry.js.map +1 -1
  77. package/dist/lib/system-bus/intents.js +1 -2
  78. package/dist/lib/system-bus/palette.js +1 -2
  79. package/dist/lib/system-bus/system-bus-builder.js +10 -13
  80. package/dist/lib/system-bus/system-bus-builder.js.map +1 -1
  81. package/dist/lib/system-bus/system-bus.js +1 -2
  82. package/dist/lib/system-bus/windows.js +1 -2
  83. package/dist/offline/id.js +1 -4
  84. package/dist/offline/id.js.map +1 -1
  85. package/dist/offline/index.js +8 -25
  86. package/dist/offline/index.js.map +1 -1
  87. package/dist/offline/mutation.js +5 -8
  88. package/dist/offline/mutation.js.map +1 -1
  89. package/dist/offline/offline-status-badge.js +7 -10
  90. package/dist/offline/offline-status-badge.js.map +1 -1
  91. package/dist/offline/online-controller.js +2 -7
  92. package/dist/offline/online-controller.js.map +1 -1
  93. package/dist/offline/outbox.js +22 -26
  94. package/dist/offline/outbox.js.map +1 -1
  95. package/dist/offline/react.js +15 -21
  96. package/dist/offline/react.js.map +1 -1
  97. package/dist/offline/storage.js +3 -9
  98. package/dist/offline/storage.js.map +1 -1
  99. package/dist/offline/types.js +2 -5
  100. package/dist/offline/types.js.map +1 -1
  101. package/dist/org-db/components/DbResultTable.js +7 -10
  102. package/dist/org-db/components/DbResultTable.js.map +1 -1
  103. package/dist/org-db/index.js +1 -5
  104. package/dist/org-db/index.js.map +1 -1
  105. package/dist/pdf/index.d.ts +2 -0
  106. package/dist/pdf/index.d.ts.map +1 -0
  107. package/dist/pdf/index.js +2 -0
  108. package/dist/pdf/index.js.map +1 -0
  109. package/dist/registry/index.js +8 -24
  110. package/dist/registry/index.js.map +1 -1
  111. package/dist/registry/lib/agent-validation-host.js +5 -8
  112. package/dist/registry/lib/agent-validation-host.js.map +1 -1
  113. package/dist/registry/lib/biome-slot.js +9 -12
  114. package/dist/registry/lib/biome-slot.js.map +1 -1
  115. package/dist/registry/lib/biomes-enabled-context.js +5 -9
  116. package/dist/registry/lib/biomes-enabled-context.js.map +1 -1
  117. package/dist/registry/lib/extension-points.js +1 -4
  118. package/dist/registry/lib/extension-points.js.map +1 -1
  119. package/dist/registry/lib/primitives/SessionEventCard.js +7 -10
  120. package/dist/registry/lib/primitives/SessionEventCard.js.map +1 -1
  121. package/dist/registry/lib/primitives/SessionEventTimeline.js +9 -12
  122. package/dist/registry/lib/primitives/SessionEventTimeline.js.map +1 -1
  123. package/dist/registry/lib/primitives/SessionMutationBar.js +3 -6
  124. package/dist/registry/lib/primitives/SessionMutationBar.js.map +1 -1
  125. package/dist/registry/lib/primitives/SessionTabbedDrawer.js +11 -14
  126. package/dist/registry/lib/primitives/SessionTabbedDrawer.js.map +1 -1
  127. package/dist/registry/lib/primitives/index.js +4 -20
  128. package/dist/registry/lib/primitives/index.js.map +1 -1
  129. package/dist/registry/lib/session-context-builder.js +6 -10
  130. package/dist/registry/lib/session-context-builder.js.map +1 -1
  131. package/dist/registry/lib/session-context-provider.js +9 -14
  132. package/dist/registry/lib/session-context-provider.js.map +1 -1
  133. package/dist/registry/lib/session-selectors.js +30 -39
  134. package/dist/registry/lib/session-selectors.js.map +1 -1
  135. package/dist/session/comments/CommentRail.js +6 -9
  136. package/dist/session/comments/CommentRail.js.map +1 -1
  137. package/dist/session/index.js +3 -9
  138. package/dist/session/index.js.map +1 -1
  139. package/dist/session/lib/cn.js +4 -7
  140. package/dist/session/lib/cn.js.map +1 -1
  141. package/dist/session/shell/SessionWorkspaceShell.js +5 -8
  142. package/dist/session/shell/SessionWorkspaceShell.js.map +1 -1
  143. package/dist/session-kit/approvals/ApprovalButton.js +3 -6
  144. package/dist/session-kit/approvals/ApprovalButton.js.map +1 -1
  145. package/dist/session-kit/approvals/ApprovalCard.js +30 -33
  146. package/dist/session-kit/approvals/ApprovalCard.js.map +1 -1
  147. package/dist/session-kit/approvals/ApprovalsCenter.js +29 -32
  148. package/dist/session-kit/approvals/ApprovalsCenter.js.map +1 -1
  149. package/dist/session-kit/approvals/CapabilityApprovalStickyBar.js +12 -15
  150. package/dist/session-kit/approvals/CapabilityApprovalStickyBar.js.map +1 -1
  151. package/dist/session-kit/approvals/Obligation.js +12 -16
  152. package/dist/session-kit/approvals/Obligation.js.map +1 -1
  153. package/dist/session-kit/approvals/ScopedBody.js +34 -37
  154. package/dist/session-kit/approvals/ScopedBody.js.map +1 -1
  155. package/dist/session-kit/approvals/approval-icons.js +1 -2
  156. package/dist/session-kit/approvals/approval-model.js +6 -11
  157. package/dist/session-kit/approvals/approval-model.js.map +1 -1
  158. package/dist/session-kit/approvals/index.js +11 -27
  159. package/dist/session-kit/approvals/index.js.map +1 -1
  160. package/dist/session-kit/approvals/obligation-display.js +13 -16
  161. package/dist/session-kit/approvals/obligation-display.js.map +1 -1
  162. package/dist/session-kit/approvals/risk-accent.js +6 -9
  163. package/dist/session-kit/approvals/risk-accent.js.map +1 -1
  164. package/dist/session-kit/approvals/scope-icons.js +2 -5
  165. package/dist/session-kit/approvals/scope-icons.js.map +1 -1
  166. package/dist/session-kit/combobox/Combobox.js +19 -22
  167. package/dist/session-kit/combobox/Combobox.js.map +1 -1
  168. package/dist/session-kit/combobox/use-click-outside.js +4 -7
  169. package/dist/session-kit/combobox/use-click-outside.js.map +1 -1
  170. package/dist/session-kit/display/ContextHeader.js +10 -13
  171. package/dist/session-kit/display/ContextHeader.js.map +1 -1
  172. package/dist/session-kit/display/FileDiffCard.js +11 -14
  173. package/dist/session-kit/display/FileDiffCard.js.map +1 -1
  174. package/dist/session-kit/display/MD.js +14 -17
  175. package/dist/session-kit/display/MD.js.map +1 -1
  176. package/dist/session-kit/display/MessageTurn.js +20 -23
  177. package/dist/session-kit/display/MessageTurn.js.map +1 -1
  178. package/dist/session-kit/display/ThinkingPanel.js +7 -10
  179. package/dist/session-kit/display/ThinkingPanel.js.map +1 -1
  180. package/dist/session-kit/display/TodoChecklist.js +13 -16
  181. package/dist/session-kit/display/TodoChecklist.js.map +1 -1
  182. package/dist/session-kit/display/TokenMeter.js +8 -11
  183. package/dist/session-kit/display/TokenMeter.js.map +1 -1
  184. package/dist/session-kit/display/ToolStrip.js +26 -30
  185. package/dist/session-kit/display/ToolStrip.js.map +1 -1
  186. package/dist/session-kit/display/TypingDots.js +3 -6
  187. package/dist/session-kit/display/TypingDots.js.map +1 -1
  188. package/dist/session-kit/index.js +20 -36
  189. package/dist/session-kit/index.js.map +1 -1
  190. package/dist/session-kit/lib/enums.js +14 -17
  191. package/dist/session-kit/lib/enums.js.map +1 -1
  192. package/dist/session-kit/lib/portal-accent.js +1 -4
  193. package/dist/session-kit/lib/portal-accent.js.map +1 -1
  194. package/dist/session-kit/lib/status-dot.js +19 -24
  195. package/dist/session-kit/lib/status-dot.js.map +1 -1
  196. package/dist/session-kit/primitives/Avatar.js +3 -6
  197. package/dist/session-kit/primitives/Avatar.js.map +1 -1
  198. package/dist/session-kit/primitives/PortalGlyph.js +8 -11
  199. package/dist/session-kit/primitives/PortalGlyph.js.map +1 -1
  200. package/dist/session-kit/primitives/RiskPill.js +10 -14
  201. package/dist/session-kit/primitives/RiskPill.js.map +1 -1
  202. package/dist/session-kit/primitives/ScopeDot.js +7 -10
  203. package/dist/session-kit/primitives/ScopeDot.js.map +1 -1
  204. package/dist/session-kit/primitives/Segmented.js +4 -7
  205. package/dist/session-kit/primitives/Segmented.js.map +1 -1
  206. package/dist/ui/branding/app-branding-provider.js +13 -51
  207. package/dist/ui/branding/app-branding-provider.js.map +1 -1
  208. package/dist/ui/branding/sanitize.js +3 -8
  209. package/dist/ui/branding/sanitize.js.map +1 -1
  210. package/dist/ui/breakpoints.js +1 -4
  211. package/dist/ui/breakpoints.js.map +1 -1
  212. package/dist/ui/capture/document-preview.js +16 -19
  213. package/dist/ui/capture/document-preview.js.map +1 -1
  214. package/dist/ui/capture/field-spec-to-zod.d.ts +1 -0
  215. package/dist/ui/capture/field-spec-to-zod.d.ts.map +1 -1
  216. package/dist/ui/capture/field-spec-to-zod.js +51 -36
  217. package/dist/ui/capture/field-spec-to-zod.js.map +1 -1
  218. package/dist/ui/capture/field-spec-validate.d.ts +4 -0
  219. package/dist/ui/capture/field-spec-validate.d.ts.map +1 -0
  220. package/dist/ui/capture/field-spec-validate.js +129 -0
  221. package/dist/ui/capture/field-spec-validate.js.map +1 -0
  222. package/dist/ui/capture/field-spec.d.ts +13 -1
  223. package/dist/ui/capture/field-spec.d.ts.map +1 -1
  224. package/dist/ui/capture/field-spec.js +31 -13
  225. package/dist/ui/capture/field-spec.js.map +1 -1
  226. package/dist/ui/capture/index.d.ts +4 -2
  227. package/dist/ui/capture/index.d.ts.map +1 -1
  228. package/dist/ui/capture/index.js +12 -30
  229. package/dist/ui/capture/index.js.map +1 -1
  230. package/dist/ui/capture/schema-field-input.d.ts.map +1 -1
  231. package/dist/ui/capture/schema-field-input.js +82 -58
  232. package/dist/ui/capture/schema-field-input.js.map +1 -1
  233. package/dist/ui/capture/schema-form.js +11 -14
  234. package/dist/ui/capture/schema-form.js.map +1 -1
  235. package/dist/ui/capture/submit-values.d.ts +6 -0
  236. package/dist/ui/capture/submit-values.d.ts.map +1 -0
  237. package/dist/ui/capture/submit-values.js +28 -0
  238. package/dist/ui/capture/submit-values.js.map +1 -0
  239. package/dist/ui/capture/use-prefill.js +13 -16
  240. package/dist/ui/capture/use-prefill.js.map +1 -1
  241. package/dist/ui/capture/use-schema-validation.js +13 -16
  242. package/dist/ui/capture/use-schema-validation.js.map +1 -1
  243. package/dist/ui/capture/use-wizard.js +15 -18
  244. package/dist/ui/capture/use-wizard.js.map +1 -1
  245. package/dist/ui/capture/value-format.js +4 -8
  246. package/dist/ui/capture/value-format.js.map +1 -1
  247. package/dist/ui/capture/wizard.js +10 -14
  248. package/dist/ui/capture/wizard.js.map +1 -1
  249. package/dist/ui/charts/bar-chart.js +14 -17
  250. package/dist/ui/charts/bar-chart.js.map +1 -1
  251. package/dist/ui/charts/chart-frame.js +11 -16
  252. package/dist/ui/charts/chart-frame.js.map +1 -1
  253. package/dist/ui/charts/chart-types.js +1 -2
  254. package/dist/ui/charts/chart-utils.js +7 -15
  255. package/dist/ui/charts/chart-utils.js.map +1 -1
  256. package/dist/ui/charts/donut-chart.js +11 -14
  257. package/dist/ui/charts/donut-chart.js.map +1 -1
  258. package/dist/ui/charts/index.js +6 -20
  259. package/dist/ui/charts/index.js.map +1 -1
  260. package/dist/ui/charts/line-chart.js +15 -18
  261. package/dist/ui/charts/line-chart.js.map +1 -1
  262. package/dist/ui/charts/sparkline.js +9 -12
  263. package/dist/ui/charts/sparkline.js.map +1 -1
  264. package/dist/ui/chrome/AsyncBoundary.js +9 -15
  265. package/dist/ui/chrome/AsyncBoundary.js.map +1 -1
  266. package/dist/ui/chrome/EmptyState.js +9 -12
  267. package/dist/ui/chrome/EmptyState.js.map +1 -1
  268. package/dist/ui/chrome/ErrorCard.js +8 -11
  269. package/dist/ui/chrome/ErrorCard.js.map +1 -1
  270. package/dist/ui/chrome/LoadingState.js +8 -11
  271. package/dist/ui/chrome/LoadingState.js.map +1 -1
  272. package/dist/ui/chrome/PageHeader.js +10 -14
  273. package/dist/ui/chrome/PageHeader.js.map +1 -1
  274. package/dist/ui/chrome/StateCard.js +7 -11
  275. package/dist/ui/chrome/StateCard.js.map +1 -1
  276. package/dist/ui/chrome/confirm-delete-dialog.js +5 -8
  277. package/dist/ui/chrome/confirm-delete-dialog.js.map +1 -1
  278. package/dist/ui/chrome/page-shell.js +9 -15
  279. package/dist/ui/chrome/page-shell.js.map +1 -1
  280. package/dist/ui/chrome/scope-badge.js +5 -8
  281. package/dist/ui/chrome/scope-badge.js.map +1 -1
  282. package/dist/ui/chrome/status-badge.js +7 -10
  283. package/dist/ui/chrome/status-badge.js.map +1 -1
  284. package/dist/ui/cn.js +5 -8
  285. package/dist/ui/cn.js.map +1 -1
  286. package/dist/ui/design-tokens.js +21 -28
  287. package/dist/ui/design-tokens.js.map +1 -1
  288. package/dist/ui/hooks/use-debounced-value.js +4 -7
  289. package/dist/ui/hooks/use-debounced-value.js.map +1 -1
  290. package/dist/ui/hooks/use-is-mobile.js +8 -11
  291. package/dist/ui/hooks/use-is-mobile.js.map +1 -1
  292. package/dist/ui/index.d.ts +1 -1
  293. package/dist/ui/index.d.ts.map +1 -1
  294. package/dist/ui/index.js +47 -87
  295. package/dist/ui/index.js.map +1 -1
  296. package/dist/ui/pdf/pdf-preview.js +17 -20
  297. package/dist/ui/pdf/pdf-preview.js.map +1 -1
  298. package/dist/ui/primitives/alert-dialog.js +14 -60
  299. package/dist/ui/primitives/alert-dialog.js.map +1 -1
  300. package/dist/ui/primitives/async-combobox.js +18 -21
  301. package/dist/ui/primitives/async-combobox.js.map +1 -1
  302. package/dist/ui/primitives/badge.js +7 -44
  303. package/dist/ui/primitives/badge.js.map +1 -1
  304. package/dist/ui/primitives/button.js +9 -46
  305. package/dist/ui/primitives/button.js.map +1 -1
  306. package/dist/ui/primitives/card.js +10 -51
  307. package/dist/ui/primitives/card.js.map +1 -1
  308. package/dist/ui/primitives/checkbox.js +7 -43
  309. package/dist/ui/primitives/checkbox.js.map +1 -1
  310. package/dist/ui/primitives/collapsible.js +2 -40
  311. package/dist/ui/primitives/collapsible.js.map +1 -1
  312. package/dist/ui/primitives/dialog.js +12 -57
  313. package/dist/ui/primitives/dialog.js.map +1 -1
  314. package/dist/ui/primitives/dropdown-menu.js +15 -65
  315. package/dist/ui/primitives/dropdown-menu.js.map +1 -1
  316. package/dist/ui/primitives/form-stepper.js +8 -12
  317. package/dist/ui/primitives/form-stepper.js.map +1 -1
  318. package/dist/ui/primitives/input.js +5 -41
  319. package/dist/ui/primitives/input.js.map +1 -1
  320. package/dist/ui/primitives/label.js +8 -44
  321. package/dist/ui/primitives/label.js.map +1 -1
  322. package/dist/ui/primitives/overflow-tabs.d.ts +5 -0
  323. package/dist/ui/primitives/overflow-tabs.d.ts.map +1 -1
  324. package/dist/ui/primitives/overflow-tabs.js +19 -22
  325. package/dist/ui/primitives/overflow-tabs.js.map +1 -1
  326. package/dist/ui/primitives/popover.js +6 -44
  327. package/dist/ui/primitives/popover.js.map +1 -1
  328. package/dist/ui/primitives/preview-device-frame.js +16 -19
  329. package/dist/ui/primitives/preview-device-frame.js.map +1 -1
  330. package/dist/ui/primitives/radio-group.js +8 -45
  331. package/dist/ui/primitives/radio-group.js.map +1 -1
  332. package/dist/ui/primitives/resizable.js +11 -16
  333. package/dist/ui/primitives/resizable.js.map +1 -1
  334. package/dist/ui/primitives/scroll-area.js +7 -44
  335. package/dist/ui/primitives/scroll-area.js.map +1 -1
  336. package/dist/ui/primitives/select.js +15 -60
  337. package/dist/ui/primitives/select.js.map +1 -1
  338. package/dist/ui/primitives/separator.js +6 -42
  339. package/dist/ui/primitives/separator.js.map +1 -1
  340. package/dist/ui/primitives/sheet.js +14 -59
  341. package/dist/ui/primitives/sheet.js.map +1 -1
  342. package/dist/ui/primitives/skeleton.js +5 -7
  343. package/dist/ui/primitives/skeleton.js.map +1 -1
  344. package/dist/ui/primitives/switch.js +6 -42
  345. package/dist/ui/primitives/switch.js.map +1 -1
  346. package/dist/ui/primitives/table.js +12 -55
  347. package/dist/ui/primitives/table.js.map +1 -1
  348. package/dist/ui/primitives/tabs.js +8 -47
  349. package/dist/ui/primitives/tabs.js.map +1 -1
  350. package/dist/ui/primitives/tag-multi-select.js +24 -27
  351. package/dist/ui/primitives/tag-multi-select.js.map +1 -1
  352. package/dist/ui/primitives/textarea.js +5 -41
  353. package/dist/ui/primitives/textarea.js.map +1 -1
  354. package/dist/ui/primitives/tooltip.js +6 -45
  355. package/dist/ui/primitives/tooltip.js.map +1 -1
  356. package/dist/ui/primitives/url-preview-chrome.d.ts +8 -0
  357. package/dist/ui/primitives/url-preview-chrome.d.ts.map +1 -0
  358. package/dist/ui/primitives/url-preview-chrome.js +40 -0
  359. package/dist/ui/primitives/url-preview-chrome.js.map +1 -0
  360. package/dist/vista/GenericCatalogueSurface.d.ts +10 -0
  361. package/dist/vista/GenericCatalogueSurface.d.ts.map +1 -0
  362. package/dist/vista/GenericCatalogueSurface.js +80 -0
  363. package/dist/vista/GenericCatalogueSurface.js.map +1 -0
  364. package/dist/vista/SurfaceFallbackCard.d.ts +9 -0
  365. package/dist/vista/SurfaceFallbackCard.d.ts.map +1 -0
  366. package/dist/vista/SurfaceFallbackCard.js +44 -0
  367. package/dist/vista/SurfaceFallbackCard.js.map +1 -0
  368. package/dist/vista/VistaPanel.d.ts +21 -0
  369. package/dist/vista/VistaPanel.d.ts.map +1 -0
  370. package/dist/vista/VistaPanel.js +31 -0
  371. package/dist/vista/VistaPanel.js.map +1 -0
  372. package/dist/vista/html/CustomUiFrame.d.ts +20 -0
  373. package/dist/vista/html/CustomUiFrame.d.ts.map +1 -0
  374. package/dist/vista/html/CustomUiFrame.js +69 -0
  375. package/dist/vista/html/CustomUiFrame.js.map +1 -0
  376. package/dist/vista/html/custom-ui-frame-bridge.d.ts +13 -0
  377. package/dist/vista/html/custom-ui-frame-bridge.d.ts.map +1 -0
  378. package/dist/vista/html/custom-ui-frame-bridge.js +30 -0
  379. package/dist/vista/html/custom-ui-frame-bridge.js.map +1 -0
  380. package/dist/vista/html/custom-ui-frame-contract.d.ts +29 -0
  381. package/dist/vista/html/custom-ui-frame-contract.d.ts.map +1 -0
  382. package/dist/vista/html/custom-ui-frame-contract.js +16 -0
  383. package/dist/vista/html/custom-ui-frame-contract.js.map +1 -0
  384. package/dist/vista/html/custom-ui-intents.d.ts +20 -0
  385. package/dist/vista/html/custom-ui-intents.d.ts.map +1 -0
  386. package/dist/vista/html/custom-ui-intents.js +57 -0
  387. package/dist/vista/html/custom-ui-intents.js.map +1 -0
  388. package/dist/vista/html/custom-ui-srcdoc.d.ts +17 -0
  389. package/dist/vista/html/custom-ui-srcdoc.d.ts.map +1 -0
  390. package/dist/vista/html/custom-ui-srcdoc.js +70 -0
  391. package/dist/vista/html/custom-ui-srcdoc.js.map +1 -0
  392. package/dist/vista/html/index.d.ts +6 -0
  393. package/dist/vista/html/index.d.ts.map +1 -0
  394. package/dist/vista/html/index.js +6 -0
  395. package/dist/vista/html/index.js.map +1 -0
  396. package/dist/vista/index.d.ts +18 -0
  397. package/dist/vista/index.d.ts.map +1 -0
  398. package/dist/vista/index.js +18 -0
  399. package/dist/vista/index.js.map +1 -0
  400. package/dist/vista/surface-catalogue.d.ts +5 -0
  401. package/dist/vista/surface-catalogue.d.ts.map +1 -0
  402. package/dist/vista/surface-catalogue.js +30 -0
  403. package/dist/vista/surface-catalogue.js.map +1 -0
  404. package/dist/vista/surface-icons.d.ts +7 -0
  405. package/dist/vista/surface-icons.d.ts.map +1 -0
  406. package/dist/vista/surface-icons.js +26 -0
  407. package/dist/vista/surface-icons.js.map +1 -0
  408. package/dist/vista/surface-registry.d.ts +7 -0
  409. package/dist/vista/surface-registry.d.ts.map +1 -0
  410. package/dist/vista/surface-registry.js +7 -0
  411. package/dist/vista/surface-registry.js.map +1 -0
  412. package/dist/vista/surfaces/ChartSurface.d.ts +4 -0
  413. package/dist/vista/surfaces/ChartSurface.d.ts.map +1 -0
  414. package/dist/vista/surfaces/ChartSurface.js +17 -0
  415. package/dist/vista/surfaces/ChartSurface.js.map +1 -0
  416. package/dist/vista/surfaces/FilesSurface.d.ts +15 -0
  417. package/dist/vista/surfaces/FilesSurface.d.ts.map +1 -0
  418. package/dist/vista/surfaces/FilesSurface.js +121 -0
  419. package/dist/vista/surfaces/FilesSurface.js.map +1 -0
  420. package/dist/vista/surfaces/FormSurface.d.ts +4 -0
  421. package/dist/vista/surfaces/FormSurface.d.ts.map +1 -0
  422. package/dist/vista/surfaces/FormSurface.js +97 -0
  423. package/dist/vista/surfaces/FormSurface.js.map +1 -0
  424. package/dist/vista/surfaces/HtmlSurface.d.ts +4 -0
  425. package/dist/vista/surfaces/HtmlSurface.d.ts.map +1 -0
  426. package/dist/vista/surfaces/HtmlSurface.js +11 -0
  427. package/dist/vista/surfaces/HtmlSurface.js.map +1 -0
  428. package/dist/vista/surfaces/TableSurface.d.ts +4 -0
  429. package/dist/vista/surfaces/TableSurface.d.ts.map +1 -0
  430. package/dist/vista/surfaces/TableSurface.js +42 -0
  431. package/dist/vista/surfaces/TableSurface.js.map +1 -0
  432. package/dist/vista/surfaces/UrlSurface.d.ts +4 -0
  433. package/dist/vista/surfaces/UrlSurface.d.ts.map +1 -0
  434. package/dist/vista/surfaces/UrlSurface.js +7 -0
  435. package/dist/vista/surfaces/UrlSurface.js.map +1 -0
  436. package/dist/vista/surfaces/blob-surfaces.d.ts +6 -0
  437. package/dist/vista/surfaces/blob-surfaces.d.ts.map +1 -0
  438. package/dist/vista/surfaces/blob-surfaces.js +38 -0
  439. package/dist/vista/surfaces/blob-surfaces.js.map +1 -0
  440. package/dist/vista/surfaces/elicitation-transport.d.ts +18 -0
  441. package/dist/vista/surfaces/elicitation-transport.d.ts.map +1 -0
  442. package/dist/vista/surfaces/elicitation-transport.js +100 -0
  443. package/dist/vista/surfaces/elicitation-transport.js.map +1 -0
  444. package/dist/vista/surfaces/index.d.ts +11 -0
  445. package/dist/vista/surfaces/index.d.ts.map +1 -0
  446. package/dist/vista/surfaces/index.js +89 -0
  447. package/dist/vista/surfaces/index.js.map +1 -0
  448. package/dist/vista/surfaces/text-surfaces.d.ts +8 -0
  449. package/dist/vista/surfaces/text-surfaces.d.ts.map +1 -0
  450. package/dist/vista/surfaces/text-surfaces.js +54 -0
  451. package/dist/vista/surfaces/text-surfaces.js.map +1 -0
  452. package/dist/vista/use-vista-tabs.d.ts +30 -0
  453. package/dist/vista/use-vista-tabs.d.ts.map +1 -0
  454. package/dist/vista/use-vista-tabs.js +77 -0
  455. package/dist/vista/use-vista-tabs.js.map +1 -0
  456. package/dist/vista/vista-code-renderer.d.ts +12 -0
  457. package/dist/vista/vista-code-renderer.d.ts.map +1 -0
  458. package/dist/vista/vista-code-renderer.js +10 -0
  459. package/dist/vista/vista-code-renderer.js.map +1 -0
  460. package/dist/vista/vista-file-source.d.ts +20 -0
  461. package/dist/vista/vista-file-source.d.ts.map +1 -0
  462. package/dist/vista/vista-file-source.js +69 -0
  463. package/dist/vista/vista-file-source.js.map +1 -0
  464. package/dist/vista/vista-form-host.d.ts +16 -0
  465. package/dist/vista/vista-form-host.d.ts.map +1 -0
  466. package/dist/vista/vista-form-host.js +10 -0
  467. package/dist/vista/vista-form-host.js.map +1 -0
  468. package/dist/vista/vista-model.d.ts +12 -0
  469. package/dist/vista/vista-model.d.ts.map +1 -0
  470. package/dist/vista/vista-model.js +72 -0
  471. package/dist/vista/vista-model.js.map +1 -0
  472. package/dist/vista/vista-open-context.d.ts +9 -0
  473. package/dist/vista/vista-open-context.d.ts.map +1 -0
  474. package/dist/vista/vista-open-context.js +10 -0
  475. package/dist/vista/vista-open-context.js.map +1 -0
  476. package/dist/vista/vista-payloads.d.ts +107 -0
  477. package/dist/vista/vista-payloads.d.ts.map +1 -0
  478. package/dist/vista/vista-payloads.js +305 -0
  479. package/dist/vista/vista-payloads.js.map +1 -0
  480. package/dist/vista/vista-tabs-manifest.d.ts +17 -0
  481. package/dist/vista/vista-tabs-manifest.d.ts.map +1 -0
  482. package/dist/vista/vista-tabs-manifest.js +60 -0
  483. package/dist/vista/vista-tabs-manifest.js.map +1 -0
  484. package/dist/vista/vista-tools.d.ts +41 -0
  485. package/dist/vista/vista-tools.d.ts.map +1 -0
  486. package/dist/vista/vista-tools.js +113 -0
  487. package/dist/vista/vista-tools.js.map +1 -0
  488. package/package.json +10 -3
  489. package/src/index.ts +5 -0
  490. package/src/lib/biome-host/biome-registry.ts +31 -11
  491. package/src/lib/contribution-registry/contribution-registry.spec.ts +141 -0
  492. package/src/lib/contribution-registry/contribution-registry.ts +202 -0
  493. package/src/lib/contribution-registry/index.ts +9 -0
  494. package/src/lib/contribution-registry/renderable-registry.ts +142 -0
  495. package/src/pdf/index.ts +11 -0
  496. package/src/ui/capture/field-spec-to-zod.ts +22 -0
  497. package/src/ui/capture/field-spec-validate.ts +147 -0
  498. package/src/ui/capture/field-spec.ts +62 -0
  499. package/src/ui/capture/index.ts +9 -1
  500. package/src/ui/capture/schema-field-input.tsx +134 -14
  501. package/src/ui/capture/submit-values.test.ts +70 -0
  502. package/src/ui/capture/submit-values.ts +63 -0
  503. package/src/ui/index.ts +8 -1
  504. package/src/ui/primitives/overflow-tabs.tsx +24 -4
  505. package/src/ui/primitives/url-preview-chrome.tsx +102 -0
  506. package/src/vista/GenericCatalogueSurface.tsx +177 -0
  507. package/src/vista/SurfaceFallbackCard.tsx +109 -0
  508. package/src/vista/VistaPanel.tsx +155 -0
  509. package/src/vista/form-payload.spec.ts +93 -0
  510. package/src/vista/html/CustomUiFrame.spec.tsx +125 -0
  511. package/src/vista/html/CustomUiFrame.tsx +204 -0
  512. package/src/vista/html/custom-ui-frame-bridge.spec.ts +191 -0
  513. package/src/vista/html/custom-ui-frame-bridge.ts +92 -0
  514. package/src/vista/html/custom-ui-frame-contract.ts +88 -0
  515. package/src/vista/html/custom-ui-intents.spec.ts +133 -0
  516. package/src/vista/html/custom-ui-intents.ts +151 -0
  517. package/src/vista/html/custom-ui-srcdoc.spec.ts +151 -0
  518. package/src/vista/html/custom-ui-srcdoc.ts +193 -0
  519. package/src/vista/html/index.ts +13 -0
  520. package/src/vista/index.ts +48 -0
  521. package/src/vista/surface-catalogue.spec.ts +140 -0
  522. package/src/vista/surface-catalogue.ts +84 -0
  523. package/src/vista/surface-icons.ts +57 -0
  524. package/src/vista/surface-registry.ts +56 -0
  525. package/src/vista/surfaces/ChartSurface.tsx +34 -0
  526. package/src/vista/surfaces/FilesSurface.tsx +268 -0
  527. package/src/vista/surfaces/FormSurface.tsx +264 -0
  528. package/src/vista/surfaces/HtmlSurface.tsx +43 -0
  529. package/src/vista/surfaces/TableSurface.tsx +99 -0
  530. package/src/vista/surfaces/UrlSurface.tsx +40 -0
  531. package/src/vista/surfaces/blob-surfaces.tsx +129 -0
  532. package/src/vista/surfaces/elicitation-transport.spec.ts +187 -0
  533. package/src/vista/surfaces/elicitation-transport.ts +175 -0
  534. package/src/vista/surfaces/index.tsx +157 -0
  535. package/src/vista/surfaces/text-surfaces.tsx +119 -0
  536. package/src/vista/use-vista-tabs.ts +188 -0
  537. package/src/vista/vista-code-renderer.tsx +46 -0
  538. package/src/vista/vista-file-source.tsx +163 -0
  539. package/src/vista/vista-form-host.tsx +78 -0
  540. package/src/vista/vista-model.ts +130 -0
  541. package/src/vista/vista-open-context.tsx +42 -0
  542. package/src/vista/vista-payloads.ts +514 -0
  543. package/src/vista/vista-tabs-manifest.ts +123 -0
  544. package/src/vista/vista-tools.ts +220 -0
@@ -1,6 +1,11 @@
1
1
  import { Registry } from '@xemahq/registry';
2
2
  import { useSyncExternalStore } from 'react';
3
3
 
4
+ import {
5
+ DuplicateContributionPolicy,
6
+ createContributionRegistry,
7
+ } from '../contribution-registry';
8
+
4
9
  import type {
5
10
  FrontendBiome,
6
11
  FrontendBiomeFactory,
@@ -153,23 +158,38 @@ class FrontendBiomeRegistry extends Registry<string, FrontendBiome & { key: stri
153
158
  * light up the moment the biome's frontend loads. Duplicate kinds
154
159
  * across biomes are surfaced as a console error and the first
155
160
  * registration wins (deterministic + fail-loud, not silent).
161
+ *
162
+ * Built on the shared `createContributionRegistry` core — the same
163
+ * closed+open two-layer bookkeeping the ChatWidget, reply-variant and
164
+ * Vista-surface registries use. This overlay is rebuilt on every call
165
+ * (it is read during render), so it takes the `FirstWins` duplicate
166
+ * policy rather than `Throw`: a duplicate must not take down a render.
167
+ * `FirstWins` still REQUIRES the `onDuplicate` reporter below — the
168
+ * rejected contribution is never dropped silently.
156
169
  */
157
170
  outputRenderers(): ReadonlyMap<string, OutputRendererContribution> {
158
- const out = new Map<string, OutputRendererContribution>();
159
- if (!this.enabled) return out;
171
+ if (!this.enabled) return new Map<string, OutputRendererContribution>();
172
+ // `onDuplicate` fires SYNCHRONOUSLY from inside `register()`, so this
173
+ // cursor always names the biome whose contribution was rejected — the
174
+ // contribution object itself does not carry its owner.
175
+ let contributingBiomeId = '';
176
+ const overlay = createContributionRegistry<OutputRendererContribution>({
177
+ name: 'biome outputRenderer',
178
+ duplicatePolicy: DuplicateContributionPolicy.FirstWins,
179
+ onDuplicate: (outputKind) => {
180
+ console.error(
181
+ `[xema-ui-kernel] duplicate outputRenderer for kind '${outputKind}' ` +
182
+ `from biome '${contributingBiomeId}'; first registration wins.`,
183
+ );
184
+ },
185
+ });
160
186
  for (const biome of this.list()) {
187
+ contributingBiomeId = biome.id;
161
188
  for (const entry of biome.outputRenderers ?? []) {
162
- if (out.has(entry.outputKind)) {
163
- console.error(
164
- `[xema-ui-kernel] duplicate outputRenderer for kind '${entry.outputKind}' ` +
165
- `from biome '${biome.id}'; first registration wins.`,
166
- );
167
- continue;
168
- }
169
- out.set(entry.outputKind, entry);
189
+ overlay.register(entry.outputKind, entry);
170
190
  }
171
191
  }
172
- return out;
192
+ return overlay.entries();
173
193
  }
174
194
 
175
195
  private notify(): void {
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Guards the shared closed+open contribution registry core — the ONE
3
+ * implementation behind the ChatWidget, biome output-renderer, reply-variant
4
+ * and Vista-surface planes. Every property the hand-written copies had must
5
+ * survive the extraction.
6
+ *
7
+ * Runs under the host-web vitest mirror (this package carries no vitest dep).
8
+ */
9
+ import { describe, expect, it, vi } from 'vitest';
10
+
11
+ import {
12
+ ContributionFallbackReason,
13
+ DuplicateContributionPolicy,
14
+ createContributionRegistry,
15
+ createRenderableContributionRegistry,
16
+ } from './index';
17
+
18
+ function makeRegistry(): ReturnType<typeof createContributionRegistry<string>> {
19
+ return createContributionRegistry<string>({
20
+ name: 'test',
21
+ reservedKinds: ['plan', 'diff'],
22
+ });
23
+ }
24
+
25
+ describe('createContributionRegistry', () => {
26
+ it('resolves first-party before open, and lists both', () => {
27
+ const registry = makeRegistry();
28
+ registry.registerFirstParty('plan', 'builtin-plan');
29
+ registry.register('acme:gantt', 'acme-gantt');
30
+ expect(registry.get('plan')).toBe('builtin-plan');
31
+ expect(registry.get('acme:gantt')).toBe('acme-gantt');
32
+ expect(registry.has('nope')).toBe(false);
33
+ expect(registry.list()).toEqual(['acme:gantt', 'plan']);
34
+ expect(registry.listOpen()).toEqual(['acme:gantt']);
35
+ expect([...registry.entries().keys()].sort()).toEqual(['acme:gantt', 'plan']);
36
+ });
37
+
38
+ it('refuses to let the open set claim a reserved first-party kind', () => {
39
+ const registry = makeRegistry();
40
+ expect(registry.isReserved('diff')).toBe(true);
41
+ expect(() => registry.register('diff', 'hijack')).toThrow(/reserved/);
42
+ // The namespaced form is fine.
43
+ expect(() => registry.register('acme:diff', 'ok')).not.toThrow();
44
+ });
45
+
46
+ it('is idempotent for the identical entry and throws for a different one', () => {
47
+ const registry = makeRegistry();
48
+ registry.register('acme:gantt', 'entry');
49
+ expect(() => registry.register('acme:gantt', 'entry')).not.toThrow();
50
+ expect(() => registry.register('acme:gantt', 'other')).toThrow(
51
+ /already registered/,
52
+ );
53
+ registry.registerFirstParty('plan', 'builtin');
54
+ expect(() => registry.registerFirstParty('plan', 'builtin')).not.toThrow();
55
+ expect(() => registry.registerFirstParty('plan', 'other')).toThrow(
56
+ /already registered/,
57
+ );
58
+ });
59
+
60
+ it('resets only the OPEN set', () => {
61
+ const registry = makeRegistry();
62
+ registry.registerFirstParty('plan', 'builtin');
63
+ registry.register('acme:gantt', 'entry');
64
+ registry.__resetOpenForTests();
65
+ expect(registry.list()).toEqual(['plan']);
66
+ });
67
+
68
+ it('reports — never swallows — a duplicate under FirstWins', () => {
69
+ const onDuplicate = vi.fn();
70
+ const registry = createContributionRegistry<string>({
71
+ name: 'overlay',
72
+ duplicatePolicy: DuplicateContributionPolicy.FirstWins,
73
+ onDuplicate,
74
+ });
75
+ registry.register('k', 'first');
76
+ registry.register('k', 'second');
77
+ expect(registry.get('k')).toBe('first');
78
+ expect(onDuplicate).toHaveBeenCalledWith('k', 'first', 'second');
79
+ });
80
+
81
+ it('refuses FirstWins without a reporter', () => {
82
+ expect(() =>
83
+ createContributionRegistry<string>({
84
+ name: 'overlay',
85
+ duplicatePolicy: DuplicateContributionPolicy.FirstWins,
86
+ }),
87
+ ).toThrow(/onDuplicate/);
88
+ });
89
+ });
90
+
91
+ describe('createRenderableContributionRegistry', () => {
92
+ const registry = createRenderableContributionRegistry<string>({
93
+ name: 'renderable',
94
+ reservedKinds: ['plan'],
95
+ });
96
+ registry.registerFirstParty<{ label: string }>('plan', {
97
+ version: 2,
98
+ validate: (payload) =>
99
+ typeof payload === 'object' &&
100
+ payload !== null &&
101
+ typeof (payload as { label?: unknown }).label === 'string'
102
+ ? (payload as { label: string })
103
+ : null,
104
+ render: (payload) => `plan:${payload.label}`,
105
+ });
106
+
107
+ it('renders a matching envelope', () => {
108
+ const resolution = registry.resolve({
109
+ kind: 'plan',
110
+ version: 1,
111
+ payload: { label: 'ship it' },
112
+ });
113
+ expect(resolution).toEqual({
114
+ matched: true,
115
+ kind: 'plan',
116
+ version: 2,
117
+ rendered: 'plan:ship it',
118
+ });
119
+ });
120
+
121
+ it('never throws — it returns a typed reason instead', () => {
122
+ expect(
123
+ registry.resolve({ kind: 'nope', version: 1, payload: {} }),
124
+ ).toMatchObject({
125
+ matched: false,
126
+ reason: ContributionFallbackReason.UnknownKind,
127
+ });
128
+ expect(
129
+ registry.resolve({ kind: 'plan', version: 99, payload: {} }),
130
+ ).toMatchObject({
131
+ matched: false,
132
+ reason: ContributionFallbackReason.UnsupportedVersion,
133
+ });
134
+ expect(
135
+ registry.resolve({ kind: 'plan', version: 1, payload: { label: 7 } }),
136
+ ).toMatchObject({
137
+ matched: false,
138
+ reason: ContributionFallbackReason.InvalidPayload,
139
+ });
140
+ });
141
+ });
@@ -0,0 +1,202 @@
1
+ /**
2
+ * `createContributionRegistry` — the ONE two-layer closed+open registry core
3
+ * the Xema frontend uses everywhere a biome may contribute into a set the
4
+ * platform also ships a closed first-party version of.
5
+ *
6
+ * Before this module the exact same bookkeeping was hand-written four times
7
+ * (in-chat widgets, biome output renderers, open reply variants, and — next —
8
+ * Vista surfaces), each with slightly different guards. This is that core,
9
+ * extracted once (reuse register U1).
10
+ *
11
+ * ── The two layers ──────────────────────────────────────────────────────────
12
+ * • a CLOSED first-party set, registered at module load and keyed by a
13
+ * platform enum value;
14
+ * • an OPEN biome set, registered at runtime (a biome registers from its
15
+ * `FrontendBiome.init()` hook) and keyed by a namespaced `<biomeId>:<kind>`
16
+ * slug.
17
+ *
18
+ * ── The invariants (all fail-loud, none silent) ─────────────────────────────
19
+ * • RESERVED KINDS. Every first-party kind is reserved: `register()` throws
20
+ * if a biome tries to claim one. The open set can never shadow the closed
21
+ * one.
22
+ * • DUPLICATE GUARD. Registering the EXACT same entry object twice is a
23
+ * no-op (this is what tolerates React Fast Refresh / a double-invoked
24
+ * `init()`); registering a DIFFERENT entry for a kind that is already
25
+ * taken is an error — two biomes cannot silently shadow each other.
26
+ * • The one exception is {@link DuplicateContributionPolicy.FirstWins}, for
27
+ * registries rebuilt on a hot path where a throw would crash a render
28
+ * (the biome output-renderer overlay). It is NOT a silent fallback: an
29
+ * `onDuplicate` reporter is REQUIRED, and the registry factory throws at
30
+ * construction if it is missing.
31
+ *
32
+ * Resolution itself lives in the caller (or in `renderable-registry.ts` for the
33
+ * versioned + payload-validated flavour) and NEVER throws.
34
+ */
35
+
36
+ /** What to do when a DIFFERENT entry is registered for an already-taken kind. */
37
+ export enum DuplicateContributionPolicy {
38
+ /**
39
+ * Throw. The default, and correct for every registry whose registrations
40
+ * happen once at module load or once per biome `init()`.
41
+ */
42
+ Throw = 'throw',
43
+ /**
44
+ * Keep the first registration and report the loser through `onDuplicate`.
45
+ * For registries REBUILT on a hot path (e.g. per render) where throwing
46
+ * would take down the UI. Requires `onDuplicate` — there is no silent mode.
47
+ */
48
+ FirstWins = 'first-wins',
49
+ }
50
+
51
+ /** Options for {@link createContributionRegistry}. */
52
+ export interface ContributionRegistryOptions<TEntry> {
53
+ /** Registry name, used verbatim in every thrown message. */
54
+ readonly name: string;
55
+ /**
56
+ * The CLOSED first-party kinds. Reserved: `register()` refuses them so a
57
+ * biome can never shadow a platform kind. Typically `Object.values(SomeEnum)`.
58
+ */
59
+ readonly reservedKinds?: Iterable<string>;
60
+ /** Duplicate handling. Defaults to {@link DuplicateContributionPolicy.Throw}. */
61
+ readonly duplicatePolicy?: DuplicateContributionPolicy;
62
+ /**
63
+ * Reporter for a rejected duplicate under
64
+ * {@link DuplicateContributionPolicy.FirstWins}. REQUIRED under that policy.
65
+ */
66
+ readonly onDuplicate?: (
67
+ kind: string,
68
+ existing: TEntry,
69
+ rejected: TEntry,
70
+ ) => void;
71
+ }
72
+
73
+ /** The two-layer registry surface. */
74
+ export interface ContributionRegistry<TEntry> {
75
+ /** Registry name (diagnostics). */
76
+ readonly name: string;
77
+ /**
78
+ * Register a FIRST-PARTY entry for a closed platform kind. Called once per
79
+ * kind at module load.
80
+ */
81
+ registerFirstParty(kind: string, entry: TEntry): void;
82
+ /**
83
+ * OPEN seam: register a biome entry under its namespaced `<biomeId>:<kind>`
84
+ * slug. Throws when the slug is a reserved first-party kind.
85
+ */
86
+ register(kind: string, entry: TEntry): void;
87
+ /** True when SOME entry (first-party or biome) is registered for the kind. */
88
+ has(kind: string): boolean;
89
+ /** The entry for a kind — first-party wins — or `undefined`. */
90
+ get(kind: string): TEntry | undefined;
91
+ /** True when the kind belongs to the closed first-party set. */
92
+ isReserved(kind: string): boolean;
93
+ /** Every registered kind (sorted) — diagnostics + tests. */
94
+ list(): readonly string[];
95
+ /** Only the OPEN (biome-contributed) kinds (sorted). */
96
+ listOpen(): readonly string[];
97
+ /** Flattened `kind -> entry` view, first-party wins. Diagnostics + overlays. */
98
+ entries(): ReadonlyMap<string, TEntry>;
99
+ /** Test-only: clear the OPEN set (the first-party set stays). */
100
+ __resetOpenForTests(): void;
101
+ }
102
+
103
+ export function createContributionRegistry<TEntry>(
104
+ options: ContributionRegistryOptions<TEntry>,
105
+ ): ContributionRegistry<TEntry> {
106
+ const {
107
+ name,
108
+ reservedKinds,
109
+ duplicatePolicy = DuplicateContributionPolicy.Throw,
110
+ onDuplicate,
111
+ } = options;
112
+
113
+ if (
114
+ duplicatePolicy === DuplicateContributionPolicy.FirstWins &&
115
+ onDuplicate === undefined
116
+ ) {
117
+ throw new Error(
118
+ `${name} registry: DuplicateContributionPolicy.FirstWins requires an ` +
119
+ `'onDuplicate' reporter — a dropped contribution must never be silent.`,
120
+ );
121
+ }
122
+
123
+ const reserved = new Set<string>(reservedKinds ?? []);
124
+ const firstParty = new Map<string, TEntry>();
125
+ const open = new Map<string, TEntry>();
126
+
127
+ /**
128
+ * Idempotent for the IDENTICAL entry (Fast Refresh / double-invoked
129
+ * `init()`); an error for a DIFFERENT one. Returns whether the entry landed.
130
+ */
131
+ function put(target: Map<string, TEntry>, kind: string, entry: TEntry): void {
132
+ const existing = target.get(kind);
133
+ if (existing === undefined) {
134
+ target.set(kind, entry);
135
+ return;
136
+ }
137
+ if (existing === entry) return;
138
+ if (duplicatePolicy === DuplicateContributionPolicy.FirstWins) {
139
+ // `onDuplicate` is guaranteed present under this policy (checked above).
140
+ (onDuplicate as (k: string, e: TEntry, r: TEntry) => void)(
141
+ kind,
142
+ existing,
143
+ entry,
144
+ );
145
+ return;
146
+ }
147
+ throw new Error(
148
+ `${name} registry: a DIFFERENT entry is already registered for kind ` +
149
+ `'${kind}'. Two contributors cannot claim the same slug.`,
150
+ );
151
+ }
152
+
153
+ return {
154
+ name,
155
+
156
+ registerFirstParty(kind: string, entry: TEntry): void {
157
+ put(firstParty, kind, entry);
158
+ },
159
+
160
+ register(kind: string, entry: TEntry): void {
161
+ if (reserved.has(kind)) {
162
+ throw new Error(
163
+ `${name} registry: '${kind}' is a reserved first-party kind and ` +
164
+ `cannot be overridden by a biome. Use a namespaced ` +
165
+ `'<biomeId>:${kind}' slug.`,
166
+ );
167
+ }
168
+ put(open, kind, entry);
169
+ },
170
+
171
+ has(kind: string): boolean {
172
+ return firstParty.has(kind) || open.has(kind);
173
+ },
174
+
175
+ get(kind: string): TEntry | undefined {
176
+ return firstParty.get(kind) ?? open.get(kind);
177
+ },
178
+
179
+ isReserved(kind: string): boolean {
180
+ return reserved.has(kind);
181
+ },
182
+
183
+ list(): readonly string[] {
184
+ return [...firstParty.keys(), ...open.keys()].sort();
185
+ },
186
+
187
+ listOpen(): readonly string[] {
188
+ return [...open.keys()].sort();
189
+ },
190
+
191
+ entries(): ReadonlyMap<string, TEntry> {
192
+ // First-party last so it wins on a key present in both (which `register`
193
+ // already forbids for reserved kinds, but `entries()` must not depend on
194
+ // that to be correct).
195
+ return new Map<string, TEntry>([...open, ...firstParty]);
196
+ },
197
+
198
+ __resetOpenForTests(): void {
199
+ open.clear();
200
+ },
201
+ };
202
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The shared two-layer (closed first-party + open biome) contribution registry
3
+ * core, and its versioned/validated renderable flavour.
4
+ *
5
+ * One implementation, four consumers: in-chat ChatWidgets, biome output
6
+ * renderers, open reply variants, and Vista surfaces.
7
+ */
8
+ export * from './contribution-registry';
9
+ export * from './renderable-registry';
@@ -0,0 +1,142 @@
1
+ /**
2
+ * The RENDERABLE flavour of {@link createContributionRegistry}: a two-layer
3
+ * closed+open registry whose entries are versioned renderers with a narrowing
4
+ * payload validator, plus the fail-safe resolution every such plane needs.
5
+ *
6
+ * This is the shape the in-chat ChatWidget plane and the Vista render plane
7
+ * both want: an envelope `{ kind, version, payload }` arrives from an agent,
8
+ * and the frontend must turn it into something drawable WITHOUT ever throwing
9
+ * and WITHOUT ever silently drawing a coerced half-widget. Resolution returns a
10
+ * typed reason instead, which the caller renders as a safe fallback card.
11
+ */
12
+ import {
13
+ createContributionRegistry,
14
+ type ContributionRegistry,
15
+ type ContributionRegistryOptions,
16
+ } from './contribution-registry';
17
+
18
+ /**
19
+ * Why an envelope fell back to the safe card. Populated on the resolution so
20
+ * the Studio debugger (and dev logs) can see WHY — mirrors the Model Resolution
21
+ * Matrix's `ResolvedModelDecision`. Closed set.
22
+ */
23
+ export enum ContributionFallbackReason {
24
+ UnknownKind = 'unknown-kind',
25
+ InvalidPayload = 'invalid-payload',
26
+ UnsupportedVersion = 'unsupported-version',
27
+ }
28
+
29
+ /** The minimum an agent-emitted envelope must carry to be resolvable. */
30
+ export interface ContributionEnvelope {
31
+ readonly kind: string;
32
+ readonly version: number;
33
+ readonly payload: unknown;
34
+ }
35
+
36
+ /**
37
+ * A versioned renderer. `validate` narrows the wire payload to the renderer's
38
+ * own type (returning `null` routes to the fallback with `InvalidPayload`) and
39
+ * MUST NOT throw; `render` draws from the narrowed payload.
40
+ */
41
+ export interface RenderableContributionEntry<TRendered, TPayload = unknown> {
42
+ /** Highest schema version this renderer supports. */
43
+ readonly version: number;
44
+ /** Narrowing validator. Returns the typed payload, or `null`. MUST NOT throw. */
45
+ validate(payload: unknown): TPayload | null;
46
+ /** Draw from the narrowed payload. */
47
+ render(payload: TPayload): TRendered;
48
+ }
49
+
50
+ /** The outcome of resolving an envelope — inspectable for the Studio debugger. */
51
+ export type RenderableResolution<TRendered> =
52
+ | {
53
+ readonly matched: true;
54
+ readonly kind: string;
55
+ readonly version: number;
56
+ readonly rendered: TRendered;
57
+ }
58
+ | {
59
+ readonly matched: false;
60
+ readonly kind: string;
61
+ readonly reason: ContributionFallbackReason;
62
+ };
63
+
64
+ /** A {@link ContributionRegistry} of versioned renderers, plus `resolve`. */
65
+ export interface RenderableContributionRegistry<TRendered>
66
+ extends Omit<
67
+ ContributionRegistry<RenderableContributionEntry<TRendered>>,
68
+ 'registerFirstParty' | 'register'
69
+ > {
70
+ registerFirstParty<TPayload>(
71
+ kind: string,
72
+ entry: RenderableContributionEntry<TRendered, TPayload>,
73
+ ): void;
74
+ register<TPayload>(
75
+ kind: string,
76
+ entry: RenderableContributionEntry<TRendered, TPayload>,
77
+ ): void;
78
+ /**
79
+ * Resolve an envelope. Pure + deterministic so it can run in render, and it
80
+ * NEVER throws — an unknown kind, a payload the entry rejects, or a `version`
81
+ * newer than the entry supports ALL yield `matched: false` with a typed
82
+ * reason the caller renders as the safe fallback card.
83
+ */
84
+ resolve(envelope: ContributionEnvelope): RenderableResolution<TRendered>;
85
+ }
86
+
87
+ export function createRenderableContributionRegistry<TRendered>(
88
+ options: ContributionRegistryOptions<RenderableContributionEntry<TRendered>>,
89
+ ): RenderableContributionRegistry<TRendered> {
90
+ const registry =
91
+ createContributionRegistry<RenderableContributionEntry<TRendered>>(options);
92
+
93
+ return {
94
+ ...registry,
95
+
96
+ registerFirstParty<TPayload>(
97
+ kind: string,
98
+ entry: RenderableContributionEntry<TRendered, TPayload>,
99
+ ): void {
100
+ registry.registerFirstParty(kind, entry);
101
+ },
102
+
103
+ register<TPayload>(
104
+ kind: string,
105
+ entry: RenderableContributionEntry<TRendered, TPayload>,
106
+ ): void {
107
+ registry.register(kind, entry);
108
+ },
109
+
110
+ resolve(envelope: ContributionEnvelope): RenderableResolution<TRendered> {
111
+ const entry = registry.get(envelope.kind);
112
+ if (entry === undefined) {
113
+ return {
114
+ matched: false,
115
+ kind: envelope.kind,
116
+ reason: ContributionFallbackReason.UnknownKind,
117
+ };
118
+ }
119
+ if (envelope.version > entry.version) {
120
+ return {
121
+ matched: false,
122
+ kind: envelope.kind,
123
+ reason: ContributionFallbackReason.UnsupportedVersion,
124
+ };
125
+ }
126
+ const narrowed = entry.validate(envelope.payload);
127
+ if (narrowed === null) {
128
+ return {
129
+ matched: false,
130
+ kind: envelope.kind,
131
+ reason: ContributionFallbackReason.InvalidPayload,
132
+ };
133
+ }
134
+ return {
135
+ matched: true,
136
+ kind: envelope.kind,
137
+ version: entry.version,
138
+ rendered: entry.render(narrowed),
139
+ };
140
+ },
141
+ };
142
+ }
@@ -0,0 +1,11 @@
1
+ // ═══════════════════════════════════════════════════════════════════════════
2
+ // @xemahq/ui-kernel/pdf — canvas-rendered PDF preview surface
3
+ //
4
+ // Split into a DEDICATED subpath (out of the `/ui` barrel) because it pulls in
5
+ // `react-pdf` → `pdfjs-dist` (~1.9 MB). Keeping it here lets `@xemahq/ui-kernel/ui`
6
+ // (and therefore `@xemahq/app-ui`'s AppShell) stay tree-shakeable: a consumer
7
+ // that never renders a PDF never bundles pdf.js. Import from this subpath only
8
+ // when you actually need the viewer.
9
+ // ═══════════════════════════════════════════════════════════════════════════
10
+
11
+ export { PdfPreview, type PdfPreviewProps } from '../ui/pdf/pdf-preview';
@@ -43,10 +43,30 @@ function scalarSchema(field: CaptureFieldSpec): z.ZodTypeAny {
43
43
  }
44
44
  }
45
45
 
46
+ /** True when `value` parses as JSON. Total — never throws. */
47
+ export function isParsableJson(value: string): boolean {
48
+ try {
49
+ JSON.parse(value);
50
+ return true;
51
+ } catch {
52
+ return false;
53
+ }
54
+ }
55
+
46
56
  function fieldSchema(field: CaptureFieldSpec): z.ZodTypeAny {
47
57
  let base: z.ZodTypeAny;
48
58
  if (field.type === CaptureFieldType.Object) {
49
59
  base = objectSchema(field.fields ?? []);
60
+ } else if (field.type === CaptureFieldType.Json) {
61
+ // A JSON blob is carried as TEXT and validated as parseable. `''` passes
62
+ // the shape check so an optional blank field stays valid; requiredness is
63
+ // enforced by the `.min(1)` below, not by the parse rule.
64
+ const text = field.required
65
+ ? z.string().min(1, { message: `${field.label} is required` })
66
+ : z.string();
67
+ base = text.refine((v) => v === '' || isParsableJson(v), {
68
+ message: `${field.label} must be valid JSON`,
69
+ });
50
70
  } else if (field.type === CaptureFieldType.List) {
51
71
  let arr = z.array(objectSchema(field.fields ?? []));
52
72
  if (typeof field.min === 'number') arr = arr.min(field.min, { message: `${field.label} needs at least ${field.min} item(s)` });
@@ -58,6 +78,8 @@ function fieldSchema(field: CaptureFieldSpec): z.ZodTypeAny {
58
78
  field.required &&
59
79
  (field.type === CaptureFieldType.String ||
60
80
  field.type === CaptureFieldType.Text ||
81
+ field.type === CaptureFieldType.Email ||
82
+ field.type === CaptureFieldType.Url ||
61
83
  field.type === CaptureFieldType.User ||
62
84
  field.type === CaptureFieldType.Reference ||
63
85
  field.type === CaptureFieldType.Datetime ||