Skip to content

Commit

Permalink
Merge branch 'dev' into feat/background-throttling-pr
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiankistner authored Jan 24, 2025
2 parents e2ac074 + 6cbfc48 commit 3dcf8c3
Show file tree
Hide file tree
Showing 30 changed files with 476 additions and 959 deletions.
5 changes: 5 additions & 0 deletions .changes/change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri-bundler': 'patch:bug'
---

The NSIS bundler will now replace non-numeric build metadata with `0` instead of returning an error.
5 changes: 5 additions & 0 deletions .changes/framework-entitlements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri-cli': 'patch:enhance'
---

Added conditional logic to MacOS codesigning where only executables get the entitlements file when being signed. This solves an issue where the app may not launch when using 3rd party frameworks if certain entitlements are added. Ex: multicast support (must be applied for through apple developer, and the framework would not have that capability).
1 change: 1 addition & 0 deletions .github/workflows/test-cli-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
pull_request:
paths:
- '.github/workflows/test-cli-js.yml'
- 'packages/cli/**'
# currently` @tauri-apps/cli` only tests the template
- 'crates/tauri-cli/templates/app/**'

Expand Down
49 changes: 30 additions & 19 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion crates/tauri-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ json-patch = "3"
walkdir = "2"
tauri-winres = "0.2"
semver = "1"
dirs = "5"
dirs = "6"
glob = "0.3"
toml = "0.8"
# Our code requires at least 0.8.18 so don't simplify this to 0.8
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-bundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ walkdir = "2"
handlebars = "6"
tempfile = "3"
log = { version = "0.4.21", features = ["kv"] }
dirs = "5"
dirs = "6"
os_pipe = "1"
ureq = { version = "2", default-features = false, features = ["socks-proxy"] }
native-tls = { version = "0.2", optional = true }
Expand Down
7 changes: 6 additions & 1 deletion crates/tauri-bundler/src/bundle/macos/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,14 @@ pub fn sign(
log::info!(action = "Signing"; "with identity \"{}\"", keychain.signing_identity());

for target in targets {
let entitlements_path = if target.is_an_executable {
settings.macos().entitlements.as_ref().map(Path::new)
} else {
None
};
keychain.sign(
&target.path,
settings.macos().entitlements.as_ref().map(Path::new),
entitlements_path,
target.is_an_executable && settings.macos().hardened_runtime,
)?;
}
Expand Down
10 changes: 7 additions & 3 deletions crates/tauri-bundler/src/bundle/windows/nsis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fn get_and_extract_nsis(nsis_toolset_path: &Path, _tauri_tools_path: &Path) -> c
Ok(())
}

fn add_build_number_if_needed(version_str: &str) -> anyhow::Result<String> {
fn try_add_numeric_build_number(version_str: &str) -> anyhow::Result<String> {
let version = semver::Version::parse(version_str).context("invalid app version")?;
if !version.build.is_empty() {
let build = version.build.parse::<u64>();
Expand All @@ -141,7 +141,10 @@ fn add_build_number_if_needed(version_str: &str) -> anyhow::Result<String> {
version.major, version.minor, version.patch, version.build
));
} else {
anyhow::bail!("optional build metadata in app version must be numeric-only");
log::warn!(
"Unable to parse version build metadata. Numeric value expected, received: `{}`. This will be replaced with `0` in `VIProductVersion` because Windows requires this field to be numeric.",
version.build
);
}
}

Expand All @@ -150,6 +153,7 @@ fn add_build_number_if_needed(version_str: &str) -> anyhow::Result<String> {
version.major, version.minor, version.patch,
))
}

