Trim off 150 deps for examples

This commit is contained in:
Jonathan Kelley committed 2024-01-18 12:32:01 -08:00
1 parent c59a2fb829
commit 451a2b6cfc
20 files changed
+297 -641

No files matched your search

Generated
+154 -538
View File
File diff suppressed because it is too large. Load diff
+9 -3
View File
@@ -45,13 +45,13 @@ members = [
"examples/tailwind",
"examples/PWA-example",
"examples/query_segments_demo",
"examples/openid_connect_demo",
# "examples/openid_connect_demo",
# Playwright tests
"playwright-tests/liveview",
"playwright-tests/web",
"playwright-tests/fullstack",
]
exclude = ["examples/mobile_demo"]
exclude = ["examples/mobile_demo", "packages/fermi", "examples/openid_connect_demo",]
[workspace.package]
version = "0.4.3"
@@ -124,6 +124,9 @@ keywords = ["dom", "ui", "gui", "react", "wasm"]
rust-version = "1.60.0"
publish = false
[dependencies]
manganis = { workspace = true, optional = true}
[dev-dependencies]
dioxus = { workspace = true, features = ["desktop"] }
dioxus-desktop = { workspace = true, features = ["transparent"] }
@@ -144,7 +147,10 @@ reqwest = { version = "0.11.9", features = ["json"] }
env_logger = "0.10.0"
simple_logger = "4.0.0"
thiserror = { workspace = true }
manganis = { workspace = true }
tracing-subscriber = "0.3.17"
http-range = "0.1.5"
[features]
default = []
collect-assets = ["manganis"]
+1 -1
View File
@@ -15,7 +15,7 @@ fn main() {
.with_inner_size(LogicalSize::new(300.0, 525.0)),
);
LaunchBuilder::new(app).cfg(config).launch();
LaunchBuilder::desktop().cfg(config).launch(app);
}
fn app() -> Element {
+13 -9
View File
@@ -5,13 +5,16 @@ use dioxus::prelude::*;
use dioxus_desktop::Config;
fn main() {
LaunchBuilder::new(app).cfg(
Config::new().with_custom_head("<style>body { background-color: red; }</style>".into()),
);
LaunchBuilder::new()
.cfg(
Config::new().with_custom_head("<style>body { background-color: red; }</style>".into()),
)
.launch(app);
LaunchBuilder::new(app).cfg(
Config::new().with_custom_index(
r#"
LaunchBuilder::new()
.cfg(
Config::new().with_custom_index(
r#"
<!DOCTYPE html>
<html>
<head>
@@ -24,9 +27,10 @@ fn main() {
</body>
</html>
"#
.into(),
),
);
.into(),
),
)
.launch(app);
}
fn app() -> Element {
+2 -2
View File
@@ -12,9 +12,9 @@ use dioxus::prelude::*;
use dioxus_desktop::{Config, WindowBuilder};
fn main() {
LaunchBuilder::new(app)
LaunchBuilder::new()
.cfg(Config::new().with_window(WindowBuilder::new().with_resizable(true)))
.launch_desktop()
.launch(app)
}
const _STYLE: &str = manganis::mg!(file("./examples/assets/fileexplorer.css"));
+2 -2
View File
@@ -2,12 +2,12 @@ use dioxus::prelude::*;
use dioxus_desktop::Config;
fn main() {
LaunchBuilder::new(app)
LaunchBuilder::desktop()
.cfg(Config::new().with_file_drop_handler(|_w, e| {
println!("{e:?}");
true
}))
.launch_desktop()
.launch(app)
}
fn app() -> Element {
+13 -13
View File
@@ -5,19 +5,19 @@ use dioxus_router::prelude::*;
fn main() {
env_logger::init();
LaunchBuilder::new(|| {
rsx! {
Router::<Route> {}
}
})
.cfg(
Config::new().with_window(
WindowBuilder::new()
.with_inner_size(LogicalSize::new(600, 1000))
.with_resizable(false),
),
)
.launch_desktop()
LaunchBuilder::desktop()
.cfg(
Config::new().with_window(
WindowBuilder::new()
.with_inner_size(LogicalSize::new(600, 1000))
.with_resizable(false),
),
)
.launch(|| {
rsx! {
Router::<Route> {}
}
})
}
#[derive(Routable, Clone)]
+2 -2
View File
@@ -13,7 +13,7 @@ use dioxus::prelude::*;
use dioxus_desktop::Config;
fn main() {
LaunchBuilder::new(app)
LaunchBuilder::desktop()
.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);
@@ -21,7 +21,7 @@ fn main() {
// We then launch the app with the pre-rendered HTML
dioxus_ssr::pre_render(&pre_rendered_dom)
}))
.launch_desktop();
.launch(app)
}
fn app() -> Element {
+1 -1
View File
@@ -49,7 +49,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::new(app).cfg(
LaunchBuilder::new().cfg(
// Note that we have to disable the viewport goofiness of the browser.
// Dioxus_mobile should do this for us
Config::default().with_custom_index(include_str!("index.html").to_string()),
+1 -1
View File
@@ -2,7 +2,7 @@ use dioxus::prelude::*;
use dioxus_desktop::{tao::dpi::PhysicalPosition, LogicalSize, WindowBuilder};
fn main() {
LaunchBuilder::new(app).cfg(make_config());
LaunchBuilder::new().cfg(make_config());
}
fn app() -> Element {
+1 -1
View File
@@ -32,7 +32,7 @@ fn main() {
.with_inner_size(LogicalSize::new(320.0, 530.0)),
);
LaunchBuilder::new(app).cfg(cfg);
LaunchBuilder::new().cfg(cfg).launch(app);
}
const STYLE: &str = include_str!("./assets/calculator.css");
+1 -1
View File
@@ -4,7 +4,7 @@ use std::rc::Rc;
use dioxus::{html::geometry::euclid::Rect, prelude::*};
fn main() {
LaunchBuilder::new(app).cfg(
LaunchBuilder::new().cfg(
dioxus_desktop::Config::default().with_custom_head(
r#"
<style type="text/css">
+2 -2
View File
@@ -17,7 +17,7 @@ use dioxus::prelude::*;
use dioxus_desktop::{Config, LogicalSize, WindowBuilder};
fn main() {
LaunchBuilder::new(app)
LaunchBuilder::desktop()
.cfg(
Config::new().with_window(
WindowBuilder::new()
@@ -25,7 +25,7 @@ fn main() {
.with_inner_size(LogicalSize::new(600.0, 800.0)),
),
)
.launch_desktop()
.launch(app)
}
fn app() -> Element {
+2 -2
View File
@@ -2,7 +2,7 @@ use dioxus::prelude::*;
use dioxus_desktop::{window, Config, WindowBuilder};
fn main() {
LaunchBuilder::new(app)
LaunchBuilder::desktop()
.cfg(
Config::new().with_window(
WindowBuilder::new()
@@ -10,7 +10,7 @@ fn main() {
.with_decorations(false),
),
)
.launch_desktop()
.launch(app)
}
fn app() -> Element {
+2 -2
View File
@@ -5,9 +5,9 @@ use dioxus_desktop::use_wry_event_handler;
use dioxus_desktop::{Config, WindowCloseBehaviour};
fn main() {
LaunchBuilder::new(app)
LaunchBuilder::new()
.cfg(Config::new().with_close_behaviour(WindowCloseBehaviour::CloseWindow))
.launch_desktop()
.launch(app)
}
fn app() -> Element {
+1 -1
View File
@@ -66,7 +66,7 @@ pub fn launch_virtual_dom(virtual_dom: VirtualDom, desktop_config: Config) {
/// Launches the WebView and runs the event loop, with configuration and root props.
pub fn launch(
root: fn() -> Element,
contexts: Vec<Box<dyn Fn() -> Box<dyn Any> + Send>>,
contexts: Vec<Box<dyn Fn() -> Box<dyn Any>>>,
platform_config: Config,
) {
let mut virtual_dom = VirtualDom::new(root);
+2
View File
@@ -20,6 +20,7 @@ dioxus-rsx = { workspace = true, optional = true }
dioxus-signals = { workspace = true, optional = true }
dioxus-router = { workspace = true, optional = true }
dioxus-web = { workspace = true, optional = true }
dioxus-mobile = { workspace = true, optional = true }
dioxus-desktop = { workspace = true, optional = true }
dioxus-fullstack = { workspace = true, optional = true }
dioxus-liveview = { workspace = true, optional = true }
@@ -44,6 +45,7 @@ router = ["dioxus-router"]
# Platforms
fullstack = ["dioxus-fullstack", "dioxus-config-macro/fullstack", "serde"]
desktop = ["dioxus-desktop", "dioxus-fullstack?/desktop", "dioxus-config-macro/desktop"]
mobile = ["dioxus-mobile", "dioxus-fullstack?/desktop", "dioxus-config-macro/desktop"] # todo: use the mobile versions of these
web = ["dioxus-web", "dioxus-fullstack?/web", "dioxus-config-macro/web"]
ssr = ["dioxus-fullstack?/ssr", "dioxus-config-macro/ssr"]
liveview = ["dioxus-desktop", "dioxus-config-macro/liveview"]
+86 -59
View File
@@ -1,35 +1,96 @@
//! Launch helper macros for fullstack apps
#![allow(unused)]
use std::any::Any;
use crate::prelude::*;
use dioxus_core::AnyProps;
use dioxus_core::VProps;
use dioxus_core::{ AnyProps};
/// A builder for a fullstack app.
pub struct LaunchBuilder {
cross_platform_config: fn() -> Element,
#[cfg(feature = "fullstack")]
contexts: Vec<Box<dyn Fn() -> Box<dyn Any> + Send + Sync>>,
#[cfg(not(feature = "fullstack"))]
contexts: Vec<Box<dyn Fn() -> Box<dyn Any>>>,
platform_config: Option<current_platform::Config>,
pub struct LaunchBuilder<Cfg = ()> {
launch_fn: LaunchFn<Cfg>,
contexts: ContextList,
platform_config: Option<Cfg>,
}
// Fullstack platform builder
pub type LaunchFn<Cfg> = fn(fn() -> Element, ContextList, Cfg);
#[cfg(feature = "fullstack")]
type ContextList = Vec<Box<dyn Fn() -> Box<dyn Any> + Send + Sync>>;
#[cfg(not(feature = "fullstack"))]
type ContextList = Vec<Box<dyn Fn() -> Box<dyn Any>>>;
impl LaunchBuilder {
/// Create a new builder for your application. This will create a launch configuration for the current platform based on the features enabled on the `dioxus` crate.
pub fn new(component: fn() -> Element) -> Self {
Self {
cross_platform_config: component,
pub fn new() -> LaunchBuilder<current_platform::Config> {
LaunchBuilder {
launch_fn: current_platform::launch,
contexts: Vec::new(),
platform_config: None,
}
}
/// Launch your web application.
#[cfg(feature = "web")]
pub fn web() -> LaunchBuilder<dioxus_web::Config> {
LaunchBuilder {
launch_fn: dioxus_web::launch::launch,
contexts: Vec::new(),
platform_config: None,
}
}
/// Launch your desktop application.
#[cfg(feature = "desktop")]
pub fn desktop() -> LaunchBuilder<dioxus_desktop::Config> {
LaunchBuilder {
launch_fn: dioxus_desktop::launch::launch,
contexts: Vec::new(),
platform_config: None,
}
}
/// Launch your fullstack application.
#[cfg(feature = "fullstack")]
pub fn fullstack() -> LaunchBuilder<dioxus_fullstack::Config> {
LaunchBuilder {
launch_fn: dioxus_fullstack::launch::launch,
contexts: Vec::new(),
platform_config: None,
}
}
/// Launch your fullstack application.
#[cfg(feature = "mobile")]
pub fn mobile() -> LaunchBuilder<dioxus_mobile::Config> {
LaunchBuilder {
launch_fn: dioxus_mobile::launch::launch,
contexts: Vec::new(),
platform_config: None,
}
}
/// Provide a custom launch function for your application.
///
/// Useful for third party renderers to tap into the launch builder API without having to reimplement it.
pub fn custom<Cfg>(launch_fn: LaunchFn<Cfg>) -> LaunchBuilder<Cfg> {
LaunchBuilder {
launch_fn,
contexts: Vec::new(),
platform_config: None,
}
}
}
// Fullstack platform builder
impl<Cfg: Default> LaunchBuilder<Cfg> {
#[cfg(feature = "fullstack")]
/// Inject state into the root component's context that is created on the thread that the app is launched on.
pub fn context_provider(mut self, state: impl Fn() -> Box<dyn Any> + Send + Sync + 'static) -> Self {
pub fn context_provider(
mut self,
state: impl Fn() -> Box<dyn Any> + Send + Sync + 'static,
) -> Self {
self.contexts
.push(Box::new(state) as Box<dyn Fn() -> Box<dyn Any> + Send + Sync>);
self
@@ -60,51 +121,17 @@ impl LaunchBuilder {
}
/// Provide a platform-specific config to the builder.
pub fn cfg(mut self, config: impl Into<Option<current_platform::Config>>) -> Self {
pub fn cfg(mut self, config: impl Into<Option<Cfg>>) -> Self {
if let Some(config) = config.into() {
self.platform_config = Some(config);
}
self
}
#[cfg(feature = "web")]
/// Launch your web application.
pub fn launch_web(self) {
dioxus_web::launch::launch(
self.cross_platform_config,
Default::default(),
Default::default(),
);
}
/// Launch your desktop application.
#[cfg(feature = "desktop")]
pub fn launch_desktop(self) {
dioxus_desktop::launch::launch(
self.cross_platform_config,
Default::default(),
Default::default(),
);
}
/// Launch your fullstack application.
#[cfg(feature = "fullstack")]
pub fn launch_fullstack(self) {
dioxus_fullstack::launch::launch(
self.cross_platform_config,
Default::default(),
Default::default(),
);
}
#[allow(clippy::unit_arg)]
/// Launch the app.
pub fn launch(self) {
current_platform::launch(
self.cross_platform_config,
Default::default(),
self.platform_config.unwrap_or_default(),
);
pub fn launch(self, app: fn() -> Element) {
(self.launch_fn)(app, self.contexts, self.platform_config.unwrap_or_default());
}
}
@@ -120,31 +147,31 @@ mod current_platform {
#[cfg(not(any(feature = "desktop", feature = "web", feature = "fullstack")))]
pub fn launch(
root: fn() -> dioxus_core::Element,
contexts: Vec<Box<dyn Fn() -> Box<dyn std::any::Any> + Send + Sync>>,
contexts: super::ContextList,
platform_config: Config,
) {
}
}
/// Launch your application without any additional configuration. See [`LaunchBuilder`] for more options.
pub fn launch(component: fn() -> Element) {
LaunchBuilder::new(component).launch()
pub fn launch(app: fn() -> Element) {
LaunchBuilder::new().launch(app)
}
#[cfg(all(feature = "web", not(feature = "fullstack")))]
/// Launch your web application without any additional configuration. See [`LaunchBuilder`] for more options.
pub fn launch_web(component: fn() -> Element) {
LaunchBuilder::new(component).launch_web()
pub fn launch_web(app: fn() -> Element) {
LaunchBuilder::web().launch(app)
}
#[cfg(all(feature = "desktop", not(feature = "fullstack")))]
/// Launch your desktop application without any additional configuration. See [`LaunchBuilder`] for more options.
pub fn launch_desktop(component: fn() -> Element) {
LaunchBuilder::new(component).launch_desktop()
pub fn launch_desktop(app: fn() -> Element) {
LaunchBuilder::desktop().launch(app)
}
#[cfg(feature = "fullstack")]
/// Launch your fullstack application without any additional configuration. See [`LaunchBuilder`] for more options.
pub fn launch_fullstack(component: fn() -> Element) {
LaunchBuilder::new(component).launch_fullstack()
pub fn launch_fullstack(app: fn() -> Element) {
LaunchBuilder::fullstack().launch(app)
}
+1
View File
@@ -7,6 +7,7 @@ pub static COMMON_JS: &str = include_str!("./common.js");
#[cfg(feature = "sledgehammer")]
mod sledgehammer_bindings;
#[cfg(feature = "sledgehammer")]
pub use sledgehammer_bindings::*;
@@ -321,7 +321,7 @@ pub mod binary_protocol {
}
node.setAttribute('data-dioxus-id', `\${id}`);
const event_name = $event$;
// if this is a mounted listener, we send the event immediately
if (event_name === "mounted") {
window.ipc.postMessage(