@adia-ai/a2ui 0.8.37
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 +1073 -0
- package/README.md +99 -0
- package/a2ui.schema.d.ts +192 -0
- package/controllers/accordion.js +73 -0
- package/controllers/base.js +68 -0
- package/controllers/data-stream.js +281 -0
- package/controllers/form.js +81 -0
- package/controllers/index.js +6 -0
- package/controllers/selection.js +82 -0
- package/controllers/state-machine.js +135 -0
- package/controllers/toggle.js +40 -0
- package/dockables/action.d.ts +55 -0
- package/dockables/action.js +152 -0
- package/dockables/base.d.ts +26 -0
- package/dockables/base.js +30 -0
- package/dockables/controller.d.ts +35 -0
- package/dockables/controller.js +97 -0
- package/dockables/data-source.d.ts +35 -0
- package/dockables/data-source.js +103 -0
- package/dockables/index.d.ts +21 -0
- package/dockables/index.js +6 -0
- package/dockables/lifecycle.d.ts +38 -0
- package/dockables/lifecycle.js +84 -0
- package/dockables/provider.d.ts +28 -0
- package/dockables/provider.js +59 -0
- package/index.d.ts +64 -0
- package/index.js +54 -0
- package/package.json +89 -0
- package/prop-apply.d.ts +13 -0
- package/prop-apply.js +113 -0
- package/registry.d.ts +17 -0
- package/registry.js +418 -0
- package/renderer.d.ts +67 -0
- package/renderer.js +715 -0
- package/stream.d.ts +62 -0
- package/stream.js +521 -0
- package/surface-manifest.d.ts +73 -0
- package/surface-manifest.js +294 -0
- package/surface.d.ts +72 -0
- package/surface.js +222 -0
- package/types.d.ts +26 -0
- package/validate/CHANGELOG.md +1005 -0
- package/validate/README.md +146 -0
- package/validate/index.d.ts +4 -0
- package/validate/index.js +12 -0
- package/validate/validator.d.ts +4 -0
- package/validate/validator.js +1232 -0
- package/wire-factory.d.ts +15 -0
- package/wire-factory.js +134 -0
- package/wiring-engine.d.ts +61 -0
- package/wiring-engine.js +209 -0
- package/wiring-registry.d.ts +80 -0
- package/wiring-registry.js +342 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ControllerDock — Wraps a AdiaUI controller as a dockable.
|
|
3
|
+
*
|
|
4
|
+
* Instantiates the controller, connects it to its host element,
|
|
5
|
+
* and sets up two-way binding between controller state and model paths.
|
|
6
|
+
*/
|
|
7
|
+
import { Dockable } from './base.js';
|
|
8
|
+
|
|
9
|
+
export class ControllerDock extends Dockable {
|
|
10
|
+
kind = 'controller';
|
|
11
|
+
|
|
12
|
+
/** @type {string} */
|
|
13
|
+
id;
|
|
14
|
+
|
|
15
|
+
/** @type {string} controller type name, e.g., 'FormController' */
|
|
16
|
+
type;
|
|
17
|
+
|
|
18
|
+
/** @type {string} component id to attach to */
|
|
19
|
+
hostId;
|
|
20
|
+
|
|
21
|
+
/** @type {object} controller config */
|
|
22
|
+
config;
|
|
23
|
+
|
|
24
|
+
/** @type {object|null} model path bindings { stateKey: '/model/path' } */
|
|
25
|
+
bind;
|
|
26
|
+
|
|
27
|
+
/** @type {import('../controllers/base.js').BaseController|null} */
|
|
28
|
+
controller = null;
|
|
29
|
+
|
|
30
|
+
/** @type {Function|null} resolve controller class */
|
|
31
|
+
#resolveClass;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {object} decl — { id, type, host, config?, bind? }
|
|
35
|
+
* @param {Function} resolveClass — async (type) => ControllerClass
|
|
36
|
+
*/
|
|
37
|
+
constructor(decl, resolveClass) {
|
|
38
|
+
super();
|
|
39
|
+
this.id = decl.id;
|
|
40
|
+
this.type = decl.type;
|
|
41
|
+
this.hostId = decl.host;
|
|
42
|
+
this.config = decl.config || {};
|
|
43
|
+
this.bind = decl.bind || null;
|
|
44
|
+
this.#resolveClass = resolveClass;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async dock(ctx) {
|
|
48
|
+
const host = ctx.getElement(this.hostId);
|
|
49
|
+
if (!host) {
|
|
50
|
+
console.warn(`ControllerDock: host element "${this.hostId}" not found`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const ControllerClass = await this.#resolveClass(this.type);
|
|
55
|
+
if (!ControllerClass) {
|
|
56
|
+
console.warn(`ControllerDock: unknown controller type "${this.type}"`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
this.controller = new ControllerClass(this.config);
|
|
61
|
+
this.controller.connect(host);
|
|
62
|
+
|
|
63
|
+
// Two-way bind: controller state ↔ model paths
|
|
64
|
+
const unbinders = [];
|
|
65
|
+
if (this.bind) {
|
|
66
|
+
for (const [stateKey, modelPath] of Object.entries(this.bind)) {
|
|
67
|
+
// Controller → model
|
|
68
|
+
if (this.controller.subscribe) {
|
|
69
|
+
const unsub = this.controller.subscribe(stateKey, (value) => {
|
|
70
|
+
ctx.setModel(modelPath, value);
|
|
71
|
+
});
|
|
72
|
+
if (unsub) unbinders.push(unsub);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Model → controller (initial sync)
|
|
76
|
+
const initial = ctx.getModel(modelPath);
|
|
77
|
+
if (initial !== undefined && this.controller.setState) {
|
|
78
|
+
this.controller.setState(stateKey, initial);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
host.controller = this.controller;
|
|
84
|
+
|
|
85
|
+
return () => {
|
|
86
|
+
host.controller = null;
|
|
87
|
+
unbinders.forEach(u => u());
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
undock() {
|
|
92
|
+
if (this.controller) {
|
|
93
|
+
this.controller.disconnect?.();
|
|
94
|
+
this.controller = null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DataSourceDock — Fetches data and pushes it into the surface model.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Dockable } from './base.js';
|
|
6
|
+
import type { SurfaceContext } from '../surface.js';
|
|
7
|
+
|
|
8
|
+
export interface DataSourceDecl {
|
|
9
|
+
id: string;
|
|
10
|
+
/** URI template, e.g., "resource://users/{userId}" */
|
|
11
|
+
uri: string;
|
|
12
|
+
/** Model path to write fetched data to. */
|
|
13
|
+
path: string;
|
|
14
|
+
/** Refresh strategy: 'once' | 'on-focus' | 'interval:<ms>' | 'stream'. Default: 'once'. */
|
|
15
|
+
refresh?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export declare class DataSourceDock extends Dockable {
|
|
19
|
+
readonly kind: 'source';
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly uri: string;
|
|
22
|
+
readonly path: string;
|
|
23
|
+
readonly refresh: string;
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
decl: DataSourceDecl,
|
|
27
|
+
resolveData: (uri: string, ctx: unknown) => Promise<unknown>,
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
dock(ctx: SurfaceContext): (() => void) | void;
|
|
31
|
+
undock(): void;
|
|
32
|
+
|
|
33
|
+
/** Manually re-fetch the data source. */
|
|
34
|
+
refetch(): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DataSourceDock — Fetches data and pushes it into the surface model.
|
|
3
|
+
*
|
|
4
|
+
* Supports refresh strategies: once, on-focus, interval:{ms}, stream.
|
|
5
|
+
* Re-fetch on demand via refetch() (used by refresh-source handler).
|
|
6
|
+
*/
|
|
7
|
+
import { Dockable } from './base.js';
|
|
8
|
+
|
|
9
|
+
export class DataSourceDock extends Dockable {
|
|
10
|
+
kind = 'source';
|
|
11
|
+
|
|
12
|
+
/** @type {string} */
|
|
13
|
+
id;
|
|
14
|
+
|
|
15
|
+
/** @type {string} URI template, e.g., "resource://users/{userId}" */
|
|
16
|
+
uri;
|
|
17
|
+
|
|
18
|
+
/** @type {string} model path to write to */
|
|
19
|
+
path;
|
|
20
|
+
|
|
21
|
+
/** @type {string} refresh strategy */
|
|
22
|
+
refresh;
|
|
23
|
+
|
|
24
|
+
/** @type {Function} (uri, params) => data */
|
|
25
|
+
#resolveData;
|
|
26
|
+
|
|
27
|
+
/** @type {import('../surface.js').SurfaceContext|null} */
|
|
28
|
+
#ctx = null;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @param {object} decl — { id, uri, path, refresh? }
|
|
32
|
+
* @param {Function} resolveData — async (uri, params) => data
|
|
33
|
+
*/
|
|
34
|
+
constructor(decl, resolveData) {
|
|
35
|
+
super();
|
|
36
|
+
this.id = decl.id;
|
|
37
|
+
this.uri = decl.uri;
|
|
38
|
+
this.path = decl.path;
|
|
39
|
+
this.refresh = decl.refresh || 'once';
|
|
40
|
+
this.#resolveData = resolveData;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
dock(ctx) {
|
|
44
|
+
this.#ctx = ctx;
|
|
45
|
+
|
|
46
|
+
// Initial fetch
|
|
47
|
+
this.#fetch(ctx);
|
|
48
|
+
|
|
49
|
+
// Refresh strategy
|
|
50
|
+
if (this.refresh === 'on-focus') {
|
|
51
|
+
const handler = () => this.#fetch(ctx);
|
|
52
|
+
window.addEventListener('focus', handler);
|
|
53
|
+
return () => window.removeEventListener('focus', handler);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (this.refresh.startsWith('interval:')) {
|
|
57
|
+
const ms = parseInt(this.refresh.split(':')[1], 10);
|
|
58
|
+
if (ms > 0) {
|
|
59
|
+
const id = setInterval(() => this.#fetch(ctx), ms);
|
|
60
|
+
return () => clearInterval(id);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (this.refresh === 'stream') {
|
|
65
|
+
const resolvedUri = this.#resolveUri(ctx);
|
|
66
|
+
try {
|
|
67
|
+
const source = new EventSource(resolvedUri);
|
|
68
|
+
source.onmessage = (e) => {
|
|
69
|
+
try { ctx.setModel(this.path, JSON.parse(e.data)); }
|
|
70
|
+
catch { /* malformed data */ }
|
|
71
|
+
};
|
|
72
|
+
return () => source.close();
|
|
73
|
+
} catch {
|
|
74
|
+
console.warn(`DataSourceDock: stream failed for ${resolvedUri}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
undock() {
|
|
80
|
+
this.#ctx = null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Re-fetch on demand (called by refresh-source handler). */
|
|
84
|
+
refetch() {
|
|
85
|
+
if (this.#ctx) this.#fetch(this.#ctx);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async #fetch(ctx) {
|
|
89
|
+
const resolvedUri = this.#resolveUri(ctx);
|
|
90
|
+
try {
|
|
91
|
+
const data = await this.#resolveData(resolvedUri, ctx);
|
|
92
|
+
if (data !== undefined) ctx.setModel(this.path, data);
|
|
93
|
+
} catch (err) {
|
|
94
|
+
console.warn(`DataSourceDock: fetch failed for ${resolvedUri}`, err);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
#resolveUri(ctx) {
|
|
99
|
+
return this.uri.replace(/\{(\w+)\}/g, (_, key) => {
|
|
100
|
+
return ctx.getParam(key) ?? ctx.getModel('/' + key) ?? '';
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dockables barrel — re-exports all dockable classes and the event mapping.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export { Dockable } from './base.js';
|
|
6
|
+
export type { DockableKind } from './base.js';
|
|
7
|
+
|
|
8
|
+
export { ControllerDock } from './controller.js';
|
|
9
|
+
export type { ControllerDecl } from './controller.js';
|
|
10
|
+
|
|
11
|
+
export { DataSourceDock } from './data-source.js';
|
|
12
|
+
export type { DataSourceDecl } from './data-source.js';
|
|
13
|
+
|
|
14
|
+
export { ActionDock, A2UI_EVENT_TO_DOM } from './action.js';
|
|
15
|
+
export type { ActionDecl, UIEventDecl } from './action.js';
|
|
16
|
+
|
|
17
|
+
export { ProviderDock } from './provider.js';
|
|
18
|
+
export type { ProviderDecl } from './provider.js';
|
|
19
|
+
|
|
20
|
+
export { LifecycleDock } from './lifecycle.js';
|
|
21
|
+
export type { LifecycleDecl, LifecycleAction, ModelChangeWatcher } from './lifecycle.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Dockable } from './base.js';
|
|
2
|
+
export { ControllerDock } from './controller.js';
|
|
3
|
+
export { DataSourceDock } from './data-source.js';
|
|
4
|
+
export { ActionDock, A2UI_EVENT_TO_DOM } from './action.js';
|
|
5
|
+
export { ProviderDock } from './provider.js';
|
|
6
|
+
export { LifecycleDock } from './lifecycle.js';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LifecycleDock — Runs actions on mount, unmount, and model changes.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Dockable } from './base.js';
|
|
6
|
+
import type { SurfaceContext } from '../surface.js';
|
|
7
|
+
|
|
8
|
+
export interface LifecycleAction {
|
|
9
|
+
handler: string;
|
|
10
|
+
config?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ModelChangeWatcher extends LifecycleAction {
|
|
14
|
+
path: string;
|
|
15
|
+
debounce?: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface LifecycleDecl {
|
|
19
|
+
onMount?: LifecycleAction[];
|
|
20
|
+
onUnmount?: LifecycleAction[];
|
|
21
|
+
onModelChange?: ModelChangeWatcher[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export declare class LifecycleDock extends Dockable {
|
|
25
|
+
readonly kind: 'lifecycle';
|
|
26
|
+
readonly id: 'lifecycle';
|
|
27
|
+
readonly onMount: LifecycleAction[];
|
|
28
|
+
readonly onUnmount: LifecycleAction[];
|
|
29
|
+
readonly onModelChange: ModelChangeWatcher[];
|
|
30
|
+
|
|
31
|
+
constructor(
|
|
32
|
+
decl: LifecycleDecl,
|
|
33
|
+
resolveHandler: (name: string) => ((config: unknown, ctx: SurfaceContext) => Promise<unknown>) | null,
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
dock(ctx: SurfaceContext): (() => void) | void;
|
|
37
|
+
undock(): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LifecycleDock — Runs actions on mount, unmount, and model changes.
|
|
3
|
+
*
|
|
4
|
+
* One per surface. Fires onMount actions immediately on dock,
|
|
5
|
+
* watches model paths for changes, and runs onUnmount on undock.
|
|
6
|
+
*/
|
|
7
|
+
import { Dockable } from './base.js';
|
|
8
|
+
|
|
9
|
+
export class LifecycleDock extends Dockable {
|
|
10
|
+
kind = 'lifecycle';
|
|
11
|
+
id = 'lifecycle';
|
|
12
|
+
|
|
13
|
+
/** @type {Array} actions to run on mount */
|
|
14
|
+
onMount;
|
|
15
|
+
|
|
16
|
+
/** @type {Array} actions to run on unmount */
|
|
17
|
+
onUnmount;
|
|
18
|
+
|
|
19
|
+
/** @type {Array} model path watchers */
|
|
20
|
+
onModelChange;
|
|
21
|
+
|
|
22
|
+
/** @type {Function} (handlerName) => handlerFn */
|
|
23
|
+
#resolveHandler;
|
|
24
|
+
|
|
25
|
+
/** @type {import('../surface.js').SurfaceContext|null} */
|
|
26
|
+
#ctx = null;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {object} decl — { onMount?, onUnmount?, onModelChange? }
|
|
30
|
+
* @param {Function} resolveHandler — (name) => async (config, ctx) => result
|
|
31
|
+
*/
|
|
32
|
+
constructor(decl, resolveHandler) {
|
|
33
|
+
super();
|
|
34
|
+
this.onMount = decl.onMount || [];
|
|
35
|
+
this.onUnmount = decl.onUnmount || [];
|
|
36
|
+
this.onModelChange = decl.onModelChange || [];
|
|
37
|
+
this.#resolveHandler = resolveHandler;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
dock(ctx) {
|
|
41
|
+
this.#ctx = ctx;
|
|
42
|
+
|
|
43
|
+
// Run onMount actions
|
|
44
|
+
for (const action of this.onMount) {
|
|
45
|
+
this.#run(action, ctx);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Set up model watchers
|
|
49
|
+
const unwatchers = this.onModelChange.map((watcher) => {
|
|
50
|
+
let handler = () => this.#run(watcher, ctx);
|
|
51
|
+
|
|
52
|
+
// Debounce if specified
|
|
53
|
+
if (watcher.debounce > 0) {
|
|
54
|
+
const origHandler = handler;
|
|
55
|
+
let timer;
|
|
56
|
+
handler = () => {
|
|
57
|
+
clearTimeout(timer);
|
|
58
|
+
timer = setTimeout(origHandler, watcher.debounce);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return ctx.watchModel(watcher.path, handler);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
return () => unwatchers.forEach(u => u());
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
undock() {
|
|
69
|
+
if (this.#ctx) {
|
|
70
|
+
for (const action of this.onUnmount) {
|
|
71
|
+
this.#run(action, this.#ctx);
|
|
72
|
+
}
|
|
73
|
+
this.#ctx = null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async #run(action, ctx) {
|
|
78
|
+
const fn = this.#resolveHandler(action.handler);
|
|
79
|
+
if (fn) {
|
|
80
|
+
try { await fn(action.config || {}, ctx); }
|
|
81
|
+
catch (err) { console.warn(`LifecycleDock: ${action.handler} failed`, err); }
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProviderDock — Injects shared context into a component subtree.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Dockable } from './base.js';
|
|
6
|
+
import type { SurfaceContext } from '../surface.js';
|
|
7
|
+
|
|
8
|
+
export interface ProviderDecl {
|
|
9
|
+
/** Context name, e.g. "auth". The dock id is set to "provider:<name>". */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Component ID to wrap. Defaults to the surface root. */
|
|
12
|
+
host?: string;
|
|
13
|
+
/** Initial context value. */
|
|
14
|
+
value?: unknown;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export declare class ProviderDock extends Dockable {
|
|
18
|
+
readonly kind: 'provider';
|
|
19
|
+
/** "provider:<name>" */
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly hostId: string | null;
|
|
22
|
+
readonly value: unknown;
|
|
23
|
+
|
|
24
|
+
constructor(decl: ProviderDecl);
|
|
25
|
+
|
|
26
|
+
dock(ctx: SurfaceContext): (() => void) | void;
|
|
27
|
+
undock(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProviderDock — Injects shared context into a component subtree.
|
|
3
|
+
*
|
|
4
|
+
* Creates an <a2ui-provider> wrapper around the host element.
|
|
5
|
+
* Children can consume the context by name.
|
|
6
|
+
*/
|
|
7
|
+
import { Dockable } from './base.js';
|
|
8
|
+
|
|
9
|
+
export class ProviderDock extends Dockable {
|
|
10
|
+
kind = 'provider';
|
|
11
|
+
|
|
12
|
+
/** @type {string} context name, e.g., "auth" */
|
|
13
|
+
id;
|
|
14
|
+
|
|
15
|
+
/** @type {string|null} component id to wrap (null = root) */
|
|
16
|
+
hostId;
|
|
17
|
+
|
|
18
|
+
/** @type {*} initial context value */
|
|
19
|
+
value;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {object} decl — { name, host?, value? }
|
|
23
|
+
*/
|
|
24
|
+
constructor(decl) {
|
|
25
|
+
super();
|
|
26
|
+
this.id = `provider:${decl.name}`;
|
|
27
|
+
this.hostId = decl.host || null;
|
|
28
|
+
this.value = decl.value ?? null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
dock(ctx) {
|
|
32
|
+
const host = this.hostId
|
|
33
|
+
? ctx.getElement(this.hostId)
|
|
34
|
+
: ctx.getRootElement();
|
|
35
|
+
|
|
36
|
+
if (!host) {
|
|
37
|
+
console.warn(`ProviderDock: host "${this.hostId}" not found`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const provider = document.createElement('a2ui-provider');
|
|
42
|
+
provider.setAttribute('name', this.id.replace('provider:', ''));
|
|
43
|
+
provider.value = this.value;
|
|
44
|
+
|
|
45
|
+
// Wrap: insert provider before host, move host inside
|
|
46
|
+
host.parentNode?.insertBefore(provider, host);
|
|
47
|
+
provider.appendChild(host);
|
|
48
|
+
|
|
49
|
+
return () => {
|
|
50
|
+
// Unwrap: move host back out, remove provider
|
|
51
|
+
if (provider.parentNode) {
|
|
52
|
+
provider.parentNode.insertBefore(host, provider);
|
|
53
|
+
provider.remove();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
undock() {}
|
|
59
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @adia-ai/a2ui — A2UI runtime surface barrel.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all public symbols from Tier 1 (Render) and Tier 2 (Wire).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// ── Types ───────────────────────────────────────────────────────────────────
|
|
8
|
+
export type { A2UIMessageType, A2UIComponent, A2UIMessage } from './types.js';
|
|
9
|
+
|
|
10
|
+
// ── Tier 1: Render ──────────────────────────────────────────────────────────
|
|
11
|
+
export { registry, resolveTag, registerType } from './registry.js';
|
|
12
|
+
export { A2UIRenderer } from './renderer.js';
|
|
13
|
+
export type { A2UIRendererOptions, SurfaceState } from './renderer.js';
|
|
14
|
+
export { applyResolvedProp, toAttr } from './prop-apply.js';
|
|
15
|
+
export { sseStream, wsStream, mockStream, mcpStream, jsonlStream } from './stream.js';
|
|
16
|
+
export type { StreamOptions, McpStreamOptions } from './stream.js';
|
|
17
|
+
|
|
18
|
+
// ── Tier 2: Wire ────────────────────────────────────────────────────────────
|
|
19
|
+
export { SurfaceManifest } from './surface-manifest.js';
|
|
20
|
+
export type {
|
|
21
|
+
SurfaceDescriptor,
|
|
22
|
+
Association,
|
|
23
|
+
AssociationType,
|
|
24
|
+
ManifestValidationResult,
|
|
25
|
+
} from './surface-manifest.js';
|
|
26
|
+
|
|
27
|
+
export { Surface } from './surface.js';
|
|
28
|
+
export type { SurfaceContext, AdiaEvent } from './surface.js';
|
|
29
|
+
|
|
30
|
+
export { createDockables } from './wire-factory.js';
|
|
31
|
+
export type { CreateDockablesResult } from './wire-factory.js';
|
|
32
|
+
|
|
33
|
+
export { WiringEngine } from './wiring-engine.js';
|
|
34
|
+
export type { WiringEngineOptions, SurfaceWireState } from './wiring-engine.js';
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
wiringRegistry,
|
|
38
|
+
registerController,
|
|
39
|
+
registerHandler,
|
|
40
|
+
registerResolver,
|
|
41
|
+
resolveController,
|
|
42
|
+
resolveHandler,
|
|
43
|
+
resolveData,
|
|
44
|
+
} from './wiring-registry.js';
|
|
45
|
+
export type { WiringRegistry, HandlerContext } from './wiring-registry.js';
|
|
46
|
+
|
|
47
|
+
// ── Dockable base + implementations ─────────────────────────────────────────
|
|
48
|
+
export { Dockable } from './dockables/base.js';
|
|
49
|
+
export type { DockableKind } from './dockables/base.js';
|
|
50
|
+
|
|
51
|
+
export { ControllerDock } from './dockables/controller.js';
|
|
52
|
+
export type { ControllerDecl } from './dockables/controller.js';
|
|
53
|
+
|
|
54
|
+
export { DataSourceDock } from './dockables/data-source.js';
|
|
55
|
+
export type { DataSourceDecl } from './dockables/data-source.js';
|
|
56
|
+
|
|
57
|
+
export { ActionDock, A2UI_EVENT_TO_DOM } from './dockables/action.js';
|
|
58
|
+
export type { ActionDecl, UIEventDecl } from './dockables/action.js';
|
|
59
|
+
|
|
60
|
+
export { ProviderDock } from './dockables/provider.js';
|
|
61
|
+
export type { ProviderDecl } from './dockables/provider.js';
|
|
62
|
+
|
|
63
|
+
export { LifecycleDock } from './dockables/lifecycle.js';
|
|
64
|
+
export type { LifecycleDecl, LifecycleAction, ModelChangeWatcher } from './dockables/lifecycle.js';
|
package/index.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { registry, resolveTag, registerType } from "./registry.js";
|
|
2
|
+
import { A2UIRenderer } from "./renderer.js";
|
|
3
|
+
import { applyResolvedProp, toAttr } from "./prop-apply.js";
|
|
4
|
+
import { sseStream, wsStream, mockStream, mcpStream, jsonlStream } from "./stream.js";
|
|
5
|
+
import { SurfaceManifest } from "./surface-manifest.js";
|
|
6
|
+
import { Surface } from "./surface.js";
|
|
7
|
+
import { createDockables } from "./wire-factory.js";
|
|
8
|
+
import { WiringEngine } from "./wiring-engine.js";
|
|
9
|
+
import {
|
|
10
|
+
wiringRegistry,
|
|
11
|
+
registerController,
|
|
12
|
+
registerHandler,
|
|
13
|
+
registerResolver,
|
|
14
|
+
resolveController,
|
|
15
|
+
resolveHandler,
|
|
16
|
+
resolveData
|
|
17
|
+
} from "./wiring-registry.js";
|
|
18
|
+
import { Dockable } from "./dockables/base.js";
|
|
19
|
+
import { ControllerDock } from "./dockables/controller.js";
|
|
20
|
+
import { DataSourceDock } from "./dockables/data-source.js";
|
|
21
|
+
import { ActionDock, A2UI_EVENT_TO_DOM } from "./dockables/action.js";
|
|
22
|
+
import { ProviderDock } from "./dockables/provider.js";
|
|
23
|
+
import { LifecycleDock } from "./dockables/lifecycle.js";
|
|
24
|
+
export {
|
|
25
|
+
A2UIRenderer,
|
|
26
|
+
A2UI_EVENT_TO_DOM,
|
|
27
|
+
ActionDock,
|
|
28
|
+
ControllerDock,
|
|
29
|
+
DataSourceDock,
|
|
30
|
+
Dockable,
|
|
31
|
+
LifecycleDock,
|
|
32
|
+
ProviderDock,
|
|
33
|
+
Surface,
|
|
34
|
+
SurfaceManifest,
|
|
35
|
+
WiringEngine,
|
|
36
|
+
applyResolvedProp,
|
|
37
|
+
createDockables,
|
|
38
|
+
jsonlStream,
|
|
39
|
+
mcpStream,
|
|
40
|
+
mockStream,
|
|
41
|
+
registerController,
|
|
42
|
+
registerHandler,
|
|
43
|
+
registerResolver,
|
|
44
|
+
registerType,
|
|
45
|
+
registry,
|
|
46
|
+
resolveController,
|
|
47
|
+
resolveData,
|
|
48
|
+
resolveHandler,
|
|
49
|
+
resolveTag,
|
|
50
|
+
sseStream,
|
|
51
|
+
toAttr,
|
|
52
|
+
wiringRegistry,
|
|
53
|
+
wsStream
|
|
54
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@adia-ai/a2ui",
|
|
3
|
+
"version": "0.8.37",
|
|
4
|
+
"description": "The A2UI protocol — runtime (renderer, registry, streams, surface manifest, wiring primitives, dockable base classes) plus protocol-side validation. Framework-agnostic and dependency-free; pairs with any A2UI-conformant component set. Folded from @adia-ai/a2ui-runtime + the protocol half of @adia-ai/a2ui-validator (ADR-0048).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
|
+
"import": "./index.js",
|
|
10
|
+
"default": "./index.js"
|
|
11
|
+
},
|
|
12
|
+
"./registry": {
|
|
13
|
+
"types": "./registry.d.ts",
|
|
14
|
+
"import": "./registry.js",
|
|
15
|
+
"default": "./registry.js"
|
|
16
|
+
},
|
|
17
|
+
"./renderer": {
|
|
18
|
+
"types": "./renderer.d.ts",
|
|
19
|
+
"import": "./renderer.js",
|
|
20
|
+
"default": "./renderer.js"
|
|
21
|
+
},
|
|
22
|
+
"./prop-apply": {
|
|
23
|
+
"types": "./prop-apply.d.ts",
|
|
24
|
+
"import": "./prop-apply.js",
|
|
25
|
+
"default": "./prop-apply.js"
|
|
26
|
+
},
|
|
27
|
+
"./streams": {
|
|
28
|
+
"types": "./stream.d.ts",
|
|
29
|
+
"import": "./stream.js",
|
|
30
|
+
"default": "./stream.js"
|
|
31
|
+
},
|
|
32
|
+
"./surface": {
|
|
33
|
+
"types": "./surface.d.ts",
|
|
34
|
+
"import": "./surface.js",
|
|
35
|
+
"default": "./surface.js"
|
|
36
|
+
},
|
|
37
|
+
"./wiring": {
|
|
38
|
+
"types": "./wiring-engine.d.ts",
|
|
39
|
+
"import": "./wiring-engine.js",
|
|
40
|
+
"default": "./wiring-engine.js"
|
|
41
|
+
},
|
|
42
|
+
"./dockables": {
|
|
43
|
+
"types": "./dockables/index.d.ts",
|
|
44
|
+
"import": "./dockables/index.js",
|
|
45
|
+
"default": "./dockables/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./schema": {
|
|
48
|
+
"types": "./a2ui.schema.d.ts",
|
|
49
|
+
"default": "./a2ui.schema.d.ts"
|
|
50
|
+
},
|
|
51
|
+
"./types": {
|
|
52
|
+
"types": "./types.d.ts",
|
|
53
|
+
"default": "./types.d.ts"
|
|
54
|
+
},
|
|
55
|
+
"./validate": {
|
|
56
|
+
"types": "./validate/index.d.ts",
|
|
57
|
+
"import": "./validate/index.js",
|
|
58
|
+
"default": "./validate/index.js"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"files": [
|
|
62
|
+
"*.js",
|
|
63
|
+
"dockables/",
|
|
64
|
+
"controllers/",
|
|
65
|
+
"validate/index.js",
|
|
66
|
+
"validate/validator.js",
|
|
67
|
+
"validate/README.md",
|
|
68
|
+
"validate/CHANGELOG.md",
|
|
69
|
+
"README.md",
|
|
70
|
+
"CHANGELOG.md",
|
|
71
|
+
"a2ui.schema.d.ts",
|
|
72
|
+
"types.d.ts",
|
|
73
|
+
"**/*.d.ts",
|
|
74
|
+
"!**/*.test.js"
|
|
75
|
+
],
|
|
76
|
+
"license": "MIT",
|
|
77
|
+
"publishConfig": {
|
|
78
|
+
"access": "public",
|
|
79
|
+
"registry": "https://registry.npmjs.org"
|
|
80
|
+
},
|
|
81
|
+
"repository": {
|
|
82
|
+
"type": "git",
|
|
83
|
+
"url": "git+https://github.com/adiahealth/gen-ui-kit.git",
|
|
84
|
+
"directory": "packages/a2ui"
|
|
85
|
+
},
|
|
86
|
+
"devDependencies": {
|
|
87
|
+
"@adia-ai/gen-ui": "^0.8.0"
|
|
88
|
+
}
|
|
89
|
+
}
|