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

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 (65) hide show
  1. package/README.md +11 -11
  2. package/dist/assetResolver.js +74 -77
  3. package/dist/autolinking/Autolinking.js +179 -179
  4. package/dist/autolinking/JSON5Writer.js +61 -0
  5. package/dist/codegen/core/CodegenError.js +3 -23
  6. package/dist/codegen/core/EventUtils.js +3 -3
  7. package/dist/codegen/core/TypeAnnotationToTS.js +24 -28
  8. package/dist/codegen/core/UberSchema.js +57 -96
  9. package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +28 -41
  10. package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +27 -34
  11. package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +25 -33
  12. package/dist/codegen/generators/CppComponentCodeGenerator.js +23 -28
  13. package/dist/codegen/generators/LibGlueCodeGenerator.js +26 -29
  14. package/dist/codegen/generators/NativeModuleCodeGenerator.js +25 -30
  15. package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
  16. package/dist/codegen/generators/UberGeneratorV1.js +24 -23
  17. package/dist/codegen/generators/UberGeneratorV2.js +34 -35
  18. package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +50 -24
  19. package/dist/codegen/templates/BasePackageHTemplate.js +120 -21
  20. package/dist/codegen/templates/ComponentDescriptorHTemplate.js +53 -8
  21. package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +75 -27
  22. package/dist/codegen/templates/ComponentUtilsTSTemplate.js +162 -29
  23. package/dist/codegen/templates/IndexTSTemplate.js +37 -17
  24. package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +119 -24
  25. package/dist/codegen/templates/TurboModuleCppTemplate.js +38 -15
  26. package/dist/codegen/templates/TurboModuleHTemplate.js +32 -11
  27. package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +52 -19
  28. package/dist/commands/bundle-harmony.js +65 -138
  29. package/dist/commands/codegen-harmony.js +105 -165
  30. package/dist/commands/codegen-lib-harmony.js +76 -116
  31. package/dist/commands/create-metro-host-constants.js +18 -47
  32. package/dist/commands/init.js +537 -961
  33. package/dist/commands/link-harmony.js +33 -71
  34. package/dist/commands/pack-harmony.js +47 -108
  35. package/dist/commands/run-harmony.js +372 -518
  36. package/dist/commands/unpack-harmony.js +105 -198
  37. package/dist/commands/verify-package-harmony.js +54 -108
  38. package/dist/core/AbsolutePath.js +31 -47
  39. package/dist/core/CodegenConfig.js +24 -22
  40. package/dist/core/DescriptiveError.js +18 -37
  41. package/dist/core/FileSystem.js +14 -18
  42. package/dist/core/OHPackageJSON5.js +17 -23
  43. package/dist/core/PackageJSON.js +26 -42
  44. package/dist/core/ProjectDependenciesManager.js +40 -92
  45. package/dist/core/ValidationError.js +2 -22
  46. package/dist/core/fs.js +9 -6
  47. package/dist/index.js +1 -1
  48. package/dist/io/CliExecutor.js +46 -98
  49. package/dist/io/Logger.js +40 -46
  50. package/dist/io/RealFS.js +35 -88
  51. package/dist/io/TarGz.js +11 -8
  52. package/dist/io/__fixtures__.js +79 -141
  53. package/dist/io/fsUtils.js +13 -12
  54. package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +19 -47
  55. package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +13 -41
  56. package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +8 -38
  57. package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +22 -54
  58. package/dist/package-verifier/verify-package.js +55 -132
  59. package/dist/simulator/LaunchSimulator.js +224 -301
  60. package/harmony/rnoh-hvigor-plugin-0.3.0.tgz +0 -0
  61. package/jest.config.js +12 -12
  62. package/package.json +79 -78
  63. package/react-native.config.js +17 -17
  64. package/tsconfig.build.json +6 -6
  65. package/tsconfig.json +2 -2
@@ -5,42 +5,137 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
7
7
  */
