github.com/secoba/wails/v2@v2.6.4/internal/frontend/runtime/runtime_prod_desktop.js (about)

     1  (()=>{var P=Object.defineProperty;var c=(e,n)=>{for(var o in n)P(e,o,{get:n[o],enumerable:!0})};var x={};c(x,{LogDebug:()=>G,LogError:()=>F,LogFatal:()=>J,LogInfo:()=>H,LogLevel:()=>j,LogPrint:()=>B,LogTrace:()=>A,LogWarning:()=>U,SetLogLevel:()=>N});function f(e,n){window.WailsInvoke("L"+e+n)}function A(e){f("T",e)}function B(e){f("P",e)}function G(e){f("D",e)}function H(e){f("I",e)}function U(e){f("W",e)}function F(e){f("E",e)}function J(e){f("F",e)}function N(e){f("S",e)}var j={TRACE:1,DEBUG:2,INFO:3,WARNING:4,ERROR:5};var v=class{constructor(n,o,t){this.eventName=n,this.maxCallbacks=t||-1,this.Callback=i=>(o.apply(null,i),this.maxCallbacks===-1?!1:(this.maxCallbacks-=1,this.maxCallbacks===0))}},a={};function p(e,n,o){a[e]=a[e]||[];let t=new v(e,n,o);return a[e].push(t),()=>V(t)}function y(e,n){return p(e,n,-1)}function C(e,n){return p(e,n,1)}function D(e){let n=e.name;if(a[n]){let o=a[n].slice();for(let t=a[n].length-1;t>=0;t-=1){let i=a[n][t],r=e.data;i.Callback(r)&&o.splice(t,1)}o.length===0?g(n):a[n]=o}}function T(e){let n;try{n=JSON.parse(e)}catch{let t="Invalid JSON passed to Notify: "+e;throw new Error(t)}D(n)}function O(e){let n={name:e,data:[].slice.apply(arguments).slice(1)};D(n),window.WailsInvoke("EE"+JSON.stringify(n))}function g(e){delete a[e],window.WailsInvoke("EX"+e)}function L(e,...n){g(e),n.length>0&&n.forEach(o=>{g(o)})}function V(e){let n=e.eventName;a[n]=a[n].filter(o=>o!==e),a[n].length===0&&g(n)}var u={};function X(){var e=new Uint32Array(1);return window.crypto.getRandomValues(e)[0]}function Y(){return Math.random()*9007199254740991}var W;window.crypto?W=X:W=Y;function s(e,n,o){return o==null&&(o=0),new Promise(function(t,i){var r;do r=e+"-"+W();while(u[r]);var l;o>0&&(l=setTimeout(function(){i(Error("Call to "+e+" timed out. Request ID: "+r))},o)),u[r]={timeoutHandle:l,reject:i,resolve:t};try{let d={name:e,args:n,callbackID:r};window.WailsInvoke("C"+JSON.stringify(d))}catch(d){console.error(d)}})}window.ObfuscatedCall=(e,n,o)=>(o==null&&(o=0),new Promise(function(t,i){var r;do r=e+"-"+W();while(u[r]);var l;o>0&&(l=setTimeout(function(){i(Error("Call to method "+e+" timed out. Request ID: "+r))},o)),u[r]={timeoutHandle:l,reject:i,resolve:t};try{let d={id:e,args:n,callbackID:r};window.WailsInvoke("c"+JSON.stringify(d))}catch(d){console.error(d)}}));function z(e){let n;try{n=JSON.parse(e)}catch(i){let r=`Invalid JSON passed to callback: ${i.message}. Message: ${e}`;throw runtime.LogDebug(r),new Error(r)}let o=n.callbackid,t=u[o];if(!t){let i=`Callback '${o}' not registered!!!`;throw console.error(i),new Error(i)}clearTimeout(t.timeoutHandle),delete u[o],n.error?t.reject(n.error):t.resolve(n.result)}window.go={};function M(e){try{e=JSON.parse(e)}catch(n){console.error(n)}window.go=window.go||{},Object.keys(e).forEach(n=>{window.go[n]=window.go[n]||{},Object.keys(e[n]).forEach(o=>{window.go[n][o]=window.go[n][o]||{},Object.keys(e[n][o]).forEach(t=>{window.go[n][o][t]=function(){let i=0;function r(){let l=[].slice.call(arguments);return s([n,o,t].join("."),l,i)}return r.setTimeout=function(l){i=l},r.getTimeout=function(){return i},r}()})})})}var h={};c(h,{WindowCenter:()=>_,WindowFullscreen:()=>ne,WindowGetPosition:()=>de,WindowGetSize:()=>re,WindowHide:()=>fe,WindowIsFullscreen:()=>te,WindowIsMaximised:()=>We,WindowIsMinimised:()=>ve,WindowIsNormal:()=>he,WindowMaximise:()=>ce,WindowMinimise:()=>me,WindowReload:()=>$,WindowReloadApp:()=>q,WindowSetAlwaysOnTop:()=>ae,WindowSetBackgroundColour:()=>ke,WindowSetDarkTheme:()=>K,WindowSetLightTheme:()=>Z,WindowSetMaxSize:()=>se,WindowSetMinSize:()=>le,WindowSetPosition:()=>we,WindowSetSize:()=>ie,WindowSetSystemDefaultTheme:()=>Q,WindowSetTitle:()=>ee,WindowShow:()=>ue,WindowToggleMaximise:()=>ge,WindowUnfullscreen:()=>oe,WindowUnmaximise:()=>pe,WindowUnminimise:()=>xe});function $(){window.location.reload()}function q(){window.WailsInvoke("WR")}function Q(){window.WailsInvoke("WASDT")}function Z(){window.WailsInvoke("WALT")}function K(){window.WailsInvoke("WADT")}function _(){window.WailsInvoke("Wc")}function ee(e){window.WailsInvoke("WT"+e)}function ne(){window.WailsInvoke("WF")}function oe(){window.WailsInvoke("Wf")}function te(){return s(":wails:WindowIsFullscreen")}function ie(e,n){window.WailsInvoke("Ws:"+e+":"+n)}function re(){return s(":wails:WindowGetSize")}function se(e,n){window.WailsInvoke("WZ:"+e+":"+n)}function le(e,n){window.WailsInvoke("Wz:"+e+":"+n)}function ae(e){window.WailsInvoke("WATP:"+(e?"1":"0"))}function we(e,n){window.WailsInvoke("Wp:"+e+":"+n)}function de(){return s(":wails:WindowGetPos")}function fe(){window.WailsInvoke("WH")}function ue(){window.WailsInvoke("WS")}function ce(){window.WailsInvoke("WM")}function ge(){window.WailsInvoke("Wt")}function pe(){window.WailsInvoke("WU")}function We(){return s(":wails:WindowIsMaximised")}function me(){window.WailsInvoke("Wm")}function xe(){window.WailsInvoke("Wu")}function ve(){return s(":wails:WindowIsMinimised")}function he(){return s(":wails:WindowIsNormal")}function ke(e,n,o,t){let i=JSON.stringify({r:e||0,g:n||0,b:o||0,a:t||255});window.WailsInvoke("Wr:"+i)}var k={};c(k,{ScreenGetAll:()=>Ie});function Ie(){return s(":wails:ScreenGetAll")}var I={};c(I,{BrowserOpenURL:()=>be});function be(e){window.WailsInvoke("BO:"+e)}var b={};c(b,{ClipboardGetText:()=>Ee,ClipboardSetText:()=>Se});function Se(e){return s(":wails:ClipboardSetText",[e])}function Ee(){return s(":wails:ClipboardGetText")}function R(e){let n=e.target;switch(window.getComputedStyle(n).getPropertyValue("--default-contextmenu").trim()){case"show":return;case"hide":e.preventDefault();return;default:if(n.isContentEditable)return;let i=window.getSelection(),r=i.toString().length>0;if(r)for(let l=0;l<i.rangeCount;l++){let S=i.getRangeAt(l).getClientRects();for(let m=0;m<S.length;m++){let E=S[m];if(document.elementFromPoint(E.left,E.top)===n)return}}if((n.tagName==="INPUT"||n.tagName==="TEXTAREA")&&(r||!n.readOnly&&!n.disabled))return;e.preventDefault()}}function Ce(){window.WailsInvoke("Q")}function De(){window.WailsInvoke("S")}function Te(){window.WailsInvoke("H")}function Oe(){return s(":wails:Environment")}window.runtime={...x,...h,...I,...k,...b,EventsOn:y,EventsOnce:C,EventsOnMultiple:p,EventsEmit:O,EventsOff:L,Environment:Oe,Show:De,Hide:Te,Quit:Ce};window.wails={Callback:z,EventsNotify:T,SetBindings:M,eventListeners:a,callbacks:u,flags:{disableScrollbarDrag:!1,disableDefaultContextMenu:!1,enableResize:!1,defaultCursor:null,borderThickness:6,shouldDrag:!1,deferDragToMouseMove:!0,cssDragProperty:"--wails-draggable",cssDragValue:"drag"}};window.wailsbindings&&(window.wails.SetBindings(window.wailsbindings),delete window.wails.SetBindings);delete window.wailsbindings;var Le=function(e){var n=window.getComputedStyle(e.target).getPropertyValue(window.wails.flags.cssDragProperty);return n&&(n=n.trim()),!(n!==window.wails.flags.cssDragValue||e.buttons!==1||e.detail!==1)};window.wails.setCSSDragProperties=function(e,n){window.wails.flags.cssDragProperty=e,window.wails.flags.cssDragValue=n};window.addEventListener("mousedown",e=>{if(window.wails.flags.resizeEdge){window.WailsInvoke("resize:"+window.wails.flags.resizeEdge),e.preventDefault();return}if(Le(e)){if(window.wails.flags.disableScrollbarDrag&&(e.offsetX>e.target.clientWidth||e.offsetY>e.target.clientHeight))return;window.wails.flags.deferDragToMouseMove?window.wails.flags.shouldDrag=!0:(e.preventDefault(),window.WailsInvoke("drag"));return}else window.wails.flags.shouldDrag=!1});window.addEventListener("mouseup",()=>{window.wails.flags.shouldDrag=!1});function w(e){document.documentElement.style.cursor=e||window.wails.flags.defaultCursor,window.wails.flags.resizeEdge=e}window.addEventListener("mousemove",function(e){if(window.wails.flags.shouldDrag&&(window.wails.flags.shouldDrag=!1,(e.buttons!==void 0?e.buttons:e.which)>0)){window.WailsInvoke("drag");return}if(!window.wails.flags.enableResize)return;window.wails.flags.defaultCursor==null&&(window.wails.flags.defaultCursor=document.documentElement.style.cursor),window.outerWidth-e.clientX<window.wails.flags.borderThickness&&window.outerHeight-e.clientY<window.wails.flags.borderThickness&&(document.documentElement.style.cursor="se-resize");let n=window.outerWidth-e.clientX<window.wails.flags.borderThickness,o=e.clientX<window.wails.flags.borderThickness,t=e.clientY<window.wails.flags.borderThickness,i=window.outerHeight-e.clientY<window.wails.flags.borderThickness;!o&&!n&&!t&&!i&&window.wails.flags.resizeEdge!==void 0?w():n&&i?w("se-resize"):o&&i?w("sw-resize"):o&&t?w("nw-resize"):t&&n?w("ne-resize"):o?w("w-resize"):t?w("n-resize"):i?w("s-resize"):n&&w("e-resize")});window.addEventListener("contextmenu",function(e){window.wails.flags.disableDefaultContextMenu?e.preventDefault():R(e)});window.WailsInvoke("runtime:ready");})();