@eolme/vma-engine
Version:
Engine for VK Mini Apps
25 lines (24 loc) • 1.34 kB
TypeScript
import { VKBridge, AnyRequestMethodName, AnyReceiveMethodName, RequestProps, RequestIdProp, ReceiveDataMap } from '@vkontakte/vk-bridge';
declare type EnhancedReceiveDataMap = {
[M in keyof ReceiveDataMap]: Omit<ReceiveDataMap[M], 'result'> & {
result: boolean;
};
};
declare type EnhancedReceiveData<M extends AnyReceiveMethodName> = EnhancedReceiveDataMap[M];
declare type EnhancedVKBridgeSend = <K extends AnyRequestMethodName>(method: K, props?: RequestProps<K> & RequestIdProp | {}) => Promise<K extends AnyReceiveMethodName ? EnhancedReceiveData<K> : never>;
declare type DeprecatedVKBridgeMethods = 'send' | 'sendPromise' | 'isIframe' | 'isEmbedded' | 'isStandalone';
export interface EnhancedVKBridge extends Omit<VKBridge, DeprecatedVKBridgeMethods> {
/**
* Sends an event to the runtime env and returns the Promise object with
* response data. In the case of Android/iOS application env is the
* application itself. In the case of the browser, the parent frame in which
* the event handlers is located.
*
* @param method The method (event) name to send.
* @param [props] Method properties.
* @returns The Promise object with response data.
*/
send: EnhancedVKBridgeSend;
}
declare const bridge: EnhancedVKBridge;
export { bridge, bridge as default };