Simplify the launch builder (#2967)

* improve documentation for the fullstack server context

* Add a section about axum integration to the crate root docs

* make serve_dioxus_application accept the cfg builder directly

* remove unused server_fn module

* improve fullstack config docs

* improve documentation for the server function macro

* fix axum router extension link

* Fix doc tests

* Fix launch builder

* Simplify the launch builder

* don't re-export launch in the prelude

* refactor fullstack launch

* Fix fullstack launch builder

* Update static generation with the new builder api

* fix some formatting/overly broad launch replacements

* fix custom menu example

* fix fullstack/static generation examples

* Fix static generation launch

* A few small formatting fixes

* Fix a few doc tests

* implement LaunchConfig for serve configs

* fix fullstack launch with separate web and server launch methods

* fix check with all features

* dont expose inner core module

* clippy and check

* fix readme

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
Evan AlmloffandJonathan Kelley authored and GitHub committed 2024-10-10 16:00:58 -07:00
1 parent 2d7bef44e8
commit 20d146d9bd
126 files changed
+618 -989

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@ use std::{collections::VecDeque, fmt::Debug, rc::Rc};
const STYLE: &str = asset!("./examples/assets/events.css");
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -11,7 +11,7 @@ use async_std::task::sleep;
use dioxus::prelude::*;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -15,7 +15,7 @@ use dioxus::prelude::*;
const STYLE: &str = asset!("./examples/assets/calculator.css");
fn main() {
LaunchBuilder::desktop()
dioxus::LaunchBuilder::desktop()
.with_cfg(desktop!({
use dioxus::desktop::{Config, LogicalSize, WindowBuilder};
Config::new().with_window(
+1 -1
View File
@@ -13,7 +13,7 @@ use dioxus::html::MouseEvent;
use dioxus::prelude::*;
fn main() {
LaunchBuilder::desktop()
dioxus::LaunchBuilder::desktop()
.with_cfg(
Config::new().with_window(
WindowBuilder::new()
+1 -1
View File
@@ -8,7 +8,7 @@ use web_time::Instant;
const STYLE: &str = asset!("./examples/assets/clock.css");
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -11,7 +11,7 @@ use dioxus::prelude::*;
const STYLE: &str = asset!("./examples/assets/roulette.css");
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -5,7 +5,7 @@ use dioxus::prelude::*;
const STYLE: &str = asset!("./examples/assets/counter.css");
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -12,7 +12,7 @@
use dioxus::prelude::*;
fn main() {
LaunchBuilder::new()
dioxus::LaunchBuilder::new()
.with_cfg(desktop!({
use dioxus::desktop::{LogicalSize, WindowBuilder};
dioxus::desktop::Config::default()
+1 -1
View File
@@ -14,7 +14,7 @@ static ASSET_PATH: &str = "examples/assets/logo.png";
static ASSET_PATH: &str = asset!("examples/assets/logo.png".format(ImageType::Avif));
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -4,7 +4,7 @@
use dioxus::prelude::*;
fn main() {
LaunchBuilder::new()
dioxus::LaunchBuilder::new()
.with_cfg(
dioxus::desktop::Config::new().with_custom_index(
r#"
+1 -1
View File
@@ -28,7 +28,7 @@ fn main() {
let config = dioxus::desktop::Config::new().with_menu(menu);
// Launch the app with the custom menu
LaunchBuilder::new().with_cfg(config).launch(app)
dioxus::LaunchBuilder::new().with_cfg(config).launch(app)
}
fn app() -> Element {
+1 -1
View File
@@ -5,7 +5,7 @@
use dioxus::prelude::*;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -11,7 +11,7 @@ use dioxus::prelude::*;
use std::collections::HashMap;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -10,7 +10,7 @@ use dioxus::prelude::*;
const STYLE: &str = asset!("./examples/assets/custom_assets.css");
fn main() {
launch_desktop(app);
dioxus::LaunchBuilder::desktop().launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -11,7 +11,7 @@
use dioxus::prelude::*;
fn main() {
launch(|| rsx! { Router::<Route> {} });
dioxus::launch(|| rsx! { Router::<Route> {} });
}
/// You can use an ErrorBoundary to catch errors in children and display a warning
+1 -1
View File
@@ -7,7 +7,7 @@ use async_std::task::sleep;
use dioxus::prelude::*;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -11,7 +11,7 @@ use dioxus::{html::HasFileData, prelude::dioxus_elements::FileEngine};
const STYLE: &str = asset!("./examples/assets/file_upload.css");
fn main() {
launch(app);
dioxus::launch(app);
}
struct UploadedFile {
+1 -1
View File
@@ -12,7 +12,7 @@ use dioxus::prelude::*;
const STYLE: &str = asset!("./examples/assets/flat_router.css");
fn main() {
launch(|| {
dioxus::launch(|| {
rsx! {
head::Link { rel: "stylesheet", href: STYLE }
Router::<Route> {}
+1 -1
View File
@@ -7,7 +7,7 @@ use dioxus::prelude::*;
use std::collections::HashMap;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -5,7 +5,7 @@ fn main() {
// Set the url of the server where server functions are hosted.
#[cfg(not(feature = "server"))]
dioxus::fullstack::prelude::server_fn::client::set_server_url("http://127.0.0.1:8080");
launch(app);
dioxus::launch(app);
}
pub fn app() -> Element {
+1 -1
View File
@@ -50,5 +50,5 @@ fn main() {
#[cfg(feature = "server")]
tracing_subscriber::fmt::init();
launch(app);
dioxus::launch(app);
}
+1 -1
View File
@@ -7,7 +7,7 @@
use dioxus::prelude::*;
fn main() {
LaunchBuilder::fullstack()
dioxus::LaunchBuilder::new()
.with_cfg(server_only!(ServeConfig::builder().incremental(
IncrementalRendererConfig::default()
.invalidate_after(std::time::Duration::from_secs(120)),
+1 -1
View File
@@ -37,5 +37,5 @@ pub async fn test_stream() -> Result<TextStream, ServerFnError> {
}
fn main() {
launch(app)
dioxus::launch(app)
}
+1 -1
View File
@@ -7,7 +7,7 @@ use async_std::task::sleep;
use dioxus::prelude::*;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -7,7 +7,7 @@ use dioxus::prelude::*;
use std::fmt::Display;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -13,7 +13,7 @@ static COUNT: GlobalSignal<i32> = Signal::global(|| 0);
static DOUBLED_COUNT: GlobalMemo<i32> = Memo::global(|| COUNT() * 2);
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -19,7 +19,7 @@ use dioxus::prelude::*;
use serde::{Deserialize, Serialize};
fn main() {
launch(|| {
dioxus::launch(|| {
rsx! {
Router::<Route> {}
}
+1 -1
View File
@@ -12,7 +12,7 @@
use dioxus::prelude::*;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -13,7 +13,7 @@ use dioxus::desktop::Config;
use dioxus::prelude::*;
fn main() {
LaunchBuilder::desktop()
dioxus::LaunchBuilder::desktop()
.with_cfg(Config::new().with_prerendered({
// We build the dom a first time, then pre-render it to HTML
let pre_rendered_dom = VirtualDom::prebuilt(app);
+1 -1
View File
@@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
use serde_json::{json, Error};
fn main() {
launch(app)
dioxus::launch(app)
}
fn app() -> Element {
+1 -1
View File
@@ -11,7 +11,7 @@ use dioxus::prelude::*;
const STYLE: &str = asset!("./examples/assets/links.css");
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -9,7 +9,7 @@
use dioxus::prelude::*;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -6,7 +6,7 @@
use dioxus::prelude::*;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -4,7 +4,7 @@ use dioxus::prelude::*;
fn main() {
tracing_subscriber::fmt::init();
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -50,7 +50,7 @@ pub fn main() -> Result<()> {
// Right now we're going through dioxus-desktop but we'd like to go through dioxus-mobile
// That will seed the index.html with some fixes that prevent the page from scrolling/zooming etc
LaunchBuilder::mobile()
dioxus::LaunchBuilder::mobile()
.with_cfg(
// Note that we have to disable the viewport goofiness of the browser.
// Dioxus_mobile should do this for us
+1 -1
View File
@@ -7,7 +7,7 @@
use dioxus::prelude::*;
fn main() {
launch_desktop(app);
dioxus::LaunchBuilder::desktop().launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -7,7 +7,7 @@
use dioxus::prelude::*;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -6,7 +6,7 @@
use dioxus::prelude::*;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+3 -1
View File
@@ -11,7 +11,9 @@ use dioxus::desktop::{
use dioxus::prelude::*;
fn main() {
LaunchBuilder::desktop().with_cfg(make_config()).launch(app);
dioxus::LaunchBuilder::desktop()
.with_cfg(make_config())
.launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -5,7 +5,7 @@ use dioxus::prelude::*;
use std::rc::Rc;
fn main() {
launch_desktop(app);
dioxus::LaunchBuilder::desktop().launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -5,7 +5,7 @@ fn main() {
wasm_logger::init(wasm_logger::Config::default());
console_error_panic_hook::set_once();
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -14,7 +14,7 @@
use dioxus::prelude::*;
fn main() {
launch(|| {
dioxus::launch(|| {
rsx! {
Router::<Route> {}
}
+1 -1
View File
@@ -9,7 +9,7 @@ use std::rc::Rc;
use dioxus::{html::geometry::euclid::Rect, prelude::*};
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -8,7 +8,7 @@
use dioxus::prelude::*;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -10,7 +10,7 @@ use dioxus::prelude::*;
const STYLE: &str = asset!("./examples/assets/radio.css");
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -8,7 +8,7 @@ use dioxus::prelude::*;
use dioxus_elements::geometry::euclid::Size2D;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -11,7 +11,7 @@ use dioxus::prelude::*;
const STYLE: &str = asset!("./examples/assets/router.css");
fn main() {
launch(|| {
dioxus::launch(|| {
rsx! {
head::Link { rel: "stylesheet", href: STYLE }
Router::<Route> {}
+1 -1
View File
@@ -15,7 +15,7 @@ enum Route {
}
fn main() {
launch(App);
dioxus::launch(App);
}
#[component]
+1 -1
View File
@@ -39,7 +39,7 @@
//! - Allow top-level fragments
fn main() {
launch(app)
dioxus::launch(app)
}
use core::{fmt, str::FromStr};
+1 -1
View File
@@ -8,7 +8,7 @@
use dioxus::prelude::*;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -9,7 +9,7 @@ use dioxus::desktop::use_global_shortcut;
use dioxus::prelude::*;
fn main() {
launch_desktop(app);
dioxus::LaunchBuilder::desktop().launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -3,7 +3,7 @@
use dioxus::prelude::*;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -10,7 +10,7 @@ use async_std::task::sleep;
use dioxus::prelude::*;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -5,7 +5,7 @@
use dioxus::prelude::*;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+2 -2
View File
@@ -3,9 +3,9 @@
use dioxus::prelude::*;
fn main() {
// Launch the router, using our `Route` component as the generic type
// launch the router, using our `Route` component as the generic type
// This will automatically boot the app to "/" unless otherwise specified
launch(|| rsx! { Router::<Route> {} });
dioxus::launch(|| rsx! { Router::<Route> {} });
}
/// By default, the Routable derive will use the name of the variant as the route
+1 -1
View File
@@ -6,7 +6,7 @@ use dioxus::prelude::*;
// Generate all routes and output them to the static path
fn main() {
LaunchBuilder::new()
dioxus::LaunchBuilder::new()
.with_cfg(dioxus::static_site_generation::Config::new().github_pages())
.launch(|| {
rsx! {
+1 -1
View File
@@ -5,7 +5,7 @@ use dioxus::prelude::*;
// Generate all routes and output them to the static path
fn main() {
launch(|| {
dioxus::launch(|| {
rsx! {
Router::<Route> {}
}
+1 -1
View File
@@ -3,7 +3,7 @@ use dioxus::prelude::*;
// Generate all routes and output them to the static path
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -5,7 +5,7 @@ use dioxus::prelude::*;
use futures_util::{future, stream, Stream, StreamExt};
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -15,7 +15,7 @@ use dioxus::desktop::{Config, LogicalSize, WindowBuilder};
use dioxus::prelude::*;
fn main() {
LaunchBuilder::new()
dioxus::LaunchBuilder::new()
.with_cfg(desktop! {
Config::new().with_window(
WindowBuilder::new()
+1 -1
View File
@@ -10,7 +10,7 @@ use dioxus::prelude::*;
use rand::{thread_rng, Rng};
fn main() {
launch(|| {
dioxus::launch(|| {
rsx! {
div { user_select: "none", webkit_user_select: "none", margin_left: "10%", margin_right: "10%",
h1 { "Click die to generate a new value" }
+1 -1
View File
@@ -5,7 +5,7 @@ use dioxus::prelude::*;
const _STYLE: &str = asset!("public/tailwind.css");
fn main() {
launch(app);
dioxus::launch(app);
}
pub fn app() -> Element {
+1 -1
View File
@@ -4,7 +4,7 @@ use dioxus::prelude::*;
fn main() {
tracing_subscriber::fmt::init();
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -6,7 +6,7 @@ use std::collections::HashMap;
const STYLE: &str = asset!("./examples/assets/todomvc.css");
fn main() {
launch(app);
dioxus::launch(app);
}
#[derive(PartialEq, Eq, Clone, Copy)]
+2 -2
View File
@@ -16,13 +16,13 @@ fn main() {
// For the sake of this example, we will download the video file if it doesn't exist
ensure_video_is_loaded();
launch_desktop(app);
dioxus::LaunchBuilder::desktop().launch(app);
}
fn app() -> Element {
// Any request to /videos will be handled by this handler
use_asset_handler("videos", move |request, responder| {
// Using dioxus::spawn works, but is slower than a dedicated thread
// Using spawn works, but is slower than a dedicated thread
tokio::task::spawn(async move {
let video_file = PathBuf::from(VIDEO_PATH);
let mut file = tokio::fs::File::open(&video_file).await.unwrap();
+1 -1
View File
@@ -4,7 +4,7 @@ use dioxus::prelude::*;
use serde::{Deserialize, Serialize};
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -7,7 +7,7 @@
use dioxus::prelude::*;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -13,7 +13,7 @@ use dioxus::desktop::{window, Config, WindowBuilder};
use dioxus::prelude::*;
fn main() {
LaunchBuilder::desktop()
dioxus::LaunchBuilder::desktop()
.with_cfg(
Config::new().with_window(
WindowBuilder::new()
+1 -1
View File
@@ -12,7 +12,7 @@ use dioxus::desktop::{Config, WindowCloseBehaviour};
use dioxus::prelude::*;
fn main() {
LaunchBuilder::desktop()
dioxus::LaunchBuilder::desktop()
.with_cfg(Config::new().with_close_behaviour(WindowCloseBehaviour::CloseWindow))
.launch(app)
}
+1 -1
View File
@@ -5,7 +5,7 @@
use dioxus::prelude::*;
fn main() {
launch_desktop(app);
dioxus::LaunchBuilder::desktop().launch(app);
}
fn app() -> Element {
+1 -1
View File
@@ -5,7 +5,7 @@
use dioxus::prelude::*;
fn main() {
launch(app);
dioxus::launch(app);
}
fn app() -> Element {