@jupyterlite/pyodide-kernel 0.6.0-alpha.5 → 0.6.0-alpha.6

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/kernel.d.ts CHANGED
@@ -112,6 +112,7 @@ export declare class PyodideKernel extends BaseKernel implements IKernel {
112
112
  private _worker;
113
113
  private _remoteKernel;
114
114
  private _ready;
115
+ private _inputDelegate;
115
116
  }
116
117
  /**
117
118
  * A namespace for PyodideKernel statics.
package/lib/kernel.js CHANGED
@@ -17,6 +17,7 @@ export class PyodideKernel extends BaseKernel {
17
17
  constructor(options) {
18
18
  super(options);
19
19
  this._ready = new PromiseDelegate();
20
+ this._inputDelegate = new PromiseDelegate();
20
21
  this._worker = this.initWorker(options);
21
22
  this._remoteKernel = this.initRemote(options);
22
23
  this._contentsManager = options.contentsManager;
@@ -65,6 +66,16 @@ export class PyodideKernel extends BaseKernel {
65
66
  }
66
67
  return await this._contentsProcessor.processDriveRequest(data);
67
68
  };
69
+ remote.processStdinRequest =
70
+ async (content) => {
71
+ const msg = {
72
+ type: 'input_request',
73
+ content,
74
+ };
75
+ this._processWorkerMessage(msg);
76
+ this._inputDelegate = new PromiseDelegate();
77
+ return await this._inputDelegate.promise;
78
+ };
68
79
  }
69
80
  else {
70
81
  remote = wrap(this._worker);
@@ -285,6 +296,7 @@ export class PyodideKernel extends BaseKernel {
285
296
  * @param content - The content of the reply.
286
297
  */
287
298
  async inputReply(content) {
288
- return await this._remoteKernel.inputReply(content, this.parent);
299
+ const value = 'value' in content ? content.value : undefined;
300
+ this._inputDelegate.resolve(value);
289
301
  }
290
302
  }
package/lib/tokens.d.ts CHANGED
@@ -30,6 +30,21 @@ export interface IPyodideWorkerKernel extends IWorkerKernel {
30
30
  */
31
31
  registerCallback(callback: (msg: any) => void): void;
32
32
  }
33
+ /**
34
+ * An interface for Coincident Pyodide workers that include extra SharedArrayBuffer
35
+ * functionality.
36
+ */
37
+ export interface ICoincidentPyodideWorkerKernel extends IPyodideWorkerKernel {
38
+ /**
39
+ * Process stdin request, blocking until the reply is received.
40
+ * This is sync for the web worker, async for the UI thread.
41
+ * @param inputRequest
42
+ */
43
+ processStdinRequest(content: {
44
+ prompt: string;
45
+ password: boolean;
46
+ }): string | undefined;
47
+ }
33
48
  /**
34
49
  * Deprecated.
35
50
  */
package/lib/worker.d.ts CHANGED
@@ -2,7 +2,7 @@ import type Pyodide from 'pyodide';
2
2
  import type { DriveFS } from '@jupyterlite/contents';
3
3
  import { KernelMessage } from '@jupyterlab/services';
4
4
  import type { IPyodideWorkerKernel } from './tokens';
