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§
- Generated
Location - Result of a
generated_position_forlookup. - Mapping
- A single decoded mapping entry. Compact at 24 bytes (6 × u32).
- Original
Location - Result of an
original_position_forlookup. - Source
Map - A parsed source map with O(log n) position lookups.
Enums§
- Parse
Error - Errors during source map parsing.