appium-android-driver 13.4.0 → 14.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.
Files changed (233) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/build/lib/commands/app-management.d.ts +2 -2
  3. package/build/lib/commands/app-management.d.ts.map +1 -1
  4. package/build/lib/commands/app-management.js +41 -67
  5. package/build/lib/commands/app-management.js.map +1 -1
  6. package/build/lib/commands/appearance.d.ts +1 -1
  7. package/build/lib/commands/appearance.d.ts.map +1 -1
  8. package/build/lib/commands/appearance.js +2 -6
  9. package/build/lib/commands/appearance.js.map +1 -1
  10. package/build/lib/commands/bidi/constants.js +4 -8
  11. package/build/lib/commands/bidi/constants.js.map +1 -1
  12. package/build/lib/commands/bidi/models.d.ts +1 -1
  13. package/build/lib/commands/bidi/models.d.ts.map +1 -1
  14. package/build/lib/commands/bidi/models.js +7 -13
  15. package/build/lib/commands/bidi/models.js.map +1 -1
  16. package/build/lib/commands/bidi/types.js +1 -2
  17. package/build/lib/commands/bluetooth.d.ts +1 -1
  18. package/build/lib/commands/bluetooth.d.ts.map +1 -1
  19. package/build/lib/commands/bluetooth.js +3 -6
  20. package/build/lib/commands/bluetooth.js.map +1 -1
  21. package/build/lib/commands/context/cache.d.ts +1 -1
  22. package/build/lib/commands/context/cache.d.ts.map +1 -1
  23. package/build/lib/commands/context/cache.js +5 -10
  24. package/build/lib/commands/context/cache.js.map +1 -1
  25. package/build/lib/commands/context/exports.d.ts +2 -2
  26. package/build/lib/commands/context/exports.d.ts.map +1 -1
  27. package/build/lib/commands/context/exports.js +64 -86
  28. package/build/lib/commands/context/exports.js.map +1 -1
  29. package/build/lib/commands/context/helpers.d.ts +2 -2
  30. package/build/lib/commands/context/helpers.d.ts.map +1 -1
  31. package/build/lib/commands/context/helpers.js +69 -82
  32. package/build/lib/commands/context/helpers.js.map +1 -1
  33. package/build/lib/commands/device/common.d.ts +2 -2
  34. package/build/lib/commands/device/common.d.ts.map +1 -1
  35. package/build/lib/commands/device/common.js +28 -71
  36. package/build/lib/commands/device/common.js.map +1 -1
  37. package/build/lib/commands/device/emulator-actions.d.ts +2 -2
  38. package/build/lib/commands/device/emulator-actions.d.ts.map +1 -1
  39. package/build/lib/commands/device/emulator-actions.js +33 -52
  40. package/build/lib/commands/device/emulator-actions.js.map +1 -1
  41. package/build/lib/commands/device/emulator-console.d.ts +1 -1
  42. package/build/lib/commands/device/emulator-console.d.ts.map +1 -1
  43. package/build/lib/commands/device/emulator-console.js +3 -6
  44. package/build/lib/commands/device/emulator-console.js.map +1 -1
  45. package/build/lib/commands/device/utils.d.ts +1 -1
  46. package/build/lib/commands/device/utils.d.ts.map +1 -1
  47. package/build/lib/commands/device/utils.js +27 -37
  48. package/build/lib/commands/device/utils.js.map +1 -1
  49. package/build/lib/commands/deviceidle.d.ts +1 -1
  50. package/build/lib/commands/deviceidle.d.ts.map +1 -1
  51. package/build/lib/commands/deviceidle.js +4 -7
  52. package/build/lib/commands/deviceidle.js.map +1 -1
  53. package/build/lib/commands/element.d.ts +2 -2
  54. package/build/lib/commands/element.d.ts.map +1 -1
  55. package/build/lib/commands/element.js +22 -39
  56. package/build/lib/commands/element.js.map +1 -1
  57. package/build/lib/commands/execute.d.ts +1 -1
  58. package/build/lib/commands/execute.d.ts.map +1 -1
  59. package/build/lib/commands/execute.js +6 -9
  60. package/build/lib/commands/execute.js.map +1 -1
  61. package/build/lib/commands/file-actions.d.ts +1 -1
  62. package/build/lib/commands/file-actions.d.ts.map +1 -1
  63. package/build/lib/commands/file-actions.js +25 -34
  64. package/build/lib/commands/file-actions.js.map +1 -1
  65. package/build/lib/commands/find.d.ts +2 -2
  66. package/build/lib/commands/find.d.ts.map +1 -1
  67. package/build/lib/commands/find.js +10 -14
  68. package/build/lib/commands/find.js.map +1 -1
  69. package/build/lib/commands/geolocation.d.ts +1 -1
  70. package/build/lib/commands/geolocation.d.ts.map +1 -1
  71. package/build/lib/commands/geolocation.js +21 -35
  72. package/build/lib/commands/geolocation.js.map +1 -1
  73. package/build/lib/commands/gestures.d.ts +1 -1
  74. package/build/lib/commands/gestures.d.ts.map +1 -1
  75. package/build/lib/commands/gestures.js +4 -7
  76. package/build/lib/commands/gestures.js.map +1 -1
  77. package/build/lib/commands/image-injection.d.ts +1 -1
  78. package/build/lib/commands/image-injection.d.ts.map +1 -1
  79. package/build/lib/commands/image-injection.js +16 -23
  80. package/build/lib/commands/image-injection.js.map +1 -1
  81. package/build/lib/commands/ime.d.ts +1 -1
  82. package/build/lib/commands/ime.d.ts.map +1 -1
  83. package/build/lib/commands/ime.js +10 -18
  84. package/build/lib/commands/ime.js.map +1 -1
  85. package/build/lib/commands/intent.d.ts +1 -1
  86. package/build/lib/commands/intent.d.ts.map +1 -1
  87. package/build/lib/commands/intent.js +22 -29
  88. package/build/lib/commands/intent.js.map +1 -1
  89. package/build/lib/commands/keyboard.d.ts +2 -2
  90. package/build/lib/commands/keyboard.d.ts.map +1 -1
  91. package/build/lib/commands/keyboard.js +21 -33
  92. package/build/lib/commands/keyboard.js.map +1 -1
  93. package/build/lib/commands/legacy.d.ts +1 -1
  94. package/build/lib/commands/legacy.d.ts.map +1 -1
  95. package/build/lib/commands/legacy.js +7 -12
  96. package/build/lib/commands/legacy.js.map +1 -1
  97. package/build/lib/commands/lock/exports.d.ts +2 -2
  98. package/build/lib/commands/lock/exports.d.ts.map +1 -1
  99. package/build/lib/commands/lock/exports.js +18 -25
  100. package/build/lib/commands/lock/exports.js.map +1 -1
  101. package/build/lib/commands/lock/helpers.d.ts +2 -2
  102. package/build/lib/commands/lock/helpers.d.ts.map +1 -1
  103. package/build/lib/commands/lock/helpers.js +48 -64
  104. package/build/lib/commands/lock/helpers.js.map +1 -1
  105. package/build/lib/commands/log.d.ts +2 -2
  106. package/build/lib/commands/log.d.ts.map +1 -1
  107. package/build/lib/commands/log.js +38 -42
  108. package/build/lib/commands/log.js.map +1 -1
  109. package/build/lib/commands/media-projection.d.ts +2 -2
  110. package/build/lib/commands/media-projection.d.ts.map +1 -1
  111. package/build/lib/commands/media-projection.js +14 -22
  112. package/build/lib/commands/media-projection.js.map +1 -1
  113. package/build/lib/commands/memory.d.ts +2 -2
  114. package/build/lib/commands/memory.d.ts.map +1 -1
  115. package/build/lib/commands/memory.js +4 -7
  116. package/build/lib/commands/memory.js.map +1 -1
  117. package/build/lib/commands/misc.d.ts +2 -2
  118. package/build/lib/commands/misc.d.ts.map +1 -1
  119. package/build/lib/commands/misc.js +10 -19
  120. package/build/lib/commands/misc.js.map +1 -1
  121. package/build/lib/commands/network.d.ts +2 -2
  122. package/build/lib/commands/network.d.ts.map +1 -1
  123. package/build/lib/commands/network.js +14 -26
  124. package/build/lib/commands/network.js.map +1 -1
  125. package/build/lib/commands/nfc.d.ts +2 -2
  126. package/build/lib/commands/nfc.d.ts.map +1 -1
  127. package/build/lib/commands/nfc.js +3 -6
  128. package/build/lib/commands/nfc.js.map +1 -1
  129. package/build/lib/commands/performance.d.ts +2 -2
  130. package/build/lib/commands/performance.d.ts.map +1 -1
  131. package/build/lib/commands/performance.js +48 -58
  132. package/build/lib/commands/performance.js.map +1 -1
  133. package/build/lib/commands/permissions.d.ts +1 -1
  134. package/build/lib/commands/permissions.d.ts.map +1 -1
  135. package/build/lib/commands/permissions.js +16 -20
  136. package/build/lib/commands/permissions.js.map +1 -1
  137. package/build/lib/commands/recordscreen.d.ts +2 -2
  138. package/build/lib/commands/recordscreen.d.ts.map +1 -1
  139. package/build/lib/commands/recordscreen.js +32 -39
  140. package/build/lib/commands/recordscreen.js.map +1 -1
  141. package/build/lib/commands/resources.d.ts +1 -1
  142. package/build/lib/commands/resources.d.ts.map +1 -1
  143. package/build/lib/commands/resources.js +7 -11
  144. package/build/lib/commands/resources.js.map +1 -1
  145. package/build/lib/commands/shell.d.ts +1 -1
  146. package/build/lib/commands/shell.d.ts.map +1 -1
  147. package/build/lib/commands/shell.js +9 -12
  148. package/build/lib/commands/shell.js.map +1 -1
  149. package/build/lib/commands/streamscreen.d.ts +1 -1
  150. package/build/lib/commands/streamscreen.d.ts.map +1 -1
  151. package/build/lib/commands/streamscreen.js +32 -37
  152. package/build/lib/commands/streamscreen.js.map +1 -1
  153. package/build/lib/commands/system-bars.d.ts +2 -2
  154. package/build/lib/commands/system-bars.d.ts.map +1 -1
  155. package/build/lib/commands/system-bars.js +10 -16
  156. package/build/lib/commands/system-bars.js.map +1 -1
  157. package/build/lib/commands/time.d.ts +1 -1
  158. package/build/lib/commands/time.d.ts.map +1 -1
  159. package/build/lib/commands/time.js +9 -17
  160. package/build/lib/commands/time.js.map +1 -1
  161. package/build/lib/commands/types.d.ts +15 -1
  162. package/build/lib/commands/types.d.ts.map +1 -1
  163. package/build/lib/commands/types.js +1 -2
  164. package/build/lib/constraints.js +2 -5
  165. package/build/lib/constraints.js.map +1 -1
  166. package/build/lib/doctor/checks.js +54 -65
  167. package/build/lib/doctor/checks.js.map +1 -1
  168. package/build/lib/doctor/utils.js +4 -7
  169. package/build/lib/doctor/utils.js.map +1 -1
  170. package/build/lib/driver.d.ts +39 -39
  171. package/build/lib/driver.d.ts.map +1 -1
  172. package/build/lib/driver.js +220 -223
  173. package/build/lib/driver.js.map +1 -1
  174. package/build/lib/execute-method-map.js +1 -4
  175. package/build/lib/execute-method-map.js.map +1 -1
  176. package/build/lib/index.d.ts +7 -7
  177. package/build/lib/index.d.ts.map +1 -1
  178. package/build/lib/index.js +11 -51
  179. package/build/lib/index.js.map +1 -1
  180. package/build/lib/logger.js +2 -5
  181. package/build/lib/logger.js.map +1 -1
  182. package/build/lib/method-map.js +1 -4
  183. package/build/lib/method-map.js.map +1 -1
  184. package/build/lib/utils.d.ts +9 -7
  185. package/build/lib/utils.d.ts.map +1 -1
  186. package/build/lib/utils.js +22 -28
  187. package/build/lib/utils.js.map +1 -1
  188. package/lib/commands/app-management.ts +5 -11
  189. package/lib/commands/appearance.ts +1 -1
  190. package/lib/commands/bidi/models.ts +3 -3
  191. package/lib/commands/bluetooth.ts +2 -2
  192. package/lib/commands/context/cache.ts +1 -1
  193. package/lib/commands/context/exports.ts +7 -7
  194. package/lib/commands/context/helpers.ts +4 -4
  195. package/lib/commands/device/common.ts +9 -10
  196. package/lib/commands/device/emulator-actions.ts +4 -4
  197. package/lib/commands/device/emulator-console.ts +2 -2
  198. package/lib/commands/device/utils.ts +3 -3
  199. package/lib/commands/deviceidle.ts +2 -2
  200. package/lib/commands/element.ts +3 -3
  201. package/lib/commands/execute.ts +2 -2
  202. package/lib/commands/file-actions.ts +2 -2
  203. package/lib/commands/find.ts +4 -4
  204. package/lib/commands/geolocation.ts +2 -2
  205. package/lib/commands/gestures.ts +3 -3
  206. package/lib/commands/image-injection.ts +2 -2
  207. package/lib/commands/ime.ts +3 -3
  208. package/lib/commands/intent.ts +3 -3
  209. package/lib/commands/keyboard.ts +3 -3
  210. package/lib/commands/legacy.ts +2 -2
  211. package/lib/commands/lock/exports.ts +3 -3
  212. package/lib/commands/lock/helpers.ts +2 -2
  213. package/lib/commands/log.ts +18 -11
  214. package/lib/commands/media-projection.ts +2 -2
  215. package/lib/commands/memory.ts +3 -3
  216. package/lib/commands/misc.ts +3 -3
  217. package/lib/commands/network.ts +3 -3
  218. package/lib/commands/nfc.ts +3 -3
  219. package/lib/commands/performance.ts +4 -4
  220. package/lib/commands/permissions.ts +3 -3
  221. package/lib/commands/recordscreen.ts +5 -5
  222. package/lib/commands/resources.ts +2 -2
  223. package/lib/commands/shell.ts +3 -3
  224. package/lib/commands/streamscreen.ts +6 -4
  225. package/lib/commands/system-bars.ts +6 -6
  226. package/lib/commands/time.ts +3 -3
  227. package/lib/commands/types.ts +15 -1
  228. package/lib/doctor/checks.ts +1 -1
  229. package/lib/driver.ts +44 -44
  230. package/lib/index.ts +7 -7
  231. package/lib/method-map.ts +1 -1
  232. package/lib/utils.ts +10 -8
  233. package/package.json +12 -3
