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

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 (106) hide show
  1. package/dist/assetResolver.js +74 -43
  2. package/dist/autolinking/Autolinking.js +179 -178
  3. package/dist/codegen/core/CodegenError.js +23 -3
  4. package/dist/codegen/core/EventUtils.js +3 -3
  5. package/dist/codegen/core/TypeAnnotationToTS.js +28 -24
  6. package/dist/codegen/core/UberSchema.js +97 -55
  7. package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +41 -28
  8. package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +34 -27
  9. package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +33 -25
  10. package/dist/codegen/generators/CppComponentCodeGenerator.js +28 -23
  11. package/dist/codegen/generators/LibGlueCodeGenerator.js +29 -26
  12. package/dist/codegen/generators/NativeModuleCodeGenerator.js +30 -25
  13. package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
  14. package/dist/codegen/generators/UberGeneratorV1.js +24 -18
  15. package/dist/codegen/generators/UberGeneratorV2.js +36 -28
  16. package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +24 -50
  17. package/dist/codegen/templates/BasePackageHTemplate.js +21 -120
  18. package/dist/codegen/templates/ComponentDescriptorHTemplate.js +8 -54
  19. package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +27 -75
  20. package/dist/codegen/templates/ComponentUtilsTSTemplate.js +29 -162
  21. package/dist/codegen/templates/IndexTSTemplate.js +17 -37
  22. package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +24 -119
  23. package/dist/codegen/templates/TurboModuleCppTemplate.js +15 -38
  24. package/dist/codegen/templates/TurboModuleHTemplate.js +11 -32
  25. package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +19 -52
  26. package/dist/commands/bundle-harmony.js +221 -118
  27. package/dist/commands/clean-harmony.js +63 -58
  28. package/dist/commands/codegen-harmony.js +175 -104
  29. package/dist/commands/codegen-lib-harmony.js +116 -76
  30. package/dist/commands/init-harmony.js +196 -151
  31. package/dist/commands/init.js +961 -537
  32. package/dist/commands/link-harmony.js +82 -35
  33. package/dist/commands/run-harmony.js +520 -352
  34. package/dist/commands/verify-package-harmony.js +117 -54
  35. package/dist/core/AbsolutePath.js +49 -33
  36. package/dist/core/CodegenConfig.js +22 -24
  37. package/dist/core/DescriptiveError.js +37 -18
  38. package/dist/core/FileSystem.js +18 -14
  39. package/dist/core/OHPackageJSON5.js +23 -17
  40. package/dist/core/PackageJSON.js +42 -26
  41. package/dist/core/ProjectDependenciesManager.js +92 -40
  42. package/dist/core/ValidationError.js +22 -2
  43. package/dist/core/fs.js +7 -10
  44. package/dist/index.js +1 -1
  45. package/dist/init/templates/AppScopeAppJSON5Template.js +8 -21
  46. package/dist/init/templates/AppScopeStringVarTemplate.js +8 -19
  47. package/dist/init/templates/EntryIndexTemplate.js +8 -56
  48. package/dist/init/templates/EntryStringVarTemplate.js +8 -27
  49. package/dist/init/templates/HvigorConfigJson5Template.js +8 -33
  50. package/dist/init/templates/MetroConfigTemplate.js +8 -38
  51. package/dist/init/templates/OhPackageJson5Template.js +8 -28
  52. package/dist/io/CliExecutor.js +98 -46
  53. package/dist/io/Logger.js +46 -40
  54. package/dist/io/RealFS.js +100 -43
  55. package/dist/io/TarGz.js +8 -11
  56. package/dist/io/__fixtures__.js +141 -79
  57. package/dist/io/fsUtils.js +12 -13
  58. package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +47 -19
  59. package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +41 -13
  60. package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +38 -8
  61. package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +54 -22
  62. package/dist/package-verifier/verify-package.js +133 -56
  63. package/dist/simulator/LaunchSimulator.js +395 -0
  64. package/dist/simulator/index.js +23 -0
  65. package/package.json +2 -11
  66. package/scripts/sync-hvigor.js +27 -0
  67. package/src/autolinking/Autolinking.ts +1 -1
  68. package/src/codegen/generators/UberGeneratorV1.ts +7 -2
  69. package/src/codegen/generators/UberGeneratorV2.ts +6 -1
  70. package/src/commands/codegen-harmony.ts +17 -7
  71. package/src/commands/run-harmony.ts +67 -41
  72. package/src/init/templates/harmony/entry/src/main/module.json5 +7 -0
  73. package/src/simulator/LaunchSimulator.ts +359 -0
  74. package/src/simulator/index.ts +8 -0
  75. package/dist/init/templates/harmony/AppScope/app.json5 +0 -10
  76. package/dist/init/templates/harmony/AppScope/resources/base/element/string.json +0 -8
  77. package/dist/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  78. package/dist/init/templates/harmony/build-profile.json5 +0 -36
  79. package/dist/init/templates/harmony/codelinter.json +0 -32
  80. package/dist/init/templates/harmony/entry/build-profile.json5 +0 -18
  81. package/dist/init/templates/harmony/entry/gitignore +0 -7
  82. package/dist/init/templates/harmony/entry/hvigorfile.ts +0 -13
  83. package/dist/init/templates/harmony/entry/oh-package.json5 +0 -9
  84. package/dist/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +0 -27
  85. package/dist/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +0 -13
  86. package/dist/init/templates/harmony/entry/src/main/cpp/gitignore +0 -4
  87. package/dist/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +0 -8
  88. package/dist/init/templates/harmony/entry/src/main/ets/codegen/gitignore +0 -2
  89. package/dist/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +0 -11
  90. package/dist/init/templates/harmony/entry/src/main/ets/gitignore +0 -1
  91. package/dist/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
  92. package/dist/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +0 -16
  93. package/dist/init/templates/harmony/entry/src/main/module.json5 +0 -58
  94. package/dist/init/templates/harmony/entry/src/main/resources/base/element/color.json +0 -8
  95. package/dist/init/templates/harmony/entry/src/main/resources/base/element/string.json +0 -16
  96. package/dist/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
  97. package/dist/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
  98. package/dist/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +0 -7
  99. package/dist/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
  100. package/dist/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +0 -5
  101. package/dist/init/templates/harmony/entry/src/main/resources/gitignore +0 -1
  102. package/dist/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +0 -2
  103. package/dist/init/templates/harmony/entry/src/ohosTest/module.json5 +0 -13
  104. package/dist/init/templates/harmony/gitignore +0 -16
  105. package/dist/init/templates/harmony/hvigor/hvigor-config.json5 +0 -22
  106. package/dist/init/templates/harmony/hvigorfile.ts +0 -7
