Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
7680f90
wip...
jkelleyrtp Aug 20, 2025
d885d9e
Merge remote-tracking branch 'origin/main' into jk/no-target-alias
jkelleyrtp Aug 20, 2025
ff18768
fix serverfn
jkelleyrtp Aug 21, 2025
b1a4a5c
wip: add test harnesses
jkelleyrtp Aug 22, 2025
76f6024
Merge remote-tracking branch 'origin/main' into jk/no-target-alias
jkelleyrtp Aug 22, 2025
d97d4af
merge conflict
jkelleyrtp Aug 22, 2025
3892c27
very sophisticated harness
jkelleyrtp Aug 22, 2025
07b0713
even larger testsuite
jkelleyrtp Aug 22, 2025
885f170
fix locking/race
jkelleyrtp Aug 22, 2025
bd225d2
fixup cases when not using dioxus explicitly
jkelleyrtp Aug 22, 2025
8f31b2b
fix dedicated syntax split
jkelleyrtp Aug 22, 2025
8dac2d3
fix bug wrt native
jkelleyrtp Aug 22, 2025
b306b2e
lil bit more cleanups, fixes, and harness
jkelleyrtp Aug 22, 2025
0b3cb0c
change to trace in native-dom
jkelleyrtp Aug 22, 2025
87edade
adb probe android
jkelleyrtp Aug 22, 2025
661f044
more test
jkelleyrtp Aug 22, 2025
dd8d85b
cleanuo
jkelleyrtp Aug 22, 2025
8ccaf69
typo
jkelleyrtp Aug 22, 2025
b0a0987
commit the harnesses for less churn
jkelleyrtp Aug 22, 2025
a38e9b5
use ios host sim arch
jkelleyrtp Aug 22, 2025
7624c56
fmt
jkelleyrtp Aug 22, 2025
97dc449
output with rustfmt right
jkelleyrtp Aug 22, 2025
294c73c
rustfmt skip
jkelleyrtp Aug 22, 2025
b1e1788
rustfmt
jkelleyrtp Aug 22, 2025
089b2d2
extra harness
jkelleyrtp Aug 22, 2025
b82c19c
add back
jkelleyrtp Aug 22, 2025
ca337cb
wip....
jkelleyrtp Sep 3, 2025
fc48fe0
fix
jkelleyrtp Sep 4, 2025
9a50e3e
Merge remote-tracking branch 'origin/main' into jk/no-target-alias
jkelleyrtp Sep 4, 2025
b6f2e65
move back router reubild
jkelleyrtp Sep 4, 2025
6363fb2
wip
jkelleyrtp Sep 4, 2025
930b7a0
wip...
jkelleyrtp Sep 4, 2025
12042ca
wip
jkelleyrtp Sep 5, 2025
2b77bf6
wip
jkelleyrtp Sep 6, 2025
11e12b3
happily compiles
jkelleyrtp Sep 7, 2025
b4d57fb
wip...
jkelleyrtp Sep 8, 2025
4d78f54
merge server + fullstack
jkelleyrtp Sep 9, 2025
5782519
wip: about to remove generic req/res
jkelleyrtp Sep 9, 2025
c81dacb
wip: simplify deps
jkelleyrtp Sep 9, 2025
0ea38c2
literally cooking
jkelleyrtp Sep 9, 2025
d951205
new api is cleaner
jkelleyrtp Sep 9, 2025
e593642
cleanup/organization
jkelleyrtp Sep 9, 2025
ae618ee
cleaner
jkelleyrtp Sep 9, 2025
70edc45
add tests for various extractors
jkelleyrtp Sep 10, 2025
d01636b
extract autoref?
jkelleyrtp Sep 10, 2025
6221bdf
tiered overloading seems to work out
jkelleyrtp Sep 11, 2025
38c9121
up to 5 generated
jkelleyrtp Sep 11, 2025
2faae94
yay it works
jkelleyrtp Sep 11, 2025
6713779
wip...
jkelleyrtp Sep 11, 2025
9d83fe8
rollback unit compacting
jkelleyrtp Sep 11, 2025
7e45779
almost there...
jkelleyrtp Sep 11, 2025
cc75de4
compiles 🪄
jkelleyrtp Sep 11, 2025
2347005
encoder types work too
jkelleyrtp Sep 11, 2025
28d84f3
wipppp
jkelleyrtp Sep 11, 2025
50e0a47
move examples into good folders
jkelleyrtp Sep 11, 2025
127526e
shuffle again
jkelleyrtp Sep 11, 2025
f30aec0
change asset path
jkelleyrtp Sep 11, 2025
f24e976
change back assets
jkelleyrtp Sep 11, 2025
4fb1345
small cleanups
jkelleyrtp Sep 11, 2025
48ccc91
Remove useless example
jkelleyrtp Sep 11, 2025
47b53f4
cleanup
jkelleyrtp Sep 11, 2025
8b0ca0d
add example scraper
jkelleyrtp Sep 11, 2025
cf560f0
update to rust 2024, fix bug in rsx expand
jkelleyrtp Sep 11, 2025
cd37aae
Update syntax to rust 2024
jkelleyrtp Sep 11, 2025
c60873a
more cleanups
jkelleyrtp Sep 12, 2025
a2cfb4b
use use_loader in more places
jkelleyrtp Sep 12, 2025
fd178ab
Improve loader a bit
jkelleyrtp Sep 12, 2025
dc572f5
Actions and Loaders are OP
jkelleyrtp Sep 12, 2025
b442521
cleanups
jkelleyrtp Sep 12, 2025
183fec7
revert zed config remove
jkelleyrtp Sep 12, 2025
c664a84
wip: cleanup error situation in core
jkelleyrtp Sep 12, 2025
6bbf914
more err cleanups
jkelleyrtp Sep 12, 2025
450f7f5
wip
jkelleyrtp Sep 13, 2025
1790686
fix bug
jkelleyrtp Sep 13, 2025
1a5c639
small cleanups
jkelleyrtp Sep 13, 2025
90cced5
rollback router changes
jkelleyrtp Sep 13, 2025
8d1bc13
switch to T: Transportable for fullstack encoding
jkelleyrtp Sep 13, 2025
81ee664
clean
jkelleyrtp Sep 13, 2025
6f61262
remove more todos
jkelleyrtp Sep 13, 2025
017c41e
fix error handling
jkelleyrtp Sep 13, 2025
cd37d74
more clean ups
jkelleyrtp Sep 13, 2025
2f012bd
allow sending error through serverfns
jkelleyrtp Sep 14, 2025
ac29397
more cleanups
jkelleyrtp Sep 14, 2025
9ac946f
reorg
jkelleyrtp Sep 15, 2025
cdb8e6b
wip, about to do refactor
jkelleyrtp Sep 16, 2025
d50cf80
split back into two crates
jkelleyrtp Sep 16, 2025
5cc132f
compiling again
jkelleyrtp Sep 16, 2025
d8baf76
use axum_core
jkelleyrtp Sep 16, 2025
1a48ecb
wip
jkelleyrtp Sep 16, 2025
10b902d
implement action/loader a bit more
jkelleyrtp Sep 16, 2025
b25d92e
implement use_action
jkelleyrtp Sep 16, 2025
3a1de38
it works but it doesnt
jkelleyrtp Sep 16, 2025
6bd499f
smaller diff
jkelleyrtp Sep 16, 2025
785bb60
derp, fix hydration
jkelleyrtp Sep 16, 2025
4e2255b
works! but why so slow
jkelleyrtp Sep 16, 2025
7e02f54
prevent using server-only endpoints on client
jkelleyrtp Sep 17, 2025
f313ca8
whole thing is working again
jkelleyrtp Sep 17, 2025
4862880
undo zed change
jkelleyrtp Sep 17, 2025
4d7f2cd
more cleanups / shrink
jkelleyrtp Sep 17, 2025
3f5b290
less flexible but more concrete
jkelleyrtp Sep 17, 2025
aa45fea
switch to axum response instead of reqwest response
jkelleyrtp Sep 17, 2025
3f79a77
wip, going to cut apart the encode impl
jkelleyrtp Sep 17, 2025
2b415ca
Chugging along nicely
jkelleyrtp Sep 17, 2025
5a004e4
existing cases seem to function
jkelleyrtp Sep 18, 2025
bfbb2f9
Custom encoding seems to work fine
jkelleyrtp Sep 18, 2025
c8e8327
warn on bad bodies
jkelleyrtp Sep 18, 2025
b7ab338
yayayayayayya
jkelleyrtp Sep 18, 2025
314d99b
wip, think I figured out a way for named fields to work
jkelleyrtp Sep 18, 2025
82d6a58
wip....
jkelleyrtp Sep 18, 2025
dc72865
wowowowowowo
jkelleyrtp Sep 18, 2025
8cbe0b2
wip.... about to clean up the magic module
jkelleyrtp Sep 18, 2025
ff20716
still cooking, just simpler
jkelleyrtp Sep 18, 2025
d5c961f
we don't need associated types!
jkelleyrtp Sep 18, 2025
a9fb0ca
cleanup magic a bit more
jkelleyrtp Sep 19, 2025
ccc87d6
typed errors!
jkelleyrtp Sep 19, 2025
c66961d
wire up status codes
jkelleyrtp Sep 19, 2025
e367d3e
wip...
jkelleyrtp Sep 20, 2025
3da99e5
implement server extraction
jkelleyrtp Sep 20, 2025
ead4863
fix bug with expansion
jkelleyrtp Sep 20, 2025
9ffcc6d
fix auth example
jkelleyrtp Sep 20, 2025
db331da
simplify a bit
jkelleyrtp Sep 20, 2025
30d4769
dispatch -> call
jkelleyrtp Sep 20, 2025
742c0e5
whys it not workng
jkelleyrtp Sep 20, 2025
5a795ad
I cold not tell you why it's not working.
jkelleyrtp Sep 20, 2025
e9ec18f
drop tables if they exist
jkelleyrtp Sep 20, 2025
e06ae00
docs as to why we drop
jkelleyrtp Sep 20, 2025
971e00d
add error handling, fix query string
jkelleyrtp Sep 21, 2025
1fff961
more docs and examples
jkelleyrtp Sep 21, 2025
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
Prev Previous commit
Next Next commit
wip: simplify deps
  • Loading branch information
