@vbotma/sdk 3.1.8

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 (145) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +64 -0
  3. package/dist/dts/composables/AsyncMountable.d.ts +44 -0
  4. package/dist/dts/composables/Button.d.ts +140 -0
  5. package/dist/dts/composables/Mountable.d.ts +43 -0
  6. package/dist/dts/composables/Stateful.d.ts +35 -0
  7. package/dist/dts/errors.d.ts +51 -0
  8. package/dist/dts/features/BackButton/BackButton.d.ts +96 -0
  9. package/dist/dts/features/BackButton/exports.d.ts +2 -0
  10. package/dist/dts/features/BackButton/instance.d.ts +2 -0
  11. package/dist/dts/features/Biometry/Biometry.d.ts +121 -0
  12. package/dist/dts/features/Biometry/exports.d.ts +3 -0
  13. package/dist/dts/features/Biometry/instance.d.ts +2 -0
  14. package/dist/dts/features/Biometry/types.d.ts +84 -0
  15. package/dist/dts/features/ClosingBehavior/ClosingBehavior.d.ts +51 -0
  16. package/dist/dts/features/ClosingBehavior/exports.d.ts +2 -0
  17. package/dist/dts/features/ClosingBehavior/instance.d.ts +2 -0
  18. package/dist/dts/features/CloudStorage/CloudStorage.d.ts +90 -0
  19. package/dist/dts/features/CloudStorage/exports.d.ts +2 -0
  20. package/dist/dts/features/CloudStorage/instance.d.ts +2 -0
  21. package/dist/dts/features/DeviceStorage/DeviceStorage.d.ts +53 -0
  22. package/dist/dts/features/DeviceStorage/exports.d.ts +2 -0
  23. package/dist/dts/features/DeviceStorage/instance.d.ts +2 -0
  24. package/dist/dts/features/HapticFeedback/HapticFeedback.d.ts +57 -0
  25. package/dist/dts/features/HapticFeedback/exports.d.ts +2 -0
  26. package/dist/dts/features/HapticFeedback/instance.d.ts +2 -0
  27. package/dist/dts/features/InitData/InitData.d.ts +87 -0
  28. package/dist/dts/features/InitData/exports.d.ts +2 -0
  29. package/dist/dts/features/InitData/instance.d.ts +2 -0
  30. package/dist/dts/features/Invoice/Invoice.d.ts +54 -0
  31. package/dist/dts/features/Invoice/exports.d.ts +2 -0
  32. package/dist/dts/features/Invoice/instance.d.ts +2 -0
  33. package/dist/dts/features/LocationManager/LocationManager.d.ts +73 -0
  34. package/dist/dts/features/LocationManager/exports.d.ts +3 -0
  35. package/dist/dts/features/LocationManager/instance.d.ts +2 -0
  36. package/dist/dts/features/LocationManager/types.d.ts +65 -0
  37. package/dist/dts/features/MainButton/MainButton.d.ts +214 -0
  38. package/dist/dts/features/MainButton/exports.d.ts +2 -0
  39. package/dist/dts/features/MainButton/instance.d.ts +2 -0
  40. package/dist/dts/features/MiniApp/MiniApp.d.ts +192 -0
  41. package/dist/dts/features/MiniApp/exports.d.ts +2 -0
  42. package/dist/dts/features/MiniApp/instance.d.ts +2 -0
  43. package/dist/dts/features/Notification/Notification.d.ts +21 -0
  44. package/dist/dts/features/Notification/exports.d.ts +3 -0
  45. package/dist/dts/features/Notification/instance.d.ts +2 -0
  46. package/dist/dts/features/Notification/types.d.ts +19 -0
  47. package/dist/dts/features/Popup/Popup.d.ts +56 -0
  48. package/dist/dts/features/Popup/exports.d.ts +3 -0
  49. package/dist/dts/features/Popup/instance.d.ts +2 -0
  50. package/dist/dts/features/Popup/prepareParams.d.ts +9 -0
  51. package/dist/dts/features/Popup/types.d.ts +54 -0
  52. package/dist/dts/features/QrScanner/QrScanner.d.ts +131 -0
  53. package/dist/dts/features/QrScanner/exports.d.ts +2 -0
  54. package/dist/dts/features/QrScanner/instance.d.ts +2 -0
  55. package/dist/dts/features/Refresh/Refresh.d.ts +39 -0
  56. package/dist/dts/features/Refresh/exports.d.ts +3 -0
  57. package/dist/dts/features/Refresh/instance.d.ts +2 -0
  58. package/dist/dts/features/Refresh/types.d.ts +7 -0
  59. package/dist/dts/features/SecondaryButton/SecondaryButton.d.ts +253 -0
  60. package/dist/dts/features/SecondaryButton/exports.d.ts +2 -0
  61. package/dist/dts/features/SecondaryButton/instance.d.ts +2 -0
  62. package/dist/dts/features/SecureStorage/SecureStorage.d.ts +68 -0
  63. package/dist/dts/features/SecureStorage/exports.d.ts +2 -0
  64. package/dist/dts/features/SecureStorage/instance.d.ts +2 -0
  65. package/dist/dts/features/SettingsButton/SettingsButton.d.ts +96 -0
  66. package/dist/dts/features/SettingsButton/exports.d.ts +2 -0
  67. package/dist/dts/features/SettingsButton/instance.d.ts +2 -0
  68. package/dist/dts/features/StoragePermission/StoragePermission.d.ts +45 -0
  69. package/dist/dts/features/StoragePermission/exports.d.ts +3 -0
  70. package/dist/dts/features/StoragePermission/instance.d.ts +2 -0
  71. package/dist/dts/features/StoragePermission/types.d.ts +51 -0
  72. package/dist/dts/features/SwipeBehavior/SwipeBehavior.d.ts +62 -0
  73. package/dist/dts/features/SwipeBehavior/exports.d.ts +2 -0
  74. package/dist/dts/features/SwipeBehavior/instance.d.ts +2 -0
  75. package/dist/dts/features/ThemeParams/ThemeParams.d.ts +127 -0
  76. package/dist/dts/features/ThemeParams/exports.d.ts +2 -0
  77. package/dist/dts/features/ThemeParams/instance.d.ts +2 -0
  78. package/dist/dts/features/Viewport/Viewport.d.ts +219 -0
  79. package/dist/dts/features/Viewport/exports.d.ts +2 -0
  80. package/dist/dts/features/Viewport/instance.d.ts +2 -0
  81. package/dist/dts/features/emoji-status/exports.d.ts +2 -0
  82. package/dist/dts/features/emoji-status/requestEmojiStatusAccess.d.ts +16 -0
  83. package/dist/dts/features/emoji-status/setEmojiStatus.d.ts +28 -0
  84. package/dist/dts/features/home-screen/addToHomeScreen.d.ts +11 -0
  85. package/dist/dts/features/home-screen/checkHomeScreenStatus.d.ts +14 -0
  86. package/dist/dts/features/home-screen/exports.d.ts +2 -0
  87. package/dist/dts/features/links/exports.d.ts +3 -0
  88. package/dist/dts/features/links/openLink.d.ts +31 -0
  89. package/dist/dts/features/links/openTelegramLink.d.ts +18 -0
  90. package/dist/dts/features/links/shareURL.d.ts +18 -0
  91. package/dist/dts/features/privacy/exports.d.ts +3 -0
  92. package/dist/dts/features/privacy/requestContact.d.ts +59 -0
  93. package/dist/dts/features/privacy/requestPhoneAccess.d.ts +19 -0
  94. package/dist/dts/features/privacy/requestWriteAccess.d.ts +14 -0
  95. package/dist/dts/features/uncategorized/copyTextToClipboard.d.ts +5 -0
  96. package/dist/dts/features/uncategorized/downloadFile.d.ts +21 -0
  97. package/dist/dts/features/uncategorized/exports.d.ts +11 -0
  98. package/dist/dts/features/uncategorized/getCurrentTime.d.ts +15 -0
  99. package/dist/dts/features/uncategorized/hideKeyboard.d.ts +13 -0
  100. package/dist/dts/features/uncategorized/readTextFromClipboard.d.ts +13 -0
  101. package/dist/dts/features/uncategorized/retrieveAndroidDeviceData.d.ts +6 -0
  102. package/dist/dts/features/uncategorized/retrieveAndroidDeviceDataFrom.d.ts +14 -0
  103. package/dist/dts/features/uncategorized/sendData.d.ts +20 -0
  104. package/dist/dts/features/uncategorized/shareMessage.d.ts +14 -0
  105. package/dist/dts/features/uncategorized/shareStory.d.ts +50 -0
  106. package/dist/dts/features/uncategorized/switchInlineQuery.d.ts +28 -0
  107. package/dist/dts/fn-options/bottomButtonOptions.d.ts +11 -0
  108. package/dist/dts/fn-options/buttonOptions.d.ts +10 -0
  109. package/dist/dts/fn-options/createFnOption.d.ts +2 -0
  110. package/dist/dts/fn-options/sharedFeatureOptions.d.ts +8 -0
  111. package/dist/dts/fn-options/withCreateRequestId.d.ts +7 -0
  112. package/dist/dts/fn-options/withInvokeCustomMethod.d.ts +11 -0
  113. package/dist/dts/fn-options/withPostEvent.d.ts +8 -0
  114. package/dist/dts/fn-options/withRequest.d.ts +8 -0
  115. package/dist/dts/fn-options/withStateRestore.d.ts +13 -0
  116. package/dist/dts/fn-options/withVersion.d.ts +9 -0
  117. package/dist/dts/globals/createRequestId.d.ts +4 -0
  118. package/dist/dts/globals/invokeCustomMethod.d.ts +16 -0
  119. package/dist/dts/globals/isInlineMode.d.ts +4 -0
  120. package/dist/dts/globals/postEvent.d.ts +4 -0
  121. package/dist/dts/globals/request.d.ts +13 -0
  122. package/dist/dts/globals/resetGlobals.d.ts +4 -0
  123. package/dist/dts/globals/signals-registry.d.ts +39 -0
  124. package/dist/dts/globals/themeParams.d.ts +4 -0
  125. package/dist/dts/globals/version.d.ts +4 -0
  126. package/dist/dts/helpers/access.d.ts +2 -0
  127. package/dist/dts/helpers/component-storage.d.ts +9 -0
  128. package/dist/dts/helpers/createIsSupportedSignal.d.ts +5 -0
  129. package/dist/dts/helpers/css-vars.d.ts +11 -0
  130. package/dist/dts/helpers/isColorDark.d.ts +11 -0
  131. package/dist/dts/helpers/navigation.d.ts +5 -0
  132. package/dist/dts/helpers/removeUndefined.d.ts +10 -0
  133. package/dist/dts/helpers/shallowEqual.d.ts +1 -0
  134. package/dist/dts/index.d.ts +38 -0
  135. package/dist/dts/init.d.ts +42 -0
  136. package/dist/dts/types.d.ts +6 -0
  137. package/dist/dts/with-checks/throwifyWithChecksFp.d.ts +3 -0
  138. package/dist/dts/with-checks/withChecksFp.d.ts +170 -0
  139. package/dist/index.cjs +2 -0
  140. package/dist/index.cjs.map +1 -0
  141. package/dist/index.iife.js +4 -0
  142. package/dist/index.iife.js.map +1 -0
  143. package/dist/index.js +4088 -0
  144. package/dist/index.js.map +1 -0
  145. package/package.json +54 -0
