mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-02-06 11:22:04 +00:00
Merge e89f96602f into 7d01aa0417
This commit is contained in:
commit
64438068a2
5
.changes/sync-getter-commands.md
Normal file
5
.changes/sync-getter-commands.md
Normal 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
|
||||
@ -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)
|
||||
}
|
||||
};
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user