diff --git a/.changes/single-instance-optional-deep-link.md b/.changes/single-instance-optional-deep-link.md new file mode 100644 index 00000000..aabf98d1 --- /dev/null +++ b/.changes/single-instance-optional-deep-link.md @@ -0,0 +1,5 @@ +--- +"single-instance": "patch" +--- + +Put deep link integration behined a feature diff --git a/plugins/deep-link/README.md b/plugins/deep-link/README.md index 394f4ece..e761fa68 100644 --- a/plugins/deep-link/README.md +++ b/plugins/deep-link/README.md @@ -145,7 +145,7 @@ await onOpenUrl((urls) => { }) ``` -Note that the Plugin will only emit events on macOS, iOS and Android. On Windows and Linux the OS will spawn a new instance of your app with the URL as a CLI argument. If you want your app to behave on Windows & Linux similar to the other platforms you can use the [single-instance](../single-instance/) plugin. +Note that the Plugin will only emit events on macOS, iOS and Android. On Windows and Linux the OS will spawn a new instance of your app with the URL as a CLI argument. If you want your app to behave on Windows & Linux similar to the other platforms you can use the [single-instance](../single-instance/) plugin with the `deep-link` feature enabled. ## Contributing diff --git a/plugins/deep-link/examples/app/src-tauri/Cargo.toml b/plugins/deep-link/examples/app/src-tauri/Cargo.toml index b4139524..57b9180e 100644 --- a/plugins/deep-link/examples/app/src-tauri/Cargo.toml +++ b/plugins/deep-link/examples/app/src-tauri/Cargo.toml @@ -22,7 +22,9 @@ serde_json = { workspace = true } tauri = { workspace = true, features = ["wry", "compression"] } tauri-plugin-deep-link = { path = "../../../" } tauri-plugin-log = { path = "../../../../log" } -tauri-plugin-single-instance = { path = "../../../../single-instance" } +tauri-plugin-single-instance = { path = "../../../../single-instance", features = [ + "deep-link", +] } log = "0.4" [features] diff --git a/plugins/deep-link/examples/app/src-tauri/src/lib.rs b/plugins/deep-link/examples/app/src-tauri/src/lib.rs index 4efa6e2a..f72f28f6 100644 --- a/plugins/deep-link/examples/app/src-tauri/src/lib.rs +++ b/plugins/deep-link/examples/app/src-tauri/src/lib.rs @@ -7,7 +7,7 @@ use tauri::Listener; // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command #[tauri::command] fn greet(name: &str) -> String { - format!("Hello, {}! You've been greeted from Rust!", name) + format!("Hello, {name}! You've been greeted from Rust!") } #[cfg_attr(mobile, tauri::mobile_entry_point)] diff --git a/plugins/single-instance/Cargo.toml b/plugins/single-instance/Cargo.toml index d58a89b8..e89b46a1 100644 --- a/plugins/single-instance/Cargo.toml +++ b/plugins/single-instance/Cargo.toml @@ -19,7 +19,7 @@ serde_json = { workspace = true } tauri = { workspace = true } log = { workspace = true } thiserror = { workspace = true } -tauri-plugin-deep-link = { path = "../deep-link", version = "2.0.0-rc.4" } +tauri-plugin-deep-link = { path = "../deep-link", version = "2.0.0-rc.4", optional = true } semver = { version = "1", optional = true } [target."cfg(target_os = \"windows\")".dependencies.windows-sys] @@ -39,3 +39,4 @@ zbus = "4" [features] semver = ["dep:semver"] +deep-link = ["dep:tauri-plugin-deep-link"] diff --git a/plugins/single-instance/README.md b/plugins/single-instance/README.md index 3a379634..bd761018 100644 --- a/plugins/single-instance/README.md +++ b/plugins/single-instance/README.md @@ -34,8 +34,8 @@ use tauri::{Manager}; #[derive(Clone, serde::Serialize)] struct Payload { - args: Vec, - cwd: String, + args: Vec, + cwd: String, } fn main() { @@ -49,6 +49,8 @@ fn main() { } ``` +Note that currently, plugins run in the order they were added in to the builder, so make sure that this plugin is registered first. + ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request. diff --git a/plugins/single-instance/src/lib.rs b/plugins/single-instance/src/lib.rs index 1dc9d61a..ce7815e8 100644 --- a/plugins/single-instance/src/lib.rs +++ b/plugins/single-instance/src/lib.rs @@ -13,7 +13,6 @@ #![cfg(not(any(target_os = "android", target_os = "ios")))] use tauri::{plugin::TauriPlugin, AppHandle, Manager, Runtime}; -use tauri_plugin_deep_link::DeepLink; #[cfg(target_os = "windows")] #[path = "platform_impl/windows.rs"] @@ -35,7 +34,8 @@ pub fn init, Vec, String) + Send + Sy mut f: F, ) -> TauriPlugin { platform_impl::init(Box::new(move |app, args, cwd| { - if let Some(deep_link) = app.try_state::>() { + #[cfg(feature = "deep-link")] + if let Some(deep_link) = app.try_state::>() { deep_link.handle_cli_arguments(args.iter()); } f(app, args, cwd)