@jupyterlite/server 0.1.0-alpha.20 → 0.1.0-alpha.24
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/app.d.ts +15 -8
- package/lib/app.js +32 -11
- package/lib/index.d.ts +1 -2
- package/lib/index.js +1 -2
- package/lib/router.js +2 -2
- package/package.json +15 -15
- package/lib/server.d.ts +0 -66
- package/lib/server.js +0 -173
- package/lib/service.d.ts +0 -32
- package/lib/service.js +0 -31
package/lib/app.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { ServiceManager } from '@jupyterlab/services';
|
|
1
2
|
import { Application, IPlugin } from '@lumino/application';
|
|
2
|
-
import {
|
|
3
|
+
import { Router } from './router';
|
|
3
4
|
export declare type JupyterLiteServerPlugin<T> = IPlugin<JupyterLiteServer, T>;
|
|
4
5
|
/**
|
|
5
6
|
* Server is the main application class. It is instantiated once and shared.
|
|
@@ -23,10 +24,21 @@ export declare class JupyterLiteServer extends Application<never> {
|
|
|
23
24
|
* The version of the application.
|
|
24
25
|
*/
|
|
25
26
|
readonly version = "unknown";
|
|
27
|
+
/**
|
|
28
|
+
* Get the underlying `Router` instance.
|
|
29
|
+
*/
|
|
30
|
+
get router(): Router;
|
|
26
31
|
/**
|
|
27
32
|
* Get the underlying lite service manager for this app.
|
|
28
33
|
*/
|
|
29
|
-
get serviceManager():
|
|
34
|
+
get serviceManager(): ServiceManager;
|
|
35
|
+
/**
|
|
36
|
+
* Handle an incoming request from the client.
|
|
37
|
+
*
|
|
38
|
+
* @param req The incoming request
|
|
39
|
+
* @param init The optional init request
|
|
40
|
+
*/
|
|
41
|
+
fetch(req: RequestInfo, init?: RequestInit | null | undefined): Promise<Response>;
|
|
30
42
|
/**
|
|
31
43
|
* Attach the application shell to the DOM.
|
|
32
44
|
*
|
|
@@ -55,12 +67,7 @@ export declare class JupyterLiteServer extends Application<never> {
|
|
|
55
67
|
* @param mods - The plugin modules to register.
|
|
56
68
|
*/
|
|
57
69
|
registerPluginModules(mods: JupyterLiteServer.IPluginModule[]): void;
|
|
58
|
-
|
|
59
|
-
* Register the underlying lite service manager for this app.
|
|
60
|
-
*
|
|
61
|
-
* @param serviceManager The Service Manager for the app.
|
|
62
|
-
*/
|
|
63
|
-
registerServiceManager(serviceManager: LiteServiceManager): void;
|
|
70
|
+
private _router;
|
|
64
71
|
private _serviceManager;
|
|
65
72
|
}
|
|
66
73
|
/**
|
package/lib/app.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
import { ServerConnection, ServiceManager } from '@jupyterlab/services';
|
|
3
4
|
import { Application } from '@lumino/application';
|
|
5
|
+
import { WebSocket } from 'mock-socket';
|
|
6
|
+
import { Router } from './router';
|
|
4
7
|
/**
|
|
5
8
|
* Server is the main application class. It is instantiated once and shared.
|
|
6
9
|
*/
|
|
@@ -11,6 +14,7 @@ export class JupyterLiteServer extends Application {
|
|
|
11
14
|
* @param options The instantiation options for a JupyterLiteServer application.
|
|
12
15
|
*/
|
|
13
16
|
constructor(options) {
|
|
17
|
+
var _a;
|
|
14
18
|
super(options);
|
|
15
19
|
/**
|
|
16
20
|
* The name of the application.
|
|
@@ -24,7 +28,20 @@ export class JupyterLiteServer extends Application {
|
|
|
24
28
|
* The version of the application.
|
|
25
29
|
*/
|
|
26
30
|
this.version = 'unknown';
|
|
27
|
-
this.
|
|
31
|
+
this._router = new Router();
|
|
32
|
+
this._serviceManager = new ServiceManager({
|
|
33
|
+
serverSettings: {
|
|
34
|
+
...ServerConnection.makeSettings(),
|
|
35
|
+
WebSocket,
|
|
36
|
+
fetch: (_a = this.fetch.bind(this)) !== null && _a !== void 0 ? _a : undefined,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get the underlying `Router` instance.
|
|
42
|
+
*/
|
|
43
|
+
get router() {
|
|
44
|
+
return this._router;
|
|
28
45
|
}
|
|
29
46
|
/**
|
|
30
47
|
* Get the underlying lite service manager for this app.
|
|
@@ -32,6 +49,18 @@ export class JupyterLiteServer extends Application {
|
|
|
32
49
|
get serviceManager() {
|
|
33
50
|
return this._serviceManager;
|
|
34
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Handle an incoming request from the client.
|
|
54
|
+
*
|
|
55
|
+
* @param req The incoming request
|
|
56
|
+
* @param init The optional init request
|
|
57
|
+
*/
|
|
58
|
+
async fetch(req, init) {
|
|
59
|
+
if (!(req instanceof Request)) {
|
|
60
|
+
throw Error('Request info is not a Request');
|
|
61
|
+
}
|
|
62
|
+
return this._router.route(req);
|
|
63
|
+
}
|
|
35
64
|
/**
|
|
36
65
|
* Attach the application shell to the DOM.
|
|
37
66
|
*
|
|
@@ -66,7 +95,7 @@ export class JupyterLiteServer extends Application {
|
|
|
66
95
|
if (!Array.isArray(data)) {
|
|
67
96
|
data = [data];
|
|
68
97
|
}
|
|
69
|
-
data.forEach(item => {
|
|
98
|
+
data.forEach((item) => {
|
|
70
99
|
try {
|
|
71
100
|
this.registerPlugin(item);
|
|
72
101
|
}
|
|
@@ -81,16 +110,8 @@ export class JupyterLiteServer extends Application {
|
|
|
81
110
|
* @param mods - The plugin modules to register.
|
|
82
111
|
*/
|
|
83
112
|
registerPluginModules(mods) {
|
|
84
|
-
mods.forEach(mod => {
|
|
113
|
+
mods.forEach((mod) => {
|
|
85
114
|
this.registerPluginModule(mod);
|
|
86
115
|
});
|
|
87
116
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Register the underlying lite service manager for this app.
|
|
90
|
-
*
|
|
91
|
-
* @param serviceManager The Service Manager for the app.
|
|
92
|
-
*/
|
|
93
|
-
registerServiceManager(serviceManager) {
|
|
94
|
-
this._serviceManager = serviceManager;
|
|
95
|
-
}
|
|
96
117
|
}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/lib/router.js
CHANGED
|
@@ -85,7 +85,7 @@ export class Router {
|
|
|
85
85
|
return r.callback.call(null, {
|
|
86
86
|
pathname,
|
|
87
87
|
body,
|
|
88
|
-
query: Object.fromEntries(url.searchParams)
|
|
88
|
+
query: Object.fromEntries(url.searchParams),
|
|
89
89
|
}, ...matches);
|
|
90
90
|
}
|
|
91
91
|
throw new Error('Cannot route ' + req.method + ' ' + req.url);
|
|
@@ -104,7 +104,7 @@ export class Router {
|
|
|
104
104
|
this._routes.push({
|
|
105
105
|
method,
|
|
106
106
|
pattern,
|
|
107
|
-
callback
|
|
107
|
+
callback,
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlite/server",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.24",
|
|
4
4
|
"description": "JupyterLite - Server",
|
|
5
5
|
"homepage": "https://github.com/jupyterlite/jupyterlite",
|
|
6
6
|
"bugs": {
|
|
@@ -42,30 +42,30 @@
|
|
|
42
42
|
"watch": "tsc -b --watch"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@jupyterlab/coreutils": "~5.2.
|
|
46
|
-
"@jupyterlab/nbformat": "~3.2.
|
|
47
|
-
"@jupyterlab/observables": "~4.2.
|
|
48
|
-
"@jupyterlab/services": "~6.2.
|
|
49
|
-
"@jupyterlab/settingregistry": "~3.2.
|
|
50
|
-
"@jupyterlab/statedb": "~3.2.
|
|
51
|
-
"@jupyterlite/contents": "^0.1.0-alpha.
|
|
52
|
-
"@jupyterlite/kernel": "^0.1.0-alpha.
|
|
53
|
-
"@jupyterlite/session": "^0.1.0-alpha.
|
|
54
|
-
"@jupyterlite/settings": "^0.1.0-alpha.
|
|
55
|
-
"@jupyterlite/translation": "^0.1.0-alpha.
|
|
45
|
+
"@jupyterlab/coreutils": "~5.2.9",
|
|
46
|
+
"@jupyterlab/nbformat": "~3.2.9",
|
|
47
|
+
"@jupyterlab/observables": "~4.2.9",
|
|
48
|
+
"@jupyterlab/services": "~6.2.9",
|
|
49
|
+
"@jupyterlab/settingregistry": "~3.2.9",
|
|
50
|
+
"@jupyterlab/statedb": "~3.2.9",
|
|
51
|
+
"@jupyterlite/contents": "^0.1.0-alpha.24",
|
|
52
|
+
"@jupyterlite/kernel": "^0.1.0-alpha.24",
|
|
53
|
+
"@jupyterlite/session": "^0.1.0-alpha.24",
|
|
54
|
+
"@jupyterlite/settings": "^0.1.0-alpha.24",
|
|
55
|
+
"@jupyterlite/translation": "^0.1.0-alpha.24",
|
|
56
56
|
"@lumino/application": "^1.20.0",
|
|
57
57
|
"@lumino/coreutils": "^1.8.0",
|
|
58
|
-
"mock-socket": "^9.0
|
|
58
|
+
"mock-socket": "^9.1.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@babel/core": "^7.11.6",
|
|
62
62
|
"@babel/preset-env": "^7.12.1",
|
|
63
|
-
"@jupyterlab/testutils": "~3.2.
|
|
63
|
+
"@jupyterlab/testutils": "~3.2.9",
|
|
64
64
|
"@types/jest": "^26.0.10",
|
|
65
65
|
"jest": "^26.4.2",
|
|
66
66
|
"rimraf": "~3.0.0",
|
|
67
67
|
"ts-jest": "^26.3.0",
|
|
68
|
-
"typescript": "~4.2
|
|
68
|
+
"typescript": "~4.5.2"
|
|
69
69
|
},
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
package/lib/server.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { IContents } from '@jupyterlite/contents';
|
|
2
|
-
import { IKernels, IKernelSpecs } from '@jupyterlite/kernel';
|
|
3
|
-
import { ISessions } from '@jupyterlite/session';
|
|
4
|
-
import { ISettings } from '@jupyterlite/settings';
|
|
5
|
-
import { ITranslation } from '@jupyterlite/translation';
|
|
6
|
-
/**
|
|
7
|
-
* A (very, very) simplified Jupyter Server running in the browser.
|
|
8
|
-
*/
|
|
9
|
-
export declare class JupyterServer {
|
|
10
|
-
/**
|
|
11
|
-
* Construct a new JupyterServer.
|
|
12
|
-
*/
|
|
13
|
-
constructor(options: JupyterServer.IOptions);
|
|
14
|
-
/**
|
|
15
|
-
* Handle an incoming request from the client.
|
|
16
|
-
*
|
|
17
|
-
* @param req The incoming request
|
|
18
|
-
* @param init The optional init request
|
|
19
|
-
*/
|
|
20
|
-
fetch(req: RequestInfo, init?: RequestInit | null | undefined): Promise<Response>;
|
|
21
|
-
/**
|
|
22
|
-
* Add the routes.
|
|
23
|
-
*/
|
|
24
|
-
private _addRoutes;
|
|
25
|
-
private _router;
|
|
26
|
-
private _contents;
|
|
27
|
-
private _kernels;
|
|
28
|
-
private _kernelspecs;
|
|
29
|
-
private _sessions;
|
|
30
|
-
private _settings;
|
|
31
|
-
private _translation;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* A namespace for JupyterServer statics.
|
|
35
|
-
*/
|
|
36
|
-
export declare namespace JupyterServer {
|
|
37
|
-
/**
|
|
38
|
-
* The instantiation options for a JupyterServer
|
|
39
|
-
*/
|
|
40
|
-
interface IOptions {
|
|
41
|
-
/**
|
|
42
|
-
* The contents service.
|
|
43
|
-
*/
|
|
44
|
-
contents: IContents;
|
|
45
|
-
/**
|
|
46
|
-
* The kernels service.
|
|
47
|
-
*/
|
|
48
|
-
kernels: IKernels;
|
|
49
|
-
/**
|
|
50
|
-
* The kernel specs service.
|
|
51
|
-
*/
|
|
52
|
-
kernelspecs: IKernelSpecs;
|
|
53
|
-
/**
|
|
54
|
-
* The sessions service.
|
|
55
|
-
*/
|
|
56
|
-
sessions: ISessions;
|
|
57
|
-
/**
|
|
58
|
-
* The settings service.
|
|
59
|
-
*/
|
|
60
|
-
settings: ISettings;
|
|
61
|
-
/**
|
|
62
|
-
* The translation service.
|
|
63
|
-
*/
|
|
64
|
-
translation: ITranslation;
|
|
65
|
-
}
|
|
66
|
-
}
|
package/lib/server.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { Router } from './router';
|
|
2
|
-
/**
|
|
3
|
-
* A (very, very) simplified Jupyter Server running in the browser.
|
|
4
|
-
*/
|
|
5
|
-
export class JupyterServer {
|
|
6
|
-
/**
|
|
7
|
-
* Construct a new JupyterServer.
|
|
8
|
-
*/
|
|
9
|
-
constructor(options) {
|
|
10
|
-
this._router = new Router();
|
|
11
|
-
const { contents, kernels, kernelspecs, sessions, settings, translation } = options;
|
|
12
|
-
this._contents = contents;
|
|
13
|
-
this._kernels = kernels;
|
|
14
|
-
this._kernelspecs = kernelspecs;
|
|
15
|
-
this._sessions = sessions;
|
|
16
|
-
this._settings = settings;
|
|
17
|
-
this._translation = translation;
|
|
18
|
-
this._addRoutes();
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Handle an incoming request from the client.
|
|
22
|
-
*
|
|
23
|
-
* @param req The incoming request
|
|
24
|
-
* @param init The optional init request
|
|
25
|
-
*/
|
|
26
|
-
async fetch(req, init) {
|
|
27
|
-
if (!(req instanceof Request)) {
|
|
28
|
-
throw Error('Request info is not a Request');
|
|
29
|
-
}
|
|
30
|
-
return this._router.route(req);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Add the routes.
|
|
34
|
-
*/
|
|
35
|
-
_addRoutes() {
|
|
36
|
-
const app = this._router;
|
|
37
|
-
// GET /api/contents/{path}/checkpoints - Get a list of checkpoints for a file
|
|
38
|
-
app.get('/api/contents/(.+)/checkpoints', async (req, filename) => {
|
|
39
|
-
const res = await this._contents.listCheckpoints(filename);
|
|
40
|
-
return new Response(JSON.stringify(res));
|
|
41
|
-
});
|
|
42
|
-
// POST /api/contents/{path}/checkpoints/{checkpoint_id} - Restore a file to a particular checkpointed state
|
|
43
|
-
app.post('/api/contents/(.+)/checkpoints/(.*)', async (req, filename, checkpoint) => {
|
|
44
|
-
const res = await this._contents.restoreCheckpoint(filename, checkpoint);
|
|
45
|
-
return new Response(JSON.stringify(res), { status: 204 });
|
|
46
|
-
});
|
|
47
|
-
// POST /api/contents/{path}/checkpoints - Create a new checkpoint for a file
|
|
48
|
-
app.post('/api/contents/(.+)/checkpoints', async (req, filename) => {
|
|
49
|
-
const res = await this._contents.createCheckpoint(filename);
|
|
50
|
-
return new Response(JSON.stringify(res), { status: 201 });
|
|
51
|
-
});
|
|
52
|
-
// DELETE /api/contents/{path}/checkpoints/{checkpoint_id} - Delete a checkpoint
|
|
53
|
-
app.delete('/api/contents/(.+)/checkpoints/(.*)', async (req, filename, checkpoint) => {
|
|
54
|
-
const res = await this._contents.deleteCheckpoint(filename, checkpoint);
|
|
55
|
-
return new Response(JSON.stringify(res), { status: 204 });
|
|
56
|
-
});
|
|
57
|
-
// GET /api/contents/{path} - Get contents of file or directory
|
|
58
|
-
app.get('/api/contents(.*)', async (req, filename) => {
|
|
59
|
-
var _a;
|
|
60
|
-
const options = {
|
|
61
|
-
content: ((_a = req.query) === null || _a === void 0 ? void 0 : _a.content) === '1'
|
|
62
|
-
};
|
|
63
|
-
const nb = await this._contents.get(filename, options);
|
|
64
|
-
if (!nb) {
|
|
65
|
-
return new Response(null, { status: 404 });
|
|
66
|
-
}
|
|
67
|
-
return new Response(JSON.stringify(nb));
|
|
68
|
-
});
|
|
69
|
-
// POST /api/contents/{path} - Create a new file in the specified path
|
|
70
|
-
app.post('/api/contents(.*)', async (req, path) => {
|
|
71
|
-
const options = req.body;
|
|
72
|
-
const copyFrom = options === null || options === void 0 ? void 0 : options.copy_from;
|
|
73
|
-
let file;
|
|
74
|
-
if (copyFrom) {
|
|
75
|
-
file = await this._contents.copy(copyFrom, path);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
file = await this._contents.newUntitled(options);
|
|
79
|
-
}
|
|
80
|
-
if (!file) {
|
|
81
|
-
return new Response(null, { status: 400 });
|
|
82
|
-
}
|
|
83
|
-
return new Response(JSON.stringify(file), { status: 201 });
|
|
84
|
-
});
|
|
85
|
-
// PATCH /api/contents/{path} - Rename a file or directory without re-uploading content
|
|
86
|
-
app.patch('/api/contents(.*)', async (req, filename) => {
|
|
87
|
-
var _a, _b;
|
|
88
|
-
const newPath = (_b = (_a = req.body) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : '';
|
|
89
|
-
filename = filename[0] === '/' ? filename.slice(1) : filename;
|
|
90
|
-
const nb = await this._contents.rename(filename, newPath);
|
|
91
|
-
return new Response(JSON.stringify(nb));
|
|
92
|
-
});
|
|
93
|
-
// PUT /api/contents/{path} - Save or upload a file
|
|
94
|
-
app.put('/api/contents/(.+)', async (req, filename) => {
|
|
95
|
-
const body = req.body;
|
|
96
|
-
const nb = await this._contents.save(filename, body);
|
|
97
|
-
return new Response(JSON.stringify(nb));
|
|
98
|
-
});
|
|
99
|
-
// DELETE /api/contents/{path} - Delete a file in the given path
|
|
100
|
-
app.delete('/api/contents/(.+)', async (req, filename) => {
|
|
101
|
-
await this._contents.delete(filename);
|
|
102
|
-
return new Response(null, { status: 204 });
|
|
103
|
-
});
|
|
104
|
-
// POST /api/kernels/{kernel_id} - Restart a kernel
|
|
105
|
-
app.post('/api/kernels/(.*)/restart', async (req, kernelId) => {
|
|
106
|
-
const res = await this._kernels.restart(kernelId);
|
|
107
|
-
return new Response(JSON.stringify(res));
|
|
108
|
-
});
|
|
109
|
-
// DELETE /api/kernels/{kernel_id} - Kill a kernel and delete the kernel id
|
|
110
|
-
app.delete('/api/kernels/(.*)', async (req, kernelId) => {
|
|
111
|
-
const res = await this._kernels.shutdown(kernelId);
|
|
112
|
-
return new Response(JSON.stringify(res), { status: 204 });
|
|
113
|
-
});
|
|
114
|
-
// KernelSpecs
|
|
115
|
-
app.get('/api/kernelspecs', async (req) => {
|
|
116
|
-
const res = this._kernelspecs.specs;
|
|
117
|
-
return new Response(JSON.stringify(res));
|
|
118
|
-
});
|
|
119
|
-
// NbConvert
|
|
120
|
-
app.get('/api/nbconvert', async (req) => {
|
|
121
|
-
return new Response(JSON.stringify({}));
|
|
122
|
-
});
|
|
123
|
-
// GET /api/sessions/{session} - Get session
|
|
124
|
-
app.get('/api/sessions/(.+)', async (req, id) => {
|
|
125
|
-
const session = await this._sessions.get(id);
|
|
126
|
-
return new Response(JSON.stringify(session), { status: 200 });
|
|
127
|
-
});
|
|
128
|
-
// GET /api/sessions - List available sessions
|
|
129
|
-
app.get('/api/sessions', async (req) => {
|
|
130
|
-
const sessions = await this._sessions.list();
|
|
131
|
-
return new Response(JSON.stringify(sessions), { status: 200 });
|
|
132
|
-
});
|
|
133
|
-
// PATCH /api/sessions/{session} - This can be used to rename a session
|
|
134
|
-
app.patch('/api/sessions(.*)', async (req, id) => {
|
|
135
|
-
const options = req.body;
|
|
136
|
-
const session = await this._sessions.patch(options);
|
|
137
|
-
return new Response(JSON.stringify(session), { status: 200 });
|
|
138
|
-
});
|
|
139
|
-
// DELETE /api/sessions/{session} - Delete a session
|
|
140
|
-
app.delete('/api/sessions/(.+)', async (req, id) => {
|
|
141
|
-
await this._sessions.shutdown(id);
|
|
142
|
-
return new Response(null, { status: 204 });
|
|
143
|
-
});
|
|
144
|
-
// POST /api/sessions - Create a new session or return an existing session if a session of the same name already exists
|
|
145
|
-
app.post('/api/sessions', async (req) => {
|
|
146
|
-
const options = req.body;
|
|
147
|
-
const session = await this._sessions.startNew(options);
|
|
148
|
-
return new Response(JSON.stringify(session), { status: 201 });
|
|
149
|
-
});
|
|
150
|
-
// Settings
|
|
151
|
-
// TODO: improve the regex
|
|
152
|
-
// const pluginPattern = new RegExp(/(?:@([^/]+?)[/])?([^/]+?):(\w+)/);
|
|
153
|
-
const pluginPattern = '/api/settings/((?:@([^/]+?)[/])?([^/]+?):([^:]+))$';
|
|
154
|
-
app.get(pluginPattern, async (req, pluginId) => {
|
|
155
|
-
const settings = await this._settings.get(pluginId);
|
|
156
|
-
return new Response(JSON.stringify(settings));
|
|
157
|
-
});
|
|
158
|
-
app.put(pluginPattern, async (req, pluginId) => {
|
|
159
|
-
const body = req.body;
|
|
160
|
-
const { raw } = body;
|
|
161
|
-
await this._settings.save(pluginId, raw);
|
|
162
|
-
return new Response(null, { status: 204 });
|
|
163
|
-
});
|
|
164
|
-
app.get('/api/settings', async (req) => {
|
|
165
|
-
const plugins = await this._settings.getAll();
|
|
166
|
-
return new Response(JSON.stringify(plugins));
|
|
167
|
-
});
|
|
168
|
-
app.get('/api/translations/?(.*)', async (req, locale) => {
|
|
169
|
-
const data = await this._translation.get(locale || 'all');
|
|
170
|
-
return new Response(JSON.stringify(data));
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
package/lib/service.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ServiceManager } from '@jupyterlab/services';
|
|
2
|
-
import { JupyterServer } from './server';
|
|
3
|
-
/**
|
|
4
|
-
* A custom ServiceManager to run in the browser
|
|
5
|
-
*/
|
|
6
|
-
export declare class LiteServiceManager extends ServiceManager {
|
|
7
|
-
/**
|
|
8
|
-
* Construct a new service provider.
|
|
9
|
-
*
|
|
10
|
-
* @param options The instantiation options for the service manager.
|
|
11
|
-
*/
|
|
12
|
-
constructor(options: LiteServiceManager.IOptions);
|
|
13
|
-
/**
|
|
14
|
-
* Get the underlying Jupyter Server
|
|
15
|
-
*/
|
|
16
|
-
get server(): JupyterServer;
|
|
17
|
-
private _server;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* A namespace for LiteServiceManager statics.
|
|
21
|
-
*/
|
|
22
|
-
export declare namespace LiteServiceManager {
|
|
23
|
-
/**
|
|
24
|
-
* The instantiation options for a LiteServiceManager.
|
|
25
|
-
*/
|
|
26
|
-
interface IOptions extends ServiceManager.IOptions {
|
|
27
|
-
/**
|
|
28
|
-
* The JupyterServer
|
|
29
|
-
*/
|
|
30
|
-
server: JupyterServer;
|
|
31
|
-
}
|
|
32
|
-
}
|
package/lib/service.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ServiceManager, ServerConnection } from '@jupyterlab/services';
|
|
2
|
-
import { WebSocket } from 'mock-socket';
|
|
3
|
-
/**
|
|
4
|
-
* A custom ServiceManager to run in the browser
|
|
5
|
-
*/
|
|
6
|
-
export class LiteServiceManager extends ServiceManager {
|
|
7
|
-
/**
|
|
8
|
-
* Construct a new service provider.
|
|
9
|
-
*
|
|
10
|
-
* @param options The instantiation options for the service manager.
|
|
11
|
-
*/
|
|
12
|
-
constructor(options) {
|
|
13
|
-
var _a;
|
|
14
|
-
const server = options.server;
|
|
15
|
-
super({
|
|
16
|
-
...options,
|
|
17
|
-
serverSettings: {
|
|
18
|
-
...ServerConnection.makeSettings(),
|
|
19
|
-
WebSocket,
|
|
20
|
-
fetch: (_a = server.fetch.bind(server)) !== null && _a !== void 0 ? _a : undefined
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
this._server = server;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Get the underlying Jupyter Server
|
|
27
|
-
*/
|
|
28
|
-
get server() {
|
|
29
|
-
return this._server;
|
|
30
|
-
}
|
|
31
|
-
}
|