UNPKG

react-native-webview-comlink

Version:

Add JavaScript interface for react-native-webview, based on Comlink

27 lines (26 loc) 1.09 kB
import { Channel, WireValue, RemoteFunction, RequestMessage, ReleaseMessage } from './message'; import { Logger } from './logger'; export interface Endpoint { postMessage(msg: string): void; } export declare class MessageHub implements Channel { private endpoint; private logger; private tag; private localFunctionByID; private localFunctionIDByFunction; private resolveByRequestID; private remoteFunctionRefByID; private remoteFunctionRegistry; constructor(name: string, endpoint: Endpoint, logger: Logger); private sendMessage; notifyRelease(msg: ReleaseMessage): void; requestResponse(msg: RequestMessage): Promise<WireValue>; registerLocalFunction(id: number, vid: number, localFunction: Function): void; tryGetLocalFuntionID(localFunction: Function): number; registerRemoteFunction(id: number, remoteFunction: RemoteFunction): void; unregisterRemoteFunction(id: number): void; tryGetRemoteFunction(id: number): RemoteFunction; canHandleMessage(msg: string): boolean; handleMessage(msg: string): void; }