import { Service } from './Service'; import { SyncAPIMethod, PluginLifeCycelMethod, BreezrPlugin, Thenable, PluginConfig, AsyncAPIMethod } from './types/PluginAPI'; import { CommandOption, CommandCallback } from './types/Command'; /** * Plugin API * * It provides the method for register method or lifecycle */ export declare class PluginAPI { readonly service: Service; readonly id: string; private _config?; /** * @param id - Id of this plugin * @param service - A Breezr service instance */ constructor(id: string, service: Service); /** * config in config/config.js or in build.options.js */ readonly config: PluginConfig; /** * Get current working directory * * @returns {string} current working directory */ getCwd(): string; /** * * @param _path */ resolve(_path: string): string; /** * Check if the project has a given plugin * @param {string} id - Plugin id, can omit the (@breezr/|breezr-|@scope/breezr)-plugin- prefix */ hasPlugin(id: string): boolean; /** * Register a command in to breezr cli * * @param {string} name - name of command * @param {CommandOption} opts - options for the command * @param {CommandCallback} fn handle function for the command */ registerCommand(name: string, opts: CommandOption, fn: CommandCallback): void; /** * Register a method in api that can be use by other plugin * * @param {string} name - methods name * @param {AsyncAPIMethod} fn - callback when methods been invoked * Register API for other Plugins */ registerAPI(name: string, fn: AsyncAPIMethod): void; /** * Register a sync method in api that can be use by other plugin * * @param {string} name - methods name * @param {SyncAPIMethod} fn - callback when methods been invoked */ registerSyncAPI(name: string, fn: SyncAPIMethod): void; /** * Register life cycle * @param lifecycleName - * @param fn - */ on(lifecycleName: string, fn: PluginLifeCycelMethod): void; /** * emit life cycle * * @param lifecycleName - * @param args - */ emit(lifecycleName: string, ...args: any[]): boolean; /** * * @param {T extends string} action * @param {P} param * * @returns {Thenable} */ dispatch(action: T, param: P): Thenable; /** * * @param action * @param param1 * @param param2 */ dispatch(action: T, param1: P1, param2: P2): Thenable; dispatch(action: string, param1: P1): Thenable; dispatch(action: string): Thenable; /** * * @param {T extends string} action * @param {P} param * * @returns {Thenable} */ dispatchSync(action: T, param: P): R; /** * * @param action * @param param1 * @param param2 */ dispatchSync(action: T, param1: P1, param2: P2): R; dispatchSync(action: string, param1: P1): R; dispatchSync(action: string): R; /** * Register a other plugins * * @param {string} name * @param {CommandOption} opts * @param {funtion} fn */ registerPlugin(plugin: BreezrPlugin): void; }