@@ -1,7 +1,7 @@
1
- import {errors} from 'appium/driver';
1
+ import {errors} from 'appium/driver.js';
2
2
  import {util} from '@appium/support';
3
- import type {AndroidDriver} from '../driver';
4
- import type {IntentOpts} from './types';
3
+ import type {AndroidDriver} from '../driver.js';
4
+ import type {IntentOpts} from './types.js';
5
5
 
6
6
  const NO_VALUE_ARG_TYPE = 'sn';
7
7
  const SUPPORTED_EXTRA_TYPES = [
@@ -1,7 +1,7 @@
1
- import {errors} from 'appium/driver';
1
+ import {errors} from 'appium/driver.js';
2
2
  import {UNICODE_IME, EMPTY_IME} from 'io.appium.settings';
3
- import type {AndroidDriver} from '../driver';
4
- import type {SendKeysOpts} from './types';
3
+ import type {AndroidDriver} from '../driver.js';
4
+ import type {SendKeysOpts} from './types.js';
5
5
 
6
6
  /**
7
7
  * Hides the on-screen keyboard.
@@ -1,5 +1,5 @@
1
- import {errors} from 'appium/driver';
2
- import type {AndroidDriver} from '../driver';
1
+ import {errors} from 'appium/driver.js';
2
+ import type {AndroidDriver} from '../driver.js';
3
3
 
4
4
  const ISSUE_URL = 'https://github.com/appium/appium/issues/15807';
5
5
 
@@ -14,9 +14,9 @@ import {
14
14
  fingerprintUnlock,
15
15
  toCredentialType,
16
16
  verifyUnlock,
17
- } from './helpers';
18
- import type {AndroidDriver, AndroidDriverCaps} from '../../driver';
19
- import type {UnlockType} from '../types';
17
+ } from './helpers.js';
18
+ import type {AndroidDriver, AndroidDriverCaps} from '../../driver.js';
19
+ import type {UnlockType} from '../types.js';
20
20
 
21
21
  /**
22
22
  * Locks the device and optionally unlocks it after a specified number of seconds.
@@ -2,8 +2,8 @@ import {util} from '@appium/support';
2
2
  import {sleep, waitForCondition} from 'asyncbox';
3
3
  import type {ADB} from 'appium-adb';
4
4
  import type {Position, StringRecord} from '@appium/types';
5
- import type {AndroidDriver, AndroidDriverCaps} from '../../driver';
6
- import type {UnlockType, FastUnlockOptions} from '../types';
5
+ import type {AndroidDriver, AndroidDriverCaps} from '../../driver.js';
6
+ import type {UnlockType, FastUnlockOptions} from '../types.js';
7
7
 
8
8
  export const PIN_UNLOCK = 'pin';
9
9
  export const PIN_UNLOCK_KEY_EVENT = 'pinWithKeyEvent';
@@ -1,6 +1,6 @@
1
- import {DEFAULT_WS_PATHNAME_PREFIX, BaseDriver} from 'appium/driver';
1
+ import {DEFAULT_WS_PATHNAME_PREFIX, BaseDriver} from 'appium/driver.js';
2
2
  import os from 'node:os';
3
- import WebSocket from 'ws';
3
+ import {WebSocket, WebSocketServer} from 'ws';
4
4
  import type {AppiumServer, WSServer} from '@appium/types';
5
5
  import type {EventEmitter} from 'node:events';
6
6
  import type {ADB} from 'appium-adb';
@@ -10,11 +10,11 @@ import {
10
10
  toLogRecord,
11
11
  nativeLogEntryToSeleniumEntry,
12
12
  type LogEntry,
13
- } from '../utils';
14
- import {NATIVE_WIN} from './context/helpers';
15
- import {BIDI_EVENT_NAME} from './bidi/constants';
16
- import {makeLogEntryAddedEvent} from './bidi/models';
17
- import type {AndroidDriver} from '../driver';
13
+ } from '../utils.js';
14
+ import {NATIVE_WIN} from './context/helpers.js';
15
+ import {BIDI_EVENT_NAME} from './bidi/constants.js';
16
+ import {makeLogEntryAddedEvent} from './bidi/models.js';
17
+ import type {AndroidDriver} from '../driver.js';
18
18
  import {util} from '@appium/support';
19
19
 
20
20
  export const supportedLogTypes = {
@@ -62,9 +62,12 @@ export async function mobileStartLogsBroadcast(this: AndroidDriver): Promise<voi
62
62
  `${JSON.stringify(server.address())} to ${pathname}`,
63
63
  );
64
64
  // https://github.com/websockets/ws/blob/master/doc/ws.md
65
- const wss = new WebSocket.Server({
65
+ const wss = new WebSocketServer({
66
66
  noServer: true,
67
67
  });
68
+ // Tracks every currently connected listener socket so log lines get
69
+ // broadcast to all of them, not just the one that connected first.
70
+ const connectedSockets = new Set<WebSocket>();
68
71
  wss.on('connection', (ws, req) => {
69
72
  if (req) {
70
73
  const remoteIp = util.isEmpty(req.headers['x-forwarded-for'])
@@ -75,17 +78,21 @@ export async function mobileStartLogsBroadcast(this: AndroidDriver): Promise<voi
75
78
  this.log.debug('Established a new logcat listener web socket connection');
76
79
  }
77
80
 
81
+ connectedSockets.add(ws);
78
82
  if (!this._logcatWebsocketListener) {
79
83
  this._logcatWebsocketListener = (logRecord: LogEntry) => {
80
- if (ws?.readyState === WebSocket.OPEN) {
81
- ws.send(logRecord.message);
84
+ for (const socket of connectedSockets) {
85
+ if (socket.readyState === WebSocket.OPEN) {
86
+ socket.send(logRecord.message);
87
+ }
82
88
  }
83
89
  };
84
90
  }
85
91
  this.adb.setLogcatListener(this._logcatWebsocketListener);
86
92
 
87
93
  ws.on('close', (code, reason) => {
88
- if (this._logcatWebsocketListener) {
94
+ connectedSockets.delete(ws);
95
+ if (connectedSockets.size === 0 && this._logcatWebsocketListener) {
89
96
  try {
90
97
  this.adb.removeLogcatListener(this._logcatWebsocketListener);
91
98
  } catch {}
@@ -3,9 +3,9 @@ import type {NetOptions, HttpUploadOptions} from '@appium/support';
3
3
  import dayjs from 'dayjs';
4
4
  import path from 'node:path';
5
5
  import type {HTTPMethod, StringRecord} from '@appium/types';
6
- import type {AndroidDriver} from '../driver';
6
+ import type {AndroidDriver} from '../driver.js';
7
7
  import type {ADB} from 'appium-adb';
8
- import type {FormFields} from './types';
8
+ import type {FormFields} from './types.js';
9
9
 
10
10
  // https://github.com/appium/io.appium.settings#internal-audio--video-recording
11
11
  const DEFAULT_EXT = '.mp4';
@@ -1,6 +1,6 @@
1
- import {errors} from 'appium/driver';
2
- import type {AndroidDriver} from '../driver';
3
- import type {TrimMemoryLevel} from './types';
1
+ import {errors} from 'appium/driver.js';
2
+ import type {AndroidDriver} from '../driver.js';
3
+ import type {TrimMemoryLevel} from './types.js';
4
4
 
5
5
  /**
6
6
  * Simulates the onTrimMemory() event for the given package.
@@ -1,7 +1,7 @@
1
- import {errors} from 'appium/driver';
1
+ import {errors} from 'appium/driver.js';
2
2
  import type {Size, Rect, StringRecord} from '@appium/types';
3
- import type {AndroidDriver} from '../driver';
4
- import type {SmsListResult, ListSmsOpts} from './types';
3
+ import type {AndroidDriver} from '../driver.js';
4
+ import type {SmsListResult, ListSmsOpts} from './types.js';
5
5
 
6
6
  /**
7
7
  * Gets the window size.
@@ -1,7 +1,7 @@
1
- import {errors} from 'appium/driver';
1
+ import {errors} from 'appium/driver.js';
2
2
  import {util} from '@appium/support';
3
- import type {AndroidDriver} from '../driver';
4
- import type {ServiceType, GetConnectivityResult} from './types';
3
+ import type {AndroidDriver} from '../driver.js';
4
+ import type {ServiceType, GetConnectivityResult} from './types.js';
5
5
 
6
6
  const AIRPLANE_MODE_MASK = 0b001;
7
7
  const WIFI_MASK = 0b010;
@@ -1,6 +1,6 @@
1
- import {errors} from 'appium/driver';
2
- import type {AndroidDriver} from '../driver';
3
- import type {NfcAction} from './types';
1
+ import {errors} from 'appium/driver.js';
2
+ import type {AndroidDriver} from '../driver.js';
3
+ import type {NfcAction} from './types.js';
4
4
 
5
5
  const SUPPORTED_ACTIONS = {
6
6
  ENABLE: 'enable',
@@ -1,7 +1,7 @@
1
1
  import {retryInterval} from 'asyncbox';
2
2
  import type {ExecError} from 'teen_process';
3
- import type {AndroidDriver} from '../driver';
4
- import type {PerformanceDataType} from './types';
3
+ import type {AndroidDriver} from '../driver.js';
4
+ import type {PerformanceDataType} from './types.js';
5
5
  import {util} from '@appium/support';
6
6
 
7
7
  export const NETWORK_KEYS = [
@@ -187,7 +187,7 @@ export async function getMemoryInfo(
187
187
  }
188
188
  }
189
189
  if (valDict.totalPrivateDirty && valDict.totalPrivateDirty !== 'nodex') {
190
- const headers = structuredClone(MEMORY_KEYS);
190
+ const headers = [...MEMORY_KEYS];
191
191
  const values = headers.map((header) => valDict[header]);
192
192
  return [headers, values];
193
193
  }
@@ -458,7 +458,7 @@ export async function getBatteryInfo(this: AndroidDriver, retries: number = 2):
458
458
  const power = parseInt((data.split(':')[1] || '').trim(), 10);
459
459
 
460
460
  if (!Number.isNaN(power)) {
461
- return [structuredClone(BATTERY_KEYS), [power.toString()]];
461
+ return [[...BATTERY_KEYS], [power.toString()]];
462
462
  } else {
463
463
  throw new Error(`Unable to parse battery data: '${data}'`);
464
464
  }
@@ -1,6 +1,6 @@
1
- import {errors} from 'appium/driver';
2
- import {ADB_SHELL_FEATURE} from '../utils';
3
- import type {AndroidDriver} from '../driver';
1
+ import {errors} from 'appium/driver.js';
2
+ import {ADB_SHELL_FEATURE} from '../utils.js';
3
+ import type {AndroidDriver} from '../driver.js';
4
4
  import {util} from '@appium/support';
5
5
 
6
6
  const ALL_PERMISSIONS_MAGIC = 'all';
@@ -3,13 +3,13 @@ import type {NetOptions, HttpUploadOptions} from '@appium/support';
3
3
  import {waitForCondition} from 'asyncbox';
4
4
  import path from 'node:path';
5
5
  import {exec} from 'teen_process';
6
- import type {AndroidDriver} from '../driver';
6
+ import type {AndroidDriver} from '../driver.js';
7
7
  import type {ADB} from 'appium-adb';
8
8
  import type {
9
9
  StartScreenRecordingOpts,
10
10
  StopScreenRecordingOpts,
11
11
  ScreenRecordingProperties,
12
- } from './types';
12
+ } from './types.js';
13
13
 
14
14
  const RETRY_PAUSE = 300;
15
15
  const RETRY_TIMEOUT = 5000;
@@ -65,7 +65,7 @@ export async function startRecordingScreen(
65
65
  if (this._screenRecordingProperties) {
66
66
  // XXX: this doesn't need to be done in serial, does it?
67
67
  const props = this._screenRecordingProperties;
68
- for (const record of props.records || []) {
68
+ for (const record of props?.records || []) {
69
69
  await this.adb.rimraf(record);
70
70
  }
71
71
  this._screenRecordingProperties = undefined;
@@ -136,7 +136,7 @@ export async function stopRecordingScreen(
136
136
  return '';
137
137
  }
138
138
 
139
- if (props.recordingProcess?.isRunning) {
139
+ if (props?.recordingProcess?.isRunning) {
140
140
  try {
141
141
  await props.recordingProcess.stop('SIGINT', PROCESS_SHUTDOWN_TIMEOUT);
142
142
  } catch {
@@ -157,7 +157,7 @@ export async function stopRecordingScreen(
157
157
  const tmpRoot = await tempDir.openDir();
158
158
  try {
159
159
  const localRecords: string[] = [];
160
- for (const pathOnDevice of props.records) {
160
+ for (const pathOnDevice of props?.records || []) {
161
161
  const relativePath = path.resolve(tmpRoot, path.posix.basename(pathOnDevice));
162
162
  localRecords.push(relativePath);
163
163
  await this.adb.pull(pathOnDevice, relativePath, {timeout: ADB_PULL_TIMEOUT});
@@ -1,7 +1,7 @@
1
1
  import {fs, tempDir, util} from '@appium/support';
2
2
  import type {StringRecord} from '@appium/types';
3
- import type {AndroidDriver, AndroidDriverOpts} from '../driver';
4
- import type {Locale} from './types';
3
+ import type {AndroidDriver, AndroidDriverOpts} from '../driver.js';
4
+ import type {Locale} from './types.js';
5
5
 
6
6
  /**
7
7
  * Gets the localized strings from the application.
@@ -1,9 +1,9 @@
1
1
  import {util} from '@appium/support';
2
- import {errors} from 'appium/driver';
2
+ import {errors} from 'appium/driver.js';
3
3
  import {exec} from 'teen_process';
4
4
  import type {ExecError} from 'teen_process';
5
- import {ADB_SHELL_FEATURE} from '../utils';
6
- import type {AndroidDriver} from '../driver';
5
+ import {ADB_SHELL_FEATURE} from '../utils.js';
6
+ import type {AndroidDriver} from '../driver.js';
7
7
 
8
8
  /**
9
9
  * Executes a shell command on the device via ADB.
@@ -6,10 +6,10 @@ import net from 'node:net';
6
6
  import url from 'node:url';
7
7
  import {checkPortStatus} from 'portscanner';
8
8
  import {SubProcess, exec} from 'teen_process';
9
- import type {AndroidDriver} from '../driver';
9
+ import type {AndroidDriver} from '../driver.js';
10
10
  import type {ADB} from 'appium-adb';
11
11
  import type {AppiumLogger} from '@appium/types';
12
- import type {DeviceInfo, InitGStreamerPipelineOpts} from './types';
12
+ import type {DeviceInfo, InitGStreamerPipelineOpts} from './types.js';
13
13
 
14
14
  const RECORDING_INTERVAL_SEC = 5;
15
15
  const STREAMING_STARTUP_TIMEOUT_MS = 5000;
@@ -225,11 +225,13 @@ export async function mobileStartScreenStreaming(
225
225
  }
226
226
  }
227
227
 
228
+ // Both are guaranteed to be set at this point, since mjpegServerReadyPromise
229
+ // only resolves after the MJPEG server has started listening.
228
230
  this._screenStreamingProps = {
229
231
  deviceStreamingProc,
230
232
  gstreamerPipeline,
231
- mjpegSocket,
232
- mjpegServer,
233
+ mjpegSocket: mjpegSocket as net.Socket,
234
+ mjpegServer: mjpegServer as http.Server,
233
235
  };
234
236
  }
235
237
 
@@ -1,7 +1,7 @@
1
- import {errors} from 'appium/driver';
1
+ import {errors} from 'appium/driver.js';
2
2
  import type {StringRecord} from '@appium/types';
3
- import type {AndroidDriver} from '../driver';
4
- import type {StatusBarCommand, WindowProperties} from './types';
3
+ import type {AndroidDriver} from '../driver.js';
4
+ import type {StatusBarCommand, WindowProperties} from './types.js';
5
5
  import {util} from '@appium/support';
6
6
 
7
7
  const WINDOW_TITLE_PATTERN = /^\s+Window\s#\d+\sWindow\{[0-9a-f]+\s\w+\s([\w-]+)\}:$/;
@@ -142,14 +142,14 @@ export function parseWindowProperties(
142
142
  export function parseWindows(this: AndroidDriver, lines: string): SystemBarsResult {
143
143
  const windows: StringRecord<string[]> = {};
144
144
  let currentWindowName: string | null = null;
145
- for (const line of lines.split('\n').map((line) => String(line)?.trimEnd())) {
146
- const match = WINDOW_TITLE_PATTERN.exec(line as any);
145
+ for (const line of lines.split('\n').map((line) => line.trimEnd())) {
146
+ const match = WINDOW_TITLE_PATTERN.exec(line);
147
147
  if (match) {
148
148
  currentWindowName = match[1];
149
149
  windows[currentWindowName] = [];
150
150
  continue;
151
151
  }
152
- if (String(line)?.trim()?.length === 0) {
152
+ if (line.trim().length === 0) {
153
153
  currentWindowName = null;
154
154
  continue;
155
155
  }
@@ -1,7 +1,7 @@
1
1
  import dayjs from 'dayjs';
2
- import utc from 'dayjs/plugin/utc';
3
- import customParseFormat from 'dayjs/plugin/customParseFormat';
4
- import type {AndroidDriver} from '../driver';
2
+ import utc from 'dayjs/plugin/utc.js';
3
+ import customParseFormat from 'dayjs/plugin/customParseFormat.js';
4
+ import type {AndroidDriver} from '../driver.js';
5
5
 
6
6
  dayjs.extend(utc);
7
7
  dayjs.extend(customParseFormat);
@@ -1,7 +1,10 @@
1
1
  import type {HTTPMethod, StringRecord} from '@appium/types';
2
- import type {AndroidDriverCaps} from '../driver';
2
+ import type {AndroidDriverCaps} from '../driver.js';
3
3
  import type {SubProcess} from 'teen_process';
4
4
  import type {timing} from '@appium/support';
5
+ import type {ChildProcess} from 'node:child_process';
6
+ import type {Socket} from 'node:net';
7
+ import type {Server} from 'node:http';
5
8
 
6
9
  /**
7
10
  * @privateRemarks probably better defined in `appium-adb`
@@ -451,6 +454,17 @@ export interface InitGStreamerPipelineOpts {
451
454
  considerRotation?: boolean;
452
455
  logPipelineDetails?: boolean;
453
456
  }
457
+
458
+ /**
459
+ * The screen streaming process handles cached on the driver instance
460
+ * while a `mobile: startScreenStreaming` session is active.
461
+ */
462
+ export interface ScreenStreamingProps {
463
+ deviceStreamingProc: ChildProcess;
464
+ gstreamerPipeline: SubProcess;
465
+ mjpegSocket: Socket;
466
+ mjpegServer: Server;
467
+ }
454
468
  export interface WindowProperties {
455
469
  /**
456
470
  * Whether the window is visible
@@ -1,4 +1,4 @@
1
- import {resolveExecutablePath} from './utils';
1
+ import {resolveExecutablePath} from './utils.js';
2
2
  import {system, fs, doctor, console} from '@appium/support';
3
3
  import path from 'node:path';
4
4
  import {getAndroidBinaryPath, getSdkRootFromEnv} from 'appium-adb';
package/lib/driver.ts CHANGED
@@ -8,14 +8,14 @@ import type {
8
8
  W3CDriverCaps,
9
9
  } from '@appium/types';
10
10
  import type {ADB, LogcatListener} from 'appium-adb';
11
- import type {default as AppiumChromedriver} from 'appium-chromedriver';
12
- import {BaseDriver} from 'appium/driver';
13
- import {ANDROID_DRIVER_CONSTRAINTS} from './constraints';
14
- import type {AndroidDriverConstraints} from './constraints';
15
- import {newMethodMap} from './method-map';
11
+ import type {Chromedriver as AppiumChromedriver} from 'appium-chromedriver';
12
+ import {BaseDriver} from 'appium/driver.js';
13
+ import {ANDROID_DRIVER_CONSTRAINTS} from './constraints.js';
14
+ import type {AndroidDriverConstraints} from './constraints.js';
15
+ import {newMethodMap} from './method-map.js';
16
16
  import {SettingsApp} from 'io.appium.settings';
17
- import {parseArray, removeAllSessionWebSocketHandlers} from './utils';
18
- import {CHROME_BROWSER_PACKAGE_ACTIVITY} from './commands/context/helpers';
17
+ import {parseArray, removeAllSessionWebSocketHandlers} from './utils.js';
18
+ import {CHROME_BROWSER_PACKAGE_ACTIVITY} from './commands/context/helpers.js';
19
19
  import {
20
20
  getContexts,
21
21
  setContext,
@@ -37,13 +37,13 @@ import {
37
37
  getWindowHandles,
38
38
  setWindow,
39
39
  notifyBiDiContextChange,
40
- } from './commands/context/exports';
40
+ } from './commands/context/exports.js';
41
41
  import {
42
42
  getDeviceInfoFromCaps,
43
43
  createADB,
44
44
  getLaunchInfo,
45
45
  initDevice,
46
- } from './commands/device/common';
46
+ } from './commands/device/common.js';
47
47
  import {
48
48
  fingerprint,
49
49
  mobileFingerprint,
@@ -62,8 +62,8 @@ import {
62
62
  networkSpeed,
63
63
  mobileNetworkSpeed,
64
64
  sensorSet,
65
- } from './commands/device/emulator-actions';
66
- import {mobileExecEmuConsoleCommand} from './commands/device/emulator-console';
65
+ } from './commands/device/emulator-actions.js';
66
+ import {mobileExecEmuConsoleCommand} from './commands/device/emulator-console.js';
67
67
  import {
68
68
  getThirdPartyPackages,
69
69
  uninstallOtherPackages,
@@ -86,10 +86,10 @@ import {
86
86
  activateApp,
87
87
  queryAppState,
88
88
  isAppInstalled,
89
- } from './commands/app-management';
90
- import {mobileGetUiMode, mobileSetUiMode} from './commands/appearance';
91
- import {mobileDeviceidle} from './commands/deviceidle';
92
- import {mobileBluetooth} from './commands/bluetooth';
89
+ } from './commands/app-management.js';
90
+ import {mobileGetUiMode, mobileSetUiMode} from './commands/appearance.js';
91
+ import {mobileDeviceidle} from './commands/deviceidle.js';
92
+ import {mobileBluetooth} from './commands/bluetooth.js';
93
93
  import {
94
94
  getAttribute,
95
95
  getName,
@@ -106,10 +106,10 @@ import {
106
106
  getText,
107
107
  getLocation,
108
108
  getSize,
109
- } from './commands/element';
110
- import {execute} from './commands/execute';
111
- import {pullFile, pullFolder, pushFile, mobileDeleteFile} from './commands/file-actions';
112
- import {findElOrEls, doFindElementOrEls} from './commands/find';
109
+ } from './commands/element.js';
110
+ import {execute} from './commands/execute.js';
111
+ import {pullFile, pullFolder, pushFile, mobileDeleteFile} from './commands/file-actions.js';
112
+ import {findElOrEls, doFindElementOrEls} from './commands/find.js';
113
113
  import {
114
114
  setGeoLocation,
115
115
  getGeoLocation,
@@ -119,8 +119,8 @@ import {
119
119
  mobileGetGeolocation,
120
120
  mobileSetGeolocation,
121
121
  mobileResetGeolocation,
122
- } from './commands/geolocation';
123
- import {performActions} from './commands/gestures';
122
+ } from './commands/geolocation.js';
123
+ import {performActions} from './commands/gestures.js';
124
124
  import {
125
125
  isIMEActivated,
126
126
  availableIMEEngines,
@@ -128,14 +128,14 @@ import {
128
128
  activateIMEEngine,
129
129
  deactivateIMEEngine,
130
130
  setStylusHandwriting,
131
- } from './commands/ime';
131
+ } from './commands/ime.js';
132
132
  import {
133
133
  startActivity,
134
134
  mobileStartActivity,
135
135
  mobileBroadcast,
136
136
  mobileStartService,
137
137
  mobileStopService,
138
- } from './commands/intent';
138
+ } from './commands/intent.js';
139
139
  import {
140
140
  hideKeyboard,
141
141
  isKeyboardShown,
@@ -144,8 +144,8 @@ import {
144
144
  pressKeyCode,
145
145
  longPressKeyCode,
146
146
  mobilePerformEditorAction,
147
- } from './commands/keyboard';
148
- import {lock, unlock, mobileUnlock, isLocked} from './commands/lock/exports';
147
+ } from './commands/keyboard.js';
148
+ import {lock, unlock, mobileUnlock, isLocked} from './commands/lock/exports.js';
149
149
  import {
150
150
  supportedLogTypes,
151
151
  mobileStartLogsBroadcast,
@@ -153,15 +153,15 @@ import {
153
153
  getLogTypes,
154
154
  getLog,
155
155
  assignBiDiLogListener,
156
- } from './commands/log';
156
+ } from './commands/log.js';
157
157
  import {
158
158
  mobileIsMediaProjectionRecordingRunning,
159
159
  mobileStartMediaProjectionRecording,
160
160
  mobileStopMediaProjectionRecording,
161
- } from './commands/media-projection';
162
- import {mobileSendTrimMemory} from './commands/memory';
163
- import {mobileNfc} from './commands/nfc';
164
- import {mobileInjectEmulatorCameraImage} from './commands/image-injection';
161
+ } from './commands/media-projection.js';
162
+ import {mobileSendTrimMemory} from './commands/memory.js';
163
+ import {mobileNfc} from './commands/nfc.js';
164
+ import {mobileInjectEmulatorCameraImage} from './commands/image-injection.js';
165
165
  import {
166
166
  getWindowRect,
167
167
  getWindowSize,
@@ -170,7 +170,7 @@ import {
170
170
  mobileListSms,
171
171
  openNotifications,
172
172
  setUrl,
173
- } from './commands/misc';
173
+ } from './commands/misc.js';
174
174
  import {
175
175
  getNetworkConnection,
176
176
  isWifiOn,
@@ -182,23 +182,23 @@ import {
182
182
  toggleData,
183
183
  toggleFlightMode,
184
184
  toggleWiFi,
185
- } from './commands/network';
185
+ } from './commands/network.js';
186
186
  import {
187
187
  getPerformanceData,
188
188
  getPerformanceDataTypes,
189
189
  mobileGetPerformanceData,
190
- } from './commands/performance';
191
- import {reset, closeApp, launchApp} from './commands/legacy';
192
- import {mobileChangePermissions, mobileGetPermissions} from './commands/permissions';
193
- import {startRecordingScreen, stopRecordingScreen} from './commands/recordscreen';
194
- import {getStrings, ensureDeviceLocale} from './commands/resources';
195
- import {mobileShell} from './commands/shell';
196
- import {mobileStartScreenStreaming, mobileStopScreenStreaming} from './commands/streamscreen';
197
- import {getSystemBars, mobilePerformStatusBarCommand} from './commands/system-bars';
198
- import {getDeviceTime, mobileGetDeviceTime} from './commands/time';
199
- import {executeMethodMap} from './execute-method-map';
190
+ } from './commands/performance.js';
191
+ import {reset, closeApp, launchApp} from './commands/legacy.js';
192
+ import {mobileChangePermissions, mobileGetPermissions} from './commands/permissions.js';
193
+ import {startRecordingScreen, stopRecordingScreen} from './commands/recordscreen.js';
194
+ import {getStrings, ensureDeviceLocale} from './commands/resources.js';
195
+ import {mobileShell} from './commands/shell.js';
196
+ import {mobileStartScreenStreaming, mobileStopScreenStreaming} from './commands/streamscreen.js';
197
+ import {getSystemBars, mobilePerformStatusBarCommand} from './commands/system-bars.js';
198
+ import {getDeviceTime, mobileGetDeviceTime} from './commands/time.js';
199
+ import {executeMethodMap} from './execute-method-map.js';
200
200
  import {LRUCache} from 'lru-cache';
201
- import type {ScreenRecordingProperties} from './commands/types';
201
+ import type {ScreenRecordingProperties, ScreenStreamingProps} from './commands/types.js';
202
202
 
203
203
  export type AndroidDriverCaps = DriverCaps<AndroidDriverConstraints>;
204
204
  export type W3CAndroidDriverCaps = W3CDriverCaps<AndroidDriverConstraints>;
@@ -228,7 +228,7 @@ class AndroidDriver
228
228
  defaultIME?: string;
229
229
  _wasWindowAnimationDisabled?: boolean;
230
230
  _cachedActivityArgs: StringRecord;
231
- _screenStreamingProps?: StringRecord;
231
+ _screenStreamingProps?: ScreenStreamingProps;
232
232
  _screenRecordingProperties?: ScreenRecordingProperties;
233
233
  _logcatWebsocketListener?: LogcatListener;
234
234
  _bidiServerLogListener?: (...args: any[]) => void;
package/lib/index.ts CHANGED
@@ -1,14 +1,14 @@
1
- import {AndroidDriver} from './driver';
2
- import {getChromePkg} from './commands/context/helpers';
3
- import {parseArray, requireArgs} from './utils';
1
+ import {AndroidDriver} from './driver.js';
2
+ import {getChromePkg} from './commands/context/helpers.js';
3
+ import {parseArray, requireArgs} from './utils.js';
4
4
  export const utils = {
5
5
  getChromePkg,
6
6
  parseArray,
7
7
  requireArgs,
8
8
  } as const;
9
- export type * from './commands/types';
10
- export {ANDROID_DRIVER_CONSTRAINTS as commonCapConstraints} from './constraints';
11
- export * from './driver';
12
- export * as doctor from './doctor/checks';
9
+ export type * from './commands/types.js';
10
+ export {ANDROID_DRIVER_CONSTRAINTS as commonCapConstraints} from './constraints.js';
11
+ export * from './driver.js';
12
+ export * as doctor from './doctor/checks.js';
13
13
 
14
14
  export default AndroidDriver;
package/lib/method-map.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type {MethodMap} from '@appium/types';
2
- import type {AndroidDriver} from './driver';
2
+ import type {AndroidDriver} from './driver.js';
3
3
 
4
4
  export const newMethodMap = {
5
5
  '/session/:sessionId/timeouts/implicit_wait': {