@react-native-oh/react-native-harmony-cli 0.0.37 → 0.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/dist/assetResolver.js +74 -43
- package/dist/autolinking/Autolinking.js +183 -179
- package/dist/codegen/core/CodegenError.js +23 -3
- package/dist/codegen/core/EventUtils.js +3 -3
- package/dist/codegen/core/TypeAnnotationToTS.js +28 -24
- package/dist/codegen/core/UberSchema.js +96 -57
- package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +41 -28
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +34 -27
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +33 -25
- package/dist/codegen/generators/CppComponentCodeGenerator.js +28 -23
- package/dist/codegen/generators/LibGlueCodeGenerator.js +29 -26
- package/dist/codegen/generators/NativeModuleCodeGenerator.js +30 -25
- package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
- package/dist/codegen/generators/UberGeneratorV1.js +24 -18
- package/dist/codegen/generators/UberGeneratorV2.js +36 -28
- package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +24 -50
- package/dist/codegen/templates/BasePackageHTemplate.js +21 -120
- package/dist/codegen/templates/ComponentDescriptorHTemplate.js +8 -53
- package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +27 -75
- package/dist/codegen/templates/ComponentUtilsTSTemplate.js +29 -162
- package/dist/codegen/templates/IndexTSTemplate.js +17 -37
- package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +24 -119
- package/dist/codegen/templates/TurboModuleCppTemplate.js +15 -38
- package/dist/codegen/templates/TurboModuleHTemplate.js +11 -32
- package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +19 -52
- package/dist/commands/bundle-harmony.js +138 -53
- package/dist/commands/codegen-harmony.js +175 -104
- package/dist/commands/codegen-lib-harmony.js +116 -76
- package/dist/commands/create-metro-host-constants.js +47 -18
- package/dist/commands/init.js +961 -537
- package/dist/commands/link-harmony.js +71 -33
- package/dist/commands/pack-harmony.js +108 -47
- package/dist/commands/run-harmony.js +518 -374
- package/dist/commands/unpack-harmony.js +198 -105
- package/dist/commands/verify-package-harmony.js +108 -54
- package/dist/core/AbsolutePath.js +47 -31
- package/dist/core/CodegenConfig.js +22 -24
- package/dist/core/DescriptiveError.js +37 -18
- package/dist/core/FileSystem.js +18 -14
- package/dist/core/OHPackageJSON5.js +23 -17
- package/dist/core/PackageJSON.js +42 -26
- package/dist/core/ProjectDependenciesManager.js +96 -46
- package/dist/core/ValidationError.js +22 -2
- package/dist/core/fs.js +6 -9
- package/dist/index.js +1 -1
- package/dist/io/CliExecutor.js +98 -46
- package/dist/io/Logger.js +46 -40
- package/dist/io/RealFS.js +88 -35
- package/dist/io/TarGz.js +8 -11
- package/dist/io/__fixtures__.js +141 -79
- package/dist/io/fsUtils.js +12 -13
- package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +47 -19
- package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +41 -13
- package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +38 -8
- package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +54 -22
- package/dist/package-verifier/verify-package.js +132 -55
- package/dist/simulator/LaunchSimulator.js +301 -217
- package/jest.config.js +12 -12
- package/package.json +78 -70
- package/react-native.config.js +17 -17
- package/tsconfig.build.json +6 -6
- package/tsconfig.json +2 -2
- package/.prettierrc +0 -6
- package/src/assetResolver.ts +0 -134
- package/src/autolinking/Autolinking.test.ts +0 -483
- package/src/autolinking/Autolinking.ts +0 -382
- package/src/autolinking/index.ts +0 -8
- package/src/codegen/core/CodeGenerator.ts +0 -16
- package/src/codegen/core/CodegenError.ts +0 -10
- package/src/codegen/core/EventUtils.ts +0 -23
- package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -82
- package/src/codegen/core/TypeAnnotationToTS.ts +0 -195
- package/src/codegen/core/UberSchema.ts +0 -152
- package/src/codegen/core/index.ts +0 -12
- package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +0 -124
- package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +0 -128
- package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +0 -122
- package/src/codegen/generators/CppComponentCodeGenerator.ts +0 -95
- package/src/codegen/generators/LibGlueCodeGenerator.ts +0 -98
- package/src/codegen/generators/NativeModuleCodeGenerator.ts +0 -124
- package/src/codegen/generators/SharedComponentCodeGenerator.ts +0 -57
- package/src/codegen/generators/UberGeneratorV1.ts +0 -75
- package/src/codegen/generators/UberGeneratorV2.ts +0 -114
- package/src/codegen/generators/index.ts +0 -15
- package/src/codegen/index.ts +0 -9
- package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +0 -128
- package/src/codegen/templates/BasePackageHTemplate.ts +0 -159
- package/src/codegen/templates/ComponentDescriptorHTemplate.ts +0 -63
- package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +0 -121
- package/src/codegen/templates/ComponentUtilsTSTemplate.ts +0 -222
- package/src/codegen/templates/IndexTSTemplate.ts +0 -62
- package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +0 -150
- package/src/codegen/templates/TurboModuleCppTemplate.ts +0 -61
- package/src/codegen/templates/TurboModuleHTemplate.ts +0 -42
- package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +0 -101
- package/src/codegen/templates/index.ts +0 -16
- package/src/commands/bundle-harmony.ts +0 -134
- package/src/commands/codegen-harmony.ts +0 -297
- package/src/commands/codegen-lib-harmony.ts +0 -389
- package/src/commands/create-metro-host-constants.ts +0 -55
- package/src/commands/index.ts +0 -16
- package/src/commands/init.ts +0 -755
- package/src/commands/link-harmony.ts +0 -102
- package/src/commands/pack-harmony.ts +0 -128
- package/src/commands/run-harmony.ts +0 -506
- package/src/commands/types.ts +0 -21
- package/src/commands/unpack-harmony.ts +0 -238
- package/src/commands/verify-package-harmony.ts +0 -113
- package/src/core/AbsolutePath.ts +0 -66
- package/src/core/CodegenConfig.ts +0 -67
- package/src/core/DescriptiveError.ts +0 -68
- package/src/core/FileSystem.ts +0 -57
- package/src/core/OHPackageJSON5.ts +0 -30
- package/src/core/PackageJSON.ts +0 -104
- package/src/core/ProjectDependenciesManager.ts +0 -103
- package/src/core/ValidationError.ts +0 -8
- package/src/core/ValueObject.ts +0 -9
- package/src/core/fs.ts +0 -38
- package/src/core/index.ts +0 -17
- package/src/index.ts +0 -33
- package/src/io/CliExecutor.ts +0 -69
- package/src/io/Logger.ts +0 -112
- package/src/io/RealFS.ts +0 -62
- package/src/io/TarGz.ts +0 -33
- package/src/io/__fixtures__.ts +0 -139
- package/src/io/fsUtils.ts +0 -44
- package/src/io/index.ts +0 -11
- package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +0 -35
- package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +0 -31
- package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +0 -25
- package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +0 -54
- package/src/package-verifier/checks/index.ts +0 -11
- package/src/package-verifier/index.ts +0 -9
- package/src/package-verifier/types.ts +0 -19
- package/src/package-verifier/verify-package.ts +0 -123
- package/src/simulator/LaunchSimulator.ts +0 -352
- package/src/simulator/index.ts +0 -8
|
@@ -5,137 +5,42 @@
|
|
|
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
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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;
|
|
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];
|
|
60
13
|
}
|
|
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
14
|
}
|
|
15
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
79
16
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
RNOHGeneratedPackage(Package::Context ctx) : Package(ctx){};
|
|
84
|
-
|
|
85
|
-
|
|
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() {
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
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() {
|
|
116
23
|
this.turboModules = [];
|
|
117
24
|
this.components = [];
|
|
118
25
|
this.supportedEventNames = [];
|
|
119
26
|
}
|
|
120
|
-
addTurboModule(turboModule) {
|
|
27
|
+
RNOHGeneratedPackageHTemplate.prototype.addTurboModule = function (turboModule) {
|
|
121
28
|
this.turboModules.push(turboModule);
|
|
122
|
-
}
|
|
123
|
-
addComponent(component) {
|
|
29
|
+
};
|
|
30
|
+
RNOHGeneratedPackageHTemplate.prototype.addComponent = function (component) {
|
|
124
31
|
this.components.push(component);
|
|
125
|
-
this.supportedEventNames = [
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
];
|
|
129
|
-
}
|
|
130
|
-
build() {
|
|
32
|
+
this.supportedEventNames = __spreadArray(__spreadArray([], this.supportedEventNames, true), component.supportedEventNames, true);
|
|
33
|
+
};
|
|
34
|
+
RNOHGeneratedPackageHTemplate.prototype.build = function () {
|
|
131
35
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
132
36
|
turboModules: this.turboModules,
|
|
133
37
|
components: this.components,
|
|
134
|
-
arkTSComponents: this.components.filter((component)
|
|
135
|
-
supportedEvents: this.supportedEventNames.map((eventName)
|
|
38
|
+
arkTSComponents: this.components.filter(function (component) { return component.isArkTSComponent; }),
|
|
39
|
+
supportedEvents: this.supportedEventNames.map(function (eventName) { return ({
|
|
136
40
|
name: eventName,
|
|
137
|
-
})),
|
|
41
|
+
}); }),
|
|
138
42
|
});
|
|
139
|
-
}
|
|
140
|
-
|
|
43
|
+
};
|
|
44
|
+
return RNOHGeneratedPackageHTemplate;
|
|
45
|
+
}());
|
|
141
46
|
exports.RNOHGeneratedPackageHTemplate = RNOHGeneratedPackageHTemplate;
|
|
@@ -5,55 +5,32 @@
|
|
|
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
|
-
};
|
|
11
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
9
|
exports.TurboModuleCppTemplate = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
{
|
|
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) {
|
|
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) {
|
|
38
14
|
this.name = name;
|
|
39
15
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
40
16
|
this.methods = [];
|
|
41
17
|
}
|
|
42
|
-
addMethod(method) {
|
|
18
|
+
TurboModuleCppTemplate.prototype.addMethod = function (method) {
|
|
43
19
|
this.methods.push(method);
|
|
44
|
-
}
|
|
45
|
-
build() {
|
|
20
|
+
};
|
|
21
|
+
TurboModuleCppTemplate.prototype.build = function () {
|
|
46
22
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
47
|
-
codegenNoticeLines: this.codegenNoticeLines.map((line)
|
|
48
|
-
line,
|
|
49
|
-
})),
|
|
23
|
+
codegenNoticeLines: this.codegenNoticeLines.map(function (line) { return ({
|
|
24
|
+
line: line,
|
|
25
|
+
}); }),
|
|
50
26
|
className: this.name,
|
|
51
|
-
methods: this.methods.map((method)
|
|
27
|
+
methods: this.methods.map(function (method) { return ({
|
|
52
28
|
name: method.name,
|
|
53
29
|
argsCount: method.argsCount,
|
|
54
30
|
asyncMarker: method.isAsync ? 'ASYNC_' : undefined,
|
|
55
|
-
})),
|
|
31
|
+
}); }),
|
|
56
32
|
});
|
|
57
|
-
}
|
|
58
|
-
|
|
33
|
+
};
|
|
34
|
+
return TurboModuleCppTemplate;
|
|
35
|
+
}());
|
|
59
36
|
exports.TurboModuleCppTemplate = TurboModuleCppTemplate;
|
|
@@ -5,44 +5,23 @@
|
|
|
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
|
-
};
|
|
11
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
9
|
exports.TurboModuleHTemplate = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
{
|
|
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) {
|
|
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) {
|
|
36
14
|
this.name = name;
|
|
37
15
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
38
16
|
}
|
|
39
|
-
build() {
|
|
17
|
+
TurboModuleHTemplate.prototype.build = function () {
|
|
40
18
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
41
19
|
className: this.name,
|
|
42
|
-
codegenNoticeLines: this.codegenNoticeLines.map((line)
|
|
43
|
-
line,
|
|
44
|
-
})),
|
|
20
|
+
codegenNoticeLines: this.codegenNoticeLines.map(function (line) { return ({
|
|
21
|
+
line: line,
|
|
22
|
+
}); }),
|
|
45
23
|
});
|
|
46
|
-
}
|
|
47
|
-
|
|
24
|
+
};
|
|
25
|
+
return TurboModuleHTemplate;
|
|
26
|
+
}());
|
|
48
27
|
exports.TurboModuleHTemplate = TurboModuleHTemplate;
|
|
@@ -5,46 +5,12 @@
|
|
|
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
|
-
};
|
|
11
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
9
|
exports.TurboModuleInterfaceTS = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
{
|
|
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) {
|
|
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) {
|
|
48
14
|
this.name = name;
|
|
49
15
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
50
16
|
this.rnohImport = rnohImport;
|
|
@@ -52,30 +18,31 @@ class TurboModuleInterfaceTS {
|
|
|
52
18
|
this.aliases = [];
|
|
53
19
|
this.enumModels = [];
|
|
54
20
|
}
|
|
55
|
-
addAlias(alias) {
|
|
21
|
+
TurboModuleInterfaceTS.prototype.addAlias = function (alias) {
|
|
56
22
|
this.aliases.push(alias);
|
|
57
|
-
}
|
|
58
|
-
addEnum(enumModel) {
|
|
23
|
+
};
|
|
24
|
+
TurboModuleInterfaceTS.prototype.addEnum = function (enumModel) {
|
|
59
25
|
this.enumModels.push(enumModel);
|
|
60
|
-
}
|
|
61
|
-
addMethod(method) {
|
|
26
|
+
};
|
|
27
|
+
TurboModuleInterfaceTS.prototype.addMethod = function (method) {
|
|
62
28
|
this.methods.push(method);
|
|
63
|
-
}
|
|
64
|
-
build() {
|
|
29
|
+
};
|
|
30
|
+
TurboModuleInterfaceTS.prototype.build = function () {
|
|
65
31
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
66
|
-
codegenNoticeLines: this.codegenNoticeLines.map((line)
|
|
67
|
-
line,
|
|
68
|
-
})),
|
|
32
|
+
codegenNoticeLines: this.codegenNoticeLines.map(function (line) { return ({
|
|
33
|
+
line: line,
|
|
34
|
+
}); }),
|
|
69
35
|
name: this.name,
|
|
70
36
|
aliases: this.aliases,
|
|
71
37
|
enums: this.enumModels,
|
|
72
38
|
rnohImport: this.rnohImport,
|
|
73
|
-
methods: this.methods.map((method)
|
|
39
|
+
methods: this.methods.map(function (method) { return ({
|
|
74
40
|
name: method.name,
|
|
75
41
|
stringifiedArgs: method.stringifiedArgs,
|
|
76
42
|
returnType: method.returnType,
|
|
77
|
-
})),
|
|
43
|
+
}); }),
|
|
78
44
|
});
|
|
79
|
-
}
|
|
80
|
-
|
|
45
|
+
};
|
|
46
|
+
return TurboModuleInterfaceTS;
|
|
47
|
+
}());
|
|
81
48
|
exports.TurboModuleInterfaceTS = TurboModuleInterfaceTS;
|
|
@@ -5,6 +5,17 @@
|
|
|
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
|
+
};
|
|
8
19
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
20
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
21
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -14,20 +25,44 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
14
25
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
26
|
});
|
|
16
27
|
};
|
|
17
|
-
var
|
|
18
|
-
|
|
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
|
+
}
|
|
19
54
|
};
|
|
20
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
56
|
exports.commandBundleHarmony = void 0;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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';
|
|
31
66
|
exports.commandBundleHarmony = {
|
|
32
67
|
name: 'bundle-harmony',
|
|
33
68
|
description: 'Creates JS bundle, creates a special cpp header containing the JS code, copies assets directory to the project.',
|
|
@@ -35,7 +70,7 @@ exports.commandBundleHarmony = {
|
|
|
35
70
|
{
|
|
36
71
|
name: '--dev [boolean]',
|
|
37
72
|
description: 'If false, warnings are disabled and the bundle is minified',
|
|
38
|
-
parse: (val)
|
|
73
|
+
parse: function (val) { return val !== 'false'; },
|
|
39
74
|
default: true,
|
|
40
75
|
},
|
|
41
76
|
{
|
|
@@ -64,59 +99,109 @@ exports.commandBundleHarmony = {
|
|
|
64
99
|
{
|
|
65
100
|
name: '--minify [boolean]',
|
|
66
101
|
description: 'Allows overriding whether bundle is minified',
|
|
67
|
-
parse: (val)
|
|
102
|
+
parse: function (val) { return val !== 'false'; },
|
|
68
103
|
},
|
|
69
104
|
],
|
|
70
|
-
func: (argv, config, args)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
+
}); },
|
|
86
136
|
};
|
|
87
137
|
function loadMetroConfig(configPath) {
|
|
88
|
-
return __awaiter(this, void 0, void 0, function
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
+
});
|
|
92
155
|
});
|
|
93
156
|
}
|
|
94
157
|
function createBundle(metroConfig, buildOptions) {
|
|
95
|
-
return __awaiter(this, void 0, void 0, function
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
+
});
|
|
99
168
|
});
|
|
100
169
|
}
|
|
101
170
|
function saveBundle(bundle, bundleOutput, sourceMapOutput) {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
+
});
|
|
110
186
|
});
|
|
111
187
|
}
|
|
112
188
|
function retrieveAssetsData(metroConfig, buildOptions) {
|
|
113
|
-
return __awaiter(this, void 0, void 0, function
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
+
});
|
|
121
206
|
});
|
|
122
207
|
}
|