@react-native-oh/react-native-harmony-cli 0.0.40 → 0.0.41

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 (64) hide show
  1. package/README.md +11 -11
  2. package/dist/assetResolver.js +43 -74
  3. package/dist/autolinking/Autolinking.js +178 -179
  4. package/dist/codegen/core/CodegenError.js +3 -23
  5. package/dist/codegen/core/EventUtils.js +3 -3
  6. package/dist/codegen/core/TypeAnnotationToTS.js +24 -28
  7. package/dist/codegen/core/UberSchema.js +57 -96
  8. package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +28 -41
  9. package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +27 -34
  10. package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +25 -33
  11. package/dist/codegen/generators/CppComponentCodeGenerator.js +23 -28
  12. package/dist/codegen/generators/LibGlueCodeGenerator.js +26 -29
  13. package/dist/codegen/generators/NativeModuleCodeGenerator.js +25 -30
  14. package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
  15. package/dist/codegen/generators/UberGeneratorV1.js +24 -23
  16. package/dist/codegen/generators/UberGeneratorV2.js +34 -35
  17. package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +50 -24
  18. package/dist/codegen/templates/BasePackageHTemplate.js +120 -21
  19. package/dist/codegen/templates/ComponentDescriptorHTemplate.js +53 -8
  20. package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +75 -27
  21. package/dist/codegen/templates/ComponentUtilsTSTemplate.js +162 -29
  22. package/dist/codegen/templates/IndexTSTemplate.js +37 -17
  23. package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +119 -24
  24. package/dist/codegen/templates/TurboModuleCppTemplate.js +38 -15
  25. package/dist/codegen/templates/TurboModuleHTemplate.js +32 -11
  26. package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +52 -19
  27. package/dist/commands/bundle-harmony.js +53 -138
  28. package/dist/commands/codegen-harmony.js +105 -165
  29. package/dist/commands/codegen-lib-harmony.js +76 -116
  30. package/dist/commands/create-metro-host-constants.js +18 -47
  31. package/dist/commands/init.js +537 -961
  32. package/dist/commands/link-harmony.js +33 -71
  33. package/dist/commands/pack-harmony.js +47 -108
  34. package/dist/commands/run-harmony.js +372 -518
  35. package/dist/commands/unpack-harmony.js +105 -198
  36. package/dist/commands/verify-package-harmony.js +54 -108
  37. package/dist/core/AbsolutePath.js +31 -47
  38. package/dist/core/CodegenConfig.js +24 -22
  39. package/dist/core/DescriptiveError.js +18 -37
  40. package/dist/core/FileSystem.js +14 -18
  41. package/dist/core/OHPackageJSON5.js +17 -23
  42. package/dist/core/PackageJSON.js +26 -42
  43. package/dist/core/ProjectDependenciesManager.js +40 -92
  44. package/dist/core/ValidationError.js +2 -22
  45. package/dist/core/fs.js +9 -6
  46. package/dist/index.js +1 -1
  47. package/dist/io/CliExecutor.js +46 -98
  48. package/dist/io/Logger.js +40 -46
  49. package/dist/io/RealFS.js +35 -88
  50. package/dist/io/TarGz.js +11 -8
  51. package/dist/io/__fixtures__.js +79 -141
  52. package/dist/io/fsUtils.js +13 -12
  53. package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +19 -47
  54. package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +13 -41
  55. package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +8 -38
  56. package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +22 -54
  57. package/dist/package-verifier/verify-package.js +55 -132
  58. package/dist/simulator/LaunchSimulator.js +224 -301
  59. package/harmony/rnoh-hvigor-plugin-0.3.0.tgz +0 -0
  60. package/jest.config.js +12 -12
  61. package/package.json +78 -78
  62. package/react-native.config.js +17 -17
  63. package/tsconfig.build.json +6 -6
  64. package/tsconfig.json +2 -2
@@ -14,53 +14,26 @@ 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 __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
- }
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
43
19
  };
44
20
  Object.defineProperty(exports, "__esModule", { value: true });
45
21
  exports.UberSchema = void 0;
46
- var core_1 = require("../../core");
22
+ const core_1 = require("../../core");
47
23
  // @ts-expect-error
