@mochabug/adapt-web
Version:
Browser client library for Adapt automation platform
102 lines (101 loc) • 3.97 kB
TypeScript
import type { AdaptTheme } from "./theme.js";
import type { AdaptError, AdaptWebClientOptions, CapWidgetOptions, Output, PersistOptions, SignalValue, StatusJson, StatusText } from "./types.js";
/**
* `<adapt-automation>` custom element for embedding Adapt automations.
*
* Attributes (HTML-serializable):
* - `automation-id` (string, required) — recreates client on change
* - `session-token`, `auth-token`, `transmitter`, `challenge-token`,
* `requires-challenge`, `inherit-token`, `inherit-from`, `signals`,
* `side-by-side-split` — read at creation only
* - `fork-display-mode`, `dark-mode`, `auto-resizing` — mutable at runtime
*
* Properties (non-serializable, set via JS):
* - `capWidgetOptions`, `classNames`, `styles`
* - `signals`, `inheritFrom` — also available as JSON attributes
* - `onSession`, `onOutput` — callbacks
*
* Events dispatched:
* - `adapt-session` with `{ status, fork }` detail
* - `adapt-output` with `{ output }` detail
*/
declare const BaseElement: {
new (): HTMLElement;
prototype: HTMLElement;
};
export declare class AdaptAutomationElement extends BaseElement {
static get observedAttributes(): readonly string[];
constructor();
private _client;
signals: Record<string, SignalValue> | undefined;
capWidgetOptions: CapWidgetOptions | undefined;
inheritFrom: {
hash: string;
} | {
param: string;
} | undefined;
classNames: AdaptWebClientOptions["classNames"];
styles: Partial<CSSStyleDeclaration> | undefined;
persistOptions: PersistOptions | undefined;
text: StatusText | undefined;
private _theme;
get theme(): AdaptTheme | undefined;
set theme(v: AdaptTheme | undefined);
onSessionCallback: ((status: StatusJson, fork?: string) => void) | undefined;
onOutputCallback: ((output: Output) => void) | undefined;
onForkActiveCallback: ((active: boolean) => void) | undefined;
onErrorCallback: ((error: AdaptError) => void) | undefined;
get automationId(): string | null;
set automationId(v: string | null);
get darkMode(): boolean;
set darkMode(v: boolean);
get autoResizing(): boolean;
set autoResizing(v: boolean);
get allowFloating(): boolean;
set allowFloating(v: boolean);
get allowDocking(): boolean;
set allowDocking(v: boolean);
get allowDialogDocking(): boolean;
set allowDialogDocking(v: boolean);
get allowMinimize(): boolean;
set allowMinimize(v: boolean);
get allowMaximize(): boolean;
set allowMaximize(v: boolean);
get floatingAutoResize(): boolean;
set floatingAutoResize(v: boolean);
get confirmOnClose(): boolean;
set confirmOnClose(v: boolean);
get forkDisplayMode(): "side-by-side" | "dialog";
set forkDisplayMode(v: "side-by-side" | "dialog");
get persist(): boolean;
set persist(v: boolean);
get debug(): boolean;
set debug(v: boolean);
/**
* Clear persisted state, stop current session, and reinitialize fresh.
*/
newSession(): Promise<void>;
/**
* Explicitly initialize the element after all properties are set.
* Framework wrappers (React, Vue, Svelte, Angular, Astro) MUST call this
* after setting non-serializable properties like `signals`, `inheritFrom`, etc.
*
* For plain HTML usage without a framework, the element auto-initializes
* when `automation-id` is set (via `attributeChangedCallback`).
*
* Idempotent — safe to call multiple times. Only creates the client once.
*/
initialize(): void;
connectedCallback(): void;
disconnectedCallback(): void;
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
private _upgradeProperty;
private _tryInit;
private _parseData;
private _parseJsonAttributeOrData;
private _parseJsonAttribute;
private _isSignals;
private _isInheritFrom;
private _destroyClient;
}
export {};