add console panic hook

This commit is contained in:
Moritz Hölting 2024-06-26 21:15:14 +02:00
parent abd5218668
commit a623308496
2 changed files with 6 additions and 1 deletions

View File

@ -10,9 +10,10 @@ crate-type = ["cdylib"]
[dependencies]
wasm-bindgen = "0.2.92"
shulkerscript = { git = "https://github.com/moritz-hoelting/shulkerscript-lang.git", default-features = false, features = ["serde", "shulkerbox"], rev = "af544ac79eea4498ef4563acfb7e8dd14ec5c84e" }
shulkerscript = { git = "https://github.com/moritz-hoelting/shulkerscript-lang.git", default-features = false, features = ["serde", "shulkerbox"], rev = "a0a27cda96e1922b019b216961c39f7ef7991d22" }
serde = "1.0"
serde-wasm-bindgen = "0.6.5"
anyhow = "1.0.86"
zip = { version = "2.1.3", default-features = false, features = ["deflate"] }
base64 = "0.22.1"
console_error_panic_hook = "0.1.7"

View File

@ -29,6 +29,8 @@ extern "C" {
/// Compiles the given directory into datapack files.
#[wasm_bindgen]
pub fn compile(root_dir: JsValue) -> JsValue {
console_error_panic_hook::set_once();
let root_dir = VFolder::from(serde_wasm_bindgen::from_value::<Directory>(root_dir).unwrap());
log("Compiling...");
@ -43,6 +45,8 @@ pub fn compile(root_dir: JsValue) -> JsValue {
/// Returns a base64 encoded zip file containing the compiled datapack.
#[wasm_bindgen(js_name = compileZip)]
pub fn compile_zip(root_dir: JsValue) -> Option<String> {
console_error_panic_hook::set_once();
let root_dir = VFolder::from(serde_wasm_bindgen::from_value::<Directory>(root_dir).unwrap());
let datapack = _compile(&root_dir).ok()?;