mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 06:20:48 +08:00
2 lines
6.2 KiB
JavaScript
2 lines
6.2 KiB
JavaScript
(()=>{var m=Object.defineProperty;var D=e=>m(e,"__esModule",{value:!0});var W=(e,n)=>{D(e);for(var o in n)m(e,o,{get:n[o],enumerable:!0})};var g={};W(g,{LogDebug:()=>B,LogError:()=>J,LogFatal:()=>G,LogInfo:()=>A,LogLevel:()=>U,LogPrint:()=>R,LogTrace:()=>C,LogWarning:()=>H,SetLogLevel:()=>M});function w(e,n){window.WailsInvoke("L"+e+n)}function C(e){w("T",e)}function R(e){w("P",e)}function B(e){w("D",e)}function A(e){w("I",e)}function H(e){w("W",e)}function J(e){w("E",e)}function G(e){w("F",e)}function M(e){w("S",e)}var U={TRACE:1,DEBUG:2,INFO:3,WARNING:4,ERROR:5};var k=class{constructor(n,o){o=o||-1,this.Callback=i=>(n.apply(null,i),o===-1?!1:(o-=1,o===0))}},s={};function c(e,n,o){s[e]=s[e]||[];let i=new k(n,o);s[e].push(i)}function b(e,n){c(e,n,-1)}function E(e,n){c(e,n,1)}function I(e){let n=e.name;if(s[n]){let o=s[n].slice();for(let i=0;i<s[n].length;i+=1){let t=s[n][i],r=e.data;t.Callback(r)&&o.splice(i,1)}s[n]=o}}function h(e){let n;try{n=JSON.parse(e)}catch(o){let i="Invalid JSON passed to Notify: "+e;throw new Error(i)}I(n)}function S(e){let n={name:e,data:[].slice.apply(arguments).slice(1)};I(n),window.WailsInvoke("EE"+JSON.stringify(n))}function y(e){delete s[e],window.WailsInvoke("EX"+e)}var f={};function F(){var e=new Uint32Array(1);return window.crypto.getRandomValues(e)[0]}function P(){return Math.random()*9007199254740991}var p;window.crypto?p=F:p=P;function d(e,n,o){return o==null&&(o=0),new Promise(function(i,t){var r;do r=e+"-"+p();while(f[r]);var a;o>0&&(a=setTimeout(function(){t(Error("Call to "+e+" timed out. Request ID: "+r))},o)),f[r]={timeoutHandle:a,reject:t,resolve:i};try{let u={name:e,args:n,callbackID:r};window.WailsInvoke("C"+JSON.stringify(u))}catch(u){console.error(u)}})}function T(e){let n;try{n=JSON.parse(e)}catch(t){let r=`Invalid JSON passed to callback: ${t.message}. Message: ${e}`;throw runtime.LogDebug(r),new Error(r)}let o=n.callbackid,i=f[o];if(!i){let t=`Callback '${o}' not registered!!!`;throw console.error(t),new Error(t)}clearTimeout(i.timeoutHandle),delete f[o],n.error?i.reject(n.error):i.resolve(n.result)}window.go={};function L(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(i=>{window.go[n][o][i]=function(){let t=0;function r(){let a=[].slice.call(arguments);return d([n,o,i].join("."),a,t)}return r.setTimeout=function(a){t=a},r.getTimeout=function(){return t},r}()})})})}var v={};W(v,{WindowCenter:()=>V,WindowFullscreen:()=>N,WindowGetPosition:()=>ie,WindowGetSize:()=>_,WindowHide:()=>te,WindowMaximise:()=>se,WindowMinimise:()=>ae,WindowReload:()=>j,WindowReloadApp:()=>X,WindowSetDarkTheme:()=>Q,WindowSetLightTheme:()=>$,WindowSetMaxSize:()=>ee,WindowSetMinSize:()=>ne,WindowSetPosition:()=>oe,WindowSetRGBA:()=>fe,WindowSetSize:()=>K,WindowSetSystemDefaultTheme:()=>Y,WindowSetTitle:()=>q,WindowShow:()=>re,WindowToggleMaximise:()=>le,WindowUnfullscreen:()=>Z,WindowUnmaximise:()=>we,WindowUnminimise:()=>de});function j(){window.location.reload()}function X(){window.WailsInvoke("WR")}function Y(){window.WailsInvoke("WASDT")}function $(){window.WailsInvoke("WALT")}function Q(){window.WailsInvoke("WADT")}function V(){window.WailsInvoke("Wc")}function q(e){window.WailsInvoke("WT"+e)}function N(){window.WailsInvoke("WF")}function Z(){window.WailsInvoke("Wf")}function K(e,n){window.WailsInvoke("Ws:"+e+":"+n)}function _(){return d(":wails:WindowGetSize")}function ee(e,n){window.WailsInvoke("WZ:"+e+":"+n)}function ne(e,n){window.WailsInvoke("Wz:"+e+":"+n)}function oe(e,n){window.WailsInvoke("Wp:"+e+":"+n)}function ie(){return d(":wails:WindowGetPos")}function te(){window.WailsInvoke("WH")}function re(){window.WailsInvoke("WS")}function se(){window.WailsInvoke("WM")}function le(){window.WailsInvoke("Wt")}function we(){window.WailsInvoke("WU")}function ae(){window.WailsInvoke("Wm")}function de(){window.WailsInvoke("Wu")}function fe(e,n,o,i){let t=JSON.stringify({r:e||0,g:n||0,b:o||0,a:i||255});window.WailsInvoke("Wr:"+t)}var x={};W(x,{BrowserOpenURL:()=>ce});function ce(e){window.WailsInvoke("BO:"+e)}function ue(){window.WailsInvoke("Q")}function We(){return d(":wails:Environment")}window.runtime={...g,...v,...x,EventsOn:b,EventsOnce:E,EventsOnMultiple:c,EventsEmit:S,EventsOff:y,Environment:We,Quit:ue};window.wails={Callback:T,EventsNotify:h,SetBindings:L,eventListeners:s,callbacks:f,flags:{disableScrollbarDrag:!1,disableWailsDefaultContextMenu:!1,enableResize:!1,defaultCursor:null,borderThickness:6,dbClickInterval:100}};window.wails.SetBindings(window.wailsbindings);delete window.wails.SetBindings;var O,z=0;function ge(){window.WailsInvoke("drag")}window.addEventListener("mousedown",e=>{if(window.wails.flags.resizeEdge){window.WailsInvoke("resize:"+window.wails.flags.resizeEdge),e.preventDefault();return}let n=e.target;for(;n!=null&&!n.hasAttribute("data-wails-no-drag");){if(n.hasAttribute("data-wails-drag")){if(window.wails.flags.disableScrollbarDrag&&(e.offsetX>e.target.clientWidth||e.offsetY>e.target.clientHeight))break;if(new Date().getTime()-z<window.wails.flags.dbClickInterval){clearTimeout(O);break}O=setTimeout(ge,window.wails.flags.dbClickInterval),z=new Date().getTime(),e.preventDefault();break}n=n.parentElement}});function l(e){document.body.style.cursor=e||window.wails.flags.defaultCursor,window.wails.flags.resizeEdge=e}window.addEventListener("mousemove",function(e){if(!window.wails.flags.enableResize)return;window.wails.flags.defaultCursor==null&&(window.wails.flags.defaultCursor=document.body.style.cursor),window.outerWidth-e.clientX<window.wails.flags.borderThickness&&window.outerHeight-e.clientY<window.wails.flags.borderThickness&&(document.body.style.cursor="se-resize");let n=window.outerWidth-e.clientX<window.wails.flags.borderThickness,o=e.clientX<window.wails.flags.borderThickness,i=e.clientY<window.wails.flags.borderThickness,t=window.outerHeight-e.clientY<window.wails.flags.borderThickness;!o&&!n&&!i&&!t&&window.wails.flags.resizeEdge!==void 0?l():n&&t?l("se-resize"):o&&t?l("sw-resize"):o&&i?l("nw-resize"):i&&n?l("ne-resize"):o?l("w-resize"):i?l("n-resize"):t?l("s-resize"):n&&l("e-resize")});window.addEventListener("contextmenu",function(e){window.wails.flags.disableWailsDefaultContextMenu&&e.preventDefault()});})();
|