rename package to dioxus-fullstack
This commit is contained in:
1 parent
3c002913eb
commit
e6c540320e
41 files changed
+78
-73
No files matched your search
+7
-7
@@ -22,13 +22,13 @@ members = [
|
|||||||
"packages/rsx-rosetta",
|
"packages/rsx-rosetta",
|
||||||
"packages/signals",
|
"packages/signals",
|
||||||
"packages/hot-reload",
|
"packages/hot-reload",
|
||||||
"packages/server",
|
"packages/fullstack",
|
||||||
"packages/server/server-macro",
|
"packages/fullstack/server-macro",
|
||||||
"packages/server/examples/axum-hello-world",
|
"packages/fullstack/examples/axum-hello-world",
|
||||||
"packages/server/examples/axum-router",
|
"packages/fullstack/examples/axum-router",
|
||||||
"packages/server/examples/axum-desktop",
|
"packages/fullstack/examples/axum-desktop",
|
||||||
"packages/server/examples/salvo-hello-world",
|
"packages/fullstack/examples/salvo-hello-world",
|
||||||
"packages/server/examples/warp-hello-world",
|
"packages/fullstack/examples/warp-hello-world",
|
||||||
"docs/guide",
|
"docs/guide",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ dioxus-native-core-macro = { path = "../../packages/native-core-macro" }
|
|||||||
dioxus-router = { path = "../../packages/router" }
|
dioxus-router = { path = "../../packages/router" }
|
||||||
dioxus-liveview = { path = "../../packages/liveview", features = ["axum"] }
|
dioxus-liveview = { path = "../../packages/liveview", features = ["axum"] }
|
||||||
dioxus-tui = { path = "../../packages/dioxus-tui" }
|
dioxus-tui = { path = "../../packages/dioxus-tui" }
|
||||||
dioxus-server = { path = "../../packages/server" }
|
dioxus-fullstack = { path = "../../packages/fullstack" }
|
||||||
fermi = { path = "../../packages/fermi" }
|
fermi = { path = "../../packages/fermi" }
|
||||||
shipyard = "0.6.2"
|
shipyard = "0.6.2"
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ fn main() {
|
|||||||
dioxus_web::launch_cfg(app, dioxus_web::Config::new().hydrate(true));
|
dioxus_web::launch_cfg(app, dioxus_web::Config::new().hydrate(true));
|
||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
{
|
{
|
||||||
use dioxus_server::prelude::*;
|
use dioxus_fullstack::prelude::*;
|
||||||
tokio::runtime::Runtime::new()
|
tokio::runtime::Runtime::new()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.block_on(async move {
|
.block_on(async move {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use dioxus::prelude::*;
|
|||||||
async fn main() {
|
async fn main() {
|
||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
{
|
{
|
||||||
use dioxus_server::prelude::*;
|
use dioxus_fullstack::prelude::*;
|
||||||
|
|
||||||
let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 8080));
|
let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 8080));
|
||||||
axum::Server::bind(&addr)
|
axum::Server::bind(&addr)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#![allow(non_snake_case, unused)]
|
#![allow(non_snake_case, unused)]
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
use dioxus_server::prelude::*;
|
use dioxus_fullstack::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[cfg(feature = "web")]
|
#[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.
|
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
|
## 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:
|
Make sure you have Rust and Cargo installed, and then create a new project:
|
||||||
|
|
||||||
@@ -17,11 +17,11 @@ cargo new --bin demo
|
|||||||
cd demo
|
cd demo
|
||||||
```
|
```
|
||||||
|
|
||||||
Add `dioxus` and `dioxus-server` as dependencies:
|
Add `dioxus` and `dioxus-fullstack` as dependencies:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
cargo add dioxus
|
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
|
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]
|
[dependencies]
|
||||||
axum = "*"
|
axum = "*"
|
||||||
dioxus = { version = "*" }
|
dioxus = { version = "*" }
|
||||||
dioxus-server = { version = "*", features = ["axum", "ssr"] }
|
dioxus-fullstack = { version = "*", features = ["axum", "ssr"] }
|
||||||
tokio = { version = "*", features = ["full"] }
|
tokio = { version = "*", features = ["full"] }
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ First, modify your `Cargo.toml` to include two features, one for the server call
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
# Common dependancies
|
# Common dependancies
|
||||||
dioxus = { version = "*" }
|
dioxus = { version = "*" }
|
||||||
dioxus-server = { version = "*" }
|
dioxus-fullstack = { version = "*" }
|
||||||
|
|
||||||
# Web dependancies
|
# Web dependancies
|
||||||
dioxus-web = { version = "*", features=["hydrate"], optional = true }
|
dioxus-web = { version = "*", features=["hydrate"], optional = true }
|
||||||
@@ -70,7 +70,7 @@ tokio = { version = "1.27.0", features = ["full"], optional = true }
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
ssr = ["axum", "tokio", "dioxus-server/axum"]
|
ssr = ["axum", "tokio", "dioxus-fullstack/axum"]
|
||||||
web = ["dioxus-web"]
|
web = ["dioxus-web"]
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -112,4 +112,4 @@ Now, build your client-side bundle with `dioxus build --features web` and run yo
|
|||||||
|
|
||||||
## Conclusion
|
## 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]
|
[package]
|
||||||
name = "dioxus-server"
|
name = "dioxus-fullstack"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Fullstack Dioxus Utilities"
|
description = "Fullstack Dioxus Utilities"
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
# Dioxus Server
|
# Dioxus Fullstack
|
||||||
|
|
||||||
[![Crates.io][crates-badge]][crates-url]
|
[![Crates.io][crates-badge]][crates-url]
|
||||||
[![MIT licensed][mit-badge]][mit-url]
|
[![MIT licensed][mit-badge]][mit-url]
|
||||||
[![Build Status][actions-badge]][actions-url]
|
[![Build Status][actions-badge]][actions-url]
|
||||||
[![Discord chat][discord-badge]][discord-url]
|
[![Discord chat][discord-badge]][discord-url]
|
||||||
|
|
||||||
[crates-badge]: https://img.shields.io/crates/v/dioxus-server.svg
|
[crates-badge]: https://img.shields.io/crates/v/dioxus-fullstack.svg
|
||||||
[crates-url]: https://crates.io/crates/dioxus-server
|
[crates-url]: https://crates.io/crates/dioxus-fullstack
|
||||||
[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg
|
[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg
|
||||||
[mit-url]: https://github.com/dioxuslabs/dioxus/blob/master/LICENSE
|
[mit-url]: https://github.com/dioxuslabs/dioxus/blob/master/LICENSE
|
||||||
[actions-badge]: https://github.com/dioxuslabs/dioxus/actions/workflows/main.yml/badge.svg
|
[actions-badge]: https://github.com/dioxuslabs/dioxus/actions/workflows/main.yml/badge.svg
|
||||||
@@ -16,16 +16,17 @@
|
|||||||
|
|
||||||
[Website](https://dioxuslabs.com) |
|
[Website](https://dioxuslabs.com) |
|
||||||
[Guides](https://dioxuslabs.com/docs/0.3/guide/en/) |
|
[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)
|
[Chat](https://discord.gg/XgGxMSkvUM)
|
||||||
|
|
||||||
Fullstack utilities for the [`Dioxus`](https://dioxuslabs.com) framework.
|
Fullstack utilities for the [`Dioxus`](https://dioxuslabs.com) framework.
|
||||||
|
|
||||||
# Features
|
# 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.
|
- 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-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.
|
- [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).
|
- 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
|
# Example
|
||||||
|
|
||||||
@@ -34,11 +35,15 @@ Full stack Dioxus in under 50 lines of code
|
|||||||
```rust
|
```rust
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
use dioxus_server::prelude::*;
|
use dioxus_fullstack::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[cfg(feature = "web")]
|
#[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")]
|
#[cfg(feature = "ssr")]
|
||||||
{
|
{
|
||||||
GetMeaning::register().unwrap();
|
GetMeaning::register().unwrap();
|
||||||
@@ -85,7 +90,7 @@ async fn get_meaning(of: String) -> Result<Option<u32>, ServerFnError> {
|
|||||||
|
|
||||||
## Getting Started
|
## 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
|
## Contributing
|
||||||
|
|
||||||
File renamed without changes.
+3
-3
@@ -10,14 +10,14 @@ publish = false
|
|||||||
dioxus-desktop = { path = "../../../desktop", optional = true }
|
dioxus-desktop = { path = "../../../desktop", optional = true }
|
||||||
dioxus = { path = "../../../dioxus" }
|
dioxus = { path = "../../../dioxus" }
|
||||||
dioxus-router = { path = "../../../router" }
|
dioxus-router = { path = "../../../router" }
|
||||||
dioxus-server = { path = "../../" }
|
dioxus-fullstack = { path = "../../" }
|
||||||
axum = { version = "0.6.12", optional = true }
|
axum = { version = "0.6.12", optional = true }
|
||||||
tokio = { version = "1.27.0", features = ["full"], optional = true }
|
tokio = { version = "1.27.0", features = ["full"], optional = true }
|
||||||
serde = "1.0.159"
|
serde = "1.0.159"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
ssr = ["axum", "tokio", "dioxus-server/axum"]
|
ssr = ["axum", "tokio", "dioxus-fullstack/axum"]
|
||||||
desktop = ["dioxus-desktop"]
|
desktop = ["dioxus-desktop"]
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
@@ -27,5 +27,5 @@ required-features = ["desktop"]
|
|||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "server"
|
name = "server"
|
||||||
path = "src/server.rs"
|
path = "src/fullstack.rs"
|
||||||
required-features = ["ssr"]
|
required-features = ["ssr"]
|
||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
// ```
|
// ```
|
||||||
|
|
||||||
use axum_desktop::*;
|
use axum_desktop::*;
|
||||||
use dioxus_server::prelude::server_fn::set_server_url;
|
use dioxus_fullstack::prelude::server_fn::set_server_url;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Set the url of the server where server functions are hosted.
|
// Set the url of the server where server functions are hosted.
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
use dioxus_server::prelude::*;
|
use dioxus_fullstack::prelude::*;
|
||||||
|
|
||||||
pub fn app(cx: Scope) -> Element {
|
pub fn app(cx: Scope) -> Element {
|
||||||
let mut count = use_state(cx, || 0);
|
let mut count = use_state(cx, || 0);
|
||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
// ```
|
// ```
|
||||||
|
|
||||||
use axum_desktop::*;
|
use axum_desktop::*;
|
||||||
use dioxus_server::prelude::*;
|
use dioxus_fullstack::prelude::*;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
File renamed without changes.
+2
-2
@@ -9,7 +9,7 @@ publish = false
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
dioxus-web = { path = "../../../web", features=["hydrate"], optional = true }
|
dioxus-web = { path = "../../../web", features=["hydrate"], optional = true }
|
||||||
dioxus = { path = "../../../dioxus" }
|
dioxus = { path = "../../../dioxus" }
|
||||||
dioxus-server = { path = "../../" }
|
dioxus-fullstack = { path = "../../" }
|
||||||
axum = { version = "0.6.12", optional = true }
|
axum = { version = "0.6.12", optional = true }
|
||||||
tokio = { version = "1.27.0", features = ["full"], optional = true }
|
tokio = { version = "1.27.0", features = ["full"], optional = true }
|
||||||
serde = "1.0.159"
|
serde = "1.0.159"
|
||||||
@@ -17,5 +17,5 @@ execute = "0.2.12"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["web"]
|
default = ["web"]
|
||||||
ssr = ["axum", "tokio", "dioxus-server/axum"]
|
ssr = ["axum", "tokio", "dioxus-fullstack/axum"]
|
||||||
web = ["dioxus-web"]
|
web = ["dioxus-web"]
|
||||||
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
use dioxus_server::prelude::*;
|
use dioxus_fullstack::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
File renamed without changes.
+2
-2
@@ -10,7 +10,7 @@ publish = false
|
|||||||
dioxus-web = { path = "../../../web", features=["hydrate"], optional = true }
|
dioxus-web = { path = "../../../web", features=["hydrate"], optional = true }
|
||||||
dioxus = { path = "../../../dioxus" }
|
dioxus = { path = "../../../dioxus" }
|
||||||
dioxus-router = { path = "../../../router" }
|
dioxus-router = { path = "../../../router" }
|
||||||
dioxus-server = { path = "../../" }
|
dioxus-fullstack = { path = "../../" }
|
||||||
axum = { version = "0.6.12", optional = true }
|
axum = { version = "0.6.12", optional = true }
|
||||||
tokio = { version = "1.27.0", features = ["full"], optional = true }
|
tokio = { version = "1.27.0", features = ["full"], optional = true }
|
||||||
serde = "1.0.159"
|
serde = "1.0.159"
|
||||||
@@ -20,5 +20,5 @@ execute = "0.2.12"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["web"]
|
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"]
|
web = ["dioxus-web", "dioxus-router/web"]
|
||||||
+1
-1
@@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
use dioxus_fullstack::prelude::*;
|
||||||
use dioxus_router::*;
|
use dioxus_router::*;
|
||||||
use dioxus_server::prelude::*;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
File renamed without changes.
+2
-2
@@ -9,7 +9,7 @@ publish = false
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
dioxus-web = { path = "../../../web", features=["hydrate"], optional = true }
|
dioxus-web = { path = "../../../web", features=["hydrate"], optional = true }
|
||||||
dioxus = { path = "../../../dioxus" }
|
dioxus = { path = "../../../dioxus" }
|
||||||
dioxus-server = { path = "../../" }
|
dioxus-fullstack = { path = "../../" }
|
||||||
tokio = { version = "1.27.0", features = ["full"], optional = true }
|
tokio = { version = "1.27.0", features = ["full"], optional = true }
|
||||||
serde = "1.0.159"
|
serde = "1.0.159"
|
||||||
salvo = { version = "0.37.9", optional = true }
|
salvo = { version = "0.37.9", optional = true }
|
||||||
@@ -17,5 +17,5 @@ execute = "0.2.12"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["web"]
|
default = ["web"]
|
||||||
ssr = ["salvo", "tokio", "dioxus-server/salvo"]
|
ssr = ["salvo", "tokio", "dioxus-fullstack/salvo"]
|
||||||
web = ["dioxus-web"]
|
web = ["dioxus-web"]
|
||||||
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
use dioxus_server::prelude::*;
|
use dioxus_fullstack::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
File renamed without changes.
+2
-2
@@ -9,7 +9,7 @@ publish = false
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
dioxus-web = { path = "../../../web", features=["hydrate"], optional = true }
|
dioxus-web = { path = "../../../web", features=["hydrate"], optional = true }
|
||||||
dioxus = { path = "../../../dioxus" }
|
dioxus = { path = "../../../dioxus" }
|
||||||
dioxus-server = { path = "../../" }
|
dioxus-fullstack = { path = "../../" }
|
||||||
tokio = { version = "1.27.0", features = ["full"], optional = true }
|
tokio = { version = "1.27.0", features = ["full"], optional = true }
|
||||||
serde = "1.0.159"
|
serde = "1.0.159"
|
||||||
warp = { version = "0.3.3", optional = true }
|
warp = { version = "0.3.3", optional = true }
|
||||||
@@ -17,5 +17,5 @@ execute = "0.2.12"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["web"]
|
default = ["web"]
|
||||||
ssr = ["warp", "tokio", "dioxus-server/warp"]
|
ssr = ["warp", "tokio", "dioxus-fullstack/warp"]
|
||||||
web = ["dioxus-web"]
|
web = ["dioxus-web"]
|
||||||
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
use dioxus_server::prelude::*;
|
use dioxus_fullstack::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
File renamed without changes.
+7
-7
@@ -2,7 +2,7 @@ use proc_macro::TokenStream;
|
|||||||
use quote::ToTokens;
|
use quote::ToTokens;
|
||||||
use server_fn_macro::*;
|
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.
|
/// 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
|
/// 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"`.
|
/// 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
|
/// 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
|
/// 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.
|
/// server-side context into the server function.
|
||||||
///
|
///
|
||||||
/// ```ignore
|
/// ```ignore
|
||||||
/// # use dioxus_server::prelude::*; use serde::{Serialize, Deserialize};
|
/// # use dioxus_fullstack::prelude::*; use serde::{Serialize, Deserialize};
|
||||||
/// # #[derive(Serialize, Deserialize)]
|
/// # #[derive(Serialize, Deserialize)]
|
||||||
/// # pub struct Post { }
|
/// # pub struct Post { }
|
||||||
/// #[server(ReadPosts, "/api")]
|
/// #[server(ReadPosts, "/api")]
|
||||||
@@ -51,20 +51,20 @@ use server_fn_macro::*;
|
|||||||
/// They are serialized as an `application/x-www-form-urlencoded`
|
/// 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`
|
/// 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/).
|
/// 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
|
/// - **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-server/latest/dixous_server/prelude/struct.DioxusServerContext.html). This scope can be used to inject dependencies like the HTTP request
|
/// 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.
|
/// or response or other server-only dependencies, but it does *not* have access to reactive state that exists in the client.
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn server(args: proc_macro::TokenStream, s: TokenStream) -> TokenStream {
|
pub fn server(args: proc_macro::TokenStream, s: TokenStream) -> TokenStream {
|
||||||
let context = ServerContext {
|
let context = ServerContext {
|
||||||
ty: syn::parse_quote!(DioxusServerContext),
|
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(
|
match server_macro_impl(
|
||||||
args.into(),
|
args.into(),
|
||||||
s.into(),
|
s.into(),
|
||||||
Some(context),
|
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(),
|
Err(e) => e.to_compile_error().into(),
|
||||||
Ok(s) => s.to_token_stream().into(),
|
Ok(s) => s.to_token_stream().into(),
|
||||||
+5
-5
@@ -4,7 +4,7 @@
|
|||||||
//! ```rust
|
//! ```rust
|
||||||
//! #![allow(non_snake_case)]
|
//! #![allow(non_snake_case)]
|
||||||
//! use dioxus::prelude::*;
|
//! use dioxus::prelude::*;
|
||||||
//! use dioxus_server::prelude::*;
|
//! use dioxus_fullstack::prelude::*;
|
||||||
//!
|
//!
|
||||||
//! fn main() {
|
//! fn main() {
|
||||||
//! #[cfg(feature = "web")]
|
//! #[cfg(feature = "web")]
|
||||||
@@ -82,7 +82,7 @@ pub trait DioxusRouterExt<S> {
|
|||||||
/// # Example
|
/// # Example
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use dioxus::prelude::*;
|
/// use dioxus::prelude::*;
|
||||||
/// use dioxus_server::prelude::*;
|
/// use dioxus_fullstack::prelude::*;
|
||||||
///
|
///
|
||||||
/// #[tokio::main]
|
/// #[tokio::main]
|
||||||
/// async fn main() {
|
/// async fn main() {
|
||||||
@@ -117,7 +117,7 @@ pub trait DioxusRouterExt<S> {
|
|||||||
/// # Example
|
/// # Example
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use dioxus::prelude::*;
|
/// use dioxus::prelude::*;
|
||||||
/// use dioxus_server::prelude::*;
|
/// use dioxus_fullstack::prelude::*;
|
||||||
///
|
///
|
||||||
/// #[tokio::main]
|
/// #[tokio::main]
|
||||||
/// async fn main() {
|
/// async fn main() {
|
||||||
@@ -139,7 +139,7 @@ pub trait DioxusRouterExt<S> {
|
|||||||
/// # Example
|
/// # Example
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![allow(non_snake_case)]
|
/// #![allow(non_snake_case)]
|
||||||
/// use dioxus_server::prelude::*;
|
/// use dioxus_fullstack::prelude::*;
|
||||||
///
|
///
|
||||||
/// #[tokio::main]
|
/// #[tokio::main]
|
||||||
/// async fn main() {
|
/// async fn main() {
|
||||||
@@ -165,7 +165,7 @@ pub trait DioxusRouterExt<S> {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![allow(non_snake_case)]
|
/// #![allow(non_snake_case)]
|
||||||
/// use dioxus::prelude::*;
|
/// use dioxus::prelude::*;
|
||||||
/// use dioxus_server::prelude::*;
|
/// use dioxus_fullstack::prelude::*;
|
||||||
///
|
///
|
||||||
/// #[tokio::main]
|
/// #[tokio::main]
|
||||||
/// async fn main() {
|
/// async fn main() {
|
||||||
File renamed without changes.
+5
-5
@@ -4,7 +4,7 @@
|
|||||||
//! ```rust
|
//! ```rust
|
||||||
//! #![allow(non_snake_case)]
|
//! #![allow(non_snake_case)]
|
||||||
//! use dioxus::prelude::*;
|
//! use dioxus::prelude::*;
|
||||||
//! use dioxus_server::prelude::*;
|
//! use dioxus_fullstack::prelude::*;
|
||||||
//!
|
//!
|
||||||
//! fn main() {
|
//! fn main() {
|
||||||
//! #[cfg(feature = "web")]
|
//! #[cfg(feature = "web")]
|
||||||
@@ -74,7 +74,7 @@ pub trait DioxusRouterExt {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// use salvo::prelude::*;
|
/// use salvo::prelude::*;
|
||||||
/// use std::{net::TcpListener, sync::Arc};
|
/// use std::{net::TcpListener, sync::Arc};
|
||||||
/// use dioxus_server::prelude::*;
|
/// use dioxus_fullstack::prelude::*;
|
||||||
///
|
///
|
||||||
/// struct ServerFunctionHandler {
|
/// struct ServerFunctionHandler {
|
||||||
/// server_fn: ServerFunction,
|
/// server_fn: ServerFunction,
|
||||||
@@ -121,7 +121,7 @@ pub trait DioxusRouterExt {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// use salvo::prelude::*;
|
/// use salvo::prelude::*;
|
||||||
/// use std::{net::TcpListener, sync::Arc};
|
/// use std::{net::TcpListener, sync::Arc};
|
||||||
/// use dioxus_server::prelude::*;
|
/// use dioxus_fullstack::prelude::*;
|
||||||
///
|
///
|
||||||
/// #[tokio::main]
|
/// #[tokio::main]
|
||||||
/// async fn main() {
|
/// async fn main() {
|
||||||
@@ -141,7 +141,7 @@ pub trait DioxusRouterExt {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// use salvo::prelude::*;
|
/// use salvo::prelude::*;
|
||||||
/// use std::{net::TcpListener, sync::Arc};
|
/// use std::{net::TcpListener, sync::Arc};
|
||||||
/// use dioxus_server::prelude::*;
|
/// use dioxus_fullstack::prelude::*;
|
||||||
///
|
///
|
||||||
/// #[tokio::main]
|
/// #[tokio::main]
|
||||||
/// async fn main() {
|
/// async fn main() {
|
||||||
@@ -160,7 +160,7 @@ pub trait DioxusRouterExt {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![allow(non_snake_case)]
|
/// #![allow(non_snake_case)]
|
||||||
/// use dioxus::prelude::*;
|
/// use dioxus::prelude::*;
|
||||||
/// use dioxus_server::prelude::*;
|
/// use dioxus_fullstack::prelude::*;
|
||||||
/// use salvo::prelude::*;
|
/// use salvo::prelude::*;
|
||||||
/// use std::{net::TcpListener, sync::Arc};
|
/// use std::{net::TcpListener, sync::Arc};
|
||||||
///
|
///
|
||||||
+4
-4
@@ -4,7 +4,7 @@
|
|||||||
//! ```rust
|
//! ```rust
|
||||||
//! #![allow(non_snake_case)]
|
//! #![allow(non_snake_case)]
|
||||||
//! use dioxus::prelude::*;
|
//! use dioxus::prelude::*;
|
||||||
//! use dioxus_server::prelude::*;
|
//! use dioxus_fullstack::prelude::*;
|
||||||
//!
|
//!
|
||||||
//! fn main() {
|
//! fn main() {
|
||||||
//! #[cfg(feature = "web")]
|
//! #[cfg(feature = "web")]
|
||||||
@@ -118,7 +118,7 @@ where
|
|||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use dioxus_server::prelude::*;
|
/// use dioxus_fullstack::prelude::*;
|
||||||
///
|
///
|
||||||
/// #[tokio::main]
|
/// #[tokio::main]
|
||||||
/// async fn main() {
|
/// async fn main() {
|
||||||
@@ -148,7 +148,7 @@ pub fn register_server_fns(server_fn_route: &'static str) -> BoxedFilter<(impl R
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![allow(non_snake_case)]
|
/// #![allow(non_snake_case)]
|
||||||
/// use dioxus::prelude::*;
|
/// use dioxus::prelude::*;
|
||||||
/// use dioxus_server::prelude::*;
|
/// use dioxus_fullstack::prelude::*;
|
||||||
///
|
///
|
||||||
/// #[tokio::main]
|
/// #[tokio::main]
|
||||||
/// async fn main() {
|
/// async fn main() {
|
||||||
@@ -348,7 +348,7 @@ fn report_err<E: Error>(e: E) -> Box<dyn warp::Reply> {
|
|||||||
/// # Example
|
/// # Example
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![allow(non_snake_case)]
|
/// #![allow(non_snake_case)]
|
||||||
/// use dioxus_server::prelude::*;
|
/// use dioxus_fullstack::prelude::*;
|
||||||
///
|
///
|
||||||
/// #[tokio::main]
|
/// #[tokio::main]
|
||||||
/// async fn main() {
|
/// async fn main() {
|
||||||
File renamed without changes.
@@ -17,7 +17,7 @@ mod serve_config;
|
|||||||
mod server_context;
|
mod server_context;
|
||||||
mod server_fn;
|
mod server_fn;
|
||||||
|
|
||||||
/// A prelude of commonly used items in dioxus-server.
|
/// A prelude of commonly used items in dioxus-fullstack.
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
#[cfg(feature = "axum")]
|
#[cfg(feature = "axum")]
|
||||||
pub use crate::adapters::axum_adapter::*;
|
pub use crate::adapters::axum_adapter::*;
|
||||||
@@ -30,10 +30,10 @@ pub mod prelude {
|
|||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
pub use crate::render::SSRState;
|
pub use crate::render::SSRState;
|
||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
pub use crate::serve_config::{ ServeConfig, ServeConfigBuilder};
|
pub use crate::serve_config::{ServeConfig, ServeConfigBuilder};
|
||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
pub use crate::server_context::{RequestParts};
|
pub use crate::server_context::RequestParts;
|
||||||
pub use crate::server_context::{ DioxusServerContext, HasServerContext};
|
pub use crate::server_context::{DioxusServerContext, HasServerContext};
|
||||||
pub use crate::server_fn::ServerFn;
|
pub use crate::server_fn::ServerFn;
|
||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
pub use crate::server_fn::{ServerFnTraitObj, ServerFunction};
|
pub use crate::server_fn::{ServerFnTraitObj, ServerFunction};
|
||||||
+1
-1
@@ -14,7 +14,7 @@ pub(crate) fn serde_from_string<T: DeserializeOwned>(string: &str) -> Option<T>
|
|||||||
#[cfg(not(feature = "ssr"))]
|
#[cfg(not(feature = "ssr"))]
|
||||||
/// Get the props from the document. This is only available in the browser.
|
/// 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> {
|
pub fn get_root_props_from_document<T: DeserializeOwned>() -> Option<T> {
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
{
|
{
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user