Skip to content

Commit

Permalink
Make dioxus-native depend dioxus-core and dioxus-html rather than dioxus
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Dec 9, 2024
1 parent 16b5991 commit a342f2b
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 60 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ app_units = "0.7.5"

# DioxusLabs dependencies
dioxus = { version = "0.6" }
dioxus-ssr = { version = "0.6" }
dioxus-core = { version = "0.6" }
dioxus-html = { version = "0.6" }
dioxus-cli-config = { version = "0.6" }
dioxus-devtools = { version = "0.6" }
taffy = { version = "0.6", default-features = false, features = ["std", "flexbox", "grid", "block_layout", "content_size"] }
Expand Down
3 changes: 2 additions & 1 deletion packages/dioxus-native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ blitz-traits = { path = "../blitz-traits" }
blitz-shell = { path = "../blitz-shell" }

# DioxusLabs dependencies
dioxus = { workspace = true }
dioxus-core = { workspace = true }
dioxus-html = { workspace = true }
dioxus-cli-config = { workspace = true, optional = true }
dioxus-devtools = { workspace = true, optional = true }

Expand Down
7 changes: 2 additions & 5 deletions packages/dioxus-native/src/dioxus_document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ use blitz_dom::{
};

use blitz_traits::net::NetProvider;
use dioxus::{
dioxus_core::{ElementId, Event, VirtualDom},
html::{FormValue, PlatformEventData},
prelude::set_event_converter,
};
use dioxus_core::{ElementId, Event, VirtualDom};
use dioxus_html::{set_event_converter, FormValue, PlatformEventData};
use futures_util::{pin_mut, FutureExt};

use super::event_handler::{NativeClickData, NativeConverter, NativeFormData};
Expand Down
90 changes: 46 additions & 44 deletions packages/dioxus-native/src/event_handler.rs
Original file line number Diff line number Diff line change
@@ -1,49 +1,57 @@
use std::collections::HashMap;

