import { AsyncSeriesBailHook, AsyncSeriesHook } from './tapable/index'; import { LifecycleFns, LifecycleFn, AppTimeouts, LifecycleOptions } from './Def'; import type { AppError } from './AppError'; import { ProtectedEventEmitter } from './utils/ProtectedEventEmitter'; import { Debugger } from './utils/Debugger'; export interface LifecycleEvent { beforeload: void; afterload: void; loaderror: AppError; beforebootstrap: void; afterbootstrap: void; bootstraperror: AppError; beforemount: void; aftermount: void; mounterror: AppError; beforeunmount: void; afterunmount: void; unmounterror: AppError; beforeupdate: void; afterupdate: void; updateerror: AppError; } export declare type LifecycleHooks = { beforeload: AsyncSeriesHook; afterload: AsyncSeriesHook; loaderror: AsyncSeriesHook; beforebootstrap: AsyncSeriesHook; afterbootstrap: AsyncSeriesHook; bootstraperror: AsyncSeriesHook; beforemount: AsyncSeriesHook; aftermount: AsyncSeriesHook; mounterror: AsyncSeriesHook; beforeunmount: AsyncSeriesHook; afterunmount: AsyncSeriesHook; unmounterror: AsyncSeriesHook; beforeupdate: AsyncSeriesHook; afterupdate: AsyncSeriesHook; updateerror: AsyncSeriesHook; load: AsyncSeriesBailHook | void>; bootstrap: AsyncSeriesBailHook; mount: AsyncSeriesBailHook; unmount: AsyncSeriesBailHook; update: AsyncSeriesBailHook<{ params: CustomProps; }, unknown>; }; export interface LifecycleShadow { rootDOM: Element | null; hooks: LifecycleHooks; customProps: CustomProps; readonly fns: { call: (fnName: keyof LifecycleFns, arg: CustomProps, allowUndefined?: boolean, each?: (index: number, total: number) => void) => ReturnType>; }; readonly on: (event: T, listener: (event: LifecycleEvent[T]) => unknown, context?: unknown) => this; readonly once: (event: T, listener: (event: LifecycleEvent[T]) => unknown, context?: unknown) => this; readonly off: (event: T, listener: (event: LifecycleEvent[T]) => unknown, context?: unknown) => this; } export declare class Lifecycle extends Debugger implements ProtectedEventEmitter { #private; hooks: LifecycleHooks; constructor(def: LifecycleOptions, rootDOM: string | Element); protected get debugName(): string; get customProps(): CustomProps; get options(): LifecycleOptions; get timeouts(): AppTimeouts; get name(): string; get [Symbol.toStringTag](): string; toString(): string; get rootDOM(): Element | null; on(event: T, listener: (event: LifecycleEvent[T]) => unknown, context?: unknown): this; once(event: T, listener: (event: LifecycleEvent[T]) => unknown, context?: unknown): this; off(event: T, listener: (event: LifecycleEvent[T]) => unknown, context?: unknown): this; get export(): LifecycleShadow; /** * Load lifecycle function from lifecycle, assetsMap or entry. * * This function is concurrency-safe, for independent preload. * @returns void */ load(): Promise; mount(): Promise; bootstrap(): Promise; unmount(): Promise; update(customProps: CustomProps): Promise; /** * Clear all states. * @returns Promise */ clear(): Promise | unknown; }