UNPKG

2.1 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}
15export declare abstract class PluginConnector extends Plugin {
16 protected loaded: boolean;
17 protected id: number;
18 protected pendingRequest: Record<number, (result: any, error: Error | string) => void>;
19 protected options: PluginConnectorOptions;
20 profile: Profile & ExternalProfile;
21 constructor(profile: Profile & ExternalProfile);
22 /**
23 * Send a message to the external plugin
24 * @param message the message passed to the plugin
25 */
26 protected abstract send(message: Partial<Message>): void;
27 /**
28 * Open connection with the plugin
29 * @param url The transformed url the plugin should connect to
30 */
31 protected abstract connect(url: string): any | Promise<any>;
32 /** Close connection with the plugin */
33 protected abstract disconnect(): any | Promise<any>;
34 activate(): Promise<any>;
35 deactivate(): Promise<any>;
36 /** Set options for an external plugin */
37 setOptions(options?: Partial<PluginConnectorOptions>): void;
38 /** Call a method from this plugin */
39 protected callPluginMethod(key: string, payload?: any[]): Promise<any>;
40 /** Perform handshake with the client if not loaded yet */
41 protected handshake(): Promise<any>;
42 /**
43 * React when a message comes from client
44 * @param message The message sent by the client
45 */
46 protected getMessage(message: Message): Promise<any>;
47}