/// <reference types="packages/refactor/modules/simulator/webClient/preload/ttTypes" />
interface ExtraAPI {
    exitMiniProgram: 'exitMiniProgram';
    filePicker: 'filePicker';
    showRichText: 'showRichText';
    operateAudio: 'operateAudio';
    emitReload: 'emitReload';
    enableAccelerometer: 'enableAccelerometer';
    operateRecorder: 'operateRecorder';
    showDebugger: 'showDebugger';
    hideDebugger: 'hideDebuggger';
    insertHTMLWebView: 'insertHTMLWebView';
    removeHTMLWebView: 'removeHTMLWebView';
    updateHTMLWebView: 'updateHTMLWebView';
    saveFileAs: 'saveFileAs';
    openSchema: 'openSchema';
    sessionExpired: 'sessionExpired';
}
export type InvokeNames = Exclude<keyof tt.API, keyof ExtraAPI> | keyof ExtraAPI;
type BackByFn<F> = F extends (args: infer P) => infer T ? P extends {
    success?: (p: infer S) => any;
    fail?: (p: infer F) => any;
} ? Promise<S | F> : T : void;
type ApiKey = keyof tt.API;
export type Back<N extends InvokeNames> = N extends ApiKey ? BackByFn<tt.API[N]> : never;
export type SyncBack<N extends InvokeNames> = Back<N> extends Promise<any> ? void : Back<N>;
type HandlerParam<H> = H extends (arg: infer P) => any ? P : any;
type BaseParam<N extends InvokeNames> = N extends ApiKey ? HandlerParam<tt.API[N]> : never;
type ParamPick<P> = Pick<P, Exclude<keyof P, 'success' | 'fail' | 'complete'>>;
export type Param<N extends InvokeNames> = BaseParam<N> extends object ? ParamPick<BaseParam<N>> : BaseParam<N>;
export interface Handler<K extends InvokeNames> {
    (param: Param<K>, callbackId: number): Back<K> | void;
}
export type TTApiMap = {
    [K in InvokeNames]: Handler<K>;
};
export {};
