mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 00:13:13 +09:00
Load all plugin types through one short lived PluginLoader
PluginLoader.load takes the plugin type, context, export name and base class as options and is used by the controller, host, instance, ctl, web interface and migrations. Module imports go through #plugin_module so the node variant stays out of the web bundle. loadPlugin.ts and the loading half of plugin_loader.ts are merged into it. The loader lives for one load. Plugins reach it through context.plugins, with waitFor(name, timeoutMs) and checkInstalled(name), replacing the waitForPlugin methods. Waiting on a plugin that is not in the load list or failed to load settles right away, as loading can't finish while the waiting entrypoint is still running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7f688d2ed0
commit
c1ea4d470b
20 files changed
+500
-522
No files matched your search
+10
-11
@@ -118,17 +118,16 @@ async function loadPlugins(pluginList: Map<string, string>, hooks: CtlHooks) {
|
||||
lib.registerPluginPermissions(pluginInfos);
|
||||
lib.addPluginConfigFields(pluginInfos);
|
||||
|
||||
const ctlPlugins = new Set<lib.PluginNodeEnvInfo>();
|
||||
for (let pluginInfo of pluginInfos) {
|
||||
if (!pluginInfo.ctlEntrypoint) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const context = { hooks, logger, plugin: pluginInfo };
|
||||
await lib.loadPlugin(pluginInfo, "ctl", context, "CtlPlugin", BaseCtlPlugin);
|
||||
ctlPlugins.add(pluginInfo);
|
||||
}
|
||||
|
||||
const { loaded } = await lib.PluginLoader.load({
|
||||
type: "ctl",
|
||||
context: { hooks },
|
||||
logger,
|
||||
installed: pluginInfos,
|
||||
load: pluginInfos.filter(pluginInfo => pluginInfo.ctlEntrypoint),
|
||||
exportName: "CtlPlugin",
|
||||
baseClass: BaseCtlPlugin,
|
||||
});
|
||||
const ctlPlugins = new Set(loaded.keys());
|
||||
return ctlPlugins;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user