glchat-a2ui-react-renderer 0.0.5 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/README.md +221 -93
  2. package/dist/index.d.ts +4 -18
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +7 -17
  5. package/dist/src/a2ui/GlchatA2UIProvider.d.ts +4 -0
  6. package/dist/src/a2ui/GlchatA2UIProvider.d.ts.map +1 -0
  7. package/dist/src/a2ui/GlchatA2UIProvider.js +8 -0
  8. package/dist/src/a2ui/GlchatA2UIRenderer.d.ts +4 -0
  9. package/dist/src/a2ui/GlchatA2UIRenderer.d.ts.map +1 -0
  10. package/dist/src/a2ui/GlchatA2UIRenderer.js +6 -0
  11. package/dist/src/a2ui/adapter.d.ts +3 -0
  12. package/dist/src/a2ui/adapter.d.ts.map +1 -0
  13. package/dist/src/a2ui/adapter.js +12 -0
  14. package/dist/src/a2ui/glchatStandardCatalog.d.ts +10 -0
  15. package/dist/src/a2ui/glchatStandardCatalog.d.ts.map +1 -0
  16. package/dist/src/a2ui/glchatStandardCatalog.js +14 -0
  17. package/dist/src/components/custom/Button.d.ts +3 -0
  18. package/dist/src/components/custom/Button.d.ts.map +1 -0
  19. package/dist/src/components/custom/Button.js +14 -0
  20. package/dist/src/components/custom/Card.d.ts +3 -0
  21. package/dist/src/components/custom/Card.d.ts.map +1 -0
  22. package/dist/src/components/custom/Card.js +7 -0
  23. package/dist/src/components/custom/Timeout.d.ts +3 -0
  24. package/dist/src/components/custom/Timeout.d.ts.map +1 -0
  25. package/dist/src/components/custom/Timeout.js +6 -0
  26. package/dist/src/components/{Button.d.ts → ui/Button.d.ts} +4 -4
  27. package/dist/src/components/ui/Button.d.ts.map +1 -0
  28. package/dist/src/components/ui/Button.js +38 -0
  29. package/dist/src/components/{Card.d.ts → ui/Card.d.ts} +1 -1
  30. package/dist/src/components/ui/Card.d.ts.map +1 -0
  31. package/dist/src/components/ui/Card.js +16 -0
  32. package/dist/src/components/ui/Timeout.d.ts +6 -0
  33. package/dist/src/components/ui/Timeout.d.ts.map +1 -0
  34. package/dist/src/components/{Timeout.js → ui/Timeout.js} +3 -4
  35. package/package.json +9 -5
  36. package/styles/globals.css +103 -0
  37. package/styles/theme-v4.css +86 -0
  38. package/tailwind.config.cjs +111 -0
  39. package/dist/src/components/Button.d.ts.map +0 -1
  40. package/dist/src/components/Button.js +0 -43
  41. package/dist/src/components/Card.d.ts.map +0 -1
  42. package/dist/src/components/Card.js +0 -16
  43. package/dist/src/components/Checkbox.d.ts +0 -5
  44. package/dist/src/components/Checkbox.d.ts.map +0 -1
  45. package/dist/src/components/Checkbox.js +0 -9
  46. package/dist/src/components/Column.d.ts +0 -13
  47. package/dist/src/components/Column.d.ts.map +0 -1
  48. package/dist/src/components/Column.js +0 -20
  49. package/dist/src/components/Image.d.ts +0 -9
  50. package/dist/src/components/Image.d.ts.map +0 -1
  51. package/dist/src/components/Image.js +0 -21
  52. package/dist/src/components/Input.d.ts +0 -8
  53. package/dist/src/components/Input.d.ts.map +0 -1
  54. package/dist/src/components/Input.js +0 -9
  55. package/dist/src/components/Label.d.ts +0 -5
  56. package/dist/src/components/Label.d.ts.map +0 -1
  57. package/dist/src/components/Label.js +0 -8
  58. package/dist/src/components/Row.d.ts +0 -13
  59. package/dist/src/components/Row.d.ts.map +0 -1
  60. package/dist/src/components/Row.js +0 -20
  61. package/dist/src/components/Separator.d.ts +0 -5
  62. package/dist/src/components/Separator.d.ts.map +0 -1
  63. package/dist/src/components/Separator.js +0 -11
  64. package/dist/src/components/Text.d.ts +0 -8
  65. package/dist/src/components/Text.d.ts.map +0 -1
  66. package/dist/src/components/Text.js +0 -19
  67. package/dist/src/components/TextField.d.ts +0 -13
  68. package/dist/src/components/TextField.d.ts.map +0 -1
  69. package/dist/src/components/TextField.js +0 -31
  70. package/dist/src/components/Timeout.d.ts +0 -8
  71. package/dist/src/components/Timeout.d.ts.map +0 -1
  72. package/dist/src/helpers/messageParser.d.ts +0 -10
  73. package/dist/src/helpers/messageParser.d.ts.map +0 -1
  74. package/dist/src/helpers/messageParser.js +0 -40
  75. package/dist/src/hooks/useA2UIProcessor.d.ts +0 -17
  76. package/dist/src/hooks/useA2UIProcessor.d.ts.map +0 -1
  77. package/dist/src/hooks/useA2UIProcessor.js +0 -16
  78. package/dist/src/rendering/Surface.d.ts +0 -26
  79. package/dist/src/rendering/Surface.d.ts.map +0 -1
  80. package/dist/src/rendering/Surface.js +0 -51
  81. package/dist/src/rendering/catalog.d.ts +0 -41
  82. package/dist/src/rendering/catalog.d.ts.map +0 -1
  83. package/dist/src/rendering/catalog.js +0 -160
  84. package/dist/src/rendering/componentRegistry.d.ts +0 -9
  85. package/dist/src/rendering/componentRegistry.d.ts.map +0 -1
  86. package/dist/src/rendering/componentRegistry.js +0 -10
  87. package/dist/src/runtime/bindingResolver.d.ts +0 -30
  88. package/dist/src/runtime/bindingResolver.d.ts.map +0 -1
  89. package/dist/src/runtime/bindingResolver.js +0 -129
  90. package/dist/src/runtime/dispatcher.d.ts +0 -15
  91. package/dist/src/runtime/dispatcher.d.ts.map +0 -1
  92. package/dist/src/runtime/dispatcher.js +0 -29
  93. package/dist/src/runtime/messageProcessor.d.ts +0 -54
  94. package/dist/src/runtime/messageProcessor.d.ts.map +0 -1
  95. package/dist/src/runtime/messageProcessor.js +0 -85
  96. package/dist/src/runtime/surfaceManager.d.ts +0 -48
  97. package/dist/src/runtime/surfaceManager.d.ts.map +0 -1
  98. package/dist/src/runtime/surfaceManager.js +0 -90
  99. package/dist/src/types.d.ts +0 -340
  100. package/dist/src/types.d.ts.map +0 -1
  101. package/dist/src/types.js +0 -3
  102. package/dist/styles.css +0 -395
