From 74212d40d80dba4501b3d4ae30104fa3d447bdf9 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Tue, 12 Nov 2024 15:59:47 +0200 Subject: [PATCH 1/4] feat(cli): include linux DE and session type in `tauri info` (#11653) --- .changes/info-linux-de-and-session.md | 7 ++++++ crates/tauri-cli/src/info/env_system.rs | 32 +++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 .changes/info-linux-de-and-session.md diff --git a/.changes/info-linux-de-and-session.md b/.changes/info-linux-de-and-session.md new file mode 100644 index 000000000000..024c5f23591b --- /dev/null +++ b/.changes/info-linux-de-and-session.md @@ -0,0 +1,7 @@ +--- +"tauri-cli": "patch:feat" +"@tauri-apps/cli": "patch:feat" +--- + +Include Linux destkop environment and session type in `tauri info` command. + diff --git a/crates/tauri-cli/src/info/env_system.rs b/crates/tauri-cli/src/info/env_system.rs index a0570c28afc6..9deb72844e37 100644 --- a/crates/tauri-cli/src/info/env_system.rs +++ b/crates/tauri-cli/src/info/env_system.rs @@ -175,17 +175,45 @@ fn is_xcode_command_line_tools_installed() -> bool { .map(|o| o.status.success()) .unwrap_or(false) } +fn de_and_session() -> String { + #[cfg(any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "openbsd", + target_os = "netbsd" + ))] + return { + let de = std::env::var("DESKTOP_SESSION"); + let session = std::env::var("XDG_SESSION_TYPE"); + format!( + " ({} on {})", + de.as_deref().unwrap_or("Unknown DE"), + session.as_deref().unwrap_or("Unknown Session") + ) + }; + + #[cfg(not(any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "openbsd", + target_os = "netbsd" + )))] + String::new() +} pub fn items() -> Vec { vec![ SectionItem::new().action(|| { let os_info = os_info::get(); format!( - "OS: {} {} {} ({:?})", + "OS: {} {} {} ({:?}){}", os_info.os_type(), os_info.version(), os_info.architecture().unwrap_or("Unknown Architecture"), - os_info.bitness() + os_info.bitness(), + de_and_session(), ).into() }), #[cfg(windows)] From 46935212b61da44dc82dfeb803fceebf5659f7b7 Mon Sep 17 00:00:00 2001 From: Tony <68118705+Legend-Master@users.noreply.github.com> Date: Tue, 12 Nov 2024 22:44:37 +0800 Subject: [PATCH 2/4] fix: parse json5 capability files when `config-json5` is enabled (#11658) --- .changes/json5-capability-files.md | 6 ++++++ crates/tauri-utils/src/acl/build.rs | 7 ++++++- crates/tauri-utils/src/acl/capability.rs | 2 ++ crates/tauri-utils/src/acl/mod.rs | 5 +++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 .changes/json5-capability-files.md diff --git a/.changes/json5-capability-files.md b/.changes/json5-capability-files.md new file mode 100644 index 000000000000..b0fe7fb54699 --- /dev/null +++ b/.changes/json5-capability-files.md @@ -0,0 +1,6 @@ +--- +"tauri": patch:bug +"tauri-utils": patch:bug +--- + +Fix `.json5` capability files not recognized even with `config-json5` feature enabled diff --git a/crates/tauri-utils/src/acl/build.rs b/crates/tauri-utils/src/acl/build.rs index d32eb0232846..12ce4e9e0a84 100644 --- a/crates/tauri-utils/src/acl/build.rs +++ b/crates/tauri-utils/src/acl/build.rs @@ -34,7 +34,12 @@ pub const PERMISSION_FILE_EXTENSIONS: &[&str] = &["json", "toml"]; pub const PERMISSION_DOCS_FILE_NAME: &str = "reference.md"; /// Allowed capability file extensions -const CAPABILITY_FILE_EXTENSIONS: &[&str] = &["json", "toml"]; +const CAPABILITY_FILE_EXTENSIONS: &[&str] = &[ + "json", + #[cfg(feature = "config-json5")] + "json5", + "toml", +]; /// Known folder name of the capability schemas const CAPABILITIES_SCHEMA_FOLDER_NAME: &str = "schemas"; diff --git a/crates/tauri-utils/src/acl/capability.rs b/crates/tauri-utils/src/acl/capability.rs index 9ac56f3ed83c..d5aeb3a79eac 100644 --- a/crates/tauri-utils/src/acl/capability.rs +++ b/crates/tauri-utils/src/acl/capability.rs @@ -267,6 +267,8 @@ impl CapabilityFile { let file: Self = match ext.as_str() { "toml" => toml::from_str(&capability_file)?, "json" => serde_json::from_str(&capability_file)?, + #[cfg(feature = "config-json5")] + "json5" => json5::from_str(&capability_file)?, _ => return Err(super::Error::UnknownCapabilityFormat(ext)), }; Ok(file) diff --git a/crates/tauri-utils/src/acl/mod.rs b/crates/tauri-utils/src/acl/mod.rs index 40e475fde51c..7821b7c068ba 100644 --- a/crates/tauri-utils/src/acl/mod.rs +++ b/crates/tauri-utils/src/acl/mod.rs @@ -103,6 +103,11 @@ pub enum Error { #[error("failed to parse JSON: {0}")] Json(#[from] serde_json::Error), + /// Invalid JSON5 encountered + #[cfg(feature = "config-json5")] + #[error("failed to parse JSON5: {0}")] + Json5(#[from] json5::Error), + /// Invalid permissions file format #[error("unknown permission format {0}")] UnknownPermissionFormat(String), From dc4d79477665bc3bfefb4048772414cf5d78e3df Mon Sep 17 00:00:00 2001 From: SpikeHD <25207995+SpikeHD@users.noreply.github.com> Date: Tue, 12 Nov 2024 15:20:06 -0800 Subject: [PATCH 3/4] feat(windows, linux): add `WebviewWindowBuilder/WebviewBuilder::extensions_path` (#11628) --- .changes/extension-path.md | 7 +++++++ crates/tauri-runtime-wry/src/lib.rs | 14 ++++++++++++++ crates/tauri-runtime/src/webview.rs | 2 ++ crates/tauri/src/webview/mod.rs | 14 +++++++++++++- crates/tauri/src/webview/webview_window.rs | 14 +++++++++++++- 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 .changes/extension-path.md diff --git a/.changes/extension-path.md b/.changes/extension-path.md new file mode 100644 index 000000000000..caec2b54d50e --- /dev/null +++ b/.changes/extension-path.md @@ -0,0 +1,7 @@ +--- +"tauri": "minor:feat" +"tauri-runtime": "minor:feat" +"tauri-runtime-wry": "minor:feat" +--- + +Add `WebviewWindowBuilder/WebviewBuilder::extensions_path` on Linux and Windows. diff --git a/crates/tauri-runtime-wry/src/lib.rs b/crates/tauri-runtime-wry/src/lib.rs index 12629db18420..6d256f1c32a8 100644 --- a/crates/tauri-runtime-wry/src/lib.rs +++ b/crates/tauri-runtime-wry/src/lib.rs @@ -4283,6 +4283,20 @@ fn create_webview( .with_browser_extensions_enabled(webview_attributes.browser_extensions_enabled); } + #[cfg(any( + windows, + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd" + ))] + { + if let Some(path) = &webview_attributes.extensions_path { + webview_builder = webview_builder.with_extension_path(path); + } + } + webview_builder = webview_builder.with_ipc_handler(create_ipc_handler( kind, window_id.clone(), diff --git a/crates/tauri-runtime/src/webview.rs b/crates/tauri-runtime/src/webview.rs index e17b9e197396..e14799bf44bf 100644 --- a/crates/tauri-runtime/src/webview.rs +++ b/crates/tauri-runtime/src/webview.rs @@ -210,6 +210,7 @@ pub struct WebviewAttributes { pub proxy_url: Option, pub zoom_hotkeys_enabled: bool, pub browser_extensions_enabled: bool, + pub extensions_path: Option, pub use_https_scheme: bool, pub devtools: Option, pub background_color: Option, @@ -272,6 +273,7 @@ impl WebviewAttributes { proxy_url: None, zoom_hotkeys_enabled: false, browser_extensions_enabled: false, + extensions_path: None, use_https_scheme: false, devtools: None, background_color: None, diff --git a/crates/tauri/src/webview/mod.rs b/crates/tauri/src/webview/mod.rs index 987186939140..feb818162910 100644 --- a/crates/tauri/src/webview/mod.rs +++ b/crates/tauri/src/webview/mod.rs @@ -42,7 +42,7 @@ use crate::{ use std::{ borrow::Cow, hash::{Hash, Hasher}, - path::PathBuf, + path::{Path, PathBuf}, sync::{Arc, Mutex, MutexGuard}, }; @@ -802,6 +802,18 @@ fn main() { self } + /// Set the path from which to load extensions from. Extensions stored in this path should be unpacked Chrome extensions on Windows, and compiled `.so` extensions on Linux. + /// + /// ## Platform-specific: + /// + /// - **Windows**: Browser extensions must first be enabled. See [`browser_extensions_enabled`](Self::browser_extensions_enabled) + /// - **MacOS / iOS / Android** - Unsupported. + #[must_use] + pub fn extensions_path(mut self, path: impl AsRef) -> Self { + self.webview_attributes.extensions_path = Some(path.as_ref().to_path_buf()); + self + } + /// Sets whether the custom protocols should use `https://.localhost` instead of the default `http://.localhost` on Windows and Android. Defaults to `false`. /// /// ## Note diff --git a/crates/tauri/src/webview/webview_window.rs b/crates/tauri/src/webview/webview_window.rs index a81599ed18dd..b95e6a90564c 100644 --- a/crates/tauri/src/webview/webview_window.rs +++ b/crates/tauri/src/webview/webview_window.rs @@ -6,7 +6,7 @@ use std::{ borrow::Cow, - path::PathBuf, + path::{Path, PathBuf}, sync::{Arc, MutexGuard}, }; @@ -906,6 +906,18 @@ impl<'a, R: Runtime, M: Manager> WebviewWindowBuilder<'a, R, M> { self } + /// Set the path from which to load extensions from. Extensions stored in this path should be unpacked Chrome extensions on Windows, and compiled `.so` extensions on Linux. + /// + /// ## Platform-specific: + /// + /// - **Windows**: Browser extensions must first be enabled. See [`browser_extensions_enabled`](Self::browser_extensions_enabled) + /// - **MacOS / iOS / Android** - Unsupported. + #[must_use] + pub fn extensions_path(mut self, path: impl AsRef) -> Self { + self.webview_builder = self.webview_builder.extensions_path(path); + self + } + /// Sets whether the custom protocols should use `https://.localhost` instead of the default `http://.localhost` on Windows and Android. Defaults to `false`. /// /// ## Note From cccb308c7b559b0838138d6cea280665f060c925 Mon Sep 17 00:00:00 2001 From: jLynx Date: Wed, 13 Nov 2024 14:12:06 +1300 Subject: [PATCH 4/4] feat(bundler): create signature for `.deb` bundle (#11562) --- .changes/deb-updater-support.md | 7 +++++++ crates/tauri-bundler/src/bundle.rs | 3 ++- crates/tauri-cli/src/bundle.rs | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 .changes/deb-updater-support.md diff --git a/.changes/deb-updater-support.md b/.changes/deb-updater-support.md new file mode 100644 index 000000000000..001a5b1dccd7 --- /dev/null +++ b/.changes/deb-updater-support.md @@ -0,0 +1,7 @@ +--- +'tauri-bundler': minor:feat +'tauri-cli': minor:feat +'@tauri-apps/cli': minor:feat +--- + +Generate signature for `.deb` packages when `createUpdaterArtifacts` option is enabled. diff --git a/crates/tauri-bundler/src/bundle.rs b/crates/tauri-bundler/src/bundle.rs index 17100cb9cdfd..2f470c0c38d9 100644 --- a/crates/tauri-bundler/src/bundle.rs +++ b/crates/tauri-bundler/src/bundle.rs @@ -151,6 +151,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result> { | PackageType::MacOsBundle | PackageType::Nsis | PackageType::WindowsMsi + | PackageType::Deb ) } else { matches!(package_type, PackageType::MacOsBundle) @@ -166,7 +167,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result> { // Self contained updater, no need to zip matches!( package_type, - PackageType::AppImage | PackageType::Nsis | PackageType::WindowsMsi + PackageType::AppImage | PackageType::Nsis | PackageType::WindowsMsi | PackageType::Deb ) }) { diff --git a/crates/tauri-cli/src/bundle.rs b/crates/tauri-cli/src/bundle.rs index eded4aa2b477..5473c4b4690c 100644 --- a/crates/tauri-cli/src/bundle.rs +++ b/crates/tauri-cli/src/bundle.rs @@ -226,7 +226,11 @@ fn sign_updaters( .filter(|bundle| { matches!( bundle.package_type, - PackageType::Updater | PackageType::Nsis | PackageType::WindowsMsi | PackageType::AppImage + PackageType::Updater + | PackageType::Nsis + | PackageType::WindowsMsi + | PackageType::AppImage + | PackageType::Deb ) }) .collect();