spana-test 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/.agents/skills/spana-testing/SKILL.md +301 -0
  2. package/README.md +33 -4
  3. package/dist/agent/index.d.ts +81 -0
  4. package/dist/agent/index.js +21 -0
  5. package/dist/allure-PTTVORQ6.js +124 -0
  6. package/dist/allure-PTTVORQ6.js.map +1 -0
  7. package/dist/android-PAPJJWVN.js +34 -0
  8. package/dist/android-PAPJJWVN.js.map +1 -0
  9. package/dist/chunk-3FSZNKEF.js +62 -0
  10. package/dist/chunk-3FSZNKEF.js.map +1 -0
  11. package/dist/chunk-53MUJUJY.js +113 -0
  12. package/dist/chunk-53MUJUJY.js.map +1 -0
  13. package/dist/chunk-5XO6S7AI.js +134 -0
  14. package/dist/chunk-5XO6S7AI.js.map +1 -0
  15. package/dist/chunk-BZRLA4Z3.js +82 -0
  16. package/dist/chunk-BZRLA4Z3.js.map +1 -0
  17. package/dist/{chunk-VZZH66U5.js → chunk-CKJQX73M.js} +896 -844
  18. package/dist/chunk-CKJQX73M.js.map +1 -0
  19. package/dist/chunk-DGUM43GV.js +11 -0
  20. package/dist/chunk-DGUM43GV.js.map +1 -0
  21. package/dist/{chunk-CYEDLQJ4.js → chunk-GZK22EIE.js} +76 -102
  22. package/dist/chunk-GZK22EIE.js.map +1 -0
  23. package/dist/chunk-PANFRTIU.js +310 -0
  24. package/dist/chunk-PANFRTIU.js.map +1 -0
  25. package/dist/chunk-PWEOJKUF.js +473 -0
  26. package/dist/chunk-PWEOJKUF.js.map +1 -0
  27. package/dist/chunk-RJ5VPHVX.js +127 -0
  28. package/dist/chunk-RJ5VPHVX.js.map +1 -0
  29. package/dist/chunk-RK4Z6C7M.js +248 -0
  30. package/dist/chunk-RK4Z6C7M.js.map +1 -0
  31. package/dist/chunk-U564GCO2.js +259 -0
  32. package/dist/chunk-U564GCO2.js.map +1 -0
  33. package/dist/chunk-V62HFH6E.js +269 -0
  34. package/dist/chunk-V62HFH6E.js.map +1 -0
  35. package/dist/chunk-VDWWIVM6.js +303 -0
  36. package/dist/chunk-VDWWIVM6.js.map +1 -0
  37. package/dist/{discover-XIRJTZ7Z.js → chunk-WIJYK22K.js} +12 -5
  38. package/dist/{discover-XIRJTZ7Z.js.map → chunk-WIJYK22K.js.map} +1 -1
  39. package/dist/cli.js +134 -16
  40. package/dist/cli.js.map +1 -1
  41. package/dist/compiler-G75RIIYS.js +312 -0
  42. package/dist/compiler-G75RIIYS.js.map +1 -0
  43. package/dist/config-Dg9O0rcQ.d.ts +219 -0
  44. package/dist/config-loader-JJ5RPP53.js +9 -0
  45. package/dist/config-loader-JJ5RPP53.js.map +1 -0
  46. package/dist/console-FV4RJPO4.js +132 -0
  47. package/dist/console-FV4RJPO4.js.map +1 -0
  48. package/dist/discover-RWBKI5IB.js +14 -0
  49. package/dist/discover-RWBKI5IB.js.map +1 -0
  50. package/dist/element-CGteXiXB.d.ts +23 -0
  51. package/dist/flow-D-_tlLpp.d.ts +99 -0
  52. package/dist/gherkin/steps.d.ts +32 -0
  53. package/dist/gherkin/steps.js +39 -0
  54. package/dist/gherkin/steps.js.map +1 -0
  55. package/dist/{html-GRB34S6X.js → html-JP2HBIJQ.js} +54 -20
  56. package/dist/html-JP2HBIJQ.js.map +1 -0
  57. package/dist/index.d.ts +4 -157
  58. package/dist/index.js +36 -165
  59. package/dist/index.js.map +1 -1
  60. package/dist/init-command-CELKL2CX.js +105 -0
  61. package/dist/init-command-CELKL2CX.js.map +1 -0
  62. package/dist/installer-R6NX7BYQ.js +20 -0
  63. package/dist/installer-R6NX7BYQ.js.map +1 -0
  64. package/dist/ios-ZZU6DHH7.js +48 -0
  65. package/dist/ios-ZZU6DHH7.js.map +1 -0
  66. package/dist/{json-FK2NSRGC.js → json-JMRPUVY2.js} +2 -2
  67. package/dist/{junit-NAGZJOGQ.js → junit-UDY5JG22.js} +14 -3
  68. package/dist/junit-UDY5JG22.js.map +1 -0
  69. package/dist/provider-CUWPULGC.js +10 -0
  70. package/dist/provider-CUWPULGC.js.map +1 -0
  71. package/dist/redact-IDA3C4UH.js +77 -0
  72. package/dist/redact-IDA3C4UH.js.map +1 -0
  73. package/dist/runner-QEF6PJOE.js +20 -0
  74. package/dist/runner-QEF6PJOE.js.map +1 -0
  75. package/dist/server-MMK7PZIH.js +505 -0
  76. package/dist/server-MMK7PZIH.js.map +1 -0
  77. package/dist/session-FBJABNXL.js +16 -0
  78. package/dist/session-FBJABNXL.js.map +1 -0
  79. package/dist/studio-command-CDVPREMG.js +24 -0
  80. package/dist/studio-command-CDVPREMG.js.map +1 -0
  81. package/dist/test-command-SB5KYPQI.js +1929 -0
  82. package/dist/test-command-SB5KYPQI.js.map +1 -0
  83. package/dist/validator-CFQ55NUQ.js +13 -0
  84. package/dist/validator-CFQ55NUQ.js.map +1 -0
  85. package/package.json +41 -4
  86. package/studio-dist/assets/index-CPdpC9i-.css +1 -0
  87. package/studio-dist/assets/index-L1Wd0vop.js +183 -0
  88. package/studio-dist/index.html +13 -0
  89. package/dist/chunk-CYEDLQJ4.js.map +0 -1
  90. package/dist/chunk-PVNNKPBW.js +0 -64
  91. package/dist/chunk-PVNNKPBW.js.map +0 -1
  92. package/dist/chunk-VZZH66U5.js.map +0 -1
  93. package/dist/console-GPV3M3PC.js +0 -71
  94. package/dist/console-GPV3M3PC.js.map +0 -1
  95. package/dist/html-GRB34S6X.js.map +0 -1
  96. package/dist/junit-NAGZJOGQ.js.map +0 -1
  97. package/dist/runner-LBQUCG3K.js +0 -12
  98. package/dist/session-U7VP5J2C.js +0 -122
  99. package/dist/session-U7VP5J2C.js.map +0 -1
  100. package/dist/test-command-WPYLJYIK.js +0 -636
  101. package/dist/test-command-WPYLJYIK.js.map +0 -1
  102. package/dist/validator-J4YSBB66.js +0 -33
  103. package/dist/validator-J4YSBB66.js.map +0 -1
  104. /package/dist/{runner-LBQUCG3K.js.map → agent/index.js.map} +0 -0
  105. /package/dist/{json-FK2NSRGC.js.map → json-JMRPUVY2.js.map} +0 -0
