@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.
@@ -5030,6 +5030,44 @@ const MainButton = ({
5030
5030
  )
5031
5031
  ] });
5032
5032
  };
5033
+ const MOBILE_UA_REGEX = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini|mobile/i;
5034
+ function isMobileDevice() {
5035
+ if (typeof navigator === "undefined") return false;
5036
+ return MOBILE_UA_REGEX.test(navigator.userAgent);
5037
+ }
5038
+ function isTronLinkInstalled() {
5039
+ if (typeof window === "undefined") {
5040
+ return false;
5041
+ }
5042
+ const win = window;
5043
+ if (!win.tronWeb) {
5044
+ return false;
5045
+ }
5046
+ const tronLink = win.tronWeb;
5047
+ if (typeof tronLink.isTronLink === "boolean") {
5048
+ return tronLink.isTronLink;
5049
+ }
5050
+ if (typeof tronLink.ready === "boolean") {
5051
+ return tronLink.ready;
5052
+ }
5053
+ return true;
5054
+ }
5055
+ function buildTronLinkDeepLink(targetUrl) {
5056
+ const param = encodeURIComponent(
5057
+ JSON.stringify({
5058
+ url: targetUrl,
5059
+ action: "open",
5060
+ protocol: "tronlink",
5061
+ version: "1.0"
5062
+ })
5063
+ );
5064
+ return `tronlinkoutside://pull.activity?param=${param}`;
5065
+ }
5066
+ function openInTronLink(targetUrl) {
5067
+ if (typeof window === "undefined") return false;
5068
+ window.location.href = buildTronLinkDeepLink(targetUrl);
5069
+ return true;
5070
+ }
5033
5071
  const WalletModalButton = (props) => {
5034
5072
  const { t: t2 } = useTranslation();
5035
5073
  const { icon: IconComponent, name, onClose } = props;
@@ -5086,6 +5124,17 @@ const WalletModalButton = (props) => {
5086
5124
  const strategy = chainRegistry.getStrategyByType("ton");
5087
5125
  await strategy?.connect();
5088
5126
  } else {
5127
+ if (walletId === "tronlink" && isMobileDevice() && !isTronLinkInstalled()) {
5128
+ const opened = openInTronLink(window.location.href);
5129
+ if (!opened) {
5130
+ toast.error(
5131
+ "Failed to open TronLink app. Please use WalletConnect."
5132
+ );
5133
+ return;
5134
+ }
5135
+ onClose?.();
5136
+ return;
5137
+ }
5089
5138
  const strategy = chainRegistry.getStrategyByType("tron");
5090
5139
  const provider = walletId === "tronwc" ? "walletconnect" : "tronlink";
5091
5140
  await strategy?.connect({ provider });
@@ -6282,14 +6331,17 @@ class TronChainStrategy {
6282
6331
  await walletConnect.connect();
6283
6332
  return;
6284
6333
  }
6285
- if (!this.isTronLinkInstalled()) {
6286
- if (typeof window !== "undefined") {
6334
+ if (!isTronLinkInstalled()) {
6335
+ if (typeof window !== "undefined" && !isMobileDevice()) {
6287
6336
  window.open("https://www.tronlink.org/", "_blank");
6288
6337
  }
6289
- throw new WalletNotFoundError(
6290
- "tron",
6291
- "TronLink wallet is not installed. Please install TronLink extension and try again."
6292
- );
6338
+ if (isMobileDevice()) {
6339
+ throw new ProviderNotAvailableError(
6340
+ "tron",
6341
+ "TronLink is not available in this mobile browser. Use WalletConnect or open this dApp in TronLink's in-app browser."
6342
+ );
6343
+ }
6344
+ throw new WalletNotFoundError("tron", "TronLink");
6293
6345
  }
6294
6346
  if (this.config.tronLink.connected && this.config.tronLink.address) {
6295
6347
  console.log("TronLink already connected, skipping connection");
@@ -6499,7 +6551,7 @@ class TronChainStrategy {
6499
6551
  if (preferProvider === "walletconnect") {
6500
6552
  return this.getFallbackClient();
6501
6553
  }
6502
- if (typeof window !== "undefined" && window.tronWeb && this.isTronLinkInstalled()) {
6554
+ if (typeof window !== "undefined" && window.tronWeb && isTronLinkInstalled()) {
6503
6555
  this.applyTronApiKey(window.tronWeb);
6504
6556
  return window.tronWeb;
6505
6557
  }
@@ -6554,27 +6606,6 @@ class TronChainStrategy {
6554
6606
  } catch {
6555
6607
  }
6556
6608
  }
6557
- /**
6558
- * Check if TronLink wallet is actually installed
6559
- * This excludes Bybit Wallet which also injects tronLink for compatibility
6560
- */
6561
- isTronLinkInstalled() {
6562
- if (typeof window === "undefined") {
6563
- return false;
6564
- }
6565
- const win = window;
6566
- if (!win.tronWeb) {
6567
- return false;
6568
- }
6569
- const tronLink = win.tronWeb;
6570
- if (typeof tronLink.isTronLink === "boolean") {
6571
- return tronLink.isTronLink;
6572
- }
6573
- if (typeof tronLink.ready === "boolean") {
6574
- return tronLink.ready;
6575
- }
6576
- return true;
6577
- }
6578
6609
  ensureDefaultAddress(tronWeb, address) {
6579
6610
  if (!address) return;
6580
6611
  try {
@@ -26505,7 +26536,7 @@ class WalletConnectModal {
26505
26536
  }
26506
26537
  async initUi() {
26507
26538
  if (typeof window !== "undefined") {
26508
- await import("./index-BqxDubHD.js");
26539
+ await import("./index-0JKTjlKW.js");
26509
26540
  const modal = document.createElement("wcm-modal");
26510
26541
  document.body.insertAdjacentElement("beforeend", modal);
26511
26542
  OptionsCtrl.setIsUiLoaded(true);
@@ -27410,4 +27441,4 @@ export {
27410
27441
  calculateMinReceived as y,
27411
27442
  getQuoteDetails as z
27412
27443
  };
27413
- //# sourceMappingURL=index-BiPDLFPf.js.map
27444
+ //# sourceMappingURL=index-D2zkzmLE.js.map