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
6 changes: 4 additions & 2 deletions .cargo/audit.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ ignore = [
"RUSTSEC-2020-0095",
# proc-macro-error is unmaintained
"RUSTSEC-2024-0370",
# time crate can't be updated in the repo because of MSRV, users are unaffected
"RUSTSEC-2026-0009",
# rand unsoundness, fixed when we remove kuchikiki from deps in v3, currently
# remains for semver reasons but is not built in default configuration
"RUSTSEC-2026-0097",
Expand All @@ -21,4 +19,8 @@ ignore = [
"RUSTSEC-2026-0099",
# rustls, fixed when updating to apple-codesign 0.28.0
"RUSTSEC-2026-0104",
# quick-xml, need an update in plist
"RUSTSEC-2026-0194",
# quick-xml, need an update in plist
"RUSTSEC-2026-0195",
]
34 changes: 16 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 7 additions & 11 deletions crates/tauri-cli/src/helpers/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::{
ffi::{OsStr, OsString},
path::Path,
process::exit,
sync::OnceLock,
sync::LazyLock,
};

use crate::error::Context;
Expand Down Expand Up @@ -141,15 +141,11 @@ pub fn custom_sign_settings(
}
}

fn config_schema_validator() -> &'static jsonschema::Validator {
// TODO: Switch to `LazyLock` when we bump MSRV to above 1.80
static CONFIG_SCHEMA_VALIDATOR: OnceLock<jsonschema::Validator> = OnceLock::new();
CONFIG_SCHEMA_VALIDATOR.get_or_init(|| {
let schema: JsonValue = serde_json::from_str(include_str!("../../config.schema.json"))
.expect("Failed to parse config schema bundled in the tauri-cli");
jsonschema::validator_for(&schema).expect("Config schema bundled in the tauri-cli is invalid")
})
}
static CONFIG_SCHEMA_VALIDATOR: LazyLock<jsonschema::Validator> = LazyLock::new(|| {
let schema: JsonValue = serde_json::from_str(include_str!("../../config.schema.json"))
.expect("Failed to parse config schema bundled in the tauri-cli");
jsonschema::validator_for(&schema).expect("Config schema bundled in the tauri-cli is invalid")
});

