@react-native-oh/react-native-harmony-cli 0.82.7 → 0.82.18
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 +31 -3
- package/dist/autolinking/Autolinking.js +8 -1
- package/dist/autolinking/JSON5Writer.js +61 -0
- package/dist/autolinking/index.js +6 -0
- package/dist/commands/bundle-harmony.js +15 -0
- package/harmony/{rnoh-hvigor-plugin-0.82.7.tgz → rnoh-hvigor-plugin-0.82.18.tgz} +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/00a68392 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0544a6cc +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0f36b2db +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/12f23f1e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/13d95d98 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1629e86b +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/180c8379 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1a697147 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1a8271b1 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1b7fa689 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/255a9f13 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/268d155b +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/27db9aa4 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/28db79ed +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2dc2bbcb +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2df5f8c5 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2f88aedb +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/31b3a7ea +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/36335b1c +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/38fca641 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/397722eb +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/397b6432 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3b17421f +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/454f5e18 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/45ec6cce +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/482d51b1 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4ac5cd67 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4d40499a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4dcad919 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4fc31929 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/54edc8f5 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/558a5405 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/58d2b670 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5ec7feca +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/62180f3e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/63981360 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/64096c89 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/64af560b +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6585e783 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6954304f +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/69fd6235 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6d3a0478 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6e131db7 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/778cd8f1 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/788206b6 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7882dc26 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7b3c14f7 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7cdfe667 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8048c487 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8332d9a3 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/84e5b603 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/854d8127 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/88c97376 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/90d5f644 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/967e25ac +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/969896c2 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9790193e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/97ae40c5 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9a5bf482 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a07adeb9 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a427f355 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a9dd7eb7 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a9e9d79e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ab920855 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ab9e3038 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/af054988 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/afe03e51 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b3b83913 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b4db7b4d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b5225355 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b8c00f06 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b917a081 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b9e2f3bd +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/bd70db0e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/bdbda648 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/be1e5469 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c9462295 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ca6e5efa +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/caf52beb +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cb268960 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cca16b15 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cfc1c937 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d10e6e05 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d172fc04 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d4e94e50 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d59f8d2c +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/da964053 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e0bb712a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e3e6ca34 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e50f7385 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f1a1d282 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f2514c3c +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f66207cf +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f8d129ce +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/fb1e9558 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ff7e3608 +0 -0
- package/package.json +2 -1
- package/src/assetResolver.ts +37 -3
- package/src/autolinking/Autolinking.test.ts +70 -17
- package/src/autolinking/Autolinking.ts +14 -9
- package/src/autolinking/JSON5Writer.ts +70 -0
- package/src/autolinking/index.ts +7 -0
- package/src/commands/bundle-harmony.ts +17 -0
package/dist/assetResolver.js
CHANGED
|
@@ -21,6 +21,13 @@ exports.copyAssets = copyAssets;
|
|
|
21
21
|
*/
|
|
22
22
|
const fs_1 = __importDefault(require("fs"));
|
|
23
23
|
const path_1 = __importDefault(require("path"));
|
|
24
|
+
const ENABLE_DEBUG_LOG = process.env.RNOH_BUNDLE_DEBUG === 'true';
|
|
25
|
+
function debugLog(message) {
|
|
26
|
+
if (ENABLE_DEBUG_LOG) {
|
|
27
|
+
const timestamp = new Date().toISOString().replace('T', ' ').substring(0, 23);
|
|
28
|
+
console.log(`[${timestamp}] ${message}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
24
31
|
const ALLOWED_SCALES = [1, 2, 3, 4];
|
|
25
32
|
function filterAssetScales(scales) {
|
|
26
33
|
const result = scales.filter(scale => ALLOWED_SCALES.includes(scale));
|
|
@@ -94,7 +101,9 @@ function copyFiles(logger, fileDestBySrc) {
|
|
|
94
101
|
}
|
|
95
102
|
if (fileSources.length === 0) {
|
|
96
103
|
logger.info(() => `Copied ${assetFilesCount} ${assetFilesCount === 1 ? 'asset' : 'assets'}`);
|
|
104
|
+
debugLog('All assets copied, resolving promise...');
|
|
97
105
|
resolve();
|
|
106
|
+
debugLog('Assets copy promise resolved');
|
|
98
107
|
}
|
|
99
108
|
else {
|
|
100
109
|
// fileSources.length === 0 is checked in previous branch, so this is string
|
|
@@ -113,8 +122,27 @@ function copyFile(src, dest, onFinished) {
|
|
|
113
122
|
onFinished(err);
|
|
114
123
|
return;
|
|
115
124
|
}
|
|
116
|
-
fs_1.default.createReadStream(src)
|
|
117
|
-
|
|
118
|
-
|
|
125
|
+
const readStream = fs_1.default.createReadStream(src);
|
|
126
|
+
const writeStream = fs_1.default.createWriteStream(dest);
|
|
127
|
+
let finished = false;
|
|
128
|
+
const handleError = (err) => {
|
|
129
|
+
if (!finished) {
|
|
130
|
+
finished = true;
|
|
131
|
+
console.error(`[Asset Copy Error] ${src} -> ${dest}:`, err.message);
|
|
132
|
+
readStream.destroy();
|
|
133
|
+
writeStream.destroy();
|
|
134
|
+
onFinished(err);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const handleFinish = () => {
|
|
138
|
+
if (!finished) {
|
|
139
|
+
finished = true;
|
|
140
|
+
onFinished();
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
readStream.on('error', handleError);
|
|
144
|
+
writeStream.on('error', handleError);
|
|
145
|
+
writeStream.on('finish', handleFinish);
|
|
146
|
+
readStream.pipe(writeStream);
|
|
119
147
|
});
|
|
120
148
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 Huawei Technologies Co., Ltd.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE-MIT file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
2
8
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
9
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
10
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -18,6 +24,7 @@ const core_1 = require("../core");
|
|
|
18
24
|
const mustache_1 = __importDefault(require("mustache"));
|
|
19
25
|
const case_1 = __importDefault(require("case"));
|
|
20
26
|
const node_path_1 = __importDefault(require("node:path"));
|
|
27
|
+
const JSON5Writer_1 = require("./JSON5Writer");
|
|
21
28
|
const ETS_RNOH_PACKAGES_FACTORY_TEMPLATE = `
|
|
22
29
|
/*
|
|
23
30
|
* This file was generated by RNOH autolinking.
|
|
@@ -209,7 +216,7 @@ class Autolinking {
|
|
|
209
216
|
],
|
|
210
217
|
ohPackagePathAndContent: [
|
|
211
218
|
input.ohPackagePathAndContent[0],
|
|
212
|
-
|
|
219
|
+
JSON5Writer_1.JSON5Writer.updateDependenciesWithFallback(input.ohPackagePathAndContent[1], Object.assign(Object.assign({}, unmanagedNativeDependencySpecifierByName), managedNativeDependencySpecifierByName)),
|
|
213
220
|
],
|
|
214
221
|
};
|
|
215
222
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 Huawei Technologies Co., Ltd.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE-MIT file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.JSON5Writer = void 0;
|
|
13
|
+
const json5_1 = __importDefault(require("json5"));
|
|
14
|
+
/**
|
|
15
|
+
* A utility class for modifying JSON5 content while preserving comments and formatting.
|
|
16
|
+
* Uses json5-writer's AST-based transformation to maintain the original structure.
|
|
17
|
+
*/
|
|
18
|
+
class JSON5Writer {
|
|
19
|
+
/**
|
|
20
|
+
* Updates the dependencies in a JSON5 string while preserving comments and formatting.
|
|
21
|
+
*
|
|
22
|
+
* @param content - The original JSON5 content
|
|
23
|
+
* @param newDependencies - The new dependencies object to set
|
|
24
|
+
* @returns The modified JSON5 content with preserved comments
|
|
25
|
+
*/
|
|
26
|
+
static updateDependencies(content, newDependencies) {
|
|
27
|
+
const json5Writer = require('json5-writer');
|
|
28
|
+
// Parse the original content to get all fields
|
|
29
|
+
const parsed = json5_1.default.parse(content);
|
|
30
|
+
// Create the new object with updated dependencies
|
|
31
|
+
const newObject = Object.assign(Object.assign({}, parsed), { dependencies: newDependencies });
|
|
32
|
+
// Load the original content into json5-writer to preserve comments
|
|
33
|
+
const writer = json5Writer.load(content);
|
|
34
|
+
// Write the new object, which will preserve comments
|
|
35
|
+
writer.write(newObject);
|
|
36
|
+
// Return the modified source with JSON5-style formatting
|
|
37
|
+
// Use double quotes for both keys and values, and trailing commas
|
|
38
|
+
// quoteKeys: true ensures keys with special characters (like @, /, -) are properly quoted
|
|
39
|
+
return writer.toSource({ quote: 'double', quoteKeys: true, trailingComma: true }) + '\n';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Updates dependencies with fallback to standard JSON5 stringify if preservation fails.
|
|
43
|
+
* This ensures backward compatibility.
|
|
44
|
+
*
|
|
45
|
+
* @param content - The original JSON5 content
|
|
46
|
+
* @param newDependencies - The new dependencies object to set
|
|
47
|
+
* @returns The modified JSON5 content
|
|
48
|
+
*/
|
|
49
|
+
static updateDependenciesWithFallback(content, newDependencies) {
|
|
50
|
+
try {
|
|
51
|
+
return this.updateDependencies(content, newDependencies);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
// Fallback to JSON5 stringify if AST transformation fails
|
|
55
|
+
const parsed = json5_1.default.parse(content);
|
|
56
|
+
const result = Object.assign(Object.assign({}, parsed), { dependencies: newDependencies });
|
|
57
|
+
return json5_1.default.stringify(result, { space: 2, quote: '"' }) + '\n';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.JSON5Writer = JSON5Writer;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 Huawei Technologies Co., Ltd.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE-MIT file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
2
8
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
9
|
if (k2 === undefined) k2 = k;
|
|
4
10
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -35,6 +35,13 @@ const child_process_1 = require("child_process");
|
|
|
35
35
|
const io_1 = require("../io");
|
|
36
36
|
const core_1 = require("../core");
|
|
37
37
|
const node_crypto_1 = require("node:crypto");
|
|
38
|
+
const ENABLE_DEBUG_LOG = process.env.RNOH_BUNDLE_DEBUG === 'true';
|
|
39
|
+
function debugLog(message) {
|
|
40
|
+
if (ENABLE_DEBUG_LOG) {
|
|
41
|
+
const timestamp = new Date().toISOString().replace('T', ' ').substring(0, 23);
|
|
42
|
+
console.log(`[${timestamp}] ${message}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
38
45
|
const HERMESC_BIN_PATH = {
|
|
39
46
|
darwin: path_1.default.normalize('osx-bin/hermesc'),
|
|
40
47
|
linux: path_1.default.normalize('linux64-bin/hermesc'),
|
|
@@ -141,7 +148,9 @@ exports.commandBundleHarmony = {
|
|
|
141
148
|
});
|
|
142
149
|
const _b = yield createBundle(metroConfig, buildOptions), { assets } = _b, bundle = __rest(_b, ["assets"]);
|
|
143
150
|
if (shouldGenerateHbcBundle) {
|
|
151
|
+
debugLog('Starting Hermes bytecode compilation...');
|
|
144
152
|
yield saveHbcBundle(logger, bundle.code, bundleOutput, args.hermescDir, args.hermescOptions);
|
|
153
|
+
debugLog('Hermes bytecode compilation finished');
|
|
145
154
|
}
|
|
146
155
|
else {
|
|
147
156
|
yield saveJSBundle(logger, bundle, bundleOutput);
|
|
@@ -149,7 +158,9 @@ exports.commandBundleHarmony = {
|
|
|
149
158
|
maybeSaveSourceMap(logger, bundle, args.sourcemapOutput);
|
|
150
159
|
if (assets) {
|
|
151
160
|
yield (0, assetResolver_1.copyAssets)(logger, assets, assetsDest);
|
|
161
|
+
debugLog('Assets copy completed, cleaning up...');
|
|
152
162
|
}
|
|
163
|
+
debugLog('Bundle process finished, exiting');
|
|
153
164
|
}
|
|
154
165
|
catch (err) {
|
|
155
166
|
if (err instanceof core_1.DescriptiveError) {
|
|
@@ -195,15 +206,19 @@ function saveHbcBundle(logger, bundleCode, bundleOutput, hermescPath, hermescOpt
|
|
|
195
206
|
});
|
|
196
207
|
}
|
|
197
208
|
const tmpBundlePath = `${os_1.default.tmpdir()}${path_1.default.sep}b-${(0, node_crypto_1.randomUUID)()}.harmony.js`;
|
|
209
|
+
debugLog('Writing temporary JS bundle...');
|
|
198
210
|
yield fs_extra_1.default.writeFile(tmpBundlePath, bundleCode);
|
|
199
211
|
const hbcFilePath = bundleOutput.endsWith('.hbc')
|
|
200
212
|
? bundleOutput
|
|
201
213
|
: path_1.default.join(path_1.default.dirname(bundleOutput), 'hermes_bundle.hbc');
|
|
202
214
|
const hermescOptionsString = (hermescOptions === null || hermescOptions === void 0 ? void 0 : hermescOptions.map((e) => `-${e}`).join(' ')) || '';
|
|
215
|
+
debugLog(`Executing hermesc compiler: ${resolvedHermescPath}`);
|
|
203
216
|
(0, child_process_1.execSync)(`${resolvedHermescPath} ${hermescOptionsString} --emit-binary -out ${hbcFilePath} ${tmpBundlePath}`, {
|
|
204
217
|
stdio: 'inherit',
|
|
205
218
|
});
|
|
219
|
+
debugLog('Hermesc execution completed, cleaning up temp file...');
|
|
206
220
|
node_fs_1.default.unlinkSync(tmpBundlePath);
|
|
221
|
+
debugLog('Temp file deleted');
|
|
207
222
|
logger.info((s) => `Created ${hbcFilePath}`);
|
|
208
223
|
});
|
|
209
224
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-oh/react-native-harmony-cli",
|
|
3
|
-
"version": "0.82.
|
|
3
|
+
"version": "0.82.18",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"fs-extra": "^11.1.1",
|
|
55
55
|
"inquirer": "^12.6.3",
|
|
56
56
|
"json5": "^2.2.3",
|
|
57
|
+
"json5-writer": "^0.2.0",
|
|
57
58
|
"memfs": "4.12.0",
|
|
58
59
|
"mustache": "^4.2.0",
|
|
59
60
|
"tar": "^6.1.15",
|
package/src/assetResolver.ts
CHANGED
|
@@ -12,6 +12,15 @@ import { Logger } from './io';
|
|
|
12
12
|
type Path = string;
|
|
13
13
|
type CopiedFiles = Record<Path, Path>;
|
|
14
14
|
|
|
15
|
+
const ENABLE_DEBUG_LOG = process.env.RNOH_BUNDLE_DEBUG === 'true';
|
|
16
|
+
|
|
17
|
+
function debugLog(message: string) {
|
|
18
|
+
if (ENABLE_DEBUG_LOG) {
|
|
19
|
+
const timestamp = new Date().toISOString().replace('T', ' ').substring(0, 23);
|
|
20
|
+
console.log(`[${timestamp}] ${message}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
15
24
|
const ALLOWED_SCALES: number[] = [1, 2, 3, 4];
|
|
16
25
|
|
|
17
26
|
function filterAssetScales(
|
|
@@ -104,7 +113,9 @@ function copyFiles(logger: Logger, fileDestBySrc: CopiedFiles) {
|
|
|
104
113
|
assetFilesCount === 1 ? 'asset' : 'assets'
|
|
105
114
|
}`
|
|
106
115
|
);
|
|
116
|
+
debugLog('All assets copied, resolving promise...');
|
|
107
117
|
resolve();
|
|
118
|
+
debugLog('Assets copy promise resolved');
|
|
108
119
|
} else {
|
|
109
120
|
// fileSources.length === 0 is checked in previous branch, so this is string
|
|
110
121
|
const src = fileSources.shift()!;
|
|
@@ -127,8 +138,31 @@ function copyFile(
|
|
|
127
138
|
onFinished(err);
|
|
128
139
|
return;
|
|
129
140
|
}
|
|
130
|
-
fs.createReadStream(src)
|
|
131
|
-
|
|
132
|
-
|
|
141
|
+
const readStream = fs.createReadStream(src);
|
|
142
|
+
const writeStream = fs.createWriteStream(dest);
|
|
143
|
+
|
|
144
|
+
let finished = false;
|
|
145
|
+
const handleError = (err: Error) => {
|
|
146
|
+
if (!finished) {
|
|
147
|
+
finished = true;
|
|
148
|
+
console.error(`[Asset Copy Error] ${src} -> ${dest}:`, err.message);
|
|
149
|
+
readStream.destroy();
|
|
150
|
+
writeStream.destroy();
|
|
151
|
+
onFinished(err);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const handleFinish = () => {
|
|
156
|
+
if (!finished) {
|
|
157
|
+
finished = true;
|
|
158
|
+
onFinished();
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
readStream.on('error', handleError);
|
|
163
|
+
writeStream.on('error', handleError);
|
|
164
|
+
writeStream.on('finish', handleFinish);
|
|
165
|
+
|
|
166
|
+
readStream.pipe(writeStream);
|
|
133
167
|
});
|
|
134
168
|
}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Huawei Technologies Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { Autolinking, AutolinkingConfig } from './Autolinking';
|
|
2
9
|
import { NestedDirectoryJSON } from 'memfs';
|
|
3
10
|
import { AbsolutePath, DescriptiveError } from '../core/';
|
|
4
11
|
import { MockedLogger, MemFS } from '../io/__fixtures__';
|
|
5
|
-
import pathUtils from
|
|
12
|
+
import pathUtils from 'node:path';
|
|
6
13
|
|
|
7
14
|
function createAutolinking({
|
|
8
15
|
fsStructure,
|
|
@@ -91,16 +98,13 @@ it('should generate correct templates with scoped package default configuration'
|
|
|
91
98
|
|
|
92
99
|
await runAutolinking();
|
|
93
100
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
}
|
|
103
|
-
`.trimStart()
|
|
101
|
+
const ohPackageContent = memFS.readTextSync(
|
|
102
|
+
new AbsolutePath('./harmony/oh-package.json5')
|
|
103
|
+
);
|
|
104
|
+
expect(ohPackageContent).toContain('dependencies');
|
|
105
|
+
expect(ohPackageContent).toContain('@rnoh/rnoh--link-scoped');
|
|
106
|
+
expect(ohPackageContent).toContain(
|
|
107
|
+
'file:../node_modules/@rnoh/link-scoped/harmony/link_scoped.har'
|
|
104
108
|
);
|
|
105
109
|
expect(
|
|
106
110
|
memFS.readTextSync(
|
|
@@ -323,14 +327,18 @@ it('should log updated files', async () => {
|
|
|
323
327
|
const { logs } = await runAutolinking();
|
|
324
328
|
|
|
325
329
|
const combinedLogs = logs.map((log) => log.msg).join('\n');
|
|
326
|
-
expect(combinedLogs).toContain(
|
|
327
|
-
|
|
328
|
-
|
|
330
|
+
expect(combinedLogs).toContain(
|
|
331
|
+
pathUtils.normalize('harmony/entry/src/main/cpp/autolink.cmake')
|
|
332
|
+
);
|
|
333
|
+
expect(combinedLogs).toContain(
|
|
334
|
+
pathUtils.normalize('harmony/entry/src/main/ets/RNOHPackageFactory.ets')
|
|
329
335
|
);
|
|
330
|
-
expect(combinedLogs).toContain(
|
|
331
|
-
'harmony/entry/src/main/cpp/RNOHPackageFactory.h')
|
|
336
|
+
expect(combinedLogs).toContain(
|
|
337
|
+
pathUtils.normalize('harmony/entry/src/main/cpp/RNOHPackageFactory.h')
|
|
338
|
+
);
|
|
339
|
+
expect(combinedLogs).toContain(
|
|
340
|
+
pathUtils.normalize('harmony/oh-package.json5')
|
|
332
341
|
);
|
|
333
|
-
expect(combinedLogs).toContain(pathUtils.normalize('harmony/oh-package.json5'));
|
|
334
342
|
});
|
|
335
343
|
|
|
336
344
|
it('should log linked and skipped packages', async () => {
|
|
@@ -517,3 +525,48 @@ it('not delete packages with two hars', async () => {
|
|
|
517
525
|
const ohPackageContent = memFS.readTextSync(output.ohPackagePath);
|
|
518
526
|
expect(ohPackageContent).toContain('@rnoh/multiple-har');
|
|
519
527
|
});
|
|
528
|
+
|
|
529
|
+
it('should preserve comments in oh-package.json5', async () => {
|
|
530
|
+
const { runAutolinking, memFS } = createAutolinking({
|
|
531
|
+
fsStructure: {
|
|
532
|
+
...baseFileStructure,
|
|
533
|
+
node_modules: {
|
|
534
|
+
'test-package': {
|
|
535
|
+
harmony: {
|
|
536
|
+
'test_package.har': '',
|
|
537
|
+
},
|
|
538
|
+
'package.json': JSON.stringify({
|
|
539
|
+
name: 'test-package',
|
|
540
|
+
harmony: {
|
|
541
|
+
autolinking: true,
|
|
542
|
+
},
|
|
543
|
+
}),
|
|
544
|
+
},
|
|
545
|
+
},
|
|
546
|
+
harmony: {
|
|
547
|
+
...baseFileStructure.harmony,
|
|
548
|
+
'oh-package.json5': `{
|
|
549
|
+
// This is a top-level comment
|
|
550
|
+
"modelVersion": "5.0.0",
|
|
551
|
+
"license": "ISC",
|
|
552
|
+
/* This is a multi-line
|
|
553
|
+
comment */
|
|
554
|
+
"dependencies": {
|
|
555
|
+
// Existing dependency comment
|
|
556
|
+
"@rnoh/react-native-openharmony/": "./react_native_openharmony",
|
|
557
|
+
},
|
|
558
|
+
}`,
|
|
559
|
+
},
|
|
560
|
+
},
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
const output = await runAutolinking();
|
|
564
|
+
|
|
565
|
+
const ohPackageContent = memFS.readTextSync(output.ohPackagePath);
|
|
566
|
+
// Verify comments are preserved
|
|
567
|
+
expect(ohPackageContent).toContain('// This is a top-level comment');
|
|
568
|
+
expect(ohPackageContent).toContain('/* This is a multi-line');
|
|
569
|
+
expect(ohPackageContent).toContain('// Existing dependency comment');
|
|
570
|
+
// Verify new dependency is added
|
|
571
|
+
expect(ohPackageContent).toContain('@rnoh/test-package');
|
|
572
|
+
});
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Huawei Technologies Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import JSON5 from 'json5';
|
|
2
9
|
import {
|
|
3
10
|
AbsolutePath,
|
|
@@ -9,6 +16,7 @@ import Mustache from 'mustache';
|
|
|
9
16
|
import Case from 'case';
|
|
10
17
|
import { Logger } from '../io';
|
|
11
18
|
import pathUtils from 'node:path';
|
|
19
|
+
import { JSON5Writer } from './JSON5Writer';
|
|
12
20
|
|
|
13
21
|
type Version = string;
|
|
14
22
|
type DependencySpecifier = `file:${string}` | Version;
|
|
@@ -299,16 +307,13 @@ export class Autolinking {
|
|
|
299
307
|
],
|
|
300
308
|
ohPackagePathAndContent: [
|
|
301
309
|
input.ohPackagePathAndContent[0],
|
|
302
|
-
|
|
310
|
+
JSON5Writer.updateDependenciesWithFallback(
|
|
311
|
+
input.ohPackagePathAndContent[1],
|
|
303
312
|
{
|
|
304
|
-
...
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
},
|
|
309
|
-
},
|
|
310
|
-
{ space: 2, quote: '"' }
|
|
311
|
-
) + '\n',
|
|
313
|
+
...unmanagedNativeDependencySpecifierByName,
|
|
314
|
+
...managedNativeDependencySpecifierByName,
|
|
315
|
+
}
|
|
316
|
+
),
|
|
312
317
|
],
|
|
313
318
|
};
|
|
314
319
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Huawei Technologies Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import JSON5 from 'json5';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A utility class for modifying JSON5 content while preserving comments and formatting.
|
|
12
|
+
* Uses json5-writer's AST-based transformation to maintain the original structure.
|
|
13
|
+
*/
|
|
14
|
+
export class JSON5Writer {
|
|
15
|
+
/**
|
|
16
|
+
* Updates the dependencies in a JSON5 string while preserving comments and formatting.
|
|
17
|
+
*
|
|
18
|
+
* @param content - The original JSON5 content
|
|
19
|
+
* @param newDependencies - The new dependencies object to set
|
|
20
|
+
* @returns The modified JSON5 content with preserved comments
|
|
21
|
+
*/
|
|
22
|
+
static updateDependencies(content: string, newDependencies: Record<string, string>): string {
|
|
23
|
+
const json5Writer = require('json5-writer');
|
|
24
|
+
|
|
25
|
+
// Parse the original content to get all fields
|
|
26
|
+
const parsed = JSON5.parse(content);
|
|
27
|
+
|
|
28
|
+
// Create the new object with updated dependencies
|
|
29
|
+
const newObject = {
|
|
30
|
+
...parsed,
|
|
31
|
+
dependencies: newDependencies,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Load the original content into json5-writer to preserve comments
|
|
35
|
+
const writer = json5Writer.load(content);
|
|
36
|
+
|
|
37
|
+
// Write the new object, which will preserve comments
|
|
38
|
+
writer.write(newObject);
|
|
39
|
+
|
|
40
|
+
// Return the modified source with JSON5-style formatting
|
|
41
|
+
// Use double quotes for both keys and values, and trailing commas
|
|
42
|
+
// quoteKeys: true ensures keys with special characters (like @, /, -) are properly quoted
|
|
43
|
+
return writer.toSource({ quote: 'double', quoteKeys: true, trailingComma: true }) + '\n';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Updates dependencies with fallback to standard JSON5 stringify if preservation fails.
|
|
48
|
+
* This ensures backward compatibility.
|
|
49
|
+
*
|
|
50
|
+
* @param content - The original JSON5 content
|
|
51
|
+
* @param newDependencies - The new dependencies object to set
|
|
52
|
+
* @returns The modified JSON5 content
|
|
53
|
+
*/
|
|
54
|
+
static updateDependenciesWithFallback(
|
|
55
|
+
content: string,
|
|
56
|
+
newDependencies: Record<string, string>
|
|
57
|
+
): string {
|
|
58
|
+
try {
|
|
59
|
+
return this.updateDependencies(content, newDependencies);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
// Fallback to JSON5 stringify if AST transformation fails
|
|
62
|
+
const parsed = JSON5.parse(content);
|
|
63
|
+
const result = {
|
|
64
|
+
...parsed,
|
|
65
|
+
dependencies: newDependencies,
|
|
66
|
+
};
|
|
67
|
+
return JSON5.stringify(result, { space: 2, quote: '"' }) + '\n';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
package/src/autolinking/index.ts
CHANGED
|
@@ -12,6 +12,15 @@ import { randomUUID } from 'node:crypto';
|
|
|
12
12
|
|
|
13
13
|
type MetroConfig = Awaited<ReturnType<typeof loadConfig>>;
|
|
14
14
|
|
|
15
|
+
const ENABLE_DEBUG_LOG = process.env.RNOH_BUNDLE_DEBUG === 'true';
|
|
16
|
+
|
|
17
|
+
function debugLog(message: string) {
|
|
18
|
+
if (ENABLE_DEBUG_LOG) {
|
|
19
|
+
const timestamp = new Date().toISOString().replace('T', ' ').substring(0, 23);
|
|
20
|
+
console.log(`[${timestamp}] ${message}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
15
24
|
const HERMESC_BIN_PATH = {
|
|
16
25
|
darwin: pathUtils.normalize('osx-bin/hermesc'),
|
|
17
26
|
linux: pathUtils.normalize('linux64-bin/hermesc'),
|
|
@@ -150,6 +159,7 @@ export const commandBundleHarmony: Command = {
|
|
|
150
159
|
const {assets, ...bundle}= await createBundle(metroConfig, buildOptions);
|
|
151
160
|
|
|
152
161
|
if (shouldGenerateHbcBundle) {
|
|
162
|
+
debugLog('Starting Hermes bytecode compilation...');
|
|
153
163
|
await saveHbcBundle(
|
|
154
164
|
logger,
|
|
155
165
|
bundle.code,
|
|
@@ -157,13 +167,16 @@ export const commandBundleHarmony: Command = {
|
|
|
157
167
|
args.hermescDir,
|
|
158
168
|
args.hermescOptions
|
|
159
169
|
);
|
|
170
|
+
debugLog('Hermes bytecode compilation finished');
|
|
160
171
|
} else {
|
|
161
172
|
await saveJSBundle(logger, bundle, bundleOutput);
|
|
162
173
|
}
|
|
163
174
|
maybeSaveSourceMap(logger, bundle, args.sourcemapOutput);
|
|
164
175
|
if(assets){
|
|
165
176
|
await copyAssets(logger, assets, assetsDest);
|
|
177
|
+
debugLog('Assets copy completed, cleaning up...');
|
|
166
178
|
}
|
|
179
|
+
debugLog('Bundle process finished, exiting');
|
|
167
180
|
} catch (err) {
|
|
168
181
|
if (err instanceof DescriptiveError) {
|
|
169
182
|
logger.descriptiveError(err);
|
|
@@ -224,19 +237,23 @@ async function saveHbcBundle(
|
|
|
224
237
|
}
|
|
225
238
|
|
|
226
239
|
const tmpBundlePath = `${os.tmpdir()}${pathUtils.sep}b-${randomUUID()}.harmony.js`;
|
|
240
|
+
debugLog('Writing temporary JS bundle...');
|
|
227
241
|
await fse.writeFile(tmpBundlePath, bundleCode);
|
|
228
242
|
const hbcFilePath = bundleOutput.endsWith('.hbc')
|
|
229
243
|
? bundleOutput
|
|
230
244
|
: pathUtils.join(pathUtils.dirname(bundleOutput), 'hermes_bundle.hbc');
|
|
231
245
|
const hermescOptionsString =
|
|
232
246
|
hermescOptions?.map((e) => `-${e}`).join(' ') || '';
|
|
247
|
+
debugLog(`Executing hermesc compiler: ${resolvedHermescPath}`);
|
|
233
248
|
execSync(
|
|
234
249
|
`${resolvedHermescPath} ${hermescOptionsString} --emit-binary -out ${hbcFilePath} ${tmpBundlePath}`,
|
|
235
250
|
{
|
|
236
251
|
stdio: 'inherit',
|
|
237
252
|
}
|
|
238
253
|
);
|
|
254
|
+
debugLog('Hermesc execution completed, cleaning up temp file...');
|
|
239
255
|
fs.unlinkSync(tmpBundlePath);
|
|
256
|
+
debugLog('Temp file deleted');
|
|
240
257
|
logger.info((s) => `Created ${hbcFilePath}`);
|
|
241
258
|
}
|
|
242
259
|
|