mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-08-15 19:00:23 +02:00
feat: update to tauri beta, add permissions (#862)
Co-authored-by: Lucas Nogueira <lucas@tauri.app> Co-authored-by: Lucas Nogueira <lucas@crabnebula.dev>
This commit is contained in:
co-authored by
Lucas Nogueira
Lucas Nogueira
parent
506ce4835b
commit
d198c01486
@@ -6,10 +6,14 @@ edition = { workspace = true }
|
||||
authors = { workspace = true }
|
||||
license = { workspace = true }
|
||||
rust-version = { workspace = true }
|
||||
links = "tauri-plugin-global-shortcut"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
rustc-args = [ "--cfg", "docsrs" ]
|
||||
rustdoc-args = [ "--cfg", "docsrs" ]
|
||||
rustc-args = ["--cfg", "docsrs"]
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-plugin = { workspace = true, features = ["build"] }
|
||||
|
||||
[dependencies]
|
||||
serde = { workspace = true }
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
const COMMANDS: &[&str] = &[
|
||||
"register",
|
||||
"register_all",
|
||||
"unregister",
|
||||
"unregister_all",
|
||||
"is_registered",
|
||||
];
|
||||
|
||||
fn main() {
|
||||
tauri_plugin::Builder::new(COMMANDS).build();
|
||||
}
|
||||
@@ -34,7 +34,7 @@ async function register(
|
||||
const h = new Channel<string>();
|
||||
h.onmessage = handler;
|
||||
|
||||
return await invoke("plugin:globalShortcut|register", {
|
||||
return await invoke("plugin:global-shortcut|register", {
|
||||
shortcut,
|
||||
handler: h,
|
||||
});
|
||||
@@ -62,7 +62,7 @@ async function registerAll(
|
||||
const h = new Channel<string>();
|
||||
h.onmessage = handler;
|
||||
|
||||
return await invoke("plugin:globalShortcut|register_all", {
|
||||
return await invoke("plugin:global-shortcut|register_all", {
|
||||
shortcuts,
|
||||
handler: h,
|
||||
});
|
||||
@@ -84,7 +84,7 @@ async function registerAll(
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function isRegistered(shortcut: string): Promise<boolean> {
|
||||
return await invoke("plugin:globalShortcut|is_registered", {
|
||||
return await invoke("plugin:global-shortcut|is_registered", {
|
||||
shortcut,
|
||||
});
|
||||
}
|
||||
@@ -102,7 +102,7 @@ async function isRegistered(shortcut: string): Promise<boolean> {
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function unregister(shortcut: string): Promise<void> {
|
||||
return await invoke("plugin:globalShortcut|unregister", {
|
||||
return await invoke("plugin:global-shortcut|unregister", {
|
||||
shortcut,
|
||||
});
|
||||
}
|
||||
@@ -118,7 +118,7 @@ async function unregister(shortcut: string): Promise<void> {
|
||||
* @since 2.0.0
|
||||
*/
|
||||
async function unregisterAll(): Promise<void> {
|
||||
return await invoke("plugin:globalShortcut|unregister_all");
|
||||
return await invoke("plugin:global-shortcut|unregister_all");
|
||||
}
|
||||
|
||||
export { register, registerAll, isRegistered, unregister, unregisterAll };
|
||||
|
||||
@@ -23,6 +23,6 @@
|
||||
"LICENSE"
|
||||
],
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "2.0.0-alpha.13"
|
||||
"@tauri-apps/api": "2.0.0-beta.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
schemas/
|
||||
@@ -0,0 +1 @@
|
||||
schemas/
|
||||
@@ -0,0 +1,13 @@
|
||||
# Automatically generated - DO NOT EDIT!
|
||||
|
||||
"$schema" = "../../schemas/schema.json"
|
||||
|
||||
[[permission]]
|
||||
identifier = "allow-is-registered"
|
||||
description = "Enables the is_registered command without any pre-configured scope."
|
||||
commands.allow = ["is_registered"]
|
||||
|
||||
[[permission]]
|
||||
identifier = "deny-is-registered"
|
||||
description = "Denies the is_registered command without any pre-configured scope."
|
||||
commands.deny = ["is_registered"]
|
||||
@@ -0,0 +1,13 @@
|
||||
# Automatically generated - DO NOT EDIT!
|
||||
|
||||
"$schema" = "../../schemas/schema.json"
|
||||
|
||||
[[permission]]
|
||||
identifier = "allow-register"
|
||||
description = "Enables the register command without any pre-configured scope."
|
||||
commands.allow = ["register"]
|
||||
|
||||
[[permission]]
|
||||
identifier = "deny-register"
|
||||
description = "Denies the register command without any pre-configured scope."
|
||||
commands.deny = ["register"]
|
||||
@@ -0,0 +1,13 @@
|
||||
# Automatically generated - DO NOT EDIT!
|
||||
|
||||
"$schema" = "../../schemas/schema.json"
|
||||
|
||||
[[permission]]
|
||||
identifier = "allow-register-all"
|
||||
description = "Enables the register_all command without any pre-configured scope."
|
||||
commands.allow = ["register_all"]
|
||||
|
||||
[[permission]]
|
||||
identifier = "deny-register-all"
|
||||
description = "Denies the register_all command without any pre-configured scope."
|
||||
commands.deny = ["register_all"]
|
||||
@@ -0,0 +1,13 @@
|
||||
# Automatically generated - DO NOT EDIT!
|
||||
|
||||
"$schema" = "../../schemas/schema.json"
|
||||
|
||||
[[permission]]
|
||||
identifier = "allow-unregister"
|
||||
description = "Enables the unregister command without any pre-configured scope."
|
||||
commands.allow = ["unregister"]
|
||||
|
||||
[[permission]]
|
||||
identifier = "deny-unregister"
|
||||
description = "Denies the unregister command without any pre-configured scope."
|
||||
commands.deny = ["unregister"]
|
||||
@@ -0,0 +1,13 @@
|
||||
# Automatically generated - DO NOT EDIT!
|
||||
|
||||
"$schema" = "../../schemas/schema.json"
|
||||
|
||||
[[permission]]
|
||||
identifier = "allow-unregister-all"
|
||||
description = "Enables the unregister_all command without any pre-configured scope."
|
||||
commands.allow = ["unregister_all"]
|
||||
|
||||
[[permission]]
|
||||
identifier = "deny-unregister-all"
|
||||
description = "Denies the unregister_all command without any pre-configured scope."
|
||||
commands.deny = ["unregister_all"]
|
||||
@@ -0,0 +1,42 @@
|
||||
# Permissions
|
||||
|
||||
## allow-is-registered
|
||||
|
||||
Enables the is_registered command without any pre-configured scope.
|
||||
|
||||
## deny-is-registered
|
||||
|
||||
Denies the is_registered command without any pre-configured scope.
|
||||
|
||||
## allow-register
|
||||
|
||||
Enables the register command without any pre-configured scope.
|
||||
|
||||
## deny-register
|
||||
|
||||
Denies the register command without any pre-configured scope.
|
||||
|
||||
## allow-register-all
|
||||
|
||||
Enables the register_all command without any pre-configured scope.
|
||||
|
||||
## deny-register-all
|
||||
|
||||
Denies the register_all command without any pre-configured scope.
|
||||
|
||||
## allow-unregister
|
||||
|
||||
Enables the unregister command without any pre-configured scope.
|
||||
|
||||
## deny-unregister
|
||||
|
||||
Denies the unregister command without any pre-configured scope.
|
||||
|
||||
## allow-unregister-all
|
||||
|
||||
Enables the unregister_all command without any pre-configured scope.
|
||||
|
||||
## deny-unregister-all
|
||||
|
||||
Denies the unregister_all command without any pre-configured scope.
|
||||
|
||||
@@ -1 +1 @@
|
||||
if("__TAURI__"in window){var __TAURI_PLUGIN_GLOBALSHORTCUT__=function(t){"use strict";function e(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)}var r;"function"==typeof SuppressedError&&SuppressedError;class n{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,r.set(this,(()=>{})),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((t=>{e(this,r,"f").call(this,t)}))}set onmessage(t){!function(t,e,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?o.call(t,r):o?o.value=r:e.set(t,r)}(this,r,t,"f")}get onmessage(){return e(this,r,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function o(t,e={},r){return window.__TAURI_INTERNALS__.invoke(t,e,r)}return r=new WeakMap,t.isRegistered=async function(t){return await o("plugin:globalShortcut|is_registered",{shortcut:t})},t.register=async function(t,e){const r=new n;return r.onmessage=e,await o("plugin:globalShortcut|register",{shortcut:t,handler:r})},t.registerAll=async function(t,e){const r=new n;return r.onmessage=e,await o("plugin:globalShortcut|register_all",{shortcuts:t,handler:r})},t.unregister=async function(t){return await o("plugin:globalShortcut|unregister",{shortcut:t})},t.unregisterAll=async function(){return await o("plugin:globalShortcut|unregister_all")},t}({});Object.defineProperty(window.__TAURI__,"globalShortcut",{value:__TAURI_PLUGIN_GLOBALSHORTCUT__})}
|
||||
if("__TAURI__"in window){var __TAURI_PLUGIN_GLOBALSHORTCUT__=function(t){"use strict";function e(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)}var r;"function"==typeof SuppressedError&&SuppressedError;class n{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,r.set(this,(()=>{})),this.id=function(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}((t=>{e(this,r,"f").call(this,t)}))}set onmessage(t){!function(t,e,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?o.call(t,r):o?o.value=r:e.set(t,r)}(this,r,t,"f")}get onmessage(){return e(this,r,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function o(t,e={},r){return window.__TAURI_INTERNALS__.invoke(t,e,r)}return r=new WeakMap,t.isRegistered=async function(t){return await o("plugin:global-shortcut|is_registered",{shortcut:t})},t.register=async function(t,e){const r=new n;return r.onmessage=e,await o("plugin:global-shortcut|register",{shortcut:t,handler:r})},t.registerAll=async function(t,e){const r=new n;return r.onmessage=e,await o("plugin:global-shortcut|register_all",{shortcuts:t,handler:r})},t.unregister=async function(t){return await o("plugin:global-shortcut|unregister",{shortcut:t})},t.unregisterAll=async function(){return await o("plugin:global-shortcut|unregister_all")},t}({});Object.defineProperty(window.__TAURI__,"globalShortcut",{value:__TAURI_PLUGIN_GLOBALSHORTCUT__})}
|
||||
|
||||
@@ -295,7 +295,7 @@ impl<R: Runtime> Builder<R> {
|
||||
|
||||
pub fn build(self) -> TauriPlugin<R> {
|
||||
let handler = self.handler;
|
||||
PluginBuilder::new("globalShortcut")
|
||||
PluginBuilder::new("global-shortcut")
|
||||
.js_init_script(include_str!("api-iife.js").to_string())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
register,
|
||||
|
||||
Reference in New Issue
Block a user