@tonconnect/ui 2.0.8 → 2.0.9-beta.1

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/lib/index.cjs CHANGED
@@ -2698,6 +2698,11 @@ function isInTMA() {
2698
2698
  var _a2;
2699
2699
  return tmaPlatform !== "unknown" || !!((_a2 = getWindow$1()) == null ? void 0 : _a2.TelegramWebviewProxy);
2700
2700
  }
2701
+ function isInTelegramBrowser() {
2702
+ var _a2;
2703
+ const isTelegramWebview = !!((_a2 = getWindow$1()) == null ? void 0 : _a2.TelegramWebview);
2704
+ return (isInTMA() || isTelegramWebview) && tmaPlatform === "unknown";
2705
+ }
2701
2706
  function sendExpand() {
2702
2707
  postEvent("web_app_expand", {});
2703
2708
  }
@@ -8360,19 +8365,20 @@ function redirectToTelegram(universalLink, options) {
8360
8365
  if (!directLinkUrl.searchParams.has("startapp")) {
8361
8366
  directLinkUrl.searchParams.append("startapp", "tonconnect");
8362
8367
  }
8363
- if (isInTMA()) {
8364
- if (isTmaPlatform("ios", "android", "macos")) {
8368
+ if (isInTelegramBrowser()) {
8369
+ options.returnStrategy = "back";
8370
+ const linkWitStrategy = addReturnStrategy(directLinkUrl.toString(), options.returnStrategy);
8371
+ openLinkBlank(linkWitStrategy);
8372
+ } else if (isInTMA()) {
8373
+ if (isTmaPlatform("ios", "android", "macos", "tdesktop", "web")) {
8365
8374
  options.returnStrategy = "back";
8366
- options.twaReturnUrl = void 0;
8367
- sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
8368
- } else if (isTmaPlatform("tdesktop")) {
8369
- sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
8375
+ const linkWitStrategy = addReturnStrategy(
8376
+ directLinkUrl.toString(),
8377
+ options.returnStrategy
8378
+ );
8379
+ sendOpenTelegramLink(linkWitStrategy);
8370
8380
  } else if (isTmaPlatform("weba")) {
8371
8381
  sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
8372
- } else if (isTmaPlatform("web")) {
8373
- options.returnStrategy = "back";
8374
- options.twaReturnUrl = void 0;
8375
- sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
8376
8382
  } else {
8377
8383
  openLinkBlank(addReturnStrategy(directLinkUrl.toString(), options));
8378
8384
  }
@@ -8475,7 +8481,19 @@ function redirectToTelegram(universalLink, options) {
8475
8481
  }
8476
8482
  function redirectToWallet(universalLink, deepLink, options, setOpenMethod) {
8477
8483
  options = __spreadValues({}, options);
8478
- if (isInTMA()) {
8484
+ if (isInTelegramBrowser()) {
8485
+ if (isOS("ios", "android")) {
8486
+ if (options.returnStrategy === "back") {
8487
+ options.returnStrategy = "tg://resolve";
8488
+ }
8489
+ setOpenMethod("universal-link");
8490
+ openLink(addReturnStrategy(universalLink, options.returnStrategy), "_self");
8491
+ } else {
8492
+ setOpenMethod("universal-link");
8493
+ const linkWitStrategy = addReturnStrategy(universalLink, options.returnStrategy);
8494
+ openLinkBlank(linkWitStrategy);
8495
+ }
8496
+ } else if (isInTMA()) {
8479
8497
  if (isTmaPlatform("ios", "android")) {
8480
8498
  if (options.returnStrategy === "back") {
8481
8499
  options.returnStrategy = "tg://resolve";
@@ -8711,16 +8729,20 @@ const DesktopConnectionModal = (props) => {
8711
8729
  generateUniversalLink();
8712
8730
  }
8713
8731
  setMode("desktop");
8714
- const forceRedirect = !firstClick();
8715
- setFirstClick(false);
8716
- redirectToWallet(universalLink(), props.wallet.deepLink, {
8717
- returnStrategy: appState.returnStrategy,
8718
- forceRedirect
8719
- }, (method) => {
8720
- setLastSelectedWalletInfo(__spreadProps(__spreadValues({}, props.wallet), {
8721
- openMethod: method
8722
- }));
8723
- });
8732
+ if (sdk.isTelegramUrl(universalLink())) {
8733
+ onClickTelegram();
8734
+ } else {
8735
+ const forceRedirect = !firstClick();
8736
+ setFirstClick(false);
8737
+ redirectToWallet(universalLink(), props.wallet.deepLink, {
8738
+ returnStrategy: appState.returnStrategy,
8739
+ forceRedirect
8740
+ }, (method) => {
8741
+ setLastSelectedWalletInfo(__spreadProps(__spreadValues({}, props.wallet), {
8742
+ openMethod: method
8743
+ }));
8744
+ });
8745
+ }
8724
8746
  };
8725
8747
  const onClickTelegram = () => {
8726
8748
  const forceRedirect = !firstClick();
@@ -10943,7 +10965,7 @@ class TonConnectUITracker {
10943
10965
  }
10944
10966
  }
10945
10967
  }
10946
- const tonConnectUiVersion = "2.0.8";
10968
+ const tonConnectUiVersion = "2.0.9-beta.1";
10947
10969
  class TonConnectUI {
10948
10970
  constructor(options) {
10949
10971
  __publicField(this, "walletInfoStorage", new WalletInfoStorage());