@tma.js/bridge 1.4.1 → 2.0.1

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.
Files changed (108) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +44 -13
  3. package/dist/dts/applyPolyfills.d.ts +5 -0
  4. package/dist/dts/base64-url.d.ts +24 -0
  5. package/dist/dts/env/hasWebviewProxy.d.ts +10 -0
  6. package/dist/dts/env/isIframe.d.ts +5 -0
  7. package/dist/dts/env/isTMA.d.ts +31 -0
  8. package/dist/dts/env/mockTelegramEnv.d.ts +57 -0
  9. package/dist/dts/errors.d.ts +27 -0
  10. package/dist/dts/events/createEmitter.d.ts +58 -0
  11. package/dist/dts/events/emitEvent.d.ts +33 -0
  12. package/dist/dts/events/emitter.d.ts +2 -11
  13. package/dist/dts/events/types/events.d.ts +721 -0
  14. package/dist/dts/events/types/index.d.ts +3 -0
  15. package/dist/dts/events/types/listening.d.ts +5 -0
  16. package/dist/dts/events/types/misc.d.ts +16 -0
  17. package/dist/dts/globals.d.ts +45 -14
  18. package/dist/dts/index.d.ts +24 -7
  19. package/dist/dts/launch-params.d.ts +32 -0
  20. package/dist/dts/methods/captureSameReq.d.ts +10 -0
  21. package/dist/dts/methods/createPostEvent.d.ts +27 -7
  22. package/dist/dts/methods/postEvent.d.ts +31 -25
  23. package/dist/dts/methods/postMessage.d.ts +7 -0
  24. package/dist/dts/methods/supports.d.ts +15 -0
  25. package/dist/dts/methods/types/custom-method.d.ts +59 -0
  26. package/dist/dts/methods/types/index.d.ts +6 -0
  27. package/dist/dts/methods/types/methods.d.ts +756 -0
  28. package/dist/dts/methods/types/misc.d.ts +27 -0
  29. package/dist/dts/methods/{popup.d.ts → types/popup.d.ts} +1 -1
  30. package/dist/dts/methods/types/utils.d.ts +9 -0
  31. package/dist/dts/obj-prop-helpers.d.ts +39 -0
  32. package/dist/dts/start-param.d.ts +53 -0
  33. package/dist/dts/utils/compareVersions.d.ts +10 -0
  34. package/dist/dts/utils/invokeCustomMethod.d.ts +34 -0
  35. package/dist/dts/utils/request.d.ts +90 -0
  36. package/dist/index.cjs +3 -1
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.iife.js +3 -1
  39. package/dist/index.iife.js.map +1 -1
  40. package/dist/index.js +977 -0
  41. package/dist/index.js.map +1 -0
  42. package/package.json +26 -26
  43. package/dist/dts/env.d.ts +0 -29
  44. package/dist/dts/errors/MethodUnsupportedError.d.ts +0 -8
  45. package/dist/dts/errors/ParameterUnsupportedError.d.ts +0 -8
  46. package/dist/dts/errors/index.d.ts +0 -2
  47. package/dist/dts/events/events.d.ts +0 -130
  48. package/dist/dts/events/index.d.ts +0 -7
  49. package/dist/dts/events/off.d.ts +0 -7
  50. package/dist/dts/events/on.d.ts +0 -10
  51. package/dist/dts/events/onTelegramEvent.d.ts +0 -7
  52. package/dist/dts/events/once.d.ts +0 -9
  53. package/dist/dts/events/parsers/clipboardTextReceived.d.ts +0 -13
  54. package/dist/dts/events/parsers/customMethodInvoked.d.ts +0 -16
  55. package/dist/dts/events/parsers/index.d.ts +0 -9
  56. package/dist/dts/events/parsers/invoiceClosed.d.ts +0 -12
  57. package/dist/dts/events/parsers/phoneRequested.d.ts +0 -8
  58. package/dist/dts/events/parsers/popupClosed.d.ts +0 -8
  59. package/dist/dts/events/parsers/qrTextReceived.d.ts +0 -7
  60. package/dist/dts/events/parsers/theme-changed.d.ts +0 -42
  61. package/dist/dts/events/parsers/viewportChanged.d.ts +0 -19
  62. package/dist/dts/events/parsers/writeAccessRequested.d.ts +0 -8
  63. package/dist/dts/events/subscribe.d.ts +0 -9
  64. package/dist/dts/events/unsubscribe.d.ts +0 -6
  65. package/dist/dts/methods/index.d.ts +0 -6
  66. package/dist/dts/methods/invoke-custom-method.d.ts +0 -24
  67. package/dist/dts/methods/methods.d.ts +0 -330
  68. package/dist/dts/request.d.ts +0 -66
  69. package/dist/dts/shared.d.ts +0 -5
  70. package/dist/dts/supports.d.ts +0 -15
  71. package/dist/index.mjs +0 -317
  72. package/dist/index.mjs.map +0 -1
  73. package/src/env.ts +0 -49
  74. package/src/errors/MethodUnsupportedError.ts +0 -13
  75. package/src/errors/ParameterUnsupportedError.ts +0 -13
  76. package/src/errors/index.ts +0 -2
  77. package/src/events/emitter.ts +0 -126
  78. package/src/events/events.ts +0 -169
  79. package/src/events/index.ts +0 -7
  80. package/src/events/off.ts +0 -12
  81. package/src/events/on.ts +0 -17
  82. package/src/events/onTelegramEvent.ts +0 -83
  83. package/src/events/once.ts +0 -16
  84. package/src/events/parsers/clipboardTextReceived.ts +0 -27
  85. package/src/events/parsers/customMethodInvoked.ts +0 -26
  86. package/src/events/parsers/index.ts +0 -9
  87. package/src/events/parsers/invoiceClosed.ts +0 -26
  88. package/src/events/parsers/phoneRequested.ts +0 -14
  89. package/src/events/parsers/popupClosed.ts +0 -19
  90. package/src/events/parsers/qrTextReceived.ts +0 -14
  91. package/src/events/parsers/theme-changed.ts +0 -58
  92. package/src/events/parsers/viewportChanged.ts +0 -33
  93. package/src/events/parsers/writeAccessRequested.ts +0 -14
  94. package/src/events/subscribe.ts +0 -16
  95. package/src/events/unsubscribe.ts +0 -11
  96. package/src/globals.ts +0 -38
  97. package/src/index.ts +0 -7
  98. package/src/methods/createPostEvent.ts +0 -39
  99. package/src/methods/haptic.ts +0 -52
  100. package/src/methods/index.ts +0 -6
  101. package/src/methods/invoke-custom-method.ts +0 -25
  102. package/src/methods/methods.ts +0 -373
  103. package/src/methods/popup.ts +0 -53
  104. package/src/methods/postEvent.ts +0 -101
  105. package/src/request.ts +0 -168
  106. package/src/shared.ts +0 -5
  107. package/src/supports.ts +0 -82
  108. /package/dist/dts/methods/{haptic.d.ts → types/haptic-feedback.d.ts} +0 -0