package/README.md CHANGED
@@ -1,137 +1,265 @@
1
1
  # glchat-a2ui-react-renderer
2
2
 
3
- A2UI (Agent-to-UI) React renderer for [GLChat](https://github.com/GDP-ADMIN/glchat-sdk). Renders declarative UI from AI agent messages using the [A2UI protocol](https://a2ui.org/).
3
+ [`@a2ui-sdk/react`](https://www.npmjs.com/package/@a2ui-sdk/react) with GLChat-specific catalog and styling.
4
4
 
5
- **This library is temporary** while waiting for the [official A2UI React renderer](https://a2ui.org/renderers/) to be released (planned Q1 2026). When the official React renderer is available, we recommend migrating to the official library. This implementation is structured to align with the official Lit and Angular renderers so that switching later should involve minimal changes.
5
+ This package provides:
6
6
 
7
- ## Install
7
+ * **`GlchatA2UIProvider`** – `A2UIProvider` wrapper that uses the GLChat catalog by default.
8
+ * **`GlchatA2UIRenderer`** – thin wrapper around `A2UIRenderer`.
9
+ * **`glchatStandardCatalog`** – the standard A2UI catalog with GLChat custom components (`Button`, `Card`, `Timeout`) for manual wiring.
10
+ * **Tailwind theming** – `styles/globals.css`, `styles/theme-v4.css`, and `tailwind-config.cjs` for default tokens and utilities.
11
+
12
+ This library provides **GLChat-specific components and styling** while remaining fully compatible with the upstream A2UI renderer.
13
+
14
+ ---
15
+
16
+ # Prerequisites
17
+
18
+ * **React 18+**
19
+ * **Tailwind CSS v3 or v4**
20
+
21
+ ---
22
+
23
+ # Install
8
24
 
9
25
  ```bash
10
26
  npm install glchat-a2ui-react-renderer
11
27
  ```
12
28
 
13
- ## Usage
29
+ ---
30
+
31
+ # Quick Start
32
+
33
+ Use the GLChat-aware wrappers:
14
34
 
15
35
  ```tsx
16
- import { useEffect } from 'react';
17
36
  import {
18
- useA2UIProcessor,
19
- A2UISurface,
20
- DEFAULT_CATALOG,
21
- parseJSONLStream,
37
+ GlchatA2UIProvider,
38
+ GlchatA2UIRenderer,
39
+ type A2UIMessage,
40
+ type A2UIAction,
22
41
  } from 'glchat-a2ui-react-renderer';
23
- import type { Theme, ComponentCatalog } from 'glchat-a2ui-react-renderer';
24
42
 
25
- // Import styles (required)
26
- import 'glchat-a2ui-react-renderer/styles.css';
43
+ function App() {
44
+ const messages: A2UIMessage[] = [
45
+ // A2UI messages from your backend
46
+ ];
27
47
 
28
- // Optional: theme = classNames per component (styling only)
29
- const theme: Theme = {
30
- components: {
31
- Text: { body: 'a2ui-text-body', h1: 'a2ui-text-h1' },
32
- Button: 'a2ui-button a2ui-button--primary',
33
- },
34
- };
48
+ const handleAction = (action: A2UIAction) => {
49
+ console.log('Action received:', action);
50
+ };
35
51
 
36
- // Optional: catalog = replace how a component type is rendered (e.g. custom Button)
37
- const catalog: ComponentCatalog = {
38
- ...DEFAULT_CATALOG,
39
- Button: (data, props) => <YourButton data={data} {...props} />,
40
- };
52
+ return (
53
+ <GlchatA2UIProvider messages={messages}>
54
+ <GlchatA2UIRenderer onAction={handleAction} />
55
+ </GlchatA2UIProvider>
56
+ );
57
+ }
58
+
59
+ ```
60
+ # Custom Catalog
41
61
 
42
- function ChatSurfaces({ messages }: { messages: string }) {
43
- const { processor, surfaces, refreshSurfaces } = useA2UIProcessor();
44
-
45
- useEffect(() => {
46
- processor.processMessages(messages);
47
- refreshSurfaces();
48
- }, [messages, processor, refreshSurfaces]);
49
-
50
- // Subscribe to user actions (button clicks, etc.).
51
- useEffect(() => {
52
- const unsubscribe = processor.events.subscribe(async (event) => {
53
- // do something with the user action (e.g. send it back to the agent)
54
- try {
55
- await processYourUserAction(event.message);
56
- } catch (err) {
57
- // handle error
58
- } finally {
59
- event.completion([]);
60
- }
61
- });
62
- return unsubscribe;
63
- }, [processor]);
62
+ To extend catalog, you can use `glchatStandardCatalog` as the base standard.
63
+
64
+ ```tsx
65
+ import {
66
+ A2UIProvider,
67
+ A2UIRenderer,
68
+ glchatStandardCatalog,
69
+ type A2UIMessage,
70
+ type A2UIAction,
71
+ } from 'glchat-a2ui-react-renderer';
72
+
73
+ function App() {
74
+ const messages: A2UIMessage[] = [
75
+ // A2UI messages from your backend
76
+ ];
77
+
78
+ const customCatalog = {
79
+ ...glchatStandardCatalog,
80
+ components: {
81
+ ...glchatStandardCatalog.components,
82
+ Button: CustomButtonComponent,
83
+ },
84
+ };
85
+
86
+ const handleAction = (action: A2UIAction) => {
87
+ console.log('Action received:', action);
88
+ };
64
89
 
65
90
  return (
66
- <>
67
- {Array.from(surfaces.entries()).map(([surfaceId, surface]) => (
68
- <A2UISurface
69
- key={surfaceId}
70
- surface={surface}
71
- processor={processor}
72
- refreshSurfaces={refreshSurfaces}
73
- theme={theme}
74
- catalog={catalog}
75
- />
76
- ))}
77
- </>
91
+ <GlchatA2UIProvider messages={messages} catalog={glchatStandardCatalog}>
92
+ <GlchatA2UIRenderer onAction={handleAction} />
93
+ </GlchatA2UIProvider>
78
94
  );
79
95
  }
80
96
  ```
81
97
 
82
- | Prop | Required | Description |
83
- |------|----------|-------------|
84
- | `surface` | Yes | Surface state (from `processor.getSurfaces()`). |
85
- | `processor` | No | With `refreshSurfaces`, enables TextField/CheckBox two-way binding. Subscribe to `processor.events` for user actions. |
86
- | `refreshSurfaces` | No | Call after `processMessages()` so UI re-renders; pass with `processor` for inputs. |
87
- | `theme` | No | ClassNames per component/part for built-in components. |
88
- | `catalog` | No | Custom renderers: type → `(data, props) => ReactNode`; defaults to built-in catalog. |
98
+ ```tsx
99
+ import {
100
+ ComponentRenderer,
101
+ type ButtonComponentProps,
102
+ type CatalogComponent,
103
+ useDispatchAction,
104
+ } from "glchat-a2ui-react-renderer";
105
+
106
+ export const CustomButtonComponent: CatalogComponent = ({
107
+ surfaceId,
108
+ componentId,
109
+ ...props
110
+ }) => {
111
+ const { child, action, primary } = props as ButtonComponentProps
112
+ const dispatchAction = useDispatchAction()
113
+
114
+ const handleClick = () => {
115
+ if (action) {
116
+ dispatchAction(surfaceId, componentId, action)
117
+ }
118
+ }
119
+
120
+ const variant = primary ? 'primary' : 'outline';
89
121
 
90
- ## Exports
122
+ return (
123
+ <Button onClick={handleClick} variant={variant}>
124
+ <div>masuk custom button</div>
125
+ {child && <ComponentRenderer surfaceId={surfaceId} componentId={child} />}
126
+ </Button>
127
+ )
128
+ }
129
+ ```
91
130
 
92
- - **Primary API:** `MessageProcessor`, `A2UISurface`, `A2UISurfaceProps`, `useA2UIProcessor`, `UseA2UIProcessorResult`
93
- - **Catalog:** `DEFAULT_CATALOG`, `renderComponentFromCatalog`, `ComponentCatalog`, `ComponentRenderer`, `ComponentRenderProps`
94
- - **Theme:** `defaultTheme`, type `Theme` (optional `components` with className strings per component/part)
95
- - **Runtime:** `MessageDispatcher`, `SurfaceManager`, `resolveBoundValue`, `getPathFromBoundValue`, `resolveActionContext`, `setPathValue`, `updateDataModel`, `parseJSONLStream`, `isValidMessage`
96
- - **Types:** `A2UIMessage`, `BoundValue`, `ClientToServerMessage`, `DispatchedEvent`, `UserAction`, `SurfaceState`, `Theme`, `ComponentDefinition`, and other protocol types (aligned with Lit/Angular)
131
+ Refer to the upstream docs for full API details:
132
+ [https://a2ui.org/renderers/](https://a2ui.org/renderers/)
97
133
 
98
- ## Supported components
134
+ ---
99
135
 
100
- The default catalog includes: **Text**, **Button**, **Card**, **Row**, **Column**, **TextField**, **CheckBox**, **Image**, **Divider**, **Timeout**. See `json/glchat_standard_catalog_definition.json` and `json/a2ui-sample-messages.json` for the full GLChat catalog and sample messages.
136
+ # Tailwind Setup
101
137
 
102
- ## Styling
138
+ ## Tailwind v4
103
139
 
104
- The renderer uses **plain CSS** with scoped class names (`a2ui-*`) to avoid clashes with your app's styles. Import the stylesheet in your app entry:
140
+ Add the following to your main CSS file (`globals.css`):
105
141
 
106
- ```tsx
107
- import 'glchat-a2ui-react-renderer/styles.css';
142
+ ```css
143
+ @import "tailwindcss";
144
+
145
+ /* Load design tokens */
146
+ @import "glchat-a2ui-react-renderer/styles/globals.css";
147
+
148
+ /* Register tokens with Tailwind */
149
+ @import "glchat-a2ui-react-renderer/styles/theme-v4.css";
150
+
151
+ /* Optional: ensure Tailwind scans this package */
152
+ @source "../node_modules/glchat-a2ui-react-renderer";
108
153
  ```
109
154
 
110
- Override theme via CSS variables on `:root` or `.a2ui-surface` (e.g. `--a2ui-primary`, `--a2ui-destructive`). Pass a **theme** prop to supply custom `className` strings per component or part without replacing the catalog.
155
+ ---
156
+
157
+ ## Tailwind v3
158
+
159
+ Use the provided preset and include the package in `content`.
160
+
161
+ ```js
162
+ const glchatPreset = require('glchat-a2ui-react-renderer/tailwind-config.cjs');
163
+
164
+ module.exports = {
165
+ presets: [glchatPreset],
166
+ content: [
167
+ './src/**/*.{js,ts,jsx,tsx}',
168
+ './app/**/*.{js,ts,jsx,tsx}',
169
+ './node_modules/glchat-a2ui-react-renderer/dist/**/*.{js,jsx,ts,tsx}',
170
+ ],
171
+ };
172
+ ```
173
+
174
+ Import the tokens in your main CSS:
175
+
176
+ ```css
177
+ @import "glchat-a2ui-react-renderer/styles/globals.css";
178
+
179
+ @tailwind base;
180
+ @tailwind components;
181
+ @tailwind utilities;
182
+ ```
183
+
184
+ ---
185
+
186
+ # Customizing Colors
187
+
188
+ Override CSS variables after importing `globals.css`:
189
+
190
+ ```css
191
+ :root {
192
+ --primary: 220 90% 45%;
193
+ --background: 0 0% 99%;
194
+ }
195
+
196
+ .dark {
197
+ --primary: 220 70% 50%;
198
+ }
199
+ ```
200
+
201
+ You may also extend the theme via:
202
+
203
+ * `tailwind.config.js` (v3)
204
+ * `@theme` (v4)
205
+
206
+ ---
207
+
208
+ # Exports
209
+
210
+ ## GLChat wrappers
211
+
212
+ * `GlchatA2UIProviderProps`
213
+ * `GlchatA2UIRendererProps`
214
+
215
+ ## GLChat catalog
216
+
217
+ * `glchatStandardCatalog` – standard catalog with custom Button, Card, Timeout
218
+
219
+ ## Re-exports from `@a2ui-sdk/react`
220
+
221
+ ### Components
222
+
223
+ * `A2UIProvider`
224
+ * `A2UIRenderer`
225
+ * `ComponentRenderer`
226
+ * `standardCatalog`
227
+
228
+ ### Hooks
111
229
 
230
+ * `useDispatchAction`
231
+ * `useDataBinding`
232
+ * `useFormBinding`
233
+ * `useSurfaceContext`
234
+ * `useDataModelContext`
235
+ * `useA2UIMessageHandler`
112
236
 
113
- ## Implementation guide
237
+ ### Context
114
238
 
115
- This renderer is guided by the **[A2UI Renderer Implementation Guide](https://a2ui.org/guides/renderer-development/)** and follows the same patterns as the existing official renderers:
239
+ * `ActionProvider`
240
+ * `useActionContext`
116
241
 
117
- - **[Lit (Web Components)](https://github.com/google/A2UI/tree/main/renderers/lit)** — [A2UI Renderers](https://a2ui.org/renderers/)
118
- - **[Angular](https://github.com/google/A2UI/tree/main/renderers/angular)** — [A2UI Renderers](https://a2ui.org/renderers/)
242
+ ### Types
119
243
 
120
- ### Current implementation
244
+ * `A2UIMessage`
245
+ * `A2UIAction`
246
+ * `Action`
247
+ * `ValueSource`
248
+ * `A2UIProviderProps`
249
+ * `A2UIRendererProps`
250
+ * `A2UIMessageHandler`
121
251
 
122
- - **Message processing & state:** JSONL-friendly parsing, message dispatcher (`beginRendering`, `surfaceUpdate`, `dataModelUpdate`, `deleteSurface`), surface manager keyed by `surfaceId`, component buffer (adjacency list) per surface, data model store per surface.
123
- - **Progressive rendering:** Buffer updates until `beginRendering`; then render from the given `root`; component catalog (type → React component).
124
- - **Data binding:** `BoundValue` resolution (literal and/or path against the surface data model); `setData(surfaceId, path, value)` for TextField/CheckBox so input changes update the model and refresh the UI.
125
- - **Client–server:** User actions with resolved `action.context` sent as `userAction` payloads.
252
+ ### Styles
126
253
 
127
- **Public API (aligned with Lit/Angular):** `MessageProcessor` (`getSurfaces()`, `processMessages()`, `clearSurfaces()`, `setData()`, `dispatch()`, `events.subscribe()`), `A2UISurface` (receives `surfaceId`, `surface`, optional `processor` + `refreshSurfaces`), and `useA2UIProcessor()` hook. No single “messages in, everything handled” component — the app feeds messages into the processor and renders one `A2UISurface` per surface.
254
+ * `styles/globals.css`
255
+ * `styles/theme-v4.css`
256
+ * `tailwind-config.cjs`
128
257
 
129
- ## Docs
258
+ Full documentation:
259
+ [https://a2ui.org/renderers/](https://a2ui.org/renderers/)
130
260
 
131
- - [A2UI Renderer Implementation Guide](https://a2ui.org/guides/renderer-development/)
132
- - [A2UI Renderers (Lit, Angular, Flutter, React roadmap)](https://a2ui.org/renderers/)
133
- - `src/README.md` in this package for architecture and message flow details.
261
+ ---
134
262
 
135
- ## License
263
+ # License
136
264
 
137
265
  MIT
package/dist/index.d.ts CHANGED
@@ -1,19 +1,5 @@
1
- /**
2
- * glchat-a2ui-react-renderer — A2UI React renderer for GLChat
3
- * Structure aligned with official Lit/Angular renderers: processor + A2UISurface.
4
- * @packageDocumentation
5
- */
6
- export { MessageProcessor } from './src/runtime/messageProcessor.js';
7
- export { A2UISurface } from './src/rendering/Surface.js';
8
- export type { A2UISurfaceProps } from './src/rendering/Surface.js';
9
- export { useA2UIProcessor } from './src/hooks/useA2UIProcessor.js';
10
- export type { UseA2UIProcessorResult } from './src/hooks/useA2UIProcessor.js';
11
- export { DEFAULT_CATALOG, renderComponentFromCatalog, } from './src/rendering/catalog.js';
12
- export type { ComponentCatalog, ComponentRenderer, ComponentRenderProps, } from './src/rendering/catalog.js';
13
- export { resolveBoundValue, updateDataModel, getPathFromBoundValue, resolveActionContext, setPathValue, } from './src/runtime/bindingResolver.js';
14
- export { MessageDispatcher } from './src/runtime/dispatcher.js';
15
- export { SurfaceManager } from './src/runtime/surfaceManager.js';
16
- export { parseJSONLStream, isValidMessage } from './src/helpers/messageParser.js';
17
- export type { A2UIMessage, BeginRenderingMessage, SurfaceUpdateMessage, DataModelUpdateMessage, DeleteSurfaceMessage, BoundValue, ComponentDefinition, ClientToServerMessage, ClientError, DispatchedEvent, UserAction, ActionDefinition, DataModelContent, ValueMapItem, SurfaceState, Component, Theme, } from './src/types.js';
18
- export { defaultTheme } from './src/types.js';
1
+ export { GlchatA2UIProvider, type GlchatA2UIProviderProps, } from './src/a2ui/GlchatA2UIProvider.js';
2
+ export { GlchatA2UIRenderer, type GlchatA2UIRendererProps, } from './src/a2ui/GlchatA2UIRenderer.js';
3
+ export { glchatStandardCatalog } from './src/a2ui/glchatStandardCatalog.js';
4
+ export * from './src/a2ui/adapter.js';
19
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,YAAY,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAG9E,OAAO,EACL,eAAe,EACf,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,GACb,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAElF,YAAY,EACV,WAAW,EACX,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,UAAU,EACV,mBAAmB,EACnB,qBAAqB,EACrB,WAAW,EACX,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,KAAK,GACN,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,GAC7B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,GAC7B,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAG5E,cAAc,uBAAuB,CAAC"}
package/dist/index.js CHANGED
@@ -1,17 +1,7 @@
1
- /**
2
- * glchat-a2ui-react-renderer — A2UI React renderer for GLChat
3
- * Structure aligned with official Lit/Angular renderers: processor + A2UISurface.
4
- * @packageDocumentation
5
- */
6
- // Primary API (same structure as Lit/Angular)
7
- export { MessageProcessor } from './src/runtime/messageProcessor.js';
8
- export { A2UISurface } from './src/rendering/Surface.js';
9
- export { useA2UIProcessor } from './src/hooks/useA2UIProcessor.js';
10
- // Catalog (type → component map, same pattern as Lit componentRegistry / Angular Catalog)
11
- export { DEFAULT_CATALOG, renderComponentFromCatalog, } from './src/rendering/catalog.js';
12
- // Runtime helpers
13
- export { resolveBoundValue, updateDataModel, getPathFromBoundValue, resolveActionContext, setPathValue, } from './src/runtime/bindingResolver.js';
14
- export { MessageDispatcher } from './src/runtime/dispatcher.js';
15
- export { SurfaceManager } from './src/runtime/surfaceManager.js';
16
- export { parseJSONLStream, isValidMessage } from './src/helpers/messageParser.js';
17
- export { defaultTheme } from './src/types.js';
1
+ // Wrapper components around @a2ui-sdk/react/0.8 with GLChat defaults
2
+ export { GlchatA2UIProvider, } from './src/a2ui/GlchatA2UIProvider.js';
3
+ export { GlchatA2UIRenderer, } from './src/a2ui/GlchatA2UIRenderer.js';
4
+ // GLChat catalog (extended upstream standard with custom components)
5
+ export { glchatStandardCatalog } from './src/a2ui/glchatStandardCatalog.js';
6
+ // Re-exports from @a2ui-sdk/react/0.8
7
+ export * from './src/a2ui/adapter.js';
@@ -0,0 +1,4 @@
1
+ import { type A2UIProviderProps } from '@a2ui-sdk/react/0.8';
2
+ export type GlchatA2UIProviderProps = A2UIProviderProps;
3
+ export declare function GlchatA2UIProvider(props: Readonly<GlchatA2UIProviderProps>): import("react/jsx-runtime").JSX.Element;
4
+ //# sourceMappingURL=GlchatA2UIProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlchatA2UIProvider.d.ts","sourceRoot":"","sources":["../../../src/a2ui/GlchatA2UIProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAG3E,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,CAAC;AAExD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,uBAAuB,CAAC,2CAI1E"}
@@ -0,0 +1,8 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { A2UIProvider } from '@a2ui-sdk/react/0.8';
4
+ import { glchatStandardCatalog } from './glchatStandardCatalog.js';
5
+ export function GlchatA2UIProvider(props) {
6
+ const catalog = props.catalog ?? glchatStandardCatalog;
7
+ return _jsx(A2UIProvider, { ...props, catalog: catalog });
8
+ }
@@ -0,0 +1,4 @@
1
+ import { type A2UIRendererProps } from '@a2ui-sdk/react/0.8';
2
+ export type GlchatA2UIRendererProps = A2UIRendererProps;
3
+ export declare function GlchatA2UIRenderer(props: Readonly<GlchatA2UIRendererProps>): import("react/jsx-runtime").JSX.Element;
4
+ //# sourceMappingURL=GlchatA2UIRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlchatA2UIRenderer.d.ts","sourceRoot":"","sources":["../../../src/a2ui/GlchatA2UIRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE3E,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,CAAC;AAExD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,uBAAuB,CAAC,2CAE1E"}
@@ -0,0 +1,6 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { A2UIRenderer } from '@a2ui-sdk/react/0.8';
4
+ export function GlchatA2UIRenderer(props) {
5
+ return _jsx(A2UIRenderer, { ...props });
6
+ }
@@ -0,0 +1,3 @@
1
+ export { ComponentRenderer, standardCatalog, useDispatchAction, useDataBinding, useFormBinding, useSurfaceContext, useDataModelContext, useA2UIMessageHandler, ActionProvider, useActionContext, type A2UIMessage, type A2UIAction, type Action, type ValueSource, type A2UIProviderProps, type A2UIRendererProps, type A2UIMessageHandler, type CatalogComponent, } from '@a2ui-sdk/react/0.8';
2
+ export * from '@a2ui-sdk/types/0.8/standard-catalog';
3
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/a2ui/adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,iBAAiB,EACjB,eAAe,EAEf,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EAErB,cAAc,EACd,gBAAgB,EAEhB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC;AAG7B,cAAc,sCAAsC,CAAC"}
@@ -0,0 +1,12 @@
1
+ /*
2
+ * Central adapter for the wrapper package.
3
+ */
4
+ export {
5
+ // Core components
6
+ ComponentRenderer, standardCatalog,
7
+ // Hooks
8
+ useDispatchAction, useDataBinding, useFormBinding, useSurfaceContext, useDataModelContext, useA2UIMessageHandler,
9
+ // Context providers
10
+ ActionProvider, useActionContext, } from '@a2ui-sdk/react/0.8';
11
+ // Re-exports standard catalog types
12
+ export * from '@a2ui-sdk/types/0.8/standard-catalog';
@@ -0,0 +1,10 @@
1
+ /** GLChat standard catalog: upstream standard catalog + custom Button, Card, Timeout. */
2
+ export declare const glchatStandardCatalog: {
3
+ components: {
4
+ Button: import("@a2ui-sdk/react/0.8").CatalogComponent;
5
+ Card: import("@a2ui-sdk/react/0.8").CatalogComponent;
6
+ Timeout: import("@a2ui-sdk/react/0.8").CatalogComponent;
7
+ };
8
+ functions?: import("@a2ui-sdk/react/0.8").CatalogFunctions;
9
+ };
10
+ //# sourceMappingURL=glchatStandardCatalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glchatStandardCatalog.d.ts","sourceRoot":"","sources":["../../../src/a2ui/glchatStandardCatalog.ts"],"names":[],"mappings":"AAKA,yFAAyF;AACzF,eAAO,MAAM,qBAAqB;;;;;;;CAQjC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { standardCatalog } from '@a2ui-sdk/react/0.8';
2
+ import { CustomButtonComponent } from '../components/custom/Button.js';
3
+ import { CustomCardComponent } from '../components/custom/Card.js';
4
+ import { CustomTimeoutComponent } from '../components/custom/Timeout.js';
5
+ /** GLChat standard catalog: upstream standard catalog + custom Button, Card, Timeout. */
6
+ export const glchatStandardCatalog = {
7
+ ...standardCatalog,
8
+ components: {
9
+ ...standardCatalog.components,
10
+ Button: CustomButtonComponent,
11
+ Card: CustomCardComponent,
12
+ Timeout: CustomTimeoutComponent,
13
+ },
14
+ };
@@ -0,0 +1,3 @@
1
+ import { type CatalogComponent } from '@a2ui-sdk/react/0.8';
2
+ export declare const CustomButtonComponent: CatalogComponent;
3
+ //# sourceMappingURL=Button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/components/custom/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAA;AAQ5B,eAAO,MAAM,qBAAqB,EAAE,gBAoBnC,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useDispatchAction, ComponentRenderer, } from '@a2ui-sdk/react/0.8';
3
+ import { Button } from '../ui/Button';
4
+ export const CustomButtonComponent = ({ surfaceId, componentId, ...props }) => {
5
+ const { child, action, primary, destructive } = props;
6
+ const dispatchAction = useDispatchAction();
7
+ const handleClick = () => {
8
+ if (action) {
9
+ dispatchAction(surfaceId, componentId, action);
10
+ }
11
+ };
12
+ const variant = destructive ? 'destructive' : primary ? 'primary' : 'outline';
13
+ return (_jsx(Button, { onClick: handleClick, variant: variant, children: child && _jsx(ComponentRenderer, { surfaceId: surfaceId, componentId: child }) }));
14
+ };
@@ -0,0 +1,3 @@
1
+ import { type CatalogComponent } from '@a2ui-sdk/react/0.8';
2
+ export declare const CustomCardComponent: CatalogComponent;
3
+ //# sourceMappingURL=Card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../../../src/components/custom/Card.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAqB,MAAM,qBAAqB,CAAA;AAI9E,eAAO,MAAM,mBAAmB,EAAE,gBAWjC,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ComponentRenderer } from '@a2ui-sdk/react/0.8';
3
+ import { Card } from '../ui/Card';
4
+ export const CustomCardComponent = ({ surfaceId, componentId, ...props }) => {
5
+ const { child } = props;
6
+ return (_jsx(Card, { children: child && _jsx(ComponentRenderer, { surfaceId: surfaceId, componentId: child }) }));
7
+ };
@@ -0,0 +1,3 @@
1
+ import { type CatalogComponent } from "@a2ui-sdk/react/0.8";
2
+ export declare const CustomTimeoutComponent: CatalogComponent;
3
+ //# sourceMappingURL=Timeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Timeout.d.ts","sourceRoot":"","sources":["../../../../src/components/custom/Timeout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAO3D,eAAO,MAAM,sBAAsB,EAAE,gBAOpC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Timeout } from "../ui/Timeout";
3
+ export const CustomTimeoutComponent = ({ surfaceId, componentId, ...props }) => {
4
+ const { targetTimeUtc } = props;
5
+ return _jsx(Timeout, { targetTimeUtc: targetTimeUtc });
6
+ };
@@ -1,12 +1,12 @@
1
1
  import { VariantProps } from 'class-variance-authority';
2
- export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
3
- asChild?: boolean;
4
- }
5
2
  declare const buttonVariants: (props?: ({
6
3
  variant?: "primary" | "secondary" | "destructive" | "destructive-subtle" | "outline" | "ghost-primary" | "ghost-neutral" | "ghost-destructive" | "link-primary" | "link-neutral" | null | undefined;
7
- size?: "icon" | "small" | "tiny" | "medium" | "large" | null | undefined;
4
+ size?: "tiny" | "small" | "medium" | "large" | "icon" | null | undefined;
8
5
  shape?: "normal" | "pill" | null | undefined;
9
6
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
+ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
8
+ asChild?: boolean;
9
+ }
10
10
  declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
11
11
  export { Button, buttonVariants };
12
12
  //# sourceMappingURL=Button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/Button.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAO,MAAM,0BAA0B,CAAC;AAE7D,QAAA,MAAM,cAAc;;;;8EAiFnB,CAAC;AAEF,MAAM,WAAW,WACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,YAAY,CAAC,OAAO,cAAc,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,QAAA,MAAM,MAAM,2GAsBX,CAAC;AAIF,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Slot } from '@radix-ui/react-slot';
3
+ import { forwardRef } from 'react';
4
+ import { cn } from '../../helpers/css.js';
5
+ import { cva } from 'class-variance-authority';
6
+ const buttonVariants = cva(cn('group inline-flex font-semibold border items-center justify-center whitespace-nowrap ring-offset-background transition-colors cursor-pointer', 'disabled:pointer-events-none disabled:opacity-secondary'), {
7
+ variants: {
8
+ variant: {
9
+ primary: cn('border-primary bg-primary text-primary-foreground', 'hover:border-primary-hover hover:bg-primary-hover', 'focus:bg-primary-hover focus:outline-none focus:ring-2 focus:ring-ring', 'focus-visible:bg-primary-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', 'active:bg-primary-hover active:outline-none active:ring-2 active:ring-ring'),
10
+ secondary: cn('border-primary-subtle bg-primary-subtle text-primary-subtle-foreground', 'hover:border-primary-subtle-hover hover:bg-primary-subtle-hover ', 'focus:border-primary-subtle-hover focus:bg-primary-subtle-hover focus:outline-none focus:ring-2 focus:ring-ring', 'focus-visible:border-primary-subtle-hover focus-visible:bg-primary-subtle-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', 'active:border-primary-subtle-hover active:bg-primary-subtle-hover active:outline-none active:ring-2 active:ring-ring'),
11
+ destructive: cn('border-destructive bg-destructive text-destructive-foreground', 'hover:border-destructive-hover hover:bg-destructive-hover', 'focus:bg-destructive-hover focus:border-destructive-hover focus:outline-none focus:ring-2 focus:ring-ring', 'focus-visible:bg-destructive-hover focus-visible:border-destructive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', 'active:bg-destructive-hover active:border-destructive-hover active:outline-none active:ring-2 active:ring-ring'),
12
+ 'destructive-subtle': cn('border-destructive-alternate bg-destructive-alternate text-destructive', 'hover:border-destructive-alternate-hover hover:bg-destructive-alternate-hover', 'focus:bg-destructive-alternate-hover focus:border-destructive-alternate-hover focus:outline-none focus:ring-2 focus:ring-ring', 'focus-visible:bg-destructive-alternate-hover focus-visible:border-destructive-alternate-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', 'active:bg-destructive-alternate-hover active:border-destructive-alternate-hover active:outline-none active:ring-2 active:ring-ring'),
13
+ outline: cn('bg-background text-foreground border-border', 'hover:bg-background-hover', 'focus:bg-background-hover', 'focus-visible:bg-background-hover', 'active:bg-background-hover'),
14
+ 'ghost-primary': cn('group-hover:underline group-hover:decoration-primary group-active:underline group-active:decoration-primary', 'text-primary border-transparent', 'hover:bg-primary-hover hover:border-primary-hover', 'focus:bg-primary-hover focus:border-primary-hover', 'focus-visible:bg-primary-hover focus-visible:border-primary-hover', 'active:bg-primary-hover active:border-primary-hover'),
15
+ 'ghost-neutral': cn('border-transparent text-foreground', 'hover:bg-background-hover hover:border-background-hover', 'focus:bg-background-hover focus:border-background-hover', 'focus-visible:bg-background-hover focus-visible:border-background-hover', 'active:bg-background-hover active:border-background-hover'),
16
+ 'ghost-destructive': cn('border-transparent text-destructive', 'hover:bg-destructive-alternate hover:border-destructive-alternate', 'focus:bg-destructive-alternate focus:border-destructive-alternate', 'focus-visible:bg-destructive-alternate focus-visible:border-destructive-alternate', 'active:bg-destructive-alternate active:border-destructive-alternate'),
17
+ 'link-primary': cn('border-transparent text-primary'),
18
+ 'link-neutral': cn('border-transparent text-foreground'),
19
+ },
20
+ size: {
21
+ tiny: 'text-sm px-[12px] py-[6px] rounded-[6px]',
22
+ small: 'text-base px-[16px] py-[8px] rounded-[8px]',
23
+ medium: 'text-base px-[16px] py-[10px] rounded-[10px]',
24
+ large: 'text-lg px-[20px] py-[10px] rounded-[12px]',
25
+ icon: 'h-10 w-10 rounded-[8px]',
26
+ },
27
+ shape: {
28
+ normal: '',
29
+ pill: 'rounded-full',
30
+ },
31
+ },
32
+ });
33
+ const Button = forwardRef(({ className, variant = 'primary', size = 'medium', shape = 'normal', asChild = false, ...props }, ref) => {
34
+ const Comp = asChild ? Slot : 'button';
35
+ return (_jsx(Comp, { className: cn(buttonVariants({ variant, size, shape }), className), ref: ref, ...props }));
36
+ });
37
+ Button.displayName = 'Button';
38
+ export { Button, buttonVariants };