import type { Api, EventKey, EventParams, MethodKey, MethodParams, EventCallback, ApiMap, Profile, PluginRequest, PluginApi, PluginBase, IPluginService } from '@remixproject/plugin-utils'; export interface RequestParams { name: string; key: string; payload: any[]; } export interface PluginOptions { /** The time to wait for a call to be executed before going to next call in the queue */ queueTimeout?: number; } export declare class Plugin implements PluginBase { profile: Profile; activateService: Record Promise>; protected requestQueue: Array<() => Promise>; protected currentRequest: PluginRequest; /** Give access to all the plugins registered by the engine */ protected app: PluginApi; protected options: PluginOptions; onRegistration?(): void; onActivation?(): void; onDeactivation?(): void; constructor(profile: Profile); get name(): string; get methods(): Extract[]; set methods(methods: Extract[]); activate(): any | Promise; deactivate(): any | Promise; setOptions(options?: Partial): void; /** Call a method from this plugin */ protected callPluginMethod(key: string, args: any[]): any; /** Add a request to the list of current requests */ protected addRequest(request: PluginRequest, method: Profile['methods'][number], args: any[]): Promise; /** * Ask the plugin manager if current request can call a specific method * @param method The method to call * @param message An optional message to show to the user */ askUserPermission(method: MethodKey, message?: string): Promise; /** * Called by the engine when a plugin try to activate it * @param from the profile of the plugin activating this plugin * @param method method used to activate this plugin if any */ canActivate(from: Profile, method?: string): Promise; /** * Called by the engine when a plugin try to deactivate it * @param from the profile of the plugin deactivating this plugin */ canDeactivate(from: Profile): Promise; /** * Create a service under the client node * @param name The name of the service * @param service The service */ createService>(name: string, service: S): Promise>; /** * Prepare a service to be lazy loaded * @param name The name of the subservice inside this service * @param factory A function to create the service on demand */ prepareService>(name: string, factory: () => S): () => Promise>; /** Listen on an event from another plugin */ on, Key extends EventKey>(name: Name, key: Key, cb: EventCallback): void; /** Listen once an event from another plugin then remove event listener */ once, Key extends EventKey>(name: Name, key: Key, cb: EventCallback): void; /** Stop listening on an event from another plugin */ off, Key extends EventKey>(name: Name, key: Key): void; /** Call a method of another plugin */ call, Key extends MethodKey>(name: Name, key: Key, ...payload: MethodParams): Promise>; /** Emit an event */ emit>(key: Key, ...payload: EventParams): void; }