refactor & improvements

This commit is contained in:
2026-03-29 22:35:57 +03:00
parent 5a51d3b4c3
commit 1675d2611c
68 changed files with 4803 additions and 7387 deletions

View File

@@ -4,14 +4,9 @@ version = "0.1.0"
edition = "2024"
[lib]
crate-type = ["cdylib", "rlib"]
crate-type = ["rlib"]
[dependencies]
serde = { version = "1", features = ["derive"] }
serde_json = "1"
base64 = "0.22"
wasm-bindgen = "0.2"
[features]
default = []
wasm = []

View File

@@ -1,5 +1 @@
pub mod models;
pub mod template_to_typst;
#[cfg(feature = "wasm")]
mod wasm_api;

File diff suppressed because it is too large Load Diff

View File

@@ -1,26 +0,0 @@
use wasm_bindgen::prelude::*;
use crate::models::Template;
use crate::template_to_typst::{self, RenderMode};
/// Template JSON + Data JSON → Typst markup (editör modu, layout query dahil)
#[wasm_bindgen(js_name = "templateToTypstEditor")]
pub fn template_to_typst_editor(template_json: &str, data_json: &str) -> Result<String, JsValue> {
let template: Template = serde_json::from_str(template_json)
.map_err(|e| JsValue::from_str(&format!("Template parse hatasi: {}", e)))?;
let data: serde_json::Value = serde_json::from_str(data_json)
.map_err(|e| JsValue::from_str(&format!("Data parse hatasi: {}", e)))?;
Ok(template_to_typst::template_to_typst(&template, &data, RenderMode::Editor))
}
/// Template JSON + Data JSON → Typst markup (PDF modu, layout query yok)
#[wasm_bindgen(js_name = "templateToTypstPdf")]
pub fn template_to_typst_pdf(template_json: &str, data_json: &str) -> Result<String, JsValue> {
let template: Template = serde_json::from_str(template_json)
.map_err(|e| JsValue::from_str(&format!("Template parse hatasi: {}", e)))?;
let data: serde_json::Value = serde_json::from_str(data_json)
.map_err(|e| JsValue::from_str(&format!("Data parse hatasi: {}", e)))?;
Ok(template_to_typst::template_to_typst(&template, &data, RenderMode::Pdf))
}