glchat-a2ui-react-renderer 0.3.0 → 0.3.2

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 (149) hide show
  1. package/README.md +59 -10
  2. package/dist/index.d.ts +8 -7
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +9 -8
  5. package/dist/src/Provider.d.ts +26 -17
  6. package/dist/src/Provider.d.ts.map +1 -1
  7. package/dist/src/Provider.js +41 -51
  8. package/dist/src/SurfaceRenderer.d.ts +2 -4
  9. package/dist/src/SurfaceRenderer.d.ts.map +1 -1
  10. package/dist/src/SurfaceRenderer.js +8 -21
  11. package/dist/src/components/a2ui/v0_8/Button/Button.d.ts +4 -0
  12. package/dist/src/components/a2ui/v0_8/Button/Button.d.ts.map +1 -0
  13. package/dist/src/components/a2ui/v0_8/Button/Button.js +18 -0
  14. package/dist/src/components/a2ui/v0_8/Button/theme.d.ts +4 -0
  15. package/dist/src/components/a2ui/v0_8/Button/theme.d.ts.map +1 -0
  16. package/dist/src/components/a2ui/v0_8/Button/theme.js +4 -0
  17. package/dist/src/components/a2ui/v0_8/ButtonAsLink/ButtonAsLink.d.ts +4 -0
  18. package/dist/src/components/a2ui/v0_8/ButtonAsLink/ButtonAsLink.d.ts.map +1 -0
  19. package/dist/src/components/a2ui/v0_8/ButtonAsLink/ButtonAsLink.js +43 -0
  20. package/dist/src/components/a2ui/v0_8/ButtonAsLink/theme.d.ts +7 -0
  21. package/dist/src/components/a2ui/v0_8/ButtonAsLink/theme.d.ts.map +1 -0
  22. package/dist/src/components/a2ui/v0_8/ButtonAsLink/theme.js +7 -0
  23. package/dist/src/components/a2ui/v0_8/Card/theme.d.ts +4 -0
  24. package/dist/src/components/a2ui/v0_8/Card/theme.d.ts.map +1 -0
  25. package/dist/src/components/a2ui/v0_8/Card/theme.js +15 -0
  26. package/dist/src/components/a2ui/v0_8/DateTimeInput/theme.d.ts +7 -0
  27. package/dist/src/components/a2ui/v0_8/DateTimeInput/theme.d.ts.map +1 -0
  28. package/dist/src/components/a2ui/v0_8/DateTimeInput/theme.js +9 -0
  29. package/dist/src/components/a2ui/v0_8/DestructiveButton/DestructiveButton.d.ts +4 -0
  30. package/dist/src/components/a2ui/v0_8/DestructiveButton/DestructiveButton.d.ts.map +1 -0
  31. package/dist/src/components/a2ui/v0_8/DestructiveButton/DestructiveButton.js +23 -0
  32. package/dist/src/components/a2ui/v0_8/DestructiveButton/theme.d.ts +7 -0
  33. package/dist/src/components/a2ui/v0_8/DestructiveButton/theme.d.ts.map +1 -0
  34. package/dist/src/components/a2ui/v0_8/DestructiveButton/theme.js +7 -0
  35. package/dist/src/components/a2ui/v0_8/MultipleChoice/MultipleChoice.d.ts +4 -0
  36. package/dist/src/components/a2ui/v0_8/MultipleChoice/MultipleChoice.d.ts.map +1 -0
  37. package/dist/src/components/a2ui/v0_8/MultipleChoice/MultipleChoice.js +72 -0
  38. package/dist/src/components/a2ui/v0_8/TagInput/TagInput.d.ts +4 -0
  39. package/dist/src/components/a2ui/v0_8/TagInput/TagInput.d.ts.map +1 -0
  40. package/dist/src/components/a2ui/v0_8/TagInput/TagInput.js +49 -0
  41. package/dist/src/components/a2ui/v0_8/TagInput/theme.d.ts +11 -0
  42. package/dist/src/components/a2ui/v0_8/TagInput/theme.d.ts.map +1 -0
  43. package/dist/src/components/a2ui/v0_8/TagInput/theme.js +9 -0
  44. package/dist/src/components/a2ui/v0_8/TextField/theme.d.ts +7 -0
  45. package/dist/src/components/a2ui/v0_8/TextField/theme.d.ts.map +1 -0
  46. package/dist/src/components/a2ui/v0_8/TextField/theme.js +9 -0
  47. package/dist/src/components/a2ui/v0_8/Timeout/Timeout.d.ts +4 -0
  48. package/dist/src/components/a2ui/v0_8/Timeout/Timeout.d.ts.map +1 -0
  49. package/dist/src/components/a2ui/v0_8/Timeout/Timeout.js +29 -0
  50. package/dist/src/components/a2ui/v0_8/Timeout/theme.d.ts +8 -0
  51. package/dist/src/components/a2ui/v0_8/Timeout/theme.d.ts.map +1 -0
  52. package/dist/src/components/a2ui/v0_8/Timeout/theme.js +12 -0
  53. package/dist/src/components/a2ui/v0_8/types.d.ts +12 -0
  54. package/dist/src/components/a2ui/v0_8/types.d.ts.map +1 -0
  55. package/dist/src/components/a2ui/v0_8/types.js +1 -0
  56. package/dist/src/components/a2ui/v0_9/Button/Button.d.ts.map +1 -0
  57. package/dist/src/components/a2ui/{Button → v0_9/Button}/Button.js +1 -1
  58. package/dist/src/components/a2ui/v0_9/ChoicePicker/ChoicePicker.d.ts.map +1 -0
  59. package/dist/src/components/a2ui/{ChoicePicker → v0_9/ChoicePicker}/ChoicePicker.js +4 -4
  60. package/dist/src/components/a2ui/v0_9/ChoicePicker/theme.d.ts +4 -0
  61. package/dist/src/components/a2ui/v0_9/ChoicePicker/theme.d.ts.map +1 -0
  62. package/dist/src/components/a2ui/v0_9/ChoicePicker/theme.js +11 -0
  63. package/dist/src/components/a2ui/{TagInput → v0_9/TagInput}/TagInput.d.ts +32 -32
  64. package/dist/src/components/a2ui/v0_9/TagInput/TagInput.d.ts.map +1 -0
  65. package/dist/src/components/a2ui/v0_9/TagInput/TagInput.js +40 -0
  66. package/dist/src/components/a2ui/v0_9/Timeout/Timeout.d.ts.map +1 -0
  67. package/dist/src/components/a2ui/{Timeout → v0_9/Timeout}/Timeout.js +1 -1
  68. package/dist/src/components/a2ui/v0_9/common.d.ts.map +1 -0
  69. package/dist/src/components/ui/Button/Button.d.ts.map +1 -1
  70. package/dist/src/components/ui/Button/Button.js +2 -2
  71. package/dist/src/components/ui/Button/ButtonAsLink.d.ts +15 -0
  72. package/dist/src/components/ui/Button/ButtonAsLink.d.ts.map +1 -0
  73. package/dist/src/components/ui/Button/ButtonAsLink.js +17 -0
  74. package/dist/src/components/ui/Checkbox/Checkbox.d.ts.map +1 -1
  75. package/dist/src/components/ui/Checkbox/Checkbox.js +2 -2
  76. package/dist/src/components/{a2ui/ChoicePicker → ui/CheckboxList}/CheckboxList.d.ts +3 -2
  77. package/dist/src/components/ui/CheckboxList/CheckboxList.d.ts.map +1 -0
  78. package/dist/src/components/{a2ui/ChoicePicker → ui/CheckboxList}/CheckboxList.js +16 -5
  79. package/dist/src/components/{a2ui/ChoicePicker → ui/CheckboxList}/theme.d.ts +0 -5
  80. package/dist/src/components/ui/CheckboxList/theme.d.ts.map +1 -0
  81. package/dist/src/components/{a2ui/ChoicePicker → ui/CheckboxList}/theme.js +0 -14
  82. package/dist/src/components/ui/MultiSelect/MultiSelect.d.ts.map +1 -1
  83. package/dist/src/components/ui/MultiSelect/MultiSelect.js +2 -3
  84. package/dist/src/components/ui/Select/Select.d.ts.map +1 -1
  85. package/dist/src/components/ui/Select/Select.js +2 -1
  86. package/dist/src/components/ui/TagInput/TagInput.d.ts +18 -0
  87. package/dist/src/components/ui/TagInput/TagInput.d.ts.map +1 -0
  88. package/dist/src/components/{a2ui → ui}/TagInput/TagInput.js +16 -48
  89. package/dist/src/components/ui/TagInput/theme.d.ts.map +1 -0
  90. package/dist/src/components/{a2ui → ui}/TagInput/theme.js +1 -1
  91. package/dist/src/utils/css.d.ts +4 -0
  92. package/dist/src/utils/css.d.ts.map +1 -0
  93. package/dist/src/utils/css.js +5 -0
  94. package/dist/src/utils/detectVersion.d.ts +9 -0
  95. package/dist/src/utils/detectVersion.d.ts.map +1 -0
  96. package/dist/src/utils/detectVersion.js +29 -0
  97. package/dist/src/utils/href.d.ts +11 -0
  98. package/dist/src/utils/href.d.ts.map +1 -0
  99. package/dist/src/utils/href.js +34 -0
  100. package/dist/src/v0_8/Provider.d.ts +17 -0
  101. package/dist/src/v0_8/Provider.d.ts.map +1 -0
  102. package/dist/src/v0_8/Provider.js +59 -0
  103. package/dist/src/v0_8/SurfaceRenderer.d.ts +3 -0
  104. package/dist/src/v0_8/SurfaceRenderer.d.ts.map +1 -0
  105. package/dist/src/v0_8/SurfaceRenderer.js +21 -0
  106. package/dist/src/v0_8/registry.d.ts +12 -0
  107. package/dist/src/v0_8/registry.d.ts.map +1 -0
  108. package/dist/src/v0_8/registry.js +35 -0
  109. package/dist/src/v0_8/theme.d.ts +11 -0
  110. package/dist/src/v0_8/theme.d.ts.map +1 -0
  111. package/dist/src/v0_8/theme.js +77 -0
  112. package/dist/src/v0_9/Provider.d.ts +16 -0
  113. package/dist/src/v0_9/Provider.d.ts.map +1 -0
  114. package/dist/src/v0_9/Provider.js +65 -0
  115. package/dist/src/v0_9/SurfaceRenderer.d.ts +3 -0
  116. package/dist/src/v0_9/SurfaceRenderer.d.ts.map +1 -0
  117. package/dist/src/v0_9/SurfaceRenderer.js +21 -0
  118. package/dist/src/{utils → v0_9}/catalog.d.ts +8 -3
  119. package/dist/src/v0_9/catalog.d.ts.map +1 -0
  120. package/dist/src/{utils → v0_9}/catalog.js +30 -6
  121. package/dist/src/v0_9/useSurfaces.d.ts.map +1 -0
  122. package/json/README.md +24 -42
  123. package/json/v0_8/a2ui-sample-messages.json +2024 -0
  124. package/json/v0_8/glchat_standard_catalog_definition.json +870 -0
  125. package/json/{a2ui-sample-messages.json → v0_9/a2ui-sample-messages.json} +12 -2
  126. package/json/{glchat_standard_catalog_definition.json → v0_9/glchat_standard_catalog_definition.json} +286 -68
  127. package/package.json +4 -5
  128. package/styles/globals.css +157 -68
  129. package/dist/src/components/a2ui/Button/Button.d.ts.map +0 -1
  130. package/dist/src/components/a2ui/ChoicePicker/CheckboxList.d.ts.map +0 -1
  131. package/dist/src/components/a2ui/ChoicePicker/ChoicePicker.d.ts.map +0 -1
  132. package/dist/src/components/a2ui/ChoicePicker/theme.d.ts.map +0 -1
  133. package/dist/src/components/a2ui/TagInput/TagInput.d.ts.map +0 -1
  134. package/dist/src/components/a2ui/TagInput/theme.d.ts.map +0 -1
  135. package/dist/src/components/a2ui/Timeout/Timeout.d.ts.map +0 -1
  136. package/dist/src/components/a2ui/common.d.ts.map +0 -1
  137. package/dist/src/components/ui/Checkbox/theme.d.ts +0 -5
  138. package/dist/src/components/ui/Checkbox/theme.d.ts.map +0 -1
  139. package/dist/src/components/ui/Checkbox/theme.js +0 -26
  140. package/dist/src/utils/catalog.d.ts.map +0 -1
  141. package/dist/src/utils/useSurfaces.d.ts.map +0 -1
  142. /package/dist/src/components/a2ui/{Button → v0_9/Button}/Button.d.ts +0 -0
  143. /package/dist/src/components/a2ui/{ChoicePicker → v0_9/ChoicePicker}/ChoicePicker.d.ts +0 -0
  144. /package/dist/src/components/a2ui/{Timeout → v0_9/Timeout}/Timeout.d.ts +0 -0
  145. /package/dist/src/components/a2ui/{common.d.ts → v0_9/common.d.ts} +0 -0
  146. /package/dist/src/components/a2ui/{common.js → v0_9/common.js} +0 -0
  147. /package/dist/src/components/{a2ui → ui}/TagInput/theme.d.ts +0 -0
  148. /package/dist/src/{utils → v0_9}/useSurfaces.d.ts +0 -0
  149. /package/dist/src/{utils → v0_9}/useSurfaces.js +0 -0
