@getpara/web-sdk 2.24.0 → 3.0.0-alpha.0

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.
@@ -8,3 +8,4 @@ export declare function isSafari(): boolean;
8
8
  export declare function isIOSWebview(): boolean;
9
9
  export declare function isMobileSafari(): boolean;
10
10
  export declare function isTelegram(): boolean;
11
+ export declare const openMobileUrl: (url?: string) => void;
@@ -41,6 +41,34 @@ function isMobileSafari() {
41
41
  function isTelegram() {
42
42
  return typeof window !== "undefined" && (Boolean(window.TelegramWebviewProxy) || Boolean(window.Telegram) || Boolean(window.TelegramWebviewProxyProto));
43
43
  }
44
+ const openMobileUrl = (url) => {
45
+ if (typeof window === "undefined") {
46
+ return;
47
+ }
48
+ if (isMobile()) {
49
+ if (!url) return;
50
+ if (isTelegram()) {
51
+ let href = url;
52
+ if (isAndroid()) {
53
+ try {
54
+ const decoded = decodeURI(url);
55
+ href = decoded === url ? encodeURI(url) : url;
56
+ } catch (e) {
57
+ href = encodeURI(url);
58
+ }
59
+ }
60
+ window.open(href, "_blank", "noreferrer noopener");
61
+ } else if (url.startsWith("http")) {
62
+ const link = document.createElement("a");
63
+ link.href = url;
64
+ link.target = "_blank";
65
+ link.rel = "noreferrer noopener";
66
+ link.click();
67
+ } else {
68
+ window.location.href = url;
69
+ }
70
+ }
71
+ };
44
72
  export {
45
73
  isAndroid,
46
74
  isIOS,
@@ -51,5 +79,6 @@ export {
51
79
  isSafari,
52
80
  isSmallIOS,
53
81
  isTablet,
54
- isTelegram
82
+ isTelegram,
83
+ openMobileUrl
55
84
  };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@getpara/web-sdk",
3
- "version": "2.24.0",
3
+ "version": "3.0.0-alpha.0",
4
4
  "dependencies": {
5
- "@getpara/core-sdk": "2.24.0",
6
- "@getpara/user-management-client": "2.24.0",
5
+ "@getpara/core-sdk": "3.0.0-alpha.0",
6
+ "@getpara/user-management-client": "3.0.0-alpha.0",
7
7
  "base64url": "^3.0.1",
8
8
  "buffer": "6.0.3",
9
9
  "cbor-web": "^9.0.2",
@@ -29,7 +29,7 @@
29
29
  "dist",
30
30
  "package.json"
31
31
  ],
32
- "gitHead": "3ea729c9a5e550c2053c5fff07d1ca7d8a8f9ce9",
32
+ "gitHead": "f58e6e365ca63a447edaa44fba3b157e5ca7a368",
33
33
  "main": "dist/index.js",
34
34
  "scripts": {
35
35
  "build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs && yarn post-build",