Merge branch 'dev' into feat/api/dpi-toIpc

This commit is contained in:
amrbashir 2024-10-22 01:57:41 +03:00
commit 258fe72f3d
No known key found for this signature in database
GPG Key ID: BBD7A47A2003FF33
53 changed files with 480 additions and 148 deletions

View File

@ -1,5 +0,0 @@
---
"tauri": patch:bug
---
Expose `content-range` header in `range` response of `asset` protocol

View File

@ -0,0 +1,6 @@
---
"tauri-bundler": "patch:feat"
---
Add `bundle > linux > deb > recommends` and `bundle > linux > rpm > recommends` fields to declare a strong, but not absolute, dependency for your `.deb` and `.rpm` packages.

View File

@ -1,6 +0,0 @@
---
"tauri-bundler": "patch:feat"
---
Add `bundler > windows > wix > version` to manually specify a wix-compatible version.

View File

@ -0,0 +1,7 @@
---
"tauri-cli": "patch:enhance"
"@tauri-apps/cli": "patch:enhance"
---
Add more context for errors when decoding secret and public keys for signing updater artifacts.

View File

@ -0,0 +1,6 @@
---
"@tauri-apps/cli": patch:enhance
"tauri-cli": patch:enhance
---
Migrate the `$schema` Tauri configuration to the v2 format.

View File

@ -1,5 +0,0 @@
---
"tauri": "patch:feat"
---
Add new methods on `tauri::menu::MenuBuilder` and `tauri::menu::SubmenuBuilder` to create predefined menu item with specific text.

View File

@ -1,6 +0,0 @@
---
"@tauri-apps/api": patch:changes
"tauri": patch:changes
---
Remove references to no longer used `__TAURI_INTERNALS__.metadata.windows` and `__TAURI_INTERNALS__.metadata.webviews`.

View File

@ -0,0 +1,5 @@
---
"tauri": patch:feat
---
Added `WebviewWindow::resolve_command_scope` to check a command scope at runtime.

View File

@ -1,5 +0,0 @@
---
"tauri": patch:enhance
---
Fallback to the Window and AppHandle resource table when closing a resource by ID.

View File

@ -1,7 +0,0 @@
---
"@tauri-apps/cli": patch:enhance
"tauri-cli": patch:enhance
---
Support custom project directory structure where the Tauri app folder is not a subfolder of the frontend project.
The frontend and Tauri app project paths can be set with the `TAURI_FRONTEND_PATH` and the `TAURI_APP_PATH` environment variables respectively.

44
Cargo.lock generated
View File

