hunter-open-sdk 2.0.0-beta.12 → 2.0.0-beta.13

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.
@@ -43,7 +43,7 @@ class Activate {
43
43
  if (!this.worker) {
44
44
  const workerPath = new _url.default.URL('file://' + (0, _utils.getCurrentEnvPath)(__dirname, './worker.js'));
45
45
  this.worker = new _webWorker.default(workerPath, {
46
- type: "module"
46
+ type: 'module'
47
47
  });
48
48
  }
49
49
  }
@@ -43,7 +43,7 @@ class Erase {
43
43
  if (!this.worker) {
44
44
  const workerPath = new _url.default.URL('file://' + (0, _utils.getCurrentEnvPath)(__dirname, './worker.js'));
45
45
  this.worker = new _webWorker.default(workerPath, {
46
- type: "module"
46
+ type: 'module'
47
47
  });
48
48
  }
49
49
  }
@@ -43,7 +43,7 @@ class GetGeneralReport {
43
43
  if (!this.worker) {
44
44
  const workerPath = new _url.default.URL('file://' + (0, _utils.getCurrentEnvPath)(__dirname, './worker.js'));
45
45
  this.worker = new _webWorker.default(workerPath, {
46
- type: "module"
46
+ type: 'module'
47
47
  });
48
48
  }
49
49
  }
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  var _utils = require("../../utils/utils.global");
4
+ const MAX_RETRY_COUNT = 3;
5
+ const RETRY_INTERVAL = 300;
6
+
4
7
  // 处理主进程消息
