import type { MaybePromise } from '@difizen/mana-common';
import { Disposable } from '@difizen/mana-common';
import { Emitter, DisposableCollection } from '@difizen/mana-common';
import { Syringe } from '@difizen/mana-syringe';
import type { Decorator, Contribution } from '@difizen/mana-syringe';
import { DebugService } from '../common/debug';
import { WindowService } from './application-protocol';
import { ApplicationStateService } from './application-state';
export declare const ApplicationContribution: Syringe.DefinedToken;
export type ApplicationContribution = {
    /**
     * Called on application startup.
     */
    initialize?: () => void;
    /**
     * Called before the start of the contributions to complete asynchronous initialization.
     */
    onWillStart?: (app: Application) => MaybePromise<void>;
    /**
     * Called when the application is starting.
     */
    onStart?: (app: Application) => MaybePromise<void>;
    /**
     * Called when the application is started and after the root view has been created.
     */
    onViewStart?: (app: Application) => MaybePromise<void>;
    /**
     * Called on `beforeunload` event, return `true` in order to prevent exit.
     */
    onWillStop?: (app: Application) => boolean;
    /**
     * Called when an application is stopped.
     * Note: this is the last tick.
     */
    onStop?: (app: Application) => void;
};
export declare function application<T = any>(option?: Syringe.DecoratorOption<T>): Decorator<T>;
export declare class Application {
    protected _host?: HTMLElement;
    started: boolean;
    protected onKeyDownEmitter: Emitter<KeyboardEvent>;
    protected onHostChangedEmitter: Emitter<HTMLElement | undefined>;
    protected unmountToDispose: DisposableCollection;
    protected readonly windowsService: WindowService;
    protected readonly contributions: Contribution.Provider<ApplicationContribution>;
    protected readonly stateService: ApplicationStateService;
    protected readonly debugService: DebugService;
    get host(): HTMLElement | undefined;
    set host(v: HTMLElement | undefined);
    get onKeyDown(): import("@difizen/mana-common").Event<KeyboardEvent>;
    get onHostChanged(): import("@difizen/mana-common").Event<HTMLElement | undefined>;
    constructor(windowsService: WindowService, contributions: Contribution.Provider<ApplicationContribution>, stateService: ApplicationStateService, debugService: DebugService);
    /**
     * Start the frontend application.
     *
     * Start up consists of the following steps:
     * - start frontend contributions
     * - create root view and render it
     * - restore or create other views and render them
     */
    start(): Promise<void>;
    inComposition: boolean;
    /**
     * Register composition related event listeners.
     */
    protected registerCompositionEventListeners(): Disposable;
    protected registerKeyDownListener(): Disposable;
    mount(): void;
    unmount(): void;
    /**
     * Initialize and start the frontend application contributions.
     */
    protected initialize(): Promise<void>;
    /**
     * Initialize and start the frontend application contributions.
     */
    protected onStart(): Promise<void>;
    protected viewStart(): Promise<void>;
    onWillStop(): boolean;
    /**
     * Stop the frontend application contributions. This is called when the window is unloaded.
     */
    protected onStop(): void;
    protected measure<T>(name: string, fn: () => MaybePromise<T>): Promise<T>;
}
//# sourceMappingURL=application.d.ts.map