@react-native-oh/react-native-harmony-cli 0.0.36 → 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 (137) 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 +42 -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 -109
  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 -108
  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 +520 -352
  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 +395 -0
  59. package/dist/simulator/index.js +23 -0
  60. package/jest.config.js +12 -12
  61. package/package.json +78 -70
  62. package/react-native.config.js +17 -17
  63. package/tsconfig.build.json +6 -6
  64. package/tsconfig.json +2 -2
  65. package/.prettierrc +0 -6
  66. package/src/assetResolver.ts +0 -134
  67. package/src/autolinking/Autolinking.test.ts +0 -483
  68. package/src/autolinking/Autolinking.ts +0 -382
  69. package/src/autolinking/index.ts +0 -8
  70. package/src/codegen/core/CodeGenerator.ts +0 -16
  71. package/src/codegen/core/CodegenError.ts +0 -10
  72. package/src/codegen/core/EventUtils.ts +0 -23
  73. package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -82
  74. package/src/codegen/core/TypeAnnotationToTS.ts +0 -195
  75. package/src/codegen/core/UberSchema.ts +0 -152
  76. package/src/codegen/core/index.ts +0 -12
  77. package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +0 -120
  78. package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +0 -128
  79. package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +0 -122
  80. package/src/codegen/generators/CppComponentCodeGenerator.ts +0 -95
  81. package/src/codegen/generators/LibGlueCodeGenerator.ts +0 -98
  82. package/src/codegen/generators/NativeModuleCodeGenerator.ts +0 -124
  83. package/src/codegen/generators/SharedComponentCodeGenerator.ts +0 -57
  84. package/src/codegen/generators/UberGeneratorV1.ts +0 -75
  85. package/src/codegen/generators/UberGeneratorV2.ts +0 -114
  86. package/src/codegen/generators/index.ts +0 -15
  87. package/src/codegen/index.ts +0 -9
  88. package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +0 -128
  89. package/src/codegen/templates/BasePackageHTemplate.ts +0 -147
  90. package/src/codegen/templates/ComponentDescriptorHTemplate.ts +0 -63
  91. package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +0 -121
  92. package/src/codegen/templates/ComponentUtilsTSTemplate.ts +0 -222
  93. package/src/codegen/templates/IndexTSTemplate.ts +0 -62
  94. package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +0 -138
  95. package/src/codegen/templates/TurboModuleCppTemplate.ts +0 -61
  96. package/src/codegen/templates/TurboModuleHTemplate.ts +0 -42
  97. package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +0 -101
  98. package/src/codegen/templates/index.ts +0 -16
  99. package/src/commands/bundle-harmony.ts +0 -134
  100. package/src/commands/codegen-harmony.ts +0 -297
  101. package/src/commands/codegen-lib-harmony.ts +0 -389
  102. package/src/commands/create-metro-host-constants.ts +0 -55
  103. package/src/commands/index.ts +0 -16
  104. package/src/commands/init.ts +0 -755
  105. package/src/commands/link-harmony.ts +0 -102
  106. package/src/commands/pack-harmony.ts +0 -128
  107. package/src/commands/run-harmony.ts +0 -478
  108. package/src/commands/types.ts +0 -21
  109. package/src/commands/unpack-harmony.ts +0 -238
  110. package/src/commands/verify-package-harmony.ts +0 -113
  111. package/src/core/AbsolutePath.ts +0 -66
  112. package/src/core/CodegenConfig.ts +0 -67
  113. package/src/core/DescriptiveError.ts +0 -68
  114. package/src/core/FileSystem.ts +0 -57
  115. package/src/core/OHPackageJSON5.ts +0 -30
  116. package/src/core/PackageJSON.ts +0 -104
  117. package/src/core/ProjectDependenciesManager.ts +0 -103
  118. package/src/core/ValidationError.ts +0 -8
  119. package/src/core/ValueObject.ts +0 -9
  120. package/src/core/fs.ts +0 -38
  121. package/src/core/index.ts +0 -17
  122. package/src/index.ts +0 -33
  123. package/src/io/CliExecutor.ts +0 -69
  124. package/src/io/Logger.ts +0 -112
  125. package/src/io/RealFS.ts +0 -62
  126. package/src/io/TarGz.ts +0 -33
  127. package/src/io/__fixtures__.ts +0 -139
  128. package/src/io/fsUtils.ts +0 -44
  129. package/src/io/index.ts +0 -11
  130. package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +0 -35
  131. package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +0 -31
  132. package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +0 -25
  133. package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +0 -54
  134. package/src/package-verifier/checks/index.ts +0 -11
  135. package/src/package-verifier/index.ts +0 -9
  136. package/src/package-verifier/types.ts +0 -19
  137. package/src/package-verifier/verify-package.ts +0 -123
