import { JsApiType, MPApi, PickMPArgs, PickMpReturns } from '@hylid/types'; export declare type JsApi = keyof MPApi; export interface JsApiConfig { type?: JsApiType; /** * @deprecated 优先使用 type = "sync" 配置 */ isSync?: boolean; /** * 套壳 jsapi 调用,通信超时时间。type = "callback" 时不生效 */ timeout?: number; useMyCallToInvoke?: boolean; } export declare type Config = JsApiConfig; export interface MpWebMessageResult { _type_: 'success' | 'fail'; _data_: T; } export interface MpWebJsApiMessage { source: 'hylid'; type: 'apiCall'; api: string; serialId: string; options: any; config?: JsApiConfig; result?: MpWebMessageResult; /** * @deprecated 优先使用 config.type = "sync" 配置 */ isSync?: boolean; /** * 使用my.call来调用JSAPI */ useMyCallToInvoke?: boolean; } export interface MpWebBroadcastMessage { source: 'hylid'; type: 'broadcast'; from: string; key: string; result?: MpWebMessageResult; } export interface MpWebPageEventMessage { source: 'hylid'; type: 'pageEvent'; event: 'onShow' | 'onHide' | 'onTitleClick' | 'onOptionMenuClick' | 'onTabItemTap' | ({} & string); result?: MpWebMessageResult; } export declare type Message = MpWebJsApiMessage | MpWebBroadcastMessage | MpWebPageEventMessage; export declare type MessageHandler = (message: Message) => void; declare type Callback = (result?: T) => void; export declare type MpWebJsApiOptions = PickMPArgs | Callback>; export interface WebviewBridgeConfig { /** 允许调用 jsApi 的白名单 */ whitelist?: string[]; /** 禁止调用 jsApi 的黑名单 */ blacklist?: string[]; /** 自定义 jsApi [ 优先级比较高,可以覆盖原生的 jsApi ] */ customApi?: CustomApi; } export interface CustomApi { [key: string]: (params: { success(v: any): void; fail(v: any): void; }) => void; } export {};