8
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
9
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
10
- if (ar || !(i in from)) {
11
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
12
- ar[i] = from[i];
13
- }
14
- }
15
- return to.concat(ar || Array.prototype.slice.call(from));
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
10
  };
17
11
  Object.defineProperty(exports, "__esModule", { value: true });
18
12
  exports.RNOHGeneratedPackageHTemplate = void 0;
19
- var mustache_1 = require("mustache");
20
- var TEMPLATE = "\n/**\n * This code was generated by \"react-native codegen-harmony\"\n *\n * Do not edit this file as changes may cause incorrect behavior and will be\n * lost once the code is regenerated.\n *\n * @generatorVersion: 1\n */\n\n#pragma once\n\n#include \"RNOH/Package.h\"\n#include \"RNOH/ArkTSTurboModule.h\"\n{{#turboModules}}\n#include \"generated/{{name}}.h\"\n{{/turboModules}}\n{{#components}}\n#include \"generated/{{name}}ComponentDescriptor.h\"\n{{/components}}\n{{#components}}\n#include \"generated/{{name}}JSIBinder.h\"\n{{/components}}\n\nnamespace rnoh {\n\nclass RNOHGeneratedPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {\n public:\n SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {\n {{#turboModules}}\n if (name == \"{{name}}\") {\n return std::make_shared<{{name}}>(ctx, name);\n }\n {{/turboModules}}\n return nullptr;\n };\n};\n\nclass GeneratedEventEmitRequestHandler : public EventEmitRequestHandler {\n public:\n void handleEvent(Context const &ctx) override {\n auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);\n auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag);\n\n if (eventEmitter == nullptr) {\n return;\n }\n\n std::vector<std::string> supportedComponentNames = {\n {{#arkTSComponents}}\n \"{{name}}\",\n {{/arkTSComponents}}\n };\n\n std::vector<std::string> supportedEventNames = {\n {{#supportedEvents}}\n \"{{name}}\",\n {{/supportedEvents}}\n };\n\n if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() &&\n std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {\n eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));\n } \n }\n};\n\nclass RNOHGeneratedPackage : public Package {\n public:\n RNOHGeneratedPackage(Package::Context ctx) : Package(ctx){};\n\n std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {\n return std::make_unique<RNOHGeneratedPackageTurboModuleFactoryDelegate>();\n }\n\n std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {\n return {\n {{#components}}\n facebook::react::concreteComponentDescriptorProvider<facebook::react::{{name}}ComponentDescriptor>(),\n {{/components}}\n };\n }\n\n ComponentJSIBinderByString createComponentJSIBinderByName() override {\n return {\n {{#components}}\n {\"{{name}}\", std::make_shared<{{name}}JSIBinder>()},\n {{/components}}\n };\n };\n\n EventEmitRequestHandlers createEventEmitRequestHandlers() override {\n return {\n std::make_shared<GeneratedEventEmitRequestHandler>(),\n };\n }\n};\n\n} // namespace rnoh\n";
21
- var RNOHGeneratedPackageHTemplate = /** @class */ (function () {
22
- function RNOHGeneratedPackageHTemplate() {
13
+ const mustache_1 = __importDefault(require("mustache"));
14
+ const TEMPLATE = `
15
+ /**
16
+ * This code was generated by "react-native codegen-harmony"
17
+ *
18
+ * Do not edit this file as changes may cause incorrect behavior and will be
19
+ * lost once the code is regenerated.
20
+ *
21
+ * @generatorVersion: 1
22
+ */
23
+
24
+ #pragma once
25
+
26
+ #include "RNOH/Package.h"
27
+ #include "RNOH/ArkTSTurboModule.h"
28
+ {{#turboModules}}
29
+ #include "generated/{{name}}.h"
30
+ {{/turboModules}}
31
+ {{#components}}
32
+ #include "generated/{{name}}ComponentDescriptor.h"
33
+ {{/components}}
34
+ {{#components}}
35
+ #include "generated/{{name}}JSIBinder.h"
36
+ {{/components}}
37
+
38
+ namespace rnoh {
39
+
40
+ class RNOHGeneratedPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
41
+ public:
42
+ SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
43
+ {{#turboModules}}
44
+ if (name == "{{name}}") {
45
+ return std::make_shared<{{name}}>(ctx, name);
46
+ }
47
+ {{/turboModules}}
48
+ return nullptr;
49
+ };
50
+ };
51
+
52
+ class GeneratedEventEmitRequestHandler : public EventEmitRequestHandler {
53
+ public:
54
+ void handleEvent(Context const &ctx) override {
55
+ auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
56
+ auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag);
57
+
58
+ if (eventEmitter == nullptr) {
59
+ return;
60
+ }
61
+
62
+ std::vector<std::string> supportedComponentNames = {
63
+ {{#arkTSComponents}}
64
+ "{{name}}",
65
+ {{/arkTSComponents}}
66
+ };
67
+
68
+ std::vector<std::string> supportedEventNames = {
69
+ {{#supportedEvents}}
70
+ "{{name}}",
71
+ {{/supportedEvents}}
72
+ };
73
+
74
+ if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() &&
75
+ std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
76
+ eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
77
+ }
78
+ }
79
+ };
80
+
81
+ class RNOHGeneratedPackage : public Package {
82
+ public:
83
+ RNOHGeneratedPackage(Package::Context ctx) : Package(ctx){};
84
+
85
+ std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
86
+ return std::make_unique<RNOHGeneratedPackageTurboModuleFactoryDelegate>();
87
+ }
88
+
89
+ std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
90
+ return {
91
+ {{#components}}
92
+ facebook::react::concreteComponentDescriptorProvider<facebook::react::{{name}}ComponentDescriptor>(),
93
+ {{/components}}
94
+ };
95
+ }
96
+
97
+ ComponentJSIBinderByString createComponentJSIBinderByName() override {
98
+ return {
99
+ {{#components}}
100
+ {"{{name}}", std::make_shared<{{name}}JSIBinder>()},
101
+ {{/components}}
102
+ };
103
+ };
104
+
105
+ EventEmitRequestHandlers createEventEmitRequestHandlers() override {
106
+ return {
107
+ std::make_shared<GeneratedEventEmitRequestHandler>(),
108
+ };
109
+ }
110
+ };
111
+
112
+ } // namespace rnoh
113
+ `;
114
+ class RNOHGeneratedPackageHTemplate {
115
+ constructor() {
23
116
  this.turboModules = [];
24
117
  this.components = [];
25
118
  this.supportedEventNames = [];
26
119
  }
27
- RNOHGeneratedPackageHTemplate.prototype.addTurboModule = function (turboModule) {
120
+ addTurboModule(turboModule) {
28
121
  this.turboModules.push(turboModule);
29
- };
30
- RNOHGeneratedPackageHTemplate.prototype.addComponent = function (component) {
122
+ }
123
+ addComponent(component) {
31
124
  this.components.push(component);
32
- this.supportedEventNames = __spreadArray(__spreadArray([], this.supportedEventNames, true), component.supportedEventNames, true);
33
- };
34
- RNOHGeneratedPackageHTemplate.prototype.build = function () {
125
+ this.supportedEventNames = [
126
+ ...this.supportedEventNames,
127
+ ...component.supportedEventNames,
128
+ ];
129
+ }
130
+ build() {
35
131
  return mustache_1.default.render(TEMPLATE.trimStart(), {
36
132
  turboModules: this.turboModules,
37
133
  components: this.components,
38
- arkTSComponents: this.components.filter(function (component) { return component.isArkTSComponent; }),
39
- supportedEvents: this.supportedEventNames.map(function (eventName) { return ({
134
+ arkTSComponents: this.components.filter((component) => component.isArkTSComponent),
135
+ supportedEvents: this.supportedEventNames.map((eventName) => ({
40
136
  name: eventName,
41
- }); }),
137
+ })),
42
138
  });
43
- };
44
- return RNOHGeneratedPackageHTemplate;
45
- }());
139
+ }
140
+ }
46
141
  exports.RNOHGeneratedPackageHTemplate = RNOHGeneratedPackageHTemplate;
@@ -5,32 +5,55 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
7
7
  */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  exports.TurboModuleCppTemplate = void 0;
10
- var mustache_1 = require("mustache");
11
- var TEMPLATE = "\n/**\n{{#codegenNoticeLines}}\n * {{{line}}}\n{{/codegenNoticeLines}}\n */\n\n#include \"{{className}}.h\"\n\nnamespace rnoh {\nusing namespace facebook;\n\n{{className}}::{{className}}(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) {\n methodMap_ = {\n {{#methods}}\n ARK_{{asyncMarker}}METHOD_METADATA({{name}}, {{argsCount}}),\n {{/methods}}\n };\n}\n\n} // namespace rnoh\n";
12
- var TurboModuleCppTemplate = /** @class */ (function () {
13
- function TurboModuleCppTemplate(name, codegenNoticeLines) {
13
+ const mustache_1 = __importDefault(require("mustache"));
14
+ const TEMPLATE = `
15
+ /**
16
+ {{#codegenNoticeLines}}
17
+ * {{{line}}}
18
+ {{/codegenNoticeLines}}
19
+ */
20
+
21
+ #include "{{className}}.h"
22
+
23
+ namespace rnoh {
24
+ using namespace facebook;
25
+
26
+ {{className}}::{{className}}(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) {
27
+ methodMap_ = {
28
+ {{#methods}}
29
+ ARK_{{asyncMarker}}METHOD_METADATA({{name}}, {{argsCount}}),
30
+ {{/methods}}
31
+ };
32
+ }
33
+
34
+ } // namespace rnoh
35
+ `;
36
+ class TurboModuleCppTemplate {
37
+ constructor(name, codegenNoticeLines) {
14
38
  this.name = name;
15
39
  this.codegenNoticeLines = codegenNoticeLines;
16
40
  this.methods = [];
17
41
  }
18
- TurboModuleCppTemplate.prototype.addMethod = function (method) {
42
+ addMethod(method) {
19
43
  this.methods.push(method);
20
- };
21
- TurboModuleCppTemplate.prototype.build = function () {
44
+ }
45
+ build() {
22
46
  return mustache_1.default.render(TEMPLATE.trimStart(), {
23
- codegenNoticeLines: this.codegenNoticeLines.map(function (line) { return ({
24
- line: line,
25
- }); }),
47
+ codegenNoticeLines: this.codegenNoticeLines.map((line) => ({
48
+ line,
49
+ })),
26
50
  className: this.name,
27
- methods: this.methods.map(function (method) { return ({
51
+ methods: this.methods.map((method) => ({
28
52
  name: method.name,
29
53
  argsCount: method.argsCount,
30
54
  asyncMarker: method.isAsync ? 'ASYNC_' : undefined,
31
- }); }),
55
+ })),
32
56
  });
33
- };
34
- return TurboModuleCppTemplate;
35
- }());
57
+ }
58
+ }
36
59
  exports.TurboModuleCppTemplate = TurboModuleCppTemplate;
@@ -5,23 +5,44 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
7
7
  */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  exports.TurboModuleHTemplate = void 0;
10
- var mustache_1 = require("mustache");
11
- var TEMPLATE = "\n/**\n{{#codegenNoticeLines}}\n * {{{line}}}\n{{/codegenNoticeLines}}\n */\n\n#pragma once\n\n#include \"RNOH/ArkTSTurboModule.h\"\n\nnamespace rnoh {\n\nclass JSI_EXPORT {{className}} : public ArkTSTurboModule {\n public:\n {{className}}(const ArkTSTurboModule::Context ctx, const std::string name);\n};\n\n} // namespace rnoh\n";
12
- var TurboModuleHTemplate = /** @class */ (function () {
13
- function TurboModuleHTemplate(name, codegenNoticeLines) {
13
+ const mustache_1 = __importDefault(require("mustache"));
14
+ const TEMPLATE = `
15
+ /**
16
+ {{#codegenNoticeLines}}
17
+ * {{{line}}}
18
+ {{/codegenNoticeLines}}
19
+ */
20
+
21
+ #pragma once
22
+
23
+ #include "RNOH/ArkTSTurboModule.h"
24
+
25
+ namespace rnoh {
26
+
27
+ class JSI_EXPORT {{className}} : public ArkTSTurboModule {
28
+ public:
29
+ {{className}}(const ArkTSTurboModule::Context ctx, const std::string name);
30
+ };
31
+
32
+ } // namespace rnoh
33
+ `;
34
+ class TurboModuleHTemplate {
35
+ constructor(name, codegenNoticeLines) {
14
36
  this.name = name;
15
37
  this.codegenNoticeLines = codegenNoticeLines;
16
38
  }
17
- TurboModuleHTemplate.prototype.build = function () {
39
+ build() {
18
40
  return mustache_1.default.render(TEMPLATE.trimStart(), {
19
41
  className: this.name,
20
- codegenNoticeLines: this.codegenNoticeLines.map(function (line) { return ({
21
- line: line,
22
- }); }),
42
+ codegenNoticeLines: this.codegenNoticeLines.map((line) => ({
43
+ line,
44
+ })),
23
45
  });
24
- };
25
- return TurboModuleHTemplate;
26
- }());
46
+ }
47
+ }
27
48
  exports.TurboModuleHTemplate = TurboModuleHTemplate;
@@ -5,12 +5,46 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
7
7
  */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  exports.TurboModuleInterfaceTS = void 0;
10
- var mustache_1 = require("mustache");
11
- 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";
12
- var TurboModuleInterfaceTS = /** @class */ (function () {
13
- function TurboModuleInterfaceTS(name, codegenNoticeLines, rnohImport) {
13
+ const mustache_1 = __importDefault(require("mustache"));
14
+ const TEMPLATE = `
15
+ /**
16
+ {{#codegenNoticeLines}}
17
+ * {{{line}}}
18
+ {{/codegenNoticeLines}}
19
+ */
20
+
21
+ import { Tag } from "{{{rnohImport}}}"
22
+
23
+ export namespace {{name}} {
24
+ export const NAME = '{{name}}' as const
25
+
26
+ {{#enums}}
27
+ export enum {{name}} {
28
+ {{#members}}
29
+ {{name}} = {{{value}}},
30
+ {{/members}}
31
+ }
32
+
33
+ {{/enums}}
34
+ {{#aliases}}
35
+ export type {{name}} = {{{type}}}
36
+
37
+ {{/aliases}}
38
+ export interface Spec {
39
+ {{#methods}}
40
+ {{name}}({{{stringifiedArgs}}}): {{{returnType}}};
41
+
42
+ {{/methods}}
43
+ }
44
+ }
45
+ `;
46
+ class TurboModuleInterfaceTS {
47
+ constructor(name, codegenNoticeLines, rnohImport) {
14
48
  this.name = name;
15
49
  this.codegenNoticeLines = codegenNoticeLines;
16
50
  this.rnohImport = rnohImport;
@@ -18,31 +52,30 @@ var TurboModuleInterfaceTS = /** @class */ (function () {
18
52
  this.aliases = [];
19
53
  this.enumModels = [];
20
54
  }
21
- TurboModuleInterfaceTS.prototype.addAlias = function (alias) {
55
+ addAlias(alias) {
22
56
  this.aliases.push(alias);
23
- };
24
- TurboModuleInterfaceTS.prototype.addEnum = function (enumModel) {
57
+ }
58
+ addEnum(enumModel) {
25
59
  this.enumModels.push(enumModel);
26
- };
27
- TurboModuleInterfaceTS.prototype.addMethod = function (method) {
60
+ }
61
+ addMethod(method) {
28
62
  this.methods.push(method);
29
- };
30
- TurboModuleInterfaceTS.prototype.build = function () {
63
+ }
64
+ build() {
31
65
  return mustache_1.default.render(TEMPLATE.trimStart(), {
32
- codegenNoticeLines: this.codegenNoticeLines.map(function (line) { return ({
33
- line: line,
34
- }); }),
66
+ codegenNoticeLines: this.codegenNoticeLines.map((line) => ({
67
+ line,
68
+ })),
35
69
  name: this.name,
36
70
  aliases: this.aliases,
37
71
  enums: this.enumModels,
38
72
  rnohImport: this.rnohImport,
39
- methods: this.methods.map(function (method) { return ({
73
+ methods: this.methods.map((method) => ({
40
74
  name: method.name,
41
75
  stringifiedArgs: method.stringifiedArgs,
42
76
  returnType: method.returnType,
43
- }); }),
77
+ })),
44
78
  });
45
- };
46
- return TurboModuleInterfaceTS;
47
- }());
79
+ }
80
+ }
48
81
  exports.TurboModuleInterfaceTS = TurboModuleInterfaceTS;
@@ -5,17 +5,6 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
7
7
  */
8
- var __assign = (this && this.__assign) || function () {
9
- __assign = Object.assign || function(t) {
10
- for (var s, i = 1, n = arguments.length; i < n; i++) {
11
- s = arguments[i];
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
13
- t[p] = s[p];
14
- }
15
- return t;
16
- };
17
- return __assign.apply(this, arguments);
18
- };
19
8
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
20
9
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
21
10
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -25,44 +14,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
25
14
  step((generator = generator.apply(thisArg, _arguments || [])).next());
26
15
  });
27
16
  };
28
- var __generator = (this && this.__generator) || function (thisArg, body) {
29
- 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);
30
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
31
- function verb(n) { return function (v) { return step([n, v]); }; }
32
- function step(op) {
33
- if (f) throw new TypeError("Generator is already executing.");
34
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
35
- 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;
36
- if (y = 0, t) op = [op[0] & 2, t.value];
37
- switch (op[0]) {
38
- case 0: case 1: t = op; break;
39
- case 4: _.label++; return { value: op[1], done: false };
40
- case 5: _.label++; y = op[1]; op = [0]; continue;
41
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
42
- default:
43
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
44
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
45
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
46
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
47
- if (t[2]) _.ops.pop();
48
- _.trys.pop(); continue;
49
- }
50
- op = body.call(thisArg, _);
51
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
52
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
53
- }
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
54
19
  };
55
20
  Object.defineProperty(exports, "__esModule", { value: true });
56
21
  exports.commandBundleHarmony = void 0;
57
- var fs_1 = require("fs");
58
- var fs_extra_1 = require("fs-extra");
59
- var metro_1 = require("metro");
60
- var Server_1 = require("metro/src/Server");
61
- var path_1 = require("path");
62
- var assetResolver_1 = require("../assetResolver");
63
- var io_1 = require("../io");
64
- var ARK_RESOURCE_PATH = './harmony/entry/src/main/resources/rawfile';
65
- var ASSETS_DEFAULT_DEST_PATH = './harmony/entry/src/main/resources/rawfile/assets';
22
+ const fs_1 = __importDefault(require("fs"));
23
+ const fs_extra_1 = __importDefault(require("fs-extra"));
24
+ const metro_1 = __importDefault(require("metro"));
25
+ const Server_1 = __importDefault(require("metro/src/Server"));
26
+ const path_1 = __importDefault(require("path"));
27
+ const assetResolver_1 = require("../assetResolver");
28
+ const io_1 = require("../io");
29
+ const ENABLE_DEBUG_LOG = process.env.RNOH_BUNDLE_DEBUG === 'true';
30
+ function debugLog(message) {
31
+ if (ENABLE_DEBUG_LOG) {
32
+ const timestamp = new Date().toISOString().replace('T', ' ').substring(0, 23);
33
+ console.log(`[${timestamp}] ${message}`);
34
+ }
35
+ }
36
+ const ARK_RESOURCE_PATH = './harmony/entry/src/main/resources/rawfile';
37
+ const ASSETS_DEFAULT_DEST_PATH = './harmony/entry/src/main/resources/rawfile/assets';
66
38
  exports.commandBundleHarmony = {
67
39
  name: 'bundle-harmony',
68
40
  description: 'Creates JS bundle, creates a special cpp header containing the JS code, copies assets directory to the project.',
@@ -70,7 +42,7 @@ exports.commandBundleHarmony = {
70
42
  {
71
43
  name: '--dev [boolean]',
72
44
  description: 'If false, warnings are disabled and the bundle is minified',
73
- parse: function (val) { return val !== 'false'; },
45
+ parse: (val) => val !== 'false',
74
46
  default: true,
75
47
  },
76
48
  {
@@ -99,109 +71,64 @@ exports.commandBundleHarmony = {
99
71
  {
100
72
  name: '--minify [boolean]',
101
73
  description: 'Allows overriding whether bundle is minified',
102
- parse: function (val) { return val !== 'false'; },
74
+ parse: (val) => val !== 'false',
103
75
  },
104
76
  ],
105
- func: function (argv, config, args) { return __awaiter(void 0, void 0, void 0, function () {
106
- var logger, buildOptions, metroConfig, bundle, assets;
107
- return __generator(this, function (_a) {
108
- switch (_a.label) {
109
- case 0:
110
- logger = new io_1.Logger();
111
- buildOptions = {
112
- entry: args.entryFile,
113
- platform: 'harmony',
114
- minify: args.minify !== undefined ? args.minify : !args.dev,
115
- dev: args.dev,
116
- sourceMap: args.sourcemapOutput,
117
- sourceMapUrl: args.sourcemapOutput,
118
- };
119
- return [4 /*yield*/, loadMetroConfig(args.config)];
120
- case 1:
121
- metroConfig = _a.sent();
122
- return [4 /*yield*/, createBundle(metroConfig, buildOptions)];
123
- case 2:
124
- bundle = _a.sent();
125
- return [4 /*yield*/, saveBundle(bundle, args.bundleOutput, args.sourcemapOutput)];
126
- case 3:
127
- _a.sent();
128
- return [4 /*yield*/, retrieveAssetsData(metroConfig, buildOptions)];
129
- case 4:
130
- assets = _a.sent();
131
- (0, assetResolver_1.copyAssets)(logger, assets, args.assetsDest);
132
- return [2 /*return*/];
133
- }
134
- });
135
- }); },
77
+ func: (argv, config, args) => __awaiter(void 0, void 0, void 0, function* () {
78
+ const logger = new io_1.Logger();
79
+ debugLog('Starting bundle-harmony process...');
80
+ const buildOptions = {
81
+ entry: args.entryFile,
82
+ platform: 'harmony',
83
+ minify: args.minify !== undefined ? args.minify : !args.dev,
84
+ dev: args.dev,
85
+ sourceMap: args.sourcemapOutput,
86
+ sourceMapUrl: args.sourcemapOutput,
87
+ };
88
+ const metroConfig = yield loadMetroConfig(args.config);
89
+ debugLog('Creating bundle...');
90
+ const bundle = yield createBundle(metroConfig, buildOptions);
91
+ yield saveBundle(bundle, args.bundleOutput, args.sourcemapOutput);
92
+ const assets = yield retrieveAssetsData(metroConfig, buildOptions);
93
+ debugLog('Copying assets...');
94
+ yield (0, assetResolver_1.copyAssets)(logger, assets, args.assetsDest);
95
+ debugLog('Assets copy completed, cleaning up...');
96
+ debugLog('Bundle process finished, exiting');
97
+ }),
136
98
  };
137
99
  function loadMetroConfig(configPath) {
138
- return __awaiter(this, void 0, void 0, function () {
139
- var _a;
140
- return __generator(this, function (_b) {
141
- switch (_b.label) {
142
- case 0:
143
- if (!configPath) return [3 /*break*/, 2];
144
- return [4 /*yield*/, metro_1.default.loadConfig({ config: configPath })];
145
- case 1:
146
- _a = _b.sent();
147
- return [3 /*break*/, 4];
148
- case 2: return [4 /*yield*/, metro_1.default.loadConfig()];
149
- case 3:
150
- _a = _b.sent();
151
- _b.label = 4;
152
- case 4: return [2 /*return*/, _a];
153
- }
154
- });
100
+ return __awaiter(this, void 0, void 0, function* () {
101
+ return configPath
102
+ ? yield metro_1.default.loadConfig({ config: configPath })
103
+ : yield metro_1.default.loadConfig();
155
104
  });
156
105
  }
157
106
  function createBundle(metroConfig, buildOptions) {
158
- return __awaiter(this, void 0, void 0, function () {
159
- return __generator(this, function (_a) {
160
- switch (_a.label) {
161
- case 0: return [4 /*yield*/, metro_1.default.runBuild(metroConfig, buildOptions)];
162
- case 1:
163
- // casting needed as Metro.runBuild returns Promise<{code: string, map: string}>
164
- // despite being typed as Promise<void>
165
- return [2 /*return*/, (_a.sent())];
166
- }
167
- });
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ // casting needed as Metro.runBuild returns Promise<{code: string, map: string}>
109
+ // despite being typed as Promise<void>
110
+ return (yield metro_1.default.runBuild(metroConfig, buildOptions));
168
111
  });
169
112
  }
170
113
  function saveBundle(bundle, bundleOutput, sourceMapOutput) {
171
- return __awaiter(this, void 0, void 0, function () {
172
- return __generator(this, function (_a) {
173
- switch (_a.label) {
174
- case 0: return [4 /*yield*/, fs_extra_1.default.ensureDir(path_1.default.dirname(bundleOutput))];
175
- case 1:
176
- _a.sent();
177
- fs_1.default.writeFileSync(bundleOutput, bundle.code);
178
- console.log("[CREATED] ".concat(bundleOutput));
179
- if (sourceMapOutput) {
180
- fs_1.default.writeFileSync(sourceMapOutput, bundle.map);
181
- console.log("[CREATED] ".concat(sourceMapOutput));
182
- }
183
- return [2 /*return*/];
184
- }
185
- });
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ yield fs_extra_1.default.ensureDir(path_1.default.dirname(bundleOutput));
116
+ fs_1.default.writeFileSync(bundleOutput, bundle.code);
117
+ console.log(`[CREATED] ${bundleOutput}`);
118
+ if (sourceMapOutput) {
119
+ fs_1.default.writeFileSync(sourceMapOutput, bundle.map);
120
+ console.log(`[CREATED] ${sourceMapOutput}`);
121
+ }
186
122
  });
187
123
  }
188
124
  function retrieveAssetsData(metroConfig, buildOptions) {
189
- return __awaiter(this, void 0, void 0, function () {
190
- var metroServer;
191
- return __generator(this, function (_a) {
192
- switch (_a.label) {
193
- case 0:
194
- metroServer = new Server_1.default(metroConfig);
195
- _a.label = 1;
196
- case 1:
197
- _a.trys.push([1, , 3, 4]);
198
- return [4 /*yield*/, metroServer.getAssets(__assign(__assign(__assign({}, Server_1.default.DEFAULT_BUNDLE_OPTIONS), buildOptions), { entryFile: buildOptions.entry }))];
199
- case 2: return [2 /*return*/, _a.sent()];
200
- case 3:
201
- metroServer.end();
202
- return [7 /*endfinally*/];
203
- case 4: return [2 /*return*/];
204
- }
205
- });
125
+ return __awaiter(this, void 0, void 0, function* () {
126
+ const metroServer = new Server_1.default(metroConfig);
127
+ try {
128
+ return yield metroServer.getAssets(Object.assign(Object.assign(Object.assign({}, Server_1.default.DEFAULT_BUNDLE_OPTIONS), buildOptions), { entryFile: buildOptions.entry }));
129
+ }
130
+ finally {
131
+ metroServer.end();
132
+ }
206
133
  });
207
134
  }