fix(core): Retain order of map keys in ipc, fixes #7922 (#8577)

* fix(core): Retain order of map keys in ipc, fixes #7922

* enable dep on http-api feature instead of http-request

* Create fix-formbody-order.md

* Update fix-formbody-order.md
This commit is contained in:
Fabian-Lars 2024-01-10 20:03:25 +01:00 committed by GitHub
parent 67d7877f27
commit b546b42db7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 5 deletions

View File

@ -0,0 +1,5 @@
---
'tauri': 'patch:bug'
---
Preserve the order of JS object/map keys in IPC calls. This also fixes issues with the JS `http` module when calling to servers that required a specific order of `FormBody` contents.

View File

@ -49,7 +49,7 @@ targets = [
normal = [ "reqwest" ]
[dependencies]
serde_json = { version = "1.0", features = [ "raw_value" ] }
serde_json = { version = "1.0", features = [ "raw_value", "preserve_order" ] }
serde = { version = "1.0", features = [ "derive" ] }
tokio = { version = "1", features = [ "rt", "rt-multi-thread", "sync", "fs", "io-util" ] }
futures-util = "0.3"
@ -95,6 +95,7 @@ ico = { version = "0.2.0", optional = true }
encoding_rs = "0.8.31"
sys-locale = { version = "0.2.3", optional = true }
tracing = { version = "0.1", optional = true }
indexmap = { version = "1", features = [ "std", "serde" ], optional = true }
[target."cfg(any(target_os = \"macos\", windows, target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
rfd = { version = "0.10", optional = true, features = [ "gtk3", "common-controls-v6" ] }
@ -156,7 +157,7 @@ updater = [
"dialog-ask",
"fs-extract-api"
]
http-api = [ "reqwest", "bytes" ]
http-api = [ "reqwest", "bytes", "indexmap" ]
http-multipart = [ "reqwest/multipart" ]
os-api = [ "sys-locale" ]
shell-open-api = [ "open", "regex", "tauri-macros/shell-scope" ]

View File

@ -250,11 +250,16 @@ pub enum FormPart {
/// Form body definition.
#[derive(Debug, Deserialize)]
pub struct FormBody(pub(crate) HashMap<String, FormPart>);
pub struct FormBody(pub(crate) indexmap::IndexMap<String, FormPart>);
impl FormBody {
/// Creates a new form body.
pub fn new(data: HashMap<String, FormPart>) -> Self {
Self(indexmap::IndexMap::from_iter(data))
}
/// Creates a new form body with pre-ordered keys. Useful if the api requires a specific order.
pub fn new_ordered(data: indexmap::IndexMap<String, FormPart>) -> Self {
Self(data)
}
}

View File

@ -32,7 +32,7 @@ tempfile = "3.8.1"
log = { version = "0.4.20", features = [ "kv_unstable" ] }
dirs-next = "2.0"
os_pipe = "1"
ureq = { version = "2.8", default-features = false }
ureq = { version = "2.9.1", default-features = false }
native-tls = { version = "0.2", optional = true }
hex = "0.4"
semver = "1"

View File

@ -59,7 +59,7 @@ handlebars = "4.4"
include_dir = "0.7"
minisign = "=0.7.3"
base64 = "0.21.5"
ureq = { version = "2.8", default-features = false, features = [ "gzip" ] }
ureq = { version = "2.9.1", default-features = false, features = [ "gzip" ] }
os_info = "3"
semver = "1.0"
regex = "1.10.2"