Skip to main content

SourceMapIndex

Struct SourceMapIndex 

Source
pub struct SourceMapIndex { /* private fields */ }
Expand description

Represents a sourcemap index in memory

Implementations§

Source§

impl SourceMapIndex

Source

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.

Source

pub fn to_writer<W: Write>(&self, w: W) -> Result<()>

Writes a sourcemap index into a writer.

Source

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.

Source

pub fn new( file: Option<String>, sections: Vec<SourceMapSection>, ) -> SourceMapIndex

Constructs a new sourcemap index from raw components.

  • file: an optional filename of the index
  • sections: a vector of source map index sections
Source

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 index
  • sections: a vector of source map index sections
  • x_facebook_offsets: a vector of facebook offsets
  • x_metro_module_paths: a vector of metro module paths
Source

pub fn get_file(&self) -> Option<&str>

Returns the embedded filename in case there is one.

Source

pub fn set_file(&mut self, value: Option<&str>)

Sets a new value for the file.

Source

pub fn get_section_count(&self) -> u32

Returns the number of sections in this index

Source

pub fn get_section(&self, idx: u32) -> Option<&SourceMapSection>

Looks up a single section and returns it

Source

pub fn get_section_mut(&mut self, idx: u32) -> Option<&mut SourceMapSection>

Looks up a single section and returns it as a mutable ref

Source

pub fn sections(&self) -> SourceMapSectionIter<'_>

Iterates over all sections

Source

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.

Source

pub fn flatten(&self) -> Result<SourceMap>

Flattens an indexed sourcemap into a regular one. This requires that all referenced sourcemaps are attached.

Source

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.

Source

pub fn is_for_ram_bundle(&self) -> bool

Returns true if this sourcemap is for a RAM bundle.

Source

pub fn x_facebook_offsets(&self) -> Option<&[Option<u32>]>

Returns embeded x-facebook-offset values.

Source

pub fn x_metro_module_paths(&self) -> Option<&[String]>

Returns embedded metro module paths.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.