Skip to content

Commit

Permalink
refactor(core): move api modules behind allowlist feature flags (#1864)
Browse files Browse the repository at this point in the history
* refactor(core): move api modules behind allowlist feature flags

* run fmt
  • Loading branch information
lucasfernog committed May 19, 2021
1 parent d509b2d commit aab3e1f
Show file tree
Hide file tree
Showing 9 changed files with 440 additions and 404 deletions.
5 changes: 5 additions & 0 deletions .changes/api-feature-flags.md
@@ -0,0 +1,5 @@
---
"tauri": patch
---

Moves `shell`, `dialog::FileDialogBuilder` and `process::Command` APIs behind their allowlist feature flags.
68 changes: 41 additions & 27 deletions core/tauri/Cargo.toml
Expand Up @@ -33,12 +33,11 @@ normal = ["attohttpc"] # we ignore attohttpc because we can't remove it based on
[dependencies]
serde_json = { version = "1.0", features = [ "raw_value" ] }
serde = { version = "1.0", features = [ "derive" ] }
base64 = "0.13.0"
tokio = { version = "1.6", features = [ "rt", "rt-multi-thread", "sync" ] }
futures = "0.3"
uuid = { version = "0.8.2", features = [ "v4" ] }
thiserror = "1.0.24"
once_cell = "1.7.2"
uuid = { version = "0.8", features = [ "v4" ] }
thiserror = "1.0"
once_cell = "1.7"
tauri-runtime = { version = "0.1.1", path = "../tauri-runtime" }
tauri-macros = { version = "1.0.0-beta.1", path = "../tauri-macros" }
tauri-utils = { version = "1.0.0-beta.0", path = "../tauri-utils" }
Expand All @@ -47,30 +46,45 @@ rand = "0.8"
tempfile = "3"
semver = "0.11"
serde_repr = "0.1"
dirs-next = "2.0.0"
zip = "0.5.12"
ignore = "^0.4.17"
either = "1.6.1"
zip = "0.5"
ignore = "0.4"
either = "1.6"
tar = "0.4"
flate2 = "1.0"
rfd = "0.3.0"
tinyfiledialogs = "3.3"
http = "0.2"
clap = { version = "=3.0.0-beta.2", optional = true }
notify-rust = { version = "4.5.2", optional = true }
tauri-hotkey = { version = "0.1.2", optional = true }
open = "1.7.0"
shared_child = "0.3"
os_pipe = "0.9"
minisign-verify = "0.1.8"
state = "0.4"
bincode = "1.3"
dirs-next = "2.0"

# FS
base64 = { version = "0.13", optional = true } # also used on the updater

# CLI
clap = { version = "=3.0.0-beta.2", optional = true }

# Notifications
notify-rust = { version = "4.5", optional = true }

# Global shortcut
tauri-hotkey = { version = "0.1.2", optional = true }

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

# Shell
open = { version = "1.7", optional = true }
shared_child = { version = "0.3", optional = true }
os_pipe = { version = "0.9", optional = true }

# Dialogs
rfd = { version = "0.3", optional = true }

# Updater
minisign-verify = { version = "0.1", optional = true }

[build-dependencies]
cfg_aliases = "0.1.1"

Expand All @@ -90,31 +104,31 @@ dox = [ "tauri-runtime-wry/dox" ]
wry = [ "tauri-runtime-wry" ]
cli = [ "clap" ]
custom-protocol = [ "tauri-macros/custom-protocol" ]
api-all = [ "notification-all", "global-shortcut-all", "updater" ]
updater = [ ]
api-all = [ "notification-all", "global-shortcut-all", "shell-all", "dialog-all", "updater" ]
updater = [ "minisign-verify", "base64" ]
menu = [ "tauri-runtime/menu", "tauri-runtime-wry/menu" ]
system-tray = [ "tauri-runtime/system-tray", "tauri-runtime-wry/system-tray" ]
system-tray = [ "tauri-runtime/system-tray", "tauri-runtime-wry/system-tray"]
reqwest-client = [ "reqwest", "bytes" ]
fs-all = [ ]
fs-read-text-file = [ ]
fs-read-binary-file = [ ]
fs-write-file = [ ]
fs-write-binary-file = [ ]
fs-write-binary-file = [ "base64" ]
fs-read-dir = [ ]
fs-copy-file = [ ]
fs-create-dir = [ ]
fs-remove-dir = [ ]
fs-remove-file = [ ]
fs-rename-file = [ ]
fs-path-api = [ ]
fs-path = [ ]
window-all = [ ]
window-create = [ ]
shell-all = [ ]
shell-execute = [ ]
shell-open = [ ]
dialog-all = [ ]
dialog-open = [ ]
dialog-save = [ ]
shell-all = [ "shell-open", "shell-execute" ]
shell-execute = [ "shared_child", "os_pipe" ]
shell-open = [ "open" ]
dialog-all = [ "dialog-open", "dialog-save" ]
dialog-open = [ "rfd" ]
dialog-save = [ "rfd" ]
http-all = [ ]
http-request = [ ]
notification-all = [ "notify-rust" ]
Expand Down
6 changes: 4 additions & 2 deletions core/tauri/src/api/dialog.rs
Expand Up @@ -2,16 +2,18 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

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

use rfd::FileDialog;
use tinyfiledialogs::{message_box_ok, message_box_yes_no, MessageBoxIcon, YesNo};

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

#[cfg(any(dialog_open, dialog_save))]
impl FileDialogBuilder {
/// Gets the default file dialog builder.
pub fn new() -> Self {
Expand Down
1 change: 1 addition & 0 deletions core/tauri/src/api/mod.rs
Expand Up @@ -21,6 +21,7 @@ pub mod process;
/// The RPC module includes utilities to send messages to the JS layer of the webview.
pub mod rpc;
/// The shell api.
#[cfg(shell_open)]
pub mod shell;
/// The semver API.
pub mod version;
Expand Down

0 comments on commit aab3e1f

Please sign in to comment.