Skip to content

Commit b546b42

Browse files
authored
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
1 parent 67d7877 commit b546b42

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

.changes/fix-formbody-order.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tauri': 'patch:bug'
3+
---
4+
5+
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.

core/tauri/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ targets = [
4949
normal = [ "reqwest" ]
5050

5151
[dependencies]
52-
serde_json = { version = "1.0", features = [ "raw_value" ] }
52+
serde_json = { version = "1.0", features = [ "raw_value", "preserve_order" ] }
5353
serde = { version = "1.0", features = [ "derive" ] }
5454
tokio = { version = "1", features = [ "rt", "rt-multi-thread", "sync", "fs", "io-util" ] }
5555
futures-util = "0.3"
@@ -95,6 +95,7 @@ ico = { version = "0.2.0", optional = true }
9595
encoding_rs = "0.8.31"
9696
sys-locale = { version = "0.2.3", optional = true }
9797
tracing = { version = "0.1", optional = true }
98+
indexmap = { version = "1", features = [ "std", "serde" ], optional = true }
9899

99100
[target."cfg(any(target_os = \"macos\", windows, target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
100101
rfd = { version = "0.10", optional = true, features = [ "gtk3", "common-controls-v6" ] }
@@ -156,7 +157,7 @@ updater = [
156157
"dialog-ask",
157158
"fs-extract-api"
158159
]
159-
http-api = [ "reqwest", "bytes" ]
160+
http-api = [ "reqwest", "bytes", "indexmap" ]
160161
http-multipart = [ "reqwest/multipart" ]
161162
os-api = [ "sys-locale" ]
162163
shell-open-api = [ "open", "regex", "tauri-macros/shell-scope" ]

core/tauri/src/api/http.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,16 @@ pub enum FormPart {
250250

251251
/// Form body definition.
252252
#[derive(Debug, Deserialize)]
253-
pub struct FormBody(pub(crate) HashMap<String, FormPart>);
253+
pub struct FormBody(pub(crate) indexmap::IndexMap<String, FormPart>);
254254

255255
impl FormBody {
256256
/// Creates a new form body.
257257
pub fn new(data: HashMap<String, FormPart>) -> Self {
258+
Self(indexmap::IndexMap::from_iter(data))
259+
}
260+
261+
/// Creates a new form body with pre-ordered keys. Useful if the api requires a specific order.
262+
pub fn new_ordered(data: indexmap::IndexMap<String, FormPart>) -> Self {
258263
Self(data)
259264
}
260265
}

tooling/bundler/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ tempfile = "3.8.1"
3232
log = { version = "0.4.20", features = [ "kv_unstable" ] }
3333
dirs-next = "2.0"
3434
os_pipe = "1"
35-
ureq = { version = "2.8", default-features = false }
35+
ureq = { version = "2.9.1", default-features = false }
3636
native-tls = { version = "0.2", optional = true }
3737
hex = "0.4"
3838
semver = "1"

tooling/cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ handlebars = "4.4"
5959
include_dir = "0.7"
6060
minisign = "=0.7.3"
6161
base64 = "0.21.5"
62-
ureq = { version = "2.8", default-features = false, features = [ "gzip" ] }
62+
ureq = { version = "2.9.1", default-features = false, features = [ "gzip" ] }
6363
os_info = "3"
6464
semver = "1.0"
6565
regex = "1.10.2"

0 commit comments

Comments
 (0)