@jupyterlite/services-extension 0.6.0-alpha.10
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/lib/configsection.d.ts +21 -0
- package/lib/configsection.js +34 -0
- package/lib/configsection.js.map +1 -0
- package/lib/event.d.ts +39 -0
- package/lib/event.js +57 -0
- package/lib/event.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +266 -0
- package/lib/index.js.map +1 -0
- package/package.json +53 -0
- package/src/configsection.ts +45 -0
- package/src/event.ts +66 -0
- package/src/index.ts +371 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ConfigSection, ConfigSectionManager, IConfigSection, ServerConnection } from '@jupyterlab/services';
|
|
2
|
+
/**
|
|
3
|
+
* A class to manager config sections in the browser.
|
|
4
|
+
*/
|
|
5
|
+
export declare class LiteConfigSectionManager implements ConfigSection.IManager {
|
|
6
|
+
/**
|
|
7
|
+
* Construct a new config section manager.
|
|
8
|
+
*/
|
|
9
|
+
constructor(options: {
|
|
10
|
+
serverSettings?: ServerConnection.ISettings;
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* The server settings.
|
|
14
|
+
*/
|
|
15
|
+
get serverSettings(): ServerConnection.ISettings;
|
|
16
|
+
/**
|
|
17
|
+
* Create a new config section.
|
|
18
|
+
*/
|
|
19
|
+
create(options: ConfigSectionManager.ICreateOptions): Promise<IConfigSection>;
|
|
20
|
+
private _serverSettings;
|
|
21
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
import { ServerConnection, } from '@jupyterlab/services';
|
|
4
|
+
/**
|
|
5
|
+
* A class to manager config sections in the browser.
|
|
6
|
+
*/
|
|
7
|
+
export class LiteConfigSectionManager {
|
|
8
|
+
/**
|
|
9
|
+
* Construct a new config section manager.
|
|
10
|
+
*/
|
|
11
|
+
constructor(options) {
|
|
12
|
+
var _a;
|
|
13
|
+
this._serverSettings = (_a = options.serverSettings) !== null && _a !== void 0 ? _a : ServerConnection.makeSettings();
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The server settings.
|
|
17
|
+
*/
|
|
18
|
+
get serverSettings() {
|
|
19
|
+
return this._serverSettings;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create a new config section.
|
|
23
|
+
*/
|
|
24
|
+
async create(options) {
|
|
25
|
+
return {
|
|
26
|
+
data: {},
|
|
27
|
+
serverSettings: this._serverSettings,
|
|
28
|
+
update: async (newData) => {
|
|
29
|
+
return newData;
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=configsection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configsection.js","sourceRoot":"","sources":["../src/configsection.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAIL,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAI9B;;GAEG;AACH,MAAM,OAAO,wBAAwB;IACnC;;OAEG;IACH,YAAY,OAAwD;;QAClE,IAAI,CAAC,eAAe,GAAG,MAAA,OAAO,CAAC,cAAc,mCAAI,gBAAgB,CAAC,YAAY,EAAE,CAAC;IACnF,CAAC;IAED;;OAEG;IACH,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,OAA4C;QACvD,OAAO;YACL,IAAI,EAAE,EAAE;YACR,cAAc,EAAE,IAAI,CAAC,eAAe;YACpC,MAAM,EAAE,KAAK,EAAE,OAAmB,EAAuB,EAAE;gBACzD,OAAO,OAAO,CAAC;YACjB,CAAC;SACF,CAAC;IACJ,CAAC;CAGF"}
|
package/lib/event.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Event, ServerConnection } from '@jupyterlab/services';
|
|
2
|
+
import { Stream } from '@lumino/signaling';
|
|
3
|
+
/**
|
|
4
|
+
* A local event manager service.
|
|
5
|
+
*
|
|
6
|
+
* #### Notes
|
|
7
|
+
* Schema IDs are not verified and all client-emitted events emit.
|
|
8
|
+
*/
|
|
9
|
+
export declare class LocalEventManager implements Event.IManager {
|
|
10
|
+
/**
|
|
11
|
+
* Construct a new event manager.
|
|
12
|
+
*/
|
|
13
|
+
constructor(options: {
|
|
14
|
+
serverSettings?: ServerConnection.ISettings;
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Dispose of the resources used by the manager.
|
|
18
|
+
*/
|
|
19
|
+
dispose(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the manager is disposed.
|
|
22
|
+
*/
|
|
23
|
+
get isDisposed(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The stream of events.
|
|
26
|
+
*/
|
|
27
|
+
get stream(): Stream<this, Event.Emission>;
|
|
28
|
+
/**
|
|
29
|
+
* The server settings.
|
|
30
|
+
*/
|
|
31
|
+
get serverSettings(): ServerConnection.ISettings;
|
|
32
|
+
/**
|
|
33
|
+
* Emit an event for all listeners.
|
|
34
|
+
*/
|
|
35
|
+
emit({ data, schema_id }: Event.Request): Promise<void>;
|
|
36
|
+
private _isDisposed;
|
|
37
|
+
private _serverSettings;
|
|
38
|
+
private _stream;
|
|
39
|
+
}
|
package/lib/event.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
import { ServerConnection } from '@jupyterlab/services';
|
|
4
|
+
import { Signal, Stream } from '@lumino/signaling';
|
|
5
|
+
/**
|
|
6
|
+
* A local event manager service.
|
|
7
|
+
*
|
|
8
|
+
* #### Notes
|
|
9
|
+
* Schema IDs are not verified and all client-emitted events emit.
|
|
10
|
+
*/
|
|
11
|
+
export class LocalEventManager {
|
|
12
|
+
/**
|
|
13
|
+
* Construct a new event manager.
|
|
14
|
+
*/
|
|
15
|
+
constructor(options) {
|
|
16
|
+
var _a;
|
|
17
|
+
this._isDisposed = false;
|
|
18
|
+
this._serverSettings = (_a = options.serverSettings) !== null && _a !== void 0 ? _a : ServerConnection.makeSettings();
|
|
19
|
+
this._stream = new Stream(this);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Dispose of the resources used by the manager.
|
|
23
|
+
*/
|
|
24
|
+
dispose() {
|
|
25
|
+
if (this.isDisposed) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this._isDisposed = true;
|
|
29
|
+
Signal.clearData(this);
|
|
30
|
+
this._stream.stop();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Whether the manager is disposed.
|
|
34
|
+
*/
|
|
35
|
+
get isDisposed() {
|
|
36
|
+
return this._isDisposed;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The stream of events.
|
|
40
|
+
*/
|
|
41
|
+
get stream() {
|
|
42
|
+
return this._stream;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The server settings.
|
|
46
|
+
*/
|
|
47
|
+
get serverSettings() {
|
|
48
|
+
return this._serverSettings;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Emit an event for all listeners.
|
|
52
|
+
*/
|
|
53
|
+
async emit({ data, schema_id }) {
|
|
54
|
+
this._stream.emit({ ...data, schema_id });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=event.js.map
|
package/lib/event.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAS,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,OAAO,iBAAiB;IAC5B;;OAEG;IACH,YAAY,OAAwD;;QA6C5D,gBAAW,GAAG,KAAK,CAAC;QA5C1B,IAAI,CAAC,eAAe,GAAG,MAAA,OAAO,CAAC,cAAc,mCAAI,gBAAgB,CAAC,YAAY,EAAE,CAAC;QACjF,IAAI,CAAC,OAAO,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,OAAO;QACL,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAiB;QAC3C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAC5C,CAAC;CAKF"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ConfigSection, Contents, Event, Kernel, KernelSpec, NbConvert, ServiceManagerPlugin, Session, Setting, User } from '@jupyterlab/services';
|
|
2
|
+
import { IKernelSpecs } from '@jupyterlite/kernel';
|
|
3
|
+
import { ILocalForage } from '@jupyterlite/localforage';
|
|
4
|
+
declare const _default: (ServiceManagerPlugin<ConfigSection.IManager> | ServiceManagerPlugin<Contents.IDrive> | ServiceManagerPlugin<Event.IManager> | ServiceManagerPlugin<Kernel.IManager> | ServiceManagerPlugin<KernelSpec.IKernelSpecAPIClient> | ServiceManagerPlugin<KernelSpec.IManager> | ServiceManagerPlugin<Kernel.IKernelAPIClient> | ServiceManagerPlugin<IKernelSpecs> | ServiceManagerPlugin<ILocalForage> | ServiceManagerPlugin<NbConvert.IManager> | ServiceManagerPlugin<Session.IManager> | ServiceManagerPlugin<Setting.IManager> | ServiceManagerPlugin<User.IManager>)[];
|
|
5
|
+
export default _default;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
import { PageConfig } from '@jupyterlab/coreutils';
|
|
4
|
+
import { ConfigSection, IConfigSectionManager, IDefaultDrive, IEventManager, IKernelManager, IKernelSpecManager, INbConvertManager, IServerSettings, ISessionManager, ISettingManager, IUserManager, KernelManager, KernelSpecManager, NbConvertManager, ServerConnection, SessionManager, UserManager, } from '@jupyterlab/services';
|
|
5
|
+
import { BrowserStorageDrive } from '@jupyterlite/contents';
|
|
6
|
+
import { IKernelClient, IKernelSpecClient, IKernelSpecs, KernelSpecs, LiteKernelClient, LiteKernelSpecClient, } from '@jupyterlite/kernel';
|
|
7
|
+
import { ILocalForage, ensureMemoryStorage } from '@jupyterlite/localforage';
|
|
8
|
+
import { LiteSessionClient } from '@jupyterlite/session';
|
|
9
|
+
import { Settings as JupyterLiteSettings } from '@jupyterlite/settings';
|
|
10
|
+
import localforage from 'localforage';
|
|
11
|
+
import { WebSocket } from 'mock-socket';
|
|
12
|
+
import { LiteConfigSectionManager } from './configsection';
|
|
13
|
+
import { LocalEventManager } from './event';
|
|
14
|
+
/**
|
|
15
|
+
* Config section manager plugin.
|
|
16
|
+
*/
|
|
17
|
+
const configSectionManager = {
|
|
18
|
+
id: '@jupyterlite/services-extension:config-section-manager',
|
|
19
|
+
autoStart: true,
|
|
20
|
+
provides: IConfigSectionManager,
|
|
21
|
+
optional: [IServerSettings],
|
|
22
|
+
description: 'Provides the config section manager.',
|
|
23
|
+
activate: (_, serverSettings) => {
|
|
24
|
+
const manager = new LiteConfigSectionManager({ serverSettings });
|
|
25
|
+
// Set the config section manager for the global ConfigSection.
|
|
26
|
+
ConfigSection._setConfigSectionManager(manager);
|
|
27
|
+
return manager;
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The default drive plugin.
|
|
32
|
+
*/
|
|
33
|
+
const defaultDrivePlugin = {
|
|
34
|
+
id: '@jupyterlite/services-extension:default-drive',
|
|
35
|
+
description: 'The default drive for the contents manager.',
|
|
36
|
+
autoStart: true,
|
|
37
|
+
provides: IDefaultDrive,
|
|
38
|
+
requires: [ILocalForage],
|
|
39
|
+
activate: async (_, forage) => {
|
|
40
|
+
const baseUrl = PageConfig.getOption('baseUrl');
|
|
41
|
+
const defaultStorageName = `JupyterLite Storage - ${baseUrl}`;
|
|
42
|
+
const storageName = PageConfig.getOption('contentsStorageName') || defaultStorageName;
|
|
43
|
+
const storageDrivers = JSON.parse(PageConfig.getOption('contentsStorageDrivers') || 'null');
|
|
44
|
+
const { localforage } = forage;
|
|
45
|
+
const drive = new BrowserStorageDrive({
|
|
46
|
+
storageName,
|
|
47
|
+
storageDrivers,
|
|
48
|
+
localforage,
|
|
49
|
+
});
|
|
50
|
+
return drive;
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The event manager plugin.
|
|
55
|
+
*/
|
|
56
|
+
const eventManagerPlugin = {
|
|
57
|
+
id: '@jupyterlite/services-extension:event-manager',
|
|
58
|
+
description: 'The event manager plugin.',
|
|
59
|
+
autoStart: true,
|
|
60
|
+
provides: IEventManager,
|
|
61
|
+
optional: [IServerSettings],
|
|
62
|
+
activate: (_, serverSettings) => {
|
|
63
|
+
return new LocalEventManager({ serverSettings });
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* The kernel manager plugin.
|
|
68
|
+
*/
|
|
69
|
+
const kernelManagerPlugin = {
|
|
70
|
+
id: '@jupyterlite/services-extension:kernel-manager',
|
|
71
|
+
description: 'The kernel manager plugin.',
|
|
72
|
+
autoStart: true,
|
|
73
|
+
provides: IKernelManager,
|
|
74
|
+
requires: [IKernelClient, IKernelSpecClient],
|
|
75
|
+
optional: [IServerSettings],
|
|
76
|
+
activate: (_, kernelAPIClient, kernelSpecAPIClient, serverSettings) => {
|
|
77
|
+
return new KernelManager({
|
|
78
|
+
kernelAPIClient,
|
|
79
|
+
kernelSpecAPIClient,
|
|
80
|
+
serverSettings: {
|
|
81
|
+
...ServerConnection.makeSettings(),
|
|
82
|
+
...serverSettings,
|
|
83
|
+
WebSocket,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* The client for managing in-browser kernel specs
|
|
90
|
+
*/
|
|
91
|
+
const kernelSpecClientPlugin = {
|
|
92
|
+
id: '@jupyterlite/services-extension:kernel-spec-client',
|
|
93
|
+
description: 'The client for managing in-browser kernel specs',
|
|
94
|
+
autoStart: true,
|
|
95
|
+
requires: [IKernelSpecs],
|
|
96
|
+
optional: [IServerSettings],
|
|
97
|
+
provides: IKernelSpecClient,
|
|
98
|
+
activate: (_, kernelSpecs, serverSettings) => {
|
|
99
|
+
return new LiteKernelSpecClient({ kernelSpecs, serverSettings });
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* The kernel spec manager plugin.
|
|
104
|
+
*/
|
|
105
|
+
const kernelSpecManagerPlugin = {
|
|
106
|
+
id: '@jupyterlite/services-extension:kernel-spec-manager',
|
|
107
|
+
description: 'The kernel spec manager plugin.',
|
|
108
|
+
autoStart: true,
|
|
109
|
+
provides: IKernelSpecManager,
|
|
110
|
+
requires: [IKernelSpecClient],
|
|
111
|
+
optional: [IKernelSpecs, IServerSettings],
|
|
112
|
+
activate: (_, kernelSpecAPIClient, kernelSpecs, serverSettings) => {
|
|
113
|
+
const kernelSpecManager = new KernelSpecManager({
|
|
114
|
+
kernelSpecAPIClient,
|
|
115
|
+
serverSettings,
|
|
116
|
+
});
|
|
117
|
+
if (kernelSpecs) {
|
|
118
|
+
// refresh the kernel spec manager when new lite specs are added
|
|
119
|
+
kernelSpecs.changed.connect(() => {
|
|
120
|
+
void kernelSpecManager.refreshSpecs();
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return kernelSpecManager;
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* The client for managing in-browser kernels
|
|
128
|
+
*/
|
|
129
|
+
const kernelClientPlugin = {
|
|
130
|
+
id: '@jupyterlite/services-extension:kernel-client',
|
|
131
|
+
description: 'The client for managing in-browser kernels',
|
|
132
|
+
autoStart: true,
|
|
133
|
+
requires: [IKernelSpecs],
|
|
134
|
+
optional: [IServerSettings],
|
|
135
|
+
provides: IKernelClient,
|
|
136
|
+
activate: (_, kernelSpecs, serverSettings) => {
|
|
137
|
+
return new LiteKernelClient({
|
|
138
|
+
kernelSpecs,
|
|
139
|
+
serverSettings,
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* The in-browser kernel spec manager plugin.
|
|
145
|
+
*/
|
|
146
|
+
const liteKernelSpecManagerPlugin = {
|
|
147
|
+
id: '@jupyterlite/services-extension:kernel-specs',
|
|
148
|
+
description: 'The in-browser kernel spec manager plugin.',
|
|
149
|
+
autoStart: true,
|
|
150
|
+
provides: IKernelSpecs,
|
|
151
|
+
activate: (_) => {
|
|
152
|
+
return new KernelSpecs();
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* The localforage plugin
|
|
157
|
+
*/
|
|
158
|
+
const localforagePlugin = {
|
|
159
|
+
id: '@jupyterlite/services-extension:localforage',
|
|
160
|
+
autoStart: true,
|
|
161
|
+
provides: ILocalForage,
|
|
162
|
+
activate: async (_) => {
|
|
163
|
+
if (JSON.parse(PageConfig.getOption('enableMemoryStorage') || 'false')) {
|
|
164
|
+
console.warn('Memory storage fallback enabled: contents and settings may not be saved');
|
|
165
|
+
await ensureMemoryStorage(localforage);
|
|
166
|
+
}
|
|
167
|
+
return { localforage };
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* The nbconvert manager plugin.
|
|
172
|
+
*/
|
|
173
|
+
const nbConvertManagerPlugin = {
|
|
174
|
+
id: '@jupyterlite/services-extension:nbconvert-manager',
|
|
175
|
+
description: 'The nbconvert manager plugin.',
|
|
176
|
+
autoStart: true,
|
|
177
|
+
provides: INbConvertManager,
|
|
178
|
+
optional: [IServerSettings],
|
|
179
|
+
activate: (_, serverSettings) => {
|
|
180
|
+
const nbConvertManager = new (class extends NbConvertManager {
|
|
181
|
+
async getExportFormats(force) {
|
|
182
|
+
return {};
|
|
183
|
+
}
|
|
184
|
+
})({ serverSettings });
|
|
185
|
+
return nbConvertManager;
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* The session manager plugin.
|
|
190
|
+
*/
|
|
191
|
+
const sessionManagerPlugin = {
|
|
192
|
+
id: '@jupyterlite/services-extension:session-manager',
|
|
193
|
+
description: 'The session manager plugin.',
|
|
194
|
+
autoStart: true,
|
|
195
|
+
provides: ISessionManager,
|
|
196
|
+
requires: [IKernelManager, IKernelClient],
|
|
197
|
+
optional: [IServerSettings],
|
|
198
|
+
activate: (_, kernelManager, kernelClient, serverSettings) => {
|
|
199
|
+
const sessionAPIClient = new LiteSessionClient({
|
|
200
|
+
kernelClient,
|
|
201
|
+
serverSettings,
|
|
202
|
+
});
|
|
203
|
+
return new SessionManager({
|
|
204
|
+
kernelManager,
|
|
205
|
+
serverSettings,
|
|
206
|
+
sessionAPIClient,
|
|
207
|
+
});
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* The settings service plugin.
|
|
212
|
+
*/
|
|
213
|
+
const settingsPlugin = {
|
|
214
|
+
id: '@jupyterlite/services-extension:settings',
|
|
215
|
+
autoStart: true,
|
|
216
|
+
requires: [ILocalForage],
|
|
217
|
+
optional: [IServerSettings],
|
|
218
|
+
provides: ISettingManager,
|
|
219
|
+
activate: (_, forage, serverSettings) => {
|
|
220
|
+
const baseUrl = PageConfig.getOption('baseUrl');
|
|
221
|
+
const defaultStorageName = `JupyterLite Storage - ${baseUrl}`;
|
|
222
|
+
const storageName = PageConfig.getOption('settingsStorageName') || defaultStorageName;
|
|
223
|
+
const storageDrivers = JSON.parse(PageConfig.getOption('settingsStorageDrivers') || 'null');
|
|
224
|
+
const { localforage } = forage;
|
|
225
|
+
const settings = new JupyterLiteSettings({
|
|
226
|
+
storageName,
|
|
227
|
+
storageDrivers,
|
|
228
|
+
localforage,
|
|
229
|
+
serverSettings: serverSettings !== null && serverSettings !== void 0 ? serverSettings : undefined,
|
|
230
|
+
});
|
|
231
|
+
return settings;
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* The user manager plugin.
|
|
236
|
+
*/
|
|
237
|
+
const userManagerPlugin = {
|
|
238
|
+
id: '@jupyterlite/services-extension:user-manager',
|
|
239
|
+
description: 'The user manager plugin.',
|
|
240
|
+
autoStart: true,
|
|
241
|
+
provides: IUserManager,
|
|
242
|
+
optional: [IServerSettings],
|
|
243
|
+
activate: (_, serverSettings) => {
|
|
244
|
+
return new (class extends UserManager {
|
|
245
|
+
async requestUser() {
|
|
246
|
+
// no-op
|
|
247
|
+
}
|
|
248
|
+
})({ serverSettings });
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
export default [
|
|
252
|
+
configSectionManager,
|
|
253
|
+
defaultDrivePlugin,
|
|
254
|
+
eventManagerPlugin,
|
|
255
|
+
kernelManagerPlugin,
|
|
256
|
+
kernelClientPlugin,
|
|
257
|
+
kernelSpecClientPlugin,
|
|
258
|
+
kernelSpecManagerPlugin,
|
|
259
|
+
liteKernelSpecManagerPlugin,
|
|
260
|
+
localforagePlugin,
|
|
261
|
+
nbConvertManagerPlugin,
|
|
262
|
+
sessionManagerPlugin,
|
|
263
|
+
settingsPlugin,
|
|
264
|
+
userManagerPlugin,
|
|
265
|
+
];
|
|
266
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EACL,aAAa,EAGb,qBAAqB,EACrB,aAAa,EACb,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,eAAe,EACf,YAAY,EAEZ,aAAa,EAEb,iBAAiB,EAEjB,gBAAgB,EAChB,gBAAgB,EAGhB,cAAc,EAGd,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,QAAQ,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAExE,OAAO,WAAW,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAE,i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AAO,IAAI,CAAC,KAAM,SAAQ,WAAW;YACnC,KAAK,CAAC,WAAW;gBACf,QAAQ;YACV,CAAC;SACF,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC;IACzB,CAAC;CACF,CAAC;AAEF,eAAe;IACb,oBAAoB;IACpB,kBAAkB;IAClB,kBAAkB;IAClB,mBAAmB;IACnB,kBAAkB;IAClB,sBAAsB;IACtB,uBAAuB;IACvB,2BAA2B;IAC3B,iBAAiB;IACjB,sBAAsB;IACtB,oBAAoB;IACpB,cAAc;IACd,iBAAiB;CAClB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jupyterlite/services-extension",
|
|
3
|
+
"version": "0.6.0-alpha.10",
|
|
4
|
+
"description": "JupyterLite - Services Extension",
|
|
5
|
+
"homepage": "https://github.com/jupyterlite/jupyterlite",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/jupyterlite/jupyterlite/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/jupyterlite/jupyterlite.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "BSD-3-Clause",
|
|
14
|
+
"author": "JupyterLite Contributors",
|
|
15
|
+
"main": "lib/index.js",
|
|
16
|
+
"types": "lib/index.d.ts",
|
|
17
|
+
"directories": {
|
|
18
|
+
"lib": "lib/"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"lib/*.d.ts",
|
|
22
|
+
"lib/*.js.map",
|
|
23
|
+
"lib/*.js",
|
|
24
|
+
"src/**/*.{ts,tsx}"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc -b",
|
|
28
|
+
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
|
|
29
|
+
"docs": "typedoc src",
|
|
30
|
+
"prepublishOnly": "npm run build",
|
|
31
|
+
"watch": "tsc -b --watch"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@jupyterlab/coreutils": "~6.4.2",
|
|
35
|
+
"@jupyterlab/services": "~7.4.2",
|
|
36
|
+
"@jupyterlite/contents": "^0.6.0-alpha.10",
|
|
37
|
+
"@jupyterlite/kernel": "^0.6.0-alpha.10",
|
|
38
|
+
"@jupyterlite/localforage": "^0.6.0-alpha.10",
|
|
39
|
+
"@jupyterlite/session": "^0.6.0-alpha.10",
|
|
40
|
+
"@jupyterlite/settings": "^0.6.0-alpha.10",
|
|
41
|
+
"@lumino/coreutils": "^2.2.1"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"rimraf": "~5.0.1",
|
|
45
|
+
"typescript": "~5.5.4"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"jupyterlab": {
|
|
51
|
+
"extension": true
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
ConfigSection,
|
|
6
|
+
ConfigSectionManager,
|
|
7
|
+
IConfigSection,
|
|
8
|
+
ServerConnection,
|
|
9
|
+
} from '@jupyterlab/services';
|
|
10
|
+
|
|
11
|
+
import { JSONObject } from '@lumino/coreutils';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A class to manager config sections in the browser.
|
|
15
|
+
*/
|
|
16
|
+
export class LiteConfigSectionManager implements ConfigSection.IManager {
|
|
17
|
+
/**
|
|
18
|
+
* Construct a new config section manager.
|
|
19
|
+
*/
|
|
20
|
+
constructor(options: { serverSettings?: ServerConnection.ISettings }) {
|
|
21
|
+
this._serverSettings = options.serverSettings ?? ServerConnection.makeSettings();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The server settings.
|
|
26
|
+
*/
|
|
27
|
+
get serverSettings(): ServerConnection.ISettings {
|
|
28
|
+
return this._serverSettings;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Create a new config section.
|
|
33
|
+
*/
|
|
34
|
+
async create(options: ConfigSectionManager.ICreateOptions): Promise<IConfigSection> {
|
|
35
|
+
return {
|
|
36
|
+
data: {},
|
|
37
|
+
serverSettings: this._serverSettings,
|
|
38
|
+
update: async (newData: JSONObject): Promise<JSONObject> => {
|
|
39
|
+
return newData;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private _serverSettings: ServerConnection.ISettings;
|
|
45
|
+
}
|
package/src/event.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import { Event, ServerConnection } from '@jupyterlab/services';
|
|
5
|
+
|
|
6
|
+
import { Signal, Stream } from '@lumino/signaling';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A local event manager service.
|
|
10
|
+
*
|
|
11
|
+
* #### Notes
|
|
12
|
+
* Schema IDs are not verified and all client-emitted events emit.
|
|
13
|
+
*/
|
|
14
|
+
export class LocalEventManager implements Event.IManager {
|
|
15
|
+
/**
|
|
16
|
+
* Construct a new event manager.
|
|
17
|
+
*/
|
|
18
|
+
constructor(options: { serverSettings?: ServerConnection.ISettings }) {
|
|
19
|
+
this._serverSettings = options.serverSettings ?? ServerConnection.makeSettings();
|
|
20
|
+
this._stream = new Stream(this);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Dispose of the resources used by the manager.
|
|
25
|
+
*/
|
|
26
|
+
dispose(): void {
|
|
27
|
+
if (this.isDisposed) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
this._isDisposed = true;
|
|
31
|
+
Signal.clearData(this);
|
|
32
|
+
this._stream.stop();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Whether the manager is disposed.
|
|
37
|
+
*/
|
|
38
|
+
get isDisposed(): boolean {
|
|
39
|
+
return this._isDisposed;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The stream of events.
|
|
44
|
+
*/
|
|
45
|
+
get stream() {
|
|
46
|
+
return this._stream;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The server settings.
|
|
51
|
+
*/
|
|
52
|
+
get serverSettings(): ServerConnection.ISettings {
|
|
53
|
+
return this._serverSettings;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Emit an event for all listeners.
|
|
58
|
+
*/
|
|
59
|
+
async emit({ data, schema_id }: Event.Request): Promise<void> {
|
|
60
|
+
this._stream.emit({ ...data, schema_id });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private _isDisposed = false;
|
|
64
|
+
private _serverSettings: ServerConnection.ISettings;
|
|
65
|
+
private _stream: Stream<this, Event.Emission>;
|
|
66
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import { PageConfig } from '@jupyterlab/coreutils';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
ConfigSection,
|
|
8
|
+
Contents,
|
|
9
|
+
Event,
|
|
10
|
+
IConfigSectionManager,
|
|
11
|
+
IDefaultDrive,
|
|
12
|
+
IEventManager,
|
|
13
|
+
IKernelManager,
|
|
14
|
+
IKernelSpecManager,
|
|
15
|
+
INbConvertManager,
|
|
16
|
+
IServerSettings,
|
|
17
|
+
ISessionManager,
|
|
18
|
+
ISettingManager,
|
|
19
|
+
IUserManager,
|
|
20
|
+
Kernel,
|
|
21
|
+
KernelManager,
|
|
22
|
+
KernelSpec,
|
|
23
|
+
KernelSpecManager,
|
|
24
|
+
NbConvert,
|
|
25
|
+
NbConvertManager,
|
|
26
|
+
ServerConnection,
|
|
27
|
+
ServiceManagerPlugin,
|
|
28
|
+
Session,
|
|
29
|
+
SessionManager,
|
|
30
|
+
Setting,
|
|
31
|
+
User,
|
|
32
|
+
UserManager,
|
|
33
|
+
} from '@jupyterlab/services';
|
|
34
|
+
|
|
35
|
+
import { BrowserStorageDrive } from '@jupyterlite/contents';
|
|
36
|
+
|
|
37
|
+
import {
|
|
38
|
+
IKernelClient,
|
|
39
|
+
IKernelSpecClient,
|
|
40
|
+
IKernelSpecs,
|
|
41
|
+
KernelSpecs,
|
|
42
|
+
LiteKernelClient,
|
|
43
|
+
LiteKernelSpecClient,
|
|
44
|
+
} from '@jupyterlite/kernel';
|
|
45
|
+
|
|
46
|
+
import { ILocalForage, ensureMemoryStorage } from '@jupyterlite/localforage';
|
|
47
|
+
|
|
48
|
+
import { LiteSessionClient } from '@jupyterlite/session';
|
|
49
|
+
|
|
50
|
+
import { Settings as JupyterLiteSettings } from '@jupyterlite/settings';
|
|
51
|
+
|
|
52
|
+
import localforage from 'localforage';
|
|
53
|
+
|
|
54
|
+
import { WebSocket } from 'mock-socket';
|
|
55
|
+
|
|
56
|
+
import { LiteConfigSectionManager } from './configsection';
|
|
57
|
+
|
|
58
|
+
import { LocalEventManager } from './event';
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Config section manager plugin.
|
|
62
|
+
*/
|
|
63
|
+
const configSectionManager: ServiceManagerPlugin<ConfigSection.IManager> = {
|
|
64
|
+
id: '@jupyterlite/services-extension:config-section-manager',
|
|
65
|
+
autoStart: true,
|
|
66
|
+
provides: IConfigSectionManager,
|
|
67
|
+
optional: [IServerSettings],
|
|
68
|
+
description: 'Provides the config section manager.',
|
|
69
|
+
activate: (_: null, serverSettings?: ServerConnection.ISettings) => {
|
|
70
|
+
const manager = new LiteConfigSectionManager({ serverSettings });
|
|
71
|
+
// Set the config section manager for the global ConfigSection.
|
|
72
|
+
ConfigSection._setConfigSectionManager(manager);
|
|
73
|
+
return manager;
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The default drive plugin.
|
|
79
|
+
*/
|
|
80
|
+
const defaultDrivePlugin: ServiceManagerPlugin<Contents.IDrive> = {
|
|
81
|
+
id: '@jupyterlite/services-extension:default-drive',
|
|
82
|
+
description: 'The default drive for the contents manager.',
|
|
83
|
+
autoStart: true,
|
|
84
|
+
provides: IDefaultDrive,
|
|
85
|
+
requires: [ILocalForage],
|
|
86
|
+
activate: async (_: null, forage: ILocalForage): Promise<Contents.IDrive> => {
|
|
87
|
+
const baseUrl = PageConfig.getOption('baseUrl');
|
|
88
|
+
const defaultStorageName = `JupyterLite Storage - ${baseUrl}`;
|
|
89
|
+
const storageName =
|
|
90
|
+
PageConfig.getOption('contentsStorageName') || defaultStorageName;
|
|
91
|
+
const storageDrivers = JSON.parse(
|
|
92
|
+
PageConfig.getOption('contentsStorageDrivers') || 'null',
|
|
93
|
+
);
|
|
94
|
+
const { localforage } = forage;
|
|
95
|
+
const drive = new BrowserStorageDrive({
|
|
96
|
+
storageName,
|
|
97
|
+
storageDrivers,
|
|
98
|
+
localforage,
|
|
99
|
+
});
|
|
100
|
+
return drive;
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The event manager plugin.
|
|
106
|
+
*/
|
|
107
|
+
const eventManagerPlugin: ServiceManagerPlugin<Event.IManager> = {
|
|
108
|
+
id: '@jupyterlite/services-extension:event-manager',
|
|
109
|
+
description: 'The event manager plugin.',
|
|
110
|
+
autoStart: true,
|
|
111
|
+
provides: IEventManager,
|
|
112
|
+
optional: [IServerSettings],
|
|
113
|
+
activate: (
|
|
114
|
+
_: null,
|
|
115
|
+
serverSettings: ServerConnection.ISettings | undefined,
|
|
116
|
+
): Event.IManager => {
|
|
117
|
+
return new LocalEventManager({ serverSettings });
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The kernel manager plugin.
|
|
123
|
+
*/
|
|
124
|
+
const kernelManagerPlugin: ServiceManagerPlugin<Kernel.IManager> = {
|
|
125
|
+
id: '@jupyterlite/services-extension:kernel-manager',
|
|
126
|
+
description: 'The kernel manager plugin.',
|
|
127
|
+
autoStart: true,
|
|
128
|
+
provides: IKernelManager,
|
|
129
|
+
requires: [IKernelClient, IKernelSpecClient],
|
|
130
|
+
optional: [IServerSettings],
|
|
131
|
+
activate: (
|
|
132
|
+
_: null,
|
|
133
|
+
kernelAPIClient: IKernelClient,
|
|
134
|
+
kernelSpecAPIClient: IKernelSpecClient,
|
|
135
|
+
serverSettings: ServerConnection.ISettings | undefined,
|
|
136
|
+
): Kernel.IManager => {
|
|
137
|
+
return new KernelManager({
|
|
138
|
+
kernelAPIClient,
|
|
139
|
+
kernelSpecAPIClient,
|
|
140
|
+
serverSettings: {
|
|
141
|
+
...ServerConnection.makeSettings(),
|
|
142
|
+
...serverSettings,
|
|
143
|
+
WebSocket,
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The client for managing in-browser kernel specs
|
|
151
|
+
*/
|
|
152
|
+
const kernelSpecClientPlugin: ServiceManagerPlugin<KernelSpec.IKernelSpecAPIClient> = {
|
|
153
|
+
id: '@jupyterlite/services-extension:kernel-spec-client',
|
|
154
|
+
description: 'The client for managing in-browser kernel specs',
|
|
155
|
+
autoStart: true,
|
|
156
|
+
requires: [IKernelSpecs],
|
|
157
|
+
optional: [IServerSettings],
|
|
158
|
+
provides: IKernelSpecClient,
|
|
159
|
+
activate: (
|
|
160
|
+
_: null,
|
|
161
|
+
kernelSpecs: IKernelSpecs,
|
|
162
|
+
serverSettings?: ServerConnection.ISettings,
|
|
163
|
+
): IKernelSpecClient => {
|
|
164
|
+
return new LiteKernelSpecClient({ kernelSpecs, serverSettings });
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* The kernel spec manager plugin.
|
|
170
|
+
*/
|
|
171
|
+
const kernelSpecManagerPlugin: ServiceManagerPlugin<KernelSpec.IManager> = {
|
|
172
|
+
id: '@jupyterlite/services-extension:kernel-spec-manager',
|
|
173
|
+
description: 'The kernel spec manager plugin.',
|
|
174
|
+
autoStart: true,
|
|
175
|
+
provides: IKernelSpecManager,
|
|
176
|
+
requires: [IKernelSpecClient],
|
|
177
|
+
optional: [IKernelSpecs, IServerSettings],
|
|
178
|
+
activate: (
|
|
179
|
+
_: null,
|
|
180
|
+
kernelSpecAPIClient: IKernelSpecClient,
|
|
181
|
+
kernelSpecs: IKernelSpecs | null,
|
|
182
|
+
serverSettings: ServerConnection.ISettings | undefined,
|
|
183
|
+
): KernelSpec.IManager => {
|
|
184
|
+
const kernelSpecManager = new KernelSpecManager({
|
|
185
|
+
kernelSpecAPIClient,
|
|
186
|
+
serverSettings,
|
|
187
|
+
});
|
|
188
|
+
if (kernelSpecs) {
|
|
189
|
+
// refresh the kernel spec manager when new lite specs are added
|
|
190
|
+
kernelSpecs.changed.connect(() => {
|
|
191
|
+
void kernelSpecManager.refreshSpecs();
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
return kernelSpecManager;
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* The client for managing in-browser kernels
|
|
200
|
+
*/
|
|
201
|
+
const kernelClientPlugin: ServiceManagerPlugin<Kernel.IKernelAPIClient> = {
|
|
202
|
+
id: '@jupyterlite/services-extension:kernel-client',
|
|
203
|
+
description: 'The client for managing in-browser kernels',
|
|
204
|
+
autoStart: true,
|
|
205
|
+
requires: [IKernelSpecs],
|
|
206
|
+
optional: [IServerSettings],
|
|
207
|
+
provides: IKernelClient,
|
|
208
|
+
activate: (
|
|
209
|
+
_: null,
|
|
210
|
+
kernelSpecs: IKernelSpecs,
|
|
211
|
+
serverSettings?: ServerConnection.ISettings,
|
|
212
|
+
): IKernelClient => {
|
|
213
|
+
return new LiteKernelClient({
|
|
214
|
+
kernelSpecs,
|
|
215
|
+
serverSettings,
|
|
216
|
+
});
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* The in-browser kernel spec manager plugin.
|
|
222
|
+
*/
|
|
223
|
+
const liteKernelSpecManagerPlugin: ServiceManagerPlugin<IKernelSpecs> = {
|
|
224
|
+
id: '@jupyterlite/services-extension:kernel-specs',
|
|
225
|
+
description: 'The in-browser kernel spec manager plugin.',
|
|
226
|
+
autoStart: true,
|
|
227
|
+
provides: IKernelSpecs,
|
|
228
|
+
activate: (_: null): IKernelSpecs => {
|
|
229
|
+
return new KernelSpecs();
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* The localforage plugin
|
|
235
|
+
*/
|
|
236
|
+
const localforagePlugin: ServiceManagerPlugin<ILocalForage> = {
|
|
237
|
+
id: '@jupyterlite/services-extension:localforage',
|
|
238
|
+
autoStart: true,
|
|
239
|
+
provides: ILocalForage,
|
|
240
|
+
activate: async (_: null) => {
|
|
241
|
+
if (JSON.parse(PageConfig.getOption('enableMemoryStorage') || 'false')) {
|
|
242
|
+
console.warn(
|
|
243
|
+
'Memory storage fallback enabled: contents and settings may not be saved',
|
|
244
|
+
);
|
|
245
|
+
await ensureMemoryStorage(localforage);
|
|
246
|
+
}
|
|
247
|
+
return { localforage };
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* The nbconvert manager plugin.
|
|
253
|
+
*/
|
|
254
|
+
const nbConvertManagerPlugin: ServiceManagerPlugin<NbConvert.IManager> = {
|
|
255
|
+
id: '@jupyterlite/services-extension:nbconvert-manager',
|
|
256
|
+
description: 'The nbconvert manager plugin.',
|
|
257
|
+
autoStart: true,
|
|
258
|
+
provides: INbConvertManager,
|
|
259
|
+
optional: [IServerSettings],
|
|
260
|
+
activate: (
|
|
261
|
+
_: null,
|
|
262
|
+
serverSettings: ServerConnection.ISettings | undefined,
|
|
263
|
+
): NbConvert.IManager => {
|
|
264
|
+
const nbConvertManager = new (class extends NbConvertManager {
|
|
265
|
+
async getExportFormats(
|
|
266
|
+
force?: boolean,
|
|
267
|
+
): Promise<NbConvertManager.IExportFormats> {
|
|
268
|
+
return {};
|
|
269
|
+
}
|
|
270
|
+
})({ serverSettings });
|
|
271
|
+
|
|
272
|
+
return nbConvertManager;
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* The session manager plugin.
|
|
278
|
+
*/
|
|
279
|
+
const sessionManagerPlugin: ServiceManagerPlugin<Session.IManager> = {
|
|
280
|
+
id: '@jupyterlite/services-extension:session-manager',
|
|
281
|
+
description: 'The session manager plugin.',
|
|
282
|
+
autoStart: true,
|
|
283
|
+
provides: ISessionManager,
|
|
284
|
+
requires: [IKernelManager, IKernelClient],
|
|
285
|
+
optional: [IServerSettings],
|
|
286
|
+
activate: (
|
|
287
|
+
_: null,
|
|
288
|
+
kernelManager: Kernel.IManager,
|
|
289
|
+
kernelClient: LiteKernelClient,
|
|
290
|
+
serverSettings: ServerConnection.ISettings | undefined,
|
|
291
|
+
): Session.IManager => {
|
|
292
|
+
const sessionAPIClient = new LiteSessionClient({
|
|
293
|
+
kernelClient,
|
|
294
|
+
serverSettings,
|
|
295
|
+
});
|
|
296
|
+
return new SessionManager({
|
|
297
|
+
kernelManager,
|
|
298
|
+
serverSettings,
|
|
299
|
+
sessionAPIClient,
|
|
300
|
+
});
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* The settings service plugin.
|
|
306
|
+
*/
|
|
307
|
+
const settingsPlugin: ServiceManagerPlugin<Setting.IManager> = {
|
|
308
|
+
id: '@jupyterlite/services-extension:settings',
|
|
309
|
+
autoStart: true,
|
|
310
|
+
requires: [ILocalForage],
|
|
311
|
+
optional: [IServerSettings],
|
|
312
|
+
provides: ISettingManager,
|
|
313
|
+
activate: (
|
|
314
|
+
_: null,
|
|
315
|
+
forage: ILocalForage,
|
|
316
|
+
serverSettings: ServerConnection.ISettings | null,
|
|
317
|
+
) => {
|
|
318
|
+
const baseUrl = PageConfig.getOption('baseUrl');
|
|
319
|
+
const defaultStorageName = `JupyterLite Storage - ${baseUrl}`;
|
|
320
|
+
const storageName =
|
|
321
|
+
PageConfig.getOption('settingsStorageName') || defaultStorageName;
|
|
322
|
+
const storageDrivers = JSON.parse(
|
|
323
|
+
PageConfig.getOption('settingsStorageDrivers') || 'null',
|
|
324
|
+
);
|
|
325
|
+
const { localforage } = forage;
|
|
326
|
+
const settings = new JupyterLiteSettings({
|
|
327
|
+
storageName,
|
|
328
|
+
storageDrivers,
|
|
329
|
+
localforage,
|
|
330
|
+
serverSettings: serverSettings ?? undefined,
|
|
331
|
+
});
|
|
332
|
+
return settings;
|
|
333
|
+
},
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* The user manager plugin.
|
|
338
|
+
*/
|
|
339
|
+
const userManagerPlugin: ServiceManagerPlugin<User.IManager> = {
|
|
340
|
+
id: '@jupyterlite/services-extension:user-manager',
|
|
341
|
+
description: 'The user manager plugin.',
|
|
342
|
+
autoStart: true,
|
|
343
|
+
provides: IUserManager,
|
|
344
|
+
optional: [IServerSettings],
|
|
345
|
+
activate: (
|
|
346
|
+
_: null,
|
|
347
|
+
serverSettings: ServerConnection.ISettings | undefined,
|
|
348
|
+
): User.IManager => {
|
|
349
|
+
return new (class extends UserManager {
|
|
350
|
+
async requestUser(): Promise<void> {
|
|
351
|
+
// no-op
|
|
352
|
+
}
|
|
353
|
+
})({ serverSettings });
|
|
354
|
+
},
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
export default [
|
|
358
|
+
configSectionManager,
|
|
359
|
+
defaultDrivePlugin,
|
|
360
|
+
eventManagerPlugin,
|
|
361
|
+
kernelManagerPlugin,
|
|
362
|
+
kernelClientPlugin,
|
|
363
|
+
kernelSpecClientPlugin,
|
|
364
|
+
kernelSpecManagerPlugin,
|
|
365
|
+
liteKernelSpecManagerPlugin,
|
|
366
|
+
localforagePlugin,
|
|
367
|
+
nbConvertManagerPlugin,
|
|
368
|
+
sessionManagerPlugin,
|
|
369
|
+
settingsPlugin,
|
|
370
|
+
userManagerPlugin,
|
|
371
|
+
];
|