@midscene/android 1.15.5-beta-20261015030228.0 → 1.15.6

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/cli.mjs CHANGED
@@ -11,7 +11,7 @@ import { Agent } from "@midscene/core/agent";
11
11
  import { mergeAndNormalizeAppNameMapping, normalizeForComparison, repeat } from "@midscene/shared/utils";
12
12
  import node_assert from "node:assert";
13
13
  import { execFile } from "node:child_process";
14
- import { createDefaultMobileActions, defineAction, resolveTextInputOptions, sendTextSequentially, shouldInputSequentially } from "@midscene/core/device";
14
+ import { createDefaultMobileActions, defineAction, resolveDefaultMobileScroll, resolveTextInputOptions, sendTextSequentially, shouldInputSequentially } from "@midscene/core/device";
15
15
  import { getTmpFile, sleep } from "@midscene/core/utils";
16
16
  import { MIDSCENE_ADB_PATH, MIDSCENE_ADB_REMOTE_HOST, MIDSCENE_ADB_REMOTE_PORT, MIDSCENE_ANDROID_IME_STRATEGY, MIDSCENE_ANDROID_SCREENSHOT_STRATEGY, globalConfigManager } from "@midscene/shared/env";
17
17
  import { ADB, getSdkRootFromEnv } from "appium-adb";
@@ -2640,10 +2640,16 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2640
2640
  await repeat(defaultScrollUntilTimes, ()=>this.scrollRaw(9999999, 0, defaultFastScrollDuration));
2641
2641
  await sleep(1000);
2642
2642
  }
2643
+ async scrollDefault(direction) {
2644
+ const { from, to } = resolveDefaultMobileScroll(direction, await this.size());
2645
+ const duration = defaultNormalScrollDuration;
2646
+ await this.swipePoint(from, to, duration);
2647
+ }
2643
2648
  async scrollUp(distance, startPoint) {
2644
2649
  await this.visualActions.scrollUp(distance, startPoint);
2645
2650
  }
2646
2651
  async scrollUpRaw(distance, startPoint) {
2652
+ if (void 0 === distance && !startPoint) return this.scrollDefault('up');
2647
2653
  const { height } = await this.size();
2648
2654
  const scrollDistance = Math.round(distance || height);
2649
2655
  const hasExplicitDistance = void 0 !== distance;
@@ -2663,6 +2669,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2663
2669
  await this.visualActions.scrollDown(distance, startPoint);
2664
2670
  }
2665
2671
  async scrollDownRaw(distance, startPoint) {
2672
+ if (void 0 === distance && !startPoint) return this.scrollDefault('down');
2666
2673
  const { height } = await this.size();
2667
2674
  const scrollDistance = Math.round(distance || height);
2668
2675
  const hasExplicitDistance = void 0 !== distance;
@@ -2682,6 +2689,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2682
2689
  await this.visualActions.scrollLeft(distance, startPoint);
2683
2690
  }
2684
2691
  async scrollLeftRaw(distance, startPoint) {
2692
+ if (void 0 === distance && !startPoint) return this.scrollDefault('left');
2685
2693
  const { width } = await this.size();
2686
2694
  const scrollDistance = Math.round(distance || width);
2687
2695
  const hasExplicitDistance = void 0 !== distance;
@@ -2701,6 +2709,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2701
2709
  await this.visualActions.scrollRight(distance, startPoint);
2702
2710
  }
