@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
|
@@ -8,18 +8,51 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var
|
|
12
|
-
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
+
if (ar || !(i in from)) {
|
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
+
ar[i] = from[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
13
46
|
};
|
|
14
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
48
|
exports.commandCodegenLibHarmony = void 0;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
49
|
+
var core_1 = require("../core");
|
|
50
|
+
var io_1 = require("../io");
|
|
51
|
+
var node_fs_1 = require("node:fs");
|
|
52
|
+
var codegen_1 = require("../codegen");
|
|
53
|
+
var case_1 = require("case");
|
|
54
|
+
var LibGlueCodeGenerator_1 = require("../codegen/generators/LibGlueCodeGenerator");
|
|
55
|
+
var COMMAND_NAME = 'codegen-lib-harmony';
|
|
23
56
|
exports.commandCodegenLibHarmony = {
|
|
24
57
|
name: COMMAND_NAME,
|
|
25
58
|
description: 'Generates boilerplate, types, and utilities from Turbo Module and Fabric Component specifications. Designed for library developers who want to include generated code in their libraries.',
|
|
@@ -31,17 +64,17 @@ exports.commandCodegenLibHarmony = {
|
|
|
31
64
|
{
|
|
32
65
|
name: '--turbo-modules-spec-paths [path...]',
|
|
33
66
|
description: 'Path or paths to Turbo Module spec files. Each path can point to a spec file or a directory containing spec files.',
|
|
34
|
-
parse: (val, prev)
|
|
67
|
+
parse: function (val, prev) { return (prev ? __spreadArray(__spreadArray([], prev, true), [val], false) : [val]); },
|
|
35
68
|
},
|
|
36
69
|
{
|
|
37
70
|
name: '--arkts-components-spec-paths [path...]',
|
|
38
71
|
description: 'Path or paths to component spec files used to generate code for components to be implemented on the ArkTS side. Each path can point to a spec file or a directory containing spec files.',
|
|
39
|
-
parse: (val, prev)
|
|
72
|
+
parse: function (val, prev) { return (prev ? __spreadArray(__spreadArray([], prev, true), [val], false) : [val]); },
|
|
40
73
|
},
|
|
41
74
|
{
|
|
42
75
|
name: '--cpp-components-spec-paths [path...]',
|
|
43
76
|
description: 'Path or paths to component spec files used to generate code for components to be implemented on the C++ side. Each path can point to a spec file or a directory containing spec files.',
|
|
44
|
-
parse: (val, prev)
|
|
77
|
+
parse: function (val, prev) { return (prev ? __spreadArray(__spreadArray([], prev, true), [val], false) : [val]); },
|
|
45
78
|
},
|
|
46
79
|
{
|
|
47
80
|
name: '--cpp-output-path <path>',
|
|
@@ -56,43 +89,44 @@ exports.commandCodegenLibHarmony = {
|
|
|
56
89
|
description: 'Skips the check that prevents file operations outside the current working directory. This command permanently deletes previously generated files. Files are generated in the path specified by cpp-output-path.',
|
|
57
90
|
},
|
|
58
91
|
],
|
|
59
|
-
func: (_argv, _config, rawArgs)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
args,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (err instanceof core_1.DescriptiveError && !err.isUnexpected()) {
|
|
71
|
-
logger.descriptiveError(err);
|
|
72
|
-
return;
|
|
92
|
+
func: function (_argv, _config, rawArgs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
93
|
+
var logger, _a, args, uberSchemaByType, fileContentByPath;
|
|
94
|
+
return __generator(this, function (_b) {
|
|
95
|
+
logger = new io_1.Logger();
|
|
96
|
+
try {
|
|
97
|
+
_a = validateArgsAndRetrieveUberSchemaByType(rawArgs), args = _a.args, uberSchemaByType = _a.uberSchemaByType;
|
|
98
|
+
fileContentByPath = generateCodeInMemory({
|
|
99
|
+
args: args,
|
|
100
|
+
uberSchemaByType: uberSchemaByType,
|
|
101
|
+
});
|
|
102
|
+
saveAndLogCodegenResult(args, logger, fileContentByPath);
|
|
73
103
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
104
|
+
catch (err) {
|
|
105
|
+
if (err instanceof core_1.DescriptiveError && !err.isUnexpected()) {
|
|
106
|
+
logger.descriptiveError(err);
|
|
107
|
+
return [2 /*return*/];
|
|
108
|
+
}
|
|
109
|
+
throw err;
|
|
110
|
+
}
|
|
111
|
+
return [2 /*return*/];
|
|
112
|
+
});
|
|
113
|
+
}); },
|
|
77
114
|
};
|
|
78
115
|
function validateArgsAndRetrieveUberSchemaByType(rawArgs) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
...arkTSComponentSpecPaths,
|
|
87
|
-
...cppComponentSpecPaths,
|
|
88
|
-
]);
|
|
116
|
+
var args = validateRawArgs(rawArgs);
|
|
117
|
+
var arkTSComponentSpecPaths = specPathsToSpecFilePaths(args.arkTSComponentsSpecPaths);
|
|
118
|
+
var turboModulesUberSchema = codegen_1.UberSchema.fromSpecFilePaths(specPathsToSpecFilePaths(args.tmSpecPaths));
|
|
119
|
+
var arkTSComponentsUberSchema = codegen_1.UberSchema.fromSpecFilePaths(arkTSComponentSpecPaths);
|
|
120
|
+
var cppComponentSpecPaths = specPathsToSpecFilePaths(args.cppComponentsSpecPaths);
|
|
121
|
+
var cppComponentsUberSchema = codegen_1.UberSchema.fromSpecFilePaths(cppComponentSpecPaths);
|
|
122
|
+
var componentsUberSchema = codegen_1.UberSchema.fromSpecFilePaths(__spreadArray(__spreadArray([], arkTSComponentSpecPaths, true), cppComponentSpecPaths, true));
|
|
89
123
|
return {
|
|
90
|
-
args,
|
|
124
|
+
args: args,
|
|
91
125
|
uberSchemaByType: {
|
|
92
|
-
turboModulesUberSchema,
|
|
93
|
-
arkTSComponentsUberSchema,
|
|
94
|
-
cppComponentsUberSchema,
|
|
95
|
-
componentsUberSchema,
|
|
126
|
+
turboModulesUberSchema: turboModulesUberSchema,
|
|
127
|
+
arkTSComponentsUberSchema: arkTSComponentsUberSchema,
|
|
128
|
+
cppComponentsUberSchema: cppComponentsUberSchema,
|
|
129
|
+
componentsUberSchema: componentsUberSchema,
|
|
96
130
|
},
|
|
97
131
|
};
|
|
98
132
|
}
|
|
@@ -118,28 +152,28 @@ function validateRawArgs(rawArgs) {
|
|
|
118
152
|
}
|
|
119
153
|
return {
|
|
120
154
|
npmPackageName: rawArgs.npmPackageName,
|
|
121
|
-
tmSpecPaths: ((_a = rawArgs.turboModulesSpecPaths) !== null && _a !== void 0 ? _a : []).map((path)
|
|
122
|
-
arkTSComponentsSpecPaths: ((_b = rawArgs.arktsComponentsSpecPaths) !== null && _b !== void 0 ? _b : []).map((path)
|
|
123
|
-
cppComponentsSpecPaths: ((_c = rawArgs.cppComponentsSpecPaths) !== null && _c !== void 0 ? _c : []).map((path)
|
|
155
|
+
tmSpecPaths: ((_a = rawArgs.turboModulesSpecPaths) !== null && _a !== void 0 ? _a : []).map(function (path) { return new core_1.AbsolutePath(path); }),
|
|
156
|
+
arkTSComponentsSpecPaths: ((_b = rawArgs.arktsComponentsSpecPaths) !== null && _b !== void 0 ? _b : []).map(function (path) { return new core_1.AbsolutePath(path); }),
|
|
157
|
+
cppComponentsSpecPaths: ((_c = rawArgs.cppComponentsSpecPaths) !== null && _c !== void 0 ? _c : []).map(function (path) { return new core_1.AbsolutePath(path); }),
|
|
124
158
|
etsOutputPath: new core_1.AbsolutePath(rawArgs.etsOutputPath),
|
|
125
159
|
cppOutputPath: new core_1.AbsolutePath(rawArgs.cppOutputPath),
|
|
126
160
|
safetyCheck: !!rawArgs.safetyCheck,
|
|
127
161
|
};
|
|
128
162
|
}
|
|
129
163
|
function specPathsToSpecFilePaths(specPaths) {
|
|
130
|
-
|
|
131
|
-
return specPaths.flatMap((specPath)
|
|
164
|
+
var SUPPORTED_SPEC_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx'];
|
|
165
|
+
return specPaths.flatMap(function (specPath) {
|
|
132
166
|
if (!node_fs_1.default.existsSync(specPath.getValue())) {
|
|
133
167
|
throw new core_1.DescriptiveError({
|
|
134
|
-
whatHappened:
|
|
135
|
-
whatCanUserDo: [
|
|
168
|
+
whatHappened: "No such file or directory: ".concat(specPath.getValue()),
|
|
169
|
+
whatCanUserDo: ["Are you sure provided specPath exists?"],
|
|
136
170
|
});
|
|
137
171
|
}
|
|
138
172
|
if (node_fs_1.default.lstatSync(specPath.getValue()).isDirectory()) {
|
|
139
173
|
return (0, io_1.findFilePathsWithExtensions)(specPath, SUPPORTED_SPEC_EXTENSIONS);
|
|
140
174
|
}
|
|
141
175
|
else {
|
|
142
|
-
|
|
176
|
+
var ext = specPath.getExtension();
|
|
143
177
|
if (ext && SUPPORTED_SPEC_EXTENSIONS.includes(ext)) {
|
|
144
178
|
return [specPath];
|
|
145
179
|
}
|
|
@@ -147,30 +181,31 @@ function specPathsToSpecFilePaths(specPaths) {
|
|
|
147
181
|
}
|
|
148
182
|
});
|
|
149
183
|
}
|
|
150
|
-
function generateCodeInMemory(
|
|
151
|
-
|
|
152
|
-
|
|
184
|
+
function generateCodeInMemory(_a) {
|
|
185
|
+
var args = _a.args, _b = _a.uberSchemaByType, arkTSComponentsUberSchema = _b.arkTSComponentsUberSchema, componentsUberSchema = _b.componentsUberSchema, cppComponentsUberSchema = _b.cppComponentsUberSchema, turboModulesUberSchema = _b.turboModulesUberSchema;
|
|
186
|
+
var CODEGEN_NOTICE_LINES = [
|
|
187
|
+
"This code was generated by \"react-native ".concat(COMMAND_NAME, "\""),
|
|
153
188
|
];
|
|
154
|
-
|
|
155
|
-
|
|
189
|
+
var fileContentByPath = new Map();
|
|
190
|
+
var appendToFileContentByPath = function (fileContent, path) {
|
|
156
191
|
fileContentByPath.set(path, fileContent);
|
|
157
192
|
};
|
|
158
|
-
|
|
193
|
+
var turboModuleGlueCodeData = turboModulesUberSchema
|
|
159
194
|
.findAllSpecSchemasByType('NativeModule')
|
|
160
|
-
.map((specSchema)
|
|
161
|
-
|
|
195
|
+
.map(function (specSchema) {
|
|
196
|
+
var nativeModuleCodeGenerator = new codegen_1.NativeModuleCodeGenerator(args.cppOutputPath.copyWithNewSegment('RNOH', 'generated', 'turbo_modules'), args.etsOutputPath.copyWithNewSegment('turboModules'), CODEGEN_NOTICE_LINES, '@rnoh/react-native-openharmony/ts');
|
|
162
197
|
nativeModuleCodeGenerator
|
|
163
198
|
.generate(specSchema)
|
|
164
199
|
.forEach(appendToFileContentByPath);
|
|
165
200
|
return nativeModuleCodeGenerator.getGlueCodeData();
|
|
166
201
|
})
|
|
167
202
|
.flat();
|
|
168
|
-
|
|
203
|
+
var arkTSComponentCodeGeneratorCAPI = new codegen_1.ArkTSComponentCodeGeneratorCAPI(args.cppOutputPath.copyWithNewSegment('RNOH', 'generated', 'components'), args.etsOutputPath.copyWithNewSegment('components'), CODEGEN_NOTICE_LINES, '@rnoh/react-native-openharmony/ts');
|
|
169
204
|
arkTSComponentCodeGeneratorCAPI
|
|
170
205
|
.generate(arkTSComponentsUberSchema)
|
|
171
206
|
.forEach(appendToFileContentByPath);
|
|
172
|
-
|
|
173
|
-
|
|
207
|
+
var libraryCppName = deriveLibraryCppNameFromNpmPackageName(args.npmPackageName);
|
|
208
|
+
var cppComponentCodeGenerator = new codegen_1.CppComponentCodeGenerator(function (filename) {
|
|
174
209
|
return args.cppOutputPath.copyWithNewSegment('RNOH', 'generated', 'components', filename);
|
|
175
210
|
}, CODEGEN_NOTICE_LINES);
|
|
176
211
|
cppComponentCodeGenerator
|
|
@@ -179,7 +214,7 @@ function generateCodeInMemory({ args, uberSchemaByType: { arkTSComponentsUberSch
|
|
|
179
214
|
uberSchema: cppComponentsUberSchema,
|
|
180
215
|
})
|
|
181
216
|
.forEach(appendToFileContentByPath);
|
|
182
|
-
new codegen_1.SharedComponentCodeGenerator((filename)
|
|
217
|
+
new codegen_1.SharedComponentCodeGenerator(function (filename) {
|
|
183
218
|
return args.cppOutputPath.copyWithNewSegment('react', 'renderer', 'components', libraryCppName, filename);
|
|
184
219
|
})
|
|
185
220
|
.generate({
|
|
@@ -189,18 +224,21 @@ function generateCodeInMemory({ args, uberSchemaByType: { arkTSComponentsUberSch
|
|
|
189
224
|
.forEach(appendToFileContentByPath);
|
|
190
225
|
new LibGlueCodeGenerator_1.LibGlueCodeGenerator(args.cppOutputPath, args.etsOutputPath, CODEGEN_NOTICE_LINES)
|
|
191
226
|
.generate({
|
|
192
|
-
libraryCppName,
|
|
227
|
+
libraryCppName: libraryCppName,
|
|
193
228
|
arkTSComponents: arkTSComponentCodeGeneratorCAPI.getLibGlueCodeData(),
|
|
194
229
|
cppComponents: cppComponentCodeGenerator
|
|
195
230
|
.getGlueCodeData()
|
|
196
|
-
.map((
|
|
231
|
+
.map(function (_a) {
|
|
232
|
+
var name = _a.name;
|
|
233
|
+
return ({ componentName: name });
|
|
234
|
+
}),
|
|
197
235
|
turboModules: turboModuleGlueCodeData,
|
|
198
236
|
})
|
|
199
237
|
.forEach(appendToFileContentByPath);
|
|
200
238
|
return fileContentByPath;
|
|
201
239
|
}
|
|
202
240
|
function deriveLibraryCppNameFromNpmPackageName(npmPackageName) {
|
|
203
|
-
|
|
241
|
+
var result = npmPackageName;
|
|
204
242
|
if (npmPackageName.includes('/')) {
|
|
205
243
|
result.replace('@', '');
|
|
206
244
|
result = npmPackageName.replace('/', '__');
|
|
@@ -217,10 +255,10 @@ function saveCodegenResultToFileSystem(fileContentByPath, cppOutputPath, etsOutp
|
|
|
217
255
|
prepareDirectory(etsOutputPath, enableSafetyCheck);
|
|
218
256
|
prepareDirectory(etsOutputPath.copyWithNewSegment('components'), enableSafetyCheck);
|
|
219
257
|
prepareDirectory(etsOutputPath.copyWithNewSegment('turboModules'), enableSafetyCheck);
|
|
220
|
-
fileContentByPath.forEach((_fileContent, path)
|
|
258
|
+
fileContentByPath.forEach(function (_fileContent, path) {
|
|
221
259
|
prepareDirectory(path.getDirectoryPath(), enableSafetyCheck);
|
|
222
260
|
});
|
|
223
|
-
fileContentByPath.forEach((fileContent, path)
|
|
261
|
+
fileContentByPath.forEach(function (fileContent, path) {
|
|
224
262
|
node_fs_1.default.writeFileSync(path.getValue(), fileContent);
|
|
225
263
|
});
|
|
226
264
|
}
|
|
@@ -228,7 +266,7 @@ function prepareDirectory(path, enableSafetyCheck) {
|
|
|
228
266
|
(0, core_1.maybeMakeDirectories)(path);
|
|
229
267
|
if (enableSafetyCheck && !path.getValue().startsWith(process.cwd())) {
|
|
230
268
|
throw new core_1.DescriptiveError({
|
|
231
|
-
whatHappened:
|
|
269
|
+
whatHappened: "Tried to remove files in ".concat(path.getValue(), "\nand that path is outside current working directory"),
|
|
232
270
|
whatCanUserDo: [
|
|
233
271
|
'Run this command with --no-safety-check flag',
|
|
234
272
|
'Run codegen from different location',
|
|
@@ -238,12 +276,14 @@ function prepareDirectory(path, enableSafetyCheck) {
|
|
|
238
276
|
(0, core_1.maybeRemoveFilesInDirectory)(path);
|
|
239
277
|
}
|
|
240
278
|
function logCodegenResult(logger, fileContentByPath, rootPath) {
|
|
241
|
-
|
|
279
|
+
var sortedRelativePathStrings = Array.from(fileContentByPath.keys()).map(function (path) { return path.relativeTo(rootPath).getValue(); });
|
|
242
280
|
sortedRelativePathStrings.sort();
|
|
243
|
-
sortedRelativePathStrings.forEach((pathStr)
|
|
244
|
-
logger.info((styles)
|
|
281
|
+
sortedRelativePathStrings.forEach(function (pathStr) {
|
|
282
|
+
logger.info(function (styles) { return styles.gray("\u2022 ".concat(pathStr)); });
|
|
283
|
+
});
|
|
284
|
+
logger.info(function () { return ''; });
|
|
285
|
+
logger.info(function (styles) {
|
|
286
|
+
return "Generated ".concat(styles.green(styles.bold(fileContentByPath.size)), " file(s)");
|
|
245
287
|
});
|
|
246
|
-
logger.info(()
|
|
247
|
-
logger.info((styles) => `Generated ${styles.green(styles.bold(fileContentByPath.size))} file(s)`);
|
|
248
|
-
logger.info(() => '');
|
|
288
|
+
logger.info(function () { return ''; });
|
|
249
289
|
}
|