diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml new file mode 100644 index 0000000..22c9456 --- /dev/null +++ b/.github/workflows/github-actions-demo.yml @@ -0,0 +1,19 @@ +name: GitHub Actions Demo +on: [push] +jobs: + Minify: + runs-on: ubuntu-latest + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so auto-minify job can access it + - uses: actions/checkout@v2 + + - name: Auto Minify + uses: nizarmah/auto-minify@v2.1 + + # Auto commits minified files to the repository + # Ignore it if you don't want to commit the files to the repository + - name: Auto committing minified files + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "Github Action: Auto Minified JS and CSS files" + branch: ${{ github.ref }} diff --git a/reconnecting-websocket.min.js b/reconnecting-websocket.min.js index 3015099..e22bbfa 100644 --- a/reconnecting-websocket.min.js +++ b/reconnecting-websocket.min.js @@ -1 +1 @@ -!function(a,b){"function"==typeof define&&define.amd?define([],b):"undefined"!=typeof module&&module.exports?module.exports=b():a.ReconnectingWebSocket=b()}(this,function(){function a(b,c,d){function l(a,b){var c=document.createEvent("CustomEvent");return c.initCustomEvent(a,!1,!1,b),c}var e={debug:!1,automaticOpen:!0,reconnectInterval:1e3,maxReconnectInterval:3e4,reconnectDecay:1.5,timeoutInterval:2e3};d||(d={});for(var f in e)this[f]="undefined"!=typeof d[f]?d[f]:e[f];this.url=b,this.reconnectAttempts=0,this.readyState=WebSocket.CONNECTING,this.protocol=null;var h,g=this,i=!1,j=!1,k=document.createElement("div");k.addEventListener("open",function(a){g.onopen(a)}),k.addEventListener("close",function(a){g.onclose(a)}),k.addEventListener("connecting",function(a){g.onconnecting(a)}),k.addEventListener("message",function(a){g.onmessage(a)}),k.addEventListener("error",function(a){g.onerror(a)}),this.addEventListener=k.addEventListener.bind(k),this.removeEventListener=k.removeEventListener.bind(k),this.dispatchEvent=k.dispatchEvent.bind(k),this.open=function(b){h=new WebSocket(g.url,c||[]),b||k.dispatchEvent(l("connecting")),(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","attempt-connect",g.url);var d=h,e=setTimeout(function(){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","connection-timeout",g.url),j=!0,d.close(),j=!1},g.timeoutInterval);h.onopen=function(){clearTimeout(e),(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onopen",g.url),g.protocol=h.protocol,g.readyState=WebSocket.OPEN,g.reconnectAttempts=0;var d=l("open");d.isReconnect=b,b=!1,k.dispatchEvent(d)},h.onclose=function(c){if(clearTimeout(e),h=null,i)g.readyState=WebSocket.CLOSED,k.dispatchEvent(l("close"));else{g.readyState=WebSocket.CONNECTING;var d=l("connecting");d.code=c.code,d.reason=c.reason,d.wasClean=c.wasClean,k.dispatchEvent(d),b||j||((g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onclose",g.url),k.dispatchEvent(l("close")));var e=g.reconnectInterval*Math.pow(g.reconnectDecay,g.reconnectAttempts);setTimeout(function(){g.reconnectAttempts++,g.open(!0)},e>g.maxReconnectInterval?g.maxReconnectInterval:e)}},h.onmessage=function(b){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onmessage",g.url,b.data);var c=l("message");c.data=b.data,k.dispatchEvent(c)},h.onerror=function(b){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onerror",g.url,b),k.dispatchEvent(l("error"))}},1==this.automaticOpen&&this.open(!1),this.send=function(b){if(h)return(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","send",g.url,b),h.send(b);throw"INVALID_STATE_ERR : Pausing to reconnect websocket"},this.close=function(a,b){"undefined"==typeof a&&(a=1e3),i=!0,h&&h.close(a,b)},this.refresh=function(){h&&h.close()}}return a.prototype.onopen=function(){},a.prototype.onclose=function(){},a.prototype.onconnecting=function(){},a.prototype.onmessage=function(){},a.prototype.onerror=function(){},a.debugAll=!1,a.CONNECTING=WebSocket.CONNECTING,a.OPEN=WebSocket.OPEN,a.CLOSING=WebSocket.CLOSING,a.CLOSED=WebSocket.CLOSED,a}); +(function(a,b){"function"==typeof define&&define.amd?define([],b):"undefined"!=typeof module&&module.exports?module.exports=b():a.ReconnectingWebSocket=b()})(this,function(){function a(b,c,d){function f(a,b){var c=document.createEvent("CustomEvent");return c.initCustomEvent(a,!1,!1,b),c}var g={debug:!1,automaticOpen:!0,reconnectInterval:1e3,maxReconnectInterval:3e4,reconnectDecay:1.5,timeoutInterval:2e3,maxReconnectAttempts:null,binaryType:"blob"};for(var h in d||(d={}),g)this[h]="undefined"==typeof d[h]?g[h]:d[h];this.url=b,this.reconnectAttempts=0,this.readyState=WebSocket.CONNECTING,this.protocol=null;var i,j=this,k=!1,l=!1,m=document.createElement("div");m.addEventListener("open",function(a){j.onopen(a)}),m.addEventListener("close",function(a){j.onclose(a)}),m.addEventListener("connecting",function(a){j.onconnecting(a)}),m.addEventListener("message",function(a){j.onmessage(a)}),m.addEventListener("error",function(a){j.onerror(a)}),this.addEventListener=m.addEventListener.bind(m),this.removeEventListener=m.removeEventListener.bind(m),this.dispatchEvent=m.dispatchEvent.bind(m),this.open=function(b){if(i=new WebSocket(j.url,c||[]),i.binaryType=this.binaryType,!b)m.dispatchEvent(f("connecting")),this.reconnectAttempts=0;else if(this.maxReconnectAttempts&&this.reconnectAttempts>this.maxReconnectAttempts)return;(j.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","attempt-connect",j.url);var d=i,g=setTimeout(function(){(j.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","connection-timeout",j.url),l=!0,d.close(),l=!1},j.timeoutInterval);i.onopen=function(){clearTimeout(g),(j.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onopen",j.url),j.protocol=i.protocol,j.readyState=WebSocket.OPEN,j.reconnectAttempts=0;var c=f("open");c.isReconnect=b,b=!1,m.dispatchEvent(c)},i.onclose=function(c){var d=Math.pow;if(clearTimeout(e),i=null,k)j.readyState=WebSocket.CLOSED,m.dispatchEvent(f("close"));else{j.readyState=WebSocket.CONNECTING;var g=f("connecting");g.code=c.code,g.reason=c.reason,g.wasClean=c.wasClean,m.dispatchEvent(g),b||l||((j.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onclose",j.url),m.dispatchEvent(f("close")));var e=j.reconnectInterval*d(j.reconnectDecay,j.reconnectAttempts);setTimeout(function(){j.reconnectAttempts++,j.open(!0)},e>j.maxReconnectInterval?j.maxReconnectInterval:e)}},i.onmessage=function(b){(j.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onmessage",j.url,b.data);var c=f("message");c.data=b.data,m.dispatchEvent(c)},i.onerror=function(b){(j.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onerror",j.url,b),m.dispatchEvent(f("error"))}},!0==this.automaticOpen&&this.open(!1),this.send=function(b){if(i)return(j.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","send",j.url,b),i.send(b);throw"INVALID_STATE_ERR : Pausing to reconnect websocket"},this.close=function(a,b){"undefined"==typeof a&&(a=1e3),k=!0,i&&i.close(a,b)},this.refresh=function(){i&&i.close()}}if("WebSocket"in window)return a.prototype.onopen=function(){},a.prototype.onclose=function(){},a.prototype.onconnecting=function(){},a.prototype.onmessage=function(){},a.prototype.onerror=function(){},a.debugAll=!1,a.CONNECTING=WebSocket.CONNECTING,a.OPEN=WebSocket.OPEN,a.CLOSING=WebSocket.CLOSING,a.CLOSED=WebSocket.CLOSED,a}); \ No newline at end of file