UNPKG

1.59 kBJavaScriptView Raw
1/*
2 * Copyright (c) Jupyter Development Team.
3 * Distributed under the terms of the Modified BSD License.
4 */
5import { ServiceManager } from '@jupyterlab/services';
6import { UUID } from '@lumino/coreutils';
7import { SessionContext } from './sessioncontext';
8/**
9 * Create a client session object.
10 */
11export async function createSessionContext(options = {}) {
12 var _a, _b, _c, _d, _e;
13 const manager = (_a = options.sessionManager) !== null && _a !== void 0 ? _a : Private.getManager().sessions;
14 const specsManager = (_b = options.specsManager) !== null && _b !== void 0 ? _b : Private.getManager().kernelspecs;
15 await Promise.all([manager.ready, specsManager.ready]);
16 return new SessionContext({
17 sessionManager: manager,
18 specsManager,
19 path: (_c = options.path) !== null && _c !== void 0 ? _c : UUID.uuid4(),
20 name: options.name,
21 type: options.type,
22 kernelPreference: (_d = options.kernelPreference) !== null && _d !== void 0 ? _d : {
23 shouldStart: true,
24 canStart: true,
25 name: (_e = specsManager.specs) === null || _e === void 0 ? void 0 : _e.default
26 }
27 });
28}
29/**
30 * A namespace for private data.
31 */
32var Private;
33(function (Private) {
34 let manager;
35 /**
36 * Get or create the service manager singleton.
37 */
38 function getManager() {
39 if (!manager) {
40 manager = new ServiceManager({ standby: 'never' });
41 }
42 return manager;
43 }
44 Private.getManager = getManager;
45})(Private || (Private = {}));
46//# sourceMappingURL=testutils.js.map
\No newline at end of file