rocketwright 3.12.0__py3-none-macosx_14_0_universal2.whl

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 (455) hide show
  1. rocketwright/__init__.py +6 -0
  2. rocketwright/__main__.py +7 -0
  3. rocketwright/_bin/rocketwright-helper +0 -0
  4. rocketwright/_helper_src/Package.swift +43 -0
  5. rocketwright/_helper_src/Sources/HelperCore/Accessibility.swift +179 -0
  6. rocketwright/_helper_src/Sources/HelperCore/Arguments.swift +245 -0
  7. rocketwright/_helper_src/Sources/HelperCore/Capture.swift +202 -0
  8. rocketwright/_helper_src/Sources/HelperCore/FrameScheduler.swift +72 -0
  9. rocketwright/_helper_src/Sources/HelperCore/Input.swift +171 -0
  10. rocketwright/_helper_src/Sources/HelperCore/JSON.swift +84 -0
  11. rocketwright/_helper_src/Sources/HelperCore/MacWindow.swift +152 -0
  12. rocketwright/_helper_src/Sources/HelperCore/Orientation.swift +131 -0
  13. rocketwright/_helper_src/Sources/HelperCore/Overlay.swift +285 -0
  14. rocketwright/_helper_src/Sources/HelperCore/Recording.swift +434 -0
  15. rocketwright/_helper_src/Sources/HelperCore/Requests.swift +159 -0
  16. rocketwright/_helper_src/Sources/HelperCore/Rotation.swift +58 -0
  17. rocketwright/_helper_src/Sources/HelperCore/Screen.swift +142 -0
  18. rocketwright/_helper_src/Sources/HelperCore/Server.swift +223 -0
  19. rocketwright/_helper_src/Sources/HelperCore/Video.swift +125 -0
  20. rocketwright/_helper_src/Sources/HelperCore/Wire.swift +122 -0
  21. rocketwright/_helper_src/Sources/HelperPlatform/AccessibilityReader.swift +204 -0
  22. rocketwright/_helper_src/Sources/HelperPlatform/CaptureDevice.swift +195 -0
  23. rocketwright/_helper_src/Sources/HelperPlatform/Disclaimed.swift +46 -0
  24. rocketwright/_helper_src/Sources/HelperPlatform/Framebuffer.swift +141 -0
  25. rocketwright/_helper_src/Sources/HelperPlatform/Frameworks.swift +84 -0
  26. rocketwright/_helper_src/Sources/HelperPlatform/H264Stream.swift +295 -0
  27. rocketwright/_helper_src/Sources/HelperPlatform/HIDTransports.swift +149 -0
  28. rocketwright/_helper_src/Sources/HelperPlatform/MacAccessibility.swift +241 -0
  29. rocketwright/_helper_src/Sources/HelperPlatform/MacOverlay.swift +352 -0
  30. rocketwright/_helper_src/Sources/HelperPlatform/MacPermissions.swift +34 -0
  31. rocketwright/_helper_src/Sources/HelperPlatform/MacWindowCapture.swift +76 -0
  32. rocketwright/_helper_src/Sources/HelperPlatform/MacWindowDevice.swift +153 -0
  33. rocketwright/_helper_src/Sources/HelperPlatform/Pictures.swift +73 -0
  34. rocketwright/_helper_src/Sources/HelperPlatform/PixelSource.swift +91 -0
  35. rocketwright/_helper_src/Sources/HelperPlatform/RecordingRenderer.swift +395 -0
  36. rocketwright/_helper_src/Sources/HelperPlatform/ScreenFeed.swift +60 -0
  37. rocketwright/_helper_src/Sources/HelperPlatform/SimDeviceHandle.swift +67 -0
  38. rocketwright/_helper_src/Sources/HelperPlatform/SimulatorDevice.swift +154 -0
  39. rocketwright/_helper_src/Sources/HelperPlatform/UnixSocket.swift +119 -0
  40. rocketwright/_helper_src/Sources/HelperPlatform/UsbCapture.swift +245 -0
  41. rocketwright/_helper_src/Sources/HelperPlatform/Warming.swift +29 -0
  42. rocketwright/_helper_src/Sources/ObjCGuard/ObjCGuard.m +11 -0
  43. rocketwright/_helper_src/Sources/ObjCGuard/include/ObjCGuard.h +12 -0
  44. rocketwright/_helper_src/Sources/rocketwright-helper/main.swift +162 -0
  45. rocketwright/_helper_src/Support/Info.plist +12 -0
  46. rocketwright/_helper_src/Tests/Fixtures/wire-vectors.json +69 -0
  47. rocketwright/_helper_src/Tests/HelperCoreTests/AccessibilityTests.swift +73 -0
  48. rocketwright/_helper_src/Tests/HelperCoreTests/ArgumentsTests.swift +63 -0
  49. rocketwright/_helper_src/Tests/HelperCoreTests/CaptureTests.swift +108 -0
  50. rocketwright/_helper_src/Tests/HelperCoreTests/InputTests.swift +90 -0
  51. rocketwright/_helper_src/Tests/HelperCoreTests/MacWindowTests.swift +101 -0
  52. rocketwright/_helper_src/Tests/HelperCoreTests/OrientationTests.swift +128 -0
  53. rocketwright/_helper_src/Tests/HelperCoreTests/OverlayTests.swift +283 -0
  54. rocketwright/_helper_src/Tests/HelperCoreTests/PictureTests.swift +129 -0
  55. rocketwright/_helper_src/Tests/HelperCoreTests/RecordingTests.swift +261 -0
  56. rocketwright/_helper_src/Tests/HelperCoreTests/RotationTests.swift +41 -0
  57. rocketwright/_helper_src/Tests/HelperCoreTests/ServerTests.swift +293 -0
  58. rocketwright/_helper_src/Tests/HelperCoreTests/WireTests.swift +122 -0
  59. rocketwright/_version.py +4 -0
  60. rocketwright/api.py +103 -0
  61. rocketwright/build/__init__.py +2 -0
  62. rocketwright/build/checkouts.py +271 -0
  63. rocketwright/build/derived.py +111 -0
  64. rocketwright/build/destination.py +102 -0
  65. rocketwright/build/flutter.py +542 -0
  66. rocketwright/build/flutter_log.py +205 -0
  67. rocketwright/build/flutter_run.py +343 -0
  68. rocketwright/build/folders.py +38 -0
  69. rocketwright/build/gradle.py +489 -0
  70. rocketwright/build/gradle_log.py +73 -0
  71. rocketwright/build/junit.py +125 -0
  72. rocketwright/build/project_files.py +52 -0
  73. rocketwright/build/provider.py +461 -0
  74. rocketwright/build/runner.py +601 -0
  75. rocketwright/build/schemes.py +129 -0
  76. rocketwright/build/source.py +59 -0
  77. rocketwright/build/stamp.py +192 -0
  78. rocketwright/build/wda.py +147 -0
  79. rocketwright/build/xcodebuild.py +734 -0
  80. rocketwright/build/xcresult.py +365 -0
  81. rocketwright/build/xctestplan.py +105 -0
  82. rocketwright/cli/__init__.py +2 -0
  83. rocketwright/cli/android.py +135 -0
  84. rocketwright/cli/app_command.py +129 -0
  85. rocketwright/cli/config_command.py +150 -0
  86. rocketwright/cli/context.py +187 -0
  87. rocketwright/cli/device_command.py +58 -0
  88. rocketwright/cli/devices.py +142 -0
  89. rocketwright/cli/doctor.py +82 -0
  90. rocketwright/cli/helper.py +251 -0
  91. rocketwright/cli/login.py +113 -0
  92. rocketwright/cli/main.py +80 -0
  93. rocketwright/cli/mcp.py +56 -0
  94. rocketwright/cli/open_viewer.py +53 -0
  95. rocketwright/cli/record.py +130 -0
  96. rocketwright/cli/serve.py +76 -0
  97. rocketwright/cli/settings_command.py +38 -0
  98. rocketwright/cli/stop.py +209 -0
  99. rocketwright/cli/tokens.py +88 -0
  100. rocketwright/cli/tools.py +29 -0
  101. rocketwright/cli/version.py +31 -0
  102. rocketwright/cli/wda.py +285 -0
  103. rocketwright/cli/xcode.py +90 -0
  104. rocketwright/config/__init__.py +3 -0
  105. rocketwright/config/discovery.py +19 -0
  106. rocketwright/config/env.py +34 -0
  107. rocketwright/config/model.py +174 -0
  108. rocketwright/config/observe_languages.py +91 -0
  109. rocketwright/config/provenance.py +39 -0
  110. rocketwright/config/schema.py +1103 -0
  111. rocketwright/config/settings_store.py +34 -0
  112. rocketwright/config/toml_source.py +139 -0
  113. rocketwright/config/writer.py +218 -0
  114. rocketwright/connectors/__init__.py +8 -0
  115. rocketwright/connectors/android/__init__.py +2 -0
  116. rocketwright/connectors/android/adb_input.py +134 -0
  117. rocketwright/connectors/android/connector.py +230 -0
  118. rocketwright/connectors/android/geometry.py +115 -0
  119. rocketwright/connectors/android/keys.py +59 -0
  120. rocketwright/connectors/android/scrcpy.py +269 -0
  121. rocketwright/connectors/android/scrcpy_roles.py +202 -0
  122. rocketwright/connectors/android/scrcpy_source.py +204 -0
  123. rocketwright/connectors/android/screen.py +69 -0
  124. rocketwright/connectors/android/uiautomator.py +256 -0
  125. rocketwright/connectors/app/__init__.py +12 -0
  126. rocketwright/connectors/app/client.py +160 -0
  127. rocketwright/connectors/app/discovery.py +182 -0
  128. rocketwright/connectors/app/document.py +229 -0
  129. rocketwright/connectors/app/errors.py +30 -0
  130. rocketwright/connectors/app/merge.py +95 -0
  131. rocketwright/connectors/app/reader.py +218 -0
  132. rocketwright/connectors/app/wire.py +37 -0
  133. rocketwright/connectors/base.py +375 -0
  134. rocketwright/connectors/helper_process.py +414 -0
  135. rocketwright/connectors/idb/__init__.py +2 -0
  136. rocketwright/connectors/idb/companion.py +195 -0
  137. rocketwright/connectors/idb/connector.py +93 -0
  138. rocketwright/connectors/idb/engine.py +202 -0
  139. rocketwright/connectors/idb/frameworks.py +51 -0
  140. rocketwright/connectors/idb/orientation.py +157 -0
  141. rocketwright/connectors/idb/proto/__init__.py +8 -0
  142. rocketwright/connectors/idb/proto/idb.proto +1301 -0
  143. rocketwright/connectors/idb/proto/idb_grpc.py +776 -0
  144. rocketwright/connectors/idb/proto/idb_pb2.py +452 -0
  145. rocketwright/connectors/iphone/__init__.py +2 -0
  146. rocketwright/connectors/iphone/cable.py +49 -0
  147. rocketwright/connectors/iphone/capture.py +147 -0
  148. rocketwright/connectors/iphone/connector.py +409 -0
  149. rocketwright/connectors/iphone/screen.py +78 -0
  150. rocketwright/connectors/iphone/wda.py +320 -0
  151. rocketwright/connectors/iphone/wda_client.py +347 -0
  152. rocketwright/connectors/iphone/wda_roles.py +520 -0
  153. rocketwright/connectors/iphone/wda_setup.py +178 -0
  154. rocketwright/connectors/iphone/wda_source.py +247 -0
  155. rocketwright/connectors/mac/__init__.py +2 -0
  156. rocketwright/connectors/mac/connector.py +344 -0
  157. rocketwright/connectors/mcpbridge/__init__.py +3 -0
  158. rocketwright/connectors/mcpbridge/client.py +140 -0
  159. rocketwright/connectors/mcpbridge/connector.py +84 -0
  160. rocketwright/connectors/mcpbridge/hierarchy.py +225 -0
  161. rocketwright/connectors/mcpbridge/merge.py +68 -0
  162. rocketwright/connectors/mcpbridge/reader.py +221 -0
  163. rocketwright/connectors/native/__init__.py +2 -0
  164. rocketwright/connectors/native/client.py +275 -0
  165. rocketwright/connectors/native/connector.py +182 -0
  166. rocketwright/connectors/native/helper.py +490 -0
  167. rocketwright/connectors/native/wire.py +98 -0
  168. rocketwright/connectors/registry.py +231 -0
  169. rocketwright/connectors/simctl/__init__.py +2 -0
  170. rocketwright/connectors/simctl/capture.py +66 -0
  171. rocketwright/connectors/simctl/connector.py +78 -0
  172. rocketwright/core/__init__.py +3 -0
  173. rocketwright/core/actions.py +1825 -0
  174. rocketwright/core/activity.py +155 -0
  175. rocketwright/core/android_backend.py +256 -0
  176. rocketwright/core/android_control.py +442 -0
  177. rocketwright/core/android_devices.py +260 -0
  178. rocketwright/core/availability.py +63 -0
  179. rocketwright/core/backends.py +277 -0
  180. rocketwright/core/cleanup.py +127 -0
  181. rocketwright/core/contact_sheet.py +75 -0
  182. rocketwright/core/control.py +457 -0
  183. rocketwright/core/device_changes.py +300 -0
  184. rocketwright/core/device_logs.py +168 -0
  185. rocketwright/core/device_settings.py +112 -0
  186. rocketwright/core/devices.py +564 -0
  187. rocketwright/core/drivers.py +150 -0
  188. rocketwright/core/events.py +46 -0
  189. rocketwright/core/flows.py +353 -0
  190. rocketwright/core/frames.py +413 -0
  191. rocketwright/core/gestures.py +268 -0
  192. rocketwright/core/given.py +89 -0
  193. rocketwright/core/instance.py +244 -0
  194. rocketwright/core/login.py +252 -0
  195. rocketwright/core/mac_backend.py +168 -0
  196. rocketwright/core/manager.py +1536 -0
  197. rocketwright/core/masking.py +113 -0
  198. rocketwright/core/reaper.py +98 -0
  199. rocketwright/core/recording_sources.py +168 -0
  200. rocketwright/core/recordings.py +1101 -0
  201. rocketwright/core/refusals.py +275 -0
  202. rocketwright/core/render.py +97 -0
  203. rocketwright/core/runtime.py +600 -0
  204. rocketwright/core/screen_input.py +269 -0
  205. rocketwright/core/screen_relay.py +327 -0
  206. rocketwright/core/selections.py +194 -0
  207. rocketwright/core/signing.py +94 -0
  208. rocketwright/core/status.py +69 -0
  209. rocketwright/core/text_entry.py +126 -0
  210. rocketwright/core/text_overlay.py +71 -0
  211. rocketwright/core/tickets.py +43 -0
  212. rocketwright/core/touch.py +225 -0
  213. rocketwright/daemon/__init__.py +2 -0
  214. rocketwright/daemon/app.py +550 -0
  215. rocketwright/daemon/auth.py +210 -0
  216. rocketwright/daemon/confirmations.py +110 -0
  217. rocketwright/daemon/health.py +47 -0
  218. rocketwright/daemon/lease.py +76 -0
  219. rocketwright/daemon/lifecycle.py +105 -0
  220. rocketwright/daemon/passes.py +151 -0
  221. rocketwright/daemon/pauses.py +46 -0
  222. rocketwright/daemon/policy.py +39 -0
  223. rocketwright/daemon/scope_names.py +81 -0
  224. rocketwright/daemon/tokens.py +302 -0
  225. rocketwright/doctor/__init__.py +2 -0
  226. rocketwright/doctor/android.py +118 -0
  227. rocketwright/doctor/checks.py +548 -0
  228. rocketwright/doctor/flutter.py +32 -0
  229. rocketwright/doctor/macos.py +104 -0
  230. rocketwright/doctor/real_devices.py +250 -0
  231. rocketwright/doctor/report.py +59 -0
  232. rocketwright/doctor/tap.py +142 -0
  233. rocketwright/doctor/worktree.py +90 -0
  234. rocketwright/host_copy.py +436 -0
  235. rocketwright/hosting.py +221 -0
  236. rocketwright/legacy.py +72 -0
  237. rocketwright/mcp/__init__.py +3 -0
  238. rocketwright/mcp/launcher.py +685 -0
  239. rocketwright/mcp/relay.py +794 -0
  240. rocketwright/perception/__init__.py +9 -0
  241. rocketwright/perception/backtracking.py +276 -0
  242. rocketwright/perception/bar_names.py +49 -0
  243. rocketwright/perception/budget.py +66 -0
  244. rocketwright/perception/capture.py +36 -0
  245. rocketwright/perception/imagehash.py +81 -0
  246. rocketwright/perception/in_front.py +116 -0
  247. rocketwright/perception/model.py +92 -0
  248. rocketwright/perception/occlusion.py +393 -0
  249. rocketwright/perception/ocr.py +289 -0
  250. rocketwright/perception/orientation.py +177 -0
  251. rocketwright/perception/readers.py +488 -0
  252. rocketwright/perception/settle.py +241 -0
  253. rocketwright/perception/snapshot.py +500 -0
  254. rocketwright/perception/system_alert.py +87 -0
  255. rocketwright/perception/vision/__init__.py +3 -0
  256. rocketwright/perception/vision/helper.py +355 -0
  257. rocketwright/perception/vision/probe.py +24 -0
  258. rocketwright/perception/vision/text_recognizer.swift +144 -0
  259. rocketwright/perception/wait.py +236 -0
  260. rocketwright/platform/__init__.py +3 -0
  261. rocketwright/platform/adb.py +488 -0
  262. rocketwright/platform/android_sdk.py +171 -0
  263. rocketwright/platform/codesign.py +38 -0
  264. rocketwright/platform/developer_dir.py +72 -0
  265. rocketwright/platform/device_data.py +65 -0
  266. rocketwright/platform/devicectl.py +414 -0
  267. rocketwright/platform/emulator.py +268 -0
  268. rocketwright/platform/errors.py +15 -0
  269. rocketwright/platform/flutter.py +142 -0
  270. rocketwright/platform/git.py +63 -0
  271. rocketwright/platform/identifiers.py +84 -0
  272. rocketwright/platform/images.py +61 -0
  273. rocketwright/platform/java.py +71 -0
  274. rocketwright/platform/json_lines.py +266 -0
  275. rocketwright/platform/keyboard.py +110 -0
  276. rocketwright/platform/keychain.py +79 -0
  277. rocketwright/platform/keymap.py +95 -0
  278. rocketwright/platform/local_signing.py +241 -0
  279. rocketwright/platform/lockdown.py +192 -0
  280. rocketwright/platform/macos.py +221 -0
  281. rocketwright/platform/passwords.py +393 -0
  282. rocketwright/platform/process.py +118 -0
  283. rocketwright/platform/simctl.py +400 -0
  284. rocketwright/platform/swift.py +76 -0
  285. rocketwright/platform/swiftpm.py +52 -0
  286. rocketwright/platform/usbmux.py +205 -0
  287. rocketwright/platform/xcode.py +30 -0
  288. rocketwright/platform/xcrun.py +129 -0
  289. rocketwright/protocol/__init__.py +47 -0
  290. rocketwright/protocol/_generated.py +1249 -0
  291. rocketwright/protocol/messages.py +220 -0
  292. rocketwright/py.typed +0 -0
  293. rocketwright/scope.py +106 -0
  294. rocketwright/seams.py +255 -0
  295. rocketwright/server/__init__.py +3 -0
  296. rocketwright/server/agent_routes.py +54 -0
  297. rocketwright/server/envelope.py +28 -0
  298. rocketwright/server/http_routes.py +291 -0
  299. rocketwright/server/log_redaction.py +68 -0
  300. rocketwright/server/pages.py +86 -0
  301. rocketwright/server/security.py +161 -0
  302. rocketwright/server/settings_routes.py +189 -0
  303. rocketwright/server/settings_view.py +92 -0
  304. rocketwright/server/socket_routes.py +61 -0
  305. rocketwright/server/static/viewer/embed.html +14 -0
  306. rocketwright/server/static/viewer/index.html +14 -0
  307. rocketwright/server/static/viewer/start.js +61 -0
  308. rocketwright/storage/__init__.py +3 -0
  309. rocketwright/storage/app_support.py +116 -0
  310. rocketwright/storage/claims.py +147 -0
  311. rocketwright/storage/private.py +135 -0
  312. rocketwright/testing/__init__.py +2 -0
  313. rocketwright/testing/adb.py +422 -0
  314. rocketwright/testing/android_sdk.py +44 -0
  315. rocketwright/testing/app_sdk.py +211 -0
  316. rocketwright/testing/asgi.py +96 -0
  317. rocketwright/testing/checkouts.py +72 -0
  318. rocketwright/testing/contract.py +120 -0
  319. rocketwright/testing/daemon.py +94 -0
  320. rocketwright/testing/fakes.py +1115 -0
  321. rocketwright/testing/fixtures/README.md +6 -0
  322. rocketwright/testing/fixtures/android-am-start-bad.txt +3 -0
  323. rocketwright/testing/fixtures/android-am-start.txt +8 -0
  324. rocketwright/testing/fixtures/android-logcat-uid.txt +12 -0
  325. rocketwright/testing/fixtures/android-package-missing.txt +1 -0
  326. rocketwright/testing/fixtures/android-package.txt +45 -0
  327. rocketwright/testing/fixtures/android-pm-uid.txt +2 -0
  328. rocketwright/testing/fixtures/android-uiautomator-landscape.xml +1 -0
  329. rocketwright/testing/fixtures/android-uiautomator-search.xml +1 -0
  330. rocketwright/testing/fixtures/android-uiautomator-settings.xml +1 -0
  331. rocketwright/testing/fixtures/android-window-search.txt +493 -0
  332. rocketwright/testing/fixtures/android-window-settings.txt +491 -0
  333. rocketwright/testing/fixtures/ax-alert-ios27.json +162 -0
  334. rocketwright/testing/fixtures/ax-alert-ipad-landscape-left-ios26.json +551 -0
  335. rocketwright/testing/fixtures/ax-alert-ipad-upside-down-ios26.json +491 -0
  336. rocketwright/testing/fixtures/ax-alert-turned-left-ios26.json +457 -0
  337. rocketwright/testing/fixtures/ax-alert-turned-right-ios26.json +491 -0
  338. rocketwright/testing/fixtures/ax-alert-upright-ios26.json +469 -0
  339. rocketwright/testing/fixtures/ax-app-sdk-alert.json +137 -0
  340. rocketwright/testing/fixtures/ax-app-sdk-keyboard.json +1257 -0
  341. rocketwright/testing/fixtures/ax-app-sdk-swiftui.json +340 -0
  342. rocketwright/testing/fixtures/ax-app-sdk-tagged.json +237 -0
  343. rocketwright/testing/fixtures/ax-app-sdk-uikit.json +340 -0
  344. rocketwright/testing/fixtures/ax-files-navigation-bar-de-ios26.json +551 -0
  345. rocketwright/testing/fixtures/ax-files-tab-bar-de-ios26.json +495 -0
  346. rocketwright/testing/fixtures/ax-floating-button-ios26.json +541 -0
  347. rocketwright/testing/fixtures/ax-health-tab-bar-ios26.json +488 -0
  348. rocketwright/testing/fixtures/ax-home-complete.json +1 -0
  349. rocketwright/testing/fixtures/ax-home-ios27.json +447 -0
  350. rocketwright/testing/fixtures/ax-keyboard-ios27.json +1261 -0
  351. rocketwright/testing/fixtures/ax-macos-chromium.json +5525 -0
  352. rocketwright/testing/fixtures/ax-macos-webkit.json +5927 -0
  353. rocketwright/testing/fixtures/ax-native-files-navigation-bar-de-ios26.json +427 -0
  354. rocketwright/testing/fixtures/ax-probe-ios27.json +444 -0
  355. rocketwright/testing/fixtures/ax-probe-ipad-upside-down-ios26.json +133 -0
  356. rocketwright/testing/fixtures/ax-probe-rotated-left-ios26.json +133 -0
  357. rocketwright/testing/fixtures/ax-safari-ios27.json +188 -0
  358. rocketwright/testing/fixtures/ax-safari-typed.json +1 -0
  359. rocketwright/testing/fixtures/ax-settings-back-button-ios26.json +395 -0
  360. rocketwright/testing/fixtures/ax-settings-interactable.json +1 -0
  361. rocketwright/testing/fixtures/ax-settings-ios27.json +425 -0
  362. rocketwright/testing/fixtures/ax-settings-search-field-ios26.json +426 -0
  363. rocketwright/testing/fixtures/ax-settings-toolbar-ja-ios26.json +397 -0
  364. rocketwright/testing/fixtures/ax-settings-under-navigation-bar-ios26.json +533 -0
  365. rocketwright/testing/fixtures/ax-turned-landscape-left-ios26.json +363 -0
  366. rocketwright/testing/fixtures/ax-turned-landscape-right-ios26.json +363 -0
  367. rocketwright/testing/fixtures/ax-turned-maps-alert-ios26.json +382 -0
  368. rocketwright/testing/fixtures/ax-turned-portrait-ios26.json +370 -0
  369. rocketwright/testing/fixtures/ax-turned-reminders-portrait-ios26.json +345 -0
  370. rocketwright/testing/fixtures/ax-turned-safari-landscape-left-ios26.json +1166 -0
  371. rocketwright/testing/fixtures/ax-turned-safari-landscape-right-ios26.json +1166 -0
  372. rocketwright/testing/fixtures/development-certificate.pem +24 -0
  373. rocketwright/testing/fixtures/devicectl-appearance.json +46 -0
  374. rocketwright/testing/fixtures/devicectl-apps.json +59 -0
  375. rocketwright/testing/fixtures/devicectl-devices.json +1065 -0
  376. rocketwright/testing/fixtures/devicectl-displays.json +63 -0
  377. rocketwright/testing/fixtures/devicectl-launch-missing.json +58 -0
  378. rocketwright/testing/fixtures/devicectl-launch.json +53 -0
  379. rocketwright/testing/fixtures/devicectl-lock-state.json +27 -0
  380. rocketwright/testing/fixtures/devicectl-processes.json +39 -0
  381. rocketwright/testing/fixtures/devicectl-screenshot.json +31 -0
  382. rocketwright/testing/fixtures/flutter-build-ios-error.log +24 -0
  383. rocketwright/testing/fixtures/flutter-integration-results.json +20 -0
  384. rocketwright/testing/fixtures/flutter-unit-results.json +16 -0
  385. rocketwright/testing/fixtures/gradle-aapt-error.log +55 -0
  386. rocketwright/testing/fixtures/gradle-kotlin-error.log +51 -0
  387. rocketwright/testing/fixtures/gradle-output-metadata.json +21 -0
  388. rocketwright/testing/fixtures/gradle-test-failure.log +166 -0
  389. rocketwright/testing/fixtures/junit-android-failure.xml +48 -0
  390. rocketwright/testing/fixtures/mcpbridge-answers.json +183 -0
  391. rocketwright/testing/fixtures/mcpbridge-hierarchy-alert.txt +46 -0
  392. rocketwright/testing/fixtures/mcpbridge-hierarchy-home.txt +257 -0
  393. rocketwright/testing/fixtures/mcpbridge-hierarchy-keyboard.txt +92 -0
  394. rocketwright/testing/fixtures/mcpbridge-hierarchy-probe.txt +39 -0
  395. rocketwright/testing/fixtures/mcpbridge-hierarchy-safari.txt +77 -0
  396. rocketwright/testing/fixtures/mcpbridge-hierarchy-settings.txt +169 -0
  397. rocketwright/testing/fixtures/simctl-devices.json +73 -0
  398. rocketwright/testing/fixtures/simctl-runtimes.json +114 -0
  399. rocketwright/testing/fixtures/xcodebuild-list-names.json +20 -0
  400. rocketwright/testing/fixtures/xcodebuild-list.json +17 -0
  401. rocketwright/testing/fixtures/xcodebuild-settings-test.json +55 -0
  402. rocketwright/testing/fixtures/xcodebuild-settings.json +13 -0
  403. rocketwright/testing/fixtures/xcodebuild-test-plans-none.json +3 -0
  404. rocketwright/testing/fixtures/xcodebuild-test-plans.json +10 -0
  405. rocketwright/testing/fixtures/xcresult-build-broken.json +32 -0
  406. rocketwright/testing/fixtures/xcresult-build-ok.json +27 -0
  407. rocketwright/testing/fixtures/xcresult-build-results-unbuilt.json +36 -0
  408. rocketwright/testing/fixtures/xcresult-test-summary-retries.json +56 -0
  409. rocketwright/testing/fixtures/xcresult-test-summary-swift-testing-xcode27.json +63 -0
  410. rocketwright/testing/fixtures/xcresult-test-summary-swift-testing.json +60 -0
  411. rocketwright/testing/fixtures/xcresult-test-summary-unbuilt.json +24 -0
  412. rocketwright/testing/fixtures/xcresult-test-summary.json +49 -0
  413. rocketwright/testing/fixtures/xcresult-test-tests-retries.json +165 -0
  414. rocketwright/testing/fixtures/xcresult-test-tests-swift-testing-xcode27.json +135 -0
  415. rocketwright/testing/fixtures/xcresult-test-tests-swift-testing.json +125 -0
  416. rocketwright/testing/fixtures/xcresult-test-tests.json +93 -0
  417. rocketwright/testing/fixtures/xcscheme-staging.xcscheme +91 -0
  418. rocketwright/testing/fixtures/xcscheme-test-plans.xcscheme +86 -0
  419. rocketwright/testing/fixtures/xctestplan-everything.xctestplan +38 -0
  420. rocketwright/testing/fixtures/xctestplan-units-only.xctestplan +42 -0
  421. rocketwright/testing/flutter.py +277 -0
  422. rocketwright/testing/gradle.py +123 -0
  423. rocketwright/testing/guards.py +190 -0
  424. rocketwright/testing/macos.py +92 -0
  425. rocketwright/testing/native.py +243 -0
  426. rocketwright/testing/pictures.py +58 -0
  427. rocketwright/testing/recording.py +67 -0
  428. rocketwright/testing/results.py +16 -0
  429. rocketwright/testing/rig.py +225 -0
  430. rocketwright/testing/scrcpy.py +148 -0
  431. rocketwright/testing/usbmux.py +236 -0
  432. rocketwright/testing/vision.py +86 -0
  433. rocketwright/testing/wda.py +278 -0
  434. rocketwright/tools/__init__.py +2 -0
  435. rocketwright/tools/act.py +86 -0
  436. rocketwright/tools/app.py +209 -0
  437. rocketwright/tools/context.py +232 -0
  438. rocketwright/tools/device.py +510 -0
  439. rocketwright/tools/flow.py +356 -0
  440. rocketwright/tools/login.py +281 -0
  441. rocketwright/tools/matrix.py +397 -0
  442. rocketwright/tools/record.py +184 -0
  443. rocketwright/tools/registry.py +116 -0
  444. rocketwright/tools/results.py +48 -0
  445. rocketwright/tools/schemas.py +648 -0
  446. rocketwright/tools/screenshot.py +158 -0
  447. rocketwright/tools/snapshot.py +36 -0
  448. rocketwright/validation.py +46 -0
  449. rocketwright-3.12.0.dist-info/METADATA +324 -0
  450. rocketwright-3.12.0.dist-info/RECORD +455 -0
  451. rocketwright-3.12.0.dist-info/WHEEL +4 -0
  452. rocketwright-3.12.0.dist-info/entry_points.txt +3 -0
  453. rocketwright-3.12.0.dist-info/licenses/LICENSE +202 -0
  454. rocketwright-3.12.0.dist-info/licenses/NOTICE +20 -0
  455. rocketwright-3.12.0.dist-info/licenses/THIRD_PARTY_LICENSES.md +158 -0