48
- var combine_js_to_schema_js_1 = require("@react-native/codegen/lib/cli/combine/combine-js-to-schema.js");
49
- var CodegenError_1 = require("./CodegenError");
24
+ const combine_js_to_schema_js_1 = __importDefault(require("@react-native/codegen/lib/cli/combine/combine-js-to-schema.js"));
25
+ const CodegenError_1 = require("./CodegenError");
50
26
  function createRawUberSchemaFromSpecFilePaths(projectSourceFilePaths) {
51
- return (0, combine_js_to_schema_js_1.default)(projectSourceFilePaths.map(function (p) { return p.getValue(); }));
27
+ return (0, combine_js_to_schema_js_1.default)(projectSourceFilePaths.map((p) => p.getValue()));
52
28
  }
53
29
  /**
54
30
  * Contains component and turbo module (NativeModule) schemas. The "Uber" word is used here to highlight that SpecSchemas don't extend this class.
55
31
  */
56
- var UberSchema = /** @class */ (function () {
57
- function UberSchema(schemaValue) {
58
- this.schemaValue = schemaValue;
59
- }
60
- UberSchema.fromSpecFilePaths = function (specPaths) {
32
+ class UberSchema {
33
+ static fromSpecFilePaths(specPaths) {
61
34
  return new UberSchema(createRawUberSchemaFromSpecFilePaths(specPaths));
62
- };
63
- UberSchema.fromCodegenConfig = function (codegenConfig) {
35
+ }
36
+ static fromCodegenConfig(codegenConfig) {
64
37
  try {
65
38
  return new UberSchema(createRawUberSchemaFromSpecFilePaths(codegenConfig.getSpecFilePaths()));
66
39
  }
@@ -69,76 +42,64 @@ var UberSchema = /** @class */ (function () {
69
42
  throw new CodegenError_1.CodegenError({
70
43
  whatHappened: "Couldn't create the schema",
71
44
  whatCanUserDo: [
72
- "There's probably at least one spec file defined in your project or in a third-party package that breaks some code generation restrictions. Please check the message below. If it's ambiguous, debug the problem with divide and conquer strategy.\n\n".concat(err.message),
45
+ `There's probably at least one spec file defined in your project or in a third-party package that breaks some code generation restrictions. Please check the message below. If it's ambiguous, debug the problem with divide and conquer strategy.\n\n${err.message}`,
73
46
  ],
74
47
  });
75
48
  }
76
49
  throw err;
77
50
  }
78
- };
79
- UberSchema.fromProject = function (fs, projectRootPath, onShouldAcceptCodegenConfig) {
80
- return __awaiter(this, void 0, void 0, function () {
81
- var onShouldAcceptCodegenConfig_, packageJSON, acceptedCodegenConfigs, appCodegenConfigs, _i, appCodegenConfigs_1, codegenConfig;
82
- return __generator(this, function (_a) {
83
- switch (_a.label) {
84
- case 0:
85
- onShouldAcceptCodegenConfig_ = onShouldAcceptCodegenConfig !== null && onShouldAcceptCodegenConfig !== void 0 ? onShouldAcceptCodegenConfig : (function (x) { return true; });
86
- packageJSON = core_1.PackageJSON.fromProjectRootPath(fs, projectRootPath, projectRootPath);
87
- acceptedCodegenConfigs = [];
88
- appCodegenConfigs = packageJSON.getCodegenConfigs();
89
- for (_i = 0, appCodegenConfigs_1 = appCodegenConfigs; _i < appCodegenConfigs_1.length; _i++) {
90
- codegenConfig = appCodegenConfigs_1[_i];
91
- if (onShouldAcceptCodegenConfig_(codegenConfig.getVersion(), packageJSON.name)) {
92
- acceptedCodegenConfigs.push(codegenConfig);
93
- }
94
- }
95
- return [4 /*yield*/, new core_1.ProjectDependenciesManager(fs, projectRootPath).forEachAsync(function (dependency) {
96
- var codegenConfigs = dependency.getCodegenConfigs();
97
- for (var _i = 0, codegenConfigs_1 = codegenConfigs; _i < codegenConfigs_1.length; _i++) {
98
- var codegenConfig = codegenConfigs_1[_i];
99
- if (onShouldAcceptCodegenConfig_(codegenConfig.getVersion(), dependency.readPackageJSON().name)) {
100
- acceptedCodegenConfigs.push(codegenConfig);
101
- }
102
- }
103
- })];
104
- case 1:
105
- _a.sent();
106
- try {
107
- return [2 /*return*/, new UberSchema(createRawUberSchemaFromSpecFilePaths(acceptedCodegenConfigs.flatMap(function (codegenConfig) {
108
- return codegenConfig.getSpecFilePaths();
109
- })))];
110
- }
111
- catch (err) {
112
- if (err instanceof Error) {
113
- throw new CodegenError_1.CodegenError({
114
- whatHappened: "Couldn't create the schema",
115
- whatCanUserDo: [
116
- "There's probably at least one spec file defined in your project or in a third-party package that breaks some code generation restrictions. Please check the message below. If it's ambiguous, debug the problem with divide and conquer strategy.\n\n".concat(err.message),
117
- ],
118
- });
119
- }
120
- throw err;
121
- }
122
- return [2 /*return*/];
51
+ }
52
+ static fromProject(fs, projectRootPath, onShouldAcceptCodegenConfig) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ const onShouldAcceptCodegenConfig_ = onShouldAcceptCodegenConfig !== null && onShouldAcceptCodegenConfig !== void 0 ? onShouldAcceptCodegenConfig : ((x) => true);
55
+ const packageJSON = core_1.PackageJSON.fromProjectRootPath(fs, projectRootPath, projectRootPath);
56
+ const acceptedCodegenConfigs = [];
57
+ const appCodegenConfigs = packageJSON.getCodegenConfigs();
58
+ for (const codegenConfig of appCodegenConfigs) {
59
+ if (onShouldAcceptCodegenConfig_(codegenConfig.getVersion(), packageJSON.name)) {
60
+ acceptedCodegenConfigs.push(codegenConfig);
61
+ }
62
+ }
63
+ yield new core_1.ProjectDependenciesManager(fs, projectRootPath).forEachAsync((dependency) => {
64
+ const codegenConfigs = dependency.getCodegenConfigs();
65
+ for (const codegenConfig of codegenConfigs) {
66
+ if (onShouldAcceptCodegenConfig_(codegenConfig.getVersion(), dependency.readPackageJSON().name)) {
67
+ acceptedCodegenConfigs.push(codegenConfig);
68
+ }
123
69
  }
124
70
  });
71
+ try {
72
+ return new UberSchema(createRawUberSchemaFromSpecFilePaths(acceptedCodegenConfigs.flatMap((codegenConfig) => codegenConfig.getSpecFilePaths())));
73
+ }
74
+ catch (err) {
75
+ if (err instanceof Error) {
76
+ throw new CodegenError_1.CodegenError({
77
+ whatHappened: "Couldn't create the schema",
78
+ whatCanUserDo: [
79
+ `There's probably at least one spec file defined in your project or in a third-party package that breaks some code generation restrictions. Please check the message below. If it's ambiguous, debug the problem with divide and conquer strategy.\n\n${err.message}`,
80
+ ],
81
+ });
82
+ }
83
+ throw err;
84
+ }
125
85
  });
126
- };
127
- UberSchema.prototype.getValue = function () {
86
+ }
87
+ constructor(schemaValue) {
88
+ this.schemaValue = schemaValue;
89
+ }
90
+ getValue() {
128
91
  return this.schemaValue;
129
- };
130
- UberSchema.prototype.findAllSpecSchemasByType = function (schemaType) {
92
+ }
93
+ findAllSpecSchemasByType(schemaType) {
131
94
  return Object.values(this.schemaValue.modules)
132
- .filter(function (module) { return module.type === schemaType; })
133
- .map(function (module) { return module; });
134
- };
135
- UberSchema.prototype.getSpecSchemaByFilenameMap = function () {
136
- return Object.entries(this.schemaValue.modules).reduce(function (acc, _a) {
137
- var moduleName = _a[0], moduleSchema = _a[1];
95
+ .filter((module) => module.type === schemaType)
96
+ .map((module) => module);
97
+ }
98
+ getSpecSchemaByFilenameMap() {
99
+ return Object.entries(this.schemaValue.modules).reduce((acc, [moduleName, moduleSchema]) => {
138
100
  acc.set(moduleName, moduleSchema);
139
101
  return acc;
140
102
  }, new Map());
141
- };
142
- return UberSchema;
143
- }());
103
+ }
104
+ }
144
105
  exports.UberSchema = UberSchema;
@@ -5,66 +5,54 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
7
7
  */
8
- var __assign = (this && this.__assign) || function () {
9
- __assign = Object.assign || function(t) {
10
- for (var s, i = 1, n = arguments.length; i < n; i++) {
11
- s = arguments[i];
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
13
- t[p] = s[p];
14
- }
15
- return t;
16
- };
17
- return __assign.apply(this, arguments);
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
10
  };
19
11
  Object.defineProperty(exports, "__esModule", { value: true });
20
12
  exports.AppBuildTimeGlueCodeGenerator = void 0;
21
- var case_1 = require("case");
22
- var templates_1 = require("../templates");
23
- var BasePackageHTemplate_1 = require("../templates/BasePackageHTemplate");
13
+ const case_1 = __importDefault(require("case"));
14
+ const templates_1 = require("../templates");
15
+ const BasePackageHTemplate_1 = require("../templates/BasePackageHTemplate");
24
16
  /**
25
17
  * Generates code based on UberGenerators results. If UberGenerators produce "leaves" (concrete turbo module or component classes),
26
18
  * this class generates "branches" (barrel files like index.ts) and "trunks" (package file or files).
27
19
  */
28
- var AppBuildTimeGlueCodeGenerator = /** @class */ (function () {
29
- function AppBuildTimeGlueCodeGenerator(cppOutputPath, etsOutputPath, codegenNoticeLines) {
20
+ class AppBuildTimeGlueCodeGenerator {
21
+ constructor(cppOutputPath, etsOutputPath, codegenNoticeLines) {
30
22
  this.cppOutputPath = cppOutputPath;
31
23
  this.etsOutputPath = etsOutputPath;
32
24
  this.codegenNoticeLines = codegenNoticeLines;
33
25
  }
34
- AppBuildTimeGlueCodeGenerator.prototype.generate = function (_a) {
35
- var _this = this;
36
- var v1 = _a.v1, v2 = _a.v2;
37
- var fileContentByPath = new Map();
38
- var generatedPackageH_v1 = new templates_1.RNOHGeneratedPackageHTemplate();
39
- var components_indexTS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
40
- var turboModules_indexTS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
41
- var generated_indexETS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
26
+ generate({ v1, v2 }) {
27
+ const fileContentByPath = new Map();
28
+ const generatedPackageH_v1 = new templates_1.RNOHGeneratedPackageHTemplate();
29
+ const components_indexTS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
30
+ const turboModules_indexTS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
31
+ const generated_indexETS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
42
32
  generated_indexETS.addReexport({ from: './ts' });
43
- v1.components.forEach(function (_a) {
44
- var name = _a.name, eventNames = _a.eventNames;
45
- components_indexTS.addReexport({ from: "./".concat(name) });
33
+ v1.components.forEach(({ name, eventNames }) => {
34
+ components_indexTS.addReexport({ from: `./${name}` });
46
35
  generatedPackageH_v1.addComponent({
47
- name: name,
36
+ name,
48
37
  supportedEventNames: eventNames,
49
38
  isArkTSComponent: true,
50
39
  });
51
40
  });
52
- v1.turboModules.forEach(function (turboModule) {
53
- turboModules_indexTS.addReexport({ from: "./".concat(turboModule.name) });
41
+ v1.turboModules.forEach((turboModule) => {
42
+ turboModules_indexTS.addReexport({ from: `./${turboModule.name}` });
54
43
  generatedPackageH_v1.addTurboModule(turboModule);
55
44
  });
56
- v2.forEach(function (_a, libraryName) {
57
- var components = _a.components, turboModules = _a.turboModules;
58
- var basePackageClassName = "Base".concat(case_1.default.pascal(libraryName), "Package");
59
- var generatedPackageH_v2 = new BasePackageHTemplate_1.BasePackageHTemplate(basePackageClassName, _this.codegenNoticeLines);
60
- components.forEach(function (component) {
61
- generatedPackageH_v2.addComponent(__assign(__assign({}, component), { isArkTSComponent: false }));
45
+ v2.forEach(({ components, turboModules }, libraryName) => {
46
+ const basePackageClassName = `Base${case_1.default.pascal(libraryName)}Package`;
47
+ const generatedPackageH_v2 = new BasePackageHTemplate_1.BasePackageHTemplate(basePackageClassName, this.codegenNoticeLines);
48
+ components.forEach((component) => {
49
+ generatedPackageH_v2.addComponent(Object.assign(Object.assign({}, component), { isArkTSComponent: false }));
62
50
  });
63
- turboModules.forEach(function (turboModule) {
64
- turboModules_indexTS.addReexport({ from: "./".concat(turboModule.name) });
51
+ turboModules.forEach((turboModule) => {
52
+ turboModules_indexTS.addReexport({ from: `./${turboModule.name}` });
65
53
  generatedPackageH_v2.addTurboModule(turboModule);
66
54
  });
67
- fileContentByPath.set(_this.cppOutputPath.copyWithNewSegment(libraryName, 'RNOH', 'generated', "".concat(basePackageClassName, ".h")), generatedPackageH_v2.build());
55
+ fileContentByPath.set(this.cppOutputPath.copyWithNewSegment(libraryName, 'RNOH', 'generated', `${basePackageClassName}.h`), generatedPackageH_v2.build());
68
56
  });
69
57
  fileContentByPath.set(this.cppOutputPath.copyWithNewSegment('RNOHGeneratedPackage.h'), generatedPackageH_v1.build());
70
58
  fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('ts.ts'), new templates_1.IndexTSTemplate(this.codegenNoticeLines)
@@ -75,7 +63,6 @@ var AppBuildTimeGlueCodeGenerator = /** @class */ (function () {
75
63
  fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('turboModules', 'ts.ts'), turboModules_indexTS.build());
76
64
  fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('index.ets'), generated_indexETS.build());
77
65
  return fileContentByPath;
78
- };
79
- return AppBuildTimeGlueCodeGenerator;
80
- }());
66
+ }
67
+ }
81
68
  exports.AppBuildTimeGlueCodeGenerator = AppBuildTimeGlueCodeGenerator;
@@ -7,35 +7,33 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.ArkTSComponentCodeGeneratorArkTS = void 0;
10
- var core_1 = require("../core");
11
- var templates_1 = require("../templates");
12
- var ArkTSComponentCodeGeneratorArkTS = /** @class */ (function () {
13
- function ArkTSComponentCodeGeneratorArkTS(cppOutputPath, tsOutputPath, codegenNoticeLines, rnohImport) {
10
+ const core_1 = require("../core");
11
+ const templates_1 = require("../templates");
12
+ class ArkTSComponentCodeGeneratorArkTS {
13
+ constructor(cppOutputPath, tsOutputPath, codegenNoticeLines, rnohImport) {
14
14
  this.cppOutputPath = cppOutputPath;
15
15
  this.tsOutputPath = tsOutputPath;
16
16
  this.codegenNoticeLines = codegenNoticeLines;
17
17
  this.rnohImport = rnohImport;
18
18
  this.glueCodeDataItems = [];
19
19
  }
20
- ArkTSComponentCodeGeneratorArkTS.prototype.getGlueCodeData = function () {
20
+ getGlueCodeData() {
21
21
  return this.glueCodeDataItems;
22
- };
23
- ArkTSComponentCodeGeneratorArkTS.prototype.generate = function (schema) {
24
- var _this = this;
22
+ }
23
+ generate(schema) {
25
24
  if (schema.type !== 'Component') {
26
25
  throw new core_1.CodegenError({
27
- whatHappened: "ComponentCodeGenerator can't generate code for a module type: ".concat(schema.type),
26
+ whatHappened: `ComponentCodeGenerator can't generate code for a module type: ${schema.type}`,
28
27
  unexpected: true,
29
28
  });
30
29
  }
31
- var typeAnnotationToTS = new core_1.TypeAnnotationToTS();
32
- var result = new Map();
33
- Object.entries(schema.components).map(function (_a) {
34
- var name = _a[0], shape = _a[1];
35
- var componentDescriptorHTemplate = new templates_1.ComponentDescriptorHTemplate(name);
36
- var componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(name, _this.codegenNoticeLines);
37
- var componentUtilsTSTemplate = new templates_1.ComponentUtilsTSTemplate(name, _this.codegenNoticeLines, _this.rnohImport);
38
- shape.props.forEach(function (prop) {
30
+ const typeAnnotationToTS = new core_1.TypeAnnotationToTS();
31
+ const result = new Map();
32
+ Object.entries(schema.components).map(([name, shape]) => {
33
+ const componentDescriptorHTemplate = new templates_1.ComponentDescriptorHTemplate(name);
34
+ const componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(name, this.codegenNoticeLines);
35
+ const componentUtilsTSTemplate = new templates_1.ComponentUtilsTSTemplate(name, this.codegenNoticeLines, this.rnohImport);
36
+ shape.props.forEach((prop) => {
39
37
  componentJSIBinderHTemplate.addProp({
40
38
  name: prop.name,
41
39
  isObject: prop.typeAnnotation.type === 'ObjectTypeAnnotation',
@@ -47,7 +45,7 @@ var ArkTSComponentCodeGeneratorArkTS = /** @class */ (function () {
47
45
  isOptional: prop.optional,
48
46
  });
49
47
  });
50
- shape.commands.forEach(function (command) {
48
+ shape.commands.forEach((command) => {
51
49
  componentJSIBinderHTemplate.addCommand({
52
50
  name: command.name,
53
51
  });
@@ -55,15 +53,13 @@ var ArkTSComponentCodeGeneratorArkTS = /** @class */ (function () {
55
53
  name: command.name,
56
54
  argsTSType: '[' +
57
55
  command.typeAnnotation.params
58
- .map(function (param) {
59
- return typeAnnotationToTS.convert(param.typeAnnotation) +
60
- (param.optional ? '?' : '');
61
- })
56
+ .map((param) => typeAnnotationToTS.convert(param.typeAnnotation) +
57
+ (param.optional ? '?' : ''))
62
58
  .join(', ') +
63
59
  ']',
64
60
  });
65
61
  });
66
- shape.events.forEach(function (event) {
62
+ shape.events.forEach((event) => {
67
63
  componentUtilsTSTemplate.addEvent({
68
64
  name: (0, core_1.createEventNameFromEventHandlerName)(event.name),
69
65
  payloadTSType: event.typeAnnotation.argument
@@ -75,18 +71,15 @@ var ArkTSComponentCodeGeneratorArkTS = /** @class */ (function () {
75
71
  eventHandlerName: event.name,
76
72
  });
77
73
  });
78
- result.set(_this.cppOutputPath.copyWithNewSegment("".concat(name, "ComponentDescriptor.h")), componentDescriptorHTemplate.build());
79
- result.set(_this.cppOutputPath.copyWithNewSegment("".concat(name, "JSIBinder.h")), componentJSIBinderHTemplate.build());
80
- result.set(_this.tsOutputPath.copyWithNewSegment("".concat(name, ".ts")), componentUtilsTSTemplate.build());
81
- _this.glueCodeDataItems.push({
82
- name: name,
83
- eventNames: shape.events.map(function (e) {
84
- return (0, core_1.createEventNameFromEventHandlerName)(e.name);
85
- }),
74
+ result.set(this.cppOutputPath.copyWithNewSegment(`${name}ComponentDescriptor.h`), componentDescriptorHTemplate.build());
75
+ result.set(this.cppOutputPath.copyWithNewSegment(`${name}JSIBinder.h`), componentJSIBinderHTemplate.build());
76
+ result.set(this.tsOutputPath.copyWithNewSegment(`${name}.ts`), componentUtilsTSTemplate.build());
77
+ this.glueCodeDataItems.push({
78
+ name,
79
+ eventNames: shape.events.map((e) => (0, core_1.createEventNameFromEventHandlerName)(e.name)),
86
80
  });
87
81
  });
88
82
  return result;
89
- };
90
- return ArkTSComponentCodeGeneratorArkTS;
91
- }());
83
+ }
84
+ }
92
85
  exports.ArkTSComponentCodeGeneratorArkTS = ArkTSComponentCodeGeneratorArkTS;
@@ -7,34 +7,31 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.ArkTSComponentCodeGeneratorCAPI = void 0;
10
- var core_1 = require("../core");
11
- var templates_1 = require("../templates");
10
+ const core_1 = require("../core");
11
+ const templates_1 = require("../templates");
12
12
  /**
13
13
  * Generates component code for ArkTS components used in C-API architecture.
14
14
  */
15
- var ArkTSComponentCodeGeneratorCAPI = /** @class */ (function () {
16
- function ArkTSComponentCodeGeneratorCAPI(cppOutputPath, tsOutputPath, codegenNoticeLines, rnohImport) {
15
+ class ArkTSComponentCodeGeneratorCAPI {
16
+ constructor(cppOutputPath, tsOutputPath, codegenNoticeLines, rnohImport) {
17
17
  this.cppOutputPath = cppOutputPath;
18
18
  this.tsOutputPath = tsOutputPath;
19
19
  this.codegenNoticeLines = codegenNoticeLines;
20
20
  this.rnohImport = rnohImport;
21
21
  this.glueCodeDataItems = [];
22
22
  }
23
- ArkTSComponentCodeGeneratorCAPI.prototype.getLibGlueCodeData = function () {
23
+ getLibGlueCodeData() {
24
24
  return this.glueCodeDataItems;
25
- };
26
- ArkTSComponentCodeGeneratorCAPI.prototype.generate = function (uberSchema) {
27
- var _this = this;
28
- var typeAnnotationToTS = new core_1.TypeAnnotationToTS();
29
- var result = new Map();
30
- var componentSpecSchemas = uberSchema.findAllSpecSchemasByType('Component');
31
- for (var _i = 0, componentSpecSchemas_1 = componentSpecSchemas; _i < componentSpecSchemas_1.length; _i++) {
32
- var componentSpecSchema = componentSpecSchemas_1[_i];
33
- Object.entries(componentSpecSchema.components).map(function (_a) {
34
- var name = _a[0], shape = _a[1];
35
- var componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(name, _this.codegenNoticeLines);
36
- var componentUtilsTSTemplate = new templates_1.ComponentUtilsTSTemplate(name, _this.codegenNoticeLines, _this.rnohImport);
37
- shape.props.forEach(function (prop) {
25
+ }
26
+ generate(uberSchema) {
27
+ const typeAnnotationToTS = new core_1.TypeAnnotationToTS();
28
+ const result = new Map();
29
+ const componentSpecSchemas = uberSchema.findAllSpecSchemasByType('Component');
30
+ for (const componentSpecSchema of componentSpecSchemas) {
31
+ Object.entries(componentSpecSchema.components).map(([name, shape]) => {
32
+ const componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(name, this.codegenNoticeLines);
33
+ const componentUtilsTSTemplate = new templates_1.ComponentUtilsTSTemplate(name, this.codegenNoticeLines, this.rnohImport);
34
+ shape.props.forEach((prop) => {
38
35
  componentJSIBinderHTemplate.addProp({
39
36
  name: prop.name,
40
37
  isObject: prop.typeAnnotation.type === 'ObjectTypeAnnotation',
@@ -46,7 +43,7 @@ var ArkTSComponentCodeGeneratorCAPI = /** @class */ (function () {
46
43
  isOptional: prop.optional,
47
44
  });
48
45
  });
49
- shape.commands.forEach(function (command) {
46
+ shape.commands.forEach((command) => {
50
47
  componentJSIBinderHTemplate.addCommand({
51
48
  name: command.name,
52
49
  });
@@ -54,15 +51,13 @@ var ArkTSComponentCodeGeneratorCAPI = /** @class */ (function () {
54
51
  name: command.name,
55
52
  argsTSType: '[' +
56
53
  command.typeAnnotation.params
57
- .map(function (param) {
58
- return typeAnnotationToTS.convert(param.typeAnnotation) +
59
- (param.optional ? '?' : '');
60
- })
54
+ .map((param) => typeAnnotationToTS.convert(param.typeAnnotation) +
55
+ (param.optional ? '?' : ''))
61
56
  .join(', ') +
62
57
  ']',
63
58
  });
64
59
  });
65
- shape.events.forEach(function (event) {
60
+ shape.events.forEach((event) => {
66
61
  componentUtilsTSTemplate.addEvent({
67
62
  name: (0, core_1.createEventNameFromEventHandlerName)(event.name),
68
63
  payloadTSType: event.typeAnnotation.argument
@@ -74,18 +69,15 @@ var ArkTSComponentCodeGeneratorCAPI = /** @class */ (function () {
74
69
  eventHandlerName: event.name,
75
70
  });
76
71
  });
77
- result.set(_this.cppOutputPath.copyWithNewSegment("".concat(name, "JSIBinder.h")), componentJSIBinderHTemplate.build());
78
- result.set(_this.tsOutputPath.copyWithNewSegment("".concat(name, ".ts")), componentUtilsTSTemplate.build());
79
- _this.glueCodeDataItems.push({
72
+ result.set(this.cppOutputPath.copyWithNewSegment(`${name}JSIBinder.h`), componentJSIBinderHTemplate.build());
73
+ result.set(this.tsOutputPath.copyWithNewSegment(`${name}.ts`), componentUtilsTSTemplate.build());
74
+ this.glueCodeDataItems.push({
80
75
  componentName: name,
81
- eventNames: shape.events.map(function (event) {
82
- return (0, core_1.createEventNameFromEventHandlerName)(event.name);
83
- }),
76
+ eventNames: shape.events.map((event) => (0, core_1.createEventNameFromEventHandlerName)(event.name)),
84
77
  });
85
78
  });
86
79
  }
87
80
  return result;
88
- };
89
- return ArkTSComponentCodeGeneratorCAPI;
90
- }());
81
+ }
82
+ }
91
83
  exports.ArkTSComponentCodeGeneratorCAPI = ArkTSComponentCodeGeneratorCAPI;
@@ -7,64 +7,59 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.CppComponentCodeGenerator = void 0;
10
- var templates_1 = require("../templates");
11
- var CppComponentCodeGenerator = /** @class */ (function () {
12
- function CppComponentCodeGenerator(onGetRNOHOutputPath, codegenNoticeLines) {
10
+ const templates_1 = require("../templates");
11
+ class CppComponentCodeGenerator {
12
+ constructor(onGetRNOHOutputPath, codegenNoticeLines) {
13
13
  this.onGetRNOHOutputPath = onGetRNOHOutputPath;
14
14
  this.codegenNoticeLines = codegenNoticeLines;
15
15
  this.glueCodeComponentsData = [];
16
16
  }
17
- CppComponentCodeGenerator.prototype.getGlueCodeData = function () {
17
+ getGlueCodeData() {
18
18
  return this.glueCodeComponentsData;
19
- };
20
- CppComponentCodeGenerator.prototype.generate = function (_a) {
21
- var _this = this;
22
- var libraryCppName = _a.libraryCppName, uberSchema = _a.uberSchema;
23
- var fileContentByPath = new Map();
24
- for (var _i = 0, _b = uberSchema
19
+ }
20
+ generate({ libraryCppName, uberSchema, }) {
21
+ const fileContentByPath = new Map();
22
+ for (const [_filename, schema] of uberSchema
25
23
  .getSpecSchemaByFilenameMap()
26
- .entries(); _i < _b.length; _i++) {
27
- var _c = _b[_i], _filename = _c[0], schema = _c[1];
24
+ .entries()) {
28
25
  if (schema.type === 'Component') {
29
- Object.entries(schema.components).map(function (_a) {
30
- var componentName = _a[0], shape = _a[1];
31
- var componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(componentName, _this.codegenNoticeLines);
32
- var componentInstanceSpecHTemplate = new templates_1.BaseComponentInstanceHTemplate(componentName, libraryCppName, _this.codegenNoticeLines);
33
- shape.props.forEach(function (prop) {
26
+ Object.entries(schema.components).map(([componentName, shape]) => {
27
+ const componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(componentName, this.codegenNoticeLines);
28
+ const componentInstanceSpecHTemplate = new templates_1.BaseComponentInstanceHTemplate(componentName, libraryCppName, this.codegenNoticeLines);
29
+ shape.props.forEach((prop) => {
34
30
  componentJSIBinderHTemplate.addProp({
35
31
  name: prop.name,
36
32
  isObject: prop.typeAnnotation.type === 'ObjectTypeAnnotation',
37
33
  });
38
34
  });
39
- shape.events.forEach(function (event) {
35
+ shape.events.forEach((event) => {
40
36
  componentJSIBinderHTemplate.addEvent({
41
37
  type: event.bubblingType,
42
38
  eventHandlerName: event.name,
43
39
  });
44
40
  });
45
- shape.commands.forEach(function (command) {
41
+ shape.commands.forEach((command) => {
46
42
  componentJSIBinderHTemplate.addCommand({
47
43
  name: command.name,
48
44
  });
49
45
  componentInstanceSpecHTemplate.addCommand({
50
46
  name: command.name,
51
- args: command.typeAnnotation.params.map(function (param) { return ({
47
+ args: command.typeAnnotation.params.map((param) => ({
52
48
  name: param.name,
53
49
  typeAnnotation: param.typeAnnotation,
54
- }); }),
50
+ })),
55
51
  });
56
52
  });
57
- fileContentByPath.set(_this.onGetRNOHOutputPath("".concat(componentName, "JSIBinder.h")), componentJSIBinderHTemplate.build());
58
- fileContentByPath.set(_this.onGetRNOHOutputPath("Base".concat(componentName, "ComponentInstance.h")), componentInstanceSpecHTemplate.build());
59
- _this.glueCodeComponentsData.push({
53
+ fileContentByPath.set(this.onGetRNOHOutputPath(`${componentName}JSIBinder.h`), componentJSIBinderHTemplate.build());
54
+ fileContentByPath.set(this.onGetRNOHOutputPath(`Base${componentName}ComponentInstance.h`), componentInstanceSpecHTemplate.build());
55
+ this.glueCodeComponentsData.push({
60
56
  name: componentName,
61
- libraryCppName: libraryCppName,
57
+ libraryCppName,
62
58
  });
63
59
  });
64
60
  }
65
61
  }
66
62
  return fileContentByPath;
67
- };
68
- return CppComponentCodeGenerator;
69
- }());
63
+ }
64
+ }
70
65
  exports.CppComponentCodeGenerator = CppComponentCodeGenerator;