import { BridgeEventsMap, BridgePostEventArgs, BridgePostAwaitEventResult, BridgePostAwaitEventWithoutArgsName, BridgePostAwaitEventWithArgsName, BridgePostEventWithArgsName, BridgePostEventWithoutArgsName, BridgeEventName, BridgePostEventName } from './events'; import { Platform } from '../../types'; interface ConOptions { /** * Is debug mode currently enabled. */ debug?: boolean; /** * Current application init params. */ initParams?: URLSearchParams; } /** * Provides special layer between parent device and current application. * It can send and receive events, return initial application parameters and * much more. */ export declare class Bridge { private ee; /** * Emits event. * @private */ private emit; /** * Emits event in unsafe mode. * @private */ private emitUnsafe; /** * Returns Promise which is returned by awaitable event. * * @param event - post awaitable event name. * @private */ private getAwaitableEventPromise; constructor(platform: Platform, props?: ConOptions); /** * Is debug mode currently enabled. This value must be set by developer * himself. In case, it is enabled, additional logs will appear in console. */ debug: boolean; /** * Current application init params. Normally, the source of this property is * list of parameters specified in application's location hash. */ initParams: URLSearchParams; /** * Returns true in case, passed event which could be sent via postEvent is * supported by current environment. * * @param event - event name. */ isPostEventSupported(event: BridgePostEventName): boolean; /** * Returns true in case, current environment is desktop. */ get isDesktop(): boolean; /** * Returns true in case, current environment is browser. */ get isWeb(): boolean; /** * Adds new event listener. */ on: (event: E, listener: import("twa-core").EventListener) => void; /** * Removes event listener. */ off: (event: E, listener: import("twa-core").EventListener) => void; /** * Current native application environment. */ platform: Platform; /** * Sends event to native application which launched Web App. In case, * low-level control required, usage of this function allowed, * but expected behavior not guaranteed. * * This function accepts only events, which are awaitable and require * arguments. As a result, it returns Promise with value which depends on * passed value. * * @param event - event name. * @param args - event arguments. * @throws {Error} Bridge could not determine current * environment and possible way to send event. */ postEvent(event: E, args: BridgePostEventArgs): Promise>; /** * Sends event to native application which launched Web App. In case, * low-level control required, usage of this function allowed, * but expected behavior not guaranteed. * * This function accepts only events, which are awaitable and do not require * arguments. As a result, it returns Promise with value which depends on * passed value. * * @param event - event name. * @throws {Error} Bridge could not determine current * environment and possible way to send event. */ postEvent(event: E): Promise>; /** * Sends event to native application which launched Web App. In case, * low-level control required, usage of this function allowed, * but expected behavior not guaranteed. * * This function accepts only events, which require arguments. * * @param event - event name. * @param args - event arguments. * @throws {Error} Bridge could not determine current * environment and possible way to send event. */ postEvent(event: E, args: BridgePostEventArgs): void; /** * Sends event to native application which launched Web App. In case, * low-level control required, usage of this function allowed, * but expected behavior not guaranteed. * * This function accepts only events, which require arguments. * * @param event - event name. * @throws {Error} Bridge could not determine current * environment and possible way to send event. */ postEvent(event: BridgePostEventWithoutArgsName): void; /** * Prepares event data before passing it to listeners. Normally, you should * not use this function directly. * * @param type - event name. * @param data - event data. * @throws {TypeError} Data has unexpected format for event. * @internal */ processEvent: (type: BridgeEventName | string, data: unknown) => void; /** * Add listener for all events. It is triggered always, when `emit` * function called. */ subscribe: (listener: import("twa-core").GlobalListener) => void; /** * Removes listener added with `subscribe`. */ unsubscribe: (listener: import("twa-core").GlobalListener) => void; } export {};