rn-update-cli 1.0.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.
Files changed (117) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +167 -0
  3. package/README.zh-CN.md +167 -0
  4. package/cli.json +525 -0
  5. package/lib/api.d.ts +56 -0
  6. package/lib/api.js +671 -0
  7. package/lib/app.d.ts +107 -0
  8. package/lib/app.js +329 -0
  9. package/lib/auto-update.d.ts +35 -0
  10. package/lib/auto-update.js +507 -0
  11. package/lib/bin.d.ts +2 -0
  12. package/lib/bin.js +133 -0
  13. package/lib/bundle-pack.d.ts +6 -0
  14. package/lib/bundle-pack.js +91 -0
  15. package/lib/bundle-runner.d.ts +168 -0
  16. package/lib/bundle-runner.js +1305 -0
  17. package/lib/bundle.d.ts +45 -0
  18. package/lib/bundle.js +226 -0
  19. package/lib/cache.d.ts +10 -0
  20. package/lib/cache.js +25 -0
  21. package/lib/commands.d.ts +11 -0
  22. package/lib/commands.js +72 -0
  23. package/lib/diff.d.ts +18 -0
  24. package/lib/diff.js +690 -0
  25. package/lib/exports.d.ts +11 -0
  26. package/lib/exports.js +20 -0
  27. package/lib/install.d.ts +9 -0
  28. package/lib/install.js +51 -0
  29. package/lib/locales/en.d.ts +187 -0
  30. package/lib/locales/en.js +194 -0
  31. package/lib/locales/zh.d.ts +187 -0
  32. package/lib/locales/zh.js +194 -0
  33. package/lib/native-package.d.ts +21 -0
  34. package/lib/native-package.js +298 -0
  35. package/lib/package.d.ts +68 -0
  36. package/lib/package.js +487 -0
  37. package/lib/provider.d.ts +24 -0
  38. package/lib/provider.js +244 -0
  39. package/lib/standalone-publish.d.ts +17 -0
  40. package/lib/standalone-publish.js +433 -0
  41. package/lib/symbolicate.d.ts +35 -0
  42. package/lib/symbolicate.js +130 -0
  43. package/lib/types.d.ts +152 -0
  44. package/lib/types.js +2 -0
  45. package/lib/user.d.ts +8 -0
  46. package/lib/user.js +50 -0
  47. package/lib/utils/add-gitignore.d.ts +6 -0
  48. package/lib/utils/add-gitignore.js +44 -0
  49. package/lib/utils/app-info-parser/aab.d.ts +27 -0
  50. package/lib/utils/app-info-parser/aab.js +256 -0
  51. package/lib/utils/app-info-parser/apk.d.ts +19 -0
  52. package/lib/utils/app-info-parser/apk.js +95 -0
  53. package/lib/utils/app-info-parser/app.d.ts +9 -0
  54. package/lib/utils/app-info-parser/app.js +15 -0
  55. package/lib/utils/app-info-parser/index.d.ts +21 -0
  56. package/lib/utils/app-info-parser/index.js +51 -0
  57. package/lib/utils/app-info-parser/ipa.d.ts +19 -0
  58. package/lib/utils/app-info-parser/ipa.js +101 -0
  59. package/lib/utils/app-info-parser/resource-finder.d.ts +49 -0
  60. package/lib/utils/app-info-parser/resource-finder.js +429 -0
  61. package/lib/utils/app-info-parser/utils.d.ts +36 -0
  62. package/lib/utils/app-info-parser/utils.js +140 -0
  63. package/lib/utils/app-info-parser/xml-parser/binary.d.ts +61 -0
  64. package/lib/utils/app-info-parser/xml-parser/binary.js +577 -0
  65. package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +15 -0
  66. package/lib/utils/app-info-parser/xml-parser/manifest.js +207 -0
  67. package/lib/utils/app-info-parser/zip.d.ts +29 -0
  68. package/lib/utils/app-info-parser/zip.js +97 -0
  69. package/lib/utils/check-lockfile.d.ts +6 -0
  70. package/lib/utils/check-lockfile.js +93 -0
  71. package/lib/utils/check-plugin.d.ts +12 -0
  72. package/lib/utils/check-plugin.js +36 -0
  73. package/lib/utils/command-result.d.ts +8 -0
  74. package/lib/utils/command-result.js +27 -0
  75. package/lib/utils/constants.d.ts +10 -0
  76. package/lib/utils/constants.js +39 -0
  77. package/lib/utils/dep-versions.d.ts +20 -0
  78. package/lib/utils/dep-versions.js +129 -0
  79. package/lib/utils/git.d.ts +14 -0
  80. package/lib/utils/git.js +64 -0
  81. package/lib/utils/hbcTransform.d.ts +111 -0
  82. package/lib/utils/hbcTransform.js +561 -0
  83. package/lib/utils/hermes-base.d.ts +227 -0
  84. package/lib/utils/hermes-base.js +1287 -0
  85. package/lib/utils/hermes-literals.d.ts +64 -0
  86. package/lib/utils/hermes-literals.js +260 -0
  87. package/lib/utils/http-helper.d.ts +10 -0
  88. package/lib/utils/http-helper.js +150 -0
  89. package/lib/utils/i18n.d.ts +22 -0
  90. package/lib/utils/i18n.js +46 -0
  91. package/lib/utils/index.d.ts +67 -0
  92. package/lib/utils/index.js +545 -0
  93. package/lib/utils/latest-version/index.d.ts +154 -0
  94. package/lib/utils/latest-version/index.js +331 -0
  95. package/lib/utils/options.d.ts +10 -0
  96. package/lib/utils/options.js +68 -0
  97. package/lib/utils/plugin-config.d.ts +14 -0
  98. package/lib/utils/plugin-config.js +66 -0
  99. package/lib/utils/runtime.d.ts +54 -0
  100. package/lib/utils/runtime.js +263 -0
  101. package/lib/utils/slim-sourcemap.d.ts +28 -0
  102. package/lib/utils/slim-sourcemap.js +106 -0
  103. package/lib/utils/zip-entries.d.ts +10 -0
  104. package/lib/utils/zip-entries.js +211 -0
  105. package/lib/utils/zip-options.d.ts +17 -0
  106. package/lib/utils/zip-options.js +190 -0
  107. package/lib/utils/zip-range.d.ts +148 -0
  108. package/lib/utils/zip-range.js +581 -0
  109. package/lib/utils/zip-raw-writer.d.ts +52 -0
  110. package/lib/utils/zip-raw-writer.js +209 -0
  111. package/lib/version-operations.d.ts +21 -0
  112. package/lib/version-operations.js +320 -0
  113. package/lib/versions.d.ts +66 -0
  114. package/lib/versions.js +402 -0
  115. package/package.json +113 -0
  116. package/proto/Configuration.proto +183 -0
  117. package/proto/Resources.proto +569 -0