@@ -0,0 +1,3 @@
1
+ export type * from './events.js';
2
+ export type * from './listening.js';
3
+ export type * from './misc.js';
@@ -0,0 +1,5 @@
1
+ import { Handler } from 'mitt';
2
+ import { WildcardHandler } from '../createEmitter.js';
3
+ import { EventName, EventPayload, Events } from './index.js';
4
+ export type EventListener<E extends EventName> = Handler<EventPayload<E>>;
5
+ export type SubscribeListener = WildcardHandler<Events>;
@@ -0,0 +1,16 @@
1
+ export type InvoiceStatus = 'paid' | 'failed' | 'pending' | 'cancelled' | string;
2
+ export type PhoneRequestedStatus = 'sent' | 'cancelled' | string;
3
+ export type EmojiStatusAccessRequestedStatus = 'allowed' | string;
4
+ export type EmojiStatusFailedError = 'SUGGESTED_EMOJI_INVALID' | 'USER_DECLINED' | string;
5
+ export type WriteAccessRequestedStatus = 'allowed' | string;
6
+ export type BiometryType = 'finger' | 'face' | string;
7
+ export type BiometryTokenUpdateStatus = 'updated' | 'removed' | 'failed' | string;
8
+ export type BiometryAuthRequestStatus = 'failed' | 'authorized' | string;
9
+ export type FullScreenErrorStatus = 'ALREADY_FULLSCREEN' | 'UNSUPPORTED' | string;
10
+ export interface SafeAreaInsets {
11
+ top: number;
12
+ bottom: number;
13
+ left: number;
14
+ right: number;
15
+ }
16
+ export type HomeScreenStatus = 'unsupported' | 'unknown' | 'added' | 'missed' | string;
@@ -1,22 +1,53 @@
1
- import { Logger } from '@tma.js/logger';
2
- export declare const logger: Logger;
1
+ import { Logger } from '@tma.js/toolkit';
3
2
  /**
4
- * Sets new debug mode. Enabling debug mode leads to printing
5
- * additional messages in console, related to the processes
6
- * inside the package.
7
- * @param value - should debug mode be enabled.
3
+ * The current debug mode state.
4
+ *
5
+ * To update the value, use the `setDebug` function.
6
+ * @see setDebug
7
+ */
8
+ export declare const debug: import('@tma.js/signals').Computed<boolean>;
9
+ /**
10
+ * Sets the package debug mode.
11
+ *
12
+ * Enabling debug mode leads to printing additional messages in the console related to the
13
+ * processes inside the package.
14
+ * @param value - enable debug mode.
8
15
  */
