Skip to content

Commit

Permalink
Fix WASI builds trying to use JS for spawn_local
Browse files Browse the repository at this point in the history
Signed-off-by: itowlson <[email protected]>
  • Loading branch information
itowlson committed Nov 29, 2023
1 parent 061213c commit 9bfc3dc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions leptos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ miniserde = ["leptos_reactive/miniserde"]
rkyv = ["leptos_reactive/rkyv"]
tracing = ["leptos_macro/tracing"]
nonce = ["leptos_dom/nonce"]
spin = ["leptos_reactive/spin"]
experimental-islands = [
"leptos_dom/experimental-islands",
"leptos_macro/experimental-islands",
Expand Down
2 changes: 2 additions & 0 deletions leptos_reactive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ bytecheck = { version = "0.7", features = [
rustc-hash = "1"
serde-wasm-bindgen = "0.5"
serde_json = "1"
spin-sdk = { git = "https://github.com/fermyon/spin", tag = "v2.0.1", optional = true }
base64 = "0.21"
thiserror = "1"
tokio = { version = "1", features = [
Expand Down Expand Up @@ -76,6 +77,7 @@ serde-lite = ["dep:serde-lite"]
miniserde = ["dep:miniserde"]
rkyv = ["dep:rkyv", "dep:bytecheck"]
experimental-islands = []
spin = ["ssr", "dep:spin-sdk"]

[package.metadata.cargo-all-features]
denylist = ["nightly"]
Expand Down
5 changes: 4 additions & 1 deletion leptos_reactive/src/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ where
F: Future<Output = ()> + 'static,
{
cfg_if! {
if #[cfg(target_arch = "wasm32")] {
if #[cfg(all(target_arch = "wasm32", target_os = "wasi", feature = "ssr", feature = "spin"))] {
spin_sdk::http::run(fut)
}
else if #[cfg(target_arch = "wasm32")] {
wasm_bindgen_futures::spawn_local(fut)
}
else if #[cfg(any(test, doctest))] {
Expand Down
4 changes: 2 additions & 2 deletions router/src/history/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ impl BrowserIntegration {
let loc = leptos_dom::helpers::location();
LocationChange {
value: loc.pathname().unwrap_or_default()
+ &loc.search().unwrap_or_default()
+ &loc.hash().unwrap_or_default(),
+ loc.search().unwrap_or_default().as_str()
+ loc.hash().unwrap_or_default().as_str(),
replace: true,
scroll: true,
state: State(None),
Expand Down
2 changes: 1 addition & 1 deletion router/src/matching/resolve_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn normalize(path: &str, omit_slash: bool) -> Cow<'_, str> {
#[doc(hidden)]
pub fn join_paths<'a>(from: &'a str, to: &'a str) -> String {
let from = remove_wildcard(&normalize(from, false));
from + &normalize(to, false)
from + normalize(to, false).as_ref()
}

fn begins_with_query_or_hash(text: &str) -> bool {
Expand Down

0 comments on commit 9bfc3dc

Please sign in to comment.