export type Arguments = [T] extends [(...args: infer U) => any] ? U : [T] extends [void] ? [] : [T]; export default class PluginInterface { constructor(plugins?: TPlugin[]); private plugins; /** * Call `event` on plugins */ emit(eventName: K, event: Arguments[0]): Promise[0]>; /** * Add a plugin to the end of the list of plugins * @param plugin the plugin * @param priority the priority for the plugin. Lower number means higher priority. (ex: 1 executes before 5) */ add(plugin: T, priority?: number): T; /** * Adds a temporary plugin with a single event hook, and resolve a promise with the event from the next occurance of that event. * Once the event fires for the first time, the plugin is unregistered. * @param eventName the name of the event to subscribe to * @param priority the priority for this event. Lower number means higher priority. (ex: 1 executes before 5) */ once(eventName: keyof TPlugin, priority?: number): Promise; /** * Adds a temporary plugin with a single event hook, and resolve a promise with the event from the next occurance of that event. * Once the event fires for the first time and the matcher evaluates to true, the plugin is unregistered. * @param eventName the name of the event to subscribe to * @param matcher a function to call that, when true, will deregister this hander and return the event * @param priority the priority for this event. Lower number means higher priority. (ex: 1 executes before 5) */ onceIf(eventName: keyof TPlugin, matcher: (TEventType: any) => boolean, priority?: number): Promise; /** * Remove the specified plugin */ remove(plugin: T): void; /** * Remove all plugins */ clear(): void; }