@jupyterlite/server 0.6.0-alpha.2 → 0.6.0-alpha.3

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 CHANGED
@@ -1,4 +1,2 @@
1
- export * from './app';
2
- export * from './router';
3
1
  export * from './tokens';
4
- export * from './service-manager';
2
+ export * from './service-worker-manager';
package/lib/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  // Copyright (c) Jupyter Development Team.
2
2
  // Distributed under the terms of the Modified BSD License.
3
- export * from './app';
4
- export * from './router';
5
3
  export * from './tokens';
6
- export * from './service-manager';
4
+ export * from './service-worker-manager';
7
5
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,cAAc,UAAU,CAAC;AACzB,cAAc,0BAA0B,CAAC"}
@@ -93,4 +93,4 @@ export class ServiceWorkerManager {
93
93
  this._registrationChanged.emit(this._registration);
94
94
  }
95
95
  }
96
- //# sourceMappingURL=service-manager.js.map
96
+ //# sourceMappingURL=service-worker-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-worker-manager.js","sourceRoot":"","sources":["../src/service-worker-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,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,CAAC;YAElD,YAAY,GAAG,CAAC,MAAM,aAAa,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,IAAI,IAAI,CAAC;YACxE,sCAAsC;YACtC,OAAO,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAC;SAClE;QAED,IAAI,CAAC,YAAY,IAAI,aAAa,EAAE;YAClC,IAAI;gBACF,sCAAsC;gBACtC,OAAO,CAAC,IAAI,CAAC,2CAA2C,EAAE,SAAS,CAAC,CAAC;gBACrE,YAAY,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;gBACvD,sCAAsC;gBACtC,OAAO,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC;aACtE;YAAC,OAAO,GAAQ,EAAE;gBACjB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAClB,OAAO,CAAC,IAAI,CACV,+DAA+D,GAAG,EAAE,CACrE,CAAC;aACH;SACF;QAED,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;QAEpC,IAAI,CAAC,YAAY,EAAE;YACjB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;SAC5B;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/tokens.js CHANGED
@@ -3,6 +3,6 @@ import SW_URL from './service-worker?text';
3
3
  /**
4
4
  * The token for the ServiceWorker.
5
5
  */
6
- export const IServiceWorkerManager = new Token('@jupyterlite/server-extension:IServiceWorkerManager');
6
+ export const IServiceWorkerManager = new Token('@jupyterlite/server:IServiceWorkerManager');
7
7
  export const WORKER_NAME = `${SW_URL}`.split('/').slice(-1)[0];
8
8
  //# sourceMappingURL=tokens.js.map
package/lib/tokens.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI1C,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,KAAK,CAC5C,qDAAqD,CACtD,CAAC;AAwCF,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI1C,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,KAAK,CAC5C,2CAA2C,CAC5C,CAAC;AAwCF,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyterlite/server",
3
- "version": "0.6.0-alpha.2",
3
+ "version": "0.6.0-alpha.3",
4
4
  "description": "JupyterLite - Server",
5
5
  "homepage": "https://github.com/jupyterlite/jupyterlite",
6
6
  "bugs": {
@@ -43,17 +43,17 @@
43
43
  "watch": "tsc -b --watch"
44
44
  },
