Split pyscript into multiple files (#1338)

In the future this should help us leak fewer names into the pyscript
namespace.

Rather than assigning to the pyscript module from JavaScript, we
mount a separate private JS module with the extra names needed by
PyScript. I moved a bit more interpeter intialization into
remote_interpreter.

I added a deprecation warning for `pyscript.js`: the proper way to
access `js` is `import js`.

---------

Co-authored-by: Antonio Cuni <anto.cuni@gmail.com>
This commit is contained in:
Hood Chatham
2023-04-12 05:49:47 -07:00
committed by GitHub
parent fc5089ac59
commit c886f887ae
22 changed files with 876 additions and 931 deletions

View File

@@ -1,6 +1,7 @@
import xml.dom
from xml.dom.minidom import Node # nosec
import js
import pyscript
@@ -114,6 +115,6 @@ class Document(Node):
self._el = impl.createDocument(None, "document", None)
pyscript.js.document = doc = Document()
pyscript.js.document.head = doc.createElement("head")
pyscript.js.document.body = doc.createElement("body")
js.document = doc = Document()
js.document.head = doc.createElement("head")
js.document.body = doc.createElement("body")