1
1
mirror of https://github.com/Eugeny/tabby.git synced 2025-01-03 08:04:02 +03:00

web preload progress callback

This commit is contained in:
Eugene Pankov 2021-07-11 16:31:00 +02:00
parent d8a8d41614
commit 37e564130e
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4

View File

@ -69,15 +69,18 @@ const Tabby = {
Tabby.registerPluginModule(info.name, module) Tabby.registerPluginModule(info.name, module)
return module return module
}, },
loadPlugins: async (urls) => { loadPlugins: async (urls, progressCallback) => {
const infos: any[] = await Promise.all(urls.map(Tabby.resolvePluginInfo)) const infos: any[] = await Promise.all(urls.map(Tabby.resolvePluginInfo))
progressCallback?.(0, 1)
await Promise.all(infos.map(x => prefetchURL(x.url))) await Promise.all(infos.map(x => prefetchURL(x.url)))
const pluginModules = [] const pluginModules = []
for (const info of infos) { for (const info of infos) {
const module = await webRequire(info.url) const module = await webRequire(info.url)
Tabby.registerPluginModule(info.name, module) Tabby.registerPluginModule(info.name, module)
pluginModules.push(module) pluginModules.push(module)
progressCallback?.(infos.indexOf(info), infos.length)
} }
progressCallback?.(1, 1)
return pluginModules return pluginModules
}, },
bootstrap: (...args) => window['bootstrapTabby'](...args), bootstrap: (...args) => window['bootstrapTabby'](...args),