add clipboard, global shortcut to examples

pull/317/head
Lucas Nogueira 2 years ago
parent 3bbe7ef7c7
commit 410f5b9275
No known key found for this signature in database
GPG Key ID: FFEA6C72E73482F1

6
Cargo.lock generated

@ -1780,15 +1780,15 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "global-hotkey"
version = "0.1.2"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9da26790f92f0be4f7a894ca1d079140827a75a9fd25eb9912913c4853696ce2"
checksum = "92007db5c632751655a4c0ef122832fd283e6651621d34613b17fd1edfbfd2ed"
dependencies = [
"crossbeam-channel",
"keyboard-types",
"once_cell",
"thiserror",
"windows-sys 0.45.0",
"windows-sys 0.48.0",
"x11-dl",
]

@ -12,7 +12,9 @@
"@tauri-apps/cli": "2.0.0-alpha.8",
"@zerodevx/svelte-json-view": "0.2.1",
"tauri-plugin-cli-api": "0.0.0",
"tauri-plugin-fs-api": "0.0.0"
"tauri-plugin-clipboard-api": "0.0.0",
"tauri-plugin-fs-api": "0.0.0",
"tauri-plugin-global-shortcut-api": "0.0.0"
},
"devDependencies": {
"@iconify-json/codicon": "^1.1.10",

@ -150,12 +150,34 @@ dependencies = [
"tauri",
"tauri-build",
"tauri-plugin-cli",
"tauri-plugin-clipboard",
"tauri-plugin-fs",
"tauri-plugin-global-shortcut",
"tauri-plugin-log",
"tiny_http",
"window-shadows",
]
[[package]]
name = "arboard"
version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6041616acea41d67c4a984709ddab1587fd0b10efe5cc563fee954d2f011854"
dependencies = [
"clipboard-win",
"core-graphics",
"image",
"log",
"objc",
"objc-foundation",
"objc_id",
"once_cell",
"parking_lot",
"thiserror",
"winapi",
"x11rb",
]
[[package]]
name = "ascii"
version = "1.1.0"
@ -534,6 +556,17 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1"
[[package]]
name = "clipboard-win"
version = "4.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7191c27c2357d9b7ef96baac1773290d4ca63b24205b82a3fd8a0637afcf0362"
dependencies = [
"error-code",
"str-buf",
"winapi",
]
[[package]]
name = "cocoa"
version = "0.24.1"
@ -941,6 +974,16 @@ dependencies = [
"libc",
]
[[package]]
name = "error-code"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64f18991e7bf11e7ffee451b5318b5c1a73c52d0d0ada6e5a3017c8c1ced6a21"
dependencies = [
"libc",
"str-buf",
]
[[package]]
name = "event-listener"
version = "2.5.3"
@ -1242,6 +1285,16 @@ dependencies = [
"version_check",
]
[[package]]
name = "gethostname"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "getrandom"
version = "0.1.16"
@ -1360,6 +1413,20 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "global-hotkey"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92007db5c632751655a4c0ef122832fd283e6651621d34613b17fd1edfbfd2ed"
dependencies = [
"crossbeam-channel",
"keyboard-types",
"once_cell",
"thiserror",
"windows-sys 0.48.0",
"x11-dl",
]
[[package]]
name = "globset"
version = "0.4.10"
@ -1642,6 +1709,8 @@ dependencies = [
"color_quant",
"num-rational",
"num-traits",
"png",
"tiff",
]
[[package]]
@ -1774,6 +1843,12 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
[[package]]
name = "jpeg-decoder"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e"
[[package]]
name = "js-sys"
version = "0.3.61"
@ -1795,6 +1870,17 @@ dependencies = [
"treediff",
]
[[package]]
name = "keyboard-types"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7668b7cff6a51fe61cdde64cd27c8a220786f399501b57ebe36f7d8112fd68"
dependencies = [
"bitflags",
"serde",
"unicode-segmentation",
]
[[package]]
name = "kuchiki"
version = "0.8.1"
@ -2061,6 +2147,18 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
[[package]]
name = "nix"
version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069"
dependencies = [
"bitflags",
"cfg-if",
"libc",
"memoffset 0.6.5",
]
[[package]]
name = "nix"
version = "0.26.2"
@ -3155,6 +3253,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "str-buf"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0"
[[package]]
name = "string_cache"
version = "0.8.4"
@ -3458,6 +3562,19 @@ dependencies = [
"thiserror",
]
[[package]]
name = "tauri-plugin-clipboard"
version = "0.1.0"
dependencies = [
"arboard",
"log",
"serde",
"serde_json",
"tauri",
"tauri-build",
"thiserror",
]
[[package]]
name = "tauri-plugin-fs"
version = "0.1.0"
@ -3468,6 +3585,18 @@ dependencies = [
"thiserror",
]
[[package]]
name = "tauri-plugin-global-shortcut"
version = "0.1.0"
dependencies = [
"global-hotkey",
"log",
"serde",
"serde_json",
"tauri",
"thiserror",
]
[[package]]
name = "tauri-plugin-log"
version = "0.1.0"
@ -3639,6 +3768,17 @@ dependencies = [
"once_cell",
]
[[package]]
name = "tiff"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7449334f9ff2baf290d55d73983a7d6fa15e01198faef72af07e2a8db851e471"
dependencies = [
"flate2",
"jpeg-decoder",
"weezl",
]
[[package]]
name = "time"
version = "0.3.20"
@ -4179,6 +4319,12 @@ dependencies = [
"windows-metadata",
]
[[package]]
name = "weezl"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb"
[[package]]
name = "win7-notifications"
version = "0.3.1"
@ -4214,6 +4360,15 @@ dependencies = [
"winapi",
]
[[package]]
name = "winapi-wsapoll"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44c17110f57155602a80dca10be03852116403c9ff3cd25b079d666f2aa3df6e"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
@ -4589,6 +4744,28 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "x11rb"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "592b4883219f345e712b3209c62654ebda0bb50887f330cbd018d0f654bfd507"
dependencies = [
"gethostname",
"nix 0.24.3",
"winapi",
"winapi-wsapoll",
"x11rb-protocol",
]
[[package]]
name = "x11rb-protocol"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56b245751c0ac9db0e006dc812031482784e434630205a93c73cfefcaabeac67"
dependencies = [
"nix 0.24.3",
]
[[package]]
name = "xattr"
version = "0.2.3"
@ -4621,7 +4798,7 @@ dependencies = [
"futures-sink",
"futures-util",
"hex",
"nix",
"nix 0.26.2",
"once_cell",
"ordered-stream",
"rand 0.8.5",

@ -18,8 +18,8 @@ serde = { version = "1.0", features = [ "derive" ] }
tiny_http = "0.11"
log = "0.4"
tauri-plugin-log = { path = "../../../plugins/log" }
tauri-plugin-cli = { path = "../../../plugins/cli" }
tauri-plugin-fs = { path = "../../../plugins/fs" }
tauri-plugin-clipboard = { path = "../../../plugins/clipboard" }
[patch.crates-io]
tauri = { git = "https://github.com/tauri-apps/tauri", branch = "next" }
@ -40,6 +40,10 @@ features = [
"updater"
]
[target."cfg(any(target_os = \"macos\", windows, target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
tauri-plugin-cli = { path = "../../../plugins/cli" }
tauri-plugin-global-shortcut = { path = "../../../plugins/global-shortcut" }
[target."cfg(target_os = \"windows\")".dependencies]
window-shadows = "0.2"

@ -32,11 +32,14 @@ pub fn run() {
.build(),
)
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_clipboard::init())
.setup(move |app| {
#[cfg(desktop)]
{
tray::create_tray(app)?;
app.handle().plugin(tauri_plugin_cli::init())?;
app.handle()
.plugin(tauri_plugin_global_shortcut::Builder::new().build())?;
}
let mut window_builder = WindowBuilder::new(app, "main", WindowUrl::default());

@ -1,5 +1,5 @@
<script>
import { writeText, readText } from '@tauri-apps/api/clipboard'
import { writeText, readText } from 'tauri-plugin-clipboard-api'
export let onMessage
let text = 'clipboard message'

@ -4,7 +4,7 @@
register as registerShortcut,
unregister as unregisterShortcut,
unregisterAll as unregisterAllShortcuts
} from '@tauri-apps/api/globalShortcut'
} from 'tauri-plugin-global-shortcut-api'
export let onMessage
const shortcuts = writable([])

@ -49,7 +49,7 @@ type ClipResponse = Clip<'Text', string>
async function writeText(text: string, opts?: { label?: string }): Promise<void> {
return invoke('plugin:clipboard|write', {
data: {
kind: 'Text',
kind: 'PlainText',
options: {
label: opts?.label,
text

@ -61,9 +61,15 @@ importers:
tauri-plugin-cli-api:
specifier: 0.0.0
version: link:../../plugins/cli
tauri-plugin-clipboard-api:
specifier: 0.0.0
version: link:../../plugins/clipboard
tauri-plugin-fs-api:
specifier: 0.0.0
version: link:../../plugins/fs
tauri-plugin-global-shortcut-api:
specifier: 0.0.0
version: link:../../plugins/global-shortcut
devDependencies:
'@iconify-json/codicon':
specifier: ^1.1.10
@ -147,6 +153,16 @@ importers:
specifier: ^2.4.1
version: 2.4.1
plugins/global-shortcut:
dependencies:
'@tauri-apps/api':
specifier: ^1.2.0
version: 1.2.0
devDependencies:
tslib:
specifier: ^2.4.1
version: 2.4.1
plugins/log:
dependencies:
'@tauri-apps/api':

Loading…
Cancel
Save