use wasm_bindgen::prelude::*;
use wasm_bindgen::JsValue;
pub mod errors;
pub mod imagesize;
pub mod template;
pub mod utils;
pub use errors::XlsxError;
pub use template::render_handlebars;
pub fn set_panic_hook() {
#[cfg(feature = "console_error_panic_hook")]
console_error_panic_hook::set_once();
}
#[wasm_bindgen]
pub fn render(
zip_bytes: Vec<u8>,
data_json: &str,
) -> Result<JsValue, JsValue> {
let data: serde_json::Value = serde_json::from_str(data_json)
.map_err(|e| JsValue::from_str(&format!("JSON 解析错误: {e}")))?;
let result = template::render_handlebars(zip_bytes, &data)
.map_err(|e| JsValue::from_str(&e.to_string()))?;
Ok(JsValue::from(result))
}