Switch over to WebAssembly, Rust and Yew #35

Merged
BlakeRain merged 87 commits from yew-static into main 2023-08-30 18:01:40 +00:00
5 changed files with 83 additions and 10 deletions
Showing only changes of commit 8024a725f3 - Show all commits

58
Cargo.lock generated
View File

@ -123,6 +123,15 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "deranged"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "env_logger" name = "env_logger"
version = "0.10.0" version = "0.10.0"
@ -571,6 +580,15 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "num_threads"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "object" name = "object"
version = "0.31.1" version = "0.31.1"
@ -810,9 +828,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.183" version = "1.0.171"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
@ -830,9 +848,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.183" version = "1.0.171"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -876,8 +894,8 @@ name = "site"
version = "2.0.0" version = "2.0.0"
dependencies = [ dependencies = [
"env_logger", "env_logger",
"futures",
"log", "log",
"time",
"tokio", "tokio",
"wasm-bindgen-futures", "wasm-bindgen-futures",
"wasm-logger", "wasm-logger",
@ -962,6 +980,36 @@ dependencies = [
"syn 2.0.29", "syn 2.0.29",
] ]
[[package]]
name = "time"
version = "0.3.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a79d09ac6b08c1ab3906a2f7cc2e81a0e27c7ae89c63812df75e52bef0751e07"
dependencies = [
"deranged",
"itoa",
"libc",
"num_threads",
"serde",
"time-core",
"time-macros",
]
[[package]]
name = "time-core"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"
[[package]]
name = "time-macros"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75c65469ed6b3a4809d987a41eb1dc918e9bc1d92211cbad7ae82931846f7451"
dependencies = [
"time-core",
]
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.32.0" version = "1.32.0"

View File

@ -26,7 +26,16 @@ name = "site"
yew = { version = "0.20" } yew = { version = "0.20" }
yew-router = { version = "0.17" } yew-router = { version = "0.17" }
log = { version = "0.4" } log = { version = "0.4" }
futures = { version = "0.3", features = ["std"], default-features = false }
[dependencies.time]
version = "0.3"
features = [
"formatting",
"local-offset",
"macros",
"parsing",
"serde"
]
[dependencies.yew_icons] [dependencies.yew_icons]
version = "0.7" version = "0.7"
@ -34,6 +43,11 @@ features = [
"LucideRss" "LucideRss"
] ]
[target.'cfg(target_arch = "wasm32")']
required-features = [
"time/wasm-bindgen"
]
[target.'cfg(target_arch = "wasm32")'.dependencies] [target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen-futures = { version = "0.4" } wasm-bindgen-futures = { version = "0.4" }
wasm-logger = { version = "0.2" } wasm-logger = { version = "0.2" }

View File

@ -2,7 +2,9 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>Blake Rain</title>
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<link data-trunk rel="rust" data-bin="site" /> <link data-trunk rel="rust" data-bin="site" />
<link data-trunk rel="css" href="target/main.css" />
</head> </head>
</html> </html>

View File

@ -112,10 +112,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let template = Template::load(dist_dir.join("index.html")).await?; let template = Template::load(dist_dir.join("index.html")).await?;
let out_dir = root_dir.join("output"); let out_dir = root_dir.join("output");
log::info!("Creating output directory: {out_dir:?}");
log::info!("Removing existing output directory: {out_dir:?}");
tokio::fs::remove_dir_all(&out_dir).await?; tokio::fs::remove_dir_all(&out_dir).await?;
log::info!("Creating output directory: {out_dir:?}");
tokio::fs::create_dir_all(&out_dir).await?; tokio::fs::create_dir_all(&out_dir).await?;
log::info!("Copying resources to output directory");
copy_resources(&dist_dir, &out_dir).await?; copy_resources(&dist_dir, &out_dir).await?;
for RenderRoute { url, path } in collect_routes(&root_dir).await? { for RenderRoute { url, path } in collect_routes(&root_dir).await? {

View File

@ -2,11 +2,17 @@ use site::app::App;
fn main() { fn main() {
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
wasm_logger::init(wasm_logger::Config::new(log::Level::Trace)); wasm_logger::init(wasm_logger::Config::default());
#[cfg(feature = "hydration")] #[cfg(feature = "hydration")]
yew::Renderer::<App>::new().hydrate(); {
log::info!("Hydration build; hydrating application");
yew::Renderer::<App>::new().hydrate();
}
#[cfg(not(feature = "hydration"))] #[cfg(not(feature = "hydration"))]
yew::Renderer::<App>::new().render(); {
log::info!("Standard build; rendering application");
yew::Renderer::<App>::new().render();
}
} }