@react-native-oh/react-native-harmony-cli 0.77.18 → 0.77.33-1
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/autolinking/Autolinking.js +1 -1
- package/dist/codegen/generators/UberGeneratorV1.js +9 -2
- package/dist/codegen/generators/UberGeneratorV2.js +8 -1
- package/dist/commands/clean-harmony.js +17 -7
- package/dist/commands/codegen-harmony.js +16 -5
- package/dist/commands/init.js +0 -0
- package/dist/commands/run-harmony.js +49 -27
- package/dist/init/templates/harmony/entry/src/main/module.json5 +7 -0
- package/dist/package-verifier/verify-package.js +1 -1
- package/dist/simulator/LaunchSimulator.js +318 -0
- package/dist/simulator/index.js +23 -0
- package/harmony/rnoh-hvigor-plugin-0.77.33.tgz +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/02febc14 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0429e5b7 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/05339e68 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/070be2fe +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/07851ff1 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/12e10c06 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/12e1d696 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/14950087 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/15e87372 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/19e6ecbe +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1aac0ac4 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1b8db102 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1c181646 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/203e747c +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/21ba4c08 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/259939e5 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/288ba98c +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2a45461c +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2d773091 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2eda89fc +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2f584eca +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/35b495ca +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/36478aed +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3844e772 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3ee777f4 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/471ac436 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4a91abcc +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4d1a5094 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4d3ef38f +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4daf5855 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4ef0389f +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4f72da28 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/59d3e924 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5a8edfaa +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5d28a510 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/61a6391d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/65921a14 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6624e7fc +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/66d28144 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6aceb8d2 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/702393d3 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/714f932b +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/73f9d4a6 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/78d3adae +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7b6564b8 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7c7c3e6e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7cbc9b6a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7dd579e0 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7e0b7d06 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7e153eef +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7ee84fd7 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7f5146a4 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/844e633a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8a1af22c +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/90a1680d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a15fb79a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ac288a8a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ad7a66b4 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/aee8805e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b0487ec8 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b10e16d2 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b32d42ac +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b7d8f35c +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b96748af +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/bedb2fea +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c01ad640 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c0472cf5 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c102ed0f +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c1a91819 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c243857a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c407792f +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c4459bee +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c72a4dcd +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c83537a9 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c88f7498 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c8d04070 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cc44d6f1 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d4d913f6 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/da97f202 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/dc965522 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/dff6f700 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e507c001 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e52f3f2d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e5c3890d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e720074d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e7656fa7 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e80bcaac +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e8e7900e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ee8993f9 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ef8cf362 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f1405b1d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f20f0e0d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f2586978 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f53cd716 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/fe71f6bb +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/febfc20b +0 -0
- package/package.json +2 -7
- package/scripts/sync-hvigor.js +27 -0
- package/src/autolinking/Autolinking.ts +1 -1
- package/src/codegen/generators/UberGeneratorV1.ts +7 -2
- package/src/codegen/generators/UberGeneratorV2.ts +6 -1
- package/src/commands/codegen-harmony.ts +17 -7
- package/src/commands/run-harmony.ts +67 -41
- package/src/init/templates/harmony/entry/src/main/module.json5 +7 -0
- package/src/simulator/LaunchSimulator.ts +359 -0
- package/src/simulator/index.ts +8 -0
|
@@ -183,7 +183,7 @@ class Autolinking {
|
|
|
183
183
|
const managedNativeDependencySpecifierByName = {};
|
|
184
184
|
for (const library of autolinkableLibraries) {
|
|
185
185
|
managedNativeDependencySpecifierByName[library.ohPackageName] =
|
|
186
|
-
|
|
186
|
+
`file:${library.harFilePathRelativeToHarmony}`.split(node_path_1.default.sep).join('/');
|
|
187
187
|
}
|
|
188
188
|
return {
|
|
189
189
|
skippedLibraryNpmPackageNames: input.skippedLibraryNpmPackageNames,
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.UberGeneratorV1 = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
4
8
|
const core_1 = require("../core");
|
|
5
9
|
const NativeModuleCodeGenerator_1 = require("./NativeModuleCodeGenerator");
|
|
6
10
|
const ArkTSComponentCodeGeneratorArkTS_1 = require("./ArkTSComponentCodeGeneratorArkTS");
|
|
11
|
+
// The name of rnoh OHOS module
|
|
12
|
+
const RNOH_OHOS_NAME = '@rnoh/react-native-openharmony';
|
|
7
13
|
/**
|
|
8
14
|
* Generates code for libraries built on top of RNOH's ArkTS architecture.
|
|
9
15
|
*/
|
|
@@ -19,8 +25,9 @@ class UberGeneratorV1 {
|
|
|
19
25
|
}
|
|
20
26
|
generate(uberSchema) {
|
|
21
27
|
const fileContentByPath = new Map();
|
|
22
|
-
const
|
|
23
|
-
const
|
|
28
|
+
const isRNOHModulePath = this.etsOutputPath.getValue().endsWith(`${RNOH_OHOS_NAME}/generated`.replace(/\//g, path_1.default.sep));
|
|
29
|
+
const componentCodeGenerator = new ArkTSComponentCodeGeneratorArkTS_1.ArkTSComponentCodeGeneratorArkTS(this.cppOutputPath, this.etsOutputPath.copyWithNewSegment('components'), this.codegenNoticeLines, isRNOHModulePath ? '../../ts' : `${RNOH_OHOS_NAME}/ts`);
|
|
30
|
+
const nativeModuleCodeGenerator = new NativeModuleCodeGenerator_1.NativeModuleCodeGenerator(this.cppOutputPath, this.etsOutputPath.copyWithNewSegment('turboModules'), this.codegenNoticeLines, isRNOHModulePath ? '../../ts' : `${RNOH_OHOS_NAME}/ts`);
|
|
24
31
|
const generatorBySpecType = {
|
|
25
32
|
Component: componentCodeGenerator,
|
|
26
33
|
NativeModule: nativeModuleCodeGenerator,
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.UberGeneratorV2 = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
4
8
|
const CppComponentCodeGenerator_1 = require("./CppComponentCodeGenerator");
|
|
5
9
|
const NativeModuleCodeGenerator_1 = require("./NativeModuleCodeGenerator");
|
|
6
10
|
const SharedComponentCodeGenerator_1 = require("./SharedComponentCodeGenerator");
|
|
11
|
+
// The name of rnoh OHOS module
|
|
12
|
+
const RNOH_OHOS_NAME = '@rnoh/react-native-openharmony';
|
|
7
13
|
/**
|
|
8
14
|
* Generates code for libraries built on top of RNOH's C-API architecture.
|
|
9
15
|
*/
|
|
@@ -51,7 +57,8 @@ class UberGeneratorV2 {
|
|
|
51
57
|
.getSpecSchemaByFilenameMap()
|
|
52
58
|
.entries()) {
|
|
53
59
|
if (specSchema.type === 'NativeModule') {
|
|
54
|
-
const
|
|
60
|
+
const isRNOHModulePath = this.etsOutputPath.getValue().endsWith(`${RNOH_OHOS_NAME}/generated`.replace(/\//g, path_1.default.sep));
|
|
61
|
+
const nativeModuleCodeGenerator = new NativeModuleCodeGenerator_1.NativeModuleCodeGenerator(libraryCppOutput.copyWithNewSegment('RNOH', 'generated', 'turbo_modules'), this.etsOutputPath.copyWithNewSegment('turboModules'), this.codegenNoticeLines, isRNOHModulePath ? '../../ts' : `${RNOH_OHOS_NAME}/ts`);
|
|
55
62
|
nativeModuleCodeGenerator
|
|
56
63
|
.generate(specSchema)
|
|
57
64
|
.forEach((fileContent, filePath) => {
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -24,7 +24,11 @@ exports.commandCodegenHarmony = {
|
|
|
24
24
|
options: [
|
|
25
25
|
{
|
|
26
26
|
name: '--rnoh-module-path <path>',
|
|
27
|
-
description: 'Specifies the relative path to the rnoh OHOS module',
|
|
27
|
+
description: '[deprecated] Specifies the relative path to the rnoh OHOS module',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: '--ets-output-path <path>',
|
|
31
|
+
description: 'Specifies the relative path to the output directory intended for storing generated ETS files.',
|
|
28
32
|
},
|
|
29
33
|
{
|
|
30
34
|
name: '--cpp-output-path <path>',
|
|
@@ -53,7 +57,12 @@ exports.commandCodegenHarmony = {
|
|
|
53
57
|
const MAX_SUPPORTED_CODEGEN_VERSION = 2;
|
|
54
58
|
// prepare the input data
|
|
55
59
|
validateArgs(args);
|
|
56
|
-
|
|
60
|
+
let etsOutputPath = args.etsOutputPath || args.rnohModulePath;
|
|
61
|
+
const isEndWithGenerated = /\/generated\/?$/.test(etsOutputPath);
|
|
62
|
+
etsOutputPath = new core_1.AbsolutePath(etsOutputPath);
|
|
63
|
+
if (!isEndWithGenerated) {
|
|
64
|
+
etsOutputPath = etsOutputPath.copyWithNewSegment('generated');
|
|
65
|
+
}
|
|
57
66
|
const enableSafetyCheck = args.safetyCheck;
|
|
58
67
|
const cppOutputPath = new core_1.AbsolutePath(args.cppOutputPath);
|
|
59
68
|
const projectRootPath = new core_1.AbsolutePath(args.projectRootPath);
|
|
@@ -110,11 +119,13 @@ exports.commandCodegenHarmony = {
|
|
|
110
119
|
}),
|
|
111
120
|
};
|
|
112
121
|
function validateArgs(args) {
|
|
113
|
-
if (!args.rnohModulePath) {
|
|
122
|
+
if (!args.rnohModulePath && !args.etsOutputPath) {
|
|
114
123
|
throw new core_1.DescriptiveError({
|
|
115
|
-
whatHappened:
|
|
124
|
+
whatHappened: '--ets-output-path is required',
|
|
116
125
|
whatCanUserDo: [
|
|
117
|
-
'Please provide
|
|
126
|
+
'Please provide an output path for the ETS file.',
|
|
127
|
+
'It is recommended to place it in the same directory as the custom component or TurboModule.',
|
|
128
|
+
'Do not place it inside @rnoh/react-native-openharmony, otherwise a jscrash may occur when using react_native_openharmony_release2.har.'
|
|
118
129
|
],
|
|
119
130
|
});
|
|
120
131
|
}
|
package/dist/commands/init.js
CHANGED
|
File without changes
|
|
@@ -28,7 +28,10 @@ const json5_1 = __importDefault(require("json5"));
|
|
|
28
28
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
29
29
|
const path_1 = __importDefault(require("path"));
|
|
30
30
|
const cli_tools_1 = require("@react-native-community/cli-tools");
|
|
31
|
+
const simulator_1 = require("../simulator");
|
|
31
32
|
const COMMAND_NAME = 'run-harmony';
|
|
33
|
+
const LOOPBACK_IP = '127.0.0.1';
|
|
34
|
+
const DEFAULT_SIMULATOR_NAME = `${LOOPBACK_IP}:5555`;
|
|
32
35
|
exports.commandRunHarmony = {
|
|
33
36
|
name: COMMAND_NAME,
|
|
34
37
|
description: 'Builds your app and starts it on your phone.',
|
|
@@ -112,7 +115,7 @@ exports.commandRunHarmony = {
|
|
|
112
115
|
const buildMode = rawArgs.buildMode;
|
|
113
116
|
const moduleName = rawArgs.module;
|
|
114
117
|
const abilityName = rawArgs.ability;
|
|
115
|
-
|
|
118
|
+
let simulatorName = rawArgs.simulator;
|
|
116
119
|
const defaultPort = rawArgs.port;
|
|
117
120
|
const packager = rawArgs.packager;
|
|
118
121
|
const devEcoStudioToolsPath = new core_1.AbsolutePath(DEVECO_SDK_HOME).copyWithNewSegment('..', 'tools');
|
|
@@ -122,6 +125,19 @@ exports.commandRunHarmony = {
|
|
|
122
125
|
});
|
|
123
126
|
}
|
|
124
127
|
const bundleName = json5_1.default.parse(fs.readTextSync(harmonyProjectPath.copyWithNewSegment('AppScope', 'app.json5'))).app.bundleName;
|
|
128
|
+
let currentPort = defaultPort;
|
|
129
|
+
if (packager) {
|
|
130
|
+
const root = _config.root || '.';
|
|
131
|
+
const reactNativePath = _config.reactNativePath || path_1.default.dirname(require.resolve('react-native', { paths: [root] }));
|
|
132
|
+
const { port: newPort, startPackager } = yield (0, cli_tools_1.findDevServerPort)(defaultPort, root);
|
|
133
|
+
if (newPort !== 8081) {
|
|
134
|
+
yield trySetMetroPort(harmonyProjectPath.copyWithNewSegment('entry', 'src', 'main', 'ets', 'pages', 'Index.ets').toString(), newPort);
|
|
135
|
+
}
|
|
136
|
+
if (startPackager) {
|
|
137
|
+
(0, cli_tools_1.startServerInNewWindow)(newPort, root, reactNativePath, (0, cli_tools_1.getDefaultUserTerminal)());
|
|
138
|
+
}
|
|
139
|
+
currentPort = newPort;
|
|
140
|
+
}
|
|
125
141
|
const selectDevice = (deviceAndSimulatorInfos) => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
142
|
const lines = deviceAndSimulatorInfos.trim().split('\n');
|
|
127
143
|
const availableDevices = lines.map((line) => {
|
|
@@ -147,6 +163,9 @@ exports.commandRunHarmony = {
|
|
|
147
163
|
return simulatorName;
|
|
148
164
|
}
|
|
149
165
|
const connectedDevices = availableDevices.filter((deviceOrSimulator) => deviceOrSimulator.state === 'Connected');
|
|
166
|
+
if (connectedDevices.length === 1) {
|
|
167
|
+
return connectedDevices[0].name;
|
|
168
|
+
}
|
|
150
169
|
if (connectedDevices.length > 1) {
|
|
151
170
|
const answers = yield inquirer_1.default.prompt([
|
|
152
171
|
{
|
|
@@ -158,15 +177,32 @@ exports.commandRunHarmony = {
|
|
|
158
177
|
]);
|
|
159
178
|
return connectedDevices[parseInt(answers.selectedDeviceIndex) - 1].name;
|
|
160
179
|
}
|
|
161
|
-
|
|
162
|
-
|
|
180
|
+
try {
|
|
181
|
+
yield (0, simulator_1.launchHarmonySimulator)({
|
|
182
|
+
devEcoStudioToolsPath,
|
|
183
|
+
sdkToolchainsPath,
|
|
184
|
+
cli,
|
|
185
|
+
logger,
|
|
186
|
+
env: process.env,
|
|
187
|
+
});
|
|
188
|
+
simulatorName = DEFAULT_SIMULATOR_NAME;
|
|
189
|
+
return simulatorName;
|
|
163
190
|
}
|
|
164
|
-
|
|
191
|
+
catch (e) {
|
|
192
|
+
if (e instanceof core_1.DescriptiveError) {
|
|
193
|
+
throw new core_1.DescriptiveError({
|
|
194
|
+
whatHappened: `${e.getMessage()} \n No devices are connected. Failed to auto-launch simulator.`,
|
|
195
|
+
whatCanUserDo: [...e.getSuggestions()],
|
|
196
|
+
extraData: e.getRawData().extraData,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
165
199
|
throw new core_1.DescriptiveError({
|
|
166
|
-
whatHappened: `No devices are connected in the current environment.`,
|
|
200
|
+
whatHappened: `No devices are connected in the current environment (auto-launch attempt failed).`,
|
|
167
201
|
whatCanUserDo: [
|
|
168
|
-
'
|
|
169
|
-
|
|
202
|
+
'Connect a HarmonyOS device via USB or start the simulator manually.',
|
|
203
|
+
'Re-run the command after a device is listed by: hdc list targets -v',
|
|
204
|
+
],
|
|
205
|
+
extraData: e,
|
|
170
206
|
});
|
|
171
207
|
}
|
|
172
208
|
});
|
|
@@ -175,18 +211,8 @@ exports.commandRunHarmony = {
|
|
|
175
211
|
cwd: harmonyProjectPath,
|
|
176
212
|
});
|
|
177
213
|
const deviceOrSimulatorName = yield selectDevice(deviceAndSimulatorInfo);
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const root = _config.root || '.';
|
|
181
|
-
const reactNativePath = _config.reactNativePath || path_1.default.dirname(require.resolve('react-native', { paths: [root] }));
|
|
182
|
-
const { port: newPort, startPackager } = yield (0, cli_tools_1.findDevServerPort)(defaultPort, root);
|
|
183
|
-
if (newPort !== 8081) {
|
|
184
|
-
yield trySetMetroPort(harmonyProjectPath.copyWithNewSegment('entry', 'src', 'main', 'ets', 'pages', 'Index.ets').toString(), newPort);
|
|
185
|
-
}
|
|
186
|
-
if (startPackager) {
|
|
187
|
-
(0, cli_tools_1.startServerInNewWindow)(newPort, root, reactNativePath, (0, cli_tools_1.getDefaultUserTerminal)());
|
|
188
|
-
}
|
|
189
|
-
currentPort = newPort;
|
|
214
|
+
if (deviceOrSimulatorName.includes(`${LOOPBACK_IP}:`)) {
|
|
215
|
+
simulatorName = deviceOrSimulatorName;
|
|
190
216
|
}
|
|
191
217
|
const runJob = (name, job) => __awaiter(void 0, void 0, void 0, function* () {
|
|
192
218
|
const stop = logger.start((s) => s.bold(name));
|
|
@@ -215,13 +241,10 @@ exports.commandRunHarmony = {
|
|
|
215
241
|
ohpmPath = devEcoStudioToolsPath
|
|
216
242
|
.copyWithNewSegment('ohpm', 'bin', 'ohpm.bat');
|
|
217
243
|
}
|
|
218
|
-
yield cli.run(
|
|
219
|
-
ohpmPath.toString(), {
|
|
244
|
+
yield cli.run(`"${ohpmPath.toString()}"`, {
|
|
220
245
|
args: [
|
|
221
246
|
'install',
|
|
222
247
|
'--all',
|
|
223
|
-
'--strict_ssl',
|
|
224
|
-
'true',
|
|
225
248
|
],
|
|
226
249
|
cwd: harmonyProjectPath,
|
|
227
250
|
shell: true,
|
|
@@ -243,9 +266,8 @@ exports.commandRunHarmony = {
|
|
|
243
266
|
nodePath = devEcoStudioToolsPath.copyWithNewSegment('node', 'node');
|
|
244
267
|
}
|
|
245
268
|
let hvigorPathRaw = devEcoStudioToolsPath.copyWithNewSegment('hvigor', 'bin', 'hvigorw.js').toString();
|
|
246
|
-
const hvigorPath =
|
|
247
|
-
yield cli.run(
|
|
248
|
-
nodePath.toString(), {
|
|
269
|
+
const hvigorPath = `"${hvigorPathRaw}"`;
|
|
270
|
+
yield cli.run(`"${nodePath.toString()}"`, {
|
|
249
271
|
args: [
|
|
250
272
|
hvigorPath,
|
|
251
273
|
`-p`,
|
|
@@ -294,7 +316,7 @@ exports.commandRunHarmony = {
|
|
|
294
316
|
const hdcPathStrRaw = sdkToolchainsPath
|
|
295
317
|
.copyWithNewSegment('hdc')
|
|
296
318
|
.toString();
|
|
297
|
-
const hdcPathStr =
|
|
319
|
+
const hdcPathStr = `"${hdcPathStrRaw.toString()}"`;
|
|
298
320
|
const tryRemoveForwardPorting = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
299
321
|
let fportInfo = '';
|
|
300
322
|
yield cli.run(hdcPathStrRaw, {
|
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
"deliveryWithInstall": true,
|
|
11
11
|
"installationFree": false,
|
|
12
12
|
"pages": "$profile:main_pages",
|
|
13
|
+
// This is needed by bundleManager.canOpenLink to check if the app can open some url
|
|
14
|
+
"querySchemes": [
|
|
15
|
+
"maps",
|
|
16
|
+
"http",
|
|
17
|
+
"https",
|
|
18
|
+
"customDomain"
|
|
19
|
+
],
|
|
13
20
|
"requestPermissions": [
|
|
14
21
|
{
|
|
15
22
|
"name": "ohos.permission.INTERNET"
|
|
@@ -15,7 +15,7 @@ var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
|
|
15
15
|
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
16
16
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
17
17
|
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
18
|
-
return i =
|
|
18
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
19
19
|
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
20
20
|
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
21
21
|
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Huawei Technologies Co., Ltd.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.launchHarmonySimulator = launchHarmonySimulator;
|
|
22
|
+
const path_1 = __importDefault(require("path"));
|
|
23
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
24
|
+
const child_process_1 = require("child_process");
|
|
25
|
+
const core_1 = require("../core");
|
|
26
|
+
const MIN_SUPPORTED_VERSION = [6, 0, 0, 828];
|
|
27
|
+
function compareVersionTuple(a, b) {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
30
|
+
const av = (_a = a[i]) !== null && _a !== void 0 ? _a : 0;
|
|
31
|
+
const bv = (_b = b[i]) !== null && _b !== void 0 ? _b : 0;
|
|
32
|
+
if (av !== bv)
|
|
33
|
+
return av - bv;
|
|
34
|
+
}
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
function isSupportedVersion(versionDir) {
|
|
38
|
+
const m = versionDir.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)/);
|
|
39
|
+
if (!m)
|
|
40
|
+
return false;
|
|
41
|
+
const current = m.slice(1).map(n => parseInt(n, 10));
|
|
42
|
+
return compareVersionTuple(current, MIN_SUPPORTED_VERSION) >= 0;
|
|
43
|
+
}
|
|
44
|
+
function getCreatedSimulators(cli, emulator) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
try {
|
|
47
|
+
let simulatorInfos = '';
|
|
48
|
+
let simulatorInfosFromStderr = '';
|
|
49
|
+
yield cli.run(`"${emulator}"`, {
|
|
50
|
+
args: ['--list'],
|
|
51
|
+
shell: true,
|
|
52
|
+
onStdout: (msg) => {
|
|
53
|
+
simulatorInfos += msg;
|
|
54
|
+
},
|
|
55
|
+
onStderr: (msg) => {
|
|
56
|
+
simulatorInfosFromStderr += msg;
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
if (simulatorInfos == null || simulatorInfos.trim() === '') {
|
|
60
|
+
simulatorInfos = simulatorInfosFromStderr;
|
|
61
|
+
}
|
|
62
|
+
if (!simulatorInfos || simulatorInfos.trim() === '' ||
|
|
63
|
+
simulatorInfos.trim() === '[Empty]' ||
|
|
64
|
+
simulatorInfos.includes('not ')) {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
return simulatorInfos.split('\n').filter(line => line.trim() !== '');
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
throw new core_1.DescriptiveError({
|
|
71
|
+
whatHappened: `Failed to get simulator list: ${(error === null || error === void 0 ? void 0 : error.message) || error}`,
|
|
72
|
+
whatCanUserDo: [
|
|
73
|
+
'Ensure DevEco Studio is properly installed and configured.',
|
|
74
|
+
'Check if the emulator path is correct.',
|
|
75
|
+
'Verify that the emulator has read/write permissions.'
|
|
76
|
+
],
|
|
77
|
+
extraData: error,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function getDevEcoVersion(devEcoStudioToolsPath) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
try {
|
|
85
|
+
let productInfoPath = path_1.default.join(devEcoStudioToolsPath.toString(), '..', 'Resources', 'product-info.json');
|
|
86
|
+
if (process.platform === 'win32') {
|
|
87
|
+
productInfoPath = path_1.default.join(devEcoStudioToolsPath.toString(), '..', 'product-info.json');
|
|
88
|
+
}
|
|
89
|
+
const content = yield fs_extra_1.default.readFile(productInfoPath, 'utf-8');
|
|
90
|
+
const info = JSON.parse(content);
|
|
91
|
+
return info.version || null;
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
throw new core_1.DescriptiveError({
|
|
95
|
+
whatHappened: `Failed to read DevEco Studio version from product-info.json: ${(error === null || error === void 0 ? void 0 : error.message) || error}`,
|
|
96
|
+
whatCanUserDo: [
|
|
97
|
+
'Verify DevEco Studio installation is complete and not corrupted.',
|
|
98
|
+
'Check if the DevEco Studio tools path is correct.',
|
|
99
|
+
'Ensure product-info.json file exists and is readable.'
|
|
100
|
+
],
|
|
101
|
+
extraData: error,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function resolveDeviceManagerXml(env, devEcoVersion) {
|
|
107
|
+
const candidates = [];
|
|
108
|
+
if (process.platform === 'darwin') {
|
|
109
|
+
const home = env.HOME || '';
|
|
110
|
+
candidates.push(path_1.default.join(home, 'Library', 'Application Support', 'Huawei', `DevEcoStudio${devEcoVersion}`, 'options', 'deviceManager.xml'));
|
|
111
|
+
}
|
|
112
|
+
else if (process.platform === 'win32') {
|
|
113
|
+
const appdata = env.APPDATA || '';
|
|
114
|
+
candidates.push(path_1.default.join(appdata, 'Huawei', `DevEcoStudio${devEcoVersion}`, 'options', 'deviceManager.xml'));
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
throw new core_1.DescriptiveError({
|
|
118
|
+
whatHappened: `Unsupported operating system.`,
|
|
119
|
+
whatCanUserDo: ['Please run the RNOH project on Windows or macOS.']
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return candidates;
|
|
123
|
+
}
|
|
124
|
+
function parseDeviceManagerXml(xmlContent) {
|
|
125
|
+
const info = {};
|
|
126
|
+
const optionRegex = /<option\b[^>]*?>/gi;
|
|
127
|
+
let m;
|
|
128
|
+
while ((m = optionRegex.exec(xmlContent))) {
|
|
129
|
+
const tag = m[0];
|
|
130
|
+
const nameMatch = tag.match(/\bname=["']([^"']+)["']/i);
|
|
131
|
+
if (!nameMatch)
|
|
132
|
+
continue;
|
|
133
|
+
const valueMatch = tag.match(/\bvalue=["']([^"']+)["']/i);
|
|
134
|
+
if (!valueMatch)
|
|
135
|
+
continue;
|
|
136
|
+
const name = nameMatch[1];
|
|
137
|
+
const value = valueMatch[1];
|
|
138
|
+
if (name === 'imageDeployPath' && !info.imageRoot) {
|
|
139
|
+
info.imageRoot = value;
|
|
140
|
+
}
|
|
141
|
+
else if (name === 'openharmonyDeployPath' && !info.instancePath) {
|
|
142
|
+
info.instancePath = value;
|
|
143
|
+
}
|
|
144
|
+
if (info.imageRoot && info.instancePath)
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
return info;
|
|
148
|
+
}
|
|
149
|
+
function candidateEmulatorExecutables(devEcoStudioToolsPath) {
|
|
150
|
+
const list = [];
|
|
151
|
+
const add = (...segs) => list.push(devEcoStudioToolsPath.copyWithNewSegment(...segs).toString());
|
|
152
|
+
if (process.platform === 'win32') {
|
|
153
|
+
add('emulator', 'Emulator.exe');
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
add('emulator', 'Emulator');
|
|
157
|
+
}
|
|
158
|
+
return list;
|
|
159
|
+
}
|
|
160
|
+
function pickExisting(paths) {
|
|
161
|
+
return paths.find(p => fs_extra_1.default.existsSync(p));
|
|
162
|
+
}
|
|
163
|
+
function resolveInstanceAndImageRoot(env, devEcoVersion) {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
const defaultInstanceCandidates = [];
|
|
166
|
+
const defaultImageCandidates = [];
|
|
167
|
+
if (process.platform === 'darwin') {
|
|
168
|
+
const home = env.HOME || '';
|
|
169
|
+
defaultInstanceCandidates.push(path_1.default.join(home, '.Huawei', 'Emulator', 'deployed'));
|
|
170
|
+
defaultImageCandidates.push(path_1.default.join(home, 'Library', 'Huawei', 'Sdk'));
|
|
171
|
+
}
|
|
172
|
+
else if (process.platform === 'win32') {
|
|
173
|
+
const localAppData = env.LOCALAPPDATA || '';
|
|
174
|
+
defaultInstanceCandidates.push(path_1.default.join(localAppData, 'Huawei', 'Emulator', 'deployed'));
|
|
175
|
+
defaultImageCandidates.push(path_1.default.join(localAppData, 'Huawei', 'Sdk'));
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
throw new core_1.DescriptiveError({
|
|
179
|
+
whatHappened: `Unsupported operating system.`,
|
|
180
|
+
whatCanUserDo: ['Please run the RNOH project on Windows or macOS.']
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
let xmlInfo = {};
|
|
184
|
+
for (const xmlPath of resolveDeviceManagerXml(env, devEcoVersion)) {
|
|
185
|
+
if (fs_extra_1.default.existsSync(xmlPath)) {
|
|
186
|
+
try {
|
|
187
|
+
const content = yield fs_extra_1.default.readFile(xmlPath, 'utf-8');
|
|
188
|
+
xmlInfo = parseDeviceManagerXml(content);
|
|
189
|
+
if (xmlInfo.instancePath || xmlInfo.imageRoot)
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
throw new core_1.DescriptiveError({
|
|
194
|
+
whatHappened: `Failed to read or parse device manager XML at ${xmlPath}: ${(error === null || error === void 0 ? void 0 : error.message) || error}`,
|
|
195
|
+
whatCanUserDo: [
|
|
196
|
+
'Verify that the DevEco Studio deviceManager.xml file exists and is readable.',
|
|
197
|
+
'Check if DEVECO_SDK_HOME environment variable is set correctly.',
|
|
198
|
+
'Ensure DevEco Studio has been launched at least once to generate configuration files.',
|
|
199
|
+
'Check file permissions for the DevEco Studio configuration directory.'
|
|
200
|
+
],
|
|
201
|
+
extraData: error,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
let resolvedInstance = pickExisting(defaultInstanceCandidates);
|
|
207
|
+
let resolvedImageRoot = pickExisting(defaultImageCandidates);
|
|
208
|
+
if (xmlInfo.imageRoot) {
|
|
209
|
+
resolvedImageRoot = xmlInfo.imageRoot;
|
|
210
|
+
}
|
|
211
|
+
if (xmlInfo.instancePath) {
|
|
212
|
+
resolvedInstance = xmlInfo.instancePath;
|
|
213
|
+
}
|
|
214
|
+
if (!resolvedInstance || !resolvedImageRoot) {
|
|
215
|
+
throw new core_1.DescriptiveError({
|
|
216
|
+
whatHappened: `No simulator instance or image root directory detected.`,
|
|
217
|
+
whatCanUserDo: [
|
|
218
|
+
'Have you already launched the simulator via DevEco Studio?'
|
|
219
|
+
]
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
return { instancePath: resolvedInstance, imageRoot: resolvedImageRoot };
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
function launchHarmonySimulator(opt) {
|
|
226
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
227
|
+
const { devEcoStudioToolsPath, cli, logger, } = opt;
|
|
228
|
+
const devEcoVersion = yield getDevEcoVersion(devEcoStudioToolsPath);
|
|
229
|
+
if (!devEcoVersion) {
|
|
230
|
+
throw new core_1.DescriptiveError({
|
|
231
|
+
whatHappened: `DevEco Studio version could not be obtained.`,
|
|
232
|
+
whatCanUserDo: [
|
|
233
|
+
'Verify DevEco Studio is properly installed and the tools path is correct.',
|
|
234
|
+
'Check if product-info.json file exists in the DevEco Studio installation directory.',
|
|
235
|
+
'Ensure you have the latest version of DevEco Studio installed.'
|
|
236
|
+
]
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
if (!isSupportedVersion(devEcoVersion)) {
|
|
240
|
+
throw new core_1.DescriptiveError({
|
|
241
|
+
whatHappened: `Current DevEco SDK version (${devEcoVersion}) does not support launching the simulator via command line (requires >= ${MIN_SUPPORTED_VERSION.join('.')}).`,
|
|
242
|
+
whatCanUserDo: [
|
|
243
|
+
`Update DevEco Studio to version ${MIN_SUPPORTED_VERSION.join('.')} or higher.`,
|
|
244
|
+
'Check the official DevEco Studio website for the latest version.',
|
|
245
|
+
'Launch the simulator manually from DevEco Studio IDE.'
|
|
246
|
+
]
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
const versionList = devEcoVersion.split('.');
|
|
250
|
+
const majorVersion = `${versionList[0]}.${versionList[1]}`;
|
|
251
|
+
const paths = yield resolveInstanceAndImageRoot(opt.env, majorVersion);
|
|
252
|
+
if (!paths) {
|
|
253
|
+
throw new core_1.DescriptiveError({
|
|
254
|
+
whatHappened: `Could not resolve simulator instance path or image root.`,
|
|
255
|
+
whatCanUserDo: [
|
|
256
|
+
'Open DevEco Studio and launch the simulator at least once to generate configuration files.',
|
|
257
|
+
'Check if DEVECO_SDK_HOME environment variable is set correctly.',
|
|
258
|
+
'Verify that the simulator has been properly configured in DevEco Studio.',
|
|
259
|
+
'Ensure the default simulator paths exist in your system.'
|
|
260
|
+
]
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
const emulatorExe = pickExisting(candidateEmulatorExecutables(devEcoStudioToolsPath));
|
|
264
|
+
if (!emulatorExe) {
|
|
265
|
+
throw new core_1.DescriptiveError({
|
|
266
|
+
whatHappened: `Emulator executable not found in DevEco Studio installation.`,
|
|
267
|
+
whatCanUserDo: [
|
|
268
|
+
'Verify DevEco Studio installation is complete and not corrupted.',
|
|
269
|
+
'Check if the emulator component is installed in DevEco Studio.',
|
|
270
|
+
'Reinstall DevEco Studio if the emulator binary is missing.',
|
|
271
|
+
'Ensure the DevEco Studio tools path is correctly configured.'
|
|
272
|
+
]
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
const simulatorName = yield getCreatedSimulators(cli, emulatorExe);
|
|
276
|
+
if (simulatorName.length <= 0) {
|
|
277
|
+
throw new core_1.DescriptiveError({
|
|
278
|
+
whatHappened: `No existing HarmonyOS simulator instance detected.`,
|
|
279
|
+
whatCanUserDo: [
|
|
280
|
+
'Create a simulator instance in DevEco Studio first.',
|
|
281
|
+
'Open DevEco Studio Device Manager and create a new virtual device.',
|
|
282
|
+
'Ensure the simulator instance is properly configured and available.',
|
|
283
|
+
'Check if the emulator --list command returns any valid instances.'
|
|
284
|
+
]
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
try {
|
|
288
|
+
const quoteIfNeeded = (p) => process.platform === 'win32' ? `"${p}"` : p;
|
|
289
|
+
const args = [
|
|
290
|
+
'-hvd',
|
|
291
|
+
quoteIfNeeded(simulatorName[0].trim()),
|
|
292
|
+
'-path',
|
|
293
|
+
quoteIfNeeded(paths.instancePath),
|
|
294
|
+
'-imageRoot',
|
|
295
|
+
quoteIfNeeded(paths.imageRoot),
|
|
296
|
+
];
|
|
297
|
+
const child = (0, child_process_1.spawn)(quoteIfNeeded(emulatorExe), args, {
|
|
298
|
+
cwd: path_1.default.dirname(emulatorExe),
|
|
299
|
+
detached: true,
|
|
300
|
+
stdio: 'ignore',
|
|
301
|
+
shell: process.platform === 'win32',
|
|
302
|
+
});
|
|
303
|
+
child.unref();
|
|
304
|
+
logger.info(() => `Launching HarmonyOS simulator in background: ${simulatorName[0]}`);
|
|
305
|
+
}
|
|
306
|
+
catch (e) {
|
|
307
|
+
throw new core_1.DescriptiveError({
|
|
308
|
+
whatHappened: `Failed to start simulator process: ${(e === null || e === void 0 ? void 0 : e.message) || e}`,
|
|
309
|
+
whatCanUserDo: [
|
|
310
|
+
'Confirm that the DevEco Simulator can be started manually from DevEco Studio.',
|
|
311
|
+
'Ensure no stale simulator process is blocking required ports.',
|
|
312
|
+
'Reinstall or repair DevEco Studio if the simulator binary is corrupted.'
|
|
313
|
+
],
|
|
314
|
+
extraData: e,
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Huawei Technologies Co., Ltd.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
__exportStar(require("./LaunchSimulator"), exports);
|
|
Binary file
|