@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,49 +1,75 @@
|
|
|
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.BaseComponentInstanceHTemplate = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const mustache_1 = __importDefault(require("mustache"));
|
|
8
|
+
const case_1 = __importDefault(require("case"));
|
|
9
|
+
const TEMPLATE = `
|
|
10
|
+
/**
|
|
11
|
+
{{#codegenNoticeLines}}
|
|
12
|
+
* {{{line}}}
|
|
13
|
+
{{/codegenNoticeLines}}
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
#pragma once
|
|
17
|
+
|
|
18
|
+
#include "RNOH/CppComponentInstance.h"
|
|
19
|
+
#include <react/renderer/components/{{libraryName}}/ShadowNodes.h>
|
|
20
|
+
|
|
21
|
+
namespace rnoh {
|
|
22
|
+
class Base{{name}}ComponentInstance
|
|
23
|
+
: public CppComponentInstance<facebook::react::{{name}}ShadowNode> {
|
|
24
|
+
public:
|
|
25
|
+
using CppComponentInstance::CppComponentInstance;
|
|
26
|
+
|
|
27
|
+
void handleCommand(std::string const &commandName, folly::dynamic const &args) override {
|
|
28
|
+
{{#commands}}
|
|
29
|
+
if (commandName == "{{commandName}}") {
|
|
30
|
+
this->on{{CommandName}}Command({{argsFromDynamic}});
|
|
31
|
+
}
|
|
32
|
+
{{/commands}}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
{{#commands}}
|
|
36
|
+
virtual void on{{CommandName}}Command({{argsDeclaration}}) = 0;
|
|
37
|
+
{{/commands}}
|
|
38
|
+
};
|
|
39
|
+
} // namespace rnoh
|
|
40
|
+
`;
|
|
41
|
+
class BaseComponentInstanceHTemplate {
|
|
42
|
+
constructor(componentName, libraryName, codegenNoticeLines) {
|
|
9
43
|
this.componentName = componentName;
|
|
10
44
|
this.libraryName = libraryName;
|
|
11
45
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
12
46
|
this.commands = [];
|
|
13
47
|
}
|
|
14
|
-
|
|
48
|
+
addCommand(command) {
|
|
15
49
|
this.commands.push(command);
|
|
16
|
-
}
|
|
17
|
-
|
|
50
|
+
}
|
|
51
|
+
build() {
|
|
18
52
|
return mustache_1.default.render(TEMPLATE, {
|
|
19
|
-
codegenNoticeLines: this.codegenNoticeLines.map(
|
|
20
|
-
line
|
|
21
|
-
})
|
|
53
|
+
codegenNoticeLines: this.codegenNoticeLines.map((line) => ({
|
|
54
|
+
line,
|
|
55
|
+
})),
|
|
22
56
|
name: this.componentName,
|
|
23
57
|
libraryName: this.libraryName,
|
|
24
|
-
commands: this.commands.map(
|
|
25
|
-
var name = _a.name, args = _a.args;
|
|
58
|
+
commands: this.commands.map(({ name, args }) => {
|
|
26
59
|
return {
|
|
27
60
|
commandName: name,
|
|
28
61
|
CommandName: case_1.default.pascal(name),
|
|
29
62
|
argsDeclaration: args
|
|
30
|
-
.map(
|
|
31
|
-
var name = _a.name, typeAnnotation = _a.typeAnnotation;
|
|
32
|
-
return "".concat(cppTypeFromTypeAnnotation(typeAnnotation), " ").concat(name);
|
|
33
|
-
})
|
|
63
|
+
.map(({ name, typeAnnotation }) => `${cppTypeFromTypeAnnotation(typeAnnotation)} ${name}`)
|
|
34
64
|
.join(', '),
|
|
35
65
|
argsFromDynamic: args
|
|
36
|
-
.map(
|
|
37
|
-
var typeAnnotation = _a.typeAnnotation;
|
|
38
|
-
return "args[".concat(index, "]").concat(dynamicExtractorFromTypeAnnotation(typeAnnotation));
|
|
39
|
-
})
|
|
66
|
+
.map(({ typeAnnotation }, index) => `args[${index}]${dynamicExtractorFromTypeAnnotation(typeAnnotation)}`)
|
|
40
67
|
.join(', '),
|
|
41
68
|
};
|
|
42
69
|
}),
|
|
43
70
|
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
}());
|
|
71
|
+
}
|
|
72
|
+
}
|
|
47
73
|
exports.BaseComponentInstanceHTemplate = BaseComponentInstanceHTemplate;
|
|
48
74
|
function cppTypeFromTypeAnnotation(typeAnnotation) {
|
|
49
75
|
switch (typeAnnotation.type) {
|
|
@@ -1,10 +1,110 @@
|
|
|
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.BasePackageHTemplate = 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
|
+
{{#libraries}}
|
|
18
|
+
#include <react/renderer/components/{{name}}/ComponentDescriptors.h>
|
|
19
|
+
{{/libraries}}
|
|
20
|
+
#include "RNOH/Package.h"
|
|
21
|
+
#include "RNOH/ArkTSTurboModule.h"
|
|
22
|
+
{{#turboModules}}
|
|
23
|
+
#include "RNOH/generated/turbo_modules/{{name}}.h"
|
|
24
|
+
{{/turboModules}}
|
|
25
|
+
{{#components}}
|
|
26
|
+
#include "RNOH/generated/components/{{name}}JSIBinder.h"
|
|
27
|
+
{{/components}}
|
|
28
|
+
|
|
29
|
+
namespace rnoh {
|
|
30
|
+
|
|
31
|
+
class {{name}}TurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
|
|
32
|
+
public:
|
|
33
|
+
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
|
|
34
|
+
{{#turboModules}}
|
|
35
|
+
if (name == "{{name}}") {
|
|
36
|
+
return std::make_shared<{{name}}>(ctx, name);
|
|
37
|
+
}
|
|
38
|
+
{{/turboModules}}
|
|
39
|
+
return nullptr;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
class {{name}}EventEmitRequestHandler : public EventEmitRequestHandler {
|
|
44
|
+
public:
|
|
45
|
+
void handleEvent(Context const &ctx) override {
|
|
46
|
+
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
|
|
47
|
+
auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag);
|
|
48
|
+
|
|
49
|
+
if (eventEmitter == nullptr) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
std::vector<std::string> supportedComponentNames = {
|
|
54
|
+
{{#arkTSComponents}}
|
|
55
|
+
"{{name}}",
|
|
56
|
+
{{/arkTSComponents}}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
std::vector<std::string> supportedEventNames = {
|
|
60
|
+
{{#arkTSEvents}}
|
|
61
|
+
"{{name}}",
|
|
62
|
+
{{/arkTSEvents}}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() &&
|
|
66
|
+
std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
|
|
67
|
+
eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class {{name}} : public Package {
|
|
74
|
+
public:
|
|
75
|
+
{{name}}(Package::Context ctx) : Package(ctx){};
|
|
76
|
+
|
|
77
|
+
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
|
|
78
|
+
return std::make_unique<{{name}}TurboModuleFactoryDelegate>();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
|
|
82
|
+
return {
|
|
83
|
+
{{#components}}
|
|
84
|
+
facebook::react::concreteComponentDescriptorProvider<facebook::react::{{name}}ComponentDescriptor>(),
|
|
85
|
+
{{/components}}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
ComponentJSIBinderByString createComponentJSIBinderByName() override {
|
|
90
|
+
return {
|
|
91
|
+
{{#components}}
|
|
92
|
+
{"{{name}}", std::make_shared<{{name}}JSIBinder>()},
|
|
93
|
+
{{/components}}
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
EventEmitRequestHandlers createEventEmitRequestHandlers() override {
|
|
98
|
+
return {
|
|
99
|
+
std::make_shared<{{name}}EventEmitRequestHandler>(),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
} // namespace rnoh
|
|
105
|
+
`;
|
|
106
|
+
class BasePackageHTemplate {
|
|
107
|
+
constructor(name, codegenNoticeLines) {
|
|
8
108
|
this.name = name;
|
|
9
109
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
10
110
|
this.turboModules = [];
|
|
@@ -12,31 +112,30 @@ var BasePackageHTemplate = /** @class */ (function () {
|
|
|
12
112
|
this.arkTSEvents = [];
|
|
13
113
|
this.libraryCppNames = new Set();
|
|
14
114
|
}
|
|
15
|
-
|
|
115
|
+
addTurboModule(turboModule) {
|
|
16
116
|
this.turboModules.push(turboModule);
|
|
17
|
-
}
|
|
18
|
-
|
|
117
|
+
}
|
|
118
|
+
addComponent(component) {
|
|
19
119
|
this.components.push(component);
|
|
20
120
|
this.libraryCppNames.add(component.libraryCppName);
|
|
21
|
-
}
|
|
22
|
-
|
|
121
|
+
}
|
|
122
|
+
addArkTSEvent(arkTSEvent) {
|
|
23
123
|
this.arkTSEvents.push(arkTSEvent);
|
|
24
|
-
}
|
|
25
|
-
|
|
124
|
+
}
|
|
125
|
+
build() {
|
|
26
126
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
27
|
-
codegenNoticeLines: this.codegenNoticeLines.map(
|
|
28
|
-
line
|
|
29
|
-
})
|
|
127
|
+
codegenNoticeLines: this.codegenNoticeLines.map((line) => ({
|
|
128
|
+
line,
|
|
129
|
+
})),
|
|
30
130
|
name: this.name,
|
|
31
131
|
turboModules: this.turboModules,
|
|
32
132
|
components: this.components,
|
|
33
|
-
arkTSComponents: this.components.filter(
|
|
133
|
+
arkTSComponents: this.components.filter((component) => component.isArkTSComponent),
|
|
34
134
|
arkTSEvents: this.arkTSEvents,
|
|
35
|
-
libraries: Array.from(this.libraryCppNames).map(
|
|
36
|
-
name
|
|
37
|
-
})
|
|
135
|
+
libraries: Array.from(this.libraryCppNames).map((name) => ({
|
|
136
|
+
name,
|
|
137
|
+
})),
|
|
38
138
|
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
}());
|
|
139
|
+
}
|
|
140
|
+
}
|
|
42
141
|
exports.BasePackageHTemplate = BasePackageHTemplate;
|
|
@@ -1,17 +1,63 @@
|
|
|
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.ComponentDescriptorHTemplate = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
21
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
22
|
+
#include <react/renderer/components/view/ViewShadowNode.h>
|
|
23
|
+
|
|
24
|
+
namespace facebook {
|
|
25
|
+
namespace react {
|
|
26
|
+
|
|
27
|
+
// RNOH patch
|
|
28
|
+
constexpr char {{name}}ComponentName[] = "{{name}}";
|
|
29
|
+
|
|
30
|
+
class {{name}}Props : public ViewProps {
|
|
31
|
+
public:
|
|
32
|
+
{{name}}Props() = default;
|
|
33
|
+
|
|
34
|
+
{{name}}Props(const PropsParserContext &context, const {{name}}Props &sourceProps, const RawProps &rawProps)
|
|
35
|
+
: ViewProps(context, sourceProps, rawProps) {}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
using {{name}}ShadowNode = ConcreteViewShadowNode<
|
|
39
|
+
{{name}}ComponentName,
|
|
40
|
+
{{name}}Props,
|
|
41
|
+
ViewEventEmitter>;
|
|
42
|
+
|
|
43
|
+
class {{name}}ComponentDescriptor final
|
|
44
|
+
: public ConcreteComponentDescriptor<{{name}}ShadowNode> {
|
|
45
|
+
public:
|
|
46
|
+
{{name}}ComponentDescriptor(ComponentDescriptorParameters const ¶meters)
|
|
47
|
+
: ConcreteComponentDescriptor(parameters) {}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
} // namespace react
|
|
51
|
+
} // namespace facebook
|
|
52
|
+
`;
|
|
53
|
+
class ComponentDescriptorHTemplate {
|
|
54
|
+
constructor(name) {
|
|
8
55
|
this.name = name;
|
|
9
56
|
}
|
|
10
|
-
|
|
57
|
+
build() {
|
|
11
58
|
return mustache_1.default.render(TEMPLATE, {
|
|
12
59
|
name: this.name,
|
|
13
60
|
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
}());
|
|
61
|
+
}
|
|
62
|
+
}
|
|
17
63
|
exports.ComponentDescriptorHTemplate = ComponentDescriptorHTemplate;
|
|
@@ -1,52 +1,100 @@
|
|
|
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.ComponentJSIBinderHTemplate = 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
|
+
#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
|
|
17
|
+
|
|
18
|
+
namespace rnoh {
|
|
19
|
+
class {{name}}JSIBinder : public ViewComponentJSIBinder {
|
|
20
|
+
protected:
|
|
21
|
+
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
|
|
22
|
+
auto object = ViewComponentJSIBinder::createNativeProps(rt);
|
|
23
|
+
{{#props}}
|
|
24
|
+
object.setProperty(rt, "{{name}}", {{{type}}});
|
|
25
|
+
{{/props}}
|
|
26
|
+
return object;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
facebook::jsi::Object createCommands(facebook::jsi::Runtime &rt) override {
|
|
30
|
+
auto commands = ViewComponentJSIBinder::createCommands(rt);
|
|
31
|
+
{{#commands}}
|
|
32
|
+
commands.setProperty(rt, "{{name}}", "{{name}}");
|
|
33
|
+
{{/commands}}
|
|
34
|
+
return commands;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override {
|
|
38
|
+
facebook::jsi::Object events(rt);
|
|
39
|
+
{{#bubblingEvents}}
|
|
40
|
+
events.setProperty(rt, "{{TOPname}}", createBubblingCapturedEvent(rt, "{{name}}"));
|
|
41
|
+
{{/bubblingEvents}}
|
|
42
|
+
return events;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override {
|
|
46
|
+
facebook::jsi::Object events(rt);
|
|
47
|
+
{{#directEvents}}
|
|
48
|
+
events.setProperty(rt, "{{TOPname}}", createDirectEvent(rt, "{{name}}"));
|
|
49
|
+
{{/directEvents}}
|
|
50
|
+
return events;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
} // namespace rnoh
|
|
54
|
+
`;
|
|
55
|
+
class ComponentJSIBinderHTemplate {
|
|
56
|
+
constructor(name, codegenNoticeLines) {
|
|
8
57
|
this.name = name;
|
|
9
58
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
10
59
|
this.props = [];
|
|
11
60
|
this.commands = [];
|
|
12
61
|
this.events = [];
|
|
13
62
|
}
|
|
14
|
-
|
|
63
|
+
addProp(prop) {
|
|
15
64
|
this.props.push(prop);
|
|
16
|
-
}
|
|
17
|
-
|
|
65
|
+
}
|
|
66
|
+
addCommand(command) {
|
|
18
67
|
this.commands.push(command);
|
|
19
|
-
}
|
|
20
|
-
|
|
68
|
+
}
|
|
69
|
+
addEvent(event) {
|
|
21
70
|
this.events.push(event);
|
|
22
|
-
}
|
|
23
|
-
|
|
71
|
+
}
|
|
72
|
+
build() {
|
|
24
73
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
25
|
-
codegenNoticeLines: this.codegenNoticeLines.map(
|
|
26
|
-
line
|
|
27
|
-
})
|
|
74
|
+
codegenNoticeLines: this.codegenNoticeLines.map((line) => ({
|
|
75
|
+
line,
|
|
76
|
+
})),
|
|
28
77
|
name: this.name,
|
|
29
|
-
props: this.props.map(
|
|
78
|
+
props: this.props.map((prop) => ({
|
|
30
79
|
name: prop.name,
|
|
31
80
|
type: prop.isObject ? '"Object"' : 'true',
|
|
32
|
-
})
|
|
33
|
-
commands: this.commands.map(
|
|
81
|
+
})),
|
|
82
|
+
commands: this.commands.map((command) => ({
|
|
34
83
|
name: command.name,
|
|
35
|
-
})
|
|
84
|
+
})),
|
|
36
85
|
bubblingEvents: this.events
|
|
37
|
-
.filter(
|
|
38
|
-
.map(
|
|
86
|
+
.filter((event) => event.type === 'bubble')
|
|
87
|
+
.map((event) => ({
|
|
39
88
|
TOPname: event.eventHandlerName.replace('on', 'top'),
|
|
40
89
|
name: event.eventHandlerName,
|
|
41
|
-
})
|
|
90
|
+
})),
|
|
42
91
|
directEvents: this.events
|
|
43
|
-
.filter(
|
|
44
|
-
.map(
|
|
92
|
+
.filter((event) => event.type === 'direct')
|
|
93
|
+
.map((event) => ({
|
|
45
94
|
TOPname: event.eventHandlerName.replace('on', 'top'),
|
|
46
95
|
name: event.eventHandlerName,
|
|
47
|
-
})
|
|
96
|
+
})),
|
|
48
97
|
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
}());
|
|
98
|
+
}
|
|
99
|
+
}
|
|
52
100
|
exports.ComponentJSIBinderHTemplate = ComponentJSIBinderHTemplate;
|