@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,10 +1,44 @@
|
|
|
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.TurboModuleInterfaceTS = 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
|
+
import { Tag } from "{{{rnohImport}}}"
|
|
16
|
+
|
|
17
|
+
export namespace {{name}} {
|
|
18
|
+
export const NAME = '{{name}}' as const
|
|
19
|
+
|
|
20
|
+
{{#enums}}
|
|
21
|
+
export enum {{name}} {
|
|
22
|
+
{{#members}}
|
|
23
|
+
{{name}} = {{{value}}},
|
|
24
|
+
{{/members}}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
{{/enums}}
|
|
28
|
+
{{#aliases}}
|
|
29
|
+
export type {{name}} = {{{type}}}
|
|
30
|
+
|
|
31
|
+
{{/aliases}}
|
|
32
|
+
export interface Spec {
|
|
33
|
+
{{#methods}}
|
|
34
|
+
{{name}}({{{stringifiedArgs}}}): {{{returnType}}};
|
|
35
|
+
|
|
36
|
+
{{/methods}}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
class TurboModuleInterfaceTS {
|
|
41
|
+
constructor(name, codegenNoticeLines, rnohImport) {
|
|
8
42
|
this.name = name;
|
|
9
43
|
this.codegenNoticeLines = codegenNoticeLines;
|
|
10
44
|
this.rnohImport = rnohImport;
|
|
@@ -12,31 +46,30 @@ var TurboModuleInterfaceTS = /** @class */ (function () {
|
|
|
12
46
|
this.aliases = [];
|
|
13
47
|
this.enumModels = [];
|
|
14
48
|
}
|
|
15
|
-
|
|
49
|
+
addAlias(alias) {
|
|
16
50
|
this.aliases.push(alias);
|
|
17
|
-
}
|
|
18
|
-
|
|
51
|
+
}
|
|
52
|
+
addEnum(enumModel) {
|
|
19
53
|
this.enumModels.push(enumModel);
|
|
20
|
-
}
|
|
21
|
-
|
|
54
|
+
}
|
|
55
|
+
addMethod(method) {
|
|
22
56
|
this.methods.push(method);
|
|
23
|
-
}
|
|
24
|
-
|
|
57
|
+
}
|
|
58
|
+
build() {
|
|
25
59
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
26
|
-
codegenNoticeLines: this.codegenNoticeLines.map(
|
|
27
|
-
line
|
|
28
|
-
})
|
|
60
|
+
codegenNoticeLines: this.codegenNoticeLines.map((line) => ({
|
|
61
|
+
line,
|
|
62
|
+
})),
|
|
29
63
|
name: this.name,
|
|
30
64
|
aliases: this.aliases,
|
|
31
65
|
enums: this.enumModels,
|
|
32
66
|
rnohImport: this.rnohImport,
|
|
33
|
-
methods: this.methods.map(
|
|
67
|
+
methods: this.methods.map((method) => ({
|
|
34
68
|
name: method.name,
|
|
35
69
|
stringifiedArgs: method.stringifiedArgs,
|
|
36
70
|
returnType: method.returnType,
|
|
37
|
-
})
|
|
71
|
+
})),
|
|
38
72
|
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
}());
|
|
73
|
+
}
|
|
74
|
+
}
|
|
42
75
|
exports.TurboModuleInterfaceTS = TurboModuleInterfaceTS;
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -19,63 +8,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
9
|
});
|
|
21
10
|
};
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
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;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
-
if (ar || !(i in from)) {
|
|
52
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
-
ar[i] = from[i];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
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 };
|
|
57
13
|
};
|
|
58
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
15
|
exports.commandBundleHarmony = void 0;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
16
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
17
|
+
const os_1 = __importDefault(require("os"));
|
|
18
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
19
|
+
const metro_1 = __importDefault(require("metro"));
|
|
20
|
+
const Server_1 = __importDefault(require("metro/src/Server"));
|
|
21
|
+
const path_1 = __importDefault(require("path"));
|
|
22
|
+
const assetResolver_1 = require("../assetResolver");
|
|
23
|
+
const child_process_1 = require("child_process");
|
|
24
|
+
const io_1 = require("../io");
|
|
25
|
+
const core_1 = require("../core");
|
|
26
|
+
const node_crypto_1 = require("node:crypto");
|
|
27
|
+
const HERMESC_BIN_PATH = {
|
|
72
28
|
darwin: path_1.default.normalize('osx-bin/hermesc'),
|
|
73
29
|
linux: path_1.default.normalize('linux64-bin/hermesc'),
|
|
74
30
|
win32: path_1.default.normalize('win64-bin/hermesc.exe'),
|
|
75
31
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
32
|
+
const HERMESC_PATH_PREFIX = path_1.default.normalize('./node_modules/react-native/sdks/hermesc/');
|
|
33
|
+
const HARMONY_RESOURCE_PATH = path_1.default.normalize('./harmony/entry/src/main/resources/rawfile');
|
|
34
|
+
const ASSETS_DEFAULT_DEST_PATH = path_1.default.normalize('./harmony/entry/src/main/resources/rawfile/assets');
|
|
79
35
|
exports.commandBundleHarmony = {
|
|
80
36
|
name: 'bundle-harmony',
|
|
81
37
|
description: 'Creates JS bundle, creates a special cpp header containing the JS code, copies assets directory to the project.',
|
|
@@ -83,14 +39,14 @@ exports.commandBundleHarmony = {
|
|
|
83
39
|
{
|
|
84
40
|
name: '--dev [boolean]',
|
|
85
41
|
description: 'If false, warnings are disabled and the bundle is minified',
|
|
86
|
-
parse:
|
|
42
|
+
parse: (val) => val !== 'false',
|
|
87
43
|
default: true,
|
|
88
44
|
},
|
|
89
45
|
{
|
|
90
46
|
name: '--entry-file <path>',
|
|
91
47
|
description: 'Path to the root JS file, either absolute or relative to JS root',
|
|
92
48
|
default: 'index.js',
|
|
93
|
-
parse:
|
|
49
|
+
parse: (val) => path_1.default.normalize(val),
|
|
94
50
|
},
|
|
95
51
|
{
|
|
96
52
|
name: '--reset-cache',
|
|
@@ -100,20 +56,20 @@ exports.commandBundleHarmony = {
|
|
|
100
56
|
{
|
|
101
57
|
name: '--config <path>',
|
|
102
58
|
description: 'Path to the Metro configuration file',
|
|
103
|
-
parse:
|
|
59
|
+
parse: (val) => path_1.default.normalize(val),
|
|
104
60
|
},
|
|
105
61
|
{
|
|
106
62
|
name: '--bundle-output <path>',
|
|
107
|
-
description:
|
|
108
|
-
parse:
|
|
63
|
+
description: `File path where to store the resulting bundle (default: "${HARMONY_RESOURCE_PATH}${path_1.default.sep}bundle.harmony.js")`,
|
|
64
|
+
parse: (val) => path_1.default.normalize(val),
|
|
109
65
|
},
|
|
110
66
|
{
|
|
111
67
|
name: '--js-engine <string>',
|
|
112
68
|
description: 'JavaScript engine used to run the bundle. Supported engines: "hermes" and "any" (default: "any"). Setting this option to "hermes" will generate a HBC bundle instead of a JS bundle.',
|
|
113
69
|
default: 'any',
|
|
114
|
-
parse:
|
|
70
|
+
parse: (val) => {
|
|
115
71
|
if (val !== 'any' && val !== 'hermes') {
|
|
116
|
-
throw new Error(
|
|
72
|
+
throw new Error(`Only "any" and "hermes" are supported as JavaScript engines, but "${val}" was provided`);
|
|
117
73
|
}
|
|
118
74
|
return val;
|
|
119
75
|
},
|
|
@@ -122,199 +78,140 @@ exports.commandBundleHarmony = {
|
|
|
122
78
|
name: '--assets-dest <path>',
|
|
123
79
|
description: 'Directory name where to store assets referenced in the bundle',
|
|
124
80
|
default: ASSETS_DEFAULT_DEST_PATH,
|
|
125
|
-
parse:
|
|
81
|
+
parse: (val) => path_1.default.normalize(val),
|
|
126
82
|
},
|
|
127
83
|
{
|
|
128
84
|
name: '--sourcemap-output <path>',
|
|
129
85
|
description: 'File name where to store the resulting source map, ex. /tmp/groups.map',
|
|
130
|
-
parse:
|
|
86
|
+
parse: (val) => path_1.default.normalize(val),
|
|
131
87
|
},
|
|
132
88
|
{
|
|
133
89
|
name: '--minify [boolean]',
|
|
134
90
|
description: 'Allows overriding whether bundle is minified',
|
|
135
|
-
parse:
|
|
91
|
+
parse: (val) => val !== 'false',
|
|
136
92
|
},
|
|
137
93
|
{
|
|
138
94
|
name: '--hermesc-dir <path>',
|
|
139
95
|
description: 'Path to hermesc directory. Relevant when --js-engine set to "hermes".',
|
|
140
96
|
default: HERMESC_PATH_PREFIX,
|
|
141
|
-
parse:
|
|
97
|
+
parse: (val) => path_1.default.normalize(val),
|
|
142
98
|
},
|
|
143
99
|
{
|
|
144
100
|
name: '--hermesc-options <string...>',
|
|
145
101
|
description: 'Additional options to pass to hermesc when generating HBC bundle. Example: --hermesc-options O g reuse-prop-cache. Relevant when --js-engine set to "hermes".',
|
|
146
|
-
parse:
|
|
102
|
+
parse: (val, prev) => (prev ? [...prev, val] : [val]),
|
|
147
103
|
},
|
|
148
104
|
],
|
|
149
|
-
func:
|
|
150
|
-
var logger, defaultBundleName, bundleOutput, shouldGenerateHbcBundle, assetsDest, buildOptions, metroConfig, bundle, assets, err_1;
|
|
105
|
+
func: (argv, config, args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
151
106
|
var _a;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
};
|
|
179
|
-
return [4 /*yield*/, loadMetroConfig({
|
|
180
|
-
config: args.config,
|
|
181
|
-
resetCache: args.resetCache,
|
|
182
|
-
})];
|
|
183
|
-
case 4:
|
|
184
|
-
metroConfig = _b.sent();
|
|
185
|
-
return [4 /*yield*/, createBundle(metroConfig, buildOptions)];
|
|
186
|
-
case 5:
|
|
187
|
-
bundle = _b.sent();
|
|
188
|
-
return [4 /*yield*/, retrieveAssetsData(metroConfig, buildOptions)];
|
|
189
|
-
case 6:
|
|
190
|
-
assets = _b.sent();
|
|
191
|
-
if (!shouldGenerateHbcBundle) return [3 /*break*/, 8];
|
|
192
|
-
return [4 /*yield*/, saveHbcBundle(logger, bundle.code, bundleOutput, args.hermescDir, args.hermescOptions)];
|
|
193
|
-
case 7:
|
|
194
|
-
_b.sent();
|
|
195
|
-
return [3 /*break*/, 10];
|
|
196
|
-
case 8: return [4 /*yield*/, saveJSBundle(logger, bundle, bundleOutput)];
|
|
197
|
-
case 9:
|
|
198
|
-
_b.sent();
|
|
199
|
-
_b.label = 10;
|
|
200
|
-
case 10:
|
|
201
|
-
maybeSaveSourceMap(logger, bundle, args.sourcemapOutput);
|
|
202
|
-
return [4 /*yield*/, (0, assetResolver_1.copyAssets)(logger, assets, assetsDest)];
|
|
203
|
-
case 11:
|
|
204
|
-
_b.sent();
|
|
205
|
-
return [3 /*break*/, 13];
|
|
206
|
-
case 12:
|
|
207
|
-
err_1 = _b.sent();
|
|
208
|
-
if (err_1 instanceof core_1.DescriptiveError) {
|
|
209
|
-
logger.descriptiveError(err_1);
|
|
210
|
-
return [2 /*return*/];
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
throw err_1;
|
|
214
|
-
}
|
|
215
|
-
return [3 /*break*/, 13];
|
|
216
|
-
case 13: return [2 /*return*/];
|
|
107
|
+
const logger = new io_1.Logger();
|
|
108
|
+
try {
|
|
109
|
+
const defaultBundleName = args.jsEngine === 'hermes' ? 'hermes_bundle.hbc' : 'bundle.harmony.js';
|
|
110
|
+
const bundleOutput = (_a = args.bundleOutput) !== null && _a !== void 0 ? _a : `${HARMONY_RESOURCE_PATH}${path_1.default.sep}${defaultBundleName}`;
|
|
111
|
+
const shouldGenerateHbcBundle = bundleOutput
|
|
112
|
+
.toLowerCase()
|
|
113
|
+
.endsWith('hbc');
|
|
114
|
+
yield fs_extra_1.default.ensureDir(path_1.default.dirname(bundleOutput));
|
|
115
|
+
const assetsDest = args.assetsDest;
|
|
116
|
+
yield fs_extra_1.default.ensureDir(assetsDest);
|
|
117
|
+
const buildOptions = {
|
|
118
|
+
entry: args.entryFile,
|
|
119
|
+
platform: 'harmony',
|
|
120
|
+
minify: args.minify !== undefined ? args.minify : !args.dev,
|
|
121
|
+
dev: args.dev,
|
|
122
|
+
sourceMap: args.sourcemapOutput,
|
|
123
|
+
sourceMapUrl: args.sourcemapOutput,
|
|
124
|
+
};
|
|
125
|
+
const metroConfig = yield loadMetroConfig({
|
|
126
|
+
config: args.config,
|
|
127
|
+
resetCache: args.resetCache,
|
|
128
|
+
});
|
|
129
|
+
const bundle = yield createBundle(metroConfig, buildOptions);
|
|
130
|
+
const assets = yield retrieveAssetsData(metroConfig, buildOptions);
|
|
131
|
+
if (shouldGenerateHbcBundle) {
|
|
132
|
+
yield saveHbcBundle(logger, bundle.code, bundleOutput, args.hermescDir, args.hermescOptions);
|
|
217
133
|
}
|
|
218
|
-
|
|
219
|
-
|
|
134
|
+
else {
|
|
135
|
+
yield saveJSBundle(logger, bundle, bundleOutput);
|
|
136
|
+
}
|
|
137
|
+
maybeSaveSourceMap(logger, bundle, args.sourcemapOutput);
|
|
138
|
+
yield (0, assetResolver_1.copyAssets)(logger, assets, assetsDest);
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
if (err instanceof core_1.DescriptiveError) {
|
|
142
|
+
logger.descriptiveError(err);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
throw err;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}),
|
|
220
150
|
};
|
|
221
151
|
function loadMetroConfig(options) {
|
|
222
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
delete options.config;
|
|
228
|
-
}
|
|
229
|
-
return [4 /*yield*/, metro_1.default.loadConfig(options)];
|
|
230
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
231
|
-
}
|
|
232
|
-
});
|
|
152
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
if (!options.config) {
|
|
154
|
+
delete options.config;
|
|
155
|
+
}
|
|
156
|
+
return yield metro_1.default.loadConfig(options);
|
|
233
157
|
});
|
|
234
158
|
}
|
|
235
159
|
function createBundle(metroConfig, buildOptions) {
|
|
236
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
case 1:
|
|
241
|
-
// casting needed as Metro.runBuild returns Promise<{code: string, map: string}>
|
|
242
|
-
// despite being typed as Promise<void>
|
|
243
|
-
return [2 /*return*/, (_a.sent())];
|
|
244
|
-
}
|
|
245
|
-
});
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
// casting needed as Metro.runBuild returns Promise<{code: string, map: string}>
|
|
162
|
+
// despite being typed as Promise<void>
|
|
163
|
+
return (yield metro_1.default.runBuild(metroConfig, buildOptions));
|
|
246
164
|
});
|
|
247
165
|
}
|
|
248
166
|
function saveHbcBundle(logger, bundleCode, bundleOutput, hermescPath, hermescOptions) {
|
|
249
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
hbcFilePath = bundleOutput.endsWith('.hbc')
|
|
273
|
-
? bundleOutput
|
|
274
|
-
: path_1.default.join(path_1.default.dirname(bundleOutput), 'hermes_bundle.hbc');
|
|
275
|
-
hermescOptionsString = (hermescOptions === null || hermescOptions === void 0 ? void 0 : hermescOptions.map(function (e) { return "-".concat(e); }).join(' ')) || '';
|
|
276
|
-
(0, child_process_1.execSync)("".concat(resolvedHermescPath, " ").concat(hermescOptionsString, " --emit-binary -out ").concat(hbcFilePath, " ").concat(tmpBundlePath), {
|
|
277
|
-
stdio: 'inherit',
|
|
278
|
-
});
|
|
279
|
-
node_fs_1.default.unlinkSync(tmpBundlePath);
|
|
280
|
-
logger.info(function (s) { return "Created ".concat(hbcFilePath); });
|
|
281
|
-
return [2 /*return*/];
|
|
282
|
-
}
|
|
167
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
if (process.platform !== 'darwin' &&
|
|
169
|
+
process.platform !== 'linux' &&
|
|
170
|
+
process.platform !== 'win32') {
|
|
171
|
+
throw new Error(`Unsupported platform ${process.platform} (⊙︿⊙)`);
|
|
172
|
+
}
|
|
173
|
+
const resolvedHermescPath = path_1.default.resolve(hermescPath, HERMESC_BIN_PATH[process.platform]);
|
|
174
|
+
if (!node_fs_1.default.existsSync(resolvedHermescPath)) {
|
|
175
|
+
throw new core_1.DescriptiveError({
|
|
176
|
+
whatHappened: `Couldn't find hermesc at ${resolvedHermescPath}`,
|
|
177
|
+
whatCanUserDo: [
|
|
178
|
+
'Find hermesc dir and provide it by using --hermesc-dir argument. hermesc dir should be in react-native package.',
|
|
179
|
+
],
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
const tmpBundlePath = `${os_1.default.tmpdir()}${path_1.default.sep}b-${(0, node_crypto_1.randomUUID)()}.harmony.js`;
|
|
183
|
+
yield fs_extra_1.default.writeFile(tmpBundlePath, bundleCode);
|
|
184
|
+
const hbcFilePath = bundleOutput.endsWith('.hbc')
|
|
185
|
+
? bundleOutput
|
|
186
|
+
: path_1.default.join(path_1.default.dirname(bundleOutput), 'hermes_bundle.hbc');
|
|
187
|
+
const hermescOptionsString = (hermescOptions === null || hermescOptions === void 0 ? void 0 : hermescOptions.map((e) => `-${e}`).join(' ')) || '';
|
|
188
|
+
(0, child_process_1.execSync)(`${resolvedHermescPath} ${hermescOptionsString} --emit-binary -out ${hbcFilePath} ${tmpBundlePath}`, {
|
|
189
|
+
stdio: 'inherit',
|
|
283
190
|
});
|
|
191
|
+
node_fs_1.default.unlinkSync(tmpBundlePath);
|
|
192
|
+
logger.info((s) => `Created ${hbcFilePath}`);
|
|
284
193
|
});
|
|
285
194
|
}
|
|
286
195
|
function saveJSBundle(logger, bundle, bundleOutput) {
|
|
287
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
logger.info(function (s) { return "Created ".concat(bundleOutput); });
|
|
291
|
-
return [2 /*return*/];
|
|
292
|
-
});
|
|
196
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
197
|
+
node_fs_1.default.writeFileSync(bundleOutput, bundle.code);
|
|
198
|
+
logger.info((s) => `Created ${bundleOutput}`);
|
|
293
199
|
});
|
|
294
200
|
}
|
|
295
201
|
function maybeSaveSourceMap(logger, bundle, sourceMapOutput) {
|
|
296
202
|
if (sourceMapOutput) {
|
|
297
203
|
node_fs_1.default.writeFileSync(sourceMapOutput, bundle.map);
|
|
298
|
-
logger.info(
|
|
204
|
+
logger.info((s) => `Created ${sourceMapOutput}`);
|
|
299
205
|
}
|
|
300
206
|
}
|
|
301
207
|
function retrieveAssetsData(metroConfig, buildOptions) {
|
|
302
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
_a.trys.push([1, , 3, 4]);
|
|
311
|
-
return [4 /*yield*/, metroServer.getAssets(__assign(__assign(__assign({}, Server_1.default.DEFAULT_BUNDLE_OPTIONS), buildOptions), { entryFile: buildOptions.entry, bundleType: 'todo' }))];
|
|
312
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
313
|
-
case 3:
|
|
314
|
-
metroServer.end();
|
|
315
|
-
return [7 /*endfinally*/];
|
|
316
|
-
case 4: return [2 /*return*/];
|
|
317
|
-
}
|
|
318
|
-
});
|
|
208
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
+
const metroServer = new Server_1.default(metroConfig);
|
|
210
|
+
try {
|
|
211
|
+
return yield metroServer.getAssets(Object.assign(Object.assign(Object.assign({}, Server_1.default.DEFAULT_BUNDLE_OPTIONS), buildOptions), { entryFile: buildOptions.entry, bundleType: 'todo' }));
|
|
212
|
+
}
|
|
213
|
+
finally {
|
|
214
|
+
metroServer.end();
|
|
215
|
+
}
|
|
319
216
|
});
|
|
320
217
|
}
|