@react-native-oh/react-native-harmony-cli 0.82.31 → 0.82.33
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/README.md +4 -4
- package/dist/assetResolver.js +1 -1
- package/dist/autolinking/Autolinking.js +4 -2
- package/dist/codegen/core/TypeAnnotationToTS.js +2 -0
- package/dist/codegen/generators/LibGlueCodeGenerator.js +16 -6
- package/dist/commands/clean-harmony.js +5 -5
- package/dist/commands/codegen-lib-harmony.js +78 -40
- package/dist/commands/init-harmony.js +2 -2
- package/dist/commands/init.js +2 -2
- package/dist/commands/verify-package-harmony.js +2 -0
- package/dist/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +1 -1
- package/dist/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +2 -2
- package/dist/package-verifier/verify-package.js +1 -1
- package/dist/simulator/LaunchSimulator.js +14 -6
- package/harmony/rnoh-hvigor-plugin-0.82.33.tgz +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/00a68392 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0544a6cc +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0f36b2db +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/12f23f1e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/13d95d98 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1629e86b +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/180c8379 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1a697147 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1a8271b1 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1b7fa689 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/255a9f13 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/268d155b +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/27db9aa4 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/28db79ed +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2dc2bbcb +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2df5f8c5 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2f88aedb +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/31b3a7ea +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/36335b1c +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/38fca641 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/397722eb +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/397b6432 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3b17421f +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/454f5e18 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/45ec6cce +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/482d51b1 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4ac5cd67 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4d40499a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4dcad919 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4fc31929 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/54edc8f5 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/558a5405 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/58d2b670 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5ec7feca +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/62180f3e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/63981360 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/64096c89 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/64af560b +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6585e783 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6954304f +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/69fd6235 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6d3a0478 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6e131db7 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/778cd8f1 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/788206b6 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7882dc26 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7b3c14f7 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7cdfe667 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8048c487 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8332d9a3 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/84e5b603 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/854d8127 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/88c97376 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/90d5f644 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/967e25ac +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/969896c2 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9790193e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/97ae40c5 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9a5bf482 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a07adeb9 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a427f355 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a9dd7eb7 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a9e9d79e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ab920855 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ab9e3038 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/af054988 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/afe03e51 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b3b83913 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b4db7b4d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b5225355 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b8c00f06 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b917a081 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b9e2f3bd +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/bd70db0e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/bdbda648 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/be1e5469 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c9462295 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ca6e5efa +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/caf52beb +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cb268960 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cca16b15 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cfc1c937 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d10e6e05 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d172fc04 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d4e94e50 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d59f8d2c +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/da964053 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e0bb712a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e3e6ca34 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e50f7385 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f1a1d282 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f2514c3c +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f66207cf +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f8d129ce +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/fb1e9558 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ff7e3608 +0 -0
- package/package.json +5 -5
- package/src/assetResolver.ts +1 -1
- package/src/autolinking/Autolinking.ts +7 -3
- package/src/codegen/core/TypeAnnotationToTS.ts +2 -0
- package/src/codegen/generators/LibGlueCodeGenerator.ts +23 -12
- package/src/commands/bundle-harmony.ts +2 -2
- package/src/commands/clean-harmony.ts +8 -6
- package/src/commands/codegen-lib-harmony.ts +110 -56
- package/src/commands/init-harmony.ts +2 -2
- package/src/commands/init.ts +7 -3
- package/src/commands/run-harmony.ts +7 -1
- package/src/commands/verify-package-harmony.ts +2 -0
- package/src/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +1 -1
- package/src/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +2 -2
- package/src/package-verifier/verify-package.ts +1 -1
- package/src/simulator/LaunchSimulator.ts +6 -6
- package/harmony/rnoh-hvigor-plugin-0.82.31.tgz +0 -0
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# @react-native-oh/react-native-harmony-cli
|
|
2
2
|
|
|
3
|
-
Please refer to: [RNOH repo](https://gitcode.com/
|
|
3
|
+
Please refer to: [RNOH repo](https://gitcode.com/CPF-RN/ohos_react_native) for more detail.
|
|
4
4
|
|
|
5
5
|
# Documentation
|
|
6
6
|
|
|
7
|
-
- [中文](https://gitcode.com/
|
|
8
|
-
- [English](https://gitcode.com/
|
|
7
|
+
- [中文](https://gitcode.com/CPF-RN/ohos_react_native/blob/0.82/docs/zh-cn/README.md)
|
|
8
|
+
- [English](https://gitcode.com/CPF-RN/ohos_react_native/blob/0.82/docs/en/README.md)
|
|
9
9
|
|
|
10
10
|
# License
|
|
11
11
|
|
|
12
|
-
This library is licensed under The [MIT License (MIT)](https://gitcode.com/
|
|
12
|
+
This library is licensed under The [MIT License (MIT)](https://gitcode.com/CPF-RN/ohos_react_native)
|
package/dist/assetResolver.js
CHANGED
|
@@ -227,10 +227,12 @@ class Autolinking {
|
|
|
227
227
|
return Object.assign(Object.assign({}, lib), { etsRNOHPackageClassName: (_a = lib.etsRNOHPackageClassName) !== null && _a !== void 0 ? _a : this.npmPackageNameToRNOHPackageClassName(lib.npmPackageName), cppRNOHPackageClassName: (_b = lib.cppRNOHPackageClassName) !== null && _b !== void 0 ? _b : this.npmPackageNameToRNOHPackageClassName(lib.npmPackageName), cmakeLibraryTargetName: (_c = lib.cmakeLibraryTargetName) !== null && _c !== void 0 ? _c : this.npmPackageNameToCMakeLibraryTargetName(lib.npmPackageName), resolvedHars: lib.resolvedHars });
|
|
228
228
|
});
|
|
229
229
|
autolinkableLibraries.sort((a, b) => {
|
|
230
|
-
if (a.npmPackageName < b.npmPackageName)
|
|
230
|
+
if (a.npmPackageName < b.npmPackageName) {
|
|
231
231
|
return -1;
|
|
232
|
-
|
|
232
|
+
}
|
|
233
|
+
if (a.npmPackageName > b.npmPackageName) {
|
|
233
234
|
return 1;
|
|
235
|
+
}
|
|
234
236
|
return 0;
|
|
235
237
|
});
|
|
236
238
|
const ohPackage = json5_1.default.parse(input.ohPackagePathAndContent[1]);
|
|
@@ -42,12 +42,22 @@ class LibGlueCodeGenerator {
|
|
|
42
42
|
basePackageTemplate.addComponent({ name: componentName, libraryCppName, isArkTSComponent: false });
|
|
43
43
|
});
|
|
44
44
|
fileContentByPath.set(this.cppOutputPath.copyWithNewSegment('RNOH', 'generated', `${basePackageClassName}.h`), basePackageTemplate.build());
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
.
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
const hasFabricComponents = arkTSComponents.length > 0 || cppComponents.length > 0;
|
|
46
|
+
const hasTurboModules = turboModules.length > 0;
|
|
47
|
+
if (hasFabricComponents) {
|
|
48
|
+
fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('components', 'ts.ts'), components_indexTS.build());
|
|
49
|
+
}
|
|
50
|
+
if (hasTurboModules) {
|
|
51
|
+
fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('turboModules', 'ts.ts'), turboModules_indexTS.build());
|
|
52
|
+
}
|
|
53
|
+
const rootTS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
|
|
54
|
+
if (hasFabricComponents) {
|
|
55
|
+
rootTS.addReexport({ from: './components/ts', as: 'RNC' });
|
|
56
|
+
}
|
|
57
|
+
if (hasTurboModules) {
|
|
58
|
+
rootTS.addReexport({ from: './turboModules/ts', as: 'TM' });
|
|
59
|
+
}
|
|
60
|
+
fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('ts.ts'), rootTS.build());
|
|
51
61
|
generated_indexETS.addReexport({ from: './ts' });
|
|
52
62
|
fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('index.ets'), generated_indexETS.build());
|
|
53
63
|
return fileContentByPath;
|
|
@@ -54,15 +54,15 @@ exports.commandCleanHarmony = {
|
|
|
54
54
|
description: 'Remove cached files in the OpenHarmony project.',
|
|
55
55
|
options: [
|
|
56
56
|
{
|
|
57
|
-
name:
|
|
58
|
-
description:
|
|
59
|
-
default:
|
|
57
|
+
name: '--harmony-project-path <path>',
|
|
58
|
+
description: 'Specifies the root of your OpenHarmony project.',
|
|
59
|
+
default: './harmony'
|
|
60
60
|
}
|
|
61
61
|
],
|
|
62
62
|
func: (_argv, _config, rawArgs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
63
|
const harmonyProjectPath = new core_1.AbsolutePath(rawArgs.harmonyProjectPath);
|
|
64
|
-
const md5Path = crypto.createHash(
|
|
65
|
-
const hvigorCachePath = new core_1.AbsolutePath(node_path_1.default.join(node_os_1.default.homedir(),
|
|
64
|
+
const md5Path = crypto.createHash('md5').update(harmonyProjectPath.getValue()).digest('hex');
|
|
65
|
+
const hvigorCachePath = new core_1.AbsolutePath(node_path_1.default.join(node_os_1.default.homedir(), '.hvigor', 'project_caches', md5Path));
|
|
66
66
|
if (node_fs_1.default.existsSync(hvigorCachePath.getValue())) {
|
|
67
67
|
node_fs_1.default.rmSync(hvigorCachePath.getValue(), { recursive: true, force: true });
|
|
68
68
|
}
|
|
@@ -26,6 +26,7 @@ const codegen_1 = require("../codegen");
|
|
|
26
26
|
const case_1 = __importDefault(require("case"));
|
|
27
27
|
const LibGlueCodeGenerator_1 = require("../codegen/generators/LibGlueCodeGenerator");
|
|
28
28
|
const COMMAND_NAME = 'codegen-lib-harmony';
|
|
29
|
+
const VALID_GENERATE_TYPES = ['all', 'turbo-module', 'fabric'];
|
|
29
30
|
exports.commandCodegenLibHarmony = {
|
|
30
31
|
name: COMMAND_NAME,
|
|
31
32
|
description: 'Generates boilerplate, types, and utilities from Turbo Module and Fabric Component specifications. Designed for library developers who want to include generated code in their libraries.',
|
|
@@ -61,6 +62,13 @@ exports.commandCodegenLibHarmony = {
|
|
|
61
62
|
name: '--no-safety-check [boolean]',
|
|
62
63
|
description: 'Skips the check that prevents file operations outside the current working directory. This command permanently deletes previously generated files. Files are generated in the path specified by cpp-output-path.',
|
|
63
64
|
},
|
|
65
|
+
{
|
|
66
|
+
name: '--generate-type <string>',
|
|
67
|
+
description: 'Controls which type of code to generate. ' +
|
|
68
|
+
'Possible values: "all" (default, generates both TurboModule and Fabric code), ' +
|
|
69
|
+
'"turbo-module" (generates only TurboModule code), ' +
|
|
70
|
+
'"fabric" (generates only Fabric component code).',
|
|
71
|
+
},
|
|
64
72
|
],
|
|
65
73
|
func: (_argv, _config, rawArgs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
74
|
const logger = new io_1.Logger();
|
|
@@ -103,7 +111,7 @@ function validateArgsAndRetrieveUberSchemaByType(rawArgs) {
|
|
|
103
111
|
};
|
|
104
112
|
}
|
|
105
113
|
function validateRawArgs(rawArgs) {
|
|
106
|
-
var _a, _b, _c;
|
|
114
|
+
var _a, _b, _c, _d;
|
|
107
115
|
if (!rawArgs.npmPackageName) {
|
|
108
116
|
throw new core_1.DescriptiveError({
|
|
109
117
|
whatHappened: '--npm-package-name is required',
|
|
@@ -122,14 +130,24 @@ function validateRawArgs(rawArgs) {
|
|
|
122
130
|
whatCanUserDo: ['Please specify --ets-output-path'],
|
|
123
131
|
});
|
|
124
132
|
}
|
|
133
|
+
const generateType = ((_a = rawArgs.generateType) !== null && _a !== void 0 ? _a : 'all');
|
|
134
|
+
if (!VALID_GENERATE_TYPES.includes(generateType)) {
|
|
135
|
+
throw new core_1.DescriptiveError({
|
|
136
|
+
whatHappened: `Invalid --generate-type value: "${rawArgs.generateType}". Valid values are: ${VALID_GENERATE_TYPES.join(', ')}`,
|
|
137
|
+
whatCanUserDo: [
|
|
138
|
+
`Please specify one of: ${VALID_GENERATE_TYPES.join(', ')}`,
|
|
139
|
+
],
|
|
140
|
+
});
|
|
141
|
+
}
|
|
125
142
|
return {
|
|
126
143
|
npmPackageName: rawArgs.npmPackageName,
|
|
127
|
-
tmSpecPaths: ((
|
|
128
|
-
arkTSComponentsSpecPaths: ((
|
|
129
|
-
cppComponentsSpecPaths: ((
|
|
144
|
+
tmSpecPaths: ((_b = rawArgs.turboModulesSpecPaths) !== null && _b !== void 0 ? _b : []).map((path) => new core_1.AbsolutePath(path)),
|
|
145
|
+
arkTSComponentsSpecPaths: ((_c = rawArgs.arktsComponentsSpecPaths) !== null && _c !== void 0 ? _c : []).map((path) => new core_1.AbsolutePath(path)),
|
|
146
|
+
cppComponentsSpecPaths: ((_d = rawArgs.cppComponentsSpecPaths) !== null && _d !== void 0 ? _d : []).map((path) => new core_1.AbsolutePath(path)),
|
|
130
147
|
etsOutputPath: new core_1.AbsolutePath(rawArgs.etsOutputPath),
|
|
131
148
|
cppOutputPath: new core_1.AbsolutePath(rawArgs.cppOutputPath),
|
|
132
149
|
safetyCheck: !!rawArgs.safetyCheck,
|
|
150
|
+
generateType,
|
|
133
151
|
};
|
|
134
152
|
}
|
|
135
153
|
function specPathsToSpecFilePaths(specPaths) {
|
|
@@ -161,46 +179,60 @@ function generateCodeInMemory({ args, uberSchemaByType: { arkTSComponentsUberSch
|
|
|
161
179
|
const appendToFileContentByPath = (fileContent, path) => {
|
|
162
180
|
fileContentByPath.set(path, fileContent);
|
|
163
181
|
};
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
182
|
+
const { generateType } = args;
|
|
183
|
+
const shouldGenerateTurboModule = generateType === 'all' || generateType === 'turbo-module';
|
|
184
|
+
const shouldGenerateFabric = generateType === 'all' || generateType === 'fabric';
|
|
185
|
+
let turboModuleGlueCodeData = [];
|
|
186
|
+
if (shouldGenerateTurboModule) {
|
|
187
|
+
turboModuleGlueCodeData = turboModulesUberSchema
|
|
188
|
+
.findAllSpecSchemasByType('NativeModule')
|
|
189
|
+
.map((specSchema) => {
|
|
190
|
+
const nativeModuleCodeGenerator = new codegen_1.NativeModuleCodeGenerator(args.cppOutputPath.copyWithNewSegment('RNOH', 'generated', 'turbo_modules'), args.etsOutputPath.copyWithNewSegment('turboModules'), CODEGEN_NOTICE_LINES, '@rnoh/react-native-openharmony/ts');
|
|
191
|
+
nativeModuleCodeGenerator
|
|
192
|
+
.generate(specSchema)
|
|
193
|
+
.forEach(appendToFileContentByPath);
|
|
194
|
+
return nativeModuleCodeGenerator.getGlueCodeData();
|
|
195
|
+
})
|
|
196
|
+
.flat();
|
|
197
|
+
}
|
|
174
198
|
const arkTSComponentCodeGeneratorCAPI = new codegen_1.ArkTSComponentCodeGeneratorCAPI(args.cppOutputPath.copyWithNewSegment('RNOH', 'generated', 'components'), args.etsOutputPath.copyWithNewSegment('components'), CODEGEN_NOTICE_LINES, '@rnoh/react-native-openharmony/ts');
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
199
|
+
if (shouldGenerateFabric) {
|
|
200
|
+
arkTSComponentCodeGeneratorCAPI
|
|
201
|
+
.generate(arkTSComponentsUberSchema)
|
|
202
|
+
.forEach(appendToFileContentByPath);
|
|
203
|
+
}
|
|
178
204
|
const libraryCppName = deriveLibraryCppNameFromNpmPackageName(args.npmPackageName);
|
|
179
205
|
const cppComponentCodeGenerator = new codegen_1.CppComponentCodeGenerator((filename) => {
|
|
180
206
|
return args.cppOutputPath.copyWithNewSegment('RNOH', 'generated', 'components', filename);
|
|
181
207
|
}, CODEGEN_NOTICE_LINES);
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
208
|
+
if (shouldGenerateFabric) {
|
|
209
|
+
cppComponentCodeGenerator
|
|
210
|
+
.generate({
|
|
211
|
+
libraryCppName: libraryCppName,
|
|
212
|
+
uberSchema: cppComponentsUberSchema,
|
|
213
|
+
})
|
|
214
|
+
.forEach(appendToFileContentByPath);
|
|
215
|
+
new codegen_1.SharedComponentCodeGenerator((filename) => {
|
|
216
|
+
return args.cppOutputPath.copyWithNewSegment('react', 'renderer', 'components', libraryCppName, filename);
|
|
217
|
+
})
|
|
218
|
+
.generate({
|
|
219
|
+
libraryCppName: libraryCppName,
|
|
220
|
+
uberSchema: componentsUberSchema,
|
|
221
|
+
})
|
|
222
|
+
.forEach(appendToFileContentByPath);
|
|
223
|
+
}
|
|
196
224
|
new LibGlueCodeGenerator_1.LibGlueCodeGenerator(args.cppOutputPath, args.etsOutputPath, CODEGEN_NOTICE_LINES)
|
|
197
225
|
.generate({
|
|
198
226
|
libraryCppName,
|
|
199
|
-
arkTSComponents:
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
227
|
+
arkTSComponents: shouldGenerateFabric
|
|
228
|
+
? arkTSComponentCodeGeneratorCAPI.getLibGlueCodeData()
|
|
229
|
+
: [],
|
|
230
|
+
cppComponents: shouldGenerateFabric
|
|
231
|
+
? cppComponentCodeGenerator
|
|
232
|
+
.getGlueCodeData()
|
|
233
|
+
.map(({ name }) => ({ componentName: name }))
|
|
234
|
+
: [],
|
|
235
|
+
turboModules: shouldGenerateTurboModule ? turboModuleGlueCodeData : [],
|
|
204
236
|
})
|
|
205
237
|
.forEach(appendToFileContentByPath);
|
|
206
238
|
return fileContentByPath;
|
|
@@ -215,14 +247,20 @@ function deriveLibraryCppNameFromNpmPackageName(npmPackageName) {
|
|
|
215
247
|
return result;
|
|
216
248
|
}
|
|
217
249
|
function saveAndLogCodegenResult(args, logger, fileContentByPath) {
|
|
218
|
-
saveCodegenResultToFileSystem(fileContentByPath, args.cppOutputPath, args.etsOutputPath, args.safetyCheck);
|
|
250
|
+
saveCodegenResultToFileSystem(fileContentByPath, args.cppOutputPath, args.etsOutputPath, args.safetyCheck, args.generateType);
|
|
219
251
|
logCodegenResult(logger, fileContentByPath, new core_1.AbsolutePath(''));
|
|
220
252
|
}
|
|
221
|
-
function saveCodegenResultToFileSystem(fileContentByPath, cppOutputPath, etsOutputPath, enableSafetyCheck) {
|
|
253
|
+
function saveCodegenResultToFileSystem(fileContentByPath, cppOutputPath, etsOutputPath, enableSafetyCheck, generateType) {
|
|
254
|
+
const shouldGenerateTurboModule = generateType === 'all' || generateType === 'turbo-module';
|
|
255
|
+
const shouldGenerateFabric = generateType === 'all' || generateType === 'fabric';
|
|
222
256
|
prepareDirectory(cppOutputPath, enableSafetyCheck);
|
|
223
257
|
prepareDirectory(etsOutputPath, enableSafetyCheck);
|
|
224
|
-
|
|
225
|
-
|
|
258
|
+
if (shouldGenerateFabric) {
|
|
259
|
+
prepareDirectory(etsOutputPath.copyWithNewSegment('components'), enableSafetyCheck);
|
|
260
|
+
}
|
|
261
|
+
if (shouldGenerateTurboModule) {
|
|
262
|
+
prepareDirectory(etsOutputPath.copyWithNewSegment('turboModules'), enableSafetyCheck);
|
|
263
|
+
}
|
|
226
264
|
fileContentByPath.forEach((_fileContent, path) => {
|
|
227
265
|
prepareDirectory(path.getDirectoryPath(), enableSafetyCheck);
|
|
228
266
|
});
|
|
@@ -168,11 +168,11 @@ exports.commandInitHarmony = {
|
|
|
168
168
|
dynamicTemplateContentByPath.forEach((content, path) => {
|
|
169
169
|
fs.writeTextSync(path, content);
|
|
170
170
|
});
|
|
171
|
-
const buildProfileTemplateComment =
|
|
171
|
+
const buildProfileTemplateComment = 'build-profile.json5 can contain signingConfigs which are unique for each developer, therefore that file is ignored by Git. Create a build-profile.json5 based on this template after cloning this repository to be able to open this project in DevEco Studio.';
|
|
172
172
|
const buildProfilePath = harmonyDirPath.copyWithNewSegment('build-profile.json5');
|
|
173
173
|
const buildProfileContent = fs.readTextSync(buildProfilePath);
|
|
174
174
|
const contentLines = buildProfileContent.split('\n');
|
|
175
|
-
contentLines.splice(1, 0,
|
|
175
|
+
contentLines.splice(1, 0, ' // ' + buildProfileTemplateComment);
|
|
176
176
|
const buildProfileTemplateContent = contentLines.join('\n');
|
|
177
177
|
fs.writeTextSync(harmonyDirPath.copyWithNewSegment('build-profile.template.json5'), buildProfileTemplateContent);
|
|
178
178
|
logger.info((s) => [
|
package/dist/commands/init.js
CHANGED
|
@@ -141,7 +141,7 @@ class ValidationHelper {
|
|
|
141
141
|
}
|
|
142
142
|
return reactNativeVersion;
|
|
143
143
|
}
|
|
144
|
-
return
|
|
144
|
+
return '0.77';
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
}
|
|
@@ -553,7 +553,7 @@ function getRNOHVersion(rnVersion) {
|
|
|
553
553
|
return __awaiter(this, void 0, void 0, function* () {
|
|
554
554
|
const versionParts = rnVersion.split('.');
|
|
555
555
|
const majorMinorVersion = `${versionParts[0]}.${versionParts[1]}`;
|
|
556
|
-
let versionInfos =
|
|
556
|
+
let versionInfos = '';
|
|
557
557
|
yield runCliCommand(NPM_EXE, ['view', DEFAULT_TEMPLATE_PKG, 'versions', '--json'], process.cwd(), false, (data) => {
|
|
558
558
|
versionInfos += data.toString();
|
|
559
559
|
});
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type { RNPackageContext, RNOHPackage } from '@rnoh/react-native-openharmony';
|
|
9
|
-
import { createRNOHPackages as createRNOHPackagesAutolinking } from
|
|
9
|
+
import { createRNOHPackages as createRNOHPackagesAutolinking } from './RNOHPackagesFactory'
|
|
10
10
|
|
|
11
11
|
export function getRNOHPackages(ctx: RNPackageContext): RNOHPackage[] {
|
|
12
12
|
return [
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* It looks like this is ArkTS problem and it may be fixed in the future.
|
|
13
13
|
* For the time being, use direct imports.
|
|
14
14
|
*/
|
|
15
|
-
import { setupRNOHWorker } from
|
|
16
|
-
import { getRNOHPackages } from
|
|
15
|
+
import { setupRNOHWorker } from '@rnoh/react-native-openharmony/src/main/ets/setupRNOHWorker'
|
|
16
|
+
import { getRNOHPackages } from '../PackageProvider'
|
|
17
17
|
|
|
18
18
|
setupRNOHWorker({
|
|
19
19
|
createWorkerRNInstanceConfig: (_rnInstanceName) => {
|
|
@@ -97,7 +97,7 @@ function findHarPath(packagePath) {
|
|
|
97
97
|
const packageHarmonyPath = packagePath.copyWithNewSegment('harmony');
|
|
98
98
|
const fileOrDirNames = node_fs_1.default.readdirSync(packageHarmonyPath.getValue());
|
|
99
99
|
const harFilenames = fileOrDirNames.filter((fileOrDirName) => fileOrDirName.endsWith('.har'));
|
|
100
|
-
if (harFilenames.length
|
|
100
|
+
if (harFilenames.length !== 1) {
|
|
101
101
|
return null;
|
|
102
102
|
}
|
|
103
103
|
return packageHarmonyPath.copyWithNewSegment(harFilenames[0]);
|
|
@@ -29,15 +29,17 @@ function compareVersionTuple(a, b) {
|
|
|
29
29
|
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
30
30
|
const av = (_a = a[i]) !== null && _a !== void 0 ? _a : 0;
|
|
31
31
|
const bv = (_b = b[i]) !== null && _b !== void 0 ? _b : 0;
|
|
32
|
-
if (av !== bv)
|
|
32
|
+
if (av !== bv) {
|
|
33
33
|
return av - bv;
|
|
34
|
+
}
|
|
34
35
|
}
|
|
35
36
|
return 0;
|
|
36
37
|
}
|
|
37
38
|
function isSupportedVersion(versionDir) {
|
|
38
39
|
const m = versionDir.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)/);
|
|
39
|
-
if (!m)
|
|
40
|
+
if (!m) {
|
|
40
41
|
return false;
|
|
42
|
+
}
|
|
41
43
|
const current = m.slice(1).map(n => parseInt(n, 10));
|
|
42
44
|
return compareVersionTuple(current, MIN_SUPPORTED_VERSION) >= 0;
|
|
43
45
|
}
|
|
@@ -128,11 +130,15 @@ function parseDeviceManagerXml(xmlContent) {
|
|
|
128
130
|
while ((m = optionRegex.exec(xmlContent))) {
|
|
129
131
|
const tag = m[0];
|
|
130
132
|
const nameMatch = tag.match(/\bname=["']([^"']+)["']/i);
|
|
131
|
-
if (!nameMatch)
|
|
133
|
+
if (!nameMatch) {
|
|
132
134
|
continue;
|
|
135
|
+
}
|
|
136
|
+
;
|
|
133
137
|
const valueMatch = tag.match(/\bvalue=["']([^"']+)["']/i);
|
|
134
|
-
if (!valueMatch)
|
|
138
|
+
if (!valueMatch) {
|
|
135
139
|
continue;
|
|
140
|
+
}
|
|
141
|
+
;
|
|
136
142
|
const name = nameMatch[1];
|
|
137
143
|
const value = valueMatch[1];
|
|
138
144
|
if (name === 'imageDeployPath' && !info.imageRoot) {
|
|
@@ -141,8 +147,9 @@ function parseDeviceManagerXml(xmlContent) {
|
|
|
141
147
|
else if (name === 'openharmonyDeployPath' && !info.instancePath) {
|
|
142
148
|
info.instancePath = value;
|
|
143
149
|
}
|
|
144
|
-
if (info.imageRoot && info.instancePath)
|
|
150
|
+
if (info.imageRoot && info.instancePath) {
|
|
145
151
|
break;
|
|
152
|
+
}
|
|
146
153
|
}
|
|
147
154
|
return info;
|
|
148
155
|
}
|
|
@@ -186,8 +193,9 @@ function resolveInstanceAndImageRoot(env, devEcoVersion) {
|
|
|
186
193
|
try {
|
|
187
194
|
const content = yield fs_extra_1.default.readFile(xmlPath, 'utf-8');
|
|
188
195
|
xmlInfo = parseDeviceManagerXml(content);
|
|
189
|
-
if (xmlInfo.instancePath || xmlInfo.imageRoot)
|
|
196
|
+
if (xmlInfo.instancePath || xmlInfo.imageRoot) {
|
|
190
197
|
break;
|
|
198
|
+
}
|
|
191
199
|
}
|
|
192
200
|
catch (error) {
|
|
193
201
|
throw new core_1.DescriptiveError({
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|