Clone in a terminal:
Commit eff2a45
Johan Mattsson - 2026-06-28T14:51:41+00:00
eff2a4515983cb579a26b418ec976cb03880d20ejohan.mattsson.m@gmail.com

Component update

Changed files (7)

Diff

diff --git a/Cargo.lock b/Cargo.lockindex 1ac1e21..9676dc1 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -382,9 +382,7 @@ dependencies = [  [[package]] name = "kaja-callback-macro"-version = "0.1.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "f991f9438ddafefdef1b5fb95a4a60f3bc834b419c27409d8e10a7839c47af8d"+version = "1.0.0" dependencies = [  "gloo",  "proc-macro2",@@ -414,6 +412,7 @@ dependencies = [  "js-sys",  "kaja-callback-macro",  "kaja-html-macro",+ "kaja-web-component",  "serde",  "serde-wasm-bindgen 0.5.0",  "wasm-bindgen",@@ -422,6 +421,20 @@ dependencies = [ ]  [[package]]+name = "kaja-web-component"+version = "0.1.0"+dependencies = [+ "gloo",+ "inventory",+ "js-sys",+ "proc-macro2",+ "quote",+ "syn 2.0.117",+ "wasm-bindgen",+ "web-sys",+]++[[package]] name = "libc" version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index"diff --git a/Cargo.toml b/Cargo.tomlindex ec6fd7b..15e446f 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -8,7 +8,6 @@ repository = "https://github.com/johanmattssonm/kaja-web" readme = "README.md" keywords = ["html", "web", "wasm", "webassembly", "frontend"] - [dependencies] gloo = "0.12.0" gloo-console = "0.4.0"@@ -20,4 +19,5 @@ serde-wasm-bindgen = "0.5" inventory = "0.3.24" js-sys = "0.3" wasm-bindgen-futures = "0.4.72"-kaja-callback-macro = "0.1.0"+kaja-callback-macro = { path = "../kaja-callback-macro" }+kaja-web-component = { path = "../kaja-web-component" }diff --git a/examples/components/Cargo.lock b/examples/components/Cargo.lockindex bf89c44..6bdfe7e 100644--- a/examples/components/Cargo.lock+++ b/examples/components/Cargo.lock@@ -446,9 +446,7 @@ dependencies = [  [[package]] name = "kaja-callback-macro"-version = "0.1.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "f991f9438ddafefdef1b5fb95a4a60f3bc834b419c27409d8e10a7839c47af8d"+version = "1.0.0" dependencies = [  "gloo",  "proc-macro2",@@ -493,7 +491,6 @@ dependencies = [  "gloo",  "inventory",  "js-sys",- "kaja-callback-macro",  "kaja-html-macro",  "kaja-web",  "serde",@@ -1083,7 +1080,3 @@ name = "zmij" version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"--[[patch.unused]]-name = "kaja-callback-macro"-version = "1.0.0"diff --git a/examples/components/Cargo.toml b/examples/components/Cargo.tomlindex 811a0a9..fbddcbf 100644--- a/examples/components/Cargo.toml+++ b/examples/components/Cargo.toml@@ -19,7 +19,6 @@ uuid = { version = "1.23.2", features = ["js", "v4"] } console_error_panic_hook = "0.1.7" inventory = "0.3.24" serde-wasm-bindgen = "0.5"-kaja-callback-macro = "0.1.0"  [patch.crates-io] kaja-callback-macro = { path = "../../../kaja-callback-macro" }diff --git a/examples/components/src/lib.rs b/examples/components/src/lib.rsindex 3088d6b..b98257a 100644--- a/examples/components/src/lib.rs+++ b/examples/components/src/lib.rs@@ -34,11 +34,12 @@ fn counter_disconnect(element: HtmlElement, wasm_id: u32) { }  #[callback(counterInit)]-fn counter_init() {+fn counter_init() -> u32 {     log!("counterInit");     let counter = Counter::default();     let mut counter_store = COUNTER_COMPONENTS.write().unwrap();     *counter_store = Some(counter);+    42 }  fn create_component(tag_name: &str) {@@ -46,19 +47,19 @@ fn create_component(tag_name: &str) {      let component = Function::new_no_args(         r#"-        return class extends HTMLElement {-            let component_id = -1;+        let componentId = -1; +        return class extends HTMLElement {             connectedCallback() {-                if (component_id == -1) {-                    component_id = counter_init();+                if (componentId == -1) {+                    componentId = counterInit();                 } -                counterComponentConnect(this, component_id);+                counterComponentConnect(this, componentId);             }              disconnectedCallback() {-                counterComponentDisconnect(this, component_id);+                counterComponentDisconnect(this, componentId);             }              attributeChangedCallback(name, oldValue, newValue) {@@ -145,8 +146,8 @@ fn init_components() { pub fn init() {     std::panic::set_hook(Box::new(console_error_panic_hook::hook));     console_error_panic_hook::set_once();-    init_components();     init_callbacks();+    init_components();      create_component("example-component") }diff --git a/src/lib.rs b/src/lib.rsindex af7db1b..b3ebc46 100644--- a/src/lib.rs+++ b/src/lib.rs@@ -4,7 +4,7 @@ #![doc = include_str!("../README.md")]  use gloo_console::{error, log};-use wasm_bindgen::JsCast;+use wasm_bindgen::{JsCast, JsValue}; use web_sys::{Element, HtmlDocument, HtmlElement, HtmlInputElement, NodeList};  pub mod prelude;@@ -298,3 +298,22 @@ pub fn get_callback(name: &str) -> Option<js_sys::Function> {     }     None }++/// HTML Component. See kaja-web-component.+pub trait Component {+    fn connected(&mut self, element: HtmlElement) {}+    fn disconnected(&mut self, element: HtmlElement) {}+    fn observed_attributes() -> &'static [&'static str] {+        &[]+    }++    fn attribute_changed(+        &mut self,+        element: HtmlElement,+        name: &str,+        old_value: &JsValue,+        new_value: &JsValue,+    ) {+        log!("Attribute changed but no update handler for ", name);+    }+}diff --git a/src/prelude.rs b/src/prelude.rsindex f7a93c5..f1d206d 100644--- a/src/prelude.rs+++ b/src/prelude.rs@@ -15,3 +15,6 @@ pub use wasm_bindgen_futures;  pub use kaja_callback_macro::callback; pub use kaja_html_macro::html;+pub use kaja_web_component::component;++pub use js_sys::Function;

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112