feat: bundled web, first attempt
This commit is contained in:
parent
3afa3b72dc
commit
396ac974d0
4 changed files with 211 additions and 5 deletions
173
Cargo.lock
generated
173
Cargo.lock
generated
|
@ -122,6 +122,7 @@ checksum = "41058deaa38c9d9dd933d6d238d825227cffa668e2839b52879f6619c63eee3b"
|
|||
dependencies = [
|
||||
"futures",
|
||||
"thiserror 2.0.11",
|
||||
"tokio",
|
||||
"wasm-bindgen-futures",
|
||||
]
|
||||
|
||||
|
@ -262,13 +263,41 @@ version = "1.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||
|
||||
[[package]]
|
||||
name = "axum"
|
||||
version = "0.7.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"axum-core 0.4.5",
|
||||
"bytes",
|
||||
"futures-util",
|
||||
"http 1.2.0",
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"itoa",
|
||||
"matchit 0.7.3",
|
||||
"memchr",
|
||||
"mime",
|
||||
"multer",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"rustversion",
|
||||
"serde",
|
||||
"sync_wrapper",
|
||||
"tower",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "axum"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d6fd624c75e18b3b4c6b9caf42b1afe24437daaee904069137d8bab077be8b8"
|
||||
dependencies = [
|
||||
"axum-core",
|
||||
"axum-core 0.5.0",
|
||||
"bytes",
|
||||
"form_urlencoded",
|
||||
"futures-util",
|
||||
|
@ -278,7 +307,7 @@ dependencies = [
|
|||
"hyper",
|
||||
"hyper-util",
|
||||
"itoa",
|
||||
"matchit",
|
||||
"matchit 0.8.4",
|
||||
"memchr",
|
||||
"mime",
|
||||
"multer",
|
||||
|
@ -297,6 +326,26 @@ dependencies = [
|
|||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "axum-core"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bytes",
|
||||
"futures-util",
|
||||
"http 1.2.0",
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"mime",
|
||||
"pin-project-lite",
|
||||
"rustversion",
|
||||
"sync_wrapper",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "axum-core"
|
||||
version = "0.5.0"
|
||||
|
@ -1639,6 +1688,12 @@ dependencies = [
|
|||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-range-header"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9171a2ea8a68358193d15dd5d70c1c10a2afc3e7e4c5bc92bc9f025cebd7359c"
|
||||
|
||||
[[package]]
|
||||
name = "httparse"
|
||||
version = "1.9.5"
|
||||
|
@ -1655,7 +1710,7 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
|||
name = "httpsign"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"axum 0.8.1",
|
||||
"base64",
|
||||
"openssl",
|
||||
"thiserror 2.0.11",
|
||||
|
@ -1669,11 +1724,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "d35485b3dcbf7e044b8f28c73f04f13e7b509c2466fd10cb2a8a447e38f8a93a"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"js-sys",
|
||||
"once_cell",
|
||||
"or_poisoned",
|
||||
"pin-project-lite",
|
||||
"serde",
|
||||
"throw_error",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1944,6 +2001,15 @@ version = "0.5.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71dd52191aae121e8611f1e8dc3e324dd0dd1dee1e6dd91d10ee07a3cfb4d9d8"
|
||||
|
||||
[[package]]
|
||||
name = "inventory"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b31349d02fe60f80bbbab1a9402364cad7460626d6030494b08ac4a2075bf81"
|
||||
dependencies = [
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipnet"
|
||||
version = "2.10.1"
|
||||
|
@ -2007,6 +2073,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "21c31c9d022c77702c53e02830d08b28320aca9c0899a19c443096c114623fa5"
|
||||
dependencies = [
|
||||
"any_spawner",
|
||||
"base64",
|
||||
"cfg-if",
|
||||
"either_of",
|
||||
"futures",
|
||||
|
@ -2020,6 +2087,7 @@ dependencies = [
|
|||
"oco_ref",
|
||||
"or_poisoned",
|
||||
"paste",
|
||||
"rand",
|
||||
"reactive_graph",
|
||||
"rustc-hash",
|
||||
"send_wrapper",
|
||||
|
@ -2062,6 +2130,30 @@ dependencies = [
|
|||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "leptos_axum"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43b613d5784037baee42a11d21bc263adfc1a55e416556a3d5bfe39c7b87fadf"
|
||||
dependencies = [
|
||||
"any_spawner",
|
||||
"axum 0.7.9",
|
||||
"dashmap",
|
||||
"futures",
|
||||
"hydration_context",
|
||||
"leptos",
|
||||
"leptos_integration_utils",
|
||||
"leptos_macro",
|
||||
"leptos_meta",
|
||||
"leptos_router",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
"server_fn",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-http",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "leptos_config"
|
||||
version = "0.7.4"
|
||||
|
@ -2109,6 +2201,21 @@ dependencies = [
|
|||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "leptos_integration_utils"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8652fcd7a1744f85403b95c5520143f3b962d640c8450b8514f9530fb5c4b76"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"hydration_context",
|
||||
"leptos",
|
||||
"leptos_config",
|
||||
"leptos_meta",
|
||||
"leptos_router",
|
||||
"reactive_graph",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "leptos_macro"
|
||||
version = "0.7.4"
|
||||
|
@ -2132,6 +2239,22 @@ dependencies = [
|
|||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "leptos_meta"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7250991b2077ef5869e999c74cf4990926a3c3919b50c9937e101c1c874102db"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"indexmap",
|
||||
"leptos",
|
||||
"once_cell",
|
||||
"or_poisoned",
|
||||
"send_wrapper",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "leptos_router"
|
||||
version = "0.7.4"
|
||||
|
@ -2147,6 +2270,7 @@ dependencies = [
|
|||
"leptos_router_macro",
|
||||
"once_cell",
|
||||
"or_poisoned",
|
||||
"percent-encoding",
|
||||
"reactive_graph",
|
||||
"send_wrapper",
|
||||
"tachys",
|
||||
|
@ -2322,6 +2446,12 @@ dependencies = [
|
|||
"regex-automata 0.1.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matchit"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
|
||||
|
||||
[[package]]
|
||||
name = "matchit"
|
||||
version = "0.8.4"
|
||||
|
@ -2359,6 +2489,16 @@ version = "0.3.17"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
|
||||
|
||||
[[package]]
|
||||
name = "mime_guess"
|
||||
version = "2.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e"
|
||||
dependencies = [
|
||||
"mime",
|
||||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
|
@ -3741,12 +3881,16 @@ version = "0.7.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f5dd7fcccd3ef2081da086c1f8595b506627abbbbc9f64be0141d2251219570e"
|
||||
dependencies = [
|
||||
"axum 0.7.9",
|
||||
"bytes",
|
||||
"const_format",
|
||||
"dashmap",
|
||||
"futures",
|
||||
"gloo-net 0.6.0",
|
||||
"http 1.2.0",
|
||||
"http-body-util",
|
||||
"hyper",
|
||||
"inventory",
|
||||
"js-sys",
|
||||
"once_cell",
|
||||
"pin-project-lite",
|
||||
|
@ -3757,6 +3901,8 @@ dependencies = [
|
|||
"server_fn_macro_default",
|
||||
"thiserror 2.0.11",
|
||||
"throw_error",
|
||||
"tower",
|
||||
"tower-layer",
|
||||
"url",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
|
@ -4750,9 +4896,18 @@ checksum = "403fa3b783d4b626a8ad51d766ab03cb6d2dbfc46b1c5d4448395e6628dc9697"
|
|||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bytes",
|
||||
"futures-util",
|
||||
"http 1.2.0",
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"http-range-header",
|
||||
"httpdate",
|
||||
"mime",
|
||||
"mime_guess",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
|
@ -4905,6 +5060,12 @@ dependencies = [
|
|||
"tinystr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.18"
|
||||
|
@ -5036,10 +5197,14 @@ name = "upub-routes"
|
|||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"apb",
|
||||
"axum",
|
||||
"axum 0.8.1",
|
||||
"chrono",
|
||||
"httpsign",
|
||||
"jrd",
|
||||
"leptos",
|
||||
"leptos_axum",
|
||||
"leptos_meta",
|
||||
"leptos_router",
|
||||
"mastodon-async-entities",
|
||||
"nodeinfo",
|
||||
"rand",
|
||||
|
|
|
@ -45,11 +45,13 @@ upub-routes = { path = "routes", optional = true }
|
|||
upub-worker = { path = "worker", optional = true }
|
||||
|
||||
[features]
|
||||
default = ["serve", "migrate", "cli", "worker"]
|
||||
default = ["serve", "migrate", "cli", "worker", "web"]
|
||||
serve = ["dep:upub-routes"]
|
||||
migrate = ["dep:upub-migrations"]
|
||||
cli = ["dep:upub-cli"]
|
||||
worker = ["dep:upub-worker"]
|
||||
web = []
|
||||
web-build-fe = []
|
||||
|
||||
[profile.wasm-release]
|
||||
inherits = "release"
|
||||
|
|
12
build.rs
Normal file
12
build.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
fn main() {
|
||||
#[cfg(all(feature = "web", feature = "web-build-fe"))]
|
||||
{
|
||||
println!("cargo:warning=running sub-process to build frontend");
|
||||
let status = std::process::Command::new("cargo")
|
||||
.current_dir("web")
|
||||
.args(["build", "--profile=wasm-release", "--target=wasm32-unknown-unknown"])
|
||||
.status()
|
||||
.unwrap();
|
||||
assert!(status.success(), "failed building wasm bundle");
|
||||
}
|
||||
}
|
27
routes/src/web.rs
Normal file
27
routes/src/web.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
use axum::{response::IntoResponse, routing::get, Router};
|
||||
|
||||
|
||||
impl super::WebRouter for Router<upub::Context> {
|
||||
fn web_routes(self) -> Self {
|
||||
self
|
||||
.route("/web/assets/upub-web.wasm", get(upub_web_wasm))
|
||||
.route("/web/assets/style.css", get(upub_style_css))
|
||||
.route("/web", get(upub_web_index))
|
||||
.route("/web/", get(upub_web_index))
|
||||
.route("/web/{*any}", get(upub_web_index))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
async fn upub_web_wasm() -> impl IntoResponse {
|
||||
include_bytes!("../../target/wasm32-unknown-unknown/wasm-release/upub-web.wasm")
|
||||
}
|
||||
|
||||
async fn upub_style_css() -> impl IntoResponse {
|
||||
include_str!("../../web/assets/style.css")
|
||||
}
|
||||
|
||||
async fn upub_web_index() -> impl IntoResponse {
|
||||
include_str!("../../web/index.html")
|
||||
}
|
Loading…
Add table
Reference in a new issue