diff --git a/packages/fs-serviceworker/README.md b/packages/fs-serviceworker/README.md index 70b7ee9..ecc335e 100644 --- a/packages/fs-serviceworker/README.md +++ b/packages/fs-serviceworker/README.md @@ -1,3 +1,6 @@ +# TODO +- explain debug url parameter + # fs-serviceworker ServiceWorker that returns files filleld in cache by `fs-provider`. You can use it as-is or extend and customize. diff --git a/packages/fs-serviceworker/fs-serviceworker.js b/packages/fs-serviceworker/fs-serviceworker.js index 9eb6ec1..9079145 100644 --- a/packages/fs-serviceworker/fs-serviceworker.js +++ b/packages/fs-serviceworker/fs-serviceworker.js @@ -4,8 +4,10 @@ import { messageProxy } from '@jscadui/postmessage' const version = 'SW7' const clientMap = {} -let prefix = new URL(location.toString()).searchParams.get('prefix') +const searchParams = new URL(location.toString()).searchParams +let prefix = searchParams.get('prefix') let initPath = prefix + 'init' +let debug = searchParams.get('debug') self.addEventListener('activate', event => { event.waitUntil(clients.claim()) @@ -27,7 +29,7 @@ self.addEventListener('install', event => { const getClientWrapper = async clientId => { let clientWrapper = clientMap[clientId] if (!clientWrapper) { - clientWrapper = clientMap[clientId] = { api: messageProxy(await clients.get(clientId), {}, { debug: 'SW::' }) } + clientWrapper = clientMap[clientId] = { api: messageProxy(await clients.get(clientId), {}, { debug }) } clientWrapper.cache = await caches.open(prefix + clientId) } return clientWrapper