1 | import type { FrontendApplication } from './frontend-application';
|
2 | import { MaybePromise } from '../common/types';
|
3 | import { StopReason } from '../common/frontend-application-state';
|
4 | /**
|
5 | * Clients can implement to get a callback for contributing widgets to a shell on start.
|
6 | */
|
7 | export declare const FrontendApplicationContribution: unique symbol;
|
8 | export interface FrontendApplicationContribution {
|
9 | /**
|
10 | * Called on application startup before configure is called.
|
11 | */
|
12 | initialize?(): void;
|
13 | /**
|
14 | * Called before commands, key bindings and menus are initialized.
|
15 | * Should return a promise if it runs asynchronously.
|
16 | */
|
17 | configure?(app: FrontendApplication): MaybePromise<void>;
|
18 | /**
|
19 | * Called when the application is started. The application shell is not attached yet when this method runs.
|
20 | * Should return a promise if it runs asynchronously.
|
21 | */
|
22 | onStart?(app: FrontendApplication): MaybePromise<void>;
|
23 | /**
|
24 | * Called on `beforeunload` event, right before the window closes.
|
25 | * Return `true` or an OnWillStopAction in order to prevent exit.
|
26 | * Note: No async code allowed, this function has to run on one tick.
|
27 | */
|
28 | onWillStop?(app: FrontendApplication): boolean | undefined | OnWillStopAction<unknown>;
|
29 | /**
|
30 | * Called when an application is stopped or unloaded.
|
31 | *
|
32 | * Note that this is implemented using `window.beforeunload` which doesn't allow any asynchronous code anymore.
|
33 | * I.e. this is the last tick.
|
34 | */
|
35 | onStop?(app: FrontendApplication): void;
|
36 | /**
|
37 | * Called after the application shell has been attached in case there is no previous workbench layout state.
|
38 | * Should return a promise if it runs asynchronously.
|
39 | */
|
40 | initializeLayout?(app: FrontendApplication): MaybePromise<void>;
|
41 | /**
|
42 | * An event is emitted when a layout is initialized, but before the shell is attached.
|
43 | */
|
44 | onDidInitializeLayout?(app: FrontendApplication): MaybePromise<void>;
|
45 | }
|
46 | export interface OnWillStopAction<T = unknown> {
|
47 | /**
|
48 | * @resolves to a prepared value to be passed into the `action` function.
|
49 | */
|
50 | prepare?: (stopReason?: StopReason) => MaybePromise<T>;
|
51 | /**
|
52 | * @resolves to `true` if it is safe to close the application; `false` otherwise.
|
53 | */
|
54 | action: (prepared: T, stopReason?: StopReason) => MaybePromise<boolean>;
|
55 | /**
|
56 | * A descriptive string for the reason preventing close.
|
57 | */
|
58 | reason: string;
|
59 | /**
|
60 | * A number representing priority. Higher priority items are run later.
|
61 | * High priority implies that some options of this check will have negative impacts if
|
62 | * the user subsequently cancels the shutdown.
|
63 | */
|
64 | priority?: number;
|
65 | }
|
66 | export declare namespace OnWillStopAction {
|
67 | function is(candidate: unknown): candidate is OnWillStopAction;
|
68 | }
|
69 | /**
|
70 | * Default frontend contribution that can be extended by clients if they do not want to implement any of the
|
71 | * methods from the interface but still want to contribute to the frontend application.
|
72 | */
|
73 | export declare abstract class DefaultFrontendApplicationContribution implements FrontendApplicationContribution {
|
74 | initialize(): void;
|
75 | }
|
76 | //# sourceMappingURL=frontend-application-contribution.d.ts.map |
\ | No newline at end of file |