import { SyncBailHook, AsyncSeriesHook } from './tapable/index'; import { AppError } from './AppError'; import { LifecycleShadow } from './Lifecycle'; import type { AppOptions } from './Def'; import { ProtectedEventEmitter } from './utils/ProtectedEventEmitter'; import { Debugger } from './utils/Debugger'; export interface AppEvent { statechange: { prevState: AppState; nextState: AppState; }; beforestart: void; afterstart: void; starterror: AppError; beforestop: void; afterstop: void; stoperror: AppError; beforeupdate: void; afterupdate: void; updateerror: AppError; beforeunload: void; afterunload: void; unloaderror: AppError; } export declare enum AppState { NOT_LOADED = "NOT_LOADED", LOADING_SOURCE_CODE = "LOADING_SOURCE_CODE", NOT_BOOTSTRAPPED = "NOT_BOOTSTRAPPED", BOOTSTRAPPING = "BOOTSTRAPPING", NOT_MOUNTED = "NOT_MOUNTED", MOUNTING = "MOUNTING", MOUNTED = "MOUNTED", UPDATING = "UPDATING", UNMOUNTING = "UNMOUNTING", UNLOADING = "UNLOADING", LOAD_ERROR = "LOAD_ERROR", SKIP_BECAUSE_BROKEN = "SKIP_BECAUSE_BROKEN" } export declare enum AppDirective { IDLE = "idle", START = "start", STOP = "stop", UPDATE = "update", UNLOAD = "unload" } export interface AppShadow { readonly on: (event: T, listener: (event: AppEvent[T]) => unknown, context?: unknown) => this; readonly once: (event: T, listener: (event: AppEvent[T]) => unknown, context?: unknown) => this; readonly off: (event: T, listener: (event: AppEvent[T]) => unknown, context?: unknown) => this; /** * Lifecycle object of this application. */ lifecycle: LifecycleShadow; /** * Options of this application. */ options: AppOptions & AdditionalOptions; /** * If is already unloaded. */ isUnloaded: boolean; /** * Update this application with specified props. * @param customProps New props to update with. */ update(customProps: CustomProps): Promise; } export declare class App, CustomProps = Record> extends Debugger implements ProtectedEventEmitter { #private; readonly hooks: Readonly<{ encounterUnmountFailure: SyncBailHook; encounterLoadingSourceCodeFailure: SyncBailHook; waitForLoadingOrBootstrappingWhenStop: SyncBailHook; beforestart: AsyncSeriesHook; afterstart: AsyncSeriesHook; starterror: AsyncSeriesHook; beforestop: AsyncSeriesHook; afterstop: AsyncSeriesHook; stoperror: AsyncSeriesHook; beforeupdate: AsyncSeriesHook; afterupdate: AsyncSeriesHook; updateerror: AsyncSeriesHook; beforeunload: AsyncSeriesHook; afterunload: AsyncSeriesHook; }>; constructor(options: AppOptions & AdditionalOptions); get export(): AppShadow; get [Symbol.toStringTag](): string; get options(): AppOptions & AdditionalOptions; get wrapperDOM(): HTMLElement; get name(): string; get state(): AppState; get lifecycle(): LifecycleShadow; get latestDirective(): AppDirective; get isUnloaded(): boolean; protected get debugName(): string; on(event: T, listener: (event: AppEvent[T]) => unknown, context?: unknown): this; once(event: T, listener: (event: AppEvent[T]) => unknown, context?: unknown): this; off(event: T, listener: (event: AppEvent[T]) => unknown, context?: unknown): this; toString(): string; /** * Load lifecycles. * @returns Promise */ load(): Promise; /** * Start this application. * * This may interrupt stopping. * @returns Promise */ start(): Promise; /** * Stop this application. * * This may interrupt starting or updating. * @returns Promise */ stop(): Promise; /** * Update this application with properties. * * This may interrupt stopping. * @param customProps Properties to update with. * @returns Promise */ update(customProps: CustomProps): Promise; /** * Unload this application. * * This may interrupt starting or updating. * * If unload() is called, other operations like start/update/stop would never be allowed again. * @returns Promise */ unload(): Promise; }