Skip to main content

Crate srcmap_sourcemap

Crate srcmap_sourcemap 

Source
Expand description

High-performance source map parser and consumer (ECMA-426).

Parses source map JSON and provides O(log n) position lookups. Uses a flat, cache-friendly representation internally.

§Examples

use srcmap_sourcemap::SourceMap;

let json = r#"{"version":3,"sources":["input.js"],"names":[],"mappings":"AAAA;AACA"}"#;
let sm = SourceMap::from_json(json).unwrap();

// Look up original position for generated line 0, column 0
let loc = sm.original_position_for(0, 0).unwrap();
assert_eq!(sm.source(loc.source), "input.js");
assert_eq!(loc.line, 0);
assert_eq!(loc.column, 0);

// Reverse lookup
let pos = sm.generated_position_for("input.js", 0, 0).unwrap();
assert_eq!(pos.line, 0);
assert_eq!(pos.column, 0);

Structs§

GeneratedLocation
Result of a generated_position_for lookup.
Mapping
A single decoded mapping entry. Compact at 24 bytes (6 × u32).
OriginalLocation
Result of an original_position_for lookup.
SourceMap
A parsed source map with O(log n) position lookups.

Enums§

ParseError
Errors during source map parsing.