@@ -0,0 +1,227 @@
1
+ /**
2
+ * [INPUT]: 依赖 Node 子进程/文件流/HTTP Range、Pakta CLI 临时目录与 ZIP 读取原语
3
+ * [OUTPUT]: 对外提供 Hermes base 选择、缓存、二进制字面量/指令等价校验、下载、清理及发布元数据能力
4
+ * [POS]: CLI Hermes delta 优化边界,所有失败降级到普通编译,不阻塞发布流程
5
+ */
6
+ import { LiteralResolver } from './hermes-literals';
7
+ export type HermesBaseOption = 'auto' | 'none' | string;
8
+ /**
9
+ * The base cannot be obtained whatever the transport or how often it is
10
+ * retried (wrong content on the server, no bundle in the package, ...).
11
+ */
12
+ export declare class PermanentBaseError extends Error {
13
+ }
14
+ /** The fetched bundle's sha256 differs from what the server recorded. */
15
+ export declare class BundleHashMismatchError extends PermanentBaseError {
16
+ constructor(actual: string, expected: string);
17
+ }
18
+ export interface HermesBaseSelection {
19
+ /** path of the bundle (HBC) handed to hermesc as -base-bytecode */
20
+ path: string;
21
+ bytecodeVersion: number;
22
+ bundleHash: string;
23
+ /** server version id when the base came from the server */
24
+ versionId?: number;
25
+ /** server object key of the base artifact when known */
26
+ hash?: string;
27
+ source: 'cache' | 'download' | 'local' | 'latest-version' | 'native-package';
28
+ }
29
+ /**
30
+ * What became of the base for this build, as reported to the server:
31
+ * - `used`: compiled with -base-bytecode (and, when verification was on,
32
+ * the disassembly matched a plain compile)
33
+ * - `rejected`: the disassembly differed from a plain compile; base dropped
34
+ * - `dump-failed`: the check could not run (dump or plain compile failed);
35
+ * base dropped
36
+ * - `none`: no base (none selected, disabled, or the base compile failed)
37
+ */
38
+ export type HermesBaseOutcome = 'used' | 'rejected' | 'dump-failed' | 'none';
39
+ /** the server column is VARCHAR(500); it truncates too, this just saves bytes */
40
+ export declare const HERMES_BASE_DETAIL_MAX_CHARS = 500;
41
+ /** Metadata attached to version/create so the server can track the chain. */
42
+ export interface HermesBaseMeta {
43
+ bytecodeVersion: number | null;
44
+ baseVersionId: number | null;
45
+ baseHash: string | null;
46
+ /** absent (never null) when the bundle step did not run hermesc */
47
+ hermesBaseOutcome?: HermesBaseOutcome;
48
+ /** first difference / failure reason; absent when there is none */
49
+ hermesBaseDetail?: string;
50
+ }
51
+ /**
52
+ * Hermes V1 (static_h) builds before 2025-07-11 carried a delta-mode bug when a
53
+ * delta-produced base is reused; every released `hermes-compiler` is newer, and
54
+ * classic hermesc (HBC ≤96, react-native/sdks or hermes-engine) upgrades kinds
55
+ * in place and was never affected. Anything else is refused.
56
+ */
57
+ export declare const MIN_HERMES_COMPILER_BUILD = 250829098;
58
+ export declare const MIN_HERMES_COMPILER_COMMITLY_DATE = 20250901;
59
+ export declare function classifyHermesCommand(hermesCommand: string): {
60
+ allowed: boolean;
61
+ kind: 'classic' | 'hermes-compiler' | 'unknown';
62
+ version?: string;
63
+ reason?: string;
64
+ };
65
+ export declare function sha256Hex(data: Buffer): string;
66
+ /** sha256 of a file, streamed (a cached base can be tens of MB) */
67
+ export declare function sha256File(file: string): Promise<string>;
68
+ /** HBC version from the first bytes of a file, without reading the rest */
69
+ export declare function readFileHbcVersion(file: string): Promise<number | null>;
70
+ /**
71
+ * Which HBC version this hermesc emits. The answer is remembered per binary
72
+ * (path, size, mtime) in the cache dir so only the first run of a given
73
+ * hermesc pays for the empty-file compile.
74
+ */
75
+ export declare function probeHbcVersion(hermesCommand: string): number | null;
76
+ export declare const BUNDLE_ENTRY_NAMES: string[];
77
+ export type BaseArtifactType = 'ppk' | 'apk' | 'ipa' | 'app';
78
+ /** Which zip entry holds the JS/HBC bundle in each kind of artifact. */
79
+ export declare function bundleEntryMatcher(artifactType: BaseArtifactType): (name: string) => boolean;
80
+ /**
81
+ * Extract the JS/HBC bundle from a local artifact: a raw bundle file, a ppk,
82
+ * or a native package (apk / ipa / harmony app). Returns null when not found.
83
+ */
84
+ export declare function extractBundleFromArchive(filePath: string): Promise<Buffer | null>;
85
+ export declare const DEFAULT_CACHE_MAX_BYTES: number;
86
+ export declare const DEFAULT_CACHE_MAX_FILES = 20;
87
+ export declare function cacheDir(): string;
88
+ export declare function tmpDir(): string;
89
+ export declare function cacheLimits(overrideMaxMb?: number): {
90
+ maxBytes: number;
91
+ maxFiles: number;
92
+ };
93
+ /** Returns the cached bundle path when present and its sha256 still matches. */
94
+ export declare function cacheLookup(bundleHash: string): Promise<string | null>;
95
+ /** Store a bundle under its sha256 (LRU-evicting to the configured limits). */
96
+ export declare function cachePut(bundle: Buffer, maxMb?: number, knownHash?: string): Promise<{
97
+ path: string;
98
+ bundleHash: string;
99
+ }>;
100
+ export declare function enforceCacheLimits(maxMb?: number, keep?: string): Promise<void>;
101
+ /** Remove every cached bundle (and staging leftovers); returns the bundle count. */
102
+ export declare function cleanCache(): Promise<number>;
103
+ export declare function cacheStats(): Promise<{
104
+ dir: string;
105
+ files: number;
106
+ bytes: number;
107
+ }>;
108
+ /** Remove leftovers of interrupted runs (older than 24h) from the tmp dir. */
109
+ export declare function cleanStaleTmp(maxAgeMs?: number): Promise<void>;
110
+ export declare function downloadToFile(url: string, destination: string): Promise<void>;
111
+ export interface HermesBaseServerRecord {
112
+ versionId?: number | null;
113
+ hash: string;
114
+ artifactType?: BaseArtifactType;
115
+ bundleHash?: string | null;
116
+ bytecodeVersion?: number | null;
117
+ url: string;
118
+ /**
119
+ * Location of the bundle's compressed bytes inside the ppk, reported by the
120
+ * publishing CLI; lets the base be fetched with a single HTTP Range request.
121
+ */
122
+ bundleOffset?: number | null;
123
+ bundleCompressedSize?: number | null;
124
+ /** zip compression method: 0 stored, 8 deflate */
125
+ bundleCompression?: number | null;
126
+ }
127
+ interface FetchedBaseBundle {
128
+ bundle: Buffer;
129
+ /** sha256 of `bundle`, computed once here */
130
+ bundleHash: string;
131
+ /** how the bytes were obtained, for the log line */
132
+ transport: 'range-entry' | 'range-zip' | 'full';
133
+ fetchedBytes?: number;
134
+ totalBytes?: number;
135
+ }
136
+ /**
137
+ * Obtain the base bundle with as little traffic as possible, in order:
138
+ * 1. one Range request for the bundle's compressed bytes when the server
139
+ * knows their location (ppk / apk / ipa published by a CLI that
140
+ * reported it);
141
+ * 2. the archive's central directory over Range, then just the bundle
142
+ * entry (any zip: ppk, apk, ipa — harmony .app nests a second zip and
143
+ * is skipped);
144
+ * 3. the whole archive, as before.
145
+ * A server that ignores Range (HTTP 200) streams the full archive into
146
+ * `archive` without a second request. Every result is verified against
147
+ * `record.bundleHash`. A mismatch of the located bytes (1) may only mean the
148
+ * recorded location is stale, so the directory transport (2) still runs; a
149
+ * mismatch of the entry itself (2, 3) is final — the same bytes would come
150
+ * back however they are fetched — and raises BundleHashMismatchError.
151
+ */
152
+ export declare function fetchBaseBundle(record: HermesBaseServerRecord, artifactType: BaseArtifactType, archive: string, log?: (message: string) => void): Promise<FetchedBaseBundle>;
153
+ export interface ResolveHermesBaseParams {
154
+ option: HermesBaseOption;
155
+ hermesCommand: string;
156
+ bytecodeVersion: number;
157
+ appId?: string;
158
+ cacheMaxMb?: number;
159
+ /**
160
+ * server lookup; returns null when the app has no usable base. The server
161
+ * itself falls back to the newest legacy version, then the newest native
162
+ * package (bytecodeVersion is null and verified here after download).
163
+ */
164
+ fetchBase: (appId: string, bytecodeVersion: number) => Promise<HermesBaseServerRecord | null>;
165
+ log?: (message: string) => void;
166
+ }
167
+ /**
168
+ * Pick and materialize the base bundle for this compile. Returns null (with
169
+ * the reason logged) whenever a base cannot be used; callers then compile
170
+ * without one.
171
+ */
172
+ export declare function resolveHermesBase(params: ResolveHermesBaseParams): Promise<HermesBaseSelection | null>;
173
+ export declare function hermescArgsWithBase(baseArgs: string[], basePath: string | null): string[];
174
+ export declare function hermesBaseMeta(selection: HermesBaseSelection | null, bytecodeVersion: number | null, check?: {
175
+ outcome: HermesBaseOutcome;
176
+ detail?: string;
177
+ }): HermesBaseMeta;
178
+ /** one line, at most HERMES_BASE_DETAIL_MAX_CHARS code points; '' when empty */
179
+ export declare function truncateHermesBaseDetail(detail: string | undefined): string;
180
+ /**
181
+ * Normalize one disassembly line so that a delta-mode compile and a plain
182
+ * compile of the same source compare equal: string IDs are renumbered, literal
183
+ * buffers are laid out differently (offsets, short/long variants), and jump
184
+ * distances follow instruction widths. Everything else must match exactly.
185
+ */
186
+ /** separates rendered literal entries inside one normalized line */
187
+ export declare const LITERAL_SEPARATOR = "\u001F";
188
+ export declare function normalizeDisassemblyLine(line: string, strings: Map<number, string>, literals?: LiteralResolver): string | null;
189
+ /** How an equivalence check ended. */
190
+ export type HermesEquivalenceStatus = 'equivalent' | 'different' | 'dump-failed';
191
+ export interface HermesEquivalenceResult {
192
+ status: HermesEquivalenceStatus;
193
+ /**
194
+ * one line for the log: where the first difference is (function, line,
195
+ * both sides) or why a dump could not be read
196
+ */
197
+ detail?: string;
198
+ /** functions compared on both sides */
199
+ functions: number;
200
+ /**
201
+ * `instruction`: literals decoded from the binary buffers at each
202
+ * New*WithBuffer instruction (HBC v87–96 and v98); `buffer`: the dumped
203
+ * buffers compared as a whole (unknown layout)
204
+ */
205
+ literals?: 'instruction' | 'buffer';
206
+ }
207
+ export interface HermesEquivalenceOptions {
208
+ /** write each side's raw disassembly here (bug reports) */
209
+ dumpTo?: {
210
+ withBase: string;
211
+ plain: string;
212
+ };
213
+ }
214
+ /**
215
+ * Compare two HBC files by disassembly (see normalizeDisassemblyLine): the
216
+ * literal buffers by content, then function by function. `-b` forces hermesc
217
+ * to treat inputs as bytecode whatever their extension. Both dumps are
218
+ * consumed as streams so the ~100 MB of text never touches the disk (unless
219
+ * `dumpTo` asks for it). A dump process that fails or ends early is reported
220
+ * as `dump-failed`, never as a difference: the two cases need different
221
+ * follow-ups. The detail names the first difference so a rejected base can be
222
+ * turned into a normalization rule or a bug report.
223
+ */
224
+ export declare function compareHermesBytecode(hermesCommand: string, withBase: string, plain: string, options?: HermesEquivalenceOptions): Promise<HermesEquivalenceResult>;
225
+ /** Resolves true when equivalent; see compareHermesBytecode for the details. */
226
+ export declare function verifyHermesBaseEquivalence(hermesCommand: string, withBase: string, plain: string): Promise<boolean>;
227
+ export {};