kopia lustrzana https://gitlab.com/rysiekpl/libresilient
cleanups and bugfixes related to the new plugin loader (ref. #15)
rodzic
672be5d223
commit
4d3558e1b5
|
@ -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 () => {
|
||||
|
|
|
@ -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()
|
||||
|
|
Ładowanie…
Reference in New Issue