@tma.js/sdk-react 2.0.2 → 2.1.0
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/dist/dts/SDKProvider/SDKContext.d.ts +8 -0
- package/dist/dts/SDKProvider/SDKProvider.d.ts +7 -0
- package/dist/dts/SDKProvider/SDKProvider.types.d.ts +39 -0
- package/dist/dts/createHOCs.d.ts +28 -0
- package/dist/dts/createHooks.d.ts +24 -0
- package/dist/dts/hooks-hocs/back-button.d.ts +2 -0
- package/dist/dts/hooks-hocs/biometry-manager.d.ts +2 -0
- package/dist/dts/hooks-hocs/closing-behavior.d.ts +2 -0
- package/dist/dts/hooks-hocs/cloud-storage.d.ts +2 -0
- package/dist/dts/hooks-hocs/haptic-feedback.d.ts +2 -0
- package/dist/dts/hooks-hocs/init-data.d.ts +2 -0
- package/dist/dts/hooks-hocs/invoice.d.ts +8 -0
- package/dist/dts/hooks-hocs/launch-params.d.ts +6 -0
- package/dist/dts/hooks-hocs/main-button.d.ts +2 -0
- package/dist/dts/hooks-hocs/mini-app.d.ts +2 -0
- package/dist/dts/hooks-hocs/popup.d.ts +2 -0
- package/dist/dts/hooks-hocs/qr-scanner.d.ts +2 -0
- package/dist/dts/hooks-hocs/settings-button.d.ts +2 -0
- package/dist/dts/hooks-hocs/theme-params.d.ts +2 -0
- package/dist/dts/hooks-hocs/utils.d.ts +2 -0
- package/dist/dts/hooks-hocs/viewport.d.ts +2 -0
- package/dist/dts/index.d.ts +20 -4
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +2988 -0
- package/dist/index.js.map +1 -0
- package/package.json +9 -7
- package/dist/dts/DisplayGate.d.ts +0 -24
- package/dist/dts/createHoc.d.ts +0 -12
- package/dist/dts/createHook.d.ts +0 -13
- package/dist/dts/provider/SDKContext.d.ts +0 -3
- package/dist/dts/provider/SDKProvider.d.ts +0 -6
- package/dist/dts/provider/index.d.ts +0 -7
- package/dist/dts/provider/types.d.ts +0 -30
- package/dist/dts/provider/useInitResultDynamicValue.d.ts +0 -2
- package/dist/dts/provider/useInitResultValue.d.ts +0 -7
- package/dist/dts/provider/useSDKContext.d.ts +0 -5
- package/dist/dts/provider/withSDKContext.d.ts +0 -9
- package/dist/dts/tools/back-button.d.ts +0 -8
- package/dist/dts/tools/closing-behavior.d.ts +0 -8
- package/dist/dts/tools/cloud-storage.d.ts +0 -8
- package/dist/dts/tools/haptic-feedback.d.ts +0 -8
- package/dist/dts/tools/index.d.ts +0 -17
- package/dist/dts/tools/init-data-raw.d.ts +0 -8
- package/dist/dts/tools/init-data.d.ts +0 -8
- package/dist/dts/tools/invoice.d.ts +0 -8
- package/dist/dts/tools/launch-params.d.ts +0 -13
- package/dist/dts/tools/main-button.d.ts +0 -8
- package/dist/dts/tools/mini-app.d.ts +0 -8
- package/dist/dts/tools/popup.d.ts +0 -8
- package/dist/dts/tools/post-event.d.ts +0 -8
- package/dist/dts/tools/qr-scanner.d.ts +0 -8
- package/dist/dts/tools/settings-button.d.ts +0 -8
- package/dist/dts/tools/theme-params.d.ts +0 -8
- package/dist/dts/tools/utils.d.ts +0 -8
- package/dist/dts/tools/viewport.d.ts +0 -8
- package/dist/dts/types.d.ts +0 -23
- package/dist/index.mjs +0 -138
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook to retrieve CloudStorage component.
|
|
3
|
-
*/
|
|
4
|
-
export declare const useCloudStorage: import("../createHook.js").Hook<"cloudStorage">;
|
|
5
|
-
/**
|
|
6
|
-
* HOC to wrap specified component to pass CloudStorage instance.
|
|
7
|
-
*/
|
|
8
|
-
export declare const withCloudStorage: import("../createHoc.js").Hoc<"cloudStorage">;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook to retrieve HapticFeedback component.
|
|
3
|
-
*/
|
|
4
|
-
export declare const useHapticFeedback: import("../createHook.js").Hook<"hapticFeedback">;
|
|
5
|
-
/**
|
|
6
|
-
* HOC to wrap specified component to pass HapticFeedback instance.
|
|
7
|
-
*/
|
|
8
|
-
export declare const withHapticFeedback: import("../createHoc.js").Hoc<"hapticFeedback">;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export * from './back-button.js';
|
|
2
|
-
export * from './closing-behavior.js';
|
|
3
|
-
export * from './cloud-storage.js';
|
|
4
|
-
export * from './haptic-feedback.js';
|
|
5
|
-
export * from './init-data.js';
|
|
6
|
-
export * from './init-data-raw.js';
|
|
7
|
-
export * from './invoice.js';
|
|
8
|
-
export * from './launch-params.js';
|
|
9
|
-
export * from './main-button.js';
|
|
10
|
-
export * from './mini-app.js';
|
|
11
|
-
export * from './popup.js';
|
|
12
|
-
export * from './post-event.js';
|
|
13
|
-
export * from './settings-button.js';
|
|
14
|
-
export * from './qr-scanner.js';
|
|
15
|
-
export * from './theme-params.js';
|
|
16
|
-
export * from './utils.js';
|
|
17
|
-
export * from './viewport.js';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook to retrieve init data raw representation.
|
|
3
|
-
*/
|
|
4
|
-
export declare const useInitDataRaw: import("../createHook.js").Hook<"initDataRaw">;
|
|
5
|
-
/**
|
|
6
|
-
* HOC to wrap specified component to pass init data raw representation.
|
|
7
|
-
*/
|
|
8
|
-
export declare const withInitDataRaw: import("../createHoc.js").Hoc<"initDataRaw">;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook to retrieve InitData component.
|
|
3
|
-
*/
|
|
4
|
-
export declare const useInitData: import("../createHook.js").Hook<"initData">;
|
|
5
|
-
/**
|
|
6
|
-
* HOC to wrap specified component to pass InitData instance.
|
|
7
|
-
*/
|
|
8
|
-
export declare const withInitData: import("../createHoc.js").Hoc<"initData">;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook to retrieve Invoice component.
|
|
3
|
-
*/
|
|
4
|
-
export declare const useInvoice: import("../createHook.js").Hook<"invoice">;
|
|
5
|
-
/**
|
|
6
|
-
* HOC to wrap specified component to pass Invoice instance.
|
|
7
|
-
*/
|
|
8
|
-
export declare const withInvoice: import("../createHoc.js").Hoc<"invoice">;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type LaunchParams } from '@tma.js/sdk';
|
|
2
|
-
import React, { type ComponentType } from 'react';
|
|
3
|
-
/**
|
|
4
|
-
* Hooks to retrieve launch parameters.
|
|
5
|
-
*/
|
|
6
|
-
export declare function useLaunchParams(): LaunchParams;
|
|
7
|
-
/**
|
|
8
|
-
* HOC to wrap specified component to pass launch parameters.
|
|
9
|
-
* @param Component - wrapped component.
|
|
10
|
-
*/
|
|
11
|
-
export declare function withLaunchParams<P extends {
|
|
12
|
-
launchParams?: LaunchParams;
|
|
13
|
-
}>(Component: ComponentType<P>): (props: P) => React.JSX.Element;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook to retrieve MainButton component.
|
|
3
|
-
*/
|
|
4
|
-
export declare const useMainButton: import("../createHook.js").Hook<"mainButton">;
|
|
5
|
-
/**
|
|
6
|
-
* HOC to wrap specified component to pass MainButton instance.
|
|
7
|
-
*/
|
|
8
|
-
export declare const withMainButton: import("../createHoc.js").Hoc<"mainButton">;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook to retrieve MiniApp component.
|
|
3
|
-
*/
|
|
4
|
-
export declare const useMiniApp: import("../createHook.js").Hook<"miniApp">;
|
|
5
|
-
/**
|
|
6
|
-
* HOC to wrap specified component to pass MiniApp instance.
|
|
7
|
-
*/
|
|
8
|
-
export declare const withMiniApp: import("../createHoc.js").Hoc<"miniApp">;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook to retrieve Popup component.
|
|
3
|
-
*/
|
|
4
|
-
export declare const usePopup: import("../createHook.js").Hook<"popup">;
|
|
5
|
-
/**
|
|
6
|
-
* HOC to wrap specified component to pass Popup instance.
|
|
7
|
-
*/
|
|
8
|
-
export declare const withPopup: import("../createHoc.js").Hoc<"popup">;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook to retrieve postEvent function.
|
|
3
|
-
*/
|
|
4
|
-
export declare const usePostEvent: import("../createHook.js").Hook<"postEvent">;
|
|
5
|
-
/**
|
|
6
|
-
* HOC to wrap specified component to pass postEvent function.
|
|
7
|
-
*/
|
|
8
|
-
export declare const withPostEvent: import("../createHoc.js").Hoc<"postEvent">;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook to retrieve QRScanner component.
|
|
3
|
-
*/
|
|
4
|
-
export declare const useQRScanner: import("../createHook.js").Hook<"qrScanner">;
|
|
5
|
-
/**
|
|
6
|
-
* HOC to wrap specified component to pass QRScanner instance.
|
|
7
|
-
*/
|
|
8
|
-
export declare const withQRScanner: import("../createHoc.js").Hoc<"qrScanner">;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook to retrieve SettingsButton component.
|
|
3
|
-
*/
|
|
4
|
-
export declare const useSettingsButton: import("../createHook.js").Hook<"settingsButton">;
|
|
5
|
-
/**
|
|
6
|
-
* HOC to wrap specified component to pass SettingsButton instance.
|
|
7
|
-
*/
|
|
8
|
-
export declare const withSettingsButton: import("../createHoc.js").Hoc<"settingsButton">;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook to retrieve ThemeParams component.
|
|
3
|
-
*/
|
|
4
|
-
export declare const useThemeParams: import("../createHook.js").Hook<"themeParams">;
|
|
5
|
-
/**
|
|
6
|
-
* HOC to wrap specified component to pass ThemeParams instance.
|
|
7
|
-
*/
|
|
8
|
-
export declare const withThemeParams: import("../createHoc.js").Hoc<"themeParams">;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook to retrieve Utils component.
|
|
3
|
-
*/
|
|
4
|
-
export declare const useUtils: import("../createHook.js").Hook<"utils">;
|
|
5
|
-
/**
|
|
6
|
-
* HOC to wrap specified component to pass Utils instance.
|
|
7
|
-
*/
|
|
8
|
-
export declare const withUtils: import("../createHoc.js").Hoc<"utils">;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook to retrieve Viewport component.
|
|
3
|
-
*/
|
|
4
|
-
export declare const useViewport: import("../createHook.js").Hook<"viewport">;
|
|
5
|
-
/**
|
|
6
|
-
* HOC to wrap specified component to pass Viewport instance.
|
|
7
|
-
*/
|
|
8
|
-
export declare const withViewport: import("../createHoc.js").Hoc<"viewport">;
|
package/dist/dts/types.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { InitOptions, InitResult } from '@tma.js/sdk';
|
|
2
|
-
export { InitOptions, InitResult };
|
|
3
|
-
export interface Trackable {
|
|
4
|
-
on(event: 'change', listener: () => void): () => void;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* SDK init result keys, which describe values with trackable changes.
|
|
8
|
-
*/
|
|
9
|
-
export type DynamicInitResultKey = {
|
|
10
|
-
[K in InitResultKey]-?: InitResultValue<K> extends Trackable ? K : never;
|
|
11
|
-
}[InitResultKey];
|
|
12
|
-
/**
|
|
13
|
-
* SDK init result keys, which describe static values.
|
|
14
|
-
*/
|
|
15
|
-
export type StaticInitResultKey = Exclude<InitResultKey, DynamicInitResultKey>;
|
|
16
|
-
/**
|
|
17
|
-
* SDK initialization result key.
|
|
18
|
-
*/
|
|
19
|
-
export type InitResultKey = keyof InitResult;
|
|
20
|
-
/**
|
|
21
|
-
* Returns SDK init result value type by its key.
|
|
22
|
-
*/
|
|
23
|
-
export type InitResultValue<K extends InitResultKey> = InitResult[K];
|
package/dist/index.mjs
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import c, { createContext as D, useState as a, useEffect as g, useMemo as f, useContext as E } from "react";
|
|
2
|
-
import { init as v, retrieveLaunchParams as y } from "@tma.js/sdk";
|
|
3
|
-
function r(t, e) {
|
|
4
|
-
return (n) => {
|
|
5
|
-
function o(s) {
|
|
6
|
-
const l = {
|
|
7
|
-
...s,
|
|
8
|
-
[t]: e()
|
|
9
|
-
};
|
|
10
|
-
return /* @__PURE__ */ c.createElement(n, { ...l });
|
|
11
|
-
}
|
|
12
|
-
return Object.defineProperty(o, "name", {
|
|
13
|
-
value: `With${t[0].toUpperCase()}${t.slice(1)}`
|
|
14
|
-
}), o;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
const u = D({
|
|
18
|
-
loading: !1
|
|
19
|
-
});
|
|
20
|
-
u.displayName = "SDKContext";
|
|
21
|
-
function C({ options: t, children: e }) {
|
|
22
|
-
const [n, o] = a(!1), [s, l] = a(), [h, S] = a();
|
|
23
|
-
g(() => {
|
|
24
|
-
o(!0), v({ ...t, complete: !0 }).then(S).catch(l).finally(() => o(!1));
|
|
25
|
-
}, []);
|
|
26
|
-
const B = f(() => {
|
|
27
|
-
const p = { loading: n };
|
|
28
|
-
return s && (p.error = s), h && (p.initResult = h), p;
|
|
29
|
-
}, [n, h, s]);
|
|
30
|
-
return /* @__PURE__ */ c.createElement(u.Provider, { value: B }, e);
|
|
31
|
-
}
|
|
32
|
-
function R({ options: t = {}, children: e }) {
|
|
33
|
-
const n = f(() => {
|
|
34
|
-
const o = { loading: !1 };
|
|
35
|
-
try {
|
|
36
|
-
o.initResult = v({ ...t, complete: !1 });
|
|
37
|
-
} catch (s) {
|
|
38
|
-
o.error = s;
|
|
39
|
-
}
|
|
40
|
-
return o;
|
|
41
|
-
}, []);
|
|
42
|
-
return /* @__PURE__ */ c.createElement(u.Provider, { value: n }, e);
|
|
43
|
-
}
|
|
44
|
-
function G(t) {
|
|
45
|
-
const { options: e = {}, async: n } = t;
|
|
46
|
-
return e.async || e.complete || n ? /* @__PURE__ */ c.createElement(C, { ...t }) : /* @__PURE__ */ c.createElement(R, { ...t });
|
|
47
|
-
}
|
|
48
|
-
function m() {
|
|
49
|
-
return E(u);
|
|
50
|
-
}
|
|
51
|
-
function P(t) {
|
|
52
|
-
const { initResult: e } = m();
|
|
53
|
-
if (!e)
|
|
54
|
-
throw new Error(`Unable to get init result key "${t}" as long as SDK is not initialized`);
|
|
55
|
-
return e[t];
|
|
56
|
-
}
|
|
57
|
-
function w(t) {
|
|
58
|
-
return Object.create(
|
|
59
|
-
Object.getPrototypeOf(t),
|
|
60
|
-
Object.getOwnPropertyDescriptors(t)
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
function b(t) {
|
|
64
|
-
const e = P(t), [n, o] = a(w(e));
|
|
65
|
-
return g(() => e.on("change", () => {
|
|
66
|
-
o(w(e));
|
|
67
|
-
}), [e]), n;
|
|
68
|
-
}
|
|
69
|
-
function N(t) {
|
|
70
|
-
return function(n) {
|
|
71
|
-
const o = {
|
|
72
|
-
...n,
|
|
73
|
-
sdk: m()
|
|
74
|
-
};
|
|
75
|
-
return /* @__PURE__ */ c.createElement(t, { ...o });
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
function i(t, e) {
|
|
79
|
-
return e ? () => b(t) : () => P(t);
|
|
80
|
-
}
|
|
81
|
-
const k = i("backButton", !0), J = r("backButton", k), x = i("closingBehavior", !0), X = r("closingBehavior", x), I = i("cloudStorage"), Y = r("cloudStorage", I), O = i("hapticFeedback"), Z = r("hapticFeedback", O), A = i("initData"), _ = r("initData", A), M = i("initDataRaw"), tt = r("initDataRaw", M), j = i("invoice", !0), et = r("invoice", j);
|
|
82
|
-
function F() {
|
|
83
|
-
return f(y, []);
|
|
84
|
-
}
|
|
85
|
-
function nt(t) {
|
|
86
|
-
return function(n) {
|
|
87
|
-
return /* @__PURE__ */ c.createElement(t, { ...n, launchParams: F() });
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
const H = i("mainButton", !0), ot = r("mainButton", H), K = i("miniApp", !0), rt = r("miniApp", K), L = i("popup", !0), it = r("popup", L), U = i("postEvent"), ct = r("postEvent", U), V = i("settingsButton", !0), st = r("settingsButton", V), W = i("qrScanner", !0), at = r("qrScanner", W), $ = i("themeParams", !0), ut = r("themeParams", $), q = i("utils"), lt = r("utils", q), Q = i("viewport", !0), ht = r("viewport", Q);
|
|
91
|
-
function d(t, e = {}) {
|
|
92
|
-
return typeof t == "function" ? /* @__PURE__ */ c.createElement(t, { ...e }) : t;
|
|
93
|
-
}
|
|
94
|
-
function pt(t) {
|
|
95
|
-
const { loading: e, initResult: n, error: o } = m();
|
|
96
|
-
return n ? t.children : o ? d(t.error, { error: o }) : d(e ? t.loading : t.initial);
|
|
97
|
-
}
|
|
98
|
-
export {
|
|
99
|
-
pt as DisplayGate,
|
|
100
|
-
u as SDKContext,
|
|
101
|
-
G as SDKProvider,
|
|
102
|
-
k as useBackButton,
|
|
103
|
-
x as useClosingBehavior,
|
|
104
|
-
I as useCloudStorage,
|
|
105
|
-
O as useHapticFeedback,
|
|
106
|
-
A as useInitData,
|
|
107
|
-
M as useInitDataRaw,
|
|
108
|
-
j as useInvoice,
|
|
109
|
-
F as useLaunchParams,
|
|
110
|
-
H as useMainButton,
|
|
111
|
-
K as useMiniApp,
|
|
112
|
-
L as usePopup,
|
|
113
|
-
U as usePostEvent,
|
|
114
|
-
W as useQRScanner,
|
|
115
|
-
m as useSDKContext,
|
|
116
|
-
V as useSettingsButton,
|
|
117
|
-
$ as useThemeParams,
|
|
118
|
-
q as useUtils,
|
|
119
|
-
Q as useViewport,
|
|
120
|
-
J as withBackButton,
|
|
121
|
-
X as withClosingBehavior,
|
|
122
|
-
Y as withCloudStorage,
|
|
123
|
-
Z as withHapticFeedback,
|
|
124
|
-
_ as withInitData,
|
|
125
|
-
tt as withInitDataRaw,
|
|
126
|
-
et as withInvoice,
|
|
127
|
-
nt as withLaunchParams,
|
|
128
|
-
ot as withMainButton,
|
|
129
|
-
rt as withMiniApp,
|
|
130
|
-
it as withPopup,
|
|
131
|
-
ct as withPostEvent,
|
|
132
|
-
at as withQRScanner,
|
|
133
|
-
N as withSDKContext,
|
|
134
|
-
st as withSettingsButton,
|
|
135
|
-
ut as withThemeParams,
|
|
136
|
-
lt as withUtils,
|
|
137
|
-
ht as withViewport
|
|
138
|
-
};
|