enhanced_magic_string/
types.rs

1/// Whether the mapping should be high-resolution.
2/// Hi-res mappings map every single character, meaning (for example) your devtools will always
3/// be able to pinpoint the exact location of function calls and so on.
4/// With lo-res mappings, devtools may only be able to identify the correct
5/// line - but they're quicker to generate and less bulky.
6/// You can also set `"boundary"` to generate a semi-hi-res mappings segmented per word boundary
7/// instead of per character, suitable for string semantics that are separated by words.
8/// If sourcemap locations have been specified with s.addSourceMapLocation(), they will be used here.
9pub enum MappingsOptionHires {
10  Bool(bool),
11  Boundary,
12}
13
14impl Default for MappingsOptionHires {
15  fn default() -> Self {
16    Self::Bool(false)
17  }
18}
19
20impl MappingsOptionHires {
21  pub fn is_boundary(&self) -> bool {
22    match self {
23      Self::Bool(_) => false,
24      Self::Boundary => true,
25    }
26  }
27
28  pub fn is_truthy(&self) -> bool {
29    match self {
30      Self::Bool(b) => *b,
31      Self::Boundary => true,
32    }
33  }
34}
35
36pub type RawSegment = Vec<usize>;
37pub type RawSegments = Vec<RawSegment>;
38
39#[derive(Default)]
40pub struct SourceMapOptions {
41  pub hires: Option<MappingsOptionHires>,
42
43  /// The filename where you plan to write the sourcemap.
44  pub file: Option<String>,
45
46  /// The filename of the file containing the original source.
47  pub source: Option<String>,
48
49  /// Whether to include the original content in the map's sourcesContent array.
50  pub include_content: Option<bool>,
51
52  /// remap source filename
53  pub remap_source: Option<Box<dyn Fn(&str) -> String>>,
54}