@skrillex1224/android-toolkit 1.0.8 → 1.0.9

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
@@ -28,7 +28,7 @@ var Code = Object.freeze({
28
28
  ContentUnavailable: 30010003,
29
29
  SourceExtractionFailed: 30010004,
30
30
  AutomationFailed: 30010005,
31
- DataAccessUnavailable: 30010008,
31
+ AppRuntimeUnavailable: 30010008,
32
32
  AppNotInstalled: 30010009
33
33
  });
34
34
  var Status = Object.freeze({
@@ -1161,8 +1161,8 @@ async function query(ctx, options = {}) {
1161
1161
  const dbPaths = await resolveDeviceDbPaths(ctx, config);
1162
1162
  if (dbPaths.length === 0) {
1163
1163
  throw new CrawlerError({
1164
- message: "data_access_unavailable: sqlite database not found",
1165
- code: Code.DataAccessUnavailable,
1164
+ message: "app_runtime_unavailable: sqlite database not found",
1165
+ code: Code.AppRuntimeUnavailable,
1166
1166
  context: { dbDir: config.dbDir, dbPath: config.dbPath, dbNamePrefix: config.dbNamePrefix }
1167
1167
  });
1168
1168
  }
@@ -1211,8 +1211,8 @@ async function resolveDeviceDbPaths(ctx, config) {
1211
1211
  maxBuffer: 2 * 1024 * 1024
1212
1212
  }).catch((error) => {
1213
1213
  throw new CrawlerError({
1214
- message: `data_access_unavailable: sqlite dbDir unavailable ${error?.message || String(error)}`,
1215
- code: Code.DataAccessUnavailable,
1214
+ message: `app_runtime_unavailable: sqlite dbDir unavailable ${error?.message || String(error)}`,
1215
+ code: Code.AppRuntimeUnavailable,
1216
1216
  context: { dbDir: config.dbDir }
1217
1217
  });
1218
1218
  });
@@ -1237,8 +1237,8 @@ async function pullDatabaseSnapshot(ctx, dbPath, localDir) {
1237
1237
  await adbSuShell(ctx, copyCommand, { timeoutMs: 3e4, maxBuffer: 4 * 1024 * 1024 });
1238
1238
  await adbPull(adbPath, serial, remoteDb, localDb).catch((error) => {
1239
1239
  throw new CrawlerError({
1240
- message: `data_access_unavailable: sqlite snapshot pull failed ${error?.message || String(error)}`,
1241
- code: Code.DataAccessUnavailable,
1240
+ message: `app_runtime_unavailable: sqlite snapshot pull failed ${error?.message || String(error)}`,
1241
+ code: Code.AppRuntimeUnavailable,
1242
1242
  context: { dbPath }
1243
1243
  });
1244
1244
  });
@@ -1697,17 +1697,28 @@ async function captureScreen(ctx, options = {}) {
1697
1697
  const frameBuffers = [];
1698
1698
  const seen = /* @__PURE__ */ new Set();
1699
1699
  const targetSelector = options.selector || { id: "message_list" };
1700
- await Device.hideKeyboard(ctx, { attempts: 2, settleMs: 350 }).catch(() => {
1700
+ const shouldHideKeyboard = options.hideKeyboard !== false;
1701
+ if (shouldHideKeyboard) await Device.hideKeyboard(ctx, { attempts: 2, settleMs: 350 }).catch(() => {
1701
1702
  });
1702
- await DeviceInput.scrollToTop(ctx, targetSelector, {
1703
- maxSwipes: Number(options.scrollToTopMaxSwipes || 12),
1704
- stableRounds: 2,
1705
- settleMs: 400
1706
- }).catch((error) => {
1703
+ try {
1704
+ const topResult = await DeviceInput.scrollToTop(ctx, targetSelector, {
1705
+ maxSwipes: Number(options.scrollToTopMaxSwipes || 12),
1706
+ stableRounds: Number(options.scrollToTopStableRounds || 2),
1707
+ settleMs: 400,
1708
+ stability: options.scrollStability || options.stability || "view"
1709
+ });
1710
+ Logger.info("captureScreen scrollToTop", {
1711
+ swipes: topResult?.swipes,
1712
+ stableRounds: topResult?.stableRounds,
1713
+ hashSource: topResult?.hashSource,
1714
+ capped: topResult?.capped === true
1715
+ });
1716
+ } catch (error) {
1717
+ if (options.strictScrollToTop === true) throw error;
1707
1718
  Logger.warn("captureScreen scrollToTop skipped", { message: error?.message || String(error) });
1708
- });
1719
+ }
1709
1720
  for (let index = 0; index < DEFAULT_CAPTURE_COUNT; index += 1) {
1710
- await Device.hideKeyboard(ctx, { attempts: 1, settleMs: 250 }).catch(() => {
1721
+ if (shouldHideKeyboard) await Device.hideKeyboard(ctx, { attempts: 1, settleMs: 250 }).catch(() => {
1711
1722
  });
1712
1723
  await sleep(DEFAULT_SETTLE_MS);
1713
1724
  const png = await Device.screenshotPng(ctx);