@midscene/android 1.4.4 → 1.4.5-beta-20260214073330.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.
- package/dist/es/cli.mjs +19 -13
- package/dist/es/index.mjs +19 -13
- package/dist/es/mcp-server.mjs +19 -13
- package/dist/lib/cli.js +19 -13
- package/dist/lib/index.js +19 -13
- package/dist/lib/mcp-server.js +19 -13
- package/dist/types/index.d.ts +9 -1
- package/dist/types/mcp-server.d.ts +9 -1
- package/package.json +4 -4
package/dist/es/cli.mjs
CHANGED
|
@@ -1096,6 +1096,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1096
1096
|
if (shouldCache) this.cachedOrientation = orientation;
|
|
1097
1097
|
return orientation;
|
|
1098
1098
|
}
|
|
1099
|
+
async getPhysicalWidth() {
|
|
1100
|
+
const deviceInfo = await this.getDevicePhysicalInfo();
|
|
1101
|
+
const isLandscape = 1 === deviceInfo.orientation || 3 === deviceInfo.orientation;
|
|
1102
|
+
const shouldSwap = true !== deviceInfo.isCurrentOrientation && isLandscape;
|
|
1103
|
+
return shouldSwap ? deviceInfo.physicalHeight : deviceInfo.physicalWidth;
|
|
1104
|
+
}
|
|
1099
1105
|
async size() {
|
|
1100
1106
|
const deviceInfo = await this.getDevicePhysicalInfo();
|
|
1101
1107
|
const isLandscape = 1 === deviceInfo.orientation || 3 === deviceInfo.orientation;
|
|
@@ -1103,7 +1109,6 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1103
1109
|
const width = shouldSwap ? deviceInfo.physicalHeight : deviceInfo.physicalWidth;
|
|
1104
1110
|
const height = shouldSwap ? deviceInfo.physicalWidth : deviceInfo.physicalHeight;
|
|
1105
1111
|
const scale = this.options?.screenshotResizeScale ?? 1 / this.devicePixelRatio;
|
|
1106
|
-
this.scalingRatio = scale;
|
|
1107
1112
|
const logicalWidth = Math.round(width * scale);
|
|
1108
1113
|
const logicalHeight = Math.round(height * scale);
|
|
1109
1114
|
return {
|
|
@@ -1112,8 +1117,10 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1112
1117
|
dpr: this.devicePixelRatio
|
|
1113
1118
|
};
|
|
1114
1119
|
}
|
|
1115
|
-
adjustCoordinates(x, y) {
|
|
1116
|
-
const
|
|
1120
|
+
async adjustCoordinates(x, y) {
|
|
1121
|
+
const physicalWidth = await this.getPhysicalWidth();
|
|
1122
|
+
const { width: logicalWidth } = await this.size();
|
|
1123
|
+
const scale = logicalWidth / physicalWidth;
|
|
1117
1124
|
return {
|
|
1118
1125
|
x: Math.round(x / scale),
|
|
1119
1126
|
y: Math.round(y / scale)
|
|
@@ -1438,12 +1445,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1438
1445
|
}
|
|
1439
1446
|
async mouseClick(x, y) {
|
|
1440
1447
|
const adb = await this.getAdb();
|
|
1441
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1448
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1442
1449
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedX} ${adjustedY} ${adjustedX} ${adjustedY} 150`);
|
|
1443
1450
|
}
|
|
1444
1451
|
async mouseDoubleClick(x, y) {
|
|
1445
1452
|
const adb = await this.getAdb();
|
|
1446
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1453
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1447
1454
|
const tapCommand = `input${this.getDisplayArg()} tap ${adjustedX} ${adjustedY}`;
|
|
1448
1455
|
await adb.shell(tapCommand);
|
|
1449
1456
|
await sleep(50);
|
|
@@ -1454,8 +1461,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1454
1461
|
}
|
|
1455
1462
|
async mouseDrag(from, to, duration) {
|
|
1456
1463
|
const adb = await this.getAdb();
|
|
1457
|
-
const { x: fromX, y: fromY } = this.adjustCoordinates(from.x, from.y);
|
|
1458
|
-
const { x: toX, y: toY } = this.adjustCoordinates(to.x, to.y);
|
|
1464
|
+
const { x: fromX, y: fromY } = await this.adjustCoordinates(from.x, from.y);
|
|
1465
|
+
const { x: toX, y: toY } = await this.adjustCoordinates(to.x, to.y);
|
|
1459
1466
|
const swipeDuration = duration ?? defaultNormalScrollDuration;
|
|
1460
1467
|
await adb.shell(`input${this.getDisplayArg()} swipe ${fromX} ${fromY} ${toX} ${toY} ${swipeDuration}`);
|
|
1461
1468
|
}
|
|
@@ -1473,8 +1480,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1473
1480
|
deltaY = Math.max(-maxNegativeDeltaY, Math.min(deltaY, maxPositiveDeltaY));
|
|
1474
1481
|
const endX = Math.round(startX - deltaX);
|
|
1475
1482
|
const endY = Math.round(startY - deltaY);
|
|
1476
|
-
const { x: adjustedStartX, y: adjustedStartY } = this.adjustCoordinates(startX, startY);
|
|
1477
|
-
const { x: adjustedEndX, y: adjustedEndY } = this.adjustCoordinates(endX, endY);
|
|
1483
|
+
const { x: adjustedStartX, y: adjustedStartY } = await this.adjustCoordinates(startX, startY);
|
|
1484
|
+
const { x: adjustedEndX, y: adjustedEndY } = await this.adjustCoordinates(endX, endY);
|
|
1478
1485
|
const adb = await this.getAdb();
|
|
1479
1486
|
const swipeDuration = duration ?? defaultNormalScrollDuration;
|
|
1480
1487
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedStartX} ${adjustedStartY} ${adjustedEndX} ${adjustedEndY} ${swipeDuration}`);
|
|
@@ -1524,7 +1531,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1524
1531
|
}
|
|
1525
1532
|
async longPress(x, y, duration = 2000) {
|
|
1526
1533
|
const adb = await this.getAdb();
|
|
1527
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1534
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1528
1535
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedX} ${adjustedY} ${adjustedX} ${adjustedY} ${duration}`);
|
|
1529
1536
|
}
|
|
1530
1537
|
async pullDown(startPoint, distance, duration = 800) {
|
|
@@ -1546,8 +1553,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1546
1553
|
}
|
|
1547
1554
|
async pullDrag(from, to, duration) {
|
|
1548
1555
|
const adb = await this.getAdb();
|
|
1549
|
-
const { x: fromX, y: fromY } = this.adjustCoordinates(from.x, from.y);
|
|
1550
|
-
const { x: toX, y: toY } = this.adjustCoordinates(to.x, to.y);
|
|
1556
|
+
const { x: fromX, y: fromY } = await this.adjustCoordinates(from.x, from.y);
|
|
1557
|
+
const { x: toX, y: toY } = await this.adjustCoordinates(to.x, to.y);
|
|
1551
1558
|
await adb.shell(`input${this.getDisplayArg()} swipe ${fromX} ${fromY} ${toX} ${toY} ${duration}`);
|
|
1552
1559
|
}
|
|
1553
1560
|
async pullUp(startPoint, distance, duration = 600) {
|
|
@@ -1634,7 +1641,6 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1634
1641
|
device_define_property(this, "yadbPushed", false);
|
|
1635
1642
|
device_define_property(this, "devicePixelRatio", 1);
|
|
1636
1643
|
device_define_property(this, "devicePixelRatioInitialized", false);
|
|
1637
|
-
device_define_property(this, "scalingRatio", 1);
|
|
1638
1644
|
device_define_property(this, "adb", null);
|
|
1639
1645
|
device_define_property(this, "connectingAdb", null);
|
|
1640
1646
|
device_define_property(this, "destroyed", false);
|
package/dist/es/index.mjs
CHANGED
|
@@ -998,6 +998,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
998
998
|
if (shouldCache) this.cachedOrientation = orientation;
|
|
999
999
|
return orientation;
|
|
1000
1000
|
}
|
|
1001
|
+
async getPhysicalWidth() {
|
|
1002
|
+
const deviceInfo = await this.getDevicePhysicalInfo();
|
|
1003
|
+
const isLandscape = 1 === deviceInfo.orientation || 3 === deviceInfo.orientation;
|
|
1004
|
+
const shouldSwap = true !== deviceInfo.isCurrentOrientation && isLandscape;
|
|
1005
|
+
return shouldSwap ? deviceInfo.physicalHeight : deviceInfo.physicalWidth;
|
|
1006
|
+
}
|
|
1001
1007
|
async size() {
|
|
1002
1008
|
const deviceInfo = await this.getDevicePhysicalInfo();
|
|
1003
1009
|
const isLandscape = 1 === deviceInfo.orientation || 3 === deviceInfo.orientation;
|
|
@@ -1005,7 +1011,6 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1005
1011
|
const width = shouldSwap ? deviceInfo.physicalHeight : deviceInfo.physicalWidth;
|
|
1006
1012
|
const height = shouldSwap ? deviceInfo.physicalWidth : deviceInfo.physicalHeight;
|
|
1007
1013
|
const scale = this.options?.screenshotResizeScale ?? 1 / this.devicePixelRatio;
|
|
1008
|
-
this.scalingRatio = scale;
|
|
1009
1014
|
const logicalWidth = Math.round(width * scale);
|
|
1010
1015
|
const logicalHeight = Math.round(height * scale);
|
|
1011
1016
|
return {
|
|
@@ -1014,8 +1019,10 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1014
1019
|
dpr: this.devicePixelRatio
|
|
1015
1020
|
};
|
|
1016
1021
|
}
|
|
1017
|
-
adjustCoordinates(x, y) {
|
|
1018
|
-
const
|
|
1022
|
+
async adjustCoordinates(x, y) {
|
|
1023
|
+
const physicalWidth = await this.getPhysicalWidth();
|
|
1024
|
+
const { width: logicalWidth } = await this.size();
|
|
1025
|
+
const scale = logicalWidth / physicalWidth;
|
|
1019
1026
|
return {
|
|
1020
1027
|
x: Math.round(x / scale),
|
|
1021
1028
|
y: Math.round(y / scale)
|
|
@@ -1340,12 +1347,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1340
1347
|
}
|
|
1341
1348
|
async mouseClick(x, y) {
|
|
1342
1349
|
const adb = await this.getAdb();
|
|
1343
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1350
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1344
1351
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedX} ${adjustedY} ${adjustedX} ${adjustedY} 150`);
|
|
1345
1352
|
}
|
|
1346
1353
|
async mouseDoubleClick(x, y) {
|
|
1347
1354
|
const adb = await this.getAdb();
|
|
1348
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1355
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1349
1356
|
const tapCommand = `input${this.getDisplayArg()} tap ${adjustedX} ${adjustedY}`;
|
|
1350
1357
|
await adb.shell(tapCommand);
|
|
1351
1358
|
await sleep(50);
|
|
@@ -1356,8 +1363,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1356
1363
|
}
|
|
1357
1364
|
async mouseDrag(from, to, duration) {
|
|
1358
1365
|
const adb = await this.getAdb();
|
|
1359
|
-
const { x: fromX, y: fromY } = this.adjustCoordinates(from.x, from.y);
|
|
1360
|
-
const { x: toX, y: toY } = this.adjustCoordinates(to.x, to.y);
|
|
1366
|
+
const { x: fromX, y: fromY } = await this.adjustCoordinates(from.x, from.y);
|
|
1367
|
+
const { x: toX, y: toY } = await this.adjustCoordinates(to.x, to.y);
|
|
1361
1368
|
const swipeDuration = duration ?? defaultNormalScrollDuration;
|
|
1362
1369
|
await adb.shell(`input${this.getDisplayArg()} swipe ${fromX} ${fromY} ${toX} ${toY} ${swipeDuration}`);
|
|
1363
1370
|
}
|
|
@@ -1375,8 +1382,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1375
1382
|
deltaY = Math.max(-maxNegativeDeltaY, Math.min(deltaY, maxPositiveDeltaY));
|
|
1376
1383
|
const endX = Math.round(startX - deltaX);
|
|
1377
1384
|
const endY = Math.round(startY - deltaY);
|
|
1378
|
-
const { x: adjustedStartX, y: adjustedStartY } = this.adjustCoordinates(startX, startY);
|
|
1379
|
-
const { x: adjustedEndX, y: adjustedEndY } = this.adjustCoordinates(endX, endY);
|
|
1385
|
+
const { x: adjustedStartX, y: adjustedStartY } = await this.adjustCoordinates(startX, startY);
|
|
1386
|
+
const { x: adjustedEndX, y: adjustedEndY } = await this.adjustCoordinates(endX, endY);
|
|
1380
1387
|
const adb = await this.getAdb();
|
|
1381
1388
|
const swipeDuration = duration ?? defaultNormalScrollDuration;
|
|
1382
1389
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedStartX} ${adjustedStartY} ${adjustedEndX} ${adjustedEndY} ${swipeDuration}`);
|
|
@@ -1426,7 +1433,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1426
1433
|
}
|
|
1427
1434
|
async longPress(x, y, duration = 2000) {
|
|
1428
1435
|
const adb = await this.getAdb();
|
|
1429
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1436
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1430
1437
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedX} ${adjustedY} ${adjustedX} ${adjustedY} ${duration}`);
|
|
1431
1438
|
}
|
|
1432
1439
|
async pullDown(startPoint, distance, duration = 800) {
|
|
@@ -1448,8 +1455,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1448
1455
|
}
|
|
1449
1456
|
async pullDrag(from, to, duration) {
|
|
1450
1457
|
const adb = await this.getAdb();
|
|
1451
|
-
const { x: fromX, y: fromY } = this.adjustCoordinates(from.x, from.y);
|
|
1452
|
-
const { x: toX, y: toY } = this.adjustCoordinates(to.x, to.y);
|
|
1458
|
+
const { x: fromX, y: fromY } = await this.adjustCoordinates(from.x, from.y);
|
|
1459
|
+
const { x: toX, y: toY } = await this.adjustCoordinates(to.x, to.y);
|
|
1453
1460
|
await adb.shell(`input${this.getDisplayArg()} swipe ${fromX} ${fromY} ${toX} ${toY} ${duration}`);
|
|
1454
1461
|
}
|
|
1455
1462
|
async pullUp(startPoint, distance, duration = 600) {
|
|
@@ -1536,7 +1543,6 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1536
1543
|
device_define_property(this, "yadbPushed", false);
|
|
1537
1544
|
device_define_property(this, "devicePixelRatio", 1);
|
|
1538
1545
|
device_define_property(this, "devicePixelRatioInitialized", false);
|
|
1539
|
-
device_define_property(this, "scalingRatio", 1);
|
|
1540
1546
|
device_define_property(this, "adb", null);
|
|
1541
1547
|
device_define_property(this, "connectingAdb", null);
|
|
1542
1548
|
device_define_property(this, "destroyed", false);
|
package/dist/es/mcp-server.mjs
CHANGED
|
@@ -1095,6 +1095,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1095
1095
|
if (shouldCache) this.cachedOrientation = orientation;
|
|
1096
1096
|
return orientation;
|
|
1097
1097
|
}
|
|
1098
|
+
async getPhysicalWidth() {
|
|
1099
|
+
const deviceInfo = await this.getDevicePhysicalInfo();
|
|
1100
|
+
const isLandscape = 1 === deviceInfo.orientation || 3 === deviceInfo.orientation;
|
|
1101
|
+
const shouldSwap = true !== deviceInfo.isCurrentOrientation && isLandscape;
|
|
1102
|
+
return shouldSwap ? deviceInfo.physicalHeight : deviceInfo.physicalWidth;
|
|
1103
|
+
}
|
|
1098
1104
|
async size() {
|
|
1099
1105
|
const deviceInfo = await this.getDevicePhysicalInfo();
|
|
1100
1106
|
const isLandscape = 1 === deviceInfo.orientation || 3 === deviceInfo.orientation;
|
|
@@ -1102,7 +1108,6 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1102
1108
|
const width = shouldSwap ? deviceInfo.physicalHeight : deviceInfo.physicalWidth;
|
|
1103
1109
|
const height = shouldSwap ? deviceInfo.physicalWidth : deviceInfo.physicalHeight;
|
|
1104
1110
|
const scale = this.options?.screenshotResizeScale ?? 1 / this.devicePixelRatio;
|
|
1105
|
-
this.scalingRatio = scale;
|
|
1106
1111
|
const logicalWidth = Math.round(width * scale);
|
|
1107
1112
|
const logicalHeight = Math.round(height * scale);
|
|
1108
1113
|
return {
|
|
@@ -1111,8 +1116,10 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1111
1116
|
dpr: this.devicePixelRatio
|
|
1112
1117
|
};
|
|
1113
1118
|
}
|
|
1114
|
-
adjustCoordinates(x, y) {
|
|
1115
|
-
const
|
|
1119
|
+
async adjustCoordinates(x, y) {
|
|
1120
|
+
const physicalWidth = await this.getPhysicalWidth();
|
|
1121
|
+
const { width: logicalWidth } = await this.size();
|
|
1122
|
+
const scale = logicalWidth / physicalWidth;
|
|
1116
1123
|
return {
|
|
1117
1124
|
x: Math.round(x / scale),
|
|
1118
1125
|
y: Math.round(y / scale)
|
|
@@ -1437,12 +1444,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1437
1444
|
}
|
|
1438
1445
|
async mouseClick(x, y) {
|
|
1439
1446
|
const adb = await this.getAdb();
|
|
1440
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1447
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1441
1448
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedX} ${adjustedY} ${adjustedX} ${adjustedY} 150`);
|
|
1442
1449
|
}
|
|
1443
1450
|
async mouseDoubleClick(x, y) {
|
|
1444
1451
|
const adb = await this.getAdb();
|
|
1445
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1452
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1446
1453
|
const tapCommand = `input${this.getDisplayArg()} tap ${adjustedX} ${adjustedY}`;
|
|
1447
1454
|
await adb.shell(tapCommand);
|
|
1448
1455
|
await sleep(50);
|
|
@@ -1453,8 +1460,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1453
1460
|
}
|
|
1454
1461
|
async mouseDrag(from, to, duration) {
|
|
1455
1462
|
const adb = await this.getAdb();
|
|
1456
|
-
const { x: fromX, y: fromY } = this.adjustCoordinates(from.x, from.y);
|
|
1457
|
-
const { x: toX, y: toY } = this.adjustCoordinates(to.x, to.y);
|
|
1463
|
+
const { x: fromX, y: fromY } = await this.adjustCoordinates(from.x, from.y);
|
|
1464
|
+
const { x: toX, y: toY } = await this.adjustCoordinates(to.x, to.y);
|
|
1458
1465
|
const swipeDuration = duration ?? defaultNormalScrollDuration;
|
|
1459
1466
|
await adb.shell(`input${this.getDisplayArg()} swipe ${fromX} ${fromY} ${toX} ${toY} ${swipeDuration}`);
|
|
1460
1467
|
}
|
|
@@ -1472,8 +1479,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1472
1479
|
deltaY = Math.max(-maxNegativeDeltaY, Math.min(deltaY, maxPositiveDeltaY));
|
|
1473
1480
|
const endX = Math.round(startX - deltaX);
|
|
1474
1481
|
const endY = Math.round(startY - deltaY);
|
|
1475
|
-
const { x: adjustedStartX, y: adjustedStartY } = this.adjustCoordinates(startX, startY);
|
|
1476
|
-
const { x: adjustedEndX, y: adjustedEndY } = this.adjustCoordinates(endX, endY);
|
|
1482
|
+
const { x: adjustedStartX, y: adjustedStartY } = await this.adjustCoordinates(startX, startY);
|
|
1483
|
+
const { x: adjustedEndX, y: adjustedEndY } = await this.adjustCoordinates(endX, endY);
|
|
1477
1484
|
const adb = await this.getAdb();
|
|
1478
1485
|
const swipeDuration = duration ?? defaultNormalScrollDuration;
|
|
1479
1486
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedStartX} ${adjustedStartY} ${adjustedEndX} ${adjustedEndY} ${swipeDuration}`);
|
|
@@ -1523,7 +1530,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1523
1530
|
}
|
|
1524
1531
|
async longPress(x, y, duration = 2000) {
|
|
1525
1532
|
const adb = await this.getAdb();
|
|
1526
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1533
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1527
1534
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedX} ${adjustedY} ${adjustedX} ${adjustedY} ${duration}`);
|
|
1528
1535
|
}
|
|
1529
1536
|
async pullDown(startPoint, distance, duration = 800) {
|
|
@@ -1545,8 +1552,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1545
1552
|
}
|
|
1546
1553
|
async pullDrag(from, to, duration) {
|
|
1547
1554
|
const adb = await this.getAdb();
|
|
1548
|
-
const { x: fromX, y: fromY } = this.adjustCoordinates(from.x, from.y);
|
|
1549
|
-
const { x: toX, y: toY } = this.adjustCoordinates(to.x, to.y);
|
|
1555
|
+
const { x: fromX, y: fromY } = await this.adjustCoordinates(from.x, from.y);
|
|
1556
|
+
const { x: toX, y: toY } = await this.adjustCoordinates(to.x, to.y);
|
|
1550
1557
|
await adb.shell(`input${this.getDisplayArg()} swipe ${fromX} ${fromY} ${toX} ${toY} ${duration}`);
|
|
1551
1558
|
}
|
|
1552
1559
|
async pullUp(startPoint, distance, duration = 600) {
|
|
@@ -1633,7 +1640,6 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1633
1640
|
device_define_property(this, "yadbPushed", false);
|
|
1634
1641
|
device_define_property(this, "devicePixelRatio", 1);
|
|
1635
1642
|
device_define_property(this, "devicePixelRatioInitialized", false);
|
|
1636
|
-
device_define_property(this, "scalingRatio", 1);
|
|
1637
1643
|
device_define_property(this, "adb", null);
|
|
1638
1644
|
device_define_property(this, "connectingAdb", null);
|
|
1639
1645
|
device_define_property(this, "destroyed", false);
|
package/dist/lib/cli.js
CHANGED
|
@@ -1111,6 +1111,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1111
1111
|
if (shouldCache) this.cachedOrientation = orientation;
|
|
1112
1112
|
return orientation;
|
|
1113
1113
|
}
|
|
1114
|
+
async getPhysicalWidth() {
|
|
1115
|
+
const deviceInfo = await this.getDevicePhysicalInfo();
|
|
1116
|
+
const isLandscape = 1 === deviceInfo.orientation || 3 === deviceInfo.orientation;
|
|
1117
|
+
const shouldSwap = true !== deviceInfo.isCurrentOrientation && isLandscape;
|
|
1118
|
+
return shouldSwap ? deviceInfo.physicalHeight : deviceInfo.physicalWidth;
|
|
1119
|
+
}
|
|
1114
1120
|
async size() {
|
|
1115
1121
|
const deviceInfo = await this.getDevicePhysicalInfo();
|
|
1116
1122
|
const isLandscape = 1 === deviceInfo.orientation || 3 === deviceInfo.orientation;
|
|
@@ -1118,7 +1124,6 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1118
1124
|
const width = shouldSwap ? deviceInfo.physicalHeight : deviceInfo.physicalWidth;
|
|
1119
1125
|
const height = shouldSwap ? deviceInfo.physicalWidth : deviceInfo.physicalHeight;
|
|
1120
1126
|
const scale = this.options?.screenshotResizeScale ?? 1 / this.devicePixelRatio;
|
|
1121
|
-
this.scalingRatio = scale;
|
|
1122
1127
|
const logicalWidth = Math.round(width * scale);
|
|
1123
1128
|
const logicalHeight = Math.round(height * scale);
|
|
1124
1129
|
return {
|
|
@@ -1127,8 +1132,10 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1127
1132
|
dpr: this.devicePixelRatio
|
|
1128
1133
|
};
|
|
1129
1134
|
}
|
|
1130
|
-
adjustCoordinates(x, y) {
|
|
1131
|
-
const
|
|
1135
|
+
async adjustCoordinates(x, y) {
|
|
1136
|
+
const physicalWidth = await this.getPhysicalWidth();
|
|
1137
|
+
const { width: logicalWidth } = await this.size();
|
|
1138
|
+
const scale = logicalWidth / physicalWidth;
|
|
1132
1139
|
return {
|
|
1133
1140
|
x: Math.round(x / scale),
|
|
1134
1141
|
y: Math.round(y / scale)
|
|
@@ -1453,12 +1460,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1453
1460
|
}
|
|
1454
1461
|
async mouseClick(x, y) {
|
|
1455
1462
|
const adb = await this.getAdb();
|
|
1456
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1463
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1457
1464
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedX} ${adjustedY} ${adjustedX} ${adjustedY} 150`);
|
|
1458
1465
|
}
|
|
1459
1466
|
async mouseDoubleClick(x, y) {
|
|
1460
1467
|
const adb = await this.getAdb();
|
|
1461
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1468
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1462
1469
|
const tapCommand = `input${this.getDisplayArg()} tap ${adjustedX} ${adjustedY}`;
|
|
1463
1470
|
await adb.shell(tapCommand);
|
|
1464
1471
|
await (0, core_utils_namespaceObject.sleep)(50);
|
|
@@ -1469,8 +1476,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1469
1476
|
}
|
|
1470
1477
|
async mouseDrag(from, to, duration) {
|
|
1471
1478
|
const adb = await this.getAdb();
|
|
1472
|
-
const { x: fromX, y: fromY } = this.adjustCoordinates(from.x, from.y);
|
|
1473
|
-
const { x: toX, y: toY } = this.adjustCoordinates(to.x, to.y);
|
|
1479
|
+
const { x: fromX, y: fromY } = await this.adjustCoordinates(from.x, from.y);
|
|
1480
|
+
const { x: toX, y: toY } = await this.adjustCoordinates(to.x, to.y);
|
|
1474
1481
|
const swipeDuration = duration ?? defaultNormalScrollDuration;
|
|
1475
1482
|
await adb.shell(`input${this.getDisplayArg()} swipe ${fromX} ${fromY} ${toX} ${toY} ${swipeDuration}`);
|
|
1476
1483
|
}
|
|
@@ -1488,8 +1495,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1488
1495
|
deltaY = Math.max(-maxNegativeDeltaY, Math.min(deltaY, maxPositiveDeltaY));
|
|
1489
1496
|
const endX = Math.round(startX - deltaX);
|
|
1490
1497
|
const endY = Math.round(startY - deltaY);
|
|
1491
|
-
const { x: adjustedStartX, y: adjustedStartY } = this.adjustCoordinates(startX, startY);
|
|
1492
|
-
const { x: adjustedEndX, y: adjustedEndY } = this.adjustCoordinates(endX, endY);
|
|
1498
|
+
const { x: adjustedStartX, y: adjustedStartY } = await this.adjustCoordinates(startX, startY);
|
|
1499
|
+
const { x: adjustedEndX, y: adjustedEndY } = await this.adjustCoordinates(endX, endY);
|
|
1493
1500
|
const adb = await this.getAdb();
|
|
1494
1501
|
const swipeDuration = duration ?? defaultNormalScrollDuration;
|
|
1495
1502
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedStartX} ${adjustedStartY} ${adjustedEndX} ${adjustedEndY} ${swipeDuration}`);
|
|
@@ -1539,7 +1546,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1539
1546
|
}
|
|
1540
1547
|
async longPress(x, y, duration = 2000) {
|
|
1541
1548
|
const adb = await this.getAdb();
|
|
1542
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1549
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1543
1550
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedX} ${adjustedY} ${adjustedX} ${adjustedY} ${duration}`);
|
|
1544
1551
|
}
|
|
1545
1552
|
async pullDown(startPoint, distance, duration = 800) {
|
|
@@ -1561,8 +1568,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1561
1568
|
}
|
|
1562
1569
|
async pullDrag(from, to, duration) {
|
|
1563
1570
|
const adb = await this.getAdb();
|
|
1564
|
-
const { x: fromX, y: fromY } = this.adjustCoordinates(from.x, from.y);
|
|
1565
|
-
const { x: toX, y: toY } = this.adjustCoordinates(to.x, to.y);
|
|
1571
|
+
const { x: fromX, y: fromY } = await this.adjustCoordinates(from.x, from.y);
|
|
1572
|
+
const { x: toX, y: toY } = await this.adjustCoordinates(to.x, to.y);
|
|
1566
1573
|
await adb.shell(`input${this.getDisplayArg()} swipe ${fromX} ${fromY} ${toX} ${toY} ${duration}`);
|
|
1567
1574
|
}
|
|
1568
1575
|
async pullUp(startPoint, distance, duration = 600) {
|
|
@@ -1649,7 +1656,6 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1649
1656
|
device_define_property(this, "yadbPushed", false);
|
|
1650
1657
|
device_define_property(this, "devicePixelRatio", 1);
|
|
1651
1658
|
device_define_property(this, "devicePixelRatioInitialized", false);
|
|
1652
|
-
device_define_property(this, "scalingRatio", 1);
|
|
1653
1659
|
device_define_property(this, "adb", null);
|
|
1654
1660
|
device_define_property(this, "connectingAdb", null);
|
|
1655
1661
|
device_define_property(this, "destroyed", false);
|
package/dist/lib/index.js
CHANGED
|
@@ -1031,6 +1031,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1031
1031
|
if (shouldCache) this.cachedOrientation = orientation;
|
|
1032
1032
|
return orientation;
|
|
1033
1033
|
}
|
|
1034
|
+
async getPhysicalWidth() {
|
|
1035
|
+
const deviceInfo = await this.getDevicePhysicalInfo();
|
|
1036
|
+
const isLandscape = 1 === deviceInfo.orientation || 3 === deviceInfo.orientation;
|
|
1037
|
+
const shouldSwap = true !== deviceInfo.isCurrentOrientation && isLandscape;
|
|
1038
|
+
return shouldSwap ? deviceInfo.physicalHeight : deviceInfo.physicalWidth;
|
|
1039
|
+
}
|
|
1034
1040
|
async size() {
|
|
1035
1041
|
const deviceInfo = await this.getDevicePhysicalInfo();
|
|
1036
1042
|
const isLandscape = 1 === deviceInfo.orientation || 3 === deviceInfo.orientation;
|
|
@@ -1038,7 +1044,6 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1038
1044
|
const width = shouldSwap ? deviceInfo.physicalHeight : deviceInfo.physicalWidth;
|
|
1039
1045
|
const height = shouldSwap ? deviceInfo.physicalWidth : deviceInfo.physicalHeight;
|
|
1040
1046
|
const scale = this.options?.screenshotResizeScale ?? 1 / this.devicePixelRatio;
|
|
1041
|
-
this.scalingRatio = scale;
|
|
1042
1047
|
const logicalWidth = Math.round(width * scale);
|
|
1043
1048
|
const logicalHeight = Math.round(height * scale);
|
|
1044
1049
|
return {
|
|
@@ -1047,8 +1052,10 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1047
1052
|
dpr: this.devicePixelRatio
|
|
1048
1053
|
};
|
|
1049
1054
|
}
|
|
1050
|
-
adjustCoordinates(x, y) {
|
|
1051
|
-
const
|
|
1055
|
+
async adjustCoordinates(x, y) {
|
|
1056
|
+
const physicalWidth = await this.getPhysicalWidth();
|
|
1057
|
+
const { width: logicalWidth } = await this.size();
|
|
1058
|
+
const scale = logicalWidth / physicalWidth;
|
|
1052
1059
|
return {
|
|
1053
1060
|
x: Math.round(x / scale),
|
|
1054
1061
|
y: Math.round(y / scale)
|
|
@@ -1373,12 +1380,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1373
1380
|
}
|
|
1374
1381
|
async mouseClick(x, y) {
|
|
1375
1382
|
const adb = await this.getAdb();
|
|
1376
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1383
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1377
1384
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedX} ${adjustedY} ${adjustedX} ${adjustedY} 150`);
|
|
1378
1385
|
}
|
|
1379
1386
|
async mouseDoubleClick(x, y) {
|
|
1380
1387
|
const adb = await this.getAdb();
|
|
1381
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1388
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1382
1389
|
const tapCommand = `input${this.getDisplayArg()} tap ${adjustedX} ${adjustedY}`;
|
|
1383
1390
|
await adb.shell(tapCommand);
|
|
1384
1391
|
await (0, utils_namespaceObject.sleep)(50);
|
|
@@ -1389,8 +1396,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1389
1396
|
}
|
|
1390
1397
|
async mouseDrag(from, to, duration) {
|
|
1391
1398
|
const adb = await this.getAdb();
|
|
1392
|
-
const { x: fromX, y: fromY } = this.adjustCoordinates(from.x, from.y);
|
|
1393
|
-
const { x: toX, y: toY } = this.adjustCoordinates(to.x, to.y);
|
|
1399
|
+
const { x: fromX, y: fromY } = await this.adjustCoordinates(from.x, from.y);
|
|
1400
|
+
const { x: toX, y: toY } = await this.adjustCoordinates(to.x, to.y);
|
|
1394
1401
|
const swipeDuration = duration ?? defaultNormalScrollDuration;
|
|
1395
1402
|
await adb.shell(`input${this.getDisplayArg()} swipe ${fromX} ${fromY} ${toX} ${toY} ${swipeDuration}`);
|
|
1396
1403
|
}
|
|
@@ -1408,8 +1415,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1408
1415
|
deltaY = Math.max(-maxNegativeDeltaY, Math.min(deltaY, maxPositiveDeltaY));
|
|
1409
1416
|
const endX = Math.round(startX - deltaX);
|
|
1410
1417
|
const endY = Math.round(startY - deltaY);
|
|
1411
|
-
const { x: adjustedStartX, y: adjustedStartY } = this.adjustCoordinates(startX, startY);
|
|
1412
|
-
const { x: adjustedEndX, y: adjustedEndY } = this.adjustCoordinates(endX, endY);
|
|
1418
|
+
const { x: adjustedStartX, y: adjustedStartY } = await this.adjustCoordinates(startX, startY);
|
|
1419
|
+
const { x: adjustedEndX, y: adjustedEndY } = await this.adjustCoordinates(endX, endY);
|
|
1413
1420
|
const adb = await this.getAdb();
|
|
1414
1421
|
const swipeDuration = duration ?? defaultNormalScrollDuration;
|
|
1415
1422
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedStartX} ${adjustedStartY} ${adjustedEndX} ${adjustedEndY} ${swipeDuration}`);
|
|
@@ -1459,7 +1466,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1459
1466
|
}
|
|
1460
1467
|
async longPress(x, y, duration = 2000) {
|
|
1461
1468
|
const adb = await this.getAdb();
|
|
1462
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1469
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1463
1470
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedX} ${adjustedY} ${adjustedX} ${adjustedY} ${duration}`);
|
|
1464
1471
|
}
|
|
1465
1472
|
async pullDown(startPoint, distance, duration = 800) {
|
|
@@ -1481,8 +1488,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1481
1488
|
}
|
|
1482
1489
|
async pullDrag(from, to, duration) {
|
|
1483
1490
|
const adb = await this.getAdb();
|
|
1484
|
-
const { x: fromX, y: fromY } = this.adjustCoordinates(from.x, from.y);
|
|
1485
|
-
const { x: toX, y: toY } = this.adjustCoordinates(to.x, to.y);
|
|
1491
|
+
const { x: fromX, y: fromY } = await this.adjustCoordinates(from.x, from.y);
|
|
1492
|
+
const { x: toX, y: toY } = await this.adjustCoordinates(to.x, to.y);
|
|
1486
1493
|
await adb.shell(`input${this.getDisplayArg()} swipe ${fromX} ${fromY} ${toX} ${toY} ${duration}`);
|
|
1487
1494
|
}
|
|
1488
1495
|
async pullUp(startPoint, distance, duration = 600) {
|
|
@@ -1569,7 +1576,6 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1569
1576
|
device_define_property(this, "yadbPushed", false);
|
|
1570
1577
|
device_define_property(this, "devicePixelRatio", 1);
|
|
1571
1578
|
device_define_property(this, "devicePixelRatioInitialized", false);
|
|
1572
|
-
device_define_property(this, "scalingRatio", 1);
|
|
1573
1579
|
device_define_property(this, "adb", null);
|
|
1574
1580
|
device_define_property(this, "connectingAdb", null);
|
|
1575
1581
|
device_define_property(this, "destroyed", false);
|
package/dist/lib/mcp-server.js
CHANGED
|
@@ -1126,6 +1126,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1126
1126
|
if (shouldCache) this.cachedOrientation = orientation;
|
|
1127
1127
|
return orientation;
|
|
1128
1128
|
}
|
|
1129
|
+
async getPhysicalWidth() {
|
|
1130
|
+
const deviceInfo = await this.getDevicePhysicalInfo();
|
|
1131
|
+
const isLandscape = 1 === deviceInfo.orientation || 3 === deviceInfo.orientation;
|
|
1132
|
+
const shouldSwap = true !== deviceInfo.isCurrentOrientation && isLandscape;
|
|
1133
|
+
return shouldSwap ? deviceInfo.physicalHeight : deviceInfo.physicalWidth;
|
|
1134
|
+
}
|
|
1129
1135
|
async size() {
|
|
1130
1136
|
const deviceInfo = await this.getDevicePhysicalInfo();
|
|
1131
1137
|
const isLandscape = 1 === deviceInfo.orientation || 3 === deviceInfo.orientation;
|
|
@@ -1133,7 +1139,6 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1133
1139
|
const width = shouldSwap ? deviceInfo.physicalHeight : deviceInfo.physicalWidth;
|
|
1134
1140
|
const height = shouldSwap ? deviceInfo.physicalWidth : deviceInfo.physicalHeight;
|
|
1135
1141
|
const scale = this.options?.screenshotResizeScale ?? 1 / this.devicePixelRatio;
|
|
1136
|
-
this.scalingRatio = scale;
|
|
1137
1142
|
const logicalWidth = Math.round(width * scale);
|
|
1138
1143
|
const logicalHeight = Math.round(height * scale);
|
|
1139
1144
|
return {
|
|
@@ -1142,8 +1147,10 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1142
1147
|
dpr: this.devicePixelRatio
|
|
1143
1148
|
};
|
|
1144
1149
|
}
|
|
1145
|
-
adjustCoordinates(x, y) {
|
|
1146
|
-
const
|
|
1150
|
+
async adjustCoordinates(x, y) {
|
|
1151
|
+
const physicalWidth = await this.getPhysicalWidth();
|
|
1152
|
+
const { width: logicalWidth } = await this.size();
|
|
1153
|
+
const scale = logicalWidth / physicalWidth;
|
|
1147
1154
|
return {
|
|
1148
1155
|
x: Math.round(x / scale),
|
|
1149
1156
|
y: Math.round(y / scale)
|
|
@@ -1468,12 +1475,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1468
1475
|
}
|
|
1469
1476
|
async mouseClick(x, y) {
|
|
1470
1477
|
const adb = await this.getAdb();
|
|
1471
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1478
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1472
1479
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedX} ${adjustedY} ${adjustedX} ${adjustedY} 150`);
|
|
1473
1480
|
}
|
|
1474
1481
|
async mouseDoubleClick(x, y) {
|
|
1475
1482
|
const adb = await this.getAdb();
|
|
1476
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1483
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1477
1484
|
const tapCommand = `input${this.getDisplayArg()} tap ${adjustedX} ${adjustedY}`;
|
|
1478
1485
|
await adb.shell(tapCommand);
|
|
1479
1486
|
await (0, core_utils_namespaceObject.sleep)(50);
|
|
@@ -1484,8 +1491,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1484
1491
|
}
|
|
1485
1492
|
async mouseDrag(from, to, duration) {
|
|
1486
1493
|
const adb = await this.getAdb();
|
|
1487
|
-
const { x: fromX, y: fromY } = this.adjustCoordinates(from.x, from.y);
|
|
1488
|
-
const { x: toX, y: toY } = this.adjustCoordinates(to.x, to.y);
|
|
1494
|
+
const { x: fromX, y: fromY } = await this.adjustCoordinates(from.x, from.y);
|
|
1495
|
+
const { x: toX, y: toY } = await this.adjustCoordinates(to.x, to.y);
|
|
1489
1496
|
const swipeDuration = duration ?? defaultNormalScrollDuration;
|
|
1490
1497
|
await adb.shell(`input${this.getDisplayArg()} swipe ${fromX} ${fromY} ${toX} ${toY} ${swipeDuration}`);
|
|
1491
1498
|
}
|
|
@@ -1503,8 +1510,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1503
1510
|
deltaY = Math.max(-maxNegativeDeltaY, Math.min(deltaY, maxPositiveDeltaY));
|
|
1504
1511
|
const endX = Math.round(startX - deltaX);
|
|
1505
1512
|
const endY = Math.round(startY - deltaY);
|
|
1506
|
-
const { x: adjustedStartX, y: adjustedStartY } = this.adjustCoordinates(startX, startY);
|
|
1507
|
-
const { x: adjustedEndX, y: adjustedEndY } = this.adjustCoordinates(endX, endY);
|
|
1513
|
+
const { x: adjustedStartX, y: adjustedStartY } = await this.adjustCoordinates(startX, startY);
|
|
1514
|
+
const { x: adjustedEndX, y: adjustedEndY } = await this.adjustCoordinates(endX, endY);
|
|
1508
1515
|
const adb = await this.getAdb();
|
|
1509
1516
|
const swipeDuration = duration ?? defaultNormalScrollDuration;
|
|
1510
1517
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedStartX} ${adjustedStartY} ${adjustedEndX} ${adjustedEndY} ${swipeDuration}`);
|
|
@@ -1554,7 +1561,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1554
1561
|
}
|
|
1555
1562
|
async longPress(x, y, duration = 2000) {
|
|
1556
1563
|
const adb = await this.getAdb();
|
|
1557
|
-
const { x: adjustedX, y: adjustedY } = this.adjustCoordinates(x, y);
|
|
1564
|
+
const { x: adjustedX, y: adjustedY } = await this.adjustCoordinates(x, y);
|
|
1558
1565
|
await adb.shell(`input${this.getDisplayArg()} swipe ${adjustedX} ${adjustedY} ${adjustedX} ${adjustedY} ${duration}`);
|
|
1559
1566
|
}
|
|
1560
1567
|
async pullDown(startPoint, distance, duration = 800) {
|
|
@@ -1576,8 +1583,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1576
1583
|
}
|
|
1577
1584
|
async pullDrag(from, to, duration) {
|
|
1578
1585
|
const adb = await this.getAdb();
|
|
1579
|
-
const { x: fromX, y: fromY } = this.adjustCoordinates(from.x, from.y);
|
|
1580
|
-
const { x: toX, y: toY } = this.adjustCoordinates(to.x, to.y);
|
|
1586
|
+
const { x: fromX, y: fromY } = await this.adjustCoordinates(from.x, from.y);
|
|
1587
|
+
const { x: toX, y: toY } = await this.adjustCoordinates(to.x, to.y);
|
|
1581
1588
|
await adb.shell(`input${this.getDisplayArg()} swipe ${fromX} ${fromY} ${toX} ${toY} ${duration}`);
|
|
1582
1589
|
}
|
|
1583
1590
|
async pullUp(startPoint, distance, duration = 600) {
|
|
@@ -1664,7 +1671,6 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
1664
1671
|
device_define_property(this, "yadbPushed", false);
|
|
1665
1672
|
device_define_property(this, "devicePixelRatio", 1);
|
|
1666
1673
|
device_define_property(this, "devicePixelRatioInitialized", false);
|
|
1667
|
-
device_define_property(this, "scalingRatio", 1);
|
|
1668
1674
|
device_define_property(this, "adb", null);
|
|
1669
1675
|
device_define_property(this, "connectingAdb", null);
|
|
1670
1676
|
device_define_property(this, "destroyed", false);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -63,7 +63,6 @@ export declare class AndroidDevice implements AbstractInterface {
|
|
|
63
63
|
private yadbPushed;
|
|
64
64
|
private devicePixelRatio;
|
|
65
65
|
private devicePixelRatioInitialized;
|
|
66
|
-
private scalingRatio;
|
|
67
66
|
private adb;
|
|
68
67
|
private connectingAdb;
|
|
69
68
|
private destroyed;
|
|
@@ -115,7 +114,16 @@ export declare class AndroidDevice implements AbstractInterface {
|
|
|
115
114
|
private initializeDevicePixelRatio;
|
|
116
115
|
getDisplayDensity(): Promise<number>;
|
|
117
116
|
getDisplayOrientation(): Promise<number>;
|
|
117
|
+
/**
|
|
118
|
+
* Returns the physical screen width in the current orientation.
|
|
119
|
+
* Used internally to derive the coordinate adjustment ratio from size().
|
|
120
|
+
*/
|
|
121
|
+
private getPhysicalWidth;
|
|
118
122
|
size(): Promise<Size>;
|
|
123
|
+
/**
|
|
124
|
+
* Convert logical coordinates (from AI) back to physical coordinates (for ADB).
|
|
125
|
+
* The ratio is derived from size(), so overriding size() alone is sufficient.
|
|
126
|
+
*/
|
|
119
127
|
private adjustCoordinates;
|
|
120
128
|
/**
|
|
121
129
|
* Calculate the end point for scroll operations based on start point, scroll delta, and screen boundaries.
|
|
@@ -64,7 +64,6 @@ declare class AndroidDevice implements AbstractInterface {
|
|
|
64
64
|
private yadbPushed;
|
|
65
65
|
private devicePixelRatio;
|
|
66
66
|
private devicePixelRatioInitialized;
|
|
67
|
-
private scalingRatio;
|
|
68
67
|
private adb;
|
|
69
68
|
private connectingAdb;
|
|
70
69
|
private destroyed;
|
|
@@ -116,7 +115,16 @@ declare class AndroidDevice implements AbstractInterface {
|
|
|
116
115
|
private initializeDevicePixelRatio;
|
|
117
116
|
getDisplayDensity(): Promise<number>;
|
|
118
117
|
getDisplayOrientation(): Promise<number>;
|
|
118
|
+
/**
|
|
119
|
+
* Returns the physical screen width in the current orientation.
|
|
120
|
+
* Used internally to derive the coordinate adjustment ratio from size().
|
|
121
|
+
*/
|
|
122
|
+
private getPhysicalWidth;
|
|
119
123
|
size(): Promise<Size>;
|
|
124
|
+
/**
|
|
125
|
+
* Convert logical coordinates (from AI) back to physical coordinates (for ADB).
|
|
126
|
+
* The ratio is derived from size(), so overriding size() alone is sufficient.
|
|
127
|
+
*/
|
|
120
128
|
private adjustCoordinates;
|
|
121
129
|
/**
|
|
122
130
|
* Calculate the end point for scroll operations based on start point, scroll delta, and screen boundaries.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/android",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.5-beta-20260214073330.0",
|
|
4
4
|
"description": "Android automation library for Midscene",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Android UI automation",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"@yume-chan/stream-extra": "^1.0.0",
|
|
42
42
|
"appium-adb": "12.12.1",
|
|
43
43
|
"sharp": "^0.34.3",
|
|
44
|
-
"@midscene/
|
|
45
|
-
"@midscene/
|
|
44
|
+
"@midscene/core": "1.4.5-beta-20260214073330.0",
|
|
45
|
+
"@midscene/shared": "1.4.5-beta-20260214073330.0"
|
|
46
46
|
},
|
|
47
47
|
"optionalDependencies": {
|
|
48
48
|
"@ffmpeg-installer/ffmpeg": "^1.1.0"
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"tsx": "^4.19.2",
|
|
57
57
|
"vitest": "3.0.5",
|
|
58
58
|
"zod": "3.24.3",
|
|
59
|
-
"@midscene/playground": "1.4.
|
|
59
|
+
"@midscene/playground": "1.4.5-beta-20260214073330.0"
|
|
60
60
|
},
|
|
61
61
|
"license": "MIT",
|
|
62
62
|
"scripts": {
|