From 2535156dacc1cbd2344a7ad278cc7ed22bf72a4e Mon Sep 17 00:00:00 2001 From: Prospector <6166773+Prospector@users.noreply.github.com> Date: Tue, 14 Oct 2025 19:55:54 -0700 Subject: [PATCH] Revert "refactor(app): reduce tech debt by eliminating `wry` fork (#4500)" This reverts commit dbc64afe --- Cargo.lock | 7 +++++-- Cargo.toml | 3 +++ apps/app/Cargo.toml | 4 ---- apps/app/src/api/ads.rs | 32 ++++++++------------------------ 4 files changed, 16 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d6068768c..8a6cef831 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9349,8 +9349,6 @@ dependencies = [ "url", "urlencoding", "uuid 1.18.1", - "webview2-com", - "windows-core 0.61.2", ] [[package]] @@ -11700,3 +11698,8 @@ dependencies = [ "wasm-bindgen", "web-sys", ] + +[[patch.unused]] +name = "wry" +version = "0.52.1" +source = "git+https://github.com/modrinth/wry?rev=f2ce0b0#f2ce0b0105d9d94f482c4f8ecffb4f3c3c325b40" diff --git a/Cargo.toml b/Cargo.toml index 8d42c3306..31f4c20e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -240,6 +240,9 @@ wildcard_dependencies = "warn" [profile.dev.package.sqlx-macros] opt-level = 3 +[patch.crates-io] +wry = { git = "https://github.com/modrinth/wry", rev = "f2ce0b0" } + # Optimize for speed and reduce size on release builds [profile.release] opt-level = "s" # Optimize for binary size diff --git a/apps/app/Cargo.toml b/apps/app/Cargo.toml index 4a07f2a1c..9631db712 100644 --- a/apps/app/Cargo.toml +++ b/apps/app/Cargo.toml @@ -49,10 +49,6 @@ tauri-build = { workspace = true, features = ["codegen"] } [target.'cfg(target_os = "linux")'.dependencies] tauri-plugin-updater = { workspace = true, optional = true } -[target.'cfg(windows)'.dependencies] -webview2-com.workspace = true -windows-core.workspace = true - [features] # by default Tauri runs in production mode # when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL diff --git a/apps/app/src/api/ads.rs b/apps/app/src/api/ads.rs index 40d00ce76..fd498a56d 100644 --- a/apps/app/src/api/ads.rs +++ b/apps/app/src/api/ads.rs @@ -79,6 +79,7 @@ pub async fn init_ads_window( override_shown: bool, ) -> crate::api::Result<()> { use tauri::WebviewUrl; + const LINK_SCRIPT: &str = include_str!("ads-init.js"); let state = app.state::>(); let mut state = state.write().await; @@ -101,42 +102,25 @@ pub async fn init_ads_window( webview.set_position(PhysicalPosition::new(-1000, -1000)); } } else if let Some(window) = app.get_window("main") { - let webview = window.add_child( + let _ = window.add_child( tauri::webview::WebviewBuilder::new( "ads-window", WebviewUrl::External( AD_LINK.parse().unwrap(), ), ) - .initialization_script_for_all_frames(include_str!("ads-init.js")) - .user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36") - .zoom_hotkeys_enabled(false) - .transparent(true) - .on_new_window(|_, _| tauri::webview::NewWindowResponse::Deny), + .initialization_script(LINK_SCRIPT) + // .initialization_script_for_main_only(LINK_SCRIPT, false) + .user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36") + .zoom_hotkeys_enabled(false) + .transparent(true), if state.shown { position } else { PhysicalPosition::new(-1000.0, -1000.0) }, size, - )?; - - webview.with_webview(#[allow(unused_variables)] |webview2| { - #[cfg(windows)] - { - use webview2_com::Microsoft::Web::WebView2::Win32::ICoreWebView2_8; - use windows_core::Interface; - - let webview2_controller = webview2.controller(); - let Ok(webview2_8) = unsafe { webview2_controller.CoreWebView2() } - .and_then(|core_webview2| core_webview2.cast::()) - else { - return; - }; - - unsafe { webview2_8.SetIsMuted(true) }.ok(); - } - })?; + ); } }