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
@@ -142,12 +142,29 @@ export interface PlayerEvent {
|
||||
stats: PlayerStats,
|
||||
}
|
||||
|
||||
/** Access to the other plugins loaded alongside a plugin */
|
||||
export interface PluginRegistry {
|
||||
/**
|
||||
* Wait for another plugin to load
|
||||
*
|
||||
* @param name - Name of the plugin to wait for.
|
||||
* @param timeoutMs - Time to wait before giving up, defaults to 30 seconds.
|
||||
* @returns
|
||||
* What the plugin's entrypoint returned, or undefined with a
|
||||
* warning logged if it did not load.
|
||||
*/
|
||||
waitFor<T = unknown>(name: string, timeoutMs?: number): Promise<T | undefined>;
|
||||
/** Check if a plugin is installed, it may still be disabled */
|
||||
checkInstalled(name: string): boolean;
|
||||
}
|
||||
|
||||
export type PluginLoadContext<
|
||||
Context extends object,
|
||||
Info extends PluginDeclaration = PluginNodeEnvInfo
|
||||
> = Context & {
|
||||
logger: Logger;
|
||||
plugin: Info;
|
||||
plugins: PluginRegistry;
|
||||
};
|
||||
|
||||
/** Hooks for migrating data that Clusterio stores on behalf of plugins */
|
||||
|
||||
Reference in new issue
Block a user