mirror of
https://github.com/leptos-rs/leptos.git
synced 2025-12-27 09:54:41 -05:00
prep for preview release
This commit is contained in:
42
Cargo.toml
42
Cargo.toml
@@ -34,41 +34,39 @@ members = [
|
|||||||
# libraries
|
# libraries
|
||||||
"meta",
|
"meta",
|
||||||
"router",
|
"router",
|
||||||
"routing",
|
|
||||||
"is_server",
|
"is_server",
|
||||||
"routing_macro",
|
"router_macro",
|
||||||
"any_error",
|
"any_error",
|
||||||
]
|
]
|
||||||
exclude = ["benchmarks", "examples"]
|
exclude = ["benchmarks", "examples"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.6.13"
|
version = "0.7.0-preview"
|
||||||
rust-version = "1.75"
|
rust-version = "1.75"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
any_error = { path = "./any_error/" }
|
any_error = { path = "./any_error/", version = "0.1" }
|
||||||
any_spawner = { path = "./any_spawner/" }
|
any_spawner = { path = "./any_spawner/", version = "0.1" }
|
||||||
const_str_slice_concat = { path = "./const_str_slice_concat" }
|
const_str_slice_concat = { path = "./const_str_slice_concat", version = "0.1" }
|
||||||
either_of = { path = "./either_of/" }
|
either_of = { path = "./either_of/" }
|
||||||
hydration_context = { path = "./hydration_context" }
|
hydration_context = { path = "./hydration_context" }
|
||||||
leptos = { path = "./leptos", version = "0.6.5" }
|
leptos = { path = "./leptos", version = "0.7.0-preview" }
|
||||||
leptos_config = { path = "./leptos_config", version = "0.6.5" }
|
leptos_config = { path = "./leptos_config", version = "0.7.0-preview" }
|
||||||
leptos_dom = { path = "./leptos_dom", version = "0.6.5" }
|
leptos_dom = { path = "./leptos_dom", version = "0.7.0-preview" }
|
||||||
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.6.5" }
|
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.7.0-preview" }
|
||||||
leptos_integration_utils = { path = "./integrations/utils", version = "0.6.5" }
|
leptos_integration_utils = { path = "./integrations/utils", version = "0.7.0-preview" }
|
||||||
leptos_macro = { path = "./leptos_macro", version = "0.6.5" }
|
leptos_macro = { path = "./leptos_macro", version = "0.7.0-preview" }
|
||||||
leptos_reactive = { path = "./leptos_reactive", version = "0.6.5" }
|
leptos_reactive = { path = "./leptos_reactive", version = "0.7.0-preview" }
|
||||||
leptos_router = { path = "./router", version = "0.6.5" }
|
leptos_router = { path = "./router", version = "0.7.0-preview" }
|
||||||
leptos_server = { path = "./leptos_server", version = "0.6.5" }
|
leptos_server = { path = "./leptos_server", version = "0.7.0-preview" }
|
||||||
leptos_meta = { path = "./meta", version = "0.6.5" }
|
leptos_meta = { path = "./meta", version = "0.7.0-preview" }
|
||||||
oco = { path = "./oco" }
|
oco_ref = { path = "./oco", version = "0.2" }
|
||||||
or_poisoned = { path = "./or_poisoned" }
|
or_poisoned = { path = "./or_poisoned" }
|
||||||
reactive_graph = { path = "./reactive_graph" }
|
reactive_graph = { path = "./reactive_graph" }
|
||||||
routing = { path = "./routing" }
|
server_fn = { path = "./server_fn", version = "0.7.0-preview" }
|
||||||
server_fn = { path = "./server_fn", version = "0.6.5" }
|
server_fn_macro = { path = "./server_fn_macro", version = "0.7.0-preview" }
|
||||||
server_fn_macro = { path = "./server_fn_macro", version = "0.6.5" }
|
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.7.0-preview" }
|
||||||
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.6" }
|
tachys = { path = "./tachys", version = "0.1" }
|
||||||
tachys = { path = "./tachys" }
|
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "any_error"
|
name = "any_error"
|
||||||
edition = "2021"
|
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]
|
[dependencies]
|
||||||
pin-project-lite = "0.2"
|
pin-project-lite = "0.2"
|
||||||
|
|||||||
1
any_error/Makefile.toml
Normal file
1
any_error/Makefile.toml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
extend = { path = "../cargo-make/main.toml" }
|
||||||
2
any_error/README.md
Normal file
2
any_error/README.md
Normal 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.
|
||||||
@@ -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::{
|
use std::{
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
error,
|
error,
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "any_spawner"
|
name = "any_spawner"
|
||||||
edition = "2021"
|
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]
|
[dependencies]
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
glib = { version = "0.19", optional = true }
|
glib = { version = "0.19", optional = true }
|
||||||
thiserror = "1"
|
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 }
|
tracing = { version = "0.1", optional = true }
|
||||||
wasm-bindgen-futures = { version = "0.4", optional = true }
|
wasm-bindgen-futures = { version = "0.4", optional = true }
|
||||||
|
|
||||||
|
|||||||
26
any_spawner/README.md
Normal file
26
any_spawner/README.md
Normal 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 { /* ... */ });
|
||||||
|
```
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "const_str_slice_concat"
|
name = "const_str_slice_concat"
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
version = "0.1.0"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
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]
|
[dependencies]
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
|
//! Utilities for const concatenation of string slices.
|
||||||
|
|
||||||
pub(crate) const MAX_TEMPLATE_SIZE: usize = 4096;
|
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
|
// credit to Rainer Stropek, "Constant fun," Rust Linz, June 2022
|
||||||
pub const fn const_concat(
|
pub const fn const_concat(
|
||||||
strs: &'static [&'static str],
|
strs: &'static [&'static str],
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "either_of"
|
name = "either_of"
|
||||||
edition = "2021"
|
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]
|
[dependencies]
|
||||||
pin-project-lite = "0.2"
|
pin-project-lite = "0.2"
|
||||||
|
|||||||
1
either_of/README.md
Normal file
1
either_of/README.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Utilities for working with enumerated types that contain one of `2..n` other types.
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
|
//! Utilities for working with enumerated types that contain one of `2..n` other types.
|
||||||
|
|
||||||
use core::{
|
use core::{
|
||||||
fmt::Display,
|
fmt::Display,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ panic = "abort"
|
|||||||
console_log = "1"
|
console_log = "1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
leptos = { path = "../../leptos", features = ["csr"] } #, "tracing"] }
|
leptos = { path = "../../leptos", features = ["csr"] } #, "tracing"] }
|
||||||
routing = { path = "../../routing" } #, features = ["tracing"] }
|
leptos_router = { path = "../../router" } #, features = ["tracing"] }
|
||||||
#leptos_router = { path = "../../router", features = ["csr", "nightly"] }
|
#leptos_router = { path = "../../router", features = ["csr", "nightly"] }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
|
|||||||
@@ -10,17 +10,21 @@ crate-type = ["cdylib", "rlib"]
|
|||||||
console_error_panic_hook = "0.1"
|
console_error_panic_hook = "0.1"
|
||||||
console_log = "1"
|
console_log = "1"
|
||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
leptos = { path = "../../leptos", features = ["nightly"] }
|
leptos = { path = "../../leptos", features = ["nightly", "hydration"] }
|
||||||
leptos_meta = { path = "../../meta" }
|
leptos_meta = { path = "../../meta" }
|
||||||
leptos_axum = { path = "../../integrations/axum", optional = true }
|
leptos_axum = { path = "../../integrations/axum", optional = true }
|
||||||
routing = { path = "../../routing" }
|
leptos_router = { path = "../../router" }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
axum = { version = "0.7", optional = true }
|
axum = { version = "0.7", optional = true }
|
||||||
tower = { version = "0.4", optional = true }
|
tower = { version = "0.4", optional = true }
|
||||||
tower-http = { version = "0.5", features = ["fs"], 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"
|
wasm-bindgen = "0.2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
@@ -33,9 +37,12 @@ ssr = [
|
|||||||
"leptos/ssr",
|
"leptos/ssr",
|
||||||
"leptos_meta/ssr",
|
"leptos_meta/ssr",
|
||||||
"dep:leptos_axum",
|
"dep:leptos_axum",
|
||||||
"routing/ssr",
|
"leptos_router/ssr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
panic = "abort"
|
||||||
|
|
||||||
[profile.wasm-release]
|
[profile.wasm-release]
|
||||||
inherits = "release"
|
inherits = "release"
|
||||||
opt-level = 'z'
|
opt-level = 'z'
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use leptos::{
|
|||||||
IntoView, Params, Suspense,
|
IntoView, Params, Suspense,
|
||||||
};
|
};
|
||||||
use leptos_meta::*;
|
use leptos_meta::*;
|
||||||
use routing::{
|
use leptos_router::{
|
||||||
components::{FlatRoutes, Route, Router},
|
components::{FlatRoutes, Route, Router},
|
||||||
hooks::use_params,
|
hooks::use_params,
|
||||||
params::Params,
|
params::Params,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ leptos_reactive = { workspace = true }
|
|||||||
leptos_server = { workspace = true }
|
leptos_server = { workspace = true }
|
||||||
leptos_config = { workspace = true }
|
leptos_config = { workspace = true }
|
||||||
leptos-spin-macro = { version = "0.1", optional = true }
|
leptos-spin-macro = { version = "0.1", optional = true }
|
||||||
oco = { workspace = true }
|
oco_ref = { workspace = true }
|
||||||
or_poisoned = { workspace = true }
|
or_poisoned = { workspace = true }
|
||||||
paste = "1"
|
paste = "1"
|
||||||
rand = { version = "0.8", optional = true }
|
rand = { version = "0.8", optional = true }
|
||||||
@@ -38,7 +38,6 @@ server_fn = { workspace = true, features = [
|
|||||||
"form-redirects",
|
"form-redirects",
|
||||||
"browser",
|
"browser",
|
||||||
"url",
|
"url",
|
||||||
"cbor",
|
|
||||||
] }
|
] }
|
||||||
web-sys = { version = "0.3.63", features = [
|
web-sys = { version = "0.3.63", features = [
|
||||||
"ShadowRoot",
|
"ShadowRoot",
|
||||||
@@ -52,10 +51,7 @@ futures = "0.3.30"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["serde"]
|
default = ["serde"]
|
||||||
hydration = [
|
hydration = ["leptos_server/hydration", "hydration_context/browser"]
|
||||||
"leptos_server/hydration",
|
|
||||||
"hydration_context/browser",
|
|
||||||
]
|
|
||||||
csr = ["leptos_macro/csr", "leptos_reactive/csr"]
|
csr = ["leptos_macro/csr", "leptos_reactive/csr"]
|
||||||
hydrate = [
|
hydrate = [
|
||||||
"leptos_macro/hydrate",
|
"leptos_macro/hydrate",
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ pub use leptos_config as config;
|
|||||||
#[cfg(feature = "hydrate")]
|
#[cfg(feature = "hydrate")]
|
||||||
pub use mount::hydrate_body;
|
pub use mount::hydrate_body;
|
||||||
pub use mount::mount_to_body;
|
pub use mount::mount_to_body;
|
||||||
pub use oco;
|
pub use oco_ref as oco;
|
||||||
pub mod from_form_data;
|
pub mod from_form_data;
|
||||||
|
|
||||||
pub mod signals {
|
pub mod signals {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use oco::Oco;
|
use oco_ref::Oco;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
/// Describes a value that is either a static or a reactive string, i.e.,
|
/// Describes a value that is either a static or a reactive string, i.e.,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ pub fn params_impl(ast: &syn::DeriveInput) -> proc_macro::TokenStream {
|
|||||||
let span = field.span();
|
let span = field.span();
|
||||||
|
|
||||||
quote_spanned! {
|
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),
|
map.get(#field_name_string),
|
||||||
#field_name_string
|
#field_name_string
|
||||||
)?
|
)?
|
||||||
@@ -32,7 +32,7 @@ pub fn params_impl(ast: &syn::DeriveInput) -> proc_macro::TokenStream {
|
|||||||
|
|
||||||
let gen = quote! {
|
let gen = quote! {
|
||||||
impl Params for #name {
|
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 {
|
Ok(Self {
|
||||||
#(#fields,)*
|
#(#fields,)*
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "leptos_meta"
|
name = "leptos_meta"
|
||||||
version = "0.6.13"
|
version = "0.7.0-preview"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Greg Johnston"]
|
authors = ["Greg Johnston"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "oco_ref"
|
name = "oco_ref"
|
||||||
|
name = "oco_ref"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
version = "0.1.1"
|
version = "0.2.0"
|
||||||
authors = ["Danik Vitek", "Greg Johnston"]
|
authors = ["Danik Vitek", "Greg Johnston"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/leptos-rs/leptos"
|
repository = "https://github.com/leptos-rs/leptos"
|
||||||
|
|||||||
1
oco/Makefile.toml
Normal file
1
oco/Makefile.toml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
extend = { path = "../cargo-make/main.toml" }
|
||||||
@@ -1,31 +1,31 @@
|
|||||||
This module contains the `Oco` (Owned Clones Once) smart pointer,
|
This module contains the `Oco` (Owned Clones Once) smart pointer,
|
||||||
which is used to store immutable references to values.
|
which is used to store immutable references to values.
|
||||||
This is useful for storing, for example, strings.
|
This is useful for storing, for example, strings.
|
||||||
|
|
||||||
Imagine this as an alternative to [`Cow`] with an additional, reference-counted
|
Imagine this as an alternative to [`Cow`] with an additional, reference-counted
|
||||||
branch.
|
branch.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use oco_ref::Oco;
|
use oco_ref::Oco;
|
||||||
use std::rc::Rc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
let static_str = "foo";
|
let static_str = "foo";
|
||||||
let rc_str: Rc<str> = "bar".into();
|
let arc_str: Arc<str> = "bar".into();
|
||||||
let owned_str: String = "baz".into();
|
let owned_str: String = "baz".into();
|
||||||
|
|
||||||
fn uses_oco(value: impl Into<Oco<'static, str>>) {
|
fn uses_oco(value: impl Into<Oco<'static, str>>) {
|
||||||
let mut value = value.into();
|
let mut value = value.into();
|
||||||
|
|
||||||
// ensures that the value is either a reference, or reference-counted
|
// ensures that the value is either a reference, or reference-counted
|
||||||
// O(n) at worst
|
// O(n) at worst
|
||||||
let clone1 = value.clone_inplace();
|
let clone1 = value.clone_inplace();
|
||||||
|
|
||||||
// these subsequent clones are O(1)
|
// these subsequent clones are O(1)
|
||||||
let clone2 = value.clone();
|
let clone2 = value.clone();
|
||||||
let clone3 = value.clone();
|
let clone3 = value.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
uses_oco(static_str);
|
uses_oco(static_str);
|
||||||
uses_oco(rc_str);
|
uses_oco(arc_str);
|
||||||
uses_oco(owned_str);
|
uses_oco(owned_str);
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -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>
|
impl<T: ?Sized> Default for Oco<'_, T>
|
||||||
|
|||||||
@@ -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 }
|
|
||||||
@@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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();
|
|
||||||
}
|
|
||||||
@@ -68,7 +68,7 @@ web-sys = { version = "0.3", optional = true, features = [
|
|||||||
"ReadableStream",
|
"ReadableStream",
|
||||||
"ReadableStreamDefaultReader",
|
"ReadableStreamDefaultReader",
|
||||||
"AbortController",
|
"AbortController",
|
||||||
"AbortSignal"
|
"AbortSignal",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
# reqwest client
|
# reqwest client
|
||||||
@@ -80,7 +80,7 @@ url = "2"
|
|||||||
pin-project-lite = "0.2.13"
|
pin-project-lite = "0.2.13"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["json", "cbor"]
|
default = ["json"]
|
||||||
axum-no-default = [
|
axum-no-default = [
|
||||||
"ssr",
|
"ssr",
|
||||||
"dep:axum",
|
"dep:axum",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ either_of = { workspace = true }
|
|||||||
next_tuple = { path = "../next_tuple" }
|
next_tuple = { path = "../next_tuple" }
|
||||||
reactive_graph = { workspace = true, optional = true }
|
reactive_graph = { workspace = true, optional = true }
|
||||||
slotmap = { version = "1", optional = true }
|
slotmap = { version = "1", optional = true }
|
||||||
oco = { workspace = true, optional = true }
|
oco_ref = { workspace = true, optional = true }
|
||||||
once_cell = "1"
|
once_cell = "1"
|
||||||
paste = "1"
|
paste = "1"
|
||||||
pin-project-lite = "0.2"
|
pin-project-lite = "0.2"
|
||||||
@@ -160,6 +160,7 @@ error-hook = []
|
|||||||
hydrate = []
|
hydrate = []
|
||||||
islands = []
|
islands = []
|
||||||
ssr = []
|
ssr = []
|
||||||
|
oco = ["dep:oco_ref"]
|
||||||
nightly = ["reactive_graph/nightly"]
|
nightly = ["reactive_graph/nightly"]
|
||||||
testing = ["dep:slotmap"]
|
testing = ["dep:slotmap"]
|
||||||
reactive_graph = ["dep:reactive_graph"]
|
reactive_graph = ["dep:reactive_graph"]
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use crate::{
|
|||||||
renderer::{DomRenderer, Renderer},
|
renderer::{DomRenderer, Renderer},
|
||||||
view::{strings::StrState, Position, PositionState, ToTemplate},
|
view::{strings::StrState, Position, PositionState, ToTemplate},
|
||||||
};
|
};
|
||||||
use oco::Oco;
|
use oco_ref::Oco;
|
||||||
use std::future::{ready, Ready};
|
use std::future::{ready, Ready};
|
||||||
|
|
||||||
pub struct OcoStrState<R: Renderer> {
|
pub struct OcoStrState<R: Renderer> {
|
||||||
|
|||||||
Reference in New Issue
Block a user