@@ -14,18 +14,51 @@ 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.commandCodegenLibHarmony = void 0;
22
- const core_1 = require("../core");
23
- const io_1 = require("../io");
24
- const node_fs_1 = __importDefault(require("node:fs"));
25
- const codegen_1 = require("../codegen");
26
- const case_1 = __importDefault(require("case"));
27
- const LibGlueCodeGenerator_1 = require("../codegen/generators/LibGlueCodeGenerator");
28
- const COMMAND_NAME = 'codegen-lib-harmony';
55
+ var core_1 = require("../core");
56
+ var io_1 = require("../io");
57
+ var node_fs_1 = require("node:fs");
58
+ var codegen_1 = require("../codegen");
59
+ var case_1 = require("case");
60
+ var LibGlueCodeGenerator_1 = require("../codegen/generators/LibGlueCodeGenerator");
61
+ var COMMAND_NAME = 'codegen-lib-harmony';
29
62
  exports.commandCodegenLibHarmony = {
30
63
  name: COMMAND_NAME,
31
64
  description: 'Generates boilerplate, types, and utilities from Turbo Module and Fabric Component specifications. Designed for library developers who want to include generated code in their libraries.',
@@ -37,17 +70,17 @@ exports.commandCodegenLibHarmony = {
37
70
  {
38
71
  name: '--turbo-modules-spec-paths [path]',
39
72
  description: 'Path or paths to Turbo Module spec files. Each path can point to a spec file or a directory containing spec files.',
40
- parse: (val) => val.split(' '),
73
+ parse: function (val) { return val.split(' '); },
41
74
  },
42
75
  {
43
76
  name: '--arkts-components-spec-paths [path]',
44
77
  description: 'Path or paths to component spec files used to generate code for components to be implemented on the ArkTS side. Each path can point to a spec file or a directory containing spec files.',
45
- parse: (val) => val.split(' '),
78
+ parse: function (val) { return val.split(' '); },
46
79
  },
47
80
  {
48
81
  name: '--cpp-components-spec-paths [path]',
49
82
  description: 'Path or paths to component spec files used to generate code for components to be implemented on the C++ side. Each path can point to a spec file or a directory containing spec files.',
50
- parse: (val) => val.split(' '),
83
+ parse: function (val) { return val.split(' '); },
51
84
  },
52
85
  {
53
86
  name: '--cpp-output-path <path>',
@@ -62,43 +95,44 @@ exports.commandCodegenLibHarmony = {
62
95
  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.',
63
96
  },
64
97
  ],
65
- func: (_argv, _config, rawArgs) => __awaiter(void 0, void 0, void 0, function* () {
66
- const logger = new io_1.Logger();
67
- try {
68
- const { args, uberSchemaByType } = validateArgsAndRetrieveUberSchemaByType(rawArgs);
69
- const fileContentByPath = generateCodeInMemory({
70
- args,
71
- uberSchemaByType,
72
- });
73
- saveAndLogCodegenResult(args, logger, fileContentByPath);
74
- }
75
- catch (err) {
76
- if (err instanceof core_1.DescriptiveError && !err.isUnexpected()) {
77
- logger.descriptiveError(err);
78
- return;
98
+ func: function (_argv, _config, rawArgs) { return __awaiter(void 0, void 0, void 0, function () {
99
+ var logger, _a, args, uberSchemaByType, fileContentByPath;
100
+ return __generator(this, function (_b) {
101
+ logger = new io_1.Logger();
102
+ try {
103
+ _a = validateArgsAndRetrieveUberSchemaByType(rawArgs), args = _a.args, uberSchemaByType = _a.uberSchemaByType;
104
+ fileContentByPath = generateCodeInMemory({
105
+ args: args,
106
+ uberSchemaByType: uberSchemaByType,
107
+ });
108
+ saveAndLogCodegenResult(args, logger, fileContentByPath);
79
109
  }
80
- throw err;
81
- }
82
- }),
110
+ catch (err) {
111
+ if (err instanceof core_1.DescriptiveError && !err.isUnexpected()) {
112
+ logger.descriptiveError(err);
113
+ return [2 /*return*/];
114
+ }
115
+ throw err;
116
+ }
117
+ return [2 /*return*/];
118
+ });
119
+ }); },
83
120
  };
84
121
  function validateArgsAndRetrieveUberSchemaByType(rawArgs) {
85
- const args = validateRawArgs(rawArgs);
86
- const arkTSComponentSpecPaths = specPathsToSpecFilePaths(args.arkTSComponentsSpecPaths);
87
- const turboModulesUberSchema = codegen_1.UberSchema.fromSpecFilePaths(specPathsToSpecFilePaths(args.tmSpecPaths));
88
- const arkTSComponentsUberSchema = codegen_1.UberSchema.fromSpecFilePaths(arkTSComponentSpecPaths);
89
- const cppComponentSpecPaths = specPathsToSpecFilePaths(args.cppComponentsSpecPaths);
90
- const cppComponentsUberSchema = codegen_1.UberSchema.fromSpecFilePaths(cppComponentSpecPaths);
91
- const componentsUberSchema = codegen_1.UberSchema.fromSpecFilePaths([
92
- ...arkTSComponentSpecPaths,
93
- ...cppComponentSpecPaths,
94
- ]);
122
+ var args = validateRawArgs(rawArgs);
123
+ var arkTSComponentSpecPaths = specPathsToSpecFilePaths(args.arkTSComponentsSpecPaths);
124
+ var turboModulesUberSchema = codegen_1.UberSchema.fromSpecFilePaths(specPathsToSpecFilePaths(args.tmSpecPaths));
125
+ var arkTSComponentsUberSchema = codegen_1.UberSchema.fromSpecFilePaths(arkTSComponentSpecPaths);
126
+ var cppComponentSpecPaths = specPathsToSpecFilePaths(args.cppComponentsSpecPaths);
127
+ var cppComponentsUberSchema = codegen_1.UberSchema.fromSpecFilePaths(cppComponentSpecPaths);
128
+ var componentsUberSchema = codegen_1.UberSchema.fromSpecFilePaths(__spreadArray(__spreadArray([], arkTSComponentSpecPaths, true), cppComponentSpecPaths, true));
95
129
  return {
96
- args,
130
+ args: args,
97
131
  uberSchemaByType: {
98
- turboModulesUberSchema,
99
- arkTSComponentsUberSchema,
100
- cppComponentsUberSchema,
101
- componentsUberSchema,
132
+ turboModulesUberSchema: turboModulesUberSchema,
133
+ arkTSComponentsUberSchema: arkTSComponentsUberSchema,
134
+ cppComponentsUberSchema: cppComponentsUberSchema,
135
+ componentsUberSchema: componentsUberSchema,
102
136
  },
103
137
  };
104
138
  }
@@ -124,28 +158,28 @@ function validateRawArgs(rawArgs) {
124
158
  }
125
159
  return {
126
160
  npmPackageName: rawArgs.npmPackageName,
127
- tmSpecPaths: ((_a = rawArgs.turboModulesSpecPaths) !== null && _a !== void 0 ? _a : []).map((path) => new core_1.AbsolutePath(path)),
128
- arkTSComponentsSpecPaths: ((_b = rawArgs.arktsComponentsSpecPaths) !== null && _b !== void 0 ? _b : []).map((path) => new core_1.AbsolutePath(path)),
129
- cppComponentsSpecPaths: ((_c = rawArgs.cppComponentsSpecPaths) !== null && _c !== void 0 ? _c : []).map((path) => new core_1.AbsolutePath(path)),
161
+ tmSpecPaths: ((_a = rawArgs.turboModulesSpecPaths) !== null && _a !== void 0 ? _a : []).map(function (path) { return new core_1.AbsolutePath(path); }),
162
+ arkTSComponentsSpecPaths: ((_b = rawArgs.arktsComponentsSpecPaths) !== null && _b !== void 0 ? _b : []).map(function (path) { return new core_1.AbsolutePath(path); }),
163
+ cppComponentsSpecPaths: ((_c = rawArgs.cppComponentsSpecPaths) !== null && _c !== void 0 ? _c : []).map(function (path) { return new core_1.AbsolutePath(path); }),
130
164
  etsOutputPath: new core_1.AbsolutePath(rawArgs.etsOutputPath),
131
165
  cppOutputPath: new core_1.AbsolutePath(rawArgs.cppOutputPath),
132
166
  safetyCheck: !!rawArgs.safetyCheck,
133
167
  };
134
168
  }
135
169
  function specPathsToSpecFilePaths(specPaths) {
136
- const SUPPORTED_SPEC_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx'];
137
- return specPaths.flatMap((specPath) => {
170
+ var SUPPORTED_SPEC_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx'];
171
+ return specPaths.flatMap(function (specPath) {
138
172
  if (!node_fs_1.default.existsSync(specPath.getValue())) {
139
173
  throw new core_1.DescriptiveError({
140
- whatHappened: `No such file or directory: ${specPath.getValue()}`,
141
- whatCanUserDo: [`Are you sure provided specPath exists?`],
174
+ whatHappened: "No such file or directory: ".concat(specPath.getValue()),
175
+ whatCanUserDo: ["Are you sure provided specPath exists?"],
142
176
  });
143
177
  }
144
178
  if (node_fs_1.default.lstatSync(specPath.getValue()).isDirectory()) {
145
179
  return (0, io_1.findFilePathsWithExtensions)(specPath, SUPPORTED_SPEC_EXTENSIONS);
146
180
  }
147
181
  else {
148
- const ext = specPath.getExtension();
182
+ var ext = specPath.getExtension();
149
183
  if (ext && SUPPORTED_SPEC_EXTENSIONS.includes(ext)) {
150
184
  return [specPath];
151
185
  }
@@ -153,30 +187,31 @@ function specPathsToSpecFilePaths(specPaths) {
153
187
  }
154
188
  });
155
189
  }
156
- function generateCodeInMemory({ args, uberSchemaByType: { arkTSComponentsUberSchema, componentsUberSchema, cppComponentsUberSchema, turboModulesUberSchema, }, }) {
157
- const CODEGEN_NOTICE_LINES = [
158
- `This code was generated by "react-native ${COMMAND_NAME}"`,
190
+ function generateCodeInMemory(_a) {
191
+ var args = _a.args, _b = _a.uberSchemaByType, arkTSComponentsUberSchema = _b.arkTSComponentsUberSchema, componentsUberSchema = _b.componentsUberSchema, cppComponentsUberSchema = _b.cppComponentsUberSchema, turboModulesUberSchema = _b.turboModulesUberSchema;
192
+ var CODEGEN_NOTICE_LINES = [
193
+ "This code was generated by \"react-native ".concat(COMMAND_NAME, "\""),
159
194
  ];
160
- const fileContentByPath = new Map();
161
- const appendToFileContentByPath = (fileContent, path) => {
195
+ var fileContentByPath = new Map();
196
+ var appendToFileContentByPath = function (fileContent, path) {
162
197
  fileContentByPath.set(path, fileContent);
163
198
  };
164
- const turboModuleGlueCodeData = turboModulesUberSchema
199
+ var turboModuleGlueCodeData = turboModulesUberSchema
165
200
  .findAllSpecSchemasByType('NativeModule')
166
- .map((specSchema) => {
167
- const nativeModuleCodeGenerator = new codegen_1.NativeModuleCodeGenerator(args.cppOutputPath.copyWithNewSegment('RNOH', 'generated', 'turbo_modules'), args.etsOutputPath.copyWithNewSegment('turboModules'), CODEGEN_NOTICE_LINES, '@rnoh/react-native-openharmony/ts');
201
+ .map(function (specSchema) {
202
+ var nativeModuleCodeGenerator = new codegen_1.NativeModuleCodeGenerator(args.cppOutputPath.copyWithNewSegment('RNOH', 'generated', 'turbo_modules'), args.etsOutputPath.copyWithNewSegment('turboModules'), CODEGEN_NOTICE_LINES, '@rnoh/react-native-openharmony/ts');
168
203
  nativeModuleCodeGenerator
169
204
  .generate(specSchema)
170
205
  .forEach(appendToFileContentByPath);
171
206
  return nativeModuleCodeGenerator.getGlueCodeData();
172
207
  })
173
208
  .flat();
174
- const arkTSComponentCodeGeneratorCAPI = new codegen_1.ArkTSComponentCodeGeneratorCAPI(args.cppOutputPath.copyWithNewSegment('RNOH', 'generated', 'components'), args.etsOutputPath.copyWithNewSegment('components'), CODEGEN_NOTICE_LINES, '@rnoh/react-native-openharmony/ts');
209
+ var arkTSComponentCodeGeneratorCAPI = new codegen_1.ArkTSComponentCodeGeneratorCAPI(args.cppOutputPath.copyWithNewSegment('RNOH', 'generated', 'components'), args.etsOutputPath.copyWithNewSegment('components'), CODEGEN_NOTICE_LINES, '@rnoh/react-native-openharmony/ts');
175
210
  arkTSComponentCodeGeneratorCAPI
176
211
  .generate(arkTSComponentsUberSchema)
177
212
  .forEach(appendToFileContentByPath);
178
- const libraryCppName = deriveLibraryCppNameFromNpmPackageName(args.npmPackageName);
179
- const cppComponentCodeGenerator = new codegen_1.CppComponentCodeGenerator((filename) => {
213
+ var libraryCppName = deriveLibraryCppNameFromNpmPackageName(args.npmPackageName);
214
+ var cppComponentCodeGenerator = new codegen_1.CppComponentCodeGenerator(function (filename) {
180
215
  return args.cppOutputPath.copyWithNewSegment('RNOH', 'generated', 'components', filename);
181
216
  }, CODEGEN_NOTICE_LINES);
182
217
  cppComponentCodeGenerator
@@ -185,7 +220,7 @@ function generateCodeInMemory({ args, uberSchemaByType: { arkTSComponentsUberSch
185
220
  uberSchema: cppComponentsUberSchema,
186
221
  })
187
222
  .forEach(appendToFileContentByPath);
188
- new codegen_1.SharedComponentCodeGenerator((filename) => {
223
+ new codegen_1.SharedComponentCodeGenerator(function (filename) {
189
224
  return args.cppOutputPath.copyWithNewSegment('react', 'renderer', 'components', libraryCppName, filename);
190
225
  })
191
226
  .generate({
@@ -195,18 +230,21 @@ function generateCodeInMemory({ args, uberSchemaByType: { arkTSComponentsUberSch
195
230
  .forEach(appendToFileContentByPath);
196
231
  new LibGlueCodeGenerator_1.LibGlueCodeGenerator(args.cppOutputPath, args.etsOutputPath, CODEGEN_NOTICE_LINES)
197
232
  .generate({
198
- libraryCppName,
233
+ libraryCppName: libraryCppName,
199
234
  arkTSComponents: arkTSComponentCodeGeneratorCAPI.getLibGlueCodeData(),
200
235
  cppComponents: cppComponentCodeGenerator
201
236
  .getGlueCodeData()
202
- .map(({ name }) => ({ componentName: name })),
237
+ .map(function (_a) {
238
+ var name = _a.name;
239
+ return ({ componentName: name });
240
+ }),
203
241
  turboModules: turboModuleGlueCodeData,
204
242
  })
205
243
  .forEach(appendToFileContentByPath);
206
244
  return fileContentByPath;
207
245
  }
208
246
  function deriveLibraryCppNameFromNpmPackageName(npmPackageName) {
209
- let result = npmPackageName;
247
+ var result = npmPackageName;
210
248
  if (npmPackageName.includes('/')) {
211
249
  result.replace('@', '');
212
250
  result = npmPackageName.replace('/', '__');
@@ -223,10 +261,10 @@ function saveCodegenResultToFileSystem(fileContentByPath, cppOutputPath, etsOutp
223
261
  prepareDirectory(etsOutputPath, enableSafetyCheck);
224
262
  prepareDirectory(etsOutputPath.copyWithNewSegment('components'), enableSafetyCheck);
225
263
  prepareDirectory(etsOutputPath.copyWithNewSegment('turboModules'), enableSafetyCheck);
226
- fileContentByPath.forEach((_fileContent, path) => {
264
+ fileContentByPath.forEach(function (_fileContent, path) {
227
265
  prepareDirectory(path.getDirectoryPath(), enableSafetyCheck);
228
266
  });
229
- fileContentByPath.forEach((fileContent, path) => {
267
+ fileContentByPath.forEach(function (fileContent, path) {
230
268
  node_fs_1.default.writeFileSync(path.getValue(), fileContent);
231
269
  });
232
270
  }
@@ -234,7 +272,7 @@ function prepareDirectory(path, enableSafetyCheck) {
234
272
  (0, core_1.maybeMakeDirectories)(path);
235
273
  if (enableSafetyCheck && !path.getValue().startsWith(process.cwd())) {
236
274
  throw new core_1.DescriptiveError({
237
- whatHappened: `Tried to remove files in ${path.getValue()}\nand that path is outside current working directory`,
275
+ whatHappened: "Tried to remove files in ".concat(path.getValue(), "\nand that path is outside current working directory"),
238
276
  whatCanUserDo: [
239
277
  'Run this command with --no-safety-check flag',
240
278
  'Run codegen from different location',
@@ -244,12 +282,14 @@ function prepareDirectory(path, enableSafetyCheck) {
244
282
  (0, core_1.maybeRemoveFilesInDirectory)(path);
245
283
  }
246
284
  function logCodegenResult(logger, fileContentByPath, rootPath) {
247
- const sortedRelativePathStrings = Array.from(fileContentByPath.keys()).map((path) => path.relativeTo(rootPath).getValue());
285
+ var sortedRelativePathStrings = Array.from(fileContentByPath.keys()).map(function (path) { return path.relativeTo(rootPath).getValue(); });
248
286
  sortedRelativePathStrings.sort();
249
- sortedRelativePathStrings.forEach((pathStr) => {
250
- logger.info((styles) => styles.gray(`• ${pathStr}`));
287
+ sortedRelativePathStrings.forEach(function (pathStr) {
288
+ logger.info(function (styles) { return styles.gray("\u2022 ".concat(pathStr)); });
289
+ });
290
+ logger.info(function () { return ''; });
291
+ logger.info(function (styles) {
292
+ return "Generated ".concat(styles.green(styles.bold(fileContentByPath.size)), " file(s)");
251
293
  });
252
- logger.info(() => '');
253
- logger.info((styles) => `Generated ${styles.green(styles.bold(fileContentByPath.size))} file(s)`);
254
- logger.info(() => '');
294
+ logger.info(function () { return ''; });
255
295
  }
@@ -14,14 +14,38 @@ 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
+ }
19
43
  };
20
44
  Object.defineProperty(exports, "__esModule", { value: true });
21
45
  exports.commandCreateMetroConstantsHarmony = void 0;
22
- const node_os_1 = __importDefault(require("node:os"));
23
- const node_fs_1 = __importDefault(require("node:fs"));
24
- const node_path_1 = __importDefault(require("node:path"));
46
+ var node_os_1 = require("node:os");
47
+ var node_fs_1 = require("node:fs");
48
+ var node_path_1 = require("node:path");
25
49
  exports.commandCreateMetroConstantsHarmony = {
26
50
  name: 'create-metro-host-constants-harmony',
27
51
  description: 'Creates a Typescript file that exports constant with IP of the host machine. That IP is later used to connect to the Metro server from a physical device.',
@@ -32,16 +56,21 @@ exports.commandCreateMetroConstantsHarmony = {
32
56
  default: './harmony/entry/src/main/ets/codegen/MetroHostConstants.ts',
33
57
  },
34
58
  ],
35
- func: (argv, config, args) => __awaiter(void 0, void 0, void 0, function* () {
36
- createMetroHostConstants(node_path_1.default.resolve(args.output));
37
- }),
59
+ func: function (argv, config, args) { return __awaiter(void 0, void 0, void 0, function () {
60
+ return __generator(this, function (_a) {
61
+ createMetroHostConstants(node_path_1.default.resolve(args.output));
62
+ return [2 /*return*/];
63
+ });
64
+ }); },
38
65
  };
39
66
  function createMetroHostConstants(outputPath) {
40
- const networkInterfacesByName = node_os_1.default.networkInterfaces();
41
- const getIP = () => {
67
+ var networkInterfacesByName = node_os_1.default.networkInterfaces();
68
+ var getIP = function () {
42
69
  var _a;
43
- for (let name of Object.keys(networkInterfacesByName)) {
44
- for (let net of (_a = networkInterfacesByName[name]) !== null && _a !== void 0 ? _a : []) {
70
+ for (var _i = 0, _b = Object.keys(networkInterfacesByName); _i < _b.length; _i++) {
71
+ var name_1 = _b[_i];
72
+ for (var _c = 0, _d = (_a = networkInterfacesByName[name_1]) !== null && _a !== void 0 ? _a : []; _c < _d.length; _c++) {
73
+ var net = _d[_c];
45
74
  // skip over non-ipv4 and internal (i.e. 127.0.0.1) addresses
46
75
  if (net.family === 'IPv4' && !net.internal) {
47
76
  return net.address;
@@ -50,18 +79,18 @@ function createMetroHostConstants(outputPath) {
50
79
  }
51
80
  return;
52
81
  };
53
- const ip = getIP();
54
- const tsCode = [
82
+ var ip = getIP();
83
+ var tsCode = [
55
84
  '// This file is autogenerated. Do not modify it manually.',
56
85
  '',
57
- `export const METRO_SERVER_IP = '${ip}';\n`,
86
+ "export const METRO_SERVER_IP = '".concat(ip, "';\n"),
58
87
  ];
59
- node_fs_1.default.writeFile(outputPath, tsCode.join('\n'), (err) => {
88
+ node_fs_1.default.writeFile(outputPath, tsCode.join('\n'), function (err) {
60
89
  if (err) {
61
- console.error(`Error writing to ${outputPath}:`, err);
90
+ console.error("Error writing to ".concat(outputPath, ":"), err);
62
91
  }
63
92
  else {
64
- console.log(`Created file at ${outputPath}`);
93
+ console.log("Created file at ".concat(outputPath));
65
94
  }
66
95
  });
67
96
  }