@react-native-oh/react-native-harmony-cli 0.0.40 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/dist/assetResolver.js +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 +57 -96
- 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 +53 -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 +53 -138
- package/dist/commands/codegen-harmony.js +105 -165
- package/dist/commands/codegen-lib-harmony.js +76 -116
- package/dist/commands/create-metro-host-constants.js +18 -47
- package/dist/commands/init.js +537 -961
- package/dist/commands/link-harmony.js +33 -71
- package/dist/commands/pack-harmony.js +47 -108
- package/dist/commands/run-harmony.js +372 -518
- package/dist/commands/unpack-harmony.js +105 -198
- package/dist/commands/verify-package-harmony.js +54 -108
- package/dist/core/AbsolutePath.js +31 -47
- 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 +9 -6
- package/dist/index.js +1 -1
- package/dist/io/CliExecutor.js +46 -98
- package/dist/io/Logger.js +40 -46
- package/dist/io/RealFS.js +35 -88
- 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 +55 -132
- package/dist/simulator/LaunchSimulator.js +224 -301
- package/harmony/rnoh-hvigor-plugin-0.3.0.tgz +0 -0
- package/jest.config.js +12 -12
- package/package.json +78 -78
- package/react-native.config.js +17 -17
- package/tsconfig.build.json +6 -6
- package/tsconfig.json +2 -2
|
@@ -14,53 +14,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
14
14
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
20
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
21
|
-
function step(op) {
|
|
22
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
23
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
24
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
25
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
26
|
-
switch (op[0]) {
|
|
27
|
-
case 0: case 1: t = op; break;
|
|
28
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
29
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
30
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
31
|
-
default:
|
|
32
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
33
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
34
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
35
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
36
|
-
if (t[2]) _.ops.pop();
|
|
37
|
-
_.trys.pop(); continue;
|
|
38
|
-
}
|
|
39
|
-
op = body.call(thisArg, _);
|
|
40
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
41
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
42
|
-
}
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
43
19
|
};
|
|
44
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
21
|
exports.UberSchema = void 0;
|
|
46
|
-
|
|
22
|
+
const core_1 = require("../../core");
|
|
47
23
|
// @ts-expect-error
|
|
48
|
-
|
|
49
|
-
|
|
24
|
+
const combine_js_to_schema_js_1 = __importDefault(require("@react-native/codegen/lib/cli/combine/combine-js-to-schema.js"));
|
|
25
|
+
const CodegenError_1 = require("./CodegenError");
|
|
50
26
|
function createRawUberSchemaFromSpecFilePaths(projectSourceFilePaths) {
|
|
51
|
-
return (0, combine_js_to_schema_js_1.default)(projectSourceFilePaths.map(
|
|
27
|
+
return (0, combine_js_to_schema_js_1.default)(projectSourceFilePaths.map((p) => p.getValue()));
|
|
52
28
|
}
|
|
53
29
|
/**
|
|
54
30
|
* Contains component and turbo module (NativeModule) schemas. The "Uber" word is used here to highlight that SpecSchemas don't extend this class.
|
|
55
31
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.schemaValue = schemaValue;
|
|
59
|
-
}
|
|
60
|
-
UberSchema.fromSpecFilePaths = function (specPaths) {
|
|
32
|
+
class UberSchema {
|
|
33
|
+
static fromSpecFilePaths(specPaths) {
|
|
61
34
|
return new UberSchema(createRawUberSchemaFromSpecFilePaths(specPaths));
|
|
62
|
-
}
|
|
63
|
-
|
|
35
|
+
}
|
|
36
|
+
static fromCodegenConfig(codegenConfig) {
|
|
64
37
|
try {
|
|
65
38
|
return new UberSchema(createRawUberSchemaFromSpecFilePaths(codegenConfig.getSpecFilePaths()));
|
|
66
39
|
}
|
|
@@ -69,76 +42,64 @@ var UberSchema = /** @class */ (function () {
|
|
|
69
42
|
throw new CodegenError_1.CodegenError({
|
|
70
43
|
whatHappened: "Couldn't create the schema",
|
|
71
44
|
whatCanUserDo: [
|
|
72
|
-
|
|
45
|
+
`There's probably at least one spec file defined in your project or in a third-party package that breaks some code generation restrictions. Please check the message below. If it's ambiguous, debug the problem with divide and conquer strategy.\n\n${err.message}`,
|
|
73
46
|
],
|
|
74
47
|
});
|
|
75
48
|
}
|
|
76
49
|
throw err;
|
|
77
50
|
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
var codegenConfigs = dependency.getCodegenConfigs();
|
|
97
|
-
for (var _i = 0, codegenConfigs_1 = codegenConfigs; _i < codegenConfigs_1.length; _i++) {
|
|
98
|
-
var codegenConfig = codegenConfigs_1[_i];
|
|
99
|
-
if (onShouldAcceptCodegenConfig_(codegenConfig.getVersion(), dependency.readPackageJSON().name)) {
|
|
100
|
-
acceptedCodegenConfigs.push(codegenConfig);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
})];
|
|
104
|
-
case 1:
|
|
105
|
-
_a.sent();
|
|
106
|
-
try {
|
|
107
|
-
return [2 /*return*/, new UberSchema(createRawUberSchemaFromSpecFilePaths(acceptedCodegenConfigs.flatMap(function (codegenConfig) {
|
|
108
|
-
return codegenConfig.getSpecFilePaths();
|
|
109
|
-
})))];
|
|
110
|
-
}
|
|
111
|
-
catch (err) {
|
|
112
|
-
if (err instanceof Error) {
|
|
113
|
-
throw new CodegenError_1.CodegenError({
|
|
114
|
-
whatHappened: "Couldn't create the schema",
|
|
115
|
-
whatCanUserDo: [
|
|
116
|
-
"There's probably at least one spec file defined in your project or in a third-party package that breaks some code generation restrictions. Please check the message below. If it's ambiguous, debug the problem with divide and conquer strategy.\n\n".concat(err.message),
|
|
117
|
-
],
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
throw err;
|
|
121
|
-
}
|
|
122
|
-
return [2 /*return*/];
|
|
51
|
+
}
|
|
52
|
+
static fromProject(fs, projectRootPath, onShouldAcceptCodegenConfig) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const onShouldAcceptCodegenConfig_ = onShouldAcceptCodegenConfig !== null && onShouldAcceptCodegenConfig !== void 0 ? onShouldAcceptCodegenConfig : ((x) => true);
|
|
55
|
+
const packageJSON = core_1.PackageJSON.fromProjectRootPath(fs, projectRootPath, projectRootPath);
|
|
56
|
+
const acceptedCodegenConfigs = [];
|
|
57
|
+
const appCodegenConfigs = packageJSON.getCodegenConfigs();
|
|
58
|
+
for (const codegenConfig of appCodegenConfigs) {
|
|
59
|
+
if (onShouldAcceptCodegenConfig_(codegenConfig.getVersion(), packageJSON.name)) {
|
|
60
|
+
acceptedCodegenConfigs.push(codegenConfig);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
yield new core_1.ProjectDependenciesManager(fs, projectRootPath).forEachAsync((dependency) => {
|
|
64
|
+
const codegenConfigs = dependency.getCodegenConfigs();
|
|
65
|
+
for (const codegenConfig of codegenConfigs) {
|
|
66
|
+
if (onShouldAcceptCodegenConfig_(codegenConfig.getVersion(), dependency.readPackageJSON().name)) {
|
|
67
|
+
acceptedCodegenConfigs.push(codegenConfig);
|
|
68
|
+
}
|
|
123
69
|
}
|
|
124
70
|
});
|
|
71
|
+
try {
|
|
72
|
+
return new UberSchema(createRawUberSchemaFromSpecFilePaths(acceptedCodegenConfigs.flatMap((codegenConfig) => codegenConfig.getSpecFilePaths())));
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
if (err instanceof Error) {
|
|
76
|
+
throw new CodegenError_1.CodegenError({
|
|
77
|
+
whatHappened: "Couldn't create the schema",
|
|
78
|
+
whatCanUserDo: [
|
|
79
|
+
`There's probably at least one spec file defined in your project or in a third-party package that breaks some code generation restrictions. Please check the message below. If it's ambiguous, debug the problem with divide and conquer strategy.\n\n${err.message}`,
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
throw err;
|
|
84
|
+
}
|
|
125
85
|
});
|
|
126
|
-
}
|
|
127
|
-
|
|
86
|
+
}
|
|
87
|
+
constructor(schemaValue) {
|
|
88
|
+
this.schemaValue = schemaValue;
|
|
89
|
+
}
|
|
90
|
+
getValue() {
|
|
128
91
|
return this.schemaValue;
|
|
129
|
-
}
|
|
130
|
-
|
|
92
|
+
}
|
|
93
|
+
findAllSpecSchemasByType(schemaType) {
|
|
131
94
|
return Object.values(this.schemaValue.modules)
|
|
132
|
-
.filter(
|
|
133
|
-
.map(
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return Object.entries(this.schemaValue.modules).reduce(
|
|
137
|
-
var moduleName = _a[0], moduleSchema = _a[1];
|
|
95
|
+
.filter((module) => module.type === schemaType)
|
|
96
|
+
.map((module) => module);
|
|
97
|
+
}
|
|
98
|
+
getSpecSchemaByFilenameMap() {
|
|
99
|
+
return Object.entries(this.schemaValue.modules).reduce((acc, [moduleName, moduleSchema]) => {
|
|
138
100
|
acc.set(moduleName, moduleSchema);
|
|
139
101
|
return acc;
|
|
140
102
|
}, new Map());
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
}());
|
|
103
|
+
}
|
|
104
|
+
}
|
|
144
105
|
exports.UberSchema = UberSchema;
|
|
@@ -5,66 +5,54 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE-MIT file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
11
|
-
s = arguments[i];
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
}
|
|
15
|
-
return t;
|
|
16
|
-
};
|
|
17
|
-
return __assign.apply(this, arguments);
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
10
|
};
|
|
19
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
12
|
exports.AppBuildTimeGlueCodeGenerator = void 0;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
const case_1 = __importDefault(require("case"));
|
|
14
|
+
const templates_1 = require("../templates");
|
|
15
|
+
const BasePackageHTemplate_1 = require("../templates/BasePackageHTemplate");
|
|
24
16
|
/**
|
|
25
17
|
* Generates code based on UberGenerators results. If UberGenerators produce "leaves" (concrete turbo module or component classes),
|
|
26
18
|
* this class generates "branches" (barrel files like index.ts) and "trunks" (package file or files).
|
|
27
19
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
class AppBuildTimeGlueCodeGenerator {
|
|
21
|
+
constructor(cppOutputPath, etsOutputPath, codegenNoticeLines) {
|
|
30
22
|
this.cppOutputPath = cppOutputPath;
|
|
31
23
|
this.etsOutputPath = etsOutputPath;
|
|
32
24
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
33
25
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var turboModules_indexTS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
|
|
41
|
-
var generated_indexETS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
|
|
26
|
+
generate({ v1, v2 }) {
|
|
27
|
+
const fileContentByPath = new Map();
|
|
28
|
+
const generatedPackageH_v1 = new templates_1.RNOHGeneratedPackageHTemplate();
|
|
29
|
+
const components_indexTS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
|
|
30
|
+
const turboModules_indexTS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
|
|
31
|
+
const generated_indexETS = new templates_1.IndexTSTemplate(this.codegenNoticeLines);
|
|
42
32
|
generated_indexETS.addReexport({ from: './ts' });
|
|
43
|
-
v1.components.forEach(
|
|
44
|
-
|
|
45
|
-
components_indexTS.addReexport({ from: "./".concat(name) });
|
|
33
|
+
v1.components.forEach(({ name, eventNames }) => {
|
|
34
|
+
components_indexTS.addReexport({ from: `./${name}` });
|
|
46
35
|
generatedPackageH_v1.addComponent({
|
|
47
|
-
name
|
|
36
|
+
name,
|
|
48
37
|
supportedEventNames: eventNames,
|
|
49
38
|
isArkTSComponent: true,
|
|
50
39
|
});
|
|
51
40
|
});
|
|
52
|
-
v1.turboModules.forEach(
|
|
53
|
-
turboModules_indexTS.addReexport({ from:
|
|
41
|
+
v1.turboModules.forEach((turboModule) => {
|
|
42
|
+
turboModules_indexTS.addReexport({ from: `./${turboModule.name}` });
|
|
54
43
|
generatedPackageH_v1.addTurboModule(turboModule);
|
|
55
44
|
});
|
|
56
|
-
v2.forEach(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
generatedPackageH_v2.addComponent(__assign(__assign({}, component), { isArkTSComponent: false }));
|
|
45
|
+
v2.forEach(({ components, turboModules }, libraryName) => {
|
|
46
|
+
const basePackageClassName = `Base${case_1.default.pascal(libraryName)}Package`;
|
|
47
|
+
const generatedPackageH_v2 = new BasePackageHTemplate_1.BasePackageHTemplate(basePackageClassName, this.codegenNoticeLines);
|
|
48
|
+
components.forEach((component) => {
|
|
49
|
+
generatedPackageH_v2.addComponent(Object.assign(Object.assign({}, component), { isArkTSComponent: false }));
|
|
62
50
|
});
|
|
63
|
-
turboModules.forEach(
|
|
64
|
-
turboModules_indexTS.addReexport({ from:
|
|
51
|
+
turboModules.forEach((turboModule) => {
|
|
52
|
+
turboModules_indexTS.addReexport({ from: `./${turboModule.name}` });
|
|
65
53
|
generatedPackageH_v2.addTurboModule(turboModule);
|
|
66
54
|
});
|
|
67
|
-
fileContentByPath.set(
|
|
55
|
+
fileContentByPath.set(this.cppOutputPath.copyWithNewSegment(libraryName, 'RNOH', 'generated', `${basePackageClassName}.h`), generatedPackageH_v2.build());
|
|
68
56
|
});
|
|
69
57
|
fileContentByPath.set(this.cppOutputPath.copyWithNewSegment('RNOHGeneratedPackage.h'), generatedPackageH_v1.build());
|
|
70
58
|
fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('ts.ts'), new templates_1.IndexTSTemplate(this.codegenNoticeLines)
|
|
@@ -75,7 +63,6 @@ var AppBuildTimeGlueCodeGenerator = /** @class */ (function () {
|
|
|
75
63
|
fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('turboModules', 'ts.ts'), turboModules_indexTS.build());
|
|
76
64
|
fileContentByPath.set(this.etsOutputPath.copyWithNewSegment('index.ets'), generated_indexETS.build());
|
|
77
65
|
return fileContentByPath;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
}());
|
|
66
|
+
}
|
|
67
|
+
}
|
|
81
68
|
exports.AppBuildTimeGlueCodeGenerator = AppBuildTimeGlueCodeGenerator;
|
|
@@ -7,35 +7,33 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.ArkTSComponentCodeGeneratorArkTS = void 0;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const core_1 = require("../core");
|
|
11
|
+
const templates_1 = require("../templates");
|
|
12
|
+
class ArkTSComponentCodeGeneratorArkTS {
|
|
13
|
+
constructor(cppOutputPath, tsOutputPath, codegenNoticeLines, rnohImport) {
|
|
14
14
|
this.cppOutputPath = cppOutputPath;
|
|
15
15
|
this.tsOutputPath = tsOutputPath;
|
|
16
16
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
17
17
|
this.rnohImport = rnohImport;
|
|
18
18
|
this.glueCodeDataItems = [];
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
getGlueCodeData() {
|
|
21
21
|
return this.glueCodeDataItems;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
var _this = this;
|
|
22
|
+
}
|
|
23
|
+
generate(schema) {
|
|
25
24
|
if (schema.type !== 'Component') {
|
|
26
25
|
throw new core_1.CodegenError({
|
|
27
|
-
whatHappened:
|
|
26
|
+
whatHappened: `ComponentCodeGenerator can't generate code for a module type: ${schema.type}`,
|
|
28
27
|
unexpected: true,
|
|
29
28
|
});
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Object.entries(schema.components).map(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
shape.props.forEach(function (prop) {
|
|
30
|
+
const typeAnnotationToTS = new core_1.TypeAnnotationToTS();
|
|
31
|
+
const result = new Map();
|
|
32
|
+
Object.entries(schema.components).map(([name, shape]) => {
|
|
33
|
+
const componentDescriptorHTemplate = new templates_1.ComponentDescriptorHTemplate(name);
|
|
34
|
+
const componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(name, this.codegenNoticeLines);
|
|
35
|
+
const componentUtilsTSTemplate = new templates_1.ComponentUtilsTSTemplate(name, this.codegenNoticeLines, this.rnohImport);
|
|
36
|
+
shape.props.forEach((prop) => {
|
|
39
37
|
componentJSIBinderHTemplate.addProp({
|
|
40
38
|
name: prop.name,
|
|
41
39
|
isObject: prop.typeAnnotation.type === 'ObjectTypeAnnotation',
|
|
@@ -47,7 +45,7 @@ var ArkTSComponentCodeGeneratorArkTS = /** @class */ (function () {
|
|
|
47
45
|
isOptional: prop.optional,
|
|
48
46
|
});
|
|
49
47
|
});
|
|
50
|
-
shape.commands.forEach(
|
|
48
|
+
shape.commands.forEach((command) => {
|
|
51
49
|
componentJSIBinderHTemplate.addCommand({
|
|
52
50
|
name: command.name,
|
|
53
51
|
});
|
|
@@ -55,15 +53,13 @@ var ArkTSComponentCodeGeneratorArkTS = /** @class */ (function () {
|
|
|
55
53
|
name: command.name,
|
|
56
54
|
argsTSType: '[' +
|
|
57
55
|
command.typeAnnotation.params
|
|
58
|
-
.map(
|
|
59
|
-
|
|
60
|
-
(param.optional ? '?' : '');
|
|
61
|
-
})
|
|
56
|
+
.map((param) => typeAnnotationToTS.convert(param.typeAnnotation) +
|
|
57
|
+
(param.optional ? '?' : ''))
|
|
62
58
|
.join(', ') +
|
|
63
59
|
']',
|
|
64
60
|
});
|
|
65
61
|
});
|
|
66
|
-
shape.events.forEach(
|
|
62
|
+
shape.events.forEach((event) => {
|
|
67
63
|
componentUtilsTSTemplate.addEvent({
|
|
68
64
|
name: (0, core_1.createEventNameFromEventHandlerName)(event.name),
|
|
69
65
|
payloadTSType: event.typeAnnotation.argument
|
|
@@ -75,18 +71,15 @@ var ArkTSComponentCodeGeneratorArkTS = /** @class */ (function () {
|
|
|
75
71
|
eventHandlerName: event.name,
|
|
76
72
|
});
|
|
77
73
|
});
|
|
78
|
-
result.set(
|
|
79
|
-
result.set(
|
|
80
|
-
result.set(
|
|
81
|
-
|
|
82
|
-
name
|
|
83
|
-
eventNames: shape.events.map(
|
|
84
|
-
return (0, core_1.createEventNameFromEventHandlerName)(e.name);
|
|
85
|
-
}),
|
|
74
|
+
result.set(this.cppOutputPath.copyWithNewSegment(`${name}ComponentDescriptor.h`), componentDescriptorHTemplate.build());
|
|
75
|
+
result.set(this.cppOutputPath.copyWithNewSegment(`${name}JSIBinder.h`), componentJSIBinderHTemplate.build());
|
|
76
|
+
result.set(this.tsOutputPath.copyWithNewSegment(`${name}.ts`), componentUtilsTSTemplate.build());
|
|
77
|
+
this.glueCodeDataItems.push({
|
|
78
|
+
name,
|
|
79
|
+
eventNames: shape.events.map((e) => (0, core_1.createEventNameFromEventHandlerName)(e.name)),
|
|
86
80
|
});
|
|
87
81
|
});
|
|
88
82
|
return result;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
}());
|
|
83
|
+
}
|
|
84
|
+
}
|
|
92
85
|
exports.ArkTSComponentCodeGeneratorArkTS = ArkTSComponentCodeGeneratorArkTS;
|
|
@@ -7,34 +7,31 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.ArkTSComponentCodeGeneratorCAPI = void 0;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const core_1 = require("../core");
|
|
11
|
+
const templates_1 = require("../templates");
|
|
12
12
|
/**
|
|
13
13
|
* Generates component code for ArkTS components used in C-API architecture.
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
class ArkTSComponentCodeGeneratorCAPI {
|
|
16
|
+
constructor(cppOutputPath, tsOutputPath, codegenNoticeLines, rnohImport) {
|
|
17
17
|
this.cppOutputPath = cppOutputPath;
|
|
18
18
|
this.tsOutputPath = tsOutputPath;
|
|
19
19
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
20
20
|
this.rnohImport = rnohImport;
|
|
21
21
|
this.glueCodeDataItems = [];
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
getLibGlueCodeData() {
|
|
24
24
|
return this.glueCodeDataItems;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(name, _this.codegenNoticeLines);
|
|
36
|
-
var componentUtilsTSTemplate = new templates_1.ComponentUtilsTSTemplate(name, _this.codegenNoticeLines, _this.rnohImport);
|
|
37
|
-
shape.props.forEach(function (prop) {
|
|
25
|
+
}
|
|
26
|
+
generate(uberSchema) {
|
|
27
|
+
const typeAnnotationToTS = new core_1.TypeAnnotationToTS();
|
|
28
|
+
const result = new Map();
|
|
29
|
+
const componentSpecSchemas = uberSchema.findAllSpecSchemasByType('Component');
|
|
30
|
+
for (const componentSpecSchema of componentSpecSchemas) {
|
|
31
|
+
Object.entries(componentSpecSchema.components).map(([name, shape]) => {
|
|
32
|
+
const componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(name, this.codegenNoticeLines);
|
|
33
|
+
const componentUtilsTSTemplate = new templates_1.ComponentUtilsTSTemplate(name, this.codegenNoticeLines, this.rnohImport);
|
|
34
|
+
shape.props.forEach((prop) => {
|
|
38
35
|
componentJSIBinderHTemplate.addProp({
|
|
39
36
|
name: prop.name,
|
|
40
37
|
isObject: prop.typeAnnotation.type === 'ObjectTypeAnnotation',
|
|
@@ -46,7 +43,7 @@ var ArkTSComponentCodeGeneratorCAPI = /** @class */ (function () {
|
|
|
46
43
|
isOptional: prop.optional,
|
|
47
44
|
});
|
|
48
45
|
});
|
|
49
|
-
shape.commands.forEach(
|
|
46
|
+
shape.commands.forEach((command) => {
|
|
50
47
|
componentJSIBinderHTemplate.addCommand({
|
|
51
48
|
name: command.name,
|
|
52
49
|
});
|
|
@@ -54,15 +51,13 @@ var ArkTSComponentCodeGeneratorCAPI = /** @class */ (function () {
|
|
|
54
51
|
name: command.name,
|
|
55
52
|
argsTSType: '[' +
|
|
56
53
|
command.typeAnnotation.params
|
|
57
|
-
.map(
|
|
58
|
-
|
|
59
|
-
(param.optional ? '?' : '');
|
|
60
|
-
})
|
|
54
|
+
.map((param) => typeAnnotationToTS.convert(param.typeAnnotation) +
|
|
55
|
+
(param.optional ? '?' : ''))
|
|
61
56
|
.join(', ') +
|
|
62
57
|
']',
|
|
63
58
|
});
|
|
64
59
|
});
|
|
65
|
-
shape.events.forEach(
|
|
60
|
+
shape.events.forEach((event) => {
|
|
66
61
|
componentUtilsTSTemplate.addEvent({
|
|
67
62
|
name: (0, core_1.createEventNameFromEventHandlerName)(event.name),
|
|
68
63
|
payloadTSType: event.typeAnnotation.argument
|
|
@@ -74,18 +69,15 @@ var ArkTSComponentCodeGeneratorCAPI = /** @class */ (function () {
|
|
|
74
69
|
eventHandlerName: event.name,
|
|
75
70
|
});
|
|
76
71
|
});
|
|
77
|
-
result.set(
|
|
78
|
-
result.set(
|
|
79
|
-
|
|
72
|
+
result.set(this.cppOutputPath.copyWithNewSegment(`${name}JSIBinder.h`), componentJSIBinderHTemplate.build());
|
|
73
|
+
result.set(this.tsOutputPath.copyWithNewSegment(`${name}.ts`), componentUtilsTSTemplate.build());
|
|
74
|
+
this.glueCodeDataItems.push({
|
|
80
75
|
componentName: name,
|
|
81
|
-
eventNames: shape.events.map(
|
|
82
|
-
return (0, core_1.createEventNameFromEventHandlerName)(event.name);
|
|
83
|
-
}),
|
|
76
|
+
eventNames: shape.events.map((event) => (0, core_1.createEventNameFromEventHandlerName)(event.name)),
|
|
84
77
|
});
|
|
85
78
|
});
|
|
86
79
|
}
|
|
87
80
|
return result;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
}());
|
|
81
|
+
}
|
|
82
|
+
}
|
|
91
83
|
exports.ArkTSComponentCodeGeneratorCAPI = ArkTSComponentCodeGeneratorCAPI;
|
|
@@ -7,64 +7,59 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.CppComponentCodeGenerator = void 0;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const templates_1 = require("../templates");
|
|
11
|
+
class CppComponentCodeGenerator {
|
|
12
|
+
constructor(onGetRNOHOutputPath, codegenNoticeLines) {
|
|
13
13
|
this.onGetRNOHOutputPath = onGetRNOHOutputPath;
|
|
14
14
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
15
15
|
this.glueCodeComponentsData = [];
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
getGlueCodeData() {
|
|
18
18
|
return this.glueCodeComponentsData;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var fileContentByPath = new Map();
|
|
24
|
-
for (var _i = 0, _b = uberSchema
|
|
19
|
+
}
|
|
20
|
+
generate({ libraryCppName, uberSchema, }) {
|
|
21
|
+
const fileContentByPath = new Map();
|
|
22
|
+
for (const [_filename, schema] of uberSchema
|
|
25
23
|
.getSpecSchemaByFilenameMap()
|
|
26
|
-
.entries()
|
|
27
|
-
var _c = _b[_i], _filename = _c[0], schema = _c[1];
|
|
24
|
+
.entries()) {
|
|
28
25
|
if (schema.type === 'Component') {
|
|
29
|
-
Object.entries(schema.components).map(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
shape.props.forEach(function (prop) {
|
|
26
|
+
Object.entries(schema.components).map(([componentName, shape]) => {
|
|
27
|
+
const componentJSIBinderHTemplate = new templates_1.ComponentJSIBinderHTemplate(componentName, this.codegenNoticeLines);
|
|
28
|
+
const componentInstanceSpecHTemplate = new templates_1.BaseComponentInstanceHTemplate(componentName, libraryCppName, this.codegenNoticeLines);
|
|
29
|
+
shape.props.forEach((prop) => {
|
|
34
30
|
componentJSIBinderHTemplate.addProp({
|
|
35
31
|
name: prop.name,
|
|
36
32
|
isObject: prop.typeAnnotation.type === 'ObjectTypeAnnotation',
|
|
37
33
|
});
|
|
38
34
|
});
|
|
39
|
-
shape.events.forEach(
|
|
35
|
+
shape.events.forEach((event) => {
|
|
40
36
|
componentJSIBinderHTemplate.addEvent({
|
|
41
37
|
type: event.bubblingType,
|
|
42
38
|
eventHandlerName: event.name,
|
|
43
39
|
});
|
|
44
40
|
});
|
|
45
|
-
shape.commands.forEach(
|
|
41
|
+
shape.commands.forEach((command) => {
|
|
46
42
|
componentJSIBinderHTemplate.addCommand({
|
|
47
43
|
name: command.name,
|
|
48
44
|
});
|
|
49
45
|
componentInstanceSpecHTemplate.addCommand({
|
|
50
46
|
name: command.name,
|
|
51
|
-
args: command.typeAnnotation.params.map(
|
|
47
|
+
args: command.typeAnnotation.params.map((param) => ({
|
|
52
48
|
name: param.name,
|
|
53
49
|
typeAnnotation: param.typeAnnotation,
|
|
54
|
-
})
|
|
50
|
+
})),
|
|
55
51
|
});
|
|
56
52
|
});
|
|
57
|
-
fileContentByPath.set(
|
|
58
|
-
fileContentByPath.set(
|
|
59
|
-
|
|
53
|
+
fileContentByPath.set(this.onGetRNOHOutputPath(`${componentName}JSIBinder.h`), componentJSIBinderHTemplate.build());
|
|
54
|
+
fileContentByPath.set(this.onGetRNOHOutputPath(`Base${componentName}ComponentInstance.h`), componentInstanceSpecHTemplate.build());
|
|
55
|
+
this.glueCodeComponentsData.push({
|
|
60
56
|
name: componentName,
|
|
61
|
-
libraryCppName
|
|
57
|
+
libraryCppName,
|
|
62
58
|
});
|
|
63
59
|
});
|
|
64
60
|
}
|
|
65
61
|
}
|
|
66
62
|
return fileContentByPath;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
}());
|
|
63
|
+
}
|
|
64
|
+
}
|
|
70
65
|
exports.CppComponentCodeGenerator = CppComponentCodeGenerator;
|