react-native-update-cli 2.29.1 → 2.29.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/lib/account.js +2 -4
  2. package/lib/api.d.ts +1 -1
  3. package/lib/api.js +26 -44
  4. package/lib/app.js +13 -27
  5. package/lib/auto-update.d.ts +1 -1
  6. package/lib/auto-update.js +6 -16
  7. package/lib/bin.js +4 -6
  8. package/lib/bundle-pack.js +25 -27
  9. package/lib/bundle-runner.js +55 -54
  10. package/lib/bundle.js +18 -26
  11. package/lib/diff.js +32 -91
  12. package/lib/locales/en.d.ts +0 -10
  13. package/lib/locales/en.js +0 -10
  14. package/lib/locales/zh.d.ts +0 -10
  15. package/lib/locales/zh.js +0 -10
  16. package/lib/native-package.js +20 -60
  17. package/lib/package.d.ts +6 -1
  18. package/lib/package.js +59 -74
  19. package/lib/provider.js +3 -5
  20. package/lib/symbolicate.js +1 -16
  21. package/lib/utils/add-gitignore.js +0 -1
  22. package/lib/utils/app-info-parser/aab.d.ts +5 -22
  23. package/lib/utils/app-info-parser/aab.js +87 -192
  24. package/lib/utils/app-info-parser/apk.d.ts +12 -13
  25. package/lib/utils/app-info-parser/apk.js +28 -78
  26. package/lib/utils/app-info-parser/ipa.d.ts +2 -14
  27. package/lib/utils/app-info-parser/ipa.js +9 -70
  28. package/lib/utils/app-info-parser/resource-finder.d.ts +1 -26
  29. package/lib/utils/app-info-parser/resource-finder.js +41 -183
  30. package/lib/utils/app-info-parser/xml-parser/binary.d.ts +6 -55
  31. package/lib/utils/app-info-parser/xml-parser/binary.js +152 -556
  32. package/lib/utils/app-info-parser/zip.d.ts +6 -24
  33. package/lib/utils/app-info-parser/zip.js +19 -86
  34. package/lib/utils/check-plugin.d.ts +7 -5
  35. package/lib/utils/check-plugin.js +15 -25
  36. package/lib/utils/dep-versions.d.ts +0 -6
  37. package/lib/utils/dep-versions.js +2 -27
  38. package/lib/utils/failure-fingerprint.js +3 -4
  39. package/lib/utils/fs-helpers.d.ts +5 -0
  40. package/lib/utils/fs-helpers.js +19 -0
  41. package/lib/utils/git.d.ts +0 -1
  42. package/lib/utils/git.js +0 -8
  43. package/lib/utils/hash.d.ts +3 -0
  44. package/lib/utils/hash.js +19 -0
  45. package/lib/utils/hbcTransform.d.ts +9 -2
  46. package/lib/utils/hbcTransform.js +41 -70
  47. package/lib/utils/hermes-base.d.ts +1 -5
  48. package/lib/utils/hermes-base.js +93 -156
  49. package/lib/utils/hermes-literals.d.ts +5 -3
  50. package/lib/utils/hermes-literals.js +30 -53
  51. package/lib/utils/hermes-raw.d.ts +7 -0
  52. package/lib/utils/hermes-raw.js +26 -9
  53. package/lib/utils/http-helper.d.ts +0 -1
  54. package/lib/utils/http-helper.js +0 -20
  55. package/lib/utils/i18n.js +0 -2
  56. package/lib/utils/index.d.ts +5 -19
  57. package/lib/utils/index.js +95 -189
  58. package/lib/utils/latest-version.d.ts +19 -0
  59. package/lib/utils/latest-version.js +137 -0
  60. package/lib/utils/options.d.ts +2 -1
  61. package/lib/utils/options.js +5 -7
  62. package/lib/utils/zip-entries.d.ts +23 -0
  63. package/lib/utils/zip-entries.js +125 -102
  64. package/lib/utils/zip-options.js +29 -56
  65. package/lib/utils/zip-range.js +25 -65
  66. package/lib/versions.d.ts +5 -0
  67. package/lib/versions.js +86 -153
  68. package/package.json +1 -3
  69. package/lib/utils/app-info-parser/app.d.ts +0 -4
  70. package/lib/utils/app-info-parser/app.js +0 -10
  71. package/lib/utils/app-info-parser/index.d.ts +0 -16
  72. package/lib/utils/app-info-parser/index.js +0 -46
  73. package/lib/utils/app-info-parser/utils.d.ts +0 -31
  74. package/lib/utils/app-info-parser/utils.js +0 -135
  75. package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +0 -10
  76. package/lib/utils/app-info-parser/xml-parser/manifest.js +0 -202
  77. package/lib/utils/latest-version/index.d.ts +0 -149
  78. package/lib/utils/latest-version/index.js +0 -326
  79. package/lib/utils/plugin-config.d.ts +0 -9
  80. package/lib/utils/plugin-config.js +0 -31
