Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ pub struct SourceMap {
source_root: Option<Arc<str>>,
#[serde(rename = "debugId", skip_serializing_if = "Option::is_none")]
debug_id: Option<Arc<str>>,
#[serde(rename = "ignoreList", skip_serializing_if = "Option::is_none")]
ignore_list: Option<Vec<u32>>,
}

impl std::fmt::Debug for SourceMap {
Expand Down Expand Up @@ -235,6 +237,7 @@ impl Hash for SourceMap {
self.sources_content.hash(state);
self.names.hash(state);
self.source_root.hash(state);
self.ignore_list.hash(state);
}
}

Expand All @@ -261,6 +264,7 @@ impl SourceMap {
names: names.into(),
source_root: None,
debug_id: None,
ignore_list: None,
}
}

Expand All @@ -274,6 +278,16 @@ impl SourceMap {
self.file = file.map(Into::into);
}

/// Get the ignoreList field in [SourceMap].
pub fn ignore_list(&self) -> Option<&[u32]> {
self.ignore_list.as_deref()
}

/// Set the ignoreList field in [SourceMap].
pub fn set_ignore_list<T: Into<Vec<u32>>>(&mut self, ignore_list: Option<T>) {
self.ignore_list = ignore_list.map(Into::into);
}

/// Get the decoded mappings in [SourceMap].
pub fn decoded_mappings(&self) -> impl Iterator<Item = Mapping> + '_ {
decode_mappings(self)
Expand Down Expand Up @@ -365,6 +379,8 @@ struct RawSourceMap {
pub mappings: String,
#[serde(rename = "debugId")]
pub debug_id: Option<String>,
#[serde(rename = "ignoreList")]
pub ignore_list: Option<Vec<u32>>,
}

impl RawSourceMap {
Expand Down Expand Up @@ -454,6 +470,7 @@ impl TryFrom<RawSourceMap> for SourceMap {
names,
source_root,
debug_id,
ignore_list: raw.ignore_list,
})
}
}
Expand Down Expand Up @@ -559,7 +576,7 @@ mod tests {
RawBufferSource::from("a".as_bytes()).hash(&mut state);
(&RawSource::from("h") as &dyn Source).hash(&mut state);
ReplaceSource::new(RawSource::from("i").boxed()).hash(&mut state);
assert_eq!(format!("{:x}", state.finish()), "1b50b537fa997c34");
assert_eq!(format!("{:x}", state.finish()), "6abed98aa11f84e5");
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/source_map_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ mod tests {

let mut hasher = twox_hash::XxHash64::default();
sms1.hash(&mut hasher);
assert_eq!(format!("{:x}", hasher.finish()), "d136621583d4618c");
assert_eq!(format!("{:x}", hasher.finish()), "736934c6e249aa6e");
}

#[test]
Expand Down