statigen
Version:
A static site generator that supports html, ejs, and markdown source files
26 lines (25 loc) • 934 B
TypeScript
import type { Plugin } from './interfaces';
export declare type Arguments<T> = [T] extends [(...args: infer U) => any] ? U : [T] extends [void] ? [] : [T];
export default class PluginManager {
constructor(plugins?: Plugin[]);
private plugins;
/**
* Call `event` on plugins
*/
emit<K extends keyof Plugin>(eventName: K, data: Arguments<Plugin[K]>[0]): void;
/**
* Emit an event and get the first non-undefined return value.
* Returning a value from the handler will cancel the rest of the plugin chain.
*/
getFirst<K extends keyof Plugin, R>(eventName: K, data: Arguments<Plugin[K]>[0]): R | undefined;
/**
* Add a plugin to the beginning of the list of plugins
*/
addFirst(plugin: Plugin): void;
/**
* Add a plugin to the end of the list of plugins
*/
add(plugin: Plugin): void;
has(plugin: Plugin): boolean;
remove(plugin: Plugin): void;
}