5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 12:51:38 +08:00
wails/v2/internal/runtime/assets/desktop.js
2021-01-05 13:20:44 +11:00

1 line
8.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=1)}([function(n,t,e){"use strict";e.r(t),e.d(t,"AppType",(function(){return r}));var r="desktop"},function(n,t,e){"use strict";e.r(t);var r={};e.r(r),e.d(r,"Trace",(function(){return b})),e.d(r,"Print",(function(){return y})),e.d(r,"Debug",(function(){return g})),e.d(r,"Info",(function(){return m})),e.d(r,"Warning",(function(){return O})),e.d(r,"Error",(function(){return h})),e.d(r,"Fatal",(function(){return S})),e.d(r,"SetLogLevel",(function(){return E})),e.d(r,"Level",(function(){return j}));var i={};e.r(i),e.d(i,"Open",(function(){return D}));var o={};e.r(o),e.d(o,"Center",(function(){return M})),e.d(o,"SetTitle",(function(){return x})),e.d(o,"Fullscreen",(function(){return T})),e.d(o,"UnFullscreen",(function(){return I})),e.d(o,"SetSize",(function(){return J})),e.d(o,"SetPosition",(function(){return L})),e.d(o,"Hide",(function(){return A})),e.d(o,"Show",(function(){return R})),e.d(o,"Maximise",(function(){return H})),e.d(o,"Unmaximise",(function(){return _})),e.d(o,"Minimise",(function(){return F})),e.d(o,"Unminimise",(function(){return U})),e.d(o,"Close",(function(){return B}));var a={};e.r(a),e.d(a,"Open",(function(){return G})),e.d(a,"Save",(function(){return q})),e.d(a,"Message",(function(){return z}));var u={};e.r(u),e.d(u,"New",(function(){return on}));var c={};function s(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),e.push.apply(e,r)}return e}function l(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}e.r(c),e.d(c,"SetIcon",(function(){return an}));var f=function(n){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?s(Object(e),!0).forEach((function(t){l(n,t,e[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):s(Object(e)).forEach((function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))}))}return n}({},e(0),{Platform:function(){return"darwin"}});var d=[];function w(n){d.push(n)}function p(n){if(function(n){window.webkit.messageHandlers.external.postMessage(n)}(n),d.length>0)for(var t=0;t<d.length;t++)d[t](n)}function v(n,t){p("L"+n+t)}function b(n){v("T",n)}function y(n){v("P",n)}function g(n){v("D",n)}function m(n){v("I",n)}function O(n){v("W",n)}function h(n){v("E",n)}function S(n){v("F",n)}function E(n){v("S",n)}var k,j={TRACE:1,DEBUG:2,INFO:3,WARNING:4,ERROR:5},P={};function C(n,t,e){return null!=e&&null!=e||(e=0),new Promise((function(r,i){var o;do{o=n+"-"+k()}while(P[o]);if(e>0)var a=setTimeout((function(){i(Error("Call to "+n+" timed out. Request ID: "+o))}),e);P[o]={timeoutHandle:a,reject:i,resolve:r};try{var u={name:n,args:t,callbackID:o};p("C"+JSON.stringify(u))}catch(n){console.error(n)}}))}function N(n){var t;try{t=JSON.parse(n)}catch(t){var e="Invalid JSON passed to callback: ".concat(t.message,". Message: ").concat(n);throw g(e),new Error(e)}var r=t.callbackid,i=P[r];if(!i){var o="Callback '".concat(r,"' not registered!!!");throw console.error(o),new Error(o)}clearTimeout(i.timeoutHandle),delete P[r],t.error?i.reject(t.error):i.resolve(t.result)}function W(n){var t=[].slice.apply(arguments).slice(1);return C(".wails."+n,t)}function D(n){return p("RBO"+n)}function M(){p("Wc")}function x(n){p("WT"+n)}function T(){p("WF")}function I(){p("Wf")}function J(n,t){p("Ws:"+n+":"+t)}function L(n,t){p("Wp:"+n+":"+t)}function A(){p("WH")}function R(){p("WS")}function H(){p("WM")}function _(){p("WU")}function F(){p("Wm")}function U(){p("Wu")}function B(){p("WC")}function G(n){return W("Dialog.Open",n)}function q(n){return W("Dialog.Save",n)}function z(n){return W("Dialog.Message",n)}k=window.crypto?function(){var n=new Uint32Array(1);return window.crypto.getRandomValues(n)[0]}:function(){return 9007199254740991*Math.random()},window.backend={};var V=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)}},K={};function Q(n,t,e){K[n]=K[n]||[];var r=new V(t,e);console.log("Pushing event listener: "+n),K[n].push(r)}function X(n,t){Q(n,t)}function Y(n,t){Q(n,t,1)}function Z(n){var t=n.name;if(K[t]){for(var e=K[t].slice(),r=0;r<K[t].length;r+=1){var i=K[t][r],o=n.data;i.Callback(o)&&e.splice(r,1)}K[t]=e}}function $(n){var t;try{t=JSON.parse(n)}catch(t){throw new h("Invalid JSON passed to Notify: "+n)}Z(t)}function nn(n){var t={name:n,data:[].slice.apply(arguments).slice(1)};Z(t),p("Ej"+JSON.stringify(t))}function tn(n,t){var e=document.createElement("script");e.text=n,document.body.appendChild(e),t&&nn(t)}function en(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 rn(){window.disableWailsDefaultContextMenu=!0}function on(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 an(n){p("TI"+n)}function un(){return(un=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.onerror=function(n,t,e,r,i){var o={message:n,url:t,line:e,column:r,error:JSON.stringify(i),stack:JSON.stringify((new Error).stack)};window.wails.Log.Error(JSON.stringify(o))},window.backend={},window.wails={System:f,Log:r,Browser:i,Window:o,Tray:c,Dialog:a,Events:{On:X,Once:Y,OnMultiple:Q,Emit:nn},_:{Callback:N,Notify:$,AddScript:tn,InjectCSS:en,DisableDefaultContextMenu:rn,AddIPCListener:w,SystemCall:W},Store:u},window.wails.System={IsDarkMode:on("wails:isdarkmode"),LogLevel:on("wails:loglevel"),AppConfig:on("wails:appconfig")},un(window.wails.System,f),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.webkit.messageHandlers.windowDrag.postMessage(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.webkit.messageHandlers.contextMenu.postMessage(JSON.stringify(r))}})),window.wailsloader.runtime=!0,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")}]);