@swype-org/react-sdk 0.1.210 → 0.1.211

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/index.cjs CHANGED
@@ -3195,6 +3195,31 @@ function Spinner({ size = 40, label }) {
3195
3195
  }
3196
3196
  );
3197
3197
  }
3198
+
3199
+ // src/deeplink.ts
3200
+ var IFRAME_CLEANUP_DELAY_MS = 3e3;
3201
+ function isCustomSchemeUri(uri) {
3202
+ try {
3203
+ return !uri.startsWith("https://") && !uri.startsWith("http://");
3204
+ } catch {
3205
+ return false;
3206
+ }
3207
+ }
3208
+ function triggerDeeplink(uri) {
3209
+ try {
3210
+ const iframe = document.createElement("iframe");
3211
+ iframe.style.display = "none";
3212
+ iframe.src = uri;
3213
+ document.body.appendChild(iframe);
3214
+ setTimeout(() => {
3215
+ try {
3216
+ document.body.removeChild(iframe);
3217
+ } catch {
3218
+ }
3219
+ }, IFRAME_CLEANUP_DELAY_MS);
3220
+ } catch {
3221
+ }
3222
+ }
3198
3223
  var WALLET_EMOJIS = {
3199
3224
  rabby: "\u{1F430}",
3200
3225
  ora: "\u2666\uFE0F",
@@ -3263,7 +3288,7 @@ function WalletPickerScreen({
3263
3288
  {
3264
3289
  onClick: () => {
3265
3290
  const session = preparedSession?.providerId === selectedProvider.id ? preparedSession : void 0;
3266
- if (session && useDeeplink) {
3291
+ if (session && useDeeplink && isCustomSchemeUri(session.uri)) {
3267
3292
  window.open(session.uri, "_blank");
3268
3293
  }
3269
3294
  setConnecting(true);
@@ -4899,24 +4924,6 @@ var stepsWrapStyle2 = {
4899
4924
  textAlign: "left",
4900
4925
  marginBottom: 16
4901
4926
  };
4902
-
4903
- // src/deeplink.ts
4904
- var IFRAME_CLEANUP_DELAY_MS = 3e3;
4905
- function triggerDeeplink(uri) {
4906
- try {
4907
- const iframe = document.createElement("iframe");
4908
- iframe.style.display = "none";
4909
- iframe.src = uri;
4910
- document.body.appendChild(iframe);
4911
- setTimeout(() => {
4912
- try {
4913
- document.body.removeChild(iframe);
4914
- } catch {
4915
- }
4916
- }, IFRAME_CLEANUP_DELAY_MS);
4917
- } catch {
4918
- }
4919
- }
4920
4927
  function OpenWalletScreen({
4921
4928
  walletName,
4922
4929
  deeplinkUri,
@@ -4937,7 +4944,11 @@ function OpenWalletScreen({
4937
4944
  triggerDeeplink(deeplinkUri);
4938
4945
  }, [useDeeplink, loading, deeplinkUri]);
4939
4946
  const handleOpen = react.useCallback(() => {
4940
- window.open(deeplinkUri, "_blank");
4947
+ if (isCustomSchemeUri(deeplinkUri)) {
4948
+ window.open(deeplinkUri, "_blank");
4949
+ } else {
4950
+ window.location.href = deeplinkUri;
4951
+ }
4941
4952
  }, [deeplinkUri]);
4942
4953
  if (!useDeeplink) {
4943
4954
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -7388,11 +7399,18 @@ function usePaymentEffects(deps) {
7388
7399
  poll();
7389
7400
  }
7390
7401
  };
7402
+ const handlePageShow = (e) => {
7403
+ if (e.persisted && !cancelled) {
7404
+ poll();
7405
+ }
7406
+ };
7391
7407
  document.addEventListener("visibilitychange", handleVisibility);
7408
+ window.addEventListener("pageshow", handlePageShow);
7392
7409
  return () => {
7393
7410
  cancelled = true;
7394
7411
  window.clearInterval(intervalId);
7395
7412
  document.removeEventListener("visibilitychange", handleVisibility);
7413
+ window.removeEventListener("pageshow", handlePageShow);
7396
7414
  };
7397
7415
  }, [
7398
7416
  state.mobileFlow,
@@ -7417,8 +7435,17 @@ function usePaymentEffects(deps) {
7417
7435
  polling.startPolling(transferIdToResume);
7418
7436
  }
7419
7437
  };
7438
+ const handlePageShow = (e) => {
7439
+ if (e.persisted && !handlingMobileReturnRef.current) {
7440
+ polling.startPolling(transferIdToResume);
7441
+ }
7442
+ };
7420
7443
  document.addEventListener("visibilitychange", handleVisibility);
7421
- return () => document.removeEventListener("visibilitychange", handleVisibility);
7444
+ window.addEventListener("pageshow", handlePageShow);
7445
+ return () => {
7446
+ document.removeEventListener("visibilitychange", handleVisibility);
7447
+ window.removeEventListener("pageshow", handlePageShow);
7448
+ };
7422
7449
  }, [
7423
7450
  state.mobileFlow,
7424
7451
  state.transfer?.id,