From d9d79dee8d12ff3f0a221b108edeb6fb701193f1 Mon Sep 17 00:00:00 2001 From: lamprez Date: Mon, 31 Jul 2017 18:40:46 +0000 Subject: [PATCH 1/6] fixed bower's entry points; previously replaced ignored assets with distributed equivalent --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index d2722f9..e43f00e 100644 --- a/bower.json +++ b/bower.json @@ -5,7 +5,7 @@ "amvtek " ], "description": "A polyfill for http://www.w3.org/TR/eventsource/", - "main": ["javascript/src/eventsource.js", "eventsource.min.js", "README.rst"], + "main": ["dist/eventsource.js", "dist/eventsource.min.js", "README.md"], "keywords": [ "sse", "server sent events", From 0603199151b2420b5877a8b75cb6f7898adf5f2a Mon Sep 17 00:00:00 2001 From: lamprez Date: Tue, 3 Oct 2017 21:13:47 +0000 Subject: [PATCH 2/6] update package.json description, repository url and data related to author --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index a28aa05..a47a19e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "eventsource-polyfill", - "version": "0.9.7", - "description": "A browser polyfill for W3C EventSource (http://www.w3.org/TR/eventsource/)", + "version": "0.9.8", + "description": "A browser polyfill for W3C EventSource (http://www.w3.org/TR/eventsource/). This is fork containg fixes. Original work can be found here: https://github.com/amvtek/EventSource.git ", "main": "dist/browserify-eventsource.js", "directories": { "doc": "docs" }, "files": [ @@ -13,7 +13,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/amvtek/EventSource.git" + "url": "https://github.com/zabrowarnyrafal/EventSource.git" }, "keywords": [ "sse", @@ -22,12 +22,12 @@ "event-source", "polyfill" ], - "author": "amvtek ", + "author": "zabrowarnyrafal ", "license": "MIT", "bugs": { - "url": "https://github.com/amvtek/EventSource/issues" + "url": "https://github.com/zabrowarnyrafal/EventSource/issues" }, - "homepage": "https://github.com/amvtek/EventSource", + "homepage": "https://github.com/zabrowarnyrafal/EventSource", "devDependencies": { "grunt": "^0.4.5", "grunt-contrib-uglify": "^0.6.0", From cebe61ab54f78b346b8a51132cb75fde23f476de Mon Sep 17 00:00:00 2001 From: lamprez Date: Tue, 3 Oct 2017 21:32:11 +0000 Subject: [PATCH 3/6] update readme.md with information about orignal work and purpose of fork --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c949243..dbbfcd7 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +#### This is fork of EventSource Polyfill. Orignal work can be found here: https://github.com/amvtek/EventSource. It contains only bugfixes. + EventSource Polyfill ==================== From 6b919db230bd66f8316f14f54e6a68df09798501 Mon Sep 17 00:00:00 2001 From: lamprez Date: Tue, 3 Oct 2017 21:38:29 +0000 Subject: [PATCH 4/6] bump to ver 0.9.8 --- dist/browserify-eventsource.js | 7 ++++--- dist/eventsource.js | 2 +- dist/eventsource.min.js | 2 +- package.json | 6 ++++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/dist/browserify-eventsource.js b/dist/browserify-eventsource.js index 76b9b4a..3abafe7 100644 --- a/dist/browserify-eventsource.js +++ b/dist/browserify-eventsource.js @@ -1,5 +1,5 @@ /* - * CommonJS module that exports EventSource polyfill version 0.9.7 + * CommonJS module that exports EventSource polyfill version 0.9.8 * This module is intended for browser side use * ===================================================================== * THIS IS A POLYFILL MODULE, SO IT HAS SIDE EFFECTS @@ -17,7 +17,8 @@ module.exports = PolyfillEventSource; // Add EventSource to window if it is missing... if (window && !window.EventSource){ window.EventSource = PolyfillEventSource; - if (console){ - console.log("polyfill-eventsource added missing EventSource to window"); + // Don't break IE < 10 + if (typeof console !== "undefined" && typeof console.log !== "undefined"){ + console.log("polyfill-eventsource added missing EventSource to window"); } } diff --git a/dist/eventsource.js b/dist/eventsource.js index d3b563b..cfae2ab 100644 --- a/dist/eventsource.js +++ b/dist/eventsource.js @@ -1,5 +1,5 @@ /* - * EventSource polyfill version 0.9.7 + * EventSource polyfill version 0.9.8 * Supported by sc AmvTek srl * :email: devel@amvtek.com */ diff --git a/dist/eventsource.min.js b/dist/eventsource.min.js index 3e79de6..eeb7f5e 100644 --- a/dist/eventsource.min.js +++ b/dist/eventsource.min.js @@ -1 +1 @@ -!function(a){function b(a,b,c,d){this.bubbles=!1,this.cancelBubble=!1,this.cancelable=!1,this.data=b||null,this.origin=c||"",this.lastEventId=d||"",this.type=a||"message"}function c(){return window.XDomainRequest&&window.XMLHttpRequest&&void 0===(new XMLHttpRequest).responseType?!0:!1}if(!a.EventSource||a._eventSourceImportPrefix){var d=(a._eventSourceImportPrefix||"")+"EventSource",e=function(a,b){if(!a||"string"!=typeof a)throw new SyntaxError("Not enough arguments");this.URL=a,this.setOptions(b);var c=this;setTimeout(function(){c.poll()},0)};if(e.prototype={CONNECTING:0,OPEN:1,CLOSED:2,defaultOptions:{loggingEnabled:!1,loggingPrefix:"eventsource",interval:500,bufferSizeLimit:262144,silentTimeout:3e5,getArgs:{evs_buffer_size_limit:262144},xhrHeaders:{Accept:"text/event-stream","Cache-Control":"no-cache","X-Requested-With":"XMLHttpRequest"}},setOptions:function(a){var b,c=this.defaultOptions;for(b in c)c.hasOwnProperty(b)&&(this[b]=c[b]);for(b in a)b in c&&a.hasOwnProperty(b)&&(this[b]=a[b]);this.getArgs&&this.bufferSizeLimit&&(this.getArgs.evs_buffer_size_limit=this.bufferSizeLimit),("undefined"==typeof console||"undefined"==typeof console.log)&&(this.loggingEnabled=!1)},log:function(a){this.loggingEnabled&&console.log("["+this.loggingPrefix+"]:"+a)},poll:function(){try{if(this.readyState==this.CLOSED)return;this.cleanup(),this.readyState=this.CONNECTING,this.cursor=0,this.cache="",this._xhr=new this.XHR(this),this.resetNoActivityTimer()}catch(a){this.log("There were errors inside the pool try-catch"),this.dispatchEvent("error",{type:"error",data:a.message})}},pollAgain:function(a){var b=this;b.readyState=b.CONNECTING,b.dispatchEvent("error",{type:"error",data:"Reconnecting "}),this._pollTimer=setTimeout(function(){b.poll()},a||0)},cleanup:function(){this.log("evs cleaning up"),this._pollTimer&&(clearInterval(this._pollTimer),this._pollTimer=null),this._noActivityTimer&&(clearInterval(this._noActivityTimer),this._noActivityTimer=null),this._xhr&&(this._xhr.abort(),this._xhr=null)},resetNoActivityTimer:function(){if(this.silentTimeout){this._noActivityTimer&&clearInterval(this._noActivityTimer);var a=this;this._noActivityTimer=setTimeout(function(){a.log("Timeout! silentTImeout:"+a.silentTimeout),a.pollAgain()},this.silentTimeout)}},close:function(){this.readyState=this.CLOSED,this.log("Closing connection. readyState: "+this.readyState),this.cleanup()},_onxhrdata:function(){var a=this._xhr;if(a.isReady()&&!a.hasError()){this.resetNoActivityTimer(),this.readyState==this.CONNECTING&&(this.readyState=this.OPEN,this.dispatchEvent("open",{type:"open"}));var b=a.getBuffer();b.length>this.bufferSizeLimit&&(this.log("buffer.length > this.bufferSizeLimit"),this.pollAgain()),0==this.cursor&&b.length>0&&""==b.substring(0,1)&&(this.cursor=1);var c=this.lastMessageIndex(b);if(c[0]>=this.cursor){var d=c[1],e=b.substring(this.cursor,d);this.parseStream(e),this.cursor=d}a.isDone()&&(this.log("request.isDone(). reopening the connection"),this.pollAgain(this.interval))}else this.readyState!==this.CLOSED&&(this.log("this.readyState !== this.CLOSED"),this.pollAgain(this.interval))},parseStream:function(a){a=this.cache+this.normalizeToLF(a);var c,d,e,f,g,h,i=a.split("\n\n");for(c=0;c=0;--d)if(c[d]===b){c.splice(d,1);break}},_pollTimer:null,_noactivityTimer:null,_xhr:null,lastEventId:null,cache:"",cursor:0,onerror:null,onmessage:null,onopen:null,readyState:0,urlWithParams:function(a,b){var c=[];if(b){var d,e,f=encodeURIComponent;for(d in b)b.hasOwnProperty(d)&&(e=f(d)+"="+f(b[d]),c.push(e))}return c.length>0?-1==a.indexOf("?")?a+"?"+c.join("&"):a+"&"+c.join("&"):a},lastMessageIndex:function(a){var b=a.lastIndexOf("\n\n"),c=a.lastIndexOf("\r\r"),d=a.lastIndexOf("\r\n\r\n");return d>Math.max(b,c)?[d,d+4]:[Math.max(b,c),Math.max(b,c)+2]},trimWhiteSpace:function(a){var b=/^(\s|\u00A0)+|(\s|\u00A0)+$/g;return a.replace(b,"")},normalizeToLF:function(a){return a.replace(/\r\n|\r/g,"\n")}},c()){e.isPolyfill="IE_8-9";var f=e.prototype.defaultOptions;f.xhrHeaders=null,f.getArgs.evs_preamble=2056,e.prototype.XHR=function(a){request=new XDomainRequest,this._request=request,request.onprogress=function(){request._ready=!0,a._onxhrdata()},request.onload=function(){this._loaded=!0,a._onxhrdata()},request.onerror=function(){this._failed=!0,a.readyState=a.CLOSED,a.dispatchEvent("error",{type:"error",data:"XDomainRequest error"})},request.ontimeout=function(){this._failed=!0,a.readyState=a.CLOSED,a.dispatchEvent("error",{type:"error",data:"XDomainRequest timed out"})};var b={};if(a.getArgs){var c=a.getArgs;for(var d in c)c.hasOwnProperty(d)&&(b[d]=c[d]);a.lastEventId&&(b.evs_last_event_id=a.lastEventId)}request.open("GET",a.urlWithParams(a.URL,b)),request.send()},e.prototype.XHR.prototype={useXDomainRequest:!0,_request:null,_ready:!1,_loaded:!1,_failed:!1,isReady:function(){return this._request._ready},isDone:function(){return this._request._loaded},hasError:function(){return this._request._failed},getBuffer:function(){var a="";try{a=this._request.responseText||""}catch(b){}return a},abort:function(){this._request&&this._request.abort()}}}else e.isPolyfill="XHR",e.prototype.XHR=function(a){request=new XMLHttpRequest,this._request=request,a._xhr=this,request.onreadystatechange=function(){request.readyState>1&&a.readyState!=a.CLOSED&&(200==request.status||request.status>=300&&request.status<400?a._onxhrdata():(request._failed=!0,a.readyState=a.CLOSED,a.dispatchEvent("error",{type:"error",data:"The server responded with "+request.status}),a.close()))},request.onprogress=function(){},request.open("GET",a.urlWithParams(a.URL,a.getArgs),!0);var b=a.xhrHeaders;for(var c in b)b.hasOwnProperty(c)&&request.setRequestHeader(c,b[c]);a.lastEventId&&request.setRequestHeader("Last-Event-Id",a.lastEventId),request.send()},e.prototype.XHR.prototype={useXDomainRequest:!1,_request:null,_failed:!1,isReady:function(){return this._request.readyState>=2},isDone:function(){return 4==this._request.readyState},hasError:function(){return this._failed||this._request.status>=400},getBuffer:function(){var a="";try{a=this._request.responseText||""}catch(b){}return a},abort:function(){this._request&&this._request.abort()}};a[d]=e}}(this); \ No newline at end of file +!function(a){function b(a,b,c,d){this.bubbles=!1,this.cancelBubble=!1,this.cancelable=!1,this.data=b||null,this.origin=c||"",this.lastEventId=d||"",this.type=a||"message"}function c(){return!(!window.XDomainRequest||!window.XMLHttpRequest||void 0!==(new XMLHttpRequest).responseType)}if(!a.EventSource||a._eventSourceImportPrefix){var d=(a._eventSourceImportPrefix||"")+"EventSource",e=function(a,b){if(!a||"string"!=typeof a)throw new SyntaxError("Not enough arguments");this.URL=a,this.setOptions(b);var c=this;setTimeout(function(){c.poll()},0)};if(e.prototype={CONNECTING:0,OPEN:1,CLOSED:2,defaultOptions:{loggingEnabled:!1,loggingPrefix:"eventsource",interval:500,bufferSizeLimit:262144,silentTimeout:3e5,getArgs:{evs_buffer_size_limit:262144},xhrHeaders:{Accept:"text/event-stream","Cache-Control":"no-cache","X-Requested-With":"XMLHttpRequest"}},setOptions:function(a){var b,c=this.defaultOptions;for(b in c)c.hasOwnProperty(b)&&(this[b]=c[b]);for(b in a)b in c&&a.hasOwnProperty(b)&&(this[b]=a[b]);this.getArgs&&this.bufferSizeLimit&&(this.getArgs.evs_buffer_size_limit=this.bufferSizeLimit),"undefined"!=typeof console&&void 0!==console.log||(this.loggingEnabled=!1)},log:function(a){this.loggingEnabled&&console.log("["+this.loggingPrefix+"]:"+a)},poll:function(){try{if(this.readyState==this.CLOSED)return;this.cleanup(),this.readyState=this.CONNECTING,this.cursor=0,this.cache="",this._xhr=new this.XHR(this),this.resetNoActivityTimer()}catch(a){this.log("There were errors inside the pool try-catch"),this.dispatchEvent("error",{type:"error",data:a.message})}},pollAgain:function(a){var b=this;b.readyState=b.CONNECTING,b.dispatchEvent("error",{type:"error",data:"Reconnecting "}),this._pollTimer=setTimeout(function(){b.poll()},a||0)},cleanup:function(){this.log("evs cleaning up"),this._pollTimer&&(clearInterval(this._pollTimer),this._pollTimer=null),this._noActivityTimer&&(clearInterval(this._noActivityTimer),this._noActivityTimer=null),this._xhr&&(this._xhr.abort(),this._xhr=null)},resetNoActivityTimer:function(){if(this.silentTimeout){this._noActivityTimer&&clearInterval(this._noActivityTimer);var a=this;this._noActivityTimer=setTimeout(function(){a.log("Timeout! silentTImeout:"+a.silentTimeout),a.pollAgain()},this.silentTimeout)}},close:function(){this.readyState=this.CLOSED,this.log("Closing connection. readyState: "+this.readyState),this.cleanup()},_onxhrdata:function(){var a=this._xhr;if(a.isReady()&&!a.hasError()){this.resetNoActivityTimer(),this.readyState==this.CONNECTING&&(this.readyState=this.OPEN,this.dispatchEvent("open",{type:"open"}));var b=a.getBuffer();b.length>this.bufferSizeLimit&&(this.log("buffer.length > this.bufferSizeLimit"),this.pollAgain()),0==this.cursor&&b.length>0&&"\ufeff"==b.substring(0,1)&&(this.cursor=1);var c=this.lastMessageIndex(b);if(c[0]>=this.cursor){var d=c[1],e=b.substring(this.cursor,d);this.parseStream(e),this.cursor=d}a.isDone()&&(this.log("request.isDone(). reopening the connection"),this.pollAgain(this.interval))}else this.readyState!==this.CLOSED&&(this.log("this.readyState !== this.CLOSED"),this.pollAgain(this.interval))},parseStream:function(a){a=this.cache+this.normalizeToLF(a);var c,d,e,f,g,h,i=a.split("\n\n");for(c=0;c=0;--d)if(c[d]===b){c.splice(d,1);break}},_pollTimer:null,_noactivityTimer:null,_xhr:null,lastEventId:null,cache:"",cursor:0,onerror:null,onmessage:null,onopen:null,readyState:0,urlWithParams:function(a,b){var c=[];if(b){var d,e,f=encodeURIComponent;for(d in b)b.hasOwnProperty(d)&&(e=f(d)+"="+f(b[d]),c.push(e))}return c.length>0?-1==a.indexOf("?")?a+"?"+c.join("&"):a+"&"+c.join("&"):a},lastMessageIndex:function(a){var b=a.lastIndexOf("\n\n"),c=a.lastIndexOf("\r\r"),d=a.lastIndexOf("\r\n\r\n");return d>Math.max(b,c)?[d,d+4]:[Math.max(b,c),Math.max(b,c)+2]},trimWhiteSpace:function(a){var b=/^(\s|\u00A0)+|(\s|\u00A0)+$/g;return a.replace(b,"")},normalizeToLF:function(a){return a.replace(/\r\n|\r/g,"\n")}},c()){e.isPolyfill="IE_8-9";var f=e.prototype.defaultOptions;f.xhrHeaders=null,f.getArgs.evs_preamble=2056,e.prototype.XHR=function(a){request=new XDomainRequest,this._request=request,request.onprogress=function(){request._ready=!0,a._onxhrdata()},request.onload=function(){this._loaded=!0,a._onxhrdata()},request.onerror=function(){this._failed=!0,a.readyState=a.CLOSED,a.dispatchEvent("error",{type:"error",data:"XDomainRequest error"})},request.ontimeout=function(){this._failed=!0,a.readyState=a.CLOSED,a.dispatchEvent("error",{type:"error",data:"XDomainRequest timed out"})};var b={};if(a.getArgs){var c=a.getArgs;for(var d in c)c.hasOwnProperty(d)&&(b[d]=c[d]);a.lastEventId&&(b.evs_last_event_id=a.lastEventId)}request.open("GET",a.urlWithParams(a.URL,b)),request.send()},e.prototype.XHR.prototype={useXDomainRequest:!0,_request:null,_ready:!1,_loaded:!1,_failed:!1,isReady:function(){return this._request._ready},isDone:function(){return this._request._loaded},hasError:function(){return this._request._failed},getBuffer:function(){var a="";try{a=this._request.responseText||""}catch(a){}return a},abort:function(){this._request&&this._request.abort()}}}else e.isPolyfill="XHR",e.prototype.XHR=function(a){request=new XMLHttpRequest,this._request=request,a._xhr=this,request.onreadystatechange=function(){request.readyState>1&&a.readyState!=a.CLOSED&&(200==request.status||request.status>=300&&request.status<400?a._onxhrdata():(request._failed=!0,a.readyState=a.CLOSED,a.dispatchEvent("error",{type:"error",data:"The server responded with "+request.status}),a.close()))},request.onprogress=function(){},request.open("GET",a.urlWithParams(a.URL,a.getArgs),!0);var b=a.xhrHeaders;for(var c in b)b.hasOwnProperty(c)&&request.setRequestHeader(c,b[c]);a.lastEventId&&request.setRequestHeader("Last-Event-Id",a.lastEventId),request.send()},e.prototype.XHR.prototype={useXDomainRequest:!1,_request:null,_failed:!1,isReady:function(){return this._request.readyState>=2},isDone:function(){return 4==this._request.readyState},hasError:function(){return this._failed||this._request.status>=400},getBuffer:function(){var a="";try{a=this._request.responseText||""}catch(a){}return a},abort:function(){this._request&&this._request.abort()}};a[d]=e}}(this); \ No newline at end of file diff --git a/package.json b/package.json index a47a19e..85c2283 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,9 @@ "version": "0.9.8", "description": "A browser polyfill for W3C EventSource (http://www.w3.org/TR/eventsource/). This is fork containg fixes. Original work can be found here: https://github.com/amvtek/EventSource.git ", "main": "dist/browserify-eventsource.js", - "directories": { "doc": "docs" }, + "directories": { + "doc": "docs" + }, "files": [ "dist/eventsource.js", "dist/browserify-eventsource.js" @@ -29,7 +31,7 @@ }, "homepage": "https://github.com/zabrowarnyrafal/EventSource", "devDependencies": { - "grunt": "^0.4.5", + "grunt": "^1.0.1", "grunt-contrib-uglify": "^0.6.0", "grunt-string-replace": "^1.0.0" } From 7d1015afc97b0777bcf4c8d4b98d88e472c9ce4f Mon Sep 17 00:00:00 2001 From: lamprez Date: Tue, 3 Oct 2017 21:59:00 +0000 Subject: [PATCH 5/6] update npm package name to be unique and reflect made changes --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 85c2283..8cecb38 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "eventsource-polyfill", + "name": "eventsource-polyfill-bugfixes", "version": "0.9.8", "description": "A browser polyfill for W3C EventSource (http://www.w3.org/TR/eventsource/). This is fork containg fixes. Original work can be found here: https://github.com/amvtek/EventSource.git ", "main": "dist/browserify-eventsource.js", From 9bf2d7201bb4409a62161ed21d3c19fe7a3f1a9a Mon Sep 17 00:00:00 2001 From: lamprez Date: Thu, 5 Oct 2017 08:00:00 +0000 Subject: [PATCH 6/6] fix bower's metadata; require to exclude minified files from bower's package --- bower.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index e43f00e..39e3328 100644 --- a/bower.json +++ b/bower.json @@ -1,11 +1,11 @@ { - "name": "eventsource-polyfill", - "homepage": "https://github.com/amvtek/EventSource", + "name": "eventsource-polyfill-bugfixes", + "homepage": "https://github.com/zabrowarnyrafal/EventSource", "authors": [ - "amvtek " + "zabrowarnyrafal " ], "description": "A polyfill for http://www.w3.org/TR/eventsource/", - "main": ["dist/eventsource.js", "dist/eventsource.min.js", "README.md"], + "main": "dist/eventsource.js", "keywords": [ "sse", "server sent events",