UNPKG

2.12 kBTypeScriptView Raw
1import type { ExternalProfile, Profile, Message } from '@remixproject/plugin-utils';
2import { Plugin, PluginOptions } from './abstract';
3/** List of available gateways for decentralised storage */
4export declare const defaultGateways: {
5 'ipfs://': (url: any, name: any) => string;
6 'swarm://': (url: any, name: any) => string;
7};
8/** Transform the URL to use a gateway if decentralised storage is specified */
9export declare function transformUrl({ url, name }: Profile & ExternalProfile): any;
10export interface PluginConnectorOptions extends PluginOptions {
11 /** Usally used to reload the plugin on changes */
12 devMode?: boolean;
13 transformUrl?: (profile: Profile & ExternalProfile) => string;
14 engine?: string;
15}
16export declare abstract class PluginConnector extends Plugin {
17 protected loaded: boolean;
18 protected id: number;
19 protected pendingRequest: Record<number, (result: any, error: Error | string) => void>;
20 protected options: PluginConnectorOptions;
21 profile: Profile & ExternalProfile;
22 constructor(profile: Profile & ExternalProfile);
23 /**
24 * Send a message to the external plugin
25 * @param message the message passed to the plugin
26 */
27 protected abstract send(message: Partial<Message>): void;
28 /**
29 * Open connection with the plugin
30 * @param url The transformed url the plugin should connect to
31 */
32 protected abstract connect(url: string): any | Promise<any>;
33 /** Close connection with the plugin */
34 protected abstract disconnect(): any | Promise<any>;
35 activate(): Promise<any>;
36 deactivate(): Promise<any>;
37 /** Set options for an external plugin */
38 setOptions(options?: Partial<PluginConnectorOptions>): void;
39 /** Call a method from this plugin */
40 protected callPluginMethod(key: string, payload?: any[]): Promise<any>;
41 /** Perform handshake with the client if not loaded yet */
42 protected handshake(): Promise<any>;
43 /**
44 * React when a message comes from client
45 * @param message The message sent by the client
46 */
47 protected getMessage(message: Message): Promise<any>;
48}