@react-native-oh/react-native-harmony-cli 0.77.33 → 0.77.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/dist/assetResolver.js +43 -74
- package/dist/autolinking/Autolinking.js +178 -179
- package/dist/codegen/core/CodegenError.js +3 -23
- package/dist/codegen/core/EventUtils.js +3 -3
- package/dist/codegen/core/TypeAnnotationToTS.js +24 -28
- package/dist/codegen/core/UberSchema.js +55 -97
- package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +28 -41
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +27 -34
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +25 -33
- package/dist/codegen/generators/CppComponentCodeGenerator.js +23 -28
- package/dist/codegen/generators/LibGlueCodeGenerator.js +26 -29
- package/dist/codegen/generators/NativeModuleCodeGenerator.js +25 -30
- package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
- package/dist/codegen/generators/UberGeneratorV1.js +24 -23
- package/dist/codegen/generators/UberGeneratorV2.js +34 -35
- package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +50 -24
- package/dist/codegen/templates/BasePackageHTemplate.js +120 -21
- package/dist/codegen/templates/ComponentDescriptorHTemplate.js +54 -8
- package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +75 -27
- package/dist/codegen/templates/ComponentUtilsTSTemplate.js +162 -29
- package/dist/codegen/templates/IndexTSTemplate.js +37 -17
- package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +119 -24
- package/dist/codegen/templates/TurboModuleCppTemplate.js +38 -15
- package/dist/codegen/templates/TurboModuleHTemplate.js +32 -11
- package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +52 -19
- package/dist/commands/bundle-harmony.js +118 -221
- package/dist/commands/clean-harmony.js +58 -63
- package/dist/commands/codegen-harmony.js +105 -165
- package/dist/commands/codegen-lib-harmony.js +76 -116
- package/dist/commands/init-harmony.js +151 -196
- package/dist/commands/init.js +537 -961
- package/dist/commands/link-harmony.js +35 -82
- package/dist/commands/run-harmony.js +372 -518
- package/dist/commands/verify-package-harmony.js +54 -117
- package/dist/core/AbsolutePath.js +33 -49
- package/dist/core/CodegenConfig.js +24 -22
- package/dist/core/DescriptiveError.js +18 -37
- package/dist/core/FileSystem.js +14 -18
- package/dist/core/OHPackageJSON5.js +17 -23
- package/dist/core/PackageJSON.js +26 -42
- package/dist/core/ProjectDependenciesManager.js +40 -92
- package/dist/core/ValidationError.js +2 -22
- package/dist/core/fs.js +10 -7
- package/dist/index.js +1 -1
- package/dist/init/templates/AppScopeAppJSON5Template.js +21 -8
- package/dist/init/templates/AppScopeStringVarTemplate.js +19 -8
- package/dist/init/templates/EntryIndexTemplate.js +56 -8
- package/dist/init/templates/EntryStringVarTemplate.js +27 -8
- package/dist/init/templates/HvigorConfigJson5Template.js +33 -8
- package/dist/init/templates/MetroConfigTemplate.js +38 -8
- package/dist/init/templates/OhPackageJson5Template.js +28 -8
- package/dist/init/templates/harmony/AppScope/app.json5 +10 -0
- package/dist/init/templates/harmony/AppScope/resources/base/element/string.json +8 -0
- package/dist/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
- package/dist/init/templates/harmony/build-profile.json5 +36 -0
- package/dist/init/templates/harmony/codelinter.json +32 -0
- package/dist/init/templates/harmony/entry/build-profile.json5 +18 -0
- package/dist/init/templates/harmony/entry/gitignore +7 -0
- package/dist/init/templates/harmony/entry/hvigorfile.ts +13 -0
- package/dist/init/templates/harmony/entry/oh-package.json5 +9 -0
- package/dist/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +27 -0
- package/dist/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +13 -0
- package/dist/init/templates/harmony/entry/src/main/cpp/gitignore +4 -0
- package/dist/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +8 -0
- package/dist/init/templates/harmony/entry/src/main/ets/codegen/gitignore +2 -0
- package/dist/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +11 -0
- package/dist/init/templates/harmony/entry/src/main/ets/gitignore +1 -0
- 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 +16 -0
- package/dist/init/templates/harmony/entry/src/main/module.json5 +65 -0
- package/dist/init/templates/harmony/entry/src/main/resources/base/element/color.json +8 -0
- package/dist/init/templates/harmony/entry/src/main/resources/base/element/string.json +16 -0
- 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 +7 -0
- 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 +5 -0
- package/dist/init/templates/harmony/entry/src/main/resources/gitignore +1 -0
- package/dist/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +2 -0
- package/dist/init/templates/harmony/entry/src/ohosTest/module.json5 +13 -0
- package/dist/init/templates/harmony/gitignore +16 -0
- package/dist/init/templates/harmony/hvigor/hvigor-config.json5 +22 -0
- package/dist/init/templates/harmony/hvigorfile.ts +7 -0
- package/dist/io/CliExecutor.js +46 -98
- package/dist/io/Logger.js +40 -46
- package/dist/io/RealFS.js +43 -100
- package/dist/io/TarGz.js +11 -8
- package/dist/io/__fixtures__.js +79 -141
- package/dist/io/fsUtils.js +13 -12
- package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +19 -47
- package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +13 -41
- package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +8 -38
- package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +22 -54
- package/dist/package-verifier/verify-package.js +56 -133
- package/dist/simulator/LaunchSimulator.js +224 -301
- package/harmony/rnoh-hvigor-plugin-0.77.40.tgz +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0271b9dd +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/07ba0208 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/082dd09d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0a9e1b0b +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0c3d528a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1014d3ff +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1184678c +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/12621366 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/126d3e66 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/19262852 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/203fac53 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/237b660a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2528002d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2587d041 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2893bd11 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2af6ff9d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2bf31f33 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/333648cc +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/386f6df0 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3b8c270e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3bcc34ba +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/444808bd +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/44a775e2 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/46da3ccd +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/51f80e35 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5203a2ca +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/52795646 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/577f8208 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5c2aafe7 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5c69bcfe +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/62695b92 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/62698102 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6411ab00 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6569ba92 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/65e5133c +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/66029655 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/69e85d0d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6afcb99e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6de07367 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/72498307 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7babd1de +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7fe56d21 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/810cbd72 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/812386d2 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8448897d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/84ab0a41 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/853825e2 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/862ad93a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/86b14da6 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/87f0fe62 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/88ee8f74 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8c5237c9 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8c725800 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8e83cbe1 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8f4085b9 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/931f0b2e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/940c8f92 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/968191a3 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/970780c0 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/98bc4394 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/99a3b0b0 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9c0ffa6b +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9d9b42c2 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a04266ef +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a18f78c5 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a642fb0e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a97edf40 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/aa672a20 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ae25c61a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b2bebae6 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ba492422 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/bd3e6c21 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/be9e564e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c342b18e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c3993e7e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c52ffd54 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c7079ad4 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c8eb01c1 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/caee5d30 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cf039161 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d0377c40 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d262bc85 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d287cb5c +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d64bff57 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d716a608 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d751012b +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e0873711 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e1fcf77b +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e8548d8a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/eaedd71d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/eca0019e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f7189953 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f75cb201 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f888164b +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/fdb9eb5a +0 -0
- package/package.json +1 -1
|
@@ -1,11 +1,146 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.ComponentUtilsTSTemplate = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const mustache_1 = __importDefault(require("mustache"));
|
|
8
|
+
const TEMPLATE = `
|
|
9
|
+
/**
|
|
10
|
+
{{#codegenNoticeLines}}
|
|
11
|
+
* {{{line}}}
|
|
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) {
|
|
9
144
|
this.name = name;
|
|
10
145
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
11
146
|
this.rnohImport = rnohImport;
|
|
@@ -15,45 +150,43 @@ var ComponentUtilsTSTemplate = /** @class */ (function () {
|
|
|
15
150
|
this.getterTemplateByTSType = new Map();
|
|
16
151
|
this.getterTemplateByTSType.set('ColorValue', COLOR_VALUE_GETTER_TEMPLATE);
|
|
17
152
|
}
|
|
18
|
-
|
|
153
|
+
addProp(prop) {
|
|
19
154
|
this.props.push(prop);
|
|
20
|
-
}
|
|
21
|
-
|
|
155
|
+
}
|
|
156
|
+
addEvent(event) {
|
|
22
157
|
this.events.push(event);
|
|
23
|
-
}
|
|
24
|
-
|
|
158
|
+
}
|
|
159
|
+
addCommand(command) {
|
|
25
160
|
this.commands.push(command);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var _this = this;
|
|
161
|
+
}
|
|
162
|
+
build() {
|
|
29
163
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
30
|
-
codegenNoticeLines: this.codegenNoticeLines.map(
|
|
31
|
-
line
|
|
32
|
-
})
|
|
164
|
+
codegenNoticeLines: this.codegenNoticeLines.map((line) => ({
|
|
165
|
+
line,
|
|
166
|
+
})),
|
|
33
167
|
name: this.name,
|
|
34
168
|
rnohImport: this.rnohImport,
|
|
35
|
-
props: this.props.map(
|
|
169
|
+
props: this.props.map((prop) => ({
|
|
36
170
|
name: prop.name,
|
|
37
171
|
type: prop.tsType,
|
|
38
172
|
optionalityMarker: prop.isOptional ? '?' : '',
|
|
39
|
-
})
|
|
173
|
+
})),
|
|
40
174
|
events: this.events,
|
|
41
175
|
commands: this.commands,
|
|
42
176
|
simpleProps: this.props
|
|
43
|
-
.filter(
|
|
44
|
-
.map(
|
|
177
|
+
.filter((prop) => !this.getterTemplateByTSType.has(prop.tsType))
|
|
178
|
+
.map((prop) => ({
|
|
45
179
|
name: prop.name,
|
|
46
180
|
type: prop.tsType,
|
|
47
|
-
orDefaultValue: prop.defaultValue ?
|
|
48
|
-
})
|
|
181
|
+
orDefaultValue: prop.defaultValue ? ` ?? ${prop.defaultValue}` : '',
|
|
182
|
+
})),
|
|
49
183
|
complexProps: this.props
|
|
50
|
-
.filter(
|
|
51
|
-
.map(
|
|
184
|
+
.filter((prop) => this.getterTemplateByTSType.has(prop.tsType))
|
|
185
|
+
.map((prop) => ({
|
|
52
186
|
name: prop.name,
|
|
53
|
-
implementation: mustache_1.default.render(
|
|
54
|
-
})
|
|
187
|
+
implementation: mustache_1.default.render(this.getterTemplateByTSType.get(prop.tsType), { name: prop.name }, {}),
|
|
188
|
+
})),
|
|
55
189
|
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
}());
|
|
190
|
+
}
|
|
191
|
+
}
|
|
59
192
|
exports.ComponentUtilsTSTemplate = ComponentUtilsTSTemplate;
|
|
@@ -1,32 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.IndexTSTemplate = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const mustache_1 = __importDefault(require("mustache"));
|
|
8
|
+
const TEMPLATE = `
|
|
9
|
+
/**
|
|
10
|
+
{{#codegenNoticeLines}}
|
|
11
|
+
* {{{line}}}
|
|
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) {
|
|
9
30
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
10
31
|
this.reexports = [];
|
|
11
32
|
}
|
|
12
|
-
|
|
33
|
+
addReexport(reexport) {
|
|
13
34
|
this.reexports.push(reexport);
|
|
14
35
|
return this;
|
|
15
|
-
}
|
|
16
|
-
|
|
36
|
+
}
|
|
37
|
+
build() {
|
|
17
38
|
if (this.reexports.length === 0) {
|
|
18
39
|
return mustache_1.default.render(TEMPLATE_EMPTY, {});
|
|
19
40
|
}
|
|
20
41
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
21
|
-
codegenNoticeLines: this.codegenNoticeLines.map(
|
|
22
|
-
line
|
|
23
|
-
})
|
|
24
|
-
reexports: this.reexports.map(
|
|
42
|
+
codegenNoticeLines: this.codegenNoticeLines.map((line) => ({
|
|
43
|
+
line,
|
|
44
|
+
})),
|
|
45
|
+
reexports: this.reexports.map((reexport) => ({
|
|
25
46
|
from: reexport.from,
|
|
26
|
-
as: reexport.as ?
|
|
27
|
-
})
|
|
47
|
+
as: reexport.as ? `as ${reexport.as} ` : '',
|
|
48
|
+
})),
|
|
28
49
|
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
}());
|
|
50
|
+
}
|
|
51
|
+
}
|
|
32
52
|
exports.IndexTSTemplate = IndexTSTemplate;
|
|
@@ -1,40 +1,135 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
if (ar || !(i in from)) {
|
|
5
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
-
ar[i] = from[i];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
4
|
};
|
|
11
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
6
|
exports.RNOHGeneratedPackageHTemplate = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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;
|
|
54
|
+
}
|
|
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
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
class RNOHGeneratedPackage : public Package {
|
|
76
|
+
public:
|
|
77
|
+
RNOHGeneratedPackage(Package::Context ctx) : Package(ctx){};
|
|
78
|
+
|
|
79
|
+
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
|
|
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() {
|
|
17
110
|
this.turboModules = [];
|
|
18
111
|
this.components = [];
|
|
19
112
|
this.supportedEventNames = [];
|
|
20
113
|
}
|
|
21
|
-
|
|
114
|
+
addTurboModule(turboModule) {
|
|
22
115
|
this.turboModules.push(turboModule);
|
|
23
|
-
}
|
|
24
|
-
|
|
116
|
+
}
|
|
117
|
+
addComponent(component) {
|
|
25
118
|
this.components.push(component);
|
|
26
|
-
this.supportedEventNames =
|
|
27
|
-
|
|
28
|
-
|
|
119
|
+
this.supportedEventNames = [
|
|
120
|
+
...this.supportedEventNames,
|
|
121
|
+
...component.supportedEventNames,
|
|
122
|
+
];
|
|
123
|
+
}
|
|
124
|
+
build() {
|
|
29
125
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
30
126
|
turboModules: this.turboModules,
|
|
31
127
|
components: this.components,
|
|
32
|
-
arkTSComponents: this.components.filter(
|
|
33
|
-
supportedEvents: this.supportedEventNames.map(
|
|
128
|
+
arkTSComponents: this.components.filter((component) => component.isArkTSComponent),
|
|
129
|
+
supportedEvents: this.supportedEventNames.map((eventName) => ({
|
|
34
130
|
name: eventName,
|
|
35
|
-
})
|
|
131
|
+
})),
|
|
36
132
|
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
}());
|
|
133
|
+
}
|
|
134
|
+
}
|
|
40
135
|
exports.RNOHGeneratedPackageHTemplate = RNOHGeneratedPackageHTemplate;
|
|
@@ -1,30 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.TurboModuleCppTemplate = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
const mustache_1 = __importDefault(require("mustache"));
|
|
8
|
+
const TEMPLATE = `
|
|
9
|
+
/**
|
|
10
|
+
{{#codegenNoticeLines}}
|
|
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) {
|
|
8
32
|
this.name = name;
|
|
9
33
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
10
34
|
this.methods = [];
|
|
11
35
|
}
|
|
12
|
-
|
|
36
|
+
addMethod(method) {
|
|
13
37
|
this.methods.push(method);
|
|
14
|
-
}
|
|
15
|
-
|
|
38
|
+
}
|
|
39
|
+
build() {
|
|
16
40
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
17
|
-
codegenNoticeLines: this.codegenNoticeLines.map(
|
|
18
|
-
line
|
|
19
|
-
})
|
|
41
|
+
codegenNoticeLines: this.codegenNoticeLines.map((line) => ({
|
|
42
|
+
line,
|
|
43
|
+
})),
|
|
20
44
|
className: this.name,
|
|
21
|
-
methods: this.methods.map(
|
|
45
|
+
methods: this.methods.map((method) => ({
|
|
22
46
|
name: method.name,
|
|
23
47
|
argsCount: method.argsCount,
|
|
24
48
|
asyncMarker: method.isAsync ? 'ASYNC_' : undefined,
|
|
25
|
-
})
|
|
49
|
+
})),
|
|
26
50
|
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
}());
|
|
51
|
+
}
|
|
52
|
+
}
|
|
30
53
|
exports.TurboModuleCppTemplate = TurboModuleCppTemplate;
|
|
@@ -1,21 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.TurboModuleHTemplate = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
const mustache_1 = __importDefault(require("mustache"));
|
|
8
|
+
const TEMPLATE = `
|
|
9
|
+
/**
|
|
10
|
+
{{#codegenNoticeLines}}
|
|
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) {
|
|
8
30
|
this.name = name;
|
|
9
31
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
10
32
|
}
|
|
11
|
-
|
|
33
|
+
build() {
|
|
12
34
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
13
35
|
className: this.name,
|
|
14
|
-
codegenNoticeLines: this.codegenNoticeLines.map(
|
|
15
|
-
line
|
|
16
|
-
})
|
|
36
|
+
codegenNoticeLines: this.codegenNoticeLines.map((line) => ({
|
|
37
|
+
line,
|
|
38
|
+
})),
|
|
17
39
|
});
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
}());
|
|
40
|
+
}
|
|
41
|
+
}
|
|
21
42
|
exports.TurboModuleHTemplate = TurboModuleHTemplate;
|