-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Youssefbaghr/feature/plugin-system
Implement plugin system and add documentation
- Loading branch information
Showing
4 changed files
with
73 additions
and
4,814 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { PluginInterface } from './types'; | ||
|
||
class PluginManager { | ||
private plugins: Map<string, PluginInterface> = new Map(); | ||
|
||
registerPlugin(plugin: PluginInterface): void { | ||
this.plugins.set(plugin.name, plugin); | ||
plugin.initialize(); | ||
} | ||
|
||
async executePlugin(name: string, context: any): Promise<any> { | ||
const plugin = this.plugins.get(name); | ||
if (!plugin) { | ||
throw new Error(`Plugin "${name}" not found`); | ||
} | ||
return await plugin.execute(context); | ||
} | ||
|
||
getPlugins(): PluginInterface[] { | ||
return Array.from(this.plugins.values()); | ||
} | ||
} | ||
|
||
export const pluginManager = new PluginManager(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface PluginInterface { | ||
name: string; | ||
version: string; | ||
initialize: () => void; | ||
execute: (context: any) => Promise<any>; | ||
} |
Oops, something went wrong.