feat: use tauri `next` branch, fix tests, MSRV 1.65 (#354)

pull/357/head
Lucas Fernandes Nogueira 2 years ago committed by GitHub
parent e0e7b4fc71
commit 937e6a5be6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -43,6 +43,10 @@ jobs:
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: create dummy dist
working-directory: examples/api
run: mkdir dist
- name: clippy - name: clippy
run: cargo clippy --workspace --exclude 'tauri-plugin-sql' --all-targets --all-features -- -D warnings run: cargo clippy --workspace --exclude 'tauri-plugin-sql' --all-targets --all-features -- -D warnings

@ -38,10 +38,14 @@ jobs:
sudo apt-get update sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libudev-dev sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libudev-dev
- uses: dtolnay/rust-toolchain@1.64.0 - uses: dtolnay/rust-toolchain@1.65.0
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- name: create dummy dist
working-directory: examples/api
run: mkdir dist
- name: build - name: build
run: cargo build --workspace --exclude 'tauri-plugin-sql' --all-targets --all-features run: cargo build --workspace --exclude 'tauri-plugin-sql' --all-targets --all-features

@ -3,3 +3,4 @@ node_modules
dist dist
pnpm-lock.yaml pnpm-lock.yaml
Cargo.lock Cargo.lock
.build

466
Cargo.lock generated

@ -17,6 +17,16 @@ dependencies = [
"generic-array", "generic-array",
] ]
[[package]]
name = "aead"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0"
dependencies = [
"crypto-common",
"generic-array",
]
[[package]] [[package]]
name = "aes" name = "aes"
version = "0.7.5" version = "0.7.5"
@ -24,22 +34,47 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"cipher", "cipher 0.3.0",
"cpufeatures", "cpufeatures",
"opaque-debug", "opaque-debug",
] ]
[[package]]
name = "aes"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241"
dependencies = [
"cfg-if",
"cipher 0.4.4",
"cpufeatures",
]
[[package]] [[package]]
name = "aes-gcm" name = "aes-gcm"
version = "0.9.4" version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6"
dependencies = [ dependencies = [
"aead", "aead 0.4.3",
"aes", "aes 0.7.5",
"cipher", "cipher 0.3.0",
"ctr", "ctr 0.8.0",
"ghash", "ghash 0.4.4",
"subtle",
]
[[package]]
name = "aes-gcm"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82e1366e0c69c9f927b1fa5ce2c7bf9eafc8f9268c0b9800729e8b267612447c"
dependencies = [
"aead 0.5.2",
"aes 0.8.2",
"cipher 0.4.4",
"ctr 0.9.2",
"ghash 0.5.0",
"subtle", "subtle",
] ]
@ -169,6 +204,46 @@ version = "1.0.70"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4"
[[package]]
name = "api"
version = "0.1.0"
dependencies = [
"log",
"serde",
"serde_json",
"tauri",
"tauri-build",
"tauri-plugin-app",
"tauri-plugin-cli",
"tauri-plugin-clipboard",
"tauri-plugin-dialog",
"tauri-plugin-fs",
"tauri-plugin-global-shortcut",
"tauri-plugin-http",
"tauri-plugin-log",
"tauri-plugin-notification",
"tauri-plugin-os",
"tauri-plugin-process",
"tauri-plugin-shell",
"tauri-plugin-updater",
"tauri-plugin-window",
"tiny_http 0.11.0",
"window-shadows",
]
[[package]]
name = "app-updater"
version = "0.1.0"
dependencies = [
"serde",
"serde_json",
"tauri",
"tauri-build",
"tauri-plugin-updater",
"time 0.3.20",
"tiny_http 0.11.0",
]
[[package]] [[package]]
name = "arboard" name = "arboard"
version = "3.2.0" version = "3.2.0"
@ -207,6 +282,16 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16"
[[package]]
name = "assert-json-diff"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12"
dependencies = [
"serde",
"serde_json",
]
[[package]] [[package]]
name = "async-broadcast" name = "async-broadcast"
version = "0.5.1" version = "0.5.1"
@ -294,6 +379,28 @@ dependencies = [
"syn 2.0.13", "syn 2.0.13",
] ]
[[package]]
name = "async-stream"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51"
dependencies = [
"async-stream-impl",
"futures-core",
"pin-project-lite",
]
[[package]]
name = "async-stream-impl"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.13",
]
[[package]] [[package]]
name = "async-task" name = "async-task"
version = "4.4.0" version = "4.4.0"
@ -604,12 +711,12 @@ dependencies = [
[[package]] [[package]]
name = "cargo_toml" name = "cargo_toml"
version = "0.14.1" version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bfbc36312494041e2cdd5f06697b7e89d4b76f42773a0b5556ac290ff22acc2" checksum = "7f83bc2e401ed041b7057345ebc488c005efa0341d5541ce7004d30458d0090b"
dependencies = [ dependencies = [
"serde", "serde",
"toml 0.5.11", "toml 0.7.3",
] ]
[[package]] [[package]]
@ -657,7 +764,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"cipher", "cipher 0.3.0",
"cpufeatures", "cpufeatures",
"zeroize", "zeroize",
] ]
@ -668,9 +775,9 @@ version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5"
dependencies = [ dependencies = [
"aead", "aead 0.4.3",
"chacha20", "chacha20",
"cipher", "cipher 0.3.0",
"poly1305", "poly1305",
"zeroize", "zeroize",
] ]
@ -685,6 +792,7 @@ dependencies = [
"js-sys", "js-sys",
"num-integer", "num-integer",
"num-traits", "num-traits",
"serde",
"time 0.1.45", "time 0.1.45",
"wasm-bindgen", "wasm-bindgen",
"winapi", "winapi",
@ -705,6 +813,16 @@ dependencies = [
"generic-array", "generic-array",
] ]
[[package]]
name = "cipher"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
dependencies = [
"crypto-common",
"inout",
]
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.2.2" version = "4.2.2"
@ -808,6 +926,17 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "colored"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd"
dependencies = [
"atty",
"lazy_static",
"winapi",
]
[[package]] [[package]]
name = "combine" name = "combine"
version = "4.6.6" version = "4.6.6"
@ -971,6 +1100,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
dependencies = [ dependencies = [
"generic-array", "generic-array",
"rand_core 0.6.4",
"typenum", "typenum",
] ]
@ -1017,7 +1147,16 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea"
dependencies = [ dependencies = [
"cipher", "cipher 0.3.0",
]
[[package]]
name = "ctr"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835"
dependencies = [
"cipher 0.4.4",
] ]
[[package]] [[package]]
@ -1079,9 +1218,9 @@ dependencies = [
[[package]] [[package]]
name = "darling" name = "darling"
version = "0.13.4" version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850"
dependencies = [ dependencies = [
"darling_core", "darling_core",
"darling_macro", "darling_macro",
@ -1089,9 +1228,9 @@ dependencies = [
[[package]] [[package]]
name = "darling_core" name = "darling_core"
version = "0.13.4" version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0"
dependencies = [ dependencies = [
"fnv", "fnv",
"ident_case", "ident_case",
@ -1103,9 +1242,9 @@ dependencies = [
[[package]] [[package]]
name = "darling_macro" name = "darling_macro"
version = "0.13.4" version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e"
dependencies = [ dependencies = [
"darling_core", "darling_core",
"quote", "quote",
@ -1369,7 +1508,7 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9f0c14694cbd524c8720dd69b0e3179344f04ebb5f90f2e4a440c6ea3b2f1ee" checksum = "d9f0c14694cbd524c8720dd69b0e3179344f04ebb5f90f2e4a440c6ea3b2f1ee"
dependencies = [ dependencies = [
"colored", "colored 1.9.3",
"log", "log",
] ]
@ -1740,7 +1879,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99"
dependencies = [ dependencies = [
"opaque-debug", "opaque-debug",
"polyval", "polyval 0.5.3",
]
[[package]]
name = "ghash"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40"
dependencies = [
"opaque-debug",
"polyval 0.6.0",
] ]
[[package]] [[package]]
@ -2103,6 +2252,19 @@ dependencies = [
"want", "want",
] ]
[[package]]
name = "hyper-rustls"
version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c"
dependencies = [
"http",
"hyper",
"rustls",
"tokio",
"tokio-rustls",
]
[[package]] [[package]]
name = "hyper-tls" name = "hyper-tls"
version = "0.5.0" version = "0.5.0"
@ -2216,6 +2378,7 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"hashbrown", "hashbrown",
"serde",
] ]
[[package]] [[package]]
@ -2256,6 +2419,15 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "inout"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5"
dependencies = [
"generic-array",
]
[[package]] [[package]]
name = "instant" name = "instant"
version = "0.1.12" version = "0.1.12"
@ -2282,9 +2454,9 @@ version = "0.15.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e04d492224bff6e97142f033d0a4383bcbc05918be1ff7b3abd2c1cc85205a2" checksum = "4e04d492224bff6e97142f033d0a4383bcbc05918be1ff7b3abd2c1cc85205a2"
dependencies = [ dependencies = [
"aead", "aead 0.4.3",
"aes", "aes 0.7.5",
"aes-gcm", "aes-gcm 0.9.4",
"autocfg", "autocfg",
"blake2", "blake2",
"chacha20poly1305", "chacha20poly1305",
@ -2456,9 +2628,9 @@ dependencies = [
[[package]] [[package]]
name = "json-patch" name = "json-patch"
version = "0.3.0" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e712e62827c382a77b87f590532febb1f8b2fdbc3eefa1ee37fe7281687075ef" checksum = "1f54898088ccb91df1b492cc80029a6fdf1c48ca0db7c6822a8babad69c94658"
dependencies = [ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
@ -2771,12 +2943,28 @@ version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
[[package]]
name = "mime_guess"
version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
dependencies = [
"mime",
"unicase",
]
[[package]] [[package]]
name = "minimal-lexical" name = "minimal-lexical"
version = "0.2.1" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "minisign-verify"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "933dca44d65cdd53b355d0b73d380a2ff5da71f87f036053188bf1eab6a19881"
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"
version = "0.6.2" version = "0.6.2"
@ -2798,6 +2986,24 @@ dependencies = [
"windows-sys 0.45.0", "windows-sys 0.45.0",
] ]
[[package]]
name = "mockito"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80f9fece9bd97ab74339fe19f4bcaf52b76dcc18e5364c7977c1838f76b38de9"
dependencies = [
"assert-json-diff",
"colored 2.0.0",
"httparse",
"lazy_static",
"log",
"rand 0.8.5",
"regex",
"serde_json",
"serde_urlencoded",
"similar",
]
[[package]] [[package]]
name = "native-tls" name = "native-tls"
version = "0.2.11" version = "0.2.11"
@ -3148,6 +3354,15 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-src"
version = "111.25.3+1.1.1t"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "924757a6a226bf60da5f7dd0311a34d2b52283dd82ddeb103208ddc66362f80c"
dependencies = [
"cc",
]
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.84" version = "0.9.84"
@ -3156,6 +3371,7 @@ checksum = "3a20eace9dc2d82904039cb76dcf50fb1a0bba071cfd1629720b5d6f1ddba0fa"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",
"openssl-src",
"pkg-config", "pkg-config",
"vcpkg", "vcpkg",
] ]
@ -3521,7 +3737,7 @@ checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede"
dependencies = [ dependencies = [
"cpufeatures", "cpufeatures",
"opaque-debug", "opaque-debug",
"universal-hash", "universal-hash 0.4.1",
] ]
[[package]] [[package]]
@ -3533,7 +3749,19 @@ dependencies = [
"cfg-if", "cfg-if",
"cpufeatures", "cpufeatures",
"opaque-debug", "opaque-debug",
"universal-hash", "universal-hash 0.4.1",
]
[[package]]
name = "polyval"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ef234e08c11dfcb2e56f79fd70f6f2eb7f025c0ce2333e82f4f0518ecad30c6"
dependencies = [
"cfg-if",
"cpufeatures",
"opaque-debug",
"universal-hash 0.5.0",
] ]
[[package]] [[package]]
@ -3798,20 +4026,25 @@ dependencies = [
"http", "http",
"http-body", "http-body",
"hyper", "hyper",
"hyper-rustls",
"hyper-tls", "hyper-tls",
"ipnet", "ipnet",
"js-sys", "js-sys",
"log", "log",
"mime", "mime",
"mime_guess",
"native-tls", "native-tls",
"once_cell", "once_cell",
"percent-encoding", "percent-encoding",
"pin-project-lite", "pin-project-lite",
"rustls",
"rustls-pemfile",
"serde", "serde",
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
"tokio", "tokio",
"tokio-native-tls", "tokio-native-tls",
"tokio-rustls",
"tokio-util", "tokio-util",
"tower-service", "tower-service",
"url", "url",
@ -3819,6 +4052,7 @@ dependencies = [
"wasm-bindgen-futures", "wasm-bindgen-futures",
"wasm-streams", "wasm-streams",
"web-sys", "web-sys",
"webpki-roots",
"winreg", "winreg",
] ]
@ -4137,19 +4371,25 @@ dependencies = [
[[package]] [[package]]
name = "serde_with" name = "serde_with"
version = "1.14.0" version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" checksum = "331bb8c3bf9b92457ab7abecf07078c13f7d270ba490103e84e8b014490cd0b0"
dependencies = [ dependencies = [
"base64 0.13.1",
"chrono",
"hex",
"indexmap",
"serde", "serde",
"serde_json",
"serde_with_macros", "serde_with_macros",
"time 0.3.20",
] ]
[[package]] [[package]]
name = "serde_with_macros" name = "serde_with_macros"
version = "1.5.2" version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" checksum = "859011bddcc11f289f07f467cc1fe01c7a941daa4d8f6c40d4d1c92eb6d9319c"
dependencies = [ dependencies = [
"darling", "darling",
"proc-macro2", "proc-macro2",
@ -4243,6 +4483,12 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "similar"
version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf"
[[package]] [[package]]
name = "siphasher" name = "siphasher"
version = "0.3.10" version = "0.3.10"
@ -4642,9 +4888,9 @@ dependencies = [
[[package]] [[package]]
name = "tao" name = "tao"
version = "0.18.3" version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f2340617d383561b0ea25358b97ec2c2ba04db48c458ce71dd1b38d7fd09ac5" checksum = "746ae5d0ca57ae275a792f109f6e992e0b41a443abdf3f5c6eff179ef5b3443a"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"cairo-rs", "cairo-rs",
@ -4714,8 +4960,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri" name = "tauri"
version = "2.0.0-alpha.8" version = "2.0.0-alpha.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/tauri-apps/tauri?branch=next#9a79dc085870e0c1a5df13481ff271b8c6cc3b78"
checksum = "f25eefe4ca0a396a73fd0309f778eeb22a19953a3169bf316b893abadc2118fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes 1.4.0", "bytes 1.4.0",
@ -4758,29 +5003,32 @@ dependencies = [
"tauri-utils", "tauri-utils",
"tempfile", "tempfile",
"thiserror", "thiserror",
"time 0.3.20",
"tokio", "tokio",
"url", "url",
"uuid", "uuid",
"webkit2gtk", "webkit2gtk",
"webview2-com", "webview2-com",
"windows 0.44.0", "windows 0.44.0",
"zip",
] ]
[[package]] [[package]]
name = "tauri-build" name = "tauri-build"
version = "2.0.0-alpha.4" version = "2.0.0-alpha.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/tauri-apps/tauri?branch=next#9a79dc085870e0c1a5df13481ff271b8c6cc3b78"
checksum = "c492211c72b95f8866e5c1fbc0a915080a5ebb9f03f9b250a1c936534b680a76"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cargo_toml", "cargo_toml",
"filetime", "filetime",
"heck 0.4.1", "heck 0.4.1",
"json-patch", "json-patch",
"quote",
"semver", "semver",
"serde", "serde",
"serde_json", "serde_json",
"swift-rs", "swift-rs",
"tauri-codegen",
"tauri-utils", "tauri-utils",
"tauri-winres", "tauri-winres",
"walkdir", "walkdir",
@ -4789,8 +5037,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-codegen" name = "tauri-codegen"
version = "2.0.0-alpha.4" version = "2.0.0-alpha.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/tauri-apps/tauri?branch=next#9a79dc085870e0c1a5df13481ff271b8c6cc3b78"
checksum = "818c570932ebc2ff6d498be89d93494b89ff142131937a7e56d7cfb9c8ef0ad0"
dependencies = [ dependencies = [
"base64 0.21.0", "base64 0.21.0",
"brotli", "brotli",
@ -4815,8 +5062,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-macros" name = "tauri-macros"
version = "2.0.0-alpha.4" version = "2.0.0-alpha.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/tauri-apps/tauri?branch=next#9a79dc085870e0c1a5df13481ff271b8c6cc3b78"
checksum = "f3b596485d89003d2d7869469b2830e9a846de9ac2eecd69bc7c24890234aefc"
dependencies = [ dependencies = [
"heck 0.4.1", "heck 0.4.1",
"proc-macro2", "proc-macro2",
@ -4904,6 +5150,16 @@ dependencies = [
"thiserror", "thiserror",
] ]
[[package]]
name = "tauri-plugin-fs"
version = "0.0.0"
dependencies = [
"anyhow",
"serde",
"tauri",
"thiserror",
]
[[package]] [[package]]
name = "tauri-plugin-fs-watch" name = "tauri-plugin-fs-watch"
version = "0.0.0" version = "0.0.0"
@ -4929,6 +5185,22 @@ dependencies = [
"thiserror", "thiserror",
] ]
[[package]]
name = "tauri-plugin-http"
version = "0.0.0"
dependencies = [
"bytes 1.4.0",
"glob",
"http",
"rand 0.8.5",
"reqwest",
"serde",
"serde_json",
"serde_repr",
"tauri",
"thiserror",
]
[[package]] [[package]]
name = "tauri-plugin-localhost" name = "tauri-plugin-localhost"
version = "0.1.0" version = "0.1.0"
@ -4939,7 +5211,7 @@ dependencies = [
"serde_json", "serde_json",
"tauri", "tauri",
"thiserror", "thiserror",
"tiny_http", "tiny_http 0.12.0",
] ]
[[package]] [[package]]
@ -5095,6 +5367,30 @@ dependencies = [
"zeroize", "zeroize",
] ]
[[package]]
name = "tauri-plugin-updater"
version = "0.0.0"
dependencies = [
"base64 0.21.0",
"dirs-next",
"futures-util",
"http",
"minisign-verify",
"mockito",
"percent-encoding",
"reqwest",
"semver",
"serde",
"serde_json",
"tauri",
"tempfile",
"thiserror",
"time 0.3.20",
"tokio",
"tokio-test",
"url",
]
[[package]] [[package]]
name = "tauri-plugin-upload" name = "tauri-plugin-upload"
version = "0.0.0" version = "0.0.0"
@ -5151,8 +5447,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-runtime" name = "tauri-runtime"
version = "0.13.0-alpha.4" version = "0.13.0-alpha.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/tauri-apps/tauri?branch=next#9a79dc085870e0c1a5df13481ff271b8c6cc3b78"
checksum = "404367cd32a5a8d33368448aab7da54bb2187b6a632526f1019de3fd13591cc2"
dependencies = [ dependencies = [
"gtk", "gtk",
"http", "http",
@ -5173,8 +5468,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-runtime-wry" name = "tauri-runtime-wry"
version = "0.13.0-alpha.4" version = "0.13.0-alpha.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/tauri-apps/tauri?branch=next#9a79dc085870e0c1a5df13481ff271b8c6cc3b78"
checksum = "203764d673b440877dea87b972772be4091ee0ab25141748008646ca774a20dc"
dependencies = [ dependencies = [
"cocoa", "cocoa",
"gtk", "gtk",
@ -5194,11 +5488,12 @@ dependencies = [
[[package]] [[package]]
name = "tauri-utils" name = "tauri-utils"
version = "2.0.0-alpha.4" version = "2.0.0-alpha.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/tauri-apps/tauri?branch=next#9a79dc085870e0c1a5df13481ff271b8c6cc3b78"
checksum = "49fa79bc56f04ece491268a64273de945f65627bcda30d9e8ecc8708b89bca26"
dependencies = [ dependencies = [
"aes-gcm 0.10.1",
"brotli", "brotli",
"ctor", "ctor",
"getrandom 0.2.9",
"glob", "glob",
"heck 0.4.1", "heck 0.4.1",
"html5ever", "html5ever",
@ -5213,6 +5508,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"serde_with", "serde_with",
"serialize-to-javascript",
"thiserror", "thiserror",
"url", "url",
"walkdir", "walkdir",
@ -5360,6 +5656,19 @@ dependencies = [
"time-core", "time-core",
] ]
[[package]]
name = "tiny_http"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0d6ef4e10d23c1efb862eecad25c5054429a71958b4eeef85eb5e7170b477ca"
dependencies = [
"ascii",
"chunked_transfer",
"log",
"time 0.3.20",
"url",
]
[[package]] [[package]]
name = "tiny_http" name = "tiny_http"
version = "0.12.0" version = "0.12.0"
@ -5435,6 +5744,19 @@ dependencies = [
"tokio", "tokio",
] ]
[[package]]
name = "tokio-test"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53474327ae5e166530d17f2d956afcb4f8a004de581b3cae10f12006bc8163e3"
dependencies = [
"async-stream",
"bytes 1.4.0",
"futures-core",
"tokio",
"tokio-stream",
]
[[package]] [[package]]
name = "tokio-tungstenite" name = "tokio-tungstenite"
version = "0.18.0" version = "0.18.0"
@ -5642,6 +5964,15 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "unicase"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
dependencies = [
"version_check",
]
[[package]] [[package]]
name = "unicode-bidi" name = "unicode-bidi"
version = "0.3.13" version = "0.3.13"
@ -5691,6 +6022,16 @@ dependencies = [
"subtle", "subtle",
] ]
[[package]]
name = "universal-hash"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d3160b73c9a19f7e2939a2fdad446c57c1bbbbf4d919d3213ff1267a580d8b5"
dependencies = [
"crypto-common",
"subtle",
]
[[package]] [[package]]
name = "untrusted" name = "untrusted"
version = "0.7.1" version = "0.7.1"
@ -6079,6 +6420,18 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "window-shadows"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29d30320647cfc3dc45554c8ad825b84831def81f967a2f7589931328ff9b16d"
dependencies = [
"cocoa",
"objc",
"raw-window-handle",
"windows-sys 0.42.0",
]
[[package]] [[package]]
name = "windows" name = "windows"
version = "0.36.1" version = "0.36.1"
@ -6409,9 +6762,9 @@ dependencies = [
[[package]] [[package]]
name = "wry" name = "wry"
version = "0.27.3" version = "0.28.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8cf0dbfa7ccbd2e3832a3098b19d4b552360ea00a40b244a99caef46bffd84f" checksum = "7d15f9f827d537cefe6d047be3930f5d89b238dfb85e08ba6a319153217635aa"
dependencies = [ dependencies = [
"base64 0.13.1", "base64 0.13.1",
"block", "block",
@ -6593,6 +6946,17 @@ dependencies = [
"syn 2.0.13", "syn 2.0.13",
] ]
[[package]]
name = "zip"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e92305c174683d78035cbf1b70e18db6329cc0f1b9cae0a52ca90bf5bfe7125"
dependencies = [
"byteorder",
"crc32fast",
"crossbeam-utils",
]
[[package]] [[package]]
name = "zvariant" name = "zvariant"
version = "3.12.0" version = "3.12.0"

@ -1,13 +1,12 @@
[workspace] [workspace]
members = ["plugins/*", "examples/*/src-tauri"] members = ["plugins/*", "plugins/*/tests/*", "examples/*/src-tauri"]
exclude = ["plugins/fs", "plugins/http", "plugins/updater", "examples/api/src-tauri"]
resolver = "2" resolver = "2"
[workspace.dependencies] [workspace.dependencies]
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
log = "0.4" log = "0.4"
tauri = "2.0.0-alpha.8" tauri = { git = "https://github.com/tauri-apps/tauri", branch = "next" }
tauri-build = "2.0.0-alpha.4" tauri-build = { git = "https://github.com/tauri-apps/tauri", branch = "next" }
serde_json = "1" serde_json = "1"
thiserror = "1" thiserror = "1"
@ -15,4 +14,12 @@ thiserror = "1"
edition = "2021" edition = "2021"
authors = [ "Tauri Programme within The Commons Conservancy" ] authors = [ "Tauri Programme within The Commons Conservancy" ]
license = "Apache-2.0 OR MIT" license = "Apache-2.0 OR MIT"
rust-version = "1.64" rust-version = "1.65"
# default to small, optimized release binaries
[profile.release]
panic = "abort"
codegen-units = 1
lto = true
incremental = false
opt-level = "s"

@ -18,4 +18,4 @@
| [websocket](plugins/websocket) | Open a WebSocket connection using a Rust client in JS. | ✅ | ✅ | ✅ | ? | ? | | [websocket](plugins/websocket) | Open a WebSocket connection using a Rust client in JS. | ✅ | ✅ | ✅ | ? | ? |
| [window-state](plugins/window-state) | Persist window sizes and positions. | ✅ | ✅ | ✅ | ? | ? | | [window-state](plugins/window-state) | Persist window sizes and positions. | ✅ | ✅ | ✅ | ? | ? |
_This repo and all plugins require a Rust version of at least **1.64**_ _This repo and all plugins require a Rust version of at least **1.65**_

@ -3,20 +3,20 @@ name = "api"
version = "0.1.0" version = "0.1.0"
description = "An example Tauri Application showcasing the api" description = "An example Tauri Application showcasing the api"
edition = "2021" edition = "2021"
rust-version = "1.64" rust-version = "1.65"
license = "Apache-2.0 OR MIT" license = "Apache-2.0 OR MIT"
[lib] [lib]
crate-type = ["staticlib", "cdylib", "rlib"] crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies] [build-dependencies]
tauri-build = { version = "2.0.0-alpha.4", features = ["codegen", "isolation"] } tauri-build = { workspace = true, features = ["codegen", "isolation"] }
[dependencies] [dependencies]
serde_json = "1.0" serde_json.workspace = true
serde = { version = "1.0", features = [ "derive" ] } serde.workspace = true
tiny_http = "0.11" tiny_http = "0.11"
log = "0.4" log.workspace = true
tauri-plugin-app = { path = "../../../plugins/app" } tauri-plugin-app = { path = "../../../plugins/app" }
tauri-plugin-log = { path = "../../../plugins/log" } tauri-plugin-log = { path = "../../../plugins/log" }
tauri-plugin-fs = { path = "../../../plugins/fs" } tauri-plugin-fs = { path = "../../../plugins/fs" }
@ -30,12 +30,8 @@ tauri-plugin-shell = { path = "../../../plugins/shell" }
tauri-plugin-updater = { path = "../../../plugins/updater" } tauri-plugin-updater = { path = "../../../plugins/updater" }
tauri-plugin-window = { path = "../../../plugins/window" } tauri-plugin-window = { path = "../../../plugins/window" }
[patch.crates-io]
tauri = { git = "https://github.com/tauri-apps/tauri", branch = "next" }
tauri-build = { git = "https://github.com/tauri-apps/tauri", branch = "next" }
[dependencies.tauri] [dependencies.tauri]
version = "2.0.0-alpha.8" workspace = true
features = [ features = [
"api-all", "api-all",
"icon-ico", "icon-ico",
@ -55,11 +51,3 @@ window-shadows = "0.2"
[features] [features]
custom-protocol = [ "tauri/custom-protocol" ] custom-protocol = [ "tauri/custom-protocol" ]
# default to small, optimized release binaries
[profile.release]
panic = "abort"
codegen-units = 1
lto = true
incremental = false
opt-level = "s"

@ -4,7 +4,7 @@ This plugin provides APIs to read application metadata and macOS app visibility
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -4,7 +4,7 @@ Use hardware security-keys in your Tauri App.
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -4,7 +4,7 @@ Automatically launch your application at startup. Supports Windows, Mac (via App
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -120,7 +120,7 @@ pub fn init<R: Runtime>(
let exe_path = current_exe.canonicalize()?.display().to_string(); let exe_path = current_exe.canonicalize()?.display().to_string();
let parts: Vec<&str> = exe_path.split(".app/").collect(); let parts: Vec<&str> = exe_path.split(".app/").collect();
let app_path = if parts.len() == 2 { let app_path = if parts.len() == 2 {
format!("{}.app", parts.get(0).unwrap().to_string()) format!("{}.app", parts.first().unwrap())
} else { } else {
exe_path exe_path
}; };

@ -4,7 +4,7 @@
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -72,10 +72,10 @@ impl Matches {
/// # Examples /// # Examples
/// ///
/// ```rust,no_run /// ```rust,no_run
/// use tauri_plugin_cli::get_matches; /// use tauri_plugin_cli::CliExt;
/// tauri::Builder::default() /// tauri::Builder::default()
/// .setup(|app| { /// .setup(|app| {
/// let matches = get_matches(app.config().tauri.cli.as_ref().unwrap(), app.package_info())?; /// let matches = app.cli().matches()?;
/// Ok(()) /// Ok(())
/// }); /// });
/// ``` /// ```

@ -4,7 +4,7 @@
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -4,7 +4,7 @@
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -324,12 +324,12 @@ impl<R: Runtime> FileDialogBuilder<R> {
/// # Examples /// # Examples
/// ///
/// ```rust,no_run /// ```rust,no_run
/// use tauri::api::dialog::FileDialogBuilder; /// use tauri_plugin_dialog::DialogExt;
/// tauri::Builder::default() /// tauri::Builder::default()
/// .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json")) /// .build(tauri::generate_context!("test/tauri.conf.json"))
/// .expect("failed to build tauri app") /// .expect("failed to build tauri app")
/// .run(|_app, _event| { /// .run(|app, _event| {
/// FileDialogBuilder::new().pick_file(|file_path| { /// app.dialog().file().pick_file(|file_path| {
/// // do something with the optional file path here /// // do something with the optional file path here
/// // the file path is `None` if the user closed the dialog /// // the file path is `None` if the user closed the dialog
/// }) /// })
@ -348,12 +348,12 @@ impl<R: Runtime> FileDialogBuilder<R> {
/// # Examples /// # Examples
/// ///
/// ```rust,no_run /// ```rust,no_run
/// use tauri::api::dialog::FileDialogBuilder; /// use tauri_plugin_dialog::DialogExt;
/// tauri::Builder::default() /// tauri::Builder::default()
/// .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json")) /// .build(tauri::generate_context!("test/tauri.conf.json"))
/// .expect("failed to build tauri app") /// .expect("failed to build tauri app")
/// .run(|_app, _event| { /// .run(|app, _event| {
/// FileDialogBuilder::new().pick_files(|file_paths| { /// app.dialog().file().pick_files(|file_paths| {
/// // do something with the optional file paths here /// // do something with the optional file paths here
/// // the file paths value is `None` if the user closed the dialog /// // the file paths value is `None` if the user closed the dialog
/// }) /// })
@ -378,12 +378,12 @@ impl<R: Runtime> FileDialogBuilder<R> {
/// # Examples /// # Examples
/// ///
/// ```rust,no_run /// ```rust,no_run
/// use tauri::api::dialog::FileDialogBuilder; /// use tauri_plugin_dialog::DialogExt;
/// tauri::Builder::default() /// tauri::Builder::default()
/// .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json")) /// .build(tauri::generate_context!("test/tauri.conf.json"))
/// .expect("failed to build tauri app") /// .expect("failed to build tauri app")
/// .run(|_app, _event| { /// .run(|app, _event| {
/// FileDialogBuilder::new().pick_folder(|folder_path| { /// app.dialog().file().pick_folder(|folder_path| {
/// // do something with the optional folder path here /// // do something with the optional folder path here
/// // the folder path is `None` if the user closed the dialog /// // the folder path is `None` if the user closed the dialog
/// }) /// })
@ -401,12 +401,12 @@ impl<R: Runtime> FileDialogBuilder<R> {
/// # Examples /// # Examples
/// ///
/// ```rust,no_run /// ```rust,no_run
/// use tauri::api::dialog::FileDialogBuilder; /// use tauri_plugin_dialog::DialogExt;
/// tauri::Builder::default() /// tauri::Builder::default()
/// .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json")) /// .build(tauri::generate_context!("test/tauri.conf.json"))
/// .expect("failed to build tauri app") /// .expect("failed to build tauri app")
/// .run(|_app, _event| { /// .run(|app, _event| {
/// FileDialogBuilder::new().pick_folders(|file_paths| { /// app.dialog().file().pick_folders(|file_paths| {
/// // do something with the optional folder paths here /// // do something with the optional folder paths here
/// // the folder paths value is `None` if the user closed the dialog /// // the folder paths value is `None` if the user closed the dialog
/// }) /// })
@ -425,12 +425,12 @@ impl<R: Runtime> FileDialogBuilder<R> {
/// # Examples /// # Examples
/// ///
/// ```rust,no_run /// ```rust,no_run
/// use tauri::api::dialog::FileDialogBuilder; /// use tauri_plugin_dialog::DialogExt;
/// tauri::Builder::default() /// tauri::Builder::default()
/// .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json")) /// .build(tauri::generate_context!("test/tauri.conf.json"))
/// .expect("failed to build tauri app") /// .expect("failed to build tauri app")
/// .run(|_app, _event| { /// .run(|app, _event| {
/// FileDialogBuilder::new().save_file(|file_path| { /// app.dialog().file().save_file(|file_path| {
/// // do something with the optional file path here /// // do something with the optional file path here
/// // the file path is `None` if the user closed the dialog /// // the file path is `None` if the user closed the dialog
/// }) /// })
@ -451,10 +451,10 @@ impl<R: Runtime> FileDialogBuilder<R> {
/// # Examples /// # Examples
/// ///
/// ```rust,no_run /// ```rust,no_run
/// use tauri::api::dialog::blocking::FileDialogBuilder; /// use tauri_plugin_dialog::DialogExt;
/// #[tauri::command] /// #[tauri::command]
/// async fn my_command() { /// async fn my_command(app: tauri::AppHandle) {
/// let file_path = FileDialogBuilder::new().pick_file(); /// let file_path = app.dialog().file().blocking_pick_file();
/// // do something with the optional file path here /// // do something with the optional file path here
/// // the file path is `None` if the user closed the dialog /// // the file path is `None` if the user closed the dialog
/// } /// }
@ -470,10 +470,10 @@ impl<R: Runtime> FileDialogBuilder<R> {
/// # Examples /// # Examples
/// ///
/// ```rust,no_run /// ```rust,no_run
/// use tauri::api::dialog::blocking::FileDialogBuilder; /// use tauri_plugin_dialog::DialogExt;
/// #[tauri::command] /// #[tauri::command]
/// async fn my_command() { /// async fn my_command(app: tauri::AppHandle) {
/// let file_path = FileDialogBuilder::new().pick_files(); /// let file_path = app.dialog().file().blocking_pick_files();
/// // do something with the optional file paths here /// // do something with the optional file paths here
/// // the file paths value is `None` if the user closed the dialog /// // the file paths value is `None` if the user closed the dialog
/// } /// }
@ -489,10 +489,10 @@ impl<R: Runtime> FileDialogBuilder<R> {
/// # Examples /// # Examples
/// ///
/// ```rust,no_run /// ```rust,no_run
/// use tauri::api::dialog::blocking::FileDialogBuilder; /// use tauri_plugin_dialog::DialogExt;
/// #[tauri::command] /// #[tauri::command]
/// async fn my_command() { /// async fn my_command(app: tauri::AppHandle) {
/// let folder_path = FileDialogBuilder::new().pick_folder(); /// let folder_path = app.dialog().file().blocking_pick_folder();
/// // do something with the optional folder path here /// // do something with the optional folder path here
/// // the folder path is `None` if the user closed the dialog /// // the folder path is `None` if the user closed the dialog
/// } /// }
@ -509,10 +509,10 @@ impl<R: Runtime> FileDialogBuilder<R> {
/// # Examples /// # Examples
/// ///
/// ```rust,no_run /// ```rust,no_run
/// use tauri::api::dialog::blocking::FileDialogBuilder; /// use tauri_plugin_dialog::DialogExt;
/// #[tauri::command] /// #[tauri::command]
/// async fn my_command() { /// async fn my_command(app: tauri::AppHandle) {
/// let folder_paths = FileDialogBuilder::new().pick_folders(); /// let folder_paths = app.dialog().file().blocking_pick_folders();
/// // do something with the optional folder paths here /// // do something with the optional folder paths here
/// // the folder paths value is `None` if the user closed the dialog /// // the folder paths value is `None` if the user closed the dialog
/// } /// }
@ -529,10 +529,10 @@ impl<R: Runtime> FileDialogBuilder<R> {
/// # Examples /// # Examples
/// ///
/// ```rust,no_run /// ```rust,no_run
/// use tauri::api::dialog::blocking::FileDialogBuilder; /// use tauri_plugin_dialog::DialogExt;
/// #[tauri::command] /// #[tauri::command]
/// async fn my_command() { /// async fn my_command(app: tauri::AppHandle) {
/// let file_path = FileDialogBuilder::new().save_file(); /// let file_path = app.dialog().file().blocking_save_file();
/// // do something with the optional file path here /// // do something with the optional file path here
/// // the file path is `None` if the user closed the dialog /// // the file path is `None` if the user closed the dialog
/// } /// }

@ -0,0 +1,22 @@
{
"$schema": "../../../node_modules/.pnpm/@tauri-apps+cli@2.0.0-alpha.8/node_modules/@tauri-apps/cli/schema.json",
"build": {
"distDir": ".",
"devPath": "http://localhost:4000"
},
"tauri": {
"bundle": {
"identifier": "studio.tauri.example",
"active": true,
"icon": ["../../../examples/api/src-tauri/icons/icon.png"]
},
"windows": [
{
"title": "Tauri App"
}
],
"security": {
"csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self'"
}
}
}

@ -4,7 +4,7 @@ Watch files and directories for changes using [notify](https://github.com/notify
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -1,8 +1,4 @@
import { invoke } from "@tauri-apps/api/tauri"; import { invoke, transformCallback } from "@tauri-apps/api/tauri";
import { UnlistenFn } from "@tauri-apps/api/event";
import { appWindow, WebviewWindow } from "tauri-plugin-window-api";
const w: WebviewWindow = appWindow;
export interface WatchOptions { export interface WatchOptions {
recursive?: boolean; recursive?: boolean;
@ -42,11 +38,39 @@ async function unwatch(id: number): Promise<void> {
await invoke("plugin:fs-watch|unwatch", { id }); await invoke("plugin:fs-watch|unwatch", { id });
} }
// TODO: use channel from @tauri-apps/api on v2
class Channel<T = unknown> {
id: number;
// @ts-expect-error field used by the IPC serializer
private readonly __TAURI_CHANNEL_MARKER__ = true;
#onmessage: (response: T) => void = () => {
// no-op
};
constructor() {
this.id = transformCallback((response: T) => {
this.#onmessage(response);
});
}
set onmessage(handler: (response: T) => void) {
this.#onmessage = handler;
}
get onmessage(): (response: T) => void {
return this.#onmessage;
}
toJSON(): string {
return `__CHANNEL__:${this.id}`;
}
}
export async function watch( export async function watch(
paths: string | string[], paths: string | string[],
cb: (event: DebouncedEvent) => void, cb: (event: DebouncedEvent) => void,
options: DebouncedWatchOptions = {} options: DebouncedWatchOptions = {}
): Promise<UnlistenFn> { ): Promise<() => void> {
const opts = { const opts = {
recursive: false, recursive: false,
delayMs: 2000, delayMs: 2000,
@ -61,22 +85,18 @@ export async function watch(
const id = window.crypto.getRandomValues(new Uint32Array(1))[0]; const id = window.crypto.getRandomValues(new Uint32Array(1))[0];
const onEvent = new Channel<DebouncedEvent>();
onEvent.onmessage = cb;
await invoke("plugin:fs-watch|watch", { await invoke("plugin:fs-watch|watch", {
id, id,
paths: watchPaths, paths: watchPaths,
options: opts, options: opts,
onEvent,
}); });
const unlisten = await w.listen<DebouncedEvent>(
`watcher://debounced-event/${id}`,
(event) => {
cb(event.payload);
}
);
return () => { return () => {
void unwatch(id); void unwatch(id);
unlisten();
}; };
} }
@ -84,7 +104,7 @@ export async function watchImmediate(
paths: string | string[], paths: string | string[],
cb: (event: RawEvent) => void, cb: (event: RawEvent) => void,
options: WatchOptions = {} options: WatchOptions = {}
): Promise<UnlistenFn> { ): Promise<() => void> {
const opts = { const opts = {
recursive: false, recursive: false,
...options, ...options,
@ -99,21 +119,17 @@ export async function watchImmediate(
const id = window.crypto.getRandomValues(new Uint32Array(1))[0]; const id = window.crypto.getRandomValues(new Uint32Array(1))[0];
const onEvent = new Channel<RawEvent>();
onEvent.onmessage = cb;
await invoke("plugin:fs-watch|watch", { await invoke("plugin:fs-watch|watch", {
id, id,
paths: watchPaths, paths: watchPaths,
options: opts, options: opts,
onEvent,
}); });
const unlisten = await w.listen<RawEvent>(
`watcher://raw-event/${id}`,
(event) => {
cb(event.payload);
}
);
return () => { return () => {
void unwatch(id); void unwatch(id);
unlisten();
}; };
} }

@ -28,7 +28,6 @@
"tslib": "^2.5.0" "tslib": "^2.5.0"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0", "@tauri-apps/api": "^1.2.0"
"tauri-plugin-window-api": "0.0.0"
} }
} }

@ -2,9 +2,10 @@ use notify::{Config, Event, RecommendedWatcher, RecursiveMode, Watcher};
use notify_debouncer_mini::{new_debouncer, DebounceEventResult, Debouncer}; use notify_debouncer_mini::{new_debouncer, DebounceEventResult, Debouncer};
use serde::{ser::Serializer, Deserialize, Serialize}; use serde::{ser::Serializer, Deserialize, Serialize};
use tauri::{ use tauri::{
api::ipc::Channel,
command, command,
plugin::{Builder as PluginBuilder, TauriPlugin}, plugin::{Builder as PluginBuilder, TauriPlugin},
Manager, Runtime, State, Window, Manager, Runtime, State,
}; };
use std::{ use std::{
@ -44,25 +45,23 @@ enum WatcherKind {
Watcher(RecommendedWatcher), Watcher(RecommendedWatcher),
} }
fn watch_raw<R: Runtime>(window: Window<R>, rx: Receiver<notify::Result<Event>>, id: Id) { fn watch_raw<R: Runtime>(on_event: Channel<R>, rx: Receiver<notify::Result<Event>>) {
spawn(move || { spawn(move || {
let event_name = format!("watcher://raw-event/{id}");
while let Ok(event) = rx.recv() { while let Ok(event) = rx.recv() {
if let Ok(event) = event { if let Ok(event) = event {
// TODO: Should errors be emitted too? // TODO: Should errors be emitted too?
let _ = window.emit(&event_name, event); let _ = on_event.send(&event);
} }
} }
}); });
} }
fn watch_debounced<R: Runtime>(window: Window<R>, rx: Receiver<DebounceEventResult>, id: Id) { fn watch_debounced<R: Runtime>(on_event: Channel<R>, rx: Receiver<DebounceEventResult>) {
spawn(move || { spawn(move || {
let event_name = format!("watcher://debounced-event/{id}");
while let Ok(event) = rx.recv() { while let Ok(event) = rx.recv() {
if let Ok(event) = event { if let Ok(event) = event {
// TODO: Should errors be emitted too? // TODO: Should errors be emitted too?
let _ = window.emit(&event_name, event); let _ = on_event.send(&event);
} }
} }
}); });
@ -77,11 +76,11 @@ struct WatchOptions {
#[command] #[command]
async fn watch<R: Runtime>( async fn watch<R: Runtime>(
window: Window<R>,
watchers: State<'_, WatcherCollection>, watchers: State<'_, WatcherCollection>,
id: Id, id: Id,
paths: Vec<PathBuf>, paths: Vec<PathBuf>,
options: WatchOptions, options: WatchOptions,
on_event: Channel<R>,
) -> Result<()> { ) -> Result<()> {
let mode = if options.recursive { let mode = if options.recursive {
RecursiveMode::Recursive RecursiveMode::Recursive
@ -96,7 +95,7 @@ async fn watch<R: Runtime>(
for path in &paths { for path in &paths {
watcher.watch(path, mode)?; watcher.watch(path, mode)?;
} }
watch_debounced(window, rx, id); watch_debounced(on_event, rx);
WatcherKind::Debouncer(debouncer) WatcherKind::Debouncer(debouncer)
} else { } else {
let (tx, rx) = channel(); let (tx, rx) = channel();
@ -104,7 +103,7 @@ async fn watch<R: Runtime>(
for path in &paths { for path in &paths {
watcher.watch(path, mode)?; watcher.watch(path, mode)?;
} }
watch_raw(window, rx, id); watch_raw(on_event, rx);
WatcherKind::Watcher(watcher) WatcherKind::Watcher(watcher)
}; };

@ -2,21 +2,15 @@
name = "tauri-plugin-fs" name = "tauri-plugin-fs"
version = "0.0.0" version = "0.0.0"
description = "Access the file system." description = "Access the file system."
edition = "2021" authors.workspace = true
#authors.workspace = true license.workspace = true
#license.workspace = true edition.workspace = true
#edition.workspace = true rust-version.workspace = true
#rust-version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
#serde.workspace = true serde.workspace = true
#serde_json.workspace = true tauri.workspace = true
#tauri.workspace = true thiserror.workspace = true
#log.workspace = true
#thiserror.workspace = true
serde = "1"
thiserror = "1"
tauri = { git = "https://github.com/tauri-apps/tauri", branch = "next" }
anyhow = "1" anyhow = "1"

@ -4,7 +4,7 @@ Access the file system.
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -4,7 +4,7 @@
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -1,22 +1,15 @@
[package] [package]
name = "tauri-plugin-http" name = "tauri-plugin-http"
version = "0.0.0" version = "0.0.0"
edition = "2021" edition.workspace = true
#edition.workspace = true authors.workspace = true
#authors.workspace = true license.workspace = true
#license.workspace = true
[dependencies] [dependencies]
#serde.workspace = true serde.workspace = true
#serde_json.workspace = true serde_json.workspace = true
#tauri.workspace = true tauri.workspace = true
#log.workspace = true thiserror.workspace = true
#thiserror.workspace = true
tauri = { git = "https://github.com/tauri-apps/tauri", branch = "next" }
serde = "1"
serde_json = "1"
thiserror = "1"
glob = "0.3" glob = "0.3"
rand = "0.8" rand = "0.8"
bytes = { version = "1", features = [ "serde" ] } bytes = { version = "1", features = [ "serde" ] }

@ -4,7 +4,7 @@
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -1,9 +1,6 @@
use tauri::{path::SafePathBuf, AppHandle, Runtime, State}; use tauri::{path::SafePathBuf, AppHandle, Runtime, State};
use crate::{ use crate::{ClientId, Http};
ClientId, Http,
};
mod client; mod client;
use client::{Body, ClientBuilder, FilePart, FormPart, HttpRequestBuilder, ResponseData}; use client::{Body, ClientBuilder, FilePart, FormPart, HttpRequestBuilder, ResponseData};

@ -38,12 +38,12 @@ impl Scope {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use tauri_utils::config::HttpAllowlistScope; use tauri::utils::config::HttpAllowlistScope;
#[test] #[test]
fn is_allowed() { fn is_allowed() {
// plain URL // plain URL
let scope = super::Scope::for_http_api(&HttpAllowlistScope(vec!["http://localhost:8080" let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://localhost:8080"
.parse() .parse()
.unwrap()])); .unwrap()]));
assert!(scope.is_allowed(&"http://localhost:8080".parse().unwrap())); assert!(scope.is_allowed(&"http://localhost:8080".parse().unwrap()));
@ -56,8 +56,7 @@ mod tests {
assert!(!scope.is_allowed(&"http://local:8080".parse().unwrap())); assert!(!scope.is_allowed(&"http://local:8080".parse().unwrap()));
// URL with fixed path // URL with fixed path
let scope = let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://localhost:8080/file.png"
super::Scope::for_http_api(&HttpAllowlistScope(vec!["http://localhost:8080/file.png"
.parse() .parse()
.unwrap()])); .unwrap()]));
@ -68,8 +67,7 @@ mod tests {
assert!(!scope.is_allowed(&"http://localhost:8080/file.png/other.jpg".parse().unwrap())); assert!(!scope.is_allowed(&"http://localhost:8080/file.png/other.jpg".parse().unwrap()));
// URL with glob pattern // URL with glob pattern
let scope = let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://localhost:8080/*.png"
super::Scope::for_http_api(&HttpAllowlistScope(vec!["http://localhost:8080/*.png"
.parse() .parse()
.unwrap()])); .unwrap()]));
@ -78,15 +76,13 @@ mod tests {
assert!(!scope.is_allowed(&"http://localhost:8080/file.jpeg".parse().unwrap())); assert!(!scope.is_allowed(&"http://localhost:8080/file.jpeg".parse().unwrap()));
let scope = let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://*".parse().unwrap()]));
super::Scope::for_http_api(&HttpAllowlistScope(vec!["http://*".parse().unwrap()]));
assert!(scope.is_allowed(&"http://something.else".parse().unwrap())); assert!(scope.is_allowed(&"http://something.else".parse().unwrap()));
assert!(!scope.is_allowed(&"http://something.else/path/to/file".parse().unwrap())); assert!(!scope.is_allowed(&"http://something.else/path/to/file".parse().unwrap()));
assert!(!scope.is_allowed(&"https://something.else".parse().unwrap())); assert!(!scope.is_allowed(&"https://something.else".parse().unwrap()));
let scope = let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://**".parse().unwrap()]));
super::Scope::for_http_api(&HttpAllowlistScope(vec!["http://**".parse().unwrap()]));
assert!(scope.is_allowed(&"http://something.else".parse().unwrap())); assert!(scope.is_allowed(&"http://something.else".parse().unwrap()));
assert!(scope.is_allowed(&"http://something.else/path/to/file".parse().unwrap())); assert!(scope.is_allowed(&"http://something.else/path/to/file".parse().unwrap()));

@ -6,7 +6,7 @@ Expose your apps assets through a localhost server instead of the default custom
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -4,7 +4,7 @@ Configurable logging for your Tauri app.
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -4,7 +4,7 @@
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -72,15 +72,16 @@ mod imp {
/// ///
/// # Examples /// # Examples
/// ```rust,no_run /// ```rust,no_run
/// use tauri::api::notification::Notification; /// use tauri_plugin_notification::NotificationExt;
/// // first we build the application to access the Tauri configuration /// // first we build the application to access the Tauri configuration
/// let app = tauri::Builder::default() /// let app = tauri::Builder::default()
/// // on an actual app, remove the string argument /// // on an actual app, remove the string argument
/// .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json")) /// .build(tauri::generate_context!("test/tauri.conf.json"))
/// .expect("error while building tauri application"); /// .expect("error while building tauri application");
/// ///
/// // shows a notification with the given title and body /// // shows a notification with the given title and body
/// Notification::new(&app.config().tauri.bundle.identifier) /// app.notification()
/// .builder()
/// .title("New message") /// .title("New message")
/// .body("You've got a new message.") /// .body("You've got a new message.")
/// .show(); /// .show();
@ -136,15 +137,20 @@ mod imp {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// use tauri::api::notification::Notification; /// use tauri_plugin_notification::NotificationExt;
/// ///
/// // on an actual app, remove the string argument /// tauri::Builder::default()
/// let context = tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"); /// .setup(|app| {
/// Notification::new(&context.config().tauri.bundle.identifier) /// app.notification()
/// .builder()
/// .title("Tauri") /// .title("Tauri")
/// .body("Tauri is awesome!") /// .body("Tauri is awesome!")
/// .show() /// .show()
/// .unwrap(); /// .unwrap();
/// Ok(())
/// })
/// .run(tauri::generate_context!("test/tauri.conf.json"))
/// .expect("error while running tauri application");
/// ``` /// ```
/// ///
/// ## Platform-specific /// ## Platform-specific
@ -200,22 +206,18 @@ mod imp {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// use tauri::api::notification::Notification; /// use tauri_plugin_notification::NotificationExt;
///
/// // on an actual app, remove the string argument
/// let context = tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json");
/// let identifier = context.config().tauri.bundle.identifier.clone();
/// ///
/// tauri::Builder::default() /// tauri::Builder::default()
/// .setup(move |app| { /// .setup(move |app| {
/// Notification::new(&identifier) /// app.notification().builder()
/// .title("Tauri") /// .title("Tauri")
/// .body("Tauri is awesome!") /// .body("Tauri is awesome!")
/// .notify(&app.handle()) /// .show()
/// .unwrap(); /// .unwrap();
/// Ok(()) /// Ok(())
/// }) /// })
/// .run(context) /// .run(tauri::generate_context!("test/tauri.conf.json"))
/// .expect("error while running tauri application"); /// .expect("error while running tauri application");
/// ``` /// ```
#[cfg(feature = "windows7-compat")] #[cfg(feature = "windows7-compat")]

@ -0,0 +1,22 @@
{
"$schema": "../../../node_modules/.pnpm/@tauri-apps+cli@2.0.0-alpha.8/node_modules/@tauri-apps/cli/schema.json",
"build": {
"distDir": ".",
"devPath": "http://localhost:4000"
},
"tauri": {
"bundle": {
"identifier": "studio.tauri.example",
"active": true,
"icon": ["../../../examples/api/src-tauri/icons/icon.png"]
},
"windows": [
{
"title": "Tauri App"
}
],
"security": {
"csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self'"
}
}
}

@ -4,7 +4,7 @@ Read information about the operating system.
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -4,7 +4,7 @@ Save filesystem and asset scopes and restore them when the app is reopened.
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -6,7 +6,7 @@ This plugin is a port of [electron-positioner](https://github.com/jenslind/elect
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -4,7 +4,7 @@ This plugin provides APIs to access the current process. To spawn child processe
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -4,7 +4,7 @@
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -200,9 +200,12 @@ impl Command {
/// # Examples /// # Examples
/// ///
/// ```rust,no_run /// ```rust,no_run
/// use tauri::api::process::{Command, CommandEvent}; /// use tauri_plugin_shell::{process::CommandEvent, ShellExt};
/// tauri::Builder::default()
/// .setup(|app| {
/// let handle = app.handle();
/// tauri::async_runtime::spawn(async move { /// tauri::async_runtime::spawn(async move {
/// let (mut rx, mut child) = Command::new("cargo") /// let (mut rx, mut child) = handle.shell().command("cargo")
/// .args(["tauri", "dev"]) /// .args(["tauri", "dev"])
/// .spawn() /// .spawn()
/// .expect("Failed to spawn cargo"); /// .expect("Failed to spawn cargo");
@ -219,6 +222,8 @@ impl Command {
/// } /// }
/// } /// }
/// }); /// });
/// Ok(())
/// });
/// ``` /// ```
pub fn spawn(self) -> crate::Result<(Receiver<CommandEvent>, CommandChild)> { pub fn spawn(self) -> crate::Result<(Receiver<CommandEvent>, CommandChild)> {
let mut command: StdCommand = self.into(); let mut command: StdCommand = self.into();
@ -288,9 +293,13 @@ impl Command {
/// ///
/// # Examples /// # Examples
/// ```rust,no_run /// ```rust,no_run
/// use tauri::api::process::Command; /// use tauri_plugin_shell::ShellExt;
/// let status = Command::new("which").args(["ls"]).status().unwrap(); /// tauri::Builder::default()
/// .setup(|app| {
/// let status = tauri::async_runtime::block_on(async move { app.shell().command("which").args(["ls"]).status().await.unwrap() });
/// println!("`which` finished with status: {:?}", status.code()); /// println!("`which` finished with status: {:?}", status.code());
/// Ok(())
/// });
/// ``` /// ```
pub async fn status(self) -> crate::Result<ExitStatus> { pub async fn status(self) -> crate::Result<ExitStatus> {
let (mut rx, _child) = self.spawn()?; let (mut rx, _child) = self.spawn()?;
@ -310,10 +319,14 @@ impl Command {
/// # Examples /// # Examples
/// ///
/// ```rust,no_run /// ```rust,no_run
/// use tauri::api::process::Command; /// use tauri_plugin_shell::ShellExt;
/// let output = Command::new("echo").args(["TAURI"]).output().unwrap(); /// tauri::Builder::default()
/// .setup(|app| {
/// let output = tauri::async_runtime::block_on(async move { app.shell().command("echo").args(["TAURI"]).output().await.unwrap() });
/// assert!(output.status.success()); /// assert!(output.status.success());
/// assert_eq!(String::from_utf8(output.stdout).unwrap(), "TAURI"); /// assert_eq!(String::from_utf8(output.stdout).unwrap(), "TAURI");
/// Ok(())
/// });
/// ``` /// ```
pub async fn output(self) -> crate::Result<Output> { pub async fn output(self) -> crate::Result<Output> {
let (mut rx, _child) = self.spawn()?; let (mut rx, _child) = self.spawn()?;
@ -387,7 +400,7 @@ mod tests {
#[cfg(not(windows))] #[cfg(not(windows))]
#[test] #[test]
fn test_cmd_spawn_output() { fn test_cmd_spawn_output() {
let cmd = Command::new("cat").args(["test/api/test.txt"]); let cmd = Command::new("cat").args(["test/test.txt"]);
let (mut rx, _) = cmd.spawn().unwrap(); let (mut rx, _) = cmd.spawn().unwrap();
tauri::async_runtime::block_on(async move { tauri::async_runtime::block_on(async move {
@ -408,7 +421,7 @@ mod tests {
#[cfg(not(windows))] #[cfg(not(windows))]
#[test] #[test]
fn test_cmd_spawn_raw_output() { fn test_cmd_spawn_raw_output() {
let cmd = Command::new("cat").args(["test/api/test.txt"]); let cmd = Command::new("cat").args(["test/test.txt"]);
let (mut rx, _) = cmd.spawn().unwrap(); let (mut rx, _) = cmd.spawn().unwrap();
tauri::async_runtime::block_on(async move { tauri::async_runtime::block_on(async move {
@ -430,7 +443,7 @@ mod tests {
#[test] #[test]
// test the failure case // test the failure case
fn test_cmd_spawn_fail() { fn test_cmd_spawn_fail() {
let cmd = Command::new("cat").args(["test/api/"]); let cmd = Command::new("cat").args(["test/"]);
let (mut rx, _) = cmd.spawn().unwrap(); let (mut rx, _) = cmd.spawn().unwrap();
tauri::async_runtime::block_on(async move { tauri::async_runtime::block_on(async move {
@ -442,7 +455,7 @@ mod tests {
CommandEvent::Stderr(line) => { CommandEvent::Stderr(line) => {
assert_eq!( assert_eq!(
String::from_utf8(line).unwrap(), String::from_utf8(line).unwrap(),
"cat: test/api/: Is a directory" "cat: test/: Is a directory"
); );
} }
_ => {} _ => {}
@ -455,7 +468,7 @@ mod tests {
#[test] #[test]
// test the failure case (raw encoding) // test the failure case (raw encoding)
fn test_cmd_spawn_raw_fail() { fn test_cmd_spawn_raw_fail() {
let cmd = Command::new("cat").args(["test/api/"]); let cmd = Command::new("cat").args(["test/"]);
let (mut rx, _) = cmd.spawn().unwrap(); let (mut rx, _) = cmd.spawn().unwrap();
tauri::async_runtime::block_on(async move { tauri::async_runtime::block_on(async move {
@ -467,7 +480,7 @@ mod tests {
CommandEvent::Stderr(line) => { CommandEvent::Stderr(line) => {
assert_eq!( assert_eq!(
String::from_utf8(line).unwrap(), String::from_utf8(line).unwrap(),
"cat: test/api/: Is a directory" "cat: test/: Is a directory"
); );
} }
_ => {} _ => {}
@ -479,7 +492,7 @@ mod tests {
#[cfg(not(windows))] #[cfg(not(windows))]
#[test] #[test]
fn test_cmd_output_output() { fn test_cmd_output_output() {
let cmd = Command::new("cat").args(["test/api/test.txt"]); let cmd = Command::new("cat").args(["test/test.txt"]);
let output = tauri::async_runtime::block_on(cmd.output()).unwrap(); let output = tauri::async_runtime::block_on(cmd.output()).unwrap();
assert_eq!(String::from_utf8(output.stderr).unwrap(), ""); assert_eq!(String::from_utf8(output.stderr).unwrap(), "");
@ -492,13 +505,13 @@ mod tests {
#[cfg(not(windows))] #[cfg(not(windows))]
#[test] #[test]
fn test_cmd_output_output_fail() { fn test_cmd_output_output_fail() {
let cmd = Command::new("cat").args(["test/api/"]); let cmd = Command::new("cat").args(["test/"]);
let output = tauri::async_runtime::block_on(cmd.output()).unwrap(); let output = tauri::async_runtime::block_on(cmd.output()).unwrap();
assert_eq!(String::from_utf8(output.stdout).unwrap(), ""); assert_eq!(String::from_utf8(output.stdout).unwrap(), "");
assert_eq!( assert_eq!(
String::from_utf8(output.stderr).unwrap(), String::from_utf8(output.stderr).unwrap(),
"cat: test/api/: Is a directory\n" "cat: test/: Is a directory\n"
); );
} }
} }

@ -0,0 +1 @@
This is a test doc!

@ -4,7 +4,7 @@ Ensure a single instance of your tauri app is running.
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -4,7 +4,7 @@ Interface with SQL databases through [sqlx](https://github.com/launchbadge/sqlx)
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -4,7 +4,7 @@ Simple, persistent key-value store.
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -46,7 +46,7 @@ pub fn with_store<R: Runtime, T, F: FnOnce(&mut Store<R>) -> Result<T, Error>>(
if collection.frozen { if collection.frozen {
return Err(Error::NotFound(path.to_path_buf())); return Err(Error::NotFound(path.to_path_buf()));
} }
let mut store = StoreBuilder::new(app, path.to_path_buf()).build(); let mut store = StoreBuilder::new(path).build(app);
// ignore loading errors, just use the default // ignore loading errors, just use the default
if let Err(err) = store.load() { if let Err(err) = store.load() {
warn!( warn!(
@ -205,15 +205,14 @@ impl<R: Runtime> Builder<R> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # fn main() -> Result<(), Box<dyn std::error::Error>> { /// use tauri_plugin_store::{StoreBuilder, Builder};
/// use tauri_plugin_store::{StoreBuilder,PluginBuilder};
/// ///
/// let store = StoreBuilder::new("store.bin".parse()?).build(); /// tauri::Builder::default()
/// /// .setup(|app| {
/// let builder = PluginBuilder::default().store(store); /// let store = StoreBuilder::new("store.bin").build(app.handle());
/// /// let builder = Builder::default().store(store);
/// # Ok(()) /// Ok(())
/// # } /// });
/// ``` /// ```
pub fn store(mut self, store: Store<R>) -> Self { pub fn store(mut self, store: Store<R>) -> Self {
self.stores.insert(store.path.clone(), store); self.stores.insert(store.path.clone(), store);
@ -225,15 +224,14 @@ impl<R: Runtime> Builder<R> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # fn main() -> Result<(), Box<dyn std::error::Error>> { /// use tauri_plugin_store::{StoreBuilder, Builder};
/// use tauri_plugin_store::{StoreBuilder,PluginBuilder};
///
/// let store = StoreBuilder::new("store.bin".parse()?).build();
///
/// let builder = PluginBuilder::default().stores([store]);
/// ///
/// # Ok(()) /// tauri::Builder::default()
/// # } /// .setup(|app| {
/// let store = StoreBuilder::new("store.bin").build(app.handle());
/// let builder = Builder::default().stores([store]);
/// Ok(())
/// });
/// ``` /// ```
pub fn stores<T: IntoIterator<Item = Store<R>>>(mut self, stores: T) -> Self { pub fn stores<T: IntoIterator<Item = Store<R>>>(mut self, stores: T) -> Self {
self.stores = stores self.stores = stores
@ -250,15 +248,14 @@ impl<R: Runtime> Builder<R> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # fn main() -> Result<(), Box<dyn std::error::Error>> { /// use tauri_plugin_store::{StoreBuilder, Builder};
/// use tauri_plugin_store::{StoreBuilder,PluginBuilder};
/// ///
/// let store = StoreBuilder::new("store.bin".parse()?).build(); /// tauri::Builder::default()
/// /// .setup(|app| {
/// let builder = PluginBuilder::default().freeze(); /// let store = StoreBuilder::new("store.bin").build(app.handle());
/// /// app.handle().plugin(Builder::default().freeze().build());
/// # Ok(()) /// Ok(())
/// # } /// });
/// ``` /// ```
pub fn freeze(mut self) -> Self { pub fn freeze(mut self) -> Self {
self.frozen = true; self.frozen = true;
@ -270,16 +267,14 @@ impl<R: Runtime> Builder<R> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # fn main() -> Result<(), Box<dyn std::error::Error>> { /// use tauri_plugin_store::{StoreBuilder, Builder};
/// use tauri_plugin_store::{StoreBuilder,PluginBuilder};
/// use tauri::Wry;
///
/// let store = StoreBuilder::new("store.bin".parse()?).build();
///
/// let plugin = PluginBuilder::default().build::<Wry>();
/// ///
/// # Ok(()) /// tauri::Builder::default()
/// # } /// .setup(|app| {
/// let store = StoreBuilder::new("store.bin").build(app.handle());
/// app.handle().plugin(Builder::default().build());
/// Ok(())
/// });
/// ``` /// ```
pub fn build(mut self) -> TauriPlugin<R> { pub fn build(mut self) -> TauriPlugin<R> {
plugin::Builder::new("store") plugin::Builder::new("store")

@ -8,7 +8,7 @@ use std::{
collections::HashMap, collections::HashMap,
fs::{create_dir_all, read, File}, fs::{create_dir_all, read, File},
io::Write, io::Write,
path::PathBuf, path::{Path, PathBuf},
}; };
use tauri::{AppHandle, Manager, Runtime}; use tauri::{AppHandle, Manager, Runtime};
@ -30,8 +30,7 @@ fn default_deserialize(
} }
/// Builds a [`Store`] /// Builds a [`Store`]
pub struct StoreBuilder<R: Runtime> { pub struct StoreBuilder {
app: AppHandle<R>,
path: PathBuf, path: PathBuf,
defaults: Option<HashMap<String, JsonValue>>, defaults: Option<HashMap<String, JsonValue>>,
cache: HashMap<String, JsonValue>, cache: HashMap<String, JsonValue>,
@ -39,7 +38,7 @@ pub struct StoreBuilder<R: Runtime> {
deserialize: DeserializeFn, deserialize: DeserializeFn,
} }
impl<R: Runtime> StoreBuilder<R> { impl StoreBuilder {
/// Creates a new [`StoreBuilder`]. /// Creates a new [`StoreBuilder`].
/// ///
/// # Examples /// # Examples
@ -47,15 +46,14 @@ impl<R: Runtime> StoreBuilder<R> {
/// # fn main() -> Result<(), Box<dyn std::error::Error>> { /// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// use tauri_plugin_store::StoreBuilder; /// use tauri_plugin_store::StoreBuilder;
/// ///
/// let builder = StoreBuilder::new("store.bin".parse()?); /// let builder = StoreBuilder::new("store.bin");
/// ///
/// # Ok(()) /// # Ok(())
/// # } /// # }
/// ``` /// ```
pub fn new(app: AppHandle<R>, path: PathBuf) -> Self { pub fn new<P: AsRef<Path>>(path: P) -> Self {
Self { Self {
app, path: path.as_ref().to_path_buf(),
path,
defaults: None, defaults: None,
cache: Default::default(), cache: Default::default(),
serialize: default_serialize, serialize: default_serialize,
@ -75,7 +73,7 @@ impl<R: Runtime> StoreBuilder<R> {
/// ///
/// defaults.insert("foo".to_string(), "bar".into()); /// defaults.insert("foo".to_string(), "bar".into());
/// ///
/// let builder = StoreBuilder::new("store.bin".parse()?) /// let builder = StoreBuilder::new("store.bin")
/// .defaults(defaults); /// .defaults(defaults);
/// ///
/// # Ok(()) /// # Ok(())
@ -93,7 +91,7 @@ impl<R: Runtime> StoreBuilder<R> {
/// # fn main() -> Result<(), Box<dyn std::error::Error>> { /// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// use tauri_plugin_store::StoreBuilder; /// use tauri_plugin_store::StoreBuilder;
/// ///
/// let builder = StoreBuilder::new("store.bin".parse()?) /// let builder = StoreBuilder::new("store.bin")
/// .default("foo".to_string(), "bar".into()); /// .default("foo".to_string(), "bar".into());
/// ///
/// # Ok(()) /// # Ok(())
@ -113,7 +111,7 @@ impl<R: Runtime> StoreBuilder<R> {
/// # fn main() -> Result<(), Box<dyn std::error::Error>> { /// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// use tauri_plugin_store::StoreBuilder; /// use tauri_plugin_store::StoreBuilder;
/// ///
/// let builder = StoreBuilder::new("store.json".parse()?) /// let builder = StoreBuilder::new("store.json")
/// .serialize(|cache| serde_json::to_vec(&cache).map_err(Into::into)); /// .serialize(|cache| serde_json::to_vec(&cache).map_err(Into::into));
/// ///
/// # Ok(()) /// # Ok(())
@ -130,7 +128,7 @@ impl<R: Runtime> StoreBuilder<R> {
/// # fn main() -> Result<(), Box<dyn std::error::Error>> { /// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// use tauri_plugin_store::StoreBuilder; /// use tauri_plugin_store::StoreBuilder;
/// ///
/// let builder = StoreBuilder::new("store.json".parse()?) /// let builder = StoreBuilder::new("store.json")
/// .deserialize(|bytes| serde_json::from_slice(&bytes).map_err(Into::into)); /// .deserialize(|bytes| serde_json::from_slice(&bytes).map_err(Into::into));
/// ///
/// # Ok(()) /// # Ok(())
@ -144,16 +142,15 @@ impl<R: Runtime> StoreBuilder<R> {
/// ///
/// # Examples /// # Examples
/// ``` /// ```
/// # fn main() -> Result<(), Box<dyn std::error::Error>> { /// tauri::Builder::default()
/// use tauri_plugin_store::StoreBuilder; /// .setup(|app| {
/// /// let store = tauri_plugin_store::StoreBuilder::new("store.json").build(app.handle());
/// let store = StoreBuilder::new("store.bin".parse()?).build(); /// Ok(())
/// /// });
/// # Ok(()) /// ```
/// # } pub fn build<R: Runtime>(self, app: AppHandle<R>) -> Store<R> {
pub fn build(self) -> Store<R> {
Store { Store {
app: self.app, app,
path: self.path, path: self.path,
defaults: self.defaults, defaults: self.defaults,
cache: self.cache, cache: self.cache,

@ -4,7 +4,7 @@ Store secrets and keys using the [IOTA Stronghold](https://github.com/iotaledger
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -1,20 +1,15 @@
[package] [package]
name = "tauri-plugin-updater" name = "tauri-plugin-updater"
version = "0.0.0" version = "0.0.0"
edition = "2021" edition.workspace = true
#edition.workspace = true authors.workspace = true
#authors.workspace = true license.workspace = true
#license.workspace = true
[dependencies] [dependencies]
#tauri = { workspace = true, features = ["updater"] } tauri = { workspace = true, features = ["updater", "fs-extract-api"] }
#serde.workspace = true serde.workspace = true
#serde_json.workspace = true serde_json.workspace = true
#thiserror.workspace = true thiserror.workspace = true
tauri = { git = "https://github.com/tauri-apps/tauri", branch = "next", features = ["updater", "fs-extract-api"] }
serde = "1"
serde_json = "1"
thiserror = "1"
tokio = "1" tokio = "1"
reqwest = { version = "0.11", default-features = false, features = [ "json", "stream" ] } reqwest = { version = "0.11", default-features = false, features = [ "json", "stream" ] }

@ -4,7 +4,7 @@ In-app updates for Tauri applications.
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -1,18 +1,17 @@
[package] [package]
name = "app-updater" name = "app-updater"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition.workspace = true
#edition.workspace = true
[build-dependencies] [build-dependencies]
tauri-build = { path = "../../../../../tauri/core/tauri-build", features = [] } tauri-build.workspace = true
[dependencies] [dependencies]
tauri = { git = "https://github.com/tauri-apps/tauri", branch = "next" } tauri.workspace = true
serde.workspace = true
serde_json.workspace = true
tauri-plugin-updater = { path = "../.." } tauri-plugin-updater = { path = "../.." }
tiny_http = "0.11" tiny_http = "0.11"
serde = "1"
serde_json = "1"
time = { version = "0.3", features = ["formatting"] } time = { version = "0.3", features = ["formatting"] }
[features] [features]

@ -30,7 +30,7 @@ fn main() {
tauri::async_runtime::spawn(async move { tauri::async_runtime::spawn(async move {
match handle.updater().check().await { match handle.updater().check().await {
Ok(update) => { Ok(update) => {
if let Err(e) = update.download_and_install().await { if let Err(e) = update.download_and_install(|_event| {}).await {
println!("{e}"); println!("{e}");
std::process::exit(1); std::process::exit(1);
} }

@ -176,7 +176,7 @@ fn update_app() {
let target = let target =
tauri_plugin_updater::target().expect("running updater test in an unsupported platform"); tauri_plugin_updater::target().expect("running updater test in an unsupported platform");
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let root_dir = manifest_dir.clone(); let root_dir = manifest_dir.join("../../../..");
let mut config = Config { let mut config = Config {
package: PackageConfig { version: "1.0.0" }, package: PackageConfig { version: "1.0.0" },

@ -4,7 +4,7 @@ Upload files from disk to a remote server over HTTP.
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -1,30 +1,38 @@
import { invoke } from "@tauri-apps/api/tauri"; import { invoke, transformCallback } from "@tauri-apps/api/tauri";
import { appWindow } from "tauri-plugin-window-api";
interface ProgressPayload { interface ProgressPayload {
id: number;
progress: number; progress: number;
total: number; total: number;
} }
type ProgressHandler = (progress: number, total: number) => void; type ProgressHandler = (progress: ProgressPayload) => void;
const handlers: Map<number, ProgressHandler> = new Map();
let listening = false; // TODO: use channel from @tauri-apps/api on v2
class Channel<T = unknown> {
id: number;
// @ts-expect-error field used by the IPC serializer
private readonly __TAURI_CHANNEL_MARKER__ = true;
#onmessage: (response: T) => void = () => {
// no-op
};
async function listenToEventIfNeeded(event: string): Promise<void> { constructor() {
if (listening) { this.id = transformCallback((response: T) => {
return await Promise.resolve(); this.#onmessage(response);
});
} }
return await appWindow
.listen<ProgressPayload>(event, ({ payload }) => { set onmessage(handler: (response: T) => void) {
const handler = handlers.get(payload.id); this.#onmessage = handler;
if (handler != null) { }
handler(payload.progress, payload.total);
get onmessage(): (response: T) => void {
return this.#onmessage;
}
toJSON(): string {
return `__CHANNEL__:${this.id}`;
} }
})
.then(() => {
listening = true;
});
} }
async function upload( async function upload(
@ -37,17 +45,17 @@ async function upload(
window.crypto.getRandomValues(ids); window.crypto.getRandomValues(ids);
const id = ids[0]; const id = ids[0];
const onProgress = new Channel<ProgressPayload>();
if (progressHandler != null) { if (progressHandler != null) {
handlers.set(id, progressHandler); onProgress.onmessage = progressHandler;
} }
await listenToEventIfNeeded("upload://progress");
await invoke("plugin:upload|upload", { await invoke("plugin:upload|upload", {
id, id,
url, url,
filePath, filePath,
headers: headers ?? {}, headers: headers ?? {},
onProgress,
}); });
} }
@ -65,17 +73,17 @@ async function download(
window.crypto.getRandomValues(ids); window.crypto.getRandomValues(ids);
const id = ids[0]; const id = ids[0];
const onProgress = new Channel<ProgressPayload>();
if (progressHandler != null) { if (progressHandler != null) {
handlers.set(id, progressHandler); onProgress.onmessage = progressHandler;
} }
await listenToEventIfNeeded("download://progress");
await invoke("plugin:upload|download", { await invoke("plugin:upload|download", {
id, id,
url, url,
filePath, filePath,
headers: headers ?? {}, headers: headers ?? {},
onProgress,
}); });
} }

@ -28,7 +28,6 @@
"tslib": "^2.5.0" "tslib": "^2.5.0"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0", "@tauri-apps/api": "^1.2.0"
"tauri-plugin-window-api": "0.0.0"
} }
} }

@ -5,16 +5,17 @@
use futures_util::TryStreamExt; use futures_util::TryStreamExt;
use serde::{ser::Serializer, Serialize}; use serde::{ser::Serializer, Serialize};
use tauri::{ use tauri::{
api::ipc::Channel,
command, command,
plugin::{Builder as PluginBuilder, TauriPlugin}, plugin::{Builder as PluginBuilder, TauriPlugin},
Runtime, Window, Runtime,
}; };
use tokio::{fs::File, io::AsyncWriteExt}; use tokio::{fs::File, io::AsyncWriteExt};
use tokio_util::codec::{BytesCodec, FramedRead}; use tokio_util::codec::{BytesCodec, FramedRead};
use read_progress_stream::ReadProgressStream; use read_progress_stream::ReadProgressStream;
use std::{collections::HashMap, sync::Mutex}; use std::collections::HashMap;
type Result<T> = std::result::Result<T, Error>; type Result<T> = std::result::Result<T, Error>;
@ -39,19 +40,17 @@ impl Serialize for Error {
#[derive(Clone, Serialize)] #[derive(Clone, Serialize)]
struct ProgressPayload { struct ProgressPayload {
id: u32,
progress: u64, progress: u64,
total: u64, total: u64,
} }
#[command] #[command]
async fn download<R: Runtime>( async fn download<R: Runtime>(
window: Window<R>,
id: u32,
url: &str, url: &str,
file_path: &str, file_path: &str,
headers: HashMap<String, String>, headers: HashMap<String, String>,
) -> Result<u32> { on_progress: Channel<R>,
) -> Result<()> {
let client = reqwest::Client::new(); let client = reqwest::Client::new();
let mut request = client.get(url); let mut request = client.get(url);
@ -69,33 +68,28 @@ async fn download<R: Runtime>(
while let Some(chunk) = stream.try_next().await? { while let Some(chunk) = stream.try_next().await? {
file.write_all(&chunk).await?; file.write_all(&chunk).await?;
let _ = window.emit( let _ = on_progress.send(&ProgressPayload {
"download://progress",
ProgressPayload {
id,
progress: chunk.len() as u64, progress: chunk.len() as u64,
total, total,
}, });
);
} }
Ok(id) Ok(())
} }
#[command] #[command]
async fn upload<R: Runtime>( async fn upload<R: Runtime>(
window: Window<R>,
id: u32,
url: &str, url: &str,
file_path: &str, file_path: &str,
headers: HashMap<String, String>, headers: HashMap<String, String>,
on_progress: Channel<R>,
) -> Result<serde_json::Value> { ) -> Result<serde_json::Value> {
// Read the file // Read the file
let file = File::open(file_path).await?; let file = File::open(file_path).await?;
// Create the request and attach the file to the body // Create the request and attach the file to the body
let client = reqwest::Client::new(); let client = reqwest::Client::new();
let mut request = client.post(url).body(file_to_body(id, window, file)); let mut request = client.post(url).body(file_to_body(on_progress, file));
// Loop trought the headers keys and values // Loop trought the headers keys and values
// and add them to the request object. // and add them to the request object.
@ -108,20 +102,13 @@ async fn upload<R: Runtime>(
response.json().await.map_err(Into::into) response.json().await.map_err(Into::into)
} }
fn file_to_body<R: Runtime>(id: u32, window: Window<R>, file: File) -> reqwest::Body { fn file_to_body<R: Runtime>(channel: Channel<R>, file: File) -> reqwest::Body {
let stream = FramedRead::new(file, BytesCodec::new()).map_ok(|r| r.freeze()); let stream = FramedRead::new(file, BytesCodec::new()).map_ok(|r| r.freeze());
let window = Mutex::new(window);
reqwest::Body::wrap_stream(ReadProgressStream::new( reqwest::Body::wrap_stream(ReadProgressStream::new(
stream, stream,
Box::new(move |progress, total| { Box::new(move |progress, total| {
let _ = window.lock().unwrap().emit( let _ = channel.send(&ProgressPayload { progress, total });
"upload://progress",
ProgressPayload {
id,
progress,
total,
},
);
}), }),
)) ))
} }

@ -4,7 +4,7 @@
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -4,7 +4,7 @@ Save window positions and sizes and restore them when the app is reopened.
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -1,5 +1,17 @@
import { invoke } from "@tauri-apps/api/tauri"; import { invoke } from "@tauri-apps/api/tauri";
import { WindowLabel, getCurrent } from "tauri-plugin-window-api";
interface WindowDef {
label: string;
}
declare global {
interface Window {
__TAURI_METADATA__: {
__windows: WindowDef[];
__currentWindow: WindowDef;
};
}
}
export enum StateFlags { export enum StateFlags {
SIZE = 1 << 0, SIZE = 1 << 0,
@ -21,7 +33,7 @@ async function saveWindowState(flags: StateFlags) {
/** /**
* Restore the state for the specified window from disk. * Restore the state for the specified window from disk.
*/ */
async function restoreState(label: WindowLabel, flags: StateFlags) { async function restoreState(label: string, flags: StateFlags) {
invoke("plugin:window-state|restore_state", { label, flags }); invoke("plugin:window-state|restore_state", { label, flags });
} }
@ -29,7 +41,7 @@ async function restoreState(label: WindowLabel, flags: StateFlags) {
* Restore the state for the current window from disk. * Restore the state for the current window from disk.
*/ */
async function restoreStateCurrent(flags: StateFlags) { async function restoreStateCurrent(flags: StateFlags) {
restoreState(getCurrent().label, flags); restoreState(window.__TAURI_METADATA__.__currentWindow.label, flags);
} }
export { restoreState, restoreStateCurrent, saveWindowState }; export { restoreState, restoreStateCurrent, saveWindowState };

@ -28,7 +28,6 @@
"tslib": "^2.5.0" "tslib": "^2.5.0"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0", "@tauri-apps/api": "^1.2.0"
"tauri-plugin-window-api": "0.0.0"
} }
} }

@ -4,7 +4,7 @@ Interact with the Tauri window.
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

@ -198,9 +198,6 @@ importers:
'@tauri-apps/api': '@tauri-apps/api':
specifier: ^1.2.0 specifier: ^1.2.0
version: 1.2.0 version: 1.2.0
tauri-plugin-window-api:
specifier: 0.0.0
version: link:../window
devDependencies: devDependencies:
tslib: tslib:
specifier: ^2.5.0 specifier: ^2.5.0
@ -337,9 +334,6 @@ importers:
'@tauri-apps/api': '@tauri-apps/api':
specifier: ^1.2.0 specifier: ^1.2.0
version: 1.2.0 version: 1.2.0
tauri-plugin-window-api:
specifier: 0.0.0
version: link:../window
devDependencies: devDependencies:
tslib: tslib:
specifier: ^2.5.0 specifier: ^2.5.0
@ -401,9 +395,6 @@ importers:
'@tauri-apps/api': '@tauri-apps/api':
specifier: ^1.2.0 specifier: ^1.2.0
version: 1.2.0 version: 1.2.0
tauri-plugin-window-api:
specifier: 0.0.0
version: link:../window
devDependencies: devDependencies:
tslib: tslib:
specifier: ^2.5.0 specifier: ^2.5.0

@ -4,7 +4,7 @@
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.

Loading…
Cancel
Save