we can kill this ugly hack now

This commit is contained in:
Antonio Cuni
2023-10-05 15:38:12 +02:00
parent e2d27d2cd3
commit b60327f022
2 changed files with 6 additions and 11 deletions

View File

@@ -75,19 +75,9 @@ const registerModule = ({ XWorker: $XWorker, interpreter, io }) => {
interpreter.runPython(stdlib, { globals: interpreter.runPython("{}") });
};
// this is a super-ugly workaround for a polyscript issue: in theory I should
// define a codeBeforeRunWorker hook inside py-terminal.js, but since it's a
// lazy plugin, it is too late: https://github.com/pyscript/polyscript/issues/52
const py_terminal_codeBeforeRunner = `
from pyscript import pyterminal
pyterminal.init()
`;
const workerHooks = {
codeBeforeRunWorker: () =>
[stdlib, py_terminal_codeBeforeRunner, ...hooks.codeBeforeRunWorker]
.map(dedent)
.join("\n"),
[stdlib, ...hooks.codeBeforeRunWorker].map(dedent).join("\n"),
codeBeforeRunWorkerAsync: () =>
[stdlib, ...hooks.codeBeforeRunWorkerAsync].map(dedent).join("\n"),
codeAfterRunWorker: () =>

View File

@@ -75,3 +75,8 @@ hooks.onWorkerReady.add(function (_, xworker) {
xworker.sync.pyterminal_readline = t.readline;
xworker.sync.pyterminal_write = t.write;
});
hooks.codeBeforeRunWorker.add(`
from pyscript import pyterminal
pyterminal.init()
`);