react-native-update-cli 2.28.2 → 2.29.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/package.js CHANGED
@@ -154,6 +154,11 @@ async function uploadNativePackage(filePath, options, config) {
154
154
  // against the client-reported bundleHash to decide pdiff applicability.
155
155
  // Old servers strip unknown fields, so this is forward-compatible.
156
156
  ...(bundleHash ? { bundleHash } : {}),
157
+ // HBC version of the embedded bundle (0 = plain JS), so the server
158
+ // offers this package as hermes base only to a matching compile
159
+ ...(bundleFile
160
+ ? { bytecodeVersion: (0, hermes_base_1.reportedBytecodeVersion)(bundleFile) }
161
+ : {}),
157
162
  ...bundleLocation,
158
163
  deps: (0, dep_versions_1.getDepVersions)(),
159
164
  commit: await (0, git_1.getCommitInfo)(),
@@ -35,7 +35,30 @@ const HBC_HEADER_SIZE = 128;
35
35
  const FUNC_OFFSET_25 = { byte: 0, bit: 0, bits: 25 };
36
36
  const STRING_OFFSET_23 = { byte: 0, bit: 1, bits: 23 };
37
37
  const PAIR_OFFSET_32 = { byte: 0, bit: 0, bits: 32 };
38
- // v98 两种头部变体共享的段布局
38
+ // 晚期 v98 与 v99 共用的头部计数字段
39
+ const V98_LATE_HEADER_FIELDS = [
40
+ 'fileLength',
41
+ 'globalCodeIndex',
42
+ 'functionCount',
43
+ 'stringKindCount',
44
+ 'identifierCount',
45
+ 'stringCount',
46
+ 'overflowStringCount',
47
+ 'stringStorageSize',
48
+ 'bigIntCount',
49
+ 'bigIntStorageSize',
50
+ 'regExpCount',
51
+ 'regExpStorageSize',
52
+ 'literalValueBufferSize',
53
+ 'objKeyBufferSize',
54
+ 'objShapeTableCount',
55
+ 'numStringSwitchImms',
56
+ 'segmentID',
57
+ 'cjsModuleCount',
58
+ 'functionSourceCount',
59
+ 'debugInfoOffset',
60
+ ];
61
+ // v98 两种头部变体(及 v99)共享的段布局
39
62
  const V98_SECTIONS = [
40
63
  {
41
64
  name: 'functionHeaders',
@@ -184,28 +207,16 @@ exports.HBC_LAYOUTS = [
184
207
  // 段布局与早期 v98 相同。
185
208
  minVersion: 98,
186
209
  maxVersion: 98,
187
- headerFields: [
188
- 'fileLength',
189
- 'globalCodeIndex',
190
- 'functionCount',
191
- 'stringKindCount',
192
- 'identifierCount',
193
- 'stringCount',
194
- 'overflowStringCount',
195
- 'stringStorageSize',
196
- 'bigIntCount',
197
- 'bigIntStorageSize',
198
- 'regExpCount',
199
- 'regExpStorageSize',
200
- 'literalValueBufferSize',
201
- 'objKeyBufferSize',
202
- 'objShapeTableCount',
203
- 'numStringSwitchImms',
204
- 'segmentID',
205
- 'cjsModuleCount',
206
- 'functionSourceCount',
207
- 'debugInfoOffset',
208
- ],
210
+ headerFields: V98_LATE_HEADER_FIELDS,
211
+ sections: V98_SECTIONS,
212
+ },
213
+ {
214
+ // Hermes V1 v99(hermes-compiler 260318099,RN 0.88+):文件头与段布局
215
+ // 同晚期 v98,只改了函数头内部位域(去 NumCacheNewObject)与操作码表,
216
+ // 二者都不在本变换触及的范围内。
217
+ minVersion: 99,
218
+ maxVersion: 99,
219
+ headerFields: V98_LATE_HEADER_FIELDS,
209
220
  sections: V98_SECTIONS,
210
221
  },
211
222
  {
@@ -16,6 +16,14 @@ export declare class HbcVersionMismatchError extends PermanentBaseError {
16
16
  readonly expected: number;
17
17
  constructor(version: number | null, expected: number);
18
18
  }
19
+ /**
20
+ * `bytecodeVersion` reported for a bundle that is not Hermes bytecode, so the
21
+ * server can tell "plain JS" from "not reported" (NULL) and never offers it
22
+ * as a base.
23
+ */
24
+ export declare const PLAIN_JS_BYTECODE_VERSION = 0;
25
+ /** the `bytecodeVersion` to report for `bundle` at publish / upload time */
26
+ export declare function reportedBytecodeVersion(bundle: Buffer): number;
19
27
  export interface HermesBaseSelection {
20
28
  /** path of the bundle (HBC) handed to hermesc as -base-bytecode */
21
29
  path: string;
@@ -46,7 +46,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
46
46
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
47
  };
48
48
  Object.defineProperty(exports, "__esModule", { value: true });
49
- exports.LITERAL_SEPARATOR = exports.DEFAULT_CACHE_MAX_FILES = exports.DEFAULT_CACHE_MAX_BYTES = exports.BUNDLE_ENTRY_NAMES = exports.MIN_HERMES_COMPILER_COMMITLY_DATE = exports.MIN_HERMES_COMPILER_BUILD = exports.HERMES_BASE_DETAIL_MAX_CHARS = exports.HbcVersionMismatchError = exports.BundleHashMismatchError = exports.PermanentBaseError = void 0;
49
+ exports.LITERAL_SEPARATOR = exports.DEFAULT_CACHE_MAX_FILES = exports.DEFAULT_CACHE_MAX_BYTES = exports.BUNDLE_ENTRY_NAMES = exports.MIN_HERMES_COMPILER_COMMITLY_DATE = exports.MIN_HERMES_COMPILER_BUILD = exports.HERMES_BASE_DETAIL_MAX_CHARS = exports.PLAIN_JS_BYTECODE_VERSION = exports.HbcVersionMismatchError = exports.BundleHashMismatchError = exports.PermanentBaseError = void 0;
50
+ exports.reportedBytecodeVersion = reportedBytecodeVersion;
50
51
  exports.classifyHermesCommand = classifyHermesCommand;
51
52
  exports.sha256Hex = sha256Hex;
52
53
  exports.sha256File = sha256File;
@@ -110,12 +111,25 @@ class HbcVersionMismatchError extends PermanentBaseError {
110
111
  version;
111
112
  expected;
112
113
  constructor(version, expected) {
113
- super(`downloaded base is HBC ${version ?? 'n/a'}, need ${expected}`);
114
+ super(`downloaded base is ${version == null ? 'plain JS' : `HBC ${version}`}, need ${expected}`);
114
115
  this.version = version;
115
116
  this.expected = expected;
116
117
  }
117
118
  }
118
119
  exports.HbcVersionMismatchError = HbcVersionMismatchError;
120
+ /**
121
+ * `bytecodeVersion` reported for a bundle that is not Hermes bytecode, so the
122
+ * server can tell "plain JS" from "not reported" (NULL) and never offers it
123
+ * as a base.
124
+ */
125
+ exports.PLAIN_JS_BYTECODE_VERSION = 0;
126
+ /** the `bytecodeVersion` to report for `bundle` at publish / upload time */
127
+ function reportedBytecodeVersion(bundle) {
128
+ return (0, hbcTransform_1.getHbcVersion)(bundle) ?? exports.PLAIN_JS_BYTECODE_VERSION;
129
+ }
130
+ const describeBytecodeVersion = (version) => version === exports.PLAIN_JS_BYTECODE_VERSION
131
+ ? 'plain JS'
132
+ : `HBC ${version ?? 'n/a'}`;
119
133
  /** bytes `getHbcVersion` needs to read the version */
120
134
  const HBC_HEAD_BYTES = 128;
121
135
  /** time allowed for a response to start (headers) */
@@ -744,7 +758,7 @@ async function resolveHermesBase(params) {
744
758
  if (record.bytecodeVersion != null &&
745
759
  record.bytecodeVersion !== bytecodeVersion) {
746
760
  log((0, i18n_1.t)('hermesBaseNone', {
747
- reason: `server base is HBC ${record.bytecodeVersion}, need ${bytecodeVersion}`,
761
+ reason: `server base is ${describeBytecodeVersion(record.bytecodeVersion)}, need ${bytecodeVersion}`,
748
762
  }));
749
763
  return null;
750
764
  }
@@ -46,7 +46,8 @@ async function readHermesSemanticData(file) {
46
46
  // A newly added diff-transform layout must not silently opt into semantic
47
47
  // parsing: function header and operand schemas need an independent review.
48
48
  if (!((resolved.version >= 87 && resolved.version <= 96) ||
49
- resolved.version === 98)) {
49
+ resolved.version === 98 ||
50
+ resolved.version === 99)) {
50
51
  throw new UnverifiableHermesBytecode('unsupported semantic HBC version');
51
52
  }
52
53
  const layout = requireValue((0, hbcTransform_1.pickLayout)(bytes), 'unknown HBC layout');
@@ -80,7 +81,11 @@ async function readHermesSemanticData(file) {
80
81
  // hbcTransform's file-header variants do not distinguish that function
81
82
  // schema change. A compiler upgrade needs independent large/small fixtures;
82
83
  // do not infer either schema from numStringSwitchImms or HBC version alone.
83
- const shaped = resolved.version === 98;
84
+ // Audited v99 function schema: hermes-compiler 260318099.0.4 (RN 0.88), the
85
+ // first HBC bump after that removal, so it always has the 36-byte form.
86
+ const shaped = resolved.version >= 98;
87
+ const noCacheNewObject = resolved.version === 99;
88
+ const largeSize = noCacheNewObject ? 36 : 37;
84
89
  const entrySize = shaped ? 12 : 16;
85
90
  const headers = section('functionHeaders');
86
91
  const functions = [];
@@ -97,15 +102,15 @@ async function readHermesSemanticData(file) {
97
102
  const largeOffset = shaped
98
103
  ? ((word1 >>> 14) & 0xff) * 0x1000000 + offset
99
104
  : (headers.readUInt32LE(at + 8) & 0x1ffffff) * 0x10000 + offset;
100
- const large = checkedSlice(bytes, largeOffset, shaped ? 37 : 31);
105
+ const large = checkedSlice(bytes, largeOffset, shaped ? largeSize : 31);
101
106
  offset = large.readUInt32LE(0);
102
107
  size = large.readUInt32LE(shaped ? 12 : 8);
103
108
  name = large.readUInt32LE(shaped ? 16 : 12);
104
- flags = large[shaped ? 36 : 30];
109
+ flags = large[shaped ? largeSize - 1 : 30];
105
110
  fields = shaped
106
111
  ? [4, 8, 20, 24, 28].map((p) => large.readUInt32LE(p))
107
112
  : [4, 20, 24].map((p) => large.readUInt32LE(p));
108
- fields.push(...large.subarray(shaped ? 32 : 28, shaped ? 36 : 30));
113
+ fields.push(...large.subarray(shaped ? 32 : 28, shaped ? largeSize - 1 : 30));
109
114
  }
110
115
  else if (shaped) {
111
116
  size = word1 & 0x3fff;
@@ -117,9 +122,13 @@ async function readHermesSemanticData(file) {
117
122
  word1 >>> 27,
118
123
  headers[at + 8],
119
124
  headers[at + 9],
120
- headers[at + 10] & 63,
121
- (headers[at + 10] >>> 6) & 1,
122
- headers[at + 10] >>> 7,
125
+ ...(noCacheNewObject
126
+ ? [headers[at + 10] & 127, headers[at + 10] >>> 7]
127
+ : [
128
+ headers[at + 10] & 63,
129
+ (headers[at + 10] >>> 6) & 1,
130
+ headers[at + 10] >>> 7,
131
+ ]),
123
132
  ];
124
133
  }
125
134
  else {
@@ -344,6 +353,10 @@ function normalizeRawHermesFunction(lines, data, functionIndex, buffers) {
344
353
  operands[shapeAt + 1] = requireValue(literal.objectValues(values[shapeAt + 1], shape.count), 'undecodable shape values');
345
354
  }
346
355
  }
356
+ else if (op === 'NewTypedObjectWithBuffer') {
357
+ // HBC v99 typed-mode buffer user; its literal operands are not decoded.
358
+ throw new UnverifiableHermesBytecode('typed object literal buffer');
359
+ }
347
360
  else if (op === 'CacheNewObject') {
348
361
  if (buffers.layout !== 'shaped' || values.length !== 4) {
349
362
  throw new UnverifiableHermesBytecode('unknown cached object operands');
package/lib/versions.js CHANGED
@@ -17,7 +17,6 @@ const package_1 = require("./package");
17
17
  const utils_1 = require("./utils");
18
18
  const dep_versions_1 = require("./utils/dep-versions");
19
19
  const git_1 = require("./utils/git");
20
- const hbcTransform_1 = require("./utils/hbcTransform");
21
20
  const hermes_base_1 = require("./utils/hermes-base");
22
21
  const i18n_1 = require("./utils/i18n");
23
22
  const options_1 = require("./utils/options");
@@ -344,9 +343,8 @@ async function describePpkBundle(ppkPath, base) {
344
343
  if (bundle) {
345
344
  const bundleHash = (0, hermes_base_1.sha256Hex)(bundle);
346
345
  meta.bundleHash = bundleHash;
347
- const hbcVersion = (0, hbcTransform_1.getHbcVersion)(bundle) ?? base?.bytecodeVersion;
348
- if (hbcVersion != null)
349
- meta.bytecodeVersion = hbcVersion;
346
+ // 0 for plain JS: the server then never offers it as a Hermes base
347
+ meta.bytecodeVersion = (0, hermes_base_1.reportedBytecodeVersion)(bundle);
350
348
  await (0, hermes_base_1.cachePut)(bundle, undefined, bundleHash).catch(() => { });
351
349
  Object.assign(meta, (0, zip_range_1.bundleLocationFields)(found?.location));
352
350
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.28.2",
3
+ "version": "2.29.0",
4
4
  "description": "command line tool for react-native-update (remote updates for react native)",
5
5
  "main": "lib/exports.js",
6
6
  "types": "lib/exports.d.ts",