mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-02-06 14:17:02 +00:00
fix(core): raw channel message type regression (#13268)
* Fix raw channel message type regression * Re-word change file * Rename formated_bytes to bytes_as_json_array
This commit is contained in:
parent
87fdc3b9cd
commit
da2a6ae5e3
5
.changes/fix-channel-raw-message-type.md
Normal file
5
.changes/fix-channel-raw-message-type.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
tauri: patch:bug
|
||||
---
|
||||
|
||||
Fix a regression that made the raw type messages received from `Channel.onmessage` became `number[]` instead of `ArrayBuffer` when that message is small
|
||||
@ -154,9 +154,9 @@ impl JavaScriptChannelId {
|
||||
))?;
|
||||
}
|
||||
InvokeResponseBody::Raw(bytes) if bytes.len() < MAX_RAW_DIRECT_EXECUTE_THRESHOLD => {
|
||||
let bytes_as_json_array = serde_json::to_string(&bytes)?;
|
||||
webview.eval(format!(
|
||||
"window['_{callback_id}']({{ message: {}, index: {current_index} }})",
|
||||
serde_json::to_string(&bytes)?,
|
||||
"window['_{callback_id}']({{ message: new Uint8Array({bytes_as_json_array}).buffer, index: {current_index} }})",
|
||||
))?;
|
||||
}
|
||||
// use the fetch API to speed up larger response payloads
|
||||
@ -246,9 +246,9 @@ impl<TSend> Channel<TSend> {
|
||||
webview.eval(format!("window['_{callback_id}']({string})"))?;
|
||||
}
|
||||
InvokeResponseBody::Raw(bytes) if bytes.len() < MAX_RAW_DIRECT_EXECUTE_THRESHOLD => {
|
||||
let bytes_as_json_array = serde_json::to_string(&bytes)?;
|
||||
webview.eval(format!(
|
||||
"window['_{callback_id}']({})",
|
||||
serde_json::to_string(&bytes)?,
|
||||
"window['_{callback_id}'](new Uint8Array({bytes_as_json_array}).buffer)",
|
||||
))?;
|
||||
}
|
||||
// use the fetch API to speed up larger response payloads
|
||||
|
||||
Loading…
Reference in New Issue
Block a user