10000 Amend #1880 - Bootstrap pyscript module ASAP (#1888) · shivashankarv/pyscript@96e671b · GitHub
[go: up one dir, main page]

Skip to content

Commit 96e671b

Browse files
Amend pyscript#1880 - Bootstrap pyscript module ASAP (pyscript#1888)
* bootstrap *pyscript* module ASAP as stdlib * improve the test to be sure `js.document` exists **before** our module is imported
1 parent 40e99ab commit 96e671b

File tree

4 files changed

+110
-41
lines changed

4 files changed

+110
-41
lines changed

pyscript.core/package-lock.json

Lines changed: 90 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyscript.core/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,21 @@
4848
"type-checked-collections": "^0.1.7"
4949
},
5050
"devDependencies": {
51-
"@codemirror/commands": "^6.3.0",
51+
"@codemirror/commands": "^6.3.2",
5252
"@codemirror/lang-python": "^6.1.3",
53-
"@codemirror/language": "^6.9.2",
54-
"@codemirror/state": "^6.3.1",
55-
"@codemirror/view": "^6.22.0",
56-
"@playwright/test": "^1.39.0",
53+
"@codemirror/language": "^6.9.3",
54+
"@codemirror/state": "^6.3.3",
55+
"@codemirror/view": "^6.22.1",
56+
"@playwright/test": "^1.40.1",
5757
"@rollup/plugin-commonjs": "^25.0.7",
5858
"@rollup/plugin-node-resolve": "^15.2.3",
5959
"@rollup/plugin-terser": "^0.4.4",
6060
"@webreflection/toml-j0.4": "^1.1.3",
6161
"@xterm/addon-fit": "^0.9.0-beta.1",
6262
"chokidar": "^3.5.3",
6363
"codemirror": "^6.0.1",
64-
"eslint": "^8.53.0",
65-
"rollup": "^4.4.1",
64+
"eslint": "^8.55.0",
65+
"rollup": "^4.6.1",
6666
"rollup-plugin-postcss": "^4.0.2",
6767
"rollup-plugin-string": "^3.0.0",
6868
"static-handler": "^0.4.3",

pyscript.core/src/stdlib.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ const write = (base, literal) => {
3333

3434
write(".", pyscript);
3535

36-
python.push("del _Path");
37-
python.push("del _path");
38-
python.push("del _os");
36+
// in order to fix js.document in the Worker case
37+
// we need to bootstrap pyscript module ASAP
38+
python.push("import pyscript as _pyscript");
39+
40+
python.push(
41+
...["_Path", "_path", "_os", "_pyscript"].map((ref) => `del ${ref}`),
42+
);
3943
python.push("\n");
4044

4145
export default python.join("\n");

pyscript.core/test/worker.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
import js
2+
3+
js.document.body.append("document patch ")
4+
15
import a
2-
from pyscript import display, sync
6+
from pyscript import RUNNING_IN_WORKER, display, sync
37

48
display("Hello World", target="test", append=True)
59

10+
print(RUNNING_IN_WORKER)
611
print("sleeping")
712
sync.sleep(1)
813
print("awake")
9-
10-
import js
11-
12-
js.document.body.append("document patch ")

0 commit comments

Comments
 (0)
0