prep for preview release

This commit is contained in:
Greg Johnston 2024-04-27 11:04:23 -04:00
parent 106aaaf412
commit 09cc5df975
30 changed files with 146 additions and 195 deletions

View file

@ -34,41 +34,39 @@ members = [
# libraries
"meta",
"router",
"routing",
"is_server",
"routing_macro",
"router_macro",
"any_error",
]
exclude = ["benchmarks", "examples"]
[workspace.package]
version = "0.6.12"
version = "0.7.0-preview"
rust-version = "1.75"
[workspace.dependencies]
any_error = { path = "./any_error/" }
any_spawner = { path = "./any_spawner/" }
const_str_slice_concat = { path = "./const_str_slice_concat" }
any_error = { path = "./any_error/", version = "0.1" }
any_spawner = { path = "./any_spawner/", version = "0.1" }
const_str_slice_concat = { path = "./const_str_slice_concat", version = "0.1" }
either_of = { path = "./either_of/" }
hydration_context = { path = "./hydration_context" }
leptos = { path = "./leptos", version = "0.6.5" }
leptos_config = { path = "./leptos_config", version = "0.6.5" }
leptos_dom = { path = "./leptos_dom", version = "0.6.5" }
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.6.5" }
leptos_integration_utils = { path = "./integrations/utils", version = "0.6.5" }
leptos_macro = { path = "./leptos_macro", version = "0.6.5" }
leptos_reactive = { path = "./leptos_reactive", version = "0.6.5" }
leptos_router = { path = "./router", version = "0.6.5" }
leptos_server = { path = "./leptos_server", version = "0.6.5" }
leptos_meta = { path = "./meta", version = "0.6.5" }
oco = { path = "./oco" }
leptos = { path = "./leptos", version = "0.7.0-preview" }
leptos_config = { path = "./leptos_config", version = "0.7.0-preview" }
leptos_dom = { path = "./leptos_dom", version = "0.7.0-preview" }
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.7.0-preview" }
leptos_integration_utils = { path = "./integrations/utils", version = "0.7.0-preview" }
leptos_macro = { path = "./leptos_macro", version = "0.7.0-preview" }
leptos_reactive = { path = "./leptos_reactive", version = "0.7.0-preview" }
leptos_router = { path = "./router", version = "0.7.0-preview" }
leptos_server = { path = "./leptos_server", version = "0.7.0-preview" }
leptos_meta = { path = "./meta", version = "0.7.0-preview" }
oco_ref = { path = "./oco", version = "0.2" }
or_poisoned = { path = "./or_poisoned" }
reactive_graph = { path = "./reactive_graph" }
routing = { path = "./routing" }
server_fn = { path = "./server_fn", version = "0.6.5" }
server_fn_macro = { path = "./server_fn_macro", version = "0.6.5" }
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.6" }
tachys = { path = "./tachys" }
server_fn = { path = "./server_fn", version = "0.7.0-preview" }
server_fn_macro = { path = "./server_fn_macro", version = "0.7.0-preview" }
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.7.0-preview" }
tachys = { path = "./tachys", version = "0.1" }
[profile.release]
codegen-units = 1

View file

@ -1,7 +1,13 @@
[package]
name = "any_error"
edition = "2021"
version.workspace = true
version = "0.1.0"
authors = ["Greg Johnston"]
license = "MIT"
readme = "../README.md"
repository = "https://github.com/leptos-rs/leptos"
description = "Utilities for wrapping, throwing, and catching errors."
rust-version.workspace = true
[dependencies]
pin-project-lite = "0.2"

1
any_error/Makefile.toml Normal file
View file

@ -0,0 +1 @@
extend = { path = "../cargo-make/main.toml" }

2
any_error/README.md Normal file
View file

@ -0,0 +1,2 @@
A utility library for wrapping arbitrary errors, and for “throwing” errors in a way
that can be caught by user-defined error hooks.

View file

