mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-02-06 13:37:09 +00:00
feat: disable background throttling (#12181)
Co-authored-by: Fabian-Lars <github@fabianlars.de>
This commit is contained in:
parent
5a3647bdfe
commit
a2d36b8c34
11
.changes/disable-background-throttling.md
Normal file
11
.changes/disable-background-throttling.md
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
'tauri-cli': 'minor:enhance'
|
||||
'tauri-runtime': 'minor:enhance'
|
||||
'tauri-runtime-wry': 'minor:enhance'
|
||||
'tauri-utils': 'minor:enhance'
|
||||
'tauri': 'minor:enhance'
|
||||
'@tauri-apps/api': 'minor:enhance'
|
||||
'@tauri-apps/cli': 'minor:enhance'
|
||||
---
|
||||
|
||||
Add an option to change the default background throttling policy (currently for WebKit only).
|
||||
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -11399,9 +11399,9 @@ checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
|
||||
|
||||
[[package]]
|
||||
name = "wry"
|
||||
version = "0.48.0"
|
||||
version = "0.48.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e644bf458e27b11b0ecafc9e5633d1304fdae82baca1d42185669752fe6ca4f"
|
||||
checksum = "a2e33c08b174442ff80d5c791020696f9f8b4e4a87b8cfc7494aad6167ec44e1"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"block2",
|
||||
|
||||
@ -516,6 +516,17 @@
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"backgroundThrottling": {
|
||||
"description": "Change the default background throttling behaviour.\n\n By default, browsers use a suspend policy that will throttle timers and even unload\n the whole tab (view) to free resources after roughly 5 minutes when a view became\n minimized or hidden. This will pause all tasks until the documents visibility state\n changes back from hidden to visible by bringing the view back to the foreground.\n\n ## Platform-specific\n\n - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice.\n - **iOS**: Supported since version 17.0+.\n - **macOS**: Supported since version 14.0+.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/BackgroundThrottlingPolicy"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
@ -948,6 +959,32 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"BackgroundThrottlingPolicy": {
|
||||
"description": "Background throttling policy.",
|
||||
"oneOf": [
|
||||
{
|
||||
"description": "A policy where background throttling is disabled",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"disabled"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "A policy where a web view that’s not in a window fully suspends tasks. This is usually the default behavior in case no policy is set.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"suspend"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "A policy where a web view that’s not in a window limits processing, but does not fully suspend tasks.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"throttle"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"SecurityConfig": {
|
||||
"description": "Security configuration.\n\n See more: <https://v2.tauri.app/reference/config/#securityconfig>",
|
||||
"type": "object",
|
||||
|
||||
@ -465,6 +465,15 @@
|
||||
"description": "Whether page zooming by hotkeys is enabled\n\n ## Platform-specific:\n\n - **Windows**: Controls WebView2's [`IsZoomControlEnabled`](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2settings?view=webview2-winrt-1.0.2420.47#iszoomcontrolenabled) setting.\n - **MacOS / Linux**: Injects a polyfill that zooms in and out with `ctrl/command` + `-/=`,\n 20% in each step, ranging from 20% to 1000%. Requires `webview:allow-set-webview-zoom` permission\n\n - **Android / iOS**: Unsupported.",
|
||||
"default": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
"backgroundThrottling": {
|
||||
"description": "Change the default background throttling behaviour.\n\n By default, browsers use a suspend policy that will throttle timers and even unload\n the whole tab (view) to free resources after roughly 5 minutes when a view became\n minimized or hidden. This will pause all tasks until the documents visibility state\n changes back from hidden to visible by bringing the view back to the foreground.\n\n ## Platform-specific\n\n - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice.\n - **iOS**: Supported since version 17.0+.\n - **macOS**: Supported since version 14.0+.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"disabled",
|
||||
"throttle",
|
||||
"suspend"
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
|
||||
@ -465,6 +465,15 @@
|
||||
"description": "Whether page zooming by hotkeys is enabled\n\n ## Platform-specific:\n\n - **Windows**: Controls WebView2's [`IsZoomControlEnabled`](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2settings?view=webview2-winrt-1.0.2420.47#iszoomcontrolenabled) setting.\n - **MacOS / Linux**: Injects a polyfill that zooms in and out with `ctrl/command` + `-/=`,\n 20% in each step, ranging from 20% to 1000%. Requires `webview:allow-set-webview-zoom` permission\n\n - **Android / iOS**: Unsupported.",
|
||||
"default": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
"backgroundThrottling": {
|
||||
"description": "Change the default background throttling behaviour.\n\n By default, browsers use a suspend policy that will throttle timers and even unload\n the whole tab (view) to free resources after roughly 5 minutes when a view became\n minimized or hidden. This will pause all tasks until the documents visibility state\n changes back from hidden to visible by bringing the view back to the foreground.\n\n ## Platform-specific\n\n - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice.\n - **iOS**: Supported since version 17.0+.\n - **macOS**: Supported since version 14.0+.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"disabled",
|
||||
"throttle",
|
||||
"suspend"
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
@ -2995,4 +3004,4 @@
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ rustc-args = ["--cfg", "docsrs"]
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[dependencies]
|
||||
wry = { version = "0.48", default-features = false, features = [
|
||||
wry = { version = "0.48.1", default-features = false, features = [
|
||||
"drag-drop",
|
||||
"protocol",
|
||||
"os-webview",
|
||||
|
||||
@ -4187,6 +4187,20 @@ fn create_webview<T: UserEvent>(
|
||||
webview_builder = webview_builder.with_https_scheme(webview_attributes.use_https_scheme);
|
||||
}
|
||||
|
||||
if let Some(background_throttling) = webview_attributes.background_throttling {
|
||||
webview_builder = webview_builder.with_background_throttling(match background_throttling {
|
||||
tauri_utils::config::BackgroundThrottlingPolicy::Disabled => {
|
||||
wry::BackgroundThrottlingPolicy::Disabled
|
||||
}
|
||||
tauri_utils::config::BackgroundThrottlingPolicy::Suspend => {
|
||||
wry::BackgroundThrottlingPolicy::Suspend
|
||||
}
|
||||
tauri_utils::config::BackgroundThrottlingPolicy::Throttle => {
|
||||
wry::BackgroundThrottlingPolicy::Throttle
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(color) = webview_attributes.background_color {
|
||||
webview_builder = webview_builder.with_background_color(color.into());
|
||||
}
|
||||
|
||||
@ -7,7 +7,9 @@
|
||||
use crate::{window::is_label_valid, Rect, Runtime, UserEvent};
|
||||
|
||||
use http::Request;
|
||||
use tauri_utils::config::{Color, WebviewUrl, WindowConfig, WindowEffectsConfig};
|
||||
use tauri_utils::config::{
|
||||
BackgroundThrottlingPolicy, Color, WebviewUrl, WindowConfig, WindowEffectsConfig,
|
||||
};
|
||||
use url::Url;
|
||||
|
||||
use std::{
|
||||
@ -215,6 +217,7 @@ pub struct WebviewAttributes {
|
||||
pub use_https_scheme: bool,
|
||||
pub devtools: Option<bool>,
|
||||
pub background_color: Option<Color>,
|
||||
pub background_throttling: Option<BackgroundThrottlingPolicy>,
|
||||
}
|
||||
|
||||
impl From<&WindowConfig> for WebviewAttributes {
|
||||
@ -225,7 +228,9 @@ impl From<&WindowConfig> for WebviewAttributes {
|
||||
.zoom_hotkeys_enabled(config.zoom_hotkeys_enabled)
|
||||
.use_https_scheme(config.use_https_scheme)
|
||||
.browser_extensions_enabled(config.browser_extensions_enabled)
|
||||
.background_throttling(config.background_throttling.clone())
|
||||
.devtools(config.devtools);
|
||||
|
||||
#[cfg(any(not(target_os = "macos"), feature = "macos-private-api"))]
|
||||
{
|
||||
builder = builder.transparent(config.transparent);
|
||||
@ -279,6 +284,7 @@ impl WebviewAttributes {
|
||||
use_https_scheme: false,
|
||||
devtools: None,
|
||||
background_color: None,
|
||||
background_throttling: None,
|
||||
}
|
||||
}
|
||||
|
||||
@ -444,6 +450,26 @@ impl WebviewAttributes {
|
||||
self.background_color = Some(color);
|
||||
self
|
||||
}
|
||||
|
||||
/// Change the default background throttling behaviour.
|
||||
///
|
||||
/// By default, browsers use a suspend policy that will throttle timers and even unload
|
||||
/// the whole tab (view) to free resources after roughly 5 minutes when a view became
|
||||
/// minimized or hidden. This will pause all tasks until the documents visibility state
|
||||
/// changes back from hidden to visible by bringing the view back to the foreground.
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice.
|
||||
/// - **iOS**: Supported since version 17.0+.
|
||||
/// - **macOS**: Supported since version 14.0+.
|
||||
///
|
||||
/// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578
|
||||
#[must_use]
|
||||
pub fn background_throttling(mut self, policy: Option<BackgroundThrottlingPolicy>) -> Self {
|
||||
self.background_throttling = policy;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// IPC handler.
|
||||
|
||||
@ -516,6 +516,17 @@
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"backgroundThrottling": {
|
||||
"description": "Change the default background throttling behaviour.\n\n By default, browsers use a suspend policy that will throttle timers and even unload\n the whole tab (view) to free resources after roughly 5 minutes when a view became\n minimized or hidden. This will pause all tasks until the documents visibility state\n changes back from hidden to visible by bringing the view back to the foreground.\n\n ## Platform-specific\n\n - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice.\n - **iOS**: Supported since version 17.0+.\n - **macOS**: Supported since version 14.0+.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/BackgroundThrottlingPolicy"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
@ -948,6 +959,32 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"BackgroundThrottlingPolicy": {
|
||||
"description": "Background throttling policy.",
|
||||
"oneOf": [
|
||||
{
|
||||
"description": "A policy where background throttling is disabled",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"disabled"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "A policy where a web view that’s not in a window fully suspends tasks. This is usually the default behavior in case no policy is set.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"suspend"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "A policy where a web view that’s not in a window limits processing, but does not fully suspend tasks.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"throttle"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"SecurityConfig": {
|
||||
"description": "Security configuration.\n\n See more: <https://v2.tauri.app/reference/config/#securityconfig>",
|
||||
"type": "object",
|
||||
|
||||
@ -1420,6 +1420,19 @@ impl schemars::JsonSchema for Color {
|
||||
}
|
||||
}
|
||||
|
||||
/// Background throttling policy.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub enum BackgroundThrottlingPolicy {
|
||||
/// A policy where background throttling is disabled
|
||||
Disabled,
|
||||
/// A policy where a web view that’s not in a window fully suspends tasks. This is usually the default behavior in case no policy is set.
|
||||
Suspend,
|
||||
/// A policy where a web view that’s not in a window limits processing, but does not fully suspend tasks.
|
||||
Throttle,
|
||||
}
|
||||
|
||||
/// The window effects configuration object
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize, Default)]
|
||||
@ -1687,6 +1700,23 @@ pub struct WindowConfig {
|
||||
/// - **Windows**: On Windows 8 and newer, if alpha channel is not `0`, it will be ignored for the webview layer.
|
||||
#[serde(alias = "background-color")]
|
||||
pub background_color: Option<Color>,
|
||||
|
||||
/// Change the default background throttling behaviour.
|
||||
///
|
||||
/// By default, browsers use a suspend policy that will throttle timers and even unload
|
||||
/// the whole tab (view) to free resources after roughly 5 minutes when a view became
|
||||
/// minimized or hidden. This will pause all tasks until the documents visibility state
|
||||
/// changes back from hidden to visible by bringing the view back to the foreground.
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice.
|
||||
/// - **iOS**: Supported since version 17.0+.
|
||||
/// - **macOS**: Supported since version 14.0+.
|
||||
///
|
||||
/// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578
|
||||
#[serde(default, alias = "background-throttling")]
|
||||
pub background_throttling: Option<BackgroundThrottlingPolicy>,
|
||||
}
|
||||
|
||||
impl Default for WindowConfig {
|
||||
@ -1739,6 +1769,7 @@ impl Default for WindowConfig {
|
||||
use_https_scheme: false,
|
||||
devtools: None,
|
||||
background_color: None,
|
||||
background_throttling: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2858,6 +2889,17 @@ mod build {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToTokens for BackgroundThrottlingPolicy {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let prefix = quote! { ::tauri::utils::config::BackgroundThrottlingPolicy };
|
||||
tokens.append_all(match self {
|
||||
Self::Disabled => quote! { #prefix::Disabled },
|
||||
Self::Throttle => quote! { #prefix::Throttle },
|
||||
Self::Suspend => quote! { #prefix::Suspend },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl ToTokens for crate::Theme {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let prefix = quote! { ::tauri::utils::Theme };
|
||||
@ -3004,6 +3046,7 @@ mod build {
|
||||
let use_https_scheme = self.use_https_scheme;
|
||||
let devtools = opt_lit(self.devtools.as_ref());
|
||||
let background_color = opt_lit(self.background_color.as_ref());
|
||||
let background_throttling = opt_lit(self.background_throttling.as_ref());
|
||||
|
||||
literal_struct!(
|
||||
tokens,
|
||||
@ -3054,7 +3097,8 @@ mod build {
|
||||
browser_extensions_enabled,
|
||||
use_https_scheme,
|
||||
devtools,
|
||||
background_color
|
||||
background_color,
|
||||
background_throttling
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -23,7 +23,7 @@ use tauri_runtime::{
|
||||
WebviewDispatch,
|
||||
};
|
||||
pub use tauri_utils::config::Color;
|
||||
use tauri_utils::config::{WebviewUrl, WindowConfig};
|
||||
use tauri_utils::config::{BackgroundThrottlingPolicy, WebviewUrl, WindowConfig};
|
||||
pub use url::Url;
|
||||
|
||||
use crate::{
|
||||
@ -867,6 +867,26 @@ fn main() {
|
||||
self.webview_attributes.background_color = Some(color);
|
||||
self
|
||||
}
|
||||
|
||||
/// Change the default background throttling behaviour.
|
||||
///
|
||||
/// By default, browsers use a suspend policy that will throttle timers and even unload
|
||||
/// the whole tab (view) to free resources after roughly 5 minutes when a view became
|
||||
/// minimized or hidden. This will pause all tasks until the documents visibility state
|
||||
/// changes back from hidden to visible by bringing the view back to the foreground.
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice.
|
||||
/// - **iOS**: Supported since version 17.0+.
|
||||
/// - **macOS**: Supported since version 14.0+.
|
||||
///
|
||||
/// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578
|
||||
#[must_use]
|
||||
pub fn background_throttling(mut self, policy: BackgroundThrottlingPolicy) -> Self {
|
||||
self.webview_attributes.background_throttling = Some(policy);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// Webview.
|
||||
|
||||
@ -14,7 +14,7 @@ mod desktop_commands {
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tauri_runtime::dpi::{Position, Size};
|
||||
use tauri_utils::config::{WebviewUrl, WindowConfig};
|
||||
use tauri_utils::config::{BackgroundThrottlingPolicy, WebviewUrl, WindowConfig};
|
||||
|
||||
use super::*;
|
||||
use crate::{
|
||||
@ -48,6 +48,8 @@ mod desktop_commands {
|
||||
incognito: bool,
|
||||
#[serde(default)]
|
||||
zoom_hotkeys_enabled: bool,
|
||||
#[serde(default)]
|
||||
background_throttling: Option<BackgroundThrottlingPolicy>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstable")]
|
||||
@ -63,6 +65,7 @@ mod desktop_commands {
|
||||
builder.webview_attributes.window_effects = config.window_effects;
|
||||
builder.webview_attributes.incognito = config.incognito;
|
||||
builder.webview_attributes.zoom_hotkeys_enabled = config.zoom_hotkeys_enabled;
|
||||
builder.webview_attributes.background_throttling = config.background_throttling;
|
||||
builder
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ use crate::{
|
||||
},
|
||||
};
|
||||
use tauri_utils::{
|
||||
config::{Color, WebviewUrl, WindowConfig},
|
||||
config::{BackgroundThrottlingPolicy, Color, WebviewUrl, WindowConfig},
|
||||
Theme,
|
||||
};
|
||||
use url::Url;
|
||||
@ -976,6 +976,26 @@ impl<R: Runtime, M: Manager<R>> WebviewWindowBuilder<'_, R, M> {
|
||||
self.webview_builder = self.webview_builder.background_color(color);
|
||||
self
|
||||
}
|
||||
|
||||
/// Change the default background throttling behaviour.
|
||||
///
|
||||
/// By default, browsers use a suspend policy that will throttle timers and even unload
|
||||
/// the whole tab (view) to free resources after roughly 5 minutes when a view became
|
||||
/// minimized or hidden. This will pause all tasks until the documents visibility state
|
||||
/// changes back from hidden to visible by bringing the view back to the foreground.
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice.
|
||||
/// - **iOS**: Supported since version 17.0+.
|
||||
/// - **macOS**: Supported since version 14.0+.
|
||||
///
|
||||
/// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578
|
||||
#[must_use]
|
||||
pub fn background_throttling(mut self, policy: BackgroundThrottlingPolicy) -> Self {
|
||||
self.webview_builder = self.webview_builder.background_throttling(policy);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// A type that wraps a [`Window`] together with a [`Webview`].
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
---
|
||||
source: crates/tests/acl/src/lib.rs
|
||||
expression: resolved
|
||||
snapshot_kind: text
|
||||
---
|
||||
Resolved {
|
||||
allowed_commands: {
|
||||
@ -29,7 +30,7 @@ Resolved {
|
||||
],
|
||||
webviews: [],
|
||||
scope_id: Some(
|
||||
3,
|
||||
4,
|
||||
),
|
||||
},
|
||||
],
|
||||
@ -85,7 +86,7 @@ Resolved {
|
||||
],
|
||||
webviews: [],
|
||||
scope_id: Some(
|
||||
2,
|
||||
3,
|
||||
),
|
||||
},
|
||||
ResolvedCommand {
|
||||
@ -111,9 +112,7 @@ Resolved {
|
||||
},
|
||||
],
|
||||
webviews: [],
|
||||
scope_id: Some(
|
||||
4,
|
||||
),
|
||||
scope_id: None,
|
||||
},
|
||||
ResolvedCommand {
|
||||
context: Local,
|
||||
@ -178,7 +177,7 @@ Resolved {
|
||||
],
|
||||
webviews: [],
|
||||
scope_id: Some(
|
||||
1,
|
||||
2,
|
||||
),
|
||||
},
|
||||
ResolvedCommand {
|
||||
@ -205,7 +204,7 @@ Resolved {
|
||||
],
|
||||
webviews: [],
|
||||
scope_id: Some(
|
||||
2,
|
||||
3,
|
||||
),
|
||||
},
|
||||
ResolvedCommand {
|
||||
@ -262,6 +261,18 @@ Resolved {
|
||||
deny: [],
|
||||
},
|
||||
2: ResolvedScope {
|
||||
allow: [
|
||||
Map(
|
||||
{
|
||||
"path": String(
|
||||
"$CONFIG/*",
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
deny: [],
|
||||
},
|
||||
3: ResolvedScope {
|
||||
allow: [
|
||||
Map(
|
||||
{
|
||||
@ -280,31 +291,12 @@ Resolved {
|
||||
],
|
||||
deny: [],
|
||||
},
|
||||
3: ResolvedScope {
|
||||
allow: [
|
||||
Map(
|
||||
{
|
||||
"path": String(
|
||||
"$TEMP/*",
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
deny: [],
|
||||
},
|
||||
4: ResolvedScope {
|
||||
allow: [
|
||||
Map(
|
||||
{
|
||||
"path": String(
|
||||
"$DOWNLOAD",
|
||||
),
|
||||
},
|
||||
),
|
||||
Map(
|
||||
{
|
||||
"path": String(
|
||||
"$DOWNLOAD/**",
|
||||
"$TEMP/*",
|
||||
),
|
||||
},
|
||||
),
|
||||
@ -322,6 +314,20 @@ Resolved {
|
||||
),
|
||||
},
|
||||
),
|
||||
Map(
|
||||
{
|
||||
"path": String(
|
||||
"$DOWNLOAD",
|
||||
),
|
||||
},
|
||||
),
|
||||
Map(
|
||||
{
|
||||
"path": String(
|
||||
"$DOWNLOAD/**",
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
deny: [
|
||||
Map(
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
---
|
||||
source: crates/tests/acl/src/lib.rs
|
||||
expression: resolved
|
||||
snapshot_kind: text
|
||||
---
|
||||
Resolved {
|
||||
allowed_commands: {
|
||||
@ -29,7 +30,7 @@ Resolved {
|
||||
],
|
||||
webviews: [],
|
||||
scope_id: Some(
|
||||
3,
|
||||
4,
|
||||
),
|
||||
},
|
||||
],
|
||||
@ -85,7 +86,7 @@ Resolved {
|
||||
],
|
||||
webviews: [],
|
||||
scope_id: Some(
|
||||
2,
|
||||
3,
|
||||
),
|
||||
},
|
||||
ResolvedCommand {
|
||||
@ -111,9 +112,7 @@ Resolved {
|
||||
},
|
||||
],
|
||||
webviews: [],
|
||||
scope_id: Some(
|
||||
4,
|
||||
),
|
||||
scope_id: None,
|
||||
},
|
||||
],
|
||||
"plugin:fs|read_file": [
|
||||
@ -141,7 +140,7 @@ Resolved {
|
||||
],
|
||||
webviews: [],
|
||||
scope_id: Some(
|
||||
1,
|
||||
2,
|
||||
),
|
||||
},
|
||||
ResolvedCommand {
|
||||
@ -168,7 +167,7 @@ Resolved {
|
||||
],
|
||||
webviews: [],
|
||||
scope_id: Some(
|
||||
2,
|
||||
3,
|
||||
),
|
||||
},
|
||||
],
|
||||
@ -188,6 +187,18 @@ Resolved {
|
||||
deny: [],
|
||||
},
|
||||
2: ResolvedScope {
|
||||
allow: [
|
||||
Map(
|
||||
{
|
||||
"path": String(
|
||||
"$HOME/.config/**",
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
deny: [],
|
||||
},
|
||||
3: ResolvedScope {
|
||||
allow: [
|
||||
Map(
|
||||
{
|
||||
@ -214,31 +225,12 @@ Resolved {
|
||||
),
|
||||
],
|
||||
},
|
||||
3: ResolvedScope {
|
||||
allow: [
|
||||
Map(
|
||||
{
|
||||
"path": String(
|
||||
"$TEMP/*",
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
deny: [],
|
||||
},
|
||||
4: ResolvedScope {
|
||||
allow: [
|
||||
Map(
|
||||
{
|
||||
"path": String(
|
||||
"$DOWNLOAD",
|
||||
),
|
||||
},
|
||||
),
|
||||
Map(
|
||||
{
|
||||
"path": String(
|
||||
"$DOWNLOAD/**",
|
||||
"$TEMP/*",
|
||||
),
|
||||
},
|
||||
),
|
||||
@ -263,6 +255,20 @@ Resolved {
|
||||
),
|
||||
},
|
||||
),
|
||||
Map(
|
||||
{
|
||||
"path": String(
|
||||
"$DOWNLOAD",
|
||||
),
|
||||
},
|
||||
),
|
||||
Map(
|
||||
{
|
||||
"path": String(
|
||||
"$DOWNLOAD/**",
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
deny: [
|
||||
Map(
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
---
|
||||
source: crates/tests/acl/src/lib.rs
|
||||
expression: resolved
|
||||
snapshot_kind: text
|
||||
---
|
||||
Resolved {
|
||||
allowed_commands: {
|
||||
@ -109,9 +110,7 @@ Resolved {
|
||||
},
|
||||
],
|
||||
webviews: [],
|
||||
scope_id: Some(
|
||||
3,
|
||||
),
|
||||
scope_id: None,
|
||||
},
|
||||
],
|
||||
"plugin:fs|read_file": [
|
||||
@ -202,8 +201,17 @@ Resolved {
|
||||
],
|
||||
deny: [],
|
||||
},
|
||||
3: ResolvedScope {
|
||||
},
|
||||
global_scope: {
|
||||
"fs": ResolvedScope {
|
||||
allow: [
|
||||
Map(
|
||||
{
|
||||
"path": String(
|
||||
"$APP",
|
||||
),
|
||||
},
|
||||
),
|
||||
Map(
|
||||
{
|
||||
"path": String(
|
||||
@ -219,20 +227,6 @@ Resolved {
|
||||
},
|
||||
),
|
||||
],
|
||||
deny: [],
|
||||
},
|
||||
},
|
||||
global_scope: {
|
||||
"fs": ResolvedScope {
|
||||
allow: [
|
||||
Map(
|
||||
{
|
||||
"path": String(
|
||||
"$APP",
|
||||
),
|
||||
},
|
||||
),
|
||||
],
|
||||
deny: [
|
||||
Map(
|
||||
{
|
||||
|
||||
@ -30,7 +30,12 @@ import {
|
||||
once
|
||||
} from './event'
|
||||
import { invoke } from './core'
|
||||
import { Color, Window, getCurrentWindow } from './window'
|
||||
import {
|
||||
BackgroundThrottlingPolicy,
|
||||
Color,
|
||||
Window,
|
||||
getCurrentWindow
|
||||
} from './window'
|
||||
import { WebviewWindow } from './webviewWindow'
|
||||
|
||||
/** The drag and drop event types. */
|
||||
@ -767,6 +772,25 @@ interface WebviewOptions {
|
||||
* @since 2.1.0
|
||||
*/
|
||||
backgroundColor?: Color
|
||||
|
||||
/** Change the default background throttling behaviour.
|
||||
*
|
||||
* By default, browsers use a suspend policy that will throttle timers and even unload
|
||||
* the whole tab (view) to free resources after roughly 5 minutes when a view became
|
||||
* minimized or hidden. This will pause all tasks until the documents visibility state
|
||||
* changes back from hidden to visible by bringing the view back to the foreground.
|
||||
*
|
||||
* ## Platform-specific
|
||||
*
|
||||
* - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice.
|
||||
* - **iOS**: Supported since version 17.0+.
|
||||
* - **macOS**: Supported since version 14.0+.
|
||||
*
|
||||
* see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
backgroundThrottling?: BackgroundThrottlingPolicy
|
||||
}
|
||||
|
||||
export { Webview, getCurrentWebview, getAllWebviews }
|
||||
|
||||
@ -2021,6 +2021,17 @@ type Color =
|
||||
| { red: number; green: number; blue: number; alpha: number }
|
||||
| string
|
||||
|
||||
/**
|
||||
* Background throttling policy
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
enum BackgroundThrottlingPolicy {
|
||||
Disabled = 'disabled',
|
||||
Throttle = 'throttle',
|
||||
Suspend = 'suspend'
|
||||
}
|
||||
|
||||
/**
|
||||
* Platform-specific window effects
|
||||
*
|
||||
@ -2338,6 +2349,20 @@ interface WindowOptions {
|
||||
* @since 2.1.0
|
||||
*/
|
||||
backgroundColor?: Color
|
||||
|
||||
/** Change the default background throttling behaviour.
|
||||
*
|
||||
* ## Platform-specific
|
||||
*
|
||||
* - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice.
|
||||
* - **iOS**: Supported since version 17.0+.
|
||||
* - **macOS**: Supported since version 14.0+.
|
||||
*
|
||||
* see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
backgroundThrottling?: BackgroundThrottlingPolicy
|
||||
}
|
||||
|
||||
function mapMonitor(m: Monitor | null): Monitor | null {
|
||||
@ -2460,5 +2485,6 @@ export type {
|
||||
ScaleFactorChanged,
|
||||
WindowOptions,
|
||||
Color,
|
||||
BackgroundThrottlingPolicy,
|
||||
DragDropEvent
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user