tauri-plugin-context-menu 0.6.1

Handle native Context Menu in Tauri
Documentation
1
2
3
4
5
6
7
8
var $e=Object.defineProperty,n=(e,t)=>{for(var s in t)$e(e,s,{get:t[s],enumerable:!0})};var S={};n(S,{convertFileSrc:()=>Ye,invoke:()=>p,transformCallback:()=>u});function Je(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function u(e,t=!1){let s=Je(),r=`_${s}`;return Object.defineProperty(window,r,{value:i=>(t&&Reflect.deleteProperty(window,r),e?.(i)),writable:!1,configurable:!0}),s}async function p(e,t={}){return new Promise((s,r)=>{let i=u(o=>{s(o),Reflect.deleteProperty(window,`_${l}`)},!0),l=u(o=>{r(o),Reflect.deleteProperty(window,`_${i}`)},!0);window.__TAURI_IPC__({cmd:e,callback:i,error:l,...t})})}function Ye(e,t="asset"){return window.__TAURI__.convertFileSrc(e,t)}async function a(e){return p("tauri",e)}var F={};n(F,{TauriEvent:()=>A,emit:()=>h,listen:()=>c,once:()=>_});async function O(e,t){return a({__tauriModule:"Event",message:{cmd:"unlisten",event:e,eventId:t}})}async function D(e,t,s){await a({__tauriModule:"Event",message:{cmd:"emit",event:e,windowLabel:t,payload:s}})}async function f(e,t,s){return a({__tauriModule:"Event",message:{cmd:"listen",event:e,windowLabel:t,handler:u(s)}}).then(r=>async()=>O(e,r))}async function P(e,t,s){return f(e,t,r=>{s(r),O(e,r.id).catch(()=>{})})}var A=(e=>(e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_CREATED="tauri://window-created",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_FILE_DROP="tauri://file-drop",e.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",e.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",e.MENU="tauri://menu",e.CHECK_UPDATE="tauri://update",e.UPDATE_AVAILABLE="tauri://update-available",e.INSTALL_UPDATE="tauri://update-install",e.STATUS_UPDATE="tauri://update-status",e.DOWNLOAD_PROGRESS="tauri://update-download-progress",e))(A||{});async function c(e,t){return f(e,null,t)}async function _(e,t){return P(e,null,t)}async function h(e,t){return D(e,void 0,t)}var R={};n(R,{checkUpdate:()=>Qe,installUpdate:()=>Ke,onUpdaterEvent:()=>x});async function x(e){return c("tauri://update-status",t=>{e(t?.payload)})}async function Ke(){let e;function t(){e&&e(),e=void 0}return new Promise((s,r)=>{function i(l){if(l.error){t(),r(l.error);return}l.status==="DONE"&&(t(),s())}x(i).then(l=>{e=l}).catch(l=>{throw t(),l}),h("tauri://update-install").catch(l=>{throw t(),l})})}async function Qe(){let e;function t(){e&&e(),e=void 0}return new Promise((s,r)=>{function i(o){t(),s({manifest:o,shouldUpdate:!0})}function l(o){if(o.error){t(),r(o.error);return}o.status==="UPTODATE"&&(t(),s({shouldUpdate:!1}))}_("tauri://update-available",o=>{i(o?.payload)}).catch(o=>{throw t(),o}),x(l).then(o=>{e=o}).catch(o=>{throw t(),o}),h("tauri://update").catch(o=>{throw t(),o})})}var k={};n(k,{CloseRequestedEvent:()=>H,LogicalPosition:()=>U,LogicalSize:()=>N,PhysicalPosition:()=>w,PhysicalSize:()=>b,UserAttentionType:()=>j,WebviewWindow:()=>d,WebviewWindowHandle:()=>q,WindowManager:()=>B,appWindow:()=>E,availableMonitors:()=>tt,currentMonitor:()=>Xe,getAll:()=>W,getCurrent:()=>Ze,primaryMonitor:()=>et});var N=class{constructor(e,t){this.type="Logical",this.width=e,this.height=t}},b=class{constructor(e,t){this.type="Physical",this.width=e,this.height=t}toLogical(e){return new N(this.width/e,this.height/e)}},U=class{constructor(e,t){this.type="Logical",this.x=e,this.y=t}},w=class{constructor(e,t){this.type="Physical",this.x=e,this.y=t}toLogical(e){return new U(this.x/e,this.y/e)}},j=(e=>(e[e.Critical=1]="Critical",e[e.Informational=2]="Informational",e))(j||{});function Ze(){return new d(window.__TAURI_METADATA__.__currentWindow.label,{skip:!0})}function W(){return window.__TAURI_METADATA__.__windows.map(e=>new d(e.label,{skip:!0}))}var I=["tauri://created","tauri://error"],q=class{constructor(e){this.label=e,this.listeners=Object.create(null)}async listen(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let s=this.listeners[e];s.splice(s.indexOf(t),1)}):f(e,this.label,t)}async once(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let s=this.listeners[e];s.splice(s.indexOf(t),1)}):P(e,this.label,t)}async emit(e,t){if(I.includes(e)){for(let s of this.listeners[e]||[])s({event:e,id:-1,windowLabel:this.label,payload:t});return Promise.resolve()}return D(e,this.label,t)}_handleTauriEvent(e,t){return I.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}},B=class extends q{async scaleFactor(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"scaleFactor"}}}})}async innerPosition(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"innerPosition"}}}}).then(({x:e,y:t})=>new w(e,t))}async outerPosition(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"outerPosition"}}}}).then(({x:e,y:t})=>new w(e,t))}async innerSize(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"innerSize"}}}}).then(({width:e,height:t})=>new b(e,t))}async outerSize(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"outerSize"}}}}).then(({width:e,height:t})=>new b(e,t))}async isFullscreen(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isFullscreen"}}}})}async isMinimized(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isMinimized"}}}})}async isMaximized(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isMaximized"}}}})}async isFocused(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isFocused"}}}})}async isDecorated(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isDecorated"}}}})}async isResizable(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isResizable"}}}})}async isMaximizable(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isMaximizable"}}}})}async isMinimizable(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isMinimizable"}}}})}async isClosable(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isClosable"}}}})}async isVisible(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"isVisible"}}}})}async title(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"title"}}}})}async theme(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"theme"}}}})}async center(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"center"}}}})}async requestUserAttention(e){let t=null;return e&&(e===1?t={type:"Critical"}:t={type:"Informational"}),a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"requestUserAttention",payload:t}}}})}async setResizable(e){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setResizable",payload:e}}}})}async setMaximizable(e){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setMaximizable",payload:e}}}})}async setMinimizable(e){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setMinimizable",payload:e}}}})}async setClosable(e){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setClosable",payload:e}}}})}async setTitle(e){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setTitle",payload:e}}}})}async maximize(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"maximize"}}}})}async unmaximize(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"unmaximize"}}}})}async toggleMaximize(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"toggleMaximize"}}}})}async minimize(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"minimize"}}}})}async unminimize(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"unminimize"}}}})}async show(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"show"}}}})}async hide(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"hide"}}}})}async close(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"close"}}}})}async setDecorations(e){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setDecorations",payload:e}}}})}async setAlwaysOnTop(e){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setAlwaysOnTop",payload:e}}}})}async setContentProtected(e){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setContentProtected",payload:e}}}})}async setSize(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setSize",payload:{type:e.type,data:{width:e.width,height:e.height}}}}}})}async setMinSize(e){if(e&&e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setMinSize",payload:e?{type:e.type,data:{width:e.width,height:e.height}}:null}}}})}async setMaxSize(e){if(e&&e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setMaxSize",payload:e?{type:e.type,data:{width:e.width,height:e.height}}:null}}}})}async setPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setPosition",payload:{type:e.type,data:{x:e.x,y:e.y}}}}}})}async setFullscreen(e){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setFullscreen",payload:e}}}})}async setFocus(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setFocus"}}}})}async setIcon(e){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setIcon",payload:{icon:typeof e=="string"?e:Array.from(e)}}}}})}async setSkipTaskbar(e){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setSkipTaskbar",payload:e}}}})}async setCursorGrab(e){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setCursorGrab",payload:e}}}})}async setCursorVisible(e){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setCursorVisible",payload:e}}}})}async setCursorIcon(e){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setCursorIcon",payload:e}}}})}async setCursorPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setCursorPosition",payload:{type:e.type,data:{x:e.x,y:e.y}}}}}})}async setIgnoreCursorEvents(e){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"setIgnoreCursorEvents",payload:e}}}})}async startDragging(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{label:this.label,cmd:{type:"startDragging"}}}})}async onResized(e){return this.listen("tauri://resize",t=>{t.payload=V(t.payload),e(t)})}async onMoved(e){return this.listen("tauri://move",t=>{t.payload=G(t.payload),e(t)})}async onCloseRequested(e){return this.listen("tauri://close-requested",t=>{let s=new H(t);Promise.resolve(e(s)).then(()=>{if(!s.isPreventDefault())return this.close()})})}async onFocusChanged(e){let t=await this.listen("tauri://focus",r=>{e({...r,payload:!0})}),s=await this.listen("tauri://blur",r=>{e({...r,payload:!1})});return()=>{t(),s()}}async onScaleChanged(e){return this.listen("tauri://scale-change",e)}async onMenuClicked(e){return this.listen("tauri://menu",e)}async onFileDropEvent(e){let t=await this.listen("tauri://file-drop",i=>{e({...i,payload:{type:"drop",paths:i.payload}})}),s=await this.listen("tauri://file-drop-hover",i=>{e({...i,payload:{type:"hover",paths:i.payload}})}),r=await this.listen("tauri://file-drop-cancelled",i=>{e({...i,payload:{type:"cancel"}})});return()=>{t(),s(),r()}}async onThemeChanged(e){return this.listen("tauri://theme-changed",e)}},H=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.windowLabel=e.windowLabel,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}},d=class extends B{constructor(e,t={}){super(e),t?.skip||a({__tauriModule:"Window",message:{cmd:"createWebview",data:{options:{label:e,...t}}}}).then(async()=>this.emit("tauri://created")).catch(async s=>this.emit("tauri://error",s))}static getByLabel(e){return W().some(t=>t.label===e)?new d(e,{skip:!0}):null}static async getFocusedWindow(){for(let e of W())if(await e.isFocused())return e;return null}},E;"__TAURI_METADATA__"in window?E=new d(window.__TAURI_METADATA__.__currentWindow.label,{skip:!0}):(console.warn(`Could not find "window.__TAURI_METADATA__". The "appWindow" value will reference the "main" window label.
Note that this is not an issue if running this frontend on a browser instead of a Tauri window.`),E=new d("main",{skip:!0}));function L(e){return e===null?null:{name:e.name,scaleFactor:e.scaleFactor,position:G(e.position),size:V(e.size)}}function G(e){return new w(e.x,e.y)}function V(e){return new b(e.width,e.height)}async function Xe(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{cmd:{type:"currentMonitor"}}}}).then(L)}async function et(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{cmd:{type:"primaryMonitor"}}}}).then(L)}async function tt(){return a({__tauriModule:"Window",message:{cmd:"manage",data:{cmd:{type:"availableMonitors"}}}}).then(e=>e.map(L))}var $={};n($,{isPermissionGranted:()=>at,requestPermission:()=>st,sendNotification:()=>rt});async function at(){return window.Notification.permission!=="default"?Promise.resolve(window.Notification.permission==="granted"):a({__tauriModule:"Notification",message:{cmd:"isNotificationPermissionGranted"}})}async function st(){return window.Notification.requestPermission()}function rt(e){typeof e=="string"?new window.Notification(e):new window.Notification(e.title,e)}function y(){return navigator.appVersion.includes("Win")}var J={};n(J,{EOL:()=>it,arch:()=>ut,locale:()=>dt,platform:()=>nt,tempdir:()=>ct,type:()=>lt,version:()=>ot});var it=y()?`\r
`:`
`;async function nt(){return a({__tauriModule:"Os",message:{cmd:"platform"}})}async function ot(){return a({__tauriModule:"Os",message:{cmd:"version"}})}async function lt(){return a({__tauriModule:"Os",message:{cmd:"osType"}})}async function ut(){return a({__tauriModule:"Os",message:{cmd:"arch"}})}async function ct(){return a({__tauriModule:"Os",message:{cmd:"tempdir"}})}async function dt(){return a({__tauriModule:"Os",message:{cmd:"locale"}})}var K={};n(K,{BaseDirectory:()=>m,Dir:()=>m,copyFile:()=>_t,createDir:()=>gt,exists:()=>Mt,readBinaryFile:()=>pt,readDir:()=>yt,readTextFile:()=>mt,removeDir:()=>ft,removeFile:()=>bt,renameFile:()=>wt,writeBinaryFile:()=>ht,writeFile:()=>Y,writeTextFile:()=>Y});var m=(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.Desktop=6]="Desktop",e[e.Document=7]="Document",e[e.Download=8]="Download",e[e.Executable=9]="Executable",e[e.Font=10]="Font",e[e.Home=11]="Home",e[e.Picture=12]="Picture",e[e.Public=13]="Public",e[e.Runtime=14]="Runtime",e[e.Template=15]="Template",e[e.Video=16]="Video",e[e.Resource=17]="Resource",e[e.App=18]="App",e[e.Log=19]="Log",e[e.Temp=20]="Temp",e[e.AppConfig=21]="AppConfig",e[e.AppData=22]="AppData",e[e.AppLocalData=23]="AppLocalData",e[e.AppCache=24]="AppCache",e[e.AppLog=25]="AppLog",e))(m||{});async function mt(e,t={}){return a({__tauriModule:"Fs",message:{cmd:"readTextFile",path:e,options:t}})}async function pt(e,t={}){let s=await a({__tauriModule:"Fs",message:{cmd:"readFile",path:e,options:t}});return Uint8Array.from(s)}async function Y(e,t,s){typeof s=="object"&&Object.freeze(s),typeof e=="object"&&Object.freeze(e);let r={path:"",contents:""},i=s;return typeof e=="string"?r.path=e:(r.path=e.path,r.contents=e.contents),typeof t=="string"?r.contents=t??"":i=t,a({__tauriModule:"Fs",message:{cmd:"writeFile",path:r.path,contents:Array.from(new TextEncoder().encode(r.contents)),options:i}})}async function ht(e,t,s){typeof s=="object"&&Object.freeze(s),typeof e=="object"&&Object.freeze(e);let r={path:"",contents:[]},i=s;return typeof e=="string"?r.path=e:(r.path=e.path,r.contents=e.contents),t&&"dir"in t?i=t:typeof e=="string"&&(r.contents=t??[]),a({__tauriModule:"Fs",message:{cmd:"writeFile",path:r.path,contents:Array.from(r.contents instanceof ArrayBuffer?new Uint8Array(r.contents):r.contents),options:i}})}async function yt(e,t={}){return a({__tauriModule:"Fs",message:{cmd:"readDir",path:e,options:t}})}async function gt(e,t={}){return a({__tauriModule:"Fs",message:{cmd:"createDir",path:e,options:t}})}async function ft(e,t={}){return a({__tauriModule:"Fs",message:{cmd:"removeDir",path:e,options:t}})}async function _t(e,t,s={}){return a({__tauriModule:"Fs",message:{cmd:"copyFile",source:e,destination:t,options:s}})}async function bt(e,t={}){return a({__tauriModule:"Fs",message:{cmd:"removeFile",path:e,options:t}})}async function wt(e,t,s={}){return a({__tauriModule:"Fs",message:{cmd:"renameFile",oldPath:e,newPath:t,options:s}})}async function Mt(e,t={}){return a({__tauriModule:"Fs",message:{cmd:"exists",path:e,options:t}})}var Q={};n(Q,{BaseDirectory:()=>m,appCacheDir:()=>te,appConfigDir:()=>C,appDataDir:()=>X,appDir:()=>Z,appLocalDataDir:()=>ee,appLogDir:()=>T,audioDir:()=>ae,basename:()=>We,cacheDir:()=>se,configDir:()=>re,dataDir:()=>ie,delimiter:()=>Me,desktopDir:()=>ne,dirname:()=>Ae,documentDir:()=>oe,downloadDir:()=>le,executableDir:()=>ue,extname:()=>xe,fontDir:()=>ce,homeDir:()=>de,isAbsolute:()=>Ee,join:()=>Pe,localDataDir:()=>me,logDir:()=>be,normalize:()=>De,pictureDir:()=>pe,publicDir:()=>he,resolve:()=>ve,resolveResource:()=>M,resourceDir:()=>ye,runtimeDir:()=>ge,sep:()=>we,templateDir:()=>fe,videoDir:()=>_e});async function Z(){return C()}async function C(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:21}})}async function X(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:22}})}async function ee(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:23}})}async function te(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:24}})}async function ae(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:1}})}async function se(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:2}})}async function re(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:3}})}async function ie(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:4}})}async function ne(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:6}})}async function oe(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:7}})}async function le(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:8}})}async function ue(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:9}})}async function ce(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:10}})}async function de(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:11}})}async function me(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:5}})}async function pe(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:12}})}async function he(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:13}})}async function ye(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:17}})}async function M(e){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:e,directory:17}})}async function ge(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:14}})}async function fe(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:15}})}async function _e(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:16}})}async function be(){return T()}async function T(){return a({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:25}})}var we=y()?"\\":"/",Me=y()?";":":";async function ve(...e){return a({__tauriModule:"Path",message:{cmd:"resolve",paths:e}})}async function De(e){return a({__tauriModule:"Path",message:{cmd:"normalize",path:e}})}async function Pe(...e){return a({__tauriModule:"Path",message:{cmd:"join",paths:e}})}async function Ae(e){return a({__tauriModule:"Path",message:{cmd:"dirname",path:e}})}async function xe(e){return a({__tauriModule:"Path",message:{cmd:"extname",path:e}})}async function We(e,t){return a({__tauriModule:"Path",message:{cmd:"basename",path:e,ext:t}})}async function Ee(e){return a({__tauriModule:"Path",message:{cmd:"isAbsolute",path:e}})}var Le={};n(Le,{exit:()=>vt,relaunch:()=>Dt});async function vt(e=0){return a({__tauriModule:"Process",message:{cmd:"exit",exitCode:e}})}async function Dt(){return a({__tauriModule:"Process",message:{cmd:"relaunch"}})}var Ce={};n(Ce,{Child:()=>Te,Command:()=>ze,EventEmitter:()=>v,open:()=>At});async function Pt(e,t,s=[],r){return typeof s=="object"&&Object.freeze(s),a({__tauriModule:"Shell",message:{cmd:"execute",program:t,args:s,options:r,onEventFn:u(e)}})}var v=class{constructor(){this.eventListeners=Object.create(null)}addListener(e,t){return this.on(e,t)}removeListener(e,t){return this.off(e,t)}on(e,t){return e in this.eventListeners?this.eventListeners[e].push(t):this.eventListeners[e]=[t],this}once(e,t){let s=(...r)=>{this.removeListener(e,s),t(...r)};return this.addListener(e,s)}off(e,t){return e in this.eventListeners&&(this.eventListeners[e]=this.eventListeners[e].filter(s=>s!==t)),this}removeAllListeners(e){return e?delete this.eventListeners[e]:this.eventListeners=Object.create(null),this}emit(e,...t){if(e in this.eventListeners){let s=this.eventListeners[e];for(let r of s)r(...t);return!0}return!1}listenerCount(e){return e in this.eventListeners?this.eventListeners[e].length:0}prependListener(e,t){return e in this.eventListeners?this.eventListeners[e].unshift(t):this.eventListeners[e]=[t],this}prependOnceListener(e,t){let s=(...r)=>{this.removeListener(e,s),t(...r)};return this.prependListener(e,s)}},Te=class{constructor(e){this.pid=e}async write(e){return a({__tauriModule:"Shell",message:{cmd:"stdinWrite",pid:this.pid,buffer:typeof e=="string"?e:Array.from(e)}})}async kill(){return a({__tauriModule:"Shell",message:{cmd:"killChild",pid:this.pid}})}},ze=class extends v{constructor(e,t=[],s){super(),this.stdout=new v,this.stderr=new v,this.program=e,this.args=typeof t=="string"?[t]:t,this.options=s??{}}static sidecar(e,t=[],s){let r=new ze(e,t,s);return r.options.sidecar=!0,r}async spawn(){return Pt(e=>{switch(e.event){case"Error":this.emit("error",e.payload);break;case"Terminated":this.emit("close",e.payload);break;case"Stdout":this.stdout.emit("data",e.payload);break;case"Stderr":this.stderr.emit("data",e.payload);break}},this.program,this.args,this.options).then(e=>new Te(e))}async execute(){return new Promise((e,t)=>{this.on("error",t);let s=[],r=[];this.stdout.on("data",i=>{s.push(i)}),this.stderr.on("data",i=>{r.push(i)}),this.on("close",i=>{e({code:i.code,signal:i.signal,stdout:s.join(`
`),stderr:r.join(`
`)})}),this.spawn().catch(t)})}};async function At(e,t){return a({__tauriModule:"Shell",message:{cmd:"open",path:e,with:t}})}var Se={};n(Se,{getName:()=>Wt,getTauriVersion:()=>Et,getVersion:()=>xt,hide:()=>Ct,show:()=>Lt});async function xt(){return a({__tauriModule:"App",message:{cmd:"getAppVersion"}})}async function Wt(){return a({__tauriModule:"App",message:{cmd:"getAppName"}})}async function Et(){return a({__tauriModule:"App",message:{cmd:"getTauriVersion"}})}async function Lt(){return a({__tauriModule:"App",message:{cmd:"show"}})}async function Ct(){return a({__tauriModule:"App",message:{cmd:"hide"}})}var Fe={};n(Fe,{getMatches:()=>Tt});async function Tt(){return a({__tauriModule:"Cli",message:{cmd:"cliMatches"}})}var Oe={};n(Oe,{readText:()=>St,writeText:()=>zt});async function zt(e){return a({__tauriModule:"Clipboard",message:{cmd:"writeText",data:e}})}async function St(){return a({__tauriModule:"Clipboard",message:{cmd:"readText",data:null}})}var Re={};n(Re,{ask:()=>It,confirm:()=>kt,message:()=>Rt,open:()=>Ft,save:()=>Ot});async function Ft(e={}){return typeof e=="object"&&Object.freeze(e),a({__tauriModule:"Dialog",message:{cmd:"openDialog",options:e}})}async function Ot(e={}){return typeof e=="object"&&Object.freeze(e),a({__tauriModule:"Dialog",message:{cmd:"saveDialog",options:e}})}async function Rt(e,t){let s=typeof t=="string"?{title:t}:t;return a({__tauriModule:"Dialog",message:{cmd:"messageDialog",message:e.toString(),title:s?.title?.toString(),type:s?.type,buttonLabel:s?.okLabel?.toString()}})}async function It(e,t){let s=typeof t=="string"?{title:t}:t;return a({__tauriModule:"Dialog",message:{cmd:"askDialog",message:e.toString(),title:s?.title?.toString(),type:s?.type,buttonLabels:[s?.okLabel?.toString()??"Yes",s?.cancelLabel?.toString()??"No"]}})}async function kt(e,t){let s=typeof t=="string"?{title:t}:t;return a({__tauriModule:"Dialog",message:{cmd:"confirmDialog",message:e.toString(),title:s?.title?.toString(),type:s?.type,buttonLabels:[s?.okLabel?.toString()??"Ok",s?.cancelLabel?.toString()??"Cancel"]}})}var Ie={};n(Ie,{isRegistered:()=>jt,register:()=>Nt,registerAll:()=>Ut,unregister:()=>qt,unregisterAll:()=>Bt});async function Nt(e,t){return a({__tauriModule:"GlobalShortcut",message:{cmd:"register",shortcut:e,handler:u(t)}})}async function Ut(e,t){return a({__tauriModule:"GlobalShortcut",message:{cmd:"registerAll",shortcuts:e,handler:u(t)}})}async function jt(e){return a({__tauriModule:"GlobalShortcut",message:{cmd:"isRegistered",shortcut:e}})}async function qt(e){return a({__tauriModule:"GlobalShortcut",message:{cmd:"unregister",shortcut:e}})}async function Bt(){return a({__tauriModule:"GlobalShortcut",message:{cmd:"unregisterAll"}})}var ke={};n(ke,{Body:()=>g,Client:()=>je,Response:()=>Ue,ResponseType:()=>Ne,fetch:()=>Gt,getClient:()=>qe});var Ne=(e=>(e[e.JSON=1]="JSON",e[e.Text=2]="Text",e[e.Binary=3]="Binary",e))(Ne||{});async function Ht(e){let t={},s=async(r,i)=>{if(i!==null){let l;typeof i=="string"?l=i:i instanceof Uint8Array||Array.isArray(i)?l=Array.from(i):i instanceof File?l={file:Array.from(new Uint8Array(await i.arrayBuffer())),mime:i.type,fileName:i.name}:typeof i.file=="string"?l={file:i.file,mime:i.mime,fileName:i.fileName}:l={file:Array.from(i.file),mime:i.mime,fileName:i.fileName},t[String(r)]=l}};if(e instanceof FormData)for(let[r,i]of e)await s(r,i);else for(let[r,i]of Object.entries(e))await s(r,i);return t}var g=class{constructor(e,t){this.type=e,this.payload=t}static form(e){return new g("Form",e)}static json(e){return new g("Json",e)}static text(e){return new g("Text",e)}static bytes(e){return new g("Bytes",Array.from(e instanceof ArrayBuffer?new Uint8Array(e):e))}},Ue=class{constructor(e){this.url=e.url,this.status=e.status,this.ok=this.status>=200&&this.status<300,this.headers=e.headers,this.rawHeaders=e.rawHeaders,this.data=e.data}},je=class{constructor(e){this.id=e}async drop(){return a({__tauriModule:"Http",message:{cmd:"dropClient",client:this.id}})}async request(e){let t=!e.responseType||e.responseType===1;return t&&(e.responseType=2),e.body?.type==="Form"&&(e.body.payload=await Ht(e.body.payload)),a({__tauriModule:"Http",message:{cmd:"httpRequest",client:this.id,options:e}}).then(s=>{let r=new Ue(s);if(t){try{r.data=JSON.parse(r.data)}catch(i){if(r.ok&&r.data==="")r.data={};else if(r.ok)throw Error(`Failed to parse response \`${r.data}\` as JSON: ${i};
              try setting the \`responseType\` option to \`ResponseType.Text\` or \`ResponseType.Binary\` if the API does not return a JSON response.`)}return r}return r})}async get(e,t){return this.request({method:"GET",url:e,...t})}async post(e,t,s){return this.request({method:"POST",url:e,body:t,...s})}async put(e,t,s){return this.request({method:"PUT",url:e,body:t,...s})}async patch(e,t){return this.request({method:"PATCH",url:e,...t})}async delete(e,t){return this.request({method:"DELETE",url:e,...t})}};async function qe(e){return a({__tauriModule:"Http",message:{cmd:"createClient",options:e}}).then(t=>new je(t))}var z=null;async function Gt(e,t){return z===null&&(z=await qe()),z.request({url:e,method:t?.method??"GET",...t})}var Be=p;var Yt="plugin:context_menu|show_context_menu";async function Hs(e){return await M(e)}async function He(e,t){let s=[],r=[...e.map(i=>({...i}))];for(let i=0;i<r.length;i++){let l=r[i].event;if(typeof l=="function"){let o=`${t}_context_menu_item_${i}`;s.push(await c(o,Ge=>{let Ve={...Ge,payload:e[i].payload};l(Ve)})),r[i].event=o,r[i].payload=void 0}if(e[i].subitems){let o=await He(e[i].subitems,`${t}_${i}`);s.push(...o.unlisteners),r[i].subitems=o.processed}}return{unlisteners:s,processed:r}}async function Kt(e){let{unlisteners:t,processed:s}=await He(e.items,"root"),r=await c("menu-did-close",()=>{t.forEach(i=>i()),t.length=0,r()});Be(Yt,{...e,items:s})}function Gs(e,t){window.addEventListener(e,async s=>{s.preventDefault(),typeof t=="function"&&(t=await t(s)),await Kt(t)})}export{Hs as assetToPath,Gs as onEventShowMenu,Kt as showMenu};
//# sourceMappingURL=index.js.map