Skip to main content

oak_source_map/
lib.rs

1//! # oak-source-map
2//!
3//! A high-performance Source Map v3 implementation for Rust.
4//!
5//! ## Features
6//!
7//! - Full Source Map v3 specification support
8//! - VLQ Base64 encoding/decoding
9//! - Zero-copy parsing where possible
10//! - Builder pattern for incremental construction
11//! - Source map composition and manipulation
12//!
13//! ## Example
14//!
15//! ```rust
16//! use oak_source_map::{SourceMap, SourceMapBuilder};
17//!
18//! // Parse an existing source map
19//! let json = r#"{"version":3,"sources":["foo.js"],"names":[],"mappings":"AAAA"}"#;
20//! let sm = SourceMap::parse(json)?;
21//!
22//! // Build a new source map
23//! let mut builder = SourceMapBuilder::new();
24//! builder.add_source("input.ts");
25//! builder.add_mapping(0, 0, Some(0), Some(0), Some(0), None);
26//! let output = builder.build();
27//!
28//! # Ok::<(), oak_source_map::SourceMapError>(())
29//! ```
30
31#![warn(missing_docs)]
32#![forbid(unsafe_code)]
33
34mod builder;
35mod composer;
36mod decoder;
37mod error;
38mod mapping;
39mod source_map;
40mod vlq;
41
42pub use builder::SourceMapBuilder;
43pub use composer::SourceMapComposer;
44pub use decoder::SourceMapDecoder;
45pub use error::{Result, SourceMapError};
46pub use mapping::{BoundedMapping, Mapping, Segment};
47pub use source_map::{SourceMap, SourceMapMetadata};
48pub use vlq::{vlq_decode, vlq_encode};
49
50pub use source_map::SourceMapInput;
51
52/// Source Map version (always 3).
53pub const SOURCE_MAP_VERSION: u8 = 3;
54
55/// The default source root.
56pub const DEFAULT_SOURCE_ROOT: &str = "";