Skip to content

Commit

Permalink
chore(deps): update windows crate to 0.54 and webview2-com to 0.29 (
Browse files Browse the repository at this point in the history
#1190)

* chore(deps): update `windows` crate to 0.54 and `webview2-com` to 0.29

* actually update windows?

* fix build
  • Loading branch information
amrbashir authored Mar 19, 2024
1 parent ba1fa58 commit e1e2e07
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 47 deletions.
5 changes: 5 additions & 0 deletions .changes/webview2-0.29.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wry": "patch"
---

Update `webview2-com` crate to `0.29`
5 changes: 5 additions & 0 deletions .changes/windows-0.54.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wry": "patch"
---

Update `windows` crate to `0.54`
14 changes: 5 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,8 @@ tracing = [ "dep:tracing" ]
cfg_aliases = "0.1"

[dependencies]
libc = "0.2"
log = "0.4"
tracing = { version = "0.1", optional = true }
once_cell = "1"
serde = { version = "1.0", features = [ "derive" ] }
serde_json = "1.0"
thiserror = "1.0"
http = "0.2"
raw-window-handle = { version = "0.6", features = [ "std" ] }
Expand All @@ -70,14 +66,13 @@ gdkx11 = { version = "0.18", optional = true }
percent-encoding = "2.1"

[target."cfg(target_os = \"windows\")".dependencies]
webview2-com = "0.28"
windows-implement = "0.52"
webview2-com = "0.29"
windows-version = "0.1"
dunce = "1"

[target."cfg(target_os = \"windows\")".dependencies.windows]
version = "0.52"
features = [
[target."cfg(target_os = \"windows\")".dependencies.windows]
version = "0.54"
features = [
"implement",
"Win32_Foundation",
"Win32_Graphics_Gdi",
Expand Down Expand Up @@ -113,6 +108,7 @@ ndk = "0.7"
ndk-sys = "0.4"
ndk-context = "0.1"
tao-macros = "0.1"
libc = "0.2"

[dev-dependencies]
pollster = "0.3.0"
Expand Down
35 changes: 26 additions & 9 deletions src/android/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ fn handle_request(
let final_request = match request_builder.body(Vec::new()) {
Ok(req) => req,
Err(e) => {
log::warn!("Failed to build response: {}", e);
#[cfg(feature = "tracing")]
tracing::warn!("Failed to build response: {}", e);
return Ok(*JObject::null());
}
};
Expand All @@ -180,7 +181,8 @@ fn handle_request(
None
};
if let Some(err) = status_err {
log::warn!("{}", err);
#[cfg(feature = "tracing")]
tracing::warn!("{}", err);
return Ok(*JObject::null());
}

Expand Down Expand Up @@ -253,7 +255,8 @@ pub unsafe fn handleRequest(
match handle_request(&mut env, request, is_document_start_script_enabled) {
Ok(response) => response,
Err(e) => {
log::warn!("Failed to handle request: {}", e);
#[cfg(feature = "tracing")]
tracing::warn!("Failed to handle request: {}", e);
JObject::null().as_raw()
}
}
Expand All @@ -274,7 +277,8 @@ pub unsafe fn shouldOverride(mut env: JNIEnv, _: JClass, url: JString) -> jboole
.unwrap_or(false)
}
Err(e) => {
log::warn!("Failed to parse JString: {}", e);
#[cfg(feature = "tracing")]
tracing::warn!("Failed to parse JString: {}", e);
false
}
}
Expand All @@ -295,7 +299,8 @@ pub unsafe fn onEval(mut env: JNIEnv, _: JClass, id: jint, result: JString) {
}
}
Err(e) => {
log::warn!("Failed to parse JString: {}", e);
#[cfg(feature = "tracing")]
tracing::warn!("Failed to parse JString: {}", e);
}
}
}
Expand All @@ -312,7 +317,10 @@ pub unsafe fn ipc(mut env: JNIEnv, _: JClass, url: JString, body: JString) {
(ipc.handler)(Request::builder().uri(url).body(body).unwrap())
}
}
(Err(e), _) | (_, Err(e)) => log::warn!("Failed to parse JString: {}", e),
(Err(e), _) | (_, Err(e)) => {
#[cfg(feature = "tracing")]
tracing::warn!("Failed to parse JString: {}", e)
}
}
}

Expand All @@ -325,7 +333,10 @@ pub unsafe fn handleReceivedTitle(mut env: JNIEnv, _: JClass, _webview: JObject,
(title_handler.handler)(title)
}
}
Err(e) => log::warn!("Failed to parse JString: {}", e),
Err(e) => {
#[cfg(feature = "tracing")]
tracing::warn!("Failed to parse JString: {}", e)
}
}
}

Expand All @@ -352,7 +363,10 @@ pub unsafe fn onPageLoading(mut env: JNIEnv, _: JClass, url: JString) {
(on_load.handler)(PageLoadEvent::Started, url)
}
}
Err(e) => log::warn!("Failed to parse JString: {}", e),
Err(e) => {
#[cfg(feature = "tracing")]
tracing::warn!("Failed to parse JString: {}", e)
}
}
}

