From fcee441b8ab5881b960cb1b19336f24d4f81bac1 Mon Sep 17 00:00:00 2001 From: Simon Hyll Date: Wed, 23 Aug 2023 00:05:31 +0200 Subject: [PATCH 1/3] fix: no longer unpacking and flattening payload --- core/tauri/scripts/core.js | 4 ++-- core/tauri/scripts/ipc-protocol.js | 2 +- core/tauri/src/ipc/protocol.rs | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/core/tauri/scripts/core.js b/core/tauri/scripts/core.js index 6c33e0a0b64b..61bdf1d672ba 100644 --- a/core/tauri/scripts/core.js +++ b/core/tauri/scripts/core.js @@ -59,11 +59,11 @@ window.__TAURI_INVOKE__ = function invoke(cmd, payload = {}, options) { return new Promise(function (resolve, reject) { - var callback = window.__TAURI__.transformCallback(function (r) { + const callback = window.__TAURI__.transformCallback(function (r) { resolve(r) delete window[`_${error}`] }, true) - var error = window.__TAURI__.transformCallback(function (e) { + const error = window.__TAURI__.transformCallback(function (e) { reject(e) delete window[`_${callback}`] }, true) diff --git a/core/tauri/scripts/ipc-protocol.js b/core/tauri/scripts/ipc-protocol.js index 724284af80b0..8d3ac764ec4b 100644 --- a/core/tauri/scripts/ipc-protocol.js +++ b/core/tauri/scripts/ipc-protocol.js @@ -44,7 +44,7 @@ }) } else { // otherwise use the postMessage interface - const { data } = processIpcMessage({ cmd, callback, error, options, ...payload }) + const { data } = processIpcMessage({ cmd, callback, error, options, payload }) window.ipc.postMessage(data) } } diff --git a/core/tauri/src/ipc/protocol.rs b/core/tauri/src/ipc/protocol.rs index 60883c5c88e2..f0cd1d06ea69 100644 --- a/core/tauri/src/ipc/protocol.rs +++ b/core/tauri/src/ipc/protocol.rs @@ -127,7 +127,6 @@ fn handle_ipc_message(message: String, manager: &WindowManager, l cmd: String, callback: CallbackFn, error: CallbackFn, - #[serde(flatten)] payload: serde_json::Value, options: Option, } @@ -142,7 +141,6 @@ fn handle_ipc_message(message: String, manager: &WindowManager, l cmd: String, callback: CallbackFn, error: CallbackFn, - #[serde(flatten)] payload: crate::utils::pattern::isolation::RawIsolationPayload<'a>, options: Option, } From 634cfcb81c0af3b29f45c52c4935b478c10b9fa3 Mon Sep 17 00:00:00 2001 From: Simon Hyll Date: Wed, 23 Aug 2023 00:15:18 +0200 Subject: [PATCH 2/3] chore: added change file --- .changes/fix-ipc-payload.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/fix-ipc-payload.md diff --git a/.changes/fix-ipc-payload.md b/.changes/fix-ipc-payload.md new file mode 100644 index 000000000000..cde0976aaa91 --- /dev/null +++ b/.changes/fix-ipc-payload.md @@ -0,0 +1,5 @@ +--- +"tauri": 'patch:bug' +--- + +No longer unpacking and flattening the `payload` over the IPC so that commands with an argument called `options` don't break. From 3b225225dbdada575a1b2c163e8ac3bfa6794c1a Mon Sep 17 00:00:00 2001 From: Simon Hyll Date: Wed, 23 Aug 2023 00:34:12 +0200 Subject: [PATCH 3/3] chore: fixed changefile message --- .changes/fix-ipc-payload.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changes/fix-ipc-payload.md b/.changes/fix-ipc-payload.md index cde0976aaa91..ea495b054a12 100644 --- a/.changes/fix-ipc-payload.md +++ b/.changes/fix-ipc-payload.md @@ -2,4 +2,4 @@ "tauri": 'patch:bug' --- -No longer unpacking and flattening the `payload` over the IPC so that commands with an argument called `options` don't break. +No longer unpacking and flattening the `payload` over the IPC so that commands with arguments called `cmd`, `callback`, `error`, `options` or `payload` aren't breaking the IPC.