@copilotkit/a2ui-renderer 1.53.0 → 1.53.1-next.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 (181) hide show
  1. package/dist/A2UIViewer.d.cts +1 -1
  2. package/dist/A2UIViewer.d.mts +1 -1
  3. package/dist/a2ui-types.cjs +9 -0
  4. package/dist/a2ui-types.cjs.map +1 -0
  5. package/dist/a2ui-types.d.cts +9 -0
  6. package/dist/a2ui-types.d.cts.map +1 -0
  7. package/dist/a2ui-types.d.mts +9 -0
  8. package/dist/a2ui-types.d.mts.map +1 -0
  9. package/dist/a2ui-types.mjs +8 -0
  10. package/dist/a2ui-types.mjs.map +1 -0
  11. package/dist/index.cjs +74 -2
  12. package/dist/index.d.cts +35 -2
  13. package/dist/index.d.cts.map +1 -1
  14. package/dist/index.d.mts +35 -2
  15. package/dist/index.d.mts.map +1 -1
  16. package/dist/index.mjs +33 -2
  17. package/dist/index.umd.js +96 -127
  18. package/dist/index.umd.js.map +1 -1
  19. package/dist/react-renderer/components/content/AudioPlayer.d.cts +12 -0
  20. package/dist/react-renderer/components/content/AudioPlayer.d.cts.map +1 -0
  21. package/dist/react-renderer/components/content/AudioPlayer.d.mts +12 -0
  22. package/dist/react-renderer/components/content/AudioPlayer.d.mts.map +1 -0
  23. package/dist/react-renderer/components/content/Divider.d.cts +17 -0
  24. package/dist/react-renderer/components/content/Divider.d.cts.map +1 -0
  25. package/dist/react-renderer/components/content/Divider.d.mts +17 -0
  26. package/dist/react-renderer/components/content/Divider.d.mts.map +1 -0
  27. package/dist/react-renderer/components/content/Icon.d.cts +20 -0
  28. package/dist/react-renderer/components/content/Icon.d.cts.map +1 -0
  29. package/dist/react-renderer/components/content/Icon.d.mts +20 -0
  30. package/dist/react-renderer/components/content/Icon.d.mts.map +1 -0
  31. package/dist/react-renderer/components/content/Image.d.cts +15 -0
  32. package/dist/react-renderer/components/content/Image.d.cts.map +1 -0
  33. package/dist/react-renderer/components/content/Image.d.mts +15 -0
  34. package/dist/react-renderer/components/content/Image.d.mts.map +1 -0
  35. package/dist/react-renderer/components/content/Text.d.cts +32 -0
  36. package/dist/react-renderer/components/content/Text.d.cts.map +1 -0
  37. package/dist/react-renderer/components/content/Text.d.mts +32 -0
  38. package/dist/react-renderer/components/content/Text.d.mts.map +1 -0
  39. package/dist/react-renderer/components/content/Video.d.cts +14 -0
  40. package/dist/react-renderer/components/content/Video.d.cts.map +1 -0
  41. package/dist/react-renderer/components/content/Video.d.mts +14 -0
  42. package/dist/react-renderer/components/content/Video.d.mts.map +1 -0
  43. package/dist/react-renderer/components/interactive/Button.d.cts +15 -0
  44. package/dist/react-renderer/components/interactive/Button.d.cts.map +1 -0
  45. package/dist/react-renderer/components/interactive/Button.d.mts +15 -0
  46. package/dist/react-renderer/components/interactive/Button.d.mts.map +1 -0
  47. package/dist/react-renderer/components/interactive/CheckBox.d.cts +14 -0
  48. package/dist/react-renderer/components/interactive/CheckBox.d.cts.map +1 -0
  49. package/dist/react-renderer/components/interactive/CheckBox.d.mts +14 -0
  50. package/dist/react-renderer/components/interactive/CheckBox.d.mts.map +1 -0
  51. package/dist/react-renderer/components/interactive/DateTimeInput.d.cts +14 -0
  52. package/dist/react-renderer/components/interactive/DateTimeInput.d.cts.map +1 -0
  53. package/dist/react-renderer/components/interactive/DateTimeInput.d.mts +14 -0
  54. package/dist/react-renderer/components/interactive/DateTimeInput.d.mts.map +1 -0
  55. package/dist/react-renderer/components/interactive/MultipleChoice.d.cts +15 -0
  56. package/dist/react-renderer/components/interactive/MultipleChoice.d.cts.map +1 -0
  57. package/dist/react-renderer/components/interactive/MultipleChoice.d.mts +15 -0
  58. package/dist/react-renderer/components/interactive/MultipleChoice.d.mts.map +1 -0
  59. package/dist/react-renderer/components/interactive/Slider.d.cts +14 -0
  60. package/dist/react-renderer/components/interactive/Slider.d.cts.map +1 -0
  61. package/dist/react-renderer/components/interactive/Slider.d.mts +14 -0
  62. package/dist/react-renderer/components/interactive/Slider.d.mts.map +1 -0
  63. package/dist/react-renderer/components/interactive/TextField.d.cts +14 -0
  64. package/dist/react-renderer/components/interactive/TextField.d.cts.map +1 -0
  65. package/dist/react-renderer/components/interactive/TextField.d.mts +14 -0
  66. package/dist/react-renderer/components/interactive/TextField.d.mts.map +1 -0
  67. package/dist/react-renderer/components/layout/Card.d.cts +21 -0
  68. package/dist/react-renderer/components/layout/Card.d.cts.map +1 -0
  69. package/dist/react-renderer/components/layout/Card.d.mts +21 -0
  70. package/dist/react-renderer/components/layout/Card.d.mts.map +1 -0
  71. package/dist/react-renderer/components/layout/Column.d.cts +14 -0
  72. package/dist/react-renderer/components/layout/Column.d.cts.map +1 -0
  73. package/dist/react-renderer/components/layout/Column.d.mts +14 -0
  74. package/dist/react-renderer/components/layout/Column.d.mts.map +1 -0
  75. package/dist/react-renderer/components/layout/List.d.cts +14 -0
  76. package/dist/react-renderer/components/layout/List.d.cts.map +1 -0
  77. package/dist/react-renderer/components/layout/List.d.mts +14 -0
  78. package/dist/react-renderer/components/layout/List.d.mts.map +1 -0
  79. package/dist/react-renderer/components/layout/Modal.d.cts +19 -0
  80. package/dist/react-renderer/components/layout/Modal.d.cts.map +1 -0
  81. package/dist/react-renderer/components/layout/Modal.d.mts +19 -0
  82. package/dist/react-renderer/components/layout/Modal.d.mts.map +1 -0
  83. package/dist/react-renderer/components/layout/Row.d.cts +14 -0
  84. package/dist/react-renderer/components/layout/Row.d.cts.map +1 -0
  85. package/dist/react-renderer/components/layout/Row.d.mts +14 -0
  86. package/dist/react-renderer/components/layout/Row.d.mts.map +1 -0
  87. package/dist/react-renderer/components/layout/Tabs.d.cts +12 -0
  88. package/dist/react-renderer/components/layout/Tabs.d.cts.map +1 -0
  89. package/dist/react-renderer/components/layout/Tabs.d.mts +12 -0
  90. package/dist/react-renderer/components/layout/Tabs.d.mts.map +1 -0
  91. package/dist/react-renderer/core/A2UIProvider.cjs +35 -0
  92. package/dist/react-renderer/core/A2UIProvider.cjs.map +1 -1
  93. package/dist/react-renderer/core/A2UIProvider.d.cts +91 -0
  94. package/dist/react-renderer/core/A2UIProvider.d.cts.map +1 -0
  95. package/dist/react-renderer/core/A2UIProvider.d.mts +91 -0
  96. package/dist/react-renderer/core/A2UIProvider.d.mts.map +1 -0
  97. package/dist/react-renderer/core/A2UIProvider.mjs +33 -1
  98. package/dist/react-renderer/core/A2UIProvider.mjs.map +1 -1
  99. package/dist/react-renderer/core/A2UIRenderer.d.cts +40 -0
  100. package/dist/react-renderer/core/A2UIRenderer.d.cts.map +1 -0
  101. package/dist/react-renderer/core/A2UIRenderer.d.mts +40 -0
  102. package/dist/react-renderer/core/A2UIRenderer.d.mts.map +1 -0
  103. package/dist/react-renderer/core/A2UIViewer.cjs +11 -0
  104. package/dist/react-renderer/core/A2UIViewer.d.cts +16 -0
  105. package/dist/react-renderer/core/A2UIViewer.d.cts.map +1 -0
  106. package/dist/react-renderer/core/A2UIViewer.d.mts +16 -0
  107. package/dist/react-renderer/core/A2UIViewer.d.mts.map +1 -0
  108. package/dist/react-renderer/core/A2UIViewer.mjs +11 -0
  109. package/dist/react-renderer/core/ComponentNode.d.cts +29 -0
  110. package/dist/react-renderer/core/ComponentNode.d.cts.map +1 -0
  111. package/dist/react-renderer/core/ComponentNode.d.mts +29 -0
  112. package/dist/react-renderer/core/ComponentNode.d.mts.map +1 -0
  113. package/dist/react-renderer/core/store.d.cts +41 -0
  114. package/dist/react-renderer/core/store.d.cts.map +1 -0
  115. package/dist/react-renderer/core/store.d.mts +41 -0
  116. package/dist/react-renderer/core/store.d.mts.map +1 -0
  117. package/dist/react-renderer/hooks/useA2UI.d.cts +50 -0
  118. package/dist/react-renderer/hooks/useA2UI.d.cts.map +1 -0
  119. package/dist/react-renderer/hooks/useA2UI.d.mts +50 -0
  120. package/dist/react-renderer/hooks/useA2UI.d.mts.map +1 -0
  121. package/dist/react-renderer/hooks/useA2UIComponent.d.cts +56 -0
  122. package/dist/react-renderer/hooks/useA2UIComponent.d.cts.map +1 -0
  123. package/dist/react-renderer/hooks/useA2UIComponent.d.mts +56 -0
  124. package/dist/react-renderer/hooks/useA2UIComponent.d.mts.map +1 -0
  125. package/dist/react-renderer/index.cjs +31 -0
  126. package/dist/react-renderer/index.d.cts +32 -0
  127. package/dist/react-renderer/index.d.mts +32 -0
  128. package/dist/react-renderer/index.mjs +33 -0
  129. package/dist/react-renderer/lib/utils.d.cts +18 -0
  130. package/dist/react-renderer/lib/utils.d.cts.map +1 -0
  131. package/dist/react-renderer/lib/utils.d.mts +18 -0
  132. package/dist/react-renderer/lib/utils.d.mts.map +1 -0
  133. package/dist/react-renderer/registry/ComponentRegistry.d.cts +82 -0
  134. package/dist/react-renderer/registry/ComponentRegistry.d.cts.map +1 -0
  135. package/dist/react-renderer/registry/ComponentRegistry.d.mts +82 -0
  136. package/dist/react-renderer/registry/ComponentRegistry.d.mts.map +1 -0
  137. package/dist/react-renderer/registry/defaultCatalog.cjs +1 -0
  138. package/dist/react-renderer/registry/defaultCatalog.d.cts +17 -0
  139. package/dist/react-renderer/registry/defaultCatalog.d.cts.map +1 -0
  140. package/dist/react-renderer/registry/defaultCatalog.d.mts +17 -0
  141. package/dist/react-renderer/registry/defaultCatalog.d.mts.map +1 -0
  142. package/dist/react-renderer/registry/defaultCatalog.mjs +1 -1
  143. package/dist/react-renderer/styles/index.cjs +10 -0
  144. package/dist/react-renderer/styles/index.cjs.map +1 -1
  145. package/dist/react-renderer/styles/index.d.cts +14 -0
  146. package/dist/react-renderer/styles/index.d.cts.map +1 -0
  147. package/dist/react-renderer/styles/index.d.mts +26 -0
  148. package/dist/react-renderer/styles/index.d.mts.map +1 -0
  149. package/dist/react-renderer/styles/index.mjs +10 -1
  150. package/dist/react-renderer/styles/index.mjs.map +1 -1
  151. package/dist/react-renderer/theme/ThemeContext.cjs +9 -0
  152. package/dist/react-renderer/theme/ThemeContext.cjs.map +1 -1
  153. package/dist/react-renderer/theme/ThemeContext.d.cts +37 -0
  154. package/dist/react-renderer/theme/ThemeContext.d.cts.map +1 -0
  155. package/dist/react-renderer/theme/ThemeContext.d.mts +37 -0
  156. package/dist/react-renderer/theme/ThemeContext.d.mts.map +1 -0
  157. package/dist/react-renderer/theme/ThemeContext.mjs +9 -1
  158. package/dist/react-renderer/theme/ThemeContext.mjs.map +1 -1
  159. package/dist/react-renderer/theme/litTheme.cjs +1 -0
  160. package/dist/react-renderer/theme/litTheme.d.cts +12 -0
  161. package/dist/react-renderer/theme/litTheme.d.cts.map +1 -0
  162. package/dist/react-renderer/theme/litTheme.d.mts +12 -0
  163. package/dist/react-renderer/theme/litTheme.d.mts.map +1 -0
  164. package/dist/react-renderer/theme/litTheme.mjs +1 -1
  165. package/dist/react-renderer/theme/utils.d.cts +26 -0
  166. package/dist/react-renderer/theme/utils.d.cts.map +1 -0
  167. package/dist/react-renderer/theme/utils.d.mts +26 -0
  168. package/dist/react-renderer/theme/utils.d.mts.map +1 -0
  169. package/dist/react-renderer/types.d.cts +50 -0
  170. package/dist/react-renderer/types.d.cts.map +1 -0
  171. package/dist/react-renderer/types.d.mts +50 -0
  172. package/dist/react-renderer/types.d.mts.map +1 -0
  173. package/package.json +2 -3
  174. package/dist/A2UIMessageRenderer.cjs +0 -135
  175. package/dist/A2UIMessageRenderer.cjs.map +0 -1
  176. package/dist/A2UIMessageRenderer.d.cts +0 -11
  177. package/dist/A2UIMessageRenderer.d.cts.map +0 -1
  178. package/dist/A2UIMessageRenderer.d.mts +0 -11
  179. package/dist/A2UIMessageRenderer.d.mts.map +0 -1
  180. package/dist/A2UIMessageRenderer.mjs +0 -134
  181. package/dist/A2UIMessageRenderer.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"List.d.cts","names":[],"sources":["../../../../src/react-renderer/components/layout/List.tsx"],"mappings":";;;;;;;;AAYA;;cAAa,IAAA,EAAI,KAAA,CAAA,oBAAA,CAAA,kBAAA,CAAA,KAAA,CAAA,QAAA"}
