- async loadPluginsByScope (scope: PluginClientScope, isReload = false) {
- if (this.loadingScopes[scope]) return
- if (!isReload && this.loadedScopes.includes(scope)) return
-
- this.loadingScopes[scope] = true
-
- try {
- await this.ensurePluginsAreBuilt()
-
- if (!isReload) this.loadedScopes.push(scope)
-
- const toLoad = this.scopes[ scope ]
- if (!Array.isArray(toLoad)) {
- this.loadingScopes[scope] = false
- this.pluginsLoaded[scope].next(true)
-
- return
- }
-
- const promises: Promise<any>[] = []
- for (const pluginInfo of toLoad) {
- const clientScript = pluginInfo.clientScript
-
- if (this.loadedScripts[ clientScript.script ]) continue
-
- promises.push(this.loadPlugin(pluginInfo))
-
- this.loadedScripts[ clientScript.script ] = true
- }
-
- await Promise.all(promises)
-
- this.pluginsLoaded[scope].next(true)
- this.loadingScopes[scope] = false
- } catch (err) {
- console.error('Cannot load plugins by scope %s.', scope, err)
- }
+ addPlugin (plugin: ServerConfigPlugin, isTheme = false) {
+ return this.pluginsManager.addPlugin(plugin, isTheme)