diff --git a/Cargo.lock b/Cargo.lock index f36e42a..90f0d32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,37 +4,42 @@ version = 3 [[package]] name = "bitflags" -version = "2.10.0" +version = "2.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" [[package]] name = "bumpalo" -version = "3.19.1" +version = "3.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" [[package]] name = "cfg-if" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" [[package]] -name = "console_error_panic_hook" -version = "0.1.7" +name = "html" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +checksum = "944d7db81871c611549302f3014418fedbcfbc46902f97e6a1c4f53e785903d2" dependencies = [ - "cfg-if", - "wasm-bindgen", + "html-sys", ] +[[package]] +name = "html-sys" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13eca55667a5657dd1b86db77c5fe2d1810e3f9413e9555a2c4c461733dd2573" + [[package]] name = "js-sys" -version = "0.3.85" +version = "0.3.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3" +checksum = "2e04e2ef80ce82e13552136fabeef8a5ed1f985a96805761cbb9a2c34e7664d9" dependencies = [ "once_cell", "wasm-bindgen", @@ -75,39 +80,39 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.21.3" +version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "proc-macro2" -version = "1.0.106" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.44" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" dependencies = [ "proc-macro2", ] [[package]] name = "rustversion" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" [[package]] name = "syn" -version = "2.0.114" +version = "2.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" dependencies = [ "proc-macro2", "quote", @@ -116,9 +121,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.22" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" +checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954" [[package]] name = "wasi" @@ -141,9 +146,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.108" +version = "0.2.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566" +checksum = "0551fc1bb415591e3372d0bc4780db7e587d84e2a7e79da121051c5c4b89d0b0" dependencies = [ "cfg-if", "once_cell", @@ -154,9 +159,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.108" +version = "0.2.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608" +checksum = "7fbdf9a35adf44786aecd5ff89b4563a90325f9da0923236f6104e603c7e86be" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -164,9 +169,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.108" +version = "0.2.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55" +checksum = "dca9693ef2bab6d4e6707234500350d8dad079eb508dca05530c85dc3a529ff2" dependencies = [ "bumpalo", "proc-macro2", @@ -177,23 +182,33 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.108" +version = "0.2.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12" +checksum = "39129a682a6d2d841b6c429d0c51e5cb0ed1a03829d8b3d1e69a011e62cb3d3b" dependencies = [ "unicode-ident", ] [[package]] name = "web-sys" -version = "0.3.85" +version = "0.3.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "312e32e551d92129218ea9a2452120f4aabc03529ef03e4d0d82fb2780608598" +checksum = "cd70027e39b12f0849461e08ffc50b9cd7688d942c1c8e3c7b22273236b4dd0a" dependencies = [ "js-sys", "wasm-bindgen", ] +[[package]] +name = "web_panic_hook" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf3adcf79d2736b0910581f6c81057e73cb183ee60c5ae197b8ddfc444cdea1a" +dependencies = [ + "html", + "web-sys", +] + [[package]] name = "whoami" version = "2.1.3" @@ -209,9 +224,9 @@ dependencies = [ name = "whoami_web" version = "0.0.0" dependencies = [ - "console_error_panic_hook", "wasm-bindgen", "web-sys", + "web_panic_hook", "whoami", ] diff --git a/example-web/Cargo.toml b/example-web/Cargo.toml index b2c6e04..2088d29 100644 --- a/example-web/Cargo.toml +++ b/example-web/Cargo.toml @@ -1,31 +1,29 @@ [package] name = "whoami_web" edition = "2021" +rust-version = "1.75" [lib] crate-type = ["cdylib", "rlib"] -[features] -default = ["console_error_panic_hook"] - -# The `console_error_panic_hook` crate provides better debugging of panics by -# logging them with `console.error`. This is great for development, but requires -# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for -# code size when deploying. -[dependencies.console_error_panic_hook] -version = "0.1.7" +# The web panic hook crate provides a visual display during panics +[dependencies.web_panic_hook] +version = "0.1.0" optional = true # wasm-bindgen lets us export our main function to the javascript that runs the # web assembly module. [dependencies.wasm-bindgen] -version = "0.2.100" +version = "0.2.117" # The `web-sys` crate lets us log in the web console. [dependencies.web-sys] -version = "0.3.77" +version = "0.3.94" features = ["console"] # `whoami` - the crate we're testing! [dependencies.whoami] path = "../whoami" + +[features] +default = ["web_panic_hook"] diff --git a/example-web/README.md b/example-web/README.md index b008fc0..a4e2d5c 100644 --- a/example-web/README.md +++ b/example-web/README.md @@ -3,13 +3,13 @@ ## Install `wasm-pack` and `http` ```bash curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -cargo install https +cargo install simple-http-server --locked ``` ## Build & Run Web Server ```bash -wasm-pack build --target web && http . +wasm-pack build --target web && simple-http-server . ``` -Now, open http://localhost:8000/ in your web browser and check the javascript -console. +Now, open http://localhost:8000/index.html in your web browser and check the +javascript console. diff --git a/example-web/src/lib.rs b/example-web/src/lib.rs index 4d93781..c8050e1 100644 --- a/example-web/src/lib.rs +++ b/example-web/src/lib.rs @@ -12,8 +12,8 @@ pub fn main() { // // For more details see // https://github.com/rustwasm/console_error_panic_hook#readme - #[cfg(feature = "console_error_panic_hook")] - console_error_panic_hook::set_once(); + #[cfg(feature = "web_panic_hook")] + std::panic::set_hook(Box::new(web_panic_hook::hook)); // Print out code from regular example. log(format!( diff --git a/whoami/Cargo.toml b/whoami/Cargo.toml index 16b8f89..c82eabc 100644 --- a/whoami/Cargo.toml +++ b/whoami/Cargo.toml @@ -34,7 +34,7 @@ default-features = false # Target-specific dependency for unix-like [target.'cfg(all(any(target_vendor = "apple", target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd", target_os = "illumos", target_os = "hurd"), not(target_arch = "wasm32")))'.dependencies.libc] -version = "0.2.186" +version = "0.2.190" optional = true features = [] default-features = false @@ -55,7 +55,7 @@ default-features = false # Target-specific dependency for web browser [target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi"), not(daku)))'.dependencies.web-sys] -version = "0.3.85" +version = "0.3.94" optional = true features = ["Navigator", "Document", "Window", "Location"] default-features = false