@limrun/appium-xcuitest-driver 10.4.3-lim.1

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 (444) hide show
  1. package/CHANGELOG.md +2600 -0
  2. package/LICENSE +201 -0
  3. package/README.md +55 -0
  4. package/build/index.d.ts +5 -0
  5. package/build/index.js +41 -0
  6. package/build/lib/app-infos-cache.d.ts +62 -0
  7. package/build/lib/app-infos-cache.d.ts.map +1 -0
  8. package/build/lib/app-infos-cache.js +180 -0
  9. package/build/lib/app-infos-cache.js.map +1 -0
  10. package/build/lib/app-utils.d.ts +89 -0
  11. package/build/lib/app-utils.d.ts.map +1 -0
  12. package/build/lib/app-utils.js +657 -0
  13. package/build/lib/app-utils.js.map +1 -0
  14. package/build/lib/commands/active-app-info.d.ts +9 -0
  15. package/build/lib/commands/active-app-info.d.ts.map +1 -0
  16. package/build/lib/commands/active-app-info.js +14 -0
  17. package/build/lib/commands/active-app-info.js.map +1 -0
  18. package/build/lib/commands/advanced-battery-types.d.ts +444 -0
  19. package/build/lib/commands/advanced-battery-types.d.ts.map +1 -0
  20. package/build/lib/commands/advanced-battery-types.js +8 -0
  21. package/build/lib/commands/advanced-battery-types.js.map +1 -0
  22. package/build/lib/commands/alert.d.ts +45 -0
  23. package/build/lib/commands/alert.d.ts.map +1 -0
  24. package/build/lib/commands/alert.js +87 -0
  25. package/build/lib/commands/alert.js.map +1 -0
  26. package/build/lib/commands/app-management.d.ts +153 -0
  27. package/build/lib/commands/app-management.d.ts.map +1 -0
  28. package/build/lib/commands/app-management.js +323 -0
  29. package/build/lib/commands/app-management.js.map +1 -0
  30. package/build/lib/commands/app-strings.d.ts +16 -0
  31. package/build/lib/commands/app-strings.d.ts.map +1 -0
  32. package/build/lib/commands/app-strings.js +30 -0
  33. package/build/lib/commands/app-strings.js.map +1 -0
  34. package/build/lib/commands/appearance.d.ts +22 -0
  35. package/build/lib/commands/appearance.d.ts.map +1 -0
  36. package/build/lib/commands/appearance.js +74 -0
  37. package/build/lib/commands/appearance.js.map +1 -0
  38. package/build/lib/commands/audit.d.ts +43 -0
  39. package/build/lib/commands/audit.d.ts.map +1 -0
  40. package/build/lib/commands/audit.js +31 -0
  41. package/build/lib/commands/audit.js.map +1 -0
  42. package/build/lib/commands/battery.d.ts +13 -0
  43. package/build/lib/commands/battery.d.ts.map +1 -0
  44. package/build/lib/commands/battery.js +49 -0
  45. package/build/lib/commands/battery.js.map +1 -0
  46. package/build/lib/commands/bidi/constants.d.ts +6 -0
  47. package/build/lib/commands/bidi/constants.d.ts.map +1 -0
  48. package/build/lib/commands/bidi/constants.js +10 -0
  49. package/build/lib/commands/bidi/constants.js.map +1 -0
  50. package/build/lib/commands/bidi/models.d.ts +9 -0
  51. package/build/lib/commands/bidi/models.d.ts.map +1 -0
  52. package/build/lib/commands/bidi/models.js +54 -0
  53. package/build/lib/commands/bidi/models.js.map +1 -0
  54. package/build/lib/commands/bidi/types.d.ts +26 -0
  55. package/build/lib/commands/bidi/types.d.ts.map +1 -0
  56. package/build/lib/commands/bidi/types.js +4 -0
  57. package/build/lib/commands/bidi/types.js.map +1 -0
  58. package/build/lib/commands/biometric.d.ts +32 -0
  59. package/build/lib/commands/biometric.d.ts.map +1 -0
  60. package/build/lib/commands/biometric.js +54 -0
  61. package/build/lib/commands/biometric.js.map +1 -0
  62. package/build/lib/commands/certificate.d.ts +50 -0
  63. package/build/lib/commands/certificate.d.ts.map +1 -0
  64. package/build/lib/commands/certificate.js +454 -0
  65. package/build/lib/commands/certificate.js.map +1 -0
  66. package/build/lib/commands/clipboard.d.ts +21 -0
  67. package/build/lib/commands/clipboard.d.ts.map +1 -0
  68. package/build/lib/commands/clipboard.js +36 -0
  69. package/build/lib/commands/clipboard.js.map +1 -0
  70. package/build/lib/commands/condition.d.ts +102 -0
  71. package/build/lib/commands/condition.d.ts.map +1 -0
  72. package/build/lib/commands/condition.js +146 -0
  73. package/build/lib/commands/condition.js.map +1 -0
  74. package/build/lib/commands/content-size.d.ts +30 -0
  75. package/build/lib/commands/content-size.d.ts.map +1 -0
  76. package/build/lib/commands/content-size.js +67 -0
  77. package/build/lib/commands/content-size.js.map +1 -0
  78. package/build/lib/commands/context.d.ts +191 -0
  79. package/build/lib/commands/context.d.ts.map +1 -0
  80. package/build/lib/commands/context.js +625 -0
  81. package/build/lib/commands/context.js.map +1 -0
  82. package/build/lib/commands/deviceInfo.d.ts +12 -0
  83. package/build/lib/commands/deviceInfo.d.ts.map +1 -0
  84. package/build/lib/commands/deviceInfo.js +25 -0
  85. package/build/lib/commands/deviceInfo.js.map +1 -0
  86. package/build/lib/commands/element.d.ts +108 -0
  87. package/build/lib/commands/element.d.ts.map +1 -0
  88. package/build/lib/commands/element.js +395 -0
  89. package/build/lib/commands/element.js.map +1 -0
  90. package/build/lib/commands/enum.d.ts +105 -0
  91. package/build/lib/commands/enum.d.ts.map +1 -0
  92. package/build/lib/commands/enum.js +113 -0
  93. package/build/lib/commands/enum.js.map +1 -0
  94. package/build/lib/commands/execute.d.ts +33 -0
  95. package/build/lib/commands/execute.d.ts.map +1 -0
  96. package/build/lib/commands/execute.js +142 -0
  97. package/build/lib/commands/execute.js.map +1 -0
  98. package/build/lib/commands/file-movement.d.ts +90 -0
  99. package/build/lib/commands/file-movement.d.ts.map +1 -0
  100. package/build/lib/commands/file-movement.js +477 -0
  101. package/build/lib/commands/file-movement.js.map +1 -0
  102. package/build/lib/commands/find.d.ts +21 -0
  103. package/build/lib/commands/find.d.ts.map +1 -0
  104. package/build/lib/commands/find.js +199 -0
  105. package/build/lib/commands/find.js.map +1 -0
  106. package/build/lib/commands/general.d.ts +137 -0
  107. package/build/lib/commands/general.d.ts.map +1 -0
  108. package/build/lib/commands/general.js +270 -0
  109. package/build/lib/commands/general.js.map +1 -0
  110. package/build/lib/commands/geolocation.d.ts +57 -0
  111. package/build/lib/commands/geolocation.d.ts.map +1 -0
  112. package/build/lib/commands/geolocation.js +58 -0
  113. package/build/lib/commands/geolocation.js.map +1 -0
  114. package/build/lib/commands/gesture.d.ts +283 -0
  115. package/build/lib/commands/gesture.d.ts.map +1 -0
  116. package/build/lib/commands/gesture.js +565 -0
  117. package/build/lib/commands/gesture.js.map +1 -0
  118. package/build/lib/commands/hid-event.d.ts +2773 -0
  119. package/build/lib/commands/hid-event.d.ts.map +1 -0
  120. package/build/lib/commands/hid-event.js +1633 -0
  121. package/build/lib/commands/hid-event.js.map +1 -0
  122. package/build/lib/commands/increase-contrast.d.ts +24 -0
  123. package/build/lib/commands/increase-contrast.d.ts.map +1 -0
  124. package/build/lib/commands/increase-contrast.js +49 -0
  125. package/build/lib/commands/increase-contrast.js.map +1 -0
  126. package/build/lib/commands/iohid.d.ts +1372 -0
  127. package/build/lib/commands/iohid.d.ts.map +1 -0
  128. package/build/lib/commands/iohid.js +63 -0
  129. package/build/lib/commands/iohid.js.map +1 -0
  130. package/build/lib/commands/keyboard.d.ts +32 -0
  131. package/build/lib/commands/keyboard.d.ts.map +1 -0
  132. package/build/lib/commands/keyboard.js +67 -0
  133. package/build/lib/commands/keyboard.js.map +1 -0
  134. package/build/lib/commands/keychains.d.ts +10 -0
  135. package/build/lib/commands/keychains.d.ts.map +1 -0
  136. package/build/lib/commands/keychains.js +22 -0
  137. package/build/lib/commands/keychains.js.map +1 -0
  138. package/build/lib/commands/localization.d.ts +17 -0
  139. package/build/lib/commands/localization.d.ts.map +1 -0
  140. package/build/lib/commands/localization.js +34 -0
  141. package/build/lib/commands/localization.js.map +1 -0
  142. package/build/lib/commands/location.d.ts +40 -0
  143. package/build/lib/commands/location.d.ts.map +1 -0
  144. package/build/lib/commands/location.js +121 -0
  145. package/build/lib/commands/location.js.map +1 -0
  146. package/build/lib/commands/lock.d.ts +23 -0
  147. package/build/lib/commands/lock.d.ts.map +1 -0
  148. package/build/lib/commands/lock.js +49 -0
  149. package/build/lib/commands/lock.js.map +1 -0
  150. package/build/lib/commands/log.d.ts +68 -0
  151. package/build/lib/commands/log.d.ts.map +1 -0
  152. package/build/lib/commands/log.js +287 -0
  153. package/build/lib/commands/log.js.map +1 -0
  154. package/build/lib/commands/memory.d.ts +11 -0
  155. package/build/lib/commands/memory.d.ts.map +1 -0
  156. package/build/lib/commands/memory.js +49 -0
  157. package/build/lib/commands/memory.js.map +1 -0
  158. package/build/lib/commands/navigation.d.ts +44 -0
  159. package/build/lib/commands/navigation.d.ts.map +1 -0
  160. package/build/lib/commands/navigation.js +121 -0
  161. package/build/lib/commands/navigation.js.map +1 -0
  162. package/build/lib/commands/notifications.d.ts +28 -0
  163. package/build/lib/commands/notifications.d.ts.map +1 -0
  164. package/build/lib/commands/notifications.js +64 -0
  165. package/build/lib/commands/notifications.js.map +1 -0
  166. package/build/lib/commands/pasteboard.d.ts +23 -0
  167. package/build/lib/commands/pasteboard.d.ts.map +1 -0
  168. package/build/lib/commands/pasteboard.js +43 -0
  169. package/build/lib/commands/pasteboard.js.map +1 -0
  170. package/build/lib/commands/pcap.d.ts +54 -0
  171. package/build/lib/commands/pcap.d.ts.map +1 -0
  172. package/build/lib/commands/pcap.js +149 -0
  173. package/build/lib/commands/pcap.js.map +1 -0
  174. package/build/lib/commands/performance.d.ts +85 -0
  175. package/build/lib/commands/performance.d.ts.map +1 -0
  176. package/build/lib/commands/performance.js +331 -0
  177. package/build/lib/commands/performance.js.map +1 -0
  178. package/build/lib/commands/permissions.d.ts +36 -0
  179. package/build/lib/commands/permissions.d.ts.map +1 -0
  180. package/build/lib/commands/permissions.js +80 -0
  181. package/build/lib/commands/permissions.js.map +1 -0
  182. package/build/lib/commands/proxy-helper.d.ts +15 -0
  183. package/build/lib/commands/proxy-helper.d.ts.map +1 -0
  184. package/build/lib/commands/proxy-helper.js +117 -0
  185. package/build/lib/commands/proxy-helper.js.map +1 -0
  186. package/build/lib/commands/record-audio.d.ts +69 -0
  187. package/build/lib/commands/record-audio.d.ts.map +1 -0
  188. package/build/lib/commands/record-audio.js +228 -0
  189. package/build/lib/commands/record-audio.js.map +1 -0
  190. package/build/lib/commands/recordscreen.d.ts +89 -0
  191. package/build/lib/commands/recordscreen.d.ts.map +1 -0
  192. package/build/lib/commands/recordscreen.js +326 -0
  193. package/build/lib/commands/recordscreen.js.map +1 -0
  194. package/build/lib/commands/screenshots.d.ts +16 -0
  195. package/build/lib/commands/screenshots.d.ts.map +1 -0
  196. package/build/lib/commands/screenshots.js +129 -0
  197. package/build/lib/commands/screenshots.js.map +1 -0
  198. package/build/lib/commands/simctl.d.ts +27 -0
  199. package/build/lib/commands/simctl.d.ts.map +1 -0
  200. package/build/lib/commands/simctl.js +65 -0
  201. package/build/lib/commands/simctl.js.map +1 -0
  202. package/build/lib/commands/source.d.ts +16 -0
  203. package/build/lib/commands/source.d.ts.map +1 -0
  204. package/build/lib/commands/source.js +128 -0
  205. package/build/lib/commands/source.js.map +1 -0
  206. package/build/lib/commands/timeouts.d.ts +53 -0
  207. package/build/lib/commands/timeouts.d.ts.map +1 -0
  208. package/build/lib/commands/timeouts.js +71 -0
  209. package/build/lib/commands/timeouts.js.map +1 -0
  210. package/build/lib/commands/types.d.ts +539 -0
  211. package/build/lib/commands/types.d.ts.map +1 -0
  212. package/build/lib/commands/types.js +3 -0
  213. package/build/lib/commands/types.js.map +1 -0
  214. package/build/lib/commands/web.d.ts +297 -0
  215. package/build/lib/commands/web.d.ts.map +1 -0
  216. package/build/lib/commands/web.js +1029 -0
  217. package/build/lib/commands/web.js.map +1 -0
  218. package/build/lib/commands/xctest-record-screen.d.ts +92 -0
  219. package/build/lib/commands/xctest-record-screen.d.ts.map +1 -0
  220. package/build/lib/commands/xctest-record-screen.js +193 -0
  221. package/build/lib/commands/xctest-record-screen.js.map +1 -0
  222. package/build/lib/commands/xctest.d.ts +71 -0
  223. package/build/lib/commands/xctest.d.ts.map +1 -0
  224. package/build/lib/commands/xctest.js +257 -0
  225. package/build/lib/commands/xctest.js.map +1 -0
  226. package/build/lib/css-converter.d.ts +10 -0
  227. package/build/lib/css-converter.d.ts.map +1 -0
  228. package/build/lib/css-converter.js +258 -0
  229. package/build/lib/css-converter.js.map +1 -0
  230. package/build/lib/desired-caps.d.ts +506 -0
  231. package/build/lib/desired-caps.d.ts.map +1 -0
  232. package/build/lib/desired-caps.js +400 -0
  233. package/build/lib/desired-caps.js.map +1 -0
  234. package/build/lib/device-connections-factory.d.ts +13 -0
  235. package/build/lib/device-connections-factory.d.ts.map +1 -0
  236. package/build/lib/device-connections-factory.js +244 -0
  237. package/build/lib/device-connections-factory.js.map +1 -0
  238. package/build/lib/device-log/helpers.d.ts +10 -0
  239. package/build/lib/device-log/helpers.d.ts.map +1 -0
  240. package/build/lib/device-log/helpers.js +37 -0
  241. package/build/lib/device-log/helpers.js.map +1 -0
  242. package/build/lib/device-log/ios-crash-log.d.ts +34 -0
  243. package/build/lib/device-log/ios-crash-log.d.ts.map +1 -0
  244. package/build/lib/device-log/ios-crash-log.js +141 -0
  245. package/build/lib/device-log/ios-crash-log.js.map +1 -0
  246. package/build/lib/device-log/ios-device-log.d.ts +19 -0
  247. package/build/lib/device-log/ios-device-log.d.ts.map +1 -0
  248. package/build/lib/device-log/ios-device-log.js +42 -0
  249. package/build/lib/device-log/ios-device-log.js.map +1 -0
  250. package/build/lib/device-log/ios-log.d.ts +24 -0
  251. package/build/lib/device-log/ios-log.d.ts.map +1 -0
  252. package/build/lib/device-log/ios-log.js +50 -0
  253. package/build/lib/device-log/ios-log.js.map +1 -0
  254. package/build/lib/device-log/ios-performance-log.d.ts +18 -0
  255. package/build/lib/device-log/ios-performance-log.d.ts.map +1 -0
  256. package/build/lib/device-log/ios-performance-log.js +43 -0
  257. package/build/lib/device-log/ios-performance-log.js.map +1 -0
  258. package/build/lib/device-log/ios-simulator-log.d.ts +38 -0
  259. package/build/lib/device-log/ios-simulator-log.d.ts.map +1 -0
  260. package/build/lib/device-log/ios-simulator-log.js +184 -0
  261. package/build/lib/device-log/ios-simulator-log.js.map +1 -0
  262. package/build/lib/device-log/line-consuming-log.d.ts +9 -0
  263. package/build/lib/device-log/line-consuming-log.d.ts.map +1 -0
  264. package/build/lib/device-log/line-consuming-log.js +16 -0
  265. package/build/lib/device-log/line-consuming-log.js.map +1 -0
  266. package/build/lib/device-log/safari-console-log.d.ts +67 -0
  267. package/build/lib/device-log/safari-console-log.d.ts.map +1 -0
  268. package/build/lib/device-log/safari-console-log.js +81 -0
  269. package/build/lib/device-log/safari-console-log.js.map +1 -0
  270. package/build/lib/device-log/safari-network-log.d.ts +75 -0
  271. package/build/lib/device-log/safari-network-log.d.ts.map +1 -0
  272. package/build/lib/device-log/safari-network-log.js +47 -0
  273. package/build/lib/device-log/safari-network-log.js.map +1 -0
  274. package/build/lib/doctor/checks.d.ts +3 -0
  275. package/build/lib/doctor/checks.d.ts.map +1 -0
  276. package/build/lib/doctor/checks.js +39 -0
  277. package/build/lib/doctor/checks.js.map +1 -0
  278. package/build/lib/doctor/optional-checks.d.ts +46 -0
  279. package/build/lib/doctor/optional-checks.d.ts.map +1 -0
  280. package/build/lib/doctor/optional-checks.js +129 -0
  281. package/build/lib/doctor/optional-checks.js.map +1 -0
  282. package/build/lib/doctor/required-checks.d.ts +42 -0
  283. package/build/lib/doctor/required-checks.d.ts.map +1 -0
  284. package/build/lib/doctor/required-checks.js +94 -0
  285. package/build/lib/doctor/required-checks.js.map +1 -0
  286. package/build/lib/doctor/utils.d.ts +8 -0
  287. package/build/lib/doctor/utils.d.ts.map +1 -0
  288. package/build/lib/doctor/utils.js +21 -0
  289. package/build/lib/doctor/utils.js.map +1 -0
  290. package/build/lib/driver.d.ts +2429 -0
  291. package/build/lib/driver.d.ts.map +1 -0
  292. package/build/lib/driver.js +1967 -0
  293. package/build/lib/driver.js.map +1 -0
  294. package/build/lib/execute-method-map.d.ts +552 -0
  295. package/build/lib/execute-method-map.d.ts.map +1 -0
  296. package/build/lib/execute-method-map.js +586 -0
  297. package/build/lib/execute-method-map.js.map +1 -0
  298. package/build/lib/ios-fs-helpers.d.ts +75 -0
  299. package/build/lib/ios-fs-helpers.d.ts.map +1 -0
  300. package/build/lib/ios-fs-helpers.js +370 -0
  301. package/build/lib/ios-fs-helpers.js.map +1 -0
  302. package/build/lib/ios-generic-simulators.d.ts +6 -0
  303. package/build/lib/ios-generic-simulators.d.ts.map +1 -0
  304. package/build/lib/ios-generic-simulators.js +14 -0
  305. package/build/lib/ios-generic-simulators.js.map +1 -0
  306. package/build/lib/logger.d.ts +3 -0
  307. package/build/lib/logger.d.ts.map +1 -0
  308. package/build/lib/logger.js +6 -0
  309. package/build/lib/logger.js.map +1 -0
  310. package/build/lib/method-map.d.ts +229 -0
  311. package/build/lib/method-map.d.ts.map +1 -0
  312. package/build/lib/method-map.js +200 -0
  313. package/build/lib/method-map.js.map +1 -0
  314. package/build/lib/real-device-clients/base-device-client.d.ts +22 -0
  315. package/build/lib/real-device-clients/base-device-client.d.ts.map +1 -0
  316. package/build/lib/real-device-clients/base-device-client.js +14 -0
  317. package/build/lib/real-device-clients/base-device-client.js.map +1 -0
  318. package/build/lib/real-device-clients/py-ios-device-client.d.ts +21 -0
  319. package/build/lib/real-device-clients/py-ios-device-client.d.ts.map +1 -0
  320. package/build/lib/real-device-clients/py-ios-device-client.js +125 -0
  321. package/build/lib/real-device-clients/py-ios-device-client.js.map +1 -0
  322. package/build/lib/real-device-management.d.ts +53 -0
  323. package/build/lib/real-device-management.d.ts.map +1 -0
  324. package/build/lib/real-device-management.js +128 -0
  325. package/build/lib/real-device-management.js.map +1 -0
  326. package/build/lib/real-device.d.ts +112 -0
  327. package/build/lib/real-device.d.ts.map +1 -0
  328. package/build/lib/real-device.js +352 -0
  329. package/build/lib/real-device.js.map +1 -0
  330. package/build/lib/simulator-management.d.ts +96 -0
  331. package/build/lib/simulator-management.d.ts.map +1 -0
  332. package/build/lib/simulator-management.js +278 -0
  333. package/build/lib/simulator-management.js.map +1 -0
  334. package/build/lib/stubs.d.ts +3 -0
  335. package/build/lib/stubs.d.ts.map +1 -0
  336. package/build/lib/stubs.js +3 -0
  337. package/build/lib/stubs.js.map +1 -0
  338. package/build/lib/types.d.ts +31 -0
  339. package/build/lib/types.d.ts.map +1 -0
  340. package/build/lib/types.js +3 -0
  341. package/build/lib/types.js.map +1 -0
  342. package/build/lib/utils.d.ts +191 -0
  343. package/build/lib/utils.d.ts.map +1 -0
  344. package/build/lib/utils.js +549 -0
  345. package/build/lib/utils.js.map +1 -0
  346. package/build/lib/xcrun.d.ts +3 -0
  347. package/build/lib/xcrun.d.ts.map +1 -0
  348. package/build/lib/xcrun.js +17 -0
  349. package/build/lib/xcrun.js.map +1 -0
  350. package/index.js +7 -0
  351. package/lib/app-infos-cache.js +187 -0
  352. package/lib/app-utils.js +710 -0
  353. package/lib/commands/active-app-info.js +12 -0
  354. package/lib/commands/advanced-battery-types.ts +454 -0
  355. package/lib/commands/alert.js +88 -0
  356. package/lib/commands/app-management.js +346 -0
  357. package/lib/commands/app-strings.js +30 -0
  358. package/lib/commands/appearance.js +71 -0
  359. package/lib/commands/audit.js +31 -0
  360. package/lib/commands/battery.js +45 -0
  361. package/lib/commands/bidi/constants.ts +6 -0
  362. package/lib/commands/bidi/models.ts +55 -0
  363. package/lib/commands/bidi/types.ts +31 -0
  364. package/lib/commands/biometric.js +53 -0
  365. package/lib/commands/certificate.js +497 -0
  366. package/lib/commands/clipboard.js +35 -0
  367. package/lib/commands/condition.js +155 -0
  368. package/lib/commands/content-size.js +68 -0
  369. package/lib/commands/context.js +705 -0
  370. package/lib/commands/deviceInfo.js +27 -0
  371. package/lib/commands/element.js +423 -0
  372. package/lib/commands/enum.ts +108 -0
  373. package/lib/commands/execute.js +153 -0
  374. package/lib/commands/file-movement.js +510 -0
  375. package/lib/commands/find.js +205 -0
  376. package/lib/commands/general.js +278 -0
  377. package/lib/commands/geolocation.js +56 -0
  378. package/lib/commands/gesture.js +596 -0
  379. package/lib/commands/hid-event.ts +1634 -0
  380. package/lib/commands/increase-contrast.js +50 -0
  381. package/lib/commands/iohid.js +64 -0
  382. package/lib/commands/keyboard.js +62 -0
  383. package/lib/commands/keychains.js +18 -0
  384. package/lib/commands/localization.js +30 -0
  385. package/lib/commands/location.js +131 -0
  386. package/lib/commands/lock.js +46 -0
  387. package/lib/commands/log.js +327 -0
  388. package/lib/commands/memory.js +51 -0
  389. package/lib/commands/navigation.js +125 -0
  390. package/lib/commands/notifications.js +66 -0
  391. package/lib/commands/pasteboard.js +42 -0
  392. package/lib/commands/pcap.js +168 -0
  393. package/lib/commands/performance.js +392 -0
  394. package/lib/commands/permissions.js +85 -0
  395. package/lib/commands/proxy-helper.js +122 -0
  396. package/lib/commands/record-audio.js +264 -0
  397. package/lib/commands/recordscreen.js +391 -0
  398. package/lib/commands/screenshots.js +137 -0
  399. package/lib/commands/simctl.js +71 -0
  400. package/lib/commands/source.js +131 -0
  401. package/lib/commands/timeouts.js +68 -0
  402. package/lib/commands/types.ts +648 -0
  403. package/lib/commands/web.js +1113 -0
  404. package/lib/commands/xctest-record-screen.js +204 -0
  405. package/lib/commands/xctest.js +285 -0
  406. package/lib/css-converter.js +311 -0
  407. package/lib/desired-caps.js +396 -0
  408. package/lib/device-connections-factory.js +269 -0
  409. package/lib/device-log/helpers.ts +40 -0
  410. package/lib/device-log/ios-crash-log.ts +166 -0
  411. package/lib/device-log/ios-device-log.ts +51 -0
  412. package/lib/device-log/ios-log.ts +70 -0
  413. package/lib/device-log/ios-performance-log.ts +50 -0
  414. package/lib/device-log/ios-simulator-log.ts +202 -0
  415. package/lib/device-log/line-consuming-log.ts +16 -0
  416. package/lib/device-log/safari-console-log.ts +117 -0
  417. package/lib/device-log/safari-network-log.ts +120 -0
  418. package/lib/doctor/checks.ts +3 -0
  419. package/lib/doctor/optional-checks.ts +173 -0
  420. package/lib/doctor/required-checks.ts +120 -0
  421. package/lib/doctor/utils.ts +18 -0
  422. package/lib/driver.js +2316 -0
  423. package/lib/execute-method-map.ts +585 -0
  424. package/lib/ios-fs-helpers.js +355 -0
  425. package/lib/ios-generic-simulators.js +11 -0
  426. package/lib/logger.js +5 -0
  427. package/lib/method-map.js +196 -0
  428. package/lib/real-device-clients/base-device-client.ts +34 -0
  429. package/lib/real-device-clients/py-ios-device-client.ts +149 -0
  430. package/lib/real-device-management.js +133 -0
  431. package/lib/real-device.js +347 -0
  432. package/lib/simulator-management.js +324 -0
  433. package/lib/stubs.ts +3 -0
  434. package/lib/types.ts +33 -0
  435. package/lib/utils.js +551 -0
  436. package/lib/xcrun.js +16 -0
  437. package/package.json +175 -0
  438. package/scripts/build-docs.js +56 -0
  439. package/scripts/build-wda.js +42 -0
  440. package/scripts/download-wda-sim.mjs +68 -0
  441. package/scripts/image-mounter.mjs +239 -0
  442. package/scripts/open-wda.mjs +15 -0
  443. package/scripts/tunnel-creation.mjs +359 -0
  444. package/scripts/utils.js +16 -0
