@react-native-oh/react-native-harmony-cli 0.77.33 → 0.77.40

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 (192) hide show
  1. package/dist/assetResolver.js +43 -74
  2. package/dist/autolinking/Autolinking.js +178 -179
  3. package/dist/codegen/core/CodegenError.js +3 -23
  4. package/dist/codegen/core/EventUtils.js +3 -3
  5. package/dist/codegen/core/TypeAnnotationToTS.js +24 -28
  6. package/dist/codegen/core/UberSchema.js +55 -97
  7. package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +28 -41
  8. package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +27 -34
  9. package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +25 -33
  10. package/dist/codegen/generators/CppComponentCodeGenerator.js +23 -28
  11. package/dist/codegen/generators/LibGlueCodeGenerator.js +26 -29
  12. package/dist/codegen/generators/NativeModuleCodeGenerator.js +25 -30
  13. package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
  14. package/dist/codegen/generators/UberGeneratorV1.js +24 -23
  15. package/dist/codegen/generators/UberGeneratorV2.js +34 -35
  16. package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +50 -24
  17. package/dist/codegen/templates/BasePackageHTemplate.js +120 -21
  18. package/dist/codegen/templates/ComponentDescriptorHTemplate.js +54 -8
  19. package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +75 -27
  20. package/dist/codegen/templates/ComponentUtilsTSTemplate.js +162 -29
  21. package/dist/codegen/templates/IndexTSTemplate.js +37 -17
  22. package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +119 -24
  23. package/dist/codegen/templates/TurboModuleCppTemplate.js +38 -15
  24. package/dist/codegen/templates/TurboModuleHTemplate.js +32 -11
  25. package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +52 -19
  26. package/dist/commands/bundle-harmony.js +118 -221
  27. package/dist/commands/clean-harmony.js +58 -63
  28. package/dist/commands/codegen-harmony.js +105 -165
  29. package/dist/commands/codegen-lib-harmony.js +76 -116
  30. package/dist/commands/init-harmony.js +151 -196
  31. package/dist/commands/init.js +537 -961
  32. package/dist/commands/link-harmony.js +35 -82
  33. package/dist/commands/run-harmony.js +372 -518
  34. package/dist/commands/verify-package-harmony.js +54 -117
  35. package/dist/core/AbsolutePath.js +33 -49
  36. package/dist/core/CodegenConfig.js +24 -22
  37. package/dist/core/DescriptiveError.js +18 -37
  38. package/dist/core/FileSystem.js +14 -18
  39. package/dist/core/OHPackageJSON5.js +17 -23
  40. package/dist/core/PackageJSON.js +26 -42
  41. package/dist/core/ProjectDependenciesManager.js +40 -92
  42. package/dist/core/ValidationError.js +2 -22
  43. package/dist/core/fs.js +10 -7
  44. package/dist/index.js +1 -1
  45. package/dist/init/templates/AppScopeAppJSON5Template.js +21 -8
  46. package/dist/init/templates/AppScopeStringVarTemplate.js +19 -8
  47. package/dist/init/templates/EntryIndexTemplate.js +56 -8
  48. package/dist/init/templates/EntryStringVarTemplate.js +27 -8
  49. package/dist/init/templates/HvigorConfigJson5Template.js +33 -8
  50. package/dist/init/templates/MetroConfigTemplate.js +38 -8
  51. package/dist/init/templates/OhPackageJson5Template.js +28 -8
  52. package/dist/init/templates/harmony/AppScope/app.json5 +10 -0
  53. package/dist/init/templates/harmony/AppScope/resources/base/element/string.json +8 -0
  54. package/dist/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  55. package/dist/init/templates/harmony/build-profile.json5 +36 -0
  56. package/dist/init/templates/harmony/codelinter.json +32 -0
  57. package/dist/init/templates/harmony/entry/build-profile.json5 +18 -0
  58. package/dist/init/templates/harmony/entry/gitignore +7 -0
  59. package/dist/init/templates/harmony/entry/hvigorfile.ts +13 -0
  60. package/dist/init/templates/harmony/entry/oh-package.json5 +9 -0
  61. package/dist/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +27 -0
  62. package/dist/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +13 -0
  63. package/dist/init/templates/harmony/entry/src/main/cpp/gitignore +4 -0
  64. package/dist/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +8 -0
  65. package/dist/init/templates/harmony/entry/src/main/ets/codegen/gitignore +2 -0
  66. package/dist/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +11 -0
  67. package/dist/init/templates/harmony/entry/src/main/ets/gitignore +1 -0
  68. package/dist/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
  69. package/dist/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +16 -0
  70. package/dist/init/templates/harmony/entry/src/main/module.json5 +65 -0
  71. package/dist/init/templates/harmony/entry/src/main/resources/base/element/color.json +8 -0
  72. package/dist/init/templates/harmony/entry/src/main/resources/base/element/string.json +16 -0
  73. package/dist/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
  74. package/dist/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
  75. package/dist/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +7 -0
  76. package/dist/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
  77. package/dist/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
  78. package/dist/init/templates/harmony/entry/src/main/resources/gitignore +1 -0
  79. package/dist/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +2 -0
  80. package/dist/init/templates/harmony/entry/src/ohosTest/module.json5 +13 -0
  81. package/dist/init/templates/harmony/gitignore +16 -0
  82. package/dist/init/templates/harmony/hvigor/hvigor-config.json5 +22 -0
  83. package/dist/init/templates/harmony/hvigorfile.ts +7 -0
  84. package/dist/io/CliExecutor.js +46 -98
  85. package/dist/io/Logger.js +40 -46
  86. package/dist/io/RealFS.js +43 -100
  87. package/dist/io/TarGz.js +11 -8
  88. package/dist/io/__fixtures__.js +79 -141
  89. package/dist/io/fsUtils.js +13 -12
  90. package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +19 -47
  91. package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +13 -41
  92. package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +8 -38
  93. package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +22 -54
  94. package/dist/package-verifier/verify-package.js +56 -133
  95. package/dist/simulator/LaunchSimulator.js +224 -301
  96. package/harmony/rnoh-hvigor-plugin-0.77.40.tgz +0 -0
  97. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0271b9dd +0 -0
  98. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/07ba0208 +0 -0
  99. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/082dd09d +0 -0
  100. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0a9e1b0b +0 -0
  101. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0c3d528a +0 -0
  102. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1014d3ff +0 -0
  103. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1184678c +0 -0
  104. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/12621366 +0 -0
  105. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/126d3e66 +0 -0
  106. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/19262852 +0 -0
  107. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/203fac53 +0 -0
  108. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/237b660a +0 -0
  109. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2528002d +0 -0
  110. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2587d041 +0 -0
  111. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2893bd11 +0 -0
  112. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2af6ff9d +0 -0
  113. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2bf31f33 +0 -0
  114. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/333648cc +0 -0
  115. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/386f6df0 +0 -0
  116. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3b8c270e +0 -0
  117. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3bcc34ba +0 -0
  118. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/444808bd +0 -0
  119. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/44a775e2 +0 -0
  120. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/46da3ccd +0 -0
  121. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/51f80e35 +0 -0
  122. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5203a2ca +0 -0
  123. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/52795646 +0 -0
  124. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/577f8208 +0 -0
  125. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5c2aafe7 +0 -0
  126. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5c69bcfe +0 -0
  127. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/62695b92 +0 -0
  128. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/62698102 +0 -0
  129. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6411ab00 +0 -0
  130. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6569ba92 +0 -0
  131. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/65e5133c +0 -0
  132. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/66029655 +0 -0
  133. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/69e85d0d +0 -0
  134. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6afcb99e +0 -0
  135. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6de07367 +0 -0
  136. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/72498307 +0 -0
  137. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7babd1de +0 -0
  138. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7fe56d21 +0 -0
  139. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/810cbd72 +0 -0
  140. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/812386d2 +0 -0
  141. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8448897d +0 -0
  142. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/84ab0a41 +0 -0
  143. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/853825e2 +0 -0
  144. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/862ad93a +0 -0
  145. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/86b14da6 +0 -0
  146. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/87f0fe62 +0 -0
  147. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/88ee8f74 +0 -0
  148. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8c5237c9 +0 -0
  149. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8c725800 +0 -0
  150. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8e83cbe1 +0 -0
  151. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8f4085b9 +0 -0
  152. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/931f0b2e +0 -0
  153. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/940c8f92 +0 -0
  154. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/968191a3 +0 -0
  155. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/970780c0 +0 -0
  156. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/98bc4394 +0 -0
  157. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/99a3b0b0 +0 -0
  158. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9c0ffa6b +0 -0
  159. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9d9b42c2 +0 -0
  160. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a04266ef +0 -0
  161. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a18f78c5 +0 -0
  162. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a642fb0e +0 -0
  163. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a97edf40 +0 -0
  164. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/aa672a20 +0 -0
  165. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ae25c61a +0 -0
  166. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b2bebae6 +0 -0
  167. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ba492422 +0 -0
  168. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/bd3e6c21 +0 -0
  169. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/be9e564e +0 -0
  170. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c342b18e +0 -0
  171. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c3993e7e +0 -0
  172. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c52ffd54 +0 -0
  173. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c7079ad4 +0 -0
  174. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c8eb01c1 +0 -0
  175. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/caee5d30 +0 -0
  176. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cf039161 +0 -0
  177. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d0377c40 +0 -0
  178. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d262bc85 +0 -0
  179. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d287cb5c +0 -0
  180. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d64bff57 +0 -0
  181. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d716a608 +0 -0
  182. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d751012b +0 -0
  183. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e0873711 +0 -0
  184. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e1fcf77b +0 -0
  185. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e8548d8a +0 -0
  186. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/eaedd71d +0 -0
  187. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/eca0019e +0 -0
  188. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f7189953 +0 -0
  189. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f75cb201 +0 -0
  190. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f888164b +0 -0
  191. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/fdb9eb5a +0 -0
  192. package/package.json +1 -1
