kopia lustrzana https://gitlab.com/rysiekpl/libresilient
service-worker: using config.js from directly under scope the service-worker is registered for
rodzic
2603596032
commit
77ee6aa127
|
@ -1,12 +1,5 @@
|
|||
/*
|
||||
* LibResilient Service Worker.
|
||||
*
|
||||
* Default strategy:
|
||||
* 1. Try to load from main website.
|
||||
* 2. If loading fails, load from LibResilient.
|
||||
* 3. If loading is too slow, load from LibResilient.
|
||||
* 4. If loaded content doesn't match authenticated versions, fall back to
|
||||
* LibResilient.
|
||||
*/
|
||||
|
||||
|
||||
|
@ -103,8 +96,14 @@ self.log = function(component, ...items) {
|
|||
try {
|
||||
|
||||
// get the config
|
||||
//
|
||||
// self.registration.scope contains the scope this service worker is registered for
|
||||
// so it makes sense to pull config from `config.js` file directly under that location
|
||||
//
|
||||
// TODO: providing config directly from browser-side control script via postMessage?
|
||||
// TODO: `updateViaCache=imports` allows at least config.js to be updated using the cache plugin?
|
||||
try {
|
||||
self.importScripts("./config.js")
|
||||
self.importScripts(self.registration.scope + "config.js")
|
||||
self.log('service-worker', 'config loaded.')
|
||||
} catch (e) {
|
||||
self.log('service-worker', 'config loading failed, using defaults')
|
||||
|
@ -686,7 +685,6 @@ self.addEventListener('activate', event => {
|
|||
});
|
||||
|
||||
self.addEventListener('fetch', event => {
|
||||
|
||||
// if event.resultingClientId is available, we need to use this
|
||||
// otherwise event.clientId is what we want
|
||||
// ref. https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/resultingClientId
|
||||
|
|
Ładowanie…
Reference in New Issue