@react-native-oh/react-native-harmony-cli 0.77.33 → 0.77.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 (192) hide show
  1. package/dist/assetResolver.js +43 -74
  2. package/dist/autolinking/Autolinking.js +178 -179
  3. package/dist/codegen/core/CodegenError.js +3 -23
  4. package/dist/codegen/core/EventUtils.js +3 -3
  5. package/dist/codegen/core/TypeAnnotationToTS.js +24 -28
  6. package/dist/codegen/core/UberSchema.js +55 -97
  7. package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +28 -41
  8. package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +27 -34
  9. package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +25 -33
  10. package/dist/codegen/generators/CppComponentCodeGenerator.js +23 -28
  11. package/dist/codegen/generators/LibGlueCodeGenerator.js +26 -29
  12. package/dist/codegen/generators/NativeModuleCodeGenerator.js +25 -30
  13. package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
  14. package/dist/codegen/generators/UberGeneratorV1.js +24 -23
  15. package/dist/codegen/generators/UberGeneratorV2.js +34 -35
  16. package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +50 -24
  17. package/dist/codegen/templates/BasePackageHTemplate.js +120 -21
  18. package/dist/codegen/templates/ComponentDescriptorHTemplate.js +54 -8
  19. package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +75 -27
  20. package/dist/codegen/templates/ComponentUtilsTSTemplate.js +162 -29
  21. package/dist/codegen/templates/IndexTSTemplate.js +37 -17
  22. package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +119 -24
  23. package/dist/codegen/templates/TurboModuleCppTemplate.js +38 -15
  24. package/dist/codegen/templates/TurboModuleHTemplate.js +32 -11
  25. package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +52 -19
  26. package/dist/commands/bundle-harmony.js +118 -221
  27. package/dist/commands/clean-harmony.js +58 -63
  28. package/dist/commands/codegen-harmony.js +105 -165
  29. package/dist/commands/codegen-lib-harmony.js +76 -116
  30. package/dist/commands/init-harmony.js +151 -196
  31. package/dist/commands/init.js +537 -961
  32. package/dist/commands/link-harmony.js +35 -82
  33. package/dist/commands/run-harmony.js +372 -518
  34. package/dist/commands/verify-package-harmony.js +54 -117
  35. package/dist/core/AbsolutePath.js +33 -49
  36. package/dist/core/CodegenConfig.js +24 -22
  37. package/dist/core/DescriptiveError.js +18 -37
  38. package/dist/core/FileSystem.js +14 -18
  39. package/dist/core/OHPackageJSON5.js +17 -23
  40. package/dist/core/PackageJSON.js +26 -42
  41. package/dist/core/ProjectDependenciesManager.js +40 -92
  42. package/dist/core/ValidationError.js +2 -22
  43. package/dist/core/fs.js +10 -7
  44. package/dist/index.js +1 -1
  45. package/dist/init/templates/AppScopeAppJSON5Template.js +21 -8
  46. package/dist/init/templates/AppScopeStringVarTemplate.js +19 -8
  47. package/dist/init/templates/EntryIndexTemplate.js +56 -8
  48. package/dist/init/templates/EntryStringVarTemplate.js +27 -8
  49. package/dist/init/templates/HvigorConfigJson5Template.js +33 -8
  50. package/dist/init/templates/MetroConfigTemplate.js +38 -8
  51. package/dist/init/templates/OhPackageJson5Template.js +28 -8
  52. package/dist/init/templates/harmony/AppScope/app.json5 +10 -0
  53. package/dist/init/templates/harmony/AppScope/resources/base/element/string.json +8 -0
  54. package/dist/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  55. package/dist/init/templates/harmony/build-profile.json5 +36 -0
  56. package/dist/init/templates/harmony/codelinter.json +32 -0
  57. package/dist/init/templates/harmony/entry/build-profile.json5 +18 -0
  58. package/dist/init/templates/harmony/entry/gitignore +7 -0
  59. package/dist/init/templates/harmony/entry/hvigorfile.ts +13 -0
  60. package/dist/init/templates/harmony/entry/oh-package.json5 +9 -0
  61. package/dist/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +27 -0
  62. package/dist/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +13 -0
  63. package/dist/init/templates/harmony/entry/src/main/cpp/gitignore +4 -0
  64. package/dist/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +8 -0
  65. package/dist/init/templates/harmony/entry/src/main/ets/codegen/gitignore +2 -0
  66. package/dist/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +11 -0
  67. package/dist/init/templates/harmony/entry/src/main/ets/gitignore +1 -0
  68. package/dist/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
  69. package/dist/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +16 -0
  70. package/dist/init/templates/harmony/entry/src/main/module.json5 +65 -0
  71. package/dist/init/templates/harmony/entry/src/main/resources/base/element/color.json +8 -0
  72. package/dist/init/templates/harmony/entry/src/main/resources/base/element/string.json +16 -0
  73. package/dist/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
  74. package/dist/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
  75. package/dist/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +7 -0
  76. package/dist/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
  77. package/dist/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
  78. package/dist/init/templates/harmony/entry/src/main/resources/gitignore +1 -0
  79. package/dist/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +2 -0
  80. package/dist/init/templates/harmony/entry/src/ohosTest/module.json5 +13 -0
  81. package/dist/init/templates/harmony/gitignore +16 -0
  82. package/dist/init/templates/harmony/hvigor/hvigor-config.json5 +22 -0
  83. package/dist/init/templates/harmony/hvigorfile.ts +7 -0
  84. package/dist/io/CliExecutor.js +46 -98
  85. package/dist/io/Logger.js +40 -46
  86. package/dist/io/RealFS.js +43 -100
  87. package/dist/io/TarGz.js +11 -8
  88. package/dist/io/__fixtures__.js +79 -141
  89. package/dist/io/fsUtils.js +13 -12
  90. package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +19 -47
  91. package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +13 -41
  92. package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +8 -38
  93. package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +22 -54
  94. package/dist/package-verifier/verify-package.js +56 -133
  95. package/dist/simulator/LaunchSimulator.js +224 -301
  96. package/harmony/rnoh-hvigor-plugin-0.77.40.tgz +0 -0
  97. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0271b9dd +0 -0
  98. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/07ba0208 +0 -0
  99. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/082dd09d +0 -0
  100. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0a9e1b0b +0 -0
  101. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0c3d528a +0 -0
  102. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1014d3ff +0 -0
  103. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1184678c +0 -0
  104. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/12621366 +0 -0
  105. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/126d3e66 +0 -0
  106. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/19262852 +0 -0
  107. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/203fac53 +0 -0
  108. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/237b660a +0 -0
  109. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2528002d +0 -0
  110. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2587d041 +0 -0
  111. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2893bd11 +0 -0
  112. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2af6ff9d +0 -0
  113. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2bf31f33 +0 -0
  114. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/333648cc +0 -0
  115. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/386f6df0 +0 -0
  116. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3b8c270e +0 -0
  117. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3bcc34ba +0 -0
  118. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/444808bd +0 -0
  119. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/44a775e2 +0 -0
  120. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/46da3ccd +0 -0
  121. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/51f80e35 +0 -0
  122. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5203a2ca +0 -0
  123. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/52795646 +0 -0
  124. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/577f8208 +0 -0
  125. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5c2aafe7 +0 -0
  126. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5c69bcfe +0 -0
  127. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/62695b92 +0 -0
  128. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/62698102 +0 -0
  129. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6411ab00 +0 -0
  130. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6569ba92 +0 -0
  131. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/65e5133c +0 -0
  132. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/66029655 +0 -0
  133. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/69e85d0d +0 -0
  134. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6afcb99e +0 -0
  135. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6de07367 +0 -0
  136. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/72498307 +0 -0
  137. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7babd1de +0 -0
  138. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7fe56d21 +0 -0
  139. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/810cbd72 +0 -0
  140. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/812386d2 +0 -0
  141. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8448897d +0 -0
  142. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/84ab0a41 +0 -0
  143. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/853825e2 +0 -0
  144. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/862ad93a +0 -0
  145. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/86b14da6 +0 -0
  146. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/87f0fe62 +0 -0
  147. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/88ee8f74 +0 -0
  148. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8c5237c9 +0 -0
  149. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8c725800 +0 -0
  150. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8e83cbe1 +0 -0
  151. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8f4085b9 +0 -0
  152. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/931f0b2e +0 -0
  153. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/940c8f92 +0 -0
  154. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/968191a3 +0 -0
  155. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/970780c0 +0 -0
  156. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/98bc4394 +0 -0
  157. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/99a3b0b0 +0 -0
  158. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9c0ffa6b +0 -0
  159. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9d9b42c2 +0 -0
  160. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a04266ef +0 -0
  161. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a18f78c5 +0 -0
  162. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a642fb0e +0 -0
  163. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a97edf40 +0 -0
  164. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/aa672a20 +0 -0
  165. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ae25c61a +0 -0
  166. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b2bebae6 +0 -0
  167. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ba492422 +0 -0
  168. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/bd3e6c21 +0 -0
  169. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/be9e564e +0 -0
  170. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c342b18e +0 -0
  171. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c3993e7e +0 -0
  172. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c52ffd54 +0 -0
  173. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c7079ad4 +0 -0
  174. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c8eb01c1 +0 -0
  175. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/caee5d30 +0 -0
  176. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cf039161 +0 -0
  177. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d0377c40 +0 -0
  178. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d262bc85 +0 -0
  179. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d287cb5c +0 -0
  180. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d64bff57 +0 -0
  181. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d716a608 +0 -0
  182. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d751012b +0 -0
  183. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e0873711 +0 -0
  184. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e1fcf77b +0 -0
  185. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e8548d8a +0 -0
  186. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/eaedd71d +0 -0
  187. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/eca0019e +0 -0
  188. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f7189953 +0 -0
  189. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f75cb201 +0 -0
  190. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f888164b +0 -0
  191. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/fdb9eb5a +0 -0
  192. package/package.json +1 -1
