diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96392f58..a41de6b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,7 @@ jobs: - name: Check globals run: | - test/rename-globals.sh + [ -x test/rename-globals.sh ] && test/rename-globals.sh other-comp: runs-on: ubuntu-latest diff --git a/dist-build/emscripten.sh b/dist-build/emscripten.sh index 0125b0a7..3f5d8ded 100755 --- a/dist-build/emscripten.sh +++ b/dist-build/emscripten.sh @@ -118,20 +118,28 @@ if [ "$DIST" = yes ]; then } }; Module.useBackupModule = function() { - var Module = {}; - $(cat "${PREFIX}/lib/libsodium.asm.tmp.js" | sed 's|use asm||g') - Object.keys(_Module).forEach(function(k) { - if (k !== 'getRandomValue') { - delete _Module[k]; - } - }); - Object.keys(Module).forEach(function(k) { - _Module[k] = Module[k]; + return new Promise(function(resolve, reject) { + var Module = {}; + Module.onAbort = reject; + + Module.onRuntimeInitialized = function() { + Object.keys(_Module).forEach(function(k) { + if (k !== 'getRandomValue') { + delete _Module[k]; + } + }); + Object.keys(Module).forEach(function(k) { + _Module[k] = Module[k]; + }); + resolve(); + }; + + $(cat "${PREFIX}/lib/libsodium.asm.tmp.js" | sed 's|use asm||g') }); }; $(cat "${PREFIX}/lib/libsodium.wasm.tmp.js") }).catch(function() { - _Module.useBackupModule(); + return _Module.useBackupModule(); }); EOM diff --git a/test/default/index.html.tpl b/test/default/index.html.tpl index 4a4e2886..cb7cb006 100644 --- a/test/default/index.html.tpl +++ b/test/default/index.html.tpl @@ -1,8 +1,8 @@ -