@react-native-oh/react-native-harmony-cli 0.0.36 → 0.77.18

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 (228) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -4
  3. package/dist/autolinking/Autolinking.js +13 -16
  4. package/dist/autolinking/index.js +0 -6
  5. package/dist/codegen/core/CodeGenerator.js +0 -6
  6. package/dist/codegen/core/CodegenError.js +0 -6
  7. package/dist/codegen/core/EventUtils.js +0 -6
  8. package/dist/codegen/core/TypeAnnotationToTS.js +0 -6
  9. package/dist/codegen/core/UberSchema.js +2 -11
  10. package/dist/codegen/core/index.js +0 -6
  11. package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +2 -7
  12. package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +0 -6
  13. package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +0 -6
  14. package/dist/codegen/generators/CppComponentCodeGenerator.js +0 -6
  15. package/dist/codegen/generators/LibGlueCodeGenerator.js +2 -8
  16. package/dist/codegen/generators/NativeModuleCodeGenerator.js +1 -7
  17. package/dist/codegen/generators/SharedComponentCodeGenerator.js +0 -6
  18. package/dist/codegen/generators/UberGeneratorV1.js +0 -6
  19. package/dist/codegen/generators/UberGeneratorV2.js +0 -6
  20. package/dist/codegen/generators/index.js +0 -6
  21. package/dist/codegen/index.js +0 -6
  22. package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +0 -6
  23. package/dist/codegen/templates/BasePackageHTemplate.js +12 -7
  24. package/dist/codegen/templates/ComponentDescriptorHTemplate.js +1 -6
  25. package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +0 -6
  26. package/dist/codegen/templates/ComponentUtilsTSTemplate.js +0 -6
  27. package/dist/codegen/templates/IndexTSTemplate.js +0 -6
  28. package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +12 -7
  29. package/dist/codegen/templates/TurboModuleCppTemplate.js +0 -6
  30. package/dist/codegen/templates/TurboModuleHTemplate.js +0 -6
  31. package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +0 -6
  32. package/dist/codegen/templates/index.js +0 -6
  33. package/dist/commands/bundle-harmony.js +131 -36
  34. package/dist/commands/clean-harmony.js +84 -0
  35. package/dist/commands/codegen-harmony.js +0 -6
  36. package/dist/commands/codegen-lib-harmony.js +6 -12
  37. package/dist/commands/index.js +2 -9
  38. package/dist/commands/init-harmony.js +226 -0
  39. package/dist/commands/init.js +0 -0
  40. package/dist/commands/link-harmony.js +12 -16
  41. package/dist/commands/types.js +0 -6
  42. package/dist/commands/verify-package-harmony.js +6 -10
  43. package/dist/core/AbsolutePath.js +3 -6
  44. package/dist/core/CodegenConfig.js +0 -6
  45. package/dist/core/DescriptiveError.js +0 -6
  46. package/dist/core/FileSystem.js +0 -6
  47. package/dist/core/OHPackageJSON5.js +0 -6
  48. package/dist/core/ProjectDependenciesManager.js +6 -14
  49. package/dist/core/ValidationError.js +0 -6
  50. package/dist/core/ValueObject.js +0 -6
  51. package/dist/core/fs.js +13 -6
  52. package/dist/core/index.js +0 -6
  53. package/dist/index.js +2 -9
  54. package/dist/init/templates/AppScopeAppJSON5Template.js +30 -0
  55. package/dist/init/templates/AppScopeStringVarTemplate.js +28 -0
  56. package/dist/init/templates/EntryIndexTemplate.js +65 -0
  57. package/dist/init/templates/EntryStringVarTemplate.js +38 -0
  58. package/dist/init/templates/HvigorConfigJson5Template.js +44 -0
  59. package/dist/init/templates/MetroConfigTemplate.js +47 -0
  60. package/dist/init/templates/OhPackageJson5Template.js +37 -0
  61. package/dist/init/templates/harmony/AppScope/app.json5 +10 -0
  62. package/dist/init/templates/harmony/AppScope/resources/base/element/string.json +8 -0
  63. package/dist/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  64. package/dist/init/templates/harmony/build-profile.json5 +36 -0
  65. package/dist/init/templates/harmony/codelinter.json +32 -0
  66. package/dist/init/templates/harmony/entry/build-profile.json5 +18 -0
  67. package/dist/init/templates/harmony/entry/gitignore +7 -0
  68. package/dist/init/templates/harmony/entry/hvigorfile.ts +13 -0
  69. package/dist/init/templates/harmony/entry/oh-package.json5 +9 -0
  70. package/dist/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +27 -0
  71. package/dist/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +13 -0
  72. package/dist/init/templates/harmony/entry/src/main/cpp/gitignore +4 -0
  73. package/dist/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +8 -0
  74. package/dist/init/templates/harmony/entry/src/main/ets/codegen/gitignore +2 -0
  75. package/dist/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +11 -0
  76. package/dist/init/templates/harmony/entry/src/main/ets/gitignore +1 -0
  77. package/dist/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
  78. package/dist/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +16 -0
  79. package/dist/init/templates/harmony/entry/src/main/module.json5 +58 -0
  80. package/dist/init/templates/harmony/entry/src/main/resources/base/element/color.json +8 -0
  81. package/dist/init/templates/harmony/entry/src/main/resources/base/element/string.json +16 -0
  82. package/dist/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
  83. package/dist/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
  84. package/dist/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +7 -0
  85. package/dist/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
  86. package/dist/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
  87. package/dist/init/templates/harmony/entry/src/main/resources/gitignore +1 -0
  88. package/dist/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +2 -0
  89. package/dist/init/templates/harmony/entry/src/ohosTest/module.json5 +13 -0
  90. package/dist/init/templates/harmony/gitignore +16 -0
  91. package/dist/init/templates/harmony/hvigor/hvigor-config.json5 +22 -0
  92. package/dist/init/templates/harmony/hvigorfile.ts +7 -0
  93. package/dist/init/templates/index.js +21 -0
  94. package/dist/io/CliExecutor.js +0 -6
  95. package/dist/io/Logger.js +0 -6
  96. package/dist/io/RealFS.js +10 -6
  97. package/dist/io/TarGz.js +2 -8
  98. package/dist/io/__fixtures__.js +0 -6
  99. package/dist/io/fsUtils.js +0 -6
  100. package/dist/io/index.js +1 -6
  101. package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +0 -6
  102. package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +0 -6
  103. package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +0 -6
  104. package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +0 -6
  105. package/dist/package-verifier/checks/index.js +0 -6
  106. package/dist/package-verifier/index.js +0 -6
  107. package/dist/package-verifier/types.js +0 -6
  108. package/dist/package-verifier/verify-package.js +1 -7
  109. package/jest.config.js +0 -7
  110. package/package.json +15 -18
  111. package/react-native.config.js +0 -7
  112. package/scripts/copy-template.js +18 -0
  113. package/src/autolinking/Autolinking.test.ts +54 -18
  114. package/src/autolinking/Autolinking.ts +23 -20
  115. package/src/autolinking/index.ts +1 -8
  116. package/src/codegen/core/CodeGenerator.ts +0 -7
  117. package/src/codegen/core/CodegenError.ts +0 -7
  118. package/src/codegen/core/EventUtils.ts +0 -7
  119. package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -7
  120. package/src/codegen/core/TypeAnnotationToTS.ts +3 -8
  121. package/src/codegen/core/UberSchema.ts +3 -12
  122. package/src/codegen/core/index.ts +0 -7
  123. package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +5 -8
  124. package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +0 -7
  125. package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +0 -7
  126. package/src/codegen/generators/CppComponentCodeGenerator.ts +0 -7
  127. package/src/codegen/generators/LibGlueCodeGenerator.ts +2 -9
  128. package/src/codegen/generators/NativeModuleCodeGenerator.ts +1 -8
  129. package/src/codegen/generators/SharedComponentCodeGenerator.ts +0 -7
  130. package/src/codegen/generators/UberGeneratorV1.ts +0 -7
  131. package/src/codegen/generators/UberGeneratorV2.ts +0 -7
  132. package/src/codegen/generators/index.ts +0 -7
  133. package/src/codegen/index.ts +0 -7
  134. package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +0 -7
  135. package/src/codegen/templates/BasePackageHTemplate.ts +13 -8
  136. package/src/codegen/templates/ComponentDescriptorHTemplate.ts +1 -7
  137. package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +0 -7
  138. package/src/codegen/templates/ComponentUtilsTSTemplate.ts +0 -7
  139. package/src/codegen/templates/IndexTSTemplate.ts +0 -7
  140. package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +13 -8
  141. package/src/codegen/templates/TurboModuleCppTemplate.ts +0 -7
  142. package/src/codegen/templates/TurboModuleHTemplate.ts +0 -7
  143. package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +0 -7
  144. package/src/codegen/templates/index.ts +0 -7
  145. package/src/commands/bundle-harmony.ts +174 -39
  146. package/src/commands/clean-harmony.ts +54 -0
  147. package/src/commands/codegen-harmony.ts +0 -7
  148. package/src/commands/codegen-lib-harmony.ts +6 -13
  149. package/src/commands/index.ts +2 -10
  150. package/src/commands/init-harmony.ts +299 -0
  151. package/src/commands/link-harmony.ts +13 -18
  152. package/src/commands/types.ts +0 -7
  153. package/src/commands/verify-package-harmony.ts +7 -10
  154. package/src/core/AbsolutePath.ts +4 -7
  155. package/src/core/CodegenConfig.ts +0 -7
  156. package/src/core/DescriptiveError.ts +0 -7
  157. package/src/core/FileSystem.ts +5 -8
  158. package/src/core/OHPackageJSON5.ts +0 -7
  159. package/src/core/PackageJSON.ts +0 -6
  160. package/src/core/ProjectDependenciesManager.ts +14 -22
  161. package/src/core/ValidationError.ts +0 -7
  162. package/src/core/ValueObject.ts +0 -7
  163. package/src/core/fs.ts +13 -7
  164. package/src/core/index.ts +0 -7
  165. package/src/index.ts +4 -13
  166. package/src/init/templates/AppScopeAppJSON5Template.ts +24 -0
  167. package/src/init/templates/AppScopeStringVarTemplate.ts +22 -0
  168. package/src/init/templates/EntryIndexTemplate.ts +59 -0
  169. package/src/init/templates/EntryStringVarTemplate.ts +31 -0
  170. package/src/init/templates/HvigorConfigJson5Template.ts +40 -0
  171. package/src/init/templates/MetroConfigTemplate.ts +41 -0
  172. package/src/init/templates/OhPackageJson5Template.ts +31 -0
  173. package/src/init/templates/harmony/AppScope/app.json5 +10 -0
  174. package/src/init/templates/harmony/AppScope/resources/base/element/string.json +8 -0
  175. package/src/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  176. package/src/init/templates/harmony/build-profile.json5 +36 -0
  177. package/src/init/templates/harmony/codelinter.json +32 -0
  178. package/src/init/templates/harmony/entry/build-profile.json5 +18 -0
  179. package/src/init/templates/harmony/entry/gitignore +7 -0
  180. package/src/init/templates/harmony/entry/hvigorfile.ts +13 -0
  181. package/src/init/templates/harmony/entry/oh-package.json5 +9 -0
  182. package/src/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +27 -0
  183. package/src/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +13 -0
  184. package/src/init/templates/harmony/entry/src/main/cpp/gitignore +4 -0
  185. package/src/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +8 -0
  186. package/src/init/templates/harmony/entry/src/main/ets/codegen/gitignore +2 -0
  187. package/src/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +11 -0
  188. package/src/init/templates/harmony/entry/src/main/ets/gitignore +1 -0
  189. package/src/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
  190. package/src/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +16 -0
  191. package/src/init/templates/harmony/entry/src/main/module.json5 +58 -0
  192. package/src/init/templates/harmony/entry/src/main/resources/base/element/color.json +8 -0
  193. package/src/init/templates/harmony/entry/src/main/resources/base/element/string.json +16 -0
  194. package/src/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
  195. package/src/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
  196. package/src/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +7 -0
  197. package/src/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
  198. package/src/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
  199. package/src/init/templates/harmony/entry/src/main/resources/gitignore +1 -0
  200. package/src/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +2 -0
  201. package/src/init/templates/harmony/entry/src/ohosTest/module.json5 +13 -0
  202. package/src/init/templates/harmony/gitignore +16 -0
  203. package/src/init/templates/harmony/hvigor/hvigor-config.json5 +22 -0
  204. package/src/init/templates/harmony/hvigorfile.ts +7 -0
  205. package/src/init/templates/index.ts +5 -0
  206. package/src/io/CliExecutor.ts +1 -8
  207. package/src/io/Logger.ts +0 -7
  208. package/src/io/RealFS.ts +15 -8
  209. package/src/io/TarGz.ts +1 -8
  210. package/src/io/__fixtures__.ts +1 -8
  211. package/src/io/fsUtils.ts +1 -7
  212. package/src/io/index.ts +1 -7
  213. package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +0 -7
  214. package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +0 -7
  215. package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +0 -7
  216. package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +0 -7
  217. package/src/package-verifier/checks/index.ts +0 -7
  218. package/src/package-verifier/index.ts +0 -7
  219. package/src/package-verifier/types.ts +0 -7
  220. package/src/package-verifier/verify-package.ts +0 -7
  221. package/tsconfig.build.json +2 -5
  222. package/tsconfig.json +4 -0
  223. package/dist/commands/create-metro-host-constants.js +0 -67
  224. package/dist/commands/pack-harmony.js +0 -106
  225. package/dist/commands/unpack-harmony.js +0 -189
  226. package/src/commands/create-metro-host-constants.ts +0 -55
  227. package/src/commands/pack-harmony.ts +0 -128
  228. package/src/commands/unpack-harmony.ts +0 -238
