appium-mac2-driver 3.2.14 → 3.2.16
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/CHANGELOG.md +12 -0
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/applescript.d.ts.map +1 -1
- package/build/lib/commands/applescript.js +2 -2
- package/build/lib/commands/applescript.js.map +1 -1
- package/build/lib/commands/bidi/models.d.ts.map +1 -1
- package/build/lib/commands/bidi/models.js.map +1 -1
- package/build/lib/commands/clipboard.d.ts.map +1 -1
- package/build/lib/commands/clipboard.js +2 -2
- package/build/lib/commands/clipboard.js.map +1 -1
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +3 -1
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/gestures.d.ts.map +1 -1
- package/build/lib/commands/gestures.js.map +1 -1
- package/build/lib/commands/helpers.d.ts.map +1 -1
- package/build/lib/commands/helpers.js.map +1 -1
- package/build/lib/commands/native-record-screen.d.ts.map +1 -1
- package/build/lib/commands/native-record-screen.js +7 -7
- package/build/lib/commands/native-record-screen.js.map +1 -1
- package/build/lib/commands/navigation.d.ts.map +1 -1
- package/build/lib/commands/navigation.js.map +1 -1
- package/build/lib/commands/record-screen.d.ts.map +1 -1
- package/build/lib/commands/record-screen.js +2 -3
- package/build/lib/commands/record-screen.js.map +1 -1
- package/build/lib/commands/screenshots.d.ts.map +1 -1
- package/build/lib/commands/screenshots.js.map +1 -1
- package/build/lib/commands/source.d.ts.map +1 -1
- package/build/lib/commands/source.js.map +1 -1
- package/build/lib/doctor/optional-checks.d.ts.map +1 -1
- package/build/lib/doctor/optional-checks.js.map +1 -1
- package/build/lib/doctor/required-checks.d.ts.map +1 -1
- package/build/lib/doctor/required-checks.js.map +1 -1
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +1 -1
- package/build/lib/driver.js.map +1 -1
- package/build/lib/execute-method-map.d.ts.map +1 -1
- package/build/lib/execute-method-map.js +31 -140
- package/build/lib/execute-method-map.js.map +1 -1
- package/build/lib/logger.js.map +1 -1
- package/build/lib/types.d.ts.map +1 -1
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +2 -1
- package/build/lib/utils.js.map +1 -1
- package/build/lib/wda-mac.d.ts.map +1 -1
- package/build/lib/wda-mac.js +34 -35
- package/build/lib/wda-mac.js.map +1 -1
- package/lib/commands/app-management.ts +9 -10
- package/lib/commands/applescript.ts +6 -7
- package/lib/commands/bidi/models.ts +2 -2
- package/lib/commands/clipboard.ts +9 -8
- package/lib/commands/execute.ts +6 -5
- package/lib/commands/find.ts +3 -4
- package/lib/commands/gestures.ts +25 -26
- package/lib/commands/helpers.ts +8 -6
- package/lib/commands/native-record-screen.ts +63 -54
- package/lib/commands/navigation.ts +3 -4
- package/lib/commands/record-screen.ts +35 -32
- package/lib/commands/screenshots.ts +4 -5
- package/lib/commands/source.ts +6 -7
- package/lib/constraints.ts +0 -1
- package/lib/doctor/optional-checks.ts +3 -3
- package/lib/doctor/required-checks.ts +12 -9
- package/lib/doctor/utils.ts +0 -1
- package/lib/driver.ts +20 -18
- package/lib/execute-method-map.ts +32 -141
- package/lib/logger.ts +1 -2
- package/lib/method-map.ts +0 -1
- package/lib/types.ts +1 -1
- package/lib/utils.ts +7 -6
- package/lib/wda-mac.ts +115 -88
- package/npm-shrinkwrap.json +270 -228
- package/package.json +5 -2
package/lib/wda-mac.ts
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import url from 'url';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import url from 'node:url';
|
|
4
4
|
import axios from 'axios';
|
|
5
5
|
import B from 'bluebird';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import type {
|
|
14
|
-
|
|
15
|
-
HTTPBody,
|
|
16
|
-
ProxyResponse,
|
|
17
|
-
ProxyOptions,
|
|
18
|
-
} from '@appium/types';
|
|
19
|
-
import { listChildrenProcessIds, getModuleRoot } from './utils';
|
|
6
|
+
import {JWProxy, errors} from 'appium/driver';
|
|
7
|
+
import {fs, logger, util, timing} from 'appium/support';
|
|
8
|
+
import {strongbox} from '@appium/strongbox';
|
|
9
|
+
import {SubProcess, exec} from 'teen_process';
|
|
10
|
+
import {waitForCondition} from 'asyncbox';
|
|
11
|
+
import {checkPortStatus} from 'portscanner';
|
|
12
|
+
import {execSync} from 'node:child_process';
|
|
13
|
+
import type {HTTPMethod, HTTPBody, ProxyResponse, ProxyOptions} from '@appium/types';
|
|
14
|
+
import {listChildrenProcessIds, getModuleRoot} from './utils';
|
|
20
15
|
|
|
21
16
|
const log = logger.getLogger('WebDriverAgentMac');
|
|
22
17
|
|
|
@@ -63,22 +58,22 @@ class WDAMacProcess {
|
|
|
63
58
|
public proc: SubProcess | null = null;
|
|
64
59
|
private _showServerLogs: boolean = DEFAULT_SHOW_SERVER_LOGS;
|
|
65
60
|
|
|
66
|
-
get isRunning
|
|
67
|
-
return !!
|
|
61
|
+
get isRunning(): boolean {
|
|
62
|
+
return !!this.proc?.isRunning;
|
|
68
63
|
}
|
|
69
64
|
|
|
70
|
-
get pid
|
|
65
|
+
get pid(): number | null {
|
|
71
66
|
return this.isRunning && this.proc ? this.proc.pid : null;
|
|
72
67
|
}
|
|
73
68
|
|
|
74
|
-
async listChildrenPids
|
|
75
|
-
return this.pid ?
|
|
69
|
+
async listChildrenPids(): Promise<string[]> {
|
|
70
|
+
return this.pid ? await listChildrenProcessIds(this.pid) : [];
|
|
76
71
|
}
|
|
77
72
|
|
|
78
|
-
async cleanupProjectIfFresh
|
|
73
|
+
async cleanupProjectIfFresh(): Promise<void> {
|
|
79
74
|
const packageInfo = JSON.parse(
|
|
80
|
-
await fs.readFile(path.join(getModuleRoot(), 'package.json'), 'utf8')
|
|
81
|
-
) as {
|
|
75
|
+
await fs.readFile(path.join(getModuleRoot(), 'package.json'), 'utf8'),
|
|
76
|
+
) as {name: string; version: string};
|
|
82
77
|
const box = strongbox(packageInfo.name);
|
|
83
78
|
let boxItem = box.getItem(RECENT_MODULE_VERSION_ITEM_NAME);
|
|
84
79
|
if (!boxItem) {
|
|
@@ -94,7 +89,9 @@ class WDAMacProcess {
|
|
|
94
89
|
return;
|
|
95
90
|
}
|
|
96
91
|
} else {
|
|
97
|
-
log.info(
|
|
92
|
+
log.info(
|
|
93
|
+
'There is no need to perform the project cleanup. A fresh install has been detected',
|
|
94
|
+
);
|
|
98
95
|
try {
|
|
99
96
|
await box.createItemWithValue(RECENT_MODULE_VERSION_ITEM_NAME, packageInfo.version);
|
|
100
97
|
} catch (e: any) {
|
|
@@ -109,7 +106,9 @@ class WDAMacProcess {
|
|
|
109
106
|
recentModuleVersion = util.coerceVersion(recentModuleVersion, true);
|
|
110
107
|
} catch (e: any) {
|
|
111
108
|
log.warn(`The persisted module version string has been damaged: ${e.message}`);
|
|
112
|
-
log.info(
|
|
109
|
+
log.info(
|
|
110
|
+
`Updating it to '${packageInfo.version}' assuming the project cleanup is not needed`,
|
|
111
|
+
);
|
|
113
112
|
await boxItem.write(packageInfo.version);
|
|
114
113
|
return;
|
|
115
114
|
}
|
|
@@ -117,18 +116,14 @@ class WDAMacProcess {
|
|
|
117
116
|
if (util.compareVersions(recentModuleVersion, '>=', packageInfo.version)) {
|
|
118
117
|
log.info(
|
|
119
118
|
`WebDriverAgent does not need a cleanup. The project sources are up to date ` +
|
|
120
|
-
|
|
119
|
+
`(${recentModuleVersion} >= ${packageInfo.version})`,
|
|
121
120
|
);
|
|
122
121
|
return;
|
|
123
122
|
}
|
|
124
123
|
|
|
125
124
|
try {
|
|
126
125
|
log.info('Performing project cleanup');
|
|
127
|
-
const args = [
|
|
128
|
-
'clean',
|
|
129
|
-
'-project', WDA_PROJECT(this.bootstrapRoot),
|
|
130
|
-
'-scheme', RUNNER_SCHEME,
|
|
131
|
-
];
|
|
126
|
+
const args = ['clean', '-project', WDA_PROJECT(this.bootstrapRoot), '-scheme', RUNNER_SCHEME];
|
|
132
127
|
await exec(XCODEBUILD, args, {cwd: this.bootstrapRoot});
|
|
133
128
|
await boxItem.write(packageInfo.version);
|
|
134
129
|
} catch (e: any) {
|
|
@@ -136,7 +131,7 @@ class WDAMacProcess {
|
|
|
136
131
|
}
|
|
137
132
|
}
|
|
138
133
|
|
|
139
|
-
async init
|
|
134
|
+
async init(opts: WDAMacProcessInitOptions = {}): Promise<boolean> {
|
|
140
135
|
if (this.isRunning && this.hasSameOpts(opts)) {
|
|
141
136
|
return false;
|
|
142
137
|
}
|
|
@@ -147,9 +142,11 @@ class WDAMacProcess {
|
|
|
147
142
|
this.bootstrapRoot = opts.bootstrapRoot ?? this.bootstrapRoot;
|
|
148
143
|
|
|
149
144
|
log.debug(`Using bootstrap root: ${this.bootstrapRoot}`);
|
|
150
|
-
if (!await fs.exists(WDA_PROJECT(this.bootstrapRoot))) {
|
|
151
|
-
throw new Error(
|
|
152
|
-
|
|
145
|
+
if (!(await fs.exists(WDA_PROJECT(this.bootstrapRoot)))) {
|
|
146
|
+
throw new Error(
|
|
147
|
+
`${WDA_PROJECT_NAME} does not exist at '${WDA_PROJECT(this.bootstrapRoot)}'. ` +
|
|
148
|
+
`Was 'bootstrapRoot' set to a proper value?`,
|
|
149
|
+
);
|
|
153
150
|
}
|
|
154
151
|
|
|
155
152
|
await this.kill();
|
|
@@ -159,8 +156,10 @@ class WDAMacProcess {
|
|
|
159
156
|
try {
|
|
160
157
|
xcodebuild = await fs.which(XCODEBUILD);
|
|
161
158
|
} catch {
|
|
162
|
-
throw new Error(
|
|
163
|
-
|
|
159
|
+
throw new Error(
|
|
160
|
+
`${XCODEBUILD} binary cannot be found in PATH. ` +
|
|
161
|
+
`Please make sure that Xcode is installed on your system`,
|
|
162
|
+
);
|
|
164
163
|
}
|
|
165
164
|
log.debug(`Using ${XCODEBUILD} binary at '${xcodebuild}'`);
|
|
166
165
|
|
|
@@ -168,11 +167,14 @@ class WDAMacProcess {
|
|
|
168
167
|
|
|
169
168
|
log.debug(`Using ${this.host} as server host`);
|
|
170
169
|
log.debug(`Using port ${this.port}`);
|
|
171
|
-
const isPortBusy = async (): Promise<boolean> =>
|
|
170
|
+
const isPortBusy = async (): Promise<boolean> =>
|
|
171
|
+
(await checkPortStatus(this.port, this.host)) === 'open';
|
|
172
172
|
if (await isPortBusy()) {
|
|
173
|
-
log.warn(
|
|
174
|
-
`
|
|
175
|
-
|
|
173
|
+
log.warn(
|
|
174
|
+
`The port #${this.port} at ${this.host} is busy. ` +
|
|
175
|
+
`Assuming it is an obsolete WDA server instance and ` +
|
|
176
|
+
`trying to terminate it in order to start a new one`,
|
|
177
|
+
);
|
|
176
178
|
const timer = new timing.Timer().start();
|
|
177
179
|
try {
|
|
178
180
|
await axios.delete(`http://${this.host}:${this.port}/`, {
|
|
@@ -185,20 +187,29 @@ class WDAMacProcess {
|
|
|
185
187
|
intervalMs: 100,
|
|
186
188
|
});
|
|
187
189
|
} catch (e: any) {
|
|
188
|
-
log.warn(
|
|
189
|
-
`
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
log.warn(
|
|
191
|
+
`Did not know how to terminate the process at ${this.host}:${this.port}: ${e.message}. ` +
|
|
192
|
+
`Perhaps, it is not a WDA server, which is hogging the port?`,
|
|
193
|
+
);
|
|
194
|
+
throw new Error(
|
|
195
|
+
`The port #${this.port} at ${this.host} is busy. ` +
|
|
196
|
+
`Consider setting 'systemPort' capability to another free port number and/or ` +
|
|
197
|
+
`make sure previous driver sessions have been closed properly.`,
|
|
198
|
+
);
|
|
193
199
|
}
|
|
194
|
-
log.info(
|
|
195
|
-
|
|
200
|
+
log.info(
|
|
201
|
+
`The previously running WDA server has been successfully terminated after ` +
|
|
202
|
+
`${Math.round(timer.getDuration().asMilliSeconds)}ms`,
|
|
203
|
+
);
|
|
196
204
|
}
|
|
197
205
|
|
|
198
206
|
const args = [
|
|
199
|
-
'build-for-testing',
|
|
200
|
-
'-
|
|
201
|
-
'-
|
|
207
|
+
'build-for-testing',
|
|
208
|
+
'test-without-building',
|
|
209
|
+
'-project',
|
|
210
|
+
WDA_PROJECT(this.bootstrapRoot),
|
|
211
|
+
'-scheme',
|
|
212
|
+
RUNNER_SCHEME,
|
|
202
213
|
DISABLE_STORE_ARG,
|
|
203
214
|
];
|
|
204
215
|
const env = Object.assign({}, process.env, {
|
|
@@ -210,9 +221,11 @@ class WDAMacProcess {
|
|
|
210
221
|
env,
|
|
211
222
|
});
|
|
212
223
|
if (!this._showServerLogs) {
|
|
213
|
-
log.info(
|
|
214
|
-
`
|
|
215
|
-
|
|
224
|
+
log.info(
|
|
225
|
+
`Mac2Driver host process logging is disabled. ` +
|
|
226
|
+
`All the ${XCODEBUILD} output is going to be suppressed. ` +
|
|
227
|
+
`Set the 'showServerLogs' capability to 'true' if this is an undesired behavior`,
|
|
228
|
+
);
|
|
216
229
|
}
|
|
217
230
|
this.proc.on('output', (stdout, stderr) => {
|
|
218
231
|
if (!this._showServerLogs) {
|
|
@@ -232,7 +245,7 @@ class WDAMacProcess {
|
|
|
232
245
|
return true;
|
|
233
246
|
}
|
|
234
247
|
|
|
235
|
-
async stop
|
|
248
|
+
async stop(): Promise<void> {
|
|
236
249
|
if (!this.isRunning) {
|
|
237
250
|
return;
|
|
238
251
|
}
|
|
@@ -246,7 +259,7 @@ class WDAMacProcess {
|
|
|
246
259
|
await this.proc?.stop('SIGTERM', 3000);
|
|
247
260
|
}
|
|
248
261
|
|
|
249
|
-
async kill
|
|
262
|
+
async kill(): Promise<void> {
|
|
250
263
|
if (!this.isRunning) {
|
|
251
264
|
return;
|
|
252
265
|
}
|
|
@@ -262,22 +275,30 @@ class WDAMacProcess {
|
|
|
262
275
|
} catch {}
|
|
263
276
|
}
|
|
264
277
|
|
|
265
|
-
private hasSameOpts
|
|
266
|
-
const {
|
|
267
|
-
if (
|
|
268
|
-
|
|
278
|
+
private hasSameOpts(opts: WDAMacProcessInitOptions): boolean {
|
|
279
|
+
const {showServerLogs, systemPort, systemHost, bootstrapRoot} = opts;
|
|
280
|
+
if (
|
|
281
|
+
(_.isBoolean(showServerLogs) && this._showServerLogs !== showServerLogs) ||
|
|
282
|
+
(_.isNil(showServerLogs) && this._showServerLogs !== DEFAULT_SHOW_SERVER_LOGS)
|
|
283
|
+
) {
|
|
269
284
|
return false;
|
|
270
285
|
}
|
|
271
|
-
if (
|
|
272
|
-
|
|
286
|
+
if (
|
|
287
|
+
(systemPort && this.port !== systemPort) ||
|
|
288
|
+
(!systemPort && this.port !== DEFAULT_SYSTEM_PORT)
|
|
289
|
+
) {
|
|
273
290
|
return false;
|
|
274
291
|
}
|
|
275
|
-
if (
|
|
276
|
-
|
|
292
|
+
if (
|
|
293
|
+
(systemHost && this.host !== systemHost) ||
|
|
294
|
+
(!systemHost && this.host !== DEFAULT_SYSTEM_HOST)
|
|
295
|
+
) {
|
|
277
296
|
return false;
|
|
278
297
|
}
|
|
279
|
-
if (
|
|
280
|
-
|
|
298
|
+
if (
|
|
299
|
+
(bootstrapRoot && this.bootstrapRoot !== bootstrapRoot) ||
|
|
300
|
+
(!bootstrapRoot && this.bootstrapRoot !== DEFAULT_WDA_ROOT)
|
|
301
|
+
) {
|
|
281
302
|
return false;
|
|
282
303
|
}
|
|
283
304
|
|
|
@@ -291,14 +312,14 @@ export class WDAMacServer {
|
|
|
291
312
|
private _serverStartupTimeoutMs: number = STARTUP_TIMEOUT_MS;
|
|
292
313
|
private _isProxyingToRemoteServer: boolean = false;
|
|
293
314
|
|
|
294
|
-
get proxy
|
|
315
|
+
get proxy(): WDAMacProxy {
|
|
295
316
|
if (!this._proxy) {
|
|
296
317
|
throw new Error('Proxy is not initialized. Did you call startSession()?');
|
|
297
318
|
}
|
|
298
319
|
return this._proxy;
|
|
299
320
|
}
|
|
300
321
|
|
|
301
|
-
async startSession
|
|
322
|
+
async startSession(caps: StartSessionCapabilities, opts: SessionOptions = {}): Promise<void> {
|
|
302
323
|
this._serverStartupTimeoutMs = caps.serverStartupTimeout ?? this._serverStartupTimeoutMs;
|
|
303
324
|
|
|
304
325
|
this._isProxyingToRemoteServer = !!caps.webDriverAgentMacUrl;
|
|
@@ -355,10 +376,10 @@ export class WDAMacServer {
|
|
|
355
376
|
if (/Condition unmet/.test(e.message)) {
|
|
356
377
|
const msg = this._isProxyingToRemoteServer
|
|
357
378
|
? `No response from '${scheme}://${host}:${port}${path}' within ${this._serverStartupTimeoutMs}ms timeout.` +
|
|
358
|
-
|
|
379
|
+
`Please make sure the remote server is running and accessible by Appium`
|
|
359
380
|
: `Mac2Driver server is not listening within ${this._serverStartupTimeoutMs}ms timeout. ` +
|
|
360
|
-
|
|
361
|
-
|
|
381
|
+
`Try to increase the value of 'serverStartupTimeout' capability, check the server logs ` +
|
|
382
|
+
`and make sure the ${XCODEBUILD} host process could be started manually from a terminal`;
|
|
362
383
|
throw new Error(msg);
|
|
363
384
|
}
|
|
364
385
|
throw e;
|
|
@@ -371,7 +392,9 @@ export class WDAMacServer {
|
|
|
371
392
|
RUNNING_PROCESS_IDS.push(...childrenPids, pid);
|
|
372
393
|
this._process.proc?.on('exit', () => void _.pull(RUNNING_PROCESS_IDS, pid));
|
|
373
394
|
}
|
|
374
|
-
log.info(
|
|
395
|
+
log.info(
|
|
396
|
+
`The host process is ready within ${timer.getDuration().asMilliSeconds.toFixed(0)}ms`,
|
|
397
|
+
);
|
|
375
398
|
}
|
|
376
399
|
} else {
|
|
377
400
|
log.info('The host process has already been listening. Proceeding with session creation');
|
|
@@ -381,12 +404,12 @@ export class WDAMacServer {
|
|
|
381
404
|
capabilities: {
|
|
382
405
|
firstMatch: [{}],
|
|
383
406
|
alwaysMatch: caps,
|
|
384
|
-
}
|
|
407
|
+
},
|
|
385
408
|
});
|
|
386
409
|
}
|
|
387
410
|
|
|
388
|
-
async stopSession
|
|
389
|
-
if (!this._isProxyingToRemoteServer && !
|
|
411
|
+
async stopSession(): Promise<void> {
|
|
412
|
+
if (!this._isProxyingToRemoteServer && !this._process?.isRunning) {
|
|
390
413
|
log.info(`Mac2Driver session cannot be stopped, because the server is not running`);
|
|
391
414
|
return;
|
|
392
415
|
}
|
|
@@ -400,7 +423,7 @@ export class WDAMacServer {
|
|
|
400
423
|
}
|
|
401
424
|
}
|
|
402
425
|
|
|
403
|
-
private async isProxyReady
|
|
426
|
+
private async isProxyReady(throwOnExit = true): Promise<boolean> {
|
|
404
427
|
if (!this._proxy) {
|
|
405
428
|
return false;
|
|
406
429
|
}
|
|
@@ -423,14 +446,14 @@ export class WDAMacServer {
|
|
|
423
446
|
* @return ProxyProperties
|
|
424
447
|
* @throws Error if 'webDriverAgentMacUrl' had invalid URL
|
|
425
448
|
*/
|
|
426
|
-
private parseProxyProperties
|
|
449
|
+
private parseProxyProperties(caps: StartSessionCapabilities): ProxyProperties {
|
|
427
450
|
let scheme = 'http';
|
|
428
451
|
if (!caps.webDriverAgentMacUrl) {
|
|
429
452
|
return {
|
|
430
453
|
scheme,
|
|
431
|
-
host:
|
|
432
|
-
port:
|
|
433
|
-
path: ''
|
|
454
|
+
host: this._process?.host ?? caps.systemHost ?? DEFAULT_SYSTEM_HOST,
|
|
455
|
+
port: this._process?.port ?? caps.systemPort ?? DEFAULT_SYSTEM_PORT,
|
|
456
|
+
path: '',
|
|
434
457
|
};
|
|
435
458
|
}
|
|
436
459
|
|
|
@@ -438,11 +461,13 @@ export class WDAMacServer {
|
|
|
438
461
|
try {
|
|
439
462
|
parsedUrl = new url.URL(caps.webDriverAgentMacUrl);
|
|
440
463
|
} catch (e: any) {
|
|
441
|
-
throw new Error(
|
|
442
|
-
`
|
|
464
|
+
throw new Error(
|
|
465
|
+
`webDriverAgentMacUrl, '${caps.webDriverAgentMacUrl}', ` +
|
|
466
|
+
`in the capabilities is invalid. ${e.message}`,
|
|
467
|
+
);
|
|
443
468
|
}
|
|
444
469
|
|
|
445
|
-
const {
|
|
470
|
+
const {protocol, hostname, port, pathname} = parsedUrl;
|
|
446
471
|
if (_.isString(protocol)) {
|
|
447
472
|
scheme = protocol.split(':')[0];
|
|
448
473
|
}
|
|
@@ -450,7 +475,7 @@ export class WDAMacServer {
|
|
|
450
475
|
scheme,
|
|
451
476
|
host: hostname ?? DEFAULT_SYSTEM_HOST,
|
|
452
477
|
port: _.isEmpty(port) ? DEFAULT_SYSTEM_PORT : _.parseInt(port),
|
|
453
|
-
path: pathname === '/' ? '' : pathname
|
|
478
|
+
path: pathname === '/' ? '' : pathname,
|
|
454
479
|
};
|
|
455
480
|
}
|
|
456
481
|
}
|
|
@@ -458,10 +483,12 @@ export class WDAMacServer {
|
|
|
458
483
|
export const WDA_MAC_SERVER = new WDAMacServer();
|
|
459
484
|
|
|
460
485
|
// Private functions
|
|
461
|
-
async function cleanupObsoleteProcesses
|
|
486
|
+
async function cleanupObsoleteProcesses(): Promise<void> {
|
|
462
487
|
if (!_.isEmpty(RUNNING_PROCESS_IDS)) {
|
|
463
|
-
log.debug(
|
|
464
|
-
|
|
488
|
+
log.debug(
|
|
489
|
+
`Cleaning up ${RUNNING_PROCESS_IDS.length} obsolete ` +
|
|
490
|
+
util.pluralize('process', RUNNING_PROCESS_IDS.length, false),
|
|
491
|
+
);
|
|
465
492
|
try {
|
|
466
493
|
await exec('kill', ['-9', ...RUNNING_PROCESS_IDS.map(String)]);
|
|
467
494
|
} catch {}
|