@jupyterlite/pyodide-kernel-extension 0.0.2

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 ADDED
@@ -0,0 +1,3 @@
1
+ import { JupyterLiteServerPlugin } from '@jupyterlite/server';
2
+ declare const plugins: JupyterLiteServerPlugin<any>[];
3
+ export default plugins;
package/lib/index.js ADDED
@@ -0,0 +1,63 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ import { PageConfig, URLExt } from '@jupyterlab/coreutils';
4
+ import { IServiceWorkerManager, } from '@jupyterlite/server';
5
+ import { IKernelSpecs } from '@jupyterlite/kernel';
6
+ import { IBroadcastChannelWrapper } from '@jupyterlite/contents';
7
+ /**
8
+ * The default CDN fallback for Pyodide
9
+ */
10
+ const PYODIDE_CDN_URL = 'https://cdn.jsdelivr.net/pyodide/v0.22.0/full/pyodide.js';
11
+ /**
12
+ * The id for the extension, and key in the litePlugins.
13
+ */
14
+ const PLUGIN_ID = '@jupyterlite/pyodide-kernel-extension:kernel';
15
+ /**
16
+ * A plugin to register the Pyodide kernel.
17
+ */
18
+ const kernel = {
19
+ id: PLUGIN_ID,
20
+ autoStart: true,
21
+ requires: [IKernelSpecs],
22
+ optional: [IServiceWorkerManager, IBroadcastChannelWrapper],
23
+ activate: (app, kernelspecs, serviceWorker, broadcastChannel) => {
24
+ const baseUrl = PageConfig.getBaseUrl();
25
+ const config = JSON.parse(PageConfig.getOption('litePluginSettings') || '{}')[PLUGIN_ID] || {};
26
+ const url = config.pyodideUrl || PYODIDE_CDN_URL;
27
+ const pyodideUrl = URLExt.parse(url).href;
28
+ const rawPipUrls = config.pipliteUrls || [];
29
+ const pipliteUrls = rawPipUrls.map((pipUrl) => URLExt.parse(pipUrl).href);
30
+ const disablePyPIFallback = !!config.disablePyPIFallback;
31
+ kernelspecs.register({
32
+ spec: {
33
+ name: 'python',
34
+ display_name: 'Python (Pyodide)',
35
+ language: 'python',
36
+ argv: [],
37
+ resources: {
38
+ 'logo-32x32': 'TODO',
39
+ 'logo-64x64': URLExt.join(baseUrl, '/kernelspecs/python.svg'),
40
+ },
41
+ },
42
+ create: async (options) => {
43
+ const { PyodideKernel } = await import('@jupyterlite/pyodide-kernel');
44
+ const mountDrive = !!((serviceWorker === null || serviceWorker === void 0 ? void 0 : serviceWorker.enabled) && (broadcastChannel === null || broadcastChannel === void 0 ? void 0 : broadcastChannel.enabled));
45
+ if (mountDrive) {
46
+ console.info('Pyodide contents will be synced with Jupyter Contents');
47
+ }
48
+ else {
49
+ console.warn('Pyodide contents will NOT be synced with Jupyter Contents');
50
+ }
51
+ return new PyodideKernel({
52
+ ...options,
53
+ pyodideUrl,
54
+ pipliteUrls,
55
+ disablePyPIFallback,
56
+ mountDrive,
57
+ });
58
+ },
59
+ });
60
+ },
61
+ };
62
+ const plugins = [kernel];
63
+ export default plugins;
package/package.json ADDED
@@ -0,0 +1,87 @@
1
+ {
2
+ "name": "@jupyterlite/pyodide-kernel-extension",
3
+ "version": "0.0.2",
4
+ "description": "JupyterLite - Pyodide Kernel Extension",
5
+ "homepage": "https://github.com/jupyterlite/pyodide-kernel",
6
+ "bugs": {
7
+ "url": "https://github.com/jupyterlite/pyodide-kernel/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/jupyterlite/pyodide-kernel.git"
12
+ },
13
+ "license": "BSD-3-Clause",
14
+ "author": "JupyterLite Contributors",
15
+ "sideEffects": [
16
+ "style/*.css",
17
+ "style/index.js"
18
+ ],
19
+ "main": "lib/index.js",
20
+ "types": "lib/index.d.ts",
21
+ "directories": {
22
+ "lib": "lib/"
23
+ },
24
+ "files": [
25
+ "lib/*.d.ts",
26
+ "lib/*.js.map",
27
+ "lib/*.js",
28
+ "style/*.css",
29
+ "style/index.js"
30
+ ],
31
+ "scripts": {
32
+ "build": "jlpm build:lib && jlpm build:labextension:dev",
33
+ "build:prod": "jlpm build:lib && jlpm build:labextension",
34
+ "build:labextension": "jupyter labextension build .",
35
+ "build:labextension:dev": "jupyter labextension build --development True .",
36
+ "build:lib": "tsc",
37
+ "dist": "cd ../../dist && npm pack ../packages/pyodide-kernel-extension",
38
+ "clean": "jlpm clean:lib",
39
+ "clean:lib": "rimraf lib tsconfig.tsbuildinfo",
40
+ "clean:labextension": "rimraf ../../jupyterlite_pyodide_kernel/labextension",
41
+ "clean:all": "jlpm clean:lib && jlpm clean:labextension",
42
+ "docs": "typedoc src",
43
+ "watch": "run-p watch:src watch:labextension",
44
+ "watch:src": "tsc -w",
45
+ "watch:labextension": "jupyter labextension watch ."
46
+ },
47
+ "dependencies": {
48
+ "@jupyterlab/coreutils": "^5.5.2",
49
+ "@jupyterlite/contents": "^0.1.0-beta.18",
50
+ "@jupyterlite/kernel": "^0.1.0-beta.18",
51
+ "@jupyterlite/pyodide-kernel": "^0.0.2",
52
+ "@jupyterlite/server": "^0.1.0-beta.18"
53
+ },
54
+ "devDependencies": {
55
+ "@jupyterlab/builder": "^3.5.0",
56
+ "rimraf": "~3.0.0",
57
+ "typescript": "~4.9.4"
58
+ },
59
+ "publishConfig": {
60
+ "access": "public"
61
+ },
62
+ "jupyterlab": {
63
+ "extension": true,
64
+ "outputDir": "../../jupyterlite_pyodide_kernel/labextension",
65
+ "webpackConfig": "webpack.config.js",
66
+ "sharedPackages": {
67
+ "@jupyterlite/kernel": {
68
+ "bundled": false,
69
+ "singleton": true
70
+ },
71
+ "@jupyterlite/server": {
72
+ "bundled": false,
73
+ "singleton": true
74
+ },
75
+ "@jupyterlite/contents": {
76
+ "bundled": false,
77
+ "singleton": true
78
+ }
79
+ }
80
+ },
81
+ "jupyterlite": {
82
+ "liteExtension": true
83
+ },
84
+ "piplite": {
85
+ "wheelDir": "static/pypi"
86
+ }
87
+ }
package/style/base.css ADDED
@@ -0,0 +1,4 @@
1
+ /*-----------------------------------------------------------------------------
2
+ | Copyright (c) Jupyter Development Team.
3
+ | Distributed under the terms of the Modified BSD License.
4
+ |----------------------------------------------------------------------------*/
@@ -0,0 +1,6 @@
1
+ /*-----------------------------------------------------------------------------
2
+ | Copyright (c) Jupyter Development Team.
3
+ | Distributed under the terms of the Modified BSD License.
4
+ |----------------------------------------------------------------------------*/
5
+
6
+ @import url('./base.css');
package/style/index.js ADDED
@@ -0,0 +1,6 @@
1
+ /*-----------------------------------------------------------------------------
2
+ | Copyright (c) Jupyter Development Team.
3
+ | Distributed under the terms of the Modified BSD License.
4
+ |----------------------------------------------------------------------------*/
5
+
6
+ import './base.css';