@tma.js/bridge 1.3.11 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tma.js/bridge",
3
- "version": "1.3.11",
3
+ "version": "1.4.0",
4
4
  "description": "Communication layer between Telegram and frontend applications.",
5
5
  "author": "Vladislav Kibenko <wolfram.deus@gmail.com>",
6
6
  "homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme",
@@ -41,7 +41,7 @@
41
41
  "@tma.js/colors": "0.0.5",
42
42
  "@tma.js/event-emitter": "0.1.0",
43
43
  "@tma.js/logger": "0.0.5",
44
- "@tma.js/parsing": "0.1.3",
44
+ "@tma.js/parsing": "1.0.0",
45
45
  "@tma.js/util-types": "0.0.3",
46
46
  "@tma.js/utils": "0.5.6"
47
47
  },
@@ -59,7 +59,6 @@
59
59
  "typecheck": "tsc --noEmit -p tsconfig.build.json",
60
60
  "build": "pnpm run build:default && pnpm run build:iife",
61
61
  "build:default": "vite build --config vite.config.ts",
62
- "build:iife": "vite build --config vite.iife.config.ts",
63
- "rollup": "pnpm run typecheck && pnpm run build"
62
+ "build:iife": "vite build --config vite.iife.config.ts"
64
63
  }
65
64
  }
@@ -0,0 +1,13 @@
1
+ import type { Version } from '@tma.js/utils';
2
+
3
+ import type { MethodName } from '../methods/index.js';
4
+
5
+ /**
6
+ * Error thrown in case, unsupported method was called.
7
+ */
8
+ export class MethodUnsupportedError extends Error {
9
+ constructor(method: MethodName, version: Version) {
10
+ super(`Method "${method}" is unsupported in the Mini Apps version ${version}.`);
11
+ Object.setPrototypeOf(this, MethodUnsupportedError.prototype);
12
+ }
13
+ }
@@ -0,0 +1,13 @@
1
+ import type { Version } from '@tma.js/utils';
2
+
3
+ import type { MethodName } from '../methods/index.js';
4
+
5
+ /**
6
+ * Error thrown in case, unsupported parameter was used.
7
+ */
8
+ export class ParameterUnsupportedError extends Error {
9
+ constructor(method: MethodName, param: string, version: Version) {
10
+ super(`Parameter "${param}" in method "${method}" is unsupported in the Mini Apps version ${version}.`);
11
+ Object.setPrototypeOf(this, ParameterUnsupportedError.prototype);
12
+ }
13
+ }
@@ -0,0 +1,2 @@
1
+ export * from './MethodUnsupportedError.js';
2
+ export * from './ParameterUnsupportedError.js';
@@ -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.
@@ -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, AnySubscribeListener,
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 = UtilEventName<Events>;
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.
@@ -4,7 +4,7 @@ import {
4
4
  boolean,
5
5
  json,
6
6
  rgb,
7
- createValueParserGen,
7
+ createValueParserGenerator,
8
8
  } from '@tma.js/parsing';
9
9
 
