import { CancellationToken } from "../../../../base/common/cancellation.js"; /** * An event that is send out when the window is about to close. Clients have a chance to veto * the closing by either calling veto with a boolean "true" directly or with a promise that * resolves to a boolean. Returning a promise is useful in cases of long running operations * on shutdown. * * Note: It is absolutely important to avoid long running promises if possible. Please try hard * to return a boolean directly. Returning a promise has quite an impact on the shutdown sequence! */ export interface BeforeShutdownEvent { /** * The reason why the application will be shutting down. */ readonly reason: ShutdownReason; /** * Allows to veto the shutdown. The veto can be a long running operation but it * will block the application from closing. * * @param id to identify the veto operation in case it takes very long or never * completes. */ veto(value: boolean | Promise, id: string): void; } export interface InternalBeforeShutdownEvent extends BeforeShutdownEvent { /** * Allows to set a veto operation to run after all other * vetos have been handled from the `BeforeShutdownEvent` * * This method is hidden from the API because it is intended * to be only used once internally. */ finalVeto(vetoFn: () => boolean | Promise, id: string): void; } /** * An event that signals an error happened during `onBeforeShutdown` veto handling. * In this case the shutdown operation will not proceed because this is an unexpected * condition that is treated like a veto. */ export interface BeforeShutdownErrorEvent { /** * The reason why the application is shutting down. */ readonly reason: ShutdownReason; /** * The error that happened during shutdown handling. */ readonly error: Error; } export declare enum WillShutdownJoinerOrder { /** * Joiners to run before the `Last` joiners. This is the default order and best for * most cases. You can be sure that services are still functional at this point. */ Default = 1, /** * The joiners to run last. This should ONLY be used in rare cases when you have no * dependencies to workbench services or state. The workbench may be in a state where * resources can no longer be accessed or changed. */ Last = 2 } export interface IWillShutdownEventJoiner { readonly id: string; readonly label: string; readonly order?: WillShutdownJoinerOrder; } export interface IWillShutdownEventDefaultJoiner extends IWillShutdownEventJoiner { readonly order?: WillShutdownJoinerOrder.Default; } export interface IWillShutdownEventLastJoiner extends IWillShutdownEventJoiner { readonly order: WillShutdownJoinerOrder.Last; } /** * An event that is send out when the window closes. Clients have a chance to join the closing * by providing a promise from the join method. Returning a promise is useful in cases of long * running operations on shutdown. * * Note: It is absolutely important to avoid long running promises if possible. Please try hard * to return a boolean directly. Returning a promise has quite an impact on the shutdown sequence! */ export interface WillShutdownEvent { /** * The reason why the application is shutting down. */ readonly reason: ShutdownReason; /** * A token that will signal cancellation when the * shutdown was forced by the user. */ readonly token: CancellationToken; /** * Allows to join the shutdown. The promise can be a long running operation but it * will block the application from closing. * * @param promise the promise to join the shutdown event. * @param joiner to identify the join operation in case it takes very long or never * completes. */ join(promise: Promise, joiner: IWillShutdownEventDefaultJoiner): void; /** * Allows to join the shutdown at the end. The promise can be a long running operation but it * will block the application from closing. * * @param promiseFn the promise to join the shutdown event. * @param joiner to identify the join operation in case it takes very long or never * completes. */ join(promiseFn: (() => Promise), joiner: IWillShutdownEventLastJoiner): void; /** * Allows to access the joiners that have not finished joining this event. */ joiners(): IWillShutdownEventJoiner[]; /** * Allows to enforce the shutdown, even when there are * pending `join` operations to complete. */ force(): void; } export declare enum ShutdownReason { /** * The window is closed. */ CLOSE = 1, /** * The window closes because the application quits. */ QUIT = 2, /** * The window is reloaded. */ RELOAD = 3, /** * The window is loaded into a different workspace context. */ LOAD = 4 } export declare enum StartupKind { NewWindow = 1, ReloadedWindow = 3, ReopenedWindow = 4 } export declare function StartupKindToString(startupKind: StartupKind): string; export declare enum LifecyclePhase { /** * The first phase signals that we are about to startup getting ready. * * Note: doing work in this phase blocks an editor from showing to * the user, so please rather consider to use `Restored` phase. */ Starting = 1, /** * Services are ready and the window is about to restore its UI state. * * Note: doing work in this phase blocks an editor from showing to * the user, so please rather consider to use `Restored` phase. */ Ready = 2, /** * Views, panels and editors have restored. Editors are given a bit of * time to restore their contents. */ Restored = 3, /** * The last phase after views, panels and editors have restored and * some time has passed (2-5 seconds). */ Eventually = 4 } export declare function LifecyclePhaseToString(phase: LifecyclePhase): string;