diff --git a/Cargo.toml b/Cargo.toml index e430b9e..7220a3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tauri-plugin-prevent-default" description = "Disable default browser shortcuts" -version = "0.7.8" +version = "0.8.0" homepage = "https://github.com/ferreira-tb/tauri-plugin-prevent-default" repository = "https://github.com/ferreira-tb/tauri-plugin-prevent-default" documentation = "https://docs.rs/tauri-plugin-prevent-default" @@ -37,12 +37,8 @@ priority = -1 [dependencies] bitflags = "2.6" itertools = "0.13" -tauri = "2.0" -thiserror = "2.0" - -[dependencies.ahash] -version = "0.8" -optional = true +tauri = "2" +thiserror = "2" [dependencies.serde] version = "1.0" @@ -65,5 +61,4 @@ version = "2.0" features = ["build"] [features] -ahash = ["dep:ahash"] unstable-native-windows = ["dep:windows", "dep:webview2-com"] diff --git a/README.md b/README.md index efa4fe7..3cdc18a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Install the plugin by adding the following to your `Cargo.toml` file: ```toml [dependencies] -tauri-plugin-prevent-default = 0.7 +tauri-plugin-prevent-default = 0.8 ``` If using custom listeners, you must also enable the required permissions: @@ -118,7 +118,7 @@ The `unstable-native-windows` feature must be enabled. ```toml [dependencies] -tauri-plugin-prevent-default = { version = "0.7", features = ["unstable-native-windows"] } +tauri-plugin-prevent-default = { version = "0.8", features = ["unstable-native-windows"] } ``` ```rust diff --git a/src/lib.rs b/src/lib.rs index b756538..c0ebf39 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,19 +9,16 @@ mod shortcut; mod state; use bitflags::bitflags; +use state::PluginState; +use std::collections::HashSet; +use tauri::plugin::{Builder as PluginBuilder, TauriPlugin}; +use tauri::{Manager, Runtime}; + pub use error::Error; pub use shortcut::{ KeyboardShortcut, KeyboardShortcutBuilder, ModifierKey, PointerEvent, PointerShortcut, PointerShortcutBuilder, Shortcut, ShortcutKind, }; -use state::PluginState; -use tauri::plugin::{Builder as PluginBuilder, TauriPlugin}; -use tauri::{Manager, Runtime}; - -#[cfg(feature = "ahash")] -use ahash::{HashSet, HashSetExt}; -#[cfg(not(feature = "ahash"))] -use std::collections::HashSet; bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] @@ -196,17 +193,9 @@ impl Builder { if let Some(it) = state.listeners.get_mut(&shortcut) { it.extend(listeners); } else { - #[cfg(feature = "ahash")] - let set = { - let mut set = HashSet::new(); - set.extend(listeners); - set - }; - - #[cfg(not(feature = "ahash"))] - let set = HashSet::from_iter(listeners); - - state.listeners.insert(shortcut, set); + state + .listeners + .insert(shortcut, HashSet::from_iter(listeners)); } } } diff --git a/src/state.rs b/src/state.rs index 68ce33f..695231a 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,10 +1,6 @@ use crate::listener::EventListener; -use tauri::{Runtime, Window}; - -#[cfg(feature = "ahash")] -use ahash::{HashMap, HashMapExt, HashSet}; -#[cfg(not(feature = "ahash"))] use std::collections::{HashMap, HashSet}; +use tauri::{Runtime, Window}; pub(crate) struct PluginState { pub(crate) listeners: HashMap>>, @@ -17,9 +13,9 @@ impl PluginState { pub(crate) fn call_listeners(&self, shortcut: &str, window: &Window) { if let Some(listeners) = self.listeners.get(shortcut) { - for listener in listeners { - listener.call(window); - } + listeners + .iter() + .for_each(|listener| listener.call(window)); } } }