@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.
- package/LICENSE +21 -0
- package/README.md +64 -0
- package/dist/dts/composables/AsyncMountable.d.ts +44 -0
- package/dist/dts/composables/Button.d.ts +140 -0
- package/dist/dts/composables/Mountable.d.ts +43 -0
- package/dist/dts/composables/Stateful.d.ts +35 -0
- package/dist/dts/errors.d.ts +51 -0
- package/dist/dts/features/BackButton/BackButton.d.ts +96 -0
- package/dist/dts/features/BackButton/exports.d.ts +2 -0
- package/dist/dts/features/BackButton/instance.d.ts +2 -0
- package/dist/dts/features/Biometry/Biometry.d.ts +121 -0
- package/dist/dts/features/Biometry/exports.d.ts +3 -0
- package/dist/dts/features/Biometry/instance.d.ts +2 -0
- package/dist/dts/features/Biometry/types.d.ts +84 -0
- package/dist/dts/features/ClosingBehavior/ClosingBehavior.d.ts +51 -0
- package/dist/dts/features/ClosingBehavior/exports.d.ts +2 -0
- package/dist/dts/features/ClosingBehavior/instance.d.ts +2 -0
- package/dist/dts/features/CloudStorage/CloudStorage.d.ts +90 -0
- package/dist/dts/features/CloudStorage/exports.d.ts +2 -0
- package/dist/dts/features/CloudStorage/instance.d.ts +2 -0
- package/dist/dts/features/DeviceStorage/DeviceStorage.d.ts +53 -0
- package/dist/dts/features/DeviceStorage/exports.d.ts +2 -0
- package/dist/dts/features/DeviceStorage/instance.d.ts +2 -0
- package/dist/dts/features/HapticFeedback/HapticFeedback.d.ts +57 -0
- package/dist/dts/features/HapticFeedback/exports.d.ts +2 -0
- package/dist/dts/features/HapticFeedback/instance.d.ts +2 -0
- package/dist/dts/features/InitData/InitData.d.ts +87 -0
- package/dist/dts/features/InitData/exports.d.ts +2 -0
- package/dist/dts/features/InitData/instance.d.ts +2 -0
- package/dist/dts/features/Invoice/Invoice.d.ts +54 -0
- package/dist/dts/features/Invoice/exports.d.ts +2 -0
- package/dist/dts/features/Invoice/instance.d.ts +2 -0
- package/dist/dts/features/LocationManager/LocationManager.d.ts +73 -0
- package/dist/dts/features/LocationManager/exports.d.ts +3 -0
- package/dist/dts/features/LocationManager/instance.d.ts +2 -0
- package/dist/dts/features/LocationManager/types.d.ts +65 -0
- package/dist/dts/features/MainButton/MainButton.d.ts +214 -0
- package/dist/dts/features/MainButton/exports.d.ts +2 -0
- package/dist/dts/features/MainButton/instance.d.ts +2 -0
- package/dist/dts/features/MiniApp/MiniApp.d.ts +192 -0
- package/dist/dts/features/MiniApp/exports.d.ts +2 -0
- package/dist/dts/features/MiniApp/instance.d.ts +2 -0
- package/dist/dts/features/Notification/Notification.d.ts +21 -0
- package/dist/dts/features/Notification/exports.d.ts +3 -0
- package/dist/dts/features/Notification/instance.d.ts +2 -0
- package/dist/dts/features/Notification/types.d.ts +19 -0
- package/dist/dts/features/Popup/Popup.d.ts +56 -0
- package/dist/dts/features/Popup/exports.d.ts +3 -0
- package/dist/dts/features/Popup/instance.d.ts +2 -0
- package/dist/dts/features/Popup/prepareParams.d.ts +9 -0
- package/dist/dts/features/Popup/types.d.ts +54 -0
- package/dist/dts/features/QrScanner/QrScanner.d.ts +131 -0
- package/dist/dts/features/QrScanner/exports.d.ts +2 -0
- package/dist/dts/features/QrScanner/instance.d.ts +2 -0
- package/dist/dts/features/Refresh/Refresh.d.ts +39 -0
- package/dist/dts/features/Refresh/exports.d.ts +3 -0
- package/dist/dts/features/Refresh/instance.d.ts +2 -0
- package/dist/dts/features/Refresh/types.d.ts +7 -0
- package/dist/dts/features/SecondaryButton/SecondaryButton.d.ts +253 -0
- package/dist/dts/features/SecondaryButton/exports.d.ts +2 -0
- package/dist/dts/features/SecondaryButton/instance.d.ts +2 -0
- package/dist/dts/features/SecureStorage/SecureStorage.d.ts +68 -0
- package/dist/dts/features/SecureStorage/exports.d.ts +2 -0
- package/dist/dts/features/SecureStorage/instance.d.ts +2 -0
- package/dist/dts/features/SettingsButton/SettingsButton.d.ts +96 -0
- package/dist/dts/features/SettingsButton/exports.d.ts +2 -0
- package/dist/dts/features/SettingsButton/instance.d.ts +2 -0
- package/dist/dts/features/StoragePermission/StoragePermission.d.ts +45 -0
- package/dist/dts/features/StoragePermission/exports.d.ts +3 -0
- package/dist/dts/features/StoragePermission/instance.d.ts +2 -0
- package/dist/dts/features/StoragePermission/types.d.ts +51 -0
- package/dist/dts/features/SwipeBehavior/SwipeBehavior.d.ts +62 -0
- package/dist/dts/features/SwipeBehavior/exports.d.ts +2 -0
- package/dist/dts/features/SwipeBehavior/instance.d.ts +2 -0
- package/dist/dts/features/ThemeParams/ThemeParams.d.ts +127 -0
- package/dist/dts/features/ThemeParams/exports.d.ts +2 -0
- package/dist/dts/features/ThemeParams/instance.d.ts +2 -0
- package/dist/dts/features/Viewport/Viewport.d.ts +219 -0
- package/dist/dts/features/Viewport/exports.d.ts +2 -0
- package/dist/dts/features/Viewport/instance.d.ts +2 -0
- package/dist/dts/features/emoji-status/exports.d.ts +2 -0
- package/dist/dts/features/emoji-status/requestEmojiStatusAccess.d.ts +16 -0
- package/dist/dts/features/emoji-status/setEmojiStatus.d.ts +28 -0
- package/dist/dts/features/home-screen/addToHomeScreen.d.ts +11 -0
- package/dist/dts/features/home-screen/checkHomeScreenStatus.d.ts +14 -0
- package/dist/dts/features/home-screen/exports.d.ts +2 -0
- package/dist/dts/features/links/exports.d.ts +3 -0
- package/dist/dts/features/links/openLink.d.ts +31 -0
- package/dist/dts/features/links/openTelegramLink.d.ts +18 -0
- package/dist/dts/features/links/shareURL.d.ts +18 -0
- package/dist/dts/features/privacy/exports.d.ts +3 -0
- package/dist/dts/features/privacy/requestContact.d.ts +59 -0
- package/dist/dts/features/privacy/requestPhoneAccess.d.ts +19 -0
- package/dist/dts/features/privacy/requestWriteAccess.d.ts +14 -0
- package/dist/dts/features/uncategorized/copyTextToClipboard.d.ts +5 -0
- package/dist/dts/features/uncategorized/downloadFile.d.ts +21 -0
- package/dist/dts/features/uncategorized/exports.d.ts +11 -0
- package/dist/dts/features/uncategorized/getCurrentTime.d.ts +15 -0
- package/dist/dts/features/uncategorized/hideKeyboard.d.ts +13 -0
- package/dist/dts/features/uncategorized/readTextFromClipboard.d.ts +13 -0
- package/dist/dts/features/uncategorized/retrieveAndroidDeviceData.d.ts +6 -0
- package/dist/dts/features/uncategorized/retrieveAndroidDeviceDataFrom.d.ts +14 -0
- package/dist/dts/features/uncategorized/sendData.d.ts +20 -0
- package/dist/dts/features/uncategorized/shareMessage.d.ts +14 -0
- package/dist/dts/features/uncategorized/shareStory.d.ts +50 -0
- package/dist/dts/features/uncategorized/switchInlineQuery.d.ts +28 -0
- package/dist/dts/fn-options/bottomButtonOptions.d.ts +11 -0
- package/dist/dts/fn-options/buttonOptions.d.ts +10 -0
- package/dist/dts/fn-options/createFnOption.d.ts +2 -0
- package/dist/dts/fn-options/sharedFeatureOptions.d.ts +8 -0
- package/dist/dts/fn-options/withCreateRequestId.d.ts +7 -0
- package/dist/dts/fn-options/withInvokeCustomMethod.d.ts +11 -0
- package/dist/dts/fn-options/withPostEvent.d.ts +8 -0
- package/dist/dts/fn-options/withRequest.d.ts +8 -0
- package/dist/dts/fn-options/withStateRestore.d.ts +13 -0
- package/dist/dts/fn-options/withVersion.d.ts +9 -0
- package/dist/dts/globals/createRequestId.d.ts +4 -0
- package/dist/dts/globals/invokeCustomMethod.d.ts +16 -0
- package/dist/dts/globals/isInlineMode.d.ts +4 -0
- package/dist/dts/globals/postEvent.d.ts +4 -0
- package/dist/dts/globals/request.d.ts +13 -0
- package/dist/dts/globals/resetGlobals.d.ts +4 -0
- package/dist/dts/globals/signals-registry.d.ts +39 -0
- package/dist/dts/globals/themeParams.d.ts +4 -0
- package/dist/dts/globals/version.d.ts +4 -0
- package/dist/dts/helpers/access.d.ts +2 -0
- package/dist/dts/helpers/component-storage.d.ts +9 -0
- package/dist/dts/helpers/createIsSupportedSignal.d.ts +5 -0
- package/dist/dts/helpers/css-vars.d.ts +11 -0
- package/dist/dts/helpers/isColorDark.d.ts +11 -0
- package/dist/dts/helpers/navigation.d.ts +5 -0
- package/dist/dts/helpers/removeUndefined.d.ts +10 -0
- package/dist/dts/helpers/shallowEqual.d.ts +1 -0
- package/dist/dts/index.d.ts +38 -0
- package/dist/dts/init.d.ts +42 -0
- package/dist/dts/types.d.ts +6 -0
- package/dist/dts/with-checks/throwifyWithChecksFp.d.ts +3 -0
- package/dist/dts/with-checks/withChecksFp.d.ts +170 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.iife.js +4 -0
- package/dist/index.iife.js.map +1 -0
- package/dist/index.js +4088 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { BiometryType, EventListener } from '@vbotma/bridge';
|
|
2
|
+
import { Maybe } from '@vbotma/toolkit';
|
|
3
|
+
import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
|
|
4
|
+
import { WithPostEvent } from '../../fn-options/withPostEvent.js';
|
|
5
|
+
import { WithRequest } from '../../fn-options/withRequest.js';
|
|
6
|
+
import { WithStateRestore } from '../../fn-options/withStateRestore.js';
|
|
7
|
+
import { WithVersion } from '../../fn-options/withVersion.js';
|
|
8
|
+
import { AsyncOptions } from '../../types.js';
|
|
9
|
+
export interface BiometryState {
|
|
10
|
+
/**
|
|
11
|
+
* If true, indicates that biometric authentication is available on the current device.
|
|
12
|
+
*/
|
|
13
|
+
available: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Indicates whether the app has previously requested permission to use biometrics.
|
|
16
|
+
*/
|
|
17
|
+
accessRequested: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Indicates whether the user has granted the app permission to use biometrics.
|
|
20
|
+
*
|
|
21
|
+
* If false and access_requested is true may indicate that:
|
|
22
|
+
*
|
|
23
|
+
* - The user has simply canceled the permission popup, in which case
|
|
24
|
+
* a `web_app_biometry_request_access` event can be emitted to re-open the popup.
|
|
25
|
+
*
|
|
26
|
+
* - The user has denied the app permission to use biometrics, in which case the app should
|
|
27
|
+
* open a prompt notifying the user that the biometric settings must be changed to use
|
|
28
|
+
* biometrics.
|
|
29
|
+
*/
|
|
30
|
+
accessGranted: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* A unique device identifier that can be used to match the token to the device.
|
|
33
|
+
*/
|
|
34
|
+
deviceId: string;
|
|
35
|
+
/**
|
|
36
|
+
* Show whether a token was safely stored on-device.
|
|
37
|
+
*/
|
|
38
|
+
tokenSaved: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The type of biometrics currently available on the device.
|
|
41
|
+
*/
|
|
42
|
+
type: BiometryType;
|
|
43
|
+
/**
|
|
44
|
+
* Last retrieved token.
|
|
45
|
+
*/
|
|
46
|
+
token?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface BiometryAuthenticateOptions extends AsyncOptions {
|
|
49
|
+
/**
|
|
50
|
+
* Reason to request biometry data. Should be at least 1 symbol length, but not more than
|
|
51
|
+
* 128 symbols.
|
|
52
|
+
*/
|
|
53
|
+
reason?: Maybe<string>;
|
|
54
|
+
}
|
|
55
|
+
export interface BiometryUpdateTokenOptions extends AsyncOptions {
|
|
56
|
+
/**
|
|
57
|
+
* Optional string field, containing the reason why the bot is asking to authenticate using biometrics (1-128 chars, used in the prompt).
|
|
58
|
+
*/
|
|
59
|
+
reason?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Token to save in the local device secure storage. Passing `null`, `undefined` or empty string
|
|
62
|
+
* removes it from the storage.
|
|
63
|
+
*/
|
|
64
|
+
token?: Maybe<string>;
|
|
65
|
+
}
|
|
66
|
+
export interface BiometryRequestAccessOptions extends AsyncOptions {
|
|
67
|
+
/**
|
|
68
|
+
* The text to be displayed to a user in the popup describing why the bot needs access to
|
|
69
|
+
* biometrics, 0-128 characters.
|
|
70
|
+
*/
|
|
71
|
+
reason?: Maybe<string>;
|
|
72
|
+
}
|
|
73
|
+
export interface BiometryOptions extends WithVersion, WithStateRestore<BiometryState>, WithRequest, WithPostEvent, SharedFeatureOptions {
|
|
74
|
+
/**
|
|
75
|
+
* Adds a biometry info received event listener.
|
|
76
|
+
* @param listener - a listener to add.
|
|
77
|
+
*/
|
|
78
|
+
onInfoReceived: (listener: EventListener<'biometry_info_received'>) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Removes a biometry info received event listener.
|
|
81
|
+
* @param listener - a listener to add.
|
|
82
|
+
*/
|
|
83
|
+
offInfoReceived: (listener: EventListener<'biometry_info_received'>) => void;
|
|
84
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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 { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
|
|
8
|
+
export interface ClosingBehaviorState {
|
|
9
|
+
isConfirmationEnabled: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ClosingBehaviorOptions extends WithStateRestore<ClosingBehaviorState>, WithPostEvent, SharedFeatureOptions {
|
|
12
|
+
}
|
|
13
|
+
export declare class ClosingBehavior {
|
|
14
|
+
constructor({ postEvent, storage, isTma, isPageReload }: ClosingBehaviorOptions);
|
|
15
|
+
/**
|
|
16
|
+
* Signal indicating if closing confirmation dialog is currently enabled.
|
|
17
|
+
*/
|
|
18
|
+
readonly isConfirmationEnabled: Computed<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Signal indicating if the component is currently mounted.
|
|
21
|
+
*/
|
|
22
|
+
readonly isMounted: Computed<boolean>;
|
|
23
|
+
/**
|
|
24
|
+
* Mounts the component restoring its state.
|
|
25
|
+
*/
|
|
26
|
+
readonly mountFp: WithChecksFp<() => void, false>;
|
|
27
|
+
/**
|
|
28
|
+
* @see mountFp
|
|
29
|
+
*/
|
|
30
|
+
readonly mount: WithChecks<() => void, false>;
|
|
31
|
+
/**
|
|
32
|
+
* Unmounts the component.
|
|
33
|
+
*/
|
|
34
|
+
readonly unmount: () => void;
|
|
35
|
+
/**
|
|
36
|
+
* Disables the closing confirmation dialog.
|
|
37
|
+
*/
|
|
38
|
+
readonly disableConfirmationFp: WithChecksFp<() => E.Either<PostEventError, void>, false>;
|
|
39
|
+
/**
|
|
40
|
+
* @see disableConfirmationFp
|
|
41
|
+
*/
|
|
42
|
+
readonly disableConfirmation: WithChecks<() => void, false>;
|
|
43
|
+
/**
|
|
44
|
+
* Enables the closing confirmation dialog.
|
|
45
|
+
*/
|
|
46
|
+
readonly enableConfirmationFp: WithChecksFp<() => E.Either<PostEventError, void>, false>;
|
|
47
|
+
/**
|
|
48
|
+
* @see enableConfirmationFp
|
|
49
|
+
*/
|
|
50
|
+
readonly enableConfirmation: WithChecks<() => void, false>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { InvokeCustomMethodFpOptions, RequestError } 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 { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
|
|
6
|
+
import { WithInvokeCustomMethod } from '../../fn-options/withInvokeCustomMethod.js';
|
|
7
|
+
import { WithVersion } from '../../fn-options/withVersion.js';
|
|
8
|
+
import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
|
|
9
|
+
type CloudStorageTask<T> = TE.TaskEither<RequestError, T>;
|
|
10
|
+
export interface CloudStorageOptions extends WithVersion, WithInvokeCustomMethod, SharedFeatureOptions {
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @since Mini Apps v6.9
|
|
14
|
+
*/
|
|
15
|
+
export declare class CloudStorage {
|
|
16
|
+
constructor({ version, isTma, invokeCustomMethod }: CloudStorageOptions);
|
|
17
|
+
/**
|
|
18
|
+
* Signal indicating if the component is supported.
|
|
19
|
+
*/
|
|
20
|
+
readonly isSupported: Computed<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Deletes specified key or keys from the cloud storage.
|
|
23
|
+
* @param keyOrKeys - key or keys to delete.
|
|
24
|
+
* @param options - request execution options.
|
|
25
|
+
* @since Mini Apps v6.9
|
|
26
|
+
*/
|
|
27
|
+
readonly deleteItemFp: WithChecksFp<(keyOrKeys: string | string[], options?: InvokeCustomMethodFpOptions) => CloudStorageTask<void>, true>;
|
|
28
|
+
readonly deleteItem: WithChecks<(keyOrKeys: string | string[], options?: InvokeCustomMethodFpOptions) => BetterPromise<void>, true>;
|
|
29
|
+
/**
|
|
30
|
+
* Gets a single key value from the cloud storage.
|
|
31
|
+
* @param key - a key to get.
|
|
32
|
+
* @param options - request execution options.
|
|
33
|
+
* @returns A key value as a string.
|
|
34
|
+
* @since Mini Apps v6.9
|
|
35
|
+
*/
|
|
36
|
+
readonly getItemFp: WithChecksFp<(key: string, options?: InvokeCustomMethodFpOptions) => CloudStorageTask<string>, true>;
|
|
37
|
+
/**
|
|
38
|
+
* @see getItemFp
|
|
39
|
+
*/
|
|
40
|
+
readonly getItem: WithChecks<{
|
|
41
|
+
<K extends string>(keys: K[], options?: InvokeCustomMethodFpOptions): BetterPromise<Record<K, string>>;
|
|
42
|
+
(key: string, options?: InvokeCustomMethodFpOptions): BetterPromise<string>;
|
|
43
|
+
}, true>;
|
|
44
|
+
/**
|
|
45
|
+
* Gets multiple keys' values from the cloud storage.
|
|
46
|
+
* @param keys - keys list.
|
|
47
|
+
* @param options - request execution options.
|
|
48
|
+
* @returns A map, where a key is one of the specified in the `keys` argument,
|
|
49
|
+
* and a value is a corresponding storage value if an array of keys was passed.
|
|
50
|
+
* @since Mini Apps v6.9
|
|
51
|
+
*/
|
|
52
|
+
readonly getItemsFp: WithChecksFp<(<K extends string>(keys: K[], options?: InvokeCustomMethodFpOptions) => CloudStorageTask<Record<K, string>>), true>;
|
|
53
|
+
/**
|
|
54
|
+
* @see getItemsFp
|
|
55
|
+
*/
|
|
56
|
+
readonly getItems: WithChecks<(<K extends string>(keys: K[], options?: InvokeCustomMethodFpOptions) => BetterPromise<Record<K, string>>), true>;
|
|
57
|
+
/**
|
|
58
|
+
* Returns a list of all keys presented in the cloud storage.
|
|
59
|
+
* @param options - request execution options.
|
|
60
|
+
* @since Mini Apps v6.9
|
|
61
|
+
*/
|
|
62
|
+
readonly getKeysFp: WithChecksFp<(options?: InvokeCustomMethodFpOptions) => CloudStorageTask<string[]>, true>;
|
|
63
|
+
/**
|
|
64
|
+
* @see getKeysFp
|
|
65
|
+
*/
|
|
66
|
+
readonly getKeys: WithChecks<(options?: InvokeCustomMethodFpOptions) => BetterPromise<string[]>, true>;
|
|
67
|
+
/**
|
|
68
|
+
* Saves the specified value by a key.
|
|
69
|
+
* @param key - storage key.
|
|
70
|
+
* @param value - storage value.
|
|
71
|
+
* @param options - request execution options.
|
|
72
|
+
* @since Mini Apps v6.9
|
|
73
|
+
*/
|
|
74
|
+
readonly setItemFp: WithChecksFp<(key: string, value: string, options?: InvokeCustomMethodFpOptions) => CloudStorageTask<void>, true>;
|
|
75
|
+
/**
|
|
76
|
+
* @see setItemFp
|
|
77
|
+
*/
|
|
78
|
+
readonly setItem: WithChecks<(key: string, value: string, options?: InvokeCustomMethodFpOptions) => BetterPromise<void>, true>;
|
|
79
|
+
/**
|
|
80
|
+
* Clears the cloud storage.
|
|
81
|
+
* @param options - additional options.
|
|
82
|
+
* @since Mini Apps v6.9
|
|
83
|
+
*/
|
|
84
|
+
readonly clearFp: WithChecksFp<(options?: InvokeCustomMethodFpOptions) => CloudStorageTask<void>, true>;
|
|
85
|
+
/**
|
|
86
|
+
* @see clearFp
|
|
87
|
+
*/
|
|
88
|
+
readonly clear: WithChecks<(options?: InvokeCustomMethodFpOptions) => BetterPromise<void>, true>;
|
|
89
|
+
}
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { RequestError } from '@vbotma/bridge';
|
|
2
|
+
import { taskEither as TE } from 'fp-ts';
|
|
3
|
+
import { DeviceStorageMethodError } 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 DeviceStorageError = RequestError | DeviceStorageMethodError;
|
|
10
|
+
export interface DeviceStorageOptions extends SharedFeatureOptions, WithVersion, WithRequest, WithCreateRequestId {
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @since Mini Apps v9.0
|
|
14
|
+
*/
|
|
15
|
+
export declare class DeviceStorage {
|
|
16
|
+
constructor({ isTma, request, version, createRequestId }: DeviceStorageOptions);
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves an item using its key.
|
|
19
|
+
* @since Mini Apps v9.0
|
|
20
|
+
*/
|
|
21
|
+
readonly getItemFp: WithChecksFp<(key: string) => TE.TaskEither<DeviceStorageError, string | null>, true>;
|
|
22
|
+
/**
|
|
23
|
+
* @see getItemFp
|
|
24
|
+
*/
|
|
25
|
+
readonly getItem: WithChecks<(key: string) => Promise<string | null>, true>;
|
|
26
|
+
/**
|
|
27
|
+
* Sets a new item in the storage.
|
|
28
|
+
* @since Mini Apps v9.0
|
|
29
|
+
*/
|
|
30
|
+
readonly setItemFp: WithChecksFp<(key: string, value: string | null) => TE.TaskEither<DeviceStorageError, void>, true>;
|
|
31
|
+
/**
|
|
32
|
+
* @see setItemFp
|
|
33
|
+
*/
|
|
34
|
+
readonly setItem: WithChecks<(key: string, value: string | null) => Promise<void>, true>;
|
|
35
|
+
/**
|
|
36
|
+
* Removes a key from the storage.
|
|
37
|
+
* @since Mini Apps v9.0
|
|
38
|
+
*/
|
|
39
|
+
readonly deleteItemFp: WithChecksFp<(key: string) => TE.TaskEither<DeviceStorageError, void>, true>;
|
|
40
|
+
/**
|
|
41
|
+
* @see deleteItemFp
|
|
42
|
+
*/
|
|
43
|
+
readonly deleteItem: WithChecks<(key: string) => Promise<void>, true>;
|
|
44
|
+
/**
|
|
45
|
+
* Removes all keys from the storage.
|
|
46
|
+
* @since Mini Apps v9.0
|
|
47
|
+
*/
|
|
48
|
+
readonly clearFp: WithChecksFp<() => TE.TaskEither<DeviceStorageError, void>, true>;
|
|
49
|
+
/**
|
|
50
|
+
* @see clearFp
|
|
51
|
+
*/
|
|
52
|
+
readonly clear: WithChecks<() => Promise<void>, true>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ImpactHapticFeedbackStyle, NotificationHapticFeedbackType, 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 { WithVersion } from '../../fn-options/withVersion.js';
|
|
7
|
+
import { WithChecksFp, WithChecks } from '../../with-checks/withChecksFp.js';
|
|
8
|
+
type HapticFeedbackEither = E.Either<PostEventError, void>;
|
|
9
|
+
export interface HapticFeedbackOptions extends WithVersion, WithPostEvent, SharedFeatureOptions {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @since Mini Apps v6.1
|
|
13
|
+
*/
|
|
14
|
+
export declare class HapticFeedback {
|
|
15
|
+
constructor({ postEvent, isTma, version }: HapticFeedbackOptions);
|
|
16
|
+
/**
|
|
17
|
+
* Signal indicating if the component is supported.
|
|
18
|
+
*/
|
|
19
|
+
readonly isSupported: Computed<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* A method that tells if an impact occurred. The Telegram app may play the
|
|
22
|
+
* appropriate haptics based on style value passed.
|
|
23
|
+
* @param style - impact style.
|
|
24
|
+
* @since Mini Apps v6.1
|
|
25
|
+
*/
|
|
26
|
+
impactOccurredFp: WithChecksFp<(style: ImpactHapticFeedbackStyle) => HapticFeedbackEither, true>;
|
|
27
|
+
/**
|
|
28
|
+
* @see impactOccurredFp
|
|
29
|
+
*/
|
|
30
|
+
impactOccurred: WithChecks<(style: ImpactHapticFeedbackStyle) => void, true>;
|
|
31
|
+
/**
|
|
32
|
+
* A method tells that a task or action has succeeded, failed, or produced
|
|
33
|
+
* a warning. The Telegram app may play the appropriate haptics based on type
|
|
34
|
+
* value passed.
|
|
35
|
+
* @param type - notification type.
|
|
36
|
+
* @since Mini Apps v6.1
|
|
37
|
+
*/
|
|
38
|
+
notificationOccurredFp: WithChecksFp<(type: NotificationHapticFeedbackType) => HapticFeedbackEither, true>;
|
|
39
|
+
/**
|
|
40
|
+
* @see notificationOccurredFp
|
|
41
|
+
*/
|
|
42
|
+
notificationOccurred: WithChecks<(type: NotificationHapticFeedbackType) => void, true>;
|
|
43
|
+
/**
|
|
44
|
+
* A method tells that the user has changed a selection. The Telegram app may
|
|
45
|
+
* play the appropriate haptics.
|
|
46
|
+
*
|
|
47
|
+
* Do not use this feedback when the user makes or confirms a selection; use
|
|
48
|
+
* it only when the selection changes.
|
|
49
|
+
* @since Mini Apps v6.1
|
|
50
|
+
*/
|
|
51
|
+
selectionChangedFp: WithChecksFp<() => HapticFeedbackEither, true>;
|
|
52
|
+
/**
|
|
53
|
+
* @see selectionChangedFp
|
|
54
|
+
*/
|
|
55
|
+
selectionChanged: WithChecks<() => void, true>;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Computed } from '@vbotma/signals';
|
|
2
|
+
import { InitData as InitDataType } from '@vbotma/types';
|
|
3
|
+
import { either as E, option as O } from 'fp-ts';
|
|
4
|
+
export interface InitDataOptions<Err> {
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves init data from the current environment.
|
|
7
|
+
*/
|
|
8
|
+
retrieveInitData: () => E.Either<Err, O.Option<{
|
|
9
|
+
raw: string;
|
|
10
|
+
obj: InitDataType;
|
|
11
|
+
}>>;
|
|
12
|
+
}
|
|
13
|
+
export declare class InitData<Err extends Error> {
|
|
14
|
+
constructor({ retrieveInitData }: InitDataOptions<Err>);
|
|
15
|
+
private fromState;
|
|
16
|
+
private readonly _state;
|
|
17
|
+
private readonly _raw;
|
|
18
|
+
/**
|
|
19
|
+
* Complete component state.
|
|
20
|
+
*/
|
|
21
|
+
readonly state: Computed<InitDataType | undefined>;
|
|
22
|
+
/**
|
|
23
|
+
* @see InitDataType.auth_date
|
|
24
|
+
*/
|
|
25
|
+
readonly authDate: Computed<Date | undefined>;
|
|
26
|
+
/**
|
|
27
|
+
* @see InitDataType.can_send_after
|
|
28
|
+
*/
|
|
29
|
+
readonly canSendAfter: Computed<number | undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* Date after which it is allowed to call
|
|
32
|
+
* the [answerWebAppQuery](https://core.telegram.org/bots/api#answerwebappquery) method.
|
|
33
|
+
*/
|
|
34
|
+
readonly canSendAfterDate: Computed<Date | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* @see InitDataType.chat
|
|
37
|
+
*/
|
|
38
|
+
readonly chat: Computed<import('@vbotma/types').Chat | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* @see InitDataType.chat_type
|
|
41
|
+
*/
|
|
42
|
+
readonly chatType: Computed<string | undefined>;
|
|
43
|
+
/**
|
|
44
|
+
* @see InitDataType.chat_instance
|
|
45
|
+
*/
|
|
46
|
+
readonly chatInstance: Computed<string | undefined>;
|
|
47
|
+
/**
|
|
48
|
+
* @see InitDataType.hash
|
|
49
|
+
*/
|
|
50
|
+
readonly hash: Computed<string | undefined>;
|
|
51
|
+
/**
|
|
52
|
+
* @see InitDataType.query_id
|
|
53
|
+
*/
|
|
54
|
+
readonly queryId: Computed<string | undefined>;
|
|
55
|
+
/**
|
|
56
|
+
* Raw representation of init data.
|
|
57
|
+
*/
|
|
58
|
+
readonly raw: Computed<string | undefined>;
|
|
59
|
+
/**
|
|
60
|
+
* @see InitDataType.receiver
|
|
61
|
+
*/
|
|
62
|
+
readonly receiver: Computed<import('@vbotma/types').User | undefined>;
|
|
63
|
+
/**
|
|
64
|
+
* @see InitDataType.signature
|
|
65
|
+
*/
|
|
66
|
+
readonly signature: Computed<string | undefined>;
|
|
67
|
+
/**
|
|
68
|
+
* @see InitDataType.start_param
|
|
69
|
+
*/
|
|
70
|
+
readonly startParam: Computed<string | undefined>;
|
|
71
|
+
/**
|
|
72
|
+
* @see InitDataType.auth
|
|
73
|
+
*/
|
|
74
|
+
readonly auth: Computed<import('@vbotma/types').Auth | undefined>;
|
|
75
|
+
/**
|
|
76
|
+
* @see InitDataType.user
|
|
77
|
+
*/
|
|
78
|
+
readonly user: Computed<import('@vbotma/types').User | undefined>;
|
|
79
|
+
/**
|
|
80
|
+
* Restores the component state.
|
|
81
|
+
*/
|
|
82
|
+
readonly restoreFp: () => E.Either<Err, void>;
|
|
83
|
+
/**
|
|
84
|
+
* @see restoreFp
|
|
85
|
+
*/
|
|
86
|
+
readonly restore: () => void;
|
|
87
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { InvoiceStatus, RequestError } 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 { ConcurrentCallError, InvalidArgumentsError } from '../../errors.js';
|
|
6
|
+
import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
|
|
7
|
+
import { WithRequest } from '../../fn-options/withRequest.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
|
+
type InvoiceTask<E, T> = TE.TaskEither<RequestError | ConcurrentCallError | E, T>;
|
|
12
|
+
export interface InvoiceOptions extends WithVersion, WithRequest, SharedFeatureOptions {
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @since Mini Apps v6.1
|
|
16
|
+
*/
|
|
17
|
+
export declare class Invoice {
|
|
18
|
+
constructor({ version, request, isTma }: InvoiceOptions);
|
|
19
|
+
/**
|
|
20
|
+
* Signal indicating if any invoice is currently opened.
|
|
21
|
+
*/
|
|
22
|
+
readonly isOpened: Computed<boolean>;
|
|
23
|
+
/**
|
|
24
|
+
* Signal indicating if the component is supported.
|
|
25
|
+
*/
|
|
26
|
+
readonly isSupported: Computed<boolean>;
|
|
27
|
+
/**
|
|
28
|
+
* Opens an invoice using its slug or URL.
|
|
29
|
+
* @param slug - invoice slug.
|
|
30
|
+
* @param options - additional options.
|
|
31
|
+
* @since Mini Apps v6.1
|
|
32
|
+
* @example
|
|
33
|
+
* const status = await invoice.openSlug('kJNFS331');
|
|
34
|
+
*/
|
|
35
|
+
readonly openSlugFp: WithChecksFp<(slug: string, options?: AsyncOptions) => InvoiceTask<never, InvoiceStatus>, true>;
|
|
36
|
+
/**
|
|
37
|
+
* @see openSlugFp
|
|
38
|
+
*/
|
|
39
|
+
readonly openSlug: WithChecks<(slug: string, options?: AsyncOptions) => BetterPromise<InvoiceStatus>, true>;
|
|
40
|
+
/**
|
|
41
|
+
* Opens an invoice using its URL.
|
|
42
|
+
* @param url - invoice URL.
|
|
43
|
+
* @param options - additional options.
|
|
44
|
+
* @since Mini Apps v6.1
|
|
45
|
+
* @example
|
|
46
|
+
* const status = await invoice.openUrl('https://t.me/$kJNFS331');
|
|
47
|
+
*/
|
|
48
|
+
readonly openUrlFp: WithChecksFp<(url: string, options?: AsyncOptions) => (InvoiceTask<InvalidArgumentsError, InvoiceStatus>), true>;
|
|
49
|
+
/**
|
|
50
|
+
* @see openUrlFp
|
|
51
|
+
*/
|
|
52
|
+
readonly openUrl: WithChecks<(url: string, options?: AsyncOptions) => BetterPromise<InvoiceStatus>, true>;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { 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 { LocationManagerOptions, LocationManagerRequestLocationResponse, LocationManagerState } from './types.js';
|
|
6
|
+
import { AsyncOptions } from '../../types.js';
|
|
7
|
+
import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
|
|
8
|
+
/**
|
|
9
|
+
* @since Mini Apps v8.0
|
|
10
|
+
*/
|
|
11
|
+
export declare class LocationManager {
|
|
12
|
+
constructor({ version, request, postEvent, storage, isTma, isPageReload, }: LocationManagerOptions);
|
|
13
|
+
/**
|
|
14
|
+
* Complete location manager state.
|
|
15
|
+
*/
|
|
16
|
+
readonly state: Computed<LocationManagerState>;
|
|
17
|
+
/**
|
|
18
|
+
* Signal indicating whether the location data tracking is currently available.
|
|
19
|
+
*/
|
|
20
|
+
readonly isAvailable: Computed<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Signal indicating whether the user has granted the app permission to track location data.
|
|
23
|
+
*/
|
|
24
|
+
readonly isAccessGranted: Computed<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Signal indicating whether the app has previously requested permission to track location data.
|
|
27
|
+
*/
|
|
28
|
+
readonly isAccessRequested: Computed<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Signal indicating if the component is currently mounted.
|
|
31
|
+
*/
|
|
32
|
+
readonly isMounted: Computed<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* Signal indicating if the component is supported.
|
|
35
|
+
*/
|
|
36
|
+
readonly isSupported: Computed<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Opens the location access settings for bots. Useful when you need to request location access
|
|
39
|
+
* from users who haven't granted it yet.
|
|
40
|
+
*
|
|
41
|
+
* Note that this method can be called only in response to user interaction with the Mini App
|
|
42
|
+
* interface (e.g., a click inside the Mini App or on the main button).
|
|
43
|
+
* @since Mini Apps v8.0
|
|
44
|
+
*/
|
|
45
|
+
readonly openSettingsFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;
|
|
46
|
+
/**
|
|
47
|
+
* @see openSettingsFp
|
|
48
|
+
*/
|
|
49
|
+
readonly openSettings: WithChecks<() => void, true>;
|
|
50
|
+
/**
|
|
51
|
+
* Requests location data.
|
|
52
|
+
* @since Mini Apps v8.0
|
|
53
|
+
* @returns Promise with location data or null it access was not granted.
|
|
54
|
+
*/
|
|
55
|
+
readonly requestLocationFp: WithChecksFp<(options?: AsyncOptions) => (TE.TaskEither<RequestError, LocationManagerRequestLocationResponse | null>), true>;
|
|
56
|
+
/**
|
|
57
|
+
* @see requestLocationFp
|
|
58
|
+
*/
|
|
59
|
+
readonly requestLocation: WithChecks<(options?: AsyncOptions) => BetterPromise<LocationManagerRequestLocationResponse | null>, true>;
|
|
60
|
+
/**
|
|
61
|
+
* Mounts the component restoring its state.
|
|
62
|
+
* @since Mini Apps v8.0
|
|
63
|
+
*/
|
|
64
|
+
readonly mountFp: WithChecksFp<(options?: AsyncOptions) => TE.TaskEither<RequestError, void>, true>;
|
|
65
|
+
/**
|
|
66
|
+
* @see mountFp
|
|
67
|
+
*/
|
|
68
|
+
readonly mount: WithChecks<(options?: AsyncOptions) => BetterPromise<void>, true>;
|
|
69
|
+
/**
|
|
70
|
+
* Unmounts the component.
|
|
71
|
+
*/
|
|
72
|
+
readonly unmount: () => void;
|
|
73
|
+
}
|