@skrillex1224/android-toolkit 1.0.6 → 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 +44 -7
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +44 -7
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -757,6 +757,9 @@ function sanitizeData(value, depth = 0, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
757
757
|
return out;
|
|
758
758
|
}
|
|
759
759
|
|
|
760
|
+
// src/device-input.js
|
|
761
|
+
var import_node_crypto2 = require("node:crypto");
|
|
762
|
+
|
|
760
763
|
// src/device-view.js
|
|
761
764
|
var import_node_crypto = require("node:crypto");
|
|
762
765
|
var import_fast_xml_parser = require("fast-xml-parser");
|
|
@@ -1034,7 +1037,10 @@ async function pressEnter2(ctx) {
|
|
|
1034
1037
|
}
|
|
1035
1038
|
async function scroll(ctx, selector, direction, options = {}) {
|
|
1036
1039
|
const node = await DeviceView.find(ctx, selector, options);
|
|
1037
|
-
|
|
1040
|
+
await scrollBounds(ctx, node.bounds, direction, options);
|
|
1041
|
+
}
|
|
1042
|
+
async function scrollBounds(ctx, bounds2, direction, options = {}) {
|
|
1043
|
+
const box = bounds2;
|
|
1038
1044
|
const ratio = Number(options.swipeRatio || 0.72);
|
|
1039
1045
|
const durationMs = Number(options.durationMs || 360);
|
|
1040
1046
|
const x = box.centerX;
|
|
@@ -1060,15 +1066,18 @@ async function scrollToTop(ctx, selector, options = {}) {
|
|
|
1060
1066
|
async function scrollUntilStable(ctx, selector, direction, options = {}) {
|
|
1061
1067
|
const maxSwipes = Math.max(1, Number(options.maxSwipes || 20));
|
|
1062
1068
|
const stableRoundsTarget = Math.max(1, Number(options.stableRounds || 2));
|
|
1069
|
+
const hashSource = String(options.stability || options.hashSource || "view");
|
|
1070
|
+
if (hashSource === "screenshot") {
|
|
1071
|
+
return scrollUntilScreenshotStable(ctx, selector, direction, options, maxSwipes, stableRoundsTarget, hashSource);
|
|
1072
|
+
}
|
|
1063
1073
|
let lastHash = "";
|
|
1064
1074
|
let stableRounds = 0;
|
|
1065
1075
|
for (let index = 0; index < maxSwipes; index += 1) {
|
|
1066
|
-
const
|
|
1067
|
-
const currentHash = DeviceView.hashNode(node);
|
|
1076
|
+
const currentHash = await scrollStateHash(ctx, selector, options, hashSource);
|
|
1068
1077
|
if (currentHash === lastHash) {
|
|
1069
1078
|
stableRounds += 1;
|
|
1070
1079
|
if (stableRounds >= stableRoundsTarget) {
|
|
1071
|
-
return { swipes: index, stableRounds, hash: currentHash };
|
|
1080
|
+
return { swipes: index, stableRounds, hash: currentHash, hashSource, capped: false };
|
|
1072
1081
|
}
|
|
1073
1082
|
} else {
|
|
1074
1083
|
stableRounds = 0;
|
|
@@ -1076,7 +1085,35 @@ async function scrollUntilStable(ctx, selector, direction, options = {}) {
|
|
|
1076
1085
|
}
|
|
1077
1086
|
await scroll(ctx, selector, direction, options);
|
|
1078
1087
|
}
|
|
1079
|
-
return { swipes: maxSwipes, stableRounds, hash: lastHash };
|
|
1088
|
+
return { swipes: maxSwipes, stableRounds, hash: lastHash, hashSource, capped: true };
|
|
1089
|
+
}
|
|
1090
|
+
async function scrollUntilScreenshotStable(ctx, selector, direction, options, maxSwipes, stableRoundsTarget, hashSource) {
|
|
1091
|
+
const node = await DeviceView.find(ctx, selector, options);
|
|
1092
|
+
const bounds2 = node.bounds;
|
|
1093
|
+
let lastHash = await scrollStateHash(ctx, selector, options, hashSource);
|
|
1094
|
+
let stableRounds = 0;
|
|
1095
|
+
for (let index = 0; index < maxSwipes; index += 1) {
|
|
1096
|
+
await scrollBounds(ctx, bounds2, direction, options);
|
|
1097
|
+
const currentHash = await scrollStateHash(ctx, selector, options, hashSource);
|
|
1098
|
+
if (currentHash === lastHash) {
|
|
1099
|
+
stableRounds += 1;
|
|
1100
|
+
if (stableRounds >= stableRoundsTarget) {
|
|
1101
|
+
return { swipes: index + 1, stableRounds, hash: currentHash, hashSource, capped: false };
|
|
1102
|
+
}
|
|
1103
|
+
} else {
|
|
1104
|
+
stableRounds = 0;
|
|
1105
|
+
lastHash = currentHash;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
return { swipes: maxSwipes, stableRounds, hash: lastHash, hashSource, capped: true };
|
|
1109
|
+
}
|
|
1110
|
+
async function scrollStateHash(ctx, selector, options, hashSource) {
|
|
1111
|
+
if (hashSource === "screenshot") {
|
|
1112
|
+
const png = await Device.screenshotPng(ctx);
|
|
1113
|
+
return (0, import_node_crypto2.createHash)("sha256").update(png).digest("hex");
|
|
1114
|
+
}
|
|
1115
|
+
const node = await DeviceView.find(ctx, selector, options);
|
|
1116
|
+
return DeviceView.hashNode(node);
|
|
1080
1117
|
}
|
|
1081
1118
|
function nearestClickable(node) {
|
|
1082
1119
|
let current = node;
|
|
@@ -1531,7 +1568,7 @@ function selectorLabel2(selector) {
|
|
|
1531
1568
|
}
|
|
1532
1569
|
|
|
1533
1570
|
// src/share.js
|
|
1534
|
-
var
|
|
1571
|
+
var import_node_crypto3 = require("node:crypto");
|
|
1535
1572
|
var import_jimp2 = require("jimp");
|
|
1536
1573
|
|
|
1537
1574
|
// src/internals/compression.js
|
|
@@ -1703,7 +1740,7 @@ async function captureScreen(ctx, options = {}) {
|
|
|
1703
1740
|
});
|
|
1704
1741
|
await sleep(DEFAULT_SETTLE_MS);
|
|
1705
1742
|
const png = await Device.screenshotPng(ctx);
|
|
1706
|
-
const hash = (0,
|
|
1743
|
+
const hash = (0, import_node_crypto3.createHash)("sha256").update(png).digest("hex");
|
|
1707
1744
|
if (seen.has(hash)) break;
|
|
1708
1745
|
seen.add(hash);
|
|
1709
1746
|
frameBuffers.push(png);
|