@midscene/harmony 1.12.8 → 1.12.9-beta-20260917120835.0
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 +19 -5
- package/dist/es/cli.mjs +20 -6
- package/dist/es/index.mjs +19 -5
- package/dist/lib/bin.js +19 -5
- package/dist/lib/cli.js +20 -6
- package/dist/lib/index.js +19 -5
- package/package.json +4 -4
- package/static/index.html +1 -1
- package/static/static/js/async/{466.42c0aeb1.js → 749.921ee4fd.js} +2 -2
- package/static/static/js/async/749.921ee4fd.js.map +1 -0
- package/static/static/js/{index.2e700293.js → index.2f2ca5c6.js} +82 -85
- package/static/static/js/index.2f2ca5c6.js.map +1 -0
- package/static/static/js/async/466.42c0aeb1.js.map +0 -1
- package/static/static/js/index.2e700293.js.map +0 -1
- /package/static/static/js/{index.2e700293.js.LICENSE.txt → index.2f2ca5c6.js.LICENSE.txt} +0 -0
package/dist/es/bin.mjs
CHANGED
|
@@ -50,6 +50,10 @@ const defaultAppNameMapping = {
|
|
|
50
50
|
百度: 'com.baidu.baiduapp',
|
|
51
51
|
携程: 'com.ctrip.harmonynext'
|
|
52
52
|
};
|
|
53
|
+
const uiInputSpeedRange = {
|
|
54
|
+
min: 200,
|
|
55
|
+
max: 40000
|
|
56
|
+
};
|
|
53
57
|
function _define_property(obj, key, value) {
|
|
54
58
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
55
59
|
value: value,
|
|
@@ -69,14 +73,12 @@ const supportedStringKeyEvents = new Set([
|
|
|
69
73
|
]);
|
|
70
74
|
const numericKeyEventPattern = /^\d+$/;
|
|
71
75
|
const uiInputErrorPattern = /(?:(?:Invalid parameters|Missing parameter|Too many parameters)\.?|Please confirm that the coordinate values are correct\.?)/i;
|
|
72
|
-
const minUiInputSpeed = 200;
|
|
73
|
-
const maxUiInputSpeed = 40000;
|
|
74
76
|
function roundUiCoordinate(value, name) {
|
|
75
77
|
if (!Number.isFinite(value) || value < 0) throw new Error(`HDC ${name} coordinate must be a non-negative finite number`);
|
|
76
78
|
return Math.round(value);
|
|
77
79
|
}
|
|
78
80
|
function roundUiInputSpeed(value, operation) {
|
|
79
|
-
if (!Number.isFinite(value) || value <
|
|
81
|
+
if (!Number.isFinite(value) || value < uiInputSpeedRange.min || value > uiInputSpeedRange.max) throw new Error(`HDC ${operation} speed must be a finite number between ${uiInputSpeedRange.min} and ${uiInputSpeedRange.max}`);
|
|
80
82
|
return Math.round(value);
|
|
81
83
|
}
|
|
82
84
|
function parseBundleInfo(output, bundleName) {
|
|
@@ -444,6 +446,18 @@ function resolveHarmonyKeyCodes(keyName) {
|
|
|
444
446
|
if (trimmedKeyName.includes('+')) throw new Error(`HarmonyOS keyboardPress does not support key combinations: ${JSON.stringify(keyName)}`);
|
|
445
447
|
return resolveSingleHarmonyKeyCodes(keyName);
|
|
446
448
|
}
|
|
449
|
+
const defaultSwipeDuration = 300;
|
|
450
|
+
const warnSwipe = getDebug('harmony:swipe', {
|
|
451
|
+
console: true
|
|
452
|
+
});
|
|
453
|
+
function resolveSwipeSpeed(start, end, duration = defaultSwipeDuration) {
|
|
454
|
+
if (!Number.isFinite(duration) || duration <= 0) throw new Error('Harmony swipe duration must be a positive finite number');
|
|
455
|
+
const distance = Math.hypot(end.x - start.x, end.y - start.y);
|
|
456
|
+
const requestedSpeed = 1000 * distance / duration;
|
|
457
|
+
const speed = Math.min(uiInputSpeedRange.max, Math.max(uiInputSpeedRange.min, requestedSpeed));
|
|
458
|
+
if (speed !== requestedSpeed) warnSwipe(`Harmony swipe speed ${requestedSpeed}px/s was clamped to ${speed}px/s; the requested ${duration}ms duration cannot be represented exactly`);
|
|
459
|
+
return Math.round(speed);
|
|
460
|
+
}
|
|
447
461
|
function device_define_property(obj, key, value) {
|
|
448
462
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
449
463
|
value: value,
|
|
@@ -915,10 +929,10 @@ class device_HarmonyDevice {
|
|
|
915
929
|
},
|
|
916
930
|
touch: {
|
|
917
931
|
swipe: async (start, end, opts)=>{
|
|
918
|
-
const
|
|
932
|
+
const speed = resolveSwipeSpeed(start, end, opts?.duration);
|
|
919
933
|
const repeatCount = opts?.repeat ?? 1;
|
|
920
934
|
const hdc = await this.getHdc();
|
|
921
|
-
for(let i = 0; i < repeatCount; i++)await hdc.swipe(start.x, start.y, end.x, end.y,
|
|
935
|
+
for(let i = 0; i < repeatCount; i++)await hdc.swipe(start.x, start.y, end.x, end.y, speed);
|
|
922
936
|
}
|
|
923
937
|
},
|
|
924
938
|
scroll: {
|
package/dist/es/cli.mjs
CHANGED
|
@@ -48,6 +48,10 @@ const defaultAppNameMapping = {
|
|
|
48
48
|
百度: 'com.baidu.baiduapp',
|
|
49
49
|
携程: 'com.ctrip.harmonynext'
|
|
50
50
|
};
|
|
51
|
+
const uiInputSpeedRange = {
|
|
52
|
+
min: 200,
|
|
53
|
+
max: 40000
|
|
54
|
+
};
|
|
51
55
|
function _define_property(obj, key, value) {
|
|
52
56
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
53
57
|
value: value,
|
|
@@ -67,14 +71,12 @@ const supportedStringKeyEvents = new Set([
|
|
|
67
71
|
]);
|
|
68
72
|
const numericKeyEventPattern = /^\d+$/;
|
|
69
73
|
const uiInputErrorPattern = /(?:(?:Invalid parameters|Missing parameter|Too many parameters)\.?|Please confirm that the coordinate values are correct\.?)/i;
|
|
70
|
-
const minUiInputSpeed = 200;
|
|
71
|
-
const maxUiInputSpeed = 40000;
|
|
72
74
|
function roundUiCoordinate(value, name) {
|
|
73
75
|
if (!Number.isFinite(value) || value < 0) throw new Error(`HDC ${name} coordinate must be a non-negative finite number`);
|
|
74
76
|
return Math.round(value);
|
|
75
77
|
}
|
|
76
78
|
function roundUiInputSpeed(value, operation) {
|
|
77
|
-
if (!Number.isFinite(value) || value <
|
|
79
|
+
if (!Number.isFinite(value) || value < uiInputSpeedRange.min || value > uiInputSpeedRange.max) throw new Error(`HDC ${operation} speed must be a finite number between ${uiInputSpeedRange.min} and ${uiInputSpeedRange.max}`);
|
|
78
80
|
return Math.round(value);
|
|
79
81
|
}
|
|
80
82
|
function parseBundleInfo(output, bundleName) {
|
|
@@ -442,6 +444,18 @@ function resolveHarmonyKeyCodes(keyName) {
|
|
|
442
444
|
if (trimmedKeyName.includes('+')) throw new Error(`HarmonyOS keyboardPress does not support key combinations: ${JSON.stringify(keyName)}`);
|
|
443
445
|
return resolveSingleHarmonyKeyCodes(keyName);
|
|
444
446
|
}
|
|
447
|
+
const defaultSwipeDuration = 300;
|
|
448
|
+
const warnSwipe = getDebug('harmony:swipe', {
|
|
449
|
+
console: true
|
|
450
|
+
});
|
|
451
|
+
function resolveSwipeSpeed(start, end, duration = defaultSwipeDuration) {
|
|
452
|
+
if (!Number.isFinite(duration) || duration <= 0) throw new Error('Harmony swipe duration must be a positive finite number');
|
|
453
|
+
const distance = Math.hypot(end.x - start.x, end.y - start.y);
|
|
454
|
+
const requestedSpeed = 1000 * distance / duration;
|
|
455
|
+
const speed = Math.min(uiInputSpeedRange.max, Math.max(uiInputSpeedRange.min, requestedSpeed));
|
|
456
|
+
if (speed !== requestedSpeed) warnSwipe(`Harmony swipe speed ${requestedSpeed}px/s was clamped to ${speed}px/s; the requested ${duration}ms duration cannot be represented exactly`);
|
|
457
|
+
return Math.round(speed);
|
|
458
|
+
}
|
|
445
459
|
function device_define_property(obj, key, value) {
|
|
446
460
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
447
461
|
value: value,
|
|
@@ -913,10 +927,10 @@ class HarmonyDevice {
|
|
|
913
927
|
},
|
|
914
928
|
touch: {
|
|
915
929
|
swipe: async (start, end, opts)=>{
|
|
916
|
-
const
|
|
930
|
+
const speed = resolveSwipeSpeed(start, end, opts?.duration);
|
|
917
931
|
const repeatCount = opts?.repeat ?? 1;
|
|
918
932
|
const hdc = await this.getHdc();
|
|
919
|
-
for(let i = 0; i < repeatCount; i++)await hdc.swipe(start.x, start.y, end.x, end.y,
|
|
933
|
+
for(let i = 0; i < repeatCount; i++)await hdc.swipe(start.x, start.y, end.x, end.y, speed);
|
|
920
934
|
}
|
|
921
935
|
},
|
|
922
936
|
scroll: {
|
|
@@ -1292,7 +1306,7 @@ class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
|
1292
1306
|
const tools = new HarmonyMidsceneTools();
|
|
1293
1307
|
runToolsCLI(tools, 'midscene-harmony', {
|
|
1294
1308
|
stripPrefix: 'harmony_',
|
|
1295
|
-
version: "1.12.
|
|
1309
|
+
version: "1.12.9-beta-20260917120835.0",
|
|
1296
1310
|
extraCommands: createReportCliCommands()
|
|
1297
1311
|
}).catch((e)=>{
|
|
1298
1312
|
process.exit(reportCLIError(e));
|
package/dist/es/index.mjs
CHANGED
|
@@ -19,6 +19,10 @@ import { select as prompts_select } from "@inquirer/prompts";
|
|
|
19
19
|
import { createScreenshotPreviewDescriptor, definePlaygroundPlatform } from "@midscene/playground";
|
|
20
20
|
import { PLAYGROUND_SERVER_PORT } from "@midscene/shared/constants";
|
|
21
21
|
import { findAvailablePort } from "@midscene/shared/node";
|
|
22
|
+
const uiInputSpeedRange = {
|
|
23
|
+
min: 200,
|
|
24
|
+
max: 40000
|
|
25
|
+
};
|
|
22
26
|
function _define_property(obj, key, value) {
|
|
23
27
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
24
28
|
value: value,
|
|
@@ -38,14 +42,12 @@ const supportedStringKeyEvents = new Set([
|
|
|
38
42
|
]);
|
|
39
43
|
const numericKeyEventPattern = /^\d+$/;
|
|
40
44
|
const uiInputErrorPattern = /(?:(?:Invalid parameters|Missing parameter|Too many parameters)\.?|Please confirm that the coordinate values are correct\.?)/i;
|
|
41
|
-
const minUiInputSpeed = 200;
|
|
42
|
-
const maxUiInputSpeed = 40000;
|
|
43
45
|
function roundUiCoordinate(value, name) {
|
|
44
46
|
if (!Number.isFinite(value) || value < 0) throw new Error(`HDC ${name} coordinate must be a non-negative finite number`);
|
|
45
47
|
return Math.round(value);
|
|
46
48
|
}
|
|
47
49
|
function roundUiInputSpeed(value, operation) {
|
|
48
|
-
if (!Number.isFinite(value) || value <
|
|
50
|
+
if (!Number.isFinite(value) || value < uiInputSpeedRange.min || value > uiInputSpeedRange.max) throw new Error(`HDC ${operation} speed must be a finite number between ${uiInputSpeedRange.min} and ${uiInputSpeedRange.max}`);
|
|
49
51
|
return Math.round(value);
|
|
50
52
|
}
|
|
51
53
|
function parseBundleInfo(output, bundleName) {
|
|
@@ -413,6 +415,18 @@ function resolveHarmonyKeyCodes(keyName) {
|
|
|
413
415
|
if (trimmedKeyName.includes('+')) throw new Error(`HarmonyOS keyboardPress does not support key combinations: ${JSON.stringify(keyName)}`);
|
|
414
416
|
return resolveSingleHarmonyKeyCodes(keyName);
|
|
415
417
|
}
|
|
418
|
+
const defaultSwipeDuration = 300;
|
|
419
|
+
const warnSwipe = getDebug('harmony:swipe', {
|
|
420
|
+
console: true
|
|
421
|
+
});
|
|
422
|
+
function resolveSwipeSpeed(start, end, duration = defaultSwipeDuration) {
|
|
423
|
+
if (!Number.isFinite(duration) || duration <= 0) throw new Error('Harmony swipe duration must be a positive finite number');
|
|
424
|
+
const distance = Math.hypot(end.x - start.x, end.y - start.y);
|
|
425
|
+
const requestedSpeed = 1000 * distance / duration;
|
|
426
|
+
const speed = Math.min(uiInputSpeedRange.max, Math.max(uiInputSpeedRange.min, requestedSpeed));
|
|
427
|
+
if (speed !== requestedSpeed) warnSwipe(`Harmony swipe speed ${requestedSpeed}px/s was clamped to ${speed}px/s; the requested ${duration}ms duration cannot be represented exactly`);
|
|
428
|
+
return Math.round(speed);
|
|
429
|
+
}
|
|
416
430
|
function device_define_property(obj, key, value) {
|
|
417
431
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
418
432
|
value: value,
|
|
@@ -884,10 +898,10 @@ class HarmonyDevice {
|
|
|
884
898
|
},
|
|
885
899
|
touch: {
|
|
886
900
|
swipe: async (start, end, opts)=>{
|
|
887
|
-
const
|
|
901
|
+
const speed = resolveSwipeSpeed(start, end, opts?.duration);
|
|
888
902
|
const repeatCount = opts?.repeat ?? 1;
|
|
889
903
|
const hdc = await this.getHdc();
|
|
890
|
-
for(let i = 0; i < repeatCount; i++)await hdc.swipe(start.x, start.y, end.x, end.y,
|
|
904
|
+
for(let i = 0; i < repeatCount; i++)await hdc.swipe(start.x, start.y, end.x, end.y, speed);
|
|
891
905
|
}
|
|
892
906
|
},
|
|
893
907
|
scroll: {
|
package/dist/lib/bin.js
CHANGED
|
@@ -190,6 +190,10 @@ var __webpack_exports__ = {};
|
|
|
190
190
|
const img_namespaceObject = require("@midscene/shared/img");
|
|
191
191
|
const external_node_child_process_namespaceObject = require("node:child_process");
|
|
192
192
|
const external_node_util_namespaceObject = require("node:util");
|
|
193
|
+
const uiInputSpeedRange = {
|
|
194
|
+
min: 200,
|
|
195
|
+
max: 40000
|
|
196
|
+
};
|
|
193
197
|
function _define_property(obj, key, value) {
|
|
194
198
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
195
199
|
value: value,
|
|
@@ -209,14 +213,12 @@ var __webpack_exports__ = {};
|
|
|
209
213
|
]);
|
|
210
214
|
const numericKeyEventPattern = /^\d+$/;
|
|
211
215
|
const uiInputErrorPattern = /(?:(?:Invalid parameters|Missing parameter|Too many parameters)\.?|Please confirm that the coordinate values are correct\.?)/i;
|
|
212
|
-
const minUiInputSpeed = 200;
|
|
213
|
-
const maxUiInputSpeed = 40000;
|
|
214
216
|
function roundUiCoordinate(value, name) {
|
|
215
217
|
if (!Number.isFinite(value) || value < 0) throw new Error(`HDC ${name} coordinate must be a non-negative finite number`);
|
|
216
218
|
return Math.round(value);
|
|
217
219
|
}
|
|
218
220
|
function roundUiInputSpeed(value, operation) {
|
|
219
|
-
if (!Number.isFinite(value) || value <
|
|
221
|
+
if (!Number.isFinite(value) || value < uiInputSpeedRange.min || value > uiInputSpeedRange.max) throw new Error(`HDC ${operation} speed must be a finite number between ${uiInputSpeedRange.min} and ${uiInputSpeedRange.max}`);
|
|
220
222
|
return Math.round(value);
|
|
221
223
|
}
|
|
222
224
|
function parseBundleInfo(output, bundleName) {
|
|
@@ -584,6 +586,18 @@ var __webpack_exports__ = {};
|
|
|
584
586
|
if (trimmedKeyName.includes('+')) throw new Error(`HarmonyOS keyboardPress does not support key combinations: ${JSON.stringify(keyName)}`);
|
|
585
587
|
return resolveSingleHarmonyKeyCodes(keyName);
|
|
586
588
|
}
|
|
589
|
+
const defaultSwipeDuration = 300;
|
|
590
|
+
const warnSwipe = (0, logger_namespaceObject.getDebug)('harmony:swipe', {
|
|
591
|
+
console: true
|
|
592
|
+
});
|
|
593
|
+
function resolveSwipeSpeed(start, end, duration = defaultSwipeDuration) {
|
|
594
|
+
if (!Number.isFinite(duration) || duration <= 0) throw new Error('Harmony swipe duration must be a positive finite number');
|
|
595
|
+
const distance = Math.hypot(end.x - start.x, end.y - start.y);
|
|
596
|
+
const requestedSpeed = 1000 * distance / duration;
|
|
597
|
+
const speed = Math.min(uiInputSpeedRange.max, Math.max(uiInputSpeedRange.min, requestedSpeed));
|
|
598
|
+
if (speed !== requestedSpeed) warnSwipe(`Harmony swipe speed ${requestedSpeed}px/s was clamped to ${speed}px/s; the requested ${duration}ms duration cannot be represented exactly`);
|
|
599
|
+
return Math.round(speed);
|
|
600
|
+
}
|
|
587
601
|
function device_define_property(obj, key, value) {
|
|
588
602
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
589
603
|
value: value,
|
|
@@ -1055,10 +1069,10 @@ var __webpack_exports__ = {};
|
|
|
1055
1069
|
},
|
|
1056
1070
|
touch: {
|
|
1057
1071
|
swipe: async (start, end, opts)=>{
|
|
1058
|
-
const
|
|
1072
|
+
const speed = resolveSwipeSpeed(start, end, opts?.duration);
|
|
1059
1073
|
const repeatCount = opts?.repeat ?? 1;
|
|
1060
1074
|
const hdc = await this.getHdc();
|
|
1061
|
-
for(let i = 0; i < repeatCount; i++)await hdc.swipe(start.x, start.y, end.x, end.y,
|
|
1075
|
+
for(let i = 0; i < repeatCount; i++)await hdc.swipe(start.x, start.y, end.x, end.y, speed);
|
|
1062
1076
|
}
|
|
1063
1077
|
},
|
|
1064
1078
|
scroll: {
|
package/dist/lib/cli.js
CHANGED
|
@@ -187,6 +187,10 @@ var __webpack_exports__ = {};
|
|
|
187
187
|
const img_namespaceObject = require("@midscene/shared/img");
|
|
188
188
|
const external_node_child_process_namespaceObject = require("node:child_process");
|
|
189
189
|
const external_node_util_namespaceObject = require("node:util");
|
|
190
|
+
const uiInputSpeedRange = {
|
|
191
|
+
min: 200,
|
|
192
|
+
max: 40000
|
|
193
|
+
};
|
|
190
194
|
function _define_property(obj, key, value) {
|
|
191
195
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
192
196
|
value: value,
|
|
@@ -206,14 +210,12 @@ var __webpack_exports__ = {};
|
|
|
206
210
|
]);
|
|
207
211
|
const numericKeyEventPattern = /^\d+$/;
|
|
208
212
|
const uiInputErrorPattern = /(?:(?:Invalid parameters|Missing parameter|Too many parameters)\.?|Please confirm that the coordinate values are correct\.?)/i;
|
|
209
|
-
const minUiInputSpeed = 200;
|
|
210
|
-
const maxUiInputSpeed = 40000;
|
|
211
213
|
function roundUiCoordinate(value, name) {
|
|
212
214
|
if (!Number.isFinite(value) || value < 0) throw new Error(`HDC ${name} coordinate must be a non-negative finite number`);
|
|
213
215
|
return Math.round(value);
|
|
214
216
|
}
|
|
215
217
|
function roundUiInputSpeed(value, operation) {
|
|
216
|
-
if (!Number.isFinite(value) || value <
|
|
218
|
+
if (!Number.isFinite(value) || value < uiInputSpeedRange.min || value > uiInputSpeedRange.max) throw new Error(`HDC ${operation} speed must be a finite number between ${uiInputSpeedRange.min} and ${uiInputSpeedRange.max}`);
|
|
217
219
|
return Math.round(value);
|
|
218
220
|
}
|
|
219
221
|
function parseBundleInfo(output, bundleName) {
|
|
@@ -581,6 +583,18 @@ var __webpack_exports__ = {};
|
|
|
581
583
|
if (trimmedKeyName.includes('+')) throw new Error(`HarmonyOS keyboardPress does not support key combinations: ${JSON.stringify(keyName)}`);
|
|
582
584
|
return resolveSingleHarmonyKeyCodes(keyName);
|
|
583
585
|
}
|
|
586
|
+
const defaultSwipeDuration = 300;
|
|
587
|
+
const warnSwipe = (0, logger_namespaceObject.getDebug)('harmony:swipe', {
|
|
588
|
+
console: true
|
|
589
|
+
});
|
|
590
|
+
function resolveSwipeSpeed(start, end, duration = defaultSwipeDuration) {
|
|
591
|
+
if (!Number.isFinite(duration) || duration <= 0) throw new Error('Harmony swipe duration must be a positive finite number');
|
|
592
|
+
const distance = Math.hypot(end.x - start.x, end.y - start.y);
|
|
593
|
+
const requestedSpeed = 1000 * distance / duration;
|
|
594
|
+
const speed = Math.min(uiInputSpeedRange.max, Math.max(uiInputSpeedRange.min, requestedSpeed));
|
|
595
|
+
if (speed !== requestedSpeed) warnSwipe(`Harmony swipe speed ${requestedSpeed}px/s was clamped to ${speed}px/s; the requested ${duration}ms duration cannot be represented exactly`);
|
|
596
|
+
return Math.round(speed);
|
|
597
|
+
}
|
|
584
598
|
function device_define_property(obj, key, value) {
|
|
585
599
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
586
600
|
value: value,
|
|
@@ -1052,10 +1066,10 @@ var __webpack_exports__ = {};
|
|
|
1052
1066
|
},
|
|
1053
1067
|
touch: {
|
|
1054
1068
|
swipe: async (start, end, opts)=>{
|
|
1055
|
-
const
|
|
1069
|
+
const speed = resolveSwipeSpeed(start, end, opts?.duration);
|
|
1056
1070
|
const repeatCount = opts?.repeat ?? 1;
|
|
1057
1071
|
const hdc = await this.getHdc();
|
|
1058
|
-
for(let i = 0; i < repeatCount; i++)await hdc.swipe(start.x, start.y, end.x, end.y,
|
|
1072
|
+
for(let i = 0; i < repeatCount; i++)await hdc.swipe(start.x, start.y, end.x, end.y, speed);
|
|
1059
1073
|
}
|
|
1060
1074
|
},
|
|
1061
1075
|
scroll: {
|
|
@@ -1335,7 +1349,7 @@ var __webpack_exports__ = {};
|
|
|
1335
1349
|
const tools = new HarmonyMidsceneTools();
|
|
1336
1350
|
(0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-harmony', {
|
|
1337
1351
|
stripPrefix: 'harmony_',
|
|
1338
|
-
version: "1.12.
|
|
1352
|
+
version: "1.12.9-beta-20260917120835.0",
|
|
1339
1353
|
extraCommands: (0, core_namespaceObject.createReportCliCommands)()
|
|
1340
1354
|
}).catch((e)=>{
|
|
1341
1355
|
process.exit((0, cli_namespaceObject.reportCLIError)(e));
|
package/dist/lib/index.js
CHANGED
|
@@ -176,6 +176,10 @@ var __webpack_exports__ = {};
|
|
|
176
176
|
const shared_utils_namespaceObject = require("@midscene/shared/utils");
|
|
177
177
|
const external_node_child_process_namespaceObject = require("node:child_process");
|
|
178
178
|
const external_node_util_namespaceObject = require("node:util");
|
|
179
|
+
const uiInputSpeedRange = {
|
|
180
|
+
min: 200,
|
|
181
|
+
max: 40000
|
|
182
|
+
};
|
|
179
183
|
function _define_property(obj, key, value) {
|
|
180
184
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
181
185
|
value: value,
|
|
@@ -195,14 +199,12 @@ var __webpack_exports__ = {};
|
|
|
195
199
|
]);
|
|
196
200
|
const numericKeyEventPattern = /^\d+$/;
|
|
197
201
|
const uiInputErrorPattern = /(?:(?:Invalid parameters|Missing parameter|Too many parameters)\.?|Please confirm that the coordinate values are correct\.?)/i;
|
|
198
|
-
const minUiInputSpeed = 200;
|
|
199
|
-
const maxUiInputSpeed = 40000;
|
|
200
202
|
function roundUiCoordinate(value, name) {
|
|
201
203
|
if (!Number.isFinite(value) || value < 0) throw new Error(`HDC ${name} coordinate must be a non-negative finite number`);
|
|
202
204
|
return Math.round(value);
|
|
203
205
|
}
|
|
204
206
|
function roundUiInputSpeed(value, operation) {
|
|
205
|
-
if (!Number.isFinite(value) || value <
|
|
207
|
+
if (!Number.isFinite(value) || value < uiInputSpeedRange.min || value > uiInputSpeedRange.max) throw new Error(`HDC ${operation} speed must be a finite number between ${uiInputSpeedRange.min} and ${uiInputSpeedRange.max}`);
|
|
206
208
|
return Math.round(value);
|
|
207
209
|
}
|
|
208
210
|
function parseBundleInfo(output, bundleName) {
|
|
@@ -570,6 +572,18 @@ var __webpack_exports__ = {};
|
|
|
570
572
|
if (trimmedKeyName.includes('+')) throw new Error(`HarmonyOS keyboardPress does not support key combinations: ${JSON.stringify(keyName)}`);
|
|
571
573
|
return resolveSingleHarmonyKeyCodes(keyName);
|
|
572
574
|
}
|
|
575
|
+
const defaultSwipeDuration = 300;
|
|
576
|
+
const warnSwipe = (0, logger_namespaceObject.getDebug)('harmony:swipe', {
|
|
577
|
+
console: true
|
|
578
|
+
});
|
|
579
|
+
function resolveSwipeSpeed(start, end, duration = defaultSwipeDuration) {
|
|
580
|
+
if (!Number.isFinite(duration) || duration <= 0) throw new Error('Harmony swipe duration must be a positive finite number');
|
|
581
|
+
const distance = Math.hypot(end.x - start.x, end.y - start.y);
|
|
582
|
+
const requestedSpeed = 1000 * distance / duration;
|
|
583
|
+
const speed = Math.min(uiInputSpeedRange.max, Math.max(uiInputSpeedRange.min, requestedSpeed));
|
|
584
|
+
if (speed !== requestedSpeed) warnSwipe(`Harmony swipe speed ${requestedSpeed}px/s was clamped to ${speed}px/s; the requested ${duration}ms duration cannot be represented exactly`);
|
|
585
|
+
return Math.round(speed);
|
|
586
|
+
}
|
|
573
587
|
function device_define_property(obj, key, value) {
|
|
574
588
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
575
589
|
value: value,
|
|
@@ -1041,10 +1055,10 @@ var __webpack_exports__ = {};
|
|
|
1041
1055
|
},
|
|
1042
1056
|
touch: {
|
|
1043
1057
|
swipe: async (start, end, opts)=>{
|
|
1044
|
-
const
|
|
1058
|
+
const speed = resolveSwipeSpeed(start, end, opts?.duration);
|
|
1045
1059
|
const repeatCount = opts?.repeat ?? 1;
|
|
1046
1060
|
const hdc = await this.getHdc();
|
|
1047
|
-
for(let i = 0; i < repeatCount; i++)await hdc.swipe(start.x, start.y, end.x, end.y,
|
|
1061
|
+
for(let i = 0; i < repeatCount; i++)await hdc.swipe(start.x, start.y, end.x, end.y, speed);
|
|
1048
1062
|
}
|
|
1049
1063
|
},
|
|
1050
1064
|
scroll: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/harmony",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.9-beta-20260917120835.0",
|
|
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/
|
|
51
|
-
"@midscene/
|
|
52
|
-
"@midscene/
|
|
50
|
+
"@midscene/playground": "1.12.9-beta-20260917120835.0",
|
|
51
|
+
"@midscene/core": "1.12.9-beta-20260917120835.0",
|
|
52
|
+
"@midscene/shared": "1.12.9-beta-20260917120835.0"
|
|
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.68c9d764.js"></script><script defer src="/static/js/index.
|
|
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.68c9d764.js"></script><script defer src="/static/js/index.2f2ca5c6.js"></script><link href="/static/css/index.67caac18.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkplayground=self.webpackChunkplayground||[]).push([["
|
|
2
|
-
//# sourceMappingURL=
|
|
1
|
+
"use strict";(self.webpackChunkplayground=self.webpackChunkplayground||[]).push([["749"],{17964(n,e,r){function u(){throw Error("proxy dependencies are unavailable in browser builds")}function o(){return u()}function a(){return u()}r.d(e,{loadFetchSocks:()=>a,loadUndici:()=>o})}}]);
|
|
2
|
+
//# sourceMappingURL=749.921ee4fd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static/js/async/749.921ee4fd.js","sources":["../../../../../../packages/core/src/ai-model/service-caller/proxy/proxy-deps.stub.ts"],"sourcesContent":["function unavailable(): never {\n throw new Error('proxy dependencies are unavailable in browser builds');\n}\n\nexport function loadUndici(): Promise<typeof import('undici')> {\n return unavailable();\n}\n\nexport function loadFetchSocks(): Promise<typeof import('fetch-socks')> {\n return unavailable();\n}\n"],"names":["unavailable","Error","loadUndici","loadFetchSocks"],"mappings":"uGAAA,SAASA,IACP,MAAM,AAAIC,MAAM,uDAClB,CAEO,SAASC,IACd,OAAOF,GACT,CAEO,SAASG,IACd,OAAOH,GACT,C"}
|