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.
Files changed (56) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/lib/mixins/connect.d.ts +27 -32
  3. package/build/lib/mixins/connect.d.ts.map +1 -1
  4. package/build/lib/mixins/connect.js +64 -30
  5. package/build/lib/mixins/connect.js.map +1 -1
  6. package/build/lib/mixins/cookies.d.ts +4 -3
  7. package/build/lib/mixins/cookies.d.ts.map +1 -1
  8. package/build/lib/mixins/cookies.js +6 -3
  9. package/build/lib/mixins/cookies.js.map +1 -1
  10. package/build/lib/mixins/events.d.ts +3 -2
  11. package/build/lib/mixins/events.d.ts.map +1 -1
  12. package/build/lib/mixins/events.js +5 -2
  13. package/build/lib/mixins/events.js.map +1 -1
  14. package/build/lib/mixins/execute.d.ts +7 -4
  15. package/build/lib/mixins/execute.d.ts.map +1 -1
  16. package/build/lib/mixins/execute.js +8 -3
  17. package/build/lib/mixins/execute.js.map +1 -1
  18. package/build/lib/mixins/message-handlers.d.ts +21 -11
  19. package/build/lib/mixins/message-handlers.d.ts.map +1 -1
  20. package/build/lib/mixins/message-handlers.js +49 -10
  21. package/build/lib/mixins/message-handlers.js.map +1 -1
  22. package/build/lib/mixins/misc.d.ts +10 -9
  23. package/build/lib/mixins/misc.d.ts.map +1 -1
  24. package/build/lib/mixins/misc.js +12 -9
  25. package/build/lib/mixins/misc.js.map +1 -1
  26. package/build/lib/mixins/navigate.d.ts +10 -8
  27. package/build/lib/mixins/navigate.d.ts.map +1 -1
  28. package/build/lib/mixins/navigate.js +10 -6
  29. package/build/lib/mixins/navigate.js.map +1 -1
  30. package/build/lib/mixins/screenshot.d.ts +2 -1
  31. package/build/lib/mixins/screenshot.d.ts.map +1 -1
  32. package/build/lib/mixins/screenshot.js +4 -1
  33. package/build/lib/mixins/screenshot.js.map +1 -1
  34. package/build/lib/remote-debugger.d.ts +4 -4
  35. package/build/lib/remote-debugger.d.ts.map +1 -1
  36. package/build/lib/types.d.ts +34 -0
  37. package/build/lib/types.d.ts.map +1 -0
  38. package/build/lib/types.js +3 -0
  39. package/build/lib/types.js.map +1 -0
  40. package/build/lib/utils.d.ts +25 -52
  41. package/build/lib/utils.d.ts.map +1 -1
  42. package/build/lib/utils.js +31 -113
  43. package/build/lib/utils.js.map +1 -1
  44. package/build/tsconfig.tsbuildinfo +1 -1
  45. package/lib/mixins/connect.js +71 -32
  46. package/lib/mixins/cookies.js +7 -3
  47. package/lib/mixins/events.js +6 -2
  48. package/lib/mixins/execute.js +9 -3
  49. package/lib/mixins/message-handlers.js +51 -11
  50. package/lib/mixins/misc.js +13 -9
  51. package/lib/mixins/navigate.js +11 -6
  52. package/lib/mixins/screenshot.js +5 -1
  53. package/lib/remote-debugger.js +2 -2
  54. package/lib/types.ts +39 -0
  55. package/lib/utils.js +30 -122
  56. package/package.json +1 -1
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  pageArrayFromDict,
3
- getPossibleDebuggerAppKeys,
3
+ WEB_CONTENT_BUNDLE_ID,
4
+ appIdsForBundle,
4
5
  } from '../utils';
5
6
  import events from './events';
6
- import { timing } from '@appium/support';
7
+ import { timing, util } from '@appium/support';
7
8
  import { retryInterval, waitForCondition } from 'asyncbox';
8
9
  import _ from 'lodash';
9
10
 
@@ -13,10 +14,14 @@ const SELECT_APP_RETRIES = 20;
13
14
  const SELECT_APP_RETRY_SLEEP_MS = 500;
