Skip to main content

source_map_tauri/sourcemaps/
trace.rs

1use std::path::{Path, PathBuf};
2
3use anyhow::{anyhow, Result};
4use serde::Serialize;
5
6#[derive(Debug, Serialize)]
7pub struct TraceResult {
8    pub bundle_path: String,
9    pub generated_line: u32,
10    pub generated_column: u32,
11    pub message: String,
12}
13
14pub fn trace_bundle_frame(
15    root: &Path,
16    bundle: &PathBuf,
17    line: u32,
18    column: u32,
19) -> Result<TraceResult> {
20    let bundle_path = if bundle.is_absolute() {
21        bundle.clone()
22    } else {
23        root.join(bundle)
24    };
25    if !bundle_path.exists() {
26        return Err(anyhow!("bundle not found: {}", bundle_path.display()));
27    }
28    Ok(TraceResult {
29        bundle_path: bundle_path.to_string_lossy().to_string(),
30        generated_line: line,
31        generated_column: column,
32        message: "Direct sourcemap tracing is not implemented yet; run scan when sourcemap artifacts are available.".to_owned(),
33    })
34}