wasm: add Emscripten module accessor to qtloader.js

After enabling -s MODULARIZE=1 there is no longer a
global MODULE object. Add module() accessor which can
be used to retrieve the Emscripten module.

This does not really fit with the current state tracking
since the app transitions from “loading” to “running” before
the module object is ready. We’ll have to revisit this
at some point.

Change-Id: Ib7191cf4ce436e1de99f84b63ed4c10936fa62b1
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This commit is contained in:
Morten Johan Sørvig 2021-08-18 13:35:36 +02:00
parent e1fe816d46
commit c6362cd55c

View File

@ -126,6 +126,11 @@
// Signals to the application that a canvas has been resized. // Signals to the application that a canvas has been resized.
// setFontDpi // setFontDpi
// Sets the logical font dpi for the application. // Sets the logical font dpi for the application.
// module
// Returns the Emscripten module object, or undefined if the module
// has not been created yet. Note that the module object becomes available
// at the very end of the loading sequence, _after_ the transition from
// Loading to Running occurs.
function QtLoader(config) function QtLoader(config)
@ -249,6 +254,7 @@ function QtLoader(config)
publicAPI.resizeCanvasElement = resizeCanvasElement; publicAPI.resizeCanvasElement = resizeCanvasElement;
publicAPI.setFontDpi = setFontDpi; publicAPI.setFontDpi = setFontDpi;
publicAPI.fontDpi = fontDpi; publicAPI.fontDpi = fontDpi;
publicAPI.module = module;
self.restartCount = 0; self.restartCount = 0;
@ -586,6 +592,10 @@ function QtLoader(config)
return self.qtFontDpi; return self.qtFontDpi;
} }
function module() {
return self.module;
}
setStatus("Created"); setStatus("Created");
return publicAPI; return publicAPI;