web: Adapt new async WASM loading API

This commit is contained in:
WerWolv
2025-05-10 21:30:27 +02:00
parent 34722404f4
commit feb5b209ed
2 changed files with 20 additions and 5 deletions

View File

@@ -9,8 +9,9 @@ fetch("imhex.wasm.size").then(async (resp) => {
// inspired from: https://github.com/WordPress/wordpress-playground/pull/46 (but had to be modified)
function monkeyPatch(progressFun) {
const _instantiateStreaming = WebAssembly.instantiateStreaming;
WebAssembly.instantiateStreaming = (response, ...args) => {
WebAssembly.instantiateStreaming = async (responsePromise, ...args) => {
// Do not collect wasm content length here see above
let response = await responsePromise
const file = response.url.substring(
new URL(response.url).origin.length + 1
);
@@ -235,12 +236,11 @@ var Module = {
totalDependencies: 0,
monitorRunDependencies: function(left) {
},
instantiateWasm: function(imports, successCallback) {
instantiateWasm: async function(imports, successCallback) {
imports.env.glfwSetCursor = glfwSetCursorCustom
imports.env.glfwCreateStandardCursor = glfwCreateStandardCursorCustom
instantiateAsync(wasmBinary, wasmBinaryFile, imports, (result) => {
successCallback(result.instance, result.module)
});
let result = await instantiateAsync(null, findWasmBinary(), imports);
successCallback(result.instance, result.module)
},
arguments: []
};