@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,112 +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.BasePackageHTemplate = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
{
|
|
17
|
-
* {{{line}}}
|
|
18
|
-
{{/codegenNoticeLines}}
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
#pragma once
|
|
22
|
-
|
|
23
|
-
{{#libraries}}
|
|
24
|
-
#include <react/renderer/components/{{name}}/ComponentDescriptors.h>
|
|
25
|
-
{{/libraries}}
|
|
26
|
-
#include "RNOH/Package.h"
|
|
27
|
-
#include "RNOH/ArkTSTurboModule.h"
|
|
28
|
-
{{#turboModules}}
|
|
29
|
-
#include "RNOH/generated/turbo_modules/{{name}}.h"
|
|
30
|
-
{{/turboModules}}
|
|
31
|
-
{{#components}}
|
|
32
|
-
#include "RNOH/generated/components/{{name}}JSIBinder.h"
|
|
33
|
-
{{/components}}
|
|
34
|
-
|
|
35
|
-
namespace rnoh {
|
|
36
|
-
|
|
37
|
-
class {{name}}TurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
|
|
38
|
-
public:
|
|
39
|
-
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
|
|
40
|
-
{{#turboModules}}
|
|
41
|
-
if (name == "{{name}}") {
|
|
42
|
-
return std::make_shared<{{name}}>(ctx, name);
|
|
43
|
-
}
|
|
44
|
-
{{/turboModules}}
|
|
45
|
-
return nullptr;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
class {{name}}EventEmitRequestHandler : public EventEmitRequestHandler {
|
|
50
|
-
public:
|
|
51
|
-
void handleEvent(Context const &ctx) override {
|
|
52
|
-
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
|
|
53
|
-
auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag);
|
|
54
|
-
|
|
55
|
-
if (eventEmitter == nullptr) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
std::vector<std::string> supportedComponentNames = {
|
|
60
|
-
{{#arkTSComponents}}
|
|
61
|
-
"{{name}}",
|
|
62
|
-
{{/arkTSComponents}}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
std::vector<std::string> supportedEventNames = {
|
|
66
|
-
{{#arkTSEvents}}
|
|
67
|
-
"{{name}}",
|
|
68
|
-
{{/arkTSEvents}}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() &&
|
|
72
|
-
std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
|
|
73
|
-
eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
class {{name}} : public Package {
|
|
80
|
-
public:
|
|
81
|
-
{{name}}(Package::Context ctx) : Package(ctx){};
|
|
82
|
-
|
|
83
|
-
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
|
|
84
|
-
return std::make_unique<{{name}}TurboModuleFactoryDelegate>();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
|
|
88
|
-
return {
|
|
89
|
-
{{#components}}
|
|
90
|
-
facebook::react::concreteComponentDescriptorProvider<facebook::react::{{name}}ComponentDescriptor>(),
|
|
91
|
-
{{/components}}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
ComponentJSIBinderByString createComponentJSIBinderByName() override {
|
|
96
|
-
return {
|
|
97
|
-
{{#components}}
|
|
98
|
-
{"{{name}}", std::make_shared<{{name}}JSIBinder>()},
|
|
99
|
-
{{/components}}
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
EventEmitRequestHandlers createEventEmitRequestHandlers() override {
|
|
104
|
-
return {
|
|
105
|
-
std::make_shared<{{name}}EventEmitRequestHandler>(),
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
} // namespace rnoh
|
|
111
|
-
`;
|
|
112
|
-
class BasePackageHTemplate {
|
|
113
|
-
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{{#libraries}}\n#include <react/renderer/components/{{name}}/ComponentDescriptors.h>\n{{/libraries}}\n#include \"RNOH/Package.h\"\n#include \"RNOH/ArkTSTurboModule.h\"\n{{#turboModules}}\n#include \"RNOH/generated/turbo_modules/{{name}}.h\"\n{{/turboModules}}\n{{#components}}\n#include \"RNOH/generated/components/{{name}}JSIBinder.h\"\n{{/components}}\n\nnamespace rnoh {\n\nclass {{name}}TurboModuleFactoryDelegate : 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 {{name}}EventEmitRequestHandler : 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 {{#arkTSEvents}}\n \"{{name}}\",\n {{/arkTSEvents}}\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\n\nclass {{name}} : public Package {\n public:\n {{name}}(Package::Context ctx) : Package(ctx){};\n\n std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {\n return std::make_unique<{{name}}TurboModuleFactoryDelegate>();\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<{{name}}EventEmitRequestHandler>(),\n };\n }\n};\n\n} // namespace rnoh\n";
|
|
12
|
+
var BasePackageHTemplate = /** @class */ (function () {
|
|
13
|
+
function BasePackageHTemplate(name, codegenNoticeLines) {
|
|
114
14
|
this.name = name;
|
|
115
15
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
116
16
|
this.turboModules = [];
|
|
@@ -118,30 +18,31 @@ class BasePackageHTemplate {
|
|
|
118
18
|
this.arkTSEvents = [];
|
|
119
19
|
this.libraryCppNames = new Set();
|
|
120
20
|
}
|
|
121
|
-
addTurboModule(turboModule) {
|
|
21
|
+
BasePackageHTemplate.prototype.addTurboModule = function (turboModule) {
|
|
122
22
|
this.turboModules.push(turboModule);
|
|
123
|
-
}
|
|
124
|
-
addComponent(component) {
|
|
23
|
+
};
|
|
24
|
+
BasePackageHTemplate.prototype.addComponent = function (component) {
|
|
125
25
|
this.components.push(component);
|
|
126
26
|
this.libraryCppNames.add(component.libraryCppName);
|
|
127
|
-
}
|
|
128
|
-
addArkTSEvent(arkTSEvent) {
|
|
27
|
+
};
|
|
28
|
+
BasePackageHTemplate.prototype.addArkTSEvent = function (arkTSEvent) {
|
|
129
29
|
this.arkTSEvents.push(arkTSEvent);
|
|
130
|
-
}
|
|
131
|
-
build() {
|
|
30
|
+
};
|
|
31
|
+
BasePackageHTemplate.prototype.build = function () {
|
|
132
32
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
133
|
-
codegenNoticeLines: this.codegenNoticeLines.map((line)
|
|
134
|
-
line,
|
|
135
|
-
})),
|
|
33
|
+
codegenNoticeLines: this.codegenNoticeLines.map(function (line) { return ({
|
|
34
|
+
line: line,
|
|
35
|
+
}); }),
|
|
136
36
|
name: this.name,
|
|
137
37
|
turboModules: this.turboModules,
|
|
138
38
|
components: this.components,
|
|
139
|
-
arkTSComponents: this.components.filter((component)
|
|
39
|
+
arkTSComponents: this.components.filter(function (component) { return component.isArkTSComponent; }),
|
|
140
40
|
arkTSEvents: this.arkTSEvents,
|
|
141
|
-
libraries: Array.from(this.libraryCppNames).map((name)
|
|
142
|
-
name,
|
|
143
|
-
})),
|
|
41
|
+
libraries: Array.from(this.libraryCppNames).map(function (name) { return ({
|
|
42
|
+
name: name,
|
|
43
|
+
}); }),
|
|
144
44
|
});
|
|
145
|
-
}
|
|
146
|
-
|
|
45
|
+
};
|
|
46
|
+
return BasePackageHTemplate;
|
|
47
|
+
}());
|
|
147
48
|
exports.BasePackageHTemplate = BasePackageHTemplate;
|
|
@@ -5,64 +5,19 @@
|
|
|
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.ComponentDescriptorHTemplate = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
|
|
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 <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
27
|
-
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
28
|
-
#include <react/renderer/components/view/ViewShadowNode.h>
|
|
29
|
-
|
|
30
|
-
namespace facebook {
|
|
31
|
-
namespace react {
|
|
32
|
-
|
|
33
|
-
constexpr char {{name}}ComponentName[] = "{{name}}";
|
|
34
|
-
|
|
35
|
-
class {{name}}Props : public ViewProps {
|
|
36
|
-
public:
|
|
37
|
-
{{name}}Props() = default;
|
|
38
|
-
|
|
39
|
-
{{name}}Props(const PropsParserContext &context, const {{name}}Props &sourceProps, const RawProps &rawProps)
|
|
40
|
-
: ViewProps(context, sourceProps, rawProps) {}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
using {{name}}ShadowNode = ConcreteViewShadowNode<
|
|
44
|
-
{{name}}ComponentName,
|
|
45
|
-
{{name}}Props,
|
|
46
|
-
ViewEventEmitter>;
|
|
47
|
-
|
|
48
|
-
class {{name}}ComponentDescriptor final
|
|
49
|
-
: public ConcreteComponentDescriptor<{{name}}ShadowNode> {
|
|
50
|
-
public:
|
|
51
|
-
{{name}}ComponentDescriptor(ComponentDescriptorParameters const ¶meters)
|
|
52
|
-
: ConcreteComponentDescriptor(parameters) {}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
} // namespace react
|
|
56
|
-
} // namespace facebook
|
|
57
|
-
`;
|
|
58
|
-
class ComponentDescriptorHTemplate {
|
|
59
|
-
constructor(name) {
|
|
10
|
+
var mustache_1 = require("mustache");
|
|
11
|
+
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 <react/renderer/core/ConcreteComponentDescriptor.h>\n#include <react/renderer/components/view/ConcreteViewShadowNode.h>\n#include <react/renderer/components/view/ViewShadowNode.h>\n\nnamespace facebook {\nnamespace react {\n\nconstexpr char {{name}}ComponentName[] = \"{{name}}\";\n\nclass {{name}}Props : public ViewProps {\n public:\n {{name}}Props() = default;\n\n {{name}}Props(const PropsParserContext &context, const {{name}}Props &sourceProps, const RawProps &rawProps)\n : ViewProps(context, sourceProps, rawProps) {}\n};\n\nusing {{name}}ShadowNode = ConcreteViewShadowNode<\n {{name}}ComponentName,\n {{name}}Props,\n ViewEventEmitter>;\n\nclass {{name}}ComponentDescriptor final\n : public ConcreteComponentDescriptor<{{name}}ShadowNode> {\n public:\n {{name}}ComponentDescriptor(ComponentDescriptorParameters const ¶meters)\n : ConcreteComponentDescriptor(parameters) {}\n};\n\n} // namespace react\n} // namespace facebook\n";
|
|
12
|
+
var ComponentDescriptorHTemplate = /** @class */ (function () {
|
|
13
|
+
function ComponentDescriptorHTemplate(name) {
|
|
60
14
|
this.name = name;
|
|
61
15
|
}
|
|
62
|
-
build() {
|
|
16
|
+
ComponentDescriptorHTemplate.prototype.build = function () {
|
|
63
17
|
return mustache_1.default.render(TEMPLATE, {
|
|
64
18
|
name: this.name,
|
|
65
19
|
});
|
|
66
|
-
}
|
|
67
|
-
|
|
20
|
+
};
|
|
21
|
+
return ComponentDescriptorHTemplate;
|
|
22
|
+
}());
|
|
68
23
|
exports.ComponentDescriptorHTemplate = ComponentDescriptorHTemplate;
|
|
@@ -5,102 +5,54 @@
|
|
|
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.ComponentJSIBinderHTemplate = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
{
|
|
17
|
-
* {{{line}}}
|
|
18
|
-
{{/codegenNoticeLines}}
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
#pragma once
|
|
22
|
-
#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
|
|
23
|
-
|
|
24
|
-
namespace rnoh {
|
|
25
|
-
class {{name}}JSIBinder : public ViewComponentJSIBinder {
|
|
26
|
-
protected:
|
|
27
|
-
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
|
|
28
|
-
auto object = ViewComponentJSIBinder::createNativeProps(rt);
|
|
29
|
-
{{#props}}
|
|
30
|
-
object.setProperty(rt, "{{name}}", {{{type}}});
|
|
31
|
-
{{/props}}
|
|
32
|
-
return object;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
facebook::jsi::Object createCommands(facebook::jsi::Runtime &rt) override {
|
|
36
|
-
auto commands = ViewComponentJSIBinder::createCommands(rt);
|
|
37
|
-
{{#commands}}
|
|
38
|
-
commands.setProperty(rt, "{{name}}", "{{name}}");
|
|
39
|
-
{{/commands}}
|
|
40
|
-
return commands;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override {
|
|
44
|
-
facebook::jsi::Object events(rt);
|
|
45
|
-
{{#bubblingEvents}}
|
|
46
|
-
events.setProperty(rt, "{{TOPname}}", createBubblingCapturedEvent(rt, "{{name}}"));
|
|
47
|
-
{{/bubblingEvents}}
|
|
48
|
-
return events;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override {
|
|
52
|
-
facebook::jsi::Object events(rt);
|
|
53
|
-
{{#directEvents}}
|
|
54
|
-
events.setProperty(rt, "{{TOPname}}", createDirectEvent(rt, "{{name}}"));
|
|
55
|
-
{{/directEvents}}
|
|
56
|
-
return events;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
} // namespace rnoh
|
|
60
|
-
`;
|
|
61
|
-
class ComponentJSIBinderHTemplate {
|
|
62
|
-
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#include \"RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h\"\n\nnamespace rnoh {\nclass {{name}}JSIBinder : public ViewComponentJSIBinder {\n protected:\n facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {\n auto object = ViewComponentJSIBinder::createNativeProps(rt);\n {{#props}}\n object.setProperty(rt, \"{{name}}\", {{{type}}});\n {{/props}}\n return object;\n }\n\n facebook::jsi::Object createCommands(facebook::jsi::Runtime &rt) override {\n auto commands = ViewComponentJSIBinder::createCommands(rt);\n {{#commands}}\n commands.setProperty(rt, \"{{name}}\", \"{{name}}\");\n {{/commands}}\n return commands;\n }\n\n facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override {\n facebook::jsi::Object events(rt);\n {{#bubblingEvents}}\n events.setProperty(rt, \"{{TOPname}}\", createBubblingCapturedEvent(rt, \"{{name}}\"));\n {{/bubblingEvents}}\n return events;\n }\n\n facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override {\n facebook::jsi::Object events(rt);\n {{#directEvents}}\n events.setProperty(rt, \"{{TOPname}}\", createDirectEvent(rt, \"{{name}}\"));\n {{/directEvents}}\n return events;\n }\n};\n} // namespace rnoh\n";
|
|
12
|
+
var ComponentJSIBinderHTemplate = /** @class */ (function () {
|
|
13
|
+
function ComponentJSIBinderHTemplate(name, codegenNoticeLines) {
|
|
63
14
|
this.name = name;
|
|
64
15
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
65
16
|
this.props = [];
|
|
66
17
|
this.commands = [];
|
|
67
18
|
this.events = [];
|
|
68
19
|
}
|
|
69
|
-
addProp(prop) {
|
|
20
|
+
ComponentJSIBinderHTemplate.prototype.addProp = function (prop) {
|
|
70
21
|
this.props.push(prop);
|
|
71
|
-
}
|
|
72
|
-
addCommand(command) {
|
|
22
|
+
};
|
|
23
|
+
ComponentJSIBinderHTemplate.prototype.addCommand = function (command) {
|
|
73
24
|
this.commands.push(command);
|
|
74
|
-
}
|
|
75
|
-
addEvent(event) {
|
|
25
|
+
};
|
|
26
|
+
ComponentJSIBinderHTemplate.prototype.addEvent = function (event) {
|
|
76
27
|
this.events.push(event);
|
|
77
|
-
}
|
|
78
|
-
build() {
|
|
28
|
+
};
|
|
29
|
+
ComponentJSIBinderHTemplate.prototype.build = function () {
|
|
79
30
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
80
|
-
codegenNoticeLines: this.codegenNoticeLines.map((line)
|
|
81
|
-
line,
|
|
82
|
-
})),
|
|
31
|
+
codegenNoticeLines: this.codegenNoticeLines.map(function (line) { return ({
|
|
32
|
+
line: line,
|
|
33
|
+
}); }),
|
|
83
34
|
name: this.name,
|
|
84
|
-
props: this.props.map((prop)
|
|
35
|
+
props: this.props.map(function (prop) { return ({
|
|
85
36
|
name: prop.name,
|
|
86
37
|
type: prop.isObject ? '"Object"' : 'true',
|
|
87
|
-
})),
|
|
88
|
-
commands: this.commands.map((command)
|
|
38
|
+
}); }),
|
|
39
|
+
commands: this.commands.map(function (command) { return ({
|
|
89
40
|
name: command.name,
|
|
90
|
-
})),
|
|
41
|
+
}); }),
|
|
91
42
|
bubblingEvents: this.events
|
|
92
|
-
.filter((event)
|
|
93
|
-
.map((event)
|
|
43
|
+
.filter(function (event) { return event.type === 'bubble'; })
|
|
44
|
+
.map(function (event) { return ({
|
|
94
45
|
TOPname: event.eventHandlerName.replace('on', 'top'),
|
|
95
46
|
name: event.eventHandlerName,
|
|
96
|
-
})),
|
|
47
|
+
}); }),
|
|
97
48
|
directEvents: this.events
|
|
98
|
-
.filter((event)
|
|
99
|
-
.map((event)
|
|
49
|
+
.filter(function (event) { return event.type === 'direct'; })
|
|
50
|
+
.map(function (event) { return ({
|
|
100
51
|
TOPname: event.eventHandlerName.replace('on', 'top'),
|
|
101
52
|
name: event.eventHandlerName,
|
|
102
|
-
})),
|
|
53
|
+
}); }),
|
|
103
54
|
});
|
|
104
|
-
}
|
|
105
|
-
|
|
55
|
+
};
|
|
56
|
+
return ComponentJSIBinderHTemplate;
|
|
57
|
+
}());
|
|
106
58
|
exports.ComponentJSIBinderHTemplate = ComponentJSIBinderHTemplate;
|
|
@@ -5,148 +5,13 @@
|
|
|
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.ComponentUtilsTSTemplate = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
{{/codegenNoticeLines}}
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
import {
|
|
22
|
-
Descriptor as ComponentDescriptor,
|
|
23
|
-
ViewBaseProps,
|
|
24
|
-
ViewRawProps,
|
|
25
|
-
ViewDescriptorWrapperBase,
|
|
26
|
-
ColorValue,
|
|
27
|
-
Color,
|
|
28
|
-
RNInstance,
|
|
29
|
-
Tag,
|
|
30
|
-
RNComponentCommandReceiver,
|
|
31
|
-
ViewPropsSelector,
|
|
32
|
-
} from '{{{rnohImport}}}';
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export namespace {{name}} {
|
|
36
|
-
export const NAME = "{{name}}" as const
|
|
37
|
-
|
|
38
|
-
export interface DirectRawProps {
|
|
39
|
-
{{#props}}
|
|
40
|
-
{{name}}{{optionalityMarker}}: {{{type}}};
|
|
41
|
-
{{/props}}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface Props extends ViewBaseProps {}
|
|
45
|
-
|
|
46
|
-
export interface State {}
|
|
47
|
-
|
|
48
|
-
export interface RawProps extends ViewRawProps, DirectRawProps {}
|
|
49
|
-
|
|
50
|
-
export class PropsSelector extends ViewPropsSelector<Props, RawProps> {
|
|
51
|
-
{{#simpleProps}}
|
|
52
|
-
get {{name}}() {
|
|
53
|
-
return this.rawProps.{{name}}{{{orDefaultValue}}};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
{{/simpleProps}}
|
|
57
|
-
|
|
58
|
-
{{#complexProps}}
|
|
59
|
-
get {{name}}() {
|
|
60
|
-
{{{implementation}}}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
{{/complexProps}}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export type Descriptor = ComponentDescriptor<
|
|
67
|
-
typeof NAME,
|
|
68
|
-
Props,
|
|
69
|
-
State,
|
|
70
|
-
RawProps
|
|
71
|
-
>;
|
|
72
|
-
|
|
73
|
-
export class DescriptorWrapper extends ViewDescriptorWrapperBase<
|
|
74
|
-
typeof NAME,
|
|
75
|
-
Props,
|
|
76
|
-
State,
|
|
77
|
-
RawProps,
|
|
78
|
-
PropsSelector
|
|
79
|
-
> {
|
|
80
|
-
protected createPropsSelector() {
|
|
81
|
-
return new PropsSelector(this.descriptor.props, this.descriptor.rawProps)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export interface EventPayloadByName {
|
|
86
|
-
{{#events}}
|
|
87
|
-
"{{name}}": {{{payloadTSType}}}
|
|
88
|
-
{{/events}}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export class EventEmitter {
|
|
92
|
-
constructor(private rnInstance: RNInstance, private tag: Tag) {}
|
|
93
|
-
|
|
94
|
-
emit<TEventName extends keyof EventPayloadByName>(eventName: TEventName, payload: EventPayloadByName[TEventName]) {
|
|
95
|
-
this.rnInstance.emitComponentEvent(this.tag, eventName, payload)
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface CommandArgvByName {
|
|
100
|
-
{{#commands}}
|
|
101
|
-
"{{name}}": {{{argsTSType}}}
|
|
102
|
-
{{/commands}}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export class CommandReceiver {
|
|
106
|
-
private listenersByCommandName = new Map<string, Set<(...args: any[]) => void>>()
|
|
107
|
-
private cleanUp: (() => void) | undefined = undefined
|
|
108
|
-
|
|
109
|
-
constructor(private componentCommandReceiver: RNComponentCommandReceiver, private tag: Tag) {
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
subscribe<TCommandName extends keyof CommandArgvByName>(commandName: TCommandName, listener: (argv: CommandArgvByName[TCommandName]) => void) {
|
|
113
|
-
if (!this.listenersByCommandName.has(commandName)) {
|
|
114
|
-
this.listenersByCommandName.set(commandName, new Set())
|
|
115
|
-
}
|
|
116
|
-
this.listenersByCommandName.get(commandName)!.add(listener)
|
|
117
|
-
const hasRegisteredCommandReceiver = !!this.cleanUp
|
|
118
|
-
if (!hasRegisteredCommandReceiver) {
|
|
119
|
-
this.cleanUp = this.componentCommandReceiver.registerCommandCallback(this.tag, (commandName: string, argv: any[]) => {
|
|
120
|
-
if (this.listenersByCommandName.has(commandName)) {
|
|
121
|
-
const listeners = this.listenersByCommandName.get(commandName)!
|
|
122
|
-
listeners.forEach(listener => {
|
|
123
|
-
listener(argv)
|
|
124
|
-
})
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return () => {
|
|
130
|
-
this.listenersByCommandName.get(commandName)?.delete(listener)
|
|
131
|
-
if (this.listenersByCommandName.get(commandName)?.size ?? 0 === 0) {
|
|
132
|
-
this.listenersByCommandName.delete(commandName)
|
|
133
|
-
}
|
|
134
|
-
if (this.listenersByCommandName.size === 0) {
|
|
135
|
-
this.cleanUp?.()
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
`;
|
|
143
|
-
const COLOR_VALUE_GETTER_TEMPLATE = ` if (this.rawProps.{{name}}) {
|
|
144
|
-
return Color.fromColorValue(this.rawProps.{{name}})
|
|
145
|
-
} else {
|
|
146
|
-
return new Color({ r: 0, g: 0, b: 0, a: 255})
|
|
147
|
-
}`;
|
|
148
|
-
class ComponentUtilsTSTemplate {
|
|
149
|
-
constructor(name, codegenNoticeLines, rnohImport) {
|
|
10
|
+
var mustache_1 = require("mustache");
|
|
11
|
+
var TEMPLATE = "\n/**\n{{#codegenNoticeLines}}\n * {{{line}}}\n{{/codegenNoticeLines}}\n */\n\nimport {\n Descriptor as ComponentDescriptor,\n ViewBaseProps,\n ViewRawProps,\n ViewDescriptorWrapperBase,\n ColorValue,\n Color,\n RNInstance,\n Tag,\n RNComponentCommandReceiver,\n ViewPropsSelector,\n} from '{{{rnohImport}}}';\n\n\nexport namespace {{name}} {\n export const NAME = \"{{name}}\" as const\n\n export interface DirectRawProps {\n {{#props}}\n {{name}}{{optionalityMarker}}: {{{type}}};\n {{/props}}\n }\n \n export interface Props extends ViewBaseProps {}\n \n export interface State {}\n \n export interface RawProps extends ViewRawProps, DirectRawProps {}\n \n export class PropsSelector extends ViewPropsSelector<Props, RawProps> {\n {{#simpleProps}}\n get {{name}}() {\n return this.rawProps.{{name}}{{{orDefaultValue}}};\n }\n \n {{/simpleProps}}\n \n {{#complexProps}}\n get {{name}}() {\n{{{implementation}}}\n }\n \n {{/complexProps}}\n }\n\n export type Descriptor = ComponentDescriptor<\n typeof NAME,\n Props,\n State,\n RawProps\n >;\n \n export class DescriptorWrapper extends ViewDescriptorWrapperBase<\n typeof NAME,\n Props,\n State,\n RawProps,\n PropsSelector\n > {\n protected createPropsSelector() {\n return new PropsSelector(this.descriptor.props, this.descriptor.rawProps)\n }\n }\n \n export interface EventPayloadByName {\n {{#events}}\n \"{{name}}\": {{{payloadTSType}}}\n {{/events}}\n }\n \n export class EventEmitter {\n constructor(private rnInstance: RNInstance, private tag: Tag) {}\n \n emit<TEventName extends keyof EventPayloadByName>(eventName: TEventName, payload: EventPayloadByName[TEventName]) {\n this.rnInstance.emitComponentEvent(this.tag, eventName, payload)\n }\n }\n \n export interface CommandArgvByName {\n {{#commands}}\n \"{{name}}\": {{{argsTSType}}}\n {{/commands}}\n }\n \n export class CommandReceiver {\n private listenersByCommandName = new Map<string, Set<(...args: any[]) => void>>()\n private cleanUp: (() => void) | undefined = undefined\n \n constructor(private componentCommandReceiver: RNComponentCommandReceiver, private tag: Tag) {\n }\n \n subscribe<TCommandName extends keyof CommandArgvByName>(commandName: TCommandName, listener: (argv: CommandArgvByName[TCommandName]) => void) {\n if (!this.listenersByCommandName.has(commandName)) {\n this.listenersByCommandName.set(commandName, new Set())\n }\n this.listenersByCommandName.get(commandName)!.add(listener)\n const hasRegisteredCommandReceiver = !!this.cleanUp\n if (!hasRegisteredCommandReceiver) {\n this.cleanUp = this.componentCommandReceiver.registerCommandCallback(this.tag, (commandName: string, argv: any[]) => {\n if (this.listenersByCommandName.has(commandName)) {\n const listeners = this.listenersByCommandName.get(commandName)!\n listeners.forEach(listener => {\n listener(argv)\n })\n }\n })\n }\n \n return () => {\n this.listenersByCommandName.get(commandName)?.delete(listener)\n if (this.listenersByCommandName.get(commandName)?.size ?? 0 === 0) {\n this.listenersByCommandName.delete(commandName)\n }\n if (this.listenersByCommandName.size === 0) {\n this.cleanUp?.()\n }\n }\n }\n }\n\n}\n";
|
|
12
|
+
var COLOR_VALUE_GETTER_TEMPLATE = " if (this.rawProps.{{name}}) {\n return Color.fromColorValue(this.rawProps.{{name}})\n } else {\n return new Color({ r: 0, g: 0, b: 0, a: 255})\n }";
|
|
13
|
+
var ComponentUtilsTSTemplate = /** @class */ (function () {
|
|
14
|
+
function ComponentUtilsTSTemplate(name, codegenNoticeLines, rnohImport) {
|
|
150
15
|
this.name = name;
|
|
151
16
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
152
17
|
this.rnohImport = rnohImport;
|
|
@@ -156,43 +21,45 @@ class ComponentUtilsTSTemplate {
|
|
|
156
21
|
this.getterTemplateByTSType = new Map();
|
|
157
22
|
this.getterTemplateByTSType.set('ColorValue', COLOR_VALUE_GETTER_TEMPLATE);
|
|
158
23
|
}
|
|
159
|
-
addProp(prop) {
|
|
24
|
+
ComponentUtilsTSTemplate.prototype.addProp = function (prop) {
|
|
160
25
|
this.props.push(prop);
|
|
161
|
-
}
|
|
162
|
-
addEvent(event) {
|
|
26
|
+
};
|
|
27
|
+
ComponentUtilsTSTemplate.prototype.addEvent = function (event) {
|
|
163
28
|
this.events.push(event);
|
|
164
|
-
}
|
|
165
|
-
addCommand(command) {
|
|
29
|
+
};
|
|
30
|
+
ComponentUtilsTSTemplate.prototype.addCommand = function (command) {
|
|
166
31
|
this.commands.push(command);
|
|
167
|
-
}
|
|
168
|
-
build() {
|
|
32
|
+
};
|
|
33
|
+
ComponentUtilsTSTemplate.prototype.build = function () {
|
|
34
|
+
var _this = this;
|
|
169
35
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
170
|
-
codegenNoticeLines: this.codegenNoticeLines.map((line)
|
|
171
|
-
line,
|
|
172
|
-
})),
|
|
36
|
+
codegenNoticeLines: this.codegenNoticeLines.map(function (line) { return ({
|
|
37
|
+
line: line,
|
|
38
|
+
}); }),
|
|
173
39
|
name: this.name,
|
|
174
40
|
rnohImport: this.rnohImport,
|
|
175
|
-
props: this.props.map((prop)
|
|
41
|
+
props: this.props.map(function (prop) { return ({
|
|
176
42
|
name: prop.name,
|
|
177
43
|
type: prop.tsType,
|
|
178
44
|
optionalityMarker: prop.isOptional ? '?' : '',
|
|
179
|
-
})),
|
|
45
|
+
}); }),
|
|
180
46
|
events: this.events,
|
|
181
47
|
commands: this.commands,
|
|
182
48
|
simpleProps: this.props
|
|
183
|
-
.filter((prop)
|
|
184
|
-
.map((prop)
|
|
49
|
+
.filter(function (prop) { return !_this.getterTemplateByTSType.has(prop.tsType); })
|
|
50
|
+
.map(function (prop) { return ({
|
|
185
51
|
name: prop.name,
|
|
186
52
|
type: prop.tsType,
|
|
187
|
-
orDefaultValue: prop.defaultValue ?
|
|
188
|
-
})),
|
|
53
|
+
orDefaultValue: prop.defaultValue ? " ?? ".concat(prop.defaultValue) : '',
|
|
54
|
+
}); }),
|
|
189
55
|
complexProps: this.props
|
|
190
|
-
.filter((prop)
|
|
191
|
-
.map((prop)
|
|
56
|
+
.filter(function (prop) { return _this.getterTemplateByTSType.has(prop.tsType); })
|
|
57
|
+
.map(function (prop) { return ({
|
|
192
58
|
name: prop.name,
|
|
193
|
-
implementation: mustache_1.default.render(
|
|
194
|
-
})),
|
|
59
|
+
implementation: mustache_1.default.render(_this.getterTemplateByTSType.get(prop.tsType), { name: prop.name }, {}),
|
|
60
|
+
}); }),
|
|
195
61
|
});
|
|
196
|
-
}
|
|
197
|
-
|
|
62
|
+
};
|
|
63
|
+
return ComponentUtilsTSTemplate;
|
|
64
|
+
}());
|
|
198
65
|
exports.ComponentUtilsTSTemplate = ComponentUtilsTSTemplate;
|
|
@@ -5,54 +5,34 @@
|
|
|
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.IndexTSTemplate = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
{{/codegenNoticeLines}}
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
{{#reexports}}
|
|
22
|
-
export * {{as}}from "{{{from}}}"
|
|
23
|
-
{{/reexports}}
|
|
24
|
-
`;
|
|
25
|
-
const TEMPLATE_EMPTY = `
|
|
26
|
-
/**
|
|
27
|
-
{{#codegenNoticeLines}}
|
|
28
|
-
* {{{line}}}
|
|
29
|
-
{{/codegenNoticeLines}}
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
export {}
|
|
33
|
-
`;
|
|
34
|
-
class IndexTSTemplate {
|
|
35
|
-
constructor(codegenNoticeLines) {
|
|
10
|
+
var mustache_1 = require("mustache");
|
|
11
|
+
var TEMPLATE = "\n/**\n{{#codegenNoticeLines}}\n * {{{line}}}\n{{/codegenNoticeLines}}\n */\n\n{{#reexports}}\nexport * {{as}}from \"{{{from}}}\"\n{{/reexports}}\n";
|
|
12
|
+
var TEMPLATE_EMPTY = "\n/**\n{{#codegenNoticeLines}}\n * {{{line}}}\n{{/codegenNoticeLines}}\n */\n\nexport {}\n";
|
|
13
|
+
var IndexTSTemplate = /** @class */ (function () {
|
|
14
|
+
function IndexTSTemplate(codegenNoticeLines) {
|
|
36
15
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
37
16
|
this.reexports = [];
|
|
38
17
|
}
|
|
39
|
-
addReexport(reexport) {
|
|
18
|
+
IndexTSTemplate.prototype.addReexport = function (reexport) {
|
|
40
19
|
this.reexports.push(reexport);
|
|
41
20
|
return this;
|
|
42
|
-
}
|
|
43
|
-
build() {
|
|
21
|
+
};
|
|
22
|
+
IndexTSTemplate.prototype.build = function () {
|
|
44
23
|
if (this.reexports.length === 0) {
|
|
45
24
|
return mustache_1.default.render(TEMPLATE_EMPTY, {});
|
|
46
25
|
}
|
|
47
26
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
48
|
-
codegenNoticeLines: this.codegenNoticeLines.map((line)
|
|
49
|
-
line,
|
|
50
|
-
})),
|
|
51
|
-
reexports: this.reexports.map((reexport)
|
|
27
|
+
codegenNoticeLines: this.codegenNoticeLines.map(function (line) { return ({
|
|
28
|
+
line: line,
|
|
29
|
+
}); }),
|
|
30
|
+
reexports: this.reexports.map(function (reexport) { return ({
|
|
52
31
|
from: reexport.from,
|
|
53
|
-
as: reexport.as ?
|
|
54
|
-
})),
|
|
32
|
+
as: reexport.as ? "as ".concat(reexport.as, " ") : '',
|
|
33
|
+
}); }),
|
|
55
34
|
});
|
|
56
|
-
}
|
|
57
|
-
|
|
35
|
+
};
|
|
36
|
+
return IndexTSTemplate;
|
|
37
|
+
}());
|
|
58
38
|
exports.IndexTSTemplate = IndexTSTemplate;
|