Skip to content

Commit

Permalink
Merge branch 'dev' into prevent-window-overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Legend-Master authored Nov 5, 2024
2 parents ab7a48f + 4191a7a commit 86ef220
Show file tree
Hide file tree
Showing 31 changed files with 705 additions and 91 deletions.
10 changes: 10 additions & 0 deletions .changes/rpm-compression-level.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"tauri-bundler": "minor:feat"
"tauri-cli": "minor:feat"
"@tauri-apps/cli": "minor:feat"
"tauri-utils": "minor:feat"
---

Add `bundle > linux > rpm > compression` config option to control RPM bundle compression type and level.


5 changes: 5 additions & 0 deletions .changes/tray-async-command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": "patch:bug"
---

Fix tray events not fired for tray icons created inside an async command.
6 changes: 6 additions & 0 deletions .changes/use_https_windows-and-android-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri": "minor:feat"
"tauri-utils": "minor:feat"
---

Add `app > windows > useHttpsScheme` config option to choose whether the custom protocols should use `https://<scheme>.localhost` instead of the default `http://<scheme>.localhost` on Windows and Android
7 changes: 7 additions & 0 deletions .changes/use_https_windows-and-android.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"tauri": "minor:feat"
"tauri-runtime": "minor:feat"
"tauri-runtime-wry": "minor:feat"
---

Add `WebviewWindowBuilder/WebviewBuilder::use_https_scheme` to choose whether the custom protocols should use `https://<scheme>.localhost` instead of the default `http://<scheme>.localhost` on Windows and Android
18 changes: 16 additions & 2 deletions crates/tauri-bundler/src/bundle/linux/rpm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::{
fs::{self, File},
path::{Path, PathBuf},
};
use tauri_utils::config::RpmCompression;

use super::freedesktop;

