@midscene/android 0.30.6-beta-20251022112352.0 → 0.30.6-beta-20251023082056.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/index.mjs +44 -45
- package/dist/lib/index.js +44 -45
- package/dist/types/index.d.ts +1 -1
- package/package.json +4 -4
package/dist/es/index.mjs
CHANGED
|
@@ -103,8 +103,7 @@ class AndroidDevice {
|
|
|
103
103
|
});
|
|
104
104
|
}),
|
|
105
105
|
defineActionKeyboardPress(async (param)=>{
|
|
106
|
-
|
|
107
|
-
await this.keyboardPress(key);
|
|
106
|
+
await this.keyboardPress(param.keyName);
|
|
108
107
|
}),
|
|
109
108
|
defineAction({
|
|
110
109
|
name: 'AndroidBackButton',
|
|
@@ -288,7 +287,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
288
287
|
}
|
|
289
288
|
async getScreenSize() {
|
|
290
289
|
var _this_options, _this_options1;
|
|
291
|
-
const shouldCache = !((null == (_this_options = this.options) ? void 0 : _this_options.
|
|
290
|
+
const shouldCache = !((null == (_this_options = this.options) ? void 0 : _this_options.alwaysRefreshScreenInfo) ?? false);
|
|
292
291
|
if (shouldCache && this.cachedScreenSize) return this.cachedScreenSize;
|
|
293
292
|
const adb = await this.getAdb();
|
|
294
293
|
if ('number' == typeof (null == (_this_options1 = this.options) ? void 0 : _this_options1.displayId)) try {
|
|
@@ -422,7 +421,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
422
421
|
}
|
|
423
422
|
async getDisplayOrientation() {
|
|
424
423
|
var _this_options;
|
|
425
|
-
const shouldCache = !((null == (_this_options = this.options) ? void 0 : _this_options.
|
|
424
|
+
const shouldCache = !((null == (_this_options = this.options) ? void 0 : _this_options.alwaysRefreshScreenInfo) ?? false);
|
|
426
425
|
if (shouldCache && null !== this.cachedOrientation) return this.cachedOrientation;
|
|
427
426
|
const adb = await this.getAdb();
|
|
428
427
|
let orientation = 0;
|
|
@@ -489,8 +488,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
489
488
|
const minScrollY = Math.min(minScrollDistance, actualScrollDistanceY);
|
|
490
489
|
actualScrollDistanceY = Math.max(minScrollY, actualScrollDistanceY);
|
|
491
490
|
}
|
|
492
|
-
const endX = 0 === deltaX ? start.x : deltaX > 0 ? Math.min(maxWidth, start.x + actualScrollDistanceX) : Math.max(0, start.x - actualScrollDistanceX);
|
|
493
|
-
const endY = 0 === deltaY ? start.y : deltaY > 0 ? Math.min(maxHeight, start.y + actualScrollDistanceY) : Math.max(0, start.y - actualScrollDistanceY);
|
|
491
|
+
const endX = Math.round(0 === deltaX ? start.x : deltaX > 0 ? Math.min(maxWidth, start.x + actualScrollDistanceX) : Math.max(0, start.x - actualScrollDistanceX));
|
|
492
|
+
const endY = Math.round(0 === deltaY ? start.y : deltaY > 0 ? Math.min(maxHeight, start.y + actualScrollDistanceY) : Math.max(0, start.y - actualScrollDistanceY));
|
|
494
493
|
return {
|
|
495
494
|
x: endX,
|
|
496
495
|
y: endY
|
|
@@ -569,12 +568,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
569
568
|
if (startPoint) {
|
|
570
569
|
const { height } = await this.size();
|
|
571
570
|
const start = {
|
|
572
|
-
x: startPoint.left,
|
|
573
|
-
y: startPoint.top
|
|
571
|
+
x: Math.round(startPoint.left),
|
|
572
|
+
y: Math.round(startPoint.top)
|
|
574
573
|
};
|
|
575
574
|
const end = {
|
|
576
575
|
x: start.x,
|
|
577
|
-
y: height
|
|
576
|
+
y: Math.round(height)
|
|
578
577
|
};
|
|
579
578
|
await repeat(defaultScrollUntilTimes, ()=>this.mouseDrag(start, end, defaultFastScrollDuration));
|
|
580
579
|
await sleep(1000);
|
|
@@ -586,8 +585,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
586
585
|
async scrollUntilBottom(startPoint) {
|
|
587
586
|
if (startPoint) {
|
|
588
587
|
const start = {
|
|
589
|
-
x: startPoint.left,
|
|
590
|
-
y: startPoint.top
|
|
588
|
+
x: Math.round(startPoint.left),
|
|
589
|
+
y: Math.round(startPoint.top)
|
|
591
590
|
};
|
|
592
591
|
const end = {
|
|
593
592
|
x: start.x,
|
|
@@ -604,11 +603,11 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
604
603
|
if (startPoint) {
|
|
605
604
|
const { width } = await this.size();
|
|
606
605
|
const start = {
|
|
607
|
-
x: startPoint.left,
|
|
608
|
-
y: startPoint.top
|
|
606
|
+
x: Math.round(startPoint.left),
|
|
607
|
+
y: Math.round(startPoint.top)
|
|
609
608
|
};
|
|
610
609
|
const end = {
|
|
611
|
-
x: width,
|
|
610
|
+
x: Math.round(width),
|
|
612
611
|
y: start.y
|
|
613
612
|
};
|
|
614
613
|
await repeat(defaultScrollUntilTimes, ()=>this.mouseDrag(start, end, defaultFastScrollDuration));
|
|
@@ -621,8 +620,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
621
620
|
async scrollUntilRight(startPoint) {
|
|
622
621
|
if (startPoint) {
|
|
623
622
|
const start = {
|
|
624
|
-
x: startPoint.left,
|
|
625
|
-
y: startPoint.top
|
|
623
|
+
x: Math.round(startPoint.left),
|
|
624
|
+
y: Math.round(startPoint.top)
|
|
626
625
|
};
|
|
627
626
|
const end = {
|
|
628
627
|
x: 0,
|
|
@@ -637,11 +636,11 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
637
636
|
}
|
|
638
637
|
async scrollUp(distance, startPoint) {
|
|
639
638
|
const { height } = await this.size();
|
|
640
|
-
const scrollDistance = distance || height;
|
|
639
|
+
const scrollDistance = Math.round(distance || height);
|
|
641
640
|
if (startPoint) {
|
|
642
641
|
const start = {
|
|
643
|
-
x: startPoint.left,
|
|
644
|
-
y: startPoint.top
|
|
642
|
+
x: Math.round(startPoint.left),
|
|
643
|
+
y: Math.round(startPoint.top)
|
|
645
644
|
};
|
|
646
645
|
const end = this.calculateScrollEndPoint(start, 0, scrollDistance, 0, height);
|
|
647
646
|
await this.mouseDrag(start, end);
|
|
@@ -651,11 +650,11 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
651
650
|
}
|
|
652
651
|
async scrollDown(distance, startPoint) {
|
|
653
652
|
const { height } = await this.size();
|
|
654
|
-
const scrollDistance = distance || height;
|
|
653
|
+
const scrollDistance = Math.round(distance || height);
|
|
655
654
|
if (startPoint) {
|
|
656
655
|
const start = {
|
|
657
|
-
x: startPoint.left,
|
|
658
|
-
y: startPoint.top
|
|
656
|
+
x: Math.round(startPoint.left),
|
|
657
|
+
y: Math.round(startPoint.top)
|
|
659
658
|
};
|
|
660
659
|
const end = this.calculateScrollEndPoint(start, 0, -scrollDistance, 0, height);
|
|
661
660
|
await this.mouseDrag(start, end);
|
|
@@ -665,11 +664,11 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
665
664
|
}
|
|
666
665
|
async scrollLeft(distance, startPoint) {
|
|
667
666
|
const { width } = await this.size();
|
|
668
|
-
const scrollDistance = distance || width;
|
|
667
|
+
const scrollDistance = Math.round(distance || width);
|
|
669
668
|
if (startPoint) {
|
|
670
669
|
const start = {
|
|
671
|
-
x: startPoint.left,
|
|
672
|
-
y: startPoint.top
|
|
670
|
+
x: Math.round(startPoint.left),
|
|
671
|
+
y: Math.round(startPoint.top)
|
|
673
672
|
};
|
|
674
673
|
const end = this.calculateScrollEndPoint(start, scrollDistance, 0, width, 0);
|
|
675
674
|
await this.mouseDrag(start, end);
|
|
@@ -679,11 +678,11 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
679
678
|
}
|
|
680
679
|
async scrollRight(distance, startPoint) {
|
|
681
680
|
const { width } = await this.size();
|
|
682
|
-
const scrollDistance = distance || width;
|
|
681
|
+
const scrollDistance = Math.round(distance || width);
|
|
683
682
|
if (startPoint) {
|
|
684
683
|
const start = {
|
|
685
|
-
x: startPoint.left,
|
|
686
|
-
y: startPoint.top
|
|
684
|
+
x: Math.round(startPoint.left),
|
|
685
|
+
y: Math.round(startPoint.top)
|
|
687
686
|
};
|
|
688
687
|
const end = this.calculateScrollEndPoint(start, -scrollDistance, 0, width, 0);
|
|
689
688
|
await this.mouseDrag(start, end);
|
|
@@ -781,16 +780,16 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
781
780
|
if (0 === deltaX && 0 === deltaY) throw new Error('Scroll distance cannot be zero in both directions');
|
|
782
781
|
const { width, height } = await this.size();
|
|
783
782
|
const n = 4;
|
|
784
|
-
const startX = deltaX < 0 ? width / n * (n - 1) : width / n;
|
|
785
|
-
const startY = deltaY < 0 ? height / n * (n - 1) : height / n;
|
|
783
|
+
const startX = Math.round(deltaX < 0 ? width / n * (n - 1) : width / n);
|
|
784
|
+
const startY = Math.round(deltaY < 0 ? height / n * (n - 1) : height / n);
|
|
786
785
|
const maxNegativeDeltaX = startX;
|
|
787
|
-
const maxPositiveDeltaX = width / n * (n - 1);
|
|
786
|
+
const maxPositiveDeltaX = Math.round(width / n * (n - 1));
|
|
788
787
|
const maxNegativeDeltaY = startY;
|
|
789
|
-
const maxPositiveDeltaY = height / n * (n - 1);
|
|
788
|
+
const maxPositiveDeltaY = Math.round(height / n * (n - 1));
|
|
790
789
|
deltaX = Math.max(-maxNegativeDeltaX, Math.min(deltaX, maxPositiveDeltaX));
|
|
791
790
|
deltaY = Math.max(-maxNegativeDeltaY, Math.min(deltaY, maxPositiveDeltaY));
|
|
792
|
-
const endX = startX - deltaX;
|
|
793
|
-
const endY = startY - deltaY;
|
|
791
|
+
const endX = Math.round(startX - deltaX);
|
|
792
|
+
const endY = Math.round(startY - deltaY);
|
|
794
793
|
const { x: adjustedStartX, y: adjustedStartY } = this.adjustCoordinates(startX, startY);
|
|
795
794
|
const { x: adjustedEndX, y: adjustedEndY } = this.adjustCoordinates(endX, endY);
|
|
796
795
|
const adb = await this.getAdb();
|
|
@@ -828,13 +827,13 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
828
827
|
async pullDown(startPoint, distance, duration = 800) {
|
|
829
828
|
const { width, height } = await this.size();
|
|
830
829
|
const start = startPoint ? {
|
|
831
|
-
x: startPoint.left,
|
|
832
|
-
y: startPoint.top
|
|
830
|
+
x: Math.round(startPoint.left),
|
|
831
|
+
y: Math.round(startPoint.top)
|
|
833
832
|
} : {
|
|
834
|
-
x: width / 2,
|
|
835
|
-
y: 0.15 * height
|
|
833
|
+
x: Math.round(width / 2),
|
|
834
|
+
y: Math.round(0.15 * height)
|
|
836
835
|
};
|
|
837
|
-
const pullDistance = distance || 0.5 * height;
|
|
836
|
+
const pullDistance = Math.round(distance || 0.5 * height);
|
|
838
837
|
const end = {
|
|
839
838
|
x: start.x,
|
|
840
839
|
y: start.y + pullDistance
|
|
@@ -851,13 +850,13 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
851
850
|
async pullUp(startPoint, distance, duration = 600) {
|
|
852
851
|
const { width, height } = await this.size();
|
|
853
852
|
const start = startPoint ? {
|
|
854
|
-
x: startPoint.left,
|
|
855
|
-
y: startPoint.top
|
|
853
|
+
x: Math.round(startPoint.left),
|
|
854
|
+
y: Math.round(startPoint.top)
|
|
856
855
|
} : {
|
|
857
|
-
x: width / 2,
|
|
858
|
-
y: 0.85 * height
|
|
856
|
+
x: Math.round(width / 2),
|
|
857
|
+
y: Math.round(0.85 * height)
|
|
859
858
|
};
|
|
860
|
-
const pullDistance = distance || 0.4 * height;
|
|
859
|
+
const pullDistance = Math.round(distance || 0.4 * height);
|
|
861
860
|
const end = {
|
|
862
861
|
x: start.x,
|
|
863
862
|
y: start.y - pullDistance
|
|
@@ -988,7 +987,7 @@ async function agentFromAdbDevice(deviceId, opts) {
|
|
|
988
987
|
usePhysicalDisplayIdForScreenshot: null == opts ? void 0 : opts.usePhysicalDisplayIdForScreenshot,
|
|
989
988
|
usePhysicalDisplayIdForDisplayLookup: null == opts ? void 0 : opts.usePhysicalDisplayIdForDisplayLookup,
|
|
990
989
|
screenshotResizeScale: null == opts ? void 0 : opts.screenshotResizeScale,
|
|
991
|
-
|
|
990
|
+
alwaysRefreshScreenInfo: null == opts ? void 0 : opts.alwaysRefreshScreenInfo
|
|
992
991
|
});
|
|
993
992
|
await device.connect();
|
|
994
993
|
return new AndroidAgent(device, opts);
|
package/dist/lib/index.js
CHANGED
|
@@ -149,8 +149,7 @@ class AndroidDevice {
|
|
|
149
149
|
});
|
|
150
150
|
}),
|
|
151
151
|
(0, device_namespaceObject.defineActionKeyboardPress)(async (param)=>{
|
|
152
|
-
|
|
153
|
-
await this.keyboardPress(key);
|
|
152
|
+
await this.keyboardPress(param.keyName);
|
|
154
153
|
}),
|
|
155
154
|
(0, device_namespaceObject.defineAction)({
|
|
156
155
|
name: 'AndroidBackButton',
|
|
@@ -334,7 +333,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
334
333
|
}
|
|
335
334
|
async getScreenSize() {
|
|
336
335
|
var _this_options, _this_options1;
|
|
337
|
-
const shouldCache = !((null == (_this_options = this.options) ? void 0 : _this_options.
|
|
336
|
+
const shouldCache = !((null == (_this_options = this.options) ? void 0 : _this_options.alwaysRefreshScreenInfo) ?? false);
|
|
338
337
|
if (shouldCache && this.cachedScreenSize) return this.cachedScreenSize;
|
|
339
338
|
const adb = await this.getAdb();
|
|
340
339
|
if ('number' == typeof (null == (_this_options1 = this.options) ? void 0 : _this_options1.displayId)) try {
|
|
@@ -468,7 +467,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
468
467
|
}
|
|
469
468
|
async getDisplayOrientation() {
|
|
470
469
|
var _this_options;
|
|
471
|
-
const shouldCache = !((null == (_this_options = this.options) ? void 0 : _this_options.
|
|
470
|
+
const shouldCache = !((null == (_this_options = this.options) ? void 0 : _this_options.alwaysRefreshScreenInfo) ?? false);
|
|
472
471
|
if (shouldCache && null !== this.cachedOrientation) return this.cachedOrientation;
|
|
473
472
|
const adb = await this.getAdb();
|
|
474
473
|
let orientation = 0;
|
|
@@ -535,8 +534,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
535
534
|
const minScrollY = Math.min(minScrollDistance, actualScrollDistanceY);
|
|
536
535
|
actualScrollDistanceY = Math.max(minScrollY, actualScrollDistanceY);
|
|
537
536
|
}
|
|
538
|
-
const endX = 0 === deltaX ? start.x : deltaX > 0 ? Math.min(maxWidth, start.x + actualScrollDistanceX) : Math.max(0, start.x - actualScrollDistanceX);
|
|
539
|
-
const endY = 0 === deltaY ? start.y : deltaY > 0 ? Math.min(maxHeight, start.y + actualScrollDistanceY) : Math.max(0, start.y - actualScrollDistanceY);
|
|
537
|
+
const endX = Math.round(0 === deltaX ? start.x : deltaX > 0 ? Math.min(maxWidth, start.x + actualScrollDistanceX) : Math.max(0, start.x - actualScrollDistanceX));
|
|
538
|
+
const endY = Math.round(0 === deltaY ? start.y : deltaY > 0 ? Math.min(maxHeight, start.y + actualScrollDistanceY) : Math.max(0, start.y - actualScrollDistanceY));
|
|
540
539
|
return {
|
|
541
540
|
x: endX,
|
|
542
541
|
y: endY
|
|
@@ -615,12 +614,12 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
615
614
|
if (startPoint) {
|
|
616
615
|
const { height } = await this.size();
|
|
617
616
|
const start = {
|
|
618
|
-
x: startPoint.left,
|
|
619
|
-
y: startPoint.top
|
|
617
|
+
x: Math.round(startPoint.left),
|
|
618
|
+
y: Math.round(startPoint.top)
|
|
620
619
|
};
|
|
621
620
|
const end = {
|
|
622
621
|
x: start.x,
|
|
623
|
-
y: height
|
|
622
|
+
y: Math.round(height)
|
|
624
623
|
};
|
|
625
624
|
await (0, shared_utils_namespaceObject.repeat)(defaultScrollUntilTimes, ()=>this.mouseDrag(start, end, defaultFastScrollDuration));
|
|
626
625
|
await (0, utils_namespaceObject.sleep)(1000);
|
|
@@ -632,8 +631,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
632
631
|
async scrollUntilBottom(startPoint) {
|
|
633
632
|
if (startPoint) {
|
|
634
633
|
const start = {
|
|
635
|
-
x: startPoint.left,
|
|
636
|
-
y: startPoint.top
|
|
634
|
+
x: Math.round(startPoint.left),
|
|
635
|
+
y: Math.round(startPoint.top)
|
|
637
636
|
};
|
|
638
637
|
const end = {
|
|
639
638
|
x: start.x,
|
|
@@ -650,11 +649,11 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
650
649
|
if (startPoint) {
|
|
651
650
|
const { width } = await this.size();
|
|
652
651
|
const start = {
|
|
653
|
-
x: startPoint.left,
|
|
654
|
-
y: startPoint.top
|
|
652
|
+
x: Math.round(startPoint.left),
|
|
653
|
+
y: Math.round(startPoint.top)
|
|
655
654
|
};
|
|
656
655
|
const end = {
|
|
657
|
-
x: width,
|
|
656
|
+
x: Math.round(width),
|
|
658
657
|
y: start.y
|
|
659
658
|
};
|
|
660
659
|
await (0, shared_utils_namespaceObject.repeat)(defaultScrollUntilTimes, ()=>this.mouseDrag(start, end, defaultFastScrollDuration));
|
|
@@ -667,8 +666,8 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
667
666
|
async scrollUntilRight(startPoint) {
|
|
668
667
|
if (startPoint) {
|
|
669
668
|
const start = {
|
|
670
|
-
x: startPoint.left,
|
|
671
|
-
y: startPoint.top
|
|
669
|
+
x: Math.round(startPoint.left),
|
|
670
|
+
y: Math.round(startPoint.top)
|
|
672
671
|
};
|
|
673
672
|
const end = {
|
|
674
673
|
x: 0,
|
|
@@ -683,11 +682,11 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
683
682
|
}
|
|
684
683
|
async scrollUp(distance, startPoint) {
|
|
685
684
|
const { height } = await this.size();
|
|
686
|
-
const scrollDistance = distance || height;
|
|
685
|
+
const scrollDistance = Math.round(distance || height);
|
|
687
686
|
if (startPoint) {
|
|
688
687
|
const start = {
|
|
689
|
-
x: startPoint.left,
|
|
690
|
-
y: startPoint.top
|
|
688
|
+
x: Math.round(startPoint.left),
|
|
689
|
+
y: Math.round(startPoint.top)
|
|
691
690
|
};
|
|
692
691
|
const end = this.calculateScrollEndPoint(start, 0, scrollDistance, 0, height);
|
|
693
692
|
await this.mouseDrag(start, end);
|
|
@@ -697,11 +696,11 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
697
696
|
}
|
|
698
697
|
async scrollDown(distance, startPoint) {
|
|
699
698
|
const { height } = await this.size();
|
|
700
|
-
const scrollDistance = distance || height;
|
|
699
|
+
const scrollDistance = Math.round(distance || height);
|
|
701
700
|
if (startPoint) {
|
|
702
701
|
const start = {
|
|
703
|
-
x: startPoint.left,
|
|
704
|
-
y: startPoint.top
|
|
702
|
+
x: Math.round(startPoint.left),
|
|
703
|
+
y: Math.round(startPoint.top)
|
|
705
704
|
};
|
|
706
705
|
const end = this.calculateScrollEndPoint(start, 0, -scrollDistance, 0, height);
|
|
707
706
|
await this.mouseDrag(start, end);
|
|
@@ -711,11 +710,11 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
711
710
|
}
|
|
712
711
|
async scrollLeft(distance, startPoint) {
|
|
713
712
|
const { width } = await this.size();
|
|
714
|
-
const scrollDistance = distance || width;
|
|
713
|
+
const scrollDistance = Math.round(distance || width);
|
|
715
714
|
if (startPoint) {
|
|
716
715
|
const start = {
|
|
717
|
-
x: startPoint.left,
|
|
718
|
-
y: startPoint.top
|
|
716
|
+
x: Math.round(startPoint.left),
|
|
717
|
+
y: Math.round(startPoint.top)
|
|
719
718
|
};
|
|
720
719
|
const end = this.calculateScrollEndPoint(start, scrollDistance, 0, width, 0);
|
|
721
720
|
await this.mouseDrag(start, end);
|
|
@@ -725,11 +724,11 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
725
724
|
}
|
|
726
725
|
async scrollRight(distance, startPoint) {
|
|
727
726
|
const { width } = await this.size();
|
|
728
|
-
const scrollDistance = distance || width;
|
|
727
|
+
const scrollDistance = Math.round(distance || width);
|
|
729
728
|
if (startPoint) {
|
|
730
729
|
const start = {
|
|
731
|
-
x: startPoint.left,
|
|
732
|
-
y: startPoint.top
|
|
730
|
+
x: Math.round(startPoint.left),
|
|
731
|
+
y: Math.round(startPoint.top)
|
|
733
732
|
};
|
|
734
733
|
const end = this.calculateScrollEndPoint(start, -scrollDistance, 0, width, 0);
|
|
735
734
|
await this.mouseDrag(start, end);
|
|
@@ -827,16 +826,16 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
827
826
|
if (0 === deltaX && 0 === deltaY) throw new Error('Scroll distance cannot be zero in both directions');
|
|
828
827
|
const { width, height } = await this.size();
|
|
829
828
|
const n = 4;
|
|
830
|
-
const startX = deltaX < 0 ? width / n * (n - 1) : width / n;
|
|
831
|
-
const startY = deltaY < 0 ? height / n * (n - 1) : height / n;
|
|
829
|
+
const startX = Math.round(deltaX < 0 ? width / n * (n - 1) : width / n);
|
|
830
|
+
const startY = Math.round(deltaY < 0 ? height / n * (n - 1) : height / n);
|
|
832
831
|
const maxNegativeDeltaX = startX;
|
|
833
|
-
const maxPositiveDeltaX = width / n * (n - 1);
|
|
832
|
+
const maxPositiveDeltaX = Math.round(width / n * (n - 1));
|
|
834
833
|
const maxNegativeDeltaY = startY;
|
|
835
|
-
const maxPositiveDeltaY = height / n * (n - 1);
|
|
834
|
+
const maxPositiveDeltaY = Math.round(height / n * (n - 1));
|
|
836
835
|
deltaX = Math.max(-maxNegativeDeltaX, Math.min(deltaX, maxPositiveDeltaX));
|
|
837
836
|
deltaY = Math.max(-maxNegativeDeltaY, Math.min(deltaY, maxPositiveDeltaY));
|
|
838
|
-
const endX = startX - deltaX;
|
|
839
|
-
const endY = startY - deltaY;
|
|
837
|
+
const endX = Math.round(startX - deltaX);
|
|
838
|
+
const endY = Math.round(startY - deltaY);
|
|
840
839
|
const { x: adjustedStartX, y: adjustedStartY } = this.adjustCoordinates(startX, startY);
|
|
841
840
|
const { x: adjustedEndX, y: adjustedEndY } = this.adjustCoordinates(endX, endY);
|
|
842
841
|
const adb = await this.getAdb();
|
|
@@ -874,13 +873,13 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
874
873
|
async pullDown(startPoint, distance, duration = 800) {
|
|
875
874
|
const { width, height } = await this.size();
|
|
876
875
|
const start = startPoint ? {
|
|
877
|
-
x: startPoint.left,
|
|
878
|
-
y: startPoint.top
|
|
876
|
+
x: Math.round(startPoint.left),
|
|
877
|
+
y: Math.round(startPoint.top)
|
|
879
878
|
} : {
|
|
880
|
-
x: width / 2,
|
|
881
|
-
y: 0.15 * height
|
|
879
|
+
x: Math.round(width / 2),
|
|
880
|
+
y: Math.round(0.15 * height)
|
|
882
881
|
};
|
|
883
|
-
const pullDistance = distance || 0.5 * height;
|
|
882
|
+
const pullDistance = Math.round(distance || 0.5 * height);
|
|
884
883
|
const end = {
|
|
885
884
|
x: start.x,
|
|
886
885
|
y: start.y + pullDistance
|
|
@@ -897,13 +896,13 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
|
|
|
897
896
|
async pullUp(startPoint, distance, duration = 600) {
|
|
898
897
|
const { width, height } = await this.size();
|
|
899
898
|
const start = startPoint ? {
|
|
900
|
-
x: startPoint.left,
|
|
901
|
-
y: startPoint.top
|
|
899
|
+
x: Math.round(startPoint.left),
|
|
900
|
+
y: Math.round(startPoint.top)
|
|
902
901
|
} : {
|
|
903
|
-
x: width / 2,
|
|
904
|
-
y: 0.85 * height
|
|
902
|
+
x: Math.round(width / 2),
|
|
903
|
+
y: Math.round(0.85 * height)
|
|
905
904
|
};
|
|
906
|
-
const pullDistance = distance || 0.4 * height;
|
|
905
|
+
const pullDistance = Math.round(distance || 0.4 * height);
|
|
907
906
|
const end = {
|
|
908
907
|
x: start.x,
|
|
909
908
|
y: start.y - pullDistance
|
|
@@ -1035,7 +1034,7 @@ async function agentFromAdbDevice(deviceId, opts) {
|
|
|
1035
1034
|
usePhysicalDisplayIdForScreenshot: null == opts ? void 0 : opts.usePhysicalDisplayIdForScreenshot,
|
|
1036
1035
|
usePhysicalDisplayIdForDisplayLookup: null == opts ? void 0 : opts.usePhysicalDisplayIdForDisplayLookup,
|
|
1037
1036
|
screenshotResizeScale: null == opts ? void 0 : opts.screenshotResizeScale,
|
|
1038
|
-
|
|
1037
|
+
alwaysRefreshScreenInfo: null == opts ? void 0 : opts.alwaysRefreshScreenInfo
|
|
1039
1038
|
});
|
|
1040
1039
|
await device.connect();
|
|
1041
1040
|
return new AndroidAgent(device, opts);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -129,7 +129,7 @@ declare type AndroidDeviceOpt = {
|
|
|
129
129
|
usePhysicalDisplayIdForDisplayLookup?: boolean;
|
|
130
130
|
customActions?: DeviceAction<any>[];
|
|
131
131
|
screenshotResizeScale?: number;
|
|
132
|
-
|
|
132
|
+
alwaysRefreshScreenInfo?: boolean;
|
|
133
133
|
} & AndroidDeviceInputOpt;
|
|
134
134
|
|
|
135
135
|
export declare function getConnectedDevices(): Promise<Device[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/android",
|
|
3
|
-
"version": "0.30.6-beta-
|
|
3
|
+
"version": "0.30.6-beta-20251023082056.0",
|
|
4
4
|
"description": "Android automation library for Midscene",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Android UI automation",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"appium-adb": "12.12.1",
|
|
30
|
-
"@midscene/
|
|
31
|
-
"@midscene/
|
|
30
|
+
"@midscene/core": "0.30.6-beta-20251023082056.0",
|
|
31
|
+
"@midscene/shared": "0.30.6-beta-20251023082056.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@rslib/core": "^0.11.2",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"typescript": "^5.8.3",
|
|
38
38
|
"tsx": "^4.19.2",
|
|
39
39
|
"vitest": "3.0.5",
|
|
40
|
-
"@midscene/playground": "0.30.6-beta-
|
|
40
|
+
"@midscene/playground": "0.30.6-beta-20251023082056.0"
|
|
41
41
|
},
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"scripts": {
|