@jupyterlab/application 0.19.1-alpha.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +34 -0
- package/lib/index.d.ts +241 -241
- package/lib/index.js +283 -283
- package/lib/layoutrestorer.d.ts +205 -205
- package/lib/layoutrestorer.js +423 -423
- package/lib/mimerenderers.d.ts +22 -22
- package/lib/mimerenderers.js +137 -134
- package/lib/router.d.ts +204 -204
- package/lib/router.js +145 -145
- package/lib/shell.d.ts +277 -277
- package/lib/shell.js +857 -854
- package/package.json +13 -10
package/lib/layoutrestorer.d.ts
CHANGED
|
@@ -1,205 +1,205 @@
|
|
|
1
|
-
import { InstanceTracker } from '@jupyterlab/apputils';
|
|
2
|
-
import { IStateDB } from '@jupyterlab/coreutils';
|
|
3
|
-
import { CommandRegistry } from '@phosphor/commands';
|
|
4
|
-
import { ReadonlyJSONObject, Token } from '@phosphor/coreutils';
|
|
5
|
-
import { Widget } from '@phosphor/widgets';
|
|
6
|
-
import { ApplicationShell } from './shell';
|
|
7
|
-
/**
|
|
8
|
-
* The layout restorer token.
|
|
9
|
-
*/
|
|
10
|
-
export declare const ILayoutRestorer: Token<ILayoutRestorer>;
|
|
11
|
-
/**
|
|
12
|
-
* A static class that restores the widgets of the application when it reloads.
|
|
13
|
-
*/
|
|
14
|
-
export interface ILayoutRestorer {
|
|
15
|
-
/**
|
|
16
|
-
* A promise resolved when the layout restorer is ready to receive signals.
|
|
17
|
-
*/
|
|
18
|
-
restored: Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* Add a widget to be tracked by the layout restorer.
|
|
21
|
-
*/
|
|
22
|
-
add(widget: Widget, name: string): void;
|
|
23
|
-
/**
|
|
24
|
-
* Restore the widgets of a particular instance tracker.
|
|
25
|
-
*
|
|
26
|
-
* @param tracker - The instance tracker whose widgets will be restored.
|
|
27
|
-
*
|
|
28
|
-
* @param options - The restoration options.
|
|
29
|
-
*/
|
|
30
|
-
restore(tracker: InstanceTracker<any>, options: ILayoutRestorer.IRestoreOptions<any>): void;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* A namespace for the layout restorer.
|
|
34
|
-
*/
|
|
35
|
-
export declare namespace ILayoutRestorer {
|
|
36
|
-
/**
|
|
37
|
-
* The state restoration configuration options.
|
|
38
|
-
*/
|
|
39
|
-
interface IRestoreOptions<T extends Widget> {
|
|
40
|
-
/**
|
|
41
|
-
* The command to execute when restoring instances.
|
|
42
|
-
*/
|
|
43
|
-
command: string;
|
|
44
|
-
/**
|
|
45
|
-
* A function that returns the args needed to restore an instance.
|
|
46
|
-
*/
|
|
47
|
-
args: (widget: T) => ReadonlyJSONObject;
|
|
48
|
-
/**
|
|
49
|
-
* A function that returns a unique persistent name for this instance.
|
|
50
|
-
*/
|
|
51
|
-
name: (widget: T) => string;
|
|
52
|
-
/**
|
|
53
|
-
* The point after which it is safe to restore state.
|
|
54
|
-
*
|
|
55
|
-
* #### Notes
|
|
56
|
-
* By definition, this promise or promises will happen after the application
|
|
57
|
-
* has `started`.
|
|
58
|
-
*/
|
|
59
|
-
when?: Promise<any> | Array<Promise<any>>;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* The default implementation of a layout restorer.
|
|
64
|
-
*
|
|
65
|
-
* #### Notes
|
|
66
|
-
* The lifecycle for state restoration is subtle. The sequence of events is:
|
|
67
|
-
*
|
|
68
|
-
* 1. The layout restorer plugin is instantiated and makes a `fetch` call to
|
|
69
|
-
* the database that stores the layout restoration data. The `fetch` call
|
|
70
|
-
* returns a promise that resolves in step 6, below.
|
|
71
|
-
*
|
|
72
|
-
* 2. Other plugins that care about state restoration require the layout
|
|
73
|
-
* restorer as a dependency.
|
|
74
|
-
*
|
|
75
|
-
* 3. As each load-time plugin initializes (which happens before the lab
|
|
76
|
-
* application has `started`), it instructs the layout restorer whether
|
|
77
|
-
* the restorer ought to `restore` its state by passing in its tracker.
|
|
78
|
-
* Alternatively, a plugin that does not require its own instance tracker
|
|
79
|
-
* (because perhaps it only creates a single widget, like a command palette),
|
|
80
|
-
* can simply `add` its widget along with a persistent unique name to the
|
|
81
|
-
* layout restorer so that its layout state can be restored when the lab
|
|
82
|
-
* application restores.
|
|
83
|
-
*
|
|
84
|
-
* 4. After all the load-time plugins have finished initializing, the lab
|
|
85
|
-
* application `started` promise will resolve. This is the `first`
|
|
86
|
-
* promise that the layout restorer waits for. By this point, all of the
|
|
87
|
-
* plugins that care about restoration will have instructed the layout
|
|
88
|
-
* restorer to `restore` their state.
|
|
89
|
-
*
|
|
90
|
-
* 5. The layout restorer will then instruct each plugin's instance tracker
|
|
91
|
-
* to restore its state and reinstantiate whichever widgets it wants. The
|
|
92
|
-
* tracker returns a promise to the layout restorer that resolves when it
|
|
93
|
-
* has completed restoring the tracked widgets it cares about.
|
|
94
|
-
*
|
|
95
|
-
* 6. As each instance tracker finishes restoring the widget instances it cares
|
|
96
|
-
* about, it resolves the promise that was made to the layout restorer
|
|
97
|
-
* (in step 5). After all of the promises that the restorer is awaiting have
|
|
98
|
-
* resolved, the restorer then resolves the outstanding `fetch` promise
|
|
99
|
-
* (from step 1) and hands off a layout state object to the application
|
|
100
|
-
* shell's `restoreLayout` method for restoration.
|
|
101
|
-
*
|
|
102
|
-
* 7. Once the application shell has finished restoring the layout, the
|
|
103
|
-
* JupyterLab application's `restored` promise is resolved.
|
|
104
|
-
*
|
|
105
|
-
* Of particular note are steps 5 and 6: since state restoration of plugins
|
|
106
|
-
* is accomplished by executing commands, the command that is used to restore
|
|
107
|
-
* the state of each plugin must return a promise that only resolves when the
|
|
108
|
-
* widget has been created and added to the plugin's instance tracker.
|
|
109
|
-
*/
|
|
110
|
-
export declare class LayoutRestorer implements ILayoutRestorer {
|
|
111
|
-
/**
|
|
112
|
-
* Create a layout restorer.
|
|
113
|
-
*/
|
|
114
|
-
constructor(options: LayoutRestorer.IOptions);
|
|
115
|
-
/**
|
|
116
|
-
* A promise resolved when the layout restorer is ready to receive signals.
|
|
117
|
-
*/
|
|
118
|
-
readonly restored: Promise<void>;
|
|
119
|
-
/**
|
|
120
|
-
* Add a widget to be tracked by the layout restorer.
|
|
121
|
-
*/
|
|
122
|
-
add(widget: Widget, name: string): void;
|
|
123
|
-
/**
|
|
124
|
-
* Fetch the layout state for the application.
|
|
125
|
-
*
|
|
126
|
-
* #### Notes
|
|
127
|
-
* Fetching the layout relies on all widget restoration to be complete, so
|
|
128
|
-
* calls to `fetch` are guaranteed to return after restoration is complete.
|
|
129
|
-
*/
|
|
130
|
-
fetch(): Promise<ApplicationShell.ILayout>;
|
|
131
|
-
/**
|
|
132
|
-
* Restore the widgets of a particular instance tracker.
|
|
133
|
-
*
|
|
134
|
-
* @param tracker - The instance tracker whose widgets will be restored.
|
|
135
|
-
*
|
|
136
|
-
* @param options - The restoration options.
|
|
137
|
-
*/
|
|
138
|
-
restore(tracker: InstanceTracker<Widget>, options: ILayoutRestorer.IRestoreOptions<Widget>): Promise<any>;
|
|
139
|
-
/**
|
|
140
|
-
* Save the layout state for the application.
|
|
141
|
-
*/
|
|
142
|
-
save(data: ApplicationShell.ILayout): Promise<void>;
|
|
143
|
-
/**
|
|
144
|
-
* Dehydrate a main area description into a serializable object.
|
|
145
|
-
*/
|
|
146
|
-
private _dehydrateMainArea;
|
|
147
|
-
/**
|
|
148
|
-
* Reydrate a serialized main area description object.
|
|
149
|
-
*
|
|
150
|
-
* #### Notes
|
|
151
|
-
* This function consumes data that can become corrupted, so it uses type
|
|
152
|
-
* coercion to guarantee the dehydrated object is safely processed.
|
|
153
|
-
*/
|
|
154
|
-
private _rehydrateMainArea;
|
|
155
|
-
/**
|
|
156
|
-
* Dehydrate a side area description into a serializable object.
|
|
157
|
-
*/
|
|
158
|
-
private _dehydrateSideArea;
|
|
159
|
-
/**
|
|
160
|
-
* Reydrate a serialized side area description object.
|
|
161
|
-
*
|
|
162
|
-
* #### Notes
|
|
163
|
-
* This function consumes data that can become corrupted, so it uses type
|
|
164
|
-
* coercion to guarantee the dehydrated object is safely processed.
|
|
165
|
-
*/
|
|
166
|
-
private _rehydrateSideArea;
|
|
167
|
-
/**
|
|
168
|
-
* Handle a widget disposal.
|
|
169
|
-
*/
|
|
170
|
-
private _onWidgetDisposed;
|
|
171
|
-
private _first;
|
|
172
|
-
private _firstDone;
|
|
173
|
-
private _promisesDone;
|
|
174
|
-
private _promises;
|
|
175
|
-
private _restored;
|
|
176
|
-
private _registry;
|
|
177
|
-
private _state;
|
|
178
|
-
private _trackers;
|
|
179
|
-
private _widgets;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* A namespace for `LayoutRestorer` statics.
|
|
183
|
-
*/
|
|
184
|
-
export declare namespace LayoutRestorer {
|
|
185
|
-
/**
|
|
186
|
-
* The configuration options for layout restorer instantiation.
|
|
187
|
-
*/
|
|
188
|
-
interface IOptions {
|
|
189
|
-
/**
|
|
190
|
-
* The initial promise that has to be resolved before restoration.
|
|
191
|
-
*
|
|
192
|
-
* #### Notes
|
|
193
|
-
* This promise should equal the JupyterLab application `started` notifier.
|
|
194
|
-
*/
|
|
195
|
-
first: Promise<any>;
|
|
196
|
-
/**
|
|
197
|
-
* The application command registry.
|
|
198
|
-
*/
|
|
199
|
-
registry: CommandRegistry;
|
|
200
|
-
/**
|
|
201
|
-
* The state database instance.
|
|
202
|
-
*/
|
|
203
|
-
state: IStateDB;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
1
|
+
import { InstanceTracker } from '@jupyterlab/apputils';
|
|
2
|
+
import { IStateDB } from '@jupyterlab/coreutils';
|
|
3
|
+
import { CommandRegistry } from '@phosphor/commands';
|
|
4
|
+
import { ReadonlyJSONObject, Token } from '@phosphor/coreutils';
|
|
5
|
+
import { Widget } from '@phosphor/widgets';
|
|
6
|
+
import { ApplicationShell } from './shell';
|
|
7
|
+
/**
|
|
8
|
+
* The layout restorer token.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ILayoutRestorer: Token<ILayoutRestorer>;
|
|
11
|
+
/**
|
|
12
|
+
* A static class that restores the widgets of the application when it reloads.
|
|
13
|
+
*/
|
|
14
|
+
export interface ILayoutRestorer {
|
|
15
|
+
/**
|
|
16
|
+
* A promise resolved when the layout restorer is ready to receive signals.
|
|
17
|
+
*/
|
|
18
|
+
restored: Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Add a widget to be tracked by the layout restorer.
|
|
21
|
+
*/
|
|
22
|
+
add(widget: Widget, name: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Restore the widgets of a particular instance tracker.
|
|
25
|
+
*
|
|
26
|
+
* @param tracker - The instance tracker whose widgets will be restored.
|
|
27
|
+
*
|
|
28
|
+
* @param options - The restoration options.
|
|
29
|
+
*/
|
|
30
|
+
restore(tracker: InstanceTracker<any>, options: ILayoutRestorer.IRestoreOptions<any>): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A namespace for the layout restorer.
|
|
34
|
+
*/
|
|
35
|
+
export declare namespace ILayoutRestorer {
|
|
36
|
+
/**
|
|
37
|
+
* The state restoration configuration options.
|
|
38
|
+
*/
|
|
39
|
+
interface IRestoreOptions<T extends Widget> {
|
|
40
|
+
/**
|
|
41
|
+
* The command to execute when restoring instances.
|
|
42
|
+
*/
|
|
43
|
+
command: string;
|
|
44
|
+
/**
|
|
45
|
+
* A function that returns the args needed to restore an instance.
|
|
46
|
+
*/
|
|
47
|
+
args: (widget: T) => ReadonlyJSONObject;
|
|
48
|
+
/**
|
|
49
|
+
* A function that returns a unique persistent name for this instance.
|
|
50
|
+
*/
|
|
51
|
+
name: (widget: T) => string;
|
|
52
|
+
/**
|
|
53
|
+
* The point after which it is safe to restore state.
|
|
54
|
+
*
|
|
55
|
+
* #### Notes
|
|
56
|
+
* By definition, this promise or promises will happen after the application
|
|
57
|
+
* has `started`.
|
|
58
|
+
*/
|
|
59
|
+
when?: Promise<any> | Array<Promise<any>>;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The default implementation of a layout restorer.
|
|
64
|
+
*
|
|
65
|
+
* #### Notes
|
|
66
|
+
* The lifecycle for state restoration is subtle. The sequence of events is:
|
|
67
|
+
*
|
|
68
|
+
* 1. The layout restorer plugin is instantiated and makes a `fetch` call to
|
|
69
|
+
* the database that stores the layout restoration data. The `fetch` call
|
|
70
|
+
* returns a promise that resolves in step 6, below.
|
|
71
|
+
*
|
|
72
|
+
* 2. Other plugins that care about state restoration require the layout
|
|
73
|
+
* restorer as a dependency.
|
|
74
|
+
*
|
|
75
|
+
* 3. As each load-time plugin initializes (which happens before the lab
|
|
76
|
+
* application has `started`), it instructs the layout restorer whether
|
|
77
|
+
* the restorer ought to `restore` its state by passing in its tracker.
|
|
78
|
+
* Alternatively, a plugin that does not require its own instance tracker
|
|
79
|
+
* (because perhaps it only creates a single widget, like a command palette),
|
|
80
|
+
* can simply `add` its widget along with a persistent unique name to the
|
|
81
|
+
* layout restorer so that its layout state can be restored when the lab
|
|
82
|
+
* application restores.
|
|
83
|
+
*
|
|
84
|
+
* 4. After all the load-time plugins have finished initializing, the lab
|
|
85
|
+
* application `started` promise will resolve. This is the `first`
|
|
86
|
+
* promise that the layout restorer waits for. By this point, all of the
|
|
87
|
+
* plugins that care about restoration will have instructed the layout
|
|
88
|
+
* restorer to `restore` their state.
|
|
89
|
+
*
|
|
90
|
+
* 5. The layout restorer will then instruct each plugin's instance tracker
|
|
91
|
+
* to restore its state and reinstantiate whichever widgets it wants. The
|
|
92
|
+
* tracker returns a promise to the layout restorer that resolves when it
|
|
93
|
+
* has completed restoring the tracked widgets it cares about.
|
|
94
|
+
*
|
|
95
|
+
* 6. As each instance tracker finishes restoring the widget instances it cares
|
|
96
|
+
* about, it resolves the promise that was made to the layout restorer
|
|
97
|
+
* (in step 5). After all of the promises that the restorer is awaiting have
|
|
98
|
+
* resolved, the restorer then resolves the outstanding `fetch` promise
|
|
99
|
+
* (from step 1) and hands off a layout state object to the application
|
|
100
|
+
* shell's `restoreLayout` method for restoration.
|
|
101
|
+
*
|
|
102
|
+
* 7. Once the application shell has finished restoring the layout, the
|
|
103
|
+
* JupyterLab application's `restored` promise is resolved.
|
|
104
|
+
*
|
|
105
|
+
* Of particular note are steps 5 and 6: since state restoration of plugins
|
|
106
|
+
* is accomplished by executing commands, the command that is used to restore
|
|
107
|
+
* the state of each plugin must return a promise that only resolves when the
|
|
108
|
+
* widget has been created and added to the plugin's instance tracker.
|
|
109
|
+
*/
|
|
110
|
+
export declare class LayoutRestorer implements ILayoutRestorer {
|
|
111
|
+
/**
|
|
112
|
+
* Create a layout restorer.
|
|
113
|
+
*/
|
|
114
|
+
constructor(options: LayoutRestorer.IOptions);
|
|
115
|
+
/**
|
|
116
|
+
* A promise resolved when the layout restorer is ready to receive signals.
|
|
117
|
+
*/
|
|
118
|
+
readonly restored: Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Add a widget to be tracked by the layout restorer.
|
|
121
|
+
*/
|
|
122
|
+
add(widget: Widget, name: string): void;
|
|
123
|
+
/**
|
|
124
|
+
* Fetch the layout state for the application.
|
|
125
|
+
*
|
|
126
|
+
* #### Notes
|
|
127
|
+
* Fetching the layout relies on all widget restoration to be complete, so
|
|
128
|
+
* calls to `fetch` are guaranteed to return after restoration is complete.
|
|
129
|
+
*/
|
|
130
|
+
fetch(): Promise<ApplicationShell.ILayout>;
|
|
131
|
+
/**
|
|
132
|
+
* Restore the widgets of a particular instance tracker.
|
|
133
|
+
*
|
|
134
|
+
* @param tracker - The instance tracker whose widgets will be restored.
|
|
135
|
+
*
|
|
136
|
+
* @param options - The restoration options.
|
|
137
|
+
*/
|
|
138
|
+
restore(tracker: InstanceTracker<Widget>, options: ILayoutRestorer.IRestoreOptions<Widget>): Promise<any>;
|
|
139
|
+
/**
|
|
140
|
+
* Save the layout state for the application.
|
|
141
|
+
*/
|
|
142
|
+
save(data: ApplicationShell.ILayout): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Dehydrate a main area description into a serializable object.
|
|
145
|
+
*/
|
|
146
|
+
private _dehydrateMainArea;
|
|
147
|
+
/**
|
|
148
|
+
* Reydrate a serialized main area description object.
|
|
149
|
+
*
|
|
150
|
+
* #### Notes
|
|
151
|
+
* This function consumes data that can become corrupted, so it uses type
|
|
152
|
+
* coercion to guarantee the dehydrated object is safely processed.
|
|
153
|
+
*/
|
|
154
|
+
private _rehydrateMainArea;
|
|
155
|
+
/**
|
|
156
|
+
* Dehydrate a side area description into a serializable object.
|
|
157
|
+
*/
|
|
158
|
+
private _dehydrateSideArea;
|
|
159
|
+
/**
|
|
160
|
+
* Reydrate a serialized side area description object.
|
|
161
|
+
*
|
|
162
|
+
* #### Notes
|
|
163
|
+
* This function consumes data that can become corrupted, so it uses type
|
|
164
|
+
* coercion to guarantee the dehydrated object is safely processed.
|
|
165
|
+
*/
|
|
166
|
+
private _rehydrateSideArea;
|
|
167
|
+
/**
|
|
168
|
+
* Handle a widget disposal.
|
|
169
|
+
*/
|
|
170
|
+
private _onWidgetDisposed;
|
|
171
|
+
private _first;
|
|
172
|
+
private _firstDone;
|
|
173
|
+
private _promisesDone;
|
|
174
|
+
private _promises;
|
|
175
|
+
private _restored;
|
|
176
|
+
private _registry;
|
|
177
|
+
private _state;
|
|
178
|
+
private _trackers;
|
|
179
|
+
private _widgets;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* A namespace for `LayoutRestorer` statics.
|
|
183
|
+
*/
|
|
184
|
+
export declare namespace LayoutRestorer {
|
|
185
|
+
/**
|
|
186
|
+
* The configuration options for layout restorer instantiation.
|
|
187
|
+
*/
|
|
188
|
+
interface IOptions {
|
|
189
|
+
/**
|
|
190
|
+
* The initial promise that has to be resolved before restoration.
|
|
191
|
+
*
|
|
192
|
+
* #### Notes
|
|
193
|
+
* This promise should equal the JupyterLab application `started` notifier.
|
|
194
|
+
*/
|
|
195
|
+
first: Promise<any>;
|
|
196
|
+
/**
|
|
197
|
+
* The application command registry.
|
|
198
|
+
*/
|
|
199
|
+
registry: CommandRegistry;
|
|
200
|
+
/**
|
|
201
|
+
* The state database instance.
|
|
202
|
+
*/
|
|
203
|
+
state: IStateDB;
|
|
204
|
+
}
|
|
205
|
+
}
|