@react-native-oh/react-native-harmony-cli 0.77.22 → 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 (200) 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 +518 -374
  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 +301 -217
  64. package/package.json +2 -11
  65. package/scripts/sync-hvigor.js +27 -0
  66. package/src/autolinking/Autolinking.ts +1 -1
  67. package/src/codegen/generators/UberGeneratorV1.ts +7 -2
  68. package/src/codegen/generators/UberGeneratorV2.ts +6 -1
  69. package/src/commands/codegen-harmony.ts +17 -7
  70. package/src/commands/run-harmony.ts +0 -2
  71. package/src/simulator/LaunchSimulator.ts +9 -2
  72. package/dist/init/templates/harmony/AppScope/app.json5 +0 -10
  73. package/dist/init/templates/harmony/AppScope/resources/base/element/string.json +0 -8
  74. package/dist/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  75. package/dist/init/templates/harmony/build-profile.json5 +0 -36
  76. package/dist/init/templates/harmony/codelinter.json +0 -32
  77. package/dist/init/templates/harmony/entry/build-profile.json5 +0 -18
  78. package/dist/init/templates/harmony/entry/gitignore +0 -7
  79. package/dist/init/templates/harmony/entry/hvigorfile.ts +0 -13
  80. package/dist/init/templates/harmony/entry/oh-package.json5 +0 -9
  81. package/dist/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +0 -27
  82. package/dist/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +0 -13
  83. package/dist/init/templates/harmony/entry/src/main/cpp/gitignore +0 -4
  84. package/dist/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +0 -8
  85. package/dist/init/templates/harmony/entry/src/main/ets/codegen/gitignore +0 -2
  86. package/dist/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +0 -11
  87. package/dist/init/templates/harmony/entry/src/main/ets/gitignore +0 -1
  88. package/dist/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
  89. package/dist/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +0 -16
  90. package/dist/init/templates/harmony/entry/src/main/module.json5 +0 -65
  91. package/dist/init/templates/harmony/entry/src/main/resources/base/element/color.json +0 -8
  92. package/dist/init/templates/harmony/entry/src/main/resources/base/element/string.json +0 -16
  93. package/dist/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
  94. package/dist/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
  95. package/dist/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +0 -7
  96. package/dist/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
  97. package/dist/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +0 -5
  98. package/dist/init/templates/harmony/entry/src/main/resources/gitignore +0 -1
  99. package/dist/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +0 -2
  100. package/dist/init/templates/harmony/entry/src/ohosTest/module.json5 +0 -13
  101. package/dist/init/templates/harmony/gitignore +0 -16
  102. package/dist/init/templates/harmony/hvigor/hvigor-config.json5 +0 -22
  103. package/dist/init/templates/harmony/hvigorfile.ts +0 -7
  104. package/harmony/rnoh-hvigor-plugin-0.77.22.tgz +0 -0
  105. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/02febc14 +0 -0
  106. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0429e5b7 +0 -0
  107. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/05339e68 +0 -0
  108. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/070be2fe +0 -0
  109. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/07851ff1 +0 -0
  110. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/12e10c06 +0 -0
  111. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/12e1d696 +0 -0
  112. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/14950087 +0 -0
  113. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/15e87372 +0 -0
  114. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/19e6ecbe +0 -0
  115. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1aac0ac4 +0 -0
  116. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1b8db102 +0 -0
  117. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1c181646 +0 -0
  118. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/203e747c +0 -0
  119. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/21ba4c08 +0 -0
  120. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/259939e5 +0 -0
  121. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/288ba98c +0 -0
  122. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2a45461c +0 -0
  123. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2d773091 +0 -0
  124. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2eda89fc +0 -0
  125. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2f584eca +0 -0
  126. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/35b495ca +0 -0
  127. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/36478aed +0 -0
  128. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3844e772 +0 -0
  129. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3ee777f4 +0 -0
  130. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/471ac436 +0 -0
  131. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4a91abcc +0 -0
  132. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4d1a5094 +0 -0
  133. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4d3ef38f +0 -0
  134. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4daf5855 +0 -0
  135. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4ef0389f +0 -0
  136. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4f72da28 +0 -0
  137. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/59d3e924 +0 -0
  138. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5a8edfaa +0 -0
  139. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5d28a510 +0 -0
  140. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/61a6391d +0 -0
  141. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/65921a14 +0 -0
  142. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6624e7fc +0 -0
  143. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/66d28144 +0 -0
  144. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6aceb8d2 +0 -0
  145. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/702393d3 +0 -0
  146. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/714f932b +0 -0
  147. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/73f9d4a6 +0 -0
  148. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/78d3adae +0 -0
  149. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7b6564b8 +0 -0
  150. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7c7c3e6e +0 -0
  151. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7cbc9b6a +0 -0
  152. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7dd579e0 +0 -0
  153. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7e0b7d06 +0 -0
  154. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7e153eef +0 -0
  155. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7ee84fd7 +0 -0
  156. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7f5146a4 +0 -0
  157. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/844e633a +0 -0
  158. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8a1af22c +0 -0
  159. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/90a1680d +0 -0
  160. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a15fb79a +0 -0
  161. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ac288a8a +0 -0
  162. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ad7a66b4 +0 -0
  163. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/aee8805e +0 -0
  164. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b0487ec8 +0 -0
  165. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b10e16d2 +0 -0
  166. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b32d42ac +0 -0
  167. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b7d8f35c +0 -0
  168. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b96748af +0 -0
  169. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/bedb2fea +0 -0
  170. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c01ad640 +0 -0
  171. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c0472cf5 +0 -0
  172. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c102ed0f +0 -0
  173. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c1a91819 +0 -0
  174. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c243857a +0 -0
  175. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c407792f +0 -0
  176. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c4459bee +0 -0
  177. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c72a4dcd +0 -0
  178. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c83537a9 +0 -0
  179. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c88f7498 +0 -0
  180. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c8d04070 +0 -0
  181. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cc44d6f1 +0 -0
  182. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d4d913f6 +0 -0
  183. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/da97f202 +0 -0
  184. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/dc965522 +0 -0
  185. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/dff6f700 +0 -0
  186. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e507c001 +0 -0
  187. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e52f3f2d +0 -0
  188. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e5c3890d +0 -0
  189. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e720074d +0 -0
  190. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e7656fa7 +0 -0
  191. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e80bcaac +0 -0
  192. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e8e7900e +0 -0
  193. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ee8993f9 +0 -0
  194. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ef8cf362 +0 -0
  195. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f1405b1d +0 -0
  196. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f20f0e0d +0 -0
  197. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f2586978 +0 -0
  198. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f53cd716 +0 -0
  199. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/fe71f6bb +0 -0
  200. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/febfc20b +0 -0
