MCPcopy Create free account
hub / github.com/reactnativecn/react-native-update / readBundleMetadata

Function readBundleMetadata

scripts/read.js:9–21  ·  view source on GitHub ↗

* 从 Hermes 字节码文件中读取 metadata * 支持两种方式: * 1. 从文件末尾的自定义 Meta 块读取(新方式,推荐) * 2. 从 Hermes -meta 参数注入的数据读取(旧方式,备用)

(filePath)

Source from the content-addressed store, hash-verified

7 * 2. 从 Hermes -meta 参数注入的数据读取(旧方式,备用)
8 */
9function readBundleMetadata(filePath) {
10 const buffer = fs.readFileSync(filePath);
11
12 // 优先尝试从文件末尾的自定义 Meta 块读取
13 const metaFromFooter = readMetadataFromHBCFooter(buffer);
14 if (metaFromFooter) {
15 return metaFromFooter;
16 }
17
18 // 如果末尾没有 Meta 块,尝试从 Hermes -meta 参数注入的数据读取(备用方案)
19 console.log('No metadata footer found, trying to read from Hermes -meta parameter...');
20 return readMetadataFromHermesMeta(buffer);
21}
22
23/**
24 * 从 HBC 文件末尾的自定义 Meta 块读取元数据

Callers 1

read.jsFile · 0.85

Calls 2

Tested by

no test coverage detected