@pyscript/core 0.7.10 → 0.7.12
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/dist/{codemirror-7vXPINKi.js → codemirror-WbVPJuAs.js} +2 -2
- package/dist/codemirror-WbVPJuAs.js.map +1 -0
- package/dist/{codemirror_commands-CN4gxvZk.js → codemirror_commands-BRu2f-2p.js} +2 -2
- package/dist/codemirror_commands-BRu2f-2p.js.map +1 -0
- package/dist/codemirror_lang-python-q-wuh0nL.js +2 -0
- package/dist/codemirror_lang-python-q-wuh0nL.js.map +1 -0
- package/dist/codemirror_language-DqPeLcFN.js +2 -0
- package/dist/codemirror_language-DqPeLcFN.js.map +1 -0
- package/dist/{codemirror_state-BIAL8JKm.js → codemirror_state-DWQh5Ruf.js} +2 -2
- package/dist/codemirror_state-DWQh5Ruf.js.map +1 -0
- package/dist/codemirror_view-CMXZSWgf.js +2 -0
- package/dist/codemirror_view-CMXZSWgf.js.map +1 -0
- package/dist/core-DmpFMpAn.js +4 -0
- package/dist/core-DmpFMpAn.js.map +1 -0
- package/dist/core.js +1 -1
- package/dist/{deprecations-manager-qW023Rjf.js → deprecations-manager-HQLYNCYn.js} +2 -2
- package/dist/{deprecations-manager-qW023Rjf.js.map → deprecations-manager-HQLYNCYn.js.map} +1 -1
- package/dist/{donkey-7fH6-q0I.js → donkey-B3F8VdSV.js} +2 -2
- package/dist/{donkey-7fH6-q0I.js.map → donkey-B3F8VdSV.js.map} +1 -1
- package/dist/{error-CO7OuWCh.js → error-DS_5_C5_.js} +2 -2
- package/dist/{error-CO7OuWCh.js.map → error-DS_5_C5_.js.map} +1 -1
- package/dist/index-DaYI1YXo.js +2 -0
- package/dist/index-DaYI1YXo.js.map +1 -0
- package/dist/{mpy-BZxQ23WL.js → mpy-Bo2uW6nt.js} +2 -2
- package/dist/{mpy-BZxQ23WL.js.map → mpy-Bo2uW6nt.js.map} +1 -1
- package/dist/{py-DI_TP8Id.js → py-BEf8j7L5.js} +2 -2
- package/dist/{py-DI_TP8Id.js.map → py-BEf8j7L5.js.map} +1 -1
- package/dist/{py-editor-BJBbMtNv.js → py-editor-C0XF2rwE.js} +2 -2
- package/dist/{py-editor-BJBbMtNv.js.map → py-editor-C0XF2rwE.js.map} +1 -1
- package/dist/{py-game-C7N5JK0D.js → py-game-eWNz96mt.js} +2 -2
- package/dist/{py-game-C7N5JK0D.js.map → py-game-eWNz96mt.js.map} +1 -1
- package/dist/{py-terminal-Cy8siD6F.js → py-terminal-VtavPj1S.js} +2 -2
- package/dist/{py-terminal-Cy8siD6F.js.map → py-terminal-VtavPj1S.js.map} +1 -1
- package/dist/xterm_addon-fit-DxKdSnof.js +14 -0
- package/dist/xterm_addon-fit-DxKdSnof.js.map +1 -0
- package/dist/xterm_addon-web-links-B6rWzrcs.js +14 -0
- package/dist/xterm_addon-web-links-B6rWzrcs.js.map +1 -0
- package/dist/zip-CgZGjqjF.js +2 -0
- package/dist/zip-CgZGjqjF.js.map +1 -0
- package/package.json +16 -15
- package/src/3rd-party/xterm_addon-fit.js +14 -2
- package/src/3rd-party/xterm_addon-web-links.js +14 -2
- package/src/core.js +13 -2
- package/src/stdlib/pyscript/__init__.py +100 -31
- package/src/stdlib/pyscript/context.py +198 -0
- package/src/stdlib/pyscript/display.py +211 -127
- package/src/stdlib/pyscript/events.py +191 -88
- package/src/stdlib/pyscript/fetch.py +156 -25
- package/src/stdlib/pyscript/ffi.py +132 -16
- package/src/stdlib/pyscript/flatted.py +78 -1
- package/src/stdlib/pyscript/fs.py +207 -50
- package/src/stdlib/pyscript/media.py +210 -50
- package/src/stdlib/pyscript/storage.py +214 -27
- package/src/stdlib/pyscript/util.py +28 -7
- package/src/stdlib/pyscript/web.py +1079 -881
- package/src/stdlib/pyscript/websocket.py +252 -45
- package/src/stdlib/pyscript/workers.py +176 -27
- package/src/stdlib/pyscript.js +13 -13
- package/src/sync.js +1 -1
- package/types/stdlib/pyscript.d.ts +1 -1
- package/dist/codemirror-7vXPINKi.js.map +0 -1
- package/dist/codemirror_commands-CN4gxvZk.js.map +0 -1
- package/dist/codemirror_lang-python-CkOVBHci.js +0 -2
- package/dist/codemirror_lang-python-CkOVBHci.js.map +0 -1
- package/dist/codemirror_language-DOkvasqm.js +0 -2
- package/dist/codemirror_language-DOkvasqm.js.map +0 -1
- package/dist/codemirror_state-BIAL8JKm.js.map +0 -1
- package/dist/codemirror_view-Bt4sLgyA.js +0 -2
- package/dist/codemirror_view-Bt4sLgyA.js.map +0 -1
- package/dist/core-5ORB_Mcj.js +0 -4
- package/dist/core-5ORB_Mcj.js.map +0 -1
- package/dist/index-jZ1aOVVJ.js +0 -2
- package/dist/index-jZ1aOVVJ.js.map +0 -1
- package/dist/xterm_addon-fit--gyF3PcZ.js +0 -2
- package/dist/xterm_addon-fit--gyF3PcZ.js.map +0 -1
- package/dist/xterm_addon-web-links-D95xh2la.js +0 -2
- package/dist/xterm_addon-web-links-D95xh2la.js.map +0 -1
- package/dist/zip-CakRHzZu.js +0 -2
- package/dist/zip-CakRHzZu.js.map +0 -1
- package/src/stdlib/pyscript/magic_js.py +0 -84
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import sys
|
|
3
|
-
|
|
4
|
-
import js as globalThis
|
|
5
|
-
from polyscript import config as _config
|
|
6
|
-
from polyscript import js_modules
|
|
7
|
-
from pyscript.util import NotSupported
|
|
8
|
-
|
|
9
|
-
RUNNING_IN_WORKER = not hasattr(globalThis, "document")
|
|
10
|
-
|
|
11
|
-
config = json.loads(globalThis.JSON.stringify(_config))
|
|
12
|
-
|
|
13
|
-
if "MicroPython" in sys.version:
|
|
14
|
-
config["type"] = "mpy"
|
|
15
|
-
else:
|
|
16
|
-
config["type"] = "py"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
# allow `from pyscript.js_modules.xxx import yyy`
|
|
20
|
-
class JSModule:
|
|
21
|
-
def __init__(self, name):
|
|
22
|
-
self.name = name
|
|
23
|
-
|
|
24
|
-
def __getattr__(self, field):
|
|
25
|
-
# avoid pyodide looking for non existent fields
|
|
26
|
-
if not field.startswith("_"):
|
|
27
|
-
return getattr(getattr(js_modules, self.name), field)
|
|
28
|
-
return None
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
# generate N modules in the system that will proxy the real value
|
|
32
|
-
for name in globalThis.Reflect.ownKeys(js_modules):
|
|
33
|
-
sys.modules[f"pyscript.js_modules.{name}"] = JSModule(name)
|
|
34
|
-
sys.modules["pyscript.js_modules"] = js_modules
|
|
35
|
-
|
|
36
|
-
if RUNNING_IN_WORKER:
|
|
37
|
-
import polyscript
|
|
38
|
-
|
|
39
|
-
PyWorker = NotSupported(
|
|
40
|
-
"pyscript.PyWorker",
|
|
41
|
-
"pyscript.PyWorker works only when running in the main thread",
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
try:
|
|
45
|
-
import js
|
|
46
|
-
|
|
47
|
-
window = polyscript.xworker.window
|
|
48
|
-
document = window.document
|
|
49
|
-
js.document = document
|
|
50
|
-
# this is the same as js_import on main and it lands modules on main
|
|
51
|
-
js_import = window.Function(
|
|
52
|
-
"return (...urls) => Promise.all(urls.map((url) => import(url)))"
|
|
53
|
-
)()
|
|
54
|
-
except:
|
|
55
|
-
message = "Unable to use `window` or `document` -> https://docs.pyscript.net/latest/faq/#sharedarraybuffer"
|
|
56
|
-
globalThis.console.warn(message)
|
|
57
|
-
window = NotSupported("pyscript.window", message)
|
|
58
|
-
document = NotSupported("pyscript.document", message)
|
|
59
|
-
js_import = None
|
|
60
|
-
|
|
61
|
-
sync = polyscript.xworker.sync
|
|
62
|
-
|
|
63
|
-
# in workers the display does not have a default ID
|
|
64
|
-
# but there is a sync utility from xworker
|
|
65
|
-
def current_target():
|
|
66
|
-
return polyscript.target
|
|
67
|
-
|
|
68
|
-
else:
|
|
69
|
-
import _pyscript
|
|
70
|
-
from _pyscript import PyWorker as _PyWorker, js_import
|
|
71
|
-
from pyscript.ffi import to_js
|
|
72
|
-
|
|
73
|
-
def PyWorker(url, **kw):
|
|
74
|
-
return _PyWorker(url, to_js(kw))
|
|
75
|
-
|
|
76
|
-
window = globalThis
|
|
77
|
-
document = globalThis.document
|
|
78
|
-
sync = NotSupported(
|
|
79
|
-
"pyscript.sync", "pyscript.sync works only when running in a worker"
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
# in MAIN the current element target exist, just use it
|
|
83
|
-
def current_target():
|
|
84
|
-
return _pyscript.target
|