@xemahq/ui-kernel 0.9.0 → 0.9.2

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 (444) hide show
  1. package/README.md +2 -2
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +1 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/lib/biome-host/biome-builders.d.ts.map +1 -1
  7. package/dist/lib/biome-host/biome-builders.js +3 -1
  8. package/dist/lib/biome-host/biome-builders.js.map +1 -1
  9. package/dist/lib/biome-host/biome-registry.d.ts.map +1 -1
  10. package/dist/lib/biome-host/biome-registry.js +14 -9
  11. package/dist/lib/biome-host/biome-registry.js.map +1 -1
  12. package/dist/lib/biome-host/biome-scope-hooks.d.ts +11 -0
  13. package/dist/lib/biome-host/biome-scope-hooks.d.ts.map +1 -0
  14. package/dist/lib/biome-host/biome-scope-hooks.js +25 -0
  15. package/dist/lib/biome-host/biome-scope-hooks.js.map +1 -0
  16. package/dist/lib/biome-host/biome-scope.d.ts +1 -10
  17. package/dist/lib/biome-host/biome-scope.d.ts.map +1 -1
  18. package/dist/lib/biome-host/biome-scope.js +1 -24
  19. package/dist/lib/biome-host/biome-scope.js.map +1 -1
  20. package/dist/lib/biome-host/biome-scoped-query.d.ts +1 -1
  21. package/dist/lib/biome-host/biome-scoped-query.d.ts.map +1 -1
  22. package/dist/lib/biome-host/biome-scoped-query.js +1 -1
  23. package/dist/lib/biome-host/biome-scoped-query.js.map +1 -1
  24. package/dist/lib/biome-host/create-biome-orval-config.js +2 -2
  25. package/dist/lib/biome-host/create-biome-orval-config.js.map +1 -1
  26. package/dist/lib/biome-host/errors.js.map +1 -1
  27. package/dist/lib/biome-host/index.d.ts +1 -1
  28. package/dist/lib/biome-host/index.d.ts.map +1 -1
  29. package/dist/lib/biome-host/index.js +1 -1
  30. package/dist/lib/biome-host/index.js.map +1 -1
  31. package/dist/lib/biome-host/session-profiles.d.ts.map +1 -1
  32. package/dist/lib/biome-host/session-profiles.js +4 -1
  33. package/dist/lib/biome-host/session-profiles.js.map +1 -1
  34. package/dist/lib/capabilities/capability-context.d.ts +9 -0
  35. package/dist/lib/capabilities/capability-context.d.ts.map +1 -0
  36. package/dist/lib/capabilities/capability-context.js +13 -0
  37. package/dist/lib/capabilities/capability-context.js.map +1 -0
  38. package/dist/lib/capabilities/capability-provider.d.ts +2 -8
  39. package/dist/lib/capabilities/capability-provider.d.ts.map +1 -1
  40. package/dist/lib/capabilities/capability-provider.js +1 -12
  41. package/dist/lib/capabilities/capability-provider.js.map +1 -1
  42. package/dist/lib/capabilities/index.d.ts +1 -0
  43. package/dist/lib/capabilities/index.d.ts.map +1 -1
  44. package/dist/lib/capabilities/index.js +1 -0
  45. package/dist/lib/capabilities/index.js.map +1 -1
  46. package/dist/lib/capabilities/use-capability.d.ts.map +1 -1
  47. package/dist/lib/capabilities/use-capability.js +1 -1
  48. package/dist/lib/capabilities/use-capability.js.map +1 -1
  49. package/dist/lib/contribution-registry/contribution-registry.d.ts +24 -0
  50. package/dist/lib/contribution-registry/contribution-registry.d.ts.map +1 -0
  51. package/dist/lib/contribution-registry/contribution-registry.js +67 -0
  52. package/dist/lib/contribution-registry/contribution-registry.js.map +1 -0
  53. package/dist/lib/contribution-registry/index.d.ts +3 -0
  54. package/dist/lib/contribution-registry/index.d.ts.map +1 -0
  55. package/dist/lib/contribution-registry/index.js +3 -0
  56. package/dist/lib/contribution-registry/index.js.map +1 -0
  57. package/dist/lib/contribution-registry/renderable-registry.d.ts +33 -0
  58. package/dist/lib/contribution-registry/renderable-registry.d.ts.map +1 -0
  59. package/dist/lib/contribution-registry/renderable-registry.js +51 -0
  60. package/dist/lib/contribution-registry/renderable-registry.js.map +1 -0
  61. package/dist/lib/system-bus/deeplink.js.map +1 -1
  62. package/dist/lib/system-bus/host-ports.d.ts +2 -1
  63. package/dist/lib/system-bus/host-ports.d.ts.map +1 -1
  64. package/dist/lib/system-bus/intent-registry.d.ts.map +1 -1
  65. package/dist/lib/system-bus/intent-registry.js.map +1 -1
  66. package/dist/offline/index.d.ts +2 -1
  67. package/dist/offline/index.d.ts.map +1 -1
  68. package/dist/offline/index.js +2 -1
  69. package/dist/offline/index.js.map +1 -1
  70. package/dist/offline/offline-status-badge.js +1 -1
  71. package/dist/offline/offline-status-badge.js.map +1 -1
  72. package/dist/offline/outbox.js.map +1 -1
  73. package/dist/offline/react-hooks.d.ts +7 -0
  74. package/dist/offline/react-hooks.d.ts.map +1 -0
  75. package/dist/offline/react-hooks.js +25 -0
  76. package/dist/offline/react-hooks.js.map +1 -0
  77. package/dist/offline/react.d.ts +0 -4
  78. package/dist/offline/react.d.ts.map +1 -1
  79. package/dist/offline/react.js +2 -24
  80. package/dist/offline/react.js.map +1 -1
  81. package/dist/offline/storage.d.ts.map +1 -1
  82. package/dist/offline/storage.js +8 -5
  83. package/dist/offline/storage.js.map +1 -1
  84. package/dist/registry/index.d.ts +1 -0
  85. package/dist/registry/index.d.ts.map +1 -1
  86. package/dist/registry/index.js +1 -0
  87. package/dist/registry/index.js.map +1 -1
  88. package/dist/registry/lib/primitives/SessionEventCard.d.ts.map +1 -1
  89. package/dist/registry/lib/primitives/SessionEventCard.js +1 -1
  90. package/dist/registry/lib/primitives/SessionEventCard.js.map +1 -1
  91. package/dist/registry/lib/session-context-provider.d.ts +1 -3
  92. package/dist/registry/lib/session-context-provider.d.ts.map +1 -1
  93. package/dist/registry/lib/session-context-provider.js +2 -15
  94. package/dist/registry/lib/session-context-provider.js.map +1 -1
  95. package/dist/registry/lib/session-context.d.ts +5 -0
  96. package/dist/registry/lib/session-context.d.ts.map +1 -0
  97. package/dist/registry/lib/session-context.js +15 -0
  98. package/dist/registry/lib/session-context.js.map +1 -0
  99. package/dist/registry/lib/session-selectors.d.ts.map +1 -1
  100. package/dist/registry/lib/session-selectors.js +3 -1
  101. package/dist/registry/lib/session-selectors.js.map +1 -1
  102. package/dist/ui/branding/app-branding-context.d.ts +9 -0
  103. package/dist/ui/branding/app-branding-context.d.ts.map +1 -0
  104. package/dist/ui/branding/app-branding-context.js +10 -0
  105. package/dist/ui/branding/app-branding-context.js.map +1 -0
  106. package/dist/ui/branding/app-branding-provider.d.ts +0 -6
  107. package/dist/ui/branding/app-branding-provider.d.ts.map +1 -1
  108. package/dist/ui/branding/app-branding-provider.js +1 -8
  109. package/dist/ui/branding/app-branding-provider.js.map +1 -1
  110. package/dist/ui/capture/field-spec-to-zod.d.ts +1 -0
  111. package/dist/ui/capture/field-spec-to-zod.d.ts.map +1 -1
  112. package/dist/ui/capture/field-spec-to-zod.js +19 -0
  113. package/dist/ui/capture/field-spec-to-zod.js.map +1 -1
  114. package/dist/ui/capture/field-spec-validate.d.ts +4 -0
  115. package/dist/ui/capture/field-spec-validate.d.ts.map +1 -0
  116. package/dist/ui/capture/field-spec-validate.js +129 -0
  117. package/dist/ui/capture/field-spec-validate.js.map +1 -0
  118. package/dist/ui/capture/field-spec.d.ts +13 -1
  119. package/dist/ui/capture/field-spec.d.ts.map +1 -1
  120. package/dist/ui/capture/field-spec.js +25 -0
  121. package/dist/ui/capture/field-spec.js.map +1 -1
  122. package/dist/ui/capture/index.d.ts +4 -2
  123. package/dist/ui/capture/index.d.ts.map +1 -1
  124. package/dist/ui/capture/index.js +4 -2
  125. package/dist/ui/capture/index.js.map +1 -1
  126. package/dist/ui/capture/schema-field-input.d.ts.map +1 -1
  127. package/dist/ui/capture/schema-field-input.js +40 -13
  128. package/dist/ui/capture/schema-field-input.js.map +1 -1
  129. package/dist/ui/capture/submit-values.d.ts +6 -0
  130. package/dist/ui/capture/submit-values.d.ts.map +1 -0
  131. package/dist/ui/capture/submit-values.js +28 -0
  132. package/dist/ui/capture/submit-values.js.map +1 -0
  133. package/dist/ui/capture/use-prefill.d.ts.map +1 -1
  134. package/dist/ui/capture/use-prefill.js +3 -1
  135. package/dist/ui/capture/use-prefill.js.map +1 -1
  136. package/dist/ui/capture/use-wizard.d.ts +1 -1
  137. package/dist/ui/capture/use-wizard.d.ts.map +1 -1
  138. package/dist/ui/capture/use-wizard.js +1 -1
  139. package/dist/ui/capture/use-wizard.js.map +1 -1
  140. package/dist/ui/capture/wizard.d.ts.map +1 -1
  141. package/dist/ui/capture/wizard.js.map +1 -1
  142. package/dist/ui/index.d.ts +6 -1
  143. package/dist/ui/index.d.ts.map +1 -1
  144. package/dist/ui/index.js +6 -1
  145. package/dist/ui/index.js.map +1 -1
  146. package/dist/ui/primitives/alert-dialog.js +1 -1
  147. package/dist/ui/primitives/alert-dialog.js.map +1 -1
  148. package/dist/ui/primitives/badge-variants.d.ts +4 -0
  149. package/dist/ui/primitives/badge-variants.d.ts.map +1 -0
  150. package/dist/ui/primitives/badge-variants.js +15 -0
  151. package/dist/ui/primitives/badge-variants.js.map +1 -0
  152. package/dist/ui/primitives/badge.d.ts +3 -5
  153. package/dist/ui/primitives/badge.d.ts.map +1 -1
  154. package/dist/ui/primitives/badge.js +2 -15
  155. package/dist/ui/primitives/badge.js.map +1 -1
  156. package/dist/ui/primitives/button-variants.d.ts +5 -0
  157. package/dist/ui/primitives/button-variants.d.ts.map +1 -0
  158. package/dist/ui/primitives/button-variants.js +24 -0
  159. package/dist/ui/primitives/button-variants.js.map +1 -0
  160. package/dist/ui/primitives/button.d.ts +3 -6
  161. package/dist/ui/primitives/button.d.ts.map +1 -1
  162. package/dist/ui/primitives/button.js +2 -24
  163. package/dist/ui/primitives/button.js.map +1 -1
  164. package/dist/ui/primitives/form-stepper.d.ts +1 -13
  165. package/dist/ui/primitives/form-stepper.d.ts.map +1 -1
  166. package/dist/ui/primitives/form-stepper.js +1 -6
  167. package/dist/ui/primitives/form-stepper.js.map +1 -1
  168. package/dist/ui/primitives/form-stepper.types.d.ts +14 -0
  169. package/dist/ui/primitives/form-stepper.types.d.ts.map +1 -0
  170. package/dist/ui/primitives/form-stepper.types.js +7 -0
  171. package/dist/ui/primitives/form-stepper.types.js.map +1 -0
  172. package/dist/ui/primitives/overflow-tabs.d.ts +5 -0
  173. package/dist/ui/primitives/overflow-tabs.d.ts.map +1 -1
  174. package/dist/ui/primitives/overflow-tabs.js +4 -4
  175. package/dist/ui/primitives/overflow-tabs.js.map +1 -1
  176. package/dist/ui/primitives/preview-device-frame.js +1 -1
  177. package/dist/ui/primitives/preview-device-frame.js.map +1 -1
  178. package/dist/ui/primitives/tag-multi-select.d.ts.map +1 -1
  179. package/dist/ui/primitives/tag-multi-select.js +1 -1
  180. package/dist/ui/primitives/tag-multi-select.js.map +1 -1
  181. package/dist/ui/primitives/url-preview-chrome.d.ts +8 -0
  182. package/dist/ui/primitives/url-preview-chrome.d.ts.map +1 -0
  183. package/dist/ui/primitives/url-preview-chrome.js +40 -0
  184. package/dist/ui/primitives/url-preview-chrome.js.map +1 -0
  185. package/dist/vista/GenericCatalogueSurface.d.ts +10 -0
  186. package/dist/vista/GenericCatalogueSurface.d.ts.map +1 -0
  187. package/dist/vista/GenericCatalogueSurface.js +80 -0
  188. package/dist/vista/GenericCatalogueSurface.js.map +1 -0
  189. package/dist/vista/SurfaceFallbackCard.d.ts +9 -0
  190. package/dist/vista/SurfaceFallbackCard.d.ts.map +1 -0
  191. package/dist/vista/SurfaceFallbackCard.js +44 -0
  192. package/dist/vista/SurfaceFallbackCard.js.map +1 -0
  193. package/dist/vista/VistaPanel.d.ts +21 -0
  194. package/dist/vista/VistaPanel.d.ts.map +1 -0
  195. package/dist/vista/VistaPanel.js +31 -0
  196. package/dist/vista/VistaPanel.js.map +1 -0
  197. package/dist/vista/html/CustomUiFrame.d.ts +20 -0
  198. package/dist/vista/html/CustomUiFrame.d.ts.map +1 -0
  199. package/dist/vista/html/CustomUiFrame.js +69 -0
  200. package/dist/vista/html/CustomUiFrame.js.map +1 -0
  201. package/dist/vista/html/custom-ui-frame-bridge.d.ts +13 -0
  202. package/dist/vista/html/custom-ui-frame-bridge.d.ts.map +1 -0
  203. package/dist/vista/html/custom-ui-frame-bridge.js +30 -0
  204. package/dist/vista/html/custom-ui-frame-bridge.js.map +1 -0
  205. package/dist/vista/html/custom-ui-frame-contract.d.ts +29 -0
  206. package/dist/vista/html/custom-ui-frame-contract.d.ts.map +1 -0
  207. package/dist/vista/html/custom-ui-frame-contract.js +16 -0
  208. package/dist/vista/html/custom-ui-frame-contract.js.map +1 -0
  209. package/dist/vista/html/custom-ui-intents.d.ts +20 -0
  210. package/dist/vista/html/custom-ui-intents.d.ts.map +1 -0
  211. package/dist/vista/html/custom-ui-intents.js +57 -0
  212. package/dist/vista/html/custom-ui-intents.js.map +1 -0
  213. package/dist/vista/html/custom-ui-srcdoc.d.ts +17 -0
  214. package/dist/vista/html/custom-ui-srcdoc.d.ts.map +1 -0
  215. package/dist/vista/html/custom-ui-srcdoc.js +70 -0
  216. package/dist/vista/html/custom-ui-srcdoc.js.map +1 -0
  217. package/dist/vista/html/index.d.ts +6 -0
  218. package/dist/vista/html/index.d.ts.map +1 -0
  219. package/dist/vista/html/index.js +6 -0
  220. package/dist/vista/html/index.js.map +1 -0
  221. package/dist/vista/index.d.ts +22 -0
  222. package/dist/vista/index.d.ts.map +1 -0
  223. package/dist/vista/index.js +22 -0
  224. package/dist/vista/index.js.map +1 -0
  225. package/dist/vista/surface-catalogue.d.ts +5 -0
  226. package/dist/vista/surface-catalogue.d.ts.map +1 -0
  227. package/dist/vista/surface-catalogue.js +30 -0
  228. package/dist/vista/surface-catalogue.js.map +1 -0
  229. package/dist/vista/surface-icons.d.ts +7 -0
  230. package/dist/vista/surface-icons.d.ts.map +1 -0
  231. package/dist/vista/surface-icons.js +26 -0
  232. package/dist/vista/surface-icons.js.map +1 -0
  233. package/dist/vista/surface-registry.d.ts +7 -0
  234. package/dist/vista/surface-registry.d.ts.map +1 -0
  235. package/dist/vista/surface-registry.js +7 -0
  236. package/dist/vista/surface-registry.js.map +1 -0
  237. package/dist/vista/surfaces/ChartSurface.d.ts +4 -0
  238. package/dist/vista/surfaces/ChartSurface.d.ts.map +1 -0
  239. package/dist/vista/surfaces/ChartSurface.js +17 -0
  240. package/dist/vista/surfaces/ChartSurface.js.map +1 -0
  241. package/dist/vista/surfaces/FilesSurface.d.ts +4 -0
  242. package/dist/vista/surfaces/FilesSurface.d.ts.map +1 -0
  243. package/dist/vista/surfaces/FilesSurface.js +77 -0
  244. package/dist/vista/surfaces/FilesSurface.js.map +1 -0
  245. package/dist/vista/surfaces/FormSurface.d.ts +4 -0
  246. package/dist/vista/surfaces/FormSurface.d.ts.map +1 -0
  247. package/dist/vista/surfaces/FormSurface.js +124 -0
  248. package/dist/vista/surfaces/FormSurface.js.map +1 -0
  249. package/dist/vista/surfaces/HtmlSurface.d.ts +4 -0
  250. package/dist/vista/surfaces/HtmlSurface.d.ts.map +1 -0
  251. package/dist/vista/surfaces/HtmlSurface.js +11 -0
  252. package/dist/vista/surfaces/HtmlSurface.js.map +1 -0
  253. package/dist/vista/surfaces/TableSurface.d.ts +4 -0
  254. package/dist/vista/surfaces/TableSurface.d.ts.map +1 -0
  255. package/dist/vista/surfaces/TableSurface.js +42 -0
  256. package/dist/vista/surfaces/TableSurface.js.map +1 -0
  257. package/dist/vista/surfaces/UrlSurface.d.ts +4 -0
  258. package/dist/vista/surfaces/UrlSurface.d.ts.map +1 -0
  259. package/dist/vista/surfaces/UrlSurface.js +7 -0
  260. package/dist/vista/surfaces/UrlSurface.js.map +1 -0
  261. package/dist/vista/surfaces/blob-surfaces.d.ts +6 -0
  262. package/dist/vista/surfaces/blob-surfaces.d.ts.map +1 -0
  263. package/dist/vista/surfaces/blob-surfaces.js +38 -0
  264. package/dist/vista/surfaces/blob-surfaces.js.map +1 -0
  265. package/dist/vista/surfaces/elicitation-transport.d.ts +27 -0
  266. package/dist/vista/surfaces/elicitation-transport.d.ts.map +1 -0
  267. package/dist/vista/surfaces/elicitation-transport.js +193 -0
  268. package/dist/vista/surfaces/elicitation-transport.js.map +1 -0
  269. package/dist/vista/surfaces/file-surface-utils.d.ts +13 -0
  270. package/dist/vista/surfaces/file-surface-utils.d.ts.map +1 -0
  271. package/dist/vista/surfaces/file-surface-utils.js +46 -0
  272. package/dist/vista/surfaces/file-surface-utils.js.map +1 -0
  273. package/dist/vista/surfaces/index.d.ts +12 -0
  274. package/dist/vista/surfaces/index.d.ts.map +1 -0
  275. package/dist/vista/surfaces/index.js +12 -0
  276. package/dist/vista/surfaces/index.js.map +1 -0
  277. package/dist/vista/surfaces/register-surfaces.d.ts +2 -0
  278. package/dist/vista/surfaces/register-surfaces.d.ts.map +1 -0
  279. package/dist/vista/surfaces/register-surfaces.js +80 -0
  280. package/dist/vista/surfaces/register-surfaces.js.map +1 -0
  281. package/dist/vista/surfaces/text-surfaces.d.ts +8 -0
  282. package/dist/vista/surfaces/text-surfaces.d.ts.map +1 -0
  283. package/dist/vista/surfaces/text-surfaces.js +54 -0
  284. package/dist/vista/surfaces/text-surfaces.js.map +1 -0
  285. package/dist/vista/use-vista-tabs.d.ts +30 -0
  286. package/dist/vista/use-vista-tabs.d.ts.map +1 -0
  287. package/dist/vista/use-vista-tabs.js +77 -0
  288. package/dist/vista/use-vista-tabs.js.map +1 -0
  289. package/dist/vista/vista-code-renderer-context.d.ts +9 -0
  290. package/dist/vista/vista-code-renderer-context.d.ts.map +1 -0
  291. package/dist/vista/vista-code-renderer-context.js +6 -0
  292. package/dist/vista/vista-code-renderer-context.js.map +1 -0
  293. package/dist/vista/vista-code-renderer.d.ts +7 -0
  294. package/dist/vista/vista-code-renderer.d.ts.map +1 -0
  295. package/dist/vista/vista-code-renderer.js +6 -0
  296. package/dist/vista/vista-code-renderer.js.map +1 -0
  297. package/dist/vista/vista-file-context.d.ts +8 -0
  298. package/dist/vista/vista-file-context.d.ts.map +1 -0
  299. package/dist/vista/vista-file-context.js +6 -0
  300. package/dist/vista/vista-file-context.js.map +1 -0
  301. package/dist/vista/vista-file-source.d.ts +15 -0
  302. package/dist/vista/vista-file-source.d.ts.map +1 -0
  303. package/dist/vista/vista-file-source.js +66 -0
  304. package/dist/vista/vista-file-source.js.map +1 -0
  305. package/dist/vista/vista-form-context.d.ts +13 -0
  306. package/dist/vista/vista-form-context.d.ts.map +1 -0
  307. package/dist/vista/vista-form-context.js +6 -0
  308. package/dist/vista/vista-form-context.js.map +1 -0
  309. package/dist/vista/vista-form-host.d.ts +7 -0
  310. package/dist/vista/vista-form-host.d.ts.map +1 -0
  311. package/dist/vista/vista-form-host.js +6 -0
  312. package/dist/vista/vista-form-host.js.map +1 -0
  313. package/dist/vista/vista-model.d.ts +12 -0
  314. package/dist/vista/vista-model.d.ts.map +1 -0
  315. package/dist/vista/vista-model.js +72 -0
  316. package/dist/vista/vista-model.js.map +1 -0
  317. package/dist/vista/vista-open-context.d.ts +7 -0
  318. package/dist/vista/vista-open-context.d.ts.map +1 -0
  319. package/dist/vista/vista-open-context.js +6 -0
  320. package/dist/vista/vista-open-context.js.map +1 -0
  321. package/dist/vista/vista-open-state.d.ts +5 -0
  322. package/dist/vista/vista-open-state.d.ts.map +1 -0
  323. package/dist/vista/vista-open-state.js +6 -0
  324. package/dist/vista/vista-open-state.js.map +1 -0
  325. package/dist/vista/vista-payloads.d.ts +106 -0
  326. package/dist/vista/vista-payloads.d.ts.map +1 -0
  327. package/dist/vista/vista-payloads.js +302 -0
  328. package/dist/vista/vista-payloads.js.map +1 -0
  329. package/dist/vista/vista-tabs-manifest.d.ts +17 -0
  330. package/dist/vista/vista-tabs-manifest.d.ts.map +1 -0
  331. package/dist/vista/vista-tabs-manifest.js +60 -0
  332. package/dist/vista/vista-tabs-manifest.js.map +1 -0
  333. package/dist/vista/vista-tools.d.ts +41 -0
  334. package/dist/vista/vista-tools.d.ts.map +1 -0
  335. package/dist/vista/vista-tools.js +113 -0
  336. package/dist/vista/vista-tools.js.map +1 -0
  337. package/package.json +4 -4
  338. package/src/index.ts +5 -0
  339. package/src/lib/biome-host/biome-builders.ts +4 -1
  340. package/src/lib/biome-host/biome-registry.ts +31 -12
  341. package/src/lib/biome-host/biome-scope-hooks.ts +39 -0
  342. package/src/lib/biome-host/biome-scope.tsx +1 -68
  343. package/src/lib/biome-host/biome-scoped-query.ts +4 -1
  344. package/src/lib/biome-host/create-biome-orval-config.ts +2 -2
  345. package/src/lib/biome-host/errors.ts +1 -1
  346. package/src/lib/biome-host/index.ts +1 -1
  347. package/src/lib/biome-host/session-profiles.ts +7 -1
  348. package/src/lib/capabilities/capability-context.ts +25 -0
  349. package/src/lib/capabilities/capability-provider.tsx +5 -34
  350. package/src/lib/capabilities/index.ts +1 -0
  351. package/src/lib/capabilities/use-capability.ts +4 -1
  352. package/src/lib/contribution-registry/contribution-registry.spec.ts +141 -0
  353. package/src/lib/contribution-registry/contribution-registry.ts +202 -0
  354. package/src/lib/contribution-registry/index.ts +9 -0
  355. package/src/lib/contribution-registry/renderable-registry.ts +142 -0
  356. package/src/lib/system-bus/deeplink.ts +1 -1
  357. package/src/lib/system-bus/host-ports.ts +2 -1
  358. package/src/lib/system-bus/intent-registry.ts +1 -2
  359. package/src/offline/index.ts +4 -2
  360. package/src/offline/offline-status-badge.tsx +1 -1
  361. package/src/offline/outbox.test.ts +23 -16
  362. package/src/offline/outbox.ts +1 -1
  363. package/src/offline/react-hooks.ts +37 -0
  364. package/src/offline/react.tsx +1 -40
  365. package/src/offline/storage.ts +11 -6
  366. package/src/registry/index.ts +1 -0
  367. package/src/registry/lib/primitives/SessionEventCard.tsx +4 -2
  368. package/src/registry/lib/session-context-provider.tsx +8 -25
  369. package/src/registry/lib/session-context.ts +21 -0
  370. package/src/registry/lib/session-selectors.ts +3 -1
  371. package/src/ui/branding/app-branding-context.ts +20 -0
  372. package/src/ui/branding/app-branding-provider.tsx +5 -27
  373. package/src/ui/capture/field-spec-to-zod.ts +22 -0
  374. package/src/ui/capture/field-spec-validate.ts +147 -0
  375. package/src/ui/capture/field-spec.ts +62 -0
  376. package/src/ui/capture/index.ts +9 -1
  377. package/src/ui/capture/schema-field-input.tsx +141 -15
  378. package/src/ui/capture/submit-values.test.ts +70 -0
  379. package/src/ui/capture/submit-values.ts +63 -0
  380. package/src/ui/capture/use-prefill.ts +4 -1
  381. package/src/ui/capture/use-wizard.ts +2 -2
  382. package/src/ui/capture/wizard.tsx +2 -1
  383. package/src/ui/index.ts +11 -2
  384. package/src/ui/primitives/alert-dialog.tsx +1 -1
  385. package/src/ui/primitives/badge-variants.ts +21 -0
  386. package/src/ui/primitives/badge.tsx +3 -19
  387. package/src/ui/primitives/button-variants.ts +31 -0
  388. package/src/ui/primitives/button.tsx +3 -28
  389. package/src/ui/primitives/form-stepper.tsx +1 -16
  390. package/src/ui/primitives/form-stepper.types.ts +15 -0
  391. package/src/ui/primitives/overflow-tabs.tsx +24 -4
  392. package/src/ui/primitives/preview-device-frame.tsx +1 -1
  393. package/src/ui/primitives/tag-multi-select.tsx +3 -4
  394. package/src/ui/primitives/url-preview-chrome.tsx +102 -0
  395. package/src/vista/GenericCatalogueSurface.tsx +177 -0
  396. package/src/vista/SurfaceFallbackCard.tsx +109 -0
  397. package/src/vista/VistaPanel.tsx +155 -0
  398. package/src/vista/form-payload.spec.ts +139 -0
  399. package/src/vista/html/CustomUiFrame.spec.tsx +125 -0
  400. package/src/vista/html/CustomUiFrame.tsx +204 -0
  401. package/src/vista/html/custom-ui-frame-bridge.spec.ts +191 -0
  402. package/src/vista/html/custom-ui-frame-bridge.ts +92 -0
  403. package/src/vista/html/custom-ui-frame-contract.ts +88 -0
  404. package/src/vista/html/custom-ui-intents.spec.ts +133 -0
  405. package/src/vista/html/custom-ui-intents.ts +151 -0
  406. package/src/vista/html/custom-ui-srcdoc.spec.ts +151 -0
  407. package/src/vista/html/custom-ui-srcdoc.ts +193 -0
  408. package/src/vista/html/index.ts +13 -0
  409. package/src/vista/index.ts +52 -0
  410. package/src/vista/surface-catalogue.spec.ts +140 -0
  411. package/src/vista/surface-catalogue.ts +84 -0
  412. package/src/vista/surface-icons.ts +57 -0
  413. package/src/vista/surface-registry.ts +56 -0
  414. package/src/vista/surfaces/ChartSurface.tsx +34 -0
  415. package/src/vista/surfaces/FilesSurface.tsx +202 -0
  416. package/src/vista/surfaces/FormSurface.tsx +363 -0
  417. package/src/vista/surfaces/HtmlSurface.tsx +43 -0
  418. package/src/vista/surfaces/TableSurface.tsx +99 -0
  419. package/src/vista/surfaces/UrlSurface.tsx +40 -0
  420. package/src/vista/surfaces/blob-surfaces.tsx +129 -0
  421. package/src/vista/surfaces/elicitation-transport.spec.ts +369 -0
  422. package/src/vista/surfaces/elicitation-transport.ts +353 -0
  423. package/src/vista/surfaces/file-surface-utils.ts +62 -0
  424. package/src/vista/surfaces/index.ts +24 -0
  425. package/src/vista/surfaces/register-surfaces.tsx +137 -0
  426. package/src/vista/surfaces/text-surfaces.tsx +119 -0
  427. package/src/vista/use-vista-tabs.ts +188 -0
  428. package/src/vista/vista-code-renderer-context.ts +16 -0
  429. package/src/vista/vista-code-renderer.tsx +34 -0
  430. package/src/vista/vista-file-context.ts +14 -0
  431. package/src/vista/vista-file-source.tsx +140 -0
  432. package/src/vista/vista-form-context.ts +20 -0
  433. package/src/vista/vista-form-host.tsx +53 -0
  434. package/src/vista/vista-model.ts +130 -0
  435. package/src/vista/vista-open-context.tsx +32 -0
  436. package/src/vista/vista-open-state.ts +11 -0
  437. package/src/vista/vista-payloads.ts +512 -0
  438. package/src/vista/vista-tabs-manifest.ts +123 -0
  439. package/src/vista/vista-tools.ts +220 -0
  440. package/dist/lib/biome-host/response-envelope.d.ts +0 -3
  441. package/dist/lib/biome-host/response-envelope.d.ts.map +0 -1
  442. package/dist/lib/biome-host/response-envelope.js +0 -21
  443. package/dist/lib/biome-host/response-envelope.js.map +0 -1
  444. package/src/lib/biome-host/response-envelope.ts +0 -69