fn build_nsis_app_installer(
settings: &Settings,
_nsis_toolset_path: &Path,
Expand Down Expand Up @@ -214,7 +218,7 @@ fn build_nsis_app_installer(
data.insert("version", to_json(version));
data.insert(
"version_with_build",
to_json(add_build_number_if_needed(version)?),
to_json(try_add_numeric_build_number(version)?),
);

data.insert(
Expand Down
8 changes: 2 additions & 6 deletions crates/tauri-cli/src/helpers/flock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,11 @@ mod sys {
}

pub(super) fn error_contended(err: &Error) -> bool {
err
.raw_os_error()
.map_or(false, |x| x == ERROR_LOCK_VIOLATION as i32)
err.raw_os_error() == Some(ERROR_LOCK_VIOLATION as i32)
}

pub(super) fn error_unsupported(err: &Error) -> bool {
err
.raw_os_error()
.map_or(false, |x| x == ERROR_INVALID_FUNCTION as i32)
err.raw_os_error() == Some(ERROR_INVALID_FUNCTION as i32)
}

pub(super) fn unlock(file: &File) -> Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-macos-sign/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ once-cell-regex = "0.2"
os_pipe = "1"
plist = "1"
rand = "0.8"
dirs-next = "2"
dirs = "6"
log = { version = "0.4.21", features = ["kv"] }
apple-codesign = "0.27"
chrono = "0.4"
Expand Down
3 changes: 1 addition & 2 deletions crates/tauri-macos-sign/src/keychain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ impl Keychain {
}

pub fn with_certificate_file(cert_path: &Path, certificate_password: &OsString) -> Result<Self> {
let home_dir =
dirs_next::home_dir().ok_or_else(|| anyhow::anyhow!("failed to resolve home dir"))?;
let home_dir = dirs::home_dir().ok_or_else(|| anyhow::anyhow!("failed to resolve home dir"))?;
let keychain_path = home_dir.join("Library").join("Keychains").join(format!(
"{}.keychain-db",
Alphanumeric.sample_string(&mut rand::thread_rng(), 16)
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-macos-sign/src/provisioning_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct ProvisioningProfile {

impl ProvisioningProfile {
pub fn from_base64(base64: &OsStr) -> Result<Self> {
let home_dir = dirs_next::home_dir().unwrap();
let home_dir = dirs::home_dir().unwrap();
let provisioning_profiles_folder = home_dir
.join("Library")
.join("MobileDevice")
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ tauri-runtime-wry = { version = "2.3.0", path = "../tauri-runtime-wry", optional
getrandom = "0.2"
serde_repr = "0.1"
http = "1"
dirs = "5"
dirs = "6"
percent-encoding = "2"
reqwest = { version = "0.12", default-features = false, features = [
"json",
Expand Down
83 changes: 6 additions & 77 deletions crates/tauri/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
sealed::{ManagerBase, RuntimeOrDispatch},
utils::{config::Config, Env},
webview::PageLoadPayload,
Context, DeviceEventFilter, Emitter, EventLoopMessage, Listener, Manager, Monitor, Result,
Context, DeviceEventFilter, Emitter, EventLoopMessage, EventName, Listener, Manager, Monitor,
Runtime, Scopes, StateManager, Theme, Webview, WebviewWindowBuilder, Window,
};

Expand All @@ -38,7 +38,6 @@ use tauri_runtime::{
};
use tauri_utils::{assets::AssetsIter, PackageInfo};

use serde::Serialize;
use std::{
borrow::Cow,
collections::HashMap,
Expand Down Expand Up @@ -929,7 +928,8 @@ macro_rules! shared_app_impl {
where
F: Fn(Event) + Send + 'static,
{
self.manager.listen(event.into(), EventTarget::App, handler)
let event = EventName::new(event.into()).unwrap();
self.manager.listen(event, EventTarget::App, handler)
}

/// Listen to an event on this app only once.
Expand All @@ -939,7 +939,8 @@ macro_rules! shared_app_impl {
where
F: FnOnce(Event) + Send + 'static,
{
self.manager.once(event.into(), EventTarget::App, handler)
let event = EventName::new(event.into()).unwrap();
self.manager.once(event, EventTarget::App, handler)
}

/// Unlisten to an event on this app.
Expand All @@ -966,79 +967,7 @@ macro_rules! shared_app_impl {
}
}

impl<R: Runtime> Emitter<R> for $app {
/// Emits an event to all [targets](EventTarget).
///
/// # Examples
/// ```
/// use tauri::Emitter;
///
/// #[tauri::command]
/// fn synchronize(app: tauri::AppHandle) {
/// // emits the synchronized event to all webviews
/// app.emit("synchronized", ());
/// }
/// ```
fn emit<S: Serialize + Clone>(&self, event: &str, payload: S) -> Result<()> {
self.manager.emit(event, payload)
}

/// Emits an event to all [targets](EventTarget) matching the given target.
///
/// # Examples
/// ```
/// use tauri::{Emitter, EventTarget};
///
/// #[tauri::command]
/// fn download(app: tauri::AppHandle) {
/// for i in 1..100 {
/// std::thread::sleep(std::time::Duration::from_millis(150));
/// // emit a download progress event to all listeners
/// app.emit_to(EventTarget::any(), "download-progress", i);
/// // emit an event to listeners that used App::listen or AppHandle::listen
/// app.emit_to(EventTarget::app(), "download-progress", i);
/// // emit an event to any webview/window/webviewWindow matching the given label
/// app.emit_to("updater", "download-progress", i); // similar to using EventTarget::labeled
/// app.emit_to(EventTarget::labeled("updater"), "download-progress", i);
/// // emit an event to listeners that used WebviewWindow::listen
/// app.emit_to(EventTarget::webview_window("updater"), "download-progress", i);
/// }
/// }
/// ```
fn emit_to<I, S>(&self, target: I, event: &str, payload: S) -> Result<()>
where
I: Into<EventTarget>,
S: Serialize + Clone,
{
self.manager.emit_to(target, event, payload)
}

/// Emits an event to all [targets](EventTarget) based on the given filter.
///
/// # Examples
/// ```
/// use tauri::{Emitter, EventTarget};
///
/// #[tauri::command]
/// fn download(app: tauri::AppHandle) {
/// for i in 1..100 {
/// std::thread::sleep(std::time::Duration::from_millis(150));
/// // emit a download progress event to the updater window
/// app.emit_filter("download-progress", i, |t| match t {
/// EventTarget::WebviewWindow { label } => label == "main",
/// _ => false,
/// });
/// }
/// }
/// ```
fn emit_filter<S, F>(&self, event: &str, payload: S, filter: F) -> Result<()>
where
S: Serialize + Clone,
F: Fn(&EventTarget) -> bool,
{
self.manager.emit_filter(event, payload, filter)
}
}
impl<R: Runtime> Emitter<R> for $app {}
};
}

Expand Down
Loading

0 comments on commit 3dcf8c3

Please sign in to comment.