@lynx-js/genui 0.0.2 → 0.0.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/README.md +5 -9
- package/a2ui/AGENTS.md +167 -0
- package/a2ui/README.md +76 -780
- package/a2ui/README_zh.md +103 -0
- package/a2ui/dist/catalog/Button/catalog.json +2 -1
- package/a2ui/dist/catalog/Button/index.d.ts +5 -0
- package/a2ui/dist/catalog/Button/index.jsx +3 -0
- package/a2ui/dist/catalog/Button/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Card/catalog.json +2 -1
- package/a2ui/dist/catalog/Card/index.d.ts +5 -0
- package/a2ui/dist/catalog/Card/index.jsx +3 -0
- package/a2ui/dist/catalog/Card/index.jsx.map +1 -1
- package/a2ui/dist/catalog/CheckBox/catalog.json +2 -1
- package/a2ui/dist/catalog/CheckBox/index.d.ts +5 -0
- package/a2ui/dist/catalog/CheckBox/index.jsx +3 -0
- package/a2ui/dist/catalog/CheckBox/index.jsx.map +1 -1
- package/a2ui/dist/catalog/ChoicePicker/catalog.json +2 -1
- package/a2ui/dist/catalog/ChoicePicker/index.d.ts +5 -0
- package/a2ui/dist/catalog/ChoicePicker/index.jsx +3 -0
- package/a2ui/dist/catalog/ChoicePicker/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Column/catalog.json +2 -1
- package/a2ui/dist/catalog/Column/index.d.ts +5 -0
- package/a2ui/dist/catalog/Column/index.jsx +3 -0
- package/a2ui/dist/catalog/Column/index.jsx.map +1 -1
- package/a2ui/dist/catalog/DateTimeInput/catalog.json +2 -1
- package/a2ui/dist/catalog/DateTimeInput/index.d.ts +5 -0
- package/a2ui/dist/catalog/DateTimeInput/index.jsx +4 -10
- package/a2ui/dist/catalog/DateTimeInput/index.jsx.map +1 -1
- package/a2ui/dist/catalog/DateTimeInput/utils.d.ts +0 -1
- package/a2ui/dist/catalog/DateTimeInput/utils.js +0 -3
- package/a2ui/dist/catalog/DateTimeInput/utils.js.map +1 -1
- package/a2ui/dist/catalog/Divider/catalog.json +2 -1
- package/a2ui/dist/catalog/Divider/index.d.ts +5 -0
- package/a2ui/dist/catalog/Divider/index.jsx +3 -0
- package/a2ui/dist/catalog/Divider/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Icon/catalog.json +2 -1
- package/a2ui/dist/catalog/Icon/index.d.ts +5 -0
- package/a2ui/dist/catalog/Icon/index.jsx +3 -0
- package/a2ui/dist/catalog/Icon/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Image/catalog.json +2 -1
- package/a2ui/dist/catalog/Image/index.d.ts +5 -0
- package/a2ui/dist/catalog/Image/index.jsx +3 -0
- package/a2ui/dist/catalog/Image/index.jsx.map +1 -1
- package/a2ui/dist/catalog/LazyComponent/catalog.json +37 -0
- package/a2ui/dist/catalog/LazyComponent/index.d.ts +27 -0
- package/a2ui/dist/catalog/LazyComponent/index.jsx +39 -0
- package/a2ui/dist/catalog/LazyComponent/index.jsx.map +1 -0
- package/a2ui/dist/catalog/LineChart/catalog.json +2 -1
- package/a2ui/dist/catalog/LineChart/index.d.ts +8 -0
- package/a2ui/dist/catalog/LineChart/index.jsx +3 -0
- package/a2ui/dist/catalog/LineChart/index.jsx.map +1 -1
- package/a2ui/dist/catalog/List/catalog.json +2 -1
- package/a2ui/dist/catalog/List/index.d.ts +5 -0
- package/a2ui/dist/catalog/List/index.jsx +3 -0
- package/a2ui/dist/catalog/List/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Loading/catalog.json +16 -0
- package/a2ui/dist/catalog/Loading/index.d.ts +15 -0
- package/a2ui/dist/catalog/Loading/index.jsx +14 -0
- package/a2ui/dist/catalog/Loading/index.jsx.map +1 -0
- package/a2ui/dist/catalog/Modal/catalog.json +2 -1
- package/a2ui/dist/catalog/Modal/index.d.ts +5 -0
- package/a2ui/dist/catalog/Modal/index.jsx +3 -0
- package/a2ui/dist/catalog/Modal/index.jsx.map +1 -1
- package/a2ui/dist/catalog/PieChart/catalog.json +2 -1
- package/a2ui/dist/catalog/PieChart/index.d.ts +8 -0
- package/a2ui/dist/catalog/PieChart/index.jsx +3 -0
- package/a2ui/dist/catalog/PieChart/index.jsx.map +1 -1
- package/a2ui/dist/catalog/RadioGroup/catalog.json +2 -1
- package/a2ui/dist/catalog/RadioGroup/index.d.ts +5 -0
- package/a2ui/dist/catalog/RadioGroup/index.jsx +3 -0
- package/a2ui/dist/catalog/RadioGroup/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Row/catalog.json +2 -1
- package/a2ui/dist/catalog/Row/index.d.ts +5 -0
- package/a2ui/dist/catalog/Row/index.jsx +3 -0
- package/a2ui/dist/catalog/Row/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Slider/catalog.json +2 -1
- package/a2ui/dist/catalog/Slider/index.d.ts +5 -0
- package/a2ui/dist/catalog/Slider/index.jsx +3 -0
- package/a2ui/dist/catalog/Slider/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Tabs/catalog.json +2 -1
- package/a2ui/dist/catalog/Tabs/index.d.ts +5 -0
- package/a2ui/dist/catalog/Tabs/index.jsx +3 -0
- package/a2ui/dist/catalog/Tabs/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Text/catalog.json +2 -1
- package/a2ui/dist/catalog/Text/index.d.ts +5 -0
- package/a2ui/dist/catalog/Text/index.jsx +3 -0
- package/a2ui/dist/catalog/Text/index.jsx.map +1 -1
- package/a2ui/dist/catalog/TextField/catalog.json +2 -1
- package/a2ui/dist/catalog/TextField/index.d.ts +5 -0
- package/a2ui/dist/catalog/TextField/index.jsx +3 -0
- package/a2ui/dist/catalog/TextField/index.jsx.map +1 -1
- package/a2ui/dist/catalog/defineCatalog.d.ts +4 -4
- package/a2ui/dist/catalog/defineCatalog.js.map +1 -1
- package/a2ui/dist/catalog/index.d.ts +2 -0
- package/a2ui/dist/catalog/index.js +92 -18
- package/a2ui/dist/catalog/index.js.map +1 -1
- package/a2ui/dist/catalog.json +2603 -0
- package/a2ui/dist/index.d.ts +1 -1
- package/a2ui/dist/index.js +2 -2
- package/a2ui/dist/index.js.map +1 -1
- package/a2ui/dist/react/A2UI.d.ts +3 -0
- package/a2ui/dist/react/A2UI.jsx.map +1 -1
- package/a2ui/dist/react/A2UIRenderer.d.ts +5 -18
- package/a2ui/dist/react/A2UIRenderer.jsx +3 -13
- package/a2ui/dist/react/A2UIRenderer.jsx.map +1 -1
- package/a2ui/dist/react/useAction.d.ts +7 -0
- package/a2ui/dist/react/useAction.js +4 -0
- package/a2ui/dist/react/useAction.js.map +1 -1
- package/a2ui/dist/react/useDataBinding.d.ts +7 -5
- package/a2ui/dist/react/useDataBinding.js +18 -0
- package/a2ui/dist/react/useDataBinding.js.map +1 -1
- package/a2ui/dist/store/FunctionRegistry.d.ts +7 -0
- package/a2ui/dist/store/FunctionRegistry.js +4 -0
- package/a2ui/dist/store/FunctionRegistry.js.map +1 -1
- package/a2ui/dist/store/MessageProcessor.d.ts +7 -0
- package/a2ui/dist/store/MessageProcessor.js +4 -0
- package/a2ui/dist/store/MessageProcessor.js.map +1 -1
- package/a2ui/dist/store/MessageStore.d.ts +6 -0
- package/a2ui/dist/store/MessageStore.js +3 -0
- package/a2ui/dist/store/MessageStore.js.map +1 -1
- package/a2ui/dist/store/Resource.d.ts +8 -0
- package/a2ui/dist/store/Resource.js +4 -0
- package/a2ui/dist/store/Resource.js.map +1 -1
- package/a2ui/dist/store/SignalStore.d.ts +3 -2
- package/a2ui/dist/store/SignalStore.js +9 -0
- package/a2ui/dist/store/SignalStore.js.map +1 -1
- package/a2ui/dist/store/resolveDynamic.d.ts +4 -3
- package/a2ui/dist/store/resolveDynamic.js +19 -0
- package/a2ui/dist/store/resolveDynamic.js.map +1 -1
- package/a2ui/dist/store/resolveFunctionCall.d.ts +7 -0
- package/a2ui/dist/store/resolveFunctionCall.js +4 -0
- package/a2ui/dist/store/resolveFunctionCall.js.map +1 -1
- package/a2ui/dist/store/types.d.ts +13 -0
- package/a2ui/dist/store/utils.d.ts +6 -4
- package/a2ui/dist/store/utils.js +26 -0
- package/a2ui/dist/store/utils.js.map +1 -1
- package/a2ui/dist/tsconfig.build.tsbuildinfo +1 -1
- package/a2ui/docs/catalog-guide.md +407 -0
- package/a2ui/docs/catalog-guide_zh.md +379 -0
- package/a2ui/docs/overview.md +312 -0
- package/a2ui/docs/overview_zh.md +289 -0
- package/a2ui/docs/system-prompts.md +187 -0
- package/a2ui/docs/system-prompts_zh.md +187 -0
- package/a2ui/src/catalog/README.md +12 -0
- package/a2ui/src/catalog/index.ts +52 -0
- package/a2ui/src/catalog/readme_zh.md +11 -0
- package/a2ui/src/index.ts +116 -0
- package/a2ui/styles/catalog/Button.css +5 -5
- package/a2ui/styles/catalog/DateTimeInput.css +22 -30
- package/a2ui/styles/catalog/Loading.css +61 -0
- package/a2ui-catalog-extractor/README.md +14 -7
- package/a2ui-catalog-extractor/dist/cli.d.ts +1 -0
- package/a2ui-catalog-extractor/dist/cli.js +15 -6
- package/a2ui-catalog-extractor/dist/cli.js.map +1 -1
- package/a2ui-catalog-extractor/dist/index.d.ts +97 -2
- package/a2ui-catalog-extractor/dist/index.js +91 -6
- package/a2ui-catalog-extractor/dist/index.js.map +1 -1
- package/a2ui-catalog-extractor/dist/tsconfig.build.tsbuildinfo +1 -1
- package/a2ui-catalog-extractor/skills/a2ui-catalog-extractor/SKILL.md +1 -1
- package/a2ui-prompt/README.md +3 -2
- package/a2ui-prompt/dist/index.d.ts +41 -0
- package/a2ui-prompt/dist/index.js +159 -84
- package/cli/README.md +26 -0
- package/cli/bin/cli.js +7 -265
- package/cli/dist/a2ui/create.d.ts +5 -0
- package/cli/dist/a2ui/create.js +178 -0
- package/cli/dist/a2ui/create.js.map +1 -0
- package/cli/dist/a2ui/index.d.ts +5 -0
- package/cli/dist/a2ui/index.js +170 -0
- package/cli/dist/a2ui/index.js.map +1 -0
- package/cli/dist/cli.d.ts +4 -0
- package/cli/dist/cli.js +40 -0
- package/cli/dist/cli.js.map +1 -0
- package/cli/dist/openui.d.ts +1 -0
- package/cli/dist/openui.js +21 -0
- package/cli/dist/openui.js.map +1 -0
- package/cli/dist/tsconfig.build.tsbuildinfo +1 -0
- package/cli/dist/utils.d.ts +2 -0
- package/cli/dist/utils.js +17 -0
- package/cli/dist/utils.js.map +1 -0
- package/cli/templates/default/lynx.config.ts +13 -0
- package/cli/templates/default/package.json +27 -0
- package/cli/templates/default/src/App.css +88 -0
- package/cli/templates/default/src/App.tsx +100 -0
- package/cli/templates/default/src/index.tsx +10 -0
- package/cli/templates/default/src/messages.ts +158 -0
- package/cli/templates/default/src/rspeedy-env.d.ts +14 -0
- package/cli/templates/default/src/tsconfig.json +17 -0
- package/cli/templates/default/tsconfig.json +15 -0
- package/cli/templates/default/tsconfig.node.json +16 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/index.ts +12 -0
- package/openui/README.md +50 -46
- package/openui/dist/catalog/Action/{index.js → index.jsx} +1 -1
- package/openui/dist/catalog/Action/index.jsx.map +1 -0
- package/openui/dist/catalog/Button/index.d.ts +8 -8
- package/openui/dist/catalog/Button/{index.js → index.jsx} +28 -14
- package/openui/dist/catalog/Button/index.jsx.map +1 -0
- package/openui/dist/catalog/Card/index.d.ts +1 -1
- package/openui/dist/catalog/Card/{index.js → index.jsx} +5 -4
- package/openui/dist/catalog/Card/{index.js.map → index.jsx.map} +1 -1
- package/openui/dist/catalog/CardHeader/index.d.ts +1 -1
- package/openui/dist/catalog/CardHeader/index.jsx +20 -0
- package/openui/dist/catalog/CardHeader/index.jsx.map +1 -0
- package/openui/dist/catalog/CheckBox/index.d.ts +16 -0
- package/openui/dist/catalog/CheckBox/index.jsx +82 -0
- package/openui/dist/catalog/CheckBox/index.jsx.map +1 -0
- package/openui/dist/catalog/Icon/index.d.ts +44 -0
- package/openui/dist/catalog/Icon/index.jsx +66 -0
- package/openui/dist/catalog/Icon/index.jsx.map +1 -0
- package/openui/dist/catalog/Image/index.d.ts +19 -0
- package/openui/dist/catalog/Image/index.jsx +40 -0
- package/openui/dist/catalog/Image/index.jsx.map +1 -0
- package/openui/dist/catalog/Loading/index.d.ts +7 -0
- package/openui/dist/catalog/Loading/index.jsx +25 -0
- package/openui/dist/catalog/Loading/index.jsx.map +1 -0
- package/openui/dist/catalog/RadioGroup/index.d.ts +21 -0
- package/openui/dist/catalog/RadioGroup/index.jsx +99 -0
- package/openui/dist/catalog/RadioGroup/index.jsx.map +1 -0
- package/openui/dist/catalog/Separator/index.d.ts +1 -1
- package/openui/dist/catalog/Separator/{index.js → index.jsx} +3 -4
- package/openui/dist/catalog/Separator/index.jsx.map +1 -0
- package/openui/dist/catalog/Slider/index.d.ts +19 -0
- package/openui/dist/catalog/Slider/index.jsx +139 -0
- package/openui/dist/catalog/Slider/index.jsx.map +1 -0
- package/openui/dist/catalog/Stack/index.d.ts +1 -1
- package/openui/dist/catalog/Stack/{index.js → index.jsx} +3 -4
- package/openui/dist/catalog/Stack/{index.js.map → index.jsx.map} +1 -1
- package/openui/dist/catalog/Tag/index.d.ts +1 -1
- package/openui/dist/catalog/Tag/{index.js → index.jsx} +5 -4
- package/openui/dist/catalog/Tag/index.jsx.map +1 -0
- package/openui/dist/catalog/TextContent/index.d.ts +1 -1
- package/openui/dist/catalog/TextContent/{index.js → index.jsx} +5 -4
- package/openui/dist/catalog/TextContent/{index.js.map → index.jsx.map} +1 -1
- package/openui/dist/catalog/TextField/index.d.ts +23 -0
- package/openui/dist/catalog/TextField/index.jsx +132 -0
- package/openui/dist/catalog/TextField/index.jsx.map +1 -0
- package/openui/dist/catalog/index.d.ts +14 -7
- package/openui/dist/catalog/index.js +14 -7
- package/openui/dist/catalog/index.js.map +1 -1
- package/openui/dist/core/context.d.ts +22 -8
- package/openui/dist/core/{context.js → context.jsx} +10 -3
- package/openui/dist/core/context.jsx.map +1 -0
- package/openui/dist/core/createLibrary.d.ts +8 -1
- package/openui/dist/core/{createLibrary.js → createLibrary.jsx} +18 -3
- package/openui/dist/core/createLibrary.jsx.map +1 -0
- package/openui/dist/core/hooks/index.d.ts +1 -0
- package/openui/dist/core/hooks/index.js +1 -0
- package/openui/dist/core/hooks/index.js.map +1 -1
- package/openui/dist/core/hooks/useFormValidation.d.ts +9 -0
- package/openui/dist/core/hooks/useFormValidation.js +6 -0
- package/openui/dist/core/hooks/useFormValidation.js.map +1 -1
- package/openui/dist/core/hooks/useOpenUIState.d.ts +8 -2
- package/openui/dist/core/hooks/useOpenUIState.js +3 -1
- package/openui/dist/core/hooks/useOpenUIState.js.map +1 -1
- package/openui/dist/core/hooks/useStateField.d.ts +3 -0
- package/openui/dist/core/hooks/useStateField.js +4 -1
- package/openui/dist/core/hooks/useStateField.js.map +1 -1
- package/openui/dist/core/index.d.ts +13 -7
- package/openui/dist/core/index.js +7 -4
- package/openui/dist/core/index.js.map +1 -1
- package/openui/dist/core/library.d.ts +6 -1
- package/openui/dist/core/{library.js → library.jsx} +9 -1
- package/openui/dist/core/library.jsx.map +1 -0
- package/openui/dist/core/renderer.css +527 -0
- package/openui/dist/core/renderer.d.ts +41 -4
- package/openui/dist/core/renderer.jsx +284 -0
- package/openui/dist/core/renderer.jsx.map +1 -0
- package/openui/dist/core/runtime/index.d.ts +1 -0
- package/openui/dist/core/runtime/index.js +5 -0
- package/openui/dist/core/runtime/index.js.map +1 -0
- package/openui/dist/core/runtime/reactive.d.ts +7 -0
- package/openui/dist/core/runtime/reactive.js +10 -0
- package/openui/dist/core/runtime/reactive.js.map +1 -0
- package/openui/dist/openui-prompt/index.d.ts +47 -0
- package/openui/dist/openui-prompt/index.js +321 -0
- package/openui/dist/openui-prompt/index.js.map +1 -0
- package/package.json +20 -8
- package/openui/dist/catalog/Action/index.js.map +0 -1
- package/openui/dist/catalog/Button/index.js.map +0 -1
- package/openui/dist/catalog/CardHeader/index.js +0 -18
- package/openui/dist/catalog/CardHeader/index.js.map +0 -1
- package/openui/dist/catalog/Separator/index.js.map +0 -1
- package/openui/dist/catalog/Tag/index.js.map +0 -1
- package/openui/dist/core/context.js.map +0 -1
- package/openui/dist/core/createLibrary.js.map +0 -1
- package/openui/dist/core/library.js.map +0 -1
- package/openui/dist/core/renderer.js +0 -139
- package/openui/dist/core/renderer.js.map +0 -1
package/README.md
CHANGED
|
@@ -88,21 +88,17 @@ component details.
|
|
|
88
88
|
|
|
89
89
|
## OpenUI
|
|
90
90
|
|
|
91
|
-
OpenUI renders
|
|
91
|
+
OpenUI renders OpenUI Lang v0.5 responses through a configurable component
|
|
92
|
+
library.
|
|
92
93
|
|
|
93
94
|
```tsx
|
|
94
|
-
import {
|
|
95
|
-
OpenUiRenderer,
|
|
96
|
-
createOpenUiLibrary,
|
|
97
|
-
createStreamingParser,
|
|
98
|
-
} from '@lynx-js/genui/openui';
|
|
95
|
+
import { OpenUiRenderer, createOpenUiLibrary } from '@lynx-js/genui/openui';
|
|
99
96
|
|
|
100
97
|
const library = createOpenUiLibrary();
|
|
101
|
-
const
|
|
102
|
-
const result = parser.push('root = Stack([TextContent("Hello")])');
|
|
98
|
+
const response = 'root = Stack([TextContent("Hello")])';
|
|
103
99
|
|
|
104
100
|
export function OpenUIScreen() {
|
|
105
|
-
return <OpenUiRenderer
|
|
101
|
+
return <OpenUiRenderer response={response} library={library} />;
|
|
106
102
|
}
|
|
107
103
|
```
|
|
108
104
|
|
package/a2ui/AGENTS.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# a2ui (packages/genui/a2ui)
|
|
2
|
+
|
|
3
|
+
This package (`@lynx-js/genui/a2ui`) is a **headless** ReactLynx
|
|
4
|
+
renderer for the A2UI v0.9 protocol.
|
|
5
|
+
|
|
6
|
+
## How It Works (High Level)
|
|
7
|
+
|
|
8
|
+
The package is split into three independently composable layers:
|
|
9
|
+
|
|
10
|
+
- **Store layer** (`src/store/`) — pure data logic. Owns the protocol
|
|
11
|
+
message buffer, surface state machine, signal-backed data model, and
|
|
12
|
+
per-component resources. No React.
|
|
13
|
+
- **React layer** (`src/react/`) — `<A2UI>` / `<A2UIRenderer>` and the
|
|
14
|
+
hooks (`useAction`, `useDataBinding`, `useCatalog`) that turn the
|
|
15
|
+
store's surface state into a ReactLynx tree.
|
|
16
|
+
- **Catalog layer** (`src/catalog/`) — built-in components plus the
|
|
17
|
+
`defineCatalog` API consumers use to compose their per-instance
|
|
18
|
+
catalog (no global registry).
|
|
19
|
+
|
|
20
|
+
In short: the developer's IO module pushes raw v0.9 messages into a
|
|
21
|
+
`MessageStore`. `<A2UI>` subscribes, owns a `MessageProcessor` that
|
|
22
|
+
turns the stream into surface state, and renders via the catalog the
|
|
23
|
+
consumer provided.
|
|
24
|
+
|
|
25
|
+
## Architecture & Data Flow
|
|
26
|
+
|
|
27
|
+
Core pieces:
|
|
28
|
+
|
|
29
|
+
- `MessageStore` (`src/store/MessageStore.ts`)
|
|
30
|
+
- Append-only buffer of raw protocol messages.
|
|
31
|
+
- `useSyncExternalStore`-friendly `subscribe` / `getSnapshot` API.
|
|
32
|
+
- The developer's transport (fetch / SSE / WebSocket / in-process
|
|
33
|
+
mock) calls `store.push(msg)` — the store is intentionally dumb
|
|
34
|
+
about protocol semantics.
|
|
35
|
+
- `MessageProcessor` (`src/store/MessageProcessor.ts`)
|
|
36
|
+
- Owns all `Surface` instances.
|
|
37
|
+
- Applies `createSurface` / `updateComponents` / `updateDataModel` /
|
|
38
|
+
`deleteSurface` into surface state.
|
|
39
|
+
- Emits typed update events (`beginRendering`, `surfaceUpdate`,
|
|
40
|
+
`deleteSurface`) consumed by the React layer.
|
|
41
|
+
- `dispatch({ userAction })` fans out to `onEvent` listeners.
|
|
42
|
+
- `Resource` (`src/store/Resource.ts`)
|
|
43
|
+
- `pending` / `success` / `error` state machine. Snapshot reference
|
|
44
|
+
changes on every transition so `useSyncExternalStore` doesn't bail
|
|
45
|
+
out on `pending → error`.
|
|
46
|
+
- One per surface root + per component instance.
|
|
47
|
+
- `SignalStore` (`src/store/SignalStore.ts`)
|
|
48
|
+
- `@preact/signals` wrapper used as the per-surface data model
|
|
49
|
+
(JSON-pointer-style paths).
|
|
50
|
+
- `<A2UI>` (`src/react/A2UI.tsx`)
|
|
51
|
+
- All-in-one renderer. Per-mount `MessageProcessor`. Subscribes to
|
|
52
|
+
the developer-supplied `MessageStore`, processes new tail messages
|
|
53
|
+
on each render, and renders the most recent surface.
|
|
54
|
+
- Wires `processor.onEvent` → the consumer's `onAction` prop.
|
|
55
|
+
- `<A2UIRenderer>` / `NodeRenderer` (`src/react/A2UIRenderer.tsx`)
|
|
56
|
+
- Subscribes to a `Resource` and renders either:
|
|
57
|
+
- `beginRendering`: mounts the surface root resource.
|
|
58
|
+
- `surfaceUpdate`: re-renders a single component node.
|
|
59
|
+
- `deleteSurface`: unmounts.
|
|
60
|
+
- Used internally by `<A2UI>`; not part of the public surface.
|
|
61
|
+
- `defineCatalog` (`src/catalog/defineCatalog.ts`)
|
|
62
|
+
- Builds the runtime catalog the renderer uses. Inputs can mix bare
|
|
63
|
+
components, `[component, manifest]` tuples, and already-resolved
|
|
64
|
+
entries from `mergeCatalogs`.
|
|
65
|
+
|
|
66
|
+
## Rendering Model
|
|
67
|
+
|
|
68
|
+
- Each protocol component instance references children via IDs (e.g.
|
|
69
|
+
`child: "text-1"`, `children: ["a","b"]`).
|
|
70
|
+
- Catalog components render their child IDs by calling `<NodeRenderer>`
|
|
71
|
+
for each child against the same surface.
|
|
72
|
+
- Unknown component tags log a warning (once per tag) and render `null`.
|
|
73
|
+
|
|
74
|
+
## Data Binding
|
|
75
|
+
|
|
76
|
+
- A binding is `{ path: string }` and resolves against
|
|
77
|
+
`Surface.store` (a `SignalStore`).
|
|
78
|
+
- `useResolvedProps` (`src/react/useDataBinding.ts`) resolves bound
|
|
79
|
+
props into concrete values and keeps them up to date via
|
|
80
|
+
`@preact/signals`.
|
|
81
|
+
- Relative paths resolve against the component's `dataContextPath`
|
|
82
|
+
(used heavily for templates / repeated structures).
|
|
83
|
+
|
|
84
|
+
## Template Expansion (Dynamic Children)
|
|
85
|
+
|
|
86
|
+
- When `updateComponents` contains a "templated children" placeholder,
|
|
87
|
+
`MessageProcessor` stores `__template` metadata on the component.
|
|
88
|
+
- When `updateDataModel` updates the template's data path, the
|
|
89
|
+
processor:
|
|
90
|
+
- reads the data at the path,
|
|
91
|
+
- clones the template subtree via `cloneComponentTree`,
|
|
92
|
+
- rewrites child IDs and sets `dataContextPath` to an item-specific
|
|
93
|
+
scope,
|
|
94
|
+
- sets `children` to the generated concrete IDs.
|
|
95
|
+
|
|
96
|
+
This is why some components can appear/disappear when only the data
|
|
97
|
+
model changes.
|
|
98
|
+
|
|
99
|
+
## Action Dispatch
|
|
100
|
+
|
|
101
|
+
User interactions are reported as `userAction` events:
|
|
102
|
+
|
|
103
|
+
- Catalog components call `sendAction(action)` (passed in through the
|
|
104
|
+
internal renderer plumbing).
|
|
105
|
+
- `useAction` (`src/react/useAction.ts`) resolves dynamic values
|
|
106
|
+
(bindings / function calls) against `Surface.store`, builds a
|
|
107
|
+
`UserActionPayload`, and calls `processor.dispatch({ userAction })`.
|
|
108
|
+
- `<A2UI>` listens to `processor.onEvent` and forwards to the
|
|
109
|
+
developer's `onAction` prop. Responses (if any) come back as new
|
|
110
|
+
protocol messages the developer pushes into the same `MessageStore`.
|
|
111
|
+
|
|
112
|
+
## What To Edit
|
|
113
|
+
|
|
114
|
+
- `src/catalog/*`: built-in UI components (also drives schema
|
|
115
|
+
generation).
|
|
116
|
+
- `src/store/*`: protocol-side data layer (buffer, processor,
|
|
117
|
+
resources, signals).
|
|
118
|
+
- `src/react/*`: ReactLynx renderer + hooks.
|
|
119
|
+
|
|
120
|
+
## Build
|
|
121
|
+
|
|
122
|
+
Run from repo root:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
pnpm -C packages/genui/a2ui build
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Notes:
|
|
129
|
+
|
|
130
|
+
- The package's `build` script runs the
|
|
131
|
+
`@lynx-js/genui/a2ui-catalog-extractor` to produce
|
|
132
|
+
`dist/catalog/<Name>/catalog.json` manifests.
|
|
133
|
+
- The root `tsc --build` (registered as `//#build`) is what produces
|
|
134
|
+
`dist/<Name>/index.{js,d.ts}` for each catalog component (project
|
|
135
|
+
references).
|
|
136
|
+
|
|
137
|
+
## Catalog Schema Generation
|
|
138
|
+
|
|
139
|
+
The build generates JSON schemas for catalog components:
|
|
140
|
+
|
|
141
|
+
- Tool: `@lynx-js/genui/a2ui-catalog-extractor` (TypeDoc-driven).
|
|
142
|
+
- Inputs: `src/catalog/<Name>/index.tsx` files annotated with
|
|
143
|
+
`@a2uiCatalog <Name>` JSDoc tags on the props interface.
|
|
144
|
+
- Outputs: `dist/catalog/<Name>/catalog.json`.
|
|
145
|
+
|
|
146
|
+
Constraints:
|
|
147
|
+
|
|
148
|
+
1. The component folder name must match the function declaration name
|
|
149
|
+
in `index.tsx` (e.g. `src/catalog/Button/index.tsx` exports
|
|
150
|
+
`function Button(...) { ... }`).
|
|
151
|
+
2. Framework-level props (`GenericComponentProps`) are intentionally
|
|
152
|
+
excluded from the emitted schema.
|
|
153
|
+
3. Schema output is build output — don't commit `dist/`.
|
|
154
|
+
|
|
155
|
+
## Adding A New Catalog Component
|
|
156
|
+
|
|
157
|
+
When adding `src/catalog/<Name>/index.tsx`:
|
|
158
|
+
|
|
159
|
+
1. Ensure the component function is named `<Name>` (matches folder
|
|
160
|
+
name).
|
|
161
|
+
2. Annotate the props interface with `@a2uiCatalog <Name>` so the
|
|
162
|
+
extractor picks it up.
|
|
163
|
+
3. Re-export the component from `src/catalog/index.ts`.
|
|
164
|
+
4. Add `./catalog/<Name>` and `./catalog/<Name>/catalog.json` entries
|
|
165
|
+
to the `exports` map in `package.json`.
|
|
166
|
+
5. Run `pnpm -C packages/genui/a2ui build` and confirm
|
|
167
|
+
`dist/catalog/<Name>/catalog.json` is generated.
|