@derelicious/ds 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (579) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/LICENSE +21 -0
  3. package/README.md +147 -2
  4. package/dist/a2ui/Surface.css +140 -0
  5. package/dist/a2ui/Surface.css.d.ts +22 -0
  6. package/dist/a2ui/Surface.css.js +29 -0
  7. package/dist/a2ui/Surface.d.ts +56 -0
  8. package/dist/a2ui/Surface.js +1411 -0
  9. package/dist/a2ui/catalog.d.ts +93 -0
  10. package/dist/a2ui/catalog.js +1666 -0
  11. package/dist/a2ui/clientMessages.d.ts +36 -0
  12. package/dist/a2ui/clientMessages.js +65 -0
  13. package/dist/a2ui/examples.d.ts +8 -0
  14. package/dist/a2ui/examples.js +877 -0
  15. package/dist/a2ui/functions.d.ts +55 -0
  16. package/dist/a2ui/functions.js +341 -0
  17. package/dist/a2ui/ids.d.ts +5 -0
  18. package/dist/a2ui/ids.js +7 -0
  19. package/dist/a2ui/index.d.ts +16 -0
  20. package/dist/a2ui/index.js +12 -0
  21. package/dist/a2ui/jsonl.d.ts +41 -0
  22. package/dist/a2ui/jsonl.js +127 -0
  23. package/dist/a2ui/links.d.ts +17 -0
  24. package/dist/a2ui/links.js +29 -0
  25. package/dist/a2ui/pointer.d.ts +22 -0
  26. package/dist/a2ui/pointer.js +85 -0
  27. package/dist/a2ui/processor.d.ts +126 -0
  28. package/dist/a2ui/processor.js +497 -0
  29. package/dist/a2ui/react.d.ts +2 -0
  30. package/dist/a2ui/react.js +1 -0
  31. package/dist/a2ui/toTsx.d.ts +9 -0
  32. package/dist/a2ui/toTsx.js +1389 -0
  33. package/dist/a2ui/types.d.ts +96 -0
  34. package/dist/a2ui/validate.d.ts +90 -0
  35. package/dist/a2ui/validate.js +750 -0
  36. package/dist/a2ui-catalog.json +4369 -0
  37. package/dist/a2ui-conformance.json +71 -0
  38. package/dist/components/Accordion/Accordion.css +58 -0
  39. package/dist/components/Accordion/Accordion.css.d.ts +5 -0
  40. package/dist/components/Accordion/Accordion.css.js +10 -0
  41. package/dist/components/Accordion/Accordion.d.ts +23 -0
  42. package/dist/components/Accordion/Accordion.docs.d.ts +19 -0
  43. package/dist/components/Accordion/Accordion.docs.js +43 -0
  44. package/dist/components/Accordion/Accordion.js +55 -0
  45. package/dist/components/Accordion/index.d.ts +1 -0
  46. package/dist/components/Accordion/index.js +1 -0
  47. package/dist/components/AiLabel/AiLabel.css +70 -0
  48. package/dist/components/AiLabel/AiLabel.css.d.ts +8 -0
  49. package/dist/components/AiLabel/AiLabel.css.js +11 -0
  50. package/dist/components/AiLabel/AiLabel.d.ts +29 -0
  51. package/dist/components/AiLabel/AiLabel.docs.d.ts +19 -0
  52. package/dist/components/AiLabel/AiLabel.docs.js +51 -0
  53. package/dist/components/AiLabel/AiLabel.js +41 -0
  54. package/dist/components/AiLabel/index.d.ts +1 -0
  55. package/dist/components/AiLabel/index.js +1 -0
  56. package/dist/components/Alert/Alert.css +76 -0
  57. package/dist/components/Alert/Alert.css.d.ts +9 -0
  58. package/dist/components/Alert/Alert.css.js +23 -0
  59. package/dist/components/Alert/Alert.d.ts +21 -0
  60. package/dist/components/Alert/Alert.docs.d.ts +19 -0
  61. package/dist/components/Alert/Alert.docs.js +57 -0
  62. package/dist/components/Alert/Alert.js +55 -0
  63. package/dist/components/Alert/index.d.ts +1 -0
  64. package/dist/components/Alert/index.js +1 -0
  65. package/dist/components/Avatar/Avatar.css +42 -0
  66. package/dist/components/Avatar/Avatar.css.d.ts +3 -0
  67. package/dist/components/Avatar/Avatar.css.js +12 -0
  68. package/dist/components/Avatar/Avatar.d.ts +13 -0
  69. package/dist/components/Avatar/Avatar.docs.d.ts +19 -0
  70. package/dist/components/Avatar/Avatar.docs.js +43 -0
  71. package/dist/components/Avatar/Avatar.js +31 -0
  72. package/dist/components/Avatar/index.d.ts +1 -0
  73. package/dist/components/Avatar/index.js +1 -0
  74. package/dist/components/Avatar/initials.d.ts +2 -0
  75. package/dist/components/Avatar/initials.js +8 -0
  76. package/dist/components/Badge/Badge.css +63 -0
  77. package/dist/components/Badge/Badge.css.d.ts +5 -0
  78. package/dist/components/Badge/Badge.css.js +16 -0
  79. package/dist/components/Badge/Badge.d.ts +15 -0
  80. package/dist/components/Badge/Badge.docs.d.ts +19 -0
  81. package/dist/components/Badge/Badge.docs.js +52 -0
  82. package/dist/components/Badge/Badge.js +24 -0
  83. package/dist/components/Badge/index.d.ts +1 -0
  84. package/dist/components/Badge/index.js +1 -0
  85. package/dist/components/Breadcrumbs/Breadcrumbs.css +40 -0
  86. package/dist/components/Breadcrumbs/Breadcrumbs.css.d.ts +5 -0
  87. package/dist/components/Breadcrumbs/Breadcrumbs.css.js +10 -0
  88. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +17 -0
  89. package/dist/components/Breadcrumbs/Breadcrumbs.docs.d.ts +19 -0
  90. package/dist/components/Breadcrumbs/Breadcrumbs.docs.js +38 -0
  91. package/dist/components/Breadcrumbs/Breadcrumbs.js +48 -0
  92. package/dist/components/Breadcrumbs/index.d.ts +1 -0
  93. package/dist/components/Breadcrumbs/index.js +1 -0
  94. package/dist/components/Button/Button.css +101 -0
  95. package/dist/components/Button/Button.css.d.ts +72 -0
  96. package/dist/components/Button/Button.css.js +35 -0
  97. package/dist/components/Button/Button.d.ts +53 -0
  98. package/dist/components/Button/Button.docs.d.ts +19 -0
  99. package/dist/components/Button/Button.docs.js +71 -0
  100. package/dist/components/Button/Button.js +68 -0
  101. package/dist/components/Button/index.d.ts +1 -0
  102. package/dist/components/Button/index.js +1 -0
  103. package/dist/components/Card/Card.css +122 -0
  104. package/dist/components/Card/Card.css.d.ts +12 -0
  105. package/dist/components/Card/Card.css.js +25 -0
  106. package/dist/components/Card/Card.d.ts +306 -0
  107. package/dist/components/Card/Card.docs.d.ts +19 -0
  108. package/dist/components/Card/Card.docs.js +65 -0
  109. package/dist/components/Card/Card.js +53 -0
  110. package/dist/components/Card/index.d.ts +1 -0
  111. package/dist/components/Card/index.js +1 -0
  112. package/dist/components/ChatMessage/ChatMessage.css +56 -0
  113. package/dist/components/ChatMessage/ChatMessage.css.d.ts +7 -0
  114. package/dist/components/ChatMessage/ChatMessage.css.js +15 -0
  115. package/dist/components/ChatMessage/ChatMessage.d.ts +35 -0
  116. package/dist/components/ChatMessage/ChatMessage.docs.d.ts +19 -0
  117. package/dist/components/ChatMessage/ChatMessage.docs.js +45 -0
  118. package/dist/components/ChatMessage/ChatMessage.js +49 -0
  119. package/dist/components/ChatMessage/index.d.ts +1 -0
  120. package/dist/components/ChatMessage/index.js +1 -0
  121. package/dist/components/Checkbox/Checkbox.css +70 -0
  122. package/dist/components/Checkbox/Checkbox.css.d.ts +1 -0
  123. package/dist/components/Checkbox/Checkbox.css.js +6 -0
  124. package/dist/components/Checkbox/Checkbox.d.ts +28 -0
  125. package/dist/components/Checkbox/Checkbox.docs.d.ts +19 -0
  126. package/dist/components/Checkbox/Checkbox.docs.js +53 -0
  127. package/dist/components/Checkbox/Checkbox.js +63 -0
  128. package/dist/components/Checkbox/index.d.ts +1 -0
  129. package/dist/components/Checkbox/index.js +1 -0
  130. package/dist/components/Code/Code.css +12 -0
  131. package/dist/components/Code/Code.css.d.ts +1 -0
  132. package/dist/components/Code/Code.css.js +5 -0
  133. package/dist/components/Code/Code.d.ts +7 -0
  134. package/dist/components/Code/Code.docs.d.ts +19 -0
  135. package/dist/components/Code/Code.docs.js +26 -0
  136. package/dist/components/Code/Code.js +12 -0
  137. package/dist/components/Code/index.d.ts +1 -0
  138. package/dist/components/Code/index.js +1 -0
  139. package/dist/components/CodeBlock/CodeBlock.css +76 -0
  140. package/dist/components/CodeBlock/CodeBlock.css.d.ts +12 -0
  141. package/dist/components/CodeBlock/CodeBlock.css.js +21 -0
  142. package/dist/components/CodeBlock/CodeBlock.d.ts +19 -0
  143. package/dist/components/CodeBlock/CodeBlock.docs.d.ts +19 -0
  144. package/dist/components/CodeBlock/CodeBlock.docs.js +47 -0
  145. package/dist/components/CodeBlock/CodeBlock.js +82 -0
  146. package/dist/components/CodeBlock/highlight.d.ts +28 -0
  147. package/dist/components/CodeBlock/highlight.js +118 -0
  148. package/dist/components/CodeBlock/index.d.ts +1 -0
  149. package/dist/components/CodeBlock/index.js +1 -0
  150. package/dist/components/Container/Container.css +21 -0
  151. package/dist/components/Container/Container.css.d.ts +3 -0
  152. package/dist/components/Container/Container.css.js +12 -0
  153. package/dist/components/Container/Container.d.ts +295 -0
  154. package/dist/components/Container/Container.docs.d.ts +19 -0
  155. package/dist/components/Container/Container.docs.js +31 -0
  156. package/dist/components/Container/Container.js +12 -0
  157. package/dist/components/Container/index.d.ts +1 -0
  158. package/dist/components/Container/index.js +1 -0
  159. package/dist/components/Dialog/Dialog.css +94 -0
  160. package/dist/components/Dialog/Dialog.css.d.ts +9 -0
  161. package/dist/components/Dialog/Dialog.css.js +17 -0
  162. package/dist/components/Dialog/Dialog.d.ts +29 -0
  163. package/dist/components/Dialog/Dialog.docs.d.ts +19 -0
  164. package/dist/components/Dialog/Dialog.docs.js +50 -0
  165. package/dist/components/Dialog/Dialog.js +90 -0
  166. package/dist/components/Dialog/index.d.ts +1 -0
  167. package/dist/components/Dialog/index.js +1 -0
  168. package/dist/components/Divider/Divider.css +41 -0
  169. package/dist/components/Divider/Divider.css.d.ts +6 -0
  170. package/dist/components/Divider/Divider.css.js +16 -0
  171. package/dist/components/Divider/Divider.d.ts +11 -0
  172. package/dist/components/Divider/Divider.docs.d.ts +19 -0
  173. package/dist/components/Divider/Divider.docs.js +43 -0
  174. package/dist/components/Divider/Divider.js +30 -0
  175. package/dist/components/Divider/index.d.ts +1 -0
  176. package/dist/components/Divider/index.js +1 -0
  177. package/dist/components/Grid/Grid.css +11 -0
  178. package/dist/components/Grid/Grid.css.d.ts +8 -0
  179. package/dist/components/Grid/Grid.css.js +8 -0
  180. package/dist/components/Grid/Grid.d.ts +18 -0
  181. package/dist/components/Grid/Grid.docs.d.ts +19 -0
  182. package/dist/components/Grid/Grid.docs.js +41 -0
  183. package/dist/components/Grid/Grid.js +22 -0
  184. package/dist/components/Grid/index.d.ts +1 -0
  185. package/dist/components/Grid/index.js +1 -0
  186. package/dist/components/Heading/Heading.css +44 -0
  187. package/dist/components/Heading/Heading.css.d.ts +3 -0
  188. package/dist/components/Heading/Heading.css.js +17 -0
  189. package/dist/components/Heading/Heading.d.ts +298 -0
  190. package/dist/components/Heading/Heading.docs.d.ts +19 -0
  191. package/dist/components/Heading/Heading.docs.js +48 -0
  192. package/dist/components/Heading/Heading.js +20 -0
  193. package/dist/components/Heading/index.d.ts +1 -0
  194. package/dist/components/Heading/index.js +1 -0
  195. package/dist/components/Icon/Icon.css +25 -0
  196. package/dist/components/Icon/Icon.css.d.ts +4 -0
  197. package/dist/components/Icon/Icon.css.js +13 -0
  198. package/dist/components/Icon/Icon.d.ts +16 -0
  199. package/dist/components/Icon/Icon.docs.d.ts +19 -0
  200. package/dist/components/Icon/Icon.docs.js +56 -0
  201. package/dist/components/Icon/Icon.js +25 -0
  202. package/dist/components/Icon/index.d.ts +1 -0
  203. package/dist/components/Icon/index.js +1 -0
  204. package/dist/components/IconButton/IconButton.css +70 -0
  205. package/dist/components/IconButton/IconButton.css.d.ts +57 -0
  206. package/dist/components/IconButton/IconButton.css.js +27 -0
  207. package/dist/components/IconButton/IconButton.d.ts +46 -0
  208. package/dist/components/IconButton/IconButton.docs.d.ts +19 -0
  209. package/dist/components/IconButton/IconButton.docs.js +48 -0
  210. package/dist/components/IconButton/IconButton.js +44 -0
  211. package/dist/components/IconButton/index.d.ts +1 -0
  212. package/dist/components/IconButton/index.js +1 -0
  213. package/dist/components/Image/Image.css +53 -0
  214. package/dist/components/Image/Image.css.d.ts +7 -0
  215. package/dist/components/Image/Image.css.js +18 -0
  216. package/dist/components/Image/Image.d.ts +23 -0
  217. package/dist/components/Image/Image.docs.d.ts +19 -0
  218. package/dist/components/Image/Image.docs.js +48 -0
  219. package/dist/components/Image/Image.js +75 -0
  220. package/dist/components/Image/index.d.ts +1 -0
  221. package/dist/components/Image/index.js +1 -0
  222. package/dist/components/Inline/Inline.css +38 -0
  223. package/dist/components/Inline/Inline.css.d.ts +4 -0
  224. package/dist/components/Inline/Inline.css.js +18 -0
  225. package/dist/components/Inline/Inline.d.ts +300 -0
  226. package/dist/components/Inline/Inline.docs.d.ts +19 -0
  227. package/dist/components/Inline/Inline.docs.js +48 -0
  228. package/dist/components/Inline/Inline.js +13 -0
  229. package/dist/components/Inline/index.d.ts +1 -0
  230. package/dist/components/Inline/index.js +1 -0
  231. package/dist/components/Link/Link.css +57 -0
  232. package/dist/components/Link/Link.css.d.ts +5 -0
  233. package/dist/components/Link/Link.css.js +14 -0
  234. package/dist/components/Link/Link.d.ts +19 -0
  235. package/dist/components/Link/Link.docs.d.ts +19 -0
  236. package/dist/components/Link/Link.docs.js +51 -0
  237. package/dist/components/Link/Link.js +39 -0
  238. package/dist/components/Link/index.d.ts +1 -0
  239. package/dist/components/Link/index.js +1 -0
  240. package/dist/components/List/List.css +39 -0
  241. package/dist/components/List/List.css.d.ts +5 -0
  242. package/dist/components/List/List.css.js +14 -0
  243. package/dist/components/List/List.d.ts +294 -0
  244. package/dist/components/List/List.docs.d.ts +19 -0
  245. package/dist/components/List/List.docs.js +43 -0
  246. package/dist/components/List/List.js +25 -0
  247. package/dist/components/List/index.d.ts +1 -0
  248. package/dist/components/List/index.js +1 -0
  249. package/dist/components/Menu/Menu.css +65 -0
  250. package/dist/components/Menu/Menu.css.d.ts +5 -0
  251. package/dist/components/Menu/Menu.css.js +9 -0
  252. package/dist/components/Menu/Menu.d.ts +60 -0
  253. package/dist/components/Menu/Menu.docs.d.ts +19 -0
  254. package/dist/components/Menu/Menu.docs.js +53 -0
  255. package/dist/components/Menu/Menu.js +192 -0
  256. package/dist/components/Menu/index.d.ts +1 -0
  257. package/dist/components/Menu/index.js +1 -0
  258. package/dist/components/NavBar/NavBar.css +187 -0
  259. package/dist/components/NavBar/NavBar.css.d.ts +16 -0
  260. package/dist/components/NavBar/NavBar.css.js +19 -0
  261. package/dist/components/NavBar/NavBar.d.ts +31 -0
  262. package/dist/components/NavBar/NavBar.docs.d.ts +19 -0
  263. package/dist/components/NavBar/NavBar.docs.js +53 -0
  264. package/dist/components/NavBar/NavBar.js +110 -0
  265. package/dist/components/NavBar/index.d.ts +1 -0
  266. package/dist/components/NavBar/index.js +1 -0
  267. package/dist/components/Popover/Popover.css +28 -0
  268. package/dist/components/Popover/Popover.css.d.ts +3 -0
  269. package/dist/components/Popover/Popover.css.js +8 -0
  270. package/dist/components/Popover/Popover.d.ts +40 -0
  271. package/dist/components/Popover/Popover.docs.d.ts +19 -0
  272. package/dist/components/Popover/Popover.docs.js +50 -0
  273. package/dist/components/Popover/Popover.js +69 -0
  274. package/dist/components/Popover/index.d.ts +1 -0
  275. package/dist/components/Popover/index.js +1 -0
  276. package/dist/components/Progress/Progress.css +106 -0
  277. package/dist/components/Progress/Progress.css.d.ts +10 -0
  278. package/dist/components/Progress/Progress.css.js +24 -0
  279. package/dist/components/Progress/Progress.d.ts +23 -0
  280. package/dist/components/Progress/Progress.docs.d.ts +19 -0
  281. package/dist/components/Progress/Progress.docs.js +43 -0
  282. package/dist/components/Progress/Progress.js +54 -0
  283. package/dist/components/Progress/index.d.ts +1 -0
  284. package/dist/components/Progress/index.js +1 -0
  285. package/dist/components/PromptInput/PromptInput.css +25 -0
  286. package/dist/components/PromptInput/PromptInput.css.d.ts +5 -0
  287. package/dist/components/PromptInput/PromptInput.css.js +8 -0
  288. package/dist/components/PromptInput/PromptInput.d.ts +65 -0
  289. package/dist/components/PromptInput/PromptInput.docs.d.ts +19 -0
  290. package/dist/components/PromptInput/PromptInput.docs.js +45 -0
  291. package/dist/components/PromptInput/PromptInput.js +91 -0
  292. package/dist/components/PromptInput/index.d.ts +1 -0
  293. package/dist/components/PromptInput/index.js +1 -0
  294. package/dist/components/Quote/Quote.css +31 -0
  295. package/dist/components/Quote/Quote.css.d.ts +5 -0
  296. package/dist/components/Quote/Quote.css.js +9 -0
  297. package/dist/components/Quote/Quote.d.ts +13 -0
  298. package/dist/components/Quote/Quote.docs.d.ts +19 -0
  299. package/dist/components/Quote/Quote.docs.js +30 -0
  300. package/dist/components/Quote/Quote.js +26 -0
  301. package/dist/components/Quote/index.d.ts +1 -0
  302. package/dist/components/Quote/index.js +1 -0
  303. package/dist/components/RadioGroup/RadioGroup.css +70 -0
  304. package/dist/components/RadioGroup/RadioGroup.css.d.ts +4 -0
  305. package/dist/components/RadioGroup/RadioGroup.css.js +12 -0
  306. package/dist/components/RadioGroup/RadioGroup.d.ts +32 -0
  307. package/dist/components/RadioGroup/RadioGroup.docs.d.ts +19 -0
  308. package/dist/components/RadioGroup/RadioGroup.docs.js +47 -0
  309. package/dist/components/RadioGroup/RadioGroup.js +85 -0
  310. package/dist/components/RadioGroup/index.d.ts +1 -0
  311. package/dist/components/RadioGroup/index.js +1 -0
  312. package/dist/components/Select/Select.css +17 -0
  313. package/dist/components/Select/Select.css.d.ts +3 -0
  314. package/dist/components/Select/Select.css.js +7 -0
  315. package/dist/components/Select/Select.d.ts +26 -0
  316. package/dist/components/Select/Select.docs.d.ts +19 -0
  317. package/dist/components/Select/Select.docs.js +35 -0
  318. package/dist/components/Select/Select.js +57 -0
  319. package/dist/components/Select/index.d.ts +1 -0
  320. package/dist/components/Select/index.js +1 -0
  321. package/dist/components/SideNav/SideNav.css +74 -0
  322. package/dist/components/SideNav/SideNav.css.d.ts +7 -0
  323. package/dist/components/SideNav/SideNav.css.js +12 -0
  324. package/dist/components/SideNav/SideNav.d.ts +23 -0
  325. package/dist/components/SideNav/SideNav.docs.d.ts +19 -0
  326. package/dist/components/SideNav/SideNav.docs.js +43 -0
  327. package/dist/components/SideNav/SideNav.js +55 -0
  328. package/dist/components/SideNav/index.d.ts +1 -0
  329. package/dist/components/SideNav/index.js +1 -0
  330. package/dist/components/Skeleton/Skeleton.css +45 -0
  331. package/dist/components/Skeleton/Skeleton.css.d.ts +3 -0
  332. package/dist/components/Skeleton/Skeleton.css.js +11 -0
  333. package/dist/components/Skeleton/Skeleton.d.ts +25 -0
  334. package/dist/components/Skeleton/Skeleton.docs.d.ts +19 -0
  335. package/dist/components/Skeleton/Skeleton.docs.js +43 -0
  336. package/dist/components/Skeleton/Skeleton.js +27 -0
  337. package/dist/components/Skeleton/index.d.ts +1 -0
  338. package/dist/components/Skeleton/index.js +1 -0
  339. package/dist/components/Spinner/Spinner.css +46 -0
  340. package/dist/components/Spinner/Spinner.css.d.ts +5 -0
  341. package/dist/components/Spinner/Spinner.css.js +13 -0
  342. package/dist/components/Spinner/Spinner.d.ts +24 -0
  343. package/dist/components/Spinner/Spinner.docs.d.ts +19 -0
  344. package/dist/components/Spinner/Spinner.docs.js +44 -0
  345. package/dist/components/Spinner/Spinner.js +46 -0
  346. package/dist/components/Spinner/index.d.ts +1 -0
  347. package/dist/components/Spinner/index.js +1 -0
  348. package/dist/components/Stack/Stack.css +21 -0
  349. package/dist/components/Stack/Stack.css.d.ts +2 -0
  350. package/dist/components/Stack/Stack.css.js +10 -0
  351. package/dist/components/Stack/Stack.d.ts +296 -0
  352. package/dist/components/Stack/Stack.docs.d.ts +19 -0
  353. package/dist/components/Stack/Stack.docs.js +48 -0
  354. package/dist/components/Stack/Stack.js +13 -0
  355. package/dist/components/Stack/index.d.ts +1 -0
  356. package/dist/components/Stack/index.js +1 -0
  357. package/dist/components/Stat/Stat.css +59 -0
  358. package/dist/components/Stat/Stat.css.d.ts +13 -0
  359. package/dist/components/Stat/Stat.css.js +18 -0
  360. package/dist/components/Stat/Stat.d.ts +20 -0
  361. package/dist/components/Stat/Stat.docs.d.ts +19 -0
  362. package/dist/components/Stat/Stat.docs.js +52 -0
  363. package/dist/components/Stat/Stat.js +49 -0
  364. package/dist/components/Stat/index.d.ts +1 -0
  365. package/dist/components/Stat/index.js +1 -0
  366. package/dist/components/StreamingIndicator/StreamingIndicator.css +46 -0
  367. package/dist/components/StreamingIndicator/StreamingIndicator.css.d.ts +5 -0
  368. package/dist/components/StreamingIndicator/StreamingIndicator.css.js +13 -0
  369. package/dist/components/StreamingIndicator/StreamingIndicator.d.ts +22 -0
  370. package/dist/components/StreamingIndicator/StreamingIndicator.docs.d.ts +19 -0
  371. package/dist/components/StreamingIndicator/StreamingIndicator.docs.js +43 -0
  372. package/dist/components/StreamingIndicator/StreamingIndicator.js +31 -0
  373. package/dist/components/StreamingIndicator/index.d.ts +1 -0
  374. package/dist/components/StreamingIndicator/index.js +1 -0
  375. package/dist/components/Switch/Switch.css +89 -0
  376. package/dist/components/Switch/Switch.css.d.ts +4 -0
  377. package/dist/components/Switch/Switch.css.js +9 -0
  378. package/dist/components/Switch/Switch.d.ts +21 -0
  379. package/dist/components/Switch/Switch.docs.d.ts +19 -0
  380. package/dist/components/Switch/Switch.docs.js +36 -0
  381. package/dist/components/Switch/Switch.js +51 -0
  382. package/dist/components/Switch/index.d.ts +1 -0
  383. package/dist/components/Switch/index.js +1 -0
  384. package/dist/components/TabBar/TabBar.css +94 -0
  385. package/dist/components/TabBar/TabBar.css.d.ts +7 -0
  386. package/dist/components/TabBar/TabBar.css.js +12 -0
  387. package/dist/components/TabBar/TabBar.d.ts +23 -0
  388. package/dist/components/TabBar/TabBar.docs.d.ts +19 -0
  389. package/dist/components/TabBar/TabBar.docs.js +43 -0
  390. package/dist/components/TabBar/TabBar.js +50 -0
  391. package/dist/components/TabBar/index.d.ts +1 -0
  392. package/dist/components/TabBar/index.js +1 -0
  393. package/dist/components/Table/Table.css +75 -0
  394. package/dist/components/Table/Table.css.d.ts +10 -0
  395. package/dist/components/Table/Table.css.js +22 -0
  396. package/dist/components/Table/Table.d.ts +32 -0
  397. package/dist/components/Table/Table.docs.d.ts +19 -0
  398. package/dist/components/Table/Table.docs.js +49 -0
  399. package/dist/components/Table/Table.js +69 -0
  400. package/dist/components/Table/index.d.ts +1 -0
  401. package/dist/components/Table/index.js +1 -0
  402. package/dist/components/Tabs/Tabs.css +79 -0
  403. package/dist/components/Tabs/Tabs.css.d.ts +6 -0
  404. package/dist/components/Tabs/Tabs.css.js +14 -0
  405. package/dist/components/Tabs/Tabs.d.ts +33 -0
  406. package/dist/components/Tabs/Tabs.docs.d.ts +19 -0
  407. package/dist/components/Tabs/Tabs.docs.js +56 -0
  408. package/dist/components/Tabs/Tabs.js +90 -0
  409. package/dist/components/Tabs/index.d.ts +1 -0
  410. package/dist/components/Tabs/index.js +1 -0
  411. package/dist/components/Tag/Tag.css +63 -0
  412. package/dist/components/Tag/Tag.css.d.ts +5 -0
  413. package/dist/components/Tag/Tag.css.js +10 -0
  414. package/dist/components/Tag/Tag.d.ts +13 -0
  415. package/dist/components/Tag/Tag.docs.d.ts +19 -0
  416. package/dist/components/Tag/Tag.docs.js +39 -0
  417. package/dist/components/Tag/Tag.js +35 -0
  418. package/dist/components/Tag/index.d.ts +1 -0
  419. package/dist/components/Tag/index.js +1 -0
  420. package/dist/components/Text/Text.css +86 -0
  421. package/dist/components/Text/Text.css.d.ts +6 -0
  422. package/dist/components/Text/Text.css.js +39 -0
  423. package/dist/components/Text/Text.d.ts +310 -0
  424. package/dist/components/Text/Text.docs.d.ts +19 -0
  425. package/dist/components/Text/Text.docs.js +52 -0
  426. package/dist/components/Text/Text.js +12 -0
  427. package/dist/components/Text/index.d.ts +1 -0
  428. package/dist/components/Text/index.js +1 -0
  429. package/dist/components/TextArea/TextArea.css +8 -0
  430. package/dist/components/TextArea/TextArea.css.d.ts +1 -0
  431. package/dist/components/TextArea/TextArea.css.js +5 -0
  432. package/dist/components/TextArea/TextArea.d.ts +15 -0
  433. package/dist/components/TextArea/TextArea.docs.d.ts +19 -0
  434. package/dist/components/TextArea/TextArea.docs.js +31 -0
  435. package/dist/components/TextArea/TextArea.js +33 -0
  436. package/dist/components/TextArea/index.d.ts +1 -0
  437. package/dist/components/TextArea/index.js +1 -0
  438. package/dist/components/TextField/TextField.d.ts +14 -0
  439. package/dist/components/TextField/TextField.docs.d.ts +19 -0
  440. package/dist/components/TextField/TextField.docs.js +59 -0
  441. package/dist/components/TextField/TextField.js +32 -0
  442. package/dist/components/TextField/index.d.ts +1 -0
  443. package/dist/components/TextField/index.js +1 -0
  444. package/dist/components/Timeline/Timeline.css +100 -0
  445. package/dist/components/Timeline/Timeline.css.d.ts +10 -0
  446. package/dist/components/Timeline/Timeline.css.js +15 -0
  447. package/dist/components/Timeline/Timeline.d.ts +22 -0
  448. package/dist/components/Timeline/Timeline.docs.d.ts +19 -0
  449. package/dist/components/Timeline/Timeline.docs.js +39 -0
  450. package/dist/components/Timeline/Timeline.js +42 -0
  451. package/dist/components/Timeline/index.d.ts +1 -0
  452. package/dist/components/Timeline/index.js +1 -0
  453. package/dist/components/Toast/Toast.css +106 -0
  454. package/dist/components/Toast/Toast.css.d.ts +11 -0
  455. package/dist/components/Toast/Toast.css.js +25 -0
  456. package/dist/components/Toast/Toast.d.ts +30 -0
  457. package/dist/components/Toast/Toast.docs.d.ts +19 -0
  458. package/dist/components/Toast/Toast.docs.js +49 -0
  459. package/dist/components/Toast/Toast.js +68 -0
  460. package/dist/components/Toast/ToastProvider.d.ts +12 -0
  461. package/dist/components/Toast/ToastProvider.js +140 -0
  462. package/dist/components/Toast/index.d.ts +3 -0
  463. package/dist/components/Toast/index.js +4 -0
  464. package/dist/components/Toast/toast-context.d.ts +21 -0
  465. package/dist/components/Toast/toast-context.js +11 -0
  466. package/dist/components/Tooltip/Tooltip.css +18 -0
  467. package/dist/components/Tooltip/Tooltip.css.d.ts +1 -0
  468. package/dist/components/Tooltip/Tooltip.css.js +5 -0
  469. package/dist/components/Tooltip/Tooltip.d.ts +45 -0
  470. package/dist/components/Tooltip/Tooltip.docs.d.ts +19 -0
  471. package/dist/components/Tooltip/Tooltip.docs.js +47 -0
  472. package/dist/components/Tooltip/Tooltip.js +93 -0
  473. package/dist/components/Tooltip/index.d.ts +1 -0
  474. package/dist/components/Tooltip/index.js +1 -0
  475. package/dist/icons/index.d.ts +293 -0
  476. package/dist/icons/index.js +395 -0
  477. package/dist/index.d.ts +66 -0
  478. package/dist/index.js +59 -0
  479. package/dist/internal/Field.d.ts +31 -0
  480. package/dist/internal/Field.js +54 -0
  481. package/dist/internal/field-ids.d.ts +7 -0
  482. package/dist/internal/field-ids.js +18 -0
  483. package/dist/internal/field.css +131 -0
  484. package/dist/internal/field.css.d.ts +16 -0
  485. package/dist/internal/field.css.js +22 -0
  486. package/dist/internal/floating-geometry.d.ts +42 -0
  487. package/dist/internal/floating-geometry.js +55 -0
  488. package/dist/internal/floating.css +36 -0
  489. package/dist/internal/floating.css.d.ts +8 -0
  490. package/dist/internal/floating.css.js +6 -0
  491. package/dist/internal/floating.d.ts +27 -0
  492. package/dist/internal/floating.js +118 -0
  493. package/dist/internal/useControllableState.d.ts +16 -0
  494. package/dist/internal/useControllableState.js +28 -0
  495. package/dist/internal/useOverflow.d.ts +7 -0
  496. package/dist/internal/useOverflow.js +24 -0
  497. package/dist/internal/usePopover.d.ts +28 -0
  498. package/dist/internal/usePopover.js +91 -0
  499. package/dist/manifest.json +12308 -0
  500. package/dist/patterns/dashboard-overview.docs.d.ts +22 -0
  501. package/dist/patterns/dashboard-overview.docs.js +80 -0
  502. package/dist/patterns/empty-state.docs.d.ts +22 -0
  503. package/dist/patterns/empty-state.docs.js +60 -0
  504. package/dist/patterns/index.d.ts +6 -0
  505. package/dist/patterns/index.js +14 -0
  506. package/dist/patterns/profile-card.docs.d.ts +22 -0
  507. package/dist/patterns/profile-card.docs.js +72 -0
  508. package/dist/patterns/settings-page.docs.d.ts +22 -0
  509. package/dist/patterns/settings-page.docs.js +76 -0
  510. package/dist/patterns/sign-in-form.docs.d.ts +22 -0
  511. package/dist/patterns/sign-in-form.docs.js +84 -0
  512. package/dist/primitives/VisuallyHidden.d.ts +13 -0
  513. package/dist/primitives/VisuallyHidden.js +18 -0
  514. package/dist/providers/LinkProvider.d.ts +18 -0
  515. package/dist/providers/LinkProvider.js +23 -0
  516. package/dist/providers/StringsProvider.d.ts +14 -0
  517. package/dist/providers/StringsProvider.js +25 -0
  518. package/dist/providers/link-context.d.ts +12 -0
  519. package/dist/providers/link-context.js +15 -0
  520. package/dist/providers/strings.d.ts +64 -0
  521. package/dist/providers/strings.js +38 -0
  522. package/dist/registry/gaps.d.ts +30 -0
  523. package/dist/registry/gaps.js +208 -0
  524. package/dist/registry/generated.d.ts +5 -0
  525. package/dist/registry/generated.js +2821 -0
  526. package/dist/registry/index.d.ts +36 -0
  527. package/dist/registry/index.js +201 -0
  528. package/dist/registry/types.d.ts +84 -0
  529. package/dist/styles/base.css +9 -0
  530. package/dist/styles/base.css.d.ts +1 -0
  531. package/dist/styles/base.css.js +1 -0
  532. package/dist/styles/layout.css +33 -0
  533. package/dist/styles/layout.css.d.ts +1 -0
  534. package/dist/styles/layout.css.js +17 -0
  535. package/dist/styles/shared.css +16 -0
  536. package/dist/styles/shared.css.d.ts +35 -0
  537. package/dist/styles/shared.css.js +5 -0
  538. package/dist/styles.css +3406 -0
  539. package/dist/themes/blueprint.css +115 -0
  540. package/dist/themes/contrast.d.ts +26 -0
  541. package/dist/themes/contrast.js +114 -0
  542. package/dist/themes/define.d.ts +9 -0
  543. package/dist/themes/define.js +29 -0
  544. package/dist/themes/dtcg.d.ts +126 -0
  545. package/dist/themes/dtcg.js +268 -0
  546. package/dist/themes/index.d.ts +19 -0
  547. package/dist/themes/index.js +21 -0
  548. package/dist/themes/letterpress.css +115 -0
  549. package/dist/themes/letterpress.d.ts +7 -0
  550. package/dist/themes/letterpress.js +187 -0
  551. package/dist/themes/presets/blueprint.d.ts +6 -0
  552. package/dist/themes/presets/blueprint.js +183 -0
  553. package/dist/themes/runtime/browser.d.ts +47 -0
  554. package/dist/themes/runtime/browser.js +164 -0
  555. package/dist/themes/runtime/cache.d.ts +43 -0
  556. package/dist/themes/runtime/cache.js +87 -0
  557. package/dist/themes/runtime/css.d.ts +43 -0
  558. package/dist/themes/runtime/css.js +89 -0
  559. package/dist/themes/runtime/diff.d.ts +22 -0
  560. package/dist/themes/runtime/diff.js +43 -0
  561. package/dist/themes/types.d.ts +59 -0
  562. package/dist/themes/values.d.ts +12 -0
  563. package/dist/themes/values.js +40 -0
  564. package/dist/tokens/blueprint.dark.tokens.json +1361 -0
  565. package/dist/tokens/blueprint.light.tokens.json +1361 -0
  566. package/dist/tokens/contract.d.ts +252 -0
  567. package/dist/tokens/contract.js +249 -0
  568. package/dist/tokens/index.d.ts +6 -0
  569. package/dist/tokens/index.js +1 -0
  570. package/dist/tokens/letterpress.dark.tokens.json +1391 -0
  571. package/dist/tokens/letterpress.light.tokens.json +1391 -0
  572. package/dist/tokens/tokens.css +117 -0
  573. package/dist/tokens/tokens.css.d.ts +128 -0
  574. package/dist/tokens/tokens.css.js +121 -0
  575. package/dist/utils/cx.d.ts +7 -0
  576. package/dist/utils/cx.js +14 -0
  577. package/dist/utils/space.d.ts +5 -0
  578. package/dist/utils/space.js +7 -0
  579. package/package.json +104 -3
