hunter-open-sdk 2.0.0-beta.3 → 2.0.0-beta.30

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.
Files changed (52) hide show
  1. package/lib/abilities/activate/index.js +51 -0
  2. package/lib/abilities/activate/worker.js +19 -0
  3. package/lib/abilities/erase/index.js +51 -0
  4. package/lib/abilities/erase/worker.js +19 -0
  5. package/lib/abilities/eventManager/index.js +347 -0
  6. package/lib/abilities/getAndroidReport/index.js +60 -0
  7. package/lib/abilities/getAndroidReport/worker.js +21 -0
  8. package/lib/abilities/getAndroidSn/index.js +187 -0
  9. package/lib/abilities/getGeneralReport/index.js +75 -0
  10. package/lib/abilities/getGeneralReport/worker.js +38 -0
  11. package/lib/abilities/getSaaSReport/index.js +51 -0
  12. package/lib/abilities/getSaaSReport/worker.js +21 -0
  13. package/lib/abilities/getUltimateReport/index.js +59 -0
  14. package/lib/abilities/getUltimateReport/worker.js +21 -0
  15. package/lib/abilities/installApp/index.js +51 -0
  16. package/lib/abilities/installApp/worker.js +19 -0
  17. package/lib/abilities/reboot/index.js +51 -0
  18. package/lib/abilities/reboot/worker.js +19 -0
  19. package/lib/abilities/shutdown/index.js +51 -0
  20. package/lib/abilities/shutdown/worker.js +19 -0
  21. package/lib/abilities/skip/index.js +51 -0
  22. package/lib/abilities/skip/worker.js +19 -0
  23. package/lib/constants/index.js +28 -0
  24. package/lib/events/driver/command.js +8 -9
  25. package/lib/events/driver/winDriver.js +123 -189
  26. package/lib/helper/deviceHelper.js +19 -37
  27. package/lib/index.d.ts +70 -0
  28. package/lib/index.js +115 -13
  29. package/lib/index.mjs +2 -0
  30. package/lib/resources/dll/{libinspectionkit_x64_0.1.0.dll → libinspectionkit_x64_0.6.1.dll} +0 -0
  31. package/lib/resources/{mac/libinspectionkit_arm64_0.1.0.dylib → dylib/libinspectionkit_amd64_0.6.1.dylib} +0 -0
  32. package/lib/resources/dylib/libinspectionkit_arm64_0.6.1.dylib +0 -0
  33. package/lib/resources/version.online +1 -1
  34. package/lib/utils/utils.ability.js +9 -0
  35. package/lib/utils/utils.command.js +8 -9
  36. package/lib/utils/utils.common.js +26 -0
  37. package/lib/utils/{utils.js → utils.env.js} +19 -18
  38. package/lib/utils/utils.global.js +70 -89
  39. package/lib/utils/utils.initDll.js +16 -14
  40. package/lib/utils/utils.path.js +56 -7
  41. package/lib/utils/utils.process.js +35 -0
  42. package/lib/utils/utils.sn.js +41 -56
  43. package/lib/utils/utils.worker.js +32 -0
  44. package/package.json +15 -8
  45. package/lib/events/driver/service.js +0 -47
  46. package/lib/getAndroidSn/index.js +0 -228
  47. package/lib/getGeneralReport/index.js +0 -76
  48. package/lib/getGeneralReport/worker.js +0 -20
  49. package/lib/getSaaSReport/index.js +0 -76
  50. package/lib/getSaaSReport/worker.js +0 -20
  51. package/lib/registerEvent/index.js +0 -427
  52. package/lib/resources/mac/libinspectionkit_amd64_0.1.0.dylib +0 -0
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
@@ -8,40 +7,43 @@ exports.initHunterInspectionKit = void 0;
8
7
  var _koffi = _interopRequireDefault(require("koffi"));
9
8
  var _path = _interopRequireDefault(require("path"));
10
9
  var _fs = _interopRequireDefault(require("fs"));
11
- var _utils = require("./utils");
10
+ var _utils = require("./utils.env");
12
11
  var _utils2 = require("./utils.global");
12
+ var _utils3 = require("./utils.path");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14
  /**
14
15
  * 声明dll函数
15
16
  * @param {String} udid 设备id
16
- * @returns
17
+ * @returns
17
18
  */
18
19
 