@@ -0,0 +1,14 @@
1
+ import { A2UIComponentProps } from "../../types.mjs";
2
+ import * as react from "react";
3
+ import { Types } from "@a2ui/lit/0.8";
4
+
5
+ //#region src/react-renderer/components/layout/List.d.ts
6
+ /**
7
+ * List component - renders a scrollable list of items.
8
+ *
9
+ * Supports direction (vertical/horizontal) properties.
10
+ */
11
+ declare const List: react.NamedExoticComponent<A2UIComponentProps<Types.ListNode>>;
12
+ //#endregion
13
+ export { List };
14
+ //# sourceMappingURL=List.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"List.d.mts","names":[],"sources":["../../../../src/react-renderer/components/layout/List.tsx"],"mappings":";;;;;;;;AAYA;;cAAa,IAAA,EAAI,KAAA,CAAA,oBAAA,CAAA,kBAAA,CAAA,KAAA,CAAA,QAAA"}
@@ -0,0 +1,19 @@
1
+ import { A2UIComponentProps } from "../../types.cjs";
2
+ import * as react from "react";
3
+ import { Types } from "@a2ui/lit/0.8";
4
+
5
+ //#region src/react-renderer/components/layout/Modal.d.ts
6
+ /**
7
+ * Modal component - displays content in a dialog overlay.
8
+ *
9
+ * Matches Lit's rendering approach:
10
+ * - When closed: renders section with entry point child
11
+ * - When open: renders dialog with content child (entry point is replaced)
12
+ *
13
+ * The dialog is rendered in place (no portal) so it stays inside .a2ui-surface
14
+ * and CSS selectors work correctly. showModal() handles the top-layer overlay.
15
+ */
16
+ declare const Modal: react.NamedExoticComponent<A2UIComponentProps<Types.ModalNode>>;
17
+ //#endregion
18
+ export { Modal };
19
+ //# sourceMappingURL=Modal.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Modal.d.cts","names":[],"sources":["../../../../src/react-renderer/components/layout/Modal.tsx"],"mappings":";;;;;;;;AAiBA;;;;;;;cAAa,KAAA,EAAK,KAAA,CAAA,oBAAA,CAAA,kBAAA,CAAA,KAAA,CAAA,SAAA"}
@@ -0,0 +1,19 @@
1
+ import { A2UIComponentProps } from "../../types.mjs";
2
+ import * as react from "react";
3
+ import { Types } from "@a2ui/lit/0.8";
4
+
5
+ //#region src/react-renderer/components/layout/Modal.d.ts
6
+ /**
7
+ * Modal component - displays content in a dialog overlay.
8
+ *
9
+ * Matches Lit's rendering approach:
10
+ * - When closed: renders section with entry point child
11
+ * - When open: renders dialog with content child (entry point is replaced)
12
+ *
13
+ * The dialog is rendered in place (no portal) so it stays inside .a2ui-surface
14
+ * and CSS selectors work correctly. showModal() handles the top-layer overlay.
15
+ */
16
+ declare const Modal: react.NamedExoticComponent<A2UIComponentProps<Types.ModalNode>>;
17
+ //#endregion
18
+ export { Modal };
19
+ //# sourceMappingURL=Modal.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Modal.d.mts","names":[],"sources":["../../../../src/react-renderer/components/layout/Modal.tsx"],"mappings":";;;;;;;;AAiBA;;;;;;;cAAa,KAAA,EAAK,KAAA,CAAA,oBAAA,CAAA,kBAAA,CAAA,KAAA,CAAA,SAAA"}
@@ -0,0 +1,14 @@
1
+ import { A2UIComponentProps } from "../../types.cjs";
2
+ import * as react from "react";
3
+ import { Types } from "@a2ui/lit/0.8";
4
+
5
+ //#region src/react-renderer/components/layout/Row.d.ts
6
+ /**
7
+ * Row component - arranges children horizontally using flexbox.
8
+ *
9
+ * Supports distribution (justify-content) and alignment (align-items) properties.
10
+ */
11
+ declare const Row: react.NamedExoticComponent<A2UIComponentProps<Types.RowNode>>;
12
+ //#endregion
13
+ export { Row };
14
+ //# sourceMappingURL=Row.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Row.d.cts","names":[],"sources":["../../../../src/react-renderer/components/layout/Row.tsx"],"mappings":";;;;;;;;AAYA;;cAAa,GAAA,EAAG,KAAA,CAAA,oBAAA,CAAA,kBAAA,CAAA,KAAA,CAAA,OAAA"}
@@ -0,0 +1,14 @@
1
+ import { A2UIComponentProps } from "../../types.mjs";
2
+ import * as react from "react";
3
+ import { Types } from "@a2ui/lit/0.8";
4
+
5
+ //#region src/react-renderer/components/layout/Row.d.ts
6
+ /**
7
+ * Row component - arranges children horizontally using flexbox.
8
+ *
9
+ * Supports distribution (justify-content) and alignment (align-items) properties.
10
+ */
11
+ declare const Row: react.NamedExoticComponent<A2UIComponentProps<Types.RowNode>>;
12
+ //#endregion
13
+ export { Row };
14
+ //# sourceMappingURL=Row.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Row.d.mts","names":[],"sources":["../../../../src/react-renderer/components/layout/Row.tsx"],"mappings":";;;;;;;;AAYA;;cAAa,GAAA,EAAG,KAAA,CAAA,oBAAA,CAAA,kBAAA,CAAA,KAAA,CAAA,OAAA"}
@@ -0,0 +1,12 @@
1
+ import { A2UIComponentProps } from "../../types.cjs";
2
+ import * as react from "react";
3
+ import { Types } from "@a2ui/lit/0.8";
4
+
5
+ //#region src/react-renderer/components/layout/Tabs.d.ts
6
+ /**
7
+ * Tabs component - displays content in switchable tabs.
8
+ */
9
+ declare const Tabs: react.NamedExoticComponent<A2UIComponentProps<Types.TabsNode>>;
10
+ //#endregion
11
+ export { Tabs };
12
+ //# sourceMappingURL=Tabs.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tabs.d.cts","names":[],"sources":["../../../../src/react-renderer/components/layout/Tabs.tsx"],"mappings":";;;;;;;;cAca,IAAA,EAAI,KAAA,CAAA,oBAAA,CAAA,kBAAA,CAAA,KAAA,CAAA,QAAA"}
@@ -0,0 +1,12 @@
1
+ import { A2UIComponentProps } from "../../types.mjs";
2
+ import * as react from "react";
3
+ import { Types } from "@a2ui/lit/0.8";
4
+
5
+ //#region src/react-renderer/components/layout/Tabs.d.ts
6
+ /**
7
+ * Tabs component - displays content in switchable tabs.
8
+ */
9
+ declare const Tabs: react.NamedExoticComponent<A2UIComponentProps<Types.TabsNode>>;
10
+ //#endregion
11
+ export { Tabs };
12
+ //# sourceMappingURL=Tabs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tabs.d.mts","names":[],"sources":["../../../../src/react-renderer/components/layout/Tabs.tsx"],"mappings":";;;;;;;;cAca,IAAA,EAAI,KAAA,CAAA,oBAAA,CAAA,kBAAA,CAAA,KAAA,CAAA,QAAA"}
@@ -115,9 +115,44 @@ function useA2UIState() {
115
115
  if (!state) throw new Error("useA2UIState must be used within an A2UIProvider");
116
116
  return state;
117
117
  }
