[K4] Projektdatei-Format (Parser, Migration, Serialisierung) in Rust (project_format.rs); projectFormat.ts nur noch Fassade

This commit is contained in:
karim committed 2026-10-28 02:27:03 +01:00
1 parent 96a5c219ec
commit e02c01d3a5
9 files changed
+317 -120

No files matched your search

+6
View File
@@ -104,3 +104,9 @@ pub fn doc_export_ifc(h: u32, now_ms: f64) -> String {
Err(e) => format!("\u{1}{e}"),
}
}
/// Das Projekt als Datei-Text (Formatversion vorn, Einrückung 2); leer, wenn das Dokument nicht offen ist.
#[wasm_bindgen]
pub fn doc_serialize(h: u32) -> String {
with_doc(h, |d| d.serialize()).unwrap_or_default()
}
+1
View File
@@ -19,6 +19,7 @@ mod polygon_holes;
mod drawing2d_3d;
mod wall_mesh_cut;
mod plan_buf;
mod project_format;
mod gpu_compile;
mod plan_stairs;
mod plan_walls;
+22
View File
@@ -0,0 +1,22 @@
//! Bindungen des Projektdatei-Formats (`crate::project_format`).
use crate::project_format::{parse_project_file, Parsed};
use serde_json::{json, Value};
use wasm_bindgen::prelude::wasm_bindgen;
/// Liest eine Projektdatei (Text). Antwort als JSON:
/// `{"ok":true,"project":{…},"warnings":[…],"migratedFrom":null|n}` oder `{"ok":false,"error":"…"}`.
#[wasm_bindgen]
pub fn project_parse(text: &str, now_ms: f64) -> String {
let v: Value = match parse_project_file(text, now_ms) {
Parsed::Ok { project, warnings, migrated_from } => json!({"ok": true, "project": project, "warnings": warnings, "migratedFrom": migrated_from}),
Parsed::Err(error) => json!({"ok": false, "error": error}),
};
v.to_string()
}
/// Aktuelle Version des Dateiformats.
#[wasm_bindgen]
pub fn project_format_version() -> u32 {
crate::project_format::PROJECT_FORMAT_VERSION as u32
}