Skip to content

Commit

Permalink
Revert old API handling
Browse files Browse the repository at this point in the history
  • Loading branch information
osa1 committed Oct 1, 2024
1 parent 0d62329 commit 4c0d6f0
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions pkgs/test/lib/src/runner/browser/static/run_wasm_chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,11 @@

// Instantiate the Dart module, importing from the global scope.
let dart2wasmJsRuntime = await import('./' + data.jsruntimeurl);
let compiledModule = await dart2wasmJsRuntime.compileStreaming(fetch(data.wasmurl));
let instantiatedModule = await compiledModule.instantiate()

// Check whether the JS shim has the new instantiation API.
if (dart2wasmJsRuntime.CompiledApp !== undefined) {
// New API.
let compiledModule = await dart2wasmJsRuntime.compileStreaming(fetch(data.wasmurl));
let instantiatedModule = await compiledModule.instantiate()

// Call `main`. If tasks are placed into the event loop (by scheduling tasks
// explicitly or awaiting Futures), these will automatically keep the script
// alive even after `main` returns.
await instantiatedModule.invokeMain();
} else {
// Old, deprecated API.
let modulePromise = WebAssembly.compileStreaming(fetch(data.wasmurl));
let dartInstance = await dart2wasmJsRuntime.instantiate(modulePromise, {});
await dart2wasmJsRuntime.invoke(dartInstance);
}
// Call `main`. If tasks are placed into the event loop (by scheduling tasks
// explicitly or awaiting Futures), these will automatically keep the script
// alive even after `main` returns.
await instantiatedModule.invokeMain();
})();

0 comments on commit 4c0d6f0

Please sign in to comment.