react-native-update-cli 2.22.8 → 2.23.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/README.md CHANGED
@@ -68,13 +68,14 @@ const publishResult = await provider.publish({
68
68
  - `hdiffFromApp`: Generate hdiff from APP files
69
69
  - `hdiffFromIpa`: Generate hdiff from IPA files
70
70
 
71
- Hermes projects: `bundle` always runs hermesc with `-output-source-map`, so the debug info section is stripped from the bytecode (15–40% smaller, same as React Native's own release builds). The Hermes sourcemap stays in the intermediate directory (`.pushy/intermedia/<platform>/<bundle>.map`, never packed into the ppk); with `--sourcemap` it is composed with the packager map as before. Keep it if you want to symbolicate `address at` crash stacks later.
71
+ Hermes projects: `bundle` always runs hermesc with `-output-source-map`, so the debug info section is stripped from the bytecode (15–40% smaller, same as React Native's own release builds). The Hermes sourcemap stays in the intermediate directory (`.pushy/intermedia/<platform>/<bundle>.map`, never packed into the ppk) and is composed with the packager map — `--sourcemap` is on by default since 2.23 (`--sourcemap false` opts out). When `bundle` publishes, that final map is uploaded and archived with the version (`sourceMapKey`), so `pushy symbolicate` can map crash stacks — including Hermes `address at` frames — back to source later. `pushy publish <ppk> --sourcemap <file.map>` archives a map for a ppk built elsewhere; publishing without a map prints a warning.
72
72
 
73
73
  Hermes delta mode (`-base-bytecode`): by default (`--hermesBase auto`) `bundle` compiles against the previous HBC of the same app, which keeps Hermes string IDs stable and makes hot-update patches 5–30× smaller. The base comes from the server (`GET /app/:id/hermesBase`), verified by sha256 and kept in a local cache (`.pushy/cache/<sha256>`, 500 MB / 20 files, `PUSHY_CACHE_DIR` / `--cacheMaxMb` to tune, `pushy cache [clean]` to inspect or clear). `--hermesBase none` disables it; `--hermesBase <file.hbc|.ppk|.apk|.ipa>` uses a local artifact (for example the store build). `--verifyHermesBase` (default on) additionally compiles without the base (concurrently with the base compile) and compares both disassemblies; on any mismatch or failure the CLI silently falls back to the plain compile, so the feature can never block a release. Only hermesc builds that include the upstream delta-mode fix are used (classic `react-native/sdks/hermesc`, or `hermes-compiler` ≥ 250829098). If a base compile fails, the full hermesc output is written to `hermes-base-error.log` next to the intermediate directory. `--resetCache false` skips Metro's `--reset-cache` and reuses its transform cache, which makes repeated bundles much faster.
74
74
 
75
75
  ### Version
76
76
 
77
- - `publish`: Publish a new version
77
+ - `publish`: Publish a new version (`--sourcemap <file.map>` archives the source map with it)
78
+ - `symbolicate`: Map a crash stack to source using the archived map: `pushy symbolicate stack.txt --hash <updateHash>` (`-` reads stdin, `--versionId` instead of `--hash`, `--output <file>`); the hash is `getUpdateMetadata().currentVersion` on the device
78
79
  - `versions`: List versions
79
80
  - `update`: Update version package rules
80
81
  - `updateVersionInfo`: Update version metadata
package/README.zh-CN.md CHANGED
@@ -68,13 +68,14 @@ const publishResult = await provider.publish({
68
68
  - `hdiffFromApp`: 基于 APP 文件生成 hdiff
69
69
  - `hdiffFromIpa`: 基于 IPA 文件生成 hdiff
70
70
 
71
- Hermes 工程:`bundle` 调用 hermesc 时始终带 `-output-source-map`,因此字节码不含 debug info 段(小 15%~40%,与 React Native 自身 release 构建一致)。Hermes sourcemap 保留在中间目录(`.pushy/intermedia/<platform>/<bundle>.map`,不会打进 ppk);传 `--sourcemap` 时照旧与 packager map 合成。留着它可以事后符号化 `address at` 形式的崩溃堆栈。
71
+ Hermes 工程:`bundle` 调用 hermesc 时始终带 `-output-source-map`,因此字节码不含 debug info 段(小 15%~40%,与 React Native 自身 release 构建一致)。Hermes sourcemap 保留在中间目录(`.pushy/intermedia/<platform>/<bundle>.map`,不会打进 ppk),并与 packager map 合成——自 2.23 起 `--sourcemap` 默认开启(`--sourcemap false` 关闭)。`bundle` 发布时会把这份最终 map 上传并随版本归档(`sourceMapKey`),之后用 `pushy symbolicate` 即可把崩溃堆栈(含 Hermes 的 `address at` 帧)还原到源码。别处打好的 ppk 可用 `pushy publish <ppk> --sourcemap <file.map>` 归档;不带 map 发布会打印警告。
72
72
 
73
73
  Hermes delta 模式(`-base-bytecode`):默认 `--hermesBase auto`,`bundle` 会以同一应用上一版的 HBC 为 base 编译,让 Hermes 字符串 ID 跨版本稳定,热更 patch 可缩小 5~30 倍。base 由服务端(`GET /app/:id/hermesBase`)给出、按 sha256 校验并存入本地缓存(`.pushy/cache/<sha256>`,默认 500 MB / 20 个,可用 `PUSHY_CACHE_DIR` / `--cacheMaxMb` 调整,`pushy cache [clean]` 查看或清空)。`--hermesBase none` 关闭;`--hermesBase <file.hbc|.ppk|.apk|.ipa>` 指定本地文件(比如商店包)作 base。`--verifyHermesBase`(默认开)会并行再做一次普通编译并比对两份反汇编;任何不一致或失败都静默回退到普通编译,不会阻塞发版。只有包含上游 delta 模式修复的 hermesc 才会启用(经典 `react-native/sdks/hermesc`,或 `hermes-compiler` ≥ 250829098)。base 编译失败时,完整的 hermesc 输出会写到中间目录旁边的 `hermes-base-error.log`。`--resetCache false` 可跳过 Metro 的 `--reset-cache`,复用其转换缓存,重复打包会快很多。
74
74
 
75
75
  ### Version
76
76
 
77
- - `publish`: 发布新版本
77
+ - `publish`: 发布新版本(`--sourcemap <file.map>` 随版本归档 source map)
78
+ - `symbolicate`: 用归档的 map 还原崩溃堆栈:`pushy symbolicate stack.txt --hash <热更 hash>`(`-` 读 stdin,可用 `--versionId` 代替 `--hash`,`--output <文件>` 写文件);hash 即设备上 `getUpdateMetadata().currentVersion`
78
79
  - `versions`: 列出版本
79
80
  - `update`: 更新版本包规则
80
81
  - `updateVersionInfo`: 更新版本元信息
package/cli.json CHANGED
@@ -139,6 +139,9 @@
139
139
  },
140
140
  "dryRun": {
141
141
  "default": false
142
+ },
143
+ "sourcemap": {
144
+ "hasValue": true
142
145
  }
143
146
  }
144
147
  },
@@ -248,7 +251,7 @@
248
251
  "hasValue": true
249
252
  },
250
253
  "sourcemap": {
251
- "default": false
254
+ "default": true
252
255
  },
253
256
  "taro": {
254
257
  "default": false
@@ -382,6 +385,23 @@
382
385
  "cache": {
383
386
  "description": "Inspect or clean the local bundle cache: cache [clean]",
384
387
  "options": {}
388
+ },
389
+ "symbolicate": {
390
+ "description": "Map a JS stack trace back to source using the source map archived with a published version.",
391
+ "options": {
392
+ "hash": {
393
+ "hasValue": true
394
+ },
395
+ "versionId": {
396
+ "hasValue": true
397
+ },
398
+ "platform": {
399
+ "hasValue": true
400
+ },
401
+ "output": {
402
+ "hasValue": true
403
+ }
404
+ }
385
405
  }
386
406
  },
387
407
  "globalOptions": {
package/lib/bin.js CHANGED
@@ -8,6 +8,7 @@ const cache_1 = require("./cache");
8
8
  const diff_1 = require("./diff");
9
9
  const install_1 = require("./install");
10
10
  const package_1 = require("./package");
11
+ const symbolicate_1 = require("./symbolicate");
11
12
  const user_1 = require("./user");
12
13
  const utils_1 = require("./utils");
13
14
  const i18n_1 = require("./utils/i18n");
@@ -38,6 +39,7 @@ const commandHandlers = {
38
39
  ...(0, app_1.getAppCommands)(),
39
40
  ...package_1.packageCommands,
40
41
  ...versions_1.versionCommands,
42
+ ...symbolicate_1.symbolicateCommands,
41
43
  ...install_1.installCommands,
42
44
  help: printUsage,
43
45
  };
package/lib/bundle.js CHANGED
@@ -37,7 +37,9 @@ function normalizeBundleOptions(translatedOptions, platform) {
37
37
  intermediaDir: (0, options_1.getStringOption)(translatedOptions, 'intermediaDir', `${constants_1.tempDir}/intermedia/${platform}`),
38
38
  output: (0, options_1.getStringOption)(translatedOptions, 'output', `${constants_1.tempDir}/output/${platform}.\${time}.ppk`),
39
39
  dev: (0, options_1.getBooleanOption)(translatedOptions, 'dev', false) ? 'true' : 'false',
40
- sourcemap: (0, options_1.getBooleanOption)(translatedOptions, 'sourcemap', false),
40
+ // On by default since 2.23: the map is archived with the published
41
+ // version (pushy symbolicate). --no-sourcemap / --sourcemap=false opts out.
42
+ sourcemap: (0, options_1.getBooleanOption)(translatedOptions, 'sourcemap', true),
41
43
  taro: (0, options_1.getBooleanOption)(translatedOptions, 'taro', false),
42
44
  expo: (0, options_1.getBooleanOption)(translatedOptions, 'expo', false),
43
45
  rncli: (0, options_1.getBooleanOption)(translatedOptions, 'rncli', false),
@@ -149,6 +151,9 @@ exports.bundleCommands = {
149
151
  rollout: normalized.rollout,
150
152
  dryRun: normalized.dryRun,
151
153
  hermesBase: baseMeta,
154
+ sourcemap: normalized.sourcemap || bundleParams.sourcemap
155
+ ? sourcemapOutput
156
+ : undefined,
152
157
  });
153
158
  await uploadSentryArtifactsIfNeeded(bundleParams.sentry, normalized.bundleName, normalized.intermediaDir, sourcemapOutput, platform, {
154
159
  sentryRelease: normalized.sentryRelease,
@@ -161,6 +166,9 @@ exports.bundleCommands = {
161
166
  if (v.toLowerCase() === 'y') {
162
167
  await publishBundleVersion(realOutput, platform, {
163
168
  hermesBase: baseMeta,
169
+ sourcemap: normalized.sourcemap || bundleParams.sourcemap
170
+ ? sourcemapOutput
171
+ : undefined,
164
172
  });
165
173
  await uploadSentryArtifactsIfNeeded(bundleParams.sentry, normalized.bundleName, normalized.intermediaDir, sourcemapOutput, platform, {
166
174
  sentryRelease: normalized.sentryRelease,
@@ -93,6 +93,14 @@ declare const _default: {
93
93
  processingPackage: string;
94
94
  processingStringPool: string;
95
95
  publishUsage: string;
96
+ sourceMapNotFound: string;
97
+ sourceMapMissingWarning: string;
98
+ sourceMapArchived: string;
99
+ sourceMapUploadFailedWarning: string;
100
+ symbolicateUsage: string;
101
+ symbolicateVersionNotFound: string;
102
+ symbolicateNoSourceMap: string;
103
+ symbolicateDone: string;
96
104
  rnuVersionNotFound: string;
97
105
  rolloutConfigSet: string;
98
106
  rolloutRangeError: string;
package/lib/locales/en.js CHANGED
@@ -101,6 +101,14 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
101
101
  processingPackage: 'Processing the package {{count}} ...',
102
102
  processingStringPool: 'Processing the string pool ...',
103
103
  publishUsage: 'Usage: pushy publish <ppk file> --platform ios|android|harmony',
104
+ sourceMapNotFound: 'Source map not found: {{path}}',
105
+ sourceMapMissingWarning: 'No source map was archived with this version: crashes cannot be symbolicated later. Bundle with the default --sourcemap, or pass --sourcemap <file> to publish.',
106
+ sourceMapArchived: 'Source map archived with version {{id}}',
107
+ sourceMapUploadFailedWarning: 'Source map upload failed ({{error}}); publishing without an archived map. Upgrade the update server to archive source maps.',
108
+ symbolicateUsage: 'Usage: pushy symbolicate <stack file | -> --hash <updateHash> [--platform ios|android|harmony] [--output <file>]',
109
+ symbolicateVersionNotFound: 'No published version with hash {{hash}} found for this app',
110
+ symbolicateNoSourceMap: 'Version {{id}} was published without a source map; nothing to symbolicate against',
111
+ symbolicateDone: 'Symbolicated {{count}} frame(s) against version {{id}} ({{hash}})',
104
112
  rnuVersionNotFound: 'react-native-update: Cannot get the version number. Please run the command in the project directory',
105
113
  rolloutConfigSet: 'Set {{rollout}}% rollout for OTA update {{version}} on native version(s) {{versions}}',
106
114
  rolloutRangeError: 'rollout must be an integer between 1-100',
@@ -92,6 +92,14 @@ declare const _default: {
92
92
  processingError: string;
93
93
  processingPackage: string;
94
94
  processingStringPool: string;
95
+ sourceMapNotFound: string;
96
+ sourceMapMissingWarning: string;
97
+ sourceMapArchived: string;
98
+ sourceMapUploadFailedWarning: string;
99
+ symbolicateUsage: string;
100
+ symbolicateVersionNotFound: string;
101
+ symbolicateNoSourceMap: string;
102
+ symbolicateDone: string;
95
103
  publishUsage: string;
96
104
  rnuVersionNotFound: string;
97
105
  rolloutConfigSet: string;
package/lib/locales/zh.js CHANGED
@@ -100,6 +100,14 @@ exports.default = {
100
100
  processingError: '处理文件时出错:{{error}}',
101
101
  processingPackage: '正在处理包 {{count}}...',
102
102
  processingStringPool: '正在处理字符串池...',
103
+ sourceMapNotFound: '找不到 source map:{{path}}',
104
+ sourceMapMissingWarning: '本版本没有归档 source map,之后的崩溃堆栈将无法还原。请用默认的 --sourcemap 打包,或在 publish 时传 --sourcemap <文件>。',
105
+ sourceMapArchived: 'source map 已随版本 {{id}} 归档',
106
+ sourceMapUploadFailedWarning: 'source map 上传失败({{error}}),本次发布不归档 map。升级更新服务端后可归档 source map。',
107
+ symbolicateUsage: '用法:pushy symbolicate <堆栈文件 | -> --hash <热更 hash> [--platform ios|android|harmony] [--output <文件>]',
108
+ symbolicateVersionNotFound: '当前应用下找不到 hash 为 {{hash}} 的已发布版本',
109
+ symbolicateNoSourceMap: '版本 {{id}} 发布时未归档 source map,无法还原',
110
+ symbolicateDone: '已按版本 {{id}}({{hash}})还原 {{count}} 个堆栈帧',
103
111
  publishUsage: '使用方法: pushy publish ppk后缀文件 --platform ios|android|harmony',
104
112
  rnuVersionNotFound: 'react-native-update: 无法获取版本号。请在项目目录中运行命令',
105
113
  rolloutConfigSet: '已在原生版本 {{versions}} 上设置灰度发布 {{rollout}}% 热更包 {{version}}',
@@ -10,8 +10,12 @@ export type NativePackageEntry = {
10
10
  * considered by the local diff implementation (or vice versa).
11
11
  */
12
12
  export declare function resolveNativePackageEntry(platform: Platform, entryName: string): NativePackageEntry | undefined;
13
+ export interface SlimPackageOptions {
14
+ /** re-deflate through yazl even when a raw copy would do (tests) */
15
+ repack?: boolean;
16
+ }
13
17
  /**
14
18
  * Repack a native package with only the bundle and resources required by
15
19
  * package-origin diffs. Entry names and nested Harmony HAP structure are kept.
16
20
  */
17
- export declare function createSlimNativePackage(source: string, output: string, platform: Platform): Promise<void>;
21
+ export declare function createSlimNativePackage(source: string, output: string, platform: Platform, options?: SlimPackageOptions): Promise<void>;
@@ -43,6 +43,7 @@ const os_1 = __importDefault(require("os"));
43
43
  const path_1 = __importDefault(require("path"));
44
44
  const yauzl_1 = require("yauzl");
45
45
  const yazl_1 = require("yazl");
46
+ const zip_raw_writer_1 = require("./utils/zip-raw-writer");
46
47
  const nativePackageRules = {
47
48
  android: {
48
49
  resolveEntry: (entryName) => {
@@ -86,23 +87,94 @@ const nativePackageRules = {
86
87
  function resolveNativePackageEntry(platform, entryName) {
87
88
  return nativePackageRules[platform].resolveEntry(entryName);
88
89
  }
89
- function copyEntryToZip(sourceZip, entry, outputZip) {
90
+ /**
91
+ * Copies each entry's stored bytes, CRC and sizes verbatim (yauzl hands out
92
+ * the raw file data with `decodeFileData: false`), so slimming a package is
93
+ * bound by disk I/O rather than by deflating every asset again.
94
+ */
95
+ class RawCopySink {
96
+ writer;
97
+ constructor(output) {
98
+ this.writer = new zip_raw_writer_1.RawZipWriter(output);
99
+ }
100
+ copyEntry(sourceZip, entry) {
101
+ return new Promise((resolve, reject) => {
102
+ sourceZip.openReadStream(entry, { decodeFileData: false }, (error, readStream) => {
103
+ if (error || !readStream) {
104
+ reject(error ?? new Error(`Unable to read zip entry: ${entry.fileName}`));
105
+ return;
106
+ }
107
+ this.writer.addRawEntry(entry, readStream).then(resolve, reject);
108
+ });
109
+ });
110
+ }
111
+ addFile(filePath, fileName, like) {
112
+ // a nested slim archive is a zip of deflated entries: storing it as-is
113
+ // loses nothing and skips another pass over its bytes
114
+ return this.writer.addStoredFile(filePath, fileName, like);
115
+ }
116
+ end() {
117
+ return this.writer.end();
118
+ }
119
+ abort() {
120
+ return this.writer.abort();
121
+ }
122
+ }
123
+ /** Re-deflates every kept entry through yazl; only for sources that need zip64. */
124
+ class RepackSink {
125
+ output;
126
+ outputZip = new yazl_1.ZipFile();
127
+ writePromise;
128
+ constructor(output) {
129
+ this.output = output;
130
+ this.writePromise = new Promise((resolve, reject) => {
131
+ this.outputZip.outputStream.once('error', reject);
132
+ this.outputZip.outputStream
133
+ .pipe(fs.createWriteStream(output))
134
+ .once('error', reject)
135
+ .once('close', () => resolve());
136
+ });
137
+ }
138
+ copyEntry(sourceZip, entry) {
139
+ return new Promise((resolve, reject) => {
140
+ sourceZip.openReadStream(entry, (error, readStream) => {
141
+ if (error || !readStream) {
142
+ reject(error ?? new Error(`Unable to read zip entry: ${entry.fileName}`));
143
+ return;
144
+ }
145
+ readStream.once('error', reject);
146
+ readStream.once('end', () => resolve());
147
+ this.outputZip.addReadStream(readStream, entry.fileName, {
148
+ compress: entry.compressionMethod !== 0,
149
+ mtime: entry.getLastModDate(),
150
+ });
151
+ });
152
+ });
153
+ }
154
+ async addFile(filePath, fileName, like) {
155
+ this.outputZip.addFile(filePath, fileName, {
156
+ compress: like.compressionMethod !== 0,
157
+ mtime: like.getLastModDate(),
158
+ });
159
+ }
160
+ async end() {
161
+ this.outputZip.end();
162
+ await this.writePromise;
163
+ }
164
+ async abort() {
165
+ this.outputZip.end();
166
+ await this.writePromise.catch(() => { });
167
+ await fs.remove(this.output).catch(() => { });
168
+ }
169
+ }
170
+ function openZip(source) {
90
171
  return new Promise((resolve, reject) => {
91
- sourceZip.openReadStream(entry, (error, readStream) => {
92
- if (error) {
93
- reject(error);
94
- return;
95
- }
96
- if (!readStream) {
97
- reject(new Error(`Unable to read zip entry: ${entry.fileName}`));
172
+ (0, yauzl_1.open)(source, { lazyEntries: true }, (error, zipFile) => {
173
+ if (error || !zipFile) {
174
+ reject(error ?? new Error(`Unable to open zip file: ${source}`));
98
175
  return;
99
176
  }
100
- readStream.once('error', reject);
101
- readStream.once('end', () => resolve());
102
- outputZip.addReadStream(readStream, entry.fileName, {
103
- compress: entry.compressionMethod !== 0,
104
- mtime: entry.getLastModDate(),
105
- });
177
+ resolve(zipFile);
106
178
  });
107
179
  });
108
180
  }
@@ -125,94 +197,83 @@ function extractEntryToFile(sourceZip, entry, outputPath) {
125
197
  });
126
198
  });
127
199
  }
128
- async function filterNativePackageArchive(source, output, platform) {
200
+ async function filterNativePackageArchive(source, output, platform, options) {
129
201
  await fs.ensureDir(path_1.default.dirname(output));
130
202
  const scratchDir = await fs.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'rnu-native-package-entry-'));
131
- const outputZip = new yazl_1.ZipFile();
132
- const writePromise = new Promise((resolve, reject) => {
133
- outputZip.outputStream.once('error', reject);
134
- outputZip.outputStream
135
- .pipe(fs.createWriteStream(output))
136
- .once('error', reject)
137
- .once('close', () => resolve());
138
- });
203
+ const sourceZip = await openZip(source);
204
+ // a subset of the source never outgrows it, so the source's own size and
205
+ // entry count decide whether plain (non-zip64) headers are enough
206
+ const rawCopy = !options.repack &&
207
+ (0, zip_raw_writer_1.fitsRawZip)((await fs.stat(source)).size, sourceZip.entryCount);
208
+ const sink = rawCopy
209
+ ? new RawCopySink(output)
210
+ : new RepackSink(output);
139
211
  let includedEntries = 0;
140
212
  let includedBundles = 0;
141
213
  let nestedArchiveIndex = 0;
142
214
  try {
143
215
  await new Promise((resolve, reject) => {
144
- (0, yauzl_1.open)(source, { lazyEntries: true }, (openError, sourceZip) => {
145
- if (openError || !sourceZip) {
146
- reject(openError ?? new Error(`Unable to open zip file: ${source}`));
216
+ let settled = false;
217
+ const fail = (error) => {
218
+ if (settled) {
147
219
  return;
148
220
  }
149
- let settled = false;
150
- const fail = (error) => {
151
- if (settled) {
152
- return;
153
- }
221
+ settled = true;
222
+ sourceZip.close();
223
+ reject(error);
224
+ };
225
+ sourceZip.once('error', fail);
226
+ sourceZip.once('end', () => {
227
+ if (!settled) {
154
228
  settled = true;
155
- sourceZip.close();
156
- reject(error);
157
- };
158
- sourceZip.once('error', fail);
159
- sourceZip.once('end', () => {
160
- if (!settled) {
161
- settled = true;
162
- resolve();
229
+ resolve();
230
+ }
231
+ });
232
+ sourceZip.on('entry', async (entry) => {
233
+ try {
234
+ if (entry.fileName.endsWith('/')) {
235
+ sourceZip.readEntry();
236
+ return;
163
237
  }
164
- });
165
- sourceZip.on('entry', async (entry) => {
166
- try {
167
- if (entry.fileName.endsWith('/')) {
168
- sourceZip.readEntry();
169
- return;
170
- }
171
- // Harmony .app packages contain one or more nested .hap archives.
172
- // Rebuild those archives recursively and keep their outer path so
173
- // the slim package has the same nesting as the original package.
174
- if (platform === 'harmony' &&
175
- entry.fileName.toLowerCase().endsWith('.hap')) {
176
- const index = nestedArchiveIndex++;
177
- const nestedSource = path_1.default.join(scratchDir, `${index}.source.hap`);
178
- const nestedOutput = path_1.default.join(scratchDir, `${index}.slim.hap`);
179
- await extractEntryToFile(sourceZip, entry, nestedSource);
180
- const nestedResult = await filterNativePackageArchive(nestedSource, nestedOutput, platform);
181
- if (nestedResult.entries > 0) {
182
- outputZip.addFile(nestedOutput, entry.fileName, {
183
- compress: entry.compressionMethod !== 0,
184
- mtime: entry.getLastModDate(),
185
- });
186
- includedEntries += nestedResult.entries;
187
- includedBundles += nestedResult.bundles;
188
- }
189
- sourceZip.readEntry();
190
- return;
191
- }
192
- const resolvedEntry = resolveNativePackageEntry(platform, entry.fileName);
193
- if (resolvedEntry) {
194
- await copyEntryToZip(sourceZip, entry, outputZip);
195
- includedEntries += 1;
196
- if (resolvedEntry.kind === 'bundle') {
197
- includedBundles += 1;
198
- }
238
+ // Harmony .app packages contain one or more nested .hap archives.
239
+ // Rebuild those archives recursively and keep their outer path so
240
+ // the slim package has the same nesting as the original package.
241
+ if (platform === 'harmony' &&
242
+ entry.fileName.toLowerCase().endsWith('.hap')) {
243
+ const index = nestedArchiveIndex++;
244
+ const nestedSource = path_1.default.join(scratchDir, `${index}.source.hap`);
245
+ const nestedOutput = path_1.default.join(scratchDir, `${index}.slim.hap`);
246
+ await extractEntryToFile(sourceZip, entry, nestedSource);
247
+ const nestedResult = await filterNativePackageArchive(nestedSource, nestedOutput, platform, options);
248
+ if (nestedResult.entries > 0) {
249
+ await sink.addFile(nestedOutput, entry.fileName, entry);
250
+ includedEntries += nestedResult.entries;
251
+ includedBundles += nestedResult.bundles;
199
252
  }
200
253
  sourceZip.readEntry();
254
+ return;
201
255
  }
202
- catch (error) {
203
- fail(error);
256
+ const resolvedEntry = resolveNativePackageEntry(platform, entry.fileName);
257
+ if (resolvedEntry) {
258
+ await sink.copyEntry(sourceZip, entry);
259
+ includedEntries += 1;
260
+ if (resolvedEntry.kind === 'bundle') {
261
+ includedBundles += 1;
262
+ }
204
263
  }
205
- });
206
- sourceZip.readEntry();
264
+ sourceZip.readEntry();
265
+ }
266
+ catch (error) {
267
+ fail(error);
268
+ }
207
269
  });
270
+ sourceZip.readEntry();
208
271
  });
209
- outputZip.end();
210
- await writePromise;
272
+ await sink.end();
211
273
  return { bundles: includedBundles, entries: includedEntries };
212
274
  }
213
275
  catch (error) {
214
- outputZip.end();
215
- await writePromise.catch(() => { });
276
+ await sink.abort();
216
277
  throw error;
217
278
  }
218
279
  finally {
@@ -223,8 +284,8 @@ async function filterNativePackageArchive(source, output, platform) {
223
284
  * Repack a native package with only the bundle and resources required by
224
285
  * package-origin diffs. Entry names and nested Harmony HAP structure are kept.
225
286
  */
226
- async function createSlimNativePackage(source, output, platform) {
227
- const result = await filterNativePackageArchive(source, output, platform);
287
+ async function createSlimNativePackage(source, output, platform, options = {}) {
288
+ const result = await filterNativePackageArchive(source, output, platform, options);
228
289
  if (result.bundles === 0) {
229
290
  await fs.remove(output);
230
291
  throw new Error(`Bundle entry not found in native package: ${source}`);
package/lib/provider.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BundleOptions, CLIProvider, CommandResult, Platform, PublishOptions, Session, UpdateVersionOptions, UploadOptions } from './types';
1
+ import type { BundleOptions, CLIProvider, CommandResult, Platform, PublishOptions, Session, SymbolicateOptions, UpdateVersionOptions, UploadOptions } from './types';
2
2
  export declare class CLIProviderImpl implements CLIProvider {
3
3
  private session?;
4
4
  private sessionInitPromise?;
@@ -8,6 +8,7 @@ export declare class CLIProviderImpl implements CLIProvider {
8
8
  private runDataCommand;
9
9
  bundle(options: BundleOptions): Promise<CommandResult>;
10
10
  publish(options: PublishOptions): Promise<CommandResult>;
11
+ symbolicate(options: SymbolicateOptions): Promise<CommandResult>;
11
12
  upload(options: UploadOptions): Promise<CommandResult>;
12
13
  getSelectedApp(platform?: Platform): Promise<{
13
14
  appId: string;
package/lib/provider.js CHANGED
@@ -117,11 +117,26 @@ class CLIProviderImpl {
117
117
  ? undefined
118
118
  : String(options.rollout),
119
119
  dryRun: options.dryRun || false,
120
+ sourcemap: options.sourcemap,
120
121
  }, options.filePath ? [options.filePath] : []);
121
122
  const { versionCommands } = await Promise.resolve().then(() => __importStar(require('./versions')));
122
123
  await versionCommands.publish(context);
123
124
  }, 'Unknown error during publishing', 'Version published successfully');
124
125
  }
126
+ async symbolicate(options) {
127
+ return this.runMessageCommand(async () => {
128
+ const context = this.createContext({
129
+ hash: options.hash,
130
+ versionId: options.versionId,
131
+ platform: options.platform,
132
+ appId: options.appId,
133
+ config: options.config,
134
+ output: options.output,
135
+ }, options.stackFile ? [options.stackFile] : []);
136
+ const { symbolicateCommands } = await Promise.resolve().then(() => __importStar(require('./symbolicate')));
137
+ await symbolicateCommands.symbolicate(context);
138
+ }, 'Unknown error during symbolication', 'Stack symbolicated');
139
+ }
125
140
  async upload(options) {
126
141
  return this.runMessageCommand(async () => {
127
142
  const filePath = options.filePath;
@@ -0,0 +1,30 @@
1
+ export interface FrameConsumer {
2
+ originalPositionFor(position: {
3
+ line: number;
4
+ column: number;
5
+ }): {
6
+ source?: string | null;
7
+ line?: number | null;
8
+ column?: number | null;
9
+ name?: string | null;
10
+ };
11
+ }
12
+ /**
13
+ * Rewrites every bundle frame of `stack` to its original source position.
14
+ * JS engines report 1-based columns, so they are shifted to the 0-based
15
+ * columns source maps use; Hermes bytecode frames (`address at`) carry the
16
+ * bytecode offset, which the composed hermes map keys directly.
17
+ */
18
+ export declare function symbolicateStack(stack: string, consumer: FrameConsumer): {
19
+ text: string;
20
+ mapped: number;
21
+ };
22
+ export declare const symbolicateCommands: {
23
+ symbolicate: ({ args, options, }: {
24
+ args: string[];
25
+ options: Record<string, unknown>;
26
+ }) => Promise<{
27
+ versionId: string;
28
+ mapped: number;
29
+ }>;
30
+ };