@react-native-oh/react-native-harmony-cli 0.77.22 → 0.77.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.
Files changed (200) hide show
  1. package/dist/assetResolver.js +74 -43
  2. package/dist/autolinking/Autolinking.js +179 -178
  3. package/dist/codegen/core/CodegenError.js +23 -3
  4. package/dist/codegen/core/EventUtils.js +3 -3
  5. package/dist/codegen/core/TypeAnnotationToTS.js +28 -24
  6. package/dist/codegen/core/UberSchema.js +97 -55
  7. package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +41 -28
  8. package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +34 -27
  9. package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +33 -25
  10. package/dist/codegen/generators/CppComponentCodeGenerator.js +28 -23
  11. package/dist/codegen/generators/LibGlueCodeGenerator.js +29 -26
  12. package/dist/codegen/generators/NativeModuleCodeGenerator.js +30 -25
  13. package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
  14. package/dist/codegen/generators/UberGeneratorV1.js +24 -18
  15. package/dist/codegen/generators/UberGeneratorV2.js +36 -28
  16. package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +24 -50
  17. package/dist/codegen/templates/BasePackageHTemplate.js +21 -120
  18. package/dist/codegen/templates/ComponentDescriptorHTemplate.js +8 -54
  19. package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +27 -75
  20. package/dist/codegen/templates/ComponentUtilsTSTemplate.js +29 -162
  21. package/dist/codegen/templates/IndexTSTemplate.js +17 -37
  22. package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +24 -119
  23. package/dist/codegen/templates/TurboModuleCppTemplate.js +15 -38
  24. package/dist/codegen/templates/TurboModuleHTemplate.js +11 -32
  25. package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +19 -52
  26. package/dist/commands/bundle-harmony.js +221 -118
  27. package/dist/commands/clean-harmony.js +63 -58
  28. package/dist/commands/codegen-harmony.js +175 -104
  29. package/dist/commands/codegen-lib-harmony.js +116 -76
  30. package/dist/commands/init-harmony.js +196 -151
  31. package/dist/commands/init.js +961 -537
  32. package/dist/commands/link-harmony.js +82 -35
  33. package/dist/commands/run-harmony.js +518 -374
  34. package/dist/commands/verify-package-harmony.js +117 -54
  35. package/dist/core/AbsolutePath.js +49 -33
  36. package/dist/core/CodegenConfig.js +22 -24
  37. package/dist/core/DescriptiveError.js +37 -18
  38. package/dist/core/FileSystem.js +18 -14
  39. package/dist/core/OHPackageJSON5.js +23 -17
  40. package/dist/core/PackageJSON.js +42 -26
  41. package/dist/core/ProjectDependenciesManager.js +92 -40
  42. package/dist/core/ValidationError.js +22 -2
  43. package/dist/core/fs.js +7 -10
  44. package/dist/index.js +1 -1
  45. package/dist/init/templates/AppScopeAppJSON5Template.js +8 -21
  46. package/dist/init/templates/AppScopeStringVarTemplate.js +8 -19
  47. package/dist/init/templates/EntryIndexTemplate.js +8 -56
  48. package/dist/init/templates/EntryStringVarTemplate.js +8 -27
  49. package/dist/init/templates/HvigorConfigJson5Template.js +8 -33
  50. package/dist/init/templates/MetroConfigTemplate.js +8 -38
  51. package/dist/init/templates/OhPackageJson5Template.js +8 -28
  52. package/dist/io/CliExecutor.js +98 -46
  53. package/dist/io/Logger.js +46 -40
  54. package/dist/io/RealFS.js +100 -43
  55. package/dist/io/TarGz.js +8 -11
  56. package/dist/io/__fixtures__.js +141 -79
  57. package/dist/io/fsUtils.js +12 -13
  58. package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +47 -19
  59. package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +41 -13
  60. package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +38 -8
  61. package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +54 -22
  62. package/dist/package-verifier/verify-package.js +133 -56
  63. package/dist/simulator/LaunchSimulator.js +301 -217
  64. package/package.json +2 -11
  65. package/scripts/sync-hvigor.js +27 -0
  66. package/src/autolinking/Autolinking.ts +1 -1
  67. package/src/codegen/generators/UberGeneratorV1.ts +7 -2
  68. package/src/codegen/generators/UberGeneratorV2.ts +6 -1
  69. package/src/commands/codegen-harmony.ts +17 -7
  70. package/src/commands/run-harmony.ts +0 -2
  71. package/src/simulator/LaunchSimulator.ts +9 -2
  72. package/dist/init/templates/harmony/AppScope/app.json5 +0 -10
  73. package/dist/init/templates/harmony/AppScope/resources/base/element/string.json +0 -8
  74. package/dist/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  75. package/dist/init/templates/harmony/build-profile.json5 +0 -36
  76. package/dist/init/templates/harmony/codelinter.json +0 -32
  77. package/dist/init/templates/harmony/entry/build-profile.json5 +0 -18
  78. package/dist/init/templates/harmony/entry/gitignore +0 -7
  79. package/dist/init/templates/harmony/entry/hvigorfile.ts +0 -13
  80. package/dist/init/templates/harmony/entry/oh-package.json5 +0 -9
  81. package/dist/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +0 -27
  82. package/dist/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +0 -13
  83. package/dist/init/templates/harmony/entry/src/main/cpp/gitignore +0 -4
  84. package/dist/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +0 -8
  85. package/dist/init/templates/harmony/entry/src/main/ets/codegen/gitignore +0 -2
  86. package/dist/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +0 -11
  87. package/dist/init/templates/harmony/entry/src/main/ets/gitignore +0 -1
  88. package/dist/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
  89. package/dist/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +0 -16
  90. package/dist/init/templates/harmony/entry/src/main/module.json5 +0 -65
  91. package/dist/init/templates/harmony/entry/src/main/resources/base/element/color.json +0 -8
  92. package/dist/init/templates/harmony/entry/src/main/resources/base/element/string.json +0 -16
  93. package/dist/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
  94. package/dist/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
  95. package/dist/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +0 -7
  96. package/dist/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
  97. package/dist/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +0 -5
  98. package/dist/init/templates/harmony/entry/src/main/resources/gitignore +0 -1
  99. package/dist/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +0 -2
  100. package/dist/init/templates/harmony/entry/src/ohosTest/module.json5 +0 -13
  101. package/dist/init/templates/harmony/gitignore +0 -16
  102. package/dist/init/templates/harmony/hvigor/hvigor-config.json5 +0 -22
  103. package/dist/init/templates/harmony/hvigorfile.ts +0 -7
  104. package/harmony/rnoh-hvigor-plugin-0.77.22.tgz +0 -0
  105. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/02febc14 +0 -0
  106. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0429e5b7 +0 -0
  107. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/05339e68 +0 -0
  108. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/070be2fe +0 -0
  109. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/07851ff1 +0 -0
  110. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/12e10c06 +0 -0
  111. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/12e1d696 +0 -0
  112. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/14950087 +0 -0
  113. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/15e87372 +0 -0
  114. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/19e6ecbe +0 -0
  115. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1aac0ac4 +0 -0
  116. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1b8db102 +0 -0
  117. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1c181646 +0 -0
  118. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/203e747c +0 -0
  119. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/21ba4c08 +0 -0
  120. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/259939e5 +0 -0
  121. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/288ba98c +0 -0
  122. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2a45461c +0 -0
  123. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2d773091 +0 -0
  124. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2eda89fc +0 -0
  125. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2f584eca +0 -0
  126. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/35b495ca +0 -0
  127. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/36478aed +0 -0
  128. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3844e772 +0 -0
  129. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3ee777f4 +0 -0
  130. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/471ac436 +0 -0
  131. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4a91abcc +0 -0
  132. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4d1a5094 +0 -0
  133. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4d3ef38f +0 -0
  134. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4daf5855 +0 -0
  135. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4ef0389f +0 -0
  136. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4f72da28 +0 -0
  137. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/59d3e924 +0 -0
  138. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5a8edfaa +0 -0
  139. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5d28a510 +0 -0
  140. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/61a6391d +0 -0
  141. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/65921a14 +0 -0
  142. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6624e7fc +0 -0
  143. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/66d28144 +0 -0
  144. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6aceb8d2 +0 -0
  145. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/702393d3 +0 -0
  146. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/714f932b +0 -0
  147. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/73f9d4a6 +0 -0
  148. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/78d3adae +0 -0
  149. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7b6564b8 +0 -0
  150. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7c7c3e6e +0 -0
  151. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7cbc9b6a +0 -0
  152. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7dd579e0 +0 -0
  153. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7e0b7d06 +0 -0
  154. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7e153eef +0 -0
  155. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7ee84fd7 +0 -0
  156. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7f5146a4 +0 -0
  157. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/844e633a +0 -0
  158. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8a1af22c +0 -0
  159. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/90a1680d +0 -0
  160. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a15fb79a +0 -0
  161. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ac288a8a +0 -0
  162. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ad7a66b4 +0 -0
  163. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/aee8805e +0 -0
  164. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b0487ec8 +0 -0
  165. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b10e16d2 +0 -0
  166. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b32d42ac +0 -0
  167. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b7d8f35c +0 -0
  168. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b96748af +0 -0
  169. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/bedb2fea +0 -0
  170. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c01ad640 +0 -0
  171. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c0472cf5 +0 -0
  172. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c102ed0f +0 -0
  173. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c1a91819 +0 -0
  174. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c243857a +0 -0
  175. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c407792f +0 -0
  176. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c4459bee +0 -0
  177. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c72a4dcd +0 -0
  178. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c83537a9 +0 -0
  179. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c88f7498 +0 -0
  180. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c8d04070 +0 -0
  181. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cc44d6f1 +0 -0
  182. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d4d913f6 +0 -0
  183. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/da97f202 +0 -0
  184. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/dc965522 +0 -0
  185. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/dff6f700 +0 -0
  186. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e507c001 +0 -0
  187. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e52f3f2d +0 -0
  188. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e5c3890d +0 -0
  189. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e720074d +0 -0
  190. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e7656fa7 +0 -0
  191. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e80bcaac +0 -0
  192. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e8e7900e +0 -0
  193. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ee8993f9 +0 -0
  194. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ef8cf362 +0 -0
  195. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f1405b1d +0 -0
  196. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f20f0e0d +0 -0
  197. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f2586978 +0 -0
  198. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f53cd716 +0 -0
  199. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/fe71f6bb +0 -0
  200. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/febfc20b +0 -0
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ const fs = require('fs').promises;
8
+
9
+ async function sync(configFilePaths = []) {
10
+ const dir = './harmony';
11
+ const files = await fs.readdir(dir);
12
+ const file = files.find(f => /^rnoh-hvigor-plugin-\d+(\.\d+){2}\.tgz$/.test(f));
13
+ if (!file) {
14
+ return;
15
+ }
16
+ configFilePaths.forEach(async (configFilePath) => {
17
+ const fileContent = await fs.readFile(configFilePath, 'utf8');
18
+ const updatedContent = fileContent.replace(/rnoh-hvigor-plugin-\d+(\.\d+){2}\.tgz/g, file);
19
+ fs.writeFile(configFilePath, updatedContent, 'utf8');
20
+ });
21
+ }
22
+
23
+ sync([
24
+ '../tester/harmony/hvigor/hvigor-config.json5',
25
+ '../tester-ecosystem/harmony/hvigor/hvigor-config.json5',
26
+ '../react-native-harmony-61-interop-tester/rnoh-entry/harmony/hvigor/hvigor-config.json5'
27
+ ]).catch(console.error);
@@ -271,7 +271,7 @@ export class Autolinking {
271
271
  const managedNativeDependencySpecifierByName: Record<string, string> = {};
272
272
  for (const library of autolinkableLibraries) {
273
273
  managedNativeDependencySpecifierByName[library.ohPackageName] =
274
- 'file:' + library.harFilePathRelativeToHarmony;
274
+ `file:${library.harFilePathRelativeToHarmony}`.split(pathUtils.sep).join('/');
275
275
  }
276
276
  return {
277
277
  skippedLibraryNpmPackageNames: input.skippedLibraryNpmPackageNames,
@@ -1,3 +1,4 @@
1
+ import pathUtils from 'path';
1
2
  import { AbsolutePath } from '../../core';
2
3
  import {
3
4
  CodeGenerator,
@@ -10,6 +11,9 @@ import { GlueCodeDataV1 } from './AppBuildTimeGlueCodeGenerator';
10
11
  import { NativeModuleCodeGenerator } from './NativeModuleCodeGenerator';
11
12
  import { ArkTSComponentCodeGeneratorArkTS } from './ArkTSComponentCodeGeneratorArkTS';
12
13
 
14
+ // The name of rnoh OHOS module
15
+ const RNOH_OHOS_NAME = '@rnoh/react-native-openharmony';
16
+
13
17
  /**
14
18
  * Generates code for libraries built on top of RNOH's ArkTS architecture.
15
19
  */
@@ -28,17 +32,18 @@ export class UberGeneratorV1 implements CodeGenerator<UberSchema> {
28
32
 
29
33
  generate(uberSchema: UberSchema) {
30
34
  const fileContentByPath = new Map<AbsolutePath, string>();
35
+ const isRNOHModulePath = this.etsOutputPath.getValue().endsWith(`${RNOH_OHOS_NAME}/generated`.replace(/\//g, pathUtils.sep));
31
36
  const componentCodeGenerator = new ArkTSComponentCodeGeneratorArkTS(
32
37
  this.cppOutputPath,
33
38
  this.etsOutputPath.copyWithNewSegment('components'),
34
39
  this.codegenNoticeLines,
35
- '../../ts'
40
+ isRNOHModulePath ? '../../ts' : `${RNOH_OHOS_NAME}/ts`
36
41
  );
37
42
  const nativeModuleCodeGenerator = new NativeModuleCodeGenerator(
38
43
  this.cppOutputPath,
39
44
  this.etsOutputPath.copyWithNewSegment('turboModules'),
40
45
  this.codegenNoticeLines,
41
- '../../ts'
46
+ isRNOHModulePath ? '../../ts' : `${RNOH_OHOS_NAME}/ts`
42
47
  );
43
48
  const generatorBySpecType = {
44
49
  Component: componentCodeGenerator,
@@ -1,3 +1,4 @@
1
+ import pathUtils from 'path';
1
2
  import { AbsolutePath } from '../../core';
2
3
  import { CodeGenerator } from '../core';
3
4
  import {
@@ -8,6 +9,9 @@ import { NativeModuleCodeGenerator } from './NativeModuleCodeGenerator';
8
9
  import { GlueCodeDataV2 } from './AppBuildTimeGlueCodeGenerator';
9
10
  import { SharedComponentCodeGenerator } from './SharedComponentCodeGenerator';
10
11
 
12
+ // The name of rnoh OHOS module
13
+ const RNOH_OHOS_NAME = '@rnoh/react-native-openharmony';
14
+
11
15
  /**
12
16
  * Generates code for libraries built on top of RNOH's C-API architecture.
13
17
  */
@@ -78,6 +82,7 @@ export class UberGeneratorV2 implements CodeGenerator<LibraryData[]> {
78
82
  .getSpecSchemaByFilenameMap()
79
83
  .entries()) {
80
84
  if (specSchema.type === 'NativeModule') {
85
+ const isRNOHModulePath = this.etsOutputPath.getValue().endsWith(`${RNOH_OHOS_NAME}/generated`.replace(/\//g, pathUtils.sep));
81
86
  const nativeModuleCodeGenerator = new NativeModuleCodeGenerator(
82
87
  libraryCppOutput.copyWithNewSegment(
83
88
  'RNOH',
@@ -86,7 +91,7 @@ export class UberGeneratorV2 implements CodeGenerator<LibraryData[]> {
86
91
  ),
87
92
  this.etsOutputPath.copyWithNewSegment('turboModules'),
88
93
  this.codegenNoticeLines,
89
- '../../ts'
94
+ isRNOHModulePath ? '../../ts' : `${RNOH_OHOS_NAME}/ts`
90
95
  );
91
96
  nativeModuleCodeGenerator
92
97
  .generate(specSchema)
@@ -27,7 +27,12 @@ export const commandCodegenHarmony: Command = {
27
27
  options: [
28
28
  {
29
29
  name: '--rnoh-module-path <path>',
30
- description: 'Specifies the relative path to the rnoh OHOS module',
30
+ description: '[deprecated] Specifies the relative path to the rnoh OHOS module',
31
+ },
32
+ {
33
+ name: '--ets-output-path <path>',
34
+ description:
35
+ 'Specifies the relative path to the output directory intended for storing generated ETS files.',
31
36
  },
32
37
  {
33
38
  name: '--cpp-output-path <path>',
@@ -58,9 +63,12 @@ export const commandCodegenHarmony: Command = {
58
63
  const MAX_SUPPORTED_CODEGEN_VERSION = 2;
59
64
  // prepare the input data
60
65
  validateArgs(args);
61
- const etsOutputPath = new AbsolutePath(
62
- args.rnohModulePath
63
- ).copyWithNewSegment('generated');
66
+ let etsOutputPath = args.etsOutputPath || args.rnohModulePath;
67
+ const isEndWithGenerated = /\/generated\/?$/.test(etsOutputPath);
68
+ etsOutputPath = new AbsolutePath(etsOutputPath);
69
+ if (!isEndWithGenerated) {
70
+ etsOutputPath = etsOutputPath.copyWithNewSegment('generated');
71
+ }
64
72
  const enableSafetyCheck: boolean = args.safetyCheck;
65
73
  const cppOutputPath = new AbsolutePath(args.cppOutputPath);
66
74
  const projectRootPath = new AbsolutePath(args.projectRootPath);
@@ -159,11 +167,13 @@ export const commandCodegenHarmony: Command = {
159
167
  };
160
168
 
161
169
  function validateArgs(args: any) {
162
- if (!args.rnohModulePath) {
170
+ if (!args.rnohModulePath && !args.etsOutputPath) {
163
171
  throw new DescriptiveError({
164
- whatHappened: "--rnoh-module-path argument wasn't provided",
172
+ whatHappened: '--ets-output-path is required',
165
173
  whatCanUserDo: [
166
- 'Please provide a path to the native React Native for Open Harmony module (rnoh) which is probably located somewhere in "<PROJECT_ROOT>/harmony" directory',
174
+ 'Please provide an output path for the ETS file.',
175
+ 'It is recommended to place it in the same directory as the custom component or TurboModule.',
176
+ 'Do not place it inside @rnoh/react-native-openharmony, otherwise a jscrash may occur when using react_native_openharmony_release2.har.'
167
177
  ],
168
178
  });
169
179
  }
@@ -270,8 +270,6 @@ export const commandRunHarmony: Command = {
270
270
  args: [
271
271
  'install',
272
272
  '--all',
273
- '--strict_ssl',
274
- 'true',
275
273
  ],
276
274
  cwd: harmonyProjectPath,
277
275
  shell: true,
@@ -39,13 +39,20 @@ function isSupportedVersion(versionDir: string): boolean {
39
39
  async function getCreatedSimulators(cli: RealCliExecutor, emulator: string): Promise<string[]> {
40
40
  try {
41
41
  let simulatorInfos = '';
42
+ let simulatorInfosFromStderr = '';
42
43
  await cli.run(`"${emulator}"`, {
43
44
  args: ['--list'],
44
45
  shell: true,
45
- onStderr: (msg) => {
46
+ onStdout: (msg) => {
46
47
  simulatorInfos += msg;
47
48
  },
49
+ onStderr: (msg) => {
50
+ simulatorInfosFromStderr += msg;
51
+ },
48
52
  });
53
+ if (simulatorInfos == null || simulatorInfos.trim() === '') {
54
+ simulatorInfos = simulatorInfosFromStderr;
55
+ }
49
56
  if (!simulatorInfos || simulatorInfos.trim() === '' ||
50
57
  simulatorInfos.trim() === '[Empty]' ||
51
58
  simulatorInfos.includes('not ')) {
@@ -324,7 +331,7 @@ export async function launchHarmonySimulator(opt: LaunchOptions): Promise<void>
324
331
  process.platform === 'win32' ? `"${p}"` : p;
325
332
  const args = [
326
333
  '-hvd',
327
- simulatorName[0].trim(),
334
+ quoteIfNeeded(simulatorName[0].trim()),
328
335
  '-path',
329
336
  quoteIfNeeded(paths.instancePath),
330
337
  '-imageRoot',
@@ -1,10 +0,0 @@
1
- {
2
- "app": {
3
- "bundleName": "com.example",
4
- "vendor": "example",
5
- "versionCode": 1000000,
6
- "versionName": "1.0.0",
7
- "icon": "$media:app_icon",
8
- "label": "$string:app_name",
9
- }
10
- }
@@ -1,8 +0,0 @@
1
- {
2
- "string": [
3
- {
4
- "name": "app_name",
5
- "value": "example"
6
- }
7
- ]
8
- }
@@ -1,36 +0,0 @@
1
- {
2
- app: {
3
- products: [
4
- {
5
- name: 'default',
6
- signingConfig: 'default',
7
- compatibleSdkVersion: '5.0.0(12)',
8
- runtimeOS: 'HarmonyOS',
9
- buildOption: {
10
- nativeCompiler: 'BiSheng'
11
- }
12
- },
13
- ],
14
- buildModeSet: [
15
- {
16
- name: 'debug',
17
- },
18
- {
19
- name: 'release',
20
- },
21
- ],
22
- signingConfigs: [],
23
- },
24
- modules: [
25
- {
26
- name: 'entry',
27
- srcPath: './entry',
28
- targets: [
29
- {
30
- name: 'default',
31
- applyToProducts: ['default'],
32
- },
33
- ],
34
- },
35
- ],
36
- }
@@ -1,32 +0,0 @@
1
- {
2
- "files": ["**/*.ts", "**/*.ets"],
3
- "ignore": [
4
- "**/ohosTest/**/*",
5
- "**/node_modules/**/*",
6
- "**/hvigorfile.ts",
7
- "**/node_modules/**/*",
8
- "**/oh_modules/**/*",
9
- "**/build/**/*",
10
- "**/.preview/**/*"
11
- ],
12
- "plugins": ["@typescript-eslint"],
13
- "ruleSet": [],
14
- "rules": {
15
- "@typescript-eslint/await-thenable": "warn",
16
- "@typescript-eslint/consistent-type-imports": "warn",
17
- "@typescript-eslint/explicit-function-return-type": "warn",
18
- "@typescript-eslint/explicit-module-boundary-types": "warn",
19
- "@typescript-eslint/no-dynamic-delete": "warn",
20
- "@typescript-eslint/no-explicit-any": "warn",
21
- "@typescript-eslint/no-for-in-array": "warn",
22
- "@typescript-eslint/no-this-alias": "warn",
23
- "@typescript-eslint/no-unnecessary-type-constraint": "warn",
24
- "@typescript-eslint/no-unsafe-argument": "warn",
25
- "@typescript-eslint/no-unsafe-assignment": "warn",
26
- "@typescript-eslint/no-unsafe-call": "warn",
27
- "@typescript-eslint/no-unsafe-member-access": "warn",
28
- "@typescript-eslint/no-unsafe-return": "warn",
29
- "@typescript-eslint/prefer-literal-enum-member": "warn"
30
- },
31
- "overrides": []
32
- }
@@ -1,18 +0,0 @@
1
- {
2
- "apiType": 'stageMode',
3
- "buildOption": {
4
- "externalNativeOptions": {
5
- "path": "./src/main/cpp/CMakeLists.txt",
6
- "arguments": "",
7
- },
8
- },
9
- "targets": [
10
- {
11
- "name": "default",
12
- "runtimeOS": "HarmonyOS"
13
- },
14
- {
15
- "name": "ohosTest",
16
- }
17
- ]
18
- }
@@ -1,7 +0,0 @@
1
- /node_modules
2
- /.preview
3
- /build
4
- /.cxx
5
- package-lock.json
6
- /oh_modules
7
- /assets
@@ -1,13 +0,0 @@
1
- import { hapTasks } from '@ohos/hvigor-ohos-plugin';
2
- import { createRNOHModulePlugin } from '@rnoh/hvigor-plugin';
3
-
4
- export default {
5
- system: hapTasks,
6
- plugins: [
7
- createRNOHModulePlugin({
8
- codegen: {
9
- rnohModulePath: './oh_modules/@rnoh/react-native-openharmony',
10
- },
11
- }),
12
- ],
13
- };
@@ -1,9 +0,0 @@
1
- {
2
- "license": "ISC",
3
- "devDependencies": {},
4
- "name": "entry",
5
- "description": "example description",
6
- "version": "1.0.0",
7
- "dependencies": {
8
- }
9
- }
@@ -1,27 +0,0 @@
1
- cmake_minimum_required(VERSION 3.11)
2
- project(rnapp)
3
-
4
- set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
5
- set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
6
- set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../oh_modules/@rnoh/react-native-openharmony/src/main/cpp")
7
- set(RNOH_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated")
8
- set(LOG_VERBOSITY_LEVEL 1)
9
- set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
10
- set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
11
- set(WITH_HITRACE_SYSTRACE ON)
12
- set(WITH_HITRACE_REACT_MARKER ON)
13
- set(OH_MODULES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../oh_modules") # required by 'autolink_libraries'
14
-
15
- add_subdirectory("${RNOH_CPP_DIR}" ./rn)
16
-
17
- include("${CMAKE_CURRENT_SOURCE_DIR}/autolinking.cmake")
18
-
19
- file(GLOB GENERATED_CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp") # this line is needed by codegen v1
20
- add_library(rnoh_app SHARED
21
- ${GENERATED_CPP_FILES}
22
- "./PackageProvider.cpp"
23
- "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
24
- )
25
- target_link_libraries(rnoh_app PUBLIC rnoh)
26
-
27
- autolink_libraries(rnoh_app)
@@ -1,13 +0,0 @@
1
- #include "RNOH/PackageProvider.h"
2
- #include "RNOHPackagesFactory.h"
3
- #include "generated/RNOHGeneratedPackage.h"
4
-
5
- using namespace rnoh;
6
-
7
- std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(
8
- Package::Context ctx) {
9
- auto packages = createRNOHPackages(ctx); // <= autolinking
10
- packages.push_back(std::make_shared<RNOHGeneratedPackage>(
11
- ctx)); // generated by codegen-harmony v1 on app preBuilt stage)
12
- return packages;
13
- }
@@ -1,4 +0,0 @@
1
- generated/
2
- /RNOHPackagesFactory.h
3
- autolinking.cmake
4
-
@@ -1,8 +0,0 @@
1
- import type { RNPackageContext, RNOHPackage } from '@rnoh/react-native-openharmony';
2
- import { createRNOHPackages as createRNOHPackagesAutolinking } from "./RNOHPackagesFactory"
3
-
4
- export function getRNOHPackages(ctx: RNPackageContext): RNOHPackage[] {
5
- return [
6
- ...createRNOHPackagesAutolinking(ctx)
7
- ]
8
- }
@@ -1,11 +0,0 @@
1
- import {RNAbility} from '@rnoh/react-native-openharmony';
2
-
3
- export default class EntryAbility extends RNAbility {
4
- override getPagePath() {
5
- return 'pages/Index';
6
- }
7
-
8
- override getRNOHWorkerScriptUrl() {
9
- return "entry/ets/workers/RNOHWorker.ets"
10
- }
11
- }
@@ -1 +0,0 @@
1
- /RNOHPackagesFactory.ets
@@ -1,16 +0,0 @@
1
- /**
2
- * Importing some ets files in the following way results in runtime errors e.g.
3
- * import { setupRNOHWorker } from "@rnoh/react-native-openharmony"
4
- *
5
- * It looks like this is ArkTS problem and it may be fixed in the future.
6
- * For the time being, use direct imports.
7
- */
8
- import { setupRNOHWorker } from "@rnoh/react-native-openharmony/src/main/ets/setupRNOHWorker"
9
- import { getRNOHPackages } from "../PackageProvider"
10
-
11
- setupRNOHWorker({
12
- createWorkerRNInstanceConfig: (_rnInstanceName) => {
13
- return { thirdPartyPackagesFactory: getRNOHPackages }
14
- }
15
- })
16
-
@@ -1,65 +0,0 @@
1
- {
2
- "module": {
3
- "name": "entry",
4
- "type": "entry",
5
- "description": "$string:module_desc",
6
- "mainElement": "EntryAbility",
7
- "deviceTypes": [
8
- "default"
9
- ],
10
- "deliveryWithInstall": true,
11
- "installationFree": false,
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
- ],
20
- "requestPermissions": [
21
- {
22
- "name": "ohos.permission.INTERNET"
23
- },
24
- {
25
- "name": "ohos.permission.VIBRATE"
26
- }
27
- ],
28
- "metadata": [
29
- {
30
- "name": "OPTLazyForEach",
31
- "value": "true",
32
- },
33
- {
34
- "name": "can_preview_text",
35
- "value": "true",
36
- },
37
- {
38
- "name": "halfLeading",
39
- "value": "true",
40
- },
41
- ],
42
- "abilities": [
43
- {
44
- "name": "EntryAbility",
45
- "srcEntry": "./ets/entryability/EntryAbility.ets",
46
- "description": "$string:EntryAbility_desc",
47
- "icon": "$media:layered_image",
48
- "label": "$string:EntryAbility_label",
49
- "startWindowIcon": "$media:startIcon",
50
- "startWindowBackground": "$color:start_window_background",
51
- "visible": true,
52
- "skills": [
53
- {
54
- "entities": [
55
- "entity.system.home"
56
- ],
57
- "actions": [
58
- "action.system.home"
59
- ],
60
- }
61
- ]
62
- }
63
- ]
64
- }
65
- }
@@ -1,8 +0,0 @@
1
- {
2
- "color": [
3
- {
4
- "name": "start_window_background",
5
- "value": "#FFFFFF"
6
- }
7
- ]
8
- }
@@ -1,16 +0,0 @@
1
- {
2
- "string": [
3
- {
4
- "name": "module_desc",
5
- "value": "module description"
6
- },
7
- {
8
- "name": "EntryAbility_desc",
9
- "value": "description"
10
- },
11
- {
12
- "name": "EntryAbility_label",
13
- "value": "template app"
14
- }
15
- ]
16
- }
@@ -1,7 +0,0 @@
1
- {
2
- "layered-image":
3
- {
4
- "background" : "$media:background",
5
- "foreground" : "$media:foreground"
6
- }
7
- }
@@ -1,2 +0,0 @@
1
- export default function testsuite() {
2
- }
@@ -1,13 +0,0 @@
1
- {
2
- "module": {
3
- "name": "entry_test",
4
- "type": "feature",
5
- "deviceTypes": [
6
- "phone",
7
- "tablet",
8
- "2in1"
9
- ],
10
- "deliveryWithInstall": true,
11
- "installationFree": false
12
- }
13
- }
@@ -1,16 +0,0 @@
1
- /build-profile.json5
2
-
3
- # ---
4
-
5
- /local.properties
6
- /.idea
7
- **/build
8
- /.hvigor
9
- .cxx
10
- /.clangd
11
- /.clang-format
12
- /.clang-tidy
13
- /oh_modules
14
- hvigorw
15
- hvigorw.bat
16
- hvigor/hvigor-wrapper.js
@@ -1,22 +0,0 @@
1
- {
2
- modelVersion: '5.0.0',
3
- dependencies: {
4
- // "@rnoh/hvigor-plugin": "../../node_modules/<RNOH_CLI>/harmony/rnoh-hvigor-plugin-X.X.X.tgz",
5
- },
6
- execution: {
7
- // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */
8
- // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
9
- // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
10
- // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
11
- // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
12
- },
13
- logging: {
14
- // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
15
- },
16
- debugging: {
17
- // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
18
- },
19
- nodeOptions: {
20
- // "maxOldSpaceSize": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */
21
- },
22
- }
@@ -1,7 +0,0 @@
1
- import { appTasks } from '@ohos/hvigor-ohos-plugin';
2
- import { createRNOHProjectPlugin } from '@rnoh/hvigor-plugin';
3
-
4
- export default {
5
- system: appTasks,
6
- plugins: [createRNOHProjectPlugin()],
7
- };