Expand description
This library implements basic processing of JavaScript sourcemaps.
§Installation
The crate is called sourcemap and you can depend on it via cargo:
[dependencies]
sourcemap = "*"
If you want to use the git version:
[dependencies.sourcemap]
git = "https://github.com/getsentry/rust-sourcemap.git"
§Basic Operation
This crate can load JavaScript sourcemaps from JSON files. It uses
serde
for parsing of the JSON data. Due to the nature of sourcemaps
the entirety of the file must be loaded into memory which can be quite
memory intensive.
Usage:
use sourcemap::SourceMap;
let input: &[_] = b"{
\"version\":3,
\"sources\":[\"coolstuff.js\"],
\"names\":[\"x\",\"alert\"],
\"mappings\":\"AAAA,GAAIA,GAAI,EACR,IAAIA,GAAK,EAAG,CACVC,MAAM\"
}";
let sm = SourceMap::from_reader(input).unwrap();
let token = sm.lookup_token(0, 0).unwrap(); // line-number and column
println!("token: {}", token);
§Features
Functionality of the crate can be turned on and off by feature flags. This is the current list of feature flags:
ram_bundle
: turns on RAM bundle support
Modules§
- ram_
bundle - RAM bundle operations
- vlq
- Implements utilities for dealing with the sourcemap vlq encoding.
Structs§
- Name
Iter - Iterates over all tokens in a sourcemap
- RawToken
- Represents a raw token
- Rewrite
Options - Controls the
SourceMap::rewrite
behavior - Source
Contents Iter - Iterates over all source contents in a sourcemap
- Source
Iter - Iterates over all sources in a sourcemap
- Source
Map - Represents a sourcemap in memory
- Source
MapBuilder - Helper for sourcemap generation
- Source
MapHermes - Represents a
react-native
-style SourceMap, which has additional scope information embedded. - Source
MapIndex - Represents a sourcemap index in memory
- Source
MapSection - Represents a section in a sourcemap index
- Source
MapSection Iter - Iterates over all sections in a sourcemap index
- Source
View - Provides efficient access to minified sources.
- Token
- Represents a token from a sourcemap
- Token
Iter - Iterates over all tokens in a sourcemap
Enums§
- Decoded
Map - Represents the result of a decode operation
- Error
- Represents different failure cases
- Source
MapRef - Represents a reference to a sourcemap
Functions§
- decode
- Decodes a sourcemap or sourcemap index from a reader
- decode_
data_ url - Loads a sourcemap from a data URL
- decode_
slice - Decodes a sourcemap or sourcemap index from a byte slice
- is_
sourcemap - Checks if a valid sourcemap can be read from the given reader
- is_
sourcemap_ slice - Checks if the given byte slice contains a sourcemap
- locate_
sourcemap_ reference - Locates a sourcemap reference
- locate_
sourcemap_ reference_ slice - Locates a sourcemap reference in a slice
- make_
relative_ path - Helper function to calculate the path from a base file to a target file.
Type Aliases§
- Result
- Represents results from this library