fn load_config(
merge_configs: &[&serde_json::Value],
Expand Down Expand Up @@ -191,7 +187,7 @@ fn load_config(
if config_path.extension() == Some(OsStr::new("json"))
|| config_path.extension() == Some(OsStr::new("json5"))
{
let mut errors = config_schema_validator().iter_errors(&config).peekable();
let mut errors = CONFIG_SCHEMA_VALIDATOR.iter_errors(&config).peekable();
if errors.peek().is_some() {
for error in errors {
let path = error.instance_path.into_iter().join(" > ");
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/helpers/updater_signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ where
{
let bin_path = bin_path.as_ref();
// We need to append .sig at the end it's where the signature will be stored
// TODO: use with_added_extension when we bump MSRV to > 1.91'
// TODO: use `with_added_extension` when we bump MSRV to >= 1.91
let signature_path = if let Some(ext) = bin_path.extension() {
let mut extension = ext.to_os_string();
extension.push(".sig");
Expand Down
8 changes: 3 additions & 5 deletions crates/tauri-cli/src/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::{
};

use std::{
borrow::Cow,
collections::HashMap,
fs::{create_dir_all, File},
io::{BufWriter, Write},
Expand Down Expand Up @@ -895,10 +894,9 @@ fn content_bounds(img: &DynamicImage) -> Option<(u32, u32, u32, u32)> {

fn resize_asset(img: &DynamicImage, target_size: u32, scale_percent: f32) -> DynamicImage {
let cropped = if let Some((x, y, cw, ch)) = content_bounds(img) {
// TODO: Use `&` here instead when we raise MSRV to above 1.79
Cow::Owned(img.crop_imm(x, y, cw, ch))
&img.crop_imm(x, y, cw, ch)
} else {
Cow::Borrowed(img)
img
};

let (cw, ch) = cropped.dimensions();
Expand All @@ -908,7 +906,7 @@ fn resize_asset(img: &DynamicImage, target_size: u32, scale_percent: f32) -> Dyn
let new_w = (cw as f32 * scale).round() as u32;
let new_h = (ch as f32 * scale).round() as u32;

let resized = resize_image(&cropped, new_w, new_h);
let resized = resize_image(cropped, new_w, new_h);

// Place on transparent square canvas
let mut canvas = ImageBuffer::from_pixel(target_size, target_size, Rgba([0, 0, 0, 0]));
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/interface/rust/desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ pub fn build(
let out_dir = app_settings.out_dir(&options, tauri_dir)?;
let bin_path = app_settings.app_binary_path(&options, tauri_dir)?;

if !std::env::var_os("STATIC_VCRUNTIME").is_some_and(|v| v == "false") {
if std::env::var_os("STATIC_VCRUNTIME").is_none_or(|v| v != "false") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This transformation is correct but the code was probably wrong to begin with; if STATIC_VCRUNTIME == true it will overwrite it with true. Probably wants is_none_or(|v| v != "true")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it, we can do it in another PR that this PR would only contain refactors without behavior changes

std::env::set_var("STATIC_VCRUNTIME", "true");
}

Expand Down
52 changes: 2 additions & 50 deletions crates/tauri-macros/src/command/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

use std::{env::var, sync::OnceLock};
use std::env::var;

use heck::{ToLowerCamelCase, ToSnakeCase};
use proc_macro::TokenStream;
Expand Down Expand Up @@ -211,13 +211,7 @@ pub fn wrapper(attributes: TokenStream, item: TokenStream) -> TokenStream {
// only implemented by `Result`. That way we don't exclude renamed result types
// which we wouldn't otherwise be able to detect purely from the token stream.
// The "error message" displayed to the user is simply the trait name.
//
// TODO: remove this check once our MSRV is high enough
let diagnostic = if is_rustc_at_least(1, 78) {
quote!(#[diagnostic::on_unimplemented(message = "async commands that contain references as inputs must return a `Result`")])
} else {
quote!()
};
let diagnostic = quote!(#[diagnostic::on_unimplemented(message = "async commands that contain references as inputs must return a `Result`")]);

async_command_check = quote_spanned! {return_type.span() =>
#[allow(unreachable_code, clippy::diverging_sub_expression, clippy::used_underscore_binding)]
Expand Down Expand Up @@ -528,45 +522,3 @@ fn parse_arg(
}
)))
}

fn is_rustc_at_least(major: u32, minor: u32) -> bool {
let version = rustc_version();
version.0 >= major && version.1 >= minor
}

fn rustc_version() -> &'static (u32, u32) {
static RUSTC_VERSION: OnceLock<(u32, u32)> = OnceLock::new();
RUSTC_VERSION.get_or_init(|| {
cross_command("rustc")
.arg("-V")
.output()
.ok()
.and_then(|o| {
let version = String::from_utf8_lossy(&o.stdout)
.trim()
.split(' ')
.nth(1)
.unwrap_or_default()
.split('.')
.take(2)
.flat_map(|p| p.parse::<u32>().ok())
.collect::<Vec<_>>();
version
.first()
.and_then(|major| version.get(1).map(|minor| (*major, *minor)))
})
.unwrap_or((1, 0))
})
}

fn cross_command(bin: &str) -> std::process::Command {
#[cfg(target_os = "windows")]
let cmd = {
let mut cmd = std::process::Command::new("cmd");
cmd.arg("/c").arg(bin);
cmd
};
#[cfg(not(target_os = "windows"))]
let cmd = std::process::Command::new(bin);
cmd
}
4 changes: 1 addition & 3 deletions crates/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5325,9 +5325,7 @@ You may have it installed on another user account, but it is not available for t
// on multiwebview mode if we change focus to a different webview
// we get the gotFocus event of the other webview before the lostFocus
// so this check makes sense
let lost_window_focus = focused_webview.as_ref().map_or(true, |w| w == &label_);
// TODO: Use `is_none_or` instead when MSRV gets raised above 1.82
// let lost_window_focus = focused_webview.as_ref().is_none_or(|t| t == &label_);
let lost_window_focus = focused_webview.as_ref().is_none_or(|t| t == &label_);

if lost_window_focus {
// only reset when we lost window focus - otherwise some other webview is focused
Expand Down
5 changes: 2 additions & 3 deletions crates/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1745,10 +1745,9 @@ impl FromStr for Color {
fn from_str(mut color: &str) -> Result<Self, Self::Err> {
color = color.trim().strip_prefix('#').unwrap_or(color);
let color = match color.len() {
// TODO: use repeat_n once our MSRV is bumped to 1.82
3 => color.chars()
.flat_map(|c| std::iter::repeat(c).take(2))
.chain(std::iter::repeat('f').take(2))
.flat_map(|c| std::iter::repeat_n(c, 2))
.chain(std::iter::repeat_n('f', 2))
.collect(),
6 => format!("{color}FF"),
8 => color.to_string(),
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri/src/resources/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl dyn Resource {
}

#[inline(always)]
pub(crate) fn downcast_arc<'a, T: Resource>(self: &'a Arc<Self>) -> Option<&'a Arc<T>> {
pub(crate) fn downcast_arc<T: Resource>(self: &Arc<Self>) -> Option<&Arc<T>> {
if self.is::<T>() {
// A resource is stored as `Arc<T>` in a BTreeMap
// and is safe to cast to `Arc<T>` because of the runtime
Expand Down
Loading