Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance(core): use sync commands for window and webview getters #12162

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/sync-getter-commands.md
Original file line number Diff line number Diff line change
@@ -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
7 changes: 2 additions & 5 deletions crates/tauri/src/webview/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,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()
Expand Down Expand Up @@ -148,10 +148,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)
}
};
Expand Down
9 changes: 3 additions & 6 deletions crates/tauri/src/window/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand All @@ -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)
}
};
Expand Down Expand Up @@ -209,7 +206,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,
Expand Down
Loading