Fixes #402 for Safari support (#409)

* Fixes #402 for Safari support

Falls back to WebAssembly.compile when compileStreaming is undefined

* Formatting tweaks for pyodide.js

* Style edit per @mdboom to pyodide.js
This commit is contained in:
Joseph D. Long 2019-05-03 10:40:57 -07:00 committed by Michael Droettboom
parent 619b4df99e
commit 74cf8f1f84
1 changed files with 9 additions and 1 deletions

View File

@ -299,7 +299,15 @@ var languagePluginLoader = new Promise((resolve, reject) => {
Module.preloadedWasm = {};
let isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
let wasm_promise = WebAssembly.compileStreaming(fetch(wasmURL));
let wasm_promise;
if (WebAssembly.compileStreaming === undefined) {
wasm_promise = fetch(wasmURL)
.then(response => response.arrayBuffer())
.then(bytes => WebAssembly.compile(bytes));
} else {
wasm_promise = WebAssembly.compileStreaming(fetch(wasmURL));
}
Module.instantiateWasm = (info, receiveInstance) => {
wasm_promise.then(module => WebAssembly.instantiate(module, info))
.then(instance => receiveInstance(instance));