Files
wails/runtime/assets/wails.js
Lea Anthony 914642bd1d Backport (#283)
* Develop (#265)


* Patch for file dialog on OSX

* Update CONTRIBUTORS.md

* 262 add wails shutdown method (#264)

* feat: support close in bridge mode

* feat: WailsShutdown callback

Now handles proper shutdown through:
  * runtime.Window.Close()
  * Killing the main window
  * Ctrl-C

* chore: version bump

* chore: version bump

* feat: adjust binary name for OS

* fix: allow spaces in gcc path

* feat: migrate command

* fix: npm/node versions

* fix: allow IE for serve

* feat: go build script

* fix: make runtime ES2015 compliant

* fix: remove invoke patch

* fix: allow any line endings

* chore: remove legacy bridge files

* chore: latest assets
2019-11-02 21:06:02 +11:00

1 line
4.7 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 c}),t.d(r,"Info",function(){return u}),t.d(r,"Warning",function(){return l}),t.d(r,"Error",function(){return f}),t.d(r,"Fatal",function(){return d});var o={};function i(n,e,t){var r={type:n,callbackID:t,payload:e};!function(n){window.wailsbridge?window.wailsbridge.websocket.send(n):window.external.invoke(n)}(JSON.stringify(r))}function a(n,e){i("log",{level:n,message:e})}function c(n){a("debug",n)}function u(n){a("info",n)}function l(n){a("warning",n)}function f(n){a("error",n)}function d(n){a("fatal",n)}t.r(o),t.d(o,"OpenURL",function(){return y}),t.d(o,"OpenFile",function(){return g});var s,p={};function w(n,e,t){return null!=t&&null!=t||(t=0),new Promise(function(r,o){var a;do{a=n+"-"+s()}while(p[a]);if(t>0)var c=setTimeout(function(){o(Error("Call to "+n+" timed out. Request ID: "+a))},t);p[a]={timeoutHandle:c,reject:o,resolve:r};try{i("call",{bindingName:n,data:JSON.stringify(e)},a)}catch(n){console.error(n)}})}function v(n,e){return w(".wails."+n,e)}function y(n){return v("Browser.OpenURL",n)}function g(n){return v("Browser.OpenFile",n)}s=window.crypto?function(){var n=new Uint32Array(1);return window.crypto.getRandomValues(n)[0]}:function(){return 9007199254740991*Math.random()};var b=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)}},m={};function h(n,e,t){m[n]=m[n]||[];var r=new b(e,t);m[n].push(r)}function O(n){i("event",{name:n,data:JSON.stringify([].slice.apply(arguments).slice(1))})}var S={};function k(n){try{return new Function("var "+n),!0}catch(n){return!1}}function j(){return(j=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)}window.backend={},t.d(e,"Init",function(){return N}),window.wails=window.wails||{},window.backend={};var E={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(!k(o))return new Error("".concat(o," is not a valid javascript identifier."));t[o]||(t[o]={}),t=t[o]}var i=e.pop();if(!k(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 w(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 c(t),new Error(t)}var r=e.callbackid,o=p[r];if(!o){var i="Callback '".concat(r,"' not registed!!!");throw console.error(i),new Error(i)}clearTimeout(o.timeoutHandle),delete p[r],e.error?o.reject(e.error):o.resolve(e.data)},Notify:function(n,e){if(m[n]){for(var t=m[n].slice(),r=0;r<m[n].length;r+=1){var o=m[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)}m[n]=t}},AddScript:function(n,e){var t=document.createElement("script");t.text=n,document.body.appendChild(t),e&&O(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:N},C={Log:r,Browser:o,Events:{On:function(n,e){h(n,e)},OnMultiple:h,Emit:O,Heartbeat:function(n,e,t){var r=null;S[n]=function(){clearInterval(r),t()},r=setInterval(function(){O(n)},e)},Acknowledge:function(n){if(!S[n])throw new f("Cannot acknowledge unknown heartbeat '".concat(n,"'"));S[n]()}},_:E};function N(n){n()}j(window.wails,C),O("wails:loaded")}]);