@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/index.js
CHANGED
|
@@ -1,283 +1,283 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Jupyter Development Team.
|
|
3
|
-
// Distributed under the terms of the Modified BSD License.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
// Local CSS must be loaded prior to loading other libs.
|
|
6
|
-
require("../style/index.css");
|
|
7
|
-
const coreutils_1 = require("@jupyterlab/coreutils");
|
|
8
|
-
const apputils_1 = require("@jupyterlab/apputils");
|
|
9
|
-
const docregistry_1 = require("@jupyterlab/docregistry");
|
|
10
|
-
const services_1 = require("@jupyterlab/services");
|
|
11
|
-
const application_1 = require("@phosphor/application");
|
|
12
|
-
const disposable_1 = require("@phosphor/disposable");
|
|
13
|
-
const mimerenderers_1 = require("./mimerenderers");
|
|
14
|
-
const shell_1 = require("./shell");
|
|
15
|
-
const signaling_1 = require("@phosphor/signaling");
|
|
16
|
-
var layoutrestorer_1 = require("./layoutrestorer");
|
|
17
|
-
exports.ILayoutRestorer = layoutrestorer_1.ILayoutRestorer;
|
|
18
|
-
exports.LayoutRestorer = layoutrestorer_1.LayoutRestorer;
|
|
19
|
-
var mimerenderers_2 = require("./mimerenderers");
|
|
20
|
-
exports.IMimeDocumentTracker = mimerenderers_2.IMimeDocumentTracker;
|
|
21
|
-
var router_1 = require("./router");
|
|
22
|
-
exports.IRouter = router_1.IRouter;
|
|
23
|
-
exports.Router = router_1.Router;
|
|
24
|
-
var shell_2 = require("./shell");
|
|
25
|
-
exports.ApplicationShell = shell_2.ApplicationShell;
|
|
26
|
-
/**
|
|
27
|
-
* JupyterLab is the main application class. It is instantiated once and shared.
|
|
28
|
-
*/
|
|
29
|
-
class JupyterLab extends application_1.Application {
|
|
30
|
-
/**
|
|
31
|
-
* Construct a new JupyterLab object.
|
|
32
|
-
*/
|
|
33
|
-
constructor(options = {}) {
|
|
34
|
-
super({ shell: new shell_1.ApplicationShell() });
|
|
35
|
-
/**
|
|
36
|
-
* A list of all errors encountered when registering plugins.
|
|
37
|
-
*/
|
|
38
|
-
this.registerPluginErrors = [];
|
|
39
|
-
this._dirtyCount = 0;
|
|
40
|
-
this._busyCount = 0;
|
|
41
|
-
this._busySignal = new signaling_1.Signal(this);
|
|
42
|
-
this._dirtySignal = new signaling_1.Signal(this);
|
|
43
|
-
// Construct the default workspace name.
|
|
44
|
-
const defaultWorkspace = coreutils_1.URLExt.join(coreutils_1.PageConfig.getOption('baseUrl'), coreutils_1.PageConfig.getOption('pageUrl'));
|
|
45
|
-
// Set default workspace in page config.
|
|
46
|
-
coreutils_1.PageConfig.setOption('defaultWorkspace', defaultWorkspace);
|
|
47
|
-
// Instantiate public resources.
|
|
48
|
-
this.serviceManager = options.serviceManager || new services_1.ServiceManager();
|
|
49
|
-
this.commandLinker =
|
|
50
|
-
options.commandLinker || new apputils_1.CommandLinker({ commands: this.commands });
|
|
51
|
-
this.docRegistry = options.docRegistry || new docregistry_1.DocumentRegistry();
|
|
52
|
-
// Remove extra resources (non-IInfo) from options object.
|
|
53
|
-
delete options.serviceManager;
|
|
54
|
-
delete options.commandLinker;
|
|
55
|
-
delete options.docRegistry;
|
|
56
|
-
// Populate application info.
|
|
57
|
-
this._info = Object.assign({}, JupyterLab.defaultInfo, options, { defaultWorkspace });
|
|
58
|
-
if (this._info.devMode) {
|
|
59
|
-
this.shell.addClass('jp-mod-devMode');
|
|
60
|
-
}
|
|
61
|
-
// Make workspace accessible via a getter because it is set at runtime.
|
|
62
|
-
Object.defineProperty(this._info, 'workspace', {
|
|
63
|
-
get: () => coreutils_1.PageConfig.getOption('workspace') || ''
|
|
64
|
-
});
|
|
65
|
-
// Add initial model factory.
|
|
66
|
-
this.docRegistry.addModelFactory(new docregistry_1.Base64ModelFactory());
|
|
67
|
-
if (options.mimeExtensions) {
|
|
68
|
-
for (let plugin of mimerenderers_1.createRendermimePlugins(options.mimeExtensions)) {
|
|
69
|
-
this.registerPlugin(plugin);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* A method invoked on a document `'contextmenu'` event.
|
|
75
|
-
*
|
|
76
|
-
* #### Notes
|
|
77
|
-
* The default implementation of this method opens the application
|
|
78
|
-
* `contextMenu` at the current mouse position.
|
|
79
|
-
*
|
|
80
|
-
* If the application context menu has no matching content *or* if
|
|
81
|
-
* the shift key is pressed, the default browser context menu will
|
|
82
|
-
* be opened instead.
|
|
83
|
-
*
|
|
84
|
-
* A subclass may reimplement this method as needed.
|
|
85
|
-
*/
|
|
86
|
-
evtContextMenu(event) {
|
|
87
|
-
if (event.shiftKey) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
this._contextMenuEvent = event;
|
|
91
|
-
if (this.contextMenu.open(event)) {
|
|
92
|
-
event.preventDefault();
|
|
93
|
-
event.stopPropagation();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Whether the application is dirty.
|
|
98
|
-
*/
|
|
99
|
-
get isDirty() {
|
|
100
|
-
return this._dirtyCount > 0;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Whether the application is busy.
|
|
104
|
-
*/
|
|
105
|
-
get isBusy() {
|
|
106
|
-
return this._busyCount > 0;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Returns a signal for when application changes its busy status.
|
|
110
|
-
*/
|
|
111
|
-
get busySignal() {
|
|
112
|
-
return this._busySignal;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Returns a signal for when application changes its dirty status.
|
|
116
|
-
*/
|
|
117
|
-
get dirtySignal() {
|
|
118
|
-
return this._dirtySignal;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* The information about the application.
|
|
122
|
-
*/
|
|
123
|
-
get info() {
|
|
124
|
-
return this._info;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Promise that resolves when state is first restored, returning layout description.
|
|
128
|
-
*
|
|
129
|
-
* #### Notes
|
|
130
|
-
* This is just a reference to `shell.restored`.
|
|
131
|
-
*/
|
|
132
|
-
get restored() {
|
|
133
|
-
return this.shell.restored;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Walks up the DOM hierarchy of the target of the active `contextmenu`
|
|
137
|
-
* event, testing the nodes for a user-supplied funcion. This can
|
|
138
|
-
* be used to find a node on which to operate, given a context menu click.
|
|
139
|
-
*
|
|
140
|
-
* @param test - a function that takes an `HTMLElement` and returns a
|
|
141
|
-
* boolean for whether it is the element the requester is seeking.
|
|
142
|
-
*
|
|
143
|
-
* @returns an HTMLElement or undefined, if none is found.
|
|
144
|
-
*/
|
|
145
|
-
contextMenuFirst(test) {
|
|
146
|
-
for (let node of this._getContextMenuNodes()) {
|
|
147
|
-
if (test(node)) {
|
|
148
|
-
return node;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return undefined;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Set the application state to dirty.
|
|
155
|
-
*
|
|
156
|
-
* @returns A disposable used to clear the dirty state for the caller.
|
|
157
|
-
*/
|
|
158
|
-
setDirty() {
|
|
159
|
-
const oldDirty = this.isDirty;
|
|
160
|
-
this._dirtyCount++;
|
|
161
|
-
if (this.isDirty !== oldDirty) {
|
|
162
|
-
this._dirtySignal.emit(this.isDirty);
|
|
163
|
-
}
|
|
164
|
-
return new disposable_1.DisposableDelegate(() => {
|
|
165
|
-
const oldDirty = this.isDirty;
|
|
166
|
-
this._dirtyCount = Math.max(0, this._dirtyCount - 1);
|
|
167
|
-
if (this.isDirty !== oldDirty) {
|
|
168
|
-
this._dirtySignal.emit(this.isDirty);
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Set the application state to busy.
|
|
174
|
-
*
|
|
175
|
-
* @returns A disposable used to clear the busy state for the caller.
|
|
176
|
-
*/
|
|
177
|
-
setBusy() {
|
|
178
|
-
const oldBusy = this.isBusy;
|
|
179
|
-
this._busyCount++;
|
|
180
|
-
if (this.isBusy !== oldBusy) {
|
|
181
|
-
this._busySignal.emit(this.isBusy);
|
|
182
|
-
}
|
|
183
|
-
return new disposable_1.DisposableDelegate(() => {
|
|
184
|
-
const oldBusy = this.isBusy;
|
|
185
|
-
this._busyCount--;
|
|
186
|
-
if (this.isBusy !== oldBusy) {
|
|
187
|
-
this._busySignal.emit(this.isBusy);
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Register plugins from a plugin module.
|
|
193
|
-
*
|
|
194
|
-
* @param mod - The plugin module to register.
|
|
195
|
-
*/
|
|
196
|
-
registerPluginModule(mod) {
|
|
197
|
-
let data = mod.default;
|
|
198
|
-
// Handle commonjs exports.
|
|
199
|
-
if (!mod.hasOwnProperty('__esModule')) {
|
|
200
|
-
data = mod;
|
|
201
|
-
}
|
|
202
|
-
if (!Array.isArray(data)) {
|
|
203
|
-
data = [data];
|
|
204
|
-
}
|
|
205
|
-
data.forEach(item => {
|
|
206
|
-
try {
|
|
207
|
-
this.registerPlugin(item);
|
|
208
|
-
}
|
|
209
|
-
catch (error) {
|
|
210
|
-
this.registerPluginErrors.push(error);
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Register the plugins from multiple plugin modules.
|
|
216
|
-
*
|
|
217
|
-
* @param mods - The plugin modules to register.
|
|
218
|
-
*/
|
|
219
|
-
registerPluginModules(mods) {
|
|
220
|
-
mods.forEach(mod => {
|
|
221
|
-
this.registerPluginModule(mod);
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Gets the hierarchy of html nodes that was under the cursor
|
|
226
|
-
* when the most recent contextmenu event was issued
|
|
227
|
-
*/
|
|
228
|
-
_getContextMenuNodes() {
|
|
229
|
-
if (!this._contextMenuEvent) {
|
|
230
|
-
return [];
|
|
231
|
-
}
|
|
232
|
-
// this one-liner doesn't work, but should at some point
|
|
233
|
-
// in the future (https://developer.mozilla.org/en-US/docs/Web/API/Event)
|
|
234
|
-
// return this._contextMenuEvent.composedPath() as HTMLElement[];
|
|
235
|
-
let nodes = [this._contextMenuEvent.target];
|
|
236
|
-
while ('parentNode' in nodes[nodes.length - 1] &&
|
|
237
|
-
nodes[nodes.length - 1].parentNode &&
|
|
238
|
-
nodes[nodes.length - 1] !== nodes[nodes.length - 1].parentNode) {
|
|
239
|
-
nodes.push(nodes[nodes.length - 1].parentNode);
|
|
240
|
-
}
|
|
241
|
-
return nodes;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
exports.JupyterLab = JupyterLab;
|
|
245
|
-
/**
|
|
246
|
-
* The namespace for `JupyterLab` class statics.
|
|
247
|
-
*/
|
|
248
|
-
(function (JupyterLab) {
|
|
249
|
-
/**
|
|
250
|
-
* The default application info.
|
|
251
|
-
*/
|
|
252
|
-
JupyterLab.defaultInfo = {
|
|
253
|
-
name: coreutils_1.PageConfig.getOption('appName') || 'JupyterLab',
|
|
254
|
-
namespace: coreutils_1.PageConfig.getOption('appNamespace'),
|
|
255
|
-
version: coreutils_1.PageConfig.getOption('appVersion') || 'unknown',
|
|
256
|
-
devMode: coreutils_1.PageConfig.getOption('devMode').toLowerCase() === 'true',
|
|
257
|
-
deferred: { patterns: [], matches: [] },
|
|
258
|
-
disabled: { patterns: [], matches: [] },
|
|
259
|
-
mimeExtensions: [],
|
|
260
|
-
urls: {
|
|
261
|
-
base: coreutils_1.PageConfig.getOption('baseUrl'),
|
|
262
|
-
page: coreutils_1.PageConfig.getOption('pageUrl'),
|
|
263
|
-
public: coreutils_1.PageConfig.getOption('publicUrl'),
|
|
264
|
-
settings: coreutils_1.PageConfig.getOption('settingsUrl'),
|
|
265
|
-
themes: coreutils_1.PageConfig.getOption('themesUrl'),
|
|
266
|
-
tree: coreutils_1.PageConfig.getOption('treeUrl'),
|
|
267
|
-
workspaces: coreutils_1.PageConfig.getOption('workspacesUrl')
|
|
268
|
-
},
|
|
269
|
-
directories: {
|
|
270
|
-
appSettings: coreutils_1.PageConfig.getOption('appSettingsDir'),
|
|
271
|
-
schemas: coreutils_1.PageConfig.getOption('schemasDir'),
|
|
272
|
-
static: coreutils_1.PageConfig.getOption('staticDir'),
|
|
273
|
-
templates: coreutils_1.PageConfig.getOption('templatesDir'),
|
|
274
|
-
themes: coreutils_1.PageConfig.getOption('themesDir'),
|
|
275
|
-
userSettings: coreutils_1.PageConfig.getOption('userSettingsDir'),
|
|
276
|
-
serverRoot: coreutils_1.PageConfig.getOption('serverRoot'),
|
|
277
|
-
workspaces: coreutils_1.PageConfig.getOption('workspacesDir')
|
|
278
|
-
},
|
|
279
|
-
filesCached: coreutils_1.PageConfig.getOption('cacheFiles').toLowerCase() === 'true',
|
|
280
|
-
workspace: '',
|
|
281
|
-
defaultWorkspace: ''
|
|
282
|
-
};
|
|
283
|
-
})(JupyterLab = exports.JupyterLab || (exports.JupyterLab = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Jupyter Development Team.
|
|
3
|
+
// Distributed under the terms of the Modified BSD License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
// Local CSS must be loaded prior to loading other libs.
|
|
6
|
+
require("../style/index.css");
|
|
7
|
+
const coreutils_1 = require("@jupyterlab/coreutils");
|
|
8
|
+
const apputils_1 = require("@jupyterlab/apputils");
|
|
9
|
+
const docregistry_1 = require("@jupyterlab/docregistry");
|
|
10
|
+
const services_1 = require("@jupyterlab/services");
|
|
11
|
+
const application_1 = require("@phosphor/application");
|
|
12
|
+
const disposable_1 = require("@phosphor/disposable");
|
|
13
|
+
const mimerenderers_1 = require("./mimerenderers");
|
|
14
|
+
const shell_1 = require("./shell");
|
|
15
|
+
const signaling_1 = require("@phosphor/signaling");
|
|
16
|
+
var layoutrestorer_1 = require("./layoutrestorer");
|
|
17
|
+
exports.ILayoutRestorer = layoutrestorer_1.ILayoutRestorer;
|
|
18
|
+
exports.LayoutRestorer = layoutrestorer_1.LayoutRestorer;
|
|
19
|
+
var mimerenderers_2 = require("./mimerenderers");
|
|
20
|
+
exports.IMimeDocumentTracker = mimerenderers_2.IMimeDocumentTracker;
|
|
21
|
+
var router_1 = require("./router");
|
|
22
|
+
exports.IRouter = router_1.IRouter;
|
|
23
|
+
exports.Router = router_1.Router;
|
|
24
|
+
var shell_2 = require("./shell");
|
|
25
|
+
exports.ApplicationShell = shell_2.ApplicationShell;
|
|
26
|
+
/**
|
|
27
|
+
* JupyterLab is the main application class. It is instantiated once and shared.
|
|
28
|
+
*/
|
|
29
|
+
class JupyterLab extends application_1.Application {
|
|
30
|
+
/**
|
|
31
|
+
* Construct a new JupyterLab object.
|
|
32
|
+
*/
|
|
33
|
+
constructor(options = {}) {
|
|
34
|
+
super({ shell: new shell_1.ApplicationShell() });
|
|
35
|
+
/**
|
|
36
|
+
* A list of all errors encountered when registering plugins.
|
|
37
|
+
*/
|
|
38
|
+
this.registerPluginErrors = [];
|
|
39
|
+
this._dirtyCount = 0;
|
|
40
|
+
this._busyCount = 0;
|
|
41
|
+
this._busySignal = new signaling_1.Signal(this);
|
|
42
|
+
this._dirtySignal = new signaling_1.Signal(this);
|
|
43
|
+
// Construct the default workspace name.
|
|
44
|
+
const defaultWorkspace = coreutils_1.URLExt.join(coreutils_1.PageConfig.getOption('baseUrl'), coreutils_1.PageConfig.getOption('pageUrl'));
|
|
45
|
+
// Set default workspace in page config.
|
|
46
|
+
coreutils_1.PageConfig.setOption('defaultWorkspace', defaultWorkspace);
|
|
47
|
+
// Instantiate public resources.
|
|
48
|
+
this.serviceManager = options.serviceManager || new services_1.ServiceManager();
|
|
49
|
+
this.commandLinker =
|
|
50
|
+
options.commandLinker || new apputils_1.CommandLinker({ commands: this.commands });
|
|
51
|
+
this.docRegistry = options.docRegistry || new docregistry_1.DocumentRegistry();
|
|
52
|
+
// Remove extra resources (non-IInfo) from options object.
|
|
53
|
+
delete options.serviceManager;
|
|
54
|
+
delete options.commandLinker;
|
|
55
|
+
delete options.docRegistry;
|
|
56
|
+
// Populate application info.
|
|
57
|
+
this._info = Object.assign({}, JupyterLab.defaultInfo, options, { defaultWorkspace });
|
|
58
|
+
if (this._info.devMode) {
|
|
59
|
+
this.shell.addClass('jp-mod-devMode');
|
|
60
|
+
}
|
|
61
|
+
// Make workspace accessible via a getter because it is set at runtime.
|
|
62
|
+
Object.defineProperty(this._info, 'workspace', {
|
|
63
|
+
get: () => coreutils_1.PageConfig.getOption('workspace') || ''
|
|
64
|
+
});
|
|
65
|
+
// Add initial model factory.
|
|
66
|
+
this.docRegistry.addModelFactory(new docregistry_1.Base64ModelFactory());
|
|
67
|
+
if (options.mimeExtensions) {
|
|
68
|
+
for (let plugin of mimerenderers_1.createRendermimePlugins(options.mimeExtensions)) {
|
|
69
|
+
this.registerPlugin(plugin);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A method invoked on a document `'contextmenu'` event.
|
|
75
|
+
*
|
|
76
|
+
* #### Notes
|
|
77
|
+
* The default implementation of this method opens the application
|
|
78
|
+
* `contextMenu` at the current mouse position.
|
|
79
|
+
*
|
|
80
|
+
* If the application context menu has no matching content *or* if
|
|
81
|
+
* the shift key is pressed, the default browser context menu will
|
|
82
|
+
* be opened instead.
|
|
83
|
+
*
|
|
84
|
+
* A subclass may reimplement this method as needed.
|
|
85
|
+
*/
|
|
86
|
+
evtContextMenu(event) {
|
|
87
|
+
if (event.shiftKey) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
this._contextMenuEvent = event;
|
|
91
|
+
if (this.contextMenu.open(event)) {
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
event.stopPropagation();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Whether the application is dirty.
|
|
98
|
+
*/
|
|
99
|
+
get isDirty() {
|
|
100
|
+
return this._dirtyCount > 0;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Whether the application is busy.
|
|
104
|
+
*/
|
|
105
|
+
get isBusy() {
|
|
106
|
+
return this._busyCount > 0;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Returns a signal for when application changes its busy status.
|
|
110
|
+
*/
|
|
111
|
+
get busySignal() {
|
|
112
|
+
return this._busySignal;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Returns a signal for when application changes its dirty status.
|
|
116
|
+
*/
|
|
117
|
+
get dirtySignal() {
|
|
118
|
+
return this._dirtySignal;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The information about the application.
|
|
122
|
+
*/
|
|
123
|
+
get info() {
|
|
124
|
+
return this._info;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Promise that resolves when state is first restored, returning layout description.
|
|
128
|
+
*
|
|
129
|
+
* #### Notes
|
|
130
|
+
* This is just a reference to `shell.restored`.
|
|
131
|
+
*/
|
|
132
|
+
get restored() {
|
|
133
|
+
return this.shell.restored;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Walks up the DOM hierarchy of the target of the active `contextmenu`
|
|
137
|
+
* event, testing the nodes for a user-supplied funcion. This can
|
|
138
|
+
* be used to find a node on which to operate, given a context menu click.
|
|
139
|
+
*
|
|
140
|
+
* @param test - a function that takes an `HTMLElement` and returns a
|
|
141
|
+
* boolean for whether it is the element the requester is seeking.
|
|
142
|
+
*
|
|
143
|
+
* @returns an HTMLElement or undefined, if none is found.
|
|
144
|
+
*/
|
|
145
|
+
contextMenuFirst(test) {
|
|
146
|
+
for (let node of this._getContextMenuNodes()) {
|
|
147
|
+
if (test(node)) {
|
|
148
|
+
return node;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Set the application state to dirty.
|
|
155
|
+
*
|
|
156
|
+
* @returns A disposable used to clear the dirty state for the caller.
|
|
157
|
+
*/
|
|
158
|
+
setDirty() {
|
|
159
|
+
const oldDirty = this.isDirty;
|
|
160
|
+
this._dirtyCount++;
|
|
161
|
+
if (this.isDirty !== oldDirty) {
|
|
162
|
+
this._dirtySignal.emit(this.isDirty);
|
|
163
|
+
}
|
|
164
|
+
return new disposable_1.DisposableDelegate(() => {
|
|
165
|
+
const oldDirty = this.isDirty;
|
|
166
|
+
this._dirtyCount = Math.max(0, this._dirtyCount - 1);
|
|
167
|
+
if (this.isDirty !== oldDirty) {
|
|
168
|
+
this._dirtySignal.emit(this.isDirty);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Set the application state to busy.
|
|
174
|
+
*
|
|
175
|
+
* @returns A disposable used to clear the busy state for the caller.
|
|
176
|
+
*/
|
|
177
|
+
setBusy() {
|
|
178
|
+
const oldBusy = this.isBusy;
|
|
179
|
+
this._busyCount++;
|
|
180
|
+
if (this.isBusy !== oldBusy) {
|
|
181
|
+
this._busySignal.emit(this.isBusy);
|
|
182
|
+
}
|
|
183
|
+
return new disposable_1.DisposableDelegate(() => {
|
|
184
|
+
const oldBusy = this.isBusy;
|
|
185
|
+
this._busyCount--;
|
|
186
|
+
if (this.isBusy !== oldBusy) {
|
|
187
|
+
this._busySignal.emit(this.isBusy);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Register plugins from a plugin module.
|
|
193
|
+
*
|
|
194
|
+
* @param mod - The plugin module to register.
|
|
195
|
+
*/
|
|
196
|
+
registerPluginModule(mod) {
|
|
197
|
+
let data = mod.default;
|
|
198
|
+
// Handle commonjs exports.
|
|
199
|
+
if (!mod.hasOwnProperty('__esModule')) {
|
|
200
|
+
data = mod;
|
|
201
|
+
}
|
|
202
|
+
if (!Array.isArray(data)) {
|
|
203
|
+
data = [data];
|
|
204
|
+
}
|
|
205
|
+
data.forEach(item => {
|
|
206
|
+
try {
|
|
207
|
+
this.registerPlugin(item);
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
this.registerPluginErrors.push(error);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Register the plugins from multiple plugin modules.
|
|
216
|
+
*
|
|
217
|
+
* @param mods - The plugin modules to register.
|
|
218
|
+
*/
|
|
219
|
+
registerPluginModules(mods) {
|
|
220
|
+
mods.forEach(mod => {
|
|
221
|
+
this.registerPluginModule(mod);
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Gets the hierarchy of html nodes that was under the cursor
|
|
226
|
+
* when the most recent contextmenu event was issued
|
|
227
|
+
*/
|
|
228
|
+
_getContextMenuNodes() {
|
|
229
|
+
if (!this._contextMenuEvent) {
|
|
230
|
+
return [];
|
|
231
|
+
}
|
|
232
|
+
// this one-liner doesn't work, but should at some point
|
|
233
|
+
// in the future (https://developer.mozilla.org/en-US/docs/Web/API/Event)
|
|
234
|
+
// return this._contextMenuEvent.composedPath() as HTMLElement[];
|
|
235
|
+
let nodes = [this._contextMenuEvent.target];
|
|
236
|
+
while ('parentNode' in nodes[nodes.length - 1] &&
|
|
237
|
+
nodes[nodes.length - 1].parentNode &&
|
|
238
|
+
nodes[nodes.length - 1] !== nodes[nodes.length - 1].parentNode) {
|
|
239
|
+
nodes.push(nodes[nodes.length - 1].parentNode);
|
|
240
|
+
}
|
|
241
|
+
return nodes;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
exports.JupyterLab = JupyterLab;
|
|
245
|
+
/**
|
|
246
|
+
* The namespace for `JupyterLab` class statics.
|
|
247
|
+
*/
|
|
248
|
+
(function (JupyterLab) {
|
|
249
|
+
/**
|
|
250
|
+
* The default application info.
|
|
251
|
+
*/
|
|
252
|
+
JupyterLab.defaultInfo = {
|
|
253
|
+
name: coreutils_1.PageConfig.getOption('appName') || 'JupyterLab',
|
|
254
|
+
namespace: coreutils_1.PageConfig.getOption('appNamespace'),
|
|
255
|
+
version: coreutils_1.PageConfig.getOption('appVersion') || 'unknown',
|
|
256
|
+
devMode: coreutils_1.PageConfig.getOption('devMode').toLowerCase() === 'true',
|
|
257
|
+
deferred: { patterns: [], matches: [] },
|
|
258
|
+
disabled: { patterns: [], matches: [] },
|
|
259
|
+
mimeExtensions: [],
|
|
260
|
+
urls: {
|
|
261
|
+
base: coreutils_1.PageConfig.getOption('baseUrl'),
|
|
262
|
+
page: coreutils_1.PageConfig.getOption('pageUrl'),
|
|
263
|
+
public: coreutils_1.PageConfig.getOption('publicUrl'),
|
|
264
|
+
settings: coreutils_1.PageConfig.getOption('settingsUrl'),
|
|
265
|
+
themes: coreutils_1.PageConfig.getOption('themesUrl'),
|
|
266
|
+
tree: coreutils_1.PageConfig.getOption('treeUrl'),
|
|
267
|
+
workspaces: coreutils_1.PageConfig.getOption('workspacesUrl')
|
|
268
|
+
},
|
|
269
|
+
directories: {
|
|
270
|
+
appSettings: coreutils_1.PageConfig.getOption('appSettingsDir'),
|
|
271
|
+
schemas: coreutils_1.PageConfig.getOption('schemasDir'),
|
|
272
|
+
static: coreutils_1.PageConfig.getOption('staticDir'),
|
|
273
|
+
templates: coreutils_1.PageConfig.getOption('templatesDir'),
|
|
274
|
+
themes: coreutils_1.PageConfig.getOption('themesDir'),
|
|
275
|
+
userSettings: coreutils_1.PageConfig.getOption('userSettingsDir'),
|
|
276
|
+
serverRoot: coreutils_1.PageConfig.getOption('serverRoot'),
|
|
277
|
+
workspaces: coreutils_1.PageConfig.getOption('workspacesDir')
|
|
278
|
+
},
|
|
279
|
+
filesCached: coreutils_1.PageConfig.getOption('cacheFiles').toLowerCase() === 'true',
|
|
280
|
+
workspace: '',
|
|
281
|
+
defaultWorkspace: ''
|
|
282
|
+
};
|
|
283
|
+
})(JupyterLab = exports.JupyterLab || (exports.JupyterLab = {}));
|