@react-native-oh/react-native-harmony-cli 0.0.36 → 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.
Files changed (137) hide show
  1. package/README.md +11 -11
  2. package/dist/assetResolver.js +74 -43
  3. package/dist/autolinking/Autolinking.js +183 -179
  4. package/dist/codegen/core/CodegenError.js +23 -3
  5. package/dist/codegen/core/EventUtils.js +3 -3
  6. package/dist/codegen/core/TypeAnnotationToTS.js +28 -24
  7. package/dist/codegen/core/UberSchema.js +96 -57
  8. package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +42 -28
  9. package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +34 -27
  10. package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +33 -25
  11. package/dist/codegen/generators/CppComponentCodeGenerator.js +28 -23
  12. package/dist/codegen/generators/LibGlueCodeGenerator.js +29 -26
  13. package/dist/codegen/generators/NativeModuleCodeGenerator.js +30 -25
  14. package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
  15. package/dist/codegen/generators/UberGeneratorV1.js +24 -18
  16. package/dist/codegen/generators/UberGeneratorV2.js +36 -28
  17. package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +24 -50
  18. package/dist/codegen/templates/BasePackageHTemplate.js +21 -109
  19. package/dist/codegen/templates/ComponentDescriptorHTemplate.js +8 -53
  20. package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +27 -75
  21. package/dist/codegen/templates/ComponentUtilsTSTemplate.js +29 -162
  22. package/dist/codegen/templates/IndexTSTemplate.js +17 -37
  23. package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +24 -108
  24. package/dist/codegen/templates/TurboModuleCppTemplate.js +15 -38
  25. package/dist/codegen/templates/TurboModuleHTemplate.js +11 -32
  26. package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +19 -52
  27. package/dist/commands/bundle-harmony.js +138 -53
  28. package/dist/commands/codegen-harmony.js +175 -104
  29. package/dist/commands/codegen-lib-harmony.js +116 -76
  30. package/dist/commands/create-metro-host-constants.js +47 -18
  31. package/dist/commands/init.js +961 -537
  32. package/dist/commands/link-harmony.js +71 -33
  33. package/dist/commands/pack-harmony.js +108 -47
  34. package/dist/commands/run-harmony.js +520 -352
  35. package/dist/commands/unpack-harmony.js +198 -105
  36. package/dist/commands/verify-package-harmony.js +108 -54
  37. package/dist/core/AbsolutePath.js +47 -31
  38. package/dist/core/CodegenConfig.js +22 -24
  39. package/dist/core/DescriptiveError.js +37 -18
  40. package/dist/core/FileSystem.js +18 -14
  41. package/dist/core/OHPackageJSON5.js +23 -17
  42. package/dist/core/PackageJSON.js +42 -26
  43. package/dist/core/ProjectDependenciesManager.js +96 -46
  44. package/dist/core/ValidationError.js +22 -2
  45. package/dist/core/fs.js +6 -9
  46. package/dist/index.js +1 -1
  47. package/dist/io/CliExecutor.js +98 -46
  48. package/dist/io/Logger.js +46 -40
  49. package/dist/io/RealFS.js +88 -35
  50. package/dist/io/TarGz.js +8 -11
  51. package/dist/io/__fixtures__.js +141 -79
  52. package/dist/io/fsUtils.js +12 -13
  53. package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +47 -19
  54. package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +41 -13
  55. package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +38 -8
  56. package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +54 -22
  57. package/dist/package-verifier/verify-package.js +132 -55
  58. package/dist/simulator/LaunchSimulator.js +395 -0
  59. package/dist/simulator/index.js +23 -0
  60. package/jest.config.js +12 -12
  61. package/package.json +78 -70
  62. package/react-native.config.js +17 -17
  63. package/tsconfig.build.json +6 -6
  64. package/tsconfig.json +2 -2
  65. package/.prettierrc +0 -6
  66. package/src/assetResolver.ts +0 -134
  67. package/src/autolinking/Autolinking.test.ts +0 -483
  68. package/src/autolinking/Autolinking.ts +0 -382
  69. package/src/autolinking/index.ts +0 -8
  70. package/src/codegen/core/CodeGenerator.ts +0 -16
  71. package/src/codegen/core/CodegenError.ts +0 -10
  72. package/src/codegen/core/EventUtils.ts +0 -23
  73. package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -82
  74. package/src/codegen/core/TypeAnnotationToTS.ts +0 -195
  75. package/src/codegen/core/UberSchema.ts +0 -152
  76. package/src/codegen/core/index.ts +0 -12
  77. package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +0 -120
  78. package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +0 -128
  79. package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +0 -122
  80. package/src/codegen/generators/CppComponentCodeGenerator.ts +0 -95
  81. package/src/codegen/generators/LibGlueCodeGenerator.ts +0 -98
  82. package/src/codegen/generators/NativeModuleCodeGenerator.ts +0 -124
  83. package/src/codegen/generators/SharedComponentCodeGenerator.ts +0 -57
  84. package/src/codegen/generators/UberGeneratorV1.ts +0 -75
  85. package/src/codegen/generators/UberGeneratorV2.ts +0 -114
  86. package/src/codegen/generators/index.ts +0 -15
  87. package/src/codegen/index.ts +0 -9
  88. package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +0 -128
  89. package/src/codegen/templates/BasePackageHTemplate.ts +0 -147
  90. package/src/codegen/templates/ComponentDescriptorHTemplate.ts +0 -63
  91. package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +0 -121
  92. package/src/codegen/templates/ComponentUtilsTSTemplate.ts +0 -222
  93. package/src/codegen/templates/IndexTSTemplate.ts +0 -62
  94. package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +0 -138
  95. package/src/codegen/templates/TurboModuleCppTemplate.ts +0 -61
  96. package/src/codegen/templates/TurboModuleHTemplate.ts +0 -42
  97. package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +0 -101
  98. package/src/codegen/templates/index.ts +0 -16
  99. package/src/commands/bundle-harmony.ts +0 -134
  100. package/src/commands/codegen-harmony.ts +0 -297
  101. package/src/commands/codegen-lib-harmony.ts +0 -389
  102. package/src/commands/create-metro-host-constants.ts +0 -55
  103. package/src/commands/index.ts +0 -16
  104. package/src/commands/init.ts +0 -755
  105. package/src/commands/link-harmony.ts +0 -102
  106. package/src/commands/pack-harmony.ts +0 -128
  107. package/src/commands/run-harmony.ts +0 -478
  108. package/src/commands/types.ts +0 -21
  109. package/src/commands/unpack-harmony.ts +0 -238
  110. package/src/commands/verify-package-harmony.ts +0 -113
  111. package/src/core/AbsolutePath.ts +0 -66
  112. package/src/core/CodegenConfig.ts +0 -67
  113. package/src/core/DescriptiveError.ts +0 -68
  114. package/src/core/FileSystem.ts +0 -57
  115. package/src/core/OHPackageJSON5.ts +0 -30
  116. package/src/core/PackageJSON.ts +0 -104
  117. package/src/core/ProjectDependenciesManager.ts +0 -103
  118. package/src/core/ValidationError.ts +0 -8
  119. package/src/core/ValueObject.ts +0 -9
  120. package/src/core/fs.ts +0 -38
  121. package/src/core/index.ts +0 -17
  122. package/src/index.ts +0 -33
  123. package/src/io/CliExecutor.ts +0 -69
  124. package/src/io/Logger.ts +0 -112
  125. package/src/io/RealFS.ts +0 -62
  126. package/src/io/TarGz.ts +0 -33
  127. package/src/io/__fixtures__.ts +0 -139
  128. package/src/io/fsUtils.ts +0 -44
  129. package/src/io/index.ts +0 -11
  130. package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +0 -35
  131. package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +0 -31
  132. package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +0 -25
  133. package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +0 -54
  134. package/src/package-verifier/checks/index.ts +0 -11
  135. package/src/package-verifier/index.ts +0 -9
  136. package/src/package-verifier/types.ts +0 -19
  137. package/src/package-verifier/verify-package.ts +0 -123
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)
@@ -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 __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
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
- const fs_1 = __importDefault(require("fs"));
23
- const path_1 = __importDefault(require("path"));
24
- const ALLOWED_SCALES = [1, 2, 3, 4];
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
- const result = scales.filter(scale => ALLOWED_SCALES.includes(scale));
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
- const maxScale = ALLOWED_SCALES[ALLOWED_SCALES.length - 1];
32
- for (const scale of scales) {
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
- if (assetsDest == null) {
48
- logger.warn((s) => 'Assets destination folder is not set, skipping...');
49
- return;
50
- }
51
- const filesToCopy = {};
52
- const addAssetToCopy = (asset) => {
53
- const validScales = filterAssetScales(asset.scales);
54
- asset.scales.forEach((scale, idx) => {
55
- if (!validScales.includes(scale)) {
56
- return;
57
- }
58
- const src = asset.files[idx];
59
- const dest = path_1.default.join(assetsDest, getAssetDestRelativePath(asset, scale));
60
- filesToCopy[src] = dest;
61
- });
62
- };
63
- assetsData.forEach(addAssetToCopy);
64
- return copyFiles(logger, filesToCopy);
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 = 1) {
68
- const suffix = scale === 1 ? '' : `@${scale}x`;
69
- const fileName = getResourceIdentifier(asset);
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 `${fileName + suffix}.${asset.type}`.replace(/\.\.\//g, '_');
102
+ return "".concat(fileName + suffix, ".").concat(asset.type).replace(/\.\.\//g, '_');
74
103
  }
75
104
  function getResourceIdentifier(asset) {
76
- const folderPath = getBasePath(asset);
77
- return `${folderPath}/${asset.name}`.replace(/^assets\//, '');
105
+ var folderPath = getBasePath(asset);
106
+ return "".concat(folderPath, "/").concat(asset.name).replace(/^assets\//, '');
78
107
  }
79
108
  function getBasePath(asset) {
80
- const basePath = asset.httpServerLocation;
109
+ var basePath = asset.httpServerLocation;
81
110
  return basePath.startsWith('/') ? basePath.slice(1) : basePath;
82
111
  }
83
112
  function copyFiles(logger, fileDestBySrc) {
84
- const fileSources = Object.keys(fileDestBySrc);
113
+ var fileSources = Object.keys(fileDestBySrc);
85
114
  if (fileSources.length === 0) {
86
115
  return Promise.resolve();
87
116
  }
88
- const assetFilesCount = fileSources.length;
89
- return new Promise((resolve, reject) => {
90
- const copyNext = (error) => {
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(() => `Copied ${assetFilesCount} ${assetFilesCount === 1 ? 'asset' : 'assets'}`);
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
- const src = fileSources.shift();
102
- const dest = fileDestBySrc[src];
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
- const destDir = path_1.default.dirname(dest);
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;