mirror of
https://github.com/pyscript/pyscript.git
synced 2026-02-27 11:04:05 -05:00
Worker sync utility (#1511)
* patched an issue with wasmoon randomly asking to resolve proxy references * simplified pyodide and micropython dance by grouping their common utilities together * created an integration test around a worker to main thread input between MicroPython and Lua * commented some weird bugs / funny behaviors around both MicroPython and Pyodide * other minor clean ups
This commit is contained in:
committed by
GitHub
parent
0cdbfbeb30
commit
af72e232c3
@@ -1,15 +1,17 @@
|
||||
import { clean, fetchPaths, stdio, writeFile } from "./_utils.js";
|
||||
import { fetchPaths, stdio } from "./_utils.js";
|
||||
import {
|
||||
run,
|
||||
runAsync,
|
||||
runEvent,
|
||||
runWorker,
|
||||
runWorkerAsync,
|
||||
writeFile,
|
||||
} from "./_python.js";
|
||||
|
||||
const type = "micropython";
|
||||
|
||||
// REQUIRES INTEGRATION TEST
|
||||
/* c8 ignore start */
|
||||
const worker = (method) =>
|
||||
function (runtime, code, xworker) {
|
||||
globalThis.xworker = xworker;
|
||||
return this[method](runtime, `from js import xworker;${code}`);
|
||||
};
|
||||
|
||||
export default {
|
||||
type: [type, "mpy"],
|
||||
module: () => `http://localhost:8080/micropython/micropython.mjs`,
|
||||
@@ -20,16 +22,11 @@ export default {
|
||||
if (config.fetch) await fetchPaths(this, runtime, config.fetch);
|
||||
return runtime;
|
||||
},
|
||||
run: (runtime, code) => runtime.runPython(clean(code)),
|
||||
runAsync: (runtime, code) => runtime.runPythonAsync(clean(code)),
|
||||
runEvent(runtime, code, key) {
|
||||
return this.run(
|
||||
runtime,
|
||||
`import js;event=js.__events.get(${key});${code}`,
|
||||
);
|
||||
},
|
||||
runWorker: worker("run"),
|
||||
runWorkerAsync: worker("runAsync"),
|
||||
writeFile: ({ FS }, path, buffer) => writeFile(FS, path, buffer),
|
||||
run,
|
||||
runAsync,
|
||||
runEvent,
|
||||
runWorker,
|
||||
runWorkerAsync,
|
||||
writeFile,
|
||||
};
|
||||
/* c8 ignore stop */
|
||||
|
||||
Reference in New Issue
Block a user