@@ -0,0 +1,77 @@
1
+ import { litTheme } from '@a2ui/react/v0_8';
2
+ import { buttonComponents } from '../components/a2ui/v0_8/Button/theme.js';
3
+ import { buttonAsLinkComponents } from '../components/a2ui/v0_8/ButtonAsLink/theme.js';
4
+ import { cardAdditionalStyles, cardComponents } from '../components/a2ui/v0_8/Card/theme.js';
5
+ import { dateTimeInputComponents } from '../components/a2ui/v0_8/DateTimeInput/theme.js';
6
+ import { destructiveButtonComponents } from '../components/a2ui/v0_8/DestructiveButton/theme.js';
7
+ import { textFieldComponents } from '../components/a2ui/v0_8/TextField/theme.js';
8
+ /** GLChat-owned component class maps merged into the default A2UI theme. */
9
+ const components = {
10
+ ...litTheme.components,
11
+ Card: cardComponents,
12
+ Button: buttonComponents,
13
+ TextField: textFieldComponents,
14
+ DateTimeInput: dateTimeInputComponents,
15
+ DestructiveButton: destructiveButtonComponents,
16
+ ButtonAsLink: buttonAsLinkComponents,
17
+ };
18
+ /** GLChat-owned inline style overrides merged into the default A2UI theme. */
19
+ const additionalStyles = {
20
+ ...litTheme.additionalStyles,
21
+ Card: { ...cardAdditionalStyles },
22
+ };
23
+ /**
24
+ * Default theme passed to Provider. Starts from upstream litTheme and layers
25
+ * GLChat component class maps and inline styles from each a2ui component theme file.
26
+ */
27
+ export const glchatDefaultTheme = {
28
+ ...litTheme,
29
+ components,
30
+ additionalStyles,
31
+ };
32
+ const DEEP_MERGE_COMPONENT_KEYS = [
33
+ 'Card',
34
+ 'Button',
35
+ 'TextField',
36
+ 'DateTimeInput',
37
+ 'DestructiveButton',
38
+ 'ButtonAsLink',
39
+ ];
40
+ function mergeSection(base, patch, deepMergeKeys) {
41
+ if (!patch)
42
+ return base;
43
+ const merged = { ...base, ...patch };
44
+ for (const key of deepMergeKeys) {
45
+ if (patch[key] === undefined)
46
+ continue;
47
+ if (!(key in base))
48
+ continue;
49
+ merged[key] = {
50
+ ...base[key],
51
+ ...patch[key],
52
+ };
53
+ }
54
+ return merged;
55
+ }
56
+ /**
57
+ * Merges consumer overrides into glchatDefaultTheme.
58
+ */
59
+ export function mergeGlchatTheme(override) {
60
+ if (!override) {
61
+ return glchatDefaultTheme;
62
+ }
63
+ const mergedComponents = mergeSection(components, override.components, DEEP_MERGE_COMPONENT_KEYS);
64
+ const mergedAdditionalStyles = mergeSection(additionalStyles, override.additionalStyles, DEEP_MERGE_COMPONENT_KEYS);
65
+ return {
66
+ ...glchatDefaultTheme,
67
+ ...override,
68
+ components: mergedComponents,
69
+ elements: override.elements
70
+ ? { ...glchatDefaultTheme.elements, ...override.elements }
71
+ : glchatDefaultTheme.elements,
72
+ markdown: override.markdown
73
+ ? { ...glchatDefaultTheme.markdown, ...override.markdown }
74
+ : glchatDefaultTheme.markdown,
75
+ additionalStyles: mergedAdditionalStyles,
76
+ };
77
+ }
@@ -0,0 +1,16 @@
1
+ import type { PropsWithChildren } from 'react';
2
+ import { type ReactComponentImplementation } from '@a2ui/react/v0_9';
3
+ import { type Catalog, type A2uiClientAction, type SurfaceGroupModel } from '@a2ui/web_core/v0_9';
4
+ import type { V09Message } from '../utils/detectVersion.js';
5
+ export type V09ActionPayload = A2uiClientAction;
6
+ export type V09ActionHandler = (action: A2uiClientAction) => void | Promise<void>;
7
+ export type V09MessageErrorHandler = (error: unknown) => void;
8
+ export type V09ProviderProps = {
9
+ messages?: V09Message[];
10
+ onAction?: V09ActionHandler;
11
+ onError?: V09MessageErrorHandler;
12
+ catalog?: Catalog<ReactComponentImplementation>;
13
+ };
14
+ export declare function V09Provider({ messages, onAction, onError, catalog, children, }: Readonly<PropsWithChildren<V09ProviderProps>>): import("react").JSX.Element;
15
+ export declare function useSurfaceGroup(): SurfaceGroupModel<ReactComponentImplementation>;
16
+ //# sourceMappingURL=Provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/v0_9/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,OAAO,EAAmB,KAAK,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAG5D,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAChD,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAClF,MAAM,MAAM,sBAAsB,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC,4BAA4B,CAAC,CAAC;CACjD,CAAC;AAMF,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,OAAO,EACP,QAAQ,GACT,EAAE,QAAQ,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,+BAgE/C;AAED,wBAAgB,eAAe,IAAI,iBAAiB,CAAC,4BAA4B,CAAC,CAIjF"}
@@ -0,0 +1,65 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext, useEffect, useRef, useState } from 'react';
4
+ import { MarkdownContext } from '@a2ui/react/v0_9';
5
+ import { MessageProcessor, } from '@a2ui/web_core/v0_9';
6
+ import { injectBasicCatalogStyles } from '@a2ui/web_core/v0_9/basic_catalog';
7
+ import { renderMarkdown } from '@a2ui/markdown-it';
8
+ import { createGlchatCatalog, GLCHAT_CATALOG_ID, withFallbackCatalogId } from './catalog.js';
9
+ const SurfaceGroupContext = createContext(null);
10
+ export function V09Provider({ messages, onAction, onError, catalog, children, }) {
11
+ const onActionRef = useRef(onAction);
12
+ const onErrorRef = useRef(onError);
13
+ useEffect(() => {
14
+ onActionRef.current = onAction;
15
+ }, [onAction]);
16
+ useEffect(() => {
17
+ onErrorRef.current = onError;
18
+ }, [onError]);
19
+ const [processor] = useState(() => {
20
+ const resolvedCatalog = catalog ?? createGlchatCatalog();
21
+ return new MessageProcessor([resolvedCatalog]);
22
+ });
23
+ const processedCountRef = useRef(0);
24
+ useEffect(() => {
25
+ const subscription = processor.model.onAction.subscribe((action) => {
26
+ onActionRef.current?.(action);
27
+ });
28
+ return () => subscription.unsubscribe();
29
+ }, [processor]);
30
+ useEffect(() => {
31
+ if (typeof document !== 'undefined' && document.adoptedStyleSheets) {
32
+ injectBasicCatalogStyles();
33
+ }
34
+ }, []);
35
+ useEffect(() => {
36
+ if (!messages?.length)
37
+ return;
38
+ if (messages.length < processedCountRef.current) {
39
+ processedCountRef.current = 0;
40
+ }
41
+ if (processedCountRef.current >= messages.length)
42
+ return;
43
+ const pending = withFallbackCatalogId(messages.slice(processedCountRef.current), catalog?.id ?? GLCHAT_CATALOG_ID);
44
+ processedCountRef.current = messages.length;
45
+ try {
46
+ processor.processMessages(pending);
47
+ }
48
+ catch (error) {
49
+ if (onErrorRef.current) {
50
+ onErrorRef.current(error);
51
+ }
52
+ else {
53
+ // eslint-disable-next-line no-console
54
+ console.error('[glchat-a2ui] Failed to process v0.9 messages:', error);
55
+ }
56
+ }
57
+ }, [messages, processor]);
58
+ return (_jsx(SurfaceGroupContext.Provider, { value: processor.model, children: _jsx(MarkdownContext.Provider, { value: renderMarkdown, children: children }) }));
59
+ }
60
+ export function useSurfaceGroup() {
61
+ const model = useContext(SurfaceGroupContext);
62
+ if (!model)
63
+ throw new Error('useSurfaceGroup must be used inside Provider (v0.9)');
64
+ return model;
65
+ }
@@ -0,0 +1,3 @@
1
+ import type { SurfaceRendererProps } from '../SurfaceRenderer.js';
2
+ export declare function V09SurfaceRenderer(props: Readonly<SurfaceRendererProps>): import("react").JSX.Element;
3
+ //# sourceMappingURL=SurfaceRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SurfaceRenderer.d.ts","sourceRoot":"","sources":["../../../src/v0_9/SurfaceRenderer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAMlE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,+BA4BvE"}
@@ -0,0 +1,21 @@
1
+ 'use client';
2
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
+ import { A2uiSurface } from '@a2ui/react/v0_9';
4
+ import { useSurfaceGroup } from './Provider.js';
5
+ import { useSurfaces } from './useSurfaces.js';
6
+ const DEFAULT_FALLBACK = _jsx(_Fragment, {});
7
+ export function V09SurfaceRenderer(props) {
8
+ const model = useSurfaceGroup();
9
+ const surfaces = useSurfaces(model);
10
+ const fallback = props.fallback ?? DEFAULT_FALLBACK;
11
+ const surfaceClassName = props.className ? `a2ui-surface ${props.className}` : 'a2ui-surface';
12
+ if (props.surfaceId !== undefined) {
13
+ const surface = model.getSurface(props.surfaceId);
14
+ if (!surface)
15
+ return _jsx(_Fragment, { children: fallback });
16
+ return (_jsx("div", { className: surfaceClassName, children: _jsx(A2uiSurface, { surface: surface }) }));
17
+ }
18
+ if (surfaces.length === 0)
19
+ return _jsx(_Fragment, { children: fallback });
20
+ return (_jsx(_Fragment, { children: surfaces.map((surface) => (_jsx("div", { className: surfaceClassName, children: _jsx(A2uiSurface, { surface: surface }) }, surface.id))) }));
21
+ }
@@ -1,8 +1,7 @@
1
1
  import { type ReactComponentImplementation } from '@a2ui/react/v0_9';