@ -1,3 +1,9 @@
#![forbid(unsafe_code)]
#![deny(missing_docs)]
//! A utility library for wrapping arbitrary errors, and for “throwing” errors in a way
//! that can be caught by user-defined error hooks.
use std::{
cell::RefCell,
error,

View file

@ -1,13 +1,20 @@
[package]
name = "any_spawner"
edition = "2021"
version.workspace = true
version = "0.1.0"
authors = ["Greg Johnston"]
license = "MIT"
readme = "../README.md"
repository = "https://github.com/leptos-rs/leptos"
description = "Spawn asynchronous tasks in an executor-independent way."
[dependencies]
futures = "0.3"
glib = { version = "0.19", optional = true }
thiserror = "1"
tokio = { version = "1", optional = true, default-features = false, features = ["rt"] }
tokio = { version = "1", optional = true, default-features = false, features = [
"rt",
] }
tracing = { version = "0.1", optional = true }
wasm-bindgen-futures = { version = "0.4", optional = true }

26
any_spawner/README.md Normal file
View file

@ -0,0 +1,26 @@
This crate makes it easier to write asynchronous code that is executor-agnostic, by providing a
utility that can be used to spawn tasks in a variety of executors.
It only supports single executor per program, but that executor can be set at runtime, anywhere
in your crate (or an application that depends on it).
This can be extended to support any executor or runtime that supports spawning [`Future`]s.
This is a least common denominator implementation in many ways. Limitations include:
- setting an executor is a one-time, global action
- no "join handle" or other result is returned from the spawn
- the `Future` must output `()`
```rust
use any_spawner::Executor;
Executor::init_futures_executor()
.expect("executor should only be initialized once");
// spawn a thread-safe Future
Executor::spawn(async { /* ... */ });
// spawn a Future that is !Send
Executor::spawn_local(async { /* ... */ });
```

View file

@ -1,8 +1,12 @@
[package]
name = "const_str_slice_concat"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
version = "0.1.0"
authors = ["Greg Johnston"]
license = "MIT"
readme = "../README.md"
repository = "https://github.com/leptos-rs/leptos"
description = "Utilities for const concatenation of string slices."
rust-version.workspace = true
[dependencies]

View file

@ -1,4 +1,8 @@
#![no_std]
#![forbid(unsafe_code)]
#![deny(missing_docs)]
//! Utilities for const concatenation of string slices.
pub(crate) const MAX_TEMPLATE_SIZE: usize = 4096;
@ -13,7 +17,7 @@ pub const fn str_from_buffer(buf: &[u8; MAX_TEMPLATE_SIZE]) -> &str {
}
}
/// Concatenates any number of static strings in a single one.
/// Concatenates any number of static strings into a single array.
// credit to Rainer Stropek, "Constant fun," Rust Linz, June 2022
pub const fn const_concat(
strs: &'static [&'static str],

View file

@ -1,7 +1,13 @@
[package]
name = "either_of"
edition = "2021"
version.workspace = true
version = "0.1.0"
authors = ["Greg Johnston"]
license = "MIT"
readme = "../README.md"
repository = "https://github.com/leptos-rs/leptos"
description = "Utilities for working with enumerated types that contain one of 2..n other types."
rust-version.workspace = true
[dependencies]
pin-project-lite = "0.2"

1
either_of/README.md Normal file
View file

@ -0,0 +1 @@
Utilities for working with enumerated types that contain one of `2..n` other types.

View file

