-
Notifications
You must be signed in to change notification settings - Fork 288
/
api-iife.js
1 lines (1 loc) · 14.5 KB
/
api-iife.js
1
if("__TAURI__"in window){var __TAURI_PLUGIN_WINDOW_STATE__=function(e){"use strict";var t;"function"==typeof SuppressedError&&SuppressedError;const i="__TAURI_TO_IPC_KEY__";function n(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}async function a(e,t={},i){return window.__TAURI_INTERNALS__.invoke(e,t,i)}class s{get rid(){return function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}(this,t,"f")}constructor(e){t.set(this,void 0),function(e,t,i,n,a){if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");t.set(e,i)}(this,t,e)}async close(){return a("plugin:resources|close",{rid:this.rid})}}t=new WeakMap;class l{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 r(this.width*e,this.height*e)}[i](){return{width:this.width,height:this.height}}toJSON(){return this[i]()}}class r{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 l(this.width/e,this.height/e)}[i](){return{width:this.width,height:this.height}}toJSON(){return this[i]()}}class o{constructor(e){this.size=e}toLogical(e){return this.size instanceof l?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof r?this.size:this.size.toPhysical(e)}[i](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[i]()}}class u{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 c(this.x*e,this.y*e)}[i](){return{x:this.x,y:this.y}}toJSON(){return this[i]()}}class c{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 u(this.x/e,this.y/e)}[i](){return{x:this.x,y:this.y}}toJSON(){return this[i]()}}class h{constructor(e){this.position=e}toLogical(e){return this.position instanceof u?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof c?this.position:this.position.toPhysical(e)}[i](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[i]()}}var d,w,b;async function g(e,t){await a("plugin:event|unlisten",{event:e,eventId:t})}async function y(e,t,i){var s;const l="string"==typeof(null==i?void 0:i.target)?{kind:"AnyLabel",label:i.target}:null!==(s=null==i?void 0:i.target)&&void 0!==s?s:{kind:"Any"};return a("plugin:event|listen",{event:e,target:l,handler:n(t)}).then((t=>async()=>g(e,t)))}!function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"}(d||(d={}));class p extends s{constructor(e){super(e)}static async new(e,t,i){return a("plugin:image|new",{rgba:_(e),width:t,height:i}).then((e=>new p(e)))}static async fromBytes(e){return a("plugin:image|from_bytes",{bytes:_(e)}).then((e=>new p(e)))}static async fromPath(e){return a("plugin:image|from_path",{path:e}).then((e=>new p(e)))}async rgba(){return a("plugin:image|rgba",{rid:this.rid}).then((e=>new Uint8Array(e)))}async size(){return a("plugin:image|size",{rid:this.rid})}}function _(e){return null==e?null:"string"==typeof e?e:e instanceof p?e.rid:e}!function(e){e[e.Critical=1]="Critical",e[e.Informational=2]="Informational"}(w||(w={}));class v{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}function f(){return new D(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function m(){return a("plugin:window|get_all_windows").then((e=>e.map((e=>new D(e,{skip:!0})))))}!function(e){e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error"}(b||(b={}));const E=["tauri://created","tauri://error"];class D{constructor(e,t={}){var i;this.label=e,this.listeners=Object.create(null),(null==t?void 0:t.skip)||a("plugin:window|create",{options:{...t,parent:"string"==typeof t.parent?t.parent:null===(i=t.parent)||void 0===i?void 0:i.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 m()).find((t=>t.label===e)))&&void 0!==t?t:null}static getCurrent(){return f()}static async getAll(){return m()}static async getFocusedWindow(){for(const e of await m())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?()=>{const i=this.listeners[e];i.splice(i.indexOf(t),1)}:y(e,t,{target:{kind:"Window",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?()=>{const i=this.listeners[e];i.splice(i.indexOf(t),1)}:async function(e,t,i){return y(e,(i=>{g(e,i.id),t(i)}),i)}(e,t,{target:{kind:"Window",label:this.label}})}async emit(e,t){if(!E.includes(e))return async function(e,t){await a("plugin:event|emit",{event:e,payload:t})}(e,t);for(const i of this.listeners[e]||[])i({event:e,id:-1,payload:t})}async emitTo(e,t,i){if(!E.includes(t))return async function(e,t,i){const n="string"==typeof e?{kind:"AnyLabel",label:e}:e;await a("plugin:event|emit_to",{target:n,event:t,payload:i})}(e,t,i);for(const e of this.listeners[t]||[])e({event:t,id:-1,payload:i})}_handleTauriEvent(e,t){return!!E.includes(e)&&(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0)}async scaleFactor(){return a("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return a("plugin:window|inner_position",{label:this.label}).then((e=>new c(e)))}async outerPosition(){return a("plugin:window|outer_position",{label:this.label}).then((e=>new c(e)))}async innerSize(){return a("plugin:window|inner_size",{label:this.label}).then((e=>new r(e)))}async outerSize(){return a("plugin:window|outer_size",{label:this.label}).then((e=>new r(e)))}async isFullscreen(){return a("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return a("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return a("plugin:window|is_maximized",{label:this.label})}async isFocused(){return a("plugin:window|is_focused",{label:this.label})}async isDecorated(){return a("plugin:window|is_decorated",{label:this.label})}async isResizable(){return a("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return a("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return a("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return a("plugin:window|is_closable",{label:this.label})}async isVisible(){return a("plugin:window|is_visible",{label:this.label})}async title(){return a("plugin:window|title",{label:this.label})}async theme(){return a("plugin:window|theme",{label:this.label})}async center(){return a("plugin:window|center",{label:this.label})}async requestUserAttention(e){let t=null;return e&&(t=e===w.Critical?{type:"Critical"}:{type:"Informational"}),a("plugin:window|request_user_attention",{label:this.label,value:t})}async setResizable(e){return a("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return a("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return a("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return a("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return a("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return a("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return a("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return a("plugin:window|maximize",{label:this.label})}async unmaximize(){return a("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return a("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return a("plugin:window|minimize",{label:this.label})}async unminimize(){return a("plugin:window|unminimize",{label:this.label})}async show(){return a("plugin:window|show",{label:this.label})}async hide(){return a("plugin:window|hide",{label:this.label})}async close(){return a("plugin:window|close",{label:this.label})}async destroy(){return a("plugin:window|destroy",{label:this.label})}async setDecorations(e){return a("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return a("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return a("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return a("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return a("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return a("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return a("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return a("plugin:window|set_size",{label:this.label,value:e instanceof o?e:new o(e)})}async setMinSize(e){return a("plugin:window|set_min_size",{label:this.label,value:e instanceof o?e:e?new o(e):null})}async setMaxSize(e){return a("plugin:window|set_max_size",{label:this.label,value:e instanceof o?e:e?new o(e):null})}async setSizeConstraints(e){function t(e){return e?{Logical:e}:null}return a("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 a("plugin:window|set_position",{label:this.label,value:e instanceof h?e:new h(e)})}async setFullscreen(e){return a("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return a("plugin:window|set_focus",{label:this.label})}async setIcon(e){return a("plugin:window|set_icon",{label:this.label,value:_(e)})}async setSkipTaskbar(e){return a("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return a("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return a("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return a("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return a("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return a("plugin:window|set_cursor_position",{label:this.label,value:e instanceof h?e:new h(e)})}async setIgnoreCursorEvents(e){return a("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return a("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return a("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setProgressBar(e){return a("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return a("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return a("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return a("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(d.WINDOW_RESIZED,(t=>{t.payload=new r(t.payload),e(t)}))}async onMoved(e){return this.listen(d.WINDOW_MOVED,(t=>{t.payload=new c(t.payload),e(t)}))}async onCloseRequested(e){return this.listen(d.WINDOW_CLOSE_REQUESTED,(async t=>{const i=new v(t);await e(i),i.isPreventDefault()||await this.destroy()}))}async onDragDropEvent(e){const t=await this.listen(d.DRAG_ENTER,(t=>{e({...t,payload:{type:"enter",paths:t.payload.paths,position:new c(t.payload.position)}})})),i=await this.listen(d.DRAG_OVER,(t=>{e({...t,payload:{type:"over",position:new c(t.payload.position)}})})),n=await this.listen(d.DRAG_DROP,(t=>{e({...t,payload:{type:"drop",paths:t.payload.paths,position:new c(t.payload.position)}})})),a=await this.listen(d.DRAG_LEAVE,(t=>{e({...t,payload:{type:"leave"}})}));return()=>{t(),n(),i(),a()}}async onFocusChanged(e){const t=await this.listen(d.WINDOW_FOCUS,(t=>{e({...t,payload:!0})})),i=await this.listen(d.WINDOW_BLUR,(t=>{e({...t,payload:!1})}));return()=>{t(),i()}}async onScaleChanged(e){return this.listen(d.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(d.WINDOW_THEME_CHANGED,e)}}var I,S,W;async function z(e,t){await a("plugin:window-state|restore_state",{label:e,flags:t})}return 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"}(I||(I={})),function(e){e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive"}(S||(S={})),e.StateFlags=void 0,(W=e.StateFlags||(e.StateFlags={}))[W.SIZE=1]="SIZE",W[W.POSITION=2]="POSITION",W[W.MAXIMIZED=4]="MAXIMIZED",W[W.VISIBLE=8]="VISIBLE",W[W.DECORATIONS=16]="DECORATIONS",W[W.FULLSCREEN=32]="FULLSCREEN",W[W.ALL=63]="ALL",e.filename=async function(){return await a("plugin:window-state|filename")},e.restoreState=z,e.restoreStateCurrent=async function(e){await z(f().label,e)},e.saveWindowState=async function(e){await a("plugin:window-state|save_window_state",{flags:e})},e}({});Object.defineProperty(window.__TAURI__,"windowState",{value:__TAURI_PLUGIN_WINDOW_STATE__})}