From b8f86669ab05f7dbdd15839a20999e63dc43bda6 Mon Sep 17 00:00:00 2001 From: Typed SIGTERM Date: Sun, 13 Apr 2025 08:30:03 +0800 Subject: [PATCH] fix: make `isTauri` runtime-unrelated (#13145) * Update core.ts * Update core.ts * Update core.ts * lint * build * fix lint, add change file --------- Co-authored-by: Lucas Nogueira --- .changes/isTauri-tests.md | 5 +++++ crates/tauri/scripts/bundle.global.js | 2 +- packages/api/src/core.ts | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changes/isTauri-tests.md diff --git a/.changes/isTauri-tests.md b/.changes/isTauri-tests.md new file mode 100644 index 000000000..5a7606370 --- /dev/null +++ b/.changes/isTauri-tests.md @@ -0,0 +1,5 @@ +--- +"@tauri-apps/api": patch:enhance +--- + +`core.isTauri` now leverages `globalThis` instead of `window` in order to be used in unit tests. diff --git a/crates/tauri/scripts/bundle.global.js b/crates/tauri/scripts/bundle.global.js index 48991350e..9d5168d37 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 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,s,a,l;"function"==typeof SuppressedError&&SuppressedError;const o="__TAURI_TO_IPC_KEY__";function u(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}class c{constructor(e){i.set(this,void 0),r.set(this,0),s.set(this,[]),a.set(this,void 0),n(this,i,e||(()=>{}),"f"),this.id=u((e=>{const l=e.index;if("end"in e)return void(l==t(this,r,"f")?this.cleanupCallback():n(this,a,l,"f"));const o=e.message;if(l==t(this,r,"f")){for(t(this,i,"f").call(this,o),n(this,r,t(this,r,"f")+1,"f");t(this,r,"f")in t(this,s,"f");){const e=t(this,s,"f")[t(this,r,"f")];t(this,i,"f").call(this,e),delete t(this,s,"f")[t(this,r,"f")],n(this,r,t(this,r,"f")+1,"f")}t(this,r,"f")===t(this,a,"f")&&this.cleanupCallback()}else t(this,s,"f")[l]=o}))}cleanupCallback(){Reflect.deleteProperty(window,`_${this.id}`)}set onmessage(e){n(this,i,e,"f")}get onmessage(){return t(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,t,n){this.plugin=e,this.event=t,this.channelId=n}async unregister(){return h(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function h(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}class p{get rid(){return t(this,l,"f")}constructor(e){l.set(this,void 0),n(this,l,e,"f")}async close(){return h("plugin:resources|close",{rid:this.rid})}}l=new WeakMap;var w=Object.freeze({__proto__:null,Channel:c,PluginListener:d,Resource:p,SERIALIZE_TO_IPC_FN:o,addPluginListener:async function(e,t,n){const i=new c(n);return h(`plugin:${e}|registerListener`,{event:t,handler:i}).then((()=>new d(e,t,i.id)))},checkPermissions:async function(e){return h(`plugin:${e}|check_permissions`)},convertFileSrc:function(e,t="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,t)},invoke:h,isTauri:function(){return"isTauri"in window&&!!window.isTauri},requestPermissions:async function(e){return h(`plugin:${e}|request_permissions`)},transformCallback:u});class y extends p{constructor(e){super(e)}static async new(e,t,n){return h("plugin:image|new",{rgba:_(e),width:t,height:n}).then((e=>new y(e)))}static async fromBytes(e){return h("plugin:image|from_bytes",{bytes:_(e)}).then((e=>new y(e)))}static async fromPath(e){return h("plugin:image|from_path",{path:e}).then((e=>new y(e)))}async rgba(){return h("plugin:image|rgba",{rid:this.rid}).then((e=>new Uint8Array(e)))}async size(){return h("plugin:image|size",{rid:this.rid})}}function _(e){return null==e?null:"string"==typeof e?e:e instanceof y?e.rid:e}var g=Object.freeze({__proto__:null,Image:y,transformImage:_});var b=Object.freeze({__proto__:null,defaultWindowIcon:async function(){return h("plugin:app|default_window_icon").then((e=>e?new y(e):null))},fetchDataStoreIdentifiers:async function(){return h("plugin:app|fetch_data_store_identifiers")},getIdentifier:async function(){return h("plugin:app|identifier")},getName:async function(){return h("plugin:app|name")},getTauriVersion:async function(){return h("plugin:app|tauri_version")},getVersion:async function(){return h("plugin:app|version")},hide:async function(){return h("plugin:app|app_hide")},removeDataStore:async function(e){return h("plugin:app|remove_data_store",{uuid:e})},setDockVisibility:async function(e){return h("plugin:app|set_dock_visibility",{visible:e})},setTheme:async function(e){return h("plugin:app|set_app_theme",{theme:e})},show:async function(){return h("plugin:app|app_show")}});class m{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 m(this.width/e,this.height/e)}[o](){return{width:this.width,height:this.height}}toJSON(){return this[o]()}}class f{constructor(e){this.size=e}toLogical(e){return this.size instanceof m?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 k{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 A(this.x*e,this.y*e)}[o](){return{x:this.x,y:this.y}}toJSON(){return this[o]()}}class A{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 k(this.x/e,this.y/e)}[o](){return{x:this.x,y:this.y}}toJSON(){return this[o]()}}class D{constructor(e){this.position=e}toLogical(e){return this.position instanceof k?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof A?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,T=Object.freeze({__proto__:null,LogicalPosition:k,LogicalSize:m,PhysicalPosition:A,PhysicalSize:v,Position:D,Size:f});async function I(e,t){await h("plugin:event|unlisten",{event:e,eventId:t})}async function S(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 h("plugin:event|listen",{event:e,target:r,handler:u(t)}).then((t=>async()=>I(e,t)))}async function R(e,t,n){return S(e,(n=>{I(e,n.id),t(n)}),n)}async function L(e,t){await h("plugin:event|emit",{event:e,payload:t})}async function C(e,t,n){const i="string"==typeof e?{kind:"AnyLabel",label:e}:e;await h("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_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,N,P,W=Object.freeze({__proto__:null,get TauriEvent(){return E},emit:L,emitTo:C,listen:S,once:R});function z(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:z(e)));else if("action"in e&&e.action){const t=new c;return t.onmessage=e.action,delete e.action,{...e,handler:t}}return e}async function O(e,t){const n=new c;if(t&&"object"==typeof t&&("action"in t&&t.action&&(n.onmessage=t.action,delete t.action),"item"in t&&t.item&&"object"==typeof t.item&&"About"in t.item&&t.item.About&&"object"==typeof t.item.About&&"icon"in t.item.About&&t.item.About.icon&&(t.item.About.icon=_(t.item.About.icon)),"icon"in t&&t.icon&&(t.icon=_(t.icon)),"items"in t&&t.items)){function i(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=_(e.item.About.icon)),"icon"in e&&e.icon&&(e.icon=_(e.icon)),"items"in e&&e.items&&(e.items=e.items.map(i)),z(e))}t.items=t.items.map(i)}return h("plugin:menu|new",{kind:e,options:t,handler:n})}class F extends p{get id(){return t(this,x,"f")}get kind(){return t(this,N,"f")}constructor(e,t,i){super(e),x.set(this,void 0),N.set(this,void 0),n(this,x,t,"f"),n(this,N,i,"f")}}x=new WeakMap,N=new WeakMap;class M extends F{constructor(e,t){super(e,t,"MenuItem")}static async new(e){return O("MenuItem",e).then((([e,t])=>new M(e,t)))}async text(){return h("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return h("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return h("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return h("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return h("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}}class U extends F{constructor(e,t){super(e,t,"Check")}static async new(e){return O("Check",e).then((([e,t])=>new U(e,t)))}async text(){return h("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return h("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return h("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return h("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return h("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async isChecked(){return h("plugin:menu|is_checked",{rid:this.rid})}async setChecked(e){return h("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 B extends F{constructor(e,t){super(e,t,"Icon")}static async new(e){return O("Icon",e).then((([e,t])=>new B(e,t)))}async text(){return h("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return h("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return h("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return h("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return h("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async setIcon(e){return h("plugin:menu|set_icon",{rid:this.rid,icon:_(e)})}}class j extends F{constructor(e,t){super(e,t,"Predefined")}static async new(e){return O("Predefined",e).then((([e,t])=>new j(e,t)))}async text(){return h("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return h("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}}function V([e,t,n]){switch(n){case"Submenu":return new G(e,t);case"Predefined":return new j(e,t);case"Check":return new U(e,t);case"Icon":return new B(e,t);default:return new M(e,t)}}class G extends F{constructor(e,t){super(e,t,"Submenu")}static async new(e){return O("Submenu",e).then((([e,t])=>new G(e,t)))}async text(){return h("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return h("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return h("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return h("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async append(e){return h("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 h("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 h("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 h("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return h("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(V)}async items(){return h("plugin:menu|items",{rid:this.rid,kind:this.kind}).then((e=>e.map(V)))}async get(e){return h("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then((e=>e?V(e):null))}async popup(e,t){var n;return h("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:null!==(n=null==t?void 0:t.label)&&void 0!==n?n:null,at:e instanceof D?e:e?new D(e):null})}async setAsWindowsMenuForNSApp(){return h("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return h("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}}class H extends F{constructor(e,t){super(e,t,"Menu")}static async new(e){return O("Menu",e).then((([e,t])=>new H(e,t)))}static async default(){return h("plugin:menu|create_default").then((([e,t])=>new H(e,t)))}async append(e){return h("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 h("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 h("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 h("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return h("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(V)}async items(){return h("plugin:menu|items",{rid:this.rid,kind:this.kind}).then((e=>e.map(V)))}async get(e){return h("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then((e=>e?V(e):null))}async popup(e,t){var n;return h("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:null!==(n=null==t?void 0:t.label)&&void 0!==n?n:null,at:e instanceof D?e:e?new D(e):null})}async setAsAppMenu(){return h("plugin:menu|set_as_app_menu",{rid:this.rid}).then((e=>e?new H(e[0],e[1]):null))}async setAsWindowMenu(e){var t;return h("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 H(e[0],e[1]):null))}}var $=Object.freeze({__proto__:null,CheckMenuItem:U,IconMenuItem:B,Menu:H,MenuItem:M,get NativeIcon(){return P},PredefinedMenuItem:j,Submenu:G,itemFromKind:V});function q(){var e;window.__TAURI_INTERNALS__=null!==(e=window.__TAURI_INTERNALS__)&&void 0!==e?e:{}}var J,Q=Object.freeze({__proto__:null,clearMocks:function(){var e,t,n;"object"==typeof window.__TAURI_INTERNALS__&&((null===(e=window.__TAURI_INTERNALS__)||void 0===e?void 0:e.convertFileSrc)&&delete window.__TAURI_INTERNALS__.convertFileSrc,(null===(t=window.__TAURI_INTERNALS__)||void 0===t?void 0:t.invoke)&&delete window.__TAURI_INTERNALS__.invoke,(null===(n=window.__TAURI_INTERNALS__)||void 0===n?void 0:n.metadata)&&delete window.__TAURI_INTERNALS__.metadata)},mockConvertFileSrc:function(e){q(),window.__TAURI_INTERNALS__.convertFileSrc=function(t,n="asset"){const i=encodeURIComponent(t);return"windows"===e?`http://${n}.localhost/${i}`:`${n}://localhost/${i}`}},mockIPC:function(e){q(),window.__TAURI_INTERNALS__.transformCallback=function(e,t=!1){const n=window.crypto.getRandomValues(new Uint32Array(1))[0],i=`_${n}`;return Object.defineProperty(window,i,{value:n=>(t&&Reflect.deleteProperty(window,i),e&&e(n)),writable:!1,configurable:!0}),n},window.__TAURI_INTERNALS__.invoke=async function(t,n,i){return e(t,n)}},mockWindows:function(e,...t){q(),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"}(J||(J={}));var Z=Object.freeze({__proto__:null,get BaseDirectory(){return J},appCacheDir:async function(){return h("plugin:path|resolve_directory",{directory:J.AppCache})},appConfigDir:async function(){return h("plugin:path|resolve_directory",{directory:J.AppConfig})},appDataDir:async function(){return h("plugin:path|resolve_directory",{directory:J.AppData})},appLocalDataDir:async function(){return h("plugin:path|resolve_directory",{directory:J.AppLocalData})},appLogDir:async function(){return h("plugin:path|resolve_directory",{directory:J.AppLog})},audioDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Audio})},basename:async function(e,t){return h("plugin:path|basename",{path:e,ext:t})},cacheDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Cache})},configDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Config})},dataDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Data})},delimiter:function(){return window.__TAURI_INTERNALS__.plugins.path.delimiter},desktopDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Desktop})},dirname:async function(e){return h("plugin:path|dirname",{path:e})},documentDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Document})},downloadDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Download})},executableDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Executable})},extname:async function(e){return h("plugin:path|extname",{path:e})},fontDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Font})},homeDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Home})},isAbsolute:async function(e){return h("plugin:path|is_absolute",{path:e})},join:async function(...e){return h("plugin:path|join",{paths:e})},localDataDir:async function(){return h("plugin:path|resolve_directory",{directory:J.LocalData})},normalize:async function(e){return h("plugin:path|normalize",{path:e})},pictureDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Picture})},publicDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Public})},resolve:async function(...e){return h("plugin:path|resolve",{paths:e})},resolveResource:async function(e){return h("plugin:path|resolve_directory",{directory:J.Resource,path:e})},resourceDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Resource})},runtimeDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Runtime})},sep:function(){return window.__TAURI_INTERNALS__.plugins.path.sep},tempDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Temp})},templateDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Template})},videoDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Video})}});class K extends p{constructor(e,t){super(e),this.id=t}static async getById(e){return h("plugin:tray|get_by_id",{id:e}).then((t=>t?new K(t,e):null))}static async removeById(e){return h("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=_(e.icon));const t=new c;if(null==e?void 0:e.action){const n=e.action;t.onmessage=e=>n(function(e){const t=e;return t.position=new A(e.position),t.rect.position=new A(e.rect.position),t.rect.size=new v(e.rect.size),t}(e)),delete e.action}return h("plugin:tray|new",{options:null!=e?e:{},handler:t}).then((([e,t])=>new K(e,t)))}async setIcon(e){let t=null;return e&&(t=_(e)),h("plugin:tray|set_icon",{rid:this.rid,icon:t})}async setMenu(e){return e&&(e=[e.rid,e.kind]),h("plugin:tray|set_menu",{rid:this.rid,menu:e})}async setTooltip(e){return h("plugin:tray|set_tooltip",{rid:this.rid,tooltip:e})}async setTitle(e){return h("plugin:tray|set_title",{rid:this.rid,title:e})}async setVisible(e){return h("plugin:tray|set_visible",{rid:this.rid,visible:e})}async setTempDirPath(e){return h("plugin:tray|set_temp_dir_path",{rid:this.rid,path:e})}async setIconAsTemplate(e){return h("plugin:tray|set_icon_as_template",{rid:this.rid,asTemplate:e})}async setMenuOnLeftClick(e){return h("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}async setShowMenuOnLeftClick(e){return h("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}}var Y,X,ee=Object.freeze({__proto__:null,TrayIcon:K});!function(e){e[e.Critical=1]="Critical",e[e.Informational=2]="Informational"}(Y||(Y={}));class te{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}function ne(){return new se(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function ie(){return h("plugin:window|get_all_windows").then((e=>e.map((e=>new se(e,{skip:!0})))))}!function(e){e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error"}(X||(X={}));const re=["tauri://created","tauri://error"];class se{constructor(e,t={}){var n;this.label=e,this.listeners=Object.create(null),(null==t?void 0:t.skip)||h("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 async getByLabel(e){var t;return null!==(t=(await ie()).find((t=>t.label===e)))&&void 0!==t?t:null}static getCurrent(){return ne()}static async getAll(){return ie()}static async getFocusedWindow(){for(const e of await ie())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)}:S(e,t,{target:{kind:"Window",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)}:R(e,t,{target:{kind:"Window",label:this.label}})}async emit(e,t){if(!re.includes(e))return L(e,t);for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:t})}async emitTo(e,t,n){if(!re.includes(t))return C(e,t,n);for(const e of this.listeners[t]||[])e({event:t,id:-1,payload:n})}_handleTauriEvent(e,t){return!!re.includes(e)&&(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0)}async scaleFactor(){return h("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return h("plugin:window|inner_position",{label:this.label}).then((e=>new A(e)))}async outerPosition(){return h("plugin:window|outer_position",{label:this.label}).then((e=>new A(e)))}async innerSize(){return h("plugin:window|inner_size",{label:this.label}).then((e=>new v(e)))}async outerSize(){return h("plugin:window|outer_size",{label:this.label}).then((e=>new v(e)))}async isFullscreen(){return h("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return h("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return h("plugin:window|is_maximized",{label:this.label})}async isFocused(){return h("plugin:window|is_focused",{label:this.label})}async isDecorated(){return h("plugin:window|is_decorated",{label:this.label})}async isResizable(){return h("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return h("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return h("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return h("plugin:window|is_closable",{label:this.label})}async isVisible(){return h("plugin:window|is_visible",{label:this.label})}async title(){return h("plugin:window|title",{label:this.label})}async theme(){return h("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return h("plugin:window|is_always_on_top",{label:this.label})}async center(){return h("plugin:window|center",{label:this.label})}async requestUserAttention(e){let t=null;return e&&(t=e===Y.Critical?{type:"Critical"}:{type:"Informational"}),h("plugin:window|request_user_attention",{label:this.label,value:t})}async setResizable(e){return h("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return h("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return h("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return h("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return h("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return h("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return h("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return h("plugin:window|maximize",{label:this.label})}async unmaximize(){return h("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return h("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return h("plugin:window|minimize",{label:this.label})}async unminimize(){return h("plugin:window|unminimize",{label:this.label})}async show(){return h("plugin:window|show",{label:this.label})}async hide(){return h("plugin:window|hide",{label:this.label})}async close(){return h("plugin:window|close",{label:this.label})}async destroy(){return h("plugin:window|destroy",{label:this.label})}async setDecorations(e){return h("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return h("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return h("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return h("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return h("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return h("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return h("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return h("plugin:window|set_size",{label:this.label,value:e instanceof f?e:new f(e)})}async setMinSize(e){return h("plugin:window|set_min_size",{label:this.label,value:e instanceof f?e:e?new f(e):null})}async setMaxSize(e){return h("plugin:window|set_max_size",{label:this.label,value:e instanceof f?e:e?new f(e):null})}async setSizeConstraints(e){function t(e){return e?{Logical:e}:null}return h("plugin:window|set_size_constraints",{label:this.label,value:{minWidth:t(null==e?void 0:e.minWidth),minHeight:t(null==e?void 0:e.minHeight),maxWidth:t(null==e?void 0:e.maxWidth),maxHeight:t(null==e?void 0:e.maxHeight)}})}async setPosition(e){return h("plugin:window|set_position",{label:this.label,value:e instanceof D?e:new D(e)})}async setFullscreen(e){return h("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return h("plugin:window|set_focus",{label:this.label})}async setIcon(e){return h("plugin:window|set_icon",{label:this.label,value:_(e)})}async setSkipTaskbar(e){return h("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return h("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return h("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return h("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return h("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return h("plugin:window|set_cursor_position",{label:this.label,value:e instanceof D?e:new D(e)})}async setIgnoreCursorEvents(e){return h("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return h("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return h("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return h("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return h("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return h("plugin:window|set_overlay_icon",{label:this.label,value:e?_(e):void 0})}async setProgressBar(e){return h("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return h("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return h("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return h("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(E.WINDOW_RESIZED,(t=>{t.payload=new v(t.payload),e(t)}))}async onMoved(e){return this.listen(E.WINDOW_MOVED,(t=>{t.payload=new A(t.payload),e(t)}))}async onCloseRequested(e){return this.listen(E.WINDOW_CLOSE_REQUESTED,(async t=>{const n=new te(t);await e(n),n.isPreventDefault()||await this.destroy()}))}async onDragDropEvent(e){const t=await this.listen(E.DRAG_ENTER,(t=>{e({...t,payload:{type:"enter",paths:t.payload.paths,position:new A(t.payload.position)}})})),n=await this.listen(E.DRAG_OVER,(t=>{e({...t,payload:{type:"over",position:new A(t.payload.position)}})})),i=await this.listen(E.DRAG_DROP,(t=>{e({...t,payload:{type:"drop",paths:t.payload.paths,position:new A(t.payload.position)}})})),r=await this.listen(E.DRAG_LEAVE,(t=>{e({...t,payload:{type:"leave"}})}));return()=>{t(),i(),n(),r()}}async onFocusChanged(e){const t=await this.listen(E.WINDOW_FOCUS,(t=>{e({...t,payload:!0})})),n=await this.listen(E.WINDOW_BLUR,(t=>{e({...t,payload:!1})}));return()=>{t(),n()}}async onScaleChanged(e){return this.listen(E.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(E.WINDOW_THEME_CHANGED,e)}}var ae,le,oe;function ue(e){return null===e?null:{name:e.name,scaleFactor:e.scaleFactor,position:new A(e.position),size:new v(e.size)}}!function(e){e.Disabled="disabled",e.Throttle="throttle",e.Suspend="suspend"}(ae||(ae={})),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"}(le||(le={})),function(e){e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive"}(oe||(oe={}));var ce=Object.freeze({__proto__:null,CloseRequestedEvent:te,get Effect(){return le},get EffectState(){return oe},LogicalPosition:k,LogicalSize:m,PhysicalPosition:A,PhysicalSize:v,get ProgressBarStatus(){return X},get UserAttentionType(){return Y},Window:se,availableMonitors:async function(){return h("plugin:window|available_monitors").then((e=>e.map(ue)))},currentMonitor:async function(){return h("plugin:window|current_monitor").then(ue)},cursorPosition:async function(){return h("plugin:window|cursor_position").then((e=>new A(e)))},getAllWindows:ie,getCurrentWindow:ne,monitorFromPoint:async function(e,t){return h("plugin:window|monitor_from_point",{x:e,y:t}).then(ue)},primaryMonitor:async function(){return h("plugin:window|primary_monitor").then(ue)}});function de(){return new we(ne(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function he(){return h("plugin:webview|get_all_webviews").then((e=>e.map((e=>new we(new se(e.windowLabel,{skip:!0}),e.label,{skip:!0})))))}const pe=["tauri://created","tauri://error"];class we{constructor(e,t,n){this.window=e,this.label=t,this.listeners=Object.create(null),(null==n?void 0:n.skip)||h("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 async getByLabel(e){var t;return null!==(t=(await he()).find((t=>t.label===e)))&&void 0!==t?t:null}static getCurrent(){return de()}static async getAll(){return he()}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)}:S(e,t,{target:{kind:"Webview",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)}:R(e,t,{target:{kind:"Webview",label:this.label}})}async emit(e,t){if(!pe.includes(e))return L(e,t);for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:t})}async emitTo(e,t,n){if(!pe.includes(t))return C(e,t,n);for(const e of this.listeners[t]||[])e({event:t,id:-1,payload:n})}_handleTauriEvent(e,t){return!!pe.includes(e)&&(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0)}async position(){return h("plugin:webview|webview_position",{label:this.label}).then((e=>new A(e)))}async size(){return h("plugin:webview|webview_size",{label:this.label}).then((e=>new v(e)))}async close(){return h("plugin:webview|webview_close",{label:this.label})}async setSize(e){return h("plugin:webview|set_webview_size",{label:this.label,value:e instanceof f?e:new f(e)})}async setPosition(e){return h("plugin:webview|set_webview_position",{label:this.label,value:e instanceof D?e:new D(e)})}async setFocus(){return h("plugin:webview|set_webview_focus",{label:this.label})}async hide(){return h("plugin:webview|webview_hide",{label:this.label})}async show(){return h("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return h("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return h("plugin:webview|reparent",{label:this.label,window:"string"==typeof e?e:e.label})}async clearAllBrowsingData(){return h("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return h("plugin:webview|set_webview_background_color",{color:e})}async onDragDropEvent(e){const t=await this.listen(E.DRAG_ENTER,(t=>{e({...t,payload:{type:"enter",paths:t.payload.paths,position:new A(t.payload.position)}})})),n=await this.listen(E.DRAG_OVER,(t=>{e({...t,payload:{type:"over",position:new A(t.payload.position)}})})),i=await this.listen(E.DRAG_DROP,(t=>{e({...t,payload:{type:"drop",paths:t.payload.paths,position:new A(t.payload.position)}})})),r=await this.listen(E.DRAG_LEAVE,(t=>{e({...t,payload:{type:"leave"}})}));return()=>{t(),i(),n(),r()}}}var ye,_e,ge=Object.freeze({__proto__:null,Webview:we,getAllWebviews:he,getCurrentWebview:de});function be(){const e=de();return new ve(e.label,{skip:!0})}async function me(){return h("plugin:window|get_all_windows").then((e=>e.map((e=>new ve(e,{skip:!0})))))}class ve{constructor(e,t={}){var n;this.label=e,this.listeners=Object.create(null),(null==t?void 0:t.skip)||h("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 async getByLabel(e){var t;const n=null!==(t=(await me()).find((t=>t.label===e)))&&void 0!==t?t:null;return n?new ve(n.label,{skip:!0}):null}static getCurrent(){return be()}static async getAll(){return me()}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)}:S(e,t,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)}:R(e,t,{target:{kind:"WebviewWindow",label:this.label}})}async setBackgroundColor(e){return h("plugin:window|set_background_color",{color:e}).then((()=>h("plugin:webview|set_webview_background_color",{color:e})))}}ye=ve,_e=[se,we],(Array.isArray(_e)?_e:[_e]).forEach((e=>{Object.getOwnPropertyNames(e.prototype).forEach((t=>{var n;"object"==typeof ye.prototype&&ye.prototype&&t in ye.prototype||Object.defineProperty(ye.prototype,t,null!==(n=Object.getOwnPropertyDescriptor(e.prototype,t))&&void 0!==n?n:Object.create(null))}))}));var fe=Object.freeze({__proto__:null,WebviewWindow:ve,getAllWebviewWindows:me,getCurrentWebviewWindow:be});return e.app=b,e.core=w,e.dpi=T,e.event=W,e.image=g,e.menu=$,e.mocks=Q,e.path=Z,e.tray=ee,e.webview=ge,e.webviewWindow=fe,e.window=ce,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,s,a,l;"function"==typeof SuppressedError&&SuppressedError;const o="__TAURI_TO_IPC_KEY__";function u(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}class c{constructor(e){i.set(this,void 0),r.set(this,0),s.set(this,[]),a.set(this,void 0),n(this,i,e||(()=>{}),"f"),this.id=u((e=>{const l=e.index;if("end"in e)return void(l==t(this,r,"f")?this.cleanupCallback():n(this,a,l,"f"));const o=e.message;if(l==t(this,r,"f")){for(t(this,i,"f").call(this,o),n(this,r,t(this,r,"f")+1,"f");t(this,r,"f")in t(this,s,"f");){const e=t(this,s,"f")[t(this,r,"f")];t(this,i,"f").call(this,e),delete t(this,s,"f")[t(this,r,"f")],n(this,r,t(this,r,"f")+1,"f")}t(this,r,"f")===t(this,a,"f")&&this.cleanupCallback()}else t(this,s,"f")[l]=o}))}cleanupCallback(){Reflect.deleteProperty(window,`_${this.id}`)}set onmessage(e){n(this,i,e,"f")}get onmessage(){return t(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,t,n){this.plugin=e,this.event=t,this.channelId=n}async unregister(){return h(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function h(e,t={},n){return window.__TAURI_INTERNALS__.invoke(e,t,n)}class p{get rid(){return t(this,l,"f")}constructor(e){l.set(this,void 0),n(this,l,e,"f")}async close(){return h("plugin:resources|close",{rid:this.rid})}}l=new WeakMap;var w=Object.freeze({__proto__:null,Channel:c,PluginListener:d,Resource:p,SERIALIZE_TO_IPC_FN:o,addPluginListener:async function(e,t,n){const i=new c(n);return h(`plugin:${e}|registerListener`,{event:t,handler:i}).then((()=>new d(e,t,i.id)))},checkPermissions:async function(e){return h(`plugin:${e}|check_permissions`)},convertFileSrc:function(e,t="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,t)},invoke:h,isTauri:function(){return!!(globalThis||window).isTauri},requestPermissions:async function(e){return h(`plugin:${e}|request_permissions`)},transformCallback:u});class y extends p{constructor(e){super(e)}static async new(e,t,n){return h("plugin:image|new",{rgba:_(e),width:t,height:n}).then((e=>new y(e)))}static async fromBytes(e){return h("plugin:image|from_bytes",{bytes:_(e)}).then((e=>new y(e)))}static async fromPath(e){return h("plugin:image|from_path",{path:e}).then((e=>new y(e)))}async rgba(){return h("plugin:image|rgba",{rid:this.rid}).then((e=>new Uint8Array(e)))}async size(){return h("plugin:image|size",{rid:this.rid})}}function _(e){return null==e?null:"string"==typeof e?e:e instanceof y?e.rid:e}var g=Object.freeze({__proto__:null,Image:y,transformImage:_});var b=Object.freeze({__proto__:null,defaultWindowIcon:async function(){return h("plugin:app|default_window_icon").then((e=>e?new y(e):null))},fetchDataStoreIdentifiers:async function(){return h("plugin:app|fetch_data_store_identifiers")},getIdentifier:async function(){return h("plugin:app|identifier")},getName:async function(){return h("plugin:app|name")},getTauriVersion:async function(){return h("plugin:app|tauri_version")},getVersion:async function(){return h("plugin:app|version")},hide:async function(){return h("plugin:app|app_hide")},removeDataStore:async function(e){return h("plugin:app|remove_data_store",{uuid:e})},setDockVisibility:async function(e){return h("plugin:app|set_dock_visibility",{visible:e})},setTheme:async function(e){return h("plugin:app|set_app_theme",{theme:e})},show:async function(){return h("plugin:app|app_show")}});class m{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 m(this.width/e,this.height/e)}[o](){return{width:this.width,height:this.height}}toJSON(){return this[o]()}}class f{constructor(e){this.size=e}toLogical(e){return this.size instanceof m?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 k{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 A(this.x*e,this.y*e)}[o](){return{x:this.x,y:this.y}}toJSON(){return this[o]()}}class A{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 k(this.x/e,this.y/e)}[o](){return{x:this.x,y:this.y}}toJSON(){return this[o]()}}class D{constructor(e){this.position=e}toLogical(e){return this.position instanceof k?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof A?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,T=Object.freeze({__proto__:null,LogicalPosition:k,LogicalSize:m,PhysicalPosition:A,PhysicalSize:v,Position:D,Size:f});async function I(e,t){await h("plugin:event|unlisten",{event:e,eventId:t})}async function S(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 h("plugin:event|listen",{event:e,target:r,handler:u(t)}).then((t=>async()=>I(e,t)))}async function R(e,t,n){return S(e,(n=>{I(e,n.id),t(n)}),n)}async function L(e,t){await h("plugin:event|emit",{event:e,payload:t})}async function C(e,t,n){const i="string"==typeof e?{kind:"AnyLabel",label:e}:e;await h("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_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,N,P,W=Object.freeze({__proto__:null,get TauriEvent(){return E},emit:L,emitTo:C,listen:S,once:R});function z(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:z(e)));else if("action"in e&&e.action){const t=new c;return t.onmessage=e.action,delete e.action,{...e,handler:t}}return e}async function O(e,t){const n=new c;if(t&&"object"==typeof t&&("action"in t&&t.action&&(n.onmessage=t.action,delete t.action),"item"in t&&t.item&&"object"==typeof t.item&&"About"in t.item&&t.item.About&&"object"==typeof t.item.About&&"icon"in t.item.About&&t.item.About.icon&&(t.item.About.icon=_(t.item.About.icon)),"icon"in t&&t.icon&&(t.icon=_(t.icon)),"items"in t&&t.items)){function i(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=_(e.item.About.icon)),"icon"in e&&e.icon&&(e.icon=_(e.icon)),"items"in e&&e.items&&(e.items=e.items.map(i)),z(e))}t.items=t.items.map(i)}return h("plugin:menu|new",{kind:e,options:t,handler:n})}class F extends p{get id(){return t(this,x,"f")}get kind(){return t(this,N,"f")}constructor(e,t,i){super(e),x.set(this,void 0),N.set(this,void 0),n(this,x,t,"f"),n(this,N,i,"f")}}x=new WeakMap,N=new WeakMap;class M extends F{constructor(e,t){super(e,t,"MenuItem")}static async new(e){return O("MenuItem",e).then((([e,t])=>new M(e,t)))}async text(){return h("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return h("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return h("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return h("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return h("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}}class U extends F{constructor(e,t){super(e,t,"Check")}static async new(e){return O("Check",e).then((([e,t])=>new U(e,t)))}async text(){return h("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return h("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return h("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return h("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return h("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async isChecked(){return h("plugin:menu|is_checked",{rid:this.rid})}async setChecked(e){return h("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 B extends F{constructor(e,t){super(e,t,"Icon")}static async new(e){return O("Icon",e).then((([e,t])=>new B(e,t)))}async text(){return h("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return h("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return h("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return h("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async setAccelerator(e){return h("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:e})}async setIcon(e){return h("plugin:menu|set_icon",{rid:this.rid,icon:_(e)})}}class j extends F{constructor(e,t){super(e,t,"Predefined")}static async new(e){return O("Predefined",e).then((([e,t])=>new j(e,t)))}async text(){return h("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return h("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}}function V([e,t,n]){switch(n){case"Submenu":return new G(e,t);case"Predefined":return new j(e,t);case"Check":return new U(e,t);case"Icon":return new B(e,t);default:return new M(e,t)}}class G extends F{constructor(e,t){super(e,t,"Submenu")}static async new(e){return O("Submenu",e).then((([e,t])=>new G(e,t)))}async text(){return h("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(e){return h("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:e})}async isEnabled(){return h("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(e){return h("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:e})}async append(e){return h("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 h("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 h("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 h("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return h("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(V)}async items(){return h("plugin:menu|items",{rid:this.rid,kind:this.kind}).then((e=>e.map(V)))}async get(e){return h("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then((e=>e?V(e):null))}async popup(e,t){var n;return h("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:null!==(n=null==t?void 0:t.label)&&void 0!==n?n:null,at:e instanceof D?e:e?new D(e):null})}async setAsWindowsMenuForNSApp(){return h("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return h("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}}class H extends F{constructor(e,t){super(e,t,"Menu")}static async new(e){return O("Menu",e).then((([e,t])=>new H(e,t)))}static async default(){return h("plugin:menu|create_default").then((([e,t])=>new H(e,t)))}async append(e){return h("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 h("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 h("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 h("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[e.rid,e.kind]})}async removeAt(e){return h("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:e}).then(V)}async items(){return h("plugin:menu|items",{rid:this.rid,kind:this.kind}).then((e=>e.map(V)))}async get(e){return h("plugin:menu|get",{rid:this.rid,kind:this.kind,id:e}).then((e=>e?V(e):null))}async popup(e,t){var n;return h("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:null!==(n=null==t?void 0:t.label)&&void 0!==n?n:null,at:e instanceof D?e:e?new D(e):null})}async setAsAppMenu(){return h("plugin:menu|set_as_app_menu",{rid:this.rid}).then((e=>e?new H(e[0],e[1]):null))}async setAsWindowMenu(e){var t;return h("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 H(e[0],e[1]):null))}}var $=Object.freeze({__proto__:null,CheckMenuItem:U,IconMenuItem:B,Menu:H,MenuItem:M,get NativeIcon(){return P},PredefinedMenuItem:j,Submenu:G,itemFromKind:V});function q(){var e;window.__TAURI_INTERNALS__=null!==(e=window.__TAURI_INTERNALS__)&&void 0!==e?e:{}}var J,Q=Object.freeze({__proto__:null,clearMocks:function(){var e,t,n;"object"==typeof window.__TAURI_INTERNALS__&&((null===(e=window.__TAURI_INTERNALS__)||void 0===e?void 0:e.convertFileSrc)&&delete window.__TAURI_INTERNALS__.convertFileSrc,(null===(t=window.__TAURI_INTERNALS__)||void 0===t?void 0:t.invoke)&&delete window.__TAURI_INTERNALS__.invoke,(null===(n=window.__TAURI_INTERNALS__)||void 0===n?void 0:n.metadata)&&delete window.__TAURI_INTERNALS__.metadata)},mockConvertFileSrc:function(e){q(),window.__TAURI_INTERNALS__.convertFileSrc=function(t,n="asset"){const i=encodeURIComponent(t);return"windows"===e?`http://${n}.localhost/${i}`:`${n}://localhost/${i}`}},mockIPC:function(e){q(),window.__TAURI_INTERNALS__.transformCallback=function(e,t=!1){const n=window.crypto.getRandomValues(new Uint32Array(1))[0],i=`_${n}`;return Object.defineProperty(window,i,{value:n=>(t&&Reflect.deleteProperty(window,i),e&&e(n)),writable:!1,configurable:!0}),n},window.__TAURI_INTERNALS__.invoke=async function(t,n,i){return e(t,n)}},mockWindows:function(e,...t){q(),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"}(J||(J={}));var Z=Object.freeze({__proto__:null,get BaseDirectory(){return J},appCacheDir:async function(){return h("plugin:path|resolve_directory",{directory:J.AppCache})},appConfigDir:async function(){return h("plugin:path|resolve_directory",{directory:J.AppConfig})},appDataDir:async function(){return h("plugin:path|resolve_directory",{directory:J.AppData})},appLocalDataDir:async function(){return h("plugin:path|resolve_directory",{directory:J.AppLocalData})},appLogDir:async function(){return h("plugin:path|resolve_directory",{directory:J.AppLog})},audioDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Audio})},basename:async function(e,t){return h("plugin:path|basename",{path:e,ext:t})},cacheDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Cache})},configDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Config})},dataDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Data})},delimiter:function(){return window.__TAURI_INTERNALS__.plugins.path.delimiter},desktopDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Desktop})},dirname:async function(e){return h("plugin:path|dirname",{path:e})},documentDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Document})},downloadDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Download})},executableDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Executable})},extname:async function(e){return h("plugin:path|extname",{path:e})},fontDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Font})},homeDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Home})},isAbsolute:async function(e){return h("plugin:path|is_absolute",{path:e})},join:async function(...e){return h("plugin:path|join",{paths:e})},localDataDir:async function(){return h("plugin:path|resolve_directory",{directory:J.LocalData})},normalize:async function(e){return h("plugin:path|normalize",{path:e})},pictureDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Picture})},publicDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Public})},resolve:async function(...e){return h("plugin:path|resolve",{paths:e})},resolveResource:async function(e){return h("plugin:path|resolve_directory",{directory:J.Resource,path:e})},resourceDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Resource})},runtimeDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Runtime})},sep:function(){return window.__TAURI_INTERNALS__.plugins.path.sep},tempDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Temp})},templateDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Template})},videoDir:async function(){return h("plugin:path|resolve_directory",{directory:J.Video})}});class K extends p{constructor(e,t){super(e),this.id=t}static async getById(e){return h("plugin:tray|get_by_id",{id:e}).then((t=>t?new K(t,e):null))}static async removeById(e){return h("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=_(e.icon));const t=new c;if(null==e?void 0:e.action){const n=e.action;t.onmessage=e=>n(function(e){const t=e;return t.position=new A(e.position),t.rect.position=new A(e.rect.position),t.rect.size=new v(e.rect.size),t}(e)),delete e.action}return h("plugin:tray|new",{options:null!=e?e:{},handler:t}).then((([e,t])=>new K(e,t)))}async setIcon(e){let t=null;return e&&(t=_(e)),h("plugin:tray|set_icon",{rid:this.rid,icon:t})}async setMenu(e){return e&&(e=[e.rid,e.kind]),h("plugin:tray|set_menu",{rid:this.rid,menu:e})}async setTooltip(e){return h("plugin:tray|set_tooltip",{rid:this.rid,tooltip:e})}async setTitle(e){return h("plugin:tray|set_title",{rid:this.rid,title:e})}async setVisible(e){return h("plugin:tray|set_visible",{rid:this.rid,visible:e})}async setTempDirPath(e){return h("plugin:tray|set_temp_dir_path",{rid:this.rid,path:e})}async setIconAsTemplate(e){return h("plugin:tray|set_icon_as_template",{rid:this.rid,asTemplate:e})}async setMenuOnLeftClick(e){return h("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}async setShowMenuOnLeftClick(e){return h("plugin:tray|set_show_menu_on_left_click",{rid:this.rid,onLeft:e})}}var Y,X,ee=Object.freeze({__proto__:null,TrayIcon:K});!function(e){e[e.Critical=1]="Critical",e[e.Informational=2]="Informational"}(Y||(Y={}));class te{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}function ne(){return new se(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function ie(){return h("plugin:window|get_all_windows").then((e=>e.map((e=>new se(e,{skip:!0})))))}!function(e){e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error"}(X||(X={}));const re=["tauri://created","tauri://error"];class se{constructor(e,t={}){var n;this.label=e,this.listeners=Object.create(null),(null==t?void 0:t.skip)||h("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 async getByLabel(e){var t;return null!==(t=(await ie()).find((t=>t.label===e)))&&void 0!==t?t:null}static getCurrent(){return ne()}static async getAll(){return ie()}static async getFocusedWindow(){for(const e of await ie())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)}:S(e,t,{target:{kind:"Window",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)}:R(e,t,{target:{kind:"Window",label:this.label}})}async emit(e,t){if(!re.includes(e))return L(e,t);for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:t})}async emitTo(e,t,n){if(!re.includes(t))return C(e,t,n);for(const e of this.listeners[t]||[])e({event:t,id:-1,payload:n})}_handleTauriEvent(e,t){return!!re.includes(e)&&(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0)}async scaleFactor(){return h("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return h("plugin:window|inner_position",{label:this.label}).then((e=>new A(e)))}async outerPosition(){return h("plugin:window|outer_position",{label:this.label}).then((e=>new A(e)))}async innerSize(){return h("plugin:window|inner_size",{label:this.label}).then((e=>new v(e)))}async outerSize(){return h("plugin:window|outer_size",{label:this.label}).then((e=>new v(e)))}async isFullscreen(){return h("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return h("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return h("plugin:window|is_maximized",{label:this.label})}async isFocused(){return h("plugin:window|is_focused",{label:this.label})}async isDecorated(){return h("plugin:window|is_decorated",{label:this.label})}async isResizable(){return h("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return h("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return h("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return h("plugin:window|is_closable",{label:this.label})}async isVisible(){return h("plugin:window|is_visible",{label:this.label})}async title(){return h("plugin:window|title",{label:this.label})}async theme(){return h("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return h("plugin:window|is_always_on_top",{label:this.label})}async center(){return h("plugin:window|center",{label:this.label})}async requestUserAttention(e){let t=null;return e&&(t=e===Y.Critical?{type:"Critical"}:{type:"Informational"}),h("plugin:window|request_user_attention",{label:this.label,value:t})}async setResizable(e){return h("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return h("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return h("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return h("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return h("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return h("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return h("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return h("plugin:window|maximize",{label:this.label})}async unmaximize(){return h("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return h("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return h("plugin:window|minimize",{label:this.label})}async unminimize(){return h("plugin:window|unminimize",{label:this.label})}async show(){return h("plugin:window|show",{label:this.label})}async hide(){return h("plugin:window|hide",{label:this.label})}async close(){return h("plugin:window|close",{label:this.label})}async destroy(){return h("plugin:window|destroy",{label:this.label})}async setDecorations(e){return h("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return h("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return h("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return h("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return h("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return h("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return h("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return h("plugin:window|set_size",{label:this.label,value:e instanceof f?e:new f(e)})}async setMinSize(e){return h("plugin:window|set_min_size",{label:this.label,value:e instanceof f?e:e?new f(e):null})}async setMaxSize(e){return h("plugin:window|set_max_size",{label:this.label,value:e instanceof f?e:e?new f(e):null})}async setSizeConstraints(e){function t(e){return e?{Logical:e}:null}return h("plugin:window|set_size_constraints",{label:this.label,value:{minWidth:t(null==e?void 0:e.minWidth),minHeight:t(null==e?void 0:e.minHeight),maxWidth:t(null==e?void 0:e.maxWidth),maxHeight:t(null==e?void 0:e.maxHeight)}})}async setPosition(e){return h("plugin:window|set_position",{label:this.label,value:e instanceof D?e:new D(e)})}async setFullscreen(e){return h("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return h("plugin:window|set_focus",{label:this.label})}async setIcon(e){return h("plugin:window|set_icon",{label:this.label,value:_(e)})}async setSkipTaskbar(e){return h("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return h("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return h("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return h("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return h("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return h("plugin:window|set_cursor_position",{label:this.label,value:e instanceof D?e:new D(e)})}async setIgnoreCursorEvents(e){return h("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return h("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return h("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return h("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return h("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return h("plugin:window|set_overlay_icon",{label:this.label,value:e?_(e):void 0})}async setProgressBar(e){return h("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return h("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return h("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return h("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(E.WINDOW_RESIZED,(t=>{t.payload=new v(t.payload),e(t)}))}async onMoved(e){return this.listen(E.WINDOW_MOVED,(t=>{t.payload=new A(t.payload),e(t)}))}async onCloseRequested(e){return this.listen(E.WINDOW_CLOSE_REQUESTED,(async t=>{const n=new te(t);await e(n),n.isPreventDefault()||await this.destroy()}))}async onDragDropEvent(e){const t=await this.listen(E.DRAG_ENTER,(t=>{e({...t,payload:{type:"enter",paths:t.payload.paths,position:new A(t.payload.position)}})})),n=await this.listen(E.DRAG_OVER,(t=>{e({...t,payload:{type:"over",position:new A(t.payload.position)}})})),i=await this.listen(E.DRAG_DROP,(t=>{e({...t,payload:{type:"drop",paths:t.payload.paths,position:new A(t.payload.position)}})})),r=await this.listen(E.DRAG_LEAVE,(t=>{e({...t,payload:{type:"leave"}})}));return()=>{t(),i(),n(),r()}}async onFocusChanged(e){const t=await this.listen(E.WINDOW_FOCUS,(t=>{e({...t,payload:!0})})),n=await this.listen(E.WINDOW_BLUR,(t=>{e({...t,payload:!1})}));return()=>{t(),n()}}async onScaleChanged(e){return this.listen(E.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(E.WINDOW_THEME_CHANGED,e)}}var ae,le,oe;function ue(e){return null===e?null:{name:e.name,scaleFactor:e.scaleFactor,position:new A(e.position),size:new v(e.size)}}!function(e){e.Disabled="disabled",e.Throttle="throttle",e.Suspend="suspend"}(ae||(ae={})),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"}(le||(le={})),function(e){e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive"}(oe||(oe={}));var ce=Object.freeze({__proto__:null,CloseRequestedEvent:te,get Effect(){return le},get EffectState(){return oe},LogicalPosition:k,LogicalSize:m,PhysicalPosition:A,PhysicalSize:v,get ProgressBarStatus(){return X},get UserAttentionType(){return Y},Window:se,availableMonitors:async function(){return h("plugin:window|available_monitors").then((e=>e.map(ue)))},currentMonitor:async function(){return h("plugin:window|current_monitor").then(ue)},cursorPosition:async function(){return h("plugin:window|cursor_position").then((e=>new A(e)))},getAllWindows:ie,getCurrentWindow:ne,monitorFromPoint:async function(e,t){return h("plugin:window|monitor_from_point",{x:e,y:t}).then(ue)},primaryMonitor:async function(){return h("plugin:window|primary_monitor").then(ue)}});function de(){return new we(ne(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function he(){return h("plugin:webview|get_all_webviews").then((e=>e.map((e=>new we(new se(e.windowLabel,{skip:!0}),e.label,{skip:!0})))))}const pe=["tauri://created","tauri://error"];class we{constructor(e,t,n){this.window=e,this.label=t,this.listeners=Object.create(null),(null==n?void 0:n.skip)||h("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 async getByLabel(e){var t;return null!==(t=(await he()).find((t=>t.label===e)))&&void 0!==t?t:null}static getCurrent(){return de()}static async getAll(){return he()}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)}:S(e,t,{target:{kind:"Webview",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)}:R(e,t,{target:{kind:"Webview",label:this.label}})}async emit(e,t){if(!pe.includes(e))return L(e,t);for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:t})}async emitTo(e,t,n){if(!pe.includes(t))return C(e,t,n);for(const e of this.listeners[t]||[])e({event:t,id:-1,payload:n})}_handleTauriEvent(e,t){return!!pe.includes(e)&&(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0)}async position(){return h("plugin:webview|webview_position",{label:this.label}).then((e=>new A(e)))}async size(){return h("plugin:webview|webview_size",{label:this.label}).then((e=>new v(e)))}async close(){return h("plugin:webview|webview_close",{label:this.label})}async setSize(e){return h("plugin:webview|set_webview_size",{label:this.label,value:e instanceof f?e:new f(e)})}async setPosition(e){return h("plugin:webview|set_webview_position",{label:this.label,value:e instanceof D?e:new D(e)})}async setFocus(){return h("plugin:webview|set_webview_focus",{label:this.label})}async hide(){return h("plugin:webview|webview_hide",{label:this.label})}async show(){return h("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return h("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return h("plugin:webview|reparent",{label:this.label,window:"string"==typeof e?e:e.label})}async clearAllBrowsingData(){return h("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return h("plugin:webview|set_webview_background_color",{color:e})}async onDragDropEvent(e){const t=await this.listen(E.DRAG_ENTER,(t=>{e({...t,payload:{type:"enter",paths:t.payload.paths,position:new A(t.payload.position)}})})),n=await this.listen(E.DRAG_OVER,(t=>{e({...t,payload:{type:"over",position:new A(t.payload.position)}})})),i=await this.listen(E.DRAG_DROP,(t=>{e({...t,payload:{type:"drop",paths:t.payload.paths,position:new A(t.payload.position)}})})),r=await this.listen(E.DRAG_LEAVE,(t=>{e({...t,payload:{type:"leave"}})}));return()=>{t(),i(),n(),r()}}}var ye,_e,ge=Object.freeze({__proto__:null,Webview:we,getAllWebviews:he,getCurrentWebview:de});function be(){const e=de();return new ve(e.label,{skip:!0})}async function me(){return h("plugin:window|get_all_windows").then((e=>e.map((e=>new ve(e,{skip:!0})))))}class ve{constructor(e,t={}){var n;this.label=e,this.listeners=Object.create(null),(null==t?void 0:t.skip)||h("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 async getByLabel(e){var t;const n=null!==(t=(await me()).find((t=>t.label===e)))&&void 0!==t?t:null;return n?new ve(n.label,{skip:!0}):null}static getCurrent(){return be()}static async getAll(){return me()}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)}:S(e,t,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{const n=this.listeners[e];n.splice(n.indexOf(t),1)}:R(e,t,{target:{kind:"WebviewWindow",label:this.label}})}async setBackgroundColor(e){return h("plugin:window|set_background_color",{color:e}).then((()=>h("plugin:webview|set_webview_background_color",{color:e})))}}ye=ve,_e=[se,we],(Array.isArray(_e)?_e:[_e]).forEach((e=>{Object.getOwnPropertyNames(e.prototype).forEach((t=>{var n;"object"==typeof ye.prototype&&ye.prototype&&t in ye.prototype||Object.defineProperty(ye.prototype,t,null!==(n=Object.getOwnPropertyDescriptor(e.prototype,t))&&void 0!==n?n:Object.create(null))}))}));var fe=Object.freeze({__proto__:null,WebviewWindow:ve,getAllWebviewWindows:me,getCurrentWebviewWindow:be});return e.app=b,e.core=w,e.dpi=T,e.event=W,e.image=g,e.menu=$,e.mocks=Q,e.path=Z,e.tray=ee,e.webview=ge,e.webviewWindow=fe,e.window=ce,e}({});window.__TAURI__=__TAURI_IIFE__; diff --git a/packages/api/src/core.ts b/packages/api/src/core.ts index d0ae8521f..334ffe1d3 100644 --- a/packages/api/src/core.ts +++ b/packages/api/src/core.ts @@ -325,7 +325,8 @@ export class Resource { } function isTauri(): boolean { - return 'isTauri' in window && !!window.isTauri + // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-member-access + return !!((globalThis as any) || window).isTauri } export type { InvokeArgs, InvokeOptions }