@ -1,4 +1,7 @@
#![no_std]
#![forbid(unsafe_code)]
//! Utilities for working with enumerated types that contain one of `2..n` other types.
use core::{
fmt::Display,

View file

@ -13,7 +13,7 @@ panic = "abort"
console_log = "1"
log = "0.4"
leptos = { path = "../../leptos", features = ["csr"] } #, "tracing"] }
routing = { path = "../../routing" } #, features = ["tracing"] }
leptos_router = { path = "../../router" } #, features = ["tracing"] }
#leptos_router = { path = "../../router", features = ["csr", "nightly"] }
serde = { version = "1", features = ["derive"] }
futures = "0.3"

View file

@ -10,17 +10,21 @@ crate-type = ["cdylib", "rlib"]
console_error_panic_hook = "0.1"
console_log = "1"
lazy_static = "1"
leptos = { path = "../../leptos", features = ["nightly"] }
leptos = { path = "../../leptos", features = ["nightly", "hydration"] }
leptos_meta = { path = "../../meta" }
leptos_axum = { path = "../../integrations/axum", optional = true }
routing = { path = "../../routing" }
leptos_router = { path = "../../router" }
log = "0.4"
serde = { version = "1", features = ["derive"] }
thiserror = "1"
axum = { version = "0.7", optional = true }
tower = { version = "0.4", optional = true }
tower-http = { version = "0.5", features = ["fs"], optional = true }
tokio = { version = "1", features = ["rt-multi-thread", "macros", "time"], optional = true }
tokio = { version = "1", features = [
"rt-multi-thread",
"macros",
"time",
], optional = true }
wasm-bindgen = "0.2"
[features]
@ -33,9 +37,12 @@ ssr = [
"leptos/ssr",
"leptos_meta/ssr",
"dep:leptos_axum",
"routing/ssr",
"leptos_router/ssr",
]
[profile.release]
panic = "abort"
[profile.wasm-release]
inherits = "release"
opt-level = 'z'

View file

@ -5,7 +5,7 @@ use leptos::{
IntoView, Params, Suspense,
};
use leptos_meta::*;
use routing::{
use leptos_router::{
components::{FlatRoutes, Route, Router},
hooks::use_params,
params::Params,

View file

@ -21,7 +21,7 @@ leptos_reactive = { workspace = true }
leptos_server = { workspace = true }
leptos_config = { workspace = true }
leptos-spin-macro = { version = "0.1", optional = true }
oco = { workspace = true }
oco_ref = { workspace = true }
or_poisoned = { workspace = true }
paste = "1"
rand = { version = "0.8", optional = true }
@ -38,7 +38,6 @@ server_fn = { workspace = true, features = [
"form-redirects",
"browser",
"url",
"cbor",
] }
web-sys = { version = "0.3.63", features = [
"ShadowRoot",
@ -52,10 +51,7 @@ futures = "0.3.30"
[features]
default = ["serde"]
hydration = [
"leptos_server/hydration",
"hydration_context/browser",
]
hydration = ["leptos_server/hydration", "hydration_context/browser"]
csr = ["leptos_macro/csr", "leptos_reactive/csr"]
hydrate = [
"leptos_macro/hydrate",

View file

@ -194,7 +194,7 @@ pub use leptos_config as config;
#[cfg(feature = "hydrate")]
pub use mount::hydrate_body;
pub use mount::mount_to_body;
pub use oco;
pub use oco_ref as oco;
pub mod from_form_data;
pub mod signals {

View file

@ -1,4 +1,4 @@
use oco::Oco;
use oco_ref::Oco;
use std::sync::Arc;
/// Describes a value that is either a static or a reactive string, i.e.,

View file

@ -19,7 +19,7 @@ pub fn params_impl(ast: &syn::DeriveInput) -> proc_macro::TokenStream {
let span = field.span();
quote_spanned! {
span=> #ident: <#ty as ::routing::params::IntoParam>::into_param(
span=> #ident: <#ty as ::leptos_router::params::IntoParam>::into_param(
map.get(#field_name_string),
#field_name_string
)?
@ -32,7 +32,7 @@ pub fn params_impl(ast: &syn::DeriveInput) -> proc_macro::TokenStream {
let gen = quote! {
impl Params for #name {
fn from_map(map: &::routing::params::ParamsMap) -> Result<Self, ::routing::params::ParamsError> {
fn from_map(map: &::leptos_router::params::ParamsMap) -> Result<Self, ::leptos_router::params::ParamsError> {
Ok(Self {
#(#fields,)*
})

View file

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

View file

@ -1,7 +1,8 @@
[package]
name = "oco_ref"
name = "oco_ref"
edition = "2021"
version = "0.1.1"
version = "0.2.0"
authors = ["Danik Vitek", "Greg Johnston"]
license = "MIT"
repository = "https://github.com/leptos-rs/leptos"

1
oco/Makefile.toml Normal file
View file

@ -0,0 +1 @@
extend = { path = "../cargo-make/main.toml" }

View file

@ -1,31 +1,31 @@
This module contains the `Oco` (Owned Clones Once) smart pointer,
which is used to store immutable references to values.
This is useful for storing, for example, strings.
This module contains the `Oco` (Owned Clones Once) smart pointer,
which is used to store immutable references to values.
This is useful for storing, for example, strings.
Imagine this as an alternative to [`Cow`] with an additional, reference-counted
branch.
Imagine this as an alternative to [`Cow`] with an additional, reference-counted
branch.
```rust
use oco_ref::Oco;
use std::rc::Rc;
```rust
use oco_ref::Oco;
use std::sync::Arc;
let static_str = "foo";
let rc_str: Rc<str> = "bar".into();
let owned_str: String = "baz".into();
let static_str = "foo";
let arc_str: Arc<str> = "bar".into();
let owned_str: String = "baz".into();
fn uses_oco(value: impl Into<Oco<'static, str>>) {
let mut value = value.into();
fn uses_oco(value: impl Into<Oco<'static, str>>) {
let mut value = value.into();
// ensures that the value is either a reference, or reference-counted
// O(n) at worst
let clone1 = value.clone_inplace();
// ensures that the value is either a reference, or reference-counted
// O(n) at worst
let clone1 = value.clone_inplace();
// these subsequent clones are O(1)
let clone2 = value.clone();
let clone3 = value.clone();
}
// these subsequent clones are O(1)
let clone2 = value.clone();
let clone3 = value.clone();
}
uses_oco(static_str);
uses_oco(rc_str);
uses_oco(owned_str);
```
uses_oco(static_str);
uses_oco(arc_str);
uses_oco(owned_str);
```

View file

@ -272,24 +272,6 @@ where
}
}
}
/// Converts the value into its cheaply-clonable form in place.
/// In other words, if it is currently [`Oco::Owned`], converts into [`Oco::Counted`]
/// in an `O(n)` operation, so that all future clones are `O(1)`.
///
/// # Examples
/// ```
/// # use leptos_reactive::oco::Oco;
/// let mut oco = Oco::<str>::Owned("Hello".to_string());
/// oco.upgrade_inplace();
/// assert!(oco1.is_counted());
/// ```
pub fn upgrade_inplace(&mut self) {
if let Self::Owned(v) = &*self {
let rc = Arc::from(v.borrow());
*self = Self::Counted(rc);
}
}
}
impl<T: ?Sized> Default for Oco<'_, T>

View file

@ -1,16 +0,0 @@
[package]
name = "routing_macro"
edition = "2021"
version.workspace = true
[lib]
proc-macro = true
[dependencies]
proc-macro-error = { version = "1", default-features = false }
proc-macro2 = "1"
quote = "1"
syn = { version = "2", features = ["full"] }
[dev-dependencies]
routing = { workspace = true }

View file

@ -1,76 +0,0 @@
use proc_macro::{TokenStream, TokenTree};
use quote::{quote, ToTokens};
use std::borrow::Cow;
use syn::{
parse::{Parse, ParseStream},
parse_macro_input,
token::Token,
};
#[proc_macro_error::proc_macro_error]
#[proc_macro]
pub fn path(tokens: TokenStream) -> TokenStream {
let mut parser = SegmentParser::new(tokens);
parser.parse_all();
let segments = Segments(parser.segments);
segments.into_token_stream().into()
}
#[derive(Debug, PartialEq)]
struct Segments(pub Vec<Segment>);
#[derive(Debug, PartialEq)]
enum Segment {
Static(Cow<'static, str>),
}
struct SegmentParser {
input: proc_macro::token_stream::IntoIter,
current_str: Option<String>,
segments: Vec<Segment>,
}
impl SegmentParser {
pub fn new(input: TokenStream) -> Self {
Self {
input: input.into_iter(),
current_str: None,
segments: Vec::new(),
}
}
}
impl SegmentParser {
pub fn parse_all(&mut self) {
for input in self.input.by_ref() {
match input {
TokenTree::Literal(lit) => {
Self::parse_str(
lit.to_string()
.trim_start_matches(['"', '/'])
.trim_end_matches(['"', '/']),
&mut self.segments,
);
}
TokenTree::Group(_) => todo!(),
TokenTree::Ident(_) => todo!(),
TokenTree::Punct(_) => todo!(),
}
}
}
pub fn parse_str(current_str: &str, segments: &mut Vec<Segment>) {
let mut chars = current_str.chars();
}
}
impl ToTokens for Segments {
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
let children = quote! {};
if self.0.len() != 1 {
tokens.extend(quote! { (#children) });
} else {
tokens.extend(children)
}
}
}

View file

@ -1,9 +0,0 @@
use routing::StaticSegment;
use routing_macro::path;
#[test]
fn parses_empty_list() {
let output = path!("");
assert_eq!(output, ());
//let segments: Segments = syn::parse(path.into()).unwrap();
}

View file

@ -68,7 +68,7 @@ web-sys = { version = "0.3", optional = true, features = [
"ReadableStream",
"ReadableStreamDefaultReader",
"AbortController",
"AbortSignal"
"AbortSignal",
] }
# reqwest client
@ -80,7 +80,7 @@ url = "2"
pin-project-lite = "0.2.13"
[features]
default = ["json", "cbor"]
default = ["json"]
axum-no-default = [
"ssr",
"dep:axum",

View file

@ -11,7 +11,7 @@ either_of = { workspace = true }
next_tuple = { path = "../next_tuple" }
reactive_graph = { workspace = true, optional = true }
slotmap = { version = "1", optional = true }
oco = { workspace = true, optional = true }
oco_ref = { workspace = true, optional = true }
once_cell = "1"
paste = "1"
pin-project-lite = "0.2"
@ -160,6 +160,7 @@ error-hook = []
hydrate = []
islands = []
ssr = []
oco = ["dep:oco_ref"]
nightly = ["reactive_graph/nightly"]
testing = ["dep:slotmap"]
reactive_graph = ["dep:reactive_graph"]

View file

@ -5,7 +5,7 @@ use crate::{
renderer::{DomRenderer, Renderer},
view::{strings::StrState, Position, PositionState, ToTemplate},
};
use oco::Oco;
use oco_ref::Oco;
use std::future::{ready, Ready};
pub struct OcoStrState<R: Renderer> {