@jupyterlab/apputils 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/clientsession.d.ts +443 -443
- package/lib/clientsession.js +883 -883
- package/lib/clipboard.d.ts +33 -33
- package/lib/clipboard.js +88 -88
- package/lib/commandlinker.d.ts +121 -121
- package/lib/commandlinker.js +175 -175
- package/lib/commandpalette.d.ts +33 -33
- package/lib/commandpalette.js +12 -12
- package/lib/dialog.d.ts +357 -357
- package/lib/dialog.js +540 -540
- package/lib/domutils.d.ts +13 -13
- package/lib/domutils.js +28 -28
- package/lib/hoverbox.d.ts +82 -82
- package/lib/hoverbox.js +101 -101
- package/lib/iframe.d.ts +14 -14
- package/lib/iframe.js +45 -45
- package/lib/index.d.ts +19 -19
- package/lib/index.js +26 -26
- package/lib/instancetracker.d.ts +278 -278
- package/lib/instancetracker.js +318 -318
- package/lib/mainareawidget.d.ts +108 -108
- package/lib/mainareawidget.js +184 -184
- package/lib/sanitizer.d.ts +44 -44
- package/lib/sanitizer.js +913 -913
- package/lib/spinner.d.ts +15 -15
- package/lib/spinner.js +30 -30
- package/lib/splash.d.ts +19 -19
- package/lib/splash.js +10 -10
- package/lib/styling.d.ts +27 -27
- package/lib/styling.js +92 -92
- package/lib/thememanager.d.ts +141 -141
- package/lib/thememanager.js +238 -238
- package/lib/toolbar.d.ts +178 -178
- package/lib/toolbar.js +515 -515
- package/lib/vdom.d.ts +90 -90
- package/lib/vdom.js +130 -130
- package/lib/windowresolver.d.ts +37 -37
- package/lib/windowresolver.js +173 -173
- package/package.json +9 -6
package/lib/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Jupyter Development Team.
|
|
3
|
-
// Distributed under the terms of the Modified BSD License.
|
|
4
|
-
function __export(m) {
|
|
5
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
6
|
-
}
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
require("../style/index.css");
|
|
9
|
-
__export(require("./clientsession"));
|
|
10
|
-
__export(require("./clipboard"));
|
|
11
|
-
__export(require("./commandlinker"));
|
|
12
|
-
__export(require("./commandpalette"));
|
|
13
|
-
__export(require("./dialog"));
|
|
14
|
-
__export(require("./domutils"));
|
|
15
|
-
__export(require("./hoverbox"));
|
|
16
|
-
__export(require("./iframe"));
|
|
17
|
-
__export(require("./instancetracker"));
|
|
18
|
-
__export(require("./mainareawidget"));
|
|
19
|
-
__export(require("./sanitizer"));
|
|
20
|
-
__export(require("./spinner"));
|
|
21
|
-
__export(require("./splash"));
|
|
22
|
-
__export(require("./styling"));
|
|
23
|
-
__export(require("./thememanager"));
|
|
24
|
-
__export(require("./toolbar"));
|
|
25
|
-
__export(require("./vdom"));
|
|
26
|
-
__export(require("./windowresolver"));
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Jupyter Development Team.
|
|
3
|
+
// Distributed under the terms of the Modified BSD License.
|
|
4
|
+
function __export(m) {
|
|
5
|
+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
require("../style/index.css");
|
|
9
|
+
__export(require("./clientsession"));
|
|
10
|
+
__export(require("./clipboard"));
|
|
11
|
+
__export(require("./commandlinker"));
|
|
12
|
+
__export(require("./commandpalette"));
|
|
13
|
+
__export(require("./dialog"));
|
|
14
|
+
__export(require("./domutils"));
|
|
15
|
+
__export(require("./hoverbox"));
|
|
16
|
+
__export(require("./iframe"));
|
|
17
|
+
__export(require("./instancetracker"));
|
|
18
|
+
__export(require("./mainareawidget"));
|
|
19
|
+
__export(require("./sanitizer"));
|
|
20
|
+
__export(require("./spinner"));
|
|
21
|
+
__export(require("./splash"));
|
|
22
|
+
__export(require("./styling"));
|
|
23
|
+
__export(require("./thememanager"));
|
|
24
|
+
__export(require("./toolbar"));
|
|
25
|
+
__export(require("./vdom"));
|
|
26
|
+
__export(require("./windowresolver"));
|
package/lib/instancetracker.d.ts
CHANGED
|
@@ -1,278 +1,278 @@
|
|
|
1
|
-
import { IStateDB } from '@jupyterlab/coreutils';
|
|
2
|
-
import { CommandRegistry } from '@phosphor/commands';
|
|
3
|
-
import { ReadonlyJSONObject } from '@phosphor/coreutils';
|
|
4
|
-
import { IDisposable } from '@phosphor/disposable';
|
|
5
|
-
import { ISignal } from '@phosphor/signaling';
|
|
6
|
-
import { Widget } from '@phosphor/widgets';
|
|
7
|
-
/**
|
|
8
|
-
* An object that tracks widget instances.
|
|
9
|
-
*/
|
|
10
|
-
export interface IInstanceTracker<T extends Widget> extends IDisposable {
|
|
11
|
-
/**
|
|
12
|
-
* A signal emitted when the current widget changes.
|
|
13
|
-
*
|
|
14
|
-
* #### Notes
|
|
15
|
-
* If the last widget being tracked is disposed, `null` will be emitted.
|
|
16
|
-
*/
|
|
17
|
-
readonly currentChanged: ISignal<this, T | null>;
|
|
18
|
-
/**
|
|
19
|
-
* A signal emitted when a widget is added.
|
|
20
|
-
*
|
|
21
|
-
* #### Notes
|
|
22
|
-
* This signal will only fire when a widget is added to the tracker. It will
|
|
23
|
-
* not fire if a widget is injected into the tracker.
|
|
24
|
-
*/
|
|
25
|
-
readonly widgetAdded: ISignal<this, T>;
|
|
26
|
-
/**
|
|
27
|
-
* The current widget is the most recently focused or added widget.
|
|
28
|
-
*
|
|
29
|
-
* #### Notes
|
|
30
|
-
* It is the most recently focused widget, or the most recently added
|
|
31
|
-
* widget if no widget has taken focus.
|
|
32
|
-
*/
|
|
33
|
-
readonly currentWidget: T | null;
|
|
34
|
-
/**
|
|
35
|
-
* The number of widgets held by the tracker.
|
|
36
|
-
*/
|
|
37
|
-
readonly size: number;
|
|
38
|
-
/**
|
|
39
|
-
* Find the first widget in the tracker that satisfies a filter function.
|
|
40
|
-
*
|
|
41
|
-
* @param - fn The filter function to call on each widget.
|
|
42
|
-
*
|
|
43
|
-
* #### Notes
|
|
44
|
-
* If no widget is found, the value returned is `undefined`.
|
|
45
|
-
*/
|
|
46
|
-
find(fn: (widget: T) => boolean): T | undefined;
|
|
47
|
-
/**
|
|
48
|
-
* Iterate through each widget in the tracker.
|
|
49
|
-
*
|
|
50
|
-
* @param fn - The function to call on each widget.
|
|
51
|
-
*/
|
|
52
|
-
forEach(fn: (widget: T) => void): void;
|
|
53
|
-
/**
|
|
54
|
-
* Filter the widgets in the tracker based on a predicate.
|
|
55
|
-
*
|
|
56
|
-
* @param fn - The function by which to filter.
|
|
57
|
-
*/
|
|
58
|
-
filter(fn: (widget: T) => boolean): T[];
|
|
59
|
-
/**
|
|
60
|
-
* Check if this tracker has the specified widget.
|
|
61
|
-
*
|
|
62
|
-
* @param widget - The widget whose existence is being checked.
|
|
63
|
-
*/
|
|
64
|
-
has(widget: Widget): boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Inject a foreign widget into the instance tracker.
|
|
67
|
-
*
|
|
68
|
-
* @param widget - The widget to inject into the tracker.
|
|
69
|
-
*
|
|
70
|
-
* #### Notes
|
|
71
|
-
* Any widgets injected into an instance tracker will not have their state
|
|
72
|
-
* saved by the tracker. The primary use case for widget injection is for a
|
|
73
|
-
* plugin that offers a sub-class of an extant plugin to have its instances
|
|
74
|
-
* share the same commands as the parent plugin (since most relevant commands
|
|
75
|
-
* will use the `currentWidget` of the parent plugin's instance tracker). In
|
|
76
|
-
* this situation, the sub-class plugin may well have its own instance tracker
|
|
77
|
-
* for layout and state restoration in addition to injecting its widgets into
|
|
78
|
-
* the parent plugin's instance tracker.
|
|
79
|
-
*/
|
|
80
|
-
inject(widget: T): void;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* A class that keeps track of widget instances on an Application shell.
|
|
84
|
-
*
|
|
85
|
-
* #### Notes
|
|
86
|
-
* The API surface area of this concrete implementation is substantially larger
|
|
87
|
-
* than the instance tracker interface it implements. The interface is intended
|
|
88
|
-
* for export by JupyterLab plugins that create widgets and have clients who may
|
|
89
|
-
* wish to keep track of newly created widgets. This class, however, can be used
|
|
90
|
-
* internally by plugins to restore state as well.
|
|
91
|
-
*/
|
|
92
|
-
export declare class InstanceTracker<T extends Widget> implements IInstanceTracker<T>, IDisposable {
|
|
93
|
-
/**
|
|
94
|
-
* Create a new instance tracker.
|
|
95
|
-
*
|
|
96
|
-
* @param options - The instantiation options for an instance tracker.
|
|
97
|
-
*/
|
|
98
|
-
constructor(options: InstanceTracker.IOptions);
|
|
99
|
-
/**
|
|
100
|
-
* A signal emitted when the current widget changes.
|
|
101
|
-
*/
|
|
102
|
-
readonly currentChanged: ISignal<this, T | null>;
|
|
103
|
-
/**
|
|
104
|
-
* A signal emitted when a widget is added.
|
|
105
|
-
*
|
|
106
|
-
* #### Notes
|
|
107
|
-
* This signal will only fire when a widget is added to the tracker. It will
|
|
108
|
-
* not fire if a widget is injected into the tracker.
|
|
109
|
-
*/
|
|
110
|
-
readonly widgetAdded: ISignal<this, T>;
|
|
111
|
-
/**
|
|
112
|
-
* A signal emitted when a widget is updated.
|
|
113
|
-
*/
|
|
114
|
-
readonly widgetUpdated: ISignal<this, T>;
|
|
115
|
-
/**
|
|
116
|
-
* A namespace for all tracked widgets, (e.g., `notebook`).
|
|
117
|
-
*/
|
|
118
|
-
readonly namespace: string;
|
|
119
|
-
/**
|
|
120
|
-
* The current widget is the most recently focused or added widget.
|
|
121
|
-
*
|
|
122
|
-
* #### Notes
|
|
123
|
-
* It is the most recently focused widget, or the most recently added
|
|
124
|
-
* widget if no widget has taken focus.
|
|
125
|
-
*/
|
|
126
|
-
readonly currentWidget: T | null;
|
|
127
|
-
/**
|
|
128
|
-
* The number of widgets held by the tracker.
|
|
129
|
-
*/
|
|
130
|
-
readonly size: number;
|
|
131
|
-
/**
|
|
132
|
-
* Add a new widget to the tracker.
|
|
133
|
-
*
|
|
134
|
-
* @param widget - The widget being added.
|
|
135
|
-
*/
|
|
136
|
-
add(widget: T): Promise<void>;
|
|
137
|
-
/**
|
|
138
|
-
* Test whether the tracker is disposed.
|
|
139
|
-
*/
|
|
140
|
-
readonly isDisposed: boolean;
|
|
141
|
-
/**
|
|
142
|
-
* Dispose of the resources held by the tracker.
|
|
143
|
-
*/
|
|
144
|
-
dispose(): void;
|
|
145
|
-
/**
|
|
146
|
-
* Find the first widget in the tracker that satisfies a filter function.
|
|
147
|
-
*
|
|
148
|
-
* @param - fn The filter function to call on each widget.
|
|
149
|
-
*
|
|
150
|
-
* #### Notes
|
|
151
|
-
* If no widget is found, the value returned is `undefined`.
|
|
152
|
-
*/
|
|
153
|
-
find(fn: (widget: T) => boolean): T | undefined;
|
|
154
|
-
/**
|
|
155
|
-
* Iterate through each widget in the tracker.
|
|
156
|
-
*
|
|
157
|
-
* @param fn - The function to call on each widget.
|
|
158
|
-
*/
|
|
159
|
-
forEach(fn: (widget: T) => void): void;
|
|
160
|
-
/**
|
|
161
|
-
* Filter the widgets in the tracker based on a predicate.
|
|
162
|
-
*
|
|
163
|
-
* @param fn - The function by which to filter.
|
|
164
|
-
*/
|
|
165
|
-
filter(fn: (widget: T) => boolean): T[];
|
|
166
|
-
/**
|
|
167
|
-
* Inject a foreign widget into the instance tracker.
|
|
168
|
-
*
|
|
169
|
-
* @param widget - The widget to inject into the tracker.
|
|
170
|
-
*
|
|
171
|
-
* #### Notes
|
|
172
|
-
* Any widgets injected into an instance tracker will not have their state
|
|
173
|
-
* saved by the tracker. The primary use case for widget injection is for a
|
|
174
|
-
* plugin that offers a sub-class of an extant plugin to have its instances
|
|
175
|
-
* share the same commands as the parent plugin (since most relevant commands
|
|
176
|
-
* will use the `currentWidget` of the parent plugin's instance tracker). In
|
|
177
|
-
* this situation, the sub-class plugin may well have its own instance tracker
|
|
178
|
-
* for layout and state restoration in addition to injecting its widgets into
|
|
179
|
-
* the parent plugin's instance tracker.
|
|
180
|
-
*/
|
|
181
|
-
inject(widget: T): void;
|
|
182
|
-
/**
|
|
183
|
-
* Check if this tracker has the specified widget.
|
|
184
|
-
*
|
|
185
|
-
* @param widget - The widget whose existence is being checked.
|
|
186
|
-
*/
|
|
187
|
-
has(widget: Widget): boolean;
|
|
188
|
-
/**
|
|
189
|
-
* Restore the widgets in this tracker's namespace.
|
|
190
|
-
*
|
|
191
|
-
* @param options - The configuration options that describe restoration.
|
|
192
|
-
*
|
|
193
|
-
* @returns A promise that resolves when restoration has completed.
|
|
194
|
-
*
|
|
195
|
-
* #### Notes
|
|
196
|
-
* This function should almost never be invoked by client code. Its primary
|
|
197
|
-
* use case is to be invoked by a layout restorer plugin that handles
|
|
198
|
-
* multiple instance trackers and, when ready, asks them each to restore their
|
|
199
|
-
* respective widgets.
|
|
200
|
-
*/
|
|
201
|
-
restore(options: InstanceTracker.IRestoreOptions<T>): Promise<any>;
|
|
202
|
-
/**
|
|
203
|
-
* Save the restore data for a given widget.
|
|
204
|
-
*
|
|
205
|
-
* @param widget - The widget being saved.
|
|
206
|
-
*/
|
|
207
|
-
save(widget: T): void;
|
|
208
|
-
/**
|
|
209
|
-
* Handle the current change event.
|
|
210
|
-
*
|
|
211
|
-
* #### Notes
|
|
212
|
-
* The default implementation is a no-op.
|
|
213
|
-
*/
|
|
214
|
-
protected onCurrentChanged(value: T | null): void;
|
|
215
|
-
/**
|
|
216
|
-
* Handle the current change signal from the internal focus tracker.
|
|
217
|
-
*/
|
|
218
|
-
private _onCurrentChanged;
|
|
219
|
-
/**
|
|
220
|
-
* Clean up after disposed widgets.
|
|
221
|
-
*/
|
|
222
|
-
private _onWidgetDisposed;
|
|
223
|
-
private _restore;
|
|
224
|
-
private _tracker;
|
|
225
|
-
private _currentChanged;
|
|
226
|
-
private _widgetAdded;
|
|
227
|
-
private _widgetUpdated;
|
|
228
|
-
private _widgets;
|
|
229
|
-
private _currentWidget;
|
|
230
|
-
private _isDisposed;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* A namespace for `InstanceTracker` statics.
|
|
234
|
-
*/
|
|
235
|
-
export declare namespace InstanceTracker {
|
|
236
|
-
/**
|
|
237
|
-
* The instantiation options for an instance tracker.
|
|
238
|
-
*/
|
|
239
|
-
interface IOptions {
|
|
240
|
-
/**
|
|
241
|
-
* A namespace for all tracked widgets, (e.g., `notebook`).
|
|
242
|
-
*/
|
|
243
|
-
namespace: string;
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* The state restoration configuration options.
|
|
247
|
-
*/
|
|
248
|
-
interface IRestoreOptions<T extends Widget> {
|
|
249
|
-
/**
|
|
250
|
-
* The command to execute when restoring instances.
|
|
251
|
-
*/
|
|
252
|
-
command: string;
|
|
253
|
-
/**
|
|
254
|
-
* A function that returns the args needed to restore an instance.
|
|
255
|
-
*/
|
|
256
|
-
args: (widget: T) => ReadonlyJSONObject;
|
|
257
|
-
/**
|
|
258
|
-
* A function that returns a unique persistent name for this instance.
|
|
259
|
-
*/
|
|
260
|
-
name: (widget: T) => string;
|
|
261
|
-
/**
|
|
262
|
-
* The command registry which holds the restore command.
|
|
263
|
-
*/
|
|
264
|
-
registry: CommandRegistry;
|
|
265
|
-
/**
|
|
266
|
-
* The state database instance.
|
|
267
|
-
*/
|
|
268
|
-
state: IStateDB;
|
|
269
|
-
/**
|
|
270
|
-
* The point after which it is safe to restore state.
|
|
271
|
-
*
|
|
272
|
-
* #### Notes
|
|
273
|
-
* By definition, this promise or promises will happen after the application
|
|
274
|
-
* has `started`.
|
|
275
|
-
*/
|
|
276
|
-
when?: Promise<any> | Array<Promise<any>>;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
1
|
+
import { IStateDB } from '@jupyterlab/coreutils';
|
|
2
|
+
import { CommandRegistry } from '@phosphor/commands';
|
|
3
|
+
import { ReadonlyJSONObject } from '@phosphor/coreutils';
|
|
4
|
+
import { IDisposable } from '@phosphor/disposable';
|
|
5
|
+
import { ISignal } from '@phosphor/signaling';
|
|
6
|
+
import { Widget } from '@phosphor/widgets';
|
|
7
|
+
/**
|
|
8
|
+
* An object that tracks widget instances.
|
|
9
|
+
*/
|
|
10
|
+
export interface IInstanceTracker<T extends Widget> extends IDisposable {
|
|
11
|
+
/**
|
|
12
|
+
* A signal emitted when the current widget changes.
|
|
13
|
+
*
|
|
14
|
+
* #### Notes
|
|
15
|
+
* If the last widget being tracked is disposed, `null` will be emitted.
|
|
16
|
+
*/
|
|
17
|
+
readonly currentChanged: ISignal<this, T | null>;
|
|
18
|
+
/**
|
|
19
|
+
* A signal emitted when a widget is added.
|
|
20
|
+
*
|
|
21
|
+
* #### Notes
|
|
22
|
+
* This signal will only fire when a widget is added to the tracker. It will
|
|
23
|
+
* not fire if a widget is injected into the tracker.
|
|
24
|
+
*/
|
|
25
|
+
readonly widgetAdded: ISignal<this, T>;
|
|
26
|
+
/**
|
|
27
|
+
* The current widget is the most recently focused or added widget.
|
|
28
|
+
*
|
|
29
|
+
* #### Notes
|
|
30
|
+
* It is the most recently focused widget, or the most recently added
|
|
31
|
+
* widget if no widget has taken focus.
|
|
32
|
+
*/
|
|
33
|
+
readonly currentWidget: T | null;
|
|
34
|
+
/**
|
|
35
|
+
* The number of widgets held by the tracker.
|
|
36
|
+
*/
|
|
37
|
+
readonly size: number;
|
|
38
|
+
/**
|
|
39
|
+
* Find the first widget in the tracker that satisfies a filter function.
|
|
40
|
+
*
|
|
41
|
+
* @param - fn The filter function to call on each widget.
|
|
42
|
+
*
|
|
43
|
+
* #### Notes
|
|
44
|
+
* If no widget is found, the value returned is `undefined`.
|
|
45
|
+
*/
|
|
46
|
+
find(fn: (widget: T) => boolean): T | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Iterate through each widget in the tracker.
|
|
49
|
+
*
|
|
50
|
+
* @param fn - The function to call on each widget.
|
|
51
|
+
*/
|
|
52
|
+
forEach(fn: (widget: T) => void): void;
|
|
53
|
+
/**
|
|
54
|
+
* Filter the widgets in the tracker based on a predicate.
|
|
55
|
+
*
|
|
56
|
+
* @param fn - The function by which to filter.
|
|
57
|
+
*/
|
|
58
|
+
filter(fn: (widget: T) => boolean): T[];
|
|
59
|
+
/**
|
|
60
|
+
* Check if this tracker has the specified widget.
|
|
61
|
+
*
|
|
62
|
+
* @param widget - The widget whose existence is being checked.
|
|
63
|
+
*/
|
|
64
|
+
has(widget: Widget): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Inject a foreign widget into the instance tracker.
|
|
67
|
+
*
|
|
68
|
+
* @param widget - The widget to inject into the tracker.
|
|
69
|
+
*
|
|
70
|
+
* #### Notes
|
|
71
|
+
* Any widgets injected into an instance tracker will not have their state
|
|
72
|
+
* saved by the tracker. The primary use case for widget injection is for a
|
|
73
|
+
* plugin that offers a sub-class of an extant plugin to have its instances
|
|
74
|
+
* share the same commands as the parent plugin (since most relevant commands
|
|
75
|
+
* will use the `currentWidget` of the parent plugin's instance tracker). In
|
|
76
|
+
* this situation, the sub-class plugin may well have its own instance tracker
|
|
77
|
+
* for layout and state restoration in addition to injecting its widgets into
|
|
78
|
+
* the parent plugin's instance tracker.
|
|
79
|
+
*/
|
|
80
|
+
inject(widget: T): void;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A class that keeps track of widget instances on an Application shell.
|
|
84
|
+
*
|
|
85
|
+
* #### Notes
|
|
86
|
+
* The API surface area of this concrete implementation is substantially larger
|
|
87
|
+
* than the instance tracker interface it implements. The interface is intended
|
|
88
|
+
* for export by JupyterLab plugins that create widgets and have clients who may
|
|
89
|
+
* wish to keep track of newly created widgets. This class, however, can be used
|
|
90
|
+
* internally by plugins to restore state as well.
|
|
91
|
+
*/
|
|
92
|
+
export declare class InstanceTracker<T extends Widget> implements IInstanceTracker<T>, IDisposable {
|
|
93
|
+
/**
|
|
94
|
+
* Create a new instance tracker.
|
|
95
|
+
*
|
|
96
|
+
* @param options - The instantiation options for an instance tracker.
|
|
97
|
+
*/
|
|
98
|
+
constructor(options: InstanceTracker.IOptions);
|
|
99
|
+
/**
|
|
100
|
+
* A signal emitted when the current widget changes.
|
|
101
|
+
*/
|
|
102
|
+
readonly currentChanged: ISignal<this, T | null>;
|
|
103
|
+
/**
|
|
104
|
+
* A signal emitted when a widget is added.
|
|
105
|
+
*
|
|
106
|
+
* #### Notes
|
|
107
|
+
* This signal will only fire when a widget is added to the tracker. It will
|
|
108
|
+
* not fire if a widget is injected into the tracker.
|
|
109
|
+
*/
|
|
110
|
+
readonly widgetAdded: ISignal<this, T>;
|
|
111
|
+
/**
|
|
112
|
+
* A signal emitted when a widget is updated.
|
|
113
|
+
*/
|
|
114
|
+
readonly widgetUpdated: ISignal<this, T>;
|
|
115
|
+
/**
|
|
116
|
+
* A namespace for all tracked widgets, (e.g., `notebook`).
|
|
117
|
+
*/
|
|
118
|
+
readonly namespace: string;
|
|
119
|
+
/**
|
|
120
|
+
* The current widget is the most recently focused or added widget.
|
|
121
|
+
*
|
|
122
|
+
* #### Notes
|
|
123
|
+
* It is the most recently focused widget, or the most recently added
|
|
124
|
+
* widget if no widget has taken focus.
|
|
125
|
+
*/
|
|
126
|
+
readonly currentWidget: T | null;
|
|
127
|
+
/**
|
|
128
|
+
* The number of widgets held by the tracker.
|
|
129
|
+
*/
|
|
130
|
+
readonly size: number;
|
|
131
|
+
/**
|
|
132
|
+
* Add a new widget to the tracker.
|
|
133
|
+
*
|
|
134
|
+
* @param widget - The widget being added.
|
|
135
|
+
*/
|
|
136
|
+
add(widget: T): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Test whether the tracker is disposed.
|
|
139
|
+
*/
|
|
140
|
+
readonly isDisposed: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Dispose of the resources held by the tracker.
|
|
143
|
+
*/
|
|
144
|
+
dispose(): void;
|
|
145
|
+
/**
|
|
146
|
+
* Find the first widget in the tracker that satisfies a filter function.
|
|
147
|
+
*
|
|
148
|
+
* @param - fn The filter function to call on each widget.
|
|
149
|
+
*
|
|
150
|
+
* #### Notes
|
|
151
|
+
* If no widget is found, the value returned is `undefined`.
|
|
152
|
+
*/
|
|
153
|
+
find(fn: (widget: T) => boolean): T | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* Iterate through each widget in the tracker.
|
|
156
|
+
*
|
|
157
|
+
* @param fn - The function to call on each widget.
|
|
158
|
+
*/
|
|
159
|
+
forEach(fn: (widget: T) => void): void;
|
|
160
|
+
/**
|
|
161
|
+
* Filter the widgets in the tracker based on a predicate.
|
|
162
|
+
*
|
|
163
|
+
* @param fn - The function by which to filter.
|
|
164
|
+
*/
|
|
165
|
+
filter(fn: (widget: T) => boolean): T[];
|
|
166
|
+
/**
|
|
167
|
+
* Inject a foreign widget into the instance tracker.
|
|
168
|
+
*
|
|
169
|
+
* @param widget - The widget to inject into the tracker.
|
|
170
|
+
*
|
|
171
|
+
* #### Notes
|
|
172
|
+
* Any widgets injected into an instance tracker will not have their state
|
|
173
|
+
* saved by the tracker. The primary use case for widget injection is for a
|
|
174
|
+
* plugin that offers a sub-class of an extant plugin to have its instances
|
|
175
|
+
* share the same commands as the parent plugin (since most relevant commands
|
|
176
|
+
* will use the `currentWidget` of the parent plugin's instance tracker). In
|
|
177
|
+
* this situation, the sub-class plugin may well have its own instance tracker
|
|
178
|
+
* for layout and state restoration in addition to injecting its widgets into
|
|
179
|
+
* the parent plugin's instance tracker.
|
|
180
|
+
*/
|
|
181
|
+
inject(widget: T): void;
|
|
182
|
+
/**
|
|
183
|
+
* Check if this tracker has the specified widget.
|
|
184
|
+
*
|
|
185
|
+
* @param widget - The widget whose existence is being checked.
|
|
186
|
+
*/
|
|
187
|
+
has(widget: Widget): boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Restore the widgets in this tracker's namespace.
|
|
190
|
+
*
|
|
191
|
+
* @param options - The configuration options that describe restoration.
|
|
192
|
+
*
|
|
193
|
+
* @returns A promise that resolves when restoration has completed.
|
|
194
|
+
*
|
|
195
|
+
* #### Notes
|
|
196
|
+
* This function should almost never be invoked by client code. Its primary
|
|
197
|
+
* use case is to be invoked by a layout restorer plugin that handles
|
|
198
|
+
* multiple instance trackers and, when ready, asks them each to restore their
|
|
199
|
+
* respective widgets.
|
|
200
|
+
*/
|
|
201
|
+
restore(options: InstanceTracker.IRestoreOptions<T>): Promise<any>;
|
|
202
|
+
/**
|
|
203
|
+
* Save the restore data for a given widget.
|
|
204
|
+
*
|
|
205
|
+
* @param widget - The widget being saved.
|
|
206
|
+
*/
|
|
207
|
+
save(widget: T): void;
|
|
208
|
+
/**
|
|
209
|
+
* Handle the current change event.
|
|
210
|
+
*
|
|
211
|
+
* #### Notes
|
|
212
|
+
* The default implementation is a no-op.
|
|
213
|
+
*/
|
|
214
|
+
protected onCurrentChanged(value: T | null): void;
|
|
215
|
+
/**
|
|
216
|
+
* Handle the current change signal from the internal focus tracker.
|
|
217
|
+
*/
|
|
218
|
+
private _onCurrentChanged;
|
|
219
|
+
/**
|
|
220
|
+
* Clean up after disposed widgets.
|
|
221
|
+
*/
|
|
222
|
+
private _onWidgetDisposed;
|
|
223
|
+
private _restore;
|
|
224
|
+
private _tracker;
|
|
225
|
+
private _currentChanged;
|
|
226
|
+
private _widgetAdded;
|
|
227
|
+
private _widgetUpdated;
|
|
228
|
+
private _widgets;
|
|
229
|
+
private _currentWidget;
|
|
230
|
+
private _isDisposed;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* A namespace for `InstanceTracker` statics.
|
|
234
|
+
*/
|
|
235
|
+
export declare namespace InstanceTracker {
|
|
236
|
+
/**
|
|
237
|
+
* The instantiation options for an instance tracker.
|
|
238
|
+
*/
|
|
239
|
+
interface IOptions {
|
|
240
|
+
/**
|
|
241
|
+
* A namespace for all tracked widgets, (e.g., `notebook`).
|
|
242
|
+
*/
|
|
243
|
+
namespace: string;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* The state restoration configuration options.
|
|
247
|
+
*/
|
|
248
|
+
interface IRestoreOptions<T extends Widget> {
|
|
249
|
+
/**
|
|
250
|
+
* The command to execute when restoring instances.
|
|
251
|
+
*/
|
|
252
|
+
command: string;
|
|
253
|
+
/**
|
|
254
|
+
* A function that returns the args needed to restore an instance.
|
|
255
|
+
*/
|
|
256
|
+
args: (widget: T) => ReadonlyJSONObject;
|
|
257
|
+
/**
|
|
258
|
+
* A function that returns a unique persistent name for this instance.
|
|
259
|
+
*/
|
|
260
|
+
name: (widget: T) => string;
|
|
261
|
+
/**
|
|
262
|
+
* The command registry which holds the restore command.
|
|
263
|
+
*/
|
|
264
|
+
registry: CommandRegistry;
|
|
265
|
+
/**
|
|
266
|
+
* The state database instance.
|
|
267
|
+
*/
|
|
268
|
+
state: IStateDB;
|
|
269
|
+
/**
|
|
270
|
+
* The point after which it is safe to restore state.
|
|
271
|
+
*
|
|
272
|
+
* #### Notes
|
|
273
|
+
* By definition, this promise or promises will happen after the application
|
|
274
|
+
* has `started`.
|
|
275
|
+
*/
|
|
276
|
+
when?: Promise<any> | Array<Promise<any>>;
|
|
277
|
+
}
|
|
278
|
+
}
|