9
16
  export declare function setDebug(value: boolean): void;
10
17
  /**
11
- * Sets new global targetOrigin, used by `postEvent` method.
12
- * Default value is "https://web.telegram.org". You don't need to
13
- * use this method until you know what you are doing.
18
+ * The current target origin used by the `postEvent` method.
19
+ *
20
+ * You don't need to override this value until you know what you are doing.
21
+ * To update the value, use the `setTargetOrigin` function.
22
+ * @default 'https://web.telegram.org'
23
+ * @see setTargetOrigin
24
+ */
25
+ export declare const targetOrigin: import('@tma.js/signals').Computed<string>;
26
+ /**
27
+ * Sets a new target origin that is being used when calling the `postEvent` function in Telegram
28
+ * web versions.
29
+ *
30
+ * You don't need to override this value until you know what you are doing.
31
+ * @param origin - allowed target origin value.
32
+ * @see _targetOrigin
33
+ */
34
+ export declare function setTargetOrigin(origin: string): void;
35
+ /**
36
+ * Signal containing a custom implementation of the method to post a message to the parent
37
+ * window. We usually use it to send a message in web versions of Telegram.
14
38
  *
15
- * This method could be used for test purposes.
16
- * @param value - new target origin.
39
+ * @default A function behaving like the `window.parent.postMessage` method.
40
+ */
41
+ export declare const postMessageImpl: import('@tma.js/signals').Signal<{
42
+ (message: any, targetOrigin: string, transfer?: Transferable[]): void;
43
+ (message: any, options?: WindowPostMessageOptions): void;
44
+ }>;
45
+ /**
46
+ * The package logger. You can override this value in order to use your own implementation.
17
47
  */
18
- export declare function setTargetOrigin(value: string): void;
48
+ export declare const logger: import('@tma.js/signals').Signal<Logger>;
19
49
  /**
20
- * Returns current global target origin.
50
+ * Resets the package global values. Normally, you don't use this function in your application.
51
+ * We are using it only for test purposes.
21
52
  */
