Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ actix-web = { default-features = false, version = "4.11.0" }
tracing = { default-features = false, version = "0.1.41" }
slotmap = { default-features = false, version = "1.0.7" }
futures = { default-features = false, version = "0.3.31" }
dashmap = { default-features = false, version = "6.1.0" }
pin-project-lite = { default-features = false, version = "0.2.16" }
send_wrapper = { default-features = false, version = "0.6.0" }
tokio-test = { default-features = false, version = "0.4.4" }
Expand Down
2 changes: 0 additions & 2 deletions examples/server_fns_axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ web-sys = { version = "0.3.70", features = ["FileList", "File"] }
strum = { version = "0.27.1", features = ["strum_macros", "derive"] }
notify = { version = "8.0", optional = true }
pin-project-lite = "0.2.14"
dashmap = { version = "6.0", optional = true }
async-broadcast = { version = "0.7.1", optional = true }
bytecheck = "0.8.0"
rkyv = { version = "0.8.8" }
Expand All @@ -52,7 +51,6 @@ ssr = [
"leptos/ssr",
"dep:leptos_axum",
"dep:notify",
"dep:dashmap",
"dep:async-broadcast",
]

Expand Down
13 changes: 8 additions & 5 deletions examples/server_fns_axum/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ pub fn FileUploadWithProgress() -> impl IntoView {
#[cfg(feature = "ssr")]
mod progress {
use async_broadcast::{broadcast, Receiver, Sender};
use dashmap::DashMap;
use std::collections::HashMap;
use std::sync::Mutex;
use futures::Stream;
use std::sync::LazyLock;

Expand All @@ -432,13 +433,14 @@ pub fn FileUploadWithProgress() -> impl IntoView {
rx: Receiver<usize>,
}

static FILES: LazyLock<DashMap<String, File>> =
LazyLock::new(DashMap::new);
static FILES: LazyLock<Mutex<Hashmap<String, File>>> =
LazyLock::new(|| Mutex::new(HashMap::new()));

pub async fn add_chunk(filename: &str, len: usize) {
println!("[{filename}]\tadding {len}");
let files = FILES.lock().unwrap();
let mut entry =
FILES.entry(filename.to_string()).or_insert_with(|| {
files.entry(filename.to_string()).or_insert_with(|| {
println!("[{filename}]\tinserting channel");
let (tx, rx) = broadcast(128);
File { total: 0, tx, rx }
Expand All @@ -457,8 +459,9 @@ pub fn FileUploadWithProgress() -> impl IntoView {
}

pub fn for_file(filename: &str) -> impl Stream<Item = usize> {
let files = FILES.lock().unwrap();
let entry =
FILES.entry(filename.to_string()).or_insert_with(|| {
files.entry(filename.to_string()).or_insert_with(|| {
println!("[{filename}]\tinserting channel");
let (tx, rx) = broadcast(128);
File { total: 0, tx, rx }
Expand Down
1 change: 0 additions & 1 deletion integrations/actix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ parking_lot = { workspace = true, default-features = true }
tracing = { optional = true, workspace = true, default-features = true }
tokio = { features = ["rt", "fs"], workspace = true, default-features = true }
send_wrapper = { workspace = true, default-features = true }
dashmap = { workspace = true, default-features = true }

[package.metadata.docs.rs]
rustdoc-args = ["--generate-link-to-definition"]
Expand Down
12 changes: 5 additions & 7 deletions integrations/actix/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use actix_web::{
web::{Data, Payload, ServiceConfig},
*,
};
use dashmap::DashMap;
use futures::{stream::once, Stream, StreamExt};
use http::StatusCode;
use hydration_context::SsrSharedContext;
Expand Down Expand Up @@ -45,7 +44,7 @@ use server_fn::{
request::actix::ActixRequest,
};
use std::{
collections::HashSet,
collections::{HashMap, HashSet},
fmt::{Debug, Display},
future::Future,
ops::{Deref, DerefMut},
Expand Down Expand Up @@ -1222,8 +1221,8 @@ impl StaticRouteGenerator {
}
}

static STATIC_HEADERS: LazyLock<DashMap<String, ResponseOptions>> =
LazyLock::new(DashMap::new);
static STATIC_HEADERS: LazyLock<RwLock<HashMap<String, ResponseOptions>>> =
LazyLock::new(|| RwLock::new(HashMap::new()));

fn was_404(owner: &Owner) -> bool {
let resp = owner.with(|| expect_context::<ResponseOptions>());
Expand Down Expand Up @@ -1255,7 +1254,7 @@ async fn write_static_route(
html: &str,
) -> Result<(), std::io::Error> {
if let Some(options) = response_options {
STATIC_HEADERS.insert(path.to_string(), options);
STATIC_HEADERS.write().insert(path.to_string(), options);
}

let path = static_path(options, path);
Expand Down Expand Up @@ -1322,8 +1321,7 @@ where
.await;
(owner.with(use_context::<ResponseOptions>), html)
} else {
let headers =
STATIC_HEADERS.get(orig_path).map(|v| v.clone());
let headers = STATIC_HEADERS.read().get(orig_path).cloned();
(headers, None)
};

Expand Down
1 change: 0 additions & 1 deletion integrations/axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ hydration_context = { workspace = true }
axum = { default-features = false, features = [
"matched-path",
], workspace = true }
dashmap = { workspace = true, default-features = true }
futures = { workspace = true, default-features = true }
leptos = { workspace = true, features = ["nonce", "ssr"] }
server_fn = { workspace = true, features = ["axum-no-default"] }
Expand Down
14 changes: 8 additions & 6 deletions integrations/axum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
response::IntoResponse,
routing::{delete, get, patch, post, put},
};
#[cfg(feature = "default")]
use dashmap::DashMap;
use futures::{stream::once, Future, Stream, StreamExt};
use hydration_context::SsrSharedContext;
use leptos::{
Expand All @@ -72,9 +70,12 @@
use parking_lot::RwLock;
use server_fn::{error::ServerFnErrorErr, redirect::REDIRECT_HEADER};
#[cfg(feature = "default")]
use std::collections::HashMap;
#[cfg(feature = "default")]
use std::path::Path;
#[cfg(feature = "default")]
use std::sync::LazyLock;
#[cfg(feature = "default")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is causing cargo check --no-default-features to fail, because all of these imports are used with or without default features

use std::{collections::HashSet, fmt::Debug, io, pin::Pin, sync::Arc};
#[cfg(feature = "default")]
use tower::util::ServiceExt;
Expand Down Expand Up @@ -121,7 +122,7 @@
/// Ok(())
/// }
#[derive(Debug, Clone, Default)]
pub struct ResponseOptions(pub Arc<RwLock<ResponseParts>>);

Check failure on line 125 in integrations/axum/src/lib.rs

View workflow job for this annotation

GitHub Actions / autofix

cannot find type `Arc` in this scope

impl ResponseOptions {
/// A simpler way to overwrite the contents of `ResponseOptions` with a new `ResponseParts`.
Expand Down Expand Up @@ -436,7 +437,7 @@

/// A stream of bytes of HTML.
pub type PinnedHtmlStream =
Pin<Box<dyn Stream<Item = io::Result<Bytes>> + Send>>;

Check failure on line 440 in integrations/axum/src/lib.rs

View workflow job for this annotation

GitHub Actions / autofix

failed to resolve: use of unresolved module or unlinked crate `io`

Check failure on line 440 in integrations/axum/src/lib.rs

View workflow job for this annotation

GitHub Actions / autofix

cannot find type `Pin` in this scope

/// Returns an Axum [Handler](axum::handler::Handler) that listens for a `GET` request and tries
/// to route it using [leptos_router], serving an HTML stream of your application.
Expand Down Expand Up @@ -488,7 +489,7 @@
app_fn: impl Fn() -> IV + Clone + Send + Sync + 'static,
) -> impl Fn(
Request<Body>,
) -> Pin<Box<dyn Future<Output = Response<Body>> + Send + 'static>>

Check failure on line 492 in integrations/axum/src/lib.rs

View workflow job for this annotation

GitHub Actions / autofix

cannot find type `Pin` in this scope
+ Clone
+ Send
+ 'static
Expand All @@ -513,7 +514,7 @@
) -> impl Fn(
State<S>,
Request<Body>,
) -> Pin<Box<dyn Future<Output = Response<Body>> + Send + 'static>>

Check failure on line 517 in integrations/axum/src/lib.rs

View workflow job for this annotation

GitHub Actions / autofix

cannot find type `Pin` in this scope
+ Clone
+ Send
+ 'static
Expand Down Expand Up @@ -577,7 +578,7 @@
app_fn: impl Fn() -> IV + Clone + Send + Sync + 'static,
) -> impl Fn(
Request<Body>,
) -> Pin<Box<dyn Future<Output = Response<Body>> + Send + 'static>>

Check failure on line 581 in integrations/axum/src/lib.rs

View workflow job for this annotation

GitHub Actions / autofix

cannot find type `Pin` in this scope
+ Clone
+ Send
+ 'static
Expand Down Expand Up @@ -631,7 +632,7 @@
app_fn: impl Fn() -> IV + Clone + Send + Sync + 'static,
) -> impl Fn(
Request<Body>,
) -> Pin<Box<dyn Future<Output = Response<Body>> + Send + 'static>>

Check failure on line 635 in integrations/axum/src/lib.rs

View workflow job for this annotation

GitHub Actions / autofix

cannot find type `Pin` in this scope
+ Clone
+ Send
+ Sync
Expand Down Expand Up @@ -662,7 +663,7 @@
) -> impl Fn(
State<S>,
Request<Body>,
) -> Pin<Box<dyn Future<Output = Response<Body>> + Send + 'static>>

Check failure on line 666 in integrations/axum/src/lib.rs

View workflow job for this annotation

GitHub Actions / autofix

cannot find type `Pin` in this scope
+ Clone
+ Send
+ 'static
Expand Down Expand Up @@ -764,7 +765,7 @@
replace_blocks: bool,
) -> impl Fn(
Request<Body>,
) -> Pin<Box<dyn Future<Output = Response<Body>> + Send + 'static>>

Check failure on line 768 in integrations/axum/src/lib.rs

View workflow job for this annotation

GitHub Actions / autofix

cannot find type `Pin` in this scope
+ Clone
+ Send
+ Sync
Expand Down Expand Up @@ -837,7 +838,7 @@
app_fn: impl Fn() -> IV + Clone + Send + Sync + 'static,
) -> impl Fn(
Request<Body>,
) -> Pin<Box<dyn Future<Output = Response<Body>> + Send + 'static>>

Check failure on line 841 in integrations/axum/src/lib.rs

View workflow job for this annotation

GitHub Actions / autofix

cannot find type `Pin` in this scope
+ Clone
+ Send
+ 'static
Expand Down Expand Up @@ -1522,8 +1523,8 @@
}

#[cfg(feature = "default")]
static STATIC_HEADERS: LazyLock<DashMap<String, ResponseOptions>> =
LazyLock::new(DashMap::new);
static STATIC_HEADERS: LazyLock<RwLock<HashMap<String, ResponseOptions>>> =
LazyLock::new(|| RwLock::new(HashMap::new()));

#[cfg(feature = "default")]
fn was_404(owner: &Owner) -> bool {
Expand Down Expand Up @@ -1558,7 +1559,7 @@
html: &str,
) -> Result<(), std::io::Error> {
if let Some(options) = response_options {
STATIC_HEADERS.insert(path.to_string(), options);
STATIC_HEADERS.write().insert(path.to_string(), options);
}

let path = static_path(options, path);
Expand Down Expand Up @@ -1635,7 +1636,8 @@
.await;
(owner.with(use_context::<ResponseOptions>), html)
} else {
let headers = STATIC_HEADERS.get(orig_path).map(|v| v.clone());
let headers =
STATIC_HEADERS.read().get(orig_path).map(|v| v.clone());
(headers, None)
};

Expand Down
1 change: 0 additions & 1 deletion reactive_stores/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ paste = { workspace = true, default-features = true }
reactive_graph = { workspace = true }
rustc-hash = { workspace = true, default-features = true }
reactive_stores_macro = { workspace = true }
dashmap = { workspace = true, default-features = true }
send_wrapper = { workspace = true, default-features = true }

[dev-dependencies]
Expand Down
34 changes: 24 additions & 10 deletions reactive_stores/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ impl<K> Default for FieldKeys<K> {
}

#[cfg(not(target_arch = "wasm32"))]
type HashMap<K, V> = Arc<dashmap::DashMap<K, V>>;
type HashMap<K, V> = Arc<std::sync::Mutex<std::collections::HashMap<K, V>>>;
#[cfg(target_arch = "wasm32")]
type HashMap<K, V> = send_wrapper::SendWrapper<
std::rc::Rc<std::cell::RefCell<std::collections::HashMap<K, V>>>,
Expand Down Expand Up @@ -453,8 +453,9 @@ impl KeyMap {
let initial_keys = initialize();

#[cfg(not(target_arch = "wasm32"))]
let mut entry = self
.0
let mut map_0 = self.0.lock().unwrap();
#[cfg(not(target_arch = "wasm32"))]
let entry = map_0
.entry(path.clone())
.or_insert_with(|| Box::new(FieldKeys::new(initial_keys)));

Expand All @@ -471,13 +472,26 @@ impl KeyMap {

let entry = entry.downcast_mut::<FieldKeys<K>>()?;
let (result, new_keys) = fun(entry);

#[cfg(not(target_arch = "wasm32"))]
drop(map_0);

let mut map_1 = {
#[cfg(not(target_arch = "wasm32"))]
{
self.1.lock().unwrap()
}

#[cfg(target_arch = "wasm32")]
{
self.1.borrow_mut()
}
};

if !new_keys.is_empty() {
for (idx, segment) in new_keys {
#[cfg(not(target_arch = "wasm32"))]
self.1.insert((path.clone(), idx), segment);

#[cfg(target_arch = "wasm32")]
self.1.borrow_mut().insert((path.clone(), idx), segment);
map_1.insert((path.clone(), idx), segment);
map_1.insert((path.clone(), idx), segment);
}
}
Some(result)
Expand All @@ -486,7 +500,7 @@ impl KeyMap {
fn contains_key(&self, key: &StorePath) -> bool {
#[cfg(not(target_arch = "wasm32"))]
{
self.0.contains_key(key)
self.0.lock().unwrap().contains_key(key)
}

#[cfg(target_arch = "wasm32")]
Expand All @@ -501,7 +515,7 @@ impl KeyMap {
) -> Option<StorePathSegment> {
#[cfg(not(target_arch = "wasm32"))]
{
self.1.get(key).as_deref().copied()
self.1.lock().unwrap().get(key).copied()
}

#[cfg(target_arch = "wasm32")]
Expand Down
14 changes: 0 additions & 14 deletions server_fn/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion server_fn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ thiserror = { workspace = true, default-features = true }

# registration system
inventory = { optional = true, workspace = true, default-features = true }
dashmap = { workspace = true, default-features = true }

## servers
# actix
Expand Down
Loading
Loading