react-native-update-cli 2.28.3 → 2.29.1
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/lib/api.js +9 -29
- package/lib/bundle-pack.js +6 -38
- package/lib/bundle-runner.js +36 -67
- package/lib/diff.js +18 -49
- package/lib/native-package.js +10 -42
- package/lib/package.js +6 -38
- package/lib/utils/app-info-parser/aab.js +6 -38
- package/lib/utils/app-info-parser/resource-finder.d.ts +5 -13
- package/lib/utils/app-info-parser/resource-finder.js +63 -60
- package/lib/utils/fs-helpers.d.ts +13 -0
- package/lib/utils/fs-helpers.js +65 -0
- package/lib/utils/hbcTransform.js +34 -23
- package/lib/utils/hermes-base.js +50 -47
- package/lib/utils/hermes-raw.js +21 -8
- package/lib/utils/plugin-config.js +6 -36
- package/lib/utils/runtime.d.ts +1 -1
- package/lib/utils/runtime.js +2 -10
- package/lib/utils/upload-request.d.ts +33 -0
- package/lib/utils/upload-request.js +120 -0
- package/lib/utils/zip-entries.js +7 -39
- package/lib/utils/zip-range.js +4 -4
- package/lib/utils/zip-raw-writer.js +6 -5
- package/package.json +1 -7
|
@@ -35,7 +35,30 @@ const HBC_HEADER_SIZE = 128;
|
|
|
35
35
|
const FUNC_OFFSET_25 = { byte: 0, bit: 0, bits: 25 };
|
|
36
36
|
const STRING_OFFSET_23 = { byte: 0, bit: 1, bits: 23 };
|
|
37
37
|
const PAIR_OFFSET_32 = { byte: 0, bit: 0, bits: 32 };
|
|
38
|
-
// v98
|
|
38
|
+
// 晚期 v98 与 v99 共用的头部计数字段
|
|
39
|
+
const V98_LATE_HEADER_FIELDS = [
|
|
40
|
+
'fileLength',
|
|
41
|
+
'globalCodeIndex',
|
|
42
|
+
'functionCount',
|
|
43
|
+
'stringKindCount',
|
|
44
|
+
'identifierCount',
|
|
45
|
+
'stringCount',
|
|
46
|
+
'overflowStringCount',
|
|
47
|
+
'stringStorageSize',
|
|
48
|
+
'bigIntCount',
|
|
49
|
+
'bigIntStorageSize',
|
|
50
|
+
'regExpCount',
|
|
51
|
+
'regExpStorageSize',
|
|
52
|
+
'literalValueBufferSize',
|
|
53
|
+
'objKeyBufferSize',
|
|
54
|
+
'objShapeTableCount',
|
|
55
|
+
'numStringSwitchImms',
|
|
56
|
+
'segmentID',
|
|
57
|
+
'cjsModuleCount',
|
|
58
|
+
'functionSourceCount',
|
|
59
|
+
'debugInfoOffset',
|
|
60
|
+
];
|
|
61
|
+
// v98 两种头部变体(及 v99)共享的段布局
|
|
39
62
|
const V98_SECTIONS = [
|
|
40
63
|
{
|
|
41
64
|
name: 'functionHeaders',
|
|
@@ -184,28 +207,16 @@ exports.HBC_LAYOUTS = [
|
|
|
184
207
|
// 段布局与早期 v98 相同。
|
|
185
208
|
minVersion: 98,
|
|
186
209
|
maxVersion: 98,
|
|
187
|
-
headerFields:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
'bigIntStorageSize',
|
|
198
|
-
'regExpCount',
|
|
199
|
-
'regExpStorageSize',
|
|
200
|
-
'literalValueBufferSize',
|
|
201
|
-
'objKeyBufferSize',
|
|
202
|
-
'objShapeTableCount',
|
|
203
|
-
'numStringSwitchImms',
|
|
204
|
-
'segmentID',
|
|
205
|
-
'cjsModuleCount',
|
|
206
|
-
'functionSourceCount',
|
|
207
|
-
'debugInfoOffset',
|
|
208
|
-
],
|
|
210
|
+
headerFields: V98_LATE_HEADER_FIELDS,
|
|
211
|
+
sections: V98_SECTIONS,
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
// Hermes V1 v99(hermes-compiler 260318099,RN 0.88+):文件头与段布局
|
|
215
|
+
// 同晚期 v98,只改了函数头内部位域(去 NumCacheNewObject)与操作码表,
|
|
216
|
+
// 二者都不在本变换触及的范围内。
|
|
217
|
+
minVersion: 99,
|
|
218
|
+
maxVersion: 99,
|
|
219
|
+
headerFields: V98_LATE_HEADER_FIELDS,
|
|
209
220
|
sections: V98_SECTIONS,
|
|
210
221
|
},
|
|
211
222
|
{
|
package/lib/utils/hermes-base.js
CHANGED
|
@@ -76,13 +76,14 @@ exports.verifyHermesBaseEquivalence = verifyHermesBaseEquivalence;
|
|
|
76
76
|
const node_string_decoder_1 = require("node:string_decoder");
|
|
77
77
|
const child_process_1 = require("child_process");
|
|
78
78
|
const crypto_1 = require("crypto");
|
|
79
|
-
const
|
|
79
|
+
const fs_1 = __importDefault(require("fs"));
|
|
80
80
|
const os_1 = __importDefault(require("os"));
|
|
81
81
|
const path_1 = __importDefault(require("path"));
|
|
82
82
|
const stream_1 = require("stream");
|
|
83
83
|
const promises_1 = require("stream/promises");
|
|
84
84
|
const constants_1 = require("./constants");
|
|
85
85
|
const failure_fingerprint_1 = require("./failure-fingerprint");
|
|
86
|
+
const fs_helpers_1 = require("./fs-helpers");
|
|
86
87
|
const hbcTransform_1 = require("./hbcTransform");
|
|
87
88
|
const hermes_cached_object_1 = require("./hermes-cached-object");
|
|
88
89
|
const hermes_literals_1 = require("./hermes-literals");
|
|
@@ -162,7 +163,7 @@ function classifyHermesCommand(hermesCommand) {
|
|
|
162
163
|
const packageRoot = normalized.slice(0, match.index + match[0].length);
|
|
163
164
|
let version = '';
|
|
164
165
|
try {
|
|
165
|
-
version = String(JSON.parse(
|
|
166
|
+
version = String(JSON.parse(fs_1.default.readFileSync(path_1.default.join(packageRoot, 'package.json'), 'utf8')).version ?? '');
|
|
166
167
|
}
|
|
167
168
|
catch {
|
|
168
169
|
return {
|
|
@@ -230,23 +231,23 @@ function sha256Hex(data) {
|
|
|
230
231
|
/** sha256 of a file, streamed (a cached base can be tens of MB) */
|
|
231
232
|
async function sha256File(file) {
|
|
232
233
|
const hash = (0, crypto_1.createHash)('sha256');
|
|
233
|
-
for await (const chunk of
|
|
234
|
+
for await (const chunk of fs_1.default.createReadStream(file))
|
|
234
235
|
hash.update(chunk);
|
|
235
236
|
return hash.digest('hex');
|
|
236
237
|
}
|
|
237
238
|
/** HBC version from the first bytes of a file, without reading the rest */
|
|
238
239
|
async function readFileHbcVersion(file) {
|
|
239
240
|
const header = Buffer.alloc(128);
|
|
240
|
-
const
|
|
241
|
+
const handle = await fs_1.default.promises.open(file, 'r');
|
|
241
242
|
try {
|
|
242
|
-
const { bytesRead } = await
|
|
243
|
+
const { bytesRead } = await handle.read(header, 0, 128, 0);
|
|
243
244
|
return (0, hbcTransform_1.getHbcVersion)(header.subarray(0, bytesRead));
|
|
244
245
|
}
|
|
245
246
|
catch {
|
|
246
247
|
return null;
|
|
247
248
|
}
|
|
248
249
|
finally {
|
|
249
|
-
await
|
|
250
|
+
await handle.close();
|
|
250
251
|
}
|
|
251
252
|
}
|
|
252
253
|
const PROBE_CACHE_FILE = 'hbc-versions.json';
|
|
@@ -254,7 +255,7 @@ const PROBE_CACHE_ENTRIES = 16;
|
|
|
254
255
|
/** identity of a hermesc binary for the probe cache: path + size + mtime */
|
|
255
256
|
function probeCacheKey(hermesCommand) {
|
|
256
257
|
try {
|
|
257
|
-
const stat =
|
|
258
|
+
const stat = fs_1.default.statSync(hermesCommand);
|
|
258
259
|
return `${path_1.default.resolve(hermesCommand)}|${stat.size}|${Math.floor(stat.mtimeMs)}`;
|
|
259
260
|
}
|
|
260
261
|
catch {
|
|
@@ -263,7 +264,7 @@ function probeCacheKey(hermesCommand) {
|
|
|
263
264
|
}
|
|
264
265
|
function readProbeCache() {
|
|
265
266
|
try {
|
|
266
|
-
const parsed = JSON.parse(
|
|
267
|
+
const parsed = JSON.parse(fs_1.default.readFileSync(path_1.default.join(cacheDir(), PROBE_CACHE_FILE), 'utf8'));
|
|
267
268
|
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
268
269
|
}
|
|
269
270
|
catch {
|
|
@@ -275,8 +276,8 @@ function writeProbeCache(entries) {
|
|
|
275
276
|
const keys = Object.keys(entries);
|
|
276
277
|
// keep the most recently inserted entries only
|
|
277
278
|
const trimmed = Object.fromEntries(keys.slice(-PROBE_CACHE_ENTRIES).map((key) => [key, entries[key]]));
|
|
278
|
-
|
|
279
|
-
|
|
279
|
+
(0, fs_helpers_1.ensureDirSync)(cacheDir());
|
|
280
|
+
fs_1.default.writeFileSync(path_1.default.join(cacheDir(), PROBE_CACHE_FILE), JSON.stringify(trimmed));
|
|
280
281
|
}
|
|
281
282
|
catch {
|
|
282
283
|
// the cache is a convenience; probing again next time is fine
|
|
@@ -303,26 +304,26 @@ function probeHbcVersion(hermesCommand) {
|
|
|
303
304
|
}
|
|
304
305
|
/** Compile an empty file to learn which HBC version this hermesc emits. */
|
|
305
306
|
function compileProbe(hermesCommand) {
|
|
306
|
-
const dir =
|
|
307
|
+
const dir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'rnu-hermes-probe-'));
|
|
307
308
|
try {
|
|
308
309
|
const input = path_1.default.join(dir, 'probe.js');
|
|
309
310
|
const output = path_1.default.join(dir, 'probe.hbc');
|
|
310
|
-
|
|
311
|
+
fs_1.default.writeFileSync(input, '');
|
|
311
312
|
const result = (0, child_process_1.spawnSync)(hermesCommand, ['-emit-binary', '-out', output, input, '-O', '-w'], {
|
|
312
313
|
stdio: 'ignore',
|
|
313
314
|
timeout: (0, hermes_timeout_1.hermesTimeout)(process.env.PUSHY_HERMES_PROBE_TIMEOUT_MS, 30_000),
|
|
314
315
|
killSignal: 'SIGKILL',
|
|
315
316
|
});
|
|
316
|
-
if (result.status !== 0 || !
|
|
317
|
+
if (result.status !== 0 || !fs_1.default.existsSync(output)) {
|
|
317
318
|
return null;
|
|
318
319
|
}
|
|
319
320
|
const header = Buffer.alloc(128);
|
|
320
|
-
const fd =
|
|
321
|
+
const fd = fs_1.default.openSync(output, 'r');
|
|
321
322
|
try {
|
|
322
|
-
|
|
323
|
+
fs_1.default.readSync(fd, header, 0, 128, 0);
|
|
323
324
|
}
|
|
324
325
|
finally {
|
|
325
|
-
|
|
326
|
+
fs_1.default.closeSync(fd);
|
|
326
327
|
}
|
|
327
328
|
return (0, hbcTransform_1.getHbcVersion)(header);
|
|
328
329
|
}
|
|
@@ -330,7 +331,7 @@ function compileProbe(hermesCommand) {
|
|
|
330
331
|
return null;
|
|
331
332
|
}
|
|
332
333
|
finally {
|
|
333
|
-
|
|
334
|
+
(0, fs_helpers_1.removeSync)(dir);
|
|
334
335
|
}
|
|
335
336
|
}
|
|
336
337
|
exports.BUNDLE_ENTRY_NAMES = [
|
|
@@ -362,7 +363,7 @@ async function extractBundleFromArchive(filePath) {
|
|
|
362
363
|
ext === '.jsbundle' ||
|
|
363
364
|
ext === '.bundlejs' ||
|
|
364
365
|
ext === '.js') {
|
|
365
|
-
return
|
|
366
|
+
return fs_1.default.promises.readFile(filePath);
|
|
366
367
|
}
|
|
367
368
|
if (ext === '.ppk' || ext === '.apk' || ext === '.ipa') {
|
|
368
369
|
return readFirstZipEntry(filePath, bundleEntryMatcher(ext.slice(1)));
|
|
@@ -378,7 +379,7 @@ async function extractBundleFromArchive(filePath) {
|
|
|
378
379
|
}
|
|
379
380
|
// unknown extension: try as zip, then as raw file
|
|
380
381
|
const fromZip = await readFirstZipEntry(filePath, (name) => exports.BUNDLE_ENTRY_NAMES.includes(name)).catch(() => null);
|
|
381
|
-
return fromZip ??
|
|
382
|
+
return fromZip ?? fs_1.default.promises.readFile(filePath);
|
|
382
383
|
}
|
|
383
384
|
async function readFirstZipEntry(zipPath, matches) {
|
|
384
385
|
let found = null;
|
|
@@ -414,53 +415,53 @@ async function cacheLookup(bundleHash) {
|
|
|
414
415
|
if (!/^[0-9a-f]{64}$/.test(bundleHash))
|
|
415
416
|
return null;
|
|
416
417
|
const file = path_1.default.join(cacheDir(), bundleHash);
|
|
417
|
-
if (!(await
|
|
418
|
+
if (!(await (0, fs_helpers_1.pathExists)(file)))
|
|
418
419
|
return null;
|
|
419
420
|
if ((await sha256File(file).catch(() => '')) !== bundleHash) {
|
|
420
421
|
// corrupt entry: never trust cache content
|
|
421
|
-
await
|
|
422
|
+
await (0, fs_helpers_1.remove)(file).catch(() => { });
|
|
422
423
|
return null;
|
|
423
424
|
}
|
|
424
425
|
const now = new Date();
|
|
425
|
-
await
|
|
426
|
+
await fs_1.default.promises.utimes(file, now, now).catch(() => { });
|
|
426
427
|
return file;
|
|
427
428
|
}
|
|
428
429
|
/** Store a bundle under its sha256 (LRU-evicting to the configured limits). */
|
|
429
430
|
async function cachePut(bundle, maxMb, knownHash) {
|
|
430
431
|
const bundleHash = knownHash ?? sha256Hex(bundle);
|
|
431
432
|
const dir = cacheDir();
|
|
432
|
-
await
|
|
433
|
+
await (0, fs_helpers_1.ensureDir)(dir);
|
|
433
434
|
const file = path_1.default.join(dir, bundleHash);
|
|
434
|
-
if (!(await
|
|
435
|
+
if (!(await (0, fs_helpers_1.pathExists)(file))) {
|
|
435
436
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
436
|
-
await
|
|
437
|
-
await
|
|
437
|
+
await fs_1.default.promises.writeFile(tmp, bundle);
|
|
438
|
+
await fs_1.default.promises.rename(tmp, file);
|
|
438
439
|
}
|
|
439
440
|
else {
|
|
440
441
|
const now = new Date();
|
|
441
|
-
await
|
|
442
|
+
await fs_1.default.promises.utimes(file, now, now).catch(() => { });
|
|
442
443
|
}
|
|
443
444
|
await enforceCacheLimits(maxMb, bundleHash);
|
|
444
445
|
return { path: file, bundleHash };
|
|
445
446
|
}
|
|
446
447
|
async function enforceCacheLimits(maxMb, keep) {
|
|
447
448
|
const dir = cacheDir();
|
|
448
|
-
if (!(await
|
|
449
|
+
if (!(await (0, fs_helpers_1.pathExists)(dir)))
|
|
449
450
|
return;
|
|
450
451
|
const { maxBytes, maxFiles } = cacheLimits(maxMb);
|
|
451
452
|
const entries = [];
|
|
452
453
|
const staleTmpCutoff = Date.now() - STALE_CACHE_TMP_MS;
|
|
453
|
-
for (const name of await
|
|
454
|
+
for (const name of await fs_1.default.promises.readdir(dir)) {
|
|
454
455
|
const isTmp = isCacheTmpName(name);
|
|
455
456
|
if (!isTmp && !/^[0-9a-f]{64}$/.test(name))
|
|
456
457
|
continue;
|
|
457
|
-
const stat = await
|
|
458
|
+
const stat = await fs_1.default.promises.stat(path_1.default.join(dir, name)).catch(() => null);
|
|
458
459
|
if (!stat?.isFile())
|
|
459
460
|
continue;
|
|
460
461
|
if (isTmp) {
|
|
461
462
|
// an interrupted cachePut; nothing will ever rename it into place
|
|
462
463
|
if (stat.mtimeMs < staleTmpCutoff)
|
|
463
|
-
await
|
|
464
|
+
await (0, fs_helpers_1.remove)(path_1.default.join(dir, name)).catch(() => { });
|
|
464
465
|
continue;
|
|
465
466
|
}
|
|
466
467
|
entries.push({ name, size: stat.size, mtime: stat.mtimeMs });
|
|
@@ -472,7 +473,7 @@ async function enforceCacheLimits(maxMb, keep) {
|
|
|
472
473
|
total += entry.size;
|
|
473
474
|
count += 1;
|
|
474
475
|
if (entry.name !== keep && (total > maxBytes || count > maxFiles)) {
|
|
475
|
-
await
|
|
476
|
+
await (0, fs_helpers_1.remove)(path_1.default.join(dir, entry.name)).catch(() => { });
|
|
476
477
|
}
|
|
477
478
|
}
|
|
478
479
|
}
|
|
@@ -483,14 +484,14 @@ function isCacheTmpName(name) {
|
|
|
483
484
|
/** Remove every cached bundle (and staging leftovers); returns the bundle count. */
|
|
484
485
|
async function cleanCache() {
|
|
485
486
|
const dir = cacheDir();
|
|
486
|
-
if (!(await
|
|
487
|
+
if (!(await (0, fs_helpers_1.pathExists)(dir)))
|
|
487
488
|
return 0;
|
|
488
489
|
let bundles = 0;
|
|
489
|
-
for (const name of await
|
|
490
|
+
for (const name of await fs_1.default.promises.readdir(dir)) {
|
|
490
491
|
const isBundle = /^[0-9a-f]{64}$/.test(name);
|
|
491
492
|
if (!isBundle && !isCacheTmpName(name))
|
|
492
493
|
continue;
|
|
493
|
-
await
|
|
494
|
+
await (0, fs_helpers_1.remove)(path_1.default.join(dir, name));
|
|
494
495
|
if (isBundle)
|
|
495
496
|
bundles += 1;
|
|
496
497
|
}
|
|
@@ -500,11 +501,13 @@ async function cacheStats() {
|
|
|
500
501
|
const dir = cacheDir();
|
|
501
502
|
let files = 0;
|
|
502
503
|
let bytes = 0;
|
|
503
|
-
if (await
|
|
504
|
-
for (const name of await
|
|
504
|
+
if (await (0, fs_helpers_1.pathExists)(dir)) {
|
|
505
|
+
for (const name of await fs_1.default.promises.readdir(dir)) {
|
|
505
506
|
if (!/^[0-9a-f]{64}$/.test(name))
|
|
506
507
|
continue;
|
|
507
|
-
const stat = await
|
|
508
|
+
const stat = await fs_1.default.promises
|
|
509
|
+
.stat(path_1.default.join(dir, name))
|
|
510
|
+
.catch(() => null);
|
|
508
511
|
if (stat?.isFile()) {
|
|
509
512
|
files += 1;
|
|
510
513
|
bytes += stat.size;
|
|
@@ -516,14 +519,14 @@ async function cacheStats() {
|
|
|
516
519
|
/** Remove leftovers of interrupted runs (older than 24h) from the tmp dir. */
|
|
517
520
|
async function cleanStaleTmp(maxAgeMs = 24 * 60 * 60 * 1000) {
|
|
518
521
|
const dir = tmpDir();
|
|
519
|
-
if (!(await
|
|
522
|
+
if (!(await (0, fs_helpers_1.pathExists)(dir)))
|
|
520
523
|
return;
|
|
521
524
|
const cutoff = Date.now() - maxAgeMs;
|
|
522
|
-
for (const name of await
|
|
525
|
+
for (const name of await fs_1.default.promises.readdir(dir)) {
|
|
523
526
|
const file = path_1.default.join(dir, name);
|
|
524
|
-
const stat = await
|
|
527
|
+
const stat = await fs_1.default.promises.stat(file).catch(() => null);
|
|
525
528
|
if (stat && stat.mtimeMs < cutoff)
|
|
526
|
-
await
|
|
529
|
+
await (0, fs_helpers_1.remove)(file).catch(() => { });
|
|
527
530
|
}
|
|
528
531
|
}
|
|
529
532
|
// ---------------------------------------------------------------------------
|
|
@@ -562,7 +565,7 @@ function hasBundleLocation(record) {
|
|
|
562
565
|
async function saveResponse(response, destination, controller = new AbortController()) {
|
|
563
566
|
if (!response.body)
|
|
564
567
|
throw new Error('empty response body');
|
|
565
|
-
await
|
|
568
|
+
await (0, fs_helpers_1.ensureDir)(path_1.default.dirname(destination));
|
|
566
569
|
const abort = () => controller.abort(new Error(`download stalled for ${STREAM_IDLE_TIMEOUT_MS / 1000}s`));
|
|
567
570
|
let idle = setTimeout(abort, STREAM_IDLE_TIMEOUT_MS);
|
|
568
571
|
const watchdog = new stream_1.PassThrough({
|
|
@@ -573,7 +576,7 @@ async function saveResponse(response, destination, controller = new AbortControl
|
|
|
573
576
|
},
|
|
574
577
|
});
|
|
575
578
|
try {
|
|
576
|
-
await (0, promises_1.pipeline)(stream_1.Readable.fromWeb(response.body), watchdog,
|
|
579
|
+
await (0, promises_1.pipeline)(stream_1.Readable.fromWeb(response.body), watchdog, fs_1.default.createWriteStream(destination), { signal: controller.signal });
|
|
577
580
|
}
|
|
578
581
|
finally {
|
|
579
582
|
clearTimeout(idle);
|
|
@@ -794,7 +797,7 @@ async function resolveHermesBase(params) {
|
|
|
794
797
|
// 2. download, extract, verify, cache — transport errors get a second try
|
|
795
798
|
for (let attempt = 1; attempt <= 2; attempt++) {
|
|
796
799
|
const dir = tmpDir();
|
|
797
|
-
await
|
|
800
|
+
await (0, fs_helpers_1.ensureDir)(dir);
|
|
798
801
|
const artifactType = [
|
|
799
802
|
'ppk',
|
|
800
803
|
'apk',
|
|
@@ -849,7 +852,7 @@ async function resolveHermesBase(params) {
|
|
|
849
852
|
}
|
|
850
853
|
}
|
|
851
854
|
finally {
|
|
852
|
-
await
|
|
855
|
+
await (0, fs_helpers_1.remove)(archive).catch(() => { });
|
|
853
856
|
}
|
|
854
857
|
}
|
|
855
858
|
return null;
|
|
@@ -1169,7 +1172,7 @@ class DumpReader {
|
|
|
1169
1172
|
const pass = (this.pass = new stream_1.PassThrough());
|
|
1170
1173
|
proc.stdout.pipe(pass);
|
|
1171
1174
|
if (dumpTo) {
|
|
1172
|
-
const output = (this.debugOutput =
|
|
1175
|
+
const output = (this.debugOutput = fs_1.default.createWriteStream(dumpTo));
|
|
1173
1176
|
this.debugFinished = new Promise((resolve) => {
|
|
1174
1177
|
output.once('finish', resolve);
|
|
1175
1178
|
output.once('error', (error) => {
|
package/lib/utils/hermes-raw.js
CHANGED
|
@@ -46,7 +46,8 @@ async function readHermesSemanticData(file) {
|
|
|
46
46
|
// A newly added diff-transform layout must not silently opt into semantic
|
|
47
47
|
// parsing: function header and operand schemas need an independent review.
|
|
48
48
|
if (!((resolved.version >= 87 && resolved.version <= 96) ||
|
|
49
|
-
resolved.version === 98
|
|
49
|
+
resolved.version === 98 ||
|
|
50
|
+
resolved.version === 99)) {
|
|
50
51
|
throw new UnverifiableHermesBytecode('unsupported semantic HBC version');
|
|
51
52
|
}
|
|
52
53
|
const layout = requireValue((0, hbcTransform_1.pickLayout)(bytes), 'unknown HBC layout');
|
|
@@ -80,7 +81,11 @@ async function readHermesSemanticData(file) {
|
|
|
80
81
|
// hbcTransform's file-header variants do not distinguish that function
|
|
81
82
|
// schema change. A compiler upgrade needs independent large/small fixtures;
|
|
82
83
|
// do not infer either schema from numStringSwitchImms or HBC version alone.
|
|
83
|
-
|
|
84
|
+
// Audited v99 function schema: hermes-compiler 260318099.0.4 (RN 0.88), the
|
|
85
|
+
// first HBC bump after that removal, so it always has the 36-byte form.
|
|
86
|
+
const shaped = resolved.version >= 98;
|
|
87
|
+
const noCacheNewObject = resolved.version === 99;
|
|
88
|
+
const largeSize = noCacheNewObject ? 36 : 37;
|
|
84
89
|
const entrySize = shaped ? 12 : 16;
|
|
85
90
|
const headers = section('functionHeaders');
|
|
86
91
|
const functions = [];
|
|
@@ -97,15 +102,15 @@ async function readHermesSemanticData(file) {
|
|
|
97
102
|
const largeOffset = shaped
|
|
98
103
|
? ((word1 >>> 14) & 0xff) * 0x1000000 + offset
|
|
99
104
|
: (headers.readUInt32LE(at + 8) & 0x1ffffff) * 0x10000 + offset;
|
|
100
|
-
const large = checkedSlice(bytes, largeOffset, shaped ?
|
|
105
|
+
const large = checkedSlice(bytes, largeOffset, shaped ? largeSize : 31);
|
|
101
106
|
offset = large.readUInt32LE(0);
|
|
102
107
|
size = large.readUInt32LE(shaped ? 12 : 8);
|
|
103
108
|
name = large.readUInt32LE(shaped ? 16 : 12);
|
|
104
|
-
flags = large[shaped ?
|
|
109
|
+
flags = large[shaped ? largeSize - 1 : 30];
|
|
105
110
|
fields = shaped
|
|
106
111
|
? [4, 8, 20, 24, 28].map((p) => large.readUInt32LE(p))
|
|
107
112
|
: [4, 20, 24].map((p) => large.readUInt32LE(p));
|
|
108
|
-
fields.push(...large.subarray(shaped ? 32 : 28, shaped ?
|
|
113
|
+
fields.push(...large.subarray(shaped ? 32 : 28, shaped ? largeSize - 1 : 30));
|
|
109
114
|
}
|
|
110
115
|
else if (shaped) {
|
|
111
116
|
size = word1 & 0x3fff;
|
|
@@ -117,9 +122,13 @@ async function readHermesSemanticData(file) {
|
|
|
117
122
|
word1 >>> 27,
|
|
118
123
|
headers[at + 8],
|
|
119
124
|
headers[at + 9],
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
125
|
+
...(noCacheNewObject
|
|
126
|
+
? [headers[at + 10] & 127, headers[at + 10] >>> 7]
|
|
127
|
+
: [
|
|
128
|
+
headers[at + 10] & 63,
|
|
129
|
+
(headers[at + 10] >>> 6) & 1,
|
|
130
|
+
headers[at + 10] >>> 7,
|
|
131
|
+
]),
|
|
123
132
|
];
|
|
124
133
|
}
|
|
125
134
|
else {
|
|
@@ -344,6 +353,10 @@ function normalizeRawHermesFunction(lines, data, functionIndex, buffers) {
|
|
|
344
353
|
operands[shapeAt + 1] = requireValue(literal.objectValues(values[shapeAt + 1], shape.count), 'undecodable shape values');
|
|
345
354
|
}
|
|
346
355
|
}
|
|
356
|
+
else if (op === 'NewTypedObjectWithBuffer') {
|
|
357
|
+
// HBC v99 typed-mode buffer user; its literal operands are not decoded.
|
|
358
|
+
throw new UnverifiableHermesBytecode('typed object literal buffer');
|
|
359
|
+
}
|
|
347
360
|
else if (op === 'CacheNewObject') {
|
|
348
361
|
if (buffers.layout !== 'shaped' || values.length !== 4) {
|
|
349
362
|
throw new UnverifiableHermesBytecode('unknown cached object operands');
|
|
@@ -1,40 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
35
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
6
|
exports.plugins = void 0;
|
|
37
|
-
const
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
38
8
|
exports.plugins = [
|
|
39
9
|
{
|
|
40
10
|
name: 'sentry',
|
|
@@ -44,12 +14,12 @@ exports.plugins = [
|
|
|
44
14
|
},
|
|
45
15
|
detect: async () => {
|
|
46
16
|
try {
|
|
47
|
-
await
|
|
17
|
+
await fs_1.default.promises.access('ios/sentry.properties');
|
|
48
18
|
return true;
|
|
49
19
|
}
|
|
50
20
|
catch {
|
|
51
21
|
try {
|
|
52
|
-
await
|
|
22
|
+
await fs_1.default.promises.access('android/sentry.properties');
|
|
53
23
|
return true;
|
|
54
24
|
}
|
|
55
25
|
catch {
|
package/lib/utils/runtime.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare function resolveProxy(targetUrl: string, env?: NodeJS.ProcessEnv)
|
|
|
29
29
|
export declare function webFetch(url: string, init?: RequestInit): Promise<Response>;
|
|
30
30
|
/**
|
|
31
31
|
* An http.Agent routing `targetUrl` through its proxy, for the core
|
|
32
|
-
* http/https APIs
|
|
32
|
+
* http/https APIs (including the streaming uploads); undefined when the
|
|
33
33
|
* connection is direct. Always a CONNECT tunnel (also for http targets, like
|
|
34
34
|
* undici's ProxyAgent above): the absolute-form alternative rewrites the
|
|
35
35
|
* request head after it was buffered, which garbles a streaming body.
|
package/lib/utils/runtime.js
CHANGED
|
@@ -127,20 +127,12 @@ function webFetch(url, init = {}) {
|
|
|
127
127
|
dispatcher,
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
-
|
|
131
|
-
return globalThis.fetch(url, init);
|
|
132
|
-
}
|
|
133
|
-
// Node < 18 only. Loaded on demand so the built-in fetch path never pays
|
|
134
|
-
// for node-fetch (nor for the punycode deprecation warning it triggers on
|
|
135
|
-
// Node ≥ 21).
|
|
136
|
-
const mod = require('node-fetch');
|
|
137
|
-
const nodeFetch = (mod.default ?? mod);
|
|
138
|
-
return nodeFetch(url, init);
|
|
130
|
+
return globalThis.fetch(url, init);
|
|
139
131
|
}
|
|
140
132
|
const proxyAgents = new Map();
|
|
141
133
|
/**
|
|
142
134
|
* An http.Agent routing `targetUrl` through its proxy, for the core
|
|
143
|
-
* http/https APIs
|
|
135
|
+
* http/https APIs (including the streaming uploads); undefined when the
|
|
144
136
|
* connection is direct. Always a CONNECT tunnel (also for http targets, like
|
|
145
137
|
* undici's ProxyAgent above): the absolute-form alternative rewrites the
|
|
146
138
|
* request head after it was buffered, which garbles a streaming body.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Agent as HttpAgent } from 'http';
|
|
2
|
+
import { Readable } from 'stream';
|
|
3
|
+
export interface UploadRequest {
|
|
4
|
+
method: string;
|
|
5
|
+
headers: Record<string, string>;
|
|
6
|
+
body: Readable;
|
|
7
|
+
}
|
|
8
|
+
export interface UploadResponse {
|
|
9
|
+
status: number;
|
|
10
|
+
statusText: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function fileContentType(fileName: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* multipart/form-data with `fields` first and the file last. The file's size
|
|
15
|
+
* is known up front, so the request carries Content-Length instead of a
|
|
16
|
+
* chunked body: what object stores expect, and the only framing that survives
|
|
17
|
+
* a proxy agent's rewrite of the buffered request head.
|
|
18
|
+
*/
|
|
19
|
+
export declare function multipartRequest(fields: Record<string, string>, file: {
|
|
20
|
+
name: string;
|
|
21
|
+
size: number;
|
|
22
|
+
stream: Readable;
|
|
23
|
+
}): UploadRequest;
|
|
24
|
+
/**
|
|
25
|
+
* Send `request` and resolve with the response status once its head arrives
|
|
26
|
+
* (the body is drained and dropped). Network errors reject as they are, with
|
|
27
|
+
* their `code` (ECONNRESET, ...); aborting `signal` rejects with an AbortError.
|
|
28
|
+
*/
|
|
29
|
+
export declare function sendUploadRequest(url: string, request: UploadRequest, options: {
|
|
30
|
+
agent?: HttpAgent;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
userAgent?: string;
|
|
33
|
+
}): Promise<UploadResponse>;
|