19
- var initHunterInspectionKit = exports.initHunterInspectionKit = function initHunterInspectionKit() {
20
- var dllPath;
20
+ const initHunterInspectionKit = () => {
21
+ let dllPath;
21
22
 
22
23
  // 读取本地sdk的version
23
- var versionPath = _path.default.resolve(__dirname, '../resources/version.online');
24
- var version = _fs.default.readFileSync(versionPath, 'utf-8');
24
+ const versionPath = (0, _utils3.getPathWithLocalResource)('version.online');
25
+ const version = _fs.default.readFileSync(versionPath, 'utf-8').trim();
25
26
  if ((0, _utils.isMac)()) {
26
27
  if ((0, _utils.isArm64)()) {
27
- dllPath = _path.default.resolve(__dirname, "../resources/mac/libinspectionkit_arm64_".concat(version, ".dylib"));
28
+ dllPath = (0, _utils3.getPathWithLocalResource)(`dylib/libinspectionkit_arm64_${version}.dylib`);
28
29
  }
29
30
  if ((0, _utils.isAmd64)()) {
30
- dllPath = _path.default.resolve(__dirname, "../resources/mac/libinspectionkit_amd64_".concat(version, ".dylib"));
31
+ dllPath = (0, _utils3.getPathWithLocalResource)(`dylib/libinspectionkit_amd64_${version}.dylib`);
31
32
  }
32
33
  } else {
33
- dllPath = _path.default.resolve(__dirname, "../resources/dll/libinspectionkit_x64_".concat(version, ".dll"));
34
+ dllPath = (0, _utils3.getPathWithLocalResource)(`dll/libinspectionkit_x64_${version}.dll`);
34
35
  }
35
36
  if (!(0, _utils.isDev)()) {
36
37
  // 如果是生产模式 则替换app.asar 路径 为了在生产调用dll
37
- dllPath = dllPath.replace('app.asar', 'app.asar.unpacked');
38
+ dllPath = (0, _utils3.convertPathWithCurrentEnv)(dllPath);
38
39
  }
39
- var dllLib = _koffi.default.load(dllPath);
40
- var dllKit = {
40
+ const dllLib = _koffi.default.load(dllPath);
41
+ const dllKit = {
41
42
  InspectionKit: dllLib.func('InspectionKit', 'str', ['str', 'str', 'str']),
42
43
  TheForceKit: dllLib.func('TheForceKit', 'str', ['str'])
43
44
  };
44
45
 
45
46
  // 挂载到全局对象,兼容主进程和渲染进程
46
47
  (0, _utils2.setGlobalProperty)('HunterInspectionKit', dllKit);
47
- };
48
+ };
49
+ exports.initHunterInspectionKit = initHunterInspectionKit;
@@ -3,14 +3,63 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.currentEnvPath = void 0;
7
- var path = require('path');
8
-
6
+ exports.convertPathWithCurrentEnv = convertPathWithCurrentEnv;
7
+ exports.getCurrentNodePath = getCurrentNodePath;
8
+ exports.getPathWithCWD = getPathWithCWD;
9
+ exports.getPathWithElectornResource = getPathWithElectornResource;
10
+ exports.getPathWithLocalResource = getPathWithLocalResource;
11
+ var _path = _interopRequireDefault(require("path"));
12
+ var _process = _interopRequireDefault(require("process"));
13
+ var _utils = require("./utils.env");
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
15
  /**
10
16
  * 当前环境地址转换
11
- * @param {*} path
17
+ * @param {*} dirPath 目录路径
18
+ * @param {*} filePath 文件路径,默认为空字符串
19
+ * @returns
20
+ */
21
+ function convertPathWithCurrentEnv(dirPath, filePath = '') {
22
+ let fixPath = dirPath;
23
+ if (!(0, _utils.isDev)()) {
24
+ fixPath = fixPath.replace('/app.asar/', '/app.asar.unpacked/').replace('\\app.asar\\', '\\app.asar.unpacked\\');
25
+ }
26
+ return _path.default.join(fixPath, filePath);
27
+ }
28
+
29
+ /**
30
+ * 当前项目resources目录地址转换
31
+ * @param {*} dirPath
12
32
  * @returns
13
33
  */
14
- var currentEnvPath = exports.currentEnvPath = function currentEnvPath(filePath) {
15
- return path.resolve(__dirname, filePath);
16
- };
34
+ function getPathWithLocalResource(dirPath) {
35
+ const resourcesPath = _path.default.join(__dirname, '../resources');
36
+ return _path.default.join(resourcesPath, dirPath);
37
+ }
38
+
39
+ /**
40
+ * Electron资源目录地址转换
41
+ * @param {*} dirPath
42
+ * @returns
43
+ */
44
+ function getPathWithElectornResource(dirPath) {
45
+ console.log('getPathWithElectornResource resourcesPath => ', _process.default.type || 'node', _process.default.resourcesPath);
46
+ return _path.default.join(_process.default.resourcesPath || '', dirPath);
47
+ }
48
+
49
+ /**
50
+ * 当前工作目录地址转换
51
+ * @param {*} dirPath
52
+ * @returns
53
+ */
54
+ function getPathWithCWD(dirPath) {
55
+ const cwd = _process.default.cwd();
56
+ return _path.default.join(cwd, dirPath);
57
+ }
58
+
59
+ /**
60
+ * 获取当前nodePath环境变量
61
+ * @returns
62
+ */
63
+ function getCurrentNodePath() {
64
+ return _process.default.env.NODE_PATH || '';
65
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getCurrentProcess = getCurrentProcess;
7
+ exports.getProccessType = getProccessType;
8
+ exports.isInMainProcess = isInMainProcess;
9
+ exports.isInRenderProcess = isInRenderProcess;
10
+ // 获取进程类型
11
+ function getProccessType() {
12
+ return process.type;
13
+ }
14
+
15
+ // 是否在主进程
16
+ function isInMainProcess() {
17
+ return getProccessType() === 'browser';
18
+ }
19
+
20
+ // 是否在渲染进程
21
+ // eslint-disable-next-line no-unused-vars
22
+ function isInRenderProcess() {
23
+ return getProccessType() === 'renderer';
24
+ }
25
+ function getCurrentProcess() {
26
+ if (typeof process === 'undefined' || process.type === undefined) {
27
+ return '这是在浏览器环境中';
28
+ } else {
29
+ if (process.type === 'browser') {
30
+ return '这是在 Node.js 环境中';
31
+ } else {
32
+ return '这是在 Electron 的渲染进程中';
33
+ }
34
+ }
35
+ }
@@ -3,39 +3,33 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.SUPPORT_PHONE_VENDORS = exports.SUPPORT_PHONE_BRANDS = void 0;
6
7
  exports.parseWmicOutput = parseWmicOutput;
7
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
8
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
9
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
+ // 只支持三星、荣耀、华为的手机设备关键词
9
+ const SUPPORT_PHONE_BRANDS = exports.SUPPORT_PHONE_BRANDS = ['samsung', 'galaxy', 'huawei', 'honor', 'honor magic'];
10
+
11
+ // 只支持三星、荣耀、华为的手机厂商VID
12
+ const SUPPORT_PHONE_VENDORS = exports.SUPPORT_PHONE_VENDORS = ['VID_04E8',
13
+ // Samsung
14
+ 'VID_12D1',
15
+ // Huawei
16
+ 'VID_2A45' // Honor (OnePlus VID,但荣耀也使用此VID)
17
+ ];
18
+
10
19
  /**
11
20
  * 判断设备是否为手机设备
12
21
  * @param {Object} device - 设备信息
13
22
  * @returns {boolean} 是否为手机设备
14
23
  */
15
24
  function isPhoneDevice(device) {
16
- var name = device.name.toLowerCase();
17
- var pnpId = device.pnpDeviceId.toLowerCase();
18
-
19
- // 只支持三星、荣耀、华为的手机设备关键词
20
- var phoneKeywords = ['samsung', 'galaxy', 'huawei', 'honor', 'honor magic'];
21
-
22
- // 只支持三星、荣耀、华为的手机厂商VID
23
- var phoneVendors = ['VID_04E8',
24
- // Samsung
25
- 'VID_12D1',
26
- // Huawei
27
- 'VID_2A45' // Honor (OnePlus VID,但荣耀也使用此VID)
28
- ];
25
+ const name = device.name.toLowerCase();
26
+ const pnpId = device.pnpDeviceId.toLowerCase();
29
27
 
30
28
  // 检查名称中是否包含手机关键词
31
- var isPhoneByName = phoneKeywords.some(function (keyword) {
32
- return name.includes(keyword);
33
- });
29
+ const isPhoneByName = SUPPORT_PHONE_BRANDS.some(keyword => name.includes(keyword));
34
30
 
35
31
  // 检查PNPDeviceID中是否包含手机厂商VID
36
- var isPhoneByVendor = phoneVendors.some(function (vendor) {
37
- return pnpId.includes(vendor.toLowerCase());
38
- });
32
+ const isPhoneByVendor = SUPPORT_PHONE_VENDORS.some(vendor => pnpId.includes(vendor.toLowerCase()));
39
33
  return isPhoneByName || isPhoneByVendor;
40
34
  }
41
35
 
@@ -46,9 +40,9 @@ function isPhoneDevice(device) {
46
40
  */
47
41
  function extractSerialNumber(pnpDeviceId) {
48
42
  // USB设备ID格式通常为: USB\VID_v(4)&PID_d(4)\序列号
49
- var parts = pnpDeviceId.split('\\');
43
+ const parts = pnpDeviceId.split('\\');
50
44
  if (parts.length >= 3) {
51
- var serialPart = parts[parts.length - 1];
45
+ const serialPart = parts[parts.length - 1];
52
46
 
53
47
  // 验证序列号格式(通常不包含&和#等特殊字符)
54
48
  if (serialPart && !serialPart.includes('&') && !serialPart.includes('#')) {
@@ -65,43 +59,34 @@ function extractSerialNumber(pnpDeviceId) {
65
59
  * @returns {Array} 手机设备信息数组
66
60
  */
67
61
  function parseWmicOutput(output) {
68
- var devices = [];
69
- var lines = output.split('\r\n');
70
- var currentDevice = {};
71
- var _iterator = _createForOfIteratorHelper(lines),
72
- _step;
73
- try {
74
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
75
- var line = _step.value;
76
- // 跳过空行
77
- if (!line.trim()) {
78
- // 如果当前设备有数据,则保存
79
- if (currentDevice.name && currentDevice.pnpDeviceId) {
80
- // 检查是否为手机设备
81
- if (isPhoneDevice(currentDevice)) {
82
- // 提取序列号
83
- currentDevice.serial = extractSerialNumber(currentDevice.pnpDeviceId);
84
- devices.push(currentDevice);
85
- }
62
+ const devices = [];
63
+ const lines = output.split('\r\n');
64
+ let currentDevice = {};
65
+ for (const line of lines) {
66
+ // 跳过空行
67
+ if (!line.trim()) {
68
+ // 如果当前设备有数据,则保存
69
+ if (currentDevice.name && currentDevice.pnpDeviceId) {
70
+ // 检查是否为手机设备
71
+ if (isPhoneDevice(currentDevice)) {
72
+ // 提取序列号
73
+ currentDevice.serial = extractSerialNumber(currentDevice.pnpDeviceId);
74
+ devices.push(currentDevice);
86
75
  }
87
- currentDevice = {};
88
- continue;
89
- }
90
-
91
- // 解析Name和PNPDeviceID
92
- if (line.startsWith('Name=')) {
93
- currentDevice.name = line.substring(5).trim();
94
- } else if (line.startsWith('PNPDeviceID=')) {
95
- currentDevice.pnpDeviceId = line.substring(12).trim();
96
76
  }
77
+ currentDevice = {};
78
+ continue;
97
79
  }
98
80
 
99
- // 处理最后一个设备
100
- } catch (err) {
101
- _iterator.e(err);
102
- } finally {
103
- _iterator.f();
81
+ // 解析Name和PNPDeviceID
82
+ if (line.startsWith('Name=')) {
83
+ currentDevice.name = line.substring(5).trim();
84
+ } else if (line.startsWith('PNPDeviceID=')) {
85
+ currentDevice.pnpDeviceId = line.substring(12).trim();
86
+ }
104
87
  }
88
+
89
+ // 处理最后一个设备
105
90
  if (currentDevice.name && currentDevice.pnpDeviceId && isPhoneDevice(currentDevice)) {
106
91
  currentDevice.serial = extractSerialNumber(currentDevice.pnpDeviceId);
107
92
  devices.push(currentDevice);
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getAsarNodePath = getAsarNodePath;
7
+ exports.initWorkerNodePath = initWorkerNodePath;
8
+ const path = require('path');
9
+ const _module = require('module');
10
+ const {
11
+ getPathWithElectornResource,
12
+ getCurrentNodePath
13
+ } = require("./utils.path");
14
+ function getAsarNodePath() {
15
+ const asarRoot = getPathWithElectornResource('app.asar');
16
+ const unpackedRoot = getPathWithElectornResource('app.asar.unpacked');
17
+ const nodeModulesPaths = [path.join(asarRoot, 'node_modules'), path.join(unpackedRoot, 'node_modules')];
18
+ return nodeModulesPaths.join(path.delimiter);
19
+ }
20
+ function initWorkerNodePath() {
21
+ const currentNodePath = getCurrentNodePath();
22
+ if (currentNodePath.includes('app.asar') && currentNodePath.includes('app.asar.unpacked')) {
23
+ console.log('Has process.env.NODE_PATH =>', process.env.NODE_PATH);
24
+ _module.Module._initPaths();
25
+ return;
26
+ }
27
+ const asarNodePath = getAsarNodePath();
28
+ const nodePathArr = [currentNodePath, asarNodePath];
29
+ process.env.NODE_PATH = nodePathArr.filter(Boolean).join(path.delimiter);
30
+ console.log('Set process.env.NODE_PATH =>', process.env.NODE_PATH);
31
+ _module.Module._initPaths();
32
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hunter-open-sdk",
3
- "version": "2.0.0-beta.3",
3
+ "version": "2.0.0-beta.30",
4
4
  "description": "采货侠SaaS版本桌面端sdk",
5
5
  "scripts": {
6
6
  "start": "zz dev",
@@ -11,8 +11,8 @@
11
11
  "fix": "zz lint --fix",
12
12
  "staged": "zz lint --staged",
13
13
  "staged-fix": "zz --staged --fix",
14
- "pub": "zz pub",
15
- "pub-beta": "zz pub --beta",
14
+ "pub": "npm run build && npm publish",
15
+ "pub-beta": "npm run build && npm publish --tag beta",
16
16
  "unpub": "zz pub --unpub",
17
17
  "doc": "zz doc && zz doc --upload",
18
18
  "dev-doc": "zz doc --dev",
@@ -22,13 +22,20 @@
22
22
  "prepare": "npx lefthook install"
23
23
  },
24
24
  "main": "lib/index.js",
25
+ "module": "lib/index.mjs",
25
26
  "types": "lib/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "import": "./lib/index.mjs",
30
+ "require": "./lib/index.js",
31
+ "types": "./lib/index.d.ts"
32
+ }
33
+ },
26
34
  "author": "xiexing <xiexing@zhuanzhuan.com>",
27
35
  "license": "ISC",
28
36
  "dependencies": {
29
37
  "@sentry/browser": "^10.10.0",
30
38
  "compressing": "2.0.0",
31
- "core-js": "3.6.5",
32
39
  "fs": "^0.0.1-security",
33
40
  "fs-extra": "^11.3.0",
34
41
  "koffi": "2.14.1",
@@ -36,10 +43,10 @@
36
43
  "request": "^2.88.2",
37
44
  "sudo-prompt": "^9.2.1",
38
45
  "usb": "^2.15.0",
39
- "usbmux": "^0.1.0"
46
+ "usbmux": "^0.1.0",
47
+ "web-worker": "1.5.0"
40
48
  },
41
49
  "devDependencies": {
42
- "@babel/plugin-transform-runtime": "7.21.0",
43
50
  "@commitlint/cli": "8.3.5",
44
51
  "@commitlint/config-conventional": "8.3.4",
45
52
  "@evilmartians/lefthook": "0.8.0",
@@ -53,6 +60,7 @@
53
60
  "commitlint": "17.0.2",
54
61
  "father": "4.6.7",
55
62
  "lint-staged": "10.0.8",
63
+ "minimatch": "3.0.0",
56
64
  "path-to-regexp": "2.4.0",
57
65
  "typedoc": "0.23.9",
58
66
  "typescript": "4.7.4"
@@ -63,8 +71,7 @@
63
71
  }
64
72
  },
65
73
  "files": [
66
- "lib",
67
- "es"
74
+ "lib"
68
75
  ],
69
76
  "engines": {
70
77
  "node": ">=20.0.0"
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _utils = require("../../utils/utils");
11
- var _command = require("./command");
12
- var _winDriver = require("./winDriver");
13
- var path = require('path');
14
- var Service = /*#__PURE__*/function () {
15
- function Service() {
16
- (0, _classCallCheck2.default)(this, Service);
17
- }
18
- (0, _createClass2.default)(Service, [{
19
- key: "setup",
20
- value:
21
- // constructor () {}
22
- function setup(mainWindow) {
23
- console.log('Service setup');
24
- if ((0, _utils.isMac)()) {
25
- if ((0, _utils.isDev)()) {
26
- (0, _command.command)(path.join(process.cwd(), './extraResources/ightools'));
27
- }
28
- if ((0, _utils.isProd)()) {
29
- (0, _command.command)('nohup ' + path.join(process.resourcesPath, './extraResources/ightools') + ' > /dev/null 2>&1 & > ' + path.join(process.resourcesPath, './log/ightools.log'));
30
- }
31
- }
32
- if ((0, _utils.isWin)()) {
33
- (0, _winDriver.checkHasDriver)().then(function (res) {
34
- console.log('------------checkHasDriver', res);
35
- if (res) {
36
- mainWindow.webContents.send("checkDriver", true);
37
- } else {
38
- mainWindow.webContents.send("checkDriver", false);
39
- (0, _winDriver.downloadDriver)(mainWindow);
40
- }
41
- });
42
- }
43
- }
44
- }]);
45
- return Service;
46
- }();
47
- var _default = exports.default = Service;