@assistant-ui/react-generative-ui 0.0.23 → 0.1.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 (338) hide show
  1. package/README.md +2 -0
  2. package/dist/a2ui.d.ts +1 -4
  3. package/dist/a2ui.d.ts.map +1 -1
  4. package/dist/a2ui.js +1 -4
  5. package/dist/index.d.ts +1 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +1 -10
  8. package/dist/index.server.d.ts +1 -2
  9. package/dist/index.server.d.ts.map +1 -1
  10. package/dist/index.server.js +1 -10
  11. package/dist/ir.d.ts +1 -111
  12. package/dist/ir.d.ts.map +1 -1
  13. package/dist/ir.js +1 -175
  14. package/dist/slack.d.ts +1 -4
  15. package/dist/slack.d.ts.map +1 -1
  16. package/dist/slack.js +1 -4
  17. package/dist/teams.d.ts +1 -4
  18. package/dist/teams.d.ts.map +1 -1
  19. package/dist/teams.js +1 -4
  20. package/package.json +5 -5
  21. package/src/a2ui.ts +1 -22
  22. package/src/index.server.ts +1 -2
  23. package/src/index.test.ts +75 -0
  24. package/src/index.ts +1 -2
  25. package/src/ir.ts +1 -279
  26. package/src/slack.ts +1 -39
  27. package/src/teams.ts +1 -35
  28. package/dist/JSONGenerativeUI.client.d.ts +0 -28
  29. package/dist/JSONGenerativeUI.client.d.ts.map +0 -1
  30. package/dist/JSONGenerativeUI.client.js +0 -101
  31. package/dist/JSONGenerativeUI.client.js.map +0 -1
  32. package/dist/JSONGenerativeUI.server.d.ts +0 -21
  33. package/dist/JSONGenerativeUI.server.d.ts.map +0 -1
  34. package/dist/JSONGenerativeUI.server.js +0 -32
  35. package/dist/JSONGenerativeUI.server.js.map +0 -1
  36. package/dist/JSONGenerativeUI.shared.d.ts +0 -63
  37. package/dist/JSONGenerativeUI.shared.d.ts.map +0 -1
  38. package/dist/JSONGenerativeUI.shared.js +0 -31
  39. package/dist/JSONGenerativeUI.shared.js.map +0 -1
  40. package/dist/RadioGroupScope.d.ts +0 -6
  41. package/dist/RadioGroupScope.d.ts.map +0 -1
  42. package/dist/RadioGroupScope.js +0 -25
  43. package/dist/RadioGroupScope.js.map +0 -1
  44. package/dist/a2ui/BindingContext.d.ts +0 -11
  45. package/dist/a2ui/BindingContext.d.ts.map +0 -1
  46. package/dist/a2ui/BindingContext.js +0 -12
  47. package/dist/a2ui/BindingContext.js.map +0 -1
  48. package/dist/a2ui/PresentRenderer.d.ts +0 -11
  49. package/dist/a2ui/PresentRenderer.d.ts.map +0 -1
  50. package/dist/a2ui/PresentRenderer.js +0 -39
  51. package/dist/a2ui/PresentRenderer.js.map +0 -1
  52. package/dist/a2ui/convert.d.ts +0 -15
  53. package/dist/a2ui/convert.d.ts.map +0 -1
  54. package/dist/a2ui/convert.js +0 -728
  55. package/dist/a2ui/convert.js.map +0 -1
  56. package/dist/a2ui/dataModel.d.ts +0 -9
  57. package/dist/a2ui/dataModel.d.ts.map +0 -1
  58. package/dist/a2ui/dataModel.js +0 -44
  59. package/dist/a2ui/dataModel.js.map +0 -1
  60. package/dist/a2ui/reducer.d.ts +0 -8
  61. package/dist/a2ui/reducer.d.ts.map +0 -1
  62. package/dist/a2ui/reducer.js +0 -242
  63. package/dist/a2ui/reducer.js.map +0 -1
  64. package/dist/a2ui/snapshot.d.ts +0 -3
  65. package/dist/a2ui/snapshot.d.ts.map +0 -1
  66. package/dist/a2ui/snapshot.js +0 -33
  67. package/dist/a2ui/snapshot.js.map +0 -1
  68. package/dist/a2ui/types.d.ts +0 -88
  69. package/dist/a2ui/types.d.ts.map +0 -1
  70. package/dist/a2ui/types.js +0 -6
  71. package/dist/a2ui/types.js.map +0 -1
  72. package/dist/a2ui/valueFunctions.d.ts +0 -16
  73. package/dist/a2ui/valueFunctions.d.ts.map +0 -1
  74. package/dist/a2ui/valueFunctions.js +0 -332
  75. package/dist/a2ui/valueFunctions.js.map +0 -1
  76. package/dist/actionRegistry.d.ts +0 -29
  77. package/dist/actionRegistry.d.ts.map +0 -1
  78. package/dist/actionRegistry.js +0 -41
  79. package/dist/actionRegistry.js.map +0 -1
  80. package/dist/answeredValues.d.ts +0 -16
  81. package/dist/answeredValues.d.ts.map +0 -1
  82. package/dist/answeredValues.js +0 -37
  83. package/dist/answeredValues.js.map +0 -1
  84. package/dist/buildPresentParameters.d.ts +0 -21
  85. package/dist/buildPresentParameters.d.ts.map +0 -1
  86. package/dist/buildPresentParameters.js +0 -95
  87. package/dist/buildPresentParameters.js.map +0 -1
  88. package/dist/constants.d.ts +0 -15
  89. package/dist/constants.d.ts.map +0 -1
  90. package/dist/constants.js +0 -19
  91. package/dist/constants.js.map +0 -1
  92. package/dist/convert/boundSpec.d.ts +0 -48
  93. package/dist/convert/boundSpec.d.ts.map +0 -1
  94. package/dist/convert/boundSpec.js +0 -108
  95. package/dist/convert/boundSpec.js.map +0 -1
  96. package/dist/convert/copyBounded.d.ts +0 -25
  97. package/dist/convert/copyBounded.d.ts.map +0 -1
  98. package/dist/convert/copyBounded.js +0 -38
  99. package/dist/convert/copyBounded.js.map +0 -1
  100. package/dist/convert/isElement.d.ts +0 -3
  101. package/dist/convert/isElement.d.ts.map +0 -1
  102. package/dist/convert/isElement.js +0 -6
  103. package/dist/convert/isElement.js.map +0 -1
  104. package/dist/convert/takeRun.d.ts +0 -6
  105. package/dist/convert/takeRun.d.ts.map +0 -1
  106. package/dist/convert/takeRun.js +0 -20
  107. package/dist/convert/takeRun.js.map +0 -1
  108. package/dist/defineGenerativeComponents.d.ts +0 -29
  109. package/dist/defineGenerativeComponents.d.ts.map +0 -1
  110. package/dist/defineGenerativeComponents.js +0 -34
  111. package/dist/defineGenerativeComponents.js.map +0 -1
  112. package/dist/fieldReferences.d.ts +0 -9
  113. package/dist/fieldReferences.d.ts.map +0 -1
  114. package/dist/fieldReferences.js +0 -53
  115. package/dist/fieldReferences.js.map +0 -1
  116. package/dist/generativeUIToJSX.d.ts +0 -18
  117. package/dist/generativeUIToJSX.d.ts.map +0 -1
  118. package/dist/generativeUIToJSX.js +0 -76
  119. package/dist/generativeUIToJSX.js.map +0 -1
  120. package/dist/index.shared.d.ts +0 -15
  121. package/dist/index.shared.d.ts.map +0 -1
  122. package/dist/index.shared.js +0 -9
  123. package/dist/ir.js.map +0 -1
  124. package/dist/renderGenerativeUI.d.ts +0 -14
  125. package/dist/renderGenerativeUI.d.ts.map +0 -1
  126. package/dist/renderGenerativeUI.js +0 -83
  127. package/dist/renderGenerativeUI.js.map +0 -1
  128. package/dist/scopeSchema.d.ts +0 -6
  129. package/dist/scopeSchema.d.ts.map +0 -1
  130. package/dist/scopeSchema.js +0 -56
  131. package/dist/scopeSchema.js.map +0 -1
  132. package/dist/slack/constants.d.ts +0 -93
  133. package/dist/slack/constants.d.ts.map +0 -1
  134. package/dist/slack/constants.js +0 -146
  135. package/dist/slack/constants.js.map +0 -1
  136. package/dist/slack/decodeBlockAction.d.ts +0 -10
  137. package/dist/slack/decodeBlockAction.d.ts.map +0 -1
  138. package/dist/slack/decodeBlockAction.js +0 -129
  139. package/dist/slack/decodeBlockAction.js.map +0 -1
  140. package/dist/slack/fromSlackBlocks.d.ts +0 -27
  141. package/dist/slack/fromSlackBlocks.d.ts.map +0 -1
  142. package/dist/slack/fromSlackBlocks.js +0 -483
  143. package/dist/slack/fromSlackBlocks.js.map +0 -1
  144. package/dist/slack/toSlackBlocks.d.ts +0 -4
  145. package/dist/slack/toSlackBlocks.d.ts.map +0 -1
  146. package/dist/slack/toSlackBlocks.js +0 -901
  147. package/dist/slack/toSlackBlocks.js.map +0 -1
  148. package/dist/slack/types.d.ts +0 -204
  149. package/dist/slack/types.d.ts.map +0 -1
  150. package/dist/slack/types.js +0 -0
  151. package/dist/teams/constants.d.ts +0 -34
  152. package/dist/teams/constants.d.ts.map +0 -1
  153. package/dist/teams/constants.js +0 -68
  154. package/dist/teams/constants.js.map +0 -1
  155. package/dist/teams/decodeSubmitData.d.ts +0 -26
  156. package/dist/teams/decodeSubmitData.d.ts.map +0 -1
  157. package/dist/teams/decodeSubmitData.js +0 -70
  158. package/dist/teams/decodeSubmitData.js.map +0 -1
  159. package/dist/teams/temporalId.d.ts +0 -5
  160. package/dist/teams/temporalId.d.ts.map +0 -1
  161. package/dist/teams/temporalId.js +0 -28
  162. package/dist/teams/temporalId.js.map +0 -1
  163. package/dist/teams/toAdaptiveCard.d.ts +0 -45
  164. package/dist/teams/toAdaptiveCard.d.ts.map +0 -1
  165. package/dist/teams/toAdaptiveCard.js +0 -642
  166. package/dist/teams/toAdaptiveCard.js.map +0 -1
  167. package/dist/teams/toTeamsAttachments.d.ts +0 -10
  168. package/dist/teams/toTeamsAttachments.d.ts.map +0 -1
  169. package/dist/teams/toTeamsAttachments.js +0 -99
  170. package/dist/teams/toTeamsAttachments.js.map +0 -1
  171. package/dist/teams/types.d.ts +0 -224
  172. package/dist/teams/types.d.ts.map +0 -1
  173. package/dist/teams/types.js +0 -0
  174. package/dist/temporal.d.ts +0 -33
  175. package/dist/temporal.d.ts.map +0 -1
  176. package/dist/temporal.js +0 -152
  177. package/dist/temporal.js.map +0 -1
  178. package/dist/types.d.ts +0 -99
  179. package/dist/types.d.ts.map +0 -1
  180. package/dist/types.js +0 -0
  181. package/dist/vocabulary/alert.d.ts +0 -32
  182. package/dist/vocabulary/alert.d.ts.map +0 -1
  183. package/dist/vocabulary/alert.js +0 -160
  184. package/dist/vocabulary/alert.js.map +0 -1
  185. package/dist/vocabulary/collectFormValues.d.ts +0 -23
  186. package/dist/vocabulary/collectFormValues.d.ts.map +0 -1
  187. package/dist/vocabulary/collectFormValues.js +0 -44
  188. package/dist/vocabulary/collectFormValues.js.map +0 -1
  189. package/dist/vocabulary/data.d.ts +0 -66
  190. package/dist/vocabulary/data.d.ts.map +0 -1
  191. package/dist/vocabulary/data.js +0 -503
  192. package/dist/vocabulary/data.js.map +0 -1
  193. package/dist/vocabulary/dispatch.d.ts +0 -9
  194. package/dist/vocabulary/dispatch.d.ts.map +0 -1
  195. package/dist/vocabulary/dispatch.js +0 -50
  196. package/dist/vocabulary/dispatch.js.map +0 -1
  197. package/dist/vocabulary/fact.d.ts +0 -19
  198. package/dist/vocabulary/fact.d.ts.map +0 -1
  199. package/dist/vocabulary/fact.js +0 -51
  200. package/dist/vocabulary/fact.js.map +0 -1
  201. package/dist/vocabulary/form.d.ts +0 -11
  202. package/dist/vocabulary/form.d.ts.map +0 -1
  203. package/dist/vocabulary/form.js +0 -23
  204. package/dist/vocabulary/form.js.map +0 -1
  205. package/dist/vocabulary/formatValue.d.ts +0 -7
  206. package/dist/vocabulary/formatValue.d.ts.map +0 -1
  207. package/dist/vocabulary/formatValue.js +0 -76
  208. package/dist/vocabulary/formatValue.js.map +0 -1
  209. package/dist/vocabulary/icon.d.ts +0 -41
  210. package/dist/vocabulary/icon.d.ts.map +0 -1
  211. package/dist/vocabulary/icon.js +0 -272
  212. package/dist/vocabulary/icon.js.map +0 -1
  213. package/dist/vocabulary/index.d.ts +0 -12
  214. package/dist/vocabulary/index.d.ts.map +0 -1
  215. package/dist/vocabulary/index.js +0 -36
  216. package/dist/vocabulary/index.js.map +0 -1
  217. package/dist/vocabulary/interactive.d.ts +0 -230
  218. package/dist/vocabulary/interactive.d.ts.map +0 -1
  219. package/dist/vocabulary/interactive.js +0 -530
  220. package/dist/vocabulary/interactive.js.map +0 -1
  221. package/dist/vocabulary/layout.d.ts +0 -79
  222. package/dist/vocabulary/layout.d.ts.map +0 -1
  223. package/dist/vocabulary/layout.js +0 -139
  224. package/dist/vocabulary/layout.js.map +0 -1
  225. package/dist/vocabulary/list.d.ts +0 -14
  226. package/dist/vocabulary/list.d.ts.map +0 -1
  227. package/dist/vocabulary/list.js +0 -50
  228. package/dist/vocabulary/list.js.map +0 -1
  229. package/dist/vocabulary/media.d.ts +0 -25
  230. package/dist/vocabulary/media.d.ts.map +0 -1
  231. package/dist/vocabulary/media.js +0 -42
  232. package/dist/vocabulary/media.js.map +0 -1
  233. package/dist/vocabulary/text.d.ts +0 -57
  234. package/dist/vocabulary/text.d.ts.map +0 -1
  235. package/dist/vocabulary/text.js +0 -49
  236. package/dist/vocabulary/text.js.map +0 -1
  237. package/dist/vocabulary/toTextContent.d.ts +0 -2
  238. package/dist/vocabulary/toTextContent.d.ts.map +0 -1
  239. package/dist/vocabulary/toTextContent.js +0 -6
  240. package/dist/vocabulary/toTextContent.js.map +0 -1
  241. package/src/JSONGenerativeUI.client.tsx +0 -168
  242. package/src/JSONGenerativeUI.server.tsx +0 -39
  243. package/src/JSONGenerativeUI.shared.ts +0 -90
  244. package/src/JSONGenerativeUI.test.tsx +0 -1298
  245. package/src/RadioGroupScope.server.test.tsx +0 -24
  246. package/src/RadioGroupScope.tsx +0 -34
  247. package/src/a2ui/BindingContext.ts +0 -26
  248. package/src/a2ui/PresentRenderer.tsx +0 -83
  249. package/src/a2ui/convert.test.ts +0 -2923
  250. package/src/a2ui/convert.ts +0 -1207
  251. package/src/a2ui/dataModel.ts +0 -69
  252. package/src/a2ui/reducer.test.ts +0 -422
  253. package/src/a2ui/reducer.ts +0 -363
  254. package/src/a2ui/snapshot.test.ts +0 -52
  255. package/src/a2ui/snapshot.ts +0 -52
  256. package/src/a2ui/types.ts +0 -114
  257. package/src/a2ui/valueFunctions.test.ts +0 -271
  258. package/src/a2ui/valueFunctions.ts +0 -523
  259. package/src/actionRegistry.test.ts +0 -90
  260. package/src/actionRegistry.ts +0 -88
  261. package/src/answeredValues.test.ts +0 -33
  262. package/src/answeredValues.tsx +0 -70
  263. package/src/buildPresentParameters.test.ts +0 -246
  264. package/src/buildPresentParameters.ts +0 -130
  265. package/src/constants.ts +0 -17
  266. package/src/convert/boundSpec.test.ts +0 -192
  267. package/src/convert/boundSpec.ts +0 -134
  268. package/src/convert/copyBounded.test.ts +0 -131
  269. package/src/convert/copyBounded.ts +0 -38
  270. package/src/convert/isElement.ts +0 -6
  271. package/src/convert/takeRun.test.ts +0 -64
  272. package/src/convert/takeRun.ts +0 -19
  273. package/src/defineGenerativeComponents.ts +0 -38
  274. package/src/fieldReferences.test.ts +0 -66
  275. package/src/fieldReferences.ts +0 -83
  276. package/src/generativeUIToJSX.test.ts +0 -268
  277. package/src/generativeUIToJSX.ts +0 -152
  278. package/src/index.server.test.ts +0 -106
  279. package/src/index.shared.ts +0 -61
  280. package/src/ir.test.ts +0 -203
  281. package/src/renderGenerativeUI.test.tsx +0 -373
  282. package/src/renderGenerativeUI.tsx +0 -165
  283. package/src/scopeSchema.test.ts +0 -72
  284. package/src/scopeSchema.ts +0 -71
  285. package/src/slack/a2uiSlack.test.ts +0 -198
  286. package/src/slack/constants.ts +0 -194
  287. package/src/slack/datePicker.test.ts +0 -612
  288. package/src/slack/decodeBlockAction.test.ts +0 -233
  289. package/src/slack/decodeBlockAction.ts +0 -232
  290. package/src/slack/fromSlackBlocks.test.ts +0 -1465
  291. package/src/slack/fromSlackBlocks.ts +0 -789
  292. package/src/slack/toSlackBlocks.test.ts +0 -3065
  293. package/src/slack/toSlackBlocks.ts +0 -1818
  294. package/src/slack/types.ts +0 -264
  295. package/src/teams/constants.ts +0 -93
  296. package/src/teams/decodeSubmitData.test.ts +0 -397
  297. package/src/teams/decodeSubmitData.ts +0 -110
  298. package/src/teams/temporal.test.ts +0 -766
  299. package/src/teams/temporalId.ts +0 -56
  300. package/src/teams/toAdaptiveCard.test.ts +0 -1897
  301. package/src/teams/toAdaptiveCard.ts +0 -1057
  302. package/src/teams/toTeamsAttachments.test.ts +0 -74
  303. package/src/teams/toTeamsAttachments.ts +0 -133
  304. package/src/teams/types.ts +0 -266
  305. package/src/temporal.test.ts +0 -319
  306. package/src/temporal.ts +0 -259
  307. package/src/types.ts +0 -119
  308. package/src/vocabulary/alert.test.tsx +0 -427
  309. package/src/vocabulary/alert.tsx +0 -217
  310. package/src/vocabulary/collectFormValues.test.ts +0 -389
  311. package/src/vocabulary/collectFormValues.ts +0 -116
  312. package/src/vocabulary/data.test.tsx +0 -858
  313. package/src/vocabulary/data.tsx +0 -819
  314. package/src/vocabulary/datepicker.dom.test.tsx +0 -1148
  315. package/src/vocabulary/dispatch.ts +0 -83
  316. package/src/vocabulary/fact.test.tsx +0 -94
  317. package/src/vocabulary/fact.tsx +0 -54
  318. package/src/vocabulary/form.test.tsx +0 -113
  319. package/src/vocabulary/form.tsx +0 -39
  320. package/src/vocabulary/formatValue.test.ts +0 -72
  321. package/src/vocabulary/formatValue.ts +0 -127
  322. package/src/vocabulary/icon.test.tsx +0 -64
  323. package/src/vocabulary/icon.tsx +0 -174
  324. package/src/vocabulary/index.test.ts +0 -65
  325. package/src/vocabulary/index.ts +0 -33
  326. package/src/vocabulary/interactive.dispatch.test.tsx +0 -454
  327. package/src/vocabulary/interactive.dom.test.tsx +0 -1747
  328. package/src/vocabulary/interactive.test.tsx +0 -377
  329. package/src/vocabulary/interactive.tsx +0 -1048
  330. package/src/vocabulary/layout.test.tsx +0 -323
  331. package/src/vocabulary/layout.tsx +0 -247
  332. package/src/vocabulary/list.test.tsx +0 -222
  333. package/src/vocabulary/list.tsx +0 -50
  334. package/src/vocabulary/media.test.tsx +0 -85
  335. package/src/vocabulary/media.tsx +0 -56
  336. package/src/vocabulary/text.test.tsx +0 -102
  337. package/src/vocabulary/text.tsx +0 -60
  338. package/src/vocabulary/toTextContent.ts +0 -2
