Skip to main content

Crate srcmap_ram_bundle

Crate srcmap_ram_bundle 

Source
Expand description

React Native RAM bundle parser for source map tooling.

Supports two RAM bundle formats used by React Native / Metro:

  • Indexed RAM bundles (iOS): single binary file with magic number 0xFB0BD1E5
  • Unbundles (Android): directory-based with js-modules/ structure

§Examples

use srcmap_ram_bundle::{IndexedRamBundle, is_ram_bundle};

// Build a minimal RAM bundle for demonstration
let startup = b"var startup = true;";
let module0 = b"__d(function(){},0);";

let mut data = Vec::new();
// Magic number
data.extend_from_slice(&0xFB0BD1E5_u32.to_le_bytes());
// Module count: 1
data.extend_from_slice(&1_u32.to_le_bytes());
// Startup code size
data.extend_from_slice(&(startup.len() as u32).to_le_bytes());
// Module table entry: offset 0, length of module0
data.extend_from_slice(&0_u32.to_le_bytes());
data.extend_from_slice(&(module0.len() as u32).to_le_bytes());
// Startup code
data.extend_from_slice(startup);
// Module code
data.extend_from_slice(module0);

assert!(is_ram_bundle(&data));

let bundle = IndexedRamBundle::from_bytes(&data).unwrap();
assert_eq!(bundle.startup_code(), "var startup = true;");
assert_eq!(bundle.module_count(), 1);
assert_eq!(bundle.get_module(0).unwrap().source_code, "__d(function(){},0);");

Structs§

IndexedRamBundle
A parsed indexed RAM bundle.
RamBundleModule
A parsed RAM bundle module.

Enums§

RamBundleError
Error type for RAM bundle operations.
RamBundleType
Type of RAM bundle.

Functions§

is_ram_bundle
Check if data starts with the RAM bundle magic number.
is_unbundle_dir
Check if a path looks like an unbundle (file RAM bundle) directory.