5
- export declare class PyodideRemoteKernel {
5
+ export declare abstract class PyodideRemoteKernel {
6
6
  constructor();
7
7
  /**
8
8
  * Accept the URLs from the host
@@ -97,14 +97,15 @@ export declare class PyodideRemoteKernel {
97
97
  */
98
98
  inputReply(content: any, parent: any): Promise<void>;
99
99
  /**
100
- * Send a input request to the front-end.
100
+ * Send a input request to the front-end and block until the reply is received.
101
101
  *
102
102
  * @param prompt the text to show at the prompt
103
103
  * @param password Is the request for a password?
104
+ * @returns String value from the input reply message, or undefined if there is none.
104
105
  */
105
- sendInputRequest(prompt: string, password: boolean): Promise<void>;
106
- getpass(prompt: string): Promise<any>;
107
- input(prompt: string): Promise<any>;
106
+ protected abstract sendInputRequest(prompt: string, password: boolean): string | undefined;
107
+ getpass(prompt: string): string | undefined;
108
+ input(prompt: string): string | undefined;
108
109
  /**
109
110
  * Send a comm message to the front-end.
110
111
  *
@@ -133,7 +134,6 @@ export declare class PyodideRemoteKernel {
133
134
  protected _interpreter: any;
134
135
  protected _stdout_stream: any;
135
136
  protected _stderr_stream: any;
136
- protected _resolveInputReply: any;
137
137
  protected _driveFS: DriveFS | null;
138
138
  protected _sendWorkerMessage: (msg: any) => void;
139
139
  }
package/lib/worker.js CHANGED
@@ -358,43 +358,16 @@ export class PyodideRemoteKernel {
358
358
  * @param content The incoming message with the reply
359
359
  */
360
360
  async inputReply(content, parent) {
361
- await this.setup(parent);
362
- this._resolveInputReply(content);
361
+ // Should never be called as input_reply messages are returned via service worker
362
+ // or SharedArrayBuffer.
363
363
  }
364
- /**
365
- * Send a input request to the front-end.
366
- *
367
- * @param prompt the text to show at the prompt
368
- * @param password Is the request for a password?
369
- */
370
- async sendInputRequest(prompt, password) {
371
- const content = {
372
- prompt,
373
- password,
374
- };
375
- this._sendWorkerMessage({
376
- type: 'input_request',
377
- parentHeader: this.formatResult(this._kernel._parent_header)['header'],
378
- content,
379
- });
380
- }
381
- async getpass(prompt) {
364
+ getpass(prompt) {
382
365
  prompt = typeof prompt === 'undefined' ? '' : prompt;
383
- await this.sendInputRequest(prompt, true);
384
- const replyPromise = new Promise((resolve) => {
385
- this._resolveInputReply = resolve;
386
- });
387
- const result = await replyPromise;
388
- return result['value'];
366
+ return this.sendInputRequest(prompt, true);
389
367
  }
390
- async input(prompt) {
368
+ input(prompt) {
391
369
  prompt = typeof prompt === 'undefined' ? '' : prompt;
392
- await this.sendInputRequest(prompt, false);
393
- const replyPromise = new Promise((resolve) => {
394
- this._resolveInputReply = resolve;
395
- });
396
- const result = await replyPromise;
397
- return result['value'];
370
+ return this.sendInputRequest(prompt, false);
398
371
  }
399
372
  /**
400
373
  * Send a comm message to the front-end.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyterlite/pyodide-kernel",
3
- "version": "0.6.0-alpha.5",
3
+ "version": "0.6.0-alpha.6",
4
4
  "description": "JupyterLite - Pyodide Kernel",
5
5
  "homepage": "https://github.com/jupyterlite/pyodide-kernel",
6
6
  "bugs": {
@@ -68,8 +68,8 @@
68
68
  },
69
69
  "pyodide-kernel": {
70
70
  "packages": {
71
- "py/pyodide-kernel": "0.6.0a5",
72
- "py/piplite": "0.6.0a5",
71
+ "py/pyodide-kernel": "0.6.0a6",
72
+ "py/piplite": "0.6.0a6",
73
73
  "py/ipykernel": "6.9.2",
74
74
  "py/widgetsnbextension3/widgetsnbextension": "3.6.999",
75
75
  "py/widgetsnbextension4/widgetsnbextension": "4.0.999"
package/pypi/all.json CHANGED
@@ -5,19 +5,19 @@
5
5
  {
6
6
  "comment_text": "",
7
7
  "digests": {
8
- "md5": "459eaf3dcda3c01862712d9fd835001a",
9
- "sha256": "72c335b14858d4434942862254e657b328d1d7da6630bea9950d85893bafa27a"
8
+ "md5": "c4a1c70e9d300eaa77da2573911088c8",
9
+ "sha256": "17c7aa29892f2724ee3bea223e2565a5a492c38953db901e1b528582670bd510"
10
10
  },
11
11
  "downloads": -1,
12
12
  "filename": "ipykernel-6.9.2-py3-none-any.whl",
13
13
  "has_sig": false,
14
- "md5_digest": "459eaf3dcda3c01862712d9fd835001a",
14
+ "md5_digest": "c4a1c70e9d300eaa77da2573911088c8",
15
15
  "packagetype": "bdist_wheel",
16
16
  "python_version": "py3",
17
17
  "requires_python": ">=3.10",
18
18
  "size": 2731,
19
- "upload_time": "2025-04-15T15:09:15.435760Z",
20
- "upload_time_iso_8601": "2025-04-15T15:09:15.435760Z",
19
+ "upload_time": "2025-05-07T18:41:19.083517Z",
20
+ "upload_time_iso_8601": "2025-05-07T18:41:19.083517Z",
21
21
  "url": "./ipykernel-6.9.2-py3-none-any.whl",
22
22
  "yanked": false,
23
23
  "yanked_reason": null
@@ -27,24 +27,24 @@
27
27
  },
28
28
  "piplite": {
29
29
  "releases": {
30
- "0.6.0a5": [
30
+ "0.6.0a6": [
31
31
  {
32
32
  "comment_text": "",
33
33
  "digests": {
34
- "md5": "a6cda0b176cf541573a6ed0aba094400",
35
- "sha256": "32d584607eee32c0cbacc41435fe13255bbda99620584dc09834dd2275905ce9"
34
+ "md5": "d09f7d8ce9121e2befca9bae84cd54b1",
35
+ "sha256": "77a42f2dbc285e0609265f5255007e2d978127eeaf7b0b2898547980fb347057"
36
36
  },
37
37
  "downloads": -1,
38
- "filename": "piplite-0.6.0a5-py3-none-any.whl",
38
+ "filename": "piplite-0.6.0a6-py3-none-any.whl",
39
39
  "has_sig": false,
40
- "md5_digest": "a6cda0b176cf541573a6ed0aba094400",
40
+ "md5_digest": "d09f7d8ce9121e2befca9bae84cd54b1",
41
41
  "packagetype": "bdist_wheel",
42
42
  "python_version": "py3",
43
43
  "requires_python": "<3.12,>=3.11",
44
- "size": 7253,
45
- "upload_time": "2025-04-15T15:09:15.435760Z",
46
- "upload_time_iso_8601": "2025-04-15T15:09:15.435760Z",
47
- "url": "./piplite-0.6.0a5-py3-none-any.whl",
44
+ "size": 7254,
45
+ "upload_time": "2025-05-07T18:41:19.082517Z",
46
+ "upload_time_iso_8601": "2025-05-07T18:41:19.082517Z",
47
+ "url": "./piplite-0.6.0a6-py3-none-any.whl",
48
48
  "yanked": false,
49
49
  "yanked_reason": null
50
50
  }
@@ -53,24 +53,24 @@
53
53
  },
54
54
  "pyodide-kernel": {
55
55
  "releases": {
56
- "0.6.0a5": [
56
+ "0.6.0a6": [
57
57
  {
58
58
  "comment_text": "",
59
59
  "digests": {
60
- "md5": "ccf6951cf6a5c53eebdf8e633551ea4e",
61
- "sha256": "81e5a4eaa6e0d92b144e18b52a1c9295e89110ff7bf1d7c4853d52984b9ba8ee"
60
+ "md5": "b59091b6a2b8c754f1967c95aa015ede",
61
+ "sha256": "014b4d106f6428930c0c582bd01355133d4a1b5ac8cdb664b9ef667e999b8d90"
62
62
  },
63
63
  "downloads": -1,
64
- "filename": "pyodide_kernel-0.6.0a5-py3-none-any.whl",
64
+ "filename": "pyodide_kernel-0.6.0a6-py3-none-any.whl",
65
65
  "has_sig": false,
66
- "md5_digest": "ccf6951cf6a5c53eebdf8e633551ea4e",
66
+ "md5_digest": "b59091b6a2b8c754f1967c95aa015ede",
67
67
  "packagetype": "bdist_wheel",
68
68
  "python_version": "py3",
69
69
  "requires_python": "<3.12,>=3.11",
70
- "size": 11415,
71
- "upload_time": "2025-04-15T15:09:15.434760Z",
72
- "upload_time_iso_8601": "2025-04-15T15:09:15.434760Z",
73
- "url": "./pyodide_kernel-0.6.0a5-py3-none-any.whl",
70
+ "size": 11411,
71
+ "upload_time": "2025-05-07T18:41:19.082517Z",
72
+ "upload_time_iso_8601": "2025-05-07T18:41:19.082517Z",
73
+ "url": "./pyodide_kernel-0.6.0a6-py3-none-any.whl",
74
74
  "yanked": false,
75
75
  "yanked_reason": null
76
76
  }
@@ -83,19 +83,19 @@
83
83
  {
84
84
  "comment_text": "",
85
85
  "digests": {
86
- "md5": "2288aa58b161ae3dd5d590b364dce5ce",
87
- "sha256": "3389e73e8176ea1306788adff5d12b1559863f32851e668a9690494922633c30"
86
+ "md5": "c60448da43a2c5fea845219309483d09",
87
+ "sha256": "901e64c7ae4560bd8f77ba92ee7011be85b06eff743b7d6c1fc45718601dce9d"
88
88
  },
89
89
  "downloads": -1,
90
90
  "filename": "widgetsnbextension-3.6.999-py3-none-any.whl",
91
91
  "has_sig": false,
92
- "md5_digest": "2288aa58b161ae3dd5d590b364dce5ce",
92
+ "md5_digest": "c60448da43a2c5fea845219309483d09",
93
93
  "packagetype": "bdist_wheel",
94
94
  "python_version": "py3",
95
95
  "requires_python": "<3.12,>=3.11",
96
96
  "size": 2369,
97
- "upload_time": "2025-04-15T15:09:15.435760Z",
98
- "upload_time_iso_8601": "2025-04-15T15:09:15.435760Z",
97
+ "upload_time": "2025-05-07T18:41:19.083517Z",
98
+ "upload_time_iso_8601": "2025-05-07T18:41:19.083517Z",
99
99
  "url": "./widgetsnbextension-3.6.999-py3-none-any.whl",
100
100
  "yanked": false,
101
101
  "yanked_reason": null
@@ -105,19 +105,19 @@
105
105
  {
106
106
  "comment_text": "",
107
107
  "digests": {
108
- "md5": "ddd85a7cd15729c14b6387a0723793dc",
109
- "sha256": "a22acd9d9921b2c542bd98ce33ab8ca6317898aee8f819bef57b41b779981a40"
108
+ "md5": "ef8e80f38311771d1cd24c206ce62c59",
109
+ "sha256": "343b63612da12c37086ae06885b8202e814a5d35154dcece93083f39517e3e39"
110
110
  },
111
111
  "downloads": -1,
112
112
  "filename": "widgetsnbextension-4.0.999-py3-none-any.whl",
113
113
  "has_sig": false,
114
- "md5_digest": "ddd85a7cd15729c14b6387a0723793dc",
114
+ "md5_digest": "ef8e80f38311771d1cd24c206ce62c59",
115
115
  "packagetype": "bdist_wheel",
116
116
  "python_version": "py3",
117
117
  "requires_python": "<3.12,>=3.11",
118
118
  "size": 2370,
119
- "upload_time": "2025-04-15T15:09:15.435760Z",
120
- "upload_time_iso_8601": "2025-04-15T15:09:15.435760Z",
119
+ "upload_time": "2025-05-07T18:41:19.083517Z",
120
+ "upload_time_iso_8601": "2025-05-07T18:41:19.083517Z",
121
121
  "url": "./widgetsnbextension-4.0.999-py3-none-any.whl",
122
122
  "yanked": false,
123
123
  "yanked_reason": null
index 722cfdd..e76f09d 100644
Binary file