event-source-polyfill 1.0.26 → 1.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/eventsource.min.js +5 -5
package/package.json
CHANGED
package/src/eventsource.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/** @license
|
|
2
|
-
* eventsource.js
|
|
3
|
-
* Available under MIT License (MIT)
|
|
4
|
-
* https://github.com/Yaffle/EventSource/
|
|
5
|
-
*/
|
|
1
|
+
/** @license
|
|
2
|
+
* eventsource.js
|
|
3
|
+
* Available under MIT License (MIT)
|
|
4
|
+
* https://github.com/Yaffle/EventSource/
|
|
5
|
+
*/
|
|
6
6
|
!function(e){"use strict";var r,k=e.setTimeout,N=e.clearTimeout,j=e.XMLHttpRequest,o=e.XDomainRequest,t=e.ActiveXObject,n=e.EventSource,a=e.document,w=e.Promise,d=e.fetch,i=e.Response,h=e.TextDecoder,s=e.TextEncoder,p=e.AbortController;function u(){this.bitsNeeded=0,this.codePoint=0}"undefined"==typeof window||void 0===a||"readyState"in a||null!=a.body||(a.readyState="loading",window.addEventListener("load",function(e){a.readyState="complete"},!1)),null==j&&null!=t&&(j=function(){return new t("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==p&&(r=d,d=function(e,t){var n=t.signal;return r(e,{headers:t.headers,credentials:t.credentials,cache:t.cache}).then(function(e){var t=e.body.getReader();return n._reader=t,n._aborted&&n._reader.cancel(),{status:e.status,statusText:e.statusText,headers:e.headers,body:{getReader:function(){return t}}}})},p=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}),u.prototype.decode=function(e){function t(e,t,n){if(1===n)return 128>>t<=e&&e<<t<=2047;if(2===n)return 2048>>t<=e&&e<<t<=55295||57344>>t<=e&&e<<t<=65535;if(3===n)return 65536>>t<=e&&e<<t<=1114111;throw new Error}function n(e,t){if(6===e)return 15<t>>6?3:31<t?2:1;if(12===e)return 15<t?3:2;if(18===e)return 3;throw new Error}for(var r="",o=this.bitsNeeded,a=this.codePoint,i=0;i<e.length;i+=1){var s=e[i];0!==o&&(s<128||191<s||!t(a<<6|63&s,o-6,n(o,a)))&&(o=0,a=65533,r+=String.fromCharCode(a)),0===o?(a=0<=s&&s<=127?(o=0,s):192<=s&&s<=223?(o=6,31&s):224<=s&&s<=239?(o=12,15&s):240<=s&&s<=247?(o=18,7&s):(o=0,65533),0===o||t(a,o,n(o,a))||(o=0,a=65533)):(o-=6,a=a<<6|63&s),0===o&&(a<=65535?r+=String.fromCharCode(a):r=(r+=String.fromCharCode(55296+(a-65535-1>>10)))+String.fromCharCode(56320+(a-65535-1&1023)))}return this.bitsNeeded=o,this.codePoint=a,r};function l(){}null!=h&&null!=s&&function(){try{return"test"===(new h).decode((new s).encode("test"),{stream:!0})}catch(e){}return!1}()||(h=u);function H(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=l,this.onload=l,this.onerror=l,this.onreadystatechange=l,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=l}function c(e){return e.replace(/[A-Z]/g,function(e){return String.fromCharCode(e.charCodeAt(0)+32)})}function f(e){for(var t=Object.create(null),n=e.split("\r\n"),r=0;r<n.length;r+=1){var o=n[r].split(": "),a=o.shift(),o=o.join(": ");t[c(a)]=o}this._map=t}function I(){}function y(e){this._headers=e}function P(){}function M(){this._listeners=Object.create(null)}function m(e){k(function(){throw e},0)}function v(e){this.type=e,this.target=void 0}function F(e,t){v.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function q(e,t){v.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function Q(e,t){v.call(this,e),this.error=t.error}H.prototype.open=function(e,t){this._abort(!0);var o=this,a=this._xhr,i=1,n=0,r=(this._abort=function(e){0!==o._sendTimeout&&(N(o._sendTimeout),o._sendTimeout=0),1!==i&&2!==i&&3!==i||(i=4,a.onload=l,a.onerror=l,a.onabort=l,a.onprogress=l,a.onreadystatechange=l,a.abort(),0!==n&&(N(n),n=0),e||(o.readyState=4,o.onabort(null),o.onreadystatechange())),i=0},function(){if(1===i){var t=0,n="",r=void 0;if("contentType"in a)t=200,n="OK",r=a.contentType;else try{t=a.status,n=a.statusText,r=a.getResponseHeader("Content-Type")}catch(e){n="",r=void(t=0)}0!==t&&(i=2,o.readyState=2,o.status=t,o.statusText=n,o._contentType=r,o.onreadystatechange())}}),s=function(){if(r(),2===i||3===i){i=3;var e="";try{e=a.responseText}catch(e){}o.readyState=3,o.responseText=e,o.onprogress()}},u=function(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:l}),s(),1===i||2===i||3===i){if(i=4,0!==n&&(N(n),n=0),o.readyState=4,"load"===e)o.onload(t);else if("error"===e)o.onerror(t);else{if("abort"!==e)throw new TypeError;o.onabort(t)}o.onreadystatechange()}},c=function(){n=k(function(){c()},500),3===a.readyState&&s()};"onload"in a&&(a.onload=function(e){u("load",e)}),"onerror"in a&&(a.onerror=function(e){u("error",e)}),"onabort"in a&&(a.onabort=function(e){u("abort",e)}),"onprogress"in a&&(a.onprogress=s),"onreadystatechange"in a&&(a.onreadystatechange=function(e){e=e,null!=a&&(4===a.readyState?"onload"in a&&"onerror"in a&&"onabort"in a||u(""===a.responseText?"error":"load",e):3===a.readyState?"onprogress"in a||s():2===a.readyState&&r())}),!("contentType"in a)&&"ontimeout"in j.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),a.open(e,t,!0),"readyState"in a&&(n=k(function(){c()},0))},H.prototype.abort=function(){this._abort(!1)},H.prototype.getResponseHeader=function(e){return this._contentType},H.prototype.setRequestHeader=function(e,t){var n=this._xhr;"setRequestHeader"in n&&n.setRequestHeader(e,t)},H.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},H.prototype.send=function(){var e;if("ontimeout"in j.prototype&&("sendAsBinary"in j.prototype||"mozAnon"in j.prototype)||null==a||null==a.readyState||"complete"===a.readyState){var t=this._xhr;"withCredentials"in t&&(t.withCredentials=this.withCredentials);try{t.send(void 0)}catch(e){throw e}}else(e=this)._sendTimeout=k(function(){e._sendTimeout=0,e.send()},4)},f.prototype.get=function(e){return this._map[c(e)]},null!=j&&null==j.HEADERS_RECEIVED&&(j.HEADERS_RECEIVED=2),I.prototype.open=function(o,a,t,n,e,r,i){o.open("GET",e);var s,u=0;for(s in o.onprogress=function(){var e=o.responseText.slice(u);u+=e.length,t(e)},o.onerror=function(e){e.preventDefault(),n(new Error("NetworkError"))},o.onload=function(){n(null)},o.onabort=function(){n(null)},o.onreadystatechange=function(){var e,t,n,r;o.readyState===j.HEADERS_RECEIVED&&(e=o.status,t=o.statusText,n=o.getResponseHeader("Content-Type"),r=o.getAllResponseHeaders(),a(e,t,n,new f(r)))},o.withCredentials=r,i)Object.prototype.hasOwnProperty.call(i,s)&&o.setRequestHeader(s,i[s]);return o.send(),o},y.prototype.get=function(e){return this._headers.get(e)},P.prototype.open=function(e,t,o,n,r,a,i){var s=null,u=new p,c=u.signal,l=new h;return d(r,{headers:i,credentials:a?"include":"same-origin",signal:c,cache:"no-store"}).then(function(e){return s=e.body.getReader(),t(e.status,e.statusText,e.headers.get("Content-Type"),new y(e.headers)),new w(function(t,n){function r(){s.read().then(function(e){e.done?t(void 0):(e=l.decode(e.value,{stream:!0}),o(e),r())}).catch(function(e){n(e)})}r()})}).catch(function(e){if("AbortError"!==e.name)return e}).then(function(e){n(e)}),{abort:function(){null!=s&&s.cancel(),u.abort()}}},M.prototype.dispatchEvent=function(e){var t=(e.target=this)._listeners[e.type];if(null!=t)for(var n=t.length,r=0;r<n;r+=1){var o=t[r];try{"function"==typeof o.handleEvent?o.handleEvent(e):o.call(this,e)}catch(e){m(e)}}},M.prototype.addEventListener=function(e,t){e=String(e);for(var n=this._listeners,r=n[e],o=(null==r&&(n[e]=r=[]),!1),a=0;a<r.length;a+=1)r[a]===t&&(o=!0);o||r.push(t)},M.prototype.removeEventListener=function(e,t){e=String(e);var n=this._listeners,r=n[e];if(null!=r){for(var o=[],a=0;a<r.length;a+=1)r[a]!==t&&o.push(r[a]);0===o.length?delete n[e]:n[e]=o}},F.prototype=Object.create(v.prototype),q.prototype=Object.create(v.prototype),Q.prototype=Object.create(v.prototype);var L=-1,K=0,V=1,z=2,U=-1,X=0,B=1,W=2,$=3,J=/^text\/event\-stream(;.*)?$/i,b=1e3,E=18e6,G=function(e,t){e=null==e?t:parseInt(e,10);return Y(e=e!=e?t:e)},Y=function(e){return Math.min(Math.max(e,b),E)},Z=function(e,t,n){try{"function"==typeof t&&t.call(e,n)}catch(e){m(e)}};function g(e,t){function a(e,t,n,r){var o;E===K&&(200===e&&null!=n&&J.test(n)?(E=V,y=Date.now(),f=d,u.readyState=V,o=new q("open",{status:e,statusText:t,headers:r}),u.dispatchEvent(o),Z(u,u.onopen,o)):(200!==e?t=t&&t.replace(/\s+/g," "):null!=n&&n.replace(/\s+/g," "),R(),o=new q("error",{status:e,statusText:t,headers:r}),u.dispatchEvent(o),Z(u,u.onerror,o)))}function i(e){if(E===V){for(var t=-1,n=0;n<e.length;n+=1)(i=e.charCodeAt(n))!=="\n".charCodeAt(0)&&i!=="\r".charCodeAt(0)||(t=n);var r=(-1!==t?S:"")+e.slice(0,t+1);S=(-1===t?S:"")+e.slice(t+1),""!==e&&(y=Date.now(),v+=e.length);for(var o=0;o<r.length;o+=1){var a,i=r.charCodeAt(o);if(_===U&&i==="\n".charCodeAt(0))_=X;else if(_===U&&(_=X),i==="\r".charCodeAt(0)||i==="\n".charCodeAt(0)){if(_!==X&&(_===B&&(O=o+1),s=r.slice(x,O-1),a=r.slice(O+(O<o&&r.charCodeAt(O)===" ".charCodeAt(0)?1:0),o),"data"===s?T=T+"\n"+a:"id"===s?C=a:"event"===s?A=a:"retry"===s?(d=G(a,d),f=d):"heartbeatTimeout"===s&&(h=G(a,h),0!==b&&(N(b),b=k(function(){D()},h)))),_===X){if(""!==T){p=C;var s=new F(A=""===A?"message":A,{data:T.slice(1),lastEventId:C});if(u.dispatchEvent(s),"open"===A?Z(u,u.onopen,s):"message"===A?Z(u,u.onmessage,s):"error"===A&&Z(u,u.onerror,s),E===z)return}A=T=""}_=i==="\r".charCodeAt(0)?U:X}else _===X&&(x=o,_=B),_===B?i===":".charCodeAt(0)&&(O=o+1,_=W):_===W&&(_=$)}}}function s(e){E!==V&&E!==K||(E=L,0!==b&&(N(b),b=0),b=k(function(){D()},f),f=Y(Math.min(16*d,2*f)),u.readyState=K,e=new Q("error",{error:e}),u.dispatchEvent(e),Z(u,u.onerror,e))}var u,c,l,d,h,p,f,y,v,n,g,w,m,b,E,T,C,A,S,_,x,O,R,D;M.call(this),t=t||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,u=this,c=e,e=t,c=String(c),t=Boolean(e.withCredentials),l=e.lastEventIdQueryParameterName||"lastEventId",d=Y(1e3),h=G(e.heartbeatTimeout,45e3),p="",f=d,y=!1,v=0,n=e.headers||{},e=e.Transport,g=ee&&null==e?void 0:new H(new(null!=e?e:null!=j&&"withCredentials"in j.prototype||null==o?j:o)),w=new(null!=e&&"string"!=typeof e?e:null==g?P:I),m=void 0,E=L,S=A=C=T="",_=X,O=x=b=0,R=function(){E=z,null!=m&&(m.abort(),m=void 0),0!==b&&(N(b),b=0),u.readyState=z},D=function(){if(b=0,E!==L)y||null==m?(e=Math.max((y||Date.now())+h-Date.now(),1),y=!1,b=k(function(){D()},e)):(s(new Error("No activity within "+h+" milliseconds. "+(E===K?"No response received.":v+" chars received.")+" Reconnecting.")),null!=m&&(m.abort(),m=void 0));else{y=!1,v=0,b=k(function(){D()},h),E=K,C=p,S=A=T="",O=x=0,_=X;var e=c,t=("data:"!==c.slice(0,5)&&"blob:"!==c.slice(0,5)&&""!==p&&(e=-1===(t=c.indexOf("?"))?c:c.slice(0,t+1)+c.slice(t+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,function(e,t){return t===l?"":e}),e+=(-1===c.indexOf("?")?"?":"&")+l+"="+encodeURIComponent(p)),u.withCredentials),n={Accept:"text/event-stream"},r=u.headers;if(null!=r)for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o]);try{m=w.open(g,a,i,s,e,t,n)}catch(e){throw R(),e}}},u.url=c,u.readyState=K,u.withCredentials=t,u.headers=n,u._close=R,D()}var ee=null!=d&&null!=i&&"body"in i.prototype;(g.prototype=Object.create(M.prototype)).CONNECTING=K,g.prototype.OPEN=V,g.prototype.CLOSED=z,g.prototype.close=function(){this._close()},g.CONNECTING=K,g.OPEN=V,g.CLOSED=z,g.prototype.withCredentials=void 0;var T=n;null==j||null!=n&&"withCredentials"in n.prototype||(T=g),k(function(){var e,t;-1!==["Asia/Anadyr","Asia/Barnaul","Asia/Chita","Asia/Irkutsk","Asia/Kamchatka","Asia/Khandyga","Asia/Krasnoyarsk","Asia/Magadan","Asia/Novokuznetsk","Asia/Novosibirsk","Asia/Omsk","Asia/Sakhalin","Asia/Srednekolymsk","Asia/Tomsk","Asia/Ust-Nera","Asia/Vladivostok","Asia/Yakutsk","Asia/Yekaterinburg","Europe/Astrakhan","Europe/Kaliningrad","Europe/Kirov","Europe/Moscow","Europe/Samara","Europe/Saratov","Europe/Simferopol","Europe/Ulyanovsk","Europe/Volgograd","W-SU"].indexOf((new Intl.DateTimeFormat).resolvedOptions().timeZone)&&(t=function(e){return"[97m[1m"+e+"[22m[37m"},t=["",(e=function(){return"🇷🇺 🇺🇦 🇷🇺 🇺🇦 🇷🇺 🇺🇦 🇷🇺 🇺🇦 🇷🇺 🇺🇦 🇷🇺 🇺🇦 🇷🇺 🇺🇦 🇷🇺 🇺🇦 🇷🇺 🇺🇦 🇷🇺 🇺🇦 🇷🇺 🇺🇦 🇷🇺 🇺🇦 🇷🇺 🇺🇦"})(),"","[37m24 февраля "+t("Россия напала на Украину")+".","","Народ Украины всеобще мобилизован и готов защищать свою страну от вражеского вторжения. "+t("91% украинцев полностью поддерживает своего президента Владимира Зеленского")+" и его ответные действия на нападение России.","","Весь мир осудил необоснованное вторжение и решил ввести "+t("невиданные ранее санкции против России")+". С каждым новым днем они будут ощущаться все сильнее и сильнее среди мирных граждан.","","В то же время, "+t("российское правительство ограничивает доступ граждан к внешней информации")+", насаждая однобокие формулировки и версии происходящего.","","В качестве надежного источника информации загрузите безопасный браузер Tor:","",t("https://www.torproject.org/"),"","И посетите:","",t("https://www.bbcweb3hytmzhn5d532owbu6oqadra5z3ar726vq5kgwwn6aucdccrad.onion/russian"),"",e(),"",t("Прекратите эту бессмысленную войну! Остановите военного преступника Путина!")+"[39m","",e(),""].join("\n"),alert(t),window.open("http://www.change.org/NetVoyne"))},15e3),i=function(e){e.EventSourcePolyfill=g,e.NativeEventSource=n,e.EventSource=T},"object"==typeof module&&"object"==typeof module.exports?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i(e)}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:this:globalThis);
|