Skip to content

Commit

Permalink
Fix compilation errors with the latest version of dioxus
Browse files Browse the repository at this point in the history
  • Loading branch information
ealmloff committed Mar 18, 2024
1 parent 2657cd7 commit 75a8389
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 44 deletions.
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ members = [
]

[workspace.package]
version = "0.5.0-alpha.0"
version = "0.5.0-alpha.2"

[workspace.dependencies]
blitz = { path = "packages/blitz", version = "0.5.0-alpha.0" }
blitz-core = { path = "packages/blitz-core", version = "0.5.0-alpha.0" }
dioxus-tui = { path = "packages/dioxus-tui", version = "0.5.0-alpha.0" }
dioxus-native-core = { path = "packages/native-core", version = "0.5.0-alpha.0" }
dioxus-native-core-macro = { path = "packages/native-core-macro", version = "0.5.0-alpha.0" }
plasmo = { path = "packages/plasmo", version = "0.5.0-alpha.0" }
blitz = { path = "packages/blitz", version = "0.5.0-alpha.2" }
blitz-core = { path = "packages/blitz-core", version = "0.5.0-alpha.2" }
dioxus-tui = { path = "packages/dioxus-tui", version = "0.5.0-alpha.2" }
dioxus-native-core = { path = "packages/native-core", version = "0.5.0-alpha.2" }
dioxus-native-core-macro = { path = "packages/native-core-macro", version = "0.5.0-alpha.2" }
plasmo = { path = "packages/plasmo", version = "0.5.0-alpha.2" }

dioxus = { version = "0.5.0-alpha.0" }
dioxus-core = { version = "0.5.0-alpha.0" }
dioxus-hot-reload = { version = "0.5.0-alpha.0" }
dioxus-html = { version = "0.5.0-alpha.0" }
dioxus = { version = "0.5.0-alpha.2" }
dioxus-core = { version = "0.5.0-alpha.2" }
dioxus-hot-reload = { version = "0.5.0-alpha.2" }
dioxus-html = { version = "0.5.0-alpha.2" }

