feat(core): add file drop handler (#1352)

This commit is contained in:
Lucas Fernandes Nogueira 2021-03-12 21:02:36 -03:00 committed by GitHub
parent 53910ff7ac
commit 2db901e744
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 304 additions and 207 deletions

View File

@ -0,0 +1,5 @@
---
"tauri": minor
---
Tauri now emits events on file drops on the webview window.

View File

@ -7,7 +7,7 @@ import { invokeTauriCommand } from './helpers/tauri'
* @param [args] command args
* @return promise resolving to the stdout text
*/
async function execute (
async function execute(
command: string,
args?: string | string[]
): Promise<string> {
@ -32,7 +32,7 @@ async function execute (
* @param path the path or URL to open
* @param openWith the app to open the file or URL with
*/
async function open (path: string, openWith?: string): Promise<void> {
async function open(path: string, openWith?: string): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Shell',
message: {

4
cli/core/Cargo.lock generated
View File

@ -661,9 +661,9 @@ dependencies = [
[[package]]
name = "image"
version = "0.23.13"
version = "0.23.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "293f07a1875fa7e9c5897b51aa68b2d8ed8271b87e1a44cb64b9c3d98aabbc0d"
checksum = "24ffcb7e7244a9bf19d35bf2883b9c080c4ced3c07a9895572178cdb8f13f6a1"
dependencies = [
"bytemuck",
"byteorder",

View File

@ -30,7 +30,7 @@ thiserror = "1.0.24"
once_cell = "1.7.2"
tauri-api = { version = "0.7.5", path = "../tauri-api" }
tauri-macros = { version = "0.1", path = "../tauri-macros" }
wry = { git = "https://github.com/tauri-apps/wry", rev = "729fdc182eaf4af44d822dfc9396deb3f5f5810a" }
wry = { git = "https://github.com/tauri-apps/wry", rev = "39575983dbd128fbbcde933d742b33b691fd1def" }
rand = "0.8"
[build-dependencies]

View File

@ -83,13 +83,13 @@ dependencies = [
[[package]]
name = "async-trait"
version = "0.1.42"
version = "0.1.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d"
checksum = "36ea56748e10732c49404c153638a15ec3d6211ec5ff35d9bb20e13b93576adf"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -184,9 +184,9 @@ checksum = "bed57e2090563b83ba8f83366628ce535a7584c9afa4c9fc0612a03925c6df58"
[[package]]
name = "byteorder"
version = "1.4.2"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "bytes"
@ -326,7 +326,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -383,7 +383,7 @@ checksum = "7606b05842fea68ddcc89e8053b8860ebcb2a0ba8d6abfe3a148e5d5a8d3f0c1"
dependencies = [
"com_macros_support",
"proc-macro2",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -394,7 +394,7 @@ checksum = "97e9a6d20f4ac8830e309a455d7e9416e65c6af5a97c88c55fbb4c2012e107da"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -569,7 +569,7 @@ dependencies = [
"proc-macro2",
"quote 1.0.9",
"strsim 0.9.3",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -580,7 +580,7 @@ checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72"
dependencies = [
"darling_core",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -601,7 +601,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -705,7 +705,7 @@ checksum = "946ee94e3dbf58fdd324f9ce245c7b238d46a66f00e86a020b71996349e46cce"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -860,7 +860,7 @@ dependencies = [
"proc-macro-hack",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -1058,7 +1058,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -1260,9 +1260,9 @@ dependencies = [
[[package]]
name = "image"
version = "0.23.13"
version = "0.23.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "293f07a1875fa7e9c5897b51aa68b2d8ed8271b87e1a44cb64b9c3d98aabbc0d"
checksum = "24ffcb7e7244a9bf19d35bf2883b9c080c4ced3c07a9895572178cdb8f13f6a1"
dependencies = [
"bytemuck",
"byteorder",
@ -1279,9 +1279,9 @@ dependencies = [
[[package]]
name = "indexmap"
version = "1.6.1"
version = "1.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b"
checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
dependencies = [
"autocfg",
"hashbrown",
@ -1399,9 +1399,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.86"
version = "0.2.88"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c"
checksum = "03b07a082330a35e43f63177cc01689da34fbffa0105e1246cf0311472cac73a"
[[package]]
name = "libloading"
@ -1663,7 +1663,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -1823,7 +1823,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -1863,9 +1863,9 @@ checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3"
[[package]]
name = "open"
version = "1.5.1"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2033f93630dd4b04768ecf5e16bcd3002a89e1e1dbef375bf290dd67e2b7a4d"
checksum = "a7e9f1bdf15cd1f5a00cc9002a733a6ee6d0ff562491852d59652471c4a389f7"
dependencies = [
"which",
"winapi 0.3.9",
@ -2024,7 +2024,7 @@ dependencies = [
"proc-macro-hack",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -2053,14 +2053,14 @@ checksum = "758669ae3558c6f74bd2a18b41f7ac0b5a195aea6639d6a9b5e5d1ad5ba24c0b"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
name = "pin-project-lite"
version = "0.2.4"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827"
checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905"
[[package]]
name = "pin-utils"
@ -2123,7 +2123,7 @@ dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
"version_check",
]
@ -2346,9 +2346,9 @@ dependencies = [
[[package]]
name = "reqwest"
version = "0.11.1"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0460542b551950620a3648c6aa23318ac6b3cd779114bd873209e6e8b5eb1c34"
checksum = "bf12057f289428dbf5c591c74bf10392e4a8003f993405a902f20117019022d4"
dependencies = [
"base64",
"bytes",
@ -2468,9 +2468,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "security-framework"
version = "2.1.1"
version = "2.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dfd318104249865096c8da1dfabf09ddbb6d0330ea176812a62ec75e40c4166"
checksum = "d493c5f39e02dfb062cd8f33301f90f9b13b650e8c1b1d0fd75c19dd64bff69d"
dependencies = [
"bitflags 1.2.1",
"core-foundation 0.9.1",
@ -2509,22 +2509,22 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.123"
version = "1.0.124"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae"
checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.123"
version = "1.0.124"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31"
checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -2546,7 +2546,7 @@ checksum = "2dc6b7951b17b051f3210b063f12cc17320e2fe30ae05b0fe2a3abb068551c76"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -2581,9 +2581,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
name = "smithay-client-toolkit"
version = "0.12.2"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "316e13a3eb853ce7bf72ad3530dc186cb2005c57c521ef5f4ada5ee4eed74de6"
checksum = "4750c76fd5d3ac95fa3ed80fe667d6a3d8590a960e5b575b98eea93339a80b80"
dependencies = [
"andrew",
"bitflags 1.2.1",
@ -2673,7 +2673,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -2685,7 +2685,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -2701,9 +2701,9 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.60"
version = "1.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081"
checksum = "8fd9bc7ccc2688b3344c2f48b9b546648b25ce0b20fc717ee7fa7981a8ca9717"
dependencies = [
"proc-macro2",
"quote 1.0.9",
@ -2844,7 +2844,7 @@ dependencies = [
"quote 1.0.9",
"serde",
"serde_json",
"syn 1.0.60",
"syn 1.0.63",
"tauri-utils",
"walkdir",
]
@ -2910,7 +2910,7 @@ checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -2961,9 +2961,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "1.2.0"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8190d04c665ea9e6b6a0dc45523ade572c088d2e6566244c1122671dbf4ae3a"
checksum = "8d56477f6ed99e10225f38f9f75f872f29b8b8bd8c0b946f63345bb144e9eeda"
dependencies = [
"autocfg",
"bytes",
@ -2986,9 +2986,9 @@ dependencies = [
[[package]]
name = "tokio-util"
version = "0.6.3"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebb7cb2f00c5ae8df755b252306272cd1790d39728363936e01827e11f0b017b"
checksum = "ec31e5cc6b46e653cf57762f36f71d5e6386391d88a72fd6db4508f8f676fb29"
dependencies = [
"bytes",
"futures-core",
@ -3221,7 +3221,7 @@ dependencies = [
"log",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
"wasm-bindgen-shared",
]
@ -3255,7 +3255,7 @@ checksum = "cc053ec74d454df287b9374ee8abb36ffd5acb95ba87da3ba5b7d3fe20eb401e"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@ -3563,8 +3563,8 @@ dependencies = [
[[package]]
name = "wry"
version = "0.5.1"
source = "git+https://github.com/tauri-apps/wry?rev=729fdc182eaf4af44d822dfc9396deb3f5f5810a#729fdc182eaf4af44d822dfc9396deb3f5f5810a"
version = "0.6.0"
source = "git+https://github.com/tauri-apps/wry?rev=39575983dbd128fbbcde933d742b33b691fd1def#39575983dbd128fbbcde933d742b33b691fd1def"
dependencies = [
"cairo-rs",
"cocoa",
@ -3683,7 +3683,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -3721,5 +3721,5 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]

View File

@ -71,13 +71,13 @@ dependencies = [
[[package]]
name = "async-trait"
version = "0.1.42"
version = "0.1.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d"
checksum = "36ea56748e10732c49404c153638a15ec3d6211ec5ff35d9bb20e13b93576adf"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -161,9 +161,9 @@ checksum = "bed57e2090563b83ba8f83366628ce535a7584c9afa4c9fc0612a03925c6df58"
[[package]]
name = "byteorder"
version = "1.4.2"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "bytes"
@ -328,7 +328,7 @@ checksum = "7606b05842fea68ddcc89e8053b8860ebcb2a0ba8d6abfe3a148e5d5a8d3f0c1"
dependencies = [
"com_macros_support",
"proc-macro2",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -339,7 +339,7 @@ checksum = "97e9a6d20f4ac8830e309a455d7e9416e65c6af5a97c88c55fbb4c2012e107da"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -514,7 +514,7 @@ dependencies = [
"proc-macro2",
"quote 1.0.9",
"strsim",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -525,7 +525,7 @@ checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72"
dependencies = [
"darling_core",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -546,7 +546,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -650,7 +650,7 @@ checksum = "946ee94e3dbf58fdd324f9ce245c7b238d46a66f00e86a020b71996349e46cce"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -805,7 +805,7 @@ dependencies = [
"proc-macro-hack",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -1003,7 +1003,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -1215,9 +1215,9 @@ dependencies = [
[[package]]
name = "image"
version = "0.23.13"
version = "0.23.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "293f07a1875fa7e9c5897b51aa68b2d8ed8271b87e1a44cb64b9c3d98aabbc0d"
checksum = "24ffcb7e7244a9bf19d35bf2883b9c080c4ced3c07a9895572178cdb8f13f6a1"
dependencies = [
"bytemuck",
"byteorder",
@ -1234,9 +1234,9 @@ dependencies = [
[[package]]
name = "indexmap"
version = "1.6.1"
version = "1.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b"
checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
dependencies = [
"autocfg",
"hashbrown",
@ -1354,9 +1354,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.86"
version = "0.2.88"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c"
checksum = "03b07a082330a35e43f63177cc01689da34fbffa0105e1246cf0311472cac73a"
[[package]]
name = "libloading"
@ -1618,7 +1618,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -1778,7 +1778,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -1812,9 +1812,19 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.7.0"
version = "1.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10acf907b94fc1b1a152d08ef97e7759650268cf986bf127f387e602b02c7e5a"
checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3"
[[package]]
name = "open"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7e9f1bdf15cd1f5a00cc9002a733a6ee6d0ff562491852d59652471c4a389f7"
dependencies = [
"which",
"winapi 0.3.9",
]
[[package]]
name = "openssl"
@ -1963,7 +1973,7 @@ dependencies = [
"proc-macro-hack",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -1992,14 +2002,14 @@ checksum = "758669ae3558c6f74bd2a18b41f7ac0b5a195aea6639d6a9b5e5d1ad5ba24c0b"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
name = "pin-project-lite"
version = "0.2.4"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827"
checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905"
[[package]]
name = "pin-utils"
@ -2062,7 +2072,7 @@ dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
"version_check",
]
@ -2285,9 +2295,9 @@ dependencies = [
[[package]]
name = "reqwest"
version = "0.11.1"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0460542b551950620a3648c6aa23318ac6b3cd779114bd873209e6e8b5eb1c34"
checksum = "bf12057f289428dbf5c591c74bf10392e4a8003f993405a902f20117019022d4"
dependencies = [
"base64",
"bytes",
@ -2407,9 +2417,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "security-framework"
version = "2.1.1"
version = "2.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dfd318104249865096c8da1dfabf09ddbb6d0330ea176812a62ec75e40c4166"
checksum = "d493c5f39e02dfb062cd8f33301f90f9b13b650e8c1b1d0fd75c19dd64bff69d"
dependencies = [
"bitflags 1.2.1",
"core-foundation 0.9.1",
@ -2448,22 +2458,22 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.123"
version = "1.0.124"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae"
checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.123"
version = "1.0.124"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31"
checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -2485,7 +2495,7 @@ checksum = "2dc6b7951b17b051f3210b063f12cc17320e2fe30ae05b0fe2a3abb068551c76"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -2520,9 +2530,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
name = "smithay-client-toolkit"
version = "0.12.2"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "316e13a3eb853ce7bf72ad3530dc186cb2005c57c521ef5f4ada5ee4eed74de6"
checksum = "4750c76fd5d3ac95fa3ed80fe667d6a3d8590a960e5b575b98eea93339a80b80"
dependencies = [
"andrew",
"bitflags 1.2.1",
@ -2606,7 +2616,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -2618,7 +2628,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -2634,9 +2644,9 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.60"
version = "1.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081"
checksum = "8fd9bc7ccc2688b3344c2f48b9b546648b25ce0b20fc717ee7fa7981a8ca9717"
dependencies = [
"proc-macro2",
"quote 1.0.9",
@ -2711,7 +2721,6 @@ dependencies = [
"thiserror",
"tokio",
"uuid",
"webbrowser",
"wry",
]
@ -2726,6 +2735,7 @@ dependencies = [
"http",
"notify-rust",
"once_cell",
"open",
"rand 0.8.3",
"reqwest",
"rfd",
@ -2776,7 +2786,7 @@ dependencies = [
"quote 1.0.9",
"serde",
"serde_json",
"syn 1.0.60",
"syn 1.0.63",
"tauri-utils",
"walkdir",
]
@ -2824,7 +2834,7 @@ checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -2875,9 +2885,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "1.2.0"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8190d04c665ea9e6b6a0dc45523ade572c088d2e6566244c1122671dbf4ae3a"
checksum = "8d56477f6ed99e10225f38f9f75f872f29b8b8bd8c0b946f63345bb144e9eeda"
dependencies = [
"autocfg",
"bytes",
@ -2900,9 +2910,9 @@ dependencies = [
[[package]]
name = "tokio-util"
version = "0.6.3"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebb7cb2f00c5ae8df755b252306272cd1790d39728363936e01827e11f0b017b"
checksum = "ec31e5cc6b46e653cf57762f36f71d5e6386391d88a72fd6db4508f8f676fb29"
dependencies = [
"bytes",
"futures-core",
@ -3123,7 +3133,7 @@ dependencies = [
"log",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
"wasm-bindgen-shared",
]
@ -3157,7 +3167,7 @@ checksum = "cc053ec74d454df287b9374ee8abb36ffd5acb95ba87da3ba5b7d3fe20eb401e"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@ -3251,17 +3261,6 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "webbrowser"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecad156490d6b620308ed411cfee90d280b3cbd13e189ea0d3fada8acc89158a"
dependencies = [
"web-sys",
"widestring",
"winapi 0.3.9",
]
[[package]]
name = "webkit2gtk"
version = "0.11.0"
@ -3344,6 +3343,16 @@ dependencies = [
"cc",
]
[[package]]
name = "which"
version = "4.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef"
dependencies = [
"libc",
"thiserror",
]
[[package]]
name = "widestring"
version = "0.4.3"
@ -3466,8 +3475,8 @@ dependencies = [
[[package]]
name = "wry"
version = "0.5.1"
source = "git+https://github.com/tauri-apps/wry?rev=729fdc182eaf4af44d822dfc9396deb3f5f5810a#729fdc182eaf4af44d822dfc9396deb3f5f5810a"
version = "0.6.0"
source = "git+https://github.com/tauri-apps/wry?rev=39575983dbd128fbbcde933d742b33b691fd1def#39575983dbd128fbbcde933d742b33b691fd1def"
dependencies = [
"cairo-rs",
"cocoa",
@ -3586,7 +3595,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -3624,5 +3633,5 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]

View File

@ -79,13 +79,13 @@ dependencies = [
[[package]]
name = "async-trait"
version = "0.1.42"
version = "0.1.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d"
checksum = "36ea56748e10732c49404c153638a15ec3d6211ec5ff35d9bb20e13b93576adf"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -169,9 +169,9 @@ checksum = "bed57e2090563b83ba8f83366628ce535a7584c9afa4c9fc0612a03925c6df58"
[[package]]
name = "byteorder"
version = "1.4.2"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "bytes"
@ -336,7 +336,7 @@ checksum = "7606b05842fea68ddcc89e8053b8860ebcb2a0ba8d6abfe3a148e5d5a8d3f0c1"
dependencies = [
"com_macros_support",
"proc-macro2",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -347,7 +347,7 @@ checksum = "97e9a6d20f4ac8830e309a455d7e9416e65c6af5a97c88c55fbb4c2012e107da"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -522,7 +522,7 @@ dependencies = [
"proc-macro2",
"quote 1.0.9",
"strsim",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -533,7 +533,7 @@ checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72"
dependencies = [
"darling_core",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -554,7 +554,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -658,7 +658,7 @@ checksum = "946ee94e3dbf58fdd324f9ce245c7b238d46a66f00e86a020b71996349e46cce"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -813,7 +813,7 @@ dependencies = [
"proc-macro-hack",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -1011,7 +1011,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -1213,9 +1213,9 @@ dependencies = [
[[package]]
name = "image"
version = "0.23.13"
version = "0.23.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "293f07a1875fa7e9c5897b51aa68b2d8ed8271b87e1a44cb64b9c3d98aabbc0d"
checksum = "24ffcb7e7244a9bf19d35bf2883b9c080c4ced3c07a9895572178cdb8f13f6a1"
dependencies = [
"bytemuck",
"byteorder",
@ -1232,9 +1232,9 @@ dependencies = [
[[package]]
name = "indexmap"
version = "1.6.1"
version = "1.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b"
checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
dependencies = [
"autocfg",
"hashbrown",
@ -1352,9 +1352,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.86"
version = "0.2.88"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c"
checksum = "03b07a082330a35e43f63177cc01689da34fbffa0105e1246cf0311472cac73a"
[[package]]
name = "libloading"
@ -1616,7 +1616,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -1776,7 +1776,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -1810,9 +1810,19 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.7.0"
version = "1.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10acf907b94fc1b1a152d08ef97e7759650268cf986bf127f387e602b02c7e5a"
checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3"
[[package]]
name = "open"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7e9f1bdf15cd1f5a00cc9002a733a6ee6d0ff562491852d59652471c4a389f7"
dependencies = [
"which",
"winapi 0.3.9",
]
[[package]]
name = "openssl"
@ -1961,7 +1971,7 @@ dependencies = [
"proc-macro-hack",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -1990,14 +2000,14 @@ checksum = "758669ae3558c6f74bd2a18b41f7ac0b5a195aea6639d6a9b5e5d1ad5ba24c0b"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
name = "pin-project-lite"
version = "0.2.4"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827"
checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905"
[[package]]
name = "pin-utils"
@ -2060,7 +2070,7 @@ dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
"version_check",
]
@ -2283,9 +2293,9 @@ dependencies = [
[[package]]
name = "reqwest"
version = "0.11.1"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0460542b551950620a3648c6aa23318ac6b3cd779114bd873209e6e8b5eb1c34"
checksum = "bf12057f289428dbf5c591c74bf10392e4a8003f993405a902f20117019022d4"
dependencies = [
"base64",
"bytes",
@ -2405,9 +2415,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "security-framework"
version = "2.1.1"
version = "2.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dfd318104249865096c8da1dfabf09ddbb6d0330ea176812a62ec75e40c4166"
checksum = "d493c5f39e02dfb062cd8f33301f90f9b13b650e8c1b1d0fd75c19dd64bff69d"
dependencies = [
"bitflags 1.2.1",
"core-foundation 0.9.1",
@ -2446,22 +2456,22 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.123"
version = "1.0.124"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae"
checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.123"
version = "1.0.124"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31"
checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -2483,7 +2493,7 @@ checksum = "2dc6b7951b17b051f3210b063f12cc17320e2fe30ae05b0fe2a3abb068551c76"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -2518,9 +2528,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
name = "smithay-client-toolkit"
version = "0.12.2"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "316e13a3eb853ce7bf72ad3530dc186cb2005c57c521ef5f4ada5ee4eed74de6"
checksum = "4750c76fd5d3ac95fa3ed80fe667d6a3d8590a960e5b575b98eea93339a80b80"
dependencies = [
"andrew",
"bitflags 1.2.1",
@ -2604,7 +2614,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -2616,7 +2626,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -2632,9 +2642,9 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.60"
version = "1.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081"
checksum = "8fd9bc7ccc2688b3344c2f48b9b546648b25ce0b20fc717ee7fa7981a8ca9717"
dependencies = [
"proc-macro2",
"quote 1.0.9",
@ -2709,7 +2719,6 @@ dependencies = [
"thiserror",
"tokio",
"uuid",
"webbrowser",
"wry",
]
@ -2724,6 +2733,7 @@ dependencies = [
"http",
"notify-rust",
"once_cell",
"open",
"rand 0.8.3",
"reqwest",
"rfd",
@ -2774,7 +2784,7 @@ dependencies = [
"quote 1.0.9",
"serde",
"serde_json",
"syn 1.0.60",
"syn 1.0.63",
"tauri-utils",
"walkdir",
]
@ -2822,7 +2832,7 @@ checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -2873,9 +2883,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "1.2.0"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8190d04c665ea9e6b6a0dc45523ade572c088d2e6566244c1122671dbf4ae3a"
checksum = "8d56477f6ed99e10225f38f9f75f872f29b8b8bd8c0b946f63345bb144e9eeda"
dependencies = [
"autocfg",
"bytes",
@ -2898,9 +2908,9 @@ dependencies = [
[[package]]
name = "tokio-util"
version = "0.6.3"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebb7cb2f00c5ae8df755b252306272cd1790d39728363936e01827e11f0b017b"
checksum = "ec31e5cc6b46e653cf57762f36f71d5e6386391d88a72fd6db4508f8f676fb29"
dependencies = [
"bytes",
"futures-core",
@ -3121,7 +3131,7 @@ dependencies = [
"log",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
"wasm-bindgen-shared",
]
@ -3155,7 +3165,7 @@ checksum = "cc053ec74d454df287b9374ee8abb36ffd5acb95ba87da3ba5b7d3fe20eb401e"
dependencies = [
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@ -3249,17 +3259,6 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "webbrowser"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecad156490d6b620308ed411cfee90d280b3cbd13e189ea0d3fada8acc89158a"
dependencies = [
"web-sys",
"widestring",
"winapi 0.3.9",
]
[[package]]
name = "webkit2gtk"
version = "0.11.0"
@ -3342,6 +3341,16 @@ dependencies = [
"cc",
]
[[package]]
name = "which"
version = "4.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef"
dependencies = [
"libc",
"thiserror",
]
[[package]]
name = "widestring"
version = "0.4.3"
@ -3464,8 +3473,8 @@ dependencies = [
[[package]]
name = "wry"
version = "0.5.1"
source = "git+https://github.com/tauri-apps/wry?rev=729fdc182eaf4af44d822dfc9396deb3f5f5810a#729fdc182eaf4af44d822dfc9396deb3f5f5810a"
version = "0.6.0"
source = "git+https://github.com/tauri-apps/wry?rev=39575983dbd128fbbcde933d742b33b691fd1def#39575983dbd128fbbcde933d742b33b691fd1def"
dependencies = [
"cairo-rs",
"cocoa",
@ -3584,7 +3593,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]
[[package]]
@ -3622,5 +3631,5 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote 1.0.9",
"syn 1.0.60",
"syn 1.0.63",
]

View File

@ -15,8 +15,8 @@ mod webview_manager;
pub use crate::api::config::WindowUrl;
use crate::flavors::Wry;
pub use webview::{
wry::WryApplication, ApplicationDispatcherExt, ApplicationExt, CustomProtocol, Icon, Message,
RpcRequest, WebviewBuilderExt, WebviewRpcHandler,
wry::WryApplication, ApplicationDispatcherExt, ApplicationExt, CustomProtocol, FileDropEvent,
FileDropHandler, Icon, Message, RpcRequest, WebviewBuilderExt, WebviewRpcHandler,
};
pub use webview_manager::{WebviewDispatcher, WebviewManager};
@ -165,6 +165,7 @@ trait WebviewInitializer<A: ApplicationExt> {
<A as ApplicationExt>::WebviewBuilder,
Option<WebviewRpcHandler<A::Dispatcher>>,
Option<CustomProtocol>,
Option<FileDropHandler>,
)>;
async fn on_webview_created(
@ -184,13 +185,14 @@ impl<A: ApplicationExt + 'static> WebviewInitializer<A> for Arc<App<A>> {
<A as ApplicationExt>::WebviewBuilder,
Option<WebviewRpcHandler<A::Dispatcher>>,
Option<CustomProtocol>,
Option<FileDropHandler>,
)> {
let webview_manager = WebviewManager::new(
self.clone(),
self.dispatchers.clone(),
webview.label.to_string(),
);
utils::build_webview(
let (webview_builder, rpc_handler, custom_protocol) = utils::build_webview(
self.clone(),
webview,
&webview_manager,
@ -198,7 +200,25 @@ impl<A: ApplicationExt + 'static> WebviewInitializer<A> for Arc<App<A>> {
&self.window_labels.lock().await,
&self.plugin_initialization_script,
&self.context,
)
)?;
let file_drop_handler: Box<dyn Fn(FileDropEvent) -> bool + Send> = Box::new(move |event| {
let webview_manager = webview_manager.clone();
crate::async_runtime::block_on(async move {
let webview = webview_manager.current_webview().await.unwrap();
let _ = match event {
FileDropEvent::Hovered(paths) => webview.emit("tauri://file-drop-hover", Some(paths)),
FileDropEvent::Dropped(paths) => webview.emit("tauri://file-drop", Some(paths)),
FileDropEvent::Cancelled => webview.emit("tauri://file-drop-cancelled", Some(())),
};
});
true
});
Ok((
webview_builder,
rpc_handler,
custom_protocol,
Some(file_drop_handler),
))
}
async fn on_webview_created(
@ -362,10 +382,15 @@ fn run<A: ApplicationExt + 'static>(mut application: App<A>) -> crate::Result<()
if main_webview_manager.is_none() {
main_webview_manager = Some(webview_manager.clone());
}
let (webview_builder, rpc_handler, custom_protocol) =
let (webview_builder, rpc_handler, custom_protocol, file_drop_handler) =
crate::async_runtime::block_on(application.init_webview(webview))?;
let dispatcher = webview_app.create_webview(webview_builder, rpc_handler, custom_protocol)?;
let dispatcher = webview_app.create_webview(
webview_builder,
rpc_handler,
custom_protocol,
file_drop_handler,
)?;
crate::async_runtime::block_on(application.on_webview_created(
webview_label,
dispatcher,

View File

@ -1,6 +1,7 @@
pub mod wry;
use crate::plugin::PluginStore;
use std::path::PathBuf;
use serde_json::Value as JsonValue;
@ -176,6 +177,21 @@ pub struct CustomProtocol {
pub handler: Box<dyn Fn(&str) -> crate::Result<Vec<u8>> + Send + Sync>,
}
/// The file drop event payload.
#[derive(Debug, Clone)]
pub enum FileDropEvent {
/// The file(s) have been dragged onto the window, but have not been dropped yet.
Hovered(Vec<PathBuf>),
/// The file(s) have been dropped onto the window.
Dropped(Vec<PathBuf>),
/// The file drop was aborted.
Cancelled,
}
/// File drop handler callback
/// Return `true` in the callback to block the OS' default behavior of handling a file drop..
pub type FileDropHandler = Box<dyn Fn(FileDropEvent) -> bool + Send>;
/// Webview dispatcher. A thread-safe handle to the webview API.
pub trait ApplicationDispatcherExt: Clone + Send + Sync + Sized {
/// The webview builder type.
@ -190,6 +206,7 @@ pub trait ApplicationDispatcherExt: Clone + Send + Sync + Sized {
webview_builder: Self::WebviewBuilder,
rpc_handler: Option<WebviewRpcHandler<Self>>,
custom_protocol: Option<CustomProtocol>,
file_drop_handler: Option<FileDropHandler>,
) -> crate::Result<Self>;
/// Updates the window resizable flag.
@ -283,6 +300,7 @@ pub trait ApplicationExt: Sized {
webview_builder: Self::WebviewBuilder,
rpc_handler: Option<WebviewRpcHandler<Self::Dispatcher>>,
custom_protocol: Option<CustomProtocol>,
file_drop_handler: Option<FileDropHandler>,
) -> crate::Result<Self::Dispatcher>;
/// Run the application.

View File

@ -1,6 +1,6 @@
use super::{
ApplicationDispatcherExt, ApplicationExt, CustomProtocol, Icon, RpcRequest, WebviewBuilderExt,
WebviewBuilderExtPrivate, WebviewRpcHandler, WindowConfig,
ApplicationDispatcherExt, ApplicationExt, CustomProtocol, FileDropEvent, FileDropHandler, Icon,
RpcRequest, WebviewBuilderExt, WebviewBuilderExtPrivate, WebviewRpcHandler, WindowConfig,
};
use once_cell::sync::Lazy;
@ -186,6 +186,16 @@ impl From<wry::RpcRequest> for RpcRequest {
}
}
impl From<wry::FileDropEvent> for FileDropEvent {
fn from(event: wry::FileDropEvent) -> Self {
match event {
wry::FileDropEvent::Hovered(paths) => FileDropEvent::Hovered(paths),
wry::FileDropEvent::Dropped(paths) => FileDropEvent::Dropped(paths),
wry::FileDropEvent::Cancelled => FileDropEvent::Cancelled,
}
}
}
#[derive(Clone)]
pub struct WryDispatcher(
Arc<Mutex<wry::WindowProxy>>,
@ -200,6 +210,7 @@ impl ApplicationDispatcherExt for WryDispatcher {
attributes: Self::WebviewBuilder,
rpc_handler: Option<WebviewRpcHandler<Self>>,
custom_protocol: Option<CustomProtocol>,
file_drop_handler: Option<FileDropHandler>,
) -> crate::Result<Self> {
let app_dispatcher = self.1.clone();
@ -215,6 +226,14 @@ impl ApplicationDispatcherExt for WryDispatcher {
},
);
let file_drop_handler = Box::new(move |event: wry::FileDropEvent| {
if let Some(handler) = &file_drop_handler {
handler(event.into())
} else {
false
}
});
let window_dispatcher = self
.1
.lock()
@ -226,6 +245,7 @@ impl ApplicationDispatcherExt for WryDispatcher {
name: p.name.clone(),
handler: Box::new(move |a| (*p.handler)(a).map_err(|_| wry::Error::InitScriptError)),
}),
Some(file_drop_handler),
)
.map_err(|_| crate::Error::FailedToSendMessage)?;
Ok(Self(
@ -457,6 +477,7 @@ impl ApplicationExt for WryApplication {
webview_builder: Self::WebviewBuilder,
rpc_handler: Option<WebviewRpcHandler<Self::Dispatcher>>,
custom_protocol: Option<CustomProtocol>,
file_drop_handler: Option<FileDropHandler>,
) -> crate::Result<Self::Dispatcher> {
let app_dispatcher = Arc::new(Mutex::new(self.inner.application_proxy()));
@ -473,6 +494,14 @@ impl ApplicationExt for WryApplication {
},
);
let file_drop_handler = Box::new(move |event: wry::FileDropEvent| {
if let Some(handler) = &file_drop_handler {
handler(event.into())
} else {
false
}
});
let dispatcher = self
.inner
.add_window_with_configs(
@ -482,6 +511,7 @@ impl ApplicationExt for WryApplication {
name: p.name.clone(),
handler: Box::new(move |a| (*p.handler)(a).map_err(|_| wry::Error::InitScriptError)),
}),
Some(file_drop_handler),
)
.map_err(|_| crate::Error::CreateWebview)?;
Ok(WryDispatcher(

View File

@ -250,13 +250,14 @@ impl<A: ApplicationExt + 'static> WebviewManager<A> {
.lock()
.await
.push(label.to_string());
let (webview_builder, rpc_handler, custom_protocol) =
let (webview_builder, rpc_handler, custom_protocol, file_drop_handler) =
self.application.init_webview(webview).await?;
let window_dispatcher = self.current_webview().await?.dispatcher.create_webview(
webview_builder,
rpc_handler,
custom_protocol,
file_drop_handler,
)?;
let webview_manager = Self::new(
self.application.clone(),