@ -14,7 +14,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"insta", "insta",
"serde_json", "serde_json",
"tauri-utils 2.0.1", "tauri-utils 2.0.2",
] ]
[[package]] [[package]]
@ -8821,7 +8821,7 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
[[package]] [[package]]
name = "tauri" name = "tauri"
version = "2.0.4" version = "2.0.6"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -8865,7 +8865,7 @@ dependencies = [
"tauri-macros", "tauri-macros",
"tauri-runtime", "tauri-runtime",
"tauri-runtime-wry", "tauri-runtime-wry",
"tauri-utils 2.0.1", "tauri-utils 2.0.2",
"thiserror", "thiserror",
"tokio", "tokio",
"tracing", "tracing",
@ -8881,7 +8881,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-build" name = "tauri-build"
version = "2.0.1" version = "2.0.2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cargo_toml", "cargo_toml",
@ -8895,7 +8895,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"tauri-codegen", "tauri-codegen",
"tauri-utils 2.0.1", "tauri-utils 2.0.2",
"tauri-winres", "tauri-winres",
"toml 0.8.19", "toml 0.8.19",
"walkdir", "walkdir",
@ -8903,7 +8903,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-bundler" name = "tauri-bundler"
version = "2.0.3" version = "2.0.4"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"ar", "ar",
@ -8932,7 +8932,7 @@ dependencies = [
"tar", "tar",
"tauri-icns", "tauri-icns",
"tauri-macos-sign", "tauri-macos-sign",
"tauri-utils 2.0.1", "tauri-utils 2.0.2",
"tempfile", "tempfile",
"thiserror", "thiserror",
"time", "time",
@ -8947,7 +8947,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-cli" name = "tauri-cli"
version = "2.0.3" version = "2.0.4"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"ar", "ar",
@ -9012,7 +9012,7 @@ dependencies = [
"tauri-icns", "tauri-icns",
"tauri-macos-sign", "tauri-macos-sign",
"tauri-utils 1.6.0", "tauri-utils 1.6.0",
"tauri-utils 2.0.1", "tauri-utils 2.0.2",
"tempfile", "tempfile",
"tokio", "tokio",
"toml 0.8.19", "toml 0.8.19",
@ -9037,7 +9037,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-codegen" name = "tauri-codegen"
version = "2.0.1" version = "2.0.2"
dependencies = [ dependencies = [
"base64 0.22.1", "base64 0.22.1",
"brotli", "brotli",
@ -9053,7 +9053,7 @@ dependencies = [
"serde_json", "serde_json",
"sha2", "sha2",
"syn 2.0.79", "syn 2.0.79",
"tauri-utils 2.0.1", "tauri-utils 2.0.2",
"thiserror", "thiserror",
"time", "time",
"url", "url",
@ -9121,14 +9121,14 @@ dependencies = [
[[package]] [[package]]
name = "tauri-macros" name = "tauri-macros"
version = "2.0.1" version = "2.0.2"
dependencies = [ dependencies = [
"heck 0.5.0", "heck 0.5.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.79", "syn 2.0.79",
"tauri-codegen", "tauri-codegen",
"tauri-utils 2.0.1", "tauri-utils 2.0.2",
] ]
[[package]] [[package]]
@ -9150,7 +9150,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin" name = "tauri-plugin"
version = "2.0.1" version = "2.0.2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"glob", "glob",
@ -9158,7 +9158,7 @@ dependencies = [
"schemars", "schemars",
"serde", "serde",
"serde_json", "serde_json",
"tauri-utils 2.0.1", "tauri-utils 2.0.2",
"toml 0.8.19", "toml 0.8.19",
"walkdir", "walkdir",
] ]
@ -9192,13 +9192,13 @@ dependencies = [
"log", "log",
"serde", "serde",
"tauri", "tauri",
"tauri-plugin 2.0.1", "tauri-plugin 2.0.2",
"thiserror", "thiserror",
] ]
[[package]] [[package]]
name = "tauri-runtime" name = "tauri-runtime"
version = "2.1.0" version = "2.1.1"
dependencies = [ dependencies = [
"dpi", "dpi",
"gtk", "gtk",
@ -9207,7 +9207,7 @@ dependencies = [
"raw-window-handle", "raw-window-handle",
"serde", "serde",
"serde_json", "serde_json",
"tauri-utils 2.0.1", "tauri-utils 2.0.2",
"thiserror", "thiserror",
"url", "url",
"windows", "windows",
@ -9215,7 +9215,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-runtime-wry" name = "tauri-runtime-wry"
version = "2.1.1" version = "2.1.2"
dependencies = [ dependencies = [
"gtk", "gtk",
"http 1.1.0", "http 1.1.0",
@ -9229,7 +9229,7 @@ dependencies = [
"softbuffer", "softbuffer",
"tao", "tao",
"tauri-runtime", "tauri-runtime",
"tauri-utils 2.0.1", "tauri-utils 2.0.2",
"tracing", "tracing",
"url", "url",
"webkit2gtk", "webkit2gtk",
@ -9245,7 +9245,7 @@ dependencies = [
"schemars", "schemars",
"serde", "serde",
"serde_json", "serde_json",
"tauri-utils 2.0.1", "tauri-utils 2.0.2",
"url", "url",
] ]
@ -9330,7 +9330,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-utils" name = "tauri-utils"
version = "2.0.1" version = "2.0.2"
dependencies = [ dependencies = [
"aes-gcm", "aes-gcm",
"brotli", "brotli",

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## \[2.0.2]
### Dependencies
- Upgraded to `tauri-utils@2.0.2`
## \[2.0.1] ## \[2.0.1]
### What's Changed ### What's Changed

View File

@ -1,6 +1,6 @@
[package] [package]
name = "tauri-build" name = "tauri-build"
version = "2.0.1" version = "2.0.2"
description = "build time code to pair with https://crates.io/crates/tauri" description = "build time code to pair with https://crates.io/crates/tauri"
exclude = ["CHANGELOG.md", "/target"] exclude = ["CHANGELOG.md", "/target"]
readme = "README.md" readme = "README.md"
@ -28,8 +28,8 @@ rustdoc-args = ["--cfg", "docsrs"]
[dependencies] [dependencies]
anyhow = "1" anyhow = "1"
quote = { version = "1", optional = true } quote = { version = "1", optional = true }
tauri-codegen = { version = "2.0.1", path = "../tauri-codegen", optional = true } tauri-codegen = { version = "2.0.2", path = "../tauri-codegen", optional = true }
tauri-utils = { version = "2.0.1", path = "../tauri-utils", features = [ tauri-utils = { version = "2.0.2", path = "../tauri-utils", features = [
"build", "build",
"resources", "resources",
] } ] }

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## \[2.0.4]
### New Features
- [`c8f55b615`](https://www.github.com/tauri-apps/tauri/commit/c8f55b615d2d98ade5c0f1896139dc283382a176) ([#11388](https://www.github.com/tauri-apps/tauri/pull/11388) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Add `bundler > windows > wix > version` to manually specify a wix-compatible version.
## \[2.0.3] ## \[2.0.3]
### New Features ### New Features

View File

@ -1,6 +1,6 @@
[package] [package]
name = "tauri-bundler" name = "tauri-bundler"
version = "2.0.3" version = "2.0.4"
authors = [ authors = [
"George Burton <burtonageo@gmail.com>", "George Burton <burtonageo@gmail.com>",
"Tauri Programme within The Commons Conservancy", "Tauri Programme within The Commons Conservancy",
@ -15,7 +15,7 @@ rust-version = "1.77.2"
exclude = ["CHANGELOG.md", "/target", "rustfmt.toml"] exclude = ["CHANGELOG.md", "/target", "rustfmt.toml"]
[dependencies] [dependencies]
tauri-utils = { version = "2.0.1", path = "../tauri-utils", features = [ tauri-utils = { version = "2.0.2", path = "../tauri-utils", features = [
"resources", "resources",
] } ] }
image = "0.25.0" image = "0.25.0"

View File

@ -198,6 +198,15 @@ fn generate_control_file(
if !dependencies.is_empty() { if !dependencies.is_empty() {
writeln!(file, "Depends: {}", dependencies.join(", "))?; writeln!(file, "Depends: {}", dependencies.join(", "))?;
} }
let dependencies = settings
.deb()
.recommends
.as_ref()
.cloned()
.unwrap_or_default();
if !dependencies.is_empty() {
writeln!(file, "Recommends: {}", dependencies.join(", "))?;
}
let provides = settings let provides = settings
.deb() .deb()
.provides .provides

View File

@ -84,6 +84,17 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
builder = builder.provides(Dependency::any(dep)); builder = builder.provides(Dependency::any(dep));
} }
// Add recommends
for dep in settings
.rpm()
.recommends
.as_ref()
.cloned()
.unwrap_or_default()
{
builder = builder.recommends(Dependency::any(dep));
}
// Add conflicts // Add conflicts
for dep in settings for dep in settings
.rpm() .rpm()

View File

@ -170,6 +170,8 @@ pub struct DebianSettings {
// OS-specific settings: // OS-specific settings:
/// the list of debian dependencies. /// the list of debian dependencies.
pub depends: Option<Vec<String>>, pub depends: Option<Vec<String>>,
/// the list of debian dependencies recommendations.
pub recommends: Option<Vec<String>>,
/// the list of dependencies the package provides. /// the list of dependencies the package provides.
pub provides: Option<Vec<String>>, pub provides: Option<Vec<String>>,
/// the list of package conflicts. /// the list of package conflicts.
@ -222,6 +224,8 @@ pub struct AppImageSettings {
pub struct RpmSettings { pub struct RpmSettings {
/// The list of RPM dependencies your application relies on. /// The list of RPM dependencies your application relies on.
pub depends: Option<Vec<String>>, pub depends: Option<Vec<String>>,
/// the list of of RPM dependencies your application recommends.
pub recommends: Option<Vec<String>>,
/// The list of RPM dependencies your application provides. /// The list of RPM dependencies your application provides.
pub provides: Option<Vec<String>>, pub provides: Option<Vec<String>>,
/// The list of RPM dependencies your application conflicts with. They must not be present /// The list of RPM dependencies your application conflicts with. They must not be present

View File

@ -1,5 +1,16 @@
# Changelog # Changelog
## \[2.0.4]
### Enhancements
- [`e4c9268b1`](https://www.github.com/tauri-apps/tauri/commit/e4c9268b19c614dc9ebb0895448fd16de7efee80) ([#11258](https://www.github.com/tauri-apps/tauri/pull/11258) by [@regexident](https://www.github.com/tauri-apps/tauri/../../regexident)) Support custom project directory structure where the Tauri app folder is not a subfolder of the frontend project.
The frontend and Tauri app project paths can be set with the `TAURI_FRONTEND_PATH` and the `TAURI_APP_PATH` environment variables respectively.
### Dependencies
- Upgraded to `tauri-bundler@2.0.4`
## \[2.0.3] ## \[2.0.3]
### New Features ### New Features

View File

@ -1,6 +1,6 @@
[package] [package]
name = "tauri-cli" name = "tauri-cli"
version = "2.0.3" version = "2.0.4"
authors = ["Tauri Programme within The Commons Conservancy"] authors = ["Tauri Programme within The Commons Conservancy"]
edition = "2021" edition = "2021"
rust-version = "1.77.2" rust-version = "1.77.2"
@ -47,7 +47,7 @@ sublime_fuzzy = "0.7"
clap_complete = "4" clap_complete = "4"
clap = { version = "4.5", features = ["derive", "env"] } clap = { version = "4.5", features = ["derive", "env"] }
anyhow = "1.0" anyhow = "1.0"
tauri-bundler = { version = "2.0.3", default-features = false, path = "../tauri-bundler" } tauri-bundler = { version = "2.0.4", default-features = false, path = "../tauri-bundler" }
colored = "2.1" colored = "2.1"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["preserve_order"] } serde_json = { version = "1.0", features = ["preserve_order"] }
@ -57,7 +57,7 @@ shared_child = "1.0"
duct = "0.13" duct = "0.13"
toml_edit = { version = "0.22", features = ["serde"] } toml_edit = { version = "0.22", features = ["serde"] }
json-patch = "2.0" json-patch = "2.0"
tauri-utils = { version = "2.0.1", path = "../tauri-utils", features = [ tauri-utils = { version = "2.0.2", path = "../tauri-utils", features = [
"isolation", "isolation",
"schema", "schema",
"config-json5", "config-json5",

View File

@ -1,6 +1,6 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://schema.tauri.app/config/2.0.4", "$id": "https://schema.tauri.app/config/2.0.6",
"title": "Config", "title": "Config",
"description": "The Tauri configuration object.\n It is read from a file where you can define your frontend assets,\n configure the bundler and define a tray icon.\n\n The configuration file is generated by the\n [`tauri init`](https://v2.tauri.app/reference/cli/#init) command that lives in\n your Tauri application source directory (src-tauri).\n\n Once generated, you may modify it at will to customize your Tauri application.\n\n ## File Formats\n\n By default, the configuration is defined as a JSON file named `tauri.conf.json`.\n\n Tauri also supports JSON5 and TOML files via the `config-json5` and `config-toml` Cargo features, respectively.\n The JSON5 file name must be either `tauri.conf.json` or `tauri.conf.json5`.\n The TOML file name is `Tauri.toml`.\n\n ## Platform-Specific Configuration\n\n In addition to the default configuration file, Tauri can\n read a platform-specific configuration from `tauri.linux.conf.json`,\n `tauri.windows.conf.json`, `tauri.macos.conf.json`, `tauri.android.conf.json` and `tauri.ios.conf.json`\n (or `Tauri.linux.toml`, `Tauri.windows.toml`, `Tauri.macos.toml`, `Tauri.android.toml` and `Tauri.ios.toml` if the `Tauri.toml` format is used),\n which gets merged with the main configuration object.\n\n ## Configuration Structure\n\n The configuration is composed of the following objects:\n\n - [`app`](#appconfig): The Tauri configuration\n - [`build`](#buildconfig): The build configuration\n - [`bundle`](#bundleconfig): The bundle configurations\n - [`plugins`](#pluginconfig): The plugins configuration\n\n Example tauri.config.json file:\n\n ```json\n {\n \"productName\": \"tauri-app\",\n \"version\": \"0.1.0\",\n \"build\": {\n \"beforeBuildCommand\": \"\",\n \"beforeDevCommand\": \"\",\n \"devUrl\": \"../dist\",\n \"frontendDist\": \"../dist\"\n },\n \"app\": {\n \"security\": {\n \"csp\": null\n },\n \"windows\": [\n {\n \"fullscreen\": false,\n \"height\": 600,\n \"resizable\": true,\n \"title\": \"Tauri App\",\n \"width\": 800\n }\n ]\n },\n \"bundle\": {},\n \"plugins\": {}\n }\n ```", "description": "The Tauri configuration object.\n It is read from a file where you can define your frontend assets,\n configure the bundler and define a tray icon.\n\n The configuration file is generated by the\n [`tauri init`](https://v2.tauri.app/reference/cli/#init) command that lives in\n your Tauri application source directory (src-tauri).\n\n Once generated, you may modify it at will to customize your Tauri application.\n\n ## File Formats\n\n By default, the configuration is defined as a JSON file named `tauri.conf.json`.\n\n Tauri also supports JSON5 and TOML files via the `config-json5` and `config-toml` Cargo features, respectively.\n The JSON5 file name must be either `tauri.conf.json` or `tauri.conf.json5`.\n The TOML file name is `Tauri.toml`.\n\n ## Platform-Specific Configuration\n\n In addition to the default configuration file, Tauri can\n read a platform-specific configuration from `tauri.linux.conf.json`,\n `tauri.windows.conf.json`, `tauri.macos.conf.json`, `tauri.android.conf.json` and `tauri.ios.conf.json`\n (or `Tauri.linux.toml`, `Tauri.windows.toml`, `Tauri.macos.toml`, `Tauri.android.toml` and `Tauri.ios.toml` if the `Tauri.toml` format is used),\n which gets merged with the main configuration object.\n\n ## Configuration Structure\n\n The configuration is composed of the following objects:\n\n - [`app`](#appconfig): The Tauri configuration\n - [`build`](#buildconfig): The build configuration\n - [`bundle`](#bundleconfig): The bundle configurations\n - [`plugins`](#pluginconfig): The plugins configuration\n\n Example tauri.config.json file:\n\n ```json\n {\n \"productName\": \"tauri-app\",\n \"version\": \"0.1.0\",\n \"build\": {\n \"beforeBuildCommand\": \"\",\n \"beforeDevCommand\": \"\",\n \"devUrl\": \"../dist\",\n \"frontendDist\": \"../dist\"\n },\n \"app\": {\n \"security\": {\n \"csp\": null\n },\n \"windows\": [\n {\n \"fullscreen\": false,\n \"height\": 600,\n \"resizable\": true,\n \"title\": \"Tauri App\",\n \"width\": 800\n }\n ]\n },\n \"bundle\": {},\n \"plugins\": {}\n }\n ```",
"type": "object", "type": "object",
@ -2574,6 +2574,16 @@
"type": "string" "type": "string"
} }
}, },
"recommends": {
"description": "The list of deb dependencies your application recommends.",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"provides": { "provides": {
"description": "The list of dependencies the package provides.", "description": "The list of dependencies the package provides.",
"type": [ "type": [
@ -2685,6 +2695,16 @@
"type": "string" "type": "string"
} }
}, },
"recommends": {
"description": "The list of RPM dependencies your application recommends.",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"provides": { "provides": {
"description": "The list of RPM dependencies your application provides.", "description": "The list of RPM dependencies your application provides.",
"type": [ "type": [

View File

@ -1,9 +1,9 @@
{ {
"cli.js": { "cli.js": {
"version": "2.0.3", "version": "2.0.4",
"node": ">= 10.0.0" "node": ">= 10.0.0"
}, },
"tauri": "2.0.4", "tauri": "2.0.6",
"tauri-build": "2.0.1", "tauri-build": "2.0.1",
"tauri-plugin": "2.0.1" "tauri-plugin": "2.0.1"
} }

View File

@ -9,7 +9,6 @@ use std::{
}; };
use anyhow::Context; use anyhow::Context;
use base64::Engine;
use clap::{builder::PossibleValue, ArgAction, Parser, ValueEnum}; use clap::{builder::PossibleValue, ArgAction, Parser, ValueEnum};
use tauri_bundler::PackageType; use tauri_bundler::PackageType;
use tauri_utils::platform::Target; use tauri_utils::platform::Target;
@ -257,15 +256,14 @@ fn sign_updaters(
// check if private_key points to a file... // check if private_key points to a file...
let maybe_path = Path::new(&private_key); let maybe_path = Path::new(&private_key);
let private_key = if maybe_path.exists() { let private_key = if maybe_path.exists() {
std::fs::read_to_string(maybe_path)? std::fs::read_to_string(maybe_path)
.with_context(|| format!("faild to read {}", maybe_path.display()))?
} else { } else {
private_key private_key
}; };
let secret_key = updater_signature::secret_key(private_key, password)?; let secret_key =
updater_signature::secret_key(private_key, password).context("failed to decode secret key")?;
let pubkey = base64::engine::general_purpose::STANDARD.decode(pubkey)?; let public_key = updater_signature::pub_key(pubkey).context("failed to decode pubkey")?;
let pub_key_decoded = String::from_utf8_lossy(&pubkey);
let public_key = minisign::PublicKeyBox::from_string(&pub_key_decoded)?.into_public_key()?;
let mut signed_paths = Vec::new(); let mut signed_paths = Vec::new();
for bundle in update_enabled_bundles { for bundle in update_enabled_bundles {

View File

@ -4,7 +4,9 @@
use anyhow::Context; use anyhow::Context;
use base64::Engine; use base64::Engine;
use minisign::{sign, KeyPair as KP, SecretKey, SecretKeyBox, SignatureBox}; use minisign::{
sign, KeyPair as KP, PublicKey, PublicKeyBox, SecretKey, SecretKeyBox, SignatureBox,
};
use std::{ use std::{
fs::{self, File, OpenOptions}, fs::{self, File, OpenOptions},
io::{BufReader, BufWriter, Write}, io::{BufReader, BufWriter, Write},
@ -132,15 +134,24 @@ pub fn secret_key<S: AsRef<[u8]>>(
private_key: S, private_key: S,
password: Option<String>, password: Option<String>,
) -> crate::Result<SecretKey> { ) -> crate::Result<SecretKey> {
let decoded_secret = decode_key(private_key)?; let decoded_secret = decode_key(private_key).context("failed to decode base64 secret key")?;
let sk_box = SecretKeyBox::from_string(&decoded_secret) let sk_box =
.with_context(|| "failed to load updater private key")?; SecretKeyBox::from_string(&decoded_secret).context("failed to load updater private key")?;
let sk = sk_box let sk = sk_box
.into_secret_key(password) .into_secret_key(password)
.with_context(|| "incorrect updater private key password")?; .context("incorrect updater private key password")?;
Ok(sk) Ok(sk)
} }
/// Gets the updater secret key from the given private key and password.
pub fn pub_key<S: AsRef<[u8]>>(public_key: S) -> crate::Result<PublicKey> {
let decoded_publick = decode_key(public_key).context("failed to decode base64 pubkey")?;
let pk_box =
PublicKeyBox::from_string(&decoded_publick).context("failed to load updater pubkey")?;
let pk = pk_box.into_public_key()?;
Ok(pk)
}
fn unix_timestamp() -> u64 { fn unix_timestamp() -> u64 {
let start = SystemTime::now(); let start = SystemTime::now();
let since_the_epoch = start let since_the_epoch = start

View File

@ -1346,6 +1346,7 @@ fn tauri_config_to_bundle_settings(
} else { } else {
Some(depends_deb) Some(depends_deb)
}, },
recommends: config.linux.deb.recommends,
provides: config.linux.deb.provides, provides: config.linux.deb.provides,
conflicts: config.linux.deb.conflicts, conflicts: config.linux.deb.conflicts,
replaces: config.linux.deb.replaces, replaces: config.linux.deb.replaces,
@ -1368,6 +1369,7 @@ fn tauri_config_to_bundle_settings(
} else { } else {
Some(depends_rpm) Some(depends_rpm)
}, },
recommends: config.linux.rpm.recommends,
provides: config.linux.rpm.provides, provides: config.linux.rpm.provides,
conflicts: config.linux.rpm.conflicts, conflicts: config.linux.rpm.conflicts,
obsoletes: config.linux.rpm.obsoletes, obsoletes: config.linux.rpm.obsoletes,

View File

@ -684,6 +684,15 @@ mod test {
let mut migrated = original.clone(); let mut migrated = original.clone();
super::migrate_config(&mut migrated).expect("failed to migrate config"); super::migrate_config(&mut migrated).expect("failed to migrate config");
if original.get("$schema").is_some() {
if let Some(map) = migrated.as_object_mut() {
map.insert(
"$schema".to_string(),
serde_json::Value::String("https://schema.tauri.app/config/2".to_string()),
);
}
}
if original if original
.get("tauri") .get("tauri")
.and_then(|v| v.get("bundle")) .and_then(|v| v.get("bundle"))
@ -708,6 +717,7 @@ mod test {
#[test] #[test]
fn migrate_full() { fn migrate_full() {
let original = serde_json::json!({ let original = serde_json::json!({
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
"build": { "build": {
"distDir": "../dist", "distDir": "../dist",
"devPath": "http://localhost:1240", "devPath": "http://localhost:1240",
@ -798,6 +808,9 @@ mod test {
let migrated = migrate(&original); let migrated = migrate(&original);
// $schema
assert_eq!(migrated["$schema"], "https://schema.tauri.app/config/2");
// plugins > updater // plugins > updater
assert_eq!( assert_eq!(
migrated["plugins"]["updater"]["endpoints"], migrated["plugins"]["updater"]["endpoints"],

View File

@ -204,7 +204,7 @@ fn get_str_array(helper: &Helper, formatter: impl Fn(&str) -> String) -> Option<
.map(|val| { .map(|val| {
val.as_str().map( val.as_str().map(
#[allow(clippy::redundant_closure)] #[allow(clippy::redundant_closure)]
|s| formatter(s), &formatter,
) )
}) })
.collect() .collect()

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## \[2.0.2]
### Dependencies
- Upgraded to `tauri-utils@2.0.2`
## \[2.0.1] ## \[2.0.1]
### What's Changed ### What's Changed

View File

@ -1,6 +1,6 @@
[package] [package]
name = "tauri-codegen" name = "tauri-codegen"
version = "2.0.1" version = "2.0.2"
description = "code generation meant to be consumed inside of `tauri` through `tauri-build` or `tauri-macros`" description = "code generation meant to be consumed inside of `tauri` through `tauri-build` or `tauri-macros`"
exclude = ["CHANGELOG.md", "/target"] exclude = ["CHANGELOG.md", "/target"]
readme = "README.md" readme = "README.md"
@ -20,7 +20,7 @@ quote = "1"
syn = "2" syn = "2"
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
serde_json = "1" serde_json = "1"
tauri-utils = { version = "2.0.1", path = "../tauri-utils", features = [ tauri-utils = { version = "2.0.2", path = "../tauri-utils", features = [
"build", "build",
] } ] }
thiserror = "1" thiserror = "1"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "tauri-macros" name = "tauri-macros"
version = "2.0.1" version = "2.0.2"
description = "Macros for the tauri crate." description = "Macros for the tauri crate."
exclude = ["CHANGELOG.md", "/target"] exclude = ["CHANGELOG.md", "/target"]
readme = "README.md" readme = "README.md"
@ -20,8 +20,8 @@ proc-macro2 = { version = "1", features = ["span-locations"] }
quote = "1" quote = "1"
syn = { version = "2", features = ["full"] } syn = { version = "2", features = ["full"] }
heck = "0.5" heck = "0.5"
tauri-codegen = { version = "2.0.1", default-features = false, path = "../tauri-codegen" } tauri-codegen = { version = "2.0.2", default-features = false, path = "../tauri-codegen" }
tauri-utils = { version = "2.0.1", path = "../tauri-utils" } tauri-utils = { version = "2.0.2", path = "../tauri-utils" }
[features] [features]
custom-protocol = [] custom-protocol = []

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## \[2.0.2]
### Dependencies
- Upgraded to `tauri-utils@2.0.2`
## \[2.0.1] ## \[2.0.1]
### What's Changed ### What's Changed

View File

@ -1,6 +1,6 @@
[package] [package]
name = "tauri-plugin" name = "tauri-plugin"
version = "2.0.1" version = "2.0.2"
description = "Build script and runtime Tauri plugin definitions" description = "Build script and runtime Tauri plugin definitions"
authors.workspace = true authors.workspace = true
homepage.workspace = true homepage.workspace = true
@ -30,7 +30,7 @@ runtime = []
[dependencies] [dependencies]
anyhow = { version = "1", optional = true } anyhow = { version = "1", optional = true }
serde = { version = "1", optional = true } serde = { version = "1", optional = true }
tauri-utils = { version = "2.0.1", default-features = false, features = [ tauri-utils = { version = "2.0.2", default-features = false, features = [
"build", "build",
], path = "../tauri-utils" } ], path = "../tauri-utils" }
serde_json = { version = "1", optional = true } serde_json = { version = "1", optional = true }

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## \[2.1.2]
### Dependencies
- Upgraded to `tauri-utils@2.0.2`
## \[2.1.1] ## \[2.1.1]
### Bug Fixes ### Bug Fixes

View File

@ -1,6 +1,6 @@
[package] [package]
name = "tauri-runtime-wry" name = "tauri-runtime-wry"
version = "2.1.1" version = "2.1.2"
description = "Wry bindings to the Tauri runtime" description = "Wry bindings to the Tauri runtime"
exclude = ["CHANGELOG.md", "/target"] exclude = ["CHANGELOG.md", "/target"]
readme = "README.md" readme = "README.md"
@ -25,7 +25,7 @@ wry = { version = "0.46.1", default-features = false, features = [
] } ] }
tao = { version = "0.30.2", default-features = false, features = ["rwh_06"] } tao = { version = "0.30.2", default-features = false, features = ["rwh_06"] }
tauri-runtime = { version = "2.1.0", path = "../tauri-runtime" } tauri-runtime = { version = "2.1.0", path = "../tauri-runtime" }
tauri-utils = { version = "2.0.1", path = "../tauri-utils" } tauri-utils = { version = "2.0.2", path = "../tauri-utils" }
raw-window-handle = "0.6" raw-window-handle = "0.6"
http = "1.1" http = "1.1"
url = "2" url = "2"

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## \[2.1.1]
### Dependencies
- Upgraded to `tauri-utils@2.0.2`
## \[2.1.0] ## \[2.1.0]
### Bug Fixes ### Bug Fixes

View File

@ -1,6 +1,6 @@
[package] [package]
name = "tauri-runtime" name = "tauri-runtime"
version = "2.1.0" version = "2.1.1"
description = "Runtime for Tauri applications" description = "Runtime for Tauri applications"
exclude = ["CHANGELOG.md", "/target"] exclude = ["CHANGELOG.md", "/target"]
readme = "README.md" readme = "README.md"
@ -29,7 +29,7 @@ targets = [
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
thiserror = "1.0" thiserror = "1.0"
tauri-utils = { version = "2.0.1", path = "../tauri-utils" } tauri-utils = { version = "2.0.2", path = "../tauri-utils" }
http = "1.1" http = "1.1"
raw-window-handle = "0.6" raw-window-handle = "0.6"
url = { version = "2" } url = { version = "2" }

View File

@ -1,6 +1,6 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://schema.tauri.app/config/2.0.4", "$id": "https://schema.tauri.app/config/2.0.6",
"title": "Config", "title": "Config",
"description": "The Tauri configuration object.\n It is read from a file where you can define your frontend assets,\n configure the bundler and define a tray icon.\n\n The configuration file is generated by the\n [`tauri init`](https://v2.tauri.app/reference/cli/#init) command that lives in\n your Tauri application source directory (src-tauri).\n\n Once generated, you may modify it at will to customize your Tauri application.\n\n ## File Formats\n\n By default, the configuration is defined as a JSON file named `tauri.conf.json`.\n\n Tauri also supports JSON5 and TOML files via the `config-json5` and `config-toml` Cargo features, respectively.\n The JSON5 file name must be either `tauri.conf.json` or `tauri.conf.json5`.\n The TOML file name is `Tauri.toml`.\n\n ## Platform-Specific Configuration\n\n In addition to the default configuration file, Tauri can\n read a platform-specific configuration from `tauri.linux.conf.json`,\n `tauri.windows.conf.json`, `tauri.macos.conf.json`, `tauri.android.conf.json` and `tauri.ios.conf.json`\n (or `Tauri.linux.toml`, `Tauri.windows.toml`, `Tauri.macos.toml`, `Tauri.android.toml` and `Tauri.ios.toml` if the `Tauri.toml` format is used),\n which gets merged with the main configuration object.\n\n ## Configuration Structure\n\n The configuration is composed of the following objects:\n\n - [`app`](#appconfig): The Tauri configuration\n - [`build`](#buildconfig): The build configuration\n - [`bundle`](#bundleconfig): The bundle configurations\n - [`plugins`](#pluginconfig): The plugins configuration\n\n Example tauri.config.json file:\n\n ```json\n {\n \"productName\": \"tauri-app\",\n \"version\": \"0.1.0\",\n \"build\": {\n \"beforeBuildCommand\": \"\",\n \"beforeDevCommand\": \"\",\n \"devUrl\": \"../dist\",\n \"frontendDist\": \"../dist\"\n },\n \"app\": {\n \"security\": {\n \"csp\": null\n },\n \"windows\": [\n {\n \"fullscreen\": false,\n \"height\": 600,\n \"resizable\": true,\n \"title\": \"Tauri App\",\n \"width\": 800\n }\n ]\n },\n \"bundle\": {},\n \"plugins\": {}\n }\n ```", "description": "The Tauri configuration object.\n It is read from a file where you can define your frontend assets,\n configure the bundler and define a tray icon.\n\n The configuration file is generated by the\n [`tauri init`](https://v2.tauri.app/reference/cli/#init) command that lives in\n your Tauri application source directory (src-tauri).\n\n Once generated, you may modify it at will to customize your Tauri application.\n\n ## File Formats\n\n By default, the configuration is defined as a JSON file named `tauri.conf.json`.\n\n Tauri also supports JSON5 and TOML files via the `config-json5` and `config-toml` Cargo features, respectively.\n The JSON5 file name must be either `tauri.conf.json` or `tauri.conf.json5`.\n The TOML file name is `Tauri.toml`.\n\n ## Platform-Specific Configuration\n\n In addition to the default configuration file, Tauri can\n read a platform-specific configuration from `tauri.linux.conf.json`,\n `tauri.windows.conf.json`, `tauri.macos.conf.json`, `tauri.android.conf.json` and `tauri.ios.conf.json`\n (or `Tauri.linux.toml`, `Tauri.windows.toml`, `Tauri.macos.toml`, `Tauri.android.toml` and `Tauri.ios.toml` if the `Tauri.toml` format is used),\n which gets merged with the main configuration object.\n\n ## Configuration Structure\n\n The configuration is composed of the following objects:\n\n - [`app`](#appconfig): The Tauri configuration\n - [`build`](#buildconfig): The build configuration\n - [`bundle`](#bundleconfig): The bundle configurations\n - [`plugins`](#pluginconfig): The plugins configuration\n\n Example tauri.config.json file:\n\n ```json\n {\n \"productName\": \"tauri-app\",\n \"version\": \"0.1.0\",\n \"build\": {\n \"beforeBuildCommand\": \"\",\n \"beforeDevCommand\": \"\",\n \"devUrl\": \"../dist\",\n \"frontendDist\": \"../dist\"\n },\n \"app\": {\n \"security\": {\n \"csp\": null\n },\n \"windows\": [\n {\n \"fullscreen\": false,\n \"height\": 600,\n \"resizable\": true,\n \"title\": \"Tauri App\",\n \"width\": 800\n }\n ]\n },\n \"bundle\": {},\n \"plugins\": {}\n }\n ```",
"type": "object", "type": "object",
@ -2574,6 +2574,16 @@
"type": "string" "type": "string"
} }
}, },
"recommends": {
"description": "The list of deb dependencies your application recommends.",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"provides": { "provides": {
"description": "The list of dependencies the package provides.", "description": "The list of dependencies the package provides.",
"type": [ "type": [
@ -2685,6 +2695,16 @@
"type": "string" "type": "string"
} }
}, },
"recommends": {
"description": "The list of RPM dependencies your application recommends.",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"provides": { "provides": {
"description": "The list of RPM dependencies your application provides.", "description": "The list of RPM dependencies your application provides.",
"type": [ "type": [

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## \[2.0.2]
### New Features
- Add `bundler > windows > wix > version` to manually specify a wix-compatible version.
## \[2.0.1] ## \[2.0.1]
### What's Changed ### What's Changed

View File

@ -1,6 +1,6 @@
[package] [package]
name = "tauri-utils" name = "tauri-utils"
version = "2.0.1" version = "2.0.2"
description = "Utilities for Tauri" description = "Utilities for Tauri"
exclude = ["CHANGELOG.md", "/target"] exclude = ["CHANGELOG.md", "/target"]
readme = "README.md" readme = "README.md"

View File

@ -331,6 +331,8 @@ pub struct AppImageConfig {
pub struct DebConfig { pub struct DebConfig {
/// The list of deb dependencies your application relies on. /// The list of deb dependencies your application relies on.
pub depends: Option<Vec<String>>, pub depends: Option<Vec<String>>,
/// The list of deb dependencies your application recommends.
pub recommends: Option<Vec<String>>,
/// The list of dependencies the package provides. /// The list of dependencies the package provides.
pub provides: Option<Vec<String>>, pub provides: Option<Vec<String>>,
/// The list of package conflicts. /// The list of package conflicts.
@ -398,6 +400,8 @@ pub struct LinuxConfig {
pub struct RpmConfig { pub struct RpmConfig {
/// The list of RPM dependencies your application relies on. /// The list of RPM dependencies your application relies on.
pub depends: Option<Vec<String>>, pub depends: Option<Vec<String>>,
/// The list of RPM dependencies your application recommends.
pub recommends: Option<Vec<String>>,
/// The list of RPM dependencies your application provides. /// The list of RPM dependencies your application provides.
pub provides: Option<Vec<String>>, pub provides: Option<Vec<String>>,
/// The list of RPM dependencies your application conflicts with. They must not be present /// The list of RPM dependencies your application conflicts with. They must not be present
@ -442,6 +446,7 @@ impl Default for RpmConfig {
fn default() -> Self { fn default() -> Self {
Self { Self {
depends: None, depends: None,
recommends: None,
provides: None, provides: None,
conflicts: None, conflicts: None,
obsoletes: None, obsoletes: None,

View File

@ -1,5 +1,29 @@
# Changelog # Changelog
## \[2.0.6]
### Dependencies
- Upgraded to `tauri-utils@2.0.2`
## \[2.0.5]
### New Features
- [`6cd917c22`](https://www.github.com/tauri-apps/tauri/commit/6cd917c227596e4e557496347ccae8ef579f6ea0) ([#11390](https://www.github.com/tauri-apps/tauri/pull/11390) by [@amrbashir](https://www.github.com/tauri-apps/tauri/../../amrbashir)) Add new methods on `tauri::menu::MenuBuilder` and `tauri::menu::SubmenuBuilder` to create predefined menu item with specific text.
### Enhancements
- [`eb61d44f9`](https://www.github.com/tauri-apps/tauri/commit/eb61d44f9fc1be591c3d10a6ac1451aa39e6a77b) ([#11398](https://www.github.com/tauri-apps/tauri/pull/11398) by [@lucasfernog](https://www.github.com/tauri-apps/tauri/../../lucasfernog)) Fallback to the Window and AppHandle resource table when closing a resource by ID.
### Bug Fixes
- [`e1bf6ef8c`](https://www.github.com/tauri-apps/tauri/commit/e1bf6ef8cbe3421eeaec47a222446121bcc28354) ([#11374](https://www.github.com/tauri-apps/tauri/pull/11374) by [@chrox](https://www.github.com/tauri-apps/tauri/../../chrox)) Expose `content-range` header in `range` response of `asset` protocol
### What's Changed
- [`2e88633ba`](https://www.github.com/tauri-apps/tauri/commit/2e88633ba4da8fc289c6d8a29c36f3327f9b576e) ([#11369](https://www.github.com/tauri-apps/tauri/pull/11369) by [@lucasfernog](https://www.github.com/tauri-apps/tauri/../../lucasfernog)) Remove references to no longer used `__TAURI_INTERNALS__.metadata.windows` and `__TAURI_INTERNALS__.metadata.webviews`.
## \[2.0.4] ## \[2.0.4]
### New Features ### New Features

View File

@ -1,6 +1,6 @@
[package] [package]
name = "tauri" name = "tauri"
version = "2.0.4" version = "2.0.6"
description = "Make tiny, secure apps for all desktop platforms with Tauri" description = "Make tiny, secure apps for all desktop platforms with Tauri"
exclude = ["/test", "/.scripts", "CHANGELOG.md", "/target"] exclude = ["/test", "/.scripts", "CHANGELOG.md", "/target"]
readme = "README.md" readme = "README.md"
@ -57,12 +57,12 @@ uuid = { version = "1", features = ["v4"], optional = true }
url = "2" url = "2"
anyhow = "1.0" anyhow = "1.0"
thiserror = "1.0" thiserror = "1.0"
tauri-runtime = { version = "2.1.0", path = "../tauri-runtime" } tauri-runtime = { version = "2.1.1", path = "../tauri-runtime" }
tauri-macros = { version = "2.0.1", path = "../tauri-macros" } tauri-macros = { version = "2.0.2", path = "../tauri-macros" }
tauri-utils = { version = "2.0.1", features = [ tauri-utils = { version = "2.0.2", features = [
"resources", "resources",
], path = "../tauri-utils" } ], path = "../tauri-utils" }
tauri-runtime-wry = { version = "2.1.1", path = "../tauri-runtime-wry", optional = true } tauri-runtime-wry = { version = "2.1.2", path = "../tauri-runtime-wry", optional = true }
getrandom = "0.2" getrandom = "0.2"
serde_repr = "0.1" serde_repr = "0.1"
http = "1.1" http = "1.1"
@ -134,8 +134,8 @@ swift-rs = "1.0.7"
[build-dependencies] [build-dependencies]
heck = "0.5" heck = "0.5"
tauri-build = { path = "../tauri-build/", default-features = false, version = "2.0.1" } tauri-build = { path = "../tauri-build/", default-features = false, version = "2.0.2" }
tauri-utils = { path = "../tauri-utils/", version = "2.0.1", features = [ tauri-utils = { path = "../tauri-utils/", version = "2.0.2", features = [
"build", "build",
] } ] }

File diff suppressed because one or more lines are too long

View File

@ -23,7 +23,7 @@ use tauri_utils::platform::Target;
use url::Url; use url::Url;
use crate::{ipc::InvokeError, sealed::ManagerBase, Runtime}; use crate::{ipc::InvokeError, sealed::ManagerBase, Runtime};
use crate::{AppHandle, Manager, StateManager}; use crate::{AppHandle, Manager, StateManager, Webview};
use super::{CommandArg, CommandItem}; use super::{CommandArg, CommandItem};
@ -614,6 +614,33 @@ pub struct CommandScope<T: ScopeObject> {
} }
impl<T: ScopeObject> CommandScope<T> { impl<T: ScopeObject> CommandScope<T> {
pub(crate) fn resolve<R: Runtime>(
webview: &Webview<R>,
scope_ids: Vec<u64>,
) -> crate::Result<Self> {
let mut allow = Vec::new();
let mut deny = Vec::new();
for scope_id in scope_ids {
let scope = webview
.manager()
.runtime_authority
.lock()
.unwrap()
.scope_manager
.get_command_scope_typed::<R, T>(webview.app_handle(), &scope_id)?;
for s in scope.allows() {
allow.push(s.clone());
}
for s in scope.denies() {
deny.push(s.clone());
}
}
Ok(CommandScope { allow, deny })
}
/// What this access scope allows. /// What this access scope allows.
pub fn allows(&self) -> &Vec<Arc<T>> { pub fn allows(&self) -> &Vec<Arc<T>> {
&self.allow &self.allow
@ -698,29 +725,7 @@ impl<'a, R: Runtime, T: ScopeObject> CommandArg<'a, R> for CommandScope<T> {
.collect::<Vec<_>>() .collect::<Vec<_>>()
}); });
if let Some(scope_ids) = scope_ids { if let Some(scope_ids) = scope_ids {
let mut allow = Vec::new(); CommandScope::resolve(&command.message.webview, scope_ids).map_err(Into::into)
let mut deny = Vec::new();
for scope_id in scope_ids {
let scope = command
.message
.webview
.manager()
.runtime_authority
.lock()
.unwrap()
.scope_manager
.get_command_scope_typed::<R, T>(command.message.webview.app_handle(), &scope_id)?;
for s in scope.allows() {
allow.push(s.clone());
}
for s in scope.denies() {
deny.push(s.clone());
}
}
Ok(CommandScope { allow, deny })
} else { } else {
Ok(CommandScope { Ok(CommandScope {
allow: Default::default(), allow: Default::default(),
@ -735,6 +740,17 @@ impl<'a, R: Runtime, T: ScopeObject> CommandArg<'a, R> for CommandScope<T> {
pub struct GlobalScope<T: ScopeObject>(ScopeValue<T>); pub struct GlobalScope<T: ScopeObject>(ScopeValue<T>);
impl<T: ScopeObject> GlobalScope<T> { impl<T: ScopeObject> GlobalScope<T> {
pub(crate) fn resolve<R: Runtime>(webview: &Webview<R>, plugin: &str) -> crate::Result<Self> {
webview
.manager()
.runtime_authority
.lock()
.unwrap()
.scope_manager
.get_global_scope_typed(webview.app_handle(), plugin)
.map(Self)
}
/// What this access scope allows. /// What this access scope allows.
pub fn allows(&self) -> &Vec<Arc<T>> { pub fn allows(&self) -> &Vec<Arc<T>> {
&self.0.allow &self.0.allow
@ -749,20 +765,11 @@ impl<T: ScopeObject> GlobalScope<T> {
impl<'a, R: Runtime, T: ScopeObject> CommandArg<'a, R> for GlobalScope<T> { impl<'a, R: Runtime, T: ScopeObject> CommandArg<'a, R> for GlobalScope<T> {
/// Grabs the [`ResolvedScope`] from the [`CommandItem`] and returns the associated [`GlobalScope`]. /// Grabs the [`ResolvedScope`] from the [`CommandItem`] and returns the associated [`GlobalScope`].
fn from_command(command: CommandItem<'a, R>) -> Result<Self, InvokeError> { fn from_command(command: CommandItem<'a, R>) -> Result<Self, InvokeError> {
command GlobalScope::resolve(
.message &command.message.webview,
.webview command.plugin.unwrap_or(APP_ACL_KEY),
.manager() )
.runtime_authority .map_err(InvokeError::from_error)
.lock()
.unwrap()
.scope_manager
.get_global_scope_typed(
command.message.webview.app_handle(),
command.plugin.unwrap_or(APP_ACL_KEY),
)
.map_err(InvokeError::from_error)
.map(GlobalScope)
} }
} }

View File

@ -29,8 +29,8 @@ use crate::{
app::{UriSchemeResponder, WebviewEvent}, app::{UriSchemeResponder, WebviewEvent},
event::{EmitArgs, EventTarget}, event::{EmitArgs, EventTarget},
ipc::{ ipc::{
CallbackFn, CommandArg, CommandItem, Invoke, InvokeBody, InvokeError, InvokeMessage, CallbackFn, CommandArg, CommandItem, CommandScope, GlobalScope, Invoke, InvokeBody,
InvokeResolver, Origin, OwnedInvokeResponder, InvokeError, InvokeMessage, InvokeResolver, Origin, OwnedInvokeResponder, ScopeObject,
}, },
manager::AppManager, manager::AppManager,
sealed::{ManagerBase, RuntimeOrDispatch}, sealed::{ManagerBase, RuntimeOrDispatch},
@ -880,6 +880,83 @@ impl<R: Runtime> Webview<R> {
.dispatcher .dispatcher
.on_webview_event(move |event| f(&event.clone().into())); .on_webview_event(move |event| f(&event.clone().into()));
} }
/// Resolves the given command scope for this webview on the currently loaded URL.
///
/// If the command is not allowed, returns None.
///
/// If the scope cannot be deserialized to the given type, an error is returned.
///
/// In a command context this can be directly resolved from the command arguments via [CommandScope]:
///
/// ```
/// use tauri::ipc::CommandScope;
///
/// #[derive(Debug, serde::Deserialize)]
/// struct ScopeType {
/// some_value: String,
/// }
/// #[tauri::command]
/// fn my_command(scope: CommandScope<ScopeType>) {
/// // check scope
/// }
/// ```
///
/// # Examples
///
/// ```
/// use tauri::Manager;
///
/// #[derive(Debug, serde::Deserialize)]
/// struct ScopeType {
/// some_value: String,
/// }
///
/// tauri::Builder::default()
/// .setup(|app| {
/// let webview = app.get_webview_window("main").unwrap();
/// let scope = webview.resolve_command_scope::<ScopeType>("my-plugin", "read");
/// Ok(())
/// });
/// ```
pub fn resolve_command_scope<T: ScopeObject>(
&self,
plugin: &str,
command: &str,
) -> crate::Result<Option<ResolvedScope<T>>> {
let current_url = self.url()?;
let is_local = self.is_local_url(&current_url);
let origin = if is_local {
Origin::Local
} else {
Origin::Remote { url: current_url }
};
let cmd_name = format!("plugin:{plugin}|{command}");
let resolved_access = self
.manager()
.runtime_authority
.lock()
.unwrap()
.resolve_access(&cmd_name, self.window().label(), self.label(), &origin);
if let Some(access) = resolved_access {
let scope_ids = access
.iter()
.filter_map(|cmd| cmd.scope_id)
.collect::<Vec<_>>();
let command_scope = CommandScope::resolve(self, scope_ids)?;
let global_scope = GlobalScope::resolve(self, plugin)?;
Ok(Some(ResolvedScope {
global_scope,
command_scope,
}))
} else {
Ok(None)
}
}
} }
/// Desktop webview setters and actions. /// Desktop webview setters and actions.
@ -1702,6 +1779,24 @@ impl<'de, R: Runtime> CommandArg<'de, R> for Webview<R> {
} }
} }
/// Resolved scope that can be obtained via [`Webview::resolve_command_scope`].
pub struct ResolvedScope<T: ScopeObject> {
command_scope: CommandScope<T>,
global_scope: GlobalScope<T>,
}
impl<T: ScopeObject> ResolvedScope<T> {
/// The global plugin scope.
pub fn global_scope(&self) -> &GlobalScope<T> {
&self.global_scope
}
/// The command-specific scope.
pub fn command_scope(&self) -> &CommandScope<T> {
&self.command_scope
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#[test] #[test]

View File

@ -12,6 +12,7 @@ use std::{
use crate::{ use crate::{
event::EventTarget, event::EventTarget,
ipc::ScopeObject,
runtime::dpi::{PhysicalPosition, PhysicalSize}, runtime::dpi::{PhysicalPosition, PhysicalSize},
window::Monitor, window::Monitor,
Emitter, Listener, ResourceTable, Window, Emitter, Listener, ResourceTable, Window,
@ -48,7 +49,7 @@ use tauri_macros::default_runtime;
#[cfg(windows)] #[cfg(windows)]
use windows::Win32::Foundation::HWND; use windows::Win32::Foundation::HWND;
use super::DownloadEvent; use super::{DownloadEvent, ResolvedScope};
/// A builder for [`WebviewWindow`], a window that hosts a single webview. /// A builder for [`WebviewWindow`], a window that hosts a single webview.
pub struct WebviewWindowBuilder<'a, R: Runtime, M: Manager<R>> { pub struct WebviewWindowBuilder<'a, R: Runtime, M: Manager<R>> {
@ -989,6 +990,52 @@ impl<R: Runtime> WebviewWindow<R> {
pub fn on_window_event<F: Fn(&WindowEvent) + Send + 'static>(&self, f: F) { pub fn on_window_event<F: Fn(&WindowEvent) + Send + 'static>(&self, f: F) {
self.window.on_window_event(f); self.window.on_window_event(f);
} }
/// Resolves the given command scope for this webview on the currently loaded URL.
///
/// If the command is not allowed, returns None.
///
/// If the scope cannot be deserialized to the given type, an error is returned.
///
/// In a command context this can be directly resolved from the command arguments via [crate::ipc::CommandScope]:
///
/// ```
/// use tauri::ipc::CommandScope;
///
/// #[derive(Debug, serde::Deserialize)]
/// struct ScopeType {
/// some_value: String,
/// }
/// #[tauri::command]
/// fn my_command(scope: CommandScope<ScopeType>) {
/// // check scope
/// }
/// ```
///
/// # Examples
///
/// ```
/// use tauri::Manager;
///
/// #[derive(Debug, serde::Deserialize)]
/// struct ScopeType {
/// some_value: String,
/// }
///
/// tauri::Builder::default()
/// .setup(|app| {
/// let webview = app.get_webview_window("main").unwrap();
/// let scope = webview.resolve_command_scope::<ScopeType>("my-plugin", "read");
/// Ok(())
/// });
/// ```
pub fn resolve_command_scope<T: ScopeObject>(
&self,
plugin: &str,
command: &str,
) -> crate::Result<Option<ResolvedScope<T>>> {
self.webview.resolve_command_scope(plugin, command)
}
} }
/// Menu APIs /// Menu APIs
@ -1038,7 +1085,7 @@ impl<R: Runtime> WebviewWindow<R> {
self.window.on_menu_event(f) self.window.on_menu_event(f)
} }
/// Returns this window menu . /// Returns this window menu.
pub fn menu(&self) -> Option<Menu<R>> { pub fn menu(&self) -> Option<Menu<R>> {
self.window.menu() self.window.menu()
} }

View File

@ -19,10 +19,10 @@ pub struct Sample<R: Runtime>(AppHandle<R>);
impl<R: Runtime> Sample<R> { impl<R: Runtime> Sample<R> {
pub fn ping(&self, payload: PingRequest) -> crate::Result<PingResponse> { pub fn ping(&self, payload: PingRequest) -> crate::Result<PingResponse> {
let _ = payload.on_event.send(Event { payload.on_event.send(Event {
kind: "ping".to_string(), kind: "ping".to_string(),
value: payload.value.clone(), value: payload.value.clone(),
}); })?;
Ok(PingResponse { Ok(PingResponse {
value: payload.value, value: payload.value,
}) })

View File

@ -7,6 +7,8 @@ pub enum Error {
#[cfg(mobile)] #[cfg(mobile)]
#[error(transparent)] #[error(transparent)]
PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError), PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError),
#[error(transparent)]
Tauri(#[from] tauri::Error),
} }
pub type Result<T> = std::result::Result<T, Error>; pub type Result<T> = std::result::Result<T, Error>;

View File

@ -1,5 +1,15 @@
# Changelog # Changelog
## \[2.0.3]
### Bug Fixes
- [`fbb45c674`](https://www.github.com/tauri-apps/tauri/commit/fbb45c674ca92fbbe04f1a8360e5f2e477dd4297) ([#11423](https://www.github.com/tauri-apps/tauri/pull/11423) by [@lucasfernog](https://www.github.com/tauri-apps/tauri/../../lucasfernog)) Fixes `addPluginListener` not working.
### What's Changed
- [`2e88633ba`](https://www.github.com/tauri-apps/tauri/commit/2e88633ba4da8fc289c6d8a29c36f3327f9b576e) ([#11369](https://www.github.com/tauri-apps/tauri/pull/11369) by [@lucasfernog](https://www.github.com/tauri-apps/tauri/../../lucasfernog)) Remove references to no longer used `__TAURI_INTERNALS__.metadata.windows` and `__TAURI_INTERNALS__.metadata.webviews`.
## \[2.0.2] ## \[2.0.2]
### What's Changed ### What's Changed

View File

@ -1,6 +1,6 @@
{ {
"name": "@tauri-apps/api", "name": "@tauri-apps/api",
"version": "2.0.2", "version": "2.0.3",
"description": "Tauri API definitions", "description": "Tauri API definitions",
"funding": { "funding": {
"type": "opencollective", "type": "opencollective",

View File

@ -171,7 +171,7 @@ async function addPluginListener<T>(
): Promise<PluginListener> { ): Promise<PluginListener> {
const handler = new Channel<T>() const handler = new Channel<T>()
handler.onmessage = cb handler.onmessage = cb
return invoke(`plugin:${plugin}|register_listener`, { event, handler }).then( return invoke(`plugin:${plugin}|registerListener`, { event, handler }).then(
() => new PluginListener(plugin, event, handler.id) () => new PluginListener(plugin, event, handler.id)
) )
} }

View File

@ -1,5 +1,16 @@
# Changelog # Changelog
## \[2.0.4]
### Enhancements
- [`e4c9268b1`](https://www.github.com/tauri-apps/tauri/commit/e4c9268b19c614dc9ebb0895448fd16de7efee80) ([#11258](https://www.github.com/tauri-apps/tauri/pull/11258) by [@regexident](https://www.github.com/tauri-apps/tauri/../../regexident)) Support custom project directory structure where the Tauri app folder is not a subfolder of the frontend project.
The frontend and Tauri app project paths can be set with the `TAURI_FRONTEND_PATH` and the `TAURI_APP_PATH` environment variables respectively.
### Dependencies
- Upgraded to `tauri-cli@2.0.4`
## \[2.0.3] ## \[2.0.3]
### New Features ### New Features

View File

@ -1,6 +1,6 @@
{ {
"name": "@tauri-apps/cli", "name": "@tauri-apps/cli",
"version": "2.0.3", "version": "2.0.4",
"description": "Command line interface for building Tauri apps", "description": "Command line interface for building Tauri apps",
"funding": { "funding": {
"type": "opencollective", "type": "opencollective",