@@ -1,34 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ArkTSComponentCodeGeneratorCAPI = void 0;
4
- var core_1 = require("../core");
5
- var templates_1 = require("../templates");
4
+ const core_1 = require("../core");
5
+ const templates_1 = require("../templates");
6
6
  /**
7
7
  * Generates component code for ArkTS components used in C-API architecture.
8
8
  */
9
- var ArkTSComponentCodeGeneratorCAPI = /** @class */ (function () {
10
- function ArkTSComponentCodeGeneratorCAPI(cppOutputPath, tsOutputPath, codegenNoticeLines, rnohImport) {
9
+ class ArkTSComponentCodeGeneratorCAPI {
10
+ constructor(cppOutputPath, tsOutputPath, codegenNoticeLines, rnohImport) {
11
11
  this.cppOutputPath = cppOutputPath;
12
12
  this.tsOutputPath = tsOutputPath;
13
13
  this.codegenNoticeLines = codegenNoticeLines;
14
14
  this.rnohImport = rnohImport;
15
15
  this.glueCodeDataItems = [];
16
16
  }
17
- ArkTSComponentCodeGeneratorCAPI.prototype.getLibGlueCodeData = function () {
17
+ getLibGlueCodeData() {
18
18
  return this.glueCodeDataItems;
19
- };
20
- ArkTSComponentCodeGeneratorCAPI.prototype.generate = function (uberSchema) {
21
- var _this = this;
22
- var typeAnnotationToTS = new core_1.TypeAnnotationToTS();
23
- var result = new Map();
24
- var componentSpecSchemas = uberSchema.findAllSpecSchemasByType('Component');
25
- for (var _i = 0, componentSpecSchemas_1 = componentSpecSchemas; _i < componentSpecSchemas_1.length; _i++) {
26
- var componentSpecSchema = componentSpecSchemas_1[_i];
27
- Object.entries(componentSpecSchema.components).map(function (_a) {
28
- var name = _a[0], shape = _a[1];
29
- var componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(name, _this.codegenNoticeLines);
30
- var componentUtilsTSTemplate = new templates_1.ComponentUtilsTSTemplate(name, _this.codegenNoticeLines, _this.rnohImport);
31
- shape.props.forEach(function (prop) {
19
+ }
20
+ generate(uberSchema) {
21
+ const typeAnnotationToTS = new core_1.TypeAnnotationToTS();
22
+ const result = new Map();
23
+ const componentSpecSchemas = uberSchema.findAllSpecSchemasByType('Component');
24
+ for (const componentSpecSchema of componentSpecSchemas) {
25
+ Object.entries(componentSpecSchema.components).map(([name, shape]) => {
26
+ const componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(name, this.codegenNoticeLines);
27
+ const componentUtilsTSTemplate = new templates_1.ComponentUtilsTSTemplate(name, this.codegenNoticeLines, this.rnohImport);
28
+ shape.props.forEach((prop) => {
32
29
  componentJSIBinderHTemplate.addProp({
33
30
  name: prop.name,
34
31
  isObject: prop.typeAnnotation.type === 'ObjectTypeAnnotation',
@@ -40,7 +37,7 @@ var ArkTSComponentCodeGeneratorCAPI = /** @class */ (function () {
40
37
  isOptional: prop.optional,
41
38
  });
42
39
  });
43
- shape.commands.forEach(function (command) {
40
+ shape.commands.forEach((command) => {
44
41
  componentJSIBinderHTemplate.addCommand({
45
42
  name: command.name,
46
43
  });
@@ -48,15 +45,13 @@ var ArkTSComponentCodeGeneratorCAPI = /** @class */ (function () {
48
45
  name: command.name,
49
46
  argsTSType: '[' +
50
47
  command.typeAnnotation.params
51
- .map(function (param) {
52
- return typeAnnotationToTS.convert(param.typeAnnotation) +
53
- (param.optional ? '?' : '');
54
- })
48
+ .map((param) => typeAnnotationToTS.convert(param.typeAnnotation) +
49
+ (param.optional ? '?' : ''))
55
50
  .join(', ') +
56
51
  ']',
57
52
  });
58
53
  });
59
- shape.events.forEach(function (event) {
54
+ shape.events.forEach((event) => {
60
55
  componentUtilsTSTemplate.addEvent({
61
56
  name: (0, core_1.createEventNameFromEventHandlerName)(event.name),
62
57
  payloadTSType: event.typeAnnotation.argument
@@ -68,18 +63,15 @@ var ArkTSComponentCodeGeneratorCAPI = /** @class */ (function () {
68
63
  eventHandlerName: event.name,
69
64
  });
70
65
  });
71
- result.set(_this.cppOutputPath.copyWithNewSegment("".concat(name, "JSIBinder.h")), componentJSIBinderHTemplate.build());
72
- result.set(_this.tsOutputPath.copyWithNewSegment("".concat(name, ".ts")), componentUtilsTSTemplate.build());
73
- _this.glueCodeDataItems.push({
66
+ result.set(this.cppOutputPath.copyWithNewSegment(`${name}JSIBinder.h`), componentJSIBinderHTemplate.build());
67
+ result.set(this.tsOutputPath.copyWithNewSegment(`${name}.ts`), componentUtilsTSTemplate.build());
68
+ this.glueCodeDataItems.push({
74
69
  componentName: name,
75
- eventNames: shape.events.map(function (event) {
76
- return (0, core_1.createEventNameFromEventHandlerName)(event.name);
77
- }),
70
+ eventNames: shape.events.map((event) => (0, core_1.createEventNameFromEventHandlerName)(event.name)),
78
71
  });
79
72
  });
80
73
  }
81
74
  return result;
82
- };
83
- return ArkTSComponentCodeGeneratorCAPI;
84
- }());
75
+ }
76
+ }
85
77
  exports.ArkTSComponentCodeGeneratorCAPI = ArkTSComponentCodeGeneratorCAPI;
@@ -1,64 +1,59 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CppComponentCodeGenerator = void 0;
4
- var templates_1 = require("../templates");
5
- var CppComponentCodeGenerator = /** @class */ (function () {
6
- function CppComponentCodeGenerator(onGetRNOHOutputPath, codegenNoticeLines) {
4
+ const templates_1 = require("../templates");
5
+ class CppComponentCodeGenerator {
6
+ constructor(onGetRNOHOutputPath, codegenNoticeLines) {
7
7
  this.onGetRNOHOutputPath = onGetRNOHOutputPath;
8
8
  this.codegenNoticeLines = codegenNoticeLines;
9
9
  this.glueCodeComponentsData = [];
10
10
  }
11
- CppComponentCodeGenerator.prototype.getGlueCodeData = function () {
11
+ getGlueCodeData() {
12
12
  return this.glueCodeComponentsData;
13
- };
14
- CppComponentCodeGenerator.prototype.generate = function (_a) {
15
- var _this = this;
16
- var libraryCppName = _a.libraryCppName, uberSchema = _a.uberSchema;
17
- var fileContentByPath = new Map();
18
- for (var _i = 0, _b = uberSchema
13
+ }
14
+ generate({ libraryCppName, uberSchema, }) {
15
+ const fileContentByPath = new Map();
16
+ for (const [_filename, schema] of uberSchema
19
17
  .getSpecSchemaByFilenameMap()
20
- .entries(); _i < _b.length; _i++) {
21
- var _c = _b[_i], _filename = _c[0], schema = _c[1];
18
+ .entries()) {
22
19
  if (schema.type === 'Component') {
23
- Object.entries(schema.components).map(function (_a) {
24
- var componentName = _a[0], shape = _a[1];
25
- var componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(componentName, _this.codegenNoticeLines);
26
- var componentInstanceSpecHTemplate = new templates_1.BaseComponentInstanceHTemplate(componentName, libraryCppName, _this.codegenNoticeLines);
27
- shape.props.forEach(function (prop) {
20
+ Object.entries(schema.components).map(([componentName, shape]) => {
21
+ const componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(componentName, this.codegenNoticeLines);
22
+ const componentInstanceSpecHTemplate = new templates_1.BaseComponentInstanceHTemplate(componentName, libraryCppName, this.codegenNoticeLines);
23
+ shape.props.forEach((prop) => {
28
24
  componentJSIBinderHTemplate.addProp({
29
25
  name: prop.name,
30
26
  isObject: prop.typeAnnotation.type === 'ObjectTypeAnnotation',
31
27
  });
32
28
  });
33
- shape.events.forEach(function (event) {
29
+ shape.events.forEach((event) => {
34
30
  componentJSIBinderHTemplate.addEvent({
35
31
  type: event.bubblingType,
36
32
  eventHandlerName: event.name,
37
33
  });
38
34
  });
39
- shape.commands.forEach(function (command) {
35
+ shape.commands.forEach((command) => {
40
36
  componentJSIBinderHTemplate.addCommand({
41
37
  name: command.name,
42
38
  });
43
39
  componentInstanceSpecHTemplate.addCommand({
44
40
  name: command.name,
45
- args: command.typeAnnotation.params.map(function (param) { return ({
41
+ args: command.typeAnnotation.params.map((param) => ({
46
42
  name: param.name,
47
43
  typeAnnotation: param.typeAnnotation,
48
- }); }),
44
+ })),
49
45
  });
50
46
  });
51
- fileContentByPath.set(_this.onGetRNOHOutputPath("".concat(componentName, "JSIBinder.h")), componentJSIBinderHTemplate.build());
52
- fileContentByPath.set(_this.onGetRNOHOutputPath("Base".concat(componentName, "ComponentInstance.h")), componentInstanceSpecHTemplate.build());
53
- _this.glueCodeComponentsData.push({
47
+ fileContentByPath.set(this.onGetRNOHOutputPath(`${componentName}JSIBinder.h`), componentJSIBinderHTemplate.build());
48
+ fileContentByPath.set(this.onGetRNOHOutputPath(`Base${componentName}ComponentInstance.h`), componentInstanceSpecHTemplate.build());
49
+ this.glueCodeComponentsData.push({
54
50
  name: componentName,
55
- libraryCppName: libraryCppName,
51
+ libraryCppName,
56
52
  });
57
53
  });
58
54
  }
59
55
  }
60
56
  return fileContentByPath;
61
- };
62
- return CppComponentCodeGenerator;
63
- }());
57
+ }
58
+ }
64
59
  exports.CppComponentCodeGenerator = CppComponentCodeGenerator;
@@ -1,43 +1,41 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.LibGlueCodeGenerator = void 0;
4
- var case_1 = require("case");
5
- var BasePackageHTemplate_1 = require("../templates/BasePackageHTemplate");
6
- var templates_1 = require("../templates");
7
+ const case_1 = __importDefault(require("case"));
8
+ const BasePackageHTemplate_1 = require("../templates/BasePackageHTemplate");
9
+ const templates_1 = require("../templates");
7
10
  /**
8
11
  * NOTE: This class is coupled with the generated code structure defined in the codegen-harmony-lib.
9
12
  */
10
- var LibGlueCodeGenerator = /** @class */ (function () {
11
- function LibGlueCodeGenerator(cppOutputPath, etsOutputPath, codegenNoticeLines) {
13
+ class LibGlueCodeGenerator {
14
+ constructor(cppOutputPath, etsOutputPath, codegenNoticeLines) {
12
15
  this.cppOutputPath = cppOutputPath;
13
16
  this.etsOutputPath = etsOutputPath;
14
17
  this.codegenNoticeLines = codegenNoticeLines;
15
18
  }
16
- LibGlueCodeGenerator.prototype.generate = function (_a) {
17
- var libraryCppName = _a.libraryCppName, turboModules = _a.turboModules, arkTSComponents = _a.arkTSComponents, cppComponents = _a.cppComponents;
18
- var fileContentByPath = new Map();
19
- var basePackageClassName = "Base".concat(case_1.default.pascal(libraryCppName), "Package");
20
- var turboModules_indexTS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
21
- var components_indexTS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
22
- var generated_indexETS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
23
- var basePackageTemplate = new BasePackageHTemplate_1.BasePackageHTemplate(basePackageClassName, this.codegenNoticeLines);
24
- turboModules.forEach(function (turboModule) {
19
+ generate({ libraryCppName, turboModules, arkTSComponents, cppComponents, }) {
20
+ const fileContentByPath = new Map();
21
+ const basePackageClassName = `Base${case_1.default.pascal(libraryCppName)}Package`;
22
+ const turboModules_indexTS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
23
+ const components_indexTS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
24
+ const generated_indexETS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
25
+ const basePackageTemplate = new BasePackageHTemplate_1.BasePackageHTemplate(basePackageClassName, this.codegenNoticeLines);
26
+ turboModules.forEach((turboModule) => {
25
27
  basePackageTemplate.addTurboModule(turboModule);
26
- turboModules_indexTS.addReexport({ from: "./".concat(turboModule.name) });
28
+ turboModules_indexTS.addReexport({ from: `./${turboModule.name}` });
27
29
  });
28
- arkTSComponents.forEach(function (_a) {
29
- var componentName = _a.componentName, eventNames = _a.eventNames;
30
- components_indexTS.addReexport({ from: "./".concat(componentName) });
31
- basePackageTemplate.addComponent({ name: componentName, libraryCppName: libraryCppName, isArkTSComponent: true });
32
- eventNames.forEach(function (eventName) {
33
- return basePackageTemplate.addArkTSEvent({ name: eventName });
34
- });
30
+ arkTSComponents.forEach(({ componentName, eventNames }) => {
31
+ components_indexTS.addReexport({ from: `./${componentName}` });
32
+ basePackageTemplate.addComponent({ name: componentName, libraryCppName, isArkTSComponent: true });
33
+ eventNames.forEach((eventName) => basePackageTemplate.addArkTSEvent({ name: eventName }));
35
34
  });
36
- cppComponents.forEach(function (_a) {
37
- var componentName = _a.componentName;
38
- basePackageTemplate.addComponent({ name: componentName, libraryCppName: libraryCppName, isArkTSComponent: false });
35
+ cppComponents.forEach(({ componentName }) => {
36
+ basePackageTemplate.addComponent({ name: componentName, libraryCppName, isArkTSComponent: false });
39
37
  });
40
- fileContentByPath.set(this.cppOutputPath.copyWithNewSegment('RNOH', 'generated', "".concat(basePackageClassName, ".h")), basePackageTemplate.build());
38
+ fileContentByPath.set(this.cppOutputPath.copyWithNewSegment('RNOH', 'generated', `${basePackageClassName}.h`), basePackageTemplate.build());
41
39
  fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('components', 'ts.ts'), components_indexTS.build());
42
40
  fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('turboModules', 'ts.ts'), turboModules_indexTS.build());
43
41
  fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('ts.ts'), new templates_1.IndexTSTemplate(this.codegenNoticeLines)
@@ -47,7 +45,6 @@ var LibGlueCodeGenerator = /** @class */ (function () {
47
45
  generated_indexETS.addReexport({ from: './ts' });
48
46
  fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('index.ets'), generated_indexETS.build());
49
47
  return fileContentByPath;
50
- };
51
- return LibGlueCodeGenerator;
52
- }());
48
+ }
49
+ }
53
50
  exports.LibGlueCodeGenerator = LibGlueCodeGenerator;
@@ -1,55 +1,53 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NativeModuleCodeGenerator = void 0;
4
- var templates_1 = require("../templates");
5
- var core_1 = require("../core");
4
+ const templates_1 = require("../templates");
5
+ const core_1 = require("../core");
6
6
  /**
7
7
  * Generates boilerplate code for Turbo Modules.
8
8
  */
9
- var NativeModuleCodeGenerator = /** @class */ (function () {
10
- function NativeModuleCodeGenerator(cppOutputPath, etsOutputPath, codegenNoticeLines, rnohImport) {
9
+ class NativeModuleCodeGenerator {
10
+ constructor(cppOutputPath, etsOutputPath, codegenNoticeLines, rnohImport) {
11
11
  this.cppOutputPath = cppOutputPath;
12
12
  this.etsOutputPath = etsOutputPath;
13
13
  this.codegenNoticeLines = codegenNoticeLines;
14
14
  this.rnohImport = rnohImport;
15
15
  this.glueCodeTurboModulesData = [];
16
16
  }
17
- NativeModuleCodeGenerator.prototype.getGlueCodeData = function () {
17
+ getGlueCodeData() {
18
18
  return this.glueCodeTurboModulesData;
19
- };
20
- NativeModuleCodeGenerator.prototype.generate = function (schema) {
21
- var result = new Map();
19
+ }
20
+ generate(schema) {
21
+ const result = new Map();
22
22
  if (schema.type !== 'NativeModule') {
23
23
  throw new core_1.CodegenError({
24
- whatHappened: "NativeModuleCodeGenerator can't generate code for module type: ".concat(schema.type),
24
+ whatHappened: `NativeModuleCodeGenerator can't generate code for module type: ${schema.type}`,
25
25
  unexpected: true,
26
26
  });
27
27
  }
28
- var typeAnnotationToTS = new core_1.TypeAnnotationToTS();
29
- var turboModuleInterfaceTS = new templates_1.TurboModuleInterfaceTS(schema.moduleName, this.codegenNoticeLines, this.rnohImport);
30
- var turboModuleH = new templates_1.TurboModuleHTemplate(schema.moduleName, this.codegenNoticeLines).build();
31
- result.set(this.cppOutputPath.copyWithNewSegment("".concat(schema.moduleName, ".h")), turboModuleH);
32
- var turboModuleCpp = new templates_1.TurboModuleCppTemplate(schema.moduleName, this.codegenNoticeLines);
33
- Object.entries(schema.aliasMap).map(function (_a) {
34
- var name = _a[0], typeAnnotation = _a[1];
28
+ const typeAnnotationToTS = new core_1.TypeAnnotationToTS();
29
+ const turboModuleInterfaceTS = new templates_1.TurboModuleInterfaceTS(schema.moduleName, this.codegenNoticeLines, this.rnohImport);
30
+ const turboModuleH = new templates_1.TurboModuleHTemplate(schema.moduleName, this.codegenNoticeLines).build();
31
+ result.set(this.cppOutputPath.copyWithNewSegment(`${schema.moduleName}.h`), turboModuleH);
32
+ const turboModuleCpp = new templates_1.TurboModuleCppTemplate(schema.moduleName, this.codegenNoticeLines);
33
+ Object.entries(schema.aliasMap).map(([name, typeAnnotation]) => {
35
34
  turboModuleInterfaceTS.addAlias({
36
35
  name: name,
37
36
  type: typeAnnotationToTS.convert(typeAnnotation),
38
37
  });
39
38
  });
40
- Object.entries(schema.enumMap).map(function (_a) {
41
- var name = _a[0], enumSpec = _a[1];
39
+ Object.entries(schema.enumMap).map(([name, enumSpec]) => {
42
40
  turboModuleInterfaceTS.addEnum({
43
- name: name,
44
- members: enumSpec.members.map(function (member) { return ({
41
+ name,
42
+ members: enumSpec.members.map((member) => ({
45
43
  name: member.name,
46
44
  value: typeof member.value === 'string'
47
45
  ? (0, core_1.wrapWithQuotes)(member.value)
48
46
  : member.value.toString(),
49
- }); }),
47
+ })),
50
48
  });
51
49
  });
52
- schema.spec.methods.map(function (prop) {
50
+ schema.spec.methods.map((prop) => {
53
51
  if (prop.typeAnnotation.type === 'FunctionTypeAnnotation') {
54
52
  turboModuleCpp.addMethod({
55
53
  name: prop.name,
@@ -61,18 +59,15 @@ var NativeModuleCodeGenerator = /** @class */ (function () {
61
59
  name: prop.name,
62
60
  returnType: typeAnnotationToTS.convert(prop.typeAnnotation.returnTypeAnnotation),
63
61
  stringifiedArgs: prop.typeAnnotation.params
64
- .map(function (param) {
65
- return "".concat(param.name, ": ").concat(typeAnnotationToTS.convert(param.typeAnnotation));
66
- })
62
+ .map((param) => `${param.name}: ${typeAnnotationToTS.convert(param.typeAnnotation)}`)
67
63
  .join(', '),
68
64
  });
69
65
  }
70
66
  });
71
- result.set(this.cppOutputPath.copyWithNewSegment("".concat(schema.moduleName, ".cpp")), turboModuleCpp.build());
72
- result.set(this.etsOutputPath.copyWithNewSegment("".concat(schema.moduleName, ".ts")), turboModuleInterfaceTS.build());
67
+ result.set(this.cppOutputPath.copyWithNewSegment(`${schema.moduleName}.cpp`), turboModuleCpp.build());
68
+ result.set(this.etsOutputPath.copyWithNewSegment(`${schema.moduleName}.ts`), turboModuleInterfaceTS.build());
73
69
  this.glueCodeTurboModulesData.push({ name: schema.moduleName });
74
70
  return result;
75
- };
76
- return NativeModuleCodeGenerator;
77
- }());
71
+ }
72
+ }
78
73
  exports.NativeModuleCodeGenerator = NativeModuleCodeGenerator;
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.SharedComponentCodeGenerator = void 0;
4
- var RNCodegen_1 = require("@react-native/codegen/lib/generators/RNCodegen");
5
- var SharedComponentCodeGenerator = /** @class */ (function () {
6
- function SharedComponentCodeGenerator(onGetSharedOutputPath) {
7
+ const RNCodegen_1 = __importDefault(require("@react-native/codegen/lib/generators/RNCodegen"));
8
+ class SharedComponentCodeGenerator {
9
+ constructor(onGetSharedOutputPath) {
7
10
  this.onGetSharedOutputPath = onGetSharedOutputPath;
8
11
  }
9
- SharedComponentCodeGenerator.prototype.generate = function (_a) {
10
- var _this = this;
11
- var libraryCppName = _a.libraryCppName, uberSchema = _a.uberSchema;
12
- var fileContentByPath = new Map();
13
- var generatorFns = [
12
+ generate({ libraryCppName, uberSchema, }) {
13
+ const fileContentByPath = new Map();
14
+ const generatorFns = [
14
15
  RNCodegen_1.default.allGenerators.generatePropsH,
15
16
  RNCodegen_1.default.allGenerators.generatePropsCpp,
16
17
  RNCodegen_1.default.allGenerators.generateEventEmitterH,
@@ -21,14 +22,13 @@ var SharedComponentCodeGenerator = /** @class */ (function () {
21
22
  RNCodegen_1.default.allGenerators.generateShadowNodeH,
22
23
  RNCodegen_1.default.allGenerators.generateShadowNodeCpp,
23
24
  ];
24
- generatorFns.forEach(function (generate) {
25
- var filesOutput = generate(libraryCppName, uberSchema.getValue(), 'UNUSED_packageName', true);
26
- filesOutput.forEach(function (fileContent, filename) {
27
- fileContentByPath.set(_this.onGetSharedOutputPath(filename), fileContent);
25
+ generatorFns.forEach((generate) => {
26
+ const filesOutput = generate(libraryCppName, uberSchema.getValue(), 'UNUSED_packageName', true);
27
+ filesOutput.forEach((fileContent, filename) => {
28
+ fileContentByPath.set(this.onGetSharedOutputPath(filename), fileContent);
28
29
  });
29
30
  });
30
31
  return fileContentByPath;
31
- };
32
- return SharedComponentCodeGenerator;
33
- }());
32
+ }
33
+ }
34
34
  exports.SharedComponentCodeGenerator = SharedComponentCodeGenerator;
@@ -1,47 +1,49 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.UberGeneratorV1 = void 0;
4
- var path_1 = require("path");
5
- var core_1 = require("../core");
6
- var NativeModuleCodeGenerator_1 = require("./NativeModuleCodeGenerator");
7
- var ArkTSComponentCodeGeneratorArkTS_1 = require("./ArkTSComponentCodeGeneratorArkTS");
7
+ const path_1 = __importDefault(require("path"));
8
+ const core_1 = require("../core");
9
+ const NativeModuleCodeGenerator_1 = require("./NativeModuleCodeGenerator");
10
+ const ArkTSComponentCodeGeneratorArkTS_1 = require("./ArkTSComponentCodeGeneratorArkTS");
8
11
  // The name of rnoh OHOS module
9
- var RNOH_OHOS_NAME = '@rnoh/react-native-openharmony';
12
+ const RNOH_OHOS_NAME = '@rnoh/react-native-openharmony';
10
13
  /**
11
14
  * Generates code for libraries built on top of RNOH's ArkTS architecture.
12
15
  */
13
- var UberGeneratorV1 = /** @class */ (function () {
14
- function UberGeneratorV1(cppOutputPath, etsOutputPath, codegenNoticeLines) {
16
+ class UberGeneratorV1 {
17
+ constructor(cppOutputPath, etsOutputPath, codegenNoticeLines) {
15
18
  this.cppOutputPath = cppOutputPath;
16
19
  this.etsOutputPath = etsOutputPath;
17
20
  this.codegenNoticeLines = codegenNoticeLines;
18
21
  this.glueCodeData = { components: [], turboModules: [] };
19
22
  }
20
- UberGeneratorV1.prototype.getGlueCodeData = function () {
23
+ getGlueCodeData() {
21
24
  return this.glueCodeData;
22
- };
23
- UberGeneratorV1.prototype.generate = function (uberSchema) {
24
- var fileContentByPath = new Map();
25
- var isRNOHModulePath = this.etsOutputPath.getValue().endsWith("".concat(RNOH_OHOS_NAME, "/generated").replace(/\//g, path_1.default.sep));
26
- var componentCodeGenerator = new ArkTSComponentCodeGeneratorArkTS_1.ArkTSComponentCodeGeneratorArkTS(this.cppOutputPath, this.etsOutputPath.copyWithNewSegment('components'), this.codegenNoticeLines, isRNOHModulePath ? '../../ts' : "".concat(RNOH_OHOS_NAME, "/ts"));
27
- var nativeModuleCodeGenerator = new NativeModuleCodeGenerator_1.NativeModuleCodeGenerator(this.cppOutputPath, this.etsOutputPath.copyWithNewSegment('turboModules'), this.codegenNoticeLines, isRNOHModulePath ? '../../ts' : "".concat(RNOH_OHOS_NAME, "/ts"));
28
- var generatorBySpecType = {
25
+ }
26
+ generate(uberSchema) {
27
+ const fileContentByPath = new Map();
28
+ const isRNOHModulePath = this.etsOutputPath.getValue().endsWith(`${RNOH_OHOS_NAME}/generated`.replace(/\//g, path_1.default.sep));
29
+ const componentCodeGenerator = new ArkTSComponentCodeGeneratorArkTS_1.ArkTSComponentCodeGeneratorArkTS(this.cppOutputPath, this.etsOutputPath.copyWithNewSegment('components'), this.codegenNoticeLines, isRNOHModulePath ? '../../ts' : `${RNOH_OHOS_NAME}/ts`);
30
+ const nativeModuleCodeGenerator = new NativeModuleCodeGenerator_1.NativeModuleCodeGenerator(this.cppOutputPath, this.etsOutputPath.copyWithNewSegment('turboModules'), this.codegenNoticeLines, isRNOHModulePath ? '../../ts' : `${RNOH_OHOS_NAME}/ts`);
31
+ const generatorBySpecType = {
29
32
  Component: componentCodeGenerator,
30
33
  NativeModule: nativeModuleCodeGenerator,
31
34
  };
32
- for (var _i = 0, _a = uberSchema
35
+ for (const [_fileName, specSchema] of uberSchema
33
36
  .getSpecSchemaByFilenameMap()
34
- .entries(); _i < _a.length; _i++) {
35
- var _b = _a[_i], _fileName = _b[0], specSchema = _b[1];
37
+ .entries()) {
36
38
  if (!(specSchema.type in generatorBySpecType)) {
37
39
  throw new core_1.CodegenError({
38
- whatHappened: "Could not find a code generator for a specification of type '".concat(specSchema.type, "'"),
40
+ whatHappened: `Could not find a code generator for a specification of type '${specSchema.type}'`,
39
41
  unexpected: true,
40
42
  });
41
43
  }
42
44
  generatorBySpecType[specSchema.type]
43
45
  .generate(specSchema)
44
- .forEach(function (fileContent, filePath) {
46
+ .forEach((fileContent, filePath) => {
45
47
  fileContentByPath.set(filePath, fileContent);
46
48
  });
47
49
  }
@@ -50,7 +52,6 @@ var UberGeneratorV1 = /** @class */ (function () {
50
52
  turboModules: nativeModuleCodeGenerator.getGlueCodeData(),
51
53
  };
52
54
  return fileContentByPath;
53
- };
54
- return UberGeneratorV1;
55
- }());
55
+ }
56
+ }
56
57
  exports.UberGeneratorV1 = UberGeneratorV1;
@@ -1,79 +1,78 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.UberGeneratorV2 = void 0;
4
- var path_1 = require("path");
5
- var CppComponentCodeGenerator_1 = require("./CppComponentCodeGenerator");
6
- var NativeModuleCodeGenerator_1 = require("./NativeModuleCodeGenerator");
7
- var SharedComponentCodeGenerator_1 = require("./SharedComponentCodeGenerator");
7
+ const path_1 = __importDefault(require("path"));
8
+ const CppComponentCodeGenerator_1 = require("./CppComponentCodeGenerator");
9
+ const NativeModuleCodeGenerator_1 = require("./NativeModuleCodeGenerator");
10
+ const SharedComponentCodeGenerator_1 = require("./SharedComponentCodeGenerator");
8
11
  // The name of rnoh OHOS module
9
- var RNOH_OHOS_NAME = '@rnoh/react-native-openharmony';
12
+ const RNOH_OHOS_NAME = '@rnoh/react-native-openharmony';
10
13
  /**
11
14
  * Generates code for libraries built on top of RNOH's C-API architecture.
12
15
  */
13
- var UberGeneratorV2 = /** @class */ (function () {
14
- function UberGeneratorV2(cppOutputPath, etsOutputPath, codegenNoticeLines) {
16
+ class UberGeneratorV2 {
17
+ constructor(cppOutputPath, etsOutputPath, codegenNoticeLines) {
15
18
  this.cppOutputPath = cppOutputPath;
16
19
  this.etsOutputPath = etsOutputPath;
17
20
  this.codegenNoticeLines = codegenNoticeLines;
18
21
  this.glueCodeData = new Map();
19
22
  }
20
- UberGeneratorV2.prototype.getGlueCodeData = function () {
23
+ getGlueCodeData() {
21
24
  return this.glueCodeData;
22
- };
23
- UberGeneratorV2.prototype.generate = function (npmPackagesInfo) {
24
- var _this = this;
25
- var fileContentByPath = new Map();
26
- npmPackagesInfo.forEach(function (_a) {
27
- var libraryCppName = _a.libraryCppName, uberSchema = _a.uberSchema;
28
- _this.glueCodeData.set(libraryCppName, {
25
+ }
26
+ generate(npmPackagesInfo) {
27
+ const fileContentByPath = new Map();
28
+ npmPackagesInfo.forEach(({ libraryCppName, uberSchema }) => {
29
+ this.glueCodeData.set(libraryCppName, {
29
30
  components: [],
30
31
  turboModules: [],
31
32
  });
32
- var libraryGlueCodeData = _this.glueCodeData.get(libraryCppName);
33
- var libraryCppOutput = _this.cppOutputPath.copyWithNewSegment(libraryCppName);
34
- var sharedComponentCodeGenerator = new SharedComponentCodeGenerator_1.SharedComponentCodeGenerator(function (filename) {
33
+ const libraryGlueCodeData = this.glueCodeData.get(libraryCppName);
34
+ const libraryCppOutput = this.cppOutputPath.copyWithNewSegment(libraryCppName);
35
+ const sharedComponentCodeGenerator = new SharedComponentCodeGenerator_1.SharedComponentCodeGenerator((filename) => {
35
36
  return libraryCppOutput.copyWithNewSegment('react', 'renderer', 'components', libraryCppName, filename);
36
37
  });
37
- var cppComponentCodeGenerator = new CppComponentCodeGenerator_1.CppComponentCodeGenerator(function (filename) {
38
+ const cppComponentCodeGenerator = new CppComponentCodeGenerator_1.CppComponentCodeGenerator((filename) => {
38
39
  return libraryCppOutput.copyWithNewSegment('RNOH', 'generated', 'components', filename);
39
- }, _this.codegenNoticeLines);
40
+ }, this.codegenNoticeLines);
40
41
  cppComponentCodeGenerator
41
- .generate({ libraryCppName: libraryCppName, uberSchema: uberSchema })
42
- .forEach(function (fileContent, path) {
42
+ .generate({ libraryCppName, uberSchema })
43
+ .forEach((fileContent, path) => {
43
44
  fileContentByPath.set(path, fileContent);
44
45
  });
45
46
  cppComponentCodeGenerator
46
47
  .getGlueCodeData()
47
- .forEach(function (componentGlueCodeData) {
48
+ .forEach((componentGlueCodeData) => {
48
49
  libraryGlueCodeData.components.push(componentGlueCodeData);
49
50
  });
50
51
  sharedComponentCodeGenerator
51
- .generate({ libraryCppName: libraryCppName, uberSchema: uberSchema })
52
- .forEach(function (fileContent, path) {
52
+ .generate({ libraryCppName, uberSchema })
53
+ .forEach((fileContent, path) => {
53
54
  fileContentByPath.set(path, fileContent);
54
55
  });
55
- for (var _i = 0, _b = uberSchema
56
+ for (const [_fileName, specSchema] of uberSchema
56
57
  .getSpecSchemaByFilenameMap()
57
- .entries(); _i < _b.length; _i++) {
58
- var _c = _b[_i], _fileName = _c[0], specSchema = _c[1];
58
+ .entries()) {
59
59
  if (specSchema.type === 'NativeModule') {
60
- var isRNOHModulePath = _this.etsOutputPath.getValue().endsWith("".concat(RNOH_OHOS_NAME, "/generated").replace(/\//g, path_1.default.sep));
61
- var nativeModuleCodeGenerator = new NativeModuleCodeGenerator_1.NativeModuleCodeGenerator(libraryCppOutput.copyWithNewSegment('RNOH', 'generated', 'turbo_modules'), _this.etsOutputPath.copyWithNewSegment('turboModules'), _this.codegenNoticeLines, isRNOHModulePath ? '../../ts' : "".concat(RNOH_OHOS_NAME, "/ts"));
60
+ const isRNOHModulePath = this.etsOutputPath.getValue().endsWith(`${RNOH_OHOS_NAME}/generated`.replace(/\//g, path_1.default.sep));
61
+ const nativeModuleCodeGenerator = new NativeModuleCodeGenerator_1.NativeModuleCodeGenerator(libraryCppOutput.copyWithNewSegment('RNOH', 'generated', 'turbo_modules'), this.etsOutputPath.copyWithNewSegment('turboModules'), this.codegenNoticeLines, isRNOHModulePath ? '../../ts' : `${RNOH_OHOS_NAME}/ts`);
62
62
  nativeModuleCodeGenerator
63
63
  .generate(specSchema)
64
- .forEach(function (fileContent, filePath) {
64
+ .forEach((fileContent, filePath) => {
65
65
  fileContentByPath.set(filePath, fileContent);
66
66
  });
67
67
  nativeModuleCodeGenerator
68
68
  .getGlueCodeData()
69
- .forEach(function (turboModuleGlueCodeData) {
69
+ .forEach((turboModuleGlueCodeData) => {
70
70
  libraryGlueCodeData.turboModules.push(turboModuleGlueCodeData);
71
71
  });
72
72
  }
73
73
  }
74
74
  });
75
75
  return fileContentByPath;
76
- };
77
- return UberGeneratorV2;
78
- }());
76
+ }
77
+ }
79
78
  exports.UberGeneratorV2 = UberGeneratorV2;