pyodide-kernel icon indicating copy to clipboard operation
pyodide-kernel copied to clipboard

Missing pyodide attributes `js.document` and `js.window`

Open qqdaiyu55 opened this issue 3 years ago • 1 comments

Description

Current pyodide stays on version v0.20.0, which should support js.window or js.document following the pyodide doc.

However, I cannot use them in jupyterlite. image

Use pyodide REPL: image

qqdaiyu55 avatar Apr 25 '22 02:04 qqdaiyu55

Thanks @qqdaiyu55 for opening this.

In JupyterLite the Pyodide-based kernel runs in a Web Worker instead of the main thread. Which means some of the APIs and access to the DOM are not directly supported, although some projects like Comlink could help with this.

In theory it's possible to implement a custom JupyterLite kernel that would run Pyodide in the main thread and would give access to document and window, However this is likely not going to be supported by default in core JupyterLite.

jtpio avatar Apr 25 '22 07:04 jtpio