@jupyterlite/server 0.1.0-beta.1 → 0.1.0-beta.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/app.js CHANGED
@@ -30,6 +30,7 @@ export class JupyterLiteServer extends Application {
30
30
  this.version = 'unknown';
31
31
  this._router = new Router();
32
32
  this._serviceManager = new ServiceManager({
33
+ standby: 'never',
33
34
  serverSettings: {
34
35
  ...ServerConnection.makeSettings(),
35
36
  WebSocket,
package/lib/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from './app';
2
2
  export * from './router';
3
+ export * from './tokens';
4
+ export * from './serviceworker';
package/lib/index.js CHANGED
@@ -2,3 +2,5 @@
2
2
  // Distributed under the terms of the Modified BSD License.
3
3
  export * from './app';
4
4
  export * from './router';
5
+ export * from './tokens';
6
+ export * from './serviceworker';
@@ -0,0 +1,17 @@
1
+ import { ISignal } from '@lumino/signaling';
2
+ import { IServiceWorkerRegistrationWrapper } from './tokens';
3
+ export declare class ServiceWorkerRegistrationWrapper implements IServiceWorkerRegistrationWrapper {
4
+ constructor();
5
+ /**
6
+ * A signal emitted when the registration changes.
7
+ */
8
+ get registrationChanged(): ISignal<IServiceWorkerRegistrationWrapper, ServiceWorkerRegistration | null>;
9
+ /**
10
+ * Whether the ServiceWorker is enabled or not.
11
+ */
12
+ get enabled(): boolean;
13
+ private initialize;
14
+ private setRegistration;
15
+ private _registration;
16
+ private _registrationChanged;
17
+ }
@@ -0,0 +1,45 @@
1
+ import { Signal } from '@lumino/signaling';
2
+ import { PageConfig, URLExt } from '@jupyterlab/coreutils';
3
+ export class ServiceWorkerRegistrationWrapper {
4
+ constructor() {
5
+ this._registration = null;
6
+ this._registrationChanged = new Signal(this);
7
+ this.initialize();
8
+ }
9
+ /**
10
+ * A signal emitted when the registration changes.
11
+ */
12
+ get registrationChanged() {
13
+ return this._registrationChanged;
14
+ }
15
+ /**
16
+ * Whether the ServiceWorker is enabled or not.
17
+ */
18
+ get enabled() {
19
+ return this._registration !== null;
20
+ }
21
+ async initialize() {
22
+ if (!('serviceWorker' in navigator)) {
23
+ console.error('ServiceWorker registration failed: Service Workers not supported in this browser');
24
+ this.setRegistration(null);
25
+ }
26
+ if (navigator.serviceWorker.controller) {
27
+ const registration = await navigator.serviceWorker.getRegistration(navigator.serviceWorker.controller.scriptURL);
28
+ if (registration) {
29
+ this.setRegistration(registration);
30
+ }
31
+ }
32
+ return await navigator.serviceWorker
33
+ .register(URLExt.join(PageConfig.getBaseUrl(), 'services.js'))
34
+ .then((registration) => {
35
+ this.setRegistration(registration);
36
+ }, (err) => {
37
+ console.error(`ServiceWorker registration failed: ${err}`);
38
+ this.setRegistration(null);
39
+ });
40
+ }
41
+ setRegistration(registration) {
42
+ this._registration = registration;
43
+ this._registrationChanged.emit(this._registration);
44
+ }
45
+ }
@@ -0,0 +1,19 @@
1
+ import { Token } from '@lumino/coreutils';
2
+ import { ISignal } from '@lumino/signaling';
3
+ /**
4
+ * The token for the ServiceWorker.
5
+ */
6
+ export declare const IServiceWorkerRegistrationWrapper: Token<IServiceWorkerRegistrationWrapper>;
7
+ /**
8
+ * The interface for the ServiceWorkerRegistration.
9
+ */
10
+ export interface IServiceWorkerRegistrationWrapper {
11
+ /**
12
+ * Signal fired when the registration changed.
13
+ */
14
+ readonly registrationChanged: ISignal<IServiceWorkerRegistrationWrapper, ServiceWorkerRegistration | null>;
15
+ /**
16
+ * Whether the ServiceWorker is enabled or not.
17
+ */
18
+ readonly enabled: boolean;
19
+ }
package/lib/tokens.js ADDED
@@ -0,0 +1,5 @@
1
+ import { Token } from '@lumino/coreutils';
2
+ /**
3
+ * The token for the ServiceWorker.
4
+ */
5
+ export const IServiceWorkerRegistrationWrapper = new Token('@jupyterlite/server-extension:IServiceWorkerRegistrationWrapper');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyterlite/server",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.0-beta.10",
4
4
  "description": "JupyterLite - Server",
5
5
  "homepage": "https://github.com/jupyterlite/jupyterlite",
6
6
  "bugs": {
@@ -42,17 +42,17 @@
42
42
  "watch": "tsc -b --watch"
43
43
  },
44
44
  "dependencies": {
45
- "@jupyterlab/coreutils": "~5.3.0",
46
- "@jupyterlab/nbformat": "~3.3.0",
47
- "@jupyterlab/observables": "~4.3.0",
48
- "@jupyterlab/services": "~6.3.0",
49
- "@jupyterlab/settingregistry": "~3.3.0",
50
- "@jupyterlab/statedb": "~3.3.0",
51
- "@jupyterlite/contents": "^0.1.0-beta.1",
52
- "@jupyterlite/kernel": "^0.1.0-beta.1",
53
- "@jupyterlite/session": "^0.1.0-beta.1",
54
- "@jupyterlite/settings": "^0.1.0-beta.1",
55
- "@jupyterlite/translation": "^0.1.0-beta.1",
45
+ "@jupyterlab/coreutils": "~5.4.3",
46
+ "@jupyterlab/nbformat": "~3.4.3",
47
+ "@jupyterlab/observables": "~4.4.3",
48
+ "@jupyterlab/services": "~6.4.3",
49
+ "@jupyterlab/settingregistry": "~3.4.3",
50
+ "@jupyterlab/statedb": "~3.4.3",
51
+ "@jupyterlite/contents": "^0.1.0-beta.10",
52
+ "@jupyterlite/kernel": "^0.1.0-beta.10",
53
+ "@jupyterlite/session": "^0.1.0-beta.10",
54
+ "@jupyterlite/settings": "^0.1.0-beta.10",
55
+ "@jupyterlite/translation": "^0.1.0-beta.10",
56
56
  "@lumino/application": "^1.28.1",
57
57
  "@lumino/coreutils": "^1.12.0",
58
58
  "mock-socket": "^9.1.0"
@@ -60,7 +60,7 @@
60
60
  "devDependencies": {
61
61
  "@babel/core": "^7.11.6",
62
62
  "@babel/preset-env": "^7.12.1",
63
- "@jupyterlab/testutils": "~3.3.0",
63
+ "@jupyterlab/testutils": "~3.4.3",
64
64
  "@types/jest": "^26.0.10",
65
65
  "jest": "^26.4.2",
66
66
  "rimraf": "~3.0.0",