@pisell/utils 1.0.3 → 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/log.d.ts CHANGED
@@ -6,7 +6,5 @@ interface sendWebhookProps {
6
6
  title: string;
7
7
  content: contentItem[];
8
8
  }
9
- declare const _default: {
10
- sendWarningLog: ({ title, content }: sendWebhookProps) => Promise<any>;
11
- };
12
- export default _default;
9
+ export declare const sendWarningLog: ({ title, content }: sendWebhookProps) => Promise<any>;
10
+ export {};
package/es/log.js CHANGED
@@ -14,7 +14,7 @@ var createFeishuMessageContent = function createFeishuMessageContent(contentArr)
14
14
  }];
15
15
  }));
16
16
  };
17
- var sendWarningLog = /*#__PURE__*/function () {
17
+ export var sendWarningLog = /*#__PURE__*/function () {
18
18
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
19
19
  var title, content, contentStr, response;
20
20
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -48,7 +48,4 @@ var sendWarningLog = /*#__PURE__*/function () {
48
48
  return function sendWarningLog(_x) {
49
49
  return _ref2.apply(this, arguments);
50
50
  };
51
- }();
52
- export default {
53
- sendWarningLog: sendWarningLog
54
- };
51
+ }();
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/log.d.ts CHANGED
@@ -6,7 +6,5 @@ interface sendWebhookProps {
6
6
  title: string;
7
7
  content: contentItem[];
8
8
  }
9
- declare const _default: {
10
- sendWarningLog: ({ title, content }: sendWebhookProps) => Promise<any>;
11
- };
12
- export default _default;
9
+ export declare const sendWarningLog: ({ title, content }: sendWebhookProps) => Promise<any>;
10
+ export {};
package/lib/log.js CHANGED
@@ -19,7 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/log.ts
20
20
  var log_exports = {};
21
21
  __export(log_exports, {
22
- default: () => log_default
22
+ sendWarningLog: () => sendWarningLog
23
23
  });
24
24
  module.exports = __toCommonJS(log_exports);
25
25
  var import_constants = require("./constants");
@@ -47,6 +47,7 @@ var sendWarningLog = async ({ title, content }) => {
47
47
  });
48
48
  return await response.json();
49
49
  };
50
- var log_default = {
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
51
52
  sendWarningLog
52
- };
53
+ });
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.3",
3
+ "version": "1.0.5",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",