|
@@ -13,18 +13,61 @@ pub struct LaunchBuilder<P: AnyProps, Platform: PlatformBuilder<P> = CurrentPlat
|
|
platform_config: Option<<Platform as PlatformBuilder<P>>::Config>,
|
|
platform_config: Option<<Platform as PlatformBuilder<P>>::Config>,
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#[cfg(feature = "fullstack")]
|
|
|
|
+// Fullstack platform builder
|
|
|
|
+impl<
|
|
|
|
+ F: ComponentFunction<Props, M> + Send + Sync,
|
|
|
|
+ Props: Clone + Send + Sync + 'static,
|
|
|
|
+ M: Send + Sync + 'static,
|
|
|
|
+ > LaunchBuilder<VProps<F, Props, M>>
|
|
|
|
+{
|
|
|
|
+ /// 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: F) -> Self
|
|
|
|
+ where
|
|
|
|
+ Props: Default,
|
|
|
|
+ {
|
|
|
|
+ Self {
|
|
|
|
+ cross_platform_config: CrossPlatformConfig::new(VProps::new(
|
|
|
|
+ component,
|
|
|
|
+ |_, _| true,
|
|
|
|
+ Default::default(),
|
|
|
|
+ "root",
|
|
|
|
+ )),
|
|
|
|
+ platform_config: None,
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// Create a new builder for your application with some root props. This will create a launch configuration for the current platform based on the features enabled on the `dioxus` crate.
|
|
|
|
+ pub fn new_with_props(component: F, props: Props) -> Self {
|
|
|
|
+ Self {
|
|
|
|
+ cross_platform_config: CrossPlatformConfig::new(VProps::new(
|
|
|
|
+ component,
|
|
|
|
+ |_, _| true,
|
|
|
|
+ props,
|
|
|
|
+ "root",
|
|
|
|
+ )),
|
|
|
|
+ platform_config: None,
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#[cfg(not(feature = "fullstack"))]
|
|
// Default platform builder
|
|
// Default platform builder
|
|
-impl<F: ComponentFunction<Props, M>, Props: Clone + Default + 'static, M: 'static>
|
|
|
|
|
|
+impl<F: ComponentFunction<Props, M>, Props: Clone + 'static, M: 'static>
|
|
LaunchBuilder<VProps<F, Props, M>>
|
|
LaunchBuilder<VProps<F, Props, M>>
|
|
{
|
|
{
|
|
/// 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.
|
|
/// 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: F) -> Self {
|
|
|
|
|
|
+ pub fn new(component: F) -> Self
|
|
|
|
+ where
|
|
|
|
+ Props: Default,
|
|
|
|
+ {
|
|
Self {
|
|
Self {
|
|
- cross_platform_config: CrossPlatformConfig::new(
|
|
|
|
|
|
+ cross_platform_config: CrossPlatformConfig::new(VProps::new(
|
|
component,
|
|
component,
|
|
|
|
+ |_, _| true,
|
|
Default::default(),
|
|
Default::default(),
|
|
- Default::default(),
|
|
|
|
- ),
|
|
|
|
|
|
+ "root",
|
|
|
|
+ )),
|
|
platform_config: None,
|
|
platform_config: None,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -32,19 +75,24 @@ impl<F: ComponentFunction<Props, M>, Props: Clone + Default + 'static, M: 'stati
|
|
/// Create a new builder for your application with some root props. This will create a launch configuration for the current platform based on the features enabled on the `dioxus` crate.
|
|
/// Create a new builder for your application with some root props. This will create a launch configuration for the current platform based on the features enabled on the `dioxus` crate.
|
|
pub fn new_with_props(component: F, props: Props) -> Self {
|
|
pub fn new_with_props(component: F, props: Props) -> Self {
|
|
Self {
|
|
Self {
|
|
- cross_platform_config: CrossPlatformConfig::new(component, props, Default::default()),
|
|
|
|
|
|
+ cross_platform_config: CrossPlatformConfig::new(VProps::new(
|
|
|
|
+ component,
|
|
|
|
+ |_, _| true,
|
|
|
|
+ props,
|
|
|
|
+ "root",
|
|
|
|
+ )),
|
|
platform_config: None,
|
|
platform_config: None,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
impl<P: AnyProps, Platform: PlatformBuilder<P>> LaunchBuilder<P, Platform> {
|
|
impl<P: AnyProps, Platform: PlatformBuilder<P>> LaunchBuilder<P, Platform> {
|
|
- /// Inject state into the root component's context.
|
|
|
|
- pub fn context(mut self, state: impl Any + Clone + 'static) -> Self {
|
|
|
|
- self.cross_platform_config
|
|
|
|
- .push_context(BoxedContext::new(state));
|
|
|
|
- self
|
|
|
|
- }
|
|
|
|
|
|
+ // /// Inject state into the root component's context.
|
|
|
|
+ // pub fn context(mut self, state: impl Any + Clone + 'static) -> Self {
|
|
|
|
+ // self.cross_platform_config
|
|
|
|
+ // .push_context(BoxedContext::new(state));
|
|
|
|
+ // self
|
|
|
|
+ // }
|
|
|
|
|
|
/// Provide a platform-specific config to the builder.
|
|
/// Provide a platform-specific config to the builder.
|
|
pub fn cfg(
|
|
pub fn cfg(
|
|
@@ -89,13 +137,37 @@ impl<P: AnyProps> LaunchBuilder<P, dioxus_desktop::DesktopPlatform> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-#[cfg(feature = "desktop")]
|
|
|
|
|
|
+#[cfg(feature = "fullstack")]
|
|
|
|
+impl<P: AnyProps + Clone + Send + Sync> LaunchBuilder<P, dioxus_fullstack::FullstackPlatform> {
|
|
|
|
+ /// Launch your fullstack application.
|
|
|
|
+ pub fn launch_fullstack(self) {
|
|
|
|
+ dioxus_fullstack::FullstackPlatform::launch(
|
|
|
|
+ self.cross_platform_config,
|
|
|
|
+ self.platform_config.unwrap_or_default(),
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#[cfg(feature = "fullstack")]
|
|
|
|
+type CurrentPlatform = dioxus_fullstack::FullstackPlatform;
|
|
|
|
+#[cfg(all(feature = "desktop", not(feature = "fullstack")))]
|
|
type CurrentPlatform = dioxus_desktop::DesktopPlatform;
|
|
type CurrentPlatform = dioxus_desktop::DesktopPlatform;
|
|
-#[cfg(all(feature = "web", not(feature = "desktop")))]
|
|
|
|
|
|
+#[cfg(all(feature = "web", not(any(feature = "desktop", feature = "fullstack"))))]
|
|
type CurrentPlatform = dioxus_web::WebPlatform;
|
|
type CurrentPlatform = dioxus_web::WebPlatform;
|
|
-#[cfg(not(any(feature = "desktop", feature = "web")))]
|
|
|
|
|
|
+#[cfg(not(any(feature = "desktop", feature = "web", feature = "fullstack")))]
|
|
type CurrentPlatform = ();
|
|
type CurrentPlatform = ();
|
|
|
|
|
|
|
|
+#[cfg(feature = "fullstack")]
|
|
|
|
+/// Launch your application without any additional configuration. See [`LaunchBuilder`] for more options.
|
|
|
|
+pub fn launch<Props, Marker>(component: impl ComponentFunction<Props, Marker> + Send + Sync)
|
|
|
|
+where
|
|
|
|
+ Props: Default + Send + Sync + Clone + 'static,
|
|
|
|
+ Marker: Send + Sync + 'static,
|
|
|
|
+{
|
|
|
|
+ LaunchBuilder::new(component).launch()
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#[cfg(not(feature = "fullstack"))]
|
|
/// Launch your application without any additional configuration. See [`LaunchBuilder`] for more options.
|
|
/// Launch your application without any additional configuration. See [`LaunchBuilder`] for more options.
|
|
pub fn launch<Props, Marker: 'static>(component: impl ComponentFunction<Props, Marker>)
|
|
pub fn launch<Props, Marker: 'static>(component: impl ComponentFunction<Props, Marker>)
|
|
where
|
|
where
|
|
@@ -104,7 +176,7 @@ where
|
|
LaunchBuilder::new(component).launch()
|
|
LaunchBuilder::new(component).launch()
|
|
}
|
|
}
|
|
|
|
|
|
-#[cfg(feature = "web")]
|
|
|
|
|
|
+#[cfg(all(feature = "web", not(feature = "fullstack")))]
|
|
/// Launch your web application without any additional configuration. See [`LaunchBuilder`] for more options.
|
|
/// Launch your web application without any additional configuration. See [`LaunchBuilder`] for more options.
|
|
pub fn launch_web<Props, Marker: 'static>(component: impl ComponentFunction<Props, Marker>)
|
|
pub fn launch_web<Props, Marker: 'static>(component: impl ComponentFunction<Props, Marker>)
|
|
where
|
|
where
|
|
@@ -113,7 +185,7 @@ where
|
|
LaunchBuilder::new(component).launch_web()
|
|
LaunchBuilder::new(component).launch_web()
|
|
}
|
|
}
|
|
|
|
|
|
-#[cfg(feature = "desktop")]
|
|
|
|
|
|
+#[cfg(all(feature = "desktop", not(feature = "fullstack")))]
|
|
/// Launch your desktop application without any additional configuration. See [`LaunchBuilder`] for more options.
|
|
/// Launch your desktop application without any additional configuration. See [`LaunchBuilder`] for more options.
|
|
pub fn launch_desktop<Props, Marker: 'static>(component: impl ComponentFunction<Props, Marker>)
|
|
pub fn launch_desktop<Props, Marker: 'static>(component: impl ComponentFunction<Props, Marker>)
|
|
where
|
|
where
|
|
@@ -121,3 +193,14 @@ where
|
|
{
|
|
{
|
|
LaunchBuilder::new(component).launch_desktop()
|
|
LaunchBuilder::new(component).launch_desktop()
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+#[cfg(feature = "fullstack")]
|
|
|
|
+/// Launch your fullstack application without any additional configuration. See [`LaunchBuilder`] for more options.
|
|
|
|
+pub fn launch_fullstack<Props, Marker>(
|
|
|
|
+ component: impl ComponentFunction<Props, Marker> + Send + Sync,
|
|
|
|
+) where
|
|
|
|
+ Props: Default + Send + Sync + Clone + 'static,
|
|
|
|
+ Marker: Send + Sync + 'static,
|
|
|
|
+{
|
|
|
|
+ LaunchBuilder::new(component).launch_fullstack()
|
|
|
|
+}
|