22
- export declare function targetOrigin(): string;
53
+ export declare function resetGlobals(): void;
@@ -1,7 +1,24 @@
1
- export * from './errors/index.js';
2
- export * from './events/index.js';
3
- export * from './methods/index.js';
4
- export * from './env.js';
5
- export { setDebug, setTargetOrigin } from './globals.js';
6
- export * from './request.js';
7
- export * from './supports.js';
1
+ export { hasWebviewProxy } from './env/hasWebviewProxy.js';
2
+ export { isIframe } from './env/isIframe.js';
3
+ export { isTMA, isTMAFp, type isTMAError } from './env/isTMA.js';
4
+ export { mockTelegramEnv } from './env/mockTelegramEnv.js';
5
+ export { emitEvent } from './events/emitEvent.js';
6
+ export { off, offAll, on } from './events/emitter.js';
7
+ export type { EventListener, SubscribeListener, Events, WriteAccessRequestedStatus, EmojiStatusAccessRequestedStatus, BiometryAuthRequestStatus, BiometryTokenUpdateStatus, BiometryType, EmojiStatusFailedError, EventName, EventPayload, EventWithoutPayload, EventWithPayload, PhoneRequestedStatus, FullScreenErrorStatus, HomeScreenStatus, InvoiceStatus, SafeAreaInsets, } from './events/types/index.js';
8
+ export { captureSameReq } from './methods/captureSameReq.js';
9
+ export { createPostEvent, type CreatePostEventMode, type OnUnsupportedFn, } from './methods/createPostEvent.js';
10
+ export { postEvent, postEventFp, type PostEventFn, type PostEventFpFn, type PostEventError, } from './methods/postEvent.js';
11
+ export { postMessage, type PostMessage } from './methods/postMessage.js';
12
+ export { supports } from './methods/supports.js';
13
+ export type { AnyHapticFeedbackParams, AnyInvokeCustomMethodParams, CreateMethodParams, CustomMethodName, ImpactHapticFeedbackParams, ImpactHapticFeedbackStyle, CustomMethodsParams, CustomMethodParams, MethodName, MethodVersionedParams, NotificationHapticFeedbackParams, NotificationHapticFeedbackType, Methods, SelectionHapticFeedbackParams, MethodNameWithOptionalParams, MethodNameWithoutParams, MethodNameWithRequiredParams, MethodNameWithVersionedParams, MethodParams, PopupParams, BackgroundColor, BottomBarColor, HeaderColorKey, PopupButton, OpenLinkBrowser, SecondaryButtonPosition, SwitchInlineQueryChatType, } from './methods/types/index.js';
14
+ export { compareVersions } from './utils/compareVersions.js';
15
+ export { invokeCustomMethod, invokeCustomMethodFp, type InvokeCustomMethodFn, type InvokeCustomMethodOptions, type InvokeCustomMethodFpFn, type InvokeCustomMethodError, type InvokeCustomMethodFpOptions, } from './utils/invokeCustomMethod.js';
16
+ export { request, requestFp, type RequestCaptureEventFn, type RequestCaptureEventsFn, type RequestCaptureFn, type RequestCaptureFnEventsPayload, type RequestFn, type RequestOptions, type RequestResult, type RequestError, type RequestFpOptions, type RequestFpFn, } from './utils/request.js';
17
+ export { applyPolyfills } from './applyPolyfills.js';
18
+ export { decodeBase64Url, encodeBase64Url, decodeBase64UrlFp, type DecodeBase64UrlError, } from './base64-url.js';
19
+ export { LaunchParamsRetrieveError, InvalidLaunchParamsError, InvokeCustomMethodFailedError, MethodParameterUnsupportedError, MethodUnsupportedError, UnknownEnvError, } from './errors.js';
20
+ export { setDebug, debug, resetGlobals, postMessageImpl, logger, setTargetOrigin, targetOrigin, } from './globals.js';
21
+ export { retrieveLaunchParams, retrieveRawInitData, retrieveRawInitDataFp, retrieveRawLaunchParams, retrieveRawLaunchParamsFp, retrieveLaunchParamsFp, type RetrieveLaunchParamsError, type RetrieveLaunchParamsResult, type RetrieveRawInitDataError, type RetrieveRawLaunchParamsError, } from './launch-params.js';
22
+ export { createStartParam, createStartParamFp, decodeStartParam, decodeStartParamFp, isSafeToCreateStartParam, } from './start-param.js';
23
+ export { createLogger, deepSnakeToCamelObjKeys, type Logger, type LoggerFn, type LoggerForceFn, type LoggerOptions, type LogLevel, } from '@tma.js/toolkit';
24
+ export { CancelledError, TimeoutError, } from 'better-promises';
@@ -0,0 +1,32 @@
1
+ import { LaunchParamsGenType, ParseLaunchParamsQueryError } from '@tma.js/transformers';
2
+ import { LaunchParamsRetrieveError } from './errors.js';
3
+ import * as E from 'fp-ts/Either';
4
+ import * as O from 'fp-ts/Option';
5
+ export type RetrieveRawInitDataError = RetrieveRawLaunchParamsError;
6
+ export type RetrieveRawLaunchParamsError = LaunchParamsRetrieveError;
7
+ export type RetrieveLaunchParamsError = RetrieveRawLaunchParamsError | ParseLaunchParamsQueryError;
8
+ export type RetrieveLaunchParamsResult = LaunchParamsGenType;
9
+ /**
10
+ * @returns Launch parameters from any known source.
11
+ */
12
+ export declare const retrieveLaunchParamsFp: () => E.Either<RetrieveLaunchParamsError, RetrieveLaunchParamsResult>;
13
+ /**
14
+ * @see retrieveLaunchParamsFp
15
+ */
16
+ export declare const retrieveLaunchParams: () => RetrieveLaunchParamsResult;
17
+ /**
18
+ * @returns Raw init data from any known source.
19
+ */
20
+ export declare const retrieveRawInitDataFp: () => E.Either<RetrieveRawInitDataError, O.Option<string>>;
21
+ /**
22
+ * @see retrieveRawInitDataFp
23
+ */
24
+ export declare const retrieveRawInitData: () => string | undefined;
25
+ /**
26
+ * @returns Launch parameters in a raw format from any known source.
27
+ */
28
+ export declare function retrieveRawLaunchParamsFp(): E.Either<RetrieveRawLaunchParamsError, string>;
29
+ /**
30
+ * @see retrieveRawLaunchParamsFp
31
+ */
32
+ export declare const retrieveRawLaunchParams: () => string;
@@ -0,0 +1,10 @@
1
+ type CaptureSameReqFn = (payload: {
2
+ req_id: string;
3
+ }) => boolean;
4
+ /**
5
+ * Returns a function which can be used in `request` function `capture` property to capture
6
+ * the event with the same request identifier.
7
+ * @param reqId - request identifier.
8
+ */
9
+ export declare function captureSameReq(reqId: string): CaptureSameReqFn;
10
+ export {};
@@ -1,10 +1,30 @@
1
- import { type Version } from '@tma.js/utils';
2
- import { type PostEvent } from './index.js';
1
+ import { Version } from '@tma.js/types';
2
+ import { PostEventFn } from './postEvent.js';
3
+ import { MethodName, MethodNameWithVersionedParams, MethodVersionedParams } from './types/index.js';
4
+ export type OnUnsupportedFn = (data: {
5
+ version: Version;
6
+ } & ({
7
+ method: MethodName;
8
+ } | {
9
+ [M in MethodNameWithVersionedParams]: {
10
+ method: M;
11
+ param: MethodVersionedParams<M>;
12
+ };
13
+ }[MethodNameWithVersionedParams])) => void;
14
+ export type CreatePostEventMode = 'strict' | 'non-strict';
3
15
  /**
4
- * Creates function which checks if specified method and parameters are supported. In case,
5
- * method or parameters are unsupported, an error will be thrown.
16
+ * Creates a function that checks if the specified method and parameters are supported.
17
+ *
18
+ * If the method or parameters are unsupported, the `onUnsupported` function will be called.
19
+ *
20
+ * If `strict` or `non-strict` value was passed as the second argument, the function
21
+ * will create its own `onUnsupported` function with behavior depending on the value passed.
22
+ *
23
+ * - Passing `strict` will make the function to throw a `MethodParameterUnsupportedError`
24
+ * or a `MethodUnsupportedError` error.
25
+ * - Passing `non-strict` will just warn you about something being unsupported.
26
+ *
6
27
  * @param version - Telegram Mini Apps version.
7
- * @throws {MethodUnsupportedError} Method is unsupported.
8
- * @throws {ParameterUnsupportedError} Method parameter is unsupported.
28
+ * @param onUnsupportedOrMode - function or strict mode. Default: `strict`
9
29
  */
