Skip to content

Commit aab3e1f

Browse files
authored
refactor(core): move api modules behind allowlist feature flags (#1864)
* refactor(core): move api modules behind allowlist feature flags * run fmt
1 parent d509b2d commit aab3e1f

9 files changed

Lines changed: 440 additions & 404 deletions

File tree

.changes/api-feature-flags.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Moves `shell`, `dialog::FileDialogBuilder` and `process::Command` APIs behind their allowlist feature flags.

core/tauri/Cargo.toml

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ normal = ["attohttpc"] # we ignore attohttpc because we can't remove it based on
3333
[dependencies]
3434
serde_json = { version = "1.0", features = [ "raw_value" ] }
3535
serde = { version = "1.0", features = [ "derive" ] }
36-
base64 = "0.13.0"
3736
tokio = { version = "1.6", features = [ "rt", "rt-multi-thread", "sync" ] }
3837
futures = "0.3"
39-
uuid = { version = "0.8.2", features = [ "v4" ] }
40-
thiserror = "1.0.24"
41-
once_cell = "1.7.2"
38+
uuid = { version = "0.8", features = [ "v4" ] }
39+
thiserror = "1.0"
40+
once_cell = "1.7"
4241
tauri-runtime = { version = "0.1.1", path = "../tauri-runtime" }
4342
tauri-macros = { version = "1.0.0-beta.1", path = "../tauri-macros" }
4443
tauri-utils = { version = "1.0.0-beta.0", path = "../tauri-utils" }
@@ -47,30 +46,45 @@ rand = "0.8"
4746
tempfile = "3"
4847
semver = "0.11"
4948
serde_repr = "0.1"
50-
dirs-next = "2.0.0"
51-
zip = "0.5.12"
52-
ignore = "^0.4.17"
53-
either = "1.6.1"
49+
zip = "0.5"
50+
ignore = "0.4"
51+
either = "1.6"
5452
tar = "0.4"
5553
flate2 = "1.0"
56-
rfd = "0.3.0"
5754
tinyfiledialogs = "3.3"
5855
http = "0.2"
59-
clap = { version = "=3.0.0-beta.2", optional = true }
60-
notify-rust = { version = "4.5.2", optional = true }
61-
tauri-hotkey = { version = "0.1.2", optional = true }
62-
open = "1.7.0"
63-
shared_child = "0.3"
64-
os_pipe = "0.9"
65-
minisign-verify = "0.1.8"
6656
state = "0.4"
6757
bincode = "1.3"
58+
dirs-next = "2.0"
59+
60+
# FS
61+
base64 = { version = "0.13", optional = true } # also used on the updater
62+
63+
# CLI
64+
clap = { version = "=3.0.0-beta.2", optional = true }
65+
66+
# Notifications
67+
notify-rust = { version = "4.5", optional = true }
68+
69+
# Global shortcut
70+
tauri-hotkey = { version = "0.1.2", optional = true }
6871

6972
# HTTP
7073
reqwest = { version = "0.11", features = [ "json", "multipart" ], optional = true }
7174
bytes = { version = "1", features = [ "serde" ], optional = true }
7275
attohttpc = { version = "0.17", features = [ "json", "form" ] }
7376

77+
# Shell
78+
open = { version = "1.7", optional = true }
79+
shared_child = { version = "0.3", optional = true }
80+
os_pipe = { version = "0.9", optional = true }
81+
82+
# Dialogs
83+
rfd = { version = "0.3", optional = true }
84+
85+
# Updater
86+
minisign-verify = { version = "0.1", optional = true }
87+
7488
[build-dependencies]
7589
cfg_aliases = "0.1.1"
7690

@@ -90,31 +104,31 @@ dox = [ "tauri-runtime-wry/dox" ]
90104
wry = [ "tauri-runtime-wry" ]
91105
cli = [ "clap" ]
92106
custom-protocol = [ "tauri-macros/custom-protocol" ]
93-
api-all = [ "notification-all", "global-shortcut-all", "updater" ]
94-
updater = [ ]
107+
api-all = [ "notification-all", "global-shortcut-all", "shell-all", "dialog-all", "updater" ]
108+
updater = [ "minisign-verify", "base64" ]
95109
menu = [ "tauri-runtime/menu", "tauri-runtime-wry/menu" ]
96-
system-tray = [ "tauri-runtime/system-tray", "tauri-runtime-wry/system-tray" ]
110+
system-tray = [ "tauri-runtime/system-tray", "tauri-runtime-wry/system-tray"]
97111
reqwest-client = [ "reqwest", "bytes" ]
98112
fs-all = [ ]
99113
fs-read-text-file = [ ]
100114
fs-read-binary-file = [ ]
101115
fs-write-file = [ ]
102-
fs-write-binary-file = [ ]
116+
fs-write-binary-file = [ "base64" ]
103117
fs-read-dir = [ ]
104118
fs-copy-file = [ ]
105119
fs-create-dir = [ ]
106120
fs-remove-dir = [ ]
107121
fs-remove-file = [ ]
108122
fs-rename-file = [ ]
109-
fs-path-api = [ ]
123+
fs-path = [ ]
110124
window-all = [ ]
111125
window-create = [ ]
112-
shell-all = [ ]
113-
shell-execute = [ ]
114-
shell-open = [ ]
115-
dialog-all = [ ]
116-
dialog-open = [ ]
117-
dialog-save = [ ]
126+
shell-all = [ "shell-open", "shell-execute" ]
127+
shell-execute = [ "shared_child", "os_pipe" ]
128+
shell-open = [ "open" ]
129+
dialog-all = [ "dialog-open", "dialog-save" ]
130+
dialog-open = [ "rfd" ]
131+
dialog-save = [ "rfd" ]
118132
http-all = [ ]
119133
http-request = [ ]
120134
notification-all = [ "notify-rust" ]

core/tauri/src/api/dialog.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
// SPDX-License-Identifier: Apache-2.0
33
// SPDX-License-Identifier: MIT
44

5+
#[cfg(any(dialog_open, dialog_save))]
56
use std::path::{Path, PathBuf};
67

7-
use rfd::FileDialog;
88
use tinyfiledialogs::{message_box_ok, message_box_yes_no, MessageBoxIcon, YesNo};
99

1010
/// The file dialog builder.
1111
/// Constructs file picker dialogs that can select single/multiple files or directories.
12+
#[cfg(any(dialog_open, dialog_save))]
1213
#[derive(Default)]
13-
pub struct FileDialogBuilder(FileDialog);
14+
pub struct FileDialogBuilder(rfd::FileDialog);
1415

16+
#[cfg(any(dialog_open, dialog_save))]
1517
impl FileDialogBuilder {
1618
/// Gets the default file dialog builder.
1719
pub fn new() -> Self {

core/tauri/src/api/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub mod process;
2121
/// The RPC module includes utilities to send messages to the JS layer of the webview.
2222
pub mod rpc;
2323
/// The shell api.
24+
#[cfg(shell_open)]
2425
pub mod shell;
2526
/// The semver API.
2627
pub mod version;

0 commit comments

Comments
 (0)