Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions crates/tauri-bundler/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,14 @@ pub enum Error {
#[error("Wrong package type {0} for platform {1}")]
InvalidPackageType(String, String),
/// Bundle type symbol missing in binary
#[cfg(target_os = "linux")]
#[error("__TAURI_BUNDLE_TYPE variable not found in binary. Make sure tauri crate and tauri-cli are up to date and that symbol stripping is disabled (https://doc.rust-lang.org/cargo/reference/profiles.html#strip)")]
MissingBundleTypeVar,
#[cfg(not(target_os = "linux"))]
#[error("__TAURI_BUNDLE_TYPE variable not found in binary. Make sure tauri crate and tauri-cli are up to date")]
#[cfg_attr(
target_os = "linux",
error("__TAURI_BUNDLE_TYPE variable not found in binary. Make sure tauri crate and tauri-cli are up to date and that symbol stripping is disabled (https://doc.rust-lang.org/cargo/reference/profiles.html#strip)")
)]
#[cfg_attr(
not(target_os = "linux"),
error("__TAURI_BUNDLE_TYPE variable not found in binary. Make sure tauri crate and tauri-cli are up to date")
)]
MissingBundleTypeVar,
/// Failed to write binary file changed
#[error("Failed to write binary file changes: `{0}`")]
Expand Down
9 changes: 2 additions & 7 deletions crates/tauri-cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,25 +785,20 @@ pub struct UpdaterConfig {
}

/// Install modes for the Windows update.
#[derive(Debug, PartialEq, Eq, Clone)]
#[derive(Default, Debug, PartialEq, Eq, Clone)]
pub enum WindowsUpdateInstallMode {
/// Specifies there's a basic UI during the installation process, including a final dialog box at the end.
BasicUi,
/// The quiet mode means there's no user interaction required.
/// Requires admin privileges if the installer does.
Quiet,
/// Specifies unattended mode, which means the installation only shows a progress bar.
#[default]
Passive,
// to add more modes, we need to check if the updater relaunch makes sense
// i.e. for a full UI mode, the user can also mark the installer to start the app
}

impl Default for WindowsUpdateInstallMode {
fn default() -> Self {
Self::Passive
}
}