10
- export declare function createPostEvent(version: Version): PostEvent;
30
+ export declare function createPostEvent(version: Version, onUnsupportedOrMode?: OnUnsupportedFn | CreatePostEventMode): PostEventFn;
@@ -1,29 +1,35 @@
1
- import type { EmptyMethodName, MethodParams, NonEmptyMethodName } from './methods.js';
2
- interface PostEventOptions {
3
- /**
4
- * Origin used while posting message. This option is only used in case,
5
- * current environment is browser (Web version of Telegram) and could
6
- * be used for test purposes.
7
- * @default 'https://web.telegram.org'
8
- */
9
- targetOrigin?: string;
10
- }
11
- export type PostEvent = typeof postEvent;
1
+ import { UnknownEnvError } from '../errors.js';
2
+ import { MethodNameWithOptionalParams, MethodNameWithoutParams, MethodNameWithRequiredParams, MethodParams } from './types/index.js';
3
+ import * as E from 'fp-ts/Either';
4
+ export type PostEventError = UnknownEnvError;
5
+ export type PostEventFn = typeof postEvent;
6
+ export type PostEventFpFn = typeof postEventFp;
12
7
  /**
13
- * Sends event to native application which launched Mini App. This function
14
- * accepts only events, which require arguments.
15
- * @param eventType - event name.
16
- * @param params - event parameters.
17
- * @param options - posting options.
18
- * @throws {Error} Bridge could not determine current environment and possible way to send event.
8
+ * @see postEventFp
19
9
  */
