@lynx-js/genui 0.0.1-rc.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.
- package/LICENSE +202 -0
- package/README.md +170 -0
- package/a2ui/README.md +140 -0
- package/a2ui/dist/catalog/Button/catalog.json +156 -0
- package/a2ui/dist/catalog/Button/index.d.ts +35 -0
- package/a2ui/dist/catalog/Button/index.js +35 -0
- package/a2ui/dist/catalog/Button/index.js.map +1 -0
- package/a2ui/dist/catalog/Card/catalog.json +24 -0
- package/a2ui/dist/catalog/Card/index.d.ts +11 -0
- package/a2ui/dist/catalog/Card/index.js +19 -0
- package/a2ui/dist/catalog/Card/index.js.map +1 -0
- package/a2ui/dist/catalog/CheckBox/catalog.json +170 -0
- package/a2ui/dist/catalog/CheckBox/index.d.ts +32 -0
- package/a2ui/dist/catalog/CheckBox/index.js +24 -0
- package/a2ui/dist/catalog/CheckBox/index.js.map +1 -0
- package/a2ui/dist/catalog/Column/catalog.json +57 -0
- package/a2ui/dist/catalog/Column/index.d.ts +15 -0
- package/a2ui/dist/catalog/Column/index.js +55 -0
- package/a2ui/dist/catalog/Column/index.js.map +1 -0
- package/a2ui/dist/catalog/Divider/catalog.json +14 -0
- package/a2ui/dist/catalog/Divider/index.d.ts +9 -0
- package/a2ui/dist/catalog/Divider/index.js +8 -0
- package/a2ui/dist/catalog/Divider/index.js.map +1 -0
- package/a2ui/dist/catalog/Icon/catalog.json +45 -0
- package/a2ui/dist/catalog/Icon/index.d.ts +14 -0
- package/a2ui/dist/catalog/Icon/index.js +11 -0
- package/a2ui/dist/catalog/Icon/index.js.map +1 -0
- package/a2ui/dist/catalog/Image/catalog.json +62 -0
- package/a2ui/dist/catalog/Image/index.d.ts +16 -0
- package/a2ui/dist/catalog/Image/index.js +30 -0
- package/a2ui/dist/catalog/Image/index.js.map +1 -0
- package/a2ui/dist/catalog/LineChart/catalog.json +98 -0
- package/a2ui/dist/catalog/LineChart/index.d.ts +31 -0
- package/a2ui/dist/catalog/LineChart/index.js +195 -0
- package/a2ui/dist/catalog/LineChart/index.js.map +1 -0
- package/a2ui/dist/catalog/List/catalog.json +52 -0
- package/a2ui/dist/catalog/List/index.d.ts +15 -0
- package/a2ui/dist/catalog/List/index.js +53 -0
- package/a2ui/dist/catalog/List/index.js.map +1 -0
- package/a2ui/dist/catalog/Modal/catalog.json +18 -0
- package/a2ui/dist/catalog/Modal/index.d.ts +12 -0
- package/a2ui/dist/catalog/Modal/index.js +33 -0
- package/a2ui/dist/catalog/Modal/index.js.map +1 -0
- package/a2ui/dist/catalog/PieChart/catalog.json +87 -0
- package/a2ui/dist/catalog/PieChart/index.d.ts +37 -0
- package/a2ui/dist/catalog/PieChart/index.js +131 -0
- package/a2ui/dist/catalog/PieChart/index.js.map +1 -0
- package/a2ui/dist/catalog/RadioGroup/catalog.json +184 -0
- package/a2ui/dist/catalog/RadioGroup/index.d.ts +36 -0
- package/a2ui/dist/catalog/RadioGroup/index.js +36 -0
- package/a2ui/dist/catalog/RadioGroup/index.js.map +1 -0
- package/a2ui/dist/catalog/Row/catalog.json +57 -0
- package/a2ui/dist/catalog/Row/index.d.ts +15 -0
- package/a2ui/dist/catalog/Row/index.js +28 -0
- package/a2ui/dist/catalog/Row/index.js.map +1 -0
- package/a2ui/dist/catalog/Slider/catalog.json +183 -0
- package/a2ui/dist/catalog/Slider/index.d.ts +41 -0
- package/a2ui/dist/catalog/Slider/index.js +39 -0
- package/a2ui/dist/catalog/Slider/index.js.map +1 -0
- package/a2ui/dist/catalog/Slider/utils.d.ts +11 -0
- package/a2ui/dist/catalog/Slider/utils.js +58 -0
- package/a2ui/dist/catalog/Slider/utils.js.map +1 -0
- package/a2ui/dist/catalog/Tabs/catalog.json +28 -0
- package/a2ui/dist/catalog/Tabs/index.d.ts +12 -0
- package/a2ui/dist/catalog/Tabs/index.js +32 -0
- package/a2ui/dist/catalog/Tabs/index.js.map +1 -0
- package/a2ui/dist/catalog/Text/catalog.json +74 -0
- package/a2ui/dist/catalog/Text/index.d.ts +18 -0
- package/a2ui/dist/catalog/Text/index.js +27 -0
- package/a2ui/dist/catalog/Text/index.js.map +1 -0
- package/a2ui/dist/catalog/TextField/catalog.json +147 -0
- package/a2ui/dist/catalog/TextField/index.d.ts +35 -0
- package/a2ui/dist/catalog/TextField/index.js +43 -0
- package/a2ui/dist/catalog/TextField/index.js.map +1 -0
- package/a2ui/dist/catalog/TextField/utils.d.ts +7 -0
- package/a2ui/dist/catalog/TextField/utils.js +51 -0
- package/a2ui/dist/catalog/TextField/utils.js.map +1 -0
- package/a2ui/dist/catalog/defineCatalog.d.ts +119 -0
- package/a2ui/dist/catalog/defineCatalog.js +196 -0
- package/a2ui/dist/catalog/defineCatalog.js.map +1 -0
- package/a2ui/dist/catalog/index.d.ts +20 -0
- package/a2ui/dist/catalog/index.js +26 -0
- package/a2ui/dist/catalog/index.js.map +1 -0
- package/a2ui/dist/catalog/utils/chart.d.ts +3 -0
- package/a2ui/dist/catalog/utils/chart.js +28 -0
- package/a2ui/dist/catalog/utils/chart.js.map +1 -0
- package/a2ui/dist/functions/index.d.ts +19 -0
- package/a2ui/dist/functions/index.js +87 -0
- package/a2ui/dist/functions/index.js.map +1 -0
- package/a2ui/dist/index.d.ts +11 -0
- package/a2ui/dist/index.js +35 -0
- package/a2ui/dist/index.js.map +1 -0
- package/a2ui/dist/react/A2UI.d.ts +77 -0
- package/a2ui/dist/react/A2UI.js +159 -0
- package/a2ui/dist/react/A2UI.js.map +1 -0
- package/a2ui/dist/react/A2UIProvider.d.ts +25 -0
- package/a2ui/dist/react/A2UIProvider.js +20 -0
- package/a2ui/dist/react/A2UIProvider.js.map +1 -0
- package/a2ui/dist/react/A2UIRenderer.d.ts +34 -0
- package/a2ui/dist/react/A2UIRenderer.js +161 -0
- package/a2ui/dist/react/A2UIRenderer.js.map +1 -0
- package/a2ui/dist/react/FormContext.d.ts +10 -0
- package/a2ui/dist/react/FormContext.js +12 -0
- package/a2ui/dist/react/FormContext.js.map +1 -0
- package/a2ui/dist/react/index.d.ts +8 -0
- package/a2ui/dist/react/index.js +23 -0
- package/a2ui/dist/react/index.js.map +1 -0
- package/a2ui/dist/react/useA2UIContext.d.ts +7 -0
- package/a2ui/dist/react/useA2UIContext.js +19 -0
- package/a2ui/dist/react/useA2UIContext.js.map +1 -0
- package/a2ui/dist/react/useAction.d.ts +9 -0
- package/a2ui/dist/react/useAction.js +38 -0
- package/a2ui/dist/react/useAction.js.map +1 -0
- package/a2ui/dist/react/useCatalog.d.ts +7 -0
- package/a2ui/dist/react/useCatalog.js +13 -0
- package/a2ui/dist/react/useCatalog.js.map +1 -0
- package/a2ui/dist/react/useChecks.d.ts +27 -0
- package/a2ui/dist/react/useChecks.js +76 -0
- package/a2ui/dist/react/useChecks.js.map +1 -0
- package/a2ui/dist/react/useDataBinding.d.ts +10 -0
- package/a2ui/dist/react/useDataBinding.js +175 -0
- package/a2ui/dist/react/useDataBinding.js.map +1 -0
- package/a2ui/dist/store/FormController.d.ts +23 -0
- package/a2ui/dist/store/FormController.js +40 -0
- package/a2ui/dist/store/FormController.js.map +1 -0
- package/a2ui/dist/store/FunctionRegistry.d.ts +47 -0
- package/a2ui/dist/store/FunctionRegistry.js +23 -0
- package/a2ui/dist/store/FunctionRegistry.js.map +1 -0
- package/a2ui/dist/store/MessageProcessor.d.ts +28 -0
- package/a2ui/dist/store/MessageProcessor.js +408 -0
- package/a2ui/dist/store/MessageProcessor.js.map +1 -0
- package/a2ui/dist/store/MessageStore.d.ts +38 -0
- package/a2ui/dist/store/MessageStore.js +37 -0
- package/a2ui/dist/store/MessageStore.js.map +1 -0
- package/a2ui/dist/store/Resource.d.ts +45 -0
- package/a2ui/dist/store/Resource.js +80 -0
- package/a2ui/dist/store/Resource.js.map +1 -0
- package/a2ui/dist/store/SignalStore.d.ts +10 -0
- package/a2ui/dist/store/SignalStore.js +29 -0
- package/a2ui/dist/store/SignalStore.js.map +1 -0
- package/a2ui/dist/store/index.d.ts +14 -0
- package/a2ui/dist/store/index.js +15 -0
- package/a2ui/dist/store/index.js.map +1 -0
- package/a2ui/dist/store/payloadNormalizer.d.ts +27 -0
- package/a2ui/dist/store/payloadNormalizer.js +179 -0
- package/a2ui/dist/store/payloadNormalizer.js.map +1 -0
- package/a2ui/dist/store/resolveFunctionCall.d.ts +18 -0
- package/a2ui/dist/store/resolveFunctionCall.js +131 -0
- package/a2ui/dist/store/resolveFunctionCall.js.map +1 -0
- package/a2ui/dist/store/types.d.ts +68 -0
- package/a2ui/dist/store/types.js +2 -0
- package/a2ui/dist/store/types.js.map +1 -0
- package/a2ui/dist/tsconfig.build.tsbuildinfo +1 -0
- package/a2ui/styles/catalog/Button.css +83 -0
- package/a2ui/styles/catalog/Card.css +49 -0
- package/a2ui/styles/catalog/CheckBox.css +46 -0
- package/a2ui/styles/catalog/Column.css +89 -0
- package/a2ui/styles/catalog/Divider.css +20 -0
- package/a2ui/styles/catalog/Icon.css +39 -0
- package/a2ui/styles/catalog/Image.css +54 -0
- package/a2ui/styles/catalog/LineChart.css +116 -0
- package/a2ui/styles/catalog/List.css +38 -0
- package/a2ui/styles/catalog/Modal.css +60 -0
- package/a2ui/styles/catalog/PieChart.css +109 -0
- package/a2ui/styles/catalog/RadioGroup.css +123 -0
- package/a2ui/styles/catalog/Row.css +83 -0
- package/a2ui/styles/catalog/Slider.css +96 -0
- package/a2ui/styles/catalog/Tabs.css +46 -0
- package/a2ui/styles/catalog/Text.css +121 -0
- package/a2ui/styles/catalog/TextField.css +48 -0
- package/a2ui/styles/theme.css +62 -0
- package/a2ui-catalog-extractor/README.md +605 -0
- package/a2ui-catalog-extractor/bin/a2ui-catalog-extractor.js +6 -0
- package/a2ui-catalog-extractor/dist/cli.d.ts +12 -0
- package/a2ui-catalog-extractor/dist/cli.js +171 -0
- package/a2ui-catalog-extractor/dist/cli.js.map +1 -0
- package/a2ui-catalog-extractor/dist/index.d.ts +140 -0
- package/a2ui-catalog-extractor/dist/index.js +755 -0
- package/a2ui-catalog-extractor/dist/index.js.map +1 -0
- package/a2ui-catalog-extractor/dist/tsconfig.build.tsbuildinfo +1 -0
- package/a2ui-catalog-extractor/skills/a2ui-catalog-extractor/SKILL.md +30 -0
- package/a2ui-prompt/README.md +65 -0
- package/a2ui-prompt/dist/index.d.ts +91 -0
- package/a2ui-prompt/dist/index.js +767 -0
- package/cli/README.md +88 -0
- package/cli/bin/cli.js +271 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/index.ts +114 -0
- package/openui/README.md +211 -0
- package/openui/dist/catalog/Action/index.d.ts +20 -0
- package/openui/dist/catalog/Action/index.js +23 -0
- package/openui/dist/catalog/Action/index.js.map +1 -0
- package/openui/dist/catalog/Button/index.d.ts +64 -0
- package/openui/dist/catalog/Button/index.js +75 -0
- package/openui/dist/catalog/Button/index.js.map +1 -0
- package/openui/dist/catalog/Card/index.d.ts +34 -0
- package/openui/dist/catalog/Card/index.js +69 -0
- package/openui/dist/catalog/Card/index.js.map +1 -0
- package/openui/dist/catalog/CardHeader/index.d.ts +5 -0
- package/openui/dist/catalog/CardHeader/index.js +18 -0
- package/openui/dist/catalog/CardHeader/index.js.map +1 -0
- package/openui/dist/catalog/Separator/index.d.ts +2 -0
- package/openui/dist/catalog/Separator/index.js +13 -0
- package/openui/dist/catalog/Separator/index.js.map +1 -0
- package/openui/dist/catalog/Stack/index.d.ts +29 -0
- package/openui/dist/catalog/Stack/index.js +61 -0
- package/openui/dist/catalog/Stack/index.js.map +1 -0
- package/openui/dist/catalog/Tag/index.d.ts +4 -0
- package/openui/dist/catalog/Tag/index.js +15 -0
- package/openui/dist/catalog/Tag/index.js.map +1 -0
- package/openui/dist/catalog/TextContent/index.d.ts +11 -0
- package/openui/dist/catalog/TextContent/index.js +33 -0
- package/openui/dist/catalog/TextContent/index.js.map +1 -0
- package/openui/dist/catalog/index.d.ts +7 -0
- package/openui/dist/catalog/index.js +11 -0
- package/openui/dist/catalog/index.js.map +1 -0
- package/openui/dist/catalog/utils.d.ts +2 -0
- package/openui/dist/catalog/utils.js +17 -0
- package/openui/dist/catalog/utils.js.map +1 -0
- package/openui/dist/core/context.d.ts +112 -0
- package/openui/dist/core/context.js +99 -0
- package/openui/dist/core/context.js.map +1 -0
- package/openui/dist/core/createLibrary.d.ts +10 -0
- package/openui/dist/core/createLibrary.js +36 -0
- package/openui/dist/core/createLibrary.js.map +1 -0
- package/openui/dist/core/hooks/index.d.ts +4 -0
- package/openui/dist/core/hooks/index.js +6 -0
- package/openui/dist/core/hooks/index.js.map +1 -0
- package/openui/dist/core/hooks/useFormValidation.d.ts +13 -0
- package/openui/dist/core/hooks/useFormValidation.js +76 -0
- package/openui/dist/core/hooks/useFormValidation.js.map +1 -0
- package/openui/dist/core/hooks/useOpenUIState.d.ts +33 -0
- package/openui/dist/core/hooks/useOpenUIState.js +413 -0
- package/openui/dist/core/hooks/useOpenUIState.js.map +1 -0
- package/openui/dist/core/hooks/useStateField.d.ts +2 -0
- package/openui/dist/core/hooks/useStateField.js +11 -0
- package/openui/dist/core/hooks/useStateField.js.map +1 -0
- package/openui/dist/core/index.d.ts +7 -0
- package/openui/dist/core/index.js +8 -0
- package/openui/dist/core/index.js.map +1 -0
- package/openui/dist/core/library.d.ts +20 -0
- package/openui/dist/core/library.js +13 -0
- package/openui/dist/core/library.js.map +1 -0
- package/openui/dist/core/renderer.css +271 -0
- package/openui/dist/core/renderer.d.ts +9 -0
- package/openui/dist/core/renderer.js +139 -0
- package/openui/dist/core/renderer.js.map +1 -0
- package/openui/dist/core/utils.d.ts +1 -0
- package/openui/dist/core/utils.js +76 -0
- package/openui/dist/core/utils.js.map +1 -0
- package/package.json +120 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { effect } from '@preact/signals';
|
|
5
|
+
import { useCallback, useMemo, useRef, useSyncExternalStore, } from '@lynx-js/react';
|
|
6
|
+
import { isFunctionCall, resolveDynamicValue, } from '../store/resolveFunctionCall.js';
|
|
7
|
+
const noop = () => {
|
|
8
|
+
/* no-op subscribe disposer */
|
|
9
|
+
};
|
|
10
|
+
const noopSubscribe = () => noop;
|
|
11
|
+
const UNSUPPORTED_PROP = Symbol('a2ui.unsupported');
|
|
12
|
+
function subscribeToSignal(signal) {
|
|
13
|
+
if (!signal)
|
|
14
|
+
return noopSubscribe;
|
|
15
|
+
return (cb) => effect(() => {
|
|
16
|
+
void signal.value;
|
|
17
|
+
cb();
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export function useDataBinding(dynamicValue, surface, dataContextPath, fallbackValue) {
|
|
21
|
+
let path;
|
|
22
|
+
let initialValue;
|
|
23
|
+
if (typeof dynamicValue === 'string'
|
|
24
|
+
|| typeof dynamicValue === 'number'
|
|
25
|
+
|| typeof dynamicValue === 'boolean') {
|
|
26
|
+
// Preserve primitive type. A static `false` must stay falsy and
|
|
27
|
+
// numeric props must stay numeric — stringifying breaks consumers that
|
|
28
|
+
// expect `boolean | number` (e.g., `if (props.disabled)`).
|
|
29
|
+
initialValue = dynamicValue;
|
|
30
|
+
}
|
|
31
|
+
else if (dynamicValue
|
|
32
|
+
&& typeof dynamicValue === 'object'
|
|
33
|
+
&& 'path' in dynamicValue) {
|
|
34
|
+
path = dynamicValue['path'];
|
|
35
|
+
}
|
|
36
|
+
if (path && !path.startsWith('/')) {
|
|
37
|
+
if (dataContextPath) {
|
|
38
|
+
path = `${dataContextPath}/${path}`;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
path = `/${path}`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const signal = surface?.store && path
|
|
45
|
+
? surface.store.getSignal(path, typeof initialValue === 'string' ? initialValue : undefined)
|
|
46
|
+
: undefined;
|
|
47
|
+
const subscribe = useMemo(() => subscribeToSignal(signal), [signal]);
|
|
48
|
+
const getSnapshot = useCallback(() => signal?.value, [signal]);
|
|
49
|
+
const signalValue = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
50
|
+
const currentValue = path
|
|
51
|
+
? (signalValue ?? initialValue ?? fallbackValue)
|
|
52
|
+
: (initialValue ?? fallbackValue);
|
|
53
|
+
const setValue = useCallback((newValue) => {
|
|
54
|
+
if (path && surface?.store) {
|
|
55
|
+
surface.store.update(path, newValue);
|
|
56
|
+
}
|
|
57
|
+
}, [path, surface]);
|
|
58
|
+
return [currentValue, setValue, path];
|
|
59
|
+
}
|
|
60
|
+
function isDataBinding(prop) {
|
|
61
|
+
return Boolean(prop
|
|
62
|
+
&& typeof prop === 'object'
|
|
63
|
+
&& 'path' in prop
|
|
64
|
+
&& !('componentId' in prop));
|
|
65
|
+
}
|
|
66
|
+
function isCallExpression(prop) {
|
|
67
|
+
return Boolean(prop
|
|
68
|
+
&& typeof prop === 'object'
|
|
69
|
+
&& 'call' in prop
|
|
70
|
+
&& 'args' in prop
|
|
71
|
+
&& 'returnType' in prop);
|
|
72
|
+
}
|
|
73
|
+
export function splitUnsupportedProps(properties) {
|
|
74
|
+
const unsupportedFields = [];
|
|
75
|
+
if (!properties) {
|
|
76
|
+
return { unsupportedFields, displayProps: properties };
|
|
77
|
+
}
|
|
78
|
+
const nextProps = {};
|
|
79
|
+
let changed = false;
|
|
80
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
81
|
+
if (value === UNSUPPORTED_PROP) {
|
|
82
|
+
unsupportedFields.push(key);
|
|
83
|
+
changed = true;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
nextProps[key] = value;
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
unsupportedFields,
|
|
90
|
+
displayProps: changed ? nextProps : properties,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export function resolveProperties(properties, surface, dataContextPath, processor, functions) {
|
|
94
|
+
if (!properties)
|
|
95
|
+
return properties;
|
|
96
|
+
const result = {};
|
|
97
|
+
for (const key in properties) {
|
|
98
|
+
const prop = properties[key];
|
|
99
|
+
if (isFunctionCall(prop) && surface && processor) {
|
|
100
|
+
result[key] = resolveDynamicValue(processor, prop, surface.surfaceId, dataContextPath, { functions });
|
|
101
|
+
}
|
|
102
|
+
else if (isDataBinding(prop)) {
|
|
103
|
+
let path = prop['path'];
|
|
104
|
+
if (path && typeof path === 'string' && !path.startsWith('/')) {
|
|
105
|
+
path = dataContextPath ? `${dataContextPath}/${path}` : `/${path}`;
|
|
106
|
+
}
|
|
107
|
+
if (path && surface?.store) {
|
|
108
|
+
const signal = surface.store.getSignal(path);
|
|
109
|
+
result[key] = signal.value;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
result[key] = undefined;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else if (isCallExpression(prop)) {
|
|
116
|
+
result[key] = UNSUPPORTED_PROP;
|
|
117
|
+
}
|
|
118
|
+
else if (typeof prop === 'string'
|
|
119
|
+
|| typeof prop === 'number'
|
|
120
|
+
|| typeof prop === 'boolean') {
|
|
121
|
+
result[key] = prop;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
result[key] = prop;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
function shallowEqual(a, b) {
|
|
130
|
+
if (a === b)
|
|
131
|
+
return true;
|
|
132
|
+
const keysA = Object.keys(a);
|
|
133
|
+
const keysB = Object.keys(b);
|
|
134
|
+
if (keysA.length !== keysB.length)
|
|
135
|
+
return false;
|
|
136
|
+
for (const k of keysA) {
|
|
137
|
+
if (a[k] !== b[k])
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
export function useResolvedProps(properties, surface, dataContextPath, processor, functions) {
|
|
143
|
+
const cacheRef = useRef(null);
|
|
144
|
+
const computeSnapshot = useCallback(() => {
|
|
145
|
+
const next = resolveProperties(properties, surface, dataContextPath, processor, functions);
|
|
146
|
+
if (cacheRef.current && shallowEqual(cacheRef.current, next)) {
|
|
147
|
+
return cacheRef.current;
|
|
148
|
+
}
|
|
149
|
+
cacheRef.current = next;
|
|
150
|
+
return next;
|
|
151
|
+
}, [properties, surface, dataContextPath, processor, functions]);
|
|
152
|
+
const subscribe = useCallback((cb) => {
|
|
153
|
+
if (!surface?.store)
|
|
154
|
+
return noop;
|
|
155
|
+
return effect(() => {
|
|
156
|
+
resolveProperties(properties, surface, dataContextPath, processor, functions);
|
|
157
|
+
cb();
|
|
158
|
+
});
|
|
159
|
+
}, [properties, surface, dataContextPath, processor, functions]);
|
|
160
|
+
const resolved = useSyncExternalStore(subscribe, computeSnapshot, computeSnapshot);
|
|
161
|
+
const setValue = useCallback((key, value) => {
|
|
162
|
+
const prop = properties?.[key];
|
|
163
|
+
if (isDataBinding(prop)) {
|
|
164
|
+
let path = prop['path'];
|
|
165
|
+
if (path && surface?.store) {
|
|
166
|
+
if (!path.startsWith('/')) {
|
|
167
|
+
path = dataContextPath ? `${dataContextPath}/${path}` : `/${path}`;
|
|
168
|
+
}
|
|
169
|
+
surface.store.update(path, value);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}, [properties, surface, dataContextPath]);
|
|
173
|
+
return [resolved, setValue];
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=useDataBinding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDataBinding.js","sourceRoot":"","sources":["../../src/react/useDataBinding.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EACL,WAAW,EACX,OAAO,EACP,MAAM,EACN,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EACL,cAAc,EACd,mBAAm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,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC,EACD,CAAC,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,CAAC,CAC7D,CAAC;IAEF,MAAM,QAAQ,GAAG,oBAAoB,CACnC,SAAS,EACT,eAAe,EACf,eAAe,CAChB,CAAC;IAEF,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,GAAW,EAAE,KAAc,EAAE,EAAE;QAC9B,MAAM,IAAI,GAAG,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,IAAI,IAAI,GAAI,IAAgC,CAAC,MAAM,CAEtC,CAAC;YACd,IAAI,IAAI,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;gBAC3B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC1B,IAAI,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,eAAe,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;gBACrE,CAAC;gBACD,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;IACH,CAAC,EACD,CAAC,UAAU,EAAE,OAAO,EAAE,eAAe,CAAC,CACvC,CAAC;IAEF,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAGzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Signal } from '@preact/signals';
|
|
2
|
+
export interface CheckFailure {
|
|
3
|
+
/** Name of the function call that returned a falsy condition. */
|
|
4
|
+
call: string;
|
|
5
|
+
/** Operator-friendly message attached to the failing check. */
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CheckOutcome {
|
|
9
|
+
ok: boolean;
|
|
10
|
+
failures: CheckFailure[];
|
|
11
|
+
}
|
|
12
|
+
export interface FormController {
|
|
13
|
+
/** Reactive view of whether every registered input currently passes. */
|
|
14
|
+
isValid: Signal<boolean>;
|
|
15
|
+
/** Per-input outcomes, keyed by component id. */
|
|
16
|
+
outcomes: ReadonlyMap<string, Signal<CheckOutcome>>;
|
|
17
|
+
/**
|
|
18
|
+
* Register or update an input's outcome. The returned `dispose` removes
|
|
19
|
+
* the input from the form when it unmounts.
|
|
20
|
+
*/
|
|
21
|
+
setOutcome(componentId: string, outcome: CheckOutcome): () => void;
|
|
22
|
+
}
|
|
23
|
+
export declare function createFormController(): FormController;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { computed, signal } from '@preact/signals';
|
|
5
|
+
export function createFormController() {
|
|
6
|
+
const inputs = new Map();
|
|
7
|
+
// Tick on add/remove so the membership change is itself a reactive
|
|
8
|
+
// dependency of `isValid` (per-outcome value changes are already reactive
|
|
9
|
+
// because we read `entry.value` inside the computed).
|
|
10
|
+
const membership = signal(0);
|
|
11
|
+
const isValid = computed(() => {
|
|
12
|
+
void membership.value;
|
|
13
|
+
for (const outcome of inputs.values()) {
|
|
14
|
+
if (!outcome.value.ok)
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
isValid,
|
|
21
|
+
outcomes: inputs,
|
|
22
|
+
setOutcome(componentId, outcome) {
|
|
23
|
+
let entry = inputs.get(componentId);
|
|
24
|
+
if (entry) {
|
|
25
|
+
entry.value = outcome;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
entry = signal(outcome);
|
|
29
|
+
inputs.set(componentId, entry);
|
|
30
|
+
membership.value++;
|
|
31
|
+
}
|
|
32
|
+
return () => {
|
|
33
|
+
if (inputs.delete(componentId)) {
|
|
34
|
+
membership.value++;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=FormController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormController.js","sourceRoot":"","sources":["../../src/store/FormController.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AA2BnD,MAAM,UAAU,oBAAoB;IAClC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAgC,CAAC;IACvD,mEAAmE;IACnE,0EAA0E;IAC1E,sDAAsD;IACtD,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,EAAE;QAC5B,KAAK,UAAU,CAAC,KAAK,CAAC;QACtB,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;YACtC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAAE,OAAO,KAAK,CAAC;QACtC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IACH,OAAO;QACL,OAAO;QACP,QAAQ,EAAE,MAA8D;QACxE,UAAU,CAAC,WAAW,EAAE,OAAO;YAC7B,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YACpC,IAAI,KAAK,EAAE,CAAC;gBACV,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC;YACxB,CAAC;iBAAM,CAAC;gBACN,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;gBACxB,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;gBAC/B,UAAU,CAAC,KAAK,EAAE,CAAC;YACrB,CAAC;YACD,OAAO,GAAG,EAAE;gBACV,IAAI,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;oBAC/B,UAAU,CAAC,KAAK,EAAE,CAAC;gBACrB,CAAC;YACH,CAAC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Signal } from '@preact/signals';
|
|
2
|
+
import type { MessageProcessor } from './MessageProcessor.js';
|
|
3
|
+
/**
|
|
4
|
+
* Runtime context passed to client-side function implementations. It mirrors
|
|
5
|
+
* the small DataContext subset used by upstream A2UI basic functions while
|
|
6
|
+
* staying tied to this renderer's `MessageProcessor` + `SignalStore`.
|
|
7
|
+
*/
|
|
8
|
+
export interface FunctionCallContext {
|
|
9
|
+
processor: MessageProcessor;
|
|
10
|
+
surfaceId: string;
|
|
11
|
+
dataContextPath?: string | undefined;
|
|
12
|
+
resolveDynamicValue(value: unknown): unknown;
|
|
13
|
+
resolveSignal(value: unknown): Signal<unknown>;
|
|
14
|
+
set(path: string, value: unknown): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Function implementations live on the client; the agent only references
|
|
18
|
+
* functions by name. The registry is the bridge from the wire-level
|
|
19
|
+
* `FunctionCall.call` string to the actual code that runs locally.
|
|
20
|
+
*/
|
|
21
|
+
export type FunctionImpl = (args: Record<string, unknown>, context?: FunctionCallContext) => unknown;
|
|
22
|
+
/**
|
|
23
|
+
* Structured definition announced to the agent during catalog handshake.
|
|
24
|
+
* Kept here (in store/) so callers in both `catalog/` and `react/` can
|
|
25
|
+
* share the same shape without importing across the layering boundary.
|
|
26
|
+
*/
|
|
27
|
+
export interface FunctionDefinition {
|
|
28
|
+
name: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
parameters: Record<string, unknown>;
|
|
31
|
+
returnType: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'any' | 'void';
|
|
32
|
+
}
|
|
33
|
+
export interface FunctionEntry {
|
|
34
|
+
name: string;
|
|
35
|
+
/** Optional function definition announced to the agent as part of the handshake. */
|
|
36
|
+
definition?: FunctionDefinition | undefined;
|
|
37
|
+
impl: FunctionImpl;
|
|
38
|
+
}
|
|
39
|
+
export declare class FunctionRegistry {
|
|
40
|
+
private readonly entries;
|
|
41
|
+
register(entry: FunctionEntry): void;
|
|
42
|
+
unregister(name: string): void;
|
|
43
|
+
has(name: string): boolean;
|
|
44
|
+
resolve(name: string): FunctionImpl | undefined;
|
|
45
|
+
list(): FunctionEntry[];
|
|
46
|
+
}
|
|
47
|
+
export declare const functionRegistry: FunctionRegistry;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
export class FunctionRegistry {
|
|
5
|
+
entries = new Map();
|
|
6
|
+
register(entry) {
|
|
7
|
+
this.entries.set(entry.name, entry);
|
|
8
|
+
}
|
|
9
|
+
unregister(name) {
|
|
10
|
+
this.entries.delete(name);
|
|
11
|
+
}
|
|
12
|
+
has(name) {
|
|
13
|
+
return this.entries.has(name);
|
|
14
|
+
}
|
|
15
|
+
resolve(name) {
|
|
16
|
+
return this.entries.get(name)?.impl;
|
|
17
|
+
}
|
|
18
|
+
list() {
|
|
19
|
+
return Array.from(this.entries.values());
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export const functionRegistry = new FunctionRegistry();
|
|
23
|
+
//# sourceMappingURL=FunctionRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FunctionRegistry.js","sourceRoot":"","sources":["../../src/store/FunctionRegistry.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAwD1D,MAAM,OAAO,gBAAgB;IACV,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAC;IAE5D,QAAQ,CAAC,KAAoB;QAC3B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,CAAC,IAAY;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IACtC,CAAC;IAED,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3C,CAAC;CACF;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAqB,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ServerToClientMessage, Surface } from './types.js';
|
|
2
|
+
export interface A2UIEvent {
|
|
3
|
+
message: Record<string, unknown>;
|
|
4
|
+
resolve: (response: unknown) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare class MessageProcessor {
|
|
7
|
+
surfaces: Map<string, Surface>;
|
|
8
|
+
private eventListeners;
|
|
9
|
+
private updateListeners;
|
|
10
|
+
constructor();
|
|
11
|
+
onUpdate(callback: (data: Record<string, unknown>) => void): () => void;
|
|
12
|
+
private emitUpdate;
|
|
13
|
+
dispatch(message: Record<string, unknown>): Promise<unknown>;
|
|
14
|
+
onEvent(callback: (event: A2UIEvent) => void): () => void;
|
|
15
|
+
getSurfaces(): ReadonlyMap<string, Surface>;
|
|
16
|
+
clearSurfaces(): void;
|
|
17
|
+
getOrCreateSurface(surfaceId: string): Surface;
|
|
18
|
+
/**
|
|
19
|
+
* Resolve a JSON Pointer taking into account the current data context.
|
|
20
|
+
*
|
|
21
|
+
* - Absolute paths (starting with '/') are returned as-is.
|
|
22
|
+
* - Relative paths are resolved against the provided dataContextPath.
|
|
23
|
+
*/
|
|
24
|
+
resolvePath(path: string, dataContextPath?: string): string;
|
|
25
|
+
private cloneComponentTree;
|
|
26
|
+
private flattenValue;
|
|
27
|
+
processMessages(messages: ServerToClientMessage[]): void;
|
|
28
|
+
}
|