@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":"fieldReferences.d.ts","sourceRoot":"","sources":["../src/fieldReferences.ts"],"names":[],"mappings":"AAYA;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,OAAO,KAAG,OAgBlD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,OAAO,OAAO,EACd,QAAQ,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KACxC,OA2CF,CAAC"}
@@ -1,53 +0,0 @@
1
- //#region src/fieldReferences.ts
2
- const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3
- const MAX_DEPTH = 64;
4
- const isFieldReference = (value) => isRecord(value) && typeof value["$field"] === "string" && Object.keys(value).every((key) => key === "$field" || key === "fallback");
5
- /**
6
- * Whether `value` contains a `{ "$field": name }` or `{ "$field": name, "fallback": value }` reference within 64 levels.
7
- */
8
- const hasFieldReference = (value) => {
9
- const seen = /* @__PURE__ */ new Set();
10
- const visit = (entry, depth) => {
11
- if (typeof entry !== "object" || entry === null || depth > MAX_DEPTH || seen.has(entry)) return false;
12
- if (isFieldReference(entry)) return true;
13
- seen.add(entry);
14
- return Object.values(entry).some((item) => visit(item, depth + 1));
15
- };
16
- return visit(value, 0);
17
- };
18
- /**
19
- * Replaces each `{ "$field": name }` reference inside `value` with the own property `name` of `fields`, or with the reference's own `fallback` when that is `undefined`. A reference that still resolves to `undefined` is dropped from its object or array, and a cyclic reference or anything nested deeper than 64 levels is kept as is.
20
- */
21
- const resolveFieldReferences = (value, fields) => {
22
- const ancestors = /* @__PURE__ */ new Set();
23
- const resolve = (entry, depth) => {
24
- if (isFieldReference(entry)) {
25
- const current = Object.hasOwn(fields, entry.$field) ? fields[entry.$field] : void 0;
26
- if (current !== void 0) return current;
27
- return Object.hasOwn(entry, "fallback") ? entry.fallback : void 0;
28
- }
29
- if (typeof entry !== "object" || entry === null || depth > MAX_DEPTH || ancestors.has(entry)) return entry;
30
- ancestors.add(entry);
31
- try {
32
- if (Array.isArray(entry)) return entry.map((item) => resolve(item, depth + 1)).filter((item) => item !== void 0);
33
- const result = {};
34
- for (const [key, item] of Object.entries(entry)) {
35
- const resolved = resolve(item, depth + 1);
36
- if (resolved !== void 0) Object.defineProperty(result, key, {
37
- value: resolved,
38
- enumerable: true,
39
- configurable: true,
40
- writable: true
41
- });
42
- }
43
- return result;
44
- } finally {
45
- ancestors.delete(entry);
46
- }
47
- };
48
- return resolve(value, 0);
49
- };
50
- //#endregion
51
- export { hasFieldReference, resolveFieldReferences };
52
-
53
- //# sourceMappingURL=fieldReferences.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fieldReferences.js","names":[],"sources":["../src/fieldReferences.ts"],"sourcesContent":["const isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst MAX_DEPTH = 64;\n\nconst isFieldReference = (\n value: unknown,\n): value is { readonly $field: string; readonly fallback?: unknown } =>\n isRecord(value) &&\n typeof value[\"$field\"] === \"string\" &&\n Object.keys(value).every((key) => key === \"$field\" || key === \"fallback\");\n\n/**\n * Whether `value` contains a `{ \"$field\": name }` or `{ \"$field\": name, \"fallback\": value }` reference within 64 levels.\n */\nexport const hasFieldReference = (value: unknown): boolean => {\n const seen = new Set<object>();\n const visit = (entry: unknown, depth: number): boolean => {\n if (\n typeof entry !== \"object\" ||\n entry === null ||\n depth > MAX_DEPTH ||\n seen.has(entry)\n ) {\n return false;\n }\n if (isFieldReference(entry)) return true;\n seen.add(entry);\n return Object.values(entry).some((item) => visit(item, depth + 1));\n };\n return visit(value, 0);\n};\n\n/**\n * Replaces each `{ \"$field\": name }` reference inside `value` with the own property `name` of `fields`, or with the reference's own `fallback` when that is `undefined`. A reference that still resolves to `undefined` is dropped from its object or array, and a cyclic reference or anything nested deeper than 64 levels is kept as is.\n */\nexport const resolveFieldReferences = (\n value: unknown,\n fields: Readonly<Record<string, unknown>>,\n): unknown => {\n const ancestors = new Set<object>();\n const resolve = (entry: unknown, depth: number): unknown => {\n if (isFieldReference(entry)) {\n const current = Object.hasOwn(fields, entry.$field)\n ? fields[entry.$field]\n : undefined;\n if (current !== undefined) return current;\n return Object.hasOwn(entry, \"fallback\") ? entry.fallback : undefined;\n }\n if (\n typeof entry !== \"object\" ||\n entry === null ||\n depth > MAX_DEPTH ||\n ancestors.has(entry)\n ) {\n return entry;\n }\n ancestors.add(entry);\n try {\n if (Array.isArray(entry)) {\n return entry\n .map((item) => resolve(item, depth + 1))\n .filter((item) => item !== undefined);\n }\n const result: Record<string, unknown> = {};\n for (const [key, item] of Object.entries(entry)) {\n const resolved = resolve(item, depth + 1);\n if (resolved !== undefined) {\n Object.defineProperty(result, key, {\n value: resolved,\n enumerable: true,\n configurable: true,\n writable: true,\n });\n }\n }\n return result;\n } finally {\n ancestors.delete(entry);\n }\n };\n return resolve(value, 0);\n};\n"],"mappings":";AAAA,MAAM,YAAY,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAErE,MAAM,YAAY;AAElB,MAAM,oBACJ,UAEA,SAAS,KAAK,KACd,OAAO,MAAM,cAAc,YAC3B,OAAO,KAAK,KAAK,CAAC,CAAC,OAAO,QAAQ,QAAQ,YAAY,QAAQ,UAAU;;;;AAK1E,MAAa,qBAAqB,UAA4B;CAC5D,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,SAAS,OAAgB,UAA2B;EACxD,IACE,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,aACR,KAAK,IAAI,KAAK,GAEd,OAAO;EAET,IAAI,iBAAiB,KAAK,GAAG,OAAO;EACpC,KAAK,IAAI,KAAK;EACd,OAAO,OAAO,OAAO,KAAK,CAAC,CAAC,MAAM,SAAS,MAAM,MAAM,QAAQ,CAAC,CAAC;CACnE;CACA,OAAO,MAAM,OAAO,CAAC;AACvB;;;;AAKA,MAAa,0BACX,OACA,WACY;CACZ,MAAM,4BAAY,IAAI,IAAY;CAClC,MAAM,WAAW,OAAgB,UAA2B;EAC1D,IAAI,iBAAiB,KAAK,GAAG;GAC3B,MAAM,UAAU,OAAO,OAAO,QAAQ,MAAM,MAAM,IAC9C,OAAO,MAAM,UACb,KAAA;GACJ,IAAI,YAAY,KAAA,GAAW,OAAO;GAClC,OAAO,OAAO,OAAO,OAAO,UAAU,IAAI,MAAM,WAAW,KAAA;EAC7D;EACA,IACE,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,aACR,UAAU,IAAI,KAAK,GAEnB,OAAO;EAET,UAAU,IAAI,KAAK;EACnB,IAAI;GACF,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MACJ,KAAK,SAAS,QAAQ,MAAM,QAAQ,CAAC,CAAC,CAAC,CACvC,QAAQ,SAAS,SAAS,KAAA,CAAS;GAExC,MAAM,SAAkC,CAAC;GACzC,KAAK,MAAM,CAAC,KAAK,SAAS,OAAO,QAAQ,KAAK,GAAG;IAC/C,MAAM,WAAW,QAAQ,MAAM,QAAQ,CAAC;IACxC,IAAI,aAAa,KAAA,GACf,OAAO,eAAe,QAAQ,KAAK;KACjC,OAAO;KACP,YAAY;KACZ,cAAc;KACd,UAAU;IACZ,CAAC;GAEL;GACA,OAAO;EACT,UAAU;GACR,UAAU,OAAO,KAAK;EACxB;CACF;CACA,OAAO,QAAQ,OAAO,CAAC;AACzB"}
@@ -1,18 +0,0 @@
1
- /** Options for {@link generativeUIToJSX}. */
2
- export interface GenerativeUIToJSXOptions {
3
- /** Escape string children so the output is safe to paste back into a JSX file. Defaults to `false`. */
4
- escape?: boolean;
5
- /** Pretty-print nested element trees with two-space indentation. Defaults to `false`. */
6
- pretty?: boolean;
7
- }
8
- /**
9
- * Serializes a generative-UI node to a JSX-like string for display: the "view source" of a model-produced tree. The wire form `{ $type: "Weather", id: "x" }` becomes `<Weather id="x" />`, and nested `children` render between tags: `<Card title="Hi"><Text>hello</Text></Card>`. A model-provided `$key` becomes the JSX `key` attribute.
10
- *
11
- * By default this is a faithful textual rendering, not a parser: text children are emitted verbatim (not HTML/JSX-escaped), so the result is meant to be shown, not re-parsed. Returns `""` for nodes that aren't renderable (no `$type` yet, `null`, booleans).
12
- *
13
- * Pass `{ escape: true }` to make the output safe to paste back into JSX: any string child containing `<`, `>`, `&`, `{`, or `}` is emitted as a JSON-stringified expression (`{JSON.stringify(child)}`) instead of verbatim, while a string child with none of those characters still renders verbatim.
14
- *
15
- * Pass `{ pretty: true }` to pretty-print nested element trees with two-space indentation, while pure text children stay on one line.
16
- */
17
- export declare function generativeUIToJSX(node: unknown, options?: GenerativeUIToJSXOptions): string;
18
- //# sourceMappingURL=generativeUIToJSX.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generativeUIToJSX.d.ts","sourceRoot":"","sources":["../src/generativeUIToJSX.ts"],"names":[],"mappings":"AAEA,6CAA6C;AAC7C,MAAM,WAAW,wBAAwB;IACvC,uGAAuG;IACvG,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,yFAAyF;IACzF,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE,wBAAwB,GACjC,MAAM,CAER"}
@@ -1,76 +0,0 @@
1
- import { TYPE_KEY } from "./constants.js";
2
- //#region src/generativeUIToJSX.ts
3
- /**
4
- * Serializes a generative-UI node to a JSX-like string for display: the "view source" of a model-produced tree. The wire form `{ $type: "Weather", id: "x" }` becomes `<Weather id="x" />`, and nested `children` render between tags: `<Card title="Hi"><Text>hello</Text></Card>`. A model-provided `$key` becomes the JSX `key` attribute.
5
- *
6
- * By default this is a faithful textual rendering, not a parser: text children are emitted verbatim (not HTML/JSX-escaped), so the result is meant to be shown, not re-parsed. Returns `""` for nodes that aren't renderable (no `$type` yet, `null`, booleans).
7
- *
8
- * Pass `{ escape: true }` to make the output safe to paste back into JSX: any string child containing `<`, `>`, `&`, `{`, or `}` is emitted as a JSON-stringified expression (`{JSON.stringify(child)}`) instead of verbatim, while a string child with none of those characters still renders verbatim.
9
- *
10
- * Pass `{ pretty: true }` to pretty-print nested element trees with two-space indentation, while pure text children stay on one line.
11
- */
12
- function generativeUIToJSX(node, options) {
13
- return toJSX(node, 0, options?.escape ?? false, options?.pretty ?? false, 0);
14
- }
15
- /**
16
- * The deepest tree we serialize. Input is model-produced, so a runaway/
17
- * adversarial response could nest arbitrarily deep and overflow the stack — past
18
- * this depth (far beyond any real UI) we stop. Mirrors the renderer's bound.
19
- */
20
- const MAX_DEPTH = 64;
21
- /** Characters that would break JSX if emitted verbatim inside a text child. */
22
- const UNSAFE_CHILD_CHARS = /[<>&{}]/;
23
- function toJSX(node, depth, escape, pretty, indent) {
24
- if (depth > MAX_DEPTH) return "";
25
- if (node == null || typeof node === "boolean") return "";
26
- if (typeof node === "string") return formatChildText(node, escape);
27
- if (typeof node === "number") return String(node);
28
- if (Array.isArray(node)) {
29
- if (pretty) return collectBlockLines(node, depth, escape, indent).join("\n");
30
- return node.map((child) => toJSX(child, depth + 1, escape, false, 0)).join("");
31
- }
32
- if (typeof node !== "object") return "";
33
- const { [TYPE_KEY]: type, $key, children, ...props } = node;
34
- if (typeof type !== "string") return "";
35
- const attrs = formatAttr("key", $key, escape) + Object.entries(props).map(([key, value]) => formatAttr(key, value, escape)).join("");
36
- if (!pretty) {
37
- const inner = children === void 0 ? "" : toJSX(children, depth + 1, escape, false, 0);
38
- return inner === "" ? `<${type}${attrs} />` : `<${type}${attrs}>${inner}</${type}>`;
39
- }
40
- const pad = " ".repeat(indent);
41
- if (children === void 0 || !hasElementChild(children)) {
42
- const inner = children === void 0 ? "" : toJSX(children, depth + 1, escape, false, 0);
43
- return inner === "" ? `${pad}<${type}${attrs} />` : `${pad}<${type}${attrs}>${inner}</${type}>`;
44
- }
45
- const lines = collectBlockLines(children, depth + 1, escape, indent + 1);
46
- if (lines.length === 0) return `${pad}<${type}${attrs} />`;
47
- return `${pad}<${type}${attrs}>\n${lines.join("\n")}\n${pad}</${type}>`;
48
- }
49
- function hasElementChild(node, depth = 0) {
50
- if (depth > MAX_DEPTH) return false;
51
- if (Array.isArray(node)) return node.some((child) => hasElementChild(child, depth + 1));
52
- return node != null && typeof node === "object" && typeof node["$type"] === "string";
53
- }
54
- function collectBlockLines(node, depth, escape, indent) {
55
- if (depth > MAX_DEPTH) return [];
56
- if (node == null || typeof node === "boolean") return [];
57
- if (Array.isArray(node)) return node.flatMap((child) => collectBlockLines(child, depth + 1, escape, indent));
58
- if (typeof node === "string") return [`${" ".repeat(indent)}${formatChildText(node, escape)}`];
59
- if (typeof node === "number") return [`${" ".repeat(indent)}${String(node)}`];
60
- const rendered = toJSX(node, depth, escape, true, indent);
61
- return rendered === "" ? [] : [rendered];
62
- }
63
- function formatChildText(value, escape) {
64
- return escape && UNSAFE_CHILD_CHARS.test(value) ? `{${JSON.stringify(value)}}` : value;
65
- }
66
- /** Formats one prop as a JSX attribute (`id="x"`, `count={3}`, `open`, …). */
67
- function formatAttr(key, value, escape) {
68
- if (value === void 0) return "";
69
- if (value === true) return ` ${key}`;
70
- if (typeof value === "string") return /["\n]/.test(value) || escape && value.includes("&") ? ` ${key}={${JSON.stringify(value)}}` : ` ${key}="${value}"`;
71
- return ` ${key}={${JSON.stringify(value)}}`;
72
- }
73
- //#endregion
74
- export { generativeUIToJSX };
75
-
76
- //# sourceMappingURL=generativeUIToJSX.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generativeUIToJSX.js","names":[],"sources":["../src/generativeUIToJSX.ts"],"sourcesContent":["import { TYPE_KEY } from \"./constants\";\n\n/** Options for {@link generativeUIToJSX}. */\nexport interface GenerativeUIToJSXOptions {\n /** Escape string children so the output is safe to paste back into a JSX file. Defaults to `false`. */\n escape?: boolean;\n /** Pretty-print nested element trees with two-space indentation. Defaults to `false`. */\n pretty?: boolean;\n}\n\n/**\n * Serializes a generative-UI node to a JSX-like string for display: the \"view source\" of a model-produced tree. The wire form `{ $type: \"Weather\", id: \"x\" }` becomes `<Weather id=\"x\" />`, and nested `children` render between tags: `<Card title=\"Hi\"><Text>hello</Text></Card>`. A model-provided `$key` becomes the JSX `key` attribute.\n *\n * By default this is a faithful textual rendering, not a parser: text children are emitted verbatim (not HTML/JSX-escaped), so the result is meant to be shown, not re-parsed. Returns `\"\"` for nodes that aren't renderable (no `$type` yet, `null`, booleans).\n *\n * Pass `{ escape: true }` to make the output safe to paste back into JSX: any string child containing `<`, `>`, `&`, `{`, or `}` is emitted as a JSON-stringified expression (`{JSON.stringify(child)}`) instead of verbatim, while a string child with none of those characters still renders verbatim.\n *\n * Pass `{ pretty: true }` to pretty-print nested element trees with two-space indentation, while pure text children stay on one line.\n */\nexport function generativeUIToJSX(\n node: unknown,\n options?: GenerativeUIToJSXOptions,\n): string {\n return toJSX(node, 0, options?.escape ?? false, options?.pretty ?? false, 0);\n}\n\n/**\n * The deepest tree we serialize. Input is model-produced, so a runaway/\n * adversarial response could nest arbitrarily deep and overflow the stack — past\n * this depth (far beyond any real UI) we stop. Mirrors the renderer's bound.\n */\nconst MAX_DEPTH = 64;\n\n/** Characters that would break JSX if emitted verbatim inside a text child. */\nconst UNSAFE_CHILD_CHARS = /[<>&{}]/;\n\nfunction toJSX(\n node: unknown,\n depth: number,\n escape: boolean,\n pretty: boolean,\n indent: number,\n): string {\n if (depth > MAX_DEPTH) return \"\";\n if (node == null || typeof node === \"boolean\") return \"\";\n if (typeof node === \"string\") return formatChildText(node, escape);\n if (typeof node === \"number\") return String(node);\n if (Array.isArray(node)) {\n if (pretty) {\n return collectBlockLines(node, depth, escape, indent).join(\"\\n\");\n }\n return node\n .map((child) => toJSX(child, depth + 1, escape, false, 0))\n .join(\"\");\n }\n if (typeof node !== \"object\") return \"\";\n\n const {\n [TYPE_KEY]: type,\n $key,\n children,\n ...props\n } = node as Record<string, unknown>;\n if (typeof type !== \"string\") return \"\";\n\n const attrs =\n formatAttr(\"key\", $key, escape) +\n Object.entries(props)\n .map(([key, value]) => formatAttr(key, value, escape))\n .join(\"\");\n\n if (!pretty) {\n const inner =\n children === undefined\n ? \"\"\n : toJSX(children, depth + 1, escape, false, 0);\n\n return inner === \"\"\n ? `<${type}${attrs} />`\n : `<${type}${attrs}>${inner}</${type}>`;\n }\n\n const pad = \" \".repeat(indent);\n\n if (children === undefined || !hasElementChild(children)) {\n const inner =\n children === undefined\n ? \"\"\n : toJSX(children, depth + 1, escape, false, 0);\n return inner === \"\"\n ? `${pad}<${type}${attrs} />`\n : `${pad}<${type}${attrs}>${inner}</${type}>`;\n }\n\n const lines = collectBlockLines(children, depth + 1, escape, indent + 1);\n if (lines.length === 0) {\n return `${pad}<${type}${attrs} />`;\n }\n return `${pad}<${type}${attrs}>\\n${lines.join(\"\\n\")}\\n${pad}</${type}>`;\n}\n\nfunction hasElementChild(node: unknown, depth = 0): boolean {\n if (depth > MAX_DEPTH) return false;\n if (Array.isArray(node))\n return node.some((child) => hasElementChild(child, depth + 1));\n return (\n node != null &&\n typeof node === \"object\" &&\n typeof (node as Record<string, unknown>)[TYPE_KEY] === \"string\"\n );\n}\n\nfunction collectBlockLines(\n node: unknown,\n depth: number,\n escape: boolean,\n indent: number,\n): string[] {\n if (depth > MAX_DEPTH) return [];\n if (node == null || typeof node === \"boolean\") return [];\n if (Array.isArray(node)) {\n return node.flatMap((child) =>\n collectBlockLines(child, depth + 1, escape, indent),\n );\n }\n if (typeof node === \"string\") {\n return [`${\" \".repeat(indent)}${formatChildText(node, escape)}`];\n }\n if (typeof node === \"number\") {\n return [`${\" \".repeat(indent)}${String(node)}`];\n }\n const rendered = toJSX(node, depth, escape, true, indent);\n return rendered === \"\" ? [] : [rendered];\n}\n\nfunction formatChildText(value: string, escape: boolean): string {\n return escape && UNSAFE_CHILD_CHARS.test(value)\n ? `{${JSON.stringify(value)}}`\n : value;\n}\n\n/** Formats one prop as a JSX attribute (`id=\"x\"`, `count={3}`, `open`, …). */\nfunction formatAttr(key: string, value: unknown, escape: boolean): string {\n if (value === undefined) return \"\";\n if (value === true) return ` ${key}`;\n if (typeof value === \"string\") {\n return /[\"\\n]/.test(value) || (escape && value.includes(\"&\"))\n ? ` ${key}={${JSON.stringify(value)}}`\n : ` ${key}=\"${value}\"`;\n }\n return ` ${key}={${JSON.stringify(value)}}`;\n}\n"],"mappings":";;;;;;;;;;;AAmBA,SAAgB,kBACd,MACA,SACQ;CACR,OAAO,MAAM,MAAM,GAAG,SAAS,UAAU,OAAO,SAAS,UAAU,OAAO,CAAC;AAC7E;;;;;;AAOA,MAAM,YAAY;;AAGlB,MAAM,qBAAqB;AAE3B,SAAS,MACP,MACA,OACA,QACA,QACA,QACQ;CACR,IAAI,QAAQ,WAAW,OAAO;CAC9B,IAAI,QAAQ,QAAQ,OAAO,SAAS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AG,IACvD,IAAI,IAAI,IAAI,KAAK,UAAU,KAAK,EAAE,KAClC,IAAI,IAAI,IAAI,MAAM;CAExB,OAAO,IAAI,IAAI,IAAI,KAAK,UAAU,KAAK,EAAE;AAC3C"}
@@ -1,15 +0,0 @@
1
- export { renderGenerativeUI } from "./renderGenerativeUI.js";
2
- export { generativeUIToJSX } from "./generativeUIToJSX.js";
3
- export type { GenerativeUIToJSXOptions } from "./generativeUIToJSX.js";
4
- export { buildPresentParameters } from "./buildPresentParameters.js";
5
- export { defineGenerativeComponents } from "./defineGenerativeComponents.js";
6
- export { TYPE_KEY } from "./constants.js";
7
- export { normalizeUINode, normalizeSpec } from "./ir.js";
8
- export { TEXT_SIZES, IMAGE_SIZE_TOKENS, WEIGHTS, COLORS, ALIGNS, JUSTIFIES, BUTTON_STYLES, ALERT_TONES, ICON_NAMES, } from "./ir.js";
9
- export { defaultGenerativeUILibrary } from "./vocabulary/index.js";
10
- export { createActionRegistry, emptyActionRegistry } from "./actionRegistry.js";
11
- export type { ActionHandler, ActionRegistry, ActionDispatchContext, } from "./actionRegistry.js";
12
- export type { JSONGenerativeUIOptions, PresentTool, PresentToolOptions, PromptUserTool, } from "./JSONGenerativeUI.shared.js";
13
- export type { GenerativeUILibrary, GenerativeUIComponent, GenerativeUIElement, GenerativeUIProps, GenerativeUINode, GenerativeUIStatus, GenerativeUIRenderContext, GenerativeUIAction, GenerativeUIDispatch, } from "./types.js";
14
- export type { UINode, UIElement, UIChildren, LegacyComponentNode, Action, UISpec, NormalizedUINode, NormalizedUIElement, TextSize, ImageSize, Weight, Color, Align, Justify, ButtonStyle, AlertTone, IconName, } from "./ir.js";
15
- //# sourceMappingURL=index.shared.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.shared.d.ts","sourceRoot":"","sources":["../src/index.shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,gCAA6B;AAC1D,OAAO,EAAE,iBAAiB,EAAE,+BAA4B;AACxD,YAAY,EAAE,wBAAwB,EAAE,+BAA4B;AACpE,OAAO,EAAE,sBAAsB,EAAE,oCAAiC;AAClE,OAAO,EAAE,0BAA0B,EAAE,wCAAqC;AAC1E,OAAO,EAAE,QAAQ,EAAE,uBAAoB;AACvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAa;AACtD,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,OAAO,EACP,MAAM,EACN,MAAM,EACN,SAAS,EACT,aAAa,EACb,WAAW,EACX,UAAU,GACX,gBAAa;AACd,OAAO,EAAE,0BAA0B,EAAE,8BAAqB;AAC1D,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,4BAAyB;AAC7E,YAAY,EACV,aAAa,EACb,cAAc,EACd,qBAAqB,GACtB,4BAAyB;AAC1B,YAAY,EACV,uBAAuB,EACvB,WAAW,EACX,kBAAkB,EAClB,cAAc,GACf,qCAAkC;AACnC,YAAY,EACV,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,oBAAoB,GACrB,mBAAgB;AACjB,YAAY,EACV,MAAM,EACN,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,MAAM,EACN,MAAM,EACN,gBAAgB,EAChB,mBAAmB,EACnB,QAAQ,EACR,SAAS,EACT,MAAM,EACN,KAAK,EACL,KAAK,EACL,OAAO,EACP,WAAW,EACX,SAAS,EACT,QAAQ,GACT,gBAAa"}
@@ -1,9 +0,0 @@
1
- import { TYPE_KEY } from "./constants.js";
2
- import { ALERT_TONES, ALIGNS, BUTTON_STYLES, COLORS, ICON_NAMES, IMAGE_SIZE_TOKENS, JUSTIFIES, TEXT_SIZES, WEIGHTS, normalizeSpec, normalizeUINode } from "./ir.js";
3
- import { renderGenerativeUI } from "./renderGenerativeUI.js";
4
- import { buildPresentParameters } from "./buildPresentParameters.js";
5
- import { createActionRegistry, emptyActionRegistry } from "./actionRegistry.js";
6
- import { defineGenerativeComponents } from "./defineGenerativeComponents.js";
7
- import { generativeUIToJSX } from "./generativeUIToJSX.js";
8
- import { defaultGenerativeUILibrary } from "./vocabulary/index.js";
9
- export { ALERT_TONES, ALIGNS, BUTTON_STYLES, COLORS, ICON_NAMES, IMAGE_SIZE_TOKENS, JUSTIFIES, TEXT_SIZES, TYPE_KEY, WEIGHTS, buildPresentParameters, createActionRegistry, defaultGenerativeUILibrary, defineGenerativeComponents, emptyActionRegistry, generativeUIToJSX, normalizeSpec, normalizeUINode, renderGenerativeUI };
package/dist/ir.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"ir.js","names":[],"sources":["../src/ir.ts"],"sourcesContent":["/**\n * The generative-ui intermediate representation: a model-emitted, cross-platform\n * UI tree. React-free, so converters and non-web runtimes consume it without\n * pulling React. The flat `$type` shape is the canonical form; the legacy\n * `component` shape is accepted as a backward-compatible alias.\n *\n * Reserved keys are partitioned off from component props so the component prop\n * namespace stays fully free:\n *\n * - `$`-prefixed keys are framework-reserved (`$type`, `$key`, `$action`,\n * `$status`). Components never declare `$`-prefixed props, so a component\n * can use `type`, `status`, `variant`, etc. as ordinary props without\n * colliding with the framework.\n * - `children` is additionally reserved (the JSX convention).\n * - every other key is an inline prop passed straight to the component.\n */\n\nimport { TYPE_KEY } from \"./constants\";\n\nexport const TEXT_SIZES = [\"sm\", \"md\", \"lg\", \"xl\", \"2xl\", \"3xl\"] as const;\nexport type TextSize = (typeof TEXT_SIZES)[number];\n\nexport const IMAGE_SIZE_TOKENS = [\"sm\", \"md\", \"lg\"] as const;\nexport type ImageSize = (typeof IMAGE_SIZE_TOKENS)[number] | number;\n\nexport const WEIGHTS = [\"normal\", \"medium\", \"semibold\", \"bold\"] as const;\nexport type Weight = (typeof WEIGHTS)[number];\n\nexport const COLORS = [\n \"emphasis\",\n \"secondary\",\n \"alpha-70\",\n \"white\",\n \"white-70\",\n \"white-50\",\n] as const;\nexport type Color = (typeof COLORS)[number];\n\nexport const ALIGNS = [\"start\", \"center\", \"end\"] as const;\nexport type Align = (typeof ALIGNS)[number];\n\nexport const JUSTIFIES = [\"start\", \"center\", \"end\", \"between\"] as const;\nexport type Justify = (typeof JUSTIFIES)[number];\n\nexport const BUTTON_STYLES = [\n \"primary\",\n \"secondary\",\n \"outline\",\n \"ghost\",\n \"danger\",\n] as const;\nexport type ButtonStyle = (typeof BUTTON_STYLES)[number];\n\nexport const ALERT_TONES = [\"info\", \"success\", \"warning\", \"danger\"] as const;\n/** A severity level, from informational to destructive. */\nexport type AlertTone = (typeof ALERT_TONES)[number];\n\nexport const ICON_NAMES = [\n \"sun\",\n \"moon\",\n \"cloud\",\n \"rain\",\n \"snow\",\n \"wind\",\n \"play\",\n \"pause\",\n \"check\",\n \"x\",\n \"star\",\n \"heart\",\n \"arrow-right\",\n \"arrow-up-right\",\n \"chevron-right\",\n \"calendar\",\n \"clock\",\n \"map-pin\",\n \"plane\",\n \"truck\",\n \"credit-card\",\n \"user\",\n \"search\",\n \"bell\",\n] as const;\n/** A name from the built-in icon set; the closed enum lets the model see exactly which icons exist. */\nexport type IconName = (typeof ICON_NAMES)[number];\n\n/**\n * Behavior payload carried by an interactive node. `type` is resolved by the host's action registry, not the renderer; keeping behavior as data keeps the tree serializable, so the same node renders on web while converters may bind the type to a native action id on other platforms. A `{ \"$field\": name }` value anywhere in the payload refers to the current value of the control with that `name`, resolved when the action fires, and `{ \"$field\": name, \"fallback\": value }` resolves to `fallback` when no control holds a value.\n */\nexport interface Action {\n readonly type: string;\n readonly [payload: string]: unknown;\n}\n\n/**\n * Anything renderable as generative UI, as the model emits it. The renderer\n * also accepts `number`, `boolean`, `null`, `undefined`, and arrays at the\n * input boundary (numbers render as text, falsy/boolean as nothing, arrays as\n * lists); {@link normalizeUINode} accepts that full range.\n */\nexport type UINode = string | number | UIElement | LegacyComponentNode;\n\nexport type UIChildren = UINode | readonly UINode[];\n\n/** The flat node shape: inline props keep the tree compact and natural for a\n * model to emit, instead of a nested `{ type, props }` bag. Reserved keys are\n * stripped before props reach the component (see the module header). */\nexport interface UIElement {\n readonly $type: string;\n readonly $key?: string | number;\n readonly children?: UIChildren;\n readonly $action?: Action;\n readonly [prop: string]: unknown;\n}\n\n/**\n * The legacy node shape: a `component` name plus a nested `props` bag. Kept\n * for backward compatibility. New code authors the flat {@link UIElement}\n * shape instead.\n */\nexport interface LegacyComponentNode {\n readonly component: string;\n readonly props?: Record<string, unknown>;\n readonly children?: UIChildren;\n readonly key?: string;\n}\n\nexport type UISpec = UINode | readonly UINode[];\n\n/**\n * A node normalized to a single canonical shape: a `type` string, an inline\n * `props` bag, recursive `children`, an optional `key`, and an optional\n * `action`. Renderers and platform converters consume this form, so they never\n * branch on whether the model emitted the flat `$type` shape or the legacy\n * `component` shape, and they never see the reserved `$`-prefixed keys leak\n * into component props.\n */\nexport interface NormalizedUIElement {\n readonly type: string;\n readonly props: Readonly<Record<string, unknown>>;\n readonly children?: NormalizedUINode | undefined;\n readonly key?: string | number | undefined;\n readonly action?: Action | undefined;\n}\n\nexport type NormalizedUINode =\n | string\n | number\n | readonly NormalizedUINode[]\n | NormalizedUIElement\n | null;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\ntype LegacyNodeRecord = { component: string } & Record<string, unknown>;\n\nconst isLegacyNode = (\n node: Record<string, unknown>,\n): node is LegacyNodeRecord => typeof node[\"component\"] === \"string\";\n\nconst isTypeNode = (node: Record<string, unknown>): node is UIElement =>\n typeof node[TYPE_KEY] === \"string\";\n\n/** Bounds recursion so a runaway or adversarial model response cannot overflow\n * the stack; past this depth (far beyond any real UI) we stop. */\nconst MAX_DEPTH = 64;\n\n/**\n * Steps a streaming partial path down into `key`. `partialPath` is the remaining\n * segment of the parse meta's partial path relative to `node` (`undefined` once\n * the walk leaves the partial frontier, i.e. everything below is complete).\n */\nfunction descend(\n partialPath: readonly string[] | undefined,\n key: string,\n): readonly string[] | undefined {\n return partialPath?.[0] === key ? partialPath.slice(1) : undefined;\n}\n\n/**\n * Normalizes a generative-ui input to {@link NormalizedUINode}. The flat\n * `$type` shape and the legacy `component` shape both map to the same canonical\n * element, with reserved keys (`$type`, `$key`, `$action`, `children`) stripped\n * from the prop bag. A node that carries neither a `$type` nor a `component`\n * string is not renderable and resolves to `null` rather than throwing, so a\n * partially-streamed or malformed node degrades to \"render nothing\".\n *\n * `partialPath` carries streaming state from the tool-args parse meta: a node\n * whose `$type` is still mid-arrival is held back (resolves to `null`) until it\n * completes, and the path is threaded into `children` so a nested streaming\n * node is held back while completed siblings render. Omit it for a\n * non-streaming (converter) normalize.\n */\nexport function normalizeUINode(\n node: unknown,\n partialPath?: readonly string[] | undefined,\n depth = 0,\n): NormalizedUINode {\n if (depth > MAX_DEPTH) return null;\n if (node == null || typeof node === \"boolean\") return null;\n if (typeof node === \"string\" || typeof node === \"number\") return node;\n if (Array.isArray(node))\n return node.map((child, index) =>\n normalizeUINode(child, descend(partialPath, String(index)), depth + 1),\n );\n if (!isRecord(node)) return null;\n\n // The flat `$type` shape is the canonical form; detect it first so a flat\n // node that happens to use `component` as an ordinary prop is not swallowed\n // by the legacy `component`-shape branch.\n if (isTypeNode(node)) {\n if (partialPath?.length === 1 && partialPath[0] === TYPE_KEY) return null;\n const { [TYPE_KEY]: type, $key, $action, children, ...rest } = node;\n // The `$`-prefixed namespace is framework-reserved (see the module header),\n // so any model-supplied `$`-prefixed key is stripped from the prop bag the\n // component sees. `$type`/`$key`/`$action` are pulled above; sweep the rest\n // (e.g. a stray `$status`) so it never leaks to converters or components.\n const props = stripReservedProps(rest);\n return {\n type,\n props,\n children: normalizeChildren(children, partialPath, depth),\n key: $key,\n action: $action,\n };\n }\n\n if (isLegacyNode(node)) {\n const props = stripReservedProps(\n (node.props ?? {}) as Record<string, unknown>,\n );\n return {\n type: node.component,\n props,\n children: normalizeChildren(node.children, partialPath, depth),\n key: node.key as string | undefined,\n };\n }\n\n return null;\n}\n\nfunction stripReservedProps(\n props: Record<string, unknown>,\n): Record<string, unknown> {\n let out: Record<string, unknown> | undefined;\n for (const key of Object.keys(props)) {\n if (key.startsWith(\"$\")) {\n out ??= { ...props };\n delete out[key];\n }\n }\n return out ?? props;\n}\n\nfunction normalizeChildren(\n children: unknown,\n partialPath: readonly string[] | undefined,\n depth: number,\n): NormalizedUINode | undefined {\n if (children === undefined) return undefined;\n return normalizeUINode(children, descend(partialPath, \"children\"), depth + 1);\n}\n\n/**\n * Normalizes the root of a {@link UISpec}, preserving whether the root was a\n * single node or a list.\n */\nexport function normalizeSpec(spec: UISpec): {\n readonly root: NormalizedUINode | readonly NormalizedUINode[];\n} {\n if (Array.isArray(spec)) {\n return {\n root: (spec as readonly UINode[]).map((node) => normalizeUINode(node)),\n };\n }\n return { root: normalizeUINode(spec) };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAa,aAAa;CAAC;CAAM;CAAM;CAAM;CAAM;CAAO;AAAK;AAG/D,MAAa,oBAAoB;CAAC;CAAM;CAAM;AAAI;AAGlD,MAAa,UAAU;CAAC;CAAU;CAAU;CAAY;AAAM;AAG9D,MAAa,SAAS;CACpB;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,MAAa,SAAS;CAAC;CAAS;CAAU;AAAK;AAG/C,MAAa,YAAY;CAAC;CAAS;CAAU;CAAO;AAAS;AAG7D,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;CACA;AACF;AAGA,MAAa,cAAc;CAAC;CAAQ;CAAW;CAAW;AAAQ;AAIlE,MAAa,aAAa;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAsEA,MAAM,YAAY,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAIrE,MAAM,gBACJ,SAC6B,OAAO,KAAK,iBAAiB;AAE5D,MAAM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,IAAI,aAAa,KAAA,GAAW,OAAO,KAAA;CACnC,OAAO,gBAAgB,UAAU,QAAQ,aAAa,UAAU,GAAG,QAAQ,CAAC;AAC9E;;;;;AAMA,SAAgB,cAAc,MAE5B;CACA,IAAI,MAAM,QAAQ,IAAI,GACpB,OAAO,EACL,MAAO,KAA2B,KAAK,SAAS,gBAAgB,IAAI,CAAC,EACvE;CAEF,OAAO,EAAE,MAAM,gBAAgB,IAAI,EAAE;AACvC"}
@@ -1,14 +0,0 @@
1
- import { type ReactNode } from "react";
2
- import type { GenerativeUILibrary, GenerativeUIRenderContext } from "./types.js";
3
- /**
4
- * Renders a generative-ui tree against a {@link GenerativeUILibrary}.
5
- *
6
- * The model emits each node as a flat object `{ $type, ...props }`. We first
7
- * normalize that wire form into the canonical {@link NormalizedUINode} (with
8
- * `children` lifted to a reserved top-level key), then render: each `type` is
9
- * looked up in the library and its `props` are passed to the component's
10
- * `render(props, context)`, with `children` rendered recursively so components
11
- * can nest.
12
- */
13
- export declare function renderGenerativeUI(node: unknown, library: GenerativeUILibrary, context?: GenerativeUIRenderContext): ReactNode;
14
- //# sourceMappingURL=renderGenerativeUI.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"renderGenerativeUI.d.ts","sourceRoot":"","sources":["../src/renderGenerativeUI.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAQjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,mBAAgB;AAO9E;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,mBAAmB,EAC5B,OAAO,GAAE,yBAA2C,GACnD,SAAS,CAgBX"}
@@ -1,83 +0,0 @@
1
- import { RadioGroupScope } from "./RadioGroupScope.js";
2
- import { hasFieldReference, resolveFieldReferences } from "./fieldReferences.js";
3
- import { normalizeUINode } from "./ir.js";
4
- import { getPartialJsonObjectMeta } from "assistant-stream/utils";
5
- import { Fragment } from "react";
6
- import { jsx } from "react/jsx-runtime";
7
- //#region src/renderGenerativeUI.tsx
8
- const DEFAULT_CONTEXT = { status: "done" };
9
- const isElement = (node) => typeof node === "object" && node !== null && !Array.isArray(node);
10
- /**
11
- * Renders a generative-ui tree against a {@link GenerativeUILibrary}.
12
- *
13
- * The model emits each node as a flat object `{ $type, ...props }`. We first
14
- * normalize that wire form into the canonical {@link NormalizedUINode} (with
15
- * `children` lifted to a reserved top-level key), then render: each `type` is
16
- * looked up in the library and its `props` are passed to the component's
17
- * `render(props, context)`, with `children` rendered recursively so components
18
- * can nest.
19
- */
20
- function renderGenerativeUI(node, library, context = DEFAULT_CONTEXT) {
21
- const meta = getPartialJsonObjectMeta(node);
22
- const partialPath = meta?.state === "partial" ? meta.partialPath : void 0;
23
- const rendered = renderNode(normalizeUINode(node, partialPath), library, withFieldFallbacks(context));
24
- return rendered !== null && typeof rendered === "object" ? /* @__PURE__ */ jsx(RadioGroupScope, { children: rendered }) : rendered;
25
- }
26
- const withFieldFallbacks = (context) => {
27
- const { dispatch } = context;
28
- if (dispatch === void 0) return context;
29
- return {
30
- ...context,
31
- dispatch: (action) => dispatch(hasFieldReference(action) ? resolveFieldReferences(action, {}) : action)
32
- };
33
- };
34
- function renderNode(node, library, context) {
35
- if (node == null || typeof node === "boolean") return null;
36
- if (typeof node === "string" || typeof node === "number") return node;
37
- if (Array.isArray(node)) return node.map((child, index) => /* @__PURE__ */ jsx(Fragment, { children: renderNode(child, library, context) }, nodeKey(child, index)));
38
- return isElement(node) ? renderElement(node, library, context) : null;
39
- }
40
- function renderElement(element, library, context) {
41
- const entry = Object.hasOwn(library, element.type) ? library[element.type] : void 0;
42
- if (!entry) {
43
- reportUnknownComponent(element.type, Object.keys(library));
44
- return null;
45
- }
46
- if (!entry.streamProperties && context.status === "streaming") return null;
47
- const props = {
48
- ...element.props,
49
- $status: context.status
50
- };
51
- if (context.dispatch !== void 0) props["$dispatch"] = context.dispatch;
52
- if (element.action !== void 0) props["$action"] = element.action;
53
- if (element.children !== void 0) props["children"] = renderNode(element.children, library, context);
54
- return /* @__PURE__ */ jsx(GenerativeUIComponentRenderer, {
55
- render: entry.render,
56
- props
57
- });
58
- }
59
- /**
60
- * Mounts a single node's `render` on its own fiber so the function may use
61
- * hooks and hold state independently of its siblings and parent.
62
- */
63
- function GenerativeUIComponentRenderer({ render, props }) {
64
- return render(props);
65
- }
66
- /** A coarse kind tag for a child, used in its list key so a node changing kind
67
- * at a given index forces a remount rather than a wrong-fiber reuse. */
68
- function nodeKind(node) {
69
- if (node == null || typeof node === "boolean") return "";
70
- if (typeof node === "string" || typeof node === "number") return "#text";
71
- if (Array.isArray(node)) return "#array";
72
- return isElement(node) ? node.type : "";
73
- }
74
- function nodeKey(node, index) {
75
- return isElement(node) && (typeof node.key === "string" || typeof node.key === "number") ? `model:${node.key}` : `${index}:${nodeKind(node)}`;
76
- }
77
- function reportUnknownComponent(type, available) {
78
- if (process.env["NODE_ENV"] !== "production") console.error(`[@assistant-ui/react-generative-ui] Unknown component "${type}". Available components: ${available.join(", ") || "(none)"}.`);
79
- }
80
- //#endregion
81
- export { renderGenerativeUI };
82
-
83
- //# sourceMappingURL=renderGenerativeUI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"renderGenerativeUI.js","names":[],"sources":["../src/renderGenerativeUI.tsx"],"sourcesContent":["import { RadioGroupScope } from \"./RadioGroupScope\";\nimport { getPartialJsonObjectMeta } from \"assistant-stream/utils\";\nimport { Fragment, type ReactNode } from \"react\";\nimport { hasFieldReference, resolveFieldReferences } from \"./fieldReferences\";\nimport {\n normalizeUINode,\n type Action,\n type NormalizedUIElement,\n type NormalizedUINode,\n} from \"./ir\";\nimport type { GenerativeUILibrary, GenerativeUIRenderContext } from \"./types\";\n\nconst DEFAULT_CONTEXT: GenerativeUIRenderContext = { status: \"done\" };\n\nconst isElement = (node: NormalizedUINode): node is NormalizedUIElement =>\n typeof node === \"object\" && node !== null && !Array.isArray(node);\n\n/**\n * Renders a generative-ui tree against a {@link GenerativeUILibrary}.\n *\n * The model emits each node as a flat object `{ $type, ...props }`. We first\n * normalize that wire form into the canonical {@link NormalizedUINode} (with\n * `children` lifted to a reserved top-level key), then render: each `type` is\n * looked up in the library and its `props` are passed to the component's\n * `render(props, context)`, with `children` rendered recursively so components\n * can nest.\n */\nexport function renderGenerativeUI(\n node: unknown,\n library: GenerativeUILibrary,\n context: GenerativeUIRenderContext = DEFAULT_CONTEXT,\n): ReactNode {\n // Tool args are parsed incrementally, and the parse meta records which path\n // is still mid-arrival, so normalization can hold back a node whose `$type`\n // string has not finished streaming.\n const meta = getPartialJsonObjectMeta(node as Record<symbol, unknown>);\n const partialPath = meta?.state === \"partial\" ? meta.partialPath : undefined;\n const rendered = renderNode(\n normalizeUINode(node, partialPath),\n library,\n withFieldFallbacks(context),\n );\n return rendered !== null && typeof rendered === \"object\" ? (\n <RadioGroupScope>{rendered}</RadioGroupScope>\n ) : (\n rendered\n );\n}\n\n// A component that dispatches `$action` itself reads no control, so each `$field` reference left in it becomes its fallback.\nconst withFieldFallbacks = (\n context: GenerativeUIRenderContext,\n): GenerativeUIRenderContext => {\n const { dispatch } = context;\n if (dispatch === undefined) return context;\n return {\n ...context,\n dispatch: (action) =>\n dispatch(\n hasFieldReference(action)\n ? (resolveFieldReferences(action, {}) as Action)\n : action,\n ),\n };\n};\n\nfunction renderNode(\n node: NormalizedUINode,\n library: GenerativeUILibrary,\n context: GenerativeUIRenderContext,\n): ReactNode {\n if (node == null || typeof node === \"boolean\") return null;\n if (typeof node === \"string\" || typeof node === \"number\") return node;\n if (Array.isArray(node)) {\n // Use a model-provided stable key when present. Otherwise, keep the\n // positional fallback: pairing the index with the node's kind means that\n // when the kind at an index changes, React remounts instead of handing a\n // streaming node's hook state to a different component.\n return node.map((child, index) => (\n <Fragment key={nodeKey(child, index)}>\n {renderNode(child, library, context)}\n </Fragment>\n ));\n }\n return isElement(node) ? renderElement(node, library, context) : null;\n}\n\nfunction renderElement(\n element: NormalizedUIElement,\n library: GenerativeUILibrary,\n context: GenerativeUIRenderContext,\n): ReactNode {\n const entry = Object.hasOwn(library, element.type)\n ? library[element.type]\n : undefined;\n if (!entry) {\n reportUnknownComponent(element.type, Object.keys(library));\n return null;\n }\n\n // Components that opt out of prop streaming wait until their props are\n // complete rather than rendering from a partial parse.\n if (!entry.streamProperties && context.status === \"streaming\") return null;\n\n // `children` is a reserved top-level key on the normalized element, not a\n // prop, so it is not in `props`. Inject the framework props last so the model\n // can never override them. `$action` is likewise reserved and stripped from\n // the prop bag during normalization, so it is re-injected here for components\n // that carry behavior (e.g. `Button`).\n const props: Record<string, unknown> = {\n ...element.props,\n $status: context.status,\n };\n if (context.dispatch !== undefined) {\n props[\"$dispatch\"] = context.dispatch;\n }\n if (element.action !== undefined) {\n props[\"$action\"] = element.action;\n }\n if (element.children !== undefined) {\n props[\"children\"] = renderNode(element.children, library, context);\n }\n\n return <GenerativeUIComponentRenderer render={entry.render} props={props} />;\n}\n\n/**\n * Mounts a single node's `render` on its own fiber so the function may use\n * hooks and hold state independently of its siblings and parent.\n */\nfunction GenerativeUIComponentRenderer({\n render,\n props,\n}: {\n render: (props: any) => ReactNode;\n props: Record<string, unknown>;\n}): ReactNode {\n return render(props);\n}\n\n/** A coarse kind tag for a child, used in its list key so a node changing kind\n * at a given index forces a remount rather than a wrong-fiber reuse. */\nfunction nodeKind(node: NormalizedUINode): string {\n if (node == null || typeof node === \"boolean\") return \"\";\n if (typeof node === \"string\" || typeof node === \"number\") return \"#text\";\n if (Array.isArray(node)) return \"#array\";\n return isElement(node) ? node.type : \"\";\n}\n\nfunction nodeKey(node: NormalizedUINode, index: number): string {\n return isElement(node) &&\n (typeof node.key === \"string\" || typeof node.key === \"number\")\n ? `model:${node.key}`\n : `${index}:${nodeKind(node)}`;\n}\n\nfunction reportUnknownComponent(type: string, available: string[]): void {\n if (process.env[\"NODE_ENV\"] !== \"production\") {\n // eslint-disable-next-line no-console\n console.error(\n `[@assistant-ui/react-generative-ui] Unknown component \"${type}\". ` +\n `Available components: ${available.join(\", \") || \"(none)\"}.`,\n );\n }\n}\n"],"mappings":";;;;;;;AAYA,MAAM,kBAA6C,EAAE,QAAQ,OAAO;AAEpE,MAAM,aAAa,SACjB,OAAO,SAAS,YAAY,SAAS,QAAQ,CAAC,MAAM,QAAQ,IAAI;;;;;;;;;;;AAYlE,SAAgB,mBACd,MACA,SACA,UAAqC,iBAC1B;CAIX,MAAM,OAAO,yBAAyB,IAA+B;CACrE,MAAM,cAAc,MAAM,UAAU,YAAY,KAAK,cAAc,KAAA;CACnE,MAAM,WAAW,WACf,gBAAgB,MAAM,WAAW,GACjC,SACA,mBAAmB,OAAO,CAC5B;CACA,OAAO,aAAa,QAAQ,OAAO,aAAa,WAC9C,oBAAC,iBAAD,EAAA,UAAkB,SAA0B,CAAA,IAE5C;AAEJ;AAGA,MAAM,sBACJ,YAC8B;CAC9B,MAAM,EAAE,aAAa;CACrB,IAAI,aAAa,KAAA,GAAW,OAAO;CACnC,OAAO;EACL,GAAG;EACH,WAAW,WACT,SACE,kBAAkB,MAAM,IACnB,uBAAuB,QAAQ,CAAC,CAAC,IAClC,MACN;CACJ;AACF;AAEA,SAAS,WACP,MACA,SACA,SACW;CACX,IAAI,QAAQ,QAAQ,OAAO,SAAS,WAAW,OAAO;CACtD,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU,OAAO;CACjE,IAAI,MAAM,QAAQ,IAAI,GAKpB,OAAO,KAAK,KAAK,OAAO,UACtB,oBAAC,UAAD,EAAA,UACG,WAAW,OAAO,SAAS,OAAO,EAC3B,GAFK,QAAQ,OAAO,KAAK,CAEzB,CACX;CAEH,OAAO,UAAU,IAAI,IAAI,cAAc,MAAM,SAAS,OAAO,IAAI;AACnE;AAEA,SAAS,cACP,SACA,SACA,SACW;CACX,MAAM,QAAQ,OAAO,OAAO,SAAS,QAAQ,IAAI,IAC7C,QAAQ,QAAQ,QAChB,KAAA;CACJ,IAAI,CAAC,OAAO;EACV,uBAAuB,QAAQ,MAAM,OAAO,KAAK,OAAO,CAAC;EACzD,OAAO;CACT;CAIA,IAAI,CAAC,MAAM,oBAAoB,QAAQ,WAAW,aAAa,OAAO;CAOtE,MAAM,QAAiC;EACrC,GAAG,QAAQ;EACX,SAAS,QAAQ;CACnB;CACA,IAAI,QAAQ,aAAa,KAAA,GACvB,MAAM,eAAe,QAAQ;CAE/B,IAAI,QAAQ,WAAW,KAAA,GACrB,MAAM,aAAa,QAAQ;CAE7B,IAAI,QAAQ,aAAa,KAAA,GACvB,MAAM,cAAc,WAAW,QAAQ,UAAU,SAAS,OAAO;CAGnE,OAAO,oBAAC,+BAAD;EAA+B,QAAQ,MAAM;EAAe;CAAQ,CAAA;AAC7E;;;;;AAMA,SAAS,8BAA8B,EACrC,QACA,SAIY;CACZ,OAAO,OAAO,KAAK;AACrB;;;AAIA,SAAS,SAAS,MAAgC;CAChD,IAAI,QAAQ,QAAQ,OAAO,SAAS,WAAW,OAAO;CACtD,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU,OAAO;CACjE,IAAI,MAAM,QAAQ,IAAI,GAAG,OAAO;CAChC,OAAO,UAAU,IAAI,IAAI,KAAK,OAAO;AACvC;AAEA,SAAS,QAAQ,MAAwB,OAAuB;CAC9D,OAAO,UAAU,IAAI,MAClB,OAAO,KAAK,QAAQ,YAAY,OAAO,KAAK,QAAQ,YACnD,SAAS,KAAK,QACd,GAAG,MAAM,GAAG,SAAS,IAAI;AAC/B;AAEA,SAAS,uBAAuB,MAAc,WAA2B;CACvE,IAAI,QAAQ,IAAI,gBAAgB,cAE9B,QAAQ,MACN,0DAA0D,KAAK,2BACpC,UAAU,KAAK,IAAI,KAAK,SAAS,EAC9D;AAEJ"}
@@ -1,6 +0,0 @@
1
- import type { JSONSchema7 } from "json-schema";
2
- export declare function scopeSchema(schema: JSONSchema7, path: string): {
3
- schema: JSONSchema7;
4
- referenced: boolean;
5
- };
6
- //# sourceMappingURL=scopeSchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scopeSchema.d.ts","sourceRoot":"","sources":["../src/scopeSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAyB,MAAM,aAAa,CAAC;AAYtE,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM;;;EA0D5D"}
@@ -1,56 +0,0 @@
1
- //#region src/scopeSchema.ts
2
- function scopeSchema(schema, path) {
3
- let referenced = false;
4
- const visit = (definition) => {
5
- if (typeof definition === "boolean") return definition;
6
- const schema = definition;
7
- const result = { ...schema };
8
- if (schema.$ref === "#" || schema.$ref?.startsWith("#/")) {
9
- referenced = true;
10
- result.$ref = path + schema.$ref.slice(1);
11
- }
12
- for (const key of [
13
- "properties",
14
- "patternProperties",
15
- "definitions",
16
- "$defs",
17
- "dependentSchemas"
18
- ]) {
19
- const entries = schema[key];
20
- if (entries) result[key] = Object.fromEntries(Object.entries(entries).map(([name, value]) => [name, visit(value)]));
21
- }
22
- for (const key of [
23
- "allOf",
24
- "anyOf",
25
- "oneOf",
26
- "prefixItems"
27
- ]) if (schema[key]) result[key] = schema[key].map(visit);
28
- for (const key of [
29
- "additionalProperties",
30
- "additionalItems",
31
- "unevaluatedProperties",
32
- "unevaluatedItems",
33
- "contentSchema",
34
- "contains",
35
- "propertyNames",
36
- "not",
37
- "if",
38
- "then",
39
- "else"
40
- ]) {
41
- const value = schema[key];
42
- if (value !== void 0) result[key] = visit(value);
43
- }
44
- if (schema.items !== void 0) result.items = Array.isArray(schema.items) ? schema.items.map(visit) : visit(schema.items);
45
- if (schema.dependencies) result.dependencies = Object.fromEntries(Object.entries(schema.dependencies).map(([name, value]) => [name, Array.isArray(value) ? value : visit(value)]));
46
- return result;
47
- };
48
- return {
49
- schema: visit(schema),
50
- referenced
51
- };
52
- }
53
- //#endregion
54
- export { scopeSchema };
55
-
56
- //# sourceMappingURL=scopeSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scopeSchema.js","names":[],"sources":["../src/scopeSchema.ts"],"sourcesContent":["import type { JSONSchema7, JSONSchema7Definition } from \"json-schema\";\n\n// The converter does not pin a JSON Schema draft, so the 2020-12 applicators\n// missing from the JSONSchema7 typings must be traversed as well.\ntype TraversableSchema = JSONSchema7 & {\n prefixItems?: JSONSchema7Definition[];\n dependentSchemas?: { [key: string]: JSONSchema7Definition };\n unevaluatedItems?: JSONSchema7Definition;\n unevaluatedProperties?: JSONSchema7Definition;\n contentSchema?: JSONSchema7Definition;\n};\n\nexport function scopeSchema(schema: JSONSchema7, path: string) {\n let referenced = false;\n const visit = (definition: JSONSchema7Definition): JSONSchema7Definition => {\n if (typeof definition === \"boolean\") return definition;\n const schema = definition as TraversableSchema;\n const result = { ...schema };\n if (schema.$ref === \"#\" || schema.$ref?.startsWith(\"#/\")) {\n referenced = true;\n result.$ref = path + schema.$ref.slice(1);\n }\n // Only schema-bearing keywords are traversed; defaults and examples are data.\n for (const key of [\n \"properties\",\n \"patternProperties\",\n \"definitions\",\n \"$defs\",\n \"dependentSchemas\",\n ] as const) {\n const entries = schema[key];\n if (entries)\n result[key] = Object.fromEntries(\n Object.entries(entries).map(([name, value]) => [name, visit(value)]),\n );\n }\n for (const key of [\"allOf\", \"anyOf\", \"oneOf\", \"prefixItems\"] as const) {\n if (schema[key]) result[key] = schema[key].map(visit);\n }\n for (const key of [\n \"additionalProperties\",\n \"additionalItems\",\n \"unevaluatedProperties\",\n \"unevaluatedItems\",\n \"contentSchema\",\n \"contains\",\n \"propertyNames\",\n \"not\",\n \"if\",\n \"then\",\n \"else\",\n ] as const) {\n const value = schema[key];\n if (value !== undefined) result[key] = visit(value);\n }\n if (schema.items !== undefined)\n result.items = Array.isArray(schema.items)\n ? schema.items.map(visit)\n : visit(schema.items);\n if (schema.dependencies)\n result.dependencies = Object.fromEntries(\n Object.entries(schema.dependencies).map(([name, value]) => [\n name,\n Array.isArray(value) ? value : visit(value),\n ]),\n );\n return result;\n };\n const scoped = visit(schema) as JSONSchema7;\n return { schema: scoped, referenced };\n}\n"],"mappings":";AAYA,SAAgB,YAAY,QAAqB,MAAc;CAC7D,IAAI,aAAa;CACjB,MAAM,SAAS,eAA6D;EAC1E,IAAI,OAAO,eAAe,WAAW,OAAO;EAC5C,MAAM,SAAS;EACf,MAAM,SAAS,EAAE,GAAG,OAAO;EAC3B,IAAI,OAAO,SAAS,OAAO,OAAO,MAAM,WAAW,IAAI,GAAG;GACxD,aAAa;GACb,OAAO,OAAO,OAAO,OAAO,KAAK,MAAM,CAAC;EAC1C;EAEA,KAAK,MAAM,OAAO;GAChB;GACA;GACA;GACA;GACA;EACF,GAAY;GACV,MAAM,UAAU,OAAO;GACvB,IAAI,SACF,OAAO,OAAO,OAAO,YACnB,OAAO,QAAQ,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAAC,MAAM,MAAM,KAAK,CAAC,CAAC,CACrE;EACJ;EACA,KAAK,MAAM,OAAO;GAAC;GAAS;GAAS;GAAS;EAAa,GACzD,IAAI,OAAO,MAAM,OAAO,OAAO,OAAO,IAAI,CAAC,IAAI,KAAK;EAEtD,KAAK,MAAM,OAAO;GAChB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,GAAY;GACV,MAAM,QAAQ,OAAO;GACrB,IAAI,UAAU,KAAA,GAAW,OAAO,OAAO,MAAM,KAAK;EACpD;EACA,IAAI,OAAO,UAAU,KAAA,GACnB,OAAO,QAAQ,MAAM,QAAQ,OAAO,KAAK,IACrC,OAAO,MAAM,IAAI,KAAK,IACtB,MAAM,OAAO,KAAK;EACxB,IAAI,OAAO,cACT,OAAO,eAAe,OAAO,YAC3B,OAAO,QAAQ,OAAO,YAAY,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CACzD,MACA,MAAM,QAAQ,KAAK,IAAI,QAAQ,MAAM,KAAK,CAC5C,CAAC,CACH;EACF,OAAO;CACT;CAEA,OAAO;EAAE,QADM,MAAM,MACC;EAAG;CAAW;AACtC"}
@@ -1,93 +0,0 @@
1
- import type { SlackAlertBlock, SlackButtonElement, SlackCardBlock, SlackCarouselBlock, SlackContextBlock, SlackDataTableBlock, SlackDataTableCell, SlackImageBlock, SlackSectionBlock, SlackTextObject } from "./types.js";
2
- /** The block limit for a Slack message. */
3
- export declare const MESSAGE_BLOCK_CAP = 50;
4
- /** The block limit for a Slack modal. */
5
- export declare const MODAL_BLOCK_CAP = 100;
6
- /**
7
- * The maximum number of top-level blocks accepted when parsing Slack Block
8
- * Kit JSON back into generative UI, guarding against a hostile or malformed
9
- * payload.
10
- */
11
- export declare const INBOUND_BLOCK_CAP = 200;
12
- /** The character limit for header text. */
13
- export declare const HEADER_TEXT_CAP = 150;
14
- /** The character limit for section text. */
15
- export declare const SECTION_TEXT_CAP = 3000;
16
- /** The maximum number of fields in one section. */
17
- export declare const FACT_FIELD_CAP = 10;
18
- /** The character limit for one section field. */
19
- export declare const FACT_FIELD_TEXT_CAP = 2000;
20
- /** The character limit for button labels and option labels. */
21
- export declare const INTERACTIVE_TEXT_CAP = 75;
22
- /** The character limit for an action_id. */
23
- export declare const ACTION_ID_CAP = 255;
24
- /** The character limit for a button's serialized value payload. */
25
- export declare const BUTTON_VALUE_CAP = 2000;
26
- /** The maximum number of elements in one actions block. */
27
- export declare const ACTIONS_ELEMENT_CAP = 25;
28
- /** The maximum number of options in a static select. */
29
- export declare const SELECT_OPTION_CAP = 100;
30
- /** The maximum number of options in a radio-button group. */
31
- export declare const RADIO_OPTION_CAP = 10;
32
- /** The maximum number of options in a checkbox group. */
33
- export declare const CHECKBOX_OPTION_CAP = 10;
34
- /** The character limit for a select or input placeholder. */
35
- export declare const PLACEHOLDER_TEXT_CAP = 150;
36
- /** The character limit for an input's label. */
37
- export declare const INPUT_LABEL_CAP = 2000;
38
- /** The maximum number of elements in one context block. */
39
- export declare const CONTEXT_ELEMENT_CAP = 10;
40
- /** The character limit for one context element's text. */
41
- export declare const CONTEXT_TEXT_CAP = 3000;
42
- /** The character limit for card titles and subtitles. */
43
- export declare const CARD_TITLE_CAP = 150;
44
- /** The character limit for a card's body text. */
45
- export declare const CARD_BODY_CAP = 200;
46
- /** The character limit for a card's subtext. */
47
- export declare const CARD_SUBTEXT_CAP = 200;
48
- /** The maximum number of buttons in a card's actions. */
49
- export declare const CARD_ACTIONS_CAP = 3;
50
- /** The minimum number of elements in a renderable carousel. */
51
- export declare const CAROUSEL_CARD_MIN = 1;
52
- /** The maximum number of elements in a carousel. */
53
- export declare const CAROUSEL_CARD_CAP = 10;
54
- /** The character limit for an alert's text. */
55
- export declare const ALERT_TEXT_CAP = 200;
56
- /**
57
- * The maximum number of data rows in a data-table block; the emitted `rows`
58
- * array additionally carries one header row.
59
- */
60
- export declare const DATA_TABLE_ROW_CAP = 200;
61
- /** The maximum number of columns in a data-table block. */
62
- export declare const DATA_TABLE_COLUMN_CAP = 20;
63
- /**
64
- * The cumulative character limit (summed across every cell's text) shared by
65
- * every data-table block in one payload.
66
- */
67
- export declare const DATA_TABLE_CHAR_BUDGET = 20000;
68
- /** The caption emitted on every native data-table block. */
69
- export declare const TABLE_CAPTION = "Table";
70
- /** The cumulative character limit for native markdown blocks. */
71
- export declare const MARKDOWN_TEXT_BUDGET = 12000;
72
- /** Builds the message-surface fallback for an alert. */
73
- export declare function buildAlertFallback(title: string, description: string, tone: "info" | "success" | "warning" | "danger"): readonly [SlackContextBlock, SlackSectionBlock];
74
- /** Builds a 2026 Slack modal-only alert block, mapping `tone` to its `level`. */
75
- export declare function buildAlertBlock(text: string, tone: "info" | "success" | "warning" | "danger"): SlackAlertBlock;
76
- type CardBlockFields = {
77
- readonly heroImage?: SlackImageBlock;
78
- readonly title?: SlackTextObject;
79
- readonly subtitle?: SlackTextObject;
80
- readonly body?: SlackTextObject;
81
- readonly subtext?: SlackTextObject;
82
- readonly actions?: readonly SlackButtonElement[];
83
- };
84
- /** Builds a 2026 Slack card block from its already-clamped fields. */
85
- export declare function buildCardBlock(fields: CardBlockFields): SlackCardBlock;
86
- /** Builds a 2026 Slack carousel block. */
87
- export declare function buildCarouselBlock(elements: readonly SlackCardBlock[]): SlackCarouselBlock;
88
- /** Builds a 2026 Slack data-table block; `rows[0]` must be the header row. */
89
- export declare function buildDataTableBlock(rows: readonly (readonly SlackDataTableCell[])[]): SlackDataTableBlock;
90
- /** Builds the final note used when a surface block budget is exceeded. */
91
- export declare function buildBlockBudgetNote(omitted: number): SlackContextBlock;
92
- export {};
93
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/slack/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,eAAe,EAChB,mBAAgB;AAEjB,2CAA2C;AAC3C,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,yCAAyC;AACzC,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,2CAA2C;AAC3C,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,4CAA4C;AAC5C,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC,mDAAmD;AACnD,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,iDAAiD;AACjD,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,+DAA+D;AAC/D,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,4CAA4C;AAC5C,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC,mEAAmE;AACnE,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC,2DAA2D;AAC3D,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,wDAAwD;AACxD,eAAO,MAAM,iBAAiB,MAAM,CAAC;AA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