10
10
  import type {
@@ -22,22 +22,30 @@ function isNullOrUndefined(value: unknown): boolean {
22
22
  const rgbOptional = rgb().optional();
23
23
  const num = number();
24
24
 
25
- const windowWidthParser = createValueParserGen((value) => (value === null || value === undefined
26
- ? window.innerWidth
27
- : num.parse(value)));
25
+ const windowWidthParser = createValueParserGenerator(
26
+ (value) => (value === null || value === undefined
27
+ ? window.innerWidth
28
+ : num.parse(value)),
29
+ );
28
30
 
29
31
  /**
30
32
  * Parses incoming value as ThemeChangedPayload.
31
33
  */
32
34
  export const themeChangedPayload = json<ThemeChangedPayload>({
33
35
  theme_params: json({
36
+ accent_text_color: rgbOptional,
34
37
  bg_color: rgbOptional,
35
- text_color: rgbOptional,
36
- hint_color: rgbOptional,
37
- link_color: rgbOptional,
38
38
  button_color: rgbOptional,
39
39
  button_text_color: rgbOptional,
40
+ destructive_text_color: rgbOptional,
41
+ header_bg_color: rgbOptional,
42
+ hint_color: rgbOptional,
43
+ link_color: rgbOptional,
40
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,
41
49
  }),
42
50
  });
43
51
 
@@ -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
- bg_color?: RGB;
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
@@ -1,3 +1,4 @@
1
+ export * from './errors/index.js';
1
2
  export * from './events/index.js';
2
3
  export * from './methods/index.js';
3
4
  export * from './env.js';
@@ -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
+ }
@@ -1,5 +1,6 @@
1
- export type * from './haptic.js';
2
- export type * from './invoke-custom-method.js';
3
- export type * from './params.js';
4
- export type * from './popup.js';
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
- type CreateParams<P = never, SupportCheckKey extends UnionKeys<P> = never> = {
20
- params: P;
21
- supportCheckKey: SupportCheckKey;
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 MethodsParams {
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 post-available event name.
333
+ * Any Telegram Mini Apps known method name.
323
334
  */
324
- export type MethodName = keyof MethodsParams;
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<E extends MethodName> = MethodsParams[E]['params'];
340
+ export type MethodParams<M extends MethodName> = Methods[M]['params'];
330
341
 
331
342
  /**
332
- * Returns true in case, method has parameters.
343
+ * True if specified method accepts parameters.
333
344
  */
334
- export type MethodHasParams<M extends MethodName> = Not<IsNever<MethodParams<M>>>;
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
- [E in MethodName]: IsNever<MethodParams<E>> extends true ? E : never;
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 = Exclude<MethodName, EmptyMethodName>;
358
+ export type NonEmptyMethodName = {
359
+ [M in MethodName]: MethodAcceptParams<M> extends true ? M : never;
360
+ }[MethodName];
347
361
 
348
362
  /**
349
- * Method names which could be used in supportsParam method.
363
+ * Method names which have versioned params.
350
364
  */
351
- export type HasCheckSupportMethodName = {
352
- [E in MethodName]: IsNever<MethodsParams[E]['supportCheckKey']> extends true ? never : E;
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 parameter which can be checked via support method.
370
+ * Method parameters which appear only in the specific Telegram Mini Apps version.
357
371
  */
358
- export type HasCheckSupportMethodParam<M extends HasCheckSupportMethodName> = MethodsParams[M]['supportCheckKey'];
372
+ export type MethodVersionedParams<M extends MethodWithVersionedParams> =
373
+ Methods[M]['versionedParams'];
@@ -3,14 +3,13 @@ import {
3
3
  hasExternalNotify,
4
4
  hasWebviewProxy,
5
5
  } from '../env.js';
6
- import { targetOrigin as globalTargetOrigin } from '../globals.js';
7
-
6
+ import { logger, targetOrigin as globalTargetOrigin } from '../globals.js';
8
7
  import type {
9
8
  EmptyMethodName,
10
9
  MethodName,
11
10
  MethodParams,
12
11
  NonEmptyMethodName,
13
- } from './params.js';
12
+ } from './methods.js';
14
13
 
15
14
  interface PostEventOptions {
16
15
  /**
@@ -30,8 +29,7 @@ export type PostEvent = typeof postEvent;
30
29
  * @param eventType - event name.
31
30
  * @param params - event parameters.
32
31
  * @param options - posting options.
33
- * @throws {Error} Bridge could not determine current
34
- * environment and possible way to send event.
32
+ * @throws {Error} Bridge could not determine current environment and possible way to send event.
35
33
  */
36
34
  export function postEvent<E extends NonEmptyMethodName>(
37
35
  eventType: E,
@@ -44,8 +42,7 @@ export function postEvent<E extends NonEmptyMethodName>(
44
42
  * accepts only events, which require arguments.
45
43
  * @param eventType - event name.
46
44
  * @param options - posting options.
47
- * @throws {Error} Bridge could not determine current
48
- * environment and possible way to send event.
45
+ * @throws {Error} Bridge could not determine current environment and possible way to send event.
49
46
  */
50
47
  export function postEvent(eventType: EmptyMethodName, options?: PostEventOptions): void;
51
48
 
@@ -74,6 +71,8 @@ export function postEvent(
74
71
  }
75
72
  const { targetOrigin = globalTargetOrigin() } = postOptions;
76
73
 
74
+ logger.log(`Calling method "${eventType}"`, eventData);
75
+
77
76
  // Telegram Web.
78
77
  if (isIframe()) {
79
78
  window.parent.postMessage(JSON.stringify({
@@ -95,8 +94,7 @@ export function postEvent(
95
94
  return;
96
95
  }
97
96
 
98
- // Otherwise current environment is unknown, and we are not able to send
99
- // event.
97
+ // Otherwise current environment is unknown, and we are not able to send event.
100
98
  throw new Error(
101
99
  'Unable to determine current environment and possible way to send event.',
102
100
  );
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, MethodHasParams,
8
+ EmptyMethodName,
9
+ MethodAcceptParams,
10
10
  MethodName,
11
11
  MethodParams,
12
12
  NonEmptyMethodName,
13
- } from './methods/params.js';
13
+ } from './methods/methods.js';
14
14
 
15
15
  /**
16
16
  * Names of methods, which require passing "req_id" parameter.
17
17
  */
18
- type MethodNameWithRequestId = {
19
- [Method in MethodName]: If<
20
- And<MethodHasParams<Method>, MethodParams<Method> extends { req_id: string } ? true : false>,
21
- Method,
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 EventNameWithRequestId = {
30
- [Event in EventName]: If<
31
- And<EventHasParams<Event>, EventParams<Event> extends { req_id: string } ? true : false>,
32
- Event,
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
- Method extends MethodNameWithRequestId,
69
- Event extends EventNameWithRequestId,
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<Event>>;
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<Method extends EmptyMethodName, Event extends EventName>(
85
- method: Method,
86
- event: Event | Event[],
87
- options?: RequestOptionsAdvanced<EventParams<Event>>,
88
- ): Promise<EventParams<Event>>;
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<Method extends NonEmptyMethodName, Event extends EventName>(
99
- method: Method,
100
- params: MethodParams<Method>,
101
- event: Event | Event[],
102
- options?: RequestOptionsAdvanced<EventParams<Event>>,
103
- ): Promise<EventParams<Event>>;
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
- HasCheckSupportMethodParam,
5
- HasCheckSupportMethodName,
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
- * By specified method and parameters extracts properties which could be used by
17
- * supports function as TWA method parameter.
18
- * @param method - TWA method.
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
- export function detectSupportParams<M extends NonEmptyMethodName>(
22
- method: M,
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 HasCheckSupportMethodName>(
24
+ export function supports<M extends MethodWithVersionedParams>(
47
25
  method: M,
48
- param: HasCheckSupportMethodParam<M>,
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 lessOrEqual('6.4', inVersion);
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 lessOrEqual('6.9', inVersion);
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 lessOrEqual('6.1', paramOrVersion);
64
+ return versionLessOrEqual('6.1', paramOrVersion);
86
65
  case 'web_app_open_popup':
87
- return lessOrEqual('6.2', paramOrVersion);
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 lessOrEqual('6.4', paramOrVersion);
70
+ return versionLessOrEqual('6.4', paramOrVersion);
92
71
  case 'web_app_switch_inline_query':
93
- return lessOrEqual('6.7', paramOrVersion);
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 lessOrEqual('6.9', paramOrVersion);
76
+ return versionLessOrEqual('6.9', paramOrVersion);
98
77
  case 'web_app_setup_settings_button':
99
- return lessOrEqual('6.10', paramOrVersion);
78
+ return versionLessOrEqual('6.10', paramOrVersion);
100
79
  default:
101
80
  return true;
102
81
  }