1 | import { Widget } from '@phosphor/widgets';
|
2 | import { FrontendApplication } from '../frontend-application';
|
3 | import { WidgetManager, WidgetConstructionOptions } from '../widget-manager';
|
4 | import { StorageService } from '../storage-service';
|
5 | import { ILogger } from '../../common/logger';
|
6 | import { CommandContribution, CommandRegistry, Command } from '../../common/command';
|
7 | import { ThemeService } from '../theming';
|
8 | import { ContributionProvider } from '../../common/contribution-provider';
|
9 | import { ApplicationShell, ApplicationShellLayoutVersion } from './application-shell';
|
10 | import { WindowService } from '../window/window-service';
|
11 | import { MaybePromise } from '../../common';
|
12 |
|
13 |
|
14 |
|
15 | export interface StatefulWidget {
|
16 | |
17 |
|
18 |
|
19 | storeState(): object | undefined;
|
20 | |
21 |
|
22 |
|
23 | restoreState(oldState: object): void;
|
24 | }
|
25 | export declare namespace StatefulWidget {
|
26 | function is(arg: unknown): arg is StatefulWidget;
|
27 | }
|
28 | export interface WidgetDescription {
|
29 | constructionOptions: WidgetConstructionOptions;
|
30 | innerWidgetState?: string | object;
|
31 | }
|
32 | export interface ApplicationShellLayoutMigrationContext {
|
33 | |
34 |
|
35 |
|
36 | layoutVersion: number;
|
37 | |
38 |
|
39 |
|
40 | layout: ApplicationShell.LayoutData;
|
41 | |
42 |
|
43 |
|
44 | parent?: Widget;
|
45 | }
|
46 | export interface ApplicationShellLayoutMigrationError extends Error {
|
47 | code: 'ApplicationShellLayoutMigrationError';
|
48 | }
|
49 | export declare namespace ApplicationShellLayoutMigrationError {
|
50 | function create(message?: string): ApplicationShellLayoutMigrationError;
|
51 | function is(error: Error | undefined): error is ApplicationShellLayoutMigrationError;
|
52 | }
|
53 | export declare const ApplicationShellLayoutMigration: unique symbol;
|
54 | export interface ApplicationShellLayoutMigration {
|
55 | |
56 |
|
57 |
|
58 | readonly layoutVersion: ApplicationShellLayoutVersion;
|
59 | |
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | onWillInflateLayout?(context: ApplicationShellLayoutMigrationContext): MaybePromise<void>;
|
66 | |
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 | onWillInflateWidget?(desc: WidgetDescription, context: ApplicationShellLayoutMigrationContext): MaybePromise<WidgetDescription | undefined>;
|
74 | }
|
75 | export declare const RESET_LAYOUT: Command;
|
76 | export declare class ShellLayoutRestorer implements CommandContribution {
|
77 | protected widgetManager: WidgetManager;
|
78 | protected logger: ILogger;
|
79 | protected storageService: StorageService;
|
80 | protected storageKey: string;
|
81 | protected shouldStoreLayout: boolean;
|
82 | protected readonly migrations: ContributionProvider<ApplicationShellLayoutMigration>;
|
83 | protected readonly windowService: WindowService;
|
84 | protected readonly themeService: ThemeService;
|
85 | constructor(widgetManager: WidgetManager, logger: ILogger, storageService: StorageService);
|
86 | registerCommands(commands: CommandRegistry): void;
|
87 | protected resetLayout(): Promise<void>;
|
88 | storeLayout(app: FrontendApplication): void;
|
89 | restoreLayout(app: FrontendApplication): Promise<boolean>;
|
90 | protected isWidgetProperty(propertyName: string): boolean;
|
91 | protected isWidgetsProperty(propertyName: string): boolean;
|
92 | /**
|
93 | * Turns the layout data to a string representation.
|
94 | */
|
95 | protected deflate(data: object): string;
|
96 | private convertToDescription;
|
97 | /**
|
98 | * Creates the layout data from its string representation.
|
99 | */
|
100 | protected inflate(layoutData: string): Promise<ApplicationShell.LayoutData>;
|
101 | protected fireWillInflateLayout(context: ShellLayoutRestorer.InflateContext): Promise<void>;
|
102 | protected parse<T>(layoutData: string, parseContext: ShellLayoutRestorer.ParseContext): T;
|
103 | protected fireWillInflateWidget(desc: WidgetDescription, context: ShellLayoutRestorer.InflateContext): Promise<WidgetDescription>;
|
104 | protected convertToWidget(desc: WidgetDescription, context: ShellLayoutRestorer.InflateContext): Promise<Widget | undefined>;
|
105 | }
|
106 | export declare namespace ShellLayoutRestorer {
|
107 | class ParseContext {
|
108 | protected readonly toInflate: Inflate[];
|
109 | protected readonly toFilter: Widgets[];
|
110 | |
111 |
|
112 |
|
113 |
|
114 | filteredArray(): Widgets;
|
115 | push(toInflate: Inflate): void;
|
116 | inflate(context: InflateContext): Promise<void>;
|
117 | }
|
118 | type Widgets = (Widget | undefined)[];
|
119 | type Inflate = (context: InflateContext) => Promise<void>;
|
120 | interface InflateContext extends ApplicationShellLayoutMigrationContext {
|
121 | readonly migrations: ApplicationShellLayoutMigration[];
|
122 | }
|
123 | }
|
124 |
|
\ | No newline at end of file |