impl<'de> Deserialize<'de> for WindowsUpdateInstallMode {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
Expand Down
9 changes: 2 additions & 7 deletions crates/tauri-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,18 @@ pub enum UserAttentionType {
Informational,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
#[serde(tag = "type")]
pub enum DeviceEventFilter {
/// Always filter out device events.
Always,
/// Filter out device events while the window is not focused.
#[default]
Unfocused,
/// Report all device events regardless of window focus.
Never,
}

impl Default for DeviceEventFilter {
fn default() -> Self {
Self::Unfocused
}
}

/// Defines the orientation that a window resize will be performed.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
pub enum ResizeDirection {
Expand Down
36 changes: 8 additions & 28 deletions crates/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,10 @@ impl<'de> Deserialize<'de> for BundleType {
}

/// Targets to bundle. Each value is case insensitive.
#[derive(Debug, PartialEq, Eq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone, Default)]
pub enum BundleTarget {
/// Bundle all targets.
#[default]
All,
/// A list of bundle targets.
List(Vec<BundleType>),
Expand Down Expand Up @@ -257,12 +258,6 @@ impl schemars::JsonSchema for BundleTarget {
}
}

impl Default for BundleTarget {
fn default() -> Self {
Self::All
}
}

impl Serialize for BundleTarget {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
Expand Down Expand Up @@ -805,7 +800,7 @@ pub struct WixConfig {
/// Compression algorithms used in the NSIS installer.
///
/// See <https://nsis.sourceforge.io/Reference/SetCompressor>
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize, Default)]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub enum NsisCompression {
Expand All @@ -814,19 +809,14 @@ pub enum NsisCompression {
/// BZIP2 usually gives better compression ratios than ZLIB, but it is a bit slower and uses more memory. With the default compression level it uses about 4 MB of memory.
Bzip2,
/// LZMA (default) is a new compression method that gives very good compression ratios. The decompression speed is high (10-20 MB/s on a 2 GHz CPU), the compression speed is lower. The memory size that will be used for decompression is the dictionary size plus a few KBs, the default is 8 MB.
#[default]
Lzma,
/// Disable compression
None,
}

impl Default for NsisCompression {
fn default() -> Self {
Self::Lzma
}
}

/// Install Modes for the NSIS installer.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
#[derive(Default, Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
pub enum NSISInstallerMode {
Expand All @@ -835,6 +825,7 @@ pub enum NSISInstallerMode {
/// Install the app by default in a directory that doesn't require Administrator access.
///
/// Installer metadata will be saved under the `HKCU` registry path.
#[default]
CurrentUser,
/// Install the app by default in the `Program Files` folder directory requires Administrator
/// access for the installation.
Expand All @@ -849,12 +840,6 @@ pub enum NSISInstallerMode {
Both,
}

impl Default for NSISInstallerMode {
fn default() -> Self {
Self::CurrentUser
}
}

/// Configuration for the Installer bundle using NSIS.
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
Expand Down Expand Up @@ -2685,11 +2670,12 @@ impl<'de> Deserialize<'de> for CapabilityEntry {

/// The application pattern.
#[skip_serializing_none]
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "lowercase", tag = "use", content = "options")]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
pub enum PatternKind {
/// Brownfield pattern.
#[default]
Brownfield,
/// Isolation pattern. Recommended for security purposes.
Isolation {
Expand All @@ -2698,12 +2684,6 @@ pub enum PatternKind {
},
}

impl Default for PatternKind {
fn default() -> Self {
Self::Brownfield
}
}

/// The App configuration object.
///
/// See more: <https://v2.tauri.app/reference/config/#appconfig>
Expand Down
45 changes: 10 additions & 35 deletions crates/tauri-utils/src/config_v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,10 @@ impl<'de> Deserialize<'de> for BundleType {
}

/// Targets to bundle. Each value is case insensitive.
#[derive(Debug, PartialEq, Eq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone, Default)]
pub enum BundleTarget {
/// Bundle all targets.
#[default]
All,
/// A list of bundle targets.
List(Vec<BundleType>),
Expand Down Expand Up @@ -251,12 +252,6 @@ impl schemars::JsonSchema for BundleTarget {
}
}

impl Default for BundleTarget {
fn default() -> Self {
Self::All
}
}

impl Serialize for BundleTarget {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
Expand Down Expand Up @@ -552,7 +547,7 @@ pub struct NsisConfig {
}

/// Install Modes for the NSIS installer.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum NSISInstallerMode {
Expand All @@ -561,6 +556,7 @@ pub enum NSISInstallerMode {
/// Install the app by default in a directory that doesn't require Administrator access.
///
/// Installer metadata will be saved under the `HKCU` registry path.
#[default]
CurrentUser,
/// Install the app by default in the `Program Files` folder directory requires Administrator
/// access for the installation.
Expand All @@ -575,12 +571,6 @@ pub enum NSISInstallerMode {
Both,
}

impl Default for NSISInstallerMode {
fn default() -> Self {
Self::CurrentUser
}
}

/// Install modes for the Webview2 runtime.
/// Note that for the updater bundle [`Self::DownloadBootstrapper`] is used.
///
Expand Down Expand Up @@ -2393,11 +2383,12 @@ impl Allowlist for AllowlistConfig {

/// The application pattern.
#[skip_serializing_none]
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "lowercase", tag = "use", content = "options")]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum PatternKind {
/// Brownfield pattern.
#[default]
Brownfield,
/// Isolation pattern. Recommended for security purposes.
Isolation {
Expand All @@ -2406,12 +2397,6 @@ pub enum PatternKind {
},
}

impl Default for PatternKind {
fn default() -> Self {
Self::Brownfield
}
}

/// The Tauri configuration object.
///
/// See more: https://tauri.app/v1/api/config#tauriconfig
Expand Down Expand Up @@ -2481,7 +2466,7 @@ impl<'de> Deserialize<'de> for UpdaterEndpoint {
}

/// Install modes for the Windows update.
#[derive(Debug, PartialEq, Eq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone, Default)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "schema", schemars(rename_all = "camelCase"))]
pub enum WindowsUpdateInstallMode {
Expand All @@ -2491,6 +2476,7 @@ pub enum WindowsUpdateInstallMode {
/// Requires admin privileges if the installer does.
Quiet,
/// Specifies unattended mode, which means the installation only shows a progress bar.
#[default]
Passive,
// to add more modes, we need to check if the updater relaunch makes sense
// i.e. for a full UI mode, the user can also mark the installer to start the app
Expand All @@ -2510,12 +2496,6 @@ impl Display for WindowsUpdateInstallMode {
}
}

impl Default for WindowsUpdateInstallMode {
fn default() -> Self {
Self::Passive
}
}

impl Serialize for WindowsUpdateInstallMode {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
Expand Down Expand Up @@ -2989,10 +2969,11 @@ fn default_build() -> BuildConfig {
}

/// How the window title bar should be displayed on macOS.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum TitleBarStyle {
/// A normal title bar.
#[default]
Visible,
/// Makes the title bar transparent, so the window background color is shown instead.
///
Expand All @@ -3007,12 +2988,6 @@ pub enum TitleBarStyle {
Overlay,
}

impl Default for TitleBarStyle {
fn default() -> Self {
Self::Visible
}
}

impl Serialize for TitleBarStyle {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
Expand Down
9 changes: 2 additions & 7 deletions crates/tauri-utils/src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,21 +211,16 @@ impl From<&PatternKind> for PatternObject {
}

/// Where the JavaScript is injected to
#[derive(Debug, Serialize)]
#[derive(Debug, Serialize, Default)]
#[serde(rename_all = "lowercase")]
pub enum IsolationSide {
/// Original frame, the Brownfield application
#[default]
Original,
/// Secure frame, the isolation security application
Secure,
}

impl Default for IsolationSide {
fn default() -> Self {
Self::Original
}
}

/// Injects the Isolation JavaScript to a codegen time document.
///
/// Note: This function is not considered part of the stable API.
Expand Down
9 changes: 2 additions & 7 deletions crates/tauri-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,12 @@ mod window_effects {
pub use window_effects::{WindowEffect, WindowEffectState};

/// How the window title bar should be displayed on macOS.
#[derive(Debug, Clone, PartialEq, Eq, Copy)]
#[derive(Debug, Clone, PartialEq, Eq, Copy, Default)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum TitleBarStyle {
/// A normal title bar.
#[default]
Visible,
/// Makes the title bar transparent, so the window background color is shown instead.
///
Expand All @@ -176,12 +177,6 @@ pub enum TitleBarStyle {
Overlay,
}

impl Default for TitleBarStyle {
fn default() -> Self {
Self::Visible
}
}

impl Serialize for TitleBarStyle {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
Expand Down
10 changes: 2 additions & 8 deletions crates/tauri/src/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,17 @@ impl From<&Pattern> for PatternObject {

/// Where the JavaScript is injected to
#[cfg(feature = "isolation")]
#[derive(Debug, Serialize)]
#[derive(Default, Debug, Serialize)]
#[serde(rename_all = "lowercase")]
pub(crate) enum IsolationSide {
/// Original frame, the Brownfield application
#[default]
Original,
/// Secure frame, the isolation security application
#[allow(dead_code)]
Secure,
}

#[cfg(feature = "isolation")]
impl Default for IsolationSide {
fn default() -> Self {
Self::Original
}
}

#[derive(Template)]
#[default_template("../scripts/pattern.js")]
pub(crate) struct PatternJavascript {
Expand Down
Loading
Loading