@tma.js/sdk 3.1.4 → 3.1.6
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/README.md +34 -1
- package/dist/dts/composables/AsyncMountable.d.ts +1 -1
- package/dist/dts/composables/Button.d.ts +1 -1
- package/dist/dts/composables/Mountable.d.ts +1 -1
- package/dist/dts/features/BackButton/BackButton.d.ts +1 -1
- package/dist/dts/features/Biometry/Biometry.d.ts +1 -2
- package/dist/dts/features/ClosingBehavior/ClosingBehavior.d.ts +1 -1
- package/dist/dts/features/CloudStorage/CloudStorage.d.ts +1 -1
- package/dist/dts/features/DeviceStorage/DeviceStorage.d.ts +1 -1
- package/dist/dts/features/HapticFeedback/HapticFeedback.d.ts +1 -1
- package/dist/dts/features/InitData/InitData.d.ts +1 -2
- package/dist/dts/features/Invoice/Invoice.d.ts +1 -1
- package/dist/dts/features/LocationManager/LocationManager.d.ts +1 -2
- package/dist/dts/features/MainButton/MainButton.d.ts +1 -1
- package/dist/dts/features/MiniApp/MiniApp.d.ts +1 -1
- package/dist/dts/features/Popup/Popup.d.ts +2 -2
- package/dist/dts/features/Popup/prepareParams.d.ts +1 -1
- package/dist/dts/features/QrScanner/QrScanner.d.ts +3 -4
- package/dist/dts/features/SecondaryButton/SecondaryButton.d.ts +1 -1
- package/dist/dts/features/SecureStorage/SecureStorage.d.ts +1 -1
- package/dist/dts/features/SettingsButton/SettingsButton.d.ts +1 -1
- package/dist/dts/features/SwipeBehavior/SwipeBehavior.d.ts +1 -1
- package/dist/dts/features/ThemeParams/ThemeParams.d.ts +1 -1
- package/dist/dts/features/Viewport/Viewport.d.ts +1 -2
- package/dist/dts/features/emoji-status/requestEmojiStatusAccess.d.ts +1 -1
- package/dist/dts/features/emoji-status/setEmojiStatus.d.ts +2 -2
- package/dist/dts/features/home-screen/checkHomeScreenStatus.d.ts +1 -1
- package/dist/dts/features/links/openLink.d.ts +1 -1
- package/dist/dts/features/links/openTelegramLink.d.ts +1 -1
- package/dist/dts/features/links/shareURL.d.ts +1 -1
- package/dist/dts/features/privacy/requestContact.d.ts +1 -1
- package/dist/dts/features/privacy/requestPhoneAccess.d.ts +1 -1
- package/dist/dts/features/privacy/requestWriteAccess.d.ts +1 -1
- package/dist/dts/features/uncategorized/downloadFile.d.ts +2 -2
- package/dist/dts/features/uncategorized/getCurrentTime.d.ts +1 -1
- package/dist/dts/features/uncategorized/hideKeyboard.d.ts +1 -1
- package/dist/dts/features/uncategorized/readTextFromClipboard.d.ts +1 -1
- package/dist/dts/features/uncategorized/sendData.d.ts +1 -1
- package/dist/dts/features/uncategorized/shareMessage.d.ts +1 -1
- package/dist/dts/features/uncategorized/shareStory.d.ts +2 -2
- package/dist/dts/features/uncategorized/switchInlineQuery.d.ts +2 -2
- package/dist/dts/globals/invokeCustomMethod.d.ts +1 -1
- package/dist/dts/helpers/isColorDark.d.ts +1 -1
- package/dist/dts/init.d.ts +1 -1
- package/dist/dts/with-checks/throwifyWithChecksFp.d.ts +1 -1
- package/dist/dts/with-checks/withChecksFp.d.ts +1 -3
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +3 -3
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +1703 -2081
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -28,4 +28,37 @@ the Telegram Mini Apps ecosystem.
|
|
|
28
28
|
|
|
29
29
|
Before you begin using the SDK, we highly recommend familiarizing yourself with the Telegram Mini
|
|
30
30
|
Apps [documentation](https://docs.telegram-mini-apps.com/platform/about)
|
|
31
|
-
to grasp the fundamental concepts of the platform.
|
|
31
|
+
to grasp the fundamental concepts of the platform.
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# pnpm
|
|
37
|
+
pnpm i @tma.js/sdk
|
|
38
|
+
|
|
39
|
+
# yarn
|
|
40
|
+
yarn add @tma.js/sdk
|
|
41
|
+
|
|
42
|
+
# npm
|
|
43
|
+
npm i @tma.js/sdk
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Usage Example
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { init, backButton } from '@tma.js/sdk';
|
|
50
|
+
|
|
51
|
+
// Initialize all library dependencies.
|
|
52
|
+
init();
|
|
53
|
+
|
|
54
|
+
// Mount all required components used across the application.
|
|
55
|
+
// This will lead to components' state restoration.
|
|
56
|
+
backButton.mount();
|
|
57
|
+
backButton.onClick(() => {
|
|
58
|
+
window.history.back();
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Documentation
|
|
63
|
+
|
|
64
|
+
You can find complete documentation over the library [here](https://docs.telegram-mini-apps.com/packages/tma-js-sdk).
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PostEventError, MethodName, MethodParams } from '@tma.js/bridge';
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
|
+
import { either as E } from 'fp-ts';
|
|
3
4
|
import { SharedFeatureOptions } from '../fn-options/sharedFeatureOptions.js';
|
|
4
5
|
import { WithPostEvent } from '../fn-options/withPostEvent.js';
|
|
5
6
|
import { WithStateRestore } from '../fn-options/withStateRestore.js';
|
|
6
7
|
import { WithVersion } from '../fn-options/withVersion.js';
|
|
7
8
|
import { WithChecksFp, WithChecks } from '../with-checks/withChecksFp.js';
|
|
8
|
-
import * as E from 'fp-ts/Either';
|
|
9
9
|
type ButtonEither = E.Either<PostEventError, void>;
|
|
10
10
|
type BoolFields<S> = {
|
|
11
11
|
[K in keyof S]-?: S[K] extends boolean ? K : never;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PostEventError } from '@tma.js/bridge';
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
|
+
import { either as E } from 'fp-ts';
|
|
3
4
|
import { ButtonOptions } from '../../composables/Button.js';
|
|
4
5
|
import { WithChecksFp, WithChecks } from '../../with-checks/withChecksFp.js';
|
|
5
|
-
import * as E from 'fp-ts/Either';
|
|
6
6
|
export interface BackButtonState {
|
|
7
7
|
isVisible: boolean;
|
|
8
8
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { RequestError, PostEventError, BiometryAuthRequestStatus, BiometryTokenUpdateStatus } from '@tma.js/bridge';
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
3
|
import { BetterPromise } from 'better-promises';
|
|
4
|
+
import { either as E, taskEither as TE } from 'fp-ts';
|
|
4
5
|
import { BiometryAuthenticateOptions, BiometryOptions, BiometryRequestAccessOptions, BiometryState, BiometryUpdateTokenOptions } from './types.js';
|
|
5
6
|
import { AsyncOptions } from '../../types.js';
|
|
6
7
|
import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
|
|
7
|
-
import * as E from 'fp-ts/Either';
|
|
8
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
9
8
|
type BiometryTask<T> = TE.TaskEither<RequestError, T>;
|
|
10
9
|
interface AuthenticateResult {
|
|
11
10
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PostEventError } from '@tma.js/bridge';
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
|
+
import { either as E } from 'fp-ts';
|
|
3
4
|
import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
|
|
4
5
|
import { WithPostEvent } from '../../fn-options/withPostEvent.js';
|
|
5
6
|
import { WithStateRestore } from '../../fn-options/withStateRestore.js';
|
|
6
7
|
import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
|
|
7
|
-
import * as E from 'fp-ts/Either';
|
|
8
8
|
export interface ClosingBehaviorState {
|
|
9
9
|
isConfirmationEnabled: boolean;
|
|
10
10
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { InvokeCustomMethodFpOptions, RequestError } from '@tma.js/bridge';
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
3
|
import { BetterPromise } from 'better-promises';
|
|
4
|
+
import { taskEither as TE } from 'fp-ts';
|
|
4
5
|
import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
|
|
5
6
|
import { WithInvokeCustomMethod } from '../../fn-options/withInvokeCustomMethod.js';
|
|
6
7
|
import { WithVersion } from '../../fn-options/withVersion.js';
|
|
7
8
|
import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
|
|
8
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
9
9
|
type CloudStorageTask<T> = TE.TaskEither<RequestError, T>;
|
|
10
10
|
export interface CloudStorageOptions extends WithVersion, WithInvokeCustomMethod, SharedFeatureOptions {
|
|
11
11
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { RequestError } from '@tma.js/bridge';
|
|
2
|
+
import { taskEither as TE } from 'fp-ts';
|
|
2
3
|
import { DeviceStorageMethodError } from '../../errors.js';
|
|
3
4
|
import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
|
|
4
5
|
import { WithCreateRequestId } from '../../fn-options/withCreateRequestId.js';
|
|
5
6
|
import { WithRequest } from '../../fn-options/withRequest.js';
|
|
6
7
|
import { WithVersion } from '../../fn-options/withVersion.js';
|
|
7
8
|
import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
|
|
8
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
9
9
|
export type DeviceStorageError = RequestError | DeviceStorageMethodError;
|
|
10
10
|
export interface DeviceStorageOptions extends SharedFeatureOptions, WithVersion, WithRequest, WithCreateRequestId {
|
|
11
11
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ImpactHapticFeedbackStyle, NotificationHapticFeedbackType, PostEventError } from '@tma.js/bridge';
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
|
+
import { either as E } from 'fp-ts';
|
|
3
4
|
import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
|
|
4
5
|
import { WithPostEvent } from '../../fn-options/withPostEvent.js';
|
|
5
6
|
import { WithVersion } from '../../fn-options/withVersion.js';
|
|
6
7
|
import { WithChecksFp, WithChecks } from '../../with-checks/withChecksFp.js';
|
|
7
|
-
import * as E from 'fp-ts/Either';
|
|
8
8
|
type HapticFeedbackEither = E.Either<PostEventError, void>;
|
|
9
9
|
export interface HapticFeedbackOptions extends WithVersion, WithPostEvent, SharedFeatureOptions {
|
|
10
10
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Computed } from '@tma.js/signals';
|
|
2
2
|
import { InitData as InitDataType } from '@tma.js/types';
|
|
3
|
-
import
|
|
4
|
-
import * as O from 'fp-ts/Option';
|
|
3
|
+
import { either as E, option as O } from 'fp-ts';
|
|
5
4
|
export interface InitDataOptions<Err> {
|
|
6
5
|
/**
|
|
7
6
|
* Retrieves init data from the current environment.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { InvoiceStatus, RequestError } from '@tma.js/bridge';
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
3
|
import { BetterPromise } from 'better-promises';
|
|
4
|
+
import { taskEither as TE } from 'fp-ts';
|
|
4
5
|
import { ConcurrentCallError, InvalidArgumentsError } from '../../errors.js';
|
|
5
6
|
import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
|
|
6
7
|
import { WithRequest } from '../../fn-options/withRequest.js';
|
|
7
8
|
import { WithVersion } from '../../fn-options/withVersion.js';
|
|
8
9
|
import { AsyncOptions } from '../../types.js';
|
|
9
10
|
import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
|
|
10
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
11
11
|
type InvoiceTask<E, T> = TE.TaskEither<RequestError | ConcurrentCallError | E, T>;
|
|
12
12
|
export interface InvoiceOptions extends WithVersion, WithRequest, SharedFeatureOptions {
|
|
13
13
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { RequestError, PostEventError } from '@tma.js/bridge';
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
3
|
import { BetterPromise } from 'better-promises';
|
|
4
|
+
import { either as E, taskEither as TE } from 'fp-ts';
|
|
4
5
|
import { LocationManagerOptions, LocationManagerRequestLocationResponse, LocationManagerState } from './types.js';
|
|
5
6
|
import { AsyncOptions } from '../../types.js';
|
|
6
7
|
import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
|
|
7
|
-
import * as E from 'fp-ts/Either';
|
|
8
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
9
8
|
/**
|
|
10
9
|
* @since Mini Apps v8.0
|
|
11
10
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PostEventError } from '@tma.js/bridge';
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
3
|
import { RGB } from '@tma.js/types';
|
|
4
|
+
import { either as E } from 'fp-ts';
|
|
4
5
|
import { ButtonOptions } from '../../composables/Button.js';
|
|
5
6
|
import { MaybeAccessor } from '../../types.js';
|
|
6
7
|
import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
|
|
7
|
-
import * as E from 'fp-ts/Either';
|
|
8
8
|
type MainButtonEither = E.Either<PostEventError, void>;
|
|
9
9
|
export interface MainButtonState {
|
|
10
10
|
isVisible: boolean;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { PostEventError, EventPayload } from '@tma.js/bridge';
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
3
|
import { KnownThemeParamsKey, RGB, ThemeParams } from '@tma.js/types';
|
|
4
|
+
import { either as E } from 'fp-ts';
|
|
4
5
|
import { CSSVarsBoundError, UnknownThemeParamsKeyError } from '../../errors.js';
|
|
5
6
|
import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
|
|
6
7
|
import { WithPostEvent } from '../../fn-options/withPostEvent.js';
|
|
7
8
|
import { WithStateRestore } from '../../fn-options/withStateRestore.js';
|
|
8
9
|
import { WithVersion } from '../../fn-options/withVersion.js';
|
|
9
10
|
import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
|
|
10
|
-
import * as E from 'fp-ts/Either';
|
|
11
11
|
type AnyColor = RGB | KnownThemeParamsKey | string;
|
|
12
12
|
export interface MiniAppState {
|
|
13
13
|
bgColor: AnyColor;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { RequestError } from '@tma.js/bridge';
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
3
|
import { BetterPromise } from 'better-promises';
|
|
4
|
+
import { taskEither as TE } from 'fp-ts';
|
|
4
5
|
import { ConcurrentCallError, InvalidArgumentsError } from '../../errors.js';
|
|
5
6
|
import { ShowOptions } from './types.js';
|
|
6
7
|
import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
|
|
7
8
|
import { WithRequest } from '../../fn-options/withRequest.js';
|
|
8
9
|
import { WithVersion } from '../../fn-options/withVersion.js';
|
|
9
10
|
import { WithChecksFp, WithChecks } from '../../with-checks/withChecksFp.js';
|
|
10
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
11
11
|
export interface PopupOptions extends SharedFeatureOptions, WithVersion, WithRequest {
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
@@ -34,7 +34,7 @@ export declare class Popup {
|
|
|
34
34
|
* @param options - popup parameters.
|
|
35
35
|
* @since Mini Apps v6.2
|
|
36
36
|
* @example
|
|
37
|
-
* pipe(
|
|
37
|
+
* fn.pipe(
|
|
38
38
|
* popup.showFp({
|
|
39
39
|
* title: 'Confirm action',
|
|
40
40
|
* message: 'Do you really want to buy this burger?',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PopupParams } from '@tma.js/bridge';
|
|
2
|
+
import { either as E } from 'fp-ts';
|
|
2
3
|
import { InvalidArgumentsError } from '../../errors.js';
|
|
3
4
|
import { ShowOptions } from './types.js';
|
|
4
|
-
import * as E from 'fp-ts/Either';
|
|
5
5
|
/**
|
|
6
6
|
* Prepares popup parameters before sending them to native app.
|
|
7
7
|
* @param params - popup parameters.
|
|
@@ -2,13 +2,12 @@ import { PostEventError } from '@tma.js/bridge';
|
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
3
|
import { BetterTaskEitherError } from '@tma.js/toolkit';
|
|
4
4
|
import { BetterPromise } from 'better-promises';
|
|
5
|
+
import { either as E, taskEither as TE } from 'fp-ts';
|
|
5
6
|
import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
|
|
6
7
|
import { WithPostEvent } from '../../fn-options/withPostEvent.js';
|
|
7
8
|
import { WithVersion } from '../../fn-options/withVersion.js';
|
|
8
9
|
import { AsyncOptions } from '../../types.js';
|
|
9
10
|
import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
|
|
10
|
-
import * as E from 'fp-ts/Either';
|
|
11
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
12
11
|
export interface QrScannerOptions extends WithVersion, WithPostEvent, SharedFeatureOptions {
|
|
13
12
|
/**
|
|
14
13
|
* A function to add a listener to the event determining if the QR scanner
|
|
@@ -66,7 +65,7 @@ export declare class QrScanner {
|
|
|
66
65
|
* @returns A promise with QR content presented as string or undefined if the scanner was closed.
|
|
67
66
|
* @since Mini Apps v6.4
|
|
68
67
|
* @example
|
|
69
|
-
* pipe(
|
|
68
|
+
* fn.pipe(
|
|
70
69
|
* qrScanner.captureFp({
|
|
71
70
|
* capture(scannedQr) {
|
|
72
71
|
* return scannedQr === 'any expected by me qr';
|
|
@@ -105,7 +104,7 @@ export declare class QrScanner {
|
|
|
105
104
|
* const qr = await qrScanner.open({ text: 'Scan any QR' });
|
|
106
105
|
* }
|
|
107
106
|
* @example
|
|
108
|
-
* pipe(
|
|
107
|
+
* fn.pipe(
|
|
109
108
|
* qrScanner.openFp({
|
|
110
109
|
* onCaptured(scannedQr) {
|
|
111
110
|
* if (scannedQr === 'any expected by me qr') {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PostEventError, SecondaryButtonPosition } from '@tma.js/bridge';
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
3
|
import { RGB } from '@tma.js/types';
|
|
4
|
+
import { either as E } from 'fp-ts';
|
|
4
5
|
import { ButtonOptions } from '../../composables/Button.js';
|
|
5
6
|
import { MaybeAccessor } from '../../types.js';
|
|
6
7
|
import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
|
|
7
|
-
import * as E from 'fp-ts/Either';
|
|
8
8
|
type SecondaryButtonEither = E.Either<PostEventError, void>;
|
|
9
9
|
export interface SecondaryButtonState {
|
|
10
10
|
isVisible: boolean;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { RequestError } from '@tma.js/bridge';
|
|
2
|
+
import { taskEither as TE } from 'fp-ts';
|
|
2
3
|
import { SecureStorageMethodError } from '../../errors.js';
|
|
3
4
|
import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
|
|
4
5
|
import { WithCreateRequestId } from '../../fn-options/withCreateRequestId.js';
|
|
5
6
|
import { WithRequest } from '../../fn-options/withRequest.js';
|
|
6
7
|
import { WithVersion } from '../../fn-options/withVersion.js';
|
|
7
8
|
import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
|
|
8
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
9
9
|
export type SecureStorageError = RequestError | SecureStorageMethodError;
|
|
10
10
|
export interface SecureStorageOptions extends SharedFeatureOptions, WithVersion, WithRequest, WithCreateRequestId {
|
|
11
11
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PostEventError } from '@tma.js/bridge';
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
|
+
import { either as E } from 'fp-ts';
|
|
3
4
|
import { ButtonOptions } from '../../composables/Button.js';
|
|
4
5
|
import { WithChecksFp, WithChecks } from '../../with-checks/withChecksFp.js';
|
|
5
|
-
import * as E from 'fp-ts/Either';
|
|
6
6
|
export interface SettingsButtonState {
|
|
7
7
|
isVisible: boolean;
|
|
8
8
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PostEventError } from '@tma.js/bridge';
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
|
+
import { either as E } from 'fp-ts';
|
|
3
4
|
import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
|
|
4
5
|
import { WithPostEvent } from '../../fn-options/withPostEvent.js';
|
|
5
6
|
import { WithStateRestore } from '../../fn-options/withStateRestore.js';
|
|
6
7
|
import { WithVersion } from '../../fn-options/withVersion.js';
|
|
7
8
|
import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
|
|
8
|
-
import * as E from 'fp-ts/Either';
|
|
9
9
|
export interface SwipeBehaviorState {
|
|
10
10
|
isVerticalEnabled: boolean;
|
|
11
11
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { EventListener } from '@tma.js/bridge';
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
3
|
import { ThemeParams as ThemeParamsType, RGB } from '@tma.js/types';
|
|
4
|
+
import { either as E } from 'fp-ts';
|
|
4
5
|
import { CSSVarsBoundError } from '../../errors.js';
|
|
5
6
|
import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
|
|
6
7
|
import { WithStateRestore } from '../../fn-options/withStateRestore.js';
|
|
7
8
|
import { MaybeAccessor } from '../../types.js';
|
|
8
9
|
import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
|
|
9
|
-
import * as E from 'fp-ts/Either';
|
|
10
10
|
export type ThemeParamsState = ThemeParamsType;
|
|
11
11
|
export interface ThemeParamsOptions extends WithStateRestore<ThemeParamsState>, SharedFeatureOptions {
|
|
12
12
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SafeAreaInsets, EventListener, RequestError, PostEventError } from '@tma.js/bridge';
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
3
|
import { BetterPromise } from 'better-promises';
|
|
4
|
+
import { either as E, taskEither as TE } from 'fp-ts';
|
|
4
5
|
import { CSSVarsBoundError, FullscreenFailedError } from '../../errors.js';
|
|
5
6
|
import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
|
|
6
7
|
import { WithPostEvent } from '../../fn-options/withPostEvent.js';
|
|
@@ -9,8 +10,6 @@ import { WithStateRestore } from '../../fn-options/withStateRestore.js';
|
|
|
9
10
|
import { WithVersion } from '../../fn-options/withVersion.js';
|
|
10
11
|
import { AsyncOptions } from '../../types.js';
|
|
11
12
|
import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
|
|
12
|
-
import * as E from 'fp-ts/Either';
|
|
13
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
14
13
|
type FullscreenError = FullscreenFailedError | RequestError;
|
|
15
14
|
type ViewportChangedEventListener = EventListener<'viewport_changed'>;
|
|
16
15
|
type FullscreenChangedEventListener = EventListener<'fullscreen_changed'>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EmojiStatusAccessRequestedStatus, RequestError } from '@tma.js/bridge';
|
|
2
|
+
import { taskEither as TE } from 'fp-ts';
|
|
2
3
|
import { AsyncOptions } from '../../types.js';
|
|
3
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
4
4
|
/**
|
|
5
5
|
* Shows a native popup requesting permission for the bot to manage user's emoji status.
|
|
6
6
|
* @param options - additional options.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RequestError } from '@tma.js/bridge';
|
|
2
|
+
import { taskEither as TE } from 'fp-ts';
|
|
2
3
|
import { SetEmojiStatusError } from '../../errors.js';
|
|
3
4
|
import { AsyncOptions } from '../../types.js';
|
|
4
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
5
5
|
export interface SetEmojiStatusOptions extends AsyncOptions {
|
|
6
6
|
duration?: number;
|
|
7
7
|
}
|
|
@@ -11,7 +11,7 @@ export interface SetEmojiStatusOptions extends AsyncOptions {
|
|
|
11
11
|
* @param options - additional options.
|
|
12
12
|
* @since Mini Apps v8.0
|
|
13
13
|
* @example
|
|
14
|
-
* pipe(
|
|
14
|
+
* fn.pipe(
|
|
15
15
|
* setEmojiStatusFp('5361800828313167608'),
|
|
16
16
|
* TE.match(error => {
|
|
17
17
|
* console.error('Error occurred', error);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HomeScreenStatus, RequestError } from '@tma.js/bridge';
|
|
2
|
+
import { taskEither as TE } from 'fp-ts';
|
|
2
3
|
import { AsyncOptions } from '../../types.js';
|
|
3
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
4
4
|
/**
|
|
5
5
|
* Sends a request to the native Telegram application to check if the current mini
|
|
6
6
|
* application is added to the device's home screen.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OpenLinkBrowser, PostEventError } from '@tma.js/bridge';
|
|
2
|
+
import { either as E } from 'fp-ts';
|
|
2
3
|
import { InvalidArgumentsError } from '../../errors.js';
|
|
3
|
-
import * as E from 'fp-ts/Either';
|
|
4
4
|
export interface OpenLinkOptions {
|
|
5
5
|
/**
|
|
6
6
|
* Attempts to use the instant view mode.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PostEventError } from '@tma.js/bridge';
|
|
2
|
+
import { either as E } from 'fp-ts';
|
|
2
3
|
import { InvalidArgumentsError } from '../../errors.js';
|
|
3
|
-
import * as E from 'fp-ts/Either';
|
|
4
4
|
export type OpenTelegramLinkError = PostEventError | InvalidArgumentsError;
|
|
5
5
|
/**
|
|
6
6
|
* Opens a Telegram link inside the Telegram app. The function expects passing a link in a full
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BetterTaskEitherError } from '@tma.js/toolkit';
|
|
2
|
+
import { taskEither as TE } from 'fp-ts';
|
|
2
3
|
import { AccessDeniedError, ValidationError } from '../../errors.js';
|
|
3
4
|
import { InvokeCustomMethodError } from '../../fn-options/withInvokeCustomMethod.js';
|
|
4
5
|
import { AsyncOptions } from '../../types.js';
|
|
5
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
6
6
|
/**
|
|
7
7
|
* Requested contact information.
|
|
8
8
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PhoneRequestedStatus, RequestError } from '@tma.js/bridge';
|
|
2
|
+
import { taskEither as TE } from 'fp-ts';
|
|
2
3
|
import { AsyncOptions } from '../../types.js';
|
|
3
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
4
4
|
export type RequestPhoneAccessError = RequestError;
|
|
5
5
|
/**
|
|
6
6
|
* Requests current user phone access. Method returns promise, which resolves
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WriteAccessRequestedStatus, RequestError } from '@tma.js/bridge';
|
|
2
|
+
import { taskEither as TE } from 'fp-ts';
|
|
2
3
|
import { AsyncOptions } from '../../types.js';
|
|
3
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
4
4
|
export type RequestWriteAccessError = RequestError;
|
|
5
5
|
/**
|
|
6
6
|
* Requests write message access to the current user.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RequestError } from '@tma.js/bridge';
|
|
2
|
+
import { taskEither as TE } from 'fp-ts';
|
|
2
3
|
import { AccessDeniedError } from '../../errors.js';
|
|
3
4
|
import { AsyncOptions } from '../../types.js';
|
|
4
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
5
5
|
export type DownloadFileError = RequestError | AccessDeniedError;
|
|
6
6
|
/**
|
|
7
7
|
* Displays a native popup prompting the user to download a file.
|
|
@@ -10,7 +10,7 @@ export type DownloadFileError = RequestError | AccessDeniedError;
|
|
|
10
10
|
* @param options - additional request execution options.
|
|
11
11
|
* @since Mini Apps v8.0
|
|
12
12
|
* @example
|
|
13
|
-
* pipe(
|
|
13
|
+
* fn.pipe(
|
|
14
14
|
* downloadFileFp('https://telegram.org/js/telegram-web-app.js', 'telegram-sdk.js'),
|
|
15
15
|
* TE.map(() => {
|
|
16
16
|
* console.log('Downloading');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { taskEither as TE } from 'fp-ts';
|
|
1
2
|
import { ValidationError } from '../../errors.js';
|
|
2
3
|
import { InvokeCustomMethodError } from '../../fn-options/withInvokeCustomMethod.js';
|
|
3
4
|
import { AsyncOptions } from '../../types.js';
|
|
4
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
5
5
|
export type GetCurrentTimeError = InvokeCustomMethodError | ValidationError;
|
|
6
6
|
/**
|
|
7
7
|
* @returns The current time according to the Telegram server time.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PostEventError } from '@tma.js/bridge';
|
|
2
|
-
import
|
|
2
|
+
import { either as E } from 'fp-ts';
|
|
3
3
|
export type HideKeyboardError = PostEventError;
|
|
4
4
|
/**
|
|
5
5
|
* Hides the on-screen keyboard, if it is currently visible. Does nothing if the keyboard is
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RequestError } from '@tma.js/bridge';
|
|
2
|
+
import { taskEither as TE } from 'fp-ts';
|
|
2
3
|
import { AsyncOptions } from '../../types.js';
|
|
3
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
4
4
|
export type ReadTextFromClipboardError = RequestError;
|
|
5
5
|
/**
|
|
6
6
|
* Reads a text from the clipboard and returns a `string` or `null`. `null` is returned
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PostEventError } from '@tma.js/bridge';
|
|
2
|
+
import { either as E } from 'fp-ts';
|
|
2
3
|
import { InvalidArgumentsError } from '../../errors.js';
|
|
3
|
-
import * as E from 'fp-ts/Either';
|
|
4
4
|
export type SendDataError = PostEventError | InvalidArgumentsError;
|
|
5
5
|
/**
|
|
6
6
|
* Sends data to the bot.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RequestError } from '@tma.js/bridge';
|
|
2
|
+
import { taskEither as TE } from 'fp-ts';
|
|
2
3
|
import { ShareMessageError } from '../../errors.js';
|
|
3
4
|
import { AsyncOptions } from '../../types.js';
|
|
4
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
5
5
|
export type ShareMessageFnError = RequestError | ShareMessageError;
|
|
6
6
|
/**
|
|
7
7
|
* Opens a dialog allowing the user to share a message provided by the bot.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PostEventError } from '@tma.js/bridge';
|
|
2
|
-
import
|
|
2
|
+
import { either as E } from 'fp-ts';
|
|
3
3
|
export interface ShareStoryOptions {
|
|
4
4
|
/**
|
|
5
5
|
* The caption to be added to the media.
|
|
@@ -28,7 +28,7 @@ export type ShareStoryError = PostEventError;
|
|
|
28
28
|
* Opens the native story editor.
|
|
29
29
|
* @since Mini Apps v7.8
|
|
30
30
|
* @example
|
|
31
|
-
* pipe(
|
|
31
|
+
* fn.pipe(
|
|
32
32
|
* shareStory('https://example.com/background.png', {
|
|
33
33
|
* text: 'Look at this cool group!',
|
|
34
34
|
* widgetLink: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PostEventError, SwitchInlineQueryChatType } from '@tma.js/bridge';
|
|
2
|
-
import
|
|
2
|
+
import { either as E } from 'fp-ts';
|
|
3
3
|
export type SwitchInlineQueryError = PostEventError;
|
|
4
4
|
/**
|
|
5
5
|
* Inserts the bot's username and the specified inline query in the current chat's input field.
|
|
@@ -12,7 +12,7 @@ export type SwitchInlineQueryError = PostEventError;
|
|
|
12
12
|
* empty list.
|
|
13
13
|
* @since Mini Apps v6.7
|
|
14
14
|
* @example
|
|
15
|
-
* pipe(
|
|
15
|
+
* fn.pipe(
|
|
16
16
|
* switchInlineQuery('my query goes here', ['users']),
|
|
17
17
|
* E.match(error => {
|
|
18
18
|
* console.error('Something went wrong', error);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RequestError, CustomMethodName, CustomMethodParams, InvokeCustomMethodOptions } from '@tma.js/bridge';
|
|
2
|
-
import
|
|
2
|
+
import { taskEither as TE } from 'fp-ts';
|
|
3
3
|
/**
|
|
4
4
|
* Invokes known custom method. Returns method execution result.
|
|
5
5
|
* @param method - method name.
|
package/dist/dts/init.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RetrieveLaunchParamsError, PostEventError, PostEventFpFn } from '@tma.js/bridge';
|
|
2
2
|
import { Version, ThemeParams } from '@tma.js/types';
|
|
3
|
-
import
|
|
3
|
+
import { either as E } from 'fp-ts';
|
|
4
4
|
export interface InitOptions {
|
|
5
5
|
/**
|
|
6
6
|
* True if SDK should accept styles sent from the Telegram application.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { AnyFn } from '@tma.js/toolkit';
|
|
2
2
|
import { WithChecksFp, WithChecks } from './withChecksFp.js';
|
|
3
|
-
export declare function throwifyWithChecksFp<Fn extends AnyFn, HasSupportCheck extends boolean, SupportsMapKeySchema extends string>(
|
|
3
|
+
export declare function throwifyWithChecksFp<Fn extends AnyFn, HasSupportCheck extends boolean, SupportsMapKeySchema extends string>(fn_: WithChecksFp<Fn, HasSupportCheck, SupportsMapKeySchema>): WithChecks<Fn, HasSupportCheck, SupportsMapKeySchema>;
|
|
@@ -2,11 +2,9 @@ import { MethodName, MethodNameWithVersionedParams, MethodVersionedParams } from
|
|
|
2
2
|
import { Computed } from '@tma.js/signals';
|
|
3
3
|
import { If, IsNever, AnyFnAnyEither, RightOfReturn, LeftOfReturn, MaybeMonadReturnTypeToCommon, MaybeCommonReturnTypeToMonad, AnyFn } from '@tma.js/toolkit';
|
|
4
4
|
import { Version } from '@tma.js/types';
|
|
5
|
+
import { either as E, option as O, taskEither as TE } from 'fp-ts';
|
|
5
6
|
import { FunctionUnavailableError } from '../errors.js';
|
|
6
7
|
import { MaybeAccessor } from '../types.js';
|
|
7
|
-
import * as E from 'fp-ts/Either';
|
|
8
|
-
import * as O from 'fp-ts/Option';
|
|
9
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
10
8
|
type IfReturnsTask<Fn extends AnyFnAnyEither, A, B> = ReturnType<Fn> extends TE.TaskEither<any, any> ? A : B;
|
|
11
9
|
type OptionsBasedRequires<O extends WithChecksOptions<any>> = O extends {
|
|
12
10
|
requires: any;
|