Skip to content

Commit

Permalink
fix(core): Retain order of map keys in ipc, fixes #7922 (#8577)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
FabianLars authored Jan 10, 2024
1 parent 67d7877 commit b546b42
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-formbody-order.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 3 additions & 2 deletions core/tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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" ] }
Expand Down Expand Up @@ -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" ]
Expand Down
7 changes: 6 additions & 1 deletion core/tauri/src/api/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion tooling/bundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tooling/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit b546b42

Please sign in to comment.