@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
|
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
|
package/package.json
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-oh/react-native-harmony-cli",
|
|
3
|
-
"version": "0.82.
|
|
3
|
+
"version": "0.82.33",
|
|
4
4
|
"description": "",
|
|
5
|
-
"publishConfig": {
|
|
6
|
-
"registry": "https://registry.npmjs.org/",
|
|
7
|
-
"access": "public"
|
|
8
|
-
},
|
|
9
5
|
"scripts": {
|
|
10
6
|
"build": "tsc --outDir dist -p tsconfig.build.json && node ./scripts/copy-template.js",
|
|
11
7
|
"prepack": "npm run build && npm run _recreate-hvigor-plugin",
|
|
@@ -59,5 +55,9 @@
|
|
|
59
55
|
"mustache": "^4.2.0",
|
|
60
56
|
"tar": "^6.1.15",
|
|
61
57
|
"tmp": "^0.2.1"
|
|
58
|
+
},
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"registry": "https://registry.npmjs.org/",
|
|
61
|
+
"access": "public"
|
|
62
62
|
}
|
|
63
63
|
}
|
package/src/assetResolver.ts
CHANGED
|
@@ -202,6 +202,7 @@ export class Autolinking {
|
|
|
202
202
|
const autolinkingConfig =
|
|
203
203
|
providedAutolinkingConfig === true ? {} : providedAutolinkingConfig;
|
|
204
204
|
|
|
205
|
+
|
|
205
206
|
// 获取自定义的 HAR 扫描路径
|
|
206
207
|
const mainHarPath = autolinkingConfig?.mainHarPath;
|
|
207
208
|
|
|
@@ -241,6 +242,7 @@ export class Autolinking {
|
|
|
241
242
|
cppRNOHPackageClassName: autolinkingConfig?.cppPackageClassName,
|
|
242
243
|
cmakeLibraryTargetName: autolinkingConfig?.cmakeLibraryTargetName,
|
|
243
244
|
});
|
|
245
|
+
|
|
244
246
|
}
|
|
245
247
|
);
|
|
246
248
|
const ohPackagePath = harmonyProjectPath.copyWithNewSegment(
|
|
@@ -357,10 +359,11 @@ export class Autolinking {
|
|
|
357
359
|
this.npmPackageNameToCMakeLibraryTargetName(lib.npmPackageName),
|
|
358
360
|
resolvedHars: lib.resolvedHars,
|
|
359
361
|
};
|
|
362
|
+
|
|
360
363
|
});
|
|
361
364
|
autolinkableLibraries.sort((a, b) => {
|
|
362
|
-
if (a.npmPackageName < b.npmPackageName) return -1;
|
|
363
|
-
if (a.npmPackageName > b.npmPackageName) return 1;
|
|
365
|
+
if (a.npmPackageName < b.npmPackageName) { return -1; }
|
|
366
|
+
if (a.npmPackageName > b.npmPackageName) { return 1; }
|
|
364
367
|
return 0;
|
|
365
368
|
});
|
|
366
369
|
|
|
@@ -428,6 +431,7 @@ export class Autolinking {
|
|
|
428
431
|
...lib,
|
|
429
432
|
ohPackageName: primaryOhPackageName,
|
|
430
433
|
};
|
|
434
|
+
|
|
431
435
|
});
|
|
432
436
|
|
|
433
437
|
return {
|
|
@@ -518,7 +522,7 @@ export class Autolinking {
|
|
|
518
522
|
if (afterNodeModules.startsWith('@')) {
|
|
519
523
|
const parts = afterNodeModules.split('/');
|
|
520
524
|
if (parts.length >= 2) {
|
|
521
|
-
return `${parts[0]}/${parts[1]}`;
|
|
525
|
+
return `${parts[0]}/${parts[1]}`; // @scope/package
|
|
522
526
|
}
|
|
523
527
|
} else {
|
|
524
528
|
// 非 scoped package
|
|
@@ -73,20 +73,31 @@ export class LibGlueCodeGenerator implements CodeGenerator<LibGlueCodeData> {
|
|
|
73
73
|
),
|
|
74
74
|
basePackageTemplate.build()
|
|
75
75
|
);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
const hasFabricComponents =
|
|
77
|
+
arkTSComponents.length > 0 || cppComponents.length > 0;
|
|
78
|
+
const hasTurboModules = turboModules.length > 0;
|
|
79
|
+
if (hasFabricComponents) {
|
|
80
|
+
fileContentByPath.set(
|
|
81
|
+
this.etsOutputPath.copyWithNewSegment('components', 'ts.ts'),
|
|
82
|
+
components_indexTS.build()
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
if (hasTurboModules) {
|
|
86
|
+
fileContentByPath.set(
|
|
87
|
+
this.etsOutputPath.copyWithNewSegment('turboModules', 'ts.ts'),
|
|
88
|
+
turboModules_indexTS.build()
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
const rootTS = new IndexTSTemplate(this.codegenNoticeLines);
|
|
92
|
+
if (hasFabricComponents) {
|
|
93
|
+
rootTS.addReexport({ from: './components/ts', as: 'RNC' });
|
|
94
|
+
}
|
|
95
|
+
if (hasTurboModules) {
|
|
96
|
+
rootTS.addReexport({ from: './turboModules/ts', as: 'TM' });
|
|
97
|
+
}
|
|
84
98
|
fileContentByPath.set(
|
|
85
99
|
this.etsOutputPath.copyWithNewSegment('ts.ts'),
|
|
86
|
-
|
|
87
|
-
.addReexport({ from: './components/ts', as: 'RNC' })
|
|
88
|
-
.addReexport({ from: './turboModules/ts', as: 'TM' })
|
|
89
|
-
.build()
|
|
100
|
+
rootTS.build()
|
|
90
101
|
);
|
|
91
102
|
generated_indexETS.addReexport({ from: './ts' });
|
|
92
103
|
fileContentByPath.set(
|
|
@@ -163,7 +163,7 @@ export const commandBundleHarmony: Command = {
|
|
|
163
163
|
resetCache: args.resetCache,
|
|
164
164
|
});
|
|
165
165
|
|
|
166
|
-
const {assets, ...bundle}= await createBundle(metroConfig, buildOptions);
|
|
166
|
+
const {assets, ...bundle } = await createBundle(metroConfig, buildOptions);
|
|
167
167
|
|
|
168
168
|
if (shouldGenerateHbcBundle) {
|
|
169
169
|
debugLog('Starting Hermes bytecode compilation...');
|
|
@@ -179,7 +179,7 @@ export const commandBundleHarmony: Command = {
|
|
|
179
179
|
await saveJSBundle(logger, bundle, bundleOutput);
|
|
180
180
|
}
|
|
181
181
|
maybeSaveSourceMap(logger, bundle, args.sourcemapOutput);
|
|
182
|
-
if(assets){
|
|
182
|
+
if (assets) {
|
|
183
183
|
await copyAssets(logger, assets, assetsDest);
|
|
184
184
|
debugLog('Assets copy completed, cleaning up...');
|
|
185
185
|
}
|
|
@@ -19,15 +19,15 @@ export const commandCleanHarmony: Command = {
|
|
|
19
19
|
description: 'Remove cached files in the OpenHarmony project.',
|
|
20
20
|
options: [
|
|
21
21
|
{
|
|
22
|
-
name:
|
|
23
|
-
description:
|
|
24
|
-
default:
|
|
22
|
+
name: '--harmony-project-path <path>',
|
|
23
|
+
description: 'Specifies the root of your OpenHarmony project.',
|
|
24
|
+
default: './harmony'
|
|
25
25
|
}
|
|
26
26
|
],
|
|
27
27
|
func: async (_argv, _config, rawArgs: any) => {
|
|
28
28
|
const harmonyProjectPath = new AbsolutePath(rawArgs.harmonyProjectPath);
|
|
29
|
-
const md5Path = crypto.createHash(
|
|
30
|
-
const hvigorCachePath = new AbsolutePath(path.join(os.homedir(),
|
|
29
|
+
const md5Path = crypto.createHash('md5').update(harmonyProjectPath.getValue()).digest('hex');
|
|
30
|
+
const hvigorCachePath = new AbsolutePath(path.join(os.homedir(), '.hvigor', 'project_caches', md5Path));
|
|
31
31
|
|
|
32
32
|
if (fs.existsSync(hvigorCachePath.getValue())) {
|
|
33
33
|
fs.rmSync(hvigorCachePath.getValue(), { recursive: true, force: true });
|
|
@@ -42,16 +42,18 @@ export const commandCleanHarmony: Command = {
|
|
|
42
42
|
if (Array.isArray(buildProfile.modules)) {
|
|
43
43
|
buildProfile.modules.forEach((module: any) => {
|
|
44
44
|
if (module && module.srcPath) {
|
|
45
|
-
const modulePath =
|
|
45
|
+
const modulePath = harmonyProjectPath.copyWithNewSegment(module.srcPath);
|
|
46
46
|
const cxxPath = modulePath.copyWithNewSegment('.cxx');
|
|
47
47
|
const buildPath = modulePath.copyWithNewSegment('build');
|
|
48
48
|
|
|
49
49
|
if (fs.existsSync(cxxPath.getValue())) {
|
|
50
50
|
fs.rmSync(cxxPath.getValue(), { recursive: true, force: true });
|
|
51
|
+
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
if (fs.existsSync(buildPath.getValue())) {
|
|
54
55
|
fs.rmSync(buildPath.getValue(), { recursive: true, force: true });
|
|
56
|
+
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
});
|
|
@@ -26,6 +26,9 @@ import { LibGlueCodeGenerator } from '../codegen/generators/LibGlueCodeGenerator
|
|
|
26
26
|
|
|
27
27
|
const COMMAND_NAME = 'codegen-lib-harmony';
|
|
28
28
|
|
|
29
|
+
const VALID_GENERATE_TYPES = ['all', 'turbo-module', 'fabric'] as const;
|
|
30
|
+
type GenerateType = (typeof VALID_GENERATE_TYPES)[number];
|
|
31
|
+
|
|
29
32
|
export const commandCodegenLibHarmony: Command = {
|
|
30
33
|
name: COMMAND_NAME,
|
|
31
34
|
description:
|
|
@@ -69,6 +72,14 @@ export const commandCodegenLibHarmony: Command = {
|
|
|
69
72
|
description:
|
|
70
73
|
'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.',
|
|
71
74
|
},
|
|
75
|
+
{
|
|
76
|
+
name: '--generate-type <string>',
|
|
77
|
+
description:
|
|
78
|
+
'Controls which type of code to generate. ' +
|
|
79
|
+
'Possible values: "all" (default, generates both TurboModule and Fabric code), ' +
|
|
80
|
+
'"turbo-module" (generates only TurboModule code), ' +
|
|
81
|
+
'"fabric" (generates only Fabric component code).',
|
|
82
|
+
},
|
|
72
83
|
],
|
|
73
84
|
func: async (_argv, _config, rawArgs: any) => {
|
|
74
85
|
const logger = new Logger();
|
|
@@ -98,6 +109,7 @@ type RawArgs = {
|
|
|
98
109
|
cppOutputPath?: string;
|
|
99
110
|
etsOutputPath?: string;
|
|
100
111
|
safetyCheck?: boolean;
|
|
112
|
+
generateType?: string;
|
|
101
113
|
};
|
|
102
114
|
|
|
103
115
|
function validateArgsAndRetrieveUberSchemaByType(rawArgs: RawArgs) {
|
|
@@ -141,6 +153,7 @@ type Args = {
|
|
|
141
153
|
cppOutputPath: AbsolutePath;
|
|
142
154
|
etsOutputPath: AbsolutePath;
|
|
143
155
|
safetyCheck: boolean;
|
|
156
|
+
generateType: GenerateType;
|
|
144
157
|
};
|
|
145
158
|
|
|
146
159
|
function validateRawArgs(rawArgs: RawArgs): Args {
|
|
@@ -162,6 +175,15 @@ function validateRawArgs(rawArgs: RawArgs): Args {
|
|
|
162
175
|
whatCanUserDo: ['Please specify --ets-output-path'],
|
|
163
176
|
});
|
|
164
177
|
}
|
|
178
|
+
const generateType = (rawArgs.generateType ?? 'all') as GenerateType;
|
|
179
|
+
if (!VALID_GENERATE_TYPES.includes(generateType)) {
|
|
180
|
+
throw new DescriptiveError({
|
|
181
|
+
whatHappened: `Invalid --generate-type value: "${rawArgs.generateType}". Valid values are: ${VALID_GENERATE_TYPES.join(', ')}`,
|
|
182
|
+
whatCanUserDo: [
|
|
183
|
+
`Please specify one of: ${VALID_GENERATE_TYPES.join(', ')}`,
|
|
184
|
+
],
|
|
185
|
+
});
|
|
186
|
+
}
|
|
165
187
|
return {
|
|
166
188
|
npmPackageName: rawArgs.npmPackageName!,
|
|
167
189
|
tmSpecPaths: (rawArgs.turboModulesSpecPaths ?? []).map(
|
|
@@ -176,6 +198,7 @@ function validateRawArgs(rawArgs: RawArgs): Args {
|
|
|
176
198
|
etsOutputPath: new AbsolutePath(rawArgs.etsOutputPath!),
|
|
177
199
|
cppOutputPath: new AbsolutePath(rawArgs.cppOutputPath!),
|
|
178
200
|
safetyCheck: !!rawArgs.safetyCheck,
|
|
201
|
+
generateType,
|
|
179
202
|
};
|
|
180
203
|
}
|
|
181
204
|
|
|
@@ -220,25 +243,36 @@ function generateCodeInMemory({
|
|
|
220
243
|
fileContentByPath.set(path, fileContent);
|
|
221
244
|
};
|
|
222
245
|
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
)
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
246
|
+
const { generateType } = args;
|
|
247
|
+
const shouldGenerateTurboModule =
|
|
248
|
+
generateType === 'all' || generateType === 'turbo-module';
|
|
249
|
+
const shouldGenerateFabric =
|
|
250
|
+
generateType === 'all' || generateType === 'fabric';
|
|
251
|
+
|
|
252
|
+
let turboModuleGlueCodeData: ReturnType<
|
|
253
|
+
NativeModuleCodeGenerator['getGlueCodeData']
|
|
254
|
+
> = [];
|
|
255
|
+
if (shouldGenerateTurboModule) {
|
|
256
|
+
turboModuleGlueCodeData = turboModulesUberSchema
|
|
257
|
+
.findAllSpecSchemasByType('NativeModule')
|
|
258
|
+
.map((specSchema) => {
|
|
259
|
+
const nativeModuleCodeGenerator = new NativeModuleCodeGenerator(
|
|
260
|
+
args.cppOutputPath.copyWithNewSegment(
|
|
261
|
+
'RNOH',
|
|
262
|
+
'generated',
|
|
263
|
+
'turbo_modules'
|
|
264
|
+
),
|
|
265
|
+
args.etsOutputPath.copyWithNewSegment('turboModules'),
|
|
266
|
+
CODEGEN_NOTICE_LINES,
|
|
267
|
+
'@rnoh/react-native-openharmony/ts'
|
|
268
|
+
);
|
|
269
|
+
nativeModuleCodeGenerator
|
|
270
|
+
.generate(specSchema)
|
|
271
|
+
.forEach(appendToFileContentByPath);
|
|
272
|
+
return nativeModuleCodeGenerator.getGlueCodeData();
|
|
273
|
+
})
|
|
274
|
+
.flat();
|
|
275
|
+
}
|
|
242
276
|
|
|
243
277
|
const arkTSComponentCodeGeneratorCAPI = new ArkTSComponentCodeGeneratorCAPI(
|
|
244
278
|
args.cppOutputPath.copyWithNewSegment('RNOH', 'generated', 'components'),
|
|
@@ -246,9 +280,12 @@ function generateCodeInMemory({
|
|
|
246
280
|
CODEGEN_NOTICE_LINES,
|
|
247
281
|
'@rnoh/react-native-openharmony/ts'
|
|
248
282
|
);
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
283
|
+
|
|
284
|
+
if (shouldGenerateFabric) {
|
|
285
|
+
arkTSComponentCodeGeneratorCAPI
|
|
286
|
+
.generate(arkTSComponentsUberSchema)
|
|
287
|
+
.forEach(appendToFileContentByPath);
|
|
288
|
+
}
|
|
252
289
|
|
|
253
290
|
const libraryCppName = deriveLibraryCppNameFromNpmPackageName(
|
|
254
291
|
args.npmPackageName
|
|
@@ -264,27 +301,29 @@ function generateCodeInMemory({
|
|
|
264
301
|
},
|
|
265
302
|
CODEGEN_NOTICE_LINES
|
|
266
303
|
);
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
304
|
+
if (shouldGenerateFabric) {
|
|
305
|
+
cppComponentCodeGenerator
|
|
306
|
+
.generate({
|
|
307
|
+
libraryCppName: libraryCppName,
|
|
308
|
+
uberSchema: cppComponentsUberSchema,
|
|
309
|
+
})
|
|
310
|
+
.forEach(appendToFileContentByPath);
|
|
273
311
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
})
|
|
283
|
-
.generate({
|
|
284
|
-
libraryCppName: libraryCppName,
|
|
285
|
-
uberSchema: componentsUberSchema,
|
|
312
|
+
new SharedComponentCodeGenerator((filename) => {
|
|
313
|
+
return args.cppOutputPath.copyWithNewSegment(
|
|
314
|
+
'react',
|
|
315
|
+
'renderer',
|
|
316
|
+
'components',
|
|
317
|
+
libraryCppName,
|
|
318
|
+
filename
|
|
319
|
+
);
|
|
286
320
|
})
|
|
287
|
-
|
|
321
|
+
.generate({
|
|
322
|
+
libraryCppName: libraryCppName,
|
|
323
|
+
uberSchema: componentsUberSchema,
|
|
324
|
+
})
|
|
325
|
+
.forEach(appendToFileContentByPath);
|
|
326
|
+
}
|
|
288
327
|
|
|
289
328
|
new LibGlueCodeGenerator(
|
|
290
329
|
args.cppOutputPath,
|
|
@@ -293,11 +332,15 @@ function generateCodeInMemory({
|
|
|
293
332
|
)
|
|
294
333
|
.generate({
|
|
295
334
|
libraryCppName,
|
|
296
|
-
arkTSComponents:
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
335
|
+
arkTSComponents: shouldGenerateFabric
|
|
336
|
+
? arkTSComponentCodeGeneratorCAPI.getLibGlueCodeData()
|
|
337
|
+
: [],
|
|
338
|
+
cppComponents: shouldGenerateFabric
|
|
339
|
+
? cppComponentCodeGenerator
|
|
340
|
+
.getGlueCodeData()
|
|
341
|
+
.map(({ name }) => ({ componentName: name }))
|
|
342
|
+
: [],
|
|
343
|
+
turboModules: shouldGenerateTurboModule ? turboModuleGlueCodeData : [],
|
|
301
344
|
})
|
|
302
345
|
.forEach(appendToFileContentByPath);
|
|
303
346
|
|
|
@@ -325,7 +368,8 @@ function saveAndLogCodegenResult(
|
|
|
325
368
|
fileContentByPath,
|
|
326
369
|
args.cppOutputPath,
|
|
327
370
|
args.etsOutputPath,
|
|
328
|
-
args.safetyCheck
|
|
371
|
+
args.safetyCheck,
|
|
372
|
+
args.generateType
|
|
329
373
|
);
|
|
330
374
|
logCodegenResult(logger, fileContentByPath, new AbsolutePath(''));
|
|
331
375
|
}
|
|
@@ -334,18 +378,28 @@ function saveCodegenResultToFileSystem(
|
|
|
334
378
|
fileContentByPath: Map<AbsolutePath, string>,
|
|
335
379
|
cppOutputPath: AbsolutePath,
|
|
336
380
|
etsOutputPath: AbsolutePath,
|
|
337
|
-
enableSafetyCheck: boolean
|
|
381
|
+
enableSafetyCheck: boolean,
|
|
382
|
+
generateType: GenerateType
|
|
338
383
|
) {
|
|
384
|
+
const shouldGenerateTurboModule =
|
|
385
|
+
generateType === 'all' || generateType === 'turbo-module';
|
|
386
|
+
const shouldGenerateFabric =
|
|
387
|
+
generateType === 'all' || generateType === 'fabric';
|
|
388
|
+
|
|
339
389
|
prepareDirectory(cppOutputPath, enableSafetyCheck);
|
|
340
390
|
prepareDirectory(etsOutputPath, enableSafetyCheck);
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
391
|
+
if (shouldGenerateFabric) {
|
|
392
|
+
prepareDirectory(
|
|
393
|
+
etsOutputPath.copyWithNewSegment('components'),
|
|
394
|
+
enableSafetyCheck
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
if (shouldGenerateTurboModule) {
|
|
398
|
+
prepareDirectory(
|
|
399
|
+
etsOutputPath.copyWithNewSegment('turboModules'),
|
|
400
|
+
enableSafetyCheck
|
|
401
|
+
);
|
|
402
|
+
}
|
|
349
403
|
fileContentByPath.forEach((_fileContent, path) => {
|
|
350
404
|
prepareDirectory(path.getDirectoryPath(), enableSafetyCheck);
|
|
351
405
|
});
|
|
@@ -223,12 +223,12 @@ export const commandInitHarmony: Command = {
|
|
|
223
223
|
fs.writeTextSync(path, content);
|
|
224
224
|
});
|
|
225
225
|
|
|
226
|
-
const buildProfileTemplateComment =
|
|
226
|
+
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.';
|
|
227
227
|
|
|
228
228
|
const buildProfilePath = harmonyDirPath.copyWithNewSegment('build-profile.json5');
|
|
229
229
|
const buildProfileContent = fs.readTextSync(buildProfilePath);
|
|
230
230
|
const contentLines = buildProfileContent.split('\n');
|
|
231
|
-
contentLines.splice(1, 0,
|
|
231
|
+
contentLines.splice(1, 0, ' // ' + buildProfileTemplateComment);
|
|
232
232
|
const buildProfileTemplateContent = contentLines.join('\n');
|
|
233
233
|
|
|
234
234
|
fs.writeTextSync(
|
package/src/commands/init.ts
CHANGED
|
@@ -153,7 +153,7 @@ class ValidationHelper {
|
|
|
153
153
|
}
|
|
154
154
|
return reactNativeVersion;
|
|
155
155
|
}
|
|
156
|
-
return
|
|
156
|
+
return '0.77';
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
|
|
@@ -482,6 +482,7 @@ async function renameDotFiles(destDir: string): Promise<void> {
|
|
|
482
482
|
const srcPath = path.join(destDir, src);
|
|
483
483
|
if (await fs.pathExists(srcPath)) {
|
|
484
484
|
await fs.move(srcPath, path.join(destDir, dest), { overwrite: true });
|
|
485
|
+
|
|
485
486
|
}
|
|
486
487
|
});
|
|
487
488
|
|
|
@@ -580,7 +581,7 @@ async function cleanupTempDir(tempDir: string): Promise<void> {
|
|
|
580
581
|
async function getRNOHVersion(rnVersion: string): Promise<string> {
|
|
581
582
|
const versionParts = rnVersion.split('.');
|
|
582
583
|
const majorMinorVersion = `${versionParts[0]}.${versionParts[1]}`;
|
|
583
|
-
let versionInfos =
|
|
584
|
+
let versionInfos = '';
|
|
584
585
|
await runCliCommand(NPM_EXE, ['view', DEFAULT_TEMPLATE_PKG, 'versions', '--json'], process.cwd(), false,
|
|
585
586
|
(data) => {
|
|
586
587
|
versionInfos += data.toString();
|
|
@@ -597,7 +598,10 @@ async function getRNOHVersion(rnVersion: string): Promise<string> {
|
|
|
597
598
|
return matchingVersions.pop();
|
|
598
599
|
}
|
|
599
600
|
|
|
600
|
-
async function handleMissingHarmonyDir(
|
|
601
|
+
async function handleMissingHarmonyDir(
|
|
602
|
+
destDir: string,
|
|
603
|
+
rnVersion: string,
|
|
604
|
+
): Promise<{ rnohTemplateConfig: TemplateConfig, rnohVersion: string, rnohCliVersion: string }> {
|
|
601
605
|
const lastestVersion = await getRNOHVersion(rnVersion);
|
|
602
606
|
const defaultTempDir = await createTempDir();
|
|
603
607
|
try {
|
|
@@ -192,7 +192,7 @@ export const commandRunHarmony: Command = {
|
|
|
192
192
|
message: 'Please select a device:',
|
|
193
193
|
choices: connectedDevices.map((deviceOrSimulator, index) => `${index + 1}. ${deviceOrSimulator.name}`)
|
|
194
194
|
}
|
|
195
|
-
])
|
|
195
|
+
]);
|
|
196
196
|
return connectedDevices[parseInt(answers.selectedDeviceIndex) - 1].name;
|
|
197
197
|
}
|
|
198
198
|
|
|
@@ -333,6 +333,7 @@ export const commandRunHarmony: Command = {
|
|
|
333
333
|
onArgsStringified: (commandWithArgs) =>
|
|
334
334
|
logger.debug((s) => s.bold(s.gray(commandWithArgs))),
|
|
335
335
|
});
|
|
336
|
+
|
|
336
337
|
if (result.startsWith('[Fail]')) {
|
|
337
338
|
throw new DescriptiveError({ whatHappened: result });
|
|
338
339
|
}
|
|
@@ -363,6 +364,7 @@ export const commandRunHarmony: Command = {
|
|
|
363
364
|
logger.debug((s) => s.gray(msg.trimEnd()));
|
|
364
365
|
},
|
|
365
366
|
});
|
|
367
|
+
|
|
366
368
|
if (fportInfo.includes(`tcp:${currentPort} tcp:${currentPort}`)) {
|
|
367
369
|
await exec(hdcPathStr, [
|
|
368
370
|
'fport',
|
|
@@ -397,6 +399,7 @@ export const commandRunHarmony: Command = {
|
|
|
397
399
|
.toString(),
|
|
398
400
|
ohosTmpDirPath,
|
|
399
401
|
]);
|
|
402
|
+
|
|
400
403
|
const installationResult = await exec(hdcPathStr, [
|
|
401
404
|
'-t',
|
|
402
405
|
deviceOrSimulatorName,
|
|
@@ -406,6 +409,7 @@ export const commandRunHarmony: Command = {
|
|
|
406
409
|
'-p',
|
|
407
410
|
ohosTmpDirPath,
|
|
408
411
|
]);
|
|
412
|
+
|
|
409
413
|
if (installationResult.includes('failed to install')) {
|
|
410
414
|
throw new DescriptiveError({
|
|
411
415
|
whatHappened: 'Installation failed.',
|
|
@@ -413,6 +417,7 @@ export const commandRunHarmony: Command = {
|
|
|
413
417
|
`If an application with the same bundle name is already installed, try uninstalling it:\n${hdcPathStr} shell bm uninstall -n ${bundleName}`,
|
|
414
418
|
],
|
|
415
419
|
});
|
|
420
|
+
|
|
416
421
|
}
|
|
417
422
|
} finally {
|
|
418
423
|
await exec(hdcPathStr, ['-t', deviceOrSimulatorName, 'shell', 'rm', '-rf', ohosTmpDirPath]);
|
|
@@ -428,6 +433,7 @@ export const commandRunHarmony: Command = {
|
|
|
428
433
|
'-b',
|
|
429
434
|
bundleName,
|
|
430
435
|
]);
|
|
436
|
+
|
|
431
437
|
await tryRemoveForwardPorting();
|
|
432
438
|
await exec(hdcPathStr, [
|
|
433
439
|
'-t',
|
|
@@ -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) => {
|
|
@@ -116,7 +116,7 @@ function findHarPath(packagePath: AbsolutePath): AbsolutePath | null {
|
|
|
116
116
|
const harFilenames = fileOrDirNames.filter((fileOrDirName) =>
|
|
117
117
|
fileOrDirName.endsWith('.har')
|
|
118
118
|
);
|
|
119
|
-
if (harFilenames.length
|
|
119
|
+
if (harFilenames.length !== 1) {
|
|
120
120
|
return null;
|
|
121
121
|
}
|
|
122
122
|
return packageHarmonyPath.copyWithNewSegment(harFilenames[0]);
|