@dead_fish/jsbridge
Version:
A lightweight and easy-to-use jsBridge for Android and IOS platforms.
67 lines (63 loc) • 1.97 kB
TypeScript
type ParseUrlResponse = Record<string, string | (string | boolean)[] | boolean> | string | boolean | (string | boolean)[] | undefined;
declare function parseUrl(key?: string): ParseUrlResponse;
declare const _default$1: {
parseUrl: typeof parseUrl;
};
type AnyFunction = (...args: any[]) => any;
declare function isAndroid(): boolean;
declare function isIOS(): boolean;
declare function isHarmonyOS(): boolean;
interface RegisterHandlerParameter {
eventName: string;
handler: (data: any, responseCallback: AnyFunction) => void;
}
/**
* Register a handler on the native side
* @param {String} eventName
* @param {Function} handler
*/
declare function registerHandler({ eventName, handler }: RegisterHandlerParameter): void;
interface CallHandlerParameter {
eventName: string;
handler: (data?: any) => void;
data?: any;
}
/**
* Call a handler on the native side
* @param {String} eventName
* @param {Function} handler
* @param {any} data
*/
declare function callHandler({ eventName, handler, data }: CallHandlerParameter): void;
declare const jsBridge: {
registerHandler: typeof registerHandler;
callHandler: typeof callHandler;
};
declare const _default: {
jsBridge: {
registerHandler: typeof registerHandler;
callHandler: typeof callHandler;
};
utils: {
parseUrl: (key?: string) => string | boolean | (string | boolean)[] | Record<string, string | boolean | (string | boolean)[]> | undefined;
};
isAndroid: typeof isAndroid;
isHarmonyOS: typeof isHarmonyOS;
isIOS: typeof isIOS;
};
/**
*
* const handleOhosClick = useCallback(async () => {
window.ohosCallNative.callNative(
'changeTel',
{
tel: '110',
},
(data) => {
console.log(55555555, data);
},
);
}, []);
*
*/
export { _default as default, isAndroid, isHarmonyOS, isIOS, jsBridge, _default$1 as utils };