@@ -0,0 +1,6 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """Rocketwright: mirror and drive the iOS Simulator from AI agents and the browser."""
3
+
4
+ from rocketwright._version import __version__
5
+
6
+ __all__ = ["__version__"]
@@ -0,0 +1,7 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """``python -m rocketwright``: the same as the ``rocketwright`` command."""
3
+
4
+ from rocketwright.cli.main import main
5
+
6
+ if __name__ == "__main__": # pragma: no cover - run as a module
7
+ raise SystemExit(main())
Binary file
@@ -0,0 +1,43 @@
1
+ // swift-tools-version:6.0
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ //
4
+ // Rocketwright's native helper: the screen, input and element tree of one booted simulator, served to Rocketwright on a unix
5
+ // socket -- without idb_companion.
6
+ //
7
+ // `HelperCore` is everything that can be decided without a simulator: the wire protocol, what a screenshot or a stream
8
+ // is cut to, how input maps onto each HID transport, and how an accessibility tree becomes Rocketwright's document. It is
9
+ // unit-tested to the per-file coverage bar. `HelperPlatform` is the thin layer that reaches Apple's private simulator
10
+ // frameworks through the Objective-C runtime; it is exercised against real simulators by Rocketwright's live suite.
11
+
12
+ import PackageDescription
13
+
14
+ let package = Package(
15
+ name: "RocketwrightHelper",
16
+ platforms: [.macOS(.v14)],
17
+ products: [
18
+ .executable(name: "rocketwright-helper", targets: ["rocketwright-helper"]),
19
+ ],
20
+ targets: [
21
+ .target(name: "HelperCore"),
22
+ .target(name: "ObjCGuard"),
23
+ .target(
24
+ name: "HelperPlatform",
25
+ dependencies: ["HelperCore", "ObjCGuard"],
26
+ swiftSettings: [.swiftLanguageMode(.v5)]
27
+ ),
28
+ .executableTarget(
29
+ name: "rocketwright-helper",
30
+ dependencies: ["HelperCore", "HelperPlatform"],
31
+ swiftSettings: [.swiftLanguageMode(.v5)],
32
+ // The Info.plist macOS reads to ask for the Camera, which reading a cabled device's screen needs, embedded
33
+ // in the program itself.
34
+ linkerSettings: [
35
+ .unsafeFlags([
36
+ "-Xlinker", "-sectcreate", "-Xlinker", "__TEXT", "-Xlinker", "__info_plist",
37
+ "-Xlinker", "\(Context.packageDirectory)/Support/Info.plist",
38
+ ]),
39
+ ]
40
+ ),
41
+ .testTarget(name: "HelperCoreTests", dependencies: ["HelperCore"]),
42
+ ]
43
+ )
@@ -0,0 +1,179 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import Foundation
3
+
4
+ /// A rectangle in points, from the top left.
5
+ public struct Rect: Equatable, Sendable {
6
+ public let x: Double
7
+ public let y: Double
8
+ public let width: Double
9
+ public let height: Double
10
+
11
+ public init(x: Double, y: Double, width: Double, height: Double) {
12
+ self.x = x
13
+ self.y = y
14
+ self.width = width
15
+ self.height = height
16
+ }
17
+
18
+ var json: JSONValue {
19
+ .object(["x": .number(x), "y": .number(y), "width": .number(width), "height": .number(height)])
20
+ }
21
+ }
22
+
23
+ /// An accessibility value: text, a number, or a switch's state.
24
+ public enum AccessibilityValue: Equatable, Sendable {
25
+ case text(String)
26
+ case number(Double)
27
+
28
+ var json: JSONValue {
29
+ switch self {
30
+ case .text(let text): return .string(text)
31
+ case .number(let number): return .number(number)
32
+ }
33
+ }
34
+ }
35
+
36
+ /// One element of a screen's accessibility tree, read from the device.
37
+ ///
38
+ /// Only what Rocketwright reads of an element is kept. Each attribute is a round trip to the simulator, and a snapshot
39
+ /// reads every element, so an attribute nothing reads -- help text, custom actions -- is not asked for at all. A role's
40
+ /// description is asked of a group only: it is how a navigation bar says what it is.
41
+ public struct AXNode: Equatable, Sendable {
42
+ /// The role of an element that only holds others, as a navigation bar, a tab bar and a toolbar are listed.
43
+ public static let groupRole = "AXGroup"
44
+
45
+ /// Its role as the accessibility API says it, ``AXButton``.
46
+ public var role: String?
47
+ public var subrole: String?
48
+ /// What its role is called, in the device's language: ``Nav bar`` for a navigation bar UIKit lists as a group.
49
+ public var roleDescription: String?
50
+ public var label: String?
51
+ public var title: String?
52
+ public var identifier: String?
53
+ public var value: AccessibilityValue?
54
+ public var frame: Rect
55
+ /// Its traits as the bits iOS keeps them in; nil when it does not say.
56
+ public var traits: UInt64?
57
+ public var enabled: Bool
58
+ public var children: [AXNode]
59
+
60
+ public var isSecure: Bool { role == "AXSecureTextField" || subrole == "AXSecureTextField" }
61
+
62
+ public init(
63
+ role: String? = nil, subrole: String? = nil, roleDescription: String? = nil, label: String? = nil,
64
+ title: String? = nil, identifier: String? = nil, value: AccessibilityValue? = nil,
65
+ frame: Rect = Rect(x: 0, y: 0, width: 0, height: 0), traits: UInt64? = nil, enabled: Bool = true,
66
+ children: [AXNode] = []
67
+ ) {
68
+ self.role = role
69
+ self.subrole = subrole
70
+ self.roleDescription = roleDescription
71
+ self.label = label
72
+ self.title = title
73
+ self.identifier = identifier
74
+ self.value = value
75
+ self.frame = frame
76
+ self.traits = traits
77
+ self.enabled = enabled
78
+ self.children = children
79
+ }
80
+ }
81
+
82
+ /// The names of the traits iOS gives an element, bit by bit.
83
+ ///
84
+ /// The bits are AXRuntime's ``kAX*Trait`` constants, which run from 0 upward in this order; the names are the constants
85
+ /// less their prefix and suffix, which is how idb_companion names them too.
86
+ public enum AXTraits {
87
+ public static let names = [
88
+ "Button", "Link", "Image", "Selected", "PlaysSound", "KeyboardKey", "StaticText", "SummaryElement",
89
+ "NotEnabled", "UpdatesFrequently", "SearchField", "StartsMediaSession", "Adjustable",
90
+ "AllowsDirectInteraction", "CausesPageTurn", "TabBar", "Header", "WebContent", "TextEntry", "PickerElement",
91
+ "RadioButton", "IsEditing", "LaunchIcon", "StatusBarElement", "SecureTextField", "Inactive", "Footer",
92
+ "BackButton", "TabButton", "AutoCorrectCandidate", "DeleteKey", "SelectionDismissesItem", "Visited",
93
+ "Scrollable", "Spacer", "TableIndex", "Map", "TextOperationsAvailable", "Draggable", "GesturePracticeRegion",
94
+ "PopupButton", "AllowsNativeSliding", "MathEquation", "ContainedByTable", "ContainedByList", "TouchContainer",
95
+ "SupportsZoom", "TextArea", "BookContent", "ContainedByLandmark", "FolderIcon", "ReadOnly", "MenuItem",
96
+ "Toggle", "IgnoreItemChooser", "SupportsTrackingDetail", "Alert", "ContainedByFieldset",
97
+ "AllowsLayoutChangeInStatusBar",
98
+ ]
99
+
100
+ /// The names of the bits set: ``None`` for none, and ``Unknown`` for bits no name is known for.
101
+ public static func names(_ mask: UInt64) -> [String] {
102
+ guard mask != 0 else { return ["None"] }
103
+ var found = names.indices.filter { mask & (1 << UInt64($0)) != 0 }.map { names[$0] }
104
+ if mask >> UInt64(names.count) != 0 { found.append("Unknown") }
105
+ return found
106
+ }
107
+ }
108
+
109
+ /// The document Rocketwright reads a screen from: the tree of the elements a person or an agent can act on or read.
110
+ ///
111
+ /// Its shape is idb_companion's consolidated accessibility document, with the keys Rocketwright reads, so Rocketwright reads
112
+ /// either one the same way. The
113
+ /// tree keeps what is worth reporting -- an element with a label, an identifier, or a role that is acted on -- and an
114
+ /// element that is not has its kept descendants take its place, so a button inside an unlabelled group is kept.
115
+ public enum AXDocument {
116
+ /// The roles, less their ``AX`` prefix, that are kept whatever they say.
117
+ public static let actionableRoles: Set<String> = [
118
+ "Button", "Cell", "TextField", "SecureTextField", "SearchField", "Switch", "Toggle", "Link", "MenuItem",
119
+ "Slider", "CheckBox", "RadioButton", "SegmentedControl", "Stepper", "PopUpButton", "Picker", "PickerWheel",
120
+ "Tab", "Key", "DisclosureTriangle",
121
+ ]
122
+
123
+ /// The document of a tree. Its frames are the interface's points, and its ``orientation`` says how that interface
124
+ /// lies on the screen, whose portrait size ``screen`` is.
125
+ public static func make(_ tree: AXTree, screen: ScreenGeometry) -> JSONValue {
126
+ let elements = kept(tree.root)
127
+ return .object([
128
+ "backend": .string("native"),
129
+ "elements": .array(elements),
130
+ "modal": .null,
131
+ "orientation": .string(tree.orientation.rawValue),
132
+ "screen": .object([
133
+ "coordinate_space": .string("screen"),
134
+ "width": .int(screen.widthPt),
135
+ "height": .int(screen.heightPt),
136
+ ]),
137
+ "truncated": .bool(false),
138
+ ])
139
+ }
140
+
141
+ /// What was found at points of the screen: each element alone, as the document writes one, or null.
142
+ public static func found(_ nodes: [AXNode?]) -> JSONValue {
143
+ .object(["elements": .array(nodes.map { $0.map { element($0, children: []) } ?? .null })])
144
+ }
145
+
146
+ /// A role without its ``AX`` prefix: ``AXButton`` is ``Button``.
147
+ public static func type(of role: String?) -> String? {
148
+ guard let role else { return nil }
149
+ return role.hasPrefix("AX") ? String(role.dropFirst(2)) : role
150
+ }
151
+
152
+ static func keeps(_ node: AXNode) -> Bool {
153
+ if let label = node.label, !label.isEmpty { return true }
154
+ if let identifier = node.identifier, !identifier.isEmpty { return true }
155
+ return type(of: node.role).map(actionableRoles.contains) ?? false
156
+ }
157
+
158
+ static func kept(_ node: AXNode) -> [JSONValue] {
159
+ let children = node.isSecure ? [] : node.children.flatMap(kept)
160
+ guard keeps(node) else { return children }
161
+ return [element(node, children: children)]
162
+ }
163
+
164
+ static func element(_ node: AXNode, children: [JSONValue]) -> JSONValue {
165
+ .object([
166
+ "type": .text(node.isSecure ? "SecureTextField" : type(of: node.role)),
167
+ "subrole": .text(node.subrole),
168
+ "role_description": .text(node.roleDescription),
169
+ "label": .text(node.label),
170
+ "title": .text(node.title),
171
+ "identifier": .text(node.identifier),
172
+ "value": node.isSecure ? .null : node.value?.json ?? .null,
173
+ "frame": node.frame.json,
174
+ "traits": node.traits.map { .array(AXTraits.names($0).map(JSONValue.string)) } ?? .null,
175
+ "enabled": .bool(node.enabled),
176
+ "children": .array(children),
177
+ ])
178
+ }
179
+ }
@@ -0,0 +1,245 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import Foundation
3
+
4
+ /// What the helper was started to do.
5
+ public enum Command: Equatable, Sendable {
6
+ /// Print its versions as JSON and exit.
7
+ case version
8
+ /// Check this helper's macOS permissions without requesting either grant.
9
+ case macApps
10
+ case window(MacWindowOptions)
11
+ case permissions
12
+ /// Serve one device on a unix socket until Rocketwright lets go of it.
13
+ case serve(ServeOptions)
14
+ /// Reach a device the way serving would -- its screen, a picture, input and the element tree -- say what worked as
15
+ /// JSON, and exit 0 only if all of it did.
16
+ case selfCheck(DeviceOptions)
17
+ /// Render a recording as the job at a path asks -- an MP4, a GIF, its touches drawn in -- say what it wrote as JSON,
18
+ /// and exit.
19
+ case render(job: String)
20
+ /// Serve a cabled real device's screen, read through AVFoundation, on a unix socket until Rocketwright lets go of it.
21
+ case capture(CaptureOptions)
22
+
23
+ public static let usage = """
24
+ usage: rocketwright-helper version
25
+ rocketwright-helper permissions
26
+ rocketwright-helper mac-apps
27
+ rocketwright-helper window --pid PID --socket PATH [--window-id ID] [--parent-pid PID] [--accessibility on|off]
28
+ [--overlay on|off]
29
+ rocketwright-helper serve --udid UDID --socket PATH [--parent-pid PID] [--hid auto|dtuhid|indigo]
30
+ [--idle-key-frames on|off] [--log-level debug|info|warning|error]
31
+ rocketwright-helper self-check --udid UDID [--hid auto|dtuhid|indigo]
32
+ rocketwright-helper render --job PATH
33
+ rocketwright-helper capture --udid UDID --name NAME --socket PATH --width-px N --height-px N --scale N
34
+ [--capture-id ID] [--reference PATH] [--parent-pid PID] [--wait SECONDS] [--linger SECONDS]
35
+ [--idle-key-frames on|off] [--log-level debug|info|warning|error]
36
+ """
37
+
38
+ public static func parse(_ arguments: [String]) throws -> Command {
39
+ guard let verb = arguments.first else { throw HelperFailure(usage, status: 400) }
40
+ var options = try flags(Array(arguments.dropFirst()))
41
+ switch verb {
42
+ case "version":
43
+ try refuseLeftovers(options)
44
+ return .version
45
+ case "mac-apps":
46
+ try refuseLeftovers(options)
47
+ return .macApps
48
+ case "window":
49
+ let window = try MacWindowOptions.take(&options)
50
+ try refuseLeftovers(options)
51
+ return .window(window)
52
+ case "permissions":
53
+ try refuseLeftovers(options)
54
+ return .permissions
55
+ case "serve":
56
+ let device = try DeviceOptions.take(&options)
57
+ guard let socket = options.removeValue(forKey: "socket"), !socket.isEmpty else {
58
+ throw HelperFailure("serve needs --socket\n\(usage)", status: 400)
59
+ }
60
+ let parent = try options.removeValue(forKey: "parent-pid").map(pid)
61
+ let idle = try options.removeValue(forKey: "idle-key-frames").map(onOff) ?? true
62
+ let level = try options.removeValue(forKey: "log-level").map(logLevel) ?? .info
63
+ try refuseLeftovers(options)
64
+ return .serve(ServeOptions(device: device, socket: socket, parentPid: parent, idleKeyFrames: idle, logLevel: level))
65
+ case "self-check":
66
+ let device = try DeviceOptions.take(&options)
67
+ try refuseLeftovers(options)
68
+ return .selfCheck(device)
69
+ case "render":
70
+ guard let job = options.removeValue(forKey: "job"), job.hasPrefix("/") else {
71
+ throw HelperFailure("render needs --job and the absolute path of its job\n\(usage)", status: 400)
72
+ }
73
+ try refuseLeftovers(options)
74
+ return .render(job: job)
75
+ case "capture":
76
+ let capture = try CaptureOptions.take(&options)
77
+ try refuseLeftovers(options)
78
+ return .capture(capture)
79
+ default:
80
+ throw HelperFailure("not a command: \(verb)\n\(usage)", status: 400)
81
+ }
82
+ }
83
+
84
+ static func flags(_ arguments: [String]) throws -> [String: String] {
85
+ var found: [String: String] = [:]
86
+ var rest = arguments[...]
87
+ while let flag = rest.popFirst() {
88
+ guard flag.hasPrefix("--"), flag.count > 2 else { throw HelperFailure("not a flag: \(flag)\n\(usage)", status: 400) }
89
+ guard let value = rest.popFirst() else { throw HelperFailure("\(flag) needs a value", status: 400) }
90
+ found[String(flag.dropFirst(2))] = value
91
+ }
92
+ return found
93
+ }
94
+
95
+ static func refuseLeftovers(_ options: [String: String]) throws {
96
+ guard let unknown = options.keys.sorted().first else { return }
97
+ throw HelperFailure("not a flag here: --\(unknown)\n\(usage)", status: 400)
98
+ }
99
+
100
+ static func pid(_ text: String) throws -> Int32 {
101
+ guard let value = Int32(text), value > 1 else { throw HelperFailure("not a pid: \(text)", status: 400) }
102
+ return value
103
+ }
104
+
105
+ static func onOff(_ text: String) throws -> Bool {
106
+ switch text {
107
+ case "on": return true
108
+ case "off": return false
109
+ default: throw HelperFailure("--idle-key-frames is on or off, not \(text)", status: 400)
110
+ }
111
+ }
112
+
113
+ static func logLevel(_ text: String) throws -> Log.Level {
114
+ guard let level = Log.Level(name: text) else { throw HelperFailure("not a log level: \(text)", status: 400) }
115
+ return level
116
+ }
117
+ }
118
+
119
+ /// Which device, and how input should reach it.
120
+ public struct DeviceOptions: Equatable, Sendable {
121
+ public let udid: String
122
+ public let hid: TransportPolicy.Preference
123
+
124
+ public init(udid: String, hid: TransportPolicy.Preference = .auto) {
125
+ self.udid = udid
126
+ self.hid = hid
127
+ }
128
+
129
+ static func take(_ options: inout [String: String]) throws -> DeviceOptions {
130
+ guard let udid = options.removeValue(forKey: "udid"), !udid.isEmpty else {
131
+ throw HelperFailure("a device is named with --udid\n\(Command.usage)", status: 400)
132
+ }
133
+ let hid = try options.removeValue(forKey: "hid").map { text in
134
+ guard let preference = TransportPolicy.Preference(rawValue: text) else {
135
+ throw HelperFailure("--hid is auto, dtuhid or indigo, not \(text)", status: 400)
136
+ }
137
+ return preference
138
+ } ?? .auto
139
+ return DeviceOptions(udid: udid, hid: hid)
140
+ }
141
+ }
142
+
143
+ public struct ServeOptions: Equatable, Sendable {
144
+ public let device: DeviceOptions
145
+ public let socket: String
146
+ /// The process to outlive by no more than a moment: when it is gone, so is the helper.
147
+ public let parentPid: Int32?
148
+ public let idleKeyFrames: Bool
149
+ public let logLevel: Log.Level
150
+
151
+ public init(device: DeviceOptions, socket: String, parentPid: Int32? = nil, idleKeyFrames: Bool = true, logLevel: Log.Level = .info) {
152
+ self.device = device
153
+ self.socket = socket
154
+ self.parentPid = parentPid
155
+ self.idleKeyFrames = idleKeyFrames
156
+ self.logLevel = logLevel
157
+ }
158
+ }
159
+
160
+ /// What `rocketwright-helper version` prints.
161
+ public struct VersionReport: Equatable, Sendable, Encodable {
162
+ /// What this helper can do besides serving a simulator, so Rocketwright asks only a helper that can.
163
+ public static let features = ["render", "capture", "rotate", "at", "mac-capture", "mac-overlay"]
164
+
165
+ public let version: String
166
+ public let wire: Int
167
+ public let coreSimulator: String?
168
+ public let features: [String]
169
+
170
+ public init(coreSimulator: String?) {
171
+ version = HelperVersion.current
172
+ wire = Wire.version
173
+ self.coreSimulator = coreSimulator
174
+ features = VersionReport.features
175
+ }
176
+
177
+ enum CodingKeys: String, CodingKey {
178
+ case version, wire, coreSimulator = "core_simulator", features
179
+ }
180
+
181
+ public func encode(to encoder: Encoder) throws {
182
+ var container = encoder.container(keyedBy: CodingKeys.self)
183
+ try container.encode(version, forKey: .version)
184
+ try container.encode(wire, forKey: .wire)
185
+ try container.encode(coreSimulator, forKey: .coreSimulator)
186
+ try container.encode(features, forKey: .features)
187
+ }
188
+ }
189
+
190
+ /// What `rocketwright-helper self-check` prints: each part of a device and whether it was reached.
191
+ public struct SelfCheckReport: Equatable, Sendable, Encodable {
192
+ public struct Part: Equatable, Sendable, Encodable {
193
+ public let name: String
194
+ public let ok: Bool
195
+ public let detail: String
196
+
197
+ public init(name: String, ok: Bool, detail: String) {
198
+ self.name = name
199
+ self.ok = ok
200
+ self.detail = detail
201
+ }
202
+ }
203
+
204
+ public let parts: [Part]
205
+ public var ok: Bool { parts.allSatisfy(\.ok) }
206
+
207
+ public init(parts: [Part]) {
208
+ self.parts = parts
209
+ }
210
+
211
+ enum CodingKeys: String, CodingKey { case ok, parts }
212
+
213
+ public func encode(to encoder: Encoder) throws {
214
+ var container = encoder.container(keyedBy: CodingKeys.self)
215
+ try container.encode(ok, forKey: .ok)
216
+ try container.encode(parts, forKey: .parts)
217
+ }
218
+
219
+ /// Check each part of a device in turn: a part that fails does not stop the next from being checked.
220
+ public static func run(_ device: Device) async -> SelfCheckReport {
221
+ var parts: [Part] = []
222
+ func check(_ name: String, _ body: () async throws -> String) async {
223
+ do {
224
+ parts.append(Part(name: name, ok: true, detail: try await body()))
225
+ } catch {
226
+ parts.append(Part(name: name, ok: false, detail: HelperFailure.from(error).message))
227
+ }
228
+ }
229
+ await check("screen") {
230
+ let screen = try device.screen()
231
+ return "\(screen.widthPx)x\(screen.heightPx) pixels, \(screen.widthPt)x\(screen.heightPt) points"
232
+ }
233
+ await check("screenshot") {
234
+ let jpeg = try await device.screenshot(ScreenshotRequest(maxWidth: 160, quality: 40))
235
+ return "\(jpeg.width)x\(jpeg.height), \(jpeg.data.count) bytes"
236
+ }
237
+ await check("input") { "through \(try device.input().transport.name)" }
238
+ await check("element tree") { "\(count(try await device.tree().root)) elements" }
239
+ return SelfCheckReport(parts: parts)
240
+ }
241
+
242
+ static func count(_ node: AXNode) -> Int {
243
+ 1 + node.children.reduce(0) { $0 + count($1) }
244
+ }
245
+ }