@react-native-oh/react-native-harmony-cli 0.0.37 → 0.0.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/README.md +11 -11
- package/dist/assetResolver.js +74 -43
- package/dist/autolinking/Autolinking.js +183 -179
- 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 +96 -57
- 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 -53
- 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 +138 -53
- package/dist/commands/codegen-harmony.js +175 -104
- package/dist/commands/codegen-lib-harmony.js +116 -76
- package/dist/commands/create-metro-host-constants.js +47 -18
- package/dist/commands/init.js +961 -537
- package/dist/commands/link-harmony.js +71 -33
- package/dist/commands/pack-harmony.js +108 -47
- package/dist/commands/run-harmony.js +518 -374
- package/dist/commands/unpack-harmony.js +198 -105
- package/dist/commands/verify-package-harmony.js +108 -54
- package/dist/core/AbsolutePath.js +47 -31
- 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 +96 -46
- package/dist/core/ValidationError.js +22 -2
- package/dist/core/fs.js +6 -9
- package/dist/index.js +1 -1
- package/dist/io/CliExecutor.js +98 -46
- package/dist/io/Logger.js +46 -40
- package/dist/io/RealFS.js +88 -35
- 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 +132 -55
- package/dist/simulator/LaunchSimulator.js +301 -217
- package/jest.config.js +12 -12
- package/package.json +78 -70
- package/react-native.config.js +17 -17
- package/tsconfig.build.json +6 -6
- package/tsconfig.json +2 -2
- package/.prettierrc +0 -6
- package/src/assetResolver.ts +0 -134
- package/src/autolinking/Autolinking.test.ts +0 -483
- package/src/autolinking/Autolinking.ts +0 -382
- package/src/autolinking/index.ts +0 -8
- package/src/codegen/core/CodeGenerator.ts +0 -16
- package/src/codegen/core/CodegenError.ts +0 -10
- package/src/codegen/core/EventUtils.ts +0 -23
- package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -82
- package/src/codegen/core/TypeAnnotationToTS.ts +0 -195
- package/src/codegen/core/UberSchema.ts +0 -152
- package/src/codegen/core/index.ts +0 -12
- package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +0 -124
- package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +0 -128
- package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +0 -122
- package/src/codegen/generators/CppComponentCodeGenerator.ts +0 -95
- package/src/codegen/generators/LibGlueCodeGenerator.ts +0 -98
- package/src/codegen/generators/NativeModuleCodeGenerator.ts +0 -124
- package/src/codegen/generators/SharedComponentCodeGenerator.ts +0 -57
- package/src/codegen/generators/UberGeneratorV1.ts +0 -75
- package/src/codegen/generators/UberGeneratorV2.ts +0 -114
- package/src/codegen/generators/index.ts +0 -15
- package/src/codegen/index.ts +0 -9
- package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +0 -128
- package/src/codegen/templates/BasePackageHTemplate.ts +0 -159
- package/src/codegen/templates/ComponentDescriptorHTemplate.ts +0 -63
- package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +0 -121
- package/src/codegen/templates/ComponentUtilsTSTemplate.ts +0 -222
- package/src/codegen/templates/IndexTSTemplate.ts +0 -62
- package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +0 -150
- package/src/codegen/templates/TurboModuleCppTemplate.ts +0 -61
- package/src/codegen/templates/TurboModuleHTemplate.ts +0 -42
- package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +0 -101
- package/src/codegen/templates/index.ts +0 -16
- package/src/commands/bundle-harmony.ts +0 -134
- package/src/commands/codegen-harmony.ts +0 -297
- package/src/commands/codegen-lib-harmony.ts +0 -389
- package/src/commands/create-metro-host-constants.ts +0 -55
- package/src/commands/index.ts +0 -16
- package/src/commands/init.ts +0 -755
- package/src/commands/link-harmony.ts +0 -102
- package/src/commands/pack-harmony.ts +0 -128
- package/src/commands/run-harmony.ts +0 -506
- package/src/commands/types.ts +0 -21
- package/src/commands/unpack-harmony.ts +0 -238
- package/src/commands/verify-package-harmony.ts +0 -113
- package/src/core/AbsolutePath.ts +0 -66
- package/src/core/CodegenConfig.ts +0 -67
- package/src/core/DescriptiveError.ts +0 -68
- package/src/core/FileSystem.ts +0 -57
- package/src/core/OHPackageJSON5.ts +0 -30
- package/src/core/PackageJSON.ts +0 -104
- package/src/core/ProjectDependenciesManager.ts +0 -103
- package/src/core/ValidationError.ts +0 -8
- package/src/core/ValueObject.ts +0 -9
- package/src/core/fs.ts +0 -38
- package/src/core/index.ts +0 -17
- package/src/index.ts +0 -33
- package/src/io/CliExecutor.ts +0 -69
- package/src/io/Logger.ts +0 -112
- package/src/io/RealFS.ts +0 -62
- package/src/io/TarGz.ts +0 -33
- package/src/io/__fixtures__.ts +0 -139
- package/src/io/fsUtils.ts +0 -44
- package/src/io/index.ts +0 -11
- package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +0 -35
- package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +0 -31
- package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +0 -25
- package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +0 -54
- package/src/package-verifier/checks/index.ts +0 -11
- package/src/package-verifier/index.ts +0 -9
- package/src/package-verifier/types.ts +0 -19
- package/src/package-verifier/verify-package.ts +0 -123
- package/src/simulator/LaunchSimulator.ts +0 -352
- package/src/simulator/index.ts +0 -8
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# @react-native-oh/react-native-harmony-cli
|
|
2
|
-
|
|
3
|
-
Please refer to: [RNOH repo](https://gitee.com/openharmony-sig/ohos_react_native) for more detail.
|
|
4
|
-
|
|
5
|
-
# Documentation
|
|
6
|
-
|
|
7
|
-
- [中文](https://gitee.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/README.md)
|
|
8
|
-
- [English](https://gitee.com/openharmony-sig/ohos_react_native/blob/master/docs/en/README.md)
|
|
9
|
-
|
|
10
|
-
# License
|
|
11
|
-
|
|
1
|
+
# @react-native-oh/react-native-harmony-cli
|
|
2
|
+
|
|
3
|
+
Please refer to: [RNOH repo](https://gitee.com/openharmony-sig/ohos_react_native) for more detail.
|
|
4
|
+
|
|
5
|
+
# Documentation
|
|
6
|
+
|
|
7
|
+
- [中文](https://gitee.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/README.md)
|
|
8
|
+
- [English](https://gitee.com/openharmony-sig/ohos_react_native/blob/master/docs/en/README.md)
|
|
9
|
+
|
|
10
|
+
# License
|
|
11
|
+
|
|
12
12
|
This library is licensed under The [MIT License (MIT)](https://gitee.com/openharmony-sig/ohos_react_native)
|
package/dist/assetResolver.js
CHANGED
|
@@ -8,8 +8,32 @@ 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
|
+
}
|
|
13
37
|
};
|
|
14
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
39
|
exports.copyAssets = copyAssets;
|
|
@@ -19,17 +43,18 @@ exports.copyAssets = copyAssets;
|
|
|
19
43
|
* This source code is licensed under the MIT license found in the
|
|
20
44
|
* LICENSE-MIT file in the root directory of this source tree.
|
|
21
45
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
46
|
+
var fs_1 = require("fs");
|
|
47
|
+
var path_1 = require("path");
|
|
48
|
+
var ALLOWED_SCALES = [1, 2, 3, 4];
|
|
25
49
|
function filterAssetScales(scales) {
|
|
26
|
-
|
|
50
|
+
var result = scales.filter(function (scale) { return ALLOWED_SCALES.includes(scale); });
|
|
27
51
|
if (result.length === 0 && scales.length > 0) {
|
|
28
52
|
// No matching scale found, but there are some available. Ideally we don't
|
|
29
53
|
// want to be in this situation and should throw, but for now as a fallback
|
|
30
54
|
// let's just use the closest larger image
|
|
31
|
-
|
|
32
|
-
for (
|
|
55
|
+
var maxScale = ALLOWED_SCALES[ALLOWED_SCALES.length - 1];
|
|
56
|
+
for (var _i = 0, scales_1 = scales; _i < scales_1.length; _i++) {
|
|
57
|
+
var scale = scales_1[_i];
|
|
33
58
|
if (scale > maxScale) {
|
|
34
59
|
result.push(scale);
|
|
35
60
|
break;
|
|
@@ -43,63 +68,69 @@ function filterAssetScales(scales) {
|
|
|
43
68
|
return result;
|
|
44
69
|
}
|
|
45
70
|
function copyAssets(logger, assetsData, assetsDest) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
asset
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
+
var filesToCopy, addAssetToCopy;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
if (assetsDest == null) {
|
|
75
|
+
logger.warn(function (s) { return 'Assets destination folder is not set, skipping...'; });
|
|
76
|
+
return [2 /*return*/];
|
|
77
|
+
}
|
|
78
|
+
filesToCopy = {};
|
|
79
|
+
addAssetToCopy = function (asset) {
|
|
80
|
+
var validScales = filterAssetScales(asset.scales);
|
|
81
|
+
asset.scales.forEach(function (scale, idx) {
|
|
82
|
+
if (!validScales.includes(scale)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
var src = asset.files[idx];
|
|
86
|
+
var dest = path_1.default.join(assetsDest, getAssetDestRelativePath(asset, scale));
|
|
87
|
+
filesToCopy[src] = dest;
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
assetsData.forEach(addAssetToCopy);
|
|
91
|
+
return [2 /*return*/, copyFiles(logger, filesToCopy)];
|
|
92
|
+
});
|
|
65
93
|
});
|
|
66
94
|
}
|
|
67
|
-
function getAssetDestRelativePath(asset, scale
|
|
68
|
-
|
|
69
|
-
|
|
95
|
+
function getAssetDestRelativePath(asset, scale) {
|
|
96
|
+
if (scale === void 0) { scale = 1; }
|
|
97
|
+
var suffix = scale === 1 ? '' : "@".concat(scale, "x");
|
|
98
|
+
var fileName = getResourceIdentifier(asset);
|
|
70
99
|
// Assets can have relative paths outside of the project root.
|
|
71
100
|
// Replace `../` with `_` to make sure they don't end up outside of
|
|
72
101
|
// the expected assets directory.
|
|
73
|
-
return
|
|
102
|
+
return "".concat(fileName + suffix, ".").concat(asset.type).replace(/\.\.\//g, '_');
|
|
74
103
|
}
|
|
75
104
|
function getResourceIdentifier(asset) {
|
|
76
|
-
|
|
77
|
-
return
|
|
105
|
+
var folderPath = getBasePath(asset);
|
|
106
|
+
return "".concat(folderPath, "/").concat(asset.name).replace(/^assets\//, '');
|
|
78
107
|
}
|
|
79
108
|
function getBasePath(asset) {
|
|
80
|
-
|
|
109
|
+
var basePath = asset.httpServerLocation;
|
|
81
110
|
return basePath.startsWith('/') ? basePath.slice(1) : basePath;
|
|
82
111
|
}
|
|
83
112
|
function copyFiles(logger, fileDestBySrc) {
|
|
84
|
-
|
|
113
|
+
var fileSources = Object.keys(fileDestBySrc);
|
|
85
114
|
if (fileSources.length === 0) {
|
|
86
115
|
return Promise.resolve();
|
|
87
116
|
}
|
|
88
|
-
|
|
89
|
-
return new Promise((resolve, reject)
|
|
90
|
-
|
|
117
|
+
var assetFilesCount = fileSources.length;
|
|
118
|
+
return new Promise(function (resolve, reject) {
|
|
119
|
+
var copyNext = function (error) {
|
|
91
120
|
if (error) {
|
|
92
121
|
reject(error);
|
|
93
122
|
return;
|
|
94
123
|
}
|
|
95
124
|
if (fileSources.length === 0) {
|
|
96
|
-
logger.info(()
|
|
125
|
+
logger.info(function () {
|
|
126
|
+
return "Copied ".concat(assetFilesCount, " ").concat(assetFilesCount === 1 ? 'asset' : 'assets');
|
|
127
|
+
});
|
|
97
128
|
resolve();
|
|
98
129
|
}
|
|
99
130
|
else {
|
|
100
131
|
// fileSources.length === 0 is checked in previous branch, so this is string
|
|
101
|
-
|
|
102
|
-
|
|
132
|
+
var src = fileSources.shift();
|
|
133
|
+
var dest = fileDestBySrc[src];
|
|
103
134
|
copyFile(src, dest, copyNext);
|
|
104
135
|
}
|
|
105
136
|
};
|
|
@@ -107,8 +138,8 @@ function copyFiles(logger, fileDestBySrc) {
|
|
|
107
138
|
});
|
|
108
139
|
}
|
|
109
140
|
function copyFile(src, dest, onFinished) {
|
|
110
|
-
|
|
111
|
-
fs_1.default.mkdir(destDir, { recursive: true }, (err)
|
|
141
|
+
var destDir = path_1.default.dirname(dest);
|
|
142
|
+
fs_1.default.mkdir(destDir, { recursive: true }, function (err) {
|
|
112
143
|
if (err) {
|
|
113
144
|
onFinished(err);
|
|
114
145
|
return;
|