@jupyterlab/apputils 4.0.0-alpha.2 → 4.0.0-alpha.21

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.
Files changed (92) hide show
  1. package/lib/clipboard.d.ts +1 -1
  2. package/lib/dialog.d.ts +73 -4
  3. package/lib/dialog.js +143 -30
  4. package/lib/dialog.js.map +1 -1
  5. package/lib/domutils.js.map +1 -1
  6. package/lib/index.d.ts +6 -5
  7. package/lib/index.js +6 -5
  8. package/lib/index.js.map +1 -1
  9. package/lib/inputdialog.d.ts +35 -3
  10. package/lib/inputdialog.js +122 -12
  11. package/lib/inputdialog.js.map +1 -1
  12. package/lib/kernelstatuses.d.ts +74 -2
  13. package/lib/kernelstatuses.js +142 -2
  14. package/lib/kernelstatuses.js.map +1 -1
  15. package/lib/mainareawidget.d.ts +9 -0
  16. package/lib/mainareawidget.js +29 -4
  17. package/lib/mainareawidget.js.map +1 -1
  18. package/lib/menufactory.js +14 -15
  19. package/lib/menufactory.js.map +1 -1
  20. package/lib/notification.d.ts +336 -0
  21. package/lib/notification.js +310 -0
  22. package/lib/notification.js.map +1 -0
  23. package/lib/runningSessions.d.ts +72 -0
  24. package/lib/runningSessions.js +119 -0
  25. package/lib/runningSessions.js.map +1 -0
  26. package/lib/sanitizer.d.ts +20 -7
  27. package/lib/sanitizer.js +47 -12
  28. package/lib/sanitizer.js.map +1 -1
  29. package/lib/semanticCommand.js +11 -2
  30. package/lib/semanticCommand.js.map +1 -1
  31. package/lib/sessioncontext.d.ts +2 -3
  32. package/lib/sessioncontext.js +46 -27
  33. package/lib/sessioncontext.js.map +1 -1
  34. package/lib/testutils.d.ts +5 -0
  35. package/lib/testutils.js +46 -0
  36. package/lib/testutils.js.map +1 -0
  37. package/lib/thememanager.js +25 -5
  38. package/lib/thememanager.js.map +1 -1
  39. package/lib/tokens.d.ts +34 -42
  40. package/lib/tokens.js +1 -6
  41. package/lib/tokens.js.map +1 -1
  42. package/lib/toolbar/factory.d.ts +12 -2
  43. package/lib/toolbar/factory.js +237 -145
  44. package/lib/toolbar/factory.js.map +1 -1
  45. package/lib/toolbar/index.js +4 -0
  46. package/lib/toolbar/index.js.map +1 -1
  47. package/lib/toolbar/registry.d.ts +11 -0
  48. package/lib/toolbar/registry.js +20 -3
  49. package/lib/toolbar/registry.js.map +1 -1
  50. package/lib/toolbar/widget.d.ts +3 -0
  51. package/lib/toolbar/widget.js +3 -0
  52. package/lib/toolbar/widget.js.map +1 -1
  53. package/lib/widgettracker.d.ts +13 -1
  54. package/lib/widgettracker.js +29 -2
  55. package/lib/widgettracker.js.map +1 -1
  56. package/package.json +30 -30
  57. package/src/clipboard.ts +107 -0
  58. package/src/commandlinker.ts +209 -0
  59. package/src/commandpalette.ts +175 -0
  60. package/src/dialog.tsx +1133 -0
  61. package/src/domutils.ts +53 -0
  62. package/src/index.ts +78 -0
  63. package/src/inputdialog.ts +551 -0
  64. package/src/kernelstatuses.tsx +279 -0
  65. package/src/mainareawidget.ts +362 -0
  66. package/src/menufactory.ts +201 -0
  67. package/src/notification.ts +559 -0
  68. package/src/printing.ts +180 -0
  69. package/src/runningSessions.tsx +233 -0
  70. package/src/sanitizer.ts +986 -0
  71. package/src/semanticCommand.ts +77 -0
  72. package/src/sessioncontext.tsx +1712 -0
  73. package/src/testutils.ts +49 -0
  74. package/src/thememanager.ts +530 -0
  75. package/src/tokens.ts +351 -0
  76. package/src/toolbar/factory.ts +422 -0
  77. package/src/toolbar/index.ts +8 -0
  78. package/src/toolbar/registry.ts +158 -0
  79. package/src/toolbar/widget.tsx +243 -0
  80. package/src/widgettracker.ts +391 -0
  81. package/src/windowresolver.ts +218 -0
  82. package/style/base.css +0 -1
  83. package/style/commandpalette.css +7 -10
  84. package/style/dialog.css +23 -7
  85. package/style/index.css +1 -0
  86. package/style/index.js +1 -0
  87. package/style/inputdialog.css +5 -0
  88. package/style/materialcolors.css +8 -21
  89. package/lib/hoverbox.d.ts +0 -82
  90. package/lib/hoverbox.js +0 -100
  91. package/lib/hoverbox.js.map +0 -1
  92. package/style/hoverbox.css +0 -13
