appium-mac2-driver 3.4.3 → 4.0.0
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 +16 -0
- package/README.md +4 -4
- package/build/lib/commands/app-management.d.ts +1 -1
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +4 -10
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/applescript.d.ts +2 -2
- package/build/lib/commands/applescript.d.ts.map +1 -1
- package/build/lib/commands/applescript.js +11 -17
- package/build/lib/commands/applescript.js.map +1 -1
- package/build/lib/commands/audit.d.ts +1 -1
- package/build/lib/commands/audit.d.ts.map +1 -1
- package/build/lib/commands/audit.js +1 -4
- package/build/lib/commands/audit.js.map +1 -1
- package/build/lib/commands/bidi/constants.js +2 -5
- package/build/lib/commands/bidi/constants.js.map +1 -1
- package/build/lib/commands/bidi/models.d.ts +1 -1
- package/build/lib/commands/bidi/models.d.ts.map +1 -1
- package/build/lib/commands/bidi/models.js +3 -6
- package/build/lib/commands/bidi/models.js.map +1 -1
- package/build/lib/commands/bidi/types.js +1 -2
- package/build/lib/commands/clipboard.d.ts +1 -1
- package/build/lib/commands/clipboard.d.ts.map +1 -1
- package/build/lib/commands/clipboard.js +2 -6
- package/build/lib/commands/clipboard.js.map +1 -1
- package/build/lib/commands/execute.d.ts +1 -1
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +1 -4
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/find.d.ts +1 -1
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +3 -6
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/gestures.d.ts +2 -2
- package/build/lib/commands/gestures.d.ts.map +1 -1
- package/build/lib/commands/gestures.js +23 -40
- package/build/lib/commands/gestures.js.map +1 -1
- package/build/lib/commands/helpers.d.ts +1 -1
- package/build/lib/commands/helpers.d.ts.map +1 -1
- package/build/lib/commands/helpers.js +6 -9
- package/build/lib/commands/helpers.js.map +1 -1
- package/build/lib/commands/native-record-screen.d.ts +1 -1
- package/build/lib/commands/native-record-screen.d.ts.map +1 -1
- package/build/lib/commands/native-record-screen.js +84 -63
- package/build/lib/commands/native-record-screen.js.map +1 -1
- package/build/lib/commands/navigation.d.ts +1 -1
- package/build/lib/commands/navigation.d.ts.map +1 -1
- package/build/lib/commands/navigation.js +1 -4
- package/build/lib/commands/navigation.js.map +1 -1
- package/build/lib/commands/record-screen.d.ts +2 -2
- package/build/lib/commands/record-screen.d.ts.map +1 -1
- package/build/lib/commands/record-screen.js +20 -28
- package/build/lib/commands/record-screen.js.map +1 -1
- package/build/lib/commands/screenshots.d.ts +2 -2
- package/build/lib/commands/screenshots.d.ts.map +1 -1
- package/build/lib/commands/screenshots.js +1 -4
- package/build/lib/commands/screenshots.js.map +1 -1
- package/build/lib/commands/source.d.ts +1 -1
- package/build/lib/commands/source.d.ts.map +1 -1
- package/build/lib/commands/source.js +1 -4
- package/build/lib/commands/source.js.map +1 -1
- package/build/lib/constraints.js +1 -3
- package/build/lib/constraints.js.map +1 -1
- package/build/lib/doctor/optional-checks.d.ts +21 -0
- package/build/lib/doctor/optional-checks.d.ts.map +1 -1
- package/build/lib/doctor/optional-checks.js +116 -20
- package/build/lib/doctor/optional-checks.js.map +1 -1
- package/build/lib/doctor/required-checks.js +16 -21
- package/build/lib/doctor/required-checks.js.map +1 -1
- package/build/lib/doctor/utils.js +4 -7
- package/build/lib/doctor/utils.js.map +1 -1
- package/build/lib/driver.d.ts +15 -15
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +31 -71
- package/build/lib/driver.js.map +1 -1
- package/build/lib/execute-method-map.js +1 -4
- package/build/lib/execute-method-map.js.map +1 -1
- package/build/lib/index.d.ts +1 -1
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +3 -6
- package/build/lib/index.js.map +1 -1
- package/build/lib/logger.js +3 -5
- package/build/lib/logger.js.map +1 -1
- package/build/lib/method-map.js +1 -4
- package/build/lib/method-map.js.map +1 -1
- package/build/lib/types.js +1 -2
- package/build/lib/utils.d.ts +7 -0
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +24 -22
- package/build/lib/utils.js.map +1 -1
- package/build/lib/wda-mac.d.ts +1 -1
- package/build/lib/wda-mac.d.ts.map +1 -1
- package/build/lib/wda-mac.js +43 -51
- package/build/lib/wda-mac.js.map +1 -1
- package/lib/commands/app-management.ts +1 -1
- package/lib/commands/applescript.ts +3 -3
- package/lib/commands/audit.ts +1 -1
- package/lib/commands/bidi/models.ts +2 -2
- package/lib/commands/clipboard.ts +1 -1
- package/lib/commands/execute.ts +1 -1
- package/lib/commands/find.ts +2 -2
- package/lib/commands/gestures.ts +4 -4
- package/lib/commands/helpers.ts +2 -2
- package/lib/commands/native-record-screen.ts +67 -35
- package/lib/commands/navigation.ts +1 -1
- package/lib/commands/record-screen.ts +4 -4
- package/lib/commands/screenshots.ts +2 -2
- package/lib/commands/source.ts +1 -1
- package/lib/doctor/optional-checks.ts +127 -2
- package/lib/doctor/required-checks.ts +1 -1
- package/lib/doctor/utils.ts +1 -1
- package/lib/driver.ts +18 -18
- package/lib/index.ts +1 -1
- package/lib/logger.ts +1 -1
- package/lib/utils.ts +20 -9
- package/lib/wda-mac.ts +3 -3
- package/npm-shrinkwrap.json +130 -590
- package/package.json +13 -12
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import {resolveExecutablePath} from './utils.js';
|
|
4
|
+
import {doctor, fs, util} from 'appium/support.js';
|
|
3
5
|
import {exec} from 'teen_process';
|
|
4
6
|
import type {IDoctorCheck, AppiumLogger, DoctorCheckResult} from '@appium/types';
|
|
5
7
|
import '@colors/colors';
|
|
@@ -66,3 +68,126 @@ export class OptionalAutomationModeCheck implements IDoctorCheck {
|
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
export const optionalAutomationModeCheck = new OptionalAutomationModeCheck();
|
|
71
|
+
|
|
72
|
+
export class OptionalFullDiskAccessDaemonContainersCheck implements IDoctorCheck {
|
|
73
|
+
log!: AppiumLogger;
|
|
74
|
+
/**
|
|
75
|
+
* Upper-case UUID basename only (native recording attachment filenames). Expressed as glob
|
|
76
|
+
* segments because `fs.glob` does not accept arbitrary RegExps. Brace `{,tmp/}` matches legacy
|
|
77
|
+
* `Data/Attachments` and Xcode 26.5+ `Data/tmp/Attachments` in one pass.
|
|
78
|
+
*/
|
|
79
|
+
private readonly NATIVE_RECORDING_ATTACHMENT_GLOB = (() => {
|
|
80
|
+
const h = '[0-9A-F]';
|
|
81
|
+
const seg = (n: number) => Array.from({length: n}, () => h).join('');
|
|
82
|
+
const uuid = `${seg(8)}-${seg(4)}-${seg(4)}-${seg(4)}-${seg(12)}`;
|
|
83
|
+
return `*/Data/{,tmp/}Attachments/${uuid}`;
|
|
84
|
+
})();
|
|
85
|
+
private readonly ANY_ATTACHMENT_GLOB = '*/Data/{,tmp/}Attachments/*';
|
|
86
|
+
private readonly DAEMON_CONTAINERS_ROOT = path.resolve(
|
|
87
|
+
os.homedir(),
|
|
88
|
+
'Library',
|
|
89
|
+
'Daemon Containers',
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
async diagnose(): Promise<DoctorCheckResult> {
|
|
93
|
+
const nonDarwin = this.checkIfNotDarwin();
|
|
94
|
+
if (nonDarwin) {
|
|
95
|
+
return nonDarwin;
|
|
96
|
+
}
|
|
97
|
+
const accessBlocked = await this.tryAccessDaemonContainers();
|
|
98
|
+
if (accessBlocked) {
|
|
99
|
+
return accessBlocked;
|
|
100
|
+
}
|
|
101
|
+
const uuidPathsOrErr = await this.globAttachmentsOrError();
|
|
102
|
+
if (!Array.isArray(uuidPathsOrErr)) {
|
|
103
|
+
return uuidPathsOrErr;
|
|
104
|
+
}
|
|
105
|
+
if (uuidPathsOrErr.length === 0) {
|
|
106
|
+
return await this.okWhenNoUuidAttachmentMatches();
|
|
107
|
+
}
|
|
108
|
+
return doctor.okOptional(
|
|
109
|
+
`This process can read "${this.DAEMON_CONTAINERS_ROOT}" ` +
|
|
110
|
+
`and found ${util.pluralize('matching path', uuidPathsOrErr.length, true)} under ` +
|
|
111
|
+
`*/Data/Attachments/ or */Data/tmp/Attachments/.`,
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async fix(): Promise<string> {
|
|
116
|
+
return (
|
|
117
|
+
`Open ${'System Settings'.bold} → ${'Privacy & Security'.bold} → ${'Full Disk Access'.bold} ` +
|
|
118
|
+
`and enable the Terminal, IDE, or launchd parent that starts Appium Server. ` +
|
|
119
|
+
`Native screen recordings live under ` +
|
|
120
|
+
`~/Library/Daemon Containers/*/Data/Attachments/ or, since Xcode 26.5, ` +
|
|
121
|
+
`~/Library/Daemon Containers/*/Data/tmp/Attachments/. ` +
|
|
122
|
+
`This permission is required to retrieve videos from the XCTest daemon ` +
|
|
123
|
+
`(macos:startNativeScreenRecording / macos:stopNativeScreenRecording).`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
hasAutofix(): boolean {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
isOptional(): boolean {
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private checkIfNotDarwin(): DoctorCheckResult | null {
|
|
136
|
+
if (process.platform === 'darwin') {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
return doctor.okOptional(
|
|
140
|
+
`Full Disk Access to ${this.DAEMON_CONTAINERS_ROOT} can only be checked on macOS`,
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private async tryAccessDaemonContainers(): Promise<DoctorCheckResult | null> {
|
|
145
|
+
try {
|
|
146
|
+
await fs.access(this.DAEMON_CONTAINERS_ROOT);
|
|
147
|
+
return null;
|
|
148
|
+
} catch (e) {
|
|
149
|
+
return doctor.nokOptional(
|
|
150
|
+
`Cannot access "${this.DAEMON_CONTAINERS_ROOT}": ${(e as Error).message}`,
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
private async globAttachmentsOrError(): Promise<string[] | DoctorCheckResult> {
|
|
156
|
+
try {
|
|
157
|
+
return await fs.glob(this.NATIVE_RECORDING_ATTACHMENT_GLOB, {
|
|
158
|
+
cwd: this.DAEMON_CONTAINERS_ROOT,
|
|
159
|
+
absolute: true,
|
|
160
|
+
});
|
|
161
|
+
} catch (e) {
|
|
162
|
+
return doctor.nokOptional(
|
|
163
|
+
`Cannot enumerate native recording attachments under "${this.DAEMON_CONTAINERS_ROOT}": ` +
|
|
164
|
+
`${(e as Error).message}`,
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private async globAnyAttachmentsBestEffort(): Promise<string[]> {
|
|
170
|
+
try {
|
|
171
|
+
return await fs.glob(this.ANY_ATTACHMENT_GLOB, {
|
|
172
|
+
cwd: this.DAEMON_CONTAINERS_ROOT,
|
|
173
|
+
absolute: true,
|
|
174
|
+
});
|
|
175
|
+
} catch {
|
|
176
|
+
return [];
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
private async okWhenNoUuidAttachmentMatches(): Promise<DoctorCheckResult> {
|
|
181
|
+
const anyAttachmentPaths = await this.globAnyAttachmentsBestEffort();
|
|
182
|
+
return doctor.okOptional(
|
|
183
|
+
anyAttachmentPaths.length > 0
|
|
184
|
+
? `This process can read "${this.DAEMON_CONTAINERS_ROOT}" ` +
|
|
185
|
+
`(found ${util.pluralize('path', anyAttachmentPaths.length, true)} under ` +
|
|
186
|
+
`*/Data/Attachments/* or */Data/tmp/Attachments/*, none matched the upper-case UUID filename glob).`
|
|
187
|
+
: `This process can read "${this.DAEMON_CONTAINERS_ROOT}" ` +
|
|
188
|
+
`(no files under */Data/Attachments/* or */Data/tmp/Attachments/* yet).`,
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
export const optionalFullDiskAccessDaemonContainersCheck =
|
|
193
|
+
new OptionalFullDiskAccessDaemonContainersCheck();
|
package/lib/doctor/utils.ts
CHANGED
package/lib/driver.ts
CHANGED
|
@@ -11,24 +11,24 @@ import type {
|
|
|
11
11
|
DriverOpts,
|
|
12
12
|
W3CDriverCaps,
|
|
13
13
|
} from '@appium/types';
|
|
14
|
-
import {BaseDriver, DeviceSettings} from 'appium/driver';
|
|
15
|
-
import {WDA_MAC_SERVER, type WDAMacServer} from './wda-mac';
|
|
16
|
-
import MAC2_CONSTRAINTS, {type Mac2Constraints} from './constraints';
|
|
17
|
-
import * as appManagemenetCommands from './commands/app-management';
|
|
18
|
-
import * as appleScriptCommands from './commands/applescript';
|
|
19
|
-
import * as executeCommands from './commands/execute';
|
|
20
|
-
import * as auditCommands from './commands/audit';
|
|
21
|
-
import * as findCommands from './commands/find';
|
|
22
|
-
import * as gesturesCommands from './commands/gestures';
|
|
23
|
-
import * as navigationCommands from './commands/navigation';
|
|
24
|
-
import * as recordScreenCommands from './commands/record-screen';
|
|
25
|
-
import * as screenshotCommands from './commands/screenshots';
|
|
26
|
-
import * as sourceCommands from './commands/source';
|
|
27
|
-
import * as clipboardCommands from './commands/clipboard';
|
|
28
|
-
import * as nativeScreenRecordingCommands from './commands/native-record-screen';
|
|
29
|
-
import log from './logger';
|
|
30
|
-
import {newMethodMap} from './method-map';
|
|
31
|
-
import {executeMethodMap} from './execute-method-map';
|
|
14
|
+
import {BaseDriver, DeviceSettings} from 'appium/driver.js';
|
|
15
|
+
import {WDA_MAC_SERVER, type WDAMacServer} from './wda-mac.js';
|
|
16
|
+
import MAC2_CONSTRAINTS, {type Mac2Constraints} from './constraints.js';
|
|
17
|
+
import * as appManagemenetCommands from './commands/app-management.js';
|
|
18
|
+
import * as appleScriptCommands from './commands/applescript.js';
|
|
19
|
+
import * as executeCommands from './commands/execute.js';
|
|
20
|
+
import * as auditCommands from './commands/audit.js';
|
|
21
|
+
import * as findCommands from './commands/find.js';
|
|
22
|
+
import * as gesturesCommands from './commands/gestures.js';
|
|
23
|
+
import * as navigationCommands from './commands/navigation.js';
|
|
24
|
+
import * as recordScreenCommands from './commands/record-screen.js';
|
|
25
|
+
import * as screenshotCommands from './commands/screenshots.js';
|
|
26
|
+
import * as sourceCommands from './commands/source.js';
|
|
27
|
+
import * as clipboardCommands from './commands/clipboard.js';
|
|
28
|
+
import * as nativeScreenRecordingCommands from './commands/native-record-screen.js';
|
|
29
|
+
import log from './logger.js';
|
|
30
|
+
import {newMethodMap} from './method-map.js';
|
|
31
|
+
import {executeMethodMap} from './execute-method-map.js';
|
|
32
32
|
|
|
33
33
|
const NO_PROXY: RouteMatcher[] = [
|
|
34
34
|
['GET', new RegExp('^/session/[^/]+/appium')],
|
package/lib/index.ts
CHANGED
package/lib/logger.ts
CHANGED
package/lib/utils.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {exec} from 'teen_process';
|
|
2
|
-
import {node} from 'appium/support';
|
|
2
|
+
import {node} from 'appium/support.js';
|
|
3
|
+
import {fileURLToPath} from 'node:url';
|
|
3
4
|
|
|
4
5
|
const MODULE_NAME = 'appium-mac2-driver';
|
|
6
|
+
const currentFilename = fileURLToPath(import.meta.url);
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Calculates the path to the current module's root folder
|
|
@@ -15,7 +17,7 @@ export const getModuleRoot = function getModuleRoot(): string {
|
|
|
15
17
|
if (moduleRootCache) {
|
|
16
18
|
return moduleRootCache;
|
|
17
19
|
}
|
|
18
|
-
const root = node.getModuleRootSync(MODULE_NAME,
|
|
20
|
+
const root = node.getModuleRootSync(MODULE_NAME, currentFilename);
|
|
19
21
|
if (!root) {
|
|
20
22
|
throw new Error(`Cannot find the root folder of the ${MODULE_NAME} Node.js module`);
|
|
21
23
|
}
|
|
@@ -24,16 +26,12 @@ export const getModuleRoot = function getModuleRoot(): string {
|
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
|
-
*
|
|
28
|
-
* parent process identifier
|
|
29
|
+
* Parses `ps` output and returns child process ids for the given parent pid.
|
|
29
30
|
*
|
|
31
|
+
* @param stdout `ps` command output
|
|
30
32
|
* @param parentPid parent process ID
|
|
31
|
-
* @returns the list of matched children process ids
|
|
32
|
-
* or an empty list if none matched
|
|
33
33
|
*/
|
|
34
|
-
export
|
|
35
|
-
const {stdout} = await exec('ps', ['axu', '-o', 'ppid']);
|
|
36
|
-
// USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND PPID
|
|
34
|
+
export function parseChildrenProcessIds(stdout: string, parentPid: number | string): string[] {
|
|
37
35
|
return stdout
|
|
38
36
|
.split('\n')
|
|
39
37
|
.map((line) => line.trim())
|
|
@@ -46,6 +44,19 @@ export async function listChildrenProcessIds(parentPid: number | string): Promis
|
|
|
46
44
|
.map(([pid]) => String(pid));
|
|
47
45
|
}
|
|
48
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves process ids of all the children processes created by the given
|
|
49
|
+
* parent process identifier
|
|
50
|
+
*
|
|
51
|
+
* @param parentPid parent process ID
|
|
52
|
+
* @returns the list of matched children process ids
|
|
53
|
+
* or an empty list if none matched
|
|
54
|
+
*/
|
|
55
|
+
export async function listChildrenProcessIds(parentPid: number | string): Promise<string[]> {
|
|
56
|
+
const {stdout} = await exec('ps', ['axu', '-o', 'ppid']);
|
|
57
|
+
return parseChildrenProcessIds(stdout, parentPid);
|
|
58
|
+
}
|
|
59
|
+
|
|
49
60
|
/**
|
|
50
61
|
* Clears the content of the given array.
|
|
51
62
|
* @param items The array to clear.
|
package/lib/wda-mac.ts
CHANGED
|
@@ -2,14 +2,14 @@ import path from 'node:path';
|
|
|
2
2
|
import url from 'node:url';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import {setTimeout as delay} from 'node:timers/promises';
|
|
5
|
-
import {JWProxy, errors} from 'appium/driver';
|
|
6
|
-
import {fs, logger, util, timing} from 'appium/support';
|
|
5
|
+
import {JWProxy, errors} from 'appium/driver.js';
|
|
6
|
+
import {fs, logger, util, timing} from 'appium/support.js';
|
|
7
7
|
import {strongbox} from '@appium/strongbox';
|
|
8
8
|
import {SubProcess, exec} from 'teen_process';
|
|
9
9
|
import {waitForCondition} from 'asyncbox';
|
|
10
10
|
import {checkPortStatus} from 'portscanner';
|
|
11
11
|
import type {HTTPMethod, HTTPBody, ProxyResponse, ProxyOptions} from '@appium/types';
|
|
12
|
-
import {listChildrenProcessIds, getModuleRoot, clearArray, removeAllOccurrences} from './utils';
|
|
12
|
+
import {listChildrenProcessIds, getModuleRoot, clearArray, removeAllOccurrences} from './utils.js';
|
|
13
13
|
|
|
14
14
|
const log = logger.getLogger('WebDriverAgentMac');
|
|
15
15
|
|