From d885a5059f34a2d517c504c300bf68b9e18efa7e Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Sun, 12 Oct 2025 18:49:08 -0300 Subject: [PATCH 1/5] feat(core): added WindowConfig::on_new_window, closes #14263 --- .changes/on-new-window-requested-api.md | 6 + .changes/on-new-window-requested-config.md | 6 + crates/tauri-cli/config.schema.json | 87 +++++++++++ .../schemas/config.schema.json | 87 +++++++++++ crates/tauri-utils/src/acl/mod.rs | 104 +------------ crates/tauri-utils/src/config.rs | 51 ++++++- crates/tauri-utils/src/lib.rs | 1 + crates/tauri-utils/src/tokens.rs | 8 + crates/tauri-utils/src/url.rs | 138 ++++++++++++++++++ crates/tauri/scripts/bundle.global.js | 2 +- crates/tauri/src/webview/mod.rs | 114 +++++++++++---- packages/api/src/webview.ts | 29 +++- packages/api/src/webviewWindow.ts | 4 + 13 files changed, 504 insertions(+), 133 deletions(-) create mode 100644 .changes/on-new-window-requested-api.md create mode 100644 .changes/on-new-window-requested-config.md create mode 100644 crates/tauri-utils/src/url.rs diff --git a/.changes/on-new-window-requested-api.md b/.changes/on-new-window-requested-api.md new file mode 100644 index 000000000000..155142ac385d --- /dev/null +++ b/.changes/on-new-window-requested-api.md @@ -0,0 +1,6 @@ +--- +"@tauri-apps/api": minor:feat +--- + +Added `onNewWindow` option to configure whether to allow the webview to open URLs when `window.open` is used. + diff --git a/.changes/on-new-window-requested-config.md b/.changes/on-new-window-requested-config.md new file mode 100644 index 000000000000..b355a8db4613 --- /dev/null +++ b/.changes/on-new-window-requested-config.md @@ -0,0 +1,6 @@ +--- +"tauri": minor:feat +"tauri-utils": minor:feat +--- + +Added `WindowConfig::on_new_window` to statically configure `WebviewBuilder::on_new_window`. diff --git a/crates/tauri-cli/config.schema.json b/crates/tauri-cli/config.schema.json index 6d480475ceec..9beb2d069953 100644 --- a/crates/tauri-cli/config.schema.json +++ b/crates/tauri-cli/config.schema.json @@ -602,6 +602,17 @@ "$ref": "#/definitions/ScrollBarStyle" } ] + }, + "onNewWindow": { + "description": "Action to perform when a new window is requested to be created.", + "default": { + "action": "deny" + }, + "allOf": [ + { + "$ref": "#/definitions/OnNewWindow" + } + ] } }, "additionalProperties": false @@ -1140,6 +1151,82 @@ } ] }, + "OnNewWindow": { + "description": "Action to perform when a new window is requested to be created.", + "oneOf": [ + { + "description": "Allow the window to be created using the default webview implementation.", + "type": "object", + "required": [ + "action" + ], + "properties": { + "action": { + "type": "string", + "enum": [ + "allowDefault" + ] + }, + "urls": { + "description": "Only allow URLs matching the given pattern list when set.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/UrlPattern" + } + } + }, + "additionalProperties": false + }, + { + "description": "Allow the window to be created using a Tauri window.", + "type": "object", + "required": [ + "action" + ], + "properties": { + "action": { + "type": "string", + "enum": [ + "allowTauriWindow" + ] + }, + "urls": { + "description": "Only allow URLs matching the given pattern list when set.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/UrlPattern" + } + } + }, + "additionalProperties": false + }, + { + "description": "Deny the window from being created.", + "type": "object", + "required": [ + "action" + ], + "properties": { + "action": { + "type": "string", + "enum": [ + "deny" + ] + } + }, + "additionalProperties": false + } + ] + }, + "UrlPattern": { + "type": "string" + }, "SecurityConfig": { "description": "Security configuration.\n\n See more: ", "type": "object", diff --git a/crates/tauri-schema-generator/schemas/config.schema.json b/crates/tauri-schema-generator/schemas/config.schema.json index 6d480475ceec..9beb2d069953 100644 --- a/crates/tauri-schema-generator/schemas/config.schema.json +++ b/crates/tauri-schema-generator/schemas/config.schema.json @@ -602,6 +602,17 @@ "$ref": "#/definitions/ScrollBarStyle" } ] + }, + "onNewWindow": { + "description": "Action to perform when a new window is requested to be created.", + "default": { + "action": "deny" + }, + "allOf": [ + { + "$ref": "#/definitions/OnNewWindow" + } + ] } }, "additionalProperties": false @@ -1140,6 +1151,82 @@ } ] }, + "OnNewWindow": { + "description": "Action to perform when a new window is requested to be created.", + "oneOf": [ + { + "description": "Allow the window to be created using the default webview implementation.", + "type": "object", + "required": [ + "action" + ], + "properties": { + "action": { + "type": "string", + "enum": [ + "allowDefault" + ] + }, + "urls": { + "description": "Only allow URLs matching the given pattern list when set.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/UrlPattern" + } + } + }, + "additionalProperties": false + }, + { + "description": "Allow the window to be created using a Tauri window.", + "type": "object", + "required": [ + "action" + ], + "properties": { + "action": { + "type": "string", + "enum": [ + "allowTauriWindow" + ] + }, + "urls": { + "description": "Only allow URLs matching the given pattern list when set.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/UrlPattern" + } + } + }, + "additionalProperties": false + }, + { + "description": "Deny the window from being created.", + "type": "object", + "required": [ + "action" + ], + "properties": { + "action": { + "type": "string", + "enum": [ + "deny" + ] + } + }, + "additionalProperties": false + } + ] + }, + "UrlPattern": { + "type": "string" + }, "SecurityConfig": { "description": "Security configuration.\n\n See more: ", "type": "object", diff --git a/crates/tauri-utils/src/acl/mod.rs b/crates/tauri-utils/src/acl/mod.rs index 4d2322c39c23..2e0ed548b888 100644 --- a/crates/tauri-utils/src/acl/mod.rs +++ b/crates/tauri-utils/src/acl/mod.rs @@ -29,15 +29,13 @@ use std::{ fs, num::NonZeroU64, path::PathBuf, - str::FromStr, - sync::Arc, }; use thiserror::Error; -use url::Url; use crate::{ config::{CapabilityEntry, Config}, platform::Target, + url::UrlPattern, }; pub use self::{identifier::*, value::*}; @@ -273,64 +271,6 @@ pub struct PermissionSet { pub permissions: Vec, } -/// UrlPattern for [`ExecutionContext::Remote`]. -#[derive(Debug, Clone)] -pub struct RemoteUrlPattern(Arc, String); - -impl FromStr for RemoteUrlPattern { - type Err = urlpattern::quirks::Error; - - fn from_str(s: &str) -> std::result::Result { - let mut init = urlpattern::UrlPatternInit::parse_constructor_string::(s, None)?; - if init.search.as_ref().map(|p| p.is_empty()).unwrap_or(true) { - init.search.replace("*".to_string()); - } - if init.hash.as_ref().map(|p| p.is_empty()).unwrap_or(true) { - init.hash.replace("*".to_string()); - } - if init - .pathname - .as_ref() - .map(|p| p.is_empty() || p == "/") - .unwrap_or(true) - { - init.pathname.replace("*".to_string()); - } - let pattern = urlpattern::UrlPattern::parse(init, Default::default())?; - Ok(Self(Arc::new(pattern), s.to_string())) - } -} - -impl RemoteUrlPattern { - #[doc(hidden)] - pub fn as_str(&self) -> &str { - &self.1 - } - - /// Test if a given URL matches the pattern. - pub fn test(&self, url: &Url) -> bool { - self - .0 - .test(urlpattern::UrlPatternMatchInput::Url(url.clone())) - .unwrap_or_default() - } -} - -impl PartialEq for RemoteUrlPattern { - fn eq(&self, other: &Self) -> bool { - self.0.protocol() == other.0.protocol() - && self.0.username() == other.0.username() - && self.0.password() == other.0.password() - && self.0.hostname() == other.0.hostname() - && self.0.port() == other.0.port() - && self.0.pathname() == other.0.pathname() - && self.0.search() == other.0.search() - && self.0.hash() == other.0.hash() - } -} - -impl Eq for RemoteUrlPattern {} - /// Execution context of an IPC call. #[derive(Debug, Default, Clone, Eq, PartialEq)] pub enum ExecutionContext { @@ -340,7 +280,7 @@ pub enum ExecutionContext { /// Remote URL is trying to use the IPC. Remote { /// The URL trying to access the IPC (URL pattern). - url: RemoteUrlPattern, + url: UrlPattern, }, } @@ -420,46 +360,6 @@ pub fn read_allowed_commands() -> Option { Some(json) } -#[cfg(test)] -mod tests { - use crate::acl::RemoteUrlPattern; - - #[test] - fn url_pattern_domain_wildcard() { - let pattern: RemoteUrlPattern = "http://*".parse().unwrap(); - - assert!(pattern.test(&"http://tauri.app/path".parse().unwrap())); - assert!(pattern.test(&"http://tauri.app/path?q=1".parse().unwrap())); - - assert!(pattern.test(&"http://localhost/path".parse().unwrap())); - assert!(pattern.test(&"http://localhost/path?q=1".parse().unwrap())); - - let pattern: RemoteUrlPattern = "http://*.tauri.app".parse().unwrap(); - - assert!(!pattern.test(&"http://tauri.app/path".parse().unwrap())); - assert!(!pattern.test(&"http://tauri.app/path?q=1".parse().unwrap())); - assert!(pattern.test(&"http://api.tauri.app/path".parse().unwrap())); - assert!(pattern.test(&"http://api.tauri.app/path?q=1".parse().unwrap())); - assert!(!pattern.test(&"http://localhost/path".parse().unwrap())); - assert!(!pattern.test(&"http://localhost/path?q=1".parse().unwrap())); - } - - #[test] - fn url_pattern_path_wildcard() { - let pattern: RemoteUrlPattern = "http://localhost/*".parse().unwrap(); - assert!(pattern.test(&"http://localhost/path".parse().unwrap())); - assert!(pattern.test(&"http://localhost/path?q=1".parse().unwrap())); - } - - #[test] - fn url_pattern_scheme_wildcard() { - let pattern: RemoteUrlPattern = "*://localhost".parse().unwrap(); - assert!(pattern.test(&"http://localhost/path".parse().unwrap())); - assert!(pattern.test(&"https://localhost/path?q=1".parse().unwrap())); - assert!(pattern.test(&"custom://localhost/path".parse().unwrap())); - } -} - #[cfg(feature = "build")] mod build_ { use std::convert::identity; diff --git a/crates/tauri-utils/src/config.rs b/crates/tauri-utils/src/config.rs index 89ec983c7a4e..b56c17a024a4 100644 --- a/crates/tauri-utils/src/config.rs +++ b/crates/tauri-utils/src/config.rs @@ -61,7 +61,9 @@ fn add_description(schema: Schema, description: impl Into) -> Schema { /// Items to help with parsing content into a [`Config`]. pub mod parse; -use crate::{acl::capability::Capability, TitleBarStyle, WindowEffect, WindowEffectState}; +use crate::{ + acl::capability::Capability, url::UrlPattern, TitleBarStyle, WindowEffect, WindowEffectState, +}; pub use self::parse::parse; @@ -1647,6 +1649,27 @@ pub enum ScrollBarStyle { FluentOverlay, } +/// Action to perform when a new window is requested to be created. +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Default)] +#[cfg_attr(feature = "schema", derive(JsonSchema))] +#[serde(rename_all = "camelCase", deny_unknown_fields, tag = "action")] +#[non_exhaustive] +pub enum OnNewWindow { + /// Allow the window to be created using the default webview implementation. + AllowDefault { + /// Only allow URLs matching the given pattern list when set. + urls: Option>, + }, + /// Allow the window to be created using a Tauri window. + AllowTauriWindow { + /// Only allow URLs matching the given pattern list when set. + urls: Option>, + }, + /// Deny the window from being created. + #[default] + Deny, +} + /// The window configuration object. /// /// See more: @@ -1995,6 +2018,9 @@ pub struct WindowConfig { /// - **Linux / Android / iOS / macOS**: Unsupported. Only supports `Default` and performs no operation. #[serde(default, alias = "scroll-bar-style")] pub scroll_bar_style: ScrollBarStyle, + /// Action to perform when a new window is requested to be created. + #[serde(default, alias = "on-window-requested")] + pub on_new_window: OnNewWindow, } impl Default for WindowConfig { @@ -2057,6 +2083,7 @@ impl Default for WindowConfig { data_directory: None, data_store_identifier: None, scroll_bar_style: ScrollBarStyle::Default, + on_new_window: OnNewWindow::default(), } } } @@ -3524,6 +3551,24 @@ mod build { } } + impl ToTokens for OnNewWindow { + fn to_tokens(&self, tokens: &mut TokenStream) { + let prefix = quote! { ::tauri::utils::config::OnNewWindow }; + + tokens.append_all(match self { + Self::AllowDefault { urls } => { + let urls = opt_vec_lit(urls.as_ref(), url_pattern_lit); + quote! { #prefix::AllowDefault { urls: #urls } } + } + Self::AllowTauriWindow { urls } => { + let urls = opt_vec_lit(urls.as_ref(), url_pattern_lit); + quote! { #prefix::AllowTauriWindow { urls: #urls } } + } + Self::Deny => quote! { #prefix::Deny }, + }) + } + } + impl ToTokens for WindowConfig { fn to_tokens(&self, tokens: &mut TokenStream) { let label = str_lit(&self.label); @@ -3583,6 +3628,7 @@ mod build { let data_directory = opt_lit(self.data_directory.as_ref().map(path_buf_lit).as_ref()); let data_store_identifier = opt_vec_lit(self.data_store_identifier, identity); let scroll_bar_style = &self.scroll_bar_style; + let on_new_window = &self.on_new_window; literal_struct!( tokens, @@ -3643,7 +3689,8 @@ mod build { disable_input_accessory_view, data_directory, data_store_identifier, - scroll_bar_style + scroll_bar_style, + on_new_window ); } } diff --git a/crates/tauri-utils/src/lib.rs b/crates/tauri-utils/src/lib.rs index b8c41bca9364..e021ccd9114e 100644 --- a/crates/tauri-utils/src/lib.rs +++ b/crates/tauri-utils/src/lib.rs @@ -35,6 +35,7 @@ pub mod plugin; pub mod resources; #[cfg(feature = "build")] pub mod tokens; +pub mod url; #[cfg(feature = "build")] pub mod build; diff --git a/crates/tauri-utils/src/tokens.rs b/crates/tauri-utils/src/tokens.rs index c02fb1fdc0bd..b1fb41cca192 100644 --- a/crates/tauri-utils/src/tokens.rs +++ b/crates/tauri-utils/src/tokens.rs @@ -11,6 +11,8 @@ use quote::{quote, ToTokens}; use serde_json::Value as JsonValue; use url::Url; +use crate::url::UrlPattern; + /// Write a `TokenStream` of the `$struct`'s fields to the `$tokens`. /// /// All fields must represent a binding of the same name that implements `ToTokens`. @@ -92,6 +94,12 @@ pub fn url_lit(url: &Url) -> TokenStream { quote! { #url.parse().unwrap() } } +/// Creates a [`UrlPattern`] constructor `TokenStream`. +pub fn url_pattern_lit(url: &UrlPattern) -> TokenStream { + let url = url.as_str(); + quote! { #url.parse().unwrap() } +} + /// Create a map constructor, mapping keys and values with other `TokenStream`s. /// /// This function is pretty generic because the types of keys AND values get transformed. diff --git a/crates/tauri-utils/src/url.rs b/crates/tauri-utils/src/url.rs new file mode 100644 index 000000000000..58bae39b79f6 --- /dev/null +++ b/crates/tauri-utils/src/url.rs @@ -0,0 +1,138 @@ +// Copyright 2019-2025 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +//! URL helpers. + +use std::{str::FromStr, sync::Arc}; + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use url::Url; + +/// UrlPattern to match URLs. +#[derive(Debug, Clone)] +pub struct UrlPattern(Arc, String); + +#[cfg(feature = "schema")] +impl schemars::JsonSchema for UrlPattern { + fn schema_name() -> String { + "UrlPattern".to_string() + } + + fn json_schema(_gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { + String::json_schema(_gen) + } +} + +impl Serialize for UrlPattern { + fn serialize(&self, serializer: S) -> std::result::Result + where + S: Serializer, + { + serializer.serialize_str(&self.1) + } +} + +impl<'de> Deserialize<'de> for UrlPattern { + fn deserialize(deserializer: D) -> std::result::Result + where + D: Deserializer<'de>, + { + let s = String::deserialize(deserializer)?; + Self::from_str(&s).map_err(serde::de::Error::custom) + } +} + +impl FromStr for UrlPattern { + type Err = urlpattern::quirks::Error; + + fn from_str(s: &str) -> std::result::Result { + let mut init = urlpattern::UrlPatternInit::parse_constructor_string::(s, None)?; + if init.search.as_ref().map(|p| p.is_empty()).unwrap_or(true) { + init.search.replace("*".to_string()); + } + if init.hash.as_ref().map(|p| p.is_empty()).unwrap_or(true) { + init.hash.replace("*".to_string()); + } + if init + .pathname + .as_ref() + .map(|p| p.is_empty() || p == "/") + .unwrap_or(true) + { + init.pathname.replace("*".to_string()); + } + let pattern = urlpattern::UrlPattern::parse(init, Default::default())?; + Ok(Self(Arc::new(pattern), s.to_string())) + } +} + +impl UrlPattern { + #[doc(hidden)] + pub fn as_str(&self) -> &str { + &self.1 + } + + /// Test if a given URL matches the pattern. + pub fn test(&self, url: &Url) -> bool { + self + .0 + .test(urlpattern::UrlPatternMatchInput::Url(url.clone())) + .unwrap_or_default() + } +} + +impl PartialEq for UrlPattern { + fn eq(&self, other: &Self) -> bool { + self.0.protocol() == other.0.protocol() + && self.0.username() == other.0.username() + && self.0.password() == other.0.password() + && self.0.hostname() == other.0.hostname() + && self.0.port() == other.0.port() + && self.0.pathname() == other.0.pathname() + && self.0.search() == other.0.search() + && self.0.hash() == other.0.hash() + } +} + +impl Eq for UrlPattern {} + +#[cfg(test)] +mod tests { + use super::UrlPattern; + + #[test] + fn url_pattern_domain_wildcard() { + let pattern: UrlPattern = "http://*".parse().unwrap(); + + assert!(pattern.test(&"http://tauri.app/path".parse().unwrap())); + assert!(pattern.test(&"http://tauri.app/path?q=1".parse().unwrap())); + + assert!(pattern.test(&"http://localhost/path".parse().unwrap())); + assert!(pattern.test(&"http://localhost/path?q=1".parse().unwrap())); + + let pattern: UrlPattern = "http://*.tauri.app".parse().unwrap(); + + assert!(!pattern.test(&"http://tauri.app/path".parse().unwrap())); + assert!(!pattern.test(&"http://tauri.app/path?q=1".parse().unwrap())); + assert!(pattern.test(&"http://api.tauri.app/path".parse().unwrap())); + assert!(pattern.test(&"http://api.tauri.app/path?q=1".parse().unwrap())); + assert!(!pattern.test(&"http://localhost/path".parse().unwrap())); + assert!(!pattern.test(&"http://localhost/path?q=1".parse().unwrap())); + } + + #[test] + fn url_pattern_path_wildcard() { + let pattern: UrlPattern = "http://localhost/*".parse().unwrap(); + assert!(pattern.test(&"http://localhost/path".parse().unwrap())); + assert!(pattern.test(&"http://localhost/path?q=1".parse().unwrap())); + } + + #[test] + fn url_pattern_scheme_wildcard() { + let pattern: UrlPattern = "*://localhost".parse().unwrap(); + assert!(pattern.test(&"http://localhost/path".parse().unwrap())); + assert!(pattern.test(&"https://localhost/path?q=1".parse().unwrap())); + assert!(pattern.test(&"custom://localhost/path".parse().unwrap())); + } +} diff --git a/crates/tauri/scripts/bundle.global.js b/crates/tauri/scripts/bundle.global.js index 870ac2ec68eb..beecc77c6dc7 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,l;"function"==typeof SuppressedError&&SuppressedError;const o="__TAURI_TO_IPC_KEY__";function u(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}class c{constructor(e){i.set(this,void 0),r.set(this,0),s.set(this,[]),a.set(this,void 0),t(this,i,e||(()=>{}),"f"),this.id=u(e=>{const l=e.index;if("end"in e)return void(l==n(this,r,"f")?this.cleanupCallback():t(this,a,l,"f"));const o=e.message;if(l==n(this,r,"f")){for(n(this,i,"f").call(this,o),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")}n(this,r,"f")===n(this,a,"f")&&this.cleanupCallback()}else n(this,s,"f")[l]=o})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){t(this,i,e,"f")}get onmessage(){return n(this,i,"f")}[(i=new WeakMap,r=new WeakMap,s=new WeakMap,a=new WeakMap,o)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[o]()}}class d{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return p(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function p(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}class h{get rid(){return n(this,l,"f")}constructor(e){l.set(this,void 0),t(this,l,e,"f")}async close(){return p("plugin:resources|close",{rid:this.rid})}}l=new WeakMap;var w=Object.freeze({__proto__:null,Channel:c,PluginListener:d,Resource:h,SERIALIZE_TO_IPC_FN:o,addPluginListener:async function(e,n,t){const i=new c(t);try{return p(`plugin:${e}|register_listener`,{event:n,handler:i}).then(()=>new d(e,n,i.id))}catch{return p(`plugin:${e}|registerListener`,{event:n,handler:i}).then(()=>new d(e,n,i.id))}},checkPermissions:async function(e){return p(`plugin:${e}|check_permissions`)},convertFileSrc:function(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)},invoke:p,isTauri:function(){return!!(globalThis||window).isTauri},requestPermissions:async function(e){return p(`plugin:${e}|request_permissions`)},transformCallback:u});class _ extends h{constructor(e){super(e)}static async new(e,n,t){return p("plugin:image|new",{rgba:y(e),width:n,height:t}).then(e=>new _(e))}static async fromBytes(e){return p("plugin:image|from_bytes",{bytes:y(e)}).then(e=>new _(e))}static async fromPath(e){return p("plugin:image|from_path",{path:e}).then(e=>new _(e))}async rgba(){return p("plugin:image|rgba",{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return p("plugin:image|size",{rid:this.rid})}}function y(e){return null==e?null:"string"==typeof e?e:e instanceof _?e.rid:e}var g,b=Object.freeze({__proto__:null,Image:_,transformImage:y});!function(e){e.Nsis="nsis",e.Msi="msi",e.Deb="deb",e.Rpm="rpm",e.AppImage="appimage",e.App="app"}(g||(g={}));var m=Object.freeze({__proto__:null,get BundleType(){return g},defaultWindowIcon:async function(){return p("plugin:app|default_window_icon").then(e=>e?new _(e):null)},fetchDataStoreIdentifiers:async function(){return p("plugin:app|fetch_data_store_identifiers")},getBundleType:async function(){return p("plugin:app|bundle_type")},getIdentifier:async function(){return p("plugin:app|identifier")},getName:async function(){return p("plugin:app|name")},getTauriVersion:async function(){return p("plugin:app|tauri_version")},getVersion:async function(){return p("plugin:app|version")},hide:async function(){return p("plugin:app|app_hide")},removeDataStore:async function(e){return p("plugin:app|remove_data_store",{uuid:e})},setDockVisibility:async function(e){return p("plugin:app|set_dock_visibility",{visible:e})},setTheme:async function(e){return p("plugin:app|set_app_theme",{theme:e})},show:async function(){return p("plugin:app|app_show")}});class f{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 v(this.width*e,this.height*e)}[o](){return{width:this.width,height:this.height}}toJSON(){return this[o]()}}class v{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 f(this.width/e,this.height/e)}[o](){return{width:this.width,height:this.height}}toJSON(){return this[o]()}}class k{constructor(e){this.size=e}toLogical(e){return this.size instanceof f?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof v?this.size:this.size.toPhysical(e)}[o](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[o]()}}class A{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 T(this.x*e,this.y*e)}[o](){return{x:this.x,y:this.y}}toJSON(){return this[o]()}}class T{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 A(this.x/e,this.y/e)}[o](){return{x:this.x,y:this.y}}toJSON(){return this[o]()}}class I{constructor(e){this.position=e}toLogical(e){return this.position instanceof A?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof T?this.position:this.position.toPhysical(e)}[o](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[o]()}}var E,R=Object.freeze({__proto__:null,LogicalPosition:A,LogicalSize:f,PhysicalPosition:T,PhysicalSize:v,Position:I,Size:k});async function D(e,n){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(e,n),await p("plugin:event|unlisten",{event:e,eventId:n})}async function S(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 p("plugin:event|listen",{event:e,target:r,handler:u(n)}).then(n=>async()=>D(e,n))}async function N(e,n,t){return S(e,t=>{D(e,t.id),n(t)},t)}async function L(e,n){await p("plugin:event|emit",{event:e,payload:n})}async function C(e,n,t){const i="string"==typeof e?{kind:"AnyLabel",label:e}:e;await p("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,P,z,W=Object.freeze({__proto__:null,get TauriEvent(){return E},emit:L,emitTo:C,listen:S,once:N});function O(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:O(e));else if("action"in e&&e.action){const n=new c;return n.onmessage=e.action,delete e.action,{...e,handler:n}}return e}async function U(e,n){const t=new c;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)),O(e))}n.items=n.items.map(i)}return p("plugin:menu|new",{kind:e,options:n,handler:t})}class F extends h{get id(){return n(this,x,"f")}get kind(){return n(this,P,"f")}constructor(e,n,i){super(e),x.set(this,void 0),P.set(this,void 0),t(this,x,n,"f"),t(this,P,i,"f")}}x=new WeakMap,P=new WeakMap;class M extends F{constructor(e,n){super(e,n,"MenuItem")}static async new(e){return U("MenuItem",e).then(([e,n])=>new M(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return p("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return p("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return p("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}}class B extends F{constructor(e,n){super(e,n,"Check")}static async new(e){return U("Check",e).then(([e,n])=>new B(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return p("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return p("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return p("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async isChecked(){return p("plugin:menu|is_checked",{rid:this.rid})}async setChecked(e){return p("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"}(z||(z={}));class V extends F{constructor(e,n){super(e,n,"Icon")}static async new(e){return U("Icon",e).then(([e,n])=>new V(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return p("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return p("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return p("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async setIcon(e){return p("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:y(e)})}}class G extends F{constructor(e,n){super(e,n,"Predefined")}static async new(e){return U("Predefined",e).then(([e,n])=>new G(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}}function j([e,n,t]){switch(t){case"Submenu":return new H(e,n);case"Predefined":return new G(e,n);case"Check":return new B(e,n);case"Icon":return new V(e,n);default:return new M(e,n)}}class H extends F{constructor(e,n){super(e,n,"Submenu")}static async new(e){return U("Submenu",e).then(([e,n])=>new H(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return p("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return p("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async append(e){return p("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 p("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 p("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 p("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return p("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(j)}async items(){return p("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(e=>e.map(j))}async get(e){return p("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then(e=>e?j(e):null)}async popup(e,n){var t;return p("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 I?e:e?new I(e):null})}async setAsWindowsMenuForNSApp(){return p("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return p("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}async setIcon(e){return p("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:y(e)})}}class $ extends F{constructor(e,n){super(e,n,"Menu")}static async new(e){return U("Menu",e).then(([e,n])=>new $(e,n))}static async default(){return p("plugin:menu|create_default").then(([e,n])=>new $(e,n))}async append(e){return p("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 p("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 p("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 p("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return p("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(j)}async items(){return p("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(e=>e.map(j))}async get(e){return p("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then(e=>e?j(e):null)}async popup(e,n){var t;return p("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 I?e:e?new I(e):null})}async setAsAppMenu(){return p("plugin:menu|set_as_app_menu",{rid:this.rid}).then(e=>e?new $(e[0],e[1]):null)}async setAsWindowMenu(e){var n;return p("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 $(e[0],e[1]):null)}}var q=Object.freeze({__proto__:null,CheckMenuItem:B,IconMenuItem:V,Menu:$,MenuItem:M,get NativeIcon(){return z},PredefinedMenuItem:G,Submenu:H,itemFromKind:j});function J(){var e,n;window.__TAURI_INTERNALS__=null!==(e=window.__TAURI_INTERNALS__)&&void 0!==e?e:{},window.__TAURI_EVENT_PLUGIN_INTERNALS__=null!==(n=window.__TAURI_EVENT_PLUGIN_INTERNALS__)&&void 0!==n?n:{}}var Q,Z=Object.freeze({__proto__:null,clearMocks:function(){"object"==typeof window.__TAURI_INTERNALS__&&(delete window.__TAURI_INTERNALS__.invoke,delete window.__TAURI_INTERNALS__.transformCallback,delete window.__TAURI_INTERNALS__.unregisterCallback,delete window.__TAURI_INTERNALS__.runCallback,delete window.__TAURI_INTERNALS__.callbacks,delete window.__TAURI_INTERNALS__.convertFileSrc,delete window.__TAURI_INTERNALS__.metadata,"object"==typeof window.__TAURI_EVENT_PLUGIN_INTERNALS__&&delete window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener)},mockConvertFileSrc:function(e){J(),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,n){function t(e,n){switch(e){case"plugin:event|listen":return function(e){i.has(e.event)||i.set(e.event,[]);return i.get(e.event).push(e.handler),e.handler}(n);case"plugin:event|emit":return function(e){const n=i.get(e.event)||[];for(const t of n)a(t,e);return null}(n);case"plugin:event|unlisten":return function(e){const n=i.get(e.event);if(n){const t=n.indexOf(e.id);-1!==t&&n.splice(t,1)}}(n)}}J();const i=new Map,r=new Map;function s(e){r.delete(e)}function a(e,n){const t=r.get(e);t?t(n):console.warn(`[TAURI] Couldn't find callback id ${e}. This might happen when the app is reloaded while Rust is running an asynchronous operation.`)}window.__TAURI_INTERNALS__.invoke=async function(i,r,s){return(null==n?void 0:n.shouldMockEvents)&&function(e){return e.startsWith("plugin:event|")}(i)?t(i,r):e(i,r)},window.__TAURI_INTERNALS__.transformCallback=function(e,n=!1){const t=window.crypto.getRandomValues(new Uint32Array(1))[0];return r.set(t,i=>(n&&s(t),e&&e(i))),t},window.__TAURI_INTERNALS__.unregisterCallback=s,window.__TAURI_INTERNALS__.runCallback=a,window.__TAURI_INTERNALS__.callbacks=r,window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener=function(e,n){s(n)}},mockWindows:function(e,...n){J(),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 K=Object.freeze({__proto__:null,get BaseDirectory(){return Q},appCacheDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppCache})},appConfigDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppConfig})},appDataDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppData})},appLocalDataDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppLocalData})},appLogDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppLog})},audioDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Audio})},basename:async function(e,n){return p("plugin:path|basename",{path:e,ext:n})},cacheDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Cache})},configDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Config})},dataDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Data})},delimiter:function(){return window.__TAURI_INTERNALS__.plugins.path.delimiter},desktopDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Desktop})},dirname:async function(e){return p("plugin:path|dirname",{path:e})},documentDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Document})},downloadDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Download})},executableDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Executable})},extname:async function(e){return p("plugin:path|extname",{path:e})},fontDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Font})},homeDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Home})},isAbsolute:async function(e){return p("plugin:path|is_absolute",{path:e})},join:async function(...e){return p("plugin:path|join",{paths:e})},localDataDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.LocalData})},normalize:async function(e){return p("plugin:path|normalize",{path:e})},pictureDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Picture})},publicDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Public})},resolve:async function(...e){return p("plugin:path|resolve",{paths:e})},resolveResource:async function(e){return p("plugin:path|resolve_directory",{directory:Q.Resource,path:e})},resourceDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Resource})},runtimeDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Runtime})},sep:function(){return window.__TAURI_INTERNALS__.plugins.path.sep},tempDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Temp})},templateDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Template})},videoDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Video})}});class Y extends h{constructor(e,n){super(e),this.id=n}static async getById(e){return p("plugin:tray|get_by_id",{id:e}).then(n=>n?new Y(n,e):null)}static async removeById(e){return p("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 c;if(null==e?void 0:e.action){const t=e.action;n.onmessage=e=>t(function(e){const n=e;return n.position=new T(e.position),n.rect.position=new T(e.rect.position),n.rect.size=new v(e.rect.size),n}(e)),delete e.action}return p("plugin:tray|new",{options:null!=e?e:{},handler:n}).then(([e,n])=>new Y(e,n))}async setIcon(e){let n=null;return e&&(n=y(e)),p("plugin:tray|set_icon",{rid:this.rid,icon:n})}async setMenu(e){return e&&(e=[e.rid,e.kind]),p("plugin:tray|set_menu",{rid:this.rid,menu:e})}async setTooltip(e){return p("plugin:tray|set_tooltip",{rid:this.rid,tooltip:e})}async setTitle(e){return p("plugin:tray|set_title",{rid:this.rid,title:e})}async setVisible(e){return p("plugin:tray|set_visible",{rid:this.rid,visible:e})}async setTempDirPath(e){return p("plugin:tray|set_temp_dir_path",{rid:this.rid,path:e})}async setIconAsTemplate(e){return p("plugin:tray|set_icon_as_template",{rid:this.rid,asTemplate:e})}async setMenuOnLeftClick(e){return p("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}async setShowMenuOnLeftClick(e){return p("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}}var X,ee,ne=Object.freeze({__proto__:null,TrayIcon:Y});!function(e){e[e.Critical=1]="Critical",e[e.Informational=2]="Informational"}(X||(X={}));class te{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}function ie(){return new ae(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function re(){return p("plugin:window|get_all_windows").then(e=>e.map(e=>new ae(e,{skip:!0})))}!function(e){e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error"}(ee||(ee={}));const se=["tauri://created","tauri://error"];class ae{constructor(e,n={}){var t;this.label=e,this.listeners=Object.create(null),(null==n?void 0:n.skip)||p("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 re()).find(n=>n.label===e))&&void 0!==n?n:null}static getCurrent(){return ie()}static async getAll(){return re()}static async getFocusedWindow(){for(const e of await re())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)}:S(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)}:N(e,n,{target:{kind:"Window",label:this.label}})}async emit(e,n){if(!se.includes(e))return L(e,n);for(const t of this.listeners[e]||[])t({event:e,id:-1,payload:n})}async emitTo(e,n,t){if(!se.includes(n))return C(e,n,t);for(const e of this.listeners[n]||[])e({event:n,id:-1,payload:t})}_handleTauriEvent(e,n){return!!se.includes(e)&&(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0)}async scaleFactor(){return p("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return p("plugin:window|inner_position",{label:this.label}).then(e=>new T(e))}async outerPosition(){return p("plugin:window|outer_position",{label:this.label}).then(e=>new T(e))}async innerSize(){return p("plugin:window|inner_size",{label:this.label}).then(e=>new v(e))}async outerSize(){return p("plugin:window|outer_size",{label:this.label}).then(e=>new v(e))}async isFullscreen(){return p("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return p("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return p("plugin:window|is_maximized",{label:this.label})}async isFocused(){return p("plugin:window|is_focused",{label:this.label})}async isDecorated(){return p("plugin:window|is_decorated",{label:this.label})}async isResizable(){return p("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return p("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return p("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return p("plugin:window|is_closable",{label:this.label})}async isVisible(){return p("plugin:window|is_visible",{label:this.label})}async title(){return p("plugin:window|title",{label:this.label})}async theme(){return p("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return p("plugin:window|is_always_on_top",{label:this.label})}async center(){return p("plugin:window|center",{label:this.label})}async requestUserAttention(e){let n=null;return e&&(n=e===X.Critical?{type:"Critical"}:{type:"Informational"}),p("plugin:window|request_user_attention",{label:this.label,value:n})}async setResizable(e){return p("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return p("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return p("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return p("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return p("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return p("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return p("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return p("plugin:window|maximize",{label:this.label})}async unmaximize(){return p("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return p("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return p("plugin:window|minimize",{label:this.label})}async unminimize(){return p("plugin:window|unminimize",{label:this.label})}async show(){return p("plugin:window|show",{label:this.label})}async hide(){return p("plugin:window|hide",{label:this.label})}async close(){return p("plugin:window|close",{label:this.label})}async destroy(){return p("plugin:window|destroy",{label:this.label})}async setDecorations(e){return p("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return p("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return p("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return p("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return p("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return p("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return p("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return p("plugin:window|set_size",{label:this.label,value:e instanceof k?e:new k(e)})}async setMinSize(e){return p("plugin:window|set_min_size",{label:this.label,value:e instanceof k?e:e?new k(e):null})}async setMaxSize(e){return p("plugin:window|set_max_size",{label:this.label,value:e instanceof k?e:e?new k(e):null})}async setSizeConstraints(e){function n(e){return e?{Logical:e}:null}return p("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 p("plugin:window|set_position",{label:this.label,value:e instanceof I?e:new I(e)})}async setFullscreen(e){return p("plugin:window|set_fullscreen",{label:this.label,value:e})}async setSimpleFullscreen(e){return p("plugin:window|set_simple_fullscreen",{label:this.label,value:e})}async setFocus(){return p("plugin:window|set_focus",{label:this.label})}async setFocusable(e){return p("plugin:window|set_focusable",{label:this.label,value:e})}async setIcon(e){return p("plugin:window|set_icon",{label:this.label,value:y(e)})}async setSkipTaskbar(e){return p("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return p("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return p("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return p("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return p("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return p("plugin:window|set_cursor_position",{label:this.label,value:e instanceof I?e:new I(e)})}async setIgnoreCursorEvents(e){return p("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return p("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return p("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return p("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return p("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return p("plugin:window|set_overlay_icon",{label:this.label,value:e?y(e):void 0})}async setProgressBar(e){return p("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return p("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return p("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return p("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(E.WINDOW_RESIZED,n=>{n.payload=new v(n.payload),e(n)})}async onMoved(e){return this.listen(E.WINDOW_MOVED,n=>{n.payload=new T(n.payload),e(n)})}async onCloseRequested(e){return this.listen(E.WINDOW_CLOSE_REQUESTED,async n=>{const t=new te(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 T(n.payload.position)}})}),t=await this.listen(E.DRAG_OVER,n=>{e({...n,payload:{type:"over",position:new T(n.payload.position)}})}),i=await this.listen(E.DRAG_DROP,n=>{e({...n,payload:{type:"drop",paths:n.payload.paths,position:new T(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 le,oe,ue,ce;function de(e){return null===e?null:{name:e.name,scaleFactor:e.scaleFactor,position:new T(e.position),size:new v(e.size),workArea:{position:new T(e.workArea.position),size:new v(e.workArea.size)}}}!function(e){e.Disabled="disabled",e.Throttle="throttle",e.Suspend="suspend"}(le||(le={})),function(e){e.Default="default",e.FluentOverlay="fluentOverlay"}(oe||(oe={})),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"}(ue||(ue={})),function(e){e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive"}(ce||(ce={}));var pe=Object.freeze({__proto__:null,CloseRequestedEvent:te,get Effect(){return ue},get EffectState(){return ce},LogicalPosition:A,LogicalSize:f,PhysicalPosition:T,PhysicalSize:v,get ProgressBarStatus(){return ee},get UserAttentionType(){return X},Window:ae,availableMonitors:async function(){return p("plugin:window|available_monitors").then(e=>e.map(de))},currentMonitor:async function(){return p("plugin:window|current_monitor").then(de)},cursorPosition:async function(){return p("plugin:window|cursor_position").then(e=>new T(e))},getAllWindows:re,getCurrentWindow:ie,monitorFromPoint:async function(e,n){return p("plugin:window|monitor_from_point",{x:e,y:n}).then(de)},primaryMonitor:async function(){return p("plugin:window|primary_monitor").then(de)}});function he(){return new ye(ie(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function we(){return p("plugin:webview|get_all_webviews").then(e=>e.map(e=>new ye(new ae(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}const _e=["tauri://created","tauri://error"];class ye{constructor(e,n,t){this.window=e,this.label=n,this.listeners=Object.create(null),(null==t?void 0:t.skip)||p("plugin:webview|create_webview",{windowLabel:e.label,options:{...t,label:n}}).then(async()=>this.emit("tauri://created")).catch(async e=>this.emit("tauri://error",e))}static async getByLabel(e){var n;return null!==(n=(await we()).find(n=>n.label===e))&&void 0!==n?n:null}static getCurrent(){return he()}static async getAll(){return we()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:S(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)}:N(e,n,{target:{kind:"Webview",label:this.label}})}async emit(e,n){if(!_e.includes(e))return L(e,n);for(const t of this.listeners[e]||[])t({event:e,id:-1,payload:n})}async emitTo(e,n,t){if(!_e.includes(n))return C(e,n,t);for(const e of this.listeners[n]||[])e({event:n,id:-1,payload:t})}_handleTauriEvent(e,n){return!!_e.includes(e)&&(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0)}async position(){return p("plugin:webview|webview_position",{label:this.label}).then(e=>new T(e))}async size(){return p("plugin:webview|webview_size",{label:this.label}).then(e=>new v(e))}async close(){return p("plugin:webview|webview_close",{label:this.label})}async setSize(e){return p("plugin:webview|set_webview_size",{label:this.label,value:e instanceof k?e:new k(e)})}async setPosition(e){return p("plugin:webview|set_webview_position",{label:this.label,value:e instanceof I?e:new I(e)})}async setFocus(){return p("plugin:webview|set_webview_focus",{label:this.label})}async setAutoResize(e){return p("plugin:webview|set_webview_auto_resize",{label:this.label,value:e})}async hide(){return p("plugin:webview|webview_hide",{label:this.label})}async show(){return p("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return p("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return p("plugin:webview|reparent",{label:this.label,window:"string"==typeof e?e:e.label})}async clearAllBrowsingData(){return p("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return p("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 T(n.payload.position)}})}),t=await this.listen(E.DRAG_OVER,n=>{e({...n,payload:{type:"over",position:new T(n.payload.position)}})}),i=await this.listen(E.DRAG_DROP,n=>{e({...n,payload:{type:"drop",paths:n.payload.paths,position:new T(n.payload.position)}})}),r=await this.listen(E.DRAG_LEAVE,n=>{e({...n,payload:{type:"leave"}})});return()=>{n(),i(),t(),r()}}}var ge,be,me=Object.freeze({__proto__:null,Webview:ye,getAllWebviews:we,getCurrentWebview:he});function fe(){const e=he();return new ke(e.label,{skip:!0})}async function ve(){return p("plugin:window|get_all_windows").then(e=>e.map(e=>new ke(e,{skip:!0})))}class ke{constructor(e,n={}){var t;this.label=e,this.listeners=Object.create(null),(null==n?void 0:n.skip)||p("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 ve()).find(n=>n.label===e))&&void 0!==n?n:null;return t?new ke(t.label,{skip:!0}):null}static getCurrent(){return fe()}static async getAll(){return ve()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:S(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)}:N(e,n,{target:{kind:"WebviewWindow",label:this.label}})}async setBackgroundColor(e){return p("plugin:window|set_background_color",{color:e}).then(()=>p("plugin:webview|set_webview_background_color",{color:e}))}}ge=ke,be=[ae,ye],(Array.isArray(be)?be:[be]).forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(n=>{var t;"object"==typeof ge.prototype&&ge.prototype&&n in ge.prototype||Object.defineProperty(ge.prototype,n,null!==(t=Object.getOwnPropertyDescriptor(e.prototype,n))&&void 0!==t?t:Object.create(null))})});var Ae=Object.freeze({__proto__:null,WebviewWindow:ke,getAllWebviewWindows:ve,getCurrentWebviewWindow:fe});return e.app=m,e.core=w,e.dpi=R,e.event=W,e.image=b,e.menu=q,e.mocks=Z,e.path=K,e.tray=ne,e.webview=me,e.webviewWindow=Ae,e.window=pe,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,l;"function"==typeof SuppressedError&&SuppressedError;const o="__TAURI_TO_IPC_KEY__";function u(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}class c{constructor(e){i.set(this,void 0),r.set(this,0),s.set(this,[]),a.set(this,void 0),t(this,i,e||(()=>{}),"f"),this.id=u(e=>{const l=e.index;if("end"in e)return void(l==n(this,r,"f")?this.cleanupCallback():t(this,a,l,"f"));const o=e.message;if(l==n(this,r,"f")){for(n(this,i,"f").call(this,o),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")}n(this,r,"f")===n(this,a,"f")&&this.cleanupCallback()}else n(this,s,"f")[l]=o})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){t(this,i,e,"f")}get onmessage(){return n(this,i,"f")}[(i=new WeakMap,r=new WeakMap,s=new WeakMap,a=new WeakMap,o)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[o]()}}class d{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return p(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function p(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}class h{get rid(){return n(this,l,"f")}constructor(e){l.set(this,void 0),t(this,l,e,"f")}async close(){return p("plugin:resources|close",{rid:this.rid})}}l=new WeakMap;var w=Object.freeze({__proto__:null,Channel:c,PluginListener:d,Resource:h,SERIALIZE_TO_IPC_FN:o,addPluginListener:async function(e,n,t){const i=new c(t);try{return p(`plugin:${e}|register_listener`,{event:n,handler:i}).then(()=>new d(e,n,i.id))}catch{return p(`plugin:${e}|registerListener`,{event:n,handler:i}).then(()=>new d(e,n,i.id))}},checkPermissions:async function(e){return p(`plugin:${e}|check_permissions`)},convertFileSrc:function(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)},invoke:p,isTauri:function(){return!!(globalThis||window).isTauri},requestPermissions:async function(e){return p(`plugin:${e}|request_permissions`)},transformCallback:u});class _ extends h{constructor(e){super(e)}static async new(e,n,t){return p("plugin:image|new",{rgba:y(e),width:n,height:t}).then(e=>new _(e))}static async fromBytes(e){return p("plugin:image|from_bytes",{bytes:y(e)}).then(e=>new _(e))}static async fromPath(e){return p("plugin:image|from_path",{path:e}).then(e=>new _(e))}async rgba(){return p("plugin:image|rgba",{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return p("plugin:image|size",{rid:this.rid})}}function y(e){return null==e?null:"string"==typeof e?e:e instanceof _?e.rid:e}var g,b=Object.freeze({__proto__:null,Image:_,transformImage:y});!function(e){e.Nsis="nsis",e.Msi="msi",e.Deb="deb",e.Rpm="rpm",e.AppImage="appimage",e.App="app"}(g||(g={}));var m=Object.freeze({__proto__:null,get BundleType(){return g},defaultWindowIcon:async function(){return p("plugin:app|default_window_icon").then(e=>e?new _(e):null)},fetchDataStoreIdentifiers:async function(){return p("plugin:app|fetch_data_store_identifiers")},getBundleType:async function(){return p("plugin:app|bundle_type")},getIdentifier:async function(){return p("plugin:app|identifier")},getName:async function(){return p("plugin:app|name")},getTauriVersion:async function(){return p("plugin:app|tauri_version")},getVersion:async function(){return p("plugin:app|version")},hide:async function(){return p("plugin:app|app_hide")},removeDataStore:async function(e){return p("plugin:app|remove_data_store",{uuid:e})},setDockVisibility:async function(e){return p("plugin:app|set_dock_visibility",{visible:e})},setTheme:async function(e){return p("plugin:app|set_app_theme",{theme:e})},show:async function(){return p("plugin:app|app_show")}});class f{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 v(this.width*e,this.height*e)}[o](){return{width:this.width,height:this.height}}toJSON(){return this[o]()}}class v{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 f(this.width/e,this.height/e)}[o](){return{width:this.width,height:this.height}}toJSON(){return this[o]()}}class k{constructor(e){this.size=e}toLogical(e){return this.size instanceof f?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof v?this.size:this.size.toPhysical(e)}[o](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[o]()}}class A{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 T(this.x*e,this.y*e)}[o](){return{x:this.x,y:this.y}}toJSON(){return this[o]()}}class T{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 A(this.x/e,this.y/e)}[o](){return{x:this.x,y:this.y}}toJSON(){return this[o]()}}class I{constructor(e){this.position=e}toLogical(e){return this.position instanceof A?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof T?this.position:this.position.toPhysical(e)}[o](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[o]()}}var E,R=Object.freeze({__proto__:null,LogicalPosition:A,LogicalSize:f,PhysicalPosition:T,PhysicalSize:v,Position:I,Size:k});async function D(e,n){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(e,n),await p("plugin:event|unlisten",{event:e,eventId:n})}async function N(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 p("plugin:event|listen",{event:e,target:r,handler:u(n)}).then(n=>async()=>D(e,n))}async function S(e,n,t){return N(e,t=>{D(e,t.id),n(t)},t)}async function L(e,n){await p("plugin:event|emit",{event:e,payload:n})}async function C(e,n,t){const i="string"==typeof e?{kind:"AnyLabel",label:e}:e;await p("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,W,P,z=Object.freeze({__proto__:null,get TauriEvent(){return E},emit:L,emitTo:C,listen:N,once:S});function O(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:O(e));else if("action"in e&&e.action){const n=new c;return n.onmessage=e.action,delete e.action,{...e,handler:n}}return e}async function U(e,n){const t=new c;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)),O(e))}n.items=n.items.map(i)}return p("plugin:menu|new",{kind:e,options:n,handler:t})}class F extends h{get id(){return n(this,x,"f")}get kind(){return n(this,W,"f")}constructor(e,n,i){super(e),x.set(this,void 0),W.set(this,void 0),t(this,x,n,"f"),t(this,W,i,"f")}}x=new WeakMap,W=new WeakMap;class M extends F{constructor(e,n){super(e,n,"MenuItem")}static async new(e){return U("MenuItem",e).then(([e,n])=>new M(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return p("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return p("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return p("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}}class B extends F{constructor(e,n){super(e,n,"Check")}static async new(e){return U("Check",e).then(([e,n])=>new B(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return p("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return p("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return p("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async isChecked(){return p("plugin:menu|is_checked",{rid:this.rid})}async setChecked(e){return p("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"}(P||(P={}));class V extends F{constructor(e,n){super(e,n,"Icon")}static async new(e){return U("Icon",e).then(([e,n])=>new V(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return p("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return p("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return p("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async setIcon(e){return p("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:y(e)})}}class G extends F{constructor(e,n){super(e,n,"Predefined")}static async new(e){return U("Predefined",e).then(([e,n])=>new G(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}}function j([e,n,t]){switch(t){case"Submenu":return new H(e,n);case"Predefined":return new G(e,n);case"Check":return new B(e,n);case"Icon":return new V(e,n);default:return new M(e,n)}}class H extends F{constructor(e,n){super(e,n,"Submenu")}static async new(e){return U("Submenu",e).then(([e,n])=>new H(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return p("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return p("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async append(e){return p("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 p("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 p("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 p("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return p("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(j)}async items(){return p("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(e=>e.map(j))}async get(e){return p("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then(e=>e?j(e):null)}async popup(e,n){var t;return p("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 I?e:e?new I(e):null})}async setAsWindowsMenuForNSApp(){return p("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return p("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}async setIcon(e){return p("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:y(e)})}}class q extends F{constructor(e,n){super(e,n,"Menu")}static async new(e){return U("Menu",e).then(([e,n])=>new q(e,n))}static async default(){return p("plugin:menu|create_default").then(([e,n])=>new q(e,n))}async append(e){return p("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 p("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 p("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 p("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return p("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(j)}async items(){return p("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(e=>e.map(j))}async get(e){return p("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then(e=>e?j(e):null)}async popup(e,n){var t;return p("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 I?e:e?new I(e):null})}async setAsAppMenu(){return p("plugin:menu|set_as_app_menu",{rid:this.rid}).then(e=>e?new q(e[0],e[1]):null)}async setAsWindowMenu(e){var n;return p("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 q(e[0],e[1]):null)}}var $=Object.freeze({__proto__:null,CheckMenuItem:B,IconMenuItem:V,Menu:q,MenuItem:M,get NativeIcon(){return P},PredefinedMenuItem:G,Submenu:H,itemFromKind:j});function J(){var e,n;window.__TAURI_INTERNALS__=null!==(e=window.__TAURI_INTERNALS__)&&void 0!==e?e:{},window.__TAURI_EVENT_PLUGIN_INTERNALS__=null!==(n=window.__TAURI_EVENT_PLUGIN_INTERNALS__)&&void 0!==n?n:{}}var Q,Z=Object.freeze({__proto__:null,clearMocks:function(){"object"==typeof window.__TAURI_INTERNALS__&&(delete window.__TAURI_INTERNALS__.invoke,delete window.__TAURI_INTERNALS__.transformCallback,delete window.__TAURI_INTERNALS__.unregisterCallback,delete window.__TAURI_INTERNALS__.runCallback,delete window.__TAURI_INTERNALS__.callbacks,delete window.__TAURI_INTERNALS__.convertFileSrc,delete window.__TAURI_INTERNALS__.metadata,"object"==typeof window.__TAURI_EVENT_PLUGIN_INTERNALS__&&delete window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener)},mockConvertFileSrc:function(e){J(),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,n){function t(e,n){switch(e){case"plugin:event|listen":return function(e){i.has(e.event)||i.set(e.event,[]);return i.get(e.event).push(e.handler),e.handler}(n);case"plugin:event|emit":return function(e){const n=i.get(e.event)||[];for(const t of n)a(t,e);return null}(n);case"plugin:event|unlisten":return function(e){const n=i.get(e.event);if(n){const t=n.indexOf(e.id);-1!==t&&n.splice(t,1)}}(n)}}J();const i=new Map,r=new Map;function s(e){r.delete(e)}function a(e,n){const t=r.get(e);t?t(n):console.warn(`[TAURI] Couldn't find callback id ${e}. This might happen when the app is reloaded while Rust is running an asynchronous operation.`)}window.__TAURI_INTERNALS__.invoke=async function(i,r,s){return(null==n?void 0:n.shouldMockEvents)&&function(e){return e.startsWith("plugin:event|")}(i)?t(i,r):e(i,r)},window.__TAURI_INTERNALS__.transformCallback=function(e,n=!1){const t=window.crypto.getRandomValues(new Uint32Array(1))[0];return r.set(t,i=>(n&&s(t),e&&e(i))),t},window.__TAURI_INTERNALS__.unregisterCallback=s,window.__TAURI_INTERNALS__.runCallback=a,window.__TAURI_INTERNALS__.callbacks=r,window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener=function(e,n){s(n)}},mockWindows:function(e,...n){J(),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 K=Object.freeze({__proto__:null,get BaseDirectory(){return Q},appCacheDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppCache})},appConfigDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppConfig})},appDataDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppData})},appLocalDataDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppLocalData})},appLogDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppLog})},audioDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Audio})},basename:async function(e,n){return p("plugin:path|basename",{path:e,ext:n})},cacheDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Cache})},configDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Config})},dataDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Data})},delimiter:function(){return window.__TAURI_INTERNALS__.plugins.path.delimiter},desktopDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Desktop})},dirname:async function(e){return p("plugin:path|dirname",{path:e})},documentDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Document})},downloadDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Download})},executableDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Executable})},extname:async function(e){return p("plugin:path|extname",{path:e})},fontDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Font})},homeDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Home})},isAbsolute:async function(e){return p("plugin:path|is_absolute",{path:e})},join:async function(...e){return p("plugin:path|join",{paths:e})},localDataDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.LocalData})},normalize:async function(e){return p("plugin:path|normalize",{path:e})},pictureDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Picture})},publicDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Public})},resolve:async function(...e){return p("plugin:path|resolve",{paths:e})},resolveResource:async function(e){return p("plugin:path|resolve_directory",{directory:Q.Resource,path:e})},resourceDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Resource})},runtimeDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Runtime})},sep:function(){return window.__TAURI_INTERNALS__.plugins.path.sep},tempDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Temp})},templateDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Template})},videoDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Video})}});class Y extends h{constructor(e,n){super(e),this.id=n}static async getById(e){return p("plugin:tray|get_by_id",{id:e}).then(n=>n?new Y(n,e):null)}static async removeById(e){return p("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 c;if(null==e?void 0:e.action){const t=e.action;n.onmessage=e=>t(function(e){const n=e;return n.position=new T(e.position),n.rect.position=new T(e.rect.position),n.rect.size=new v(e.rect.size),n}(e)),delete e.action}return p("plugin:tray|new",{options:null!=e?e:{},handler:n}).then(([e,n])=>new Y(e,n))}async setIcon(e){let n=null;return e&&(n=y(e)),p("plugin:tray|set_icon",{rid:this.rid,icon:n})}async setMenu(e){return e&&(e=[e.rid,e.kind]),p("plugin:tray|set_menu",{rid:this.rid,menu:e})}async setTooltip(e){return p("plugin:tray|set_tooltip",{rid:this.rid,tooltip:e})}async setTitle(e){return p("plugin:tray|set_title",{rid:this.rid,title:e})}async setVisible(e){return p("plugin:tray|set_visible",{rid:this.rid,visible:e})}async setTempDirPath(e){return p("plugin:tray|set_temp_dir_path",{rid:this.rid,path:e})}async setIconAsTemplate(e){return p("plugin:tray|set_icon_as_template",{rid:this.rid,asTemplate:e})}async setMenuOnLeftClick(e){return p("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}async setShowMenuOnLeftClick(e){return p("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}}var X,ee,ne=Object.freeze({__proto__:null,TrayIcon:Y});!function(e){e[e.Critical=1]="Critical",e[e.Informational=2]="Informational"}(X||(X={}));class te{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}function ie(){return new ae(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function re(){return p("plugin:window|get_all_windows").then(e=>e.map(e=>new ae(e,{skip:!0})))}!function(e){e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error"}(ee||(ee={}));const se=["tauri://created","tauri://error"];class ae{constructor(e,n={}){var t;this.label=e,this.listeners=Object.create(null),(null==n?void 0:n.skip)||p("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 re()).find(n=>n.label===e))&&void 0!==n?n:null}static getCurrent(){return ie()}static async getAll(){return re()}static async getFocusedWindow(){for(const e of await re())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)}:N(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)}:S(e,n,{target:{kind:"Window",label:this.label}})}async emit(e,n){if(!se.includes(e))return L(e,n);for(const t of this.listeners[e]||[])t({event:e,id:-1,payload:n})}async emitTo(e,n,t){if(!se.includes(n))return C(e,n,t);for(const e of this.listeners[n]||[])e({event:n,id:-1,payload:t})}_handleTauriEvent(e,n){return!!se.includes(e)&&(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0)}async scaleFactor(){return p("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return p("plugin:window|inner_position",{label:this.label}).then(e=>new T(e))}async outerPosition(){return p("plugin:window|outer_position",{label:this.label}).then(e=>new T(e))}async innerSize(){return p("plugin:window|inner_size",{label:this.label}).then(e=>new v(e))}async outerSize(){return p("plugin:window|outer_size",{label:this.label}).then(e=>new v(e))}async isFullscreen(){return p("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return p("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return p("plugin:window|is_maximized",{label:this.label})}async isFocused(){return p("plugin:window|is_focused",{label:this.label})}async isDecorated(){return p("plugin:window|is_decorated",{label:this.label})}async isResizable(){return p("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return p("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return p("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return p("plugin:window|is_closable",{label:this.label})}async isVisible(){return p("plugin:window|is_visible",{label:this.label})}async title(){return p("plugin:window|title",{label:this.label})}async theme(){return p("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return p("plugin:window|is_always_on_top",{label:this.label})}async center(){return p("plugin:window|center",{label:this.label})}async requestUserAttention(e){let n=null;return e&&(n=e===X.Critical?{type:"Critical"}:{type:"Informational"}),p("plugin:window|request_user_attention",{label:this.label,value:n})}async setResizable(e){return p("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return p("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return p("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return p("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return p("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return p("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return p("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return p("plugin:window|maximize",{label:this.label})}async unmaximize(){return p("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return p("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return p("plugin:window|minimize",{label:this.label})}async unminimize(){return p("plugin:window|unminimize",{label:this.label})}async show(){return p("plugin:window|show",{label:this.label})}async hide(){return p("plugin:window|hide",{label:this.label})}async close(){return p("plugin:window|close",{label:this.label})}async destroy(){return p("plugin:window|destroy",{label:this.label})}async setDecorations(e){return p("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return p("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return p("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return p("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return p("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return p("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return p("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return p("plugin:window|set_size",{label:this.label,value:e instanceof k?e:new k(e)})}async setMinSize(e){return p("plugin:window|set_min_size",{label:this.label,value:e instanceof k?e:e?new k(e):null})}async setMaxSize(e){return p("plugin:window|set_max_size",{label:this.label,value:e instanceof k?e:e?new k(e):null})}async setSizeConstraints(e){function n(e){return e?{Logical:e}:null}return p("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 p("plugin:window|set_position",{label:this.label,value:e instanceof I?e:new I(e)})}async setFullscreen(e){return p("plugin:window|set_fullscreen",{label:this.label,value:e})}async setSimpleFullscreen(e){return p("plugin:window|set_simple_fullscreen",{label:this.label,value:e})}async setFocus(){return p("plugin:window|set_focus",{label:this.label})}async setFocusable(e){return p("plugin:window|set_focusable",{label:this.label,value:e})}async setIcon(e){return p("plugin:window|set_icon",{label:this.label,value:y(e)})}async setSkipTaskbar(e){return p("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return p("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return p("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return p("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return p("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return p("plugin:window|set_cursor_position",{label:this.label,value:e instanceof I?e:new I(e)})}async setIgnoreCursorEvents(e){return p("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return p("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return p("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return p("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return p("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return p("plugin:window|set_overlay_icon",{label:this.label,value:e?y(e):void 0})}async setProgressBar(e){return p("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return p("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return p("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return p("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(E.WINDOW_RESIZED,n=>{n.payload=new v(n.payload),e(n)})}async onMoved(e){return this.listen(E.WINDOW_MOVED,n=>{n.payload=new T(n.payload),e(n)})}async onCloseRequested(e){return this.listen(E.WINDOW_CLOSE_REQUESTED,async n=>{const t=new te(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 T(n.payload.position)}})}),t=await this.listen(E.DRAG_OVER,n=>{e({...n,payload:{type:"over",position:new T(n.payload.position)}})}),i=await this.listen(E.DRAG_DROP,n=>{e({...n,payload:{type:"drop",paths:n.payload.paths,position:new T(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 le,oe,ue,ce;function de(e){return null===e?null:{name:e.name,scaleFactor:e.scaleFactor,position:new T(e.position),size:new v(e.size),workArea:{position:new T(e.workArea.position),size:new v(e.workArea.size)}}}!function(e){e.Disabled="disabled",e.Throttle="throttle",e.Suspend="suspend"}(le||(le={})),function(e){e.Default="default",e.FluentOverlay="fluentOverlay"}(oe||(oe={})),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"}(ue||(ue={})),function(e){e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive"}(ce||(ce={}));var pe=Object.freeze({__proto__:null,CloseRequestedEvent:te,get Effect(){return ue},get EffectState(){return ce},LogicalPosition:A,LogicalSize:f,PhysicalPosition:T,PhysicalSize:v,get ProgressBarStatus(){return ee},get UserAttentionType(){return X},Window:ae,availableMonitors:async function(){return p("plugin:window|available_monitors").then(e=>e.map(de))},currentMonitor:async function(){return p("plugin:window|current_monitor").then(de)},cursorPosition:async function(){return p("plugin:window|cursor_position").then(e=>new T(e))},getAllWindows:re,getCurrentWindow:ie,monitorFromPoint:async function(e,n){return p("plugin:window|monitor_from_point",{x:e,y:n}).then(de)},primaryMonitor:async function(){return p("plugin:window|primary_monitor").then(de)}});function he(){return new ye(ie(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function we(){return p("plugin:webview|get_all_webviews").then(e=>e.map(e=>new ye(new ae(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}const _e=["tauri://created","tauri://error"];class ye{constructor(e,n,t){this.window=e,this.label=n,this.listeners=Object.create(null),(null==t?void 0:t.skip)||("string"==typeof(null==t?void 0:t.onNewWindow)&&(t.onNewWindow={action:t.onNewWindow}),p("plugin:webview|create_webview",{windowLabel:e.label,options:{...t,label:n}}).then(async()=>this.emit("tauri://created")).catch(async e=>this.emit("tauri://error",e)))}static async getByLabel(e){var n;return null!==(n=(await we()).find(n=>n.label===e))&&void 0!==n?n:null}static getCurrent(){return he()}static async getAll(){return we()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:N(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)}:S(e,n,{target:{kind:"Webview",label:this.label}})}async emit(e,n){if(!_e.includes(e))return L(e,n);for(const t of this.listeners[e]||[])t({event:e,id:-1,payload:n})}async emitTo(e,n,t){if(!_e.includes(n))return C(e,n,t);for(const e of this.listeners[n]||[])e({event:n,id:-1,payload:t})}_handleTauriEvent(e,n){return!!_e.includes(e)&&(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0)}async position(){return p("plugin:webview|webview_position",{label:this.label}).then(e=>new T(e))}async size(){return p("plugin:webview|webview_size",{label:this.label}).then(e=>new v(e))}async close(){return p("plugin:webview|webview_close",{label:this.label})}async setSize(e){return p("plugin:webview|set_webview_size",{label:this.label,value:e instanceof k?e:new k(e)})}async setPosition(e){return p("plugin:webview|set_webview_position",{label:this.label,value:e instanceof I?e:new I(e)})}async setFocus(){return p("plugin:webview|set_webview_focus",{label:this.label})}async setAutoResize(e){return p("plugin:webview|set_webview_auto_resize",{label:this.label,value:e})}async hide(){return p("plugin:webview|webview_hide",{label:this.label})}async show(){return p("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return p("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return p("plugin:webview|reparent",{label:this.label,window:"string"==typeof e?e:e.label})}async clearAllBrowsingData(){return p("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return p("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 T(n.payload.position)}})}),t=await this.listen(E.DRAG_OVER,n=>{e({...n,payload:{type:"over",position:new T(n.payload.position)}})}),i=await this.listen(E.DRAG_DROP,n=>{e({...n,payload:{type:"drop",paths:n.payload.paths,position:new T(n.payload.position)}})}),r=await this.listen(E.DRAG_LEAVE,n=>{e({...n,payload:{type:"leave"}})});return()=>{n(),i(),t(),r()}}}var ge,be,me=Object.freeze({__proto__:null,Webview:ye,getAllWebviews:we,getCurrentWebview:he});function fe(){const e=he();return new ke(e.label,{skip:!0})}async function ve(){return p("plugin:window|get_all_windows").then(e=>e.map(e=>new ke(e,{skip:!0})))}class ke{constructor(e,n={}){var t;this.label=e,this.listeners=Object.create(null),(null==n?void 0:n.skip)||("string"==typeof(null==n?void 0:n.onNewWindow)&&(n.onNewWindow={action:n.onNewWindow}),p("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 ve()).find(n=>n.label===e))&&void 0!==n?n:null;return t?new ke(t.label,{skip:!0}):null}static getCurrent(){return fe()}static async getAll(){return ve()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:N(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)}:S(e,n,{target:{kind:"WebviewWindow",label:this.label}})}async setBackgroundColor(e){return p("plugin:window|set_background_color",{color:e}).then(()=>p("plugin:webview|set_webview_background_color",{color:e}))}}ge=ke,be=[ae,ye],(Array.isArray(be)?be:[be]).forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(n=>{var t;"object"==typeof ge.prototype&&ge.prototype&&n in ge.prototype||Object.defineProperty(ge.prototype,n,null!==(t=Object.getOwnPropertyDescriptor(e.prototype,n))&&void 0!==t?t:Object.create(null))})});var Ae=Object.freeze({__proto__:null,WebviewWindow:ke,getAllWebviewWindows:ve,getCurrentWebviewWindow:fe});return e.app=m,e.core=w,e.dpi=R,e.event=z,e.image=b,e.menu=$,e.mocks=Z,e.path=K,e.tray=ne,e.webview=me,e.webviewWindow=Ae,e.window=pe,e}({});window.__TAURI__=__TAURI_IIFE__; diff --git a/crates/tauri/src/webview/mod.rs b/crates/tauri/src/webview/mod.rs index c185e7c62124..948298bd90a1 100644 --- a/crates/tauri/src/webview/mod.rs +++ b/crates/tauri/src/webview/mod.rs @@ -31,7 +31,7 @@ use tauri_runtime::{ WebviewDispatch, }; pub use tauri_utils::config::Color; -use tauri_utils::config::{BackgroundThrottlingPolicy, WebviewUrl, WindowConfig}; +use tauri_utils::config::{BackgroundThrottlingPolicy, OnNewWindow, WebviewUrl, WindowConfig}; pub use url::Url; use crate::{ @@ -48,6 +48,7 @@ use crate::{ ResourceTable, Runtime, Window, }; +use std::sync::atomic::AtomicUsize; use std::{ borrow::Cow, hash::{Hash, Hasher}, @@ -274,13 +275,18 @@ unstable_struct!( pub(crate) webview_attributes: WebviewAttributes, pub(crate) web_resource_request_handler: Option>, pub(crate) navigation_handler: Option>, - pub(crate) new_window_handler: Option>>, + pub(crate) on_new_window_handler: Option>, pub(crate) on_page_load_handler: Option>>, pub(crate) document_title_changed_handler: Option>>, pub(crate) download_handler: Option>>, } ); +pub(crate) enum OnNewWindowHandler { + Fn(Box>), + Flag(OnNewWindow), +} + #[cfg_attr(not(feature = "unstable"), allow(dead_code))] impl WebviewBuilder { /// Initializes a webview builder with the given webview label and URL to load. @@ -352,7 +358,7 @@ async fn create_window(app: tauri::AppHandle) { webview_attributes: WebviewAttributes::new(url), web_resource_request_handler: None, navigation_handler: None, - new_window_handler: None, + on_new_window_handler: None, on_page_load_handler: None, document_title_changed_handler: None, download_handler: None, @@ -431,7 +437,7 @@ async fn create_window(app: tauri::AppHandle) { webview_attributes: WebviewAttributes::from(&config), web_resource_request_handler: None, navigation_handler: None, - new_window_handler: None, + on_new_window_handler: Some(OnNewWindowHandler::Flag(config.on_new_window)), on_page_load_handler: None, document_title_changed_handler: None, download_handler: None, @@ -590,7 +596,9 @@ tauri::Builder::default() mut self, f: F, ) -> Self { - self.new_window_handler.replace(Box::new(f)); + self + .on_new_window_handler + .replace(OnNewWindowHandler::Fn(Box::new(f))); self } @@ -704,30 +712,82 @@ tauri::Builder::default() ) -> crate::Result> { let mut pending = PendingWebview::new(self.webview_attributes, self.label.clone())?; pending.navigation_handler = self.navigation_handler.take(); - pending.new_window_handler = self.new_window_handler.take().map(|handler| { - Box::new( - move |url, features: NewWindowFeatures| match handler(url, features) { - NewWindowResponse::Allow => tauri_runtime::webview::NewWindowResponse::Allow, - #[cfg(mobile)] - NewWindowResponse::Create { window: _ } => { - tauri_runtime::webview::NewWindowResponse::Allow + let app_handle = manager.app_handle().clone(); + let label = window_label.to_string(); + pending.new_window_handler = + self + .on_new_window_handler + .take() + .map(|on_new_window| match on_new_window { + OnNewWindowHandler::Fn(handler) => { + Box::new( + move |url, features: NewWindowFeatures| match handler(url, features) { + NewWindowResponse::Allow => tauri_runtime::webview::NewWindowResponse::Allow, + #[cfg(mobile)] + NewWindowResponse::Create { window: _ } => { + tauri_runtime::webview::NewWindowResponse::Allow + } + #[cfg(desktop)] + NewWindowResponse::Create { window } => { + tauri_runtime::webview::NewWindowResponse::Create { + window_id: window.window.window.id, + } + } + NewWindowResponse::Deny => tauri_runtime::webview::NewWindowResponse::Deny, + }, + ) + as Box< + dyn Fn(Url, NewWindowFeatures) -> tauri_runtime::webview::NewWindowResponse + + Send + + Sync + + 'static, + > } - #[cfg(desktop)] - NewWindowResponse::Create { window } => { - tauri_runtime::webview::NewWindowResponse::Create { - window_id: window.window.window.id, - } + OnNewWindowHandler::Flag(on_new_window) => { + let created_window_count = AtomicUsize::new(0); + Box::new(move |url, features| match &on_new_window { + OnNewWindow::AllowDefault { urls: Some(urls) } => { + if urls.iter().any(|pattern| pattern.test(&url)) { + tauri_runtime::webview::NewWindowResponse::Allow + } else { + tauri_runtime::webview::NewWindowResponse::Deny + } + } + OnNewWindow::AllowTauriWindow { urls: Some(urls) } => { + if urls.iter().any(|pattern| pattern.test(&url)) { + let number = + created_window_count.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + + let builder = WebviewWindowBuilder::new( + &app_handle, + format!("{label}-created-{number}"), + WebviewUrl::External("about:blank".parse().unwrap()), + ) + .window_features(features) + .on_document_title_changed(|window, title| { + window.set_title(&title).unwrap(); + }) + .title(url.as_str()); + + let window = builder.build().unwrap(); + tauri_runtime::webview::NewWindowResponse::Create { + window_id: window.window.window.id, + } + } else { + tauri_runtime::webview::NewWindowResponse::Deny + } + } + OnNewWindow::AllowDefault { urls: None } => { + tauri_runtime::webview::NewWindowResponse::Allow + } + OnNewWindow::AllowTauriWindow { urls: None } => { + tauri_runtime::webview::NewWindowResponse::Allow + } + OnNewWindow::Deny => tauri_runtime::webview::NewWindowResponse::Deny, + _ => tauri_runtime::webview::NewWindowResponse::Deny, + }) } - NewWindowResponse::Deny => tauri_runtime::webview::NewWindowResponse::Deny, - }, - ) - as Box< - dyn Fn(Url, NewWindowFeatures) -> tauri_runtime::webview::NewWindowResponse - + Send - + Sync - + 'static, - > - }); + }); if let Some(document_title_changed_handler) = self.document_title_changed_handler.take() { let label = pending.label.clone(); diff --git a/packages/api/src/webview.ts b/packages/api/src/webview.ts index cf78dffe6874..d66246b8ce59 100644 --- a/packages/api/src/webview.ts +++ b/packages/api/src/webview.ts @@ -199,6 +199,10 @@ class Webview { // @ts-expect-error `skip` is not a public API so it is not defined in WebviewOptions if (!options?.skip) { + if (typeof options?.onNewWindow === 'string') { + options.onNewWindow = { action: options.onNewWindow } + } + invoke('plugin:webview|create_webview', { windowLabel: window.label, options: { @@ -897,8 +901,31 @@ interface WebviewOptions { * - **Linux / Android / iOS / macOS**: Unsupported. Only supports `Default` and performs no operation. */ scrollBarStyle?: ScrollBarStyle + /** + * Action to perform when a new window is requested to be created. + * + * 'allowDefault' lets the webview open the URL using the native implementation. + * 'allowTauriWindow' creates a Tauri window to load the URL. + * Additionally you can provide a list of filters to only allow URLs matching certain {@link https://developer.mozilla.org/en-US/docs/Web/API/URLPattern|URL patterns}. + * + * A new window is requested to be opened by the {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/open|window.open API}. + * + * ## Platform-specific + * + * - **Android / iOS**: Not supported. + * + * */ + onNewWindow?: onNewWindow } +type onNewWindow = + | 'allowDefault' + | 'allowTauriWindow' + | 'deny' + | { action: 'allowDefault'; urls?: string[] } + | { action: 'allowTauriWindow'; urls?: string[] } + | { action: 'deny' } + export { Webview, getCurrentWebview, getAllWebviews } -export type { DragDropEvent, WebviewOptions, Color } +export type { DragDropEvent, WebviewOptions, Color, onNewWindow } diff --git a/packages/api/src/webviewWindow.ts b/packages/api/src/webviewWindow.ts index f73d5cab58a8..e8d33bc7972e 100644 --- a/packages/api/src/webviewWindow.ts +++ b/packages/api/src/webviewWindow.ts @@ -83,6 +83,10 @@ class WebviewWindow { // @ts-expect-error `skip` is not a public API so it is not defined in WebviewOptions if (!options?.skip) { + if (typeof options?.onNewWindow === 'string') { + options.onNewWindow = { action: options.onNewWindow } + } + invoke('plugin:webview|create_webview_window', { options: { ...options, From 0df3eee3d8d02a6df9ad23bae5c19df12aedf16f Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Sun, 12 Oct 2025 19:00:18 -0300 Subject: [PATCH 2/5] fix ci --- crates/tauri-utils/src/url.rs | 2 +- crates/tauri/scripts/bundle.global.js | 2 +- crates/tauri/src/webview/mod.rs | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/tauri-utils/src/url.rs b/crates/tauri-utils/src/url.rs index 58bae39b79f6..8f4340ab1076 100644 --- a/crates/tauri-utils/src/url.rs +++ b/crates/tauri-utils/src/url.rs @@ -1,4 +1,4 @@ -// Copyright 2019-2025 Tauri Programme within The Commons Conservancy +// Copyright 2019-2024 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT diff --git a/crates/tauri/scripts/bundle.global.js b/crates/tauri/scripts/bundle.global.js index beecc77c6dc7..e68499fbebfd 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,l;"function"==typeof SuppressedError&&SuppressedError;const o="__TAURI_TO_IPC_KEY__";function u(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}class c{constructor(e){i.set(this,void 0),r.set(this,0),s.set(this,[]),a.set(this,void 0),t(this,i,e||(()=>{}),"f"),this.id=u(e=>{const l=e.index;if("end"in e)return void(l==n(this,r,"f")?this.cleanupCallback():t(this,a,l,"f"));const o=e.message;if(l==n(this,r,"f")){for(n(this,i,"f").call(this,o),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")}n(this,r,"f")===n(this,a,"f")&&this.cleanupCallback()}else n(this,s,"f")[l]=o})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){t(this,i,e,"f")}get onmessage(){return n(this,i,"f")}[(i=new WeakMap,r=new WeakMap,s=new WeakMap,a=new WeakMap,o)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[o]()}}class d{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return p(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function p(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}class h{get rid(){return n(this,l,"f")}constructor(e){l.set(this,void 0),t(this,l,e,"f")}async close(){return p("plugin:resources|close",{rid:this.rid})}}l=new WeakMap;var w=Object.freeze({__proto__:null,Channel:c,PluginListener:d,Resource:h,SERIALIZE_TO_IPC_FN:o,addPluginListener:async function(e,n,t){const i=new c(t);try{return p(`plugin:${e}|register_listener`,{event:n,handler:i}).then(()=>new d(e,n,i.id))}catch{return p(`plugin:${e}|registerListener`,{event:n,handler:i}).then(()=>new d(e,n,i.id))}},checkPermissions:async function(e){return p(`plugin:${e}|check_permissions`)},convertFileSrc:function(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)},invoke:p,isTauri:function(){return!!(globalThis||window).isTauri},requestPermissions:async function(e){return p(`plugin:${e}|request_permissions`)},transformCallback:u});class _ extends h{constructor(e){super(e)}static async new(e,n,t){return p("plugin:image|new",{rgba:y(e),width:n,height:t}).then(e=>new _(e))}static async fromBytes(e){return p("plugin:image|from_bytes",{bytes:y(e)}).then(e=>new _(e))}static async fromPath(e){return p("plugin:image|from_path",{path:e}).then(e=>new _(e))}async rgba(){return p("plugin:image|rgba",{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return p("plugin:image|size",{rid:this.rid})}}function y(e){return null==e?null:"string"==typeof e?e:e instanceof _?e.rid:e}var g,b=Object.freeze({__proto__:null,Image:_,transformImage:y});!function(e){e.Nsis="nsis",e.Msi="msi",e.Deb="deb",e.Rpm="rpm",e.AppImage="appimage",e.App="app"}(g||(g={}));var m=Object.freeze({__proto__:null,get BundleType(){return g},defaultWindowIcon:async function(){return p("plugin:app|default_window_icon").then(e=>e?new _(e):null)},fetchDataStoreIdentifiers:async function(){return p("plugin:app|fetch_data_store_identifiers")},getBundleType:async function(){return p("plugin:app|bundle_type")},getIdentifier:async function(){return p("plugin:app|identifier")},getName:async function(){return p("plugin:app|name")},getTauriVersion:async function(){return p("plugin:app|tauri_version")},getVersion:async function(){return p("plugin:app|version")},hide:async function(){return p("plugin:app|app_hide")},removeDataStore:async function(e){return p("plugin:app|remove_data_store",{uuid:e})},setDockVisibility:async function(e){return p("plugin:app|set_dock_visibility",{visible:e})},setTheme:async function(e){return p("plugin:app|set_app_theme",{theme:e})},show:async function(){return p("plugin:app|app_show")}});class f{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 v(this.width*e,this.height*e)}[o](){return{width:this.width,height:this.height}}toJSON(){return this[o]()}}class v{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 f(this.width/e,this.height/e)}[o](){return{width:this.width,height:this.height}}toJSON(){return this[o]()}}class k{constructor(e){this.size=e}toLogical(e){return this.size instanceof f?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof v?this.size:this.size.toPhysical(e)}[o](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[o]()}}class A{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 T(this.x*e,this.y*e)}[o](){return{x:this.x,y:this.y}}toJSON(){return this[o]()}}class T{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 A(this.x/e,this.y/e)}[o](){return{x:this.x,y:this.y}}toJSON(){return this[o]()}}class I{constructor(e){this.position=e}toLogical(e){return this.position instanceof A?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof T?this.position:this.position.toPhysical(e)}[o](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[o]()}}var E,R=Object.freeze({__proto__:null,LogicalPosition:A,LogicalSize:f,PhysicalPosition:T,PhysicalSize:v,Position:I,Size:k});async function D(e,n){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(e,n),await p("plugin:event|unlisten",{event:e,eventId:n})}async function N(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 p("plugin:event|listen",{event:e,target:r,handler:u(n)}).then(n=>async()=>D(e,n))}async function S(e,n,t){return N(e,t=>{D(e,t.id),n(t)},t)}async function L(e,n){await p("plugin:event|emit",{event:e,payload:n})}async function C(e,n,t){const i="string"==typeof e?{kind:"AnyLabel",label:e}:e;await p("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,W,P,z=Object.freeze({__proto__:null,get TauriEvent(){return E},emit:L,emitTo:C,listen:N,once:S});function O(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:O(e));else if("action"in e&&e.action){const n=new c;return n.onmessage=e.action,delete e.action,{...e,handler:n}}return e}async function U(e,n){const t=new c;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)),O(e))}n.items=n.items.map(i)}return p("plugin:menu|new",{kind:e,options:n,handler:t})}class F extends h{get id(){return n(this,x,"f")}get kind(){return n(this,W,"f")}constructor(e,n,i){super(e),x.set(this,void 0),W.set(this,void 0),t(this,x,n,"f"),t(this,W,i,"f")}}x=new WeakMap,W=new WeakMap;class M extends F{constructor(e,n){super(e,n,"MenuItem")}static async new(e){return U("MenuItem",e).then(([e,n])=>new M(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return p("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return p("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return p("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}}class B extends F{constructor(e,n){super(e,n,"Check")}static async new(e){return U("Check",e).then(([e,n])=>new B(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return p("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return p("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return p("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async isChecked(){return p("plugin:menu|is_checked",{rid:this.rid})}async setChecked(e){return p("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"}(P||(P={}));class V extends F{constructor(e,n){super(e,n,"Icon")}static async new(e){return U("Icon",e).then(([e,n])=>new V(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return p("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return p("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return p("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async setIcon(e){return p("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:y(e)})}}class G extends F{constructor(e,n){super(e,n,"Predefined")}static async new(e){return U("Predefined",e).then(([e,n])=>new G(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}}function j([e,n,t]){switch(t){case"Submenu":return new H(e,n);case"Predefined":return new G(e,n);case"Check":return new B(e,n);case"Icon":return new V(e,n);default:return new M(e,n)}}class H extends F{constructor(e,n){super(e,n,"Submenu")}static async new(e){return U("Submenu",e).then(([e,n])=>new H(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return p("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return p("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async append(e){return p("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 p("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 p("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 p("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return p("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(j)}async items(){return p("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(e=>e.map(j))}async get(e){return p("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then(e=>e?j(e):null)}async popup(e,n){var t;return p("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 I?e:e?new I(e):null})}async setAsWindowsMenuForNSApp(){return p("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return p("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}async setIcon(e){return p("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:y(e)})}}class q extends F{constructor(e,n){super(e,n,"Menu")}static async new(e){return U("Menu",e).then(([e,n])=>new q(e,n))}static async default(){return p("plugin:menu|create_default").then(([e,n])=>new q(e,n))}async append(e){return p("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 p("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 p("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 p("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return p("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(j)}async items(){return p("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(e=>e.map(j))}async get(e){return p("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then(e=>e?j(e):null)}async popup(e,n){var t;return p("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 I?e:e?new I(e):null})}async setAsAppMenu(){return p("plugin:menu|set_as_app_menu",{rid:this.rid}).then(e=>e?new q(e[0],e[1]):null)}async setAsWindowMenu(e){var n;return p("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 q(e[0],e[1]):null)}}var $=Object.freeze({__proto__:null,CheckMenuItem:B,IconMenuItem:V,Menu:q,MenuItem:M,get NativeIcon(){return P},PredefinedMenuItem:G,Submenu:H,itemFromKind:j});function J(){var e,n;window.__TAURI_INTERNALS__=null!==(e=window.__TAURI_INTERNALS__)&&void 0!==e?e:{},window.__TAURI_EVENT_PLUGIN_INTERNALS__=null!==(n=window.__TAURI_EVENT_PLUGIN_INTERNALS__)&&void 0!==n?n:{}}var Q,Z=Object.freeze({__proto__:null,clearMocks:function(){"object"==typeof window.__TAURI_INTERNALS__&&(delete window.__TAURI_INTERNALS__.invoke,delete window.__TAURI_INTERNALS__.transformCallback,delete window.__TAURI_INTERNALS__.unregisterCallback,delete window.__TAURI_INTERNALS__.runCallback,delete window.__TAURI_INTERNALS__.callbacks,delete window.__TAURI_INTERNALS__.convertFileSrc,delete window.__TAURI_INTERNALS__.metadata,"object"==typeof window.__TAURI_EVENT_PLUGIN_INTERNALS__&&delete window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener)},mockConvertFileSrc:function(e){J(),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,n){function t(e,n){switch(e){case"plugin:event|listen":return function(e){i.has(e.event)||i.set(e.event,[]);return i.get(e.event).push(e.handler),e.handler}(n);case"plugin:event|emit":return function(e){const n=i.get(e.event)||[];for(const t of n)a(t,e);return null}(n);case"plugin:event|unlisten":return function(e){const n=i.get(e.event);if(n){const t=n.indexOf(e.id);-1!==t&&n.splice(t,1)}}(n)}}J();const i=new Map,r=new Map;function s(e){r.delete(e)}function a(e,n){const t=r.get(e);t?t(n):console.warn(`[TAURI] Couldn't find callback id ${e}. This might happen when the app is reloaded while Rust is running an asynchronous operation.`)}window.__TAURI_INTERNALS__.invoke=async function(i,r,s){return(null==n?void 0:n.shouldMockEvents)&&function(e){return e.startsWith("plugin:event|")}(i)?t(i,r):e(i,r)},window.__TAURI_INTERNALS__.transformCallback=function(e,n=!1){const t=window.crypto.getRandomValues(new Uint32Array(1))[0];return r.set(t,i=>(n&&s(t),e&&e(i))),t},window.__TAURI_INTERNALS__.unregisterCallback=s,window.__TAURI_INTERNALS__.runCallback=a,window.__TAURI_INTERNALS__.callbacks=r,window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener=function(e,n){s(n)}},mockWindows:function(e,...n){J(),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 K=Object.freeze({__proto__:null,get BaseDirectory(){return Q},appCacheDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppCache})},appConfigDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppConfig})},appDataDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppData})},appLocalDataDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppLocalData})},appLogDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppLog})},audioDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Audio})},basename:async function(e,n){return p("plugin:path|basename",{path:e,ext:n})},cacheDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Cache})},configDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Config})},dataDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Data})},delimiter:function(){return window.__TAURI_INTERNALS__.plugins.path.delimiter},desktopDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Desktop})},dirname:async function(e){return p("plugin:path|dirname",{path:e})},documentDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Document})},downloadDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Download})},executableDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Executable})},extname:async function(e){return p("plugin:path|extname",{path:e})},fontDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Font})},homeDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Home})},isAbsolute:async function(e){return p("plugin:path|is_absolute",{path:e})},join:async function(...e){return p("plugin:path|join",{paths:e})},localDataDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.LocalData})},normalize:async function(e){return p("plugin:path|normalize",{path:e})},pictureDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Picture})},publicDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Public})},resolve:async function(...e){return p("plugin:path|resolve",{paths:e})},resolveResource:async function(e){return p("plugin:path|resolve_directory",{directory:Q.Resource,path:e})},resourceDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Resource})},runtimeDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Runtime})},sep:function(){return window.__TAURI_INTERNALS__.plugins.path.sep},tempDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Temp})},templateDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Template})},videoDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Video})}});class Y extends h{constructor(e,n){super(e),this.id=n}static async getById(e){return p("plugin:tray|get_by_id",{id:e}).then(n=>n?new Y(n,e):null)}static async removeById(e){return p("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 c;if(null==e?void 0:e.action){const t=e.action;n.onmessage=e=>t(function(e){const n=e;return n.position=new T(e.position),n.rect.position=new T(e.rect.position),n.rect.size=new v(e.rect.size),n}(e)),delete e.action}return p("plugin:tray|new",{options:null!=e?e:{},handler:n}).then(([e,n])=>new Y(e,n))}async setIcon(e){let n=null;return e&&(n=y(e)),p("plugin:tray|set_icon",{rid:this.rid,icon:n})}async setMenu(e){return e&&(e=[e.rid,e.kind]),p("plugin:tray|set_menu",{rid:this.rid,menu:e})}async setTooltip(e){return p("plugin:tray|set_tooltip",{rid:this.rid,tooltip:e})}async setTitle(e){return p("plugin:tray|set_title",{rid:this.rid,title:e})}async setVisible(e){return p("plugin:tray|set_visible",{rid:this.rid,visible:e})}async setTempDirPath(e){return p("plugin:tray|set_temp_dir_path",{rid:this.rid,path:e})}async setIconAsTemplate(e){return p("plugin:tray|set_icon_as_template",{rid:this.rid,asTemplate:e})}async setMenuOnLeftClick(e){return p("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}async setShowMenuOnLeftClick(e){return p("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}}var X,ee,ne=Object.freeze({__proto__:null,TrayIcon:Y});!function(e){e[e.Critical=1]="Critical",e[e.Informational=2]="Informational"}(X||(X={}));class te{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}function ie(){return new ae(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function re(){return p("plugin:window|get_all_windows").then(e=>e.map(e=>new ae(e,{skip:!0})))}!function(e){e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error"}(ee||(ee={}));const se=["tauri://created","tauri://error"];class ae{constructor(e,n={}){var t;this.label=e,this.listeners=Object.create(null),(null==n?void 0:n.skip)||p("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 re()).find(n=>n.label===e))&&void 0!==n?n:null}static getCurrent(){return ie()}static async getAll(){return re()}static async getFocusedWindow(){for(const e of await re())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)}:N(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)}:S(e,n,{target:{kind:"Window",label:this.label}})}async emit(e,n){if(!se.includes(e))return L(e,n);for(const t of this.listeners[e]||[])t({event:e,id:-1,payload:n})}async emitTo(e,n,t){if(!se.includes(n))return C(e,n,t);for(const e of this.listeners[n]||[])e({event:n,id:-1,payload:t})}_handleTauriEvent(e,n){return!!se.includes(e)&&(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0)}async scaleFactor(){return p("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return p("plugin:window|inner_position",{label:this.label}).then(e=>new T(e))}async outerPosition(){return p("plugin:window|outer_position",{label:this.label}).then(e=>new T(e))}async innerSize(){return p("plugin:window|inner_size",{label:this.label}).then(e=>new v(e))}async outerSize(){return p("plugin:window|outer_size",{label:this.label}).then(e=>new v(e))}async isFullscreen(){return p("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return p("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return p("plugin:window|is_maximized",{label:this.label})}async isFocused(){return p("plugin:window|is_focused",{label:this.label})}async isDecorated(){return p("plugin:window|is_decorated",{label:this.label})}async isResizable(){return p("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return p("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return p("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return p("plugin:window|is_closable",{label:this.label})}async isVisible(){return p("plugin:window|is_visible",{label:this.label})}async title(){return p("plugin:window|title",{label:this.label})}async theme(){return p("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return p("plugin:window|is_always_on_top",{label:this.label})}async center(){return p("plugin:window|center",{label:this.label})}async requestUserAttention(e){let n=null;return e&&(n=e===X.Critical?{type:"Critical"}:{type:"Informational"}),p("plugin:window|request_user_attention",{label:this.label,value:n})}async setResizable(e){return p("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return p("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return p("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return p("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return p("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return p("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return p("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return p("plugin:window|maximize",{label:this.label})}async unmaximize(){return p("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return p("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return p("plugin:window|minimize",{label:this.label})}async unminimize(){return p("plugin:window|unminimize",{label:this.label})}async show(){return p("plugin:window|show",{label:this.label})}async hide(){return p("plugin:window|hide",{label:this.label})}async close(){return p("plugin:window|close",{label:this.label})}async destroy(){return p("plugin:window|destroy",{label:this.label})}async setDecorations(e){return p("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return p("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return p("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return p("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return p("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return p("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return p("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return p("plugin:window|set_size",{label:this.label,value:e instanceof k?e:new k(e)})}async setMinSize(e){return p("plugin:window|set_min_size",{label:this.label,value:e instanceof k?e:e?new k(e):null})}async setMaxSize(e){return p("plugin:window|set_max_size",{label:this.label,value:e instanceof k?e:e?new k(e):null})}async setSizeConstraints(e){function n(e){return e?{Logical:e}:null}return p("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 p("plugin:window|set_position",{label:this.label,value:e instanceof I?e:new I(e)})}async setFullscreen(e){return p("plugin:window|set_fullscreen",{label:this.label,value:e})}async setSimpleFullscreen(e){return p("plugin:window|set_simple_fullscreen",{label:this.label,value:e})}async setFocus(){return p("plugin:window|set_focus",{label:this.label})}async setFocusable(e){return p("plugin:window|set_focusable",{label:this.label,value:e})}async setIcon(e){return p("plugin:window|set_icon",{label:this.label,value:y(e)})}async setSkipTaskbar(e){return p("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return p("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return p("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return p("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return p("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return p("plugin:window|set_cursor_position",{label:this.label,value:e instanceof I?e:new I(e)})}async setIgnoreCursorEvents(e){return p("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return p("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return p("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return p("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return p("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return p("plugin:window|set_overlay_icon",{label:this.label,value:e?y(e):void 0})}async setProgressBar(e){return p("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return p("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return p("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return p("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(E.WINDOW_RESIZED,n=>{n.payload=new v(n.payload),e(n)})}async onMoved(e){return this.listen(E.WINDOW_MOVED,n=>{n.payload=new T(n.payload),e(n)})}async onCloseRequested(e){return this.listen(E.WINDOW_CLOSE_REQUESTED,async n=>{const t=new te(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 T(n.payload.position)}})}),t=await this.listen(E.DRAG_OVER,n=>{e({...n,payload:{type:"over",position:new T(n.payload.position)}})}),i=await this.listen(E.DRAG_DROP,n=>{e({...n,payload:{type:"drop",paths:n.payload.paths,position:new T(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 le,oe,ue,ce;function de(e){return null===e?null:{name:e.name,scaleFactor:e.scaleFactor,position:new T(e.position),size:new v(e.size),workArea:{position:new T(e.workArea.position),size:new v(e.workArea.size)}}}!function(e){e.Disabled="disabled",e.Throttle="throttle",e.Suspend="suspend"}(le||(le={})),function(e){e.Default="default",e.FluentOverlay="fluentOverlay"}(oe||(oe={})),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"}(ue||(ue={})),function(e){e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive"}(ce||(ce={}));var pe=Object.freeze({__proto__:null,CloseRequestedEvent:te,get Effect(){return ue},get EffectState(){return ce},LogicalPosition:A,LogicalSize:f,PhysicalPosition:T,PhysicalSize:v,get ProgressBarStatus(){return ee},get UserAttentionType(){return X},Window:ae,availableMonitors:async function(){return p("plugin:window|available_monitors").then(e=>e.map(de))},currentMonitor:async function(){return p("plugin:window|current_monitor").then(de)},cursorPosition:async function(){return p("plugin:window|cursor_position").then(e=>new T(e))},getAllWindows:re,getCurrentWindow:ie,monitorFromPoint:async function(e,n){return p("plugin:window|monitor_from_point",{x:e,y:n}).then(de)},primaryMonitor:async function(){return p("plugin:window|primary_monitor").then(de)}});function he(){return new ye(ie(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function we(){return p("plugin:webview|get_all_webviews").then(e=>e.map(e=>new ye(new ae(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}const _e=["tauri://created","tauri://error"];class ye{constructor(e,n,t){this.window=e,this.label=n,this.listeners=Object.create(null),(null==t?void 0:t.skip)||("string"==typeof(null==t?void 0:t.onNewWindow)&&(t.onNewWindow={action:t.onNewWindow}),p("plugin:webview|create_webview",{windowLabel:e.label,options:{...t,label:n}}).then(async()=>this.emit("tauri://created")).catch(async e=>this.emit("tauri://error",e)))}static async getByLabel(e){var n;return null!==(n=(await we()).find(n=>n.label===e))&&void 0!==n?n:null}static getCurrent(){return he()}static async getAll(){return we()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:N(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)}:S(e,n,{target:{kind:"Webview",label:this.label}})}async emit(e,n){if(!_e.includes(e))return L(e,n);for(const t of this.listeners[e]||[])t({event:e,id:-1,payload:n})}async emitTo(e,n,t){if(!_e.includes(n))return C(e,n,t);for(const e of this.listeners[n]||[])e({event:n,id:-1,payload:t})}_handleTauriEvent(e,n){return!!_e.includes(e)&&(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0)}async position(){return p("plugin:webview|webview_position",{label:this.label}).then(e=>new T(e))}async size(){return p("plugin:webview|webview_size",{label:this.label}).then(e=>new v(e))}async close(){return p("plugin:webview|webview_close",{label:this.label})}async setSize(e){return p("plugin:webview|set_webview_size",{label:this.label,value:e instanceof k?e:new k(e)})}async setPosition(e){return p("plugin:webview|set_webview_position",{label:this.label,value:e instanceof I?e:new I(e)})}async setFocus(){return p("plugin:webview|set_webview_focus",{label:this.label})}async setAutoResize(e){return p("plugin:webview|set_webview_auto_resize",{label:this.label,value:e})}async hide(){return p("plugin:webview|webview_hide",{label:this.label})}async show(){return p("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return p("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return p("plugin:webview|reparent",{label:this.label,window:"string"==typeof e?e:e.label})}async clearAllBrowsingData(){return p("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return p("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 T(n.payload.position)}})}),t=await this.listen(E.DRAG_OVER,n=>{e({...n,payload:{type:"over",position:new T(n.payload.position)}})}),i=await this.listen(E.DRAG_DROP,n=>{e({...n,payload:{type:"drop",paths:n.payload.paths,position:new T(n.payload.position)}})}),r=await this.listen(E.DRAG_LEAVE,n=>{e({...n,payload:{type:"leave"}})});return()=>{n(),i(),t(),r()}}}var ge,be,me=Object.freeze({__proto__:null,Webview:ye,getAllWebviews:we,getCurrentWebview:he});function fe(){const e=he();return new ke(e.label,{skip:!0})}async function ve(){return p("plugin:window|get_all_windows").then(e=>e.map(e=>new ke(e,{skip:!0})))}class ke{constructor(e,n={}){var t;this.label=e,this.listeners=Object.create(null),(null==n?void 0:n.skip)||("string"==typeof(null==n?void 0:n.onNewWindow)&&(n.onNewWindow={action:n.onNewWindow}),p("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 ve()).find(n=>n.label===e))&&void 0!==n?n:null;return t?new ke(t.label,{skip:!0}):null}static getCurrent(){return fe()}static async getAll(){return ve()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:N(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)}:S(e,n,{target:{kind:"WebviewWindow",label:this.label}})}async setBackgroundColor(e){return p("plugin:window|set_background_color",{color:e}).then(()=>p("plugin:webview|set_webview_background_color",{color:e}))}}ge=ke,be=[ae,ye],(Array.isArray(be)?be:[be]).forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(n=>{var t;"object"==typeof ge.prototype&&ge.prototype&&n in ge.prototype||Object.defineProperty(ge.prototype,n,null!==(t=Object.getOwnPropertyDescriptor(e.prototype,n))&&void 0!==t?t:Object.create(null))})});var Ae=Object.freeze({__proto__:null,WebviewWindow:ke,getAllWebviewWindows:ve,getCurrentWebviewWindow:fe});return e.app=m,e.core=w,e.dpi=R,e.event=z,e.image=b,e.menu=$,e.mocks=Z,e.path=K,e.tray=ne,e.webview=me,e.webviewWindow=Ae,e.window=pe,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,l;"function"==typeof SuppressedError&&SuppressedError;const o="__TAURI_TO_IPC_KEY__";function u(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}class c{constructor(e){i.set(this,void 0),r.set(this,0),s.set(this,[]),a.set(this,void 0),t(this,i,e||(()=>{}),"f"),this.id=u(e=>{const l=e.index;if("end"in e)return void(l==n(this,r,"f")?this.cleanupCallback():t(this,a,l,"f"));const o=e.message;if(l==n(this,r,"f")){for(n(this,i,"f").call(this,o),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")}n(this,r,"f")===n(this,a,"f")&&this.cleanupCallback()}else n(this,s,"f")[l]=o})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){t(this,i,e,"f")}get onmessage(){return n(this,i,"f")}[(i=new WeakMap,r=new WeakMap,s=new WeakMap,a=new WeakMap,o)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[o]()}}class d{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return p(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function p(e,n={},t){return window.__TAURI_INTERNALS__.invoke(e,n,t)}class h{get rid(){return n(this,l,"f")}constructor(e){l.set(this,void 0),t(this,l,e,"f")}async close(){return p("plugin:resources|close",{rid:this.rid})}}l=new WeakMap;var w=Object.freeze({__proto__:null,Channel:c,PluginListener:d,Resource:h,SERIALIZE_TO_IPC_FN:o,addPluginListener:async function(e,n,t){const i=new c(t);try{return p(`plugin:${e}|register_listener`,{event:n,handler:i}).then(()=>new d(e,n,i.id))}catch{return p(`plugin:${e}|registerListener`,{event:n,handler:i}).then(()=>new d(e,n,i.id))}},checkPermissions:async function(e){return p(`plugin:${e}|check_permissions`)},convertFileSrc:function(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)},invoke:p,isTauri:function(){return!!(globalThis||window).isTauri},requestPermissions:async function(e){return p(`plugin:${e}|request_permissions`)},transformCallback:u});class _ extends h{constructor(e){super(e)}static async new(e,n,t){return p("plugin:image|new",{rgba:y(e),width:n,height:t}).then(e=>new _(e))}static async fromBytes(e){return p("plugin:image|from_bytes",{bytes:y(e)}).then(e=>new _(e))}static async fromPath(e){return p("plugin:image|from_path",{path:e}).then(e=>new _(e))}async rgba(){return p("plugin:image|rgba",{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return p("plugin:image|size",{rid:this.rid})}}function y(e){return null==e?null:"string"==typeof e?e:e instanceof _?e.rid:e}var g,b=Object.freeze({__proto__:null,Image:_,transformImage:y});!function(e){e.Nsis="nsis",e.Msi="msi",e.Deb="deb",e.Rpm="rpm",e.AppImage="appimage",e.App="app"}(g||(g={}));var m=Object.freeze({__proto__:null,get BundleType(){return g},defaultWindowIcon:async function(){return p("plugin:app|default_window_icon").then(e=>e?new _(e):null)},fetchDataStoreIdentifiers:async function(){return p("plugin:app|fetch_data_store_identifiers")},getBundleType:async function(){return p("plugin:app|bundle_type")},getIdentifier:async function(){return p("plugin:app|identifier")},getName:async function(){return p("plugin:app|name")},getTauriVersion:async function(){return p("plugin:app|tauri_version")},getVersion:async function(){return p("plugin:app|version")},hide:async function(){return p("plugin:app|app_hide")},removeDataStore:async function(e){return p("plugin:app|remove_data_store",{uuid:e})},setDockVisibility:async function(e){return p("plugin:app|set_dock_visibility",{visible:e})},setTheme:async function(e){return p("plugin:app|set_app_theme",{theme:e})},show:async function(){return p("plugin:app|app_show")}});class f{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 v(this.width*e,this.height*e)}[o](){return{width:this.width,height:this.height}}toJSON(){return this[o]()}}class v{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 f(this.width/e,this.height/e)}[o](){return{width:this.width,height:this.height}}toJSON(){return this[o]()}}class k{constructor(e){this.size=e}toLogical(e){return this.size instanceof f?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof v?this.size:this.size.toPhysical(e)}[o](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[o]()}}class A{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 T(this.x*e,this.y*e)}[o](){return{x:this.x,y:this.y}}toJSON(){return this[o]()}}class T{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 A(this.x/e,this.y/e)}[o](){return{x:this.x,y:this.y}}toJSON(){return this[o]()}}class I{constructor(e){this.position=e}toLogical(e){return this.position instanceof A?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof T?this.position:this.position.toPhysical(e)}[o](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[o]()}}var E,R=Object.freeze({__proto__:null,LogicalPosition:A,LogicalSize:f,PhysicalPosition:T,PhysicalSize:v,Position:I,Size:k});async function D(e,n){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(e,n),await p("plugin:event|unlisten",{event:e,eventId:n})}async function N(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 p("plugin:event|listen",{event:e,target:r,handler:u(n)}).then(n=>async()=>D(e,n))}async function S(e,n,t){return N(e,t=>{D(e,t.id),n(t)},t)}async function L(e,n){await p("plugin:event|emit",{event:e,payload:n})}async function C(e,n,t){const i="string"==typeof e?{kind:"AnyLabel",label:e}:e;await p("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,W,P,z=Object.freeze({__proto__:null,get TauriEvent(){return E},emit:L,emitTo:C,listen:N,once:S});function O(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:O(e));else if("action"in e&&e.action){const n=new c;return n.onmessage=e.action,delete e.action,{...e,handler:n}}return e}async function U(e,n){const t=new c;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)),O(e))}n.items=n.items.map(i)}return p("plugin:menu|new",{kind:e,options:n,handler:t})}class F extends h{get id(){return n(this,x,"f")}get kind(){return n(this,W,"f")}constructor(e,n,i){super(e),x.set(this,void 0),W.set(this,void 0),t(this,x,n,"f"),t(this,W,i,"f")}}x=new WeakMap,W=new WeakMap;class M extends F{constructor(e,n){super(e,n,"MenuItem")}static async new(e){return U("MenuItem",e).then(([e,n])=>new M(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return p("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return p("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return p("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}}class B extends F{constructor(e,n){super(e,n,"Check")}static async new(e){return U("Check",e).then(([e,n])=>new B(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return p("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return p("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return p("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async isChecked(){return p("plugin:menu|is_checked",{rid:this.rid})}async setChecked(e){return p("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"}(P||(P={}));class V extends F{constructor(e,n){super(e,n,"Icon")}static async new(e){return U("Icon",e).then(([e,n])=>new V(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return p("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return p("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return p("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async setIcon(e){return p("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:y(e)})}}class G extends F{constructor(e,n){super(e,n,"Predefined")}static async new(e){return U("Predefined",e).then(([e,n])=>new G(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}}function j([e,n,t]){switch(t){case"Submenu":return new H(e,n);case"Predefined":return new G(e,n);case"Check":return new B(e,n);case"Icon":return new V(e,n);default:return new M(e,n)}}class H extends F{constructor(e,n){super(e,n,"Submenu")}static async new(e){return U("Submenu",e).then(([e,n])=>new H(e,n))}async text(){return p("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return p("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return p("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return p("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async append(e){return p("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 p("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 p("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 p("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return p("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(j)}async items(){return p("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(e=>e.map(j))}async get(e){return p("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then(e=>e?j(e):null)}async popup(e,n){var t;return p("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 I?e:e?new I(e):null})}async setAsWindowsMenuForNSApp(){return p("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return p("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}async setIcon(e){return p("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:y(e)})}}class $ extends F{constructor(e,n){super(e,n,"Menu")}static async new(e){return U("Menu",e).then(([e,n])=>new $(e,n))}static async default(){return p("plugin:menu|create_default").then(([e,n])=>new $(e,n))}async append(e){return p("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 p("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 p("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 p("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return p("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(j)}async items(){return p("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(e=>e.map(j))}async get(e){return p("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then(e=>e?j(e):null)}async popup(e,n){var t;return p("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 I?e:e?new I(e):null})}async setAsAppMenu(){return p("plugin:menu|set_as_app_menu",{rid:this.rid}).then(e=>e?new $(e[0],e[1]):null)}async setAsWindowMenu(e){var n;return p("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 $(e[0],e[1]):null)}}var q=Object.freeze({__proto__:null,CheckMenuItem:B,IconMenuItem:V,Menu:$,MenuItem:M,get NativeIcon(){return P},PredefinedMenuItem:G,Submenu:H,itemFromKind:j});function J(){var e,n;window.__TAURI_INTERNALS__=null!==(e=window.__TAURI_INTERNALS__)&&void 0!==e?e:{},window.__TAURI_EVENT_PLUGIN_INTERNALS__=null!==(n=window.__TAURI_EVENT_PLUGIN_INTERNALS__)&&void 0!==n?n:{}}var Q,Z=Object.freeze({__proto__:null,clearMocks:function(){"object"==typeof window.__TAURI_INTERNALS__&&(delete window.__TAURI_INTERNALS__.invoke,delete window.__TAURI_INTERNALS__.transformCallback,delete window.__TAURI_INTERNALS__.unregisterCallback,delete window.__TAURI_INTERNALS__.runCallback,delete window.__TAURI_INTERNALS__.callbacks,delete window.__TAURI_INTERNALS__.convertFileSrc,delete window.__TAURI_INTERNALS__.metadata,"object"==typeof window.__TAURI_EVENT_PLUGIN_INTERNALS__&&delete window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener)},mockConvertFileSrc:function(e){J(),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,n){function t(e,n){switch(e){case"plugin:event|listen":return function(e){i.has(e.event)||i.set(e.event,[]);return i.get(e.event).push(e.handler),e.handler}(n);case"plugin:event|emit":return function(e){const n=i.get(e.event)||[];for(const t of n)a(t,e);return null}(n);case"plugin:event|unlisten":return function(e){const n=i.get(e.event);if(n){const t=n.indexOf(e.id);-1!==t&&n.splice(t,1)}}(n)}}J();const i=new Map,r=new Map;function s(e){r.delete(e)}function a(e,n){const t=r.get(e);t?t(n):console.warn(`[TAURI] Couldn't find callback id ${e}. This might happen when the app is reloaded while Rust is running an asynchronous operation.`)}window.__TAURI_INTERNALS__.invoke=async function(i,r,s){return(null==n?void 0:n.shouldMockEvents)&&function(e){return e.startsWith("plugin:event|")}(i)?t(i,r):e(i,r)},window.__TAURI_INTERNALS__.transformCallback=function(e,n=!1){const t=window.crypto.getRandomValues(new Uint32Array(1))[0];return r.set(t,i=>(n&&s(t),e&&e(i))),t},window.__TAURI_INTERNALS__.unregisterCallback=s,window.__TAURI_INTERNALS__.runCallback=a,window.__TAURI_INTERNALS__.callbacks=r,window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener=function(e,n){s(n)}},mockWindows:function(e,...n){J(),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 K=Object.freeze({__proto__:null,get BaseDirectory(){return Q},appCacheDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppCache})},appConfigDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppConfig})},appDataDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppData})},appLocalDataDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppLocalData})},appLogDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.AppLog})},audioDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Audio})},basename:async function(e,n){return p("plugin:path|basename",{path:e,ext:n})},cacheDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Cache})},configDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Config})},dataDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Data})},delimiter:function(){return window.__TAURI_INTERNALS__.plugins.path.delimiter},desktopDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Desktop})},dirname:async function(e){return p("plugin:path|dirname",{path:e})},documentDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Document})},downloadDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Download})},executableDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Executable})},extname:async function(e){return p("plugin:path|extname",{path:e})},fontDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Font})},homeDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Home})},isAbsolute:async function(e){return p("plugin:path|is_absolute",{path:e})},join:async function(...e){return p("plugin:path|join",{paths:e})},localDataDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.LocalData})},normalize:async function(e){return p("plugin:path|normalize",{path:e})},pictureDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Picture})},publicDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Public})},resolve:async function(...e){return p("plugin:path|resolve",{paths:e})},resolveResource:async function(e){return p("plugin:path|resolve_directory",{directory:Q.Resource,path:e})},resourceDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Resource})},runtimeDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Runtime})},sep:function(){return window.__TAURI_INTERNALS__.plugins.path.sep},tempDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Temp})},templateDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Template})},videoDir:async function(){return p("plugin:path|resolve_directory",{directory:Q.Video})}});class Y extends h{constructor(e,n){super(e),this.id=n}static async getById(e){return p("plugin:tray|get_by_id",{id:e}).then(n=>n?new Y(n,e):null)}static async removeById(e){return p("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 c;if(null==e?void 0:e.action){const t=e.action;n.onmessage=e=>t(function(e){const n=e;return n.position=new T(e.position),n.rect.position=new T(e.rect.position),n.rect.size=new v(e.rect.size),n}(e)),delete e.action}return p("plugin:tray|new",{options:null!=e?e:{},handler:n}).then(([e,n])=>new Y(e,n))}async setIcon(e){let n=null;return e&&(n=y(e)),p("plugin:tray|set_icon",{rid:this.rid,icon:n})}async setMenu(e){return e&&(e=[e.rid,e.kind]),p("plugin:tray|set_menu",{rid:this.rid,menu:e})}async setTooltip(e){return p("plugin:tray|set_tooltip",{rid:this.rid,tooltip:e})}async setTitle(e){return p("plugin:tray|set_title",{rid:this.rid,title:e})}async setVisible(e){return p("plugin:tray|set_visible",{rid:this.rid,visible:e})}async setTempDirPath(e){return p("plugin:tray|set_temp_dir_path",{rid:this.rid,path:e})}async setIconAsTemplate(e){return p("plugin:tray|set_icon_as_template",{rid:this.rid,asTemplate:e})}async setMenuOnLeftClick(e){return p("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}async setShowMenuOnLeftClick(e){return p("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}}var X,ee,ne=Object.freeze({__proto__:null,TrayIcon:Y});!function(e){e[e.Critical=1]="Critical",e[e.Informational=2]="Informational"}(X||(X={}));class te{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}function ie(){return new ae(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function re(){return p("plugin:window|get_all_windows").then(e=>e.map(e=>new ae(e,{skip:!0})))}!function(e){e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error"}(ee||(ee={}));const se=["tauri://created","tauri://error"];class ae{constructor(e,n={}){var t;this.label=e,this.listeners=Object.create(null),(null==n?void 0:n.skip)||p("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 re()).find(n=>n.label===e))&&void 0!==n?n:null}static getCurrent(){return ie()}static async getAll(){return re()}static async getFocusedWindow(){for(const e of await re())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)}:N(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)}:S(e,n,{target:{kind:"Window",label:this.label}})}async emit(e,n){if(!se.includes(e))return L(e,n);for(const t of this.listeners[e]||[])t({event:e,id:-1,payload:n})}async emitTo(e,n,t){if(!se.includes(n))return C(e,n,t);for(const e of this.listeners[n]||[])e({event:n,id:-1,payload:t})}_handleTauriEvent(e,n){return!!se.includes(e)&&(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0)}async scaleFactor(){return p("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return p("plugin:window|inner_position",{label:this.label}).then(e=>new T(e))}async outerPosition(){return p("plugin:window|outer_position",{label:this.label}).then(e=>new T(e))}async innerSize(){return p("plugin:window|inner_size",{label:this.label}).then(e=>new v(e))}async outerSize(){return p("plugin:window|outer_size",{label:this.label}).then(e=>new v(e))}async isFullscreen(){return p("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return p("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return p("plugin:window|is_maximized",{label:this.label})}async isFocused(){return p("plugin:window|is_focused",{label:this.label})}async isDecorated(){return p("plugin:window|is_decorated",{label:this.label})}async isResizable(){return p("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return p("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return p("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return p("plugin:window|is_closable",{label:this.label})}async isVisible(){return p("plugin:window|is_visible",{label:this.label})}async title(){return p("plugin:window|title",{label:this.label})}async theme(){return p("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return p("plugin:window|is_always_on_top",{label:this.label})}async center(){return p("plugin:window|center",{label:this.label})}async requestUserAttention(e){let n=null;return e&&(n=e===X.Critical?{type:"Critical"}:{type:"Informational"}),p("plugin:window|request_user_attention",{label:this.label,value:n})}async setResizable(e){return p("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return p("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return p("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return p("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return p("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return p("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return p("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return p("plugin:window|maximize",{label:this.label})}async unmaximize(){return p("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return p("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return p("plugin:window|minimize",{label:this.label})}async unminimize(){return p("plugin:window|unminimize",{label:this.label})}async show(){return p("plugin:window|show",{label:this.label})}async hide(){return p("plugin:window|hide",{label:this.label})}async close(){return p("plugin:window|close",{label:this.label})}async destroy(){return p("plugin:window|destroy",{label:this.label})}async setDecorations(e){return p("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return p("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return p("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return p("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return p("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return p("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return p("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return p("plugin:window|set_size",{label:this.label,value:e instanceof k?e:new k(e)})}async setMinSize(e){return p("plugin:window|set_min_size",{label:this.label,value:e instanceof k?e:e?new k(e):null})}async setMaxSize(e){return p("plugin:window|set_max_size",{label:this.label,value:e instanceof k?e:e?new k(e):null})}async setSizeConstraints(e){function n(e){return e?{Logical:e}:null}return p("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 p("plugin:window|set_position",{label:this.label,value:e instanceof I?e:new I(e)})}async setFullscreen(e){return p("plugin:window|set_fullscreen",{label:this.label,value:e})}async setSimpleFullscreen(e){return p("plugin:window|set_simple_fullscreen",{label:this.label,value:e})}async setFocus(){return p("plugin:window|set_focus",{label:this.label})}async setFocusable(e){return p("plugin:window|set_focusable",{label:this.label,value:e})}async setIcon(e){return p("plugin:window|set_icon",{label:this.label,value:y(e)})}async setSkipTaskbar(e){return p("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return p("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return p("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return p("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return p("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return p("plugin:window|set_cursor_position",{label:this.label,value:e instanceof I?e:new I(e)})}async setIgnoreCursorEvents(e){return p("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return p("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return p("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return p("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return p("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return p("plugin:window|set_overlay_icon",{label:this.label,value:e?y(e):void 0})}async setProgressBar(e){return p("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return p("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return p("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return p("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(E.WINDOW_RESIZED,n=>{n.payload=new v(n.payload),e(n)})}async onMoved(e){return this.listen(E.WINDOW_MOVED,n=>{n.payload=new T(n.payload),e(n)})}async onCloseRequested(e){return this.listen(E.WINDOW_CLOSE_REQUESTED,async n=>{const t=new te(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 T(n.payload.position)}})}),t=await this.listen(E.DRAG_OVER,n=>{e({...n,payload:{type:"over",position:new T(n.payload.position)}})}),i=await this.listen(E.DRAG_DROP,n=>{e({...n,payload:{type:"drop",paths:n.payload.paths,position:new T(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 le,oe,ue,ce;function de(e){return null===e?null:{name:e.name,scaleFactor:e.scaleFactor,position:new T(e.position),size:new v(e.size),workArea:{position:new T(e.workArea.position),size:new v(e.workArea.size)}}}!function(e){e.Disabled="disabled",e.Throttle="throttle",e.Suspend="suspend"}(le||(le={})),function(e){e.Default="default",e.FluentOverlay="fluentOverlay"}(oe||(oe={})),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"}(ue||(ue={})),function(e){e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive"}(ce||(ce={}));var pe=Object.freeze({__proto__:null,CloseRequestedEvent:te,get Effect(){return ue},get EffectState(){return ce},LogicalPosition:A,LogicalSize:f,PhysicalPosition:T,PhysicalSize:v,get ProgressBarStatus(){return ee},get UserAttentionType(){return X},Window:ae,availableMonitors:async function(){return p("plugin:window|available_monitors").then(e=>e.map(de))},currentMonitor:async function(){return p("plugin:window|current_monitor").then(de)},cursorPosition:async function(){return p("plugin:window|cursor_position").then(e=>new T(e))},getAllWindows:re,getCurrentWindow:ie,monitorFromPoint:async function(e,n){return p("plugin:window|monitor_from_point",{x:e,y:n}).then(de)},primaryMonitor:async function(){return p("plugin:window|primary_monitor").then(de)}});function he(){return new ye(ie(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function we(){return p("plugin:webview|get_all_webviews").then(e=>e.map(e=>new ye(new ae(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}const _e=["tauri://created","tauri://error"];class ye{constructor(e,n,t){this.window=e,this.label=n,this.listeners=Object.create(null),(null==t?void 0:t.skip)||("string"==typeof(null==t?void 0:t.onNewWindow)&&(t.onNewWindow={action:t.onNewWindow}),p("plugin:webview|create_webview",{windowLabel:e.label,options:{...t,label:n}}).then(async()=>this.emit("tauri://created")).catch(async e=>this.emit("tauri://error",e)))}static async getByLabel(e){var n;return null!==(n=(await we()).find(n=>n.label===e))&&void 0!==n?n:null}static getCurrent(){return he()}static async getAll(){return we()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:N(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)}:S(e,n,{target:{kind:"Webview",label:this.label}})}async emit(e,n){if(!_e.includes(e))return L(e,n);for(const t of this.listeners[e]||[])t({event:e,id:-1,payload:n})}async emitTo(e,n,t){if(!_e.includes(n))return C(e,n,t);for(const e of this.listeners[n]||[])e({event:n,id:-1,payload:t})}_handleTauriEvent(e,n){return!!_e.includes(e)&&(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0)}async position(){return p("plugin:webview|webview_position",{label:this.label}).then(e=>new T(e))}async size(){return p("plugin:webview|webview_size",{label:this.label}).then(e=>new v(e))}async close(){return p("plugin:webview|webview_close",{label:this.label})}async setSize(e){return p("plugin:webview|set_webview_size",{label:this.label,value:e instanceof k?e:new k(e)})}async setPosition(e){return p("plugin:webview|set_webview_position",{label:this.label,value:e instanceof I?e:new I(e)})}async setFocus(){return p("plugin:webview|set_webview_focus",{label:this.label})}async setAutoResize(e){return p("plugin:webview|set_webview_auto_resize",{label:this.label,value:e})}async hide(){return p("plugin:webview|webview_hide",{label:this.label})}async show(){return p("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return p("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return p("plugin:webview|reparent",{label:this.label,window:"string"==typeof e?e:e.label})}async clearAllBrowsingData(){return p("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return p("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 T(n.payload.position)}})}),t=await this.listen(E.DRAG_OVER,n=>{e({...n,payload:{type:"over",position:new T(n.payload.position)}})}),i=await this.listen(E.DRAG_DROP,n=>{e({...n,payload:{type:"drop",paths:n.payload.paths,position:new T(n.payload.position)}})}),r=await this.listen(E.DRAG_LEAVE,n=>{e({...n,payload:{type:"leave"}})});return()=>{n(),i(),t(),r()}}}var ge,be,me=Object.freeze({__proto__:null,Webview:ye,getAllWebviews:we,getCurrentWebview:he});function fe(){const e=he();return new ke(e.label,{skip:!0})}async function ve(){return p("plugin:window|get_all_windows").then(e=>e.map(e=>new ke(e,{skip:!0})))}class ke{constructor(e,n={}){var t;this.label=e,this.listeners=Object.create(null),(null==n?void 0:n.skip)||("string"==typeof(null==n?void 0:n.onNewWindow)&&(n.onNewWindow={action:n.onNewWindow}),p("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 ve()).find(n=>n.label===e))&&void 0!==n?n:null;return t?new ke(t.label,{skip:!0}):null}static getCurrent(){return fe()}static async getAll(){return ve()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{const t=this.listeners[e];t.splice(t.indexOf(n),1)}:N(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)}:S(e,n,{target:{kind:"WebviewWindow",label:this.label}})}async setBackgroundColor(e){return p("plugin:window|set_background_color",{color:e}).then(()=>p("plugin:webview|set_webview_background_color",{color:e}))}}ge=ke,be=[ae,ye],(Array.isArray(be)?be:[be]).forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(n=>{var t;"object"==typeof ge.prototype&&ge.prototype&&n in ge.prototype||Object.defineProperty(ge.prototype,n,null!==(t=Object.getOwnPropertyDescriptor(e.prototype,n))&&void 0!==t?t:Object.create(null))})});var Ae=Object.freeze({__proto__:null,WebviewWindow:ke,getAllWebviewWindows:ve,getCurrentWebviewWindow:fe});return e.app=m,e.core=w,e.dpi=R,e.event=z,e.image=b,e.menu=q,e.mocks=Z,e.path=K,e.tray=ne,e.webview=me,e.webviewWindow=Ae,e.window=pe,e}({});window.__TAURI__=__TAURI_IIFE__; diff --git a/crates/tauri/src/webview/mod.rs b/crates/tauri/src/webview/mod.rs index 948298bd90a1..b81952770c05 100644 --- a/crates/tauri/src/webview/mod.rs +++ b/crates/tauri/src/webview/mod.rs @@ -753,6 +753,11 @@ tauri::Builder::default() tauri_runtime::webview::NewWindowResponse::Deny } } + #[cfg(mobile)] + OnNewWindow::AllowTauriWindow { urls: _ } => { + tauri_runtime::webview::NewWindowResponse::Deny + } + #[cfg(desktop)] OnNewWindow::AllowTauriWindow { urls: Some(urls) } => { if urls.iter().any(|pattern| pattern.test(&url)) { let number = @@ -780,6 +785,7 @@ tauri::Builder::default() OnNewWindow::AllowDefault { urls: None } => { tauri_runtime::webview::NewWindowResponse::Allow } + #[cfg(desktop)] OnNewWindow::AllowTauriWindow { urls: None } => { tauri_runtime::webview::NewWindowResponse::Allow } From 710256b20c7ded14bfb3908176258a8eef4f6c9c Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Tue, 14 Oct 2025 07:32:57 -0300 Subject: [PATCH 3/5] code review suggestions --- crates/tauri/src/webview/mod.rs | 11 ++++++++--- packages/api/src/webview.ts | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/tauri/src/webview/mod.rs b/crates/tauri/src/webview/mod.rs index b81952770c05..40824b557e19 100644 --- a/crates/tauri/src/webview/mod.rs +++ b/crates/tauri/src/webview/mod.rs @@ -774,9 +774,14 @@ tauri::Builder::default() }) .title(url.as_str()); - let window = builder.build().unwrap(); - tauri_runtime::webview::NewWindowResponse::Create { - window_id: window.window.window.id, + match builder.build() { + Ok(window) => tauri_runtime::webview::NewWindowResponse::Create { + window_id: window.window.window.id, + }, + Err(e) => { + log::error!("failed to create window: {:?}", e); + tauri_runtime::webview::NewWindowResponse::Deny + } } } else { tauri_runtime::webview::NewWindowResponse::Deny diff --git a/packages/api/src/webview.ts b/packages/api/src/webview.ts index d66246b8ce59..d770213cc3fe 100644 --- a/packages/api/src/webview.ts +++ b/packages/api/src/webview.ts @@ -915,10 +915,10 @@ interface WebviewOptions { * - **Android / iOS**: Not supported. * * */ - onNewWindow?: onNewWindow + onNewWindow?: OnNewWindow } -type onNewWindow = +type OnNewWindow = | 'allowDefault' | 'allowTauriWindow' | 'deny' @@ -928,4 +928,4 @@ type onNewWindow = export { Webview, getCurrentWebview, getAllWebviews } -export type { DragDropEvent, WebviewOptions, Color, onNewWindow } +export type { DragDropEvent, WebviewOptions, Color, OnNewWindow } From e32108a4534029f76ddf893d99ae1e787700b156 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Tue, 14 Oct 2025 08:08:24 -0300 Subject: [PATCH 4/5] use glob patterns by default --- crates/tauri-cli/config.schema.json | 23 ++++-- .../schemas/config.schema.json | 23 ++++-- crates/tauri-utils/Cargo.toml | 1 + crates/tauri-utils/src/config.rs | 18 +++-- crates/tauri-utils/src/tokens.rs | 25 ++++++- crates/tauri-utils/src/url.rs | 73 ++++++++++++++++++- crates/tauri/Cargo.toml | 1 + crates/tauri/src/lib.rs | 1 + packages/api/src/webview.ts | 4 +- 9 files changed, 150 insertions(+), 19 deletions(-) diff --git a/crates/tauri-cli/config.schema.json b/crates/tauri-cli/config.schema.json index 9beb2d069953..fed84a1627ec 100644 --- a/crates/tauri-cli/config.schema.json +++ b/crates/tauri-cli/config.schema.json @@ -1168,13 +1168,13 @@ ] }, "urls": { - "description": "Only allow URLs matching the given pattern list when set.", + "description": "Only allow URLs matching the given pattern list when set.\n\n By default it is a glob pattern, but can use the full [URLPattern] spec if the `url-pattern` feature is enabled.\n\n [URLPattern]: https://developer.mozilla.org/en-US/docs/Web/API/URLPattern", "type": [ "array", "null" ], "items": { - "$ref": "#/definitions/UrlPattern" + "$ref": "#/definitions/UrlScope" } } }, @@ -1194,13 +1194,13 @@ ] }, "urls": { - "description": "Only allow URLs matching the given pattern list when set.", + "description": "Only allow URLs matching the given pattern list when set.\n\n By default it is a glob pattern, but can use the full [URLPattern] spec if the `url-pattern` feature is enabled.\n\n [URLPattern]: https://developer.mozilla.org/en-US/docs/Web/API/URLPattern", "type": [ "array", "null" ], "items": { - "$ref": "#/definitions/UrlPattern" + "$ref": "#/definitions/UrlScope" } } }, @@ -1224,7 +1224,20 @@ } ] }, - "UrlPattern": { + "UrlScope": { + "description": "A scope to match URLs.", + "anyOf": [ + { + "description": "A [`GlobPattern`] to match URLs.", + "allOf": [ + { + "$ref": "#/definitions/GlobPattern" + } + ] + } + ] + }, + "GlobPattern": { "type": "string" }, "SecurityConfig": { diff --git a/crates/tauri-schema-generator/schemas/config.schema.json b/crates/tauri-schema-generator/schemas/config.schema.json index 9beb2d069953..fed84a1627ec 100644 --- a/crates/tauri-schema-generator/schemas/config.schema.json +++ b/crates/tauri-schema-generator/schemas/config.schema.json @@ -1168,13 +1168,13 @@ ] }, "urls": { - "description": "Only allow URLs matching the given pattern list when set.", + "description": "Only allow URLs matching the given pattern list when set.\n\n By default it is a glob pattern, but can use the full [URLPattern] spec if the `url-pattern` feature is enabled.\n\n [URLPattern]: https://developer.mozilla.org/en-US/docs/Web/API/URLPattern", "type": [ "array", "null" ], "items": { - "$ref": "#/definitions/UrlPattern" + "$ref": "#/definitions/UrlScope" } } }, @@ -1194,13 +1194,13 @@ ] }, "urls": { - "description": "Only allow URLs matching the given pattern list when set.", + "description": "Only allow URLs matching the given pattern list when set.\n\n By default it is a glob pattern, but can use the full [URLPattern] spec if the `url-pattern` feature is enabled.\n\n [URLPattern]: https://developer.mozilla.org/en-US/docs/Web/API/URLPattern", "type": [ "array", "null" ], "items": { - "$ref": "#/definitions/UrlPattern" + "$ref": "#/definitions/UrlScope" } } }, @@ -1224,7 +1224,20 @@ } ] }, - "UrlPattern": { + "UrlScope": { + "description": "A scope to match URLs.", + "anyOf": [ + { + "description": "A [`GlobPattern`] to match URLs.", + "allOf": [ + { + "$ref": "#/definitions/GlobPattern" + } + ] + } + ] + }, + "GlobPattern": { "type": "string" }, "SecurityConfig": { diff --git a/crates/tauri-utils/Cargo.toml b/crates/tauri-utils/Cargo.toml index 939cb93ed2db..468b495061ca 100644 --- a/crates/tauri-utils/Cargo.toml +++ b/crates/tauri-utils/Cargo.toml @@ -75,3 +75,4 @@ config-json5 = ["json5"] config-toml = [] resources = ["walkdir"] html-manipulation = ["dep:html5ever", "dep:kuchiki"] +url-pattern = [] diff --git a/crates/tauri-utils/src/config.rs b/crates/tauri-utils/src/config.rs index b56c17a024a4..022ed8899f84 100644 --- a/crates/tauri-utils/src/config.rs +++ b/crates/tauri-utils/src/config.rs @@ -62,7 +62,7 @@ fn add_description(schema: Schema, description: impl Into) -> Schema { pub mod parse; use crate::{ - acl::capability::Capability, url::UrlPattern, TitleBarStyle, WindowEffect, WindowEffectState, + acl::capability::Capability, url::UrlScope, TitleBarStyle, WindowEffect, WindowEffectState, }; pub use self::parse::parse; @@ -1658,12 +1658,20 @@ pub enum OnNewWindow { /// Allow the window to be created using the default webview implementation. AllowDefault { /// Only allow URLs matching the given pattern list when set. - urls: Option>, + /// + /// By default it is a glob pattern, but can use the full [URLPattern] spec if the `url-pattern` feature is enabled. + /// + /// [URLPattern]: https://developer.mozilla.org/en-US/docs/Web/API/URLPattern + urls: Option>, }, /// Allow the window to be created using a Tauri window. AllowTauriWindow { /// Only allow URLs matching the given pattern list when set. - urls: Option>, + /// + /// By default it is a glob pattern, but can use the full [URLPattern] spec if the `url-pattern` feature is enabled. + /// + /// [URLPattern]: https://developer.mozilla.org/en-US/docs/Web/API/URLPattern + urls: Option>, }, /// Deny the window from being created. #[default] @@ -3557,11 +3565,11 @@ mod build { tokens.append_all(match self { Self::AllowDefault { urls } => { - let urls = opt_vec_lit(urls.as_ref(), url_pattern_lit); + let urls = opt_vec_lit(urls.as_ref(), url_scope_lit); quote! { #prefix::AllowDefault { urls: #urls } } } Self::AllowTauriWindow { urls } => { - let urls = opt_vec_lit(urls.as_ref(), url_pattern_lit); + let urls = opt_vec_lit(urls.as_ref(), url_scope_lit); quote! { #prefix::AllowTauriWindow { urls: #urls } } } Self::Deny => quote! { #prefix::Deny }, diff --git a/crates/tauri-utils/src/tokens.rs b/crates/tauri-utils/src/tokens.rs index b1fb41cca192..8b237b5dba58 100644 --- a/crates/tauri-utils/src/tokens.rs +++ b/crates/tauri-utils/src/tokens.rs @@ -11,7 +11,7 @@ use quote::{quote, ToTokens}; use serde_json::Value as JsonValue; use url::Url; -use crate::url::UrlPattern; +use crate::url::{GlobPattern, UrlPattern, UrlScope}; /// Write a `TokenStream` of the `$struct`'s fields to the `$tokens`. /// @@ -100,6 +100,29 @@ pub fn url_pattern_lit(url: &UrlPattern) -> TokenStream { quote! { #url.parse().unwrap() } } +/// Creates a [`GlobPattern`] constructor `TokenStream`. +pub fn glob_pattern_lit(pattern: &GlobPattern) -> TokenStream { + let pattern = pattern.0.as_str(); + quote! { #pattern.parse().unwrap() } +} + +/// Creates a [`UrlScope`] constructor `TokenStream`. +pub fn url_scope_lit(url: &UrlScope) -> TokenStream { + let prefix = quote! { ::tauri::utils::url::UrlScope }; + match url { + #[cfg(feature = "url-pattern")] + UrlScope::UrlPattern(url) => { + let url = url.as_str(); + quote! { #prefix::UrlPattern(#url.parse().unwrap()) } + } + #[cfg(not(feature = "url-pattern"))] + UrlScope::Glob(glob) => { + let pattern = glob.0.as_str(); + quote! { #prefix::Glob(#pattern.parse().unwrap()) } + } + } +} + /// Create a map constructor, mapping keys and values with other `TokenStream`s. /// /// This function is pretty generic because the types of keys AND values get transformed. diff --git a/crates/tauri-utils/src/url.rs b/crates/tauri-utils/src/url.rs index 8f4340ab1076..c8e38d142fb3 100644 --- a/crates/tauri-utils/src/url.rs +++ b/crates/tauri-utils/src/url.rs @@ -9,6 +9,77 @@ use std::{str::FromStr, sync::Arc}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use url::Url; +/// A scope to match URLs. +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +#[serde(untagged)] +pub enum UrlScope { + /// A [`UrlPattern`] to match URLs. + /// + /// This is only available if the `url-pattern` feature is enabled. + #[cfg(feature = "url-pattern")] + UrlPattern(UrlPattern), + /// A [`GlobPattern`] to match URLs. + #[cfg(not(feature = "url-pattern"))] + Glob(GlobPattern), +} + +impl UrlScope { + /// Test if a given URL is matched by the scope. + pub fn test(&self, url: &Url) -> bool { + match self { + #[cfg(feature = "url-pattern")] + Self::UrlPattern(pattern) => pattern.test(url), + #[cfg(not(feature = "url-pattern"))] + Self::Glob(pattern) => pattern.0.matches(url.as_str()), + } + } +} + +/// A [`glob::Pattern`] to match URLs. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct GlobPattern(pub(crate) glob::Pattern); + +#[cfg(feature = "schema")] +impl schemars::JsonSchema for GlobPattern { + fn schema_name() -> String { + "GlobPattern".to_string() + } + + fn json_schema(_gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { + String::json_schema(_gen) + } +} + +impl FromStr for GlobPattern { + type Err = glob::PatternError; + + fn from_str(s: &str) -> std::result::Result { + glob::Pattern::new(s).map(Self) + } +} + +impl Serialize for GlobPattern { + fn serialize(&self, serializer: S) -> std::result::Result + where + S: Serializer, + { + serializer.serialize_str(&self.0.as_str()) + } +} + +impl<'de> Deserialize<'de> for GlobPattern { + fn deserialize(deserializer: D) -> std::result::Result + where + D: Deserializer<'de>, + { + let s = String::deserialize(deserializer)?; + glob::Pattern::new(&s) + .map(Self) + .map_err(serde::de::Error::custom) + } +} + /// UrlPattern to match URLs. #[derive(Debug, Clone)] pub struct UrlPattern(Arc, String); @@ -73,7 +144,7 @@ impl UrlPattern { &self.1 } - /// Test if a given URL matches the pattern. + /// Test if a given URL is matched by the pattern. pub fn test(&self, url: &Url) -> bool { self .0 diff --git a/crates/tauri/Cargo.toml b/crates/tauri/Cargo.toml index 7d453f8e7406..fd7146ed4420 100644 --- a/crates/tauri/Cargo.toml +++ b/crates/tauri/Cargo.toml @@ -221,6 +221,7 @@ image-png = ["image/png"] macos-proxy = ["tauri-runtime-wry?/macos-proxy"] dynamic-acl = [] specta = ["dep:specta"] +url-pattern = ["tauri-utils/url-pattern"] [[example]] name = "commands" diff --git a/crates/tauri/src/lib.rs b/crates/tauri/src/lib.rs index 68a58edcc137..965fd72acd79 100644 --- a/crates/tauri/src/lib.rs +++ b/crates/tauri/src/lib.rs @@ -37,6 +37,7 @@ //! - **macos-proxy**: Adds support for [`WebviewBuilder::proxy_url`] on macOS. Requires macOS 14+. //! - **specta**: Add support for [`specta::specta`](https://docs.rs/specta/%5E2.0.0-rc.9/specta/attr.specta.html) with Tauri arguments such as [`State`](crate::State), [`Window`](crate::Window) and [`AppHandle`](crate::AppHandle) //! - **dynamic-acl** *(enabled by default)*: Enables you to add ACLs at runtime, notably it enables the [`Manager::add_capability`] function. +//! - **url-pattern**: Enables using the [URLPattern] spec for URL scopes on JavaScript APIs. //! //! ## Cargo allowlist features //! diff --git a/packages/api/src/webview.ts b/packages/api/src/webview.ts index d770213cc3fe..68ed230a69c7 100644 --- a/packages/api/src/webview.ts +++ b/packages/api/src/webview.ts @@ -906,14 +906,14 @@ interface WebviewOptions { * * 'allowDefault' lets the webview open the URL using the native implementation. * 'allowTauriWindow' creates a Tauri window to load the URL. - * Additionally you can provide a list of filters to only allow URLs matching certain {@link https://developer.mozilla.org/en-US/docs/Web/API/URLPattern|URL patterns}. + * Additionally you can provide a list of filters to only allow URLs matching certain glob patterns. + * It can leverage the {@link https://developer.mozilla.org/en-US/docs/Web/API/URLPattern|URL pattern spec} if the `url-pattern` Cargo feature is enabled. * * A new window is requested to be opened by the {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/open|window.open API}. * * ## Platform-specific * * - **Android / iOS**: Not supported. - * * */ onNewWindow?: OnNewWindow } From bfa2964114ffd607af43471c0d1d93bc1b24851c Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Tue, 14 Oct 2025 08:35:24 -0300 Subject: [PATCH 5/5] clippy --- crates/tauri-utils/src/url.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/tauri-utils/src/url.rs b/crates/tauri-utils/src/url.rs index c8e38d142fb3..1f26304f0ec4 100644 --- a/crates/tauri-utils/src/url.rs +++ b/crates/tauri-utils/src/url.rs @@ -64,7 +64,7 @@ impl Serialize for GlobPattern { where S: Serializer, { - serializer.serialize_str(&self.0.as_str()) + serializer.serialize_str(self.0.as_str()) } }