2703
2711
  async scrollRightRaw(distance, startPoint) {
2712
+ if (void 0 === distance && !startPoint) return this.scrollDefault('right');
2704
2713
  const { width } = await this.size();
2705
2714
  const scrollDistance = Math.round(distance || width);
2706
2715
  const hasExplicitDistance = void 0 !== distance;
@@ -2832,8 +2841,9 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2832
2841
  if (0 === deltaX && 0 === deltaY) throw new Error('Scroll distance cannot be zero in both directions');
2833
2842
  const { width, height } = await this.size();
2834
2843
  const n = 4;
2835
- const startX = Math.round(deltaX < 0 ? width / n * (n - 1) : width / n);
2836
- const startY = Math.round(deltaY < 0 ? height / n * (n - 1) : height / n);
2844
+ const axisStart = (delta, size)=>0 === delta ? Math.round(size / 2) : Math.round(delta < 0 ? size / n : size / n * (n - 1));
2845
+ const startX = axisStart(deltaX, width);
2846
+ const startY = axisStart(deltaY, height);
2837
2847
  const maxPositiveDeltaX = startX;
2838
2848
  const maxNegativeDeltaX = width - startX;
2839
2849
  const maxPositiveDeltaY = startY;
@@ -3540,7 +3550,7 @@ class AndroidMidsceneTools extends BaseMidsceneTools {
3540
3550
  const tools = new AndroidMidsceneTools();
3541
3551
  runToolsCLI(tools, 'midscene-android', {
3542
3552
  stripPrefix: 'android_',
3543
- version: "1.15.5-beta-20261015030228.0",
3553
+ version: "1.15.6",
3544
3554
  extraCommands: createReportCliCommands()
3545
3555
  }).catch((e)=>{
3546
3556
  process.exit(reportCLIError(e));
package/dist/es/index.mjs CHANGED
@@ -6,7 +6,7 @@ import * as __rspack_external_node_path_c5b9b54f from "node:path";
6
6
  import node_assert from "node:assert";
7
7
  import { execFile } from "node:child_process";
8
8
  import { getMidsceneLocationSchema, z } from "@midscene/core";
9
- import { createDefaultMobileActions, defineAction, resolveTextInputOptions, sendTextSequentially, shouldInputSequentially } from "@midscene/core/device";
9
+ import { createDefaultMobileActions, defineAction, resolveDefaultMobileScroll, resolveTextInputOptions, sendTextSequentially, shouldInputSequentially } from "@midscene/core/device";
10
10
  import { getTmpFile, sleep } from "@midscene/core/utils";
11
11
  import { MIDSCENE_ADB_PATH, MIDSCENE_ADB_REMOTE_HOST, MIDSCENE_ADB_REMOTE_PORT, MIDSCENE_ANDROID_IME_STRATEGY, MIDSCENE_ANDROID_SCREENSHOT_STRATEGY, globalConfigManager, overrideAIConfig } from "@midscene/shared/env";
12
12
  import { mergeAndNormalizeAppNameMapping, normalizeForComparison, repeat } from "@midscene/shared/utils";
@@ -2543,10 +2543,16 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2543
2543
  await repeat(defaultScrollUntilTimes, ()=>this.scrollRaw(9999999, 0, defaultFastScrollDuration));
2544
2544
  await sleep(1000);
2545
2545
  }
2546
+ async scrollDefault(direction) {
2547
+ const { from, to } = resolveDefaultMobileScroll(direction, await this.size());
2548
+ const duration = defaultNormalScrollDuration;
2549
+ await this.swipePoint(from, to, duration);
2550
+ }
2546
2551
  async scrollUp(distance, startPoint) {
2547
2552
  await this.visualActions.scrollUp(distance, startPoint);
2548
2553
  }
2549
2554
  async scrollUpRaw(distance, startPoint) {
2555
+ if (void 0 === distance && !startPoint) return this.scrollDefault('up');
2550
2556
  const { height } = await this.size();
2551
2557
  const scrollDistance = Math.round(distance || height);
2552
2558
  const hasExplicitDistance = void 0 !== distance;
@@ -2566,6 +2572,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2566
2572
  await this.visualActions.scrollDown(distance, startPoint);
2567
2573
  }
2568
2574
  async scrollDownRaw(distance, startPoint) {
2575
+ if (void 0 === distance && !startPoint) return this.scrollDefault('down');
2569
2576
  const { height } = await this.size();
2570
2577
  const scrollDistance = Math.round(distance || height);
2571
2578
  const hasExplicitDistance = void 0 !== distance;
@@ -2585,6 +2592,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2585
2592
  await this.visualActions.scrollLeft(distance, startPoint);
2586
2593
  }
2587
2594
  async scrollLeftRaw(distance, startPoint) {
2595
+ if (void 0 === distance && !startPoint) return this.scrollDefault('left');
2588
2596
  const { width } = await this.size();
2589
2597
  const scrollDistance = Math.round(distance || width);
2590
2598
  const hasExplicitDistance = void 0 !== distance;
@@ -2604,6 +2612,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2604
2612
  await this.visualActions.scrollRight(distance, startPoint);
2605
2613
  }
2606
2614
  async scrollRightRaw(distance, startPoint) {
2615
+ if (void 0 === distance && !startPoint) return this.scrollDefault('right');
2607
2616
  const { width } = await this.size();
2608
2617
  const scrollDistance = Math.round(distance || width);
2609
2618
  const hasExplicitDistance = void 0 !== distance;
@@ -2735,8 +2744,9 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2735
2744
  if (0 === deltaX && 0 === deltaY) throw new Error('Scroll distance cannot be zero in both directions');
2736
2745
  const { width, height } = await this.size();
2737
2746
  const n = 4;
2738
- const startX = Math.round(deltaX < 0 ? width / n * (n - 1) : width / n);
2739
- const startY = Math.round(deltaY < 0 ? height / n * (n - 1) : height / n);
2747
+ const axisStart = (delta, size)=>0 === delta ? Math.round(size / 2) : Math.round(delta < 0 ? size / n : size / n * (n - 1));
2748
+ const startX = axisStart(deltaX, width);
2749
+ const startY = axisStart(deltaY, height);
2740
2750
  const maxPositiveDeltaX = startX;
2741
2751
  const maxNegativeDeltaX = width - startX;
2742
2752
  const maxPositiveDeltaY = startY;
package/dist/lib/cli.js CHANGED
@@ -2761,10 +2761,16 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2761
2761
  await (0, utils_namespaceObject.repeat)(defaultScrollUntilTimes, ()=>this.scrollRaw(9999999, 0, defaultFastScrollDuration));
2762
2762
  await (0, core_utils_namespaceObject.sleep)(1000);
2763
2763
  }
2764
+ async scrollDefault(direction) {
2765
+ const { from, to } = (0, device_namespaceObject.resolveDefaultMobileScroll)(direction, await this.size());
2766
+ const duration = defaultNormalScrollDuration;
2767
+ await this.swipePoint(from, to, duration);
2768
+ }
2764
2769
  async scrollUp(distance, startPoint) {
2765
2770
  await this.visualActions.scrollUp(distance, startPoint);
2766
2771
  }
2767
2772
  async scrollUpRaw(distance, startPoint) {
2773
+ if (void 0 === distance && !startPoint) return this.scrollDefault('up');
2768
2774
  const { height } = await this.size();
2769
2775
  const scrollDistance = Math.round(distance || height);
2770
2776
  const hasExplicitDistance = void 0 !== distance;
@@ -2784,6 +2790,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2784
2790
  await this.visualActions.scrollDown(distance, startPoint);
2785
2791
  }
2786
2792
  async scrollDownRaw(distance, startPoint) {
2793
+ if (void 0 === distance && !startPoint) return this.scrollDefault('down');
2787
2794
  const { height } = await this.size();
2788
2795
  const scrollDistance = Math.round(distance || height);
2789
2796
  const hasExplicitDistance = void 0 !== distance;
@@ -2803,6 +2810,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2803
2810
  await this.visualActions.scrollLeft(distance, startPoint);
2804
2811
  }
2805
2812
  async scrollLeftRaw(distance, startPoint) {
2813
+ if (void 0 === distance && !startPoint) return this.scrollDefault('left');
2806
2814
  const { width } = await this.size();
2807
2815
  const scrollDistance = Math.round(distance || width);
2808
2816
  const hasExplicitDistance = void 0 !== distance;
@@ -2822,6 +2830,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2822
2830
  await this.visualActions.scrollRight(distance, startPoint);
2823
2831
  }
2824
2832
  async scrollRightRaw(distance, startPoint) {
2833
+ if (void 0 === distance && !startPoint) return this.scrollDefault('right');
2825
2834
  const { width } = await this.size();
2826
2835
  const scrollDistance = Math.round(distance || width);
2827
2836
  const hasExplicitDistance = void 0 !== distance;
@@ -2953,8 +2962,9 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2953
2962
  if (0 === deltaX && 0 === deltaY) throw new Error('Scroll distance cannot be zero in both directions');
2954
2963
  const { width, height } = await this.size();
2955
2964
  const n = 4;
2956
- const startX = Math.round(deltaX < 0 ? width / n * (n - 1) : width / n);
2957
- const startY = Math.round(deltaY < 0 ? height / n * (n - 1) : height / n);
2965
+ const axisStart = (delta, size)=>0 === delta ? Math.round(size / 2) : Math.round(delta < 0 ? size / n : size / n * (n - 1));
2966
+ const startX = axisStart(deltaX, width);
2967
+ const startY = axisStart(deltaY, height);
2958
2968
  const maxPositiveDeltaX = startX;
2959
2969
  const maxNegativeDeltaX = width - startX;
2960
2970
  const maxPositiveDeltaY = startY;
@@ -3560,7 +3570,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
3560
3570
  const tools = new AndroidMidsceneTools();
3561
3571
  (0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-android', {
3562
3572
  stripPrefix: 'android_',
3563
- version: "1.15.5-beta-20261015030228.0",
3573
+ version: "1.15.6",
3564
3574
  extraCommands: (0, core_namespaceObject.createReportCliCommands)()
3565
3575
  }).catch((e)=>{
3566
3576
  process.exit((0, cli_namespaceObject.reportCLIError)(e));
package/dist/lib/index.js CHANGED
@@ -2692,10 +2692,16 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2692
2692
  await (0, shared_utils_namespaceObject.repeat)(defaultScrollUntilTimes, ()=>this.scrollRaw(9999999, 0, defaultFastScrollDuration));
2693
2693
  await (0, utils_namespaceObject.sleep)(1000);
2694
2694
  }
2695
+ async scrollDefault(direction) {
2696
+ const { from, to } = (0, device_namespaceObject.resolveDefaultMobileScroll)(direction, await this.size());
2697
+ const duration = defaultNormalScrollDuration;
2698
+ await this.swipePoint(from, to, duration);
2699
+ }
2695
2700
  async scrollUp(distance, startPoint) {
2696
2701
  await this.visualActions.scrollUp(distance, startPoint);
2697
2702
  }
2698
2703
  async scrollUpRaw(distance, startPoint) {
2704
+ if (void 0 === distance && !startPoint) return this.scrollDefault('up');
2699
2705
  const { height } = await this.size();
2700
2706
  const scrollDistance = Math.round(distance || height);
2701
2707
  const hasExplicitDistance = void 0 !== distance;
@@ -2715,6 +2721,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2715
2721
  await this.visualActions.scrollDown(distance, startPoint);
2716
2722
  }
2717
2723
  async scrollDownRaw(distance, startPoint) {
2724
+ if (void 0 === distance && !startPoint) return this.scrollDefault('down');
2718
2725
  const { height } = await this.size();
2719
2726
  const scrollDistance = Math.round(distance || height);
2720
2727
  const hasExplicitDistance = void 0 !== distance;
@@ -2734,6 +2741,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2734
2741
  await this.visualActions.scrollLeft(distance, startPoint);
2735
2742
  }
2736
2743
  async scrollLeftRaw(distance, startPoint) {
2744
+ if (void 0 === distance && !startPoint) return this.scrollDefault('left');
2737
2745
  const { width } = await this.size();
2738
2746
  const scrollDistance = Math.round(distance || width);
2739
2747
  const hasExplicitDistance = void 0 !== distance;
@@ -2753,6 +2761,7 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2753
2761
  await this.visualActions.scrollRight(distance, startPoint);
2754
2762
  }
2755
2763
  async scrollRightRaw(distance, startPoint) {
2764
+ if (void 0 === distance && !startPoint) return this.scrollDefault('right');
2756
2765
  const { width } = await this.size();
2757
2766
  const scrollDistance = Math.round(distance || width);
2758
2767
  const hasExplicitDistance = void 0 !== distance;
@@ -2884,8 +2893,9 @@ ${Object.keys(size).filter((key)=>size[key]).map((key)=>` ${key} size: ${size[k
2884
2893
  if (0 === deltaX && 0 === deltaY) throw new Error('Scroll distance cannot be zero in both directions');
2885
2894
  const { width, height } = await this.size();
2886
2895
  const n = 4;
2887
- const startX = Math.round(deltaX < 0 ? width / n * (n - 1) : width / n);
2888
- const startY = Math.round(deltaY < 0 ? height / n * (n - 1) : height / n);
2896
+ const axisStart = (delta, size)=>0 === delta ? Math.round(size / 2) : Math.round(delta < 0 ? size / n : size / n * (n - 1));
2897
+ const startX = axisStart(deltaX, width);
2898
+ const startY = axisStart(deltaY, height);
2889
2899
  const maxPositiveDeltaX = startX;
2890
2900
  const maxNegativeDeltaX = width - startX;
2891
2901
  const maxPositiveDeltaY = startY;
@@ -244,6 +244,7 @@ export declare class AndroidDevice implements AbstractInterface {
244
244
  private scrollUntilLeftRaw;
245
245
  scrollUntilRight(startPoint?: Point): Promise<void>;
246
246
  private scrollUntilRightRaw;
247
+ private scrollDefault;
247
248
  scrollUp(distance?: number, startPoint?: Point): Promise<void>;
248
249
  private scrollUpRaw;
249
250
  scrollDown(distance?: number, startPoint?: Point): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/android",
3
- "version": "1.15.5-beta-20261015030228.0",
3
+ "version": "1.15.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/midscene.git",
@@ -47,8 +47,8 @@
47
47
  "appium-adb": "12.12.1",
48
48
  "sharp": "^0.34.3",
49
49
  "zod": "^3.25.1",
50
- "@midscene/core": "1.15.5-beta-20261015030228.0",
51
- "@midscene/shared": "1.15.5-beta-20261015030228.0"
50
+ "@midscene/core": "1.15.6",
51
+ "@midscene/shared": "1.15.6"
52
52
  },
53
53
  "optionalDependencies": {
54
54
  "@ffmpeg-installer/ffmpeg": "^1.1.0"
@@ -61,7 +61,7 @@
61
61
  "tsx": "^4.19.2",
62
62
  "typescript": "^5.8.3",
63
63
  "undici": "^6.0.0",
64
- "@midscene/playground": "1.15.5-beta-20261015030228.0"
64
+ "@midscene/playground": "1.15.6"
65
65
  },
66
66
  "license": "MIT",
67
67
  "scripts": {