chore(deps): upgrade wry from 0.45.0 to v0.52.0 (#4255)

* chore(deps): upgrade wry from 0.45.0 to v0.51.2

* Unwrap webview

* update tauri

* fix more versions

* switch to a single websocket per app to communicate edits in desktop

* use websockets on the ts side

* queue pending edits before the websocket connects

* fix decoding the websocket blobs in ts

* rebuild js

* fix clippy

* more sensible struct names

* allow http on android and require a key to match between the webview and native sides

* remove out.txt

* clippy

* small style changes

* More light cleanups

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
Co-authored-by: Evan Almloff <evanalmloff@gmail.com>
This commit is contained in:
authored and GitHub committed 2025-07-01 18:08:24 -07:00
1 parent 65dd1f1762
commit d5daf14c15
18 files changed
+1324 -1083

No files matched your search

+17 -15
View File
@@ -7,12 +7,6 @@ use wry::{
RequestAsyncResponder,
};
#[cfg(any(target_os = "android", target_os = "windows"))]
const EDITS_PATH: &str = "http://dioxus.index.html/__edits";
#[cfg(not(any(target_os = "android", target_os = "windows")))]
const EDITS_PATH: &str = "dioxus://index.html/__edits";
#[cfg(any(target_os = "android", target_os = "windows"))]
const EVENTS_PATH: &str = "http://dioxus.index.html/__events";
@@ -42,17 +36,19 @@ pub(super) fn desktop_handler(
headless: bool,
) {
// Try to serve the index file first
if let Some(index_bytes) =
index_request(&request, custom_head, custom_index, root_name, headless)
{
if let Some(index_bytes) = index_request(
&request,
custom_head,
custom_index,
root_name,
headless,
edit_state,
) {
return responder.respond(index_bytes);
}
// If the request is asking for edits (ie binary protocol streaming), do that
let trimmed_uri = request.uri().path().trim_matches('/');
if trimmed_uri == "__edits" {
return edit_state.wry_queue.handle_request(responder);
}
// If the request is asking for an event response, do that
if trimmed_uri == "__events" {
@@ -93,6 +89,7 @@ fn index_request(
custom_index: Option<String>,
root_name: &str,
headless: bool,
edit_state: &WebviewEdits,
) -> Option<Response<Vec<u8>>> {
// If the request is for the root, we'll serve the index.html file.
if request.uri().path() != "/" {
@@ -114,7 +111,7 @@ fn index_request(
// Might want to document this
index.insert_str(
index.find("</body>").expect("Body element to exist"),
&module_loader(root_name, headless),
&module_loader(root_name, headless, edit_state),
);
Response::builder()
@@ -130,7 +127,12 @@ fn index_request(
/// - root_name: the root element (by Id) that we stream edits into
/// - headless: is this page being loaded but invisible? Important because not all windows are visible and the
/// interpreter can't connect until the window is ready.
fn module_loader(root_id: &str, headless: bool) -> String {
/// - port: the port that the websocket server is listening on for edits
/// - webview_id: the id of the webview that we're loading this into. This is used to differentiate between
/// multiple webviews in the same application, so that we can send edits to the correct one.
fn module_loader(root_id: &str, headless: bool, edit_state: &WebviewEdits) -> String {
let edits_path = edit_state.wry_queue.edits_path();
format!(
r#"
<script type="module">
@@ -141,7 +143,7 @@ fn module_loader(root_id: &str, headless: bool) -> String {
{NATIVE_JS}
// The native interpreter extends the sledgehammer interpreter with a few extra methods that we use for IPC
window.interpreter = new NativeInterpreter("{EDITS_PATH}", "{EVENTS_PATH}");
window.interpreter = new NativeInterpreter("{edits_path}", "{EVENTS_PATH}");
// Wait for the page to load before sending the initialize message
window.onload = function() {{