Creates a new plugin manager.
The application context
The command manager for plugin command registration
Gets all trigger command names registered for lazy plugins.
Normalized (uppercase) trigger command names
Gets all currently loaded plugins.
Array of loaded plugin names
Gets information about a loaded plugin.
The name of the plugin
The plugin instance if loaded, undefined otherwise
Returns whether a trigger command is registered to a lazy plugin.
Command name to check (case-insensitive)
true if the trigger loads a lazy plugin
Checks if a plugin is currently loaded.
The name of the plugin to check
true if the plugin is loaded, false otherwise
Loads the lazy plugin associated with a trigger command, if registered.
Concurrent calls for the same plugin share one in-flight load promise.
Command name that triggers lazy load (case-insensitive)
true when the plugin is loaded after this call, otherwise false
Loads a plugin and calls its onLoad hook.
If the plugin is already loaded, this method will throw an error.
The plugin's onLoad method will be called with the context and command manager.
The plugin instance to load
Loads multiple plugins from a configuration array.
This method accepts an array of plugin instances or plugin factory functions. Factory functions are useful when you want to create plugin instances lazily.
Array of plugin instances or factory functions that return plugin instances
Optionaloptions: { continueOnError?: boolean }Optional configuration for loading behavior
OptionalcontinueOnError?: booleanIf true, continue loading other plugins even if one fails (default: false)
Promise that resolves to an object containing successful and failed plugin loads
// Load plugins from instances
await pluginManager.loadPluginsFromConfig([
new MyPlugin1(),
new MyPlugin2()
]);
// Load plugins from factory functions
await pluginManager.loadPluginsFromConfig([
() => new MyPlugin1(),
() => new MyPlugin2()
]);
// Continue loading even if some fail
const result = await pluginManager.loadPluginsFromConfig(
[new Plugin1(), new Plugin2()],
{ continueOnError: true }
);
log.info('Loaded:', result.loaded);
log.info('Failed:', result.failed);
Loads plugins from a folder using dynamic imports.
This method scans a folder for plugin files and dynamically imports them. It expects each plugin file to export a default export that is either:
Path to the folder containing plugin files (relative to the base URL)
Optionaloptions: { continueOnError?: boolean; pluginList?: string[] }Optional configuration for loading behavior
OptionalcontinueOnError?: booleanIf true, continue loading other plugins even if one fails (default: false)
OptionalpluginList?: string[]Optional array of specific plugin file names to load (if not provided, attempts to auto-discover)
Promise that resolves to an object containing successful and failed plugin loads
// Load all plugins from a folder (requires plugin list or manifest)
await pluginManager.loadPluginsFromFolder('./plugins', {
pluginList: ['MyPlugin1.js', 'MyPlugin2.js']
});
// Or with continue on error
const result = await pluginManager.loadPluginsFromFolder('./plugins', {
pluginList: ['Plugin1.js', 'Plugin2.js'],
continueOnError: true
});
In browser environments, you typically need to provide a list of plugin files to load, as there's no direct way to list directory contents. You can:
pluginList array with specific file namesRegisters a lazy plugin without loading it.
The plugin is loaded automatically when one of its trigger commands is requested via loadByTrigger or AcApDocManager.sendStringToExecute.
Lazy plugin descriptor (name, triggers, loader)
Unloads a plugin and calls its onUnload hook.
This method will:
onUnload hook (plugins should clean up their commands here)The name of the plugin to unload
true if the plugin was successfully unloaded, false if it wasn't loaded
Plugin manager for dynamically loading and unloading plugins.
This class manages the lifecycle of plugins, including:
onLoadhooksonUnloadhooksPlugins are responsible for cleaning up their own registered commands in the
onUnloadhook usingcommandManager.removeCmd().Example