@react-native-oh/react-native-harmony-cli 0.0.30 → 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 (234) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -4
  3. package/dist/assetResolver.js +105 -10
  4. package/dist/autolinking/Autolinking.js +21 -26
  5. package/dist/autolinking/index.js +0 -6
  6. package/dist/codegen/core/CodeGenerator.js +0 -6
  7. package/dist/codegen/core/CodegenError.js +0 -6
  8. package/dist/codegen/core/EventUtils.js +4 -13
  9. package/dist/codegen/core/TypeAnnotationToTS.js +3 -9
  10. package/dist/codegen/core/UberSchema.js +8 -21
  11. package/dist/codegen/core/index.js +0 -6
  12. package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +2 -7
  13. package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +3 -6
  14. package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +3 -6
  15. package/dist/codegen/generators/CppComponentCodeGenerator.js +3 -6
  16. package/dist/codegen/generators/LibGlueCodeGenerator.js +2 -8
  17. package/dist/codegen/generators/NativeModuleCodeGenerator.js +1 -7
  18. package/dist/codegen/generators/SharedComponentCodeGenerator.js +0 -6
  19. package/dist/codegen/generators/UberGeneratorV1.js +0 -6
  20. package/dist/codegen/generators/UberGeneratorV2.js +0 -6
  21. package/dist/codegen/generators/index.js +0 -6
  22. package/dist/codegen/index.js +0 -6
  23. package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +0 -6
  24. package/dist/codegen/templates/BasePackageHTemplate.js +12 -7
  25. package/dist/codegen/templates/ComponentDescriptorHTemplate.js +1 -6
  26. package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +15 -6
  27. package/dist/codegen/templates/ComponentUtilsTSTemplate.js +0 -6
  28. package/dist/codegen/templates/IndexTSTemplate.js +0 -6
  29. package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +12 -7
  30. package/dist/codegen/templates/TurboModuleCppTemplate.js +0 -6
  31. package/dist/codegen/templates/TurboModuleHTemplate.js +0 -6
  32. package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +0 -6
  33. package/dist/codegen/templates/index.js +0 -6
  34. package/dist/commands/bundle-harmony.js +133 -101
  35. package/dist/commands/clean-harmony.js +84 -0
  36. package/dist/commands/codegen-harmony.js +12 -22
  37. package/dist/commands/codegen-lib-harmony.js +15 -25
  38. package/dist/commands/index.js +3 -9
  39. package/dist/commands/init-harmony.js +226 -0
  40. package/dist/commands/init.js +703 -0
  41. package/dist/commands/link-harmony.js +12 -16
  42. package/dist/commands/run-harmony.js +438 -0
  43. package/dist/commands/types.js +2 -0
  44. package/dist/commands/verify-package-harmony.js +7 -11
  45. package/dist/core/AbsolutePath.js +3 -6
  46. package/dist/core/CodegenConfig.js +3 -11
  47. package/dist/core/DescriptiveError.js +7 -9
  48. package/dist/core/FileSystem.js +0 -6
  49. package/dist/core/OHPackageJSON5.js +0 -6
  50. package/dist/core/PackageJSON.js +4 -7
  51. package/dist/core/ProjectDependenciesManager.js +6 -14
  52. package/dist/core/ValidationError.js +0 -6
  53. package/dist/core/ValueObject.js +0 -6
  54. package/dist/core/fs.js +16 -10
  55. package/dist/core/index.js +0 -6
  56. package/dist/index.js +3 -9
  57. package/dist/init/templates/AppScopeAppJSON5Template.js +30 -0
  58. package/dist/init/templates/AppScopeStringVarTemplate.js +28 -0
  59. package/dist/init/templates/EntryIndexTemplate.js +65 -0
  60. package/dist/init/templates/EntryStringVarTemplate.js +38 -0
  61. package/dist/init/templates/HvigorConfigJson5Template.js +44 -0
  62. package/dist/init/templates/MetroConfigTemplate.js +47 -0
  63. package/dist/init/templates/OhPackageJson5Template.js +37 -0
  64. package/dist/init/templates/harmony/AppScope/app.json5 +10 -0
  65. package/dist/init/templates/harmony/AppScope/resources/base/element/string.json +8 -0
  66. package/dist/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  67. package/dist/init/templates/harmony/build-profile.json5 +36 -0
  68. package/dist/init/templates/harmony/codelinter.json +32 -0
  69. package/dist/init/templates/harmony/entry/build-profile.json5 +18 -0
  70. package/dist/init/templates/harmony/entry/gitignore +7 -0
  71. package/dist/init/templates/harmony/entry/hvigorfile.ts +13 -0
  72. package/dist/init/templates/harmony/entry/oh-package.json5 +9 -0
  73. package/dist/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +27 -0
  74. package/dist/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +13 -0
  75. package/dist/init/templates/harmony/entry/src/main/cpp/gitignore +4 -0
  76. package/dist/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +8 -0
  77. package/dist/init/templates/harmony/entry/src/main/ets/codegen/gitignore +2 -0
  78. package/dist/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +11 -0
  79. package/dist/init/templates/harmony/entry/src/main/ets/gitignore +1 -0
  80. package/dist/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
  81. package/dist/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +16 -0
  82. package/dist/init/templates/harmony/entry/src/main/module.json5 +58 -0
  83. package/dist/init/templates/harmony/entry/src/main/resources/base/element/color.json +8 -0
  84. package/dist/init/templates/harmony/entry/src/main/resources/base/element/string.json +16 -0
  85. package/dist/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
  86. package/dist/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
  87. package/dist/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +7 -0
  88. package/dist/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
  89. package/dist/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
  90. package/dist/init/templates/harmony/entry/src/main/resources/gitignore +1 -0
  91. package/dist/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +2 -0
  92. package/dist/init/templates/harmony/entry/src/ohosTest/module.json5 +13 -0
  93. package/dist/init/templates/harmony/gitignore +16 -0
  94. package/dist/init/templates/harmony/hvigor/hvigor-config.json5 +22 -0
  95. package/dist/init/templates/harmony/hvigorfile.ts +7 -0
  96. package/dist/init/templates/index.js +21 -0
  97. package/dist/io/CliExecutor.js +56 -29
  98. package/dist/io/Logger.js +71 -47
  99. package/dist/io/RealFS.js +10 -6
  100. package/dist/io/TarGz.js +3 -10
  101. package/dist/io/__fixtures__.js +8 -8
  102. package/dist/io/fsUtils.js +1 -8
  103. package/dist/io/index.js +1 -6
  104. package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +1 -8
  105. package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +1 -8
  106. package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +1 -8
  107. package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +1 -8
  108. package/dist/package-verifier/checks/index.js +0 -6
  109. package/dist/package-verifier/index.js +0 -6
  110. package/dist/package-verifier/types.js +0 -6
  111. package/dist/package-verifier/verify-package.js +5 -14
  112. package/jest.config.js +0 -7
  113. package/package.json +20 -16
  114. package/react-native.config.js +0 -7
  115. package/scripts/copy-template.js +18 -0
  116. package/src/assetResolver.ts +117 -11
  117. package/src/autolinking/Autolinking.test.ts +54 -18
  118. package/src/autolinking/Autolinking.ts +32 -31
  119. package/src/autolinking/index.ts +1 -8
  120. package/src/codegen/core/CodeGenerator.ts +0 -7
  121. package/src/codegen/core/CodegenError.ts +0 -7
  122. package/src/codegen/core/EventUtils.ts +3 -12
  123. package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -7
  124. package/src/codegen/core/TypeAnnotationToTS.ts +3 -8
  125. package/src/codegen/core/UberSchema.ts +9 -22
  126. package/src/codegen/core/index.ts +0 -7
  127. package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +5 -8
  128. package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +3 -7
  129. package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +3 -7
  130. package/src/codegen/generators/CppComponentCodeGenerator.ts +3 -7
  131. package/src/codegen/generators/LibGlueCodeGenerator.ts +2 -9
  132. package/src/codegen/generators/NativeModuleCodeGenerator.ts +1 -8
  133. package/src/codegen/generators/SharedComponentCodeGenerator.ts +0 -7
  134. package/src/codegen/generators/UberGeneratorV1.ts +0 -7
  135. package/src/codegen/generators/UberGeneratorV2.ts +0 -7
  136. package/src/codegen/generators/index.ts +0 -7
  137. package/src/codegen/index.ts +0 -7
  138. package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +0 -7
  139. package/src/codegen/templates/BasePackageHTemplate.ts +13 -8
  140. package/src/codegen/templates/ComponentDescriptorHTemplate.ts +1 -7
  141. package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +24 -8
  142. package/src/codegen/templates/ComponentUtilsTSTemplate.ts +0 -7
  143. package/src/codegen/templates/IndexTSTemplate.ts +0 -7
  144. package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +13 -8
  145. package/src/codegen/templates/TurboModuleCppTemplate.ts +0 -7
  146. package/src/codegen/templates/TurboModuleHTemplate.ts +0 -7
  147. package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +0 -7
  148. package/src/codegen/templates/index.ts +0 -7
  149. package/src/commands/bundle-harmony.ts +178 -118
  150. package/src/commands/clean-harmony.ts +54 -0
  151. package/src/commands/codegen-harmony.ts +13 -25
  152. package/src/commands/codegen-lib-harmony.ts +16 -28
  153. package/src/commands/index.ts +3 -10
  154. package/src/commands/init-harmony.ts +299 -0
  155. package/src/commands/init.ts +755 -0
  156. package/src/commands/link-harmony.ts +14 -19
  157. package/src/commands/run-harmony.ts +478 -0
  158. package/src/commands/types.ts +14 -0
  159. package/src/commands/verify-package-harmony.ts +9 -12
  160. package/src/core/AbsolutePath.ts +4 -7
  161. package/src/core/CodegenConfig.ts +3 -12
  162. package/src/core/DescriptiveError.ts +8 -15
  163. package/src/core/FileSystem.ts +5 -8
  164. package/src/core/OHPackageJSON5.ts +0 -7
  165. package/src/core/PackageJSON.ts +4 -13
  166. package/src/core/ProjectDependenciesManager.ts +14 -22
  167. package/src/core/ValidationError.ts +0 -7
  168. package/src/core/ValueObject.ts +0 -7
  169. package/src/core/fs.ts +14 -8
  170. package/src/core/index.ts +0 -7
  171. package/src/index.ts +8 -15
  172. package/src/init/templates/AppScopeAppJSON5Template.ts +24 -0
  173. package/src/init/templates/AppScopeStringVarTemplate.ts +22 -0
  174. package/src/init/templates/EntryIndexTemplate.ts +59 -0
  175. package/src/init/templates/EntryStringVarTemplate.ts +31 -0
  176. package/src/init/templates/HvigorConfigJson5Template.ts +40 -0
  177. package/src/init/templates/MetroConfigTemplate.ts +41 -0
  178. package/src/init/templates/OhPackageJson5Template.ts +31 -0
  179. package/src/init/templates/harmony/AppScope/app.json5 +10 -0
  180. package/src/init/templates/harmony/AppScope/resources/base/element/string.json +8 -0
  181. package/src/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  182. package/src/init/templates/harmony/build-profile.json5 +36 -0
  183. package/src/init/templates/harmony/codelinter.json +32 -0
  184. package/src/init/templates/harmony/entry/build-profile.json5 +18 -0
  185. package/src/init/templates/harmony/entry/gitignore +7 -0
  186. package/src/init/templates/harmony/entry/hvigorfile.ts +13 -0
  187. package/src/init/templates/harmony/entry/oh-package.json5 +9 -0
  188. package/src/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +27 -0
  189. package/src/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +13 -0
  190. package/src/init/templates/harmony/entry/src/main/cpp/gitignore +4 -0
  191. package/src/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +8 -0
  192. package/src/init/templates/harmony/entry/src/main/ets/codegen/gitignore +2 -0
  193. package/src/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +11 -0
  194. package/src/init/templates/harmony/entry/src/main/ets/gitignore +1 -0
  195. package/src/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
  196. package/src/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +16 -0
  197. package/src/init/templates/harmony/entry/src/main/module.json5 +58 -0
  198. package/src/init/templates/harmony/entry/src/main/resources/base/element/color.json +8 -0
  199. package/src/init/templates/harmony/entry/src/main/resources/base/element/string.json +16 -0
  200. package/src/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
  201. package/src/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
  202. package/src/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +7 -0
  203. package/src/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
  204. package/src/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
  205. package/src/init/templates/harmony/entry/src/main/resources/gitignore +1 -0
  206. package/src/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +2 -0
  207. package/src/init/templates/harmony/entry/src/ohosTest/module.json5 +13 -0
  208. package/src/init/templates/harmony/gitignore +16 -0
  209. package/src/init/templates/harmony/hvigor/hvigor-config.json5 +22 -0
  210. package/src/init/templates/harmony/hvigorfile.ts +7 -0
  211. package/src/init/templates/index.ts +5 -0
  212. package/src/io/CliExecutor.ts +55 -40
  213. package/src/io/Logger.ts +77 -51
  214. package/src/io/RealFS.ts +15 -8
  215. package/src/io/TarGz.ts +1 -8
  216. package/src/io/__fixtures__.ts +15 -18
  217. package/src/io/fsUtils.ts +1 -7
  218. package/src/io/index.ts +1 -7
  219. package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +0 -7
  220. package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +0 -7
  221. package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +0 -7
  222. package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +0 -7
  223. package/src/package-verifier/checks/index.ts +0 -7
  224. package/src/package-verifier/index.ts +0 -7
  225. package/src/package-verifier/types.ts +0 -7
  226. package/src/package-verifier/verify-package.ts +4 -13
  227. package/tsconfig.build.json +2 -5
  228. package/tsconfig.json +4 -0
  229. package/dist/commands/create-metro-host-constants.js +0 -67
  230. package/dist/commands/pack-harmony.js +0 -106
  231. package/dist/commands/unpack-harmony.js +0 -191
  232. package/src/commands/create-metro-host-constants.ts +0 -55
  233. package/src/commands/pack-harmony.ts +0 -128
  234. package/src/commands/unpack-harmony.ts +0 -240
