@tma.js/sdk 0.13.0 → 0.13.2

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.
@@ -1,7 +0,0 @@
1
- import { type PostEvent } from '@tma.js/bridge';
2
- /**
3
- * Creates postEvent function.
4
- * @param checkCompat - should compatibility check be enabled.
5
- * @param version - platform version.
6
- */
7
- export declare function createPostEvent(checkCompat: boolean, version: string): PostEvent;
@@ -1,36 +0,0 @@
1
- import {
2
- supports,
3
- postEvent as defaultPostEvent,
4
- detectSupportParams,
5
- type PostEvent,
6
- } from '@tma.js/bridge';
7
- import { isRecord } from '@tma.js/utils';
8
-
9
- import { MethodNotSupportedError, ParameterUnsupportedError } from '../../errors/index.js';
10
-
11
- /**
12
- * Creates postEvent function.
13
- * @param checkCompat - should compatibility check be enabled.
14
- * @param version - platform version.
15
- */
16
- export function createPostEvent(checkCompat: boolean, version: string): PostEvent {
17
- return checkCompat
18
- ? (method: any, params: any) => {
19
- // Firstly, check if method itself is supported.
20
- if (!supports(method, version)) {
21
- throw new MethodNotSupportedError(method, version);
22
- }
23
-
24
- // Method could use parameters, which are supported only in specific versions of TWA.
25
- if (isRecord(params)) {
26
- detectSupportParams(method, params).forEach((param) => {
27
- if (!supports(method as any, param, version)) {
28
- throw new ParameterUnsupportedError(method, param, version);
29
- }
30
- });
31
- }
32
-
33
- return defaultPostEvent(method, params);
34
- }
35
- : defaultPostEvent;
36
- }