2
- import { Catalog } from '@a2ui/web_core/v0_9';
2
+ import { Catalog, type A2uiMessage } from '@a2ui/web_core/v0_9';
3
3
  /**
4
- * Catalog identifier for the GLChat extended A2UI v0.9 catalog. Used as the
5
- * `catalogId` in `createSurface` messages targeting the GLChat renderer.
4
+ * Catalog identifier for the GLChat extended A2UI v0.9 catalog.
6
5
  */
7
6
  export declare const GLCHAT_CATALOG_ID = "https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/glchat_standard_catalog_definition.json";
8
7
  /** Basic catalog components whose JSON Schema is regenerated from Zod. */
@@ -16,4 +15,10 @@ export declare const GLCHAT_CATALOG_EXTENSIONS: readonly ["TagInput", "Timeout"]
16
15
  * - Reuses basic catalog functions unchanged.
17
16
  */
18
17
  export declare function createGlchatCatalog(): Catalog<ReactComponentImplementation>;
18
+ /**
19
+ * Rewrites `createSurface.catalogId` to the given `registeredId` when the
20
+ * message uses an unrecognized catalog. This prevents "Catalog not found"
21
+ * errors from the upstream `MessageProcessor`.
22
+ */
23
+ export declare function withFallbackCatalogId(messages: A2uiMessage[], registeredId: string): A2uiMessage[];
19
24
  //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/v0_9/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAOhE;;GAEG;AACH,eAAO,MAAM,iBAAiB,iIACkG,CAAC;AAKjI,0EAA0E;AAC1E,eAAO,MAAM,wBAAwB,qBAAsB,CAAC;AAE5D,+DAA+D;AAC/D,eAAO,MAAM,yBAAyB,kCAAmC,CAAC;AAE1E;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,4BAA4B,CAAC,CAgB3E;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,WAAW,EAAE,EACvB,YAAY,EAAE,MAAM,GACnB,WAAW,EAAE,CAqBf"}
