@midscene/harmony 1.15.4 → 1.15.5

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/bin.mjs CHANGED
@@ -9,7 +9,7 @@ import { mergeAndNormalizeAppNameMapping, normalizeForComparison, repeat } from
9
9
  import node_assert from "node:assert";
10
10
  import node_fs, { accessSync, constants } from "node:fs";
11
11
  import { z } from "@midscene/core";
12
- import { createDefaultMobileActions, defineAction, resolveTextInputOptions, sendTextSequentially, shouldInputSequentially } from "@midscene/core/device";
12
+ import { createDefaultMobileActions, defineAction, resolveDefaultMobileScroll, resolveTextInputOptions, sendTextSequentially, shouldInputSequentially } from "@midscene/core/device";
13
13
  import { getTmpFile, sleep } from "@midscene/core/utils";
14
14
  import { createImgBase64ByFormat } from "@midscene/shared/img";
15
15
  import { execFile } from "node:child_process";
@@ -708,8 +708,9 @@ class device_HarmonyDevice {
708
708
  if (0 === deltaX && 0 === deltaY) throw new Error('Scroll distance cannot be zero in both directions');
709
709
  const { width, height } = await this.size();
710
710
  const n = scrollQuadrantDivisions;
711
- const startX = Math.round(deltaX < 0 ? width / n * (n - 1) : width / n);
712
- const startY = Math.round(deltaY < 0 ? height / n * (n - 1) : height / n);
711
+ const axisStart = (delta, extent)=>Math.round(0 === delta ? extent / 2 : delta < 0 ? extent / n : (n - 1) * extent / n);
712
+ const startX = axisStart(deltaX, width);
713
+ const startY = axisStart(deltaY, height);
713
714
  const maxPositiveDeltaX = startX;
714
715
  const maxNegativeDeltaX = width - startX;
715
716
  const maxPositiveDeltaY = startY;
@@ -724,6 +725,15 @@ class device_HarmonyDevice {
724
725
  async scrollInDirection(direction, distance, startPoint) {
725
726
  const { width, height } = await this.size();
726
727
  const isVertical = 'up' === direction || 'down' === direction;
728
+ if (void 0 === distance && !startPoint) {
729
+ const { from, to } = resolveDefaultMobileScroll(direction, {
730
+ width,
731
+ height
732
+ });
733
+ const hdc = await this.getHdc();
734
+ await hdc.fling(from.x, from.y, to.x, to.y, resolveSwipeSpeed(from, to, 1000));
735
+ return;
736
+ }
727
737
  const scrollDistance = Math.round(distance ?? (isVertical ? height : width));
728
738
  if (startPoint) {
729
739
  const hdc = await this.getHdc();
package/dist/es/cli.mjs CHANGED
@@ -7,7 +7,7 @@ import { Agent } from "@midscene/core/agent";
7
7
  import { mergeAndNormalizeAppNameMapping, normalizeForComparison, repeat } from "@midscene/shared/utils";
8
8
  import node_assert from "node:assert";
9
9
  import node_fs, { accessSync, constants } from "node:fs";
10
- import { createDefaultMobileActions, defineAction, resolveTextInputOptions, sendTextSequentially, shouldInputSequentially } from "@midscene/core/device";
10
+ import { createDefaultMobileActions, defineAction, resolveDefaultMobileScroll, resolveTextInputOptions, sendTextSequentially, shouldInputSequentially } from "@midscene/core/device";
11
11
  import { getTmpFile, sleep } from "@midscene/core/utils";
12
12
  import { createImgBase64ByFormat } from "@midscene/shared/img";
13
13
  import { execFile } from "node:child_process";
@@ -706,8 +706,9 @@ class HarmonyDevice {
706
706
  if (0 === deltaX && 0 === deltaY) throw new Error('Scroll distance cannot be zero in both directions');
707
707
  const { width, height } = await this.size();
708
708
  const n = scrollQuadrantDivisions;
709
- const startX = Math.round(deltaX < 0 ? width / n * (n - 1) : width / n);
710
- const startY = Math.round(deltaY < 0 ? height / n * (n - 1) : height / n);
709
+ const axisStart = (delta, extent)=>Math.round(0 === delta ? extent / 2 : delta < 0 ? extent / n : (n - 1) * extent / n);
710
+ const startX = axisStart(deltaX, width);
711
+ const startY = axisStart(deltaY, height);
711
712
  const maxPositiveDeltaX = startX;
712
713
  const maxNegativeDeltaX = width - startX;
713
714
  const maxPositiveDeltaY = startY;
@@ -722,6 +723,15 @@ class HarmonyDevice {
722
723
  async scrollInDirection(direction, distance, startPoint) {
723
724
  const { width, height } = await this.size();
724
725
  const isVertical = 'up' === direction || 'down' === direction;
726
+ if (void 0 === distance && !startPoint) {
727
+ const { from, to } = resolveDefaultMobileScroll(direction, {
728
+ width,
729
+ height
730
+ });
731
+ const hdc = await this.getHdc();
732
+ await hdc.fling(from.x, from.y, to.x, to.y, resolveSwipeSpeed(from, to, 1000));
733
+ return;
734
+ }
725
735
  const scrollDistance = Math.round(distance ?? (isVertical ? height : width));
726
736
  if (startPoint) {
727
737
  const hdc = await this.getHdc();
@@ -1306,7 +1316,7 @@ class HarmonyMidsceneTools extends BaseMidsceneTools {
1306
1316
  const tools = new HarmonyMidsceneTools();
1307
1317
  runToolsCLI(tools, 'midscene-harmony', {
1308
1318
  stripPrefix: 'harmony_',
1309
- version: "1.15.4",
1319
+ version: "1.15.5",
1310
1320
  extraCommands: createReportCliCommands()
1311
1321
  }).catch((e)=>{
1312
1322
  process.exit(reportCLIError(e));
package/dist/es/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import node_assert from "node:assert";
2
2
  import node_fs, { accessSync, constants } from "node:fs";
3
3
  import { z } from "@midscene/core";
4
- import { createDefaultMobileActions, defineAction, resolveTextInputOptions, sendTextSequentially, shouldInputSequentially } from "@midscene/core/device";
4
+ import { createDefaultMobileActions, defineAction, resolveDefaultMobileScroll, resolveTextInputOptions, sendTextSequentially, shouldInputSequentially } from "@midscene/core/device";
5
5
  import { getTmpFile, sleep } from "@midscene/core/utils";
6
6
  import { createImgBase64ByFormat } from "@midscene/shared/img";
7
7
  import { getDebug } from "@midscene/shared/logger";
@@ -677,8 +677,9 @@ class HarmonyDevice {
677
677
  if (0 === deltaX && 0 === deltaY) throw new Error('Scroll distance cannot be zero in both directions');
678
678
  const { width, height } = await this.size();
679
679
  const n = scrollQuadrantDivisions;
680
- const startX = Math.round(deltaX < 0 ? width / n * (n - 1) : width / n);
681
- const startY = Math.round(deltaY < 0 ? height / n * (n - 1) : height / n);
680
+ const axisStart = (delta, extent)=>Math.round(0 === delta ? extent / 2 : delta < 0 ? extent / n : (n - 1) * extent / n);
681
+ const startX = axisStart(deltaX, width);
682
+ const startY = axisStart(deltaY, height);
682
683
  const maxPositiveDeltaX = startX;
683
684
  const maxNegativeDeltaX = width - startX;
684
685
  const maxPositiveDeltaY = startY;
@@ -693,6 +694,15 @@ class HarmonyDevice {
693
694
  async scrollInDirection(direction, distance, startPoint) {
694
695
  const { width, height } = await this.size();
695
696
  const isVertical = 'up' === direction || 'down' === direction;
697
+ if (void 0 === distance && !startPoint) {
698
+ const { from, to } = resolveDefaultMobileScroll(direction, {
699
+ width,
700
+ height
701
+ });
702
+ const hdc = await this.getHdc();
703
+ await hdc.fling(from.x, from.y, to.x, to.y, resolveSwipeSpeed(from, to, 1000));
704
+ return;
705
+ }
696
706
  const scrollDistance = Math.round(distance ?? (isVertical ? height : width));
697
707
  if (startPoint) {
698
708
  const hdc = await this.getHdc();
package/dist/lib/bin.js CHANGED
@@ -848,8 +848,9 @@ var __webpack_exports__ = {};
848
848
  if (0 === deltaX && 0 === deltaY) throw new Error('Scroll distance cannot be zero in both directions');
849
849
  const { width, height } = await this.size();
850
850
  const n = scrollQuadrantDivisions;
851
- const startX = Math.round(deltaX < 0 ? width / n * (n - 1) : width / n);
852
- const startY = Math.round(deltaY < 0 ? height / n * (n - 1) : height / n);
851
+ const axisStart = (delta, extent)=>Math.round(0 === delta ? extent / 2 : delta < 0 ? extent / n : (n - 1) * extent / n);
852
+ const startX = axisStart(deltaX, width);
853
+ const startY = axisStart(deltaY, height);
853
854
  const maxPositiveDeltaX = startX;
854
855
  const maxNegativeDeltaX = width - startX;
855
856
  const maxPositiveDeltaY = startY;
@@ -864,6 +865,15 @@ var __webpack_exports__ = {};
864
865
  async scrollInDirection(direction, distance, startPoint) {
865
866
  const { width, height } = await this.size();
866
867
  const isVertical = 'up' === direction || 'down' === direction;
868
+ if (void 0 === distance && !startPoint) {
869
+ const { from, to } = (0, device_namespaceObject.resolveDefaultMobileScroll)(direction, {
870
+ width,
871
+ height
872
+ });
873
+ const hdc = await this.getHdc();
874
+ await hdc.fling(from.x, from.y, to.x, to.y, resolveSwipeSpeed(from, to, 1000));
875
+ return;
876
+ }
867
877
  const scrollDistance = Math.round(distance ?? (isVertical ? height : width));
868
878
  if (startPoint) {
869
879
  const hdc = await this.getHdc();
package/dist/lib/cli.js CHANGED
@@ -845,8 +845,9 @@ var __webpack_exports__ = {};
845
845
  if (0 === deltaX && 0 === deltaY) throw new Error('Scroll distance cannot be zero in both directions');
846
846
  const { width, height } = await this.size();
847
847
  const n = scrollQuadrantDivisions;
848
- const startX = Math.round(deltaX < 0 ? width / n * (n - 1) : width / n);
849
- const startY = Math.round(deltaY < 0 ? height / n * (n - 1) : height / n);
848
+ const axisStart = (delta, extent)=>Math.round(0 === delta ? extent / 2 : delta < 0 ? extent / n : (n - 1) * extent / n);
849
+ const startX = axisStart(deltaX, width);
850
+ const startY = axisStart(deltaY, height);
850
851
  const maxPositiveDeltaX = startX;
851
852
  const maxNegativeDeltaX = width - startX;
852
853
  const maxPositiveDeltaY = startY;
@@ -861,6 +862,15 @@ var __webpack_exports__ = {};
861
862
  async scrollInDirection(direction, distance, startPoint) {
862
863
  const { width, height } = await this.size();
863
864
  const isVertical = 'up' === direction || 'down' === direction;
865
+ if (void 0 === distance && !startPoint) {
866
+ const { from, to } = (0, device_namespaceObject.resolveDefaultMobileScroll)(direction, {
867
+ width,
868
+ height
869
+ });
870
+ const hdc = await this.getHdc();
871
+ await hdc.fling(from.x, from.y, to.x, to.y, resolveSwipeSpeed(from, to, 1000));
872
+ return;
873
+ }
864
874
  const scrollDistance = Math.round(distance ?? (isVertical ? height : width));
865
875
  if (startPoint) {
866
876
  const hdc = await this.getHdc();
@@ -1349,7 +1359,7 @@ var __webpack_exports__ = {};
1349
1359
  const tools = new HarmonyMidsceneTools();
1350
1360
  (0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-harmony', {
1351
1361
  stripPrefix: 'harmony_',
1352
- version: "1.15.4",
1362
+ version: "1.15.5",
1353
1363
  extraCommands: (0, core_namespaceObject.createReportCliCommands)()
1354
1364
  }).catch((e)=>{
1355
1365
  process.exit((0, cli_namespaceObject.reportCLIError)(e));
package/dist/lib/index.js CHANGED
@@ -834,8 +834,9 @@ var __webpack_exports__ = {};
834
834
  if (0 === deltaX && 0 === deltaY) throw new Error('Scroll distance cannot be zero in both directions');
835
835
  const { width, height } = await this.size();
836
836
  const n = scrollQuadrantDivisions;
837
- const startX = Math.round(deltaX < 0 ? width / n * (n - 1) : width / n);
838
- const startY = Math.round(deltaY < 0 ? height / n * (n - 1) : height / n);
837
+ const axisStart = (delta, extent)=>Math.round(0 === delta ? extent / 2 : delta < 0 ? extent / n : (n - 1) * extent / n);
838
+ const startX = axisStart(deltaX, width);
839
+ const startY = axisStart(deltaY, height);
839
840
  const maxPositiveDeltaX = startX;
840
841
  const maxNegativeDeltaX = width - startX;
841
842
  const maxPositiveDeltaY = startY;
@@ -850,6 +851,15 @@ var __webpack_exports__ = {};
850
851
  async scrollInDirection(direction, distance, startPoint) {
851
852
  const { width, height } = await this.size();
852
853
  const isVertical = 'up' === direction || 'down' === direction;
854
+ if (void 0 === distance && !startPoint) {
855
+ const { from, to } = (0, device_namespaceObject.resolveDefaultMobileScroll)(direction, {
856
+ width,
857
+ height
858
+ });
859
+ const hdc = await this.getHdc();
860
+ await hdc.fling(from.x, from.y, to.x, to.y, resolveSwipeSpeed(from, to, 1000));
861
+ return;
862
+ }
853
863
  const scrollDistance = Math.round(distance ?? (isVertical ? height : width));
854
864
  if (startPoint) {
855
865
  const hdc = await this.getHdc();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/harmony",
3
- "version": "1.15.4",
3
+ "version": "1.15.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/midscene.git",
@@ -47,9 +47,9 @@
47
47
  "@inquirer/prompts": "^7.8.6",
48
48
  "open": "10.1.0",
49
49
  "zod": "^3.25.1",
50
- "@midscene/playground": "1.15.4",
51
- "@midscene/shared": "1.15.4",
52
- "@midscene/core": "1.15.4"
50
+ "@midscene/core": "1.15.5",
51
+ "@midscene/playground": "1.15.5",
52
+ "@midscene/shared": "1.15.5"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@rslib/core": "^0.18.3",
package/static/index.html CHANGED
@@ -1 +1 @@
1
- <!doctype html><html><head><link rel="icon" href="/favicon.ico"><title>Midscene Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.8bb5dc6e.js"></script><script defer src="/static/js/652.6a7cf351.js"></script><script defer src="/static/js/index.2cdf63aa.js"></script><link href="/static/css/index.67caac18.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
1
+ <!doctype html><html><head><link rel="icon" href="/favicon.ico"><title>Midscene Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.8bb5dc6e.js"></script><script defer src="/static/js/652.6a7cf351.js"></script><script defer src="/static/js/index.b180169f.js"></script><link href="/static/css/index.67caac18.css" rel="stylesheet"></head><body><div id="root"></div></body></html>