@tma.js/bridge 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +44 -13
- package/dist/dts/applyPolyfills.d.ts +5 -0
- package/dist/dts/base64-url.d.ts +24 -0
- package/dist/dts/env/hasWebviewProxy.d.ts +10 -0
- package/dist/dts/env/isIframe.d.ts +5 -0
- package/dist/dts/env/isTMA.d.ts +31 -0
- package/dist/dts/env/mockTelegramEnv.d.ts +57 -0
- package/dist/dts/errors.d.ts +27 -0
- package/dist/dts/events/createEmitter.d.ts +58 -0
- package/dist/dts/events/emitEvent.d.ts +33 -0
- package/dist/dts/events/emitter.d.ts +2 -11
- package/dist/dts/events/types/events.d.ts +721 -0
- package/dist/dts/events/types/index.d.ts +3 -0
- package/dist/dts/events/types/listening.d.ts +5 -0
- package/dist/dts/events/types/misc.d.ts +16 -0
- package/dist/dts/globals.d.ts +45 -14
- package/dist/dts/index.d.ts +24 -7
- package/dist/dts/launch-params.d.ts +32 -0
- package/dist/dts/methods/captureSameReq.d.ts +10 -0
- package/dist/dts/methods/createPostEvent.d.ts +27 -7
- package/dist/dts/methods/postEvent.d.ts +31 -25
- package/dist/dts/methods/postMessage.d.ts +7 -0
- package/dist/dts/methods/supports.d.ts +15 -0
- package/dist/dts/methods/types/custom-method.d.ts +59 -0
- package/dist/dts/methods/types/index.d.ts +6 -0
- package/dist/dts/methods/types/methods.d.ts +756 -0
- package/dist/dts/methods/types/misc.d.ts +27 -0
- package/dist/dts/methods/{popup.d.ts → types/popup.d.ts} +1 -1
- package/dist/dts/methods/types/utils.d.ts +9 -0
- package/dist/dts/obj-prop-helpers.d.ts +39 -0
- package/dist/dts/start-param.d.ts +53 -0
- package/dist/dts/utils/compareVersions.d.ts +10 -0
- package/dist/dts/utils/invokeCustomMethod.d.ts +34 -0
- package/dist/dts/utils/request.d.ts +90 -0
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +3 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +977 -0
- package/dist/index.js.map +1 -0
- package/package.json +26 -26
- package/dist/dts/env.d.ts +0 -29
- package/dist/dts/errors/MethodUnsupportedError.d.ts +0 -8
- package/dist/dts/errors/ParameterUnsupportedError.d.ts +0 -8
- package/dist/dts/errors/index.d.ts +0 -2
- package/dist/dts/events/events.d.ts +0 -130
- package/dist/dts/events/index.d.ts +0 -7
- package/dist/dts/events/off.d.ts +0 -7
- package/dist/dts/events/on.d.ts +0 -10
- package/dist/dts/events/onTelegramEvent.d.ts +0 -7
- package/dist/dts/events/once.d.ts +0 -9
- package/dist/dts/events/parsing.d.ts +0 -38
- package/dist/dts/events/payloads.d.ts +0 -93
- package/dist/dts/events/subscribe.d.ts +0 -9
- package/dist/dts/events/unsubscribe.d.ts +0 -6
- package/dist/dts/methods/index.d.ts +0 -6
- package/dist/dts/methods/invoke-custom-method.d.ts +0 -24
- package/dist/dts/methods/methods.d.ts +0 -330
- package/dist/dts/request.d.ts +0 -66
- package/dist/dts/shared.d.ts +0 -5
- package/dist/dts/supports.d.ts +0 -15
- package/dist/index.mjs +0 -297
- package/dist/index.mjs.map +0 -1
- package/src/env.ts +0 -49
- package/src/errors/MethodUnsupportedError.ts +0 -13
- package/src/errors/ParameterUnsupportedError.ts +0 -13
- package/src/errors/index.ts +0 -2
- package/src/events/emitter.ts +0 -126
- package/src/events/events.ts +0 -169
- package/src/events/index.ts +0 -7
- package/src/events/off.ts +0 -12
- package/src/events/on.ts +0 -17
- package/src/events/onTelegramEvent.ts +0 -83
- package/src/events/once.ts +0 -16
- package/src/events/parsing.ts +0 -110
- package/src/events/payloads.ts +0 -125
- package/src/events/subscribe.ts +0 -16
- package/src/events/unsubscribe.ts +0 -11
- package/src/globals.ts +0 -38
- package/src/index.ts +0 -7
- package/src/methods/createPostEvent.ts +0 -39
- package/src/methods/haptic.ts +0 -52
- package/src/methods/index.ts +0 -6
- package/src/methods/invoke-custom-method.ts +0 -25
- package/src/methods/methods.ts +0 -373
- package/src/methods/popup.ts +0 -53
- package/src/methods/postEvent.ts +0 -101
- package/src/request.ts +0 -168
- package/src/shared.ts +0 -5
- package/src/supports.ts +0 -82
- /package/dist/dts/methods/{haptic.d.ts → types/haptic-feedback.d.ts} +0 -0
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,28 +1,59 @@
|
|
|
1
1
|
# @tma.js/bridge
|
|
2
2
|
|
|
3
|
-
[code-link]: https://github.com/Telegram-Mini-Apps/tma.js/tree/master/packages/bridge
|
|
4
|
-
|
|
5
3
|
[code-badge]: https://img.shields.io/badge/source-black?logo=github
|
|
6
4
|
|
|
7
|
-
[docs-link]: https://docs.telegram-mini-apps.com/packages/typescript/tma-js-bridge
|
|
8
|
-
|
|
9
5
|
[docs-badge]: https://img.shields.io/badge/documentation-blue?logo=gitbook&logoColor=white
|
|
10
6
|
|
|
7
|
+
[link]: https://github.com/Telegram-Mini-Apps/telegram-apps/tree/master/tma.js/bridge
|
|
8
|
+
|
|
9
|
+
[docs-link]: https://docs.telegram-mini-apps.com/packages/tma-js-bridge
|
|
10
|
+
|
|
11
11
|
[npm-link]: https://npmjs.com/package/@tma.js/bridge
|
|
12
12
|
|
|
13
13
|
[npm-badge]: https://img.shields.io/npm/v/@tma.js/bridge?logo=npm
|
|
14
14
|
|
|
15
15
|
[size-badge]: https://img.shields.io/bundlephobia/minzip/@tma.js/bridge
|
|
16
16
|
|
|
17
|
-
[![npm-badge]][npm-link]
|
|
18
|
-
![size-badge]
|
|
17
|
+
[![NPM][npm-badge]][npm-link]
|
|
18
|
+
![Size][size-badge]
|
|
19
19
|
[![docs-badge]][docs-link]
|
|
20
|
-
[![code-badge]][
|
|
20
|
+
[![code-badge]][link]
|
|
21
|
+
|
|
22
|
+
The lowest level communication layer with Telegram Mini Apps.
|
|
23
|
+
|
|
24
|
+
This package provides fundamental utilities and types for developing applications on the Telegram
|
|
25
|
+
Mini Apps platform.
|
|
26
|
+
|
|
27
|
+
While a developer can use this package alone, it's recommended to use a higher-level package
|
|
28
|
+
like [@tma.js/sdk](https://docs.telegram-mini-apps.com/packages/tma-js-sdk).
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pnpm i @tma.js/bridge
|
|
34
|
+
# or
|
|
35
|
+
npm i @tma.js/bridge
|
|
36
|
+
# or
|
|
37
|
+
yarn add @tma.js/bridge
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
Here’s a basic example of how to use this package. For more details, refer to the package complete
|
|
43
|
+
[documentation](https://docs.telegram-mini-apps.com/packages/tma-js-bridge).
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { on, postEvent, applyPolyfills } from '@tma.js/bridge';
|
|
47
|
+
|
|
48
|
+
// The package uses some polyfills, so let's use them.
|
|
49
|
+
applyPolyfills();
|
|
21
50
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
51
|
+
// Show the back button, wait for it to be clicked once,
|
|
52
|
+
// then hide it.
|
|
53
|
+
postEvent('web_app_setup_back_button', { is_visible: true });
|
|
25
54
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
55
|
+
const off = on('back_button_pressed', () => {
|
|
56
|
+
postEvent('web_app_setup_back_button', { is_visible: false });
|
|
57
|
+
off();
|
|
58
|
+
});
|
|
59
|
+
```
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as E from 'fp-ts/Either';
|
|
2
|
+
export type DecodeBase64UrlError = DOMException;
|
|
3
|
+
/**
|
|
4
|
+
* Decodes a base-64-url ASCII string.
|
|
5
|
+
* @param value - the value to decode.
|
|
6
|
+
* @see Learn more about base64url:
|
|
7
|
+
* https://herongyang.com/Encoding/Base64URL-Encoding-Algorithm.html
|
|
8
|
+
* @see Source:
|
|
9
|
+
* https://developer.mozilla.org/ru/docs/Glossary/Base64#solution_1_–_escaping_the_string_before_encoding_it
|
|
10
|
+
*/
|
|
11
|
+
export declare function decodeBase64UrlFp(value: string): E.Either<DecodeBase64UrlError, string>;
|
|
12
|
+
/**
|
|
13
|
+
* @see decodeBase64UrlFp
|
|
14
|
+
*/
|
|
15
|
+
export declare const decodeBase64Url: (value: string) => DOMException;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a base-64-url encoded ASCII string from the passed value.
|
|
18
|
+
* @param value - the value to encode.
|
|
19
|
+
* @see Learn more about base64url:
|
|
20
|
+
* https://herongyang.com/Encoding/Base64URL-Encoding-Algorithm.html
|
|
21
|
+
* @see Source:
|
|
22
|
+
* https://developer.mozilla.org/ru/docs/Glossary/Base64#solution_1_–_escaping_the_string_before_encoding_it
|
|
23
|
+
*/
|
|
24
|
+
export declare function encodeBase64Url(value: string): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true in case, passed value contains path `TelegramWebviewProxy.postEvent` property and
|
|
3
|
+
* `postEvent` is a function.
|
|
4
|
+
* @param value - value to check.
|
|
5
|
+
*/
|
|
6
|
+
export declare function hasWebviewProxy<T>(value: T): value is T & {
|
|
7
|
+
TelegramWebviewProxy: {
|
|
8
|
+
postEvent: (...args: unknown[]) => unknown;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BetterPromise, BetterPromiseOptions, TimeoutError } from 'better-promises';
|
|
2
|
+
import { RequestError } from '../utils/request.js';
|
|
3
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
4
|
+
export type isTMAError = Exclude<RequestError, TimeoutError>;
|
|
5
|
+
/**
|
|
6
|
+
* @see isTMAFp
|
|
7
|
+
*/
|
|
8
|
+
export declare function isTMA(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* @see isTMAFp
|
|
11
|
+
*/
|
|
12
|
+
export declare function isTMA(type: 'complete', options?: BetterPromiseOptions): BetterPromise<boolean>;
|
|
13
|
+
/**
|
|
14
|
+
* Returns true if the current environment is Telegram Mini Apps.
|
|
15
|
+
*
|
|
16
|
+
* It uses the `retrieveLaunchParams` function to determine if the environment
|
|
17
|
+
* contains launch parameters. In case it does, true will be returned.
|
|
18
|
+
*
|
|
19
|
+
* In case you need stricter checks, use async override of this function.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isTMAFp(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Returns promise with true if the current environment is Telegram Mini Apps.
|
|
24
|
+
*
|
|
25
|
+
* First of all, it checks if the current environment contains traits specific
|
|
26
|
+
* to the Mini Apps environment. Then, it attempts to call a Mini Apps method
|
|
27
|
+
* and waits for a response to be received.
|
|
28
|
+
*
|
|
29
|
+
* In case you need less strict checks, use sync override of this function.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isTMAFp(type: 'complete', options?: BetterPromiseOptions): TE.TaskEither<isTMAError, boolean>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { LaunchParamsLike } from '@tma.js/transformers';
|
|
2
|
+
import { MethodName, MethodParams } from '../methods/types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Mocks the environment and imitates Telegram Mini Apps behavior.
|
|
5
|
+
*
|
|
6
|
+
* We usually use this function in the following cases:
|
|
7
|
+
* 1. We are developing an application outside the Telegram environment and would like to imitate
|
|
8
|
+
* the Telegram client in order to re-create the same communication behavior.
|
|
9
|
+
* 2. We would like to intercept some Telegram Mini Apps methods' calls in order to enhance them
|
|
10
|
+
* or write a custom behavior. It is extremely useful in some Telegram clients improperly handling
|
|
11
|
+
* Mini Apps methods' calls and not even responding.
|
|
12
|
+
*
|
|
13
|
+
* Note that calling this function in Telegram web clients, the `postMessageImplementation` signal
|
|
14
|
+
* value will be updated with a new one, enhancing previously set signal value to allow wrapping
|
|
15
|
+
* the original `window.parent.postMessage` function. In other words, calling `mockTelegramEnv`
|
|
16
|
+
* function N times, you will effectively wrap previously set implementation N times, so be
|
|
17
|
+
* careful calling this function several times during a single lifecycle of the app. In case you
|
|
18
|
+
* would like to avoid such kind of behavior, use the `resetPostMessage` option.
|
|
19
|
+
*/
|
|
20
|
+
export declare function mockTelegramEnv({ launchParams, onEvent, resetPostMessage }?: {
|
|
21
|
+
/**
|
|
22
|
+
* Launch parameters to mock. They will be saved in the storage, so the SDK functions could
|
|
23
|
+
* retrieve them.
|
|
24
|
+
*
|
|
25
|
+
* Note that this value must have `tgWebAppData` presented in a raw format as long as you will
|
|
26
|
+
* need it when retrieving init data in this format. Otherwise, init data may be broken.
|
|
27
|
+
*/
|
|
28
|
+
launchParams?: (Omit<LaunchParamsLike, 'tgWebAppData'> & {
|
|
29
|
+
tgWebAppData?: string | URLSearchParams;
|
|
30
|
+
}) | string | URLSearchParams;
|
|
31
|
+
/**
|
|
32
|
+
* Function that will be called if a Mini Apps method call was requested by the mini app.
|
|
33
|
+
*
|
|
34
|
+
* It receives a Mini Apps method name along with the passed payload.
|
|
35
|
+
*
|
|
36
|
+
* Note that using the `next` function, in non-web environments it uses the
|
|
37
|
+
* `window.TelegramWebviewProxy.postEvent` method.
|
|
38
|
+
*
|
|
39
|
+
* Talking about the web versions of Telegram, the value of `next` is a bit more complex - it
|
|
40
|
+
* will be equal to the value stored in the `postMessageImpl` signal set previously. By default,
|
|
41
|
+
* this value contains a function utilizing the `window.parent.postMessage` method.
|
|
42
|
+
* @param event - event information.
|
|
43
|
+
* @param next - function to call the original method used to call a Mini Apps method.
|
|
44
|
+
*/
|
|
45
|
+
onEvent?: (event: {
|
|
46
|
+
[M in MethodName]: {
|
|
47
|
+
name: M;
|
|
48
|
+
params: MethodParams<M>;
|
|
49
|
+
};
|
|
50
|
+
}[MethodName] | [string, unknown], next: () => void) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Removes all previously set enhancements of the `window.parent.postMessage` function set
|
|
53
|
+
* by other `mockTelegramEnv` calls.
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
resetPostMessage?: boolean;
|
|
57
|
+
}): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare const MethodUnsupportedError_base: import('error-kid').ErrorClass<[method: string, version: string]>;
|
|
2
|
+
export declare class MethodUnsupportedError extends MethodUnsupportedError_base {
|
|
3
|
+
}
|
|
4
|
+
declare const MethodParameterUnsupportedError_base: import('error-kid').ErrorClass<[method: string, param: string, version: string]>;
|
|
5
|
+
export declare class MethodParameterUnsupportedError extends MethodParameterUnsupportedError_base {
|
|
6
|
+
}
|
|
7
|
+
declare const LaunchParamsRetrieveError_base: import('error-kid').ErrorClassWithData<[{
|
|
8
|
+
source: string;
|
|
9
|
+
error: unknown;
|
|
10
|
+
}[]], {
|
|
11
|
+
errors: {
|
|
12
|
+
source: string;
|
|
13
|
+
error: unknown;
|
|
14
|
+
}[];
|
|
15
|
+
}>;
|
|
16
|
+
export declare class LaunchParamsRetrieveError extends LaunchParamsRetrieveError_base {
|
|
17
|
+
}
|
|
18
|
+
declare const InvalidLaunchParamsError_base: import('error-kid').ErrorClass<[launchParams: string, cause: unknown]>;
|
|
19
|
+
export declare class InvalidLaunchParamsError extends InvalidLaunchParamsError_base {
|
|
20
|
+
}
|
|
21
|
+
declare const UnknownEnvError_base: import('error-kid').ErrorClass<[]>;
|
|
22
|
+
export declare class UnknownEnvError extends UnknownEnvError_base {
|
|
23
|
+
}
|
|
24
|
+
declare const InvokeCustomMethodFailedError_base: import('error-kid').ErrorClass<[error: string]>;
|
|
25
|
+
export declare class InvokeCustomMethodFailedError extends InvokeCustomMethodFailedError_base {
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { If, IsNever, IsUndefined, Or } from '@tma.js/toolkit';
|
|
2
|
+
import { Handler } from 'mitt';
|
|
3
|
+
export type WildcardHandler<E> = Handler<{
|
|
4
|
+
[K in keyof E]: {
|
|
5
|
+
name: K;
|
|
6
|
+
payload: If<Or<IsNever<E[K]>, IsUndefined<E[K]>>, never, E[K]>;
|
|
7
|
+
};
|
|
8
|
+
}[keyof E]>;
|
|
9
|
+
export interface OnFn<E> {
|
|
10
|
+
/**
|
|
11
|
+
* Adds a new listener for the specified event.
|
|
12
|
+
* @param type - event name.
|
|
13
|
+
* @param handler - event listener.
|
|
14
|
+
* @param once - should this listener be called only once.
|
|
15
|
+
* @returns Function to remove bound event listener.
|
|
16
|
+
*/
|
|
17
|
+
<K extends keyof E>(type: K, handler: Handler<E[K]>, once?: boolean): VoidFunction;
|
|
18
|
+
/**
|
|
19
|
+
* Adds a listener to the wildcard event.
|
|
20
|
+
* @param type - event name.
|
|
21
|
+
* @param handler - event listener.
|
|
22
|
+
* @param once - should this listener be called only once.
|
|
23
|
+
* @returns Function to remove bound event listener.
|
|
24
|
+
*/
|
|
25
|
+
(type: '*', handler: WildcardHandler<E>, once?: boolean): VoidFunction;
|
|
26
|
+
}
|
|
27
|
+
export interface OffFn<E> {
|
|
28
|
+
/**
|
|
29
|
+
* Removes a listener from the specified event.
|
|
30
|
+
* @param type - event to listen.
|
|
31
|
+
* @param handler - event listener to remove.
|
|
32
|
+
* @param once - had this listener to be called only once.
|
|
33
|
+
*/
|
|
34
|
+
<K extends keyof E>(type: K, handler: Handler<E[K]>, once?: boolean): void;
|
|
35
|
+
/**
|
|
36
|
+
* Removes a listener from the wildcard event.
|
|
37
|
+
* @param type - event to stop listening.
|
|
38
|
+
* @param handler - event listener to remove.
|
|
39
|
+
* @param once - should this listener be called only once.
|
|
40
|
+
*/
|
|
41
|
+
(type: '*', handler: WildcardHandler<E>, once?: boolean): void;
|
|
42
|
+
}
|
|
43
|
+
export interface EmitFn<E> {
|
|
44
|
+
<K extends keyof E>(type: K, event: E[K]): void;
|
|
45
|
+
<K extends keyof E>(type: undefined extends E[K] ? K : never): void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates a new enhanced event emitter.
|
|
49
|
+
* @param onFirst - a function to call every time when the events map appeared to be empty during
|
|
50
|
+
* the event listener creation.
|
|
51
|
+
* @param onEmpty - a function to call every tume when the events map became empty.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createEmitter<E extends object>(onFirst: VoidFunction, onEmpty: VoidFunction): {
|
|
54
|
+
on: OnFn<E>;
|
|
55
|
+
off: OffFn<E>;
|
|
56
|
+
emit: EmitFn<E>;
|
|
57
|
+
clear: VoidFunction;
|
|
58
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { EventPayload, EventWithoutPayload, EventWithPayload } from './types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Emits an event without payload sent from the Telegram native application like it was sent in
|
|
4
|
+
* a default web environment between two iframes.
|
|
5
|
+
*
|
|
6
|
+
* It dispatches a new MessageEvent and expects it to be handled via
|
|
7
|
+
* the `window.addEventListener('message', ...)` call, as a developer would do it to handle
|
|
8
|
+
* messages sent from the parent iframe.
|
|
9
|
+
* @param eventType - event name.
|
|
10
|
+
*/
|
|
11
|
+
export declare function emitEvent<E extends EventWithoutPayload>(eventType: E): void;
|
|
12
|
+
/**
|
|
13
|
+
* Emits an event with payload sent from the Telegram native application like it was sent in
|
|
14
|
+
* a default web environment between two iframes.
|
|
15
|
+
*
|
|
16
|
+
* It dispatches a new MessageEvent and expects it to be handled via
|
|
17
|
+
* the `window.addEventListener('message', ...)` call, as a developer would do it to handle
|
|
18
|
+
* messages sent from the parent iframe.
|
|
19
|
+
* @param eventType - event name.
|
|
20
|
+
* @param eventData - event payload.
|
|
21
|
+
*/
|
|
22
|
+
export declare function emitEvent<E extends EventWithPayload>(eventType: E, eventData: EventPayload<E>): void;
|
|
23
|
+
/**
|
|
24
|
+
* Emits an unknown event sent from the Telegram native application like it was sent in a default
|
|
25
|
+
* web environment between two iframes.
|
|
26
|
+
*
|
|
27
|
+
* It dispatches a new MessageEvent and expects it to be handled via
|
|
28
|
+
* the `window.addEventListener('message', ...)` call, as a developer would do it to handle
|
|
29
|
+
* messages sent from the parent iframe.
|
|
30
|
+
* @param eventType - event name.
|
|
31
|
+
* @param eventData - event payload.
|
|
32
|
+
*/
|
|
33
|
+
export declare function emitEvent<E extends string>(eventType: E, eventData: E extends EventWithoutPayload ? never : E extends EventWithPayload ? EventPayload<E> : unknown): void;
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
* Returns event emitter which could be safely used, to process events from
|
|
4
|
-
* Telegram native application.
|
|
5
|
-
*/
|
|
6
|
-
export declare function createEmitter(): EventEmitter;
|
|
7
|
-
/**
|
|
8
|
-
* Returns singleton instance of bridge EventEmitter. Also, defines
|
|
9
|
-
* Telegram event handlers.
|
|
10
|
-
*/
|
|
11
|
-
export declare function singletonEmitter(): EventEmitter;
|
|
1
|
+
import { Events } from './types/index.js';
|
|
2
|
+
export declare const on: import('./createEmitter.js').OnFn<Events>, off: import('./createEmitter.js').OffFn<Events>, emit: import('./createEmitter.js').EmitFn<Events>, offAll: VoidFunction;
|