@@ -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 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 (
@@ -133,9 +130,8 @@ export class Autolinking {
133
130
  ) {
134
131
  throw new DescriptiveError({
135
132
  whatHappened: 'Tried to exclude and include npm packages.',
136
- whatCanUserDo: {
137
- default: ['Include or exclude npm packages, but not both.'],
138
- },
133
+ whatCanUserDo: ['Include or exclude npm packages, but not both.'],
134
+
139
135
  extraData: {
140
136
  includedNpmPackageNamesCount: config.includedNpmPackageNames.size,
141
137
  excludedNpmPackageNamesCount: config.excludedNpmPackageNames.size,
@@ -152,21 +148,21 @@ export class Autolinking {
152
148
  const skippedLibraryNpmPackageNames: string[] = [];
153
149
  await new ProjectDependenciesManager(this.fs, projectRootPath).forEachAsync(
154
150
  (dependency) => {
155
- const harFilePath = dependency.getHarFilePath();
156
- if (!harFilePath) {
151
+ const harFilePaths = dependency.getHarFilePaths();
152
+ if (harFilePaths.length === 0) {
157
153
  return;
158
154
  }
159
- nodeModuleHarPaths.push(harFilePath);
155
+ nodeModuleHarPaths.push(...harFilePaths);
160
156
  const packageJson = dependency.readPackageJSON();
161
157
  const providedAutolinkingConfig = packageJson.harmony?.autolinking;
162
-
163
158
  if (
164
159
  providedAutolinkingConfig === undefined ||
165
160
  providedAutolinkingConfig === null ||
166
161
  (config.excludedNpmPackageNames.has(packageJson.name) &&
167
162
  config.excludedNpmPackageNames.size > 0) ||
168
163
  (!config.includedNpmPackageNames.has(packageJson.name) &&
169
- config.includedNpmPackageNames.size > 0)
164
+ config.includedNpmPackageNames.size > 0) ||
165
+ harFilePaths.length !== 1
170
166
  ) {
171
167
  skippedLibraryNpmPackageNames.push(packageJson.name);
172
168
  return;
@@ -179,7 +175,7 @@ export class Autolinking {
179
175
  cppRNOHPackageClassName: autolinkingConfig?.cppPackageClassName,
180
176
  cmakeLibraryTargetName: autolinkingConfig?.cmakeLibraryTargetName,
181
177
  ohPackageName: autolinkingConfig?.ohPackageName,
182
- harFilePathRelativeToHarmony: harFilePath
178
+ harFilePathRelativeToHarmony: harFilePaths[0]
183
179
  .relativeTo(harmonyProjectPath)
184
180
  .toString(),
185
181
  });
@@ -195,6 +191,7 @@ export class Autolinking {
195
191
  const cmakeAutolinkingPath = harmonyProjectPath.copyWithNewSegment(
196
192
  config.cmakeAutolinkPathRelativeToHarmony
197
193
  );
194
+
198
195
  return {
199
196
  projectRootPath,
200
197
  skippedLibraryNpmPackageNames,
@@ -245,7 +242,12 @@ export class Autolinking {
245
242
  > = {};
246
243
  Object.entries<DependencySpecifier>(ohPackage.dependencies).forEach(
247
244
  ([name, dependencySpecifier]) => {
248
- if (!dependencySpecifier.includes('file:')) {
245
+ if (
246
+ !(
247
+ dependencySpecifier.includes('file:') &&
248
+ dependencySpecifier.includes('node_modules')
249
+ )
250
+ ) {
249
251
  unmanagedNativeDependencySpecifierByName[name] = dependencySpecifier;
250
252
  } else {
251
253
  const harFilePathRelativeToHarmony = dependencySpecifier.replace(
@@ -254,10 +256,10 @@ export class Autolinking {
254
256
  );
255
257
  if (
256
258
  !autolinkableHarFilePathsRelativeToHarmony.includes(
257
- harFilePathRelativeToHarmony
259
+ pathUtils.normalize(harFilePathRelativeToHarmony)
258
260
  ) &&
259
261
  input.nodeModuleHarFilePathsRelativeToHarmony.includes(
260
- harFilePathRelativeToHarmony
262
+ pathUtils.normalize(harFilePathRelativeToHarmony)
261
263
  )
262
264
  ) {
263
265
  unmanagedNativeDependencySpecifierByName[name] =
@@ -351,23 +353,23 @@ export class Autolinking {
351
353
  this.fs.writeTextSync(path, content);
352
354
  });
353
355
  output.linkedLibraryNpmPackageNames.forEach((npmPackageName) => {
354
- this.logger.info(
356
+ this.logger.debug(
355
357
  (styles) => `[${styles.green(styles.bold('link'))}] ${npmPackageName}`
356
358
  );
357
359
  });
358
360
  output.skippedLibraryNpmPackageNames.forEach((npmPackageName) => {
359
- this.logger.warn(
361
+ this.logger.debug(
360
362
  (styles) => `[${styles.yellow(styles.bold('skip'))}] ${npmPackageName}`
361
363
  );
362
364
  });
363
- this.logger.info(() => '');
365
+ this.logger.debug(() => '');
364
366
  const sortedPathsRelativeToRoot = pathAndContentPairs
365
367
  .map(([path]) => path.relativeTo(output.projectRootPath).toString())
366
368
  .sort();
367
369
  sortedPathsRelativeToRoot.forEach((pathStr) => {
368
- this.logger.info((styles) => styles.gray(`• ${pathStr}`));
370
+ this.logger.debug((styles) => styles.gray(`• ${pathStr}`));
369
371
  });
370
- this.logger.info(() => '');
372
+ this.logger.debug(() => '');
371
373
  this.logger.info(
372
374
  (styles) =>
373
375
  `updated ${styles.green(
@@ -376,9 +378,8 @@ export class Autolinking {
376
378
  styles.bold(output.linkedLibraryNpmPackageNames.length)
377
379
  )} libraries, skipped ${styles.yellow(
378
380
  styles.bold(output.skippedLibraryNpmPackageNames.length)
379
- )} libraries`,
380
- { prefix: true }
381
+ )} libraries`
381
382
  );
382
- this.logger.info(() => '');
383
+ this.logger.debug(() => '');
383
384
  }
384
- }
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 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(
@@ -14,11 +7,9 @@ export function createEventNameFromEventHandlerName(
14
7
  if (eventName.length === 0) {
15
8
  throw new CodegenError({
16
9
  whatHappened: `Received invalid event handler name: ${eventHandlerName}`,
17
- whatCanUserDo: {
18
- default: [
19
- 'Change your event listener name to match naming convention "onEventName" e.g. "onPress"',
20
- ],
21
- },
10
+ whatCanUserDo: [
11
+ 'Change your event listener name to match naming convention "onEventName" e.g. "onPress"',
12
+ ],
22
13
  });
23
14
  }
24
15
  return eventName.charAt(0).toLowerCase() + eventName.slice(1);
@@ -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 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;
@@ -54,11 +45,9 @@ export class UberSchema implements ValueObject {
54
45
  if (err instanceof Error) {
55
46
  throw new CodegenError({
56
47
  whatHappened: "Couldn't create the schema",
57
- whatCanUserDo: {
58
- default: [
59
- `There's probably at least one spec file defined in your project or in a third-party package that breaks some code generation restrictions. Please check the message below. If it's ambiguous, debug the problem with divide and conquer strategy.\n\n${err.message}`,
60
- ],
61
- },
48
+ whatCanUserDo: [
49
+ `There's probably at least one spec file defined in your project or in a third-party package that breaks some code generation restrictions. Please check the message below. If it's ambiguous, debug the problem with divide and conquer strategy.\n\n${err.message}`,
50
+ ],
62
51
  });
63
52
  }
64
53
  throw err;
@@ -119,11 +108,9 @@ export class UberSchema implements ValueObject {
119
108
  if (err instanceof Error) {
120
109
  throw new CodegenError({
121
110
  whatHappened: "Couldn't create the schema",
122
- whatCanUserDo: {
123
- default: [
124
- `There's probably at least one spec file defined in your project or in a third-party package that breaks some code generation restrictions. Please check the message below. If it's ambiguous, debug the problem with divide and conquer strategy.\n\n${err.message}`,
125
- ],
126
- },
111
+ whatCanUserDo: [
112
+ `There's probably at least one spec file defined in your project or in a third-party package that breaks some code generation restrictions. Please check the message below. If it's ambiguous, debug the problem with divide and conquer strategy.\n\n${err.message}`,
113
+ ],
127
114
  });
128
115
  }
129
116
  throw err;
@@ -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,
@@ -74,6 +67,9 @@ export class ArkTSComponentCodeGeneratorArkTS implements SpecCodeGenerator {
74
67
  });
75
68
  });
76
69
  shape.commands.forEach((command) => {
70
+ componentJSIBinderHTemplate.addCommand({
71
+ name: command.name,
72
+ });
77
73
  componentUtilsTSTemplate.addCommand({
78
74
  name: command.name,
79
75
  argsTSType:
@@ -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,
@@ -70,6 +63,9 @@ export class ArkTSComponentCodeGeneratorCAPI
70
63
  });
71
64
  });
72
65
  shape.commands.forEach((command) => {
66
+ componentJSIBinderHTemplate.addCommand({
67
+ name: command.name,
68
+ });
73
69
  componentUtilsTSTemplate.addCommand({
74
70
  name: command.name,
75
71
  argsTSType:
@@ -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 {
@@ -63,6 +56,9 @@ export class CppComponentCodeGenerator implements CodeGenerator<LibraryData> {
63
56
  });
64
57
  });
65
58
  shape.commands.forEach((command) => {
59
+ componentJSIBinderHTemplate.addCommand({
60
+ name: command.name,
61
+ });
66
62
  componentInstanceSpecHTemplate.addCommand({
67
63
  name: command.name,
68
64
  args: command.typeAnnotation.params.map((param) => ({
@@ -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';
@@ -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 mustache from 'mustache';
9
2
  import Case from 'case';
10
3
  import { TypeAnnotation } 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 mustache from 'mustache';
9
2
 
10
3
  const TEMPLATE = `
@@ -46,16 +39,26 @@ class {{name}}EventEmitRequestHandler : public EventEmitRequestHandler {
46
39
  public:
47
40
  void handleEvent(Context const &ctx) override {
48
41
  auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
42
+ auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag);
43
+
49
44
  if (eventEmitter == nullptr) {
50
45
  return;
51
46
  }
52
47
 
48
+ std::vector<std::string> supportedComponentNames = {
49
+ {{#arkTSComponents}}
50
+ "{{name}}",
51
+ {{/arkTSComponents}}
52
+ };
53
+
53
54
  std::vector<std::string> supportedEventNames = {
54
55
  {{#arkTSEvents}}
55
56
  "{{name}}",
56
57
  {{/arkTSEvents}}
57
58
  };
58
- if (std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
59
+
60
+ if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() &&
61
+ std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
59
62
  eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
60
63
  }
61
64
  }
@@ -103,6 +106,7 @@ type GeneratedPackageTurboModule = {
103
106
  type GeneratedPackageComponent = {
104
107
  name: string;
105
108
  libraryCppName: string;
109
+ isArkTSComponent: boolean;
106
110
  };
107
111
 
108
112
  type ArkTSEvent = {
@@ -138,6 +142,7 @@ export class BasePackageHTemplate {
138
142
  name: this.name,
139
143
  turboModules: this.turboModules,
140
144
  components: this.components,
145
+ arkTSComponents: this.components.filter((component) => component.isArkTSComponent),
141
146
  arkTSEvents: this.arkTSEvents,
142
147
  libraries: Array.from(this.libraryCppNames).map((name) => ({
143
148
  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 mustache from 'mustache';
9
2
 
10
3
  const TEMPLATE = `
@@ -26,6 +19,7 @@ const TEMPLATE = `
26
19
  namespace facebook {
27
20
  namespace react {
28
21
 
22
+ // RNOH patch
29
23
  constexpr char {{name}}ComponentName[] = "{{name}}";
30
24
 
31
25
  class {{name}}Props : public ViewProps {