This commit is contained in:
Tony 2026-02-05 17:18:06 -03:00 committed by GitHub
commit 64438068a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 11 deletions

View File

@ -0,0 +1,5 @@
---
'tauri': 'patch:enhance'
---
Use sync commands for window and webview getters to reduce overhead and make the final binary size smaller

View File

@ -28,7 +28,7 @@ mod desktop_commands {
}
#[command(root = "crate")]
pub async fn get_all_webviews<R: Runtime>(app: AppHandle<R>) -> Vec<WebviewRef> {
pub fn get_all_webviews<R: Runtime>(app: AppHandle<R>) -> Vec<WebviewRef> {
app
.manager()
.webviews()
@ -104,10 +104,7 @@ mod desktop_commands {
};
($fn: ident, $cmd: ident, $ret: ty) => {
#[command(root = "crate")]
pub async fn $fn<R: Runtime>(
webview: Webview<R>,
label: Option<String>,
) -> crate::Result<$ret> {
pub fn $fn<R: Runtime>(webview: Webview<R>, label: Option<String>) -> crate::Result<$ret> {
get_webview(webview, label)?.$cmd().map_err(Into::into)
}
};

View File

@ -26,7 +26,7 @@ mod desktop_commands {
};
#[command(root = "crate")]
pub async fn get_all_windows<R: Runtime>(app: AppHandle<R>) -> Vec<String> {
pub fn get_all_windows<R: Runtime>(app: AppHandle<R>) -> Vec<String> {
app.manager().windows().keys().cloned().collect()
}
@ -49,10 +49,7 @@ mod desktop_commands {
macro_rules! getter {
($cmd: ident, $ret: ty) => {
#[command(root = "crate")]
pub async fn $cmd<R: Runtime>(
window: Window<R>,
label: Option<String>,
) -> crate::Result<$ret> {
pub fn $cmd<R: Runtime>(window: Window<R>, label: Option<String>) -> crate::Result<$ret> {
get_window(window, label)?.$cmd().map_err(Into::into)
}
};
@ -210,7 +207,7 @@ mod desktop_commands {
}
#[command(root = "crate")]
pub async fn monitor_from_point<R: Runtime>(
pub fn monitor_from_point<R: Runtime>(
window: Window<R>,
label: Option<String>,
x: f64,