@@ -0,0 +1,269 @@
1
+ import {
2
+ __require
3
+ } from "./chunk-DGUM43GV.js";
4
+
5
+ // src/device/ios.ts
6
+ import { execFileSync, execSync } from "child_process";
7
+ function listIOSSimulators() {
8
+ try {
9
+ const output = execSync("xcrun simctl list devices -j", { encoding: "utf-8" });
10
+ const data = JSON.parse(output);
11
+ const simulators = [];
12
+ for (const [runtime, devices] of Object.entries(data.devices ?? {})) {
13
+ const runtimeName = runtime.replace("com.apple.CoreSimulator.SimRuntime.", "").replace(/-/g, ".");
14
+ for (const device of devices) {
15
+ simulators.push({
16
+ udid: device.udid,
17
+ name: device.name,
18
+ state: device.state,
19
+ runtime: runtimeName,
20
+ isAvailable: device.isAvailable ?? true
21
+ });
22
+ }
23
+ }
24
+ return simulators;
25
+ } catch {
26
+ return [];
27
+ }
28
+ }
29
+ function listBootedSimulators() {
30
+ return listIOSSimulators().filter((s) => s.state === "Booted" && s.isAvailable);
31
+ }
32
+ function firstIOSSimulator() {
33
+ const booted = listBootedSimulators();
34
+ if (booted.length > 0) return booted[0];
35
+ const available = listIOSSimulators().filter((s) => s.isAvailable);
36
+ return available[0] ?? null;
37
+ }
38
+ function hasAppInstalledOnSimulator(udid, bundleId) {
39
+ if (!bundleId) return false;
40
+ try {
41
+ execSync(`xcrun simctl get_app_container ${udid} ${bundleId} app`, { stdio: "ignore" });
42
+ return true;
43
+ } catch {
44
+ return false;
45
+ }
46
+ }
47
+ function firstIOSSimulatorWithApp(bundleId) {
48
+ const bootedWithApp = listBootedSimulators().find(
49
+ (sim) => hasAppInstalledOnSimulator(sim.udid, bundleId)
50
+ );
51
+ if (bootedWithApp) return bootedWithApp;
52
+ const availableWithApp = listIOSSimulators().filter((sim) => sim.isAvailable).find((sim) => hasAppInstalledOnSimulator(sim.udid, bundleId));
53
+ if (availableWithApp) return availableWithApp;
54
+ return firstIOSSimulator();
55
+ }
56
+ function ensureIOSSimulator(bundleId) {
57
+ const sim = bundleId ? firstIOSSimulatorWithApp(bundleId) : firstIOSSimulator();
58
+ if (!sim) return null;
59
+ if (sim.state !== "Booted") {
60
+ console.log(`Booting iOS simulator "${sim.name}"...`);
61
+ bootSimulator(sim.udid);
62
+ }
63
+ return sim;
64
+ }
65
+ function bootSimulator(udid) {
66
+ try {
67
+ execSync(`xcrun simctl boot ${udid}`, { stdio: "ignore" });
68
+ } catch {
69
+ }
70
+ }
71
+ function installOnSimulator(udid, appPath) {
72
+ execSync(`xcrun simctl install ${udid} ${appPath}`);
73
+ }
74
+ function launchOnSimulator(udid, bundleId) {
75
+ execSync(`xcrun simctl launch ${udid} ${bundleId}`);
76
+ }
77
+ function launchWithUrlOnSimulator(udid, bundleId, url) {
78
+ execFileSync("xcrun", ["simctl", "launch", udid, bundleId, "--open-url", url]);
79
+ }
80
+ function installedUrlSchemesOnSimulator(udid, bundleId) {
81
+ if (!bundleId) return [];
82
+ try {
83
+ const appPath = execSync(`xcrun simctl get_app_container ${udid} ${bundleId} app`, {
84
+ encoding: "utf-8"
85
+ }).trim();
86
+ const raw = execFileSync(
87
+ "plutil",
88
+ ["-extract", "CFBundleURLTypes", "json", "-o", "-", `${appPath}/Info.plist`],
89
+ {
90
+ encoding: "utf-8"
91
+ }
92
+ );
93
+ const urlTypes = JSON.parse(raw);
94
+ return urlTypes.flatMap((entry) => entry.CFBundleURLSchemes ?? []);
95
+ } catch {
96
+ return [];
97
+ }
98
+ }
99
+ function openUrlOnSimulator(udid, url) {
100
+ execFileSync("xcrun", ["simctl", "openurl", udid, url], { stdio: "ignore" });
101
+ }
102
+ function terminateOnSimulator(udid, bundleId) {
103
+ try {
104
+ execSync(`xcrun simctl terminate ${udid} ${bundleId}`, { stdio: "ignore" });
105
+ } catch {
106
+ }
107
+ }
108
+ function listIOSPhysicalDevices() {
109
+ try {
110
+ const tmpFile = `/tmp/spana-devicectl-${Date.now()}.json`;
111
+ execSync(`xcrun devicectl list devices --json-output ${tmpFile} 2>/dev/null`, {
112
+ timeout: 1e4
113
+ });
114
+ const { readFileSync, unlinkSync } = __require("fs");
115
+ const output = readFileSync(tmpFile, "utf-8");
116
+ try {
117
+ unlinkSync(tmpFile);
118
+ } catch {
119
+ }
120
+ const data = JSON.parse(output);
121
+ const devices = [];
122
+ for (const device of data?.result?.devices ?? []) {
123
+ const deviceType = device.hardwareProperties?.deviceType ?? "";
124
+ const transport = device.connectionProperties?.transportType;
125
+ const state = device.connectionProperties?.tunnelState;
126
+ if ((deviceType === "iPhone" || deviceType === "iPad") && transport && state !== "unavailable") {
127
+ devices.push({
128
+ udid: device.hardwareProperties?.udid ?? device.identifier,
129
+ name: device.deviceProperties?.name ?? "Unknown",
130
+ connectionType: transport === "wired" ? "USB" : transport ?? "unknown"
131
+ });
132
+ }
133
+ }
134
+ return devices;
135
+ } catch {
136
+ }
137
+ try {
138
+ let walkUSB2 = function(items) {
139
+ for (const item of items) {
140
+ if (item.serial_num && /iPhone|iPad|iPod/i.test(item._name ?? "")) {
141
+ devices.push({
142
+ udid: item.serial_num.replace(/-/g, ""),
143
+ name: item._name ?? "iOS Device",
144
+ connectionType: "USB"
145
+ });
146
+ }
147
+ if (item._items) walkUSB2(item._items);
148
+ }
149
+ };
150
+ var walkUSB = walkUSB2;
151
+ const output = execSync("system_profiler SPUSBDataType -json 2>/dev/null", {
152
+ encoding: "utf-8",
153
+ timeout: 1e4
154
+ });
155
+ const data = JSON.parse(output);
156
+ const devices = [];
157
+ walkUSB2(data.SPUSBDataType ?? []);
158
+ return devices;
159
+ } catch {
160
+ return [];
161
+ }
162
+ }
163
+ function firstIOSPhysicalDevice() {
164
+ const devices = listIOSPhysicalDevices();
165
+ return devices[0] ?? null;
166
+ }
167
+ function startIproxy(udid, localPort, devicePort) {
168
+ try {
169
+ execSync("which iproxy", { stdio: "ignore" });
170
+ } catch {
171
+ throw new Error("iproxy not found. Install with: brew install libimobiledevice");
172
+ }
173
+ const { spawn } = __require("child_process");
174
+ const proc = spawn("iproxy", [`${localPort}:${devicePort}`, "-u", udid], {
175
+ stdio: "ignore",
176
+ detached: true
177
+ });
178
+ proc.unref();
179
+ const waitUntil = Date.now() + 1500;
180
+ while (Date.now() < waitUntil) {
181
+ }
182
+ return {
183
+ host: "localhost",
184
+ port: localPort,
185
+ cleanup: () => {
186
+ try {
187
+ proc.kill();
188
+ } catch {
189
+ }
190
+ }
191
+ };
192
+ }
193
+ function connectPhysicalDevice(udid, wdaPort = 8100) {
194
+ const localPort = 8100 + Math.floor(Math.random() * 100);
195
+ return startIproxy(udid, localPort, wdaPort);
196
+ }
197
+ function installOnPhysicalDevice(udid, appPath) {
198
+ try {
199
+ execSync(`xcrun devicectl device install app --device ${udid} ${appPath}`, {
200
+ stdio: "inherit",
201
+ timeout: 12e4
202
+ });
203
+ } catch {
204
+ throw new Error(
205
+ `Failed to install app on device ${udid}. Ensure the app is signed for this device.`
206
+ );
207
+ }
208
+ }
209
+ function hasAppOnPhysicalDevice(udid, bundleId) {
210
+ if (!bundleId) return false;
211
+ try {
212
+ const tmpFile = `/tmp/spana-applist-${Date.now()}.json`;
213
+ execSync(
214
+ `xcrun devicectl device info apps --device ${udid} --json-output ${tmpFile} 2>/dev/null`,
215
+ { timeout: 15e3 }
216
+ );
217
+ const { readFileSync, unlinkSync } = __require("fs");
218
+ const output = readFileSync(tmpFile, "utf-8");
219
+ try {
220
+ unlinkSync(tmpFile);
221
+ } catch {
222
+ }
223
+ return output.includes(bundleId);
224
+ } catch {
225
+ return false;
226
+ }
227
+ }
228
+ function resetSimulatorKeychain(udid) {
229
+ execSync(`xcrun simctl keychain ${udid} reset`, { stdio: "ignore" });
230
+ }
231
+ function ensureAppInstalled(opts) {
232
+ const { udid, bundleId, appPath, isPhysicalDevice } = opts;
233
+ if (isPhysicalDevice) {
234
+ if (!hasAppOnPhysicalDevice(udid, bundleId)) {
235
+ console.log(`Installing ${bundleId} on physical device...`);
236
+ installOnPhysicalDevice(udid, appPath);
237
+ }
238
+ } else {
239
+ if (!hasAppInstalledOnSimulator(udid, bundleId)) {
240
+ console.log(`Installing ${bundleId} on simulator...`);
241
+ installOnSimulator(udid, appPath);
242
+ }
243
+ }
244
+ }
245
+
246
+ export {
247
+ listIOSSimulators,
248
+ listBootedSimulators,
249
+ firstIOSSimulator,
250
+ hasAppInstalledOnSimulator,
251
+ firstIOSSimulatorWithApp,
252
+ ensureIOSSimulator,
253
+ bootSimulator,
254
+ installOnSimulator,
255
+ launchOnSimulator,
256
+ launchWithUrlOnSimulator,
257
+ installedUrlSchemesOnSimulator,
258
+ openUrlOnSimulator,
259
+ terminateOnSimulator,
260
+ listIOSPhysicalDevices,
261
+ firstIOSPhysicalDevice,
262
+ startIproxy,
263
+ connectPhysicalDevice,
264
+ installOnPhysicalDevice,
265
+ hasAppOnPhysicalDevice,
266
+ resetSimulatorKeychain,
267
+ ensureAppInstalled
268
+ };
269
+ //# sourceMappingURL=chunk-V62HFH6E.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/device/ios.ts"],"sourcesContent":["import { execFileSync, execSync } from \"node:child_process\";\n\nexport interface IOSSimulator {\n udid: string;\n name: string;\n state: \"Booted\" | \"Shutdown\" | string;\n runtime: string; // e.g. \"iOS 17.5\"\n isAvailable: boolean;\n}\n\nexport interface IOSDevice {\n udid: string;\n name: string;\n type: \"simulator\" | \"device\";\n state: string;\n runtime?: string;\n}\n\n/** List iOS simulators */\nexport function listIOSSimulators(): IOSSimulator[] {\n try {\n const output = execSync(\"xcrun simctl list devices -j\", { encoding: \"utf-8\" });\n const data = JSON.parse(output);\n const simulators: IOSSimulator[] = [];\n\n for (const [runtime, devices] of Object.entries(data.devices ?? {})) {\n // runtime looks like \"com.apple.CoreSimulator.SimRuntime.iOS-17-5\"\n const runtimeName = runtime\n .replace(\"com.apple.CoreSimulator.SimRuntime.\", \"\")\n .replace(/-/g, \".\");\n\n for (const device of devices as any[]) {\n simulators.push({\n udid: device.udid,\n name: device.name,\n state: device.state,\n runtime: runtimeName,\n isAvailable: device.isAvailable ?? true,\n });\n }\n }\n\n return simulators;\n } catch {\n return [];\n }\n}\n\n/** List booted iOS simulators */\nexport function listBootedSimulators(): IOSSimulator[] {\n return listIOSSimulators().filter((s) => s.state === \"Booted\" && s.isAvailable);\n}\n\n/** Get first booted simulator, or first available if none booted */\nexport function firstIOSSimulator(): IOSSimulator | null {\n const booted = listBootedSimulators();\n if (booted.length > 0) return booted[0]!;\n\n const available = listIOSSimulators().filter((s) => s.isAvailable);\n return available[0] ?? null;\n}\n\n/** Check whether an app is installed on a simulator */\nexport function hasAppInstalledOnSimulator(udid: string, bundleId: string): boolean {\n if (!bundleId) return false;\n\n try {\n execSync(`xcrun simctl get_app_container ${udid} ${bundleId} app`, { stdio: \"ignore\" });\n return true;\n } catch {\n return false;\n }\n}\n\n/** Prefer a simulator that already has the requested app installed */\nexport function firstIOSSimulatorWithApp(bundleId: string): IOSSimulator | null {\n const bootedWithApp = listBootedSimulators().find((sim) =>\n hasAppInstalledOnSimulator(sim.udid, bundleId),\n );\n if (bootedWithApp) return bootedWithApp;\n\n const availableWithApp = listIOSSimulators()\n .filter((sim) => sim.isAvailable)\n .find((sim) => hasAppInstalledOnSimulator(sim.udid, bundleId));\n if (availableWithApp) return availableWithApp;\n\n return firstIOSSimulator();\n}\n\n/**\n * Ensure an iOS simulator is available and booted.\n * If none booted, boots the first available simulator (preferring one with the app installed).\n * Returns the simulator or null if none available.\n */\nexport function ensureIOSSimulator(bundleId?: string): IOSSimulator | null {\n const sim = bundleId ? firstIOSSimulatorWithApp(bundleId) : firstIOSSimulator();\n if (!sim) return null;\n\n if (sim.state !== \"Booted\") {\n console.log(`Booting iOS simulator \"${sim.name}\"...`);\n bootSimulator(sim.udid);\n }\n\n return sim;\n}\n\n/** Boot a simulator by UDID */\nexport function bootSimulator(udid: string): void {\n try {\n execSync(`xcrun simctl boot ${udid}`, { stdio: \"ignore\" });\n } catch {\n // May already be booted — ignore\n }\n}\n\n/** Install app on simulator */\nexport function installOnSimulator(udid: string, appPath: string): void {\n execSync(`xcrun simctl install ${udid} ${appPath}`);\n}\n\n/** Launch app on simulator */\nexport function launchOnSimulator(udid: string, bundleId: string): void {\n execSync(`xcrun simctl launch ${udid} ${bundleId}`);\n}\n\n/** Launch app on simulator with a deep link URL (bypasses system confirmation dialog) */\nexport function launchWithUrlOnSimulator(udid: string, bundleId: string, url: string): void {\n execFileSync(\"xcrun\", [\"simctl\", \"launch\", udid, bundleId, \"--open-url\", url]);\n}\n\n/** List URL schemes registered by the installed app on simulator */\nexport function installedUrlSchemesOnSimulator(udid: string, bundleId: string): string[] {\n if (!bundleId) return [];\n\n try {\n const appPath = execSync(`xcrun simctl get_app_container ${udid} ${bundleId} app`, {\n encoding: \"utf-8\",\n }).trim();\n\n const raw = execFileSync(\n \"plutil\",\n [\"-extract\", \"CFBundleURLTypes\", \"json\", \"-o\", \"-\", `${appPath}/Info.plist`],\n {\n encoding: \"utf-8\",\n },\n );\n\n const urlTypes = JSON.parse(raw) as Array<{\n CFBundleURLSchemes?: string[];\n }>;\n\n return urlTypes.flatMap((entry) => entry.CFBundleURLSchemes ?? []);\n } catch {\n return [];\n }\n}\n\n/** Open a URL or deep link on simulator */\nexport function openUrlOnSimulator(udid: string, url: string): void {\n execFileSync(\"xcrun\", [\"simctl\", \"openurl\", udid, url], { stdio: \"ignore\" });\n}\n\n/** Terminate app on simulator */\nexport function terminateOnSimulator(udid: string, bundleId: string): void {\n try {\n execSync(`xcrun simctl terminate ${udid} ${bundleId}`, { stdio: \"ignore\" });\n } catch {\n // May not be running\n }\n}\n\n// ---------------------------------------------------------------------------\n// Physical device support\n// ---------------------------------------------------------------------------\n\nexport interface IOSPhysicalDevice {\n udid: string;\n name: string;\n connectionType: \"USB\" | \"Wi-Fi\" | string;\n}\n\n/**\n * List connected physical iOS devices using xcrun devicectl (Xcode 15+).\n * Falls back to system_profiler if devicectl is unavailable.\n */\nexport function listIOSPhysicalDevices(): IOSPhysicalDevice[] {\n // Try xcrun devicectl first (Xcode 15+)\n try {\n const tmpFile = `/tmp/spana-devicectl-${Date.now()}.json`;\n execSync(`xcrun devicectl list devices --json-output ${tmpFile} 2>/dev/null`, {\n timeout: 10_000,\n });\n const { readFileSync, unlinkSync } = require(\"node:fs\") as typeof import(\"node:fs\");\n const output = readFileSync(tmpFile, \"utf-8\");\n try {\n unlinkSync(tmpFile);\n } catch {\n /* cleanup */\n }\n\n const data = JSON.parse(output);\n const devices: IOSPhysicalDevice[] = [];\n\n for (const device of data?.result?.devices ?? []) {\n const deviceType = device.hardwareProperties?.deviceType ?? \"\";\n const transport = device.connectionProperties?.transportType;\n const state = device.connectionProperties?.tunnelState;\n\n // Include iPhones and iPads that have a transport (physically connected)\n // tunnelState can be \"connected\", \"disconnected\", or \"unavailable\"\n if (\n (deviceType === \"iPhone\" || deviceType === \"iPad\") &&\n transport &&\n state !== \"unavailable\"\n ) {\n devices.push({\n udid: device.hardwareProperties?.udid ?? device.identifier,\n name: device.deviceProperties?.name ?? \"Unknown\",\n connectionType: transport === \"wired\" ? \"USB\" : (transport ?? \"unknown\"),\n });\n }\n }\n\n return devices;\n } catch {\n // Fall back to system_profiler for older Xcode\n }\n\n try {\n const output = execSync(\"system_profiler SPUSBDataType -json 2>/dev/null\", {\n encoding: \"utf-8\",\n timeout: 10_000,\n });\n const data = JSON.parse(output);\n const devices: IOSPhysicalDevice[] = [];\n\n function walkUSB(items: any[]): void {\n for (const item of items) {\n // iOS devices have serial_num and contain \"iPhone\" or \"iPad\" in name\n if (item.serial_num && /iPhone|iPad|iPod/i.test(item._name ?? \"\")) {\n devices.push({\n udid: item.serial_num.replace(/-/g, \"\"),\n name: item._name ?? \"iOS Device\",\n connectionType: \"USB\",\n });\n }\n if (item._items) walkUSB(item._items);\n }\n }\n\n walkUSB(data.SPUSBDataType ?? []);\n return devices;\n } catch {\n return [];\n }\n}\n\n/** Get first connected physical iOS device */\nexport function firstIOSPhysicalDevice(): IOSPhysicalDevice | null {\n const devices = listIOSPhysicalDevices();\n return devices[0] ?? null;\n}\n\n/**\n * Start iproxy to tunnel a port from localhost to a physical device via USB.\n * Requires libimobiledevice (`brew install libimobiledevice`).\n *\n * @returns A cleanup function to kill the iproxy process.\n */\nexport function startIproxy(\n udid: string,\n localPort: number,\n devicePort: number,\n): { host: string; port: number; cleanup: () => void } {\n // Check iproxy is available\n try {\n execSync(\"which iproxy\", { stdio: \"ignore\" });\n } catch {\n throw new Error(\"iproxy not found. Install with: brew install libimobiledevice\");\n }\n\n const { spawn } = require(\"node:child_process\") as typeof import(\"node:child_process\");\n const proc = spawn(\"iproxy\", [`${localPort}:${devicePort}`, \"-u\", udid], {\n stdio: \"ignore\",\n detached: true,\n });\n proc.unref();\n\n // Give iproxy a moment to bind\n const waitUntil = Date.now() + 1500;\n while (Date.now() < waitUntil) {\n /* busy wait */\n }\n\n return {\n host: \"localhost\",\n port: localPort,\n cleanup: () => {\n try {\n proc.kill();\n } catch {\n // already dead\n }\n },\n };\n}\n\n/**\n * Connect to a physical iOS device for testing.\n * Sets up iproxy tunnel and returns connection info for WDA.\n *\n * WDA must be pre-installed and running on the device.\n * Install with: xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner\n * -destination \"id=<UDID>\" test\n */\nexport function connectPhysicalDevice(\n udid: string,\n wdaPort = 8100,\n): { host: string; port: number; cleanup: () => void } {\n const localPort = 8100 + Math.floor(Math.random() * 100);\n return startIproxy(udid, localPort, wdaPort);\n}\n\n/**\n * Install an app on a physical iOS device using xcrun devicectl (Xcode 15+).\n * Accepts .app bundles or .ipa files.\n */\nexport function installOnPhysicalDevice(udid: string, appPath: string): void {\n try {\n execSync(`xcrun devicectl device install app --device ${udid} ${appPath}`, {\n stdio: \"inherit\",\n timeout: 120_000,\n });\n } catch {\n throw new Error(\n `Failed to install app on device ${udid}. Ensure the app is signed for this device.`,\n );\n }\n}\n\n/**\n * Check if an app is installed on a physical device.\n */\nexport function hasAppOnPhysicalDevice(udid: string, bundleId: string): boolean {\n if (!bundleId) return false;\n try {\n const tmpFile = `/tmp/spana-applist-${Date.now()}.json`;\n execSync(\n `xcrun devicectl device info apps --device ${udid} --json-output ${tmpFile} 2>/dev/null`,\n { timeout: 15_000 },\n );\n const { readFileSync, unlinkSync } = require(\"node:fs\") as typeof import(\"node:fs\");\n const output = readFileSync(tmpFile, \"utf-8\");\n try {\n unlinkSync(tmpFile);\n } catch {\n /* cleanup */\n }\n return output.includes(bundleId);\n } catch {\n return false;\n }\n}\n\n/** Reset simulator keychain (removes all stored passwords and certificates) */\nexport function resetSimulatorKeychain(udid: string): void {\n execSync(`xcrun simctl keychain ${udid} reset`, { stdio: \"ignore\" });\n}\n\n/**\n * Ensure an app is installed on the target device (simulator or physical).\n * Installs from appPath if not already present.\n */\nexport function ensureAppInstalled(opts: {\n udid: string;\n bundleId: string;\n appPath: string;\n isPhysicalDevice: boolean;\n}): void {\n const { udid, bundleId, appPath, isPhysicalDevice } = opts;\n\n if (isPhysicalDevice) {\n if (!hasAppOnPhysicalDevice(udid, bundleId)) {\n console.log(`Installing ${bundleId} on physical device...`);\n installOnPhysicalDevice(udid, appPath);\n }\n } else {\n if (!hasAppInstalledOnSimulator(udid, bundleId)) {\n console.log(`Installing ${bundleId} on simulator...`);\n installOnSimulator(udid, appPath);\n }\n }\n}\n"],"mappings":";;;;;AAAA,SAAS,cAAc,gBAAgB;AAmBhC,SAAS,oBAAoC;AAClD,MAAI;AACF,UAAM,SAAS,SAAS,gCAAgC,EAAE,UAAU,QAAQ,CAAC;AAC7E,UAAM,OAAO,KAAK,MAAM,MAAM;AAC9B,UAAM,aAA6B,CAAC;AAEpC,eAAW,CAAC,SAAS,OAAO,KAAK,OAAO,QAAQ,KAAK,WAAW,CAAC,CAAC,GAAG;AAEnE,YAAM,cAAc,QACjB,QAAQ,uCAAuC,EAAE,EACjD,QAAQ,MAAM,GAAG;AAEpB,iBAAW,UAAU,SAAkB;AACrC,mBAAW,KAAK;AAAA,UACd,MAAM,OAAO;AAAA,UACb,MAAM,O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2B;AAC9E,MAAI,CAAC,SAAU,QAAO;AACtB,MAAI;AACF,UAAM,UAAU,sBAAsB,KAAK,IAAI,CAAC;AAChD;AAAA,MACE,6CAA6C,IAAI,kBAAkB,OAAO;AAAA,MAC1E,EAAE,SAAS,KAAO;AAAA,IACpB;AACA,UAAM,EAAE,cAAc,WAAW,IAAI,UAAQ,IAAS;AACtD,UAAM,SAAS,aAAa,SAAS,OAAO;AAC5C,QAAI;AACF,iBAAW,OAAO;AAAA,IACpB,QAAQ;AAAA,IAER;AACA,WAAO,OAAO,SAAS,QAAQ;AAAA,EACjC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGO,SAAS,uBAAuB,MAAoB;AACzD,WAAS,yBAAyB,IAAI,UAAU,EAAE,OAAO,SAAS,CAAC;AACrE;AAMO,SAAS,mBAAmB,MAK1B;AACP,QAAM,EAAE,MAAM,UAAU,SAAS,iBAAiB,IAAI;AAEtD,MAAI,kBAAkB;AACpB,QAAI,CAAC,uBAAuB,MAAM,QAAQ,GAAG;AAC3C,cAAQ,IAAI,cAAc,QAAQ,wBAAwB;AAC1D,8BAAwB,MAAM,OAAO;AAAA,IACvC;AAAA,EACF,OAAO;AACL,QAAI,CAAC,2BAA2B,MAAM,QAAQ,GAAG;AAC/C,cAAQ,IAAI,cAAc,QAAQ,kBAAkB;AACpD,yBAAmB,MAAM,OAAO;AAAA,IAClC;AAAA,EACF;AACF;","names":["walkUSB"]}
@@ -0,0 +1,303 @@
1
+ import {
2
+ createUiAutomator2Driver,
3
+ createWDADriver,
4
+ makePlaywrightDriver,
5
+ parseAndroidHierarchy,
6
+ parseIOSHierarchy,
7
+ parseWebHierarchy,
8
+ setupUiAutomator2
9
+ } from "./chunk-CKJQX73M.js";
10
+ import {
11
+ DriverError,
12
+ centerOf,
13
+ findElementExtended,
14
+ flattenElements
15
+ } from "./chunk-U564GCO2.js";
16
+ import {
17
+ allocatePort,
18
+ setupWDA
19
+ } from "./chunk-RK4Z6C7M.js";
20
+ import {
21
+ findDeviceById
22
+ } from "./chunk-WIJYK22K.js";
23
+ import {
24
+ firstAndroidDevice
25
+ } from "./chunk-GZK22EIE.js";
26
+ import {
27
+ bootSimulator,
28
+ firstIOSSimulatorWithApp
29
+ } from "./chunk-V62HFH6E.js";
30
+
31
+ // src/agent/session.ts
32
+ import { Effect } from "effect";
33
+ var Session = class {
34
+ driver;
35
+ appId;
36
+ platform;
37
+ parse;
38
+ cleanups;
39
+ constructor(driver, platform, parse, appId = "", cleanups = []) {
40
+ this.driver = driver;
41
+ this.platform = platform;
42
+ this.parse = parse;
43
+ this.appId = appId;
44
+ this.cleanups = cleanups;
45
+ }
46
+ // ---------------------------------------------------------------------------
47
+ // Hierarchy & selectors
48
+ // ---------------------------------------------------------------------------
49
+ async hierarchy() {
50
+ const raw = await Effect.runPromise(this.driver.dumpHierarchy());
51
+ return this.parse(raw);
52
+ }
53
+ async selectors() {
54
+ const root = await this.hierarchy();
55
+ const all = flattenElements(root);
56
+ return all.filter((el) => el.visible !== false && (el.id || el.text || el.accessibilityLabel)).map((el) => {
57
+ let suggestedSelector;
58
+ if (el.id) {
59
+ suggestedSelector = { testID: el.id };
60
+ } else if (el.accessibilityLabel) {
61
+ suggestedSelector = { accessibilityLabel: el.accessibilityLabel };
62
+ } else if (el.text) {
63
+ suggestedSelector = { text: el.text };
64
+ } else {
65
+ suggestedSelector = el.text ?? "";
66
+ }
67
+ return {
68
+ suggestedSelector,
69
+ elementType: el.elementType,
70
+ text: el.text,
71
+ accessibilityLabel: el.accessibilityLabel,
72
+ bounds: el.bounds,
73
+ id: el.id
74
+ };
75
+ });
76
+ }
77
+ // ---------------------------------------------------------------------------
78
+ // Touch actions
79
+ // ---------------------------------------------------------------------------
80
+ async tap(selector) {
81
+ const root = await this.hierarchy();
82
+ const el = findElementExtended(root, selector);
83
+ if (!el) throw new Error(`Element not found: ${JSON.stringify(selector)}`);
84
+ const { x, y } = centerOf(el);
85
+ await Effect.runPromise(this.driver.tapAtCoordinate(x, y));
86
+ }
87
+ async tapXY(x, y) {
88
+ await Effect.runPromise(this.driver.tapAtCoordinate(x, y));
89
+ }
90
+ async doubleTap(selector) {
91
+ const root = await this.hierarchy();
92
+ const el = findElementExtended(root, selector);
93
+ if (!el) throw new Error(`Element not found: ${JSON.stringify(selector)}`);
94
+ const { x, y } = centerOf(el);
95
+ await Effect.runPromise(this.driver.doubleTapAtCoordinate(x, y));
96
+ }
97
+ async longPress(selector, opts) {
98
+ const root = await this.hierarchy();
99
+ const el = findElementExtended(root, selector);
100
+ if (!el) throw new Error(`Element not found: ${JSON.stringify(selector)}`);
101
+ const { x, y } = centerOf(el);
102
+ await Effect.runPromise(this.driver.longPressAtCoordinate(x, y, opts?.duration ?? 1e3));
103
+ }
104
+ async longPressXY(x, y, opts) {
105
+ await Effect.runPromise(this.driver.longPressAtCoordinate(x, y, opts?.duration ?? 1e3));
106
+ }
107
+ // ---------------------------------------------------------------------------
108
+ // Gestures
109
+ // ---------------------------------------------------------------------------
110
+ async swipe(direction, opts) {
111
+ const info = await Effect.runPromise(this.driver.getDeviceInfo());
112
+ const cx = info.screenWidth / 2;
113
+ const cy = info.screenHeight / 2;
114
+ const dist = Math.min(info.screenWidth, info.screenHeight) * 0.3;
115
+ const dur = opts?.duration ?? 300;
116
+ const vectors = {
117
+ up: [cx, cy + dist, cx, cy - dist],
118
+ down: [cx, cy - dist, cx, cy + dist],
119
+ left: [cx + dist, cy, cx - dist, cy],
120
+ right: [cx - dist, cy, cx + dist, cy]
121
+ };
122
+ const [sx, sy, ex, ey] = vectors[direction];
123
+ await Effect.runPromise(this.driver.swipe(sx, sy, ex, ey, dur));
124
+ }
125
+ async scroll(direction) {
126
+ await this.swipe(direction, { duration: 500 });
127
+ }
128
+ // ---------------------------------------------------------------------------
129
+ // Text input
130
+ // ---------------------------------------------------------------------------
131
+ async inputText(text) {
132
+ await Effect.runPromise(this.driver.inputText(text));
133
+ }
134
+ async pressKey(key) {
135
+ await Effect.runPromise(this.driver.pressKey(key));
136
+ }
137
+ async hideKeyboard() {
138
+ await Effect.runPromise(this.driver.hideKeyboard());
139
+ }
140
+ // ---------------------------------------------------------------------------
141
+ // App lifecycle
142
+ // ---------------------------------------------------------------------------
143
+ async launch(opts) {
144
+ await Effect.runPromise(this.driver.launchApp(this.appId, opts));
145
+ }
146
+ async stop() {
147
+ await Effect.runPromise(this.driver.stopApp(this.appId));
148
+ }
149
+ async kill() {
150
+ await Effect.runPromise(this.driver.killApp(this.appId));
151
+ }
152
+ async clearState() {
153
+ await Effect.runPromise(this.driver.clearAppState(this.appId));
154
+ }
155
+ // ---------------------------------------------------------------------------
156
+ // Navigation
157
+ // ---------------------------------------------------------------------------
158
+ async openLink(url) {
159
+ await Effect.runPromise(this.driver.openLink(url));
160
+ }
161
+ async back() {
162
+ await Effect.runPromise(this.driver.back());
163
+ }
164
+ // ---------------------------------------------------------------------------
165
+ // Queries
166
+ // ---------------------------------------------------------------------------
167
+ async screenshot() {
168
+ return Effect.runPromise(this.driver.takeScreenshot());
169
+ }
170
+ async evaluate(fn, ...args) {
171
+ return Effect.runPromise(this.driver.evaluate(fn, ...args));
172
+ }
173
+ async mockNetwork(matcher, response) {
174
+ const effect = this.driver.mockNetwork?.(matcher, response) ?? Effect.fail(
175
+ new DriverError({ message: "mockNetwork() is only supported on the web platform" })
176
+ );
177
+ await Effect.runPromise(effect);
178
+ }
179
+ async blockNetwork(matcher) {
180
+ const effect = this.driver.blockNetwork?.(matcher) ?? Effect.fail(
181
+ new DriverError({ message: "blockNetwork() is only supported on the web platform" })
182
+ );
183
+ await Effect.runPromise(effect);
184
+ }
185
+ async clearNetworkMocks() {
186
+ const effect = this.driver.clearNetworkMocks?.() ?? Effect.fail(
187
+ new DriverError({ message: "clearNetworkMocks() is only supported on the web platform" })
188
+ );
189
+ await Effect.runPromise(effect);
190
+ }
191
+ async setNetworkConditions(conditions) {
192
+ const effect = this.driver.setNetworkConditions?.(conditions) ?? Effect.fail(
193
+ new DriverError({
194
+ message: "setNetworkConditions() is only supported on the web platform"
195
+ })
196
+ );
197
+ await Effect.runPromise(effect);
198
+ }
199
+ async saveCookies(path) {
200
+ const effect = this.driver.saveCookies?.(path) ?? Effect.fail(
201
+ new DriverError({ message: "saveCookies() is only supported on the web platform" })
202
+ );
203
+ await Effect.runPromise(effect);
204
+ }
205
+ async loadCookies(path) {
206
+ const effect = this.driver.loadCookies?.(path) ?? Effect.fail(
207
+ new DriverError({ message: "loadCookies() is only supported on the web platform" })
208
+ );
209
+ await Effect.runPromise(effect);
210
+ }
211
+ async saveAuthState(path) {
212
+ const effect = this.driver.saveAuthState?.(path) ?? Effect.fail(
213
+ new DriverError({ message: "saveAuthState() is only supported on the web platform" })
214
+ );
215
+ await Effect.runPromise(effect);
216
+ }
217
+ async loadAuthState(path) {
218
+ const effect = this.driver.loadAuthState?.(path) ?? Effect.fail(
219
+ new DriverError({ message: "loadAuthState() is only supported on the web platform" })
220
+ );
221
+ await Effect.runPromise(effect);
222
+ }
223
+ // ---------------------------------------------------------------------------
224
+ // Lifecycle
225
+ // ---------------------------------------------------------------------------
226
+ async disconnect() {
227
+ try {
228
+ await Effect.runPromise(this.driver.killApp(""));
229
+ } catch {
230
+ }
231
+ for (const cleanup of this.cleanups) {
232
+ try {
233
+ cleanup();
234
+ } catch {
235
+ }
236
+ }
237
+ }
238
+ };
239
+ async function connect(opts) {
240
+ if (opts.platform === "web") {
241
+ const baseUrl = opts.baseUrl ?? "http://localhost:3000";
242
+ const driver = await Effect.runPromise(
243
+ makePlaywrightDriver({
244
+ browser: opts.browser,
245
+ headless: opts.headless ?? true,
246
+ baseUrl,
247
+ storageState: opts.storageState
248
+ })
249
+ );
250
+ await Effect.runPromise(driver.launchApp(baseUrl));
251
+ return new Session(driver, "web", parseWebHierarchy, baseUrl);
252
+ }
253
+ if (opts.platform === "android") {
254
+ const device = opts.device ? (() => {
255
+ const found = findDeviceById(opts.device);
256
+ if (!found || found.platform !== "android")
257
+ throw new Error(`Android device not found: ${opts.device}`);
258
+ return {
259
+ serial: found.id,
260
+ state: "device",
261
+ type: found.type
262
+ };
263
+ })() : firstAndroidDevice();
264
+ if (!device) throw new Error("No Android device connected");
265
+ const hostPort = allocatePort(8200);
266
+ const conn = await setupUiAutomator2(device.serial, hostPort);
267
+ const packageName = opts.packageName ?? "";
268
+ const driver = await Effect.runPromise(
269
+ createUiAutomator2Driver(conn.host, conn.port, device.serial, packageName)
270
+ );
271
+ return new Session(driver, "android", parseAndroidHierarchy, packageName, [conn.cleanup]);
272
+ }
273
+ if (opts.platform === "ios") {
274
+ const bundleId = opts.bundleId ?? "";
275
+ const sim = opts.device ? (() => {
276
+ const found = findDeviceById(opts.device);
277
+ if (!found || found.platform !== "ios")
278
+ throw new Error(`iOS device not found: ${opts.device}`);
279
+ return {
280
+ udid: found.id,
281
+ name: found.name,
282
+ state: found.state,
283
+ runtime: "",
284
+ isAvailable: true
285
+ };
286
+ })() : firstIOSSimulatorWithApp(bundleId);
287
+ if (!sim) throw new Error("No iOS simulator available");
288
+ if (sim.state !== "Booted") bootSimulator(sim.udid);
289
+ const wdaPort = allocatePort(8100);
290
+ const conn = await setupWDA(sim.udid, wdaPort);
291
+ const driver = await Effect.runPromise(
292
+ createWDADriver(conn.host, conn.port, bundleId, sim.udid)
293
+ );
294
+ return new Session(driver, "ios", parseIOSHierarchy, bundleId, [conn.cleanup]);
295
+ }
296
+ throw new Error(`Unsupported platform: ${opts.platform}`);
297
+ }
298
+
299
+ export {
300
+ Session,
301
+ connect
302
+ };
303
+ //# sourceMappingURL=chunk-VDWWIVM6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/agent/session.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport { DriverError } from \"../errors.js\";\nimport type {\n RawDriverService,\n LaunchOptions,\n BrowserMockResponse,\n BrowserNetworkConditions,\n BrowserRouteMatcher,\n} from \"../drivers/raw-driver.js\";\nimport type { Platform, Selector, ExtendedSelector } from \"../schemas/selector.js\";\nimport type { Element } from \"../schemas/element.js\";\nimport { makePlaywrightDriver } from \"../drivers/playwright.js\";\nimport { createUiAutomator2Driver } from \"../drivers/uiautomator2/driver.js\";\nimport { createWDADriver } from \"../drivers/wda/driver.js\";\nimport { parseWebHierarchy } from \"../drivers/playwright-parser.js\";\nimport { parseAndroidHierarchy } from \"../drivers/uiautomator2/pagesource.js\";\nimport { parseIOSHierarchy } from \"../drivers/wda/pagesource.js\";\nimport { flattenElements, findElementExtended, centerOf } from \"../smart/element-matcher.js\";\nimport { setupUiAutomator2 } from \"../drivers/uiautomator2/installer.js\";\nimport { setupWDA } from \"../drivers/wda/installer.js\";\nimport { allocatePort } from \"../core/port-allocator.js\";\nimport { firstAndroidDevice } from \"../device/android.js\";\nimport { firstIOSSimulatorWithApp, bootSimulator } from \"../device/ios.js\";\nimport { findDeviceById } from \"../device/discover.js\";\nimport type { BrowserName } from \"../schemas/config.js\";\n\nexport type Direction = \"up\" | \"down\" | \"left\" | \"right\";\n\nexport interface ConnectOptions {\n platform: Platform;\n device?: string; // device ID override\n baseUrl?: string; // for web\n packageName?: string; // for android\n bundleId?: string; // for ios\n headless?: boolean; // for web (default true)\n browser?: BrowserName; // for web (default chromium)\n storageState?: string; // for web\n}\n\nexport interface SuggestedSelector {\n suggestedSelector: Selector;\n elementType?: string;\n text?: string;\n accessibilityLabel?: string;\n bounds: { x: number; y: number; width: number; height: number };\n id?: string;\n}\n\nexport class Session {\n private driver: RawDriverService;\n private appId: string;\n readonly platform: Platform;\n private parse: (raw: string) => Element;\n private cleanups: (() => void)[];\n\n constructor(\n driver: RawDriverService,\n platform: Platform,\n parse: (raw: string) => Element,\n appId = \"\",\n cleanups: (() => void)[] = [],\n ) {\n this.driver = driver;\n this.platform = platform;\n this.parse = parse;\n this.appId = appId;\n this.cleanups = cleanups;\n }\n\n // ---------------------------------------------------------------------------\n // Hierarchy & selectors\n // ---------------------------------------------------------------------------\n\n async hierarchy(): Promise<Element> {\n const raw = await Effect.runPromise(this.driver.dumpHierarchy());\n return this.parse(raw);\n }\n\n async selectors(): Promise<SuggestedSelector[]> {\n const root = await this.hierarchy();\n const all = flattenElements(root);\n\n return all\n .filter((el) => el.visible !== false && (el.id || el.text || el.accessibilityLabel))\n .map((el) => {\n let suggestedSelector: Selector;\n if (el.id) {\n suggestedSelector = { testID: el.id };\n } else if (el.accessibilityLabel) {\n suggestedSelector = { accessibilityLabel: el.accessibilityLabel };\n } else if (el.text) {\n suggestedSelector = { text: el.text };\n } else {\n suggestedSelector = el.text ?? \"\";\n }\n\n return {\n suggestedSelector,\n elementType: el.elementType,\n text: el.text,\n accessibilityLabel: el.accessibilityLabel,\n bounds: el.bounds,\n id: el.id,\n };\n });\n }\n\n // ---------------------------------------------------------------------------\n // Touch actions\n // ---------------------------------------------------------------------------\n\n async tap(selector: ExtendedSelector): Promise<void> {\n const root = await this.hierarchy();\n const el = findElementExtended(root, selector);\n if (!el) throw new Error(`Element not found: ${JSON.stringify(selector)}`);\n const { x, y } = centerOf(el);\n await Effect.runPromise(this.driver.tapAtCoordinate(x, y));\n }\n\n async tapXY(x: number, y: number): Promise<void> {\n await Effect.runPromise(this.driver.tapAtCoordinate(x, y));\n }\n\n async doubleTap(selector: ExtendedSelector): Promise<void> {\n const root = await this.hierarchy();\n const el = findElementExtended(root, selector);\n if (!el) throw new Error(`Element not found: ${JSON.stringify(selector)}`);\n const { x, y } = centerOf(el);\n await Effect.runPromise(this.driver.doubleTapAtCoordinate(x, y));\n }\n\n async longPress(selector: ExtendedSelector, opts?: { duration?: number }): Promise<void> {\n const root = await this.hierarchy();\n const el = findElementExtended(root, selector);\n if (!el) throw new Error(`Element not found: ${JSON.stringify(selector)}`);\n const { x, y } = centerOf(el);\n await Effect.runPromise(this.driver.longPressAtCoordinate(x, y, opts?.duration ?? 1000));\n }\n\n async longPressXY(x: number, y: number, opts?: { duration?: number }): Promise<void> {\n await Effect.runPromise(this.driver.longPressAtCoordinate(x, y, opts?.duration ?? 1000));\n }\n\n // ---------------------------------------------------------------------------\n // Gestures\n // ---------------------------------------------------------------------------\n\n async swipe(direction: Direction, opts?: { duration?: number }): Promise<void> {\n const info = await Effect.runPromise(this.driver.getDeviceInfo());\n const cx = info.screenWidth / 2;\n const cy = info.screenHeight / 2;\n const dist = Math.min(info.screenWidth, info.screenHeight) * 0.3;\n const dur = opts?.duration ?? 300;\n\n const vectors: Record<Direction, [number, number, number, number]> = {\n up: [cx, cy + dist, cx, cy - dist],\n down: [cx, cy - dist, cx, cy + dist],\n left: [cx + dist, cy, cx - dist, cy],\n right: [cx - dist, cy, cx + dist, cy],\n };\n const [sx, sy, ex, ey] = vectors[direction];\n await Effect.runPromise(this.driver.swipe(sx, sy, ex, ey, dur));\n }\n\n async scroll(direction: Direction): Promise<void> {\n await this.swipe(direction, { duration: 500 });\n }\n\n // ---------------------------------------------------------------------------\n // Text input\n // ---------------------------------------------------------------------------\n\n async inputText(text: string): Promise<void> {\n await Effect.runPromise(this.driver.inputText(text));\n }\n\n async pressKey(key: string): Promise<void> {\n await Effect.runPromise(this.driver.pressKey(key));\n }\n\n async hideKeyboard(): Promise<void> {\n await Effect.runPromise(this.driver.hideKeyboard());\n }\n\n // ---------------------------------------------------------------------------\n // App lifecycle\n // ---------------------------------------------------------------------------\n\n async launch(opts?: LaunchOptions): Promise<void> {\n await Effect.runPromise(this.driver.launchApp(this.appId, opts));\n }\n\n async stop(): Promise<void> {\n await Effect.runPromise(this.driver.stopApp(this.appId));\n }\n\n async kill(): Promise<void> {\n await Effect.runPromise(this.driver.killApp(this.appId));\n }\n\n async clearState(): Promise<void> {\n await Effect.runPromise(this.driver.clearAppState(this.appId));\n }\n\n // ---------------------------------------------------------------------------\n // Navigation\n // ---------------------------------------------------------------------------\n\n async openLink(url: string): Promise<void> {\n await Effect.runPromise(this.driver.openLink(url));\n }\n\n async back(): Promise<void> {\n await Effect.runPromise(this.driver.back());\n }\n\n // ---------------------------------------------------------------------------\n // Queries\n // ---------------------------------------------------------------------------\n\n async screenshot(): Promise<Uint8Array> {\n return Effect.runPromise(this.driver.takeScreenshot());\n }\n\n async evaluate<T = unknown>(fn: ((...args: any[]) => T) | string, ...args: any[]): Promise<T> {\n return Effect.runPromise(this.driver.evaluate(fn as any, ...args)) as Promise<T>;\n }\n\n async mockNetwork(matcher: BrowserRouteMatcher, response: BrowserMockResponse): Promise<void> {\n const effect =\n this.driver.mockNetwork?.(matcher, response) ??\n Effect.fail(\n new DriverError({ message: \"mockNetwork() is only supported on the web platform\" }),\n );\n await Effect.runPromise(effect);\n }\n\n async blockNetwork(matcher: BrowserRouteMatcher): Promise<void> {\n const effect =\n this.driver.blockNetwork?.(matcher) ??\n Effect.fail(\n new DriverError({ message: \"blockNetwork() is only supported on the web platform\" }),\n );\n await Effect.runPromise(effect);\n }\n\n async clearNetworkMocks(): Promise<void> {\n const effect =\n this.driver.clearNetworkMocks?.() ??\n Effect.fail(\n new DriverError({ message: \"clearNetworkMocks() is only supported on the web platform\" }),\n );\n await Effect.runPromise(effect);\n }\n\n async setNetworkConditions(conditions: BrowserNetworkConditions): Promise<void> {\n const effect =\n this.driver.setNetworkConditions?.(conditions) ??\n Effect.fail(\n new DriverError({\n message: \"setNetworkConditions() is only supported on the web platform\",\n }),\n );\n await Effect.runPromise(effect);\n }\n\n async saveCookies(path: string): Promise<void> {\n const effect =\n this.driver.saveCookies?.(path) ??\n Effect.fail(\n new DriverError({ message: \"saveCookies() is only supported on the web platform\" }),\n );\n await Effect.runPromise(effect);\n }\n\n async loadCookies(path: string): Promise<void> {\n const effect =\n this.driver.loadCookies?.(path) ??\n Effect.fail(\n new DriverError({ message: \"loadCookies() is only supported on the web platform\" }),\n );\n await Effect.runPromise(effect);\n }\n\n async saveAuthState(path: string): Promise<void> {\n const effect =\n this.driver.saveAuthState?.(path) ??\n Effect.fail(\n new DriverError({ message: \"saveAuthState() is only supported on the web platform\" }),\n );\n await Effect.runPromise(effect);\n }\n\n async loadAuthState(path: string): Promise<void> {\n const effect =\n this.driver.loadAuthState?.(path) ??\n Effect.fail(\n new DriverError({ message: \"loadAuthState() is only supported on the web platform\" }),\n );\n await Effect.runPromise(effect);\n }\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n async disconnect(): Promise<void> {\n try {\n await Effect.runPromise(this.driver.killApp(\"\"));\n } catch {\n // ignore\n }\n for (const cleanup of this.cleanups) {\n try {\n cleanup();\n } catch {\n /* ignore */\n }\n }\n }\n}\n\n/** Connect to a device and create a persistent session */\nexport async function connect(opts: ConnectOptions): Promise<Session> {\n if (opts.platform === \"web\") {\n const baseUrl = opts.baseUrl ?? \"http://localhost:3000\";\n const driver = await Effect.runPromise(\n makePlaywrightDriver({\n browser: opts.browser,\n headless: opts.headless ?? true,\n baseUrl,\n storageState: opts.storageState,\n }),\n );\n await Effect.runPromise(driver.launchApp(baseUrl));\n return new Session(driver, \"web\", parseWebHierarchy, baseUrl);\n }\n\n if (opts.platform === \"android\") {\n const device = opts.device\n ? (() => {\n const found = findDeviceById(opts.device!);\n if (!found || found.platform !== \"android\")\n throw new Error(`Android device not found: ${opts.device}`);\n return {\n serial: found.id,\n state: \"device\" as const,\n type: found.type as \"emulator\" | \"device\",\n };\n })()\n : firstAndroidDevice();\n if (!device) throw new Error(\"No Android device connected\");\n const hostPort = allocatePort(8200);\n const conn = await setupUiAutomator2(device.serial, hostPort);\n const packageName = opts.packageName ?? \"\";\n const driver = await Effect.runPromise(\n createUiAutomator2Driver(conn.host, conn.port, device.serial, packageName),\n );\n return new Session(driver, \"android\", parseAndroidHierarchy, packageName, [conn.cleanup]);\n }\n\n if (opts.platform === \"ios\") {\n const bundleId = opts.bundleId ?? \"\";\n const sim = opts.device\n ? (() => {\n const found = findDeviceById(opts.device!);\n if (!found || found.platform !== \"ios\")\n throw new Error(`iOS device not found: ${opts.device}`);\n return {\n udid: found.id,\n name: found.name,\n state: found.state as \"Booted\" | \"Shutdown\",\n runtime: \"\",\n isAvailable: true,\n };\n })()\n : firstIOSSimulatorWithApp(bundleId);\n if (!sim) throw new Error(\"No iOS simulator available\");\n if (sim.state !== \"Booted\") bootSimulator(sim.udid);\n const wdaPort = allocatePort(8100);\n const conn = await setupWDA(sim.udid, wdaPort);\n const driver = await Effect.runPromise(\n createWDADriver(conn.host, conn.port, bundleId, sim.udid),\n );\n return new Session(driver, \"ios\", parseIOSHierarchy, bundleId, [conn.cleanup]);\n }\n\n throw new Error(`Unsupported platform: ${opts.platform}`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,cAAc;AAgDhB,IAAM,UAAN,MAAc;AAAA,EACX;AAAA,EACA;AAAA,EACC;AAAA,EACD;AAAA,EACA;AAAA,EAER,YACE,QACA,UACA,OACA,QAAQ,IACR,WAA2B,CAAC,GAC5B;AACA,SAAK,SAAS;AACd,SAAK,WAAW;AAChB,SAAK,QAAQ;AACb,SAAK,QAAQ;AACb,SAAK,WAAW;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,YAA8B;AAClC,UAAM,MAAM,MAAM,OAAO,WAAW,KAAK,OAAO,cAAc,CAAC;AAC/D,WAAO,KAAK,MAAM,GAAG;AAAA,EACvB;AAAA,EAEA,MAAM,YAA0C;AAC9C,UAAM,OAAO,MAAM,KAAK,UAAU;AAClC,UAAM,MAAM,gBAAgB,IAAI;AAEhC,WAAO,IACJ,OAAO,CAAC,OAAO,GAAG,YAAY,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,mBAAmB,EAClF,IAAI,CAAC,OAAO;AACX,UAAI;AACJ,UAAI,GAAG,IAAI;AACT,4BAAoB,EAAE,QAAQ,GAAG,GAAG;AAAA,MACtC,WAAW,GAAG,oBAAoB;AAChC,4BAAoB,EAAE,oBAAoB,GAAG,mBAAmB;AAAA,MAClE,WAAW,GAAG,MAAM;AAClB,4BAAoB,EAAE,MAAM,GAAG,KAAK;AAAA,MACtC,OAAO;AACL,4BAAoB,GAAG,QAAQ;AAAA,MACjC;AAEA,aAAO;AAAA,QACL;AAAA,QAC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