@@ -1,90 +1,40 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApkParser = void 0;
3
+ exports.parseApkManifest = parseApkManifest;
4
4
  const resource_finder_1 = require("./resource-finder");
5
- const utils_1 = require("./utils");
6
- const manifest_1 = require("./xml-parser/manifest");
7
- const zip_1 = require("./zip");
8
- const ManifestName = /^androidmanifest\.xml$/;
9
- const ResourceName = /^resources\.arsc$/;
10
- class ApkParser extends zip_1.Zip {
11
- parse() {
12
- const manifestKey = ManifestName.toString();
13
- const resourceKey = ResourceName.toString();
14
- return new Promise((resolve, reject) => {
15
- this.getEntries([ManifestName, ResourceName])
16
- .then((buffers) => {
17
- const manifestBuffer = buffers[manifestKey];
18
- if (!manifestBuffer) {
19
- throw new Error("AndroidManifest.xml can't be found.");
20
- }
21
- let apkInfo;
22
- let resourceMap;
23
- apkInfo = this._parseManifest(manifestBuffer);
24
- if (!buffers[resourceKey]) {
25
- resolve(apkInfo);
26
- }
27
- else {
28
- resourceMap = this._parseResourceMap(buffers[resourceKey]);
29
- apkInfo = (0, utils_1.mapInfoResource)(apkInfo, resourceMap);
30
- const iconPath = (0, utils_1.findApkIconPath)(apkInfo);
31
- if (iconPath) {
32
- this.getEntry(iconPath)
33
- .then((iconBuffer) => {
34
- apkInfo.icon = Buffer.isBuffer(iconBuffer)
35
- ? (0, utils_1.getBase64FromBuffer)(iconBuffer)
36
- : null;
37
- resolve(apkInfo);
38
- })
39
- .catch((e) => {
40
- apkInfo.icon = null;
41
- resolve(apkInfo);
42
- console.warn('[Warning] failed to parse icon: ', e);
43
- });
44
- }
45
- else {
46
- apkInfo.icon = null;
47
- resolve(apkInfo);
48
- }
49
- }
50
- })
51
- .catch((e) => {
52
- reject(e);
53
- });
54
- });
5
+ const binary_1 = require("./xml-parser/binary");
6
+ /**
7
+ * The fields of a binary AndroidManifest.xml the CLI reads, with
8
+ * `@<resource>` references resolved through resources.arsc when given.
9
+ */
10
+ function parseApkManifest(manifest, resources) {
11
+ let root;
12
+ try {
13
+ root = (0, binary_1.parseBinaryXml)(manifest);
55
14
  }
56
- /**
57
- * Parse manifest
58
- * @param {Buffer} buffer // manifest file's buffer
59
- */
60
- _parseManifest(buffer) {
61
- try {
62
- const parser = new manifest_1.ManifestParser(buffer, {
63
- ignore: [
64
- 'application.activity',
65
- 'application.service',
66
- 'application.receiver',
67
- 'application.provider',
68
- 'permission-group',
69
- ],
70
- });
71
- return parser.parse();
72
- }
73
- catch (e) {
74
- throw new Error(`Parse AndroidManifest.xml error: ${e.message || e}`);
75
- }
15
+ catch (e) {
16
+ throw new Error(`Parse AndroidManifest.xml error: ${e.message || e}`);
76
17
  }
77
- /**
78
- * Parse resourceMap
79
- * @param {Buffer} buffer // resourceMap file's buffer
80
- */
81
- _parseResourceMap(buffer) {
18
+ let resourceMap = {};
19
+ if (resources) {
82
20
  try {
83
- return new resource_finder_1.ResourceFinder().processResourceTable(buffer);
21
+ resourceMap = new resource_finder_1.ResourceFinder().processResourceTable(resources);
84
22
  }
85
23
  catch (e) {
86
24
  throw new Error(`Parser resources.arsc error: ${e}`);
87
25
  }
88
26
  }
27
+ const resolve = (value) => typeof value === 'string' && value.startsWith('resourceId:')
28
+ ? resourceMap[`@${value.replace('resourceId:0x', '').toUpperCase()}`]
29
+ : value;
30
+ const application = root.children.find((el) => el.name === 'application');
31
+ return {
32
+ versionName: resolve(root.attributes.versionName),
33
+ metaData: (application?.children ?? [])
34
+ .filter((el) => el.name === 'meta-data')
35
+ .map(({ attributes }) => ({
36
+ name: resolve(attributes.name),
37
+ value: resolve(attributes.value),
38
+ })),
39
+ };
89
40
  }
90
- exports.ApkParser = ApkParser;
@@ -1,14 +1,2 @@
1
- import { Zip } from './zip';
2
- export declare class IpaParser extends Zip {
3
- parse(): Promise<any>;
4
- /**
5
- * Parse plist
6
- * @param {Buffer} buffer // plist file's buffer
7
- */
8
- private _parsePlist;
9
- /**
10
- * parse provision
11
- * @param {Buffer} buffer // provision file's buffer
12
- */
13
- private _parseProvision;
14
- }
1
+ /** Parse an Info.plist in XML or binary form. */
2
+ export declare function parsePlist(buffer: Buffer): Promise<Record<string, any>>;
@@ -1,12 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IpaParser = void 0;
3
+ exports.parsePlist = parsePlist;
4
4
  const parseBplist = require('bplist-parser').parseBuffer;
5
- const cgbiToPng = require('cgbi-to-png');
6
- const utils_1 = require("./utils");
7
- const zip_1 = require("./zip");
8
- const PlistName = /payload\/[^/]+?.app\/info.plist$/i;
9
- const ProvisionName = /payload\/.+?\.app\/embedded.mobileprovision/;
10
5
  let parsePlistPromise;
11
6
  function loadParsePlist() {
12
7
  if (!parsePlistPromise) {
@@ -27,70 +22,14 @@ function loadParsePlist() {
27
22
  }
28
23
  return parsePlistPromise;
29
24
  }
30
- class IpaParser extends zip_1.Zip {
31
- async parse() {
32
- const parsePlist = await loadParsePlist();
33
- const buffers = await this.getEntries([PlistName, ProvisionName]);
34
- if (!buffers[PlistName]) {
35
- throw new Error("Info.plist can't be found.");
36
- }
37
- const plistInfo = this._parsePlist(buffers[PlistName], parsePlist);
38
- const provisionInfo = this._parseProvision(buffers[ProvisionName], parsePlist);
39
- plistInfo.mobileProvision = provisionInfo;
40
- const iconRegex = new RegExp((0, utils_1.findIpaIconPath)(plistInfo).toLowerCase());
41
- const iconBuffer = await this.getEntry(iconRegex);
42
- try {
43
- plistInfo.icon = iconBuffer
44
- ? (0, utils_1.getBase64FromBuffer)(cgbiToPng.revert(iconBuffer))
45
- : null;
46
- }
47
- catch (err) {
48
- if ((0, utils_1.isBrowser)()) {
49
- plistInfo.icon = iconBuffer
50
- ? (0, utils_1.getBase64FromBuffer)(window.btoa(String.fromCharCode(...iconBuffer)))
51
- : null;
52
- }
53
- else {
54
- plistInfo.icon = null;
55
- console.warn('[Warning] failed to parse icon: ', err);
56
- }
57
- }
58
- return plistInfo;
25
+ /** Parse an Info.plist in XML or binary form. */
26
+ async function parsePlist(buffer) {
27
+ const bufferType = buffer[0];
28
+ if (bufferType === 60 || bufferType === 239) {
29
+ return (await loadParsePlist())(buffer.toString());
59
30
  }
60
- /**
61
- * Parse plist
62
- * @param {Buffer} buffer // plist file's buffer
63
- */
64
- _parsePlist(buffer, parsePlist) {
65
- let result;
66
- const bufferType = buffer[0];
67
- if (bufferType === 60 || bufferType === 239) {
68
- result = parsePlist(buffer.toString());
69
- }
70
- else if (bufferType === 98) {
71
- result = parseBplist(buffer)[0];
72
- }
73
- else {
74
- throw new Error('Unknown plist buffer type.');
75
- }
76
- return result;
77
- }
78
- /**
79
- * parse provision
80
- * @param {Buffer} buffer // provision file's buffer
81
- */
82
- _parseProvision(buffer, parsePlist) {
83
- let info = {};
84
- if (buffer) {
85
- let content = buffer.toString('utf-8');
86
- const firstIndex = content.indexOf('<?xml');
87
- const endIndex = content.indexOf('</plist>');
88
- content = content.slice(firstIndex, endIndex + 8);
89
- if (content) {
90
- info = parsePlist(content);
91
- }
92
- }
93
- return info;
31
+ if (bufferType === 98) {
32
+ return parseBplist(buffer)[0];
94
33
  }
34
+ throw new Error('Unknown plist buffer type.');
95
35
  }
96
- exports.IpaParser = IpaParser;
@@ -5,37 +5,12 @@
5
5
  */
6
6
  export declare class ResourceFinder {
7
7
  private valueStringPool;
8
- private typeStringPool;
9
- private keyStringPool;
10
8
  private packageId;
11
9
  private responseMap;
12
- private entryMap;
13
- /**
14
- *
15
- * @param {Reader} bb
16
- * @return {Map<String, Set<String>>}
17
- */
10
+ /** Map of `@<RESOURCE ID>` to the values of that resource. */
18
11
  processResourceTable(resourceBuffer: Buffer): Record<string, any[]>;
19
- /**
20
- *
21
- * @param {Reader} bb
22
- */
23
12
  private processPackage;
24
- /**
25
- *
26
- * @param {Reader} bb
27
- */
28
13
  private processType;
29
- /**
30
- *
31
- * @param {Reader} bb
32
- * @return {Array}
33
- */
34
14
  private processStringPool;
35
- /**
36
- *
37
- * @param {Reader} bb
38
- */
39
- private processTypeSpec;
40
15
  private putIntoMap;
41
16
  }
@@ -45,6 +45,9 @@ class Reader {
45
45
  readInt() {
46
46
  return this.buffer.readInt32LE(this.advance(4));
47
47
  }
48
+ skip(len) {
49
+ this.advance(len);
50
+ }
48
51
  /** The next `len` bytes as a new reader (a view, not a copy). */
49
52
  readBytes(len) {
50
53
  const at = this.advance(len);
@@ -55,26 +58,18 @@ class Reader {
55
58
  function chunkAt(bb, pos, size) {
56
59
  return new Reader(bb.buffer.subarray(pos, pos + size));
57
60
  }
58
- const DEBUG = false;
59
61
  const RES_STRING_POOL_TYPE = 0x0001;
60
62
  const RES_TABLE_TYPE = 0x0002;
61
63
  const RES_TABLE_PACKAGE_TYPE = 0x0200;
62
64
  const RES_TABLE_TYPE_TYPE = 0x0201;
63
- const RES_TABLE_TYPE_SPEC_TYPE = 0x0202;
64
65
  const TYPE_REFERENCE = 0x01;
65
66
  const TYPE_STRING = 0x03;
67
+ const FLAG_COMPLEX = 0x0001;
66
68
  class ResourceFinder {
67
69
  valueStringPool = null;
68
- typeStringPool = null;
69
- keyStringPool = null;
70
70
  packageId = 0;
71
71
  responseMap = {};
72
- entryMap = {};
73
- /**
74
- *
75
- * @param {Reader} bb
76
- * @return {Map<String, Set<String>>}
77
- */
72
+ /** Map of `@<RESOURCE ID>` to the values of that resource. */
78
73
  processResourceTable(resourceBuffer) {
79
74
  const bb = new Reader(resourceBuffer);
80
75
  const type = bb.readShort();
@@ -93,12 +88,11 @@ class ResourceFinder {
93
88
  while (true) {
94
89
  let pos = 0;
95
90
  let t = 0;
96
- let _hs = 0;
97
91
  let s = 0;
98
92
  try {
99
93
  pos = bb.offset;
100
94
  t = bb.readShort();
101
- _hs = bb.readShort();
95
+ bb.readShort(); // header size
102
96
  s = bb.readInt();
103
97
  }
104
98
  catch (_e) {
@@ -106,17 +100,11 @@ class ResourceFinder {
106
100
  }
107
101
  if (t === RES_STRING_POOL_TYPE) {
108
102
  if (realStringPoolCount === 0) {
109
- if (DEBUG) {
110
- console.log('Processing the string pool ...');
111
- }
112
103
  this.valueStringPool = this.processStringPool(chunkAt(bb, pos, s));
113
104
  }
114
105
  realStringPoolCount++;
115
106
  }
116
107
  else if (t === RES_TABLE_PACKAGE_TYPE) {
117
- if (DEBUG) {
118
- console.log(`Processing the package ${realPackageCount} ...`);
119
- }
120
108
  this.processPackage(chunkAt(bb, pos, s));
121
109
  realPackageCount++;
122
110
  }
@@ -135,74 +123,34 @@ class ResourceFinder {
135
123
  }
136
124
  return this.responseMap;
137
125
  }
138
- /**
139
- *
140
- * @param {Reader} bb
141
- */
142
126
  processPackage(bb) {
143
- const type = bb.readShort();
127
+ bb.readShort(); // type
144
128
  const headerSize = bb.readShort();
145
- const size = bb.readInt();
146
- const id = bb.readInt();
147
- void type;
148
- void size;
149
- this.packageId = id;
150
- for (let i = 0; i < 256; ++i) {
151
- bb.readUint8();
152
- }
129
+ bb.readInt(); // size
130
+ this.packageId = bb.readInt();
131
+ bb.skip(256); // package name
153
132
  const typeStrings = bb.readInt();
154
- const lastPublicType = bb.readInt();
133
+ bb.readInt(); // last public type
155
134
  const keyStrings = bb.readInt();
156
- const lastPublicKey = bb.readInt();
157
- void lastPublicType;
158
- void lastPublicKey;
135
+ bb.readInt(); // last public key
159
136
  if (typeStrings !== headerSize) {
160
137
  throw new Error('TypeStrings must immediately following the package structure header.');
161
138
  }
162
- if (DEBUG) {
163
- console.log('Type strings:');
164
- }
165
- let lastPosition = bb.offset;
166
- bb.offset = typeStrings;
167
- const bbTypeStrings = bb.readBytes(bb.limit - bb.offset);
168
- bb.offset = lastPosition;
169
- this.typeStringPool = this.processStringPool(bbTypeStrings);
170
- if (DEBUG) {
171
- console.log('Key strings:');
172
- }
173
- bb.offset = keyStrings;
174
- const keyType = bb.readShort();
175
- const keyHeaderSize = bb.readShort();
176
- const keySize = bb.readInt();
177
- void keyType;
178
- void keyHeaderSize;
179
- lastPosition = bb.offset;
139
+ // the type and key string pools only name entries: skip both, and the
140
+ // type specs (only flags); types carry the values
180
141
  bb.offset = keyStrings;
181
- const bbKeyStrings = bb.readBytes(bb.limit - bb.offset);
182
- bb.offset = lastPosition;
183
- this.keyStringPool = this.processStringPool(bbKeyStrings);
184
- let typeSpecCount = 0;
185
- let typeCount = 0;
186
- bb.offset = keyStrings + keySize;
187
- let bb2;
142
+ bb.readShort(); // key pool type
143
+ bb.readShort(); // key pool header size
144
+ bb.offset = keyStrings + bb.readInt();
188
145
  while (true) {
189
146
  const pos = bb.offset;
190
147
  try {
191
148
  const t = bb.readShort();
192
- const hs = bb.readShort();
149
+ bb.readShort(); // header size
193
150
  const s = bb.readInt();
194
- void hs;
195
- if (t === RES_TABLE_TYPE_SPEC_TYPE) {
151
+ if (t === RES_TABLE_TYPE_TYPE) {
196
152
  bb.offset = pos;
197
- bb2 = bb.readBytes(s);
198
- this.processTypeSpec(bb2);
199
- typeSpecCount++;
200
- }
201
- else if (t === RES_TABLE_TYPE_TYPE) {
202
- bb.offset = pos;
203
- bb2 = bb.readBytes(s);
204
- this.processType(bb2);
205
- typeCount++;
153
+ this.processType(bb.readBytes(s));
206
154
  }
207
155
  if (s === 0) {
208
156
  break;
@@ -216,29 +164,16 @@ class ResourceFinder {
216
164
  break;
217
165
  }
218
166
  }
219
- void typeSpecCount;
220
- void typeCount;
221
167
  }
222
- /**
223
- *
224
- * @param {Reader} bb
225
- */
226
168
  processType(bb) {
227
- const type = bb.readShort();
169
+ bb.readShort(); // type
228
170
  const headerSize = bb.readShort();
229
- const size = bb.readInt();
171
+ bb.readInt(); // size
230
172
  const id = bb.readByte();
231
- const res0 = bb.readByte();
232
- const res1 = bb.readShort();
173
+ bb.skip(3); // res0, res1
233
174
  const entryCount = bb.readInt();
234
175
  const entriesStart = bb.readInt();
235
- void type;
236
- void size;
237
- void res0;
238
- void res1;
239
176
  const refKeys = {};
240
- const configSize = bb.readInt();
241
- void configSize;
242
177
  bb.offset = headerSize;
243
178
  if (headerSize + entryCount * 4 !== entriesStart) {
244
179
  throw new Error('HeaderSize, entryCount and entriesStart are not valid.');
@@ -251,73 +186,38 @@ class ResourceFinder {
251
186
  if (entryIndices[i] === -1)
252
187
  continue;
253
188
  const resourceId = (this.packageId << 24) | (id << 16) | i;
254
- let entrySize = 0;
255
189
  let entryFlag = 0;
256
- let entryKey = 0;
257
190
  try {
258
- entrySize = bb.readShort();
191
+ bb.readShort(); // entry size
259
192
  entryFlag = bb.readShort();
260
- entryKey = bb.readInt();
193
+ bb.readInt(); // key
261
194
  }
262
195
  catch (_e) {
263
196
  break;
264
197
  }
265
- void entrySize;
266
- const FLAG_COMPLEX = 0x0001;
267
198
  if ((entryFlag & FLAG_COMPLEX) === 0) {
268
- const valueSize = bb.readShort();
269
- const valueRes0 = bb.readByte();
270
- const valueDataType = bb.readByte();
199
+ bb.readShort(); // value size
200
+ bb.readUint8(); // res0
201
+ const valueDataType = bb.readUint8();
271
202
  const valueData = bb.readInt();
272
- void valueSize;
273
- void valueRes0;
274
203
  const idStr = Number(resourceId).toString(16);
275
- const keyStr = this.keyStringPool ? this.keyStringPool[entryKey] : '';
276
204
  let data = null;
277
- if (DEBUG) {
278
- console.log(`Entry 0x${idStr}, key: ${keyStr}, simple value type: `);
279
- }
280
- const key = Number.parseInt(idStr, 16);
281
- const entryArr = this.entryMap[key] ?? [];
282
- entryArr.push(keyStr);
283
- this.entryMap[key] = entryArr;
284
205
  if (valueDataType === TYPE_STRING) {
285
206
  data = this.valueStringPool ? this.valueStringPool[valueData] : null;
286
- if (DEBUG && this.valueStringPool) {
287
- console.log(`, data: ${this.valueStringPool[valueData]}`);
288
- }
289
207
  }
290
208
  else if (valueDataType === TYPE_REFERENCE) {
291
209
  refKeys[idStr] = valueData;
292
210
  }
293
211
  else {
294
212
  data = `${valueData}`;
295
- if (DEBUG) {
296
- console.log(`, data: ${valueData}`);
297
- }
298
213
  }
299
214
  this.putIntoMap(`@${idStr}`, data);
300
215
  }
301
216
  else {
302
- const entryParent = bb.readInt();
303
- const entryCountValue = bb.readInt();
304
- void entryParent;
305
- for (let j = 0; j < entryCountValue; ++j) {
306
- const refName = bb.readInt();
307
- const valueSize = bb.readShort();
308
- const valueRes0 = bb.readByte();
309
- const valueDataType = bb.readByte();
310
- const valueData = bb.readInt();
311
- void refName;
312
- void valueSize;
313
- void valueRes0;
314
- void valueDataType;
315
- void valueData;
316
- }
317
- if (DEBUG) {
318
- const keyStr = this.keyStringPool ? this.keyStringPool[entryKey] : '';
319
- console.log(`Entry 0x${Number(resourceId).toString(16)}, key: ${keyStr}, complex value, not printed.`);
320
- }
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);
321
221
  }
322
222
  }
323
223
  for (const refKey in refKeys) {
@@ -329,25 +229,15 @@ class ResourceFinder {
329
229
  }
330
230
  }
331
231
  }
332
- /**
333
- *
334
- * @param {Reader} bb
335
- * @return {Array}
336
- */
337
232
  processStringPool(bb) {
338
- const type = bb.readShort();
339
- const headerSize = bb.readShort();
340
- const size = bb.readInt();
233
+ bb.readShort(); // type
234
+ bb.readShort(); // header size
235
+ bb.readInt(); // size
341
236
  const stringCount = bb.readInt();
342
- const styleCount = bb.readInt();
237
+ bb.readInt(); // style count
343
238
  const flags = bb.readInt();
344
239
  const stringsStart = bb.readInt();
345
- const stylesStart = bb.readInt();
346
- void type;
347
- void headerSize;
348
- void size;
349
- void styleCount;
350
- void stylesStart;
240
+ bb.readInt(); // styles start
351
241
  const isUtf8 = (flags & 256) !== 0;
352
242
  const offsets = new Array(stringCount);
353
243
  for (let i = 0; i < stringCount; ++i) {
@@ -355,13 +245,12 @@ class ResourceFinder {
355
245
  }
356
246
  const strings = new Array(stringCount);
357
247
  for (let i = 0; i < stringCount; ++i) {
358
- const pos = stringsStart + offsets[i];
359
- bb.offset = pos;
248
+ bb.offset = stringsStart + offsets[i];
360
249
  strings[i] = '';
361
250
  if (isUtf8) {
362
- let u16len = bb.readUint8();
363
- if ((u16len & 0x80) !== 0) {
364
- u16len = ((u16len & 0x7f) << 8) + bb.readUint8();
251
+ // UTF-16 length, then UTF-8 byte length; each 1 or 2 bytes
252
+ if ((bb.readUint8() & 0x80) !== 0) {
253
+ bb.readUint8();
365
254
  }
366
255
  let u8len = bb.readUint8();
367
256
  if ((u8len & 0x80) !== 0) {
@@ -370,9 +259,6 @@ class ResourceFinder {
370
259
  if (u8len > 0) {
371
260
  strings[i] = bb.readBytes(u8len).buffer.toString('utf8');
372
261
  }
373
- else {
374
- strings[i] = '';
375
- }
376
262
  }
377
263
  else {
378
264
  let u16len = bb.readUint16();
@@ -383,37 +269,9 @@ class ResourceFinder {
383
269
  strings[i] = bb.readBytes(u16len * 2).buffer.toString('utf16le');
384
270
  }
385
271
  }
386
- if (DEBUG) {
387
- console.log('Parsed value: {0}', strings[i]);
388
- }
389
272
  }
390
273
  return strings;
391
274
  }
392
- /**
393
- *
394
- * @param {Reader} bb
395
- */
396
- processTypeSpec(bb) {
397
- const type = bb.readShort();
398
- const headerSize = bb.readShort();
399
- const size = bb.readInt();
400
- const id = bb.readByte();
401
- const res0 = bb.readByte();
402
- const res1 = bb.readShort();
403
- const entryCount = bb.readInt();
404
- void type;
405
- void headerSize;
406
- void size;
407
- void res0;
408
- void res1;
409
- if (DEBUG && this.typeStringPool) {
410
- console.log(`Processing type spec ${this.typeStringPool[id - 1]}...`);
411
- }
412
- const flags = new Array(entryCount);
413
- for (let i = 0; i < entryCount; ++i) {
414
- flags[i] = bb.readInt();
415
- }
416
- }
417
275
  putIntoMap(resId, value) {
418
276
  const key = resId.toUpperCase();
419
277
  if (this.responseMap[key] == null) {