@arcblock/react-hooks 2.11.7 → 2.11.8

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.
@@ -1,6 +1,8 @@
1
1
  export default function useBrowser(): {
2
2
  wallet: boolean;
3
3
  walletVersion: string | undefined;
4
+ arcSphere: boolean;
5
+ arcSphereVersion: string | undefined;
4
6
  wechat: boolean;
5
7
  mobile: {
6
8
  apple: {
package/lib/useBrowser.js CHANGED
@@ -4,8 +4,8 @@ import isMobile from 'ismobilejs';
4
4
  const DID_WALLET_TAG = 'ABTWallet';
5
5
  const ARC_SPHERE_TAG = 'ArcSphere';
6
6
 
7
- function getDIDWalletVersion(userAgent) {
8
- const reg = new RegExp(`${DID_WALLET_TAG}/(?<version>[0-9.]+)`, 'g');
7
+ function getUaVersion(userAgent, tag) {
8
+ const reg = new RegExp(`${tag}/(?<version>[0-9.]+)`, 'g');
9
9
  const result = reg.exec(userAgent);
10
10
  const version = result?.groups?.version;
11
11
  return version;
@@ -14,8 +14,13 @@ function getDIDWalletVersion(userAgent) {
14
14
  export default function useBrowser() {
15
15
  const userAgent = window?.navigator?.userAgent;
16
16
  const [browser] = useState({
17
+ // FIXME: @zhanghan 待应用中相关代码兼容 arcSphere 的判断后,才能移除 arcSphere 的判断
18
+ // https://github.com/search?q=org%3AArcBlock%20browser.wallet&type=code
19
+ // https://github.com/search?q=org%3Ablocklet+browser.wallet&type=code
17
20
  wallet: userAgent.indexOf(DID_WALLET_TAG) > -1 || userAgent.indexOf(ARC_SPHERE_TAG) > -1,
18
- walletVersion: getDIDWalletVersion(userAgent),
21
+ walletVersion: getUaVersion(userAgent, DID_WALLET_TAG),
22
+ arcSphere: userAgent.indexOf(ARC_SPHERE_TAG) > -1,
23
+ arcSphereVersion: getUaVersion(userAgent, ARC_SPHERE_TAG),
19
24
  wechat: /MicroMessenger/i.test(userAgent),
20
25
  mobile: {
21
26
  apple: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/react-hooks",
3
- "version": "2.11.7",
3
+ "version": "2.11.8",
4
4
  "description": "React hooks used by arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -46,5 +46,5 @@
46
46
  "jest": "^29.7.0",
47
47
  "unbuild": "^2.0.0"
48
48
  },
49
- "gitHead": "1561a224b2ac2e0f8ec38fdaa4983d0582b418ba"
49
+ "gitHead": "a73181c78c51f12508fa3878a1f1c628517376f9"
50
50
  }
package/src/useBrowser.js CHANGED
@@ -4,8 +4,8 @@ import isMobile from 'ismobilejs';
4
4
  const DID_WALLET_TAG = 'ABTWallet';
5
5
  const ARC_SPHERE_TAG = 'ArcSphere';
6
6
 
7
- function getDIDWalletVersion(userAgent) {
8
- const reg = new RegExp(`${DID_WALLET_TAG}/(?<version>[0-9.]+)`, 'g');
7
+ function getUaVersion(userAgent, tag) {
8
+ const reg = new RegExp(`${tag}/(?<version>[0-9.]+)`, 'g');
9
9
  const result = reg.exec(userAgent);
10
10
  const version = result?.groups?.version;
11
11
  return version;
@@ -14,8 +14,13 @@ function getDIDWalletVersion(userAgent) {
14
14
  export default function useBrowser() {
15
15
  const userAgent = window?.navigator?.userAgent;
16
16
  const [browser] = useState({
17
+ // FIXME: @zhanghan 待应用中相关代码兼容 arcSphere 的判断后,才能移除 arcSphere 的判断
18
+ // https://github.com/search?q=org%3AArcBlock%20browser.wallet&type=code
19
+ // https://github.com/search?q=org%3Ablocklet+browser.wallet&type=code
17
20
  wallet: userAgent.indexOf(DID_WALLET_TAG) > -1 || userAgent.indexOf(ARC_SPHERE_TAG) > -1,
18
- walletVersion: getDIDWalletVersion(userAgent),
21
+ walletVersion: getUaVersion(userAgent, DID_WALLET_TAG),
22
+ arcSphere: userAgent.indexOf(ARC_SPHERE_TAG) > -1,
23
+ arcSphereVersion: getUaVersion(userAgent, ARC_SPHERE_TAG),
19
24
  wechat: /MicroMessenger/i.test(userAgent),
20
25
  mobile: {
21
26
  apple: {