@exponential-at/ui-element 0.0.0-stage → 0.1.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 +201 -0
- package/NOTICE +54 -0
- package/README.md +212 -2
- package/dist/chunks/index-yte5bftp.js +898 -0
- package/dist/chunks/index-yte5bftp.js.map +15 -0
- package/dist/define.js +44 -0
- package/dist/define.js.map +10 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +9 -0
- package/dist/standalone.js +466 -0
- package/dist/standalone.js.map +1 -0
- package/dist/types/define.d.ts +1 -0
- package/dist/types/element.d.ts +91 -0
- package/dist/types/events.d.ts +71 -0
- package/dist/types/extensions.d.ts +39 -0
- package/dist/types/icons.d.ts +7 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/standalone.d.ts +2 -0
- package/dist/types/transport.d.ts +34 -0
- package/package.json +52 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./index.js";
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { ExponentialHost, ModeName, ScrollAlign, SurfaceCommand, TransportStatus, UiNode } from "@exponential-at/ui";
|
|
2
|
+
import { type DataModel } from "@exponential-at/ui/web";
|
|
3
|
+
import type { A2uiMessage, ExponentialSurfaceProps, HostPlugin, SolidExtension, SurfaceHandle, SurfaceState, ThemeInput } from "@exponential-at/ui-solid";
|
|
4
|
+
export declare const TAG = "exponential-surface";
|
|
5
|
+
type Density = NonNullable<ExponentialSurfaceProps[`density`]>;
|
|
6
|
+
type Contrast = NonNullable<ExponentialSurfaceProps[`contrast`]>;
|
|
7
|
+
type Mode = ModeName | `system`;
|
|
8
|
+
type Direction = `ltr` | `rtl`;
|
|
9
|
+
/** A numeric string = px, any other string = a CSS length. */
|
|
10
|
+
export declare function lengthOf(value: number | string | null | undefined): number | string | undefined;
|
|
11
|
+
export declare class ExponentialSurfaceElement extends HTMLElement {
|
|
12
|
+
#private;
|
|
13
|
+
static get observedAttributes(): string[];
|
|
14
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
15
|
+
get theme(): ThemeInput | undefined;
|
|
16
|
+
set theme(v: ThemeInput | undefined | null);
|
|
17
|
+
get mode(): Mode | undefined;
|
|
18
|
+
set mode(v: Mode | undefined | null);
|
|
19
|
+
get density(): Density | undefined;
|
|
20
|
+
set density(v: Density | undefined | null);
|
|
21
|
+
get contrast(): Contrast | undefined;
|
|
22
|
+
set contrast(v: Contrast | undefined | null);
|
|
23
|
+
get locale(): string | undefined;
|
|
24
|
+
set locale(v: string | undefined | null);
|
|
25
|
+
get timeZone(): string | undefined;
|
|
26
|
+
set timeZone(v: string | undefined | null);
|
|
27
|
+
get direction(): Direction | undefined;
|
|
28
|
+
set direction(v: Direction | undefined | null);
|
|
29
|
+
get width(): number | string | undefined;
|
|
30
|
+
set width(v: number | string | undefined | null);
|
|
31
|
+
get height(): number | string | undefined;
|
|
32
|
+
set height(v: number | string | undefined | null);
|
|
33
|
+
/** The surface id (`surface-id`, default `main`). */
|
|
34
|
+
get surfaceId(): string;
|
|
35
|
+
set surfaceId(v: string | undefined | null);
|
|
36
|
+
get src(): string | undefined;
|
|
37
|
+
set src(v: string | undefined | null);
|
|
38
|
+
get post(): string | undefined;
|
|
39
|
+
set post(v: string | undefined | null);
|
|
40
|
+
get transport(): string | undefined;
|
|
41
|
+
set transport(v: string | undefined | null);
|
|
42
|
+
get surface(): SurfaceState | undefined;
|
|
43
|
+
set surface(v: SurfaceState | undefined | null);
|
|
44
|
+
get root(): UiNode | null | undefined;
|
|
45
|
+
set root(v: UiNode | null | undefined);
|
|
46
|
+
get templates(): Readonly<Record<string, UiNode>> | undefined;
|
|
47
|
+
set templates(v: Readonly<Record<string, UiNode>> | undefined | null);
|
|
48
|
+
get data(): DataModel | undefined;
|
|
49
|
+
set data(v: DataModel | undefined | null);
|
|
50
|
+
get host(): ExponentialHost | undefined;
|
|
51
|
+
set host(v: ExponentialHost | undefined | null);
|
|
52
|
+
get plugin(): HostPlugin | undefined;
|
|
53
|
+
set plugin(v: HostPlugin | undefined | null);
|
|
54
|
+
get extensions(): readonly SolidExtension[] | undefined;
|
|
55
|
+
set extensions(v: readonly SolidExtension[] | undefined | null);
|
|
56
|
+
get strings(): Record<string, string> | undefined;
|
|
57
|
+
set strings(v: Record<string, string> | undefined | null);
|
|
58
|
+
get states(): readonly string[] | undefined;
|
|
59
|
+
set states(v: readonly string[] | undefined | null);
|
|
60
|
+
get measure(): ExponentialSurfaceProps[`measure`];
|
|
61
|
+
set measure(v: ExponentialSurfaceProps[`measure`] | null);
|
|
62
|
+
get viewportHeight(): number | undefined;
|
|
63
|
+
set viewportHeight(v: number | undefined | null);
|
|
64
|
+
/** The painted surface's handle; null until the first paint. */
|
|
65
|
+
get handle(): SurfaceHandle | null;
|
|
66
|
+
/** The active store's reduce issues. */
|
|
67
|
+
get issues(): SurfaceState[`issues`];
|
|
68
|
+
/** The host's transport state (a host property or one built from `src`);
|
|
69
|
+
* `closed` when the URL policy denied `src`/`post` (see `statusDetail`). */
|
|
70
|
+
get status(): TransportStatus | undefined;
|
|
71
|
+
/** The transport's detail (an error, or `src denied by the URL policy (private)`). */
|
|
72
|
+
get statusDetail(): string | undefined;
|
|
73
|
+
/** The state painted: the `surface` property, the host's surface, or the
|
|
74
|
+
* store `apply()` made. */
|
|
75
|
+
get surfaceState(): SurfaceState | null;
|
|
76
|
+
/** One A2UI server message: to the `surface` property, else the host,
|
|
77
|
+
* else a store made on first use (surface id = `surfaceId`). */
|
|
78
|
+
apply(message: A2uiMessage): void;
|
|
79
|
+
/** Write the data model (the active store's; in fixture mode a new `data`). */
|
|
80
|
+
setData(pointer: string, value: unknown): void;
|
|
81
|
+
/** Back to the store's initial state (a host surface ignores it). */
|
|
82
|
+
reset(): void;
|
|
83
|
+
run(command: SurfaceCommand): void;
|
|
84
|
+
focus(id?: string | FocusOptions): boolean;
|
|
85
|
+
announce(text: string, live?: `polite` | `assertive`): void;
|
|
86
|
+
scrollIntoView(id?: string | boolean | ScrollIntoViewOptions): boolean;
|
|
87
|
+
scrollToIndex(id: string, index: number, align?: ScrollAlign): boolean;
|
|
88
|
+
connectedCallback(): void;
|
|
89
|
+
disconnectedCallback(): void;
|
|
90
|
+
}
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { FunctionCallInfo, ThemeIssue, TransportStatus, UiNode } from "@exponential-at/ui";
|
|
2
|
+
import type { PaintError, SurfaceActionEvent, SurfaceHandle, SurfaceInputEvent } from "@exponential-at/ui-solid";
|
|
3
|
+
import type { ExponentialSurfaceElement } from "./element.js";
|
|
4
|
+
/** Keeps the source control pending until `promise` settles. */
|
|
5
|
+
export interface WaitUntil {
|
|
6
|
+
waitUntil: (promise: Promise<unknown>) => void;
|
|
7
|
+
}
|
|
8
|
+
export type SurfaceActionDetail = SurfaceActionEvent & WaitUntil;
|
|
9
|
+
/** `waitUntil` acknowledges the input's revision when it settles. */
|
|
10
|
+
export type SurfaceInputDetail = SurfaceInputEvent & WaitUntil;
|
|
11
|
+
export interface FunctionCallDetail {
|
|
12
|
+
call: FunctionCallInfo;
|
|
13
|
+
/** The call's result (the first `respond` wins; none = the plugin's
|
|
14
|
+
* `onFunctionCall` result, else undefined). A promise keeps the source
|
|
15
|
+
* control pending. */
|
|
16
|
+
respond: (value: unknown) => void;
|
|
17
|
+
}
|
|
18
|
+
/** Cancelable: `preventDefault()` = the page opens it (or not) itself. */
|
|
19
|
+
export interface OpenUrlDetail {
|
|
20
|
+
url: string;
|
|
21
|
+
}
|
|
22
|
+
export interface UploadDetail extends WaitUntil {
|
|
23
|
+
files: File[];
|
|
24
|
+
target: {
|
|
25
|
+
nodeId: string;
|
|
26
|
+
name: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface StatusDetail {
|
|
30
|
+
status: TransportStatus;
|
|
31
|
+
detail?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ExponentialSurfaceEventMap {
|
|
34
|
+
"xui-action": CustomEvent<SurfaceActionDetail>;
|
|
35
|
+
"xui-input": CustomEvent<SurfaceInputDetail>;
|
|
36
|
+
"xui-function-call": CustomEvent<FunctionCallDetail>;
|
|
37
|
+
"xui-open-url": CustomEvent<OpenUrlDetail>;
|
|
38
|
+
"xui-upload": CustomEvent<UploadDetail>;
|
|
39
|
+
"xui-paint-error": CustomEvent<{
|
|
40
|
+
error: PaintError;
|
|
41
|
+
}>;
|
|
42
|
+
"xui-theme-issues": CustomEvent<{
|
|
43
|
+
issues: ThemeIssue[];
|
|
44
|
+
}>;
|
|
45
|
+
"xui-unknown": CustomEvent<{
|
|
46
|
+
node: UiNode;
|
|
47
|
+
}>;
|
|
48
|
+
"xui-status": CustomEvent<StatusDetail>;
|
|
49
|
+
"xui-ready": CustomEvent<{
|
|
50
|
+
handle: SurfaceHandle;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
export type ExponentialSurfaceEventName = keyof ExponentialSurfaceEventMap;
|
|
54
|
+
declare global {
|
|
55
|
+
interface HTMLElementTagNameMap {
|
|
56
|
+
"exponential-surface": ExponentialSurfaceElement;
|
|
57
|
+
}
|
|
58
|
+
interface HTMLElementEventMap extends ExponentialSurfaceEventMap {
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
type DetailOf<K extends ExponentialSurfaceEventName> = ExponentialSurfaceEventMap[K] extends CustomEvent<infer D> ? D : never;
|
|
62
|
+
/** Dispatch one event; returns false when a listener cancelled it. */
|
|
63
|
+
export declare function emit<K extends ExponentialSurfaceEventName>(target: EventTarget, name: K, detail: DetailOf<K>, cancelable?: boolean): boolean;
|
|
64
|
+
/** The plugin's result and every `waitUntil` promise, joined: undefined when
|
|
65
|
+
* none is a promise (the painter acknowledges at once), else one promise
|
|
66
|
+
* that settles with all of them (and rejects with the first rejection). */
|
|
67
|
+
export declare function joinPending(results: readonly unknown[]): Promise<void> | undefined;
|
|
68
|
+
/** Dispatch a waiting event: `base` + `waitUntil`; returns the promises the
|
|
69
|
+
* listeners handed over. */
|
|
70
|
+
export declare function emitWaiting<K extends `xui-action` | `xui-input` | `xui-upload`>(target: EventTarget, name: K, base: Omit<DetailOf<K>, `waitUntil`>): Promise<unknown>[];
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ExtensionDef, ModeName, ResolvedTheme, UiNode } from "@exponential-at/ui";
|
|
2
|
+
import { type RegisterExtensionOptions, type SolidExtension } from "@exponential-at/ui-solid";
|
|
3
|
+
export interface ElementPaintContext {
|
|
4
|
+
node: UiNode;
|
|
5
|
+
/** The node's props, resolved against the data model. */
|
|
6
|
+
props: Record<string, unknown>;
|
|
7
|
+
theme: ResolvedTheme;
|
|
8
|
+
mode: ModeName;
|
|
9
|
+
tokens: ResolvedTheme[`tokens`];
|
|
10
|
+
/** Fire one of the node's `on` handlers (`own` = what the element just
|
|
11
|
+
* wrote, by prop). A promise = the host is still handling it. */
|
|
12
|
+
emit: (event: string, payload?: Record<string, unknown>, own?: Record<string, unknown>) => Promise<void> | void;
|
|
13
|
+
/** What the renderer wants on the root: `class`, `data-xui-id`,
|
|
14
|
+
* `data-xui-c`, recipe `data-r-*`/`data-m-*`, `data-xs`, aria, `dir`,
|
|
15
|
+
* `style` (kebab-case keys). */
|
|
16
|
+
rootProps: Record<string, unknown>;
|
|
17
|
+
/** Sets `rootProps` on `el` (classes added to its own). */
|
|
18
|
+
applyRootProps: (el: Element) => void;
|
|
19
|
+
/** The node's painted children (append them where they belong). */
|
|
20
|
+
children: () => Node[];
|
|
21
|
+
/** One slot's painted nodes (empty when the node has no such slot). */
|
|
22
|
+
slot: (name: string) => Node[];
|
|
23
|
+
}
|
|
24
|
+
export type ElementPainter = (ctx: ElementPaintContext) => Element;
|
|
25
|
+
/** `rootProps` onto an element: classes merge, `style` entries are set one
|
|
26
|
+
* by one, null/undefined skip, everything else as a string. */
|
|
27
|
+
export declare function applyRootProps(el: Element, rootProps: Record<string, unknown>): void;
|
|
28
|
+
/** A per-surface extension (the `extensions` property) or, through
|
|
29
|
+
* `registerExtension`, a page-wide one, painted by vanilla painters. A
|
|
30
|
+
* `components` key naming a core native OVERRIDES its painter. */
|
|
31
|
+
export declare function defineElementExtension(options: {
|
|
32
|
+
catalog?: ExtensionDef | unknown;
|
|
33
|
+
components: Record<string, ElementPainter>;
|
|
34
|
+
}): SolidExtension;
|
|
35
|
+
/** Register an extension for every surface on the page (Solid's
|
|
36
|
+
* `registerExtension`), taking a `defineElementExtension` /
|
|
37
|
+
* `defineSolidExtension` result as well as the raw options. Returns the
|
|
38
|
+
* unregister function. */
|
|
39
|
+
export declare function registerExtension(extension: SolidExtension | RegisterExtensionOptions): () => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IconComponent, IconMap } from "@exponential-at/ui-solid";
|
|
2
|
+
/** One SVG markup string as an icon component. */
|
|
3
|
+
export declare function svgIcon(markup: string): IconComponent;
|
|
4
|
+
/** A registry name → SVG markup lookup, as the icon map `plugin.icons`
|
|
5
|
+
* takes. A name it has no markup for falls through to the renderer's own
|
|
6
|
+
* glyphs (then the placeholder). One component per distinct markup. */
|
|
7
|
+
export declare function iconsFromSvg(resolve: (name: string) => string | undefined): IconMap;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { ExponentialSurfaceElement, TAG, lengthOf } from "./element.js";
|
|
2
|
+
export { iconsFromSvg, svgIcon } from "./icons.js";
|
|
3
|
+
export { defineElementExtension, registerExtension, applyRootProps } from "./extensions.js";
|
|
4
|
+
export type { ElementPainter, ElementPaintContext } from "./extensions.js";
|
|
5
|
+
export { createHost, createTransport, transportKind, decideTransport, transportSchemes } from "./transport.js";
|
|
6
|
+
export type { TransportKind, TransportAttributes, TransportDecision } from "./transport.js";
|
|
7
|
+
export type { SurfaceActionDetail, SurfaceInputDetail, FunctionCallDetail, OpenUrlDetail, UploadDetail, StatusDetail, WaitUntil, ExponentialSurfaceEventMap, ExponentialSurfaceEventName } from "./events.js";
|
|
8
|
+
export { defineSolidExtension, createSurface } from "@exponential-at/ui-solid";
|
|
9
|
+
export type { A2uiMessage, SurfaceState, SurfaceHandle, HostPlugin, IconMap, IconComponent, ThemeInput, SolidExtension } from "@exponential-at/ui-solid";
|
|
10
|
+
/** Register the element under `tag` (default `exponential-surface`).
|
|
11
|
+
* Idempotent; a tag already taken by another class throws. Another tag
|
|
12
|
+
* gets its own subclass (one constructor per tag). */
|
|
13
|
+
export declare function define(tag?: string): void;
|
|
14
|
+
/** ONE document rule per tag, `:where(<tag>){display:contents}` (specificity
|
|
15
|
+
* 0: any author rule wins): the element is no box of its own, the surface's
|
|
16
|
+
* `.xui-surface` root is. Idempotent; nothing without a document. */
|
|
17
|
+
export declare function installHostRule(tag: string): void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ExponentialHost } from "@exponential-at/ui";
|
|
2
|
+
import type { ExtensionDef, Transport, UrlDecision, UrlPolicy } from "@exponential-at/ui";
|
|
3
|
+
export type TransportKind = `jsonl` | `sse` | `ws`;
|
|
4
|
+
export interface TransportAttributes {
|
|
5
|
+
src: string;
|
|
6
|
+
post?: string | null;
|
|
7
|
+
transport?: string | null;
|
|
8
|
+
}
|
|
9
|
+
/** Which transport the attributes name. */
|
|
10
|
+
export declare function transportKind(attrs: TransportAttributes): TransportKind;
|
|
11
|
+
export declare function createTransport(attrs: TransportAttributes): Transport;
|
|
12
|
+
/** The decision for `src` and `post` under the page's URL policy. */
|
|
13
|
+
export interface TransportDecision {
|
|
14
|
+
allowed: boolean;
|
|
15
|
+
src: UrlDecision;
|
|
16
|
+
/** Only when `post` is set. */
|
|
17
|
+
post?: UrlDecision;
|
|
18
|
+
/** Why not, for the element's status (`src denied by the URL policy (private)`). */
|
|
19
|
+
reason?: string;
|
|
20
|
+
}
|
|
21
|
+
/** The transport schemes a URL policy allows: its http(s) entries (default
|
|
22
|
+
* both) and their ws(s) twins; nothing else (mailto, tel, javascript,
|
|
23
|
+
* file, data never carry a transport). */
|
|
24
|
+
export declare function transportSchemes(policy: UrlPolicy | undefined): string[];
|
|
25
|
+
/** VAPP-107: `src` (and `post` when set) under the page's URL policy. */
|
|
26
|
+
export declare function decideTransport(attrs: TransportAttributes, policy?: UrlPolicy): TransportDecision;
|
|
27
|
+
/** A host over the attributes' transport (not connected yet). `extensions`
|
|
28
|
+
* = the catalogs of the element's `extensions` at build time (the host's
|
|
29
|
+
* reducer must know them, or an extension component reduces to Unknown).
|
|
30
|
+
* VAPP-107: `policy` (the page's URL policy, default the SDK's) decides
|
|
31
|
+
* `src` and `post` first; a denied one throws before any transport exists. */
|
|
32
|
+
export declare function createHost(attrs: TransportAttributes, extensions?: readonly ExtensionDef[], policy?: UrlPolicy): ExponentialHost;
|
|
33
|
+
/** The identity of a built host: a change rebuilds it. */
|
|
34
|
+
export declare const transportKey: (attrs: TransportAttributes) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exponential-at/ui-element",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Exponential UI as a custom element: <exponential-surface> paints a core A2UI surface with no framework in the host page, on the Solid painter and the shared web layer, with the same DOM, the same compiled stylesheet and the same runtime themes as the React renderer, run through the conformance suite and the web-parity check.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"homepage": "https://ui.exponential.at",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/Niach/exponential.git",
|
|
10
|
+
"directory": "packages/exponential-ui-element"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"a2ui",
|
|
14
|
+
"generative-ui",
|
|
15
|
+
"exponential-ui"
|
|
16
|
+
],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"module": "./dist/index.js",
|
|
20
|
+
"types": "./dist/types/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/types/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js",
|
|
25
|
+
"default": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./define": {
|
|
28
|
+
"types": "./dist/types/define.d.ts",
|
|
29
|
+
"import": "./dist/define.js",
|
|
30
|
+
"default": "./dist/define.js"
|
|
31
|
+
},
|
|
32
|
+
"./standalone": "./dist/standalone.js",
|
|
33
|
+
"./package.json": "./package.json"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md",
|
|
38
|
+
"LICENSE",
|
|
39
|
+
"NOTICE"
|
|
40
|
+
],
|
|
41
|
+
"sideEffects": [
|
|
42
|
+
"./dist/define.js",
|
|
43
|
+
"./dist/standalone.js"
|
|
44
|
+
],
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@exponential-at/ui": "^0.1.0",
|
|
47
|
+
"@exponential-at/ui-solid": "^0.1.0",
|
|
48
|
+
"solid-js": "^1.9.17"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public",
|
|
52
|
+
"provenance": true
|
|
53
|
+
}
|
|
54
|
+
}
|