wasm-http-server/index.js

15 lines
408 B
JavaScript
Raw Normal View History

2019-12-02 16:52:40 +01:00
window.wasmhttp = {
2019-12-02 17:04:06 +01:00
register: async (wasm, { scope, base = '', swUrl = 'sw.js' } = {}) => {
2019-12-02 16:52:40 +01:00
const options = {}
if (scope) options.scope = scope
//FIXME register once
2019-12-02 16:58:20 +01:00
const registration = await navigator.serviceWorker.register(swUrl, options)
2019-12-02 16:52:40 +01:00
await navigator.serviceWorker.ready
registration.active.postMessage({
type: 'wasmhttp.register',
wasm,
base,
})
}
}