@@ -1,10 +1,44 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.TurboModuleInterfaceTS = void 0;
4
- var mustache_1 = require("mustache");
5
- var TEMPLATE = "\n/**\n{{#codegenNoticeLines}}\n * {{{line}}}\n{{/codegenNoticeLines}}\n */\n\nimport { Tag } from \"{{{rnohImport}}}\"\n\nexport namespace {{name}} {\n export const NAME = '{{name}}' as const\n\n {{#enums}}\n export enum {{name}} {\n {{#members}}\n {{name}} = {{{value}}},\n {{/members}}\n }\n\n {{/enums}}\n {{#aliases}}\n export type {{name}} = {{{type}}}\n \n {{/aliases}}\n export interface Spec {\n {{#methods}}\n {{name}}({{{stringifiedArgs}}}): {{{returnType}}};\n \n {{/methods}}\n }\n}\n";
6
- var TurboModuleInterfaceTS = /** @class */ (function () {
7
- function TurboModuleInterfaceTS(name, codegenNoticeLines, rnohImport) {
7
+ const mustache_1 = __importDefault(require("mustache"));
8
+ const TEMPLATE = `
9
+ /**
10
+ {{#codegenNoticeLines}}
11
+ * {{{line}}}
12
+ {{/codegenNoticeLines}}
13
+ */
14
+
15
+ import { Tag } from "{{{rnohImport}}}"
16
+
17
+ export namespace {{name}} {
18
+ export const NAME = '{{name}}' as const
19
+
20
+ {{#enums}}
21
+ export enum {{name}} {
22
+ {{#members}}
23
+ {{name}} = {{{value}}},
24
+ {{/members}}
25
+ }
26
+
27
+ {{/enums}}
28
+ {{#aliases}}
29
+ export type {{name}} = {{{type}}}
30
+
31
+ {{/aliases}}
32
+ export interface Spec {
33
+ {{#methods}}
34
+ {{name}}({{{stringifiedArgs}}}): {{{returnType}}};
35
+
36
+ {{/methods}}
37
+ }
38
+ }
39
+ `;
40
+ class TurboModuleInterfaceTS {
41
+ constructor(name, codegenNoticeLines, rnohImport) {
8
42
  this.name = name;
9
43
  this.codegenNoticeLines = codegenNoticeLines;
10
44
  this.rnohImport = rnohImport;
@@ -12,31 +46,30 @@ var TurboModuleInterfaceTS = /** @class */ (function () {
12
46
  this.aliases = [];
13
47
  this.enumModels = [];
14
48
  }
15
- TurboModuleInterfaceTS.prototype.addAlias = function (alias) {
49
+ addAlias(alias) {
16
50
  this.aliases.push(alias);
17
- };
18
- TurboModuleInterfaceTS.prototype.addEnum = function (enumModel) {
51
+ }
52
+ addEnum(enumModel) {
19
53
  this.enumModels.push(enumModel);
20
- };
21
- TurboModuleInterfaceTS.prototype.addMethod = function (method) {
54
+ }
55
+ addMethod(method) {
22
56
  this.methods.push(method);
23
- };
24
- TurboModuleInterfaceTS.prototype.build = function () {
57
+ }
58
+ build() {
25
59
  return mustache_1.default.render(TEMPLATE.trimStart(), {
26
- codegenNoticeLines: this.codegenNoticeLines.map(function (line) { return ({
27
- line: line,
28
- }); }),
60
+ codegenNoticeLines: this.codegenNoticeLines.map((line) => ({
61
+ line,
62
+ })),
29
63
  name: this.name,
30
64
  aliases: this.aliases,
31
65
  enums: this.enumModels,
32
66
  rnohImport: this.rnohImport,
33
- methods: this.methods.map(function (method) { return ({
67
+ methods: this.methods.map((method) => ({
34
68
  name: method.name,
35
69
  stringifiedArgs: method.stringifiedArgs,
36
70
  returnType: method.returnType,
37
- }); }),
71
+ })),
38
72
  });
39
- };
40
- return TurboModuleInterfaceTS;
41
- }());
73
+ }
74
+ }
42
75
  exports.TurboModuleInterfaceTS = TurboModuleInterfaceTS;
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -19,63 +8,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
20
9
  });
21
10
  };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- 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);
