@tonconnect/ui 2.0.0-beta.7 → 2.0.0-beta.9
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/tonconnect-ui.min.js +207 -207
- package/dist/tonconnect-ui.min.js.map +1 -1
- package/lib/index.cjs +33 -30
- package/lib/index.cjs.map +1 -1
- package/lib/index.mjs +33 -30
- package/lib/index.mjs.map +1 -1
- package/package.json +2 -2
package/lib/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
42
42
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
43
43
|
});
|
|
44
44
|
};
|
|
45
|
-
var _a;
|
|
45
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
46
46
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
47
47
|
const sdk = require("@tonconnect/sdk");
|
|
48
48
|
const UAParser = require("ua-parser-js");
|
|
@@ -1777,13 +1777,19 @@ try {
|
|
|
1777
1777
|
} catch (e2) {
|
|
1778
1778
|
}
|
|
1779
1779
|
let tmaPlatform = "unknown";
|
|
1780
|
-
if (initParams.tgWebAppPlatform) {
|
|
1781
|
-
tmaPlatform = initParams.tgWebAppPlatform;
|
|
1780
|
+
if (initParams == null ? void 0 : initParams.tgWebAppPlatform) {
|
|
1781
|
+
tmaPlatform = (_a = initParams.tgWebAppPlatform) != null ? _a : "unknown";
|
|
1782
|
+
}
|
|
1783
|
+
if (tmaPlatform === "unknown") {
|
|
1784
|
+
tmaPlatform = (_d = (_c = (_b = window == null ? void 0 : window.Telegram) == null ? void 0 : _b.WebApp) == null ? void 0 : _c.platform) != null ? _d : "unknown";
|
|
1782
1785
|
}
|
|
1783
1786
|
let webAppVersion = "6.0";
|
|
1784
|
-
if (initParams.tgWebAppVersion) {
|
|
1787
|
+
if (initParams == null ? void 0 : initParams.tgWebAppVersion) {
|
|
1785
1788
|
webAppVersion = initParams.tgWebAppVersion;
|
|
1786
1789
|
}
|
|
1790
|
+
if (!webAppVersion) {
|
|
1791
|
+
webAppVersion = (_g = (_f = (_e = window == null ? void 0 : window.Telegram) == null ? void 0 : _e.WebApp) == null ? void 0 : _f.version) != null ? _g : "6.0";
|
|
1792
|
+
}
|
|
1787
1793
|
function isTmaPlatform(...platforms) {
|
|
1788
1794
|
return platforms.includes(tmaPlatform);
|
|
1789
1795
|
}
|
|
@@ -2012,7 +2018,7 @@ function isNodeJs() {
|
|
|
2012
2018
|
return typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
2013
2019
|
}
|
|
2014
2020
|
function getUserAgent() {
|
|
2015
|
-
var _a2,
|
|
2021
|
+
var _a2, _b2;
|
|
2016
2022
|
const results = new UAParser__default.default().getResult();
|
|
2017
2023
|
const osName = (_a2 = results.os.name) == null ? void 0 : _a2.toLowerCase();
|
|
2018
2024
|
let os;
|
|
@@ -2033,7 +2039,7 @@ function getUserAgent() {
|
|
|
2033
2039
|
os = "windows";
|
|
2034
2040
|
break;
|
|
2035
2041
|
}
|
|
2036
|
-
const browserName = (
|
|
2042
|
+
const browserName = (_b2 = results.browser.name) == null ? void 0 : _b2.toLowerCase();
|
|
2037
2043
|
let browser;
|
|
2038
2044
|
switch (true) {
|
|
2039
2045
|
case browserName === "chrome":
|
|
@@ -2063,18 +2069,15 @@ function redirectToTelegram(universalLink, options) {
|
|
|
2063
2069
|
}
|
|
2064
2070
|
if (isInTMA()) {
|
|
2065
2071
|
if (isTmaPlatform("ios", "android")) {
|
|
2066
|
-
options.returnStrategy = "
|
|
2072
|
+
options.returnStrategy = "back";
|
|
2067
2073
|
options.twaReturnUrl = void 0;
|
|
2068
2074
|
sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
|
|
2069
2075
|
} else if (isTmaPlatform("macos", "tdesktop")) {
|
|
2070
|
-
if (!options.twaReturnUrl) {
|
|
2071
|
-
throw new TonConnectUIError("`twaReturnUrl` is required for this platform");
|
|
2072
|
-
}
|
|
2073
2076
|
sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
|
|
2074
2077
|
} else if (isTmaPlatform("weba")) {
|
|
2075
2078
|
sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
|
|
2076
2079
|
} else if (isTmaPlatform("web")) {
|
|
2077
|
-
options.returnStrategy = "
|
|
2080
|
+
options.returnStrategy = "back";
|
|
2078
2081
|
options.twaReturnUrl = void 0;
|
|
2079
2082
|
sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
|
|
2080
2083
|
} else {
|
|
@@ -2082,7 +2085,7 @@ function redirectToTelegram(universalLink, options) {
|
|
|
2082
2085
|
}
|
|
2083
2086
|
} else {
|
|
2084
2087
|
if (isOS("ios", "android")) {
|
|
2085
|
-
options.returnStrategy = "
|
|
2088
|
+
options.returnStrategy = "none";
|
|
2086
2089
|
openLinkBlank(addReturnStrategy(directLinkUrl.toString(), options.returnStrategy));
|
|
2087
2090
|
} else if (isOS("macos", "windows", "linux")) {
|
|
2088
2091
|
options.returnStrategy = "none";
|
|
@@ -3266,10 +3269,10 @@ function clickOutside$1(el, accessor) {
|
|
|
3266
3269
|
}
|
|
3267
3270
|
function escPressed(_, accessor) {
|
|
3268
3271
|
const onKeyPress = (e2) => {
|
|
3269
|
-
var _a2,
|
|
3272
|
+
var _a2, _b2;
|
|
3270
3273
|
if (e2.key === "Escape") {
|
|
3271
3274
|
(_a2 = document.activeElement) == null ? void 0 : _a2.blur();
|
|
3272
|
-
(
|
|
3275
|
+
(_b2 = accessor()) == null ? void 0 : _b2();
|
|
3273
3276
|
}
|
|
3274
3277
|
};
|
|
3275
3278
|
document.body.addEventListener("keydown", onKeyPress);
|
|
@@ -6575,7 +6578,7 @@ const ScrollDivider = styled.div`
|
|
|
6575
6578
|
margin: 0;
|
|
6576
6579
|
}
|
|
6577
6580
|
`;
|
|
6578
|
-
const [windowHeight, setWindowHeight] = createSignal(((
|
|
6581
|
+
const [windowHeight, setWindowHeight] = createSignal(((_h = getWindow$1()) == null ? void 0 : _h.innerHeight) || 0);
|
|
6579
6582
|
if (getWindow$1()) {
|
|
6580
6583
|
window.addEventListener("resize", () => setWindowHeight(window.innerHeight));
|
|
6581
6584
|
}
|
|
@@ -8015,8 +8018,8 @@ const AccountButton = () => {
|
|
|
8015
8018
|
}), null);
|
|
8016
8019
|
insert(_el$, createComponent(NotificationsStyled, {}), null);
|
|
8017
8020
|
createRenderEffect((_p$) => {
|
|
8018
|
-
var _a2,
|
|
8019
|
-
const _v$ = position.strategy, _v$2 = `${(_a2 = position.y) != null ? _a2 : 0}px`, _v$3 = `${(
|
|
8021
|
+
var _a2, _b2;
|
|
8022
|
+
const _v$ = position.strategy, _v$2 = `${(_a2 = position.y) != null ? _a2 : 0}px`, _v$3 = `${(_b2 = position.x) != null ? _b2 : 0}px`;
|
|
8020
8023
|
_v$ !== _p$._v$ && _el$.style.setProperty("position", _p$._v$ = _v$);
|
|
8021
8024
|
_v$2 !== _p$._v$2 && _el$.style.setProperty("top", _p$._v$2 = _v$2);
|
|
8022
8025
|
_v$3 !== _p$._v$3 && _el$.style.setProperty("left", _p$._v$3 = _v$3);
|
|
@@ -10189,12 +10192,12 @@ class TonConnectUI {
|
|
|
10189
10192
|
return __spreadValues(__spreadValues({}, this.connector.wallet), this.walletInfo);
|
|
10190
10193
|
}
|
|
10191
10194
|
set uiOptions(options) {
|
|
10192
|
-
var _a2,
|
|
10195
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
10193
10196
|
this.checkButtonRootExist(options.buttonRootId);
|
|
10194
10197
|
this.actionsConfiguration = options.actionsConfiguration;
|
|
10195
10198
|
if ((_a2 = options.uiPreferences) == null ? void 0 : _a2.theme) {
|
|
10196
|
-
if (((
|
|
10197
|
-
(
|
|
10199
|
+
if (((_b2 = options.uiPreferences) == null ? void 0 : _b2.theme) !== "SYSTEM") {
|
|
10200
|
+
(_c2 = this.systemThemeChangeUnsubscribe) == null ? void 0 : _c2.call(this);
|
|
10198
10201
|
setTheme(options.uiPreferences.theme, options.uiPreferences.colorsSet);
|
|
10199
10202
|
} else {
|
|
10200
10203
|
setTheme(getSystemTheme(), options.uiPreferences.colorsSet);
|
|
@@ -10203,19 +10206,19 @@ class TonConnectUI {
|
|
|
10203
10206
|
}
|
|
10204
10207
|
}
|
|
10205
10208
|
} else {
|
|
10206
|
-
if ((
|
|
10209
|
+
if ((_d2 = options.uiPreferences) == null ? void 0 : _d2.colorsSet) {
|
|
10207
10210
|
setColors(options.uiPreferences.colorsSet);
|
|
10208
10211
|
}
|
|
10209
10212
|
}
|
|
10210
|
-
if ((
|
|
10213
|
+
if ((_e2 = options.uiPreferences) == null ? void 0 : _e2.borderRadius) {
|
|
10211
10214
|
setBorderRadius(options.uiPreferences.borderRadius);
|
|
10212
10215
|
}
|
|
10213
10216
|
setAppState((state) => {
|
|
10214
|
-
var _a3,
|
|
10217
|
+
var _a3, _b3;
|
|
10215
10218
|
const merged = mergeOptions(
|
|
10216
10219
|
__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, options.language && { language: options.language }), !!((_a3 = options.actionsConfiguration) == null ? void 0 : _a3.returnStrategy) && {
|
|
10217
10220
|
returnStrategy: options.actionsConfiguration.returnStrategy
|
|
10218
|
-
}), !!((
|
|
10221
|
+
}), !!((_b3 = options.actionsConfiguration) == null ? void 0 : _b3.twaReturnUrl) && {
|
|
10219
10222
|
twaReturnUrl: options.actionsConfiguration.twaReturnUrl
|
|
10220
10223
|
}), !!options.walletsListConfiguration && {
|
|
10221
10224
|
walletsListConfiguration: options.walletsListConfiguration
|
|
@@ -10529,14 +10532,14 @@ class TonConnectUI {
|
|
|
10529
10532
|
}
|
|
10530
10533
|
}
|
|
10531
10534
|
getModalsAndNotificationsConfiguration(options) {
|
|
10532
|
-
var _a2,
|
|
10535
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
10533
10536
|
const allActions = [
|
|
10534
10537
|
"before",
|
|
10535
10538
|
"success",
|
|
10536
10539
|
"error"
|
|
10537
10540
|
];
|
|
10538
10541
|
let notifications2 = allActions;
|
|
10539
|
-
if (((_a2 = this.actionsConfiguration) == null ? void 0 : _a2.notifications) && ((
|
|
10542
|
+
if (((_a2 = this.actionsConfiguration) == null ? void 0 : _a2.notifications) && ((_b2 = this.actionsConfiguration) == null ? void 0 : _b2.notifications) !== "all") {
|
|
10540
10543
|
notifications2 = this.actionsConfiguration.notifications;
|
|
10541
10544
|
}
|
|
10542
10545
|
if (options == null ? void 0 : options.notifications) {
|
|
@@ -10547,7 +10550,7 @@ class TonConnectUI {
|
|
|
10547
10550
|
}
|
|
10548
10551
|
}
|
|
10549
10552
|
let modals = ["before"];
|
|
10550
|
-
if ((
|
|
10553
|
+
if ((_c2 = this.actionsConfiguration) == null ? void 0 : _c2.modals) {
|
|
10551
10554
|
if (this.actionsConfiguration.modals === "all") {
|
|
10552
10555
|
modals = allActions;
|
|
10553
10556
|
} else {
|
|
@@ -10561,9 +10564,9 @@ class TonConnectUI {
|
|
|
10561
10564
|
modals = options.modals;
|
|
10562
10565
|
}
|
|
10563
10566
|
}
|
|
10564
|
-
const returnStrategy = (options == null ? void 0 : options.returnStrategy) || ((
|
|
10565
|
-
const twaReturnUrl = (options == null ? void 0 : options.twaReturnUrl) || ((
|
|
10566
|
-
let skipRedirectToWallet = (options == null ? void 0 : options.skipRedirectToWallet) || ((
|
|
10567
|
+
const returnStrategy = (options == null ? void 0 : options.returnStrategy) || ((_d2 = this.actionsConfiguration) == null ? void 0 : _d2.returnStrategy) || "back";
|
|
10568
|
+
const twaReturnUrl = (options == null ? void 0 : options.twaReturnUrl) || ((_e2 = this.actionsConfiguration) == null ? void 0 : _e2.twaReturnUrl);
|
|
10569
|
+
let skipRedirectToWallet = (options == null ? void 0 : options.skipRedirectToWallet) || ((_f2 = this.actionsConfiguration) == null ? void 0 : _f2.skipRedirectToWallet) || "ios";
|
|
10567
10570
|
if (isInTMA()) {
|
|
10568
10571
|
skipRedirectToWallet = "never";
|
|
10569
10572
|
}
|