pub struct SourceMap {
pub version: u8,
pub sources: Vec<String>,
pub sources_content: Vec<Option<String>>,
pub names: Vec<String>,
pub mappings: String,
pub file: Option<String>,
pub source_root: Option<String>,
pub sections: Vec<SourceMapSection>,
}Expand description
Source Map v3 representation.
This is the main data structure for working with source maps. It follows the Source Map v3 specification.
Fields§
§version: u8Version (always 3).
sources: Vec<String>List of source file paths.
sources_content: Vec<Option<String>>List of source file contents (optional).
names: Vec<String>List of symbol names.
mappings: StringEncoded mappings string.
file: Option<String>Output file path (optional).
source_root: Option<String>Source root (optional).
sections: Vec<SourceMapSection>Source map references (for indexed source maps).
Implementations§
Source§impl SourceMap
impl SourceMap
Sourcepub fn parse(json: impl Into<SourceMapInput>) -> Result<Self>
pub fn parse(json: impl Into<SourceMapInput>) -> Result<Self>
Parses a source map from JSON.
Sourcepub fn to_json_pretty(&self) -> Result<String>
pub fn to_json_pretty(&self) -> Result<String>
Converts the source map to pretty-printed JSON.
Sourcepub fn add_source(&mut self, source: impl Into<String>) -> usize
pub fn add_source(&mut self, source: impl Into<String>) -> usize
Adds a source file.
Sourcepub fn set_source_content(&mut self, index: usize, content: impl Into<String>)
pub fn set_source_content(&mut self, index: usize, content: impl Into<String>)
Sets the content for a source.
Sourcepub fn get_source(&self, index: usize) -> Option<&str>
pub fn get_source(&self, index: usize) -> Option<&str>
Gets the source path at an index.
Sourcepub fn get_source_content(&self, index: usize) -> Option<Option<&String>>
pub fn get_source_content(&self, index: usize) -> Option<Option<&String>>
Gets the source content at an index.
Sourcepub fn parse_mappings(&self) -> Result<Vec<Mapping>>
pub fn parse_mappings(&self) -> Result<Vec<Mapping>>
Parses all mappings into a vector.
Sourcepub fn metadata(&self) -> SourceMapMetadata
pub fn metadata(&self) -> SourceMapMetadata
Returns metadata about this source map.
Sourcepub fn to_inline_comment(&self) -> Result<String>
pub fn to_inline_comment(&self) -> Result<String>
Generates the inline source map comment.
Sourcepub fn to_external_comment(&self, filename: &str) -> String
pub fn to_external_comment(&self, filename: &str) -> String
Generates the external source map comment.
Sourcepub fn is_indexed(&self) -> bool
pub fn is_indexed(&self) -> bool
Checks if this is an indexed source map.
Sourcepub fn has_sources_content(&self) -> bool
pub fn has_sources_content(&self) -> bool
Checks if this source map has sources content.
Sourcepub fn get_full_source_path(&self, index: usize) -> Option<String>
pub fn get_full_source_path(&self, index: usize) -> Option<String>
Returns the full source path for a source index.