mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
committed by
GitHub
parent
f1a46be738
commit
2d50ca86a6
4
pyscript.core/package-lock.json
generated
4
pyscript.core/package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@pyscript/core",
|
"name": "@pyscript/core",
|
||||||
"version": "0.3.3",
|
"version": "0.3.4",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@pyscript/core",
|
"name": "@pyscript/core",
|
||||||
"version": "0.3.3",
|
"version": "0.3.4",
|
||||||
"license": "APACHE-2.0",
|
"license": "APACHE-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ungap/with-resolvers": "^0.1.0",
|
"@ungap/with-resolvers": "^0.1.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pyscript/core",
|
"name": "@pyscript/core",
|
||||||
"version": "0.3.3",
|
"version": "0.3.4",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "PyScript",
|
"description": "PyScript",
|
||||||
"module": "./index.js",
|
"module": "./index.js",
|
||||||
|
|||||||
@@ -98,12 +98,6 @@ const pyTerminal = async () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// at the end of the code, make the terminal interactive
|
|
||||||
const codeAfter = `
|
|
||||||
import code as _code
|
|
||||||
_code.interact()
|
|
||||||
`;
|
|
||||||
|
|
||||||
// add a hook on the main thread to setup all sync helpers
|
// add a hook on the main thread to setup all sync helpers
|
||||||
// also bootstrapping the XTerm target on main
|
// also bootstrapping the XTerm target on main
|
||||||
hooks.main.onWorker.add(function worker(_, xworker) {
|
hooks.main.onWorker.add(function worker(_, xworker) {
|
||||||
@@ -118,14 +112,12 @@ const pyTerminal = async () => {
|
|||||||
// allow a worker to drop main thread hooks ASAP
|
// allow a worker to drop main thread hooks ASAP
|
||||||
xworker.sync.pyterminal_drop_hooks = () => {
|
xworker.sync.pyterminal_drop_hooks = () => {
|
||||||
hooks.worker.onReady.delete(workerReady);
|
hooks.worker.onReady.delete(workerReady);
|
||||||
hooks.worker.codeAfterRun.delete(codeAfter);
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// setup remote thread JS/Python code for whenever the
|
// setup remote thread JS/Python code for whenever the
|
||||||
// worker is ready to become a terminal
|
// worker is ready to become a terminal
|
||||||
hooks.worker.onReady.add(workerReady);
|
hooks.worker.onReady.add(workerReady);
|
||||||
hooks.worker.codeAfterRun.add(codeAfter);
|
|
||||||
} else {
|
} else {
|
||||||
// in the main case, just bootstrap XTerm without
|
// in the main case, just bootstrap XTerm without
|
||||||
// allowing any input as that's not possible / awkward
|
// allowing any input as that's not possible / awkward
|
||||||
|
|||||||
@@ -15,13 +15,14 @@
|
|||||||
</script>
|
</script>
|
||||||
<py-script worker terminal>
|
<py-script worker terminal>
|
||||||
import sys
|
import sys
|
||||||
from pyscript import display
|
from pyscript import display, document
|
||||||
display("Hello", "PyScript Next - PyTerminal", append=False)
|
display("Hello", "PyScript Next - PyTerminal", append=False)
|
||||||
print("this should go to the terminal")
|
print("this should go to the terminal")
|
||||||
print("another line")
|
print("another line")
|
||||||
|
|
||||||
# this works as expected
|
# this works as expected
|
||||||
print("this goes to stderr", file=sys.stderr)
|
print("this goes to stderr", file=sys.stderr)
|
||||||
|
document.addEventListener('click', lambda event: print(event.type));
|
||||||
</py-script>
|
</py-script>
|
||||||
<button id="my-button" py-click="greetings">Click me</button>
|
<button id="my-button" py-click="greetings">Click me</button>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -24,21 +24,22 @@ class TestPyTerminal(PyScriptTest):
|
|||||||
with pytest.raises(PageErrors, match="You can use at most 1 terminal"):
|
with pytest.raises(PageErrors, match="You can use at most 1 terminal"):
|
||||||
self.check_js_errors()
|
self.check_js_errors()
|
||||||
|
|
||||||
@only_worker
|
# TODO: interactive shell still unclear
|
||||||
def test_py_terminal_input(self):
|
# @only_worker
|
||||||
"""
|
# def test_py_terminal_input(self):
|
||||||
Only worker py-terminal accepts an input
|
# """
|
||||||
"""
|
# Only worker py-terminal accepts an input
|
||||||
self.pyscript_run(
|
# """
|
||||||
"""
|
# self.pyscript_run(
|
||||||
<script type="py" terminal></script>
|
# """
|
||||||
""",
|
# <script type="py" terminal></script>
|
||||||
wait_for_pyscript=False,
|
# """,
|
||||||
)
|
# wait_for_pyscript=False,
|
||||||
self.page.get_by_text(">>> ", exact=True).wait_for()
|
# )
|
||||||
self.page.keyboard.type("'the answer is ' + str(6 * 7)")
|
# self.page.get_by_text(">>> ", exact=True).wait_for()
|
||||||
self.page.keyboard.press("Enter")
|
# self.page.keyboard.type("'the answer is ' + str(6 * 7)")
|
||||||
self.page.get_by_text("the answer is 42").wait_for()
|
# self.page.keyboard.press("Enter")
|
||||||
|
# self.page.get_by_text("the answer is 42").wait_for()
|
||||||
|
|
||||||
@only_worker
|
@only_worker
|
||||||
def test_py_terminal_os_write(self):
|
def test_py_terminal_os_write(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user