From b9198e400d5f989e5049f68b9a7a1175a67835e1 Mon Sep 17 00:00:00 2001 From: Jason Tsai Date: Wed, 15 May 2024 18:02:08 +0800 Subject: [PATCH 1/3] feat(macos): support change title bar style dynamically --- core/tauri-runtime-wry/src/lib.rs | 25 +++++++++++++++++++ core/tauri-runtime/src/lib.rs | 7 ++++++ core/tauri/build.rs | 1 + .../window/autogenerated/reference.md | 2 ++ core/tauri/scripts/bundle.global.js | 2 +- core/tauri/src/test/mock_runtime.rs | 4 +++ core/tauri/src/webview/webview_window.rs | 9 +++++++ core/tauri/src/window/mod.rs | 12 +++++++++ core/tauri/src/window/plugin.rs | 3 +++ tooling/api/src/window.ts | 16 ++++++++++++ 10 files changed, 80 insertions(+), 1 deletion(-) diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index ed2c7f1aaf2..727cc682b24 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -1148,6 +1148,7 @@ pub enum WindowMessage { SetCursorPosition(Position), SetIgnoreCursorEvents(bool), SetProgressBar(ProgressBarState), + SetTitleBarStyle(TitleBarStyle), DragWindow, ResizeDragWindow(tauri_runtime::ResizeDirection), RequestRedraw, @@ -1941,6 +1942,13 @@ impl WindowDispatch for WryWindowDispatcher { ), ) } + + fn set_title_bar_style(&self, style: tauri_utils::TitleBarStyle) -> Result<()> { + send_user_message( + &self.context, + Message::Window(self.window_id, WindowMessage::SetTitleBarStyle(style)), + ) + } } #[derive(Clone)] @@ -2851,6 +2859,23 @@ fn handle_user_message( WindowMessage::SetProgressBar(progress_state) => { window.set_progress_bar(ProgressBarStateWrapper::from(progress_state).0); } + WindowMessage::SetTitleBarStyle(style) => { + #[cfg(target_os = "macos")] + match style { + TitleBarStyle::Visible => { + window.set_titlebar_transparent(false); + window.set_fullsize_content_view(true); + } + TitleBarStyle::Transparent => { + window.set_titlebar_transparent(true); + window.set_fullsize_content_view(false); + } + TitleBarStyle::Overlay => { + window.set_titlebar_transparent(true); + window.set_fullsize_content_view(true); + } + }; + } } } } diff --git a/core/tauri-runtime/src/lib.rs b/core/tauri-runtime/src/lib.rs index fe12ecf7125..c985f8d0298 100644 --- a/core/tauri-runtime/src/lib.rs +++ b/core/tauri-runtime/src/lib.rs @@ -775,4 +775,11 @@ pub trait WindowDispatch: Debug + Clone + Send + Sync + Sized + 's /// - **Linux / macOS**: Progress bar is app-wide and not specific to this window. Only supported desktop environments with `libunity` (e.g. GNOME). /// - **iOS / Android:** Unsupported. fn set_progress_bar(&self, progress_state: ProgressBarState) -> Result<()>; + + /// Sets the title bar style. Available on macOS only. + /// + /// ## Platform-specific + /// + /// - **Linux / Windows / iOS / Android:** Unsupported. + fn set_title_bar_style(&self, style: tauri_utils::TitleBarStyle) -> Result<()>; } diff --git a/core/tauri/build.rs b/core/tauri/build.rs index 6c3ccb4f197..9cbc088ec36 100644 --- a/core/tauri/build.rs +++ b/core/tauri/build.rs @@ -106,6 +106,7 @@ const PLUGINS: &[(&str, &[(&str, bool)])] = &[ ("start_resize_dragging", false), ("set_progress_bar", false), ("set_icon", false), + ("set_title_bar_style", false), ("toggle_maximize", false), // internal ("internal_toggle_maximize", true), diff --git a/core/tauri/permissions/window/autogenerated/reference.md b/core/tauri/permissions/window/autogenerated/reference.md index 1e24e41a408..ea1ab591c37 100644 --- a/core/tauri/permissions/window/autogenerated/reference.md +++ b/core/tauri/permissions/window/autogenerated/reference.md @@ -108,6 +108,8 @@ |`deny-set-skip-taskbar`|Denies the set_skip_taskbar command without any pre-configured scope.| |`allow-set-title`|Enables the set_title command without any pre-configured scope.| |`deny-set-title`|Denies the set_title command without any pre-configured scope.| +|`allow-set-title-bar-style`|Enables the set_title_bar_style command without any pre-configured scope.| +|`deny-set-title-bar-style`|Denies the set_title_bar_style command without any pre-configured scope.| |`allow-set-visible-on-all-workspaces`|Enables the set_visible_on_all_workspaces command without any pre-configured scope.| |`deny-set-visible-on-all-workspaces`|Denies the set_visible_on_all_workspaces command without any pre-configured scope.| |`allow-show`|Enables the show command without any pre-configured scope.| diff --git a/core/tauri/scripts/bundle.global.js b/core/tauri/scripts/bundle.global.js index 9b7943f7606..f1dd443e375 100644 --- a/core/tauri/scripts/bundle.global.js +++ b/core/tauri/scripts/bundle.global.js @@ -1 +1 @@ -var __TAURI_IIFE__=function(e){"use strict";function t(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function n(e,t,n,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 t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}var i,r,a,s;function l(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}"function"==typeof SuppressedError&&SuppressedError;class o{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,i.set(this,(()=>{})),r.set(this,0),a.set(this,{}),this.id=l((({message:e,id:s})=>{if(s===t(this,r,"f")){n(this,r,s+1,"f"),t(this,i,"f").call(this,e);const l=Object.keys(t(this,a,"f"));if(l.length>0){let e=s+1;for(const n of l.sort()){if(parseInt(n)!==e)break;{const r=t(this,a,"f")[n];delete t(this,a,"f")[n],t(this,i,"f").call(this,r),e+=1}}n(this,r,e,"f")}}else t(this,a,"f")[s.toString()]=e}))}set onmessage(e){n(this,i,e,"f")}get onmessage(){return t(this,i,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}i=new WeakMap,r=new WeakMap,a=new WeakMap;class u{constructor(e,t,n){this.plugin=e,this.event=t,this.channelId=n}async unregister(){return c(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function c(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}class d{get rid(){return t(this,s,"f")}constructor(e){s.set(this,void 0),n(this,s,e,"f")}async close(){return c("plugin:resources|close",{rid:this.rid})}}s=new WeakMap;var p=Object.freeze({__proto__:null,Channel:o,PluginListener:u,Resource:d,addPluginListener:async function(e,t,n){const i=new o;return i.onmessage=n,c(`plugin:${e}|register_listener`,{event:t,handler:i}).then((()=>new u(e,t,i.id)))},convertFileSrc:function(e,t="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,t)},invoke:c,isTauri:function(){return"isTauri"in window&&!!window.isTauri},transformCallback:l});var h,y=Object.freeze({__proto__:null,getName:async function(){return c("plugin:app|name")},getTauriVersion:async function(){return c("plugin:app|tauri_version")},getVersion:async function(){return c("plugin:app|version")},hide:async function(){return c("plugin:app|app_hide")},show:async function(){return c("plugin:app|app_show")}});async function w(e,t){await c("plugin:event|unlisten",{event:e,eventId:t})}async function g(e,t,n){var i;const r="string"==typeof(null==n?void 0:n.target)?{kind:"AnyLabel",label:n.target}:null!==(i=null==n?void 0:n.target)&&void 0!==i?i:{kind:"Any"};return c("plugin:event|listen",{event:e,target:r,handler:l(t)}).then((t=>async()=>w(e,t)))}async function b(e,t,n){return g(e,(n=>{t(n),w(e,n.id).catch((()=>{}))}),n)}async function _(e,t){await c("plugin:event|emit",{event:e,payload:t})}async function m(e,t,n){const i="string"==typeof e?{kind:"AnyLabel",label:e}:e;await c("plugin:event|emit_to",{target:i,event:t,payload:n})}!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="tauri://drag",e.DROP="tauri://drop",e.DROP_OVER="tauri://drop-over",e.DROP_CANCELLED="tauri://drag-cancelled"}(h||(h={}));var v=Object.freeze({__proto__:null,get TauriEvent(){return h},emit:_,emitTo:m,listen:g,once:b});class f{constructor(e,t){this.type="Logical",this.width=e,this.height=t}}class k{constructor(e,t){this.type="Physical",this.width=e,this.height=t}toLogical(e){return new f(this.width/e,this.height/e)}}class A{constructor(e,t){this.type="Logical",this.x=e,this.y=t}}class D{constructor(e,t){this.type="Physical",this.x=e,this.y=t}toLogical(e){return new A(this.x/e,this.y/e)}}var E=Object.freeze({__proto__:null,LogicalPosition:A,LogicalSize:f,PhysicalPosition:D,PhysicalSize:k});class P extends d{constructor(e){super(e)}static async new(e,t,n){return c("plugin:image|new",{rgba:L(e),width:t,height:n}).then((e=>new P(e)))}static async fromBytes(e){return c("plugin:image|from_bytes",{bytes:L(e)}).then((e=>new P(e)))}static async fromPath(e){return c("plugin:image|from_path",{path:e}).then((e=>new P(e)))}async rgba(){return c("plugin:image|rgba",{rid:this.rid}).then((e=>new Uint8Array(e)))}async size(){return c("plugin:image|size",{rid:this.rid})}}function L(e){return null==e?null:"string"==typeof e?e:e instanceof Uint8Array?Array.from(e):e instanceof ArrayBuffer?Array.from(new Uint8Array(e)):e instanceof P?e.rid:e}var S,T,I=Object.freeze({__proto__:null,Image:P,transformImage:L});!function(e){e[e.Critical=1]="Critical",e[e.Informational=2]="Informational"}(S||(S={}));class C{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}function x(){return new O(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}function z(){return window.__TAURI_INTERNALS__.metadata.windows.map((e=>new O(e.label,{skip:!0})))}!function(e){e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error"}(T||(T={}));const R=["tauri://created","tauri://error"];class O{constructor(e,t={}){var n;this.label=e,this.listeners=Object.create(null),(null==t?void 0:t.skip)||c("plugin:window|create",{options:{...t,parent:"string"==typeof t.parent?t.parent:null===(n=t.parent)||void 0===n?void 0:n.label,label:e}}).then((async()=>this.emit("tauri://created"))).catch((async e=>this.emit("tauri://error",e)))}static getByLabel(e){var t;return null!==(t=z().find((t=>t.label===e)))&&void 0!==t?t:null}static getCurrent(){return x()}static getAll(){return z()}static async getFocusedWindow(){for(const e of z())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?Promise.resolve((()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)})):g(e,t,{target:{kind:"Window",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?Promise.resolve((()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)})):b(e,t,{target:{kind:"Window",label:this.label}})}async emit(e,t){if(R.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return Promise.resolve()}return _(e,t)}async emitTo(e,t,n){if(R.includes(t)){for(const e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return Promise.resolve()}return m(e,t,n)}_handleTauriEvent(e,t){return!!R.includes(e)&&(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0)}async scaleFactor(){return c("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return c("plugin:window|inner_position",{label:this.label}).then((({x:e,y:t})=>new D(e,t)))}async outerPosition(){return c("plugin:window|outer_position",{label:this.label}).then((({x:e,y:t})=>new D(e,t)))}async innerSize(){return c("plugin:window|inner_size",{label:this.label}).then((({width:e,height:t})=>new k(e,t)))}async outerSize(){return c("plugin:window|outer_size",{label:this.label}).then((({width:e,height:t})=>new k(e,t)))}async isFullscreen(){return c("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return c("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return c("plugin:window|is_maximized",{label:this.label})}async isFocused(){return c("plugin:window|is_focused",{label:this.label})}async isDecorated(){return c("plugin:window|is_decorated",{label:this.label})}async isResizable(){return c("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return c("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return c("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return c("plugin:window|is_closable",{label:this.label})}async isVisible(){return c("plugin:window|is_visible",{label:this.label})}async title(){return c("plugin:window|title",{label:this.label})}async theme(){return c("plugin:window|theme",{label:this.label})}async center(){return c("plugin:window|center",{label:this.label})}async requestUserAttention(e){let t=null;return e&&(t=e===S.Critical?{type:"Critical"}:{type:"Informational"}),c("plugin:window|request_user_attention",{label:this.label,value:t})}async setResizable(e){return c("plugin:window|set_resizable",{label:this.label,value:e})}async setMaximizable(e){return c("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return c("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return c("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return c("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return c("plugin:window|maximize",{label:this.label})}async unmaximize(){return c("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return c("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return c("plugin:window|minimize",{label:this.label})}async unminimize(){return c("plugin:window|unminimize",{label:this.label})}async show(){return c("plugin:window|show",{label:this.label})}async hide(){return c("plugin:window|hide",{label:this.label})}async close(){return c("plugin:window|close",{label:this.label})}async destroy(){return c("plugin:window|destroy",{label:this.label})}async setDecorations(e){return c("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return c("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return c("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return c("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return c("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return c("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return c("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");const t={};return t[`${e.type}`]={width:e.width,height:e.height},c("plugin:window|set_size",{label:this.label,value:t})}async setMinSize(e){if(e&&"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");let t=null;return e&&(t={},t[`${e.type}`]={width:e.width,height:e.height}),c("plugin:window|set_min_size",{label:this.label,value:t})}async setMaxSize(e){if(e&&"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");let t=null;return e&&(t={},t[`${e.type}`]={width:e.width,height:e.height}),c("plugin:window|set_max_size",{label:this.label,value:t})}async setPosition(e){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");const t={};return t[`${e.type}`]={x:e.x,y:e.y},c("plugin:window|set_position",{label:this.label,value:t})}async setFullscreen(e){return c("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return c("plugin:window|set_focus",{label:this.label})}async setIcon(e){return c("plugin:window|set_icon",{label:this.label,value:L(e)})}async setSkipTaskbar(e){return c("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return c("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return c("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return c("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setCursorPosition(e){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");const t={};return t[`${e.type}`]={x:e.x,y:e.y},c("plugin:window|set_cursor_position",{label:this.label,value:t})}async setIgnoreCursorEvents(e){return c("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return c("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return c("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setProgressBar(e){return c("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return c("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async onResized(e){return this.listen(h.WINDOW_RESIZED,(t=>{t.payload=U(t.payload),e(t)}))}async onMoved(e){return this.listen(h.WINDOW_MOVED,(t=>{t.payload=M(t.payload),e(t)}))}async onCloseRequested(e){return this.listen(h.WINDOW_CLOSE_REQUESTED,(t=>{const n=new C(t);Promise.resolve(e(n)).then((()=>{if(!n.isPreventDefault())return this.destroy()}))}))}async onDragDropEvent(e){const t=await this.listen(h.DRAG,(t=>{e({...t,payload:{type:"dragged",paths:t.payload.paths,position:M(t.payload.position)}})})),n=await this.listen(h.DROP,(t=>{e({...t,payload:{type:"dropped",paths:t.payload.paths,position:M(t.payload.position)}})})),i=await this.listen(h.DROP_OVER,(t=>{e({...t,payload:{type:"dragOver",position:M(t.payload.position)}})})),r=await this.listen(h.DROP_CANCELLED,(t=>{e({...t,payload:{type:"cancelled"}})}));return()=>{t(),n(),i(),r()}}async onFocusChanged(e){const t=await this.listen(h.WINDOW_FOCUS,(t=>{e({...t,payload:!0})})),n=await this.listen(h.WINDOW_BLUR,(t=>{e({...t,payload:!1})}));return()=>{t(),n()}}async onScaleChanged(e){return this.listen(h.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(h.WINDOW_THEME_CHANGED,e)}}var W,N;function F(e){return null===e?null:{name:e.name,scaleFactor:e.scaleFactor,position:M(e.position),size:U(e.size)}}function M(e){return new D(e.x,e.y)}function U(e){return new k(e.width,e.height)}!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"}(W||(W={})),function(e){e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive"}(N||(N={}));var B=Object.freeze({__proto__:null,CloseRequestedEvent:C,get Effect(){return W},get EffectState(){return N},LogicalPosition:A,LogicalSize:f,PhysicalPosition:D,PhysicalSize:k,get ProgressBarStatus(){return T},get UserAttentionType(){return S},Window:O,availableMonitors:async function(){return c("plugin:window|available_monitors").then((e=>e.map(F)))},currentMonitor:async function(){return c("plugin:window|current_monitor").then(F)},cursorPosition:async function(){return c("plugin:window|cursor_position").then(M)},getAll:z,getCurrent:x,monitorFromPoint:async function(e,t){return c("plugin:window|monitor_from_point",{x:e,y:t}).then(F)},primaryMonitor:async function(){return c("plugin:window|primary_monitor").then(F)}});function j(){return new H(x(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}function V(){return window.__TAURI_INTERNALS__.metadata.webviews.map((e=>new H(O.getByLabel(e.windowLabel),e.label,{skip:!0})))}const G=["tauri://created","tauri://error"];class H{constructor(e,t,n){this.window=e,this.label=t,this.listeners=Object.create(null),(null==n?void 0:n.skip)||c("plugin:webview|create_webview",{windowLabel:e.label,label:t,options:n}).then((async()=>this.emit("tauri://created"))).catch((async e=>this.emit("tauri://error",e)))}static getByLabel(e){var t;return null!==(t=V().find((t=>t.label===e)))&&void 0!==t?t:null}static getCurrent(){return j()}static getAll(){return V()}async listen(e,t){return this._handleTauriEvent(e,t)?Promise.resolve((()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)})):g(e,t,{target:{kind:"Webview",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?Promise.resolve((()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)})):b(e,t,{target:{kind:"Webview",label:this.label}})}async emit(e,t){if(G.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return Promise.resolve()}return _(e,t)}async emitTo(e,t,n){if(G.includes(t)){for(const e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return Promise.resolve()}return m(e,t,n)}_handleTauriEvent(e,t){return!!G.includes(e)&&(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0)}async position(){return c("plugin:webview|webview_position",{label:this.label}).then((({x:e,y:t})=>new D(e,t)))}async size(){return c("plugin:webview|webview_size",{label:this.label}).then((({width:e,height:t})=>new k(e,t)))}async close(){return c("plugin:webview|close",{label:this.label})}async setSize(e){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");const t={};return t[`${e.type}`]={width:e.width,height:e.height},c("plugin:webview|set_webview_size",{label:this.label,value:t})}async setPosition(e){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");const t={};return t[`${e.type}`]={x:e.x,y:e.y},c("plugin:webview|set_webview_position",{label:this.label,value:t})}async setFocus(){return c("plugin:webview|set_webview_focus",{label:this.label})}async setZoom(e){return c("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return c("plugin:webview|set_webview_focus",{label:this.label,window:"string"==typeof e?e:e.label})}async onDragDropEvent(e){const t=await this.listen(h.DRAG,(t=>{e({...t,payload:{type:"dragged",paths:t.payload.paths,position:$(t.payload.position)}})})),n=await this.listen(h.DROP,(t=>{e({...t,payload:{type:"dropped",paths:t.payload.paths,position:$(t.payload.position)}})})),i=await this.listen(h.DROP_CANCELLED,(t=>{e({...t,payload:{type:"dragOver",position:$(t.payload.position)}})})),r=await this.listen(h.DROP_CANCELLED,(t=>{e({...t,payload:{type:"cancelled"}})}));return()=>{t(),n(),i(),r()}}}function $(e){return new D(e.x,e.y)}var q,Q,Z=Object.freeze({__proto__:null,Webview:H,getAll:V,getCurrent:j});function J(){const e=j();return new Y(e.label,{skip:!0})}function K(){return window.__TAURI_INTERNALS__.metadata.webviews.map((e=>new Y(e.label,{skip:!0})))}class Y{constructor(e,t={}){var n;this.label=e,this.listeners=Object.create(null),(null==t?void 0:t.skip)||c("plugin:webview|create_webview_window",{options:{...t,parent:"string"==typeof t.parent?t.parent:null===(n=t.parent)||void 0===n?void 0:n.label,label:e}}).then((async()=>this.emit("tauri://created"))).catch((async e=>this.emit("tauri://error",e)))}static getByLabel(e){var t;const n=null!==(t=K().find((t=>t.label===e)))&&void 0!==t?t:null;return n?new Y(n.label,{skip:!0}):null}static getCurrent(){return J()}static getAll(){return K().map((e=>new Y(e.label,{skip:!0})))}async listen(e,t){return this._handleTauriEvent(e,t)?Promise.resolve((()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)})):g(e,t,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?Promise.resolve((()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)})):b(e,t,{target:{kind:"WebviewWindow",label:this.label}})}}q=Y,Q=[O,H],(Array.isArray(Q)?Q:[Q]).forEach((e=>{Object.getOwnPropertyNames(e.prototype).forEach((t=>{var n;"object"==typeof q.prototype&&q.prototype&&t in q.prototype||Object.defineProperty(q.prototype,t,null!==(n=Object.getOwnPropertyDescriptor(e.prototype,t))&&void 0!==n?n:Object.create(null))}))}));var X,ee=Object.freeze({__proto__:null,WebviewWindow:Y,getAll:K,getCurrent:J});!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"}(X||(X={}));var te=Object.freeze({__proto__:null,get BaseDirectory(){return X},appCacheDir:async function(){return c("plugin:path|resolve_directory",{directory:X.AppCache})},appConfigDir:async function(){return c("plugin:path|resolve_directory",{directory:X.AppConfig})},appDataDir:async function(){return c("plugin:path|resolve_directory",{directory:X.AppData})},appLocalDataDir:async function(){return c("plugin:path|resolve_directory",{directory:X.AppLocalData})},appLogDir:async function(){return c("plugin:path|resolve_directory",{directory:X.AppLog})},audioDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Audio})},basename:async function(e,t){return c("plugin:path|basename",{path:e,ext:t})},cacheDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Cache})},configDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Config})},dataDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Data})},delimiter:function(){return window.__TAURI_INTERNALS__.plugins.path.delimiter},desktopDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Desktop})},dirname:async function(e){return c("plugin:path|dirname",{path:e})},documentDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Document})},downloadDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Download})},executableDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Executable})},extname:async function(e){return c("plugin:path|extname",{path:e})},fontDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Font})},homeDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Home})},isAbsolute:async function(e){return c("plugin:path|isAbsolute",{path:e})},join:async function(...e){return c("plugin:path|join",{paths:e})},localDataDir:async function(){return c("plugin:path|resolve_directory",{directory:X.LocalData})},normalize:async function(e){return c("plugin:path|normalize",{path:e})},pictureDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Picture})},publicDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Public})},resolve:async function(...e){return c("plugin:path|resolve",{paths:e})},resolveResource:async function(e){return c("plugin:path|resolve_directory",{directory:X.Resource,path:e})},resourceDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Resource})},runtimeDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Runtime})},sep:function(){return window.__TAURI_INTERNALS__.plugins.path.sep},tempDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Temp})},templateDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Template})},videoDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Video})}});class ne extends d{constructor(e,t){super(e),this.id=t}static async getById(e){return c("plugin:tray|get_by_id",{id:e}).then((t=>t?new ne(t,e):null))}static async removeById(e){return c("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=L(e.icon));const t=new o;return(null==e?void 0:e.action)&&(t.onmessage=e.action,delete e.action),c("plugin:tray|new",{options:null!=e?e:{},handler:t}).then((([e,t])=>new ne(e,t)))}async setIcon(e){let t=null;return e&&(t=L(e)),c("plugin:tray|set_icon",{rid:this.rid,icon:t})}async setMenu(e){return e&&(e=[e.rid,e.kind]),c("plugin:tray|set_menu",{rid:this.rid,menu:e})}async setTooltip(e){return c("plugin:tray|set_tooltip",{rid:this.rid,tooltip:e})}async setTitle(e){return c("plugin:tray|set_title",{rid:this.rid,title:e})}async setVisible(e){return c("plugin:tray|set_visible",{rid:this.rid,visible:e})}async setTempDirPath(e){return c("plugin:tray|set_temp_dir_path",{rid:this.rid,path:e})}async setIconAsTemplate(e){return c("plugin:tray|set_icon_as_template",{rid:this.rid,asTemplate:e})}async setMenuOnLeftClick(e){return c("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}}var ie,re,ae,se=Object.freeze({__proto__:null,TrayIcon:ne});function le(e){var t;if("items"in e)e.items=null===(t=e.items)||void 0===t?void 0:t.map((e=>"rid"in e?e:le(e)));else if("action"in e&&e.action){const t=new o;return t.onmessage=e.action,delete e.action,{...e,handler:t}}return e}async function oe(e,t){const n=new o;let i=null;return t&&"object"==typeof t&&("action"in t&&t.action&&(n.onmessage=t.action,delete t.action),"items"in t&&t.items&&(i=t.items.map((e=>{var t;return"rid"in e?[e.rid,e.kind]:("item"in e&&"object"==typeof e.item&&(null===(t=e.item.About)||void 0===t?void 0:t.icon)&&(e.item.About.icon=L(e.item.About.icon)),"icon"in e&&e.icon&&(e.icon=L(e.icon)),le(e))})))),c("plugin:menu|new",{kind:e,options:t?{...t,items:i}:void 0,handler:n})}class ue extends d{get id(){return t(this,ie,"f")}get kind(){return t(this,re,"f")}constructor(e,t,i){super(e),ie.set(this,void 0),re.set(this,void 0),n(this,ie,t,"f"),n(this,re,i,"f")}}ie=new WeakMap,re=new WeakMap;class ce extends ue{constructor(e,t){super(e,t,"MenuItem")}static async new(e){return oe("MenuItem",e).then((([e,t])=>new ce(e,t)))}async text(){return c("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return c("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return c("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return c("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return c("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}}class de extends ue{constructor(e,t){super(e,t,"Check")}static async new(e){return oe("Check",e).then((([e,t])=>new de(e,t)))}async text(){return c("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return c("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return c("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return c("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return c("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async isChecked(){return c("plugin:menu|is_checked",{rid:this.rid})}async setChecked(e){return c("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"}(ae||(ae={}));class pe extends ue{constructor(e,t){super(e,t,"Icon")}static async new(e){return oe("Icon",e).then((([e,t])=>new pe(e,t)))}async text(){return c("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return c("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return c("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return c("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return c("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async setIcon(e){return c("plugin:menu|set_icon",{rid:this.rid,icon:L(e)})}}class he extends ue{constructor(e,t){super(e,t,"Predefined")}static async new(e){return oe("Predefined",e).then((([e,t])=>new he(e,t)))}async text(){return c("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return c("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}}function ye([e,t,n]){switch(n){case"Submenu":return new we(e,t);case"Predefined":return new he(e,t);case"Check":return new de(e,t);case"Icon":return new pe(e,t);default:return new ce(e,t)}}class we extends ue{constructor(e,t){super(e,t,"Submenu")}static async new(e){return oe("Submenu",e).then((([e,t])=>new we(e,t)))}async text(){return c("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return c("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return c("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return c("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async append(e){return c("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 c("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,t){return c("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:t})}async remove(e){return c("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return c("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(ye)}async items(){return c("plugin:menu|items",{rid:this.rid,kind:this.kind}).then((e=>e.map(ye)))}async get(e){return c("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then((e=>e?ye(e):null))}async popup(e,t){var n;let i=null;return e&&(i={},i[""+(e instanceof D?"Physical":"Logical")]={x:e.x,y:e.y}),c("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:null!==(n=null==t?void 0:t.label)&&void 0!==n?n:null,at:i})}async setAsWindowsMenuForNSApp(){return c("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return c("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}}function ge([e,t,n]){switch(n){case"Submenu":return new we(e,t);case"Predefined":return new he(e,t);case"Check":return new de(e,t);case"Icon":return new pe(e,t);default:return new ce(e,t)}}class be extends ue{constructor(e,t){super(e,t,"Menu")}static async new(e){return oe("Menu",e).then((([e,t])=>new be(e,t)))}static async default(){return c("plugin:menu|create_default").then((([e,t])=>new be(e,t)))}async append(e){return c("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 c("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,t){return c("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:t})}async remove(e){return c("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return c("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(ge)}async items(){return c("plugin:menu|items",{rid:this.rid,kind:this.kind}).then((e=>e.map(ge)))}async get(e){return c("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then((e=>e?ge(e):null))}async popup(e,t){var n;let i=null;return e&&(i={},i[""+(e instanceof D?"Physical":"Logical")]={x:e.x,y:e.y}),c("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:null!==(n=null==t?void 0:t.label)&&void 0!==n?n:null,at:i})}async setAsAppMenu(){return c("plugin:menu|set_as_app_menu",{rid:this.rid}).then((e=>e?new be(e[0],e[1]):null))}async setAsWindowMenu(e){var t;return c("plugin:menu|set_as_window_menu",{rid:this.rid,window:null!==(t=null==e?void 0:e.label)&&void 0!==t?t:null}).then((e=>e?new be(e[0],e[1]):null))}}var _e=Object.freeze({__proto__:null,CheckMenuItem:de,IconMenuItem:pe,Menu:be,MenuItem:ce,get NativeIcon(){return ae},PredefinedMenuItem:he,Submenu:we});return e.app=y,e.core=p,e.dpi=E,e.event=v,e.image=I,e.menu=_e,e.path=te,e.tray=se,e.webview=Z,e.webviewWindow=ee,e.window=B,e}({});window.__TAURI__=__TAURI_IIFE__; +var __TAURI_IIFE__=function(e){"use strict";function t(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function n(e,t,n,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 t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}var i,r,a,s;function l(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}"function"==typeof SuppressedError&&SuppressedError;class o{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,i.set(this,(()=>{})),r.set(this,0),a.set(this,{}),this.id=l((({message:e,id:s})=>{if(s===t(this,r,"f")){n(this,r,s+1,"f"),t(this,i,"f").call(this,e);const l=Object.keys(t(this,a,"f"));if(l.length>0){let e=s+1;for(const n of l.sort()){if(parseInt(n)!==e)break;{const r=t(this,a,"f")[n];delete t(this,a,"f")[n],t(this,i,"f").call(this,r),e+=1}}n(this,r,e,"f")}}else t(this,a,"f")[s.toString()]=e}))}set onmessage(e){n(this,i,e,"f")}get onmessage(){return t(this,i,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}i=new WeakMap,r=new WeakMap,a=new WeakMap;class u{constructor(e,t,n){this.plugin=e,this.event=t,this.channelId=n}async unregister(){return c(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function c(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}class d{get rid(){return t(this,s,"f")}constructor(e){s.set(this,void 0),n(this,s,e,"f")}async close(){return c("plugin:resources|close",{rid:this.rid})}}s=new WeakMap;var p=Object.freeze({__proto__:null,Channel:o,PluginListener:u,Resource:d,addPluginListener:async function(e,t,n){const i=new o;return i.onmessage=n,c(`plugin:${e}|register_listener`,{event:t,handler:i}).then((()=>new u(e,t,i.id)))},convertFileSrc:function(e,t="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,t)},invoke:c,isTauri:function(){return"isTauri"in window&&!!window.isTauri},transformCallback:l});var h,y=Object.freeze({__proto__:null,getName:async function(){return c("plugin:app|name")},getTauriVersion:async function(){return c("plugin:app|tauri_version")},getVersion:async function(){return c("plugin:app|version")},hide:async function(){return c("plugin:app|app_hide")},show:async function(){return c("plugin:app|app_show")}});async function w(e,t){await c("plugin:event|unlisten",{event:e,eventId:t})}async function g(e,t,n){var i;const r="string"==typeof(null==n?void 0:n.target)?{kind:"AnyLabel",label:n.target}:null!==(i=null==n?void 0:n.target)&&void 0!==i?i:{kind:"Any"};return c("plugin:event|listen",{event:e,target:r,handler:l(t)}).then((t=>async()=>w(e,t)))}async function b(e,t,n){return g(e,(n=>{t(n),w(e,n.id).catch((()=>{}))}),n)}async function _(e,t){await c("plugin:event|emit",{event:e,payload:t})}async function m(e,t,n){const i="string"==typeof e?{kind:"AnyLabel",label:e}:e;await c("plugin:event|emit_to",{target:i,event:t,payload:n})}!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="tauri://drag",e.DROP="tauri://drop",e.DROP_OVER="tauri://drop-over",e.DROP_CANCELLED="tauri://drag-cancelled"}(h||(h={}));var v=Object.freeze({__proto__:null,get TauriEvent(){return h},emit:_,emitTo:m,listen:g,once:b});class f{constructor(e,t){this.type="Logical",this.width=e,this.height=t}}class k{constructor(e,t){this.type="Physical",this.width=e,this.height=t}toLogical(e){return new f(this.width/e,this.height/e)}}class A{constructor(e,t){this.type="Logical",this.x=e,this.y=t}}class D{constructor(e,t){this.type="Physical",this.x=e,this.y=t}toLogical(e){return new A(this.x/e,this.y/e)}}var E=Object.freeze({__proto__:null,LogicalPosition:A,LogicalSize:f,PhysicalPosition:D,PhysicalSize:k});class P extends d{constructor(e){super(e)}static async new(e,t,n){return c("plugin:image|new",{rgba:L(e),width:t,height:n}).then((e=>new P(e)))}static async fromBytes(e){return c("plugin:image|from_bytes",{bytes:L(e)}).then((e=>new P(e)))}static async fromPath(e){return c("plugin:image|from_path",{path:e}).then((e=>new P(e)))}async rgba(){return c("plugin:image|rgba",{rid:this.rid}).then((e=>new Uint8Array(e)))}async size(){return c("plugin:image|size",{rid:this.rid})}}function L(e){return null==e?null:"string"==typeof e?e:e instanceof Uint8Array?Array.from(e):e instanceof ArrayBuffer?Array.from(new Uint8Array(e)):e instanceof P?e.rid:e}var S,T,I=Object.freeze({__proto__:null,Image:P,transformImage:L});!function(e){e[e.Critical=1]="Critical",e[e.Informational=2]="Informational"}(S||(S={}));class C{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}function x(){return new O(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}function z(){return window.__TAURI_INTERNALS__.metadata.windows.map((e=>new O(e.label,{skip:!0})))}!function(e){e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error"}(T||(T={}));const R=["tauri://created","tauri://error"];class O{constructor(e,t={}){var n;this.label=e,this.listeners=Object.create(null),(null==t?void 0:t.skip)||c("plugin:window|create",{options:{...t,parent:"string"==typeof t.parent?t.parent:null===(n=t.parent)||void 0===n?void 0:n.label,label:e}}).then((async()=>this.emit("tauri://created"))).catch((async e=>this.emit("tauri://error",e)))}static getByLabel(e){var t;return null!==(t=z().find((t=>t.label===e)))&&void 0!==t?t:null}static getCurrent(){return x()}static getAll(){return z()}static async getFocusedWindow(){for(const e of z())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?Promise.resolve((()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)})):g(e,t,{target:{kind:"Window",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?Promise.resolve((()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)})):b(e,t,{target:{kind:"Window",label:this.label}})}async emit(e,t){if(R.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return Promise.resolve()}return _(e,t)}async emitTo(e,t,n){if(R.includes(t)){for(const e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return Promise.resolve()}return m(e,t,n)}_handleTauriEvent(e,t){return!!R.includes(e)&&(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0)}async scaleFactor(){return c("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return c("plugin:window|inner_position",{label:this.label}).then((({x:e,y:t})=>new D(e,t)))}async outerPosition(){return c("plugin:window|outer_position",{label:this.label}).then((({x:e,y:t})=>new D(e,t)))}async innerSize(){return c("plugin:window|inner_size",{label:this.label}).then((({width:e,height:t})=>new k(e,t)))}async outerSize(){return c("plugin:window|outer_size",{label:this.label}).then((({width:e,height:t})=>new k(e,t)))}async isFullscreen(){return c("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return c("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return c("plugin:window|is_maximized",{label:this.label})}async isFocused(){return c("plugin:window|is_focused",{label:this.label})}async isDecorated(){return c("plugin:window|is_decorated",{label:this.label})}async isResizable(){return c("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return c("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return c("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return c("plugin:window|is_closable",{label:this.label})}async isVisible(){return c("plugin:window|is_visible",{label:this.label})}async title(){return c("plugin:window|title",{label:this.label})}async theme(){return c("plugin:window|theme",{label:this.label})}async center(){return c("plugin:window|center",{label:this.label})}async requestUserAttention(e){let t=null;return e&&(t=e===S.Critical?{type:"Critical"}:{type:"Informational"}),c("plugin:window|request_user_attention",{label:this.label,value:t})}async setResizable(e){return c("plugin:window|set_resizable",{label:this.label,value:e})}async setMaximizable(e){return c("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return c("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return c("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return c("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return c("plugin:window|maximize",{label:this.label})}async unmaximize(){return c("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return c("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return c("plugin:window|minimize",{label:this.label})}async unminimize(){return c("plugin:window|unminimize",{label:this.label})}async show(){return c("plugin:window|show",{label:this.label})}async hide(){return c("plugin:window|hide",{label:this.label})}async close(){return c("plugin:window|close",{label:this.label})}async destroy(){return c("plugin:window|destroy",{label:this.label})}async setDecorations(e){return c("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return c("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return c("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return c("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return c("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return c("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return c("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");const t={};return t[`${e.type}`]={width:e.width,height:e.height},c("plugin:window|set_size",{label:this.label,value:t})}async setMinSize(e){if(e&&"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");let t=null;return e&&(t={},t[`${e.type}`]={width:e.width,height:e.height}),c("plugin:window|set_min_size",{label:this.label,value:t})}async setMaxSize(e){if(e&&"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");let t=null;return e&&(t={},t[`${e.type}`]={width:e.width,height:e.height}),c("plugin:window|set_max_size",{label:this.label,value:t})}async setPosition(e){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");const t={};return t[`${e.type}`]={x:e.x,y:e.y},c("plugin:window|set_position",{label:this.label,value:t})}async setFullscreen(e){return c("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return c("plugin:window|set_focus",{label:this.label})}async setIcon(e){return c("plugin:window|set_icon",{label:this.label,value:L(e)})}async setSkipTaskbar(e){return c("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return c("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return c("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return c("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setCursorPosition(e){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");const t={};return t[`${e.type}`]={x:e.x,y:e.y},c("plugin:window|set_cursor_position",{label:this.label,value:t})}async setIgnoreCursorEvents(e){return c("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return c("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return c("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setProgressBar(e){return c("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return c("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return c("plugin:window|set_title_bar_style",{label:this.label,value:e})}async onResized(e){return this.listen(h.WINDOW_RESIZED,(t=>{t.payload=U(t.payload),e(t)}))}async onMoved(e){return this.listen(h.WINDOW_MOVED,(t=>{t.payload=M(t.payload),e(t)}))}async onCloseRequested(e){return this.listen(h.WINDOW_CLOSE_REQUESTED,(t=>{const n=new C(t);Promise.resolve(e(n)).then((()=>{if(!n.isPreventDefault())return this.destroy()}))}))}async onDragDropEvent(e){const t=await this.listen(h.DRAG,(t=>{e({...t,payload:{type:"dragged",paths:t.payload.paths,position:M(t.payload.position)}})})),n=await this.listen(h.DROP,(t=>{e({...t,payload:{type:"dropped",paths:t.payload.paths,position:M(t.payload.position)}})})),i=await this.listen(h.DROP_OVER,(t=>{e({...t,payload:{type:"dragOver",position:M(t.payload.position)}})})),r=await this.listen(h.DROP_CANCELLED,(t=>{e({...t,payload:{type:"cancelled"}})}));return()=>{t(),n(),i(),r()}}async onFocusChanged(e){const t=await this.listen(h.WINDOW_FOCUS,(t=>{e({...t,payload:!0})})),n=await this.listen(h.WINDOW_BLUR,(t=>{e({...t,payload:!1})}));return()=>{t(),n()}}async onScaleChanged(e){return this.listen(h.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(h.WINDOW_THEME_CHANGED,e)}}var W,N;function F(e){return null===e?null:{name:e.name,scaleFactor:e.scaleFactor,position:M(e.position),size:U(e.size)}}function M(e){return new D(e.x,e.y)}function U(e){return new k(e.width,e.height)}!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"}(W||(W={})),function(e){e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive"}(N||(N={}));var B=Object.freeze({__proto__:null,CloseRequestedEvent:C,get Effect(){return W},get EffectState(){return N},LogicalPosition:A,LogicalSize:f,PhysicalPosition:D,PhysicalSize:k,get ProgressBarStatus(){return T},get UserAttentionType(){return S},Window:O,availableMonitors:async function(){return c("plugin:window|available_monitors").then((e=>e.map(F)))},currentMonitor:async function(){return c("plugin:window|current_monitor").then(F)},cursorPosition:async function(){return c("plugin:window|cursor_position").then(M)},getAll:z,getCurrent:x,monitorFromPoint:async function(e,t){return c("plugin:window|monitor_from_point",{x:e,y:t}).then(F)},primaryMonitor:async function(){return c("plugin:window|primary_monitor").then(F)}});function j(){return new H(x(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}function V(){return window.__TAURI_INTERNALS__.metadata.webviews.map((e=>new H(O.getByLabel(e.windowLabel),e.label,{skip:!0})))}const G=["tauri://created","tauri://error"];class H{constructor(e,t,n){this.window=e,this.label=t,this.listeners=Object.create(null),(null==n?void 0:n.skip)||c("plugin:webview|create_webview",{windowLabel:e.label,label:t,options:n}).then((async()=>this.emit("tauri://created"))).catch((async e=>this.emit("tauri://error",e)))}static getByLabel(e){var t;return null!==(t=V().find((t=>t.label===e)))&&void 0!==t?t:null}static getCurrent(){return j()}static getAll(){return V()}async listen(e,t){return this._handleTauriEvent(e,t)?Promise.resolve((()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)})):g(e,t,{target:{kind:"Webview",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?Promise.resolve((()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)})):b(e,t,{target:{kind:"Webview",label:this.label}})}async emit(e,t){if(G.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:t});return Promise.resolve()}return _(e,t)}async emitTo(e,t,n){if(G.includes(t)){for(const e of this.listeners[t]||[])e({event:t,id:-1,payload:n});return Promise.resolve()}return m(e,t,n)}_handleTauriEvent(e,t){return!!G.includes(e)&&(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0)}async position(){return c("plugin:webview|webview_position",{label:this.label}).then((({x:e,y:t})=>new D(e,t)))}async size(){return c("plugin:webview|webview_size",{label:this.label}).then((({width:e,height:t})=>new k(e,t)))}async close(){return c("plugin:webview|close",{label:this.label})}async setSize(e){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");const t={};return t[`${e.type}`]={width:e.width,height:e.height},c("plugin:webview|set_webview_size",{label:this.label,value:t})}async setPosition(e){if(!e||"Logical"!==e.type&&"Physical"!==e.type)throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");const t={};return t[`${e.type}`]={x:e.x,y:e.y},c("plugin:webview|set_webview_position",{label:this.label,value:t})}async setFocus(){return c("plugin:webview|set_webview_focus",{label:this.label})}async setZoom(e){return c("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return c("plugin:webview|set_webview_focus",{label:this.label,window:"string"==typeof e?e:e.label})}async onDragDropEvent(e){const t=await this.listen(h.DRAG,(t=>{e({...t,payload:{type:"dragged",paths:t.payload.paths,position:$(t.payload.position)}})})),n=await this.listen(h.DROP,(t=>{e({...t,payload:{type:"dropped",paths:t.payload.paths,position:$(t.payload.position)}})})),i=await this.listen(h.DROP_CANCELLED,(t=>{e({...t,payload:{type:"dragOver",position:$(t.payload.position)}})})),r=await this.listen(h.DROP_CANCELLED,(t=>{e({...t,payload:{type:"cancelled"}})}));return()=>{t(),n(),i(),r()}}}function $(e){return new D(e.x,e.y)}var q,Q,Z=Object.freeze({__proto__:null,Webview:H,getAll:V,getCurrent:j});function J(){const e=j();return new Y(e.label,{skip:!0})}function K(){return window.__TAURI_INTERNALS__.metadata.webviews.map((e=>new Y(e.label,{skip:!0})))}class Y{constructor(e,t={}){var n;this.label=e,this.listeners=Object.create(null),(null==t?void 0:t.skip)||c("plugin:webview|create_webview_window",{options:{...t,parent:"string"==typeof t.parent?t.parent:null===(n=t.parent)||void 0===n?void 0:n.label,label:e}}).then((async()=>this.emit("tauri://created"))).catch((async e=>this.emit("tauri://error",e)))}static getByLabel(e){var t;const n=null!==(t=K().find((t=>t.label===e)))&&void 0!==t?t:null;return n?new Y(n.label,{skip:!0}):null}static getCurrent(){return J()}static getAll(){return K().map((e=>new Y(e.label,{skip:!0})))}async listen(e,t){return this._handleTauriEvent(e,t)?Promise.resolve((()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)})):g(e,t,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?Promise.resolve((()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)})):b(e,t,{target:{kind:"WebviewWindow",label:this.label}})}}q=Y,Q=[O,H],(Array.isArray(Q)?Q:[Q]).forEach((e=>{Object.getOwnPropertyNames(e.prototype).forEach((t=>{var n;"object"==typeof q.prototype&&q.prototype&&t in q.prototype||Object.defineProperty(q.prototype,t,null!==(n=Object.getOwnPropertyDescriptor(e.prototype,t))&&void 0!==n?n:Object.create(null))}))}));var X,ee=Object.freeze({__proto__:null,WebviewWindow:Y,getAll:K,getCurrent:J});!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"}(X||(X={}));var te=Object.freeze({__proto__:null,get BaseDirectory(){return X},appCacheDir:async function(){return c("plugin:path|resolve_directory",{directory:X.AppCache})},appConfigDir:async function(){return c("plugin:path|resolve_directory",{directory:X.AppConfig})},appDataDir:async function(){return c("plugin:path|resolve_directory",{directory:X.AppData})},appLocalDataDir:async function(){return c("plugin:path|resolve_directory",{directory:X.AppLocalData})},appLogDir:async function(){return c("plugin:path|resolve_directory",{directory:X.AppLog})},audioDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Audio})},basename:async function(e,t){return c("plugin:path|basename",{path:e,ext:t})},cacheDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Cache})},configDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Config})},dataDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Data})},delimiter:function(){return window.__TAURI_INTERNALS__.plugins.path.delimiter},desktopDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Desktop})},dirname:async function(e){return c("plugin:path|dirname",{path:e})},documentDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Document})},downloadDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Download})},executableDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Executable})},extname:async function(e){return c("plugin:path|extname",{path:e})},fontDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Font})},homeDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Home})},isAbsolute:async function(e){return c("plugin:path|isAbsolute",{path:e})},join:async function(...e){return c("plugin:path|join",{paths:e})},localDataDir:async function(){return c("plugin:path|resolve_directory",{directory:X.LocalData})},normalize:async function(e){return c("plugin:path|normalize",{path:e})},pictureDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Picture})},publicDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Public})},resolve:async function(...e){return c("plugin:path|resolve",{paths:e})},resolveResource:async function(e){return c("plugin:path|resolve_directory",{directory:X.Resource,path:e})},resourceDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Resource})},runtimeDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Runtime})},sep:function(){return window.__TAURI_INTERNALS__.plugins.path.sep},tempDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Temp})},templateDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Template})},videoDir:async function(){return c("plugin:path|resolve_directory",{directory:X.Video})}});class ne extends d{constructor(e,t){super(e),this.id=t}static async getById(e){return c("plugin:tray|get_by_id",{id:e}).then((t=>t?new ne(t,e):null))}static async removeById(e){return c("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=L(e.icon));const t=new o;return(null==e?void 0:e.action)&&(t.onmessage=e.action,delete e.action),c("plugin:tray|new",{options:null!=e?e:{},handler:t}).then((([e,t])=>new ne(e,t)))}async setIcon(e){let t=null;return e&&(t=L(e)),c("plugin:tray|set_icon",{rid:this.rid,icon:t})}async setMenu(e){return e&&(e=[e.rid,e.kind]),c("plugin:tray|set_menu",{rid:this.rid,menu:e})}async setTooltip(e){return c("plugin:tray|set_tooltip",{rid:this.rid,tooltip:e})}async setTitle(e){return c("plugin:tray|set_title",{rid:this.rid,title:e})}async setVisible(e){return c("plugin:tray|set_visible",{rid:this.rid,visible:e})}async setTempDirPath(e){return c("plugin:tray|set_temp_dir_path",{rid:this.rid,path:e})}async setIconAsTemplate(e){return c("plugin:tray|set_icon_as_template",{rid:this.rid,asTemplate:e})}async setMenuOnLeftClick(e){return c("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}}var ie,re,ae,se=Object.freeze({__proto__:null,TrayIcon:ne});function le(e){var t;if("items"in e)e.items=null===(t=e.items)||void 0===t?void 0:t.map((e=>"rid"in e?e:le(e)));else if("action"in e&&e.action){const t=new o;return t.onmessage=e.action,delete e.action,{...e,handler:t}}return e}async function oe(e,t){const n=new o;let i=null;return t&&"object"==typeof t&&("action"in t&&t.action&&(n.onmessage=t.action,delete t.action),"items"in t&&t.items&&(i=t.items.map((e=>{var t;return"rid"in e?[e.rid,e.kind]:("item"in e&&"object"==typeof e.item&&(null===(t=e.item.About)||void 0===t?void 0:t.icon)&&(e.item.About.icon=L(e.item.About.icon)),"icon"in e&&e.icon&&(e.icon=L(e.icon)),le(e))})))),c("plugin:menu|new",{kind:e,options:t?{...t,items:i}:void 0,handler:n})}class ue extends d{get id(){return t(this,ie,"f")}get kind(){return t(this,re,"f")}constructor(e,t,i){super(e),ie.set(this,void 0),re.set(this,void 0),n(this,ie,t,"f"),n(this,re,i,"f")}}ie=new WeakMap,re=new WeakMap;class ce extends ue{constructor(e,t){super(e,t,"MenuItem")}static async new(e){return oe("MenuItem",e).then((([e,t])=>new ce(e,t)))}async text(){return c("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return c("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return c("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return c("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return c("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}}class de extends ue{constructor(e,t){super(e,t,"Check")}static async new(e){return oe("Check",e).then((([e,t])=>new de(e,t)))}async text(){return c("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return c("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return c("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return c("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return c("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async isChecked(){return c("plugin:menu|is_checked",{rid:this.rid})}async setChecked(e){return c("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"}(ae||(ae={}));class pe extends ue{constructor(e,t){super(e,t,"Icon")}static async new(e){return oe("Icon",e).then((([e,t])=>new pe(e,t)))}async text(){return c("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return c("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return c("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return c("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return c("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async setIcon(e){return c("plugin:menu|set_icon",{rid:this.rid,icon:L(e)})}}class he extends ue{constructor(e,t){super(e,t,"Predefined")}static async new(e){return oe("Predefined",e).then((([e,t])=>new he(e,t)))}async text(){return c("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return c("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}}function ye([e,t,n]){switch(n){case"Submenu":return new we(e,t);case"Predefined":return new he(e,t);case"Check":return new de(e,t);case"Icon":return new pe(e,t);default:return new ce(e,t)}}class we extends ue{constructor(e,t){super(e,t,"Submenu")}static async new(e){return oe("Submenu",e).then((([e,t])=>new we(e,t)))}async text(){return c("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return c("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return c("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return c("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async append(e){return c("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 c("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,t){return c("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:t})}async remove(e){return c("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return c("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(ye)}async items(){return c("plugin:menu|items",{rid:this.rid,kind:this.kind}).then((e=>e.map(ye)))}async get(e){return c("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then((e=>e?ye(e):null))}async popup(e,t){var n;let i=null;return e&&(i={},i[""+(e instanceof D?"Physical":"Logical")]={x:e.x,y:e.y}),c("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:null!==(n=null==t?void 0:t.label)&&void 0!==n?n:null,at:i})}async setAsWindowsMenuForNSApp(){return c("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return c("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}}function ge([e,t,n]){switch(n){case"Submenu":return new we(e,t);case"Predefined":return new he(e,t);case"Check":return new de(e,t);case"Icon":return new pe(e,t);default:return new ce(e,t)}}class be extends ue{constructor(e,t){super(e,t,"Menu")}static async new(e){return oe("Menu",e).then((([e,t])=>new be(e,t)))}static async default(){return c("plugin:menu|create_default").then((([e,t])=>new be(e,t)))}async append(e){return c("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 c("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,t){return c("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:t})}async remove(e){return c("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return c("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(ge)}async items(){return c("plugin:menu|items",{rid:this.rid,kind:this.kind}).then((e=>e.map(ge)))}async get(e){return c("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then((e=>e?ge(e):null))}async popup(e,t){var n;let i=null;return e&&(i={},i[""+(e instanceof D?"Physical":"Logical")]={x:e.x,y:e.y}),c("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:null!==(n=null==t?void 0:t.label)&&void 0!==n?n:null,at:i})}async setAsAppMenu(){return c("plugin:menu|set_as_app_menu",{rid:this.rid}).then((e=>e?new be(e[0],e[1]):null))}async setAsWindowMenu(e){var t;return c("plugin:menu|set_as_window_menu",{rid:this.rid,window:null!==(t=null==e?void 0:e.label)&&void 0!==t?t:null}).then((e=>e?new be(e[0],e[1]):null))}}var _e=Object.freeze({__proto__:null,CheckMenuItem:de,IconMenuItem:pe,Menu:be,MenuItem:ce,get NativeIcon(){return ae},PredefinedMenuItem:he,Submenu:we});return e.app=y,e.core=p,e.dpi=E,e.event=v,e.image=I,e.menu=_e,e.path=te,e.tray=se,e.webview=Z,e.webviewWindow=ee,e.window=B,e}({});window.__TAURI__=__TAURI_IIFE__; diff --git a/core/tauri/src/test/mock_runtime.rs b/core/tauri/src/test/mock_runtime.rs index becab3e21cf..5c5e4b45fe3 100644 --- a/core/tauri/src/test/mock_runtime.rs +++ b/core/tauri/src/test/mock_runtime.rs @@ -929,6 +929,10 @@ impl WindowDispatch for MockWindowDispatcher { fn set_progress_bar(&self, progress_state: ProgressBarState) -> Result<()> { Ok(()) } + + fn set_title_bar_style(&self, style: tauri_utils::TitleBarStyle) -> Result<()> { + Ok(()) + } } #[derive(Debug, Clone)] diff --git a/core/tauri/src/webview/webview_window.rs b/core/tauri/src/webview/webview_window.rs index 69547bcc1ca..068f8aba764 100644 --- a/core/tauri/src/webview/webview_window.rs +++ b/core/tauri/src/webview/webview_window.rs @@ -1534,6 +1534,15 @@ impl WebviewWindow { ) -> crate::Result<()> { self.webview.window().set_progress_bar(progress_state) } + + /// Sets the title bar style. Available on macOS only. + /// + /// ## Platform-specific + /// + /// - **Linux / Windows / iOS / Android:** Unsupported. + pub fn set_title_bar_style(&self, style: tauri_utils::TitleBarStyle) -> crate::Result<()> { + self.webview.window().set_title_bar_style(style) + } } /// Desktop webview setters and actions. diff --git a/core/tauri/src/window/mod.rs b/core/tauri/src/window/mod.rs index ce7ae276178..9e41a4dc8e8 100644 --- a/core/tauri/src/window/mod.rs +++ b/core/tauri/src/window/mod.rs @@ -1999,6 +1999,18 @@ tauri::Builder::default() }) .map_err(Into::into) } + /// Sets the title bar style. Available on macOS only. + /// + /// ## Platform-specific + /// + /// - **Linux / Windows / iOS / Android:** Unsupported. + pub fn set_title_bar_style(&self, style: tauri_utils::TitleBarStyle) -> crate::Result<()> { + self + .window + .dispatcher + .set_title_bar_style(style) + .map_err(Into::into) + } } /// Progress bar state. diff --git a/core/tauri/src/window/plugin.rs b/core/tauri/src/window/plugin.rs index afaf6026e34..587c7b0037c 100644 --- a/core/tauri/src/window/plugin.rs +++ b/core/tauri/src/window/plugin.rs @@ -12,6 +12,7 @@ use crate::{ #[cfg(desktop)] mod desktop_commands { use tauri_runtime::ResizeDirection; + use tauri_utils::TitleBarStyle; use super::*; use crate::{ @@ -130,6 +131,7 @@ mod desktop_commands { setter!(start_resize_dragging, ResizeDirection); setter!(set_progress_bar, ProgressBarState); setter!(set_visible_on_all_workspaces, bool); + setter!(set_title_bar_style, TitleBarStyle); #[command(root = "crate")] pub async fn set_icon( @@ -276,6 +278,7 @@ pub fn init() -> TauriPlugin { desktop_commands::set_progress_bar, desktop_commands::set_icon, desktop_commands::set_visible_on_all_workspaces, + desktop_commands::set_title_bar_style, desktop_commands::toggle_maximize, desktop_commands::internal_toggle_maximize, ]); diff --git a/tooling/api/src/window.ts b/tooling/api/src/window.ts index c94a211aa7a..88049093073 100644 --- a/tooling/api/src/window.ts +++ b/tooling/api/src/window.ts @@ -1624,6 +1624,22 @@ class Window { }) } + /** + * Sets the title bar style. Available on macOS only. + * + * ## Platform-specific + * + * - **Linux / Windows / iOS / Android:**: Unsupported. + * + * @since 2.0.0 + */ + async setTitleBarStyle(style: TitleBarStyle): Promise { + return invoke('plugin:window|set_title_bar_style', { + label: this.label, + value: style + }) + } + // Listeners /** From 8bfb262a9ea1e5c3cc199dd4c209b0766dfcf555 Mon Sep 17 00:00:00 2001 From: Jason Tsai Date: Wed, 15 May 2024 18:09:20 +0800 Subject: [PATCH 2/3] chore: add changelog --- .changes/tauri-set-title-bar-style.md | 6 ++++++ core/tauri-runtime-wry/src/lib.rs | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changes/tauri-set-title-bar-style.md diff --git a/.changes/tauri-set-title-bar-style.md b/.changes/tauri-set-title-bar-style.md new file mode 100644 index 00000000000..bd46ea23662 --- /dev/null +++ b/.changes/tauri-set-title-bar-style.md @@ -0,0 +1,6 @@ +--- +'tauri': 'patch:feat' +'@tauri-apps/api': 'patch:feat' +--- + +Add a new method to set title bar style dynamically on macOS. diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index 727cc682b24..daeb9e63389 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -1148,7 +1148,7 @@ pub enum WindowMessage { SetCursorPosition(Position), SetIgnoreCursorEvents(bool), SetProgressBar(ProgressBarState), - SetTitleBarStyle(TitleBarStyle), + SetTitleBarStyle(tauri_utils::TitleBarStyle), DragWindow, ResizeDragWindow(tauri_runtime::ResizeDirection), RequestRedraw, @@ -2859,9 +2859,9 @@ fn handle_user_message( WindowMessage::SetProgressBar(progress_state) => { window.set_progress_bar(ProgressBarStateWrapper::from(progress_state).0); } - WindowMessage::SetTitleBarStyle(style) => { + WindowMessage::SetTitleBarStyle(_style) => { #[cfg(target_os = "macos")] - match style { + match _style { TitleBarStyle::Visible => { window.set_titlebar_transparent(false); window.set_fullsize_content_view(true); From b35f9a896c45bb21093b6978990baa9887501c81 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Wed, 3 Jul 2024 05:29:11 +0300 Subject: [PATCH 3/3] Apply suggestions from code review --- core/tauri/src/webview/webview_window.rs | 6 +----- core/tauri/src/window/mod.rs | 6 +----- tooling/api/src/window.ts | 6 +----- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/core/tauri/src/webview/webview_window.rs b/core/tauri/src/webview/webview_window.rs index 9bb1def61ae..1a1ff00aaa2 100644 --- a/core/tauri/src/webview/webview_window.rs +++ b/core/tauri/src/webview/webview_window.rs @@ -1585,11 +1585,7 @@ impl WebviewWindow { self.webview.window().set_progress_bar(progress_state) } - /// Sets the title bar style. Available on macOS only. - /// - /// ## Platform-specific - /// - /// - **Linux / Windows / iOS / Android:** Unsupported. + /// Sets the title bar style. **macOS only**. pub fn set_title_bar_style(&self, style: tauri_utils::TitleBarStyle) -> crate::Result<()> { self.webview.window().set_title_bar_style(style) } diff --git a/core/tauri/src/window/mod.rs b/core/tauri/src/window/mod.rs index 291ad00ce4b..847463adab7 100644 --- a/core/tauri/src/window/mod.rs +++ b/core/tauri/src/window/mod.rs @@ -1995,11 +1995,7 @@ tauri::Builder::default() }) .map_err(Into::into) } - /// Sets the title bar style. Available on macOS only. - /// - /// ## Platform-specific - /// - /// - **Linux / Windows / iOS / Android:** Unsupported. + /// Sets the title bar style. **macOS only**. pub fn set_title_bar_style(&self, style: tauri_utils::TitleBarStyle) -> crate::Result<()> { self .window diff --git a/tooling/api/src/window.ts b/tooling/api/src/window.ts index 5e2bb82b13b..aa19c84e2d0 100644 --- a/tooling/api/src/window.ts +++ b/tooling/api/src/window.ts @@ -1624,11 +1624,7 @@ class Window { } /** - * Sets the title bar style. Available on macOS only. - * - * ## Platform-specific - * - * - **Linux / Windows / iOS / Android:**: Unsupported. + * Sets the title bar style. **macOS only**. * * @since 2.0.0 */