@@ -0,0 +1,269 @@
1
+ import _ from 'lodash';
2
+ import net from 'net';
3
+ import B from 'bluebird';
4
+ import {logger, util, timing} from 'appium/support';
5
+ import {utilities} from 'appium-ios-device';
6
+ import {checkPortStatus} from 'portscanner';
7
+ import {waitForCondition} from 'asyncbox';
8
+
9
+ const LOCALHOST = '127.0.0.1';
10
+
11
+ class iProxy {
12
+ constructor(udid, localport, deviceport) {
13
+ this.localport = parseInt(localport, 10);
14
+ this.deviceport = parseInt(deviceport, 10);
15
+ this.udid = udid;
16
+ this.localServer = null;
17
+ this.log = logger.getLogger(`iProxy@${udid.substring(0, 8)}:${this.localport}`);
18
+ }
19
+
20
+ async start() {
21
+ if (this.localServer) {
22
+ return;
23
+ }
24
+
25
+ this.localServer = net.createServer(async (localSocket) => {
26
+ let remoteSocket;
27
+ try {
28
+ // We can only connect to the remote socket after the local socket connection succeeds
29
+ remoteSocket = await utilities.connectPort(this.udid, this.deviceport);
30
+ } catch (e) {
31
+ this.log.debug(e.message);
32
+ localSocket.destroy();
33
+ return;
34
+ }
35
+
36
+ const destroyCommChannel = () => {
37
+ remoteSocket.unpipe(localSocket);
38
+ localSocket.unpipe(remoteSocket);
39
+ };
40
+ remoteSocket.once('close', () => {
41
+ destroyCommChannel();
42
+ localSocket.destroy();
43
+ });
44
+ // not all remote socket errors are critical for the user
45
+ remoteSocket.on('error', (e) => this.log.debug(e));
46
+ localSocket.once('end', destroyCommChannel);
47
+ localSocket.once('close', () => {
48
+ destroyCommChannel();
49
+ remoteSocket.destroy();
50
+ });
51
+ localSocket.on('error', (e) => this.log.warn(e.message));
52
+ localSocket.pipe(remoteSocket);
53
+ remoteSocket.pipe(localSocket);
54
+ });
55
+ const listeningPromise = new B((resolve, reject) => {
56
+ /** @type {net.Server} */ (this.localServer).once('listening', resolve);
57
+ /** @type {net.Server} */ (this.localServer).once('error', reject);
58
+ });
59
+ this.localServer.listen(this.localport);
60
+ try {
61
+ await listeningPromise;
62
+ } catch (e) {
63
+ this.localServer = null;
64
+ throw e;
65
+ }
66
+ this.localServer.on('error', (e) => this.log.warn(e.message));
67
+ this.localServer.once('close', (e) => {
68
+ if (e) {
69
+ this.log.info(`The connection has been closed with error ${e.message}`);
70
+ } else {
71
+ this.log.info(`The connection has been closed`);
72
+ }
73
+ this.localServer = null;
74
+ });
75
+
76
+ this.onBeforeProcessExit = this._closeLocalServer.bind(this);
77
+ // Make sure we free up the socket on process exit
78
+ process.on('beforeExit', this.onBeforeProcessExit);
79
+ }
80
+
81
+ _closeLocalServer() {
82
+ if (!this.localServer) {
83
+ return;
84
+ }
85
+
86
+ this.log.debug(`Closing the connection`);
87
+ this.localServer.close();
88
+ this.localServer = null;
89
+ }
90
+
91
+ stop() {
92
+ if (this.onBeforeProcessExit) {
93
+ process.off('beforeExit', this.onBeforeProcessExit);
94
+ this.onBeforeProcessExit = null;
95
+ }
96
+
97
+ this._closeLocalServer();
98
+ }
99
+ }
100
+
101
+ const log = logger.getLogger('DevCon Factory');
102
+ const PORT_CLOSE_TIMEOUT = 15 * 1000; // 15 seconds
103
+ const SPLITTER = ':';
104
+
105
+ class DeviceConnectionsFactory {
106
+ constructor() {
107
+ this._connectionsMapping = {};
108
+ }
109
+
110
+ _udidAsToken(udid) {
111
+ return `${util.hasValue(udid) ? udid : ''}${SPLITTER}`;
112
+ }
113
+
114
+ _portAsToken(port) {
115
+ return `${SPLITTER}${util.hasValue(port) ? port : ''}`;
116
+ }
117
+
118
+ _toKey(udid = null, port = null) {
119
+ return `${util.hasValue(udid) ? udid : ''}${SPLITTER}${util.hasValue(port) ? port : ''}`;
120
+ }
121
+
122
+ _releaseProxiedConnections(connectionKeys) {
123
+ const keys = connectionKeys.filter((k) => _.has(this._connectionsMapping[k], 'iproxy'));
124
+ for (const key of keys) {
125
+ log.info(`Releasing the listener for '${key}'`);
126
+ try {
127
+ this._connectionsMapping[key].iproxy.stop();
128
+ } catch (e) {
129
+ log.debug(e);
130
+ }
131
+ }
132
+ return keys;
133
+ }
134
+
135
+ listConnections(udid = null, port = null, strict = false) {
136
+ if (!udid && !port) {
137
+ return [];
138
+ }
139
+
140
+ // `this._connectionMapping` keys have format `udid:port`
141
+ // the `strict` argument enforces to match keys having both `udid` and `port`
142
+ // if they are defined
143
+ // while in non-strict mode keys having any of these are going to be matched
144
+ return _.keys(this._connectionsMapping).filter((key) =>
145
+ strict && udid && port
146
+ ? key === this._toKey(udid, port)
147
+ : (udid && key.startsWith(this._udidAsToken(udid))) ||
148
+ (port && key.endsWith(this._portAsToken(port))),
149
+ );
150
+ }
151
+
152
+ async requestConnection(udid, port, options = {}) {
153
+ if (!udid || !port) {
154
+ log.warn('Did not know how to request the connection:');
155
+ if (!udid) {
156
+ log.warn('- Device UDID is unset');
157
+ }
158
+ if (!port) {
159
+ log.warn('- The local port number is unset');
160
+ }
161
+ return;
162
+ }
163
+
164
+ const {usePortForwarding, devicePort} = options;
165
+
166
+ log.info(
167
+ `Requesting connection for device ${udid} on local port ${port}` +
168
+ (devicePort ? `, device port ${devicePort}` : ''),
169
+ );
170
+ log.debug(`Cached connections count: ${_.size(this._connectionsMapping)}`);
171
+ const connectionsOnPort = this.listConnections(null, port);
172
+ if (!_.isEmpty(connectionsOnPort)) {
173
+ log.info(`Found cached connections on port #${port}: ${JSON.stringify(connectionsOnPort)}`);
174
+ }
175
+
176
+ if (usePortForwarding) {
177
+ let isPortBusy = (await checkPortStatus(port, LOCALHOST)) === 'open';
178
+ if (isPortBusy) {
179
+ log.warn(`Port #${port} is busy. Did you quit the previous driver session(s) properly?`);
180
+ if (!_.isEmpty(connectionsOnPort)) {
181
+ log.info('Trying to release the port');
182
+ for (const key of this._releaseProxiedConnections(connectionsOnPort)) {
183
+ delete this._connectionsMapping[key];
184
+ }
185
+ const timer = new timing.Timer().start();
186
+ try {
187
+ await waitForCondition(
188
+ async () => {
189
+ try {
190
+ if ((await checkPortStatus(port, LOCALHOST)) !== 'open') {
191
+ log.info(
192
+ `Port #${port} has been successfully released after ` +
193
+ `${timer.getDuration().asMilliSeconds.toFixed(0)}ms`,
194
+ );
195
+ isPortBusy = false;
196
+ return true;
197
+ }
198
+ } catch {}
199
+ return false;
200
+ },
201
+ {
202
+ waitMs: PORT_CLOSE_TIMEOUT,
203
+ intervalMs: 300,
204
+ },
205
+ );
206
+ } catch {
207
+ log.warn(
208
+ `Did not know how to release port #${port} in ` +
209
+ `${timer.getDuration().asMilliSeconds.toFixed(0)}ms`,
210
+ );
211
+ }
212
+ }
213
+ }
214
+
215
+ if (isPortBusy) {
216
+ throw new Error(
217
+ `The port #${port} is occupied by an other process. ` +
218
+ `You can either quit that process or select another free port.`,
219
+ );
220
+ }
221
+ }
222
+ const currentKey = this._toKey(udid, port);
223
+ if (usePortForwarding) {
224
+ const iproxy = new iProxy(udid, port, devicePort);
225
+ try {
226
+ await iproxy.start();
227
+ this._connectionsMapping[currentKey] = {iproxy};
228
+ } catch (e) {
229
+ try {
230
+ iproxy.stop();
231
+ } catch (e1) {
232
+ log.debug(e1);
233
+ }
234
+ throw e;
235
+ }
236
+ } else {
237
+ this._connectionsMapping[currentKey] = {};
238
+ }
239
+ log.info(`Successfully requested the connection for ${currentKey}`);
240
+ }
241
+
242
+ releaseConnection(udid = null, port = null) {
243
+ if (!udid && !port) {
244
+ log.warn(
245
+ 'Neither device UDID nor local port is set. ' +
246
+ 'Did not know how to release the connection',
247
+ );
248
+ return;
249
+ }
250
+ log.info(`Releasing connections for ${udid || 'any'} device on ${port || 'any'} port number`);
251
+
252
+ const keys = this.listConnections(udid, port, true);
253
+ if (_.isEmpty(keys)) {
254
+ log.info('No cached connections have been found');
255
+ return;
256
+ }
257
+ log.info(`Found cached connections to release: ${JSON.stringify(keys)}`);
258
+ this._releaseProxiedConnections(keys);
259
+ for (const key of keys) {
260
+ delete this._connectionsMapping[key];
261
+ }
262
+ log.debug(`Cached connections count: ${_.size(this._connectionsMapping)}`);
263
+ }
264
+ }
265
+
266
+ const DEVICE_CONNECTIONS_FACTORY = new DeviceConnectionsFactory();
267
+
268
+ export {DEVICE_CONNECTIONS_FACTORY, DeviceConnectionsFactory};
269
+ export default DEVICE_CONNECTIONS_FACTORY;
@@ -0,0 +1,40 @@
1
+ import type { LogEntry } from '../commands/types';
2
+ import { fs } from 'appium/support';
3
+ import { createInterface } from 'node:readline';
4
+ import _ from 'lodash';
5
+
6
+ export const DEFAULT_LOG_LEVEL = 'ALL';
7
+ export const MAX_JSON_LOG_LENGTH = 200;
8
+ export const MAX_BUFFERED_EVENTS_COUNT = 5000;
9
+
10
+ export function toLogEntry(message: string, timestamp: number, level: string = DEFAULT_LOG_LEVEL): LogEntry {
11
+ return {
12
+ timestamp,
13
+ level,
14
+ message,
15
+ };
16
+ }
17
+
18
+ export interface GrepOptions {
19
+ caseInsensitive?: boolean;
20
+ }
21
+
22
+ export async function grepFile(
23
+ fullPath: string,
24
+ str: string,
25
+ opts: GrepOptions = {}
26
+ ): Promise<boolean> {
27
+ const input = fs.createReadStream(fullPath);
28
+ const rl = createInterface({input});
29
+ return await new Promise((resolve, reject) => {
30
+ input.once('error', reject);
31
+ rl.on('line', (line) => {
32
+ if (opts.caseInsensitive && _.toLower(line).includes(_.toLower(str))
33
+ || !opts.caseInsensitive && line.includes(str)) {
34
+ resolve(true);
35
+ input.close();
36
+ }
37
+ });
38
+ input.once('end', () => resolve(false));
39
+ });
40
+ }
@@ -0,0 +1,166 @@
1
+ import {fs, tempDir, util} from 'appium/support';
2
+ import B from 'bluebird';
3
+ import path from 'path';
4
+ import _ from 'lodash';
5
+ import {Pyidevice} from '../real-device-clients/py-ios-device-client';
6
+ import {IOSLog} from './ios-log';
7
+ import { toLogEntry, grepFile } from './helpers';
8
+ import type { AppiumLogger } from '@appium/types';
9
+ import type { BaseDeviceClient } from '../real-device-clients/base-device-client';
10
+ import type { Simulator } from '@limrun/appium-ios-simulator';
11
+ import type { LogEntry } from '../commands/types';
12
+
13
+ // The file format has been changed from '.crash' to '.ips' since Monterey.
14
+ const CRASH_REPORTS_GLOB_PATTERN = '**/*.@(crash|ips)';
15
+ // The size of a single diagnostic report might be hundreds of kilobytes.
16
+ // Thus we do not want to store too many items in the memory at once.
17
+ const MAX_RECENT_ITEMS = 20;
18
+
19
+ type TSerializedEntry = [string, number];
20
+
21
+ export interface IOSCrashLogOptions {
22
+ /** UDID of a real device */
23
+ udid?: string;
24
+ /** Simulator instance */
25
+ sim?: Simulator;
26
+ log: AppiumLogger;
27
+ }
28
+
29
+ export class IOSCrashLog extends IOSLog<TSerializedEntry, TSerializedEntry> {
30
+ private readonly _udid: string | undefined;
31
+ private readonly _realDeviceClient: BaseDeviceClient | null;
32
+ private readonly _logDir: string | null;
33
+ private readonly _sim: Simulator | undefined;
34
+ private _recentCrashFiles: string[];
35
+ private _started: boolean;
36
+
37
+ constructor(opts: IOSCrashLogOptions) {
38
+ super({
39
+ log: opts.log,
40
+ maxBufferSize: MAX_RECENT_ITEMS,
41
+ });
42
+ this._udid = opts.udid;
43
+ this._sim = opts.sim;
44
+ this._realDeviceClient = this._isRealDevice()
45
+ ? new Pyidevice({
46
+ udid: this._udid as string,
47
+ log: opts.log,
48
+ })
49
+ : null;
50
+ this._logDir = this._isRealDevice()
51
+ ? null
52
+ : path.resolve(process.env.HOME || '/', 'Library', 'Logs', 'DiagnosticReports');
53
+ this._recentCrashFiles = [];
54
+ this._started = false;
55
+ }
56
+
57
+ override async startCapture(): Promise<void> {
58
+ this._recentCrashFiles = await this._listCrashFiles(false);
59
+ this._started = true;
60
+ }
61
+
62
+ override async stopCapture(): Promise<void> {
63
+ this._started = false;
64
+ }
65
+
66
+ override get isCapturing(): boolean {
67
+ return this._started;
68
+ }
69
+
70
+ override async getLogs(): Promise<LogEntry[]> {
71
+ const crashFiles = (await this._listCrashFiles(true)).slice(-MAX_RECENT_ITEMS);
72
+ const diffFiles = _.difference(crashFiles, this._recentCrashFiles);
73
+ if (_.isEmpty(diffFiles)) {
74
+ return [];
75
+ }
76
+
77
+ this.log.debug(`Found ${util.pluralize('fresh crash report', diffFiles.length, true)}`);
78
+ await this._serializeCrashes(diffFiles);
79
+ this._recentCrashFiles = crashFiles;
80
+ return super.getLogs();
81
+ }
82
+
83
+ protected override _serializeEntry(value: TSerializedEntry): TSerializedEntry {
84
+ return value;
85
+ }
86
+
87
+ protected override _deserializeEntry(value: TSerializedEntry): LogEntry {
88
+ const [message, timestamp] = value;
89
+ return toLogEntry(message, timestamp);
90
+ }
91
+
92
+ private async _serializeCrashes(paths: string[]): Promise<void> {
93
+ const tmpRoot = await tempDir.openDir();
94
+ try {
95
+ for (const filePath of paths) {
96
+ let fullPath = filePath;
97
+ if (this._isRealDevice()) {
98
+ const fileName = filePath;
99
+ try {
100
+ await (this._realDeviceClient as BaseDeviceClient).exportCrash(fileName, tmpRoot);
101
+ } catch (e) {
102
+ this.log.warn(
103
+ `Cannot export the crash report '${fileName}'. Skipping it. ` +
104
+ `Original error: ${e.message}`,
105
+ );
106
+ return;
107
+ }
108
+ fullPath = path.join(tmpRoot, fileName);
109
+ }
110
+ const {ctime} = await fs.stat(fullPath);
111
+ this.broadcast([await fs.readFile(fullPath, 'utf8'), ctime.getTime()]);
112
+ }
113
+ } finally {
114
+ await fs.rimraf(tmpRoot);
115
+ }
116
+ }
117
+
118
+ private async _gatherFromRealDevice(strict: boolean): Promise<string[]> {
119
+ if (!this._realDeviceClient) {
120
+ return [];
121
+ }
122
+ if (!await this._realDeviceClient.assertExists(strict)) {
123
+ this.log.info(
124
+ `The ${_.toLower(this._realDeviceClient.constructor.name)} tool is not present in PATH. ` +
125
+ `Skipping crash logs collection for real devices.`
126
+ );
127
+ return [];
128
+ }
129
+
130
+ return await this._realDeviceClient.listCrashes();
131
+ }
132
+
133
+ private async _gatherFromSimulator(): Promise<string[]> {
134
+ if (!this._logDir || !this._sim || !(await fs.exists(this._logDir))) {
135
+ this.log.debug(`Crash reports root '${this._logDir}' does not exist. Got nothing to gather.`);
136
+ return [];
137
+ }
138
+
139
+ const foundFiles = await fs.glob(CRASH_REPORTS_GLOB_PATTERN, {
140
+ cwd: this._logDir,
141
+ absolute: true,
142
+ });
143
+ const simUdid = (this._sim as Simulator).udid;
144
+ // For Simulator only include files, that contain current UDID
145
+ return await B.filter(foundFiles, async (filePath) => {
146
+ try {
147
+ return await grepFile(filePath, simUdid, {caseInsensitive: true});
148
+ } catch (err) {
149
+ this.log.warn(err);
150
+ return false;
151
+ }
152
+ });
153
+ }
154
+
155
+ private async _listCrashFiles(strict: boolean): Promise<string[]> {
156
+ return this._isRealDevice()
157
+ ? await this._gatherFromRealDevice(strict)
158
+ : await this._gatherFromSimulator();
159
+ }
160
+
161
+ private _isRealDevice(): boolean {
162
+ return Boolean(this._udid);
163
+ }
164
+ }
165
+
166
+ export default IOSCrashLog;
@@ -0,0 +1,51 @@
1
+ import {services} from 'appium-ios-device';
2
+ import { LineConsumingLog } from './line-consuming-log';
3
+ import type { AppiumLogger } from '@appium/types';
4
+
5
+ export interface IOSDeviceLogOpts {
6
+ udid: string;
7
+ showLogs?: boolean;
8
+ log: AppiumLogger;
9
+ }
10
+
11
+ export class IOSDeviceLog extends LineConsumingLog {
12
+ private readonly udid: string;
13
+ private readonly showLogs: boolean;
14
+ private service: any | null;
15
+
16
+ constructor(opts: IOSDeviceLogOpts) {
17
+ super({log: opts.log});
18
+ this.udid = opts.udid;
19
+ this.showLogs = !!opts.showLogs;
20
+ this.service = null;
21
+ }
22
+
23
+ override async startCapture(): Promise<void> {
24
+ if (this.service) {
25
+ return;
26
+ }
27
+ this.service = await services.startSyslogService(this.udid);
28
+ this.service.start(this.onLog.bind(this));
29
+ }
30
+
31
+ override get isCapturing(): boolean {
32
+ return !!this.service;
33
+ }
34
+
35
+ override async stopCapture(): Promise<void> {
36
+ if (!this.service) {
37
+ return;
38
+ }
39
+ this.service.close();
40
+ this.service = null;
41
+ }
42
+
43
+ private onLog(logLine: string): void {
44
+ this.broadcast(logLine);
45
+ if (this.showLogs) {
46
+ this.log.info(`[IOS_SYSLOG_ROW] ${logLine}`);
47
+ }
48
+ }
49
+ }
50
+
51
+ export default IOSDeviceLog;
@@ -0,0 +1,70 @@
1
+ import {EventEmitter} from 'events';
2
+ import { LRUCache } from 'lru-cache';
3
+ import type { LogEntry } from '../commands/types';
4
+ import type { AppiumLogger } from '@appium/types';
5
+ import {logger} from 'appium/support';
6
+
7
+ // We keep only the most recent log entries to avoid out of memory error
8
+ const MAX_LOG_ENTRIES_COUNT = 10000;
9
+
10
+ export interface IOSLogOptions {
11
+ maxBufferSize?: number;
12
+ log?: AppiumLogger;
13
+ }
14
+
15
+ export abstract class IOSLog<
16
+ TRawEntry,
17
+ TSerializedEntry extends object
18
+ > extends EventEmitter {
19
+ private maxBufferSize: number;
20
+ private logs: LRUCache<number, TSerializedEntry>;
21
+ private _log: AppiumLogger;
22
+
23
+ constructor(opts: IOSLogOptions = {}) {
24
+ super();
25
+ this.maxBufferSize = opts.maxBufferSize ?? MAX_LOG_ENTRIES_COUNT;
26
+ this.logs = new LRUCache({
27
+ max: this.maxBufferSize,
28
+ });
29
+ this._log = opts.log ?? logger.getLogger(this.constructor.name);
30
+ }
31
+
32
+ abstract startCapture(): Promise<void>;
33
+ abstract stopCapture(): Promise<void>;
34
+ abstract get isCapturing(): boolean;
35
+
36
+ get log(): AppiumLogger {
37
+ return this._log;
38
+ }
39
+
40
+ async getLogs(): Promise<LogEntry[]> {
41
+ const result: LogEntry[] = [];
42
+ for (const value of this.logs.rvalues()) {
43
+ result.push(this._deserializeEntry(value as TSerializedEntry));
44
+ }
45
+ this._clearEntries();
46
+ return result;
47
+ }
48
+
49
+ protected abstract _serializeEntry(value: TRawEntry): TSerializedEntry;
50
+ protected abstract _deserializeEntry(value: TSerializedEntry): LogEntry;
51
+
52
+ protected _clearEntries() {
53
+ this.logs.clear();
54
+ }
55
+
56
+ protected broadcast(entry: TRawEntry): void {
57
+ let recentIndex = -1;
58
+ for (const key of this.logs.keys()) {
59
+ recentIndex = key;
60
+ break;
61
+ }
62
+ const serializedEntry = this._serializeEntry(entry);
63
+ this.logs.set(++recentIndex, serializedEntry);
64
+ if (this.listenerCount('output')) {
65
+ this.emit('output', this._deserializeEntry(serializedEntry));
66
+ }
67
+ }
68
+ }
69
+
70
+ export default IOSLog;
@@ -0,0 +1,50 @@
1
+ import _ from 'lodash';
2
+ import type { AppiumLogger } from '@appium/types';
3
+ import { MAX_JSON_LOG_LENGTH, MAX_BUFFERED_EVENTS_COUNT } from './helpers';
4
+ import { LineConsumingLog } from './line-consuming-log';
5
+
6
+ type PerformanceLogEntry = object;
7
+ export interface IOSPerformanceLogOptions {
8
+ remoteDebugger: any;
9
+ maxEvents?: number;
10
+ log: AppiumLogger;
11
+ }
12
+
13
+ export class IOSPerformanceLog extends LineConsumingLog {
14
+ private readonly remoteDebugger: any;
15
+ private _started: boolean;
16
+
17
+ constructor(opts: IOSPerformanceLogOptions) {
18
+ super({
19
+ maxBufferSize: opts.maxEvents ?? MAX_BUFFERED_EVENTS_COUNT,
20
+ log: opts.log,
21
+ });
22
+ this.remoteDebugger = opts.remoteDebugger;
23
+ this._started = false;
24
+ }
25
+
26
+ override async startCapture(): Promise<void> {
27
+ this.log.debug('Starting performance (Timeline) log capture');
28
+ this._clearEntries();
29
+ await this.remoteDebugger.startTimeline(this.onTimelineEvent.bind(this));
30
+ this._started = true;
31
+ }
32
+
33
+ override async stopCapture(): Promise<void> {
34
+ this.log.debug('Stopping performance (Timeline) log capture');
35
+ await this.remoteDebugger.stopTimeline();
36
+ this._started = false;
37
+ }
38
+
39
+ override get isCapturing(): boolean {
40
+ return this._started;
41
+ }
42
+
43
+ private onTimelineEvent(event: PerformanceLogEntry): void {
44
+ const serializedEntry = JSON.stringify(event);
45
+ this.broadcast(serializedEntry);
46
+ this.log.debug(`Received Timeline event: ${_.truncate(serializedEntry, {length: MAX_JSON_LOG_LENGTH})}`);
47
+ }
48
+ }
49
+
50
+ export default IOSPerformanceLog;