UNPKG

@theia/core

Version:

Theia is a cloud & desktop IDE framework implemented in TypeScript.

72 lines 3.73 kB
import { Event, Emitter, ILogger } from '../../common'; import { CorePreferences } from '../../common/core-preferences'; import { ContributionProvider } from '../../common/contribution-provider'; import { FrontendApplicationContribution, OnWillStopAction } from '../frontend-application-contribution'; import { WindowService } from './window-service'; import { StopReason } from '../../common/frontend-application-state'; import { FrontendApplication } from '../frontend-application'; export declare class DefaultWindowService implements WindowService, FrontendApplicationContribution { protected frontendApplication: FrontendApplication; protected allowVetoes: boolean; protected unloaded: boolean; protected onUnloadEmitter: Emitter<void>; get onUnload(): Event<void>; protected readonly corePreferences: CorePreferences; protected readonly contributions: ContributionProvider<FrontendApplicationContribution>; protected readonly logger: ILogger; onStart(app: FrontendApplication): void; openNewWindow(url: string): undefined; openNewDefaultWindow(): Promise<number>; closeWindow(windowId: number): void; focus(): void; /** * Returns a list of actions that {@link FrontendApplicationContribution}s would like to take before shutdown * It is expected that this will succeed - i.e. return an empty array - at most once per session. If no vetoes are received * during any cycle, no further checks will be made. In that case, shutdown should proceed unconditionally. */ protected collectContributionUnloadVetoes(): OnWillStopAction[]; /** * Implement the mechanism to detect unloading of the page. */ protected registerUnloadListeners(): void; /** * `pagehide` is used instead of the deprecated `unload` event, which Chrome may block * via permissions policy (https://developer.chrome.com/docs/web-platform/deprecating-unload), * silently skipping the handler and thus e.g. losing the layout. */ protected registerPageHideListener(): void; /** * `pagehide` also fires when the page enters the back/forward cache, in which case the frontend * has already shut down (state saved, connections closed). Reload to get a working application * again if the page is restored from the cache. That shutdown already happened, so the reload * must not be vetoed by the contributions. */ protected handlePageShow(event: PageTransitionEvent): void; /** * Fires {@link onUnload} at most once per document: `pagehide` fires again for the reload that * recovers a page restored from the back/forward cache, but the application is already stopped. */ protected handlePageHide(): void; isSafeToShutDown(stopReason: StopReason): Promise<boolean>; setSafeToShutDown(): void; /** * Called when the `window` is about to `unload` its resources. * At this point, the `document` is still visible and the [`BeforeUnloadEvent`](https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event) * event will be canceled if the return value of this method is `false`. * * In Electron, handleCloseRequestEvent is is run instead. */ protected handleBeforeUnloadEvent(event: BeforeUnloadEvent): string | void; /** * Notify the browser that we do not want to unload. * * Notes: * - Shows a confirmation popup in browsers. * - Prevents the window from closing without confirmation in electron. * * @param event The beforeunload event */ protected preventUnload(event: BeforeUnloadEvent): string | void; reload(): void; } //# sourceMappingURL=default-window-service.d.ts.map