diff --git a/plugins/app/src/commands.rs b/plugins/app/src/commands.rs index 1ef048ff..1871473b 100644 --- a/plugins/app/src/commands.rs +++ b/plugins/app/src/commands.rs @@ -12,8 +12,7 @@ pub fn name(app: AppHandle) -> String { #[tauri::command] pub fn tauri_version() -> &'static str { - // TODO: return actual tauri version with `tauri::VERSION` - env!("CARGO_PKG_VERSION") + tauri::VERSION } #[tauri::command] diff --git a/plugins/cli/src/lib.rs b/plugins/cli/src/lib.rs index aaa13498..25795c01 100644 --- a/plugins/cli/src/lib.rs +++ b/plugins/cli/src/lib.rs @@ -11,12 +11,11 @@ use config::{Arg, Config}; pub use error::Error; type Result = std::result::Result; -// TODO: use PluginApi#app when 2.0.0-alpha.9 is released -pub struct Cli(PluginApi, AppHandle); +pub struct Cli(PluginApi); impl Cli { pub fn matches(&self) -> Result { - parser::get_matches(self.0.config(), self.1.package_info()) + parser::get_matches(self.0.config(), self.0.app().package_info()) } } @@ -39,7 +38,7 @@ pub fn init() -> TauriPlugin { Builder::new("cli") .invoke_handler(tauri::generate_handler![cli_matches]) .setup(|app, api| { - app.manage(Cli(api, app.clone())); + app.manage(Cli(api)); Ok(()) }) .build() diff --git a/plugins/dialog/src/desktop.rs b/plugins/dialog/src/desktop.rs index caba5892..25222f91 100644 --- a/plugins/dialog/src/desktop.rs +++ b/plugins/dialog/src/desktop.rs @@ -10,6 +10,7 @@ use std::path::PathBuf; +use raw_window_handle::{HasRawWindowHandle, RawWindowHandle}; use serde::de::DeserializeOwned; use tauri::{plugin::PluginApi, AppHandle, Runtime}; @@ -101,6 +102,14 @@ impl From for rfd::MessageLevel { } } +struct WindowHandle(RawWindowHandle); + +unsafe impl HasRawWindowHandle for WindowHandle { + fn raw_window_handle(&self) -> RawWindowHandle { + self.0 + } +} + impl From> for FileDialog { fn from(d: FileDialogBuilder) -> Self { let mut builder = FileDialog::new(); @@ -119,8 +128,8 @@ impl From> for FileDialog { builder = builder.add_filter(&filter.name, &v); } #[cfg(desktop)] - if let Some(_parent) = d.parent { - // TODO builder = builder.set_parent(&parent); + if let Some(parent) = d.parent { + builder = builder.set_parent(&WindowHandle(parent)); } builder @@ -144,8 +153,8 @@ impl From> for rfd::MessageDialog { dialog = dialog.set_buttons(buttons); } - if let Some(_parent) = d.parent { - // TODO dialog.set_parent(parent); + if let Some(parent) = d.parent { + dialog = dialog.set_parent(&WindowHandle(parent)); } dialog diff --git a/plugins/updater/src/lib.rs b/plugins/updater/src/lib.rs index ae30a372..7d4818b3 100644 --- a/plugins/updater/src/lib.rs +++ b/plugins/updater/src/lib.rs @@ -25,6 +25,7 @@ struct PendingUpdate(Mutex>>); #[derive(Default)] pub struct Builder { target: Option, + installer_args: Option>, } /// Extension trait to use the updater on [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`]. @@ -63,14 +64,26 @@ impl Builder { self } + pub fn installer_args(mut self, args: I) -> Self + where + I: IntoIterator, + S: Into, + { + self.installer_args + .replace(args.into_iter().map(Into::into).collect()); + self + } + pub fn build(self) -> TauriPlugin { let target = self.target; + let installer_args = self.installer_args; PluginBuilder::::new("updater") .setup(move |app, api| { - app.manage(UpdaterState { - target, - config: api.config().clone(), - }); + let mut config = api.config().clone(); + if let Some(installer_args) = installer_args { + config.installer_args = installer_args; + } + app.manage(UpdaterState { target, config }); app.manage(PendingUpdate::(Default::default())); Ok(()) }) diff --git a/plugins/updater/tests/app-updater/src/main.rs b/plugins/updater/tests/app-updater/src/main.rs index c8e21de7..9efc9b0b 100644 --- a/plugins/updater/tests/app-updater/src/main.rs +++ b/plugins/updater/tests/app-updater/src/main.rs @@ -9,6 +9,8 @@ use tauri_plugin_updater::UpdaterExt; fn main() { #[allow(unused_mut)] let mut context = tauri::generate_context!(); + + let mut updater = tauri_plugin_updater::Builder::new(); if std::env::var("TARGET").unwrap_or_default() == "nsis" { // /D sets the default installation directory ($INSTDIR), // overriding InstallDir and InstallDirRegKey. @@ -16,23 +18,18 @@ fn main() { // Only absolute paths are supported. // NOTE: we only need this because this is an integration test and we don't want to install the app in the programs folder // TODO mutate plugin config - /*context - .config_mut() - .tauri - .bundle - .updater - .windows - .installer_args = vec![format!( + updater = updater.installer_args(vec![format!( "/D={}", tauri::utils::platform::current_exe() .unwrap() .parent() .unwrap() .display() - )];*/ + )]); } + tauri::Builder::default() - .plugin(tauri_plugin_updater::Builder::new().build()) + .plugin(updater.build()) .setup(|app| { let handle = app.handle(); tauri::async_runtime::spawn(async move {