react-native-update-cli 2.16.1 → 2.18.0
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/cli.json +3 -0
- package/lib/diff.js +171 -10
- package/lib/locales/en.d.ts +3 -0
- package/lib/locales/en.js +3 -0
- package/lib/locales/zh.d.ts +3 -0
- package/lib/locales/zh.js +3 -0
- package/lib/utils/hbcTransform.d.ts +86 -0
- package/lib/utils/hbcTransform.js +506 -0
- package/package.json +2 -1
- package/src/diff.ts +277 -9
- package/src/locales/en.ts +6 -0
- package/src/locales/zh.ts +6 -0
- package/src/utils/hbcTransform.ts +460 -0
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get HBC_LAYOUTS () {
|
|
13
|
+
return HBC_LAYOUTS;
|
|
14
|
+
},
|
|
15
|
+
get HBC_TRANSFORM_VERSION () {
|
|
16
|
+
return HBC_TRANSFORM_VERSION;
|
|
17
|
+
},
|
|
18
|
+
get compileLayoutToWire () {
|
|
19
|
+
return compileLayoutToWire;
|
|
20
|
+
},
|
|
21
|
+
get findLayouts () {
|
|
22
|
+
return findLayouts;
|
|
23
|
+
},
|
|
24
|
+
get getHbcVersion () {
|
|
25
|
+
return getHbcVersion;
|
|
26
|
+
},
|
|
27
|
+
get pickLayout () {
|
|
28
|
+
return pickLayout;
|
|
29
|
+
},
|
|
30
|
+
get transformHbc () {
|
|
31
|
+
return transformHbc;
|
|
32
|
+
},
|
|
33
|
+
get transformHbcWithLayout () {
|
|
34
|
+
return transformHbcWithLayout;
|
|
35
|
+
},
|
|
36
|
+
get tryTransformPair () {
|
|
37
|
+
return tryTransformPair;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* Hermes 字节码(HBC)delta-friendly 可逆变换。
|
|
42
|
+
*
|
|
43
|
+
* 原理:HBC 中 functionHeaders / smallStringTable 等表的条目携带绝对偏移,
|
|
44
|
+
* 任意一处内容增删都会让其后所有条目的偏移整体 +N,精确匹配型 diff(hdiff)
|
|
45
|
+
* 无法复用这些被移位的条目。对这些偏移字段做前项差分(wrapping,模字段位宽)
|
|
46
|
+
* 后,整体移位在差分域退化为单点变化,diff 显著变小。
|
|
47
|
+
*
|
|
48
|
+
* 布局描述表是纯数据:解释器(本文件 + 客户端 C 版)不含任何版本分支。
|
|
49
|
+
* 新 Hermes 版本只需在 HBC_LAYOUTS 增加/扩展一个条目。CLI 生成 diff 时把
|
|
50
|
+
* 实际使用的描述表以 wire 格式写入 __diff.json,客户端按表执行 T⁻¹,
|
|
51
|
+
* 因此客户端无需跟进 HBC 版本。
|
|
52
|
+
*
|
|
53
|
+
* wrapping 差分与单调性无关、恒可逆:T⁻¹(T(x)) === x 对任意输入成立
|
|
54
|
+
* (只要两侧使用同一份描述表)。
|
|
55
|
+
*/ const HBC_MAGIC = Buffer.from([
|
|
56
|
+
0xc6,
|
|
57
|
+
0x1f,
|
|
58
|
+
0xbc,
|
|
59
|
+
0x03,
|
|
60
|
+
0xc1,
|
|
61
|
+
0x03,
|
|
62
|
+
0x19,
|
|
63
|
+
0x1f
|
|
64
|
+
]);
|
|
65
|
+
const HEADER_COUNTS_OFFSET = 32; // magic(8) + version(4) + sourceHash(20)
|
|
66
|
+
const HBC_HEADER_SIZE = 128;
|
|
67
|
+
const FUNC_OFFSET_25 = {
|
|
68
|
+
byte: 0,
|
|
69
|
+
bit: 0,
|
|
70
|
+
bits: 25
|
|
71
|
+
};
|
|
72
|
+
const STRING_OFFSET_23 = {
|
|
73
|
+
byte: 0,
|
|
74
|
+
bit: 1,
|
|
75
|
+
bits: 23
|
|
76
|
+
};
|
|
77
|
+
const PAIR_OFFSET_32 = {
|
|
78
|
+
byte: 0,
|
|
79
|
+
bit: 0,
|
|
80
|
+
bits: 32
|
|
81
|
+
};
|
|
82
|
+
// v98 两种头部变体共享的段布局
|
|
83
|
+
const V98_SECTIONS = [
|
|
84
|
+
{
|
|
85
|
+
name: 'functionHeaders',
|
|
86
|
+
countField: 'functionCount',
|
|
87
|
+
entrySize: 12,
|
|
88
|
+
deltaFields: [
|
|
89
|
+
FUNC_OFFSET_25
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'stringKinds',
|
|
94
|
+
countField: 'stringKindCount',
|
|
95
|
+
entrySize: 4
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'identifierHashes',
|
|
99
|
+
countField: 'identifierCount',
|
|
100
|
+
entrySize: 4
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'smallStringTable',
|
|
104
|
+
countField: 'stringCount',
|
|
105
|
+
entrySize: 4,
|
|
106
|
+
deltaFields: [
|
|
107
|
+
STRING_OFFSET_23
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'overflowStringTable',
|
|
112
|
+
countField: 'overflowStringCount',
|
|
113
|
+
entrySize: 8,
|
|
114
|
+
deltaFields: [
|
|
115
|
+
PAIR_OFFSET_32
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: 'stringStorage',
|
|
120
|
+
countField: 'stringStorageSize',
|
|
121
|
+
entrySize: 1
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: 'literalValueBuffer',
|
|
125
|
+
countField: 'literalValueBufferSize',
|
|
126
|
+
entrySize: 1
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: 'objKeyBuffer',
|
|
130
|
+
countField: 'objKeyBufferSize',
|
|
131
|
+
entrySize: 1
|
|
132
|
+
},
|
|
133
|
+
// ShapeTableEntry 8B:{keyBufferOffset u32, numProps u32}
|
|
134
|
+
{
|
|
135
|
+
name: 'objShapeTable',
|
|
136
|
+
countField: 'objShapeTableCount',
|
|
137
|
+
entrySize: 8,
|
|
138
|
+
deltaFields: [
|
|
139
|
+
PAIR_OFFSET_32
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'bigIntTable',
|
|
144
|
+
countField: 'bigIntCount',
|
|
145
|
+
entrySize: 8,
|
|
146
|
+
deltaFields: [
|
|
147
|
+
PAIR_OFFSET_32
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'bigIntStorage',
|
|
152
|
+
countField: 'bigIntStorageSize',
|
|
153
|
+
entrySize: 1
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: 'regExpTable',
|
|
157
|
+
countField: 'regExpCount',
|
|
158
|
+
entrySize: 8,
|
|
159
|
+
deltaFields: [
|
|
160
|
+
PAIR_OFFSET_32
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: 'regExpStorage',
|
|
165
|
+
countField: 'regExpStorageSize',
|
|
166
|
+
entrySize: 1
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: 'cjsModuleTable',
|
|
170
|
+
countField: 'cjsModuleCount',
|
|
171
|
+
entrySize: 8
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: 'functionSourceTable',
|
|
175
|
+
countField: 'functionSourceCount',
|
|
176
|
+
entrySize: 8
|
|
177
|
+
}
|
|
178
|
+
];
|
|
179
|
+
const HBC_LAYOUTS = [
|
|
180
|
+
{
|
|
181
|
+
// hermes 0.12 主线(RN 0.69~0.81+),v87 引入 bigInt 字段后布局稳定
|
|
182
|
+
minVersion: 87,
|
|
183
|
+
maxVersion: 96,
|
|
184
|
+
headerFields: [
|
|
185
|
+
'fileLength',
|
|
186
|
+
'globalCodeIndex',
|
|
187
|
+
'functionCount',
|
|
188
|
+
'stringKindCount',
|
|
189
|
+
'identifierCount',
|
|
190
|
+
'stringCount',
|
|
191
|
+
'overflowStringCount',
|
|
192
|
+
'stringStorageSize',
|
|
193
|
+
'bigIntCount',
|
|
194
|
+
'bigIntStorageSize',
|
|
195
|
+
'regExpCount',
|
|
196
|
+
'regExpStorageSize',
|
|
197
|
+
'arrayBufferSize',
|
|
198
|
+
'objKeyBufferSize',
|
|
199
|
+
'objValueBufferSize',
|
|
200
|
+
'segmentID',
|
|
201
|
+
'cjsModuleCount',
|
|
202
|
+
'functionSourceCount',
|
|
203
|
+
'debugInfoOffset'
|
|
204
|
+
],
|
|
205
|
+
sections: [
|
|
206
|
+
// SmallFuncHeader 16B:word0 offset:25|paramCount:7,word2 infoOffset:25|frameSize:7
|
|
207
|
+
{
|
|
208
|
+
name: 'functionHeaders',
|
|
209
|
+
countField: 'functionCount',
|
|
210
|
+
entrySize: 16,
|
|
211
|
+
deltaFields: [
|
|
212
|
+
FUNC_OFFSET_25,
|
|
213
|
+
{
|
|
214
|
+
byte: 8,
|
|
215
|
+
bit: 0,
|
|
216
|
+
bits: 25
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
name: 'stringKinds',
|
|
222
|
+
countField: 'stringKindCount',
|
|
223
|
+
entrySize: 4
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
name: 'identifierHashes',
|
|
227
|
+
countField: 'identifierCount',
|
|
228
|
+
entrySize: 4
|
|
229
|
+
},
|
|
230
|
+
// SmallStringTableEntry 4B:isUTF16:1|offset:23|length:8
|
|
231
|
+
{
|
|
232
|
+
name: 'smallStringTable',
|
|
233
|
+
countField: 'stringCount',
|
|
234
|
+
entrySize: 4,
|
|
235
|
+
deltaFields: [
|
|
236
|
+
STRING_OFFSET_23
|
|
237
|
+
]
|
|
238
|
+
},
|
|
239
|
+
// OverflowStringTableEntry 8B:{offset u32, length u32}
|
|
240
|
+
{
|
|
241
|
+
name: 'overflowStringTable',
|
|
242
|
+
countField: 'overflowStringCount',
|
|
243
|
+
entrySize: 8,
|
|
244
|
+
deltaFields: [
|
|
245
|
+
PAIR_OFFSET_32
|
|
246
|
+
]
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
name: 'stringStorage',
|
|
250
|
+
countField: 'stringStorageSize',
|
|
251
|
+
entrySize: 1
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
name: 'arrayBuffer',
|
|
255
|
+
countField: 'arrayBufferSize',
|
|
256
|
+
entrySize: 1
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: 'objKeyBuffer',
|
|
260
|
+
countField: 'objKeyBufferSize',
|
|
261
|
+
entrySize: 1
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: 'objValueBuffer',
|
|
265
|
+
countField: 'objValueBufferSize',
|
|
266
|
+
entrySize: 1
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
name: 'bigIntTable',
|
|
270
|
+
countField: 'bigIntCount',
|
|
271
|
+
entrySize: 8,
|
|
272
|
+
deltaFields: [
|
|
273
|
+
PAIR_OFFSET_32
|
|
274
|
+
]
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
name: 'bigIntStorage',
|
|
278
|
+
countField: 'bigIntStorageSize',
|
|
279
|
+
entrySize: 1
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
name: 'regExpTable',
|
|
283
|
+
countField: 'regExpCount',
|
|
284
|
+
entrySize: 8,
|
|
285
|
+
deltaFields: [
|
|
286
|
+
PAIR_OFFSET_32
|
|
287
|
+
]
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
name: 'regExpStorage',
|
|
291
|
+
countField: 'regExpStorageSize',
|
|
292
|
+
entrySize: 1
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
name: 'cjsModuleTable',
|
|
296
|
+
countField: 'cjsModuleCount',
|
|
297
|
+
entrySize: 8
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
name: 'functionSourceTable',
|
|
301
|
+
countField: 'functionSourceCount',
|
|
302
|
+
entrySize: 8
|
|
303
|
+
}
|
|
304
|
+
]
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
// Static Hermes 晚期 v98(生产观测到的主流形态):相对早期 v98 头部
|
|
308
|
+
// 多一个 numStringSwitchImms 槽(hermes static_h 在不 bump 版本号的
|
|
309
|
+
// 情况下插入,同一版本号 98 因此存在两种布局,依结构校验区分)。
|
|
310
|
+
// 段布局与早期 v98 相同。
|
|
311
|
+
minVersion: 98,
|
|
312
|
+
maxVersion: 98,
|
|
313
|
+
headerFields: [
|
|
314
|
+
'fileLength',
|
|
315
|
+
'globalCodeIndex',
|
|
316
|
+
'functionCount',
|
|
317
|
+
'stringKindCount',
|
|
318
|
+
'identifierCount',
|
|
319
|
+
'stringCount',
|
|
320
|
+
'overflowStringCount',
|
|
321
|
+
'stringStorageSize',
|
|
322
|
+
'bigIntCount',
|
|
323
|
+
'bigIntStorageSize',
|
|
324
|
+
'regExpCount',
|
|
325
|
+
'regExpStorageSize',
|
|
326
|
+
'literalValueBufferSize',
|
|
327
|
+
'objKeyBufferSize',
|
|
328
|
+
'objShapeTableCount',
|
|
329
|
+
'numStringSwitchImms',
|
|
330
|
+
'segmentID',
|
|
331
|
+
'cjsModuleCount',
|
|
332
|
+
'functionSourceCount',
|
|
333
|
+
'debugInfoOffset'
|
|
334
|
+
],
|
|
335
|
+
sections: V98_SECTIONS
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
// Static Hermes 早期 v98(hermes c00cc57595 时点,无 numStringSwitchImms)。
|
|
339
|
+
// 相对 v96:SmallFuncHeader 16B→12B(去 infoOffset/environmentSize);
|
|
340
|
+
// objValueBuffer(字节段)→ objShapeTable(8B 条目);
|
|
341
|
+
// arrayBufferSize 更名 literalValueBufferSize(槽位不变)。
|
|
342
|
+
minVersion: 98,
|
|
343
|
+
maxVersion: 98,
|
|
344
|
+
headerFields: [
|
|
345
|
+
'fileLength',
|
|
346
|
+
'globalCodeIndex',
|
|
347
|
+
'functionCount',
|
|
348
|
+
'stringKindCount',
|
|
349
|
+
'identifierCount',
|
|
350
|
+
'stringCount',
|
|
351
|
+
'overflowStringCount',
|
|
352
|
+
'stringStorageSize',
|
|
353
|
+
'bigIntCount',
|
|
354
|
+
'bigIntStorageSize',
|
|
355
|
+
'regExpCount',
|
|
356
|
+
'regExpStorageSize',
|
|
357
|
+
'literalValueBufferSize',
|
|
358
|
+
'objKeyBufferSize',
|
|
359
|
+
'objShapeTableCount',
|
|
360
|
+
'segmentID',
|
|
361
|
+
'cjsModuleCount',
|
|
362
|
+
'functionSourceCount',
|
|
363
|
+
'debugInfoOffset'
|
|
364
|
+
],
|
|
365
|
+
sections: V98_SECTIONS
|
|
366
|
+
}
|
|
367
|
+
];
|
|
368
|
+
function compileLayoutToWire(layout) {
|
|
369
|
+
if (layout.headerFields[0] !== 'fileLength' || layout.headerFields[layout.headerFields.length - 1] !== 'debugInfoOffset') {
|
|
370
|
+
throw new Error('HbcLayout must start with fileLength and end with debugInfoOffset');
|
|
371
|
+
}
|
|
372
|
+
return {
|
|
373
|
+
counts: layout.headerFields.length,
|
|
374
|
+
sections: layout.sections.map((s)=>{
|
|
375
|
+
var _s_deltaFields;
|
|
376
|
+
return [
|
|
377
|
+
layout.headerFields.indexOf(s.countField),
|
|
378
|
+
s.entrySize,
|
|
379
|
+
((_s_deltaFields = s.deltaFields) != null ? _s_deltaFields : []).map((f)=>[
|
|
380
|
+
f.byte,
|
|
381
|
+
f.bit,
|
|
382
|
+
f.bits
|
|
383
|
+
])
|
|
384
|
+
];
|
|
385
|
+
})
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
function getHbcVersion(buf) {
|
|
389
|
+
if (buf.length < HBC_HEADER_SIZE) return null;
|
|
390
|
+
if (!buf.subarray(0, 8).equals(HBC_MAGIC)) return null;
|
|
391
|
+
return buf.readUInt32LE(8);
|
|
392
|
+
}
|
|
393
|
+
function findLayouts(version) {
|
|
394
|
+
return HBC_LAYOUTS.filter((l)=>version >= l.minVersion && version <= l.maxVersion);
|
|
395
|
+
}
|
|
396
|
+
const align4 = (x)=>x + 3 & ~3;
|
|
397
|
+
/**
|
|
398
|
+
* 按描述表解析并校验段边界。任何不一致(截断、计数越界、段区间超出
|
|
399
|
+
* debugInfoOffset)都返回 null——调用方回退到不变换路径。
|
|
400
|
+
* 描述表视为不可信输入,所有算术做显式边界检查。
|
|
401
|
+
*/ function resolveSections(buf, layout) {
|
|
402
|
+
const headerEnd = HEADER_COUNTS_OFFSET + layout.headerFields.length * 4;
|
|
403
|
+
if (buf.length < HBC_HEADER_SIZE || headerEnd > HBC_HEADER_SIZE) return null;
|
|
404
|
+
const counts = {};
|
|
405
|
+
layout.headerFields.forEach((name, i)=>{
|
|
406
|
+
counts[name] = buf.readUInt32LE(HEADER_COUNTS_OFFSET + i * 4);
|
|
407
|
+
});
|
|
408
|
+
if (counts.fileLength !== buf.length) return null;
|
|
409
|
+
const debugInfoOffset = counts.debugInfoOffset;
|
|
410
|
+
if (!Number.isInteger(debugInfoOffset) || debugInfoOffset < HBC_HEADER_SIZE || debugInfoOffset > buf.length) {
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
413
|
+
const resolved = [];
|
|
414
|
+
let off = HBC_HEADER_SIZE;
|
|
415
|
+
for (const desc of layout.sections){
|
|
416
|
+
var _desc_deltaFields;
|
|
417
|
+
const count = counts[desc.countField];
|
|
418
|
+
if (count === undefined || count > 0x0fffffff) return null;
|
|
419
|
+
const size = count * desc.entrySize;
|
|
420
|
+
off = align4(off);
|
|
421
|
+
if (off + size > debugInfoOffset) return null;
|
|
422
|
+
for (const f of (_desc_deltaFields = desc.deltaFields) != null ? _desc_deltaFields : []){
|
|
423
|
+
// 差分字段必须完整落在条目内且可用一次 u32 读写覆盖
|
|
424
|
+
if (f.bits < 1 || f.bits > 32 || f.bit + f.bits > 32 || f.byte + 4 > desc.entrySize) {
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
resolved.push({
|
|
429
|
+
start: off,
|
|
430
|
+
size,
|
|
431
|
+
desc
|
|
432
|
+
});
|
|
433
|
+
off += size;
|
|
434
|
+
}
|
|
435
|
+
return resolved;
|
|
436
|
+
}
|
|
437
|
+
function applyDelta(out, section, inverse) {
|
|
438
|
+
var _desc_deltaFields;
|
|
439
|
+
const { start, size, desc } = section;
|
|
440
|
+
for (const f of (_desc_deltaFields = desc.deltaFields) != null ? _desc_deltaFields : []){
|
|
441
|
+
// bits === 32 时掩码为全 1;>>> 保持无符号语义
|
|
442
|
+
const mask = f.bits === 32 ? 0xffffffff : (1 << f.bits) - 1 << f.bit;
|
|
443
|
+
const fieldMask = f.bits === 32 ? 0xffffffff : (1 << f.bits) - 1;
|
|
444
|
+
let prev = 0;
|
|
445
|
+
for(let p = start + f.byte; p < start + size; p += desc.entrySize){
|
|
446
|
+
const word = out.readUInt32LE(p);
|
|
447
|
+
const val = word >>> f.bit & fieldMask;
|
|
448
|
+
let enc;
|
|
449
|
+
if (!inverse) {
|
|
450
|
+
enc = val - prev & fieldMask;
|
|
451
|
+
prev = val;
|
|
452
|
+
} else {
|
|
453
|
+
enc = val + prev & fieldMask;
|
|
454
|
+
prev = enc;
|
|
455
|
+
}
|
|
456
|
+
out.writeUInt32LE((word & ~mask | enc << f.bit) >>> 0, p);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
function transformHbc(buf, inverse = false) {
|
|
461
|
+
const layout = pickLayout(buf);
|
|
462
|
+
if (!layout) return null;
|
|
463
|
+
return transformHbcWithLayout(buf, layout, inverse);
|
|
464
|
+
}
|
|
465
|
+
function pickLayout(buf) {
|
|
466
|
+
const version = getHbcVersion(buf);
|
|
467
|
+
if (version === null) return null;
|
|
468
|
+
for (const layout of findLayouts(version)){
|
|
469
|
+
if (resolveSections(buf, layout)) return layout;
|
|
470
|
+
}
|
|
471
|
+
return null;
|
|
472
|
+
}
|
|
473
|
+
function transformHbcWithLayout(buf, layout, inverse) {
|
|
474
|
+
const sections = resolveSections(buf, layout);
|
|
475
|
+
if (!sections) return null;
|
|
476
|
+
const out = Buffer.from(buf);
|
|
477
|
+
for (const s of sections){
|
|
478
|
+
var _s_desc_deltaFields;
|
|
479
|
+
if ((_s_desc_deltaFields = s.desc.deltaFields) == null ? void 0 : _s_desc_deltaFields.length) applyDelta(out, s, inverse);
|
|
480
|
+
}
|
|
481
|
+
return out;
|
|
482
|
+
}
|
|
483
|
+
const HBC_TRANSFORM_VERSION = 1;
|
|
484
|
+
function tryTransformPair(oldBuf, newBuf) {
|
|
485
|
+
const oldVersion = getHbcVersion(oldBuf);
|
|
486
|
+
const newVersion = getHbcVersion(newBuf);
|
|
487
|
+
if (oldVersion === null || newVersion === null || oldVersion !== newVersion) {
|
|
488
|
+
return null;
|
|
489
|
+
}
|
|
490
|
+
for (const layout of findLayouts(newVersion)){
|
|
491
|
+
const tOld = transformHbcWithLayout(oldBuf, layout, false);
|
|
492
|
+
const tNew = transformHbcWithLayout(newBuf, layout, false);
|
|
493
|
+
if (!tOld || !tNew) continue;
|
|
494
|
+
return {
|
|
495
|
+
tOld,
|
|
496
|
+
tNew,
|
|
497
|
+
layout,
|
|
498
|
+
meta: {
|
|
499
|
+
v: HBC_TRANSFORM_VERSION,
|
|
500
|
+
hbcVersion: newVersion,
|
|
501
|
+
layout: compileLayoutToWire(layout)
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
return null;
|
|
506
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-update-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.0",
|
|
4
4
|
"description": "command line tool for react-native-update (remote updates for react native)",
|
|
5
5
|
"main": "lib/exports.js",
|
|
6
6
|
"types": "lib/exports.d.ts",
|
|
@@ -102,6 +102,7 @@
|
|
|
102
102
|
"@types/semver": "^7.7.1",
|
|
103
103
|
"@types/yauzl": "^2.10.3",
|
|
104
104
|
"@types/yazl": "^2.4.6",
|
|
105
|
+
"node-hdiffpatch": "^2.0.3",
|
|
105
106
|
"typescript": "^6.0.2"
|
|
106
107
|
},
|
|
107
108
|
"trustedDependencies": [
|