@skrillex1224/android-toolkit 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +29 -3
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +29 -3
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1008,7 +1008,10 @@ async function pressEnter2(ctx) {
|
|
|
1008
1008
|
}
|
|
1009
1009
|
async function scroll(ctx, selector, direction, options = {}) {
|
|
1010
1010
|
const node = await DeviceView.find(ctx, selector, options);
|
|
1011
|
-
|
|
1011
|
+
await scrollBounds(ctx, node.bounds, direction, options);
|
|
1012
|
+
}
|
|
1013
|
+
async function scrollBounds(ctx, bounds2, direction, options = {}) {
|
|
1014
|
+
const box = bounds2;
|
|
1012
1015
|
const ratio = Number(options.swipeRatio || 0.72);
|
|
1013
1016
|
const durationMs = Number(options.durationMs || 360);
|
|
1014
1017
|
const x = box.centerX;
|
|
@@ -1035,6 +1038,9 @@ async function scrollUntilStable(ctx, selector, direction, options = {}) {
|
|
|
1035
1038
|
const maxSwipes = Math.max(1, Number(options.maxSwipes || 20));
|
|
1036
1039
|
const stableRoundsTarget = Math.max(1, Number(options.stableRounds || 2));
|
|
1037
1040
|
const hashSource = String(options.stability || options.hashSource || "view");
|
|
1041
|
+
if (hashSource === "screenshot") {
|
|
1042
|
+
return scrollUntilScreenshotStable(ctx, selector, direction, options, maxSwipes, stableRoundsTarget, hashSource);
|
|
1043
|
+
}
|
|
1038
1044
|
let lastHash = "";
|
|
1039
1045
|
let stableRounds = 0;
|
|
1040
1046
|
for (let index = 0; index < maxSwipes; index += 1) {
|
|
@@ -1042,7 +1048,7 @@ async function scrollUntilStable(ctx, selector, direction, options = {}) {
|
|
|
1042
1048
|
if (currentHash === lastHash) {
|
|
1043
1049
|
stableRounds += 1;
|
|
1044
1050
|
if (stableRounds >= stableRoundsTarget) {
|
|
1045
|
-
return { swipes: index, stableRounds, hash: currentHash, hashSource };
|
|
1051
|
+
return { swipes: index, stableRounds, hash: currentHash, hashSource, capped: false };
|
|
1046
1052
|
}
|
|
1047
1053
|
} else {
|
|
1048
1054
|
stableRounds = 0;
|
|
@@ -1050,7 +1056,27 @@ async function scrollUntilStable(ctx, selector, direction, options = {}) {
|
|
|
1050
1056
|
}
|
|
1051
1057
|
await scroll(ctx, selector, direction, options);
|
|
1052
1058
|
}
|
|
1053
|
-
return { swipes: maxSwipes, stableRounds, hash: lastHash, hashSource };
|
|
1059
|
+
return { swipes: maxSwipes, stableRounds, hash: lastHash, hashSource, capped: true };
|
|
1060
|
+
}
|
|
1061
|
+
async function scrollUntilScreenshotStable(ctx, selector, direction, options, maxSwipes, stableRoundsTarget, hashSource) {
|
|
1062
|
+
const node = await DeviceView.find(ctx, selector, options);
|
|
1063
|
+
const bounds2 = node.bounds;
|
|
1064
|
+
let lastHash = await scrollStateHash(ctx, selector, options, hashSource);
|
|
1065
|
+
let stableRounds = 0;
|
|
1066
|
+
for (let index = 0; index < maxSwipes; index += 1) {
|
|
1067
|
+
await scrollBounds(ctx, bounds2, direction, options);
|
|
1068
|
+
const currentHash = await scrollStateHash(ctx, selector, options, hashSource);
|
|
1069
|
+
if (currentHash === lastHash) {
|
|
1070
|
+
stableRounds += 1;
|
|
1071
|
+
if (stableRounds >= stableRoundsTarget) {
|
|
1072
|
+
return { swipes: index + 1, stableRounds, hash: currentHash, hashSource, capped: false };
|
|
1073
|
+
}
|
|
1074
|
+
} else {
|
|
1075
|
+
stableRounds = 0;
|
|
1076
|
+
lastHash = currentHash;
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
return { swipes: maxSwipes, stableRounds, hash: lastHash, hashSource, capped: true };
|
|
1054
1080
|
}
|
|
1055
1081
|
async function scrollStateHash(ctx, selector, options, hashSource) {
|
|
1056
1082
|
if (hashSource === "screenshot") {
|