24
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- 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;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
50
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
51
- if (ar || !(i in from)) {
52
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
53
- ar[i] = from[i];
54
- }
55
- }
56
- return to.concat(ar || Array.prototype.slice.call(from));
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
57
13
  };
58
14
  Object.defineProperty(exports, "__esModule", { value: true });
59
15
  exports.commandBundleHarmony = void 0;
60
- var node_fs_1 = require("node:fs");
61
- var os_1 = require("os");
62
- var fs_extra_1 = require("fs-extra");
63
- var metro_1 = require("metro");
64
- var Server_1 = require("metro/src/Server");
65
- var path_1 = require("path");
66
- var assetResolver_1 = require("../assetResolver");
67
- var child_process_1 = require("child_process");
68
- var io_1 = require("../io");
69
- var core_1 = require("../core");
70
- var node_crypto_1 = require("node:crypto");
71
- var HERMESC_BIN_PATH = {
16
+ const node_fs_1 = __importDefault(require("node:fs"));
17
+ const os_1 = __importDefault(require("os"));
18
+ const fs_extra_1 = __importDefault(require("fs-extra"));
19
+ const metro_1 = __importDefault(require("metro"));
20
+ const Server_1 = __importDefault(require("metro/src/Server"));
21
+ const path_1 = __importDefault(require("path"));
22
+ const assetResolver_1 = require("../assetResolver");
23
+ const child_process_1 = require("child_process");
24
+ const io_1 = require("../io");
25
+ const core_1 = require("../core");
26
+ const node_crypto_1 = require("node:crypto");
27
+ const HERMESC_BIN_PATH = {
72
28
  darwin: path_1.default.normalize('osx-bin/hermesc'),
73
29
  linux: path_1.default.normalize('linux64-bin/hermesc'),
74
30
  win32: path_1.default.normalize('win64-bin/hermesc.exe'),
75
31
  };
76
- var HERMESC_PATH_PREFIX = path_1.default.normalize('./node_modules/react-native/sdks/hermesc/');
77
- var HARMONY_RESOURCE_PATH = path_1.default.normalize('./harmony/entry/src/main/resources/rawfile');
78
- var ASSETS_DEFAULT_DEST_PATH = path_1.default.normalize('./harmony/entry/src/main/resources/rawfile/assets');
32
+ const HERMESC_PATH_PREFIX = path_1.default.normalize('./node_modules/react-native/sdks/hermesc/');
33
+ const HARMONY_RESOURCE_PATH = path_1.default.normalize('./harmony/entry/src/main/resources/rawfile');
34
+ const ASSETS_DEFAULT_DEST_PATH = path_1.default.normalize('./harmony/entry/src/main/resources/rawfile/assets');
79
35
  exports.commandBundleHarmony = {
80
36
  name: 'bundle-harmony',
81
37
  description: 'Creates JS bundle, creates a special cpp header containing the JS code, copies assets directory to the project.',
@@ -83,14 +39,14 @@ exports.commandBundleHarmony = {
83
39
  {
84
40
  name: '--dev [boolean]',
85
41
  description: 'If false, warnings are disabled and the bundle is minified',
86
- parse: function (val) { return val !== 'false'; },
42
+ parse: (val) => val !== 'false',
87
43
  default: true,
88
44
  },
89
45
  {
90
46
  name: '--entry-file <path>',
91
47
  description: 'Path to the root JS file, either absolute or relative to JS root',
92
48
  default: 'index.js',
93
- parse: function (val) { return path_1.default.normalize(val); },
49
+ parse: (val) => path_1.default.normalize(val),
94
50
  },
95
51
  {
96
52
  name: '--reset-cache',
@@ -100,20 +56,20 @@ exports.commandBundleHarmony = {
100
56
  {
101
57
  name: '--config <path>',
102
58
  description: 'Path to the Metro configuration file',
103
- parse: function (val) { return path_1.default.normalize(val); },
59
+ parse: (val) => path_1.default.normalize(val),
104
60
  },
105
61
  {
106
62
  name: '--bundle-output <path>',
107
- description: "File path where to store the resulting bundle (default: \"".concat(HARMONY_RESOURCE_PATH).concat(path_1.default.sep, "bundle.harmony.js\")"),
108
- parse: function (val) { return path_1.default.normalize(val); },
63
+ description: `File path where to store the resulting bundle (default: "${HARMONY_RESOURCE_PATH}${path_1.default.sep}bundle.harmony.js")`,
64
+ parse: (val) => path_1.default.normalize(val),
109
65
  },
110
66
  {
111
67
  name: '--js-engine <string>',
112
68
  description: 'JavaScript engine used to run the bundle. Supported engines: "hermes" and "any" (default: "any"). Setting this option to "hermes" will generate a HBC bundle instead of a JS bundle.',
113
69
  default: 'any',
114
- parse: function (val) {
70
+ parse: (val) => {
115
71
  if (val !== 'any' && val !== 'hermes') {
116
- throw new Error("Only \"any\" and \"hermes\" are supported as JavaScript engines, but \"".concat(val, "\" was provided"));
72
+ throw new Error(`Only "any" and "hermes" are supported as JavaScript engines, but "${val}" was provided`);
117
73
  }
118
74
  return val;
119
75
  },
@@ -122,199 +78,140 @@ exports.commandBundleHarmony = {
122
78
  name: '--assets-dest <path>',
123
79
  description: 'Directory name where to store assets referenced in the bundle',
124
80
  default: ASSETS_DEFAULT_DEST_PATH,
125
- parse: function (val) { return path_1.default.normalize(val); },
81
+ parse: (val) => path_1.default.normalize(val),
126
82
  },
127
83
  {
128
84
  name: '--sourcemap-output <path>',
129
85
  description: 'File name where to store the resulting source map, ex. /tmp/groups.map',
130
- parse: function (val) { return path_1.default.normalize(val); },
86
+ parse: (val) => path_1.default.normalize(val),
131
87
  },
132
88
  {
133
89
  name: '--minify [boolean]',
134
90
  description: 'Allows overriding whether bundle is minified',
135
- parse: function (val) { return val !== 'false'; },
91
+ parse: (val) => val !== 'false',
136
92
  },
137
93
  {
138
94
  name: '--hermesc-dir <path>',
139
95
  description: 'Path to hermesc directory. Relevant when --js-engine set to "hermes".',
140
96
  default: HERMESC_PATH_PREFIX,
141
- parse: function (val) { return path_1.default.normalize(val); },
97
+ parse: (val) => path_1.default.normalize(val),
142
98
  },
143
99
  {
144
100
  name: '--hermesc-options <string...>',
145
101
  description: 'Additional options to pass to hermesc when generating HBC bundle. Example: --hermesc-options O g reuse-prop-cache. Relevant when --js-engine set to "hermes".',
146
- parse: function (val, prev) { return (prev ? __spreadArray(__spreadArray([], prev, true), [val], false) : [val]); },
102
+ parse: (val, prev) => (prev ? [...prev, val] : [val]),
147
103
  },
148
104
  ],
149
- func: function (argv, config, args) { return __awaiter(void 0, void 0, void 0, function () {
150
- var logger, defaultBundleName, bundleOutput, shouldGenerateHbcBundle, assetsDest, buildOptions, metroConfig, bundle, assets, err_1;
105
+ func: (argv, config, args) => __awaiter(void 0, void 0, void 0, function* () {
151
106
  var _a;
152
- return __generator(this, function (_b) {
153
- switch (_b.label) {
154
- case 0:
155
- logger = new io_1.Logger();
156
- _b.label = 1;
157
- case 1:
158
- _b.trys.push([1, 12, , 13]);
159
- defaultBundleName = args.jsEngine === 'hermes' ? 'hermes_bundle.hbc' : 'bundle.harmony.js';
160
- bundleOutput = (_a = args.bundleOutput) !== null && _a !== void 0 ? _a : "".concat(HARMONY_RESOURCE_PATH).concat(path_1.default.sep).concat(defaultBundleName);
161
- shouldGenerateHbcBundle = bundleOutput
162
- .toLowerCase()
163
- .endsWith('hbc');
164
- return [4 /*yield*/, fs_extra_1.default.ensureDir(path_1.default.dirname(bundleOutput))];
165
- case 2:
166
- _b.sent();
167
- assetsDest = args.assetsDest;
168
- return [4 /*yield*/, fs_extra_1.default.ensureDir(assetsDest)];
169
- case 3:
170
- _b.sent();
171
- buildOptions = {
172
- entry: args.entryFile,
173
- platform: 'harmony',
174
- minify: args.minify !== undefined ? args.minify : !args.dev,
175
- dev: args.dev,
176
- sourceMap: args.sourcemapOutput,
177
- sourceMapUrl: args.sourcemapOutput,
178
- };
179
- return [4 /*yield*/, loadMetroConfig({
180
- config: args.config,
181
- resetCache: args.resetCache,
182
- })];
183
- case 4:
184
- metroConfig = _b.sent();
185
- return [4 /*yield*/, createBundle(metroConfig, buildOptions)];
186
- case 5:
187
- bundle = _b.sent();
188
- return [4 /*yield*/, retrieveAssetsData(metroConfig, buildOptions)];
189
- case 6:
190
- assets = _b.sent();
191
- if (!shouldGenerateHbcBundle) return [3 /*break*/, 8];
192
- return [4 /*yield*/, saveHbcBundle(logger, bundle.code, bundleOutput, args.hermescDir, args.hermescOptions)];
193
- case 7:
194
- _b.sent();
195
- return [3 /*break*/, 10];
196
- case 8: return [4 /*yield*/, saveJSBundle(logger, bundle, bundleOutput)];
197
- case 9:
198
- _b.sent();
199
- _b.label = 10;
200
- case 10:
201
- maybeSaveSourceMap(logger, bundle, args.sourcemapOutput);
202
- return [4 /*yield*/, (0, assetResolver_1.copyAssets)(logger, assets, assetsDest)];
203
- case 11:
204
- _b.sent();
205
- return [3 /*break*/, 13];
206
- case 12:
207
- err_1 = _b.sent();
208
- if (err_1 instanceof core_1.DescriptiveError) {
209
- logger.descriptiveError(err_1);
210
- return [2 /*return*/];
211
- }
212
- else {
213
- throw err_1;
214
- }
215
- return [3 /*break*/, 13];
216
- case 13: return [2 /*return*/];
107
+ const logger = new io_1.Logger();
108
+ try {
109
+ const defaultBundleName = args.jsEngine === 'hermes' ? 'hermes_bundle.hbc' : 'bundle.harmony.js';
110
+ const bundleOutput = (_a = args.bundleOutput) !== null && _a !== void 0 ? _a : `${HARMONY_RESOURCE_PATH}${path_1.default.sep}${defaultBundleName}`;
111
+ const shouldGenerateHbcBundle = bundleOutput
112
+ .toLowerCase()
113
+ .endsWith('hbc');
114
+ yield fs_extra_1.default.ensureDir(path_1.default.dirname(bundleOutput));
115
+ const assetsDest = args.assetsDest;
116
+ yield fs_extra_1.default.ensureDir(assetsDest);
117
+ const buildOptions = {
118
+ entry: args.entryFile,
119
+ platform: 'harmony',
120
+ minify: args.minify !== undefined ? args.minify : !args.dev,
121
+ dev: args.dev,
122
+ sourceMap: args.sourcemapOutput,
123
+ sourceMapUrl: args.sourcemapOutput,
124
+ };
125
+ const metroConfig = yield loadMetroConfig({
126
+ config: args.config,
127
+ resetCache: args.resetCache,
128
+ });
129
+ const bundle = yield createBundle(metroConfig, buildOptions);
130
+ const assets = yield retrieveAssetsData(metroConfig, buildOptions);
131
+ if (shouldGenerateHbcBundle) {
132
+ yield saveHbcBundle(logger, bundle.code, bundleOutput, args.hermescDir, args.hermescOptions);
217
133
  }
218
- });
219
- }); },
134
+ else {
135
+ yield saveJSBundle(logger, bundle, bundleOutput);
136
+ }
137
+ maybeSaveSourceMap(logger, bundle, args.sourcemapOutput);
138
+ yield (0, assetResolver_1.copyAssets)(logger, assets, assetsDest);
139
+ }
140
+ catch (err) {
141
+ if (err instanceof core_1.DescriptiveError) {
142
+ logger.descriptiveError(err);
143
+ return;
144
+ }
145
+ else {
146
+ throw err;
147
+ }
148
+ }
149
+ }),
220
150
  };
221
151
  function loadMetroConfig(options) {
222
- return __awaiter(this, void 0, void 0, function () {
223
- return __generator(this, function (_a) {
224
- switch (_a.label) {
225
- case 0:
226
- if (!options.config) {
227
- delete options.config;
228
- }
229
- return [4 /*yield*/, metro_1.default.loadConfig(options)];
230
- case 1: return [2 /*return*/, _a.sent()];
231
- }
232
- });
152
+ return __awaiter(this, void 0, void 0, function* () {
153
+ if (!options.config) {
154
+ delete options.config;
155
+ }
156
+ return yield metro_1.default.loadConfig(options);
233
157
  });
234
158
  }
235
159
  function createBundle(metroConfig, buildOptions) {
236
- return __awaiter(this, void 0, void 0, function () {
237
- return __generator(this, function (_a) {
238
- switch (_a.label) {
239
- case 0: return [4 /*yield*/, metro_1.default.runBuild(metroConfig, buildOptions)];
240
- case 1:
241
- // casting needed as Metro.runBuild returns Promise<{code: string, map: string}>
242
- // despite being typed as Promise<void>
243
- return [2 /*return*/, (_a.sent())];
244
- }
245
- });
160
+ return __awaiter(this, void 0, void 0, function* () {
161
+ // casting needed as Metro.runBuild returns Promise<{code: string, map: string}>
162
+ // despite being typed as Promise<void>
163
+ return (yield metro_1.default.runBuild(metroConfig, buildOptions));
246
164
  });
247
165
  }
248
166
  function saveHbcBundle(logger, bundleCode, bundleOutput, hermescPath, hermescOptions) {
249
- return __awaiter(this, void 0, void 0, function () {
250
- var resolvedHermescPath, tmpBundlePath, hbcFilePath, hermescOptionsString;
251
- return __generator(this, function (_a) {
252
- switch (_a.label) {
253
- case 0:
254
- if (process.platform !== 'darwin' &&
255
- process.platform !== 'linux' &&
256
- process.platform !== 'win32') {
257
- throw new Error("Unsupported platform ".concat(process.platform, " (\u2299\uFE3F\u2299)"));
258
- }
259
- resolvedHermescPath = path_1.default.resolve(hermescPath, HERMESC_BIN_PATH[process.platform]);
260
- if (!node_fs_1.default.existsSync(resolvedHermescPath)) {
261
- throw new core_1.DescriptiveError({
262
- whatHappened: "Couldn't find hermesc at ".concat(resolvedHermescPath),
263
- whatCanUserDo: [
264
- 'Find hermesc dir and provide it by using --hermesc-dir argument. hermesc dir should be in react-native package.',
265
- ],
266
- });
267
- }
268
- tmpBundlePath = "".concat(os_1.default.tmpdir()).concat(path_1.default.sep, "b-").concat((0, node_crypto_1.randomUUID)(), ".harmony.js");
269
- return [4 /*yield*/, fs_extra_1.default.writeFile(tmpBundlePath, bundleCode)];
270
- case 1:
271
- _a.sent();
272
- hbcFilePath = bundleOutput.endsWith('.hbc')
273
- ? bundleOutput
274
- : path_1.default.join(path_1.default.dirname(bundleOutput), 'hermes_bundle.hbc');
275
- hermescOptionsString = (hermescOptions === null || hermescOptions === void 0 ? void 0 : hermescOptions.map(function (e) { return "-".concat(e); }).join(' ')) || '';
276
- (0, child_process_1.execSync)("".concat(resolvedHermescPath, " ").concat(hermescOptionsString, " --emit-binary -out ").concat(hbcFilePath, " ").concat(tmpBundlePath), {
277
- stdio: 'inherit',
278
- });
279
- node_fs_1.default.unlinkSync(tmpBundlePath);
280
- logger.info(function (s) { return "Created ".concat(hbcFilePath); });
281
- return [2 /*return*/];
282
- }
167
+ return __awaiter(this, void 0, void 0, function* () {
168
+ if (process.platform !== 'darwin' &&
169
+ process.platform !== 'linux' &&
170
+ process.platform !== 'win32') {
171
+ throw new Error(`Unsupported platform ${process.platform} (⊙︿⊙)`);
172
+ }
173
+ const resolvedHermescPath = path_1.default.resolve(hermescPath, HERMESC_BIN_PATH[process.platform]);
174
+ if (!node_fs_1.default.existsSync(resolvedHermescPath)) {
175
+ throw new core_1.DescriptiveError({
176
+ whatHappened: `Couldn't find hermesc at ${resolvedHermescPath}`,
177
+ whatCanUserDo: [
178
+ 'Find hermesc dir and provide it by using --hermesc-dir argument. hermesc dir should be in react-native package.',
179
+ ],
180
+ });
181
+ }
182
+ const tmpBundlePath = `${os_1.default.tmpdir()}${path_1.default.sep}b-${(0, node_crypto_1.randomUUID)()}.harmony.js`;
183
+ yield fs_extra_1.default.writeFile(tmpBundlePath, bundleCode);
184
+ const hbcFilePath = bundleOutput.endsWith('.hbc')
185
+ ? bundleOutput
186
+ : path_1.default.join(path_1.default.dirname(bundleOutput), 'hermes_bundle.hbc');
187
+ const hermescOptionsString = (hermescOptions === null || hermescOptions === void 0 ? void 0 : hermescOptions.map((e) => `-${e}`).join(' ')) || '';
188
+ (0, child_process_1.execSync)(`${resolvedHermescPath} ${hermescOptionsString} --emit-binary -out ${hbcFilePath} ${tmpBundlePath}`, {
189
+ stdio: 'inherit',
283
190
  });
191
+ node_fs_1.default.unlinkSync(tmpBundlePath);
192
+ logger.info((s) => `Created ${hbcFilePath}`);
284
193
  });
285
194
  }
286
195
  function saveJSBundle(logger, bundle, bundleOutput) {
287
- return __awaiter(this, void 0, void 0, function () {
288
- return __generator(this, function (_a) {
289
- node_fs_1.default.writeFileSync(bundleOutput, bundle.code);
290
- logger.info(function (s) { return "Created ".concat(bundleOutput); });
291
- return [2 /*return*/];
292
- });
196
+ return __awaiter(this, void 0, void 0, function* () {
197
+ node_fs_1.default.writeFileSync(bundleOutput, bundle.code);
198
+ logger.info((s) => `Created ${bundleOutput}`);
293
199
  });
294
200
  }
295
201
  function maybeSaveSourceMap(logger, bundle, sourceMapOutput) {
296
202
  if (sourceMapOutput) {
297
203
  node_fs_1.default.writeFileSync(sourceMapOutput, bundle.map);
298
- logger.info(function (s) { return "Created ".concat(sourceMapOutput); });
204
+ logger.info((s) => `Created ${sourceMapOutput}`);
299
205
  }
300
206
  }
301
207
  function retrieveAssetsData(metroConfig, buildOptions) {
302
- return __awaiter(this, void 0, void 0, function () {
303
- var metroServer;
304
- return __generator(this, function (_a) {
305
- switch (_a.label) {
306
- case 0:
307
- metroServer = new Server_1.default(metroConfig);
308
- _a.label = 1;
309
- case 1:
310
- _a.trys.push([1, , 3, 4]);
311
- return [4 /*yield*/, metroServer.getAssets(__assign(__assign(__assign({}, Server_1.default.DEFAULT_BUNDLE_OPTIONS), buildOptions), { entryFile: buildOptions.entry, bundleType: 'todo' }))];
312
- case 2: return [2 /*return*/, _a.sent()];
313
- case 3:
314
- metroServer.end();
315
- return [7 /*endfinally*/];
316
- case 4: return [2 /*return*/];
317
- }
318
- });
208
+ return __awaiter(this, void 0, void 0, function* () {
209
+ const metroServer = new Server_1.default(metroConfig);
210
+ try {
211
+ return yield metroServer.getAssets(Object.assign(Object.assign(Object.assign({}, Server_1.default.DEFAULT_BUNDLE_OPTIONS), buildOptions), { entryFile: buildOptions.entry, bundleType: 'todo' }));
212
+ }
213
+ finally {
214
+ metroServer.end();
215
+ }
319
216
  });
320
217
  }