@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/windowresolver.js
CHANGED
|
@@ -1,173 +1,173 @@
|
|
|
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
|
-
const coreutils_1 = require("@phosphor/coreutils");
|
|
6
|
-
/* tslint:disable */
|
|
7
|
-
/**
|
|
8
|
-
* The default window resolver token.
|
|
9
|
-
*/
|
|
10
|
-
exports.IWindowResolver = new coreutils_1.Token('@jupyterlab/apputils:IWindowResolver');
|
|
11
|
-
/**
|
|
12
|
-
* A concrete implementation of a window name resolver.
|
|
13
|
-
*/
|
|
14
|
-
class WindowResolver {
|
|
15
|
-
constructor() {
|
|
16
|
-
this._name = null;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* The resolved window name.
|
|
20
|
-
*/
|
|
21
|
-
get name() {
|
|
22
|
-
return this._name;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Resolve a window name to use as a handle among shared resources.
|
|
26
|
-
*
|
|
27
|
-
* @param candidate - The potential window name being resolved.
|
|
28
|
-
*
|
|
29
|
-
* #### Notes
|
|
30
|
-
* Typically, the name candidate should be a JupyterLab workspace name or
|
|
31
|
-
* an empty string if there is no workspace.
|
|
32
|
-
*
|
|
33
|
-
* If the returned promise rejects, a window name cannot be resolved without
|
|
34
|
-
* user intervention, which typically means navigation to a new URL.
|
|
35
|
-
*/
|
|
36
|
-
resolve(candidate) {
|
|
37
|
-
return Private.resolve(candidate).then(name => {
|
|
38
|
-
this._name = name;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.WindowResolver = WindowResolver;
|
|
43
|
-
/*
|
|
44
|
-
* A namespace for private module data.
|
|
45
|
-
*/
|
|
46
|
-
var Private;
|
|
47
|
-
(function (Private) {
|
|
48
|
-
/**
|
|
49
|
-
* The internal prefix for private local storage keys.
|
|
50
|
-
*/
|
|
51
|
-
const PREFIX = '@jupyterlab/coreutils:StateDB';
|
|
52
|
-
/**
|
|
53
|
-
* The local storage beacon key.
|
|
54
|
-
*/
|
|
55
|
-
const BEACON = `${PREFIX}:beacon`;
|
|
56
|
-
/**
|
|
57
|
-
* The timeout (in ms) to wait for beacon responders.
|
|
58
|
-
*
|
|
59
|
-
* #### Notes
|
|
60
|
-
* This value is a whole number between 200 and 500 in order to prevent
|
|
61
|
-
* perfect timeout collisions between multiple simultaneously opening windows
|
|
62
|
-
* that have the same URL. This is an edge case because multiple windows
|
|
63
|
-
* should not ordinarily share the same URL, but it can be contrived.
|
|
64
|
-
*/
|
|
65
|
-
const TIMEOUT = Math.floor(200 + Math.random() * 300);
|
|
66
|
-
/**
|
|
67
|
-
* The local storage window key.
|
|
68
|
-
*/
|
|
69
|
-
const WINDOW = `${PREFIX}:window`;
|
|
70
|
-
/**
|
|
71
|
-
* A potential preferred default window name.
|
|
72
|
-
*/
|
|
73
|
-
let candidate = null;
|
|
74
|
-
/**
|
|
75
|
-
* The window name promise.
|
|
76
|
-
*/
|
|
77
|
-
let delegate = new coreutils_1.PromiseDelegate();
|
|
78
|
-
/**
|
|
79
|
-
* The known window names.
|
|
80
|
-
*/
|
|
81
|
-
let known = {};
|
|
82
|
-
/**
|
|
83
|
-
* The window name.
|
|
84
|
-
*/
|
|
85
|
-
let name = null;
|
|
86
|
-
/**
|
|
87
|
-
* Whether the name resolution has completed.
|
|
88
|
-
*/
|
|
89
|
-
let resolved = false;
|
|
90
|
-
/**
|
|
91
|
-
* Start the storage event handler.
|
|
92
|
-
*/
|
|
93
|
-
function initialize() {
|
|
94
|
-
// Listen to all storage events for beacons and window names.
|
|
95
|
-
window.addEventListener('storage', (event) => {
|
|
96
|
-
const { key, newValue } = event;
|
|
97
|
-
// All the keys we care about have values.
|
|
98
|
-
if (newValue === null) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
// If the beacon was fired, respond with a ping.
|
|
102
|
-
if (key === BEACON && candidate !== null) {
|
|
103
|
-
ping(resolved ? name : candidate);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
// If the window name is resolved, bail.
|
|
107
|
-
if (resolved || key !== WINDOW) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const reported = newValue.replace(/\-\d+$/, '');
|
|
111
|
-
// Store the reported window name.
|
|
112
|
-
known[reported] = null;
|
|
113
|
-
// If a reported window name and candidate collide, reject the candidate.
|
|
114
|
-
if (candidate in known) {
|
|
115
|
-
reject();
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Ping peers with payload.
|
|
121
|
-
*/
|
|
122
|
-
function ping(payload) {
|
|
123
|
-
if (payload === null) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const { localStorage } = window;
|
|
127
|
-
localStorage.setItem(WINDOW, `${payload}-${new Date().getTime()}`);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Reject the candidate.
|
|
131
|
-
*/
|
|
132
|
-
function reject() {
|
|
133
|
-
resolved = true;
|
|
134
|
-
delegate.reject(`Window name candidate "${candidate}" already exists`);
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Returns a promise that resolves with the window name used for restoration.
|
|
138
|
-
*/
|
|
139
|
-
function resolve(potential) {
|
|
140
|
-
if (resolved) {
|
|
141
|
-
return delegate.promise;
|
|
142
|
-
}
|
|
143
|
-
// Set the local candidate.
|
|
144
|
-
candidate = potential;
|
|
145
|
-
if (candidate in known) {
|
|
146
|
-
reject();
|
|
147
|
-
return delegate.promise;
|
|
148
|
-
}
|
|
149
|
-
const { localStorage, setTimeout } = window;
|
|
150
|
-
// Wait until other windows have reported before claiming the candidate.
|
|
151
|
-
setTimeout(() => {
|
|
152
|
-
if (resolved) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
// If the window name has not already been resolved, check one last time
|
|
156
|
-
// to confirm it is not a duplicate before resolving.
|
|
157
|
-
if (candidate in known) {
|
|
158
|
-
return reject();
|
|
159
|
-
}
|
|
160
|
-
resolved = true;
|
|
161
|
-
delegate.resolve((name = candidate));
|
|
162
|
-
ping(name);
|
|
163
|
-
}, TIMEOUT);
|
|
164
|
-
// Fire the beacon to collect other windows' names.
|
|
165
|
-
localStorage.setItem(BEACON, `${Math.random()}-${new Date().getTime()}`);
|
|
166
|
-
return delegate.promise;
|
|
167
|
-
}
|
|
168
|
-
Private.resolve = resolve;
|
|
169
|
-
// Initialize the storage listener at runtime.
|
|
170
|
-
(() => {
|
|
171
|
-
initialize();
|
|
172
|
-
})();
|
|
173
|
-
})(Private || (Private = {}));
|
|
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
|
+
const coreutils_1 = require("@phosphor/coreutils");
|
|
6
|
+
/* tslint:disable */
|
|
7
|
+
/**
|
|
8
|
+
* The default window resolver token.
|
|
9
|
+
*/
|
|
10
|
+
exports.IWindowResolver = new coreutils_1.Token('@jupyterlab/apputils:IWindowResolver');
|
|
11
|
+
/**
|
|
12
|
+
* A concrete implementation of a window name resolver.
|
|
13
|
+
*/
|
|
14
|
+
class WindowResolver {
|
|
15
|
+
constructor() {
|
|
16
|
+
this._name = null;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The resolved window name.
|
|
20
|
+
*/
|
|
21
|
+
get name() {
|
|
22
|
+
return this._name;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Resolve a window name to use as a handle among shared resources.
|
|
26
|
+
*
|
|
27
|
+
* @param candidate - The potential window name being resolved.
|
|
28
|
+
*
|
|
29
|
+
* #### Notes
|
|
30
|
+
* Typically, the name candidate should be a JupyterLab workspace name or
|
|
31
|
+
* an empty string if there is no workspace.
|
|
32
|
+
*
|
|
33
|
+
* If the returned promise rejects, a window name cannot be resolved without
|
|
34
|
+
* user intervention, which typically means navigation to a new URL.
|
|
35
|
+
*/
|
|
36
|
+
resolve(candidate) {
|
|
37
|
+
return Private.resolve(candidate).then(name => {
|
|
38
|
+
this._name = name;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.WindowResolver = WindowResolver;
|
|
43
|
+
/*
|
|
44
|
+
* A namespace for private module data.
|
|
45
|
+
*/
|
|
46
|
+
var Private;
|
|
47
|
+
(function (Private) {
|
|
48
|
+
/**
|
|
49
|
+
* The internal prefix for private local storage keys.
|
|
50
|
+
*/
|
|
51
|
+
const PREFIX = '@jupyterlab/coreutils:StateDB';
|
|
52
|
+
/**
|
|
53
|
+
* The local storage beacon key.
|
|
54
|
+
*/
|
|
55
|
+
const BEACON = `${PREFIX}:beacon`;
|
|
56
|
+
/**
|
|
57
|
+
* The timeout (in ms) to wait for beacon responders.
|
|
58
|
+
*
|
|
59
|
+
* #### Notes
|
|
60
|
+
* This value is a whole number between 200 and 500 in order to prevent
|
|
61
|
+
* perfect timeout collisions between multiple simultaneously opening windows
|
|
62
|
+
* that have the same URL. This is an edge case because multiple windows
|
|
63
|
+
* should not ordinarily share the same URL, but it can be contrived.
|
|
64
|
+
*/
|
|
65
|
+
const TIMEOUT = Math.floor(200 + Math.random() * 300);
|
|
66
|
+
/**
|
|
67
|
+
* The local storage window key.
|
|
68
|
+
*/
|
|
69
|
+
const WINDOW = `${PREFIX}:window`;
|
|
70
|
+
/**
|
|
71
|
+
* A potential preferred default window name.
|
|
72
|
+
*/
|
|
73
|
+
let candidate = null;
|
|
74
|
+
/**
|
|
75
|
+
* The window name promise.
|
|
76
|
+
*/
|
|
77
|
+
let delegate = new coreutils_1.PromiseDelegate();
|
|
78
|
+
/**
|
|
79
|
+
* The known window names.
|
|
80
|
+
*/
|
|
81
|
+
let known = {};
|
|
82
|
+
/**
|
|
83
|
+
* The window name.
|
|
84
|
+
*/
|
|
85
|
+
let name = null;
|
|
86
|
+
/**
|
|
87
|
+
* Whether the name resolution has completed.
|
|
88
|
+
*/
|
|
89
|
+
let resolved = false;
|
|
90
|
+
/**
|
|
91
|
+
* Start the storage event handler.
|
|
92
|
+
*/
|
|
93
|
+
function initialize() {
|
|
94
|
+
// Listen to all storage events for beacons and window names.
|
|
95
|
+
window.addEventListener('storage', (event) => {
|
|
96
|
+
const { key, newValue } = event;
|
|
97
|
+
// All the keys we care about have values.
|
|
98
|
+
if (newValue === null) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
// If the beacon was fired, respond with a ping.
|
|
102
|
+
if (key === BEACON && candidate !== null) {
|
|
103
|
+
ping(resolved ? name : candidate);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// If the window name is resolved, bail.
|
|
107
|
+
if (resolved || key !== WINDOW) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const reported = newValue.replace(/\-\d+$/, '');
|
|
111
|
+
// Store the reported window name.
|
|
112
|
+
known[reported] = null;
|
|
113
|
+
// If a reported window name and candidate collide, reject the candidate.
|
|
114
|
+
if (candidate in known) {
|
|
115
|
+
reject();
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Ping peers with payload.
|
|
121
|
+
*/
|
|
122
|
+
function ping(payload) {
|
|
123
|
+
if (payload === null) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const { localStorage } = window;
|
|
127
|
+
localStorage.setItem(WINDOW, `${payload}-${new Date().getTime()}`);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Reject the candidate.
|
|
131
|
+
*/
|
|
132
|
+
function reject() {
|
|
133
|
+
resolved = true;
|
|
134
|
+
delegate.reject(`Window name candidate "${candidate}" already exists`);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Returns a promise that resolves with the window name used for restoration.
|
|
138
|
+
*/
|
|
139
|
+
function resolve(potential) {
|
|
140
|
+
if (resolved) {
|
|
141
|
+
return delegate.promise;
|
|
142
|
+
}
|
|
143
|
+
// Set the local candidate.
|
|
144
|
+
candidate = potential;
|
|
145
|
+
if (candidate in known) {
|
|
146
|
+
reject();
|
|
147
|
+
return delegate.promise;
|
|
148
|
+
}
|
|
149
|
+
const { localStorage, setTimeout } = window;
|
|
150
|
+
// Wait until other windows have reported before claiming the candidate.
|
|
151
|
+
setTimeout(() => {
|
|
152
|
+
if (resolved) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
// If the window name has not already been resolved, check one last time
|
|
156
|
+
// to confirm it is not a duplicate before resolving.
|
|
157
|
+
if (candidate in known) {
|
|
158
|
+
return reject();
|
|
159
|
+
}
|
|
160
|
+
resolved = true;
|
|
161
|
+
delegate.resolve((name = candidate));
|
|
162
|
+
ping(name);
|
|
163
|
+
}, TIMEOUT);
|
|
164
|
+
// Fire the beacon to collect other windows' names.
|
|
165
|
+
localStorage.setItem(BEACON, `${Math.random()}-${new Date().getTime()}`);
|
|
166
|
+
return delegate.promise;
|
|
167
|
+
}
|
|
168
|
+
Private.resolve = resolve;
|
|
169
|
+
// Initialize the storage listener at runtime.
|
|
170
|
+
(() => {
|
|
171
|
+
initialize();
|
|
172
|
+
})();
|
|
173
|
+
})(Private || (Private = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlab/apputils",
|
|
3
|
-
"version": "0.19.1
|
|
3
|
+
"version": "0.19.1",
|
|
4
4
|
"description": "JupyterLab - Application Utilities",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyterlab",
|
|
6
6
|
"bugs": {
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"url": "https://github.com/jupyterlab/jupyterlab.git"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "tsc -b
|
|
27
|
+
"build": "tsc -b",
|
|
28
28
|
"clean": "rimraf lib",
|
|
29
29
|
"docs": "typedoc --options tdoptions.json --theme ../../typedoc-theme src",
|
|
30
30
|
"prepublishOnly": "npm run build",
|
|
31
|
-
"watch": "tsc -b
|
|
31
|
+
"watch": "tsc -b --watch"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@jupyterlab/coreutils": "^2.2.1
|
|
35
|
-
"@jupyterlab/services": "^3.2.1
|
|
34
|
+
"@jupyterlab/coreutils": "^2.2.1",
|
|
35
|
+
"@jupyterlab/services": "^3.2.1",
|
|
36
36
|
"@phosphor/algorithm": "^1.1.2",
|
|
37
37
|
"@phosphor/commands": "^1.6.1",
|
|
38
38
|
"@phosphor/coreutils": "^1.3.0",
|
|
@@ -55,5 +55,8 @@
|
|
|
55
55
|
"typedoc": "~0.12.0",
|
|
56
56
|
"typescript": "~3.1.1"
|
|
57
57
|
},
|
|
58
|
-
"
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public"
|
|
60
|
+
},
|
|
61
|
+
"gitHead": "7fc900168981e58051253ecc66a18015a052cd2f"
|
|
59
62
|
}
|