UNPKG

@daysnap/horn-jssdk

Version:

原生容器面向 H5 开发者提供的基于容器应用内的网页开发工具包

38 lines (37 loc) 1.1 kB
export interface FailCallbackResult { code?: number; message?: string; } export declare const HornApi: { call<T = any>(success: (res: { code: number; message?: string; data: T; }) => void, fail: (err: { code?: number; message?: string; }) => void, service: string, action: string, params: any): void; }; export type PromisifySuccessResult<P, T extends { success?: (...args: any[]) => void; }> = P extends { success: any; } ? void : P extends { fail: any; } ? void : Promise<Parameters<Exclude<T['success'], undefined>>[0]>; export type Options<T> = { success?(data: T): void; fail?(err: FailCallbackResult): void; service: string; action: string; [props: string]: any; }; export type PickOptions<T> = T & Pick<Options<any>, 'service' | 'action'>; /** * jssdk 核心 无需直接调用 */ export declare const core: <T>(options: Options<T>) => void; /** * 包装函数 */ export declare const call: <T extends Options<any>, P extends Partial<Options<any>>>(options: T) => PromisifySuccessResult<T, P>;