cleanups and bugfixes related to the new plugin loader (ref. #15)

merge-requests/3/head
Michał 'rysiek' Woźniak 2021-09-19 10:04:19 +00:00
rodzic 672be5d223
commit 4d3558e1b5
2 zmienionych plików z 11 dodań i 11 usunięć

Wyświetl plik

@ -33,7 +33,9 @@ describe("service-worker", () => {
require('../' + url);
} catch(e) {}
})
// TODO: pretty ugly, but necessary for some reason...
global.LibResilientPluginConstructors = new Map()
self.LibResilientPluginConstructors = global.LibResilientPluginConstructors
})
test("basic set-up: LibResilientPlugins", async () => {

Wyświetl plik

@ -64,10 +64,6 @@ if (typeof self.LibResilientConfig !== 'object' || self.LibResilientConfig === n
name: 'fetch'
},{
name: 'cache'
},{
name: 'alt-fetch'
},{
name: 'gun-ipfs'
}
],
// which components should be logged?
@ -79,9 +75,7 @@ if (typeof self.LibResilientConfig !== 'object' || self.LibResilientConfig === n
loggedComponents: [
'service-worker',
'fetch',
'cache',
'alt-fetch',
'gun-ipfs'
'cache'
]
}
}
@ -107,15 +101,19 @@ self.log = function(component, ...items) {
// everything in a try-catch block
// so that we get an informative message if there's an error
try {
// get the config
self.importScripts("./config.js")
self.log('service-worker', 'config loaded.')
try {
self.importScripts("./config.js")
self.log('service-worker', 'config loaded.')
} catch (e) {
self.log('service-worker', 'config loading failed, using defaults')
}
// create the LibResilientPluginConstructors map
// the global... hack is here so that we can run tests; not the most elegant
// TODO: find a better way
var LibResilientPluginConstructors = global.LibResilientPluginConstructors || new Map()
var LibResilientPluginConstructors = self.LibResilientPluginConstructors || new Map()
// this is the stash for plugins that need dependencies instantiated first
var dependentPlugins = new Array()