118
+ /**
119
+ * Hook to access the full A2UI context (actions + state).
120
+ * Components using this will re-render when state changes.
121
+ *
122
+ * @returns The A2UI context value
123
+ * @throws If used outside of an A2UIProvider
124
+ */
125
+ function useA2UIContext() {
126
+ const actions = useA2UIActions();
127
+ const state = useA2UIState();
128
+ return (0, react.useMemo)(() => ({
129
+ ...actions,
130
+ processor: null,
131
+ version: state.version,
132
+ onAction: null
133
+ }), [actions, state.version]);
134
+ }
135
+ /**
136
+ * @deprecated Use useA2UIContext instead. This alias exists for backward compatibility only.
137
+ */
138
+ const useA2UIStore = useA2UIContext;
139
+ /**
140
+ * @deprecated This selector pattern does not provide performance benefits with React Context.
141
+ * Components will re-render on any context change regardless of what you select.
142
+ * Use useA2UIContext() or useA2UI() directly instead.
143
+ *
144
+ * @param selector - Function to select a slice of state
145
+ * @returns The selected state
146
+ */
147
+ function useA2UIStoreSelector(selector) {
148
+ return selector(useA2UIContext());
149
+ }
118
150
 
119
151
  //#endregion
120
152
  exports.A2UIProvider = A2UIProvider;
121
153
  exports.useA2UIActions = useA2UIActions;
154
+ exports.useA2UIContext = useA2UIContext;
122
155
  exports.useA2UIState = useA2UIState;
156
+ exports.useA2UIStore = useA2UIStore;
157
+ exports.useA2UIStoreSelector = useA2UIStoreSelector;
123
158
  //# sourceMappingURL=A2UIProvider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"A2UIProvider.cjs","names":["Data","ThemeProvider"],"sources":["../../../src/react-renderer/core/A2UIProvider.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useRef,\n useState,\n useMemo,\n type ReactNode,\n} from \"react\";\nimport { Data, type Types } from \"@a2ui/lit/0.8\";\nimport type { A2UIContextValue, A2UIActions } from \"./store\";\nimport { ThemeProvider } from \"../theme/ThemeContext\";\nimport type { OnActionCallback } from \"../types\";\n\n/**\n * Context for stable actions (never changes reference, prevents re-renders).\n * Components that only need to dispatch actions or read data won't re-render.\n */\nconst A2UIActionsContext = createContext<A2UIActions | null>(null);\n\n/**\n * Context for reactive state (changes trigger re-renders).\n * Only components that need to react to state changes subscribe to this.\n */\nconst A2UIStateContext = createContext<{ version: number } | null>(null);\n\n/**\n * Props for the A2UIProvider component.\n */\nexport interface A2UIProviderProps {\n /** Callback invoked when a user action is dispatched (button click, etc.) */\n onAction?: OnActionCallback;\n /** Theme configuration. Falls back to default theme if not provided. */\n theme?: Types.Theme;\n /** Child components */\n children: ReactNode;\n}\n\n/**\n * Provider component that sets up the A2UI context for descendant components.\n *\n * This provider uses a two-context architecture for performance:\n * - A2UIActionsContext: Stable actions that never change (no re-renders)\n * - A2UIStateContext: Reactive state that triggers re-renders when needed\n *\n * @example\n * ```tsx\n * function App() {\n * const handleAction = async (message) => {\n * const response = await fetch('/api/a2ui', {\n * method: 'POST',\n * body: JSON.stringify(message)\n * });\n * const newMessages = await response.json();\n * };\n *\n * return (\n * <A2UIProvider onAction={handleAction}>\n * <A2UIRenderer surfaceId=\"main\" />\n * </A2UIProvider>\n * );\n * }\n * ```\n */\nexport function A2UIProvider({ onAction, theme, children }: A2UIProviderProps) {\n // Create message processor only once using ref\n const processorRef = useRef<Types.MessageProcessor | null>(null);\n if (!processorRef.current) {\n processorRef.current = Data.createSignalA2uiMessageProcessor();\n }\n const processor = processorRef.current;\n\n // Version counter for triggering re-renders\n const [version, setVersion] = useState(0);\n\n // Store onAction in a ref so callbacks always have the latest value\n const onActionRef = useRef<OnActionCallback | null>(onAction ?? null);\n onActionRef.current = onAction ?? null;\n\n // Create stable actions object once - stored in ref, never changes\n const actionsRef = useRef<A2UIActions | null>(null);\n if (!actionsRef.current) {\n actionsRef.current = {\n processMessages: (messages: Types.ServerToClientMessage[]) => {\n processor.processMessages(messages);\n setVersion((v) => v + 1);\n },\n\n setData: (\n node: Types.AnyComponentNode | null,\n path: string,\n value: Types.DataValue,\n surfaceId: string,\n ) => {\n processor.setData(node, path, value, surfaceId);\n setVersion((v) => v + 1);\n },\n\n dispatch: (message: Types.A2UIClientEventMessage) => {\n if (onActionRef.current) {\n onActionRef.current(message);\n }\n },\n\n clearSurfaces: () => {\n processor.clearSurfaces();\n setVersion((v) => v + 1);\n },\n\n getSurface: (surfaceId: string) => {\n return processor.getSurfaces().get(surfaceId);\n },\n\n getSurfaces: () => {\n return processor.getSurfaces();\n },\n\n getData: (\n node: Types.AnyComponentNode,\n path: string,\n surfaceId: string,\n ) => {\n return processor.getData(node, path, surfaceId);\n },\n\n resolvePath: (path: string, dataContextPath?: string) => {\n return processor.resolvePath(path, dataContextPath);\n },\n };\n }\n const actions = actionsRef.current;\n\n // State context value - only changes when version changes\n const stateValue = useMemo(() => ({ version }), [version]);\n\n return (\n <A2UIActionsContext.Provider value={actions}>\n <A2UIStateContext.Provider value={stateValue}>\n <ThemeProvider theme={theme}>{children}</ThemeProvider>\n </A2UIStateContext.Provider>\n </A2UIActionsContext.Provider>\n );\n}\n\n/**\n * Hook to access stable A2UI actions (won't cause re-renders).\n * Use this when you only need to dispatch actions or read data.\n *\n * @returns Stable actions object\n * @throws If used outside of an A2UIProvider\n */\nexport function useA2UIActions(): A2UIActions {\n const actions = useContext(A2UIActionsContext);\n if (!actions) {\n throw new Error(\"useA2UIActions must be used within an A2UIProvider\");\n }\n return actions;\n}\n\n/**\n * Hook to subscribe to A2UI state changes.\n * Components using this will re-render when state changes.\n *\n * @returns Current version number\n * @throws If used outside of an A2UIProvider\n */\nexport function useA2UIState(): { version: number } {\n const state = useContext(A2UIStateContext);\n if (!state) {\n throw new Error(\"useA2UIState must be used within an A2UIProvider\");\n }\n return state;\n}\n\n/**\n * Hook to access the full A2UI context (actions + state).\n * Components using this will re-render when state changes.\n *\n * @returns The A2UI context value\n * @throws If used outside of an A2UIProvider\n */\nexport function useA2UIContext(): A2UIContextValue {\n const actions = useA2UIActions();\n const state = useA2UIState();\n\n // Memoize combined value - only changes when state changes\n // Actions are stable, so this only re-creates when version changes\n return useMemo(\n () => ({\n ...actions,\n processor: null as unknown as Types.MessageProcessor, // Not exposed directly\n version: state.version,\n onAction: null, // Use dispatch instead\n }),\n [actions, state.version],\n );\n}\n\n/**\n * @deprecated Use useA2UIContext instead. This alias exists for backward compatibility only.\n */\nexport const useA2UIStore = useA2UIContext;\n\n/**\n * @deprecated This selector pattern does not provide performance benefits with React Context.\n * Components will re-render on any context change regardless of what you select.\n * Use useA2UIContext() or useA2UI() directly instead.\n *\n * @param selector - Function to select a slice of state\n * @returns The selected state\n */\nexport function useA2UIStoreSelector<T>(\n selector: (state: A2UIContextValue) => T,\n): T {\n const context = useA2UIContext();\n return selector(context);\n}\n"],"mappings":";;;;;;;;;;;AAiBA,MAAM,8CAAuD,KAAK;;;;;AAMlE,MAAM,4CAA6D,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCxE,SAAgB,aAAa,EAAE,UAAU,OAAO,YAA+B;CAE7E,MAAM,iCAAqD,KAAK;AAChE,KAAI,CAAC,aAAa,QAChB,cAAa,UAAUA,mBAAK,kCAAkC;CAEhE,MAAM,YAAY,aAAa;CAG/B,MAAM,CAAC,SAAS,kCAAuB,EAAE;CAGzC,MAAM,gCAA8C,YAAY,KAAK;AACrE,aAAY,UAAU,YAAY;CAGlC,MAAM,+BAAwC,KAAK;AACnD,KAAI,CAAC,WAAW,QACd,YAAW,UAAU;EACnB,kBAAkB,aAA4C;AAC5D,aAAU,gBAAgB,SAAS;AACnC,eAAY,MAAM,IAAI,EAAE;;EAG1B,UACE,MACA,MACA,OACA,cACG;AACH,aAAU,QAAQ,MAAM,MAAM,OAAO,UAAU;AAC/C,eAAY,MAAM,IAAI,EAAE;;EAG1B,WAAW,YAA0C;AACnD,OAAI,YAAY,QACd,aAAY,QAAQ,QAAQ;;EAIhC,qBAAqB;AACnB,aAAU,eAAe;AACzB,eAAY,MAAM,IAAI,EAAE;;EAG1B,aAAa,cAAsB;AACjC,UAAO,UAAU,aAAa,CAAC,IAAI,UAAU;;EAG/C,mBAAmB;AACjB,UAAO,UAAU,aAAa;;EAGhC,UACE,MACA,MACA,cACG;AACH,UAAO,UAAU,QAAQ,MAAM,MAAM,UAAU;;EAGjD,cAAc,MAAc,oBAA6B;AACvD,UAAO,UAAU,YAAY,MAAM,gBAAgB;;EAEtD;CAEH,MAAM,UAAU,WAAW;CAG3B,MAAM,uCAA4B,EAAE,SAAS,GAAG,CAAC,QAAQ,CAAC;AAE1D,QACE,2CAAC,mBAAmB;EAAS,OAAO;YAClC,2CAAC,iBAAiB;GAAS,OAAO;aAChC,2CAACC;IAAqB;IAAQ;KAAyB;IAC7B;GACA;;;;;;;;;AAWlC,SAAgB,iBAA8B;CAC5C,MAAM,gCAAqB,mBAAmB;AAC9C,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,qDAAqD;AAEvE,QAAO;;;;;;;;;AAUT,SAAgB,eAAoC;CAClD,MAAM,8BAAmB,iBAAiB;AAC1C,KAAI,CAAC,MACH,OAAM,IAAI,MAAM,mDAAmD;AAErE,QAAO"}
