From ebcee6a4704ae8cb33b590614e72eff16b53f10e Mon Sep 17 00:00:00 2001 From: Exidex <16986685+exidex@users.noreply.github.com> Date: Sat, 3 May 2025 10:09:57 +0200 Subject: [PATCH] Make `entrypoint.*.actions.*.shortcut` optional --- CHANGELOG.md | 7 +++++++ bundled_plugins/gauntlet/gauntlet.toml | 4 ++-- .../gauntlet/src/window/shared.tsx | 2 +- docs/schema/plugin_manifest.schema.json | 8 ++++--- rust/server/src/plugins/data_db_repository.rs | 20 +++++++++++------- rust/server/src/plugins/loader.rs | 21 +++++++++++++------ rust/server/src/plugins/plugin_manifest.rs | 4 ++-- 7 files changed, 44 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d21e91..9c4fbbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,13 @@ For changes in `@project-gauntlet/tools` see [separate CHANGELOG.md](https://git ## [Unreleased] +- Windows in "Opened windows" view entrypoint are now sorted following "most recently focused on the top" order +- Plugin manifest property `entrypoint.*.actions.*.shortcut` is now optional + +### Fixes +- Unified `Vec` usage to `ArrayBuffer` in JS + - Fixes `icon` in EntrypointGenerator requiring `number[]` + ## [18] - 2025-04-13 ### General diff --git a/bundled_plugins/gauntlet/gauntlet.toml b/bundled_plugins/gauntlet/gauntlet.toml index 1859162..dad0976 100644 --- a/bundled_plugins/gauntlet/gauntlet.toml +++ b/bundled_plugins/gauntlet/gauntlet.toml @@ -29,10 +29,10 @@ enum_values = [ [[entrypoint]] id = 'windows' -name = 'Open Windows' +name = 'Opened Windows' path = 'src/windows.tsx' type = 'view' -description = 'Show all open windows' +description = 'Show all opened windows' [[entrypoint]] id = 'settings' diff --git a/bundled_plugins/gauntlet/src/window/shared.tsx b/bundled_plugins/gauntlet/src/window/shared.tsx index 3da2c93..55bbfdf 100644 --- a/bundled_plugins/gauntlet/src/window/shared.tsx +++ b/bundled_plugins/gauntlet/src/window/shared.tsx @@ -13,7 +13,7 @@ export function ListOfWindows({ windows, focusWindow }: { }) { const knownWindows = readWindowOrder(); - const sortedWindows = Object.keys(windows) // sort windows bases on array stored on storage + const sortedWindows = Object.keys(windows) // sort windows based on array stored on storage .sort((a, b) => knownWindows.indexOf(a) - knownWindows.indexOf(b)); return ( diff --git a/docs/schema/plugin_manifest.schema.json b/docs/schema/plugin_manifest.schema.json index 0b12326..2863549 100644 --- a/docs/schema/plugin_manifest.schema.json +++ b/docs/schema/plugin_manifest.schema.json @@ -75,8 +75,7 @@ "type": "object", "required": [ "description", - "id", - "shortcut" + "id" ], "properties": { "description": { @@ -89,9 +88,12 @@ }, "shortcut": { "description": "Default keyboard shortcut to trigger the action", - "allOf": [ + "anyOf": [ { "$ref": "#/definitions/PluginManifestActionShortcut" + }, + { + "type": "null" } ] } diff --git a/rust/server/src/plugins/data_db_repository.rs b/rust/server/src/plugins/data_db_repository.rs index c91388c..85d6072 100644 --- a/rust/server/src/plugins/data_db_repository.rs +++ b/rust/server/src/plugins/data_db_repository.rs @@ -200,8 +200,8 @@ pub enum DbPluginPreferenceUserData { pub struct DbPluginAction { pub id: String, pub description: String, - pub key: String, - pub kind: DbPluginActionShortcutKind, + pub key: Option, + pub kind: Option, } #[derive(Debug, Deserialize, Serialize)] @@ -722,17 +722,21 @@ impl DataDbRepository { let action_shortcuts = actions .into_iter() - .map(|action| { + .filter_map(|action| { let id = action.id; let shortcut = match actions_user_data.get(&id) { None => { - let (physical_key, modifier_shift) = match ActionShortcutKey::from_value(&action.key) { - Some(key) => key.to_physical_key(), - None => return Err(anyhow!("unknown key: {}", &action.key)), + let (Some(key), Some(kind)) = (action.key, action.kind) else { + return None; }; - let (modifier_control, modifier_alt, modifier_meta) = match action.kind { + let (physical_key, modifier_shift) = match ActionShortcutKey::from_value(&key) { + Some(key) => key.to_physical_key(), + None => return Some(Err(anyhow!("unknown key: {}", &key))), + }; + + let (modifier_control, modifier_alt, modifier_meta) = match kind { DbPluginActionShortcutKind::Main => { if cfg!(target_os = "macos") { (false, false, true) @@ -762,7 +766,7 @@ impl DataDbRepository { } }; - Ok((id, shortcut)) + Some(Ok((id, shortcut))) }) .collect::, _>>()?; diff --git a/rust/server/src/plugins/loader.rs b/rust/server/src/plugins/loader.rs index ddce67a..1da2a02 100644 --- a/rust/server/src/plugins/loader.rs +++ b/rust/server/src/plugins/loader.rs @@ -401,16 +401,25 @@ impl PluginLoader { .actions .into_iter() .map(|action| { - DbPluginAction { - id: action.id, - description: action.description, - key: action.shortcut.key.to_model().to_value(), - kind: match action.shortcut.kind { + let key = action + .shortcut + .as_ref() + .map(|shortcut| shortcut.key.to_model().to_value()); + + let kind = action.shortcut.as_ref().map(|shortcut| { + match shortcut.kind { PluginManifestActionShortcutKind::Main => DbPluginActionShortcutKind::Main, PluginManifestActionShortcutKind::Alternative => { DbPluginActionShortcutKind::Alternative } - }, + } + }); + + DbPluginAction { + id: action.id, + description: action.description, + key, + kind, } }) .collect(), diff --git a/rust/server/src/plugins/plugin_manifest.rs b/rust/server/src/plugins/plugin_manifest.rs index f311b0b..871c2f2 100644 --- a/rust/server/src/plugins/plugin_manifest.rs +++ b/rust/server/src/plugins/plugin_manifest.rs @@ -175,7 +175,7 @@ pub struct PluginManifestAction { #[schemars(description = "Description of what the action does")] pub description: String, #[schemars(description = "Default keyboard shortcut to trigger the action")] - pub shortcut: PluginManifestActionShortcut, + pub shortcut: Option, } #[derive(Debug, Deserialize, Serialize, JsonSchema)] @@ -382,7 +382,7 @@ pub enum PluginManifestActionShortcutKey { } impl PluginManifestActionShortcutKey { - pub fn to_model(self) -> ActionShortcutKey { + pub fn to_model(&self) -> ActionShortcutKey { match self { PluginManifestActionShortcutKey::Num0 => ActionShortcutKey::Num0, PluginManifestActionShortcutKey::Num1 => ActionShortcutKey::Num1,