From d3ded8c677b25237aee8d4951c6da347684c4266 Mon Sep 17 00:00:00 2001 From: Ege Gungordu Date: Tue, 23 Jan 2024 18:31:14 +0300 Subject: [PATCH 1/8] add isComposing support of KeyboardEvent --- packages/html/src/events/keyboard.rs | 18 ++++++++++++++++++ packages/html/src/web_sys_bind/events.rs | 4 ++++ packages/interpreter/src/interpreter.js | 2 ++ packages/rink/src/hooks.rs | 2 ++ 4 files changed, 26 insertions(+) diff --git a/packages/html/src/events/keyboard.rs b/packages/html/src/events/keyboard.rs index feb0ab313..1dac40d1c 100644 --- a/packages/html/src/events/keyboard.rs +++ b/packages/html/src/events/keyboard.rs @@ -33,6 +33,7 @@ impl std::fmt::Debug for KeyboardData { .field("modifiers", &self.modifiers()) .field("location", &self.location()) .field("is_auto_repeating", &self.is_auto_repeating()) + .field("is_composing", &self.is_composing()) .finish() } } @@ -44,6 +45,7 @@ impl PartialEq for KeyboardData { && self.modifiers() == other.modifiers() && self.location() == other.location() && self.is_auto_repeating() == other.is_auto_repeating() + && self.is_composing() == other.is_composing() } } @@ -75,6 +77,11 @@ impl KeyboardData { self.inner.is_auto_repeating() } + /// Indicates whether the key is fired within a composition session. + pub fn is_composing(&self) -> bool { + self.inner.is_composing() + } + /// Downcast this KeyboardData to a concrete type. pub fn downcast(&self) -> Option<&T> { self.inner.as_any().downcast_ref::() @@ -92,6 +99,7 @@ impl ModifiersInteraction for KeyboardData { #[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Clone)] pub struct SerializedKeyboardData { char_code: u32, + is_composing: bool, key: String, key_code: KeyCode, #[serde(deserialize_with = "resilient_deserialize_code")] @@ -114,9 +122,11 @@ impl SerializedKeyboardData { location: Location, is_auto_repeating: bool, modifiers: Modifiers, + is_composing: bool, ) -> Self { Self { char_code: key.legacy_charcode(), + is_composing, key: key.to_string(), key_code: KeyCode::from_raw_code( std::convert::TryInto::try_into(key.legacy_keycode()) @@ -144,6 +154,7 @@ impl From<&KeyboardData> for SerializedKeyboardData { data.location(), data.is_auto_repeating(), data.modifiers(), + data.is_composing(), ) } } @@ -166,6 +177,10 @@ impl HasKeyboardData for SerializedKeyboardData { self.repeat } + fn is_composing(&self) -> bool { + self.is_composing + } + fn as_any(&self) -> &dyn std::any::Any { self } @@ -236,6 +251,9 @@ pub trait HasKeyboardData: ModifiersInteraction + std::any::Any { /// `true` iff the key is being held down such that it is automatically repeating. fn is_auto_repeating(&self) -> bool; + /// Indicates whether the key is fired within a composition session. + fn is_composing(&self) -> bool; + /// return self as Any fn as_any(&self) -> &dyn std::any::Any; } diff --git a/packages/html/src/web_sys_bind/events.rs b/packages/html/src/web_sys_bind/events.rs index 40d14f28b..f5fb84760 100644 --- a/packages/html/src/web_sys_bind/events.rs +++ b/packages/html/src/web_sys_bind/events.rs @@ -78,6 +78,10 @@ impl HasKeyboardData for KeyboardEvent { self.repeat() } + fn is_composing(&self) -> bool { + self.is_composing() + } + fn as_any(&self) -> &dyn std::any::Any { self } diff --git a/packages/interpreter/src/interpreter.js b/packages/interpreter/src/interpreter.js index c8384a8b7..0e9800645 100644 --- a/packages/interpreter/src/interpreter.js +++ b/packages/interpreter/src/interpreter.js @@ -351,6 +351,7 @@ async function serialize_event(event) { case "keyup": { let { charCode, + isComposing, key, altKey, ctrlKey, @@ -364,6 +365,7 @@ async function serialize_event(event) { } = event; return { char_code: charCode, + is_composing: isComposing, key: key, alt_key: altKey, ctrl_key: ctrlKey, diff --git a/packages/rink/src/hooks.rs b/packages/rink/src/hooks.rs index d519273f0..81f6558b6 100644 --- a/packages/rink/src/hooks.rs +++ b/packages/rink/src/hooks.rs @@ -179,6 +179,7 @@ impl InnerInputState { k.location(), is_repeating, k.modifiers(), + k.is_composing(), ); } @@ -779,6 +780,7 @@ fn translate_key_event(event: crossterm::event::KeyEvent) -> Option { Location::Standard, false, modifiers, + false, ))) } From 8887d674ed9ff04b4196dc7d93f4ec16abf2b432 Mon Sep 17 00:00:00 2001 From: Ege Gungordu Date: Tue, 23 Jan 2024 18:33:28 +0300 Subject: [PATCH 2/8] add is_composing check to desktop headless tests --- packages/desktop/headless_tests/events.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/desktop/headless_tests/events.rs b/packages/desktop/headless_tests/events.rs index 69f743a1a..9f6f9fea7 100644 --- a/packages/desktop/headless_tests/events.rs +++ b/packages/desktop/headless_tests/events.rs @@ -154,7 +154,7 @@ fn app(cx: Scope) -> Element { ctrlKey: false, metaKey: false, shiftKey: false, - isComposing: false, + isComposing: true, which: 65, bubbles: true, })"#, @@ -356,6 +356,7 @@ fn app(cx: Scope) -> Element { assert_eq!(event.data.code().to_string(), "KeyA"); assert_eq!(event.data.location(), Location::Standard); assert!(event.data.is_auto_repeating()); + assert!(event.data.is_composing()); received_events.modify(|x| *x + 1) } } @@ -368,6 +369,7 @@ fn app(cx: Scope) -> Element { assert_eq!(event.data.code().to_string(), "KeyA"); assert_eq!(event.data.location(), Location::Standard); assert!(!event.data.is_auto_repeating()); + assert!(!event.data.is_composing()); received_events.modify(|x| *x + 1) } } @@ -380,6 +382,7 @@ fn app(cx: Scope) -> Element { assert_eq!(event.data.code().to_string(), "KeyA"); assert_eq!(event.data.location(), Location::Standard); assert!(!event.data.is_auto_repeating()); + assert!(!event.data.is_composing()); received_events.modify(|x| *x + 1) } } From 47d15fc8a1675af0044352aae1e08ba32a096325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20S=C3=B6derstr=C3=B6m?= Date: Thu, 25 Jan 2024 21:28:39 +0100 Subject: [PATCH 3/8] fix: initialize linux wry webview In the wry 0.32 examples the linux webviews are initialized in a different way to render properly using tao::platform::unix::WindowExtUnix. Tested with Gnome 45.3 and Wayland. --- packages/desktop/src/webview.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/desktop/src/webview.rs b/packages/desktop/src/webview.rs index 168e5ff3c..700633234 100644 --- a/packages/desktop/src/webview.rs +++ b/packages/desktop/src/webview.rs @@ -91,7 +91,28 @@ impl WebviewInstance { } }; - let mut webview = WebViewBuilder::new(&window) + #[cfg(any( + target_os = "windows", + target_os = "macos", + target_os = "ios", + target_os = "android" + ))] + let mut webview = WebViewBuilder::new(&window); + + #[cfg(not(any( + target_os = "windows", + target_os = "macos", + target_os = "ios", + target_os = "android" + )))] + let mut webview = { + use tao::platform::unix::WindowExtUnix; + use wry::WebViewBuilderExtUnix; + let vbox = window.default_vbox().unwrap(); + WebViewBuilder::new_gtk(vbox) + }; + + webview = webview .with_transparent(cfg.window.window.transparent) .with_url("dioxus://index.html/") .unwrap() From f98a9adad2aff174edc65d0b45f9ae2b84169fac Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 25 Jan 2024 17:23:06 -0600 Subject: [PATCH 4/8] fix duplicate window menu in the default menubar --- packages/desktop/src/menubar.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/desktop/src/menubar.rs b/packages/desktop/src/menubar.rs index 8c9941cf8..731fb6a68 100644 --- a/packages/desktop/src/menubar.rs +++ b/packages/desktop/src/menubar.rs @@ -64,7 +64,7 @@ mod impl_ { ]) .unwrap(); - let edit_menu = Submenu::new("Window", true); + let edit_menu = Submenu::new("Edit", true); edit_menu .append_items(&[ &PredefinedMenuItem::undo(None), From f7041b118d23b5ae8f033be87e8c1b7c8c2d2b62 Mon Sep 17 00:00:00 2001 From: Andrew Voynov Date: Sat, 27 Jan 2024 21:52:52 +0300 Subject: [PATCH 5/8] chore(deps): bump cargo-generate from 0.18 to 0.19 When building the `dx` CLI there is 1 less dependency (from 710 to 709). --- Cargo.lock | 22 +++++++++++----------- packages/cli/Cargo.toml | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1939afbe9..9eece9cfd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1286,9 +1286,9 @@ dependencies = [ [[package]] name = "cargo-generate" -version = "0.18.5" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a2885ae054e000b117515ab33e91c10eca90c2788a7baec1b97ada1f1f51e57" +checksum = "92c1b6f44358912a9538fa3b6ac8d3aa3f585444f9dc32f12ed85d1545a9df9f" dependencies = [ "anyhow", "auth-git2", @@ -4142,9 +4142,9 @@ dependencies = [ [[package]] name = "gix-config" -version = "0.31.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cae98c6b4c66c09379bc35274b172587d6b0ac369a416c39128ad8c6454f9bb" +checksum = "0341471d55d8676e98b88e121d7065dfa4c9c5acea4b6d6ecdd2846e85cce0c3" dependencies = [ "bstr 1.9.0", "gix-config-value", @@ -4244,9 +4244,9 @@ dependencies = [ [[package]] name = "gix-object" -version = "0.38.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740f2a44267f58770a1cb3a3d01d14e67b089c7136c48d4bddbb3cfd2bf86a51" +checksum = "febf79c5825720c1c63fe974c7bbe695d0cb54aabad73f45671c60ce0e501e33" dependencies = [ "bstr 1.9.0", "btoi", @@ -4276,9 +4276,9 @@ dependencies = [ [[package]] name = "gix-ref" -version = "0.38.0" +version = "0.39.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ec2f6d07ac88d2fb8007ee3fa3e801856fb9d82e7366ec0ca332eb2c9d74a52" +checksum = "3b2069adc212cf7f3317ef55f6444abd06c50f28479dbbac5a86acf3b05cbbfe" dependencies = [ "gix-actor", "gix-date", @@ -5081,7 +5081,7 @@ dependencies = [ "httpdate", "itoa 1.0.10", "pin-project-lite", - "socket2 0.4.10", + "socket2 0.5.5", "tokio", "tower-service", "tracing", @@ -6274,9 +6274,9 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "memmap2" -version = "0.7.1" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f49388d20533534cd19360ad3d6a7dadc885944aa802ba3995040c5ec11288c6" +checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" dependencies = [ "libc", ] diff --git a/packages/cli/Cargo.toml b/packages/cli/Cargo.toml index 8f0c0dc8a..7801f60fe 100644 --- a/packages/cli/Cargo.toml +++ b/packages/cli/Cargo.toml @@ -69,7 +69,7 @@ mlua = { version = "0.8.1", features = [ ], optional = true } ctrlc = "3.2.3" open = "4.1.0" -cargo-generate = "0.18" +cargo-generate = "0.19" toml_edit = "0.19.11" # bundling From fad060766741b8774e35b97c26335534e7cbdf35 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sat, 27 Jan 2024 22:27:23 +0100 Subject: [PATCH 6/8] feat: Reduce CLI deps --- Cargo.lock | 3 --- packages/cli/Cargo.toml | 3 --- packages/cli/src/cli/autoformat.rs | 2 +- packages/cli/src/cli/check.rs | 2 +- packages/cli/src/tools.rs | 2 +- 5 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1939afbe9..c1d1ff9da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2495,14 +2495,11 @@ dependencies = [ "serde", "serde_json", "subprocess", - "syn 2.0.48", "tar", "tauri-bundler", - "tauri-utils", "tempfile", "thiserror", "tokio", - "toml 0.5.11", "toml_edit 0.19.15", "tower", "tower-http 0.2.5", diff --git a/packages/cli/Cargo.toml b/packages/cli/Cargo.toml index 8f0c0dc8a..694025d36 100644 --- a/packages/cli/Cargo.toml +++ b/packages/cli/Cargo.toml @@ -21,7 +21,6 @@ log = "0.4.14" fern = { version = "0.6.0", features = ["colored"] } serde = { version = "1.0.136", features = ["derive"] } serde_json = "1.0.79" -toml = "0.5.8" fs_extra = "1.2.0" cargo_toml = "0.16.0" futures = "0.3.21" @@ -56,7 +55,6 @@ flate2 = "1.0.22" tar = "0.4.38" zip = "0.6.2" tower = "0.4.12" -syn = { version = "2.0", features = ["full", "extra-traits"] } lazy_static = "1.4.0" # plugin packages @@ -74,7 +72,6 @@ toml_edit = "0.19.11" # bundling tauri-bundler = { version = "=1.4.*", features = ["native-tls-vendored"] } -tauri-utils = "=1.5.*" manganis-cli-support = { workspace = true, features = ["webp", "html"] } diff --git a/packages/cli/src/cli/autoformat.rs b/packages/cli/src/cli/autoformat.rs index d1702ebf2..87d780524 100644 --- a/packages/cli/src/cli/autoformat.rs +++ b/packages/cli/src/cli/autoformat.rs @@ -1,5 +1,5 @@ use dioxus_autofmt::{IndentOptions, IndentType}; -use futures::{stream::FuturesUnordered, StreamExt}; +use futures_util::{stream::FuturesUnordered, StreamExt}; use std::{fs, path::Path, process::exit}; use super::*; diff --git a/packages/cli/src/cli/check.rs b/packages/cli/src/cli/check.rs index 0832647f2..614a0c4de 100644 --- a/packages/cli/src/cli/check.rs +++ b/packages/cli/src/cli/check.rs @@ -1,4 +1,4 @@ -use futures::{stream::FuturesUnordered, StreamExt}; +use futures_util::{stream::FuturesUnordered, StreamExt}; use std::{path::Path, process::exit}; use super::*; diff --git a/packages/cli/src/tools.rs b/packages/cli/src/tools.rs index 4045b236e..6bc4256d1 100644 --- a/packages/cli/src/tools.rs +++ b/packages/cli/src/tools.rs @@ -7,7 +7,7 @@ use std::{ use anyhow::Context; use flate2::read::GzDecoder; -use futures::StreamExt; +use futures_util::StreamExt; use tar::Archive; use tokio::io::AsyncWriteExt; From 63b82b279ba6964fafef4aa5458cb7d383cc7877 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sat, 27 Jan 2024 22:29:28 +0100 Subject: [PATCH 7/8] ok --- Cargo.lock | 3 ++- packages/cli/Cargo.toml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c1d1ff9da..01980f050 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2476,7 +2476,7 @@ dependencies = [ "fern", "flate2", "fs_extra", - "futures", + "futures-util", "gitignore", "headers 0.3.9", "html_parser", @@ -2500,6 +2500,7 @@ dependencies = [ "tempfile", "thiserror", "tokio", + "toml 0.5.11", "toml_edit 0.19.15", "tower", "tower-http 0.2.5", diff --git a/packages/cli/Cargo.toml b/packages/cli/Cargo.toml index 694025d36..61dcdadf5 100644 --- a/packages/cli/Cargo.toml +++ b/packages/cli/Cargo.toml @@ -21,9 +21,10 @@ log = "0.4.14" fern = { version = "0.6.0", features = ["colored"] } serde = { version = "1.0.136", features = ["derive"] } serde_json = "1.0.79" +toml = "0.5.8" fs_extra = "1.2.0" cargo_toml = "0.16.0" -futures = "0.3.21" +futures-util = "0.3.30" notify = { version = "5.0.0-pre.16", features = ["serde"] } html_parser = { workspace = true } cargo_metadata = "0.15.0" From d83a6d683fdc8e22f86cdb9f5c6d7f478c747474 Mon Sep 17 00:00:00 2001 From: ealmloff Date: Sat, 27 Jan 2024 20:07:16 -0600 Subject: [PATCH 8/8] use the workspace version of futures utils --- packages/cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/Cargo.toml b/packages/cli/Cargo.toml index 61dcdadf5..e67ff05fe 100644 --- a/packages/cli/Cargo.toml +++ b/packages/cli/Cargo.toml @@ -24,7 +24,7 @@ serde_json = "1.0.79" toml = "0.5.8" fs_extra = "1.2.0" cargo_toml = "0.16.0" -futures-util = "0.3.30" +futures-util.workspace = true notify = { version = "5.0.0-pre.16", features = ["serde"] } html_parser = { workspace = true } cargo_metadata = "0.15.0"