hunter-open-sdk 0.0.13 → 0.0.15
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/lib/events/driver/winDriver.js +51 -16
- package/package.json +1 -1
|
@@ -68,10 +68,13 @@ var checkCache = function checkCache() {
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
// 轮询检测是否存在进程
|
|
71
|
+
var processCheckTimer = null;
|
|
71
72
|
var checkProcessTimer = function checkProcessTimer() {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
// 清除之前的定时器
|
|
74
|
+
if (processCheckTimer) {
|
|
75
|
+
clearTimeout(processCheckTimer);
|
|
76
|
+
}
|
|
77
|
+
processCheckTimer = setTimeout( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
75
78
|
var hasDriver;
|
|
76
79
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
77
80
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -84,9 +87,14 @@ var checkProcessTimer = function checkProcessTimer() {
|
|
|
84
87
|
_context.next = 6;
|
|
85
88
|
break;
|
|
86
89
|
}
|
|
87
|
-
|
|
90
|
+
// 检测到驱动,清除定时器并返回
|
|
91
|
+
if (processCheckTimer) {
|
|
92
|
+
clearTimeout(processCheckTimer);
|
|
93
|
+
processCheckTimer = null;
|
|
94
|
+
}
|
|
88
95
|
return _context.abrupt("return");
|
|
89
96
|
case 6:
|
|
97
|
+
// 继续轮询检测
|
|
90
98
|
checkProcessTimer();
|
|
91
99
|
case 7:
|
|
92
100
|
case "end":
|
|
@@ -101,6 +109,12 @@ var installDriver = function installDriver() {
|
|
|
101
109
|
var AppleMobileDeviceSupport64 = path.join(CACHE_PATH, './AppleMobileDeviceSupport64.msi');
|
|
102
110
|
var Bonjour64 = path.join(CACHE_PATH, './Bonjour64.msi');
|
|
103
111
|
var cmdStr = "start /i /wait ".concat(AppleApplicationSupport, " /qn && start /i /wait ").concat(AppleApplicationSupport64, " /qn && start /i /wait ").concat(AppleMobileDeviceSupport64, " /qn && start /i /wait ").concat(Bonjour64, " /qn");
|
|
112
|
+
console.log('开始安装驱动,命令:', cmdStr);
|
|
113
|
+
console.log('检查安装文件是否存在:');
|
|
114
|
+
console.log('AppleApplicationSupport:', fs.existsSync(AppleApplicationSupport));
|
|
115
|
+
console.log('AppleApplicationSupport64:', fs.existsSync(AppleApplicationSupport64));
|
|
116
|
+
console.log('AppleMobileDeviceSupport64:', fs.existsSync(AppleMobileDeviceSupport64));
|
|
117
|
+
console.log('Bonjour64:', fs.existsSync(Bonjour64));
|
|
104
118
|
return new Promise(function (resolve, reject) {
|
|
105
119
|
sudo.exec(cmdStr, options, function (error, stdout, stderr) {
|
|
106
120
|
console.log('安装 error>>', error);
|
|
@@ -113,8 +127,10 @@ var installDriver = function installDriver() {
|
|
|
113
127
|
}
|
|
114
128
|
checkProcessTimer();
|
|
115
129
|
if (error) {
|
|
130
|
+
console.error('驱动安装失败:', error);
|
|
116
131
|
reject(error); // 安装失败
|
|
117
132
|
} else {
|
|
133
|
+
console.log('驱动安装成功');
|
|
118
134
|
resolve(); // 安装成功
|
|
119
135
|
}
|
|
120
136
|
});
|
|
@@ -123,11 +139,13 @@ var installDriver = function installDriver() {
|
|
|
123
139
|
// 解压文件
|
|
124
140
|
var uncopressingFile = function uncopressingFile(filePath) {
|
|
125
141
|
return new Promise(function (resolve) {
|
|
142
|
+
console.log('开始解压文件:', filePath);
|
|
126
143
|
compressing.zip.uncompress(filePath, CACHE_PATH).then(function () {
|
|
144
|
+
console.log('文件解压成功');
|
|
127
145
|
resolve(true);
|
|
128
146
|
}).catch(function (err) {
|
|
147
|
+
console.error('文件解压失败:', err);
|
|
129
148
|
resolve(false);
|
|
130
|
-
console.log('error', err);
|
|
131
149
|
});
|
|
132
150
|
});
|
|
133
151
|
};
|
|
@@ -137,54 +155,71 @@ function downloadDriver(onProgress) {
|
|
|
137
155
|
return new Promise(function (resolve, reject) {
|
|
138
156
|
var url = 'http://ljtools.zhuanstatic.com/download/iTunesDriver/iTunesOL_Lite_64_12.10.0.7.zip';
|
|
139
157
|
var dest = filePath;
|
|
158
|
+
console.log('开始下载驱动文件:', url);
|
|
159
|
+
console.log('目标路径:', dest);
|
|
140
160
|
var fileStream = _fsExtra.default.createWriteStream(dest);
|
|
141
161
|
var received = 0;
|
|
142
162
|
var total = 0;
|
|
143
163
|
(0, _request.default)(url).on('response', function (response) {
|
|
164
|
+
console.log('下载响应状态:', response.statusCode);
|
|
144
165
|
if (response.statusCode !== 200) {
|
|
145
166
|
reject(new Error("\u4E0B\u8F7D\u5931\u8D25: ".concat(response.statusMessage)));
|
|
146
167
|
return;
|
|
147
168
|
}
|
|
148
169
|
total = parseInt(response.headers['content-length'], 10);
|
|
170
|
+
console.log('文件总大小:', total, 'bytes');
|
|
149
171
|
}).on('data', function (chunk) {
|
|
150
172
|
received += chunk.length;
|
|
151
173
|
if (onProgress && total) {
|
|
152
|
-
|
|
174
|
+
var percent = Math.round(received / total * 100);
|
|
175
|
+
onProgress(percent);
|
|
176
|
+
console.log("\u4E0B\u8F7D\u8FDB\u5EA6: ".concat(percent, "% (").concat(received, "/").concat(total, ")"));
|
|
153
177
|
}
|
|
154
178
|
}).on('error', function (err) {
|
|
155
179
|
console.error('驱动下载失败', err);
|
|
180
|
+
fileStream.end(); // 确保关闭文件流
|
|
156
181
|
reject(err);
|
|
157
182
|
}).pipe(fileStream).on('finish', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
158
183
|
var uncopressing;
|
|
159
184
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
160
185
|
while (1) switch (_context2.prev = _context2.next) {
|
|
161
186
|
case 0:
|
|
162
|
-
|
|
163
|
-
_context2.
|
|
187
|
+
console.log('文件下载完成,开始解压...');
|
|
188
|
+
_context2.prev = 1;
|
|
189
|
+
_context2.next = 4;
|
|
164
190
|
return uncopressingFile(filePath);
|
|
165
|
-
case
|
|
191
|
+
case 4:
|
|
166
192
|
uncopressing = _context2.sent;
|
|
193
|
+
console.log('解压结果:', uncopressing);
|
|
167
194
|
if (uncopressing) {
|
|
195
|
+
console.log('开始安装驱动...');
|
|
168
196
|
installDriver().then(function () {
|
|
197
|
+
console.log('驱动安装成功');
|
|
169
198
|
resolve();
|
|
170
199
|
}).catch(function (err) {
|
|
200
|
+
console.error('驱动安装失败:', err);
|
|
171
201
|
reject(err);
|
|
172
202
|
});
|
|
173
203
|
} else {
|
|
204
|
+
console.error('解压失败');
|
|
174
205
|
reject(new Error('解压失败'));
|
|
175
206
|
}
|
|
176
|
-
_context2.next =
|
|
207
|
+
_context2.next = 13;
|
|
177
208
|
break;
|
|
178
|
-
case
|
|
179
|
-
_context2.prev =
|
|
180
|
-
_context2.t0 = _context2["catch"](
|
|
209
|
+
case 9:
|
|
210
|
+
_context2.prev = 9;
|
|
211
|
+
_context2.t0 = _context2["catch"](1);
|
|
212
|
+
console.error('解压或安装过程中出错:', _context2.t0);
|
|
181
213
|
reject(_context2.t0);
|
|
182
|
-
case
|
|
214
|
+
case 13:
|
|
183
215
|
case "end":
|
|
184
216
|
return _context2.stop();
|
|
185
217
|
}
|
|
186
|
-
}, _callee2, null, [[
|
|
187
|
-
})))
|
|
218
|
+
}, _callee2, null, [[1, 9]]);
|
|
219
|
+
}))).on('error', function (err) {
|
|
220
|
+
console.error('文件流写入错误:', err);
|
|
221
|
+
reject(err);
|
|
222
|
+
});
|
|
188
223
|
});
|
|
189
224
|
}
|
|
190
225
|
function checkHasDriver() {
|