5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 01:19:12 +08:00
wails/v2/internal/bridge/linux.js
2021-06-04 20:32:40 +10:00

1 line
7.3 KiB
JavaScript

var Wails=function(n){var t={};function e(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return n[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=n,e.c=t,e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:r})},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},e.t=function(n,t){if(1&t&&(n=e(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var i in n)e.d(r,i,function(t){return n[t]}.bind(null,i));return r},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.p="",e(e.s=0)}([function(n,t,e){"use strict";e.r(t);var r={};e.r(r),e.d(r,"Trace",(function(){return v})),e.d(r,"Print",(function(){return p})),e.d(r,"Debug",(function(){return y})),e.d(r,"Info",(function(){return m})),e.d(r,"Warning",(function(){return b})),e.d(r,"Error",(function(){return g})),e.d(r,"Fatal",(function(){return h})),e.d(r,"SetLogLevel",(function(){return S})),e.d(r,"Level",(function(){return E}));var i={};e.r(i),e.d(i,"Open",(function(){return M}));var o={};e.r(o),e.d(o,"Center",(function(){return N})),e.d(o,"SetTitle",(function(){return T})),e.d(o,"Fullscreen",(function(){return j})),e.d(o,"UnFullscreen",(function(){return D})),e.d(o,"SetSize",(function(){return I})),e.d(o,"SetPosition",(function(){return P})),e.d(o,"Hide",(function(){return A})),e.d(o,"Show",(function(){return J})),e.d(o,"Maximise",(function(){return L})),e.d(o,"Unmaximise",(function(){return R})),e.d(o,"Minimise",(function(){return _})),e.d(o,"Unminimise",(function(){return F})),e.d(o,"Close",(function(){return U}));var a={};e.r(a),e.d(a,"Open",(function(){return B})),e.d(a,"Save",(function(){return H})),e.d(a,"Message",(function(){return G}));var u={};e.r(u),e.d(u,"New",(function(){return en}));var c={};e.r(c),e.d(c,"SetIcon",(function(){return rn}));var l={AppType:"desktop",Platform:function(){return"linux"}};var s=[];function f(n){s.push(n)}function d(n){if(function(n){window.wailsInvoke(n)}(n),s.length>0)for(var t=0;t<s.length;t++)s[t](n)}function w(n,t){d("L"+n+t)}function v(n){w("T",n)}function p(n){w("P",n)}function y(n){w("D",n)}function m(n){w("I",n)}function b(n){w("W",n)}function g(n){w("E",n)}function h(n){w("F",n)}function S(n){w("S",n)}var O,E={TRACE:1,DEBUG:2,INFO:3,WARNING:4,ERROR:5},k={};function C(n,t,e){return null!=e&&null!=e||(e=0),new Promise((function(r,i){var o;do{o=n+"-"+O()}while(k[o]);if(e>0)var a=setTimeout((function(){i(Error("Call to "+n+" timed out. Request ID: "+o))}),e);k[o]={timeoutHandle:a,reject:i,resolve:r};try{var u={name:n,args:t,callbackID:o};d("C"+JSON.stringify(u))}catch(n){console.error(n)}}))}function W(n){var t;try{t=JSON.parse(n)}catch(t){var e="Invalid JSON passed to callback: ".concat(t.message,". Message: ").concat(n);throw y(e),new Error(e)}var r=t.callbackid,i=k[r];if(!i){var o="Callback '".concat(r,"' not registered!!!");throw console.error(o),new Error(o)}clearTimeout(i.timeoutHandle),delete k[r],t.error?i.reject(t.error):i.resolve(t.result)}function x(n){var t=[].slice.apply(arguments).slice(1);return C(".wails."+n,t)}function M(n){return d("RBO"+n)}function N(){d("Wc")}function T(n){d("WT"+n)}function j(){d("WF")}function D(){d("Wf")}function I(n,t){d("Ws:"+n+":"+t)}function P(n,t){d("Wp:"+n+":"+t)}function A(){d("WH")}function J(){d("WS")}function L(){d("WM")}function R(){d("WU")}function _(){d("Wm")}function F(){d("Wu")}function U(){d("WC")}function B(n){return x("Dialog.Open",n)}function H(n){return x("Dialog.Save",n)}function G(n){return x("Dialog.Message",n)}O=window.crypto?function(){var n=new Uint32Array(1);return window.crypto.getRandomValues(n)[0]}:function(){return 9007199254740991*Math.random()},window.backend={};var q=function n(t,e){!function(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),e=e||-1,this.Callback=function(n){return t.apply(null,n),-1!==e&&0===(e-=1)}},z={};function V(n,t,e){z[n]=z[n]||[];var r=new q(t,e);console.log("Pushing event listener: "+n),z[n].push(r)}function K(n,t){V(n,t)}function Q(n,t){V(n,t,1)}function X(n){var t=n.name;if(z[t]){for(var e=z[t].slice(),r=0;r<z[t].length;r+=1){var i=z[t][r],o=n.data;i.Callback(o)&&e.splice(r,1)}z[t]=e}}function Y(n){var t;try{t=JSON.parse(n)}catch(t){throw new g("Invalid JSON passed to Notify: "+n)}X(t)}function Z(n){var t={name:n,data:[].slice.apply(arguments).slice(1)};X(t),d("Ej"+JSON.stringify(t))}function $(n,t){var e=document.createElement("script");e.text=n,document.body.appendChild(e),t&&Z(t)}function nn(n){try{var t=document.createElement("style");t.setAttribute("type","text/css"),t.styleSheet?t.styleSheet.cssText=n:t.appendChild(document.createTextNode(n)),(document.head||document.getElementsByTagName("head")[0]).appendChild(t)}catch(n){console.log(n)}}function tn(){window.disableWailsDefaultContextMenu=!0}function en(n,t){var e;if(!window.wails)throw Error("Wails is not initialised");var r=[];return window.wails.Events.On("wails:sync:store:updatedbybackend:"+n,(function(n){var t=JSON.parse(n);e=t,r.forEach((function(n){n(e)}))})),t&&this.set(t),window.wails.Events.Emit("wails:sync:store:resync:"+n),{subscribe:function(n){r.push(n)},get:function(){return e},set:function(t){e=t,window.wails.Events.Emit("wails:sync:store:updatedbyfrontend:"+n,JSON.stringify(e)),r.forEach((function(n){n(e)}))},update:function(n){var t=n(e);this.set(t)}}}function rn(n){d("TI"+n)}function on(){return(on=Object.assign||function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n}).apply(this,arguments)}window.backend={},window.wails={System:l,Log:r,Browser:i,Window:o,Tray:c,Dialog:a,Events:{On:K,Once:Q,OnMultiple:V,Emit:Z},_:{Callback:W,Notify:Y,AddScript:$,InjectCSS:nn,DisableDefaultContextMenu:tn,AddIPCListener:f,SystemCall:x,SendMessage:d},Store:u},window.wails.System={IsDarkMode:en("wails:isdarkmode"),LogLevel:en("wails:loglevel"),AppConfig:en("wails:appconfig")},on(window.wails.System,l),window.addEventListener("mousedown",(function(n){for(var t=n.target;null!=t&&!t.hasAttribute("data-wails-no-drag");){if(t.hasAttribute("data-wails-drag")){window.wailsDrag(null);break}t=t.parentElement}})),window.addEventListener("contextmenu",(function(n){for(var t,e=n.target;null!=e&&null==(t=e.dataset["wails-context-menu-id"]);)e=e.parentElement;if((null!=t||window.disableWailsDefaultContextMenu)&&n.preventDefault(),null!=t){var r={id:t,data:e.dataset["wails-context-menu-data"]||""};window.wailsContextMenuMessage(JSON.stringify(r))}})),window.wailsbindings&&function(n){try{n=JSON.parse(n)}catch(n){console.error(n)}window.backend=window.backend||{},Object.keys(n).forEach((function(t){window.backend[t]=window.backend[t]||{},Object.keys(n[t]).forEach((function(e){window.backend[t][e]=window.backend[t][e]||{},Object.keys(n[t][e]).forEach((function(n){window.backend[t][e][n]=function(){var r=0;function i(){var i=[].slice.call(arguments);return C([t,e,n].join("."),i,r)}return i.setTimeout=function(n){r=n},i.getTimeout=function(){return r},i}()}))}))}))}(window.wailsbindings),window.wails.Events.Emit("wails:loaded")}]);