1 | "use strict";
|
2 |
|
3 |
|
4 | Object.defineProperty(exports, "__esModule", { value: true });
|
5 | exports.ServiceManager = void 0;
|
6 | const signaling_1 = require("@lumino/signaling");
|
7 | const builder_1 = require("./builder");
|
8 | const contents_1 = require("./contents");
|
9 | const event_1 = require("./event");
|
10 | const kernel_1 = require("./kernel");
|
11 | const kernelspec_1 = require("./kernelspec");
|
12 | const nbconvert_1 = require("./nbconvert");
|
13 | const serverconnection_1 = require("./serverconnection");
|
14 | const session_1 = require("./session");
|
15 | const setting_1 = require("./setting");
|
16 | const terminal_1 = require("./terminal");
|
17 | const user_1 = require("./user");
|
18 | const workspace_1 = require("./workspace");
|
19 |
|
20 |
|
21 |
|
22 | class ServiceManager {
|
23 | |
24 |
|
25 |
|
26 | constructor(options = {}) {
|
27 | var _a, _b;
|
28 | this._isDisposed = false;
|
29 | this._connectionFailure = new signaling_1.Signal(this);
|
30 | this._isReady = false;
|
31 | const defaultDrive = options.defaultDrive;
|
32 | const serverSettings = (_a = options.serverSettings) !== null && _a !== void 0 ? _a : serverconnection_1.ServerConnection.makeSettings();
|
33 | const standby = (_b = options.standby) !== null && _b !== void 0 ? _b : 'when-hidden';
|
34 | const normalized = { defaultDrive, serverSettings, standby };
|
35 | this.serverSettings = serverSettings;
|
36 | this.contents = options.contents || new contents_1.ContentsManager(normalized);
|
37 | this.events = options.events || new event_1.EventManager(normalized);
|
38 | this.kernels = options.kernels || new kernel_1.KernelManager(normalized);
|
39 | this.sessions =
|
40 | options.sessions ||
|
41 | new session_1.SessionManager({
|
42 | ...normalized,
|
43 | kernelManager: this.kernels
|
44 | });
|
45 | this.settings = options.settings || new setting_1.SettingManager(normalized);
|
46 | this.terminals = options.terminals || new terminal_1.TerminalManager(normalized);
|
47 | this.builder = options.builder || new builder_1.BuildManager(normalized);
|
48 | this.workspaces = options.workspaces || new workspace_1.WorkspaceManager(normalized);
|
49 | this.nbconvert = options.nbconvert || new nbconvert_1.NbConvertManager(normalized);
|
50 | this.kernelspecs = options.kernelspecs || new kernelspec_1.KernelSpecManager(normalized);
|
51 | this.user = options.user || new user_1.UserManager(normalized);
|
52 |
|
53 | this.kernelspecs.connectionFailure.connect(this._onConnectionFailure, this);
|
54 | this.sessions.connectionFailure.connect(this._onConnectionFailure, this);
|
55 | this.terminals.connectionFailure.connect(this._onConnectionFailure, this);
|
56 |
|
57 | const readyList = [this.sessions.ready, this.kernelspecs.ready];
|
58 | if (this.terminals.isAvailable()) {
|
59 | readyList.push(this.terminals.ready);
|
60 | }
|
61 | this._readyPromise = Promise.all(readyList).then(() => {
|
62 | this._isReady = true;
|
63 | });
|
64 | }
|
65 | |
66 |
|
67 |
|
68 | get connectionFailure() {
|
69 | return this._connectionFailure;
|
70 | }
|
71 | |
72 |
|
73 |
|
74 | get isDisposed() {
|
75 | return this._isDisposed;
|
76 | }
|
77 | |
78 |
|
79 |
|
80 | dispose() {
|
81 | if (this.isDisposed) {
|
82 | return;
|
83 | }
|
84 | this._isDisposed = true;
|
85 | signaling_1.Signal.clearData(this);
|
86 | this.contents.dispose();
|
87 | this.events.dispose();
|
88 | this.sessions.dispose();
|
89 | this.terminals.dispose();
|
90 | }
|
91 | |
92 |
|
93 |
|
94 | get isReady() {
|
95 | return this._isReady;
|
96 | }
|
97 | |
98 |
|
99 |
|
100 | get ready() {
|
101 | return this._readyPromise;
|
102 | }
|
103 | _onConnectionFailure(sender, err) {
|
104 | this._connectionFailure.emit(err);
|
105 | }
|
106 | }
|
107 | exports.ServiceManager = ServiceManager;
|
108 |
|
\ | No newline at end of file |