20
- export declare function postEvent<E extends NonEmptyMethodName>(eventType: E, params: MethodParams<E>, options?: PostEventOptions): void;
10
+ export declare function postEvent<Method extends MethodNameWithRequiredParams>(method: Method, params: MethodParams<Method>): void;
21
11
  /**
22
- * Sends event to native application which launched Mini App. This function
23
- * accepts only events, which require arguments.
24
- * @param eventType - event name.
25
- * @param options - posting options.
26
- * @throws {Error} Bridge could not determine current environment and possible way to send event.
12
+ * @see postEventFp
27
13
  */
28
- export declare function postEvent(eventType: EmptyMethodName, options?: PostEventOptions): void;
29
- export {};
14
+ export declare function postEvent(method: MethodNameWithoutParams): void;
15
+ /**
16
+ * @see postEventFp
17
+ */
18
+ export declare function postEvent<Method extends MethodNameWithOptionalParams>(method: Method, params?: MethodParams<Method>): void;
19
+ /**
20
+ * Calls Mini Apps methods requiring parameters.
21
+ * @param method - method name.
22
+ * @param params - options along with params.
23
+ */
24
+ export declare function postEventFp<Method extends MethodNameWithRequiredParams>(method: Method, params: MethodParams<Method>): E.Either<PostEventError, void>;
25
+ /**
26
+ * Calls Mini Apps methods accepting no parameters at all.
27
+ * @param method - method name.
28
+ */
29
+ export declare function postEventFp(method: MethodNameWithoutParams): E.Either<PostEventError, void>;
30
+ /**
31
+ * Calls Mini Apps methods accepting optional parameters.
32
+ * @param method - method name.
33
+ * @param params - options along with params.
34
+ */
35
+ export declare function postEventFp<Method extends MethodNameWithOptionalParams>(method: Method, params?: MethodParams<Method>): E.Either<PostEventError, void>;
@@ -0,0 +1,7 @@
1
+ export type PostMessage = typeof window.parent.postMessage;
2
+ /**
3
+ * Posts a message to the parent window. We usually use it to send a message in web versions of
4
+ * Telegram.
5
+ * @param args - `window.parent.postMessage` arguments.
6
+ */
7
+ export declare const postMessage: PostMessage;
@@ -0,0 +1,15 @@
1
+ import { Version } from '@tma.js/types';
2
+ import { MethodName, MethodNameWithVersionedParams, MethodVersionedParams } from './types/index.js';
3
+ /**
4
+ * Returns true in case, passed parameter in specified method is supported.
5
+ * @param method - method name
6
+ * @param param - method parameter
7
+ * @param inVersion - platform version.
8
+ */
9
+ export declare function supports<M extends MethodNameWithVersionedParams>(method: M, param: MethodVersionedParams<M>, inVersion: Version): boolean;
10
+ /**
11
+ * Returns true in case, specified method is supported in a passed version.
12
+ * @param method - method name.
13
+ * @param inVersion - platform version.
14
+ */
15
+ export declare function supports(method: MethodName, inVersion: Version): boolean;
@@ -0,0 +1,59 @@
1
+ interface CreateInvokeCustomMethodParams<M extends string, Params extends object> {
2
+ /**
3
+ * Unique request identifier.
4
+ */
5
+ req_id: string;
6
+ /**
7
+ * Method name.
8
+ */
9
+ method: M;
10
+ /**
11
+ * Method specific parameters.
12
+ */
13
+ params: Params;
14
+ }
15
+ export interface CustomMethodsParams {
16
+ /**
17
+ * Deletes storage values using their keys.
18
+ */
19
+ deleteStorageValues: {
20
+ keys: string | string[];
21
+ };
22
+ /**
23
+ * Returns the current server time.
24
+ */
25
+ getCurrentTime: {};
26
+ /**
27
+ * Gets the current user contact in case, the mini app has access to it.
28
+ */
29
+ getRequestedContact: {};
30
+ /**
31
+ * Gets all registered storage keys.
32
+ */
33
+ getStorageKeys: {};
34
+ /**
35
+ * Gets storage values using their keys.
36
+ */
37
+ getStorageValues: {
38
+ keys: string | string[];
39
+ };
40
+ /**
41
+ * Saves a value using specified key in the storage.
42
+ */
43
+ saveStorageValue: {
44
+ key: string;
45
+ value: string;
46
+ };
47
+ }
48
+ /**
49
+ * Known custom method name.
50
+ */
51
+ export type CustomMethodName = keyof CustomMethodsParams;
52
+ /**
53
+ * Custom method parameters.
54
+ */
55
+ export type CustomMethodParams<M extends CustomMethodName> = CustomMethodsParams[M];
56
+ export type AnyInvokeCustomMethodParams = CreateInvokeCustomMethodParams<string, any> | {
57
+ [M in CustomMethodName]: CreateInvokeCustomMethodParams<M, CustomMethodParams<M>>;
58
+ }[CustomMethodName];
59
+ export {};
@@ -0,0 +1,6 @@
1
+ export type * from './custom-method.js';
2
+ export type * from './haptic-feedback.js';
3
+ export type * from './methods.js';
4
+ export type * from './misc.js';
5
+ export type * from './popup.js';
6
+ export type { CreateMethodParams } from './utils.js';