[70] Flächen-Nachweis: CSV, Seitenaufteilung und SVG im Kern (area_report.rs), TS nur Fassade

This commit is contained in:
Claude committed 2026-10-29 17:28:20 +00:00
1 parent 6884932827
commit 8bd3d8ad7b
7 files changed
+492 -188

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
//! Bindungen des Flächen-Nachweises (`crate::area_report`): der Bericht reist als JSON (Texte und
//! wenige Zahlen, keine Geometrie). Kaputte Eingaben → leeres Ergebnis ("" bzw. "null"), nie Panic.
use crate::area_report as ar;
use wasm_bindgen::prelude::wasm_bindgen;
fn report(json: &str) -> Option<ar::Report> {
serde_json::from_str(json).ok()
}
fn opts(json: &str) -> ar::LayoutOptions {
serde_json::from_str(json).unwrap_or_default()
}
/// Bericht-JSON → CSV-Text ("" bei kaputtem Bericht).
#[wasm_bindgen]
pub fn area_report_csv(report_json: &str, delimiter: &str) -> String {
report(report_json).map(|r| ar::to_csv(&r, delimiter)).unwrap_or_default()
}
/// CSV-Text → JSON `{title, projectName, sections, notes}`.
#[wasm_bindgen]
pub fn area_report_parse_csv(text: &str, delimiter: &str) -> String {
ar::parse_csv(text, delimiter).to_string()
}
/// Bericht-JSON, Optionen-JSON → Layout-JSON `{width, height, pages}` ("null" bei kaputtem Bericht).
#[wasm_bindgen]
pub fn area_report_layout(report_json: &str, opts_json: &str) -> String {
match report(report_json) {
Some(r) => ar::layout_json(&ar::layout(&r, &opts(opts_json))).to_string(),
None => "null".into(),
}
}
/// Bericht-JSON, Seite, Optionen-JSON → SVG-Text ("" bei kaputtem Bericht).
#[wasm_bindgen]
pub fn area_report_svg(report_json: &str, page: u32, opts_json: &str) -> String {
report(report_json).map(|r| ar::to_svg(&r, page as usize, &opts(opts_json))).unwrap_or_default()
}
+1
View File
@@ -41,6 +41,7 @@ mod project_refs;
mod commands;
mod import;
mod cmd_create;
mod area_report;
use wasm_bindgen::prelude::wasm_bindgen;