@@ -0,0 +1,59 @@
1
+ import { BetterTaskEitherError } from '@vbotma/toolkit';
2
+ import { taskEither as TE } from 'fp-ts';
3
+ import { AccessDeniedError, ValidationError } from '../../errors.js';
4
+ import { InvokeCustomMethodError } from '../../fn-options/withInvokeCustomMethod.js';
5
+ import { AsyncOptions } from '../../types.js';
6
+ /**
7
+ * Requested contact information.
8
+ */
9
+ export interface RequestedContact {
10
+ contact: {
11
+ user_id: number;
12
+ phone_number: string;
13
+ first_name: string;
14
+ last_name?: string;
15
+ [key: string]: unknown;
16
+ };
17
+ auth_date: Date;
18
+ hash: string;
19
+ [key: string]: unknown;
20
+ }
21
+ /**
22
+ * Requested contact complete data.
23
+ */
24
+ export interface RequestedContactCompleteData {
25
+ /**
26
+ * Raw original representation of the contact data returned from the Telegram server.
27
+ */
28
+ raw: string;
29
+ /**
30
+ * Parsed representation of the contact data.
31
+ */
32
+ parsed: RequestedContact;
33
+ }
34
+ export type RequestContactError = InvokeCustomMethodError | AccessDeniedError | ValidationError | BetterTaskEitherError;
35
+ /**
36
+ * Requests current user contact information.
37
+ *
38
+ * This function returns an object, containing both raw and parsed representations of a response,
39
+ * received from the VBot client.
40
+ * @param options - additional options.
41
+ * @since Mini Apps v6.9
42
+ */
43
+ export declare const requestContactCompleteFp: import('../../with-checks/withChecksFp.js').WithChecksFp<(options?: AsyncOptions) => TE.TaskEither<RequestContactError, RequestedContactCompleteData>, true, never>;
44
+ /**
45
+ * @see requestContactCompleteFp
46
+ */
47
+ export declare const requestContactComplete: import('../../with-checks/withChecksFp.js').WithChecks<(options?: AsyncOptions) => TE.TaskEither<RequestContactError, RequestedContactCompleteData>, true, never>;
48
+ /**
49
+ * Works the same way as the `requestContactCompleteFp` function, but returns only parsed
50
+ * representation of the contact data.
51
+ * @see requestContactCompleteFp
52
+ * @param options - additional options.
53
+ * @since Mini Apps v6.9
54
+ */
55
+ export declare const requestContactFp: import('../../with-checks/withChecksFp.js').WithChecksFp<(options?: AsyncOptions) => TE.TaskEither<RequestContactError, RequestedContact>, true, never>;
56
+ /**
57
+ * @see requestContactFp
58
+ */
59
+ export declare const requestContact: import('../../with-checks/withChecksFp.js').WithChecks<(options?: AsyncOptions) => TE.TaskEither<RequestContactError, RequestedContact>, true, never>;
@@ -0,0 +1,19 @@
1
+ import { PhoneRequestedStatus, RequestError } from '@vbotma/bridge';
2
+ import { taskEither as TE } from 'fp-ts';
3
+ import { AsyncOptions } from '../../types.js';
4
+ export type RequestPhoneAccessError = RequestError;
5
+ /**
6
+ * Requests current user phone access. Method returns promise, which resolves
7
+ * status of the request. In case, user accepted the request, Mini App bot will receive
8
+ * the according notification.
9
+ *
10
+ * To obtain the retrieved information instead, utilize the `requestContact` method.
11
+ * @param options - additional options.
12
+ * @since Mini Apps v6.9
13
+ * @see requestContact
14
+ */
15
+ export declare const requestPhoneAccessFp: import('../../with-checks/withChecksFp.js').WithChecksFp<(options?: AsyncOptions) => TE.TaskEither<RequestPhoneAccessError, PhoneRequestedStatus>, true, never>;
16
+ /**
17
+ * @see requestPhoneAccessFp
18
+ */
19
+ export declare const requestPhoneAccess: import('../../with-checks/withChecksFp.js').WithChecks<(options?: AsyncOptions) => TE.TaskEither<RequestPhoneAccessError, PhoneRequestedStatus>, true, never>;
@@ -0,0 +1,14 @@
1
+ import { WriteAccessRequestedStatus, RequestError } from '@vbotma/bridge';
2
+ import { taskEither as TE } from 'fp-ts';
3
+ import { AsyncOptions } from '../../types.js';
4
+ export type RequestWriteAccessError = RequestError;
5
+ /**
6
+ * Requests write message access to the current user.
7
+ * @param options - additional options.
8
+ * @since Mini Apps v6.9
9
+ */
10
+ export declare const requestWriteAccessFp: import('../../with-checks/withChecksFp.js').WithChecksFp<(options?: AsyncOptions) => TE.TaskEither<RequestWriteAccessError, WriteAccessRequestedStatus>, true, never>;
11
+ /**
12
+ * @see requestWriteAccessFp
13
+ */
14
+ export declare const requestWriteAccess: import('../../with-checks/withChecksFp.js').WithChecks<(options?: AsyncOptions) => TE.TaskEither<RequestWriteAccessError, WriteAccessRequestedStatus>, true, never>;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Copies specified text to the clipboard.
3
+ * @param text - text to copy.
4
+ */
5
+ export declare function copyTextToClipboard(text: string): Promise<void>;
@@ -0,0 +1,21 @@
1
+ import { RequestError } from '@vbotma/bridge';
2
+ import { taskEither as TE } from 'fp-ts';
3
+ import { AccessDeniedError } from '../../errors.js';
4
+ import { AsyncOptions } from '../../types.js';
5
+ export type DownloadFileError = RequestError | AccessDeniedError;
6
+ /**
7
+ * Displays a native popup prompting the user to download a file.
8
+ * @param url - the HTTPS URL of the file to be downloaded.
9
+ * @param file - the suggested name for the downloaded file.
10
+ * @param options - additional request execution options.
11
+ * @since Mini Apps v8.0
12
+ * @example
13
+ * fn.pipe(
14
+ * downloadFileFp('https://telegram.org/js/telegram-web-app.js', 'telegram-sdk.js'),
15
+ * TE.map(() => {
16
+ * console.log('Downloading');
17
+ * })
18
+ * )
19
+ */
20
+ export declare const downloadFileFp: import('../../with-checks/withChecksFp.js').WithChecksFp<(url: string, fileName: string, options?: AsyncOptions) => TE.TaskEither<DownloadFileError, void>, true, never>;
21
+ export declare const downloadFile: import('../../with-checks/withChecksFp.js').WithChecks<(url: string, fileName: string, options?: AsyncOptions) => TE.TaskEither<DownloadFileError, void>, true, never>;
@@ -0,0 +1,11 @@
1
+ export { copyTextToClipboard } from './copyTextToClipboard.js';
2
+ export { downloadFile, type DownloadFileError, downloadFileFp } from './downloadFile.js';
3
+ export { getCurrentTime, type GetCurrentTimeError, getCurrentTimeFp } from './getCurrentTime.js';
4
+ export { hideKeyboard, hideKeyboardFp, type HideKeyboardError } from './hideKeyboard.js';
5
+ export { readTextFromClipboard, readTextFromClipboardFp, type ReadTextFromClipboardError, } from './readTextFromClipboard.js';
6
+ export { retrieveAndroidDeviceData } from './retrieveAndroidDeviceData.js';
7
+ export { retrieveAndroidDeviceDataFrom, type AndroidDeviceData, } from './retrieveAndroidDeviceDataFrom.js';
8
+ export { sendData, sendDataFp, type SendDataError } from './sendData.js';
9
+ export { shareMessage, shareMessageFp, type ShareMessageFnError } from './shareMessage.js';
10
+ export { shareStory, shareStoryFp, type ShareStoryOptions, type ShareStoryError, } from './shareStory.js';
11
+ export { switchInlineQuery, switchInlineQueryFp, type SwitchInlineQueryError, } from './switchInlineQuery.js';
@@ -0,0 +1,15 @@
1
+ import { taskEither as TE } from 'fp-ts';
2
+ import { ValidationError } from '../../errors.js';
3
+ import { InvokeCustomMethodError } from '../../fn-options/withInvokeCustomMethod.js';
4
+ import { AsyncOptions } from '../../types.js';
5
+ export type GetCurrentTimeError = InvokeCustomMethodError | ValidationError;
6
+ /**
7
+ * @returns The current time according to the Telegram server time.
8
+ * @param options - additional options.
9
+ * @since Mini Apps v6.9
10
+ */
11
+ export declare const getCurrentTimeFp: import('../../with-checks/withChecksFp.js').WithChecksFp<(options?: AsyncOptions) => TE.TaskEither<GetCurrentTimeError, Date>, true, never>;
12
+ /**
13
+ * @see getCurrentTimeFp
14
+ */
15
+ export declare const getCurrentTime: import('../../with-checks/withChecksFp.js').WithChecks<(options?: AsyncOptions) => TE.TaskEither<GetCurrentTimeError, Date>, true, never>;
@@ -0,0 +1,13 @@
1
+ import { PostEventError } from '@vbotma/bridge';
2
+ import { either as E } from 'fp-ts';
3
+ export type HideKeyboardError = PostEventError;
4
+ /**
5
+ * Hides the on-screen keyboard, if it is currently visible. Does nothing if the keyboard is
6
+ * not active.
7
+ * @since Mini Apps v9.1
8
+ */
9
+ export declare const hideKeyboardFp: import('../../with-checks/withChecksFp.js').WithChecksFp<() => E.Either<HideKeyboardError, void>, true, never>;
10
+ /**
11
+ * @see hideKeyboardFp
12
+ */
13
+ export declare const hideKeyboard: import('../../with-checks/withChecksFp.js').WithChecks<() => E.Either<HideKeyboardError, void>, true, never>;
@@ -0,0 +1,13 @@
1
+ import { RequestError } from '@vbotma/bridge';
2
+ import { taskEither as TE } from 'fp-ts';
3
+ import { AsyncOptions } from '../../types.js';
4
+ export type ReadTextFromClipboardError = RequestError;
5
+ /**
6
+ * Reads a text from the clipboard and returns a `string` or `null`. `null` is returned
7
+ * in one of the following cases:
8
+ * - A value in the clipboard is not a text.
9
+ * - Access to the clipboard is not granted.
10
+ * @since Mini Apps v6.4
11
+ */
12
+ export declare const readTextFromClipboardFp: import('../../with-checks/withChecksFp.js').WithChecksFp<(options?: AsyncOptions) => TE.TaskEither<ReadTextFromClipboardError, string | null>, true, never>;
13
+ export declare const readTextFromClipboard: import('../../with-checks/withChecksFp.js').WithChecks<(options?: AsyncOptions) => TE.TaskEither<ReadTextFromClipboardError, string | null>, true, never>;
@@ -0,0 +1,6 @@
1
+ import { AndroidDeviceData } from './retrieveAndroidDeviceDataFrom.js';
2
+ /**
3
+ * Retrieves Android device data from the navigator.userAgent.
4
+ * @see https://core.telegram.org/bots/webapps#additional-data-in-user-agent
5
+ */
6
+ export declare function retrieveAndroidDeviceData(): AndroidDeviceData;
@@ -0,0 +1,14 @@
1
+ export interface AndroidDeviceData {
2
+ appVersion?: string;
3
+ manufacturer?: string;
4
+ model?: string;
5
+ androidVersion?: string;
6
+ sdkVersion?: number;
7
+ performanceClass?: 'LOW' | 'AVERAGE' | 'HIGH' | string;
8
+ }
9
+ /**
10
+ * Retrieves Android device data from the specified User Agent.
11
+ * @see https://core.telegram.org/bots/webapps#additional-data-in-user-agent
12
+ * @param userAgent - user agent.
13
+ */
14
+ export declare function retrieveAndroidDeviceDataFrom(userAgent: string): AndroidDeviceData;
@@ -0,0 +1,20 @@
1
+ import { PostEventError } from '@vbotma/bridge';
2
+ import { either as E } from 'fp-ts';
3
+ import { InvalidArgumentsError } from '../../errors.js';
4
+ export type SendDataError = PostEventError | InvalidArgumentsError;
5
+ /**
6
+ * Sends data to the bot.
7
+ *
8
+ * When this method called, a service message sent to the bot containing the data of the length
9
+ * up to 4096 bytes, and the Mini App closed.
10
+ *
11
+ * See the field `web_app_data` in the class [Message](https://core.telegram.org/bots/api#message).
12
+ *
13
+ * This method is only available for Mini Apps launched via a Keyboard button.
14
+ * @param data - data to send to bot.
15
+ */
16
+ export declare const sendDataFp: import('../../with-checks/withChecksFp.js').WithChecksFp<(data: string) => E.Either<SendDataError, void>, false, never>;
17
+ /**
18
+ * @see sendDataFp
19
+ */
20
+ export declare const sendData: import('../../with-checks/withChecksFp.js').WithChecks<(data: string) => E.Either<SendDataError, void>, false, never>;
@@ -0,0 +1,14 @@
1
+ import { RequestError } from '@vbotma/bridge';
2
+ import { taskEither as TE } from 'fp-ts';
3
+ import { ShareMessageError } from '../../errors.js';
4
+ import { AsyncOptions } from '../../types.js';
5
+ export type ShareMessageFnError = RequestError | ShareMessageError;
6
+ /**
7
+ * Opens a dialog allowing the user to share a message provided by the bot.
8
+ * @since Mini Apps v8.0
9
+ */
10
+ export declare const shareMessageFp: import('../../with-checks/withChecksFp.js').WithChecksFp<(messageId: string, options?: AsyncOptions) => TE.TaskEither<ShareMessageFnError, void>, true, never>;
11
+ /**
12
+ * @see shareMessageFp
13
+ */
14
+ export declare const shareMessage: import('../../with-checks/withChecksFp.js').WithChecks<(messageId: string, options?: AsyncOptions) => TE.TaskEither<ShareMessageFnError, void>, true, never>;
@@ -0,0 +1,50 @@
1
+ import { PostEventError } from '@vbotma/bridge';
2
+ import { either as E } from 'fp-ts';
3
+ export interface ShareStoryOptions {
4
+ /**
5
+ * The caption to be added to the media.
6
+ * 0-200 characters for regular users and 0-2048 characters for premium subscribers.
7
+ * @see https://telegram.org/faq_premium#telegram-premium
8
+ */
9
+ text?: string;
10
+ /**
11
+ * An object that describes a widget link to be included in the story.
12
+ * Note that only premium subscribers can post stories with links.
13
+ * @see https://telegram.org/faq_premium#telegram-premium
14
+ */
15
+ widgetLink?: {
16
+ /**
17
+ * The URL to be included in the story.
18
+ */
19
+ url: string;
20
+ /**
21
+ * The name to be displayed for the widget link, 0-48 characters.
22
+ */
23
+ name?: string;
24
+ };
25
+ }
26
+ export type ShareStoryError = PostEventError;
27
+ /**
28
+ * Opens the native story editor.
29
+ * @since Mini Apps v7.8
30
+ * @example
31
+ * fn.pipe(
32
+ * shareStory('https://example.com/background.png', {
33
+ * text: 'Look at this cool group!',
34
+ * widgetLink: {
35
+ * url: 'https://t.me/heyqbnk',
36
+ * name: 'Vlad\'s community',
37
+ * },
38
+ * }),
39
+ * TE.match(error => {
40
+ * console.error('Something went wrong', error);
41
+ * }, () => {
42
+ * console.log('Call was successful');
43
+ * }),
44
+ * );
45
+ */
46
+ export declare const shareStoryFp: import('../../with-checks/withChecksFp.js').WithChecksFp<(mediaUrl: string, options?: ShareStoryOptions) => E.Either<ShareStoryError, void>, true, never>;
47
+ /**
48
+ * @see shareStoryFp
49
+ */
50
+ export declare const shareStory: import('../../with-checks/withChecksFp.js').WithChecks<(mediaUrl: string, options?: ShareStoryOptions) => E.Either<ShareStoryError, void>, true, never>;
@@ -0,0 +1,28 @@
1
+ import { PostEventError, SwitchInlineQueryChatType } from '@vbotma/bridge';
2
+ import { either as E } from 'fp-ts';
3
+ export type SwitchInlineQueryError = PostEventError;
4
+ /**
5
+ * Inserts the bot's username and the specified inline query in the current chat's input field.
6
+ * Query may be empty, in which case only the bot's username will be inserted. The client prompts
7
+ * the user to choose a specific chat, then opens that chat and inserts the bot's username and
8
+ * the specified inline query in the input field.
9
+ * @param query - text which should be inserted in the input after the current bot name. Max
10
+ * length is 256 symbols.
11
+ * @param chatTypes - List of chat types which could be chosen to send the message. Could be an
12
+ * empty list.
13
+ * @since Mini Apps v6.7
14
+ * @example
15
+ * fn.pipe(
16
+ * switchInlineQuery('my query goes here', ['users']),
17
+ * E.match(error => {
18
+ * console.error('Something went wrong', error);
19
+ * }, () => {
20
+ * console.log('Call was successful');
21
+ * }),
22
+ * );
23
+ */
24
+ export declare const switchInlineQueryFp: import('../../with-checks/withChecksFp.js').WithChecksFp<(query: string, chatTypes?: SwitchInlineQueryChatType[]) => E.Either<SwitchInlineQueryError, void>, true, never>;
25
+ /**
26
+ * @see switchInlineQueryFp
27
+ */
28
+ export declare const switchInlineQuery: import('../../with-checks/withChecksFp.js').WithChecks<(query: string, chatTypes?: SwitchInlineQueryChatType[]) => E.Either<SwitchInlineQueryError, void>, true, never>;
@@ -0,0 +1,11 @@
1
+ import { EventName } from '@vbotma/bridge';
2
+ export declare function bottomButtonOptions<S, D>(storageName: string, trackedClickEvent: EventName, defaults: D): {
3
+ defaults: D;
4
+ onClick(listener: VoidFunction, once?: boolean): VoidFunction;
5
+ offClick(listener: VoidFunction, once?: boolean): void;
6
+ isTma: import('../types.js').MaybeAccessor<boolean>;
7
+ postEvent: import('@vbotma/bridge').PostEventFpFn;
8
+ version: import('../types.js').MaybeAccessor<import('@vbotma/types').Version>;
9
+ storage: import('../helpers/component-storage.js').ComponentStorage<S>;
10
+ isPageReload: import('../types.js').MaybeAccessor<boolean>;
11
+ };
@@ -0,0 +1,10 @@
1
+ import { EventName } from '@vbotma/bridge';
2
+ export declare function buttonOptions<S>(storageName: string, trackedClickEvent: EventName): {
3
+ onClick(listener: VoidFunction, once?: boolean): VoidFunction;
4
+ offClick(listener: VoidFunction, once?: boolean): void;
5
+ isTma: import('../types.js').MaybeAccessor<boolean>;
6
+ postEvent: import('@vbotma/bridge').PostEventFpFn;
7
+ version: import('../types.js').MaybeAccessor<import('@vbotma/types').Version>;
8
+ storage: import('../helpers/component-storage.js').ComponentStorage<S>;
9
+ isPageReload: import('../types.js').MaybeAccessor<boolean>;
10
+ };
@@ -0,0 +1,2 @@
1
+ import { MaybeAccessor } from '../types.js';
2
+ export declare function createFnOption<T>(mix: MaybeAccessor<T>): <O extends object>(obj: O) => O & T;
@@ -0,0 +1,8 @@
1
+ import { MaybeAccessor } from '../types.js';
2
+ export interface SharedFeatureOptions {
3
+ /**
4
+ * True if the current environment is VBot Mini Apps.
5
+ */
6
+ isTma: MaybeAccessor<boolean>;
7
+ }
8
+ export declare function sharedFeatureOptions(): SharedFeatureOptions;
@@ -0,0 +1,7 @@
1
+ export interface WithCreateRequestId {
2
+ /**
3
+ * A function generating a request identifier.
4
+ */
5
+ createRequestId: () => string;
6
+ }
7
+ export declare const withCreateRequestId: <O extends object>(obj: O) => O & WithCreateRequestId;
@@ -0,0 +1,11 @@
1
+ import { CustomMethodParams, CustomMethodName, InvokeCustomMethodError, InvokeCustomMethodFpOptions, RequestError } from '@vbotma/bridge';
2
+ import type * as TE from 'fp-ts/TaskEither';
3
+ export type { InvokeCustomMethodError };
4
+ export interface InvokeCustomMethodNoRequestIdFn {
5
+ <M extends CustomMethodName>(this: void, method: M, params: CustomMethodParams<M>, options?: InvokeCustomMethodFpOptions): TE.TaskEither<InvokeCustomMethodError, unknown>;
6
+ (this: void, method: string, params: object, options?: InvokeCustomMethodFpOptions): TE.TaskEither<RequestError, unknown>;
7
+ }
8
+ export interface WithInvokeCustomMethod {
9
+ invokeCustomMethod: InvokeCustomMethodNoRequestIdFn;
10
+ }
11
+ export declare const withInvokeCustomMethod: <O extends object>(obj: O) => O & WithInvokeCustomMethod;
@@ -0,0 +1,8 @@
1
+ import { PostEventFpFn } from '@vbotma/bridge';
2
+ export interface WithPostEvent {
3
+ /**
4
+ * A postEvent function to use to call Mini Apps methods.
5
+ */
6
+ postEvent: PostEventFpFn;
7
+ }
8
+ export declare const withPostEvent: <O extends object>(obj: O) => O & WithPostEvent;
@@ -0,0 +1,8 @@
1
+ import { Request2FpFn } from '@vbotma/bridge';
2
+ export interface WithRequest {
3
+ /**
4
+ * A request function to use to call Mini Apps methods.
5
+ */
6
+ request: Request2FpFn;
7
+ }
8
+ export declare const withRequest: <O extends object>(obj: O) => O & WithRequest;
@@ -0,0 +1,13 @@
1
+ import { ComponentStorage } from '../helpers/component-storage.js';
2
+ import { MaybeAccessor } from '../types.js';
3
+ export interface WithStateRestore<T> {
4
+ /**
5
+ * A storage the component could use to store its data.
6
+ */
7
+ storage: ComponentStorage<T>;
8
+ /**
9
+ * True if the current page is reloaded.
10
+ */
11
+ isPageReload: MaybeAccessor<boolean>;
12
+ }
13
+ export declare function withStateRestore<S>(storageName: string): <O extends object>(obj: O) => O & WithStateRestore<S>;
@@ -0,0 +1,9 @@
1
+ import { Version } from '@vbotma/types';
2
+ import { MaybeAccessor } from '../types.js';
3
+ export interface WithVersion {
4
+ /**
5
+ * The currently supported VBot Mini Apps version by the VBot client.
6
+ */
7
+ version: MaybeAccessor<Version>;
8
+ }
9
+ export declare const withVersion: <O extends object>(obj: O) => O & WithVersion;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @returns A new request identifier.
3
+ */
4
+ export declare function createRequestId(): string;
@@ -0,0 +1,16 @@
1
+ import { RequestError, CustomMethodName, CustomMethodParams, InvokeCustomMethodOptions } from '@vbotma/bridge';
2
+ import { taskEither as TE } from 'fp-ts';
3
+ /**
4
+ * Invokes known custom method. Returns method execution result.
5
+ * @param method - method name.
6
+ * @param params - method parameters.
7
+ * @param options - additional options.
8
+ */
9
+ export declare function invokeCustomMethod<M extends CustomMethodName>(method: M, params: CustomMethodParams<M>, options?: InvokeCustomMethodOptions): TE.TaskEither<RequestError, unknown>;
10
+ /**
11
+ * Invokes unknown custom method. Returns method execution result.
12
+ * @param method - method name.
13
+ * @param params - method parameters.
14
+ * @param options - additional options.
15
+ */
16
+ export declare function invokeCustomMethod(method: string, params: object, options?: InvokeCustomMethodOptions): TE.TaskEither<RequestError, unknown>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * True if the application is launched in inline mode.
3
+ */
4
+ export declare const isInlineMode: import('@vbotma/signals').Signal<boolean>;
@@ -0,0 +1,4 @@
1
+ import { postEventFp as _postEventFp, PostEventFpFn, PostEventFn } from '@vbotma/bridge';
2
+ export declare const postEventFpSignal: import('@vbotma/signals').Signal<typeof _postEventFp>;
3
+ export declare const postEventFp: PostEventFpFn;
4
+ export declare const postEvent: PostEventFn;
@@ -0,0 +1,13 @@
1
+ import { RequestFpFn, RequestFn, Request2FpFn, Request2Fn } from '@vbotma/bridge';
2
+ /**
3
+ * @deprecated To be removed in the next major update. Use `request2fp` instead, it provides
4
+ * a proper way of handling multiple events.
5
+ */
6
+ export declare const requestFp: RequestFpFn;
7
+ export declare const request2Fp: Request2FpFn;
8
+ /**
9
+ * @deprecated To be removed in the next major update. Use `request` instead, it provides
10
+ * a proper way of handling multiple events.
11
+ */
12
+ export declare const request: RequestFn;
13
+ export declare const request2: Request2Fn;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Resets all bridge globals and locally created signals.
3
+ */
4
+ export declare function resetGlobals(): void;
@@ -0,0 +1,39 @@
1
+ import { Computed, Signal, SignalOptions } from '@vbotma/signals';
2
+ export type SignalsTuple<T> = [Signal<T>, Computed<T>];
3
+ /**
4
+ * Creates a new signal with the initial value.
5
+ * @param initialValue - the initial value.
6
+ * @param options - additional options.
7
+ */
8
+ export declare function createSignal<T>(initialValue: T, options?: SignalOptions<T>): Signal<T>;
9
+ /**
10
+ * Creates a new signal without the initial value.
11
+ * @param initialValue - the initial value.
12
+ * @param options - additional options.
13
+ */
14
+ export declare function createSignal<T>(initialValue?: T, options?: SignalOptions<T | undefined>): Signal<T | undefined>;
15
+ /**
16
+ * Creates a signal, which wil be automatically updated if some of its dependant signals were
17
+ * modified.
18
+ * @param fn - computation function.
19
+ * @param options - additional functions.
20
+ */
21
+ export declare function createComputed<T>(fn: (prev?: T) => T, options?: SignalOptions<T>): Computed<T>;
22
+ /**
23
+ * Resets all signals states.
24
+ */
25
+ export declare function resetSignals(): void;
26
+ /**
27
+ * @returns A tuple, containing a manual and computed signals. The computed signal is based on
28
+ * the manual one.
29
+ * @param initialValue - the initial value.
30
+ * @param options - additional options.
31
+ */
32
+ export declare function createSignalsTuple<T>(initialValue: T, options?: SignalOptions<T>): SignalsTuple<T>;
33
+ /**
34
+ * @returns A tuple, containing a manual and computed signals. The computed signal is based on
35
+ * the manual one.
36
+ * @param initialValue - an initial value.
37
+ * @param options - additional options.
38
+ */
39
+ export declare function createSignalsTuple<T>(initialValue?: T, options?: SignalOptions<T | undefined>): SignalsTuple<T | undefined>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Mini application's theme parameters.
3
+ */
4
+ export declare const themeParams: import('@vbotma/signals').Signal<Partial<Record<string, `#${string}`>>>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * The current Mini Apps version.
3
+ */
4
+ export declare const version: import('@vbotma/signals').Signal<string>;
@@ -0,0 +1,2 @@
1
+ import { MaybeAccessor } from '../types.js';
2
+ export declare function access<T>(value: MaybeAccessor<T>): T;
@@ -0,0 +1,9 @@
1
+ export interface ComponentStorage<T> {
2
+ get: () => T | undefined;
3
+ set: (value: T) => void;
4
+ }
5
+ /**
6
+ * Creates a new sessionStorage-based component storage.
7
+ * @param key - session storage key to use.
8
+ */
9
+ export declare function createComponentSessionStorage<T>(key: string): ComponentStorage<T>;
@@ -0,0 +1,5 @@
1
+ import { MethodName } from '@vbotma/bridge';
2
+ import { Computed } from '@vbotma/signals';
3
+ import { Version } from '@vbotma/types';
4
+ import { MaybeAccessor } from '../types.js';
5
+ export declare function createIsSupportedSignal(method: MethodName, version: MaybeAccessor<Version>): Computed<boolean>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Sets CSS variable globally.
3
+ * @param name - variable name.
4
+ * @param value - variable value.
5
+ */
6
+ export declare function setCssVar(name: string, value: string | null): void;
7
+ /**
8
+ * Deletes specified CSS variable.
9
+ * @param name - variable name.
10
+ */
11
+ export declare function deleteCssVar(name: string): void;
@@ -0,0 +1,11 @@
1
+ import { either as E } from 'fp-ts';
2
+ /**
3
+ * @param color - color in any format acceptable by the `toRGB` function.
4
+ * @returns True if the color is recognized as dark.
5
+ * @see toRGB
6
+ */
7
+ export declare function isColorDarkFp(color: string): E.Either<Error, boolean>;
8
+ /**
9
+ * @see isColorDarkFp
10
+ */
11
+ export declare const isColorDark: ((color: string) => boolean) & {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @returns True, if the current page was reloaded.
3
+ * @see https://stackoverflow.com/a/36444134/11894710
4
+ */
5
+ export declare function isPageReload(): boolean;
@@ -0,0 +1,10 @@
1
+ import { UnionRequiredKeys } from '@vbotma/toolkit';
2
+ type RemoveUndefined<T> = {
3
+ [K in UnionRequiredKeys<T>]-?: T[K];
4
+ };
5
+ /**
6
+ * @returns Object with keys having undefined values.
7
+ * @param value - an object to remove undefined values from.
8
+ */
9
+ export declare function removeUndefined<T extends {}>(value: T): RemoveUndefined<T>;
10
+ export {};
@@ -0,0 +1 @@
1
+ export declare function shallowEqual<T extends object>(a: T, b: T): boolean;