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