From 381a466db344e59a76b2a4d5785b2a0b64d4d373 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Mon, 8 Jul 2024 19:20:00 +0300 Subject: [PATCH] refactor(global-shortcut): enhance `un/register` to accept an array, remove `un/registerAll` (#1117) * refactor(shell): enhance `un/register` to accept an array, remove `un/registerAll` closes #1101 * Update lib.rs * remove permissions, cleanup docs * bring back unregister_all * fmt * fix build * bundle --------- Co-authored-by: Lucas Nogueira --- .changes/global-shortcut-js-apis-refactor.md | 10 ++ .../global-shortcut-rust-apis-refactor.md | 8 ++ .../src-tauri/gen/schemas/desktop-schema.json | 14 --- examples/api/src/views/Shortcuts.svelte | 5 +- plugins/global-shortcut/api-iife.js | 2 +- plugins/global-shortcut/build.rs | 8 +- plugins/global-shortcut/guest-js/index.ts | 97 +++++++++---------- .../global-shortcut/permissions/default.toml | 2 +- plugins/global-shortcut/src/lib.rs | 72 ++++++-------- 9 files changed, 98 insertions(+), 120 deletions(-) create mode 100644 .changes/global-shortcut-js-apis-refactor.md create mode 100644 .changes/global-shortcut-rust-apis-refactor.md diff --git a/.changes/global-shortcut-js-apis-refactor.md b/.changes/global-shortcut-js-apis-refactor.md new file mode 100644 index 00000000..3bc6d76c --- /dev/null +++ b/.changes/global-shortcut-js-apis-refactor.md @@ -0,0 +1,10 @@ +--- +"global-shortcut": "patch" +--- + +Refactored the Rust APIs: + +- Renamed `GlobalShortcut::on_all_shortcuts` to `GlobalShortcut::on_shortcuts` +- Renamed `GlobalShortcut::register_all` to `GlobalShortcut::register_multiple` +- Changed `GlobalShortcut::unregister_all` behavior to remove all registerd shortcuts. +- Added `GlobalShortcut::unregister_multiple` to register a list of shortcuts (old behavior of `unregister_all`). diff --git a/.changes/global-shortcut-rust-apis-refactor.md b/.changes/global-shortcut-rust-apis-refactor.md new file mode 100644 index 00000000..073ec6de --- /dev/null +++ b/.changes/global-shortcut-rust-apis-refactor.md @@ -0,0 +1,8 @@ +--- +"global-shortcut-js": "patch" +--- + +Refactored the JS APIs: + +- Enhanced `register` and `unregister` to take either a single shortcut or an array. +- Removed `registerAll` instead use `register` with an array. diff --git a/examples/api/src-tauri/gen/schemas/desktop-schema.json b/examples/api/src-tauri/gen/schemas/desktop-schema.json index 40b64e2c..cb656d6e 100644 --- a/examples/api/src-tauri/gen/schemas/desktop-schema.json +++ b/examples/api/src-tauri/gen/schemas/desktop-schema.json @@ -4850,13 +4850,6 @@ "global-shortcut:allow-register" ] }, - { - "description": "global-shortcut:allow-register-all -> Enables the register_all command without any pre-configured scope.", - "type": "string", - "enum": [ - "global-shortcut:allow-register-all" - ] - }, { "description": "global-shortcut:allow-unregister -> Enables the unregister command without any pre-configured scope.", "type": "string", @@ -4885,13 +4878,6 @@ "global-shortcut:deny-register" ] }, - { - "description": "global-shortcut:deny-register-all -> Denies the register_all command without any pre-configured scope.", - "type": "string", - "enum": [ - "global-shortcut:deny-register-all" - ] - }, { "description": "global-shortcut:deny-unregister -> Denies the unregister command without any pre-configured scope.", "type": "string", diff --git a/examples/api/src/views/Shortcuts.svelte b/examples/api/src/views/Shortcuts.svelte index b2dde459..41d0271d 100644 --- a/examples/api/src/views/Shortcuts.svelte +++ b/examples/api/src/views/Shortcuts.svelte @@ -1,9 +1,8 @@