@maxhealth.tech/prefab 0.3.9 → 0.3.10
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/CHANGELOG.md +27 -0
- package/README.md +76 -10
- package/dist/a2ui/browser.d.ts +46 -0
- package/dist/a2ui/browser.d.ts.map +1 -0
- package/dist/a2ui/browser.js +58 -0
- package/dist/a2ui/browser.js.map +1 -0
- package/dist/a2ui/catalog.d.ts +51 -0
- package/dist/a2ui/catalog.d.ts.map +1 -0
- package/dist/a2ui/catalog.js +465 -0
- package/dist/a2ui/catalog.js.map +1 -0
- package/dist/a2ui/emit.d.ts +59 -0
- package/dist/a2ui/emit.d.ts.map +1 -0
- package/dist/a2ui/emit.js +269 -0
- package/dist/a2ui/emit.js.map +1 -0
- package/dist/a2ui/expr.d.ts +58 -0
- package/dist/a2ui/expr.d.ts.map +1 -0
- package/dist/a2ui/expr.js +81 -0
- package/dist/a2ui/expr.js.map +1 -0
- package/dist/a2ui/icons.d.ts +30 -0
- package/dist/a2ui/icons.d.ts.map +1 -0
- package/dist/a2ui/icons.js +87 -0
- package/dist/a2ui/icons.js.map +1 -0
- package/dist/a2ui/index.d.ts +27 -0
- package/dist/a2ui/index.d.ts.map +1 -0
- package/dist/a2ui/index.js +23 -0
- package/dist/a2ui/index.js.map +1 -0
- package/dist/a2ui/table.d.ts +31 -0
- package/dist/a2ui/table.d.ts.map +1 -0
- package/dist/a2ui/table.js +155 -0
- package/dist/a2ui/table.js.map +1 -0
- package/dist/a2ui/types.d.ts +174 -0
- package/dist/a2ui/types.d.ts.map +1 -0
- package/dist/a2ui/types.js +35 -0
- package/dist/a2ui/types.js.map +1 -0
- package/dist/a2ui.min.js +1 -0
- package/dist/app.d.ts +17 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +19 -0
- package/dist/app.js.map +1 -1
- package/dist/auto/form.d.ts +25 -0
- package/dist/auto/form.d.ts.map +1 -1
- package/dist/auto/form.js +21 -8
- package/dist/auto/form.js.map +1 -1
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.d.ts.map +1 -1
- package/dist/core/version.js +1 -1
- package/dist/core/version.js.map +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/a2ui.d.ts +91 -0
- package/dist/mcp/a2ui.d.ts.map +1 -0
- package/dist/mcp/a2ui.js +134 -0
- package/dist/mcp/a2ui.js.map +1 -0
- package/dist/mcp/display.d.ts +28 -6
- package/dist/mcp/display.d.ts.map +1 -1
- package/dist/mcp/display.js +10 -9
- package/dist/mcp/display.js.map +1 -1
- package/dist/mcp/index.d.ts +7 -2
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +3 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/input-required.d.ts +79 -0
- package/dist/mcp/input-required.d.ts.map +1 -0
- package/dist/mcp/input-required.js +231 -0
- package/dist/mcp/input-required.js.map +1 -0
- package/dist/mcp/resource.d.ts +10 -0
- package/dist/mcp/resource.d.ts.map +1 -1
- package/dist/mcp/resource.js +12 -4
- package/dist/mcp/resource.js.map +1 -1
- package/dist/mcp/result.d.ts +7 -5
- package/dist/mcp/result.d.ts.map +1 -1
- package/dist/mcp/result.js +5 -3
- package/dist/mcp/result.js.map +1 -1
- package/dist/mcp/types.d.ts +117 -0
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/renderer/components/index.d.ts.map +1 -1
- package/dist/renderer/components/index.js +6 -0
- package/dist/renderer/components/index.js.map +1 -1
- package/dist/renderer/engine.d.ts +4 -0
- package/dist/renderer/engine.d.ts.map +1 -1
- package/dist/renderer/engine.js +24 -0
- package/dist/renderer/engine.js.map +1 -1
- package/dist/renderer.auto.min.js +13 -13
- package/dist/renderer.min.js +13 -13
- package/package.json +13 -3
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `$prefab` → A2UI emitter.
|
|
3
|
+
*
|
|
4
|
+
* Walks the nested `$prefab` component tree and produces A2UI's flat adjacency
|
|
5
|
+
* list, plus the surface data model. Three invariants drive the implementation:
|
|
6
|
+
*
|
|
7
|
+
* - **The root is named `root`.** A2UI requires exactly that id on the entry
|
|
8
|
+
* component, so it is reserved before traversal begins rather than renamed
|
|
9
|
+
* afterwards.
|
|
10
|
+
* - **Ids are allocated before children are emitted.** A mapper calls back
|
|
11
|
+
* into the context to emit its children, so the parent's slot is reserved
|
|
12
|
+
* first and filled in once the mapper returns. Nodes that turn out to be
|
|
13
|
+
* unmappable release their slot, which is why the components map is keyed
|
|
14
|
+
* by id rather than being a positional array.
|
|
15
|
+
* - **Emission is deterministic.** Ids are drawn from a counter in traversal
|
|
16
|
+
* order, so the same tree always produces byte-identical output and can be
|
|
17
|
+
* asserted on in tests and cached by hosts.
|
|
18
|
+
*/
|
|
19
|
+
import { createLogger } from '../core/logger.js';
|
|
20
|
+
import { escapePointerToken, toBinding } from './expr.js';
|
|
21
|
+
import { fallbackMapper, isConsumedByParent, mapperFor } from './catalog.js';
|
|
22
|
+
import { A2UI_BASIC_CATALOG, A2UI_ROOT_ID, A2UI_VERSION, } from './types.js';
|
|
23
|
+
const log = createLogger('a2ui');
|
|
24
|
+
/**
|
|
25
|
+
* The wrapper `toJSON()` puts around every view. It carries a CSS class and
|
|
26
|
+
* nothing else, so it is unwrapped rather than emitted as a pointless Column.
|
|
27
|
+
*/
|
|
28
|
+
function unwrapAppRoot(view) {
|
|
29
|
+
const children = view.children;
|
|
30
|
+
if (view.type === 'Div'
|
|
31
|
+
&& typeof view.cssClass === 'string'
|
|
32
|
+
&& view.cssClass.startsWith('pf-app-root')
|
|
33
|
+
&& Array.isArray(children)
|
|
34
|
+
&& children.length === 1) {
|
|
35
|
+
return children[0];
|
|
36
|
+
}
|
|
37
|
+
return view;
|
|
38
|
+
}
|
|
39
|
+
class Emitter {
|
|
40
|
+
warn;
|
|
41
|
+
/** Insertion-ordered; `undefined` marks a reserved slot that was released. */
|
|
42
|
+
components = new Map();
|
|
43
|
+
dataModel = {};
|
|
44
|
+
used = new Set([A2UI_ROOT_ID]);
|
|
45
|
+
diagnostics = [];
|
|
46
|
+
counter = 0;
|
|
47
|
+
constructor(warn) {
|
|
48
|
+
this.warn = warn;
|
|
49
|
+
}
|
|
50
|
+
note(kind, subject, detail) {
|
|
51
|
+
this.diagnostics.push({ kind, subject, detail });
|
|
52
|
+
if (this.warn)
|
|
53
|
+
log.warn(`${kind}: ${subject} — ${detail}`);
|
|
54
|
+
}
|
|
55
|
+
/** Allocate an id, honouring an author-supplied one when it is still free. */
|
|
56
|
+
allocate(node) {
|
|
57
|
+
const preferred = typeof node?.id === 'string' && node.id.length > 0 ? node.id : undefined;
|
|
58
|
+
if (preferred != null && !this.used.has(preferred)) {
|
|
59
|
+
this.used.add(preferred);
|
|
60
|
+
return preferred;
|
|
61
|
+
}
|
|
62
|
+
let id;
|
|
63
|
+
do {
|
|
64
|
+
this.counter += 1;
|
|
65
|
+
id = `c${this.counter}`;
|
|
66
|
+
} while (this.used.has(id));
|
|
67
|
+
this.used.add(id);
|
|
68
|
+
return id;
|
|
69
|
+
}
|
|
70
|
+
push(props) {
|
|
71
|
+
const id = this.allocate();
|
|
72
|
+
this.components.set(id, { id, ...props });
|
|
73
|
+
return id;
|
|
74
|
+
}
|
|
75
|
+
bindData(key, value) {
|
|
76
|
+
let name = key;
|
|
77
|
+
let n = 0;
|
|
78
|
+
while (name in this.dataModel) {
|
|
79
|
+
n += 1;
|
|
80
|
+
name = `${key}${n}`;
|
|
81
|
+
}
|
|
82
|
+
this.dataModel[name] = value;
|
|
83
|
+
return `/${escapePointerToken(name)}`;
|
|
84
|
+
}
|
|
85
|
+
child(node) {
|
|
86
|
+
return this.emit(node, false);
|
|
87
|
+
}
|
|
88
|
+
children(nodes) {
|
|
89
|
+
if (!Array.isArray(nodes))
|
|
90
|
+
return [];
|
|
91
|
+
const ids = [];
|
|
92
|
+
for (const node of nodes) {
|
|
93
|
+
if (node == null || typeof node !== 'object')
|
|
94
|
+
continue;
|
|
95
|
+
const id = this.emit(node, false);
|
|
96
|
+
if (id != null)
|
|
97
|
+
ids.push(id);
|
|
98
|
+
}
|
|
99
|
+
return ids;
|
|
100
|
+
}
|
|
101
|
+
single(nodes) {
|
|
102
|
+
const ids = this.children(nodes);
|
|
103
|
+
if (ids.length === 0)
|
|
104
|
+
return undefined;
|
|
105
|
+
if (ids.length === 1)
|
|
106
|
+
return ids[0];
|
|
107
|
+
// A2UI's single-child slots take one id, so several children need a wrapper.
|
|
108
|
+
return this.push({ component: 'Column', children: ids });
|
|
109
|
+
}
|
|
110
|
+
action(value, subject) {
|
|
111
|
+
if (value == null)
|
|
112
|
+
return undefined;
|
|
113
|
+
if (Array.isArray(value)) {
|
|
114
|
+
if (value.length === 0)
|
|
115
|
+
return undefined;
|
|
116
|
+
if (value.length > 1) {
|
|
117
|
+
this.note('action', subject, `${value.length} actions were bound; A2UI carries one, so the rest were dropped`);
|
|
118
|
+
}
|
|
119
|
+
return this.action(value[0], subject);
|
|
120
|
+
}
|
|
121
|
+
if (typeof value !== 'object')
|
|
122
|
+
return undefined;
|
|
123
|
+
const json = value;
|
|
124
|
+
const kind = typeof json.action === 'string' ? json.action : undefined;
|
|
125
|
+
if (kind == null)
|
|
126
|
+
return undefined;
|
|
127
|
+
switch (kind) {
|
|
128
|
+
case 'toolCall': {
|
|
129
|
+
const tool = typeof json.tool === 'string' ? json.tool : undefined;
|
|
130
|
+
if (tool == null)
|
|
131
|
+
return undefined;
|
|
132
|
+
const context = this.eventContext(json.arguments, subject);
|
|
133
|
+
return { event: { name: tool, ...(context != null && { context }) } };
|
|
134
|
+
}
|
|
135
|
+
case 'sendMessage': {
|
|
136
|
+
const message = typeof json.message === 'string' ? json.message : '';
|
|
137
|
+
return { event: { name: 'sendMessage', context: { message } } };
|
|
138
|
+
}
|
|
139
|
+
case 'openLink': {
|
|
140
|
+
const url = typeof json.url === 'string' ? json.url : typeof json.href === 'string' ? json.href : undefined;
|
|
141
|
+
if (url == null)
|
|
142
|
+
return undefined;
|
|
143
|
+
return { functionCall: { call: 'openUrl', args: { url } } };
|
|
144
|
+
}
|
|
145
|
+
default: {
|
|
146
|
+
// Everything else mutates renderer state, which the Basic catalog has no
|
|
147
|
+
// function for. Reporting the intent to the agent keeps the control
|
|
148
|
+
// interactive instead of dropping it for want of an action.
|
|
149
|
+
this.note('action', subject, `"${kind}" has no renderer-side equivalent; emitted as an agent event`);
|
|
150
|
+
const { action: _kind, ...rest } = json;
|
|
151
|
+
const context = this.eventContext(rest, subject);
|
|
152
|
+
return { event: { name: kind, ...(context != null && { context }) } };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Convert a prefab action's argument bag into an A2UI event context.
|
|
158
|
+
*
|
|
159
|
+
* Values go through the same `{{ }}` conversion as component props, so a
|
|
160
|
+
* `CallTool('search', { arguments: { q: '{{ query }}' } })` sends the bound
|
|
161
|
+
* value rather than shipping the uninterpolated template to the agent.
|
|
162
|
+
*/
|
|
163
|
+
eventContext(value, subject) {
|
|
164
|
+
if (value == null || typeof value !== 'object' || Array.isArray(value))
|
|
165
|
+
return undefined;
|
|
166
|
+
const context = {};
|
|
167
|
+
for (const [key, raw] of Object.entries(value)) {
|
|
168
|
+
if (typeof raw === 'number' || typeof raw === 'boolean' || raw === null) {
|
|
169
|
+
context[key] = raw;
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (typeof raw !== 'string') {
|
|
173
|
+
this.note('action', subject, `argument "${key}" is not a scalar and was dropped from the event context`);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
const bound = toBinding(raw);
|
|
177
|
+
if (bound.kind === 'unbindable') {
|
|
178
|
+
this.note('action', subject, `argument "${key}" uses "${bound.expression}", which A2UI cannot bind; it was dropped`);
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
context[key] = bound.kind === 'binding' ? bound.value : bound.value;
|
|
182
|
+
}
|
|
183
|
+
return Object.keys(context).length > 0 ? context : undefined;
|
|
184
|
+
}
|
|
185
|
+
/** Emit one subtree. Returns the allocated id, or `undefined` if it was dropped. */
|
|
186
|
+
emit(node, isRoot) {
|
|
187
|
+
if (typeof node.type !== 'string')
|
|
188
|
+
return undefined;
|
|
189
|
+
if (isConsumedByParent(node.type)) {
|
|
190
|
+
this.note('unsupported', node.type, 'only meaningful inside its parent; emitted standalone it has no meaning');
|
|
191
|
+
return undefined;
|
|
192
|
+
}
|
|
193
|
+
const id = isRoot ? A2UI_ROOT_ID : this.allocate(node);
|
|
194
|
+
// Reserve the slot before the mapper runs, so children emitted during
|
|
195
|
+
// mapping cannot claim this id.
|
|
196
|
+
this.components.set(id, undefined);
|
|
197
|
+
const mapper = mapperFor(node.type) ?? fallbackMapper;
|
|
198
|
+
const props = mapper(node, this);
|
|
199
|
+
if (props == null) {
|
|
200
|
+
this.components.delete(id);
|
|
201
|
+
if (!isRoot)
|
|
202
|
+
this.used.delete(id);
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
this.components.set(id, { id, ...props });
|
|
206
|
+
return id;
|
|
207
|
+
}
|
|
208
|
+
finish(wire, options) {
|
|
209
|
+
const surfaceId = options.surfaceId ?? 'prefab';
|
|
210
|
+
const rootId = this.emit(unwrapAppRoot(wire.view), true);
|
|
211
|
+
if (rootId == null) {
|
|
212
|
+
this.note('unsupported', 'view', 'nothing in the view could be expressed in A2UI; the surface is empty');
|
|
213
|
+
}
|
|
214
|
+
const components = [];
|
|
215
|
+
for (const c of this.components.values())
|
|
216
|
+
if (c != null)
|
|
217
|
+
components.push(c);
|
|
218
|
+
// prefab state and any literals seeded during mapping share one data model.
|
|
219
|
+
// State wins on a collision, since seeded keys are generated and state keys
|
|
220
|
+
// are author-chosen.
|
|
221
|
+
const dataModel = { ...this.dataModel, ...(wire.state ?? {}) };
|
|
222
|
+
const hasData = Object.keys(dataModel).length > 0;
|
|
223
|
+
const messages = [];
|
|
224
|
+
const catalogId = options.catalogId ?? A2UI_BASIC_CATALOG;
|
|
225
|
+
if (options.stream === true) {
|
|
226
|
+
messages.push({
|
|
227
|
+
version: A2UI_VERSION,
|
|
228
|
+
createSurface: {
|
|
229
|
+
surfaceId,
|
|
230
|
+
catalogId,
|
|
231
|
+
...(options.sendDataModel === true && { sendDataModel: true }),
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
if (components.length > 0) {
|
|
235
|
+
messages.push({ version: A2UI_VERSION, updateComponents: { surfaceId, components } });
|
|
236
|
+
}
|
|
237
|
+
if (hasData) {
|
|
238
|
+
messages.push({ version: A2UI_VERSION, updateDataModel: { surfaceId, value: dataModel } });
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
messages.push({
|
|
243
|
+
version: A2UI_VERSION,
|
|
244
|
+
createSurface: {
|
|
245
|
+
surfaceId,
|
|
246
|
+
catalogId,
|
|
247
|
+
...(options.sendDataModel === true && { sendDataModel: true }),
|
|
248
|
+
...(components.length > 0 && { components }),
|
|
249
|
+
...(hasData && { dataModel }),
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
return { messages, diagnostics: this.diagnostics };
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Translate a `$prefab` wire payload into A2UI messages.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* const { messages, diagnostics } = emitA2UI(app.toJSON())
|
|
262
|
+
* if (diagnostics.length > 0) console.warn(diagnostics)
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
export function emitA2UI(wire, options) {
|
|
266
|
+
const opts = options ?? {};
|
|
267
|
+
return new Emitter(opts.warn === true).finish(wire, opts);
|
|
268
|
+
}
|
|
269
|
+
//# sourceMappingURL=emit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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AE,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC,CAAA;YAC5F,CAAC;QACH,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,IAAI,CAAC;gBACZ,OAAO,EAAE,YAAY;gBACrB,aAAa,EAAE;oBACb,SAAS;oBACT,SAAS;oBACT,GAAG,CAAC,OAAO,CAAC,aAAa,KAAK,IAAI,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;oBAC9D,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC;oBAC5C,GAAG,CAAC,OAAO,IAAI,EAAE,SAAS,EAAE,CAAC;iBAC9B;aACF,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAA;IACpD,CAAC;CACF;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAsB,EAAE,OAAyB;IACxE,MAAM,IAAI,GAAG,OAAO,IAAI,EAAE,CAAA;IAC1B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AAC3D,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `{{ }}` template → A2UI data binding.
|
|
3
|
+
*
|
|
4
|
+
* `$prefab` interpolates arbitrary expressions client-side — `{{ count + 1 }}`,
|
|
5
|
+
* `{{ price | currency:'USD' }}`, `{{ active ? 'Yes' : 'No' }}`. A2UI binds
|
|
6
|
+
* values through JSON Pointer paths into the data model and has no expression
|
|
7
|
+
* language, so only the plain-path subset crosses over: `{{ user.name }}`
|
|
8
|
+
* becomes `{ path: '/user/name' }`, and anything with an operator, pipe or
|
|
9
|
+
* conditional does not survive.
|
|
10
|
+
*
|
|
11
|
+
* Rather than silently emitting a broken binding, richer expressions are
|
|
12
|
+
* reported back to the caller as an `expression` diagnostic and the property is
|
|
13
|
+
* dropped, so the failure shows up at emit time instead of as an empty widget
|
|
14
|
+
* in someone's renderer.
|
|
15
|
+
*/
|
|
16
|
+
import type { A2uiDataBinding, A2uiDynamicString } from './types.js';
|
|
17
|
+
/**
|
|
18
|
+
* Escape one JSON Pointer reference token (RFC 6901 §3).
|
|
19
|
+
*
|
|
20
|
+
* `~` must be escaped before `/`, otherwise the `~1` produced for a slash gets
|
|
21
|
+
* re-escaped into `~01` on the second pass.
|
|
22
|
+
*/
|
|
23
|
+
export declare function escapePointerToken(token: string): string;
|
|
24
|
+
/** Build a JSON Pointer from already-split path segments. */
|
|
25
|
+
export declare function toJsonPointer(segments: string[]): string;
|
|
26
|
+
/** The outcome of converting one prefab value into an A2UI dynamic value. */
|
|
27
|
+
export type BindingResult =
|
|
28
|
+
/** A literal with no template in it. */
|
|
29
|
+
{
|
|
30
|
+
kind: 'literal';
|
|
31
|
+
value: string;
|
|
32
|
+
}
|
|
33
|
+
/** A `{{ path }}` that mapped cleanly onto a JSON Pointer. */
|
|
34
|
+
| {
|
|
35
|
+
kind: 'binding';
|
|
36
|
+
value: A2uiDataBinding;
|
|
37
|
+
}
|
|
38
|
+
/** A template too rich for A2UI. `expression` is the source, for diagnostics. */
|
|
39
|
+
| {
|
|
40
|
+
kind: 'unbindable';
|
|
41
|
+
expression: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Convert a prefab string value into an A2UI dynamic value.
|
|
45
|
+
*
|
|
46
|
+
* Whole-string templates over a plain member path become bindings; strings with
|
|
47
|
+
* no template at all pass through as literals; everything else is unbindable.
|
|
48
|
+
* Mixed text such as `Hello {{ name }}` is unbindable too — A2UI has no string
|
|
49
|
+
* interpolation, and `formatString` would need an argument list this function
|
|
50
|
+
* has no way to name.
|
|
51
|
+
*/
|
|
52
|
+
export declare function toBinding(value: string): BindingResult;
|
|
53
|
+
/**
|
|
54
|
+
* Resolve a value to an `A2uiDynamicString`, or `undefined` when it cannot be
|
|
55
|
+
* expressed. Callers pair this with a diagnostic when it returns `undefined`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function dynamicString(value: string | undefined): A2uiDynamicString | undefined;
|
|
58
|
+
//# sourceMappingURL=expr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expr.d.ts","sourceRoot":"","sources":["../../src/a2ui/expr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAapE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,6DAA6D;AAC7D,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAExD;AAWD,6EAA6E;AAC7E,MAAM,MAAM,aAAa;AACvB,wCAAwC;AACtC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AACpC,8DAA8D;GAC5D;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,eAAe,CAAA;CAAE;AAC7C,iFAAiF;GAC/E;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAA;AAE9C;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAWtD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,iBAAiB,GAAG,SAAS,CAMtF"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `{{ }}` template → A2UI data binding.
|
|
3
|
+
*
|
|
4
|
+
* `$prefab` interpolates arbitrary expressions client-side — `{{ count + 1 }}`,
|
|
5
|
+
* `{{ price | currency:'USD' }}`, `{{ active ? 'Yes' : 'No' }}`. A2UI binds
|
|
6
|
+
* values through JSON Pointer paths into the data model and has no expression
|
|
7
|
+
* language, so only the plain-path subset crosses over: `{{ user.name }}`
|
|
8
|
+
* becomes `{ path: '/user/name' }`, and anything with an operator, pipe or
|
|
9
|
+
* conditional does not survive.
|
|
10
|
+
*
|
|
11
|
+
* Rather than silently emitting a broken binding, richer expressions are
|
|
12
|
+
* reported back to the caller as an `expression` diagnostic and the property is
|
|
13
|
+
* dropped, so the failure shows up at emit time instead of as an empty widget
|
|
14
|
+
* in someone's renderer.
|
|
15
|
+
*/
|
|
16
|
+
/** Matches a string that is exactly one `{{ … }}` template and nothing else. */
|
|
17
|
+
const SOLE_TEMPLATE = /^\s*\{\{\s*(.+?)\s*\}\}\s*$/s;
|
|
18
|
+
/**
|
|
19
|
+
* A plain member path: `user.name`, `items.0.label`, `count`.
|
|
20
|
+
*
|
|
21
|
+
* Deliberately narrow. Anything outside this shape (operators, pipes, calls,
|
|
22
|
+
* ternaries, string literals) has no A2UI equivalent.
|
|
23
|
+
*/
|
|
24
|
+
const PLAIN_PATH = /^[A-Za-z_$][\w$]*(?:\.(?:[A-Za-z_$][\w$]*|\d+))*$/;
|
|
25
|
+
/**
|
|
26
|
+
* Escape one JSON Pointer reference token (RFC 6901 §3).
|
|
27
|
+
*
|
|
28
|
+
* `~` must be escaped before `/`, otherwise the `~1` produced for a slash gets
|
|
29
|
+
* re-escaped into `~01` on the second pass.
|
|
30
|
+
*/
|
|
31
|
+
export function escapePointerToken(token) {
|
|
32
|
+
return token.replace(/~/g, '~0').replace(/\//g, '~1');
|
|
33
|
+
}
|
|
34
|
+
/** Build a JSON Pointer from already-split path segments. */
|
|
35
|
+
export function toJsonPointer(segments) {
|
|
36
|
+
return '/' + segments.map(escapePointerToken).join('/');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* prefab state expressions address state keys directly (`count`), but actions
|
|
40
|
+
* and docs also spell the same key as `state.count`. Both mean the root of the
|
|
41
|
+
* data model, so the prefix is stripped before the pointer is built.
|
|
42
|
+
*/
|
|
43
|
+
function stripStatePrefix(path) {
|
|
44
|
+
return path.startsWith('state.') ? path.slice('state.'.length) : path;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Convert a prefab string value into an A2UI dynamic value.
|
|
48
|
+
*
|
|
49
|
+
* Whole-string templates over a plain member path become bindings; strings with
|
|
50
|
+
* no template at all pass through as literals; everything else is unbindable.
|
|
51
|
+
* Mixed text such as `Hello {{ name }}` is unbindable too — A2UI has no string
|
|
52
|
+
* interpolation, and `formatString` would need an argument list this function
|
|
53
|
+
* has no way to name.
|
|
54
|
+
*/
|
|
55
|
+
export function toBinding(value) {
|
|
56
|
+
const sole = SOLE_TEMPLATE.exec(value);
|
|
57
|
+
if (sole == null) {
|
|
58
|
+
if (value.includes('{{'))
|
|
59
|
+
return { kind: 'unbindable', expression: value };
|
|
60
|
+
return { kind: 'literal', value };
|
|
61
|
+
}
|
|
62
|
+
const expr = stripStatePrefix(sole[1].trim());
|
|
63
|
+
if (!PLAIN_PATH.test(expr))
|
|
64
|
+
return { kind: 'unbindable', expression: sole[1].trim() };
|
|
65
|
+
return { kind: 'binding', value: { path: toJsonPointer(expr.split('.')) } };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Resolve a value to an `A2uiDynamicString`, or `undefined` when it cannot be
|
|
69
|
+
* expressed. Callers pair this with a diagnostic when it returns `undefined`.
|
|
70
|
+
*/
|
|
71
|
+
export function dynamicString(value) {
|
|
72
|
+
if (value == null)
|
|
73
|
+
return undefined;
|
|
74
|
+
const r = toBinding(value);
|
|
75
|
+
if (r.kind === 'literal')
|
|
76
|
+
return r.value;
|
|
77
|
+
if (r.kind === 'binding')
|
|
78
|
+
return r.value;
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=expr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expr.js","sourceRoot":"","sources":["../../src/a2ui/expr.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AE,YAAY,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAA;IAErF,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAA;AAC7E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,SAAS,CAAA;IACnC,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;IAC1B,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC,KAAK,CAAA;IACxC,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC,KAAK,CAAA;IACxC,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* prefab icon name → A2UI Basic catalog icon.
|
|
3
|
+
*
|
|
4
|
+
* The one place where the two catalogs disagree on *values* rather than on
|
|
5
|
+
* component shape. prefab's `Icon(name)` takes any string, because its renderer
|
|
6
|
+
* resolves Lucide names at runtime and new icons cost nothing. A2UI's
|
|
7
|
+
* `Icon.name` is a closed enum of 59 names, so an unrecognised value does not
|
|
8
|
+
* render as a fallback glyph — it makes the whole component fail validation.
|
|
9
|
+
*
|
|
10
|
+
* Passing the name through unchecked therefore emits an invalid surface for
|
|
11
|
+
* every icon outside those 59, which is most of them. Instead the name is
|
|
12
|
+
* normalised, matched against the enum, and dropped with a diagnostic when
|
|
13
|
+
* nothing fits, so an unmappable icon costs a glyph rather than the payload.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* The A2UI Basic catalog's `Icon.name` enum, v1.0.
|
|
17
|
+
*
|
|
18
|
+
* Duplicated as a literal because prefab ships zero runtime dependencies and
|
|
19
|
+
* cannot read the catalog JSON at emit time. `test/a2ui-icons.test.ts` asserts
|
|
20
|
+
* this matches the vendored catalog exactly, so it cannot drift silently.
|
|
21
|
+
*/
|
|
22
|
+
export declare const A2UI_ICONS: readonly string[];
|
|
23
|
+
/**
|
|
24
|
+
* Resolve a prefab icon name to an A2UI one.
|
|
25
|
+
*
|
|
26
|
+
* @returns the catalog name, or `undefined` when nothing in the enum means the
|
|
27
|
+
* same thing. Callers drop the icon and record a diagnostic.
|
|
28
|
+
*/
|
|
29
|
+
export declare function a2uiIconName(name: string): string | undefined;
|
|
30
|
+
//# sourceMappingURL=icons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/a2ui/icons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,SAAS,MAAM,EAUvC,CAAA;AAiDD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG7D"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* prefab icon name → A2UI Basic catalog icon.
|
|
3
|
+
*
|
|
4
|
+
* The one place where the two catalogs disagree on *values* rather than on
|
|
5
|
+
* component shape. prefab's `Icon(name)` takes any string, because its renderer
|
|
6
|
+
* resolves Lucide names at runtime and new icons cost nothing. A2UI's
|
|
7
|
+
* `Icon.name` is a closed enum of 59 names, so an unrecognised value does not
|
|
8
|
+
* render as a fallback glyph — it makes the whole component fail validation.
|
|
9
|
+
*
|
|
10
|
+
* Passing the name through unchecked therefore emits an invalid surface for
|
|
11
|
+
* every icon outside those 59, which is most of them. Instead the name is
|
|
12
|
+
* normalised, matched against the enum, and dropped with a diagnostic when
|
|
13
|
+
* nothing fits, so an unmappable icon costs a glyph rather than the payload.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* The A2UI Basic catalog's `Icon.name` enum, v1.0.
|
|
17
|
+
*
|
|
18
|
+
* Duplicated as a literal because prefab ships zero runtime dependencies and
|
|
19
|
+
* cannot read the catalog JSON at emit time. `test/a2ui-icons.test.ts` asserts
|
|
20
|
+
* this matches the vendored catalog exactly, so it cannot drift silently.
|
|
21
|
+
*/
|
|
22
|
+
export const A2UI_ICONS = [
|
|
23
|
+
'accountCircle', 'add', 'arrowBack', 'arrowForward', 'attachFile', 'calendarToday',
|
|
24
|
+
'call', 'camera', 'check', 'close', 'delete', 'download', 'edit', 'event', 'error',
|
|
25
|
+
'fastForward', 'favorite', 'favoriteOff', 'folder', 'help', 'home', 'info',
|
|
26
|
+
'locationOn', 'lock', 'lockOpen', 'mail', 'menu', 'moreVert', 'moreHoriz',
|
|
27
|
+
'notificationsOff', 'notifications', 'pause', 'payment', 'person', 'phone', 'photo',
|
|
28
|
+
'play', 'print', 'refresh', 'rewind', 'search', 'send', 'settings', 'share',
|
|
29
|
+
'shoppingCart', 'skipNext', 'skipPrevious', 'star', 'starHalf', 'starOff', 'stop',
|
|
30
|
+
'upload', 'visibility', 'visibilityOff', 'volumeDown', 'volumeMute', 'volumeOff',
|
|
31
|
+
'volumeUp', 'warning',
|
|
32
|
+
];
|
|
33
|
+
/** Lookup by normalised form, so `Arrow-Back`, `arrow_back` and `ArrowBack` all hit. */
|
|
34
|
+
const BY_NORMALISED = new Map(A2UI_ICONS.map(name => [normalise(name), name]));
|
|
35
|
+
/**
|
|
36
|
+
* Names that differ between the two vocabularies rather than merely in case.
|
|
37
|
+
*
|
|
38
|
+
* prefab follows Lucide, A2UI follows Material. Where the concept exists in both
|
|
39
|
+
* under different words, the alias keeps the icon; where it does not, the entry
|
|
40
|
+
* is absent and the icon is dropped rather than mapped to something that means
|
|
41
|
+
* something else. Keys are normalised, so one entry covers every spelling.
|
|
42
|
+
*/
|
|
43
|
+
const ALIASES = {
|
|
44
|
+
// Status and feedback
|
|
45
|
+
alertcircle: 'error', alerttriangle: 'warning', alertoctagon: 'error',
|
|
46
|
+
xcircle: 'error', circlex: 'error', circlealert: 'error',
|
|
47
|
+
checkcircle: 'check', circlecheck: 'check', checkcircle2: 'check',
|
|
48
|
+
infocircle: 'info', circleinfo: 'info', helpcircle: 'help', circlehelp: 'help',
|
|
49
|
+
bell: 'notifications', belloff: 'notificationsOff',
|
|
50
|
+
// Navigation
|
|
51
|
+
arrowleft: 'arrowBack', arrowright: 'arrowForward',
|
|
52
|
+
chevronleft: 'arrowBack', chevronright: 'arrowForward',
|
|
53
|
+
x: 'close', plus: 'add', trash: 'delete', trash2: 'delete',
|
|
54
|
+
ellipsisvertical: 'moreVert', ellipsis: 'moreHoriz', morehorizontal: 'moreHoriz',
|
|
55
|
+
morevertical: 'moreVert',
|
|
56
|
+
// Objects and actions
|
|
57
|
+
pencil: 'edit', pen: 'edit', squarepen: 'edit',
|
|
58
|
+
user: 'person', usercircle: 'accountCircle', circleuser: 'accountCircle',
|
|
59
|
+
eye: 'visibility', eyeoff: 'visibilityOff',
|
|
60
|
+
mappin: 'locationOn', map: 'locationOn',
|
|
61
|
+
image: 'photo', images: 'photo', file: 'folder', files: 'folder',
|
|
62
|
+
calendar: 'calendarToday', calendardays: 'calendarToday', clock: 'event',
|
|
63
|
+
creditcard: 'payment', cart: 'shoppingCart', shoppingbag: 'shoppingCart',
|
|
64
|
+
phonecall: 'call', mailopen: 'mail', inbox: 'mail',
|
|
65
|
+
cog: 'settings', gear: 'settings', sliders: 'settings',
|
|
66
|
+
rotatecw: 'refresh', rotateccw: 'refresh', refreshcw: 'refresh',
|
|
67
|
+
heart: 'favorite', heartoff: 'favoriteOff',
|
|
68
|
+
volume: 'volumeUp', volume1: 'volumeDown', volume2: 'volumeUp', volumex: 'volumeOff',
|
|
69
|
+
skipforward: 'skipNext', skipback: 'skipPrevious',
|
|
70
|
+
paperclip: 'attachFile', link: 'share', share2: 'share',
|
|
71
|
+
magnifyingglass: 'search', searchicon: 'search',
|
|
72
|
+
};
|
|
73
|
+
/** Case-insensitive, separator-insensitive key for matching either vocabulary. */
|
|
74
|
+
function normalise(name) {
|
|
75
|
+
return name.replace(/[\s._-]/g, '').toLowerCase();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Resolve a prefab icon name to an A2UI one.
|
|
79
|
+
*
|
|
80
|
+
* @returns the catalog name, or `undefined` when nothing in the enum means the
|
|
81
|
+
* same thing. Callers drop the icon and record a diagnostic.
|
|
82
|
+
*/
|
|
83
|
+
export function a2uiIconName(name) {
|
|
84
|
+
const key = normalise(name);
|
|
85
|
+
return BY_NORMALISED.get(key) ?? ALIASES[key];
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=icons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../../src/a2ui/icons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAsB;IAC3C,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe;IAClF,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAClF,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAC1E,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW;IACzE,kBAAkB,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO;IACnF,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO;IAC3E,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,UA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|
|
1
|
+
/**
|
|
2
|
+
* A2UI emitter — the second output target alongside the `$prefab` wire format.
|
|
3
|
+
*
|
|
4
|
+
* `$prefab` payloads render through prefab's own renderer, in an MCP Apps
|
|
5
|
+
* iframe or any web app. A2UI payloads render natively in the A2UI renderers
|
|
6
|
+
* (React, Angular, Lit, Flutter, Swift, Compose) with no iframe involved. Both
|
|
7
|
+
* come from the same server-side component tree.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { Column, H1, autoTable } from '@maxhealth.tech/prefab'
|
|
12
|
+
* import { PrefabApp } from '@maxhealth.tech/prefab'
|
|
13
|
+
*
|
|
14
|
+
* const app = new PrefabApp({ view: Column({ children: [H1('Users'), autoTable(rows)] }) })
|
|
15
|
+
* const { messages, diagnostics } = app.toA2UI()
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export { emitA2UI } from './emit.js';
|
|
19
|
+
export type { A2uiEmitOptions, A2uiEmitResult } from './emit.js';
|
|
20
|
+
export { mappedTypes } from './catalog.js';
|
|
21
|
+
export { a2uiIconName, A2UI_ICONS } from './icons.js';
|
|
22
|
+
export type { A2uiProps, EmitContext, Mapper } from './catalog.js';
|
|
23
|
+
export { toBinding, toJsonPointer, escapePointerToken, dynamicString } from './expr.js';
|
|
24
|
+
export type { BindingResult } from './expr.js';
|
|
25
|
+
export { A2UI_VERSION, A2UI_BASIC_CATALOG, A2UI_MIME, A2UI_SCHEME, A2UI_ROOT_ID, } from './types.js';
|
|
26
|
+
export type { A2uiAccessibility, A2uiAction, A2uiChildList, A2uiChildTemplate, A2uiComponent, A2uiCreateSurface, A2uiDataBinding, A2uiDeleteSurface, A2uiDiagnostic, A2uiDiagnosticKind, A2uiDynamicBoolean, A2uiDynamicNumber, A2uiDynamicString, A2uiDynamicValue, A2uiEventAction, A2uiFunctionAction, A2uiFunctionCall, A2uiMessage, A2uiMessageList, A2uiUpdateComponents, A2uiUpdateDataModel, } from './types.js';
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/a2ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAEhE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACrD,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAElE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACvF,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAE9C,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,WAAW,EACX,YAAY,GACb,MAAM,YAAY,CAAA;AACnB,YAAY,EACV,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2UI emitter — the second output target alongside the `$prefab` wire format.
|
|
3
|
+
*
|
|
4
|
+
* `$prefab` payloads render through prefab's own renderer, in an MCP Apps
|
|
5
|
+
* iframe or any web app. A2UI payloads render natively in the A2UI renderers
|
|
6
|
+
* (React, Angular, Lit, Flutter, Swift, Compose) with no iframe involved. Both
|
|
7
|
+
* come from the same server-side component tree.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { Column, H1, autoTable } from '@maxhealth.tech/prefab'
|
|
12
|
+
* import { PrefabApp } from '@maxhealth.tech/prefab'
|
|
13
|
+
*
|
|
14
|
+
* const app = new PrefabApp({ view: Column({ children: [H1('Users'), autoTable(rows)] }) })
|
|
15
|
+
* const { messages, diagnostics } = app.toA2UI()
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export { emitA2UI } from './emit.js';
|
|
19
|
+
export { mappedTypes } from './catalog.js';
|
|
20
|
+
export { a2uiIconName, A2UI_ICONS } from './icons.js';
|
|
21
|
+
export { toBinding, toJsonPointer, escapePointerToken, dynamicString } from './expr.js';
|
|
22
|
+
export { A2UI_VERSION, A2UI_BASIC_CATALOG, A2UI_MIME, A2UI_SCHEME, A2UI_ROOT_ID, } from './types.js';
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/a2ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGpC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAGrD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAGvF,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,WAAW,EACX,YAAY,GACb,MAAM,YAAY,CAAA"}
|