@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,26 +14,53 @@ 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.UberSchema = void 0;
22
- const core_1 = require("../../core");
46
+ var core_1 = require("../../core");
23
47
  // @ts-expect-error
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");
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");
26
50
  function createRawUberSchemaFromSpecFilePaths(projectSourceFilePaths) {
27
- return (0, combine_js_to_schema_js_1.default)(projectSourceFilePaths.map((p) => p.getValue()));
51
+ return (0, combine_js_to_schema_js_1.default)(projectSourceFilePaths.map(function (p) { return p.getValue(); }));
28
52
  }
29
53
  /**
30
54
  * Contains component and turbo module (NativeModule) schemas. The "Uber" word is used here to highlight that SpecSchemas don't extend this class.
31
55
  */
32
- class UberSchema {
33
- static fromSpecFilePaths(specPaths) {
34
- return new UberSchema(createRawUberSchemaFromSpecFilePaths(specPaths));
56
+ var UberSchema = /** @class */ (function () {
57
+ function UberSchema(schemaValue) {
58
+ this.schemaValue = schemaValue;
35
59
  }
36
- static fromCodegenConfig(codegenConfig) {
60
+ UberSchema.fromSpecFilePaths = function (specPaths) {
61
+ return new UberSchema(createRawUberSchemaFromSpecFilePaths(specPaths));
62
+ };
63
+ UberSchema.fromCodegenConfig = function (codegenConfig) {
37
64
  try {
38
65
  return new UberSchema(createRawUberSchemaFromSpecFilePaths(codegenConfig.getSpecFilePaths()));
39
66
  }
@@ -42,64 +69,76 @@ class UberSchema {
42
69
  throw new CodegenError_1.CodegenError({
43
70
  whatHappened: "Couldn't create the schema",
44
71
  whatCanUserDo: [
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}`,
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),
46
73
  ],
47
74
  });
48
75
  }
49
76
  throw err;
50
77
  }
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
- }
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*/];
69
123
  }
70
124
  });
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
- }
85
125
  });
86
- }
87
- constructor(schemaValue) {
88
- this.schemaValue = schemaValue;
89
- }
90
- getValue() {
126
+ };
127
+ UberSchema.prototype.getValue = function () {
91
128
  return this.schemaValue;
92
- }
93
- findAllSpecSchemasByType(schemaType) {
129
+ };
130
+ UberSchema.prototype.findAllSpecSchemasByType = function (schemaType) {
94
131
  return Object.values(this.schemaValue.modules)
95
- .filter((module) => module.type === schemaType)
96
- .map((module) => module);
97
- }
98
- getSpecSchemaByFilenameMap() {
99
- return Object.entries(this.schemaValue.modules).reduce((acc, [moduleName, moduleSchema]) => {
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];
100
138
  acc.set(moduleName, moduleSchema);
101
139
  return acc;
102
140
  }, new Map());
103
- }
104
- }
141
+ };
142
+ return UberSchema;
143
+ }());
105
144
  exports.UberSchema = UberSchema;
@@ -5,53 +5,66 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
9
- return (mod && mod.__esModule) ? mod : { "default": mod };
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);
10
18
  };
11
19
  Object.defineProperty(exports, "__esModule", { value: true });
12
20
  exports.AppBuildTimeGlueCodeGenerator = void 0;
13
- const case_1 = __importDefault(require("case"));
14
- const templates_1 = require("../templates");
15
- const BasePackageHTemplate_1 = require("../templates/BasePackageHTemplate");
21
+ var case_1 = require("case");
22
+ var templates_1 = require("../templates");
23
+ var BasePackageHTemplate_1 = require("../templates/BasePackageHTemplate");
16
24
  /**
17
25
  * Generates code based on UberGenerators results. If UberGenerators produce "leaves" (concrete turbo module or component classes),
18
26
  * this class generates "branches" (barrel files like index.ts) and "trunks" (package file or files).
19
27
  */
20
- class AppBuildTimeGlueCodeGenerator {
21
- constructor(cppOutputPath, etsOutputPath, codegenNoticeLines) {
28
+ var AppBuildTimeGlueCodeGenerator = /** @class */ (function () {
29
+ function AppBuildTimeGlueCodeGenerator(cppOutputPath, etsOutputPath, codegenNoticeLines) {
22
30
  this.cppOutputPath = cppOutputPath;
23
31
  this.etsOutputPath = etsOutputPath;
24
32
  this.codegenNoticeLines = codegenNoticeLines;
25
33
  }
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);
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);
32
42
  generated_indexETS.addReexport({ from: './ts' });
33
- v1.components.forEach(({ name, eventNames }) => {
34
- components_indexTS.addReexport({ from: `./${name}` });
43
+ v1.components.forEach(function (_a) {
44
+ var name = _a.name, eventNames = _a.eventNames;
45
+ components_indexTS.addReexport({ from: "./".concat(name) });
35
46
  generatedPackageH_v1.addComponent({
36
- name,
47
+ name: name,
37
48
  supportedEventNames: eventNames,
49
+ isArkTSComponent: true,
38
50
  });
39
51
  });
40
- v1.turboModules.forEach((turboModule) => {
41
- turboModules_indexTS.addReexport({ from: `./${turboModule.name}` });
52
+ v1.turboModules.forEach(function (turboModule) {
53
+ turboModules_indexTS.addReexport({ from: "./".concat(turboModule.name) });
42
54
  generatedPackageH_v1.addTurboModule(turboModule);
43
55
  });
44
- v2.forEach(({ components, turboModules }, libraryName) => {
45
- const basePackageClassName = `Base${case_1.default.pascal(libraryName)}Package`;
46
- const generatedPackageH_v2 = new BasePackageHTemplate_1.BasePackageHTemplate(basePackageClassName, this.codegenNoticeLines);
47
- components.forEach((component) => {
48
- generatedPackageH_v2.addComponent(component);
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 }));
49
62
  });
50
- turboModules.forEach((turboModule) => {
51
- turboModules_indexTS.addReexport({ from: `./${turboModule.name}` });
63
+ turboModules.forEach(function (turboModule) {
64
+ turboModules_indexTS.addReexport({ from: "./".concat(turboModule.name) });
52
65
  generatedPackageH_v2.addTurboModule(turboModule);
53
66
  });
54
- fileContentByPath.set(this.cppOutputPath.copyWithNewSegment(libraryName, 'RNOH', 'generated', `${basePackageClassName}.h`), generatedPackageH_v2.build());
67
+ fileContentByPath.set(_this.cppOutputPath.copyWithNewSegment(libraryName, 'RNOH', 'generated', "".concat(basePackageClassName, ".h")), generatedPackageH_v2.build());
55
68
  });
56
69
  fileContentByPath.set(this.cppOutputPath.copyWithNewSegment('RNOHGeneratedPackage.h'), generatedPackageH_v1.build());
57
70
  fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('ts.ts'), new templates_1.IndexTSTemplate(this.codegenNoticeLines)
@@ -62,6 +75,7 @@ class AppBuildTimeGlueCodeGenerator {
62
75
  fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('turboModules', 'ts.ts'), turboModules_indexTS.build());
63
76
  fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('index.ets'), generated_indexETS.build());
64
77
  return fileContentByPath;
65
- }
66
- }
78
+ };
79
+ return AppBuildTimeGlueCodeGenerator;
80
+ }());
67
81
  exports.AppBuildTimeGlueCodeGenerator = AppBuildTimeGlueCodeGenerator;
@@ -7,33 +7,35 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.ArkTSComponentCodeGeneratorArkTS = void 0;
10
- const core_1 = require("../core");
11
- const templates_1 = require("../templates");
12
- class ArkTSComponentCodeGeneratorArkTS {
13
- constructor(cppOutputPath, tsOutputPath, codegenNoticeLines, rnohImport) {
10
+ var core_1 = require("../core");
11
+ var templates_1 = require("../templates");
12
+ var ArkTSComponentCodeGeneratorArkTS = /** @class */ (function () {
13
+ function ArkTSComponentCodeGeneratorArkTS(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
- getGlueCodeData() {
20
+ ArkTSComponentCodeGeneratorArkTS.prototype.getGlueCodeData = function () {
21
21
  return this.glueCodeDataItems;
22
- }
23
- generate(schema) {
22
+ };
23
+ ArkTSComponentCodeGeneratorArkTS.prototype.generate = function (schema) {
24
+ var _this = this;
24
25
  if (schema.type !== 'Component') {
25
26
  throw new core_1.CodegenError({
26
- whatHappened: `ComponentCodeGenerator can't generate code for a module type: ${schema.type}`,
27
+ whatHappened: "ComponentCodeGenerator can't generate code for a module type: ".concat(schema.type),
27
28
  unexpected: true,
28
29
  });
29
30
  }
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) => {
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) {
37
39
  componentJSIBinderHTemplate.addProp({
38
40
  name: prop.name,
39
41
  isObject: prop.typeAnnotation.type === 'ObjectTypeAnnotation',
@@ -45,7 +47,7 @@ class ArkTSComponentCodeGeneratorArkTS {
45
47
  isOptional: prop.optional,
46
48
  });
47
49
  });
48
- shape.commands.forEach((command) => {
50
+ shape.commands.forEach(function (command) {
49
51
  componentJSIBinderHTemplate.addCommand({
50
52
  name: command.name,
51
53
  });
@@ -53,13 +55,15 @@ class ArkTSComponentCodeGeneratorArkTS {
53
55
  name: command.name,
54
56
  argsTSType: '[' +
55
57
  command.typeAnnotation.params
56
- .map((param) => typeAnnotationToTS.convert(param.typeAnnotation) +
57
- (param.optional ? '?' : ''))
58
+ .map(function (param) {
59
+ return typeAnnotationToTS.convert(param.typeAnnotation) +
60
+ (param.optional ? '?' : '');
61
+ })
58
62
  .join(', ') +
59
63
  ']',
60
64
  });
61
65
  });
62
- shape.events.forEach((event) => {
66
+ shape.events.forEach(function (event) {
63
67
  componentUtilsTSTemplate.addEvent({
64
68
  name: (0, core_1.createEventNameFromEventHandlerName)(event.name),
65
69
  payloadTSType: event.typeAnnotation.argument
@@ -71,15 +75,18 @@ class ArkTSComponentCodeGeneratorArkTS {
71
75
  eventHandlerName: event.name,
72
76
  });
73
77
  });
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)),
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
+ }),
80
86
  });
81
87
  });
82
88
  return result;
83
- }
84
- }
89
+ };
90
+ return ArkTSComponentCodeGeneratorArkTS;
91
+ }());
85
92
  exports.ArkTSComponentCodeGeneratorArkTS = ArkTSComponentCodeGeneratorArkTS;
