@lynx-js/genui 0.0.1-rc.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 (254) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +170 -0
  3. package/a2ui/README.md +140 -0
  4. package/a2ui/dist/catalog/Button/catalog.json +156 -0
  5. package/a2ui/dist/catalog/Button/index.d.ts +35 -0
  6. package/a2ui/dist/catalog/Button/index.js +35 -0
  7. package/a2ui/dist/catalog/Button/index.js.map +1 -0
  8. package/a2ui/dist/catalog/Card/catalog.json +24 -0
  9. package/a2ui/dist/catalog/Card/index.d.ts +11 -0
  10. package/a2ui/dist/catalog/Card/index.js +19 -0
  11. package/a2ui/dist/catalog/Card/index.js.map +1 -0
  12. package/a2ui/dist/catalog/CheckBox/catalog.json +170 -0
  13. package/a2ui/dist/catalog/CheckBox/index.d.ts +32 -0
  14. package/a2ui/dist/catalog/CheckBox/index.js +24 -0
  15. package/a2ui/dist/catalog/CheckBox/index.js.map +1 -0
  16. package/a2ui/dist/catalog/Column/catalog.json +57 -0
  17. package/a2ui/dist/catalog/Column/index.d.ts +15 -0
  18. package/a2ui/dist/catalog/Column/index.js +55 -0
  19. package/a2ui/dist/catalog/Column/index.js.map +1 -0
  20. package/a2ui/dist/catalog/Divider/catalog.json +14 -0
  21. package/a2ui/dist/catalog/Divider/index.d.ts +9 -0
  22. package/a2ui/dist/catalog/Divider/index.js +8 -0
  23. package/a2ui/dist/catalog/Divider/index.js.map +1 -0
  24. package/a2ui/dist/catalog/Icon/catalog.json +45 -0
  25. package/a2ui/dist/catalog/Icon/index.d.ts +14 -0
  26. package/a2ui/dist/catalog/Icon/index.js +11 -0
  27. package/a2ui/dist/catalog/Icon/index.js.map +1 -0
  28. package/a2ui/dist/catalog/Image/catalog.json +62 -0
  29. package/a2ui/dist/catalog/Image/index.d.ts +16 -0
  30. package/a2ui/dist/catalog/Image/index.js +30 -0
  31. package/a2ui/dist/catalog/Image/index.js.map +1 -0
  32. package/a2ui/dist/catalog/LineChart/catalog.json +98 -0
  33. package/a2ui/dist/catalog/LineChart/index.d.ts +31 -0
  34. package/a2ui/dist/catalog/LineChart/index.js +195 -0
  35. package/a2ui/dist/catalog/LineChart/index.js.map +1 -0
  36. package/a2ui/dist/catalog/List/catalog.json +52 -0
  37. package/a2ui/dist/catalog/List/index.d.ts +15 -0
  38. package/a2ui/dist/catalog/List/index.js +53 -0
  39. package/a2ui/dist/catalog/List/index.js.map +1 -0
  40. package/a2ui/dist/catalog/Modal/catalog.json +18 -0
  41. package/a2ui/dist/catalog/Modal/index.d.ts +12 -0
  42. package/a2ui/dist/catalog/Modal/index.js +33 -0
  43. package/a2ui/dist/catalog/Modal/index.js.map +1 -0
  44. package/a2ui/dist/catalog/PieChart/catalog.json +87 -0
  45. package/a2ui/dist/catalog/PieChart/index.d.ts +37 -0
  46. package/a2ui/dist/catalog/PieChart/index.js +131 -0
  47. package/a2ui/dist/catalog/PieChart/index.js.map +1 -0
  48. package/a2ui/dist/catalog/RadioGroup/catalog.json +184 -0
  49. package/a2ui/dist/catalog/RadioGroup/index.d.ts +36 -0
  50. package/a2ui/dist/catalog/RadioGroup/index.js +36 -0
  51. package/a2ui/dist/catalog/RadioGroup/index.js.map +1 -0
  52. package/a2ui/dist/catalog/Row/catalog.json +57 -0
  53. package/a2ui/dist/catalog/Row/index.d.ts +15 -0
  54. package/a2ui/dist/catalog/Row/index.js +28 -0
  55. package/a2ui/dist/catalog/Row/index.js.map +1 -0
  56. package/a2ui/dist/catalog/Slider/catalog.json +183 -0
  57. package/a2ui/dist/catalog/Slider/index.d.ts +41 -0
  58. package/a2ui/dist/catalog/Slider/index.js +39 -0
  59. package/a2ui/dist/catalog/Slider/index.js.map +1 -0
  60. package/a2ui/dist/catalog/Slider/utils.d.ts +11 -0
  61. package/a2ui/dist/catalog/Slider/utils.js +58 -0
  62. package/a2ui/dist/catalog/Slider/utils.js.map +1 -0
  63. package/a2ui/dist/catalog/Tabs/catalog.json +28 -0
  64. package/a2ui/dist/catalog/Tabs/index.d.ts +12 -0
  65. package/a2ui/dist/catalog/Tabs/index.js +32 -0
  66. package/a2ui/dist/catalog/Tabs/index.js.map +1 -0
  67. package/a2ui/dist/catalog/Text/catalog.json +74 -0
  68. package/a2ui/dist/catalog/Text/index.d.ts +18 -0
  69. package/a2ui/dist/catalog/Text/index.js +27 -0
  70. package/a2ui/dist/catalog/Text/index.js.map +1 -0
  71. package/a2ui/dist/catalog/TextField/catalog.json +147 -0
  72. package/a2ui/dist/catalog/TextField/index.d.ts +35 -0
  73. package/a2ui/dist/catalog/TextField/index.js +43 -0
  74. package/a2ui/dist/catalog/TextField/index.js.map +1 -0
  75. package/a2ui/dist/catalog/TextField/utils.d.ts +7 -0
  76. package/a2ui/dist/catalog/TextField/utils.js +51 -0
  77. package/a2ui/dist/catalog/TextField/utils.js.map +1 -0
  78. package/a2ui/dist/catalog/defineCatalog.d.ts +119 -0
  79. package/a2ui/dist/catalog/defineCatalog.js +196 -0
  80. package/a2ui/dist/catalog/defineCatalog.js.map +1 -0
  81. package/a2ui/dist/catalog/index.d.ts +20 -0
  82. package/a2ui/dist/catalog/index.js +26 -0
  83. package/a2ui/dist/catalog/index.js.map +1 -0
  84. package/a2ui/dist/catalog/utils/chart.d.ts +3 -0
  85. package/a2ui/dist/catalog/utils/chart.js +28 -0
  86. package/a2ui/dist/catalog/utils/chart.js.map +1 -0
  87. package/a2ui/dist/functions/index.d.ts +19 -0
  88. package/a2ui/dist/functions/index.js +87 -0
  89. package/a2ui/dist/functions/index.js.map +1 -0
  90. package/a2ui/dist/index.d.ts +11 -0
  91. package/a2ui/dist/index.js +35 -0
  92. package/a2ui/dist/index.js.map +1 -0
  93. package/a2ui/dist/react/A2UI.d.ts +77 -0
  94. package/a2ui/dist/react/A2UI.js +159 -0
  95. package/a2ui/dist/react/A2UI.js.map +1 -0
  96. package/a2ui/dist/react/A2UIProvider.d.ts +25 -0
  97. package/a2ui/dist/react/A2UIProvider.js +20 -0
  98. package/a2ui/dist/react/A2UIProvider.js.map +1 -0
  99. package/a2ui/dist/react/A2UIRenderer.d.ts +34 -0
  100. package/a2ui/dist/react/A2UIRenderer.js +161 -0
  101. package/a2ui/dist/react/A2UIRenderer.js.map +1 -0
  102. package/a2ui/dist/react/FormContext.d.ts +10 -0
  103. package/a2ui/dist/react/FormContext.js +12 -0
  104. package/a2ui/dist/react/FormContext.js.map +1 -0
  105. package/a2ui/dist/react/index.d.ts +8 -0
  106. package/a2ui/dist/react/index.js +23 -0
  107. package/a2ui/dist/react/index.js.map +1 -0
  108. package/a2ui/dist/react/useA2UIContext.d.ts +7 -0
  109. package/a2ui/dist/react/useA2UIContext.js +19 -0
  110. package/a2ui/dist/react/useA2UIContext.js.map +1 -0
  111. package/a2ui/dist/react/useAction.d.ts +9 -0
  112. package/a2ui/dist/react/useAction.js +38 -0
  113. package/a2ui/dist/react/useAction.js.map +1 -0
  114. package/a2ui/dist/react/useCatalog.d.ts +7 -0
  115. package/a2ui/dist/react/useCatalog.js +13 -0
  116. package/a2ui/dist/react/useCatalog.js.map +1 -0
  117. package/a2ui/dist/react/useChecks.d.ts +27 -0
  118. package/a2ui/dist/react/useChecks.js +76 -0
  119. package/a2ui/dist/react/useChecks.js.map +1 -0
  120. package/a2ui/dist/react/useDataBinding.d.ts +10 -0
  121. package/a2ui/dist/react/useDataBinding.js +175 -0
  122. package/a2ui/dist/react/useDataBinding.js.map +1 -0
  123. package/a2ui/dist/store/FormController.d.ts +23 -0
  124. package/a2ui/dist/store/FormController.js +40 -0
  125. package/a2ui/dist/store/FormController.js.map +1 -0
  126. package/a2ui/dist/store/FunctionRegistry.d.ts +47 -0
  127. package/a2ui/dist/store/FunctionRegistry.js +23 -0
  128. package/a2ui/dist/store/FunctionRegistry.js.map +1 -0
  129. package/a2ui/dist/store/MessageProcessor.d.ts +28 -0
  130. package/a2ui/dist/store/MessageProcessor.js +408 -0
  131. package/a2ui/dist/store/MessageProcessor.js.map +1 -0
  132. package/a2ui/dist/store/MessageStore.d.ts +38 -0
  133. package/a2ui/dist/store/MessageStore.js +37 -0
  134. package/a2ui/dist/store/MessageStore.js.map +1 -0
  135. package/a2ui/dist/store/Resource.d.ts +45 -0
  136. package/a2ui/dist/store/Resource.js +80 -0
  137. package/a2ui/dist/store/Resource.js.map +1 -0
  138. package/a2ui/dist/store/SignalStore.d.ts +10 -0
  139. package/a2ui/dist/store/SignalStore.js +29 -0
  140. package/a2ui/dist/store/SignalStore.js.map +1 -0
  141. package/a2ui/dist/store/index.d.ts +14 -0
  142. package/a2ui/dist/store/index.js +15 -0
  143. package/a2ui/dist/store/index.js.map +1 -0
  144. package/a2ui/dist/store/payloadNormalizer.d.ts +27 -0
  145. package/a2ui/dist/store/payloadNormalizer.js +179 -0
  146. package/a2ui/dist/store/payloadNormalizer.js.map +1 -0
  147. package/a2ui/dist/store/resolveFunctionCall.d.ts +18 -0
  148. package/a2ui/dist/store/resolveFunctionCall.js +131 -0
  149. package/a2ui/dist/store/resolveFunctionCall.js.map +1 -0
  150. package/a2ui/dist/store/types.d.ts +68 -0
  151. package/a2ui/dist/store/types.js +2 -0
  152. package/a2ui/dist/store/types.js.map +1 -0
  153. package/a2ui/dist/tsconfig.build.tsbuildinfo +1 -0
  154. package/a2ui/styles/catalog/Button.css +83 -0
  155. package/a2ui/styles/catalog/Card.css +49 -0
  156. package/a2ui/styles/catalog/CheckBox.css +46 -0
  157. package/a2ui/styles/catalog/Column.css +89 -0
  158. package/a2ui/styles/catalog/Divider.css +20 -0
  159. package/a2ui/styles/catalog/Icon.css +39 -0
  160. package/a2ui/styles/catalog/Image.css +54 -0
  161. package/a2ui/styles/catalog/LineChart.css +116 -0
  162. package/a2ui/styles/catalog/List.css +38 -0
  163. package/a2ui/styles/catalog/Modal.css +60 -0
  164. package/a2ui/styles/catalog/PieChart.css +109 -0
  165. package/a2ui/styles/catalog/RadioGroup.css +123 -0
  166. package/a2ui/styles/catalog/Row.css +83 -0
  167. package/a2ui/styles/catalog/Slider.css +96 -0
  168. package/a2ui/styles/catalog/Tabs.css +46 -0
  169. package/a2ui/styles/catalog/Text.css +121 -0
  170. package/a2ui/styles/catalog/TextField.css +48 -0
  171. package/a2ui/styles/theme.css +62 -0
  172. package/a2ui-catalog-extractor/README.md +605 -0
  173. package/a2ui-catalog-extractor/bin/a2ui-catalog-extractor.js +6 -0
  174. package/a2ui-catalog-extractor/dist/cli.d.ts +12 -0
  175. package/a2ui-catalog-extractor/dist/cli.js +171 -0
  176. package/a2ui-catalog-extractor/dist/cli.js.map +1 -0
  177. package/a2ui-catalog-extractor/dist/index.d.ts +140 -0
  178. package/a2ui-catalog-extractor/dist/index.js +755 -0
  179. package/a2ui-catalog-extractor/dist/index.js.map +1 -0
  180. package/a2ui-catalog-extractor/dist/tsconfig.build.tsbuildinfo +1 -0
  181. package/a2ui-catalog-extractor/skills/a2ui-catalog-extractor/SKILL.md +30 -0
  182. package/a2ui-prompt/README.md +65 -0
  183. package/a2ui-prompt/dist/index.d.ts +91 -0
  184. package/a2ui-prompt/dist/index.js +767 -0
  185. package/cli/README.md +88 -0
  186. package/cli/bin/cli.js +271 -0
  187. package/dist/index.d.ts +10 -0
  188. package/dist/index.js +10 -0
  189. package/dist/index.js.map +1 -0
  190. package/dist/tsconfig.build.tsbuildinfo +1 -0
  191. package/index.ts +114 -0
  192. package/openui/README.md +211 -0
  193. package/openui/dist/catalog/Action/index.d.ts +20 -0
  194. package/openui/dist/catalog/Action/index.js +23 -0
  195. package/openui/dist/catalog/Action/index.js.map +1 -0
  196. package/openui/dist/catalog/Button/index.d.ts +64 -0
  197. package/openui/dist/catalog/Button/index.js +75 -0
  198. package/openui/dist/catalog/Button/index.js.map +1 -0
  199. package/openui/dist/catalog/Card/index.d.ts +34 -0
  200. package/openui/dist/catalog/Card/index.js +69 -0
  201. package/openui/dist/catalog/Card/index.js.map +1 -0
  202. package/openui/dist/catalog/CardHeader/index.d.ts +5 -0
  203. package/openui/dist/catalog/CardHeader/index.js +18 -0
  204. package/openui/dist/catalog/CardHeader/index.js.map +1 -0
  205. package/openui/dist/catalog/Separator/index.d.ts +2 -0
  206. package/openui/dist/catalog/Separator/index.js +13 -0
  207. package/openui/dist/catalog/Separator/index.js.map +1 -0
  208. package/openui/dist/catalog/Stack/index.d.ts +29 -0
  209. package/openui/dist/catalog/Stack/index.js +61 -0
  210. package/openui/dist/catalog/Stack/index.js.map +1 -0
  211. package/openui/dist/catalog/Tag/index.d.ts +4 -0
  212. package/openui/dist/catalog/Tag/index.js +15 -0
  213. package/openui/dist/catalog/Tag/index.js.map +1 -0
  214. package/openui/dist/catalog/TextContent/index.d.ts +11 -0
  215. package/openui/dist/catalog/TextContent/index.js +33 -0
  216. package/openui/dist/catalog/TextContent/index.js.map +1 -0
  217. package/openui/dist/catalog/index.d.ts +7 -0
  218. package/openui/dist/catalog/index.js +11 -0
  219. package/openui/dist/catalog/index.js.map +1 -0
  220. package/openui/dist/catalog/utils.d.ts +2 -0
  221. package/openui/dist/catalog/utils.js +17 -0
  222. package/openui/dist/catalog/utils.js.map +1 -0
  223. package/openui/dist/core/context.d.ts +112 -0
  224. package/openui/dist/core/context.js +99 -0
  225. package/openui/dist/core/context.js.map +1 -0
  226. package/openui/dist/core/createLibrary.d.ts +10 -0
  227. package/openui/dist/core/createLibrary.js +36 -0
  228. package/openui/dist/core/createLibrary.js.map +1 -0
  229. package/openui/dist/core/hooks/index.d.ts +4 -0
  230. package/openui/dist/core/hooks/index.js +6 -0
  231. package/openui/dist/core/hooks/index.js.map +1 -0
  232. package/openui/dist/core/hooks/useFormValidation.d.ts +13 -0
  233. package/openui/dist/core/hooks/useFormValidation.js +76 -0
  234. package/openui/dist/core/hooks/useFormValidation.js.map +1 -0
  235. package/openui/dist/core/hooks/useOpenUIState.d.ts +33 -0
  236. package/openui/dist/core/hooks/useOpenUIState.js +413 -0
  237. package/openui/dist/core/hooks/useOpenUIState.js.map +1 -0
  238. package/openui/dist/core/hooks/useStateField.d.ts +2 -0
  239. package/openui/dist/core/hooks/useStateField.js +11 -0
  240. package/openui/dist/core/hooks/useStateField.js.map +1 -0
  241. package/openui/dist/core/index.d.ts +7 -0
  242. package/openui/dist/core/index.js +8 -0
  243. package/openui/dist/core/index.js.map +1 -0
  244. package/openui/dist/core/library.d.ts +20 -0
  245. package/openui/dist/core/library.js +13 -0
  246. package/openui/dist/core/library.js.map +1 -0
  247. package/openui/dist/core/renderer.css +271 -0
  248. package/openui/dist/core/renderer.d.ts +9 -0
  249. package/openui/dist/core/renderer.js +139 -0
  250. package/openui/dist/core/renderer.js.map +1 -0
  251. package/openui/dist/core/utils.d.ts +1 -0
  252. package/openui/dist/core/utils.js +76 -0
  253. package/openui/dist/core/utils.js.map +1 -0
  254. package/package.json +120 -0
