@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.js CHANGED
@@ -3192,6 +3192,31 @@ function Spinner({ size = 40, label }) {
3192
3192
  }
3193
3193
  );
3194
3194
  }
3195
+
3196
+ // src/deeplink.ts
3197
+ var IFRAME_CLEANUP_DELAY_MS = 3e3;
3198
+ function isCustomSchemeUri(uri) {
3199
+ try {
3200
+ return !uri.startsWith("https://") && !uri.startsWith("http://");
3201
+ } catch {
3202
+ return false;
3203
+ }
3204
+ }
3205
+ function triggerDeeplink(uri) {
3206
+ try {
3207
+ const iframe = document.createElement("iframe");
3208
+ iframe.style.display = "none";
3209
+ iframe.src = uri;
3210
+ document.body.appendChild(iframe);
3211
+ setTimeout(() => {
3212
+ try {
3213
+ document.body.removeChild(iframe);
3214
+ } catch {
3215
+ }
3216
+ }, IFRAME_CLEANUP_DELAY_MS);
3217
+ } catch {
3218
+ }
3219
+ }
3195
3220
  var WALLET_EMOJIS = {
3196
3221
  rabby: "\u{1F430}",
3197
3222
  ora: "\u2666\uFE0F",
@@ -3260,11 +3285,8 @@ function WalletPickerScreen({
3260
3285
  {
3261
3286
  onClick: () => {
3262
3287
  const session = preparedSession?.providerId === selectedProvider.id ? preparedSession : void 0;
3263
- if (session && useDeeplink) {
3264
- const opened = window.open(session.uri, "_blank");
3265
- if (!opened && window === window.parent) {
3266
- window.location.href = session.uri;
3267
- }
3288
+ if (session && useDeeplink && isCustomSchemeUri(session.uri)) {
3289
+ window.open(session.uri, "_blank");
3268
3290
  }
3269
3291
  setConnecting(true);
3270
3292
  onSelectProvider(selectedProvider.id, session).finally(() => setConnecting(false));
@@ -4899,28 +4921,6 @@ var stepsWrapStyle2 = {
4899
4921
  textAlign: "left",
4900
4922
  marginBottom: 16
4901
4923
  };
4902
-
4903
- // src/deeplink.ts
4904
- var IFRAME_CLEANUP_DELAY_MS = 3e3;
4905
- var LOCATION_FALLBACK_DELAY_MS = 100;
4906
- function triggerDeeplink(uri) {
4907
- try {
4908
- const iframe = document.createElement("iframe");
4909
- iframe.style.display = "none";
4910
- iframe.src = uri;
4911
- document.body.appendChild(iframe);
4912
- setTimeout(() => {
4913
- try {
4914
- document.body.removeChild(iframe);
4915
- } catch {
4916
- }
4917
- }, IFRAME_CLEANUP_DELAY_MS);
4918
- } catch {
4919
- }
4920
- setTimeout(() => {
4921
- window.location.href = uri;
4922
- }, LOCATION_FALLBACK_DELAY_MS);
4923
- }
4924
4924
  function OpenWalletScreen({
4925
4925
  walletName,
4926
4926
  deeplinkUri,
@@ -4941,8 +4941,9 @@ function OpenWalletScreen({
4941
4941
  triggerDeeplink(deeplinkUri);
4942
4942
  }, [useDeeplink, loading, deeplinkUri]);
4943
4943
  const handleOpen = useCallback(() => {
4944
- const opened = window.open(deeplinkUri, "_blank");
4945
- if (!opened && window === window.parent) {
4944
+ if (isCustomSchemeUri(deeplinkUri)) {
4945
+ window.open(deeplinkUri, "_blank");
4946
+ } else {
4946
4947
  window.location.href = deeplinkUri;
4947
4948
  }
4948
4949
  }, [deeplinkUri]);
@@ -7395,11 +7396,18 @@ function usePaymentEffects(deps) {
7395
7396
  poll();
7396
7397
  }
7397
7398
  };
7399
+ const handlePageShow = (e) => {
7400
+ if (e.persisted && !cancelled) {
7401
+ poll();
7402
+ }
7403
+ };
7398
7404
  document.addEventListener("visibilitychange", handleVisibility);
7405
+ window.addEventListener("pageshow", handlePageShow);
7399
7406
  return () => {
7400
7407
  cancelled = true;
7401
7408
  window.clearInterval(intervalId);
7402
7409
  document.removeEventListener("visibilitychange", handleVisibility);
7410
+ window.removeEventListener("pageshow", handlePageShow);
7403
7411
  };
7404
7412
  }, [
7405
7413
  state.mobileFlow,
@@ -7424,8 +7432,17 @@ function usePaymentEffects(deps) {
7424
7432
  polling.startPolling(transferIdToResume);
7425
7433
  }
7426
7434
  };
7435
+ const handlePageShow = (e) => {
7436
+ if (e.persisted && !handlingMobileReturnRef.current) {
7437
+ polling.startPolling(transferIdToResume);
7438
+ }
7439
+ };
7427
7440
  document.addEventListener("visibilitychange", handleVisibility);
7428
- return () => document.removeEventListener("visibilitychange", handleVisibility);
7441
+ window.addEventListener("pageshow", handlePageShow);
7442
+ return () => {
7443
+ document.removeEventListener("visibilitychange", handleVisibility);
7444
+ window.removeEventListener("pageshow", handlePageShow);
7445
+ };
7429
7446
  }, [
7430
7447
  state.mobileFlow,
7431
7448
  state.transfer?.id,