glchat-a2ui-react-renderer 0.2.2 → 0.2.4

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.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { Provider, type ProviderProps, type A2UIMessage, type ActionPayload, type ActionHandler, } from './src/Provider.js';
1
+ export { Provider, type ProviderProps, type A2UIMessage, type ActionPayload, type ActionHandler, type MessageErrorHandler, } from './src/Provider.js';
2
2
  export { SingleSurfaceRenderer, type SingleSurfaceRendererProps, } from './src/SingleSurfaceRenderer.js';
3
3
  export { AllSurfacesRenderer, type AllSurfacesRendererProps } from './src/AllSurfacesRenderer.js';
4
4
  export { Types, ComponentRegistry, ComponentNode, useA2UIComponent, useA2UI, classMapToString, stylesToObject, type A2UIComponentProps, type Theme, type AnyComponentNode, type StringValue, type NumberValue, type BooleanValue, } from '@a2ui/react';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,GAChC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,KAAK,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAGlG,OAAO,EACL,KAAK,EACL,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,KAAK,EACV,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,mBAAmB,GACzB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,GAChC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,KAAK,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAGlG,OAAO,EACL,KAAK,EACL,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,KAAK,EACV,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC"}
@@ -4,10 +4,12 @@ import type { Theme } from '@a2ui/web_core/types/types';
4
4
  export type A2UIMessage = ServerToClientMessage;
5
5
  export type ActionPayload = A2UIActionEvent;
6
6
  export type ActionHandler = (action: ActionPayload) => void | Promise<void>;
