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.
Files changed (85) hide show
  1. package/lib/account.js +2 -4
  2. package/lib/api.d.ts +1 -1
  3. package/lib/api.js +35 -73
  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 +26 -60
  9. package/lib/bundle-runner.js +89 -119
  10. package/lib/bundle.js +18 -26
  11. package/lib/diff.js +43 -133
  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 +27 -99
  17. package/lib/package.d.ts +6 -1
  18. package/lib/package.js +56 -108
  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 +89 -226
  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 -34
  29. package/lib/utils/app-info-parser/resource-finder.js +95 -234
  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 +18 -0
  40. package/lib/utils/fs-helpers.js +84 -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 +136 -196
  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/runtime.d.ts +1 -1
  63. package/lib/utils/runtime.js +2 -10
  64. package/lib/utils/upload-request.d.ts +33 -0
  65. package/lib/utils/upload-request.js +120 -0
  66. package/lib/utils/zip-entries.d.ts +23 -0
  67. package/lib/utils/zip-entries.js +130 -139
  68. package/lib/utils/zip-options.js +29 -56
  69. package/lib/utils/zip-range.js +29 -69
  70. package/lib/utils/zip-raw-writer.js +6 -5
  71. package/lib/versions.d.ts +5 -0
  72. package/lib/versions.js +86 -153
  73. package/package.json +1 -9
  74. package/lib/utils/app-info-parser/app.d.ts +0 -4
  75. package/lib/utils/app-info-parser/app.js +0 -10
  76. package/lib/utils/app-info-parser/index.d.ts +0 -16
  77. package/lib/utils/app-info-parser/index.js +0 -46
  78. package/lib/utils/app-info-parser/utils.d.ts +0 -31
  79. package/lib/utils/app-info-parser/utils.js +0 -135
  80. package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +0 -10
  81. package/lib/utils/app-info-parser/xml-parser/manifest.js +0 -202
  82. package/lib/utils/latest-version/index.d.ts +0 -149
  83. package/lib/utils/latest-version/index.js +0 -326
  84. package/lib/utils/plugin-config.d.ts +0 -9
  85. package/lib/utils/plugin-config.js +0 -61
@@ -1,251 +1,114 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
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
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
38
5
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.AabParser = void 0;
6
+ exports.extractApk = extractApk;
40
7
  const child_process_1 = require("child_process");
41
- const fs = __importStar(require("fs-extra"));
8
+ const fs_1 = __importDefault(require("fs"));
42
9
  const os_1 = __importDefault(require("os"));
43
10
  const path_1 = __importDefault(require("path"));
44
- const yauzl_1 = require("yauzl");
11
+ const fs_helpers_1 = require("../fs-helpers");
45
12
  const i18n_1 = require("../i18n");