1
+ {"version":3,"file":"A2UIProvider.cjs","names":["Data","ThemeProvider"],"sources":["../../../src/react-renderer/core/A2UIProvider.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useRef,\n useState,\n useMemo,\n type ReactNode,\n} from \"react\";\nimport { Data, type Types } from \"@a2ui/lit/0.8\";\nimport type { A2UIContextValue, A2UIActions } from \"./store\";\nimport { ThemeProvider } from \"../theme/ThemeContext\";\nimport type { OnActionCallback } from \"../types\";\n\n/**\n * Context for stable actions (never changes reference, prevents re-renders).\n * Components that only need to dispatch actions or read data won't re-render.\n */\nconst A2UIActionsContext = createContext<A2UIActions | null>(null);\n\n/**\n * Context for reactive state (changes trigger re-renders).\n * Only components that need to react to state changes subscribe to this.\n */\nconst A2UIStateContext = createContext<{ version: number } | null>(null);\n\n/**\n * Props for the A2UIProvider component.\n */\nexport interface A2UIProviderProps {\n /** Callback invoked when a user action is dispatched (button click, etc.) */\n onAction?: OnActionCallback;\n /** Theme configuration. Falls back to default theme if not provided. */\n theme?: Types.Theme;\n /** Child components */\n children: ReactNode;\n}\n\n/**\n * Provider component that sets up the A2UI context for descendant components.\n *\n * This provider uses a two-context architecture for performance:\n * - A2UIActionsContext: Stable actions that never change (no re-renders)\n * - A2UIStateContext: Reactive state that triggers re-renders when needed\n *\n * @example\n * ```tsx\n * function App() {\n * const handleAction = async (message) => {\n * const response = await fetch('/api/a2ui', {\n * method: 'POST',\n * body: JSON.stringify(message)\n * });\n * const newMessages = await response.json();\n * };\n *\n * return (\n * <A2UIProvider onAction={handleAction}>\n * <A2UIRenderer surfaceId=\"main\" />\n * </A2UIProvider>\n * );\n * }\n * ```\n */\nexport function A2UIProvider({ onAction, theme, children }: A2UIProviderProps) {\n // Create message processor only once using ref\n const processorRef = useRef<Types.MessageProcessor | null>(null);\n if (!processorRef.current) {\n processorRef.current = Data.createSignalA2uiMessageProcessor();\n }\n const processor = processorRef.current;\n\n // Version counter for triggering re-renders\n const [version, setVersion] = useState(0);\n\n // Store onAction in a ref so callbacks always have the latest value\n const onActionRef = useRef<OnActionCallback | null>(onAction ?? null);\n onActionRef.current = onAction ?? null;\n\n // Create stable actions object once - stored in ref, never changes\n const actionsRef = useRef<A2UIActions | null>(null);\n if (!actionsRef.current) {\n actionsRef.current = {\n processMessages: (messages: Types.ServerToClientMessage[]) => {\n processor.processMessages(messages);\n setVersion((v) => v + 1);\n },\n\n setData: (\n node: Types.AnyComponentNode | null,\n path: string,\n value: Types.DataValue,\n surfaceId: string,\n ) => {\n processor.setData(node, path, value, surfaceId);\n setVersion((v) => v + 1);\n },\n\n dispatch: (message: Types.A2UIClientEventMessage) => {\n if (onActionRef.current) {\n onActionRef.current(message);\n }\n },\n\n clearSurfaces: () => {\n processor.clearSurfaces();\n setVersion((v) => v + 1);\n },\n\n getSurface: (surfaceId: string) => {\n return processor.getSurfaces().get(surfaceId);\n },\n\n getSurfaces: () => {\n return processor.getSurfaces();\n },\n\n getData: (\n node: Types.AnyComponentNode,\n path: string,\n surfaceId: string,\n ) => {\n return processor.getData(node, path, surfaceId);\n },\n\n resolvePath: (path: string, dataContextPath?: string) => {\n return processor.resolvePath(path, dataContextPath);\n },\n };\n }\n const actions = actionsRef.current;\n\n // State context value - only changes when version changes\n const stateValue = useMemo(() => ({ version }), [version]);\n\n return (\n <A2UIActionsContext.Provider value={actions}>\n <A2UIStateContext.Provider value={stateValue}>\n <ThemeProvider theme={theme}>{children}</ThemeProvider>\n </A2UIStateContext.Provider>\n </A2UIActionsContext.Provider>\n );\n}\n\n/**\n * Hook to access stable A2UI actions (won't cause re-renders).\n * Use this when you only need to dispatch actions or read data.\n *\n * @returns Stable actions object\n * @throws If used outside of an A2UIProvider\n */\nexport function useA2UIActions(): A2UIActions {\n const actions = useContext(A2UIActionsContext);\n if (!actions) {\n throw new Error(\"useA2UIActions must be used within an A2UIProvider\");\n }\n return actions;\n}\n\n/**\n * Hook to subscribe to A2UI state changes.\n * Components using this will re-render when state changes.\n *\n * @returns Current version number\n * @throws If used outside of an A2UIProvider\n */\nexport function useA2UIState(): { version: number } {\n const state = useContext(A2UIStateContext);\n if (!state) {\n throw new Error(\"useA2UIState must be used within an A2UIProvider\");\n }\n return state;\n}\n\n/**\n * Hook to access the full A2UI context (actions + state).\n * Components using this will re-render when state changes.\n *\n * @returns The A2UI context value\n * @throws If used outside of an A2UIProvider\n */\nexport function useA2UIContext(): A2UIContextValue {\n const actions = useA2UIActions();\n const state = useA2UIState();\n\n // Memoize combined value - only changes when state changes\n // Actions are stable, so this only re-creates when version changes\n return useMemo(\n () => ({\n ...actions,\n processor: null as unknown as Types.MessageProcessor, // Not exposed directly\n version: state.version,\n onAction: null, // Use dispatch instead\n }),\n [actions, state.version],\n );\n}\n\n/**\n * @deprecated Use useA2UIContext instead. This alias exists for backward compatibility only.\n */\nexport const useA2UIStore = useA2UIContext;\n\n/**\n * @deprecated This selector pattern does not provide performance benefits with React Context.\n * Components will re-render on any context change regardless of what you select.\n * Use useA2UIContext() or useA2UI() directly instead.\n *\n * @param selector - Function to select a slice of state\n * @returns The selected state\n */\nexport function useA2UIStoreSelector<T>(\n selector: (state: A2UIContextValue) => T,\n): T {\n const context = useA2UIContext();\n return selector(context);\n}\n"],"mappings":";;;;;;;;;;;AAiBA,MAAM,8CAAuD,KAAK;;;;;AAMlE,MAAM,4CAA6D,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCxE,SAAgB,aAAa,EAAE,UAAU,OAAO,YAA+B;CAE7E,MAAM,iCAAqD,KAAK;AAChE,KAAI,CAAC,aAAa,QAChB,cAAa,UAAUA,mBAAK,kCAAkC;CAEhE,MAAM,YAAY,aAAa;CAG/B,MAAM,CAAC,SAAS,kCAAuB,EAAE;CAGzC,MAAM,gCAA8C,YAAY,KAAK;AACrE,aAAY,UAAU,YAAY;CAGlC,MAAM,+BAAwC,KAAK;AACnD,KAAI,CAAC,WAAW,QACd,YAAW,UAAU;EACnB,kBAAkB,aAA4C;AAC5D,aAAU,gBAAgB,SAAS;AACnC,eAAY,MAAM,IAAI,EAAE;;EAG1B,UACE,MACA,MACA,OACA,cACG;AACH,aAAU,QAAQ,MAAM,MAAM,OAAO,UAAU;AAC/C,eAAY,MAAM,IAAI,EAAE;;EAG1B,WAAW,YAA0C;AACnD,OAAI,YAAY,QACd,aAAY,QAAQ,QAAQ;;EAIhC,qBAAqB;AACnB,aAAU,eAAe;AACzB,eAAY,MAAM,IAAI,EAAE;;EAG1B,aAAa,cAAsB;AACjC,UAAO,UAAU,aAAa,CAAC,IAAI,UAAU;;EAG/C,mBAAmB;AACjB,UAAO,UAAU,aAAa;;EAGhC,UACE,MACA,MACA,cACG;AACH,UAAO,UAAU,QAAQ,MAAM,MAAM,UAAU;;EAGjD,cAAc,MAAc,oBAA6B;AACvD,UAAO,UAAU,YAAY,MAAM,gBAAgB;;EAEtD;CAEH,MAAM,UAAU,WAAW;CAG3B,MAAM,uCAA4B,EAAE,SAAS,GAAG,CAAC,QAAQ,CAAC;AAE1D,QACE,2CAAC,mBAAmB;EAAS,OAAO;YAClC,2CAAC,iBAAiB;GAAS,OAAO;aAChC,2CAACC;IAAqB;IAAQ;KAAyB;IAC7B;GACA;;;;;;;;;AAWlC,SAAgB,iBAA8B;CAC5C,MAAM,gCAAqB,mBAAmB;AAC9C,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,qDAAqD;AAEvE,QAAO;;;;;;;;;AAUT,SAAgB,eAAoC;CAClD,MAAM,8BAAmB,iBAAiB;AAC1C,KAAI,CAAC,MACH,OAAM,IAAI,MAAM,mDAAmD;AAErE,QAAO;;;;;;;;;AAUT,SAAgB,iBAAmC;CACjD,MAAM,UAAU,gBAAgB;CAChC,MAAM,QAAQ,cAAc;AAI5B,kCACS;EACL,GAAG;EACH,WAAW;EACX,SAAS,MAAM;EACf,UAAU;EACX,GACD,CAAC,SAAS,MAAM,QAAQ,CACzB;;;;;AAMH,MAAa,eAAe;;;;;;;;;AAU5B,SAAgB,qBACd,UACG;AAEH,QAAO,SADS,gBAAgB,CACR"}
@@ -0,0 +1,91 @@
1
+ import { OnActionCallback } from "../types.cjs";
2
+ import { A2UIActions, A2UIContextValue } from "./store.cjs";
3
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
4
+ import { ReactNode } from "react";
5
+ import { Types } from "@a2ui/lit/0.8";
6
+
7
+ //#region src/react-renderer/core/A2UIProvider.d.ts
8
+ /**
9
+ * Props for the A2UIProvider component.
10
+ */
11
+ interface A2UIProviderProps {
12
+ /** Callback invoked when a user action is dispatched (button click, etc.) */
13
+ onAction?: OnActionCallback;
14
+ /** Theme configuration. Falls back to default theme if not provided. */
15
+ theme?: Types.Theme;
16
+ /** Child components */
17
+ children: ReactNode;
18
+ }
19
+ /**
20
+ * Provider component that sets up the A2UI context for descendant components.
21
+ *
22
+ * This provider uses a two-context architecture for performance:
23
+ * - A2UIActionsContext: Stable actions that never change (no re-renders)
24
+ * - A2UIStateContext: Reactive state that triggers re-renders when needed
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * function App() {
29
+ * const handleAction = async (message) => {
30
+ * const response = await fetch('/api/a2ui', {
31
+ * method: 'POST',
32
+ * body: JSON.stringify(message)
33
+ * });
34
+ * const newMessages = await response.json();
35
+ * };
36
+ *
37
+ * return (
38
+ * <A2UIProvider onAction={handleAction}>
39
+ * <A2UIRenderer surfaceId="main" />
40
+ * </A2UIProvider>
41
+ * );
42
+ * }
43
+ * ```
44
+ */
45
+ declare function A2UIProvider({
46
+ onAction,
47
+ theme,
48
+ children
49
+ }: A2UIProviderProps): react_jsx_runtime0.JSX.Element;
50
+ /**
51
+ * Hook to access stable A2UI actions (won't cause re-renders).
52
+ * Use this when you only need to dispatch actions or read data.
53
+ *
54
+ * @returns Stable actions object
55
+ * @throws If used outside of an A2UIProvider
56
+ */
57
+ declare function useA2UIActions(): A2UIActions;
58
+ /**
59
+ * Hook to subscribe to A2UI state changes.
60
+ * Components using this will re-render when state changes.
61
+ *
62
+ * @returns Current version number
63
+ * @throws If used outside of an A2UIProvider
64
+ */
65
+ declare function useA2UIState(): {
66
+ version: number;
67
+ };
68
+ /**
69
+ * Hook to access the full A2UI context (actions + state).
70
+ * Components using this will re-render when state changes.
71
+ *
72
+ * @returns The A2UI context value
73
+ * @throws If used outside of an A2UIProvider
74
+ */
75
+ declare function useA2UIContext(): A2UIContextValue;
76
+ /**
77
+ * @deprecated Use useA2UIContext instead. This alias exists for backward compatibility only.
78
+ */
79
+ declare const useA2UIStore: typeof useA2UIContext;
80
+ /**
81
+ * @deprecated This selector pattern does not provide performance benefits with React Context.
82
+ * Components will re-render on any context change regardless of what you select.
83
+ * Use useA2UIContext() or useA2UI() directly instead.
84
+ *
85
+ * @param selector - Function to select a slice of state
86
+ * @returns The selected state
87
+ */
88
+ declare function useA2UIStoreSelector<T>(selector: (state: A2UIContextValue) => T): T;
89
+ //#endregion
90
+ export { A2UIProvider, A2UIProviderProps, useA2UIActions, useA2UIContext, useA2UIState, useA2UIStore, useA2UIStoreSelector };
91
+ //# sourceMappingURL=A2UIProvider.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"A2UIProvider.d.cts","names":[],"sources":["../../../src/react-renderer/core/A2UIProvider.tsx"],"mappings":";;;;;;;;;;UA4BiB,iBAAA;EAAiB;EAEhC,QAAA,GAAW,gBAAA;EAAA;EAEX,KAAA,GAAQ,KAAA,CAAM,KAAA;EAEJ;EAAV,QAAA,EAAU,SAAA;AAAA;;;;;;;;;;AA6BZ;;;;;;;;;;;;;;;;;iBAAgB,YAAA,CAAA;EAAe,QAAA;EAAU,KAAA;EAAO;AAAA,GAAY,iBAAA,GAAiB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;AAuF7E;;;;iBAAgB,cAAA,CAAA,GAAkB,WAAA;AAelC;;;;;AAeA;;AAfA,iBAAgB,YAAA,CAAA;EAAkB,OAAA;AAAA;AAmClC;;;;;AAUA;;AAVA,iBApBgB,cAAA,CAAA,GAAkB,gBAAA;;;;cAoBrB,YAAA,SAAY,cAAA;;;;;;;;;iBAUT,oBAAA,GAAA,CACd,QAAA,GAAW,KAAA,EAAO,gBAAA,KAAqB,CAAA,GACtC,CAAA"}
@@ -0,0 +1,91 @@
1
+ import { OnActionCallback } from "../types.mjs";
2
+ import { A2UIActions, A2UIContextValue } from "./store.mjs";
3
+ import { ReactNode } from "react";
4
+ import { Types } from "@a2ui/lit/0.8";
5
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
6
+
7
+ //#region src/react-renderer/core/A2UIProvider.d.ts
8
+ /**
9
+ * Props for the A2UIProvider component.
10
+ */
11
+ interface A2UIProviderProps {
12
+ /** Callback invoked when a user action is dispatched (button click, etc.) */
13
+ onAction?: OnActionCallback;
14
+ /** Theme configuration. Falls back to default theme if not provided. */
15
+ theme?: Types.Theme;
16
+ /** Child components */
17
+ children: ReactNode;
18
+ }
19
+ /**
20
+ * Provider component that sets up the A2UI context for descendant components.
21
+ *
22
+ * This provider uses a two-context architecture for performance:
23
+ * - A2UIActionsContext: Stable actions that never change (no re-renders)
24
+ * - A2UIStateContext: Reactive state that triggers re-renders when needed
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * function App() {
29
+ * const handleAction = async (message) => {
30
+ * const response = await fetch('/api/a2ui', {
31
+ * method: 'POST',
32
+ * body: JSON.stringify(message)
33
+ * });
34
+ * const newMessages = await response.json();
35
+ * };
36
+ *
37
+ * return (
38
+ * <A2UIProvider onAction={handleAction}>
39
+ * <A2UIRenderer surfaceId="main" />
40
+ * </A2UIProvider>
41
+ * );
42
+ * }
43
+ * ```
44
+ */
45
+ declare function A2UIProvider({
46
+ onAction,
47
+ theme,
48
+ children
49
+ }: A2UIProviderProps): react_jsx_runtime0.JSX.Element;
50
+ /**
51
+ * Hook to access stable A2UI actions (won't cause re-renders).
52
+ * Use this when you only need to dispatch actions or read data.
53
+ *
54
+ * @returns Stable actions object
55
+ * @throws If used outside of an A2UIProvider
56
+ */
57
+ declare function useA2UIActions(): A2UIActions;
58
+ /**
59
+ * Hook to subscribe to A2UI state changes.
60
+ * Components using this will re-render when state changes.
61
+ *
62
+ * @returns Current version number
63
+ * @throws If used outside of an A2UIProvider
64
+ */
65
+ declare function useA2UIState(): {
66
+ version: number;
67
+ };
68
+ /**
69
+ * Hook to access the full A2UI context (actions + state).
70
+ * Components using this will re-render when state changes.
71
+ *
72
+ * @returns The A2UI context value
73
+ * @throws If used outside of an A2UIProvider
74
+ */
75
+ declare function useA2UIContext(): A2UIContextValue;
76
+ /**
77
+ * @deprecated Use useA2UIContext instead. This alias exists for backward compatibility only.
78
+ */
79
+ declare const useA2UIStore: typeof useA2UIContext;
80
+ /**
81
+ * @deprecated This selector pattern does not provide performance benefits with React Context.
82
+ * Components will re-render on any context change regardless of what you select.
83
+ * Use useA2UIContext() or useA2UI() directly instead.
84
+ *
85
+ * @param selector - Function to select a slice of state
86
+ * @returns The selected state
87
+ */
88
+ declare function useA2UIStoreSelector<T>(selector: (state: A2UIContextValue) => T): T;
89
+ //#endregion
90
+ export { A2UIProvider, A2UIProviderProps, useA2UIActions, useA2UIContext, useA2UIState, useA2UIStore, useA2UIStoreSelector };
91
+ //# sourceMappingURL=A2UIProvider.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"A2UIProvider.d.mts","names":[],"sources":["../../../src/react-renderer/core/A2UIProvider.tsx"],"mappings":";;;;;;;;;;UA4BiB,iBAAA;EAAiB;EAEhC,QAAA,GAAW,gBAAA;EAAA;EAEX,KAAA,GAAQ,KAAA,CAAM,KAAA;EAEJ;EAAV,QAAA,EAAU,SAAA;AAAA;;;;;;;;;;AA6BZ;;;;;;;;;;;;;;;;;iBAAgB,YAAA,CAAA;EAAe,QAAA;EAAU,KAAA;EAAO;AAAA,GAAY,iBAAA,GAAiB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;AAuF7E;;;;iBAAgB,cAAA,CAAA,GAAkB,WAAA;AAelC;;;;;AAeA;;AAfA,iBAAgB,YAAA,CAAA;EAAkB,OAAA;AAAA;AAmClC;;;;;AAUA;;AAVA,iBApBgB,cAAA,CAAA,GAAkB,gBAAA;;;;cAoBrB,YAAA,SAAY,cAAA;;;;;;;;;iBAUT,oBAAA,GAAA,CACd,QAAA,GAAW,KAAA,EAAO,gBAAA,KAAqB,CAAA,GACtC,CAAA"}
@@ -114,7 +114,39 @@ function useA2UIState() {
114
114
  if (!state) throw new Error("useA2UIState must be used within an A2UIProvider");
115
115
  return state;
116
116
  }