7
+ export type MessageErrorHandler = (error: unknown) => void;
7
8
  export type ProviderProps = {
8
9
  messages?: A2UIMessage[];
9
10
  theme?: Theme;
10
11
  onAction?: ActionHandler;
12
+ onError?: MessageErrorHandler;
11
13
  children: ReactNode;
12
14
  /**
13
15
  * Optional registry override.
@@ -1 +1 @@
1
- {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../src/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAEL,iBAAiB,EAGjB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAKxD,MAAM,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAEhD,MAAM,MAAM,aAAa,GAAG,eAAe,CAAC;AAC5C,MAAM,MAAM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AQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B,CAAC;AA8BF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,2CA2CtD;AAED,wBAAgB,eAAe,IAAI,iBAAiB,CAInD"}
@@ -5,13 +5,24 @@ import { A2UIProvider, ComponentRegistry, useA2UI, } from '@a2ui/react';
5
5
  import { ensureGlchatComponentsRegistered } from './utils/catalog.js';
6
6
  import { mergeGlchatTheme } from './utils/theme.js';
7
7
  const A2UIRegistryContext = createContext(null);
8
- function MessagesProcessor({ messages }) {
8
+ function MessagesProcessor({ messages, onError, }) {
9
9
  const { processMessages } = useA2UI();
10
10
  useEffect(() => {
11
11
  if (!messages)
12
12
  return;
13
- processMessages(messages);
14
- }, [messages, processMessages]);
13
+ try {
14
+ processMessages(messages);
15
+ }
16
+ catch (error) {
17
+ if (onError) {
18
+ onError(error);
19
+ }
20
+ else {
21
+ // eslint-disable-next-line no-console
22
+ console.error('[glchat-a2ui] Failed to process messages:', error);
23
+ }
24
+ }
25
+ }, [messages, processMessages, onError]);
15
26
  return null;
16
27
  }
17
28
  export function Provider(props) {
@@ -40,7 +51,7 @@ export function Provider(props) {
40
51
  ensureGlchatComponentsRegistered(registry);
41
52
  }, [registry]);
42
53
  const theme = useMemo(() => mergeGlchatTheme(props.theme), [props.theme]);
43
- return (_jsx(A2UIRegistryContext.Provider, { value: registry, children: _jsxs(A2UIProvider, { onAction: onAction, theme: theme, children: [_jsx(MessagesProcessor, { messages: props.messages }), props.children] }) }));
54
+ return (_jsx(A2UIRegistryContext.Provider, { value: registry, children: _jsxs(A2UIProvider, { onAction: onAction, theme: theme, children: [_jsx(MessagesProcessor, { messages: props.messages, onError: props.onError }), props.children] }) }));
44
55
  }
45
56
  export function useA2UIRegistry() {
46
57
  const registry = useContext(A2UIRegistryContext);
@@ -1 +1 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,4BAA4B,CAAC;AAW7E,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,SAAS,GACV,EAAE,QAAQ,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,2CAyC1C"}
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAM7D,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,SAAS,GACV,EAAE,QAAQ,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,2CAwC1C"}
@@ -4,8 +4,7 @@ import { useMemo } from 'react';
4
4
  import { getGlchatButtonVariantStyles } from './theme';
5
5
  export function CustomButtonComponent({ node, surfaceId, }) {
6
6
  const { sendAction, theme } = useA2UIComponent(node, surfaceId);
7
- const nodeProps = node.properties;
8
- const { child, action, primary, destructive } = nodeProps;
7
+ const { child, action, primary, destructive } = node.properties;
9
8
  const variant = useMemo(() => {
10
9
  if (primary)
11
10
  return 'primary';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glchat-a2ui-react-renderer",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "A2UI (Agent-to-UI) React renderer for GLChat — render declarative UI from AI agent messages",
5
5
  "author": {
6
6
  "name": "GDP Labs",
@@ -34,12 +34,14 @@
34
34
  "README.md",
35
35
  "LICENSE",
36
36
  "tailwind.config.cjs",
37
- "styles"
37
+ "styles",
38
+ "patches"
38
39
  ],
39
40
  "scripts": {
40
41
  "build": "npm run build:ts",
41
42
  "build:ts": "tsc -p tsconfig.build.json",
42
43
  "prepare": "npm run build",
44
+ "postinstall": "patch-package",
43
45
  "lint": "eslint . && npx publint",
44
46
  "lint:pub": "npx publint",
45
47
  "format": "prettier --write .",
@@ -53,6 +55,8 @@
53
55
  },
54
56
  "dependencies": {
55
57
  "@a2ui/react": "^0.10.0",
58
+ "patch-package": "^8.0.1",
59
+ "@a2ui/web_core": "^0.10.0",
56
60
  "@radix-ui/react-checkbox": "^1.3.3",
57
61
  "@radix-ui/react-label": "^2.1.8",
58
62
  "@radix-ui/react-separator": "^1.1.8",
@@ -0,0 +1,55 @@
1
+ diff --git a/node_modules/@a2ui/web_core/src/v0_8/schema/common-types.d.ts b/node_modules/@a2ui/web_core/src/v0_8/schema/common-types.d.ts
2
+ index 9c7381f..bdc89a0 100644
3
+ --- a/node_modules/@a2ui/web_core/src/v0_8/schema/common-types.d.ts
4
+ +++ b/node_modules/@a2ui/web_core/src/v0_8/schema/common-types.d.ts
5
+ @@ -596,6 +596,7 @@ export declare const ButtonSchema: z.ZodObject<{
6
+ }[] | undefined;
7
+ }>;
8
+ primary: z.ZodOptional<z.ZodBoolean>;
9
+ + destructive: z.ZodOptional<z.ZodBoolean>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ child: string;
12
+ action: {
13
+ @@ -611,6 +612,7 @@ export declare const ButtonSchema: z.ZodObject<{
14
+ }[] | undefined;
15
+ };
16
+ primary?: boolean | undefined;
17
+ + destructive?: boolean | undefined;
18
+ }, {
19
+ child: string;
20
+ action: {
21
+ @@ -626,6 +628,7 @@ export declare const ButtonSchema: z.ZodObject<{
22
+ }[] | undefined;
23
+ };
24
+ primary?: boolean | undefined;
25
+ + destructive?: boolean | undefined;
26
+ }>;
27
+ export declare const CheckboxSchema: z.ZodObject<{
28
+ label: z.ZodEffects<z.ZodObject<{
29
+ diff --git a/node_modules/@a2ui/web_core/src/v0_8/schema/common-types.js b/node_modules/@a2ui/web_core/src/v0_8/schema/common-types.js
30
+ index 2dd98d4..54ebcef 100644
31
+ --- a/node_modules/@a2ui/web_core/src/v0_8/schema/common-types.js
32
+ +++ b/node_modules/@a2ui/web_core/src/v0_8/schema/common-types.js
33
+ @@ -223,6 +223,10 @@ export const ButtonSchema = z.object({
34
+ .boolean()
35
+ .optional()
36
+ .describe('Indicates if this button should be styled as the primary action.'),
37
+ + destructive: z
38
+ + .boolean()
39
+ + .optional()
40
+ + .describe('Indicates if this button should be styled as a destructive action.'),
41
+ });
42
+ export const CheckboxSchema = z.object({
43
+ label: StringValueSchema,
44
+ diff --git a/node_modules/@a2ui/web_core/src/v0_8/types/types.d.ts b/node_modules/@a2ui/web_core/src/v0_8/types/types.d.ts
45
+ index d5df150..ca74153 100644
46
+ --- a/node_modules/@a2ui/web_core/src/v0_8/types/types.d.ts
47
+ +++ b/node_modules/@a2ui/web_core/src/v0_8/types/types.d.ts
48
+ @@ -376,6 +376,7 @@ export declare interface ResolvedButton {
49
+ child: AnyComponentNode;
50
+ action: Button['action'];
51
+ primary?: boolean;
52
+ + destructive?: boolean;
53
+ }
54
+ export declare interface ResolvedList {
55
+ children: AnyComponentNode[];