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);
|
require('../' + url);
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
})
|
})
|
||||||
|
// TODO: pretty ugly, but necessary for some reason...
|
||||||
global.LibResilientPluginConstructors = new Map()
|
global.LibResilientPluginConstructors = new Map()
|
||||||
|
self.LibResilientPluginConstructors = global.LibResilientPluginConstructors
|
||||||
})
|
})
|
||||||
|
|
||||||
test("basic set-up: LibResilientPlugins", async () => {
|
test("basic set-up: LibResilientPlugins", async () => {
|
||||||
|
|
|
@ -64,10 +64,6 @@ if (typeof self.LibResilientConfig !== 'object' || self.LibResilientConfig === n
|
||||||
name: 'fetch'
|
name: 'fetch'
|
||||||
},{
|
},{
|
||||||
name: 'cache'
|
name: 'cache'
|
||||||
},{
|
|
||||||
name: 'alt-fetch'
|
|
||||||
},{
|
|
||||||
name: 'gun-ipfs'
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
// which components should be logged?
|
// which components should be logged?
|
||||||
|
@ -79,9 +75,7 @@ if (typeof self.LibResilientConfig !== 'object' || self.LibResilientConfig === n
|
||||||
loggedComponents: [
|
loggedComponents: [
|
||||||
'service-worker',
|
'service-worker',
|
||||||
'fetch',
|
'fetch',
|
||||||
'cache',
|
'cache'
|
||||||
'alt-fetch',
|
|
||||||
'gun-ipfs'
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,15 +101,19 @@ self.log = function(component, ...items) {
|
||||||
// everything in a try-catch block
|
// everything in a try-catch block
|
||||||
// so that we get an informative message if there's an error
|
// so that we get an informative message if there's an error
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// get the config
|
// get the config
|
||||||
self.importScripts("./config.js")
|
try {
|
||||||
self.log('service-worker', 'config loaded.')
|
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
|
// create the LibResilientPluginConstructors map
|
||||||
// the global... hack is here so that we can run tests; not the most elegant
|
// the global... hack is here so that we can run tests; not the most elegant
|
||||||
// TODO: find a better way
|
// 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
|
// this is the stash for plugins that need dependencies instantiated first
|
||||||
var dependentPlugins = new Array()
|
var dependentPlugins = new Array()
|
||||||
|
|
Ładowanie…
Reference in New Issue