kopia lustrzana https://github.com/micropython/micropython
webassembly/api: Fix waiting for Emscripten module to be loaded.
In modularize mode, the `_createMicroPythonModule()` constructor must be await'ed on, before `Module` is ready to use. Signed-off-by: Damien George <damien@micropython.org>pull/14318/head
rodzic
49ce7a6075
commit
45848f77ca
|
@ -38,7 +38,7 @@ export async function loadMicroPython(options) {
|
||||||
{ heapsize: 1024 * 1024, linebuffer: true },
|
{ heapsize: 1024 * 1024, linebuffer: true },
|
||||||
options,
|
options,
|
||||||
);
|
);
|
||||||
const Module = {};
|
let Module = {};
|
||||||
Module.locateFile = (path, scriptDirectory) =>
|
Module.locateFile = (path, scriptDirectory) =>
|
||||||
url || scriptDirectory + path;
|
url || scriptDirectory + path;
|
||||||
Module._textDecoder = new TextDecoder();
|
Module._textDecoder = new TextDecoder();
|
||||||
|
@ -83,11 +83,7 @@ export async function loadMicroPython(options) {
|
||||||
Module.stderr = (c) => stderr(new Uint8Array([c]));
|
Module.stderr = (c) => stderr(new Uint8Array([c]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const moduleLoaded = new Promise((r) => {
|
Module = await _createMicroPythonModule(Module);
|
||||||
Module.postRun = r;
|
|
||||||
});
|
|
||||||
_createMicroPythonModule(Module);
|
|
||||||
await moduleLoaded;
|
|
||||||
globalThis.Module = Module;
|
globalThis.Module = Module;
|
||||||
proxy_js_init();
|
proxy_js_init();
|
||||||
const pyimport = (name) => {
|
const pyimport = (name) => {
|
||||||
|
|
Ładowanie…
Reference in New Issue