@@ -7,31 +7,34 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.ArkTSComponentCodeGeneratorCAPI = void 0;
10
- const core_1 = require("../core");
11
- const templates_1 = require("../templates");
10
+ var core_1 = require("../core");
11
+ var templates_1 = require("../templates");
12
12
  /**
13
13
  * Generates component code for ArkTS components used in C-API architecture.
14
14
  */
15
- class ArkTSComponentCodeGeneratorCAPI {
16
- constructor(cppOutputPath, tsOutputPath, codegenNoticeLines, rnohImport) {
15
+ var ArkTSComponentCodeGeneratorCAPI = /** @class */ (function () {
16
+ function ArkTSComponentCodeGeneratorCAPI(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
- getLibGlueCodeData() {
23
+ ArkTSComponentCodeGeneratorCAPI.prototype.getLibGlueCodeData = function () {
24
24
  return this.glueCodeDataItems;
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) => {
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) {
35
38
  componentJSIBinderHTemplate.addProp({
36
39
  name: prop.name,
37
40
  isObject: prop.typeAnnotation.type === 'ObjectTypeAnnotation',
@@ -43,7 +46,7 @@ class ArkTSComponentCodeGeneratorCAPI {
43
46
  isOptional: prop.optional,
44
47
  });
45
48
  });
46
- shape.commands.forEach((command) => {
49
+ shape.commands.forEach(function (command) {
47
50
  componentJSIBinderHTemplate.addCommand({
48
51
  name: command.name,
49
52
  });
@@ -51,13 +54,15 @@ class ArkTSComponentCodeGeneratorCAPI {
51
54
  name: command.name,
52
55
  argsTSType: '[' +
53
56
  command.typeAnnotation.params
54
- .map((param) => typeAnnotationToTS.convert(param.typeAnnotation) +
55
- (param.optional ? '?' : ''))
57
+ .map(function (param) {
58
+ return typeAnnotationToTS.convert(param.typeAnnotation) +
59
+ (param.optional ? '?' : '');
60
+ })
56
61
  .join(', ') +
57
62
  ']',
58
63
  });
59
64
  });
60
- shape.events.forEach((event) => {
65
+ shape.events.forEach(function (event) {
61
66
  componentUtilsTSTemplate.addEvent({
62
67
  name: (0, core_1.createEventNameFromEventHandlerName)(event.name),
63
68
  payloadTSType: event.typeAnnotation.argument
@@ -69,15 +74,18 @@ class ArkTSComponentCodeGeneratorCAPI {
69
74
  eventHandlerName: event.name,
70
75
  });
71
76
  });
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({
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({
75
80
  componentName: name,
76
- eventNames: shape.events.map((event) => (0, core_1.createEventNameFromEventHandlerName)(event.name)),
81
+ eventNames: shape.events.map(function (event) {
82
+ return (0, core_1.createEventNameFromEventHandlerName)(event.name);
83
+ }),
77
84
  });
78
85
  });
79
86
  }
80
87
  return result;
81
- }
82
- }
88
+ };
89
+ return ArkTSComponentCodeGeneratorCAPI;
90
+ }());
83
91
  exports.ArkTSComponentCodeGeneratorCAPI = ArkTSComponentCodeGeneratorCAPI;
@@ -7,59 +7,64 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.CppComponentCodeGenerator = void 0;
10
- const templates_1 = require("../templates");
11
- class CppComponentCodeGenerator {
12
- constructor(onGetRNOHOutputPath, codegenNoticeLines) {
10
+ var templates_1 = require("../templates");
11
+ var CppComponentCodeGenerator = /** @class */ (function () {
12
+ function CppComponentCodeGenerator(onGetRNOHOutputPath, codegenNoticeLines) {
13
13
  this.onGetRNOHOutputPath = onGetRNOHOutputPath;
14
14
  this.codegenNoticeLines = codegenNoticeLines;
15
15
  this.glueCodeComponentsData = [];
16
16
  }
17
- getGlueCodeData() {
17
+ CppComponentCodeGenerator.prototype.getGlueCodeData = function () {
18
18
  return this.glueCodeComponentsData;
19
- }
20
- generate({ libraryCppName, uberSchema, }) {
21
- const fileContentByPath = new Map();
22
- for (const [_filename, schema] of uberSchema
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
23
25
  .getSpecSchemaByFilenameMap()
24
- .entries()) {
26
+ .entries(); _i < _b.length; _i++) {
27
+ var _c = _b[_i], _filename = _c[0], schema = _c[1];
25
28
  if (schema.type === 'Component') {
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) => {
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) {
30
34
  componentJSIBinderHTemplate.addProp({
31
35
  name: prop.name,
32
36
  isObject: prop.typeAnnotation.type === 'ObjectTypeAnnotation',
33
37
  });
34
38
  });
35
- shape.events.forEach((event) => {
39
+ shape.events.forEach(function (event) {
36
40
  componentJSIBinderHTemplate.addEvent({
37
41
  type: event.bubblingType,
38
42
  eventHandlerName: event.name,
39
43
  });
40
44
  });
41
- shape.commands.forEach((command) => {
45
+ shape.commands.forEach(function (command) {
42
46
  componentJSIBinderHTemplate.addCommand({
43
47
  name: command.name,
44
48
  });
45
49
  componentInstanceSpecHTemplate.addCommand({
46
50
  name: command.name,
47
- args: command.typeAnnotation.params.map((param) => ({
51
+ args: command.typeAnnotation.params.map(function (param) { return ({
48
52
  name: param.name,
49
53
  typeAnnotation: param.typeAnnotation,
50
- })),
54
+ }); }),
51
55
  });
52
56
  });
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({
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({
56
60
  name: componentName,
57
- libraryCppName,
61
+ libraryCppName: libraryCppName,
58
62
  });
59
63
  });
60
64
  }
61
65
  }
62
66
  return fileContentByPath;
63
- }
64
- }
67
+ };
68
+ return CppComponentCodeGenerator;
69
+ }());
65
70
  exports.CppComponentCodeGenerator = CppComponentCodeGenerator;