3
3
// Distributed under the terms of the Modified BSD License.
4
4
5
5
import {
6
- IServiceWorkerRegistrationWrapper ,
6
+ IServiceWorkerManager ,
7
7
JupyterLiteServer ,
8
- JupyterLiteServerPlugin
8
+ JupyterLiteServerPlugin ,
9
9
} from '@jupyterlite/server' ;
10
-
10
+ import { IBroadcastChannelWrapper } from '@jupyterlite/contents' ;
11
11
import { IKernel , IKernelSpecs } from '@jupyterlite/kernel' ;
12
12
13
13
import { WebWorkerKernel } from './web_worker_kernel' ;
@@ -18,11 +18,13 @@ import logo64 from '!!file-loader?context=.!../style/logos/python-logo-64x64.png
18
18
const server_kernel : JupyterLiteServerPlugin < void > = {
19
19
id : '@jupyterlite/xeus-python-kernel-extension:kernel' ,
20
20
autoStart : true ,
21
- requires : [ IKernelSpecs , IServiceWorkerRegistrationWrapper ] ,
21
+ requires : [ IKernelSpecs ] ,
22
+ optional : [ IServiceWorkerManager , IBroadcastChannelWrapper ] ,
22
23
activate : (
23
24
app : JupyterLiteServer ,
24
25
kernelspecs : IKernelSpecs ,
25
- serviceWorkerRegistrationWrapper : IServiceWorkerRegistrationWrapper
26
+ serviceWorker ?: IServiceWorkerManager ,
27
+ broadcastChannel ?: IBroadcastChannelWrapper
26
28
) => {
27
29
kernelspecs . register ( {
28
30
spec : {
@@ -36,9 +38,17 @@ const server_kernel: JupyterLiteServerPlugin<void> = {
36
38
}
37
39
} ,
38
40
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
+
39
49
return new WebWorkerKernel ( {
40
50
...options ,
41
- mountDrive : serviceWorkerRegistrationWrapper . enabled
51
+ mountDrive
42
52
} ) ;
43
53
}
44
54
} ) ;
0 commit comments