@midscene/harmony 1.10.13-beta-20260818094410.0 → 1.11.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 +23 -20
- package/dist/es/cli.mjs +24 -21
- package/dist/es/index.mjs +23 -20
- package/dist/lib/bin.js +23 -20
- package/dist/lib/cli.js +24 -21
- package/dist/lib/index.js +23 -20
- package/dist/types/index.d.ts +10 -4
- package/package.json +4 -4
- package/static/index.html +1 -1
- package/static/static/js/index.4b0c684c.js +814 -0
- package/static/static/js/index.4b0c684c.js.map +1 -0
- package/static/static/js/index.d98790a5.js +0 -822
- package/static/static/js/index.d98790a5.js.map +0 -1
- /package/static/static/js/{index.d98790a5.js.LICENSE.txt → index.4b0c684c.js.LICENSE.txt} +0 -0
package/dist/es/bin.mjs
CHANGED
|
@@ -533,27 +533,31 @@ class device_HarmonyDevice {
|
|
|
533
533
|
return this.connecting;
|
|
534
534
|
}
|
|
535
535
|
setAppNameMapping(mapping) {
|
|
536
|
-
this.appNameMapping = mapping;
|
|
536
|
+
this.appNameMapping = mergeAndNormalizeAppNameMapping({}, mapping);
|
|
537
537
|
}
|
|
538
|
-
|
|
538
|
+
resolveMappedAppTarget(appName) {
|
|
539
539
|
const normalizedAppName = normalizeForComparison(appName);
|
|
540
540
|
return this.appNameMapping[normalizedAppName];
|
|
541
541
|
}
|
|
542
|
+
resolveBundleNameForTerminate(target) {
|
|
543
|
+
const mappedTarget = this.resolveMappedAppTarget(target);
|
|
544
|
+
if (mappedTarget) return mappedTarget.split('/')[0];
|
|
545
|
+
const [bundleOrAppName] = target.split('/');
|
|
546
|
+
return (this.resolveMappedAppTarget(bundleOrAppName) ?? bundleOrAppName).split('/')[0];
|
|
547
|
+
}
|
|
542
548
|
async launch(uri) {
|
|
543
549
|
const hdc = await this.getHdc();
|
|
544
550
|
this.uri = uri;
|
|
545
551
|
try {
|
|
546
552
|
debugDevice(`Launching app: ${uri}`);
|
|
547
|
-
|
|
548
|
-
|
|
553
|
+
const target = uri.includes('://') ? uri : this.resolveMappedAppTarget(uri) ?? uri;
|
|
554
|
+
if (target.includes('://')) {
|
|
555
|
+
const sanitizedUri = target.replace(/[`$\\;"'|&<>(){}]/g, '');
|
|
549
556
|
await hdc.shell(`aa start -U ${sanitizedUri}`);
|
|
550
|
-
} else if (
|
|
551
|
-
const [bundleName, abilityName] =
|
|
557
|
+
} else if (target.includes('/')) {
|
|
558
|
+
const [bundleName, abilityName] = target.split('/');
|
|
552
559
|
await hdc.startAbility(bundleName, abilityName);
|
|
553
|
-
} else
|
|
554
|
-
const bundleName = this.resolvePackageName(uri) ?? uri;
|
|
555
|
-
await hdc.launchBundle(bundleName);
|
|
556
|
-
}
|
|
560
|
+
} else await hdc.launchBundle(target);
|
|
557
561
|
debugDevice(`Successfully launched: ${uri}`);
|
|
558
562
|
} catch (error) {
|
|
559
563
|
debugDevice(`Error launching ${uri}: ${error}`);
|
|
@@ -564,16 +568,15 @@ class device_HarmonyDevice {
|
|
|
564
568
|
return this;
|
|
565
569
|
}
|
|
566
570
|
async terminate(uri) {
|
|
567
|
-
const
|
|
568
|
-
const resolved = this.resolvePackageName(bundlePart) ?? bundlePart;
|
|
571
|
+
const bundleName = this.resolveBundleNameForTerminate(uri);
|
|
569
572
|
const hdc = await this.getHdc();
|
|
570
573
|
try {
|
|
571
|
-
debugDevice(`Terminating app: ${
|
|
572
|
-
await hdc.forceStop(
|
|
573
|
-
debugDevice(`Successfully terminated: ${
|
|
574
|
+
debugDevice(`Terminating app: ${bundleName}`);
|
|
575
|
+
await hdc.forceStop(bundleName);
|
|
576
|
+
debugDevice(`Successfully terminated: ${bundleName}`);
|
|
574
577
|
} catch (error) {
|
|
575
|
-
debugDevice(`Error terminating ${
|
|
576
|
-
throw new Error(`Failed to terminate ${
|
|
578
|
+
debugDevice(`Error terminating ${bundleName}: ${error}`);
|
|
579
|
+
throw new Error(`Failed to terminate ${bundleName}: ${error.message}`, {
|
|
577
580
|
cause: error
|
|
578
581
|
});
|
|
579
582
|
}
|
|
@@ -1050,9 +1053,9 @@ class HarmonyAgent extends Agent {
|
|
|
1050
1053
|
return (...args)=>action(args[0]);
|
|
1051
1054
|
}
|
|
1052
1055
|
constructor(device, opts){
|
|
1053
|
-
super(device, opts), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0)
|
|
1054
|
-
|
|
1055
|
-
device.setAppNameMapping(
|
|
1056
|
+
super(device, opts), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0);
|
|
1057
|
+
const appNameMapping = mergeAndNormalizeAppNameMapping(defaultAppNameMapping, opts?.appNameMapping);
|
|
1058
|
+
device.setAppNameMapping(appNameMapping);
|
|
1056
1059
|
this.back = this.createActionWrapper('HarmonyBackButton');
|
|
1057
1060
|
this.home = this.createActionWrapper('HarmonyHomeButton');
|
|
1058
1061
|
this.recentApps = this.createActionWrapper('HarmonyRecentAppsButton');
|
package/dist/es/cli.mjs
CHANGED
|
@@ -531,27 +531,31 @@ class HarmonyDevice {
|
|
|
531
531
|
return this.connecting;
|
|
532
532
|
}
|
|
533
533
|
setAppNameMapping(mapping) {
|
|
534
|
-
this.appNameMapping = mapping;
|
|
534
|
+
this.appNameMapping = mergeAndNormalizeAppNameMapping({}, mapping);
|
|
535
535
|
}
|
|
536
|
-
|
|
536
|
+
resolveMappedAppTarget(appName) {
|
|
537
537
|
const normalizedAppName = normalizeForComparison(appName);
|
|
538
538
|
return this.appNameMapping[normalizedAppName];
|
|
539
539
|
}
|
|
540
|
+
resolveBundleNameForTerminate(target) {
|
|
541
|
+
const mappedTarget = this.resolveMappedAppTarget(target);
|
|
542
|
+
if (mappedTarget) return mappedTarget.split('/')[0];
|
|
543
|
+
const [bundleOrAppName] = target.split('/');
|
|
544
|
+
return (this.resolveMappedAppTarget(bundleOrAppName) ?? bundleOrAppName).split('/')[0];
|
|
545
|
+
}
|
|
540
546
|
async launch(uri) {
|
|
541
547
|
const hdc = await this.getHdc();
|
|
542
548
|
this.uri = uri;
|
|
543
549
|
try {
|
|
544
550
|
debugDevice(`Launching app: ${uri}`);
|
|
545
|
-
|
|
546
|
-
|
|
551
|
+
const target = uri.includes('://') ? uri : this.resolveMappedAppTarget(uri) ?? uri;
|
|
552
|
+
if (target.includes('://')) {
|
|
553
|
+
const sanitizedUri = target.replace(/[`$\\;"'|&<>(){}]/g, '');
|
|
547
554
|
await hdc.shell(`aa start -U ${sanitizedUri}`);
|
|
548
|
-
} else if (
|
|
549
|
-
const [bundleName, abilityName] =
|
|
555
|
+
} else if (target.includes('/')) {
|
|
556
|
+
const [bundleName, abilityName] = target.split('/');
|
|
550
557
|
await hdc.startAbility(bundleName, abilityName);
|
|
551
|
-
} else
|
|
552
|
-
const bundleName = this.resolvePackageName(uri) ?? uri;
|
|
553
|
-
await hdc.launchBundle(bundleName);
|
|
554
|
-
}
|
|
558
|
+
} else await hdc.launchBundle(target);
|
|
555
559
|
debugDevice(`Successfully launched: ${uri}`);
|
|
556
560
|
} catch (error) {
|
|
557
561
|
debugDevice(`Error launching ${uri}: ${error}`);
|
|
@@ -562,16 +566,15 @@ class HarmonyDevice {
|
|
|
562
566
|
return this;
|
|
563
567
|
}
|
|
564
568
|
async terminate(uri) {
|
|
565
|
-
const
|
|
566
|
-
const resolved = this.resolvePackageName(bundlePart) ?? bundlePart;
|
|
569
|
+
const bundleName = this.resolveBundleNameForTerminate(uri);
|
|
567
570
|
const hdc = await this.getHdc();
|
|
568
571
|
try {
|
|
569
|
-
debugDevice(`Terminating app: ${
|
|
570
|
-
await hdc.forceStop(
|
|
571
|
-
debugDevice(`Successfully terminated: ${
|
|
572
|
+
debugDevice(`Terminating app: ${bundleName}`);
|
|
573
|
+
await hdc.forceStop(bundleName);
|
|
574
|
+
debugDevice(`Successfully terminated: ${bundleName}`);
|
|
572
575
|
} catch (error) {
|
|
573
|
-
debugDevice(`Error terminating ${
|
|
574
|
-
throw new Error(`Failed to terminate ${
|
|
576
|
+
debugDevice(`Error terminating ${bundleName}: ${error}`);
|
|
577
|
+
throw new Error(`Failed to terminate ${bundleName}: ${error.message}`, {
|
|
575
578
|
cause: error
|
|
576
579
|
});
|
|
577
580
|
}
|
|
@@ -1048,9 +1051,9 @@ class HarmonyAgent extends Agent {
|
|
|
1048
1051
|
return (...args)=>action(args[0]);
|
|
1049
1052
|
}
|
|
1050
1053
|
constructor(device, opts){
|
|
1051
|
-
super(device, opts), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0)
|
|
1052
|
-
|
|
1053
|
-
device.setAppNameMapping(
|
|
1054
|
+
super(device, opts), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0);
|
|
1055
|
+
const appNameMapping = mergeAndNormalizeAppNameMapping(defaultAppNameMapping, opts?.appNameMapping);
|
|
1056
|
+
device.setAppNameMapping(appNameMapping);
|
|
1054
1057
|
this.back = this.createActionWrapper('HarmonyBackButton');
|
|
1055
1058
|
this.home = this.createActionWrapper('HarmonyHomeButton');
|
|
1056
1059
|
this.recentApps = this.createActionWrapper('HarmonyRecentAppsButton');
|
|
@@ -1178,7 +1181,7 @@ class HarmonyMidsceneTools extends BaseMidsceneTools {
|
|
|
1178
1181
|
const tools = new HarmonyMidsceneTools();
|
|
1179
1182
|
runToolsCLI(tools, 'midscene-harmony', {
|
|
1180
1183
|
stripPrefix: 'harmony_',
|
|
1181
|
-
version: "1.
|
|
1184
|
+
version: "1.11.0",
|
|
1182
1185
|
extraCommands: createReportCliCommands()
|
|
1183
1186
|
}).catch((e)=>{
|
|
1184
1187
|
process.exit(reportCLIError(e));
|
package/dist/es/index.mjs
CHANGED
|
@@ -502,27 +502,31 @@ class HarmonyDevice {
|
|
|
502
502
|
return this.connecting;
|
|
503
503
|
}
|
|
504
504
|
setAppNameMapping(mapping) {
|
|
505
|
-
this.appNameMapping = mapping;
|
|
505
|
+
this.appNameMapping = mergeAndNormalizeAppNameMapping({}, mapping);
|
|
506
506
|
}
|
|
507
|
-
|
|
507
|
+
resolveMappedAppTarget(appName) {
|
|
508
508
|
const normalizedAppName = normalizeForComparison(appName);
|
|
509
509
|
return this.appNameMapping[normalizedAppName];
|
|
510
510
|
}
|
|
511
|
+
resolveBundleNameForTerminate(target) {
|
|
512
|
+
const mappedTarget = this.resolveMappedAppTarget(target);
|
|
513
|
+
if (mappedTarget) return mappedTarget.split('/')[0];
|
|
514
|
+
const [bundleOrAppName] = target.split('/');
|
|
515
|
+
return (this.resolveMappedAppTarget(bundleOrAppName) ?? bundleOrAppName).split('/')[0];
|
|
516
|
+
}
|
|
511
517
|
async launch(uri) {
|
|
512
518
|
const hdc = await this.getHdc();
|
|
513
519
|
this.uri = uri;
|
|
514
520
|
try {
|
|
515
521
|
debugDevice(`Launching app: ${uri}`);
|
|
516
|
-
|
|
517
|
-
|
|
522
|
+
const target = uri.includes('://') ? uri : this.resolveMappedAppTarget(uri) ?? uri;
|
|
523
|
+
if (target.includes('://')) {
|
|
524
|
+
const sanitizedUri = target.replace(/[`$\\;"'|&<>(){}]/g, '');
|
|
518
525
|
await hdc.shell(`aa start -U ${sanitizedUri}`);
|
|
519
|
-
} else if (
|
|
520
|
-
const [bundleName, abilityName] =
|
|
526
|
+
} else if (target.includes('/')) {
|
|
527
|
+
const [bundleName, abilityName] = target.split('/');
|
|
521
528
|
await hdc.startAbility(bundleName, abilityName);
|
|
522
|
-
} else
|
|
523
|
-
const bundleName = this.resolvePackageName(uri) ?? uri;
|
|
524
|
-
await hdc.launchBundle(bundleName);
|
|
525
|
-
}
|
|
529
|
+
} else await hdc.launchBundle(target);
|
|
526
530
|
debugDevice(`Successfully launched: ${uri}`);
|
|
527
531
|
} catch (error) {
|
|
528
532
|
debugDevice(`Error launching ${uri}: ${error}`);
|
|
@@ -533,16 +537,15 @@ class HarmonyDevice {
|
|
|
533
537
|
return this;
|
|
534
538
|
}
|
|
535
539
|
async terminate(uri) {
|
|
536
|
-
const
|
|
537
|
-
const resolved = this.resolvePackageName(bundlePart) ?? bundlePart;
|
|
540
|
+
const bundleName = this.resolveBundleNameForTerminate(uri);
|
|
538
541
|
const hdc = await this.getHdc();
|
|
539
542
|
try {
|
|
540
|
-
debugDevice(`Terminating app: ${
|
|
541
|
-
await hdc.forceStop(
|
|
542
|
-
debugDevice(`Successfully terminated: ${
|
|
543
|
+
debugDevice(`Terminating app: ${bundleName}`);
|
|
544
|
+
await hdc.forceStop(bundleName);
|
|
545
|
+
debugDevice(`Successfully terminated: ${bundleName}`);
|
|
543
546
|
} catch (error) {
|
|
544
|
-
debugDevice(`Error terminating ${
|
|
545
|
-
throw new Error(`Failed to terminate ${
|
|
547
|
+
debugDevice(`Error terminating ${bundleName}: ${error}`);
|
|
548
|
+
throw new Error(`Failed to terminate ${bundleName}: ${error.message}`, {
|
|
546
549
|
cause: error
|
|
547
550
|
});
|
|
548
551
|
}
|
|
@@ -1053,9 +1056,9 @@ class HarmonyAgent extends Agent {
|
|
|
1053
1056
|
return (...args)=>action(args[0]);
|
|
1054
1057
|
}
|
|
1055
1058
|
constructor(device, opts){
|
|
1056
|
-
super(device, opts), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0)
|
|
1057
|
-
|
|
1058
|
-
device.setAppNameMapping(
|
|
1059
|
+
super(device, opts), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0);
|
|
1060
|
+
const appNameMapping = mergeAndNormalizeAppNameMapping(defaultAppNameMapping, opts?.appNameMapping);
|
|
1061
|
+
device.setAppNameMapping(appNameMapping);
|
|
1059
1062
|
this.back = this.createActionWrapper('HarmonyBackButton');
|
|
1060
1063
|
this.home = this.createActionWrapper('HarmonyHomeButton');
|
|
1061
1064
|
this.recentApps = this.createActionWrapper('HarmonyRecentAppsButton');
|
package/dist/lib/bin.js
CHANGED
|
@@ -559,27 +559,31 @@ class device_HarmonyDevice {
|
|
|
559
559
|
return this.connecting;
|
|
560
560
|
}
|
|
561
561
|
setAppNameMapping(mapping) {
|
|
562
|
-
this.appNameMapping = mapping;
|
|
562
|
+
this.appNameMapping = (0, utils_namespaceObject.mergeAndNormalizeAppNameMapping)({}, mapping);
|
|
563
563
|
}
|
|
564
|
-
|
|
564
|
+
resolveMappedAppTarget(appName) {
|
|
565
565
|
const normalizedAppName = (0, utils_namespaceObject.normalizeForComparison)(appName);
|
|
566
566
|
return this.appNameMapping[normalizedAppName];
|
|
567
567
|
}
|
|
568
|
+
resolveBundleNameForTerminate(target) {
|
|
569
|
+
const mappedTarget = this.resolveMappedAppTarget(target);
|
|
570
|
+
if (mappedTarget) return mappedTarget.split('/')[0];
|
|
571
|
+
const [bundleOrAppName] = target.split('/');
|
|
572
|
+
return (this.resolveMappedAppTarget(bundleOrAppName) ?? bundleOrAppName).split('/')[0];
|
|
573
|
+
}
|
|
568
574
|
async launch(uri) {
|
|
569
575
|
const hdc = await this.getHdc();
|
|
570
576
|
this.uri = uri;
|
|
571
577
|
try {
|
|
572
578
|
debugDevice(`Launching app: ${uri}`);
|
|
573
|
-
|
|
574
|
-
|
|
579
|
+
const target = uri.includes('://') ? uri : this.resolveMappedAppTarget(uri) ?? uri;
|
|
580
|
+
if (target.includes('://')) {
|
|
581
|
+
const sanitizedUri = target.replace(/[`$\\;"'|&<>(){}]/g, '');
|
|
575
582
|
await hdc.shell(`aa start -U ${sanitizedUri}`);
|
|
576
|
-
} else if (
|
|
577
|
-
const [bundleName, abilityName] =
|
|
583
|
+
} else if (target.includes('/')) {
|
|
584
|
+
const [bundleName, abilityName] = target.split('/');
|
|
578
585
|
await hdc.startAbility(bundleName, abilityName);
|
|
579
|
-
} else
|
|
580
|
-
const bundleName = this.resolvePackageName(uri) ?? uri;
|
|
581
|
-
await hdc.launchBundle(bundleName);
|
|
582
|
-
}
|
|
586
|
+
} else await hdc.launchBundle(target);
|
|
583
587
|
debugDevice(`Successfully launched: ${uri}`);
|
|
584
588
|
} catch (error) {
|
|
585
589
|
debugDevice(`Error launching ${uri}: ${error}`);
|
|
@@ -590,16 +594,15 @@ class device_HarmonyDevice {
|
|
|
590
594
|
return this;
|
|
591
595
|
}
|
|
592
596
|
async terminate(uri) {
|
|
593
|
-
const
|
|
594
|
-
const resolved = this.resolvePackageName(bundlePart) ?? bundlePart;
|
|
597
|
+
const bundleName = this.resolveBundleNameForTerminate(uri);
|
|
595
598
|
const hdc = await this.getHdc();
|
|
596
599
|
try {
|
|
597
|
-
debugDevice(`Terminating app: ${
|
|
598
|
-
await hdc.forceStop(
|
|
599
|
-
debugDevice(`Successfully terminated: ${
|
|
600
|
+
debugDevice(`Terminating app: ${bundleName}`);
|
|
601
|
+
await hdc.forceStop(bundleName);
|
|
602
|
+
debugDevice(`Successfully terminated: ${bundleName}`);
|
|
600
603
|
} catch (error) {
|
|
601
|
-
debugDevice(`Error terminating ${
|
|
602
|
-
throw new Error(`Failed to terminate ${
|
|
604
|
+
debugDevice(`Error terminating ${bundleName}: ${error}`);
|
|
605
|
+
throw new Error(`Failed to terminate ${bundleName}: ${error.message}`, {
|
|
603
606
|
cause: error
|
|
604
607
|
});
|
|
605
608
|
}
|
|
@@ -1076,9 +1079,9 @@ class HarmonyAgent extends agent_namespaceObject.Agent {
|
|
|
1076
1079
|
return (...args)=>action(args[0]);
|
|
1077
1080
|
}
|
|
1078
1081
|
constructor(device, opts){
|
|
1079
|
-
super(device, opts), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0)
|
|
1080
|
-
|
|
1081
|
-
device.setAppNameMapping(
|
|
1082
|
+
super(device, opts), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0);
|
|
1083
|
+
const appNameMapping = (0, utils_namespaceObject.mergeAndNormalizeAppNameMapping)(defaultAppNameMapping, opts?.appNameMapping);
|
|
1084
|
+
device.setAppNameMapping(appNameMapping);
|
|
1082
1085
|
this.back = this.createActionWrapper('HarmonyBackButton');
|
|
1083
1086
|
this.home = this.createActionWrapper('HarmonyHomeButton');
|
|
1084
1087
|
this.recentApps = this.createActionWrapper('HarmonyRecentAppsButton');
|
package/dist/lib/cli.js
CHANGED
|
@@ -556,27 +556,31 @@ class HarmonyDevice {
|
|
|
556
556
|
return this.connecting;
|
|
557
557
|
}
|
|
558
558
|
setAppNameMapping(mapping) {
|
|
559
|
-
this.appNameMapping = mapping;
|
|
559
|
+
this.appNameMapping = (0, utils_namespaceObject.mergeAndNormalizeAppNameMapping)({}, mapping);
|
|
560
560
|
}
|
|
561
|
-
|
|
561
|
+
resolveMappedAppTarget(appName) {
|
|
562
562
|
const normalizedAppName = (0, utils_namespaceObject.normalizeForComparison)(appName);
|
|
563
563
|
return this.appNameMapping[normalizedAppName];
|
|
564
564
|
}
|
|
565
|
+
resolveBundleNameForTerminate(target) {
|
|
566
|
+
const mappedTarget = this.resolveMappedAppTarget(target);
|
|
567
|
+
if (mappedTarget) return mappedTarget.split('/')[0];
|
|
568
|
+
const [bundleOrAppName] = target.split('/');
|
|
569
|
+
return (this.resolveMappedAppTarget(bundleOrAppName) ?? bundleOrAppName).split('/')[0];
|
|
570
|
+
}
|
|
565
571
|
async launch(uri) {
|
|
566
572
|
const hdc = await this.getHdc();
|
|
567
573
|
this.uri = uri;
|
|
568
574
|
try {
|
|
569
575
|
debugDevice(`Launching app: ${uri}`);
|
|
570
|
-
|
|
571
|
-
|
|
576
|
+
const target = uri.includes('://') ? uri : this.resolveMappedAppTarget(uri) ?? uri;
|
|
577
|
+
if (target.includes('://')) {
|
|
578
|
+
const sanitizedUri = target.replace(/[`$\\;"'|&<>(){}]/g, '');
|
|
572
579
|
await hdc.shell(`aa start -U ${sanitizedUri}`);
|
|
573
|
-
} else if (
|
|
574
|
-
const [bundleName, abilityName] =
|
|
580
|
+
} else if (target.includes('/')) {
|
|
581
|
+
const [bundleName, abilityName] = target.split('/');
|
|
575
582
|
await hdc.startAbility(bundleName, abilityName);
|
|
576
|
-
} else
|
|
577
|
-
const bundleName = this.resolvePackageName(uri) ?? uri;
|
|
578
|
-
await hdc.launchBundle(bundleName);
|
|
579
|
-
}
|
|
583
|
+
} else await hdc.launchBundle(target);
|
|
580
584
|
debugDevice(`Successfully launched: ${uri}`);
|
|
581
585
|
} catch (error) {
|
|
582
586
|
debugDevice(`Error launching ${uri}: ${error}`);
|
|
@@ -587,16 +591,15 @@ class HarmonyDevice {
|
|
|
587
591
|
return this;
|
|
588
592
|
}
|
|
589
593
|
async terminate(uri) {
|
|
590
|
-
const
|
|
591
|
-
const resolved = this.resolvePackageName(bundlePart) ?? bundlePart;
|
|
594
|
+
const bundleName = this.resolveBundleNameForTerminate(uri);
|
|
592
595
|
const hdc = await this.getHdc();
|
|
593
596
|
try {
|
|
594
|
-
debugDevice(`Terminating app: ${
|
|
595
|
-
await hdc.forceStop(
|
|
596
|
-
debugDevice(`Successfully terminated: ${
|
|
597
|
+
debugDevice(`Terminating app: ${bundleName}`);
|
|
598
|
+
await hdc.forceStop(bundleName);
|
|
599
|
+
debugDevice(`Successfully terminated: ${bundleName}`);
|
|
597
600
|
} catch (error) {
|
|
598
|
-
debugDevice(`Error terminating ${
|
|
599
|
-
throw new Error(`Failed to terminate ${
|
|
601
|
+
debugDevice(`Error terminating ${bundleName}: ${error}`);
|
|
602
|
+
throw new Error(`Failed to terminate ${bundleName}: ${error.message}`, {
|
|
600
603
|
cause: error
|
|
601
604
|
});
|
|
602
605
|
}
|
|
@@ -1073,9 +1076,9 @@ class HarmonyAgent extends agent_namespaceObject.Agent {
|
|
|
1073
1076
|
return (...args)=>action(args[0]);
|
|
1074
1077
|
}
|
|
1075
1078
|
constructor(device, opts){
|
|
1076
|
-
super(device, opts), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0)
|
|
1077
|
-
|
|
1078
|
-
device.setAppNameMapping(
|
|
1079
|
+
super(device, opts), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0);
|
|
1080
|
+
const appNameMapping = (0, utils_namespaceObject.mergeAndNormalizeAppNameMapping)(defaultAppNameMapping, opts?.appNameMapping);
|
|
1081
|
+
device.setAppNameMapping(appNameMapping);
|
|
1079
1082
|
this.back = this.createActionWrapper('HarmonyBackButton');
|
|
1080
1083
|
this.home = this.createActionWrapper('HarmonyHomeButton');
|
|
1081
1084
|
this.recentApps = this.createActionWrapper('HarmonyRecentAppsButton');
|
|
@@ -1203,7 +1206,7 @@ class HarmonyMidsceneTools extends base_tools_namespaceObject.BaseMidsceneTools
|
|
|
1203
1206
|
const tools = new HarmonyMidsceneTools();
|
|
1204
1207
|
(0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-harmony', {
|
|
1205
1208
|
stripPrefix: 'harmony_',
|
|
1206
|
-
version: "1.
|
|
1209
|
+
version: "1.11.0",
|
|
1207
1210
|
extraCommands: (0, core_namespaceObject.createReportCliCommands)()
|
|
1208
1211
|
}).catch((e)=>{
|
|
1209
1212
|
process.exit((0, cli_namespaceObject.reportCLIError)(e));
|
package/dist/lib/index.js
CHANGED
|
@@ -538,27 +538,31 @@ class HarmonyDevice {
|
|
|
538
538
|
return this.connecting;
|
|
539
539
|
}
|
|
540
540
|
setAppNameMapping(mapping) {
|
|
541
|
-
this.appNameMapping = mapping;
|
|
541
|
+
this.appNameMapping = (0, shared_utils_namespaceObject.mergeAndNormalizeAppNameMapping)({}, mapping);
|
|
542
542
|
}
|
|
543
|
-
|
|
543
|
+
resolveMappedAppTarget(appName) {
|
|
544
544
|
const normalizedAppName = (0, shared_utils_namespaceObject.normalizeForComparison)(appName);
|
|
545
545
|
return this.appNameMapping[normalizedAppName];
|
|
546
546
|
}
|
|
547
|
+
resolveBundleNameForTerminate(target) {
|
|
548
|
+
const mappedTarget = this.resolveMappedAppTarget(target);
|
|
549
|
+
if (mappedTarget) return mappedTarget.split('/')[0];
|
|
550
|
+
const [bundleOrAppName] = target.split('/');
|
|
551
|
+
return (this.resolveMappedAppTarget(bundleOrAppName) ?? bundleOrAppName).split('/')[0];
|
|
552
|
+
}
|
|
547
553
|
async launch(uri) {
|
|
548
554
|
const hdc = await this.getHdc();
|
|
549
555
|
this.uri = uri;
|
|
550
556
|
try {
|
|
551
557
|
debugDevice(`Launching app: ${uri}`);
|
|
552
|
-
|
|
553
|
-
|
|
558
|
+
const target = uri.includes('://') ? uri : this.resolveMappedAppTarget(uri) ?? uri;
|
|
559
|
+
if (target.includes('://')) {
|
|
560
|
+
const sanitizedUri = target.replace(/[`$\\;"'|&<>(){}]/g, '');
|
|
554
561
|
await hdc.shell(`aa start -U ${sanitizedUri}`);
|
|
555
|
-
} else if (
|
|
556
|
-
const [bundleName, abilityName] =
|
|
562
|
+
} else if (target.includes('/')) {
|
|
563
|
+
const [bundleName, abilityName] = target.split('/');
|
|
557
564
|
await hdc.startAbility(bundleName, abilityName);
|
|
558
|
-
} else
|
|
559
|
-
const bundleName = this.resolvePackageName(uri) ?? uri;
|
|
560
|
-
await hdc.launchBundle(bundleName);
|
|
561
|
-
}
|
|
565
|
+
} else await hdc.launchBundle(target);
|
|
562
566
|
debugDevice(`Successfully launched: ${uri}`);
|
|
563
567
|
} catch (error) {
|
|
564
568
|
debugDevice(`Error launching ${uri}: ${error}`);
|
|
@@ -569,16 +573,15 @@ class HarmonyDevice {
|
|
|
569
573
|
return this;
|
|
570
574
|
}
|
|
571
575
|
async terminate(uri) {
|
|
572
|
-
const
|
|
573
|
-
const resolved = this.resolvePackageName(bundlePart) ?? bundlePart;
|
|
576
|
+
const bundleName = this.resolveBundleNameForTerminate(uri);
|
|
574
577
|
const hdc = await this.getHdc();
|
|
575
578
|
try {
|
|
576
|
-
debugDevice(`Terminating app: ${
|
|
577
|
-
await hdc.forceStop(
|
|
578
|
-
debugDevice(`Successfully terminated: ${
|
|
579
|
+
debugDevice(`Terminating app: ${bundleName}`);
|
|
580
|
+
await hdc.forceStop(bundleName);
|
|
581
|
+
debugDevice(`Successfully terminated: ${bundleName}`);
|
|
579
582
|
} catch (error) {
|
|
580
|
-
debugDevice(`Error terminating ${
|
|
581
|
-
throw new Error(`Failed to terminate ${
|
|
583
|
+
debugDevice(`Error terminating ${bundleName}: ${error}`);
|
|
584
|
+
throw new Error(`Failed to terminate ${bundleName}: ${error.message}`, {
|
|
582
585
|
cause: error
|
|
583
586
|
});
|
|
584
587
|
}
|
|
@@ -1090,9 +1093,9 @@ class HarmonyAgent extends agent_namespaceObject.Agent {
|
|
|
1090
1093
|
return (...args)=>action(args[0]);
|
|
1091
1094
|
}
|
|
1092
1095
|
constructor(device, opts){
|
|
1093
|
-
super(device, opts), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0)
|
|
1094
|
-
|
|
1095
|
-
device.setAppNameMapping(
|
|
1096
|
+
super(device, opts), agent_define_property(this, "back", void 0), agent_define_property(this, "home", void 0), agent_define_property(this, "recentApps", void 0);
|
|
1097
|
+
const appNameMapping = (0, shared_utils_namespaceObject.mergeAndNormalizeAppNameMapping)(defaultAppNameMapping, opts?.appNameMapping);
|
|
1098
|
+
device.setAppNameMapping(appNameMapping);
|
|
1096
1099
|
this.back = this.createActionWrapper('HarmonyBackButton');
|
|
1097
1100
|
this.home = this.createActionWrapper('HarmonyHomeButton');
|
|
1098
1101
|
this.recentApps = this.createActionWrapper('HarmonyRecentAppsButton');
|
package/dist/types/index.d.ts
CHANGED
|
@@ -34,7 +34,6 @@ export declare class HarmonyAgent extends Agent<HarmonyDevice> {
|
|
|
34
34
|
back: WrappedAction<DeviceActionHarmonyBackButton>;
|
|
35
35
|
home: WrappedAction<DeviceActionHarmonyHomeButton>;
|
|
36
36
|
recentApps: WrappedAction<DeviceActionHarmonyRecentAppsButton>;
|
|
37
|
-
private appNameMapping;
|
|
38
37
|
constructor(device: HarmonyDevice, opts?: HarmonyAgentOpt);
|
|
39
38
|
launch(uri: string): Promise<void>;
|
|
40
39
|
terminate(uri: string): Promise<void>;
|
|
@@ -44,8 +43,9 @@ export declare class HarmonyAgent extends Agent<HarmonyDevice> {
|
|
|
44
43
|
|
|
45
44
|
export declare type HarmonyAgentOpt = AgentOpt & {
|
|
46
45
|
/**
|
|
47
|
-
* Custom mapping of app names to bundle names
|
|
48
|
-
*
|
|
46
|
+
* Custom mapping of app names to bundle names or explicit bundle/ability
|
|
47
|
+
* targets. Bundle-only targets use bundle metadata to resolve their declared
|
|
48
|
+
* launch ability. User-provided mappings take precedence over defaults.
|
|
49
49
|
*/
|
|
50
50
|
appNameMapping?: Record<string, string>;
|
|
51
51
|
};
|
|
@@ -70,8 +70,14 @@ export declare class HarmonyDevice implements AbstractInterface {
|
|
|
70
70
|
describe(): string;
|
|
71
71
|
connect(): Promise<HdcClient>;
|
|
72
72
|
getHdc(): Promise<HdcClient>;
|
|
73
|
+
/**
|
|
74
|
+
* Set app-name aliases used by launch and terminate.
|
|
75
|
+
* Keys are normalized here so callers do not need to know the internal
|
|
76
|
+
* comparison format.
|
|
77
|
+
*/
|
|
73
78
|
setAppNameMapping(mapping: Record<string, string>): void;
|
|
74
|
-
private
|
|
79
|
+
private resolveMappedAppTarget;
|
|
80
|
+
private resolveBundleNameForTerminate;
|
|
75
81
|
launch(uri: string): Promise<HarmonyDevice>;
|
|
76
82
|
/**
|
|
77
83
|
* Terminate (force-stop) a HarmonyOS app by bundle name.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/harmony",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/midscene.git",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@inquirer/prompts": "^7.8.6",
|
|
43
43
|
"open": "10.1.0",
|
|
44
|
-
"@midscene/
|
|
45
|
-
"@midscene/shared": "1.
|
|
46
|
-
"@midscene/
|
|
44
|
+
"@midscene/core": "1.11.0",
|
|
45
|
+
"@midscene/shared": "1.11.0",
|
|
46
|
+
"@midscene/playground": "1.11.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@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/226.e0976a0a.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/226.e0976a0a.js"></script><script defer src="/static/js/index.4b0c684c.js"></script><link href="/static/css/index.1e8e86da.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
|