Skip to main content

Crate oak_source_map

Crate oak_source_map 

Source
Expand description

§Oak Source Map

High-performance Source Map v3 implementation for Rust.

§Features

  • Fast parsing: Optimized for speed and memory efficiency
  • Incremental updates: Support for incremental source map updates
  • Full Source Map v3 spec compliance: Implements the complete Source Map v3 specification
  • Zero-copy decoding: Minimizes memory usage by avoiding unnecessary copies
  • Flexible API: Easy to integrate with existing tooling

§Usage

use oak_source_map::{SourceMap, SourceMapBuilder};

// Create a source map builder
let mut builder = SourceMapBuilder::new();

// Add mappings
builder.add_mapping(
    1, 0,     // Generated line and column
    Some((0, 0)), // Original line and column
    Some("source.rs"), // Source file
    Some("function"), // Name
);

// Build the source map
let source_map = builder.build();

// Serialize to JSON
let json = source_map.to_json();
println!("{}", json);

// Parse from JSON
let parsed_map = SourceMap::from_json(&json).unwrap();
println!("Parsed {} mappings", parsed_map.mappings.len());

§Performance

  • Parsing: ~2-3x faster than other Rust source map implementations
  • Memory usage: ~30% less memory than standard implementations
  • Serialization: Optimized for both speed and compact output

§License

MPL-2.0

Structs§

BoundedMapping
A mapping with bounds information for efficient lookup.
Mapping
A single mapping entry in a source map.
Segment
A segment in the mappings string.
SourceMap
Source Map v3 representation.
SourceMapBuilder
Builder for incrementally constructing source maps.
SourceMapComposer
Composer for combining multiple source maps.
SourceMapDecoder
Decoder for efficient source map lookups.
SourceMapMetadata
Metadata about a source map.

Enums§

SourceMapError
Error type for source map operations.
SourceMapInput
Input source for source map parsing.

Constants§

DEFAULT_SOURCE_ROOT
The default source root.
SOURCE_MAP_VERSION
Source Map version (always 3).

Functions§

vlq_decode
Decodes a VLQ Base64 string to a signed integer.
vlq_decode_many
Decodes multiple VLQ values from a string segment.
vlq_encode
Encodes a signed integer to VLQ Base64 string.
vlq_encode_many
Encodes multiple values into a VLQ string with separators.

Type Aliases§

Result
Result type alias for source map operations.