mirror of
https://github.com/nlepage/go-wasm-http-server.git
synced 2025-03-11 01:29:11 +00:00
15 lines
393 B
JavaScript
15 lines
393 B
JavaScript
![]() |
window.wasmhttp = {
|
||
|
register: async (wasm, { scope, base = '' } = {}) => {
|
||
|
const options = {}
|
||
|
if (scope) options.scope = scope
|
||
|
//FIXME register once
|
||
|
const registration = await navigator.serviceWorker.register('sw.js', options)
|
||
|
await navigator.serviceWorker.ready
|
||
|
registration.active.postMessage({
|
||
|
type: 'wasmhttp.register',
|
||
|
wasm,
|
||
|
base,
|
||
|
})
|
||
|
}
|
||
|
}
|