From 4396c2ed6024c4e537a5943804268d13b65af5de Mon Sep 17 00:00:00 2001 From: Maik Hummel Date: Mon, 29 Feb 2016 20:19:09 +0100 Subject: [PATCH] Prepare v0.2.0 --- .gitignore | 3 +-- .npmignore | 5 +--- .travis.yml | 5 ++-- Gruntfile.js | 7 +++-- README.md | 26 ++++++++++++------- bower.json | 4 +-- ng-stomp.min.js => dist/ng-stomp.min.js | 4 +-- .../ng-stomp.standalone.min.js | 4 +-- package.json | 4 +-- ng-stomp.js => src/ng-stomp.js | 4 +-- 10 files changed, 35 insertions(+), 31 deletions(-) rename ng-stomp.min.js => dist/ng-stomp.min.js (96%) rename ng-stomp.standalone.min.js => dist/ng-stomp.standalone.min.js (99%) rename ng-stomp.js => src/ng-stomp.js (98%) diff --git a/.gitignore b/.gitignore index 3d93db4..0cfc89f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ bower_components/ -node_modules/ -.idea/ \ No newline at end of file +node_modules/ \ No newline at end of file diff --git a/.npmignore b/.npmignore index f1698da..4a688ff 100644 --- a/.npmignore +++ b/.npmignore @@ -1,5 +1,2 @@ node_modules/ -bower_components/ - -build/ -dist/ \ No newline at end of file +bower_components/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 1398bdd..eb38ecc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: node_js node_js: - - "0.10" -before_install: npm install -g grunt-cli \ No newline at end of file + - "4.1" +before_install: npm install -g grunt-cli + diff --git a/Gruntfile.js b/Gruntfile.js index 5698903..bdffedf 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,11 +6,11 @@ module.exports = function (grunt) { preserveComments: 'some' }, files: { - 'ng-stomp.min.js': ['ng-stomp.js'], - 'ng-stomp.standalone.min.js': [ + 'dist/ng-stomp.min.js': ['src/ng-stomp.js'], + 'dist/ng-stomp.standalone.min.js': [ 'bower_components/sockjs/sockjs.min.js', 'bower_components/stomp-websocket/lib/stomp.min.js', - 'ng-stomp.js' + 'src/ng-stomp.js' ] } } @@ -26,7 +26,6 @@ module.exports = function (grunt) { }) grunt.loadNpmTasks('grunt-contrib-uglify') - grunt.loadNpmTasks('grunt-contrib-jshint') grunt.loadNpmTasks('grunt-standard') grunt.registerTask('default', ['standard', 'uglify']) } diff --git a/README.md b/README.md index 2aa9f25..77ce948 100644 --- a/README.md +++ b/README.md @@ -17,16 +17,16 @@ bower install --save ng-stomp ``` -#### Add standalone version (dependencies included) +#### Add standalone version (dependencies included) to your HTML file ```html - + ``` -#### Add SockJS + STOMP + (minified) ngStomp: +#### Or add SockJS + STOMP + (minified) ngStomp individually: ```html - + ``` ---- @@ -35,16 +35,16 @@ bower install --save ng-stomp npm install --save ng-stomp ``` -#### Add standalone version (dependencies included) +#### Add standalone version (dependencies included) to your HTML file ```html - + ``` -#### Add SockJS + STOMP + (minified) Stompie: +#### Or add SockJS + STOMP + (minified) Stompie individually: ```html - + ``` ---- @@ -91,4 +91,12 @@ angular }) ``` -## API-Docs (TBD) \ No newline at end of file +## API-Docs (TBD) +- setDebug(callback) +- connect(endpoint, headers) +- disconnect +- subscribe(destination, callback, headers) +- on(destination, callback, headers) +- unsubscribe(subscription) +- off(subscription) +- send(destination, body, headers) \ No newline at end of file diff --git a/bower.json b/bower.json index 3bc573f..2ef3f03 100644 --- a/bower.json +++ b/bower.json @@ -1,12 +1,12 @@ { "name": "ng-stomp", - "version": "0.1.2", + "version": "0.2.0", "homepage": "https://github.com/beevelop/ng-stomp", "authors": [ "Maik Hummel " ], "description": "STOMP for AngularJS", - "main": "ng-stomp.js", + "main": "src/ng-stomp.js", "keywords": [ "STOMP", "websockets" diff --git a/ng-stomp.min.js b/dist/ng-stomp.min.js similarity index 96% rename from ng-stomp.min.js rename to dist/ng-stomp.min.js index 6606065..80ae1f9 100644 --- a/ng-stomp.min.js +++ b/dist/ng-stomp.min.js @@ -1,9 +1,9 @@ /** * ngStomp * - * @version 0.1.0 + * @version 0.2.0 * @author Maik Hummel - * @license WTFPL + * @license MIT */ /*global angular, SockJS, Stomp */ diff --git a/ng-stomp.standalone.min.js b/dist/ng-stomp.standalone.min.js similarity index 99% rename from ng-stomp.standalone.min.js rename to dist/ng-stomp.standalone.min.js index a52a705..8b0aec3 100644 --- a/ng-stomp.standalone.min.js +++ b/dist/ng-stomp.standalone.min.js @@ -32,9 +32,9 @@ var JSON;JSON||(JSON={}),function(){function str(a,b){var c,d,e,f,g,h=gap,i=b[a] function(){var a,b,c,d,e={}.hasOwnProperty,f=[].slice;a={LF:"\n",NULL:"\x00"},c=function(){function b(a,b,c){this.command=a,this.headers=null!=b?b:{},this.body=null!=c?c:""}var c;return b.prototype.toString=function(){var c,d,f,g,h;c=[this.command],f=this.headers["content-length"]===!1,f&&delete this.headers["content-length"],h=this.headers;for(d in h)e.call(h,d)&&(g=h[d],c.push(""+d+":"+g));return this.body&&!f&&c.push("content-length:"+b.sizeOfUTF8(this.body)),c.push(a.LF+this.body),c.join(a.LF)},b.sizeOfUTF8=function(a){return a?encodeURI(a).match(/%..|./g).length:0},c=function(c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;for(g=c.search(RegExp(""+a.LF+a.LF)),h=c.substring(0,g).split(a.LF),f=h.shift(),i={},o=function(a){return a.replace(/^\s+|\s+$/g,"")},s=h.reverse(),p=0,r=s.length;r>p;p++)m=s[p],k=m.indexOf(":"),i[o(m.substring(0,k))]=o(m.substring(k+1));if(d="",n=g+2,i["content-length"])l=parseInt(i["content-length"]),d=(""+c).substring(n,n+l);else for(e=null,j=q=n,t=c.length;(t>=n?t>q:q>t)&&(e=c.charAt(j),e!==a.NULL);j=t>=n?++q:--q)d+=e;return new b(f,i,d)},b.unmarshall=function(b){var d,e,f,g;return e=b.split(RegExp(""+a.NULL+a.LF+"*")),g={frames:[],partial:""},g.frames=function(){var a,b,f,g;for(f=e.slice(0,-1),g=[],a=0,b=f.length;b>a;a++)d=f[a],g.push(c(d));return g}(),f=e.slice(-1)[0],f===a.LF||-1!==f.search(RegExp(""+a.NULL+a.LF+"*$"))?g.frames.push(c(f)):g.partial=f,g},b.marshall=function(c,d,e){var f;return f=new b(c,d,e),f.toString()+a.NULL},b}(),b=function(){function b(a){this.ws=a,this.ws.binaryType="arraybuffer",this.counter=0,this.connected=!1,this.heartbeat={outgoing:1e4,incoming:1e4},this.maxWebSocketFrameSize=16384,this.subscriptions={},this.partialData=""}var e;return b.prototype.debug=function(a){var b;return"undefined"!=typeof window&&null!==window&&null!=(b=window.console)?b.log(a):void 0},e=function(){return Date.now?Date.now():(new Date).valueOf},b.prototype._transmit=function(a,b,d){var e;for(e=c.marshall(a,b,d),"function"==typeof this.debug&&this.debug(">>> "+e);;){if(!(e.length>this.maxWebSocketFrameSize))return this.ws.send(e);this.ws.send(e.substring(0,this.maxWebSocketFrameSize)),e=e.substring(this.maxWebSocketFrameSize),"function"==typeof this.debug&&this.debug("remaining = "+e.length)}},b.prototype._setupHeartbeat=function(b){var c,f,g,h,i,j;if((i=b.version)===d.VERSIONS.V1_1||i===d.VERSIONS.V1_2)return j=function(){var a,c,d,e;for(d=b["heart-beat"].split(","),e=[],a=0,c=d.length;c>a;a++)h=d[a],e.push(parseInt(h));return e}(),f=j[0],c=j[1],0!==this.heartbeat.outgoing&&0!==c&&(g=Math.max(this.heartbeat.outgoing,c),"function"==typeof this.debug&&this.debug("send PING every "+g+"ms"),this.pinger=d.setInterval(g,function(b){return function(){return b.ws.send(a.LF),"function"==typeof b.debug?b.debug(">>> PING"):void 0}}(this))),0!==this.heartbeat.incoming&&0!==f?(g=Math.max(this.heartbeat.incoming,f),"function"==typeof this.debug&&this.debug("check PONG every "+g+"ms"),this.ponger=d.setInterval(g,function(a){return function(){var b;return b=e()-a.serverActivity,b>2*g?("function"==typeof a.debug&&a.debug("did not receive server activity for the last "+b+"ms"),a.ws.close()):void 0}}(this))):void 0},b.prototype._parseConnect=function(){var a,b,c,d;switch(a=1<=arguments.length?f.call(arguments,0):[],d={},a.length){case 2:d=a[0],b=a[1];break;case 3:a[1]instanceof Function?(d=a[0],b=a[1],c=a[2]):(d.login=a[0],d.passcode=a[1],b=a[2]);break;case 4:d.login=a[0],d.passcode=a[1],b=a[2],c=a[3];break;default:d.login=a[0],d.passcode=a[1],b=a[2],c=a[3],d.host=a[4]}return[d,b,c]},b.prototype.connect=function(){var b,g,h,i;return b=1<=arguments.length?f.call(arguments,0):[],i=this._parseConnect.apply(this,b),h=i[0],this.connectCallback=i[1],g=i[2],"function"==typeof this.debug&&this.debug("Opening Web Socket..."),this.ws.onmessage=function(b){return function(d){var f,h,i,j,k,l,m,n,o,p,q,r,s;if(j="undefined"!=typeof ArrayBuffer&&d.data instanceof ArrayBuffer?(f=new Uint8Array(d.data),"function"==typeof b.debug?b.debug("--- got data length: "+f.length):void 0,function(){var a,b,c;for(c=[],a=0,b=f.length;b>a;a++)h=f[a],c.push(String.fromCharCode(h));return c}().join("")):d.data,b.serverActivity=e(),j===a.LF)return void("function"==typeof b.debug&&b.debug("<<< PONG"));for("function"==typeof b.debug&&b.debug("<<< "+j),o=c.unmarshall(b.partialData+j),b.partialData=o.partial,r=o.frames,s=[],p=0,q=r.length;q>p;p++)switch(k=r[p],k.command){case"CONNECTED":"function"==typeof b.debug&&b.debug("connected to server "+k.headers.server),b.connected=!0,b._setupHeartbeat(k.headers),s.push("function"==typeof b.connectCallback?b.connectCallback(k):void 0);break;case"MESSAGE":n=k.headers.subscription,m=b.subscriptions[n]||b.onreceive,m?(i=b,l=k.headers["message-id"],k.ack=function(a){return null==a&&(a={}),i.ack(l,n,a)},k.nack=function(a){return null==a&&(a={}),i.nack(l,n,a)},s.push(m(k))):s.push("function"==typeof b.debug?b.debug("Unhandled received MESSAGE: "+k):void 0);break;case"RECEIPT":s.push("function"==typeof b.onreceipt?b.onreceipt(k):void 0);break;case"ERROR":s.push("function"==typeof g?g(k):void 0);break;default:s.push("function"==typeof b.debug?b.debug("Unhandled frame: "+k):void 0)}return s}}(this),this.ws.onclose=function(a){return function(){var b;return b="Whoops! Lost connection to "+a.ws.url,"function"==typeof a.debug&&a.debug(b),a._cleanUp(),"function"==typeof g?g(b):void 0}}(this),this.ws.onopen=function(a){return function(){return"function"==typeof a.debug&&a.debug("Web Socket Opened..."),h["accept-version"]=d.VERSIONS.supportedVersions(),h["heart-beat"]=[a.heartbeat.outgoing,a.heartbeat.incoming].join(","),a._transmit("CONNECT",h)}}(this)},b.prototype.disconnect=function(a,b){return null==b&&(b={}),this._transmit("DISCONNECT",b),this.ws.onclose=null,this.ws.close(),this._cleanUp(),"function"==typeof a?a():void 0},b.prototype._cleanUp=function(){return this.connected=!1,this.pinger&&d.clearInterval(this.pinger),this.ponger?d.clearInterval(this.ponger):void 0},b.prototype.send=function(a,b,c){return null==b&&(b={}),null==c&&(c=""),b.destination=a,this._transmit("SEND",b,c)},b.prototype.subscribe=function(a,b,c){var d;return null==c&&(c={}),c.id||(c.id="sub-"+this.counter++),c.destination=a,this.subscriptions[c.id]=b,this._transmit("SUBSCRIBE",c),d=this,{id:c.id,unsubscribe:function(){return d.unsubscribe(c.id)}}},b.prototype.unsubscribe=function(a){return delete this.subscriptions[a],this._transmit("UNSUBSCRIBE",{id:a})},b.prototype.begin=function(a){var b,c;return c=a||"tx-"+this.counter++,this._transmit("BEGIN",{transaction:c}),b=this,{id:c,commit:function(){return b.commit(c)},abort:function(){return b.abort(c)}}},b.prototype.commit=function(a){return this._transmit("COMMIT",{transaction:a})},b.prototype.abort=function(a){return this._transmit("ABORT",{transaction:a})},b.prototype.ack=function(a,b,c){return null==c&&(c={}),c["message-id"]=a,c.subscription=b,this._transmit("ACK",c)},b.prototype.nack=function(a,b,c){return null==c&&(c={}),c["message-id"]=a,c.subscription=b,this._transmit("NACK",c)},b}(),d={VERSIONS:{V1_0:"1.0",V1_1:"1.1",V1_2:"1.2",supportedVersions:function(){return"1.1,1.0"}},client:function(a,c){var e,f;return null==c&&(c=["v10.stomp","v11.stomp"]),e=d.WebSocketClass||WebSocket,f=new e(a,c),new b(f)},over:function(a){return new b(a)},Frame:c},"undefined"!=typeof exports&&null!==exports&&(exports.Stomp=d),"undefined"!=typeof window&&null!==window?(d.setInterval=function(a,b){return window.setInterval(b,a)},d.clearInterval=function(a){return window.clearInterval(a)},window.Stomp=d):exports||(self.Stomp=d)}.call(this),/** * ngStomp * - * @version 0.1.0 + * @version 0.2.0 * @author Maik Hummel - * @license WTFPL + * @license MIT */ /*global angular, SockJS, Stomp */ diff --git a/package.json b/package.json index 5780c73..7e66175 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "ng-stomp", - "version": "0.1.2", + "version": "0.2.0", "description": "STOMP for AngularJS", - "main": "ng-stomp.js", + "main": "src/ng-stomp.js", "dependencies": { "sockjs": "^0.3.15", "stompjs": "^2.3.3" diff --git a/ng-stomp.js b/src/ng-stomp.js similarity index 98% rename from ng-stomp.js rename to src/ng-stomp.js index fa42e50..6915763 100644 --- a/ng-stomp.js +++ b/src/ng-stomp.js @@ -1,9 +1,9 @@ /** * ngStomp * - * @version 0.1.0 + * @version 0.2.0 * @author Maik Hummel - * @license WTFPL + * @license MIT */ /*global