///
import { WebView } from 'react-native-webview';
import Bus from './Bus';
export declare const WEBVIEW_TARGET = "@@WEBVIEW_TARGET";
export declare const constructors: Record;
export declare const ID: () => string;
export interface Instance {
postMessage: (...args: any[]) => void;
[WEBVIEW_TARGET]?: string;
[key: string]: any;
}
export interface WebviewConstructor {
new (...args: any[]): Instance;
constructLocally?: (...args: unknown[]) => Instance;
}
export interface WebviewMessage {
type: 'set' | 'exec' | 'listen' | 'event' | 'construct';
payload: {
target?: string | {
[key: string]: any;
};
key?: string;
value?: any;
method?: string;
args?: any[];
types?: string[];
type?: string;
constructor?: string | Function;
id?: string;
};
}
export interface CanvasInstance {
webview: WebView | null;
bus: Bus | null;
context2D: CanvasRenderingContext2D;
getContext: (contextType: string) => CanvasRenderingContext2D | null;
createImage: (width?: number, height?: number) => any;
postMessage: (message: WebviewMessage) => Promise;
listeners: Array<(payload: any) => void>;
addMessageListener: (listener: (payload: any) => void) => () => void;
removeMessageListener: (listener: (payload: any) => void) => void;
createImageData: (dataArray: number[], width?: number, height?: number) => any;
}
export declare const registerWebviewTarget: (instance: Instance, targetName: string) => void;
export declare const registerWebviewProperties: (instance: Instance, properties: Record) => void;
export declare const registerWebviewMethods: (instance: Instance, methods: string[]) => void;
export declare const registerWebviewConstructor: (constructor: WebviewConstructor, constructorName: string) => void;
export declare const useWebviewBinding: ({ targetName, properties, methods }: {
targetName: string;
properties?: Record | undefined;
methods?: string[] | undefined;
}) => import("react").MutableRefObject<{}>;