@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,3 @@
1
+ export { StoragePermission } from './StoragePermission.js';
2
+ export { storagePermission } from './instance.js';
3
+ export type { StoragePermissionOptions, StorageItem, StorageAccessResult, RequestStorageAccessOptions, } from './types.js';
@@ -0,0 +1,2 @@
1
+ import { StoragePermission } from './StoragePermission.js';
2
+ export declare const storagePermission: StoragePermission;
@@ -0,0 +1,51 @@
1
+ import { RequestFpFn } from '@vbotma/bridge';
2
+ export interface StoragePermissionOptions {
3
+ request: RequestFpFn;
4
+ }
5
+ /**
6
+ * Represents a selected file or folder.
7
+ */
8
+ export interface StorageItem {
9
+ name: string;
10
+ path: string;
11
+ size?: number;
12
+ type?: string;
13
+ content?: string;
14
+ lastModified?: number;
15
+ }
16
+ /**
17
+ * Result of storage access request.
18
+ */
19
+ export interface StorageAccessResult {
20
+ accessType: 'file' | 'folder';
21
+ items: StorageItem[];
22
+ }
23
+ /**
24
+ * Options for requesting storage access.
25
+ */
26
+ export interface RequestStorageAccessOptions {
27
+ /**
28
+ * Type of storage access to request.
29
+ */
30
+ accessType: 'file' | 'folder';
31
+ /**
32
+ * Allow multiple file selection (only for files).
33
+ * @default false
34
+ */
35
+ multiple?: boolean;
36
+ /**
37
+ * MIME types to filter files.
38
+ */
39
+ accept?: string[];
40
+ /**
41
+ * Maximum file size in bytes.
42
+ * Files larger than this will be rejected.
43
+ * @default undefined (no limit)
44
+ */
45
+ maxFileSize?: number;
46
+ /**
47
+ * Read file content as base64.
48
+ * @default false
49
+ */
50
+ readContent?: boolean;
51
+ }
@@ -0,0 +1,62 @@
1
+ import { PostEventError } from '@vbotma/bridge';
2
+ import { Computed } from '@vbotma/signals';
3
+ import { either as E } from 'fp-ts';
4
+ import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
5
+ import { WithPostEvent } from '../../fn-options/withPostEvent.js';
6
+ import { WithStateRestore } from '../../fn-options/withStateRestore.js';
7
+ import { WithVersion } from '../../fn-options/withVersion.js';
8
+ import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
9
+ export interface SwipeBehaviorState {
10
+ isVerticalEnabled: boolean;
11
+ }
12
+ export interface SwipeBehaviorOptions extends WithStateRestore<SwipeBehaviorState>, WithVersion, WithPostEvent, SharedFeatureOptions {
13
+ }
14
+ /**
15
+ * @since Mini Apps v7.7
16
+ */
17
+ export declare class SwipeBehavior {
18
+ constructor({ postEvent, storage, isTma, isPageReload, version }: SwipeBehaviorOptions);
19
+ /**
20
+ * Signal indicating if the component is supported.
21
+ */
22
+ readonly isSupported: Computed<boolean>;
23
+ /**
24
+ * Signal indicating if vertical swipes are enabled.
25
+ */
26
+ readonly isVerticalEnabled: Computed<boolean>;
27
+ /**
28
+ * Signal indicating if the component is currently mounted.
29
+ */
30
+ readonly isMounted: Computed<boolean>;
31
+ /**
32
+ * Mounts the component restoring its state.
33
+ * @since Mini Apps v7.7
34
+ */
35
+ readonly mountFp: WithChecksFp<() => void, true>;
36
+ /**
37
+ * @see mountFp
38
+ */
39
+ readonly mount: WithChecks<() => void, true>;
40
+ /**
41
+ * Unmounts the component.
42
+ */
43
+ readonly unmount: () => void;
44
+ /**
45
+ * Disables the closing confirmation dialog.
46
+ * @since Mini Apps v7.7
47
+ */
48
+ readonly disableVerticalFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;
49
+ /**
50
+ * @see disableVerticalFp
51
+ */
52
+ readonly disableVertical: WithChecks<() => void, true>;
53
+ /**
54
+ * Enables the closing confirmation dialog.
55
+ * @since Mini Apps v7.7
56
+ */
57
+ readonly enableVerticalFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;
58
+ /**
59
+ * @see enableVerticalFp
60
+ */
61
+ readonly enableVertical: WithChecks<() => void, true>;
62
+ }
@@ -0,0 +1,2 @@
1
+ export { swipeBehavior } from './instance.js';
2
+ export { type SwipeBehaviorOptions, SwipeBehavior, type SwipeBehaviorState, } from './SwipeBehavior.js';
@@ -0,0 +1,2 @@
1
+ import { SwipeBehavior } from './SwipeBehavior.js';
2
+ export declare const swipeBehavior: SwipeBehavior;
@@ -0,0 +1,127 @@
1
+ import { EventListener } from '@vbotma/bridge';
2
+ import { Computed } from '@vbotma/signals';
3
+ import { ThemeParams as ThemeParamsType, RGB } from '@vbotma/types';
4
+ import { either as E } from 'fp-ts';
5
+ import { CSSVarsBoundError } from '../../errors.js';
6
+ import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
7
+ import { WithStateRestore } from '../../fn-options/withStateRestore.js';
8
+ import { MaybeAccessor } from '../../types.js';
9
+ import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
10
+ export type ThemeParamsState = ThemeParamsType;
11
+ export interface ThemeParamsOptions extends WithStateRestore<ThemeParamsState>, SharedFeatureOptions {
12
+ /**
13
+ * Removes a theme change listener.
14
+ * @param listener - a listener to remove.
15
+ */
16
+ offChange: (listener: EventListener<'theme_changed'>) => void;
17
+ /**
18
+ * Adds a theme change listener.
19
+ * @returns A function to remove listener.
20
+ * @param listener - a listener to add.
21
+ */
22
+ onChange: (listener: EventListener<'theme_changed'>) => void;
23
+ /**
24
+ * Theme parameters initial state.
25
+ */
26
+ initialState: MaybeAccessor<ThemeParamsType>;
27
+ }
28
+ export interface ThemeParamsGetCssVarNameFn {
29
+ /**
30
+ * @param property - palette key.
31
+ * @returns Computed complete CSS variable name.
32
+ */
33
+ (property: Extract<keyof ThemeParamsType, string>): string;
34
+ }
35
+ export declare class ThemeParams {
36
+ constructor({ initialState, onChange, offChange, isTma, storage, isPageReload, }: ThemeParamsOptions);
37
+ /**
38
+ * @since v6.10
39
+ */
40
+ readonly accentTextColor: Computed<RGB | undefined>;
41
+ readonly bgColor: Computed<RGB | undefined>;
42
+ readonly buttonColor: Computed<RGB | undefined>;
43
+ readonly buttonTextColor: Computed<RGB | undefined>;
44
+ /**
45
+ * @since v7.10
46
+ */
47
+ readonly bottomBarBgColor: Computed<RGB | undefined>;
48
+ readonly destructiveTextColor: Computed<RGB | undefined>;
49
+ /**
50
+ * @since v6.10
51
+ */
52
+ readonly headerBgColor: Computed<RGB | undefined>;
53
+ readonly hintColor: Computed<RGB | undefined>;
54
+ readonly linkColor: Computed<RGB | undefined>;
55
+ readonly secondaryBgColor: Computed<RGB | undefined>;
56
+ /**
57
+ * @since v6.10
58
+ */
59
+ readonly sectionBgColor: Computed<RGB | undefined>;
60
+ /**
61
+ * @since v6.10
62
+ */
63
+ readonly sectionHeaderTextColor: Computed<RGB | undefined>;
64
+ /**
65
+ * @since v7.6
66
+ */
67
+ readonly sectionSeparatorColor: Computed<RGB | undefined>;
68
+ /**
69
+ * @since v6.10
70
+ */
71
+ readonly subtitleTextColor: Computed<RGB | undefined>;
72
+ readonly textColor: Computed<RGB | undefined>;
73
+ private readonly _isCssVarsBound;
74
+ /**
75
+ * True if CSS variables are currently bound.
76
+ */
77
+ readonly isCssVarsBound: Computed<boolean>;
78
+ /**
79
+ * Creates CSS variables connected with the current theme parameters.
80
+ *
81
+ * By default, created CSS variables names are following the pattern "--tg-theme-{name}", where
82
+ * {name} is a theme parameters key name converted from snake case to kebab case.
83
+ *
84
+ * Default variables:
85
+ * - `--tg-theme-bg-color`
86
+ * - `--tg-theme-secondary-text-color`
87
+ *
88
+ * Variables are being automatically updated if theme parameters were changed.
89
+ *
90
+ * @param getCSSVarName - function, returning complete CSS variable name for the specified
91
+ * theme parameters key.
92
+ * @returns Function to stop updating variables.
93
+ * @throws {CSSVarsBoundError} CSS variables are already bound
94
+ * @example Using custom CSS vars generator
95
+ * themeParams.bindCssVars(key => `--my-prefix-${key}`);
96
+ */
97
+ readonly bindCssVarsFp: WithChecksFp<(getCSSVarName?: ThemeParamsGetCssVarNameFn) => E.Either<CSSVarsBoundError, VoidFunction>, false>;
98
+ /**
99
+ * @see bindCssVarsFp
100
+ */
101
+ readonly bindCssVars: WithChecks<(getCSSVarName?: ThemeParamsGetCssVarNameFn) => VoidFunction, false>;
102
+ /**
103
+ * Complete component state.
104
+ */
105
+ readonly state: Computed<ThemeParamsType>;
106
+ /**
107
+ * @returns True if the current color scheme is recognized as dark.
108
+ * This value is calculated based on the current theme's background color.
109
+ */
110
+ readonly isDark: Computed<boolean>;
111
+ /**
112
+ * Signal indicating if the component is currently mounted.
113
+ */
114
+ readonly isMounted: Computed<boolean>;
115
+ /**
116
+ * Mounts the component restoring its state.
117
+ */
118
+ readonly mountFp: WithChecksFp<() => E.Either<never, void>, false>;
119
+ /**
120
+ * @see mountFp
121
+ */
122
+ readonly mount: WithChecks<() => void, false>;
123
+ /**
124
+ * Unmounts the component.
125
+ */
126
+ readonly unmount: () => void;
127
+ }
@@ -0,0 +1,2 @@
1
+ export { themeParams } from './instance.js';
2
+ export { type ThemeParamsOptions, ThemeParams, type ThemeParamsState, type ThemeParamsGetCssVarNameFn, } from './ThemeParams.js';
@@ -0,0 +1,2 @@
1
+ import { ThemeParams } from './ThemeParams.js';
2
+ export declare const themeParams: ThemeParams;
@@ -0,0 +1,219 @@
1
+ import { SafeAreaInsets, EventListener, RequestError, PostEventError } from '@vbotma/bridge';
2
+ import { Computed } from '@vbotma/signals';
3
+ import { BetterPromise } from 'better-promises';
4
+ import { either as E, taskEither as TE } from 'fp-ts';
5
+ import { CSSVarsBoundError, FullscreenFailedError } from '../../errors.js';
6
+ import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
7
+ import { WithPostEvent } from '../../fn-options/withPostEvent.js';
8
+ import { WithRequest } from '../../fn-options/withRequest.js';
9
+ import { WithStateRestore } from '../../fn-options/withStateRestore.js';
10
+ import { WithVersion } from '../../fn-options/withVersion.js';
11
+ import { AsyncOptions } from '../../types.js';
12
+ import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
13
+ type FullscreenError = FullscreenFailedError | RequestError;
14
+ type ViewportChangedEventListener = EventListener<'viewport_changed'>;
15
+ type FullscreenChangedEventListener = EventListener<'fullscreen_changed'>;
16
+ type SafeAreaInsetsChangedEventListener = EventListener<'safe_area_changed'>;
17
+ type SafeAreaInsetCSSVarKey = `safeAreaInset${Capitalize<keyof SafeAreaInsets>}`;
18
+ export type GetCSSVarNameKey = 'width' | 'height' | 'stableHeight' | SafeAreaInsetCSSVarKey | `content${Capitalize<SafeAreaInsetCSSVarKey>}`;
19
+ export type GetCSSVarNameFn = (key: GetCSSVarNameKey) => string | null | undefined | false;
20
+ export interface ViewportState {
21
+ contentSafeAreaInsets: SafeAreaInsets;
22
+ height: number;
23
+ isExpanded: boolean;
24
+ isFullscreen: boolean;
25
+ safeAreaInsets: SafeAreaInsets;
26
+ stableHeight: number;
27
+ width: number;
28
+ }
29
+ type WithListeners<On extends string, Off extends string, L> = {
30
+ [K in On | Off]: (listener: L) => void;
31
+ };
32
+ export interface ViewportOptions<EViewportStable, EFullscreen> extends WithStateRestore<ViewportState>, WithVersion, WithRequest, WithPostEvent, WithListeners<'onViewportChanged', 'offViewportChanged', ViewportChangedEventListener>, WithListeners<'onFullscreenChanged', 'offFullscreenChanged', FullscreenChangedEventListener>, WithListeners<'onSafeAreaInsetsChanged', 'offSafeAreaInsetsChanged', SafeAreaInsetsChangedEventListener>, WithListeners<'onContentSafeAreaInsetsChanged', 'offContentSafeAreaInsetsChanged', SafeAreaInsetsChangedEventListener>, SharedFeatureOptions {
33
+ /**
34
+ * True if the viewport is stable.
35
+ */
36
+ isViewportStable: boolean | (() => E.Either<EViewportStable, boolean>);
37
+ /**
38
+ * True if the application was opened in fullscreen initially.
39
+ */
40
+ isFullscreen: boolean | (() => E.Either<EFullscreen, boolean>);
41
+ }
42
+ export declare class Viewport<EViewportStable, EFullscreen> {
43
+ constructor({ storage, isPageReload, onContentSafeAreaInsetsChanged, onSafeAreaInsetsChanged, onViewportChanged, onFullscreenChanged, offContentSafeAreaInsetsChanged, offFullscreenChanged, offSafeAreaInsetsChanged, offViewportChanged, request, isViewportStable, isFullscreen, isTma, version, postEvent, }: ViewportOptions<EViewportStable, EFullscreen>);
44
+ /**
45
+ * Complete component state.
46
+ */
47
+ readonly state: Computed<ViewportState>;
48
+ /**
49
+ * Signal containing the current height of the **visible area** of the Mini App.
50
+ *
51
+ * The application can display just the top part of the Mini App, with its
52
+ * lower part remaining outside the screen area. From this position, the user
53
+ * can "pull" the Mini App to its maximum height, while the bot can do the same
54
+ * by calling `expand` method. As the position of the Mini App changes, the
55
+ * current height value of the visible area will be updated in real time.
56
+ *
57
+ * Please note that the refresh rate of this value is not sufficient to
58
+ * smoothly follow the lower border of the window. It should not be used to pin
59
+ * interface elements to the bottom of the visible area. It's more appropriate
60
+ * to use the value of the `stableHeight` field for this purpose.
61
+ *
62
+ * @see stableHeight
63
+ */
64
+ readonly height: Computed<number>;
65
+ /**
66
+ * Signal containing the height of the visible area of the Mini App in its last stable state.
67
+ *
68
+ * The application can display just the top part of the Mini App, with its
69
+ * lower part remaining outside the screen area. From this position, the user
70
+ * can "pull" the Mini App to its maximum height, while the application can do
71
+ * the same by calling `expand` method.
72
+ *
73
+ * Unlike the value of `height`, the value of `stableHeight` does not change as
74
+ * the position of the Mini App changes with user gestures or during
75
+ * animations. The value of `stableHeight` will be updated after all gestures
76
+ * and animations are completed and the Mini App reaches its final size.
77
+ *
78
+ * @see height
79
+ */
80
+ readonly stableHeight: Computed<number>;
81
+ /**
82
+ * Signal containing the currently visible area width.
83
+ */
84
+ readonly width: Computed<number>;
85
+ /**
86
+ * Signal indicating if the Mini App is expanded to the maximum available height. Otherwise,
87
+ * if the Mini App occupies part of the screen and can be expanded to the full
88
+ * height using the `expand` method.
89
+ */
90
+ readonly isExpanded: Computed<boolean>;
91
+ /**
92
+ * Signal indicating if the current viewport height is stable and is not going to change in
93
+ * the next moment.
94
+ */
95
+ readonly isStable: Computed<boolean>;
96
+ /**
97
+ * Signal containing content safe area insets.
98
+ */
99
+ readonly contentSafeAreaInsets: Computed<SafeAreaInsets>;
100
+ /**
101
+ * Signal containing top content safe area inset.
102
+ */
103
+ readonly contentSafeAreaInsetTop: Computed<number>;
104
+ /**
105
+ * Signal containing left content safe area inset.
106
+ */
107
+ readonly contentSafeAreaInsetLeft: Computed<number>;
108
+ /**
109
+ * Signal containing right content safe area inset.
110
+ */
111
+ readonly contentSafeAreaInsetRight: Computed<number>;
112
+ /**
113
+ * Signal containing bottom content safe area inset.
114
+ */
115
+ readonly contentSafeAreaInsetBottom: Computed<number>;
116
+ /**
117
+ * Signal containing safe area insets.
118
+ */
119
+ readonly safeAreaInsets: Computed<SafeAreaInsets>;
120
+ /**
121
+ * Signal containing top safe area inset.
122
+ */
123
+ readonly safeAreaInsetTop: Computed<number>;
124
+ /**
125
+ * Signal containing left safe area inset.
126
+ */
127
+ readonly safeAreaInsetLeft: Computed<number>;
128
+ /**
129
+ * Signal containing right safe area inset.
130
+ */
131
+ readonly safeAreaInsetRight: Computed<number>;
132
+ /**
133
+ * Signal containing bottom safe area inset.
134
+ */
135
+ readonly safeAreaInsetBottom: Computed<number>;
136
+ /**
137
+ * Signal indicating if the viewport is currently in fullscreen mode.
138
+ */
139
+ readonly isFullscreen: Computed<boolean>;
140
+ /**
141
+ * Requests fullscreen mode for the mini application.
142
+ * @since Mini Apps v8.0
143
+ */
144
+ readonly requestFullscreenFp: WithChecksFp<(options?: AsyncOptions) => TE.TaskEither<FullscreenError, void>, true>;
145
+ /**
146
+ * @see requestFullscreenFp
147
+ */
148
+ readonly requestFullscreen: WithChecks<(options?: AsyncOptions) => BetterPromise<void>, true>;
149
+ /**
150
+ * Exits mini application from the fullscreen mode.
151
+ * @since Mini Apps v8.0
152
+ */
153
+ readonly exitFullscreenFp: WithChecksFp<(options?: AsyncOptions) => TE.TaskEither<FullscreenError, void>, true>;
154
+ /**
155
+ * @see exitFullscreenFp
156
+ */
157
+ readonly exitFullscreen: WithChecks<(options?: AsyncOptions) => BetterPromise<void>, true>;
158
+ /**
159
+ * Signal indicating if CSS variables are bound.
160
+ */
161
+ readonly isCssVarsBound: Computed<boolean>;
162
+ /**
163
+ * Creates CSS variables connected with the current viewport.
164
+ *
165
+ * By default, created CSS variables names are following the pattern "--tg-theme-{name}", where
166
+ * {name} is a viewport property name converted from camel case to kebab case.
167
+ *
168
+ * Default variables:
169
+ * - `--tg-viewport-height`
170
+ * - `--tg-viewport-width`
171
+ * - `--tg-viewport-stable-height`
172
+ * - `--tg-viewport-content-safe-area-inset-top`
173
+ * - `--tg-viewport-content-safe-area-inset-bottom`
174
+ * - `--tg-viewport-content-safe-area-inset-left`
175
+ * - `--tg-viewport-content-safe-area-inset-right`
176
+ * - `--tg-viewport-safe-area-inset-top`
177
+ * - `--tg-viewport-safe-area-inset-bottom`
178
+ * - `--tg-viewport-safe-area-inset-left`
179
+ * - `--tg-viewport-safe-area-inset-right`
180
+ *
181
+ * Variables are being automatically updated if the viewport was changed.
182
+ *
183
+ * @param getCSSVarName - function, returning computed complete CSS variable name. The CSS
184
+ * variable will only be defined if the function returned non-empty string value.
185
+ * @returns Function to stop updating variables.
186
+ * @example Using no arguments
187
+ * bindCssVarsFp();
188
+ * @example Using custom CSS vars generator
189
+ * bindCssVarsFp(key => `--my-prefix-${key}`);
190
+ */
191
+ readonly bindCssVarsFp: WithChecksFp<(getCSSVarName?: GetCSSVarNameFn) => (E.Either<CSSVarsBoundError, VoidFunction>), false>;
192
+ /**
193
+ * @see bindCssVarsFp
194
+ */
195
+ readonly bindCssVars: WithChecks<(getCSSVarName?: GetCSSVarNameFn) => VoidFunction, false>;
196
+ /**
197
+ * Signal indicating if the component is currently mounted.
198
+ */
199
+ readonly isMounted: Computed<boolean>;
200
+ /**
201
+ * Mounts the component.
202
+ */
203
+ readonly mountFp: WithChecksFp<(options?: AsyncOptions) => (TE.TaskEither<EFullscreen | EViewportStable | RequestError, void>), false>;
204
+ /**
205
+ * @see mountFp
206
+ */
207
+ readonly mount: WithChecks<(options?: AsyncOptions) => BetterPromise<void>, false>;
208
+ /**
209
+ * A method that expands the Mini App to the maximum available height. To find
210
+ * out if the Mini App is expanded to the maximum height, refer to the value of
211
+ * the `isExpanded`.
212
+ */
213
+ readonly expandFp: WithChecksFp<() => E.Either<PostEventError, void>, false>;
214
+ /**
215
+ * @see expandFp
216
+ */
217
+ readonly expand: WithChecks<() => void, false>;
218
+ }
219
+ export {};
@@ -0,0 +1,2 @@
1
+ export { viewport } from './instance.js';
2
+ export { Viewport, type ViewportState, type ViewportOptions } from './Viewport.js';
@@ -0,0 +1,2 @@
1
+ import { Viewport } from './Viewport.js';
2
+ export declare const viewport: Viewport<import('@vbotma/bridge').RetrieveLaunchParamsError, import('@vbotma/bridge').RetrieveLaunchParamsError>;
@@ -0,0 +1,2 @@
1
+ export { requestEmojiStatusAccess, requestEmojiStatusAccessFp, } from './requestEmojiStatusAccess.js';
2
+ export { setEmojiStatus, setEmojiStatusFp, type SetEmojiStatusOptions, } from './setEmojiStatus.js';
@@ -0,0 +1,16 @@
1
+ import { EmojiStatusAccessRequestedStatus, RequestError } from '@vbotma/bridge';
2
+ import { taskEither as TE } from 'fp-ts';
3
+ import { AsyncOptions } from '../../types.js';
4
+ /**
5
+ * Shows a native popup requesting permission for the bot to manage user's emoji status.
6
+ * @param options - additional options.
7
+ * @returns Emoji status access status.
8
+ * @since Mini Apps v8.0
9
+ * @example
10
+ * const status = await requestEmojiStatusAccess();
11
+ */
12
+ export declare const requestEmojiStatusAccessFp: import('../../with-checks/withChecksFp.js').WithChecksFp<(options: AsyncOptions) => TE.TaskEither<RequestError, EmojiStatusAccessRequestedStatus>, true, never>;
13
+ /**
14
+ * @see requestEmojiStatusAccessFp
15
+ */
16
+ export declare const requestEmojiStatusAccess: import('../../with-checks/withChecksFp.js').WithChecks<(options: AsyncOptions) => TE.TaskEither<RequestError, EmojiStatusAccessRequestedStatus>, true, never>;
@@ -0,0 +1,28 @@
1
+ import { RequestError } from '@vbotma/bridge';
2
+ import { taskEither as TE } from 'fp-ts';
3
+ import { SetEmojiStatusError } from '../../errors.js';
4
+ import { AsyncOptions } from '../../types.js';
5
+ export interface SetEmojiStatusOptions extends AsyncOptions {
6
+ duration?: number;
7
+ }
8
+ /**
9
+ * Opens a dialog allowing the user to set the specified custom emoji as their status.
10
+ * @returns Nothing if status set was successful.
11
+ * @param options - additional options.
12
+ * @since Mini Apps v8.0
13
+ * @example
14
+ * fn.pipe(
15
+ * setEmojiStatusFp('5361800828313167608'),
16
+ * TE.match(error => {
17
+ * console.error('Error occurred', error);
18
+ * }, () => {
19
+ * console.log('Status set');
20
+ * }),
21
+ * );
22
+ * const statusSet = await setEmojiStatus('5361800828313167608');
23
+ */
24
+ export declare const setEmojiStatusFp: import('../../with-checks/withChecksFp.js').WithChecksFp<(customEmojiId: string, options?: SetEmojiStatusOptions) => TE.TaskEither<RequestError | SetEmojiStatusError, void>, true, never>;
25
+ /**
26
+ * @see setEmojiStatusFp
27
+ */
28
+ export declare const setEmojiStatus: import('../../with-checks/withChecksFp.js').WithChecks<(customEmojiId: string, options?: SetEmojiStatusOptions) => TE.TaskEither<RequestError | SetEmojiStatusError, void>, true, never>;
@@ -0,0 +1,11 @@
1
+ import { PostEventError } from '@vbotma/bridge';
2
+ import type * as E from 'fp-ts/Either';
3
+ /**
4
+ * Prompts the user to add the Mini App to the home screen.
5
+ * @since Mini Apps v8.0
6
+ */
7
+ export declare const addToHomeScreenFp: import('../../with-checks/withChecksFp.js').WithChecksFp<() => E.Either<PostEventError, void>, true, never>;
8
+ /**
9
+ * @see addToHomeScreenFp
10
+ */
11
+ export declare const addToHomeScreen: import('../../with-checks/withChecksFp.js').WithChecks<() => E.Either<PostEventError, void>, true, never>;
@@ -0,0 +1,14 @@
1
+ import { HomeScreenStatus, RequestError } from '@vbotma/bridge';
2
+ import { taskEither as TE } from 'fp-ts';
3
+ import { AsyncOptions } from '../../types.js';
4
+ /**
5
+ * Sends a request to the native VBot application to check if the current mini
6
+ * application is added to the device's home screen.
7
+ * @param options - additional options.
8
+ * @since Mini Apps v8.0
9
+ */
10
+ export declare const checkHomeScreenStatusFp: import('../../with-checks/withChecksFp.js').WithChecksFp<(options?: AsyncOptions) => TE.TaskEither<RequestError, HomeScreenStatus>, true, never>;
11
+ /**
12
+ * @see checkHomeScreenStatusFp
13
+ */
14
+ export declare const checkHomeScreenStatus: import('../../with-checks/withChecksFp.js').WithChecks<(options?: AsyncOptions) => TE.TaskEither<RequestError, HomeScreenStatus>, true, never>;
@@ -0,0 +1,2 @@
1
+ export { addToHomeScreenFp, addToHomeScreen } from './addToHomeScreen.js';
2
+ export { checkHomeScreenStatus, checkHomeScreenStatusFp } from './checkHomeScreenStatus.js';
@@ -0,0 +1,3 @@
1
+ export { type OpenLinkError, openLinkFp, openLink, type OpenLinkOptions } from './openLink.js';
2
+ export { type OpenTelegramLinkError, openTelegramLinkFp, openTelegramLink, } from './openTelegramLink.js';
3
+ export { shareURLFp, shareURL, type ShareURLError } from './shareURL.js';
@@ -0,0 +1,31 @@
1
+ import { OpenLinkBrowser, PostEventError } from '@vbotma/bridge';
2
+ import { either as E } from 'fp-ts';
3
+ import { InvalidArgumentsError } from '../../errors.js';
4
+ export interface OpenLinkOptions {
5
+ /**
6
+ * Attempts to use the instant view mode.
7
+ */
8
+ tryInstantView?: boolean;
9
+ /**
10
+ * A preferred browser to open the link in.
11
+ */
12
+ tryBrowser?: OpenLinkBrowser;
13
+ }
14
+ export type OpenLinkError = PostEventError | InvalidArgumentsError;
15
+ /**
16
+ * Opens a link.
17
+ *
18
+ * The Mini App will not be closed.
19
+ *
20
+ * Note that this method can be called only in response to the user
21
+ * interaction with the Mini App interface (e.g. click inside the Mini App or on the main button).
22
+ * @param url - URL to be opened.
23
+ * @param options - additional options.
24
+ * @example
25
+ * openLink('https://google.com', {
26
+ * tryInstantView: true,
27
+ * tryBrowser: 'chrome',
28
+ * });
29
+ */
30
+ export declare const openLinkFp: import('../../with-checks/withChecksFp.js').WithChecksFp<(url: string | URL, options?: OpenLinkOptions) => E.Either<OpenLinkError, void>, false, never>;
31
+ export declare const openLink: import('../../with-checks/withChecksFp.js').WithChecks<(url: string | URL, options?: OpenLinkOptions) => E.Either<OpenLinkError, void>, false, never>;
@@ -0,0 +1,18 @@
1
+ import { PostEventError } from '@vbotma/bridge';
2
+ import { either as E } from 'fp-ts';
3
+ import { InvalidArgumentsError } from '../../errors.js';
4
+ export type OpenTelegramLinkError = PostEventError | InvalidArgumentsError;
5
+ /**
6
+ * Opens a Telegram link inside the Telegram app. The function expects passing a link in a full
7
+ * format using the hostname "t.me".
8
+ *
9
+ * The Mini App will be closed.
10
+ * @param url - URL to be opened.
11
+ * @example
12
+ * openTelegramLink('https://t.me/heyqbnk');
13
+ */
14
+ export declare const openTelegramLinkFp: import('../../with-checks/withChecksFp.js').WithChecksFp<(url: string | URL) => E.Either<OpenTelegramLinkError, void>, false, never>;
15
+ /**
16
+ * @see openTelegramLinkFp
17
+ */
18
+ export declare const openTelegramLink: import('../../with-checks/withChecksFp.js').WithChecks<(url: string | URL) => E.Either<OpenTelegramLinkError, void>, false, never>;
@@ -0,0 +1,18 @@
1
+ import { PostEventError } from '@vbotma/bridge';
2
+ import { either as E } from 'fp-ts';
3
+ export type ShareURLError = PostEventError;
4
+ /**
5
+ * Shares the specified URL with the passed to the chats, selected by user.
6
+ * After being called, it closes the mini application.
7
+ *
8
+ * This method uses Telegram's Share Links.
9
+ * @param url - URL to share.
10
+ * @param text - text to append after the URL.
11
+ * @see https://core.telegram.org/api/links#share-links
12
+ * @see https://core.telegram.org/widgets/share#custom-buttons
13
+ */
14
+ export declare const shareURLFp: import('../../with-checks/withChecksFp.js').WithChecksFp<(url: string, text?: string) => E.Either<ShareURLError, void>, false, never>;
15
+ /**
16
+ * @see shareURLFp
17
+ */
18
+ export declare const shareURL: import('../../with-checks/withChecksFp.js').WithChecks<(url: string, text?: string) => E.Either<ShareURLError, void>, false, never>;
@@ -0,0 +1,3 @@
1
+ export { type RequestContactError, type RequestedContactCompleteData, type RequestedContact, requestContact, requestContactComplete, requestContactCompleteFp, requestContactFp, } from './requestContact.js';
2
+ export { type RequestPhoneAccessError, requestPhoneAccess, requestPhoneAccessFp, } from './requestPhoneAccess.js';
3
+ export { requestWriteAccess, requestWriteAccessFp, type RequestWriteAccessError, } from './requestWriteAccess.js';