@nbakka/mcp-appium 4.0.7 → 4.0.8

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 (2) hide show
  1. package/lib/android.js +14 -1
  2. package/package.json +1 -1
package/lib/android.js CHANGED
@@ -249,11 +249,24 @@ class AndroidRobot {
249
249
  const elements = this.collectElements(hierarchy.node);
250
250
  return elements;
251
251
  }
252
+ parseBounds(bounds) {
253
+ if (!bounds) return { x: 0, y: 0 };
254
+ const match = bounds.match(/\[(\d+),(\d+)\]/);
255
+ if (!match) return { x: 0, y: 0 };
256
+ return { x: parseInt(match[1]), y: parseInt(match[2]) };
257
+ }
252
258
  async getSimplifiedElements() {
253
259
  const parsedXml = await this.getUiAutomatorXml();
254
260
  const hierarchy = parsedXml.hierarchy;
255
261
  const elements = this.collectSimplifiedElements(hierarchy.node);
256
- return elements;
262
+
263
+ // Sort by visual position: top-to-bottom, left-to-right
264
+ return elements.sort((a, b) => {
265
+ const rectA = this.parseBounds(a.bounds);
266
+ const rectB = this.parseBounds(b.bounds);
267
+ if (rectA.y !== rectB.y) return rectA.y - rectB.y;
268
+ return rectA.x - rectB.x;
269
+ });
257
270
  }
258
271
  async terminateApp(packageName) {
259
272
  this.adb("shell", "am", "force-stop", packageName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nbakka/mcp-appium",
3
- "version": "4.0.7",
3
+ "version": "4.0.8",
4
4
  "description": "Appium MCP",
5
5
  "engines": {
6
6
  "node": ">=18"