import { AppState } from "../constants"; import { RealContextFuncs } from "../context"; import { Model } from "../data"; import { DOMBodyComponent, DOMRootComponent, DOMWindowComponent, View } from "../dom"; import { AppHookMap } from "./hooks"; import { PluginOption } from "./plugin"; export type RefTreeNode = Record; export type AppOptions = { name?: string; plugins?: PluginOption; root?: string | HTMLElement; } | PluginOption; export declare class App { main: View; constructor(options: AppOptions, main: View); readonly name: string | undefined; readonly plugins: PluginOption; /** * The map of context functions that are transformed, excluding HTML/SVG/Text element funcs. * * Context functions provided by plugins should be merged into this object. */ readonly contextFuncs: RealContextFuncs; /** * The map of HTML element aliases. * * Most frequently used to process Web Components with slashes in their names. * * Plugins can add aliases to this map. */ readonly htmlElementAlias: Record; /** * The root element component of the app. * * Initialized in the constructor depending on `rootElementId`. * * Call `app.root.addCls` or `app.root.addCss` to add classes or styles to the root element. */ readonly root: DOMRootComponent; /** * The DOM element component of the document body. * * Call `app.body.addCls` or `app.body.addCss` to add classes or styles to the document body. */ readonly body: DOMBodyComponent; /** * The DOM element component of the window. * * Call `app.window.addEventListener` to add event listeners to window. */ readonly window: DOMWindowComponent; /** * Lifetime: from the construction of the app to the window is closed. */ readonly permanentData: Record; /** * The state of the app. */ state: AppState; requireRecv: boolean; requireUpdate: boolean; /** * Mount the app to the root element. */ mount(): void; /** * Trigger an `UPDATE` call. */ readonly update: () => void; /** * Trigger a `RECV` call. */ readonly recv: () => void; protected execUpdate(): void; /** * Execute the main function of the app in current state. */ protected execMain(): void; /** * Lifecycle: removed after one call. */ onetimeHooks: { [K in keyof AppHookMap]?: AppHookMap[K][]; }; /** * Lifecycle: not removed after calls. */ readonly permanentHooks: { [K in keyof AppHookMap]?: AppHookMap[K][]; }; /** * Promises that resolve after the corresponding hooks are called. */ readonly promises: { /** * Store the app instance, because `this` is lost in the getters. */ app: App; /** * This promise resolves after the `beforeMain` hook is called. */ readonly mainExecuted: Promise; /** * This promise resolves after the `beforeModifyDOM` hook is called. */ readonly DOMUpdated: Promise; }; /** * Call onetime hooks and reset them, then call permanent hooks. * * @param hookName the name of the hooks to call * @param args the arguments to pass to each hook */ callHook(hookName: K, ...args: Parameters): void; /** * Add a onetime hook to the end of the hook queue. * * @param hookName The name of the hook to push * @param hooks The hook to push */ pushOnetimeHook(hookName: K, hook: AppHookMap[K]): void; /** * Add a permanent hook to the end of the hook queue. * * @param hookName * @param hooks */ pushPermanentHook(hookName: K, ...hooks: AppHookMap[K][]): void; /** * Set the value of a model and trigger an `UPDATE` call if the value is changed. * * @param model The model. * @param v The new value. * @returns Whether the value is changed. */ updateModel: (model: Model, v: T) => boolean; } export declare function $app(options: AppOptions, main: View): App; //# sourceMappingURL=app.d.ts.map