claude-in-mobile 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,154 @@
1
+ # Claude Mobile
2
+
3
+ MCP server for mobile device automation — Android (via ADB) and iOS Simulator (via simctl). Like [Claude in Chrome](https://www.anthropic.com/news/claude-for-chrome) but for mobile devices.
4
+
5
+ Control your Android phone, emulator, or iOS Simulator with natural language through Claude.
6
+
7
+ ## Features
8
+
9
+ - **Unified API** — Same commands work for both Android and iOS
10
+ - **Smart screenshots** — Auto-compressed for optimal LLM processing (no more oversized images!)
11
+ - **Device logs** — Read logcat/system logs with filters for debugging
12
+ - **UI interactions** — Tap, long press, swipe by coordinates or element text
13
+ - **Text input** — Type into focused fields
14
+ - **App control** — Launch, stop, and install apps
15
+ - **Platform selection** — Explicitly target Android or iOS, or auto-detect
16
+
17
+ ## Installation
18
+
19
+ ### Claude Code CLI (recommended)
20
+
21
+ ```bash
22
+ claude mcp add --transport stdio mobile -- npx -y claude-in-mobile
23
+ ```
24
+
25
+ To add globally (available in all projects):
26
+
27
+ ```bash
28
+ claude mcp add --scope user --transport stdio mobile -- npx -y claude-in-android
29
+ ```
30
+
31
+ ### From npm
32
+
33
+ ```bash
34
+ npx claude-in-mobile
35
+ ```
36
+
37
+ ### From source
38
+
39
+ ```bash
40
+ git clone https://github.com/AlexGladkov/claude-in-mobile.git
41
+ cd claude-in-mobile
42
+ npm install
43
+ npm run build
44
+ ```
45
+
46
+ ### Manual configuration
47
+
48
+ Add to your Claude Code settings (`~/.claude.json` or project settings):
49
+
50
+ ```json
51
+ {
52
+ "mcpServers": {
53
+ "mobile": {
54
+ "command": "npx",
55
+ "args": ["-y", "claude-in-mobile"]
56
+ }
57
+ }
58
+ }
59
+ ```
60
+
61
+ ### Windows
62
+
63
+ ```bash
64
+ claude mcp add --transport stdio mobile -- cmd /c npx -y claude-in-android
65
+ ```
66
+
67
+ ## Requirements
68
+
69
+ ### Android
70
+ - ADB installed and in PATH
71
+ - Connected Android device (USB debugging enabled) or emulator
72
+
73
+ ### iOS
74
+ - macOS with Xcode installed
75
+ - iOS Simulator (no physical device support yet)
76
+
77
+ ## Available Tools
78
+
79
+ | Tool | Android | iOS | Description |
80
+ |------|---------|-----|-------------|
81
+ | `list_devices` | ✅ | ✅ | List all connected devices |
82
+ | `set_device` | ✅ | ✅ | Select active device |
83
+ | `screenshot` | ✅ | ✅ | Take screenshot |
84
+ | `tap` | ✅ | ✅ | Tap at coordinates or by text |
85
+ | `long_press` | ✅ | ✅ | Long press gesture |
86
+ | `swipe` | ✅ | ✅ | Swipe in direction or coordinates |
87
+ | `input_text` | ✅ | ✅ | Type text |
88
+ | `press_key` | ✅ | ✅ | Press hardware buttons |
89
+ | `launch_app` | ✅ | ✅ | Launch app |
90
+ | `stop_app` | ✅ | ✅ | Stop app |
91
+ | `install_app` | ✅ | ✅ | Install APK/.app |
92
+ | `get_ui` | ✅ | ⚠️ | Get UI hierarchy (limited on iOS) |
93
+ | `find_element` | ✅ | ❌ | Find elements by text/id |
94
+ | `get_current_activity` | ✅ | ❌ | Get foreground activity |
95
+ | `open_url` | ✅ | ✅ | Open URL in browser |
96
+ | `shell` | ✅ | ✅ | Run shell command |
97
+ | `wait` | ✅ | ✅ | Wait for duration |
98
+ | `get_logs` | ✅ | ✅ | Get device logs (logcat/system log) |
99
+ | `clear_logs` | ✅ | ⚠️ | Clear log buffer |
100
+ | `get_system_info` | ✅ | ❌ | Battery, memory info |
101
+
102
+ ## Usage Examples
103
+
104
+ Just talk to Claude naturally:
105
+
106
+ ```
107
+ "Show me all connected devices"
108
+ "Take a screenshot of the Android emulator"
109
+ "Take a screenshot on iOS"
110
+ "Tap on Settings"
111
+ "Swipe down to scroll"
112
+ "Type 'hello world' in the search field"
113
+ "Press the back button on Android"
114
+ "Open Safari on iOS"
115
+ "Switch to iOS simulator"
116
+ "Run the app on both platforms"
117
+ ```
118
+
119
+ ### Platform Selection
120
+
121
+ You can explicitly specify the platform:
122
+
123
+ ```
124
+ "Screenshot on android" → Uses Android device
125
+ "Screenshot on ios" → Uses iOS simulator
126
+ "Screenshot" → Uses last active device
127
+ ```
128
+
129
+ Or set the active device:
130
+
131
+ ```
132
+ "Use the iPhone 15 simulator"
133
+ "Switch to the Android emulator"
134
+ ```
135
+
136
+ ## How It Works
137
+
138
+ ```
139
+ ┌─────────────┐ ┌──────────────────┐ ┌─────────────────┐
140
+ │ Claude │────▶│ Claude Mobile │────▶│ Android (ADB) │
141
+ │ │ │ MCP Server │ └─────────────────┘
142
+ │ │ │ │ ┌─────────────────┐
143
+ │ │ │ │────▶│ iOS (simctl) │
144
+ └─────────────┘ └──────────────────┘ └─────────────────┘
145
+ ```
146
+
147
+ 1. Claude sends commands through MCP protocol
148
+ 2. Server routes to appropriate platform (ADB or simctl)
149
+ 3. Commands execute on your device
150
+ 4. Results (screenshots, UI data) return to Claude
151
+
152
+ ## License
153
+
154
+ MIT
@@ -0,0 +1,137 @@
1
+ export interface Device {
2
+ id: string;
3
+ state: string;
4
+ model?: string;
5
+ }
6
+ export declare class AdbClient {
7
+ private deviceId?;
8
+ constructor(deviceId?: string);
9
+ private get deviceFlag();
10
+ /**
11
+ * Execute ADB command and return stdout as string
12
+ */
13
+ exec(command: string): string;
14
+ /**
15
+ * Execute ADB command and return raw bytes (for screenshots)
16
+ */
17
+ execRaw(command: string): Buffer;
18
+ /**
19
+ * Execute ADB command async
20
+ */
21
+ execAsync(command: string): Promise<string>;
22
+ /**
23
+ * Get list of connected devices
24
+ */
25
+ getDevices(): Device[];
26
+ /**
27
+ * Set active device
28
+ */
29
+ setDevice(deviceId: string): void;
30
+ /**
31
+ * Take screenshot and return raw PNG buffer
32
+ */
33
+ screenshotRaw(): Buffer;
34
+ /**
35
+ * Take screenshot and return as base64 PNG (legacy)
36
+ */
37
+ screenshot(): string;
38
+ /**
39
+ * Tap at coordinates
40
+ */
41
+ tap(x: number, y: number): void;
42
+ /**
43
+ * Long press at coordinates
44
+ */
45
+ longPress(x: number, y: number, durationMs?: number): void;
46
+ /**
47
+ * Swipe gesture
48
+ */
49
+ swipe(x1: number, y1: number, x2: number, y2: number, durationMs?: number): void;
50
+ /**
51
+ * Swipe in direction (uses screen center)
52
+ */
53
+ swipeDirection(direction: "up" | "down" | "left" | "right", distance?: number): void;
54
+ /**
55
+ * Input text
56
+ */
57
+ inputText(text: string): void;
58
+ /**
59
+ * Press key by name or keycode
60
+ */
61
+ pressKey(key: string): void;
62
+ /**
63
+ * Get UI hierarchy XML
64
+ */
65
+ getUiHierarchy(): string;
66
+ /**
67
+ * Launch app by package name
68
+ */
69
+ launchApp(packageName: string): string;
70
+ /**
71
+ * Stop app
72
+ */
73
+ stopApp(packageName: string): void;
74
+ /**
75
+ * Clear app data
76
+ */
77
+ clearAppData(packageName: string): void;
78
+ /**
79
+ * Install APK
80
+ */
81
+ installApk(apkPath: string): string;
82
+ /**
83
+ * Uninstall app
84
+ */
85
+ uninstallApp(packageName: string): string;
86
+ /**
87
+ * Get current activity
88
+ */
89
+ getCurrentActivity(): string;
90
+ /**
91
+ * Get screen size
92
+ */
93
+ getScreenSize(): {
94
+ width: number;
95
+ height: number;
96
+ };
97
+ /**
98
+ * Wait for device
99
+ */
100
+ waitForDevice(): void;
101
+ /**
102
+ * Execute shell command
103
+ */
104
+ shell(command: string): string;
105
+ /**
106
+ * Get device logs (logcat)
107
+ * @param options - filter options
108
+ */
109
+ getLogs(options?: {
110
+ tag?: string;
111
+ level?: "V" | "D" | "I" | "W" | "E" | "F";
112
+ lines?: number;
113
+ since?: string;
114
+ package?: string;
115
+ }): string;
116
+ /**
117
+ * Clear logcat buffer
118
+ */
119
+ clearLogs(): void;
120
+ /**
121
+ * Get network stats
122
+ */
123
+ getNetworkStats(): string;
124
+ /**
125
+ * Get battery info
126
+ */
127
+ getBatteryInfo(): string;
128
+ /**
129
+ * Get memory info
130
+ */
131
+ getMemoryInfo(packageName?: string): string;
132
+ /**
133
+ * Get CPU info
134
+ */
135
+ getCpuInfo(): string;
136
+ }
137
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/adb/client.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,CAAS;gBAEd,QAAQ,CAAC,EAAE,MAAM;IAI7B,OAAO,KAAK,UAAU,GAErB;IAED;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAY7B;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAWhC;;OAEG;IACG,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQjD;;OAEG;IACH,UAAU,IAAI,MAAM,EAAE;IAoBtB;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAIjC;;OAEG;IACH,aAAa,IAAI,MAAM;IAIvB;;OAEG;IACH,UAAU,IAAI,MAAM;IAIpB;;OAEG;IACH,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACH,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,UAAU,GAAE,MAAa,GAAG,IAAI;IAIhE;;OAEG;IACH,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,GAAE,MAAY,GAAG,IAAI;IAIrF;;OAEG;IACH,cAAc,CAAC,SAAS,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,QAAQ,GA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AAI,MAAM;CAGrB"}
@@ -0,0 +1,329 @@
1
+ import { execSync, exec } from "child_process";
2
+ import { promisify } from "util";
3
+ const execAsync = promisify(exec);
4
+ export class AdbClient {
5
+ deviceId;
6
+ constructor(deviceId) {
7
+ this.deviceId = deviceId;
8
+ }
9
+ get deviceFlag() {
10
+ return this.deviceId ? `-s ${this.deviceId}` : "";
11
+ }
12
+ /**
13
+ * Execute ADB command and return stdout as string
14
+ */
15
+ exec(command) {
16
+ const fullCommand = `adb ${this.deviceFlag} ${command}`;
17
+ try {
18
+ return execSync(fullCommand, {
19
+ encoding: "utf-8",
20
+ maxBuffer: 50 * 1024 * 1024 // 50MB for screenshots
21
+ }).trim();
22
+ }
23
+ catch (error) {
24
+ throw new Error(`ADB command failed: ${fullCommand}\n${error.message}`);
25
+ }
26
+ }
27
+ /**
28
+ * Execute ADB command and return raw bytes (for screenshots)
29
+ */
30
+ execRaw(command) {
31
+ const fullCommand = `adb ${this.deviceFlag} ${command}`;
32
+ try {
33
+ return execSync(fullCommand, {
34
+ maxBuffer: 50 * 1024 * 1024
35
+ });
36
+ }
37
+ catch (error) {
38
+ throw new Error(`ADB command failed: ${fullCommand}\n${error.message}`);
39
+ }
40
+ }
41
+ /**
42
+ * Execute ADB command async
43
+ */
44
+ async execAsync(command) {
45
+ const fullCommand = `adb ${this.deviceFlag} ${command}`;
46
+ const { stdout } = await execAsync(fullCommand, {
47
+ maxBuffer: 50 * 1024 * 1024
48
+ });
49
+ return stdout.trim();
50
+ }
51
+ /**
52
+ * Get list of connected devices
53
+ */
54
+ getDevices() {
55
+ const output = execSync("adb devices -l", { encoding: "utf-8" });
56
+ const lines = output.split("\n").slice(1); // Skip header
57
+ return lines
58
+ .filter(line => line.trim())
59
+ .map(line => {
60
+ const parts = line.split(/\s+/);
61
+ const id = parts[0];
62
+ const state = parts[1];
63
+ const modelMatch = line.match(/model:(\S+)/);
64
+ return {
65
+ id,
66
+ state,
67
+ model: modelMatch?.[1]
68
+ };
69
+ });
70
+ }
71
+ /**
72
+ * Set active device
73
+ */
74
+ setDevice(deviceId) {
75
+ this.deviceId = deviceId;
76
+ }
77
+ /**
78
+ * Take screenshot and return raw PNG buffer
79
+ */
80
+ screenshotRaw() {
81
+ return this.execRaw("exec-out screencap -p");
82
+ }
83
+ /**
84
+ * Take screenshot and return as base64 PNG (legacy)
85
+ */
86
+ screenshot() {
87
+ return this.screenshotRaw().toString("base64");
88
+ }
89
+ /**
90
+ * Tap at coordinates
91
+ */
92
+ tap(x, y) {
93
+ this.exec(`shell input tap ${x} ${y}`);
94
+ }
95
+ /**
96
+ * Long press at coordinates
97
+ */
98
+ longPress(x, y, durationMs = 1000) {
99
+ this.exec(`shell input swipe ${x} ${y} ${x} ${y} ${durationMs}`);
100
+ }
101
+ /**
102
+ * Swipe gesture
103
+ */
104
+ swipe(x1, y1, x2, y2, durationMs = 300) {
105
+ this.exec(`shell input swipe ${x1} ${y1} ${x2} ${y2} ${durationMs}`);
106
+ }
107
+ /**
108
+ * Swipe in direction (uses screen center)
109
+ */
110
+ swipeDirection(direction, distance = 800) {
111
+ // Get screen size
112
+ const sizeOutput = this.exec("shell wm size");
113
+ const match = sizeOutput.match(/(\d+)x(\d+)/);
114
+ const width = match ? parseInt(match[1]) : 1080;
115
+ const height = match ? parseInt(match[2]) : 1920;
116
+ const centerX = Math.floor(width / 2);
117
+ const centerY = Math.floor(height / 2);
118
+ const coords = {
119
+ up: [centerX, centerY + distance / 2, centerX, centerY - distance / 2],
120
+ down: [centerX, centerY - distance / 2, centerX, centerY + distance / 2],
121
+ left: [centerX + distance / 2, centerY, centerX - distance / 2, centerY],
122
+ right: [centerX - distance / 2, centerY, centerX + distance / 2, centerY],
123
+ };
124
+ const [x1, y1, x2, y2] = coords[direction];
125
+ this.swipe(x1, y1, x2, y2);
126
+ }
127
+ /**
128
+ * Input text
129
+ */
130
+ inputText(text) {
131
+ // Escape special characters for shell
132
+ const escaped = text
133
+ .replace(/\\/g, "\\\\")
134
+ .replace(/"/g, '\\"')
135
+ .replace(/'/g, "\\'")
136
+ .replace(/`/g, "\\`")
137
+ .replace(/\$/g, "\\$")
138
+ .replace(/ /g, "%s")
139
+ .replace(/&/g, "\\&")
140
+ .replace(/\(/g, "\\(")
141
+ .replace(/\)/g, "\\)")
142
+ .replace(/</g, "\\<")
143
+ .replace(/>/g, "\\>")
144
+ .replace(/\|/g, "\\|")
145
+ .replace(/;/g, "\\;");
146
+ this.exec(`shell input text "${escaped}"`);
147
+ }
148
+ /**
149
+ * Press key by name or keycode
150
+ */
151
+ pressKey(key) {
152
+ const keyCodes = {
153
+ "BACK": 4,
154
+ "HOME": 3,
155
+ "MENU": 82,
156
+ "ENTER": 66,
157
+ "TAB": 61,
158
+ "DELETE": 67,
159
+ "BACKSPACE": 67,
160
+ "POWER": 26,
161
+ "VOLUME_UP": 24,
162
+ "VOLUME_DOWN": 25,
163
+ "VOLUME_MUTE": 164,
164
+ "CAMERA": 27,
165
+ "APP_SWITCH": 187,
166
+ "DPAD_UP": 19,
167
+ "DPAD_DOWN": 20,
168
+ "DPAD_LEFT": 21,
169
+ "DPAD_RIGHT": 22,
170
+ "DPAD_CENTER": 23,
171
+ "SEARCH": 84,
172
+ "ESCAPE": 111,
173
+ "SPACE": 62,
174
+ };
175
+ const keyCode = keyCodes[key.toUpperCase()] ?? parseInt(key);
176
+ if (isNaN(keyCode)) {
177
+ throw new Error(`Unknown key: ${key}`);
178
+ }
179
+ this.exec(`shell input keyevent ${keyCode}`);
180
+ }
181
+ /**
182
+ * Get UI hierarchy XML
183
+ */
184
+ getUiHierarchy() {
185
+ this.exec("shell uiautomator dump /sdcard/ui.xml");
186
+ return this.exec("shell cat /sdcard/ui.xml");
187
+ }
188
+ /**
189
+ * Launch app by package name
190
+ */
191
+ launchApp(packageName) {
192
+ // Try to get launch activity
193
+ try {
194
+ const output = this.exec(`shell cmd package resolve-activity --brief ${packageName}`);
195
+ const activity = output.split("\n").find(line => line.includes("/"));
196
+ if (activity) {
197
+ this.exec(`shell am start -n ${activity.trim()}`);
198
+ return `Launched ${activity.trim()}`;
199
+ }
200
+ }
201
+ catch {
202
+ // Fallback: use monkey to launch
203
+ }
204
+ this.exec(`shell monkey -p ${packageName} -c android.intent.category.LAUNCHER 1`);
205
+ return `Launched ${packageName}`;
206
+ }
207
+ /**
208
+ * Stop app
209
+ */
210
+ stopApp(packageName) {
211
+ this.exec(`shell am force-stop ${packageName}`);
212
+ }
213
+ /**
214
+ * Clear app data
215
+ */
216
+ clearAppData(packageName) {
217
+ this.exec(`shell pm clear ${packageName}`);
218
+ }
219
+ /**
220
+ * Install APK
221
+ */
222
+ installApk(apkPath) {
223
+ return this.exec(`install -r "${apkPath}"`);
224
+ }
225
+ /**
226
+ * Uninstall app
227
+ */
228
+ uninstallApp(packageName) {
229
+ return this.exec(`uninstall ${packageName}`);
230
+ }
231
+ /**
232
+ * Get current activity
233
+ */
234
+ getCurrentActivity() {
235
+ const output = this.exec("shell dumpsys activity activities | grep mResumedActivity");
236
+ const match = output.match(/(\S+\/\S+)/);
237
+ return match?.[1] ?? "unknown";
238
+ }
239
+ /**
240
+ * Get screen size
241
+ */
242
+ getScreenSize() {
243
+ const output = this.exec("shell wm size");
244
+ const match = output.match(/(\d+)x(\d+)/);
245
+ return {
246
+ width: match ? parseInt(match[1]) : 1080,
247
+ height: match ? parseInt(match[2]) : 1920
248
+ };
249
+ }
250
+ /**
251
+ * Wait for device
252
+ */
253
+ waitForDevice() {
254
+ this.exec("wait-for-device");
255
+ }
256
+ /**
257
+ * Execute shell command
258
+ */
259
+ shell(command) {
260
+ return this.exec(`shell ${command}`);
261
+ }
262
+ /**
263
+ * Get device logs (logcat)
264
+ * @param options - filter options
265
+ */
266
+ getLogs(options = {}) {
267
+ let cmd = "logcat -d";
268
+ // Filter by log level
269
+ if (options.level) {
270
+ cmd += ` *:${options.level}`;
271
+ }
272
+ // Filter by tag
273
+ if (options.tag) {
274
+ cmd += ` -s ${options.tag}`;
275
+ }
276
+ // Limit number of lines
277
+ if (options.lines) {
278
+ cmd += ` -t ${options.lines}`;
279
+ }
280
+ // Filter by time (e.g., "01-01 00:00:00.000")
281
+ if (options.since) {
282
+ cmd += ` -t "${options.since}"`;
283
+ }
284
+ const output = this.exec(`shell ${cmd}`);
285
+ // Filter by package if specified
286
+ if (options.package) {
287
+ const lines = output.split("\n");
288
+ const filtered = lines.filter(line => line.includes(options.package) ||
289
+ line.match(/^\d+-\d+\s+\d+:\d+/) // Keep timestamp lines
290
+ );
291
+ return filtered.join("\n");
292
+ }
293
+ return output;
294
+ }
295
+ /**
296
+ * Clear logcat buffer
297
+ */
298
+ clearLogs() {
299
+ this.exec("logcat -c");
300
+ }
301
+ /**
302
+ * Get network stats
303
+ */
304
+ getNetworkStats() {
305
+ return this.exec("shell dumpsys netstats | head -100");
306
+ }
307
+ /**
308
+ * Get battery info
309
+ */
310
+ getBatteryInfo() {
311
+ return this.exec("shell dumpsys battery");
312
+ }
313
+ /**
314
+ * Get memory info
315
+ */
316
+ getMemoryInfo(packageName) {
317
+ if (packageName) {
318
+ return this.exec(`shell dumpsys meminfo ${packageName}`);
319
+ }
320
+ return this.exec("shell cat /proc/meminfo | head -20");
321
+ }
322
+ /**
323
+ * Get CPU info
324
+ */
325
+ getCpuInfo() {
326
+ return this.exec("shell top -n 1 | head -20");
327
+ }
328
+ }
329
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/adb/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAQlC,MAAM,OAAO,SAAS;IACZ,QAAQ,CAAU;IAE1B,YAAY,QAAiB;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAY,U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,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CACnC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAQ,CAAC;gBAC/B,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,uBAAuB;aACzD,CAAC;YACF,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,SAAS;QACP,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,WAAoB;QAChC,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC,IAAI,CAAC,yBAAyB,WAAW,EAAE,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAChD,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ export { AdbClient } from "./client.js";
2
+ export type { Device } from "./client.js";
3
+ export { parseUiHierarchy, findByText, findByResourceId, findByClassName, findClickable, findElements, formatElement, formatUiTree, } from "./ui-parser.js";
4
+ export type { Bounds, UiElement } from "./ui-parser.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adb/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { AdbClient } from "./client.js";
2
+ export { parseUiHierarchy, findByText, findByResourceId, findByClassName, findClickable, findElements, formatElement, formatUiTree, } from "./ui-parser.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adb/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,gBAAgB,CAAC"}