srcmap-ram-bundle 0.2.3

React Native RAM bundle parser for source map tooling
Documentation
  • Coverage
  • 100%
    23 out of 23 items documented1 out of 12 items with examples
  • Size
  • Source code size: 23.53 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.65 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 26s Average build duration of successful builds.
  • all releases: 28s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • BartWaardenburg/srcmap
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • BartWaardenburg

srcmap-ram-bundle

crates.io docs.rs

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

Usage

use srcmap_ram_bundle::{IndexedRamBundle, is_ram_bundle};

let data = std::fs::read("app.bundle").unwrap();

if is_ram_bundle(&data) {
    let bundle = IndexedRamBundle::from_bytes(&data).unwrap();

    println!("Startup code: {} bytes", bundle.startup_code().len());
    println!("Modules: {}", bundle.module_count());

    for module in bundle.modules() {
        println!("Module {}: {} bytes", module.id, module.source_code.len());
    }
}

API

Item Kind Description
IndexedRamBundle struct Parsed indexed RAM bundle (iOS format)
IndexedRamBundle::from_bytes(data) fn Parse from raw bytes
IndexedRamBundle::module_count() fn Number of module slots
IndexedRamBundle::get_module(id) fn Get a module by ID, or None if the slot is empty
IndexedRamBundle::modules() fn Iterate over all non-empty modules
IndexedRamBundle::startup_code() fn Returns the startup (prelude) code
RamBundleModule struct A parsed module with id and source_code fields
RamBundleType enum Indexed (iOS) or Unbundle (Android)
RamBundleError enum Error type: InvalidMagic, TooShort, InvalidEntry, Io, SourceMap
is_ram_bundle(data) fn Check if data starts with the RAM bundle magic number
is_unbundle_dir(path) fn Check if a path looks like an unbundle directory

Part of srcmap

See the main repo for the full source map SDK.

License

MIT