@react-native-oh/react-native-harmony-cli 0.0.37 → 0.0.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 (138) hide show
  1. package/README.md +11 -11
  2. package/dist/assetResolver.js +74 -43
  3. package/dist/autolinking/Autolinking.js +183 -179
  4. package/dist/codegen/core/CodegenError.js +23 -3
  5. package/dist/codegen/core/EventUtils.js +3 -3
  6. package/dist/codegen/core/TypeAnnotationToTS.js +28 -24
  7. package/dist/codegen/core/UberSchema.js +96 -57
  8. package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +41 -28
  9. package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +34 -27
  10. package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +33 -25
  11. package/dist/codegen/generators/CppComponentCodeGenerator.js +28 -23
  12. package/dist/codegen/generators/LibGlueCodeGenerator.js +29 -26
  13. package/dist/codegen/generators/NativeModuleCodeGenerator.js +30 -25
  14. package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
  15. package/dist/codegen/generators/UberGeneratorV1.js +24 -18
  16. package/dist/codegen/generators/UberGeneratorV2.js +36 -28
  17. package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +24 -50
  18. package/dist/codegen/templates/BasePackageHTemplate.js +21 -120
  19. package/dist/codegen/templates/ComponentDescriptorHTemplate.js +8 -53
  20. package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +27 -75
  21. package/dist/codegen/templates/ComponentUtilsTSTemplate.js +29 -162
  22. package/dist/codegen/templates/IndexTSTemplate.js +17 -37
  23. package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +24 -119
  24. package/dist/codegen/templates/TurboModuleCppTemplate.js +15 -38
  25. package/dist/codegen/templates/TurboModuleHTemplate.js +11 -32
  26. package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +19 -52
  27. package/dist/commands/bundle-harmony.js +138 -53
  28. package/dist/commands/codegen-harmony.js +175 -104
  29. package/dist/commands/codegen-lib-harmony.js +116 -76
  30. package/dist/commands/create-metro-host-constants.js +47 -18
  31. package/dist/commands/init.js +961 -537
  32. package/dist/commands/link-harmony.js +71 -33
  33. package/dist/commands/pack-harmony.js +108 -47
  34. package/dist/commands/run-harmony.js +518 -374
  35. package/dist/commands/unpack-harmony.js +198 -105
  36. package/dist/commands/verify-package-harmony.js +108 -54
  37. package/dist/core/AbsolutePath.js +47 -31
  38. package/dist/core/CodegenConfig.js +22 -24
  39. package/dist/core/DescriptiveError.js +37 -18
  40. package/dist/core/FileSystem.js +18 -14
  41. package/dist/core/OHPackageJSON5.js +23 -17
  42. package/dist/core/PackageJSON.js +42 -26
  43. package/dist/core/ProjectDependenciesManager.js +96 -46
  44. package/dist/core/ValidationError.js +22 -2
  45. package/dist/core/fs.js +6 -9
  46. package/dist/index.js +1 -1
  47. package/dist/io/CliExecutor.js +98 -46
  48. package/dist/io/Logger.js +46 -40
  49. package/dist/io/RealFS.js +88 -35
  50. package/dist/io/TarGz.js +8 -11
  51. package/dist/io/__fixtures__.js +141 -79
  52. package/dist/io/fsUtils.js +12 -13
  53. package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +47 -19
  54. package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +41 -13
  55. package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +38 -8
  56. package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +54 -22
  57. package/dist/package-verifier/verify-package.js +132 -55
  58. package/dist/simulator/LaunchSimulator.js +301 -217
  59. package/jest.config.js +12 -12
  60. package/package.json +78 -70
  61. package/react-native.config.js +17 -17
  62. package/tsconfig.build.json +6 -6
  63. package/tsconfig.json +2 -2
  64. package/.prettierrc +0 -6
  65. package/src/assetResolver.ts +0 -134
  66. package/src/autolinking/Autolinking.test.ts +0 -483
  67. package/src/autolinking/Autolinking.ts +0 -382
  68. package/src/autolinking/index.ts +0 -8
  69. package/src/codegen/core/CodeGenerator.ts +0 -16
  70. package/src/codegen/core/CodegenError.ts +0 -10
  71. package/src/codegen/core/EventUtils.ts +0 -23
  72. package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -82
  73. package/src/codegen/core/TypeAnnotationToTS.ts +0 -195
  74. package/src/codegen/core/UberSchema.ts +0 -152
  75. package/src/codegen/core/index.ts +0 -12
  76. package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +0 -124
  77. package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +0 -128
  78. package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +0 -122
  79. package/src/codegen/generators/CppComponentCodeGenerator.ts +0 -95
  80. package/src/codegen/generators/LibGlueCodeGenerator.ts +0 -98
  81. package/src/codegen/generators/NativeModuleCodeGenerator.ts +0 -124
  82. package/src/codegen/generators/SharedComponentCodeGenerator.ts +0 -57
  83. package/src/codegen/generators/UberGeneratorV1.ts +0 -75
  84. package/src/codegen/generators/UberGeneratorV2.ts +0 -114
  85. package/src/codegen/generators/index.ts +0 -15
  86. package/src/codegen/index.ts +0 -9
  87. package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +0 -128
  88. package/src/codegen/templates/BasePackageHTemplate.ts +0 -159
  89. package/src/codegen/templates/ComponentDescriptorHTemplate.ts +0 -63
  90. package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +0 -121
  91. package/src/codegen/templates/ComponentUtilsTSTemplate.ts +0 -222
  92. package/src/codegen/templates/IndexTSTemplate.ts +0 -62
  93. package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +0 -150
  94. package/src/codegen/templates/TurboModuleCppTemplate.ts +0 -61
  95. package/src/codegen/templates/TurboModuleHTemplate.ts +0 -42
  96. package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +0 -101
  97. package/src/codegen/templates/index.ts +0 -16
  98. package/src/commands/bundle-harmony.ts +0 -134
  99. package/src/commands/codegen-harmony.ts +0 -297
  100. package/src/commands/codegen-lib-harmony.ts +0 -389
  101. package/src/commands/create-metro-host-constants.ts +0 -55
  102. package/src/commands/index.ts +0 -16
  103. package/src/commands/init.ts +0 -755
  104. package/src/commands/link-harmony.ts +0 -102
  105. package/src/commands/pack-harmony.ts +0 -128
  106. package/src/commands/run-harmony.ts +0 -506
  107. package/src/commands/types.ts +0 -21
  108. package/src/commands/unpack-harmony.ts +0 -238
  109. package/src/commands/verify-package-harmony.ts +0 -113
  110. package/src/core/AbsolutePath.ts +0 -66
  111. package/src/core/CodegenConfig.ts +0 -67
  112. package/src/core/DescriptiveError.ts +0 -68
  113. package/src/core/FileSystem.ts +0 -57
  114. package/src/core/OHPackageJSON5.ts +0 -30
  115. package/src/core/PackageJSON.ts +0 -104
  116. package/src/core/ProjectDependenciesManager.ts +0 -103
  117. package/src/core/ValidationError.ts +0 -8
  118. package/src/core/ValueObject.ts +0 -9
  119. package/src/core/fs.ts +0 -38
  120. package/src/core/index.ts +0 -17
  121. package/src/index.ts +0 -33
  122. package/src/io/CliExecutor.ts +0 -69
  123. package/src/io/Logger.ts +0 -112
  124. package/src/io/RealFS.ts +0 -62
  125. package/src/io/TarGz.ts +0 -33
  126. package/src/io/__fixtures__.ts +0 -139
  127. package/src/io/fsUtils.ts +0 -44
  128. package/src/io/index.ts +0 -11
  129. package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +0 -35
  130. package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +0 -31
  131. package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +0 -25
  132. package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +0 -54
  133. package/src/package-verifier/checks/index.ts +0 -11
  134. package/src/package-verifier/index.ts +0 -9
  135. package/src/package-verifier/types.ts +0 -19
  136. package/src/package-verifier/verify-package.ts +0 -123
  137. package/src/simulator/LaunchSimulator.ts +0 -352
  138. package/src/simulator/index.ts +0 -8
