@rash2x/bridge-widget 0.8.2 → 0.8.3

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.
@@ -5047,6 +5047,44 @@ const MainButton = ({
5047
5047
  )
5048
5048
  ] });
5049
5049
  };
5050
+ const MOBILE_UA_REGEX = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini|mobile/i;
5051
+ function isMobileDevice() {
5052
+ if (typeof navigator === "undefined") return false;
5053
+ return MOBILE_UA_REGEX.test(navigator.userAgent);
5054
+ }
5055
+ function isTronLinkInstalled() {
5056
+ if (typeof window === "undefined") {
5057
+ return false;
5058
+ }
5059
+ const win = window;
5060
+ if (!win.tronWeb) {
5061
+ return false;
5062
+ }
5063
+ const tronLink = win.tronWeb;
5064
+ if (typeof tronLink.isTronLink === "boolean") {
5065
+ return tronLink.isTronLink;
5066
+ }
5067
+ if (typeof tronLink.ready === "boolean") {
5068
+ return tronLink.ready;
5069
+ }
5070
+ return true;
5071
+ }
5072
+ function buildTronLinkDeepLink(targetUrl) {
5073
+ const param = encodeURIComponent(
5074
+ JSON.stringify({
5075
+ url: targetUrl,
5076
+ action: "open",
5077
+ protocol: "tronlink",
5078
+ version: "1.0"
5079
+ })
5080
+ );
5081
+ return `tronlinkoutside://pull.activity?param=${param}`;
5082
+ }
5083
+ function openInTronLink(targetUrl) {
5084
+ if (typeof window === "undefined") return false;
5085
+ window.location.href = buildTronLinkDeepLink(targetUrl);
5086
+ return true;
5087
+ }
5050
5088
  const WalletModalButton = (props) => {
5051
5089
  const { t: t2 } = reactI18next.useTranslation();
5052
5090
  const { icon: IconComponent, name, onClose } = props;
@@ -5103,6 +5141,17 @@ const WalletModalButton = (props) => {
5103
5141
  const strategy = chainRegistry.getStrategyByType("ton");
5104
5142
  await strategy?.connect();
5105
5143
  } else {
5144
+ if (walletId === "tronlink" && isMobileDevice() && !isTronLinkInstalled()) {
5145
+ const opened = openInTronLink(window.location.href);
5146
+ if (!opened) {
5147
+ sonner.toast.error(
5148
+ "Failed to open TronLink app. Please use WalletConnect."
5149
+ );
5150
+ return;
5151
+ }
5152
+ onClose?.();
5153
+ return;
5154
+ }
5106
5155
  const strategy = chainRegistry.getStrategyByType("tron");
5107
5156
  const provider = walletId === "tronwc" ? "walletconnect" : "tronlink";
5108
5157
  await strategy?.connect({ provider });
@@ -6299,14 +6348,17 @@ class TronChainStrategy {
6299
6348
  await walletConnect.connect();
6300
6349
  return;
6301
6350
  }
6302
- if (!this.isTronLinkInstalled()) {
6303
- if (typeof window !== "undefined") {
6351
+ if (!isTronLinkInstalled()) {
6352
+ if (typeof window !== "undefined" && !isMobileDevice()) {
6304
6353
  window.open("https://www.tronlink.org/", "_blank");
6305
6354
  }
6306
- throw new WalletNotFoundError(
6307
- "tron",
6308
- "TronLink wallet is not installed. Please install TronLink extension and try again."
6309
- );
6355
+ if (isMobileDevice()) {
6356
+ throw new ProviderNotAvailableError(
6357
+ "tron",
6358
+ "TronLink is not available in this mobile browser. Use WalletConnect or open this dApp in TronLink's in-app browser."
6359
+ );
6360
+ }
6361
+ throw new WalletNotFoundError("tron", "TronLink");
6310
6362
  }
6311
6363
  if (this.config.tronLink.connected && this.config.tronLink.address) {
6312
6364
  console.log("TronLink already connected, skipping connection");
@@ -6516,7 +6568,7 @@ class TronChainStrategy {
6516
6568
  if (preferProvider === "walletconnect") {
6517
6569
  return this.getFallbackClient();
6518
6570
  }
6519
- if (typeof window !== "undefined" && window.tronWeb && this.isTronLinkInstalled()) {
6571
+ if (typeof window !== "undefined" && window.tronWeb && isTronLinkInstalled()) {
6520
6572
  this.applyTronApiKey(window.tronWeb);
6521
6573
  return window.tronWeb;
6522
6574
  }
@@ -6571,27 +6623,6 @@ class TronChainStrategy {
6571
6623
  } catch {
6572
6624
  }
6573
6625
  }
6574
- /**
6575
- * Check if TronLink wallet is actually installed
6576
- * This excludes Bybit Wallet which also injects tronLink for compatibility
6577
- */
6578
- isTronLinkInstalled() {
6579
- if (typeof window === "undefined") {
6580
- return false;
6581
- }
6582
- const win = window;
6583
- if (!win.tronWeb) {
6584
- return false;
6585
- }
6586
- const tronLink = win.tronWeb;
6587
- if (typeof tronLink.isTronLink === "boolean") {
6588
- return tronLink.isTronLink;
6589
- }
6590
- if (typeof tronLink.ready === "boolean") {
6591
- return tronLink.ready;
6592
- }
6593
- return true;
6594
- }
6595
6626
  ensureDefaultAddress(tronWeb, address) {
6596
6627
  if (!address) return;
6597
6628
  try {
@@ -26522,7 +26553,7 @@ class WalletConnectModal {
26522
26553
  }
26523
26554
  async initUi() {
26524
26555
  if (typeof window !== "undefined") {
26525
- await Promise.resolve().then(() => require("./index-CFKU946o.cjs"));
26556
+ await Promise.resolve().then(() => require("./index-s4FyGXJW.cjs"));
26526
26557
  const modal = document.createElement("wcm-modal");
26527
26558
  document.body.insertAdjacentElement("beforeend", modal);
26528
26559
  OptionsCtrl.setIsUiLoaded(true);
@@ -27425,4 +27456,4 @@ exports.useSettingsStore = useSettingsStore;
27425
27456
  exports.useSwapModel = useSwapModel;
27426
27457
  exports.useTokensStore = useTokensStore;
27427
27458
  exports.useTransactionStore = useTransactionStore;
27428
- //# sourceMappingURL=index-BcqN6B-E.cjs.map
27459
+ //# sourceMappingURL=index-egFmHlPu.cjs.map