@@ -1,12 +1,11 @@
1
1
  import { basicCatalog } from '@a2ui/react/v0_9';
2
2
  import { Catalog } from '@a2ui/web_core/v0_9';
3
- import { GlchatButtonComponent } from '../components/a2ui/Button/Button.js';
4
- import { GlchatChoicePickerComponent } from '../components/a2ui/ChoicePicker/ChoicePicker.js';
5
- import { GlchatTagInputComponent } from '../components/a2ui/TagInput/TagInput.js';
6
- import { GlchatTimeoutComponent } from '../components/a2ui/Timeout/Timeout.js';
3
+ import { GlchatButtonComponent } from '../components/a2ui/v0_9/Button/Button.js';
4
+ import { GlchatChoicePickerComponent } from '../components/a2ui/v0_9/ChoicePicker/ChoicePicker.js';
5
+ import { GlchatTagInputComponent } from '../components/a2ui/v0_9/TagInput/TagInput.js';
6
+ import { GlchatTimeoutComponent } from '../components/a2ui/v0_9/Timeout/Timeout.js';
7
7
  /**
8
- * Catalog identifier for the GLChat extended A2UI v0.9 catalog. Used as the
9
- * `catalogId` in `createSurface` messages targeting the GLChat renderer.
8
+ * Catalog identifier for the GLChat extended A2UI v0.9 catalog.
10
9
  */
