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