This repository has been archived by the owner on Feb 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathindex.ts
66 lines (58 loc) · 1.87 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) Thorsten Beier
// Copyright (c) JupyterLite Contributors
// Distributed under the terms of the Modified BSD License.
import {
IServiceWorkerManager,
JupyterLiteServer,
JupyterLiteServerPlugin
} from '@jupyterlite/server';
import { IBroadcastChannelWrapper } from '@jupyterlite/contents';
import { IKernel, IKernelSpecs } from '@jupyterlite/kernel';
import { WebWorkerKernel } from './web_worker_kernel';
import logo32 from '!!file-loader?context=.!../style/logos/python-logo-32x32.png';
import logo64 from '!!file-loader?context=.!../style/logos/python-logo-64x64.png';
const server_kernel: JupyterLiteServerPlugin<void> = {
id: '@jupyterlite/xeus-python-kernel-extension:kernel',
autoStart: true,
requires: [IKernelSpecs],
optional: [IServiceWorkerManager, IBroadcastChannelWrapper],
activate: (
app: JupyterLiteServer,
kernelspecs: IKernelSpecs,
serviceWorker?: IServiceWorkerManager,
broadcastChannel?: IBroadcastChannelWrapper
) => {
kernelspecs.register({
spec: {
name: 'xeus-python',
display_name: 'Python (XPython)',
language: 'python',
argv: [],
resources: {
'logo-32x32': logo32,
'logo-64x64': logo64
}
},
create: async (options: IKernel.IOptions): Promise<IKernel> => {
const mountDrive = !!(
serviceWorker?.enabled && broadcastChannel?.enabled
);
if (mountDrive) {
console.info(
'xeus-python contents will be synced with Jupyter Contents'
);
} else {
console.warn(
'xeus-python contents will NOT be synced with Jupyter Contents'
);
}
return new WebWorkerKernel({
...options,
mountDrive
});
}
});
}
};
const plugins: JupyterLiteServerPlugin<any>[] = [server_kernel];
export default plugins;