tracing = "0.1.37"
tracing-futures = "0.2.5"
Expand Down
6 changes: 3 additions & 3 deletions packages/blitz-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ repository = "https://github.com/DioxusLabs/blitz"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dioxus-native-core = { git = "https://github.com/DioxusLabs/dioxus/", features = [
dioxus-native-core = { workspace = true, features = [
"layout-attributes",
] }
dioxus-native-core-macro = { git = "https://github.com/DioxusLabs/dioxus/" }
dioxus-html = { git = "https://github.com/DioxusLabs/dioxus/" }
dioxus-native-core-macro = { workspace = true }
dioxus-html = { version = "0.5.0-alpha.2" }
taffy = "0.3.12"
tokio = { version = "1.25.0", features = ["full"] }
lightningcss = "1.0.0-alpha.39"
Expand Down
34 changes: 16 additions & 18 deletions packages/blitz-core/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ use tao::event::MouseButton;
use vello::kurbo::Point;

use dioxus_html::{
events::{FocusData, KeyboardData, MouseData, WheelData},
geometry::{euclid::Point2D, ClientPoint, Coordinates, ElementPoint, PagePoint, ScreenPoint},
input_data::{self, keyboard_types::Modifiers, MouseButtonSet},
geometry::{euclid::Point2D, ClientPoint, Coordinates, ElementPoint, PagePoint, ScreenPoint}, input_data::{self, keyboard_types::Modifiers, MouseButtonSet}, SerializedFocusData, SerializedKeyboardData, SerializedMouseData, SerializedWheelData
};
use dioxus_native_core::prelude::*;

Expand All @@ -40,17 +38,17 @@ struct CursorState {
}

impl CursorState {
fn get_event_mouse_data(&self) -> MouseData {
fn get_event_mouse_data(&self) -> SerializedMouseData {
// MouseData::new(coordinates, trigger_button, held_buttons, modifiers)
MouseData::new(
SerializedMouseData::new(
None,
self.buttons,
Coordinates::new(
self.position.screen(),
self.position.client(),
self.position.element(),
self.position.page(),
),
None,
self.buttons,
Modifiers::default(),
)
}
Expand Down Expand Up @@ -95,10 +93,10 @@ pub struct DomEvent {

#[derive(Debug, Clone, PartialEq)]
pub enum EventData {
Mouse(MouseData),
Keyboard(KeyboardData),
Focus(FocusData),
Wheel(WheelData),
Mouse(SerializedMouseData),
Keyboard(SerializedKeyboardData),
Focus(SerializedFocusData),
Wheel(SerializedWheelData),
}

impl EventData {
Expand Down Expand Up @@ -168,7 +166,7 @@ impl BlitzEventHandler {
let key = map_key(&event.logical_key);
let code = map_code(&event.physical_key);

let data = Arc::new(EventData::Keyboard(KeyboardData::new(
let data = Arc::new(EventData::Keyboard(SerializedKeyboardData::new(
key,
code,
match event.location {
Expand All @@ -187,7 +185,7 @@ impl BlitzEventHandler {
_ => todo!(),
},
event.repeat,
self.state.modifier_state,
self.state.modifier_state,true
)));

// keypress events are only triggered when a key that has text is pressed
Expand Down Expand Up @@ -259,10 +257,10 @@ impl BlitzEventHandler {
let position =
Coordinates::new(screen_point, client_point, element_point, page_point);

let data = MouseData::new(
Coordinates::new(screen_point, client_point, element_point, page_point),
let data = SerializedMouseData::new(
None,
self.state.cursor_state.buttons,
Coordinates::new(screen_point, client_point, element_point, page_point),
self.state.modifier_state,
);
match (hovered, self.state.cursor_state.hovered) {
Expand Down Expand Up @@ -356,15 +354,15 @@ impl BlitzEventHandler {

let pos = &self.state.cursor_state.position;

let data = Arc::new(EventData::Mouse(MouseData::new(
let data = Arc::new(EventData::Mouse(SerializedMouseData::new(
None,
self.state.cursor_state.buttons,
Coordinates::new(
pos.screen(),
pos.client(),
pos.element(),
pos.page(),
),
None,
self.state.cursor_state.buttons,
self.state.modifier_state,
)));

Expand Down
8 changes: 4 additions & 4 deletions packages/blitz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ repository = "https://github.com/DioxusLabs/blitz"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
dioxus = { git = "https://github.com/DioxusLabs/dioxus/" }
dioxus-native-core = { git = "https://github.com/DioxusLabs/dioxus/", features = [
dioxus = { version = "0.5.0-alpha.2" }
dioxus-native-core = { workspace = true, features = [
"dioxus",
] }
dioxus-html = { git = "https://github.com/DioxusLabs/dioxus/" }
dioxus-hot-reload = { git = "https://github.com/DioxusLabs/dioxus/" }
dioxus-html = { version = "0.5.0-alpha.2" }
dioxus-hot-reload = { version = "0.5.0-alpha.2" }
blitz-core = { path = "../blitz-core" }
tokio = { version = "1.26.0", features = ["full"] }
keyboard-types = "0.7.0"
Expand Down
11 changes: 5 additions & 6 deletions packages/blitz/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::ops::Deref;
use std::sync::Arc;

use dioxus::core::{Component, VirtualDom};
use dioxus::dioxus_core::{Component, VirtualDom};
use dioxus_native_core::prelude::*;

use blitz_core::EventData;
Expand All @@ -15,18 +15,17 @@ pub async fn launch_cfg(app: Component<()>, cfg: Config) {
launch_cfg_with_props(app, (), cfg).await
}

pub async fn launch_cfg_with_props<Props: 'static + Send>(
pub async fn launch_cfg_with_props<Props: 'static +Clone+ Send>(
app: Component<Props>,
props: Props,
cfg: Config,
) {
render(
move |rdom, _| {
let mut vdom = VirtualDom::new_with_props(app, props);
let muts = vdom.rebuild();
let mut rdom = rdom.write().unwrap();
let mut dioxus_state = DioxusState::create(&mut rdom);
dioxus_state.apply_mutations(&mut rdom, muts);
vdom.rebuild(&mut dioxus_state.create_mutation_writer(&mut rdom));
DioxusRenderer {
vdom,
dioxus_state,
Expand Down Expand Up @@ -56,8 +55,7 @@ struct DioxusRenderer {
impl Driver for DioxusRenderer {
fn update(&mut self, mut root: NodeMut<()>) {
let rdom = root.real_dom_mut();
let muts = self.vdom.render_immediate();
self.dioxus_state.apply_mutations(rdom, muts);
self.vdom.render_immediate(&mut self.dioxus_state.create_mutation_writer( rdom));
}

fn handle_event(
Expand Down Expand Up @@ -99,6 +97,7 @@ impl Driver for DioxusRenderer {
dioxus_hot_reload::HotReloadMsg::Shutdown => {
std::process::exit(0);
}
_ => {}
}
}
});
Expand Down
1 change: 1 addition & 0 deletions packages/dioxus-tui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ impl Driver for DioxusRenderer {
dioxus_hot_reload::HotReloadMsg::Shutdown => {
std::process::exit(0);
}
dioxus_hot_reload::HotReloadMsg::UpdateAsset(_) => {}
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions packages/plasmo/src/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl EventData {
pub struct FormData {
pub(crate) value: String,

pub values: HashMap<String, FormValue>,
pub values: HashMap<String, String>,

pub(crate) files: Option<Files>,
}
Expand All @@ -76,7 +76,7 @@ impl HasFormData for FormData {
self.value.clone()
}

fn values(&self) -> HashMap<String, FormValue> {
fn values(&self) -> HashMap<String, String> {
self.values.clone()
}

Expand Down

0 comments on commit 75a8389

Please sign in to comment.