From 90acfe15e59dfc1c91ce20c6510a919b18e69583 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Fri, 3 Jan 2025 10:15:20 +0100 Subject: [PATCH] feat: Add support for sourcemap `debugid` property --- src/source.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/source.rs b/src/source.rs index 3fd78a3..937ece4 100644 --- a/src/source.rs +++ b/src/source.rs @@ -206,6 +206,8 @@ pub struct SourceMap { mappings: Arc, #[serde(rename = "sourceRoot", skip_serializing_if = "Option::is_none")] source_root: Option>, + #[serde(rename = "debugId", skip_serializing_if = "Option::is_none")] + debug_id: Option>, } impl Hash for SourceMap { @@ -241,6 +243,7 @@ impl SourceMap { sources_content: sources_content.into(), names: names.into(), source_root: None, + debug_id: None, } } @@ -321,6 +324,16 @@ impl SourceMap { pub fn set_source_root>>(&mut self, source_root: Option) { self.source_root = source_root.map(Into::into); } + + /// Set the debug_id field in [SourceMap]. + pub fn set_debug_id>>(&mut self, debug_id: Option) { + self.debug_id = debug_id.map(Into::into); + } + + /// Get the debug_id field in [SourceMap]. + pub fn get_debug_id(&self) -> Option<&str> { + self.debug_id.as_deref() + } } #[derive(Debug, Default, Deserialize)] @@ -333,6 +346,8 @@ struct RawSourceMap { pub sources_content: Option>>, pub names: Option>>, pub mappings: String, + #[serde(rename = "debugId")] + pub debug_id: Option, } impl RawSourceMap { @@ -411,6 +426,7 @@ impl TryFrom for SourceMap { .collect::>() .into(); let source_root = raw.source_root.map(Into::into); + let debug_id = raw.debug_id.map(Into::into); Ok(Self { version: 3, @@ -420,6 +436,7 @@ impl TryFrom for SourceMap { sources_content, names, source_root, + debug_id, }) } }