pub struct SourceMapIndex { /* private fields */ }Expand description
Represents a sourcemap index in memory
Implementations§
Source§impl SourceMapIndex
impl SourceMapIndex
Sourcepub fn from_reader<R: Read>(rdr: R) -> Result<SourceMapIndex>
pub fn from_reader<R: Read>(rdr: R) -> Result<SourceMapIndex>
Creates a sourcemap index from a reader over a JSON stream in UTF-8 format. Optionally a “garbage header” as defined by the sourcemap draft specification is supported. In case a regular sourcemap is encountered an error is returned.
Sourcepub fn from_slice(slice: &[u8]) -> Result<SourceMapIndex>
pub fn from_slice(slice: &[u8]) -> Result<SourceMapIndex>
Creates a sourcemap index from a reader over a JSON byte slice in UTF-8 format. Optionally a “garbage header” as defined by the sourcemap draft specification is supported. In case a regular sourcemap is encountered an error is returned.
Sourcepub fn new(
file: Option<String>,
sections: Vec<SourceMapSection>,
) -> SourceMapIndex
pub fn new( file: Option<String>, sections: Vec<SourceMapSection>, ) -> SourceMapIndex
Constructs a new sourcemap index from raw components.
file: an optional filename of the indexsections: a vector of source map index sections
Sourcepub fn new_ram_bundle_compatible(
file: Option<String>,
sections: Vec<SourceMapSection>,
x_facebook_offsets: Option<Vec<Option<u32>>>,
x_metro_module_paths: Option<Vec<String>>,
) -> SourceMapIndex
pub fn new_ram_bundle_compatible( file: Option<String>, sections: Vec<SourceMapSection>, x_facebook_offsets: Option<Vec<Option<u32>>>, x_metro_module_paths: Option<Vec<String>>, ) -> SourceMapIndex
Constructs a new sourcemap index from raw components including the facebook RAM bundle extensions.
file: an optional filename of the indexsections: a vector of source map index sectionsx_facebook_offsets: a vector of facebook offsetsx_metro_module_paths: a vector of metro module paths
Sourcepub fn get_section_count(&self) -> u32
pub fn get_section_count(&self) -> u32
Returns the number of sections in this index
Sourcepub fn get_section(&self, idx: u32) -> Option<&SourceMapSection>
pub fn get_section(&self, idx: u32) -> Option<&SourceMapSection>
Looks up a single section and returns it
Sourcepub fn get_section_mut(&mut self, idx: u32) -> Option<&mut SourceMapSection>
pub fn get_section_mut(&mut self, idx: u32) -> Option<&mut SourceMapSection>
Looks up a single section and returns it as a mutable ref
Sourcepub fn sections(&self) -> SourceMapSectionIter<'_> ⓘ
pub fn sections(&self) -> SourceMapSectionIter<'_> ⓘ
Iterates over all sections
Sourcepub fn lookup_token(&self, line: u32, col: u32) -> Option<Token<'_>>
pub fn lookup_token(&self, line: u32, col: u32) -> Option<Token<'_>>
Looks up the closest token to a given line and column.
This requires that the referenced sourcemaps are actually loaded. If a sourcemap is encountered that is not embedded but just externally referenced it is silently skipped.
Sourcepub fn flatten(&self) -> Result<SourceMap>
pub fn flatten(&self) -> Result<SourceMap>
Flattens an indexed sourcemap into a regular one. This requires that all referenced sourcemaps are attached.
Sourcepub fn flatten_and_rewrite(
self,
options: &RewriteOptions<'_>,
) -> Result<SourceMap>
pub fn flatten_and_rewrite( self, options: &RewriteOptions<'_>, ) -> Result<SourceMap>
Flattens an indexed sourcemap into a regular one and automatically rewrites it. This is more useful than plain flattening as this will cause the sourcemap to be properly deduplicated.
Sourcepub fn is_for_ram_bundle(&self) -> bool
pub fn is_for_ram_bundle(&self) -> bool
Returns true if this sourcemap is for a RAM bundle.
Sourcepub fn x_facebook_offsets(&self) -> Option<&[Option<u32>]>
pub fn x_facebook_offsets(&self) -> Option<&[Option<u32>]>
Returns embeded x-facebook-offset values.
Sourcepub fn x_metro_module_paths(&self) -> Option<&[String]>
pub fn x_metro_module_paths(&self) -> Option<&[String]>
Returns embedded metro module paths.