package/package.json CHANGED
@@ -1,19 +1,22 @@
1
1
  {
2
2
  "name": "@react-native-oh/react-native-harmony-cli",
3
- "version": "0.0.36",
3
+ "version": "0.77.18",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
7
7
  "access": "public"
8
8
  },
9
9
  "scripts": {
10
- "build": "tsc --outDir dist -p tsconfig.build.json",
11
- "prepack": "npm run build",
10
+ "build": "tsc --outDir dist -p tsconfig.build.json && node ./scripts/copy-template.js",
11
+ "prepack": "npm run build && npm run _recreate-hvigor-plugin",
12
+ "_recreate-hvigor-plugin": "cd ../react-native-harmony-hvigor-plugin && npm i && npm run deploy && cd ../react-native-harmony-cli",
12
13
  "verify": "tsc --noEmit && npm run test",
13
14
  "test": "npm run build && jest",
14
15
  "test:codegen": "jest ./src/codegen/.* && npm run build && jest tests/codegen.*",
15
16
  "rn": "npm run build && react-native",
16
- "prepublishOnly": "npm run verify"
17
+ "dev": "tsc --outDir dist -p tsconfig.build.json --watch",
18
+ "prepublishOnly": "npm run build",
19
+ "deploy": "npm run verify && npm publish"
17
20
  },
