@swype-org/react-sdk 0.1.209 → 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,11 +3288,8 @@ function WalletPickerScreen({
3263
3288
  {
3264
3289
  onClick: () => {
3265
3290
  const session = preparedSession?.providerId === selectedProvider.id ? preparedSession : void 0;
3266
- if (session && useDeeplink) {
3267
- const opened = window.open(session.uri, "_blank");
3268
- if (!opened && window === window.parent) {
3269
- window.location.href = session.uri;
3270
- }
3291
+ if (session && useDeeplink && isCustomSchemeUri(session.uri)) {
3292
+ window.open(session.uri, "_blank");
3271
3293
  }
3272
3294
  setConnecting(true);
3273
3295
  onSelectProvider(selectedProvider.id, session).finally(() => setConnecting(false));
@@ -4902,28 +4924,6 @@ var stepsWrapStyle2 = {
4902
4924
  textAlign: "left",
4903
4925
  marginBottom: 16
4904
4926
  };
4905
-
4906
- // src/deeplink.ts
4907
- var IFRAME_CLEANUP_DELAY_MS = 3e3;
4908
- var LOCATION_FALLBACK_DELAY_MS = 100;
4909
- function triggerDeeplink(uri) {
4910
- try {
4911
- const iframe = document.createElement("iframe");
4912
- iframe.style.display = "none";
4913
- iframe.src = uri;
4914
- document.body.appendChild(iframe);
4915
- setTimeout(() => {
4916
- try {
4917
- document.body.removeChild(iframe);
4918
- } catch {
4919
- }
4920
- }, IFRAME_CLEANUP_DELAY_MS);
4921
- } catch {
4922
- }
4923
- setTimeout(() => {
4924
- window.location.href = uri;
4925
- }, LOCATION_FALLBACK_DELAY_MS);
4926
- }
4927
4927
  function OpenWalletScreen({
4928
4928
  walletName,
4929
4929
  deeplinkUri,
@@ -4944,8 +4944,9 @@ function OpenWalletScreen({
4944
4944
  triggerDeeplink(deeplinkUri);
4945
4945
  }, [useDeeplink, loading, deeplinkUri]);
4946
4946
  const handleOpen = react.useCallback(() => {
4947
- const opened = window.open(deeplinkUri, "_blank");
4948
- if (!opened && window === window.parent) {
4947
+ if (isCustomSchemeUri(deeplinkUri)) {
4948
+ window.open(deeplinkUri, "_blank");
4949
+ } else {
4949
4950
  window.location.href = deeplinkUri;
4950
4951
  }
4951
4952
  }, [deeplinkUri]);
@@ -7398,11 +7399,18 @@ function usePaymentEffects(deps) {
7398
7399
  poll();
7399
7400
  }
7400
7401
  };
7402
+ const handlePageShow = (e) => {
7403
+ if (e.persisted && !cancelled) {
7404
+ poll();
7405
+ }
7406
+ };
7401
7407
  document.addEventListener("visibilitychange", handleVisibility);
7408
+ window.addEventListener("pageshow", handlePageShow);
7402
7409
  return () => {
7403
7410
  cancelled = true;
7404
7411
  window.clearInterval(intervalId);
7405
7412
  document.removeEventListener("visibilitychange", handleVisibility);
7413
+ window.removeEventListener("pageshow", handlePageShow);
7406
7414
  };
7407
7415
  }, [
7408
7416
  state.mobileFlow,
@@ -7427,8 +7435,17 @@ function usePaymentEffects(deps) {
7427
7435
  polling.startPolling(transferIdToResume);
7428
7436
  }
7429
7437
  };
7438
+ const handlePageShow = (e) => {
7439
+ if (e.persisted && !handlingMobileReturnRef.current) {
7440
+ polling.startPolling(transferIdToResume);
7441
+ }
7442
+ };
7430
7443
  document.addEventListener("visibilitychange", handleVisibility);
7431
- return () => document.removeEventListener("visibilitychange", handleVisibility);
7444
+ window.addEventListener("pageshow", handlePageShow);
7445
+ return () => {
7446
+ document.removeEventListener("visibilitychange", handleVisibility);
7447
+ window.removeEventListener("pageshow", handlePageShow);
7448
+ };
7432
7449
  }, [
7433
7450
  state.mobileFlow,
7434
7451
  state.transfer?.id,