14
15
  const SAFARI_BUNDLE_ID = 'com.apple.mobilesafari';
15
16
  const BLANK_PAGE_URL = 'about:blank';
17
+ const WEB_CONTENT_PROCESS_BUNDLE_ID = 'process-com.apple.WebKit.WebContent';
18
+ const SAFARI_VIEW_PROCESS_BUNDLE_ID = 'process-SafariViewService';
19
+ const SAFARI_VIEW_BUNDLE_ID = 'com.apple.SafariViewService';
20
+ const WILDCARD_BUNDLE_ID = '*';
16
21
 
17
22
  /**
18
23
  *
19
- * @this {import('../remote-debugger').RemoteDebugger}
24
+ * @this {RemoteDebugger}
20
25
  * @returns {Promise<void>}
21
26
  */
22
27
  export async function setConnectionKey () {
@@ -29,7 +34,7 @@ export async function setConnectionKey () {
29
34
 
30
35
  /**
31
36
  *
32
- * @this {import('../remote-debugger').RemoteDebugger}
37
+ * @this {RemoteDebugger}
33
38
  * @param {number} [timeout=APP_CONNECT_TIMEOUT_MS]
34
39
  * @returns {Promise<import('@appium/types').StringRecord>}
35
40
  */
@@ -56,14 +61,19 @@ export async function connect (timeout = APP_CONNECT_TIMEOUT_MS) {
56
61
 
57
62
  // get the connection information about the app
58
63
  try {
59
- this.setConnectionKey();
64
+ await this.setConnectionKey();
60
65
  if (timeout) {
66
+ const timer = new timing.Timer().start();
61
67
  this.log.debug(`Waiting up to ${timeout}ms for applications to be reported`);
62
68
  try {
63
69
  await waitForCondition(() => !_.isEmpty(this.appDict), {
64
70
  waitMs: timeout,
65
71
  intervalMs: APP_CONNECT_INTERVAL_MS,
66
72
  });
73
+ this.log.debug(
74
+ `Retrieved ${util.pluralize('application', _.size(this.appDict), true)} ` +
75
+ `within ${timer.getDuration().asMilliSeconds.toFixed(0)}ms`
76
+ );
67
77
  } catch (err) {
68
78
  this.log.debug(`Timed out waiting for applications to be reported`);
69
79
  }
@@ -78,7 +88,7 @@ export async function connect (timeout = APP_CONNECT_TIMEOUT_MS) {
78
88
 
79
89
  /**
80
90
  *
81
- * @this {import('../remote-debugger').RemoteDebugger}
91
+ * @this {RemoteDebugger}
82
92
  * @returns {Promise<void>}
83
93
  */
84
94
  export async function disconnect () {
@@ -91,11 +101,11 @@ export async function disconnect () {
91
101
 
92
102
  /**
93
103
  *
94
- * @this {import('../remote-debugger').RemoteDebugger}
104
+ * @this {RemoteDebugger}
95
105
  * @param {string?} [currentUrl=null]
96
106
  * @param {number} [maxTries=SELECT_APP_RETRIES]
97
107
  * @param {boolean} [ignoreAboutBlankUrl=false]
98
- * @returns {Promise<Page[]>}
108
+ * @returns {Promise<import('../types').Page[]>}
99
109
  */
100
110
  export async function selectApp (currentUrl = null, maxTries = SELECT_APP_RETRIES, ignoreAboutBlankUrl = false) {
101
111
  this.log.debug('Selecting application');
@@ -119,7 +129,7 @@ export async function selectApp (currentUrl = null, maxTries = SELECT_APP_RETRIE
119
129
  // translate the dictionary into a useful form, and return to sender
120
130
  this.log.debug(`Finally selecting app ${this.appIdKey}`);
121
131
 
122
- /** @type {Page[]} */
132
+ /** @type {import('../types').Page[]} */
123
133
  const fullPageArray = [];
124
134
  for (const [app, info] of _.toPairs(this.appDict)) {
125
135
  if (!_.isArray(info.pageArray) || !info.isActive) {
@@ -145,20 +155,20 @@ export async function selectApp (currentUrl = null, maxTries = SELECT_APP_RETRIE
145
155
 
146
156
  /**
147
157
  *
148
- * @this {import('../remote-debugger').RemoteDebugger}
158
+ * @this {RemoteDebugger}
149
159
  * @param {string?} currentUrl
150
160
  * @param {number} maxTries
151
161
  * @param {boolean} ignoreAboutBlankUrl
152
- * @returns {Promise<AppPage>}
162
+ * @returns {Promise<import('../types').AppPage>}
153
163
  */
154
164
  export async function searchForApp (currentUrl, maxTries, ignoreAboutBlankUrl) {
155
165
  const bundleIds = this.includeSafari && !this.isSafari
156
166
  ? [this.bundleId, ...this.additionalBundleIds, SAFARI_BUNDLE_ID]
157
167
  : [this.bundleId, ...this.additionalBundleIds];
158
168
  let retryCount = 0;
159
- return /** @type {AppPage} */ (await retryInterval(maxTries, SELECT_APP_RETRY_SLEEP_MS, async () => {
169
+ return /** @type {import('../types').AppPage} */ (await retryInterval(maxTries, SELECT_APP_RETRY_SLEEP_MS, async () => {
160
170
  logApplicationDictionary.bind(this)();
161
- const possibleAppIds = getPossibleDebuggerAppKeys(/** @type {string[]} */ (bundleIds), this.appDict);
171
+ const possibleAppIds = getPossibleDebuggerAppKeys.bind(this)(/** @type {string[]} */ (bundleIds));
162
172
  this.log.debug(`Trying out the possible app ids: ${possibleAppIds.join(', ')} (try #${retryCount + 1} of ${maxTries})`);
163
173
  for (const attemptedAppIdKey of possibleAppIds) {
164
174
  try {
@@ -209,11 +219,11 @@ export async function searchForApp (currentUrl, maxTries, ignoreAboutBlankUrl) {
209
219
 
210
220
  /**
211
221
  *
212
- * @this {import('../remote-debugger').RemoteDebugger}
213
- * @param {Record<string, import('../utils').AppInfo>} appsDict
222
+ * @this {RemoteDebugger}
223
+ * @param {Record<string, import('../types').AppInfo>} appsDict
214
224
  * @param {string?} currentUrl
215
225
  * @param {boolean} [ignoreAboutBlankUrl]
216
- * @returns {AppPage?}
226
+ * @returns {import('../types').AppPage?}
217
227
  */
218
228
  export function searchForPage (appsDict, currentUrl = null, ignoreAboutBlankUrl = false) {
219
229
  for (const appDict of _.values(appsDict)) {
@@ -236,7 +246,7 @@ export function searchForPage (appsDict, currentUrl = null, ignoreAboutBlankUrl
236
246
 
237
247
  /**
238
248
  *
239
- * @this {import('../remote-debugger').RemoteDebugger}
249
+ * @this {RemoteDebugger}
240
250
  * @param {string|number} appIdKey
241
251
  * @param {string|number} pageIdKey
242
252
  * @param {boolean} [skipReadyCheck]
@@ -261,7 +271,7 @@ export async function selectPage (appIdKey, pageIdKey, skipReadyCheck = false) {
261
271
  }
262
272
 
263
273
  /**
264
- * @this {import('../remote-debugger').RemoteDebugger}
274
+ * @this {RemoteDebugger}
265
275
  * @returns {void}
266
276
  */
267
277
  function logApplicationDictionary () {
@@ -287,22 +297,51 @@ function logApplicationDictionary () {
287
297
  }
288
298
 
289
299
  /**
290
- * @typedef {Object} AppPage
291
- * @property {string} appIdKey
292
- * @property {Page} pageDict
300
+ * Find app keys based on assigned bundleIds from appDict
301
+ * When bundleIds includes a wildcard ('*'), returns all appKeys in appDict.
302
+ *
303
+ * @this {RemoteDebugger}
304
+ * @param {string[]} bundleIds
305
+ * @returns {string[]}
293
306
  */
307
+ export function getPossibleDebuggerAppKeys(bundleIds) {
308
+ if (bundleIds.includes(WILDCARD_BUNDLE_ID)) {
309
+ this.log.debug('Skip checking bundle identifiers because the bundleIds includes a wildcard');
310
+ return _.uniq(Object.keys(this.appDict));
311
+ }
294
312
 
295
- /**
296
- * @typedef {Object} App
297
- * @property {string} id
298
- * @property {string} bundleId
299
- */
313
+ // go through the possible bundle identifiers
314
+ const possibleBundleIds = _.uniq([
315
+ WEB_CONTENT_BUNDLE_ID,
316
+ WEB_CONTENT_PROCESS_BUNDLE_ID,
317
+ SAFARI_VIEW_PROCESS_BUNDLE_ID,
318
+ SAFARI_VIEW_BUNDLE_ID,
319
+ WILDCARD_BUNDLE_ID,
320
+ ...bundleIds,
321
+ ]);
322
+ this.log.debug(`Checking for bundle identifiers: ${possibleBundleIds.join(', ')}`);
323
+ /** @type {Set<string>} */
324
+ const proxiedAppIds = new Set();
325
+ for (const bundleId of possibleBundleIds) {
326
+ // now we need to determine if we should pick a proxy for this instead
327
+ for (const appId of appIdsForBundle(bundleId, this.appDict)) {
328
+ proxiedAppIds.add(appId);
329
+ this.log.debug(`Found app id key '${appId}' for bundle '${bundleId}'`);
330
+ for (const [key, data] of _.toPairs(this.appDict)) {
331
+ if (data.isProxy && data.hostId === appId) {
332
+ this.log.debug(
333
+ `Found separate bundleId '${data.bundleId}' ` +
334
+ `acting as proxy for '${bundleId}', with app id '${key}'`
335
+ );
336
+ proxiedAppIds.add(key);
337
+ }
338
+ }
339
+ }
340
+ }
341
+
342
+ return Array.from(proxiedAppIds);
343
+ }
300
344
 
301
345
  /**
302
- * @typedef {Object} Page
303
- * @property {string} url
304
- * @property {string} title
305
- * @property {number} id
306
- * @property {boolean} isKey
307
- * @property {string} [bundleId]
346
+ * @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
308
347
  */
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
3
  *
4
- * @this {import('../remote-debugger').RemoteDebugger}
4
+ * @this {RemoteDebugger}
5
5
  * @returns {Promise<import('@appium/types').StringRecord>}
6
6
  */
7
7
  export async function getCookies () {
@@ -14,7 +14,7 @@ export async function getCookies () {
14
14
 
15
15
  /**
16
16
  *
17
- * @this {import('../remote-debugger').RemoteDebugger}
17
+ * @this {RemoteDebugger}
18
18
  * @param {import('@appium/types').StringRecord} cookie
19
19
  * @returns {Promise<any>}
20
20
  */
@@ -29,7 +29,7 @@ export async function setCookie (cookie) {
29
29
 
30
30
  /**
31
31
  *
32
- * @this {import('../remote-debugger').RemoteDebugger}
32
+ * @this {RemoteDebugger}
33
33
  * @param {string} cookieName
34
34
  * @param {string} url
35
35
  * @returns {Promise<any>}
@@ -43,3 +43,7 @@ export async function deleteCookie (cookieName, url) {
43
43
  url,
44
44
  });
45
45
  }
46
+
47
+ /**
48
+ * @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
49
+ */
@@ -8,7 +8,7 @@ export const events = {
8
8
  /**
9
9
  * Keep track of the client event listeners so they can be removed
10
10
  *
11
- * @this {import('../remote-debugger').RemoteDebugger}
11
+ * @this {RemoteDebugger}
12
12
  * @param {string} eventName
13
13
  * @param {(event: import('@appium/types').StringRecord) => any} listener
14
14
  * @returns {void}
@@ -20,7 +20,7 @@ export function addClientEventListener (eventName, listener) {
20
20
  }
21
21
 
22
22
  /**
23
- * @this {import('../remote-debugger').RemoteDebugger}
23
+ * @this {RemoteDebugger}
24
24
  * @param {string} eventName
25
25
  * @returns {void}
26
26
  */
@@ -31,3 +31,7 @@ export function removeClientEventListener (eventName) {
31
31
  }
32
32
 
33
33
  export default events;
34
+
35
+ /**
36
+ * @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
37
+ */
@@ -11,6 +11,8 @@ const RPC_RESPONSE_TIMEOUT_MS = 5000;
11
11
 
12
12
  /**
13
13
  * Execute a Selenium atom in Safari
14
+ *
15
+ * @this {RemoteDebugger}
14
16
  * @param {string} atom Name of Selenium atom (see atoms/ directory)
15
17
  * @param {any[]} args Arguments passed to the atom
16
18
  * @param {string[]} frames
@@ -25,7 +27,7 @@ export async function executeAtom (atom, args = [], frames = []) {
25
27
  }
26
28
 
27
29
  /**
28
- * @this {import('../remote-debugger').RemoteDebugger}
30
+ * @this {RemoteDebugger}
29
31
  * @param {string} atom
30
32
  * @param {any[]} [args]
31
33
  * @param {string[]} [frames]
@@ -116,7 +118,7 @@ export async function executeAtomAsync (atom, args = [], frames = []) {
116
118
  }
117
119
 
118
120
  /**
119
- * @this {import('../remote-debugger').RemoteDebugger}
121
+ * @this {RemoteDebugger}
120
122
  * @param {string} command
121
123
  * @param {boolean} [override]
122
124
  * @returns {Promise<any>}
@@ -150,7 +152,7 @@ export async function execute (command, override) {
150
152
  }
151
153
 
152
154
  /**
153
- * @this {import('../remote-debugger').RemoteDebugger}
155
+ * @this {RemoteDebugger}
154
156
  * @param {string} objectId
155
157
  * @param {any} fn
156
158
  * @param {any[]} [args]
@@ -174,3 +176,7 @@ export async function callFunction (objectId, fn, args) {
174
176
 
175
177
  return convertResult(res);
176
178
  }
179
+
180
+ /**
181
+ * @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
182
+ */
@@ -1,7 +1,6 @@
1
1
  import events from './events';
2
2
  import {
3
3
  pageArrayFromDict,
4
- getDebuggerAppKey,
5
4
  appInfoFromDict,
6
5
  } from '../utils';
7
6
  import _ from 'lodash';
@@ -13,7 +12,7 @@ import _ from 'lodash';
13
12
  */
14
13
 
15
14
  /**
16
- * @this {import('../remote-debugger').RemoteDebugger}
15
+ * @this {RemoteDebugger}
17
16
  * @param {Error?} err
18
17
  * @param {string} appIdKey
19
18
  * @param {Record<string, any>} pageDict
@@ -56,7 +55,7 @@ export async function onPageChange (err, appIdKey, pageDict) {
56
55
  }
57
56
 
58
57
  /**
59
- * @this {import('../remote-debugger').RemoteDebugger}
58
+ * @this {RemoteDebugger}
60
59
  * @param {Error?} err
61
60
  * @param {Record<string, any>} dict
62
61
  * @returns {Promise<void>}
@@ -69,7 +68,7 @@ export async function onAppConnect (err, dict) {
69
68
  }
70
69
 
71
70
  /**
72
- * @this {import('../remote-debugger').RemoteDebugger}
71
+ * @this {RemoteDebugger}
73
72
  * @param {Error?} err
74
73
  * @param {import('@appium/types').StringRecord} dict
75
74
  * @returns {void}
@@ -86,7 +85,7 @@ export function onAppDisconnect (err, dict) {
86
85
  // if the disconnected app is the one we are connected to, try to find another
87
86
  if (this.appIdKey === appIdKey) {
88
87
  this.log.debug(`No longer have app id. Attempting to find new one.`);
89
- this.appIdKey = getDebuggerAppKey(/** @type {string} */ (this.bundleId), this.appDict);
88
+ this.appIdKey = getDebuggerAppKey.bind(this)(/** @type {string} */ (this.bundleId));
90
89
  }
91
90
 
92
91
  if (!this.appDict) {
@@ -98,7 +97,7 @@ export function onAppDisconnect (err, dict) {
98
97
  }
99
98
 
100
99
  /**
101
- * @this {import('../remote-debugger').RemoteDebugger}
100
+ * @this {RemoteDebugger}
102
101
  * @param {Error?} err
103
102
  * @param {Record<string, any>} dict
104
103
  * @returns {Promise<void>}
@@ -110,7 +109,7 @@ export async function onAppUpdate (err, dict) {
110
109
  }
111
110
 
112
111
  /**
113
- * @this {import('../remote-debugger').RemoteDebugger}
112
+ * @this {RemoteDebugger}
114
113
  * @param {Error?} err
115
114
  * @param {Record<string, any>} drivers
116
115
  * @returns {void}
@@ -121,7 +120,7 @@ export function onConnectedDriverList (err, drivers) {
121
120
  }
122
121
 
123
122
  /**
124
- * @this {import('../remote-debugger').RemoteDebugger}
123
+ * @this {RemoteDebugger}
125
124
  * @param {Error?} err
126
125
  * @param {Record<string, any>} state
127
126
  * @returns {void}
@@ -134,7 +133,7 @@ export function onCurrentState (err, state) {
134
133
  }
135
134
 
136
135
  /**
137
- * @this {import('../remote-debugger').RemoteDebugger}
136
+ * @this {RemoteDebugger}
138
137
  * @param {Error?} err
139
138
  * @param {Record<string, any>} apps
140
139
  * @returns {Promise<void>}
@@ -159,7 +158,7 @@ export async function onConnectedApplicationList (err, apps) {
159
158
 
160
159
  /**
161
160
  *
162
- * @this {import('../remote-debugger').RemoteDebugger}
161
+ * @this {RemoteDebugger}
163
162
  * @param {import('@appium/types').StringRecord} dict
164
163
  * @returns {void}
165
164
  */
@@ -176,6 +175,47 @@ function updateAppsWithDict (dict) {
176
175
 
177
176
  // try to get the app id from our connected apps
178
177
  if (!this.appIdKey) {
179
- this.appIdKey = getDebuggerAppKey(/** @type {string} */ (this.bundleId), this.appDict);
178
+ this.appIdKey = getDebuggerAppKey.bind(this)(/** @type {string} */ (this.bundleId));
180
179
  }
181
180
  }
181
+
182
+ /**
183
+ * Given a bundle id, finds the correct remote debugger app that is
184
+ * connected.
185
+ *
186
+ * @this {RemoteDebugger}
187
+ * @param {string} bundleId
188
+ * @returns {string|undefined}
189
+ */
190
+ export function getDebuggerAppKey (bundleId) {
191
+ let appId;
192
+ for (const [key, data] of _.toPairs(this.appDict)) {
193
+ if (data.bundleId === bundleId) {
194
+ appId = key;
195
+ break;
196
+ }
197
+ }
198
+ // now we need to determine if we should pick a proxy for this instead
199
+ if (appId) {
200
+ this.log.debug(`Found app id key '${appId}' for bundle '${bundleId}'`);
201
+ let proxyAppId;
202
+ for (const [key, data] of _.toPairs(this.appDict)) {
203
+ if (data.isProxy && data.hostId === appId) {
204
+ this.log.debug(`Found separate bundleId '${data.bundleId}' ` +
205
+ `acting as proxy for '${bundleId}', with app id '${key}'`);
206
+ // set the app id... the last one will be used, so just keep re-assigning
207
+ proxyAppId = key;
208
+ }
209
+ }
210
+ if (proxyAppId) {
211
+ appId = proxyAppId;
212
+ this.log.debug(`Using proxied app id '${appId}'`);
213
+ }
214
+ }
215
+
216
+ return appId;
217
+ }
218
+
219
+ /**
220
+ * @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
221
+ */
@@ -5,7 +5,7 @@ const SAFARI_BUNDLE_ID = 'com.apple.mobilesafari';
5
5
  const GARBAGE_COLLECT_TIMEOUT_MS = 5000;
6
6
 
7
7
  /**
8
- * @this {import('../remote-debugger').RemoteDebugger}
8
+ * @this {RemoteDebugger}
9
9
  * @returns {Promise<void>}
10
10
  */
11
11
  export async function launchSafari () {
@@ -15,7 +15,7 @@ export async function launchSafari () {
15
15
  }
16
16
 
17
17
  /**
18
- * @this {import('../remote-debugger').RemoteDebugger}
18
+ * @this {RemoteDebugger}
19
19
  * @param {(event: import('@appium/types').StringRecord) => any} fn
20
20
  * @returns {Promise<any>}
21
21
  */
@@ -29,7 +29,7 @@ export async function startTimeline (fn) {
29
29
  }
30
30
 
31
31
  /**
32
- * @this {import('../remote-debugger').RemoteDebugger}
32
+ * @this {RemoteDebugger}
33
33
  * @returns {Promise<any>}
34
34
  */
35
35
  export async function stopTimeline () {
@@ -41,7 +41,7 @@ export async function stopTimeline () {
41
41
  }
42
42
 
43
43
  /**
44
- * @this {import('../remote-debugger').RemoteDebugger}
44
+ * @this {RemoteDebugger}
45
45
  * @param {(event: import('@appium/types').StringRecord) => any} listener
46
46
  * @returns {void}
47
47
  */
@@ -52,7 +52,7 @@ export function startConsole (listener) {
52
52
  }
53
53
 
54
54
  /**
55
- * @this {import('../remote-debugger').RemoteDebugger}
55
+ * @this {RemoteDebugger}
56
56
  * @returns {void}
57
57
  */
58
58
  export function stopConsole () {
@@ -62,7 +62,7 @@ export function stopConsole () {
62
62
  }
63
63
 
64
64
  /**
65
- * @this {import('../remote-debugger').RemoteDebugger}
65
+ * @this {RemoteDebugger}
66
66
  * @param {(event: import('@appium/types').StringRecord) => any} listener
67
67
  * @returns {void}
68
68
  */
@@ -72,7 +72,7 @@ export function startNetwork (listener) {
72
72
  }
73
73
 
74
74
  /**
75
- * @this {import('../remote-debugger').RemoteDebugger}
75
+ * @this {RemoteDebugger}
76
76
  * @returns {void}
77
77
  */
78
78
  export function stopNetwork () {
@@ -82,7 +82,7 @@ export function stopNetwork () {
82
82
 
83
83
  // Potentially this does not work for mobile safari
84
84
  /**
85
- * @this {import('../remote-debugger').RemoteDebugger}
85
+ * @this {RemoteDebugger}
86
86
  * @param {string} value
87
87
  * @returns {Promise<any>}
88
88
  */
@@ -96,7 +96,7 @@ export async function overrideUserAgent (value) {
96
96
  }
97
97
 
98
98
  /**
99
- * @this {import('../remote-debugger').RemoteDebugger}
99
+ * @this {RemoteDebugger}
100
100
  * @param {number} [timeoutMs=GARBAGE_COLLECT_TIMEOUT_MS]
101
101
  * @returns {Promise<void>}
102
102
  */
@@ -126,3 +126,7 @@ export async function garbageCollect (timeoutMs = GARBAGE_COLLECT_TIMEOUT_MS) {
126
126
  }
127
127
  }
128
128
  }
129
+
130
+ /**
131
+ * @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
132
+ */
@@ -21,7 +21,7 @@ const PAGE_LOAD_STRATEGY = {
21
21
  };
22
22
 
23
23
  /**
24
- * @this {import('../remote-debugger').RemoteDebugger}
24
+ * @this {RemoteDebugger}
25
25
  * @returns {void}
26
26
  */
27
27
  export function frameDetached () {
@@ -29,7 +29,7 @@ export function frameDetached () {
29
29
  }
30
30
 
31
31
  /**
32
- * @this {import('../remote-debugger').RemoteDebugger}
32
+ * @this {RemoteDebugger}
33
33
  * @returns {void}
34
34
  */
35
35
  export function cancelPageLoad () {
@@ -43,7 +43,8 @@ export function cancelPageLoad () {
43
43
  /**
44
44
  * Return if current readState can be handles as page load completes
45
45
  * for the given page load strategy.
46
- * @this {import('../remote-debugger').RemoteDebugger}
46
+ *
47
+ * @this {RemoteDebugger}
47
48
  * @param {string} readyState
48
49
  * @returns {boolean}
49
50
  */
@@ -63,7 +64,7 @@ export function isPageLoadingCompleted (readyState) {
63
64
  }
64
65
 
65
66
  /**
66
- * @this {import('../remote-debugger').RemoteDebugger}
67
+ * @this {RemoteDebugger}
67
68
  * @param {timing.Timer?} [startPageLoadTimer]
68
69
  * @returns {Promise<void>}
69
70
  */
@@ -132,7 +133,7 @@ export async function waitForDom (startPageLoadTimer) {
132
133
  }
133
134
 
134
135
  /**
135
- * @this {import('../remote-debugger').RemoteDebugger}
136
+ * @this {RemoteDebugger}
136
137
  * @param {number} [timeoutMs]
137
138
  * @returns {Promise<boolean>}
138
139
  */
@@ -156,7 +157,7 @@ export async function checkPageIsReady (timeoutMs) {
156
157
  }
157
158
 
158
159
  /**
159
- * @this {import('../remote-debugger').RemoteDebugger}
160
+ * @this {RemoteDebugger}
160
161
  * @param {string} url
161
162
  * @returns {Promise<void>}
162
163
  */
@@ -280,3 +281,7 @@ export async function navToUrl (url) {
280
281
  throw err;
281
282
  }
282
283
  }
284
+
285
+ /**
286
+ * @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
287
+ */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Capture a rect of the page or by default the viewport
3
- * @this {import('../remote-debugger').RemoteDebugger}
3
+ * @this {RemoteDebugger}
4
4
  * @param {ScreenshotCaptureOptions} [opts={}] if rect is null capture the whole
5
5
  * coordinate system else capture the rect in the given coordinateSystem
6
6
  * @returns {Promise<string>} a base64 encoded string of the screenshot
@@ -32,3 +32,7 @@ export async function captureScreenshot(opts = {}) {
32
32
  * @property {import('@appium/types').Rect | null} [rect=null]
33
33
  * @property {"Viewport" | "Page"} [coordinateSystem="Viewport"]
34
34
  */
35
+
36
+ /**
37
+ * @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
38
+ */
@@ -24,9 +24,9 @@ export class RemoteDebugger extends EventEmitter {
24
24
  // properties
25
25
  /** @type {string[]|undefined} */
26
26
  _skippedApps;
27
- /** @type {Record<string, any>} */
27
+ /** @type {import('@appium/types').StringRecord<Function[]>} */
28
28
  _clientEventListeners;
29
- /** @type {Record<string, any>} */
29
+ /** @type {import('./types').AppDict} */
30
30
  appDict;
31
31
  /** @type {string|null|undefined} */
32
32
  appIdKey;
package/lib/types.ts ADDED
@@ -0,0 +1,39 @@
1
+ import type { StringRecord } from '@appium/types';
2
+ import type B from 'bluebird';
3
+
4
+ export interface DeferredPromise {
5
+ promise: B<any>;
6
+ resolve: (...args: any[]) => void;
7
+ reject: (err?: Error) => void;
8
+ }
9
+
10
+ export interface AppInfo {
11
+ id: string;
12
+ isProxy: boolean;
13
+ name: string;
14
+ bundleId: string;
15
+ hostId?: string;
16
+ isActive: boolean;
17
+ isAutomationEnabled: boolean | string;
18
+ pageArray?: Page[];
19
+ }
20
+
21
+ export interface AppPage {
22
+ appIdKey: string;
23
+ pageDict: Page;
24
+ }
25
+
26
+ export interface App {
27
+ id: string;
28
+ bundleId: string;
29
+ }
30
+
31
+ export interface Page {
32
+ url: string;
33
+ title: string;
34
+ id: number | string;
35
+ isKey: boolean;
36
+ bundleId?: string;
37
+ }
38
+
39
+ export type AppDict = StringRecord<AppInfo>;