@@ -0,0 +1,310 @@
1
+ /*
2
+ * Copyright (c) Jupyter Development Team.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ import { UUID } from '@lumino/coreutils';
6
+ import { Signal } from '@lumino/signaling';
7
+ /**
8
+ * Notification manager
9
+ */
10
+ export class NotificationManager {
11
+ constructor() {
12
+ this._isDisposed = false;
13
+ this._queue = [];
14
+ this._changed = new Signal(this);
15
+ }
16
+ /**
17
+ * Signal emitted whenever a notification changes.
18
+ */
19
+ get changed() {
20
+ return this._changed;
21
+ }
22
+ /**
23
+ * Total number of notifications.
24
+ */
25
+ get count() {
26
+ return this._queue.length;
27
+ }
28
+ /**
29
+ * Whether the manager is disposed or not.
30
+ */
31
+ get isDisposed() {
32
+ return this._isDisposed;
33
+ }
34
+ /**
35
+ * The list of notifications.
36
+ */
37
+ get notifications() {
38
+ return this._queue.slice();
39
+ }
40
+ /**
41
+ * Dismiss one notification (specified by its id) or all if no id provided.
42
+ *
43
+ * @param id Notification id
44
+ */
45
+ dismiss(id) {
46
+ if (typeof id === 'undefined') {
47
+ const q = this._queue.slice();
48
+ this._queue.length = 0;
49
+ for (const notification of q) {
50
+ this._changed.emit({
51
+ type: 'removed',
52
+ notification
53
+ });
54
+ }
55
+ }
56
+ else {
57
+ const notificationIndex = this._queue.findIndex(n => n.id === id);
58
+ if (notificationIndex > -1) {
59
+ const notification = this._queue.splice(notificationIndex, 1)[0];
60
+ this._changed.emit({
61
+ type: 'removed',
62
+ notification
63
+ });
64
+ }
65
+ }
66
+ }
67
+ /**
68
+ * Dispose the manager.
69
+ */
70
+ dispose() {
71
+ if (this._isDisposed) {
72
+ return;
73
+ }
74
+ this._isDisposed = true;
75
+ Signal.clearData(this);
76
+ }
77
+ /**
78
+ * Test whether a notification exists or not.
79
+ *
80
+ * @param id Notification id
81
+ * @returns Notification status
82
+ */
83
+ has(id) {
84
+ return this._queue.findIndex(n => n.id === id) > -1;
85
+ }
86
+ /**
87
+ * Add a new notification.
88
+ *
89
+ * This will trigger the `changed` signal with an `added` event.
90
+ *
91
+ * @param message Notification message
92
+ * @param type Notification type
93
+ * @param options Notification option
94
+ * @returns Notification unique id
95
+ */
96
+ notify(message, type, options) {
97
+ const now = Date.now();
98
+ const { progress, ...othersOptions } = options;
99
+ const notification = Object.freeze({
100
+ id: UUID.uuid4(),
101
+ createdAt: now,
102
+ modifiedAt: now,
103
+ message,
104
+ type,
105
+ options: {
106
+ // By default notification will be silent
107
+ autoClose: 0,
108
+ progress: typeof progress === 'number'
109
+ ? Math.min(Math.max(0, progress), 1)
110
+ : progress,
111
+ ...othersOptions
112
+ }
113
+ });
114
+ this._queue.unshift(notification);
115
+ this._changed.emit({
116
+ type: 'added',
117
+ notification
118
+ });
119
+ return notification.id;
120
+ }
121
+ /**
122
+ * Update an existing notification.
123
+ *
124
+ * If the notification does not exists this won't do anything.
125
+ *
126
+ * Once updated the notification will be moved at the begin
127
+ * of the notification stack.
128
+ *
129
+ * @param args Update options
130
+ * @returns Whether the update was successful or not.
131
+ */
132
+ update(args) {
133
+ const { id, message, actions, autoClose, data, progress, type } = args;
134
+ const newProgress = typeof progress === 'number'
135
+ ? Math.min(Math.max(0, progress), 1)
136
+ : progress;
137
+ const notificationIndex = this._queue.findIndex(n => n.id === id);
138
+ if (notificationIndex > -1) {
139
+ const oldNotification = this._queue[notificationIndex];
140
+ // We need to create a new object as notification are frozen; i.e. cannot be edited
141
+ const notification = Object.freeze({
142
+ ...oldNotification,
143
+ message: message !== null && message !== void 0 ? message : oldNotification.message,
144
+ type: type !== null && type !== void 0 ? type : oldNotification.type,
145
+ options: {
146
+ actions: actions !== null && actions !== void 0 ? actions : oldNotification.options.actions,
147
+ autoClose: autoClose !== null && autoClose !== void 0 ? autoClose : oldNotification.options.autoClose,
148
+ data: data !== null && data !== void 0 ? data : oldNotification.options.data,
149
+ progress: newProgress !== null && newProgress !== void 0 ? newProgress : oldNotification.options.progress
150
+ },
151
+ modifiedAt: Date.now()
152
+ });
153
+ this._queue.splice(notificationIndex, 1);
154
+ this._queue.unshift(notification);
155
+ this._changed.emit({
156
+ type: 'updated',
157
+ notification
158
+ });
159
+ return true;
160
+ }
161
+ return false;
162
+ }
163
+ }
164
+ /**
165
+ * Notification namespace
166
+ */
167
+ export var Notification;
168
+ (function (Notification) {
169
+ /**
170
+ * The global notification manager.
171
+ */
172
+ Notification.manager = new NotificationManager();
173
+ /**
174
+ * Dismiss one notification (specified by its id) or all if no id provided
175
+ *
176
+ * @param id notification id
177
+ */
178
+ function dismiss(id) {
179
+ Notification.manager.dismiss(id);
180
+ }
181
+ Notification.dismiss = dismiss;
182
+ /**
183
+ * Helper function to emit a notification.
184
+ *
185
+ * #### Notes
186
+ * The message will be truncated if longer than 140 characters.
187
+ *
188
+ * @param message Notification message
189
+ * @param type Notification type
190
+ * @param options Options for the error notification
191
+ * @returns Notification unique id
192
+ */
193
+ function emit(message, type = 'default', options = {}) {
194
+ return Notification.manager.notify(message, type, options);
195
+ }
196
+ Notification.emit = emit;
197
+ /**
198
+ * Helper function to emit an error notification.
199
+ *
200
+ * #### Notes
201
+ * The message will be truncated if longer than 140 characters.
202
+ *
203
+ * @param message Notification message
204
+ * @param options Options for the error notification
205
+ * @returns Notification unique id
206
+ */
207
+ function error(message, options = {}) {
208
+ return Notification.manager.notify(message, 'error', options);
209
+ }
210
+ Notification.error = error;
211
+ /**
212
+ * Helper function to emit an info notification.
213
+ *
214
+ * #### Notes
215
+ * The message will be truncated if longer than 140 characters.
216
+ *
217
+ * @param message Notification message
218
+ * @param options Options for the info notification
219
+ * @returns Notification unique id
220
+ */
221
+ function info(message, options = {}) {
222
+ return Notification.manager.notify(message, 'info', options);
223
+ }
224
+ Notification.info = info;
225
+ /**
226
+ * Helper function to show an in-progress notification.
227
+ *
228
+ * #### Notes
229
+ * The message will be truncated if longer than 140 characters.
230
+ *
231
+ * @param promise Promise to wait for
232
+ * @param options Options for the in-progress notification
233
+ * @returns Notification unique id
234
+ */
235
+ function promise(promise, options) {
236
+ var _a;
237
+ const { pending, error, success } = options;
238
+ const id = Notification.manager.notify(pending.message, 'in-progress', (_a = pending.options) !== null && _a !== void 0 ? _a : {});
239
+ promise
240
+ .then(result => {
241
+ var _a, _b, _c;
242
+ Notification.manager.update({
243
+ id,
244
+ message: success.message(result, (_a = success.options) === null || _a === void 0 ? void 0 : _a.data),
245
+ type: 'success',
246
+ ...success.options,
247
+ data: (_c = (_b = success.options) === null || _b === void 0 ? void 0 : _b.data) !== null && _c !== void 0 ? _c : result
248
+ });
249
+ })
250
+ .catch(reason => {
251
+ var _a, _b, _c;
252
+ Notification.manager.update({
253
+ id,
254
+ message: error.message(reason, (_a = error.options) === null || _a === void 0 ? void 0 : _a.data),
255
+ type: 'error',
256
+ ...error.options,
257
+ data: (_c = (_b = error.options) === null || _b === void 0 ? void 0 : _b.data) !== null && _c !== void 0 ? _c : reason
258
+ });
259
+ });
260
+ return id;
261
+ }
262
+ Notification.promise = promise;
263
+ /**
264
+ * Helper function to emit a success notification.
265
+ *
266
+ * #### Notes
267
+ * The message will be truncated if longer than 140 characters.
268
+ *
269
+ * @param message Notification message
270
+ * @param options Options for the success notification
271
+ * @returns Notification unique id
272
+ */
273
+ function success(message, options = {}) {
274
+ return Notification.manager.notify(message, 'success', options);
275
+ }
276
+ Notification.success = success;
277
+ /**
278
+ * Helper function to update a notification.
279
+ *
280
+ * If the notification does not exists, nothing will happen.
281
+ *
282
+ * Once updated the notification will be moved at the begin
283
+ * of the notification stack.
284
+ *
285
+ * #### Notes
286
+ * The message will be truncated if longer than 140 characters.
287
+ *
288
+ * @param args Update options
289
+ * @returns Whether the update was successful or not.
290
+ */
291
+ function update(args) {
292
+ return Notification.manager.update(args);
293
+ }
294
+ Notification.update = update;
295
+ /**
296
+ * Helper function to emit a warning notification.
297
+ *
298
+ * #### Notes
299
+ * The message will be truncated if longer than 140 characters.
300
+ *
301
+ * @param message Notification message
302
+ * @param options Options for the warning notification
303
+ * @returns Notification unique id
304
+ */
305
+ function warning(message, options = {}) {
306
+ return Notification.manager.notify(message, 'warning', options);
307
+ }
308
+ Notification.warning = warning;
309
+ })(Notification || (Notification = {}));
310
+ //# sourceMappingURL=notification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification.js","sourceRoot":"","sources":["../src/notification.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAqB,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAW,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAC9B;QACE,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,IAAI,MAAM,CAA4C,IAAI,CAAC,CAAC;IAC9E,CAAC;IAED;;OAEG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,EAAW;QACjB,IAAI,OAAO,EAAE,KAAK,WAAW,EAAE;YAC7B,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;YACvB,KAAK,MAAM,YAAY,IAAI,CAAC,EAAE;gBAC5B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;oBACjB,IAAI,EAAE,SAAS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,GAAG,KAAK,CAAC,OAAO;gBAChB,IAAI,EAAE,MAAA,MAAA,KAAK,CAAC,OAAO,0CAAE,IAAI,mCAAI,MAAM;aACpC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACL,OAAO,EAAE,CAAC;IACZ,CAAC;IAlCe,oBAAO,UAkCtB,CAAA;IAED;;;;;;;;;OASG;IACH,SAAgB,OAAO,CACrB,OAAe,EACf,UAAuB,EAAE;QAEzB,OAAO,aAAA,OAAO,CAAC,MAAM,CAAI,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IALe,oBAAO,UAKtB,CAAA;IAED;;;;;;;;;;;;;OAaG;IACH,SAAgB,MAAM,CACpB,IAAgB;QAEhB,OAAO,aAAA,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAJe,mBAAM,SAIrB,CAAA;IAED;;;;;;;;;OASG;IACH,SAAgB,OAAO,CACrB,OAAe,EACf,UAAuB,EAAE;QAEzB,OAAO,aAAA,OAAO,CAAC,MAAM,CAAI,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IALe,oBAAO,UAKtB,CAAA;AACH,CAAC,EAzWgB,YAAY,KAAZ,YAAY,QAyW5B"}
@@ -0,0 +1,72 @@
1
+ import { ServiceManager } from '@jupyterlab/services';
2
+ import { ITranslator } from '@jupyterlab/translation';
3
+ import { VDomModel, VDomRenderer } from '@jupyterlab/ui-components';
4
+ /**
5
+ * A VDomRenderer for a RunningSessions status item.
6
+ */
7
+ export declare class RunningSessions extends VDomRenderer<RunningSessions.Model> {
8
+ /**
9
+ * Create a new RunningSessions widget.
10
+ */
11
+ constructor(opts: RunningSessions.IOptions);
12
+ /**
13
+ * Render the running sessions widget.
14
+ */
15
+ render(): JSX.Element | null;
16
+ /**
17
+ * Dispose of the status item.
18
+ */
19
+ dispose(): void;
20
+ /**
21
+ * Set the number of kernel sessions when the list changes.
22
+ */
23
+ private _onSessionsRunningChanged;
24
+ /**
25
+ * Set the number of terminal sessions when the list changes.
26
+ */
27
+ private _onTerminalsRunningChanged;
28
+ protected translator: ITranslator;
29
+ private _trans;
30
+ private _handleClick;
31
+ private _serviceManager;
32
+ }
33
+ /**
34
+ * A namespace for RunningSessions statics.
35
+ */
36
+ export declare namespace RunningSessions {
37
+ /**
38
+ * A VDomModel for the RunningSessions status item.
39
+ */
40
+ class Model extends VDomModel {
41
+ /**
42
+ * The number of active kernel sessions.
43
+ */
44
+ get sessions(): number;
45
+ set sessions(sessions: number);
46
+ /**
47
+ * The number of active terminal sessions.
48
+ */
49
+ get terminals(): number;
50
+ set terminals(terminals: number);
51
+ private _terminals;
52
+ private _sessions;
53
+ }
54
+ /**
55
+ * Options for creating a RunningSessions item.
56
+ */
57
+ interface IOptions {
58
+ /**
59
+ * The application service manager.
60
+ */
61
+ serviceManager: ServiceManager.IManager;
62
+ /**
63
+ * A click handler for the item. By default this is used
64
+ * to activate the running sessions side panel.
65
+ */
66
+ onClick: () => void;
67
+ /**
68
+ * The application language translator.
69
+ */
70
+ translator?: ITranslator;
71
+ }
72
+ }
@@ -0,0 +1,119 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ import { nullTranslator } from '@jupyterlab/translation';
4
+ import { kernelIcon, terminalIcon, VDomModel, VDomRenderer } from '@jupyterlab/ui-components';
5
+ import React from 'react';
6
+ import { GroupItem, TextItem } from '@jupyterlab/statusbar';
7
+ /**
8
+ * Half spacing between subitems in a status item.
9
+ */
10
+ const HALF_SPACING = 4;
11
+ /**
12
+ * A pure functional component for rendering kernel and terminal sessions.
13
+ *
14
+ * @param props: the props for the component.
15
+ *
16
+ * @returns a tsx component for the running sessions.
17
+ */
18
+ function RunningSessionsComponent(props) {
19
+ return (React.createElement(GroupItem, { spacing: HALF_SPACING, onClick: props.handleClick },
20
+ React.createElement(GroupItem, { spacing: HALF_SPACING },
21
+ React.createElement(TextItem, { source: props.terminals }),
22
+ React.createElement(terminalIcon.react, { left: '1px', top: '3px', stylesheet: 'statusBar' })),
23
+ React.createElement(GroupItem, { spacing: HALF_SPACING },
24
+ React.createElement(TextItem, { source: props.sessions }),
25
+ React.createElement(kernelIcon.react, { top: '2px', stylesheet: 'statusBar' }))));
26
+ }
27
+ /**
28
+ * A VDomRenderer for a RunningSessions status item.
29
+ */
30
+ export class RunningSessions extends VDomRenderer {
31
+ /**
32
+ * Create a new RunningSessions widget.
33
+ */
34
+ constructor(opts) {
35
+ super(new RunningSessions.Model());
36
+ this._serviceManager = opts.serviceManager;
37
+ this._handleClick = opts.onClick;
38
+ this.translator = opts.translator || nullTranslator;
39
+ this._trans = this.translator.load('jupyterload');
40
+ this._serviceManager.sessions.runningChanged.connect(this._onSessionsRunningChanged, this);
41
+ this._serviceManager.terminals.runningChanged.connect(this._onTerminalsRunningChanged, this);
42
+ this.addClass('jp-mod-highlighted');
43
+ }
44
+ /**
45
+ * Render the running sessions widget.
46
+ */
47
+ render() {
48
+ if (!this.model) {
49
+ return null;
50
+ }
51
+ // TODO-TRANS: Should probably be handled differently.
52
+ // This is more localizable friendly: "Terminals: %1 | Kernels: %2"
53
+ this.title.caption = this._trans.__('%1 Terminals, %2 Kernel sessions', this.model.terminals, this.model.sessions);
54
+ return (React.createElement(RunningSessionsComponent, { sessions: this.model.sessions, terminals: this.model.terminals, handleClick: this._handleClick }));
55
+ }
56
+ /**
57
+ * Dispose of the status item.
58
+ */
59
+ dispose() {
60
+ super.dispose();
61
+ this._serviceManager.sessions.runningChanged.disconnect(this._onSessionsRunningChanged, this);
62
+ this._serviceManager.terminals.runningChanged.disconnect(this._onTerminalsRunningChanged, this);
63
+ }
64
+ /**
65
+ * Set the number of kernel sessions when the list changes.
66
+ */
67
+ _onSessionsRunningChanged(manager, sessions) {
68
+ this.model.sessions = sessions.length;
69
+ }
70
+ /**
71
+ * Set the number of terminal sessions when the list changes.
72
+ */
73
+ _onTerminalsRunningChanged(manager, terminals) {
74
+ this.model.terminals = terminals.length;
75
+ }
76
+ }
77
+ /**
78
+ * A namespace for RunningSessions statics.
79
+ */
80
+ (function (RunningSessions) {
81
+ /**
82
+ * A VDomModel for the RunningSessions status item.
83
+ */
84
+ class Model extends VDomModel {
85
+ constructor() {
86
+ super(...arguments);
87
+ this._terminals = 0;
88
+ this._sessions = 0;
89
+ }
90
+ /**
91
+ * The number of active kernel sessions.
92
+ */
93
+ get sessions() {
94
+ return this._sessions;
95
+ }
96
+ set sessions(sessions) {
97
+ const oldSessions = this._sessions;
98
+ this._sessions = sessions;
99
+ if (oldSessions !== this._sessions) {
100
+ this.stateChanged.emit(void 0);
101
+ }
102
+ }
103
+ /**
104
+ * The number of active terminal sessions.
105
+ */
106
+ get terminals() {
107
+ return this._terminals;
108
+ }
109
+ set terminals(terminals) {
110
+ const oldTerminals = this._terminals;
111
+ this._terminals = terminals;
112
+ if (oldTerminals !== this._terminals) {
113
+ this.stateChanged.emit(void 0);
114
+ }
115
+ }
116
+ }
117
+ RunningSessions.Model = Model;
118
+ })(RunningSessions || (RunningSessions = {}));
119
+ //# sourceMappingURL=runningSessions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runningSessions.js","sourceRoot":"","sources":["../src/runningSessions.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAS3D,OAAO,EAEL,cAAc,EAEf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,UAAU,EACV,YAAY,EACZ,SAAS,EACT,YAAY,EACb,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;GAEG;AACH,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB;;;;;;GAMG;AACH,SAAS,wBAAwB,CAC/B,KAAsC;IAEtC,OAAO,CACL,oBAAC,SAAS,IAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,C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AAC,QAAgB;YAC3B,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC;YACnC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;YAE1B,IAAI,WAAW,KAAK,IAAI,CAAC,SAAS,EAAE;gBAClC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;aAChC;QACH,CAAC;QAED;;WAEG;QACH,IAAI,SAAS;YACX,OAAO,IAAI,CAAC,UAAU,CAAC;QACzB,CAAC;QACD,IAAI,SAAS,CAAC,SAAiB;YAC7B,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC;YACrC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;YAE5B,IAAI,YAAY,KAAK,IAAI,CAAC,UAAU,EAAE;gBACpC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;aAChC;QACH,CAAC;KAIF;IAjCY,qBAAK,QAiCjB,CAAA;AAsBH,CAAC,EA3DgB,eAAe,KAAf,eAAe,QA2D/B"}
@@ -1,8 +1,8 @@
1
- import { ISanitizer } from './tokens';
1
+ import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
2
2
  /**
3
3
  * A class to sanitize HTML strings.
4
4
  */
