@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,131 @@
1
+ import { PostEventError } from '@vbotma/bridge';
2
+ import { Computed } from '@vbotma/signals';
3
+ import { BetterTaskEitherError } from '@vbotma/toolkit';
4
+ import { BetterPromise } from 'better-promises';
5
+ import { either as E, taskEither as TE } from 'fp-ts';
6
+ import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
7
+ import { WithPostEvent } from '../../fn-options/withPostEvent.js';
8
+ import { WithVersion } from '../../fn-options/withVersion.js';
9
+ import { AsyncOptions } from '../../types.js';
10
+ import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
11
+ export interface QrScannerOptions extends WithVersion, WithPostEvent, SharedFeatureOptions {
12
+ /**
13
+ * A function to add a listener to the event determining if the QR scanner
14
+ * was closed.
15
+ * @param listener - a listener to add.
16
+ * @returns A function to remove the listener.
17
+ */
18
+ onClosed: (listener: VoidFunction) => VoidFunction;
19
+ /**
20
+ * A function to add a listener to the event containing a scanned QR content.
21
+ * @param listener - a listener to add.
22
+ * @returns A function to remove the listener.
23
+ */
24
+ onTextReceived: (listener: (data: string) => void) => VoidFunction;
25
+ }
26
+ interface SharedOptions extends AsyncOptions {
27
+ /**
28
+ * Title to be displayed in the scanner.
29
+ */
30
+ text?: string;
31
+ }
32
+ interface CaptureOptions extends SharedOptions {
33
+ /**
34
+ * @returns True if the passed QR code should be captured.
35
+ * @param qr - scanned QR content.
36
+ */
37
+ capture: (qr: string) => boolean;
38
+ }
39
+ interface OpenOptions extends SharedOptions {
40
+ /**
41
+ * Function which will be called if a QR code was scanned.
42
+ * @param qr - scanned QR content.
43
+ */
44
+ onCaptured: (qr: string) => void;
45
+ }
46
+ /**
47
+ * @since Mini Apps v6.4
48
+ */
49
+ export declare class QrScanner {
50
+ constructor({ version, onClosed, onTextReceived, isTma, postEvent, }: QrScannerOptions);
51
+ /**
52
+ * Signal indicating if the scanner is currently opened.
53
+ */
54
+ readonly isOpened: Computed<boolean>;
55
+ /**
56
+ * Signal indicating if the component is supported.
57
+ */
58
+ readonly isSupported: Computed<boolean>;
59
+ /**
60
+ * Opens the scanner and returns a task which will be completed with the QR content if the
61
+ * passed `capture` function returned true.
62
+ *
63
+ * Task may also be completed with undefined if the scanner was closed.
64
+ * @param options - method options.
65
+ * @returns A promise with QR content presented as string or undefined if the scanner was closed.
66
+ * @since Mini Apps v6.4
67
+ * @example
68
+ * fn.pipe(
69
+ * qrScanner.captureFp({
70
+ * capture(scannedQr) {
71
+ * return scannedQr === 'any expected by me qr';
72
+ * }
73
+ * }),
74
+ * TE.match(
75
+ * error => {
76
+ * console.error(error);
77
+ * },
78
+ * qr => {
79
+ * console.log('My QR:'), qr;
80
+ * }
81
+ * ),
82
+ * );
83
+ */
84
+ readonly captureFp: WithChecksFp<(options: CaptureOptions) => (TE.TaskEither<PostEventError | BetterTaskEitherError, string | undefined>), true>;
85
+ /**
86
+ * @see captureFp
87
+ */
88
+ readonly capture: WithChecks<(options: CaptureOptions) => BetterPromise<string | undefined>, true>;
89
+ /**
90
+ * Closes the scanner.
91
+ * @since Mini Apps v6.4
92
+ */
93
+ readonly closeFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;
94
+ /**
95
+ * @see close
96
+ */
97
+ readonly close: WithChecks<() => void, true>;
98
+ /**
99
+ * Opens the scanner and returns a task which will be completed when the scanner was closed.
100
+ * @param options - method options.
101
+ * @since Mini Apps v6.4
102
+ * @example Without `capture` option
103
+ * if (qrScanner.open.isAvailable()) {
104
+ * const qr = await qrScanner.open({ text: 'Scan any QR' });
105
+ * }
106
+ * @example
107
+ * fn.pipe(
108
+ * qrScanner.openFp({
109
+ * onCaptured(scannedQr) {
110
+ * if (scannedQr === 'any expected by me qr') {
111
+ * qrScanner.close();
112
+ * }
113
+ * }
114
+ * }),
115
+ * TE.match(
116
+ * error => {
117
+ * console.error(error);
118
+ * },
119
+ * () => {
120
+ * console.log('The scanner was closed');
121
+ * }
122
+ * ),
123
+ * );
124
+ */
125
+ readonly openFp: WithChecksFp<(options: OpenOptions) => TE.TaskEither<PostEventError, void>, true>;
126
+ /**
127
+ * @see openFp
128
+ */
129
+ readonly open: WithChecks<(options: OpenOptions) => BetterPromise<void>, true>;
130
+ }
131
+ export {};
@@ -0,0 +1,2 @@
1
+ export { QrScanner, type QrScannerOptions } from './QrScanner.js';
2
+ export { qrScanner } from './instance.js';
@@ -0,0 +1,2 @@
1
+ import { QrScanner } from './QrScanner.js';
2
+ export declare const qrScanner: QrScanner;
@@ -0,0 +1,39 @@
1
+ import { UnknownEnvError } from '@vbotma/bridge';
2
+ import { Computed } from '@vbotma/signals';
3
+ import { BetterPromise } from 'better-promises';
4
+ import { taskEither as TE } from 'fp-ts';
5
+ import { RefreshOptions, RefreshRequestListener } from './types.js';
6
+ /**
7
+ * Refresh feature class.
8
+ * @since v9.2
9
+ */
10
+ export declare class Refresh {
11
+ constructor({}: RefreshOptions);
12
+ /**
13
+ * Signal indicating if refresh is currently in progress.
14
+ */
15
+ readonly isRefreshing: Computed<boolean>;
16
+ /**
17
+ * Notifies native app that refresh has completed.
18
+ * @since v9.2
19
+ */
20
+ readonly finishRefreshFp: () => TE.TaskEither<UnknownEnvError, void>;
21
+ /**
22
+ * @see finishRefreshFp
23
+ */
24
+ readonly finishRefresh: () => BetterPromise<void>;
25
+ /**
26
+ * Subscribes to refresh request events from native app.
27
+ * @param listener - callback function to execute when refresh is requested
28
+ * @returns unsubscribe function
29
+ * @since v9.2
30
+ * @example
31
+ * const unsubscribe = refresh.onRefreshRequest(() => {
32
+ * // Fetch new data
33
+ * fetchData().then(() => {
34
+ * refresh.finishRefresh();
35
+ * });
36
+ * });
37
+ */
38
+ readonly onRefreshRequest: (listener: RefreshRequestListener) => VoidFunction;
39
+ }
@@ -0,0 +1,3 @@
1
+ export type { RefreshOptions, RefreshRequestListener, } from './types.js';
2
+ export { Refresh } from './Refresh.js';
3
+ export { refresh } from './instance.js';
@@ -0,0 +1,2 @@
1
+ import { Refresh } from './Refresh.js';
2
+ export declare const refresh: Refresh;
@@ -0,0 +1,7 @@
1
+ import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
2
+ export interface RefreshOptions extends SharedFeatureOptions {
3
+ }
4
+ /**
5
+ * Callback function called when refresh is requested by native app.
6
+ */
7
+ export type RefreshRequestListener = () => void;
@@ -0,0 +1,253 @@
1
+ import { PostEventError, SecondaryButtonPosition } from '@vbotma/bridge';
2
+ import { Computed } from '@vbotma/signals';
3
+ import { RGB } from '@vbotma/types';
4
+ import { either as E } from 'fp-ts';
5
+ import { ButtonOptions } from '../../composables/Button.js';
6
+ import { MaybeAccessor } from '../../types.js';
7
+ import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
8
+ type SecondaryButtonEither = E.Either<PostEventError, void>;
9
+ export interface SecondaryButtonState {
10
+ isVisible: boolean;
11
+ bgColor?: RGB;
12
+ hasShineEffect: boolean;
13
+ isEnabled: boolean;
14
+ isLoaderVisible: boolean;
15
+ text: string;
16
+ textColor?: RGB;
17
+ position: SecondaryButtonPosition;
18
+ }
19
+ export interface SecondaryButtonOptions extends Omit<ButtonOptions<SecondaryButtonState, 'web_app_setup_secondary_button'>, 'initialState' | 'method' | 'payload'> {
20
+ /**
21
+ * Default values for different kinds of the button properties.
22
+ */
23
+ defaults: {
24
+ bgColor: MaybeAccessor<RGB>;
25
+ textColor: MaybeAccessor<RGB>;
26
+ };
27
+ }
28
+ /**
29
+ * @since Mini Apps v7.10
30
+ */
31
+ export declare class SecondaryButton {
32
+ constructor({ defaults, ...options }: SecondaryButtonOptions);
33
+ /**
34
+ * Signal indicating if the component is supported.
35
+ */
36
+ readonly isSupported: Computed<boolean>;
37
+ /**
38
+ * The button position relative to the main one.
39
+ */
40
+ readonly position: Computed<SecondaryButtonPosition>;
41
+ /**
42
+ * The button background color.
43
+ */
44
+ readonly bgColor: Computed<RGB>;
45
+ /**
46
+ * True if the button has a shining effect.
47
+ */
48
+ readonly hasShineEffect: Computed<boolean>;
49
+ /**
50
+ * True if the button is clickable.
51
+ */
52
+ readonly isEnabled: Computed<boolean>;
53
+ /**
54
+ * True if the button loader is visible.
55
+ */
56
+ readonly isLoaderVisible: Computed<boolean>;
57
+ /**
58
+ * True if the button is visible.
59
+ */
60
+ readonly isVisible: Computed<boolean>;
61
+ /**
62
+ * Signal indicating if the component is currently mounted.
63
+ */
64
+ readonly isMounted: Computed<boolean>;
65
+ /**
66
+ * The complete button state.
67
+ */
68
+ readonly state: Computed<SecondaryButtonState>;
69
+ /**
70
+ * The button displayed text.
71
+ */
72
+ readonly text: Computed<string>;
73
+ /**
74
+ * The button text color.
75
+ *
76
+ * Note that this value is computed based on the external defaults. For
77
+ * example, if not explicitly set, this value may be equal to one of theme
78
+ * params colors.
79
+ */
80
+ readonly textColor: Computed<RGB>;
81
+ /**
82
+ * Shows the button.
83
+ * @since Mini Apps v7.10
84
+ */
85
+ readonly showFp: WithChecksFp<() => SecondaryButtonEither, true>;
86
+ /**
87
+ * @see showFp
88
+ */
89
+ readonly show: WithChecks<() => void, true>;
90
+ /**
91
+ * Hides the button.
92
+ * @since Mini Apps v7.10
93
+ */
94
+ readonly hideFp: WithChecksFp<() => SecondaryButtonEither, true>;
95
+ /**
96
+ * @see hideFp
97
+ */
98
+ readonly hide: WithChecks<() => void, true>;
99
+ /**
100
+ * Enables the button.
101
+ * @since Mini Apps v7.10
102
+ */
103
+ readonly enableFp: WithChecksFp<() => SecondaryButtonEither, true>;
104
+ /**
105
+ * @see enableFp
106
+ */
107
+ readonly enable: WithChecks<() => void, true>;
108
+ /**
109
+ * Enables the button.
110
+ * @since Mini Apps v7.10
111
+ */
112
+ readonly enableShineEffectFp: WithChecksFp<() => SecondaryButtonEither, true>;
113
+ /**
114
+ * @see enableShineEffectFp
115
+ */
116
+ readonly enableShineEffect: WithChecks<() => void, true>;
117
+ /**
118
+ * Disables the button.
119
+ * @since Mini Apps v7.10
120
+ */
121
+ readonly disableFp: WithChecksFp<() => SecondaryButtonEither, true>;
122
+ /**
123
+ * @see disableFp
124
+ */
125
+ readonly disable: WithChecks<() => void, true>;
126
+ /**
127
+ * Enables the button.
128
+ * @since Mini Apps v7.10
129
+ */
130
+ readonly disableShineEffectFp: WithChecksFp<() => SecondaryButtonEither, true>;
131
+ /**
132
+ * @see disableShineEffectFp
133
+ */
134
+ readonly disableShineEffect: WithChecks<() => void, true>;
135
+ /**
136
+ * Updates the button background color.
137
+ * @since Mini Apps v7.10
138
+ */
139
+ readonly setBgColorFp: WithChecksFp<(value: RGB) => SecondaryButtonEither, true>;
140
+ /**
141
+ * @see setBgColorFp
142
+ */
143
+ readonly setBgColor: WithChecks<(value: RGB) => void, true>;
144
+ /**
145
+ * Updates the button text color.
146
+ * @since Mini Apps v7.10
147
+ */
148
+ readonly setTextColorFp: WithChecksFp<(value: RGB) => SecondaryButtonEither, true>;
149
+ /**
150
+ * @see setTextColorFp
151
+ */
152
+ readonly setTextColor: WithChecks<(value: RGB) => void, true>;
153
+ /**
154
+ * Updates the button text.
155
+ * @since Mini Apps v7.10
156
+ */
157
+ readonly setTextFp: WithChecksFp<(value: string) => SecondaryButtonEither, true>;
158
+ /**
159
+ * @see setTextFp
160
+ */
161
+ readonly setText: WithChecks<(value: string) => void, true>;
162
+ /**
163
+ * Updates the button position.
164
+ * @since Mini Apps v7.10
165
+ */
166
+ readonly setPositionFp: WithChecksFp<(position: SecondaryButtonPosition) => SecondaryButtonEither, true>;
167
+ /**
168
+ * @see setPositionFp
169
+ */
170
+ readonly setPosition: WithChecks<(position: SecondaryButtonPosition) => void, true>;
171
+ /**
172
+ * Shows the button loader.
173
+ * @since Mini Apps v7.10
174
+ */
175
+ readonly showLoaderFp: WithChecksFp<() => SecondaryButtonEither, true>;
176
+ /**
177
+ * @see showLoaderFp
178
+ */
179
+ readonly showLoader: WithChecks<() => void, true>;
180
+ /**
181
+ * Hides the button loader.
182
+ * @since Mini Apps v7.10
183
+ */
184
+ readonly hideLoaderFp: WithChecksFp<() => SecondaryButtonEither, true>;
185
+ /**
186
+ * @see hideLoaderFp
187
+ */
188
+ readonly hideLoader: WithChecks<() => void, true>;
189
+ /**
190
+ * Updates the button state.
191
+ * @param state - updates to apply.
192
+ * @since Mini Apps v7.10
193
+ * @example
194
+ * button.setParams({
195
+ * text: 'Submit',
196
+ * isEnabled: true,
197
+ * hasShineEffect: true,
198
+ * });
199
+ */
200
+ readonly setParamsFp: WithChecksFp<(state: Partial<SecondaryButtonState>) => SecondaryButtonEither, true>;
201
+ /**
202
+ * @see setParamsFp
203
+ */
204
+ readonly setParams: WithChecks<(state: Partial<SecondaryButtonState>) => void, true>;
205
+ /**
206
+ * Mounts the component restoring its state.
207
+ * @since Mini Apps v7.10
208
+ */
209
+ readonly mountFp: WithChecksFp<() => void, true>;
210
+ /**
211
+ * @see mountFp
212
+ */
213
+ readonly mount: WithChecks<() => void, true>;
214
+ /**
215
+ * Unmounts the component.
216
+ */
217
+ readonly unmount: () => void;
218
+ /**
219
+ * Adds a new button listener.
220
+ * @param listener - event listener.
221
+ * @param once - should the listener be called only once.
222
+ * @returns A function to remove bound listener.
223
+ * @since Mini Apps v7.10
224
+ * @example
225
+ * const off = button.onClick(() => {
226
+ * console.log('User clicked the button');
227
+ * off();
228
+ * });
229
+ */
230
+ readonly onClickFp: WithChecksFp<(listener: VoidFunction, once?: boolean) => VoidFunction, true>;
231
+ /**
232
+ * @see onClick
233
+ */
234
+ readonly onClick: WithChecks<(listener: VoidFunction, once?: boolean) => VoidFunction, true>;
235
+ /**
236
+ * Removes the button click listener.
237
+ * @param listener - event listener.
238
+ * @param once - should the listener be called only once.
239
+ * @since Mini Apps v7.10
240
+ * @example
241
+ * function listener() {
242
+ * console.log('User clicked the button');
243
+ * button.offClick(listener);
244
+ * }
245
+ * button.onClick(listener);
246
+ */
247
+ readonly offClickFp: WithChecksFp<(listener: VoidFunction, once?: boolean) => void, true>;
248
+ /**
249
+ * @see offClick
250
+ */
251
+ readonly offClick: WithChecks<(listener: VoidFunction, once?: boolean) => void, true>;
252
+ }
253
+ export {};
@@ -0,0 +1,2 @@
1
+ export { secondaryButton } from './instance.js';
2
+ export { type SecondaryButtonOptions, SecondaryButton, type SecondaryButtonState, } from './SecondaryButton.js';
@@ -0,0 +1,2 @@
1
+ import { SecondaryButton } from './SecondaryButton.js';
2
+ export declare const secondaryButton: SecondaryButton;
@@ -0,0 +1,68 @@
1
+ import { RequestError } from '@vbotma/bridge';
2
+ import { taskEither as TE } from 'fp-ts';
3
+ import { SecureStorageMethodError } from '../../errors.js';
4
+ import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
5
+ import { WithCreateRequestId } from '../../fn-options/withCreateRequestId.js';
6
+ import { WithRequest } from '../../fn-options/withRequest.js';
7
+ import { WithVersion } from '../../fn-options/withVersion.js';
8
+ import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
9
+ export type SecureStorageError = RequestError | SecureStorageMethodError;
10
+ export interface SecureStorageOptions extends SharedFeatureOptions, WithVersion, WithRequest, WithCreateRequestId {
11
+ }
12
+ /**
13
+ * @since Mini Apps v9.0
14
+ */
15
+ export declare class SecureStorage {
16
+ constructor({ isTma, request, version, createRequestId }: SecureStorageOptions);
17
+ /**
18
+ * Retrieves an item using its key.
19
+ * @since Mini Apps v9.0
20
+ */
21
+ readonly getItemFp: WithChecksFp<(key: string) => TE.TaskEither<SecureStorageError, {
22
+ value: string | null;
23
+ canRestore: boolean;
24
+ }>, true>;
25
+ /**
26
+ * @see getItemFp
27
+ */
28
+ readonly getItem: WithChecks<(key: string) => Promise<{
29
+ value: string | null;
30
+ canRestore: boolean;
31
+ }>, true>;
32
+ /**
33
+ * Restores an item from the storage.
34
+ * @since Mini Apps v9.0
35
+ */
36
+ readonly restoreItemFp: WithChecksFp<(key: string) => TE.TaskEither<SecureStorageError, string | null>, true>;
37
+ /**
38
+ * @see restoreItemFp
39
+ */
40
+ readonly restoreItem: WithChecks<(key: string) => Promise<string | null>, true>;
41
+ /**
42
+ * Sets a new item in the storage.
43
+ * @since Mini Apps v9.0
44
+ */
45
+ readonly setItemFp: WithChecksFp<(key: string, value: string | null) => TE.TaskEither<SecureStorageError, void>, true>;
46
+ /**
47
+ * @see setItemFp
48
+ */
49
+ readonly setItem: WithChecks<(key: string, value: string | null) => Promise<void>, true>;
50
+ /**
51
+ * Removes a key from the storage.
52
+ * @since Mini Apps v9.0
53
+ */
54
+ readonly deleteItemFp: WithChecksFp<(key: string) => TE.TaskEither<SecureStorageError, void>, true>;
55
+ /**
56
+ * @see deleteItemFp
57
+ */
58
+ readonly deleteItem: WithChecks<(key: string) => Promise<void>, true>;
59
+ /**
60
+ * Removes all keys from the storage.
61
+ * @since Mini Apps v9.0
62
+ */
63
+ readonly clearFp: WithChecksFp<() => TE.TaskEither<SecureStorageError, void>, true>;
64
+ /**
65
+ * @see clearFp
66
+ */
67
+ readonly clear: WithChecks<() => Promise<void>, true>;
68
+ }
@@ -0,0 +1,2 @@
1
+ export { SecureStorage, type SecureStorageOptions, type SecureStorageError } from './SecureStorage.js';
2
+ export { secureStorage } from './instance.js';
@@ -0,0 +1,2 @@
1
+ import { SecureStorage } from './SecureStorage.js';
2
+ export declare const secureStorage: SecureStorage;
@@ -0,0 +1,96 @@
1
+ import { PostEventError } from '@vbotma/bridge';
2
+ import { Computed } from '@vbotma/signals';
3
+ import { either as E } from 'fp-ts';
4
+ import { ButtonOptions } from '../../composables/Button.js';
5
+ import { WithChecksFp, WithChecks } from '../../with-checks/withChecksFp.js';
6
+ export interface SettingsButtonState {
7
+ isVisible: boolean;
8
+ }
9
+ export type SettingsButtonOptions = Omit<ButtonOptions<SettingsButtonState, 'web_app_setup_settings_button'>, 'method' | 'payload' | 'initialState'>;
10
+ /**
11
+ * @since Mini Apps v6.10
12
+ */
13
+ export declare class SettingsButton {
14
+ constructor(options: SettingsButtonOptions);
15
+ /**
16
+ * Signal indicating if the component is currently visible.
17
+ */
18
+ readonly isVisible: Computed<boolean>;
19
+ /**
20
+ * Signal indicating if the component is currently mounted.
21
+ */
22
+ readonly isMounted: Computed<boolean>;
23
+ /**
24
+ * Signal indicating if the component is supported.
25
+ */
26
+ readonly isSupported: Computed<boolean>;
27
+ /**
28
+ * Hides the button.
29
+ * @since Mini Apps v6.10
30
+ */
31
+ readonly hideFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;
32
+ /**
33
+ * @see hideFp
34
+ */
35
+ readonly hide: WithChecks<() => void, true>;
36
+ /**
37
+ * Shows the button.
38
+ * @since Mini Apps v6.10
39
+ */
40
+ readonly showFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;
41
+ /**
42
+ * @see showFp
43
+ */
44
+ readonly show: WithChecks<() => void, true>;
45
+ /**
46
+ * Adds a new button listener.
47
+ * @param listener - event listener.
48
+ * @param once - should the listener be called only once.
49
+ * @returns A function to remove bound listener.
50
+ * @since Mini Apps v6.10
51
+ * @example
52
+ * const off = button.onClick(() => {
53
+ * console.log('User clicked the button');
54
+ * off();
55
+ * });
56
+ */
57
+ readonly onClickFp: WithChecksFp<(listener: VoidFunction, once?: boolean) => VoidFunction, true>;
58
+ /**
59
+ * @see onClickFp
60
+ */
61
+ readonly onClick: WithChecks<(listener: VoidFunction, once?: boolean) => VoidFunction, true>;
62
+ /**
63
+ * Removes the button click listener.
64
+ * @param listener - event listener.
65
+ * @param once - should the listener be called only once.
66
+ * @since Mini Apps v6.10
67
+ * @example
68
+ * function listener() {
69
+ * console.log('User clicked the button');
70
+ * button.offClick(listener);
71
+ * }
72
+ * button.onClick(listener);
73
+ */
74
+ readonly offClickFp: WithChecksFp<(listener: VoidFunction, once?: boolean) => void, true>;
75
+ /**
76
+ * @see offClickFp
77
+ */
78
+ readonly offClick: WithChecks<(listener: VoidFunction, once?: boolean) => void, true>;
79
+ /**
80
+ * Mounts the component restoring its state.
81
+ * @since Mini Apps v6.10
82
+ */
83
+ readonly mountFp: WithChecksFp<() => void, true>;
84
+ /**
85
+ * @see mountFp
86
+ */
87
+ readonly mount: WithChecks<() => void, true>;
88
+ /**
89
+ * Unmounts the component.
90
+ *
91
+ * Note that this function does not remove listeners added via the `onClick`
92
+ * function, so you have to remove them on your own.
93
+ * @see onClick
94
+ */
95
+ readonly unmount: () => void;
96
+ }
@@ -0,0 +1,2 @@
1
+ export { settingsButton } from './instance.js';
2
+ export { type SettingsButtonOptions, SettingsButton, type SettingsButtonState, } from './SettingsButton.js';
@@ -0,0 +1,2 @@
1
+ import { SettingsButton } from './SettingsButton.js';
2
+ export declare const settingsButton: SettingsButton;
@@ -0,0 +1,45 @@
1
+ import { RequestError } from '@vbotma/bridge';
2
+ import { BetterPromise } from 'better-promises';
3
+ import { taskEither as TE } from 'fp-ts';
4
+ import { StoragePermissionOptions, RequestStorageAccessOptions, StorageAccessResult } from './types.js';
5
+ /**
6
+ * Storage Permission feature class.
7
+ * Allows requesting access to device storage to select files or folders.
8
+ * @since v9.3
9
+ */
10
+ export declare class StoragePermission {
11
+ constructor({ request }: StoragePermissionOptions);
12
+ /**
13
+ * Requests storage access with specified options.
14
+ * Returns a promise that resolves with selected files/folders.
15
+ * @param options - Storage access options
16
+ * @since v9.3
17
+ */
18
+ readonly requestAccessFp: (options: RequestStorageAccessOptions) => TE.TaskEither<RequestError, StorageAccessResult>;
19
+ /**
20
+ * @see requestAccessFp
21
+ */
22
+ readonly requestAccess: (options: RequestStorageAccessOptions) => BetterPromise<StorageAccessResult>;
23
+ /**
24
+ * Convenience method to select a single file.
25
+ * @param options - Optional file selection options
26
+ */
27
+ readonly selectFile: (options?: {
28
+ accept?: string[];
29
+ maxFileSize?: number;
30
+ readContent?: boolean;
31
+ }) => BetterPromise<StorageAccessResult>;
32
+ /**
33
+ * Convenience method to select multiple files.
34
+ * @param options - Optional file selection options
35
+ */
36
+ readonly selectFiles: (options?: {
37
+ accept?: string[];
38
+ maxFileSize?: number;
39
+ readContent?: boolean;
40
+ }) => BetterPromise<StorageAccessResult>;
41
+ /**
42
+ * Convenience method to select a folder.
43
+ */
44
+ readonly selectFolder: () => BetterPromise<StorageAccessResult>;
45
+ }