Skip to content
This repository was archived by the owner on Feb 14, 2024. It is now read-only.

Commit 72a8d11

Browse files
committed
Make the service worker optional
1 parent d6f0f45 commit 72a8d11

File tree

5 files changed

+786
-1239
lines changed

5 files changed

+786
-1239
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The [xeus-python](https://github.com/jupyter-xeus/xeus-python) Python kernel for
1313

1414
## Requirements
1515

16-
- JupyterLite >= 0.1.0b12
16+
- JupyterLite >= 0.1.0b16
1717

1818
## Install
1919

docs/environment.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ dependencies:
77
- mamba
88
- pydata-sphinx-theme
99
- pip
10-
1110
- pip:
12-
- jupyterlite
13-
- jupyterlite-sphinx
14-
- jupyterlite-xeus-python>=0.5.0
11+
- jupyterlite>=0.1.0b16
12+
- jupyterlite-sphinx
13+
- jupyterlite-xeus-python>=0.5.0

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
"watch:labextension": "jupyter labextension watch ."
5656
},
5757
"dependencies": {
58-
"@jupyterlite/contents": "^0.1.0-beta.12",
59-
"@jupyterlite/server": "^0.1.0-beta.12",
58+
"@jupyterlite/contents": "^0.1.0-beta.16",
59+
"@jupyterlite/server": "^0.1.0-beta.16",
6060
"comlink": "^4.3.1"
6161
},
6262
"devDependencies": {

src/index.ts

+16-6
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
// Distributed under the terms of the Modified BSD License.
44

55
import {
6-
IServiceWorkerRegistrationWrapper,
6+
IServiceWorkerManager,
77
JupyterLiteServer,
8-
JupyterLiteServerPlugin
8+
JupyterLiteServerPlugin,
99
} from '@jupyterlite/server';
10-
10+
import { IBroadcastChannelWrapper } from '@jupyterlite/contents';
1111
import { IKernel, IKernelSpecs } from '@jupyterlite/kernel';
1212

1313
import { WebWorkerKernel } from './web_worker_kernel';
@@ -18,11 +18,13 @@ import logo64 from '!!file-loader?context=.!../style/logos/python-logo-64x64.png
1818
const server_kernel: JupyterLiteServerPlugin<void> = {
1919
id: '@jupyterlite/xeus-python-kernel-extension:kernel',
2020
autoStart: true,
21-
requires: [IKernelSpecs, IServiceWorkerRegistrationWrapper],
21+
requires: [IKernelSpecs],
22+
optional: [IServiceWorkerManager, IBroadcastChannelWrapper],
2223
activate: (
2324
app: JupyterLiteServer,
2425
kernelspecs: IKernelSpecs,
25-
serviceWorkerRegistrationWrapper: IServiceWorkerRegistrationWrapper
26+
serviceWorker?: IServiceWorkerManager,
27+
broadcastChannel?: IBroadcastChannelWrapper
2628
) => {
2729
kernelspecs.register({
2830
spec: {
@@ -36,9 +38,17 @@ const server_kernel: JupyterLiteServerPlugin<void> = {
3638
}
3739
},
3840
create: async (options: IKernel.IOptions): Promise<IKernel> => {
41+
const mountDrive = !!(serviceWorker?.enabled && broadcastChannel?.enabled);
42+
43+
if (mountDrive) {
44+
console.info('Pyolite contents will be synced with Jupyter Contents');
45+
} else {
46+
console.warn('Pyolite contents will NOT be synced with Jupyter Contents');
47+
}
48+
3949
return new WebWorkerKernel({
4050
...options,
41-
mountDrive: serviceWorkerRegistrationWrapper.enabled
51+
mountDrive
4252
});
4353
}
4454
});

0 commit comments

Comments
 (0)