Clone in a terminal:
Commit c8b0c25
Johan Mattsson - 2026-06-28T08:41:05+00:00
c8b0c255c7b4cd973fb3ab8ac142bd55cde990c0johan.mattsson.m@gmail.com

Component sketch

Changed files (9)

Diff

diff --git a/examples/components/Cargo.lock b/examples/components/Cargo.locknew file mode 100644index 0000000..bf89c44--- /dev/null+++ b/examples/components/Cargo.lock@@ -0,0 +1,1089 @@+# This file is automatically @generated by Cargo.+# It is not intended for manual editing.+version = 4++[[package]]+name = "anyhow"+version = "1.0.102"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"++[[package]]+name = "bincode"+version = "1.3.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"+dependencies = [+ "serde",+]++[[package]]+name = "bitflags"+version = "2.11.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3"++[[package]]+name = "bumpalo"+version = "3.20.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"++[[package]]+name = "bytes"+version = "1.11.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33"++[[package]]+name = "cfg-if"+version = "1.0.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"++[[package]]+name = "console_error_panic_hook"+version = "0.1.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"+dependencies = [+ "cfg-if",+ "wasm-bindgen",+]++[[package]]+name = "equivalent"+version = "1.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"++[[package]]+name = "foldhash"+version = "0.1.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"++[[package]]+name = "form_urlencoded"+version = "1.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"+dependencies = [+ "percent-encoding",+]++[[package]]+name = "futures"+version = "0.3.32"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d"+dependencies = [+ "futures-channel",+ "futures-core",+ "futures-io",+ "futures-sink",+ "futures-task",+ "futures-util",+]++[[package]]+name = "futures-channel"+version = "0.3.32"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d"+dependencies = [+ "futures-core",+ "futures-sink",+]++[[package]]+name = "futures-core"+version = "0.3.32"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d"++[[package]]+name = "futures-io"+version = "0.3.32"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718"++[[package]]+name = "futures-macro"+version = "0.3.32"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.117",+]++[[package]]+name = "futures-sink"+version = "0.3.32"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893"++[[package]]+name = "futures-task"+version = "0.3.32"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393"++[[package]]+name = "futures-util"+version = "0.3.32"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6"+dependencies = [+ "futures-channel",+ "futures-core",+ "futures-io",+ "futures-macro",+ "futures-sink",+ "futures-task",+ "memchr",+ "pin-project-lite",+ "slab",+]++[[package]]+name = "getrandom"+version = "0.2.17"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"+dependencies = [+ "cfg-if",+ "js-sys",+ "libc",+ "wasi",+ "wasm-bindgen",+]++[[package]]+name = "getrandom"+version = "0.4.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555"+dependencies = [+ "cfg-if",+ "libc",+ "r-efi",+ "wasip2",+ "wasip3",+]++[[package]]+name = "gloo"+version = "0.12.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "dc13cc21c3835347855fd83900414d94716adc1e332f09f7fba56f21be127214"+dependencies = [+ "gloo-console",+ "gloo-dialogs",+ "gloo-events",+ "gloo-file",+ "gloo-history",+ "gloo-net",+ "gloo-render",+ "gloo-storage",+ "gloo-timers",+ "gloo-utils 0.3.0",+ "gloo-worker",+]++[[package]]+name = "gloo-console"+version = "0.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9f1d5cec0b97edb53f21221f799c659cef3764ad5a00eca52950eb9b902028ba"+dependencies = [+ "gloo-utils 0.3.0",+ "js-sys",+ "serde",+ "wasm-bindgen",+ "web-sys",+]++[[package]]+name = "gloo-dialogs"+version = "0.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "45618929b7022bb49903b958b5b7af1d4fb58fbd99712926d91641fe582f3d55"+dependencies = [+ "wasm-bindgen",+ "web-sys",+]++[[package]]+name = "gloo-events"+version = "0.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8c6a94fa8cd88bea0babf8a27fe9abbcdece831fd1c3c84dd5c231fab4685ec7"+dependencies = [+ "wasm-bindgen",+ "web-sys",+]++[[package]]+name = "gloo-file"+version = "0.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "544a15ff6a3d5976bebc97380c8471ae14283bc71f4bb198d6c8cae64f411ab7"+dependencies = [+ "gloo-events",+ "js-sys",+ "wasm-bindgen",+ "web-sys",+]++[[package]]+name = "gloo-history"+version = "0.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f07f3d446931414cc92f4a1b6e631dfa233db2f96c887d5f72beeecd1b5db39c"+dependencies = [+ "getrandom 0.2.17",+ "gloo-events",+ "gloo-utils 0.3.0",+ "serde",+ "serde-wasm-bindgen 0.6.5",+ "serde_urlencoded",+ "thiserror 2.0.18",+ "wasm-bindgen",+ "web-sys",+]++[[package]]+name = "gloo-net"+version = "0.7.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a6420f887c48417e9e86c6cf61274eb231830cccc100e49613f7952e269a1fe1"+dependencies = [+ "futures-channel",+ "futures-core",+ "futures-sink",+ "gloo-utils 0.3.0",+ "http",+ "js-sys",+ "pin-project",+ "serde",+ "serde_json",+ "thiserror 2.0.18",+ "wasm-bindgen",+ "wasm-bindgen-futures",+ "web-sys",+]++[[package]]+name = "gloo-render"+version = "0.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3f609333b9e38e43e74224410d6616e3ad773ed6fe14f53cd8a006d1bb25e108"+dependencies = [+ "wasm-bindgen",+ "web-sys",+]++[[package]]+name = "gloo-storage"+version = "0.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e82ce7d41c6d821640a43726f6ff33c924795cc151b62e5a84d0c988c151c980"+dependencies = [+ "gloo-utils 0.3.0",+ "js-sys",+ "serde",+ "serde_json",+ "thiserror 2.0.18",+ "wasm-bindgen",+ "web-sys",+]++[[package]]+name = "gloo-timers"+version = "0.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "482ce8a491a501da4cd806bd190275363d674f2845005c6ddbd5d3e1dd54495d"+dependencies = [+ "js-sys",+ "wasm-bindgen",+]++[[package]]+name = "gloo-utils"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0b5555354113b18c547c1d3a98fbf7fb32a9ff4f6fa112ce823a21641a0ba3aa"+dependencies = [+ "js-sys",+ "serde",+ "serde_json",+ "wasm-bindgen",+ "web-sys",+]++[[package]]+name = "gloo-utils"+version = "0.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4202275d95a142fa209a1e35e91c250a710c5600731372cd3464a39ed01573d6"+dependencies = [+ "js-sys",+ "serde",+ "serde_json",+ "wasm-bindgen",+ "web-sys",+]++[[package]]+name = "gloo-worker"+version = "0.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "142478655c5d764e5168d3019510ea0c0885687a72ba74e90548bd74ae160a41"+dependencies = [+ "bincode",+ "futures",+ "gloo-utils 0.2.0",+ "gloo-worker-macros",+ "js-sys",+ "pinned",+ "serde",+ "thiserror 2.0.18",+ "wasm-bindgen",+ "wasm-bindgen-futures",+ "web-sys",+]++[[package]]+name = "gloo-worker-macros"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f3bf5ede96b06406bd74351a026f708ae196b7dc262077aee56e6ad7223e7466"+dependencies = [+ "proc-macro-crate",+ "proc-macro2",+ "quote",+ "syn 2.0.117",+]++[[package]]+name = "hashbrown"+version = "0.15.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"+dependencies = [+ "foldhash",+]++[[package]]+name = "hashbrown"+version = "0.17.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"++[[package]]+name = "heck"+version = "0.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"++[[package]]+name = "http"+version = "1.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8be7462df143984c4598a256ef469b251d7d7f9e271135073e78fc535414f3d0"+dependencies = [+ "bytes",+ "itoa",+]++[[package]]+name = "id-arena"+version = "2.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"++[[package]]+name = "indexmap"+version = "2.14.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"+dependencies = [+ "equivalent",+ "hashbrown 0.17.1",+ "serde",+ "serde_core",+]++[[package]]+name = "inventory"+version = "0.3.24"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a4f0c30c76f2f4ccee3fe55a2435f691ca00c0e4bd87abe4f4a851b1d4dac39b"+dependencies = [+ "rustversion",+]++[[package]]+name = "itoa"+version = "1.0.18"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"++[[package]]+name = "js-sys"+version = "0.3.99"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "142bc4740e452c1e57ade0cbc129f139c9093e354346f0872ef985f4f5cf5f11"+dependencies = [+ "cfg-if",+ "futures-util",+ "once_cell",+ "wasm-bindgen",+]++[[package]]+name = "kaja-callback-macro"+version = "0.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f991f9438ddafefdef1b5fb95a4a60f3bc834b419c27409d8e10a7839c47af8d"+dependencies = [+ "gloo",+ "proc-macro2",+ "quote",+ "syn 2.0.117",+]++[[package]]+name = "kaja-html-macro"+version = "1.0.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "46133dd45e19d67a03f37f98e356c3851845cec889434a6f928c1403f6abac02"+dependencies = [+ "proc-macro-error",+ "proc-macro2",+ "quote",+ "syn 2.0.117",+]++[[package]]+name = "kaja-web"+version = "1.0.2"+dependencies = [+ "gloo",+ "gloo-console",+ "inventory",+ "js-sys",+ "kaja-callback-macro",+ "kaja-html-macro",+ "serde",+ "serde-wasm-bindgen 0.5.0",+ "wasm-bindgen",+ "wasm-bindgen-futures",+ "web-sys",+]++[[package]]+name = "kaja-web-component-example"+version = "0.1.0"+dependencies = [+ "console_error_panic_hook",+ "gloo",+ "inventory",+ "js-sys",+ "kaja-callback-macro",+ "kaja-html-macro",+ "kaja-web",+ "serde",+ "serde-wasm-bindgen 0.5.0",+ "serde_json",+ "uuid",+ "wasm-bindgen",+ "web-sys",+]++[[package]]+name = "leb128fmt"+version = "0.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"++[[package]]+name = "libc"+version = "0.2.186"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"++[[package]]+name = "log"+version = "0.4.30"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "616ec5685824bcc94416c6d4a7a446eea774a31efd7062c8480ba6fd06d7a6e5"++[[package]]+name = "memchr"+version = "2.8.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6b947ae49db0d222b1dbc6b113ce7248a3fc3a6ca21b696717bfc000ba4484d8"++[[package]]+name = "once_cell"+version = "1.21.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"++[[package]]+name = "percent-encoding"+version = "2.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"++[[package]]+name = "pin-project"+version = "1.1.13"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924"+dependencies = [+ "pin-project-internal",+]++[[package]]+name = "pin-project-internal"+version = "1.1.13"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.117",+]++[[package]]+name = "pin-project-lite"+version = "0.2.17"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"++[[package]]+name = "pinned"+version = "0.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a829027bd95e54cfe13e3e258a1ae7b645960553fb82b75ff852c29688ee595b"+dependencies = [+ "futures",+ "rustversion",+ "thiserror 1.0.69",+]++[[package]]+name = "prettyplease"+version = "0.2.37"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"+dependencies = [+ "proc-macro2",+ "syn 2.0.117",+]++[[package]]+name = "proc-macro-crate"+version = "3.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35"+dependencies = [+ "toml_edit",+]++[[package]]+name = "proc-macro-error"+version = "1.0.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"+dependencies = [+ "proc-macro-error-attr",+ "proc-macro2",+ "quote",+ "syn 1.0.109",+ "version_check",+]++[[package]]+name = "proc-macro-error-attr"+version = "1.0.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"+dependencies = [+ "proc-macro2",+ "quote",+ "version_check",+]++[[package]]+name = "proc-macro2"+version = "1.0.106"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"+dependencies = [+ "unicode-ident",+]++[[package]]+name = "quote"+version = "1.0.45"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"+dependencies = [+ "proc-macro2",+]++[[package]]+name = "r-efi"+version = "6.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"++[[package]]+name = "rustversion"+version = "1.0.22"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"++[[package]]+name = "ryu"+version = "1.0.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"++[[package]]+name = "semver"+version = "1.0.28"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"++[[package]]+name = "serde"+version = "1.0.228"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"+dependencies = [+ "serde_core",+ "serde_derive",+]++[[package]]+name = "serde-wasm-bindgen"+version = "0.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e"+dependencies = [+ "js-sys",+ "serde",+ "wasm-bindgen",+]++[[package]]+name = "serde-wasm-bindgen"+version = "0.6.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b"+dependencies = [+ "js-sys",+ "serde",+ "wasm-bindgen",+]++[[package]]+name = "serde_core"+version = "1.0.228"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"+dependencies = [+ "serde_derive",+]++[[package]]+name = "serde_derive"+version = "1.0.228"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.117",+]++[[package]]+name = "serde_json"+version = "1.0.150"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9"+dependencies = [+ "itoa",+ "memchr",+ "serde",+ "serde_core",+ "zmij",+]++[[package]]+name = "serde_urlencoded"+version = "0.7.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"+dependencies = [+ "form_urlencoded",+ "itoa",+ "ryu",+ "serde",+]++[[package]]+name = "slab"+version = "0.4.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"++[[package]]+name = "syn"+version = "1.0.109"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"+dependencies = [+ "proc-macro2",+ "unicode-ident",+]++[[package]]+name = "syn"+version = "2.0.117"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"+dependencies = [+ "proc-macro2",+ "quote",+ "unicode-ident",+]++[[package]]+name = "thiserror"+version = "1.0.69"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"+dependencies = [+ "thiserror-impl 1.0.69",+]++[[package]]+name = "thiserror"+version = "2.0.18"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"+dependencies = [+ "thiserror-impl 2.0.18",+]++[[package]]+name = "thiserror-impl"+version = "1.0.69"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.117",+]++[[package]]+name = "thiserror-impl"+version = "2.0.18"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.117",+]++[[package]]+name = "toml_datetime"+version = "0.6.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c"++[[package]]+name = "toml_edit"+version = "0.22.27"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"+dependencies = [+ "indexmap",+ "toml_datetime",+ "winnow",+]++[[package]]+name = "unicode-ident"+version = "1.0.24"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"++[[package]]+name = "unicode-xid"+version = "0.2.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"++[[package]]+name = "uuid"+version = "1.23.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d258b83ceec21034727ecee8c382cfa6c3e133699b0742c64571814fb420c9f7"+dependencies = [+ "getrandom 0.4.2",+ "js-sys",+ "wasm-bindgen",+]++[[package]]+name = "version_check"+version = "0.9.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"++[[package]]+name = "wasi"+version = "0.11.1+wasi-snapshot-preview1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"++[[package]]+name = "wasip2"+version = "1.0.3+wasi-0.2.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6"+dependencies = [+ "wit-bindgen 0.57.1",+]++[[package]]+name = "wasip3"+version = "0.4.0+wasi-0.3.0-rc-2026-01-06"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5"+dependencies = [+ "wit-bindgen 0.51.0",+]++[[package]]+name = "wasm-bindgen"+version = "0.2.122"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3ed04576f974d2b2fba0f38c51dbc5518011e38c36bf1143164be765528fd409"+dependencies = [+ "cfg-if",+ "once_cell",+ "rustversion",+ "wasm-bindgen-macro",+ "wasm-bindgen-shared",+]++[[package]]+name = "wasm-bindgen-futures"+version = "0.4.72"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9473dbd2991ae90b6291c3c32c30c6187ac49aa32f9905d1cce280ec1e110b0f"+dependencies = [+ "js-sys",+ "wasm-bindgen",+]++[[package]]+name = "wasm-bindgen-macro"+version = "0.2.122"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "916151b09da36bd82f6615cbf3a419e2f0ba23a03c6160e8e92eb6bd4aa1dec6"+dependencies = [+ "quote",+ "wasm-bindgen-macro-support",+]++[[package]]+name = "wasm-bindgen-macro-support"+version = "0.2.122"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "299047362ccbfce148b67ab7e73349f77748e00c8296f9542adfad2ad82c5c5e"+dependencies = [+ "bumpalo",+ "proc-macro2",+ "quote",+ "syn 2.0.117",+ "wasm-bindgen-shared",+]++[[package]]+name = "wasm-bindgen-shared"+version = "0.2.122"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9a929b2c61f11ba3e9bc35b50c1f25cb38e0e892c0c231ae2b8cf78d5dad4437"+dependencies = [+ "unicode-ident",+]++[[package]]+name = "wasm-encoder"+version = "0.244.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319"+dependencies = [+ "leb128fmt",+ "wasmparser",+]++[[package]]+name = "wasm-metadata"+version = "0.244.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909"+dependencies = [+ "anyhow",+ "indexmap",+ "wasm-encoder",+ "wasmparser",+]++[[package]]+name = "wasmparser"+version = "0.244.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe"+dependencies = [+ "bitflags",+ "hashbrown 0.15.5",+ "indexmap",+ "semver",+]++[[package]]+name = "web-sys"+version = "0.3.99"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6d621441cfc37b84979402712047321980c178f299193a3589d05b99e8763436"+dependencies = [+ "js-sys",+ "wasm-bindgen",+]++[[package]]+name = "winnow"+version = "0.7.15"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945"+dependencies = [+ "memchr",+]++[[package]]+name = "wit-bindgen"+version = "0.51.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"+dependencies = [+ "wit-bindgen-rust-macro",+]++[[package]]+name = "wit-bindgen"+version = "0.57.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"++[[package]]+name = "wit-bindgen-core"+version = "0.51.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc"+dependencies = [+ "anyhow",+ "heck",+ "wit-parser",+]++[[package]]+name = "wit-bindgen-rust"+version = "0.51.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21"+dependencies = [+ "anyhow",+ "heck",+ "indexmap",+ "prettyplease",+ "syn 2.0.117",+ "wasm-metadata",+ "wit-bindgen-core",+ "wit-component",+]++[[package]]+name = "wit-bindgen-rust-macro"+version = "0.51.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a"+dependencies = [+ "anyhow",+ "prettyplease",+ "proc-macro2",+ "quote",+ "syn 2.0.117",+ "wit-bindgen-core",+ "wit-bindgen-rust",+]++[[package]]+name = "wit-component"+version = "0.244.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2"+dependencies = [+ "anyhow",+ "bitflags",+ "indexmap",+ "log",+ "serde",+ "serde_derive",+ "serde_json",+ "wasm-encoder",+ "wasm-metadata",+ "wasmparser",+ "wit-parser",+]++[[package]]+name = "wit-parser"+version = "0.244.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736"+dependencies = [+ "anyhow",+ "id-arena",+ "indexmap",+ "log",+ "semver",+ "serde",+ "serde_derive",+ "serde_json",+ "unicode-xid",+ "wasmparser",+]++[[package]]+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.tomlnew file mode 100644index 0000000..811a0a9--- /dev/null+++ b/examples/components/Cargo.toml@@ -0,0 +1,25 @@+[package]+name = "kaja-web-component-example"+version = "0.1.0"+edition = "2024"++[lib]+crate-type = ["cdylib"]++[dependencies]+wasm-bindgen = "0.2.122"+kaja-web = { path = "../.." }+js-sys = "0.3"+web-sys = { version = "0.3.99", features = ["Element", "HtmlElement", "NodeList", "CustomElementRegistry", "ElementDefinitionOptions"] }+gloo = "0.12"+kaja-html-macro = "1.0.3"+serde = { version = "1.0.228", features = ["derive"] }+serde_json = "1.0.150"+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/build.sh b/examples/components/build.shnew file mode 100755index 0000000..dba3cc0--- /dev/null+++ b/examples/components/build.sh@@ -0,0 +1,13 @@+#!/bin/sh+set -e++wasm-pack build \+    --release \+    --target web \+    --out-dir pkg \+    --out-name componentexample \+    --no-typescript++cp index.html pkg/+cp main.js pkg/+cp styles.css pkg/diff --git a/examples/components/index.html b/examples/components/index.htmlnew file mode 100644index 0000000..7b3ced1--- /dev/null+++ b/examples/components/index.html@@ -0,0 +1,14 @@+<!doctype html>+<html lang="en">+    <head>+        <meta charset="UTF-8" />+        <link rel="stylesheet" href="styles.css" />+        <meta name="viewport" content="width=device-width, initial-scale=1.0" />+        <title>Example: Web Components using Kaja Web</title>+        <script type="module" src="main.js" defer></script>+    </head>++    <body>+        <example-component></example-component>+    </body>+</html>diff --git a/examples/components/main.js b/examples/components/main.jsnew file mode 100644index 0000000..7144a29--- /dev/null+++ b/examples/components/main.js@@ -0,0 +1,18 @@+let wasmModule;++async function loadWasm() {+    try {+        const wasmModule = await import("./componentexample.js");+        await wasmModule.default("./componentexample_bg.wasm");++        return wasmModule;+    } catch (error) {+        console.error("Failed to load WASM module:", error);+    }++    return null;+}++window.addEventListener("DOMContentLoaded", async () => {+    wasmModule = await loadWasm();+});diff --git a/examples/components/run.sh b/examples/components/run.shnew file mode 100755index 0000000..a048608--- /dev/null+++ b/examples/components/run.sh@@ -0,0 +1,7 @@+#!/bin/bash+set -e++./build.sh++cd pkg+python3 -m http.server 8080 --bind 127.0.0.1diff --git a/examples/components/src/lib.rs b/examples/components/src/lib.rsnew file mode 100644index 0000000..3088d6b--- /dev/null+++ b/examples/components/src/lib.rs@@ -0,0 +1,152 @@+use js_sys::Function;+use kaja_web::prelude::*;+use std::sync::RwLock;+use web_sys::HtmlElement;++pub static COUNTER_COMPONENTS: RwLock<Option<Counter>> = RwLock::new(None);++#[callback(counterComponentConnect)]+fn counter_connect(element: HtmlElement, wasm_id: u32) {+    log!("counterComponentConnect");+    let mut counter = COUNTER_COMPONENTS.write().unwrap();++    if counter.is_none() {+        error!("Component not found in connect.");+        return;+    }++    let mut counter_info: &mut Counter = counter.as_mut().unwrap();+    counter_info.connected(element);+}++#[callback(counterComponentDisconnect)]+fn counter_disconnect(element: HtmlElement, wasm_id: u32) {+    log!("counterComponentDisconnect");+    let mut counter = COUNTER_COMPONENTS.write().unwrap();++    if counter.is_none() {+        error!("Component not found in connect.");+        return;+    }++    let mut counter_info: &mut Counter = counter.as_mut().unwrap();+    counter_info.disconnected(element);+}++#[callback(counterInit)]+fn counter_init() {+    log!("counterInit");+    let counter = Counter::default();+    let mut counter_store = COUNTER_COMPONENTS.write().unwrap();+    *counter_store = Some(counter);+}++fn create_component(tag_name: &str) {+    let wasm_id = 0;++    let component = Function::new_no_args(+        r#"+        return class extends HTMLElement {+            let component_id = -1;++            connectedCallback() {+                if (component_id == -1) {+                    component_id = counter_init();+                }++                counterComponentConnect(this, component_id);+            }++            disconnectedCallback() {+                counterComponentDisconnect(this, component_id);+            }++            attributeChangedCallback(name, oldValue, newValue) {+                //callbacks.attributeChanged(this, name, oldValue, newValue);+            }++            static get observedAttributes() {+                return [];+            }+        }+    "#,+    );++    let class = component.call0(&JsValue::NULL);++    if class.is_err() {+        error!("Failed to register class for", tag_name);+        return;+    }++    let class_fn = class.unwrap();+    let registry = web_sys::window().unwrap().custom_elements();++    let result = registry.define(tag_name, &class_fn.unchecked_into());++    if result.is_err() {+        error!("Failed to register component", tag_name);+    }+}++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);+    }+}++//#[component]+#[derive(Default)]+struct Counter {+    value: usize,+}++impl Component for Counter {+    fn connected(&mut self, element: HtmlElement) {+        element.set_inner_html("Hello!");+    }++    fn disconnected(&mut self, element: HtmlElement) {+        element.set_inner_html("Bye");+    }++    fn observed_attributes() -> &'static [&'static str] {+        &["count"]+    }++    fn attribute_changed(+        &mut self,+        element: HtmlElement,+        name: &str,+        old_value: &JsValue,+        new_value: &JsValue,+    ) {+        log!("change", name, old_value, new_value);+    }+}++fn init_components() {+    let _component = create_component("my-button");+}++#[wasm_bindgen(start)]+pub fn init() {+    std::panic::set_hook(Box::new(console_error_panic_hook::hook));+    console_error_panic_hook::set_once();+    init_components();+    init_callbacks();++    create_component("example-component")+}diff --git a/examples/components/styles.css b/examples/components/styles.cssnew file mode 100644index 0000000..e69de29--- /dev/null+++ b/examples/components/styles.cssdiff --git a/src/lib.rs b/src/lib.rsindex 464a664..af7db1b 100644--- a/src/lib.rs+++ b/src/lib.rs@@ -33,7 +33,7 @@ inventory::collect!(CallbackRegistration); /// } /// ``` ///-/// The Rust functions as marked with the `#[callback]` attribute in order to+/// The Rust functions are marked with the `#[callback]` attribute in order to /// be callable from JS. The JS function in this example has the name /// `testCallback`. Note that camel case is used in JS and regular snake case /// is used in Rust for the same function.

Contact

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