5
- function onMainMessage(event) {
8
+ function onMainMessage(event, retryCount = 0) {
6
9
  const {
7
10
  type,
8
11
  params
@@ -17,6 +20,21 @@ function onMainMessage(event) {
17
20
  };
18
21
  }
19
22
  const reportRes = (0, _utils.getGeneralReportCallKit)(params);
23
+ console.log(`第${retryCount + 1}次获取报告:`, reportRes);
24
+ const {
25
+ data: {
26
+ code
27
+ } = {}
28
+ } = reportRes;
29
+
30
+ // 如果获取报告失败,则重试一次
31
+ if (code !== 0 && retryCount < MAX_RETRY_COUNT) {
32
+ retryCount++;
33
+ setTimeout(() => {
34
+ onMainMessage(event, retryCount);
35
+ }, retryCount * RETRY_INTERVAL);
36
+ break;
37
+ }
20
38
  postMessage(reportRes);
21
39
  break;
22
40
  }
@@ -43,7 +43,7 @@ class GetSaaSReport {
43
43
  if (!this.worker) {
44
44
  const workerPath = new _url.default.URL('file://' + (0, _utils.getCurrentEnvPath)(__dirname, './worker.js'));
45
45
  this.worker = new _webWorker.default(workerPath, {
46
- type: "module"
46
+ type: 'module'
47
47
  });
48
48
  }
49
49
  }
@@ -43,7 +43,7 @@ class Skip {
43
43
  if (!this.worker) {
44
44
  const workerPath = new _url.default.URL('file://' + (0, _utils.getCurrentEnvPath)(__dirname, './worker.js'));
45
45
  this.worker = new _webWorker.default(workerPath, {
46
- type: "module"
46
+ type: 'module'
47
47
  });
48
48
  }
49
49
  }
@@ -24,9 +24,9 @@ class Service {
24
24
  (0, _winDriver.checkHasDriver)().then(res => {
25
25
  console.log('------------checkHasDriver', res);
26
26
  if (res) {
27
- mainWindow.webContents.send("checkDriver", true);
27
+ mainWindow.webContents.send('checkDriver', true);
28
28
  } else {
29
- mainWindow.webContents.send("checkDriver", false);
29
+ mainWindow.webContents.send('checkDriver', false);
30
30
  (0, _winDriver.downloadDriver)(mainWindow);
31
31
  }
32
32
  });
@@ -12,7 +12,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
12
12
  // import { app } from 'electron'
13
13
  // import { command } from '../../utils/utils.command'
14
14
 
15
- const Sentry = require("@sentry/browser");
15
+ const Sentry = require('@sentry/browser');
16
16
  const sudo = require('sudo-prompt');
17
17
  const path = require('path');
18
18
  const fs = require('fs');
package/lib/index.js CHANGED
@@ -11,9 +11,9 @@ var _getGeneralReport = require("./abilities/getGeneralReport");
11
11
  var _erase = require("./abilities/erase");
12
12
  var _activate = require("./abilities/activate");
13
13
  var _skip = require("./abilities/skip");
14
- const Sentry = require("@sentry/browser");
14
+ const Sentry = require('@sentry/browser');
15
15
  Sentry.init({
16
- dsn: "https://8a5296c59083430fbac0756f56ddbf5d@sentry.zhuanzhuan.com/2300",
16
+ dsn: 'https://8a5296c59083430fbac0756f56ddbf5d@sentry.zhuanzhuan.com/2300',
17
17
  tracesSampleRate: 1.0
18
18
  });
19
19
  console.log('Sentry initialized');
@@ -12,9 +12,9 @@ var _deviceHelper = require("../helper/deviceHelper");
12
12
  var _utils4 = require("../utils/utils.initDll");
13
13
  const usbmux = require('usbmux');
14
14
  const path = require('path');
15
- const request = require("request");
15
+ const request = require('request');
16
16
  const fs = require('fs');
17
- const Sentry = require("@sentry/browser");
17
+ const Sentry = require('@sentry/browser');
18
18
 
19
19
  // saas回调
20
20
  let saasCallBack;
@@ -55,7 +55,7 @@ const publishPair = (udid = '', params) => {
55
55
  /**
56
56
  * 获取信任状态
57
57
  * @param {String} udid 设备id
58
- * @returns
58
+ * @returns
59
59
  */
60
60
  const getTrustStatus = async (udid = '', params, once = false) => {
61
61
  if (!_deviceHelper.deviceHelper.hasUdid(udid)) {
@@ -96,7 +96,7 @@ const getTrustStatusOnce = async (udid, params) => {
96
96
  /**
97
97
  * 配对并获取信任状态
98
98
  * @param {String} udid 设备id
99
- * @returns
99
+ * @returns
100
100
  */
101
101
  const DevicePair = async (udid = '', params) => {
102
102
  const callBack = () => {
@@ -168,7 +168,7 @@ const updateDll = (packageUrl, targetVersion) => {
168
168
  dllOutPath = path.resolve(resourcePath, `dll/libinspectionkit_x64_${targetVersion}.dll`);
169
169
  }
170
170
  const dllStream = fs.createWriteStream(dllOutPath);
171
- request(packageUrl).pipe(dllStream).on("close", function (err) {
171
+ request(packageUrl).pipe(dllStream).on('close', function (err) {
172
172
  if (err) {
173
173
  saasCallBack({
174
174
  data: {
@@ -186,7 +186,7 @@ const updateDll = (packageUrl, targetVersion) => {
186
186
  /**
187
187
  * 更新下载dll文件 并重写本地版本号
188
188
  * @param {String} udid 设备id
189
- * @returns
189
+ * @returns
190
190
  */
191
191
  const updateDllFileCheck = () => {
192
192
  // mac的amd不支持更新
@@ -9,7 +9,7 @@ var _utils = require("../utils/utils.initDll");
9
9
  * 全局对象兼容性处理工具
10
10
  * 兼容Electron主进程(global)和渲染进程(window)环境
11
11
  */
12
- const Sentry = require("@sentry/browser");
12
+ const Sentry = require('@sentry/browser');
13
13
  /**
14
14
  * 获取全局对象
15
15
  * @returns {Object} 全局对象
@@ -14,7 +14,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
14
14
  /**
15
15
  * 声明dll函数
16
16
  * @param {String} udid 设备id
17
- * @returns
17
+ * @returns
18
18
  */
19
19
 
20
20
  const initHunterInspectionKit = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hunter-open-sdk",
3
- "version": "2.0.0-beta.12",
3
+ "version": "2.0.0-beta.13",
4
4
  "description": "采货侠SaaS版本桌面端sdk",
5
5
  "scripts": {
6
6
  "start": "zz dev",