Skip to content

Commit e1bd85d

Browse files
authored
feat: support ignore list (#163)
1 parent 938650c commit e1bd85d

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/source.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ pub struct SourceMap {
208208
source_root: Option<Arc<str>>,
209209
#[serde(rename = "debugId", skip_serializing_if = "Option::is_none")]
210210
debug_id: Option<Arc<str>>,
211+
#[serde(rename = "ignoreList", skip_serializing_if = "Option::is_none")]
212+
ignore_list: Option<Vec<u32>>,
211213
}
212214

213215
impl std::fmt::Debug for SourceMap {
@@ -235,6 +237,7 @@ impl Hash for SourceMap {
235237
self.sources_content.hash(state);
236238
self.names.hash(state);
237239
self.source_root.hash(state);
240+
self.ignore_list.hash(state);
238241
}
239242
}
240243

@@ -261,6 +264,7 @@ impl SourceMap {
261264
names: names.into(),
262265
source_root: None,
263266
debug_id: None,
267+
ignore_list: None,
264268
}
265269
}
266270

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

281+
/// Get the ignoreList field in [SourceMap].
282+
pub fn ignore_list(&self) -> Option<&[u32]> {
283+
self.ignore_list.as_deref()
284+
}
285+
286+
/// Set the ignoreList field in [SourceMap].
287+
pub fn set_ignore_list<T: Into<Vec<u32>>>(&mut self, ignore_list: Option<T>) {
288+
self.ignore_list = ignore_list.map(Into::into);
289+
}
290+
277291
/// Get the decoded mappings in [SourceMap].
278292
pub fn decoded_mappings(&self) -> impl Iterator<Item = Mapping> + '_ {
279293
decode_mappings(self)
@@ -365,6 +379,8 @@ struct RawSourceMap {
365379
pub mappings: String,
366380
#[serde(rename = "debugId")]
367381
pub debug_id: Option<String>,
382+
#[serde(rename = "ignoreList")]
383+
pub ignore_list: Option<Vec<u32>>,
368384
}
369385

370386
impl RawSourceMap {
@@ -454,6 +470,7 @@ impl TryFrom<RawSourceMap> for SourceMap {
454470
names,
455471
source_root,
456472
debug_id,
473+
ignore_list: raw.ignore_list,
457474
})
458475
}
459476
}
@@ -559,7 +576,7 @@ mod tests {
559576
RawBufferSource::from("a".as_bytes()).hash(&mut state);
560577
(&RawSource::from("h") as &dyn Source).hash(&mut state);
561578
ReplaceSource::new(RawSource::from("i").boxed()).hash(&mut state);
562-
assert_eq!(format!("{:x}", state.finish()), "1b50b537fa997c34");
579+
assert_eq!(format!("{:x}", state.finish()), "6abed98aa11f84e5");
563580
}
564581

565582
#[test]

src/source_map_source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ mod tests {
297297

298298
let mut hasher = twox_hash::XxHash64::default();
299299
sms1.hash(&mut hasher);
300-
assert_eq!(format!("{:x}", hasher.finish()), "d136621583d4618c");
300+
assert_eq!(format!("{:x}", hasher.finish()), "736934c6e249aa6e");
301301
}
302302

303303
#[test]

0 commit comments

Comments
 (0)