Compare commits

..

4 Commits

Author SHA1 Message Date
Greg Johnston
f5d3fbb091 0.8.5 2025-07-21 09:04:16 -04:00
Greg Johnston
fbe7cdc482 docs: update documentation for #[lazy] and #[lazy_route] 2025-07-21 08:53:38 -04:00
Greg Johnston
14884bc8ac Merge pull request #3988 from leptos-rs/wasm-splitting-support
feat: wasm-splitting library support for future cargo-leptos integration
2025-07-21 07:17:29 -04:00
martin frances
5f2d511553 chore: bump oco_ref version number (#4168) 2025-07-20 18:44:09 -04:00
12 changed files with 117 additions and 57 deletions

49
Cargo.lock generated
View File

@@ -1788,7 +1788,7 @@ checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388"
[[package]]
name = "leptos"
version = "0.8.4"
version = "0.8.5"
dependencies = [
"any_spawner",
"base64",
@@ -1844,7 +1844,7 @@ dependencies = [
[[package]]
name = "leptos_actix"
version = "0.8.4"
version = "0.8.5"
dependencies = [
"actix-files",
"actix-http",
@@ -1869,7 +1869,7 @@ dependencies = [
[[package]]
name = "leptos_axum"
version = "0.8.4"
version = "0.8.5"
dependencies = [
"any_spawner",
"axum",
@@ -1892,7 +1892,7 @@ dependencies = [
[[package]]
name = "leptos_config"
version = "0.8.4"
version = "0.8.5"
dependencies = [
"config",
"regex",
@@ -1906,7 +1906,7 @@ dependencies = [
[[package]]
name = "leptos_dom"
version = "0.8.4"
version = "0.8.5"
dependencies = [
"js-sys",
"leptos",
@@ -1923,7 +1923,7 @@ dependencies = [
[[package]]
name = "leptos_hot_reload"
version = "0.8.4"
version = "0.8.5"
dependencies = [
"anyhow",
"camino",
@@ -1939,7 +1939,7 @@ dependencies = [
[[package]]
name = "leptos_integration_utils"
version = "0.8.4"
version = "0.8.5"
dependencies = [
"futures",
"hydration_context",
@@ -1952,7 +1952,7 @@ dependencies = [
[[package]]
name = "leptos_macro"
version = "0.8.4"
version = "0.8.5"
dependencies = [
"attribute-derive",
"cfg-if",
@@ -1972,7 +1972,7 @@ dependencies = [
"rustc_version",
"serde",
"server_fn",
"server_fn_macro 0.8.4",
"server_fn_macro 0.8.5",
"syn 2.0.104",
"tracing",
"trybuild",
@@ -1982,7 +1982,7 @@ dependencies = [
[[package]]
name = "leptos_meta"
version = "0.8.4"
version = "0.8.5"
dependencies = [
"futures",
"indexmap",
@@ -1996,7 +1996,7 @@ dependencies = [
[[package]]
name = "leptos_router"
version = "0.8.4"
version = "0.8.5"
dependencies = [
"any_spawner",
"either_of",
@@ -2020,8 +2020,9 @@ dependencies = [
[[package]]
name = "leptos_router_macro"
version = "0.8.4"
version = "0.8.5"
dependencies = [
"leptos",
"leptos_macro",
"leptos_router",
"proc-macro-error2",
@@ -2032,7 +2033,7 @@ dependencies = [
[[package]]
name = "leptos_server"
version = "0.8.4"
version = "0.8.5"
dependencies = [
"any_spawner",
"base64",
@@ -2312,7 +2313,7 @@ dependencies = [
[[package]]
name = "oco_ref"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"serde",
"serde_json",
@@ -2716,9 +2717,9 @@ dependencies = [
[[package]]
name = "rand"
version = "0.9.1"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97"
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
dependencies = [
"rand_chacha",
"rand_core",
@@ -2745,7 +2746,7 @@ dependencies = [
[[package]]
name = "reactive_graph"
version = "0.2.4"
version = "0.2.5"
dependencies = [
"any_spawner",
"async-lock",
@@ -2768,7 +2769,7 @@ dependencies = [
[[package]]
name = "reactive_stores"
version = "0.2.4"
version = "0.2.5"
dependencies = [
"any_spawner",
"dashmap",
@@ -2787,7 +2788,7 @@ dependencies = [
[[package]]
name = "reactive_stores_macro"
version = "0.2.4"
version = "0.2.5"
dependencies = [
"convert_case 0.8.0",
"proc-macro-error2",
@@ -3281,7 +3282,7 @@ dependencies = [
[[package]]
name = "server_fn"
version = "0.8.4"
version = "0.8.5"
dependencies = [
"actix-web",
"actix-ws",
@@ -3344,7 +3345,7 @@ dependencies = [
[[package]]
name = "server_fn_macro"
version = "0.8.4"
version = "0.8.5"
dependencies = [
"const_format",
"convert_case 0.8.0",
@@ -3357,9 +3358,9 @@ dependencies = [
[[package]]
name = "server_fn_macro_default"
version = "0.8.4"
version = "0.8.5"
dependencies = [
"server_fn_macro 0.8.4",
"server_fn_macro 0.8.5",
"syn 2.0.104",
]
@@ -3561,7 +3562,7 @@ dependencies = [
[[package]]
name = "tachys"
version = "0.2.5"
version = "0.2.6"
dependencies = [
"any_spawner",
"async-trait",

View File

@@ -40,7 +40,7 @@ members = [
exclude = ["benchmarks", "examples", "projects"]
[workspace.package]
version = "0.8.4"
version = "0.8.5"
edition = "2021"
rust-version = "1.88"
@@ -51,26 +51,26 @@ any_spawner = { path = "./any_spawner/", version = "0.3.0" }
const_str_slice_concat = { path = "./const_str_slice_concat", version = "0.1" }
either_of = { path = "./either_of/", version = "0.1.6" }
hydration_context = { path = "./hydration_context", version = "0.3.0" }
leptos = { path = "./leptos", version = "0.8.4" }
leptos_config = { path = "./leptos_config", version = "0.8.4" }
leptos_dom = { path = "./leptos_dom", version = "0.8.4" }
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.8.4" }
leptos_integration_utils = { path = "./integrations/utils", version = "0.8.4" }
leptos_macro = { path = "./leptos_macro", version = "0.8.4" }
leptos_router = { path = "./router", version = "0.8.4" }
leptos_router_macro = { path = "./router_macro", version = "0.8.4" }
leptos_server = { path = "./leptos_server", version = "0.8.4" }
leptos_meta = { path = "./meta", version = "0.8.4" }
leptos = { path = "./leptos", version = "0.8.5" }
leptos_config = { path = "./leptos_config", version = "0.8.5" }
leptos_dom = { path = "./leptos_dom", version = "0.8.5" }
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.8.5" }
leptos_integration_utils = { path = "./integrations/utils", version = "0.8.5" }
leptos_macro = { path = "./leptos_macro", version = "0.8.5" }
leptos_router = { path = "./router", version = "0.8.5" }
leptos_router_macro = { path = "./router_macro", version = "0.8.5" }
leptos_server = { path = "./leptos_server", version = "0.8.5" }
leptos_meta = { path = "./meta", version = "0.8.5" }
next_tuple = { path = "./next_tuple", version = "0.1.0" }
oco_ref = { path = "./oco", version = "0.2.0" }
oco_ref = { path = "./oco", version = "0.2.1" }
or_poisoned = { path = "./or_poisoned", version = "0.1.0" }
reactive_graph = { path = "./reactive_graph", version = "0.2.4" }
reactive_stores = { path = "./reactive_stores", version = "0.2.4" }
reactive_stores_macro = { path = "./reactive_stores_macro", version = "0.2.4" }
server_fn = { path = "./server_fn", version = "0.8.4" }
server_fn_macro = { path = "./server_fn_macro", version = "0.8.4" }
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.8.4" }
tachys = { path = "./tachys", version = "0.2.5" }
reactive_graph = { path = "./reactive_graph", version = "0.2.5" }
reactive_stores = { path = "./reactive_stores", version = "0.2.5" }
reactive_stores_macro = { path = "./reactive_stores_macro", version = "0.2.5" }
server_fn = { path = "./server_fn", version = "0.8.5" }
server_fn_macro = { path = "./server_fn_macro", version = "0.8.5" }
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.8.5" }
tachys = { path = "./tachys", version = "0.2.6" }
wasm_split_helpers = { path = "./wasm_split", version = "0.1.0" }
wasm_split_macros = { path = "./wasm_split_macros", version = "0.1.0" }

View File

@@ -1030,14 +1030,41 @@ pub fn memo(input: TokenStream) -> TokenStream {
memo::memo_impl(input)
}
/// The `#[lazy]` macro marks an `async` function as a function that can be lazy-loaded from a
/// separate (WebAssembly) binary.
/// The `#[lazy]` macro indicates that a function can be lazy-loaded from a separate WebAssembly (WASM) binary.
///
/// The first time the function is called, calling the function will first load that other binary,
/// then call the function. On subsequent call it will be called immediately, but still return
/// then call the function. On subsequent calls it will be called immediately, but still return
/// asynchronously to maintain the same API.
///
/// All parameters and output types should be concrete types, with no generics.
/// `#[lazy]` can be used to annotate synchronous or `async` functions. In both cases, the final function will be
/// `async` and must be called as such.
///
/// All parameters and output types should be concrete types, with no generics or `impl Trait` types.
///
/// This should be used in tandem with a suitable build process, such as `cargo leptos --split`.
///
/// ```rust
/// # use leptos_macro::lazy;
///
/// #[lazy]
/// fn lazy_synchronous_function() -> String {
/// "Hello, lazy world!".to_string()
/// }
///
/// #[lazy]
/// async fn lazy_async_function() -> String {
/// /* do something that requires async work */
/// "Hello, lazy async world!".to_string()
/// }
///
/// async fn use_lazy_functions() {
/// // synchronous function has been converted to async
/// let value1 = lazy_synchronous_function().await;
///
/// // async function is still async
/// let value1 = lazy_async_function().await;
/// }
/// ```
#[proc_macro_attribute]
#[proc_macro_error]
pub fn lazy(args: proc_macro::TokenStream, s: TokenStream) -> TokenStream {

View File

@@ -1,6 +1,6 @@
[package]
name = "leptos_meta"
version = "0.8.4"
version = { workspace = true }
authors = ["Greg Johnston"]
license = "MIT"
repository = "https://github.com/leptos-rs/leptos"

View File

@@ -1,6 +1,6 @@
[package]
name = "oco_ref"
version = "0.2.0"
version = "0.2.1"
authors = ["Danik Vitek", "Greg Johnston"]
license = "MIT"
repository = "https://github.com/leptos-rs/leptos"
@@ -10,7 +10,7 @@ edition.workspace = true
[dependencies]
serde = { workspace = true, default-features = true }
thiserror = { workspace = true , default-features = true }
thiserror = { workspace = true, default-features = true }
[dev-dependencies]
serde_json = { workspace = true , default-features = true }
serde_json = { workspace = true, default-features = true }

View File

@@ -1,6 +1,6 @@
[package]
name = "reactive_graph"
version = "0.2.4"
version = "0.2.5"
authors = ["Greg Johnston"]
license = "MIT"
readme = "../README.md"

View File

@@ -1,6 +1,6 @@
[package]
name = "reactive_stores"
version = "0.2.4"
version = "0.2.5"
authors = ["Greg Johnston"]
license = "MIT"
readme = "../README.md"

View File

@@ -1,6 +1,6 @@
[package]
name = "reactive_stores_macro"
version = "0.2.4"
version = "0.2.5"
authors = ["Greg Johnston"]
license = "MIT"
readme = "../README.md"

View File

@@ -1,6 +1,6 @@
[package]
name = "leptos_router"
version = "0.8.4"
version = { workspace = true }
authors = ["Greg Johnston", "Ben Wishovich"]
license = "MIT"
readme = "../README.md"

View File

@@ -1,6 +1,6 @@
[package]
name = "leptos_router_macro"
version = "0.8.4"
version = { workspace = true }
authors = ["Greg Johnston", "Ben Wishovich"]
license = "MIT"
readme = "../README.md"
@@ -19,6 +19,7 @@ quote = { workspace = true, default-features = true }
syn = { features = ["full"], workspace = true, default-features = true }
[dev-dependencies]
leptos = { path = "../leptos" }
leptos_router = { path = "../router" }
leptos_macro = { path = "../leptos_macro" }

View File

@@ -198,6 +198,37 @@ impl ToTokens for Segments {
/// add a [`lazy`] annotation to the `view` method, which will cause the code for the view
/// to lazy-load concurrently with the `data` being loaded for the route.
///
/// ```rust
/// use leptos::prelude::*;
/// use leptos_router::{lazy_route, LazyRoute};
///
/// // the route definition
/// #[derive(Debug)]
/// struct BlogListingRoute {
/// titles: Resource<Vec<String>>
/// }
///
/// #[lazy_route]
/// impl LazyRoute for BlogListingRoute {
/// fn data() -> Self {
/// Self {
/// titles: Resource::new(|| (), |_| async {
/// vec![/* todo: load blog posts */]
/// })
/// }
/// }
///
/// // this function will be lazy-loaded, concurrently with data()
/// fn view(this: Self) -> AnyView {
/// let BlogListingRoute { titles } = this;
///
/// // ... now you can use the `posts` resource with Suspense, etc.,
/// // and return AnyView by calling .into_any() on a view
/// # ().into_any()
/// }
/// }
/// ```
///
/// [`impl LazyRoute`]: https://docs.rs/leptos_router/latest/leptos_router/trait.LazyRoute.html
/// [`lazy`]: https://docs.rs/leptos_macro/latest/leptos_macro/macro.lazy.html
#[proc_macro_attribute]

View File

@@ -1,6 +1,6 @@
[package]
name = "tachys"
version = "0.2.5"
version = "0.2.6"
authors = ["Greg Johnston"]
license = "MIT"
readme = "../README.md"