@pisell/utils 1.0.4 → 1.0.5

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/es/platform.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export declare const isIpad: () => boolean;
2
2
  export declare const isMobile: () => boolean;
3
+ export declare const isAndroid: () => boolean;
4
+ export declare const isIos: () => boolean;
package/es/platform.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export var isIpad = function isIpad() {
2
2
  var ua = navigator.userAgent;
3
- var isSafari = ua.indexOf('Safari') != -1 && ua.indexOf('Version') != -1;
4
- var isIphone = ua.indexOf('iPhone') != -1 && ua.indexOf('Version') != -1;
5
- var isIPad = isSafari && !isIphone && 'ontouchend' in document;
3
+ var isSafari = ua.indexOf("Safari") != -1 && ua.indexOf("Version") != -1;
4
+ var isIphone = ua.indexOf("iPhone") != -1 && ua.indexOf("Version") != -1;
5
+ var isIPad = isSafari && !isIphone && "ontouchend" in document;
6
6
  if (!/iphone|ios|ipad|android|mobile/i.test(navigator.userAgent.toLowerCase()) && !isIPad) {
7
7
  return false;
8
8
  }
@@ -10,17 +10,27 @@ export var isIpad = function isIpad() {
10
10
  };
11
11
  export var isMobile = function isMobile() {
12
12
  var sUserAgent = window.navigator.userAgent.toLowerCase();
13
- var bIsIpad = sUserAgent.match(/ipad/i) == 'ipad';
14
- var bIsIphoneOs = sUserAgent.match(/iphone os/i) == 'iphone os';
15
- var bIsMidp = sUserAgent.match(/midp/i) == 'midp';
16
- var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == 'rv:1.2.3.4';
17
- var bIsUc = sUserAgent.match(/ucweb/i) == 'ucweb';
18
- var bIsAndroid = sUserAgent.match(/android/i) == 'android';
19
- var bIsCE = sUserAgent.match(/windows ce/i) == 'windows ce';
20
- var bIsWM = sUserAgent.match(/windows mobile/i) == 'windows mobile';
13
+ var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
14
+ var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
15
+ var bIsMidp = sUserAgent.match(/midp/i) == "midp";
16
+ var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
17
+ var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
18
+ var bIsAndroid = sUserAgent.match(/android/i) == "android";
19
+ var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
20
+ var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
21
21
  if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM || isIpad()) {
22
22
  return true;
23
23
  } else {
24
24
  return false;
25
25
  }
26
+ };
27
+
28
+ // 是否是安卓平台
29
+ export var isAndroid = function isAndroid() {
30
+ return navigator.userAgent.toLowerCase().indexOf("android") !== -1;
31
+ };
32
+
33
+ // 是否是ios平台
34
+ export var isIos = function isIos() {
35
+ return /iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase());
26
36
  };
package/lib/platform.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export declare const isIpad: () => boolean;
2
2
  export declare const isMobile: () => boolean;
3
+ export declare const isAndroid: () => boolean;
4
+ export declare const isIos: () => boolean;
package/lib/platform.js CHANGED
@@ -19,6 +19,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/platform.ts
20
20
  var platform_exports = {};
21
21
  __export(platform_exports, {
22
+ isAndroid: () => isAndroid,
23
+ isIos: () => isIos,
22
24
  isIpad: () => isIpad,
23
25
  isMobile: () => isMobile
24
26
  });
@@ -51,8 +53,16 @@ var isMobile = () => {
51
53
  return false;
52
54
  }
53
55
  };
56
+ var isAndroid = () => {
57
+ return navigator.userAgent.toLowerCase().indexOf("android") !== -1;
58
+ };
59
+ var isIos = () => {
60
+ return /iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase());
61
+ };
54
62
  // Annotate the CommonJS export names for ESM import in node:
55
63
  0 && (module.exports = {
64
+ isAndroid,
65
+ isIos,
56
66
  isIpad,
57
67
  isMobile
58
68
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/utils",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",