46
- const resource_finder_1 = require("./resource-finder");
47
- const utils_1 = require("./utils");
48
- const manifest_1 = require("./xml-parser/manifest");
49
- const zip_1 = require("./zip");
50
- class AabParser extends zip_1.Zip {
51
- async extractApk(outputPath, { includeAllSplits, splits, }) {
52
- const normalizedSplits = Array.isArray(splits)
53
- ? splits.map((item) => item.trim()).filter(Boolean)
54
- : [];
55
- const modules = includeAllSplits
56
- ? null
57
- : Array.from(new Set(['base', ...normalizedSplits]));
58
- const modulesArgs = modules ? [`--modules=${modules.join(',')}`] : [];
59
- const runCommand = (command, args, options = {}) => new Promise((resolve, reject) => {
60
- const inheritStdio = options.stdio === 'inherit';
61
- const child = (0, child_process_1.spawn)(command, args, {
62
- stdio: inheritStdio ? 'inherit' : ['ignore', 'pipe', 'pipe'],
63
- env: options.env,
13
+ const zip_entries_1 = require("../zip-entries");
14
+ /** Build a universal APK from an .aab with bundletool (or npx node-bundletool). */
15
+ async function extractApk(aabPath, outputPath, { includeAllSplits, splits, }) {
16
+ const bundlePath = path_1.default.resolve(aabPath);
17
+ const normalizedSplits = Array.isArray(splits)
18
+ ? splits.map((item) => item.trim()).filter(Boolean)
19
+ : [];
20
+ const modules = includeAllSplits
21
+ ? null
22
+ : Array.from(new Set(['base', ...normalizedSplits]));
23
+ const modulesArgs = modules ? [`--modules=${modules.join(',')}`] : [];
24
+ const runCommand = (command, args, options = {}) => new Promise((resolve, reject) => {
25
+ const inheritStdio = options.stdio === 'inherit';
26
+ const child = (0, child_process_1.spawn)(command, args, {
27
+ stdio: inheritStdio ? 'inherit' : ['ignore', 'pipe', 'pipe'],
28
+ env: options.env,
29
+ });
30
+ let stderr = '';
31
+ if (!inheritStdio) {
32
+ child.stderr?.on('data', (chunk) => {
33
+ stderr += chunk.toString();
64
34
  });
65
- let stderr = '';
66
- if (!inheritStdio) {
67
- child.stderr?.on('data', (chunk) => {
68
- stderr += chunk.toString();
69
- });
35
+ }
36
+ child.on('error', reject);
37
+ child.on('close', (code) => {
38
+ if (code === 0) {
39
+ resolve();
40
+ return;
70
41
  }
71
- child.on('error', reject);
72
- child.on('close', (code) => {
73
- if (code === 0) {
74
- resolve();
75
- return;
76
- }
77
- reject(new Error(stderr.trim() || `Command failed: ${command} (code ${code})`));
78
- });
42
+ reject(new Error(stderr.trim() || `Command failed: ${command} (code ${code})`));
79
43
  });
80
- // Create a temp file for the .apks output
81
- const tempDir = await fs.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'bundletool-'));
82
- const tempApksPath = path_1.default.join(tempDir, 'output.apks');
83
- const needsNpxDownload = async () => {
84
- try {
85
- await runCommand('npx', [
86
- '--no-install',
87
- 'node-bundletool',
88
- '--version',
89
- ]);
90
- return false;
91
- }
92
- catch {
93
- return true;
94
- }
95
- };
44
+ });
45
+ // Create a temp file for the .apks output
46
+ const tempDir = await fs_1.default.promises.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'bundletool-'));
47
+ const tempApksPath = path_1.default.join(tempDir, 'output.apks');
48
+ const needsNpxDownload = async () => {
96
49
  try {
97
- // 1. Build APKS (universal mode)
98
- // We assume bundletool is in the path.
99
- // User might need keystore to sign it properly but for simple extraction we stick to default debug key if possible or unsigned?
100
- // actually bundletool build-apks signs with debug key by default if no keystore provided.
101
- try {
102
- await runCommand('bundletool', [
103
- 'build-apks',
104
- '--mode=universal',
105
- `--bundle=${this.file}`,
106
- `--output=${tempApksPath}`,
107
- '--overwrite',
108
- ...modulesArgs,
109
- ]);
110
- }
111
- catch (e) {
112
- // Only fall back when bundletool itself is missing from PATH (spawn
113
- // ENOENT). Any other failure (corrupt AAB, Java issues, bad args,
114
- // non-zero exit) must surface as-is instead of being masked by an
115
- // online npx install.
116
- if (e?.code !== 'ENOENT') {
117
- throw e;
118
- }
119
- // Fallback to npx node-bundletool if bundletool is not in PATH
120
- // We use -y to avoid interactive prompt for installation
121
- if (await needsNpxDownload()) {
122
- console.log((0, i18n_1.t)('aabBundletoolDownloadHint'));
123
- }
124
- await runCommand('npx', [
125
- '-y',
126
- 'node-bundletool',
127
- 'build-apks',
128
- '--mode=universal',
129
- `--bundle=${this.file}`,
130
- `--output=${tempApksPath}`,
131
- '--overwrite',
132
- ...modulesArgs,
133
- ], {
134
- stdio: 'inherit',
135
- env: {
136
- ...process.env,
137
- npm_config_progress: 'true',
138
- },
139
- });
140
- }
141
- // 2. Extract universal.apk from the .apks (zip) file
142
- await new Promise((resolve, reject) => {
143
- (0, yauzl_1.open)(tempApksPath, { lazyEntries: true }, (err, zipfile) => {
144
- if (err || !zipfile) {
145
- reject(err || new Error((0, i18n_1.t)('aabOpenApksFailed')));
146
- return;
147
- }
148
- let found = false;
149
- zipfile.readEntry();
150
- zipfile.on('entry', (entry) => {
151
- if (entry.fileName === 'universal.apk') {
152
- found = true;
153
- zipfile.openReadStream(entry, (err, readStream) => {
154
- if (err || !readStream) {
155
- reject(err || new Error((0, i18n_1.t)('aabReadUniversalApkFailed')));
156
- return;
157
- }
158
- const writeStream = fs.createWriteStream(outputPath);
159
- readStream.pipe(writeStream);
160
- writeStream.on('close', () => {
161
- zipfile.close();
162
- resolve();
163
- });
164
- readStream.on('error', reject);
165
- writeStream.on('error', reject);
166
- });
167
- }
168
- else {
169
- zipfile.readEntry();
170
- }
171
- });
172
- zipfile.on('end', () => {
173
- if (!found)
174
- reject(new Error((0, i18n_1.t)('aabUniversalApkNotFound')));
175
- });
176
- zipfile.on('error', reject);
177
- });
178
- });
50
+ await runCommand('npx', ['--no-install', 'node-bundletool', '--version']);
51
+ return false;
179
52
  }
180
- finally {
181
- // Cleanup
182
- if (await fs.pathExists(tempDir)) {
183
- await fs.remove(tempDir);
184
- }
53
+ catch {
54
+ return true;
185
55
  }
186
- }
187
- /**
188
- * 解析 AAB 文件信息(类似 APK parser 的 parse 方法)
189
- * 注意:AAB 中的 AndroidManifest.xml 在 base/manifest/AndroidManifest.xml
190
- */
191
- async parse() {
192
- const manifestPath = 'base/manifest/AndroidManifest.xml';
193
- const ResourceName = /^base\/resources\.arsc$/;
56
+ };
57
+ try {
58
+ // 1. Build APKS (universal mode)
59
+ // We assume bundletool is in the path.
60
+ // User might need keystore to sign it properly but for simple extraction we stick to default debug key if possible or unsigned?
61
+ // actually bundletool build-apks signs with debug key by default if no keystore provided.
194
62
  try {
195
- const manifestBuffer = await this.getEntry(new RegExp(`^${escapeRegExp(manifestPath)}$`));
196
- if (!manifestBuffer) {
197
- throw new Error((0, i18n_1.t)('aabManifestNotFound'));
198
- }
199
- let apkInfo = this._parseManifest(manifestBuffer);
200
- try {
201
- const resourceBuffer = await this.getEntry(ResourceName);
202
- if (resourceBuffer) {
203
- const resourceMap = this._parseResourceMap(resourceBuffer);
204
- apkInfo = (0, utils_1.mapInfoResource)(apkInfo, resourceMap);
205
- }
63
+ await runCommand('bundletool', [
64
+ 'build-apks',
65
+ '--mode=universal',
66
+ `--bundle=${bundlePath}`,
67
+ `--output=${tempApksPath}`,
68
+ '--overwrite',
69
+ ...modulesArgs,
70
+ ]);
71
+ }
72
+ catch (e) {
73
+ // Only fall back when bundletool itself is missing from PATH (spawn
74
+ // ENOENT). Any other failure (corrupt AAB, Java issues, bad args,
75
+ // non-zero exit) must surface as-is instead of being masked by an
76
+ // online npx install.
77
+ if (e?.code !== 'ENOENT') {
78
+ throw e;
206
79
  }
207
- catch (e) {
208
- console.warn((0, i18n_1.t)('aabParseResourcesWarning', { error: e?.message ?? e }));
80
+ // Fallback to npx node-bundletool if bundletool is not in PATH
81
+ // We use -y to avoid interactive prompt for installation
82
+ if (await needsNpxDownload()) {
83
+ console.log((0, i18n_1.t)('aabBundletoolDownloadHint'));
209
84
  }
210
- return apkInfo;
211
- }
212
- catch (error) {
213
- throw new Error((0, i18n_1.t)('aabParseFailed', { error: error.message ?? error }));
214
- }
215
- }
216
- /**
217
- * Parse manifest
218
- * @param {Buffer} buffer // manifest file's buffer
219
- */
220
- _parseManifest(buffer) {
221
- try {
222
- const parser = new manifest_1.ManifestParser(buffer, {
223
- ignore: [
224
- 'application.activity',
225
- 'application.service',
226
- 'application.receiver',
227
- 'application.provider',
228
- 'permission-group',
229
- ],
85
+ await runCommand('npx', [
86
+ '-y',
87
+ 'node-bundletool',
88
+ 'build-apks',
89
+ '--mode=universal',
90
+ `--bundle=${bundlePath}`,
91
+ `--output=${tempApksPath}`,
92
+ '--overwrite',
93
+ ...modulesArgs,
94
+ ], {
95
+ stdio: 'inherit',
96
+ env: {
97
+ ...process.env,
98
+ npm_config_progress: 'true',
99
+ },
230
100
  });
231
- return parser.parse();
232
101
  }
233
- catch (e) {
234
- throw new Error((0, i18n_1.t)('aabParseManifestError', { error: e?.message ?? e }));
102
+ // 2. Extract universal.apk from the .apks (zip) file
103
+ const found = await (0, zip_entries_1.extractFirstEntry)(tempApksPath, (name) => name === 'universal.apk', outputPath);
104
+ if (!found) {
105
+ throw new Error((0, i18n_1.t)('aabUniversalApkNotFound'));
235
106
  }
236
107
  }
237
- /**
238
- * Parse resourceMap
239
- * @param {Buffer} buffer // resourceMap file's buffer
240
- */
241
- _parseResourceMap(buffer) {
242
- try {
243
- return new resource_finder_1.ResourceFinder().processResourceTable(buffer);
244
- }
245
- catch (e) {
246
- throw new Error((0, i18n_1.t)('aabParseResourcesError', { error: e?.message ?? e }));
108
+ finally {
109
+ // Cleanup
110
+ if (await (0, fs_helpers_1.pathExists)(tempDir)) {
111
+ await (0, fs_helpers_1.remove)(tempDir);
247
112
  }
248
113
  }
249
114
  }
250
- exports.AabParser = AabParser;
251
- const escapeRegExp = (value) => value.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
@@ -1,14 +1,13 @@
1
- import { Zip } from './zip';
2
- export declare class ApkParser extends Zip {
3
- parse(): Promise<any>;
4
- /**
5
- * Parse manifest
6
- * @param {Buffer} buffer // manifest file's buffer
7
- */
8
- private _parseManifest;
9
- /**
10
- * Parse resourceMap
11
- * @param {Buffer} buffer // resourceMap file's buffer
12
- */
13
- private _parseResourceMap;
1
+ export interface ApkManifestInfo {
2
+ versionName?: unknown;
3
+ /** `<application>`'s `<meta-data>` entries, resource references resolved */
4
+ metaData: Array<{
5
+ name?: unknown;
6
+ value?: unknown;
7
+ }>;
14
8
  }
9
+ /**
10
+ * The fields of a binary AndroidManifest.xml the CLI reads, with
11
+ * `@<resource>` references resolved through resources.arsc when given.
12
+ */
13
+ export declare function parseApkManifest(manifest: Buffer, resources?: Buffer): ApkManifestInfo;
@@ -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,45 +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
- * Same to C# BinaryReader.readBytes
15
- *
16
- * @param bb ByteBuffer
17
- * @param len length
18
- * @returns {Buffer}
19
- */
20
- static readBytes(bb: any, len: number): any;
21
- /**
22
- *
23
- * @param {ByteBuffer} bb
24
- * @return {Map<String, Set<String>>}
25
- */
10
+ /** Map of `@<RESOURCE ID>` to the values of that resource. */
26
11
  processResourceTable(resourceBuffer: Buffer): Record<string, any[]>;
27
- /**
28
- *
29
- * @param {ByteBuffer} bb
30
- */
31
12
  private processPackage;
32
- /**
33
- *
34
- * @param {ByteBuffer} bb
35
- */
36
13
  private processType;
37
- /**
38
- *
39
- * @param {ByteBuffer} bb
40
- * @return {Array}
41
- */
42
14
  private processStringPool;
43
- /**
44
- *
45
- * @param {ByteBuffer} bb
46
- */
47
- private processTypeSpec;
48
15
  private putIntoMap;
49
16
  }