Skip to content

Commit

Permalink
chore(deps): Update windows-rs to 0.58 and SDK to 1.0.2592.51
Browse files Browse the repository at this point in the history
  • Loading branch information
wravery committed Jul 24, 2024
1 parent cb4c42f commit 2a4d92c
Show file tree
Hide file tree
Showing 18 changed files with 7,737 additions and 6,465 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ By default this crate uses the `WebView2LoaderStatic.lib` static library and doe
## Updating the WebView2 SDK
You can tell the `update-bindings` tool to use a different version by updating `WEBVIEW2_VERSION` in `main.rs`:
```rust
const WEBVIEW2_VERSION: &str = "1.0.2535.41";
const WEBVIEW2_VERSION: &str = "1.0.2592.51";
```
It will also regenerate [callback_interfaces.rs](./crates/bindings/src/callback_interfaces.rs) if they change in a new version. This file is used in `webview2-com`, and in particular, the tests in [callback.rs](./crates/webview2-com/src/callback.rs) verify that all of the interfaces listed in `callback_interfaces.rs` are implemented. If a new version of the SDK declared additional callback interfaces, you will need to add those interfaces to `callback.rs` using the `#[completed_callback]` (for `ICoreWebView2...CompletedHandler` interfaces) and `#[event_callback]` (for `ICoreWebView2...EventHandler` interfaces) macros.

Expand Down
8 changes: 4 additions & 4 deletions crates/bindings/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "webview2-com-sys"
version = "0.31.0"
version = "0.32.0"
edition = "2021"
rust-version = "1.61"
description = "Bindings generated with the windows crate for the WebView2 COM APIs"
Expand All @@ -19,10 +19,10 @@ targets = [
]

[dependencies]
windows-core = "0.57"
windows-core = "0.58"

