rename package to dioxus-fullstack

This commit is contained in:
Evan Almloff committed 2023-05-02 10:15:34 -05:00
1 parent 3c002913eb
commit e6c540320e
41 files changed
+78 -73

No files matched your search

+7 -7
View File
@@ -22,13 +22,13 @@ members = [
"packages/rsx-rosetta",
"packages/signals",
"packages/hot-reload",
"packages/server",
"packages/server/server-macro",
"packages/server/examples/axum-hello-world",
"packages/server/examples/axum-router",
"packages/server/examples/axum-desktop",
"packages/server/examples/salvo-hello-world",
"packages/server/examples/warp-hello-world",
"packages/fullstack",
"packages/fullstack/server-macro",
"packages/fullstack/examples/axum-hello-world",
"packages/fullstack/examples/axum-router",
"packages/fullstack/examples/axum-desktop",
"packages/fullstack/examples/salvo-hello-world",
"packages/fullstack/examples/warp-hello-world",
"docs/guide",
]
+1 -1
View File
@@ -16,7 +16,7 @@ dioxus-native-core-macro = { path = "../../packages/native-core-macro" }
dioxus-router = { path = "../../packages/router" }
dioxus-liveview = { path = "../../packages/liveview", features = ["axum"] }
dioxus-tui = { path = "../../packages/dioxus-tui" }
dioxus-server = { path = "../../packages/server" }
dioxus-fullstack = { path = "../../packages/fullstack" }
fermi = { path = "../../packages/fermi" }
shipyard = "0.6.2"
+1 -1
View File
@@ -6,7 +6,7 @@ fn main() {
dioxus_web::launch_cfg(app, dioxus_web::Config::new().hydrate(true));
#[cfg(feature = "ssr")]
{
use dioxus_server::prelude::*;
use dioxus_fullstack::prelude::*;
tokio::runtime::Runtime::new()
.unwrap()
.block_on(async move {
+1 -1
View File
@@ -5,7 +5,7 @@ use dioxus::prelude::*;
async fn main() {
#[cfg(feature = "ssr")]
{
use dioxus_server::prelude::*;
use dioxus_fullstack::prelude::*;
let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 8080));
axum::Server::bind(&addr)
+1 -1
View File
@@ -1,6 +1,6 @@
#![allow(non_snake_case, unused)]
use dioxus::prelude::*;
use dioxus_server::prelude::*;
use dioxus_fullstack::prelude::*;
fn main() {
#[cfg(feature = "web")]
@@ -4,11 +4,11 @@
We can combine the `dioxus-web` renderer with the `dioxus-ssr` renderer to create a full-stack Dioxus application. By combining server-side rendering with client-side hydration we can create an application that is initially rendered on the server and then hydrates the application on the client. Server-side rendering results in a fast first paint and make our page SEO-friendly. Client-side hydration makes our page responsive once the application has fully loaded.
To help make full-stack development easier, Dioxus provides a `dioxus-server` crate that integrates with popular web frameworks with utilities for full-stack development.
To help make full-stack development easier, Dioxus provides a `dioxus-fullstack` crate that integrates with popular web frameworks with utilities for full-stack development.
## Setup
For this guide, we're going to show how to use Dioxus with [Axum](https://docs.rs/axum/latest/axum/), but `dioxus-server` also integrates with the [Warp](https://docs.rs/warp/latest/warp/) and [Salvo](https://docs.rs/salvo/latest/salvo/) web frameworks.
For this guide, we're going to show how to use Dioxus with [Axum](https://docs.rs/axum/latest/axum/), but `dioxus-fullstack` also integrates with the [Warp](https://docs.rs/warp/latest/warp/) and [Salvo](https://docs.rs/salvo/latest/salvo/) web frameworks.
Make sure you have Rust and Cargo installed, and then create a new project:
@@ -17,11 +17,11 @@ cargo new --bin demo
cd demo
```
Add `dioxus` and `dioxus-server` as dependencies:
Add `dioxus` and `dioxus-fullstack` as dependencies:
```shell
cargo add dioxus
cargo add dioxus-server --features axum, ssr
cargo add dioxus-fullstack --features axum, ssr
```
Next, add all the Axum dependencies. This will be different if you're using a different Web Framework
@@ -37,7 +37,7 @@ Your dependencies should look roughly like this:
[dependencies]
axum = "*"
dioxus = { version = "*" }
dioxus-server = { version = "*", features = ["axum", "ssr"] }
dioxus-fullstack = { version = "*", features = ["axum", "ssr"] }
tokio = { version = "*", features = ["full"] }
```
@@ -59,7 +59,7 @@ First, modify your `Cargo.toml` to include two features, one for the server call
[dependencies]
# Common dependancies
dioxus = { version = "*" }
dioxus-server = { version = "*" }
dioxus-fullstack = { version = "*" }
# Web dependancies
dioxus-web = { version = "*", features=["hydrate"], optional = true }
@@ -70,7 +70,7 @@ tokio = { version = "1.27.0", features = ["full"], optional = true }
[features]
default = []
ssr = ["axum", "tokio", "dioxus-server/axum"]
ssr = ["axum", "tokio", "dioxus-fullstack/axum"]
web = ["dioxus-web"]
```
@@ -112,4 +112,4 @@ Now, build your client-side bundle with `dioxus build --features web` and run yo
## Conclusion
That's it! You've created a full-stack Dioxus app. You can find more examples of full-stack apps and information about how to integrate with other frameworks and desktop renderers in the [dioxus-server examples directory](https://github.com/DioxusLabs/dioxus/tree/master/packages/server/examples).
That's it! You've created a full-stack Dioxus app. You can find more examples of full-stack apps and information about how to integrate with other frameworks and desktop renderers in the [dioxus-fullstack examples directory](https://github.com/DioxusLabs/dioxus/tree/master/packages/server/examples).
File renamed without changes.
@@ -1,5 +1,5 @@
[package]
name = "dioxus-server"
name = "dioxus-fullstack"
version = "0.1.0"
edition = "2021"
description = "Fullstack Dioxus Utilities"
@@ -1,12 +1,12 @@
# Dioxus Server
# Dioxus Fullstack
[![Crates.io][crates-badge]][crates-url]
[![MIT licensed][mit-badge]][mit-url]
[![Build Status][actions-badge]][actions-url]
[![Discord chat][discord-badge]][discord-url]
[crates-badge]: https://img.shields.io/crates/v/dioxus-server.svg
[crates-url]: https://crates.io/crates/dioxus-server
[crates-badge]: https://img.shields.io/crates/v/dioxus-fullstack.svg
[crates-url]: https://crates.io/crates/dioxus-fullstack
[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg
[mit-url]: https://github.com/dioxuslabs/dioxus/blob/master/LICENSE
[actions-badge]: https://github.com/dioxuslabs/dioxus/actions/workflows/main.yml/badge.svg
@@ -16,16 +16,17 @@
[Website](https://dioxuslabs.com) |
[Guides](https://dioxuslabs.com/docs/0.3/guide/en/) |
[API Docs](https://docs.rs/dioxus-server/latest/dioxus_sever) |
[API Docs](https://docs.rs/dioxus-fullstack/latest/dioxus_sever) |
[Chat](https://discord.gg/XgGxMSkvUM)
Fullstack utilities for the [`Dioxus`](https://dioxuslabs.com) framework.
# Features
- Intigrations with the [Axum](https::/docs.rs/dioxus-server/latest/dixous_server/axum_adapter/index.html), [Salvo](https::/docs.rs/dioxus-server/latest/dixous_server/salvo_adapter/index.html), and [Warp](https::/docs.rs/dioxus-server/latest/dixous_server/warp_adapter/index.html) server frameworks with utilities for serving and rendering Dioxus applications.
- [Server functions](https::/docs.rs/dioxus-server/latest/dixous_server/prelude/attr.server.html) allow you to call code on the server from the client as if it were a normal function.
- Intigrations with the [Axum](https::/docs.rs/dioxus-fullstack/latest/dixous_server/axum_adapter/index.html), [Salvo](https::/docs.rs/dioxus-fullstack/latest/dixous_server/salvo_adapter/index.html), and [Warp](https::/docs.rs/dioxus-fullstack/latest/dixous_server/warp_adapter/index.html) server frameworks with utilities for serving and rendering Dioxus applications.
- [Server functions](https::/docs.rs/dioxus-fullstack/latest/dixous_server/prelude/attr.server.html) allow you to call code on the server from the client as if it were a normal function.
- Instant RSX Hot reloading with [`dioxus-hot-reload`](https://crates.io/crates/dioxus-hot-reload).
- Passing root props from the server to the client.
# Example
@@ -34,11 +35,15 @@ Full stack Dioxus in under 50 lines of code
```rust
#![allow(non_snake_case)]
use dioxus::prelude::*;
use dioxus_server::prelude::*;
use dioxus_fullstack::prelude::*;
fn main() {
#[cfg(feature = "web")]
dioxus_web::launch_cfg(app, dioxus_web::Config::new().hydrate(true));
dioxus_web::launch_with_props(
app,
get_root_props_from_document().unwrap_or_default(),
dioxus_web::Config::new().hydrate(true),
);
#[cfg(feature = "ssr")]
{
GetMeaning::register().unwrap();
@@ -85,7 +90,7 @@ async fn get_meaning(of: String) -> Result<Option<u32>, ServerFnError> {
## Getting Started
To get started with full stack Dioxus, check out our [getting started guide](https://dioxuslabs.com/docs/nightly/guide/en/getting_started/ssr.html), or the [full stack examples](https://github.com/DioxusLabs/dioxus/tree/master/packages/server/examples).
To get started with full stack Dioxus, check out our [getting started guide](https://dioxuslabs.com/docs/nightly/guide/en/getting_started/ssr.html), or the [full stack examples](https://github.com/DioxusLabs/dioxus/tree/master/packages/fullstack/examples).
## Contributing
@@ -10,14 +10,14 @@ publish = false
dioxus-desktop = { path = "../../../desktop", optional = true }
dioxus = { path = "../../../dioxus" }
dioxus-router = { path = "../../../router" }
dioxus-server = { path = "../../" }
dioxus-fullstack = { path = "../../" }
axum = { version = "0.6.12", optional = true }
tokio = { version = "1.27.0", features = ["full"], optional = true }
serde = "1.0.159"
[features]
default = []
ssr = ["axum", "tokio", "dioxus-server/axum"]
ssr = ["axum", "tokio", "dioxus-fullstack/axum"]
desktop = ["dioxus-desktop"]
[[bin]]
@@ -27,5 +27,5 @@ required-features = ["desktop"]
[[bin]]
name = "server"
path = "src/server.rs"
path = "src/fullstack.rs"
required-features = ["ssr"]
@@ -4,7 +4,7 @@
// ```
use axum_desktop::*;
use dioxus_server::prelude::server_fn::set_server_url;
use dioxus_fullstack::prelude::server_fn::set_server_url;
fn main() {
// Set the url of the server where server functions are hosted.
@@ -1,6 +1,6 @@
#![allow(non_snake_case)]
use dioxus::prelude::*;
use dioxus_server::prelude::*;
use dioxus_fullstack::prelude::*;
pub fn app(cx: Scope) -> Element {
let mut count = use_state(cx, || 0);
@@ -4,7 +4,7 @@
// ```
use axum_desktop::*;
use dioxus_server::prelude::*;
use dioxus_fullstack::prelude::*;
#[tokio::main]
async fn main() {
@@ -9,7 +9,7 @@ publish = false
[dependencies]
dioxus-web = { path = "../../../web", features=["hydrate"], optional = true }
dioxus = { path = "../../../dioxus" }
dioxus-server = { path = "../../" }
dioxus-fullstack = { path = "../../" }
axum = { version = "0.6.12", optional = true }
tokio = { version = "1.27.0", features = ["full"], optional = true }
serde = "1.0.159"
@@ -17,5 +17,5 @@ execute = "0.2.12"
[features]
default = ["web"]
ssr = ["axum", "tokio", "dioxus-server/axum"]
ssr = ["axum", "tokio", "dioxus-fullstack/axum"]
web = ["dioxus-web"]
@@ -7,7 +7,7 @@
#![allow(non_snake_case)]
use dioxus::prelude::*;
use dioxus_server::prelude::*;
use dioxus_fullstack::prelude::*;
use serde::{Deserialize, Serialize};
fn main() {
@@ -10,7 +10,7 @@ publish = false
dioxus-web = { path = "../../../web", features=["hydrate"], optional = true }
dioxus = { path = "../../../dioxus" }
dioxus-router = { path = "../../../router" }
dioxus-server = { path = "../../" }
dioxus-fullstack = { path = "../../" }
axum = { version = "0.6.12", optional = true }
tokio = { version = "1.27.0", features = ["full"], optional = true }
serde = "1.0.159"
@@ -20,5 +20,5 @@ execute = "0.2.12"
[features]
default = ["web"]
ssr = ["axum", "tokio", "dioxus-server/axum", "tower-http", "http"]
ssr = ["axum", "tokio", "dioxus-fullstack/axum", "tower-http", "http"]
web = ["dioxus-web", "dioxus-router/web"]
@@ -7,8 +7,8 @@
#![allow(non_snake_case)]
use dioxus::prelude::*;
use dioxus_fullstack::prelude::*;
use dioxus_router::*;
use dioxus_server::prelude::*;
use serde::{Deserialize, Serialize};
fn main() {
@@ -9,7 +9,7 @@ publish = false
[dependencies]
dioxus-web = { path = "../../../web", features=["hydrate"], optional = true }
dioxus = { path = "../../../dioxus" }
dioxus-server = { path = "../../" }
dioxus-fullstack = { path = "../../" }
tokio = { version = "1.27.0", features = ["full"], optional = true }
serde = "1.0.159"
salvo = { version = "0.37.9", optional = true }
@@ -17,5 +17,5 @@ execute = "0.2.12"
[features]
default = ["web"]
ssr = ["salvo", "tokio", "dioxus-server/salvo"]
ssr = ["salvo", "tokio", "dioxus-fullstack/salvo"]
web = ["dioxus-web"]
@@ -7,7 +7,7 @@
#![allow(non_snake_case)]
use dioxus::prelude::*;
use dioxus_server::prelude::*;
use dioxus_fullstack::prelude::*;
use serde::{Deserialize, Serialize};
fn main() {
@@ -9,7 +9,7 @@ publish = false
[dependencies]
dioxus-web = { path = "../../../web", features=["hydrate"], optional = true }
dioxus = { path = "../../../dioxus" }
dioxus-server = { path = "../../" }
dioxus-fullstack = { path = "../../" }
tokio = { version = "1.27.0", features = ["full"], optional = true }
serde = "1.0.159"
warp = { version = "0.3.3", optional = true }
@@ -17,5 +17,5 @@ execute = "0.2.12"
[features]
default = ["web"]
ssr = ["warp", "tokio", "dioxus-server/warp"]
ssr = ["warp", "tokio", "dioxus-fullstack/warp"]
web = ["dioxus-web"]
@@ -7,7 +7,7 @@
#![allow(non_snake_case)]
use dioxus::prelude::*;
use dioxus_server::prelude::*;
use dioxus_fullstack::prelude::*;
use serde::{Deserialize, Serialize};
fn main() {
@@ -2,7 +2,7 @@ use proc_macro::TokenStream;
use quote::ToTokens;
use server_fn_macro::*;
/// Declares that a function is a [server function](dioxus_server). This means that
/// Declares that a function is a [server function](dioxus_fullstack). This means that
/// its body will only run on the server, i.e., when the `ssr` feature is enabled.
///
/// If you call a server function from the client (i.e., when the `csr` or `hydrate` features
@@ -20,12 +20,12 @@ use server_fn_macro::*;
/// using Get instead of Post methods, the encoding must be `"GetCbor"` or `"GetJson"`.
///
/// The server function itself can take any number of arguments, each of which should be serializable
/// and deserializable with `serde`. Optionally, its first argument can be a [DioxusServerContext](https::/docs.rs/dioxus-server/latest/dixous_server/prelude/struct.DioxusServerContext.html),
/// and deserializable with `serde`. Optionally, its first argument can be a [DioxusServerContext](https::/docs.rs/dioxus-fullstack/latest/dixous_server/prelude/struct.DioxusServerContext.html),
/// which will be injected *on the server side.* This can be used to inject the raw HTTP request or other
/// server-side context into the server function.
///
/// ```ignore
/// # use dioxus_server::prelude::*; use serde::{Serialize, Deserialize};
/// # use dioxus_fullstack::prelude::*; use serde::{Serialize, Deserialize};
/// # #[derive(Serialize, Deserialize)]
/// # pub struct Post { }
/// #[server(ReadPosts, "/api")]
@@ -51,20 +51,20 @@ use server_fn_macro::*;
/// They are serialized as an `application/x-www-form-urlencoded`
/// form data using [`serde_urlencoded`](https://docs.rs/serde_urlencoded/latest/serde_urlencoded/) or as `application/cbor`
/// using [`cbor`](https://docs.rs/cbor/latest/cbor/).
/// - **The [DioxusServerContext](https::/docs.rs/dioxus-server/latest/dixous_server/prelude/struct.DioxusServerContext.html) comes from the server.** Optionally, the first argument of a server function
/// can be a [DioxusServerContext](https::/docs.rs/dioxus-server/latest/dixous_server/prelude/struct.DioxusServerContext.html). This scope can be used to inject dependencies like the HTTP request
/// - **The [DioxusServerContext](https::/docs.rs/dioxus-fullstack/latest/dixous_server/prelude/struct.DioxusServerContext.html) comes from the server.** Optionally, the first argument of a server function
/// can be a [DioxusServerContext](https::/docs.rs/dioxus-fullstack/latest/dixous_server/prelude/struct.DioxusServerContext.html). This scope can be used to inject dependencies like the HTTP request
/// or response or other server-only dependencies, but it does *not* have access to reactive state that exists in the client.
#[proc_macro_attribute]
pub fn server(args: proc_macro::TokenStream, s: TokenStream) -> TokenStream {
let context = ServerContext {
ty: syn::parse_quote!(DioxusServerContext),
path: syn::parse_quote!(::dioxus_server::prelude::DioxusServerContext),
path: syn::parse_quote!(::dioxus_fullstack::prelude::DioxusServerContext),
};
match server_macro_impl(
args.into(),
s.into(),
Some(context),
Some(syn::parse_quote!(::dioxus_server::prelude::server_fn)),
Some(syn::parse_quote!(::dioxus_fullstack::prelude::server_fn)),
) {
Err(e) => e.to_compile_error().into(),
Ok(s) => s.to_token_stream().into(),
@@ -4,7 +4,7 @@
//! ```rust
//! #![allow(non_snake_case)]
//! use dioxus::prelude::*;
//! use dioxus_server::prelude::*;
//! use dioxus_fullstack::prelude::*;
//!
//! fn main() {
//! #[cfg(feature = "web")]
@@ -82,7 +82,7 @@ pub trait DioxusRouterExt<S> {
/// # Example
/// ```rust
/// use dioxus::prelude::*;
/// use dioxus_server::prelude::*;
/// use dioxus_fullstack::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
@@ -117,7 +117,7 @@ pub trait DioxusRouterExt<S> {
/// # Example
/// ```rust
/// use dioxus::prelude::*;
/// use dioxus_server::prelude::*;
/// use dioxus_fullstack::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
@@ -139,7 +139,7 @@ pub trait DioxusRouterExt<S> {
/// # Example
/// ```rust
/// #![allow(non_snake_case)]
/// use dioxus_server::prelude::*;
/// use dioxus_fullstack::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
@@ -165,7 +165,7 @@ pub trait DioxusRouterExt<S> {
/// ```rust
/// #![allow(non_snake_case)]
/// use dioxus::prelude::*;
/// use dioxus_server::prelude::*;
/// use dioxus_fullstack::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
File renamed without changes.
@@ -4,7 +4,7 @@
//! ```rust
//! #![allow(non_snake_case)]
//! use dioxus::prelude::*;
//! use dioxus_server::prelude::*;
//! use dioxus_fullstack::prelude::*;
//!
//! fn main() {
//! #[cfg(feature = "web")]
@@ -74,7 +74,7 @@ pub trait DioxusRouterExt {
/// ```rust
/// use salvo::prelude::*;
/// use std::{net::TcpListener, sync::Arc};
/// use dioxus_server::prelude::*;
/// use dioxus_fullstack::prelude::*;
///
/// struct ServerFunctionHandler {
/// server_fn: ServerFunction,
@@ -121,7 +121,7 @@ pub trait DioxusRouterExt {
/// ```rust
/// use salvo::prelude::*;
/// use std::{net::TcpListener, sync::Arc};
/// use dioxus_server::prelude::*;
/// use dioxus_fullstack::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
@@ -141,7 +141,7 @@ pub trait DioxusRouterExt {
/// ```rust
/// use salvo::prelude::*;
/// use std::{net::TcpListener, sync::Arc};
/// use dioxus_server::prelude::*;
/// use dioxus_fullstack::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
@@ -160,7 +160,7 @@ pub trait DioxusRouterExt {
/// ```rust
/// #![allow(non_snake_case)]
/// use dioxus::prelude::*;
/// use dioxus_server::prelude::*;
/// use dioxus_fullstack::prelude::*;
/// use salvo::prelude::*;
/// use std::{net::TcpListener, sync::Arc};
///
@@ -4,7 +4,7 @@
//! ```rust
//! #![allow(non_snake_case)]
//! use dioxus::prelude::*;
//! use dioxus_server::prelude::*;
//! use dioxus_fullstack::prelude::*;
//!
//! fn main() {
//! #[cfg(feature = "web")]
@@ -118,7 +118,7 @@ where
///
/// # Example
/// ```rust
/// use dioxus_server::prelude::*;
/// use dioxus_fullstack::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
@@ -148,7 +148,7 @@ pub fn register_server_fns(server_fn_route: &'static str) -> BoxedFilter<(impl R
/// ```rust
/// #![allow(non_snake_case)]
/// use dioxus::prelude::*;
/// use dioxus_server::prelude::*;
/// use dioxus_fullstack::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
@@ -348,7 +348,7 @@ fn report_err<E: Error>(e: E) -> Box<dyn warp::Reply> {
/// # Example
/// ```rust
/// #![allow(non_snake_case)]
/// use dioxus_server::prelude::*;
/// use dioxus_fullstack::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
File renamed without changes.
@@ -17,7 +17,7 @@ mod serve_config;
mod server_context;
mod server_fn;
/// A prelude of commonly used items in dioxus-server.
/// A prelude of commonly used items in dioxus-fullstack.
pub mod prelude {
#[cfg(feature = "axum")]
pub use crate::adapters::axum_adapter::*;
@@ -30,10 +30,10 @@ pub mod prelude {
#[cfg(feature = "ssr")]
pub use crate::render::SSRState;
#[cfg(feature = "ssr")]
pub use crate::serve_config::{ ServeConfig, ServeConfigBuilder};
pub use crate::serve_config::{ServeConfig, ServeConfigBuilder};
#[cfg(feature = "ssr")]
pub use crate::server_context::{RequestParts};
pub use crate::server_context::{ DioxusServerContext, HasServerContext};
pub use crate::server_context::RequestParts;
pub use crate::server_context::{DioxusServerContext, HasServerContext};
pub use crate::server_fn::ServerFn;
#[cfg(feature = "ssr")]
pub use crate::server_fn::{ServerFnTraitObj, ServerFunction};
@@ -14,7 +14,7 @@ pub(crate) fn serde_from_string<T: DeserializeOwned>(string: &str) -> Option<T>
#[cfg(not(feature = "ssr"))]
/// Get the props from the document. This is only available in the browser.
///
/// When dioxus-server renders the page, it will serialize the root props and put them in the document. This function gets them from the document.
/// When dioxus-fullstack renders the page, it will serialize the root props and put them in the document. This function gets them from the document.
pub fn get_root_props_from_document<T: DeserializeOwned>() -> Option<T> {
#[cfg(not(target_arch = "wasm32"))]
{
File renamed without changes.
File renamed without changes.
File renamed without changes.