@tma.js/bridge 1.3.12 → 1.4.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/dist/dts/errors/MethodUnsupportedError.d.ts +8 -0
- package/dist/dts/errors/ParameterUnsupportedError.d.ts +8 -0
- package/dist/dts/errors/index.d.ts +2 -0
- package/dist/dts/events/events.d.ts +7 -2
- package/dist/dts/events/payloads.d.ts +2 -7
- package/dist/dts/index.d.ts +1 -0
- package/dist/dts/methods/createPostEvent.d.ts +10 -0
- package/dist/dts/methods/index.d.ts +5 -4
- package/dist/dts/methods/{params.d.ts → methods.d.ts} +30 -18
- package/dist/dts/methods/postEvent.d.ts +1 -1
- package/dist/dts/request.d.ts +10 -10
- package/dist/dts/supports.d.ts +2 -9
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +174 -146
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/errors/MethodUnsupportedError.ts +13 -0
- package/src/errors/ParameterUnsupportedError.ts +13 -0
- package/src/errors/index.ts +2 -0
- package/src/events/emitter.ts +1 -0
- package/src/events/events.ts +10 -5
- package/src/events/parsing.ts +9 -3
- package/src/events/payloads.ts +16 -7
- package/src/index.ts +1 -0
- package/src/methods/createPostEvent.ts +39 -0
- package/src/methods/index.ts +5 -4
- package/src/methods/{params.ts → methods.ts} +33 -18
- package/src/methods/postEvent.ts +1 -1
- package/src/request.ts +27 -30
- package/src/supports.ts +19 -40
package/src/events/emitter.ts
CHANGED
|
@@ -95,6 +95,7 @@ export function createEmitter(): EventEmitter {
|
|
|
95
95
|
case 'back_button_pressed':
|
|
96
96
|
case 'settings_button_pressed':
|
|
97
97
|
case 'scan_qr_popup_closed':
|
|
98
|
+
case 'reload_iframe':
|
|
98
99
|
return emit(eventType);
|
|
99
100
|
|
|
100
101
|
// All other event listeners will receive unknown type of data.
|
package/src/events/events.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
EventEmitter as UtilEventEmitter,
|
|
3
|
-
EventName as UtilEventName,
|
|
4
3
|
EventListener as UtilEventListener,
|
|
5
|
-
EventParams as UtilEventParams,
|
|
4
|
+
EventParams as UtilEventParams,
|
|
5
|
+
AnySubscribeListener,
|
|
6
6
|
} from '@tma.js/event-emitter';
|
|
7
7
|
import type { IsNever, Not } from '@tma.js/util-types';
|
|
8
8
|
|
|
@@ -74,6 +74,12 @@ export interface Events {
|
|
|
74
74
|
*/
|
|
75
75
|
popup_closed: (payload: PopupClosedPayload) => void;
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Parent iframe requested current iframe reload.
|
|
79
|
+
* @see https://docs.telegram-mini-apps.com/apps-communication/events#reload-iframe
|
|
80
|
+
*/
|
|
81
|
+
reload_iframe: () => void;
|
|
82
|
+
|
|
77
83
|
/**
|
|
78
84
|
* The QR scanner scanned some QR and extracted its content.
|
|
79
85
|
* @param payload - event payload.
|
|
@@ -133,7 +139,7 @@ export interface Events {
|
|
|
133
139
|
/**
|
|
134
140
|
* Any known event name.
|
|
135
141
|
*/
|
|
136
|
-
export type EventName =
|
|
142
|
+
export type EventName = keyof Events;
|
|
137
143
|
|
|
138
144
|
/**
|
|
139
145
|
* Parameters of specified event.
|
|
@@ -143,8 +149,7 @@ export type EventParams<E extends EventName> = UtilEventParams<Events[E]>[0];
|
|
|
143
149
|
/**
|
|
144
150
|
* Returns event listener for specified event name.
|
|
145
151
|
*/
|
|
146
|
-
export type EventListener<E extends EventName> =
|
|
147
|
-
UtilEventListener<Events[E]>;
|
|
152
|
+
export type EventListener<E extends EventName> = UtilEventListener<Events[E]>;
|
|
148
153
|
|
|
149
154
|
/**
|
|
150
155
|
* Event emitter, based describe events map.
|
package/src/events/parsing.ts
CHANGED
|
@@ -33,13 +33,19 @@ const windowWidthParser = createValueParserGenerator(
|
|
|
33
33
|
*/
|
|
34
34
|
export const themeChangedPayload = json<ThemeChangedPayload>({
|
|
35
35
|
theme_params: json({
|
|
36
|
+
accent_text_color: rgbOptional,
|
|
36
37
|
bg_color: rgbOptional,
|
|
37
|
-
text_color: rgbOptional,
|
|
38
|
-
hint_color: rgbOptional,
|
|
39
|
-
link_color: rgbOptional,
|
|
40
38
|
button_color: rgbOptional,
|
|
41
39
|
button_text_color: rgbOptional,
|
|
40
|
+
destructive_text_color: rgbOptional,
|
|
41
|
+
header_bg_color: rgbOptional,
|
|
42
|
+
hint_color: rgbOptional,
|
|
43
|
+
link_color: rgbOptional,
|
|
42
44
|
secondary_bg_color: rgbOptional,
|
|
45
|
+
section_bg_color: rgbOptional,
|
|
46
|
+
section_header_text_color: rgbOptional,
|
|
47
|
+
subtitle_text_color: rgbOptional,
|
|
48
|
+
text_color: rgbOptional,
|
|
43
49
|
}),
|
|
44
50
|
});
|
|
45
51
|
|
package/src/events/payloads.ts
CHANGED
|
@@ -54,19 +54,28 @@ export interface QrTextReceivedPayload {
|
|
|
54
54
|
data?: string;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
export type ThemeParamsKey =
|
|
58
|
+
| 'accent_text_color'
|
|
59
|
+
| 'bg_color'
|
|
60
|
+
| 'button_color'
|
|
61
|
+
| 'button_text_color'
|
|
62
|
+
| 'destructive_text_color'
|
|
63
|
+
| 'header_bg_color'
|
|
64
|
+
| 'hint_color'
|
|
65
|
+
| 'link_color'
|
|
66
|
+
| 'secondary_bg_color'
|
|
67
|
+
| 'section_header_text_color'
|
|
68
|
+
| 'section_bg_color'
|
|
69
|
+
| 'subtitle_text_color'
|
|
70
|
+
| 'text_color';
|
|
71
|
+
|
|
57
72
|
export interface ThemeChangedPayload {
|
|
58
73
|
/**
|
|
59
74
|
* Map where the key is a theme stylesheet key and value is the corresponding color in
|
|
60
75
|
* `#RRGGBB` format.
|
|
61
76
|
*/
|
|
62
77
|
theme_params: {
|
|
63
|
-
|
|
64
|
-
text_color?: RGB;
|
|
65
|
-
hint_color?: RGB;
|
|
66
|
-
link_color?: RGB;
|
|
67
|
-
button_color?: RGB;
|
|
68
|
-
button_text_color?: RGB;
|
|
69
|
-
secondary_bg_color?: RGB;
|
|
78
|
+
[Key in ThemeParamsKey]?: RGB;
|
|
70
79
|
};
|
|
71
80
|
}
|
|
72
81
|
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { isRecord, type Version } from '@tma.js/utils';
|
|
2
|
+
|
|
3
|
+
import { supports } from '../supports.js';
|
|
4
|
+
import { MethodUnsupportedError, ParameterUnsupportedError } from '../errors/index.js';
|
|
5
|
+
import { postEvent, type PostEvent } from './index.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Creates function which checks if specified method and parameters are supported. In case,
|
|
9
|
+
* method or parameters are unsupported, an error will be thrown.
|
|
10
|
+
* @param version - Telegram Mini Apps version.
|
|
11
|
+
* @throws {MethodUnsupportedError} Method is unsupported.
|
|
12
|
+
* @throws {ParameterUnsupportedError} Method parameter is unsupported.
|
|
13
|
+
*/
|
|
14
|
+
export function createPostEvent(version: Version): PostEvent {
|
|
15
|
+
return (method: any, params: any) => {
|
|
16
|
+
// Firstly, check if method itself is supported.
|
|
17
|
+
if (!supports(method, version)) {
|
|
18
|
+
throw new MethodUnsupportedError(method, version);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Method could use parameters, which are supported only in specific versions of Telegram
|
|
22
|
+
// Mini Apps.
|
|
23
|
+
if (isRecord(params)) {
|
|
24
|
+
let validateParam: string | undefined;
|
|
25
|
+
|
|
26
|
+
if (method === 'web_app_open_link' && 'try_instant_view' in params) {
|
|
27
|
+
validateParam = 'try_instant_view';
|
|
28
|
+
} else if (method === 'web_app_set_header_color' && 'color' in params) {
|
|
29
|
+
validateParam = 'color';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (validateParam && !supports(method, validateParam, version)) {
|
|
33
|
+
throw new ParameterUnsupportedError(method, validateParam, version);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return postEvent(method, params);
|
|
38
|
+
};
|
|
39
|
+
}
|
package/src/methods/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
export * from './createPostEvent.js';
|
|
2
|
+
export * from './haptic.js';
|
|
3
|
+
export * from './invoke-custom-method.js';
|
|
4
|
+
export * from './methods.js';
|
|
5
|
+
export * from './popup.js';
|
|
5
6
|
export * from './postEvent.js';
|
|
@@ -16,22 +16,33 @@ export type HeaderColorKey = 'bg_color' | 'secondary_bg_color';
|
|
|
16
16
|
*/
|
|
17
17
|
export type SwitchInlineQueryChatType = 'users' | 'bots' | 'groups' | 'channels';
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
params:
|
|
21
|
-
|
|
22
|
-
}
|
|
19
|
+
interface CreateParams<Params = undefined, VersionedParam extends UnionKeys<Params> = never> {
|
|
20
|
+
params: Params;
|
|
21
|
+
versionedParams: VersionedParam;
|
|
22
|
+
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Describes list of events and their parameters that could be posted by Bridge.
|
|
26
26
|
* @see https://docs.telegram-mini-apps.com/apps-communication/methods
|
|
27
27
|
*/
|
|
28
|
-
export interface
|
|
28
|
+
export interface Methods {
|
|
29
29
|
/**
|
|
30
30
|
* Notifies parent iframe about the current frame is ready. This method is only used in the Web
|
|
31
31
|
* version of Telegram. As a result, Mini App will receive `set_custom_style` event.
|
|
32
32
|
* @see https://docs.telegram-mini-apps.com/apps-communication/methods#iframe-ready
|
|
33
33
|
*/
|
|
34
|
-
iframe_ready: CreateParams
|
|
34
|
+
iframe_ready: CreateParams<{
|
|
35
|
+
/**
|
|
36
|
+
* True, if current Mini App supports native reloading.
|
|
37
|
+
*/
|
|
38
|
+
reload_supported?: boolean;
|
|
39
|
+
} | undefined>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Notifies parent iframe about the current iframe is going to reload.
|
|
43
|
+
* @see https://docs.telegram-mini-apps.com/apps-communication/methods#iframe-will-reload
|
|
44
|
+
*/
|
|
45
|
+
iframe_will_reload: CreateParams;
|
|
35
46
|
|
|
36
47
|
/**
|
|
37
48
|
* Closes Mini App.
|
|
@@ -319,40 +330,44 @@ export interface MethodsParams {
|
|
|
319
330
|
}
|
|
320
331
|
|
|
321
332
|
/**
|
|
322
|
-
* Any
|
|
333
|
+
* Any Telegram Mini Apps known method name.
|
|
323
334
|
*/
|
|
324
|
-
export type MethodName = keyof
|
|
335
|
+
export type MethodName = keyof Methods;
|
|
325
336
|
|
|
326
337
|
/**
|
|
327
338
|
* Returns parameters for specified post-available event.
|
|
328
339
|
*/
|
|
329
|
-
export type MethodParams<
|
|
340
|
+
export type MethodParams<M extends MethodName> = Methods[M]['params'];
|
|
330
341
|
|
|
331
342
|
/**
|
|
332
|
-
*
|
|
343
|
+
* True if specified method accepts parameters.
|
|
333
344
|
*/
|
|
334
|
-
export type
|
|
345
|
+
export type MethodAcceptParams<M extends MethodName> =
|
|
346
|
+
Not<IsNever<Exclude<MethodParams<M>, undefined>>>;
|
|
335
347
|
|
|
336
348
|
/**
|
|
337
349
|
* Any post-available event name which does not require arguments.
|
|
338
350
|
*/
|
|
339
351
|
export type EmptyMethodName = {
|
|
340
|
-
[
|
|
352
|
+
[M in MethodName]: undefined extends MethodParams<M> ? M : never;
|
|
341
353
|
}[MethodName];
|
|
342
354
|
|
|
343
355
|
/**
|
|
344
356
|
* Any post-available event name which require arguments.
|
|
345
357
|
*/
|
|
346
|
-
export type NonEmptyMethodName =
|
|
358
|
+
export type NonEmptyMethodName = {
|
|
359
|
+
[M in MethodName]: MethodAcceptParams<M> extends true ? M : never;
|
|
360
|
+
}[MethodName];
|
|
347
361
|
|
|
348
362
|
/**
|
|
349
|
-
* Method names which
|
|
363
|
+
* Method names which have versioned params.
|
|
350
364
|
*/
|
|
351
|
-
export type
|
|
352
|
-
[
|
|
365
|
+
export type MethodWithVersionedParams = {
|
|
366
|
+
[M in MethodName]: IsNever<Methods[M]['versionedParams']> extends true ? never : M;
|
|
353
367
|
}[MethodName];
|
|
354
368
|
|
|
355
369
|
/**
|
|
356
|
-
* Method
|
|
370
|
+
* Method parameters which appear only in the specific Telegram Mini Apps version.
|
|
357
371
|
*/
|
|
358
|
-
export type
|
|
372
|
+
export type MethodVersionedParams<M extends MethodWithVersionedParams> =
|
|
373
|
+
Methods[M]['versionedParams'];
|
package/src/methods/postEvent.ts
CHANGED
package/src/request.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { withTimeout, isRecord } from '@tma.js/utils';
|
|
2
|
-
|
|
3
2
|
import type { And, If, IsNever } from '@tma.js/util-types';
|
|
4
3
|
|
|
5
4
|
import { postEvent as defaultPostEvent, type PostEvent } from './methods/postEvent.js';
|
|
6
5
|
import { on, type EventName, type EventParams, type EventHasParams } from './events/index.js';
|
|
7
6
|
|
|
8
7
|
import type {
|
|
9
|
-
EmptyMethodName,
|
|
8
|
+
EmptyMethodName,
|
|
9
|
+
MethodAcceptParams,
|
|
10
10
|
MethodName,
|
|
11
11
|
MethodParams,
|
|
12
12
|
NonEmptyMethodName,
|
|
13
|
-
} from './methods/
|
|
13
|
+
} from './methods/methods.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Names of methods, which require passing "req_id" parameter.
|
|
17
17
|
*/
|
|
18
|
-
type
|
|
19
|
-
[
|
|
20
|
-
And<
|
|
21
|
-
|
|
18
|
+
type MethodWithRequestId = {
|
|
19
|
+
[M in MethodName]: If<
|
|
20
|
+
And<MethodAcceptParams<M>, MethodParams<M> extends { req_id: string } ? true : false>,
|
|
21
|
+
M,
|
|
22
22
|
never
|
|
23
23
|
>;
|
|
24
24
|
}[MethodName];
|
|
@@ -26,10 +26,10 @@ type MethodNameWithRequestId = {
|
|
|
26
26
|
/**
|
|
27
27
|
* Names of events, which contain "req_id" parameter.
|
|
28
28
|
*/
|
|
29
|
-
type
|
|
30
|
-
[
|
|
31
|
-
And<EventHasParams<
|
|
32
|
-
|
|
29
|
+
type EventWithRequestId = {
|
|
30
|
+
[E in EventName]: If<
|
|
31
|
+
And<EventHasParams<E>, EventParams<E> extends { req_id: string } ? true : false>,
|
|
32
|
+
E,
|
|
33
33
|
never
|
|
34
34
|
>;
|
|
35
35
|
}[EventName];
|
|
@@ -64,15 +64,12 @@ export interface RequestOptionsAdvanced<EventPayload> extends RequestOptions {
|
|
|
64
64
|
* @param event - event or events to listen.
|
|
65
65
|
* @param options - additional execution options.
|
|
66
66
|
*/
|
|
67
|
-
export function request<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
method: Method,
|
|
72
|
-
params: MethodParams<Method>,
|
|
73
|
-
event: Event | Event[],
|
|
67
|
+
export function request<M extends MethodWithRequestId, E extends EventWithRequestId>(
|
|
68
|
+
method: M,
|
|
69
|
+
params: MethodParams<M>,
|
|
70
|
+
event: E | E[],
|
|
74
71
|
options?: RequestOptions,
|
|
75
|
-
): Promise<EventParams<
|
|
72
|
+
): Promise<EventParams<E>>;
|
|
76
73
|
|
|
77
74
|
/**
|
|
78
75
|
* Calls specified TWA method and captures one of the specified events. Returns promise
|
|
@@ -81,11 +78,11 @@ export function request<
|
|
|
81
78
|
* @param event - event or events to listen.
|
|
82
79
|
* @param options - additional execution options.
|
|
83
80
|
*/
|
|
84
|
-
export function request<
|
|
85
|
-
method:
|
|
86
|
-
event:
|
|
87
|
-
options?: RequestOptionsAdvanced<EventParams<
|
|
88
|
-
): Promise<EventParams<
|
|
81
|
+
export function request<M extends EmptyMethodName, E extends EventName>(
|
|
82
|
+
method: M,
|
|
83
|
+
event: E | E[],
|
|
84
|
+
options?: RequestOptionsAdvanced<EventParams<E>>,
|
|
85
|
+
): Promise<EventParams<E>>;
|
|
89
86
|
|
|
90
87
|
/**
|
|
91
88
|
* Calls specified TWA method and captures one of the specified events. Returns promise
|
|
@@ -95,12 +92,12 @@ export function request<Method extends EmptyMethodName, Event extends EventName>
|
|
|
95
92
|
* @param event - event or events to listen
|
|
96
93
|
* @param options - additional execution options.
|
|
97
94
|
*/
|
|
98
|
-
export function request<
|
|
99
|
-
method:
|
|
100
|
-
params: MethodParams<
|
|
101
|
-
event:
|
|
102
|
-
options?: RequestOptionsAdvanced<EventParams<
|
|
103
|
-
): Promise<EventParams<
|
|
95
|
+
export function request<M extends NonEmptyMethodName, E extends EventName>(
|
|
96
|
+
method: M,
|
|
97
|
+
params: MethodParams<M>,
|
|
98
|
+
event: E | E[],
|
|
99
|
+
options?: RequestOptionsAdvanced<EventParams<E>>,
|
|
100
|
+
): Promise<EventParams<E>>;
|
|
104
101
|
|
|
105
102
|
export function request(
|
|
106
103
|
method: MethodName,
|
package/src/supports.ts
CHANGED
|
@@ -1,40 +1,18 @@
|
|
|
1
1
|
import { compareVersions, type Version } from '@tma.js/utils';
|
|
2
2
|
|
|
3
3
|
import type {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
MethodVersionedParams,
|
|
5
|
+
MethodWithVersionedParams,
|
|
6
6
|
MethodName,
|
|
7
|
-
MethodParams,
|
|
8
|
-
NonEmptyMethodName,
|
|
9
7
|
} from './methods/index.js';
|
|
10
8
|
|
|
11
|
-
function lessOrEqual(a: Version, b: Version): boolean {
|
|
12
|
-
return compareVersions(a, b) <= 0;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
9
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @param
|
|
19
|
-
* @param params - method parameters.
|
|
10
|
+
* Returns true if "a" version is less than or equal to "b" version.
|
|
11
|
+
* @param a
|
|
12
|
+
* @param b
|
|
20
13
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
params: MethodParams<M>,
|
|
24
|
-
): HasCheckSupportMethodParam<HasCheckSupportMethodName>[] {
|
|
25
|
-
if (method === 'web_app_open_link') {
|
|
26
|
-
if ('try_instant_view' in params) {
|
|
27
|
-
return ['try_instant_view'];
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (method === 'web_app_set_header_color') {
|
|
32
|
-
if ('color' in params) {
|
|
33
|
-
return ['color'];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return [];
|
|
14
|
+
function versionLessOrEqual(a: Version, b: Version): boolean {
|
|
15
|
+
return compareVersions(a, b) <= 0;
|
|
38
16
|
}
|
|
39
17
|
|
|
40
18
|
/**
|
|
@@ -43,17 +21,19 @@ export function detectSupportParams<M extends NonEmptyMethodName>(
|
|
|
43
21
|
* @param param - method parameter
|
|
44
22
|
* @param inVersion - platform version.
|
|
45
23
|
*/
|
|
46
|
-
export function supports<M extends
|
|
24
|
+
export function supports<M extends MethodWithVersionedParams>(
|
|
47
25
|
method: M,
|
|
48
|
-
param:
|
|
26
|
+
param: MethodVersionedParams<M>,
|
|
49
27
|
inVersion: Version,
|
|
50
28
|
): boolean;
|
|
29
|
+
|
|
51
30
|
/**
|
|
52
31
|
* Returns true in case, specified method is supported in passed version.
|
|
53
32
|
* @param method - method name.
|
|
54
33
|
* @param inVersion - platform version.
|
|
55
34
|
*/
|
|
56
35
|
export function supports(method: MethodName, inVersion: Version): boolean;
|
|
36
|
+
|
|
57
37
|
export function supports(
|
|
58
38
|
method: MethodName,
|
|
59
39
|
paramOrVersion: Version | string,
|
|
@@ -63,18 +43,17 @@ export function supports(
|
|
|
63
43
|
if (typeof inVersion === 'string') {
|
|
64
44
|
if (method === 'web_app_open_link') {
|
|
65
45
|
if (paramOrVersion === 'try_instant_view') {
|
|
66
|
-
return
|
|
46
|
+
return versionLessOrEqual('6.4', inVersion);
|
|
67
47
|
}
|
|
68
48
|
}
|
|
69
49
|
|
|
70
50
|
if (method === 'web_app_set_header_color') {
|
|
71
51
|
if (paramOrVersion === 'color') {
|
|
72
|
-
return
|
|
52
|
+
return versionLessOrEqual('6.9', inVersion);
|
|
73
53
|
}
|
|
74
54
|
}
|
|
75
55
|
}
|
|
76
56
|
|
|
77
|
-
// Method name, target version.
|
|
78
57
|
switch (method) {
|
|
79
58
|
case 'web_app_open_tg_link':
|
|
80
59
|
case 'web_app_open_invoice':
|
|
@@ -82,21 +61,21 @@ export function supports(
|
|
|
82
61
|
case 'web_app_set_background_color':
|
|
83
62
|
case 'web_app_set_header_color':
|
|
84
63
|
case 'web_app_trigger_haptic_feedback':
|
|
85
|
-
return
|
|
64
|
+
return versionLessOrEqual('6.1', paramOrVersion);
|
|
86
65
|
case 'web_app_open_popup':
|
|
87
|
-
return
|
|
66
|
+
return versionLessOrEqual('6.2', paramOrVersion);
|
|
88
67
|
case 'web_app_close_scan_qr_popup':
|
|
89
68
|
case 'web_app_open_scan_qr_popup':
|
|
90
69
|
case 'web_app_read_text_from_clipboard':
|
|
91
|
-
return
|
|
70
|
+
return versionLessOrEqual('6.4', paramOrVersion);
|
|
92
71
|
case 'web_app_switch_inline_query':
|
|
93
|
-
return
|
|
72
|
+
return versionLessOrEqual('6.7', paramOrVersion);
|
|
94
73
|
case 'web_app_invoke_custom_method':
|
|
95
74
|
case 'web_app_request_write_access':
|
|
96
75
|
case 'web_app_request_phone':
|
|
97
|
-
return
|
|
76
|
+
return versionLessOrEqual('6.9', paramOrVersion);
|
|
98
77
|
case 'web_app_setup_settings_button':
|
|
99
|
-
return
|
|
78
|
+
return versionLessOrEqual('6.10', paramOrVersion);
|
|
100
79
|
default:
|
|
101
80
|
return true;
|
|
102
81
|
}
|