fast-layer 0.1.1

WIP: A fast WebAssembly-based layer for high-performance MapLibre/Mapbox
Documentation
use std::panic;
use std::panic::PanicInfo;
use wasm_bindgen::JsValue;
use wasm_bindgen::prelude::*;
use web_sys::console;

// Install a panic hook at WASM startup that preserves console_error_panic_hook output
#[wasm_bindgen(start)]
pub fn wasm_start() {
    panic::set_hook(Box::new(|info: &PanicInfo| {
        // Let console_error_panic_hook print the full panic info + backtrace to the console
        console_error_panic_hook::hook(info);

        // Also emit a concise, capture-friendly message (useful for sending to servers)
        let msg = if let Some(s) = info.payload().downcast_ref::<&str>() {
            s.to_string()
        } else if let Some(s) = info.payload().downcast_ref::<String>() {
            s.clone()
        } else {
            format!("{}", info)
        };

        console::error_1(&JsValue::from_str(&format!("Captured panic: {}", msg)));

        // TODO: optionally send the panic info to a remote logging endpoint here
    }));
}