@web-widget/web-widget
Version:
Web front-end application container
207 lines (203 loc) • 6.62 kB
TypeScript
import { ClientRenderResult, ClientWidgetModule, Meta } from '@web-widget/helpers';
import { S as SerializableObject } from './types-CoQQqBlK.js';
/**
* The status of the widget module lifecycle.
* It represents the current state of the widget module.
* The status can be one of the following:
* - `initial`: The initial state before loading the module.
* - `loading`: The module is being loaded.
* - `loaded`: The module has been loaded successfully.
* - `bootstrapping`: The module is being bootstrapped.
* - `bootstrapped`: The module has been bootstrapped successfully.
* - `mounting`: The module is being mounted.
* - `mounted`: The module has been mounted successfully.
* - `updating`: The module is being updated.
* - `unmounting`: The module is being unmounted.
* - `unloading`: The module is being unloaded.
* - `load-error`: An error occurred while loading the module.
* - `bootstrap-error`: An error occurred while bootstrapping the module.
* - `mount-error`: An error occurred while mounting the module.
* - `update-error`: An error occurred while updating the module.
* - `unmount-error`: An error occurred while unmounting the module.
* - `unload-error`: An error occurred while unloading the module.
*/
declare const status: {
readonly INITIAL: "initial";
readonly LOADING: "loading";
readonly LOADED: "loaded";
readonly BOOTSTRAPPING: "bootstrapping";
readonly BOOTSTRAPPED: "bootstrapped";
readonly MOUNTING: "mounting";
readonly MOUNTED: "mounted";
readonly UPDATING: "updating";
readonly UNMOUNTING: "unmounting";
readonly UNLOADING: "unloading";
readonly LOAD_ERROR: "load-error";
readonly BOOTSTRAP_ERROR: "bootstrap-error";
readonly MOUNT_ERROR: "mount-error";
readonly UPDATE_ERROR: "update-error";
readonly UNMOUNT_ERROR: "unmount-error";
readonly UNLOAD_ERROR: "unload-error";
};
type Lifecycle = 'load' | keyof ClientRenderResult;
type ModuleLoader = () => Promise<ClientWidgetModule>;
type Status = (typeof status)[keyof typeof status];
type Timeouts = Partial<Record<Lifecycle, number>>;
type Loading = 'eager' | 'lazy' | 'idle';
type RenderTarget = 'light' | 'shadow';
type PerformanceMarkDetail = {
name: string;
import: string;
source: string;
timestamp: number;
};
declare const INNER_HTML_PLACEHOLDER = "<!--web-widget:placeholder-->";
/**
* Web Widget Container
* @event {Event} statuschange
*/
declare class HTMLWebWidgetElement extends HTMLElement {
#private;
performance?: {
loadTime?: string;
mountTime?: string;
};
constructor();
/**
* WidgetModule loader.
* @default null
*/
get loader(): ModuleLoader | null;
set loader(value: ModuleLoader | null);
/**
* WidgetModule base.
*/
get base(): string;
set base(value: string);
/**
* WidgetModule data.
* @deprecated Use `contextData` instead.
*/
get data(): SerializableObject | null;
set data(value: SerializableObject);
/**
* WidgetModule data.
*/
get contextData(): SerializableObject | null;
set contextData(value: SerializableObject);
/**
* WidgetModule meta.
*/
get contextMeta(): Meta | null;
set contextMeta(value: Meta);
/**
* Whether the module is inactive.
*/
get inactive(): boolean;
set inactive(value: boolean);
/**
* Hydration mode.
* @default false
*/
get recovering(): boolean;
set recovering(value: boolean);
/**
* Indicates how the browser should load the module.
* @default "eager"
*/
get loading(): Loading;
set loading(value: Loading);
/**
* WidgetModule container status.
* @default "initial"
*/
get status(): Status;
/**
* WidgetModule module url.
* @default ""
*/
get import(): string;
set import(value: string);
/**
* WidgetModule render target.
* @default "shadow"
*/
get renderTarget(): RenderTarget;
set renderTarget(value: RenderTarget);
/**
* WidgetModule timeouts.
*/
get timeouts(): Partial<Record<Lifecycle, number>>;
set timeouts(value: Partial<Record<Lifecycle, number>>);
set innerHTML(value: string);
/**
* Hook: Create the module's render node.
*/
createContainer(): Element | DocumentFragment;
/**
* Hook: Create the module's loader.
*/
createLoader(): ModuleLoader;
/**
* Trigger the loading of the module.
*/
load(): Promise<void>;
/**
* Trigger the bootstrapping of the module.
*/
bootstrap(): Promise<void>;
/**
* Trigger the mounting of the module.
*/
mount(): Promise<void>;
/**
* Trigger the updating of the module.
*/
update(data: any): Promise<void>;
/**
* Trigger the unmounting of the module.
*/
unmount(): Promise<void>;
/**
* Trigger the unloading of the module.
*/
unload(): Promise<void>;
connectedCallback(): void;
disconnectedCallback(): void;
attributeChangedCallback(name: string): void;
destroyedCallback(): void;
static get observedAttributes(): string[];
static get timeouts(): Partial<Record<Lifecycle, number>>;
static set timeouts(value: Partial<Record<Lifecycle, number>>);
static INITIAL: typeof status.INITIAL;
static LOADING: typeof status.LOADING;
static LOADED: typeof status.LOADED;
static BOOTSTRAPPING: typeof status.BOOTSTRAPPING;
static BOOTSTRAPPED: typeof status.BOOTSTRAPPED;
static MOUNTING: typeof status.MOUNTING;
static MOUNTED: typeof status.MOUNTED;
static UPDATING: typeof status.UPDATING;
static UNMOUNTING: typeof status.UNMOUNTING;
static UNLOADING: typeof status.UNLOADING;
static LOAD_ERROR: typeof status.LOAD_ERROR;
static BOOTSTRAP_ERROR: typeof status.BOOTSTRAP_ERROR;
static MOUNT_ERROR: typeof status.MOUNT_ERROR;
static UPDATE_ERROR: typeof status.UPDATE_ERROR;
static UNMOUNT_ERROR: typeof status.UNMOUNT_ERROR;
static UNLOAD_ERROR: typeof status.UNLOAD_ERROR;
}
interface HTMLWebWidgetElementAttributes extends Partial<HTMLWebWidgetElement> {
contextdata?: string;
contextmeta?: string;
inactive?: boolean;
recovering?: boolean;
loading?: Loading;
import?: string;
rendertarget?: RenderTarget;
base?: string;
timeouts?: Timeouts;
}
declare global {
let importShim: <T>(src: string) => Promise<T>;
}
export { HTMLWebWidgetElement, type HTMLWebWidgetElementAttributes, INNER_HTML_PLACEHOLDER, type PerformanceMarkDetail };