From 078ff3547ebe2abfbee1fd5af9ca5ad64be480c0 Mon Sep 17 00:00:00 2001 From: Nicolas Lepage <19571875+nlepage@users.noreply.github.com> Date: Fri, 22 Jan 2021 15:25:41 +0100 Subject: [PATCH] :fire: --- index.js | 15 --------------- sw.js | 2 +- 2 files changed, 1 insertion(+), 16 deletions(-) delete mode 100644 index.js diff --git a/index.js b/index.js deleted file mode 100644 index a92d44a..0000000 --- a/index.js +++ /dev/null @@ -1,15 +0,0 @@ -window.wasmhttp = { - register: async (wasm, { scope, base = '', swUrl = 'sw.js', args = [] } = {}) => { - const options = {} - if (scope) options.scope = scope - // FIXME register once (beware of changing scope ?) - const registration = await navigator.serviceWorker.register(swUrl, options) - await navigator.serviceWorker.ready - registration.active.postMessage({ - type: 'wasmhttp.register', - wasm, - base, - args, - }) - } -} diff --git a/sw.js b/sw.js index d402116..58f6ec1 100644 --- a/sw.js +++ b/sw.js @@ -1,6 +1,6 @@ importScripts('https://cdn.jsdelivr.net/gh/golang/go@go1.15.7/misc/wasm/wasm_exec.js') -function registerWasmHTTPListener(wasm, base, args = []) { +function registerWasmHTTPListener(wasm, { base, args = [] } = {}) { let path = new URL(registration.scope).pathname if (base && base !== '') path = `${trimEnd(path, '/')}/${trimStart(base, '/')}`