18
21
  "bin": {
19
22
  "rnoh-cli": "dist/commands/init.js"
@@ -22,7 +25,7 @@
22
25
  "author": "",
23
26
  "license": "MIT",
24
27
  "peerDependencies": {
25
- "metro": "*"
28
+ "metro": "^0.81.0"
26
29
  },
27
30
  "main": "dist/index.js",
28
31
  "devDependencies": {
@@ -31,40 +34,34 @@
31
34
  "@types/adm-zip": "^0.5.5",
32
35
  "@types/fs-extra": "^11.0.1",
33
36
  "@types/jest": "^29.5.1",
34
- "@types/jszip": "^3.4.1",
35
37
  "@types/mustache": "^4.2.5",
36
38
  "@types/tar": "^6.1.5",
37
39
  "@types/tmp": "^0.2.3",
38
40
  "directory-tree": "^3.5.1",
39
41
  "execa": "npm:@esm2cjs/execa@^6.1.1-cjs.1",
40
42
  "jest": "^29.5.0",
41
- "react-native": "^0.72.0",
43
+ "react-native": "^0.77.1",
42
44
  "ts-jest": "^29.1.0",
43
- "ts-node": "^10.9.1",
44
45
  "typescript": "^5.0.4"
45
46
  },
46
47
  "dependencies": {
47
48
  "@react-native-community/cli-tools": "^13.6.5",
48
- "@react-native/codegen": "0.74.0",
49
+ "@react-native/codegen": "0.77.1",
49
50
  "@tsconfig/recommended": "^1.0.2",
50
- "adm-zip": "^0.5.12",
51
51
  "case": "^1.6.3",
52
52
  "chalk": "^4",
53
53
  "commander": "^14.0.0",
54
54
  "fs-extra": "^11.1.1",
55
- "glob": "^10.2.6",
56
- "ignore": "^5.2.4",
57
- "inquirer": "^12.7.0",
55
+ "inquirer": "^12.6.3",
58
56
  "json5": "^2.2.3",
59
57
  "memfs": "4.12.0",
60
58
  "mustache": "^4.2.0",
61
59
  "tar": "^6.1.15",
62
- "tmp": "^0.2.1",
63
- "metro": "0.82.5"
60
+ "tmp": "^0.2.1"
64
61
  },
65
- "homepage": "https://gitee.com/openharmony-sig/ohos_react_native",
62
+ "homepage": "https://gitcode.com/openharmony-sig/ohos_react_native",
66
63
  "repository": {
67
- "type": "gitee",
68
- "url": "https://gitee.com/openharmony-sig/ohos_react_native"
64
+ "type": "gitcode",
65
+ "url": "https://gitcode.com/openharmony-sig/ohos_react_native"
69
66
  }
70
67
  }
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  const { config: harmonyConfig } = require('./dist');
9
2
 