117
+ /**
118
+ * Hook to access the full A2UI context (actions + state).
119
+ * Components using this will re-render when state changes.
120
+ *
121
+ * @returns The A2UI context value
122
+ * @throws If used outside of an A2UIProvider
123
+ */
124
+ function useA2UIContext() {
125
+ const actions = useA2UIActions();
126
+ const state = useA2UIState();
127
+ return useMemo(() => ({
128
+ ...actions,
129
+ processor: null,
130
+ version: state.version,
131
+ onAction: null
132
+ }), [actions, state.version]);
133
+ }
134
+ /**
135
+ * @deprecated Use useA2UIContext instead. This alias exists for backward compatibility only.
136
+ */
137
+ const useA2UIStore = useA2UIContext;
138
+ /**
139
+ * @deprecated This selector pattern does not provide performance benefits with React Context.
140
+ * Components will re-render on any context change regardless of what you select.
141
+ * Use useA2UIContext() or useA2UI() directly instead.
142
+ *
143
+ * @param selector - Function to select a slice of state
144
+ * @returns The selected state
145
+ */
146
+ function useA2UIStoreSelector(selector) {
147
+ return selector(useA2UIContext());
148
+ }
117
149
 
118
150
  //#endregion
119
- export { A2UIProvider, useA2UIActions, useA2UIState };
151
+ export { A2UIProvider, useA2UIActions, useA2UIContext, useA2UIState, useA2UIStore, useA2UIStoreSelector };
120
152
  //# sourceMappingURL=A2UIProvider.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"A2UIProvider.mjs","names":[],"sources":["../../../src/react-renderer/core/A2UIProvider.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useRef,\n useState,\n useMemo,\n type ReactNode,\n} from \"react\";\nimport { Data, type Types } from \"@a2ui/lit/0.8\";\nimport type { A2UIContextValue, A2UIActions } from \"./store\";\nimport { ThemeProvider } from \"../theme/ThemeContext\";\nimport type { OnActionCallback } from \"../types\";\n\n/**\n * Context for stable actions (never changes reference, prevents re-renders).\n * Components that only need to dispatch actions or read data won't re-render.\n */\nconst A2UIActionsContext = createContext<A2UIActions | null>(null);\n\n/**\n * Context for reactive state (changes trigger re-renders).\n * Only components that need to react to state changes subscribe to this.\n */\nconst A2UIStateContext = createContext<{ version: number } | null>(null);\n\n/**\n * Props for the A2UIProvider component.\n */\nexport interface A2UIProviderProps {\n /** Callback invoked when a user action is dispatched (button click, etc.) */\n onAction?: OnActionCallback;\n /** Theme configuration. Falls back to default theme if not provided. */\n theme?: Types.Theme;\n /** Child components */\n children: ReactNode;\n}\n\n/**\n * Provider component that sets up the A2UI context for descendant components.\n *\n * This provider uses a two-context architecture for performance:\n * - A2UIActionsContext: Stable actions that never change (no re-renders)\n * - A2UIStateContext: Reactive state that triggers re-renders when needed\n *\n * @example\n * ```tsx\n * function App() {\n * const handleAction = async (message) => {\n * const response = await fetch('/api/a2ui', {\n * method: 'POST',\n * body: JSON.stringify(message)\n * });\n * const newMessages = await response.json();\n * };\n *\n * return (\n * <A2UIProvider onAction={handleAction}>\n * <A2UIRenderer surfaceId=\"main\" />\n * </A2UIProvider>\n * );\n * }\n * ```\n */\nexport function A2UIProvider({ onAction, theme, children }: A2UIProviderProps) {\n // Create message processor only once using ref\n const processorRef = useRef<Types.MessageProcessor | null>(null);\n if (!processorRef.current) {\n processorRef.current = Data.createSignalA2uiMessageProcessor();\n }\n const processor = processorRef.current;\n\n // Version counter for triggering re-renders\n const [version, setVersion] = useState(0);\n\n // Store onAction in a ref so callbacks always have the latest value\n const onActionRef = useRef<OnActionCallback | null>(onAction ?? null);\n onActionRef.current = onAction ?? null;\n\n // Create stable actions object once - stored in ref, never changes\n const actionsRef = useRef<A2UIActions | null>(null);\n if (!actionsRef.current) {\n actionsRef.current = {\n processMessages: (messages: Types.ServerToClientMessage[]) => {\n processor.processMessages(messages);\n setVersion((v) => v + 1);\n },\n\n setData: (\n node: Types.AnyComponentNode | null,\n path: string,\n value: Types.DataValue,\n surfaceId: string,\n ) => {\n processor.setData(node, path, value, surfaceId);\n setVersion((v) => v + 1);\n },\n\n dispatch: (message: Types.A2UIClientEventMessage) => {\n if (onActionRef.current) {\n onActionRef.current(message);\n }\n },\n\n clearSurfaces: () => {\n processor.clearSurfaces();\n setVersion((v) => v + 1);\n },\n\n getSurface: (surfaceId: string) => {\n return processor.getSurfaces().get(surfaceId);\n },\n\n getSurfaces: () => {\n return processor.getSurfaces();\n },\n\n getData: (\n node: Types.AnyComponentNode,\n path: string,\n surfaceId: string,\n ) => {\n return processor.getData(node, path, surfaceId);\n },\n\n resolvePath: (path: string, dataContextPath?: string) => {\n return processor.resolvePath(path, dataContextPath);\n },\n };\n }\n const actions = actionsRef.current;\n\n // State context value - only changes when version changes\n const stateValue = useMemo(() => ({ version }), [version]);\n\n return (\n <A2UIActionsContext.Provider value={actions}>\n <A2UIStateContext.Provider value={stateValue}>\n <ThemeProvider theme={theme}>{children}</ThemeProvider>\n </A2UIStateContext.Provider>\n </A2UIActionsContext.Provider>\n );\n}\n\n/**\n * Hook to access stable A2UI actions (won't cause re-renders).\n * Use this when you only need to dispatch actions or read data.\n *\n * @returns Stable actions object\n * @throws If used outside of an A2UIProvider\n */\nexport function useA2UIActions(): A2UIActions {\n const actions = useContext(A2UIActionsContext);\n if (!actions) {\n throw new Error(\"useA2UIActions must be used within an A2UIProvider\");\n }\n return actions;\n}\n\n/**\n * Hook to subscribe to A2UI state changes.\n * Components using this will re-render when state changes.\n *\n * @returns Current version number\n * @throws If used outside of an A2UIProvider\n */\nexport function useA2UIState(): { version: number } {\n const state = useContext(A2UIStateContext);\n if (!state) {\n throw new Error(\"useA2UIState must be used within an A2UIProvider\");\n }\n return state;\n}\n\n/**\n * Hook to access the full A2UI context (actions + state).\n * Components using this will re-render when state changes.\n *\n * @returns The A2UI context value\n * @throws If used outside of an A2UIProvider\n */\nexport function useA2UIContext(): A2UIContextValue {\n const actions = useA2UIActions();\n const state = useA2UIState();\n\n // Memoize combined value - only changes when state changes\n // Actions are stable, so this only re-creates when version changes\n return useMemo(\n () => ({\n ...actions,\n processor: null as unknown as Types.MessageProcessor, // Not exposed directly\n version: state.version,\n onAction: null, // Use dispatch instead\n }),\n [actions, state.version],\n );\n}\n\n/**\n * @deprecated Use useA2UIContext instead. This alias exists for backward compatibility only.\n */\nexport const useA2UIStore = useA2UIContext;\n\n/**\n * @deprecated This selector pattern does not provide performance benefits with React Context.\n * Components will re-render on any context change regardless of what you select.\n * Use useA2UIContext() or useA2UI() directly instead.\n *\n * @param selector - Function to select a slice of state\n * @returns The selected state\n */\nexport function useA2UIStoreSelector<T>(\n selector: (state: A2UIContextValue) => T,\n): T {\n const context = useA2UIContext();\n return selector(context);\n}\n"],"mappings":";;;;;;;;;;AAiBA,MAAM,qBAAqB,cAAkC,KAAK;;;;;AAMlE,MAAM,mBAAmB,cAA0C,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCxE,SAAgB,aAAa,EAAE,UAAU,OAAO,YAA+B;CAE7E,MAAM,eAAe,OAAsC,KAAK;AAChE,KAAI,CAAC,aAAa,QAChB,cAAa,UAAU,KAAK,kCAAkC;CAEhE,MAAM,YAAY,aAAa;CAG/B,MAAM,CAAC,SAAS,cAAc,SAAS,EAAE;CAGzC,MAAM,cAAc,OAAgC,YAAY,KAAK;AACrE,aAAY,UAAU,YAAY;CAGlC,MAAM,aAAa,OAA2B,KAAK;AACnD,KAAI,CAAC,WAAW,QACd,YAAW,UAAU;EACnB,kBAAkB,aAA4C;AAC5D,aAAU,gBAAgB,SAAS;AACnC,eAAY,MAAM,IAAI,EAAE;;EAG1B,UACE,MACA,MACA,OACA,cACG;AACH,aAAU,QAAQ,MAAM,MAAM,OAAO,UAAU;AAC/C,eAAY,MAAM,IAAI,EAAE;;EAG1B,WAAW,YAA0C;AACnD,OAAI,YAAY,QACd,aAAY,QAAQ,QAAQ;;EAIhC,qBAAqB;AACnB,aAAU,eAAe;AACzB,eAAY,MAAM,IAAI,EAAE;;EAG1B,aAAa,cAAsB;AACjC,UAAO,UAAU,aAAa,CAAC,IAAI,UAAU;;EAG/C,mBAAmB;AACjB,UAAO,UAAU,aAAa;;EAGhC,UACE,MACA,MACA,cACG;AACH,UAAO,UAAU,QAAQ,MAAM,MAAM,UAAU;;EAGjD,cAAc,MAAc,oBAA6B;AACvD,UAAO,UAAU,YAAY,MAAM,gBAAgB;;EAEtD;CAEH,MAAM,UAAU,WAAW;CAG3B,MAAM,aAAa,eAAe,EAAE,SAAS,GAAG,CAAC,QAAQ,CAAC;AAE1D,QACE,oBAAC,mBAAmB;EAAS,OAAO;YAClC,oBAAC,iBAAiB;GAAS,OAAO;aAChC,oBAAC;IAAqB;IAAQ;KAAyB;IAC7B;GACA;;;;;;;;;AAWlC,SAAgB,iBAA8B;CAC5C,MAAM,UAAU,WAAW,mBAAmB;AAC9C,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,qDAAqD;AAEvE,QAAO;;;;;;;;;AAUT,SAAgB,eAAoC;CAClD,MAAM,QAAQ,WAAW,iBAAiB;AAC1C,KAAI,CAAC,MACH,OAAM,IAAI,MAAM,mDAAmD;AAErE,QAAO"}
