aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api
diff options
context:
space:
mode:
Diffstat (limited to 'ext/wasm/api')
-rw-r--r--ext/wasm/api/extern-post-js.c-pp.js13
-rw-r--r--ext/wasm/api/post-js-footer.js2
-rw-r--r--ext/wasm/api/post-js-header.js1
-rw-r--r--ext/wasm/api/sqlite3-api-cleanup.js3
4 files changed, 18 insertions, 1 deletions
diff --git a/ext/wasm/api/extern-post-js.c-pp.js b/ext/wasm/api/extern-post-js.c-pp.js
index 63e55051c..c54e1f082 100644
--- a/ext/wasm/api/extern-post-js.c-pp.js
+++ b/ext/wasm/api/extern-post-js.c-pp.js
@@ -12,6 +12,7 @@
const toExportForESM =
//#endif
(function(){
+ //console.warn("this is extern-post-js");
/**
In order to hide the sqlite3InitModule()'s resulting
Emscripten module from downstream clients (and simplify our
@@ -62,6 +63,17 @@ const toExportForESM =
globalThis.sqlite3InitModule = function ff(...args){
//console.warn("Using replaced sqlite3InitModule()",globalThis.location);
return originalInit(...args).then((EmscriptenModule)=>{
+ //console.warn("originalInit() then() arg =",EmscriptenModule);
+ //console.warn("initModuleState =",initModuleState);
+ if( EmscriptenModule.postRun && EmscriptenModule.postRun.length ){
+ /* Emscripten 4.0.0 changes the order in which our Module.postRun handler
+ runs. In 3.x postRun would have run by now, and our code relies
+ heavily on that order, so we'll work around that difference here.
+
+ https://github.com/emscripten-core/emscripten/issues/23420 */
+ //console.warn("Emscripten did not run postRun: running them now!");
+ EmscriptenModule.postRun.shift()(EmscriptenModule);
+ }
//#if wasmfs
if('undefined'!==typeof WorkerGlobalScope &&
EmscriptenModule['ENVIRONMENT_IS_PTHREAD']){
@@ -74,7 +86,6 @@ const toExportForESM =
return EmscriptenModule;
}
//#endif
- //console.warn("sqlite3InitModule() returning sqlite3 object.");
const s = EmscriptenModule.sqlite3;
s.scriptInfo = initModuleState;
//console.warn("sqlite3.scriptInfo =",s.scriptInfo);
diff --git a/ext/wasm/api/post-js-footer.js b/ext/wasm/api/post-js-footer.js
index 58882cbd9..d9bb1eab0 100644
--- a/ext/wasm/api/post-js-footer.js
+++ b/ext/wasm/api/post-js-footer.js
@@ -1,4 +1,6 @@
/* The current function scope was opened via post-js-header.js, which
gets prepended to this at build-time. This file closes that
scope. */
+//console.warn("This is the end of the Module.postRun handler.");
})/*postRun.push(...)*/;
+//console.warn("This is the end of the setup of the (pending) Module.postRun");
diff --git a/ext/wasm/api/post-js-header.js b/ext/wasm/api/post-js-header.js
index 7fd82a7d6..d0778b980 100644
--- a/ext/wasm/api/post-js-header.js
+++ b/ext/wasm/api/post-js-header.js
@@ -10,6 +10,7 @@
if(!Module.postRun) Module.postRun = [];
Module.postRun.push(function(Module/*the Emscripten-style module object*/){
'use strict';
+ //console.warn("This is the start of the Module.postRun handler.");
/* This function will contain at least the following:
- post-js-header.js (this file)
diff --git a/ext/wasm/api/sqlite3-api-cleanup.js b/ext/wasm/api/sqlite3-api-cleanup.js
index 65dbb4eb6..7fb29e648 100644
--- a/ext/wasm/api/sqlite3-api-cleanup.js
+++ b/ext/wasm/api/sqlite3-api-cleanup.js
@@ -14,6 +14,9 @@
intended to be appended after all other sqlite3-api-*.js files so
that it can finalize any setup and clean up any global symbols
temporarily used for setting up the API's various subsystems.
+
+ In Emscripten builds it's run in the context of a Module.postRun
+ handler.
*/
'use strict';
if('undefined' !== typeof Module){ // presumably an Emscripten build