Initial commit: Plugin Host system
This commit is contained in:
59
README.md
Normal file
59
README.md
Normal file
@@ -0,0 +1,59 @@
|
||||
# Plugin Host
|
||||
|
||||
A lightweight, event-driven plugin host system for Node.js applications.
|
||||
|
||||
## Features
|
||||
|
||||
- **Dynamic Plugin Loading**: Load plugins at runtime from a local directory
|
||||
- **Plugin Registry**: Automatic fetching of available plugins from a remote directory
|
||||
- **Hook System**: Plugins can register hooks for extensibility
|
||||
- **Event System**: EventEmitter-based communication between host and plugins
|
||||
- **Hot Reload**: Support for unloading and reloading plugins
|
||||
- **Auto-Update**: Periodic registry updates from the plugin directory
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
import { PluginHost } from './src/PluginHost.js';
|
||||
|
||||
const host = new PluginHost({
|
||||
directoryUrl: 'http://your-plugin-directory/plugins',
|
||||
pluginsDir: './plugins',
|
||||
autoUpdate: true,
|
||||
updateInterval: 300000 // 5 minutes
|
||||
});
|
||||
|
||||
await host.initialize();
|
||||
await host.loadPlugins();
|
||||
```
|
||||
|
||||
## Plugin Context API
|
||||
|
||||
Plugins receive a context object with the following API:
|
||||
|
||||
- `registerHook(hookName, callback)` - Register a hook
|
||||
- `unregisterHook(hookName, callback)` - Unregister a hook
|
||||
- `runHook(hookName, ...args)` - Execute a hook
|
||||
- `getConfig(key)` - Get plugin configuration
|
||||
- `log(...args)` - Log with plugin prefix
|
||||
- `on(event, listener)` - Listen to host events
|
||||
- `emit(event, ...args)` - Emit events
|
||||
|
||||
## Events
|
||||
|
||||
- `initialized` - Host initialized
|
||||
- `registry-updated` - Plugin registry updated
|
||||
- `plugin-loaded` - Plugin loaded
|
||||
- `plugin-unloaded` - Plugin unloaded
|
||||
- `plugin-error` - Plugin error occurred
|
||||
- `shutdown` - Host shutting down
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
Reference in New Issue
Block a user