Merge remote-tracking branch 'origin' into wasm-splitting-support

This commit is contained in:
Greg Johnston
2025-07-20 13:09:26 -04:00
40 changed files with 532 additions and 316 deletions

View File

@@ -169,7 +169,9 @@ jobs:
cd '${{ inputs.directory }}' cd '${{ inputs.directory }}'
cargo make --no-workspace --profile=github-actions ci cargo make --no-workspace --profile=github-actions ci
# check the direct-minimal-versions on release # check the direct-minimal-versions on release
if [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then COMMIT_MSG=$(git log -1 --pretty=format:'%s')
# Supports: v1.2.3, v1.2.3-alpha, v1.2.3-beta1, v1.2.3-rc.1, etc.
if [[ "$COMMIT_MSG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+(\.?[0-9]+)?)?$ ]]; then
cargo make --no-workspace --profile=github-actions check-minimal-versions cargo make --no-workspace --profile=github-actions check-minimal-versions
fi fi
# Check if the counter_isomorphic can be built with leptos_debuginfo cfg flag in release mode # Check if the counter_isomorphic can be built with leptos_debuginfo cfg flag in release mode

43
Cargo.lock generated
View File

@@ -589,6 +589,7 @@ dependencies = [
[[package]] [[package]]
name = "cfg-expr" name = "cfg-expr"
version = "0.20.1" version = "0.20.1"
version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d0390889d58f934f01cd49736275b4c2da15bcfc328c78ff2349907e6cabf22" checksum = "0d0390889d58f934f01cd49736275b4c2da15bcfc328c78ff2349907e6cabf22"
dependencies = [ dependencies = [
@@ -1788,7 +1789,7 @@ checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388"
[[package]] [[package]]
name = "leptos" name = "leptos"
version = "0.8.3" version = "0.8.4"
dependencies = [ dependencies = [
"any_spawner", "any_spawner",
"base64", "base64",
@@ -1844,7 +1845,7 @@ dependencies = [
[[package]] [[package]]
name = "leptos_actix" name = "leptos_actix"
version = "0.8.3" version = "0.8.4"
dependencies = [ dependencies = [
"actix-files", "actix-files",
"actix-http", "actix-http",
@@ -1869,7 +1870,7 @@ dependencies = [
[[package]] [[package]]
name = "leptos_axum" name = "leptos_axum"
version = "0.8.3" version = "0.8.4"
dependencies = [ dependencies = [
"any_spawner", "any_spawner",
"axum", "axum",
@@ -1892,7 +1893,7 @@ dependencies = [
[[package]] [[package]]
name = "leptos_config" name = "leptos_config"
version = "0.8.3" version = "0.8.4"
dependencies = [ dependencies = [
"config", "config",
"regex", "regex",
@@ -1906,7 +1907,7 @@ dependencies = [
[[package]] [[package]]
name = "leptos_dom" name = "leptos_dom"
version = "0.8.3" version = "0.8.4"
dependencies = [ dependencies = [
"js-sys", "js-sys",
"leptos", "leptos",
@@ -1923,7 +1924,7 @@ dependencies = [
[[package]] [[package]]
name = "leptos_hot_reload" name = "leptos_hot_reload"
version = "0.8.3" version = "0.8.4"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"camino", "camino",
@@ -1939,7 +1940,7 @@ dependencies = [
[[package]] [[package]]
name = "leptos_integration_utils" name = "leptos_integration_utils"
version = "0.8.3" version = "0.8.4"
dependencies = [ dependencies = [
"futures", "futures",
"hydration_context", "hydration_context",
@@ -1952,7 +1953,7 @@ dependencies = [
[[package]] [[package]]
name = "leptos_macro" name = "leptos_macro"
version = "0.8.3" version = "0.8.4"
dependencies = [ dependencies = [
"attribute-derive", "attribute-derive",
"cfg-if", "cfg-if",
@@ -1972,7 +1973,7 @@ dependencies = [
"rustc_version", "rustc_version",
"serde", "serde",
"server_fn", "server_fn",
"server_fn_macro 0.8.3", "server_fn_macro 0.8.4",
"syn 2.0.104", "syn 2.0.104",
"tracing", "tracing",
"trybuild", "trybuild",
@@ -1982,7 +1983,7 @@ dependencies = [
[[package]] [[package]]
name = "leptos_meta" name = "leptos_meta"
version = "0.8.3" version = "0.8.4"
dependencies = [ dependencies = [
"futures", "futures",
"indexmap", "indexmap",
@@ -1996,7 +1997,7 @@ dependencies = [
[[package]] [[package]]
name = "leptos_router" name = "leptos_router"
version = "0.8.3" version = "0.8.4"
dependencies = [ dependencies = [
"any_spawner", "any_spawner",
"either_of", "either_of",
@@ -2020,7 +2021,7 @@ dependencies = [
[[package]] [[package]]
name = "leptos_router_macro" name = "leptos_router_macro"
version = "0.8.3" version = "0.8.4"
dependencies = [ dependencies = [
"leptos_macro", "leptos_macro",
"leptos_router", "leptos_router",
@@ -2032,7 +2033,7 @@ dependencies = [
[[package]] [[package]]
name = "leptos_server" name = "leptos_server"
version = "0.8.3" version = "0.8.4"
dependencies = [ dependencies = [
"any_spawner", "any_spawner",
"base64", "base64",
@@ -2745,7 +2746,7 @@ dependencies = [
[[package]] [[package]]
name = "reactive_graph" name = "reactive_graph"
version = "0.2.3" version = "0.2.4"
dependencies = [ dependencies = [
"any_spawner", "any_spawner",
"async-lock", "async-lock",
@@ -2768,7 +2769,7 @@ dependencies = [
[[package]] [[package]]
name = "reactive_stores" name = "reactive_stores"
version = "0.2.3" version = "0.2.4"
dependencies = [ dependencies = [
"any_spawner", "any_spawner",
"dashmap", "dashmap",
@@ -2787,7 +2788,7 @@ dependencies = [
[[package]] [[package]]
name = "reactive_stores_macro" name = "reactive_stores_macro"
version = "0.2.3" version = "0.2.4"
dependencies = [ dependencies = [
"convert_case 0.8.0", "convert_case 0.8.0",
"proc-macro-error2", "proc-macro-error2",
@@ -3281,7 +3282,7 @@ dependencies = [
[[package]] [[package]]
name = "server_fn" name = "server_fn"
version = "0.8.3" version = "0.8.4"
dependencies = [ dependencies = [
"actix-web", "actix-web",
"actix-ws", "actix-ws",
@@ -3344,7 +3345,7 @@ dependencies = [
[[package]] [[package]]
name = "server_fn_macro" name = "server_fn_macro"
version = "0.8.3" version = "0.8.4"
dependencies = [ dependencies = [
"const_format", "const_format",
"convert_case 0.8.0", "convert_case 0.8.0",
@@ -3357,9 +3358,9 @@ dependencies = [
[[package]] [[package]]
name = "server_fn_macro_default" name = "server_fn_macro_default"
version = "0.8.3" version = "0.8.4"
dependencies = [ dependencies = [
"server_fn_macro 0.8.3", "server_fn_macro 0.8.4",
"syn 2.0.104", "syn 2.0.104",
] ]
@@ -3561,7 +3562,7 @@ dependencies = [
[[package]] [[package]]
name = "tachys" name = "tachys"
version = "0.2.4" version = "0.2.5"
dependencies = [ dependencies = [
"any_spawner", "any_spawner",
"async-trait", "async-trait",

View File

@@ -40,7 +40,7 @@ members = [
exclude = ["benchmarks", "examples", "projects"] exclude = ["benchmarks", "examples", "projects"]
[workspace.package] [workspace.package]
version = "0.8.3" version = "0.8.4"
edition = "2021" edition = "2021"
rust-version = "1.88" rust-version = "1.88"
@@ -51,26 +51,26 @@ any_spawner = { path = "./any_spawner/", version = "0.3.0" }
const_str_slice_concat = { path = "./const_str_slice_concat", version = "0.1" } const_str_slice_concat = { path = "./const_str_slice_concat", version = "0.1" }
either_of = { path = "./either_of/", version = "0.1.6" } either_of = { path = "./either_of/", version = "0.1.6" }
hydration_context = { path = "./hydration_context", version = "0.3.0" } hydration_context = { path = "./hydration_context", version = "0.3.0" }
leptos = { path = "./leptos", version = "0.8.3" } leptos = { path = "./leptos", version = "0.8.4" }
leptos_config = { path = "./leptos_config", version = "0.8.3" } leptos_config = { path = "./leptos_config", version = "0.8.4" }
leptos_dom = { path = "./leptos_dom", version = "0.8.3" } leptos_dom = { path = "./leptos_dom", version = "0.8.4" }
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.8.3" } leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.8.4" }
leptos_integration_utils = { path = "./integrations/utils", version = "0.8.3" } leptos_integration_utils = { path = "./integrations/utils", version = "0.8.4" }
leptos_macro = { path = "./leptos_macro", version = "0.8.3" } leptos_macro = { path = "./leptos_macro", version = "0.8.4" }
leptos_router = { path = "./router", version = "0.8.3" } leptos_router = { path = "./router", version = "0.8.4" }
leptos_router_macro = { path = "./router_macro", version = "0.8.3" } leptos_router_macro = { path = "./router_macro", version = "0.8.4" }
leptos_server = { path = "./leptos_server", version = "0.8.3" } leptos_server = { path = "./leptos_server", version = "0.8.4" }
leptos_meta = { path = "./meta", version = "0.8.3" } leptos_meta = { path = "./meta", version = "0.8.4" }
next_tuple = { path = "./next_tuple", version = "0.1.0" } next_tuple = { path = "./next_tuple", version = "0.1.0" }
oco_ref = { path = "./oco", version = "0.2.0" } oco_ref = { path = "./oco", version = "0.2.0" }
or_poisoned = { path = "./or_poisoned", version = "0.1.0" } or_poisoned = { path = "./or_poisoned", version = "0.1.0" }
reactive_graph = { path = "./reactive_graph", version = "0.2.3" } reactive_graph = { path = "./reactive_graph", version = "0.2.4" }
reactive_stores = { path = "./reactive_stores", version = "0.2.3" } reactive_stores = { path = "./reactive_stores", version = "0.2.4" }
reactive_stores_macro = { path = "./reactive_stores_macro", version = "0.2.3" } reactive_stores_macro = { path = "./reactive_stores_macro", version = "0.2.4" }
server_fn = { path = "./server_fn", version = "0.8.3" } server_fn = { path = "./server_fn", version = "0.8.4" }
server_fn_macro = { path = "./server_fn_macro", version = "0.8.3" } server_fn_macro = { path = "./server_fn_macro", version = "0.8.4" }
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.8.3" } server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.8.4" }
tachys = { path = "./tachys", version = "0.2.4" } tachys = { path = "./tachys", version = "0.2.5" }
wasm_split_helpers = { path = "./wasm_split", version = "0.1.0" } wasm_split_helpers = { path = "./wasm_split", version = "0.1.0" }
wasm_split_macros = { path = "./wasm_split_macros", version = "0.1.0" } wasm_split_macros = { path = "./wasm_split_macros", version = "0.1.0" }
@@ -79,7 +79,7 @@ async-once-cell = { default-features = false, version = "0.5.3" }
itertools = { default-features = false, version = "0.14.0" } itertools = { default-features = false, version = "0.14.0" }
convert_case = { default-features = false, version = "0.8.0" } convert_case = { default-features = false, version = "0.8.0" }
serde_json = { default-features = false, version = "1.0.140" } serde_json = { default-features = false, version = "1.0.140" }
trybuild = { default-features = false, version = "1.0.105" } trybuild = { default-features = false, version = "1.0.106" }
typed-builder = { default-features = false, version = "0.21.0" } typed-builder = { default-features = false, version = "0.21.0" }
thiserror = { default-features = false, version = "2.0.12" } thiserror = { default-features = false, version = "2.0.12" }
wasm-bindgen = { default-features = false, version = "0.2.100" } wasm-bindgen = { default-features = false, version = "0.2.100" }
@@ -101,7 +101,7 @@ proc-macro-error2 = { default-features = false, version = "2.0.1" }
const_format = { default-features = false, version = "0.2.34" } const_format = { default-features = false, version = "0.2.34" }
gloo-net = { default-features = false, version = "0.6.0" } gloo-net = { default-features = false, version = "0.6.0" }
url = { default-features = false, version = "2.5.4" } url = { default-features = false, version = "2.5.4" }
tokio = { default-features = false, version = "1.45.1" } tokio = { default-features = false, version = "1.46.1" }
base64 = { default-features = false, version = "0.22.1" } base64 = { default-features = false, version = "0.22.1" }
cfg-if = { default-features = false, version = "1.0.0" } cfg-if = { default-features = false, version = "1.0.0" }
wasm-bindgen-futures = { default-features = false, version = "0.4.50" } wasm-bindgen-futures = { default-features = false, version = "0.4.50" }
@@ -132,7 +132,7 @@ actix-ws = { default-features = false, version = "0.3.0" }
tower-http = { default-features = false, version = "0.6.4" } tower-http = { default-features = false, version = "0.6.4" }
prettyplease = { default-features = false, version = "0.2.35" } prettyplease = { default-features = false, version = "0.2.35" }
inventory = { default-features = false, version = "0.3.20" } inventory = { default-features = false, version = "0.3.20" }
config = { default-features = false, version = "0.15.11" } config = { default-features = false, version = "0.15.13" }
camino = { default-features = false, version = "1.1.9" } camino = { default-features = false, version = "1.1.9" }
ciborium = { default-features = false, version = "0.2.2" } ciborium = { default-features = false, version = "0.2.2" }
multer = { default-features = false, version = "3.1.0" } multer = { default-features = false, version = "3.1.0" }
@@ -152,12 +152,12 @@ futures-lite = { default-features = false, version = "2.6.0" }
log = { default-features = false, version = "0.4.27" } log = { default-features = false, version = "0.4.27" }
percent-encoding = { default-features = false, version = "2.3.1" } percent-encoding = { default-features = false, version = "2.3.1" }
async-executor = { default-features = false, version = "1.13.2" } async-executor = { default-features = false, version = "1.13.2" }
const-str = { default-features = false, version = "0.6.2" } const-str = { default-features = false, version = "0.6.3" }
http-body-util = { default-features = false, version = "0.1.3" } http-body-util = { default-features = false, version = "0.1.3" }
hyper = { default-features = false, version = "1.6.0" } hyper = { default-features = false, version = "1.6.0" }
postcard = { default-features = false, version = "1.1.1" } postcard = { default-features = false, version = "1.1.1" }
rmp-serde = { default-features = false, version = "1.3.0" } rmp-serde = { default-features = false, version = "1.3.0" }
reqwest = { default-features = false, version = "0.12.18" } reqwest = { default-features = false, version = "0.12.22" }
tower-layer = { default-features = false, version = "0.3.3" } tower-layer = { default-features = false, version = "0.3.3" }
attribute-derive = { default-features = false, version = "0.10.3" } attribute-derive = { default-features = false, version = "0.10.3" }
insta = { default-features = false, version = "1.43.1" } insta = { default-features = false, version = "1.43.1" }

View File

@@ -125,7 +125,7 @@ Yes, Im sure there are. You can see from the state of our issue tracker over
This may be the big one: “production ready” implies a certain orientation to a library: that you can basically use it, without any special knowledge of its internals or ability to contribute. Everyone has this at some level in their stack: for example I (@gbj) dont have the capacity or knowledge to contribute to something like `wasm-bindgen` at this point: I simply rely on it to work. This may be the big one: “production ready” implies a certain orientation to a library: that you can basically use it, without any special knowledge of its internals or ability to contribute. Everyone has this at some level in their stack: for example I (@gbj) dont have the capacity or knowledge to contribute to something like `wasm-bindgen` at this point: I simply rely on it to work.
There are several people in the community using Leptos right now for internal apps at work, who have also become significant contributors. I think this is the right level of production use for now. There may be missing features that you need, and you may end up building them! But for internal apps, if youre willing to build and contribute missing pieces along the way, the framework is definitely usable right now. There are several people in the community using Leptos right now for many websites at work, who have also become significant contributors. There may be missing features that you need, and you may end up building them! But, if you're willing to contribute a few missing pieces along the way, the framework is most definitely usable for production applications, especially given the ecosystem of libraries that have sprung up around it.
### Can I use this for native GUI? ### Can I use this for native GUI?

View File

@@ -19,7 +19,7 @@ leptos_meta = { path = "../../meta" }
leptos_axum = { path = "../../integrations/axum", optional = true } leptos_axum = { path = "../../integrations/axum", optional = true }
leptos_router = { path = "../../router" } leptos_router = { path = "../../router" }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0" thiserror = "2.0.12"
tokio = { version = "1.39", features = [ tokio = { version = "1.39", features = [
"rt-multi-thread", "rt-multi-thread",
"macros", "macros",

View File

@@ -18,7 +18,7 @@ tower = { version = "0.4.13", optional = true }
tower-http = { version = "0.5.2", features = ["fs"], optional = true } tower-http = { version = "0.5.2", features = ["fs"], optional = true }
tokio = { version = "1.39", features = ["full"], optional = true } tokio = { version = "1.39", features = ["full"], optional = true }
http = { version = "1.1" } http = { version = "1.1" }
thiserror = "1.0" thiserror = "2.0.12"
wasm-bindgen = "0.2.93" wasm-bindgen = "0.2.93"
[features] [features]

View File

@@ -15,7 +15,7 @@ serde = { version = "1.0", features = ["derive"] }
log = "0.4.22" log = "0.4.22"
console_log = "1.0" console_log = "1.0"
console_error_panic_hook = "0.1.7" console_error_panic_hook = "0.1.7"
thiserror = "1.0" thiserror = "2.0.12"
tracing = "0.1.40" tracing = "0.1.40"
tracing-subscriber = "0.3.18" tracing-subscriber = "0.3.18"
tracing-subscriber-wasm = "0.1.0" tracing-subscriber-wasm = "0.1.0"

View File

@@ -15,7 +15,7 @@ leptos_meta = { path = "../../meta" }
leptos_axum = { path = "../../integrations/axum", optional = true } leptos_axum = { path = "../../integrations/axum", optional = true }
leptos_router = { path = "../../router" } leptos_router = { path = "../../router" }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0" thiserror = "2.0.12"
tokio = { version = "1.39", features = [ "rt-multi-thread", "macros", "time" ], optional = true } tokio = { version = "1.39", features = [ "rt-multi-thread", "macros", "time" ], optional = true }
wasm-bindgen = "0.2.92" wasm-bindgen = "0.2.92"

View File

@@ -29,7 +29,7 @@ tower-http = { version = "0.6.2", features = [
"trace", "trace",
], optional = true } ], optional = true }
tokio = { version = "1.39", features = ["full"], optional = true } tokio = { version = "1.39", features = ["full"], optional = true }
thiserror = "2.0.11" thiserror = "2.0.12"
wasm-bindgen = "0.2.93" wasm-bindgen = "0.2.93"
serde_toml = "0.0.1" serde_toml = "0.0.1"
toml = "0.8.19" toml = "0.8.19"

View File

@@ -17,7 +17,7 @@ leptos_actix = { path = "../../integrations/actix", optional = true }
leptos_router = { path = "../../router" } leptos_router = { path = "../../router" }
log = "0.4.22" log = "0.4.22"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0" thiserror = "2.0.12"
tokio = { version = "1.39", features = ["time"] } tokio = { version = "1.39", features = ["time"] }
wasm-bindgen = "0.2.93" wasm-bindgen = "0.2.93"

View File

@@ -17,7 +17,7 @@ leptos_axum = { path = "../../integrations/axum", optional = true }
leptos_router = { path = "../../router" } leptos_router = { path = "../../router" }
log = "0.4.22" log = "0.4.22"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0" thiserror = "2.0.12"
axum = { version = "0.8.1", optional = true } axum = { version = "0.8.1", optional = true }
tower = { version = "0.4.13", optional = true } tower = { version = "0.4.13", optional = true }
tower-http = { version = "0.5.2", features = ["fs"], optional = true } tower-http = { version = "0.5.2", features = ["fs"], optional = true }

View File

@@ -17,7 +17,7 @@ leptos_axum = { path = "../../integrations/axum", optional = true }
leptos_router = { path = "../../router" } leptos_router = { path = "../../router" }
log = "0.4.22" log = "0.4.22"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0" thiserror = "2.0.12"
axum = { version = "0.8.1", optional = true } axum = { version = "0.8.1", optional = true }
tower = { version = "0.4.13", optional = true } tower = { version = "0.4.13", optional = true }
tower-http = { version = "0.5.2", features = ["fs"], optional = true } tower-http = { version = "0.5.2", features = ["fs"], optional = true }

View File

@@ -20,7 +20,7 @@ tokio = { version = "1.39", features = [
tower = { version = "0.4.13", optional = true } tower = { version = "0.4.13", optional = true }
tower-http = { version = "0.5.2", features = ["fs"], optional = true } tower-http = { version = "0.5.2", features = ["fs"], optional = true }
wasm-bindgen = "0.2.93" wasm-bindgen = "0.2.93"
thiserror = "1.0" thiserror = "2.0.12"
tracing = { version = "0.1.40", optional = true } tracing = { version = "0.1.40", optional = true }
http = "1.1" http = "1.1"

View File

@@ -20,7 +20,7 @@ leptos_actix = { path = "../../integrations/actix", optional = true }
log = "0.4.22" log = "0.4.22"
simple_logger = "5.0" simple_logger = "5.0"
gloo = { git = "https://github.com/rustwasm/gloo" } gloo = { git = "https://github.com/rustwasm/gloo" }
sqlx = { version = "0.8.0", features = [ sqlx = { version = "0.8.6", features = [
"runtime-tokio-rustls", "runtime-tokio-rustls",
"sqlite", "sqlite",
], optional = true } ], optional = true }
@@ -44,12 +44,12 @@ denylist = ["actix-files", "actix-web", "leptos_actix", "sqlx"]
skip_feature_sets = [["csr", "ssr"], ["csr", "hydrate"], ["ssr", "hydrate"], []] skip_feature_sets = [["csr", "ssr"], ["csr", "hydrate"], ["ssr", "hydrate"], []]
[package.metadata.leptos] [package.metadata.leptos]
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name # The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
output-name = "todo_app_sqlite" output-name = "todo_app_sqlite"
# The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup. # The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup.
site-root = "target/site" site-root = "target/site"
# The site-root relative folder where all compiled output (JS, WASM and CSS) is written # The site-root relative folder where all compiled output (JS, WASM and CSS) is written
# Defaults to pkg # Defaults to pkg
site-pkg-dir = "pkg" site-pkg-dir = "pkg"
# [Optional] The source CSS file. If it ends with .sass or .scss then it will be compiled by dart-sass into CSS. The CSS is optimized by Lightning CSS before being written to <site-root>/<site-pkg>/app.css # [Optional] The source CSS file. If it ends with .sass or .scss then it will be compiled by dart-sass into CSS. The CSS is optimized by Lightning CSS before being written to <site-root>/<site-pkg>/app.css
style-file = "./style.css" style-file = "./style.css"

View File

@@ -20,11 +20,11 @@ axum = { version = "0.8.1", optional = true }
tower = { version = "0.4.13", optional = true } tower = { version = "0.4.13", optional = true }
tower-http = { version = "0.5.2", features = ["fs"], optional = true } tower-http = { version = "0.5.2", features = ["fs"], optional = true }
tokio = { version = "1.39", features = ["full"], optional = true } tokio = { version = "1.39", features = ["full"], optional = true }
sqlx = { version = "0.8.0", features = [ sqlx = { version = "0.8.6", features = [
"runtime-tokio-rustls", "runtime-tokio-rustls",
"sqlite", "sqlite",
], optional = true } ], optional = true }
thiserror = "1.0" thiserror = "2.0.12"
wasm-bindgen = "0.2.93" wasm-bindgen = "0.2.93"
[features] [features]

View File

@@ -20,11 +20,11 @@ tower = { version = "0.5.1", features = ["util"], optional = true }
tower-http = { version = "0.6.1", features = ["fs"], optional = true } tower-http = { version = "0.6.1", features = ["fs"], optional = true }
tokio = { version = "1.39", features = ["full"], optional = true } tokio = { version = "1.39", features = ["full"], optional = true }
http = { version = "1.1" } http = { version = "1.1" }
sqlx = { version = "0.8.0", features = [ sqlx = { version = "0.8.6", features = [
"runtime-tokio-rustls", "runtime-tokio-rustls",
"sqlite", "sqlite",
], optional = true } ], optional = true }
thiserror = "2.0" thiserror = "2.0.12"
wasm-bindgen = "0.2.93" wasm-bindgen = "0.2.93"
[features] [features]

View File

@@ -17,7 +17,7 @@ simple_logger = "5.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
axum = { version = "0.8.1", optional = true } axum = { version = "0.8.1", optional = true }
tokio = { version = "1.39", features = ["full"], optional = true } tokio = { version = "1.39", features = ["full"], optional = true }
thiserror = "2.0" thiserror = "2.0.12"
wasm-bindgen = "0.2.100" wasm-bindgen = "0.2.100"
[features] [features]

View File

@@ -11,7 +11,7 @@ edition.workspace = true
[dependencies] [dependencies]
actix-http = { workspace = true, default-features = true } actix-http = { workspace = true, default-features = true }
actix-files = { workspace = true, default-features = true } actix-files = { workspace = true, default-features = true }
actix-web = { workspace = true, default-features = true } actix-web = { workspace = true, default-features = false }
futures = { workspace = true, default-features = true } futures = { workspace = true, default-features = true }
any_spawner = { workspace = true, features = ["tokio"] } any_spawner = { workspace = true, features = ["tokio"] }
hydration_context = { workspace = true } hydration_context = { workspace = true }
@@ -20,7 +20,7 @@ leptos_integration_utils = { workspace = true }
leptos_macro = { workspace = true, features = ["actix"] } leptos_macro = { workspace = true, features = ["actix"] }
leptos_meta = { workspace = true, features = ["nonce"] } leptos_meta = { workspace = true, features = ["nonce"] }
leptos_router = { workspace = true, features = ["ssr"] } leptos_router = { workspace = true, features = ["ssr"] }
server_fn = { workspace = true, features = ["actix"] } server_fn = { workspace = true, features = ["actix-no-default"] }
tachys = { workspace = true } tachys = { workspace = true }
serde_json = { workspace = true , default-features = true } serde_json = { workspace = true , default-features = true }
parking_lot = { workspace = true, default-features = true } parking_lot = { workspace = true, default-features = true }
@@ -33,6 +33,8 @@ dashmap = { workspace = true, default-features = true }
rustdoc-args = ["--generate-link-to-definition"] rustdoc-args = ["--generate-link-to-definition"]
[features] [features]
default = ["actix-default"]
actix-default = ["actix-web/default"]
islands-router = ["tachys/islands"] islands-router = ["tachys/islands"]
tracing = ["dep:tracing"] tracing = ["dep:tracing"]

View File

@@ -282,6 +282,7 @@ pub fn redirect(path: &str) {
/// // call ServerFn::register() for each of the server functions you've defined /// // call ServerFn::register() for each of the server functions you've defined
/// } /// }
/// ///
/// # #[cfg(feature = "default")]
/// #[actix_web::main] /// #[actix_web::main]
/// async fn main() -> std::io::Result<()> { /// async fn main() -> std::io::Result<()> {
/// // make sure you actually register your server functions /// // make sure you actually register your server functions
@@ -297,6 +298,8 @@ pub fn redirect(path: &str) {
/// .run() /// .run()
/// .await /// .await
/// } /// }
/// # #[cfg(not(feature = "default"))]
/// # fn main() {}
/// ``` /// ```
/// ///
/// ## Provided Context Types /// ## Provided Context Types
@@ -442,6 +445,7 @@ pub fn handle_server_fns_with_context(
/// view! { <main>"Hello, world!"</main> } /// view! { <main>"Hello, world!"</main> }
/// } /// }
/// ///
/// # #[cfg(feature = "default")]
/// #[actix_web::main] /// #[actix_web::main]
/// async fn main() -> std::io::Result<()> { /// async fn main() -> std::io::Result<()> {
/// let conf = get_configuration(Some("Cargo.toml")).unwrap(); /// let conf = get_configuration(Some("Cargo.toml")).unwrap();
@@ -461,6 +465,8 @@ pub fn handle_server_fns_with_context(
/// .run() /// .run()
/// .await /// .await
/// } /// }
/// # #[cfg(not(feature = "default"))]
/// # fn main() {}
/// ``` /// ```
/// ///
/// ## Provided Context Types /// ## Provided Context Types
@@ -499,6 +505,7 @@ where
/// view! { <main>"Hello, world!"</main> } /// view! { <main>"Hello, world!"</main> }
/// } /// }
/// ///
/// # #[cfg(feature = "default")]
/// #[actix_web::main] /// #[actix_web::main]
/// async fn main() -> std::io::Result<()> { /// async fn main() -> std::io::Result<()> {
/// let conf = get_configuration(Some("Cargo.toml")).unwrap(); /// let conf = get_configuration(Some("Cargo.toml")).unwrap();
@@ -521,6 +528,9 @@ where
/// .run() /// .run()
/// .await /// .await
/// } /// }
///
/// # #[cfg(not(feature = "default"))]
/// # fn main() {}
/// ``` /// ```
/// ///
/// ## Provided Context Types /// ## Provided Context Types
@@ -557,6 +567,7 @@ where
/// view! { <main>"Hello, world!"</main> } /// view! { <main>"Hello, world!"</main> }
/// } /// }
/// ///
/// # #[cfg(feature = "default")]
/// #[actix_web::main] /// #[actix_web::main]
/// async fn main() -> std::io::Result<()> { /// async fn main() -> std::io::Result<()> {
/// let conf = get_configuration(Some("Cargo.toml")).unwrap(); /// let conf = get_configuration(Some("Cargo.toml")).unwrap();
@@ -576,6 +587,8 @@ where
/// .run() /// .run()
/// .await /// .await
/// } /// }
/// # #[cfg(not(feature = "default"))]
/// # fn main() {}
/// ``` /// ```
/// ///
/// ## Provided Context Types /// ## Provided Context Types

View File

@@ -4,7 +4,7 @@ authors = ["Greg Johnston"]
license = "MIT" license = "MIT"
repository = "https://github.com/leptos-rs/leptos" repository = "https://github.com/leptos-rs/leptos"
description = "Axum integrations for the Leptos web framework." description = "Axum integrations for the Leptos web framework."
version = "0.8.3" version = { workspace = true }
rust-version.workspace = true rust-version.workspace = true
edition.workspace = true edition.workspace = true

View File

@@ -3,7 +3,7 @@ use std::sync::Arc;
use tachys::prelude::IntoAttributeValue; use tachys::prelude::IntoAttributeValue;
/// 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.,
/// a [`String`], a [`&str`], or a reactive `Fn() -> String`. /// a [`String`], a [`&str`], a `Signal` or a reactive `Fn() -> String`.
#[derive(Clone)] #[derive(Clone)]
pub struct TextProp(Arc<dyn Fn() -> Oco<'static, str> + Send + Sync>); pub struct TextProp(Arc<dyn Fn() -> Oco<'static, str> + Send + Sync>);
@@ -82,3 +82,93 @@ impl IntoAttributeValue for TextProp {
self.0 self.0
} }
} }
macro_rules! textprop_reactive {
($name:ident, <$($gen:ident),*>, $v:ty, $( $where_clause:tt )*) =>
{
#[allow(deprecated)]
impl<$($gen),*> From<$name<$($gen),*>> for TextProp
where
$v: Into<Oco<'static, str>> + Clone + Send + Sync + 'static,
$($where_clause)*
{
#[inline(always)]
fn from(s: $name<$($gen),*>) -> Self {
TextProp(Arc::new(move || s.get().into()))
}
}
};
}
#[cfg(not(feature = "nightly"))]
mod stable {
use super::TextProp;
use oco_ref::Oco;
#[allow(deprecated)]
use reactive_graph::wrappers::read::MaybeSignal;
use reactive_graph::{
computed::{ArcMemo, Memo},
owner::Storage,
signal::{ArcReadSignal, ArcRwSignal, ReadSignal, RwSignal},
traits::Get,
wrappers::read::{ArcSignal, Signal},
};
use std::sync::Arc;
textprop_reactive!(
RwSignal,
<V, S>,
V,
RwSignal<V, S>: Get<Value = V>,
S: Storage<V> + Storage<Option<V>>,
S: Send + Sync + 'static,
);
textprop_reactive!(
ReadSignal,
<V, S>,
V,
ReadSignal<V, S>: Get<Value = V>,
S: Storage<V> + Storage<Option<V>>,
S: Send + Sync + 'static,
);
textprop_reactive!(
Memo,
<V, S>,
V,
Memo<V, S>: Get<Value = V>,
S: Storage<V> + Storage<Option<V>>,
S: Send + Sync + 'static,
);
textprop_reactive!(
Signal,
<V, S>,
V,
Signal<V, S>: Get<Value = V>,
S: Storage<V> + Storage<Option<V>>,
S: Send + Sync + 'static,
);
textprop_reactive!(
MaybeSignal,
<V, S>,
V,
MaybeSignal<V, S>: Get<Value = V>,
S: Storage<V> + Storage<Option<V>>,
S: Send + Sync + 'static,
);
textprop_reactive!(ArcRwSignal, <V>, V, ArcRwSignal<V>: Get<Value = V>);
textprop_reactive!(ArcReadSignal, <V>, V, ArcReadSignal<V>: Get<Value = V>);
textprop_reactive!(ArcMemo, <V>, V, ArcMemo<V>: Get<Value = V>);
textprop_reactive!(ArcSignal, <V>, V, ArcSignal<V>: Get<Value = V>);
}
/// Extension trait for `Option<TextProp>`
pub trait OptionTextPropExt {
/// Accesses the current value of the `Option<TextProp>` as an `Option<Oco<'static, str>>`.
fn get(&self) -> Option<Oco<'static, str>>;
}
impl OptionTextPropExt for Option<TextProp> {
fn get(&self) -> Option<Oco<'static, str>> {
self.as_ref().map(|text_prop| text_prop.get())
}
}

View File

@@ -23,6 +23,19 @@ macro_rules! error {
($($t:tt)*) => ($crate::logging::console_error(&format_args!($($t)*).to_string())) ($($t:tt)*) => ($crate::logging::console_error(&format_args!($($t)*).to_string()))
} }
/// Uses `println!()`-style formatting to log something to the console (in the browser)
/// or via `println!()` (if not in the browser), but only if it's a debug build.
#[macro_export]
macro_rules! debug_log {
($($x:tt)*) => {
{
if cfg!(debug_assertions) {
$crate::log!($($x)*)
}
}
}
}
/// Uses `println!()`-style formatting to log warnings to the console (in the browser) /// Uses `println!()`-style formatting to log warnings to the console (in the browser)
/// or via `eprintln!()` (if not in the browser), but only if it's a debug build. /// or via `eprintln!()` (if not in the browser), but only if it's a debug build.
#[macro_export] #[macro_export]
@@ -36,6 +49,19 @@ macro_rules! debug_warn {
} }
} }
/// Uses `println!()`-style formatting to log errors to the console (in the browser)
/// or via `eprintln!()` (if not in the browser), but only if it's a debug build.
#[macro_export]
macro_rules! debug_error {
($($x:tt)*) => {
{
if cfg!(debug_assertions) {
$crate::error!($($x)*)
}
}
}
}
const fn log_to_stdout() -> bool { const fn log_to_stdout() -> bool {
cfg!(not(all( cfg!(not(all(
target_arch = "wasm32", target_arch = "wasm32",
@@ -55,7 +81,7 @@ pub fn console_log(s: &str) {
} }
/// Log a warning to the console (in the browser) /// Log a warning to the console (in the browser)
/// or via `println!()` (if not in the browser). /// or via `eprintln!()` (if not in the browser).
pub fn console_warn(s: &str) { pub fn console_warn(s: &str) {
if log_to_stdout() { if log_to_stdout() {
eprintln!("{s}"); eprintln!("{s}");
@@ -65,7 +91,7 @@ pub fn console_warn(s: &str) {
} }
/// Log an error to the console (in the browser) /// Log an error to the console (in the browser)
/// or via `println!()` (if not in the browser). /// or via `eprintln!()` (if not in the browser).
#[inline(always)] #[inline(always)]
pub fn console_error(s: &str) { pub fn console_error(s: &str) {
if log_to_stdout() { if log_to_stdout() {
@@ -75,21 +101,29 @@ pub fn console_error(s: &str) {
} }
} }
/// Log an error to the console (in the browser) /// Log a string to the console (in the browser)
/// or via `println!()` (if not in the browser), but only in a debug build. /// or via `println!()` (if not in the browser), but only in a debug build.
#[inline(always)] #[inline(always)]
pub fn console_debug_warn(s: &str) { pub fn console_debug_log(s: &str) {
#[cfg(debug_assertions)] if cfg!(debug_assertions) {
{ console_log(s)
if log_to_stdout() { }
eprintln!("{s}"); }
} else {
web_sys::console::warn_1(&JsValue::from_str(s)); /// Log a warning to the console (in the browser)
} /// or via `eprintln!()` (if not in the browser), but only in a debug build.
} #[inline(always)]
pub fn console_debug_warn(s: &str) {
#[cfg(not(debug_assertions))] if cfg!(debug_assertions) {
{ console_warn(s)
let _ = s; }
}
/// Log an error to the console (in the browser)
/// or via `eprintln!()` (if not in the browser), but only in a debug build.
#[inline(always)]
pub fn console_debug_error(s: &str) {
if cfg!(debug_assertions) {
console_error(s)
} }
} }

View File

@@ -251,93 +251,67 @@ impl LNode {
action: PatchAction::ClearChildren, action: PatchAction::ClearChildren,
}] }]
} else { } else {
let mut a = 0; let width = old.len() + 1;
let mut b = std::cmp::max(old.len(), new.len()) - 1; // min is 0, have checked both have items let height = new.len() + 1;
let mut mat = vec![0; width * height];
#[allow(clippy::needless_range_loop)]
for i in 1..width {
mat[i] = i;
}
for i in 1..height {
mat[i * width] = i;
}
for j in 1..height {
for i in 1..width {
if old[i - 1] == new[j - 1] {
mat[j * width + i] = mat[(j - 1) * width + (i - 1)];
} else {
mat[j * width + i] = (mat[(j - 1) * width + i] + 1)
.min(mat[j * width + (i - 1)] + 1)
.min(mat[(j - 1) * width + (i - 1)] + 1)
}
}
}
let (mut i, mut j) = (old.len(), new.len());
let mut patches = vec![]; let mut patches = vec![];
// common prefix while i > 0 || j > 0 {
while a < b { if i > 0 && j > 0 && old[i - 1] == new[j - 1] {
let old = old.get(a); i -= 1;
let new = new.get(a); j -= 1;
} else {
match (old, new) { let current = mat[j * width + i];
(None, Some(new)) => patches.push(Patch { if i > 0
path: path.to_owned(), && j > 0
action: PatchAction::InsertChild { && mat[(j - 1) * width + i - 1] + 1 == current
before: a, {
child: new.to_replacement_node(old_children), let mut new_path = path.to_owned();
}, new_path.push(i - 1);
}), let diffs = old[i - 1].diff_at(
(Some(_), None) => patches.push(Patch { &new[j - 1],
path: path.to_owned(), &new_path,
action: PatchAction::RemoveChild { at: a }, old_children,
}), );
(Some(old), Some(new)) if old != new => { patches.extend(&mut diffs.into_iter());
break; i -= 1;
} j -= 1;
_ => {} } else if i > 0 && mat[j * width + i - 1] + 1 == current {
} patches.push(Patch {
path: path.to_owned(),
a += 1; action: PatchAction::RemoveChild { at: i - 1 },
} });
i -= 1;
// common suffix } else if j > 0 && mat[(j - 1) * width + i] + 1 == current {
while b >= a { patches.push(Patch {
let old = old.get(b);
let new = new.get(b);
match (old, new) {
(None, Some(new)) => patches.push(Patch {
path: path.to_owned(),
action: PatchAction::InsertChildAfter {
after: b - 1,
child: new.to_replacement_node(old_children),
},
}),
(Some(_), None) => patches.push(Patch {
path: path.to_owned(),
action: PatchAction::RemoveChild { at: b },
}),
(Some(old), Some(new)) if old != new => {
break;
}
_ => {}
}
if b == 0 {
break;
}
b -= 1;
}
// diffing in middle
if b >= a {
let old_slice_end =
if b >= old.len() { old.len() - 1 } else { b };
let new_slice_end =
if b >= new.len() { new.len() - 1 } else { b };
let old = &old[a..=old_slice_end];
let new = &new[a..=new_slice_end];
for (new_idx, new_node) in new.iter().enumerate() {
match old.get(new_idx) {
Some(old_node) => {
let mut new_path = path.to_vec();
new_path.push(new_idx + a);
let diffs = old_node.diff_at(
new_node,
&new_path,
old_children,
);
patches.extend(&mut diffs.into_iter());
}
None => patches.push(Patch {
path: path.to_owned(), path: path.to_owned(),
action: PatchAction::InsertChild { action: PatchAction::InsertChild {
before: new_idx, before: i,
child: new_node child: new[j - 1]
.to_replacement_node(old_children), .to_replacement_node(old_children),
}, },
}), });
j -= 1;
} else {
unreachable!();
} }
} }
} }
@@ -514,23 +488,17 @@ mod tests {
let delta = a.diff(&b); let delta = a.diff(&b);
assert_eq!( assert_eq!(
delta, delta,
vec![ vec![Patch {
Patch { path: vec![],
path: vec![], action: PatchAction::InsertChild {
action: PatchAction::InsertChildAfter { before: 0,
after: 0, child: ReplacementNode::Element {
child: ReplacementNode::Element { name: "button".into(),
name: "button".into(), attrs: vec![],
attrs: vec![], children: vec![ReplacementNode::Html("foo".into())]
children: vec![ReplacementNode::Html("bar".into())]
}
} }
},
Patch {
path: vec![0, 0],
action: PatchAction::SetText("foo".into())
} }
] }]
); );
} }

View File

@@ -121,6 +121,10 @@ impl ViewMacros {
} }
diffs diffs
} else { } else {
// TODO: instead of simply returning no patches, when number of views differs,
// we can compare views content to determine which views were shifted
// or come up with another idea that will allow to send patches when views were shifted/removed/added
lock.insert(path.clone(), new_views);
return Ok(None); return Ok(None);
} }
} }

View File

@@ -66,6 +66,9 @@ impl LNode {
LNode::parse_node(child, views)?; LNode::parse_node(child, views)?;
} }
} }
Node::RawText(text) => {
views.push(LNode::Text(text.to_string_best()));
}
Node::Text(text) => { Node::Text(text) => {
views.push(LNode::Text(text.value_string())); views.push(LNode::Text(text.value_string()));
} }

View File

@@ -4,7 +4,10 @@ function patch(json) {
const views = JSON.parse(json); const views = JSON.parse(json);
for (const [id, patches] of views) { for (const [id, patches] of views) {
console.log("[HOT RELOAD]", id, patches); console.log("[HOT RELOAD]", id, patches);
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_COMMENT), const walker = document.createTreeWalker(
document.body,
NodeFilter.SHOW_COMMENT,
),
open = `hot-reload|${id}|open`, open = `hot-reload|${id}|open`,
close = `hot-reload|${id}|close`; close = `hot-reload|${id}|close`;
let start, end; let start, end;
@@ -21,150 +24,200 @@ function patch(json) {
} }
for (const [start, end] of instances) { for (const [start, end] of instances) {
// build tree of current actual children
const actualChildren = childrenFromRange(start.parentElement, start, end);
const actions = [];
// build up the set of actions
for (const patch of patches) { for (const patch of patches) {
const actualChildren = childrenFromRange(
start.parentElement,
start,
end,
);
const child = childAtPath( const child = childAtPath(
actualChildren.length > 1 ? { children: actualChildren } : actualChildren[0], actualChildren.length > 1
patch.path ? { children: actualChildren }
: actualChildren[0],
patch.path,
); );
const action = patch.action; const action = patch.action;
if (action == "ClearChildren") { if (action == "ClearChildren") {
actions.push(() => { console.log("[HOT RELOAD] > ClearChildren", child.node);
console.log("[HOT RELOAD] > ClearChildren", child.node); if (child.node) {
child.node.textContent = ""; child.node.textContent = "";
}); } else {
} else if (action.ReplaceWith) { for (const existingChild of child.children) {
actions.push(() => { let parent = existingChild.node.parentElement;
console.log("[HOT RELOAD] > ReplaceWith", child, action.ReplaceWith); parent.removeChild(existingChild.node);
const replacement = fromReplacementNode(action.ReplaceWith, actualChildren);
if (child.node) {
child.node.replaceWith(replacement);
} else {
const range = new Range();
range.setStartAfter(child.start);
range.setEndAfter(child.end);
range.deleteContents();
child.start.replaceWith(replacement);
} }
}); }
} else if (action.ReplaceWith) {
console.log(
"[HOT RELOAD] > ReplaceWith",
child,
action.ReplaceWith,
);
const replacement = fromReplacementNode(
action.ReplaceWith,
actualChildren,
);
if (child.node) {
child.node.replaceWith(replacement);
} else {
if (child.children) {
child.children[0].node.parentElement.insertBefore(
replacement,
child.children[0].node,
);
for (const existingChild of child.children) {
existingChild.node.parentElement.removeChild(
existingChild.node,
);
}
}
}
} else if (action.ChangeTagName) { } else if (action.ChangeTagName) {
const oldNode = child.node; const oldNode = child.node;
actions.push(() => { console.log(
console.log("[HOT RELOAD] > ChangeTagName", child.node, action.ChangeTagName); "[HOT RELOAD] > ChangeTagName",
const newElement = document.createElement(action.ChangeTagName); child.node,
for (const attr of oldNode.attributes) { action.ChangeTagName,
newElement.setAttribute(attr.name, attr.value); );
} const newElement = document.createElement(action.ChangeTagName);
for (const childNode of child.node.childNodes) { for (const attr of oldNode.attributes) {
newElement.appendChild(childNode); newElement.setAttribute(attr.name, attr.value);
} }
for (const childNode of child.node.childNodes) {
newElement.appendChild(childNode);
}
child.node.replaceWith(newElement); child.node.replaceWith(newElement);
});
} else if (action.RemoveAttribute) { } else if (action.RemoveAttribute) {
actions.push(() => { console.log(
console.log("[HOT RELOAD] > RemoveAttribute", child.node, action.RemoveAttribute); "[HOT RELOAD] > RemoveAttribute",
child.node.removeAttribute(action.RemoveAttribute); child.node,
}); action.RemoveAttribute,
);
child.node.removeAttribute(action.RemoveAttribute);
} else if (action.SetAttribute) { } else if (action.SetAttribute) {
const [name, value] = action.SetAttribute; const [name, value] = action.SetAttribute;
actions.push(() => { console.log(
console.log("[HOT RELOAD] > SetAttribute", child.node, action.SetAttribute); "[HOT RELOAD] > SetAttribute",
child.node.setAttribute(name, value); child.node,
}); action.SetAttribute,
);
child.node.setAttribute(name, value);
} else if (action.SetText) { } else if (action.SetText) {
const node = child.node; const node = child.node;
actions.push(() => { console.log("[HOT RELOAD] > SetText", child.node, action.SetText);
console.log("[HOT RELOAD] > SetText", child.node, action.SetText); node.textContent = action.SetText;
node.textContent = action.SetText;
});
} else if (action.AppendChildren) { } else if (action.AppendChildren) {
actions.push(() => { console.log(
console.log("[HOT RELOAD] > AppendChildren", child.node, action.AppendChildren); "[HOT RELOAD] > AppendChildren",
const newChildren = fromReplacementNode(action.AppendChildren, actualChildren); child.node,
child.node.append(newChildren); action.AppendChildren,
}); );
const newChildren = action.AppendChildren.map((x) =>
fromReplacementNode(x, actualChildren),
);
child.node.append(...newChildren);
} else if (action.RemoveChild) { } else if (action.RemoveChild) {
actions.push(() => { console.log(
console.log("[HOT RELOAD] > RemoveChild", child.node, child.children, action.RemoveChild); "[HOT RELOAD] > RemoveChild",
const toRemove = child.children[action.RemoveChild.at]; child.node,
let toRemoveNode = toRemove.node; child.children,
if (!toRemoveNode) { action.RemoveChild,
const range = new Range(); );
range.setStartBefore(toRemove.start); const toRemove = child.children[action.RemoveChild.at];
range.setEndAfter(toRemove.end); let toRemoveNode = toRemove.node;
toRemoveNode = range.deleteContents(); if (!toRemoveNode) {
} else { const range = new Range();
toRemoveNode.parentNode.removeChild(toRemoveNode); range.setStartBefore(toRemove.start);
} range.setEndAfter(toRemove.end);
}); toRemoveNode = range.deleteContents();
} else {
toRemoveNode.parentNode.removeChild(toRemoveNode);
}
} else if (action.InsertChild) { } else if (action.InsertChild) {
const newChild = fromReplacementNode(action.InsertChild.child, actualChildren); const newChild = fromReplacementNode(
action.InsertChild.child,
actualChildren,
);
let children = []; let children = [];
if (child.children) { if (child.children) {
children = child.children; children = child.children;
} else if (child.start && child.end) { } else if (child.start && child.end) {
children = childrenFromRange(child.node || child.start.parentElement, start, end); children = childrenFromRange(
child.node || child.start.parentElement,
start,
end,
);
} else { } else {
console.warn("InsertChildAfter could not build children."); console.warn("InsertChildAfter could not build children.");
} }
const before = children[action.InsertChild.before]; const beforeNode = children[action.InsertChild.before];
actions.push(() => { console.log(
console.log("[HOT RELOAD] > InsertChild", child, child.node, action.InsertChild, " before ", before); "[HOT RELOAD] > InsertChild",
if (!before && child.node) { child,
child.node.appendChild(newChild); child.node,
} else { action.InsertChild,
let node = child.node || child.end.parentElement; " before ",
const reference = before ? before.node || before.start : child.end; beforeNode,
node.insertBefore(newChild, reference); );
} if (beforeNode) {
}); let node = beforeNode.node || beforeNode.start.previousSibling;
node.parentElement.insertBefore(newChild, node);
} else if (child.node) {
child.node.appendChild(newChild);
} else if (children) {
let lastNode = children[children.length - 1];
let afterNode = lastNode.node || lastNode.end.nextSibling;
afterNode.after(newChild);
}
} else if (action.InsertChildAfter) { } else if (action.InsertChildAfter) {
const newChild = fromReplacementNode(action.InsertChildAfter.child, actualChildren); const newChild = fromReplacementNode(
action.InsertChildAfter.child,
actualChildren,
);
let children = []; let children = [];
if (child.children) { if (child.children) {
children = child.children; children = child.children;
} else if (child.start && child.end) { } else if (child.start && child.end) {
children = childrenFromRange(child.node || child.start.parentElement, start, end); children = childrenFromRange(
child.node || child.start.parentElement,
start,
end,
);
} else { } else {
console.warn("InsertChildAfter could not build children."); console.warn("InsertChildAfter could not build children.");
} }
const after = children[action.InsertChildAfter.after]; const after = children[action.InsertChildAfter.after];
actions.push(() => { console.log(
console.log( "[HOT RELOAD] > InsertChildAfter",
"[HOT RELOAD] > InsertChildAfter", child,
child, child.node,
child.node, action.InsertChildAfter,
action.InsertChildAfter, " after ",
" after ", after,
after );
); if (
if (child.node && (!after || !(after.node || after.start).nextSibling)) { child.node &&
child.node.appendChild(newChild); (!after || !(after.node || after.start).nextSibling)
) {
child.node.appendChild(newChild);
} else {
const node = child.node || child.end;
const parent =
node.nodeType === Node.COMMENT_NODE ? node.parentNode : node;
if (!after) {
parent.appendChild(newChild);
} else { } else {
const node = child.node || child.end; parent.insertBefore(
const parent = node.nodeType === Node.COMMENT_NODE ? node.parentNode : node; newChild,
if (!after) { (after.node || after.start).nextSibling,
parent.appendChild(newChild); );
} else {
parent.insertBefore(newChild, (after.node || after.start).nextSibling);
}
} }
}); }
} else { } else {
console.warn("[HOT RELOADING] Unmatched action", action); console.warn("[HOT RELOADING] Unmatched action", action);
} }
} }
// actually run the actions
// the reason we delay them is so that children aren't moved before other children are found, etc.
for (const action of actions) {
action();
}
} }
} }
} catch (e) { } catch (e) {
@@ -191,8 +244,10 @@ function patch(json) {
return element; return element;
} else { } else {
const child = childAtPath( const child = childAtPath(
actualChildren.length > 1 ? { children: actualChildren } : actualChildren[0], actualChildren.length > 1
node.Path ? { children: actualChildren }
: actualChildren[0],
node.Path,
); );
if (child) { if (child) {
let childNode = child.node; let childNode = child.node;
@@ -215,7 +270,10 @@ function patch(json) {
} }
return childNode; return childNode;
} else { } else {
console.warn("[HOT RELOADING] Could not find replacement node at ", node.Path); console.warn(
"[HOT RELOADING] Could not find replacement node at ",
node.Path,
);
return undefined; return undefined;
} }
} }
@@ -227,13 +285,16 @@ function patch(json) {
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT,
{ {
acceptNode(node) { acceptNode(node) {
if (node.parentNode == element && (!range || range.isPointInRange(node, 0))) { if (
node.parentNode == element &&
(!range || range.isPointInRange(node, 0))
) {
return NodeFilter.FILTER_ACCEPT; return NodeFilter.FILTER_ACCEPT;
} else { } else {
return NodeFilter.FILTER_REJECT; return NodeFilter.FILTER_REJECT;
} }
}, },
} },
); );
const actualChildren = [], const actualChildren = [],
elementCount = {}; elementCount = {};
@@ -259,18 +320,22 @@ function patch(json) {
node: walker.currentNode, node: walker.currentNode,
}); });
} else if (walker.currentNode.nodeType == Node.COMMENT_NODE) { } else if (walker.currentNode.nodeType == Node.COMMENT_NODE) {
if (walker.currentNode.textContent.trim().startsWith("hot-reload")) { if (walker.currentNode.textContent.trim().startsWith("hot-reload|")) {
if (walker.currentNode.textContent.trim().endsWith("-children|open")) { if (walker.currentNode.textContent.trim().endsWith("|open")) {
const startingName = walker.currentNode.textContent.trim(); const startingName = walker.currentNode.textContent.trim();
const componentName = startingName.replace("-children|open").replace("hot-reload|"); const componentName = startingName
const endingName = `hot-reload|${componentName}-children|close`; .replace("|open", "")
.replace("hot-reload|", "");
const endingName = `hot-reload|${componentName}|close`;
let start = walker.currentNode; let start = walker.currentNode;
let depth = 1; let depth = 1;
while (walker.nextNode()) { while (walker.nextNode()) {
if (walker.currentNode.textContent.trim() == endingName) { if (walker.currentNode.textContent.trim() == endingName) {
depth--; depth--;
} else if (walker.currentNode.textContent.trim() == startingName) { } else if (
walker.currentNode.textContent.trim() == startingName
) {
depth++; depth++;
} }
@@ -283,7 +348,11 @@ function patch(json) {
type: "fragment", type: "fragment",
start: start.nextSibling, start: start.nextSibling,
end: end.previousSibling, end: end.previousSibling,
children: childrenFromRange(start.parentElement, start.nextSibling, end.previousSibling), children: childrenFromRange(
start.parentElement,
start.nextSibling,
end.previousSibling,
),
}); });
} }
} else if (walker.currentNode.textContent.trim() == "<() />") { } else if (walker.currentNode.textContent.trim() == "<() />") {
@@ -358,7 +427,10 @@ function patch(json) {
}); });
} }
} else { } else {
console.warn("[HOT RELOADING] Building children, encountered", walker.currentNode); console.warn(
"[HOT RELOADING] Building children, encountered",
walker.currentNode,
);
} }
} }
return actualChildren; return actualChildren;
@@ -374,7 +446,11 @@ function patch(json) {
} else if (path == [0]) { } else if (path == [0]) {
return element; return element;
} else if (element.start && element.end) { } else if (element.start && element.end) {
const actualChildren = childrenFromRange(element.node || element.start.parentElement, element.start, element.end); const actualChildren = childrenFromRange(
element.node || element.start.parentElement,
element.start,
element.end,
);
return childAtPath({ children: actualChildren }, path); return childAtPath({ children: actualChildren }, path);
} else { } else {
console.warn("[HOT RELOADING] Child at ", path, "not found in ", element); console.warn("[HOT RELOADING] Child at ", path, "not found in ", element);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -67,10 +67,32 @@ impl Url {
} }
pub fn hash(&self) -> &str { pub fn hash(&self) -> &str {
#[cfg(all(feature = "ssr", any(debug_assertions, leptos_debuginfo)))]
{
#[cfg(feature = "tracing")]
tracing::warn!(
"Reading hash on the server can lead to hydration errors."
);
#[cfg(not(feature = "tracing"))]
eprintln!(
"Reading hash on the server can lead to hydration errors."
);
}
&self.hash &self.hash
} }
pub fn hash_mut(&mut self) -> &mut String { pub fn hash_mut(&mut self) -> &mut String {
#[cfg(all(feature = "ssr", any(debug_assertions, leptos_debuginfo)))]
{
#[cfg(feature = "tracing")]
tracing::warn!(
"Reading hash on the server can lead to hydration errors."
);
#[cfg(not(feature = "tracing"))]
eprintln!(
"Reading hash on the server can lead to hydration errors."
);
}
&mut self.hash &mut self.hash
} }
@@ -173,7 +195,7 @@ impl Location {
let state = state.into(); let state = state.into();
let pathname = Memo::new(move |_| url.with(|url| url.path.clone())); let pathname = Memo::new(move |_| url.with(|url| url.path.clone()));
let search = Memo::new(move |_| url.with(|url| url.search.clone())); let search = Memo::new(move |_| url.with(|url| url.search.clone()));
let hash = Memo::new(move |_| url.with(|url| url.hash.clone())); let hash = Memo::new(move |_| url.with(|url| url.hash().to_string()));
let query = let query =
Memo::new(move |_| url.with(|url| url.search_params.clone())); Memo::new(move |_| url.with(|url| url.search_params.clone()));
Location { Location {

View File

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

View File

@@ -32,7 +32,7 @@ dashmap = { workspace = true, default-features = true }
## servers ## servers
# actix # actix
actix-web = { optional = true, workspace = true, default-features = true } actix-web = { optional = true, workspace = true, default-features = false }
actix-ws = { optional = true, workspace = true, default-features = true } actix-ws = { optional = true, workspace = true, default-features = true }
# axum # axum
@@ -108,7 +108,8 @@ axum-no-default = [
"dep:tower-layer", "dep:tower-layer",
] ]
form-redirects = [] form-redirects = []
actix = ["ssr", "dep:actix-web", "dep:actix-ws", "dep:send_wrapper"] actix-no-default = ["ssr", "dep:actix-web", "dep:actix-ws", "dep:send_wrapper"]
actix = ["actix-web/default", "actix-no-default"]
axum = ["axum/default", "axum-no-default", "axum/ws", "dep:tokio"] axum = ["axum/default", "axum-no-default", "axum/ws", "dep:tokio"]
browser = [ browser = [
"dep:gloo-net", "dep:gloo-net",

View File

@@ -120,7 +120,7 @@ pub mod request;
/// Types and traits for HTTP responses. /// Types and traits for HTTP responses.
pub mod response; pub mod response;
#[cfg(feature = "actix")] #[cfg(feature = "actix-no-default")]
#[doc(hidden)] #[doc(hidden)]
pub use ::actix_web as actix_export; pub use ::actix_web as actix_export;
#[cfg(feature = "axum-no-default")] #[cfg(feature = "axum-no-default")]
@@ -1118,7 +1118,7 @@ pub mod axum {
} }
/// Actix integration. /// Actix integration.
#[cfg(feature = "actix")] #[cfg(feature = "actix-no-default")]
pub mod actix { pub mod actix {
use crate::{ use crate::{
error::FromServerFnError, middleware::BoxedService, error::FromServerFnError, middleware::BoxedService,

View File

@@ -123,7 +123,7 @@ mod axum {
} }
} }
#[cfg(feature = "actix")] #[cfg(feature = "actix-no-default")]
mod actix { mod actix {
use crate::{ use crate::{
error::ServerFnErrorErr, error::ServerFnErrorErr,

View File

@@ -4,7 +4,7 @@ use http::Method;
use std::{borrow::Cow, future::Future}; use std::{borrow::Cow, future::Future};
/// Request types for Actix. /// Request types for Actix.
#[cfg(feature = "actix")] #[cfg(feature = "actix-no-default")]
pub mod actix; pub mod actix;
/// Request types for Axum. /// Request types for Axum.
#[cfg(feature = "axum-no-default")] #[cfg(feature = "axum-no-default")]

View File

@@ -1,5 +1,5 @@
/// Response types for Actix. /// Response types for Actix.
#[cfg(feature = "actix")] #[cfg(feature = "actix-no-default")]
pub mod actix; pub mod actix;
/// Response types for the browser. /// Response types for the browser.
#[cfg(feature = "browser")] #[cfg(feature = "browser")]

View File

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

View File

@@ -224,7 +224,7 @@ where
extra_attrs, extra_attrs,
); );
if !T::EXISTS { if !T::EXISTS {
buf.push_str("<!>"); buf.push_str("<!--<() />-->");
} }
} }
@@ -245,7 +245,7 @@ where
extra_attrs, extra_attrs,
); );
if !T::EXISTS { if !T::EXISTS {
buf.push_sync("<!>"); buf.push_sync("<!--<() />-->");
} }
} }
@@ -266,7 +266,7 @@ where
extra_attrs, extra_attrs,
); );
if !T::EXISTS { if !T::EXISTS {
buf.push_sync("<!>"); buf.push_sync("<!--<() />-->");
} }
} }