Expand Down Expand Up @@ -54,11 +55,24 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {

let license = settings.license().unwrap_or_default();
let name = heck::AsKebabCase(settings.product_name()).to_string();

let compression = settings
.rpm()
.compression
.map(|c| match c {
RpmCompression::Gzip { level } => rpm::CompressionWithLevel::Gzip(level),
RpmCompression::Zstd { level } => rpm::CompressionWithLevel::Zstd(level),
RpmCompression::Xz { level } => rpm::CompressionWithLevel::Xz(level),
RpmCompression::Bzip2 { level } => rpm::CompressionWithLevel::Bzip2(level),
_ => rpm::CompressionWithLevel::None,
})
// This matches .deb compression. On a 240MB source binary the bundle will be 100KB larger than rpm's default while reducing build times by ~25%.
.unwrap_or(rpm::CompressionWithLevel::Gzip(6));

let mut builder = rpm::PackageBuilder::new(&name, version, &license, arch, summary)
.epoch(epoch)
.release(release)
// This matches .deb compression. On a 240MB source binary the bundle will be 100KB larger than rpm's default while reducing build times by ~25%.
.compression(rpm::CompressionWithLevel::Gzip(6));
.compression(compression);

if let Some(description) = settings.long_description() {
builder = builder.description(description);
Expand Down
7 changes: 6 additions & 1 deletion crates/tauri-bundler/src/bundle/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ use crate::bundle::{common, platform::target_triple};
use anyhow::Context;
pub use tauri_utils::config::WebviewInstallMode;
use tauri_utils::{
config::{BundleType, DeepLinkProtocol, FileAssociation, NSISInstallerMode, NsisCompression},
config::{
BundleType, DeepLinkProtocol, FileAssociation, NSISInstallerMode, NsisCompression,
RpmCompression,
},
resources::{external_binaries, ResourcePaths},
};

Expand Down Expand Up @@ -262,6 +265,8 @@ pub struct RpmSettings {
/// Path to script that will be executed after the package is removed. See
/// <http://ftp.rpm.org/max-rpm/s1-rpm-inside-scripts.html>
pub post_remove_script: Option<PathBuf>,
/// Compression algorithm and level. Defaults to `Gzip` with level 6.
pub compression: Option<RpmCompression>,
}

/// Position coordinates struct.
Expand Down
4 changes: 2 additions & 2 deletions crates/tauri-bundler/src/bundle/windows/nsis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ pub fn bundle_project(settings: &Settings, updater: bool) -> crate::Result<Vec<P

if !mismatched.is_empty() {
log::warn!("NSIS directory contains mis-hashed files. Redownloading them.");
for (path, url, hash, hash_algorithim) in mismatched {
let data = download_and_verify(url, hash, *hash_algorithim)?;
for (path, url, hash, hash_algorithm) in mismatched {
let data = download_and_verify(url, hash, *hash_algorithm)?;
fs::write(nsis_toolset_path.join(path), data)?;
}
}
Expand Down
128 changes: 128 additions & 0 deletions crates/tauri-cli/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,11 @@
"description": "Whether browser extensions can be installed for the webview process\n\n ## Platform-specific:\n\n - **Windows**: Enables the WebView2 environment's [`AreBrowserExtensionsEnabled`](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2environmentoptions?view=webview2-winrt-1.0.2739.15#arebrowserextensionsenabled)\n - **MacOS / Linux / iOS / Android** - Unsupported.",
"default": false,
"type": "boolean"
},
"useHttpsScheme": {
"description": "Sets whether the custom protocols should use `https://<scheme>.localhost` instead of the default `http://<scheme>.localhost` on Windows and Android. Defaults to `false`.\n\n ## Note\n\n Using a `https` scheme will NOT allow mixed content when trying to fetch `http` endpoints and therefore will not match the behavior of the `<scheme>://localhost` protocols used on macOS and Linux.\n\n ## Warning\n\n Changing this value between releases will change the IndexedDB, cookies and localstorage location and your app will not be able to access the old data.",
"default": false,
"type": "boolean"
}
},
"additionalProperties": false
Expand Down Expand Up @@ -2840,10 +2845,133 @@
"string",
"null"
]
},
"compression": {
"description": "Compression algorithm and level. Defaults to `Gzip` with level 6.",
"anyOf": [
{
"$ref": "#/definitions/RpmCompression"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
},
"RpmCompression": {
"description": "Compression algorithms used when bundling RPM packages.",
"oneOf": [
{
"description": "Gzip compression",
"type": "object",
"required": [
"level",
"type"
],
"properties": {
"type": {
"type": "string",
"enum": [
"gzip"
]
},
"level": {
"description": "Gzip compression level",
"type": "integer",
"format": "uint32",
"minimum": 0.0
}
},
"additionalProperties": false
},
{
"description": "Zstd compression",
"type": "object",
"required": [
"level",
"type"
],
"properties": {
"type": {
"type": "string",
"enum": [
"zstd"
]
},
"level": {
"description": "Zstd compression level",
"type": "integer",
"format": "int32"
}
},
"additionalProperties": false
},
{
"description": "Xz compression",
"type": "object",
"required": [
"level",
"type"
],
"properties": {
"type": {
"type": "string",
"enum": [
"xz"
]
},
"level": {
"description": "Xz compression level",
"type": "integer",
"format": "uint32",
"minimum": 0.0
}
},
"additionalProperties": false
},
{
"description": "Bzip2 compression",
"type": "object",
"required": [
"level",
"type"
],
"properties": {
"type": {
"type": "string",
"enum": [
"bzip2"
]
},
"level": {
"description": "Bzip2 compression level",
"type": "integer",
"format": "uint32",
"minimum": 0.0
}
},
"additionalProperties": false
},
{
"description": "Disable compression",
"type": "object",
"required": [
"type"
],
"properties": {
"type": {
"type": "string",
"enum": [
"none"
]
}
},
"additionalProperties": false
}
]
},
"MacConfig": {
"description": "Configuration for the macOS bundles.\n\n See more: <https://v2.tauri.app/reference/config/#macconfig>",
"type": "object",
Expand Down
1 change: 1 addition & 0 deletions crates/tauri-cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,7 @@ fn tauri_config_to_bundle_settings(
post_install_script: config.linux.rpm.post_install_script,
pre_remove_script: config.linux.rpm.pre_remove_script,
post_remove_script: config.linux.rpm.post_remove_script,
compression: config.linux.rpm.compression,
},
dmg: DmgSettings {
background: config.macos.dmg.background,
Expand Down
49 changes: 48 additions & 1 deletion crates/tauri-cli/src/migrate/migrations/v1/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,28 @@ fn migrate_config(config: &mut Value) -> Result<MigratedConfig> {
migrated.permissions = permissions;
}

// dangerousUseHttpScheme/useHttpsScheme
let dangerouse_use_http = tauri_config
.get("security")
.and_then(|w| w.as_object())
.and_then(|w| {
w.get("dangerousUseHttpScheme")
.or_else(|| w.get("dangerous-use-http-scheme"))
})
.and_then(|v| v.as_bool())
.unwrap_or_default();

if let Some(windows) = tauri_config
.get_mut("windows")
.and_then(|w| w.as_array_mut())
{
for window in windows {
if let Some(window) = window.as_object_mut() {
window.insert("useHttpsScheme".to_string(), (!dangerouse_use_http).into());
}
}
}

// security
if let Some(security) = tauri_config
.get_mut("security")
Expand Down Expand Up @@ -802,7 +824,8 @@ mod test {
"pattern": { "use": "brownfield" },
"security": {
"csp": "default-src 'self' tauri:"
}
},
"windows": [{}]
}
});

Expand Down Expand Up @@ -907,6 +930,8 @@ mod test {
migrated["app"]["withGlobalTauri"],
original["build"]["withGlobalTauri"]
);

assert_eq!(migrated["app"]["windows"][0]["useHttpsScheme"], true);
}

#[test]
Expand Down Expand Up @@ -941,6 +966,28 @@ mod test {
);
}

#[test]
fn migrate_dangerous_use_http_scheme() {
let original = serde_json::json!({
"tauri": {
"windows": [{}],
"security": {
"dangerousUseHttpScheme": true,
}
}
});

let migrated = migrate(&original);
assert_eq!(
!migrated["app"]["windows"][0]["useHttpsScheme"]
.as_bool()
.unwrap(),
original["tauri"]["security"]["dangerousUseHttpScheme"]
.as_bool()
.unwrap()
);
}

#[test]
fn can_migrate_default_config() {
let original = serde_json::to_value(tauri_utils_v1::config::Config::default()).unwrap();
Expand Down
Loading

0 comments on commit 86ef220

Please sign in to comment.