feat: update dependencies and update leptos to v0.6.0-rc1

This commit is contained in:
luoxiao 2024-01-27 00:06:07 +08:00 committed by luoxiaozero
parent 24df111b4b
commit 9817acdcfa
8 changed files with 72 additions and 72 deletions

View file

@ -7,9 +7,9 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
leptos = { version = "0.5.7" }
leptos_meta = { version = "0.5.7" }
leptos_router = { version = "0.5.7" }
leptos = { version = "0.6.0-rc1" }
leptos_meta = { version = "0.6.0-rc1" }
leptos_router = { version = "0.6.0-rc1" }
leptos_devtools = { version = "0.0.1", optional = true}
thaw = { path = "../thaw", default-features = false }
demo_markdown = { path = "../demo_markdown" }

View file

@ -10,8 +10,8 @@ edition = "2021"
proc-macro = true
[dependencies]
quote = "1.0.33"
comrak = "0.20.0"
proc-macro2 = "1.0.71"
syn = "2.0.43"
quote = "1.0.35"
comrak = "0.21.0"
proc-macro2 = "1.0.78"
syn = "2.0.48"
syntect = "5.1.0"

View file

@ -145,5 +145,6 @@ fn iter_nodes<'a>(node: &'a AstNode<'a>, demos: &mut Vec<String>) -> TokenStream
NodeValue::Link(_) => quote!("Link todo!!!"),
NodeValue::Image(_) => quote!("Image todo!!!"),
NodeValue::FootnoteReference(_) => quote!("FootnoteReference todo!!!"),
NodeValue::MultilineBlockQuote(_) => quote!("FootnoteReference todo!!!"),
}
}

View file

@ -7,22 +7,22 @@ edition = "2021"
crate-type = ["cdylib", "rlib"]
[dependencies]
axum = { version = "0.6.4", optional = true }
axum = { version = "0.7.4", optional = true }
console_error_panic_hook = "0.1"
console_log = "1"
cfg-if = "1"
leptos = { version = "0.5" }
leptos_axum = { version = "0.5", optional = true }
leptos_meta = { version = "0.5" }
leptos_router = { version = "0.5" }
leptos = { version = "0.6.0-rc1" }
leptos_axum = { version = "0.6.0-rc1", optional = true }
leptos_meta = { version = "0.6.0-rc1" }
leptos_router = { version = "0.6.0-rc1" }
log = "0.4"
simple_logger = "4"
tokio = { version = "1.25.0", optional = true }
tokio = { version = "1.35.1", features = ["rt-multi-thread"], optional = true }
tower = { version = "0.4.13", optional = true }
tower-http = { version = "0.4", features = ["fs"], optional = true }
wasm-bindgen = "=0.2.89"
thiserror = "1.0.38"
tracing = { version = "0.1.37", optional = true }
tower-http = { version = "0.5.1", features = ["fs"], optional = true }
wasm-bindgen = "=0.2.90"
thiserror = "1.0.56"
tracing = { version = "0.1.40", optional = true }
http = "0.2.8"
demo = { path = "../../demo", default-features = false }

View file