@@ -1 +0,0 @@
1
- {"version":3,"file":"convert.js","names":[],"sources":["../../src/a2ui/convert.ts"],"sourcesContent":["import { ICON_NAMES, type UIElement } from \"../ir\";\nimport { classifyTemporal } from \"../temporal\";\nimport { A2UI_SURFACE_ID, type A2uiSurfaceState } from \"./types\";\nimport {\n evaluateA2uiValueFunction,\n type ExpressionPart,\n} from \"./valueFunctions\";\nimport { MAX_AUTO_VIVIFY_ARRAY_INDEX } from \"./reducer\";\nimport type { A2uiBinding } from \"./BindingContext\";\nimport { decodePointer, resolvePointer } from \"./dataModel\";\n\nconst DEPTH_CAP = 32;\nconst TEMPLATE_ITEM_CAP = 100;\nconst NODE_BUDGET = 5000;\nconst EVALUATION_BUDGET = 20_000;\n\nconst SUPPORTED_COMPONENTS = new Set([\n \"Text\",\n \"Image\",\n \"Icon\",\n \"Row\",\n \"Column\",\n \"List\",\n \"Card\",\n \"Divider\",\n \"Button\",\n \"TextField\",\n \"CheckBox\",\n \"ChoicePicker\",\n \"DateTimeInput\",\n \"Slider\",\n]);\n\nconst CHILD_LIST_COMPONENTS: ReadonlySet<string> = new Set([\n \"Row\",\n \"Column\",\n \"List\",\n]);\n\nconst ICON_NAME_SET: ReadonlySet<string> = new Set(ICON_NAMES);\nconst ICON_SIZE_SET: ReadonlySet<string> = new Set([\"sm\", \"md\", \"lg\"]);\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n if (!isRecord(value)) return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n};\n\nconst setOwnProperty = (\n target: Record<string, unknown>,\n key: string,\n value: unknown,\n) => {\n if (key === \"__proto__\") {\n Object.defineProperty(target, key, {\n value,\n enumerable: true,\n configurable: true,\n writable: true,\n });\n } else {\n target[key] = value;\n }\n};\n\nconst FUNCTION_CALL_KEYS: ReadonlySet<string> = new Set([\n \"call\",\n \"args\",\n \"returnType\",\n \"catalogId\",\n]);\n\nconst isFunctionCall = (\n value: unknown,\n): value is {\n readonly call: string;\n readonly args?: Record<string, unknown>;\n} =>\n isPlainObject(value) &&\n typeof value[\"call\"] === \"string\" &&\n (value[\"args\"] === undefined || isPlainObject(value[\"args\"])) &&\n Object.keys(value).every((key) => FUNCTION_CALL_KEYS.has(key));\n\nconst isBinding = (value: unknown): value is { readonly path: string } =>\n isPlainObject(value) &&\n Object.keys(value).length === 1 &&\n typeof value[\"path\"] === \"string\";\n\ntype ChildTemplate = { readonly componentId: string; readonly path: string };\n\nconst childTemplateOf = (children: unknown): ChildTemplate | undefined => {\n const template =\n isPlainObject(children) &&\n Object.keys(children).length === 1 &&\n isPlainObject(children[\"template\"])\n ? children[\"template\"]\n : children;\n return isPlainObject(template) &&\n Object.keys(template).length === 2 &&\n typeof template[\"componentId\"] === \"string\" &&\n typeof template[\"path\"] === \"string\"\n ? { componentId: template[\"componentId\"], path: template[\"path\"] }\n : undefined;\n};\n\nconst bindingPath = (value: unknown): string | undefined =>\n isBinding(value) ? value.path : undefined;\n\ntype Scope = { readonly data: unknown; readonly path: string };\n\nconst pointerIn = (scope: Scope, path: string): string =>\n (path.startsWith(\"/\") ? \"\" : scope.path) +\n decodePointer(path)\n .map((segment) => `/${segment.replaceAll(\"~\", \"~0\").replaceAll(\"/\", \"~1\")}`)\n .join(\"\");\n\nconst setIn = (\n value: unknown,\n segments: readonly string[],\n leaf: unknown,\n): unknown => {\n const [head, ...rest] = segments;\n if (head === undefined) return leaf;\n if (\n /^(0|[1-9]\\d*)$/.test(head) &&\n (Array.isArray(value) || value === undefined || value === null)\n ) {\n const list = Array.isArray(value) ? value : [];\n const index = Number(head);\n if (index >= list.length && index > MAX_AUTO_VIVIFY_ARRAY_INDEX) {\n return value;\n }\n const copy = [...list];\n copy[index] = setIn(copy[index], rest, leaf);\n return copy;\n }\n const copy: Record<string, unknown> = isRecord(value) ? { ...value } : {};\n setOwnProperty(\n copy,\n head,\n setIn(Object.hasOwn(copy, head) ? copy[head] : undefined, rest, leaf),\n );\n return copy;\n};\n\nconst withFieldReferences = (\n value: unknown,\n pointer: string,\n fields: ReadonlyMap<string, unknown>,\n): unknown => {\n if (fields.has(pointer)) return fields.get(pointer);\n let result = value;\n for (const [name, field] of fields) {\n if (name.startsWith(`${pointer}/`)) {\n result = setIn(result, decodePointer(name.slice(pointer.length)), field);\n }\n }\n return result;\n};\n\nconst materializeEntries = (\n value: Record<string, unknown>,\n source: unknown,\n context: ConversionContext,\n evaluate: boolean,\n depth: number,\n positional = false,\n): Record<string, unknown> => {\n const result: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n // An action's functionCall runs when the button fires, so only its arguments resolve here.\n const resolved =\n key === \"functionCall\" && isFunctionCall(entry)\n ? {\n ...entry,\n ...(entry.args !== undefined\n ? {\n args: materializeEntries(\n entry.args,\n source,\n context,\n evaluate,\n depth,\n true,\n ),\n }\n : {}),\n }\n : materialize(entry, source, context, evaluate, depth, positional);\n if (resolved !== undefined) {\n setOwnProperty(result, key, resolved);\n }\n }\n return result;\n};\n\nfunction materialize(\n value: unknown,\n source: unknown,\n context: ConversionContext,\n evaluate = true,\n depth = 0,\n positional = false,\n): unknown {\n if (isBinding(value)) {\n const pointer = pointerIn(\n { data: source, path: context.scopePath },\n value.path,\n );\n const resolved = resolvePointer(context.surface.dataModel, pointer);\n context.dependencies?.set(pointer, resolved);\n return resolved;\n }\n if (Array.isArray(value)) {\n const entries = value.map((entry) =>\n materialize(entry, source, context, evaluate, depth, positional),\n );\n return positional\n ? entries\n : entries.filter((entry) => entry !== undefined);\n }\n if (!isPlainObject(value)) return value;\n if (!evaluate || !isFunctionCall(value)) {\n return materializeEntries(\n value,\n source,\n context,\n evaluate,\n depth,\n positional,\n );\n }\n if (!spendEvaluation(context)) return undefined;\n if (depth >= DEPTH_CAP) {\n if (!context.functionDepthWarned) {\n context.warnings.push(\n `A2UI function nesting cap of ${DEPTH_CAP} was reached.`,\n );\n context.functionDepthWarned = true;\n }\n return undefined;\n }\n return evaluateA2uiValueFunction(\n value.call,\n materializeEntries(\n value.args ?? {},\n source,\n context,\n true,\n depth + 1,\n true,\n ),\n {\n resolve: (part) =>\n spendEvaluation(context)\n ? materialize(part, source, context, true, depth + 1)\n : undefined,\n warn: (message) => context.warnings.push(message),\n templates: context.templates,\n },\n );\n}\n\nconst firstDefined = (\n props: Record<string, unknown>,\n keys: readonly string[],\n): unknown => {\n for (const key of keys) {\n if (props[key] !== undefined) return props[key];\n }\n return undefined;\n};\n\nconst stringProp = (\n props: Record<string, unknown>,\n keys: readonly string[],\n): string | undefined => {\n const value = firstDefined(props, keys);\n return typeof value === \"string\" ? value : undefined;\n};\n\nconst sourceSurfaceId = (surface: A2uiSurfaceState): string =>\n (surface as A2uiSurfaceState & { [A2UI_SURFACE_ID]?: string })[\n A2UI_SURFACE_ID\n ] ?? \"\";\n\ntype ConversionContext = {\n readonly surface: A2uiSurfaceState;\n readonly stepModel: unknown;\n readonly surfaceId: string;\n readonly warnings: string[];\n emittedNodes: number;\n depthWarned: boolean;\n budgetWarned: boolean;\n templateCapWarned: boolean;\n evaluations: number;\n evaluationBudgetWarned: boolean;\n functionDepthWarned: boolean;\n readonly templates: Map<string, ExpressionPart[] | null>;\n readonly inputFields: Map<string, unknown>;\n readonly textFields: Map<string, boolean>;\n readonly boundActionEntries: {\n readonly target: Record<string, unknown>;\n readonly key: string;\n readonly pointer: string;\n }[];\n readonly boundUserMessages: {\n readonly action: Record<string, unknown>;\n readonly pointer: string;\n }[];\n readonly keepUnknownComponents: boolean;\n readonly bindings: Map<string, A2uiBinding> | undefined;\n readonly cache: Map<string, CachedComponent> | undefined;\n dependencies: Map<string, unknown> | undefined;\n scopePath: string;\n};\n\ntype CachedComponent = {\n readonly props: Record<string, unknown>;\n readonly mapped: UIElement | undefined;\n readonly dependencies: ReadonlyMap<string, unknown>;\n readonly evaluations: number;\n children?: readonly UIElement[];\n result?: UIElement;\n};\n\nconst BOUND_KEYS = [\"text\", \"value\", \"binding\"] as const;\n\nconst INPUT_COMPONENTS: ReadonlySet<string> = new Set([\n \"TextField\",\n \"CheckBox\",\n \"ChoicePicker\",\n \"DateTimeInput\",\n \"Slider\",\n]);\n\ntype DateInputType = \"date\" | \"datetime\" | \"time\";\n\nconst dateInputType = (value: string): DateInputType | undefined => {\n const kind = classifyTemporal(value).kind;\n if (kind === \"date\" || kind === \"time\") return kind;\n return kind === \"floating\" || kind === \"instant\" ? \"datetime\" : undefined;\n};\n\nconst finiteNumber = (value: unknown): number | undefined =>\n typeof value === \"number\" && Number.isFinite(value) ? value : undefined;\n\nconst decimalPlaces = (value: number): number => {\n const [mantissa = \"\", exponent = \"0\"] = String(value).split(\"e\");\n return Math.max(0, (mantissa.split(\".\")[1]?.length ?? 0) - Number(exponent));\n};\n\n// A spec slider without `steps` is continuous, so its step leaves at least a hundred divisions and keeps every bound value on the grid.\nconst sliderStep = (\n min: number,\n max: number,\n value: number | undefined,\n steps: unknown,\n): number | undefined => {\n if (max <= min) return undefined;\n if (typeof steps === \"number\" && Number.isInteger(steps) && steps >= 1) {\n return (max - min) / steps;\n }\n const precision = Math.max(\n decimalPlaces(min),\n value === undefined ? 0 : decimalPlaces(value),\n );\n return Math.min(\n 10 ** Math.floor(Math.log10((max - min) / 100)),\n 10 ** -precision,\n );\n};\n\nconst recordBindings = (\n node: Record<string, unknown>,\n props: Record<string, unknown>,\n mapped: UIElement,\n scope: Scope,\n context: ConversionContext,\n) => {\n const component = node[\"component\"];\n const name = mapped[\"name\"];\n const boundKey = BOUND_KEYS.find((key) => node[key] !== undefined);\n const value = boundKey === undefined ? undefined : props[boundKey];\n if (INPUT_COMPONENTS.has(String(component)) && typeof name === \"string\") {\n context.textFields.set(\n name,\n (!context.textFields.has(name) || context.bindings !== undefined) &&\n (component === \"TextField\" || component === \"DateTimeInput\"),\n );\n const field = (fallback: unknown) =>\n fallback === undefined ? { $field: name } : { $field: name, fallback };\n // A single-choice picker collects one string, while the spec binds it to a string list.\n const listValued =\n component === \"ChoicePicker\" &&\n mapped.$type !== \"CheckboxGroup\" &&\n typeof value !== \"string\";\n context.inputFields.set(\n name,\n listValued\n ? [field(Array.isArray(value) ? value[0] : undefined)]\n : field(value),\n );\n }\n const action = mapped.$action;\n const raw = node[\"action\"];\n if (!action || !isRecord(raw)) return;\n const functionCall = action.type === \"a2ui:functionCall\";\n const event = isRecord(raw[\"event\"]) ? raw[\"event\"] : raw;\n const userMessage = event[\"userMessage\"];\n if (!functionCall && isBinding(userMessage)) {\n context.boundUserMessages.push({\n action,\n pointer: pointerIn(scope, userMessage.path),\n });\n }\n const rawEntries = functionCall\n ? isRecord(raw[\"functionCall\"])\n ? raw[\"functionCall\"][\"args\"]\n : undefined\n : event[\"context\"];\n const target = functionCall ? action[\"args\"] : action[\"context\"];\n if (!isRecord(rawEntries) || !isRecord(target)) return;\n for (const [key, entry] of Object.entries(rawEntries)) {\n if (isBinding(entry)) {\n context.boundActionEntries.push({\n target,\n key,\n pointer: pointerIn(scope, entry.path),\n });\n }\n }\n};\n\nconst spendEvaluation = (context: ConversionContext): boolean => {\n if (context.evaluations < EVALUATION_BUDGET) {\n context.evaluations++;\n return true;\n }\n if (!context.evaluationBudgetWarned) {\n context.warnings.push(\n `A2UI function evaluation budget of ${EVALUATION_BUDGET} was reached.`,\n );\n context.evaluationBudgetWarned = true;\n }\n return false;\n};\n\nconst reserveNode = (context: ConversionContext): boolean => {\n if (context.emittedNodes >= NODE_BUDGET) {\n if (!context.budgetWarned) {\n context.warnings.push(`A2UI node budget of ${NODE_BUDGET} was reached.`);\n context.budgetWarned = true;\n }\n return false;\n }\n context.emittedNodes++;\n return true;\n};\n\nconst childReferences = (node: Record<string, unknown>): unknown[] => {\n const children = node[\"children\"];\n const references: unknown[] = Array.isArray(children) ? [...children] : [];\n if (node[\"child\"] !== undefined) references.push(node[\"child\"]);\n if (node[\"component\"] === \"Modal\") {\n references.push(node[\"trigger\"], node[\"content\"]);\n }\n if (node[\"component\"] === \"Tabs\" && Array.isArray(node[\"tabs\"])) {\n for (const tab of node[\"tabs\"]) {\n references.push(isRecord(tab) ? tab[\"child\"] : undefined);\n }\n }\n return references;\n};\n\nconst childrenOf = (\n node: Record<string, unknown>,\n scope: Scope,\n context: ConversionContext,\n depth: number,\n visited: Set<string>,\n): UIElement[] => {\n const result: UIElement[] = [];\n for (const childId of childReferences(node)) {\n if (typeof childId !== \"string\") {\n context.warnings.push(\n `Component \"${String(node[\"id\"] ?? \"\")}\" has a malformed child reference.`,\n );\n continue;\n }\n const child = convertComponent(childId, scope, context, depth + 1, visited);\n if (child) result.push(child);\n }\n return result;\n};\n\nconst textLabel = (\n node: Record<string, unknown>,\n children: readonly UIElement[],\n context: ConversionContext,\n): string | undefined => {\n const references = childReferences(node);\n const [reference] = references;\n const [child] = children;\n if (\n references.length !== 1 ||\n children.length !== 1 ||\n typeof reference !== \"string\" ||\n !child ||\n context.surface.components.get(reference)?.[\"component\"] !== \"Text\"\n ) {\n return undefined;\n }\n const text = child.$type === \"Header\" ? child[\"text\"] : child[\"value\"];\n return typeof text === \"string\" ? text : undefined;\n};\n\nconst mappedAction = (\n node: Record<string, unknown>,\n props: Record<string, unknown>,\n context: ConversionContext,\n): UIElement[\"$action\"] | undefined => {\n const action = props[\"action\"];\n if (action === undefined) return undefined;\n const source = {\n surfaceId: context.surfaceId,\n sourceComponentId: typeof node[\"id\"] === \"string\" ? node[\"id\"] : \"\",\n };\n const event =\n isRecord(action) && isRecord(action[\"event\"]) ? action[\"event\"] : action;\n const actionName =\n typeof event === \"string\"\n ? event\n : isRecord(event) && typeof event[\"name\"] === \"string\"\n ? event[\"name\"]\n : undefined;\n if (actionName) {\n const actionContext = isRecord(event) ? event[\"context\"] : undefined;\n const userMessage = isRecord(event) ? event[\"userMessage\"] : undefined;\n return {\n type: \"a2ui:action\",\n name: actionName,\n ...source,\n ...(typeof userMessage === \"string\" ? { userMessage } : {}),\n ...(actionContext !== undefined ? { context: actionContext } : {}),\n };\n }\n const functionCall = isRecord(action) ? action[\"functionCall\"] : undefined;\n if (isRecord(functionCall) && typeof functionCall[\"call\"] === \"string\") {\n const args = functionCall[\"args\"];\n return {\n type: \"a2ui:functionCall\",\n call: functionCall[\"call\"],\n ...source,\n ...(isRecord(args) ? { args } : {}),\n };\n }\n context.warnings.push(\n `Component \"${String(node[\"id\"] ?? \"\")}\" has a malformed action.`,\n );\n return undefined;\n};\n\nconst choiceOptions = (value: unknown): { label: string; value: string }[] => {\n if (!Array.isArray(value)) return [];\n const options: { label: string; value: string }[] = [];\n for (const option of value) {\n if (\n isRecord(option) &&\n typeof option[\"label\"] === \"string\" &&\n typeof option[\"value\"] === \"string\"\n ) {\n options.push({ label: option[\"label\"], value: option[\"value\"] });\n }\n }\n return options;\n};\n\nconst mappedProps = (\n node: Record<string, unknown>,\n props: Record<string, unknown>,\n context: ConversionContext,\n scope: Scope,\n): UIElement | undefined => {\n const component = node[\"component\"];\n\n if (component === \"Text\") {\n const text = stringProp(props, [\"text\", \"value\"]);\n const variant = props[\"variant\"];\n if (typeof variant === \"string\" && /^h[1-6]$/.test(variant)) {\n return {\n $type: \"Header\",\n ...(text !== undefined ? { text } : {}),\n };\n }\n if (variant === \"caption\") {\n return {\n $type: \"Caption\",\n ...(text !== undefined ? { value: text } : {}),\n };\n }\n return {\n $type: \"Markdown\",\n ...(text !== undefined ? { value: text } : {}),\n };\n }\n\n if (component === \"Image\") {\n const src = stringProp(props, [\"src\", \"url\"]);\n const alt = stringProp(props, [\"alt\", \"altText\", \"description\"]);\n const size = props[\"size\"];\n const round = props[\"round\"];\n return {\n $type: \"Image\",\n ...(src !== undefined ? { src } : {}),\n ...(alt !== undefined ? { alt } : {}),\n ...(typeof size === \"string\" || typeof size === \"number\" ? { size } : {}),\n ...(typeof round === \"boolean\" ? { round } : {}),\n };\n }\n\n if (component === \"Icon\") {\n const name = stringProp(props, [\"name\"]);\n if (!name || !ICON_NAME_SET.has(name)) return undefined;\n const size = props[\"size\"];\n return {\n $type: \"Icon\",\n name,\n ...(typeof size === \"string\" && ICON_SIZE_SET.has(size) ? { size } : {}),\n };\n }\n\n if (component === \"Row\") {\n const gap = props[\"gap\"];\n const align = firstDefined(props, [\"align\", \"alignment\"]);\n const justify = firstDefined(props, [\"justify\", \"distribution\"]);\n return {\n $type: \"Row\",\n ...(typeof gap === \"number\" ? { gap } : {}),\n ...(typeof align === \"string\" ? { align } : {}),\n ...(typeof justify === \"string\" ? { justify } : {}),\n };\n }\n\n if (component === \"Column\") {\n const gap = props[\"gap\"];\n const align = firstDefined(props, [\"align\", \"alignment\"]);\n return {\n $type: \"Col\",\n ...(typeof gap === \"number\" ? { gap } : {}),\n ...(typeof align === \"string\" ? { align } : {}),\n };\n }\n\n if (component === \"List\") {\n const direction = props[\"direction\"];\n const align = props[\"align\"];\n if (direction === \"horizontal\") {\n return {\n $type: \"Row\",\n ...(typeof align === \"string\" ? { align } : {}),\n };\n }\n return { $type: \"ListView\" };\n }\n\n if (component === \"Card\") {\n const title = props[\"title\"];\n const padding = props[\"padding\"];\n const background = props[\"background\"];\n return {\n $type: \"Card\",\n ...(typeof title === \"string\" ? { title } : {}),\n ...(typeof padding === \"number\" ? { padding } : {}),\n ...(typeof background === \"string\" ? { background } : {}),\n };\n }\n\n if (component === \"Divider\") {\n return {\n $type: \"Divider\",\n ...(typeof props[\"flush\"] === \"boolean\" ? { flush: props[\"flush\"] } : {}),\n };\n }\n\n if (component === \"Button\") {\n const label = stringProp(props, [\"label\", \"text\"]);\n const variantStyle =\n props[\"variant\"] === \"primary\"\n ? \"primary\"\n : props[\"variant\"] === \"borderless\"\n ? \"ghost\"\n : undefined;\n const buttonStyle =\n typeof props[\"buttonStyle\"] === \"string\"\n ? props[\"buttonStyle\"]\n : variantStyle;\n const block = props[\"block\"];\n const submit = props[\"submit\"];\n const action = mappedAction(node, props, context);\n return {\n $type: \"Button\",\n ...(label !== undefined ? { label } : {}),\n ...(buttonStyle !== undefined ? { buttonStyle } : {}),\n ...(typeof block === \"boolean\" ? { block } : {}),\n ...(typeof submit === \"boolean\" ? { submit } : {}),\n ...(action ? { $action: action } : {}),\n };\n }\n\n const bound = bindingPath(firstDefined(node, BOUND_KEYS));\n const name = bound === undefined ? undefined : pointerIn(scope, bound);\n const label = stringProp(props, [\"label\"]);\n\n if (component === \"TextField\") {\n const placeholder = stringProp(props, [\"placeholder\"]);\n const inputType =\n props[\"variant\"] === \"obscured\"\n ? \"password\"\n : props[\"variant\"] === \"number\"\n ? \"number\"\n : undefined;\n const multiline =\n typeof props[\"multiline\"] === \"boolean\"\n ? props[\"multiline\"]\n : props[\"variant\"] === \"longText\" ||\n props[\"textFieldType\"] === \"longText\"\n ? true\n : undefined;\n const initial = firstDefined(props, [\"value\", \"text\"]);\n const defaultValue =\n typeof initial === \"string\"\n ? initial\n : typeof initial === \"number\" && Number.isFinite(initial)\n ? String(initial)\n : undefined;\n return {\n $type: \"Input\",\n ...(inputType !== undefined ? { inputType } : {}),\n ...(placeholder !== undefined ? { placeholder } : {}),\n ...(multiline !== undefined ? { multiline } : {}),\n ...(label !== undefined ? { label } : {}),\n ...(name !== undefined ? { name } : {}),\n ...(defaultValue !== undefined ? { defaultValue } : {}),\n };\n }\n\n if (component === \"CheckBox\") {\n const defaultChecked = firstDefined(props, [\"defaultChecked\", \"value\"]);\n return {\n $type: \"Checkbox\",\n ...(label !== undefined ? { label } : {}),\n ...(name !== undefined ? { name } : {}),\n ...(typeof defaultChecked === \"boolean\" ? { defaultChecked } : {}),\n };\n }\n\n if (component === \"Slider\") {\n const min = finiteNumber(props[\"min\"]) ?? 0;\n const max = finiteNumber(props[\"max\"]);\n if (max === undefined || max < min) return undefined;\n const value = finiteNumber(props[\"value\"]);\n const step = sliderStep(\n min,\n max,\n name === undefined\n ? value\n : finiteNumber(resolvePointer(context.stepModel, name)),\n props[\"steps\"],\n );\n return {\n $type: \"Slider\",\n min,\n max,\n ...(step !== undefined ? { step } : {}),\n ...(value !== undefined ? { defaultValue: value } : {}),\n ...(label !== undefined ? { label } : {}),\n ...(name !== undefined ? { name } : {}),\n };\n }\n\n if (component === \"ChoicePicker\") {\n const options = choiceOptions(props[\"options\"]);\n const value = props[\"value\"];\n const selected =\n typeof value === \"string\"\n ? [value]\n : Array.isArray(value)\n ? value.filter((entry): entry is string => typeof entry === \"string\")\n : [];\n if (props[\"variant\"] === \"multipleSelection\") {\n return {\n $type: \"CheckboxGroup\",\n options,\n ...(label !== undefined ? { label } : {}),\n ...(name !== undefined ? { name } : {}),\n ...(selected.length > 0 ? { defaultValue: selected } : {}),\n };\n }\n const [defaultValue] = selected;\n return {\n $type: \"RadioGroup\",\n options,\n ...(label !== undefined ? { label } : {}),\n ...(name !== undefined ? { name } : {}),\n ...(defaultValue !== undefined ? { defaultValue } : {}),\n };\n }\n\n if (component === \"DateTimeInput\") {\n const value = stringProp(props, [\"value\"]);\n const shapeValue =\n name === undefined ? value : resolvePointer(context.stepModel, name);\n const shapeType =\n typeof shapeValue === \"string\" ? dateInputType(shapeValue) : undefined;\n let inputType: DateInputType = shapeType ?? \"date\";\n if (\"enableDate\" in props || \"enableTime\" in props) {\n inputType =\n props[\"enableTime\"] === true\n ? props[\"enableDate\"] === true\n ? \"datetime\"\n : \"time\"\n : \"date\";\n }\n if (\n typeof shapeValue === \"string\" &&\n shapeValue !== \"\" &&\n shapeType !== inputType\n ) {\n return {\n $type: \"Input\",\n ...(value !== undefined ? { defaultValue: value } : {}),\n ...(label !== undefined ? { label } : {}),\n ...(name !== undefined ? { name } : {}),\n };\n }\n // The spec types a bound as a date, a time or a date-time whatever the\n // enabled flags are, so a date bound on a datetime control is the range of\n // that whole local day rather than a mismatch.\n const bound = (edge: \"min\" | \"max\"): string | undefined => {\n const boundValue = stringProp(props, [edge]);\n if (boundValue === undefined) return undefined;\n const boundType = dateInputType(boundValue);\n if (boundType === inputType) return boundValue;\n if (inputType === \"datetime\" && boundType === \"date\") {\n return `${boundValue}T${edge === \"min\" ? \"00:00\" : \"23:59:59.999\"}`;\n }\n context.warnings.push(\n `A2UI DateTimeInput \"${edge}\" of \"${boundValue}\" is not a ${inputType} value and was dropped.`,\n );\n return undefined;\n };\n const min = bound(\"min\");\n const max = bound(\"max\");\n return {\n $type: \"DatePicker\",\n inputType,\n ...(value !== undefined ? { value } : {}),\n ...(min !== undefined ? { min } : {}),\n ...(max !== undefined ? { max } : {}),\n ...(label !== undefined ? { label } : {}),\n ...(name !== undefined ? { name } : {}),\n };\n }\n\n return undefined;\n};\n\nconst convertTemplate = (\n node: Record<string, unknown>,\n template: ChildTemplate,\n scope: Scope,\n context: ConversionContext,\n depth: number,\n visited: Set<string>,\n converted: UIElement | undefined,\n): UIElement | null => {\n if (!reserveNode(context)) return null;\n const container = converted ?? { $type: \"ListView\" };\n const itemized = container.$type === \"ListView\";\n const list = resolvePointer(\n context.surface.dataModel,\n pointerIn(scope, template.path),\n );\n const listPointer = pointerIn(scope, template.path);\n if (!Array.isArray(list)) {\n context.warnings.push(\n `Template on component \"${String(node[\"id\"] ?? \"\")}\" did not resolve to a list.`,\n );\n return { ...container, children: [] };\n }\n const itemCount = Math.min(list.length, TEMPLATE_ITEM_CAP);\n if (list.length > TEMPLATE_ITEM_CAP && !context.templateCapWarned) {\n context.warnings.push(\n `A2UI template expansion was capped at ${TEMPLATE_ITEM_CAP} items.`,\n );\n context.templateCapWarned = true;\n }\n const children: UIElement[] = [];\n for (let index = 0; index < itemCount; index++) {\n if (itemized && !reserveNode(context)) break;\n const child = convertComponent(\n template.componentId,\n { data: list[index], path: `${listPointer}/${index}` },\n context,\n depth + 1,\n visited,\n );\n if (itemized) {\n children.push({\n $type: \"ListViewItem\",\n ...(child ? { children: child } : {}),\n });\n } else if (child) {\n children.push(child);\n }\n }\n return { ...container, children };\n};\n\nfunction convertComponent(\n componentId: string,\n scope: Scope,\n context: ConversionContext,\n depth: number,\n visited: Set<string>,\n): UIElement | null {\n if (depth >= DEPTH_CAP) {\n if (!context.depthWarned) {\n context.warnings.push(`A2UI depth cap of ${DEPTH_CAP} was reached.`);\n context.depthWarned = true;\n }\n return null;\n }\n if (visited.has(componentId)) {\n context.warnings.push(`A2UI component cycle detected at \"${componentId}\".`);\n return null;\n }\n const node = context.surface.components.get(componentId);\n if (!node) {\n context.warnings.push(`A2UI component \"${componentId}\" was not found.`);\n return null;\n }\n const component = node[\"component\"];\n\n visited.add(componentId);\n try {\n if (typeof component !== \"string\") {\n context.warnings.push(\n `Unknown A2UI component \"${String(component ?? \"\")}\" was skipped.`,\n );\n return null;\n }\n const template = childTemplateOf(node[\"children\"]);\n if (\n !SUPPORTED_COMPONENTS.has(component) &&\n !context.keepUnknownComponents &&\n !template\n ) {\n context.warnings.push(\n `Unknown A2UI component \"${component}\" was skipped.`,\n );\n return null;\n }\n const cacheKey = context.cache\n ? JSON.stringify([componentId, scope.path, depth])\n : \"\";\n let cached = context.cache?.get(cacheKey);\n if (\n cached &&\n (context.evaluations + cached.evaluations > EVALUATION_BUDGET ||\n [...cached.dependencies].some(\n ([path, value]) =>\n !Object.is(resolvePointer(context.surface.dataModel, path), value),\n ))\n )\n cached = undefined;\n let props: Record<string, unknown>;\n let mapped: UIElement | undefined;\n if (cached) {\n props = cached.props;\n mapped = cached.mapped;\n context.evaluations += cached.evaluations;\n } else {\n props = {};\n const dependencies = new Map<string, unknown>();\n const evaluations = context.evaluations;\n context.dependencies = dependencies;\n context.scopePath = scope.path;\n for (const [key, value] of Object.entries(node)) {\n if (\n key === \"id\" ||\n key === \"component\" ||\n key === \"children\" ||\n key === \"child\"\n )\n continue;\n const resolved = materialize(\n value,\n scope.data,\n context,\n key !== \"checks\",\n );\n if (resolved !== undefined) setOwnProperty(props, key, resolved);\n }\n context.dependencies = undefined;\n mapped = mappedProps(node, props, context, scope);\n if (context.cache && context.warnings.length === 0 && !mapped?.$action) {\n cached = {\n props,\n mapped,\n dependencies,\n evaluations: context.evaluations - evaluations,\n };\n context.cache.set(cacheKey, cached);\n }\n }\n if (\n mapped &&\n context.bindings &&\n typeof mapped[\"name\"] === \"string\" &&\n INPUT_COMPONENTS.has(component)\n ) {\n const field = mapped.$type === \"Checkbox\" ? \"checked\" : \"value\";\n const defaultField =\n mapped.$type === \"Checkbox\" ? \"defaultChecked\" : \"defaultValue\";\n const fallback =\n mapped.$type === \"Checkbox\"\n ? false\n : mapped.$type === \"CheckboxGroup\"\n ? []\n : mapped.$type === \"Slider\"\n ? mapped[\"min\"]\n : \"\";\n const { [defaultField]: initialValue, ...rest } = mapped;\n mapped = { ...rest, [field]: initialValue ?? mapped[field] ?? fallback };\n context.bindings.set(mapped[\"name\"] as string, {\n value: mapped[field],\n arrayValue:\n component === \"ChoicePicker\" &&\n mapped.$type !== \"CheckboxGroup\" &&\n typeof props[\"value\"] !== \"string\",\n });\n }\n\n if (!mapped && SUPPORTED_COMPONENTS.has(component)) {\n context.warnings.push(\n `A2UI component \"${component}\" could not be mapped and was skipped.`,\n );\n return null;\n }\n const retained =\n !mapped && context.keepUnknownComponents\n ? {\n $type: component,\n ...Object.fromEntries(\n Object.entries(props).filter(([key]) => !key.startsWith(\"$\")),\n ),\n }\n : undefined;\n if (template) {\n return convertTemplate(\n node,\n template,\n scope,\n context,\n depth,\n visited,\n CHILD_LIST_COMPONENTS.has(component) ? mapped : retained,\n );\n }\n if (!reserveNode(context)) return null;\n const converted = mapped ?? retained;\n if (!converted) return null;\n recordBindings(node, props, converted, scope, context);\n const children = childrenOf(node, scope, context, depth, visited);\n if (mapped?.$type === \"Button\" && mapped[\"label\"] === undefined) {\n const label = textLabel(node, children, context);\n if (label !== undefined) return { ...mapped, label };\n }\n const listChildren =\n component === \"List\" && mapped?.$type === \"ListView\"\n ? children.map((child) => ({ $type: \"ListViewItem\", children: child }))\n : children;\n if (\n cached?.result &&\n cached.children?.length === listChildren.length &&\n cached.children.every((child, index) => child === listChildren[index])\n )\n return cached.result;\n const result = {\n ...converted,\n ...(listChildren.length > 0 ? { children: listChildren } : {}),\n };\n if (cached) {\n cached.children = listChildren;\n cached.result = result;\n }\n return result;\n } finally {\n visited.delete(componentId);\n }\n}\n\nexport function convertSurfaceToUISpec(\n surface: A2uiSurfaceState,\n options: {\n readonly keepUnknownComponents?: boolean;\n } = {},\n): {\n spec: UIElement | null;\n warnings: string[];\n} {\n return convertSurface(surface, options.keepUnknownComponents === true);\n}\n\nexport const createLiveSurfaceConverter = (surface: A2uiSurfaceState) => {\n const cache = new Map<string, CachedComponent>();\n const templates = new Map<string, ExpressionPart[] | null>();\n return (dataModel: unknown) => {\n const bindings = new Map<string, A2uiBinding>();\n const converted = convertSurface(\n { ...surface, dataModel, [A2UI_SURFACE_ID]: sourceSurfaceId(surface) },\n false,\n bindings,\n cache,\n templates,\n surface.dataModel,\n );\n return { ...converted, bindings };\n };\n};\n\nfunction convertSurface(\n surface: A2uiSurfaceState & { [A2UI_SURFACE_ID]?: string },\n keepUnknownComponents: boolean,\n bindings?: Map<string, A2uiBinding>,\n cache?: Map<string, CachedComponent>,\n templates = new Map<string, ExpressionPart[] | null>(),\n stepModel: unknown = surface.dataModel,\n): { spec: UIElement | null; warnings: string[] } {\n const warnings: string[] = [];\n if (!surface.components.has(\"root\")) {\n return {\n spec: null,\n warnings: ['A2UI root component \"root\" was not found.'],\n };\n }\n const context: ConversionContext = {\n surface,\n stepModel,\n surfaceId: sourceSurfaceId(surface),\n warnings,\n emittedNodes: 0,\n depthWarned: false,\n budgetWarned: false,\n templateCapWarned: false,\n evaluations: 0,\n evaluationBudgetWarned: false,\n functionDepthWarned: false,\n templates,\n inputFields: new Map(),\n textFields: new Map(),\n boundActionEntries: [],\n boundUserMessages: [],\n keepUnknownComponents,\n bindings,\n cache,\n dependencies: undefined,\n scopePath: \"\",\n };\n try {\n const spec = convertComponent(\n \"root\",\n { data: surface.dataModel, path: \"\" },\n context,\n 0,\n new Set(),\n );\n for (const { target, key, pointer } of context.boundActionEntries) {\n const value = withFieldReferences(\n target[key],\n pointer,\n context.inputFields,\n );\n if (value !== undefined) setOwnProperty(target, key, value);\n }\n for (const { action, pointer } of context.boundUserMessages) {\n if (!context.textFields.get(pointer)) continue;\n const fallback = action[\"userMessage\"];\n setOwnProperty(\n action,\n \"userMessage\",\n typeof fallback === \"string\"\n ? { $field: pointer, fallback }\n : { $field: pointer },\n );\n }\n return { spec, warnings };\n } catch {\n warnings.push(\"A2UI surface conversion encountered malformed input.\");\n return { spec: null, warnings };\n }\n}\n"],"mappings":";;;;;;;AAWA,MAAM,YAAY;AAClB,MAAM,oBAAoB;AAC1B,MAAM,cAAc;AACpB,MAAM,oBAAoB;AAE1B,MAAM,uCAAuB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,wCAA6C,IAAI,IAAI;CACzD;CACA;CACA;AAC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boolean;
2
- export declare const decodePointer: (path: string) => string[];
3
- export declare const resolvePointer: (source: unknown, path: string) => unknown;
4
- export declare const reconcileDataModel: (previous: unknown, incoming: unknown, local: unknown, editedPaths: ReadonlySet<string>) => {
5
- incoming: unknown;
6
- value: unknown;
7
- editedPaths: Set<string>;
8
- };
9
- //# sourceMappingURL=dataModel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dataModel.d.ts","sourceRoot":"","sources":["../../src/a2ui/dataModel.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS,GAAI,MAAM,OAAO,EAAE,OAAO,OAAO,KAAG,OAgBzD,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,MAAM,EAKlD,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,OAAO,EAAE,MAAM,MAAM,KAAG,OAc9D,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,UAAU,OAAO,EACjB,UAAU,OAAO,EACjB,OAAO,OAAO,EACd,aAAa,WAAW,CAAC,MAAM,CAAC;;;;CAkBjC,CAAC"}
@@ -1,44 +0,0 @@
1
- import { setAtPointer } from "./reducer.js";
2
- //#region src/a2ui/dataModel.ts
3
- const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
4
- const equalData = (left, right) => {
5
- if (Object.is(left, right)) return true;
6
- if (Array.isArray(left) && Array.isArray(right)) return left.length === right.length && left.every((value, index) => equalData(value, right[index]));
7
- if (!isRecord(left) || !isRecord(right)) return false;
8
- const keys = Object.keys(left);
9
- return keys.length === Object.keys(right).length && keys.every((key) => Object.hasOwn(right, key) && equalData(left[key], right[key]));
10
- };
11
- const decodePointer = (path) => {
12
- if (path === "" || path === "/") return [];
13
- return (path.startsWith("/") ? path.slice(1) : path).split("/").map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~"));
14
- };
15
- const resolvePointer = (source, path) => {
16
- let current = source;
17
- for (const segment of decodePointer(path)) {
18
- if (Array.isArray(current)) {
19
- if (!/^(0|[1-9]\d*)$/.test(segment)) return void 0;
20
- current = current[Number(segment)];
21
- continue;
22
- }
23
- if (!isRecord(current) || !Object.hasOwn(current, segment)) return;
24
- current = current[segment];
25
- }
26
- return current;
27
- };
28
- const reconcileDataModel = (previous, incoming, local, editedPaths) => {
29
- let value = incoming;
30
- const retained = /* @__PURE__ */ new Set();
31
- for (const path of editedPaths) if (equalData(resolvePointer(previous, path), resolvePointer(incoming, path))) {
32
- value = setAtPointer(value, path, resolvePointer(local, path), false).value;
33
- retained.add(path);
34
- }
35
- return {
36
- incoming,
37
- value,
38
- editedPaths: retained
39
- };
40
- };
41
- //#endregion
42
- export { decodePointer, equalData, reconcileDataModel, resolvePointer };
43
-
44
- //# sourceMappingURL=dataModel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dataModel.js","names":[],"sources":["../../src/a2ui/dataModel.ts"],"sourcesContent":["import { setAtPointer } from \"./reducer\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nexport const equalData = (left: unknown, right: unknown): boolean => {\n if (Object.is(left, right)) return true;\n if (Array.isArray(left) && Array.isArray(right)) {\n return (\n left.length === right.length &&\n left.every((value, index) => equalData(value, right[index]))\n );\n }\n if (!isRecord(left) || !isRecord(right)) return false;\n const keys = Object.keys(left);\n return (\n keys.length === Object.keys(right).length &&\n keys.every(\n (key) => Object.hasOwn(right, key) && equalData(left[key], right[key]),\n )\n );\n};\n\nexport const decodePointer = (path: string): string[] => {\n if (path === \"\" || path === \"/\") return [];\n return (path.startsWith(\"/\") ? path.slice(1) : path)\n .split(\"/\")\n .map((segment) => segment.replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\"));\n};\n\nexport const resolvePointer = (source: unknown, path: string): unknown => {\n let current = source;\n for (const segment of decodePointer(path)) {\n if (Array.isArray(current)) {\n if (!/^(0|[1-9]\\d*)$/.test(segment)) return undefined;\n current = current[Number(segment)];\n continue;\n }\n if (!isRecord(current) || !Object.hasOwn(current, segment)) {\n return undefined;\n }\n current = current[segment];\n }\n return current;\n};\n\nexport const reconcileDataModel = (\n previous: unknown,\n incoming: unknown,\n local: unknown,\n editedPaths: ReadonlySet<string>,\n) => {\n let value = incoming;\n const retained = new Set<string>();\n for (const path of editedPaths) {\n if (\n equalData(resolvePointer(previous, path), resolvePointer(incoming, path))\n ) {\n value = setAtPointer(\n value,\n path,\n resolvePointer(local, path),\n false,\n ).value;\n retained.add(path);\n }\n }\n return { incoming, value, editedPaths: retained };\n};\n"],"mappings":";;AAEA,MAAM,YAAY,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAErE,MAAa,aAAa,MAAe,UAA4B;CACnE,IAAI,OAAO,GAAG,MAAM,KAAK,GAAG,OAAO;CACnC,IAAI,MAAM,QAAQ,IAAI,KAAK,MAAM,QAAQ,KAAK,GAC5C,OACE,KAAK,WAAW,MAAM,UACtB,KAAK,OAAO,OAAO,UAAU,UAAU,OAAO,MAAM,MAAM,CAAC;CAG/D,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,KAAK,GAAG,OAAO;CAChD,MAAM,OAAO,OAAO,KAAK,IAAI;CAC7B,OACE,KAAK,WAAW,OAAO,KAAK,KAAK,CAAC,CAAC,UACnC,KAAK,OACF,QAAQ,OAAO,OAAO,OAAO,GAAG,KAAK,UAAU,KAAK,MAAM,MAAM,IAAI,CACvE;AAEJ;AAEA,MAAa,iBAAiB,SAA2B;CACvD,IAAI,SAAS,MAAM,SAAS,KAAK,OAAO,CAAC;CACzC,QAAQ,KAAK,WAAW,GAAG,IAAI,KAAK,MAAM,CAAC,IAAI,KAAA,CAC5C,MAAM,GAAG,CAAC,CACV,KAAK,YAAY,QAAQ,WAAW,MAAM,GAAG,CAAC,CAAC,WAAW,MAAM,GAAG,CAAC;AACzE;AAEA,MAAa,kBAAkB,QAAiB,SAA0B;CACxE,IAAI,UAAU;CACd,KAAK,MAAM,WAAW,cAAc,IAAI,GAAG;EACzC,IAAI,MAAM,QAAQ,OAAO,GAAG;GAC1B,IAAI,CAAC,iBAAiB,KAAK,OAAO,GAAG,OAAO,KAAA;GAC5C,UAAU,QAAQ,OAAO,OAAO;GAChC;EACF;EACA,IAAI,CAAC,SAAS,OAAO,KAAK,CAAC,OAAO,OAAO,SAAS,OAAO,GACvD;EAEF,UAAU,QAAQ;CACpB;CACA,OAAO;AACT;AAEA,MAAa,sBACX,UACA,UACA,OACA,gBACG;CACH,IAAI,QAAQ;CACZ,MAAM,2BAAW,IAAI,IAAY;CACjC,KAAK,MAAM,QAAQ,aACjB,IACE,UAAU,eAAe,UAAU,IAAI,GAAG,eAAe,UAAU,IAAI,CAAC,GACxE;EACA,QAAQ,aACN,OACA,MACA,eAAe,OAAO,IAAI,GAC1B,KACF,CAAC,CAAC;EACF,SAAS,IAAI,IAAI;CACnB;CAEF,OAAO;EAAE;EAAU;EAAO,aAAa;CAAS;AAClD"}
@@ -1,8 +0,0 @@
1
- import { type A2uiOperationResult, type A2uiState } from "./types.js";
2
- export declare const MAX_AUTO_VIVIFY_ARRAY_INDEX = 10000;
3
- export declare const setAtPointer: (model: unknown, path: string, value: unknown, nullDeletes: boolean) => {
4
- readonly ok: boolean;
5
- readonly value: unknown;
6
- };
7
- export declare function applyA2uiOperations(state: A2uiState, operations: unknown): A2uiOperationResult;
8
- //# sourceMappingURL=reducer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/a2ui/reducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,SAAS,EAGf,mBAAgB;AASjB,eAAO,MAAM,2BAA2B,QAAS,CAAC;AAyGlD,eAAO,MAAM,YAAY,GACvB,OAAO,OAAO,EACd,MAAM,MAAM,EACZ,OAAO,OAAO,EACd,aAAa,OAAO,KACnB;IAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CA4FjD,CAAC;AAaF,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,OAAO,GAClB,mBAAmB,CAiIrB"}
@@ -1,242 +0,0 @@
1
- import { A2UI_SURFACE_ID } from "./types.js";
2
- //#region src/a2ui/reducer.ts
3
- const OPERATION_KEYS = /* @__PURE__ */ new Set([
4
- "createSurface",
5
- "updateComponents",
6
- "updateDataModel",
7
- "deleteSurface"
8
- ]);
9
- const MAX_AUTO_VIVIFY_ARRAY_INDEX = 1e4;
10
- const INVALID_POINTER = Symbol("invalidPointer");
11
- const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
12
- const isVersion = (value) => value === "v0.9" || value === "v0.9.1" || value === "v1.0";
13
- const surfaceIdOf = (payload) => {
14
- const surfaceId = payload["surfaceId"];
15
- return typeof surfaceId === "string" && surfaceId.length > 0 ? surfaceId : void 0;
16
- };
17
- const catalogIdOf = (payload) => {
18
- if (typeof payload["catalogId"] === "string") return payload["catalogId"];
19
- const surfaceProperties = payload["surfaceProperties"];
20
- return isRecord(surfaceProperties) && typeof surfaceProperties["catalogId"] === "string" ? surfaceProperties["catalogId"] : void 0;
21
- };
22
- const withSurfaceId = (surface, surfaceId) => {
23
- Object.defineProperty(surface, A2UI_SURFACE_ID, {
24
- value: surfaceId,
25
- enumerable: false
26
- });
27
- return surface;
28
- };
29
- const getSurfaceId = (surface) => surface[A2UI_SURFACE_ID];
30
- const cloneSurface = (surface, surfaceId) => withSurfaceId({
31
- ...surface.catalogId !== void 0 ? { catalogId: surface.catalogId } : {},
32
- components: new Map(surface.components),
33
- dataModel: surface.dataModel
34
- }, getSurfaceId(surface) ?? surfaceId);
35
- const upsertComponents = (surface, components, warnings, operationIndex) => {
36
- if (!Array.isArray(components)) {
37
- warnings.push(`Operation at index ${operationIndex} has malformed components.`);
38
- return;
39
- }
40
- for (let componentIndex = 0; componentIndex < components.length; componentIndex++) {
41
- const component = components[componentIndex];
42
- if (!isRecord(component) || typeof component["id"] !== "string" || component["id"].length === 0 || typeof component["component"] !== "string" || component["component"].length === 0) {
43
- warnings.push(`Component at index ${componentIndex} in operation ${operationIndex} is malformed.`);
44
- continue;
45
- }
46
- surface.components.set(component["id"], { ...component });
47
- }
48
- };
49
- const decodePointer = (path) => {
50
- if (path === "" || path === "/") return [];
51
- if (!path.startsWith("/")) return void 0;
52
- return path.slice(1).split("/").map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~"));
53
- };
54
- const isArrayIndex = (segment) => segment === "0" || /^[1-9]\d*$/.test(segment);
55
- const setAtPointer = (model, path, value, nullDeletes) => {
56
- const segments = decodePointer(path);
57
- if (!segments) return {
58
- ok: false,
59
- value: model
60
- };
61
- if (segments.length === 0) return {
62
- ok: true,
63
- value
64
- };
65
- const remove = (current, index) => {
66
- const segment = segments[index];
67
- const isLast = index === segments.length - 1;
68
- if (Array.isArray(current)) {
69
- if (segment !== "-" && !isArrayIndex(segment)) return current;
70
- const targetIndex = segment === "-" ? current.length : Number(segment);
71
- if (isLast) {
72
- if (segment === "-" || !Object.prototype.hasOwnProperty.call(current, targetIndex)) return current;
73
- const clone = current.slice();
74
- delete clone[targetIndex];
75
- return clone;
76
- }
77
- const child = current[targetIndex];
78
- if (!Array.isArray(child) && !isRecord(child)) return current;
79
- const next = remove(child, index + 1);
80
- if (next === child) return current;
81
- const clone = current.slice();
82
- clone[targetIndex] = next;
83
- return clone;
84
- }
85
- if (!isRecord(current)) return current;
86
- if (!Object.prototype.hasOwnProperty.call(current, segment)) return current;
87
- if (isLast) {
88
- const clone = { ...current };
89
- delete clone[segment];
90
- return clone;
91
- }
92
- const child = current[segment];
93
- if (!Array.isArray(child) && !isRecord(child)) return current;
94
- const next = remove(child, index + 1);
95
- if (next === child) return current;
96
- return {
97
- ...current,
98
- [segment]: next
99
- };
100
- };
101
- if (nullDeletes && value === null) return {
102
- ok: true,
103
- value: remove(model, 0)
104
- };
105
- const update = (current, index) => {
106
- const segment = segments[index];
107
- const isLast = index === segments.length - 1;
108
- if (Array.isArray(current)) {
109
- if (segment !== "-" && !isArrayIndex(segment)) return current;
110
- const targetIndex = segment === "-" ? current.length : Number(segment);
111
- if (segment !== "-" && targetIndex >= current.length && targetIndex > 1e4) return INVALID_POINTER;
112
- const next = isLast ? value : update(current[targetIndex], index + 1);
113
- if (next === INVALID_POINTER) return INVALID_POINTER;
114
- const clone = current.slice();
115
- clone[targetIndex] = next;
116
- return clone;
117
- }
118
- const record = isRecord(current) ? current : {};
119
- const child = Object.hasOwn(record, segment) ? record[segment] : void 0;
120
- const next = isLast ? value : update(child ?? (isArrayIndex(segments[index + 1] ?? "") || segments[index + 1] === "-" ? [] : {}), index + 1);
121
- if (next === INVALID_POINTER) return INVALID_POINTER;
122
- return {
123
- ...record,
124
- [segment]: next
125
- };
126
- };
127
- const result = update(model, 0);
128
- return result === INVALID_POINTER ? {
129
- ok: false,
130
- value: model
131
- } : {
132
- ok: true,
133
- value: result
134
- };
135
- };
136
- const dataModelValue = (payload) => {
137
- for (const key of [
138
- "contents",
139
- "value",
140
- "data"
141
- ]) if (payload[key] !== void 0) return {
142
- found: true,
143
- value: payload[key]
144
- };
145
- return {
146
- found: false,
147
- value: void 0
148
- };
149
- };
150
- function applyA2uiOperations(state, operations) {
151
- const nextState = new Map(state);
152
- const warnings = [];
153
- if (!Array.isArray(operations)) return {
154
- state: nextState,
155
- warnings: ["A2UI operations must be an array."]
156
- };
157
- for (let index = 0; index < operations.length; index++) try {
158
- const entry = operations[index];
159
- if (!isRecord(entry)) {
160
- warnings.push(`Operation at index ${index} is malformed.`);
161
- continue;
162
- }
163
- const version = entry["version"];
164
- if (!isVersion(version)) {
165
- warnings.push(`Operation at index ${index} has an unsupported version.`);
166
- continue;
167
- }
168
- const operationKeys = Object.keys(entry).filter((key) => key !== "version");
169
- if (operationKeys.length !== 1) {
170
- warnings.push(`Operation at index ${index} must contain exactly one operation key.`);
171
- continue;
172
- }
173
- const operationKey = operationKeys[0];
174
- if (!OPERATION_KEYS.has(operationKey)) {
175
- warnings.push(`Unknown A2UI operation "${operationKey}" at index ${index}.`);
176
- continue;
177
- }
178
- const payload = entry[operationKey];
179
- if (!isRecord(payload)) {
180
- warnings.push(`Operation at index ${index} has a malformed payload.`);
181
- continue;
182
- }
183
- const surfaceId = surfaceIdOf(payload);
184
- if (!surfaceId) {
185
- warnings.push(`Operation at index ${index} has no valid surfaceId.`);
186
- continue;
187
- }
188
- if (operationKey === "createSurface") {
189
- const catalogId = catalogIdOf(payload);
190
- const surface = withSurfaceId({
191
- ...catalogId !== void 0 ? { catalogId } : {},
192
- components: /* @__PURE__ */ new Map(),
193
- dataModel: version === "v1.0" && payload["dataModel"] !== void 0 ? payload["dataModel"] : void 0
194
- }, surfaceId);
195
- if (version === "v1.0" && payload["components"] !== void 0) upsertComponents(surface, payload["components"], warnings, index);
196
- nextState.set(surfaceId, surface);
197
- continue;
198
- }
199
- if (operationKey === "deleteSurface") {
200
- nextState.delete(surfaceId);
201
- continue;
202
- }
203
- const currentSurface = nextState.get(surfaceId);
204
- if (!currentSurface) {
205
- warnings.push(`Operation at index ${index} references missing surface "${surfaceId}".`);
206
- continue;
207
- }
208
- const surface = cloneSurface(currentSurface, surfaceId);
209
- if (operationKey === "updateComponents") {
210
- upsertComponents(surface, payload["components"], warnings, index);
211
- nextState.set(surfaceId, surface);
212
- continue;
213
- }
214
- const update = dataModelValue(payload);
215
- if (!update.found) {
216
- warnings.push(`Operation at index ${index} has no data model value.`);
217
- continue;
218
- }
219
- const path = payload["path"] ?? "/";
220
- if (typeof path !== "string") {
221
- warnings.push(`Operation at index ${index} has a malformed data model path.`);
222
- continue;
223
- }
224
- const result = setAtPointer(surface.dataModel, path, update.value, version === "v1.0");
225
- if (!result.ok) {
226
- warnings.push(`Operation at index ${index} has an invalid JSON Pointer path.`);
227
- continue;
228
- }
229
- surface.dataModel = result.value;
230
- nextState.set(surfaceId, surface);
231
- } catch {
232
- warnings.push(`Operation at index ${index} is malformed.`);
233
- }
234
- return {
235
- state: nextState,
236
- warnings
237
- };
238
- }
239
- //#endregion
240
- export { MAX_AUTO_VIVIFY_ARRAY_INDEX, applyA2uiOperations, setAtPointer };
241
-
242
- //# sourceMappingURL=reducer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reducer.js","names":[],"sources":["../../src/a2ui/reducer.ts"],"sourcesContent":["import {\n A2UI_SURFACE_ID,\n type A2uiOperationResult,\n type A2uiState,\n type A2uiSurfaceState,\n type A2uiVersion,\n} from \"./types\";\n\nconst OPERATION_KEYS = new Set([\n \"createSurface\",\n \"updateComponents\",\n \"updateDataModel\",\n \"deleteSurface\",\n]);\n// This defensive ceiling is well above the renderer's displayed-item limit.\nexport const MAX_AUTO_VIVIFY_ARRAY_INDEX = 10_000;\nconst INVALID_POINTER = Symbol(\"invalidPointer\");\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isVersion = (value: unknown): value is A2uiVersion =>\n value === \"v0.9\" || value === \"v0.9.1\" || value === \"v1.0\";\n\nconst surfaceIdOf = (payload: Record<string, unknown>): string | undefined => {\n const surfaceId = payload[\"surfaceId\"];\n return typeof surfaceId === \"string\" && surfaceId.length > 0\n ? surfaceId\n : undefined;\n};\n\nconst catalogIdOf = (payload: Record<string, unknown>): string | undefined => {\n if (typeof payload[\"catalogId\"] === \"string\") {\n return payload[\"catalogId\"];\n }\n const surfaceProperties = payload[\"surfaceProperties\"];\n return isRecord(surfaceProperties) &&\n typeof surfaceProperties[\"catalogId\"] === \"string\"\n ? surfaceProperties[\"catalogId\"]\n : undefined;\n};\n\nconst withSurfaceId = (\n surface: A2uiSurfaceState,\n surfaceId: string,\n): A2uiSurfaceState => {\n Object.defineProperty(surface, A2UI_SURFACE_ID, {\n value: surfaceId,\n enumerable: false,\n });\n return surface;\n};\n\nconst getSurfaceId = (surface: A2uiSurfaceState): string | undefined =>\n (surface as A2uiSurfaceState & { [A2UI_SURFACE_ID]?: string })[\n A2UI_SURFACE_ID\n ];\n\nconst cloneSurface = (\n surface: A2uiSurfaceState,\n surfaceId: string,\n): A2uiSurfaceState =>\n withSurfaceId(\n {\n ...(surface.catalogId !== undefined\n ? { catalogId: surface.catalogId }\n : {}),\n components: new Map(surface.components),\n dataModel: surface.dataModel,\n },\n getSurfaceId(surface) ?? surfaceId,\n );\n\nconst upsertComponents = (\n surface: A2uiSurfaceState,\n components: unknown,\n warnings: string[],\n operationIndex: number,\n): void => {\n if (!Array.isArray(components)) {\n warnings.push(\n `Operation at index ${operationIndex} has malformed components.`,\n );\n return;\n }\n\n for (\n let componentIndex = 0;\n componentIndex < components.length;\n componentIndex++\n ) {\n const component = components[componentIndex];\n if (\n !isRecord(component) ||\n typeof component[\"id\"] !== \"string\" ||\n component[\"id\"].length === 0 ||\n typeof component[\"component\"] !== \"string\" ||\n component[\"component\"].length === 0\n ) {\n warnings.push(\n `Component at index ${componentIndex} in operation ${operationIndex} is malformed.`,\n );\n continue;\n }\n surface.components.set(component[\"id\"], { ...component });\n }\n};\n\nconst decodePointer = (path: string): string[] | undefined => {\n if (path === \"\" || path === \"/\") return [];\n if (!path.startsWith(\"/\")) return undefined;\n return path\n .slice(1)\n .split(\"/\")\n .map((segment) => segment.replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\"));\n};\n\nconst isArrayIndex = (segment: string): boolean =>\n segment === \"0\" || /^[1-9]\\d*$/.test(segment);\n\nexport const setAtPointer = (\n model: unknown,\n path: string,\n value: unknown,\n nullDeletes: boolean,\n): { readonly ok: boolean; readonly value: unknown } => {\n const segments = decodePointer(path);\n if (!segments) return { ok: false, value: model };\n if (segments.length === 0) return { ok: true, value };\n\n const remove = (current: unknown, index: number): unknown => {\n const segment = segments[index]!;\n const isLast = index === segments.length - 1;\n\n if (Array.isArray(current)) {\n if (segment !== \"-\" && !isArrayIndex(segment)) return current;\n const targetIndex = segment === \"-\" ? current.length : Number(segment);\n if (isLast) {\n if (\n segment === \"-\" ||\n !Object.prototype.hasOwnProperty.call(current, targetIndex)\n ) {\n return current;\n }\n const clone = current.slice();\n // Preserve indices referenced by other JSON Pointers.\n delete clone[targetIndex];\n return clone;\n }\n const child = current[targetIndex];\n if (!Array.isArray(child) && !isRecord(child)) return current;\n const next = remove(child, index + 1);\n if (next === child) return current;\n const clone = current.slice();\n clone[targetIndex] = next;\n return clone;\n }\n\n if (!isRecord(current)) return current;\n if (!Object.prototype.hasOwnProperty.call(current, segment)) return current;\n if (isLast) {\n const clone = { ...current };\n delete clone[segment];\n return clone;\n }\n const child = current[segment];\n if (!Array.isArray(child) && !isRecord(child)) return current;\n const next = remove(child, index + 1);\n if (next === child) return current;\n return { ...current, [segment]: next };\n };\n\n if (nullDeletes && value === null) {\n return { ok: true, value: remove(model, 0) };\n }\n\n const update = (current: unknown, index: number): unknown => {\n const segment = segments[index]!;\n const isLast = index === segments.length - 1;\n\n if (Array.isArray(current)) {\n if (segment !== \"-\" && !isArrayIndex(segment)) return current;\n const targetIndex = segment === \"-\" ? current.length : Number(segment);\n if (\n segment !== \"-\" &&\n targetIndex >= current.length &&\n targetIndex > MAX_AUTO_VIVIFY_ARRAY_INDEX\n ) {\n return INVALID_POINTER;\n }\n const next = isLast ? value : update(current[targetIndex], index + 1);\n if (next === INVALID_POINTER) return INVALID_POINTER;\n const clone = current.slice();\n clone[targetIndex] = next;\n return clone;\n }\n\n const record: Record<string, unknown> = isRecord(current) ? current : {};\n const child = Object.hasOwn(record, segment) ? record[segment] : undefined;\n const next = isLast\n ? value\n : update(\n child ??\n (isArrayIndex(segments[index + 1] ?? \"\") ||\n segments[index + 1] === \"-\"\n ? []\n : {}),\n index + 1,\n );\n if (next === INVALID_POINTER) return INVALID_POINTER;\n return { ...record, [segment]: next };\n };\n\n const result = update(model, 0);\n return result === INVALID_POINTER\n ? { ok: false, value: model }\n : { ok: true, value: result };\n};\n\nconst dataModelValue = (\n payload: Record<string, unknown>,\n): { readonly found: boolean; readonly value: unknown } => {\n for (const key of [\"contents\", \"value\", \"data\"] as const) {\n if (payload[key] !== undefined) {\n return { found: true, value: payload[key] };\n }\n }\n return { found: false, value: undefined };\n};\n\nexport function applyA2uiOperations(\n state: A2uiState,\n operations: unknown,\n): A2uiOperationResult {\n const nextState = new Map(state);\n const warnings: string[] = [];\n\n if (!Array.isArray(operations)) {\n return {\n state: nextState,\n warnings: [\"A2UI operations must be an array.\"],\n };\n }\n\n for (let index = 0; index < operations.length; index++) {\n try {\n const entry = operations[index];\n if (!isRecord(entry)) {\n warnings.push(`Operation at index ${index} is malformed.`);\n continue;\n }\n\n const version = entry[\"version\"];\n if (!isVersion(version)) {\n warnings.push(\n `Operation at index ${index} has an unsupported version.`,\n );\n continue;\n }\n\n const operationKeys = Object.keys(entry).filter(\n (key) => key !== \"version\",\n );\n if (operationKeys.length !== 1) {\n warnings.push(\n `Operation at index ${index} must contain exactly one operation key.`,\n );\n continue;\n }\n\n const operationKey = operationKeys[0]!;\n if (!OPERATION_KEYS.has(operationKey)) {\n warnings.push(\n `Unknown A2UI operation \"${operationKey}\" at index ${index}.`,\n );\n continue;\n }\n\n const payload = entry[operationKey];\n if (!isRecord(payload)) {\n warnings.push(`Operation at index ${index} has a malformed payload.`);\n continue;\n }\n\n const surfaceId = surfaceIdOf(payload);\n if (!surfaceId) {\n warnings.push(`Operation at index ${index} has no valid surfaceId.`);\n continue;\n }\n\n if (operationKey === \"createSurface\") {\n const catalogId = catalogIdOf(payload);\n const surface = withSurfaceId(\n {\n ...(catalogId !== undefined ? { catalogId } : {}),\n components: new Map(),\n dataModel:\n version === \"v1.0\" && payload[\"dataModel\"] !== undefined\n ? payload[\"dataModel\"]\n : undefined,\n },\n surfaceId,\n );\n if (version === \"v1.0\" && payload[\"components\"] !== undefined) {\n upsertComponents(surface, payload[\"components\"], warnings, index);\n }\n nextState.set(surfaceId, surface);\n continue;\n }\n\n if (operationKey === \"deleteSurface\") {\n nextState.delete(surfaceId);\n continue;\n }\n\n const currentSurface = nextState.get(surfaceId);\n if (!currentSurface) {\n warnings.push(\n `Operation at index ${index} references missing surface \"${surfaceId}\".`,\n );\n continue;\n }\n const surface = cloneSurface(currentSurface, surfaceId);\n\n if (operationKey === \"updateComponents\") {\n upsertComponents(surface, payload[\"components\"], warnings, index);\n nextState.set(surfaceId, surface);\n continue;\n }\n\n const update = dataModelValue(payload);\n if (!update.found) {\n warnings.push(`Operation at index ${index} has no data model value.`);\n continue;\n }\n const path = payload[\"path\"] ?? \"/\";\n if (typeof path !== \"string\") {\n warnings.push(\n `Operation at index ${index} has a malformed data model path.`,\n );\n continue;\n }\n const result = setAtPointer(\n surface.dataModel,\n path,\n update.value,\n version === \"v1.0\",\n );\n if (!result.ok) {\n warnings.push(\n `Operation at index ${index} has an invalid JSON Pointer path.`,\n );\n continue;\n }\n surface.dataModel = result.value;\n nextState.set(surfaceId, surface);\n } catch {\n warnings.push(`Operation at index ${index} is malformed.`);\n }\n }\n\n return { state: nextState, warnings };\n}\n"],"mappings":";;AAQA,MAAM,iCAAiB,IAAI,IAAI;CAC7B;CACA;CACA;CACA;AACF,CAAC;AAED,MAAa,8BAA8B;AAC3C,MAAM,kBAAkB,OAAO,gBAAgB;AAE/C,MAAM,YAAY,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAErE,MAAM,aAAa,UACjB,UAAU,UAAU,UAAU,YAAY,UAAU;AAEtD,MAAM,eAAe,YAAyD;CAC5E,MAAM,YAAY,QAAQ;CAC1B,OAAO,OAAO,cAAc,YAAY,UAAU,SAAS,IACvD,YACA,KAAA;AACN;AAEA,MAAM,eAAe,YAAyD;CAC5E,IAAI,OAAO,QAAQ,iBAAiB,UAClC,OAAO,QAAQ;CAEjB,MAAM,oBAAoB,QAAQ;CAClC,OAAO,SAAS,iBAAiB,KAC/B,OAAO,kBAAkB,iBAAiB,WACxC,kBAAkB,eAClB,KAAA;AACN;AAEA,MAAM,iBACJ,S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AQ,eAAe,UAAU,KAAK;GAElE,UAAU,IAAI,WAAW,OAAO;GAChC;EACF;EAEA,IAAI,iBAAiB,iBAAiB;GACpC,UAAU,OAAO,SAAS;GAC1B;EACF;EAEA,MAAM,iBAAiB,UAAU,IAAI,SAAS;EAC9C,IAAI,CAAC,gBAAgB;GACnB,SAAS,KACP,sBAAsB,MAAM,+BAA+B,UAAU,GACvE;GACA;EACF;EACA,MAAM,UAAU,aAAa,gBAAgB,SAAS;EAEtD,IAAI,iBAAiB,oBAAoB;GACvC,iBAAiB,SAAS,QAAQ,eAAe,UAAU,KAAK;GAChE,UAAU,IAAI,WAAW,OAAO;GAChC;EACF;EAEA,MAAM,SAAS,eAAe,OAAO;EACrC,IAAI,CAAC,OAAO,OAAO;GACjB,SAAS,KAAK,sBAAsB,MAAM,0BAA0B;GACpE;EACF;EACA,MAAM,OAAO,QAAQ,WAAW;EAChC,IAAI,OAAO,SAAS,UAAU;GAC5B,SAAS,KACP,sBAAsB,MAAM,kCAC9B;GACA;EACF;EACA,MAAM,SAAS,aACb,QAAQ,WACR,MACA,OAAO,OACP,YAAY,MACd;EACA,IAAI,CAAC,OAAO,IAAI;GACd,SAAS,KACP,sBAAsB,MAAM,mCAC9B;GACA;EACF;EACA,QAAQ,YAAY,OAAO;EAC3B,UAAU,IAAI,WAAW,OAAO;CAClC,QAAQ;EACN,SAAS,KAAK,sBAAsB,MAAM,eAAe;CAC3D;CAGF,OAAO;EAAE,OAAO;EAAW;CAAS;AACtC"}
@@ -1,3 +0,0 @@
1
- import { type A2uiSurfaceState, type A2uiSurfaceSnapshotOperation } from "./types.js";
2
- export declare function surfaceToOperations(surface: A2uiSurfaceState, surfaceId?: string): readonly A2uiSurfaceSnapshotOperation[];
3
- //# sourceMappingURL=snapshot.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/a2ui/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,4BAA4B,EAElC,mBAAgB;AAOjB,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,gBAAgB,EACzB,SAAS,CAAC,EAAE,MAAM,GACjB,SAAS,4BAA4B,EAAE,CAoCzC"}
@@ -1,33 +0,0 @@
1
- import { A2UI_SURFACE_ID } from "./types.js";
2
- //#region src/a2ui/snapshot.ts
3
- const surfaceIdOf = (surface) => surface[A2UI_SURFACE_ID];
4
- function surfaceToOperations(surface, surfaceId) {
5
- const resolvedSurfaceId = surfaceId ?? surfaceIdOf(surface);
6
- if (!resolvedSurfaceId) throw new Error("A2UI surfaces must have a surface id to be replayed.");
7
- const operations = [{
8
- version: "v0.9",
9
- createSurface: {
10
- surfaceId: resolvedSurfaceId,
11
- ...surface.catalogId !== void 0 ? { catalogId: surface.catalogId } : {}
12
- }
13
- }, {
14
- version: "v0.9",
15
- updateComponents: {
16
- surfaceId: resolvedSurfaceId,
17
- components: [...surface.components.values()].map((component) => ({ ...component }))
18
- }
19
- }];
20
- if (surface.dataModel !== void 0) operations.push({
21
- version: "v0.9",
22
- updateDataModel: {
23
- surfaceId: resolvedSurfaceId,
24
- path: "/",
25
- contents: surface.dataModel
26
- }
27
- });
28
- return operations;
29
- }
30
- //#endregion
31
- export { surfaceToOperations };
32
-
33
- //# sourceMappingURL=snapshot.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snapshot.js","names":[],"sources":["../../src/a2ui/snapshot.ts"],"sourcesContent":["import {\n A2UI_SURFACE_ID,\n type A2uiSurfaceState,\n type A2uiSurfaceSnapshotOperation,\n type ComponentNode,\n} from \"./types\";\n\nconst surfaceIdOf = (surface: A2uiSurfaceState): string | undefined =>\n (surface as A2uiSurfaceState & { [A2UI_SURFACE_ID]?: string })[\n A2UI_SURFACE_ID\n ];\n\nexport function surfaceToOperations(\n surface: A2uiSurfaceState,\n surfaceId?: string,\n): readonly A2uiSurfaceSnapshotOperation[] {\n const resolvedSurfaceId = surfaceId ?? surfaceIdOf(surface);\n if (!resolvedSurfaceId) {\n throw new Error(\"A2UI surfaces must have a surface id to be replayed.\");\n }\n const operations: A2uiSurfaceSnapshotOperation[] = [\n {\n version: \"v0.9\",\n createSurface: {\n surfaceId: resolvedSurfaceId,\n ...(surface.catalogId !== undefined\n ? { catalogId: surface.catalogId }\n : {}),\n },\n },\n {\n version: \"v0.9\",\n updateComponents: {\n surfaceId: resolvedSurfaceId,\n components: [...surface.components.values()].map((component) => ({\n ...component,\n })) as ComponentNode[],\n },\n },\n ];\n if (surface.dataModel !== undefined) {\n operations.push({\n version: \"v0.9\",\n updateDataModel: {\n surfaceId: resolvedSurfaceId,\n path: \"/\",\n contents: surface.dataModel,\n },\n });\n }\n return operations;\n}\n"],"mappings":";;AAOA,MAAM,eAAe,YAClB,QACC;AAGJ,SAAgB,oBACd,SACA,WACyC;CACzC,MAAM,oBAAoB,aAAa,YAAY,OAAO;CAC1D,IAAI,CAAC,mBACH,MAAM,IAAI,MAAM,sDAAsD;CAExE,MAAM,aAA6C,CACjD;EACE,SAAS;EACT,eAAe;GACb,WAAW;GACX,GAAI,QAAQ,cAAc,KAAA,IACtB,EAAE,WAAW,QAAQ,UAAU,IAC/B,CAAC;EACP;CACF,GACA;EACE,SAAS;EACT,kBAAkB;GAChB,WAAW;GACX,YAAY,CAAC,GAAG,QAAQ,WAAW,OAAO,CAAC,CAAC,CAAC,KAAK,eAAe,EAC/D,GAAG,UACL,EAAE;EACJ;CACF,CACF;CACA,IAAI,QAAQ,cAAc,KAAA,GACxB,WAAW,KAAK;EACd,SAAS;EACT,iBAAiB;GACf,WAAW;GACX,MAAM;GACN,UAAU,QAAQ;EACpB;CACF,CAAC;CAEH,OAAO;AACT"}