@tma.js/bridge 1.4.1 → 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/parsers/clipboardTextReceived.d.ts +0 -13
- package/dist/dts/events/parsers/customMethodInvoked.d.ts +0 -16
- package/dist/dts/events/parsers/index.d.ts +0 -9
- package/dist/dts/events/parsers/invoiceClosed.d.ts +0 -12
- package/dist/dts/events/parsers/phoneRequested.d.ts +0 -8
- package/dist/dts/events/parsers/popupClosed.d.ts +0 -8
- package/dist/dts/events/parsers/qrTextReceived.d.ts +0 -7
- package/dist/dts/events/parsers/theme-changed.d.ts +0 -42
- package/dist/dts/events/parsers/viewportChanged.d.ts +0 -19
- package/dist/dts/events/parsers/writeAccessRequested.d.ts +0 -8
- 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 -317
- 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/parsers/clipboardTextReceived.ts +0 -27
- package/src/events/parsers/customMethodInvoked.ts +0 -26
- package/src/events/parsers/index.ts +0 -9
- package/src/events/parsers/invoiceClosed.ts +0 -26
- package/src/events/parsers/phoneRequested.ts +0 -14
- package/src/events/parsers/popupClosed.ts +0 -19
- package/src/events/parsers/qrTextReceived.ts +0 -14
- package/src/events/parsers/theme-changed.ts +0 -58
- package/src/events/parsers/viewportChanged.ts +0 -33
- package/src/events/parsers/writeAccessRequested.ts +0 -14
- 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/package.json
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tma.js/bridge",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "TypeScript package to provide communication layer between Mini App and Telegram application.",
|
|
5
5
|
"author": "Vladislav Kibenko <wolfram.deus@gmail.com>",
|
|
6
|
-
"homepage": "https://github.com/Telegram-Mini-Apps/
|
|
6
|
+
"homepage": "https://github.com/Telegram-Mini-Apps/telegram-apps#readme",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git
|
|
10
|
-
"directory": "
|
|
9
|
+
"url": "git@github.com:Telegram-Mini-Apps/telegram-apps.git",
|
|
10
|
+
"directory": "tma.js/bridge"
|
|
11
11
|
},
|
|
12
12
|
"bugs": {
|
|
13
|
-
"url": "https://github.com/Telegram-Mini-Apps/
|
|
13
|
+
"url": "https://github.com/Telegram-Mini-Apps/telegram-apps/issues"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"telegram-mini-apps",
|
|
17
17
|
"typescript",
|
|
18
|
-
"bridge"
|
|
19
|
-
"webview"
|
|
18
|
+
"bridge"
|
|
20
19
|
],
|
|
21
20
|
"license": "MIT",
|
|
22
21
|
"type": "module",
|
|
23
22
|
"sideEffects": false,
|
|
24
23
|
"files": [
|
|
25
|
-
"dist"
|
|
26
|
-
"src"
|
|
24
|
+
"dist"
|
|
27
25
|
],
|
|
28
26
|
"main": "./dist/index.cjs",
|
|
29
|
-
"
|
|
30
|
-
"module": "./dist/index.mjs",
|
|
27
|
+
"module": "./dist/index.js",
|
|
31
28
|
"types": "./dist/dts/index.d.ts",
|
|
32
29
|
"exports": {
|
|
33
30
|
".": {
|
|
34
31
|
"types": "./dist/dts/index.d.ts",
|
|
35
|
-
"import": "./dist/index.
|
|
32
|
+
"import": "./dist/index.js",
|
|
36
33
|
"require": "./dist/index.cjs",
|
|
37
34
|
"default": "./dist/index.cjs"
|
|
38
35
|
}
|
|
39
36
|
},
|
|
40
37
|
"dependencies": {
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"@tma.js/
|
|
38
|
+
"better-promises": "^1.0.0",
|
|
39
|
+
"error-kid": "^1.0.2",
|
|
40
|
+
"fp-ts": "^2.16.11",
|
|
41
|
+
"mitt": "^3.0.1",
|
|
42
|
+
"valibot": "^1.1.0",
|
|
43
|
+
"@tma.js/signals": "^1.0.0",
|
|
44
|
+
"@tma.js/toolkit": "^1.0.0",
|
|
45
|
+
"@tma.js/transformers": "^1.0.0",
|
|
46
|
+
"@tma.js/types": "^1.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"
|
|
50
|
-
"eslint-config-custom": "0.1.0",
|
|
49
|
+
"test-utils": "0.0.1",
|
|
51
50
|
"tsconfig": "0.0.2"
|
|
52
51
|
},
|
|
53
52
|
"publishConfig": {
|
|
54
53
|
"access": "public"
|
|
55
54
|
},
|
|
56
55
|
"scripts": {
|
|
57
|
-
"test": "vitest",
|
|
58
|
-
"lint": "eslint -
|
|
56
|
+
"test": "vitest --run",
|
|
57
|
+
"lint": "cd ../.. && eslint tma.js/bridge/src --ignore-pattern **/*.test.ts",
|
|
58
|
+
"lint:fix": "pnpm run lint --fix",
|
|
59
59
|
"typecheck": "tsc --noEmit -p tsconfig.build.json",
|
|
60
|
-
"build": "pnpm run build:default && pnpm run build:iife",
|
|
61
|
-
"build:default": "vite build
|
|
62
|
-
"build:iife": "vite build
|
|
60
|
+
"build": "rimraf dist && pnpm run build:default && pnpm run build:iife",
|
|
61
|
+
"build:default": "vite build -c vite.config.ts",
|
|
62
|
+
"build:iife": "vite build -c vite.iife.config.ts"
|
|
63
63
|
}
|
|
64
64
|
}
|
package/dist/dts/env.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
type AnyFunc = (...args: unknown[]) => unknown;
|
|
2
|
-
type WithExternalNotify<T> = T & {
|
|
3
|
-
external: {
|
|
4
|
-
notify: AnyFunc;
|
|
5
|
-
};
|
|
6
|
-
};
|
|
7
|
-
type WithWebviewProxy<T> = T & {
|
|
8
|
-
TelegramWebviewProxy: {
|
|
9
|
-
postEvent: AnyFunc;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Returns true in case, passed value contains path `external.notify` property and `notify` is a
|
|
14
|
-
* function.
|
|
15
|
-
* @param value - value to check.
|
|
16
|
-
*/
|
|
17
|
-
export declare function hasExternalNotify<T extends {}>(value: T): value is WithExternalNotify<T>;
|
|
18
|
-
/**
|
|
19
|
-
* Returns true in case, passed value contains path `TelegramWebviewProxy.postEvent` property and
|
|
20
|
-
* `postEvent` is a function.
|
|
21
|
-
* @param value - value to check.
|
|
22
|
-
*/
|
|
23
|
-
export declare function hasWebviewProxy<T extends {}>(value: T): value is WithWebviewProxy<T>;
|
|
24
|
-
/**
|
|
25
|
-
* Returns true in case, current environment is iframe.
|
|
26
|
-
* @see https://stackoverflow.com/a/326076
|
|
27
|
-
*/
|
|
28
|
-
export declare function isIframe(): boolean;
|
|
29
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Version } from '@tma.js/utils';
|
|
2
|
-
import type { MethodName } from '../methods/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Error thrown in case, unsupported method was called.
|
|
5
|
-
*/
|
|
6
|
-
export declare class MethodUnsupportedError extends Error {
|
|
7
|
-
constructor(method: MethodName, version: Version);
|
|
8
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Version } from '@tma.js/utils';
|
|
2
|
-
import type { MethodName } from '../methods/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Error thrown in case, unsupported parameter was used.
|
|
5
|
-
*/
|
|
6
|
-
export declare class ParameterUnsupportedError extends Error {
|
|
7
|
-
constructor(method: MethodName, param: string, version: Version);
|
|
8
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import type { EventEmitter as UtilEventEmitter, EventListener as UtilEventListener, EventParams as UtilEventParams, AnySubscribeListener } from '@tma.js/event-emitter';
|
|
2
|
-
import type { IsNever, Not } from '@tma.js/util-types';
|
|
3
|
-
import type { ClipboardTextReceivedPayload, CustomMethodInvokedPayload, InvoiceClosedPayload, PhoneRequestedPayload, PopupClosedPayload, QrTextReceivedPayload, ThemeChangedPayload, ViewportChangedPayload, WriteAccessRequestedPayload } from './parsers/index.js';
|
|
4
|
-
/**
|
|
5
|
-
* Map where key is known event name, and value is its listener.
|
|
6
|
-
* @see https://docs.telegram-mini-apps.com/apps-communication/events
|
|
7
|
-
*/
|
|
8
|
-
export interface Events {
|
|
9
|
-
/**
|
|
10
|
-
* User clicked back button.
|
|
11
|
-
* @since v6.1
|
|
12
|
-
* @see https://docs.telegram-mini-apps.com/apps-communication/events#back-button-pressed
|
|
13
|
-
*/
|
|
14
|
-
back_button_pressed: () => void;
|
|
15
|
-
/**
|
|
16
|
-
* Telegram application attempted to extract text from clipboard.
|
|
17
|
-
* @param payload - event payload.
|
|
18
|
-
* @since v6.4
|
|
19
|
-
* @see https://docs.telegram-mini-apps.com/apps-communication/events#clipboard-text-received
|
|
20
|
-
*/
|
|
21
|
-
clipboard_text_received: (payload: ClipboardTextReceivedPayload) => void;
|
|
22
|
-
/**
|
|
23
|
-
* Custom method invocation completed.
|
|
24
|
-
* @param payload - event payload.
|
|
25
|
-
* @since v6.9
|
|
26
|
-
* @see https://docs.telegram-mini-apps.com/apps-communication/events#custom-method-invoked
|
|
27
|
-
*/
|
|
28
|
-
custom_method_invoked: (payload: CustomMethodInvokedPayload) => void;
|
|
29
|
-
/**
|
|
30
|
-
* An invoice was closed.
|
|
31
|
-
* @param payload - invoice close information.
|
|
32
|
-
* @see https://docs.telegram-mini-apps.com/apps-communication/events#invoice-closed
|
|
33
|
-
*/
|
|
34
|
-
invoice_closed: (payload: InvoiceClosedPayload) => void;
|
|
35
|
-
/**
|
|
36
|
-
* User clicked the Main Button.
|
|
37
|
-
* @see https://docs.telegram-mini-apps.com/apps-communication/events#main-button-pressed
|
|
38
|
-
*/
|
|
39
|
-
main_button_pressed: () => void;
|
|
40
|
-
/**
|
|
41
|
-
* Application received phone access request status.
|
|
42
|
-
* @param payload - event payload.
|
|
43
|
-
* @since v6.9
|
|
44
|
-
* @see https://docs.telegram-mini-apps.com/apps-communication/events#phone-requested
|
|
45
|
-
*/
|
|
46
|
-
phone_requested: (payload: PhoneRequestedPayload) => void;
|
|
47
|
-
/**
|
|
48
|
-
* Popup was closed.
|
|
49
|
-
* @param payload - event payload.
|
|
50
|
-
* @see https://docs.telegram-mini-apps.com/apps-communication/events#popup-closed
|
|
51
|
-
*/
|
|
52
|
-
popup_closed: (payload: PopupClosedPayload) => void;
|
|
53
|
-
/**
|
|
54
|
-
* Parent iframe requested current iframe reload.
|
|
55
|
-
* @see https://docs.telegram-mini-apps.com/apps-communication/events#reload-iframe
|
|
56
|
-
*/
|
|
57
|
-
reload_iframe: () => void;
|
|
58
|
-
/**
|
|
59
|
-
* The QR scanner scanned some QR and extracted its content.
|
|
60
|
-
* @param payload - event payload.
|
|
61
|
-
* @since v6.4
|
|
62
|
-
* @see https://docs.telegram-mini-apps.com/apps-communication/events#qr-text-received
|
|
63
|
-
*/
|
|
64
|
-
qr_text_received: (payload: QrTextReceivedPayload) => void;
|
|
65
|
-
/**
|
|
66
|
-
* QR scanner was closed.
|
|
67
|
-
* @since v6.4
|
|
68
|
-
* @see https://docs.telegram-mini-apps.com/apps-communication/events#scan-qr-popup-closed
|
|
69
|
-
*/
|
|
70
|
-
scan_qr_popup_closed: () => void;
|
|
71
|
-
/**
|
|
72
|
-
* The event which is usually sent by the Telegram web application. Its payload represents
|
|
73
|
-
* `<style/>` tag html content, a developer could use. The stylesheet described in the payload
|
|
74
|
-
* will help the developer to stylize the app scrollbar (but he is still able to do it himself).
|
|
75
|
-
* @param html - `style` tag inner HTML.
|
|
76
|
-
* @see https://docs.telegram-mini-apps.com/apps-communication/events#set-custom-style
|
|
77
|
-
*/
|
|
78
|
-
set_custom_style: (html: string) => void;
|
|
79
|
-
/**
|
|
80
|
-
* Occurs when the Settings Button was pressed.
|
|
81
|
-
* @since v6.1
|
|
82
|
-
* @see https://docs.telegram-mini-apps.com/apps-communication/events#settings-button-pressed
|
|
83
|
-
*/
|
|
84
|
-
settings_button_pressed: () => void;
|
|
85
|
-
/**
|
|
86
|
-
* Occurs whenever theme settings are changed in the user's Telegram app
|
|
87
|
-
* (including switching to night mode).
|
|
88
|
-
* @param payload - event payload.
|
|
89
|
-
* @see https://docs.telegram-mini-apps.com/apps-communication/events#theme-changed
|
|
90
|
-
*/
|
|
91
|
-
theme_changed: (payload: ThemeChangedPayload) => void;
|
|
92
|
-
/**
|
|
93
|
-
* Occurs whenever the viewport has been changed. For example, when the user started
|
|
94
|
-
* dragging the application or called the expansion method.
|
|
95
|
-
* @param payload - event payload.
|
|
96
|
-
* @see https://docs.telegram-mini-apps.com/apps-communication/events#viewport-changed
|
|
97
|
-
*/
|
|
98
|
-
viewport_changed: (payload: ViewportChangedPayload) => void;
|
|
99
|
-
/**
|
|
100
|
-
* Application received write access request status.
|
|
101
|
-
* @param payload - event payload.
|
|
102
|
-
* @since v6.9
|
|
103
|
-
* @see https://docs.telegram-mini-apps.com/apps-communication/events#write-access-requested
|
|
104
|
-
*/
|
|
105
|
-
write_access_requested: (payload: WriteAccessRequestedPayload) => void;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Any known event name.
|
|
109
|
-
*/
|
|
110
|
-
export type EventName = keyof Events;
|
|
111
|
-
/**
|
|
112
|
-
* Parameters of specified event.
|
|
113
|
-
*/
|
|
114
|
-
export type EventParams<E extends EventName> = UtilEventParams<Events[E]>[0];
|
|
115
|
-
/**
|
|
116
|
-
* Returns event listener for specified event name.
|
|
117
|
-
*/
|
|
118
|
-
export type EventListener<E extends EventName> = UtilEventListener<Events[E]>;
|
|
119
|
-
/**
|
|
120
|
-
* Event emitter, based describe events map.
|
|
121
|
-
*/
|
|
122
|
-
export type EventEmitter = UtilEventEmitter<Events>;
|
|
123
|
-
/**
|
|
124
|
-
* Returns true in case, event has parameters.
|
|
125
|
-
*/
|
|
126
|
-
export type EventHasParams<E extends EventName> = Not<IsNever<EventParams<E>>>;
|
|
127
|
-
/**
|
|
128
|
-
* Event listener used in `subscribe` and `unsubscribe` functions.
|
|
129
|
-
*/
|
|
130
|
-
export type GlobalEventListener = AnySubscribeListener<Events> | ((event: string, data: unknown) => void);
|
package/dist/dts/events/off.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { EventName, EventListener } from './events.js';
|
|
2
|
-
/**
|
|
3
|
-
* Removes listener from specified event.
|
|
4
|
-
* @param event - event to listen.
|
|
5
|
-
* @param listener - event listener.
|
|
6
|
-
*/
|
|
7
|
-
export declare function off<E extends EventName>(event: E, listener: EventListener<E>): void;
|
package/dist/dts/events/on.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { EventName, EventListener } from './events.js';
|
|
2
|
-
type StopListening = () => void;
|
|
3
|
-
/**
|
|
4
|
-
* Adds new listener to the specified event. Returns handler
|
|
5
|
-
* which allows to stop listening to event.
|
|
6
|
-
* @param event - event name.
|
|
7
|
-
* @param listener - event listener.
|
|
8
|
-
*/
|
|
9
|
-
export declare function on<E extends EventName>(event: E, listener: EventListener<E>): StopListening;
|
|
10
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adds listener to window "message" event assuming, that this event could
|
|
3
|
-
* be sent by Telegram native application. Calls passed callback with event
|
|
4
|
-
* type and data.
|
|
5
|
-
* @param cb - callback to call.
|
|
6
|
-
*/
|
|
7
|
-
export declare function onTelegramEvent(cb: (eventType: string, eventData: unknown) => void): void;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { EventName, EventListener } from './events.js';
|
|
2
|
-
type StopListening = () => void;
|
|
3
|
-
/**
|
|
4
|
-
* Works the same as "on" method, but after catching the event, will remove event listener.
|
|
5
|
-
* @param event - event name.
|
|
6
|
-
* @param listener - event listener.
|
|
7
|
-
*/
|
|
8
|
-
export declare function once<E extends EventName>(event: E, listener: EventListener<E>): StopListening;
|
|
9
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { RequestId } from '../../shared.js';
|
|
2
|
-
export interface ClipboardTextReceivedPayload {
|
|
3
|
-
/**
|
|
4
|
-
* Passed during the `web_app_read_text_from_clipboard` method invocation `req_id` value.
|
|
5
|
-
*/
|
|
6
|
-
req_id: RequestId;
|
|
7
|
-
/**
|
|
8
|
-
* Data extracted from the clipboard. The returned value will have the type `string` only in
|
|
9
|
-
* the case, application has access to the clipboard.
|
|
10
|
-
*/
|
|
11
|
-
data?: string | null;
|
|
12
|
-
}
|
|
13
|
-
export declare function clipboardTextReceived(): import("@tma.js/parsing").ValueParser<ClipboardTextReceivedPayload, false>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { RequestId } from '../../shared.js';
|
|
2
|
-
export interface CustomMethodInvokedPayload<R = unknown> {
|
|
3
|
-
/**
|
|
4
|
-
* Unique identifier of this invocation.
|
|
5
|
-
*/
|
|
6
|
-
req_id: RequestId;
|
|
7
|
-
/**
|
|
8
|
-
* Method invocation successful result.
|
|
9
|
-
*/
|
|
10
|
-
result?: R;
|
|
11
|
-
/**
|
|
12
|
-
* Method invocation error code.
|
|
13
|
-
*/
|
|
14
|
-
error?: string;
|
|
15
|
-
}
|
|
16
|
-
export declare function customMethodInvoked(): import("@tma.js/parsing").ValueParser<CustomMethodInvokedPayload<unknown>, false>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './clipboardTextReceived.js';
|
|
2
|
-
export * from './customMethodInvoked.js';
|
|
3
|
-
export * from './invoiceClosed.js';
|
|
4
|
-
export * from './phoneRequested.js';
|
|
5
|
-
export * from './popupClosed.js';
|
|
6
|
-
export * from './qrTextReceived.js';
|
|
7
|
-
export * from './theme-changed.js';
|
|
8
|
-
export * from './viewportChanged.js';
|
|
9
|
-
export * from './writeAccessRequested.js';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type InvoiceStatus = 'paid' | 'failed' | 'pending' | 'cancelled' | string;
|
|
2
|
-
export interface InvoiceClosedPayload {
|
|
3
|
-
/**
|
|
4
|
-
* Passed during the `web_app_open_invoice` method invocation `slug` value.
|
|
5
|
-
*/
|
|
6
|
-
slug: string;
|
|
7
|
-
/**
|
|
8
|
-
* Invoice status
|
|
9
|
-
*/
|
|
10
|
-
status: InvoiceStatus;
|
|
11
|
-
}
|
|
12
|
-
export declare function invoiceClosed(): import("@tma.js/parsing").ValueParser<InvoiceClosedPayload, false>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type PhoneRequestedStatus = 'sent' | string;
|
|
2
|
-
export interface PhoneRequestedPayload {
|
|
3
|
-
/**
|
|
4
|
-
* Request status.
|
|
5
|
-
*/
|
|
6
|
-
status: PhoneRequestedStatus;
|
|
7
|
-
}
|
|
8
|
-
export declare function phoneRequested(): import("@tma.js/parsing").ValueParser<PhoneRequestedPayload, false>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface PopupClosedPayload {
|
|
2
|
-
/**
|
|
3
|
-
* Identifier of the clicked button. In case, the popup was closed without clicking any button,
|
|
4
|
-
* this property will be omitted.
|
|
5
|
-
*/
|
|
6
|
-
button_id?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function popupClosed(): import("@tma.js/parsing").ValueParser<PopupClosedPayload, false>;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { RGB } from '@tma.js/colors';
|
|
2
|
-
export interface ThemeChangedPayload {
|
|
3
|
-
/**
|
|
4
|
-
* Map where the key is a theme stylesheet key and value is the corresponding color in
|
|
5
|
-
* `#RRGGBB` format.
|
|
6
|
-
*/
|
|
7
|
-
theme_params: {
|
|
8
|
-
/**
|
|
9
|
-
* @since v6.10
|
|
10
|
-
*/
|
|
11
|
-
accent_text_color?: RGB;
|
|
12
|
-
bg_color?: RGB;
|
|
13
|
-
button_color?: RGB;
|
|
14
|
-
button_text_color?: RGB;
|
|
15
|
-
/**
|
|
16
|
-
* @since v6.10
|
|
17
|
-
*/
|
|
18
|
-
destructive_text_color?: RGB;
|
|
19
|
-
/**
|
|
20
|
-
* @since v6.10
|
|
21
|
-
*/
|
|
22
|
-
header_bg_color?: RGB;
|
|
23
|
-
hint_color?: RGB;
|
|
24
|
-
link_color?: RGB;
|
|
25
|
-
secondary_bg_color?: RGB;
|
|
26
|
-
/**
|
|
27
|
-
* @since v6.10
|
|
28
|
-
*/
|
|
29
|
-
section_bg_color?: RGB;
|
|
30
|
-
/**
|
|
31
|
-
* @since v6.10
|
|
32
|
-
*/
|
|
33
|
-
section_header_text_color?: RGB;
|
|
34
|
-
/**
|
|
35
|
-
* @since v6.10
|
|
36
|
-
*/
|
|
37
|
-
subtitle_text_color?: RGB;
|
|
38
|
-
text_color?: RGB;
|
|
39
|
-
[key: string]: RGB | undefined;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
export declare function themeChanged(): import("@tma.js/parsing").ValueParser<ThemeChangedPayload, false>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export interface ViewportChangedPayload {
|
|
2
|
-
/**
|
|
3
|
-
* The viewport height.
|
|
4
|
-
*/
|
|
5
|
-
height: number;
|
|
6
|
-
/**
|
|
7
|
-
* The viewport width.
|
|
8
|
-
*/
|
|
9
|
-
width: number;
|
|
10
|
-
/**
|
|
11
|
-
* Is the viewport currently expanded.
|
|
12
|
-
*/
|
|
13
|
-
is_expanded: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Is the viewport current state stable and not going to change in the next moment.
|
|
16
|
-
*/
|
|
17
|
-
is_state_stable: boolean;
|
|
18
|
-
}
|
|
19
|
-
export declare function viewportChanged(): import("@tma.js/parsing").ValueParser<ViewportChangedPayload, false>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type WriteAccessRequestedStatus = 'allowed' | string;
|
|
2
|
-
export interface WriteAccessRequestedPayload {
|
|
3
|
-
/**
|
|
4
|
-
* Request status.
|
|
5
|
-
*/
|
|
6
|
-
status: WriteAccessRequestedStatus;
|
|
7
|
-
}
|
|
8
|
-
export declare function writeAccessRequested(): import("@tma.js/parsing").ValueParser<WriteAccessRequestedPayload, false>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { GlobalEventListener } from './events.js';
|
|
2
|
-
type StopListening = () => void;
|
|
3
|
-
/**
|
|
4
|
-
* Subscribes to all events sent from the native Telegram application.
|
|
5
|
-
* Returns function used to remove added event listener.
|
|
6
|
-
* @param listener - event listener.
|
|
7
|
-
*/
|
|
8
|
-
export declare function subscribe(listener: GlobalEventListener): StopListening;
|
|
9
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { RequestId } from '../shared.js';
|
|
2
|
-
interface CreateInvokeCustomMethodParams<M extends string, Params extends object> {
|
|
3
|
-
/**
|
|
4
|
-
* Unique request identifier.
|
|
5
|
-
*/
|
|
6
|
-
req_id: RequestId;
|
|
7
|
-
/**
|
|
8
|
-
* Method name.
|
|
9
|
-
*/
|
|
10
|
-
method: M;
|
|
11
|
-
/**
|
|
12
|
-
* Method specific parameters.
|
|
13
|
-
*/
|
|
14
|
-
params: Params;
|
|
15
|
-
}
|
|
16
|
-
export type AnyInvokeCustomMethodParams = CreateInvokeCustomMethodParams<'deleteStorageValues', {
|
|
17
|
-
keys: string | string[];
|
|
18
|
-
}> | CreateInvokeCustomMethodParams<'getStorageValues', {
|
|
19
|
-
keys: string | string[];
|
|
20
|
-
}> | CreateInvokeCustomMethodParams<'getStorageKeys', {}> | CreateInvokeCustomMethodParams<'saveStorageValue', {
|
|
21
|
-
key: string;
|
|
22
|
-
value: string;
|
|
23
|
-
}> | CreateInvokeCustomMethodParams<string, any>;
|
|
24
|
-
export {};
|