Compare commits

..

10 Commits
3280 ... v0.7.0

Author SHA1 Message Date
Greg Johnston
d665dd4b89 v0.7.0 2024-11-30 12:09:41 -05:00
Greg Johnston
be740b38ee feat: add NodeRef::on_load() and writeable NodeRef (#3305) 2024-11-30 11:55:13 -05:00
Rakshith Ravi
d2803c938c chore: remove pre-release message from README (#3075) 2024-11-30 11:48:50 -05:00
Greg Johnston
f29224415a fix: sort tuple-syntax class and style in addition to colon-syntax (closes #3296) (#3303) 2024-11-29 19:28:11 -05:00
Greg Johnston
292772c4d6 fix: allow a deprecated wasm-bindgen struct 2024-11-29 15:50:57 -05:00
benwis
5947aa299e Release rc3 2024-11-28 11:28:20 -08:00
Greg Johnston
6098836cf7 docs: improve line location of hydration error message when using view macro (#3293) 2024-11-27 14:36:31 -05:00
Niklas Eicker
2dfa61ff6a docs: fix help message for island macro (#3287) 2024-11-24 14:45:10 -05:00
Darwin Boersma
4f39b0b0ef Version any_spawner alongside other crates, reexport CustomExecutor (#3284)
* rc2 version any_spawner

Signed-off-by: Darwin Boersma <darwin@sadlark.com>

* reexport full any_spawner crate

Signed-off-by: Darwin Boersma <darwin@sadlark.com>

---------

Signed-off-by: Darwin Boersma <darwin@sadlark.com>
2024-11-23 14:49:43 -08:00
dependabot[bot]
980595f1f0 chore(deps): bump proc-macro2 from 1.0.91 to 1.0.92 (#3276)
Bumps [proc-macro2](https://github.com/dtolnay/proc-macro2) from 1.0.91 to 1.0.92.
- [Release notes](https://github.com/dtolnay/proc-macro2/releases)
- [Commits](https://github.com/dtolnay/proc-macro2/compare/1.0.91...1.0.92)

---
updated-dependencies:
- dependency-name: proc-macro2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-23 08:29:52 -05:00
21 changed files with 145 additions and 91 deletions

54
Cargo.lock generated
View File

@@ -273,7 +273,7 @@ dependencies = [
[[package]]
name = "any_spawner"
version = "0.1.1"
version = "0.2.0"
dependencies = [
"async-executor",
"futures",
@@ -1448,7 +1448,7 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
[[package]]
name = "hydration_context"
version = "0.2.0-rc2"
version = "0.2.0"
dependencies = [
"futures",
"js-sys",
@@ -1765,7 +1765,7 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "leptos"
version = "0.7.0-rc2"
version = "0.7.0"
dependencies = [
"any_spawner",
"base64",
@@ -1815,7 +1815,7 @@ dependencies = [
[[package]]
name = "leptos_actix"
version = "0.7.0-rc2"
version = "0.7.0"
dependencies = [
"actix-files",
"actix-http",
@@ -1840,7 +1840,7 @@ dependencies = [
[[package]]
name = "leptos_axum"
version = "0.7.0-rc2"
version = "0.7.0"
dependencies = [
"any_spawner",
"axum",
@@ -1863,7 +1863,7 @@ dependencies = [
[[package]]
name = "leptos_config"
version = "0.7.0-rc2"
version = "0.7.0"
dependencies = [
"config",
"regex",
@@ -1877,7 +1877,7 @@ dependencies = [
[[package]]
name = "leptos_dom"
version = "0.7.0-rc2"
version = "0.7.0"
dependencies = [
"js-sys",
"leptos",
@@ -1894,7 +1894,7 @@ dependencies = [
[[package]]
name = "leptos_hot_reload"
version = "0.7.0-rc2"
version = "0.7.0"
dependencies = [
"anyhow",
"camino",
@@ -1910,7 +1910,7 @@ dependencies = [
[[package]]
name = "leptos_integration_utils"
version = "0.7.0-rc2"
version = "0.7.0"
dependencies = [
"futures",
"hydration_context",
@@ -1923,7 +1923,7 @@ dependencies = [
[[package]]
name = "leptos_macro"
version = "0.7.0-rc2"
version = "0.7.0"
dependencies = [
"attribute-derive",
"cfg-if",
@@ -1941,7 +1941,7 @@ dependencies = [
"rstml",
"serde",
"server_fn",
"server_fn_macro 0.7.0-rc2",
"server_fn_macro 0.7.0",
"syn 2.0.89",
"tracing",
"trybuild",
@@ -1951,7 +1951,7 @@ dependencies = [
[[package]]
name = "leptos_meta"
version = "0.7.0-rc2"
version = "0.7.0"
dependencies = [
"futures",
"indexmap",
@@ -1966,7 +1966,7 @@ dependencies = [
[[package]]
name = "leptos_router"
version = "0.7.0-rc2"
version = "0.7.0"
dependencies = [
"any_spawner",
"either_of",
@@ -1990,7 +1990,7 @@ dependencies = [
[[package]]
name = "leptos_router_macro"
version = "0.7.0-rc2"
version = "0.7.0"
dependencies = [
"leptos_router",
"proc-macro-error2",
@@ -2000,7 +2000,7 @@ dependencies = [
[[package]]
name = "leptos_server"
version = "0.7.0-rc2"
version = "0.7.0"
dependencies = [
"any_spawner",
"base64",
@@ -2239,7 +2239,7 @@ dependencies = [
[[package]]
name = "next_tuple"
version = "0.1.0-rc2"
version = "0.1.0"
[[package]]
name = "nom"
@@ -2539,9 +2539,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.91"
version = "1.0.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "307e3004becf10f5a6e0d59d20f3cd28231b0e0827a96cd3e0ce6d14bc1e4bb3"
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
dependencies = [
"unicode-ident",
]
@@ -2726,7 +2726,7 @@ dependencies = [
[[package]]
name = "reactive_graph"
version = "0.1.0-rc2"
version = "0.1.0"
dependencies = [
"any_spawner",
"async-lock",
@@ -2748,7 +2748,7 @@ dependencies = [
[[package]]
name = "reactive_stores"
version = "0.1.0-rc2"
version = "0.1.0"
dependencies = [
"any_spawner",
"guardian",
@@ -2764,7 +2764,7 @@ dependencies = [
[[package]]
name = "reactive_stores_macro"
version = "0.1.0-rc2"
version = "0.1.0"
dependencies = [
"convert_case 0.6.0",
"proc-macro-error2",
@@ -3262,7 +3262,7 @@ dependencies = [
[[package]]
name = "server_fn"
version = "0.7.0-rc2"
version = "0.7.0"
dependencies = [
"actix-web",
"axum",
@@ -3318,7 +3318,7 @@ dependencies = [
[[package]]
name = "server_fn_macro"
version = "0.7.0-rc2"
version = "0.7.0"
dependencies = [
"const_format",
"convert_case 0.6.0",
@@ -3330,9 +3330,9 @@ dependencies = [
[[package]]
name = "server_fn_macro_default"
version = "0.7.0-rc2"
version = "0.7.0"
dependencies = [
"server_fn_macro 0.7.0-rc2",
"server_fn_macro 0.7.0",
"syn 2.0.89",
]
@@ -3533,7 +3533,7 @@ dependencies = [
[[package]]
name = "tachys"
version = "0.1.0-rc2"
version = "0.1.0"
dependencies = [
"any_spawner",
"const_str_slice_concat",
@@ -3658,7 +3658,7 @@ dependencies = [
[[package]]
name = "throw_error"
version = "0.2.0-rc2"
version = "0.2.0"
dependencies = [
"pin-project-lite",
]

View File

@@ -40,36 +40,36 @@ members = [
exclude = ["benchmarks", "examples", "projects"]
[workspace.package]
version = "0.7.0-rc2"
version = "0.7.0"
edition = "2021"
rust-version = "1.76"
[workspace.dependencies]
throw_error = { path = "./any_error/", version = "0.2.0-rc2" }
any_spawner = { path = "./any_spawner/", version = "0.1.0" }
throw_error = { path = "./any_error/", version = "0.2.0" }
any_spawner = { path = "./any_spawner/", version = "0.2.0" }
const_str_slice_concat = { path = "./const_str_slice_concat", version = "0.1.0" }
either_of = { path = "./either_of/", version = "0.1.0" }
hydration_context = { path = "./hydration_context", version = "0.2.0-rc2" }
leptos = { path = "./leptos", version = "0.7.0-rc2" }
leptos_config = { path = "./leptos_config", version = "0.7.0-rc2" }
leptos_dom = { path = "./leptos_dom", version = "0.7.0-rc2" }
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.7.0-rc2" }
leptos_integration_utils = { path = "./integrations/utils", version = "0.7.0-rc2" }
leptos_macro = { path = "./leptos_macro", version = "0.7.0-rc2" }
leptos_router = { path = "./router", version = "0.7.0-rc2" }
leptos_router_macro = { path = "./router_macro", version = "0.7.0-rc2" }
leptos_server = { path = "./leptos_server", version = "0.7.0-rc2" }
leptos_meta = { path = "./meta", version = "0.7.0-rc2" }
next_tuple = { path = "./next_tuple", version = "0.1.0-rc2" }
hydration_context = { path = "./hydration_context", version = "0.2.0" }
leptos = { path = "./leptos", version = "0.7.0" }
leptos_config = { path = "./leptos_config", version = "0.7.0" }
leptos_dom = { path = "./leptos_dom", version = "0.7.0" }
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.7.0" }
leptos_integration_utils = { path = "./integrations/utils", version = "0.7.0" }
leptos_macro = { path = "./leptos_macro", version = "0.7.0" }
leptos_router = { path = "./router", version = "0.7.0" }
leptos_router_macro = { path = "./router_macro", version = "0.7.0" }
leptos_server = { path = "./leptos_server", version = "0.7.0" }
leptos_meta = { path = "./meta", version = "0.7.0" }
next_tuple = { path = "./next_tuple", version = "0.1.0" }
oco_ref = { path = "./oco", version = "0.2.0" }
or_poisoned = { path = "./or_poisoned", version = "0.1.0" }
reactive_graph = { path = "./reactive_graph", version = "0.1.0-rc2" }
reactive_stores = { path = "./reactive_stores", version = "0.1.0-rc2" }
reactive_stores_macro = { path = "./reactive_stores_macro", version = "0.1.0-rc2" }
server_fn = { path = "./server_fn", version = "0.7.0-rc2" }
server_fn_macro = { path = "./server_fn_macro", version = "0.7.0-rc2" }
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.7.0-rc2" }
tachys = { path = "./tachys", version = "0.1.0-rc2" }
reactive_graph = { path = "./reactive_graph", version = "0.1.0" }
reactive_stores = { path = "./reactive_stores", version = "0.1.0" }
reactive_stores_macro = { path = "./reactive_stores_macro", version = "0.1.0" }
server_fn = { path = "./server_fn", version = "0.7.0" }
server_fn_macro = { path = "./server_fn_macro", version = "0.7.0" }
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.7.0" }
tachys = { path = "./tachys", version = "0.1.0" }
[profile.release]
codegen-units = 1

View File

@@ -12,8 +12,6 @@
You can find a list of useful libraries and example projects at [`awesome-leptos`](https://github.com/leptos-rs/awesome-leptos).
# The `main` branch is currently undergoing major changes in preparation for the [0.7](https://github.com/leptos-rs/leptos/milestone/4) release. For a stable version, please use the [v0.6.13 tag](https://github.com/leptos-rs/leptos/tree/v0.6.13)
# Leptos
```rust

View File

@@ -1,6 +1,6 @@
[package]
name = "throw_error"
version = "0.2.0-rc2"
version = "0.2.0"
authors = ["Greg Johnston"]
license = "MIT"
readme = "../README.md"

View File

@@ -1,6 +1,6 @@
[package]
name = "any_spawner"
version = "0.1.1"
version = "0.2.0"
authors = ["Greg Johnston"]
license = "MIT"
readme = "../README.md"

View File

@@ -1,6 +1,6 @@
[package]
name = "hydration_context"
version = "0.2.0-rc2"
version = "0.2.0"
authors = ["Greg Johnston"]
license = "MIT"
readme = "../README.md"

View File

@@ -1,3 +1,8 @@
// #[wasm_bindgen(thread_local)] is deprecated in wasm-bindgen 0.2.96
// but the replacement is also only shipped in that version
// as a result, we'll just allow deprecated for now
#![allow(deprecated)]
use super::{SerializedDataId, SharedContext};
use crate::{PinnedFuture, PinnedStream};
use core::fmt::Debug;

View File

@@ -40,28 +40,15 @@ pub trait ExtendResponse: Sized {
let (owner, stream) =
build_response(app_fn, additional_context, stream_builder);
let sc = owner.shared_context().unwrap();
let stream = stream.await.ready_chunks(32).map(|n| n.join(""));
let sc = owner.shared_context().unwrap();
while let Some(pending) = sc.await_deferred() {
pending.await;
}
let mut stream = Box::pin(
meta_context.inject_meta_context(stream).await.then({
let sc = Arc::clone(&sc);
move |chunk| {
let sc = Arc::clone(&sc);
async move {
while let Some(pending) = sc.await_deferred() {
pending.await;
}
chunk
}
}
}),
);
let mut stream =
Box::pin(meta_context.inject_meta_context(stream).await);
// wait for the first chunk of the stream, then set the status and headers
let first_chunk = stream.next().await.unwrap_or_default();

View File

@@ -290,7 +290,7 @@ pub mod logging {
/// Utilities for working with asynchronous tasks.
pub mod task {
pub use any_spawner::Executor;
pub use any_spawner::{self, CustomExecutor, Executor};
use std::future::Future;
/// Spawns a thread-safe [`Future`].

View File

@@ -1,6 +1,6 @@
[package]
name = "leptos_macro"
version = "0.7.0-rc2"
version = "0.7.0"
authors = ["Greg Johnston"]
license = "MIT"
repository = "https://github.com/leptos-rs/leptos"

View File

@@ -639,7 +639,7 @@ pub fn island(args: proc_macro::TokenStream, s: TokenStream) -> TokenStream {
abort!(
transparent,
"only `transparent` is supported";
help = "try `#[component(transparent)]` or `#[component]`"
help = "try `#[island(transparent)]` or `#[island]`"
);
}

View File

@@ -652,6 +652,18 @@ pub(crate) fn element_to_tokens(
},
_ => None,
};
if let NodeAttribute::Attribute(a) = a {
if let Some(Tuple(_)) = a.value() {
return Ordering::Greater;
}
}
if let NodeAttribute::Attribute(b) = b {
if let Some(Tuple(_)) = b.value() {
return Ordering::Less;
}
}
match (key_a.as_deref(), key_b.as_deref()) {
(Some("class"), Some("class")) | (Some("style"), Some("style")) => {
Ordering::Equal
@@ -755,7 +767,7 @@ pub(crate) fn element_to_tokens(
let name = node.name().to_string();
// link custom ident to name span for IDE docs
let custom = Ident::new("custom", name.span());
quote! { ::leptos::tachys::html::element::#custom(#name) }
quote_spanned! { node.name().span() => ::leptos::tachys::html::element::#custom(#name) }
} else if is_svg_element(&tag) {
parent_type = TagType::Svg;
let name = if tag == "use" || tag == "use_" {
@@ -763,33 +775,33 @@ pub(crate) fn element_to_tokens(
} else {
name.to_token_stream()
};
quote! { ::leptos::tachys::svg::#name() }
quote_spanned! { node.name().span() => ::leptos::tachys::svg::#name() }
} else if is_math_ml_element(&tag) {
parent_type = TagType::Math;
quote! { ::leptos::tachys::mathml::#name() }
quote_spanned! { node.name().span() => ::leptos::tachys::mathml::#name() }
} else if is_ambiguous_element(&tag) {
match parent_type {
TagType::Unknown => {
// We decided this warning was too aggressive, but I'll leave it here in case we want it later
/* proc_macro_error2::emit_warning!(name.span(), "The view macro is assuming this is an HTML element, \
but it is ambiguous; if it is an SVG or MathML element, prefix with svg:: or math::"); */
quote! {
quote_spanned! { node.name().span() =>
::leptos::tachys::html::element::#name()
}
}
TagType::Html => {
quote! { ::leptos::tachys::html::element::#name() }
quote_spanned! { node.name().span() => ::leptos::tachys::html::element::#name() }
}
TagType::Svg => {
quote! { ::leptos::tachys::svg::#name() }
quote_spanned! { node.name().span() => ::leptos::tachys::svg::#name() }
}
TagType::Math => {
quote! { ::leptos::tachys::math::#name() }
quote_spanned! { node.name().span() => ::leptos::tachys::math::#name() }
}
}
} else {
parent_type = TagType::Html;
quote! { ::leptos::tachys::html::element::#name() }
quote_spanned! { name.span() => ::leptos::tachys::html::element::#name() }
};
/* TODO restore this
@@ -1710,7 +1722,7 @@ fn tuple_name(name: &str, node: &KeyedAttribute) -> TupleName {
TupleName::None
}
#[derive(Debug)]
#[derive(Debug, PartialEq, Eq)]
enum TupleName {
None,
Str(String),

View File

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

View File

@@ -1,6 +1,6 @@
[package]
name = "next_tuple"
version = "0.1.0-rc2"
version = "0.1.0"
authors = ["Greg Johnston"]
license = "MIT"
readme = "../README.md"

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
[package]
name = "leptos_router"
version = "0.7.0-rc2"
version = "0.7.0"
authors = ["Greg Johnston", "Ben Wishovich"]
license = "MIT"
readme = "../README.md"

View File

@@ -1,6 +1,6 @@
[package]
name = "leptos_router_macro"
version = "0.7.0-rc2"
version = "0.7.0"
authors = ["Greg Johnston", "Ben Wishovich"]
license = "MIT"
readme = "../README.md"

View File

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

View File

@@ -1,12 +1,17 @@
use crate::html::{element::ElementType, node_ref::NodeRefContainer};
use reactive_graph::{
effect::Effect,
signal::{
guards::{Derefable, ReadGuard},
RwSignal,
},
traits::{DefinedAt, ReadUntracked, Set, Track},
traits::{
DefinedAt, Get, Notify, ReadUntracked, Set, Track, UntrackableGuard,
Write,
},
};
use send_wrapper::SendWrapper;
use std::{cell::Cell, ops::DerefMut};
use wasm_bindgen::JsCast;
/// A reactive reference to a DOM node that can be used with the `node_ref` attribute.
@@ -26,6 +31,25 @@ where
pub fn new() -> Self {
Self(RwSignal::new(None))
}
/// Runs the provided closure when the `NodeRef` has been connected
/// with its element.
#[inline(always)]
pub fn on_load<F>(self, f: F)
where
E: 'static,
F: FnOnce(E::Output) + 'static,
E: ElementType,
E::Output: JsCast + Clone + 'static,
{
let f = Cell::new(Some(f));
Effect::new(move |_| {
if let Some(node_ref) = self.get() {
f.take().unwrap()(node_ref);
}
});
}
}
impl<E> Default for NodeRef<E>
@@ -78,6 +102,34 @@ where
}
}
impl<E> Notify for NodeRef<E>
where
E: ElementType,
E::Output: JsCast + Clone + 'static,
{
fn notify(&self) {
self.0.notify();
}
}
impl<E> Write for NodeRef<E>
where
E: ElementType,
E::Output: JsCast + Clone + 'static,
{
type Value = Option<SendWrapper<E::Output>>;
fn try_write(&self) -> Option<impl UntrackableGuard<Target = Self::Value>> {
self.0.try_write()
}
fn try_write_untracked(
&self,
) -> Option<impl DerefMut<Target = Self::Value>> {
self.0.try_write_untracked()
}
}
impl<E> ReadUntracked for NodeRef<E>
where
E: ElementType,