5
- export declare class Sanitizer implements ISanitizer {
5
+ export declare class Sanitizer implements IRenderMime.ISanitizer {
6
6
  /**
7
7
  * Sanitize an HTML string.
8
8
  *
@@ -12,10 +12,23 @@ export declare class Sanitizer implements ISanitizer {
12
12
  *
13
13
  * @returns The sanitized string.
14
14
  */
15
- sanitize(dirty: string, options?: ISanitizer.IOptions): string;
15
+ sanitize(dirty: string, options?: IRenderMime.ISanitizerOptions): string;
16
+ /**
17
+ * @returns Whether to replace URLs by HTML anchors.
18
+ */
19
+ getAutolink(): boolean;
20
+ /**
21
+ * Set the allowed schemes
22
+ *
23
+ * @param scheme Allowed schemes
24
+ */
25
+ setAllowedSchemes(scheme: Array<string>): void;
26
+ /**
27
+ * Set the URL replacement boolean.
28
+ *
29
+ * @param autolink URL replacement boolean.
30
+ */
31
+ setAutolink(autolink: boolean): void;
32
+ private _autolink;
16
33
  private _options;
17
34
  }
18
- /**
19
- * The default instance of an `ISanitizer` meant for use by user code.
20
- */
21
- export declare const defaultSanitizer: ISanitizer;
package/lib/sanitizer.js CHANGED
@@ -1,8 +1,6 @@
1
1
  /* eslint-disable camelcase */
2
2
  // Copyright (c) Jupyter Development Team.
3
3
  // Distributed under the terms of the Modified BSD License.
4
- // sanitize-html uses the url package, so we depend on a standalone version of
5
- // it which acts as a polyfill for browsers.
6
4
  import sanitize from 'sanitize-html';
7
5
  /**
8
6
  * Helper class that contains regular expressions for inline CSS style validation.
@@ -28,7 +26,7 @@ CssProp.N = {
28
26
  number: `[+-]?([0-9]*[.])?[0-9]+(e-?[0-9]*)?`,
29
27
  number_pos: `[+]?([0-9]*[.])?[0-9]+(e-?[0-9]*)?`,
30
28
  number_zero_hundred: `[+]?(([0-9]|[1-9][0-9])([.][0-9]+)?|100)`,
31
- number_zero_one: `[+]?(1([.][0]+)?|0([.][0-9]+)?)`
29
+ number_zero_one: `[+]?(1([.][0]+)?|0?([.][0-9]+)?)`
32
30
  };
33
31
  /*
34
32
  * Base expressions of common CSS syntax elements
@@ -89,6 +87,8 @@ CssProp._C = {
89
87
  border_width: `thin|medium|thick|${CssProp.B.length}`,
90
88
  bottom: `${CssProp.B.length}|auto`,
91
89
  color: `${CssProp._COLOR.hex}|${CssProp._COLOR.rgb}|${CssProp._COLOR.rgba}|${CssProp._COLOR.name}`,
90
+ color_stop_length: `(${CssProp.B.len_or_perc}\\s*){1,2}`,
91
+ linear_color_hint: `${CssProp.B.len_or_perc}`,
92
92
  family_name: `${CssProp.B.string}|(${CssProp.B.ident}\\s*)+`,
93
93
  image_decl: CssProp.B.url,
94
94
  left: `${CssProp.B.length}|auto`,
@@ -104,14 +104,28 @@ CssProp._C = {
104
104
  };
105
105
  CssProp._C1 = {
106
106
  image_list: `image\\(\\s*(${CssProp.B.url})*\\s*(${CssProp.B.url}|${CssProp._C.color})\\s*\\)`,
107
+ linear_color_stop: `(${CssProp._C.color})(\\s*${CssProp._C.color_stop_length})?`,
107
108
  shadow: `((${CssProp._C.color})\\s+((${CssProp.B.length})\\s*){2,4}(\s+inset)?)|((inset\\s+)?((${CssProp.B.length})\\s*){2,4}\\s*(${CssProp._C.color})?)`
108
109
  };
109
110
  CssProp._C2 = {
110
- bg_image: `(${CssProp.B.url}|${CssProp._C1.image_list})|none`,
111
- image: `${CssProp.B.url}|${CssProp._C1.image_list}`,
111
+ color_stop_list: `((${CssProp._C1.linear_color_stop})(\\s*(${CssProp._C.linear_color_hint}))?\\s*,\\s*)+(${CssProp._C1.linear_color_stop})`,
112
112
  shape: `rect\\(\\s*(${CssProp._C.top})\\s*,\\s*(${CssProp._C.right})\\s*,\\s*(${CssProp._C.bottom})\\s*,\\s*(${CssProp._C.left})\\s*\\)`
113
113
  };
114
- CssProp.C = Object.assign(Object.assign(Object.assign({}, CssProp._C), CssProp._C1), CssProp._C2);
114
+ CssProp._C3 = {
115
+ linear_gradient: `linear-gradient\\((((${CssProp.B.angle})|to\\s+(${CssProp.A.side_or_corner}))\\s*,\\s*)?\\s*(${CssProp._C2.color_stop_list})\\s*\\)`,
116
+ radial_gradient: `radial-gradient\\(((((${CssProp.A.ending_shape})|(${CssProp._C.size}))\\s*)*\\s*(at\\s+${CssProp._C.position})?\\s*,\\s*)?\\s*(${CssProp._C2.color_stop_list})\\s*\\)`
117
+ };
118
+ CssProp._C4 = {
119
+ image: `${CssProp.B.url}|${CssProp._C3.linear_gradient}|${CssProp._C3.radial_gradient}|${CssProp._C1.image_list}`,
120
+ bg_image: `(${CssProp.B.url}|${CssProp._C3.linear_gradient}|${CssProp._C3.radial_gradient}|${CssProp._C1.image_list})|none`
121
+ };
122
+ CssProp.C = {
123
+ ...CssProp._C,
124
+ ...CssProp._C1,
125
+ ...CssProp._C2,
126
+ ...CssProp._C3,
127
+ ...CssProp._C4
128
+ };
115
129
  /*
116
130
  * Property value regular expressions not dependant on other sub expressions
117
131
  */
@@ -255,7 +269,7 @@ CssProp._CP = {
255
269
  CssProp._CP1 = {
256
270
  font: `(((((${CssProp.AP.font_style}|${CssProp.AP.font_variant}|${CssProp.AP.font_weight})\\s*){1,3})?\\s*(${CssProp._CP.font_size})\\s*(\\/\\s*(${CssProp._CP.line_height}))?\\s+(${CssProp._CP.font_family}))|caption|icon|menu|message-box|small-caption|status-bar)`
257
271
  };
258
- CssProp.CP = Object.assign(Object.assign({}, CssProp._CP), CssProp._CP1);
272
+ CssProp.CP = { ...CssProp._CP, ...CssProp._CP1 };
259
273
  // CSS Property value validation regular expressions for use with sanitize-html
260
274
  CssProp.BORDER_COLLAPSE = CssProp.reg(CssProp.AP.border_collapse);
261
275
  CssProp.BOX = CssProp.reg(CssProp.AP.box);
@@ -392,6 +406,7 @@ CssProp.MIN_WIDTH = CssProp.reg(CssProp.CP.min_width);
392
406
  */
393
407
  export class Sanitizer {
394
408
  constructor() {
409
+ this._autolink = true;
395
410
  this._options = {
396
411
  // HTML tags that are allowed to be used. Tags were extracted from Google Caja
397
412
  allowedTags: [
@@ -889,6 +904,7 @@ export class Sanitizer {
889
904
  // Set the "disabled" attribute for <input> tags.
890
905
  input: sanitize.simpleTransform('input', { disabled: 'disabled' })
891
906
  },
907
+ allowedSchemes: [...sanitize.defaults.allowedSchemes],
892
908
  allowedSchemesByTag: {
893
909
  // Allow 'attachment:' img src (used for markdown cell attachments).
894
910
  img: sanitize.defaults.allowedSchemes.concat(['attachment'])
@@ -910,11 +926,30 @@ export class Sanitizer {
910
926
  * @returns The sanitized string.
911
927
  */
912
928
  sanitize(dirty, options) {
913
- return sanitize(dirty, Object.assign(Object.assign({}, this._options), (options || {})));
929
+ return sanitize(dirty, { ...this._options, ...(options || {}) });
930
+ }
931
+ /**
932
+ * @returns Whether to replace URLs by HTML anchors.
933
+ */
934
+ getAutolink() {
935
+ return this._autolink;
936
+ }
937
+ /**
938
+ * Set the allowed schemes
939
+ *
940
+ * @param scheme Allowed schemes
941
+ */
942
+ setAllowedSchemes(scheme) {
943
+ // Force copy of `scheme`
944
+ this._options.allowedSchemes = [...scheme];
945
+ }
946
+ /**
947
+ * Set the URL replacement boolean.
948
+ *
949
+ * @param autolink URL replacement boolean.
950
+ */
951
+ setAutolink(autolink) {
952
+ this._autolink = autolink;
914
953
  }
915
954
  }
916
- /**
917
- * The default instance of an `ISanitizer` meant for use by user code.
918
- */
919
- export const defaultSanitizer = new Sanitizer();
920
955
  //# sourceMappingURL=sanitizer.js.map