@@ -0,0 +1,750 @@
1
+ // src/a2ui/validate.mjs
2
+ /**
3
+ * Checks A2UI v0.9 messages and components against a catalog document (the
4
+ * JSON that `buildCatalogJson()` returns, also committed as
5
+ * `generated/a2ui-catalog.json`).
6
+ *
7
+ * Plain JavaScript on purpose: the browser processor and the Vercel functions
8
+ * both import this file, and the functions run without a build step. Types
9
+ * live in `validate.d.mts`.
10
+ *
11
+ * It understands the JSON Schema subset the catalog uses: `$ref` (local
12
+ * pointers), `type`, `const`, `enum`, `oneOf`/`anyOf`, `properties`,
13
+ * `required`, `additionalProperties`, `items`, `minItems`/`maxItems`,
14
+ * `minLength`/`maxLength`, `pattern`, `minimum`/`maximum`, and two catalog
15
+ * extensions: function arguments are checked against `functions[call]`, and
16
+ * `x-derelicious.requireOneOf` lists props where at least one must be set.
17
+ */
18
+ var A2UI_VERSION = "v0.9";
19
+ /**
20
+ * The JSON Schema subset the catalog uses. Unknown keywords are ignored.
21
+ *
22
+ * @typedef {{
23
+ * $ref?: string,
24
+ * title?: string,
25
+ * const?: unknown,
26
+ * enum?: unknown[],
27
+ * oneOf?: JsonSchema[],
28
+ * anyOf?: JsonSchema[],
29
+ * type?: string | string[],
30
+ * format?: string,
31
+ * pattern?: string,
32
+ * minLength?: number,
33
+ * maxLength?: number,
34
+ * minimum?: number,
35
+ * maximum?: number,
36
+ * minItems?: number,
37
+ * maxItems?: number,
38
+ * items?: JsonSchema,
39
+ * properties?: Record<string, JsonSchema>,
40
+ * required?: string[],
41
+ * additionalProperties?: boolean | JsonSchema,
42
+ * 'x-derelicious'?: { requireOneOf?: string[][] },
43
+ * }} JsonSchema
44
+ * @typedef {import('./validate.d.mts').SchemaIssue} SchemaIssue
45
+ * @typedef {import('./validate.d.mts').MessageCheck} MessageCheck
46
+ * @typedef {import('./validate.d.mts').ComponentRefs} ComponentRefs
47
+ * @typedef {Record<string, unknown>} JsonObject
48
+ */
49
+ /**
50
+ * The value as a schema node, if it is an object.
51
+ *
52
+ * @param {unknown} value
53
+ * @returns {JsonSchema | undefined}
54
+ */
55
+ var asSchema = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
56
+ /**
57
+ * The value as a plain JSON object, if it is one.
58
+ *
59
+ * @param {unknown} value
60
+ * @returns {JsonObject | undefined}
61
+ */
62
+ var asObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
63
+ var MESSAGE_KINDS = [
64
+ "createSurface",
65
+ "updateComponents",
66
+ "updateDataModel",
67
+ "deleteSurface"
68
+ ];
69
+ var COMPONENT_ID_REF = "#/$defs/ComponentId";
70
+ var CHILD_LIST_REF = "#/$defs/ChildList";
71
+ var FUNCTION_CALL_REF = "#/$defs/FunctionCall";
72
+ var MAX_DEPTH = 48;
73
+ /** Longest regular expression a catalog value may carry. */
74
+ var MAX_PATTERN_LENGTH = 200;
75
+ /** Longest text a regular expression is tested against. */
76
+ var MAX_REGEX_INPUT = 1e3;
77
+ /** Object keys that would reach a prototype instead of data. */
78
+ var UNSAFE_KEYS = /* @__PURE__ */ new Set([
79
+ "__proto__",
80
+ "prototype",
81
+ "constructor"
82
+ ]);
83
+ /**
84
+ * True for a key that must never be read or written as data.
85
+ *
86
+ * @param {string} key
87
+ */
88
+ function isUnsafeKey(key) {
89
+ return UNSAFE_KEYS.has(key);
90
+ }
91
+ /**
92
+ * Why a regular expression from model output is unsafe to run, or null when
93
+ * it is fine. Generated patterns run on the main thread, so anything that can
94
+ * backtrack catastrophically is refused: a repeated group that itself repeats
95
+ * or alternates, like `(a+)+` or `(a|a)*`, and backreferences. Over-long and
96
+ * invalid patterns are refused too.
97
+ *
98
+ * @param {unknown} pattern
99
+ * @returns {string | null}
100
+ */
101
+ function unsafePatternReason(pattern) {
102
+ if (typeof pattern !== "string") return "it is not text";
103
+ if (pattern.length > 200) return `it is longer than 200 characters`;
104
+ try {
105
+ new RegExp(pattern, "u");
106
+ } catch {
107
+ return "it is not a valid regular expression";
108
+ }
109
+ if (/\\[1-9]|\\k</.test(pattern)) return "it uses a backreference";
110
+ /** One entry per open group: does it repeat or alternate inside? */
111
+ const groups = [{ risky: false }];
112
+ /** Mark the innermost open group as repeating or alternating. */
113
+ const markRisky = () => {
114
+ const open = groups.at(-1);
115
+ if (open) open.risky = true;
116
+ };
117
+ let inClass = false;
118
+ for (let index = 0; index < pattern.length; index += 1) {
119
+ const char = pattern[index];
120
+ if (char === "\\") {
121
+ index += 1;
122
+ continue;
123
+ }
124
+ if (inClass) {
125
+ if (char === "]") inClass = false;
126
+ continue;
127
+ }
128
+ if (char === "[") {
129
+ inClass = true;
130
+ continue;
131
+ }
132
+ const next = pattern[index + 1];
133
+ const repeats = next === "*" || next === "+" || next === "{";
134
+ if (char === "(") {
135
+ groups.push({ risky: false });
136
+ continue;
137
+ }
138
+ if (char === ")") {
139
+ const group = groups.pop() ?? { risky: false };
140
+ if (repeats && group.risky) return "a repeated group repeats or alternates inside (like \"(a+)+\")";
141
+ if (group.risky || repeats) markRisky();
142
+ continue;
143
+ }
144
+ if (char === "|") {
145
+ markRisky();
146
+ continue;
147
+ }
148
+ if (char === "*" || char === "+" || char === "{") markRisky();
149
+ }
150
+ return null;
151
+ }
152
+ /**
153
+ * A RegExp for a pattern from model output, or null when it is unsafe.
154
+ *
155
+ * @param {unknown} pattern
156
+ * @returns {RegExp | null}
157
+ */
158
+ function safeRegExp(pattern) {
159
+ if (unsafePatternReason(pattern) !== null) return null;
160
+ return new RegExp(pattern, "u");
161
+ }
162
+ /**
163
+ * Readable JSON for messages: short, single line.
164
+ *
165
+ * @param {unknown} value
166
+ */
167
+ function show(value) {
168
+ if (value === void 0) return "nothing";
169
+ let text;
170
+ try {
171
+ text = JSON.stringify(value);
172
+ } catch {
173
+ text = String(value);
174
+ }
175
+ if (text === void 0) text = String(value);
176
+ return text.length > 60 ? `${text.slice(0, 57)}…` : text;
177
+ }
178
+ /** @param {unknown} value */
179
+ function kindOf(value) {
180
+ if (value === null) return "null";
181
+ if (Array.isArray(value)) return "array";
182
+ if (typeof value === "number") return Number.isInteger(value) ? "integer" : "number";
183
+ return typeof value;
184
+ }
185
+ /** @type {Record<string, string>} */
186
+ var article = {
187
+ string: "a string",
188
+ number: "a number",
189
+ integer: "a whole number",
190
+ boolean: "true or false",
191
+ array: "an array",
192
+ object: "an object",
193
+ null: "null"
194
+ };
195
+ /**
196
+ * @param {string} type
197
+ * @param {unknown} value
198
+ */
199
+ function typeMatches(type, value) {
200
+ const kind = kindOf(value);
201
+ if (type === "number") return kind === "number" || kind === "integer";
202
+ return kind === type;
203
+ }
204
+ /**
205
+ * Edit distance, for "did you mean" hints.
206
+ *
207
+ * @param {string} a
208
+ * @param {string} b
209
+ * @returns {number}
210
+ */
211
+ function distance(a, b) {
212
+ const row = Array.from({ length: b.length + 1 }, (_, index) => index);
213
+ const at = (index) => row[index];
214
+ for (let i = 1; i <= a.length; i += 1) {
215
+ let previous = at(0);
216
+ row[0] = i;
217
+ for (let j = 1; j <= b.length; j += 1) {
218
+ const current = at(j);
219
+ row[j] = Math.min(at(j) + 1, at(j - 1) + 1, previous + (a[i - 1] === b[j - 1] ? 0 : 1));
220
+ previous = current;
221
+ }
222
+ }
223
+ return at(b.length);
224
+ }
225
+ /**
226
+ * The closest name within two edits, ignoring case.
227
+ *
228
+ * @param {string} name
229
+ * @param {readonly string[]} options
230
+ * @returns {string | null}
231
+ */
232
+ function suggest(name, options) {
233
+ /** @type {string | null} */
234
+ let best = null;
235
+ let bestScore = 3;
236
+ for (const option of options) {
237
+ const score = distance(name.toLowerCase(), option.toLowerCase());
238
+ if (score < bestScore) {
239
+ best = option;
240
+ bestScore = score;
241
+ }
242
+ }
243
+ return best;
244
+ }
245
+ /**
246
+ * @param {string} path
247
+ * @param {string | number} key
248
+ * @returns {string}
249
+ */
250
+ function join(path, key) {
251
+ if (typeof key === "number") return `${path}[${key}]`;
252
+ return path ? `${path}.${key}` : key;
253
+ }
254
+ /**
255
+ * Resolve a local `#/...` JSON Pointer against the catalog document.
256
+ *
257
+ * @param {unknown} root
258
+ * @param {unknown} ref
259
+ * @returns {JsonSchema | undefined}
260
+ */
261
+ function resolvePointer(root, ref) {
262
+ if (typeof ref !== "string" || !ref.startsWith("#/")) return void 0;
263
+ let node = root;
264
+ for (const raw of ref.slice(2).split("/")) {
265
+ const key = raw.replace(/~1/g, "/").replace(/~0/g, "~");
266
+ const object = asObject(node);
267
+ if (!object) return void 0;
268
+ node = object[key];
269
+ }
270
+ return asSchema(node);
271
+ }
272
+ /**
273
+ * @param {Record<string, unknown>} catalog The catalog document.
274
+ */
275
+ function createSchemaChecker(catalog) {
276
+ /**
277
+ * Words for what a schema accepts, used in error messages.
278
+ *
279
+ * @param {JsonSchema | undefined} schema
280
+ * @param {number} [depth]
281
+ * @returns {string}
282
+ */
283
+ function expected(schema, depth = 0) {
284
+ if (!schema || typeof schema !== "object" || depth > 4) return "a value";
285
+ if (schema.$ref) {
286
+ const target = resolvePointer(catalog, schema.$ref);
287
+ return target?.title ?? expected(target, depth + 1);
288
+ }
289
+ if (schema.title) return schema.title;
290
+ if ("const" in schema) return show(schema.const);
291
+ if (Array.isArray(schema.enum)) {
292
+ const values = schema.enum.map(show);
293
+ return values.length === 1 ? values[0] : `one of ${values.slice(0, 12).join(", ")}${values.length > 12 ? ", …" : ""}`;
294
+ }
295
+ const alternatives = schema.oneOf ?? schema.anyOf;
296
+ if (Array.isArray(alternatives)) return alternatives.map((item) => expected(item, depth + 1)).join(" or ");
297
+ if (typeof schema.type === "string") return article[schema.type] ?? "a value";
298
+ return "a value";
299
+ }
300
+ /**
301
+ * @param {unknown} value
302
+ * @param {JsonSchema | undefined} schema
303
+ * @param {string} path
304
+ * @param {number} [depth]
305
+ * @returns {SchemaIssue[]}
306
+ */
307
+ function check(value, schema, path, depth = 0) {
308
+ if (!schema || typeof schema !== "object") return [];
309
+ if (depth > MAX_DEPTH) return [{
310
+ path,
311
+ message: `${path || "value"} is nested too deeply`
312
+ }];
313
+ const where = path || "value";
314
+ if (schema.$ref) {
315
+ const target = resolvePointer(catalog, schema.$ref);
316
+ if (!target) return [{
317
+ path,
318
+ message: `${where} uses an unknown schema`
319
+ }];
320
+ const issues = check(value, target, path, depth + 1);
321
+ const call = asObject(value);
322
+ if (issues.length === 0 && schema.$ref === FUNCTION_CALL_REF && call) return checkFunctionArgs(call, path, depth);
323
+ return issues;
324
+ }
325
+ if ("const" in schema && value !== schema.const) return [{
326
+ path,
327
+ message: `${where} should be ${show(schema.const)}, not ${show(value)}`
328
+ }];
329
+ if (Array.isArray(schema.enum) && !schema.enum.includes(value)) {
330
+ const hint = typeof value === "string" ? suggest(value, schema.enum.filter(
331
+ /** @returns {item is string} */
332
+ (item) => typeof item === "string"
333
+ )) : null;
334
+ return [{
335
+ path,
336
+ message: `${where} should be ${expected(schema)}, not ${show(value)}${hint ? `. Did you mean ${show(hint)}?` : ""}`
337
+ }];
338
+ }
339
+ const alternatives = schema.oneOf ?? schema.anyOf;
340
+ if (Array.isArray(alternatives)) {
341
+ /** @type {{ issues: SchemaIssue[], count: number, shapeMatches: boolean } | null} */
342
+ let best = null;
343
+ for (const alternative of alternatives) {
344
+ const issues = check(value, alternative, path, depth + 1);
345
+ if (issues.length === 0) return [];
346
+ const shapeMatches = alternativeMatchesKind(alternative, value);
347
+ if (shapeMatches && (best === null || !best.shapeMatches || issues.length < best.count)) best = {
348
+ issues,
349
+ count: issues.length,
350
+ shapeMatches
351
+ };
352
+ }
353
+ if (best) return best.issues;
354
+ return [{
355
+ path,
356
+ message: `${where} should be ${expected(schema)}, not ${show(value)}`
357
+ }];
358
+ }
359
+ if (schema.type !== void 0) {
360
+ if (!(Array.isArray(schema.type) ? schema.type : [schema.type]).some((type) => typeMatches(type, value))) return [{
361
+ path,
362
+ message: `${where} should be ${expected(schema)}, not ${show(value)}`
363
+ }];
364
+ }
365
+ /** @type {SchemaIssue[]} */
366
+ const issues = [];
367
+ if (typeof value === "string") {
368
+ if (typeof schema.minLength === "number" && value.length < schema.minLength) issues.push({
369
+ path,
370
+ message: schema.minLength === 1 ? `${where} should not be empty` : `${where} should be at least ${schema.minLength} characters`
371
+ });
372
+ if (typeof schema.maxLength === "number" && value.length > schema.maxLength) issues.push({
373
+ path,
374
+ message: `${where} should be at most ${schema.maxLength} characters`
375
+ });
376
+ if (schema.format === "regex") {
377
+ const reason = unsafePatternReason(value);
378
+ if (reason) issues.push({
379
+ path,
380
+ message: `${where} is not an allowed regular expression: ${reason}`
381
+ });
382
+ }
383
+ if (typeof schema.pattern === "string") {
384
+ let pattern = null;
385
+ try {
386
+ pattern = new RegExp(schema.pattern, "u");
387
+ } catch {
388
+ pattern = null;
389
+ }
390
+ if (pattern && !pattern.test(value)) issues.push({
391
+ path,
392
+ message: `${where} should be ${schema.title ?? `text matching ${schema.pattern}`}, not ${show(value)}`
393
+ });
394
+ }
395
+ }
396
+ if (typeof value === "number") {
397
+ if (typeof schema.minimum === "number" && value < schema.minimum) issues.push({
398
+ path,
399
+ message: `${where} should be at least ${schema.minimum}`
400
+ });
401
+ if (typeof schema.maximum === "number" && value > schema.maximum) issues.push({
402
+ path,
403
+ message: `${where} should be at most ${schema.maximum}`
404
+ });
405
+ }
406
+ if (Array.isArray(value)) {
407
+ if (typeof schema.minItems === "number" && value.length < schema.minItems) issues.push({
408
+ path,
409
+ message: `${where} needs at least ${schema.minItems} item${schema.minItems === 1 ? "" : "s"}`
410
+ });
411
+ if (typeof schema.maxItems === "number" && value.length > schema.maxItems) issues.push({
412
+ path,
413
+ message: `${where} has ${value.length} items; the most is ${schema.maxItems}`
414
+ });
415
+ if (schema.items && typeof schema.items === "object") value.forEach((item, index) => {
416
+ issues.push(...check(item, schema.items, join(path, index), depth + 1));
417
+ });
418
+ }
419
+ const object = asObject(value);
420
+ if (object) {
421
+ const properties = schema.properties ?? {};
422
+ for (const key of schema.required ?? []) if (object[key] === void 0) issues.push({
423
+ path: join(path, key),
424
+ message: `${path ? `${where} is ` : ""}missing required prop "${key}"`
425
+ });
426
+ for (const [key, item] of Object.entries(object)) {
427
+ if (item === void 0) continue;
428
+ if (isUnsafeKey(key)) {
429
+ issues.push({
430
+ path: join(path, key),
431
+ message: `${path ? `${where} has ` : ""}a reserved key "${key}"`
432
+ });
433
+ continue;
434
+ }
435
+ if (Object.hasOwn(properties, key)) issues.push(...check(item, properties[key], join(path, key), depth + 1));
436
+ else if (schema.additionalProperties === false) {
437
+ const hint = suggest(key, Object.keys(properties));
438
+ issues.push({
439
+ path: join(path, key),
440
+ message: `${path ? `${where} has ` : ""}unknown prop "${key}"${hint ? `. Did you mean "${hint}"?` : ""}`
441
+ });
442
+ } else if (schema.additionalProperties && typeof schema.additionalProperties === "object") issues.push(...check(item, schema.additionalProperties, join(path, key), depth + 1));
443
+ }
444
+ const rules = schema["x-derelicious"]?.requireOneOf ?? [];
445
+ for (const group of rules) if (!group.some((key) => object[key] !== void 0)) issues.push({
446
+ path,
447
+ message: `${path ? `${where} needs` : "needs"} ${group.map((key) => `"${key}"`).join(" or ")}`
448
+ });
449
+ }
450
+ return issues;
451
+ }
452
+ /**
453
+ * @param {JsonSchema} schema
454
+ * @param {unknown} value
455
+ * @returns {boolean}
456
+ */
457
+ function alternativeMatchesKind(schema, value) {
458
+ /** @type {JsonSchema | undefined} */
459
+ let node = schema;
460
+ for (let hops = 0; node?.$ref && hops < 8; hops += 1) node = resolvePointer(catalog, node.$ref);
461
+ if (!node || typeof node !== "object") return false;
462
+ if ("const" in node) return kindOf(node.const) === kindOf(value);
463
+ if (Array.isArray(node.enum)) return node.enum.some((item) => kindOf(item) === kindOf(value));
464
+ const nested = node.oneOf ?? node.anyOf;
465
+ if (Array.isArray(nested)) return nested.some((item) => alternativeMatchesKind(item, value));
466
+ if (node.type === void 0) return true;
467
+ return (Array.isArray(node.type) ? node.type : [node.type]).some((type) => typeMatches(type, value));
468
+ }
469
+ /**
470
+ * @param {JsonObject} value a FunctionCall
471
+ * @param {string} path
472
+ * @param {number} depth
473
+ * @returns {SchemaIssue[]}
474
+ */
475
+ function checkFunctionArgs(value, path, depth) {
476
+ const functions = asObject(catalog.functions) ?? {};
477
+ if (typeof value.call !== "string" || !Object.hasOwn(functions, value.call)) return [];
478
+ const argsSchema = asSchema(functions[value.call])?.properties?.args;
479
+ if (!argsSchema) return [];
480
+ const label = `${value.call}()`;
481
+ if (value.args === void 0) return (argsSchema.required ?? []).length ? [{
482
+ path,
483
+ message: `${label} needs args`
484
+ }] : [];
485
+ return check(value.args, argsSchema, join(path, "args"), depth + 1).map((issue) => ({
486
+ ...issue,
487
+ message: issue.message.startsWith(`${label}`) ? issue.message : `${label}: ${issue.message}`
488
+ }));
489
+ }
490
+ return {
491
+ check,
492
+ expected
493
+ };
494
+ }
495
+ /**
496
+ * Component ids a component points at, found by walking its props against
497
+ * the catalog schema: every `ComponentId`, every id in a `ChildList` array,
498
+ * and every `ChildList` template.
499
+ *
500
+ * @param {JsonObject} catalog
501
+ */
502
+ function createRefCollector(catalog) {
503
+ /**
504
+ * @param {unknown} value
505
+ * @param {JsonSchema | undefined} schema
506
+ * @param {ComponentRefs} out
507
+ * @param {number} [depth]
508
+ */
509
+ function collect(value, schema, out, depth = 0) {
510
+ if (!schema || typeof schema !== "object" || depth > MAX_DEPTH) return;
511
+ if (schema.$ref === COMPONENT_ID_REF) {
512
+ if (typeof value === "string") out.ids.push(value);
513
+ return;
514
+ }
515
+ if (schema.$ref === CHILD_LIST_REF) {
516
+ const template = asObject(value);
517
+ if (Array.isArray(value)) {
518
+ for (const id of value) if (typeof id === "string") out.ids.push(id);
519
+ } else if (template && typeof template.componentId === "string" && typeof template.path === "string") out.templates.push({
520
+ componentId: template.componentId,
521
+ path: template.path
522
+ });
523
+ return;
524
+ }
525
+ if (schema.$ref) {
526
+ collect(value, resolvePointer(catalog, schema.$ref), out, depth + 1);
527
+ return;
528
+ }
529
+ for (const alternative of schema.oneOf ?? schema.anyOf ?? []) collect(value, alternative, out, depth + 1);
530
+ if (Array.isArray(value) && schema.items) for (const item of value) collect(item, schema.items, out, depth + 1);
531
+ const object = asObject(value);
532
+ if (object) {
533
+ for (const [key, propSchema] of Object.entries(schema.properties ?? {})) if (object[key] !== void 0) collect(object[key], propSchema, out, depth + 1);
534
+ }
535
+ }
536
+ return collect;
537
+ }
538
+ /**
539
+ * @param {Record<string, unknown>} catalog The catalog document.
540
+ * @param {{ catalogIds?: string[] }} [options] Catalog ids createSurface may
541
+ * name. Defaults to the catalog's own id and the one it extends.
542
+ */
543
+ function createCatalogValidator(catalog, options = {}) {
544
+ const { check, expected } = createSchemaChecker(catalog);
545
+ const collect = createRefCollector(catalog);
546
+ /** @type {Record<string, JsonSchema>} */
547
+ const components = asObject(catalog.components) ?? {};
548
+ const types = Object.keys(components);
549
+ const catalogId = typeof catalog.catalogId === "string" ? catalog.catalogId : "";
550
+ const catalogIds = options.catalogIds ?? [catalog.catalogId, catalog.extends].filter(
551
+ /** @returns {id is string} */
552
+ (id) => typeof id === "string"
553
+ );
554
+ /**
555
+ * @param {unknown} value
556
+ * @returns {SchemaIssue[]}
557
+ */
558
+ function validateComponent(value) {
559
+ const component = asObject(value);
560
+ if (!component) return [{
561
+ path: "",
562
+ message: `a component should be an object, not ${show(value)}`
563
+ }];
564
+ if (typeof component.id !== "string" || component.id.length === 0) return [{
565
+ path: "id",
566
+ message: "a component is missing its \"id\""
567
+ }];
568
+ if (typeof component.component !== "string") return [{
569
+ path: "component",
570
+ message: `"${component.id}" is missing its "component" type`
571
+ }];
572
+ const schema = Object.hasOwn(components, component.component) ? components[component.component] : void 0;
573
+ if (!schema) {
574
+ const hint = suggest(component.component, types);
575
+ return [{
576
+ path: "component",
577
+ message: `"${component.id}" uses unknown component "${component.component}"${hint ? `. Did you mean "${hint}"?` : ""}`
578
+ }];
579
+ }
580
+ return check(component, schema, "").map((issue) => ({
581
+ ...issue,
582
+ message: `"${component.id}" (${component.component}): ${issue.message}`
583
+ }));
584
+ }
585
+ /**
586
+ * @param {unknown} value
587
+ * @returns {ComponentRefs}
588
+ */
589
+ function componentRefs(value) {
590
+ /** @type {ComponentRefs} */
591
+ const out = {
592
+ ids: [],
593
+ templates: []
594
+ };
595
+ const component = asObject(value);
596
+ const type = component?.component;
597
+ const schema = typeof type === "string" && Object.hasOwn(components, type) ? components[type] : void 0;
598
+ if (schema && component) {
599
+ const { id: _own, ...props } = component;
600
+ collect(props, schema, out);
601
+ }
602
+ return {
603
+ ids: [...new Set(out.ids)],
604
+ templates: out.templates
605
+ };
606
+ }
607
+ /**
608
+ * Check one server-to-client message. For updateComponents, a bad
609
+ * component is reported in `components` and does not fail the envelope,
610
+ * so callers can keep the good ones.
611
+ *
612
+ * @param {unknown} value
613
+ * @returns {MessageCheck}
614
+ */
615
+ function validateMessage(value) {
616
+ /** @type {MessageCheck} */
617
+ const result = {
618
+ ok: false,
619
+ kind: null,
620
+ surfaceId: null,
621
+ issues: [],
622
+ components: []
623
+ };
624
+ const message = asObject(value);
625
+ if (!message) {
626
+ result.issues.push(`a message should be a JSON object, not ${show(value)}`);
627
+ return result;
628
+ }
629
+ if (message.version !== "v0.9") result.issues.push(`"version" should be "${A2UI_VERSION}", not ${show(message.version)}`);
630
+ const kinds = MESSAGE_KINDS.filter((kind) => message[kind] !== void 0);
631
+ const extra = Object.keys(message).filter((key) => key !== "version" && !MESSAGE_KINDS.includes(key));
632
+ for (const key of extra) {
633
+ const hint = suggest(key, MESSAGE_KINDS);
634
+ result.issues.push(`unknown message key "${key}"${hint ? `. Did you mean "${hint}"?` : ""}`);
635
+ }
636
+ if (kinds.length !== 1) {
637
+ result.issues.push(kinds.length === 0 ? `a message needs one of ${MESSAGE_KINDS.join(", ")}` : `a message can carry only one of ${kinds.join(", ")}`);
638
+ return result;
639
+ }
640
+ const [kind] = kinds;
641
+ if (!kind) return result;
642
+ result.kind = kind;
643
+ const body = asObject(message[kind]);
644
+ if (!body) {
645
+ result.issues.push(`"${kind}" should be an object`);
646
+ return result;
647
+ }
648
+ if (typeof body.surfaceId !== "string" || body.surfaceId.length === 0) result.issues.push(`"${kind}" is missing "surfaceId"`);
649
+ else result.surfaceId = body.surfaceId;
650
+ const allowed = {
651
+ createSurface: [
652
+ "surfaceId",
653
+ "catalogId",
654
+ "theme",
655
+ "sendDataModel"
656
+ ],
657
+ updateComponents: ["surfaceId", "components"],
658
+ updateDataModel: [
659
+ "surfaceId",
660
+ "path",
661
+ "value"
662
+ ],
663
+ deleteSurface: ["surfaceId"]
664
+ }[kind];
665
+ for (const key of Object.keys(body)) if (!allowed.includes(key)) {
666
+ const hint = suggest(key, allowed);
667
+ result.issues.push(`"${kind}" has unknown key "${key}"${hint ? `. Did you mean "${hint}"?` : ""}`);
668
+ }
669
+ if (kind === "createSurface") {
670
+ if (typeof body.catalogId !== "string") result.issues.push("\"createSurface\" is missing \"catalogId\"");
671
+ else if (!catalogIds.includes(body.catalogId)) result.issues.push(`catalog ${show(body.catalogId)} is not supported. Use "${catalogId}"`);
672
+ if (body.theme !== void 0 && (body.theme === null || typeof body.theme !== "object" || Array.isArray(body.theme))) result.issues.push("\"theme\" should be an object");
673
+ if (body.sendDataModel !== void 0 && typeof body.sendDataModel !== "boolean") result.issues.push("\"sendDataModel\" should be true or false");
674
+ }
675
+ if (kind === "updateComponents") {
676
+ if (!Array.isArray(body.components) || body.components.length === 0) result.issues.push("\"updateComponents\" needs a non-empty \"components\" array");
677
+ else {
678
+ const seen = /* @__PURE__ */ new Set();
679
+ result.components = body.components.map((component, index) => {
680
+ const issues = validateComponent(component);
681
+ const raw = asObject(component)?.id;
682
+ const id = typeof raw === "string" ? raw : null;
683
+ if (id && seen.has(id)) issues.push({
684
+ path: "id",
685
+ message: `"${id}" appears twice in one message`
686
+ });
687
+ if (id) seen.add(id);
688
+ return {
689
+ index,
690
+ id,
691
+ issues
692
+ };
693
+ });
694
+ }
695
+ }
696
+ if (kind === "updateDataModel") {
697
+ if (body.path !== void 0 && !isPointer(body.path)) result.issues.push(`"path" should be a JSON Pointer like "/user/name", not ${show(body.path)}`);
698
+ else if (pointerHasUnsafeKey(body.path)) result.issues.push(`"path" uses the reserved key "__proto__": ${show(body.path)}`);
699
+ if (valueHasUnsafeKey(body.value)) result.issues.push("\"value\" uses the reserved key \"__proto__\"");
700
+ }
701
+ result.ok = result.issues.length === 0;
702
+ return result;
703
+ }
704
+ return {
705
+ catalogId,
706
+ types,
707
+ has: (type) => typeof type === "string" && Object.hasOwn(components, type),
708
+ expected,
709
+ check,
710
+ validateComponent,
711
+ validateMessage,
712
+ componentRefs
713
+ };
714
+ }
715
+ /**
716
+ * True when a JSON Pointer names `__proto__`. Data may use any other key;
717
+ * only `__proto__` reaches an object's prototype when it is assigned.
718
+ *
719
+ * @param {unknown} path
720
+ */
721
+ function pointerHasUnsafeKey(path) {
722
+ if (typeof path !== "string") return false;
723
+ return path.split("/").some((token) => token.replace(/~1/g, "/").replace(/~0/g, "~") === "__proto__");
724
+ }
725
+ /**
726
+ * True when a JSON value has a `__proto__` key at any depth.
727
+ *
728
+ * @param {unknown} value
729
+ * @param {number} [depth]
730
+ * @returns {boolean}
731
+ */
732
+ function valueHasUnsafeKey(value, depth = 0) {
733
+ if (!value || typeof value !== "object" || depth > MAX_DEPTH) return false;
734
+ const object = value;
735
+ for (const key of Object.keys(object)) {
736
+ if (key === "__proto__") return true;
737
+ if (valueHasUnsafeKey(object[key], depth + 1)) return true;
738
+ }
739
+ return false;
740
+ }
741
+ /**
742
+ * True for "" , "/" and "/a/b" style JSON Pointers.
743
+ *
744
+ * @param {unknown} path
745
+ * @returns {path is string}
746
+ */
747
+ function isPointer(path) {
748
+ return typeof path === "string" && (path === "" || path.startsWith("/"));
749
+ }
750
+ export { A2UI_VERSION, MAX_PATTERN_LENGTH, MAX_REGEX_INPUT, createCatalogValidator, createSchemaChecker, isPointer, isUnsafeKey, pointerHasUnsafeKey, safeRegExp, suggest, unsafePatternReason, valueHasUnsafeKey };