@@ -1,31 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ArkTSComponentCodeGeneratorCAPI = void 0;
4
- const core_1 = require("../core");
5
- const templates_1 = require("../templates");
4
+ var core_1 = require("../core");
5
+ var templates_1 = require("../templates");
6
6
  /**
7
7
  * Generates component code for ArkTS components used in C-API architecture.
8
8
  */
9
- class ArkTSComponentCodeGeneratorCAPI {
10
- constructor(cppOutputPath, tsOutputPath, codegenNoticeLines, rnohImport) {
9
+ var ArkTSComponentCodeGeneratorCAPI = /** @class */ (function () {
10
+ function ArkTSComponentCodeGeneratorCAPI(cppOutputPath, tsOutputPath, codegenNoticeLines, rnohImport) {
11
11
  this.cppOutputPath = cppOutputPath;
12
12
  this.tsOutputPath = tsOutputPath;
13
13
  this.codegenNoticeLines = codegenNoticeLines;
14
14
  this.rnohImport = rnohImport;
15
15
  this.glueCodeDataItems = [];
16
16
  }
17
- getLibGlueCodeData() {
17
+ ArkTSComponentCodeGeneratorCAPI.prototype.getLibGlueCodeData = function () {
18
18
  return this.glueCodeDataItems;
19
- }
20
- generate(uberSchema) {
21
- const typeAnnotationToTS = new core_1.TypeAnnotationToTS();
22
- const result = new Map();
23
- const componentSpecSchemas = uberSchema.findAllSpecSchemasByType('Component');
24
- for (const componentSpecSchema of componentSpecSchemas) {
25
- Object.entries(componentSpecSchema.components).map(([name, shape]) => {
26
- const componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(name, this.codegenNoticeLines);
27
- const componentUtilsTSTemplate = new templates_1.ComponentUtilsTSTemplate(name, this.codegenNoticeLines, this.rnohImport);
28
- shape.props.forEach((prop) => {
19
+ };
20
+ ArkTSComponentCodeGeneratorCAPI.prototype.generate = function (uberSchema) {
21
+ var _this = this;
22
+ var typeAnnotationToTS = new core_1.TypeAnnotationToTS();
23
+ var result = new Map();
24
+ var componentSpecSchemas = uberSchema.findAllSpecSchemasByType('Component');
25
+ for (var _i = 0, componentSpecSchemas_1 = componentSpecSchemas; _i < componentSpecSchemas_1.length; _i++) {
26
+ var componentSpecSchema = componentSpecSchemas_1[_i];
27
+ Object.entries(componentSpecSchema.components).map(function (_a) {
28
+ var name = _a[0], shape = _a[1];
29
+ var componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(name, _this.codegenNoticeLines);
30
+ var componentUtilsTSTemplate = new templates_1.ComponentUtilsTSTemplate(name, _this.codegenNoticeLines, _this.rnohImport);
31
+ shape.props.forEach(function (prop) {
29
32
  componentJSIBinderHTemplate.addProp({
30
33
  name: prop.name,
31
34
  isObject: prop.typeAnnotation.type === 'ObjectTypeAnnotation',
@@ -37,7 +40,7 @@ class ArkTSComponentCodeGeneratorCAPI {
37
40
  isOptional: prop.optional,
38
41
  });
39
42
  });
40
- shape.commands.forEach((command) => {
43
+ shape.commands.forEach(function (command) {
41
44
  componentJSIBinderHTemplate.addCommand({
42
45
  name: command.name,
43
46
  });
@@ -45,13 +48,15 @@ class ArkTSComponentCodeGeneratorCAPI {
45
48
  name: command.name,
46
49
  argsTSType: '[' +
47
50
  command.typeAnnotation.params
48
- .map((param) => typeAnnotationToTS.convert(param.typeAnnotation) +
49
- (param.optional ? '?' : ''))
51
+ .map(function (param) {
52
+ return typeAnnotationToTS.convert(param.typeAnnotation) +
53
+ (param.optional ? '?' : '');
54
+ })
50
55
  .join(', ') +
51
56
  ']',
52
57
  });
53
58
  });
54
- shape.events.forEach((event) => {
59
+ shape.events.forEach(function (event) {
55
60
  componentUtilsTSTemplate.addEvent({
56
61
  name: (0, core_1.createEventNameFromEventHandlerName)(event.name),
57
62
  payloadTSType: event.typeAnnotation.argument
@@ -63,15 +68,18 @@ class ArkTSComponentCodeGeneratorCAPI {
63
68
  eventHandlerName: event.name,
64
69
  });
65
70
  });
66
- result.set(this.cppOutputPath.copyWithNewSegment(`${name}JSIBinder.h`), componentJSIBinderHTemplate.build());
67
- result.set(this.tsOutputPath.copyWithNewSegment(`${name}.ts`), componentUtilsTSTemplate.build());
68
- this.glueCodeDataItems.push({
71
+ result.set(_this.cppOutputPath.copyWithNewSegment("".concat(name, "JSIBinder.h")), componentJSIBinderHTemplate.build());
72
+ result.set(_this.tsOutputPath.copyWithNewSegment("".concat(name, ".ts")), componentUtilsTSTemplate.build());
73
+ _this.glueCodeDataItems.push({
69
74
  componentName: name,
70
- eventNames: shape.events.map((event) => (0, core_1.createEventNameFromEventHandlerName)(event.name)),
75
+ eventNames: shape.events.map(function (event) {
76
+ return (0, core_1.createEventNameFromEventHandlerName)(event.name);
77
+ }),
71
78
  });
72
79
  });
73
80
  }
74
81
  return result;
75
- }
76
- }
82
+ };
83
+ return ArkTSComponentCodeGeneratorCAPI;
84
+ }());
77
85
  exports.ArkTSComponentCodeGeneratorCAPI = ArkTSComponentCodeGeneratorCAPI;
@@ -1,59 +1,64 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CppComponentCodeGenerator = void 0;
4
- const templates_1 = require("../templates");
5
- class CppComponentCodeGenerator {
6
- constructor(onGetRNOHOutputPath, codegenNoticeLines) {
4
+ var templates_1 = require("../templates");
5
+ var CppComponentCodeGenerator = /** @class */ (function () {
6
+ function CppComponentCodeGenerator(onGetRNOHOutputPath, codegenNoticeLines) {
7
7
  this.onGetRNOHOutputPath = onGetRNOHOutputPath;
8
8
  this.codegenNoticeLines = codegenNoticeLines;
9
9
  this.glueCodeComponentsData = [];
10
10
  }
11
- getGlueCodeData() {
11
+ CppComponentCodeGenerator.prototype.getGlueCodeData = function () {
12
12
  return this.glueCodeComponentsData;
13
- }
14
- generate({ libraryCppName, uberSchema, }) {
15
- const fileContentByPath = new Map();
16
- for (const [_filename, schema] of uberSchema
13
+ };
14
+ CppComponentCodeGenerator.prototype.generate = function (_a) {
15
+ var _this = this;
16
+ var libraryCppName = _a.libraryCppName, uberSchema = _a.uberSchema;
17
+ var fileContentByPath = new Map();
18
+ for (var _i = 0, _b = uberSchema
17
19
  .getSpecSchemaByFilenameMap()
18
- .entries()) {
20
+ .entries(); _i < _b.length; _i++) {
21
+ var _c = _b[_i], _filename = _c[0], schema = _c[1];
19
22
  if (schema.type === 'Component') {
20
- Object.entries(schema.components).map(([componentName, shape]) => {
21
- const componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(componentName, this.codegenNoticeLines);
22
- const componentInstanceSpecHTemplate = new templates_1.BaseComponentInstanceHTemplate(componentName, libraryCppName, this.codegenNoticeLines);
23
- shape.props.forEach((prop) => {
23
+ Object.entries(schema.components).map(function (_a) {
24
+ var componentName = _a[0], shape = _a[1];
25
+ var componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(componentName, _this.codegenNoticeLines);
26
+ var componentInstanceSpecHTemplate = new templates_1.BaseComponentInstanceHTemplate(componentName, libraryCppName, _this.codegenNoticeLines);
27
+ shape.props.forEach(function (prop) {
24
28
  componentJSIBinderHTemplate.addProp({
25
29
  name: prop.name,
26
30
  isObject: prop.typeAnnotation.type === 'ObjectTypeAnnotation',
27
31
  });
28
32
  });
29
- shape.events.forEach((event) => {
33
+ shape.events.forEach(function (event) {
30
34
  componentJSIBinderHTemplate.addEvent({
31
35
  type: event.bubblingType,
32
36
  eventHandlerName: event.name,
33
37
  });
34
38
  });
35
- shape.commands.forEach((command) => {
39
+ shape.commands.forEach(function (command) {
36
40
  componentJSIBinderHTemplate.addCommand({
37
41
  name: command.name,
38
42
  });
39
43
  componentInstanceSpecHTemplate.addCommand({
40
44
  name: command.name,
41
- args: command.typeAnnotation.params.map((param) => ({
45
+ args: command.typeAnnotation.params.map(function (param) { return ({
42
46
  name: param.name,
43
47
  typeAnnotation: param.typeAnnotation,
44
- })),
48
+ }); }),
45
49
  });
46
50
  });
47
- fileContentByPath.set(this.onGetRNOHOutputPath(`${componentName}JSIBinder.h`), componentJSIBinderHTemplate.build());
48
- fileContentByPath.set(this.onGetRNOHOutputPath(`Base${componentName}ComponentInstance.h`), componentInstanceSpecHTemplate.build());
49
- this.glueCodeComponentsData.push({
51
+ fileContentByPath.set(_this.onGetRNOHOutputPath("".concat(componentName, "JSIBinder.h")), componentJSIBinderHTemplate.build());
52
+ fileContentByPath.set(_this.onGetRNOHOutputPath("Base".concat(componentName, "ComponentInstance.h")), componentInstanceSpecHTemplate.build());
53
+ _this.glueCodeComponentsData.push({
50
54
  name: componentName,
51
- libraryCppName,
55
+ libraryCppName: libraryCppName,
52
56
  });
53
57
  });
54
58
  }
55
59
  }
56
60
  return fileContentByPath;
57
- }
58
- }
61
+ };
62
+ return CppComponentCodeGenerator;
63
+ }());
59
64
  exports.CppComponentCodeGenerator = CppComponentCodeGenerator;
@@ -1,41 +1,43 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.LibGlueCodeGenerator = void 0;
7
- const case_1 = __importDefault(require("case"));
8
- const BasePackageHTemplate_1 = require("../templates/BasePackageHTemplate");
9
- const templates_1 = require("../templates");
4
+ var case_1 = require("case");
5
+ var BasePackageHTemplate_1 = require("../templates/BasePackageHTemplate");
6
+ var templates_1 = require("../templates");
10
7
  /**
11
8
  * NOTE: This class is coupled with the generated code structure defined in the codegen-harmony-lib.
12
9
  */
13
- class LibGlueCodeGenerator {
14
- constructor(cppOutputPath, etsOutputPath, codegenNoticeLines) {
10
+ var LibGlueCodeGenerator = /** @class */ (function () {
11
+ function LibGlueCodeGenerator(cppOutputPath, etsOutputPath, codegenNoticeLines) {
15
12
  this.cppOutputPath = cppOutputPath;
16
13
  this.etsOutputPath = etsOutputPath;
17
14
  this.codegenNoticeLines = codegenNoticeLines;
18
15
  }
19
- generate({ libraryCppName, turboModules, arkTSComponents, cppComponents, }) {
20
- const fileContentByPath = new Map();
21
- const basePackageClassName = `Base${case_1.default.pascal(libraryCppName)}Package`;
22
- const turboModules_indexTS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
23
- const components_indexTS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
24
- const generated_indexETS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
25
- const basePackageTemplate = new BasePackageHTemplate_1.BasePackageHTemplate(basePackageClassName, this.codegenNoticeLines);
26
- turboModules.forEach((turboModule) => {
16
+ LibGlueCodeGenerator.prototype.generate = function (_a) {
17
+ var libraryCppName = _a.libraryCppName, turboModules = _a.turboModules, arkTSComponents = _a.arkTSComponents, cppComponents = _a.cppComponents;
18
+ var fileContentByPath = new Map();
19
+ var basePackageClassName = "Base".concat(case_1.default.pascal(libraryCppName), "Package");
20
+ var turboModules_indexTS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
21
+ var components_indexTS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
22
+ var generated_indexETS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
23
+ var basePackageTemplate = new BasePackageHTemplate_1.BasePackageHTemplate(basePackageClassName, this.codegenNoticeLines);
24
+ turboModules.forEach(function (turboModule) {
27
25
  basePackageTemplate.addTurboModule(turboModule);
28
- turboModules_indexTS.addReexport({ from: `./${turboModule.name}` });
26
+ turboModules_indexTS.addReexport({ from: "./".concat(turboModule.name) });
29
27
  });
30
- arkTSComponents.forEach(({ componentName, eventNames }) => {
31
- components_indexTS.addReexport({ from: `./${componentName}` });
32
- basePackageTemplate.addComponent({ name: componentName, libraryCppName, isArkTSComponent: true });
33
- eventNames.forEach((eventName) => basePackageTemplate.addArkTSEvent({ name: eventName }));
28
+ arkTSComponents.forEach(function (_a) {
29
+ var componentName = _a.componentName, eventNames = _a.eventNames;
30
+ components_indexTS.addReexport({ from: "./".concat(componentName) });
31
+ basePackageTemplate.addComponent({ name: componentName, libraryCppName: libraryCppName, isArkTSComponent: true });
32
+ eventNames.forEach(function (eventName) {
33
+ return basePackageTemplate.addArkTSEvent({ name: eventName });
34
+ });
34
35
  });
35
- cppComponents.forEach(({ componentName }) => {
36
- basePackageTemplate.addComponent({ name: componentName, libraryCppName, isArkTSComponent: false });
36
+ cppComponents.forEach(function (_a) {
37
+ var componentName = _a.componentName;
38
+ basePackageTemplate.addComponent({ name: componentName, libraryCppName: libraryCppName, isArkTSComponent: false });
37
39
  });
38
- fileContentByPath.set(this.cppOutputPath.copyWithNewSegment('RNOH', 'generated', `${basePackageClassName}.h`), basePackageTemplate.build());
40
+ fileContentByPath.set(this.cppOutputPath.copyWithNewSegment('RNOH', 'generated', "".concat(basePackageClassName, ".h")), basePackageTemplate.build());
39
41
  fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('components', 'ts.ts'), components_indexTS.build());
40
42
  fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('turboModules', 'ts.ts'), turboModules_indexTS.build());
41
43
  fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('ts.ts'), new templates_1.IndexTSTemplate(this.codegenNoticeLines)
@@ -45,6 +47,7 @@ class LibGlueCodeGenerator {
45
47
  generated_indexETS.addReexport({ from: './ts' });
46
48
  fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('index.ets'), generated_indexETS.build());
47
49
  return fileContentByPath;
48
- }
49
- }
50
+ };
51
+ return LibGlueCodeGenerator;
52
+ }());
50
53
  exports.LibGlueCodeGenerator = LibGlueCodeGenerator;
@@ -1,53 +1,55 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NativeModuleCodeGenerator = void 0;
4
- const templates_1 = require("../templates");
5
- const core_1 = require("../core");
4
+ var templates_1 = require("../templates");
5
+ var core_1 = require("../core");
6
6
  /**
7
7
  * Generates boilerplate code for Turbo Modules.
8
8
  */
9
- class NativeModuleCodeGenerator {
10
- constructor(cppOutputPath, etsOutputPath, codegenNoticeLines, rnohImport) {
9
+ var NativeModuleCodeGenerator = /** @class */ (function () {
10
+ function NativeModuleCodeGenerator(cppOutputPath, etsOutputPath, codegenNoticeLines, rnohImport) {
11
11
  this.cppOutputPath = cppOutputPath;
12
12
  this.etsOutputPath = etsOutputPath;
13
13
  this.codegenNoticeLines = codegenNoticeLines;
14
14
  this.rnohImport = rnohImport;
15
15
  this.glueCodeTurboModulesData = [];
16
16
  }
17
- getGlueCodeData() {
17
+ NativeModuleCodeGenerator.prototype.getGlueCodeData = function () {
18
18
  return this.glueCodeTurboModulesData;
19
- }
20
- generate(schema) {
21
- const result = new Map();
19
+ };
20
+ NativeModuleCodeGenerator.prototype.generate = function (schema) {
21
+ var result = new Map();
22
22
  if (schema.type !== 'NativeModule') {
23
23
  throw new core_1.CodegenError({
24
- whatHappened: `NativeModuleCodeGenerator can't generate code for module type: ${schema.type}`,
24
+ whatHappened: "NativeModuleCodeGenerator can't generate code for module type: ".concat(schema.type),
25
25
  unexpected: true,
26
26
  });
27
27
  }
28
- const typeAnnotationToTS = new core_1.TypeAnnotationToTS();
29
- const turboModuleInterfaceTS = new templates_1.TurboModuleInterfaceTS(schema.moduleName, this.codegenNoticeLines, this.rnohImport);
30
- const turboModuleH = new templates_1.TurboModuleHTemplate(schema.moduleName, this.codegenNoticeLines).build();
31
- result.set(this.cppOutputPath.copyWithNewSegment(`${schema.moduleName}.h`), turboModuleH);
32
- const turboModuleCpp = new templates_1.TurboModuleCppTemplate(schema.moduleName, this.codegenNoticeLines);
33
- Object.entries(schema.aliasMap).map(([name, typeAnnotation]) => {
28
+ var typeAnnotationToTS = new core_1.TypeAnnotationToTS();
29
+ var turboModuleInterfaceTS = new templates_1.TurboModuleInterfaceTS(schema.moduleName, this.codegenNoticeLines, this.rnohImport);
30
+ var turboModuleH = new templates_1.TurboModuleHTemplate(schema.moduleName, this.codegenNoticeLines).build();
31
+ result.set(this.cppOutputPath.copyWithNewSegment("".concat(schema.moduleName, ".h")), turboModuleH);
32
+ var turboModuleCpp = new templates_1.TurboModuleCppTemplate(schema.moduleName, this.codegenNoticeLines);
33
+ Object.entries(schema.aliasMap).map(function (_a) {
34
+ var name = _a[0], typeAnnotation = _a[1];
34
35
  turboModuleInterfaceTS.addAlias({
35
36
  name: name,
36
37
  type: typeAnnotationToTS.convert(typeAnnotation),
37
38
  });
38
39
  });
39
- Object.entries(schema.enumMap).map(([name, enumSpec]) => {
40
+ Object.entries(schema.enumMap).map(function (_a) {
41
+ var name = _a[0], enumSpec = _a[1];
40
42
  turboModuleInterfaceTS.addEnum({
41
- name,
42
- members: enumSpec.members.map((member) => ({
43
+ name: name,
44
+ members: enumSpec.members.map(function (member) { return ({
43
45
  name: member.name,
44
46
  value: typeof member.value === 'string'
45
47
  ? (0, core_1.wrapWithQuotes)(member.value)
46
48
  : member.value.toString(),
47
- })),
49
+ }); }),
48
50
  });
49
51
  });
50
- schema.spec.methods.map((prop) => {
52
+ schema.spec.methods.map(function (prop) {
51
53
  if (prop.typeAnnotation.type === 'FunctionTypeAnnotation') {
52
54
  turboModuleCpp.addMethod({
53
55
  name: prop.name,
@@ -59,15 +61,18 @@ class NativeModuleCodeGenerator {
59
61
  name: prop.name,
60
62
  returnType: typeAnnotationToTS.convert(prop.typeAnnotation.returnTypeAnnotation),
61
63
  stringifiedArgs: prop.typeAnnotation.params
62
- .map((param) => `${param.name}: ${typeAnnotationToTS.convert(param.typeAnnotation)}`)
64
+ .map(function (param) {
65
+ return "".concat(param.name, ": ").concat(typeAnnotationToTS.convert(param.typeAnnotation));
66
+ })
63
67
  .join(', '),
64
68
  });
65
69
  }
66
70
  });
67
- result.set(this.cppOutputPath.copyWithNewSegment(`${schema.moduleName}.cpp`), turboModuleCpp.build());
68
- result.set(this.etsOutputPath.copyWithNewSegment(`${schema.moduleName}.ts`), turboModuleInterfaceTS.build());
71
+ result.set(this.cppOutputPath.copyWithNewSegment("".concat(schema.moduleName, ".cpp")), turboModuleCpp.build());
72
+ result.set(this.etsOutputPath.copyWithNewSegment("".concat(schema.moduleName, ".ts")), turboModuleInterfaceTS.build());
69
73
  this.glueCodeTurboModulesData.push({ name: schema.moduleName });
70
74
  return result;
71
- }
72
- }
75
+ };
76
+ return NativeModuleCodeGenerator;
77
+ }());
73
78
  exports.NativeModuleCodeGenerator = NativeModuleCodeGenerator;
@@ -1,17 +1,16 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.SharedComponentCodeGenerator = void 0;
7
- const RNCodegen_1 = __importDefault(require("@react-native/codegen/lib/generators/RNCodegen"));
8
- class SharedComponentCodeGenerator {
9
- constructor(onGetSharedOutputPath) {
4
+ var RNCodegen_1 = require("@react-native/codegen/lib/generators/RNCodegen");
5
+ var SharedComponentCodeGenerator = /** @class */ (function () {
6
+ function SharedComponentCodeGenerator(onGetSharedOutputPath) {
10
7
  this.onGetSharedOutputPath = onGetSharedOutputPath;
11
8
  }
12
- generate({ libraryCppName, uberSchema, }) {
13
- const fileContentByPath = new Map();
14
- const generatorFns = [
9
+ SharedComponentCodeGenerator.prototype.generate = function (_a) {
10
+ var _this = this;
11
+ var libraryCppName = _a.libraryCppName, uberSchema = _a.uberSchema;
12
+ var fileContentByPath = new Map();
13
+ var generatorFns = [
15
14
  RNCodegen_1.default.allGenerators.generatePropsH,
16
15
  RNCodegen_1.default.allGenerators.generatePropsCpp,
17
16
  RNCodegen_1.default.allGenerators.generateEventEmitterH,
@@ -22,13 +21,14 @@ class SharedComponentCodeGenerator {
22
21
  RNCodegen_1.default.allGenerators.generateShadowNodeH,
23
22
  RNCodegen_1.default.allGenerators.generateShadowNodeCpp,
24
23
  ];
25
- generatorFns.forEach((generate) => {
26
- const filesOutput = generate(libraryCppName, uberSchema.getValue(), 'UNUSED_packageName', true);
27
- filesOutput.forEach((fileContent, filename) => {
28
- fileContentByPath.set(this.onGetSharedOutputPath(filename), fileContent);
24
+ generatorFns.forEach(function (generate) {
25
+ var filesOutput = generate(libraryCppName, uberSchema.getValue(), 'UNUSED_packageName', true);
26
+ filesOutput.forEach(function (fileContent, filename) {
27
+ fileContentByPath.set(_this.onGetSharedOutputPath(filename), fileContent);
29
28
  });
30
29
  });
31
30
  return fileContentByPath;
32
- }
33
- }
31
+ };
32
+ return SharedComponentCodeGenerator;
33
+ }());
34
34
  exports.SharedComponentCodeGenerator = SharedComponentCodeGenerator;
@@ -1,42 +1,47 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UberGeneratorV1 = void 0;
4
- const core_1 = require("../core");
5
- const NativeModuleCodeGenerator_1 = require("./NativeModuleCodeGenerator");
6
- const ArkTSComponentCodeGeneratorArkTS_1 = require("./ArkTSComponentCodeGeneratorArkTS");
4
+ var path_1 = require("path");
5
+ var core_1 = require("../core");
6
+ var NativeModuleCodeGenerator_1 = require("./NativeModuleCodeGenerator");
7
+ var ArkTSComponentCodeGeneratorArkTS_1 = require("./ArkTSComponentCodeGeneratorArkTS");
8
+ // The name of rnoh OHOS module
9
+ var RNOH_OHOS_NAME = '@rnoh/react-native-openharmony';
7
10
  /**
8
11
  * Generates code for libraries built on top of RNOH's ArkTS architecture.
9
12
  */
10
- class UberGeneratorV1 {
11
- constructor(cppOutputPath, etsOutputPath, codegenNoticeLines) {
13
+ var UberGeneratorV1 = /** @class */ (function () {
14
+ function UberGeneratorV1(cppOutputPath, etsOutputPath, codegenNoticeLines) {
12
15
  this.cppOutputPath = cppOutputPath;
13
16
  this.etsOutputPath = etsOutputPath;
14
17
  this.codegenNoticeLines = codegenNoticeLines;
15
18
  this.glueCodeData = { components: [], turboModules: [] };
16
19
  }
17
- getGlueCodeData() {
20
+ UberGeneratorV1.prototype.getGlueCodeData = function () {
18
21
  return this.glueCodeData;
19
- }
20
- generate(uberSchema) {
21
- const fileContentByPath = new Map();
22
- const componentCodeGenerator = new ArkTSComponentCodeGeneratorArkTS_1.ArkTSComponentCodeGeneratorArkTS(this.cppOutputPath, this.etsOutputPath.copyWithNewSegment('components'), this.codegenNoticeLines, '../../ts');
23
- const nativeModuleCodeGenerator = new NativeModuleCodeGenerator_1.NativeModuleCodeGenerator(this.cppOutputPath, this.etsOutputPath.copyWithNewSegment('turboModules'), this.codegenNoticeLines, '../../ts');
24
- const generatorBySpecType = {
22
+ };
23
+ UberGeneratorV1.prototype.generate = function (uberSchema) {
24
+ var fileContentByPath = new Map();
25
+ var isRNOHModulePath = this.etsOutputPath.getValue().endsWith("".concat(RNOH_OHOS_NAME, "/generated").replace(/\//g, path_1.default.sep));
26
+ var componentCodeGenerator = new ArkTSComponentCodeGeneratorArkTS_1.ArkTSComponentCodeGeneratorArkTS(this.cppOutputPath, this.etsOutputPath.copyWithNewSegment('components'), this.codegenNoticeLines, isRNOHModulePath ? '../../ts' : "".concat(RNOH_OHOS_NAME, "/ts"));
27
+ var nativeModuleCodeGenerator = new NativeModuleCodeGenerator_1.NativeModuleCodeGenerator(this.cppOutputPath, this.etsOutputPath.copyWithNewSegment('turboModules'), this.codegenNoticeLines, isRNOHModulePath ? '../../ts' : "".concat(RNOH_OHOS_NAME, "/ts"));
28
+ var generatorBySpecType = {
25
29
  Component: componentCodeGenerator,
26
30
  NativeModule: nativeModuleCodeGenerator,
27
31
  };
28
- for (const [_fileName, specSchema] of uberSchema
32
+ for (var _i = 0, _a = uberSchema
29
33
  .getSpecSchemaByFilenameMap()
30
- .entries()) {
34
+ .entries(); _i < _a.length; _i++) {
35
+ var _b = _a[_i], _fileName = _b[0], specSchema = _b[1];
31
36
  if (!(specSchema.type in generatorBySpecType)) {
32
37
  throw new core_1.CodegenError({
33
- whatHappened: `Could not find a code generator for a specification of type '${specSchema.type}'`,
38
+ whatHappened: "Could not find a code generator for a specification of type '".concat(specSchema.type, "'"),
34
39
  unexpected: true,
35
40
  });
36
41
  }
37
42
  generatorBySpecType[specSchema.type]
38
43
  .generate(specSchema)
39
- .forEach((fileContent, filePath) => {
44
+ .forEach(function (fileContent, filePath) {
40
45
  fileContentByPath.set(filePath, fileContent);
41
46
  });
42
47
  }
@@ -45,6 +50,7 @@ class UberGeneratorV1 {
45
50
  turboModules: nativeModuleCodeGenerator.getGlueCodeData(),
46
51
  };
47
52
  return fileContentByPath;
48
- }
49
- }
53
+ };
54
+ return UberGeneratorV1;
55
+ }());
50
56
  exports.UberGeneratorV1 = UberGeneratorV1;
@@ -1,71 +1,79 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UberGeneratorV2 = void 0;
4
- const CppComponentCodeGenerator_1 = require("./CppComponentCodeGenerator");
5
- const NativeModuleCodeGenerator_1 = require("./NativeModuleCodeGenerator");
6
- const SharedComponentCodeGenerator_1 = require("./SharedComponentCodeGenerator");
4
+ var path_1 = require("path");
5
+ var CppComponentCodeGenerator_1 = require("./CppComponentCodeGenerator");
6
+ var NativeModuleCodeGenerator_1 = require("./NativeModuleCodeGenerator");
7
+ var SharedComponentCodeGenerator_1 = require("./SharedComponentCodeGenerator");
8
+ // The name of rnoh OHOS module
9
+ var RNOH_OHOS_NAME = '@rnoh/react-native-openharmony';
7
10
  /**
8
11
  * Generates code for libraries built on top of RNOH's C-API architecture.
9
12
  */
10
- class UberGeneratorV2 {
11
- constructor(cppOutputPath, etsOutputPath, codegenNoticeLines) {
13
+ var UberGeneratorV2 = /** @class */ (function () {
14
+ function UberGeneratorV2(cppOutputPath, etsOutputPath, codegenNoticeLines) {
12
15
  this.cppOutputPath = cppOutputPath;
13
16
  this.etsOutputPath = etsOutputPath;
14
17
  this.codegenNoticeLines = codegenNoticeLines;
15
18
  this.glueCodeData = new Map();
16
19
  }
17
- getGlueCodeData() {
20
+ UberGeneratorV2.prototype.getGlueCodeData = function () {
18
21
  return this.glueCodeData;
19
- }
20
- generate(npmPackagesInfo) {
21
- const fileContentByPath = new Map();
22
- npmPackagesInfo.forEach(({ libraryCppName, uberSchema }) => {
23
- this.glueCodeData.set(libraryCppName, {
22
+ };
23
+ UberGeneratorV2.prototype.generate = function (npmPackagesInfo) {
24
+ var _this = this;
25
+ var fileContentByPath = new Map();
26
+ npmPackagesInfo.forEach(function (_a) {
27
+ var libraryCppName = _a.libraryCppName, uberSchema = _a.uberSchema;
28
+ _this.glueCodeData.set(libraryCppName, {
24
29
  components: [],
25
30
  turboModules: [],
26
31
  });
27
- const libraryGlueCodeData = this.glueCodeData.get(libraryCppName);
28
- const libraryCppOutput = this.cppOutputPath.copyWithNewSegment(libraryCppName);
29
- const sharedComponentCodeGenerator = new SharedComponentCodeGenerator_1.SharedComponentCodeGenerator((filename) => {
32
+ var libraryGlueCodeData = _this.glueCodeData.get(libraryCppName);
33
+ var libraryCppOutput = _this.cppOutputPath.copyWithNewSegment(libraryCppName);
34
+ var sharedComponentCodeGenerator = new SharedComponentCodeGenerator_1.SharedComponentCodeGenerator(function (filename) {
30
35
  return libraryCppOutput.copyWithNewSegment('react', 'renderer', 'components', libraryCppName, filename);
31
36
  });
32
- const cppComponentCodeGenerator = new CppComponentCodeGenerator_1.CppComponentCodeGenerator((filename) => {
37
+ var cppComponentCodeGenerator = new CppComponentCodeGenerator_1.CppComponentCodeGenerator(function (filename) {
33
38
  return libraryCppOutput.copyWithNewSegment('RNOH', 'generated', 'components', filename);
34
- }, this.codegenNoticeLines);
39
+ }, _this.codegenNoticeLines);
35
40
  cppComponentCodeGenerator
36
- .generate({ libraryCppName, uberSchema })
37
- .forEach((fileContent, path) => {
41
+ .generate({ libraryCppName: libraryCppName, uberSchema: uberSchema })
42
+ .forEach(function (fileContent, path) {
38
43
  fileContentByPath.set(path, fileContent);
39
44
  });
40
45
  cppComponentCodeGenerator
41
46
  .getGlueCodeData()
42
- .forEach((componentGlueCodeData) => {
47
+ .forEach(function (componentGlueCodeData) {
43
48
  libraryGlueCodeData.components.push(componentGlueCodeData);
44
49
  });
45
50
  sharedComponentCodeGenerator
46
- .generate({ libraryCppName, uberSchema })
47
- .forEach((fileContent, path) => {
51
+ .generate({ libraryCppName: libraryCppName, uberSchema: uberSchema })
52
+ .forEach(function (fileContent, path) {
48
53
  fileContentByPath.set(path, fileContent);
49
54
  });
50
- for (const [_fileName, specSchema] of uberSchema
55
+ for (var _i = 0, _b = uberSchema
51
56
  .getSpecSchemaByFilenameMap()
52
- .entries()) {
57
+ .entries(); _i < _b.length; _i++) {
58
+ var _c = _b[_i], _fileName = _c[0], specSchema = _c[1];
53
59
  if (specSchema.type === 'NativeModule') {
54
- const nativeModuleCodeGenerator = new NativeModuleCodeGenerator_1.NativeModuleCodeGenerator(libraryCppOutput.copyWithNewSegment('RNOH', 'generated', 'turbo_modules'), this.etsOutputPath.copyWithNewSegment('turboModules'), this.codegenNoticeLines, '../../ts');
60
+ var isRNOHModulePath = _this.etsOutputPath.getValue().endsWith("".concat(RNOH_OHOS_NAME, "/generated").replace(/\//g, path_1.default.sep));
61
+ var nativeModuleCodeGenerator = new NativeModuleCodeGenerator_1.NativeModuleCodeGenerator(libraryCppOutput.copyWithNewSegment('RNOH', 'generated', 'turbo_modules'), _this.etsOutputPath.copyWithNewSegment('turboModules'), _this.codegenNoticeLines, isRNOHModulePath ? '../../ts' : "".concat(RNOH_OHOS_NAME, "/ts"));
55
62
  nativeModuleCodeGenerator
56
63
  .generate(specSchema)
57
- .forEach((fileContent, filePath) => {
64
+ .forEach(function (fileContent, filePath) {
58
65
  fileContentByPath.set(filePath, fileContent);
59
66
  });
60
67
  nativeModuleCodeGenerator
61
68
  .getGlueCodeData()
62
- .forEach((turboModuleGlueCodeData) => {
69
+ .forEach(function (turboModuleGlueCodeData) {
63
70
  libraryGlueCodeData.turboModules.push(turboModuleGlueCodeData);
64
71
  });
65
72
  }
66
73
  }
67
74
  });
68
75
  return fileContentByPath;
69
- }
70
- }
76
+ };
77
+ return UberGeneratorV2;
78
+ }());
71
79
  exports.UberGeneratorV2 = UberGeneratorV2;