react-native-update-cli 2.18.0 → 2.20.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/lib/api.d.ts +1 -1
- package/lib/api.js +143 -134
- package/lib/app.d.ts +2 -2
- package/lib/app.js +60 -107
- package/lib/bin.js +38 -35
- package/lib/bundle-pack.js +57 -77
- package/lib/bundle-runner.js +249 -312
- package/lib/bundle.js +71 -89
- package/lib/diff.js +190 -240
- package/lib/exports.js +14 -37
- package/lib/index.js +16 -17
- package/lib/install.js +24 -37
- package/lib/locales/en.js +3 -11
- package/lib/locales/zh.js +3 -11
- package/lib/native-package.d.ts +17 -0
- package/lib/native-package.js +232 -0
- package/lib/package.js +180 -225
- package/lib/provider.js +85 -107
- package/lib/types.js +1 -3
- package/lib/user.d.ts +1 -1
- package/lib/user.js +26 -39
- package/lib/utils/add-gitignore.js +16 -29
- package/lib/utils/app-info-parser/aab.js +133 -157
- package/lib/utils/app-info-parser/apk.js +42 -39
- package/lib/utils/app-info-parser/app.js +5 -11
- package/lib/utils/app-info-parser/index.js +21 -31
- package/lib/utils/app-info-parser/ipa.js +35 -35
- package/lib/utils/app-info-parser/resource-finder.js +84 -71
- package/lib/utils/app-info-parser/utils.js +52 -77
- package/lib/utils/app-info-parser/xml-parser/binary.js +82 -90
- package/lib/utils/app-info-parser/xml-parser/manifest.js +88 -98
- package/lib/utils/app-info-parser/zip.js +43 -51
- package/lib/utils/check-lockfile.js +28 -37
- package/lib/utils/check-plugin.js +16 -32
- package/lib/utils/command-result.js +7 -20
- package/lib/utils/constants.js +23 -63
- package/lib/utils/dep-versions.js +21 -27
- package/lib/utils/git.js +20 -64
- package/lib/utils/hbcTransform.js +133 -246
- package/lib/utils/http-helper.js +33 -44
- package/lib/utils/i18n.js +17 -26
- package/lib/utils/index.js +137 -179
- package/lib/utils/latest-version/index.js +128 -137
- package/lib/utils/options.js +13 -34
- package/lib/utils/plugin-config.js +43 -56
- package/lib/utils/runtime.js +50 -108
- package/lib/utils/zip-entries.js +70 -97
- package/lib/utils/zip-options.js +80 -181
- package/lib/versions.js +231 -265
- package/package.json +19 -21
- package/src/api.ts +47 -3
- package/src/diff.ts +12 -20
- package/src/native-package.ts +248 -0
- package/src/package.ts +29 -19
- package/src/user.ts +1 -1
- package/src/versions.ts +1 -1
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "BinaryXmlParser", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return BinaryXmlParser;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BinaryXmlParser = void 0;
|
|
11
4
|
// From https://github.com/openstf/adbkit-apkreader
|
|
12
5
|
const NodeType = {
|
|
13
6
|
ELEMENT_NODE: 1,
|
|
14
7
|
ATTRIBUTE_NODE: 2,
|
|
15
|
-
CDATA_SECTION_NODE: 4
|
|
8
|
+
CDATA_SECTION_NODE: 4,
|
|
16
9
|
};
|
|
17
10
|
const ChunkType = {
|
|
18
11
|
NULL: 0x0000,
|
|
@@ -29,11 +22,11 @@ const ChunkType = {
|
|
|
29
22
|
XML_RESOURCE_MAP: 0x0180,
|
|
30
23
|
TABLE_PACKAGE: 0x0200,
|
|
31
24
|
TABLE_TYPE: 0x0201,
|
|
32
|
-
TABLE_TYPE_SPEC: 0x0202
|
|
25
|
+
TABLE_TYPE_SPEC: 0x0202,
|
|
33
26
|
};
|
|
34
27
|
const StringFlags = {
|
|
35
28
|
SORTED: 1 << 0,
|
|
36
|
-
UTF8: 1 << 8
|
|
29
|
+
UTF8: 1 << 8,
|
|
37
30
|
};
|
|
38
31
|
// Taken from android.util.TypedValue
|
|
39
32
|
const TypedValue = {
|
|
@@ -74,9 +67,27 @@ const TypedValue = {
|
|
|
74
67
|
TYPE_LAST_INT: 0x0000001f,
|
|
75
68
|
TYPE_NULL: 0x00000000,
|
|
76
69
|
TYPE_REFERENCE: 0x00000001,
|
|
77
|
-
TYPE_STRING: 0x00000003
|
|
70
|
+
TYPE_STRING: 0x00000003,
|
|
78
71
|
};
|
|
79
72
|
class BinaryXmlParser {
|
|
73
|
+
buffer;
|
|
74
|
+
cursor = 0;
|
|
75
|
+
strings = [];
|
|
76
|
+
resources = [];
|
|
77
|
+
document = null;
|
|
78
|
+
parent = null;
|
|
79
|
+
stack = [];
|
|
80
|
+
debug;
|
|
81
|
+
constructor(buffer, options = {}) {
|
|
82
|
+
this.buffer = buffer;
|
|
83
|
+
this.cursor = 0;
|
|
84
|
+
this.strings = [];
|
|
85
|
+
this.resources = [];
|
|
86
|
+
this.document = null;
|
|
87
|
+
this.parent = null;
|
|
88
|
+
this.stack = [];
|
|
89
|
+
this.debug = options.debug || false;
|
|
90
|
+
}
|
|
80
91
|
readU8() {
|
|
81
92
|
this.debug && console.group('readU8');
|
|
82
93
|
this.debug && console.debug('cursor:', this.cursor);
|
|
@@ -140,13 +151,13 @@ class BinaryXmlParser {
|
|
|
140
151
|
const dimension = {
|
|
141
152
|
value: null,
|
|
142
153
|
unit: null,
|
|
143
|
-
rawUnit: null
|
|
154
|
+
rawUnit: null,
|
|
144
155
|
};
|
|
145
156
|
const value = this.readU32();
|
|
146
157
|
const unit = value & 0xff;
|
|
147
158
|
dimension.value = value >> 8;
|
|
148
159
|
dimension.rawUnit = unit;
|
|
149
|
-
switch(unit){
|
|
160
|
+
switch (unit) {
|
|
150
161
|
case TypedValue.COMPLEX_UNIT_MM:
|
|
151
162
|
dimension.unit = 'mm';
|
|
152
163
|
break;
|
|
@@ -174,13 +185,13 @@ class BinaryXmlParser {
|
|
|
174
185
|
const fraction = {
|
|
175
186
|
value: null,
|
|
176
187
|
type: null,
|
|
177
|
-
rawType: null
|
|
188
|
+
rawType: null,
|
|
178
189
|
};
|
|
179
190
|
const value = this.readU32();
|
|
180
191
|
const type = value & 0xf;
|
|
181
192
|
fraction.value = this.convertIntToFloat(value >> 4);
|
|
182
193
|
fraction.rawType = type;
|
|
183
|
-
switch(type){
|
|
194
|
+
switch (type) {
|
|
184
195
|
case TypedValue.COMPLEX_UNIT_FRACTION:
|
|
185
196
|
fraction.type = '%';
|
|
186
197
|
break;
|
|
@@ -208,7 +219,7 @@ class BinaryXmlParser {
|
|
|
208
219
|
const typedValue = {
|
|
209
220
|
value: null,
|
|
210
221
|
type: null,
|
|
211
|
-
rawType: null
|
|
222
|
+
rawType: null,
|
|
212
223
|
};
|
|
213
224
|
const start = this.cursor;
|
|
214
225
|
let size = this.readU16();
|
|
@@ -218,7 +229,7 @@ class BinaryXmlParser {
|
|
|
218
229
|
size = 8;
|
|
219
230
|
}
|
|
220
231
|
typedValue.rawType = dataType;
|
|
221
|
-
switch(dataType){
|
|
232
|
+
switch (dataType) {
|
|
222
233
|
case TypedValue.TYPE_INT_DEC:
|
|
223
234
|
typedValue.value = this.readS32();
|
|
224
235
|
typedValue.type = 'int_dec';
|
|
@@ -227,20 +238,18 @@ class BinaryXmlParser {
|
|
|
227
238
|
typedValue.value = this.readS32();
|
|
228
239
|
typedValue.type = 'int_hex';
|
|
229
240
|
break;
|
|
230
|
-
case TypedValue.TYPE_STRING:
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
{
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
break;
|
|
243
|
-
}
|
|
241
|
+
case TypedValue.TYPE_STRING: {
|
|
242
|
+
const ref = this.readS32();
|
|
243
|
+
typedValue.value = ref > 0 ? this.strings[ref] : '';
|
|
244
|
+
typedValue.type = 'string';
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
case TypedValue.TYPE_REFERENCE: {
|
|
248
|
+
const id = this.readU32();
|
|
249
|
+
typedValue.value = `resourceId:0x${id.toString(16)}`;
|
|
250
|
+
typedValue.type = 'reference';
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
244
253
|
case TypedValue.TYPE_INT_BOOLEAN:
|
|
245
254
|
typedValue.value = this.readS32() !== 0;
|
|
246
255
|
typedValue.type = 'boolean';
|
|
@@ -274,13 +283,12 @@ class BinaryXmlParser {
|
|
|
274
283
|
typedValue.value = this.readFraction();
|
|
275
284
|
typedValue.type = 'fraction';
|
|
276
285
|
break;
|
|
277
|
-
default:
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
286
|
+
default: {
|
|
287
|
+
const type = dataType.toString(16);
|
|
288
|
+
console.debug(`Not sure what to do with typed value of type 0x${type}, falling back to reading an uint32.`);
|
|
289
|
+
typedValue.value = this.readU32();
|
|
290
|
+
typedValue.type = 'unknown';
|
|
291
|
+
}
|
|
284
292
|
}
|
|
285
293
|
const end = start + size;
|
|
286
294
|
if (this.cursor !== end) {
|
|
@@ -302,29 +310,27 @@ and is supposed to end at offset ${end}. Ignoring the rest of the value.`);
|
|
|
302
310
|
}
|
|
303
311
|
readString(encoding) {
|
|
304
312
|
this.debug && console.group('readString', encoding);
|
|
305
|
-
switch(encoding){
|
|
306
|
-
case 'utf-8':
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
return value;
|
|
327
|
-
}
|
|
313
|
+
switch (encoding) {
|
|
314
|
+
case 'utf-8': {
|
|
315
|
+
const stringLength = this.readLength8();
|
|
316
|
+
this.debug && console.debug('stringLength:', stringLength);
|
|
317
|
+
const byteLength = this.readLength8();
|
|
318
|
+
this.debug && console.debug('byteLength:', byteLength);
|
|
319
|
+
const value = this.buffer.toString(encoding, this.cursor, (this.cursor += byteLength));
|
|
320
|
+
this.debug && console.debug('value:', value);
|
|
321
|
+
this.debug && console.groupEnd();
|
|
322
|
+
return value;
|
|
323
|
+
}
|
|
324
|
+
case 'ucs2': {
|
|
325
|
+
const stringLength = this.readLength16();
|
|
326
|
+
this.debug && console.debug('stringLength:', stringLength);
|
|
327
|
+
const byteLength = stringLength * 2;
|
|
328
|
+
this.debug && console.debug('byteLength:', byteLength);
|
|
329
|
+
const value = this.buffer.toString(encoding, this.cursor, (this.cursor += byteLength));
|
|
330
|
+
this.debug && console.debug('value:', value);
|
|
331
|
+
this.debug && console.groupEnd();
|
|
332
|
+
return value;
|
|
333
|
+
}
|
|
328
334
|
default:
|
|
329
335
|
throw new Error(`Unsupported encoding '${encoding}'`);
|
|
330
336
|
}
|
|
@@ -335,7 +341,7 @@ and is supposed to end at offset ${end}. Ignoring the rest of the value.`);
|
|
|
335
341
|
startOffset: this.cursor,
|
|
336
342
|
chunkType: this.readU16(),
|
|
337
343
|
headerSize: this.readU16(),
|
|
338
|
-
chunkSize: this.readU32()
|
|
344
|
+
chunkSize: this.readU32(),
|
|
339
345
|
};
|
|
340
346
|
this.debug && console.debug('startOffset:', header.startOffset);
|
|
341
347
|
this.debug && console.debug('chunkType:', header.chunkType);
|
|
@@ -360,7 +366,7 @@ and is supposed to end at offset ${end}. Ignoring the rest of the value.`);
|
|
|
360
366
|
throw new Error('Invalid string pool header');
|
|
361
367
|
}
|
|
362
368
|
const offsets = [];
|
|
363
|
-
for(let i = 0, l = header.stringCount; i < l; ++i){
|
|
369
|
+
for (let i = 0, l = header.stringCount; i < l; ++i) {
|
|
364
370
|
this.debug && console.debug('offset:', i);
|
|
365
371
|
offsets.push(this.readU32());
|
|
366
372
|
}
|
|
@@ -370,7 +376,7 @@ and is supposed to end at offset ${end}. Ignoring the rest of the value.`);
|
|
|
370
376
|
this.debug && console.debug('encoding:', encoding);
|
|
371
377
|
const stringsStart = header.startOffset + header.stringsStart;
|
|
372
378
|
this.cursor = stringsStart;
|
|
373
|
-
for(let i = 0, l = header.stringCount; i < l; ++i){
|
|
379
|
+
for (let i = 0, l = header.stringCount; i < l; ++i) {
|
|
374
380
|
this.debug && console.debug('string:', i);
|
|
375
381
|
this.debug && console.debug('offset:', offsets[i]);
|
|
376
382
|
this.cursor = stringsStart + offsets[i];
|
|
@@ -383,7 +389,7 @@ and is supposed to end at offset ${end}. Ignoring the rest of the value.`);
|
|
|
383
389
|
readResourceMap(header) {
|
|
384
390
|
this.debug && console.group('readResourceMap');
|
|
385
391
|
const count = Math.floor((header.chunkSize - header.headerSize) / 4);
|
|
386
|
-
for(let i = 0; i < count; ++i){
|
|
392
|
+
for (let i = 0; i < count; ++i) {
|
|
387
393
|
this.resources.push(this.readU32());
|
|
388
394
|
}
|
|
389
395
|
this.debug && console.groupEnd();
|
|
@@ -414,7 +420,7 @@ and is supposed to end at offset ${end}. Ignoring the rest of the value.`);
|
|
|
414
420
|
nodeType: NodeType.ELEMENT_NODE,
|
|
415
421
|
nodeName: null,
|
|
416
422
|
attributes: [],
|
|
417
|
-
childNodes: []
|
|
423
|
+
childNodes: [],
|
|
418
424
|
};
|
|
419
425
|
/* const line = */ this.readU32();
|
|
420
426
|
/* const commentRef = */ this.readU32();
|
|
@@ -430,13 +436,14 @@ and is supposed to end at offset ${end}. Ignoring the rest of the value.`);
|
|
|
430
436
|
/* const idIndex = */ this.readU16();
|
|
431
437
|
/* const classIndex = */ this.readU16();
|
|
432
438
|
/* const styleIndex = */ this.readU16();
|
|
433
|
-
for(let i = 0; i < attrCount; ++i){
|
|
439
|
+
for (let i = 0; i < attrCount; ++i) {
|
|
434
440
|
node.attributes.push(this.readXmlAttribute());
|
|
435
441
|
}
|
|
436
442
|
if (this.document) {
|
|
437
443
|
this.parent.childNodes.push(node);
|
|
438
444
|
this.parent = node;
|
|
439
|
-
}
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
440
447
|
this.document = this.parent = node;
|
|
441
448
|
}
|
|
442
449
|
this.stack.push(node);
|
|
@@ -451,7 +458,7 @@ and is supposed to end at offset ${end}. Ignoring the rest of the value.`);
|
|
|
451
458
|
nodeName: null,
|
|
452
459
|
name: null,
|
|
453
460
|
value: null,
|
|
454
|
-
typedValue: null
|
|
461
|
+
typedValue: null,
|
|
455
462
|
};
|
|
456
463
|
const nsRef = this.readS32();
|
|
457
464
|
const nameRef = this.readS32();
|
|
@@ -490,7 +497,7 @@ and is supposed to end at offset ${end}. Ignoring the rest of the value.`);
|
|
|
490
497
|
nodeType: NodeType.CDATA_SECTION_NODE,
|
|
491
498
|
nodeName: '#cdata',
|
|
492
499
|
data: null,
|
|
493
|
-
typedValue: null
|
|
500
|
+
typedValue: null,
|
|
494
501
|
};
|
|
495
502
|
/* const line = */ this.readU32();
|
|
496
503
|
/* const commentRef = */ this.readU32();
|
|
@@ -515,11 +522,11 @@ and is supposed to end at offset ${end}. Ignoring the rest of the value.`);
|
|
|
515
522
|
if (xmlHeader.chunkType !== ChunkType.XML) {
|
|
516
523
|
throw new Error('Invalid XML header');
|
|
517
524
|
}
|
|
518
|
-
while(this.cursor < this.buffer.length){
|
|
525
|
+
while (this.cursor < this.buffer.length) {
|
|
519
526
|
this.debug && console.group('chunk');
|
|
520
527
|
const start = this.cursor;
|
|
521
528
|
const header = this.readChunkHeader();
|
|
522
|
-
switch(header.chunkType){
|
|
529
|
+
switch (header.chunkType) {
|
|
523
530
|
case ChunkType.STRING_POOL:
|
|
524
531
|
this.readStringPool(header);
|
|
525
532
|
break;
|
|
@@ -561,20 +568,5 @@ supposed to end at offset ${end}. Ignoring the rest of the chunk.`);
|
|
|
561
568
|
this.debug && console.groupEnd();
|
|
562
569
|
return this.document;
|
|
563
570
|
}
|
|
564
|
-
constructor(buffer, options = {}){
|
|
565
|
-
this.cursor = 0;
|
|
566
|
-
this.strings = [];
|
|
567
|
-
this.resources = [];
|
|
568
|
-
this.document = null;
|
|
569
|
-
this.parent = null;
|
|
570
|
-
this.stack = [];
|
|
571
|
-
this.buffer = buffer;
|
|
572
|
-
this.cursor = 0;
|
|
573
|
-
this.strings = [];
|
|
574
|
-
this.resources = [];
|
|
575
|
-
this.document = null;
|
|
576
|
-
this.parent = null;
|
|
577
|
-
this.stack = [];
|
|
578
|
-
this.debug = options.debug || false;
|
|
579
|
-
}
|
|
580
571
|
}
|
|
572
|
+
exports.BinaryXmlParser = BinaryXmlParser;
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
// From https://github.com/openstf/adbkit-apkreader
|
|
2
1
|
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function() {
|
|
9
|
-
return ManifestParser;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
const _binary = require("./binary");
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManifestParser = void 0;
|
|
4
|
+
// From https://github.com/openstf/adbkit-apkreader
|
|
5
|
+
const binary_1 = require("./binary");
|
|
13
6
|
const INTENT_MAIN = 'android.intent.action.MAIN';
|
|
14
7
|
const CATEGORY_LAUNCHER = 'android.intent.category.LAUNCHER';
|
|
15
8
|
class ManifestParser {
|
|
9
|
+
buffer;
|
|
10
|
+
xmlParser;
|
|
11
|
+
constructor(buffer, options = {}) {
|
|
12
|
+
this.buffer = buffer;
|
|
13
|
+
this.xmlParser = new binary_1.BinaryXmlParser(this.buffer, options);
|
|
14
|
+
}
|
|
16
15
|
collapseAttributes(element) {
|
|
17
16
|
const collapsed = Object.create(null);
|
|
18
17
|
const attributes = element.attributes;
|
|
19
|
-
for(let i = 0, len = attributes.length; i < len; i++){
|
|
18
|
+
for (let i = 0, len = attributes.length; i < len; i++) {
|
|
20
19
|
const attr = attributes[i];
|
|
21
20
|
collapsed[attr.name] = attr.typedValue.value;
|
|
22
21
|
}
|
|
@@ -25,30 +24,29 @@ class ManifestParser {
|
|
|
25
24
|
parseIntents(element, target) {
|
|
26
25
|
target.intentFilters = [];
|
|
27
26
|
target.metaData = [];
|
|
28
|
-
for (const child of element.childNodes){
|
|
29
|
-
switch(child.nodeName){
|
|
30
|
-
case 'intent-filter':
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
27
|
+
for (const child of element.childNodes) {
|
|
28
|
+
switch (child.nodeName) {
|
|
29
|
+
case 'intent-filter': {
|
|
30
|
+
const intentFilter = this.collapseAttributes(child);
|
|
31
|
+
intentFilter.actions = [];
|
|
32
|
+
intentFilter.categories = [];
|
|
33
|
+
intentFilter.data = [];
|
|
34
|
+
for (const item of child.childNodes) {
|
|
35
|
+
switch (item.nodeName) {
|
|
36
|
+
case 'action':
|
|
37
|
+
intentFilter.actions.push(this.collapseAttributes(item));
|
|
38
|
+
break;
|
|
39
|
+
case 'category':
|
|
40
|
+
intentFilter.categories.push(this.collapseAttributes(item));
|
|
41
|
+
break;
|
|
42
|
+
case 'data':
|
|
43
|
+
intentFilter.data.push(this.collapseAttributes(item));
|
|
44
|
+
break;
|
|
48
45
|
}
|
|
49
|
-
target.intentFilters.push(intentFilter);
|
|
50
|
-
break;
|
|
51
46
|
}
|
|
47
|
+
target.intentFilters.push(intentFilter);
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
52
50
|
case 'meta-data':
|
|
53
51
|
target.metaData.push(this.collapseAttributes(child));
|
|
54
52
|
break;
|
|
@@ -65,64 +63,59 @@ class ManifestParser {
|
|
|
65
63
|
app.providers = [];
|
|
66
64
|
app.usesLibraries = [];
|
|
67
65
|
app.metaData = [];
|
|
68
|
-
for (const child of element.childNodes){
|
|
69
|
-
switch(child.nodeName){
|
|
70
|
-
case 'activity':
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
app.launcherActivities.push(activity);
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
66
|
+
for (const child of element.childNodes) {
|
|
67
|
+
switch (child.nodeName) {
|
|
68
|
+
case 'activity': {
|
|
69
|
+
const activity = this.collapseAttributes(child);
|
|
70
|
+
this.parseIntents(child, activity);
|
|
71
|
+
app.activities.push(activity);
|
|
72
|
+
if (this.isLauncherActivity(activity)) {
|
|
73
|
+
app.launcherActivities.push(activity);
|
|
79
74
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
case 'service':
|
|
91
|
-
{
|
|
92
|
-
const service = this.collapseAttributes(child);
|
|
93
|
-
this.parseIntents(child, service);
|
|
94
|
-
app.services.push(service);
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
case 'receiver':
|
|
98
|
-
{
|
|
99
|
-
const receiver = this.collapseAttributes(child);
|
|
100
|
-
this.parseIntents(child, receiver);
|
|
101
|
-
app.receivers.push(receiver);
|
|
102
|
-
break;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case 'activity-alias': {
|
|
78
|
+
const activityAlias = this.collapseAttributes(child);
|
|
79
|
+
this.parseIntents(child, activityAlias);
|
|
80
|
+
app.activityAliases.push(activityAlias);
|
|
81
|
+
if (this.isLauncherActivity(activityAlias)) {
|
|
82
|
+
app.launcherActivities.push(activityAlias);
|
|
103
83
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
case 'service': {
|
|
87
|
+
const service = this.collapseAttributes(child);
|
|
88
|
+
this.parseIntents(child, service);
|
|
89
|
+
app.services.push(service);
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case 'receiver': {
|
|
93
|
+
const receiver = this.collapseAttributes(child);
|
|
94
|
+
this.parseIntents(child, receiver);
|
|
95
|
+
app.receivers.push(receiver);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case 'provider': {
|
|
99
|
+
const provider = this.collapseAttributes(child);
|
|
100
|
+
provider.grantUriPermissions = [];
|
|
101
|
+
provider.metaData = [];
|
|
102
|
+
provider.pathPermissions = [];
|
|
103
|
+
for (const item of child.childNodes) {
|
|
104
|
+
switch (item.nodeName) {
|
|
105
|
+
case 'grant-uri-permission':
|
|
106
|
+
provider.grantUriPermissions.push(this.collapseAttributes(item));
|
|
107
|
+
break;
|
|
108
|
+
case 'meta-data':
|
|
109
|
+
provider.metaData.push(this.collapseAttributes(item));
|
|
110
|
+
break;
|
|
111
|
+
case 'path-permission':
|
|
112
|
+
provider.pathPermissions.push(this.collapseAttributes(item));
|
|
113
|
+
break;
|
|
122
114
|
}
|
|
123
|
-
app.providers.push(provider);
|
|
124
|
-
break;
|
|
125
115
|
}
|
|
116
|
+
app.providers.push(provider);
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
126
119
|
case 'uses-library':
|
|
127
120
|
app.usesLibraries.push(this.collapseAttributes(child));
|
|
128
121
|
break;
|
|
@@ -134,12 +127,12 @@ class ManifestParser {
|
|
|
134
127
|
return app;
|
|
135
128
|
}
|
|
136
129
|
isLauncherActivity(activity) {
|
|
137
|
-
return activity.intentFilters.some((filter)=>{
|
|
138
|
-
const hasMain = filter.actions.some((action)=>action.name === INTENT_MAIN);
|
|
130
|
+
return activity.intentFilters.some((filter) => {
|
|
131
|
+
const hasMain = filter.actions.some((action) => action.name === INTENT_MAIN);
|
|
139
132
|
if (!hasMain) {
|
|
140
133
|
return false;
|
|
141
134
|
}
|
|
142
|
-
return filter.categories.some((category)=>category.name === CATEGORY_LAUNCHER);
|
|
135
|
+
return filter.categories.some((category) => category.name === CATEGORY_LAUNCHER);
|
|
143
136
|
});
|
|
144
137
|
}
|
|
145
138
|
parse() {
|
|
@@ -158,8 +151,8 @@ class ManifestParser {
|
|
|
158
151
|
manifest.compatibleScreens = [];
|
|
159
152
|
manifest.supportsGlTextures = [];
|
|
160
153
|
manifest.application = Object.create(null);
|
|
161
|
-
for (const element of document.childNodes){
|
|
162
|
-
switch(element.nodeName){
|
|
154
|
+
for (const element of document.childNodes) {
|
|
155
|
+
switch (element.nodeName) {
|
|
163
156
|
case 'uses-permission':
|
|
164
157
|
manifest.usesPermissions.push(this.collapseAttributes(element));
|
|
165
158
|
break;
|
|
@@ -191,7 +184,7 @@ class ManifestParser {
|
|
|
191
184
|
manifest.supportsScreens = this.collapseAttributes(element);
|
|
192
185
|
break;
|
|
193
186
|
case 'compatible-screens':
|
|
194
|
-
for (const screen of element.childNodes){
|
|
187
|
+
for (const screen of element.childNodes) {
|
|
195
188
|
manifest.compatibleScreens.push(this.collapseAttributes(screen));
|
|
196
189
|
}
|
|
197
190
|
break;
|
|
@@ -205,8 +198,5 @@ class ManifestParser {
|
|
|
205
198
|
}
|
|
206
199
|
return manifest;
|
|
207
200
|
}
|
|
208
|
-
constructor(buffer, options = {}){
|
|
209
|
-
this.buffer = buffer;
|
|
210
|
-
this.xmlParser = new _binary.BinaryXmlParser(this.buffer, options);
|
|
211
|
-
}
|
|
212
201
|
}
|
|
202
|
+
exports.ManifestParser = ManifestParser;
|