react-native-update-cli 2.29.0 → 2.29.2
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/account.js +2 -4
- package/lib/api.d.ts +1 -1
- package/lib/api.js +35 -73
- package/lib/app.js +13 -27
- package/lib/auto-update.d.ts +1 -1
- package/lib/auto-update.js +6 -16
- package/lib/bin.js +4 -6
- package/lib/bundle-pack.js +26 -60
- package/lib/bundle-runner.js +89 -119
- package/lib/bundle.js +18 -26
- package/lib/diff.js +43 -133
- package/lib/locales/en.d.ts +0 -10
- package/lib/locales/en.js +0 -10
- package/lib/locales/zh.d.ts +0 -10
- package/lib/locales/zh.js +0 -10
- package/lib/native-package.js +27 -99
- package/lib/package.d.ts +6 -1
- package/lib/package.js +56 -108
- package/lib/provider.js +3 -5
- package/lib/symbolicate.js +1 -16
- package/lib/utils/add-gitignore.js +0 -1
- package/lib/utils/app-info-parser/aab.d.ts +5 -22
- package/lib/utils/app-info-parser/aab.js +89 -226
- package/lib/utils/app-info-parser/apk.d.ts +12 -13
- package/lib/utils/app-info-parser/apk.js +28 -78
- package/lib/utils/app-info-parser/ipa.d.ts +2 -14
- package/lib/utils/app-info-parser/ipa.js +9 -70
- package/lib/utils/app-info-parser/resource-finder.d.ts +1 -34
- package/lib/utils/app-info-parser/resource-finder.js +95 -234
- package/lib/utils/app-info-parser/xml-parser/binary.d.ts +6 -55
- package/lib/utils/app-info-parser/xml-parser/binary.js +152 -556
- package/lib/utils/app-info-parser/zip.d.ts +6 -24
- package/lib/utils/app-info-parser/zip.js +19 -86
- package/lib/utils/check-plugin.d.ts +7 -5
- package/lib/utils/check-plugin.js +15 -25
- package/lib/utils/dep-versions.d.ts +0 -6
- package/lib/utils/dep-versions.js +2 -27
- package/lib/utils/failure-fingerprint.js +3 -4
- package/lib/utils/fs-helpers.d.ts +18 -0
- package/lib/utils/fs-helpers.js +84 -0
- package/lib/utils/git.d.ts +0 -1
- package/lib/utils/git.js +0 -8
- package/lib/utils/hash.d.ts +3 -0
- package/lib/utils/hash.js +19 -0
- package/lib/utils/hbcTransform.d.ts +9 -2
- package/lib/utils/hbcTransform.js +41 -70
- package/lib/utils/hermes-base.d.ts +1 -5
- package/lib/utils/hermes-base.js +136 -196
- package/lib/utils/hermes-literals.d.ts +5 -3
- package/lib/utils/hermes-literals.js +30 -53
- package/lib/utils/hermes-raw.d.ts +7 -0
- package/lib/utils/hermes-raw.js +26 -9
- package/lib/utils/http-helper.d.ts +0 -1
- package/lib/utils/http-helper.js +0 -20
- package/lib/utils/i18n.js +0 -2
- package/lib/utils/index.d.ts +5 -19
- package/lib/utils/index.js +95 -189
- package/lib/utils/latest-version.d.ts +19 -0
- package/lib/utils/latest-version.js +137 -0
- package/lib/utils/options.d.ts +2 -1
- package/lib/utils/options.js +5 -7
- 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.d.ts +23 -0
- package/lib/utils/zip-entries.js +130 -139
- package/lib/utils/zip-options.js +29 -56
- package/lib/utils/zip-range.js +29 -69
- package/lib/utils/zip-raw-writer.js +6 -5
- package/lib/versions.d.ts +5 -0
- package/lib/versions.js +86 -153
- package/package.json +1 -9
- package/lib/utils/app-info-parser/app.d.ts +0 -4
- package/lib/utils/app-info-parser/app.js +0 -10
- package/lib/utils/app-info-parser/index.d.ts +0 -16
- package/lib/utils/app-info-parser/index.js +0 -46
- package/lib/utils/app-info-parser/utils.d.ts +0 -31
- package/lib/utils/app-info-parser/utils.js +0 -135
- package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +0 -10
- package/lib/utils/app-info-parser/xml-parser/manifest.js +0 -202
- package/lib/utils/latest-version/index.d.ts +0 -149
- package/lib/utils/latest-version/index.js +0 -326
- package/lib/utils/plugin-config.d.ts +0 -9
- package/lib/utils/plugin-config.js +0 -61
|
@@ -6,49 +6,76 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.ResourceFinder = void 0;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Little-endian cursor over a Buffer: the subset of the `bytebuffer` API this
|
|
11
|
+
* decoder used. Reads past `limit` throw a RangeError, which the chunk loops
|
|
12
|
+
* below rely on to stop at the end of the data.
|
|
13
|
+
*/
|
|
14
|
+
class Reader {
|
|
15
|
+
buffer;
|
|
16
|
+
offset = 0;
|
|
17
|
+
limit;
|
|
18
|
+
constructor(buffer) {
|
|
19
|
+
this.buffer = buffer;
|
|
20
|
+
this.limit = buffer.length;
|
|
21
|
+
}
|
|
22
|
+
advance(size) {
|
|
23
|
+
const at = this.offset;
|
|
24
|
+
if (at < 0 || at + size > this.limit) {
|
|
25
|
+
throw new RangeError(`Illegal offset: 0 <= ${at} (+${size}) <= ${this.limit}`);
|
|
26
|
+
}
|
|
27
|
+
this.offset = at + size;
|
|
28
|
+
return at;
|
|
29
|
+
}
|
|
30
|
+
remaining() {
|
|
31
|
+
return this.limit - this.offset;
|
|
32
|
+
}
|
|
33
|
+
readByte() {
|
|
34
|
+
return this.buffer.readInt8(this.advance(1));
|
|
35
|
+
}
|
|
36
|
+
readUint8() {
|
|
37
|
+
return this.buffer.readUInt8(this.advance(1));
|
|
38
|
+
}
|
|
39
|
+
readShort() {
|
|
40
|
+
return this.buffer.readInt16LE(this.advance(2));
|
|
41
|
+
}
|
|
42
|
+
readUint16() {
|
|
43
|
+
return this.buffer.readUInt16LE(this.advance(2));
|
|
44
|
+
}
|
|
45
|
+
readInt() {
|
|
46
|
+
return this.buffer.readInt32LE(this.advance(4));
|
|
47
|
+
}
|
|
48
|
+
skip(len) {
|
|
49
|
+
this.advance(len);
|
|
50
|
+
}
|
|
51
|
+
/** The next `len` bytes as a new reader (a view, not a copy). */
|
|
52
|
+
readBytes(len) {
|
|
53
|
+
const at = this.advance(len);
|
|
54
|
+
return new Reader(this.buffer.subarray(at, at + len));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** The `size`-byte chunk starting at `pos`, cut short at the end of the data. */
|
|
58
|
+
function chunkAt(bb, pos, size) {
|
|
59
|
+
return new Reader(bb.buffer.subarray(pos, pos + size));
|
|
60
|
+
}
|
|
11
61
|
const RES_STRING_POOL_TYPE = 0x0001;
|
|
12
62
|
const RES_TABLE_TYPE = 0x0002;
|
|
13
63
|
const RES_TABLE_PACKAGE_TYPE = 0x0200;
|
|
14
64
|
const RES_TABLE_TYPE_TYPE = 0x0201;
|
|
15
|
-
const RES_TABLE_TYPE_SPEC_TYPE = 0x0202;
|
|
16
65
|
const TYPE_REFERENCE = 0x01;
|
|
17
66
|
const TYPE_STRING = 0x03;
|
|
67
|
+
const FLAG_COMPLEX = 0x0001;
|
|
18
68
|
class ResourceFinder {
|
|
19
69
|
valueStringPool = null;
|
|
20
|
-
typeStringPool = null;
|
|
21
|
-
keyStringPool = null;
|
|
22
70
|
packageId = 0;
|
|
23
71
|
responseMap = {};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Same to C# BinaryReader.readBytes
|
|
27
|
-
*
|
|
28
|
-
* @param bb ByteBuffer
|
|
29
|
-
* @param len length
|
|
30
|
-
* @returns {Buffer}
|
|
31
|
-
*/
|
|
32
|
-
static readBytes(bb, len) {
|
|
33
|
-
const uint8Array = new Uint8Array(len);
|
|
34
|
-
for (let i = 0; i < len; i++) {
|
|
35
|
-
uint8Array[i] = bb.readUint8();
|
|
36
|
-
}
|
|
37
|
-
return ByteBuffer.wrap(uint8Array, 'binary', true);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
* @param {ByteBuffer} bb
|
|
42
|
-
* @return {Map<String, Set<String>>}
|
|
43
|
-
*/
|
|
72
|
+
/** Map of `@<RESOURCE ID>` to the values of that resource. */
|
|
44
73
|
processResourceTable(resourceBuffer) {
|
|
45
|
-
const bb =
|
|
74
|
+
const bb = new Reader(resourceBuffer);
|
|
46
75
|
const type = bb.readShort();
|
|
47
76
|
const headerSize = bb.readShort();
|
|
48
77
|
const size = bb.readInt();
|
|
49
78
|
const packageCount = bb.readInt();
|
|
50
|
-
let buffer;
|
|
51
|
-
let bb2;
|
|
52
79
|
if (type !== RES_TABLE_TYPE) {
|
|
53
80
|
throw new Error('No RES_TABLE_TYPE found!');
|
|
54
81
|
}
|
|
@@ -61,12 +88,11 @@ class ResourceFinder {
|
|
|
61
88
|
while (true) {
|
|
62
89
|
let pos = 0;
|
|
63
90
|
let t = 0;
|
|
64
|
-
let _hs = 0;
|
|
65
91
|
let s = 0;
|
|
66
92
|
try {
|
|
67
93
|
pos = bb.offset;
|
|
68
94
|
t = bb.readShort();
|
|
69
|
-
|
|
95
|
+
bb.readShort(); // header size
|
|
70
96
|
s = bb.readInt();
|
|
71
97
|
}
|
|
72
98
|
catch (_e) {
|
|
@@ -74,28 +100,12 @@ class ResourceFinder {
|
|
|
74
100
|
}
|
|
75
101
|
if (t === RES_STRING_POOL_TYPE) {
|
|
76
102
|
if (realStringPoolCount === 0) {
|
|
77
|
-
|
|
78
|
-
console.log('Processing the string pool ...');
|
|
79
|
-
}
|
|
80
|
-
buffer = new ByteBuffer(s);
|
|
81
|
-
bb.offset = pos;
|
|
82
|
-
bb.prependTo(buffer);
|
|
83
|
-
bb2 = ByteBuffer.wrap(buffer, 'binary', true);
|
|
84
|
-
bb2.LE();
|
|
85
|
-
this.valueStringPool = this.processStringPool(bb2);
|
|
103
|
+
this.valueStringPool = this.processStringPool(chunkAt(bb, pos, s));
|
|
86
104
|
}
|
|
87
105
|
realStringPoolCount++;
|
|
88
106
|
}
|
|
89
107
|
else if (t === RES_TABLE_PACKAGE_TYPE) {
|
|
90
|
-
|
|
91
|
-
console.log(`Processing the package ${realPackageCount} ...`);
|
|
92
|
-
}
|
|
93
|
-
buffer = new ByteBuffer(s);
|
|
94
|
-
bb.offset = pos;
|
|
95
|
-
bb.prependTo(buffer);
|
|
96
|
-
bb2 = ByteBuffer.wrap(buffer, 'binary', true);
|
|
97
|
-
bb2.LE();
|
|
98
|
-
this.processPackage(bb2);
|
|
108
|
+
this.processPackage(chunkAt(bb, pos, s));
|
|
99
109
|
realPackageCount++;
|
|
100
110
|
}
|
|
101
111
|
else {
|
|
@@ -113,74 +123,34 @@ class ResourceFinder {
|
|
|
113
123
|
}
|
|
114
124
|
return this.responseMap;
|
|
115
125
|
}
|
|
116
|
-
/**
|
|
117
|
-
*
|
|
118
|
-
* @param {ByteBuffer} bb
|
|
119
|
-
*/
|
|
120
126
|
processPackage(bb) {
|
|
121
|
-
|
|
127
|
+
bb.readShort(); // type
|
|
122
128
|
const headerSize = bb.readShort();
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
void size;
|
|
127
|
-
this.packageId = id;
|
|
128
|
-
for (let i = 0; i < 256; ++i) {
|
|
129
|
-
bb.readUint8();
|
|
130
|
-
}
|
|
129
|
+
bb.readInt(); // size
|
|
130
|
+
this.packageId = bb.readInt();
|
|
131
|
+
bb.skip(256); // package name
|
|
131
132
|
const typeStrings = bb.readInt();
|
|
132
|
-
|
|
133
|
+
bb.readInt(); // last public type
|
|
133
134
|
const keyStrings = bb.readInt();
|
|
134
|
-
|
|
135
|
-
void lastPublicType;
|
|
136
|
-
void lastPublicKey;
|
|
135
|
+
bb.readInt(); // last public key
|
|
137
136
|
if (typeStrings !== headerSize) {
|
|
138
137
|
throw new Error('TypeStrings must immediately following the package structure header.');
|
|
139
138
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
let lastPosition = bb.offset;
|
|
144
|
-
bb.offset = typeStrings;
|
|
145
|
-
const bbTypeStrings = ResourceFinder.readBytes(bb, bb.limit - bb.offset);
|
|
146
|
-
bb.offset = lastPosition;
|
|
147
|
-
this.typeStringPool = this.processStringPool(bbTypeStrings);
|
|
148
|
-
if (DEBUG) {
|
|
149
|
-
console.log('Key strings:');
|
|
150
|
-
}
|
|
139
|
+
// the type and key string pools only name entries: skip both, and the
|
|
140
|
+
// type specs (only flags); types carry the values
|
|
151
141
|
bb.offset = keyStrings;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
void keyType;
|
|
156
|
-
void keyHeaderSize;
|
|
157
|
-
lastPosition = bb.offset;
|
|
158
|
-
bb.offset = keyStrings;
|
|
159
|
-
const bbKeyStrings = ResourceFinder.readBytes(bb, bb.limit - bb.offset);
|
|
160
|
-
bb.offset = lastPosition;
|
|
161
|
-
this.keyStringPool = this.processStringPool(bbKeyStrings);
|
|
162
|
-
let typeSpecCount = 0;
|
|
163
|
-
let typeCount = 0;
|
|
164
|
-
bb.offset = keyStrings + keySize;
|
|
165
|
-
let bb2;
|
|
142
|
+
bb.readShort(); // key pool type
|
|
143
|
+
bb.readShort(); // key pool header size
|
|
144
|
+
bb.offset = keyStrings + bb.readInt();
|
|
166
145
|
while (true) {
|
|
167
146
|
const pos = bb.offset;
|
|
168
147
|
try {
|
|
169
148
|
const t = bb.readShort();
|
|
170
|
-
|
|
149
|
+
bb.readShort(); // header size
|
|
171
150
|
const s = bb.readInt();
|
|
172
|
-
|
|
173
|
-
if (t === RES_TABLE_TYPE_SPEC_TYPE) {
|
|
174
|
-
bb.offset = pos;
|
|
175
|
-
bb2 = ResourceFinder.readBytes(bb, s);
|
|
176
|
-
this.processTypeSpec(bb2);
|
|
177
|
-
typeSpecCount++;
|
|
178
|
-
}
|
|
179
|
-
else if (t === RES_TABLE_TYPE_TYPE) {
|
|
151
|
+
if (t === RES_TABLE_TYPE_TYPE) {
|
|
180
152
|
bb.offset = pos;
|
|
181
|
-
|
|
182
|
-
this.processType(bb2);
|
|
183
|
-
typeCount++;
|
|
153
|
+
this.processType(bb.readBytes(s));
|
|
184
154
|
}
|
|
185
155
|
if (s === 0) {
|
|
186
156
|
break;
|
|
@@ -194,29 +164,16 @@ class ResourceFinder {
|
|
|
194
164
|
break;
|
|
195
165
|
}
|
|
196
166
|
}
|
|
197
|
-
void typeSpecCount;
|
|
198
|
-
void typeCount;
|
|
199
167
|
}
|
|
200
|
-
/**
|
|
201
|
-
*
|
|
202
|
-
* @param {ByteBuffer} bb
|
|
203
|
-
*/
|
|
204
168
|
processType(bb) {
|
|
205
|
-
|
|
169
|
+
bb.readShort(); // type
|
|
206
170
|
const headerSize = bb.readShort();
|
|
207
|
-
|
|
171
|
+
bb.readInt(); // size
|
|
208
172
|
const id = bb.readByte();
|
|
209
|
-
|
|
210
|
-
const res1 = bb.readShort();
|
|
173
|
+
bb.skip(3); // res0, res1
|
|
211
174
|
const entryCount = bb.readInt();
|
|
212
175
|
const entriesStart = bb.readInt();
|
|
213
|
-
void type;
|
|
214
|
-
void size;
|
|
215
|
-
void res0;
|
|
216
|
-
void res1;
|
|
217
176
|
const refKeys = {};
|
|
218
|
-
const configSize = bb.readInt();
|
|
219
|
-
void configSize;
|
|
220
177
|
bb.offset = headerSize;
|
|
221
178
|
if (headerSize + entryCount * 4 !== entriesStart) {
|
|
222
179
|
throw new Error('HeaderSize, entryCount and entriesStart are not valid.');
|
|
@@ -229,73 +186,38 @@ class ResourceFinder {
|
|
|
229
186
|
if (entryIndices[i] === -1)
|
|
230
187
|
continue;
|
|
231
188
|
const resourceId = (this.packageId << 24) | (id << 16) | i;
|
|
232
|
-
let entrySize = 0;
|
|
233
189
|
let entryFlag = 0;
|
|
234
|
-
let entryKey = 0;
|
|
235
190
|
try {
|
|
236
|
-
|
|
191
|
+
bb.readShort(); // entry size
|
|
237
192
|
entryFlag = bb.readShort();
|
|
238
|
-
|
|
193
|
+
bb.readInt(); // key
|
|
239
194
|
}
|
|
240
195
|
catch (_e) {
|
|
241
196
|
break;
|
|
242
197
|
}
|
|
243
|
-
void entrySize;
|
|
244
|
-
const FLAG_COMPLEX = 0x0001;
|
|
245
198
|
if ((entryFlag & FLAG_COMPLEX) === 0) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const valueDataType = bb.
|
|
199
|
+
bb.readShort(); // value size
|
|
200
|
+
bb.readUint8(); // res0
|
|
201
|
+
const valueDataType = bb.readUint8();
|
|
249
202
|
const valueData = bb.readInt();
|
|
250
|
-
void valueSize;
|
|
251
|
-
void valueRes0;
|
|
252
203
|
const idStr = Number(resourceId).toString(16);
|
|
253
|
-
const keyStr = this.keyStringPool ? this.keyStringPool[entryKey] : '';
|
|
254
204
|
let data = null;
|
|
255
|
-
if (DEBUG) {
|
|
256
|
-
console.log(`Entry 0x${idStr}, key: ${keyStr}, simple value type: `);
|
|
257
|
-
}
|
|
258
|
-
const key = Number.parseInt(idStr, 16);
|
|
259
|
-
const entryArr = this.entryMap[key] ?? [];
|
|
260
|
-
entryArr.push(keyStr);
|
|
261
|
-
this.entryMap[key] = entryArr;
|
|
262
205
|
if (valueDataType === TYPE_STRING) {
|
|
263
206
|
data = this.valueStringPool ? this.valueStringPool[valueData] : null;
|
|
264
|
-
if (DEBUG && this.valueStringPool) {
|
|
265
|
-
console.log(`, data: ${this.valueStringPool[valueData]}`);
|
|
266
|
-
}
|
|
267
207
|
}
|
|
268
208
|
else if (valueDataType === TYPE_REFERENCE) {
|
|
269
209
|
refKeys[idStr] = valueData;
|
|
270
210
|
}
|
|
271
211
|
else {
|
|
272
212
|
data = `${valueData}`;
|
|
273
|
-
if (DEBUG) {
|
|
274
|
-
console.log(`, data: ${valueData}`);
|
|
275
|
-
}
|
|
276
213
|
}
|
|
277
214
|
this.putIntoMap(`@${idStr}`, data);
|
|
278
215
|
}
|
|
279
216
|
else {
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
const refName = bb.readInt();
|
|
285
|
-
const valueSize = bb.readShort();
|
|
286
|
-
const valueRes0 = bb.readByte();
|
|
287
|
-
const valueDataType = bb.readByte();
|
|
288
|
-
const valueData = bb.readInt();
|
|
289
|
-
void refName;
|
|
290
|
-
void valueSize;
|
|
291
|
-
void valueRes0;
|
|
292
|
-
void valueDataType;
|
|
293
|
-
void valueData;
|
|
294
|
-
}
|
|
295
|
-
if (DEBUG) {
|
|
296
|
-
const keyStr = this.keyStringPool ? this.keyStringPool[entryKey] : '';
|
|
297
|
-
console.log(`Entry 0x${Number(resourceId).toString(16)}, key: ${keyStr}, complex value, not printed.`);
|
|
298
|
-
}
|
|
217
|
+
bb.readInt(); // parent
|
|
218
|
+
const valueCount = bb.readInt();
|
|
219
|
+
// name (4) + Res_value (8) per value; maps are not resolved
|
|
220
|
+
bb.skip(valueCount * 12);
|
|
299
221
|
}
|
|
300
222
|
}
|
|
301
223
|
for (const refKey in refKeys) {
|
|
@@ -307,25 +229,15 @@ class ResourceFinder {
|
|
|
307
229
|
}
|
|
308
230
|
}
|
|
309
231
|
}
|
|
310
|
-
/**
|
|
311
|
-
*
|
|
312
|
-
* @param {ByteBuffer} bb
|
|
313
|
-
* @return {Array}
|
|
314
|
-
*/
|
|
315
232
|
processStringPool(bb) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
233
|
+
bb.readShort(); // type
|
|
234
|
+
bb.readShort(); // header size
|
|
235
|
+
bb.readInt(); // size
|
|
319
236
|
const stringCount = bb.readInt();
|
|
320
|
-
|
|
237
|
+
bb.readInt(); // style count
|
|
321
238
|
const flags = bb.readInt();
|
|
322
239
|
const stringsStart = bb.readInt();
|
|
323
|
-
|
|
324
|
-
void type;
|
|
325
|
-
void headerSize;
|
|
326
|
-
void size;
|
|
327
|
-
void styleCount;
|
|
328
|
-
void stylesStart;
|
|
240
|
+
bb.readInt(); // styles start
|
|
329
241
|
const isUtf8 = (flags & 256) !== 0;
|
|
330
242
|
const offsets = new Array(stringCount);
|
|
331
243
|
for (let i = 0; i < stringCount; ++i) {
|
|
@@ -333,32 +245,19 @@ class ResourceFinder {
|
|
|
333
245
|
}
|
|
334
246
|
const strings = new Array(stringCount);
|
|
335
247
|
for (let i = 0; i < stringCount; ++i) {
|
|
336
|
-
|
|
337
|
-
bb.offset = pos;
|
|
248
|
+
bb.offset = stringsStart + offsets[i];
|
|
338
249
|
strings[i] = '';
|
|
339
250
|
if (isUtf8) {
|
|
340
|
-
|
|
341
|
-
if ((
|
|
342
|
-
|
|
251
|
+
// UTF-16 length, then UTF-8 byte length; each 1 or 2 bytes
|
|
252
|
+
if ((bb.readUint8() & 0x80) !== 0) {
|
|
253
|
+
bb.readUint8();
|
|
343
254
|
}
|
|
344
255
|
let u8len = bb.readUint8();
|
|
345
256
|
if ((u8len & 0x80) !== 0) {
|
|
346
257
|
u8len = ((u8len & 0x7f) << 8) + bb.readUint8();
|
|
347
258
|
}
|
|
348
259
|
if (u8len > 0) {
|
|
349
|
-
|
|
350
|
-
try {
|
|
351
|
-
strings[i] = ByteBuffer.wrap(buffer, 'utf8', true).toString('utf8');
|
|
352
|
-
}
|
|
353
|
-
catch (e) {
|
|
354
|
-
if (DEBUG) {
|
|
355
|
-
console.error(e);
|
|
356
|
-
console.log('Error when turning buffer to utf-8 string.');
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
else {
|
|
361
|
-
strings[i] = '';
|
|
260
|
+
strings[i] = bb.readBytes(u8len).buffer.toString('utf8');
|
|
362
261
|
}
|
|
363
262
|
}
|
|
364
263
|
else {
|
|
@@ -367,50 +266,12 @@ class ResourceFinder {
|
|
|
367
266
|
u16len = ((u16len & 0x7fff) << 16) + bb.readUint16();
|
|
368
267
|
}
|
|
369
268
|
if (u16len > 0) {
|
|
370
|
-
|
|
371
|
-
const buffer = ResourceFinder.readBytes(bb, len);
|
|
372
|
-
try {
|
|
373
|
-
strings[i] = ByteBuffer.wrap(buffer, 'utf8', true).toString('utf8');
|
|
374
|
-
}
|
|
375
|
-
catch (e) {
|
|
376
|
-
if (DEBUG) {
|
|
377
|
-
console.error(e);
|
|
378
|
-
console.log('Error when turning buffer to utf-8 string.');
|
|
379
|
-
}
|
|
380
|
-
}
|
|
269
|
+
strings[i] = bb.readBytes(u16len * 2).buffer.toString('utf16le');
|
|
381
270
|
}
|
|
382
271
|
}
|
|
383
|
-
if (DEBUG) {
|
|
384
|
-
console.log('Parsed value: {0}', strings[i]);
|
|
385
|
-
}
|
|
386
272
|
}
|
|
387
273
|
return strings;
|
|
388
274
|
}
|
|
389
|
-
/**
|
|
390
|
-
*
|
|
391
|
-
* @param {ByteBuffer} bb
|
|
392
|
-
*/
|
|
393
|
-
processTypeSpec(bb) {
|
|
394
|
-
const type = bb.readShort();
|
|
395
|
-
const headerSize = bb.readShort();
|
|
396
|
-
const size = bb.readInt();
|
|
397
|
-
const id = bb.readByte();
|
|
398
|
-
const res0 = bb.readByte();
|
|
399
|
-
const res1 = bb.readShort();
|
|
400
|
-
const entryCount = bb.readInt();
|
|
401
|
-
void type;
|
|
402
|
-
void headerSize;
|
|
403
|
-
void size;
|
|
404
|
-
void res0;
|
|
405
|
-
void res1;
|
|
406
|
-
if (DEBUG && this.typeStringPool) {
|
|
407
|
-
console.log(`Processing type spec ${this.typeStringPool[id - 1]}...`);
|
|
408
|
-
}
|
|
409
|
-
const flags = new Array(entryCount);
|
|
410
|
-
for (let i = 0; i < entryCount; ++i) {
|
|
411
|
-
flags[i] = bb.readInt();
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
275
|
putIntoMap(resId, value) {
|
|
415
276
|
const key = resId.toUpperCase();
|
|
416
277
|
if (this.responseMap[key] == null) {
|
|
@@ -1,56 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
cursor: number;
|
|
7
|
-
strings: string[];
|
|
8
|
-
resources: number[];
|
|
9
|
-
document: any;
|
|
10
|
-
parent: any;
|
|
11
|
-
stack: any[];
|
|
12
|
-
debug: boolean;
|
|
13
|
-
constructor(buffer: Buffer, options?: BinaryXmlParserOptions);
|
|
14
|
-
readU8(): number;
|
|
15
|
-
readU16(): number;
|
|
16
|
-
readS32(): number;
|
|
17
|
-
readU32(): number;
|
|
18
|
-
readLength8(): number;
|
|
19
|
-
readLength16(): number;
|
|
20
|
-
readDimension(): {
|
|
21
|
-
value: number | null;
|
|
22
|
-
unit: string | null;
|
|
23
|
-
rawUnit: number | null;
|
|
24
|
-
};
|
|
25
|
-
readFraction(): {
|
|
26
|
-
value: number | null;
|
|
27
|
-
type: string | null;
|
|
28
|
-
rawType: number | null;
|
|
29
|
-
};
|
|
30
|
-
readHex24(): string;
|
|
31
|
-
readHex32(): string;
|
|
32
|
-
readTypedValue(): {
|
|
33
|
-
value: any;
|
|
34
|
-
type: string | null;
|
|
35
|
-
rawType: number | null;
|
|
36
|
-
};
|
|
37
|
-
convertIntToFloat(int: number): number;
|
|
38
|
-
readString(encoding: string): string;
|
|
39
|
-
readChunkHeader(): {
|
|
40
|
-
startOffset: number;
|
|
41
|
-
chunkType: number;
|
|
42
|
-
headerSize: number;
|
|
43
|
-
chunkSize: number;
|
|
44
|
-
};
|
|
45
|
-
readStringPool(header: any): null;
|
|
46
|
-
readResourceMap(header: any): null;
|
|
47
|
-
readXmlNamespaceStart(): null;
|
|
48
|
-
readXmlNamespaceEnd(): null;
|
|
49
|
-
readXmlElementStart(): any;
|
|
50
|
-
readXmlAttribute(): any;
|
|
51
|
-
readXmlElementEnd(): null;
|
|
52
|
-
readXmlCData(): any;
|
|
53
|
-
readNull(header: any): null;
|
|
54
|
-
parse(): any;
|
|
1
|
+
export interface XmlElement {
|
|
2
|
+
name: string;
|
|
3
|
+
/** typed attribute values; references read as `resourceId:0x<id>` */
|
|
4
|
+
attributes: Record<string, unknown>;
|
|
5
|
+
children: XmlElement[];
|
|
55
6
|
}
|
|
56
|
-
export
|
|
7
|
+
export declare function parseBinaryXml(buffer: Buffer): XmlElement;
|