@skrillex1224/android-toolkit 1.0.6 → 1.0.7

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.js CHANGED
@@ -728,6 +728,9 @@ function sanitizeData(value, depth = 0, seen = /* @__PURE__ */ new WeakSet()) {
728
728
  return out;
729
729
  }
730
730
 
731
+ // src/device-input.js
732
+ import { createHash as createHash2 } from "node:crypto";
733
+
731
734
  // src/device-view.js
732
735
  import { createHash } from "node:crypto";
733
736
  import { XMLParser } from "fast-xml-parser";
@@ -1031,15 +1034,15 @@ async function scrollToTop(ctx, selector, options = {}) {
1031
1034
  async function scrollUntilStable(ctx, selector, direction, options = {}) {
1032
1035
  const maxSwipes = Math.max(1, Number(options.maxSwipes || 20));
1033
1036
  const stableRoundsTarget = Math.max(1, Number(options.stableRounds || 2));
1037
+ const hashSource = String(options.stability || options.hashSource || "view");
1034
1038
  let lastHash = "";
1035
1039
  let stableRounds = 0;
1036
1040
  for (let index = 0; index < maxSwipes; index += 1) {
1037
- const node = await DeviceView.find(ctx, selector, options);
1038
- const currentHash = DeviceView.hashNode(node);
1041
+ const currentHash = await scrollStateHash(ctx, selector, options, hashSource);
1039
1042
  if (currentHash === lastHash) {
1040
1043
  stableRounds += 1;
1041
1044
  if (stableRounds >= stableRoundsTarget) {
1042
- return { swipes: index, stableRounds, hash: currentHash };
1045
+ return { swipes: index, stableRounds, hash: currentHash, hashSource };
1043
1046
  }
1044
1047
  } else {
1045
1048
  stableRounds = 0;
@@ -1047,7 +1050,15 @@ async function scrollUntilStable(ctx, selector, direction, options = {}) {
1047
1050
  }
1048
1051
  await scroll(ctx, selector, direction, options);
1049
1052
  }
1050
- return { swipes: maxSwipes, stableRounds, hash: lastHash };
1053
+ return { swipes: maxSwipes, stableRounds, hash: lastHash, hashSource };
1054
+ }
1055
+ async function scrollStateHash(ctx, selector, options, hashSource) {
1056
+ if (hashSource === "screenshot") {
1057
+ const png = await Device.screenshotPng(ctx);
1058
+ return createHash2("sha256").update(png).digest("hex");
1059
+ }
1060
+ const node = await DeviceView.find(ctx, selector, options);
1061
+ return DeviceView.hashNode(node);
1051
1062
  }
1052
1063
  function nearestClickable(node) {
1053
1064
  let current = node;
@@ -1502,7 +1513,7 @@ function selectorLabel2(selector) {
1502
1513
  }
1503
1514
 
1504
1515
  // src/share.js
1505
- import { createHash as createHash2 } from "node:crypto";
1516
+ import { createHash as createHash3 } from "node:crypto";
1506
1517
  import { Jimp as Jimp2, JimpMime as JimpMime2 } from "jimp";
1507
1518
 
1508
1519
  // src/internals/compression.js
@@ -1674,7 +1685,7 @@ async function captureScreen(ctx, options = {}) {
1674
1685
  });
1675
1686
  await sleep(DEFAULT_SETTLE_MS);
1676
1687
  const png = await Device.screenshotPng(ctx);
1677
- const hash = createHash2("sha256").update(png).digest("hex");
1688
+ const hash = createHash3("sha256").update(png).digest("hex");
1678
1689
  if (seen.has(hash)) break;
1679
1690
  seen.add(hash);
1680
1691
  frameBuffers.push(png);