audioview/frontend/core/static/app.js

26 lines
879 B
JavaScript

import init from "/wasm/audioview_core.js";
// https://github.com/rustwasm/wasm-bindgen/blob/master/examples/raytrace-parallel/index.js#L14
function checkBrowser() {
let msg = 'This demo requires a current version of Firefox (e.g., 79.0)';
if (typeof SharedArrayBuffer !== 'function') {
alert('this browser does not have SharedArrayBuffer support enabled' + '\n\n' + msg);
return
}
const buf = new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00,
0x05, 0x03, 0x01, 0x00, 0x01, 0x0b, 0x03, 0x01, 0x01, 0x00]);
if (!WebAssembly.validate(buf)) {
alert('this browser does not support passive wasm memory, demo does not work' + '\n\n' + msg);
return
}
}
window.addEventListener("DOMContentLoaded", () => {
checkBrowser();
// Initialize frontend/core wasm module, which loads the frontend/player module
// internally:
init();
});