From aeb21251766c83574949f8d293b8fcd0dcd2a29b Mon Sep 17 00:00:00 2001 From: Fabian-Lars Date: Fri, 17 Feb 2023 21:14:42 +0100 Subject: [PATCH 01/46] chore(single-instance): Fix banner link in readme --- plugins/single-instance/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/single-instance/README.md b/plugins/single-instance/README.md index 1efbba90..c6b0c685 100644 --- a/plugins/single-instance/README.md +++ b/plugins/single-instance/README.md @@ -1,4 +1,4 @@ -![tauri-plugin-single-instance](banner.jpg) +![tauri-plugin-single-instance](banner.png) Ensure a single instance of your tauri app is running. From 8f0d662ea959c671405c36f5f1d349088fe85199 Mon Sep 17 00:00:00 2001 From: Fabian-Lars Date: Thu, 23 Feb 2023 13:30:32 +0100 Subject: [PATCH 02/46] fix(upload): download function invokes wrong command --- plugins/upload/guest-js/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/upload/guest-js/index.ts b/plugins/upload/guest-js/index.ts index 7b4a94c7..d2eced4e 100644 --- a/plugins/upload/guest-js/index.ts +++ b/plugins/upload/guest-js/index.ts @@ -67,7 +67,7 @@ async function download( await listenToEventIfNeeded("download://progress"); - await invoke("plugin:upload|upload", { + await invoke("plugin:upload|download", { id, url, filePath, From 8f34eb83e4f9a8c72fd3823a066c94f861f2d021 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 23 Feb 2023 13:54:46 +0100 Subject: [PATCH 03/46] fix(deps): update rust crate windows-sys to 0.45 (#103) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 42 +++++++++++++++++++++++------- plugins/single-instance/Cargo.toml | 2 +- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ebd4ec1a..35300066 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -153,7 +153,7 @@ dependencies = [ "slab", "socket2", "waker-fn", - "windows-sys", + "windows-sys 0.42.0", ] [[package]] @@ -1156,7 +1156,7 @@ dependencies = [ "cfg-if", "libc", "redox_syscall", - "windows-sys", + "windows-sys 0.42.0", ] [[package]] @@ -2384,7 +2384,7 @@ dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", + "windows-sys 0.42.0", ] [[package]] @@ -2506,7 +2506,7 @@ dependencies = [ "mio", "serde", "walkdir", - "windows-sys", + "windows-sys 0.42.0", ] [[package]] @@ -2808,7 +2808,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-sys", + "windows-sys 0.42.0", ] [[package]] @@ -3046,7 +3046,7 @@ dependencies = [ "libc", "log", "wepoll-ffi", - "windows-sys", + "windows-sys 0.42.0", ] [[package]] @@ -3489,7 +3489,7 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" dependencies = [ - "windows-sys", + "windows-sys 0.42.0", ] [[package]] @@ -4372,7 +4372,7 @@ dependencies = [ "serde_json", "tauri", "thiserror", - "windows-sys", + "windows-sys 0.45.0", "zbus", ] @@ -4678,7 +4678,7 @@ dependencies = [ "num_cpus", "pin-project-lite", "socket2", - "windows-sys", + "windows-sys 0.42.0", ] [[package]] @@ -5414,6 +5414,30 @@ dependencies = [ "windows_x86_64_msvc 0.42.1", ] +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.1", +] + [[package]] name = "windows-tokens" version = "0.39.0" diff --git a/plugins/single-instance/Cargo.toml b/plugins/single-instance/Cargo.toml index 4762e033..d57ff092 100644 --- a/plugins/single-instance/Cargo.toml +++ b/plugins/single-instance/Cargo.toml @@ -18,7 +18,7 @@ log.workspace = true thiserror.workspace = true [target.'cfg(target_os = "windows")'.dependencies.windows-sys] -version = "0.42" +version = "0.45" features = [ "Win32_System_Threading", "Win32_System_DataExchange", From 265acf745435dabe78321ff7cf1e0af92df566e2 Mon Sep 17 00:00:00 2001 From: Flux Xu Date: Mon, 27 Feb 2023 03:15:07 -0500 Subject: [PATCH 04/46] docs(single-instance): Fix a typo (#264) --- plugins/single-instance/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/single-instance/README.md b/plugins/single-instance/README.md index c6b0c685..595d6b17 100644 --- a/plugins/single-instance/README.md +++ b/plugins/single-instance/README.md @@ -38,7 +38,7 @@ struct Payload { fn main() { tauri::Builder::default() - .plugin(auri_plugin_single_instance::init(|app, argv, cwd| { + .plugin(tauri_plugin_single_instance::init(|app, argv, cwd| { println!("{}, {argv:?}, {cwd}", app.package_info().name); app.emit_all("single-instance", Payload { args: argv, cwd }).unwrap(); From 1d52416f7042b1b6b157dc66f6daa96a96d342e2 Mon Sep 17 00:00:00 2001 From: Fabian-Lars Date: Sun, 5 Mar 2023 12:25:15 +0100 Subject: [PATCH 05/46] feat(sql): Improve type decoding. Adds support for time and dates (#266) * feat(sql): Improve type decoding. Adds support for time and dates * remove default feat * typo --- Cargo.lock | 4 +- plugins/sql/Cargo.toml | 5 +- plugins/sql/src/decode/mod.rs | 15 +++++ plugins/sql/src/decode/mysql.rs | 90 ++++++++++++++++++++++++++++++ plugins/sql/src/decode/postgres.rs | 82 +++++++++++++++++++++++++++ plugins/sql/src/decode/sqlite.rs | 74 ++++++++++++++++++++++++ plugins/sql/src/lib.rs | 11 +--- plugins/sql/src/plugin.rs | 57 +------------------ 8 files changed, 271 insertions(+), 67 deletions(-) create mode 100644 plugins/sql/src/decode/mod.rs create mode 100644 plugins/sql/src/decode/mysql.rs create mode 100644 plugins/sql/src/decode/postgres.rs create mode 100644 plugins/sql/src/decode/sqlite.rs diff --git a/Cargo.lock b/Cargo.lock index 35300066..d2a0e851 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3901,6 +3901,7 @@ dependencies = [ "sqlx-rt", "stringprep", "thiserror", + "time 0.3.17", "tokio-stream", "url", "webpki-roots", @@ -4380,13 +4381,14 @@ dependencies = [ name = "tauri-plugin-sql" version = "0.1.0" dependencies = [ - "futures", + "futures-core", "log", "serde", "serde_json", "sqlx", "tauri", "thiserror", + "time 0.3.17", "tokio", ] diff --git a/plugins/sql/Cargo.toml b/plugins/sql/Cargo.toml index c72e237c..502cd12c 100644 --- a/plugins/sql/Cargo.toml +++ b/plugins/sql/Cargo.toml @@ -15,9 +15,10 @@ serde_json.workspace = true tauri.workspace = true log.workspace = true thiserror.workspace = true -sqlx = { version = "0.6", features = ["runtime-tokio-rustls", "json"] } +futures-core = "0.3" +sqlx = { version = "0.6", features = ["runtime-tokio-rustls", "json", "time"] } +time = "0.3" tokio = { version = "1", features = ["sync"] } -futures = "0.3" [features] sqlite = ["sqlx/sqlite"] diff --git a/plugins/sql/src/decode/mod.rs b/plugins/sql/src/decode/mod.rs new file mode 100644 index 00000000..415c99b8 --- /dev/null +++ b/plugins/sql/src/decode/mod.rs @@ -0,0 +1,15 @@ +#[cfg(feature = "mysql")] +mod mysql; +#[cfg(feature = "postgres")] +mod postgres; +#[cfg(feature = "sqlite")] +mod sqlite; + +#[cfg(feature = "mysql")] +pub(crate) use mysql::to_json; + +#[cfg(feature = "postgres")] +pub(crate) use postgres::to_json; + +#[cfg(feature = "sqlite")] +pub(crate) use sqlite::to_json; diff --git a/plugins/sql/src/decode/mysql.rs b/plugins/sql/src/decode/mysql.rs new file mode 100644 index 00000000..e68bd1ac --- /dev/null +++ b/plugins/sql/src/decode/mysql.rs @@ -0,0 +1,90 @@ +use serde_json::Value as JsonValue; +use sqlx::{mysql::MySqlValueRef, TypeInfo, Value, ValueRef}; +use time::{Date, OffsetDateTime, PrimitiveDateTime, Time}; + +use crate::Error; + +pub(crate) fn to_json(v: MySqlValueRef) -> Result { + if v.is_null() { + return Ok(JsonValue::Null); + } + + let res = match v.type_info().name() { + "CHAR" | "VARCHAR" | "TINYTEXT" | "TEXT" | "MEDIUMTEXT" | "LONGTEXT" | "ENUM" => { + if let Ok(v) = ValueRef::to_owned(&v).try_decode() { + JsonValue::String(v) + } else { + JsonValue::Null + } + } + "FLOAT" | "DOUBLE" => { + if let Ok(v) = ValueRef::to_owned(&v).try_decode::() { + JsonValue::from(v) + } else { + JsonValue::Null + } + } + "TINYINT" | "SMALLINT" | "INT" | "MEDIUMINT" | "BIGINT" => { + if let Ok(v) = ValueRef::to_owned(&v).try_decode::() { + JsonValue::Number(v.into()) + } else { + JsonValue::Null + } + } + "TINYINT UNSIGNED" | "SMALLINT UNSIGNED" | "INT UNSIGNED" | "MEDIUMINT UNSIGNED" + | "BIGINT UNSIGNED" | "YEAR" => { + if let Ok(v) = ValueRef::to_owned(&v).try_decode::() { + JsonValue::Number(v.into()) + } else { + JsonValue::Null + } + } + "BOOLEAN" => { + if let Ok(v) = ValueRef::to_owned(&v).try_decode() { + JsonValue::Bool(v) + } else { + JsonValue::Null + } + } + "DATE" => { + if let Ok(v) = ValueRef::to_owned(&v).try_decode::() { + JsonValue::String(v.to_string()) + } else { + JsonValue::Null + } + } + "TIME" => { + if let Ok(v) = ValueRef::to_owned(&v).try_decode::