@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/clientsession.d.ts
CHANGED
|
@@ -1,443 +1,443 @@
|
|
|
1
|
-
import { Kernel, KernelMessage, Session } from '@jupyterlab/services';
|
|
2
|
-
import { IterableOrArrayLike } from '@phosphor/algorithm';
|
|
3
|
-
import { IDisposable } from '@phosphor/disposable';
|
|
4
|
-
import { ISignal } from '@phosphor/signaling';
|
|
5
|
-
/**
|
|
6
|
-
* The interface of client session object.
|
|
7
|
-
*
|
|
8
|
-
* The client session represents the link between
|
|
9
|
-
* a path and its kernel for the duration of the lifetime
|
|
10
|
-
* of the session object. The session can have no current
|
|
11
|
-
* kernel, and can start a new kernel at any time.
|
|
12
|
-
*/
|
|
13
|
-
export interface IClientSession extends IDisposable {
|
|
14
|
-
/**
|
|
15
|
-
* A signal emitted when the session is shut down.
|
|
16
|
-
*/
|
|
17
|
-
readonly terminated: ISignal<this, void>;
|
|
18
|
-
/**
|
|
19
|
-
* A signal emitted when the kernel changes.
|
|
20
|
-
*/
|
|
21
|
-
readonly kernelChanged: ISignal<this, Session.IKernelChangedArgs>;
|
|
22
|
-
/**
|
|
23
|
-
* A signal emitted when the kernel status changes.
|
|
24
|
-
*/
|
|
25
|
-
readonly statusChanged: ISignal<this, Kernel.Status>;
|
|
26
|
-
/**
|
|
27
|
-
* A signal emitted for a kernel messages.
|
|
28
|
-
*/
|
|
29
|
-
readonly iopubMessage: ISignal<this, KernelMessage.IMessage>;
|
|
30
|
-
/**
|
|
31
|
-
* A signal emitted for an unhandled kernel message.
|
|
32
|
-
*/
|
|
33
|
-
readonly unhandledMessage: ISignal<this, KernelMessage.IMessage>;
|
|
34
|
-
/**
|
|
35
|
-
* A signal emitted when a session property changes.
|
|
36
|
-
*/
|
|
37
|
-
readonly propertyChanged: ISignal<this, 'path' | 'name' | 'type'>;
|
|
38
|
-
/**
|
|
39
|
-
* The current kernel associated with the document.
|
|
40
|
-
*/
|
|
41
|
-
readonly kernel: Kernel.IKernelConnection | null;
|
|
42
|
-
/**
|
|
43
|
-
* The current path associated with the client session.
|
|
44
|
-
*/
|
|
45
|
-
readonly path: string;
|
|
46
|
-
/**
|
|
47
|
-
* The current name associated with the client session.
|
|
48
|
-
*/
|
|
49
|
-
readonly name: string;
|
|
50
|
-
/**
|
|
51
|
-
* The type of the client session.
|
|
52
|
-
*/
|
|
53
|
-
readonly type: string;
|
|
54
|
-
/**
|
|
55
|
-
* The current status of the client session.
|
|
56
|
-
*/
|
|
57
|
-
readonly status: Kernel.Status;
|
|
58
|
-
/**
|
|
59
|
-
* Whether the session is ready.
|
|
60
|
-
*/
|
|
61
|
-
readonly isReady: boolean;
|
|
62
|
-
/**
|
|
63
|
-
* A promise that is fulfilled when the session is ready.
|
|
64
|
-
*/
|
|
65
|
-
readonly ready: Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
* The kernel preference.
|
|
68
|
-
*/
|
|
69
|
-
kernelPreference: IClientSession.IKernelPreference;
|
|
70
|
-
/**
|
|
71
|
-
* The display name of the kernel.
|
|
72
|
-
*/
|
|
73
|
-
readonly kernelDisplayName: string;
|
|
74
|
-
/**
|
|
75
|
-
* Change the current kernel associated with the document.
|
|
76
|
-
*/
|
|
77
|
-
changeKernel(options: Partial<Kernel.IModel>): Promise<Kernel.IKernelConnection>;
|
|
78
|
-
/**
|
|
79
|
-
* Kill the kernel and shutdown the session.
|
|
80
|
-
*
|
|
81
|
-
* @returns A promise that resolves when the session is shut down.
|
|
82
|
-
*/
|
|
83
|
-
shutdown(): Promise<void>;
|
|
84
|
-
/**
|
|
85
|
-
* Select a kernel for the session.
|
|
86
|
-
*/
|
|
87
|
-
selectKernel(): Promise<void>;
|
|
88
|
-
/**
|
|
89
|
-
* Restart the session.
|
|
90
|
-
*
|
|
91
|
-
* @returns A promise that resolves with whether the kernel has restarted.
|
|
92
|
-
*
|
|
93
|
-
* #### Notes
|
|
94
|
-
* If there is a running kernel, present a dialog.
|
|
95
|
-
* If there is no kernel, we start a kernel with the last run
|
|
96
|
-
* kernel name and resolves with `true`. If no kernel has been started,
|
|
97
|
-
* this is a no-op, and resolves with `false`.
|
|
98
|
-
*/
|
|
99
|
-
restart(): Promise<boolean>;
|
|
100
|
-
/**
|
|
101
|
-
* Change the session path.
|
|
102
|
-
*
|
|
103
|
-
* @param path - The new session path.
|
|
104
|
-
*
|
|
105
|
-
* @returns A promise that resolves when the session has renamed.
|
|
106
|
-
*
|
|
107
|
-
* #### Notes
|
|
108
|
-
* This uses the Jupyter REST API, and the response is validated.
|
|
109
|
-
* The promise is fulfilled on a valid response and rejected otherwise.
|
|
110
|
-
*/
|
|
111
|
-
setPath(path: string): Promise<void>;
|
|
112
|
-
/**
|
|
113
|
-
* Change the session name.
|
|
114
|
-
*/
|
|
115
|
-
setName(name: string): Promise<void>;
|
|
116
|
-
/**
|
|
117
|
-
* Change the session type.
|
|
118
|
-
*/
|
|
119
|
-
setType(type: string): Promise<void>;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* The namespace for Client Session related interfaces.
|
|
123
|
-
*/
|
|
124
|
-
export declare namespace IClientSession {
|
|
125
|
-
/**
|
|
126
|
-
* A kernel preference.
|
|
127
|
-
*/
|
|
128
|
-
interface IKernelPreference {
|
|
129
|
-
/**
|
|
130
|
-
* The name of the kernel.
|
|
131
|
-
*/
|
|
132
|
-
readonly name?: string;
|
|
133
|
-
/**
|
|
134
|
-
* The preferred kernel language.
|
|
135
|
-
*/
|
|
136
|
-
readonly language?: string;
|
|
137
|
-
/**
|
|
138
|
-
* The id of an existing kernel.
|
|
139
|
-
*/
|
|
140
|
-
readonly id?: string;
|
|
141
|
-
/**
|
|
142
|
-
* Whether to prefer starting a kernel.
|
|
143
|
-
*/
|
|
144
|
-
readonly shouldStart?: boolean;
|
|
145
|
-
/**
|
|
146
|
-
* Whether a kernel can be started.
|
|
147
|
-
*/
|
|
148
|
-
readonly canStart?: boolean;
|
|
149
|
-
/**
|
|
150
|
-
* Whether to auto-start the default kernel if no matching kernel is found.
|
|
151
|
-
*/
|
|
152
|
-
readonly autoStartDefault?: boolean;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* The default implementation of client session object.
|
|
157
|
-
*/
|
|
158
|
-
export declare class ClientSession implements IClientSession {
|
|
159
|
-
/**
|
|
160
|
-
* Construct a new client session.
|
|
161
|
-
*/
|
|
162
|
-
constructor(options: ClientSession.IOptions);
|
|
163
|
-
/**
|
|
164
|
-
* A signal emitted when the session is shut down.
|
|
165
|
-
*/
|
|
166
|
-
readonly terminated: ISignal<this, void>;
|
|
167
|
-
/**
|
|
168
|
-
* A signal emitted when the kernel changes.
|
|
169
|
-
*/
|
|
170
|
-
readonly kernelChanged: ISignal<this, Session.IKernelChangedArgs>;
|
|
171
|
-
/**
|
|
172
|
-
* A signal emitted when the status changes.
|
|
173
|
-
*/
|
|
174
|
-
readonly statusChanged: ISignal<this, Kernel.Status>;
|
|
175
|
-
/**
|
|
176
|
-
* A signal emitted for iopub kernel messages.
|
|
177
|
-
*/
|
|
178
|
-
readonly iopubMessage: ISignal<this, KernelMessage.IMessage>;
|
|
179
|
-
/**
|
|
180
|
-
* A signal emitted for an unhandled kernel message.
|
|
181
|
-
*/
|
|
182
|
-
readonly unhandledMessage: ISignal<this, KernelMessage.IMessage>;
|
|
183
|
-
/**
|
|
184
|
-
* A signal emitted when a session property changes.
|
|
185
|
-
*/
|
|
186
|
-
readonly propertyChanged: ISignal<this, 'path' | 'name' | 'type'>;
|
|
187
|
-
/**
|
|
188
|
-
* The current kernel of the session.
|
|
189
|
-
*/
|
|
190
|
-
readonly kernel: Kernel.IKernelConnection | null;
|
|
191
|
-
/**
|
|
192
|
-
* The current path of the session.
|
|
193
|
-
*/
|
|
194
|
-
readonly path: string;
|
|
195
|
-
/**
|
|
196
|
-
* The current name of the session.
|
|
197
|
-
*/
|
|
198
|
-
readonly name: string;
|
|
199
|
-
/**
|
|
200
|
-
* The type of the client session.
|
|
201
|
-
*/
|
|
202
|
-
readonly type: string;
|
|
203
|
-
/**
|
|
204
|
-
* The kernel preference of the session.
|
|
205
|
-
*/
|
|
206
|
-
kernelPreference: IClientSession.IKernelPreference;
|
|
207
|
-
/**
|
|
208
|
-
* The session manager used by the session.
|
|
209
|
-
*/
|
|
210
|
-
readonly manager: Session.IManager;
|
|
211
|
-
/**
|
|
212
|
-
* The current status of the session.
|
|
213
|
-
*/
|
|
214
|
-
readonly status: Kernel.Status;
|
|
215
|
-
/**
|
|
216
|
-
* Whether the session is ready.
|
|
217
|
-
*/
|
|
218
|
-
readonly isReady: boolean;
|
|
219
|
-
/**
|
|
220
|
-
* A promise that is fulfilled when the session is ready.
|
|
221
|
-
*/
|
|
222
|
-
readonly ready: Promise<void>;
|
|
223
|
-
/**
|
|
224
|
-
* The display name of the current kernel.
|
|
225
|
-
*/
|
|
226
|
-
readonly kernelDisplayName: string;
|
|
227
|
-
/**
|
|
228
|
-
* Test whether the context is disposed.
|
|
229
|
-
*/
|
|
230
|
-
readonly isDisposed: boolean;
|
|
231
|
-
/**
|
|
232
|
-
* Dispose of the resources held by the context.
|
|
233
|
-
*/
|
|
234
|
-
dispose(): void;
|
|
235
|
-
/**
|
|
236
|
-
* Change the current kernel associated with the document.
|
|
237
|
-
*/
|
|
238
|
-
changeKernel(options: Partial<Kernel.IModel>): Promise<Kernel.IKernelConnection>;
|
|
239
|
-
/**
|
|
240
|
-
* Select a kernel for the session.
|
|
241
|
-
*/
|
|
242
|
-
selectKernel(): Promise<void>;
|
|
243
|
-
/**
|
|
244
|
-
* Kill the kernel and shutdown the session.
|
|
245
|
-
*
|
|
246
|
-
* @returns A promise that resolves when the session is shut down.
|
|
247
|
-
*/
|
|
248
|
-
shutdown(): Promise<void>;
|
|
249
|
-
/**
|
|
250
|
-
* Restart the session.
|
|
251
|
-
*
|
|
252
|
-
* @returns A promise that resolves with whether the kernel has restarted.
|
|
253
|
-
*
|
|
254
|
-
* #### Notes
|
|
255
|
-
* If there is a running kernel, present a dialog.
|
|
256
|
-
* If there is no kernel, we start a kernel with the last run
|
|
257
|
-
* kernel name and resolves with `true`.
|
|
258
|
-
*/
|
|
259
|
-
restart(): Promise<boolean>;
|
|
260
|
-
/**
|
|
261
|
-
* Change the session path.
|
|
262
|
-
*
|
|
263
|
-
* @param path - The new session path.
|
|
264
|
-
*
|
|
265
|
-
* @returns A promise that resolves when the session has renamed.
|
|
266
|
-
*
|
|
267
|
-
* #### Notes
|
|
268
|
-
* This uses the Jupyter REST API, and the response is validated.
|
|
269
|
-
* The promise is fulfilled on a valid response and rejected otherwise.
|
|
270
|
-
*/
|
|
271
|
-
setPath(path: string): Promise<void>;
|
|
272
|
-
/**
|
|
273
|
-
* Change the session name.
|
|
274
|
-
*/
|
|
275
|
-
setName(name: string): Promise<void>;
|
|
276
|
-
/**
|
|
277
|
-
* Change the session type.
|
|
278
|
-
*/
|
|
279
|
-
setType(type: string): Promise<void>;
|
|
280
|
-
/**
|
|
281
|
-
* Initialize the session.
|
|
282
|
-
*
|
|
283
|
-
* #### Notes
|
|
284
|
-
* If a server session exists on the current path, we will connect to it.
|
|
285
|
-
* If preferences include disabling `canStart` or `shouldStart`, no
|
|
286
|
-
* server session will be started.
|
|
287
|
-
* If a kernel id is given, we attempt to start a session with that id.
|
|
288
|
-
* If a default kernel is available, we connect to it.
|
|
289
|
-
* Otherwise we ask the user to select a kernel.
|
|
290
|
-
*/
|
|
291
|
-
initialize(): Promise<void>;
|
|
292
|
-
/**
|
|
293
|
-
* Start the session if necessary.
|
|
294
|
-
*/
|
|
295
|
-
private _startIfNecessary;
|
|
296
|
-
/**
|
|
297
|
-
* Change the kernel.
|
|
298
|
-
*/
|
|
299
|
-
private _changeKernel;
|
|
300
|
-
/**
|
|
301
|
-
* Select a kernel.
|
|
302
|
-
*
|
|
303
|
-
* @param cancelable: whether the dialog should have a cancel button.
|
|
304
|
-
*/
|
|
305
|
-
private _selectKernel;
|
|
306
|
-
/**
|
|
307
|
-
* Start a session and set up its signals.
|
|
308
|
-
*/
|
|
309
|
-
private _startSession;
|
|
310
|
-
/**
|
|
311
|
-
* Handle a new session object.
|
|
312
|
-
*/
|
|
313
|
-
private _handleNewSession;
|
|
314
|
-
/**
|
|
315
|
-
* Handle an error in session startup.
|
|
316
|
-
*/
|
|
317
|
-
private _handleSessionError;
|
|
318
|
-
/**
|
|
319
|
-
* Handle a session termination.
|
|
320
|
-
*/
|
|
321
|
-
private _onTerminated;
|
|
322
|
-
/**
|
|
323
|
-
* Handle a change to a session property.
|
|
324
|
-
*/
|
|
325
|
-
private _onPropertyChanged;
|
|
326
|
-
/**
|
|
327
|
-
* Handle a change to the kernel.
|
|
328
|
-
*/
|
|
329
|
-
private _onKernelChanged;
|
|
330
|
-
/**
|
|
331
|
-
* Handle a change to the session status.
|
|
332
|
-
*/
|
|
333
|
-
private _onStatusChanged;
|
|
334
|
-
/**
|
|
335
|
-
* Handle an iopub message.
|
|
336
|
-
*/
|
|
337
|
-
private _onIopubMessage;
|
|
338
|
-
/**
|
|
339
|
-
* Handle an unhandled message.
|
|
340
|
-
*/
|
|
341
|
-
private _onUnhandledMessage;
|
|
342
|
-
private _path;
|
|
343
|
-
private _name;
|
|
344
|
-
private _type;
|
|
345
|
-
private _prevKernelName;
|
|
346
|
-
private _kernelPreference;
|
|
347
|
-
private _isDisposed;
|
|
348
|
-
private _session;
|
|
349
|
-
private _ready;
|
|
350
|
-
private _initializing;
|
|
351
|
-
private _isReady;
|
|
352
|
-
private _terminated;
|
|
353
|
-
private _kernelChanged;
|
|
354
|
-
private _statusChanged;
|
|
355
|
-
private _iopubMessage;
|
|
356
|
-
private _unhandledMessage;
|
|
357
|
-
private _propertyChanged;
|
|
358
|
-
private _dialog;
|
|
359
|
-
private _setBusy;
|
|
360
|
-
private _busyDisposable;
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* A namespace for `ClientSession` statics.
|
|
364
|
-
*/
|
|
365
|
-
export declare namespace ClientSession {
|
|
366
|
-
/**
|
|
367
|
-
* The options used to initialize a context.
|
|
368
|
-
*/
|
|
369
|
-
interface IOptions {
|
|
370
|
-
/**
|
|
371
|
-
* A session manager instance.
|
|
372
|
-
*/
|
|
373
|
-
manager: Session.IManager;
|
|
374
|
-
/**
|
|
375
|
-
* The initial path of the file.
|
|
376
|
-
*/
|
|
377
|
-
path?: string;
|
|
378
|
-
/**
|
|
379
|
-
* The name of the session.
|
|
380
|
-
*/
|
|
381
|
-
name?: string;
|
|
382
|
-
/**
|
|
383
|
-
* The type of the session.
|
|
384
|
-
*/
|
|
385
|
-
type?: string;
|
|
386
|
-
/**
|
|
387
|
-
* A kernel preference.
|
|
388
|
-
*/
|
|
389
|
-
kernelPreference?: IClientSession.IKernelPreference;
|
|
390
|
-
/**
|
|
391
|
-
* A function to call when the session becomes busy.
|
|
392
|
-
*/
|
|
393
|
-
setBusy?: () => IDisposable;
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Restart a kernel if the user accepts the risk.
|
|
397
|
-
*
|
|
398
|
-
* Returns a promise resolving with whether the kernel was restarted.
|
|
399
|
-
*/
|
|
400
|
-
function restartKernel(kernel: Kernel.IKernelConnection): Promise<boolean>;
|
|
401
|
-
/**
|
|
402
|
-
* An interface for populating a kernel selector.
|
|
403
|
-
*/
|
|
404
|
-
interface IKernelSearch {
|
|
405
|
-
/**
|
|
406
|
-
* The Kernel specs.
|
|
407
|
-
*/
|
|
408
|
-
specs: Kernel.ISpecModels | null;
|
|
409
|
-
/**
|
|
410
|
-
* The kernel preference.
|
|
411
|
-
*/
|
|
412
|
-
preference: IClientSession.IKernelPreference;
|
|
413
|
-
/**
|
|
414
|
-
* The current running sessions.
|
|
415
|
-
*/
|
|
416
|
-
sessions?: IterableOrArrayLike<Session.IModel>;
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
|
-
* Get the default kernel name given select options.
|
|
420
|
-
*/
|
|
421
|
-
function getDefaultKernel(options: IKernelSearch): string | null;
|
|
422
|
-
/**
|
|
423
|
-
* Populate a kernel dropdown list.
|
|
424
|
-
*
|
|
425
|
-
* @param node - The node to populate.
|
|
426
|
-
*
|
|
427
|
-
* @param options - The options used to populate the kernels.
|
|
428
|
-
*
|
|
429
|
-
* #### Notes
|
|
430
|
-
* Populates the list with separated sections:
|
|
431
|
-
* - Kernels matching the preferred language (display names).
|
|
432
|
-
* - "None" signifying no kernel.
|
|
433
|
-
* - The remaining kernels.
|
|
434
|
-
* - Sessions matching the preferred language (file names).
|
|
435
|
-
* - The remaining sessions.
|
|
436
|
-
* If no preferred language is given or no kernels are found using
|
|
437
|
-
* the preferred language, the default kernel is used in the first
|
|
438
|
-
* section. Kernels are sorted by display name. Sessions display the
|
|
439
|
-
* base name of the file with an ellipsis overflow and a tooltip with
|
|
440
|
-
* the explicit session information.
|
|
441
|
-
*/
|
|
442
|
-
function populateKernelSelect(node: HTMLSelectElement, options: IKernelSearch): void;
|
|
443
|
-
}
|
|
1
|
+
import { Kernel, KernelMessage, Session } from '@jupyterlab/services';
|
|
2
|
+
import { IterableOrArrayLike } from '@phosphor/algorithm';
|
|
3
|
+
import { IDisposable } from '@phosphor/disposable';
|
|
4
|
+
import { ISignal } from '@phosphor/signaling';
|
|
5
|
+
/**
|
|
6
|
+
* The interface of client session object.
|
|
7
|
+
*
|
|
8
|
+
* The client session represents the link between
|
|
9
|
+
* a path and its kernel for the duration of the lifetime
|
|
10
|
+
* of the session object. The session can have no current
|
|
11
|
+
* kernel, and can start a new kernel at any time.
|
|
12
|
+
*/
|
|
13
|
+
export interface IClientSession extends IDisposable {
|
|
14
|
+
/**
|
|
15
|
+
* A signal emitted when the session is shut down.
|
|
16
|
+
*/
|
|
17
|
+
readonly terminated: ISignal<this, void>;
|
|
18
|
+
/**
|
|
19
|
+
* A signal emitted when the kernel changes.
|
|
20
|
+
*/
|
|
21
|
+
readonly kernelChanged: ISignal<this, Session.IKernelChangedArgs>;
|
|
22
|
+
/**
|
|
23
|
+
* A signal emitted when the kernel status changes.
|
|
24
|
+
*/
|
|
25
|
+
readonly statusChanged: ISignal<this, Kernel.Status>;
|
|
26
|
+
/**
|
|
27
|
+
* A signal emitted for a kernel messages.
|
|
28
|
+
*/
|
|
29
|
+
readonly iopubMessage: ISignal<this, KernelMessage.IMessage>;
|
|
30
|
+
/**
|
|
31
|
+
* A signal emitted for an unhandled kernel message.
|
|
32
|
+
*/
|
|
33
|
+
readonly unhandledMessage: ISignal<this, KernelMessage.IMessage>;
|
|
34
|
+
/**
|
|
35
|
+
* A signal emitted when a session property changes.
|
|
36
|
+
*/
|
|
37
|
+
readonly propertyChanged: ISignal<this, 'path' | 'name' | 'type'>;
|
|
38
|
+
/**
|
|
39
|
+
* The current kernel associated with the document.
|
|
40
|
+
*/
|
|
41
|
+
readonly kernel: Kernel.IKernelConnection | null;
|
|
42
|
+
/**
|
|
43
|
+
* The current path associated with the client session.
|
|
44
|
+
*/
|
|
45
|
+
readonly path: string;
|
|
46
|
+
/**
|
|
47
|
+
* The current name associated with the client session.
|
|
48
|
+
*/
|
|
49
|
+
readonly name: string;
|
|
50
|
+
/**
|
|
51
|
+
* The type of the client session.
|
|
52
|
+
*/
|
|
53
|
+
readonly type: string;
|
|
54
|
+
/**
|
|
55
|
+
* The current status of the client session.
|
|
56
|
+
*/
|
|
57
|
+
readonly status: Kernel.Status;
|
|
58
|
+
/**
|
|
59
|
+
* Whether the session is ready.
|
|
60
|
+
*/
|
|
61
|
+
readonly isReady: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* A promise that is fulfilled when the session is ready.
|
|
64
|
+
*/
|
|
65
|
+
readonly ready: Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* The kernel preference.
|
|
68
|
+
*/
|
|
69
|
+
kernelPreference: IClientSession.IKernelPreference;
|
|
70
|
+
/**
|
|
71
|
+
* The display name of the kernel.
|
|
72
|
+
*/
|
|
73
|
+
readonly kernelDisplayName: string;
|
|
74
|
+
/**
|
|
75
|
+
* Change the current kernel associated with the document.
|
|
76
|
+
*/
|
|
77
|
+
changeKernel(options: Partial<Kernel.IModel>): Promise<Kernel.IKernelConnection>;
|
|
78
|
+
/**
|
|
79
|
+
* Kill the kernel and shutdown the session.
|
|
80
|
+
*
|
|
81
|
+
* @returns A promise that resolves when the session is shut down.
|
|
82
|
+
*/
|
|
83
|
+
shutdown(): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Select a kernel for the session.
|
|
86
|
+
*/
|
|
87
|
+
selectKernel(): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Restart the session.
|
|
90
|
+
*
|
|
91
|
+
* @returns A promise that resolves with whether the kernel has restarted.
|
|
92
|
+
*
|
|
93
|
+
* #### Notes
|
|
94
|
+
* If there is a running kernel, present a dialog.
|
|
95
|
+
* If there is no kernel, we start a kernel with the last run
|
|
96
|
+
* kernel name and resolves with `true`. If no kernel has been started,
|
|
97
|
+
* this is a no-op, and resolves with `false`.
|
|
98
|
+
*/
|
|
99
|
+
restart(): Promise<boolean>;
|
|
100
|
+
/**
|
|
101
|
+
* Change the session path.
|
|
102
|
+
*
|
|
103
|
+
* @param path - The new session path.
|
|
104
|
+
*
|
|
105
|
+
* @returns A promise that resolves when the session has renamed.
|
|
106
|
+
*
|
|
107
|
+
* #### Notes
|
|
108
|
+
* This uses the Jupyter REST API, and the response is validated.
|
|
109
|
+
* The promise is fulfilled on a valid response and rejected otherwise.
|
|
110
|
+
*/
|
|
111
|
+
setPath(path: string): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Change the session name.
|
|
114
|
+
*/
|
|
115
|
+
setName(name: string): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Change the session type.
|
|
118
|
+
*/
|
|
119
|
+
setType(type: string): Promise<void>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The namespace for Client Session related interfaces.
|
|
123
|
+
*/
|
|
124
|
+
export declare namespace IClientSession {
|
|
125
|
+
/**
|
|
126
|
+
* A kernel preference.
|
|
127
|
+
*/
|
|
128
|
+
interface IKernelPreference {
|
|
129
|
+
/**
|
|
130
|
+
* The name of the kernel.
|
|
131
|
+
*/
|
|
132
|
+
readonly name?: string;
|
|
133
|
+
/**
|
|
134
|
+
* The preferred kernel language.
|
|
135
|
+
*/
|
|
136
|
+
readonly language?: string;
|
|
137
|
+
/**
|
|
138
|
+
* The id of an existing kernel.
|
|
139
|
+
*/
|
|
140
|
+
readonly id?: string;
|
|
141
|
+
/**
|
|
142
|
+
* Whether to prefer starting a kernel.
|
|
143
|
+
*/
|
|
144
|
+
readonly shouldStart?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Whether a kernel can be started.
|
|
147
|
+
*/
|
|
148
|
+
readonly canStart?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Whether to auto-start the default kernel if no matching kernel is found.
|
|
151
|
+
*/
|
|
152
|
+
readonly autoStartDefault?: boolean;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* The default implementation of client session object.
|
|
157
|
+
*/
|
|
158
|
+
export declare class ClientSession implements IClientSession {
|
|
159
|
+
/**
|
|
160
|
+
* Construct a new client session.
|
|
161
|
+
*/
|
|
162
|
+
constructor(options: ClientSession.IOptions);
|
|
163
|
+
/**
|
|
164
|
+
* A signal emitted when the session is shut down.
|
|
165
|
+
*/
|
|
166
|
+
readonly terminated: ISignal<this, void>;
|
|
167
|
+
/**
|
|
168
|
+
* A signal emitted when the kernel changes.
|
|
169
|
+
*/
|
|
170
|
+
readonly kernelChanged: ISignal<this, Session.IKernelChangedArgs>;
|
|
171
|
+
/**
|
|
172
|
+
* A signal emitted when the status changes.
|
|
173
|
+
*/
|
|
174
|
+
readonly statusChanged: ISignal<this, Kernel.Status>;
|
|
175
|
+
/**
|
|
176
|
+
* A signal emitted for iopub kernel messages.
|
|
177
|
+
*/
|
|
178
|
+
readonly iopubMessage: ISignal<this, KernelMessage.IMessage>;
|
|
179
|
+
/**
|
|
180
|
+
* A signal emitted for an unhandled kernel message.
|
|
181
|
+
*/
|
|
182
|
+
readonly unhandledMessage: ISignal<this, KernelMessage.IMessage>;
|
|
183
|
+
/**
|
|
184
|
+
* A signal emitted when a session property changes.
|
|
185
|
+
*/
|
|
186
|
+
readonly propertyChanged: ISignal<this, 'path' | 'name' | 'type'>;
|
|
187
|
+
/**
|
|
188
|
+
* The current kernel of the session.
|
|
189
|
+
*/
|
|
190
|
+
readonly kernel: Kernel.IKernelConnection | null;
|
|
191
|
+
/**
|
|
192
|
+
* The current path of the session.
|
|
193
|
+
*/
|
|
194
|
+
readonly path: string;
|
|
195
|
+
/**
|
|
196
|
+
* The current name of the session.
|
|
197
|
+
*/
|
|
198
|
+
readonly name: string;
|
|
199
|
+
/**
|
|
200
|
+
* The type of the client session.
|
|
201
|
+
*/
|
|
202
|
+
readonly type: string;
|
|
203
|
+
/**
|
|
204
|
+
* The kernel preference of the session.
|
|
205
|
+
*/
|
|
206
|
+
kernelPreference: IClientSession.IKernelPreference;
|
|
207
|
+
/**
|
|
208
|
+
* The session manager used by the session.
|
|
209
|
+
*/
|
|
210
|
+
readonly manager: Session.IManager;
|
|
211
|
+
/**
|
|
212
|
+
* The current status of the session.
|
|
213
|
+
*/
|
|
214
|
+
readonly status: Kernel.Status;
|
|
215
|
+
/**
|
|
216
|
+
* Whether the session is ready.
|
|
217
|
+
*/
|
|
218
|
+
readonly isReady: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* A promise that is fulfilled when the session is ready.
|
|
221
|
+
*/
|
|
222
|
+
readonly ready: Promise<void>;
|
|
223
|
+
/**
|
|
224
|
+
* The display name of the current kernel.
|
|
225
|
+
*/
|
|
226
|
+
readonly kernelDisplayName: string;
|
|
227
|
+
/**
|
|
228
|
+
* Test whether the context is disposed.
|
|
229
|
+
*/
|
|
230
|
+
readonly isDisposed: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Dispose of the resources held by the context.
|
|
233
|
+
*/
|
|
234
|
+
dispose(): void;
|
|
235
|
+
/**
|
|
236
|
+
* Change the current kernel associated with the document.
|
|
237
|
+
*/
|
|
238
|
+
changeKernel(options: Partial<Kernel.IModel>): Promise<Kernel.IKernelConnection>;
|
|
239
|
+
/**
|
|
240
|
+
* Select a kernel for the session.
|
|
241
|
+
*/
|
|
242
|
+
selectKernel(): Promise<void>;
|
|
243
|
+
/**
|
|
244
|
+
* Kill the kernel and shutdown the session.
|
|
245
|
+
*
|
|
246
|
+
* @returns A promise that resolves when the session is shut down.
|
|
247
|
+
*/
|
|
248
|
+
shutdown(): Promise<void>;
|
|
249
|
+
/**
|
|
250
|
+
* Restart the session.
|
|
251
|
+
*
|
|
252
|
+
* @returns A promise that resolves with whether the kernel has restarted.
|
|
253
|
+
*
|
|
254
|
+
* #### Notes
|
|
255
|
+
* If there is a running kernel, present a dialog.
|
|
256
|
+
* If there is no kernel, we start a kernel with the last run
|
|
257
|
+
* kernel name and resolves with `true`.
|
|
258
|
+
*/
|
|
259
|
+
restart(): Promise<boolean>;
|
|
260
|
+
/**
|
|
261
|
+
* Change the session path.
|
|
262
|
+
*
|
|
263
|
+
* @param path - The new session path.
|
|
264
|
+
*
|
|
265
|
+
* @returns A promise that resolves when the session has renamed.
|
|
266
|
+
*
|
|
267
|
+
* #### Notes
|
|
268
|
+
* This uses the Jupyter REST API, and the response is validated.
|
|
269
|
+
* The promise is fulfilled on a valid response and rejected otherwise.
|
|
270
|
+
*/
|
|
271
|
+
setPath(path: string): Promise<void>;
|
|
272
|
+
/**
|
|
273
|
+
* Change the session name.
|
|
274
|
+
*/
|
|
275
|
+
setName(name: string): Promise<void>;
|
|
276
|
+
/**
|
|
277
|
+
* Change the session type.
|
|
278
|
+
*/
|
|
279
|
+
setType(type: string): Promise<void>;
|
|
280
|
+
/**
|
|
281
|
+
* Initialize the session.
|
|
282
|
+
*
|
|
283
|
+
* #### Notes
|
|
284
|
+
* If a server session exists on the current path, we will connect to it.
|
|
285
|
+
* If preferences include disabling `canStart` or `shouldStart`, no
|
|
286
|
+
* server session will be started.
|
|
287
|
+
* If a kernel id is given, we attempt to start a session with that id.
|
|
288
|
+
* If a default kernel is available, we connect to it.
|
|
289
|
+
* Otherwise we ask the user to select a kernel.
|
|
290
|
+
*/
|
|
291
|
+
initialize(): Promise<void>;
|
|
292
|
+
/**
|
|
293
|
+
* Start the session if necessary.
|
|
294
|
+
*/
|
|
295
|
+
private _startIfNecessary;
|
|
296
|
+
/**
|
|
297
|
+
* Change the kernel.
|
|
298
|
+
*/
|
|
299
|
+
private _changeKernel;
|
|
300
|
+
/**
|
|
301
|
+
* Select a kernel.
|
|
302
|
+
*
|
|
303
|
+
* @param cancelable: whether the dialog should have a cancel button.
|
|
304
|
+
*/
|
|
305
|
+
private _selectKernel;
|
|
306
|
+
/**
|
|
307
|
+
* Start a session and set up its signals.
|
|
308
|
+
*/
|
|
309
|
+
private _startSession;
|
|
310
|
+
/**
|
|
311
|
+
* Handle a new session object.
|
|
312
|
+
*/
|
|
313
|
+
private _handleNewSession;
|
|
314
|
+
/**
|
|
315
|
+
* Handle an error in session startup.
|
|
316
|
+
*/
|
|
317
|
+
private _handleSessionError;
|
|
318
|
+
/**
|
|
319
|
+
* Handle a session termination.
|
|
320
|
+
*/
|
|
321
|
+
private _onTerminated;
|
|
322
|
+
/**
|
|
323
|
+
* Handle a change to a session property.
|
|
324
|
+
*/
|
|
325
|
+
private _onPropertyChanged;
|
|
326
|
+
/**
|
|
327
|
+
* Handle a change to the kernel.
|
|
328
|
+
*/
|
|
329
|
+
private _onKernelChanged;
|
|
330
|
+
/**
|
|
331
|
+
* Handle a change to the session status.
|
|
332
|
+
*/
|
|
333
|
+
private _onStatusChanged;
|
|
334
|
+
/**
|
|
335
|
+
* Handle an iopub message.
|
|
336
|
+
*/
|
|
337
|
+
private _onIopubMessage;
|
|
338
|
+
/**
|
|
339
|
+
* Handle an unhandled message.
|
|
340
|
+
*/
|
|
341
|
+
private _onUnhandledMessage;
|
|
342
|
+
private _path;
|
|
343
|
+
private _name;
|
|
344
|
+
private _type;
|
|
345
|
+
private _prevKernelName;
|
|
346
|
+
private _kernelPreference;
|
|
347
|
+
private _isDisposed;
|
|
348
|
+
private _session;
|
|
349
|
+
private _ready;
|
|
350
|
+
private _initializing;
|
|
351
|
+
private _isReady;
|
|
352
|
+
private _terminated;
|
|
353
|
+
private _kernelChanged;
|
|
354
|
+
private _statusChanged;
|
|
355
|
+
private _iopubMessage;
|
|
356
|
+
private _unhandledMessage;
|
|
357
|
+
private _propertyChanged;
|
|
358
|
+
private _dialog;
|
|
359
|
+
private _setBusy;
|
|
360
|
+
private _busyDisposable;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* A namespace for `ClientSession` statics.
|
|
364
|
+
*/
|
|
365
|
+
export declare namespace ClientSession {
|
|
366
|
+
/**
|
|
367
|
+
* The options used to initialize a context.
|
|
368
|
+
*/
|
|
369
|
+
interface IOptions {
|
|
370
|
+
/**
|
|
371
|
+
* A session manager instance.
|
|
372
|
+
*/
|
|
373
|
+
manager: Session.IManager;
|
|
374
|
+
/**
|
|
375
|
+
* The initial path of the file.
|
|
376
|
+
*/
|
|
377
|
+
path?: string;
|
|
378
|
+
/**
|
|
379
|
+
* The name of the session.
|
|
380
|
+
*/
|
|
381
|
+
name?: string;
|
|
382
|
+
/**
|
|
383
|
+
* The type of the session.
|
|
384
|
+
*/
|
|
385
|
+
type?: string;
|
|
386
|
+
/**
|
|
387
|
+
* A kernel preference.
|
|
388
|
+
*/
|
|
389
|
+
kernelPreference?: IClientSession.IKernelPreference;
|
|
390
|
+
/**
|
|
391
|
+
* A function to call when the session becomes busy.
|
|
392
|
+
*/
|
|
393
|
+
setBusy?: () => IDisposable;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Restart a kernel if the user accepts the risk.
|
|
397
|
+
*
|
|
398
|
+
* Returns a promise resolving with whether the kernel was restarted.
|
|
399
|
+
*/
|
|
400
|
+
function restartKernel(kernel: Kernel.IKernelConnection): Promise<boolean>;
|
|
401
|
+
/**
|
|
402
|
+
* An interface for populating a kernel selector.
|
|
403
|
+
*/
|
|
404
|
+
interface IKernelSearch {
|
|
405
|
+
/**
|
|
406
|
+
* The Kernel specs.
|
|
407
|
+
*/
|
|
408
|
+
specs: Kernel.ISpecModels | null;
|
|
409
|
+
/**
|
|
410
|
+
* The kernel preference.
|
|
411
|
+
*/
|
|
412
|
+
preference: IClientSession.IKernelPreference;
|
|
413
|
+
/**
|
|
414
|
+
* The current running sessions.
|
|
415
|
+
*/
|
|
416
|
+
sessions?: IterableOrArrayLike<Session.IModel>;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Get the default kernel name given select options.
|
|
420
|
+
*/
|
|
421
|
+
function getDefaultKernel(options: IKernelSearch): string | null;
|
|
422
|
+
/**
|
|
423
|
+
* Populate a kernel dropdown list.
|
|
424
|
+
*
|
|
425
|
+
* @param node - The node to populate.
|
|
426
|
+
*
|
|
427
|
+
* @param options - The options used to populate the kernels.
|
|
428
|
+
*
|
|
429
|
+
* #### Notes
|
|
430
|
+
* Populates the list with separated sections:
|
|
431
|
+
* - Kernels matching the preferred language (display names).
|
|
432
|
+
* - "None" signifying no kernel.
|
|
433
|
+
* - The remaining kernels.
|
|
434
|
+
* - Sessions matching the preferred language (file names).
|
|
435
|
+
* - The remaining sessions.
|
|
436
|
+
* If no preferred language is given or no kernels are found using
|
|
437
|
+
* the preferred language, the default kernel is used in the first
|
|
438
|
+
* section. Kernels are sorted by display name. Sessions display the
|
|
439
|
+
* base name of the file with an ellipsis overflow and a tooltip with
|
|
440
|
+
* the explicit session information.
|
|
441
|
+
*/
|
|
442
|
+
function populateKernelSelect(node: HTMLSelectElement, options: IKernelSearch): void;
|
|
443
|
+
}
|