tauri-plugin-single-window 1.1.1

Desktop-only Tauri plugin that prevents duplicate app launches and redirects activation to the existing instance.
Documentation
#[derive(Clone, Default)]
pub struct Config {
    pub duplicate_notice: Option<String>,
    pub target_window_label: Option<String>,
    pub(crate) activation_callback: Option<std::sync::Arc<dyn std::any::Any + Send + Sync>>,
}

impl Config {
    pub fn new() -> Self {
        Self {
            duplicate_notice: None,
            target_window_label: None,
            activation_callback: None,
        }
    }

    pub fn with_duplicate_notice<S: Into<String>>(mut self, duplicate_notice: S) -> Self {
        self.duplicate_notice = Some(duplicate_notice.into());
        self
    }

    pub fn with_target_window<S: Into<String>>(mut self, target_window_label: S) -> Self {
        self.target_window_label = Some(target_window_label.into());
        self
    }

    pub fn on_activate<R, F>(mut self, callback: F) -> Self
    where
        R: tauri::Runtime,
        F: Fn(tauri::AppHandle<R>, crate::ActivationPayload) + Send + Sync + 'static,
    {
        let callback: crate::ActivationCallback<R> = std::sync::Arc::new(callback);
        self.activation_callback = Some(std::sync::Arc::new(callback));
        self
    }
}