@@ -1,44 +1,10 @@
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.TurboModuleInterfaceTS = void 0;
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) {
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) {
42
8
  this.name = name;
43
9
  this.codegenNoticeLines = codegenNoticeLines;
44
10
  this.rnohImport = rnohImport;
@@ -46,30 +12,31 @@ class TurboModuleInterfaceTS {
46
12
  this.aliases = [];
47
13
  this.enumModels = [];
48
14
  }
49
- addAlias(alias) {
15
+ TurboModuleInterfaceTS.prototype.addAlias = function (alias) {
50
16
  this.aliases.push(alias);
51
- }
52
- addEnum(enumModel) {
17
+ };
18
+ TurboModuleInterfaceTS.prototype.addEnum = function (enumModel) {
53
19
  this.enumModels.push(enumModel);
54
- }
55
- addMethod(method) {
20
+ };
21
+ TurboModuleInterfaceTS.prototype.addMethod = function (method) {
56
22
  this.methods.push(method);
57
- }
58
- build() {
23
+ };
24
+ TurboModuleInterfaceTS.prototype.build = function () {
59
25
  return mustache_1.default.render(TEMPLATE.trimStart(), {
60
- codegenNoticeLines: this.codegenNoticeLines.map((line) => ({
61
- line,
62
- })),
26
+ codegenNoticeLines: this.codegenNoticeLines.map(function (line) { return ({
27
+ line: line,
28
+ }); }),
63
29
  name: this.name,
64
30
  aliases: this.aliases,
65
31
  enums: this.enumModels,
66
32
  rnohImport: this.rnohImport,
67
- methods: this.methods.map((method) => ({
33
+ methods: this.methods.map(function (method) { return ({
68
34
  name: method.name,
69
35
  stringifiedArgs: method.stringifiedArgs,
70
36
  returnType: method.returnType,
71
- })),
37
+ }); }),
72
38
  });
73
- }
74
- }
39
+ };
40
+ return TurboModuleInterfaceTS;
41
+ }());
75
42
  exports.TurboModuleInterfaceTS = TurboModuleInterfaceTS;
@@ -1,4 +1,15 @@
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
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,30 +19,63 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
19
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
20
  });
10
21
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
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));
13
57
  };
14
58
  Object.defineProperty(exports, "__esModule", { value: true });