@@ -0,0 +1,92 @@
1
+ /**
2
+ * The host-side inbound-message classifier for the sandbox-frame bridge.
3
+ *
4
+ * Every `message` event the host window receives while a frame is mounted
5
+ * passes through {@link classifyFrameMessage}. It enforces the security gate
6
+ * BEFORE the host acts on anything:
7
+ *
8
+ * 1. SOURCE IDENTITY — `event.source` must be the frame's own
9
+ * `contentWindow`. We compare the window identity, NOT `event.origin`: an
10
+ * opaque-origin sandbox frame (no `allow-same-origin`) reports its origin
11
+ * as the string `"null"`, so origin is useless as an allow-check. Window
12
+ * identity is unforgeable across the boundary.
13
+ * 2. PROTOCOL — `event.data.protocol` must equal the pinned protocol version.
14
+ * 3. TYPE — `event.data.type` must be a member of the closed
15
+ * {@link CustomUiFrameMessageType} set.
16
+ *
17
+ * Anything failing any gate is classified `ignored` and the host does nothing.
18
+ * A valid message is narrowed to a typed, discriminated result the caller acts
19
+ * on. The intent payload is parsed against the mounting surface's CLOSED intent
20
+ * set here too, so a frame that posts a well-formed envelope but an
21
+ * unknown/invalid intent is still `ignored` — never performed.
22
+ *
23
+ * Promoted from `app-forge-web` into the UI kernel (Canopy §8.3). The only
24
+ * change is that the intent set is a parameter instead of a hard-wired import;
25
+ * every gate is carried over verbatim.
26
+ */
27
+ import {
28
+ CUSTOM_UI_FRAME_PROTOCOL,
29
+ CustomUiFrameMessageType,
30
+ } from './custom-ui-frame-contract';
31
+
32
+ /** The typed outcome of classifying one inbound frame message. */
33
+ export type ClassifiedFrameMessage<TIntent> =
34
+ | { readonly kind: 'ready' }
35
+ | { readonly kind: 'intent'; readonly intent: TIntent }
36
+ | { readonly kind: 'error'; readonly message: string }
37
+ | { readonly kind: 'ignored' };
38
+
39
+ const IGNORED: ClassifiedFrameMessage<never> = { kind: 'ignored' };
40
+
41
+ /**
42
+ * Classify an inbound `message` event from a sandbox frame. `frameWindow` is the
43
+ * mounted iframe's `contentWindow` (may be `null` before mount); `parseIntent`
44
+ * is the mounting surface's closed-set parser (returns `null` to reject).
45
+ * Returns a typed result; every rejection path returns `ignored` (fail-safe —
46
+ * the host performs nothing on a message it cannot fully validate).
47
+ */
48
+ export function classifyFrameMessage<TIntent>(
49
+ event: Pick<MessageEvent, 'source' | 'data'>,
50
+ frameWindow: Window | null,
51
+ parseIntent: (raw: unknown) => TIntent | null,
52
+ ): ClassifiedFrameMessage<TIntent> {
53
+ // Gate 1: source identity. Reject if we have no frame yet or the message did
54
+ // not come from THIS frame's window.
55
+ if (frameWindow === null || event.source !== frameWindow) return IGNORED;
56
+
57
+ const data = event.data;
58
+ if (data === null || typeof data !== 'object') return IGNORED;
59
+ const envelope = data as {
60
+ protocol?: unknown;
61
+ type?: unknown;
62
+ intent?: unknown;
63
+ message?: unknown;
64
+ };
65
+
66
+ // Gate 2: protocol version.
67
+ if (envelope.protocol !== CUSTOM_UI_FRAME_PROTOCOL) return IGNORED;
68
+
69
+ // Gate 3: closed message-type set.
70
+ switch (envelope.type) {
71
+ case CustomUiFrameMessageType.FrameReady:
72
+ return { kind: 'ready' };
73
+ case CustomUiFrameMessageType.FrameIntent: {
74
+ const intent = parseIntent(envelope.intent);
75
+ // A valid envelope carrying an unknown/invalid intent is rejected, not
76
+ // performed.
77
+ return intent === null ? IGNORED : { kind: 'intent', intent };
78
+ }
79
+ case CustomUiFrameMessageType.FrameError:
80
+ return {
81
+ kind: 'error',
82
+ message:
83
+ typeof envelope.message === 'string'
84
+ ? envelope.message
85
+ : 'The custom view failed to render.',
86
+ };
87
+ default:
88
+ // Includes HostProps (host→frame only, never inbound) and any unknown
89
+ // string — ignored.
90
+ return IGNORED;
91
+ }
92
+ }
@@ -0,0 +1,88 @@
1
+ /**
2
+ * The frozen custom-UI frame wire contract — the HOST side of the ONLY channel
3
+ * across the sandbox-frame boundary.
4
+ *
5
+ * Promoted from `app-forge-web` into the UI kernel (Canopy §8.3) so every plane
6
+ * that renders untrusted, author-authored UI — App Forge's runtime views AND
7
+ * the Vista `html` surface — speaks ONE protocol through ONE hardened frame.
8
+ *
9
+ * A compiled custom-UI chunk (self-mounting ESM, running inside a strict-CSP,
10
+ * opaque-origin iframe) speaks exactly these four message `type`s at exactly
11
+ * this protocol version. The chunk's self-mount wrapper is generated by the
12
+ * app-function-broker from its OWN copy of these values
13
+ * (`repos/xema-cultivars/biomes/platform/app-function-broker/api/src/compile/ui/custom-ui-frame-contract.ts`),
14
+ * so the enum members and protocol number here MUST stay byte-for-byte
15
+ * identical to that source of truth. Changing a value is a coordinated,
16
+ * breaking wire change: bump the protocol on BOTH sides in lockstep.
17
+ *
18
+ * The chunk never touches host state directly — it announces readiness, the
19
+ * host pushes props, the component asks the host to perform intents, and a
20
+ * render throw is reported back. The host validates every inbound message
21
+ * (source identity + protocol + closed `type` set) before acting.
22
+ */
23
+
24
+ /** The frozen protocol version stamped on every frame message. */
25
+ export const CUSTOM_UI_FRAME_PROTOCOL = 1 as const;
26
+
27
+ /**
28
+ * The closed set of message `type`s exchanged across the frame boundary. The
29
+ * string values are the wire contract and must never diverge from the broker's.
30
+ *
31
+ * - {@link FrameReady} frame → host: mounted, ready for props (no payload).
32
+ * - {@link HostProps} host → frame: `{ props }`; repeatable to re-render.
33
+ * - {@link FrameIntent} frame → host: `{ intent }` — the host validates+performs.
34
+ * - {@link FrameError} frame → host: `{ message }` — the render threw.
35
+ */
36
+ export enum CustomUiFrameMessageType {
37
+ FrameReady = 'xema.customui.frameReady',
38
+ HostProps = 'xema.customui.hostProps',
39
+ FrameIntent = 'xema.customui.frameIntent',
40
+ FrameError = 'xema.customui.frameError',
41
+ }
42
+
43
+ /** frame → host: emitted once on load. */
44
+ export interface FrameReadyMessage {
45
+ readonly type: CustomUiFrameMessageType.FrameReady;
46
+ readonly protocol: typeof CUSTOM_UI_FRAME_PROTOCOL;
47
+ }
48
+
49
+ /** host → frame: the props to render the component with. */
50
+ export interface HostPropsMessage {
51
+ readonly type: CustomUiFrameMessageType.HostProps;
52
+ readonly protocol: typeof CUSTOM_UI_FRAME_PROTOCOL;
53
+ readonly props: CustomUiComponentProps;
54
+ }
55
+
56
+ /** frame → host: the component asked the host to perform an action. */
57
+ export interface FrameIntentMessage {
58
+ readonly type: CustomUiFrameMessageType.FrameIntent;
59
+ readonly protocol: typeof CUSTOM_UI_FRAME_PROTOCOL;
60
+ readonly intent: unknown;
61
+ }
62
+
63
+ /** frame → host: the component's render threw. */
64
+ export interface FrameErrorMessage {
65
+ readonly type: CustomUiFrameMessageType.FrameError;
66
+ readonly protocol: typeof CUSTOM_UI_FRAME_PROTOCOL;
67
+ readonly message: string;
68
+ }
69
+
70
+ /**
71
+ * The read-only props payload handed to a custom-UI component. It MUST be a
72
+ * plain, structured-clone-serializable object — it crosses the frame boundary
73
+ * via `postMessage`. The component also receives an injected `xemaEmit(intent)`
74
+ * function (added inside the frame by the self-mount wrapper, NOT sent over the
75
+ * wire), so this shape carries data only.
76
+ */
77
+ export type CustomUiComponentProps = Record<string, unknown>;
78
+
79
+ /** Build the host→frame props message (single seam so the shape can't drift). */
80
+ export function hostPropsMessage(
81
+ props: CustomUiComponentProps,
82
+ ): HostPropsMessage {
83
+ return {
84
+ type: CustomUiFrameMessageType.HostProps,
85
+ protocol: CUSTOM_UI_FRAME_PROTOCOL,
86
+ props,
87
+ };
88
+ }
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Custom-UI intent parsing/dispatch — the frame asks, the host validates+
3
+ * performs. Proves the closed set rejects unknown kinds and out-of-policy
4
+ * (external) navigation targets, that a valid intent dispatches to its handler,
5
+ * and that the two shipped intent SETS behave as their names promise: the
6
+ * built-in navigate set parses+performs exactly one kind, and
7
+ * `NO_CUSTOM_UI_INTENTS` grants a frame no authority at all.
8
+ *
9
+ * Migrated from `app-forge-web` when the frame was promoted into the UI kernel;
10
+ * runs under the host-web vitest mirror (this package carries no vitest dep).
11
+ */
12
+ import { describe, expect, it, vi } from 'vitest';
13
+
14
+ import {
15
+ createNavigateIntentSet,
16
+ CustomUiIntentKind,
17
+ NO_CUSTOM_UI_INTENTS,
18
+ parseCustomUiIntent,
19
+ performCustomUiIntent,
20
+ type CustomUiIntentHandlers,
21
+ } from './custom-ui-intents';
22
+
23
+ describe('parseCustomUiIntent', () => {
24
+ it('parses a valid host-relative navigate intent', () => {
25
+ expect(
26
+ parseCustomUiIntent({ kind: 'navigate', href: '/apps/x/page' }),
27
+ ).toEqual({ kind: CustomUiIntentKind.Navigate, href: '/apps/x/page' });
28
+ });
29
+
30
+ it('rejects an unknown intent kind', () => {
31
+ expect(parseCustomUiIntent({ kind: 'delete-everything' })).toBeNull();
32
+ });
33
+
34
+ it('rejects a navigate to an external (protocol-relative) URL', () => {
35
+ expect(
36
+ parseCustomUiIntent({ kind: 'navigate', href: '//evil.example.com' }),
37
+ ).toBeNull();
38
+ });
39
+
40
+ it('rejects a navigate to an absolute external URL', () => {
41
+ expect(
42
+ parseCustomUiIntent({ kind: 'navigate', href: 'https://evil.example' }),
43
+ ).toBeNull();
44
+ });
45
+
46
+ // Regression: a backslash normalises to a forward slash (WHATWG), so `/\host`
47
+ // is protocol-relative and resolves to a FOREIGN origin — the exact bypass a
48
+ // prefix-only check (`startsWith('/') && !startsWith('//')`) missed. The
49
+ // origin-resolution validator MUST reject every backslash form.
50
+ it('rejects a navigate whose backslash form resolves to a foreign origin', () => {
51
+ for (const href of [
52
+ '/\\evil.example.com',
53
+ '/\\\\evil.example.com',
54
+ '/\\/evil.example.com',
55
+ '\\/evil.example.com',
56
+ ]) {
57
+ expect(parseCustomUiIntent({ kind: 'navigate', href })).toBeNull();
58
+ }
59
+ });
60
+
61
+ it('rejects a navigate href containing whitespace or control chars', () => {
62
+ expect(
63
+ parseCustomUiIntent({ kind: 'navigate', href: '/ /evil' }),
64
+ ).toBeNull();
65
+ expect(parseCustomUiIntent({ kind: 'navigate', href: '/\tx' })).toBeNull();
66
+ });
67
+
68
+ it('rejects a navigate with a non-string href', () => {
69
+ expect(parseCustomUiIntent({ kind: 'navigate', href: 42 })).toBeNull();
70
+ });
71
+
72
+ it('rejects non-object payloads', () => {
73
+ expect(parseCustomUiIntent(null)).toBeNull();
74
+ expect(parseCustomUiIntent('navigate')).toBeNull();
75
+ });
76
+ });
77
+
78
+ describe('performCustomUiIntent', () => {
79
+ it('dispatches a navigate intent to the navigate handler', () => {
80
+ const navigate = vi.fn();
81
+ const handlers: CustomUiIntentHandlers = {
82
+ [CustomUiIntentKind.Navigate]: navigate,
83
+ };
84
+ performCustomUiIntent(
85
+ { kind: CustomUiIntentKind.Navigate, href: '/apps/x' },
86
+ handlers,
87
+ );
88
+ expect(navigate).toHaveBeenCalledWith({
89
+ kind: CustomUiIntentKind.Navigate,
90
+ href: '/apps/x',
91
+ });
92
+ });
93
+ });
94
+
95
+ describe('createNavigateIntentSet', () => {
96
+ it('parses and performs a host-relative navigate, and only that', () => {
97
+ const navigate = vi.fn();
98
+ const set = createNavigateIntentSet({
99
+ [CustomUiIntentKind.Navigate]: navigate,
100
+ });
101
+
102
+ const intent = set.parse({ kind: 'navigate', href: '/apps/x' });
103
+ expect(intent).toEqual({
104
+ kind: CustomUiIntentKind.Navigate,
105
+ href: '/apps/x',
106
+ });
107
+ if (intent === null) throw new Error('expected a parsed navigate intent');
108
+ set.perform(intent);
109
+ expect(navigate).toHaveBeenCalledWith({
110
+ kind: CustomUiIntentKind.Navigate,
111
+ href: '/apps/x',
112
+ });
113
+
114
+ // Anything outside the closed set is rejected by `parse` — never performed.
115
+ expect(set.parse({ kind: 'wipe-db' })).toBeNull();
116
+ expect(
117
+ set.parse({ kind: 'navigate', href: 'https://evil.example' }),
118
+ ).toBeNull();
119
+ });
120
+ });
121
+
122
+ describe('NO_CUSTOM_UI_INTENTS', () => {
123
+ it('grants the frame NO authority: every payload is rejected', () => {
124
+ for (const raw of [
125
+ { kind: 'navigate', href: '/apps/x' },
126
+ { kind: 'wipe-db' },
127
+ null,
128
+ 'navigate',
129
+ ]) {
130
+ expect(NO_CUSTOM_UI_INTENTS.parse(raw)).toBeNull();
131
+ }
132
+ });
133
+ });
@@ -0,0 +1,151 @@
1
+ /**
2
+ * The intent plane of the custom-UI frame bridge — now PLUGGABLE.
3
+ *
4
+ * A component running inside the sandbox frame NEVER acts with the user's
5
+ * authority. It posts an intent across the boundary; the host validates it
6
+ * against a CLOSED set and performs it. An unrecognised or malformed intent is
7
+ * rejected — never coerced, never silently dropped into a default action.
8
+ *
9
+ * Promoting this out of App Forge required one change and one only: WHICH
10
+ * closed set applies is now supplied by the mounting surface
11
+ * ({@link CustomUiIntentSet}) instead of being hard-wired. The security shape is
12
+ * unchanged — a set is still a `parse` that returns `null` for anything outside
13
+ * it, plus a `perform` that is exhaustive over it. There is no "accept any
14
+ * intent" set and no free-form action strings.
15
+ *
16
+ * {@link createNavigateIntentSet} is the built-in set every host gets.
17
+ */
18
+
19
+ /**
20
+ * A closed intent set: parse-or-reject, then perform. `parse` MUST be total and
21
+ * MUST NOT throw — returning `null` is the ONLY way to reject, and the bridge
22
+ * turns that into `ignored`.
23
+ */
24
+ export interface CustomUiIntentSet<TIntent> {
25
+ parse(raw: unknown): TIntent | null;
26
+ perform(intent: TIntent): void;
27
+ }
28
+
29
+ /** Closed set of intent kinds the built-in set understands. */
30
+ export enum CustomUiIntentKind {
31
+ /** Navigate the host to an in-app path. */
32
+ Navigate = 'navigate',
33
+ }
34
+
35
+ /**
36
+ * Navigate intent — the host routes to `href`. Constrained to a host-relative
37
+ * path (leading `/`, no scheme, no protocol-relative `//`) so a frame can never
38
+ * drive the host to an arbitrary external origin.
39
+ */
40
+ export interface NavigateIntent {
41
+ readonly kind: CustomUiIntentKind.Navigate;
42
+ readonly href: string;
43
+ }
44
+
45
+ /** The discriminated union of every intent the BUILT-IN set performs. */
46
+ export type CustomUiIntent = NavigateIntent;
47
+
48
+ /**
49
+ * Typed handler set for the built-in intents. Exhaustive over
50
+ * {@link CustomUiIntentKind} by construction — adding a kind forces adding a
51
+ * handler here (a compile error otherwise), so no intent kind can ship without
52
+ * a host-side performer.
53
+ */
54
+ export interface CustomUiIntentHandlers {
55
+ readonly [CustomUiIntentKind.Navigate]: (intent: NavigateIntent) => void;
56
+ }
57
+
58
+ /**
59
+ * True for a same-origin, host-relative path — the only href a frame may request.
60
+ *
61
+ * A prefix check (`startsWith('/') && !startsWith('//')`) is NOT sufficient:
62
+ * browsers (WHATWG URL) normalize a backslash to a forward slash for special
63
+ * schemes, so `"/\\evil.com"` is protocol-relative and resolves to a FOREIGN
64
+ * origin — a `router.push` of it hard-navigates the victim's top window off to
65
+ * `evil.com` (open redirect / phishing). Author code runs inside the frame and
66
+ * an authored app is viewed by OTHER users, so this is a real cross-user
67
+ * surface. We therefore RESOLVE the href against the current origin and require
68
+ * the resolved origin to be identical — the browser's own parser decides, so no
69
+ * textual-prefix trick (`\`, control chars, whitespace, embedded scheme) can
70
+ * slip a foreign origin past us. A relative href that cannot be parsed, or that
71
+ * escapes the origin, is rejected.
72
+ */
73
+ function isHostRelativePath(href: string): boolean {
74
+ // Must be rooted at '/'.
75
+ if (!href.startsWith('/')) return false;
76
+ // A backslash is a protocol-relative/scheme trick after WHATWG normalisation
77
+ // ("/\\evil.com" -> //evil.com -> foreign origin); whitespace / control
78
+ // chars can also confuse the parser. Reject any before resolving.
79
+ if (href.includes('\\')) return false;
80
+ // eslint-disable-next-line no-control-regex
81
+ if (/[\u0000-\u0020\u007f]/.test(href)) return false;
82
+ let resolved: URL;
83
+ try {
84
+ resolved = new URL(href, window.location.origin);
85
+ } catch {
86
+ return false;
87
+ }
88
+ // The browser's parser is authoritative: the resolved origin MUST equal ours.
89
+ return resolved.origin === window.location.origin;
90
+ }
91
+
92
+ /**
93
+ * Parse an untrusted intent payload (arrived from the sandbox frame) into a
94
+ * typed {@link CustomUiIntent}, or `null` if it is not a recognized, valid
95
+ * member of the closed set. Fail-safe: unknown `kind`, wrong payload shape, or
96
+ * an out-of-policy value all return `null` — the caller rejects it.
97
+ */
98
+ export function parseCustomUiIntent(raw: unknown): CustomUiIntent | null {
99
+ if (raw === null || typeof raw !== 'object') return null;
100
+ const candidate = raw as { kind?: unknown; href?: unknown };
101
+ switch (candidate.kind) {
102
+ case CustomUiIntentKind.Navigate:
103
+ if (typeof candidate.href !== 'string') return null;
104
+ if (!isHostRelativePath(candidate.href)) return null;
105
+ return { kind: CustomUiIntentKind.Navigate, href: candidate.href };
106
+ default:
107
+ return null;
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Dispatch a parsed intent to its handler. Exhaustive `switch` over the closed
113
+ * set — a new kind added to {@link CustomUiIntentKind} without a `case` here is
114
+ * a compile error (the `never` guard), so the set can never be silently
115
+ * under-served.
116
+ */
117
+ export function performCustomUiIntent(
118
+ intent: CustomUiIntent,
119
+ handlers: CustomUiIntentHandlers,
120
+ ): void {
121
+ switch (intent.kind) {
122
+ case CustomUiIntentKind.Navigate:
123
+ handlers[CustomUiIntentKind.Navigate](intent);
124
+ return;
125
+ default: {
126
+ const exhaustive: never = intent.kind;
127
+ throw new Error(`Unhandled custom-UI intent kind: ${String(exhaustive)}`);
128
+ }
129
+ }
130
+ }
131
+
132
+ /** The built-in intent set: host-relative navigation and nothing else. */
133
+ export function createNavigateIntentSet(
134
+ handlers: CustomUiIntentHandlers,
135
+ ): CustomUiIntentSet<CustomUiIntent> {
136
+ return {
137
+ parse: parseCustomUiIntent,
138
+ perform: (intent) => performCustomUiIntent(intent, handlers),
139
+ };
140
+ }
141
+
142
+ /**
143
+ * The EMPTY intent set — parses nothing, performs nothing. Mount a frame with
144
+ * this when the rendered content must be strictly presentational (the Vista
145
+ * `html` surface's static-document form). It is an explicit "this frame has no
146
+ * authority", not an absent configuration.
147
+ */
148
+ export const NO_CUSTOM_UI_INTENTS: CustomUiIntentSet<never> = {
149
+ parse: () => null,
150
+ perform: () => undefined,
151
+ };
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Custom-UI srcdoc / CSP builder — the security invariant lives HERE.
3
+ *
4
+ * These assertions pin the strict-CSP posture that makes running author- and
5
+ * agent-authored content safe, on BOTH forms the frame renders: the compiled,
6
+ * SRI-pinned chunk (`script-src '<hash>'`) and the untrusted static document
7
+ * (`script-src 'none'`). The mutation blocks prove the invariants IN ISOLATION:
8
+ * the suite goes RED if the CSP `script-src` hash is dropped or loosened (e.g.
9
+ * to `'unsafe-inline'` / a wildcard), or if the static-document policy ever
10
+ * grew a script source.
11
+ *
12
+ * Migrated verbatim from `app-forge-web` when the frame was promoted into the
13
+ * UI kernel; runs under the host-web vitest mirror (this package carries no
14
+ * vitest dep).
15
+ */
16
+ import { describe, expect, it } from 'vitest';
17
+
18
+ import {
19
+ buildCustomUiFrameCsp,
20
+ buildCustomUiSrcDoc,
21
+ buildUntrustedHtmlFrameCsp,
22
+ buildUntrustedHtmlSrcDoc,
23
+ CustomUiSrcDocError,
24
+ } from './custom-ui-srcdoc';
25
+
26
+ const INTEGRITY = 'sha384-AbC123+/def456Ghi789jklMnoPqr==';
27
+ const COMPILED = 'export default function C(){return null}';
28
+
29
+ describe('buildCustomUiFrameCsp', () => {
30
+ it('emits the exact airtight directive string, pinning the server hash', () => {
31
+ expect(buildCustomUiFrameCsp(INTEGRITY)).toBe(
32
+ `default-src 'none'; script-src '${INTEGRITY}'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'`,
33
+ );
34
+ });
35
+
36
+ it('script-src carries the server integrity token verbatim', () => {
37
+ expect(buildCustomUiFrameCsp(INTEGRITY)).toContain(
38
+ `script-src '${INTEGRITY}'`,
39
+ );
40
+ });
41
+
42
+ it('never grants scripts unsafe-inline or a wildcard', () => {
43
+ const csp = buildCustomUiFrameCsp(INTEGRITY);
44
+ expect(csp).not.toContain("script-src 'unsafe-inline'");
45
+ expect(csp).not.toContain('script-src *');
46
+ expect(csp).toContain(`default-src 'none'`);
47
+ });
48
+ });
49
+
50
+ describe('buildCustomUiSrcDoc', () => {
51
+ const srcDoc = buildCustomUiSrcDoc({
52
+ compiledOutput: COMPILED,
53
+ integrity: INTEGRITY,
54
+ styleCss: ':root{--x:1}',
55
+ });
56
+
57
+ it('embeds the pinned CSP as a meta http-equiv', () => {
58
+ expect(srcDoc).toContain(
59
+ `<meta http-equiv="Content-Security-Policy" content="${buildCustomUiFrameCsp(
60
+ INTEGRITY,
61
+ )}" />`,
62
+ );
63
+ });
64
+
65
+ it('inlines the chunk verbatim as the one module script (hash must match)', () => {
66
+ expect(srcDoc).toContain(`<script type="module">${COMPILED}</script>`);
67
+ });
68
+
69
+ it('carries the #root mount point the self-mount wrapper renders into', () => {
70
+ expect(srcDoc).toContain('<div id="root"></div>');
71
+ });
72
+
73
+ it('inlines the design-system style (style-src unsafe-inline)', () => {
74
+ expect(srcDoc).toContain('<style>:root{--x:1}</style>');
75
+ });
76
+
77
+ it('refuses a chunk containing a literal </script (would truncate the module)', () => {
78
+ expect(() =>
79
+ buildCustomUiSrcDoc({
80
+ compiledOutput: 'const x = "a</script><script>alert(1)</script>";',
81
+ integrity: INTEGRITY,
82
+ styleCss: '',
83
+ }),
84
+ ).toThrow(CustomUiSrcDocError);
85
+ });
86
+
87
+ // ── MUTATION TEST (security invariant, isolated) ───────────────────────────
88
+ // A loosened policy that drops the hash pin must FAIL these assertions. This
89
+ // proves the guard is load-bearing: remove/loosen the script-src hash and the
90
+ // suite goes red.
91
+ it('MUTATION: dropping the script-src hash makes the CSP invalid — caught', () => {
92
+ const loosened = `default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'`;
93
+ // The real builder must NOT equal the loosened (hash-dropped) policy…
94
+ expect(buildCustomUiFrameCsp(INTEGRITY)).not.toBe(loosened);
95
+ // …and the real policy MUST pin the exact hash the loosened one dropped.
96
+ expect(buildCustomUiFrameCsp(INTEGRITY)).toContain(
97
+ `script-src '${INTEGRITY}'`,
98
+ );
99
+ });
100
+ });
101
+
102
+ describe('buildUntrustedHtmlFrameCsp', () => {
103
+ it('emits the same airtight policy with script-src none', () => {
104
+ expect(buildUntrustedHtmlFrameCsp()).toBe(
105
+ `default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'`,
106
+ );
107
+ });
108
+ });
109
+
110
+ describe('buildUntrustedHtmlSrcDoc', () => {
111
+ const DOCUMENT = '<h1>Report</h1><p>Static, agent-authored markup.</p>';
112
+ const srcDoc = buildUntrustedHtmlSrcDoc({
113
+ document: DOCUMENT,
114
+ styleCss: ':root{--x:1}',
115
+ });
116
+
117
+ it("pins script-src 'none' — an authored <script> can NEVER execute", () => {
118
+ expect(srcDoc).toContain(
119
+ `<meta http-equiv="Content-Security-Policy" content="${buildUntrustedHtmlFrameCsp()}" />`,
120
+ );
121
+ expect(srcDoc).toContain(`script-src 'none'`);
122
+ // No script source of any kind may be granted on the static path.
123
+ expect(srcDoc).not.toContain("script-src 'unsafe-inline'");
124
+ expect(srcDoc).not.toContain('script-src *');
125
+ expect(srcDoc).not.toContain('script-src sha384-');
126
+ expect(srcDoc).toContain(`default-src 'none'`);
127
+ expect(srcDoc).toContain(`base-uri 'none'`);
128
+ expect(srcDoc).toContain(`form-action 'none'`);
129
+ });
130
+
131
+ it('emits the document verbatim with the inlined styles', () => {
132
+ expect(srcDoc).toContain('<style>:root{--x:1}</style>');
133
+ expect(srcDoc).toContain(DOCUMENT);
134
+ });
135
+
136
+ it('refuses a document containing a literal </script (fail-closed)', () => {
137
+ expect(() =>
138
+ buildUntrustedHtmlSrcDoc({
139
+ document: '<p>ok</p></script><script>alert(1)</script>',
140
+ styleCss: '',
141
+ }),
142
+ ).toThrow(CustomUiSrcDocError);
143
+ });
144
+
145
+ // ── MUTATION TEST (static-document invariant, isolated) ────────────────────
146
+ it('MUTATION: granting the static document any script source is caught', () => {
147
+ const loosened = `default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'`;
148
+ expect(buildUntrustedHtmlFrameCsp()).not.toBe(loosened);
149
+ expect(buildUntrustedHtmlFrameCsp()).toContain(`script-src 'none'`);
150
+ });
151
+ });