8000 Amend #1880 - Bootstrap pyscript module ASAP by WebReflection · Pull Request #1888 · pyscript/pyscript · GitHub
[go: up one dir, main page]

Skip to content

Amend #1880 - Bootstrap pyscript module ASAP #1888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 90 additions & 26 deletions pyscript.core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions pyscript.core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@
"type-checked-collections": "^0.1.7"
},
"devDependencies": {
"@codemirror/commands": "^6.3.0",
"@codemirror/commands": "^6.3.2",
"@codemirror/lang-python": "^6.1.3",
"@codemirror/language": "^6.9.2",
"@codemirror/state": "^6.3.1",
"@codemirror/view": "^6.22.0",
"@playwright/test": "^1.39.0",
"@codemirror/language": "^6.9.3",
"@codemirror/state": "^6.3.3",
"@codemirror/view": "^6.22.1",
"@playwright/test": "^1.40.1",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@webreflection/toml-j0.4": "^1.1.3",
"@xterm/addon-fit": "^0.9.0-beta.1",
"chokidar": "^3.5.3",
"codemirror": "^6.0.1",
"eslint": "^8.53.0",
"rollup": "^4.4.1",
"eslint": "^8.55.0",
"rollup": "^4.6.1",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-string": "^3.0.0",
"static-handler": "^0.4.3",
Expand Down
10 changes: 7 additions & 3 deletions pyscript.core/src/stdlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ const write = (base, literal) => {

write(".", pyscript);

python.push("del _Path");
python.push("del _path");
python.push("del _os");
// in order to fix js.document in the Worker case
// we need to bootstrap pyscript module ASAP
python.push("import pyscript as _pyscript");

python.push(
...["_Path", "_path", "_os", "_pyscript"].map((ref) => `del ${ref}`),
);
python.push("\n");

export default python.join("\n");
11 changes: 6 additions & 5 deletions pyscript.core/test/worker.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import js

js.document.body.append("document patch ")

import a
from pyscript import display, sync
from pyscript import RUNNING_IN_WORKER, display, sync

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

print(RUNNING_IN_WORKER)
print("sleeping")
4568 sync.sleep(1)
print("awake")

import js

js.document.body.append("document patch ")
0