@arcblock/react-hooks 2.10.2 → 2.10.4
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/lib/useBrowser.js +2 -1
- package/package.json +2 -2
- package/src/useBrowser.js +2 -1
package/lib/useBrowser.js
CHANGED
|
@@ -13,6 +13,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
13
13
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
14
14
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
15
|
const DID_WALLET_TAG = 'ABTWallet';
|
|
16
|
+
const ARC_SPHERE_TAG = 'ArcSphere';
|
|
16
17
|
function getDIDWalletVersion(userAgent) {
|
|
17
18
|
var _result$groups;
|
|
18
19
|
const reg = new RegExp("".concat(DID_WALLET_TAG, "/(?<version>[0-9.]+)"), 'g');
|
|
@@ -24,7 +25,7 @@ function useBrowser() {
|
|
|
24
25
|
var _window, _window$navigator;
|
|
25
26
|
const userAgent = (_window = window) === null || _window === void 0 ? void 0 : (_window$navigator = _window.navigator) === null || _window$navigator === void 0 ? void 0 : _window$navigator.userAgent;
|
|
26
27
|
const [browser] = (0, _react.useState)({
|
|
27
|
-
wallet: userAgent.indexOf(DID_WALLET_TAG) > -1,
|
|
28
|
+
wallet: userAgent.indexOf(DID_WALLET_TAG) > -1 || userAgent.indexOf(ARC_SPHERE_TAG) > -1,
|
|
28
29
|
walletVersion: getDIDWalletVersion(userAgent),
|
|
29
30
|
wechat: /MicroMessenger/i.test(userAgent),
|
|
30
31
|
mobile: _objectSpread({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/react-hooks",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.4",
|
|
4
4
|
"description": "React hooks used by arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
46
46
|
"jest": "^28.1.3"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "57248b30b2ad697026249b768894c44345c37ed3"
|
|
49
49
|
}
|
package/src/useBrowser.js
CHANGED
|
@@ -2,6 +2,7 @@ import { useState } from 'react';
|
|
|
2
2
|
import isMobile from 'ismobilejs';
|
|
3
3
|
|
|
4
4
|
const DID_WALLET_TAG = 'ABTWallet';
|
|
5
|
+
const ARC_SPHERE_TAG = 'ArcSphere';
|
|
5
6
|
|
|
6
7
|
function getDIDWalletVersion(userAgent) {
|
|
7
8
|
const reg = new RegExp(`${DID_WALLET_TAG}/(?<version>[0-9.]+)`, 'g');
|
|
@@ -13,7 +14,7 @@ function getDIDWalletVersion(userAgent) {
|
|
|
13
14
|
export default function useBrowser() {
|
|
14
15
|
const userAgent = window?.navigator?.userAgent;
|
|
15
16
|
const [browser] = useState({
|
|
16
|
-
wallet: userAgent.indexOf(DID_WALLET_TAG) > -1,
|
|
17
|
+
wallet: userAgent.indexOf(DID_WALLET_TAG) > -1 || userAgent.indexOf(ARC_SPHERE_TAG) > -1,
|
|
17
18
|
walletVersion: getDIDWalletVersion(userAgent),
|
|
18
19
|
wechat: /MicroMessenger/i.test(userAgent),
|
|
19
20
|
mobile: {
|