@@ -14,23 +14,60 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
14
14
  step((generator = generator.apply(thisArg, _arguments || [])).next());
15
15
  });
16
16
  };
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ var __generator = (this && this.__generator) || function (thisArg, body) {
18
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
19
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
20
+ function verb(n) { return function (v) { return step([n, v]); }; }
21
+ function step(op) {
22
+ if (f) throw new TypeError("Generator is already executing.");
23
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
24
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
25
+ if (y = 0, t) op = [op[0] & 2, t.value];
26
+ switch (op[0]) {
27
+ case 0: case 1: t = op; break;
28
+ case 4: _.label++; return { value: op[1], done: false };
29
+ case 5: _.label++; y = op[1]; op = [0]; continue;
30
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
31
+ default:
32
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
33
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
34
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
35
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
36
+ if (t[2]) _.ops.pop();
37
+ _.trys.pop(); continue;
38
+ }
39
+ op = body.call(thisArg, _);
40
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
41
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
42
+ }
43
+ };
44
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
45
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
46
+ if (ar || !(i in from)) {
47
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
48
+ ar[i] = from[i];
49
+ }
50
+ }
51
+ return to.concat(ar || Array.prototype.slice.call(from));
19
52
  };
20
53
  Object.defineProperty(exports, "__esModule", { value: true });