10
3
  /**
@@ -0,0 +1,18 @@
1
+ const fs = require('fs-extra');
2
+ const path = require('path');
3
+
4
+ const templatesSrc = path.join(__dirname, '../src/init/templates/harmony');
5
+ const templatesDest = path.join(__dirname, '../dist/init/templates/harmony');
6
+ async function copyTemplate() {
7
+ try {
8
+ if (await fs.pathExists(templatesDest)) {
9
+ await fs.remove(templatesDest);
10
+ }
11
+ await fs.copy(templatesSrc, templatesDest);
12
+ console.log('Templates folder copied successfully!');
13
+ } catch (err) {
14
+ console.error('Error copying templates folder:', err);
15
+ }
16
+ }
17
+
18
+ copyTemplate();
@@ -1,14 +1,8 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  import { Autolinking, AutolinkingConfig } from './Autolinking';
9
2
  import { NestedDirectoryJSON } from 'memfs';
10
- import { AbsolutePath, DescriptiveError } from '../core';
3
+ import { AbsolutePath, DescriptiveError } from '../core/';
11
4
  import { MockedLogger, MemFS } from '../io/__fixtures__';
5
+ import pathUtils from "node:path"
12
6
 
13
7
  function createAutolinking({
14
8
  fsStructure,
@@ -98,7 +92,7 @@ it('should generate correct templates with scoped package default configuration'
98
92
  await runAutolinking();
99
93
 
100
94
  expect(
101
- memFS.readTextSync(new AbsolutePath('./harmony/oh-package.json5'))
95
+ memFS.readTextSync(new AbsolutePath('./harmony/oh-package.json5')).replace(/\\\\/g, '/')
102
96
  ).toBe(
103
97
  `
104
98
  {
@@ -162,7 +156,7 @@ std::vector<rnoh::Package::Shared> createRNOHPackages(const rnoh::Package::Conte
162
156
  # DO NOT modify it manually, your changes WILL be overwritten.
163
157
  cmake_minimum_required(VERSION 3.5)
164
158
 
165
- # @api
159
+ # @actor RNOH_APP
166
160
  function(autolink_libraries target)
167
161
  add_subdirectory("\${OH_MODULES_DIR}/@rnoh/rnoh--link-scoped/src/main/cpp" ./rnoh__rnoh__link_scoped)
168
162
 
@@ -210,9 +204,15 @@ it('should handle custom autolinking configuration', async () => {
210
204
  expect(memFS.readTextSync(output.etsRNOHPackagesFactoryPath)).toContain(
211
205
  'CustomEtsClass'
212
206
  );
207
+ expect(memFS.readTextSync(output.etsRNOHPackagesFactoryPath)).not.toContain(
208
+ 'CustomCppClass'
209
+ );
213
210
  expect(memFS.readTextSync(output.cppRNOHPackagesFactoryPath)).toContain(
214
211
  'CustomCppClass'
215
212
  );
213
+ expect(memFS.readTextSync(output.cppRNOHPackagesFactoryPath)).not.toContain(
214
+ 'CustomEtsClass'
215
+ );
216
216
  expect(memFS.readTextSync(output.cmakeAutolinkingPath)).toContain(
217
217
  'custom_cmake_target'
218
218
  );
@@ -323,14 +323,14 @@ it('should log updated files', async () => {
323
323
  const { logs } = await runAutolinking();
324
324
 
325
325
  const combinedLogs = logs.map((log) => log.msg).join('\n');
326
- expect(combinedLogs).toContain('harmony/entry/src/main/cpp/autolink.cmake');
327
- expect(combinedLogs).toContain(
328
- 'harmony/entry/src/main/ets/RNOHPackageFactory.ets'
326
+ expect(combinedLogs).toContain(pathUtils.normalize('harmony/entry/src/main/cpp/autolink.cmake'));
327
+ expect(combinedLogs).toContain(pathUtils.normalize(
328
+ 'harmony/entry/src/main/ets/RNOHPackageFactory.ets')
329
329
  );
330
- expect(combinedLogs).toContain(
331
- 'harmony/entry/src/main/cpp/RNOHPackageFactory.h'
330
+ expect(combinedLogs).toContain(pathUtils.normalize(
331
+ 'harmony/entry/src/main/cpp/RNOHPackageFactory.h')
332
332
  );
333
- expect(combinedLogs).toContain('harmony/oh-package.json5');
333
+ expect(combinedLogs).toContain(pathUtils.normalize('harmony/oh-package.json5'));
334
334
  });
335
335
 
336
336
  it('should log linked and skipped packages', async () => {
@@ -446,7 +446,6 @@ it('should link only specified packages', async () => {
446
446
  expect(combinedLogs).toContain('[skip] ignored-package');
447
447
  });
448
448
 
449
-
450
449
  it('should link by default only those packages that support autolinking', async () => {
451
450
  const { runAutolinking } = createAutolinking({
452
451
  fsStructure: {
@@ -480,4 +479,41 @@ it('should link by default only those packages that support autolinking', async
480
479
  const combinedLogs = logs.map((log) => log.msg).join('\n');
481
480
  expect(combinedLogs).toContain('[link] autolinkable-package');
482
481
  expect(combinedLogs).toContain('[skip] not-autolinkable-package');
483
- });
482
+ });
483
+
484
+ it('not delete packages with two hars', async () => {
485
+ const { runAutolinking, memFS } = createAutolinking({
486
+ fsStructure: {
487
+ ...baseFileStructure,
488
+ node_modules: {
489
+ '@rnoh': {
490
+ 'multiple-har': {
491
+ harmony: {
492
+ 'multiple_har.har': '',
493
+ 'some_other_har.har': '',
494
+ },
495
+ 'package.json': JSON.stringify({
496
+ name: '@rnoh/multiple-har',
497
+ harmony: {
498
+ autolinking: null,
499
+ },
500
+ }),
501
+ },
502
+ },
503
+ },
504
+ harmony: {
505
+ ...baseFileStructure.harmony,
506
+ 'oh-package.json5': `{
507
+ "dependencies": {
508
+ "@rnoh/multiple-har": "file:../node_modules/@rnoh/multiple-har/harmony/multiple_har.har",
509
+ }
510
+ }`,
511
+ },
512
+ },
513
+ });
514
+
515
+ const output = await runAutolinking();
516
+
517
+ const ohPackageContent = memFS.readTextSync(output.ohPackagePath);
518
+ expect(ohPackageContent).toContain('@rnoh/multiple-har');
519
+ });
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  import JSON5 from 'json5';
9
2
  import {
10
3
  AbsolutePath,
@@ -15,6 +8,7 @@ import {
15
8
  import Mustache from 'mustache';
16
9
  import Case from 'case';
17
10
  import { Logger } from '../io';
11
+ import pathUtils from 'node:path';
18
12
 
19
13
  type Version = string;
20
14
  type DependencySpecifier = `file:${string}` | Version;
@@ -88,7 +82,7 @@ const CPP_RNOH_PACKAGES_FACTORY_TEMPLATE = `
88
82
  #pragma once
89
83
  #include "RNOH/Package.h"
90
84
  {{#libraries}}
91
- #include "{{etsRNOHPackageClassName}}.h"
85
+ #include "{{cppRNOHPackageClassName}}.h"
92
86
  {{/libraries}}
93
87
 
94
88
  std::vector<rnoh::Package::Shared> createRNOHPackages(const rnoh::Package::Context &ctx) {
@@ -105,7 +99,7 @@ const CMAKE_AUTOLINKING_TEMPLATE = `
105
99
  # DO NOT modify it manually, your changes WILL be overwritten.
106
100
  cmake_minimum_required(VERSION 3.5)
107
101
 
108
- # @api
102
+ # @actor RNOH_APP
109
103
  function(autolink_libraries target)
110
104
  {{#libraries}}
111
105
  add_subdirectory("\${OH_MODULES_DIR}/{{{ohPackageName}}}/src/main/cpp" ./{{cmakeLibraryTargetName}})
@@ -124,7 +118,10 @@ endfunction()
124
118
  `.trimStart();
125
119
 
126
120
  export class Autolinking {
127
- constructor(private fs: FS, private logger: Logger) {}
121
+ constructor(
122
+ private fs: FS,
123
+ private logger: Logger
124
+ ) { }
128
125
 
129
126
  async prepareInput(config: AutolinkingConfig): Promise<AutolinkingInput> {
130
127
  if (
@@ -151,21 +148,21 @@ export class Autolinking {
151
148
  const skippedLibraryNpmPackageNames: string[] = [];
152
149
  await new ProjectDependenciesManager(this.fs, projectRootPath).forEachAsync(
153
150
  (dependency) => {
154
- const harFilePath = dependency.getHarFilePath();
155
- if (!harFilePath) {
151
+ const harFilePaths = dependency.getHarFilePaths();
152
+ if (harFilePaths.length === 0) {
156
153
  return;
157
154
  }
158
- nodeModuleHarPaths.push(harFilePath);
155
+ nodeModuleHarPaths.push(...harFilePaths);
159
156
  const packageJson = dependency.readPackageJSON();
160
157
  const providedAutolinkingConfig = packageJson.harmony?.autolinking;
161
-
162
158
  if (
163
159
  providedAutolinkingConfig === undefined ||
164
160
  providedAutolinkingConfig === null ||
165
161
  (config.excludedNpmPackageNames.has(packageJson.name) &&
166
162
  config.excludedNpmPackageNames.size > 0) ||
167
163
  (!config.includedNpmPackageNames.has(packageJson.name) &&
168
- config.includedNpmPackageNames.size > 0)
164
+ config.includedNpmPackageNames.size > 0) ||
165
+ harFilePaths.length !== 1
169
166
  ) {
170
167
  skippedLibraryNpmPackageNames.push(packageJson.name);
171
168
  return;
@@ -178,7 +175,7 @@ export class Autolinking {
178
175
  cppRNOHPackageClassName: autolinkingConfig?.cppPackageClassName,
179
176
  cmakeLibraryTargetName: autolinkingConfig?.cmakeLibraryTargetName,
180
177
  ohPackageName: autolinkingConfig?.ohPackageName,
181
- harFilePathRelativeToHarmony: harFilePath
178
+ harFilePathRelativeToHarmony: harFilePaths[0]
182
179
  .relativeTo(harmonyProjectPath)
183
180
  .toString(),
184
181
  });
@@ -194,6 +191,7 @@ export class Autolinking {
194
191
  const cmakeAutolinkingPath = harmonyProjectPath.copyWithNewSegment(
195
192
  config.cmakeAutolinkPathRelativeToHarmony
196
193
  );
194
+
197
195
  return {
198
196
  projectRootPath,
199
197
  skippedLibraryNpmPackageNames,
@@ -244,7 +242,12 @@ export class Autolinking {
244
242
  > = {};
245
243
  Object.entries<DependencySpecifier>(ohPackage.dependencies).forEach(
246
244
  ([name, dependencySpecifier]) => {
247
- if (!dependencySpecifier.includes('file:')) {
245
+ if (
246
+ !(
247
+ dependencySpecifier.includes('file:') &&
248
+ dependencySpecifier.includes('node_modules')
249
+ )
250
+ ) {
248
251
  unmanagedNativeDependencySpecifierByName[name] = dependencySpecifier;
249
252
  } else {
250
253
  const harFilePathRelativeToHarmony = dependencySpecifier.replace(
@@ -253,10 +256,10 @@ export class Autolinking {
253
256
  );
254
257
  if (
255
258
  !autolinkableHarFilePathsRelativeToHarmony.includes(
256
- harFilePathRelativeToHarmony
259
+ pathUtils.normalize(harFilePathRelativeToHarmony)
257
260
  ) &&
258
261
  input.nodeModuleHarFilePathsRelativeToHarmony.includes(
259
- harFilePathRelativeToHarmony
262
+ pathUtils.normalize(harFilePathRelativeToHarmony)
260
263
  )
261
264
  ) {
262
265
  unmanagedNativeDependencySpecifierByName[name] =
@@ -379,4 +382,4 @@ export class Autolinking {
379
382
  );
380
383
  this.logger.debug(() => '');
381
384
  }
382
- }
385
+ }
@@ -1,8 +1 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
- export * from './Autolinking';
1
+ export * from './Autolinking';
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  import { AbsolutePath } from '../../core';
9
2
  import { SpecSchema } from './UberSchema';
10
3
 
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  import { DescriptiveError } from '../../core';
9
2
 
10
3
  export class CodegenError extends DescriptiveError {}
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  import { CodegenError } from './CodegenError';
9
2
 
10
3
  export function createEventNameFromEventHandlerName(
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  import { TypeAnnotationToTS, TypeAnnotation } from './TypeAnnotationToTS';
9
2
 
10
3
  function convert(typeAnnotation: TypeAnnotation) {
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  import {
9
2
  BooleanTypeAnnotation,
10
3
  DoubleTypeAnnotation,
@@ -19,6 +12,7 @@ import {
19
12
  Nullable,
20
13
  NativeModuleTypeAnnotation,
21
14
  UnionTypeAnnotationMemberType,
15
+ UnsafeAnyTypeAnnotation,
22
16
  } from '@react-native/codegen/lib/CodegenSchema';
23
17
 
24
18
  type StringEnumTypeAnnotation = {
@@ -50,7 +44,8 @@ export type TypeAnnotation =
50
44
  | ArrayTypeAnnotation
51
45
  | NativeModuleTypeAnnotation
52
46
  | Nullable<NativeModuleTypeAnnotation>
53
- | ObjectTypeAnnotation<TypeAnnotation>;
47
+ | ObjectTypeAnnotation<TypeAnnotation>
48
+ | UnsafeAnyTypeAnnotation;
54
49
 
55
50
  export class TypeAnnotationToTS {
56
51
  constructor(private aliasPrefix: string = '') {}
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  import {
9
2
  ComponentSchema,
10
3
  NativeModuleSchema,
@@ -16,18 +9,16 @@ import {
16
9
  PackageJSON,
17
10
  ProjectDependenciesManager,
18
11
  CodegenConfig,
19
- FS
12
+ FS,
20
13
  } from '../../core';
21
14
  // @ts-expect-error
22
- import extractUberSchemaFromSpecFilePaths_ from '@react-native/codegen/lib/cli/combine/combine-js-to-schema.js';
15
+ import { combineSchemas } from '@react-native/codegen/lib/cli/combine/combine-js-to-schema.js';
23
16
  import { CodegenError } from './CodegenError';
24
17
 
25
18
  function createRawUberSchemaFromSpecFilePaths(
26
19
  projectSourceFilePaths: AbsolutePath[]
27
20
  ): RawUberSchema {
28
- return extractUberSchemaFromSpecFilePaths_(
29
- projectSourceFilePaths.map((p) => p.getValue())
30
- );
21
+ return combineSchemas(projectSourceFilePaths.map((p) => p.getValue()));
31
22
  }
32
23
 
33
24
  export type SpecSchema = ComponentSchema | NativeModuleSchema;
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  export * from './CodeGenerator';
9
2
  export * from './UberSchema';
10
3
  export * from './CodegenError';
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  import Case from 'case';
9
2
  import { AbsolutePath } from '../../core';
10
3
  import { CodeGenerator } from '../core';
@@ -62,6 +55,7 @@ export class AppBuildTimeGlueCodeGenerator
62
55
  generatedPackageH_v1.addComponent({
63
56
  name,
64
57
  supportedEventNames: eventNames,
58
+ isArkTSComponent: true,
65
59
  });
66
60
  });
67
61
 
@@ -76,7 +70,10 @@ export class AppBuildTimeGlueCodeGenerator
76
70
  this.codegenNoticeLines
77
71
  );
78
72
  components.forEach((component) => {
79
- generatedPackageH_v2.addComponent(component);
73
+ generatedPackageH_v2.addComponent({
74
+ ...component,
75
+ isArkTSComponent: false,
76
+ });
80
77
  });
81
78
  turboModules.forEach((turboModule) => {
82
79
  turboModules_indexTS.addReexport({ from: `./${turboModule.name}` });
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  import { AbsolutePath } from '../../core';
9
2
  import {
10
3
  CodegenError,
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  import { AbsolutePath } from '../../core';
9
2
  import {
10
3
  TypeAnnotationToTS,
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  import { AbsolutePath } from '../../core';
9
2
  import { CodeGenerator, UberSchema } from '../core';
10
3
  import {
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  import Case from 'case';
9
2
  import { AbsolutePath } from '../../core';
10
3
  import { CodeGenerator } from '../core';
@@ -57,13 +50,13 @@ export class LibGlueCodeGenerator implements CodeGenerator<LibGlueCodeData> {
57
50
  });
58
51
  arkTSComponents.forEach(({ componentName, eventNames }) => {
59
52
  components_indexTS.addReexport({ from: `./${componentName}` });
60
- basePackageTemplate.addComponent({ name: componentName, libraryCppName });
53
+ basePackageTemplate.addComponent({ name: componentName, libraryCppName, isArkTSComponent: true });
61
54
  eventNames.forEach((eventName) =>
62
55
  basePackageTemplate.addArkTSEvent({ name: eventName })
63
56
  );
64
57
  });
65
58
  cppComponents.forEach(({ componentName }) => {
66
- basePackageTemplate.addComponent({ name: componentName, libraryCppName });
59
+ basePackageTemplate.addComponent({ name: componentName, libraryCppName, isArkTSComponent: false });
67
60
  });
68
61
  fileContentByPath.set(
69
62
  this.cppOutputPath.copyWithNewSegment(
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  import { AbsolutePath } from '../../core';
9
2
  import type { SpecCodeGenerator } from '../core';
10
3
  import {
@@ -84,7 +77,7 @@ export class NativeModuleCodeGenerator implements SpecCodeGenerator {
84
77
  });
85
78
  });
86
79
 
87
- schema.spec.properties.map((prop) => {
80
+ schema.spec.methods.map((prop) => {
88
81
  if (prop.typeAnnotation.type === 'FunctionTypeAnnotation') {
89
82
  turboModuleCpp.addMethod({
90
83
  name: prop.name,
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  import RNCodegen from '@react-native/codegen/lib/generators/RNCodegen';
9
2
  import { AbsolutePath } from '../../core';
10
3
  import { CodeGenerator, UberSchema } from '../core';
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  import { AbsolutePath } from '../../core';
9
2
  import {
10
3
  CodeGenerator,
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  import { AbsolutePath } from '../../core';
9
2
  import { CodeGenerator } from '../core';
10
3
  import {
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  export * from './NativeModuleCodeGenerator';
9
2
  export * from './AppBuildTimeGlueCodeGenerator';
10
3
  export * from './ArkTSComponentCodeGeneratorArkTS';
@@ -1,9 +1,2 @@
1
- /**
2
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE-MIT file in the root directory of this source tree.
6
- */
7
-
8
1
  export * from './core';
9
2
  export * from './generators';