From e0dc3ac730e0a76309348d024a6565ba9ba44fb7 Mon Sep 17 00:00:00 2001 From: Cong-Cong Date: Wed, 14 May 2025 16:59:52 +0800 Subject: [PATCH 1/3] support: ignore list --- src/source.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/source.rs b/src/source.rs index 937ece4d..d965ff06 100644 --- a/src/source.rs +++ b/src/source.rs @@ -208,6 +208,8 @@ pub struct SourceMap { source_root: Option>, #[serde(rename = "debugId", skip_serializing_if = "Option::is_none")] debug_id: Option>, + #[serde(rename = "ignoreList", skip_serializing_if = "Option::is_none")] + ignore_list: Option>, } impl Hash for SourceMap { @@ -218,6 +220,7 @@ impl Hash for SourceMap { self.sources_content.hash(state); self.names.hash(state); self.source_root.hash(state); + self.ignore_list.hash(state); } } @@ -244,6 +247,7 @@ impl SourceMap { names: names.into(), source_root: None, debug_id: None, + ignore_list: None, } } @@ -257,6 +261,16 @@ impl SourceMap { self.file = file.map(Into::into); } + /// Get the ignoreList field in [SourceMap]. + pub fn ignore_list(&self) -> Option<&Vec> { + self.ignore_list.as_ref() + } + + /// Set the ignoreList field in [SourceMap]. + pub fn set_ignore_list(&mut self, ignore_list: Option>) { + self.ignore_list = ignore_list; + } + /// Get the decoded mappings in [SourceMap]. pub fn decoded_mappings(&self) -> impl Iterator + '_ { decode_mappings(self) @@ -348,6 +362,8 @@ struct RawSourceMap { pub mappings: String, #[serde(rename = "debugId")] pub debug_id: Option, + #[serde(rename = "ignoreList")] + pub ignore_list: Option>, } impl RawSourceMap { @@ -437,6 +453,7 @@ impl TryFrom for SourceMap { names, source_root, debug_id, + ignore_list: raw.ignore_list, }) } } From 142fc27de4c498f16721c791af3c7bc9cd5b75f5 Mon Sep 17 00:00:00 2001 From: Cong-Cong Date: Wed, 15 Oct 2025 17:22:27 +0800 Subject: [PATCH 2/3] refactor --- src/source.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/source.rs b/src/source.rs index d965ff06..aeb1860b 100644 --- a/src/source.rs +++ b/src/source.rs @@ -262,13 +262,13 @@ impl SourceMap { } /// Get the ignoreList field in [SourceMap]. - pub fn ignore_list(&self) -> Option<&Vec> { - self.ignore_list.as_ref() + pub fn ignore_list(&self) -> Option<&[u32]> { + self.ignore_list.as_deref() } /// Set the ignoreList field in [SourceMap]. - pub fn set_ignore_list(&mut self, ignore_list: Option>) { - self.ignore_list = ignore_list; + pub fn set_ignore_list>>(&mut self, ignore_list: Option) { + self.ignore_list = ignore_list.map(Into::into); } /// Get the decoded mappings in [SourceMap]. From bd7cd3ca0219f706ce1f2dadc0bf3f6e2fc99dd5 Mon Sep 17 00:00:00 2001 From: Cong-Cong Date: Wed, 15 Oct 2025 17:23:35 +0800 Subject: [PATCH 3/3] fix: test case --- src/source.rs | 2 +- src/source_map_source.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/source.rs b/src/source.rs index aeb1860b..71a21242 100644 --- a/src/source.rs +++ b/src/source.rs @@ -559,7 +559,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] diff --git a/src/source_map_source.rs b/src/source_map_source.rs index f248f751..96286242 100644 --- a/src/source_map_source.rs +++ b/src/source_map_source.rs @@ -270,7 +270,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]