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 SourceMap::generated_position_for lookup.
LazySourceMap
A lazily-decoded source map that defers VLQ mappings decoding until needed.
MappedRange
A mapped range: original start/end positions for a generated range.
Mapping
A single decoded mapping entry. Compact at 28 bytes (6 × u32 + bool with padding).
MappingsIter
Lazy iterator over VLQ-encoded source map mappings.
OriginalLocation
Result of an SourceMap::original_position_for lookup.
SourceMap
A fully-parsed source map with O(log n) position lookups.
SourceMapBuilder
Builder for incrementally constructing a SourceMap from iterators.

Enums§

Bias
Search bias for position lookups.
ParseError
Errors that can occur during source map parsing.
SourceMappingUrl
Result of parsing a sourceMappingURL reference.

Functions§

parse_source_mapping_url
Extract the sourceMappingURL from generated source code.
validate_deep
Validate a source map with deep structural checks.