+22
| export interface ExtensionPoint { | ||
| [extPoint: string]: (...args) => unknown; | ||
| } | ||
| export interface Plugin { | ||
| name: string; | ||
| initialize?: () => void; | ||
| /** | ||
| * ExtensionPoint can be nested, e.g. 'menu.processMenuItems' | ||
| * When index signature is provided, every key have to match the type, the type for 'name' and 'initialize' is added as index signature. | ||
| */ | ||
| [key: string]: string | (() => void) | ExtensionPoint | ((...args) => unknown); | ||
| } | ||
| export function register(plugin: Plugin): void; | ||
| export function unregister(name: string): void; | ||
| export function getPlugin(name: string): Plugin; | ||
| export function getPlugins(extPoint: string): Plugin[]; | ||
| export function processRawPlugins(callback: (plugins: Plugin[]) => void): void; | ||
| export function invoke(extPoint: string, ...args): unknown; | ||
| export function sort(arr: unknown[], sortProp: string): void; |
+4
-2
| { | ||
| "name": "js-plugin", | ||
| "version": "1.0.7", | ||
| "version": "1.0.8", | ||
| "repository": "rekit/js-plugin", | ||
| "main": "plugin.js", | ||
| "types": "plugin.d.ts", | ||
| "publishConfig": { | ||
@@ -13,3 +14,4 @@ "registry": "https://registry.npmjs.org" | ||
| "files": [ | ||
| "plugin.js" | ||
| "plugin.js", | ||
| "plugin.d.ts" | ||
| ], | ||
@@ -16,0 +18,0 @@ "devDependencies": { |
+2
-2
@@ -10,3 +10,3 @@ # Overview | ||
| Note that every plugin in the system maybe not bundled separatly but just a logical plugin. Below I give two cases to show the advantages of plugin based architecture. | ||
| Every plugin in the system maybe not bundled separatly but just a logical plugin. Below two cases show the advantages of plugin based architecture. | ||
@@ -359,2 +359,2 @@ ## Example 1: Menu | ||
| # License | ||
| MIT | ||
| MIT |
17680
5.24%4
33.33%142
15.45%359
0.28%