45
45
  "dependencies": {
46
- "@jupyterlab/coreutils": "~6.4.0-beta.0",
47
- "@jupyterlab/nbformat": "~4.4.0-beta.0",
48
- "@jupyterlab/observables": "~5.4.0-beta.0",
49
- "@jupyterlab/services": "~7.4.0-beta.0",
50
- "@jupyterlab/settingregistry": "~4.4.0-beta.0",
51
- "@jupyterlab/statedb": "~4.4.0-beta.0",
52
- "@jupyterlite/contents": "^0.6.0-alpha.2",
53
- "@jupyterlite/kernel": "^0.6.0-alpha.2",
54
- "@jupyterlite/session": "^0.6.0-alpha.2",
55
- "@jupyterlite/settings": "^0.6.0-alpha.2",
56
- "@jupyterlite/translation": "^0.6.0-alpha.2",
46
+ "@jupyterlab/coreutils": "~6.4.0-beta.1",
47
+ "@jupyterlab/nbformat": "~4.4.0-beta.1",
48
+ "@jupyterlab/observables": "~5.4.0-beta.1",
49
+ "@jupyterlab/services": "~7.4.0-beta.1",
50
+ "@jupyterlab/settingregistry": "~4.4.0-beta.1",
51
+ "@jupyterlab/statedb": "~4.4.0-beta.1",
52
+ "@jupyterlite/contents": "^0.6.0-alpha.3",
53
+ "@jupyterlite/kernel": "^0.6.0-alpha.3",
54
+ "@jupyterlite/session": "^0.6.0-alpha.3",
55
+ "@jupyterlite/settings": "^0.6.0-alpha.3",
56
+ "@jupyterlite/translation": "^0.6.0-alpha.3",
57
57
  "@lumino/application": "^2.4.2",
58
58
  "@lumino/coreutils": "^2.2.0",
59
59
  "@lumino/signaling": "^2.1.3",
@@ -62,13 +62,13 @@
62
62
  "devDependencies": {
63
63
  "@babel/core": "^7.11.6",
64
64
  "@babel/preset-env": "^7.12.1",
65
- "@jupyterlab/testutils": "~4.4.0-beta.0",
65
+ "@jupyterlab/testutils": "~4.4.0-beta.1",
66
66
  "@types/jest": "^29.5.3",
67
67
  "@types/serviceworker": "^0.0.56",
68
68
  "jest": "^29.6.2",
69
69
  "rimraf": "~5.0.1",
70
70
  "ts-jest": "^29.1.1",
71
- "typescript": "~5.1.6"
71
+ "typescript": "~5.5.4"
72
72
  },
73
73
  "publishConfig": {
74
74
  "access": "public"
package/src/index.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  // Copyright (c) Jupyter Development Team.
2
2
  // Distributed under the terms of the Modified BSD License.
3
3
 
4
- export * from './app';
5
- export * from './router';
6
4
  export * from './tokens';
7
- export * from './service-manager';
5
+ export * from './service-worker-manager';
package/src/tokens.ts CHANGED
@@ -8,7 +8,7 @@ import SW_URL from './service-worker?text';
8
8
  * The token for the ServiceWorker.
9
9
  */
10
10
  export const IServiceWorkerManager = new Token<IServiceWorkerManager>(
11
- '@jupyterlite/server-extension:IServiceWorkerManager',
11
+ '@jupyterlite/server:IServiceWorkerManager',
12
12
  );
13
13
 
14
14
  /**
package/lib/app.d.ts DELETED
@@ -1,87 +0,0 @@
1
- import { ServiceManager } from '@jupyterlab/services';
2
- import { Application, IPlugin } from '@lumino/application';
3
- import { Router } from './router';
4
- export type JupyterLiteServerPlugin<T> = IPlugin<JupyterLiteServer, T>;
5
- /**
6
- * Server is the main application class. It is instantiated once and shared.
7
- */
8
- export declare class JupyterLiteServer extends Application<never> {
9
- /**
10
- * Construct a new JupyterLite object.
11
- *
12
- * @param options The instantiation options for a JupyterLiteServer application.
13
- */
14
- constructor(options: Application.IOptions<never>);
15
- /**
16
- * The name of the application.
17
- */
18
- readonly name = "JupyterLite Server";
19
- /**
20
- * A namespace/prefix plugins may use to denote their provenance.
21
- */
22
- readonly namespace = "JupyterLite Server";
23
- /**
24
- * The version of the application.
25
- */
26
- readonly version = "unknown";
27
- /**
28
- * Get the underlying `Router` instance.
29
- */
30
- get router(): Router;
31
- /**
32
- * Get the underlying lite service manager for this app.
33
- */
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>;
42
- /**
43
- * Attach the application shell to the DOM.
44
- *
45
- * @param id - The id of the host node for the shell, or `''`.
46
- *
47
- * #### Notes
48
- * For this server application there is no shell to attach
49
- */
50
- protected attachShell(id: string): void;
51
- /**
52
- * A method invoked on a window `'resize'` event.
53
- *
54
- * #### Notes
55
- * For this server application there is no shell to update
56
- */
57
- protected evtResize(event: Event): void;
58
- /**
59
- * Register plugins from a plugin module.
60
- *
61
- * @param mod - The plugin module to register.
62
- */
63
- registerPluginModule(mod: JupyterLiteServer.IPluginModule): void;
64
- /**
65
- * Register the plugins from multiple plugin modules.
66
- *
67
- * @param mods - The plugin modules to register.
68
- */
69
- registerPluginModules(mods: JupyterLiteServer.IPluginModule[]): void;
70
- private _router;
71
- private _serviceManager;
72
- }
73
- /**
74
- * A namespace for Server statics.
75
- */
76
- export declare namespace JupyterLiteServer {
77
- /**
78
- * The interface for a module that exports a plugin or plugins as
79
- * the default value.
80
- */
81
- interface IPluginModule {
82
- /**
83
- * The default export.
84
- */
85
- default: IPlugin<JupyterLiteServer, any> | IPlugin<JupyterLiteServer, any>[];
86
- }
87
- }
package/lib/app.js DELETED
@@ -1,155 +0,0 @@
1
- // Copyright (c) Jupyter Development Team.
2
- // Distributed under the terms of the Modified BSD License.
3
- import { ServerConnection, ServiceManager } from '@jupyterlab/services';
4
- import { Application } from '@lumino/application';
5
- import { Signal, Stream } from '@lumino/signaling';
6
- import { WebSocket } from 'mock-socket';
7
- import { Router } from './router';
8
- /**
9
- * A local event manager service.
10
- *
11
- * #### Notes
12
- * Schema IDs are not verified and all client-emitted events emit.
13
- */
14
- class LocalEventManager {
15
- constructor(options) {
16
- this._isDisposed = false;
17
- this._serverSettings = options.serverSettings;
18
- this._stream = new Stream(this);
19
- }
20
- async emit({ data, schema_id }) {
21
- this._stream.emit({ ...data, schema_id });
22
- }
23
- dispose() {
24
- if (this.isDisposed) {
25
- return;
26
- }
27
- this._isDisposed = true;
28
- Signal.clearData(this);
29
- this._stream.stop();
30
- }
31
- get isDisposed() {
32
- return this._isDisposed;
33
- }
34
- get stream() {
35
- return this._stream;
36
- }
37
- get serverSettings() {
38
- return this._serverSettings;
39
- }
40
- }
41
- /**
42
- * Server is the main application class. It is instantiated once and shared.
43
- */
44
- export class JupyterLiteServer extends Application {
45
- /**
46
- * Construct a new JupyterLite object.
47
- *
48
- * @param options The instantiation options for a JupyterLiteServer application.
49
- */
50
- constructor(options) {
51
- var _a;
52
- super(options);
53
- /**
54
- * The name of the application.
55
- */
56
- this.name = 'JupyterLite Server';
57
- /**
58
- * A namespace/prefix plugins may use to denote their provenance.
59
- */
60
- this.namespace = this.name;
61
- /**
62
- * The version of the application.
63
- */
64
- this.version = 'unknown';
65
- this._router = new Router();
66
- const serverSettings = {
67
- ...ServerConnection.makeSettings(),
68
- WebSocket,
69
- fetch: (_a = this.fetch.bind(this)) !== null && _a !== void 0 ? _a : undefined,
70
- };
71
- this._serviceManager = new ServiceManager({
72
- standby: 'never',
73
- serverSettings,
74
- events: new LocalEventManager({ serverSettings }),
75
- });
76
- }
77
- /**
78
- * Get the underlying `Router` instance.
79
- */
80
- get router() {
81
- return this._router;
82
- }
83
- /**
84
- * Get the underlying lite service manager for this app.
85
- */
86
- get serviceManager() {
87
- return this._serviceManager;
88
- }
89
- /**
90
- * Handle an incoming request from the client.
91
- *
92
- * @param req The incoming request
93
- * @param init The optional init request
94
- */
95
- async fetch(req, init) {
96
- if (!(req instanceof Request)) {
97
- throw Error('Request info is not a Request');
98
- }
99
- return this._router.route(req);
100
- }
101
- /**
102
- * Attach the application shell to the DOM.
103
- *
104
- * @param id - The id of the host node for the shell, or `''`.
105
- *
106
- * #### Notes
107
- * For this server application there is no shell to attach
108
- */
109
- attachShell(id) {
110
- // no-op
111
- }
112
- /**
113
- * A method invoked on a window `'resize'` event.
114
- *
115
- * #### Notes
116
- * For this server application there is no shell to update
117
- */
118
- evtResize(event) {
119
- // no-op
120
- }
121
- /**
122
- * Register plugins from a plugin module.
123
- *
124
- * @param mod - The plugin module to register.
125
- */
126
- registerPluginModule(mod) {
127
- let data = mod.default;
128
- // Handle commonjs exports.
129
- if (!Object.prototype.hasOwnProperty.call(mod, '__esModule')) {
130
- data = mod;
131
- }
132
- if (!Array.isArray(data)) {
133
- data = [data];
134
- }
135
- data.forEach((item) => {
136
- try {
137
- this.registerPlugin(item);
138
- }
139
- catch (error) {
140
- console.error(error);
141
- }
142
- });
143
- }
144
- /**
145
- * Register the plugins from multiple plugin modules.
146
- *
147
- * @param mods - The plugin modules to register.
148
- */
149
- registerPluginModules(mods) {
150
- mods.forEach((mod) => {
151
- this.registerPluginModule(mod);
152
- });
153
- }
154
- }
155
- //# sourceMappingURL=app.js.map
package/lib/app.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAS,gBAAgB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE/E,OAAO,EAAE,WAAW,EAAW,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC;;;;;GAKG;AACH,MAAM,iBAAiB;IACrB,YAAY,OAAuD;QA8B3D,gBAAW,GAAG,KAAK,CAAC;QA7B1B,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;QAC9C,IAAI,CAAC,OAAO,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,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;IAED,OAAO;QACL,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,OAAO;SACR;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,MAAM,CAAC,SAA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M,KAAK,CAAC,+BAA+B,CAAC,CAAC;SAC9C;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;OAOG;IACO,WAAW,CAAC,EAAU;QAC9B,QAAQ;IACV,CAAC;IAED;;;;;OAKG;IACO,SAAS,CAAC,KAAY;QAC9B,QAAQ;IACV,CAAC;IAED;;;;OAIG;IACH,oBAAoB,CAAC,GAAoC;QACvD,IAAI,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC;QACvB,2BAA2B;QAC3B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,EAAE;YAC5D,IAAI,GAAG,GAAU,CAAC;SACnB;QACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACxB,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;SACf;QACD,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACpB,IAAI;gBACF,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;aAC3B;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;aACtB;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,qBAAqB,CAAC,IAAuC;QAC3D,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnB,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;CAIF"}
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,QAAQ,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,OAAwB,EAAE,QAAyB;QACxD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAK,CAAC,GAAY;QACtB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;QACvB,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;QAEzB,KAAK,MAAM,CAAC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AAC,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
- }
package/src/router.ts DELETED
@@ -1,170 +0,0 @@
1
- import { ReadonlyJSONObject } from '@lumino/coreutils';
2
-
3
- /**
4
- * A simple router.
5
- */
6
- export class Router {
7
- /**
8
- * Add a new GET route
9
- *
10
- * @param pattern The pattern to match
11
- * @param callback The function to call on pattern match
12
- *
13
- */
14
- get(pattern: string | RegExp, callback: Router.Callback): void {
15
- this._add('GET', pattern, callback);
16
- }
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: string | RegExp, callback: Router.Callback): void {
26
- this._add('PUT', pattern, callback);
27
- }
28
-
29
- /**
30
- * Add a new POST route
31
- *
32
- * @param pattern The pattern to match
33
- * @param callback The function to call on pattern match
34
- *
35
- */
36
- post(pattern: string | RegExp, callback: Router.Callback): void {
37
- this._add('POST', pattern, callback);
38
- }
39
-
40
- /**
41
- * Add a new PATCH route
42
- *
43
- * @param pattern The pattern to match
44
- * @param callback The function to call on pattern match
45
- *
46
- */
47
- patch(pattern: string | RegExp, callback: Router.Callback): void {
48
- this._add('PATCH', pattern, callback);
49
- }
50
-
51
- /**
52
- * Add a new DELETE route
53
- *
54
- * @param pattern The pattern to match
55
- * @param callback The function to call on pattern match
56
- *
57
- */
58
- delete(pattern: string | RegExp, callback: Router.Callback): void {
59
- this._add('DELETE', pattern, callback);
60
- }
61
-
62
- /**
63
- * Route a request.
64
- *
65
- * @param req The request to route.
66
- */
67
- async route(req: Request): Promise<Response> {
68
- const url = new URL(req.url);
69
- const { method } = req;
70
- const { pathname } = url;
71
-
72
- for (const r of this._routes) {
73
- if (r.method !== method) {
74
- continue;
75
- }
76
- const match = pathname.match(r.pattern);
77
- if (!match) {
78
- continue;
79
- }
80
- const matches = match.slice(1);
81
- let body;
82
- if (r.method === 'PATCH' || r.method === 'PUT' || r.method === 'POST') {
83
- try {
84
- body = JSON.parse(await req.text());
85
- } catch {
86
- body = undefined;
87
- }
88
- }
89
- return r.callback.call(
90
- null,
91
- {
92
- pathname,
93
- body,
94
- query: Object.fromEntries(url.searchParams),
95
- },
96
- ...matches,
97
- );
98
- }
99
-
100
- throw new Error('Cannot route ' + req.method + ' ' + req.url);
101
- }
102
-
103
- /**
104
- * Add a new route.
105
- *
106
- * @param method The method
107
- * @param pattern The pattern
108
- * @param callback The callback
109
- */
110
- private _add(
111
- method: Router.Method,
112
- pattern: string | RegExp,
113
- callback: Router.Callback,
114
- ): void {
115
- if (typeof pattern === 'string') {
116
- pattern = new RegExp(pattern);
117
- }
118
- this._routes.push({
119
- method,
120
- pattern,
121
- callback,
122
- });
123
- }
124
-
125
- private _routes: Router.IRoute[] = [];
126
- }
127
-
128
- /**
129
- * A namespace for Router statics.
130
- */
131
- export namespace Router {
132
- /**
133
- * The Callback type.
134
- */
135
- export type Callback = (req: IRequest, ...args: string[]) => Promise<Response>;
136
-
137
- /**
138
- * The Method type.
139
- */
140
- export type Method = 'GET' | 'PUT' | 'POST' | 'PATCH' | 'DELETE';
141
-
142
- /**
143
- * The interface for a parsed request
144
- */
145
- export interface IRequest {
146
- /**
147
- * The path for the url.
148
- */
149
- pathname: string;
150
-
151
- /**
152
- * The optional query parameters.
153
- */
154
- query?: ReadonlyJSONObject;
155
-
156
- /**
157
- * The optional body parameters.
158
- */
159
- body?: ReadonlyJSONObject;
160
- }
161
-
162
- /**
163
- * An interface for a route.
164
- */
165
- export interface IRoute {
166
- method: Method;
167
- pattern: string | RegExp;
168
- callback: Callback;
169
- }
170
- }
package/src/status.ts 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(): any {
9
- return {};
10
- }
11
- }
12
-
13
- /**
14
- * A namespace for Status statics.
15
- */
16
- export namespace Status {
17
- /**
18
- * The url for the status service.
19
- */
20
- export const STATUS_SERVICE_URL = '/api/status';
21
- }