Compare commits

..

6 Commits
v0.6.0 ... 2237

Author SHA1 Message Date
Greg Johnston
bcaa102d8d fix: correctly track source in create_local_resource 2024-01-27 19:49:00 -05:00
Greg Johnston
8a2ae7fc7c \v0.6.3\ 2024-01-26 21:00:21 -05:00
Greg Johnston
9de34b74cf 0.6.2 2024-01-26 18:07:04 -05:00
Greg Johnston
1b5961edaa fix: fix type inference on extract() functions (#2233) 2024-01-26 17:54:42 -05:00
Greg Johnston
26d1aee9ad Update README.md framework comparisons (#2232) 2024-01-26 17:01:26 -05:00
benwis
2bf09384df 0.6.1
Signed-off-by: benwis <ben@celcyon.com>
2024-01-26 12:32:14 -08:00
8 changed files with 91 additions and 39 deletions

View File

@@ -25,22 +25,22 @@ members = [
exclude = ["benchmarks", "examples"]
[workspace.package]
version = "0.6.0"
version = "0.6.3"
[workspace.dependencies]
leptos = { path = "./leptos", version = "0.6.0" }
leptos_dom = { path = "./leptos_dom", version = "0.6.0" }
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.6.0" }
leptos_macro = { path = "./leptos_macro", version = "0.6.0" }
leptos_reactive = { path = "./leptos_reactive", version = "0.6.0" }
leptos_server = { path = "./leptos_server", version = "0.6.0" }
server_fn = { path = "./server_fn", version = "0.6.0" }
server_fn_macro = { path = "./server_fn_macro", version = "0.6.0" }
leptos = { path = "./leptos", version = "0.6.3" }
leptos_dom = { path = "./leptos_dom", version = "0.6.3" }
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.6.3" }
leptos_macro = { path = "./leptos_macro", version = "0.6.3" }
leptos_reactive = { path = "./leptos_reactive", version = "0.6.3" }
leptos_server = { path = "./leptos_server", version = "0.6.3" }
server_fn = { path = "./server_fn", version = "0.6.3" }
server_fn_macro = { path = "./server_fn_macro", version = "0.6.3" }
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.6" }
leptos_config = { path = "./leptos_config", version = "0.6.0" }
leptos_router = { path = "./router", version = "0.6.0" }
leptos_meta = { path = "./meta", version = "0.6.0" }
leptos_integration_utils = { path = "./integrations/utils", version = "0.6.0" }
leptos_config = { path = "./leptos_config", version = "0.6.3" }
leptos_router = { path = "./router", version = "0.6.3" }
leptos_meta = { path = "./meta", version = "0.6.3" }
leptos_integration_utils = { path = "./integrations/utils", version = "0.6.3" }
[profile.release]
codegen-units = 1

View File

@@ -40,6 +40,25 @@ pub fn SimpleCounter(initial_value: i32) -> impl IntoView {
}
}
// we also support a builder syntax rather than the JSX-like `view` macro
#[component]
pub fn SimpleCounterWithBuilder(initial_value: i32) -> impl IntoView {
use leptos::html::*;
let (value, set_value) = create_signal(initial_value);
let clear = move |_| set_value(0);
let decrement = move |_| set_value.update(|value| *value -= 1);
let increment = move |_| set_value.update(|value| *value += 1);
// the `view` macro above expands to this builder syntax
div().child((
button().on(ev::click, clear).child("Clear"),
button().on(ev::click, decrement).child("-1"),
span().child(("Value: ", value, "!")),
button().on(ev::click, increment).child("+1")
))
}
// Easy to use with Trunk (trunkrs.dev) or with a simple wasm-bindgen setup
pub fn main() {
mount_to_body(|| view! {
@@ -141,3 +160,26 @@ Sure! Obviously the `view` macro is for generating DOM nodes but you can use the
I've put together a [very simple GTK example](https://github.com/leptos-rs/leptos/blob/main/examples/gtk/src/main.rs) so you can see what I mean.
The new rendering approach being developed for 0.7 supports “universal rendering,” i.e., it can use any rendering library that supports a small set of 6-8 functions. (This is intended as a layer over typical retained-mode, OOP-style GUI toolkits like the DOM, GTK, etc.) That future rendering work will allow creating native UI in a way that is much more similar to the declarative approach used by the web framework.
### How is this different from Yew?
Yew is the most-used library for Rust web UI development, but there are several differences between Yew and Leptos, in philosophy, approach, and performance.
- **VDOM vs. fine-grained:** Yew is built on the virtual DOM (VDOM) model: state changes cause components to re-render, generating a new virtual DOM tree. Yew diffs this against the previous VDOM, and applies those patches to the actual DOM. Component functions rerun whenever state changes. Leptos takes an entirely different approach. Components run once, creating (and returning) actual DOM nodes and setting up a reactive system to update those DOM nodes.
- **Performance:** This has huge performance implications: Leptos is simply much faster at both creating and updating the UI than Yew is.
- **Server integration:** Yew was created in an era in which browser-rendered single-page apps (SPAs) were the dominant paradigm. While Leptos supports client-side rendering, it also focuses on integrating with the server side of your application via server functions and multiple modes of serving HTML, including out-of-order streaming.
- ### How is this different from Dioxus?
Like Leptos, Dioxus is a framework for building UIs using web technologies. However, there are significant differences in approach and features.
- **VDOM vs. fine-grained:** While Dioxus has a performant virtual DOM (VDOM), it still uses coarse-grained/component-scoped reactivity: changing a stateful value reruns the component function and diffs the old UI against the new one. Leptos components use a different mental model, creating (and returning) actual DOM nodes and setting up a reactive system to update those DOM nodes.
- **Web vs. desktop priorities:** Dioxus uses Leptos server functions in its fullstack mode, but does not have the same `<Suspense>`-based support for things like streaming HTML rendering, or share the same focus on holistic web performance. Leptos tends to prioritize holistic web performance (streaming HTML rendering, smaller WASM binary sizes, etc.), whereas Dioxus has an unparalleled experience when building desktop apps, because your application logic runs as a native Rust binary.
- ### How is this different from Sycamore?
Sycamore and Leptos are both heavily influenced by SolidJS. At this point, Leptos has a larger community and ecosystem and is more actively developed. Other differences:
- **Templating DSLs:** Sycamore uses a custom templating language for its views, while Leptos uses a JSX-like template format.
- **`'static` signals:** One of Leptoss main innovations was the creation of `Copy + 'static` signals, which have excellent ergonomics. Sycamore is in the process of adopting the same pattern, but this is not yet released.
- **Perseus vs. server functions:** The Perseus metaframework provides an opinionated way to build Sycamore apps that include server functionality. Leptos instead provides primitives like server functions in the core of the framework.

View File

@@ -1390,15 +1390,13 @@ impl LeptosRoutes for &mut ServiceConfig {
/// Ok(data)
/// }
/// ```
pub async fn extract<T, CustErr>() -> Result<T, ServerFnError<CustErr>>
pub async fn extract<T>() -> Result<T, ServerFnError>
where
T: actix_web::FromRequest,
<T as FromRequest>::Error: Display,
{
let req = use_context::<HttpRequest>().ok_or_else(|| {
ServerFnError::ServerError(
"HttpRequest should have been provided via context".to_string(),
)
ServerFnError::new("HttpRequest should have been provided via context")
})?;
T::extract(&req)

View File

@@ -55,10 +55,7 @@ use leptos_router::*;
use once_cell::sync::OnceCell;
use parking_lot::RwLock;
use server_fn::redirect::REDIRECT_HEADER;
use std::{
error::Error, fmt::Debug, io, pin::Pin, sync::Arc,
thread::available_parallelism,
};
use std::{fmt::Debug, io, pin::Pin, sync::Arc, thread::available_parallelism};
use tokio_util::task::LocalPoolHandle;
use tracing::Instrument;
@@ -1772,13 +1769,12 @@ fn get_leptos_pool() -> LocalPoolHandle {
/// Ok(query)
/// }
/// ```
pub async fn extract<T, CustErr>() -> Result<T, ServerFnError>
pub async fn extract<T>() -> Result<T, ServerFnError>
where
T: Sized + FromRequestParts<()>,
T::Rejection: Debug,
CustErr: Error + 'static,
{
extract_with_state::<T, (), CustErr>(&()).await
extract_with_state::<T, ()>(&()).await
}
/// A helper to make it easier to use Axum extractors in server functions. This
@@ -1800,18 +1796,14 @@ where
/// Ok(query)
/// }
/// ```
pub async fn extract_with_state<T, S, CustErr>(
state: &S,
) -> Result<T, ServerFnError>
pub async fn extract_with_state<T, S>(state: &S) -> Result<T, ServerFnError>
where
T: Sized + FromRequestParts<S>,
T::Rejection: Debug,
CustErr: Error + 'static,
{
let mut parts = use_context::<Parts>().ok_or_else(|| {
ServerFnError::ServerError::<CustErr>(
"should have had Parts provided by the leptos_axum integration"
.to_string(),
ServerFnError::new(
"should have had Parts provided by the leptos_axum integration",
)
})?;
T::from_request_parts(&mut parts, state)

View File

@@ -385,7 +385,10 @@ where
// client
create_render_effect({
let r = Rc::clone(&r);
move |_| r.load(false, id)
move |_| {
source.track();
r.load(false, id)
}
});
Resource {

View File

@@ -1,6 +1,6 @@
[package]
name = "leptos_meta"
version = "0.6.0"
version = "0.6.3"
edition = "2021"
authors = ["Greg Johnston"]
license = "MIT"

View File

@@ -1,6 +1,6 @@
[package]
name = "leptos_router"
version = "0.6.0"
version = "0.6.3"
edition = "2021"
authors = ["Greg Johnston"]
license = "MIT"

View File

@@ -9,7 +9,7 @@ description = "RPC for any web framework."
readme = "../README.md"
[dependencies]
server_fn_macro_default = "0.6.0"
server_fn_macro_default = { workspace = true }
# used for hashing paths in #[server] macro
const_format = "0.2"
xxhash-rust = { version = "0.8", features = ["const_xxh64"] }
@@ -18,7 +18,7 @@ serde = { version = "1", features = ["derive"] }
send_wrapper = { version = "0.6", features = ["futures"], optional = true }
# registration system
inventory = {version="0.3",optional=true}
inventory = { version = "0.3", optional = true }
dashmap = "5"
once_cell = "1"
@@ -72,11 +72,11 @@ reqwest = { version = "0.11", default-features = false, optional = true, feature
url = "2"
[features]
default = [ "json", "cbor"]
default = ["json", "cbor"]
form-redirects = []
actix = ["ssr", "dep:actix-web", "dep:send_wrapper"]
axum = [
"ssr",
"ssr",
"dep:axum",
"dep:hyper",
"dep:http-body-util",
@@ -109,4 +109,21 @@ all-features = true
# disables some feature combos for testing in CI
[package.metadata.cargo-all-features]
denylist = ["rustls", "default-tls", "form-redirects"]
skip_feature_sets = [["actix", "axum"], ["browser", "actix"], ["browser", "axum"], ["browser", "reqwest"]]
skip_feature_sets = [
[
"actix",
"axum",
],
[
"browser",
"actix",
],
[
"browser",
"axum",
],
[
"browser",
"reqwest",
],
]