[dependencies.windows]
version = "0.57"
version = "0.58"
features = [
"implement",
"Win32_Foundation",
Expand All @@ -35,4 +35,4 @@ features = [
]

[build-dependencies]
thiserror = "1.0.26"
thiserror = "1.0"
Binary file modified crates/bindings/arm64/WebView2Loader.dll
Binary file not shown.
Binary file modified crates/bindings/arm64/WebView2LoaderStatic.lib
Binary file not shown.
14,119 changes: 7,695 additions & 6,424 deletions crates/bindings/src/Microsoft.rs

Large diffs are not rendered by default.

Binary file modified crates/bindings/x64/WebView2Loader.dll
Binary file not shown.
Binary file modified crates/bindings/x64/WebView2LoaderStatic.lib
Binary file not shown.
Binary file modified crates/bindings/x86/WebView2Loader.dll
Binary file not shown.
Binary file modified crates/bindings/x86/WebView2LoaderStatic.lib
Binary file not shown.
8 changes: 4 additions & 4 deletions crates/callback-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "webview2-com-macros"
version = "0.7.0"
version = "0.8.0"
edition = "2021"
description = "Macros which generate callback implementations for WebView2 COM APIs"
repository = "https://github.com/wravery/webview2-rs"
Expand All @@ -12,6 +12,6 @@ categories = [ "os::windows-apis" ]
proc-macro = true

[dependencies]
proc-macro2 = "1.0.26"
quote = "1.0.9"
syn = { version = "2.0.13", features = ["full"] }
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "2.0", features = ["full"] }
14 changes: 8 additions & 6 deletions crates/callback-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ fn impl_completed_callback(ast: &CallbackStruct) -> TokenStream {
let vis = &ast.vis;

let name = &ast.ident;
let name_impl = format_ident!("{name}_Impl");
let closure = get_closure(name);
let interface = &ast.args.interface;
let interface = interface
Expand All @@ -72,7 +73,7 @@ fn impl_completed_callback(ast: &CallbackStruct) -> TokenStream {
let arg_1 = &ast.args.arg_1;
let arg_2 = &ast.args.arg_2;

let msg = format!("Implementation of [`{}`].", interface.ident);
let msg = format!("Implementation of [`{interface_impl}`].");

let gen = match arg_2 {
Some(arg_2) => quote! {
Expand Down Expand Up @@ -110,7 +111,7 @@ fn impl_completed_callback(ast: &CallbackStruct) -> TokenStream {
}

#[allow(non_snake_case)]
impl #interface_impl for #name {
impl #interface_impl for #name_impl {
fn Invoke<'a>(
&self,
arg_1: <#arg_1 as InvokeArg<'a>>::Input,
Expand Down Expand Up @@ -161,7 +162,7 @@ fn impl_completed_callback(ast: &CallbackStruct) -> TokenStream {
}

#[allow(non_snake_case)]
impl #interface_impl for #name {
impl #interface_impl for #name_impl {
fn Invoke<'a>(
&self,
arg_1: <#arg_1 as InvokeArg<'a>>::Input,
Expand Down Expand Up @@ -191,6 +192,7 @@ fn impl_event_callback(ast: &CallbackStruct) -> TokenStream {
let vis = &ast.vis;

let name = &ast.ident;
let name_impl = format_ident!("{name}_Impl");
let closure = get_closure(name);

let interface = &ast.args.interface;
Expand All @@ -208,7 +210,7 @@ fn impl_event_callback(ast: &CallbackStruct) -> TokenStream {
.as_ref()
.expect("event_callback should always have 2 arguments");

let msg = format!("Implementation of [`{}`].", interface.ident);
let msg = format!("Implementation of [`{interface_impl}`].");

let gen = quote! {
type #closure = EventClosure<#arg_1, #arg_2>;
Expand All @@ -226,7 +228,7 @@ fn impl_event_callback(ast: &CallbackStruct) -> TokenStream {
}

#[allow(non_snake_case)]
impl #interface_impl for #name {
impl #interface_impl for #name_impl {
fn Invoke<'a>(
&self,
arg_1: <#arg_1 as InvokeArg<'a>>::Input,
Expand All @@ -244,5 +246,5 @@ fn impl_event_callback(ast: &CallbackStruct) -> TokenStream {
}

fn get_closure(name: &Ident) -> Ident {
format_ident!("{}Closure", name)
format_ident!("{name}Closure")
}
6 changes: 3 additions & 3 deletions crates/update-bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ edition = "2021"
publish = false

[dependencies]
regex = "1.5.4"
thiserror = "1.0.26"
regex = "1.0"
thiserror = "1.0"

[dependencies.windows-bindgen]
version = "0.57"
version = "0.58"
features = [ "metadata" ]
2 changes: 1 addition & 1 deletion crates/update-bindings/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ mod webview2_nuget {
include!("../../bindings/src/callback_interfaces.rs");

const WEBVIEW2_NAME: &str = "Microsoft.Web.WebView2";
const WEBVIEW2_VERSION: &str = "1.0.2535.41";
const WEBVIEW2_VERSION: &str = "1.0.2592.51";

pub fn install() -> super::Result<PathBuf> {
let out_dir = get_out_dir();
Expand Down
Binary file modified crates/update-bindings/winmd/Microsoft.Web.WebView2.Win32.winmd
Binary file not shown.
18 changes: 9 additions & 9 deletions crates/webview2-com/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "webview2-com"
version = "0.31.0"
version = "0.32.0"
edition = "2021"
rust-version = "1.61"
description = "Rust bindings for the WebView2 COM APIs"
Expand All @@ -19,23 +19,23 @@ targets = [
]

[dependencies]
webview2-com-sys = "0.31.0"
webview2-com-macros = "0.7.0"
windows-core = "0.57"
windows-implement = "0.57"
windows-interface = "0.57"
webview2-com-sys = "0.32"
webview2-com-macros = "0.8"
windows-core = "0.58"
windows-implement = "0.58"
windows-interface = "0.58"

[dependencies.windows]
version = "0.57"
version = "0.58"
features = [ "implement" ]

[dev-dependencies]
regex = "1.5.4"
regex = "1.0"
serde = { version = "1.0", features = [ "derive" ] }
serde_json = "1.0"

[dev-dependencies.windows]
version = "0.57"
version = "0.58"
features = [
"Win32_Graphics_Gdi",
"Win32_System_LibraryLoader",
Expand Down
4 changes: 2 additions & 2 deletions crates/webview2-com/examples/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl FrameWindow {
};

FrameWindow {
window: Rc::new(hwnd),
window: Rc::new(hwnd.unwrap_or_default()),
size: Rc::new(RefCell::new(SIZE { cx: 0, cy: 0 })),
}
}
Expand Down Expand Up @@ -355,7 +355,7 @@ impl WebView {
unsafe {
let _ = WindowsAndMessaging::ShowWindow(hwnd, WindowsAndMessaging::SW_SHOW);
let _ = Gdi::UpdateWindow(hwnd);
KeyboardAndMouse::SetFocus(hwnd);
let _ = KeyboardAndMouse::SetFocus(hwnd);
}
}

Expand Down
19 changes: 9 additions & 10 deletions crates/webview2-com/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl CoreWebView2EnvironmentOptions {
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
impl ICoreWebView2EnvironmentOptions_Impl for CoreWebView2EnvironmentOptions {
impl ICoreWebView2EnvironmentOptions_Impl for CoreWebView2EnvironmentOptions_Impl {
fn AdditionalBrowserArguments(&self, result: *mut PWSTR) -> Result<()> {
if result.is_null() {
E_POINTER.ok()
Expand Down Expand Up @@ -283,7 +283,7 @@ impl ICoreWebView2EnvironmentOptions_Impl for CoreWebView2EnvironmentOptions {
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
impl ICoreWebView2EnvironmentOptions2_Impl for CoreWebView2EnvironmentOptions {
impl ICoreWebView2EnvironmentOptions2_Impl for CoreWebView2EnvironmentOptions_Impl {
fn ExclusiveUserDataFolderAccess(&self, result: *mut BOOL) -> Result<()> {
if result.is_null() {
E_POINTER.ok()
Expand All @@ -302,7 +302,7 @@ impl ICoreWebView2EnvironmentOptions2_Impl for CoreWebView2EnvironmentOptions {
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
impl ICoreWebView2EnvironmentOptions3_Impl for CoreWebView2EnvironmentOptions {
impl ICoreWebView2EnvironmentOptions3_Impl for CoreWebView2EnvironmentOptions_Impl {
fn IsCustomCrashReportingEnabled(&self, result: *mut BOOL) -> Result<()> {
if result.is_null() {
E_POINTER.ok()
Expand Down Expand Up @@ -340,7 +340,7 @@ pub unsafe trait IFixedEnvironmentOptions4: IUnknown {
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
impl IFixedEnvironmentOptions4_Impl for CoreWebView2EnvironmentOptions {
impl IFixedEnvironmentOptions4_Impl for CoreWebView2EnvironmentOptions_Impl {
#[allow(clippy::crosspointer_transmute)]
unsafe fn GetCustomSchemeRegistrations(
&self,
Expand All @@ -354,9 +354,9 @@ impl IFixedEnvironmentOptions4_Impl for CoreWebView2EnvironmentOptions {
if let Ok(length) = scheme_registrations.len().try_into() {
*count = length;
if !scheme_registrations.is_empty() {
*results = mem::transmute(CoTaskMemAlloc(
*results = CoTaskMemAlloc(
mem::size_of::<*mut c_void>() * (*scheme_registrations).len(),
));
) as *mut *mut _;
let results =
ptr::slice_from_raw_parts_mut(*results, scheme_registrations.len());
for (i, scheme) in scheme_registrations.iter().enumerate() {
Expand Down Expand Up @@ -489,7 +489,7 @@ impl CoreWebView2CustomSchemeRegistration {
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
impl ICoreWebView2CustomSchemeRegistration_Impl for CoreWebView2CustomSchemeRegistration {
impl ICoreWebView2CustomSchemeRegistration_Impl for CoreWebView2CustomSchemeRegistration_Impl {
fn SchemeName(&self, result: *mut PWSTR) -> Result<()> {
if result.is_null() {
E_POINTER.ok()
Expand Down Expand Up @@ -523,9 +523,8 @@ impl ICoreWebView2CustomSchemeRegistration_Impl for CoreWebView2CustomSchemeRegi
.try_into()
.map_err(|_| Error::from(E_UNEXPECTED))?;
if !allowed_origins.is_empty() {
*results = mem::transmute(CoTaskMemAlloc(
mem::size_of::<*mut PWSTR>() * (*allowed_origins).len(),
));
*results = CoTaskMemAlloc(mem::size_of::<*mut PWSTR>() * (*allowed_origins).len())
as *mut _;
let results = ptr::slice_from_raw_parts_mut(*results, allowed_origins.len());
for (i, scheme) in allowed_origins.iter().enumerate() {
(*results)[i] = pwstr_from_str(scheme);
Expand Down
2 changes: 1 addition & 1 deletion crates/webview2-com/src/pwstr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<'a> Drop for CoTaskMemPWSTR<'a> {
fn drop(&mut self) {
if !self.0.is_null() {
unsafe {
Com::CoTaskMemFree(Some(mem::transmute(self.0.as_ptr())));
Com::CoTaskMemFree(Some(self.0.as_ptr() as *mut _ as *const _));
}
}
}
Expand Down

0 comments on commit 2a4d92c

Please sign in to comment.