jkelleyrtp committed Sep 9, 2025
commit c81dacb0b4d1da9e1af9a877dd1d0c4dc481f00c
1 change: 0 additions & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion packages/dioxus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ signals = ["dep:dioxus-signals", "dep:dioxus-stores"]
macro = ["dep:dioxus-core-macro"]
html = ["dep:dioxus-html"]
hooks = ["dep:dioxus-hooks"]
devtools = ["dep:dioxus-devtools", "dioxus-web?/devtools", "dioxus-fullstack?/devtools"]
devtools = ["dep:dioxus-devtools", "dioxus-web?/devtools"]
mounted = ["dioxus-web?/mounted"]
file_engine = ["dioxus-web?/file_engine"]
asset = ["dep:manganis", "dep:dioxus-asset-resolver"]
Expand Down
17 changes: 9 additions & 8 deletions packages/fullstack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ hyper-util = { workspace = true, features = ["full"], optional = true }
hyper = { workspace = true, optional = true }

# Web Integration
dioxus-web = { workspace = true, features = ["hydrate"], default-features = false, optional = true }
# dioxus-web = { workspace = true, features = ["hydrate"], default-features = false, optional = true }
dioxus-interpreter-js = { workspace = true, optional = true }

tracing = { workspace = true }
Expand Down Expand Up @@ -89,7 +89,7 @@ web-sys = { version = "0.3.77", optional = true, features = [
subsecond = { workspace = true }
dioxus-cli-config = { workspace = true, optional = true }
tokio-tungstenite = { workspace = true }
dioxus-devtools = { workspace = true, optional = true }
dioxus-devtools = { workspace = true }
aws-lc-rs = { version = "1.13.1", optional = true }
dioxus-history = { workspace = true }
http.workspace = true
Expand All @@ -115,12 +115,9 @@ dioxus = { workspace = true, features = ["fullstack"] }
tokio = { workspace = true, features = ["full"] }

[features]
default = ["devtools", "document", "file_engine", "mounted", "client", "server", "router"]
devtools = ["dioxus-web?/devtools", "dep:dioxus-devtools"]
mounted = ["dioxus-web?/mounted"]
file_engine = ["dioxus-web?/file_engine"]
document = ["dioxus-web?/document"]
web = ["dep:dioxus-web", "dep:web-sys", "dioxus-fullstack-hooks/web"]
default = ["router", "document", "client", "server"]
document = []
web = ["dep:web-sys", "dioxus-fullstack-hooks/web"]
router = ["dep:dioxus-router"]
default-tls = []
rustls = ["dep:rustls", "dep:hyper-rustls"]
Expand Down Expand Up @@ -154,6 +151,10 @@ server-core = [
]
aws-lc-rs = ["dep:aws-lc-rs"]

# document = ["dioxus-web?/document"]
# devtools = ["dioxus-web?/devtools", "dep:dioxus-devtools"]
# web = ["dep:dioxus-web", "dep:web-sys", "dioxus-fullstack-hooks/web"]

[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
features = ["axum", "web", "aws-lc-rs"]
14 changes: 7 additions & 7 deletions packages/fullstack/examples/simple-host.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use dioxus::prelude::*;
use dioxus_fullstack::{codec::Json, make_server_fn, AxumServerFn, Http, Websocket};
use dioxus_fullstack::{codec::Json, make_server_fn, Http, ServerFunction, WebSocket};
use std::future::Future;

#[tokio::main]
Expand Down Expand Up @@ -32,13 +32,13 @@ async fn do_thing(a: i32, b: String) -> dioxus::Result<()> {
}

inventory::submit! {
AxumServerFn::new(
ServerFunction::new(
http::Method::GET,
"/thing",
|req| {
Box::pin(async move {
todo!()
})
// this_protocol::run_on_server(req)
// this_protocol::run_on_client(req)
todo!()
},
None
)
Expand All @@ -53,8 +53,8 @@ async fn do_thing(a: i32, b: String) -> dioxus::Result<()> {
}
}

async fn make_websocket() -> dioxus::Result<Websocket> {
Ok(Websocket::new(|tx, rx| async move {
async fn make_websocket() -> dioxus::Result<WebSocket> {
Ok(WebSocket::new(|tx, rx| async move {
//
}))
}
Expand Down
10 changes: 2 additions & 8 deletions packages/fullstack/src/codec/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,15 @@ impl FormatType for JsonEncoding {
const FORMAT_TYPE: Format = Format::Text;
}

impl<T> Encodes<T> for JsonEncoding
where
T: Serialize,
{
impl<T: Serialize> Encodes<T> for JsonEncoding {
type Error = serde_json::Error;

fn encode(output: &T) -> Result<Bytes, Self::Error> {
serde_json::to_vec(output).map(Bytes::from)
}
}

impl<T> Decodes<T> for JsonEncoding
where
T: DeserializeOwned,
{
impl<T: DeserializeOwned> Decodes<T> for JsonEncoding {
type Error = serde_json::Error;

fn decode(bytes: Bytes) -> Result<T, Self::Error> {
Expand Down
8 changes: 4 additions & 4 deletions packages/fullstack/src/codec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ use futures::Future;
use http::Method;
// pub use stream::*;

pub trait Codec<Encoding>: Sized {
pub trait Codec<Encoding>: Sized + Send {
fn into_req(self, path: &str, accepts: &str) -> Result<HybridRequest, HybridError>;
async fn from_req(req: HybridRequest) -> Result<Self, HybridError>;
async fn into_res(self) -> Result<HybridResponse, HybridError>;
async fn from_res(res: HybridResponse) -> Result<Self, HybridError>;
fn from_req(req: HybridRequest) -> impl Future<Output = Result<Self, HybridError>> + Send;
fn into_res(self) -> impl Future<Output = Result<HybridResponse, HybridError>> + Send;
fn from_res(res: HybridResponse) -> impl Future<Output = Result<Self, HybridError>> + Send;
}

/// Defines a particular encoding format, which can be used for serializing or deserializing data.
Expand Down
11 changes: 11 additions & 0 deletions packages/fullstack/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use std::collections::HashMap;
use std::sync::atomic::AtomicU32;
use std::sync::Arc;

use crate::ContextProviders;

type SendSyncAnyMap = std::collections::HashMap<std::any::TypeId, ContextType>;

#[derive(EnumSetType)]
Expand Down Expand Up @@ -94,6 +96,15 @@ impl Default for DioxusServerContext {
}
}

impl DioxusServerContext {
pub(crate) fn add_server_context(&self, context_providers: &ContextProviders) {
for index in 0..context_providers.len() {
let context_providers = context_providers.clone();
self.insert_boxed_factory(Box::new(move || context_providers[index]()));
}
}
}

mod server_fn_impl {
use super::*;
use parking_lot::{MappedRwLockWriteGuard, RwLockReadGuard, RwLockWriteGuard};
Expand Down
24 changes: 12 additions & 12 deletions packages/fullstack/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ use crate::{FromServerFnError, ServerFnError};
// #[cfg(feature = "form-redirects")]
// use super::error::ServerFnUrlError;

use super::middleware::{BoxedService, Layer, Service};
use super::redirect::call_redirect_hook;
// use super::middleware::{BoxedService, Layer, Service};
// use super::redirect::call_redirect_hook;
// use super::response::{Res, TryRes};
// use super::response::{ClientRes, Res, TryRes};
use bytes::{BufMut, Bytes, BytesMut};
use dashmap::DashMap;
use futures::{pin_mut, SinkExt, Stream, StreamExt};
use http::Method;
// use dashmap::DashMap;
// use futures::{pin_mut, SinkExt, Stream, StreamExt};
// use http::Method;

// use super::server::Server;
use std::{
fmt::{Debug, Display},
future::Future,
marker::PhantomData,
ops::{Deref, DerefMut},
pin::Pin,
sync::{Arc, LazyLock},
// future::Future,
// marker::PhantomData,
// ops::{Deref, DerefMut},
// pin::Pin,
// sync::{Arc, LazyLock},
};

/// A trait for types that can be encoded into a bytes for a request body.
Expand Down Expand Up @@ -87,7 +87,7 @@ pub trait FormatType {
// Format: [tag: u8][content: Bytes]
// - Tag 0: Ok variant
// - Tag 1: Err variant
pub fn serialize_result(result: Result<Bytes, Bytes>) -> Bytes {
pub(crate) fn serialize_result(result: Result<Bytes, Bytes>) -> Bytes {
match result {
Ok(bytes) => {
let mut buf = BytesMut::with_capacity(1 + bytes.len());
Expand All @@ -105,7 +105,7 @@ pub fn serialize_result(result: Result<Bytes, Bytes>) -> Bytes {
}

// Deserializes a Bytes instance back into a Result<Bytes, Bytes>.
pub fn deserialize_result<E: FromServerFnError>(bytes: Bytes) -> Result<Bytes, Bytes> {
pub(crate) fn deserialize_result<E: FromServerFnError>(bytes: Bytes) -> Result<Bytes, Bytes> {
if bytes.is_empty() {
return Err(E::from_server_fn_error(ServerFnError::Deserialization(
"Data is empty".into(),
Expand Down
11 changes: 6 additions & 5 deletions packages/fullstack/src/launch.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! A launch function that creates an axum router for the LaunchBuilder

use crate::{
collect_raw_server_fns, render_handler, server::DioxusRouterExt, RenderHandleState, SSRState,
ServeConfig, ServeConfigBuilder,
render_handler, server::DioxusRouterExt, RenderHandleState, SSRState, ServeConfig,
ServeConfigBuilder,
};
use axum::{
body::Body,
Expand Down Expand Up @@ -147,12 +147,14 @@ async fn serve_server(
DevserverMsg::HotReload(hot_reload_msg) => {
if hot_reload_msg.for_build_id == Some(dioxus_cli_config::build_id()) {
if let Some(table) = hot_reload_msg.jump_table {
use crate::ServerFunction;

unsafe { dioxus_devtools::subsecond::apply_patch(table).unwrap() };

let mut new_router = axum::Router::new().serve_static_assets();
let new_cfg = ServeConfig::new().unwrap();

let server_fn_iter = collect_raw_server_fns();
let server_fn_iter = ServerFunction::collect_static();

// de-duplicate iteratively by preferring the most recent (first, since it's linked)
let mut server_fn_map: HashMap<_, _> = HashMap::new();
Expand All @@ -166,8 +168,7 @@ async fn serve_server(
fn_.path(),
fn_.method()
);
new_router = crate::register_server_fn_on_router(
fn_,
new_router = fn_.register_server_fn_on_router(
new_router,
new_cfg.context_providers.clone(),
);
Expand Down
6 changes: 4 additions & 2 deletions packages/fullstack/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#![doc = include_str!("../README.md")]
#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/79236386")]
#![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/79236386")]
#![warn(missing_docs)]
// #![warn(missing_docs)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![forbid(unexpected_cfgs)]

pub mod http_fn;
pub mod ws_fn;

pub mod fetch;
pub mod protocols;
pub use protocols::*;

pub mod websocket;
pub use websocket::*;
Expand Down Expand Up @@ -209,7 +211,7 @@ macro_rules! make_server_fn {
}

inventory::submit! {
AxumServerFn::new(
ServerFunction::new(
http::Method::GET,
"/thing",
|req| {
Expand Down
22 changes: 0 additions & 22 deletions packages/fullstack/src/old.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,28 +148,6 @@
// InputStreamError = Error,
// OutputStreamError = Error,

// /// The protocol that a server function uses to communicate with the client. This trait handles
// /// the server and client side of running a server function. It is implemented for the [`Http`] and
// /// [`Websocket`] protocols and can be used to implement custom protocols.
// pub trait Protocol<Input, Output> {
// /// The HTTP method used for requests.
// const METHOD: Method;

// /// Run the server function on the server. The implementation should handle deserializing the
// /// input, running the server function, and serializing the output.
// async fn run_server<F, Fut>(
// request: HybridRequest,
// server_fn: F,
// ) -> Result<HybridResponse, HybridError>
// where
// F: Fn(Input) -> Fut + Send,
// Fut: Future<Output = Result<Output, HybridError>>;

// /// Run the server function on the client. The implementation should handle serializing the
// /// input, sending the request, and deserializing the output.
// async fn run_client(path: &str, input: Input) -> Result<Output, HybridError>;
// }

// /// A client defines a pair of request/response types and the logic to send
// /// and receive them.
// ///
Expand Down
Loading