5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 19:19:15 +08:00
wails/v2/internal/runtime/assets/wails.js

1 line
5.1 KiB
JavaScript

!function(n){var e={};function t(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=n,t.c=e,t.d=function(n,e,r){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:r})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)t.d(r,o,function(e){return n[e]}.bind(null,o));return r},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){"use strict";t.r(e);var r={};t.r(r),t.d(r,"Debug",(function(){return u})),t.d(r,"Info",(function(){return l})),t.d(r,"Warning",(function(){return d})),t.d(r,"Error",(function(){return f})),t.d(r,"Fatal",(function(){return s}));var o={};t.r(o),t.d(o,"OpenURL",(function(){return w})),t.d(o,"OpenFile",(function(){return p}));var i=[];function a(n){!function(n){if(window.wailsbridge?window.wailsbridge.websocket.send(n):(window.external.invoke(n),console.log("Invoke called with: "+n)),i.length>0)for(var e=0;e<i.length;e++)i[e](n)}(n)}function c(n,e){a("L"+n+e)}function u(n){c("D",n)}function l(n){c("I",n)}function d(n){c("W",n)}function f(n){c("E",n)}function s(n){c("F",n)}function w(n){return a("RBU"+n)}function p(n){return a("runtime:browser:openfile")}var v=function n(e,t){!function(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),t=t||-1,this.Callback=function(n){return e.apply(null,n),-1!==t&&0===(t-=1)}},g={};function h(n,e,t){g[n]=g[n]||[];var r=new v(e,t);g[n].push(r)}function y(n){if(arguments.length>1){var e={name:n,data:[].slice.apply(arguments).slice(1)};a("Ej"+JSON.stringify(e))}else a("ej"+n)}var b={};var m,E={};function O(n,e,t){return null!=t&&null!=t||(t=0),new Promise((function(r,o){var i;do{i=n+"-"+m()}while(E[i]);if(t>0)var c=setTimeout((function(){o(Error("Call to "+n+" timed out. Request ID: "+i))}),t);E[i]={timeoutHandle:c,reject:o,resolve:r};try{JSON.stringify(e);a("call")}catch(n){console.error(n)}}))}function j(n){try{return new Function("var "+n),!0}catch(n){return!1}}function S(){return(S=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n}).apply(this,arguments)}m=window.crypto?function(){var n=new Uint32Array(1);return window.crypto.getRandomValues(n)[0]}:function(){return 9007199254740991*Math.random()},window.backend={},t.d(e,"Init",(function(){return I})),window.wails=window.wails||{},window.backend={};var k={NewBinding:function(n){var e=[].concat(n.split(".").splice(1)),t=window.backend;if(e.length>1)for(var r=0;r<e.length-1;r+=1){var o=e[r];if(!j(o))return new Error("".concat(o," is not a valid javascript identifier."));t[o]||(t[o]={}),t=t[o]}var i=e.pop();if(!j(i))return new Error("".concat(i," is not a valid javascript identifier."));t[i]=function(){var e=0;function t(){var t=[].slice.call(arguments);return O(n,t,e)}return t.setTimeout=function(n){e=n},t.getTimeout=function(){return e},t}()},Callback:function(n){var e;n=decodeURIComponent(n.replace(/\s+/g,"").replace(/[0-9a-f]{2}/g,"%$&"));try{e=JSON.parse(n)}catch(e){var t="Invalid JSON passed to callback: ".concat(e.message,". Message: ").concat(n);throw u(t),new Error(t)}var r=e.callbackid,o=E[r];if(!o){var i="Callback '".concat(r,"' not registed!!!");throw console.error(i),new Error(i)}clearTimeout(o.timeoutHandle),delete E[r],e.error?o.reject(e.error):o.resolve(e.data)},Notify:function(n,e){if(g[n]){for(var t=g[n].slice(),r=0;r<g[n].length;r+=1){var o=g[n][r],i=[];if(e)try{i=JSON.parse(e)}catch(e){f("Invalid JSON data sent to notify. Event name = "+n)}o.Callback(i)&&t.splice(r,1)}g[n]=t}},AddScript:function(n,e){var t=document.createElement("script");t.text=n,document.body.appendChild(t),e&&y(e)},InjectCSS:function(n){var e=document.createElement("style");e.setAttribute("type","text/css"),e.styleSheet?e.styleSheet.cssText=n:e.appendChild(document.createTextNode(n)),(document.head||document.getElementsByTagName("head")[0]).appendChild(e)},Init:I,AddIPCListener:function(n){i.push(n)}},C={Log:r,Browser:o,Events:{On:function(n,e){h(n,e)},OnMultiple:h,Emit:y,Heartbeat:function(n,e,t){var r=null;b[n]=function(){clearInterval(r),t()},r=setInterval((function(){y(n)}),e)},Acknowledge:function(n){if(!b[n])throw new f("Cannot acknowledge unknown heartbeat '".concat(n,"'"));b[n]()}},_:k};function I(n){window.wailspreinit&&(window.wailspreinit(),delete window.wailspreinit),n()}S(window.wails,C),window.onerror=function(n,e,t,r,o){window.wails.Log.Error("**** Caught Unhandled Error ****"),window.wails.Log.Error("Message: "+n),window.wails.Log.Error("URL: "+e),window.wails.Log.Error("Line No: "+t),window.wails.Log.Error("Column No: "+r),window.wails.Log.Error("error: "+o)},y("wails:loaded")}]);