@jupyterlite/server 0.6.0-alpha.1 → 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/index.d.ts +1 -3
- package/lib/index.js +1 -3
- package/lib/index.js.map +1 -1
- package/lib/service-worker-manager.d.ts +68 -0
- package/lib/service-worker-manager.js +195 -0
- package/lib/service-worker-manager.js.map +1 -0
- package/lib/service-worker.d.ts +2 -2
- package/lib/service-worker.js +18 -11
- package/lib/service-worker.js.map +1 -1
- package/lib/tokens.d.ts +25 -0
- package/lib/tokens.js +1 -1
- package/lib/tokens.js.map +1 -1
- package/package.json +16 -17
- package/src/index.ts +1 -3
- package/src/service-worker-manager.ts +253 -0
- package/src/service-worker.ts +21 -11
- package/src/tokens.ts +34 -1
- package/lib/app.d.ts +0 -87
- package/lib/app.js +0 -155
- package/lib/app.js.map +0 -1
- package/lib/router.d.ts +0 -99
- package/lib/router.js +0 -111
- package/lib/router.js.map +0 -1
- package/lib/service-manager.d.ts +0 -21
- package/lib/service-manager.js +0 -96
- package/lib/service-manager.js.map +0 -1
- package/lib/status.d.ts +0 -18
- package/lib/status.js +0 -21
- package/lib/status.js.map +0 -1
- package/src/app.ts +0 -200
- package/src/router.ts +0 -170
- package/src/service-manager.ts +0 -118
- package/src/status.ts +0 -21
package/lib/router.d.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { ReadonlyJSONObject } from '@lumino/coreutils';
|
|
2
|
-
/**
|
|
3
|
-
* A simple router.
|
|
4
|
-
*/
|
|
5
|
-
export declare class Router {
|
|
6
|
-
/**
|
|
7
|
-
* Add a new GET route
|
|
8
|
-
*
|
|
9
|
-
* @param pattern The pattern to match
|
|
10
|
-
* @param callback The function to call on pattern match
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
get(pattern: string | RegExp, callback: Router.Callback): void;
|
|
14
|
-
/**
|
|
15
|
-
* Add a new PUT route
|
|
16
|
-
*
|
|
17
|
-
* @param pattern The pattern to match
|
|
18
|
-
* @param callback The function to call on pattern match
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
put(pattern: string | RegExp, callback: Router.Callback): void;
|
|
22
|
-
/**
|
|
23
|
-
* Add a new POST route
|
|
24
|
-
*
|
|
25
|
-
* @param pattern The pattern to match
|
|
26
|
-
* @param callback The function to call on pattern match
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
post(pattern: string | RegExp, callback: Router.Callback): void;
|
|
30
|
-
/**
|
|
31
|
-
* Add a new PATCH route
|
|
32
|
-
*
|
|
33
|
-
* @param pattern The pattern to match
|
|
34
|
-
* @param callback The function to call on pattern match
|
|
35
|
-
*
|
|
36
|
-
*/
|
|
37
|
-
patch(pattern: string | RegExp, callback: Router.Callback): void;
|
|
38
|
-
/**
|
|
39
|
-
* Add a new DELETE route
|
|
40
|
-
*
|
|
41
|
-
* @param pattern The pattern to match
|
|
42
|
-
* @param callback The function to call on pattern match
|
|
43
|
-
*
|
|
44
|
-
*/
|
|
45
|
-
delete(pattern: string | RegExp, callback: Router.Callback): void;
|
|
46
|
-
/**
|
|
47
|
-
* Route a request.
|
|
48
|
-
*
|
|
49
|
-
* @param req The request to route.
|
|
50
|
-
*/
|
|
51
|
-
route(req: Request): Promise<Response>;
|
|
52
|
-
/**
|
|
53
|
-
* Add a new route.
|
|
54
|
-
*
|
|
55
|
-
* @param method The method
|
|
56
|
-
* @param pattern The pattern
|
|
57
|
-
* @param callback The callback
|
|
58
|
-
*/
|
|
59
|
-
private _add;
|
|
60
|
-
private _routes;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* A namespace for Router statics.
|
|
64
|
-
*/
|
|
65
|
-
export declare namespace Router {
|
|
66
|
-
/**
|
|
67
|
-
* The Callback type.
|
|
68
|
-
*/
|
|
69
|
-
type Callback = (req: IRequest, ...args: string[]) => Promise<Response>;
|
|
70
|
-
/**
|
|
71
|
-
* The Method type.
|
|
72
|
-
*/
|
|
73
|
-
type Method = 'GET' | 'PUT' | 'POST' | 'PATCH' | 'DELETE';
|
|
74
|
-
/**
|
|
75
|
-
* The interface for a parsed request
|
|
76
|
-
*/
|
|
77
|
-
interface IRequest {
|
|
78
|
-
/**
|
|
79
|
-
* The path for the url.
|
|
80
|
-
*/
|
|
81
|
-
pathname: string;
|
|
82
|
-
/**
|
|
83
|
-
* The optional query parameters.
|
|
84
|
-
*/
|
|
85
|
-
query?: ReadonlyJSONObject;
|
|
86
|
-
/**
|
|
87
|
-
* The optional body parameters.
|
|
88
|
-
*/
|
|
89
|
-
body?: ReadonlyJSONObject;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* An interface for a route.
|
|
93
|
-
*/
|
|
94
|
-
interface IRoute {
|
|
95
|
-
method: Method;
|
|
96
|
-
pattern: string | RegExp;
|
|
97
|
-
callback: Callback;
|
|
98
|
-
}
|
|
99
|
-
}
|
package/lib/router.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A simple router.
|
|
3
|
-
*/
|
|
4
|
-
export class Router {
|
|
5
|
-
constructor() {
|
|
6
|
-
this._routes = [];
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Add a new GET route
|
|
10
|
-
*
|
|
11
|
-
* @param pattern The pattern to match
|
|
12
|
-
* @param callback The function to call on pattern match
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
get(pattern, callback) {
|
|
16
|
-
this._add('GET', pattern, callback);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Add a new PUT route
|
|
20
|
-
*
|
|
21
|
-
* @param pattern The pattern to match
|
|
22
|
-
* @param callback The function to call on pattern match
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
put(pattern, callback) {
|
|
26
|
-
this._add('PUT', pattern, callback);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Add a new POST route
|
|
30
|
-
*
|
|
31
|
-
* @param pattern The pattern to match
|
|
32
|
-
* @param callback The function to call on pattern match
|
|
33
|
-
*
|
|
34
|
-
*/
|
|
35
|
-
post(pattern, callback) {
|
|
36
|
-
this._add('POST', pattern, callback);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Add a new PATCH route
|
|
40
|
-
*
|
|
41
|
-
* @param pattern The pattern to match
|
|
42
|
-
* @param callback The function to call on pattern match
|
|
43
|
-
*
|
|
44
|
-
*/
|
|
45
|
-
patch(pattern, callback) {
|
|
46
|
-
this._add('PATCH', pattern, callback);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Add a new DELETE route
|
|
50
|
-
*
|
|
51
|
-
* @param pattern The pattern to match
|
|
52
|
-
* @param callback The function to call on pattern match
|
|
53
|
-
*
|
|
54
|
-
*/
|
|
55
|
-
delete(pattern, callback) {
|
|
56
|
-
this._add('DELETE', pattern, callback);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Route a request.
|
|
60
|
-
*
|
|
61
|
-
* @param req The request to route.
|
|
62
|
-
*/
|
|
63
|
-
async route(req) {
|
|
64
|
-
const url = new URL(req.url);
|
|
65
|
-
const { method } = req;
|
|
66
|
-
const { pathname } = url;
|
|
67
|
-
for (const r of this._routes) {
|
|
68
|
-
if (r.method !== method) {
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
const match = pathname.match(r.pattern);
|
|
72
|
-
if (!match) {
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
const matches = match.slice(1);
|
|
76
|
-
let body;
|
|
77
|
-
if (r.method === 'PATCH' || r.method === 'PUT' || r.method === 'POST') {
|
|
78
|
-
try {
|
|
79
|
-
body = JSON.parse(await req.text());
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
body = undefined;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return r.callback.call(null, {
|
|
86
|
-
pathname,
|
|
87
|
-
body,
|
|
88
|
-
query: Object.fromEntries(url.searchParams),
|
|
89
|
-
}, ...matches);
|
|
90
|
-
}
|
|
91
|
-
throw new Error('Cannot route ' + req.method + ' ' + req.url);
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Add a new route.
|
|
95
|
-
*
|
|
96
|
-
* @param method The method
|
|
97
|
-
* @param pattern The pattern
|
|
98
|
-
* @param callback The callback
|
|
99
|
-
*/
|
|
100
|
-
_add(method, pattern, callback) {
|
|
101
|
-
if (typeof pattern === 'string') {
|
|
102
|
-
pattern = new RegExp(pattern);
|
|
103
|
-
}
|
|
104
|
-
this._routes.push({
|
|
105
|
-
method,
|
|
106
|
-
pattern,
|
|
107
|
-
callback,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
//# sourceMappingURL=router.js.map
|
package/lib/router.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,MAAM;IAAnB;QAuHU,YAAO,GAAoB,EAAE,CAAC;IACxC,CAAC;IAvHC;;;;;;OAMG;IACH,GAAG,CAAC,OAAwB,EAAE,QAAyB;QACrD,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACH,GAAG,CAAC,OAAwB,EAAE,QAAyB;QACrD,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACH,IAAI,CAAC,OAAwB,EAAE,QAAyB;QACtD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,OAAwB,EAAE,QAAyB;QACvD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,Q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Ae,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IAChE,CAAC;IAED;;;;;;OAMG;IACK,IAAI,CACV,MAAqB,EACrB,OAAwB,EACxB,QAAyB;QAEzB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC/B,OAAO,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;SAC/B;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YAChB,MAAM;YACN,OAAO;YACP,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;CAGF"}
|
package/lib/service-manager.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ISignal } from '@lumino/signaling';
|
|
2
|
-
import { IServiceWorkerManager } from './tokens';
|
|
3
|
-
export declare class ServiceWorkerManager implements IServiceWorkerManager {
|
|
4
|
-
constructor(options?: IServiceWorkerManager.IOptions);
|
|
5
|
-
/**
|
|
6
|
-
* A signal emitted when the registration changes.
|
|
7
|
-
*/
|
|
8
|
-
get registrationChanged(): ISignal<IServiceWorkerManager, ServiceWorkerRegistration | null>;
|
|
9
|
-
/**
|
|
10
|
-
* Whether the ServiceWorker is enabled or not.
|
|
11
|
-
*/
|
|
12
|
-
get enabled(): boolean;
|
|
13
|
-
get ready(): Promise<void>;
|
|
14
|
-
private unregisterOldServiceWorkers;
|
|
15
|
-
private initialize;
|
|
16
|
-
private _pingServiceWorker;
|
|
17
|
-
private _setRegistration;
|
|
18
|
-
private _registration;
|
|
19
|
-
private _registrationChanged;
|
|
20
|
-
private _ready;
|
|
21
|
-
}
|
package/lib/service-manager.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { PromiseDelegate } from '@lumino/coreutils';
|
|
2
|
-
import { Signal } from '@lumino/signaling';
|
|
3
|
-
import { PageConfig, URLExt } from '@jupyterlab/coreutils';
|
|
4
|
-
import { WORKER_NAME } from './tokens';
|
|
5
|
-
const VERSION = PageConfig.getOption('appVersion');
|
|
6
|
-
const SW_PING_ENDPOINT = '/api/service-worker-heartbeat';
|
|
7
|
-
export class ServiceWorkerManager {
|
|
8
|
-
constructor(options) {
|
|
9
|
-
var _a;
|
|
10
|
-
this.unregisterOldServiceWorkers = async (scriptURL) => {
|
|
11
|
-
const versionKey = `${scriptURL}-version`;
|
|
12
|
-
// Check if we have an installed version. If we do, compare it to the current version
|
|
13
|
-
// and unregister all service workers if they are different.
|
|
14
|
-
const installedVersion = localStorage.getItem(versionKey);
|
|
15
|
-
if ((installedVersion && installedVersion !== VERSION) || !installedVersion) {
|
|
16
|
-
// eslint-disable-next-line no-console
|
|
17
|
-
console.info('New version, unregistering existing service workers.');
|
|
18
|
-
const registrations = await navigator.serviceWorker.getRegistrations();
|
|
19
|
-
await Promise.all(registrations.map((registration) => registration.unregister()));
|
|
20
|
-
// eslint-disable-next-line no-console
|
|
21
|
-
console.info('All existing service workers have been unregistered.');
|
|
22
|
-
}
|
|
23
|
-
localStorage.setItem(versionKey, VERSION);
|
|
24
|
-
};
|
|
25
|
-
this._pingServiceWorker = async () => {
|
|
26
|
-
const response = await fetch(SW_PING_ENDPOINT);
|
|
27
|
-
const text = await response.text();
|
|
28
|
-
if (text === 'ok') {
|
|
29
|
-
setTimeout(this._pingServiceWorker, 20000);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
this._registration = null;
|
|
33
|
-
this._registrationChanged = new Signal(this);
|
|
34
|
-
this._ready = new PromiseDelegate();
|
|
35
|
-
const workerUrl = (_a = options === null || options === void 0 ? void 0 : options.workerUrl) !== null && _a !== void 0 ? _a : URLExt.join(PageConfig.getBaseUrl(), WORKER_NAME);
|
|
36
|
-
const fullWorkerUrl = new URL(workerUrl, window.location.href);
|
|
37
|
-
const enableCache = PageConfig.getOption('enableServiceWorkerCache') || 'false';
|
|
38
|
-
fullWorkerUrl.searchParams.set('enableCache', enableCache);
|
|
39
|
-
void this.initialize(fullWorkerUrl.href).catch(console.warn);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* A signal emitted when the registration changes.
|
|
43
|
-
*/
|
|
44
|
-
get registrationChanged() {
|
|
45
|
-
return this._registrationChanged;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Whether the ServiceWorker is enabled or not.
|
|
49
|
-
*/
|
|
50
|
-
get enabled() {
|
|
51
|
-
return this._registration !== null;
|
|
52
|
-
}
|
|
53
|
-
get ready() {
|
|
54
|
-
return this._ready.promise;
|
|
55
|
-
}
|
|
56
|
-
async initialize(workerUrl) {
|
|
57
|
-
const { serviceWorker } = navigator;
|
|
58
|
-
let registration = null;
|
|
59
|
-
if (!serviceWorker) {
|
|
60
|
-
console.warn('ServiceWorkers not supported in this browser');
|
|
61
|
-
}
|
|
62
|
-
else if (serviceWorker.controller) {
|
|
63
|
-
const scriptURL = serviceWorker.controller.scriptURL;
|
|
64
|
-
await this.unregisterOldServiceWorkers(scriptURL);
|
|
65
|
-
registration = (await serviceWorker.getRegistration(scriptURL)) || null;
|
|
66
|
-
// eslint-disable-next-line no-console
|
|
67
|
-
console.info('JupyterLite ServiceWorker was already registered');
|
|
68
|
-
}
|
|
69
|
-
if (!registration && serviceWorker) {
|
|
70
|
-
try {
|
|
71
|
-
// eslint-disable-next-line no-console
|
|
72
|
-
console.info('Registering new JupyterLite ServiceWorker', workerUrl);
|
|
73
|
-
registration = await serviceWorker.register(workerUrl);
|
|
74
|
-
// eslint-disable-next-line no-console
|
|
75
|
-
console.info('JupyterLite ServiceWorker was sucessfully registered');
|
|
76
|
-
}
|
|
77
|
-
catch (err) {
|
|
78
|
-
console.warn(err);
|
|
79
|
-
console.warn(`JupyterLite ServiceWorker registration unexpectedly failed: ${err}`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
this._setRegistration(registration);
|
|
83
|
-
if (!registration) {
|
|
84
|
-
this._ready.reject(void 0);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
this._ready.resolve(void 0);
|
|
88
|
-
setTimeout(this._pingServiceWorker, 20000);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
_setRegistration(registration) {
|
|
92
|
-
this._registration = registration;
|
|
93
|
-
this._registrationChanged.emit(this._registration);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=service-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service-manager.js","sourceRoot":"","sources":["../src/service-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAW,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAyB,WAAW,EAAE,MAAM,UAAU,CAAC;AAE9D,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AACnD,MAAM,gBAAgB,GAAG,+BAA+B,CAAC;AACzD,MAAM,OAAO,oBAAoB;IAC/B,YAAY,OAAwC;;QA8B5C,gCAA2B,GAAG,KAAK,EAAE,SAAiB,EAAE,EAAE;YAChE,MAAM,UAAU,GAAG,GAAG,SAAS,UAAU,CAAC;YAC1C,qFAAqF;YACrF,4DAA4D;YAC5D,MAAM,gBAAgB,GAAG,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YAE1D,IAAI,CAAC,gBAAgB,IAAI,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE;gBAC3E,sCAAsC;gBACtC,OAAO,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC;gBACrE,MAAM,aAAa,GAAG,MAAM,SAAS,CAAC,aAAa,CAAC,gBAAgB,EAAE,CAAC;gBAEvE,MAAM,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,CA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5B;aAAM;YACL,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;YAC5B,UAAU,CAAC,IAAI,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;SAC5C;IACH,CAAC;IAQO,gBAAgB,CAAC,YAA8C;QACrE,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACrD,CAAC;CAOF"}
|
package/lib/status.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A class to handle requests to /api/status
|
|
3
|
-
*/
|
|
4
|
-
export declare class Status {
|
|
5
|
-
/**
|
|
6
|
-
* Get the status
|
|
7
|
-
*/
|
|
8
|
-
get(): any;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* A namespace for Status statics.
|
|
12
|
-
*/
|
|
13
|
-
export declare namespace Status {
|
|
14
|
-
/**
|
|
15
|
-
* The url for the status service.
|
|
16
|
-
*/
|
|
17
|
-
const STATUS_SERVICE_URL = "/api/status";
|
|
18
|
-
}
|
package/lib/status.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A class to handle requests to /api/status
|
|
3
|
-
*/
|
|
4
|
-
export class Status {
|
|
5
|
-
/**
|
|
6
|
-
* Get the status
|
|
7
|
-
*/
|
|
8
|
-
get() {
|
|
9
|
-
return {};
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* A namespace for Status statics.
|
|
14
|
-
*/
|
|
15
|
-
(function (Status) {
|
|
16
|
-
/**
|
|
17
|
-
* The url for the status service.
|
|
18
|
-
*/
|
|
19
|
-
Status.STATUS_SERVICE_URL = '/api/status';
|
|
20
|
-
})(Status || (Status = {}));
|
|
21
|
-
//# sourceMappingURL=status.js.map
|
package/lib/status.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,MAAM;IACjB;;OAEG;IACH,GAAG;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAED;;GAEG;AACH,WAAiB,MAAM;IACrB;;OAEG;IACU,yBAAkB,GAAG,aAAa,CAAC;AAClD,CAAC,EALgB,MAAM,KAAN,MAAM,QAKtB"}
|
package/src/app.ts
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Jupyter Development Team.
|
|
2
|
-
// Distributed under the terms of the Modified BSD License.
|
|
3
|
-
|
|
4
|
-
import { Event, ServerConnection, ServiceManager } from '@jupyterlab/services';
|
|
5
|
-
|
|
6
|
-
import { Application, IPlugin } from '@lumino/application';
|
|
7
|
-
|
|
8
|
-
import { Signal, Stream } from '@lumino/signaling';
|
|
9
|
-
|
|
10
|
-
import { WebSocket } from 'mock-socket';
|
|
11
|
-
|
|
12
|
-
import { Router } from './router';
|
|
13
|
-
|
|
14
|
-
export type JupyterLiteServerPlugin<T> = IPlugin<JupyterLiteServer, T>;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* A local event manager service.
|
|
18
|
-
*
|
|
19
|
-
* #### Notes
|
|
20
|
-
* Schema IDs are not verified and all client-emitted events emit.
|
|
21
|
-
*/
|
|
22
|
-
class LocalEventManager implements Event.IManager {
|
|
23
|
-
constructor(options: { serverSettings: ServerConnection.ISettings }) {
|
|
24
|
-
this._serverSettings = options.serverSettings;
|
|
25
|
-
this._stream = new Stream(this);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async emit({ data, schema_id }: Event.Request): Promise<void> {
|
|
29
|
-
this._stream.emit({ ...data, schema_id });
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
dispose(): void {
|
|
33
|
-
if (this.isDisposed) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
this._isDisposed = true;
|
|
37
|
-
Signal.clearData(this);
|
|
38
|
-
this._stream.stop();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
get isDisposed(): boolean {
|
|
42
|
-
return this._isDisposed;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
get stream() {
|
|
46
|
-
return this._stream;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
get serverSettings(): ServerConnection.ISettings {
|
|
50
|
-
return this._serverSettings;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
private _isDisposed = false;
|
|
54
|
-
private _serverSettings: ServerConnection.ISettings;
|
|
55
|
-
private _stream: Stream<this, Event.Emission>;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Server is the main application class. It is instantiated once and shared.
|
|
60
|
-
*/
|
|
61
|
-
export class JupyterLiteServer extends Application<never> {
|
|
62
|
-
/**
|
|
63
|
-
* Construct a new JupyterLite object.
|
|
64
|
-
*
|
|
65
|
-
* @param options The instantiation options for a JupyterLiteServer application.
|
|
66
|
-
*/
|
|
67
|
-
constructor(options: Application.IOptions<never>) {
|
|
68
|
-
super(options);
|
|
69
|
-
const serverSettings = {
|
|
70
|
-
...ServerConnection.makeSettings(),
|
|
71
|
-
WebSocket,
|
|
72
|
-
fetch: this.fetch.bind(this) ?? undefined,
|
|
73
|
-
};
|
|
74
|
-
this._serviceManager = new ServiceManager({
|
|
75
|
-
standby: 'never',
|
|
76
|
-
serverSettings,
|
|
77
|
-
events: new LocalEventManager({ serverSettings }),
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* The name of the application.
|
|
83
|
-
*/
|
|
84
|
-
readonly name = 'JupyterLite Server';
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* A namespace/prefix plugins may use to denote their provenance.
|
|
88
|
-
*/
|
|
89
|
-
readonly namespace = this.name;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* The version of the application.
|
|
93
|
-
*/
|
|
94
|
-
readonly version = 'unknown';
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Get the underlying `Router` instance.
|
|
98
|
-
*/
|
|
99
|
-
get router(): Router {
|
|
100
|
-
return this._router;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Get the underlying lite service manager for this app.
|
|
105
|
-
*/
|
|
106
|
-
get serviceManager(): ServiceManager {
|
|
107
|
-
return this._serviceManager;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Handle an incoming request from the client.
|
|
112
|
-
*
|
|
113
|
-
* @param req The incoming request
|
|
114
|
-
* @param init The optional init request
|
|
115
|
-
*/
|
|
116
|
-
async fetch(
|
|
117
|
-
req: RequestInfo,
|
|
118
|
-
init?: RequestInit | null | undefined,
|
|
119
|
-
): Promise<Response> {
|
|
120
|
-
if (!(req instanceof Request)) {
|
|
121
|
-
throw Error('Request info is not a Request');
|
|
122
|
-
}
|
|
123
|
-
return this._router.route(req);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Attach the application shell to the DOM.
|
|
128
|
-
*
|
|
129
|
-
* @param id - The id of the host node for the shell, or `''`.
|
|
130
|
-
*
|
|
131
|
-
* #### Notes
|
|
132
|
-
* For this server application there is no shell to attach
|
|
133
|
-
*/
|
|
134
|
-
protected attachShell(id: string): void {
|
|
135
|
-
// no-op
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* A method invoked on a window `'resize'` event.
|
|
140
|
-
*
|
|
141
|
-
* #### Notes
|
|
142
|
-
* For this server application there is no shell to update
|
|
143
|
-
*/
|
|
144
|
-
protected evtResize(event: Event): void {
|
|
145
|
-
// no-op
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Register plugins from a plugin module.
|
|
150
|
-
*
|
|
151
|
-
* @param mod - The plugin module to register.
|
|
152
|
-
*/
|
|
153
|
-
registerPluginModule(mod: JupyterLiteServer.IPluginModule): void {
|
|
154
|
-
let data = mod.default;
|
|
155
|
-
// Handle commonjs exports.
|
|
156
|
-
if (!Object.prototype.hasOwnProperty.call(mod, '__esModule')) {
|
|
157
|
-
data = mod as any;
|
|
158
|
-
}
|
|
159
|
-
if (!Array.isArray(data)) {
|
|
160
|
-
data = [data];
|
|
161
|
-
}
|
|
162
|
-
data.forEach((item) => {
|
|
163
|
-
try {
|
|
164
|
-
this.registerPlugin(item);
|
|
165
|
-
} catch (error) {
|
|
166
|
-
console.error(error);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Register the plugins from multiple plugin modules.
|
|
173
|
-
*
|
|
174
|
-
* @param mods - The plugin modules to register.
|
|
175
|
-
*/
|
|
176
|
-
registerPluginModules(mods: JupyterLiteServer.IPluginModule[]): void {
|
|
177
|
-
mods.forEach((mod) => {
|
|
178
|
-
this.registerPluginModule(mod);
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
private _router = new Router();
|
|
183
|
-
private _serviceManager: ServiceManager;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* A namespace for Server statics.
|
|
188
|
-
*/
|
|
189
|
-
export namespace JupyterLiteServer {
|
|
190
|
-
/**
|
|
191
|
-
* The interface for a module that exports a plugin or plugins as
|
|
192
|
-
* the default value.
|
|
193
|
-
*/
|
|
194
|
-
export interface IPluginModule {
|
|
195
|
-
/**
|
|
196
|
-
* The default export.
|
|
197
|
-
*/
|
|
198
|
-
default: IPlugin<JupyterLiteServer, any> | IPlugin<JupyterLiteServer, any>[];
|
|
199
|
-
}
|
|
200
|
-
}
|