15
59
  exports.commandBundleHarmony = void 0;
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 = {
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 = {
28
72
  darwin: path_1.default.normalize('osx-bin/hermesc'),
29
73
  linux: path_1.default.normalize('linux64-bin/hermesc'),
30
74
  win32: path_1.default.normalize('win64-bin/hermesc.exe'),
31
75
  };
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');
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');
35
79
  exports.commandBundleHarmony = {
36
80
  name: 'bundle-harmony',
37
81
  description: 'Creates JS bundle, creates a special cpp header containing the JS code, copies assets directory to the project.',
@@ -39,14 +83,14 @@ exports.commandBundleHarmony = {
39
83
  {
40
84
  name: '--dev [boolean]',
41
85
  description: 'If false, warnings are disabled and the bundle is minified',
42
- parse: (val) => val !== 'false',
86
+ parse: function (val) { return val !== 'false'; },
43
87
  default: true,
44
88
  },
45
89
  {
46
90
  name: '--entry-file <path>',
47
91
  description: 'Path to the root JS file, either absolute or relative to JS root',
48
92
  default: 'index.js',
49
- parse: (val) => path_1.default.normalize(val),
93
+ parse: function (val) { return path_1.default.normalize(val); },
50
94
  },
51
95
  {
52
96
  name: '--reset-cache',
@@ -56,20 +100,20 @@ exports.commandBundleHarmony = {
56
100
  {
57
101
  name: '--config <path>',
58
102
  description: 'Path to the Metro configuration file',
59
- parse: (val) => path_1.default.normalize(val),
103
+ parse: function (val) { return path_1.default.normalize(val); },
60
104
  },
61
105
  {
62
106
  name: '--bundle-output <path>',
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),
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); },
65
109
  },
66
110
  {
67
111
  name: '--js-engine <string>',
68
112
  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.',
69
113
  default: 'any',
70
- parse: (val) => {
114
+ parse: function (val) {
71
115
  if (val !== 'any' && val !== 'hermes') {
72
- throw new Error(`Only "any" and "hermes" are supported as JavaScript engines, but "${val}" was provided`);
116
+ throw new Error("Only \"any\" and \"hermes\" are supported as JavaScript engines, but \"".concat(val, "\" was provided"));
73
117
  }
74
118
  return val;
75
119
  },
@@ -78,140 +122,199 @@ exports.commandBundleHarmony = {
78
122
  name: '--assets-dest <path>',
79
123
  description: 'Directory name where to store assets referenced in the bundle',
80
124
  default: ASSETS_DEFAULT_DEST_PATH,
81
- parse: (val) => path_1.default.normalize(val),
125
+ parse: function (val) { return path_1.default.normalize(val); },
82
126
  },
83
127
  {
84
128
  name: '--sourcemap-output <path>',
85
129
  description: 'File name where to store the resulting source map, ex. /tmp/groups.map',
86
- parse: (val) => path_1.default.normalize(val),
130
+ parse: function (val) { return path_1.default.normalize(val); },
87
131
  },
88
132
  {
89
133
  name: '--minify [boolean]',
90
134
  description: 'Allows overriding whether bundle is minified',
91
- parse: (val) => val !== 'false',
135
+ parse: function (val) { return val !== 'false'; },
92
136
  },
93
137
  {
94
138
  name: '--hermesc-dir <path>',
95
139
  description: 'Path to hermesc directory. Relevant when --js-engine set to "hermes".',
96
140
  default: HERMESC_PATH_PREFIX,
97
- parse: (val) => path_1.default.normalize(val),
141
+ parse: function (val) { return path_1.default.normalize(val); },
98
142
  },
99
143
  {
100
144
  name: '--hermesc-options <string...>',
101
145
  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".',
102
- parse: (val, prev) => (prev ? [...prev, val] : [val]),
146
+ parse: function (val, prev) { return (prev ? __spreadArray(__spreadArray([], prev, true), [val], false) : [val]); },
103
147
  },
104
148
  ],
105
- func: (argv, config, args) => __awaiter(void 0, void 0, void 0, function* () {
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;
106
151
  var _a;
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);
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*/];
133
217
  }
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
- }),
218
+ });
219
+ }); },
150
220
  };
151
221
  function loadMetroConfig(options) {
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);
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
+ });
157
233
  });
158
234
  }
159
235
  function createBundle(metroConfig, buildOptions) {
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));
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
+ });
164
246
  });
165
247
  }
166
248
  function saveHbcBundle(logger, bundleCode, bundleOutput, hermescPath, hermescOptions) {
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',
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
+ }
190
283
  });
191
- node_fs_1.default.unlinkSync(tmpBundlePath);
192
- logger.info((s) => `Created ${hbcFilePath}`);
193
284
  });
194
285
  }
195
286
  function saveJSBundle(logger, bundle, bundleOutput) {
196
- return __awaiter(this, void 0, void 0, function* () {
197
- node_fs_1.default.writeFileSync(bundleOutput, bundle.code);
198
- logger.info((s) => `Created ${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
+ });
199
293
  });
200
294
  }
201
295
  function maybeSaveSourceMap(logger, bundle, sourceMapOutput) {
202
296
  if (sourceMapOutput) {
203
297
  node_fs_1.default.writeFileSync(sourceMapOutput, bundle.map);
204
- logger.info((s) => `Created ${sourceMapOutput}`);
298
+ logger.info(function (s) { return "Created ".concat(sourceMapOutput); });
205
299
  }
206
300
  }
207
301
  function retrieveAssetsData(metroConfig, buildOptions) {
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
- }
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
+ });
216
319
  });
217
320
  }