1
+ {"version":3,"file":"A2UIProvider.mjs","names":[],"sources":["../../../src/react-renderer/core/A2UIProvider.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useRef,\n useState,\n useMemo,\n type ReactNode,\n} from \"react\";\nimport { Data, type Types } from \"@a2ui/lit/0.8\";\nimport type { A2UIContextValue, A2UIActions } from \"./store\";\nimport { ThemeProvider } from \"../theme/ThemeContext\";\nimport type { OnActionCallback } from \"../types\";\n\n/**\n * Context for stable actions (never changes reference, prevents re-renders).\n * Components that only need to dispatch actions or read data won't re-render.\n */\nconst A2UIActionsContext = createContext<A2UIActions | null>(null);\n\n/**\n * Context for reactive state (changes trigger re-renders).\n * Only components that need to react to state changes subscribe to this.\n */\nconst A2UIStateContext = createContext<{ version: number } | null>(null);\n\n/**\n * Props for the A2UIProvider component.\n */\nexport interface A2UIProviderProps {\n /** Callback invoked when a user action is dispatched (button click, etc.) */\n onAction?: OnActionCallback;\n /** Theme configuration. Falls back to default theme if not provided. */\n theme?: Types.Theme;\n /** Child components */\n children: ReactNode;\n}\n\n/**\n * Provider component that sets up the A2UI context for descendant components.\n *\n * This provider uses a two-context architecture for performance:\n * - A2UIActionsContext: Stable actions that never change (no re-renders)\n * - A2UIStateContext: Reactive state that triggers re-renders when needed\n *\n * @example\n * ```tsx\n * function App() {\n * const handleAction = async (message) => {\n * const response = await fetch('/api/a2ui', {\n * method: 'POST',\n * body: JSON.stringify(message)\n * });\n * const newMessages = await response.json();\n * };\n *\n * return (\n * <A2UIProvider onAction={handleAction}>\n * <A2UIRenderer surfaceId=\"main\" />\n * </A2UIProvider>\n * );\n * }\n * ```\n */\nexport function A2UIProvider({ onAction, theme, children }: A2UIProviderProps) {\n // Create message processor only once using ref\n const processorRef = useRef<Types.MessageProcessor | null>(null);\n if (!processorRef.current) {\n processorRef.current = Data.createSignalA2uiMessageProcessor();\n }\n const processor = processorRef.current;\n\n // Version counter for triggering re-renders\n const [version, setVersion] = useState(0);\n\n // Store onAction in a ref so callbacks always have the latest value\n const onActionRef = useRef<OnActionCallback | null>(onAction ?? null);\n onActionRef.current = onAction ?? null;\n\n // Create stable actions object once - stored in ref, never changes\n const actionsRef = useRef<A2UIActions | null>(null);\n if (!actionsRef.current) {\n actionsRef.current = {\n processMessages: (messages: Types.ServerToClientMessage[]) => {\n processor.processMessages(messages);\n setVersion((v) => v + 1);\n },\n\n setData: (\n node: Types.AnyComponentNode | null,\n path: string,\n value: Types.DataValue,\n surfaceId: string,\n ) => {\n processor.setData(node, path, value, surfaceId);\n setVersion((v) => v + 1);\n },\n\n dispatch: (message: Types.A2UIClientEventMessage) => {\n if (onActionRef.current) {\n onActionRef.current(message);\n }\n },\n\n clearSurfaces: () => {\n processor.clearSurfaces();\n setVersion((v) => v + 1);\n },\n\n getSurface: (surfaceId: string) => {\n return processor.getSurfaces().get(surfaceId);\n },\n\n getSurfaces: () => {\n return processor.getSurfaces();\n },\n\n getData: (\n node: Types.AnyComponentNode,\n path: string,\n surfaceId: string,\n ) => {\n return processor.getData(node, path, surfaceId);\n },\n\n resolvePath: (path: string, dataContextPath?: string) => {\n return processor.resolvePath(path, dataContextPath);\n },\n };\n }\n const actions = actionsRef.current;\n\n // State context value - only changes when version changes\n const stateValue = useMemo(() => ({ version }), [version]);\n\n return (\n <A2UIActionsContext.Provider value={actions}>\n <A2UIStateContext.Provider value={stateValue}>\n <ThemeProvider theme={theme}>{children}</ThemeProvider>\n </A2UIStateContext.Provider>\n </A2UIActionsContext.Provider>\n );\n}\n\n/**\n * Hook to access stable A2UI actions (won't cause re-renders).\n * Use this when you only need to dispatch actions or read data.\n *\n * @returns Stable actions object\n * @throws If used outside of an A2UIProvider\n */\nexport function useA2UIActions(): A2UIActions {\n const actions = useContext(A2UIActionsContext);\n if (!actions) {\n throw new Error(\"useA2UIActions must be used within an A2UIProvider\");\n }\n return actions;\n}\n\n/**\n * Hook to subscribe to A2UI state changes.\n * Components using this will re-render when state changes.\n *\n * @returns Current version number\n * @throws If used outside of an A2UIProvider\n */\nexport function useA2UIState(): { version: number } {\n const state = useContext(A2UIStateContext);\n if (!state) {\n throw new Error(\"useA2UIState must be used within an A2UIProvider\");\n }\n return state;\n}\n\n/**\n * Hook to access the full A2UI context (actions + state).\n * Components using this will re-render when state changes.\n *\n * @returns The A2UI context value\n * @throws If used outside of an A2UIProvider\n */\nexport function useA2UIContext(): A2UIContextValue {\n const actions = useA2UIActions();\n const state = useA2UIState();\n\n // Memoize combined value - only changes when state changes\n // Actions are stable, so this only re-creates when version changes\n return useMemo(\n () => ({\n ...actions,\n processor: null as unknown as Types.MessageProcessor, // Not exposed directly\n version: state.version,\n onAction: null, // Use dispatch instead\n }),\n [actions, state.version],\n );\n}\n\n/**\n * @deprecated Use useA2UIContext instead. This alias exists for backward compatibility only.\n */\nexport const useA2UIStore = useA2UIContext;\n\n/**\n * @deprecated This selector pattern does not provide performance benefits with React Context.\n * Components will re-render on any context change regardless of what you select.\n * Use useA2UIContext() or useA2UI() directly instead.\n *\n * @param selector - Function to select a slice of state\n * @returns The selected state\n */\nexport function useA2UIStoreSelector<T>(\n selector: (state: A2UIContextValue) => T,\n): T {\n const context = useA2UIContext();\n return selector(context);\n}\n"],"mappings":";;;;;;;;;;AAiBA,MAAM,qBAAqB,cAAkC,KAAK;;;;;AAMlE,MAAM,mBAAmB,cAA0C,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCxE,SAAgB,aAAa,EAAE,UAAU,OAAO,YAA+B;CAE7E,MAAM,eAAe,OAAsC,KAAK;AAChE,KAAI,CAAC,aAAa,QAChB,cAAa,UAAU,KAAK,kCAAkC;CAEhE,MAAM,YAAY,aAAa;CAG/B,MAAM,CAAC,SAAS,cAAc,SAAS,EAAE;CAGzC,MAAM,cAAc,OAAgC,YAAY,KAAK;AACrE,aAAY,UAAU,YAAY;CAGlC,MAAM,aAAa,OAA2B,KAAK;AACnD,KAAI,CAAC,WAAW,QACd,YAAW,UAAU;EACnB,kBAAkB,aAA4C;AAC5D,aAAU,gBAAgB,SAAS;AACnC,eAAY,MAAM,IAAI,EAAE;;EAG1B,UACE,MACA,MACA,OACA,cACG;AACH,aAAU,QAAQ,MAAM,MAAM,OAAO,UAAU;AAC/C,eAAY,MAAM,IAAI,EAAE;;EAG1B,WAAW,YAA0C;AACnD,OAAI,YAAY,QACd,aAAY,QAAQ,QAAQ;;EAIhC,qBAAqB;AACnB,aAAU,eAAe;AACzB,eAAY,MAAM,IAAI,EAAE;;EAG1B,aAAa,cAAsB;AACjC,UAAO,UAAU,aAAa,CAAC,IAAI,UAAU;;EAG/C,mBAAmB;AACjB,UAAO,UAAU,aAAa;;EAGhC,UACE,MACA,MACA,cACG;AACH,UAAO,UAAU,QAAQ,MAAM,MAAM,UAAU;;EAGjD,cAAc,MAAc,oBAA6B;AACvD,UAAO,UAAU,YAAY,MAAM,gBAAgB;;EAEtD;CAEH,MAAM,UAAU,WAAW;CAG3B,MAAM,aAAa,eAAe,EAAE,SAAS,GAAG,CAAC,QAAQ,CAAC;AAE1D,QACE,oBAAC,mBAAmB;EAAS,OAAO;YAClC,oBAAC,iBAAiB;GAAS,OAAO;aAChC,oBAAC;IAAqB;IAAQ;KAAyB;IAC7B;GACA;;;;;;;;;AAWlC,SAAgB,iBAA8B;CAC5C,MAAM,UAAU,WAAW,mBAAmB;AAC9C,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,qDAAqD;AAEvE,QAAO;;;;;;;;;AAUT,SAAgB,eAAoC;CAClD,MAAM,QAAQ,WAAW,iBAAiB;AAC1C,KAAI,CAAC,MACH,OAAM,IAAI,MAAM,mDAAmD;AAErE,QAAO;;;;;;;;;AAUT,SAAgB,iBAAmC;CACjD,MAAM,UAAU,gBAAgB;CAChC,MAAM,QAAQ,cAAc;AAI5B,QAAO,eACE;EACL,GAAG;EACH,WAAW;EACX,SAAS,MAAM;EACf,UAAU;EACX,GACD,CAAC,SAAS,MAAM,QAAQ,CACzB;;;;;AAMH,MAAa,eAAe;;;;;;;;;AAU5B,SAAgB,qBACd,UACG;AAEH,QAAO,SADS,gBAAgB,CACR"}
@@ -0,0 +1,40 @@
1
+ import { ComponentRegistry } from "../registry/ComponentRegistry.cjs";
2
+ import * as react from "react";
3
+ import { ReactNode } from "react";
4
+
5
+ //#region src/react-renderer/core/A2UIRenderer.d.ts
6
+ interface A2UIRendererProps {
7
+ /** The surface ID to render */
8
+ surfaceId: string;
9
+ /** Additional CSS classes for the surface container */
10
+ className?: string;
11
+ /** Fallback content when surface is not yet available */
12
+ fallback?: ReactNode;
13
+ /** Loading fallback for lazy-loaded components */
14
+ loadingFallback?: ReactNode;
15
+ /** Optional custom component registry */
16
+ registry?: ComponentRegistry;
17
+ }
18
+ /**
19
+ * A2UIRenderer - renders an A2UI surface.
20
+ *
21
+ * This is the main entry point for rendering A2UI content in your React app.
22
+ * It reads the surface state from the A2UI store and renders the component tree.
23
+ *
24
+ * Memoized to prevent unnecessary re-renders when props haven't changed.
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * function App() {
29
+ * return (
30
+ * <A2UIProvider onAction={handleAction}>
31
+ * <A2UIRenderer surfaceId="main" />
32
+ * </A2UIProvider>
33
+ * );
34
+ * }
35
+ * ```
36
+ */
37
+ declare const A2UIRenderer: react.NamedExoticComponent<A2UIRendererProps>;
38
+ //#endregion
39
+ export { A2UIRenderer, A2UIRendererProps };
40
+ //# sourceMappingURL=A2UIRenderer.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"A2UIRenderer.d.cts","names":[],"sources":["../../../src/react-renderer/core/A2UIRenderer.tsx"],"mappings":";;;;;UAeiB,iBAAA;;EAEf,SAAA;EAFe;EAIf,SAAA;;EAEA,QAAA,GAAW,SAAA;EAEO;EAAlB,eAAA,GAAkB,SAAA;EAEU;EAA5B,QAAA,GAAW,iBAAA;AAAA;;;;;;;;;;AAsBb;;;;;;;;;;cAAa,YAAA,EAAY,KAAA,CAAA,oBAAA,CAAA,iBAAA"}
@@ -0,0 +1,40 @@
1
+ import { ComponentRegistry } from "../registry/ComponentRegistry.mjs";
2
+ import * as react from "react";
3
+ import { ReactNode } from "react";
4
+
5
+ //#region src/react-renderer/core/A2UIRenderer.d.ts
6
+ interface A2UIRendererProps {
7
+ /** The surface ID to render */
8
+ surfaceId: string;
9
+ /** Additional CSS classes for the surface container */
10
+ className?: string;
11
+ /** Fallback content when surface is not yet available */
12
+ fallback?: ReactNode;
13
+ /** Loading fallback for lazy-loaded components */
14
+ loadingFallback?: ReactNode;
15
+ /** Optional custom component registry */
16
+ registry?: ComponentRegistry;
17
+ }
18
+ /**
19
+ * A2UIRenderer - renders an A2UI surface.
20
+ *
21
+ * This is the main entry point for rendering A2UI content in your React app.
22
+ * It reads the surface state from the A2UI store and renders the component tree.
23
+ *
24
+ * Memoized to prevent unnecessary re-renders when props haven't changed.
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * function App() {
29
+ * return (
30
+ * <A2UIProvider onAction={handleAction}>
31
+ * <A2UIRenderer surfaceId="main" />
32
+ * </A2UIProvider>
33
+ * );
34
+ * }
35
+ * ```
36
+ */
37
+ declare const A2UIRenderer: react.NamedExoticComponent<A2UIRendererProps>;
38
+ //#endregion
39
+ export { A2UIRenderer, A2UIRendererProps };
40
+ //# sourceMappingURL=A2UIRenderer.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"A2UIRenderer.d.mts","names":[],"sources":["../../../src/react-renderer/core/A2UIRenderer.tsx"],"mappings":";;;;;UAeiB,iBAAA;;EAEf,SAAA;EAFe;EAIf,SAAA;;EAEA,QAAA,GAAW,SAAA;EAEO;EAAlB,eAAA,GAAkB,SAAA;EAEU;EAA5B,QAAA,GAAW,iBAAA;AAAA;;;;;;;;;;AAsBb;;;;;;;;;;cAAa,YAAA,EAAY,KAAA,CAAA,oBAAA,CAAA,iBAAA"}
@@ -0,0 +1,11 @@
1
+ "use client";
2
+
3
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
4
+ require('../theme/litTheme.cjs');
5
+ require('./A2UIProvider.cjs');
6
+ require('./A2UIRenderer.cjs');
7
+ require('../registry/defaultCatalog.cjs');
8
+ require('../styles/index.cjs');
9
+ let react = require("react");
10
+ react = require_runtime.__toESM(react);
11
+ let react_jsx_runtime = require("react/jsx-runtime");
@@ -0,0 +1,16 @@
1
+ import "react/jsx-runtime";
2
+ import { Types } from "@a2ui/lit/0.8";
3
+
4
+ //#region src/react-renderer/core/A2UIViewer.d.ts
5
+ /**
6
+ * Action event dispatched when a user interacts with a component.
7
+ */
8
+ interface A2UIActionEvent {
9
+ actionName: string;
10
+ sourceComponentId: string;
11
+ timestamp: string;
12
+ context: Record<string, unknown>;
13
+ }
14
+ //#endregion
15
+ export { A2UIActionEvent };
16
+ //# sourceMappingURL=A2UIViewer.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"A2UIViewer.d.cts","names":[],"sources":["../../../src/react-renderer/core/A2UIViewer.tsx"],"mappings":";;;;;;;UAsBiB,eAAA;EACf,UAAA;EACA,iBAAA;EACA,SAAA;EACA,OAAA,EAAS,MAAA;AAAA"}