Skip to content

Commit 4b1494a

Browse files
Legend-MasterFabianLars
authored andcommitted
chore(single-instance): put deep link integration behined a feature (tauri-apps#1766)
* Make deep link optional for single instance * Add change file * Add deep-link feature to example * Update plugins/deep-link/README.md Co-authored-by: Fabian-Lars <[email protected]> * format * [skip ci] update readme --------- Co-authored-by: Fabian-Lars <[email protected]>
1 parent c4faa4b commit 4b1494a

File tree

7 files changed

+18
-8
lines changed

7 files changed

+18
-8
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"single-instance": "patch"
3+
---
4+
5+
Put deep link integration behined a feature

plugins/deep-link/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ await onOpenUrl((urls) => {
145145
})
146146
```
147147

148-
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.
148+
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.
149149

150150
## Contributing
151151

plugins/deep-link/examples/app/src-tauri/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ serde_json = { workspace = true }
2222
tauri = { workspace = true, features = ["wry", "compression"] }
2323
tauri-plugin-deep-link = { path = "../../../" }
2424
tauri-plugin-log = { path = "../../../../log" }
25-
tauri-plugin-single-instance = { path = "../../../../single-instance" }
25+
tauri-plugin-single-instance = { path = "../../../../single-instance", features = [
26+
"deep-link",
27+
] }
2628
log = "0.4"
2729

2830
[features]

plugins/deep-link/examples/app/src-tauri/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use tauri::Listener;
77
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
88
#[tauri::command]
99
fn greet(name: &str) -> String {
10-
format!("Hello, {}! You've been greeted from Rust!", name)
10+
format!("Hello, {name}! You've been greeted from Rust!")
1111
}
1212

1313
#[cfg_attr(mobile, tauri::mobile_entry_point)]

plugins/single-instance/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ serde_json = { workspace = true }
1919
tauri = { workspace = true }
2020
log = { workspace = true }
2121
thiserror = { workspace = true }
22-
tauri-plugin-deep-link = { path = "../deep-link", version = "2.0.0-rc.4" }
22+
tauri-plugin-deep-link = { path = "../deep-link", version = "2.0.0-rc.4", optional = true }
2323
semver = { version = "1", optional = true }
2424

2525
[target."cfg(target_os = \"windows\")".dependencies.windows-sys]
@@ -39,3 +39,4 @@ zbus = "4"
3939

4040
[features]
4141
semver = ["dep:semver"]
42+
deep-link = ["dep:tauri-plugin-deep-link"]

plugins/single-instance/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ use tauri::{Manager};
3434

3535
#[derive(Clone, serde::Serialize)]
3636
struct Payload {
37-
args: Vec<String>,
38-
cwd: String,
37+
args: Vec<String>,
38+
cwd: String,
3939
}
4040

4141
fn main() {
@@ -49,6 +49,8 @@ fn main() {
4949
}
5050
```
5151

52+
Note that currently, plugins run in the order they were added in to the builder, so make sure that this plugin is registered first.
53+
5254
## Contributing
5355

5456
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.

plugins/single-instance/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#![cfg(not(any(target_os = "android", target_os = "ios")))]
1414

1515
use tauri::{plugin::TauriPlugin, AppHandle, Manager, Runtime};
16-
use tauri_plugin_deep_link::DeepLink;
1716

1817
#[cfg(target_os = "windows")]
1918
#[path = "platform_impl/windows.rs"]
@@ -35,7 +34,8 @@ pub fn init<R: Runtime, F: FnMut(&AppHandle<R>, Vec<String>, String) + Send + Sy
3534
mut f: F,
3635
) -> TauriPlugin<R> {
3736
platform_impl::init(Box::new(move |app, args, cwd| {
38-
if let Some(deep_link) = app.try_state::<DeepLink<R>>() {
37+
#[cfg(feature = "deep-link")]
38+
if let Some(deep_link) = app.try_state::<tauri_plugin_deep_link::DeepLink<R>>() {
3939
deep_link.handle_cli_arguments(args.iter());
4040
}
4141
f(app, args, cwd)

0 commit comments

Comments
 (0)