Collections of useful macros for wasm

demo

Cargo.toml ```toml [package] name = "demo_wasm" version = "0.1.0" edition = "2021"

[dependencies] wasmmacro="0.1.8" web-sys = { version = "0.3.57", features = [ 'Document', 'Element', 'HtmlElement', 'Node', 'Window', "WindowClient", ] } dioxus = { version = "0.2.4", features = ["web", "router"] } consoleerrorpanichook = "0.1" tracing-wasm = "0.2" tracing = "0.1" index.html html Document

main.rs rust fn main(){ run::launch(); } pub mod run{ use dioxus::prelude::; pub fn launch() { dioxus::web::launch(app); } pub fn app(cx: Scope) -> Element { use wasm_macro::; consoleerrorpanichook::setonce(); tracingwasm::setasglobaldefault(); cx.render(rsx! { div{ onclick:move||{ // locationassign!("/demo"); // info!("{}",locationherf!()); // locationreload!(); let maindiv = documentqueryselectorall!(".main"); match maindiv.get(0){ //frist of NodeList Some(div) => { div.appendchild(&documentcreateelement!("div").clonenode().unwrap()).unwrap(); }, None => {}, } consolelog!(documentinnerhtml!(".main")); consolelog!(documentbaseuri!()); documentsetinnerhtml!(".main","

hello

") }, class:"main", "test" } }) } }
then run sh trunk serve ```

All Examples

```rust use wasmmacro::*; //locationassign onclick:move||{ locationassign!("/demo");// nevigate to /demo } //locationherf onclick:move||{ let herf = locationherf!(); consolelog!(herf); //get current location herf } //locationreload onclick:move||{ locationreload!(); //reload current location } //queryselector onclick:move||{ let maindiv = documentqueryselector!(".main"); match maindiv{ Some(div) => { div.appendchild(&documentcreateelement!("div").clonenode().unwrap()); }, None => {}, } } //queryselectorall onclick:move||{ let maindiv = documentqueryselectorall!(".main"); match maindiv.get(0){ //frist of NodeList Some(div) => { div.appendchild(&documentcreateelement!("div").clonenode().unwrap()); }, None => {}, } // get innerhtml onclick:move||{ consolelog!(documentinnerhtml!(".main")); } //set innerhtml onclick:move||{ documentsetinner_html!(".main","

hello

"); }

//console.log() onclick:move||{ consolelog!(documentinnerhtml!(".main")); }

//documentbaseuri!() return baseuri use wasmmacro::; onclick:move|_|{ console_log!(document_base_uri!()); } use wasm_macro::; onclick:move||{ consolelog!(elementgetattribute!(".main","class"));//"main" } ```