Remove Sync requirement on on_new_window

This commit is contained in:
Tony 2026-01-31 17:28:40 +08:00
parent ee89ab8d92
commit c29c19cb95
No known key found for this signature in database
GPG Key ID: 34BDD3EA27824956
3 changed files with 4 additions and 12 deletions

View File

@ -33,7 +33,7 @@ type WebResourceRequestHandler =
type NavigationHandler = dyn Fn(&Url) -> bool + Send;
type NewWindowHandler = dyn Fn(Url, NewWindowFeatures) -> NewWindowResponse + Send + Sync;
type NewWindowHandler = dyn Fn(Url, NewWindowFeatures) -> NewWindowResponse + Send;
type OnPageLoadHandler = dyn Fn(Url, PageLoadEvent) + Send;

View File

@ -58,8 +58,7 @@ use std::{
pub(crate) type WebResourceRequestHandler =
dyn Fn(http::Request<Vec<u8>>, &mut http::Response<Cow<'static, [u8]>>) + Send + Sync;
pub(crate) type NavigationHandler = dyn Fn(&Url) -> bool + Send;
pub(crate) type NewWindowHandler<R> =
dyn Fn(Url, NewWindowFeatures) -> NewWindowResponse<R> + Send + Sync;
pub(crate) type NewWindowHandler<R> = dyn Fn(Url, NewWindowFeatures) -> NewWindowResponse<R> + Send;
pub(crate) type UriSchemeProtocolHandler =
Box<dyn Fn(&str, http::Request<Vec<u8>>, UriSchemeResponder) + Send + Sync>;
pub(crate) type OnPageLoad<R> = dyn Fn(Webview<R>, PageLoadPayload<'_>) + Send + Sync + 'static;
@ -581,12 +580,9 @@ tauri::Builder::default()
/// # Platform-specific
///
/// - **Android / iOS**: Not supported.
/// - **Windows**: The closure is executed on a separate thread to prevent a deadlock.
///
/// [window.open]: https://developer.mozilla.org/en-US/docs/Web/API/Window/open
pub fn on_new_window<
F: Fn(Url, NewWindowFeatures) -> NewWindowResponse<R> + Send + Sync + 'static,
>(
pub fn on_new_window<F: Fn(Url, NewWindowFeatures) -> NewWindowResponse<R> + Send + 'static>(
mut self,
f: F,
) -> Self {
@ -724,7 +720,6 @@ tauri::Builder::default()
as Box<
dyn Fn(Url, NewWindowFeatures) -> tauri_runtime::webview::NewWindowResponse
+ Send
+ Sync
+ 'static,
>
});

View File

@ -314,12 +314,9 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
/// # Platform-specific
///
/// - **Android / iOS**: Not supported.
/// - **Windows**: The closure is executed on a separate thread to prevent a deadlock.
///
/// [window.open]: https://developer.mozilla.org/en-US/docs/Web/API/Window/open
pub fn on_new_window<
F: Fn(Url, NewWindowFeatures) -> NewWindowResponse<R> + Send + Sync + 'static,
>(
pub fn on_new_window<F: Fn(Url, NewWindowFeatures) -> NewWindowResponse<R> + Send + 'static>(
mut self,
f: F,
) -> Self {