use dioxus::{
html::{FormValue, HasFileData, HasFormData},
prelude::{HtmlEventConverter, PlatformEventData},
use dioxus_html::{
geometry::{ClientPoint, ElementPoint, PagePoint, ScreenPoint},
input_data::{MouseButton, MouseButtonSet},
point_interaction::{
InteractionElementOffset, InteractionLocation, ModifiersInteraction, PointerInteraction,
},
AnimationData, ClipboardData, CompositionData, DragData, FocusData, FormData, FormValue,
HasFileData, HasFormData, HasMouseData, HtmlEventConverter, ImageData, KeyboardData, MediaData,
MountedData, MouseData, PlatformEventData, PointerData, ResizeData, ScrollData, SelectionData,
ToggleData, TouchData, TransitionData, VisibleData, WheelData,
};
use keyboard_types::Modifiers;

use super::keyboard_event::BlitzKeyboardData;

#[derive(Clone)]
pub struct NativeClickData;

impl dioxus::html::point_interaction::InteractionLocation for NativeClickData {
fn client_coordinates(&self) -> dioxus::prelude::dioxus_elements::geometry::ClientPoint {
impl InteractionLocation for NativeClickData {
fn client_coordinates(&self) -> ClientPoint {
todo!()
}

fn screen_coordinates(&self) -> dioxus::prelude::dioxus_elements::geometry::ScreenPoint {
fn screen_coordinates(&self) -> ScreenPoint {
todo!()
}

fn page_coordinates(&self) -> dioxus::prelude::dioxus_elements::geometry::PagePoint {
fn page_coordinates(&self) -> PagePoint {
todo!()
}
}
impl dioxus::html::point_interaction::InteractionElementOffset for NativeClickData {
fn element_coordinates(&self) -> dioxus::prelude::dioxus_elements::geometry::ElementPoint {
impl InteractionElementOffset for NativeClickData {
fn element_coordinates(&self) -> ElementPoint {
todo!()
}
}
impl dioxus::html::point_interaction::ModifiersInteraction for NativeClickData {
fn modifiers(&self) -> dioxus::prelude::Modifiers {
impl ModifiersInteraction for NativeClickData {
fn modifiers(&self) -> Modifiers {
todo!()
}
}

impl dioxus::html::point_interaction::PointerInteraction for NativeClickData {
fn trigger_button(&self) -> Option<dioxus::prelude::dioxus_elements::input_data::MouseButton> {
impl PointerInteraction for NativeClickData {
fn trigger_button(&self) -> Option<MouseButton> {
todo!()
}

fn held_buttons(&self) -> dioxus::prelude::dioxus_elements::input_data::MouseButtonSet {
fn held_buttons(&self) -> MouseButtonSet {
todo!()
}
}
impl dioxus::html::HasMouseData for NativeClickData {
impl HasMouseData for NativeClickData {
fn as_any(&self) -> &dyn std::any::Any {
self as &dyn std::any::Any
}
Expand All @@ -52,92 +60,86 @@ impl dioxus::html::HasMouseData for NativeClickData {
pub struct NativeConverter {}

impl HtmlEventConverter for NativeConverter {
fn convert_animation_data(&self, _event: &PlatformEventData) -> dioxus::prelude::AnimationData {
fn convert_animation_data(&self, _event: &PlatformEventData) -> AnimationData {
todo!()
}

fn convert_clipboard_data(&self, _event: &PlatformEventData) -> dioxus::prelude::ClipboardData {
fn convert_clipboard_data(&self, _event: &PlatformEventData) -> ClipboardData {
todo!()
}

fn convert_composition_data(
&self,
_event: &PlatformEventData,
) -> dioxus::prelude::CompositionData {
fn convert_composition_data(&self, _event: &PlatformEventData) -> CompositionData {
todo!()
}

fn convert_drag_data(&self, _event: &PlatformEventData) -> dioxus::prelude::DragData {
fn convert_drag_data(&self, _event: &PlatformEventData) -> DragData {
todo!()
}

fn convert_focus_data(&self, _event: &PlatformEventData) -> dioxus::prelude::FocusData {
fn convert_focus_data(&self, _event: &PlatformEventData) -> FocusData {
todo!()
}

fn convert_form_data(&self, event: &PlatformEventData) -> dioxus::prelude::FormData {
fn convert_form_data(&self, event: &PlatformEventData) -> FormData {
let o = event.downcast::<NativeFormData>().unwrap().clone();
dioxus::prelude::FormData::from(o)
FormData::from(o)
}

fn convert_image_data(&self, _event: &PlatformEventData) -> dioxus::prelude::ImageData {
fn convert_image_data(&self, _event: &PlatformEventData) -> ImageData {
todo!()
}

fn convert_keyboard_data(&self, event: &PlatformEventData) -> dioxus::prelude::KeyboardData {
fn convert_keyboard_data(&self, event: &PlatformEventData) -> KeyboardData {
let data = event.downcast::<BlitzKeyboardData>().unwrap().clone();
dioxus::prelude::KeyboardData::from(data)
KeyboardData::from(data)
}

fn convert_media_data(&self, _event: &PlatformEventData) -> dioxus::prelude::MediaData {
fn convert_media_data(&self, _event: &PlatformEventData) -> MediaData {
todo!()
}

fn convert_mounted_data(&self, _event: &PlatformEventData) -> dioxus::prelude::MountedData {
fn convert_mounted_data(&self, _event: &PlatformEventData) -> MountedData {
todo!()
}

fn convert_mouse_data(&self, event: &PlatformEventData) -> dioxus::prelude::MouseData {
fn convert_mouse_data(&self, event: &PlatformEventData) -> MouseData {
let o = event.downcast::<NativeClickData>().unwrap().clone();
dioxus::prelude::MouseData::from(o)
MouseData::from(o)
}

fn convert_pointer_data(&self, _event: &PlatformEventData) -> dioxus::prelude::PointerData {
fn convert_pointer_data(&self, _event: &PlatformEventData) -> PointerData {
todo!()
}

fn convert_scroll_data(&self, _event: &PlatformEventData) -> dioxus::prelude::ScrollData {
fn convert_scroll_data(&self, _event: &PlatformEventData) -> ScrollData {
todo!()
}

fn convert_selection_data(&self, _event: &PlatformEventData) -> dioxus::prelude::SelectionData {
fn convert_selection_data(&self, _event: &PlatformEventData) -> SelectionData {
todo!()
}

fn convert_toggle_data(&self, _event: &PlatformEventData) -> dioxus::prelude::ToggleData {
fn convert_toggle_data(&self, _event: &PlatformEventData) -> ToggleData {
todo!()
}

fn convert_touch_data(&self, _event: &PlatformEventData) -> dioxus::prelude::TouchData {
fn convert_touch_data(&self, _event: &PlatformEventData) -> TouchData {
todo!()
}

fn convert_transition_data(
&self,
_event: &PlatformEventData,
) -> dioxus::prelude::TransitionData {
fn convert_transition_data(&self, _event: &PlatformEventData) -> TransitionData {
todo!()
}

fn convert_wheel_data(&self, _event: &PlatformEventData) -> dioxus::prelude::WheelData {
fn convert_wheel_data(&self, _event: &PlatformEventData) -> WheelData {
todo!()
}

fn convert_resize_data(&self, _event: &PlatformEventData) -> dioxus::prelude::ResizeData {
fn convert_resize_data(&self, _event: &PlatformEventData) -> ResizeData {
todo!()
}

fn convert_visible_data(&self, _event: &PlatformEventData) -> dioxus::prelude::VisibleData {
fn convert_visible_data(&self, _event: &PlatformEventData) -> VisibleData {
todo!()
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dioxus-native/src/keyboard_event.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::any::Any;

use dioxus::events::{HasKeyboardData, ModifiersInteraction};
use dioxus_html::{point_interaction::ModifiersInteraction, HasKeyboardData};
use keyboard_types::{Code, Key, Location, Modifiers};

use winit::event::KeyEvent as WinitKeyEvent;
Expand Down
6 changes: 1 addition & 5 deletions packages/dioxus-native/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@ use blitz_shell::{
create_default_event_loop, BlitzEvent, BlitzShellNetCallback, Config, WindowConfig,
};
use blitz_traits::net::SharedCallback;
use dioxus::prelude::{ComponentFunction, Element, VirtualDom};
use dioxus_core::{ComponentFunction, Element, VirtualDom};
use std::sync::Arc;

type NodeId = usize;

pub mod exports {
pub use dioxus;
}

/// Launch an interactive HTML/CSS renderer driven by the Dioxus virtualdom
pub fn launch(root: fn() -> Element) {
launch_cfg(root, Config::default())
Expand Down
5 changes: 2 additions & 3 deletions packages/dioxus-native/src/mutation_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use blitz_dom::{
node::{Attribute, NodeSpecificData},
ns, Document, ElementNodeData, NodeData, QualName, RestyleHint,
};
use dioxus::{
dioxus_core::{AttributeValue, ElementId, Template, WriteMutations},
prelude::{TemplateAttribute, TemplateNode},
use dioxus_core::{
AttributeValue, ElementId, Template, TemplateAttribute, TemplateNode, WriteMutations,
};
use rustc_hash::FxHashMap;
use std::collections::HashSet;
Expand Down

0 comments on commit a342f2b

Please sign in to comment.