From 6f1b8a2e9f04cac9925623273a1d426f57f2ad1c Mon Sep 17 00:00:00 2001 From: Bastian Kistner Date: Sat, 4 Jan 2025 00:09:34 +0100 Subject: [PATCH 1/9] feat: disable background throttling --- crates/tauri-cli/config.schema.json | 5 +++ crates/tauri-cli/schema.json | 5 +++ crates/tauri-cli/tauri.config.schema.json | 5 +++ crates/tauri-runtime-wry/src/lib.rs | 1 + crates/tauri-runtime/src/webview.rs | 21 ++++++++++++ .../schemas/config.schema.json | 5 +++ crates/tauri-utils/src/config.rs | 19 ++++++++++- crates/tauri/src/webview/mod.rs | 17 ++++++++++ crates/tauri/src/webview/plugin.rs | 4 +++ crates/tauri/src/webview/webview_window.rs | 17 ++++++++++ packages/api/src/webview.ts | 17 ++++++++++ packages/api/src/window.ts | 33 +++++++++++++++++++ 12 files changed, 148 insertions(+), 1 deletion(-) diff --git a/crates/tauri-cli/config.schema.json b/crates/tauri-cli/config.schema.json index 3229931cf177..dada7706514f 100644 --- a/crates/tauri-cli/config.schema.json +++ b/crates/tauri-cli/config.schema.json @@ -516,6 +516,11 @@ "type": "null" } ] + }, + "disableBackgroundThrottling": { + "description": "Set whether background throttling should be disabled.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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 yet. But workarounds like a pending WebLock transaction might suffice.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578", + "default": false, + "type": "boolean" } }, "additionalProperties": false diff --git a/crates/tauri-cli/schema.json b/crates/tauri-cli/schema.json index 613287fc78f8..d5abdc0fe566 100644 --- a/crates/tauri-cli/schema.json +++ b/crates/tauri-cli/schema.json @@ -465,6 +465,11 @@ "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" + }, + "disableBackgroundThrottling": { + "description": "Set whether background throttling should be disabled\n\n Will prevent the browser from suspending the WebView's tab and all its tasks while running in background after ~5 Minutes.\n\n ## Platform-specific\n\n - **Linux / Windows / Android**: Unsupported yet. But workarounds like a pending WebLock transaction might suffice.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578", + "default": false, + "type": "boolean" } }, "additionalProperties": false diff --git a/crates/tauri-cli/tauri.config.schema.json b/crates/tauri-cli/tauri.config.schema.json index 9d28874da38b..44e87ff8ed6e 100644 --- a/crates/tauri-cli/tauri.config.schema.json +++ b/crates/tauri-cli/tauri.config.schema.json @@ -465,6 +465,11 @@ "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" + }, + "disableBackgroundThrottling": { + "description": "Set whether background throttling should be disabled\n\n Will prevent the browser from suspending the WebView's tab and all its tasks while running in background after ~5 Minutes.\n\n ## Platform-specific\n\n - **Linux / Windows / Android**: Unsupported yet. But workarounds like a pending WebLock transaction might suffice.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578", + "default": false, + "type": "boolean" } }, "additionalProperties": false diff --git a/crates/tauri-runtime-wry/src/lib.rs b/crates/tauri-runtime-wry/src/lib.rs index 82d636dd2d37..c7e2eb602024 100644 --- a/crates/tauri-runtime-wry/src/lib.rs +++ b/crates/tauri-runtime-wry/src/lib.rs @@ -4180,6 +4180,7 @@ fn create_webview( .with_accept_first_mouse(webview_attributes.accept_first_mouse) .with_incognito(webview_attributes.incognito) .with_clipboard(webview_attributes.clipboard) + .with_disable_background_throttling(webview_attributes.disable_background_throttling) .with_hotkeys_zoom(webview_attributes.zoom_hotkeys_enabled); #[cfg(any(target_os = "windows", target_os = "android"))] diff --git a/crates/tauri-runtime/src/webview.rs b/crates/tauri-runtime/src/webview.rs index f317a5857638..17dfb6137e9a 100644 --- a/crates/tauri-runtime/src/webview.rs +++ b/crates/tauri-runtime/src/webview.rs @@ -215,6 +215,7 @@ pub struct WebviewAttributes { pub use_https_scheme: bool, pub devtools: Option, pub background_color: Option, + pub disable_background_throttling: bool, } impl From<&WindowConfig> for WebviewAttributes { @@ -225,7 +226,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) + .disable_background_throttling(config.disable_background_throttling) .devtools(config.devtools); + #[cfg(any(not(target_os = "macos"), feature = "macos-private-api"))] { builder = builder.transparent(config.transparent); @@ -279,6 +282,7 @@ impl WebviewAttributes { use_https_scheme: false, devtools: None, background_color: None, + disable_background_throttling: false, } } @@ -444,6 +448,23 @@ impl WebviewAttributes { self.background_color = Some(color); self } + + /// Set whether background throttling should be disabled. + /// + /// By default, browsers 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 permanently suspend 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 yet. But workarounds like a pending WebLock transaction might suffice. + /// + /// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 + #[must_use] + pub fn disable_background_throttling(mut self, disable: bool) -> Self { + self.disable_background_throttling = disable; + self + } } /// IPC handler. diff --git a/crates/tauri-schema-generator/schemas/config.schema.json b/crates/tauri-schema-generator/schemas/config.schema.json index 3229931cf177..dada7706514f 100644 --- a/crates/tauri-schema-generator/schemas/config.schema.json +++ b/crates/tauri-schema-generator/schemas/config.schema.json @@ -516,6 +516,11 @@ "type": "null" } ] + }, + "disableBackgroundThrottling": { + "description": "Set whether background throttling should be disabled.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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 yet. But workarounds like a pending WebLock transaction might suffice.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578", + "default": false, + "type": "boolean" } }, "additionalProperties": false diff --git a/crates/tauri-utils/src/config.rs b/crates/tauri-utils/src/config.rs index 3877fefeb305..2fea79448f23 100644 --- a/crates/tauri-utils/src/config.rs +++ b/crates/tauri-utils/src/config.rs @@ -1687,6 +1687,20 @@ 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, + + /// Set whether background throttling should be disabled. + /// + /// By default, browsers 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 permanently suspend 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 yet. But workarounds like a pending WebLock transaction might suffice. + /// + /// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 + #[serde(default, alias = "disable-background-throttling")] + pub disable_background_throttling: bool, } impl Default for WindowConfig { @@ -1739,6 +1753,7 @@ impl Default for WindowConfig { use_https_scheme: false, devtools: None, background_color: None, + disable_background_throttling: false, } } } @@ -3004,6 +3019,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 disable_background_throttling = self.disable_background_throttling; literal_struct!( tokens, @@ -3054,7 +3070,8 @@ mod build { browser_extensions_enabled, use_https_scheme, devtools, - background_color + background_color, + disable_background_throttling ); } } diff --git a/crates/tauri/src/webview/mod.rs b/crates/tauri/src/webview/mod.rs index cd27e2eb259a..e2475fa4d210 100644 --- a/crates/tauri/src/webview/mod.rs +++ b/crates/tauri/src/webview/mod.rs @@ -867,6 +867,23 @@ fn main() { self.webview_attributes.background_color = Some(color); self } + + /// Set whether background throttling should be disabled. + /// + /// By default, browsers 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 permanently suspend 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 yet. But workarounds like a pending WebLock transaction might suffice. + /// + /// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 + #[must_use] + pub fn disable_background_throttling(mut self, disabled: bool) -> Self { + self.webview_attributes.disable_background_throttling = disabled; + self + } } /// Webview. diff --git a/crates/tauri/src/webview/plugin.rs b/crates/tauri/src/webview/plugin.rs index aa92050e361f..29df19843384 100644 --- a/crates/tauri/src/webview/plugin.rs +++ b/crates/tauri/src/webview/plugin.rs @@ -48,6 +48,8 @@ mod desktop_commands { incognito: bool, #[serde(default)] zoom_hotkeys_enabled: bool, + #[serde(default)] + disable_background_throttling: bool, } #[cfg(feature = "unstable")] @@ -63,6 +65,8 @@ 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.disable_background_throttling = + config.disable_background_throttling; builder } } diff --git a/crates/tauri/src/webview/webview_window.rs b/crates/tauri/src/webview/webview_window.rs index 901ffb1d9a47..f8120bf15dbe 100644 --- a/crates/tauri/src/webview/webview_window.rs +++ b/crates/tauri/src/webview/webview_window.rs @@ -977,6 +977,23 @@ impl> WebviewWindowBuilder<'_, R, M> { self.webview_builder = self.webview_builder.background_color(color); self } + + /// Set whether background throttling should be disabled. + /// + /// By default, browsers 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 permanently suspend 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 yet. But workarounds like a pending WebLock transaction might suffice. + /// + /// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 + #[must_use] + pub fn disable_background_throttling(mut self, disabled: bool) -> Self { + self.webview_builder = self.webview_builder.disable_background_throttling(disabled); + self + } } /// A type that wraps a [`Window`] together with a [`Webview`]. diff --git a/packages/api/src/webview.ts b/packages/api/src/webview.ts index ed2948da2854..789d15810d26 100644 --- a/packages/api/src/webview.ts +++ b/packages/api/src/webview.ts @@ -767,6 +767,23 @@ interface WebviewOptions { * @since 2.1.0 */ backgroundColor?: Color + + /** Set whether background throttling should be disabled. + * + * By default, browsers 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 permanently suspend 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 yet. But workarounds like a pending WebLock transaction might suffice. + * + * see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 + * + * @since 2.2.0 + * + */ + disableBackgroundThrottling?: boolean } export { Webview, getCurrentWebview, getAllWebviews } diff --git a/packages/api/src/window.ts b/packages/api/src/window.ts index 2283be585d3d..282efa56c4dd 100644 --- a/packages/api/src/window.ts +++ b/packages/api/src/window.ts @@ -1533,6 +1533,28 @@ class Window { return invoke('plugin:window|set_background_color', { color }) } + /** Set whether background throttling should be disabled. + * + * By default, browsers 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 permanently suspend 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 yet. But workarounds like a pending WebLock transaction might suffice. + * + * see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 + * + * @since 2.2.0 + * + */ + async setDisableBackgroundThrottling(disable: boolean): Promise { + return invoke('plugin:window|set_disable_background_throttling', { + label: this.label, + value: disable + }) + } + /** * Changes the position of the cursor in window coordinates. * @example @@ -2338,6 +2360,17 @@ interface WindowOptions { * @since 2.1.0 */ backgroundColor?: Color + /** + * Set whether background throttling should be disabled + * + * #### Platform-specific + * - **Linux / Windows / Android**: Unsupported yet. But workarounds like a pending WebLock transaction might suffice. + * + * see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 + * + * @since 2.2.0 + */ + disableBackgroundThrottling?: boolean } function mapMonitor(m: Monitor | null): Monitor | null { From ad7d78593d382e48c1db747f6c8e2fdc6c97f348 Mon Sep 17 00:00:00 2001 From: Bastian Kistner Date: Sat, 4 Jan 2025 00:29:49 +0100 Subject: [PATCH 2/9] fix: snapshot tests --- .../snapshots/acl_tests__tests__scope.snap | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/crates/tests/acl/fixtures/snapshots/acl_tests__tests__scope.snap b/crates/tests/acl/fixtures/snapshots/acl_tests__tests__scope.snap index c38697f41c2b..d049085d8c4e 100644 --- a/crates/tests/acl/fixtures/snapshots/acl_tests__tests__scope.snap +++ b/crates/tests/acl/fixtures/snapshots/acl_tests__tests__scope.snap @@ -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,33 +201,28 @@ Resolved { ], deny: [], }, - 3: ResolvedScope { + }, + global_scope: { + "fs": ResolvedScope { allow: [ Map( { "path": String( - "$DOWNLOAD", + "$APP", ), }, ), Map( { "path": String( - "$DOWNLOAD/**", + "$DOWNLOAD", ), }, ), - ], - deny: [], - }, - }, - global_scope: { - "fs": ResolvedScope { - allow: [ Map( { "path": String( - "$APP", + "$DOWNLOAD/**", ), }, ), From 1db8caeaec4ab890cd93423a59874a8b485d9ab0 Mon Sep 17 00:00:00 2001 From: Bastian Kistner Date: Sat, 4 Jan 2025 00:32:05 +0100 Subject: [PATCH 3/9] chore: changes file --- .changes/disable-background-throttling.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .changes/disable-background-throttling.md diff --git a/.changes/disable-background-throttling.md b/.changes/disable-background-throttling.md new file mode 100644 index 000000000000..694da993e124 --- /dev/null +++ b/.changes/disable-background-throttling.md @@ -0,0 +1,11 @@ +--- +'tauri-cli': 'minor' +'tauri-runtime': 'minor' +'tauri-runtime-wry': 'minor' +'tauri-schema-generator': 'minor' +'tauri-utils': 'minor' +'tauri': 'minor' +'@tauri-apps/api': 'minor' +--- + +Add an option to disable background throttling (currently for WebKit only). \ No newline at end of file From fd44a00714dd36b3f7867ddca80377df0cfc8d09 Mon Sep 17 00:00:00 2001 From: Bastian Kistner Date: Mon, 6 Jan 2025 23:34:31 +0100 Subject: [PATCH 4/9] Update .changes/disable-background-throttling.md Co-authored-by: Fabian-Lars --- .changes/disable-background-throttling.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.changes/disable-background-throttling.md b/.changes/disable-background-throttling.md index 694da993e124..96fe0de6a4b5 100644 --- a/.changes/disable-background-throttling.md +++ b/.changes/disable-background-throttling.md @@ -1,11 +1,11 @@ --- -'tauri-cli': 'minor' -'tauri-runtime': 'minor' -'tauri-runtime-wry': 'minor' -'tauri-schema-generator': 'minor' -'tauri-utils': 'minor' -'tauri': 'minor' -'@tauri-apps/api': 'minor' +'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 disable background throttling (currently for WebKit only). \ No newline at end of file From e4eb0094c92b49e7025e3145a43ffecbd1a287d1 Mon Sep 17 00:00:00 2001 From: Bastian Kistner Date: Tue, 7 Jan 2025 12:20:46 +0100 Subject: [PATCH 5/9] chore: comments --- crates/tauri-cli/config.schema.json | 2 +- crates/tauri-cli/schema.json | 2 +- crates/tauri-cli/tauri.config.schema.json | 2 +- crates/tauri-runtime/src/webview.rs | 3 ++- crates/tauri-schema-generator/schemas/config.schema.json | 2 +- crates/tauri-utils/src/config.rs | 3 ++- crates/tauri/src/webview/mod.rs | 3 ++- crates/tauri/src/webview/webview_window.rs | 3 ++- packages/api/src/webview.ts | 3 ++- packages/api/src/window.ts | 7 +++++-- 10 files changed, 19 insertions(+), 11 deletions(-) diff --git a/crates/tauri-cli/config.schema.json b/crates/tauri-cli/config.schema.json index dada7706514f..b425dec1cbe1 100644 --- a/crates/tauri-cli/config.schema.json +++ b/crates/tauri-cli/config.schema.json @@ -518,7 +518,7 @@ ] }, "disableBackgroundThrottling": { - "description": "Set whether background throttling should be disabled.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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 yet. But workarounds like a pending WebLock transaction might suffice.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578", + "description": "Set whether background throttling should be disabled.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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 / macOS**: Supported since version 17.0+.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578", "default": false, "type": "boolean" } diff --git a/crates/tauri-cli/schema.json b/crates/tauri-cli/schema.json index d5abdc0fe566..25e6529ae22b 100644 --- a/crates/tauri-cli/schema.json +++ b/crates/tauri-cli/schema.json @@ -467,7 +467,7 @@ "type": "boolean" }, "disableBackgroundThrottling": { - "description": "Set whether background throttling should be disabled\n\n Will prevent the browser from suspending the WebView's tab and all its tasks while running in background after ~5 Minutes.\n\n ## Platform-specific\n\n - **Linux / Windows / Android**: Unsupported yet. But workarounds like a pending WebLock transaction might suffice.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578", + "description": "Set whether background throttling should be disabled\n\n Will prevent the browser from suspending the WebView's tab and all its tasks while running in background after ~5 Minutes.\n\n ## Platform-specific\n\n - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice.\n - **iOS / macOS**: Supported since version 17.0+.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578", "default": false, "type": "boolean" } diff --git a/crates/tauri-cli/tauri.config.schema.json b/crates/tauri-cli/tauri.config.schema.json index 44e87ff8ed6e..2ac513bd93f3 100644 --- a/crates/tauri-cli/tauri.config.schema.json +++ b/crates/tauri-cli/tauri.config.schema.json @@ -467,7 +467,7 @@ "type": "boolean" }, "disableBackgroundThrottling": { - "description": "Set whether background throttling should be disabled\n\n Will prevent the browser from suspending the WebView's tab and all its tasks while running in background after ~5 Minutes.\n\n ## Platform-specific\n\n - **Linux / Windows / Android**: Unsupported yet. But workarounds like a pending WebLock transaction might suffice.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578", + "description": "Set whether background throttling should be disabled\n\n Will prevent the browser from suspending the WebView's tab and all its tasks while running in background after ~5 Minutes.\n\n ## Platform-specific\n\n - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice.\n - **iOS / macOS**: Supported since version 17.0+.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578", "default": false, "type": "boolean" } diff --git a/crates/tauri-runtime/src/webview.rs b/crates/tauri-runtime/src/webview.rs index 17dfb6137e9a..c6465bccec5b 100644 --- a/crates/tauri-runtime/src/webview.rs +++ b/crates/tauri-runtime/src/webview.rs @@ -457,7 +457,8 @@ impl WebviewAttributes { /// /// ## Platform-specific /// - /// - **Linux / Windows / Android**: Unsupported yet. But workarounds like a pending WebLock transaction might suffice. + /// - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice. + /// - **iOS / macOS**: Supported since version 17.0+. /// /// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 #[must_use] diff --git a/crates/tauri-schema-generator/schemas/config.schema.json b/crates/tauri-schema-generator/schemas/config.schema.json index dada7706514f..b425dec1cbe1 100644 --- a/crates/tauri-schema-generator/schemas/config.schema.json +++ b/crates/tauri-schema-generator/schemas/config.schema.json @@ -518,7 +518,7 @@ ] }, "disableBackgroundThrottling": { - "description": "Set whether background throttling should be disabled.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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 yet. But workarounds like a pending WebLock transaction might suffice.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578", + "description": "Set whether background throttling should be disabled.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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 / macOS**: Supported since version 17.0+.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578", "default": false, "type": "boolean" } diff --git a/crates/tauri-utils/src/config.rs b/crates/tauri-utils/src/config.rs index 2fea79448f23..71c338a01847 100644 --- a/crates/tauri-utils/src/config.rs +++ b/crates/tauri-utils/src/config.rs @@ -1696,7 +1696,8 @@ pub struct WindowConfig { /// /// ## Platform-specific /// - /// - **Linux / Windows / Android**: Unsupported yet. But workarounds like a pending WebLock transaction might suffice. + /// - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice. + /// - **iOS / macOS**: Supported since version 17.0+. /// /// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 #[serde(default, alias = "disable-background-throttling")] diff --git a/crates/tauri/src/webview/mod.rs b/crates/tauri/src/webview/mod.rs index e2475fa4d210..0dd1341f419d 100644 --- a/crates/tauri/src/webview/mod.rs +++ b/crates/tauri/src/webview/mod.rs @@ -876,7 +876,8 @@ fn main() { /// /// ## Platform-specific /// - /// - **Linux / Windows / Android**: Unsupported yet. But workarounds like a pending WebLock transaction might suffice. + /// - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice. + /// - **iOS / macOS**: Supported since version 17.0+. /// /// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 #[must_use] diff --git a/crates/tauri/src/webview/webview_window.rs b/crates/tauri/src/webview/webview_window.rs index f8120bf15dbe..05f88da1d6c9 100644 --- a/crates/tauri/src/webview/webview_window.rs +++ b/crates/tauri/src/webview/webview_window.rs @@ -986,7 +986,8 @@ impl> WebviewWindowBuilder<'_, R, M> { /// /// ## Platform-specific /// - /// - **Linux / Windows / Android**: Unsupported yet. But workarounds like a pending WebLock transaction might suffice. + /// - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice. + /// - **iOS / macOS**: Supported since version 17.0+. /// /// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 #[must_use] diff --git a/packages/api/src/webview.ts b/packages/api/src/webview.ts index 789d15810d26..1cfa67f4764d 100644 --- a/packages/api/src/webview.ts +++ b/packages/api/src/webview.ts @@ -776,7 +776,8 @@ interface WebviewOptions { * ## Platform-specific * - * - **Linux / Windows / Android**: Unsupported yet. But workarounds like a pending WebLock transaction might suffice. + * - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice. + * - **iOS / macOS**: Supported since version 17.0+. * * see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 * diff --git a/packages/api/src/window.ts b/packages/api/src/window.ts index 282efa56c4dd..03302c2a22fb 100644 --- a/packages/api/src/window.ts +++ b/packages/api/src/window.ts @@ -1541,7 +1541,8 @@ class Window { * ## Platform-specific * - * - **Linux / Windows / Android**: Unsupported yet. But workarounds like a pending WebLock transaction might suffice. + * - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice. + * - **iOS / macOS**: Supported since version 17.0+. * * see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 * @@ -2364,7 +2365,9 @@ interface WindowOptions { * Set whether background throttling should be disabled * * #### Platform-specific - * - **Linux / Windows / Android**: Unsupported yet. But workarounds like a pending WebLock transaction might suffice. + * + * - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice. + * - **iOS / macOS**: Supported since version 17.0+. * * see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 * From 4f0327011918069175f44b9591d5bcbde9277692 Mon Sep 17 00:00:00 2001 From: Bastian Kistner Date: Tue, 7 Jan 2025 16:40:02 +0100 Subject: [PATCH 6/9] chore: comments --- crates/tauri-cli/config.schema.json | 2 +- crates/tauri-cli/schema.json | 2 +- crates/tauri-cli/tauri.config.schema.json | 2 +- crates/tauri-runtime/src/webview.rs | 3 ++- crates/tauri-schema-generator/schemas/config.schema.json | 2 +- crates/tauri-utils/src/config.rs | 3 ++- crates/tauri/src/webview/mod.rs | 3 ++- crates/tauri/src/webview/webview_window.rs | 3 ++- packages/api/src/webview.ts | 3 ++- packages/api/src/window.ts | 6 ++++-- 10 files changed, 18 insertions(+), 11 deletions(-) diff --git a/crates/tauri-cli/config.schema.json b/crates/tauri-cli/config.schema.json index b425dec1cbe1..bdc4e103ed80 100644 --- a/crates/tauri-cli/config.schema.json +++ b/crates/tauri-cli/config.schema.json @@ -518,7 +518,7 @@ ] }, "disableBackgroundThrottling": { - "description": "Set whether background throttling should be disabled.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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 / macOS**: Supported since version 17.0+.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578", + "description": "Set whether background throttling should be disabled.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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", "default": false, "type": "boolean" } diff --git a/crates/tauri-cli/schema.json b/crates/tauri-cli/schema.json index 25e6529ae22b..30596f3cca1a 100644 --- a/crates/tauri-cli/schema.json +++ b/crates/tauri-cli/schema.json @@ -467,7 +467,7 @@ "type": "boolean" }, "disableBackgroundThrottling": { - "description": "Set whether background throttling should be disabled\n\n Will prevent the browser from suspending the WebView's tab and all its tasks while running in background after ~5 Minutes.\n\n ## Platform-specific\n\n - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice.\n - **iOS / macOS**: Supported since version 17.0+.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578", + "description": "Set whether background throttling should be disabled.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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", "default": false, "type": "boolean" } diff --git a/crates/tauri-cli/tauri.config.schema.json b/crates/tauri-cli/tauri.config.schema.json index 2ac513bd93f3..04ea6dd9e95c 100644 --- a/crates/tauri-cli/tauri.config.schema.json +++ b/crates/tauri-cli/tauri.config.schema.json @@ -467,7 +467,7 @@ "type": "boolean" }, "disableBackgroundThrottling": { - "description": "Set whether background throttling should be disabled\n\n Will prevent the browser from suspending the WebView's tab and all its tasks while running in background after ~5 Minutes.\n\n ## Platform-specific\n\n - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice.\n - **iOS / macOS**: Supported since version 17.0+.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578", + "description": "Set whether background throttling should be disabled.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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", "default": false, "type": "boolean" } diff --git a/crates/tauri-runtime/src/webview.rs b/crates/tauri-runtime/src/webview.rs index c6465bccec5b..8da93d17a4c1 100644 --- a/crates/tauri-runtime/src/webview.rs +++ b/crates/tauri-runtime/src/webview.rs @@ -458,7 +458,8 @@ impl WebviewAttributes { /// ## Platform-specific /// /// - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice. - /// - **iOS / macOS**: Supported since version 17.0+. + /// - **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] diff --git a/crates/tauri-schema-generator/schemas/config.schema.json b/crates/tauri-schema-generator/schemas/config.schema.json index b425dec1cbe1..bdc4e103ed80 100644 --- a/crates/tauri-schema-generator/schemas/config.schema.json +++ b/crates/tauri-schema-generator/schemas/config.schema.json @@ -518,7 +518,7 @@ ] }, "disableBackgroundThrottling": { - "description": "Set whether background throttling should be disabled.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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 / macOS**: Supported since version 17.0+.\n\n see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578", + "description": "Set whether background throttling should be disabled.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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", "default": false, "type": "boolean" } diff --git a/crates/tauri-utils/src/config.rs b/crates/tauri-utils/src/config.rs index 71c338a01847..4fd8ec819cb5 100644 --- a/crates/tauri-utils/src/config.rs +++ b/crates/tauri-utils/src/config.rs @@ -1697,7 +1697,8 @@ pub struct WindowConfig { /// ## Platform-specific /// /// - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice. - /// - **iOS / macOS**: Supported since version 17.0+. + /// - **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 = "disable-background-throttling")] diff --git a/crates/tauri/src/webview/mod.rs b/crates/tauri/src/webview/mod.rs index 0dd1341f419d..9e4823867d87 100644 --- a/crates/tauri/src/webview/mod.rs +++ b/crates/tauri/src/webview/mod.rs @@ -877,7 +877,8 @@ fn main() { /// ## Platform-specific /// /// - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice. - /// - **iOS / macOS**: Supported since version 17.0+. + /// - **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] diff --git a/crates/tauri/src/webview/webview_window.rs b/crates/tauri/src/webview/webview_window.rs index 05f88da1d6c9..36b8b18c6017 100644 --- a/crates/tauri/src/webview/webview_window.rs +++ b/crates/tauri/src/webview/webview_window.rs @@ -987,7 +987,8 @@ impl> WebviewWindowBuilder<'_, R, M> { /// ## Platform-specific /// /// - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice. - /// - **iOS / macOS**: Supported since version 17.0+. + /// - **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] diff --git a/packages/api/src/webview.ts b/packages/api/src/webview.ts index 1cfa67f4764d..bb153cdbfbba 100644 --- a/packages/api/src/webview.ts +++ b/packages/api/src/webview.ts @@ -777,7 +777,8 @@ interface WebviewOptions { ## Platform-specific * * - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice. - * - **iOS / macOS**: Supported since version 17.0+. + * - **iOS**: Supported since version 17.0+. + * - **macOS**: Supported since version 14.0+. * * see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 * diff --git a/packages/api/src/window.ts b/packages/api/src/window.ts index 03302c2a22fb..105ac2f878e3 100644 --- a/packages/api/src/window.ts +++ b/packages/api/src/window.ts @@ -1542,7 +1542,8 @@ class Window { ## Platform-specific * * - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice. - * - **iOS / macOS**: Supported since version 17.0+. + * - **iOS**: Supported since version 17.0+. + * - **macOS**: Supported since version 14.0+. * * see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 * @@ -2367,7 +2368,8 @@ interface WindowOptions { * #### Platform-specific * * - **Linux / Windows / Android**: Unsupported. Workarounds like a pending WebLock transaction might suffice. - * - **iOS / macOS**: Supported since version 17.0+. + * - **iOS**: Supported since version 17.0+. + * - **macOS**: Supported since version 14.0+. * * see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 * From 435a7186000e9ccb88d7c8feeed20a2c3c43f599 Mon Sep 17 00:00:00 2001 From: Bastian Kistner Date: Wed, 8 Jan 2025 12:00:03 +0100 Subject: [PATCH 7/9] feat: use policy enum for background throttling --- .changes/disable-background-throttling.md | 2 +- Cargo.lock | 5 +- crates/tauri-cli/config.schema.json | 40 ++++++++++++++-- crates/tauri-cli/schema.json | 12 +++-- crates/tauri-cli/tauri.config.schema.json | 14 ++++-- crates/tauri-runtime-wry/Cargo.toml | 2 +- crates/tauri-runtime-wry/src/lib.rs | 2 +- crates/tauri-runtime/src/webview.rs | 16 ++++--- .../schemas/config.schema.json | 40 ++++++++++++++-- crates/tauri-utils/Cargo.toml | 1 + crates/tauri-utils/src/config.rs | 46 ++++++++++++++++--- crates/tauri/scripts/bundle.global.js | 2 +- crates/tauri/src/webview/mod.rs | 8 ++-- crates/tauri/src/webview/plugin.rs | 7 ++- crates/tauri/src/webview/webview_window.rs | 8 ++-- packages/api/src/webview.ts | 17 ++++--- packages/api/src/window.ts | 32 +++++++++---- 17 files changed, 190 insertions(+), 64 deletions(-) diff --git a/.changes/disable-background-throttling.md b/.changes/disable-background-throttling.md index 96fe0de6a4b5..48f6e20e4260 100644 --- a/.changes/disable-background-throttling.md +++ b/.changes/disable-background-throttling.md @@ -8,4 +8,4 @@ '@tauri-apps/cli': 'minor:enhance' --- -Add an option to disable background throttling (currently for WebKit only). \ No newline at end of file +Add an option to change the default background throttling policy (currently for WebKit only). diff --git a/Cargo.lock b/Cargo.lock index 286b07141c24..07fb68f5bdcd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9627,6 +9627,7 @@ dependencies = [ "urlpattern", "uuid", "walkdir", + "wry", ] [[package]] @@ -11386,9 +11387,7 @@ checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" [[package]] name = "wry" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e644bf458e27b11b0ecafc9e5633d1304fdae82baca1d42185669752fe6ca4f" +version = "0.49.0" dependencies = [ "base64 0.22.1", "block2", diff --git a/crates/tauri-cli/config.schema.json b/crates/tauri-cli/config.schema.json index bdc4e103ed80..fc0bb59d4da7 100644 --- a/crates/tauri-cli/config.schema.json +++ b/crates/tauri-cli/config.schema.json @@ -517,10 +517,16 @@ } ] }, - "disableBackgroundThrottling": { - "description": "Set whether background throttling should be disabled.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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", - "default": false, - "type": "boolean" + "backgroundThrottling": { + "description": "Change the default background throttling behaviour.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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 @@ -953,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.", + "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: ", "type": "object", diff --git a/crates/tauri-cli/schema.json b/crates/tauri-cli/schema.json index 30596f3cca1a..8b2d4b4248e9 100644 --- a/crates/tauri-cli/schema.json +++ b/crates/tauri-cli/schema.json @@ -466,10 +466,14 @@ "default": false, "type": "boolean" }, - "disableBackgroundThrottling": { - "description": "Set whether background throttling should be disabled.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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", - "default": false, - "type": "boolean" + "backgroundThrottling": { + "description": "Change the default background throttling behaviour.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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 diff --git a/crates/tauri-cli/tauri.config.schema.json b/crates/tauri-cli/tauri.config.schema.json index 04ea6dd9e95c..8b2d4b4248e9 100644 --- a/crates/tauri-cli/tauri.config.schema.json +++ b/crates/tauri-cli/tauri.config.schema.json @@ -466,10 +466,14 @@ "default": false, "type": "boolean" }, - "disableBackgroundThrottling": { - "description": "Set whether background throttling should be disabled.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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", - "default": false, - "type": "boolean" + "backgroundThrottling": { + "description": "Change the default background throttling behaviour.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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 @@ -3000,4 +3004,4 @@ "additionalProperties": true } } -} \ No newline at end of file +} diff --git a/crates/tauri-runtime-wry/Cargo.toml b/crates/tauri-runtime-wry/Cargo.toml index 3a180bc43f4e..f6d972f3eb4e 100644 --- a/crates/tauri-runtime-wry/Cargo.toml +++ b/crates/tauri-runtime-wry/Cargo.toml @@ -17,7 +17,7 @@ rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"] [dependencies] -wry = { version = "0.48", default-features = false, features = [ +wry = { version = "0.49", default-features = false, features = [ "drag-drop", "protocol", "os-webview", diff --git a/crates/tauri-runtime-wry/src/lib.rs b/crates/tauri-runtime-wry/src/lib.rs index a0568d114f9b..9703729944dd 100644 --- a/crates/tauri-runtime-wry/src/lib.rs +++ b/crates/tauri-runtime-wry/src/lib.rs @@ -4180,7 +4180,7 @@ fn create_webview( .with_accept_first_mouse(webview_attributes.accept_first_mouse) .with_incognito(webview_attributes.incognito) .with_clipboard(webview_attributes.clipboard) - .with_disable_background_throttling(webview_attributes.disable_background_throttling) + .with_background_throttling(webview_attributes.background_throttling.map(|p| p.into())) .with_hotkeys_zoom(webview_attributes.zoom_hotkeys_enabled); #[cfg(any(target_os = "windows", target_os = "android"))] diff --git a/crates/tauri-runtime/src/webview.rs b/crates/tauri-runtime/src/webview.rs index 8da93d17a4c1..d1601751e58a 100644 --- a/crates/tauri-runtime/src/webview.rs +++ b/crates/tauri-runtime/src/webview.rs @@ -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,7 +217,7 @@ pub struct WebviewAttributes { pub use_https_scheme: bool, pub devtools: Option, pub background_color: Option, - pub disable_background_throttling: bool, + pub background_throttling: Option, } impl From<&WindowConfig> for WebviewAttributes { @@ -226,7 +228,7 @@ 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) - .disable_background_throttling(config.disable_background_throttling) + .background_throttling(config.background_throttling.clone()) .devtools(config.devtools); #[cfg(any(not(target_os = "macos"), feature = "macos-private-api"))] @@ -282,7 +284,7 @@ impl WebviewAttributes { use_https_scheme: false, devtools: None, background_color: None, - disable_background_throttling: false, + background_throttling: None, } } @@ -449,7 +451,7 @@ impl WebviewAttributes { self } - /// Set whether background throttling should be disabled. + /// Change the default background throttling behaviour. /// /// By default, browsers 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 permanently suspend all tasks until the documents visibility state @@ -463,8 +465,8 @@ impl WebviewAttributes { /// /// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 #[must_use] - pub fn disable_background_throttling(mut self, disable: bool) -> Self { - self.disable_background_throttling = disable; + pub fn background_throttling(mut self, policy: Option) -> Self { + self.background_throttling = policy; self } } diff --git a/crates/tauri-schema-generator/schemas/config.schema.json b/crates/tauri-schema-generator/schemas/config.schema.json index bdc4e103ed80..fc0bb59d4da7 100644 --- a/crates/tauri-schema-generator/schemas/config.schema.json +++ b/crates/tauri-schema-generator/schemas/config.schema.json @@ -517,10 +517,16 @@ } ] }, - "disableBackgroundThrottling": { - "description": "Set whether background throttling should be disabled.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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", - "default": false, - "type": "boolean" + "backgroundThrottling": { + "description": "Change the default background throttling behaviour.\n\n By default, browsers throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when\n a view became minimized or hidden. This will permanently suspend 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 @@ -953,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.", + "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: ", "type": "object", diff --git a/crates/tauri-utils/Cargo.toml b/crates/tauri-utils/Cargo.toml index 273582cc2460..0fd436358ce3 100644 --- a/crates/tauri-utils/Cargo.toml +++ b/crates/tauri-utils/Cargo.toml @@ -13,6 +13,7 @@ edition.workspace = true rust-version.workspace = true [dependencies] +wry = { version = "0.49", default-features = false } serde = { version = "1", features = ["derive"] } serde_json = "1" thiserror = "2" diff --git a/crates/tauri-utils/src/config.rs b/crates/tauri-utils/src/config.rs index 4fd8ec819cb5..be8514f9c755 100644 --- a/crates/tauri-utils/src/config.rs +++ b/crates/tauri-utils/src/config.rs @@ -1420,6 +1420,29 @@ 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. + Suspend, + /// A policy where a web view that’s not in a window limits processing, but does not fully suspend tasks. + Throttle, +} + +impl From for wry::BackgroundThrottlingPolicy { + fn from(policy: BackgroundThrottlingPolicy) -> Self { + match policy { + BackgroundThrottlingPolicy::Disabled => Self::Disabled, + BackgroundThrottlingPolicy::Throttle => Self::Throttle, + BackgroundThrottlingPolicy::Suspend => Self::Suspend, + } + } +} + /// The window effects configuration object #[skip_serializing_none] #[derive(Debug, PartialEq, Clone, Deserialize, Serialize, Default)] @@ -1688,7 +1711,7 @@ pub struct WindowConfig { #[serde(alias = "background-color")] pub background_color: Option, - /// Set whether background throttling should be disabled. + /// Change the default background throttling behaviour. /// /// By default, browsers 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 permanently suspend all tasks until the documents visibility state @@ -1701,8 +1724,8 @@ pub struct WindowConfig { /// - **macOS**: Supported since version 14.0+. /// /// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 - #[serde(default, alias = "disable-background-throttling")] - pub disable_background_throttling: bool, + #[serde(default, alias = "background-throttling")] + pub background_throttling: Option, } impl Default for WindowConfig { @@ -1755,7 +1778,7 @@ impl Default for WindowConfig { use_https_scheme: false, devtools: None, background_color: None, - disable_background_throttling: false, + background_throttling: None, } } } @@ -2875,6 +2898,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 }; @@ -3021,7 +3055,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 disable_background_throttling = self.disable_background_throttling; + let background_throttling = opt_lit(self.background_throttling.as_ref()); literal_struct!( tokens, @@ -3073,7 +3107,7 @@ mod build { use_https_scheme, devtools, background_color, - disable_background_throttling + background_throttling ); } } diff --git a/crates/tauri/scripts/bundle.global.js b/crates/tauri/scripts/bundle.global.js index 03416080c2e9..782e544c8507 100644 --- a/crates/tauri/scripts/bundle.global.js +++ b/crates/tauri/scripts/bundle.global.js @@ -1 +1 @@ -var __TAURI_IIFE__=function(e){"use strict";function n(e,n,t,i){if("a"===t&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof n?e!==n||!i:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?i:"a"===t?i.call(e):i?i.value:n.get(e)}function t(e,n,t,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof n?e!==n||!r:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,t):r?r.value=t:n.set(e,t),t}var i,r,s,a;"function"==typeof SuppressedError&&SuppressedError;const l="__TAURI_TO_IPC_KEY__";function o(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}class u{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,i.set(this,(()=>{})),r.set(this,0),s.set(this,[]),this.id=o((({message:e,id:a})=>{if(a==n(this,r,"f"))for(n(this,i,"f").call(this,e),t(this,r,n(this,r,"f")+1,"f");n(this,r,"f")in n(this,s,"f");){const e=n(this,s,"f")[n(this,r,"f")];n(this,i,"f").call(this,e),delete n(this,s,"f")[n(this,r,"f")],t(this,r,n(this,r,"f")+1,"f")}else n(this,s,"f")[a]=e}))}set onmessage(e){t(this,i,e,"f")}get onmessage(){return n(this,i,"f")}[(i=new WeakMap,r=new WeakMap,s=new WeakMap,l)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[l]()}}class c{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return d(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function d(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}class h{get rid(){return n(this,a,"f")}constructor(e){a.set(this,void 0),t(this,a,e,"f")}async close(){return d("plugin:resources|close",{rid:this.rid})}}a=new WeakMap;var p=Object.freeze({__proto__:null,Channel:u,PluginListener:c,Resource:h,SERIALIZE_TO_IPC_FN:l,addPluginListener:async function(e,n,t){const i=new u;return i.onmessage=t,d(`plugin:${e}|registerListener`,{event:n,handler:i}).then((()=>new c(e,n,i.id)))},checkPermissions:async function(e){return d(`plugin:${e}|check_permissions`)},convertFileSrc:function(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)},invoke:d,isTauri:function(){return"isTauri"in window&&!!window.isTauri},requestPermissions:async function(e){return d(`plugin:${e}|request_permissions`)},transformCallback:o});class w extends h{constructor(e){super(e)}static async new(e,n,t){return d("plugin:image|new",{rgba:y(e),width:n,height:t}).then((e=>new w(e)))}static async fromBytes(e){return d("plugin:image|from_bytes",{bytes:y(e)}).then((e=>new w(e)))}static async fromPath(e){return d("plugin:image|from_path",{path:e}).then((e=>new w(e)))}async rgba(){return d("plugin:image|rgba",{rid:this.rid}).then((e=>new Uint8Array(e)))}async size(){return d("plugin:image|size",{rid:this.rid})}}function y(e){return null==e?null:"string"==typeof e?e:e instanceof w?e.rid:e}var _=Object.freeze({__proto__:null,Image:w,transformImage:y});var g=Object.freeze({__proto__:null,defaultWindowIcon:async function(){return d("plugin:app|default_window_icon").then((e=>e?new w(e):null))},getName:async function(){return d("plugin:app|name")},getTauriVersion:async function(){return d("plugin:app|tauri_version")},getVersion:async function(){return d("plugin:app|version")},hide:async function(){return d("plugin:app|app_hide")},setTheme:async function(e){return d("plugin:app|set_app_theme",{theme:e})},show:async function(){return d("plugin:app|app_show")}});class b{constructor(...e){this.type="Logical",1===e.length?"Logical"in e[0]?(this.width=e[0].Logical.width,this.height=e[0].Logical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toPhysical(e){return new m(this.width*e,this.height*e)}[l](){return{width:this.width,height:this.height}}toJSON(){return this[l]()}}class m{constructor(...e){this.type="Physical",1===e.length?"Physical"in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new b(this.width/e,this.height/e)}[l](){return{width:this.width,height:this.height}}toJSON(){return this[l]()}}class v{constructor(e){this.size=e}toLogical(e){return this.size instanceof b?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof m?this.size:this.size.toPhysical(e)}[l](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[l]()}}class f{constructor(...e){this.type="Logical",1===e.length?"Logical"in e[0]?(this.x=e[0].Logical.x,this.y=e[0].Logical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toPhysical(e){return new k(this.x*e,this.y*e)}[l](){return{x:this.x,y:this.y}}toJSON(){return this[l]()}}class k{constructor(...e){this.type="Physical",1===e.length?"Physical"in e[0]?(this.x=e[0].Physical.x,this.y=e[0].Physical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toLogical(e){return new f(this.x/e,this.y/e)}[l](){return{x:this.x,y:this.y}}toJSON(){return this[l]()}}class A{constructor(e){this.position=e}toLogical(e){return this.position instanceof f?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof k?this.position:this.position.toPhysical(e)}[l](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[l]()}}var E,T=Object.freeze({__proto__:null,LogicalPosition:f,LogicalSize:b,PhysicalPosition:k,PhysicalSize:m,Position:A,Size:v});async function D(e,n){await d("plugin:event|unlisten",{event:e,eventId:n})}async function I(e,n,t){var i;const r="string"==typeof(null==t?void 0:t.target)?{kind:"AnyLabel",label:t.target}:null!==(i=null==t?void 0:t.target)&&void 0!==i?i:{kind:"Any"};return d("plugin:event|listen",{event:e,target:r,handler:o(n)}).then((n=>async()=>D(e,n)))}async function R(e,n,t){return I(e,(t=>{D(e,t.id),n(t)}),t)}async function S(e,n){await d("plugin:event|emit",{event:e,payload:n})}async function L(e,n,t){const i="string"==typeof e?{kind:"AnyLabel",label:e}:e;await d("plugin:event|emit_to",{target:i,event:n,payload:t})}!function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"}(E||(E={}));var x,C,N,P=Object.freeze({__proto__:null,get TauriEvent(){return E},emit:S,emitTo:L,listen:I,once:R});function z(e){var n;if("items"in e)e.items=null===(n=e.items)||void 0===n?void 0:n.map((e=>"rid"in e?e:z(e)));else if("action"in e&&e.action){const n=new u;return n.onmessage=e.action,delete e.action,{...e,handler:n}}return e}async function W(e,n){const t=new u;if(n&&"object"==typeof n&&("action"in n&&n.action&&(t.onmessage=n.action,delete n.action),"item"in n&&n.item&&"object"==typeof n.item&&"About"in n.item&&n.item.About&&"object"==typeof n.item.About&&"icon"in n.item.About&&n.item.About.icon&&(n.item.About.icon=y(n.item.About.icon)),"icon"in n&&n.icon&&(n.icon=y(n.icon)),"items"in n&&n.items)){function i(e){var n;return"rid"in e?[e.rid,e.kind]:("item"in e&&"object"==typeof e.item&&(null===(n=e.item.About)||void 0===n?void 0:n.icon)&&(e.item.About.icon=y(e.item.About.icon)),"icon"in e&&e.icon&&(e.icon=y(e.icon)),"items"in e&&e.items&&(e.items=e.items.map(i)),z(e))}n.items=n.items.map(i)}return d("plugin:menu|new",{kind:e,options:n,handler:t})}class O extends h{get id(){return n(this,x,"f")}get kind(){return n(this,C,"f")}constructor(e,n,i){super(e),x.set(this,void 0),C.set(this,void 0),t(this,x,n,"f"),t(this,C,i,"f")}}x=new WeakMap,C=new WeakMap;class F extends O{constructor(e,n){super(e,n,"MenuItem")}static async new(e){return W("MenuItem",e).then((([e,n])=>new F(e,n)))}async text(){return d("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return d("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return d("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return d("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return d("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}}class M extends O{constructor(e,n){super(e,n,"Check")}static async new(e){return W("Check",e).then((([e,n])=>new M(e,n)))}async text(){return d("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return d("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return d("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return d("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return d("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async isChecked(){return d("plugin:menu|is_checked",{rid:this.rid})}async setChecked(e){return d("plugin:menu|set_checked",{rid:this.rid,checked:e})}}!function(e){e.Add="Add",e.Advanced="Advanced",e.Bluetooth="Bluetooth",e.Bookmarks="Bookmarks",e.Caution="Caution",e.ColorPanel="ColorPanel",e.ColumnView="ColumnView",e.Computer="Computer",e.EnterFullScreen="EnterFullScreen",e.Everyone="Everyone",e.ExitFullScreen="ExitFullScreen",e.FlowView="FlowView",e.Folder="Folder",e.FolderBurnable="FolderBurnable",e.FolderSmart="FolderSmart",e.FollowLinkFreestanding="FollowLinkFreestanding",e.FontPanel="FontPanel",e.GoLeft="GoLeft",e.GoRight="GoRight",e.Home="Home",e.IChatTheater="IChatTheater",e.IconView="IconView",e.Info="Info",e.InvalidDataFreestanding="InvalidDataFreestanding",e.LeftFacingTriangle="LeftFacingTriangle",e.ListView="ListView",e.LockLocked="LockLocked",e.LockUnlocked="LockUnlocked",e.MenuMixedState="MenuMixedState",e.MenuOnState="MenuOnState",e.MobileMe="MobileMe",e.MultipleDocuments="MultipleDocuments",e.Network="Network",e.Path="Path",e.PreferencesGeneral="PreferencesGeneral",e.QuickLook="QuickLook",e.RefreshFreestanding="RefreshFreestanding",e.Refresh="Refresh",e.Remove="Remove",e.RevealFreestanding="RevealFreestanding",e.RightFacingTriangle="RightFacingTriangle",e.Share="Share",e.Slideshow="Slideshow",e.SmartBadge="SmartBadge",e.StatusAvailable="StatusAvailable",e.StatusNone="StatusNone",e.StatusPartiallyAvailable="StatusPartiallyAvailable",e.StatusUnavailable="StatusUnavailable",e.StopProgressFreestanding="StopProgressFreestanding",e.StopProgress="StopProgress",e.TrashEmpty="TrashEmpty",e.TrashFull="TrashFull",e.User="User",e.UserAccounts="UserAccounts",e.UserGroup="UserGroup",e.UserGuest="UserGuest"}(N||(N={}));class U extends O{constructor(e,n){super(e,n,"Icon")}static async new(e){return W("Icon",e).then((([e,n])=>new U(e,n)))}async text(){return d("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return d("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return d("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return d("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return d("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async setIcon(e){return d("plugin:menu|set_icon",{rid:this.rid,icon:y(e)})}}class B extends O{constructor(e,n){super(e,n,"Predefined")}static async new(e){return W("Predefined",e).then((([e,n])=>new B(e,n)))}async text(){return d("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return d("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}}function j([e,n,t]){switch(t){case"Submenu":return new V(e,n);case"Predefined":return new B(e,n);case"Check":return new M(e,n);case"Icon":return new U(e,n);default:return new F(e,n)}}class V extends O{constructor(e,n){super(e,n,"Submenu")}static async new(e){return W("Submenu",e).then((([e,n])=>new V(e,n)))}async text(){return d("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return d("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return d("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return d("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async append(e){return d("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(e)?e:[e]).map((e=>"rid"in e?[e.rid,e.kind]:e))})}async prepend(e){return d("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(e)?e:[e]).map((e=>"rid"in e?[e.rid,e.kind]:e))})}async insert(e,n){return d("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(e)?e:[e]).map((e=>"rid"in e?[e.rid,e.kind]:e)),position:n})}async remove(e){return d("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return d("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(j)}async items(){return d("plugin:menu|items",{rid:this.rid,kind:this.kind}).then((e=>e.map(j)))}async get(e){return d("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then((e=>e?j(e):null))}async popup(e,n){var t;return d("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:null!==(t=null==n?void 0:n.label)&&void 0!==t?t:null,at:e instanceof A?e:e?new A(e):null})}async setAsWindowsMenuForNSApp(){return d("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return d("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}}class G extends O{constructor(e,n){super(e,n,"Menu")}static async new(e){return W("Menu",e).then((([e,n])=>new G(e,n)))}static async default(){return d("plugin:menu|create_default").then((([e,n])=>new G(e,n)))}async append(e){return d("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(e)?e:[e]).map((e=>"rid"in e?[e.rid,e.kind]:e))})}async prepend(e){return d("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(e)?e:[e]).map((e=>"rid"in e?[e.rid,e.kind]:e))})}async insert(e,n){return d("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(e)?e:[e]).map((e=>"rid"in e?[e.rid,e.kind]:e)),position:n})}async remove(e){return d("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return d("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(j)}async items(){return d("plugin:menu|items",{rid:this.rid,kind:this.kind}).then((e=>e.map(j)))}async get(e){return d("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then((e=>e?j(e):null))}async popup(e,n){var t;return d("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:null!==(t=null==n?void 0:n.label)&&void 0!==t?t:null,at:e instanceof A?e:e?new A(e):null})}async setAsAppMenu(){return d("plugin:menu|set_as_app_menu",{rid:this.rid}).then((e=>e?new G(e[0],e[1]):null))}async setAsWindowMenu(e){var n;return d("plugin:menu|set_as_window_menu",{rid:this.rid,window:null!==(n=null==e?void 0:e.label)&&void 0!==n?n:null}).then((e=>e?new G(e[0],e[1]):null))}}var H=Object.freeze({__proto__:null,CheckMenuItem:M,IconMenuItem:U,Menu:G,MenuItem:F,get NativeIcon(){return N},PredefinedMenuItem:B,Submenu:V,itemFromKind:j});function $(){var e;window.__TAURI_INTERNALS__=null!==(e=window.__TAURI_INTERNALS__)&&void 0!==e?e:{}}var q,J=Object.freeze({__proto__:null,clearMocks:function(){var e,n,t;"object"==typeof window.__TAURI_INTERNALS__&&((null===(e=window.__TAURI_INTERNALS__)||void 0===e?void 0:e.convertFileSrc)&&delete window.__TAURI_INTERNALS__.convertFileSrc,(null===(n=window.__TAURI_INTERNALS__)||void 0===n?void 0:n.invoke)&&delete window.__TAURI_INTERNALS__.invoke,(null===(t=window.__TAURI_INTERNALS__)||void 0===t?void 0:t.metadata)&&delete window.__TAURI_INTERNALS__.metadata)},mockConvertFileSrc:function(e){$(),window.__TAURI_INTERNALS__.convertFileSrc=function(n,t="asset"){const i=encodeURIComponent(n);return"windows"===e?`http://${t}.localhost/${i}`:`${t}://localhost/${i}`}},mockIPC:function(e){$(),window.__TAURI_INTERNALS__.transformCallback=function(e,n=!1){const t=window.crypto.getRandomValues(new Uint32Array(1))[0],i=`_${t}`;return Object.defineProperty(window,i,{value:t=>(n&&Reflect.deleteProperty(window,i),e&&e(t)),writable:!1,configurable:!0}),t},window.__TAURI_INTERNALS__.invoke=async function(n,t,i){return e(n,t)}},mockWindows:function(e,...n){$(),window.__TAURI_INTERNALS__.metadata={currentWindow:{label:e},currentWebview:{windowLabel:e,label:e}}}});!function(e){e[e.Audio=1]="Audio",e[e.Cache=2]="Cache",e[e.Config=3]="Config",e[e.Data=4]="Data",e[e.LocalData=5]="LocalData",e[e.Document=6]="Document",e[e.Download=7]="Download",e[e.Picture=8]="Picture",e[e.Public=9]="Public",e[e.Video=10]="Video",e[e.Resource=11]="Resource",e[e.Temp=12]="Temp",e[e.AppConfig=13]="AppConfig",e[e.AppData=14]="AppData",e[e.AppLocalData=15]="AppLocalData",e[e.AppCache=16]="AppCache",e[e.AppLog=17]="AppLog",e[e.Desktop=18]="Desktop",e[e.Executable=19]="Executable",e[e.Font=20]="Font",e[e.Home=21]="Home",e[e.Runtime=22]="Runtime",e[e.Template=23]="Template"}(q||(q={}));var Q=Object.freeze({__proto__:null,get BaseDirectory(){return q},appCacheDir:async function(){return d("plugin:path|resolve_directory",{directory:q.AppCache})},appConfigDir:async function(){return d("plugin:path|resolve_directory",{directory:q.AppConfig})},appDataDir:async function(){return d("plugin:path|resolve_directory",{directory:q.AppData})},appLocalDataDir:async function(){return d("plugin:path|resolve_directory",{directory:q.AppLocalData})},appLogDir:async function(){return d("plugin:path|resolve_directory",{directory:q.AppLog})},audioDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Audio})},basename:async function(e,n){return d("plugin:path|basename",{path:e,ext:n})},cacheDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Cache})},configDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Config})},dataDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Data})},delimiter:function(){return window.__TAURI_INTERNALS__.plugins.path.delimiter},desktopDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Desktop})},dirname:async function(e){return d("plugin:path|dirname",{path:e})},documentDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Document})},downloadDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Download})},executableDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Executable})},extname:async function(e){return d("plugin:path|extname",{path:e})},fontDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Font})},homeDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Home})},isAbsolute:async function(e){return d("plugin:path|is_absolute",{path:e})},join:async function(...e){return d("plugin:path|join",{paths:e})},localDataDir:async function(){return d("plugin:path|resolve_directory",{directory:q.LocalData})},normalize:async function(e){return d("plugin:path|normalize",{path:e})},pictureDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Picture})},publicDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Public})},resolve:async function(...e){return d("plugin:path|resolve",{paths:e})},resolveResource:async function(e){return d("plugin:path|resolve_directory",{directory:q.Resource,path:e})},resourceDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Resource})},runtimeDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Runtime})},sep:function(){return window.__TAURI_INTERNALS__.plugins.path.sep},tempDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Temp})},templateDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Template})},videoDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Video})}});class Z extends h{constructor(e,n){super(e),this.id=n}static async getById(e){return d("plugin:tray|get_by_id",{id:e}).then((n=>n?new Z(n,e):null))}static async removeById(e){return d("plugin:tray|remove_by_id",{id:e})}static async new(e){(null==e?void 0:e.menu)&&(e.menu=[e.menu.rid,e.menu.kind]),(null==e?void 0:e.icon)&&(e.icon=y(e.icon));const n=new u;if(null==e?void 0:e.action){const t=e.action;n.onmessage=e=>t(function(e){const n=e;return n.position=new k(e.position),n.rect.position=new k(e.rect.position),n.rect.size=new m(e.rect.size),n}(e)),delete e.action}return d("plugin:tray|new",{options:null!=e?e:{},handler:n}).then((([e,n])=>new Z(e,n)))}async setIcon(e){let n=null;return e&&(n=y(e)),d("plugin:tray|set_icon",{rid:this.rid,icon:n})}async setMenu(e){return e&&(e=[e.rid,e.kind]),d("plugin:tray|set_menu",{rid:this.rid,menu:e})}async setTooltip(e){return d("plugin:tray|set_tooltip",{rid:this.rid,tooltip:e})}async setTitle(e){return d("plugin:tray|set_title",{rid:this.rid,title:e})}async setVisible(e){return d("plugin:tray|set_visible",{rid:this.rid,visible:e})}async setTempDirPath(e){return d("plugin:tray|set_temp_dir_path",{rid:this.rid,path:e})}async setIconAsTemplate(e){return d("plugin:tray|set_icon_as_template",{rid:this.rid,asTemplate:e})}async setMenuOnLeftClick(e){return d("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}async setShowMenuOnLeftClick(e){return d("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}}var K,Y,X=Object.freeze({__proto__:null,TrayIcon:Z});!function(e){e[e.Critical=1]="Critical",e[e.Informational=2]="Informational"}(K||(K={}));class ee{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}function ne(){return new re(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function te(){return d("plugin:window|get_all_windows").then((e=>e.map((e=>new re(e,{skip:!0})))))}!function(e){e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error"}(Y||(Y={}));const ie=["tauri://created","tauri://error"];class re{constructor(e,n={}){var t;this.label=e,this.listeners=Object.create(null),(null==n?void 0:n.skip)||d("plugin:window|create",{options:{...n,parent:"string"==typeof n.parent?n.parent:null===(t=n.parent)||void 0===t?void 0:t.label,label:e}}).then((async()=>this.emit("tauri://created"))).catch((async e=>this.emit("tauri://error",e)))}static async getByLabel(e){var n;return null!==(n=(await te()).find((n=>n.label===e)))&&void 0!==n?n:null}static getCurrent(){return ne()}static async getAll(){return te()}static async getFocusedWindow(){for(const e of await te())if(await e.isFocused())return e;return null}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:I(e,n,{target:{kind:"Window",label:this.label}})}async once(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:R(e,n,{target:{kind:"Window",label:this.label}})}async emit(e,n){if(!ie.includes(e))return S(e,n);for(const t of this.listeners[e]||[])t({event:e,id:-1,payload:n})}async emitTo(e,n,t){if(!ie.includes(n))return L(e,n,t);for(const e of this.listeners[n]||[])e({event:n,id:-1,payload:t})}_handleTauriEvent(e,n){return!!ie.includes(e)&&(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0)}async scaleFactor(){return d("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return d("plugin:window|inner_position",{label:this.label}).then((e=>new k(e)))}async outerPosition(){return d("plugin:window|outer_position",{label:this.label}).then((e=>new k(e)))}async innerSize(){return d("plugin:window|inner_size",{label:this.label}).then((e=>new m(e)))}async outerSize(){return d("plugin:window|outer_size",{label:this.label}).then((e=>new m(e)))}async isFullscreen(){return d("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return d("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return d("plugin:window|is_maximized",{label:this.label})}async isFocused(){return d("plugin:window|is_focused",{label:this.label})}async isDecorated(){return d("plugin:window|is_decorated",{label:this.label})}async isResizable(){return d("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return d("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return d("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return d("plugin:window|is_closable",{label:this.label})}async isVisible(){return d("plugin:window|is_visible",{label:this.label})}async title(){return d("plugin:window|title",{label:this.label})}async theme(){return d("plugin:window|theme",{label:this.label})}async center(){return d("plugin:window|center",{label:this.label})}async requestUserAttention(e){let n=null;return e&&(n=e===K.Critical?{type:"Critical"}:{type:"Informational"}),d("plugin:window|request_user_attention",{label:this.label,value:n})}async setResizable(e){return d("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return d("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return d("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return d("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return d("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return d("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return d("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return d("plugin:window|maximize",{label:this.label})}async unmaximize(){return d("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return d("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return d("plugin:window|minimize",{label:this.label})}async unminimize(){return d("plugin:window|unminimize",{label:this.label})}async show(){return d("plugin:window|show",{label:this.label})}async hide(){return d("plugin:window|hide",{label:this.label})}async close(){return d("plugin:window|close",{label:this.label})}async destroy(){return d("plugin:window|destroy",{label:this.label})}async setDecorations(e){return d("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return d("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return d("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return d("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return d("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return d("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return d("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return d("plugin:window|set_size",{label:this.label,value:e instanceof v?e:new v(e)})}async setMinSize(e){return d("plugin:window|set_min_size",{label:this.label,value:e instanceof v?e:e?new v(e):null})}async setMaxSize(e){return d("plugin:window|set_max_size",{label:this.label,value:e instanceof v?e:e?new v(e):null})}async setSizeConstraints(e){function n(e){return e?{Logical:e}:null}return d("plugin:window|set_size_constraints",{label:this.label,value:{minWidth:n(null==e?void 0:e.minWidth),minHeight:n(null==e?void 0:e.minHeight),maxWidth:n(null==e?void 0:e.maxWidth),maxHeight:n(null==e?void 0:e.maxHeight)}})}async setPosition(e){return d("plugin:window|set_position",{label:this.label,value:e instanceof A?e:new A(e)})}async setFullscreen(e){return d("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return d("plugin:window|set_focus",{label:this.label})}async setIcon(e){return d("plugin:window|set_icon",{label:this.label,value:y(e)})}async setSkipTaskbar(e){return d("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return d("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return d("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return d("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return d("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return d("plugin:window|set_cursor_position",{label:this.label,value:e instanceof A?e:new A(e)})}async setIgnoreCursorEvents(e){return d("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return d("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return d("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return d("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return d("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return d("plugin:window|set_overlay_icon",{label:this.label,value:e?y(e):void 0})}async setProgressBar(e){return d("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return d("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return d("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return d("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(E.WINDOW_RESIZED,(n=>{n.payload=new m(n.payload),e(n)}))}async onMoved(e){return this.listen(E.WINDOW_MOVED,(n=>{n.payload=new k(n.payload),e(n)}))}async onCloseRequested(e){return this.listen(E.WINDOW_CLOSE_REQUESTED,(async n=>{const t=new ee(n);await e(t),t.isPreventDefault()||await this.destroy()}))}async onDragDropEvent(e){const n=await this.listen(E.DRAG_ENTER,(n=>{e({...n,payload:{type:"enter",paths:n.payload.paths,position:new k(n.payload.position)}})})),t=await this.listen(E.DRAG_OVER,(n=>{e({...n,payload:{type:"over",position:new k(n.payload.position)}})})),i=await this.listen(E.DRAG_DROP,(n=>{e({...n,payload:{type:"drop",paths:n.payload.paths,position:new k(n.payload.position)}})})),r=await this.listen(E.DRAG_LEAVE,(n=>{e({...n,payload:{type:"leave"}})}));return()=>{n(),i(),t(),r()}}async onFocusChanged(e){const n=await this.listen(E.WINDOW_FOCUS,(n=>{e({...n,payload:!0})})),t=await this.listen(E.WINDOW_BLUR,(n=>{e({...n,payload:!1})}));return()=>{n(),t()}}async onScaleChanged(e){return this.listen(E.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(E.WINDOW_THEME_CHANGED,e)}}var se,ae;function le(e){return null===e?null:{name:e.name,scaleFactor:e.scaleFactor,position:new k(e.position),size:new m(e.size)}}!function(e){e.AppearanceBased="appearanceBased",e.Light="light",e.Dark="dark",e.MediumLight="mediumLight",e.UltraDark="ultraDark",e.Titlebar="titlebar",e.Selection="selection",e.Menu="menu",e.Popover="popover",e.Sidebar="sidebar",e.HeaderView="headerView",e.Sheet="sheet",e.WindowBackground="windowBackground",e.HudWindow="hudWindow",e.FullScreenUI="fullScreenUI",e.Tooltip="tooltip",e.ContentBackground="contentBackground",e.UnderWindowBackground="underWindowBackground",e.UnderPageBackground="underPageBackground",e.Mica="mica",e.Blur="blur",e.Acrylic="acrylic",e.Tabbed="tabbed",e.TabbedDark="tabbedDark",e.TabbedLight="tabbedLight"}(se||(se={})),function(e){e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive"}(ae||(ae={}));var oe=Object.freeze({__proto__:null,CloseRequestedEvent:ee,get Effect(){return se},get EffectState(){return ae},LogicalPosition:f,LogicalSize:b,PhysicalPosition:k,PhysicalSize:m,get ProgressBarStatus(){return Y},get UserAttentionType(){return K},Window:re,availableMonitors:async function(){return d("plugin:window|available_monitors").then((e=>e.map(le)))},currentMonitor:async function(){return d("plugin:window|current_monitor").then(le)},cursorPosition:async function(){return d("plugin:window|cursor_position").then((e=>new k(e)))},getAllWindows:te,getCurrentWindow:ne,monitorFromPoint:async function(e,n){return d("plugin:window|monitor_from_point",{x:e,y:n}).then(le)},primaryMonitor:async function(){return d("plugin:window|primary_monitor").then(le)}});function ue(){return new he(ne(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function ce(){return d("plugin:webview|get_all_webviews").then((e=>e.map((e=>new he(new re(e.windowLabel,{skip:!0}),e.label,{skip:!0})))))}const de=["tauri://created","tauri://error"];class he{constructor(e,n,t){this.window=e,this.label=n,this.listeners=Object.create(null),(null==t?void 0:t.skip)||d("plugin:webview|create_webview",{windowLabel:e.label,label:n,options:t}).then((async()=>this.emit("tauri://created"))).catch((async e=>this.emit("tauri://error",e)))}static async getByLabel(e){var n;return null!==(n=(await ce()).find((n=>n.label===e)))&&void 0!==n?n:null}static getCurrent(){return ue()}static async getAll(){return ce()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:I(e,n,{target:{kind:"Webview",label:this.label}})}async once(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:R(e,n,{target:{kind:"Webview",label:this.label}})}async emit(e,n){if(!de.includes(e))return S(e,n);for(const t of this.listeners[e]||[])t({event:e,id:-1,payload:n})}async emitTo(e,n,t){if(!de.includes(n))return L(e,n,t);for(const e of this.listeners[n]||[])e({event:n,id:-1,payload:t})}_handleTauriEvent(e,n){return!!de.includes(e)&&(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0)}async position(){return d("plugin:webview|webview_position",{label:this.label}).then((e=>new k(e)))}async size(){return d("plugin:webview|webview_size",{label:this.label}).then((e=>new m(e)))}async close(){return d("plugin:webview|close",{label:this.label})}async setSize(e){return d("plugin:webview|set_webview_size",{label:this.label,value:e instanceof v?e:new v(e)})}async setPosition(e){return d("plugin:webview|set_webview_position",{label:this.label,value:e instanceof A?e:new A(e)})}async setFocus(){return d("plugin:webview|set_webview_focus",{label:this.label})}async hide(){return d("plugin:webview|webview_hide",{label:this.label})}async show(){return d("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return d("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return d("plugin:webview|reparent",{label:this.label,window:"string"==typeof e?e:e.label})}async clearAllBrowsingData(){return d("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return d("plugin:webview|set_webview_background_color",{color:e})}async onDragDropEvent(e){const n=await this.listen(E.DRAG_ENTER,(n=>{e({...n,payload:{type:"enter",paths:n.payload.paths,position:new k(n.payload.position)}})})),t=await this.listen(E.DRAG_OVER,(n=>{e({...n,payload:{type:"over",position:new k(n.payload.position)}})})),i=await this.listen(E.DRAG_DROP,(n=>{e({...n,payload:{type:"drop",paths:n.payload.paths,position:new k(n.payload.position)}})})),r=await this.listen(E.DRAG_LEAVE,(n=>{e({...n,payload:{type:"leave"}})}));return()=>{n(),i(),t(),r()}}}var pe,we,ye=Object.freeze({__proto__:null,Webview:he,getAllWebviews:ce,getCurrentWebview:ue});function _e(){const e=ue();return new be(e.label,{skip:!0})}async function ge(){return d("plugin:window|get_all_windows").then((e=>e.map((e=>new be(e,{skip:!0})))))}class be{constructor(e,n={}){var t;this.label=e,this.listeners=Object.create(null),(null==n?void 0:n.skip)||d("plugin:webview|create_webview_window",{options:{...n,parent:"string"==typeof n.parent?n.parent:null===(t=n.parent)||void 0===t?void 0:t.label,label:e}}).then((async()=>this.emit("tauri://created"))).catch((async e=>this.emit("tauri://error",e)))}static async getByLabel(e){var n;const t=null!==(n=(await ge()).find((n=>n.label===e)))&&void 0!==n?n:null;return t?new be(t.label,{skip:!0}):null}static getCurrent(){return _e()}static async getAll(){return ge()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:I(e,n,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:R(e,n,{target:{kind:"WebviewWindow",label:this.label}})}async setBackgroundColor(e){return d("plugin:window|set_background_color",{color:e}).then((()=>d("plugin:webview|set_webview_background_color",{color:e})))}}pe=be,we=[re,he],(Array.isArray(we)?we:[we]).forEach((e=>{Object.getOwnPropertyNames(e.prototype).forEach((n=>{var t;"object"==typeof pe.prototype&&pe.prototype&&n in pe.prototype||Object.defineProperty(pe.prototype,n,null!==(t=Object.getOwnPropertyDescriptor(e.prototype,n))&&void 0!==t?t:Object.create(null))}))}));var me=Object.freeze({__proto__:null,WebviewWindow:be,getAllWebviewWindows:ge,getCurrentWebviewWindow:_e});return e.app=g,e.core=p,e.dpi=T,e.event=P,e.image=_,e.menu=H,e.mocks=J,e.path=Q,e.tray=X,e.webview=ye,e.webviewWindow=me,e.window=oe,e}({});window.__TAURI__=__TAURI_IIFE__; +var __TAURI_IIFE__=function(e){"use strict";function n(e,n,t,i){if("a"===t&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof n?e!==n||!i:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?i:"a"===t?i.call(e):i?i.value:n.get(e)}function t(e,n,t,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof n?e!==n||!r:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,t):r?r.value=t:n.set(e,t),t}var i,r,s,a;"function"==typeof SuppressedError&&SuppressedError;const l="__TAURI_TO_IPC_KEY__";function o(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}class u{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,i.set(this,(()=>{})),r.set(this,0),s.set(this,[]),this.id=o((({message:e,id:a})=>{if(a==n(this,r,"f"))for(n(this,i,"f").call(this,e),t(this,r,n(this,r,"f")+1,"f");n(this,r,"f")in n(this,s,"f");){const e=n(this,s,"f")[n(this,r,"f")];n(this,i,"f").call(this,e),delete n(this,s,"f")[n(this,r,"f")],t(this,r,n(this,r,"f")+1,"f")}else n(this,s,"f")[a]=e}))}set onmessage(e){t(this,i,e,"f")}get onmessage(){return n(this,i,"f")}[(i=new WeakMap,r=new WeakMap,s=new WeakMap,l)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[l]()}}class c{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return d(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function d(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}class h{get rid(){return n(this,a,"f")}constructor(e){a.set(this,void 0),t(this,a,e,"f")}async close(){return d("plugin:resources|close",{rid:this.rid})}}a=new WeakMap;var p=Object.freeze({__proto__:null,Channel:u,PluginListener:c,Resource:h,SERIALIZE_TO_IPC_FN:l,addPluginListener:async function(e,n,t){const i=new u;return i.onmessage=t,d(`plugin:${e}|registerListener`,{event:n,handler:i}).then((()=>new c(e,n,i.id)))},checkPermissions:async function(e){return d(`plugin:${e}|check_permissions`)},convertFileSrc:function(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)},invoke:d,isTauri:function(){return"isTauri"in window&&!!window.isTauri},requestPermissions:async function(e){return d(`plugin:${e}|request_permissions`)},transformCallback:o});class w extends h{constructor(e){super(e)}static async new(e,n,t){return d("plugin:image|new",{rgba:y(e),width:n,height:t}).then((e=>new w(e)))}static async fromBytes(e){return d("plugin:image|from_bytes",{bytes:y(e)}).then((e=>new w(e)))}static async fromPath(e){return d("plugin:image|from_path",{path:e}).then((e=>new w(e)))}async rgba(){return d("plugin:image|rgba",{rid:this.rid}).then((e=>new Uint8Array(e)))}async size(){return d("plugin:image|size",{rid:this.rid})}}function y(e){return null==e?null:"string"==typeof e?e:e instanceof w?e.rid:e}var _=Object.freeze({__proto__:null,Image:w,transformImage:y});var g=Object.freeze({__proto__:null,defaultWindowIcon:async function(){return d("plugin:app|default_window_icon").then((e=>e?new w(e):null))},getName:async function(){return d("plugin:app|name")},getTauriVersion:async function(){return d("plugin:app|tauri_version")},getVersion:async function(){return d("plugin:app|version")},hide:async function(){return d("plugin:app|app_hide")},setTheme:async function(e){return d("plugin:app|set_app_theme",{theme:e})},show:async function(){return d("plugin:app|app_show")}});class b{constructor(...e){this.type="Logical",1===e.length?"Logical"in e[0]?(this.width=e[0].Logical.width,this.height=e[0].Logical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toPhysical(e){return new m(this.width*e,this.height*e)}[l](){return{width:this.width,height:this.height}}toJSON(){return this[l]()}}class m{constructor(...e){this.type="Physical",1===e.length?"Physical"in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new b(this.width/e,this.height/e)}[l](){return{width:this.width,height:this.height}}toJSON(){return this[l]()}}class v{constructor(e){this.size=e}toLogical(e){return this.size instanceof b?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof m?this.size:this.size.toPhysical(e)}[l](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[l]()}}class f{constructor(...e){this.type="Logical",1===e.length?"Logical"in e[0]?(this.x=e[0].Logical.x,this.y=e[0].Logical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toPhysical(e){return new k(this.x*e,this.y*e)}[l](){return{x:this.x,y:this.y}}toJSON(){return this[l]()}}class k{constructor(...e){this.type="Physical",1===e.length?"Physical"in e[0]?(this.x=e[0].Physical.x,this.y=e[0].Physical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toLogical(e){return new f(this.x/e,this.y/e)}[l](){return{x:this.x,y:this.y}}toJSON(){return this[l]()}}class A{constructor(e){this.position=e}toLogical(e){return this.position instanceof f?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof k?this.position:this.position.toPhysical(e)}[l](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[l]()}}var E,T=Object.freeze({__proto__:null,LogicalPosition:f,LogicalSize:b,PhysicalPosition:k,PhysicalSize:m,Position:A,Size:v});async function D(e,n){await d("plugin:event|unlisten",{event:e,eventId:n})}async function I(e,n,t){var i;const r="string"==typeof(null==t?void 0:t.target)?{kind:"AnyLabel",label:t.target}:null!==(i=null==t?void 0:t.target)&&void 0!==i?i:{kind:"Any"};return d("plugin:event|listen",{event:e,target:r,handler:o(n)}).then((n=>async()=>D(e,n)))}async function R(e,n,t){return I(e,(t=>{D(e,t.id),n(t)}),t)}async function S(e,n){await d("plugin:event|emit",{event:e,payload:n})}async function L(e,n,t){const i="string"==typeof e?{kind:"AnyLabel",label:e}:e;await d("plugin:event|emit_to",{target:i,event:n,payload:t})}!function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"}(E||(E={}));var x,C,N,P=Object.freeze({__proto__:null,get TauriEvent(){return E},emit:S,emitTo:L,listen:I,once:R});function z(e){var n;if("items"in e)e.items=null===(n=e.items)||void 0===n?void 0:n.map((e=>"rid"in e?e:z(e)));else if("action"in e&&e.action){const n=new u;return n.onmessage=e.action,delete e.action,{...e,handler:n}}return e}async function W(e,n){const t=new u;if(n&&"object"==typeof n&&("action"in n&&n.action&&(t.onmessage=n.action,delete n.action),"item"in n&&n.item&&"object"==typeof n.item&&"About"in n.item&&n.item.About&&"object"==typeof n.item.About&&"icon"in n.item.About&&n.item.About.icon&&(n.item.About.icon=y(n.item.About.icon)),"icon"in n&&n.icon&&(n.icon=y(n.icon)),"items"in n&&n.items)){function i(e){var n;return"rid"in e?[e.rid,e.kind]:("item"in e&&"object"==typeof e.item&&(null===(n=e.item.About)||void 0===n?void 0:n.icon)&&(e.item.About.icon=y(e.item.About.icon)),"icon"in e&&e.icon&&(e.icon=y(e.icon)),"items"in e&&e.items&&(e.items=e.items.map(i)),z(e))}n.items=n.items.map(i)}return d("plugin:menu|new",{kind:e,options:n,handler:t})}class O extends h{get id(){return n(this,x,"f")}get kind(){return n(this,C,"f")}constructor(e,n,i){super(e),x.set(this,void 0),C.set(this,void 0),t(this,x,n,"f"),t(this,C,i,"f")}}x=new WeakMap,C=new WeakMap;class F extends O{constructor(e,n){super(e,n,"MenuItem")}static async new(e){return W("MenuItem",e).then((([e,n])=>new F(e,n)))}async text(){return d("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return d("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return d("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return d("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return d("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}}class M extends O{constructor(e,n){super(e,n,"Check")}static async new(e){return W("Check",e).then((([e,n])=>new M(e,n)))}async text(){return d("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return d("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return d("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return d("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return d("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async isChecked(){return d("plugin:menu|is_checked",{rid:this.rid})}async setChecked(e){return d("plugin:menu|set_checked",{rid:this.rid,checked:e})}}!function(e){e.Add="Add",e.Advanced="Advanced",e.Bluetooth="Bluetooth",e.Bookmarks="Bookmarks",e.Caution="Caution",e.ColorPanel="ColorPanel",e.ColumnView="ColumnView",e.Computer="Computer",e.EnterFullScreen="EnterFullScreen",e.Everyone="Everyone",e.ExitFullScreen="ExitFullScreen",e.FlowView="FlowView",e.Folder="Folder",e.FolderBurnable="FolderBurnable",e.FolderSmart="FolderSmart",e.FollowLinkFreestanding="FollowLinkFreestanding",e.FontPanel="FontPanel",e.GoLeft="GoLeft",e.GoRight="GoRight",e.Home="Home",e.IChatTheater="IChatTheater",e.IconView="IconView",e.Info="Info",e.InvalidDataFreestanding="InvalidDataFreestanding",e.LeftFacingTriangle="LeftFacingTriangle",e.ListView="ListView",e.LockLocked="LockLocked",e.LockUnlocked="LockUnlocked",e.MenuMixedState="MenuMixedState",e.MenuOnState="MenuOnState",e.MobileMe="MobileMe",e.MultipleDocuments="MultipleDocuments",e.Network="Network",e.Path="Path",e.PreferencesGeneral="PreferencesGeneral",e.QuickLook="QuickLook",e.RefreshFreestanding="RefreshFreestanding",e.Refresh="Refresh",e.Remove="Remove",e.RevealFreestanding="RevealFreestanding",e.RightFacingTriangle="RightFacingTriangle",e.Share="Share",e.Slideshow="Slideshow",e.SmartBadge="SmartBadge",e.StatusAvailable="StatusAvailable",e.StatusNone="StatusNone",e.StatusPartiallyAvailable="StatusPartiallyAvailable",e.StatusUnavailable="StatusUnavailable",e.StopProgressFreestanding="StopProgressFreestanding",e.StopProgress="StopProgress",e.TrashEmpty="TrashEmpty",e.TrashFull="TrashFull",e.User="User",e.UserAccounts="UserAccounts",e.UserGroup="UserGroup",e.UserGuest="UserGuest"}(N||(N={}));class U extends O{constructor(e,n){super(e,n,"Icon")}static async new(e){return W("Icon",e).then((([e,n])=>new U(e,n)))}async text(){return d("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return d("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return d("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return d("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return d("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async setIcon(e){return d("plugin:menu|set_icon",{rid:this.rid,icon:y(e)})}}class B extends O{constructor(e,n){super(e,n,"Predefined")}static async new(e){return W("Predefined",e).then((([e,n])=>new B(e,n)))}async text(){return d("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return d("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}}function j([e,n,t]){switch(t){case"Submenu":return new V(e,n);case"Predefined":return new B(e,n);case"Check":return new M(e,n);case"Icon":return new U(e,n);default:return new F(e,n)}}class V extends O{constructor(e,n){super(e,n,"Submenu")}static async new(e){return W("Submenu",e).then((([e,n])=>new V(e,n)))}async text(){return d("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return d("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return d("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return d("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async append(e){return d("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(e)?e:[e]).map((e=>"rid"in e?[e.rid,e.kind]:e))})}async prepend(e){return d("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(e)?e:[e]).map((e=>"rid"in e?[e.rid,e.kind]:e))})}async insert(e,n){return d("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(e)?e:[e]).map((e=>"rid"in e?[e.rid,e.kind]:e)),position:n})}async remove(e){return d("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return d("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(j)}async items(){return d("plugin:menu|items",{rid:this.rid,kind:this.kind}).then((e=>e.map(j)))}async get(e){return d("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then((e=>e?j(e):null))}async popup(e,n){var t;return d("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:null!==(t=null==n?void 0:n.label)&&void 0!==t?t:null,at:e instanceof A?e:e?new A(e):null})}async setAsWindowsMenuForNSApp(){return d("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return d("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}}class G extends O{constructor(e,n){super(e,n,"Menu")}static async new(e){return W("Menu",e).then((([e,n])=>new G(e,n)))}static async default(){return d("plugin:menu|create_default").then((([e,n])=>new G(e,n)))}async append(e){return d("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(e)?e:[e]).map((e=>"rid"in e?[e.rid,e.kind]:e))})}async prepend(e){return d("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(e)?e:[e]).map((e=>"rid"in e?[e.rid,e.kind]:e))})}async insert(e,n){return d("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(e)?e:[e]).map((e=>"rid"in e?[e.rid,e.kind]:e)),position:n})}async remove(e){return d("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return d("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(j)}async items(){return d("plugin:menu|items",{rid:this.rid,kind:this.kind}).then((e=>e.map(j)))}async get(e){return d("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then((e=>e?j(e):null))}async popup(e,n){var t;return d("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:null!==(t=null==n?void 0:n.label)&&void 0!==t?t:null,at:e instanceof A?e:e?new A(e):null})}async setAsAppMenu(){return d("plugin:menu|set_as_app_menu",{rid:this.rid}).then((e=>e?new G(e[0],e[1]):null))}async setAsWindowMenu(e){var n;return d("plugin:menu|set_as_window_menu",{rid:this.rid,window:null!==(n=null==e?void 0:e.label)&&void 0!==n?n:null}).then((e=>e?new G(e[0],e[1]):null))}}var H=Object.freeze({__proto__:null,CheckMenuItem:M,IconMenuItem:U,Menu:G,MenuItem:F,get NativeIcon(){return N},PredefinedMenuItem:B,Submenu:V,itemFromKind:j});function $(){var e;window.__TAURI_INTERNALS__=null!==(e=window.__TAURI_INTERNALS__)&&void 0!==e?e:{}}var q,J=Object.freeze({__proto__:null,clearMocks:function(){var e,n,t;"object"==typeof window.__TAURI_INTERNALS__&&((null===(e=window.__TAURI_INTERNALS__)||void 0===e?void 0:e.convertFileSrc)&&delete window.__TAURI_INTERNALS__.convertFileSrc,(null===(n=window.__TAURI_INTERNALS__)||void 0===n?void 0:n.invoke)&&delete window.__TAURI_INTERNALS__.invoke,(null===(t=window.__TAURI_INTERNALS__)||void 0===t?void 0:t.metadata)&&delete window.__TAURI_INTERNALS__.metadata)},mockConvertFileSrc:function(e){$(),window.__TAURI_INTERNALS__.convertFileSrc=function(n,t="asset"){const i=encodeURIComponent(n);return"windows"===e?`http://${t}.localhost/${i}`:`${t}://localhost/${i}`}},mockIPC:function(e){$(),window.__TAURI_INTERNALS__.transformCallback=function(e,n=!1){const t=window.crypto.getRandomValues(new Uint32Array(1))[0],i=`_${t}`;return Object.defineProperty(window,i,{value:t=>(n&&Reflect.deleteProperty(window,i),e&&e(t)),writable:!1,configurable:!0}),t},window.__TAURI_INTERNALS__.invoke=async function(n,t,i){return e(n,t)}},mockWindows:function(e,...n){$(),window.__TAURI_INTERNALS__.metadata={currentWindow:{label:e},currentWebview:{windowLabel:e,label:e}}}});!function(e){e[e.Audio=1]="Audio",e[e.Cache=2]="Cache",e[e.Config=3]="Config",e[e.Data=4]="Data",e[e.LocalData=5]="LocalData",e[e.Document=6]="Document",e[e.Download=7]="Download",e[e.Picture=8]="Picture",e[e.Public=9]="Public",e[e.Video=10]="Video",e[e.Resource=11]="Resource",e[e.Temp=12]="Temp",e[e.AppConfig=13]="AppConfig",e[e.AppData=14]="AppData",e[e.AppLocalData=15]="AppLocalData",e[e.AppCache=16]="AppCache",e[e.AppLog=17]="AppLog",e[e.Desktop=18]="Desktop",e[e.Executable=19]="Executable",e[e.Font=20]="Font",e[e.Home=21]="Home",e[e.Runtime=22]="Runtime",e[e.Template=23]="Template"}(q||(q={}));var Q=Object.freeze({__proto__:null,get BaseDirectory(){return q},appCacheDir:async function(){return d("plugin:path|resolve_directory",{directory:q.AppCache})},appConfigDir:async function(){return d("plugin:path|resolve_directory",{directory:q.AppConfig})},appDataDir:async function(){return d("plugin:path|resolve_directory",{directory:q.AppData})},appLocalDataDir:async function(){return d("plugin:path|resolve_directory",{directory:q.AppLocalData})},appLogDir:async function(){return d("plugin:path|resolve_directory",{directory:q.AppLog})},audioDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Audio})},basename:async function(e,n){return d("plugin:path|basename",{path:e,ext:n})},cacheDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Cache})},configDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Config})},dataDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Data})},delimiter:function(){return window.__TAURI_INTERNALS__.plugins.path.delimiter},desktopDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Desktop})},dirname:async function(e){return d("plugin:path|dirname",{path:e})},documentDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Document})},downloadDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Download})},executableDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Executable})},extname:async function(e){return d("plugin:path|extname",{path:e})},fontDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Font})},homeDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Home})},isAbsolute:async function(e){return d("plugin:path|is_absolute",{path:e})},join:async function(...e){return d("plugin:path|join",{paths:e})},localDataDir:async function(){return d("plugin:path|resolve_directory",{directory:q.LocalData})},normalize:async function(e){return d("plugin:path|normalize",{path:e})},pictureDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Picture})},publicDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Public})},resolve:async function(...e){return d("plugin:path|resolve",{paths:e})},resolveResource:async function(e){return d("plugin:path|resolve_directory",{directory:q.Resource,path:e})},resourceDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Resource})},runtimeDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Runtime})},sep:function(){return window.__TAURI_INTERNALS__.plugins.path.sep},tempDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Temp})},templateDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Template})},videoDir:async function(){return d("plugin:path|resolve_directory",{directory:q.Video})}});class Z extends h{constructor(e,n){super(e),this.id=n}static async getById(e){return d("plugin:tray|get_by_id",{id:e}).then((n=>n?new Z(n,e):null))}static async removeById(e){return d("plugin:tray|remove_by_id",{id:e})}static async new(e){(null==e?void 0:e.menu)&&(e.menu=[e.menu.rid,e.menu.kind]),(null==e?void 0:e.icon)&&(e.icon=y(e.icon));const n=new u;if(null==e?void 0:e.action){const t=e.action;n.onmessage=e=>t(function(e){const n=e;return n.position=new k(e.position),n.rect.position=new k(e.rect.position),n.rect.size=new m(e.rect.size),n}(e)),delete e.action}return d("plugin:tray|new",{options:null!=e?e:{},handler:n}).then((([e,n])=>new Z(e,n)))}async setIcon(e){let n=null;return e&&(n=y(e)),d("plugin:tray|set_icon",{rid:this.rid,icon:n})}async setMenu(e){return e&&(e=[e.rid,e.kind]),d("plugin:tray|set_menu",{rid:this.rid,menu:e})}async setTooltip(e){return d("plugin:tray|set_tooltip",{rid:this.rid,tooltip:e})}async setTitle(e){return d("plugin:tray|set_title",{rid:this.rid,title:e})}async setVisible(e){return d("plugin:tray|set_visible",{rid:this.rid,visible:e})}async setTempDirPath(e){return d("plugin:tray|set_temp_dir_path",{rid:this.rid,path:e})}async setIconAsTemplate(e){return d("plugin:tray|set_icon_as_template",{rid:this.rid,asTemplate:e})}async setMenuOnLeftClick(e){return d("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}async setShowMenuOnLeftClick(e){return d("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}}var K,Y,X=Object.freeze({__proto__:null,TrayIcon:Z});!function(e){e[e.Critical=1]="Critical",e[e.Informational=2]="Informational"}(K||(K={}));class ee{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}function ne(){return new re(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function te(){return d("plugin:window|get_all_windows").then((e=>e.map((e=>new re(e,{skip:!0})))))}!function(e){e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error"}(Y||(Y={}));const ie=["tauri://created","tauri://error"];class re{constructor(e,n={}){var t;this.label=e,this.listeners=Object.create(null),(null==n?void 0:n.skip)||d("plugin:window|create",{options:{...n,parent:"string"==typeof n.parent?n.parent:null===(t=n.parent)||void 0===t?void 0:t.label,label:e}}).then((async()=>this.emit("tauri://created"))).catch((async e=>this.emit("tauri://error",e)))}static async getByLabel(e){var n;return null!==(n=(await te()).find((n=>n.label===e)))&&void 0!==n?n:null}static getCurrent(){return ne()}static async getAll(){return te()}static async getFocusedWindow(){for(const e of await te())if(await e.isFocused())return e;return null}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:I(e,n,{target:{kind:"Window",label:this.label}})}async once(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:R(e,n,{target:{kind:"Window",label:this.label}})}async emit(e,n){if(!ie.includes(e))return S(e,n);for(const t of this.listeners[e]||[])t({event:e,id:-1,payload:n})}async emitTo(e,n,t){if(!ie.includes(n))return L(e,n,t);for(const e of this.listeners[n]||[])e({event:n,id:-1,payload:t})}_handleTauriEvent(e,n){return!!ie.includes(e)&&(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0)}async scaleFactor(){return d("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return d("plugin:window|inner_position",{label:this.label}).then((e=>new k(e)))}async outerPosition(){return d("plugin:window|outer_position",{label:this.label}).then((e=>new k(e)))}async innerSize(){return d("plugin:window|inner_size",{label:this.label}).then((e=>new m(e)))}async outerSize(){return d("plugin:window|outer_size",{label:this.label}).then((e=>new m(e)))}async isFullscreen(){return d("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return d("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return d("plugin:window|is_maximized",{label:this.label})}async isFocused(){return d("plugin:window|is_focused",{label:this.label})}async isDecorated(){return d("plugin:window|is_decorated",{label:this.label})}async isResizable(){return d("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return d("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return d("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return d("plugin:window|is_closable",{label:this.label})}async isVisible(){return d("plugin:window|is_visible",{label:this.label})}async title(){return d("plugin:window|title",{label:this.label})}async theme(){return d("plugin:window|theme",{label:this.label})}async center(){return d("plugin:window|center",{label:this.label})}async requestUserAttention(e){let n=null;return e&&(n=e===K.Critical?{type:"Critical"}:{type:"Informational"}),d("plugin:window|request_user_attention",{label:this.label,value:n})}async setResizable(e){return d("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return d("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return d("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return d("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return d("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return d("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return d("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return d("plugin:window|maximize",{label:this.label})}async unmaximize(){return d("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return d("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return d("plugin:window|minimize",{label:this.label})}async unminimize(){return d("plugin:window|unminimize",{label:this.label})}async show(){return d("plugin:window|show",{label:this.label})}async hide(){return d("plugin:window|hide",{label:this.label})}async close(){return d("plugin:window|close",{label:this.label})}async destroy(){return d("plugin:window|destroy",{label:this.label})}async setDecorations(e){return d("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return d("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return d("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return d("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return d("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return d("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return d("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return d("plugin:window|set_size",{label:this.label,value:e instanceof v?e:new v(e)})}async setMinSize(e){return d("plugin:window|set_min_size",{label:this.label,value:e instanceof v?e:e?new v(e):null})}async setMaxSize(e){return d("plugin:window|set_max_size",{label:this.label,value:e instanceof v?e:e?new v(e):null})}async setSizeConstraints(e){function n(e){return e?{Logical:e}:null}return d("plugin:window|set_size_constraints",{label:this.label,value:{minWidth:n(null==e?void 0:e.minWidth),minHeight:n(null==e?void 0:e.minHeight),maxWidth:n(null==e?void 0:e.maxWidth),maxHeight:n(null==e?void 0:e.maxHeight)}})}async setPosition(e){return d("plugin:window|set_position",{label:this.label,value:e instanceof A?e:new A(e)})}async setFullscreen(e){return d("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return d("plugin:window|set_focus",{label:this.label})}async setIcon(e){return d("plugin:window|set_icon",{label:this.label,value:y(e)})}async setSkipTaskbar(e){return d("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return d("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return d("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return d("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return d("plugin:window|set_background_color",{color:e})}async setBackgroundThrottling(e){return d("plugin:window|set_background_throttling",{label:this.label,value:e})}async setCursorPosition(e){return d("plugin:window|set_cursor_position",{label:this.label,value:e instanceof A?e:new A(e)})}async setIgnoreCursorEvents(e){return d("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return d("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return d("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return d("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return d("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return d("plugin:window|set_overlay_icon",{label:this.label,value:e?y(e):void 0})}async setProgressBar(e){return d("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return d("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return d("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return d("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(E.WINDOW_RESIZED,(n=>{n.payload=new m(n.payload),e(n)}))}async onMoved(e){return this.listen(E.WINDOW_MOVED,(n=>{n.payload=new k(n.payload),e(n)}))}async onCloseRequested(e){return this.listen(E.WINDOW_CLOSE_REQUESTED,(async n=>{const t=new ee(n);await e(t),t.isPreventDefault()||await this.destroy()}))}async onDragDropEvent(e){const n=await this.listen(E.DRAG_ENTER,(n=>{e({...n,payload:{type:"enter",paths:n.payload.paths,position:new k(n.payload.position)}})})),t=await this.listen(E.DRAG_OVER,(n=>{e({...n,payload:{type:"over",position:new k(n.payload.position)}})})),i=await this.listen(E.DRAG_DROP,(n=>{e({...n,payload:{type:"drop",paths:n.payload.paths,position:new k(n.payload.position)}})})),r=await this.listen(E.DRAG_LEAVE,(n=>{e({...n,payload:{type:"leave"}})}));return()=>{n(),i(),t(),r()}}async onFocusChanged(e){const n=await this.listen(E.WINDOW_FOCUS,(n=>{e({...n,payload:!0})})),t=await this.listen(E.WINDOW_BLUR,(n=>{e({...n,payload:!1})}));return()=>{n(),t()}}async onScaleChanged(e){return this.listen(E.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(E.WINDOW_THEME_CHANGED,e)}}var se,ae,le;function oe(e){return null===e?null:{name:e.name,scaleFactor:e.scaleFactor,position:new k(e.position),size:new m(e.size)}}!function(e){e.Disabled="disabled",e.Throttle="throttle",e.Suspend="suspend"}(se||(se={})),function(e){e.AppearanceBased="appearanceBased",e.Light="light",e.Dark="dark",e.MediumLight="mediumLight",e.UltraDark="ultraDark",e.Titlebar="titlebar",e.Selection="selection",e.Menu="menu",e.Popover="popover",e.Sidebar="sidebar",e.HeaderView="headerView",e.Sheet="sheet",e.WindowBackground="windowBackground",e.HudWindow="hudWindow",e.FullScreenUI="fullScreenUI",e.Tooltip="tooltip",e.ContentBackground="contentBackground",e.UnderWindowBackground="underWindowBackground",e.UnderPageBackground="underPageBackground",e.Mica="mica",e.Blur="blur",e.Acrylic="acrylic",e.Tabbed="tabbed",e.TabbedDark="tabbedDark",e.TabbedLight="tabbedLight"}(ae||(ae={})),function(e){e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive"}(le||(le={}));var ue=Object.freeze({__proto__:null,CloseRequestedEvent:ee,get Effect(){return ae},get EffectState(){return le},LogicalPosition:f,LogicalSize:b,PhysicalPosition:k,PhysicalSize:m,get ProgressBarStatus(){return Y},get UserAttentionType(){return K},Window:re,availableMonitors:async function(){return d("plugin:window|available_monitors").then((e=>e.map(oe)))},currentMonitor:async function(){return d("plugin:window|current_monitor").then(oe)},cursorPosition:async function(){return d("plugin:window|cursor_position").then((e=>new k(e)))},getAllWindows:te,getCurrentWindow:ne,monitorFromPoint:async function(e,n){return d("plugin:window|monitor_from_point",{x:e,y:n}).then(oe)},primaryMonitor:async function(){return d("plugin:window|primary_monitor").then(oe)}});function ce(){return new pe(ne(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function de(){return d("plugin:webview|get_all_webviews").then((e=>e.map((e=>new pe(new re(e.windowLabel,{skip:!0}),e.label,{skip:!0})))))}const he=["tauri://created","tauri://error"];class pe{constructor(e,n,t){this.window=e,this.label=n,this.listeners=Object.create(null),(null==t?void 0:t.skip)||d("plugin:webview|create_webview",{windowLabel:e.label,label:n,options:t}).then((async()=>this.emit("tauri://created"))).catch((async e=>this.emit("tauri://error",e)))}static async getByLabel(e){var n;return null!==(n=(await de()).find((n=>n.label===e)))&&void 0!==n?n:null}static getCurrent(){return ce()}static async getAll(){return de()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:I(e,n,{target:{kind:"Webview",label:this.label}})}async once(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:R(e,n,{target:{kind:"Webview",label:this.label}})}async emit(e,n){if(!he.includes(e))return S(e,n);for(const t of this.listeners[e]||[])t({event:e,id:-1,payload:n})}async emitTo(e,n,t){if(!he.includes(n))return L(e,n,t);for(const e of this.listeners[n]||[])e({event:n,id:-1,payload:t})}_handleTauriEvent(e,n){return!!he.includes(e)&&(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0)}async position(){return d("plugin:webview|webview_position",{label:this.label}).then((e=>new k(e)))}async size(){return d("plugin:webview|webview_size",{label:this.label}).then((e=>new m(e)))}async close(){return d("plugin:webview|close",{label:this.label})}async setSize(e){return d("plugin:webview|set_webview_size",{label:this.label,value:e instanceof v?e:new v(e)})}async setPosition(e){return d("plugin:webview|set_webview_position",{label:this.label,value:e instanceof A?e:new A(e)})}async setFocus(){return d("plugin:webview|set_webview_focus",{label:this.label})}async hide(){return d("plugin:webview|webview_hide",{label:this.label})}async show(){return d("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return d("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return d("plugin:webview|reparent",{label:this.label,window:"string"==typeof e?e:e.label})}async clearAllBrowsingData(){return d("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return d("plugin:webview|set_webview_background_color",{color:e})}async onDragDropEvent(e){const n=await this.listen(E.DRAG_ENTER,(n=>{e({...n,payload:{type:"enter",paths:n.payload.paths,position:new k(n.payload.position)}})})),t=await this.listen(E.DRAG_OVER,(n=>{e({...n,payload:{type:"over",position:new k(n.payload.position)}})})),i=await this.listen(E.DRAG_DROP,(n=>{e({...n,payload:{type:"drop",paths:n.payload.paths,position:new k(n.payload.position)}})})),r=await this.listen(E.DRAG_LEAVE,(n=>{e({...n,payload:{type:"leave"}})}));return()=>{n(),i(),t(),r()}}}var we,ye,_e=Object.freeze({__proto__:null,Webview:pe,getAllWebviews:de,getCurrentWebview:ce});function ge(){const e=ce();return new me(e.label,{skip:!0})}async function be(){return d("plugin:window|get_all_windows").then((e=>e.map((e=>new me(e,{skip:!0})))))}class me{constructor(e,n={}){var t;this.label=e,this.listeners=Object.create(null),(null==n?void 0:n.skip)||d("plugin:webview|create_webview_window",{options:{...n,parent:"string"==typeof n.parent?n.parent:null===(t=n.parent)||void 0===t?void 0:t.label,label:e}}).then((async()=>this.emit("tauri://created"))).catch((async e=>this.emit("tauri://error",e)))}static async getByLabel(e){var n;const t=null!==(n=(await be()).find((n=>n.label===e)))&&void 0!==n?n:null;return t?new me(t.label,{skip:!0}):null}static getCurrent(){return ge()}static async getAll(){return be()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:I(e,n,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:R(e,n,{target:{kind:"WebviewWindow",label:this.label}})}async setBackgroundColor(e){return d("plugin:window|set_background_color",{color:e}).then((()=>d("plugin:webview|set_webview_background_color",{color:e})))}}we=me,ye=[re,pe],(Array.isArray(ye)?ye:[ye]).forEach((e=>{Object.getOwnPropertyNames(e.prototype).forEach((n=>{var t;"object"==typeof we.prototype&&we.prototype&&n in we.prototype||Object.defineProperty(we.prototype,n,null!==(t=Object.getOwnPropertyDescriptor(e.prototype,n))&&void 0!==t?t:Object.create(null))}))}));var ve=Object.freeze({__proto__:null,WebviewWindow:me,getAllWebviewWindows:be,getCurrentWebviewWindow:ge});return e.app=g,e.core=p,e.dpi=T,e.event=P,e.image=_,e.menu=H,e.mocks=J,e.path=Q,e.tray=X,e.webview=_e,e.webviewWindow=ve,e.window=ue,e}({});window.__TAURI__=__TAURI_IIFE__; diff --git a/crates/tauri/src/webview/mod.rs b/crates/tauri/src/webview/mod.rs index 9e4823867d87..d8d0f83e40ea 100644 --- a/crates/tauri/src/webview/mod.rs +++ b/crates/tauri/src/webview/mod.rs @@ -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::{ @@ -868,7 +868,7 @@ fn main() { self } - /// Set whether background throttling should be disabled. + /// Change the default background throttling behaviour. /// /// By default, browsers 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 permanently suspend all tasks until the documents visibility state @@ -882,8 +882,8 @@ fn main() { /// /// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 #[must_use] - pub fn disable_background_throttling(mut self, disabled: bool) -> Self { - self.webview_attributes.disable_background_throttling = disabled; + pub fn background_throttling(mut self, policy: Option) -> Self { + self.webview_attributes.background_throttling = policy; self } } diff --git a/crates/tauri/src/webview/plugin.rs b/crates/tauri/src/webview/plugin.rs index 29df19843384..afdcaac74b92 100644 --- a/crates/tauri/src/webview/plugin.rs +++ b/crates/tauri/src/webview/plugin.rs @@ -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::{ @@ -49,7 +49,7 @@ mod desktop_commands { #[serde(default)] zoom_hotkeys_enabled: bool, #[serde(default)] - disable_background_throttling: bool, + background_throttling: Option, } #[cfg(feature = "unstable")] @@ -65,8 +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.disable_background_throttling = - config.disable_background_throttling; + builder.webview_attributes.background_throttling = config.background_throttling; builder } } diff --git a/crates/tauri/src/webview/webview_window.rs b/crates/tauri/src/webview/webview_window.rs index 36b8b18c6017..00da04a35a7e 100644 --- a/crates/tauri/src/webview/webview_window.rs +++ b/crates/tauri/src/webview/webview_window.rs @@ -29,7 +29,7 @@ use crate::{ }; use serde::Serialize; use tauri_utils::{ - config::{Color, WebviewUrl, WindowConfig}, + config::{BackgroundThrottlingPolicy, Color, WebviewUrl, WindowConfig}, Theme, }; use url::Url; @@ -978,7 +978,7 @@ impl> WebviewWindowBuilder<'_, R, M> { self } - /// Set whether background throttling should be disabled. + /// Change the default background throttling behaviour. /// /// By default, browsers 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 permanently suspend all tasks until the documents visibility state @@ -992,8 +992,8 @@ impl> WebviewWindowBuilder<'_, R, M> { /// /// see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 #[must_use] - pub fn disable_background_throttling(mut self, disabled: bool) -> Self { - self.webview_builder = self.webview_builder.disable_background_throttling(disabled); + pub fn background_throttling(mut self, policy: Option) -> Self { + self.webview_builder = self.webview_builder.background_throttling(policy); self } } diff --git a/packages/api/src/webview.ts b/packages/api/src/webview.ts index bb153cdbfbba..4b236caf4bfd 100644 --- a/packages/api/src/webview.ts +++ b/packages/api/src/webview.ts @@ -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. */ @@ -768,7 +773,7 @@ interface WebviewOptions { */ backgroundColor?: Color - /** Set whether background throttling should be disabled. + /** Change the default background throttling behaviour. * * By default, browsers 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 permanently suspend all tasks until the documents visibility state @@ -779,13 +784,13 @@ interface WebviewOptions { * - **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.2.0 - * + * */ - disableBackgroundThrottling?: boolean + backgroundThrottling?: BackgroundThrottlingPolicy } export { Webview, getCurrentWebview, getAllWebviews } diff --git a/packages/api/src/window.ts b/packages/api/src/window.ts index 105ac2f878e3..221df3b55978 100644 --- a/packages/api/src/window.ts +++ b/packages/api/src/window.ts @@ -1533,7 +1533,7 @@ class Window { return invoke('plugin:window|set_background_color', { color }) } - /** Set whether background throttling should be disabled. + /** Change the default background throttling behaviour. * * By default, browsers 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 permanently suspend all tasks until the documents visibility state @@ -1544,16 +1544,18 @@ class Window { * - **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.2.0 - * + * */ - async setDisableBackgroundThrottling(disable: boolean): Promise { - return invoke('plugin:window|set_disable_background_throttling', { + async setBackgroundThrottling( + policy: BackgroundThrottlingPolicy + ): Promise { + return invoke('plugin:window|set_background_throttling', { label: this.label, - value: disable + value: policy }) } @@ -2045,6 +2047,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 * @@ -2363,7 +2376,7 @@ interface WindowOptions { */ backgroundColor?: Color /** - * Set whether background throttling should be disabled + * Change the default background throttling behaviour * * #### Platform-specific * @@ -2375,7 +2388,7 @@ interface WindowOptions { * * @since 2.2.0 */ - disableBackgroundThrottling?: boolean + backgroundThrottling?: BackgroundThrottlingPolicy } function mapMonitor(m: Monitor | null): Monitor | null { @@ -2498,5 +2511,6 @@ export type { ScaleFactorChanged, WindowOptions, Color, + BackgroundThrottlingPolicy, DragDropEvent } From 068be379b40aa1fbc76784120cb54aeb1cf164a4 Mon Sep 17 00:00:00 2001 From: Bastian Kistner Date: Wed, 8 Jan 2025 12:44:02 +0100 Subject: [PATCH 8/9] chore: do not use an option for throttling policy --- crates/tauri-runtime-wry/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/tauri-runtime-wry/src/lib.rs b/crates/tauri-runtime-wry/src/lib.rs index 9703729944dd..4fd76a46d059 100644 --- a/crates/tauri-runtime-wry/src/lib.rs +++ b/crates/tauri-runtime-wry/src/lib.rs @@ -4180,7 +4180,6 @@ fn create_webview( .with_accept_first_mouse(webview_attributes.accept_first_mouse) .with_incognito(webview_attributes.incognito) .with_clipboard(webview_attributes.clipboard) - .with_background_throttling(webview_attributes.background_throttling.map(|p| p.into())) .with_hotkeys_zoom(webview_attributes.zoom_hotkeys_enabled); #[cfg(any(target_os = "windows", target_os = "android"))] @@ -4188,6 +4187,10 @@ fn create_webview( 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(background_throttling.into()); + } + if let Some(color) = webview_attributes.background_color { webview_builder = webview_builder.with_background_color(color.into()); } From ce3cb337232821ad257dd0da7d3401ff15f03c48 Mon Sep 17 00:00:00 2001 From: Bastian Kistner Date: Wed, 8 Jan 2025 12:57:54 +0100 Subject: [PATCH 9/9] chore: update wry crate version --- crates/tauri-runtime-wry/Cargo.toml | 2 +- crates/tauri-utils/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/tauri-runtime-wry/Cargo.toml b/crates/tauri-runtime-wry/Cargo.toml index f6d972f3eb4e..2030326b6f53 100644 --- a/crates/tauri-runtime-wry/Cargo.toml +++ b/crates/tauri-runtime-wry/Cargo.toml @@ -17,7 +17,7 @@ rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"] [dependencies] -wry = { version = "0.49", default-features = false, features = [ +wry = { version = "0.48.1", default-features = false, features = [ "drag-drop", "protocol", "os-webview", diff --git a/crates/tauri-utils/Cargo.toml b/crates/tauri-utils/Cargo.toml index 0fd436358ce3..da9486ff3771 100644 --- a/crates/tauri-utils/Cargo.toml +++ b/crates/tauri-utils/Cargo.toml @@ -13,7 +13,7 @@ edition.workspace = true rust-version.workspace = true [dependencies] -wry = { version = "0.49", default-features = false } +wry = { version = "0.48.1", default-features = false } serde = { version = "1", features = ["derive"] } serde_json = "1" thiserror = "2"