@ -1,40 +1,42 @@
use cfg_if::cfg_if;
use axum::{
body::Body,
extract::State,
http::{Request, Response, StatusCode, Uri},
response::{IntoResponse, Response as AxumResponse},
};
use demo::App;
use leptos::{view, LeptosOptions};
use tower::ServiceExt;
use tower_http::services::ServeDir;
cfg_if! { if #[cfg(feature = "ssr")] {
use axum::{
body::{boxed, Body, BoxBody},
extract::State,
response::IntoResponse,
http::{Request, Response, StatusCode, Uri},
};
use axum::response::Response as AxumResponse;
use tower::ServiceExt;
use tower_http::services::ServeDir;
use leptos::*;
use demo::App;
pub async fn file_and_error_handler(
uri: Uri,
State(options): State<LeptosOptions>,
req: Request<Body>,
) -> AxumResponse {
let root = options.site_root.clone();
let res = get_static_file(uri.clone(), &root).await.unwrap();
pub async fn file_and_error_handler(uri: Uri, State(options): State<LeptosOptions>, req: Request<Body>) -> AxumResponse {
let root = options.site_root.clone();
let res = get_static_file(uri.clone(), &root).await.unwrap();
if res.status() == StatusCode::OK {
res.into_response()
} else {
let handler = leptos_axum::render_app_to_stream(options.to_owned(), move || view!{<App/>});
handler(req).await.into_response()
}
if res.status() == StatusCode::OK {
res.into_response()
} else {
let handler = leptos_axum::render_app_to_stream(options.to_owned(), move || view! {<App/>});
handler(req).await.into_response()
}
}
async fn get_static_file(uri: Uri, root: &str) -> Result<Response<BoxBody>, (StatusCode, String)> {
let req = Request::builder().uri(uri.clone()).body(Body::empty()).unwrap();
// `ServeDir` implements `tower::Service` so we can call it with `tower::ServiceExt::oneshot`
// This path is relative to the cargo root
match ServeDir::new(root).oneshot(req).await {
Ok(res) => Ok(res.map(boxed)),
Err(err) => Err((
StatusCode::INTERNAL_SERVER_ERROR,
format!("Something went wrong: {err}"),
)),
}
async fn get_static_file(uri: Uri, root: &str) -> Result<Response<Body>, (StatusCode, String)> {
let req = Request::builder()
.uri(uri.clone())
.body(Body::empty())
.unwrap();
// `ServeDir` implements `tower::Service` so we can call it with `tower::ServiceExt::oneshot`
// This path is relative to the cargo root
match ServeDir::new(root).oneshot(req).await {
Ok(res) => Ok(res.into_response()),
Err(err) => Err((
StatusCode::INTERNAL_SERVER_ERROR,
format!("Something went wrong: {err}"),
)),
}
}}
}

View file

@ -1,17 +1,14 @@
use cfg_if::cfg_if;
#[cfg(feature = "ssr")]
pub mod fileserv;
cfg_if! { if #[cfg(feature = "hydrate")] {
use leptos::*;
use wasm_bindgen::prelude::wasm_bindgen;
#[cfg(feature = "hydrate")]
#[wasm_bindgen::prelude::wasm_bindgen]
pub fn hydrate() {
use demo::App;
#[wasm_bindgen]
pub fn hydrate() {
// initializes logging using the `log` crate
_ = console_log::init_with_level(log::Level::Debug);
console_error_panic_hook::set_once();
// initializes logging using the `log` crate
_ = console_log::init_with_level(log::Level::Debug);
console_error_panic_hook::set_once();
leptos::mount_to_body(App);
}
}}
leptos::mount_to_body(App);
}

View file

@ -29,8 +29,8 @@ async fn main() {
// run our app with hyper
// `axum::Server` is a re-export of `hyper::Server`
log::info!("listening on http://{}", &addr);
axum::Server::bind(&addr)
.serve(app.into_make_service())
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
axum::serve(listener, app.into_make_service())
.await
.unwrap();
}

View file

@ -13,19 +13,19 @@ license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
leptos = { version = "0.5.7" }
leptos_meta = { version = "0.5.7", optional = true }
web-sys = { version = "0.3.63", features = [
leptos = { version = "0.6.0-rc1" }
leptos_meta = { version = "0.6.0-rc1", optional = true }
web-sys = { version = "0.3.67", features = [
"DomRect",
"File",
"FileList",
"DataTransfer",
] }
wasm-bindgen = "0.2.89"
wasm-bindgen = "0.2.90"
icondata = "0.3.0"
uuid = { version = "1.5.0", features = ["v4"] }
uuid = { version = "1.7.0", features = ["v4"] }
cfg-if = "1.0.0"
chrono = "0.4.31"
chrono = "0.4.33"
[features]
default = ["csr"]