mirror of
https://github.com/duhanbalci/dreport.git
synced 2026-07-01 18:39:16 +00:00
refactor & improvements
This commit is contained in:
@@ -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 = []
|
||||
|
||||
@@ -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
@@ -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))
|
||||
}
|
||||
Reference in New Issue
Block a user