@react-native-oh/react-native-harmony-cli 0.0.25 → 0.0.26-10
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/.prettierrc +6 -6
- package/dist/assetResolver.js +1 -23
- package/dist/codegen/core/CodeGenerator.js +2 -0
- package/dist/codegen/core/UberSchema.js +35 -9
- package/dist/codegen/core/index.js +1 -1
- package/dist/codegen/generators/{ComponentCodeGenerator.js → ComponentCodeGeneratorArkTS.js} +12 -4
- package/dist/codegen/generators/ComponentCodeGeneratorCAPI.js +79 -0
- package/dist/codegen/generators/GlueCodeGenerator.js +60 -0
- package/dist/codegen/generators/NativeModuleCodeGenerator.js +14 -6
- package/dist/codegen/generators/UberGeneratorV1.js +49 -0
- package/dist/codegen/generators/UberGeneratorV2.js +60 -0
- package/dist/codegen/generators/index.js +5 -2
- package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +103 -0
- package/dist/codegen/templates/ComponentDescriptorHTemplate.js +42 -36
- package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +45 -36
- package/dist/codegen/templates/ComponentUtilsTSTemplate.js +135 -127
- package/dist/codegen/templates/GeneratedPackageHTemplate.js +101 -0
- package/dist/codegen/templates/IndexTSTemplate.js +23 -5
- package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +88 -82
- package/dist/codegen/templates/TurboModuleCppTemplate.js +26 -18
- package/dist/codegen/templates/TurboModuleHTemplate.js +27 -17
- package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +37 -27
- package/dist/codegen/templates/index.js +1 -0
- package/dist/commands/codegen-harmony.js +99 -14
- package/dist/commands/verify-package-harmony.js +7 -12
- package/dist/core/AbsolutePath.js +6 -0
- package/dist/core/CodegenConfig.js +8 -4
- package/dist/core/PackageJSON.js +8 -3
- package/dist/core/ProjectDependenciesManager.js +2 -2
- package/dist/package-verifier/verify-package.js +5 -4
- package/jest.config.js +5 -5
- package/package.json +57 -56
- package/react-native.config.js +10 -10
- package/src/assetResolver.ts +21 -44
- package/src/codegen/core/CodeGenerator.ts +9 -0
- package/src/codegen/core/CodegenError.ts +3 -3
- package/src/codegen/core/EventUtils.ts +18 -18
- package/src/codegen/core/TypeAnnotationToTS.test.ts +75 -75
- package/src/codegen/core/TypeAnnotationToTS.ts +188 -188
- package/src/codegen/core/UberSchema.ts +142 -99
- package/src/codegen/core/index.ts +5 -5
- package/src/codegen/generators/{ComponentCodeGenerator.ts → ComponentCodeGeneratorArkTS.ts} +112 -98
- package/src/codegen/generators/ComponentCodeGeneratorCAPI.ts +114 -0
- package/src/codegen/generators/GlueCodeGenerator.ts +109 -0
- package/src/codegen/generators/NativeModuleCodeGenerator.ts +115 -95
- package/src/codegen/generators/UberGeneratorV1.ts +64 -0
- package/src/codegen/generators/UberGeneratorV2.ts +91 -0
- package/src/codegen/generators/index.ts +6 -3
- package/src/codegen/index.ts +2 -2
- package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +116 -0
- package/src/codegen/templates/ComponentDescriptorHTemplate.ts +55 -49
- package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +93 -85
- package/src/codegen/templates/ComponentUtilsTSTemplate.ts +210 -202
- package/src/codegen/templates/GeneratedPackageHTemplate.ts +107 -0
- package/src/codegen/templates/IndexTSTemplate.ts +53 -33
- package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +130 -124
- package/src/codegen/templates/TurboModuleCppTemplate.ts +54 -47
- package/src/codegen/templates/TurboModuleHTemplate.ts +35 -26
- package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +90 -81
- package/src/codegen/templates/index.ts +9 -8
- package/src/commands/bundle-harmony.ts +203 -203
- package/src/commands/codegen-harmony.ts +272 -143
- package/src/commands/create-metro-host-constants.ts +48 -48
- package/src/commands/index.ts +6 -6
- package/src/commands/pack-harmony.ts +121 -121
- package/src/commands/unpack-harmony.ts +231 -231
- package/src/commands/verify-package-harmony.ts +106 -106
- package/src/core/AbsolutePath.ts +50 -43
- package/src/core/CodegenConfig.ts +62 -54
- package/src/core/DescriptiveError.ts +61 -61
- package/src/core/OHPackageJSON5.ts +23 -23
- package/src/core/PackageJSON.ts +75 -63
- package/src/core/ProjectDependenciesManager.ts +77 -77
- package/src/core/ValidationError.ts +1 -1
- package/src/core/ValueObject.ts +2 -2
- package/src/core/fs.ts +31 -31
- package/src/core/index.ts +9 -9
- package/src/index.ts +20 -20
- package/src/io/Logger.ts +68 -68
- package/src/io/TarGz.ts +26 -26
- package/src/io/fsUtils.ts +24 -24
- package/src/io/index.ts +3 -3
- package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +28 -28
- package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +24 -24
- package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +18 -18
- package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +47 -47
- package/src/package-verifier/checks/index.ts +4 -4
- package/src/package-verifier/index.ts +2 -2
- package/src/package-verifier/types.ts +12 -12
- package/src/package-verifier/verify-package.ts +117 -117
- package/tsconfig.build.json +6 -6
- package/tsconfig.json +2 -2
- package/dist/codegen/core/Codegen.js +0 -35
- package/dist/codegen/generators/PackageCodeGenerator.js +0 -52
- package/src/codegen/core/Codegen.ts +0 -44
- package/src/codegen/generators/PackageCodeGenerator.ts +0 -73
|
@@ -5,42 +5,48 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ComponentDescriptorHTemplate = void 0;
|
|
7
7
|
const mustache_1 = __importDefault(require("mustache"));
|
|
8
|
-
const TEMPLATE = `
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
{{name}}Props,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{{name}}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
8
|
+
const TEMPLATE = `
|
|
9
|
+
/**
|
|
10
|
+
* This code was generated by "react-native codegen-harmony"
|
|
11
|
+
*
|
|
12
|
+
* Do not edit this file as changes may cause incorrect behavior and will be
|
|
13
|
+
* lost once the code is regenerated.
|
|
14
|
+
*
|
|
15
|
+
* @generatorVersion: 1
|
|
16
|
+
*/
|
|
17
|
+
#pragma once
|
|
18
|
+
|
|
19
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
20
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
21
|
+
#include <react/renderer/components/view/ViewShadowNode.h>
|
|
22
|
+
|
|
23
|
+
namespace facebook {
|
|
24
|
+
namespace react {
|
|
25
|
+
|
|
26
|
+
extern const char {{name}}ComponentName[] = "{{name}}";
|
|
27
|
+
|
|
28
|
+
class {{name}}Props : public ViewProps {
|
|
29
|
+
public:
|
|
30
|
+
{{name}}Props() = default;
|
|
31
|
+
|
|
32
|
+
{{name}}Props(const PropsParserContext &context, const {{name}}Props &sourceProps, const RawProps &rawProps)
|
|
33
|
+
: ViewProps(context, sourceProps, rawProps) {}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
using {{name}}ShadowNode = ConcreteViewShadowNode<
|
|
37
|
+
{{name}}ComponentName,
|
|
38
|
+
{{name}}Props,
|
|
39
|
+
ViewEventEmitter>;
|
|
40
|
+
|
|
41
|
+
class {{name}}ComponentDescriptor final
|
|
42
|
+
: public ConcreteComponentDescriptor<{{name}}ShadowNode> {
|
|
43
|
+
public:
|
|
44
|
+
{{name}}ComponentDescriptor(ComponentDescriptorParameters const ¶meters)
|
|
45
|
+
: ConcreteComponentDescriptor(parameters) {}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
} // namespace react
|
|
49
|
+
} // namespace facebook
|
|
44
50
|
`;
|
|
45
51
|
class ComponentDescriptorHTemplate {
|
|
46
52
|
constructor(name) {
|
|
@@ -5,45 +5,53 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ComponentJSIBinderHTemplate = void 0;
|
|
7
7
|
const mustache_1 = __importDefault(require("mustache"));
|
|
8
|
-
const TEMPLATE = `
|
|
9
|
-
#pragma once
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
{{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
{{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
8
|
+
const TEMPLATE = `
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This code was generated by "react-native codegen-harmony"
|
|
13
|
+
*
|
|
14
|
+
* Do not edit this file as changes may cause incorrect behavior and will be
|
|
15
|
+
* lost once the code is regenerated.
|
|
16
|
+
*
|
|
17
|
+
* @generatorVersion: {{generatorVersion}}
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
|
|
21
|
+
|
|
22
|
+
namespace rnoh {
|
|
23
|
+
class {{name}}JSIBinder : public ViewComponentJSIBinder {
|
|
24
|
+
protected:
|
|
25
|
+
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
|
|
26
|
+
auto object = ViewComponentJSIBinder::createNativeProps(rt);
|
|
27
|
+
{{#props}}
|
|
28
|
+
object.setProperty(rt, "{{name}}", {{{type}}});
|
|
29
|
+
{{/props}}
|
|
30
|
+
return object;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override {
|
|
34
|
+
facebook::jsi::Object events(rt);
|
|
35
|
+
{{#bubblingEvents}}
|
|
36
|
+
events.setProperty(rt, "{{TOPname}}", createBubblingCapturedEvent(rt, "{{name}}"));
|
|
37
|
+
{{/bubblingEvents}}
|
|
38
|
+
return events;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override {
|
|
42
|
+
facebook::jsi::Object events(rt);
|
|
43
|
+
{{#directEvents}}
|
|
44
|
+
events.setProperty(rt, "{{TOPname}}", createDirectEvent(rt, "{{name}}"));
|
|
45
|
+
{{/directEvents}}
|
|
46
|
+
return events;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
} // namespace rnoh
|
|
43
50
|
`;
|
|
44
51
|
class ComponentJSIBinderHTemplate {
|
|
45
|
-
constructor(name) {
|
|
52
|
+
constructor(name, generatorVersion) {
|
|
46
53
|
this.name = name;
|
|
54
|
+
this.generatorVersion = generatorVersion;
|
|
47
55
|
this.props = [];
|
|
48
56
|
this.events = [];
|
|
49
57
|
}
|
|
@@ -56,6 +64,7 @@ class ComponentJSIBinderHTemplate {
|
|
|
56
64
|
build() {
|
|
57
65
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
58
66
|
name: this.name,
|
|
67
|
+
generatorVersion: this.generatorVersion,
|
|
59
68
|
props: this.props.map((prop) => ({
|
|
60
69
|
name: prop.name,
|
|
61
70
|
type: prop.isObject ? '"Object"' : 'true',
|
|
@@ -5,134 +5,142 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ComponentUtilsTSTemplate = void 0;
|
|
7
7
|
const mustache_1 = __importDefault(require("mustache"));
|
|
8
|
-
const TEMPLATE = `
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
export interface
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
{{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
{
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export
|
|
89
|
-
{
|
|
90
|
-
|
|
91
|
-
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
8
|
+
const TEMPLATE = `
|
|
9
|
+
/**
|
|
10
|
+
* This code was generated by "react-native codegen-harmony"
|
|
11
|
+
*
|
|
12
|
+
* Do not edit this file as changes may cause incorrect behavior and will be
|
|
13
|
+
* lost once the code is regenerated.
|
|
14
|
+
*
|
|
15
|
+
* @generatorVersion: 1
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
Descriptor as ComponentDescriptor,
|
|
20
|
+
ViewBaseProps,
|
|
21
|
+
ViewRawProps,
|
|
22
|
+
ViewDescriptorWrapperBase,
|
|
23
|
+
ColorValue,
|
|
24
|
+
Color,
|
|
25
|
+
RNInstance,
|
|
26
|
+
Tag,
|
|
27
|
+
RNComponentCommandReceiver,
|
|
28
|
+
ViewPropsSelector,
|
|
29
|
+
} from '../../ts';
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
export namespace {{name}} {
|
|
33
|
+
export const NAME = "{{name}}" as const
|
|
34
|
+
|
|
35
|
+
export interface DirectRawProps {
|
|
36
|
+
{{#props}}
|
|
37
|
+
{{name}}{{optionalityMarker}}: {{{type}}};
|
|
38
|
+
{{/props}}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface Props extends ViewBaseProps {}
|
|
42
|
+
|
|
43
|
+
export interface State {}
|
|
44
|
+
|
|
45
|
+
export interface RawProps extends ViewRawProps, DirectRawProps {}
|
|
46
|
+
|
|
47
|
+
export class PropsSelector extends ViewPropsSelector<Props, RawProps> {
|
|
48
|
+
{{#simpleProps}}
|
|
49
|
+
get {{name}}() {
|
|
50
|
+
return this.rawProps.{{name}}{{{orDefaultValue}}};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
{{/simpleProps}}
|
|
54
|
+
|
|
55
|
+
{{#complexProps}}
|
|
56
|
+
get {{name}}() {
|
|
57
|
+
{{{implementation}}}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
{{/complexProps}}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type Descriptor = ComponentDescriptor<
|
|
64
|
+
typeof NAME,
|
|
65
|
+
Props,
|
|
66
|
+
State,
|
|
67
|
+
RawProps
|
|
68
|
+
>;
|
|
69
|
+
|
|
70
|
+
export class DescriptorWrapper extends ViewDescriptorWrapperBase<
|
|
71
|
+
typeof NAME,
|
|
72
|
+
Props,
|
|
73
|
+
State,
|
|
74
|
+
RawProps,
|
|
75
|
+
PropsSelector
|
|
76
|
+
> {
|
|
77
|
+
protected createPropsSelector() {
|
|
78
|
+
return new PropsSelector(this.descriptor.props, this.descriptor.rawProps)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface EventPayloadByName {
|
|
83
|
+
{{#events}}
|
|
84
|
+
"{{name}}": {{{payloadTSType}}}
|
|
85
|
+
{{/events}}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export class EventEmitter {
|
|
89
|
+
constructor(private rnInstance: RNInstance, private tag: Tag) {}
|
|
90
|
+
|
|
91
|
+
emit<TEventName extends keyof EventPayloadByName>(eventName: TEventName, payload: EventPayloadByName[TEventName]) {
|
|
92
|
+
this.rnInstance.emitComponentEvent(this.tag, eventName, payload)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface CommandArgvByName {
|
|
97
|
+
{{#commands}}
|
|
98
|
+
"{{name}}": {{{argsTSType}}}
|
|
99
|
+
{{/commands}}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export class CommandReceiver {
|
|
103
|
+
private listenersByCommandName = new Map<string, Set<(...args: any[]) => void>>()
|
|
104
|
+
private cleanUp: (() => void) | undefined = undefined
|
|
105
|
+
|
|
106
|
+
constructor(private componentCommandReceiver: RNComponentCommandReceiver, private tag: Tag) {
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
subscribe<TCommandName extends keyof CommandArgvByName>(commandName: TCommandName, listener: (argv: CommandArgvByName[TCommandName]) => void) {
|
|
110
|
+
if (!this.listenersByCommandName.has(commandName)) {
|
|
111
|
+
this.listenersByCommandName.set(commandName, new Set())
|
|
112
|
+
}
|
|
113
|
+
this.listenersByCommandName.get(commandName)!.add(listener)
|
|
114
|
+
const hasRegisteredCommandReceiver = !!this.cleanUp
|
|
115
|
+
if (!hasRegisteredCommandReceiver) {
|
|
116
|
+
this.cleanUp = this.componentCommandReceiver.registerCommandCallback(this.tag, (commandName: string, argv: any[]) => {
|
|
117
|
+
if (this.listenersByCommandName.has(commandName)) {
|
|
118
|
+
const listeners = this.listenersByCommandName.get(commandName)!
|
|
119
|
+
listeners.forEach(listener => {
|
|
120
|
+
listener(argv)
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return () => {
|
|
127
|
+
this.listenersByCommandName.get(commandName)?.delete(listener)
|
|
128
|
+
if (this.listenersByCommandName.get(commandName)?.size ?? 0 === 0) {
|
|
129
|
+
this.listenersByCommandName.delete(commandName)
|
|
130
|
+
}
|
|
131
|
+
if (this.listenersByCommandName.size === 0) {
|
|
132
|
+
this.cleanUp?.()
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
}
|
|
131
139
|
`;
|
|
132
|
-
const COLOR_VALUE_GETTER_TEMPLATE = ` if (this.rawProps.{{name}}) {
|
|
133
|
-
return Color.fromColorValue(this.rawProps.{{name}})
|
|
134
|
-
} else {
|
|
135
|
-
return new Color({ r: 0, g: 0, b: 0, a: 255})
|
|
140
|
+
const COLOR_VALUE_GETTER_TEMPLATE = ` if (this.rawProps.{{name}}) {
|
|
141
|
+
return Color.fromColorValue(this.rawProps.{{name}})
|
|
142
|
+
} else {
|
|
143
|
+
return new Color({ r: 0, g: 0, b: 0, a: 255})
|
|
136
144
|
}`;
|
|
137
145
|
class ComponentUtilsTSTemplate {
|
|
138
146
|
constructor(name) {
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BasePackageHTemplate = void 0;
|
|
7
|
+
const mustache_1 = __importDefault(require("mustache"));
|
|
8
|
+
const TEMPLATE = `
|
|
9
|
+
/**
|
|
10
|
+
* This code was generated by "react-native codegen-harmony"
|
|
11
|
+
*
|
|
12
|
+
* Do not edit this file as changes may cause incorrect behavior and will be
|
|
13
|
+
* lost once the code is regenerated.
|
|
14
|
+
*
|
|
15
|
+
* @generatorVersion: 2
|
|
16
|
+
*/
|
|
17
|
+
#pragma once
|
|
18
|
+
|
|
19
|
+
{{#libraries}}
|
|
20
|
+
#include <react/renderer/components/{{name}}/ComponentDescriptors.h>
|
|
21
|
+
{{/libraries}}
|
|
22
|
+
#include "RNOH/Package.h"
|
|
23
|
+
#include "RNOH/ArkTSTurboModule.h"
|
|
24
|
+
{{#turboModules}}
|
|
25
|
+
#include "RNOH/generated/turbo_modules/{{name}}.h"
|
|
26
|
+
{{/turboModules}}
|
|
27
|
+
{{#components}}
|
|
28
|
+
#include "RNOH/generated/components/{{name}}JSIBinder.h"
|
|
29
|
+
{{/components}}
|
|
30
|
+
|
|
31
|
+
namespace rnoh {
|
|
32
|
+
|
|
33
|
+
class {{name}}TurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
|
|
34
|
+
public:
|
|
35
|
+
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
|
|
36
|
+
{{#turboModules}}
|
|
37
|
+
if (name == "{{name}}") {
|
|
38
|
+
return std::make_shared<{{name}}>(ctx, name);
|
|
39
|
+
}
|
|
40
|
+
{{/turboModules}}
|
|
41
|
+
return nullptr;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
class {{name}} : public Package {
|
|
46
|
+
public:
|
|
47
|
+
{{name}}(Package::Context ctx) : Package(ctx){};
|
|
48
|
+
|
|
49
|
+
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
|
|
50
|
+
return std::make_unique<{{name}}TurboModuleFactoryDelegate>();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
|
|
54
|
+
return {
|
|
55
|
+
{{#components}}
|
|
56
|
+
facebook::react::concreteComponentDescriptorProvider<facebook::react::{{name}}ComponentDescriptor>(),
|
|
57
|
+
{{/components}}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
ComponentJSIBinderByString createComponentJSIBinderByName() override {
|
|
62
|
+
return {
|
|
63
|
+
{{#components}}
|
|
64
|
+
{"{{name}}", std::make_shared<{{name}}JSIBinder>()},
|
|
65
|
+
{{/components}}
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
EventEmitRequestHandlers createEventEmitRequestHandlers() override {
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
} // namespace rnoh
|
|
75
|
+
`;
|
|
76
|
+
class BasePackageHTemplate {
|
|
77
|
+
constructor(name) {
|
|
78
|
+
this.name = name;
|
|
79
|
+
this.turboModules = [];
|
|
80
|
+
this.components = [];
|
|
81
|
+
this.libraryNames = new Set();
|
|
82
|
+
}
|
|
83
|
+
addTurboModule(turboModule) {
|
|
84
|
+
this.turboModules.push(turboModule);
|
|
85
|
+
}
|
|
86
|
+
addComponent(component) {
|
|
87
|
+
this.components.push(component);
|
|
88
|
+
this.libraryNames.add(component.libraryName);
|
|
89
|
+
}
|
|
90
|
+
build() {
|
|
91
|
+
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
92
|
+
name: this.name,
|
|
93
|
+
turboModules: this.turboModules,
|
|
94
|
+
components: this.components,
|
|
95
|
+
libraries: Array.from(this.libraryNames).map((name) => ({
|
|
96
|
+
name,
|
|
97
|
+
})),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.BasePackageHTemplate = BasePackageHTemplate;
|
|
@@ -5,11 +5,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.IndexTSTemplate = void 0;
|
|
7
7
|
const mustache_1 = __importDefault(require("mustache"));
|
|
8
|
-
const TEMPLATE = `
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const TEMPLATE = `
|
|
9
|
+
/**
|
|
10
|
+
* This code was generated by "react-native codegen-harmony"
|
|
11
|
+
*
|
|
12
|
+
* Do not edit this file as changes may cause incorrect behavior and will be
|
|
13
|
+
* lost once the code is regenerated.
|
|
14
|
+
*/
|
|
15
|
+
{{#reexports}}
|
|
16
|
+
export * {{as}}from "{{{from}}}"
|
|
17
|
+
{{/reexports}}
|
|
18
|
+
`;
|
|
19
|
+
const TEMPLATE_EMPTY = `
|
|
20
|
+
/**
|
|
21
|
+
* This code was generated by "react-native codegen-harmony"
|
|
22
|
+
*
|
|
23
|
+
* Do not edit this file as changes may cause incorrect behavior and will be
|
|
24
|
+
* lost once the code is regenerated.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export {}
|
|
13
28
|
`;
|
|
14
29
|
class IndexTSTemplate {
|
|
15
30
|
constructor() {
|
|
@@ -20,6 +35,9 @@ class IndexTSTemplate {
|
|
|
20
35
|
return this;
|
|
21
36
|
}
|
|
22
37
|
build() {
|
|
38
|
+
if (this.reexports.length === 0) {
|
|
39
|
+
return mustache_1.default.render(TEMPLATE_EMPTY, {});
|
|
40
|
+
}
|
|
23
41
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
24
42
|
reexports: this.reexports.map((reexport) => ({
|
|
25
43
|
from: reexport.from,
|