Expand All @@ -365,6 +379,9 @@ pub unsafe fn onPageLoaded(mut env: JNIEnv, _: JClass, url: JString) {
(on_load.handler)(PageLoadEvent::Finished, url)
}
}
Err(e) => log::warn!("Failed to parse JString: {}", e),
Err(e) => {
#[cfg(feature = "tracing")]
tracing::warn!("Failed to parse JString: {}", e)
}
}
}
3 changes: 2 additions & 1 deletion src/android/main_pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ impl<'a> MainPipe<'a> {
activity,
webview: &webview,
}) {
log::warn!("failed to run webview created hook: {e}");
#[cfg(feature = "tracing")]
tracing::warn!("failed to run webview created hook: {e}");
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ impl InnerWebView {
let responder: Box<dyn FnOnce(HttpResponse<Cow<'static, [u8]>>)> =
Box::new(move |mut response| {
if !is_document_start_script_enabled {
log::info!("`addDocumentStartJavaScript` is not supported; injecting initialization scripts via custom protocol handler");
#[cfg(feature = "tracing")]
tracing::info!("`addDocumentStartJavaScript` is not supported; injecting initialization scripts via custom protocol handler");
let should_inject_scripts = response
.headers()
.get(CONTENT_TYPE)
Expand Down
2 changes: 0 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ pub enum Error {
SenderError(#[from] std::sync::mpsc::SendError<String>),
#[error("Failed to send the message")]
MessageSender,
#[error(transparent)]
Json(#[from] serde_json::Error),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[cfg(target_os = "windows")]
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ impl WebView {

/// An event describing drag and drop operations on the webview.
#[non_exhaustive]
#[derive(Debug, serde::Serialize, Clone)]
#[derive(Debug, Clone)]
pub enum DragDropEvent {
/// A drag operation has entered the webview.
Enter {
Expand Down
38 changes: 20 additions & 18 deletions src/webview2/drag_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,26 @@ use std::{
rc::Rc,
};

use windows::Win32::{
Foundation::{self as win32f, BOOL, DRAGDROP_E_INVALIDHWND, HWND, LPARAM, POINT, POINTL},
Graphics::Gdi::ScreenToClient,
System::{
Com::{IDataObject, DVASPECT_CONTENT, FORMATETC, TYMED_HGLOBAL},
Ole::{
IDropTarget, IDropTarget_Impl, RegisterDragDrop, RevokeDragDrop, CF_HDROP, DROPEFFECT,
DROPEFFECT_COPY, DROPEFFECT_NONE,
use windows::{
core::implement,
Win32::{
Foundation::{BOOL, DRAGDROP_E_INVALIDHWND, HWND, LPARAM, POINT, POINTL},
Graphics::Gdi::ScreenToClient,
System::{
Com::{IDataObject, DVASPECT_CONTENT, FORMATETC, TYMED_HGLOBAL},
Ole::{
IDropTarget, IDropTarget_Impl, RegisterDragDrop, RevokeDragDrop, CF_HDROP, DROPEFFECT,
DROPEFFECT_COPY, DROPEFFECT_NONE,
},
SystemServices::MODIFIERKEYS_FLAGS,
},
UI::{
Shell::{DragFinish, DragQueryFileW, HDROP},
WindowsAndMessaging::EnumChildWindows,
},
SystemServices::MODIFIERKEYS_FLAGS,
},
UI::{
Shell::{DragFinish, DragQueryFileW, HDROP},
WindowsAndMessaging::EnumChildWindows,
},
};

use windows_implement::implement;

#[derive(Default)]
pub(crate) struct DragDropController {
drop_targets: Vec<IDropTarget>,
Expand Down Expand Up @@ -133,10 +134,11 @@ impl DragDropTarget {

Some(hdrop)
}
Err(error) => {
log::warn!(
Err(_error) => {
#[cfg(feature = "tracing")]
tracing::warn!(
"{}",
match error.code() {
match _error.code() {
win32f::DV_E_FORMATETC => {
// If the dropped item is not a file this error will occur.
// In this case it is OK to return without taking further action.
Expand Down
2 changes: 1 addition & 1 deletion src/webview2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use once_cell::sync::Lazy;
use raw_window_handle::{HasWindowHandle, RawWindowHandle};
use webview2_com::{Microsoft::Web::WebView2::Win32::*, *};
use windows::{
core::{s, ComInterface, PCWSTR, PWSTR},
core::{s, Interface, PCWSTR, PWSTR},
Win32::{
Foundation::*,
Globalization::{self, MAX_LOCALE_NAME},
Expand Down
5 changes: 3 additions & 2 deletions src/wkwebview/download.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::{path::PathBuf, ptr::null_mut, rc::Rc};

use cocoa::base::id;
use libc::c_void;
use objc::{
declare::ClassDecl,
runtime::{Object, Sel},
};
use std::ffi::c_void;

use super::NSString;

Expand Down Expand Up @@ -79,7 +79,8 @@ pub extern "C" fn download_policy(
false => (*handler).call((null_mut(),)),
};
} else {
log::warn!("WebView instance is dropped! This navigation handler shouldn't be called.");
#[cfg(feature = "tracing")]
tracing::warn!("WebView instance is dropped! This navigation handler shouldn't be called.");
(*handler).call((null_mut(),));
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/wkwebview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ impl InnerWebView {
}
}

log::warn!("WebView received invalid IPC call.");
#[cfg(feature = "tracing")]
tracing::warn!("WebView received invalid IPC call.");
}
}

Expand Down Expand Up @@ -288,7 +289,8 @@ impl InnerWebView {
Err(_) => respond_with_404(),
};
} else {
log::warn!(
#[cfg(feature = "tracing")]
tracing::warn!(
"Either WebView or WebContext instance is dropped! This handler shouldn't be called."
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/wkwebview/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: MIT

use cocoa::base::nil;
use libc::c_char;
use std::ffi::c_char;

use crate::{proxy::ProxyEndpoint, Error};

Expand Down

0 comments on commit e1e2e07

Please sign in to comment.