codify "platform" into resolution logic, server-fn/fullstack overhaul (#4596)
overhaul dioxus fullstack using a new implementation of server_fn This PR is a complete rewrite of dioxus fullstack designed to improve compatibility with axum and to fix a number of compilation errors based on feature flag unification plumbing through macros.
This commit is contained in:
1 parent
8421c3aef0
commit
f2b1c6d97f
424 files changed
+17284
-6624
No files matched your search
@@ -0,0 +1,2 @@
|
||||
!README.md
|
||||
!.gitignore
|
||||
@@ -0,0 +1,65 @@
|
||||
# Test harnesses
|
||||
|
||||
This folder contains a series of CLI harnesses that represent common structures of dioxus apps.
|
||||
|
||||
We test these projects as a form of smoke testing to ensure our argument resolution works properly.
|
||||
|
||||
These projects might not be functionally useful, but they do have interesting properties that the CLI tests.
|
||||
|
||||
The tests for the CLI are contained within the CLI itself.
|
||||
|
||||
## This Folder
|
||||
|
||||
The items in this folder are procedurally generated by tests in the CLI crate. We will delete EVERYTHING that ends up here.
|
||||
|
||||
## How platform resolution works
|
||||
|
||||
Determine which features, triple, profile, etc to pass to the build.
|
||||
|
||||
Most of the time, users should use `dx serve --<platform>` where the platform name directly
|
||||
corresponds to the feature in their cargo.toml. So,
|
||||
- `dx serve --web` will enable the `web` feature
|
||||
- `dx serve --mobile` will enable the `mobile` feature
|
||||
- `dx serve --desktop` will enable the `desktop` feature
|
||||
|
||||
In this case, we set default-features to false and then add back the default features that
|
||||
aren't renderers, and then add the feature for the given renderer (ie web/desktop/mobile).
|
||||
We call this "no-default-features-stripped."
|
||||
|
||||
There are a few cases where the user doesn't need to pass a platform.
|
||||
- they selected one via `dioxus = { features = ["web"] }`
|
||||
- they have a single platform in their default features `default = ["web"]`
|
||||
- there is only a single non-server renderer as a feature `web = ["dioxus/web"], server = ["dioxus/server"]`
|
||||
- they compose the super triple via triple + bundleformat + features
|
||||
|
||||
Note that we only use the names of the features to correspond with the platform.
|
||||
Platforms are "super triples", meaning they contain information about
|
||||
- bundle format
|
||||
- target triple
|
||||
- how to serve
|
||||
- enabled features
|
||||
|
||||
By default, the --platform presets correspond to:
|
||||
- web: bundle(web), triple(wasm32), serve(http-serve), features("web")
|
||||
- desktop: alias to mac/win/linux
|
||||
- mac: bundle(mac), triple(host), serve(appbundle-open), features("desktop")
|
||||
- windows: bundle(exefolder), triple(host), serve(run-exe), features("desktop")
|
||||
- linux: bundle(appimage), triple(host), serve(run-exe), features("desktop")
|
||||
- ios: bundle(ios), triple(arm64-apple-ios), serve(ios-simulator/xcrun), features("mobile")
|
||||
- android: bundle(android), triple(arm64-apple-ios), serve(android-emulator/adb), features("mobile")
|
||||
- server: bundle(server), triple(host), serve(run-exe), features("server")
|
||||
- liveview: bundle(liveview), triple(host), serve(run-exe), features("liveview")
|
||||
- unknown: <auto or default to desktop>
|
||||
|
||||
Fullstack usage is inferred from the presence of the fullstack feature or --fullstack.
|
||||
|
||||
## List of harnesses (brainstorming)
|
||||
|
||||
- app that doesn't use dioxus
|
||||
- simple app where the renderer is used as an explicit feature
|
||||
- simple app, same as above, but with fullstack enabled
|
||||
- since no `server` feature is present, we don't run the server
|
||||
- simple app, same as above, but with a `server` feature
|
||||
- server should launch and take precedence over the client
|
||||
- simple server-only app
|
||||
- IE you're doing SSR with dioxus
|
||||
@@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "harness-default-to-non-default"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
dioxus = { workspace = true, features = [] }
|
||||
|
||||
|
||||
[features]
|
||||
default=["web"]
|
||||
web=["dioxus/web"]
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
use dioxus::prelude::*;
|
||||
fn main() {
|
||||
dioxus::launch(|| rsx! { "hello world!" })
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
[package]
|
||||
name = "harness-fullstack-desktop-with-default"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
dioxus = { workspace = true, features = ["fullstack"] }
|
||||
anyhow = { workspace = true, optional = true }
|
||||
|
||||
|
||||
[features]
|
||||
default=["desktop"]
|
||||
desktop=["dioxus/desktop", "has_anyhow"]
|
||||
has_anyhow=["dep:anyhow"]
|
||||
server=["dioxus/server"]
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
use dioxus::prelude::*;
|
||||
fn main() {
|
||||
dioxus::launch(|| rsx! { "hello world!" })
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "harness-fullstack-desktop-with-features"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
dioxus = { workspace = true, features = ["fullstack"] }
|
||||
anyhow = { workspace = true, optional = true }
|
||||
|
||||
|
||||
[features]
|
||||
desktop=["dioxus/desktop", "has_anyhow"]
|
||||
has_anyhow=["dep:anyhow"]
|
||||
server=["dioxus/server"]
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
use dioxus::prelude::*;
|
||||
fn main() {
|
||||
dioxus::launch(|| rsx! { "hello world!" })
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "harness-fullstack-desktop"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
dioxus = { workspace = true, features = ["fullstack"] }
|
||||
|
||||
|
||||
[features]
|
||||
desktop=["dioxus/desktop"]
|
||||
server=["dioxus/server"]
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
use dioxus::prelude::*;
|
||||
fn main() {
|
||||
dioxus::launch(|| rsx! { "hello world!" })
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "harness-fullstack-multi-target-no-default"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
dioxus = { workspace = true, features = ["fullstack"] }
|
||||
|
||||
|
||||
[features]
|
||||
web=["dioxus/web"]
|
||||
desktop=["dioxus/desktop"]
|
||||
mobile=["dioxus/mobile"]
|
||||
server=["dioxus/server"]
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
use dioxus::prelude::*;
|
||||
fn main() {
|
||||
dioxus::launch(|| rsx! { "hello world!" })
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
[package]
|
||||
name = "harness-fullstack-multi-target"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
dioxus = { workspace = true, features = ["fullstack"] }
|
||||
|
||||
|
||||
[features]
|
||||
default=["web", "desktop", "mobile", "server"]
|
||||
web=["dioxus/web"]
|
||||
desktop=["dioxus/desktop"]
|
||||
mobile=["dioxus/mobile"]
|
||||
server=["dioxus/server"]
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
use dioxus::prelude::*;
|
||||
fn main() {
|
||||
dioxus::launch(|| rsx! { "hello world!" })
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
[package]
|
||||
name = "harness-fullstack-with-optional-tokio"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
dioxus = { workspace = true, features = ["fullstack"] }
|
||||
serde = "1.0.219"
|
||||
tokio = { workspace = true, features = ["full"], optional = true }
|
||||
|
||||
|
||||
[features]
|
||||
default = []
|
||||
server = ["dioxus/server", "dep:tokio"]
|
||||
web = ["dioxus/web"]
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
use dioxus::prelude::*;
|
||||
fn main() {
|
||||
dioxus::launch(|| rsx! { "hello world!" })
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "harness-no-dioxus"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
anyhow = { workspace = true, optional = true }
|
||||
|
||||
|
||||
[features]
|
||||
web=["dep:anyhow"]
|
||||
server=[]
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "harness-renderer-swap"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
dioxus = { workspace = true, features = ["fullstack"] }
|
||||
|
||||
|
||||
[features]
|
||||
default=["desktop", "server"]
|
||||
desktop=["dioxus/desktop"]
|
||||
native=["dioxus/native"]
|
||||
server=["dioxus/server"]
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
use dioxus::prelude::*;
|
||||
fn main() {
|
||||
dioxus::launch(|| rsx! { "hello world!" })
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "harness-simple-dedicated-client"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
dioxus = { workspace = true, features = ["web"] }
|
||||
|
||||
|
||||
[features]
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "harness-simple-dedicated-server"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
|
||||
|
||||
[features]
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "harness-simple-desktop"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
dioxus = { workspace = true, features = ["desktop"] }
|
||||
|
||||
|
||||
[features]
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "harness-simple-fullstack-native-with-default"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
dioxus = { workspace = true, features = ["fullstack"] }
|
||||
|
||||
|
||||
[features]
|
||||
default=["native", "server"]
|
||||
native=["dioxus/native"]
|
||||
server=["dioxus/server"]
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
use dioxus::prelude::*;
|
||||
fn main() {
|
||||
dioxus::launch(|| rsx! { "hello world!" })
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "harness-simple-fullstack-with-default"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
dioxus = { workspace = true, features = ["fullstack"] }
|
||||
|
||||
|
||||
[features]
|
||||
default=["web", "server"]
|
||||
web=["dioxus/web"]
|
||||
server=["dioxus/server"]
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
use dioxus::prelude::*;
|
||||
fn main() {
|
||||
dioxus::launch(|| rsx! { "hello world!" })
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "harness-simple-fullstack"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
dioxus = { workspace = true, features = ["fullstack"] }
|
||||
|
||||
|
||||
[features]
|
||||
web=["dioxus/web"]
|
||||
server=["dioxus/server"]
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
use dioxus::prelude::*;
|
||||
fn main() {
|
||||
dioxus::launch(|| rsx! { "hello world!" })
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "harness-simple-mobile"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
dioxus = { workspace = true, features = ["mobile"] }
|
||||
|
||||
|
||||
[features]
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "harness-simple-web"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
dioxus = { workspace = true, features = ["web"] }
|
||||
|
||||
|
||||
[features]
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
Reference in new issue
Block a user