@tonconnect/ui 2.0.0-beta.8 → 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 +1 -1
package/lib/index.mjs
CHANGED
|
@@ -41,7 +41,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
41
41
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
|
-
var _a;
|
|
44
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
45
45
|
import { TonConnectError, isTelegramUrl, encodeTelegramUrlParameters, isWalletInfoCurrentlyInjected, toUserFriendlyAddress, CHAIN, TonConnect, isWalletInfoRemote, isWalletInfoCurrentlyEmbedded } from "@tonconnect/sdk";
|
|
46
46
|
export * from "@tonconnect/sdk";
|
|
47
47
|
import UAParser from "ua-parser-js";
|
|
@@ -1772,13 +1772,19 @@ try {
|
|
|
1772
1772
|
} catch (e2) {
|
|
1773
1773
|
}
|
|
1774
1774
|
let tmaPlatform = "unknown";
|
|
1775
|
-
if (initParams.tgWebAppPlatform) {
|
|
1776
|
-
tmaPlatform = initParams.tgWebAppPlatform;
|
|
1775
|
+
if (initParams == null ? void 0 : initParams.tgWebAppPlatform) {
|
|
1776
|
+
tmaPlatform = (_a = initParams.tgWebAppPlatform) != null ? _a : "unknown";
|
|
1777
|
+
}
|
|
1778
|
+
if (tmaPlatform === "unknown") {
|
|
1779
|
+
tmaPlatform = (_d = (_c = (_b = window == null ? void 0 : window.Telegram) == null ? void 0 : _b.WebApp) == null ? void 0 : _c.platform) != null ? _d : "unknown";
|
|
1777
1780
|
}
|
|
1778
1781
|
let webAppVersion = "6.0";
|
|
1779
|
-
if (initParams.tgWebAppVersion) {
|
|
1782
|
+
if (initParams == null ? void 0 : initParams.tgWebAppVersion) {
|
|
1780
1783
|
webAppVersion = initParams.tgWebAppVersion;
|
|
1781
1784
|
}
|
|
1785
|
+
if (!webAppVersion) {
|
|
1786
|
+
webAppVersion = (_g = (_f = (_e = window == null ? void 0 : window.Telegram) == null ? void 0 : _e.WebApp) == null ? void 0 : _f.version) != null ? _g : "6.0";
|
|
1787
|
+
}
|
|
1782
1788
|
function isTmaPlatform(...platforms) {
|
|
1783
1789
|
return platforms.includes(tmaPlatform);
|
|
1784
1790
|
}
|
|
@@ -2007,7 +2013,7 @@ function isNodeJs() {
|
|
|
2007
2013
|
return typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
2008
2014
|
}
|
|
2009
2015
|
function getUserAgent() {
|
|
2010
|
-
var _a2,
|
|
2016
|
+
var _a2, _b2;
|
|
2011
2017
|
const results = new UAParser().getResult();
|
|
2012
2018
|
const osName = (_a2 = results.os.name) == null ? void 0 : _a2.toLowerCase();
|
|
2013
2019
|
let os;
|
|
@@ -2028,7 +2034,7 @@ function getUserAgent() {
|
|
|
2028
2034
|
os = "windows";
|
|
2029
2035
|
break;
|
|
2030
2036
|
}
|
|
2031
|
-
const browserName = (
|
|
2037
|
+
const browserName = (_b2 = results.browser.name) == null ? void 0 : _b2.toLowerCase();
|
|
2032
2038
|
let browser;
|
|
2033
2039
|
switch (true) {
|
|
2034
2040
|
case browserName === "chrome":
|
|
@@ -2058,18 +2064,15 @@ function redirectToTelegram(universalLink, options) {
|
|
|
2058
2064
|
}
|
|
2059
2065
|
if (isInTMA()) {
|
|
2060
2066
|
if (isTmaPlatform("ios", "android")) {
|
|
2061
|
-
options.returnStrategy = "
|
|
2067
|
+
options.returnStrategy = "back";
|
|
2062
2068
|
options.twaReturnUrl = void 0;
|
|
2063
2069
|
sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
|
|
2064
2070
|
} else if (isTmaPlatform("macos", "tdesktop")) {
|
|
2065
|
-
if (!options.twaReturnUrl) {
|
|
2066
|
-
throw new TonConnectUIError("`twaReturnUrl` is required for this platform");
|
|
2067
|
-
}
|
|
2068
2071
|
sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
|
|
2069
2072
|
} else if (isTmaPlatform("weba")) {
|
|
2070
2073
|
sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
|
|
2071
2074
|
} else if (isTmaPlatform("web")) {
|
|
2072
|
-
options.returnStrategy = "
|
|
2075
|
+
options.returnStrategy = "back";
|
|
2073
2076
|
options.twaReturnUrl = void 0;
|
|
2074
2077
|
sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
|
|
2075
2078
|
} else {
|
|
@@ -2077,7 +2080,7 @@ function redirectToTelegram(universalLink, options) {
|
|
|
2077
2080
|
}
|
|
2078
2081
|
} else {
|
|
2079
2082
|
if (isOS("ios", "android")) {
|
|
2080
|
-
options.returnStrategy = "
|
|
2083
|
+
options.returnStrategy = "none";
|
|
2081
2084
|
openLinkBlank(addReturnStrategy(directLinkUrl.toString(), options.returnStrategy));
|
|
2082
2085
|
} else if (isOS("macos", "windows", "linux")) {
|
|
2083
2086
|
options.returnStrategy = "none";
|
|
@@ -3261,10 +3264,10 @@ function clickOutside$1(el, accessor) {
|
|
|
3261
3264
|
}
|
|
3262
3265
|
function escPressed(_, accessor) {
|
|
3263
3266
|
const onKeyPress = (e2) => {
|
|
3264
|
-
var _a2,
|
|
3267
|
+
var _a2, _b2;
|
|
3265
3268
|
if (e2.key === "Escape") {
|
|
3266
3269
|
(_a2 = document.activeElement) == null ? void 0 : _a2.blur();
|
|
3267
|
-
(
|
|
3270
|
+
(_b2 = accessor()) == null ? void 0 : _b2();
|
|
3268
3271
|
}
|
|
3269
3272
|
};
|
|
3270
3273
|
document.body.addEventListener("keydown", onKeyPress);
|
|
@@ -6570,7 +6573,7 @@ const ScrollDivider = styled.div`
|
|
|
6570
6573
|
margin: 0;
|
|
6571
6574
|
}
|
|
6572
6575
|
`;
|
|
6573
|
-
const [windowHeight, setWindowHeight] = createSignal(((
|
|
6576
|
+
const [windowHeight, setWindowHeight] = createSignal(((_h = getWindow$1()) == null ? void 0 : _h.innerHeight) || 0);
|
|
6574
6577
|
if (getWindow$1()) {
|
|
6575
6578
|
window.addEventListener("resize", () => setWindowHeight(window.innerHeight));
|
|
6576
6579
|
}
|
|
@@ -8010,8 +8013,8 @@ const AccountButton = () => {
|
|
|
8010
8013
|
}), null);
|
|
8011
8014
|
insert(_el$, createComponent(NotificationsStyled, {}), null);
|
|
8012
8015
|
createRenderEffect((_p$) => {
|
|
8013
|
-
var _a2,
|
|
8014
|
-
const _v$ = position.strategy, _v$2 = `${(_a2 = position.y) != null ? _a2 : 0}px`, _v$3 = `${(
|
|
8016
|
+
var _a2, _b2;
|
|
8017
|
+
const _v$ = position.strategy, _v$2 = `${(_a2 = position.y) != null ? _a2 : 0}px`, _v$3 = `${(_b2 = position.x) != null ? _b2 : 0}px`;
|
|
8015
8018
|
_v$ !== _p$._v$ && _el$.style.setProperty("position", _p$._v$ = _v$);
|
|
8016
8019
|
_v$2 !== _p$._v$2 && _el$.style.setProperty("top", _p$._v$2 = _v$2);
|
|
8017
8020
|
_v$3 !== _p$._v$3 && _el$.style.setProperty("left", _p$._v$3 = _v$3);
|
|
@@ -10184,12 +10187,12 @@ class TonConnectUI {
|
|
|
10184
10187
|
return __spreadValues(__spreadValues({}, this.connector.wallet), this.walletInfo);
|
|
10185
10188
|
}
|
|
10186
10189
|
set uiOptions(options) {
|
|
10187
|
-
var _a2,
|
|
10190
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
10188
10191
|
this.checkButtonRootExist(options.buttonRootId);
|
|
10189
10192
|
this.actionsConfiguration = options.actionsConfiguration;
|
|
10190
10193
|
if ((_a2 = options.uiPreferences) == null ? void 0 : _a2.theme) {
|
|
10191
|
-
if (((
|
|
10192
|
-
(
|
|
10194
|
+
if (((_b2 = options.uiPreferences) == null ? void 0 : _b2.theme) !== "SYSTEM") {
|
|
10195
|
+
(_c2 = this.systemThemeChangeUnsubscribe) == null ? void 0 : _c2.call(this);
|
|
10193
10196
|
setTheme(options.uiPreferences.theme, options.uiPreferences.colorsSet);
|
|
10194
10197
|
} else {
|
|
10195
10198
|
setTheme(getSystemTheme(), options.uiPreferences.colorsSet);
|
|
@@ -10198,19 +10201,19 @@ class TonConnectUI {
|
|
|
10198
10201
|
}
|
|
10199
10202
|
}
|
|
10200
10203
|
} else {
|
|
10201
|
-
if ((
|
|
10204
|
+
if ((_d2 = options.uiPreferences) == null ? void 0 : _d2.colorsSet) {
|
|
10202
10205
|
setColors(options.uiPreferences.colorsSet);
|
|
10203
10206
|
}
|
|
10204
10207
|
}
|
|
10205
|
-
if ((
|
|
10208
|
+
if ((_e2 = options.uiPreferences) == null ? void 0 : _e2.borderRadius) {
|
|
10206
10209
|
setBorderRadius(options.uiPreferences.borderRadius);
|
|
10207
10210
|
}
|
|
10208
10211
|
setAppState((state) => {
|
|
10209
|
-
var _a3,
|
|
10212
|
+
var _a3, _b3;
|
|
10210
10213
|
const merged = mergeOptions(
|
|
10211
10214
|
__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, options.language && { language: options.language }), !!((_a3 = options.actionsConfiguration) == null ? void 0 : _a3.returnStrategy) && {
|
|
10212
10215
|
returnStrategy: options.actionsConfiguration.returnStrategy
|
|
10213
|
-
}), !!((
|
|
10216
|
+
}), !!((_b3 = options.actionsConfiguration) == null ? void 0 : _b3.twaReturnUrl) && {
|
|
10214
10217
|
twaReturnUrl: options.actionsConfiguration.twaReturnUrl
|
|
10215
10218
|
}), !!options.walletsListConfiguration && {
|
|
10216
10219
|
walletsListConfiguration: options.walletsListConfiguration
|
|
@@ -10524,14 +10527,14 @@ class TonConnectUI {
|
|
|
10524
10527
|
}
|
|
10525
10528
|
}
|
|
10526
10529
|
getModalsAndNotificationsConfiguration(options) {
|
|
10527
|
-
var _a2,
|
|
10530
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
10528
10531
|
const allActions = [
|
|
10529
10532
|
"before",
|
|
10530
10533
|
"success",
|
|
10531
10534
|
"error"
|
|
10532
10535
|
];
|
|
10533
10536
|
let notifications2 = allActions;
|
|
10534
|
-
if (((_a2 = this.actionsConfiguration) == null ? void 0 : _a2.notifications) && ((
|
|
10537
|
+
if (((_a2 = this.actionsConfiguration) == null ? void 0 : _a2.notifications) && ((_b2 = this.actionsConfiguration) == null ? void 0 : _b2.notifications) !== "all") {
|
|
10535
10538
|
notifications2 = this.actionsConfiguration.notifications;
|
|
10536
10539
|
}
|
|
10537
10540
|
if (options == null ? void 0 : options.notifications) {
|
|
@@ -10542,7 +10545,7 @@ class TonConnectUI {
|
|
|
10542
10545
|
}
|
|
10543
10546
|
}
|
|
10544
10547
|
let modals = ["before"];
|
|
10545
|
-
if ((
|
|
10548
|
+
if ((_c2 = this.actionsConfiguration) == null ? void 0 : _c2.modals) {
|
|
10546
10549
|
if (this.actionsConfiguration.modals === "all") {
|
|
10547
10550
|
modals = allActions;
|
|
10548
10551
|
} else {
|
|
@@ -10556,9 +10559,9 @@ class TonConnectUI {
|
|
|
10556
10559
|
modals = options.modals;
|
|
10557
10560
|
}
|
|
10558
10561
|
}
|
|
10559
|
-
const returnStrategy = (options == null ? void 0 : options.returnStrategy) || ((
|
|
10560
|
-
const twaReturnUrl = (options == null ? void 0 : options.twaReturnUrl) || ((
|
|
10561
|
-
let skipRedirectToWallet = (options == null ? void 0 : options.skipRedirectToWallet) || ((
|
|
10562
|
+
const returnStrategy = (options == null ? void 0 : options.returnStrategy) || ((_d2 = this.actionsConfiguration) == null ? void 0 : _d2.returnStrategy) || "back";
|
|
10563
|
+
const twaReturnUrl = (options == null ? void 0 : options.twaReturnUrl) || ((_e2 = this.actionsConfiguration) == null ? void 0 : _e2.twaReturnUrl);
|
|
10564
|
+
let skipRedirectToWallet = (options == null ? void 0 : options.skipRedirectToWallet) || ((_f2 = this.actionsConfiguration) == null ? void 0 : _f2.skipRedirectToWallet) || "ios";
|
|
10562
10565
|
if (isInTMA()) {
|
|
10563
10566
|
skipRedirectToWallet = "never";
|
|
10564
10567
|
}
|