appium-remote-debugger 11.5.6 → 11.5.8
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/mixins/connect.d.ts +27 -32
- package/build/lib/mixins/connect.d.ts.map +1 -1
- package/build/lib/mixins/connect.js +64 -30
- package/build/lib/mixins/connect.js.map +1 -1
- package/build/lib/mixins/cookies.d.ts +4 -3
- package/build/lib/mixins/cookies.d.ts.map +1 -1
- package/build/lib/mixins/cookies.js +6 -3
- package/build/lib/mixins/cookies.js.map +1 -1
- package/build/lib/mixins/events.d.ts +3 -2
- package/build/lib/mixins/events.d.ts.map +1 -1
- package/build/lib/mixins/events.js +5 -2
- package/build/lib/mixins/events.js.map +1 -1
- package/build/lib/mixins/execute.d.ts +7 -4
- package/build/lib/mixins/execute.d.ts.map +1 -1
- package/build/lib/mixins/execute.js +8 -3
- package/build/lib/mixins/execute.js.map +1 -1
- package/build/lib/mixins/message-handlers.d.ts +21 -11
- package/build/lib/mixins/message-handlers.d.ts.map +1 -1
- package/build/lib/mixins/message-handlers.js +49 -10
- package/build/lib/mixins/message-handlers.js.map +1 -1
- package/build/lib/mixins/misc.d.ts +10 -9
- package/build/lib/mixins/misc.d.ts.map +1 -1
- package/build/lib/mixins/misc.js +12 -9
- package/build/lib/mixins/misc.js.map +1 -1
- package/build/lib/mixins/navigate.d.ts +10 -8
- package/build/lib/mixins/navigate.d.ts.map +1 -1
- package/build/lib/mixins/navigate.js +10 -6
- package/build/lib/mixins/navigate.js.map +1 -1
- package/build/lib/mixins/screenshot.d.ts +2 -1
- package/build/lib/mixins/screenshot.d.ts.map +1 -1
- package/build/lib/mixins/screenshot.js +4 -1
- package/build/lib/mixins/screenshot.js.map +1 -1
- package/build/lib/remote-debugger.d.ts +4 -4
- package/build/lib/remote-debugger.d.ts.map +1 -1
- package/build/lib/types.d.ts +34 -0
- package/build/lib/types.d.ts.map +1 -0
- package/build/lib/types.js +3 -0
- package/build/lib/types.js.map +1 -0
- package/build/lib/utils.d.ts +25 -52
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +31 -113
- package/build/lib/utils.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/lib/mixins/connect.js +71 -32
- package/lib/mixins/cookies.js +7 -3
- package/lib/mixins/events.js +6 -2
- package/lib/mixins/execute.js +9 -3
- package/lib/mixins/message-handlers.js +51 -11
- package/lib/mixins/misc.js +13 -9
- package/lib/mixins/navigate.js +11 -6
- package/lib/mixins/screenshot.js +5 -1
- package/lib/remote-debugger.js +2 -2
- package/lib/types.ts +39 -0
- package/lib/utils.js +30 -122
- package/package.json +1 -1
package/lib/utils.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import log from './logger';
|
|
2
1
|
import _ from 'lodash';
|
|
3
2
|
import B from 'bluebird';
|
|
4
3
|
import { errorFromMJSONWPStatusCode } from '@appium/base-driver';
|
|
@@ -7,49 +6,22 @@ import nodeFs from 'node:fs';
|
|
|
7
6
|
import path from 'node:path';
|
|
8
7
|
|
|
9
8
|
const MODULE_NAME = 'appium-remote-debugger';
|
|
10
|
-
|
|
11
|
-
const WEB_CONTENT_BUNDLE_ID = 'com.apple.WebKit.WebContent';
|
|
12
|
-
const WEB_CONTENT_PROCESS_BUNDLE_ID = 'process-com.apple.WebKit.WebContent';
|
|
13
|
-
const SAFARI_VIEW_PROCESS_BUNDLE_ID = 'process-SafariViewService';
|
|
14
|
-
const SAFARI_VIEW_BUNDLE_ID = 'com.apple.SafariViewService';
|
|
15
|
-
const WILDCARD_BUNDLE_ID = '*';
|
|
16
|
-
|
|
9
|
+
export const WEB_CONTENT_BUNDLE_ID = 'com.apple.WebKit.WebContent';
|
|
17
10
|
const INACTIVE_APP_CODE = 0;
|
|
18
|
-
|
|
19
11
|
// values for the page `WIRTypeKey` entry
|
|
20
12
|
const ACCEPTED_PAGE_TYPES = [
|
|
21
13
|
'WIRTypeWeb', // up to iOS 11.3
|
|
22
14
|
'WIRTypeWebPage', // iOS 11.4
|
|
23
15
|
'WIRTypePage', // iOS 11.4 webview
|
|
24
16
|
];
|
|
25
|
-
|
|
26
17
|
export const RESPONSE_LOG_LENGTH = 100;
|
|
27
18
|
|
|
28
|
-
/**
|
|
29
|
-
* @typedef {Object} DeferredPromise
|
|
30
|
-
* @property {B<any>} promise
|
|
31
|
-
* @property {(...args: any[]) => void} resolve
|
|
32
|
-
* @property {(err?: Error) => void} reject
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @typedef {Object} AppInfo
|
|
37
|
-
* @property {string} id
|
|
38
|
-
* @property {boolean} isProxy
|
|
39
|
-
* @property {string} name
|
|
40
|
-
* @property {string} bundleId
|
|
41
|
-
* @property {string} [hostId]
|
|
42
|
-
* @property {boolean} isActive
|
|
43
|
-
* @property {boolean|string} isAutomationEnabled
|
|
44
|
-
* @property {import('./mixins/connect').Page[]} [pageArray]
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
19
|
/**
|
|
48
20
|
* Takes a dictionary from the remote debugger and makes a more manageable
|
|
49
21
|
* dictionary whose keys are understandable
|
|
50
22
|
*
|
|
51
23
|
* @param {Record<string, any>} dict
|
|
52
|
-
* @returns {[string, AppInfo]}
|
|
24
|
+
* @returns {[string, import('./types').AppInfo]}
|
|
53
25
|
*/
|
|
54
26
|
export function appInfoFromDict (dict) {
|
|
55
27
|
const id = dict.WIRApplicationIdentifierKey;
|
|
@@ -70,6 +42,7 @@ export function appInfoFromDict (dict) {
|
|
|
70
42
|
isAutomationEnabled = !!dict.WIRAutomationAvailabilityKey;
|
|
71
43
|
}
|
|
72
44
|
}
|
|
45
|
+
/** @type {import('./types').AppInfo} */
|
|
73
46
|
const entry = {
|
|
74
47
|
id,
|
|
75
48
|
isProxy,
|
|
@@ -88,7 +61,7 @@ export function appInfoFromDict (dict) {
|
|
|
88
61
|
* dictionary of pages available.
|
|
89
62
|
*
|
|
90
63
|
* @param {import('@appium/types').StringRecord} pageDict
|
|
91
|
-
* @returns {import('./
|
|
64
|
+
* @returns {import('./types').Page[]}
|
|
92
65
|
*/
|
|
93
66
|
export function pageArrayFromDict (pageDict) {
|
|
94
67
|
return _.values(pageDict)
|
|
@@ -103,84 +76,32 @@ export function pageArrayFromDict (pageDict) {
|
|
|
103
76
|
}
|
|
104
77
|
|
|
105
78
|
/**
|
|
106
|
-
*
|
|
107
|
-
* connected.
|
|
79
|
+
*
|
|
108
80
|
* @param {string} bundleId
|
|
109
|
-
* @param {
|
|
110
|
-
* @returns {string
|
|
81
|
+
* @param {import('./types').AppDict} appDict
|
|
82
|
+
* @returns {string[]}
|
|
111
83
|
*/
|
|
112
|
-
export function
|
|
113
|
-
|
|
84
|
+
export function appIdsForBundle (bundleId, appDict) {
|
|
85
|
+
/** @type {Set<string>} */
|
|
86
|
+
const appIds = new Set();
|
|
114
87
|
for (const [key, data] of _.toPairs(appDict)) {
|
|
115
|
-
if (data.bundleId
|
|
116
|
-
|
|
117
|
-
break;
|
|
88
|
+
if (data.bundleId.endsWith(bundleId)) {
|
|
89
|
+
appIds.add(key);
|
|
118
90
|
}
|
|
119
91
|
}
|
|
120
|
-
|
|
121
|
-
if
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
for (const [key, data] of _.toPairs(appDict)) {
|
|
125
|
-
if (data.isProxy && data.hostId === appId) {
|
|
126
|
-
log.debug(`Found separate bundleId '${data.bundleId}' ` +
|
|
127
|
-
`acting as proxy for '${bundleId}', with app id '${key}'`);
|
|
128
|
-
// set the app id... the last one will be used, so just keep re-assigning
|
|
129
|
-
proxyAppId = key;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (proxyAppId) {
|
|
133
|
-
appId = proxyAppId;
|
|
134
|
-
log.debug(`Using proxied app id '${appId}'`);
|
|
135
|
-
}
|
|
92
|
+
|
|
93
|
+
// if nothing is found, try to get the generic app
|
|
94
|
+
if (appIds.size === 0 && bundleId !== WEB_CONTENT_BUNDLE_ID) {
|
|
95
|
+
return appIdsForBundle(WEB_CONTENT_BUNDLE_ID, appDict);
|
|
136
96
|
}
|
|
137
97
|
|
|
138
|
-
return
|
|
98
|
+
return Array.from(appIds);
|
|
139
99
|
}
|
|
140
100
|
|
|
141
101
|
/**
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
* @param {string[]} bundleIds
|
|
145
|
-
* @param {Record<string, AppInfo>} appDict
|
|
146
|
-
* @returns {string[]}
|
|
102
|
+
* @param {import('@appium/types').StringRecord} params
|
|
103
|
+
* @returns {void}
|
|
147
104
|
*/
|
|
148
|
-
export function getPossibleDebuggerAppKeys(bundleIds, appDict) {
|
|
149
|
-
if (bundleIds.includes(WILDCARD_BUNDLE_ID)) {
|
|
150
|
-
log.debug('Skip checking bundle identifiers because the bundleIds includes a wildcard');
|
|
151
|
-
return _.uniq(Object.keys(appDict));
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// go through the possible bundle identifiers
|
|
155
|
-
const possibleBundleIds = _.uniq([
|
|
156
|
-
WEB_CONTENT_BUNDLE_ID,
|
|
157
|
-
WEB_CONTENT_PROCESS_BUNDLE_ID,
|
|
158
|
-
SAFARI_VIEW_PROCESS_BUNDLE_ID,
|
|
159
|
-
SAFARI_VIEW_BUNDLE_ID,
|
|
160
|
-
WILDCARD_BUNDLE_ID,
|
|
161
|
-
...bundleIds,
|
|
162
|
-
]);
|
|
163
|
-
log.debug(`Checking for bundle identifiers: ${possibleBundleIds.join(', ')}`);
|
|
164
|
-
/** @type {Set<string>} */
|
|
165
|
-
const proxiedAppIds = new Set();
|
|
166
|
-
for (const bundleId of possibleBundleIds) {
|
|
167
|
-
// now we need to determine if we should pick a proxy for this instead
|
|
168
|
-
for (const appId of appIdsForBundle(bundleId, appDict)) {
|
|
169
|
-
proxiedAppIds.add(appId);
|
|
170
|
-
log.debug(`Found app id key '${appId}' for bundle '${bundleId}'`);
|
|
171
|
-
for (const [key, data] of _.toPairs(appDict)) {
|
|
172
|
-
if (data.isProxy && data.hostId === appId) {
|
|
173
|
-
log.debug(`Found separate bundleId '${data.bundleId}' ` +
|
|
174
|
-
`acting as proxy for '${bundleId}', with app id '${key}'`);
|
|
175
|
-
proxiedAppIds.add(key);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return Array.from(proxiedAppIds);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
105
|
export function checkParams (params) {
|
|
185
106
|
// check if all parameters have a value
|
|
186
107
|
const errors = _.toPairs(params)
|
|
@@ -191,6 +112,11 @@ export function checkParams (params) {
|
|
|
191
112
|
}
|
|
192
113
|
}
|
|
193
114
|
|
|
115
|
+
/**
|
|
116
|
+
* @param {any} value
|
|
117
|
+
* @param {boolean} [multiline=false]
|
|
118
|
+
* @returns {string}
|
|
119
|
+
*/
|
|
194
120
|
export function simpleStringify (value, multiline = false) {
|
|
195
121
|
if (!value) {
|
|
196
122
|
return JSON.stringify(value);
|
|
@@ -206,7 +132,7 @@ export function simpleStringify (value, multiline = false) {
|
|
|
206
132
|
}
|
|
207
133
|
|
|
208
134
|
/**
|
|
209
|
-
* @returns {DeferredPromise}
|
|
135
|
+
* @returns {import('./types').DeferredPromise}
|
|
210
136
|
*/
|
|
211
137
|
export function deferredPromise () {
|
|
212
138
|
// http://bluebirdjs.com/docs/api/deferred-migration.html
|
|
@@ -227,6 +153,11 @@ export function deferredPromise () {
|
|
|
227
153
|
};
|
|
228
154
|
}
|
|
229
155
|
|
|
156
|
+
/**
|
|
157
|
+
*
|
|
158
|
+
* @param {any} res
|
|
159
|
+
* @returns {any}
|
|
160
|
+
*/
|
|
230
161
|
export function convertResult (res) {
|
|
231
162
|
if (_.isUndefined(res)) {
|
|
232
163
|
throw new Error(`Did not get OK result from remote debugger. Result was: ${_.truncate(simpleStringify(res), {length: RESPONSE_LOG_LENGTH})}`);
|
|
@@ -280,26 +211,3 @@ export function getModuleProperties() {
|
|
|
280
211
|
const fullPath = path.resolve(getModuleRoot(), 'package.json');
|
|
281
212
|
return JSON.parse(nodeFs.readFileSync(fullPath, 'utf8'));
|
|
282
213
|
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
*
|
|
286
|
-
* @param {string} bundleId
|
|
287
|
-
* @param {Record<string, any>} appDict
|
|
288
|
-
* @returns {string[]}
|
|
289
|
-
*/
|
|
290
|
-
function appIdsForBundle (bundleId, appDict) {
|
|
291
|
-
/** @type {Set<string>} */
|
|
292
|
-
const appIds = new Set();
|
|
293
|
-
for (const [key, data] of _.toPairs(appDict)) {
|
|
294
|
-
if (data.bundleId.endsWith(bundleId)) {
|
|
295
|
-
appIds.add(key);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// if nothing is found, try to get the generic app
|
|
300
|
-
if (appIds.size === 0 && bundleId !== WEB_CONTENT_BUNDLE_ID) {
|
|
301
|
-
return appIdsForBundle(WEB_CONTENT_BUNDLE_ID, appDict);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
return Array.from(appIds);
|
|
305
|
-
}
|