11
10
  export const GLCHAT_CATALOG_ID = 'https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/glchat_standard_catalog_definition.json';
12
11
  /** Basic catalog components overridden at runtime by GLChat implementations. */
@@ -33,3 +32,28 @@ export function createGlchatCatalog() {
33
32
  const functions = Array.from(basicCatalog.functions.values());
34
33
  return new Catalog(GLCHAT_CATALOG_ID, components, functions);
35
34
  }
35
+ /**
36
+ * Rewrites `createSurface.catalogId` to the given `registeredId` when the
37
+ * message uses an unrecognized catalog. This prevents "Catalog not found"
38
+ * errors from the upstream `MessageProcessor`.
39
+ */
40
+ export function withFallbackCatalogId(messages, registeredId) {
41
+ return messages.map((msg) => {
42
+ if (msg &&
43
+ typeof msg === 'object' &&
44
+ 'createSurface' in msg &&
45
+ msg.createSurface &&
46
+ typeof msg.createSurface === 'object' &&
47
+ 'catalogId' in msg.createSurface &&
48
+ msg.createSurface.catalogId !== registeredId) {
49
+ return {
50
+ ...msg,
51
+ createSurface: {
52
+ ...msg.createSurface,
53
+ catalogId: registeredId,
54
+ },
55
+ };
56
+ }
57
+ return msg;
58
+ });
59
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSurfaces.d.ts","sourceRoot":"","sources":["../../../src/v0_9/useSurfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAG3E;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,iBAAiB,CAAC,4BAA4B,CAAC,GACrD,YAAY,CAAC,4BAA4B,CAAC,EAAE,CA6B9C"}
package/json/README.md CHANGED
@@ -1,61 +1,43 @@
1
1
  # JSON reference files
2
2
 
3
- This folder contains JSON schema and sample payload files for the GLChat A2UI React renderer.
4
-
5
- These files are generated from the official A2UI v0.9 basic catalog plus GLChat
6
- extensions. To regenerate the catalog JSON after changing a component schema, run:
7
-
8
- ```bash
9
- npm run generate:json
10
- ```
3
+ This folder contains JSON schema and sample payload files for the GLChat A2UI React renderer, split by schema version under `v0_8/` and `v0_9/`.
11
4
 
12
5
  ---
13
6
 
14
- ## `glchat_standard_catalog_definition.json` — GLChat component catalog
7
+ ## v0.9 files (`v0_9/`)
15
8
 
16
- The GLChat extended A2UI **v0.9** unified catalog (components **and** functions).
17
- It **extends** the official basic catalog JSON Schema (same structure as the
18
- [rizzcharts custom catalog example](https://github.com/a2ui-project/a2ui/blob/main/samples/community/agent/adk/rizzcharts/catalog_schemas/0.9/rizzcharts_catalog_definition.json)):
19
- clone [basic/catalog.json](https://github.com/a2ui-project/a2ui/blob/main/specification/v0_9/catalogs/basic/catalog.json),
20
- normalize `common_types.json` refs, then merge GLChat overrides and extensions
21
- generated from the live Zod component APIs.
9
+ ### `v0_9/glchat_standard_catalog_definition.json`
22
10
 
23
- **Base specification:** [a2ui-project/a2ui — A2UI v0.9 basic catalog](https://github.com/a2ui-project/a2ui/blob/main/specification/v0_9/catalogs/basic/catalog.json)
11
+ The GLChat extended A2UI **v0.9** unified catalog.
24
12
 
25
13
  **Catalog ID:** `https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/glchat_standard_catalog_definition.json`
26
14
 
27
- The GLChat catalog keeps the v0.9 basic catalog and adds/overrides:
28
-
29
- 1. **`Button`** (override) — GLChat-styled button. Extends the basic catalog schema
30
- with a `destructive` variant.
15
+ **Base specification:** [A2UI v0.9 basic catalog](https://github.com/a2ui-project/a2ui/blob/main/specification/v0_9/catalogs/basic/catalog.json)
31
16
 
32
- 2. **`ChoicePicker`** (override) — GLChat-styled choice picker. Schema matches the
33
- basic catalog.
17
+ GLChat overrides/extensions: `Button`, `ChoicePicker`, `TagInput`, `Timeout`.
34
18
 
35
- 3. **`TagInput`** (extension) — tag input field. `label`, `value` (string array),
36
- `placeholder`, `disabled`, `disableTextInput`, `validationRegexp`,
37
- `validationErrorMessage`.
19
+ To regenerate the v0.9 catalog JSON after changing a component schema, run:
38
20
 
39
- 4. **`Timeout`** (extension) — countdown to a target UTC time. `targetTimeUtc`
40
- (ISO 8601) and optional `variant` text style (`body`, `caption`, `h3`, `h4`, `h5`).
21
+ ```bash
22
+ npm run generate:json
23
+ ```
41
24
 
42
- ### Components
25
+ ### `v0_9/a2ui-sample-messages.json`
43
26
 
44
- | Component | Source |
45
- |---|---|
46
- | Text, Image, Icon, Video, AudioPlayer | v0.9 basic catalog |
47
- | Row, Column, List, Card, Tabs, Divider, Modal | v0.9 basic catalog |
48
- | TextField, CheckBox, Slider, DateTimeInput | v0.9 basic catalog |
49
- | Button | GLChat override |
50
- | ChoicePicker | GLChat override |
51
- | TagInput | GLChat extension |
52
- | Timeout | GLChat extension |
27
+ A2UI **v0.9** sample messages (`createSurface`, `updateDataModel`, `updateComponents`) for surface `"main"`.
53
28
 
54
29
  ---
55
30
 
56
- ## `a2ui-sample-messages.json` — sample message sequence (all components)
31
+ ## v0.8 files (`v0_8/`)
32
+
33
+ ### `v0_8/glchat_standard_catalog_definition.json`
34
+
35
+ The GLChat extended A2UI **v0.8** catalog. Extends the [v0.8 standard catalog](https://a2ui.org/specification/v0_8/standard_catalog_definition.json) with `ButtonAsLink`, `DestructiveButton`, `TagInput`, and `Timeout`.
36
+
37
+ **Catalog ID:** `https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/v0_8/glchat_standard_catalog_definition.json`
38
+
39
+ When `beginRendering` omits `catalogId`, `Provider` injects this catalog ID automatically.
40
+
41
+ ### `v0_8/a2ui-sample-messages.json`
57
42
 
58
- A JSON array of A2UI **v0.9** messages (`createSurface`, `updateDataModel`,
59
- `updateComponents`) describing a surface that includes **every component** from the
60
- catalog. Validated against the catalog during generation. Use for reference and
61
- testing.
43
+ A2UI **v0.8** sample messages (`beginRendering`, `surfaceUpdate`) for surface `"all-components-demo"`. Demonstrates standard catalog components plus GLChat-styled `Button` and `MultipleChoice` variants.