21
54
  exports.commandCodegenHarmony = void 0;
22
- const node_path_1 = __importDefault(require("node:path"));
23
- const case_1 = __importDefault(require("case"));
24
- const core_1 = require("../core");
25
- const codegen_1 = require("../codegen");
26
- const io_1 = require("../io");
55
+ var node_path_1 = require("node:path");
56
+ var case_1 = require("case");
57
+ var core_1 = require("../core");
58
+ var codegen_1 = require("../codegen");
59
+ var io_1 = require("../io");
27
60
  exports.commandCodegenHarmony = {
28
61
  name: 'codegen-harmony',
29
62
  description: 'Generates boilerplate, types, and utilities from Turbo Module and Fabric Component specifications. This command is meant to be executed during the application build process.',
30
63
  options: [
31
64
  {
32
65
  name: '--rnoh-module-path <path>',
33
- description: 'Specifies the relative path to the rnoh OHOS module',
66
+ description: '[deprecated] Specifies the relative path to the rnoh OHOS module',
67
+ },
68
+ {
69
+ name: '--ets-output-path <path>',
70
+ description: 'Specifies the relative path to the output directory intended for storing generated ETS files.',
34
71
  },
35
72
  {
36
73
  name: '--cpp-output-path <path>',
@@ -52,109 +89,141 @@ exports.commandCodegenHarmony = {
52
89
  description: 'Skips the check that prevents file operations outside the current working directory. This command permanently deletes previously generated files. Files are generated in the path specified by cpp-output-path.',
53
90
  },
54
91
  ],
55
- func: (_argv, _config, args) => __awaiter(void 0, void 0, void 0, function* () {
56
- const logger = new io_1.Logger();
57
- const fs = new io_1.RealFS();
58
- try {
59
- const MAX_SUPPORTED_CODEGEN_VERSION = 2;
60
- // prepare the input data
61
- validateArgs(args);
62
- const etsOutputPath = new core_1.AbsolutePath(args.rnohModulePath).copyWithNewSegment('generated');
63
- const enableSafetyCheck = args.safetyCheck;
64
- const cppOutputPath = new core_1.AbsolutePath(args.cppOutputPath);
65
- const projectRootPath = new core_1.AbsolutePath(args.projectRootPath);
66
- const uberSchemaFromArkTSLibraries = yield codegen_1.UberSchema.fromProject(fs, projectRootPath, (codegenVersion, packageName) => {
67
- throwErrorIfUnsupportedCodegenVersion(codegenVersion, MAX_SUPPORTED_CODEGEN_VERSION, packageName);
68
- return codegenVersion === 1;
69
- });
70
- const cApiLibrariesData = yield collectLibrariesData(fs, projectRootPath, (codegenVersion, packageName) => {
71
- throwErrorIfUnsupportedCodegenVersion(codegenVersion, MAX_SUPPORTED_CODEGEN_VERSION, packageName);
72
- return codegenVersion === 2;
73
- });
74
- // instantiate objects
75
- const codegenNoticeLines = [
76
- 'This code was generated by "react-native codegen-harmony"',
77
- '',
78
- 'Do not edit this file as changes may cause incorrect behavior and will be',
79
- 'lost once the code is regenerated.',
80
- ];
81
- const uberGeneratorV1 = new codegen_1.UberGeneratorV1(cppOutputPath, etsOutputPath, [...codegenNoticeLines, '', '@generatorVersion: 1']);
82
- const uberGeneratorV2 = new codegen_1.UberGeneratorV2(cppOutputPath, etsOutputPath, [...codegenNoticeLines, '', '@generatorVersion: 2']);
83
- const glueCodeGenerator = new codegen_1.AppBuildTimeGlueCodeGenerator(cppOutputPath, etsOutputPath, codegenNoticeLines);
84
- // generate the code
85
- const fileContentByPath = new Map();
86
- const appendToFileContentByPath = (fileContent, path) => {
87
- fileContentByPath.set(path, fileContent);
88
- };
89
- uberGeneratorV1
90
- .generate(uberSchemaFromArkTSLibraries)
91
- .forEach(appendToFileContentByPath);
92
- uberGeneratorV2
93
- .generate(cApiLibrariesData)
94
- .forEach(appendToFileContentByPath);
95
- glueCodeGenerator
96
- .generate({
97
- v1: uberGeneratorV1.getGlueCodeData(),
98
- v2: uberGeneratorV2.getGlueCodeData(),
99
- })
100
- .forEach(appendToFileContentByPath);
101
- // output the results
102
- if (args.debug) {
103
- const uberSchema = yield codegen_1.UberSchema.fromProject(fs, projectRootPath);
104
- logger.debug((styles) => styles.gray(JSON.stringify(uberSchema.getValue(), null, 2)));
105
- }
106
- saveCodegenResult(fs, fileContentByPath, cppOutputPath, etsOutputPath, enableSafetyCheck);
107
- logCodegenResult(logger, fileContentByPath, projectRootPath);
108
- }
109
- catch (err) {
110
- if (err instanceof core_1.DescriptiveError) {
111
- logger.descriptiveError(err);
112
- process.exit(1);
92
+ func: function (_argv, _config, args) { return __awaiter(void 0, void 0, void 0, function () {
93
+ var logger, fs, MAX_SUPPORTED_CODEGEN_VERSION_1, etsOutputPath, isEndWithGenerated, enableSafetyCheck, cppOutputPath, projectRootPath, uberSchemaFromArkTSLibraries, cApiLibrariesData, codegenNoticeLines, uberGeneratorV1, uberGeneratorV2, glueCodeGenerator, fileContentByPath_1, appendToFileContentByPath, uberSchema_1, err_1;
94
+ return __generator(this, function (_a) {
95
+ switch (_a.label) {
96
+ case 0:
97
+ logger = new io_1.Logger();
98
+ fs = new io_1.RealFS();
99
+ _a.label = 1;
100
+ case 1:
101
+ _a.trys.push([1, 6, , 7]);
102
+ MAX_SUPPORTED_CODEGEN_VERSION_1 = 2;
103
+ // prepare the input data
104
+ validateArgs(args);
105
+ etsOutputPath = args.etsOutputPath || args.rnohModulePath;
106
+ isEndWithGenerated = /\/generated\/?$/.test(etsOutputPath);
107
+ etsOutputPath = new core_1.AbsolutePath(etsOutputPath);
108
+ if (!isEndWithGenerated) {
109
+ etsOutputPath = etsOutputPath.copyWithNewSegment('generated');
110
+ }
111
+ enableSafetyCheck = args.safetyCheck;
112
+ cppOutputPath = new core_1.AbsolutePath(args.cppOutputPath);
113
+ projectRootPath = new core_1.AbsolutePath(args.projectRootPath);
114
+ return [4 /*yield*/, codegen_1.UberSchema.fromProject(fs, projectRootPath, function (codegenVersion, packageName) {
115
+ throwErrorIfUnsupportedCodegenVersion(codegenVersion, MAX_SUPPORTED_CODEGEN_VERSION_1, packageName);
116
+ return codegenVersion === 1;
117
+ })];
118
+ case 2:
119
+ uberSchemaFromArkTSLibraries = _a.sent();
120
+ return [4 /*yield*/, collectLibrariesData(fs, projectRootPath, function (codegenVersion, packageName) {
121
+ throwErrorIfUnsupportedCodegenVersion(codegenVersion, MAX_SUPPORTED_CODEGEN_VERSION_1, packageName);
122
+ return codegenVersion === 2;
123
+ })];
124
+ case 3:
125
+ cApiLibrariesData = _a.sent();
126
+ codegenNoticeLines = [
127
+ 'This code was generated by "react-native codegen-harmony"',
128
+ '',
129
+ 'Do not edit this file as changes may cause incorrect behavior and will be',
130
+ 'lost once the code is regenerated.',
131
+ ];
132
+ uberGeneratorV1 = new codegen_1.UberGeneratorV1(cppOutputPath, etsOutputPath, __spreadArray(__spreadArray([], codegenNoticeLines, true), ['', '@generatorVersion: 1'], false));
133
+ uberGeneratorV2 = new codegen_1.UberGeneratorV2(cppOutputPath, etsOutputPath, __spreadArray(__spreadArray([], codegenNoticeLines, true), ['', '@generatorVersion: 2'], false));
134
+ glueCodeGenerator = new codegen_1.AppBuildTimeGlueCodeGenerator(cppOutputPath, etsOutputPath, codegenNoticeLines);
135
+ fileContentByPath_1 = new Map();
136
+ appendToFileContentByPath = function (fileContent, path) {
137
+ fileContentByPath_1.set(path, fileContent);
138
+ };
139
+ uberGeneratorV1
140
+ .generate(uberSchemaFromArkTSLibraries)
141
+ .forEach(appendToFileContentByPath);
142
+ uberGeneratorV2
143
+ .generate(cApiLibrariesData)
144
+ .forEach(appendToFileContentByPath);
145
+ glueCodeGenerator
146
+ .generate({
147
+ v1: uberGeneratorV1.getGlueCodeData(),
148
+ v2: uberGeneratorV2.getGlueCodeData(),
149
+ })
150
+ .forEach(appendToFileContentByPath);
151
+ if (!args.debug) return [3 /*break*/, 5];
152
+ return [4 /*yield*/, codegen_1.UberSchema.fromProject(fs, projectRootPath)];
153
+ case 4:
154
+ uberSchema_1 = _a.sent();
155
+ logger.debug(function (styles) {
156
+ return styles.gray(JSON.stringify(uberSchema_1.getValue(), null, 2));
157
+ });
158
+ _a.label = 5;
159
+ case 5:
160
+ saveCodegenResult(fs, fileContentByPath_1, cppOutputPath, etsOutputPath, enableSafetyCheck);
161
+ logCodegenResult(logger, fileContentByPath_1, projectRootPath);
162
+ return [3 /*break*/, 7];
163
+ case 6:
164
+ err_1 = _a.sent();
165
+ if (err_1 instanceof core_1.DescriptiveError) {
166
+ logger.descriptiveError(err_1);
167
+ process.exit(1);
168
+ }
169
+ throw err_1;
170
+ case 7: return [2 /*return*/];
113
171
  }
114
- throw err;
115
- }
116
- }),
172
+ });
173
+ }); },
117
174
  };
118
175
  function validateArgs(args) {
119
- if (!args.rnohModulePath) {
176
+ if (!args.rnohModulePath && !args.etsOutputPath) {
120
177
  throw new core_1.DescriptiveError({
121
- whatHappened: "--rnoh-module-path argument wasn't provided",
178
+ whatHappened: '--ets-output-path is required',
122
179
  whatCanUserDo: [
123
- 'Please provide a path to the native React Native for Open Harmony module (rnoh) which is probably located somewhere in "<PROJECT_ROOT>/harmony" directory',
180
+ 'Please provide an output path for the ETS file.',
181
+ 'It is recommended to place it in the same directory as the custom component or TurboModule.',
182
+ 'Do not place it inside @rnoh/react-native-openharmony, otherwise a jscrash may occur when using react_native_openharmony_release2.har.'
124
183
  ],
125
184
  });
126
185
  }
127
186
  }
128
187
  function collectLibrariesData(fs, projectRootPath, onShouldAcceptCodegenConfig) {
129
- return __awaiter(this, void 0, void 0, function* () {
130
- const packageJSONs = [
131
- core_1.PackageJSON.fromProjectRootPath(fs, projectRootPath, projectRootPath),
132
- ];
133
- yield new core_1.ProjectDependenciesManager(fs, projectRootPath).forEachAsync((dependency) => {
134
- packageJSONs.push(dependency.readPackageJSON());
135
- });
136
- const results = [];
137
- for (const packageJSON of packageJSONs) {
138
- const codegenConfigs = packageJSON.getCodegenConfigs();
139
- for (const codegenConfig of codegenConfigs) {
140
- if (codegenConfig &&
141
- onShouldAcceptCodegenConfig(codegenConfig.getVersion(), packageJSON.name)) {
142
- results.push({
143
- libraryCppName: deriveCppDirectoryNameFromNpmPackageName(packageJSON.name),
144
- uberSchema: codegen_1.UberSchema.fromCodegenConfig(codegenConfig),
145
- });
146
- }
188
+ return __awaiter(this, void 0, void 0, function () {
189
+ var packageJSONs, results, _i, packageJSONs_1, packageJSON, codegenConfigs, _a, codegenConfigs_1, codegenConfig;
190
+ return __generator(this, function (_b) {
191
+ switch (_b.label) {
192
+ case 0:
193
+ packageJSONs = [
194
+ core_1.PackageJSON.fromProjectRootPath(fs, projectRootPath, projectRootPath),
195
+ ];
196
+ return [4 /*yield*/, new core_1.ProjectDependenciesManager(fs, projectRootPath).forEachAsync(function (dependency) {
197
+ packageJSONs.push(dependency.readPackageJSON());
198
+ })];
199
+ case 1:
200
+ _b.sent();
201
+ results = [];
202
+ for (_i = 0, packageJSONs_1 = packageJSONs; _i < packageJSONs_1.length; _i++) {
203
+ packageJSON = packageJSONs_1[_i];
204
+ codegenConfigs = packageJSON.getCodegenConfigs();
205
+ for (_a = 0, codegenConfigs_1 = codegenConfigs; _a < codegenConfigs_1.length; _a++) {
206
+ codegenConfig = codegenConfigs_1[_a];
207
+ if (codegenConfig &&
208
+ onShouldAcceptCodegenConfig(codegenConfig.getVersion(), packageJSON.name)) {
209
+ results.push({
210
+ libraryCppName: deriveCppDirectoryNameFromNpmPackageName(packageJSON.name),
211
+ uberSchema: codegen_1.UberSchema.fromCodegenConfig(codegenConfig),
212
+ });
213
+ }
214
+ }
215
+ }
216
+ return [2 /*return*/, results];
147
217
  }
148
- }
149
- return results;
218
+ });
150
219
  });
151
220
  }
152
221
  function throwErrorIfUnsupportedCodegenVersion(codegenVersion, maxSupportedCodegenVersion, packageName) {
153
222
  if (codegenVersion > maxSupportedCodegenVersion) {
154
223
  throw new codegen_1.CodegenError({
155
- whatHappened: `Package "${packageName}" requires codegenVersion: ${codegenVersion}, which is not supported (maxSupportedCodegenVersion=${maxSupportedCodegenVersion}).`,
224
+ whatHappened: "Package \"".concat(packageName, "\" requires codegenVersion: ").concat(codegenVersion, ", which is not supported (maxSupportedCodegenVersion=").concat(maxSupportedCodegenVersion, ")."),
156
225
  whatCanUserDo: [
157
- `Try downgrading "${packageName}".`,
226
+ "Try downgrading \"".concat(packageName, "\"."),
158
227
  'Update the "@react-native-oh/react-native-harmony-cli" package.',
159
228
  ],
160
229
  });
@@ -165,10 +234,10 @@ function saveCodegenResult(fs, fileContentByPath, cppOutputPath, etsOutputPath,
165
234
  prepareDirectory(etsOutputPath, enableSafetyCheck);
166
235
  prepareDirectory(etsOutputPath.copyWithNewSegment('components'), enableSafetyCheck);
167
236
  prepareDirectory(etsOutputPath.copyWithNewSegment('turboModules'), enableSafetyCheck);
168
- fileContentByPath.forEach((_fileContent, path) => {
237
+ fileContentByPath.forEach(function (_fileContent, path) {
169
238
  prepareDirectory(path.getDirectoryPath(), enableSafetyCheck);
170
239
  });
171
- fileContentByPath.forEach((fileContent, path) => {
240
+ fileContentByPath.forEach(function (fileContent, path) {
172
241
  fs.writeTextSync(path, fileContent);
173
242
  });
174
243
  }
@@ -176,24 +245,26 @@ function prepareDirectory(path, enableSafetyCheck) {
176
245
  (0, core_1.maybeMakeDirectories)(path);
177
246
  if (enableSafetyCheck && !path.getValue().startsWith(process.cwd())) {
178
247
  throw new core_1.DescriptiveError({
179
- whatHappened: `Tried to remove files in ${path.getValue()}\nand that path is outside current working directory`,
248
+ whatHappened: "Tried to remove files in ".concat(path.getValue(), "\nand that path is outside current working directory"),
180
249
  whatCanUserDo: ['Run codegen from different location'],
181
250
  });
182
251
  }
183
252
  (0, core_1.maybeRemoveFilesInDirectory)(path);
184
253
  }
185
254
  function logCodegenResult(logger, fileContentByPath, projectRootPath) {
186
- const sortedRelativePathStrings = Array.from(fileContentByPath.keys()).map((path) => node_path_1.default.relative(projectRootPath.getValue(), path.getValue()));
255
+ var sortedRelativePathStrings = Array.from(fileContentByPath.keys()).map(function (path) { return node_path_1.default.relative(projectRootPath.getValue(), path.getValue()); });
187
256
  sortedRelativePathStrings.sort();
188
- sortedRelativePathStrings.forEach((pathStr) => {
189
- logger.debug((styles) => styles.gray(`• ${pathStr}`));
257
+ sortedRelativePathStrings.forEach(function (pathStr) {
258
+ logger.debug(function (styles) { return styles.gray("\u2022 ".concat(pathStr)); });
259
+ });
260
+ logger.debug(function () { return ''; });
261
+ logger.info(function (styles) {
262
+ return "Generated ".concat(styles.green(styles.bold(fileContentByPath.size)), " file(s)");
190
263
  });
191
- logger.debug(() => '');
192
- logger.info((styles) => `Generated ${styles.green(styles.bold(fileContentByPath.size))} file(s)`);
193
- logger.debug(() => '');
264
+ logger.debug(function () { return ''; });
194
265
  }
195
266
  function deriveCppDirectoryNameFromNpmPackageName(npmPackageName) {
196
- let result = npmPackageName;
267
+ var result = npmPackageName;
197
268
  if (npmPackageName.includes('/')) {
198
269
  result.replace('@', '');
199
270
  result = npmPackageName.replace('/', '__');