@@ -0,0 +1,26 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ export { defineCatalog, defineFunction, mergeCatalogs, resolveCatalog, serializeCatalog, } from './defineCatalog.js';
5
+ // Per-component re-exports so consumers can pick exactly what they need.
6
+ // Each is an independently tree-shakeable ESM re-export — pulling `Text`
7
+ // does not drag `Button` into the bundle.
8
+ export { Button } from './Button/index.js';
9
+ export { Card } from './Card/index.js';
10
+ export { CheckBox } from './CheckBox/index.js';
11
+ export { LineChart } from './LineChart/index.js';
12
+ export { PieChart } from './PieChart/index.js';
13
+ export { Column } from './Column/index.js';
14
+ export { Divider } from './Divider/index.js';
15
+ export { Icon } from './Icon/index.js';
16
+ export { Image } from './Image/index.js';
17
+ export { List } from './List/index.js';
18
+ export { Modal } from './Modal/index.js';
19
+ export { RadioGroup } from './RadioGroup/index.js';
20
+ export { Row } from './Row/index.js';
21
+ export { Slider } from './Slider/index.js';
22
+ export { Tabs } from './Tabs/index.js';
23
+ export { Text } from './Text/index.js';
24
+ export { TextField } from './TextField/index.js';
25
+ export { DEFAULT_CHART_COLORS, escapeXml, formatValue } from './utils/chart.js';
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B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const DEFAULT_CHART_COLORS: readonly ["#0057d9", "#0a8f8f", "#8a5cf6", "#d92d20", "#2d6a4f", "#b26a00"];
2
+ export declare function escapeXml(value: string): string;
3
+ export declare function formatValue(value: number): string;
@@ -0,0 +1,28 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ export const DEFAULT_CHART_COLORS = [
5
+ '#0057d9',
6
+ '#0a8f8f',
7
+ '#8a5cf6',
8
+ '#d92d20',
9
+ '#2d6a4f',
10
+ '#b26a00',
11
+ ];
12
+ export function escapeXml(value) {
13
+ return value
14
+ .replace(/&/g, '&')
15
+ .replace(/</g, '&lt;')
16
+ .replace(/>/g, '&gt;')
17
+ .replace(/"/g, '&quot;')
18
+ .replace(/'/g, '&apos;');
19
+ }
20
+ export function formatValue(value) {
21
+ if (!Number.isFinite(value))
22
+ return '0';
23
+ const rounded = Math.abs(value) >= 1000
24
+ ? Math.round(value)
25
+ : Number(value.toFixed(1));
26
+ return String(rounded);
27
+ }
28
+ //# sourceMappingURL=chart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart.js","sourceRoot":"","sources":["../../../src/catalog/utils/chart.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;CACD,CAAC;AAEX,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,KAAK;SACT,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI;QACrC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACnB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;AACzB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { CatalogFunctionEntry } from '../catalog/defineCatalog.js';
2
+ /**
3
+ * The A2UI 0.9 basic-catalog function implementations packaged as
4
+ * `CatalogFunctionEntry`s, ready to spread into `<A2UI catalogs={[...]}>`.
5
+ * The impls themselves come from `@a2ui/web_core` so we stay aligned with
6
+ * the upstream spec for free.
7
+ *
8
+ * @example
9
+ * <A2UI catalogs={[Text, Button, ...basicFunctions]} ... />
10
+ */
11
+ export declare const basicFunctions: readonly CatalogFunctionEntry[];
12
+ /**
13
+ * Manual escape hatch for consumers who build their own renderer and don't
14
+ * go through `defineCatalog`. Registers every adapted basic-catalog impl
15
+ * into the shared `functionRegistry`. Calling more than once is harmless —
16
+ * later registrations override earlier ones, which is the intended override
17
+ * path.
18
+ */
19
+ export declare function registerBasicFunctions(): void;
@@ -0,0 +1,87 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { Catalog as A2UICoreCatalog, MessageProcessor as A2UICoreMessageProcessor, isSignal, } from '@a2ui/web_core/v0_9';
5
+ import { BASIC_FUNCTIONS } from '@a2ui/web_core/v0_9/basic_catalog';
6
+ import { defineFunction } from '../catalog/defineCatalog.js';
7
+ import { functionRegistry } from '../store/FunctionRegistry.js';
8
+ const BASIC_CATALOG_ID = 'https://a2ui.org/specification/v0_9/basic_catalog.json';
9
+ function createUpstreamContext(context) {
10
+ return {
11
+ resolveDynamicValue(value) {
12
+ return context?.resolveDynamicValue(value);
13
+ },
14
+ resolveSignal(value) {
15
+ return context?.resolveSignal(value);
16
+ },
17
+ set(path, value) {
18
+ context?.set(path, value);
19
+ },
20
+ path: context?.dataContextPath ?? '/',
21
+ };
22
+ }
23
+ /**
24
+ * Adapt an upstream `FunctionImplementation` (zod-typed args, returns a
25
+ * raw value OR a Preact Signal, takes a `DataContext`) into the simpler
26
+ * `(args) => unknown` shape the renderer's `executeFunctionCall` expects.
27
+ */
28
+ function adaptUpstreamImpl(impl) {
29
+ return (args, context) => {
30
+ const safeArgs = impl.schema.parse(args);
31
+ const result = impl.execute(safeArgs, createUpstreamContext(context));
32
+ if (isSignal(result))
33
+ return result.value;
34
+ return result;
35
+ };
36
+ }
37
+ const adaptedBasicFunctionImpls = BASIC_FUNCTIONS.map(fn => ({
38
+ name: fn.name,
39
+ impl: adaptUpstreamImpl(fn),
40
+ }));
41
+ function createBasicFunctionManifests() {
42
+ const upstreamCatalog = new A2UICoreCatalog(BASIC_CATALOG_ID, [], BASIC_FUNCTIONS);
43
+ const processor = new A2UICoreMessageProcessor([upstreamCatalog]);
44
+ const inlineCatalog = processor.getClientCapabilities({
45
+ includeInlineCatalogs: true,
46
+ })['v0.9'].inlineCatalogs?.[0];
47
+ const definitions = inlineCatalog?.functions ?? [];
48
+ return new Map(definitions.map(definition => {
49
+ const typedDefinition = definition;
50
+ return [
51
+ typedDefinition.name,
52
+ { [typedDefinition.name]: typedDefinition },
53
+ ];
54
+ }));
55
+ }
56
+ const basicFunctionManifests = createBasicFunctionManifests();
57
+ /**
58
+ * The A2UI 0.9 basic-catalog function implementations packaged as
59
+ * `CatalogFunctionEntry`s, ready to spread into `<A2UI catalogs={[...]}>`.
60
+ * The impls themselves come from `@a2ui/web_core` so we stay aligned with
61
+ * the upstream spec for free.
62
+ *
63
+ * @example
64
+ * <A2UI catalogs={[Text, Button, ...basicFunctions]} ... />
65
+ */
66
+ export const basicFunctions = adaptedBasicFunctionImpls
67
+ .map(({ name, impl }) => {
68
+ Object.defineProperty(impl, 'name', { value: name });
69
+ return defineFunction(impl, basicFunctionManifests.get(name));
70
+ });
71
+ /**
72
+ * Manual escape hatch for consumers who build their own renderer and don't
73
+ * go through `defineCatalog`. Registers every adapted basic-catalog impl
74
+ * into the shared `functionRegistry`. Calling more than once is harmless —
75
+ * later registrations override earlier ones, which is the intended override
76
+ * path.
77
+ */
78
+ export function registerBasicFunctions() {
79
+ for (const entry of adaptedBasicFunctionImpls) {
80
+ const definition = basicFunctionManifests.get(entry.name)?.[entry.name];
81
+ functionRegistry.register({
82
+ ...entry,
83
+ ...(definition ? { definition } : {}),
84
+ });
85
+ }
86
+ }
87
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EACL,OAAO,IAAI,eAAe,EAC1B,gBAAgB,IAAI,wBAAwB,EAC5C,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAM7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAMhE,MAAM,gBAAgB,GACpB,wDAAwD,CAAC;AAE3D,SAAS,qBAAqB,CAC5B,OAAwC;IAExC,OAAO;QACL,mBAAmB,CAAC,KAAc;YAChC,OAAO,OAAO,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC7C,CAAC;QACD,aAAa,CAAC,KAAc;YAC1B,OAAO,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;QACvC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AAC,EAAE;QAC1C,MAAM,eAAe,GAAG,UAAuC,CAAC;QAChE,OAAO;YACL,eAAe,CAAC,IAAI;YACpB,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,eAAe,EAAE;SAC5C,CAAC;IACJ,CAAC,CAAC,CAAC,CAAC;AACN,CAAC;AAED,MAAM,sBAAsB,GAAG,4BAA4B,EAAE,CAAC;AAE9D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GACzB,yBAAyB;KACtB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;IACtB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,OAAO,cAAc,CAAC,IAAI,EAAE,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AAChE,CAAC,CAAC,CAAC;AAEP;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB;IACpC,KAAK,MAAM,KAAK,IAAI,yBAAyB,EAAE,CAAC;QAC9C,MAAM,UAAU,GAAG,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxE,gBAAgB,CAAC,QAAQ,CAAC;YACxB,GAAG,KAAK;YACR,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACtC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ export { A2UI, NodeRenderer, useAction, useChecks, useDataBinding, useResolvedProps, } from './react/index.js';
2
+ export type { A2UIProps, ActionProps, CheckLike } from './react/index.js';
3
+ export { createMessageStore, MessageProcessor } from './store/index.js';
4
+ export type { A2UIClientEventMessage, ComponentInstance, GenericComponentProps, MessageStore, MessageStoreOptions, Resource, ResourceInfo, ServerToClientMessage, Surface, SurfaceId, UserActionPayload, } from './store/index.js';
5
+ export { createFallbackMessagesFromPlainText, createTextCardMessages, normalizePayloadToMessages, prepareMessagesForProcessing, } from './store/index.js';
6
+ export { executeFunctionCall, functionRegistry, FunctionRegistry, resolveDynamicValue, } from './store/index.js';
7
+ export type { FunctionCallContext, FunctionEntry, FunctionImpl, ResolveFunctionOptions, } from './store/index.js';
8
+ export { defineCatalog, defineFunction, mergeCatalogs, resolveCatalog, serializeCatalog, } from './catalog/index.js';
9
+ export type { Catalog, CatalogComponent, CatalogFunctionDefinition, CatalogFunctionEntry, CatalogInput, CatalogManifest, CatalogSchema, FunctionManifest, ResolvedCatalogEntry, SerializedCatalog, } from './catalog/index.js';
10
+ export { Button, Card, CheckBox, Column, Divider, Image, LineChart, PieChart, List, Modal, RadioGroup, Row, Slider, Tabs, Text, TextField, Icon, } from './catalog/index.js';
11
+ export { basicFunctions, registerBasicFunctions } from './functions/index.js';
@@ -0,0 +1,35 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ // React surface — `<A2UI>` is the all-in-one entry point. The hooks +
5
+ // `NodeRenderer` are the contract for custom catalog components.
6
+ export { A2UI, NodeRenderer, useAction, useChecks, useDataBinding, useResolvedProps, } from './react/index.js';
7
+ // Store — a pure raw-message buffer. The developer's IO module pushes
8
+ // protocol messages into it; `<A2UI>` subscribes and processes them.
9
+ // `MessageProcessor` is exposed for protocol-aware consumers who want to
10
+ // build their own renderer instead of using `<A2UI>`.
11
+ export { createMessageStore, MessageProcessor } from './store/index.js';
12
+ // Helpers for IO that returns free-form text instead of structured
13
+ // protocol messages.
14
+ export { createFallbackMessagesFromPlainText, createTextCardMessages, normalizePayloadToMessages, prepareMessagesForProcessing, } from './store/index.js';
15
+ // Function registry primitives. Consumers building a custom renderer reach
16
+ // the impls through these; `<A2UI>` consumers usually just spread
17
+ // `basicFunctions` into `catalogs`.
18
+ export { executeFunctionCall, functionRegistry, FunctionRegistry, resolveDynamicValue, } from './store/index.js';
19
+ // Catalog — declarative composition.
20
+ export { defineCatalog, defineFunction, mergeCatalogs, resolveCatalog, serializeCatalog, } from './catalog/index.js';
21
+ // Built-in components — re-exported individually so apps can pick exactly
22
+ // what they need:
23
+ //
24
+ // import { Text, Button } from '@lynx-js/genui/a2ui';
25
+ // <A2UI catalogs={[Text, Button]} ... />
26
+ //
27
+ // There is intentionally no all-in-one aggregate — see
28
+ // `packages/genui/a2ui/src/catalog/README.md`.
29
+ export { Button, Card, CheckBox, Column, Divider, Image, LineChart, PieChart, List, Modal, RadioGroup, Row, Slider, Tabs, Text, TextField, Icon, } from './catalog/index.js';
30
+ // A2UI 0.9 basic-catalog functions — registered + announced when spread
31
+ // into `<A2UI catalogs={[..., ...basicFunctions]}>`. Impls come from
32
+ // `@a2ui/web_core` (the upstream basic-catalog package), so the wire
33
+ // contract stays aligned with the spec for free.
34
+ export { basicFunctions, registerBasicFunctions } from './functions/index.js';
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,sEAAsE;AACtE,iEAAiE;AACjE,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,SAAS,EACT,cAAc,EACd,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAG1B,sEAAsE;AACtE,qEAAqE;AACrE,yEAAyE;AACzE,sDAAsD;AACtD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAcxE,mEAAmE;AACnE,qBAAqB;AACrB,OAAO,EACL,mCAAmC,EACnC,sBAAsB,EACtB,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,kBAAkB,CAAC;AAC1B,2EAA2E;AAC3E,kEAAkE;AAClE,oCAAoC;AACpC,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAQ1B,qCAAqC;AACrC,OAAO,EACL,aAAa,EACb,cAAc,EACd,aAAa,EACb,cAAc,EACd,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAc5B,0EAA0E;AAC1E,kBAAkB;AAClB,EAAE;AACF,wDAAwD;AACxD,2CAA2C;AAC3C,EAAE;AACF,uDAAuD;AACvD,+CAA+C;AAC/C,OAAO,EACL,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,OAAO,EACP,KAAK,EACL,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,UAAU,EACV,GAAG,EACH,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,IAAI,GACL,MAAM,oBAAoB,CAAC;AAE5B,wEAAwE;AACxE,qEAAqE;AACrE,qEAAqE;AACrE,iDAAiD;AACjD,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,77 @@
1
+ import type { ReactNode } from '@lynx-js/react';
2
+ import type { UnsupportedInfo } from './A2UIRenderer.js';
3
+ import type { CatalogInput } from '../catalog/defineCatalog.js';
4
+ import type { MessageStore } from '../store/MessageStore.js';
5
+ import type { UserActionPayload } from '../store/types.js';
6
+ export interface A2UIProps {
7
+ /**
8
+ * The raw-message buffer the developer pushes protocol messages into.
9
+ * `<A2UI>` subscribes via `useSyncExternalStore` and processes new
10
+ * messages incrementally.
11
+ *
12
+ * The internal `MessageProcessor` (surfaces, signals, resources) is
13
+ * created once per mount and is **not reset** if `messageStore` is
14
+ * later replaced with a different instance. Pass a `key` prop derived
15
+ * from the store's identity if you want a fresh session, e.g.
16
+ * `<A2UI key={turnId} messageStore={turnStore} ... />`.
17
+ */
18
+ messageStore: MessageStore;
19
+ /**
20
+ * Components the renderer is allowed to instantiate. Each item is either
21
+ * a bare component (name read from `displayName ?? name`) or a tuple
22
+ * `[component, manifest]` where the manifest is the JSON the extractor
23
+ * emits at `dist/catalog/<Name>/catalog.json`.
24
+ */
25
+ catalogs: readonly CatalogInput[];
26
+ /**
27
+ * Called when a user action fires inside the rendered tree (button
28
+ * tap, etc.). Forward to your agent and push the response messages
29
+ * back into the same `messageStore` to update the UI. Fire-and-forget;
30
+ * the renderer never awaits this.
31
+ */
32
+ onAction?: (action: UserActionPayload) => void;
33
+ /**
34
+ * Optional class name applied to the top-level `surface-${surfaceId}`
35
+ * view for the active surface. Use this when theme switching is
36
+ * expressed as surface-level classes.
37
+ */
38
+ className?: string;
39
+ /**
40
+ * Wrap each top-level surface so consumers can apply an outer theme
41
+ * shell, wrapper className, or additional styles.
42
+ */
43
+ wrapSurface?: (children: ReactNode, ctx: {
44
+ surfaceId: string;
45
+ }) => ReactNode;
46
+ /** Render before the first `beginRendering` arrives from the buffer. */
47
+ renderEmpty?: () => ReactNode;
48
+ /** Render while the active resource is pending. */
49
+ renderFallback?: () => ReactNode;
50
+ /** Render when the active resource fails. */
51
+ renderError?: (err: unknown) => ReactNode;
52
+ /** Render when unsupported data syntax or an unsupported component is encountered. */
53
+ renderUnsupported?: (info: UnsupportedInfo) => ReactNode;
54
+ }
55
+ /**
56
+ * The all-in-one A2UI component. Owns a `MessageProcessor` internally,
57
+ * processes raw messages from the buffer on each render, and renders
58
+ * the most recent `beginRendering` surface tree.
59
+ *
60
+ * @example
61
+ * const store = createMessageStore();
62
+ *
63
+ * // Developer's IO module pushes raw messages into the store.
64
+ * async function streamFromAgent(input: string) {
65
+ * for await (const msg of myAgent.stream(input)) store.push(msg);
66
+ * }
67
+ *
68
+ * <A2UI
69
+ * messageStore={store}
70
+ * catalogs={[Text, Button, [Card, cardManifest]]}
71
+ * onAction={(action) => { void streamFromAgent(serializeAction(action)); }}
72
+ * wrapSurface={(c) => <view className='luna-light'>{c}</view>}
73
+ * />
74
+ */
75
+ declare function A2UIImpl(props: A2UIProps): import('@lynx-js/react').ReactNode;
76
+ export declare const A2UI: import("react").MemoExoticComponent<typeof A2UIImpl>;
77
+ export {};
@@ -0,0 +1,159 @@
1
+ import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
2
+ // Copyright 2026 The Lynx Authors. All rights reserved.
3
+ // Licensed under the Apache License Version 2.0 that can be found in the
4
+ // LICENSE file in the root directory of this source tree.
5
+ import * as v0_9 from '@a2ui/web_core/v0_9';
6
+ import { memo, useEffect, useMemo, useReducer, useRef, useSyncExternalStore, } from '@lynx-js/react';
7
+ import { A2UIProvider } from './A2UIProvider.js';
8
+ import { A2UIRenderer } from './A2UIRenderer.js';
9
+ import { defineCatalog } from '../catalog/defineCatalog.js';
10
+ import { MessageProcessor } from '../store/MessageProcessor.js';
11
+ import { createResource } from '../store/Resource.js';
12
+ // Mark v0_9 used so the namespace import doesn't get pruned. Kept around so
13
+ // future enhancements (typed protocol message guards) don't need a fresh
14
+ // import diff.
15
+ void v0_9;
16
+ /**
17
+ * The all-in-one A2UI component. Owns a `MessageProcessor` internally,
18
+ * processes raw messages from the buffer on each render, and renders
19
+ * the most recent `beginRendering` surface tree.
20
+ *
21
+ * @example
22
+ * const store = createMessageStore();
23
+ *
24
+ * // Developer's IO module pushes raw messages into the store.
25
+ * async function streamFromAgent(input: string) {
26
+ * for await (const msg of myAgent.stream(input)) store.push(msg);
27
+ * }
28
+ *
29
+ * <A2UI
30
+ * messageStore={store}
31
+ * catalogs={[Text, Button, [Card, cardManifest]]}
32
+ * onAction={(action) => { void streamFromAgent(serializeAction(action)); }}
33
+ * wrapSurface={(c) => <view className='luna-light'>{c}</view>}
34
+ * />
35
+ */
36
+ function A2UIImpl(props) {
37
+ const { messageStore, catalogs, onAction, wrapSurface, renderEmpty, renderFallback, renderError, renderUnsupported, className, } = props;
38
+ // Keep the latest onAction in a ref so the once-mounted processor.onEvent
39
+ // listener always calls the up-to-date prop without re-binding.
40
+ const onActionRef = useRef(onAction);
41
+ useEffect(() => {
42
+ onActionRef.current = onAction;
43
+ }, [onAction]);
44
+ // Per-instance session. Created once; mutated as messages arrive.
45
+ const sessionRef = useRef(null);
46
+ sessionRef.current ??= {
47
+ processor: new MessageProcessor(),
48
+ resources: new Map(),
49
+ activeMessageId: null,
50
+ processedCount: 0,
51
+ };
52
+ const session = sessionRef.current;
53
+ // Counter used to force a re-render whenever the processor emits an
54
+ // update (new beginRendering, surfaceUpdate that mutated the active
55
+ // surface, deleteSurface). The processor's per-resource `onUpdate`
56
+ // already handles fine-grained updates inside the active surface;
57
+ // this is just for the activeResource pointer + first paint.
58
+ const [, forceUpdate] = useReducer((n) => n + 1, 0);
59
+ // Subscribe to the developer's raw buffer.
60
+ const messages = useSyncExternalStore(messageStore.subscribe, messageStore.getSnapshot, messageStore.getSnapshot);
61
+ // One-time wiring of processor → resource bookkeeping + onAction
62
+ // dispatch. The processor instance itself is stable across renders.
63
+ useEffect(() => {
64
+ const proc = session.processor;
65
+ const offUpdate = proc.onUpdate((data) => {
66
+ const { type, surfaceId, messageId } = data;
67
+ const surface = proc.getOrCreateSurface(surfaceId);
68
+ if (type === 'beginRendering') {
69
+ let resource = session.resources.get(messageId);
70
+ if (!resource) {
71
+ resource = createResource(messageId);
72
+ session.resources.set(messageId, resource);
73
+ }
74
+ resource.complete({ type: 'beginRendering', surfaceId, surface });
75
+ session.activeMessageId = messageId;
76
+ forceUpdate();
77
+ }
78
+ else if (type === 'surfaceUpdate') {
79
+ const updates = data.updates ?? [];
80
+ for (const update of updates) {
81
+ if (!update.id)
82
+ continue;
83
+ const r = surface.resources.get(update.id);
84
+ r?.complete({
85
+ type: 'surfaceUpdate',
86
+ surfaceId,
87
+ surface,
88
+ component: update,
89
+ });
90
+ }
91
+ }
92
+ else if (type === 'deleteSurface') {
93
+ const targetId = data.targetId
94
+ ?? surface.rootComponentId;
95
+ if (targetId && surface.resources.has(targetId)) {
96
+ surface.resources.get(targetId).complete({
97
+ type: 'deleteSurface',
98
+ surfaceId,
99
+ surface,
100
+ });
101
+ }
102
+ forceUpdate();
103
+ }
104
+ });
105
+ const offEvent = proc.onEvent(({ message, resolve }) => {
106
+ // Empty resolve — there is no "response" channel from the renderer
107
+ // back into the protocol. Responses arrive via the buffer.
108
+ resolve([]);
109
+ if (typeof message === 'object' && message !== null
110
+ && 'userAction' in message
111
+ && message.userAction) {
112
+ const action = message.userAction;
113
+ try {
114
+ onActionRef.current?.(action);
115
+ }
116
+ catch (e) {
117
+ console.error('[a2ui] onAction handler threw:', e);
118
+ }
119
+ }
120
+ });
121
+ return () => {
122
+ offUpdate();
123
+ offEvent();
124
+ };
125
+ }, [session]);
126
+ // Process any new messages in the buffer.
127
+ useEffect(() => {
128
+ if (messages.length === session.processedCount)
129
+ return;
130
+ const slice = messages.slice(session.processedCount);
131
+ session.processedCount = messages.length;
132
+ if (slice.length > 0) {
133
+ session.processor.processMessages(slice);
134
+ }
135
+ }, [messages, session]);
136
+ const catalog = useMemo(() => defineCatalog(catalogs), [catalogs]);
137
+ const activeResource = session.activeMessageId
138
+ ? (session.resources.get(session.activeMessageId) ?? null)
139
+ : null;
140
+ if (!activeResource) {
141
+ return renderEmpty?.() ?? null;
142
+ }
143
+ const rendererProps = {
144
+ resource: activeResource,
145
+ };
146
+ if (className !== undefined)
147
+ rendererProps.className = className;
148
+ if (wrapSurface)
149
+ rendererProps.wrapSurface = wrapSurface;
150
+ if (renderFallback)
151
+ rendererProps.renderFallback = renderFallback;
152
+ if (renderError)
153
+ rendererProps.renderError = renderError;
154
+ if (renderUnsupported)
155
+ rendererProps.renderUnsupported = renderUnsupported;
156
+ return (_jsx(A2UIProvider, { processor: session.processor, catalog: catalog, children: _jsx(A2UIRenderer, { ...rendererProps }) }));
157
+ }
158
+ export const A2UI = memo(A2UIImpl);
159
+ //# sourceMappingURL=A2UI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"A2UI.js","sourceRoot":"","sources":["../../src/react/A2UI.tsx"],"names":[],"mappings":";AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC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c;QAAE,aAAa,CAAC,cAAc,GAAG,cAAc,CAAC;IAClE,IAAI,WAAW;QAAE,aAAa,CAAC,WAAW,GAAG,WAAW,CAAC;IACzD,IAAI,iBAAiB;QAAE,aAAa,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAE3E,OAAO,CACL,KAAC,YAAY,IAAC,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,YAC1D,KAAC,YAAY,OAAK,aAAa,GAAI,GACtB,CAChB,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { ReactNode } from '@lynx-js/react';
2
+ import type { Catalog, CatalogComponent } from '../catalog/defineCatalog.js';
3
+ import type { MessageProcessor } from '../store/MessageProcessor.js';
4
+ /**
5
+ * The context value `<A2UI>` provides to its catalog-component subtree.
6
+ * Internal — neither the context nor the provider is part of the public
7
+ * API. Catalog components reach this value via `useAction`,
8
+ * `useDataBinding`, etc.
9
+ */
10
+ export interface A2UIInternalContext {
11
+ processor: MessageProcessor;
12
+ catalog: Catalog;
13
+ catalogMap: ReadonlyMap<string, CatalogComponent>;
14
+ }
15
+ export declare const A2UIContext: import("react").Context<A2UIInternalContext | null>;
16
+ interface ProviderProps {
17
+ processor: MessageProcessor;
18
+ catalog: Catalog;
19
+ children: ReactNode;
20
+ }
21
+ /**
22
+ * Internal provider mounted by `<A2UI>`. Not exported from the package.
23
+ */
24
+ export declare function A2UIProvider(props: ProviderProps): import('@lynx-js/react').ReactNode;
25
+ export {};
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
2
+ // Copyright 2026 The Lynx Authors. All rights reserved.
3
+ // Licensed under the Apache License Version 2.0 that can be found in the
4
+ // LICENSE file in the root directory of this source tree.
5
+ import { createContext, useMemo } from '@lynx-js/react';
6
+ import { resolveCatalog } from '../catalog/defineCatalog.js';
7
+ export const A2UIContext = createContext(null);
8
+ /**
9
+ * Internal provider mounted by `<A2UI>`. Not exported from the package.
10
+ */
11
+ export function A2UIProvider(props) {
12
+ const { processor, catalog, children } = props;
13
+ const value = useMemo(() => ({
14
+ processor,
15
+ catalog,
16
+ catalogMap: resolveCatalog(catalog),
17
+ }), [processor, catalog]);
18
+ return _jsx(A2UIContext.Provider, { value: value, children: children });
19
+ }
20
+ //# sourceMappingURL=A2UIProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"A2UIProvider.js","sourceRoot":"","sources":["../../src/react/A2UIProvider.tsx"],"names":[],"mappings":";AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAIxD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAe7D,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAA6B,IAAI,CAAC,CAAC;AAQ3E;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAoB;IAEpB,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC/C,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC;QACL,SAAS;QACT,OAAO;QACP,UAAU,EAAE,cAAc,CAAC,OAAO,CAAC;KACpC,CAAC,EACF,CAAC,SAAS,EAAE,OAAO,CAAC,CACrB,CAAC;IACF,OAAO,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAwB,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { ReactNode } from '@lynx-js/react';
2
+ import type { ComponentInstance, Resource, Surface } from '../store/types.js';
3
+ export interface UnsupportedInfo {
4
+ id: string;
5
+ tag: string;
6
+ kind: 'component' | 'syntax';
7
+ fields?: string[];
8
+ }
9
+ export interface A2UIRendererProps {
10
+ resource: Resource;
11
+ /** Optional class name applied to the top-level surface view. */
12
+ className?: string;
13
+ renderFallback?: () => ReactNode;
14
+ renderError?: (e: unknown) => ReactNode;
15
+ renderUnsupported?: (info: UnsupportedInfo) => ReactNode;
16
+ /**
17
+ * Wrap each top-level surface so consumers can apply an outer theme
18
+ * shell, wrapper className, or additional styles. The default does not
19
+ * wrap — that is intentional, the renderer is headless. Lynx-themed
20
+ * shells can use this together with `className` on the surface root.
21
+ */
22
+ wrapSurface?: (children: ReactNode, ctx: {
23
+ surfaceId: string;
24
+ }) => ReactNode;
25
+ }
26
+ declare function A2UIRendererImpl(props: A2UIRendererProps): import('@lynx-js/react').ReactNode;
27
+ export declare const A2UIRenderer: import("react").MemoExoticComponent<typeof A2UIRendererImpl>;
28
+ declare function NodeRendererImpl(props: {
29
+ component: ComponentInstance;
30
+ surface: Surface;
31
+ renderUnsupported?: ((info: UnsupportedInfo) => ReactNode) | undefined;
32
+ }): import('@lynx-js/react').ReactNode;
33
+ export declare const NodeRenderer: typeof NodeRendererImpl;
34
+ export {};