wasm-http-server/index.js
Nicolas Lepage 21aa954d1c
⚗️
2019-12-02 17:04:16 +01:00

15 lines
408 B
JavaScript

window.wasmhttp = {
register: async (wasm, { scope, base = '', swUrl = 'sw.js' } = {}) => {
const options = {}
if (scope) options.scope = scope
//FIXME register once
const registration = await navigator.serviceWorker.register(swUrl, options)
await navigator.serviceWorker.ready
registration.active.postMessage({
type: 'wasmhttp.register',
wasm,
base,
})
}
}