@jupyterlite/pyodide-kernel 0.4.0-alpha.2 → 0.4.0-beta.0
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/_pypi.d.ts +2 -2
- package/lib/_pypi.js +2 -2
- package/lib/coincident.worker.d.ts +15 -0
- package/lib/coincident.worker.js +18 -0
- package/lib/{worker.js.map → coincident.worker.js.map} +4 -4
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/kernel.d.ts +9 -2
- package/lib/kernel.js +23 -7
- package/lib/tokens.d.ts +8 -3
- package/lib/worker.d.ts +2 -4
- package/lib/worker.js +399 -11
- package/package.json +6 -6
- package/pypi/all.json +32 -32
- package/pypi/ipykernel-6.9.2-py3-none-any.whl +0 -0
- package/pypi/{piplite-0.4.0a2-py3-none-any.whl → piplite-0.4.0b0-py3-none-any.whl} +0 -0
- package/pypi/{pyodide_kernel-0.4.0a2-py3-none-any.whl → pyodide_kernel-0.4.0b0-py3-none-any.whl} +0 -0
- package/pypi/widgetsnbextension-3.6.6-py3-none-any.whl +0 -0
- package/pypi/widgetsnbextension-4.0.11-py3-none-any.whl +0 -0
- package/lib/comlink.worker.d.ts +0 -1
- package/lib/comlink.worker.js +0 -9
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
export * from './_pypi';
|
|
4
|
-
export * from './
|
|
4
|
+
export * from './coincident.worker';
|
|
5
5
|
export * from './kernel';
|
|
6
6
|
export * from './tokens';
|
|
7
7
|
export * from './worker';
|
package/lib/kernel.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KernelMessage } from '@jupyterlab/services';
|
|
1
|
+
import { Contents, KernelMessage } from '@jupyterlab/services';
|
|
2
2
|
import { BaseKernel, IKernel } from '@jupyterlite/kernel';
|
|
3
3
|
import { IPyodideWorkerKernel } from './tokens';
|
|
4
4
|
/**
|
|
@@ -11,6 +11,7 @@ export declare class PyodideKernel extends BaseKernel implements IKernel {
|
|
|
11
11
|
* @param options The instantiation options for a new PyodideKernel
|
|
12
12
|
*/
|
|
13
13
|
constructor(options: PyodideKernel.IOptions);
|
|
14
|
+
private setupFilesystemAPIs;
|
|
14
15
|
/**
|
|
15
16
|
* Load the worker.
|
|
16
17
|
*
|
|
@@ -20,7 +21,7 @@ export declare class PyodideKernel extends BaseKernel implements IKernel {
|
|
|
20
21
|
* webpack to find it.
|
|
21
22
|
*/
|
|
22
23
|
protected initWorker(options: PyodideKernel.IOptions): Worker;
|
|
23
|
-
protected initRemote(options: PyodideKernel.IOptions):
|
|
24
|
+
protected initRemote(options: PyodideKernel.IOptions): IPyodideWorkerKernel;
|
|
24
25
|
protected initRemoteOptions(options: PyodideKernel.IOptions): IPyodideWorkerKernel.IOptions;
|
|
25
26
|
/**
|
|
26
27
|
* Dispose the kernel.
|
|
@@ -100,6 +101,8 @@ export declare class PyodideKernel extends BaseKernel implements IKernel {
|
|
|
100
101
|
* @param content - The content of the reply.
|
|
101
102
|
*/
|
|
102
103
|
inputReply(content: KernelMessage.IInputReplyMsg['content']): Promise<void>;
|
|
104
|
+
private _contentsManager;
|
|
105
|
+
private _contentsProcessor;
|
|
103
106
|
private _worker;
|
|
104
107
|
private _remoteKernel;
|
|
105
108
|
private _ready;
|
|
@@ -140,5 +143,9 @@ export declare namespace PyodideKernel {
|
|
|
140
143
|
lockFileURL: string;
|
|
141
144
|
packages: string[];
|
|
142
145
|
};
|
|
146
|
+
/**
|
|
147
|
+
* The Jupyterlite content manager
|
|
148
|
+
*/
|
|
149
|
+
contentsManager: Contents.IManager;
|
|
143
150
|
}
|
|
144
151
|
}
|
package/lib/kernel.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import coincident from 'coincident';
|
|
1
2
|
import { PromiseDelegate } from '@lumino/coreutils';
|
|
2
3
|
import { PageConfig } from '@jupyterlab/coreutils';
|
|
3
4
|
import { BaseKernel } from '@jupyterlite/kernel';
|
|
4
|
-
import { wrap } from 'comlink';
|
|
5
5
|
import { allJSONUrl, pipliteWheelUrl } from './_pypi';
|
|
6
|
+
import { DriveContentsProcessor, } from '@jupyterlite/contents';
|
|
6
7
|
/**
|
|
7
8
|
* A kernel that executes Python code with Pyodide.
|
|
8
9
|
*/
|
|
@@ -17,8 +18,22 @@ export class PyodideKernel extends BaseKernel {
|
|
|
17
18
|
this._ready = new PromiseDelegate();
|
|
18
19
|
this._worker = this.initWorker(options);
|
|
19
20
|
this._worker.onmessage = (e) => this._processWorkerMessage(e.data);
|
|
20
|
-
this._remoteKernel =
|
|
21
|
-
this.
|
|
21
|
+
this._remoteKernel = this.initRemote(options);
|
|
22
|
+
this._contentsManager = options.contentsManager;
|
|
23
|
+
this.setupFilesystemAPIs();
|
|
24
|
+
}
|
|
25
|
+
setupFilesystemAPIs() {
|
|
26
|
+
this._remoteKernel.processDriveRequest = async (data) => {
|
|
27
|
+
if (!DriveContentsProcessor) {
|
|
28
|
+
throw new Error('File system calls over Atomics.wait is only supported with jupyterlite>=0.4.0a3');
|
|
29
|
+
}
|
|
30
|
+
if (this._contentsProcessor === undefined) {
|
|
31
|
+
this._contentsProcessor = new DriveContentsProcessor({
|
|
32
|
+
contentsManager: this._contentsManager,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return await this._contentsProcessor.processDriveRequest(data);
|
|
36
|
+
};
|
|
22
37
|
}
|
|
23
38
|
/**
|
|
24
39
|
* Load the worker.
|
|
@@ -29,14 +44,15 @@ export class PyodideKernel extends BaseKernel {
|
|
|
29
44
|
* webpack to find it.
|
|
30
45
|
*/
|
|
31
46
|
initWorker(options) {
|
|
32
|
-
return new Worker(new URL('./
|
|
47
|
+
return new Worker(new URL('./coincident.worker.js', import.meta.url), {
|
|
33
48
|
type: 'module',
|
|
34
49
|
});
|
|
35
50
|
}
|
|
36
|
-
|
|
51
|
+
initRemote(options) {
|
|
52
|
+
const remote = coincident(this._worker);
|
|
37
53
|
const remoteOptions = this.initRemoteOptions(options);
|
|
38
|
-
|
|
39
|
-
|
|
54
|
+
remote.initialize(remoteOptions).then(this._ready.resolve.bind(this._ready));
|
|
55
|
+
return remote;
|
|
40
56
|
}
|
|
41
57
|
initRemoteOptions(options) {
|
|
42
58
|
const { pyodideUrl } = options;
|
package/lib/tokens.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Definitions for the Pyodide kernel.
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import { TDriveMethod, TDriveRequest, TDriveResponse } from '@jupyterlite/contents';
|
|
5
5
|
import { IWorkerKernel } from '@jupyterlite/kernel';
|
|
6
6
|
/**
|
|
7
7
|
* The schema for a Warehouse-like index, as used by piplite.
|
|
@@ -15,11 +15,16 @@ export interface IPyodideWorkerKernel extends IWorkerKernel {
|
|
|
15
15
|
* Handle any lazy initialization activities.
|
|
16
16
|
*/
|
|
17
17
|
initialize(options: IPyodideWorkerKernel.IOptions): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Process drive request
|
|
20
|
+
* @param data
|
|
21
|
+
*/
|
|
22
|
+
processDriveRequest<T extends TDriveMethod>(data: TDriveRequest<T>): TDriveResponse<T>;
|
|
18
23
|
}
|
|
19
24
|
/**
|
|
20
|
-
*
|
|
25
|
+
* Deprecated.
|
|
21
26
|
*/
|
|
22
|
-
export type IRemotePyodideWorkerKernel =
|
|
27
|
+
export type IRemotePyodideWorkerKernel = IPyodideWorkerKernel;
|
|
23
28
|
/**
|
|
24
29
|
* An namespace for Pyodide workers.
|
|
25
30
|
*/
|
package/lib/worker.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type Pyodide from 'pyodide';
|
|
2
2
|
import type { DriveFS } from '@jupyterlite/contents';
|
|
3
|
+
import { KernelMessage } from '@jupyterlab/services';
|
|
3
4
|
import type { IPyodideWorkerKernel } from './tokens';
|
|
4
5
|
export declare class PyodideRemoteKernel {
|
|
5
6
|
constructor();
|
|
@@ -65,10 +66,7 @@ export declare class PyodideRemoteKernel {
|
|
|
65
66
|
*
|
|
66
67
|
* @param content The incoming message with the comm target name.
|
|
67
68
|
*/
|
|
68
|
-
commInfo(content: any, parent: any): Promise<
|
|
69
|
-
comms: any;
|
|
70
|
-
status: string;
|
|
71
|
-
}>;
|
|
69
|
+
commInfo(content: any, parent: any): Promise<KernelMessage.ICommInfoReplyMsg['content']>;
|
|
72
70
|
/**
|
|
73
71
|
* Respond to the commOpen.
|
|
74
72
|
*
|