@react-native-oh/react-native-harmony-cli 0.77.18 → 0.77.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assetResolver.js +74 -43
- package/dist/autolinking/Autolinking.js +179 -178
- 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 +97 -55
- 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 -54
- 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 +221 -118
- package/dist/commands/clean-harmony.js +63 -58
- package/dist/commands/codegen-harmony.js +175 -104
- package/dist/commands/codegen-lib-harmony.js +116 -76
- package/dist/commands/init-harmony.js +196 -151
- package/dist/commands/init.js +961 -537
- package/dist/commands/link-harmony.js +82 -35
- package/dist/commands/run-harmony.js +520 -352
- package/dist/commands/verify-package-harmony.js +117 -54
- package/dist/core/AbsolutePath.js +49 -33
- 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 +92 -40
- package/dist/core/ValidationError.js +22 -2
- package/dist/core/fs.js +7 -10
- package/dist/index.js +1 -1
- package/dist/init/templates/AppScopeAppJSON5Template.js +8 -21
- package/dist/init/templates/AppScopeStringVarTemplate.js +8 -19
- package/dist/init/templates/EntryIndexTemplate.js +8 -56
- package/dist/init/templates/EntryStringVarTemplate.js +8 -27
- package/dist/init/templates/HvigorConfigJson5Template.js +8 -33
- package/dist/init/templates/MetroConfigTemplate.js +8 -38
- package/dist/init/templates/OhPackageJson5Template.js +8 -28
- package/dist/io/CliExecutor.js +98 -46
- package/dist/io/Logger.js +46 -40
- package/dist/io/RealFS.js +100 -43
- 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 +133 -56
- package/dist/simulator/LaunchSimulator.js +395 -0
- package/dist/simulator/index.js +23 -0
- package/package.json +2 -11
- package/scripts/sync-hvigor.js +27 -0
- package/src/autolinking/Autolinking.ts +1 -1
- package/src/codegen/generators/UberGeneratorV1.ts +7 -2
- package/src/codegen/generators/UberGeneratorV2.ts +6 -1
- package/src/commands/codegen-harmony.ts +17 -7
- package/src/commands/run-harmony.ts +67 -41
- package/src/init/templates/harmony/entry/src/main/module.json5 +7 -0
- package/src/simulator/LaunchSimulator.ts +359 -0
- package/src/simulator/index.ts +8 -0
- package/dist/init/templates/harmony/AppScope/app.json5 +0 -10
- package/dist/init/templates/harmony/AppScope/resources/base/element/string.json +0 -8
- package/dist/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
- package/dist/init/templates/harmony/build-profile.json5 +0 -36
- package/dist/init/templates/harmony/codelinter.json +0 -32
- package/dist/init/templates/harmony/entry/build-profile.json5 +0 -18
- package/dist/init/templates/harmony/entry/gitignore +0 -7
- package/dist/init/templates/harmony/entry/hvigorfile.ts +0 -13
- package/dist/init/templates/harmony/entry/oh-package.json5 +0 -9
- package/dist/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +0 -27
- package/dist/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +0 -13
- package/dist/init/templates/harmony/entry/src/main/cpp/gitignore +0 -4
- package/dist/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +0 -8
- package/dist/init/templates/harmony/entry/src/main/ets/codegen/gitignore +0 -2
- package/dist/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +0 -11
- package/dist/init/templates/harmony/entry/src/main/ets/gitignore +0 -1
- package/dist/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
- package/dist/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +0 -16
- package/dist/init/templates/harmony/entry/src/main/module.json5 +0 -58
- package/dist/init/templates/harmony/entry/src/main/resources/base/element/color.json +0 -8
- package/dist/init/templates/harmony/entry/src/main/resources/base/element/string.json +0 -16
- package/dist/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
- package/dist/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
- package/dist/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +0 -7
- package/dist/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
- package/dist/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +0 -5
- package/dist/init/templates/harmony/entry/src/main/resources/gitignore +0 -1
- package/dist/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +0 -2
- package/dist/init/templates/harmony/entry/src/ohosTest/module.json5 +0 -13
- package/dist/init/templates/harmony/gitignore +0 -16
- package/dist/init/templates/harmony/hvigor/hvigor-config.json5 +0 -22
- package/dist/init/templates/harmony/hvigorfile.ts +0 -7
|
@@ -1,146 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.ComponentUtilsTSTemplate = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{
|
|
11
|
-
|
|
12
|
-
{{/codegenNoticeLines}}
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
Descriptor as ComponentDescriptor,
|
|
17
|
-
ViewBaseProps,
|
|
18
|
-
ViewRawProps,
|
|
19
|
-
ViewDescriptorWrapperBase,
|
|
20
|
-
ColorValue,
|
|
21
|
-
Color,
|
|
22
|
-
RNInstance,
|
|
23
|
-
Tag,
|
|
24
|
-
RNComponentCommandReceiver,
|
|
25
|
-
ViewPropsSelector,
|
|
26
|
-
} from '{{{rnohImport}}}';
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export namespace {{name}} {
|
|
30
|
-
export const NAME = "{{name}}" as const
|
|
31
|
-
|
|
32
|
-
export interface DirectRawProps {
|
|
33
|
-
{{#props}}
|
|
34
|
-
{{name}}{{optionalityMarker}}: {{{type}}};
|
|
35
|
-
{{/props}}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface Props extends ViewBaseProps {}
|
|
39
|
-
|
|
40
|
-
export interface State {}
|
|
41
|
-
|
|
42
|
-
export interface RawProps extends ViewRawProps, DirectRawProps {}
|
|
43
|
-
|
|
44
|
-
export class PropsSelector extends ViewPropsSelector<Props, RawProps> {
|
|
45
|
-
{{#simpleProps}}
|
|
46
|
-
get {{name}}() {
|
|
47
|
-
return this.rawProps.{{name}}{{{orDefaultValue}}};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
{{/simpleProps}}
|
|
51
|
-
|
|
52
|
-
{{#complexProps}}
|
|
53
|
-
get {{name}}() {
|
|
54
|
-
{{{implementation}}}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
{{/complexProps}}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export type Descriptor = ComponentDescriptor<
|
|
61
|
-
typeof NAME,
|
|
62
|
-
Props,
|
|
63
|
-
State,
|
|
64
|
-
RawProps
|
|
65
|
-
>;
|
|
66
|
-
|
|
67
|
-
export class DescriptorWrapper extends ViewDescriptorWrapperBase<
|
|
68
|
-
typeof NAME,
|
|
69
|
-
Props,
|
|
70
|
-
State,
|
|
71
|
-
RawProps,
|
|
72
|
-
PropsSelector
|
|
73
|
-
> {
|
|
74
|
-
protected createPropsSelector() {
|
|
75
|
-
return new PropsSelector(this.descriptor.props, this.descriptor.rawProps)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface EventPayloadByName {
|
|
80
|
-
{{#events}}
|
|
81
|
-
"{{name}}": {{{payloadTSType}}}
|
|
82
|
-
{{/events}}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export class EventEmitter {
|
|
86
|
-
constructor(private rnInstance: RNInstance, private tag: Tag) {}
|
|
87
|
-
|
|
88
|
-
emit<TEventName extends keyof EventPayloadByName>(eventName: TEventName, payload: EventPayloadByName[TEventName]) {
|
|
89
|
-
this.rnInstance.emitComponentEvent(this.tag, eventName, payload)
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export interface CommandArgvByName {
|
|
94
|
-
{{#commands}}
|
|
95
|
-
"{{name}}": {{{argsTSType}}}
|
|
96
|
-
{{/commands}}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export class CommandReceiver {
|
|
100
|
-
private listenersByCommandName = new Map<string, Set<(...args: any[]) => void>>()
|
|
101
|
-
private cleanUp: (() => void) | undefined = undefined
|
|
102
|
-
|
|
103
|
-
constructor(private componentCommandReceiver: RNComponentCommandReceiver, private tag: Tag) {
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
subscribe<TCommandName extends keyof CommandArgvByName>(commandName: TCommandName, listener: (argv: CommandArgvByName[TCommandName]) => void) {
|
|
107
|
-
if (!this.listenersByCommandName.has(commandName)) {
|
|
108
|
-
this.listenersByCommandName.set(commandName, new Set())
|
|
109
|
-
}
|
|
110
|
-
this.listenersByCommandName.get(commandName)!.add(listener)
|
|
111
|
-
const hasRegisteredCommandReceiver = !!this.cleanUp
|
|
112
|
-
if (!hasRegisteredCommandReceiver) {
|
|
113
|
-
this.cleanUp = this.componentCommandReceiver.registerCommandCallback(this.tag, (commandName: string, argv: any[]) => {
|
|
114
|
-
if (this.listenersByCommandName.has(commandName)) {
|
|
115
|
-
const listeners = this.listenersByCommandName.get(commandName)!
|
|
116
|
-
listeners.forEach(listener => {
|
|
117
|
-
listener(argv)
|
|
118
|
-
})
|
|
119
|
-
}
|
|
120
|
-
})
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return () => {
|
|
124
|
-
this.listenersByCommandName.get(commandName)?.delete(listener)
|
|
125
|
-
if (this.listenersByCommandName.get(commandName)?.size ?? 0 === 0) {
|
|
126
|
-
this.listenersByCommandName.delete(commandName)
|
|
127
|
-
}
|
|
128
|
-
if (this.listenersByCommandName.size === 0) {
|
|
129
|
-
this.cleanUp?.()
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
`;
|
|
137
|
-
const COLOR_VALUE_GETTER_TEMPLATE = ` if (this.rawProps.{{name}}) {
|
|
138
|
-
return Color.fromColorValue(this.rawProps.{{name}})
|
|
139
|
-
} else {
|
|
140
|
-
return new Color({ r: 0, g: 0, b: 0, a: 255})
|
|
141
|
-
}`;
|
|
142
|
-
class ComponentUtilsTSTemplate {
|
|
143
|
-
constructor(name, codegenNoticeLines, rnohImport) {
|
|
4
|
+
var mustache_1 = require("mustache");
|
|
5
|
+
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";
|
|
6
|
+
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 }";
|
|
7
|
+
var ComponentUtilsTSTemplate = /** @class */ (function () {
|
|
8
|
+
function ComponentUtilsTSTemplate(name, codegenNoticeLines, rnohImport) {
|
|
144
9
|
this.name = name;
|
|
145
10
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
146
11
|
this.rnohImport = rnohImport;
|
|
@@ -150,43 +15,45 @@ class ComponentUtilsTSTemplate {
|
|
|
150
15
|
this.getterTemplateByTSType = new Map();
|
|
151
16
|
this.getterTemplateByTSType.set('ColorValue', COLOR_VALUE_GETTER_TEMPLATE);
|
|
152
17
|
}
|
|
153
|
-
addProp(prop) {
|
|
18
|
+
ComponentUtilsTSTemplate.prototype.addProp = function (prop) {
|
|
154
19
|
this.props.push(prop);
|
|
155
|
-
}
|
|
156
|
-
addEvent(event) {
|
|
20
|
+
};
|
|
21
|
+
ComponentUtilsTSTemplate.prototype.addEvent = function (event) {
|
|
157
22
|
this.events.push(event);
|
|
158
|
-
}
|
|
159
|
-
addCommand(command) {
|
|
23
|
+
};
|
|
24
|
+
ComponentUtilsTSTemplate.prototype.addCommand = function (command) {
|
|
160
25
|
this.commands.push(command);
|
|
161
|
-
}
|
|
162
|
-
build() {
|
|
26
|
+
};
|
|
27
|
+
ComponentUtilsTSTemplate.prototype.build = function () {
|
|
28
|
+
var _this = this;
|
|
163
29
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
164
|
-
codegenNoticeLines: this.codegenNoticeLines.map((line)
|
|
165
|
-
line,
|
|
166
|
-
})),
|
|
30
|
+
codegenNoticeLines: this.codegenNoticeLines.map(function (line) { return ({
|
|
31
|
+
line: line,
|
|
32
|
+
}); }),
|
|
167
33
|
name: this.name,
|
|
168
34
|
rnohImport: this.rnohImport,
|
|
169
|
-
props: this.props.map((prop)
|
|
35
|
+
props: this.props.map(function (prop) { return ({
|
|
170
36
|
name: prop.name,
|
|
171
37
|
type: prop.tsType,
|
|
172
38
|
optionalityMarker: prop.isOptional ? '?' : '',
|
|
173
|
-
})),
|
|
39
|
+
}); }),
|
|
174
40
|
events: this.events,
|
|
175
41
|
commands: this.commands,
|
|
176
42
|
simpleProps: this.props
|
|
177
|
-
.filter((prop)
|
|
178
|
-
.map((prop)
|
|
43
|
+
.filter(function (prop) { return !_this.getterTemplateByTSType.has(prop.tsType); })
|
|
44
|
+
.map(function (prop) { return ({
|
|
179
45
|
name: prop.name,
|
|
180
46
|
type: prop.tsType,
|
|
181
|
-
orDefaultValue: prop.defaultValue ?
|
|
182
|
-
})),
|
|
47
|
+
orDefaultValue: prop.defaultValue ? " ?? ".concat(prop.defaultValue) : '',
|
|
48
|
+
}); }),
|
|
183
49
|
complexProps: this.props
|
|
184
|
-
.filter((prop)
|
|
185
|
-
.map((prop)
|
|
50
|
+
.filter(function (prop) { return _this.getterTemplateByTSType.has(prop.tsType); })
|
|
51
|
+
.map(function (prop) { return ({
|
|
186
52
|
name: prop.name,
|
|
187
|
-
implementation: mustache_1.default.render(
|
|
188
|
-
})),
|
|
53
|
+
implementation: mustache_1.default.render(_this.getterTemplateByTSType.get(prop.tsType), { name: prop.name }, {}),
|
|
54
|
+
}); }),
|
|
189
55
|
});
|
|
190
|
-
}
|
|
191
|
-
|
|
56
|
+
};
|
|
57
|
+
return ComponentUtilsTSTemplate;
|
|
58
|
+
}());
|
|
192
59
|
exports.ComponentUtilsTSTemplate = ComponentUtilsTSTemplate;
|
|
@@ -1,52 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.IndexTSTemplate = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{
|
|
11
|
-
|
|
12
|
-
{{/codegenNoticeLines}}
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
{{#reexports}}
|
|
16
|
-
export * {{as}}from "{{{from}}}"
|
|
17
|
-
{{/reexports}}
|
|
18
|
-
`;
|
|
19
|
-
const TEMPLATE_EMPTY = `
|
|
20
|
-
/**
|
|
21
|
-
{{#codegenNoticeLines}}
|
|
22
|
-
* {{{line}}}
|
|
23
|
-
{{/codegenNoticeLines}}
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
export {}
|
|
27
|
-
`;
|
|
28
|
-
class IndexTSTemplate {
|
|
29
|
-
constructor(codegenNoticeLines) {
|
|
4
|
+
var mustache_1 = require("mustache");
|
|
5
|
+
var TEMPLATE = "\n/**\n{{#codegenNoticeLines}}\n * {{{line}}}\n{{/codegenNoticeLines}}\n */\n\n{{#reexports}}\nexport * {{as}}from \"{{{from}}}\"\n{{/reexports}}\n";
|
|
6
|
+
var TEMPLATE_EMPTY = "\n/**\n{{#codegenNoticeLines}}\n * {{{line}}}\n{{/codegenNoticeLines}}\n */\n\nexport {}\n";
|
|
7
|
+
var IndexTSTemplate = /** @class */ (function () {
|
|
8
|
+
function IndexTSTemplate(codegenNoticeLines) {
|
|
30
9
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
31
10
|
this.reexports = [];
|
|
32
11
|
}
|
|
33
|
-
addReexport(reexport) {
|
|
12
|
+
IndexTSTemplate.prototype.addReexport = function (reexport) {
|
|
34
13
|
this.reexports.push(reexport);
|
|
35
14
|
return this;
|
|
36
|
-
}
|
|
37
|
-
build() {
|
|
15
|
+
};
|
|
16
|
+
IndexTSTemplate.prototype.build = function () {
|
|
38
17
|
if (this.reexports.length === 0) {
|
|
39
18
|
return mustache_1.default.render(TEMPLATE_EMPTY, {});
|
|
40
19
|
}
|
|
41
20
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
42
|
-
codegenNoticeLines: this.codegenNoticeLines.map((line)
|
|
43
|
-
line,
|
|
44
|
-
})),
|
|
45
|
-
reexports: this.reexports.map((reexport)
|
|
21
|
+
codegenNoticeLines: this.codegenNoticeLines.map(function (line) { return ({
|
|
22
|
+
line: line,
|
|
23
|
+
}); }),
|
|
24
|
+
reexports: this.reexports.map(function (reexport) { return ({
|
|
46
25
|
from: reexport.from,
|
|
47
|
-
as: reexport.as ?
|
|
48
|
-
})),
|
|
26
|
+
as: reexport.as ? "as ".concat(reexport.as, " ") : '',
|
|
27
|
+
}); }),
|
|
49
28
|
});
|
|
50
|
-
}
|
|
51
|
-
|
|
29
|
+
};
|
|
30
|
+
return IndexTSTemplate;
|
|
31
|
+
}());
|
|
52
32
|
exports.IndexTSTemplate = IndexTSTemplate;
|
|
@@ -1,135 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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: 1
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
#pragma once
|
|
19
|
-
|
|
20
|
-
#include "RNOH/Package.h"
|
|
21
|
-
#include "RNOH/ArkTSTurboModule.h"
|
|
22
|
-
{{#turboModules}}
|
|
23
|
-
#include "generated/{{name}}.h"
|
|
24
|
-
{{/turboModules}}
|
|
25
|
-
{{#components}}
|
|
26
|
-
#include "generated/{{name}}ComponentDescriptor.h"
|
|
27
|
-
{{/components}}
|
|
28
|
-
{{#components}}
|
|
29
|
-
#include "generated/{{name}}JSIBinder.h"
|
|
30
|
-
{{/components}}
|
|
31
|
-
|
|
32
|
-
namespace rnoh {
|
|
33
|
-
|
|
34
|
-
class RNOHGeneratedPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
|
|
35
|
-
public:
|
|
36
|
-
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
|
|
37
|
-
{{#turboModules}}
|
|
38
|
-
if (name == "{{name}}") {
|
|
39
|
-
return std::make_shared<{{name}}>(ctx, name);
|
|
40
|
-
}
|
|
41
|
-
{{/turboModules}}
|
|
42
|
-
return nullptr;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
class GeneratedEventEmitRequestHandler : public EventEmitRequestHandler {
|
|
47
|
-
public:
|
|
48
|
-
void handleEvent(Context const &ctx) override {
|
|
49
|
-
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
|
|
50
|
-
auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag);
|
|
51
|
-
|
|
52
|
-
if (eventEmitter == nullptr) {
|
|
53
|
-
return;
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
54
7
|
}
|
|
55
|
-
|
|
56
|
-
std::vector<std::string> supportedComponentNames = {
|
|
57
|
-
{{#arkTSComponents}}
|
|
58
|
-
"{{name}}",
|
|
59
|
-
{{/arkTSComponents}}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
std::vector<std::string> supportedEventNames = {
|
|
63
|
-
{{#supportedEvents}}
|
|
64
|
-
"{{name}}",
|
|
65
|
-
{{/supportedEvents}}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() &&
|
|
69
|
-
std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
|
|
70
|
-
eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
|
|
71
|
-
}
|
|
72
8
|
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
73
10
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
RNOHGeneratedPackage(Package::Context ctx) : Package(ctx){};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return std::make_unique<RNOHGeneratedPackageTurboModuleFactoryDelegate>();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
|
|
84
|
-
return {
|
|
85
|
-
{{#components}}
|
|
86
|
-
facebook::react::concreteComponentDescriptorProvider<facebook::react::{{name}}ComponentDescriptor>(),
|
|
87
|
-
{{/components}}
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
ComponentJSIBinderByString createComponentJSIBinderByName() override {
|
|
92
|
-
return {
|
|
93
|
-
{{#components}}
|
|
94
|
-
{"{{name}}", std::make_shared<{{name}}JSIBinder>()},
|
|
95
|
-
{{/components}}
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
EventEmitRequestHandlers createEventEmitRequestHandlers() override {
|
|
100
|
-
return {
|
|
101
|
-
std::make_shared<GeneratedEventEmitRequestHandler>(),
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
} // namespace rnoh
|
|
107
|
-
`;
|
|
108
|
-
class RNOHGeneratedPackageHTemplate {
|
|
109
|
-
constructor() {
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RNOHGeneratedPackageHTemplate = void 0;
|
|
13
|
+
var mustache_1 = require("mustache");
|
|
14
|
+
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";
|
|
15
|
+
var RNOHGeneratedPackageHTemplate = /** @class */ (function () {
|
|
16
|
+
function RNOHGeneratedPackageHTemplate() {
|
|
110
17
|
this.turboModules = [];
|
|
111
18
|
this.components = [];
|
|
112
19
|
this.supportedEventNames = [];
|
|
113
20
|
}
|
|
114
|
-
addTurboModule(turboModule) {
|
|
21
|
+
RNOHGeneratedPackageHTemplate.prototype.addTurboModule = function (turboModule) {
|
|
115
22
|
this.turboModules.push(turboModule);
|
|
116
|
-
}
|
|
117
|
-
addComponent(component) {
|
|
23
|
+
};
|
|
24
|
+
RNOHGeneratedPackageHTemplate.prototype.addComponent = function (component) {
|
|
118
25
|
this.components.push(component);
|
|
119
|
-
this.supportedEventNames = [
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
];
|
|
123
|
-
}
|
|
124
|
-
build() {
|
|
26
|
+
this.supportedEventNames = __spreadArray(__spreadArray([], this.supportedEventNames, true), component.supportedEventNames, true);
|
|
27
|
+
};
|
|
28
|
+
RNOHGeneratedPackageHTemplate.prototype.build = function () {
|
|
125
29
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
126
30
|
turboModules: this.turboModules,
|
|
127
31
|
components: this.components,
|
|
128
|
-
arkTSComponents: this.components.filter((component)
|
|
129
|
-
supportedEvents: this.supportedEventNames.map((eventName)
|
|
32
|
+
arkTSComponents: this.components.filter(function (component) { return component.isArkTSComponent; }),
|
|
33
|
+
supportedEvents: this.supportedEventNames.map(function (eventName) { return ({
|
|
130
34
|
name: eventName,
|
|
131
|
-
})),
|
|
35
|
+
}); }),
|
|
132
36
|
});
|
|
133
|
-
}
|
|
134
|
-
|
|
37
|
+
};
|
|
38
|
+
return RNOHGeneratedPackageHTemplate;
|
|
39
|
+
}());
|
|
135
40
|
exports.RNOHGeneratedPackageHTemplate = RNOHGeneratedPackageHTemplate;
|
|
@@ -1,53 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.TurboModuleCppTemplate = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
{
|
|
11
|
-
* {{{line}}}
|
|
12
|
-
{{/codegenNoticeLines}}
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
#include "{{className}}.h"
|
|
16
|
-
|
|
17
|
-
namespace rnoh {
|
|
18
|
-
using namespace facebook;
|
|
19
|
-
|
|
20
|
-
{{className}}::{{className}}(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) {
|
|
21
|
-
methodMap_ = {
|
|
22
|
-
{{#methods}}
|
|
23
|
-
ARK_{{asyncMarker}}METHOD_METADATA({{name}}, {{argsCount}}),
|
|
24
|
-
{{/methods}}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
} // namespace rnoh
|
|
29
|
-
`;
|
|
30
|
-
class TurboModuleCppTemplate {
|
|
31
|
-
constructor(name, codegenNoticeLines) {
|
|
4
|
+
var mustache_1 = require("mustache");
|
|
5
|
+
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";
|
|
6
|
+
var TurboModuleCppTemplate = /** @class */ (function () {
|
|
7
|
+
function TurboModuleCppTemplate(name, codegenNoticeLines) {
|
|
32
8
|
this.name = name;
|
|
33
9
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
34
10
|
this.methods = [];
|
|
35
11
|
}
|
|
36
|
-
addMethod(method) {
|
|
12
|
+
TurboModuleCppTemplate.prototype.addMethod = function (method) {
|
|
37
13
|
this.methods.push(method);
|
|
38
|
-
}
|
|
39
|
-
build() {
|
|
14
|
+
};
|
|
15
|
+
TurboModuleCppTemplate.prototype.build = function () {
|
|
40
16
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
41
|
-
codegenNoticeLines: this.codegenNoticeLines.map((line)
|
|
42
|
-
line,
|
|
43
|
-
})),
|
|
17
|
+
codegenNoticeLines: this.codegenNoticeLines.map(function (line) { return ({
|
|
18
|
+
line: line,
|
|
19
|
+
}); }),
|
|
44
20
|
className: this.name,
|
|
45
|
-
methods: this.methods.map((method)
|
|
21
|
+
methods: this.methods.map(function (method) { return ({
|
|
46
22
|
name: method.name,
|
|
47
23
|
argsCount: method.argsCount,
|
|
48
24
|
asyncMarker: method.isAsync ? 'ASYNC_' : undefined,
|
|
49
|
-
})),
|
|
25
|
+
}); }),
|
|
50
26
|
});
|
|
51
|
-
}
|
|
52
|
-
|
|
27
|
+
};
|
|
28
|
+
return TurboModuleCppTemplate;
|
|
29
|
+
}());
|
|
53
30
|
exports.TurboModuleCppTemplate = TurboModuleCppTemplate;
|
|
@@ -1,42 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.TurboModuleHTemplate = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
{
|
|
11
|
-
* {{{line}}}
|
|
12
|
-
{{/codegenNoticeLines}}
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
#pragma once
|
|
16
|
-
|
|
17
|
-
#include "RNOH/ArkTSTurboModule.h"
|
|
18
|
-
|
|
19
|
-
namespace rnoh {
|
|
20
|
-
|
|
21
|
-
class JSI_EXPORT {{className}} : public ArkTSTurboModule {
|
|
22
|
-
public:
|
|
23
|
-
{{className}}(const ArkTSTurboModule::Context ctx, const std::string name);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
} // namespace rnoh
|
|
27
|
-
`;
|
|
28
|
-
class TurboModuleHTemplate {
|
|
29
|
-
constructor(name, codegenNoticeLines) {
|
|
4
|
+
var mustache_1 = require("mustache");
|
|
5
|
+
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";
|
|
6
|
+
var TurboModuleHTemplate = /** @class */ (function () {
|
|
7
|
+
function TurboModuleHTemplate(name, codegenNoticeLines) {
|
|
30
8
|
this.name = name;
|
|
31
9
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
32
10
|
}
|
|
33
|
-
build() {
|
|
11
|
+
TurboModuleHTemplate.prototype.build = function () {
|
|
34
12
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
35
13
|
className: this.name,
|
|
36
|
-
codegenNoticeLines: this.codegenNoticeLines.map((line)
|
|
37
|
-
line,
|
|
38
|
-
})),
|
|
14
|
+
codegenNoticeLines: this.codegenNoticeLines.map(function (line) { return ({
|
|
15
|
+
line: line,
|
|
16
|
+
}); }),
|
|
39
17
|
});
|
|
40
|
-
}
|
|
41
|
-
|
|
18
|
+
};
|
|
19
|
+
return TurboModuleHTemplate;
|
|
20
|
+
}());
|
|
42
21
|
exports.TurboModuleHTemplate = TurboModuleHTemplate;
|