Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-sse

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-sse - npm Package Compare versions

Comparing version 2.0.2 to 2.1.0

15

dist/vue-sse.common.js
/*!
* vue-sse v2.0.2
* vue-sse v2.1.0
* (c) 2021 James Churchard

@@ -179,3 +179,14 @@ * @license MIT

SSEManager.prototype.create = function create (config) {
SSEManager.prototype.create = function create (configOrURL) {
var config;
if (typeof configOrURL === 'object') {
config = configOrURL;
} else if (typeof configOrURL === 'string') {
config = {
url: configOrURL,
};
} else {
config = {};
}
return new SSEClient(Object.assign({}, this.$defaultConfig, config));

@@ -182,0 +193,0 @@ };

/*!
* vue-sse v2.0.2
* vue-sse v2.1.0
* (c) 2021 James Churchard

@@ -170,3 +170,14 @@ * @license MIT

create(config) {
create(configOrURL) {
let config;
if (typeof configOrURL === 'object') {
config = configOrURL;
} else if (typeof configOrURL === 'string') {
config = {
url: configOrURL,
};
} else {
config = {};
}
return new SSEClient(Object.assign({}, this.$defaultConfig, config));

@@ -173,0 +184,0 @@ }

4

dist/vue-sse.esm.browser.min.js
/*!
* vue-sse v2.0.2
* vue-sse v2.1.0
* (c) 2021 James Churchard
* @license MIT
*/
const e=e=>e.data,t=e=>JSON.parse(e.data);class n{constructor(n){if(this._handlers={},this._listeners={},this._source=null,n.format?"string"==typeof n.format?"plain"===n.format?this._format=e:"json"===n.format?this._format=t:this._format=e:"function"==typeof n.format?this._format=n.format:this._format=e:this._format=e,n.handlers)for(const e in n.handlers)this.on(e,n.handlers[e]);this.url=n.url,this.withCredentials=!!n.withCredentials}get source(){return this._source}connect(){return this._source=new window.EventSource(this.url,{withCredentials:this.withCredentials}),new Promise(((e,t)=>{this._source.onopen=()=>{for(let e in this._listeners)this._source.addEventListener(e,this._listeners[e]);this._source.onerror=null,e(this)},this._source.onerror=t}))}disconnect(){null!==this._source&&(this._source.close(),this._source=null)}on(e,t){return e||(e="message"),this._listeners[e]||this._create(e),this._handlers[e].push(t),this}once(e,t){return this.on(e,(n=>{this.off(e,t),t(n)})),this}off(e,t){if(!this._handlers[e])return this;const n=this._handlers[e].indexOf(t);return-1===n||(this._handlers[e].splice(n,1),0===this._handlers[e].length&&(this._source.removeEventListener(e,this._listeners[e]),delete this._handlers[e],delete this._listeners[e])),this}_create(e){this._handlers[e]=[],this._listeners[e]=t=>{let n;try{n=this._format(t)}catch(e){return void("function"==typeof this._source.onerror&&this._source.onerror(e))}this._handlers[e].forEach((e=>e(n)))},this._source&&this._source.addEventListener(e,this._listeners[e])}}function r(e,t){e.$sse=e.prototype.$sse=new o(t),t&&t.polyfill&&Promise.resolve().then((function(){return c}))}class o{constructor(t){this.$defaultConfig=Object.assign({format:e,sendCredentials:!1},t)}create(e){return new n(Object.assign({},this.$defaultConfig,e))}}var s={install:r},i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};
const e=e=>e.data,t=e=>JSON.parse(e.data);class n{constructor(n){if(this._handlers={},this._listeners={},this._source=null,n.format?"string"==typeof n.format?"plain"===n.format?this._format=e:"json"===n.format?this._format=t:this._format=e:"function"==typeof n.format?this._format=n.format:this._format=e:this._format=e,n.handlers)for(const e in n.handlers)this.on(e,n.handlers[e]);this.url=n.url,this.withCredentials=!!n.withCredentials}get source(){return this._source}connect(){return this._source=new window.EventSource(this.url,{withCredentials:this.withCredentials}),new Promise(((e,t)=>{this._source.onopen=()=>{for(let e in this._listeners)this._source.addEventListener(e,this._listeners[e]);this._source.onerror=null,e(this)},this._source.onerror=t}))}disconnect(){null!==this._source&&(this._source.close(),this._source=null)}on(e,t){return e||(e="message"),this._listeners[e]||this._create(e),this._handlers[e].push(t),this}once(e,t){return this.on(e,(n=>{this.off(e,t),t(n)})),this}off(e,t){if(!this._handlers[e])return this;const n=this._handlers[e].indexOf(t);return-1===n||(this._handlers[e].splice(n,1),0===this._handlers[e].length&&(this._source.removeEventListener(e,this._listeners[e]),delete this._handlers[e],delete this._listeners[e])),this}_create(e){this._handlers[e]=[],this._listeners[e]=t=>{let n;try{n=this._format(t)}catch(e){return void("function"==typeof this._source.onerror&&this._source.onerror(e))}this._handlers[e].forEach((e=>e(n)))},this._source&&this._source.addEventListener(e,this._listeners[e])}}function r(e,t){e.$sse=e.prototype.$sse=new o(t),t&&t.polyfill&&Promise.resolve().then((function(){return c}))}class o{constructor(t){this.$defaultConfig=Object.assign({format:e,sendCredentials:!1},t)}create(e){let t;return t="object"==typeof e?e:"string"==typeof e?{url:e}:{},new n(Object.assign({},this.$defaultConfig,t))}}var s={install:r},i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};
/** @license

@@ -8,0 +8,0 @@ * eventsource.js

/*!
* vue-sse v2.0.2
* vue-sse v2.1.0
* (c) 2021 James Churchard

@@ -177,3 +177,14 @@ * @license MIT

SSEManager.prototype.create = function create (config) {
SSEManager.prototype.create = function create (configOrURL) {
var config;
if (typeof configOrURL === 'object') {
config = configOrURL;
} else if (typeof configOrURL === 'string') {
config = {
url: configOrURL,
};
} else {
config = {};
}
return new SSEClient(Object.assign({}, this.$defaultConfig, config));

@@ -180,0 +191,0 @@ };

/*!
* vue-sse v2.0.2
* vue-sse v2.1.0
* (c) 2021 James Churchard

@@ -183,3 +183,14 @@ * @license MIT

SSEManager.prototype.create = function create (config) {
SSEManager.prototype.create = function create (configOrURL) {
var config;
if (typeof configOrURL === 'object') {
config = configOrURL;
} else if (typeof configOrURL === 'string') {
config = {
url: configOrURL,
};
} else {
config = {};
}
return new SSEClient(Object.assign({}, this.$defaultConfig, config));

@@ -186,0 +197,0 @@ };

/*!
* vue-sse v2.0.2
* vue-sse v2.1.0
* (c) 2021 James Churchard
* @license MIT
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VueSSE=t()}(this,(function(){"use strict";var e=function(e){return e.data},t=function(e){return JSON.parse(e.data)},n=function(n){if(this._handlers={},this._listeners={},this._source=null,n.format?"string"==typeof n.format?"plain"===n.format?this._format=e:"json"===n.format?this._format=t:this._format=e:"function"==typeof n.format?this._format=n.format:this._format=e:this._format=e,n.handlers)for(var r in n.handlers)this.on(r,n.handlers[r]);this.url=n.url,this.withCredentials=!!n.withCredentials},r={source:{configurable:!0}};r.source.get=function(){return this._source},n.prototype.connect=function(){var e=this;return this._source=new window.EventSource(this.url,{withCredentials:this.withCredentials}),new Promise((function(t,n){e._source.onopen=function(){for(var n in e._listeners)e._source.addEventListener(n,e._listeners[n]);e._source.onerror=null,t(e)},e._source.onerror=n}))},n.prototype.disconnect=function(){null!==this._source&&(this._source.close(),this._source=null)},n.prototype.on=function(e,t){return e||(e="message"),this._listeners[e]||this._create(e),this._handlers[e].push(t),this},n.prototype.once=function(e,t){var n=this;return this.on(e,(function(r){n.off(e,t),t(r)})),this},n.prototype.off=function(e,t){if(!this._handlers[e])return this;var n=this._handlers[e].indexOf(t);return-1===n||(this._handlers[e].splice(n,1),0===this._handlers[e].length&&(this._source.removeEventListener(e,this._listeners[e]),delete this._handlers[e],delete this._listeners[e])),this},n.prototype._create=function(e){var t=this;this._handlers[e]=[],this._listeners[e]=function(n){var r;try{r=t._format(n)}catch(e){return void("function"==typeof t._source.onerror&&t._source.onerror(e))}t._handlers[e].forEach((function(e){return e(r)}))},this._source&&this._source.addEventListener(e,this._listeners[e])},Object.defineProperties(n.prototype,r);var o=function(t){this.$defaultConfig=Object.assign({format:e,sendCredentials:!1},t)};o.prototype.create=function(e){return new n(Object.assign({},this.$defaultConfig,e))};var i={SSEManager:o,install:function(e,t){e.$sse=e.prototype.$sse=new o(t),t&&t.polyfill&&Promise.resolve().then((function(){return u}))}},s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VueSSE=t()}(this,(function(){"use strict";var e=function(e){return e.data},t=function(e){return JSON.parse(e.data)},n=function(n){if(this._handlers={},this._listeners={},this._source=null,n.format?"string"==typeof n.format?"plain"===n.format?this._format=e:"json"===n.format?this._format=t:this._format=e:"function"==typeof n.format?this._format=n.format:this._format=e:this._format=e,n.handlers)for(var r in n.handlers)this.on(r,n.handlers[r]);this.url=n.url,this.withCredentials=!!n.withCredentials},r={source:{configurable:!0}};r.source.get=function(){return this._source},n.prototype.connect=function(){var e=this;return this._source=new window.EventSource(this.url,{withCredentials:this.withCredentials}),new Promise((function(t,n){e._source.onopen=function(){for(var n in e._listeners)e._source.addEventListener(n,e._listeners[n]);e._source.onerror=null,t(e)},e._source.onerror=n}))},n.prototype.disconnect=function(){null!==this._source&&(this._source.close(),this._source=null)},n.prototype.on=function(e,t){return e||(e="message"),this._listeners[e]||this._create(e),this._handlers[e].push(t),this},n.prototype.once=function(e,t){var n=this;return this.on(e,(function(r){n.off(e,t),t(r)})),this},n.prototype.off=function(e,t){if(!this._handlers[e])return this;var n=this._handlers[e].indexOf(t);return-1===n||(this._handlers[e].splice(n,1),0===this._handlers[e].length&&(this._source.removeEventListener(e,this._listeners[e]),delete this._handlers[e],delete this._listeners[e])),this},n.prototype._create=function(e){var t=this;this._handlers[e]=[],this._listeners[e]=function(n){var r;try{r=t._format(n)}catch(e){return void("function"==typeof t._source.onerror&&t._source.onerror(e))}t._handlers[e].forEach((function(e){return e(r)}))},this._source&&this._source.addEventListener(e,this._listeners[e])},Object.defineProperties(n.prototype,r);var o=function(t){this.$defaultConfig=Object.assign({format:e,sendCredentials:!1},t)};o.prototype.create=function(e){var t;return t="object"==typeof e?e:"string"==typeof e?{url:e}:{},new n(Object.assign({},this.$defaultConfig,t))};var i={SSEManager:o,install:function(e,t){e.$sse=e.prototype.$sse=new o(t),t&&t.polyfill&&Promise.resolve().then((function(){return u}))}},s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};
/** @license

@@ -12,2 +12,2 @@ * eventsource.js

*/
var a=function(e){var t={exports:{}};return e(t,t.exports),t.exports}((function(e,t){!function(n){var r=n.setTimeout,o=n.clearTimeout,i=n.XMLHttpRequest,s=n.XDomainRequest,a=n.ActiveXObject,u=n.EventSource,c=n.document,l=n.Promise,d=n.fetch,h=n.Response,f=n.TextDecoder,p=n.TextEncoder,y=n.AbortController;if("undefined"==typeof window||"readyState"in c||null!=c.body||(c.readyState="loading",window.addEventListener("load",(function(e){c.readyState="complete"}),!1)),null==i&&null!=a&&(i=function(){return new a("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==y){var v=d;d=function(e,t){var n=t.signal;return v(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}}}}))},y=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function g(){this.bitsNeeded=0,this.codePoint=0}g.prototype.decode=function(e){function t(e,t,n){if(1===n)return e>=128>>t&&e<<t<=2047;if(2===n)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===n)return e>=65536>>t&&e<<t<=1114111;throw new Error}function n(e,t){if(6===e)return t>>6>15?3:t>31?2:1;if(12===e)return t>15?3:2;if(18===e)return 3;throw new Error}for(var r=65533,o="",i=this.bitsNeeded,s=this.codePoint,a=0;a<e.length;a+=1){var u=e[a];0!==i&&(u<128||u>191||!t(s<<6|63&u,i-6,n(i,s)))&&(i=0,s=r,o+=String.fromCharCode(s)),0===i?(u>=0&&u<=127?(i=0,s=u):u>=192&&u<=223?(i=6,s=31&u):u>=224&&u<=239?(i=12,s=15&u):u>=240&&u<=247?(i=18,s=7&u):(i=0,s=r),0===i||t(s,i,n(i,s))||(i=0,s=r)):(i-=6,s=s<<6|63&u),0===i&&(s<=65535?o+=String.fromCharCode(s):(o+=String.fromCharCode(55296+(s-65535-1>>10)),o+=String.fromCharCode(56320+(s-65535-1&1023))))}return this.bitsNeeded=i,this.codePoint=s,o};null!=f&&null!=p&&function(){try{return"test"===(new f).decode((new p).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1}()||(f=g);var _=function(){};function w(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=_,this.onload=_,this.onerror=_,this.onreadystatechange=_,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=_}function b(e){return e.replace(/[A-Z]/g,(function(e){return String.fromCharCode(e.charCodeAt(0)+32)}))}function m(e){for(var t=Object.create(null),n=e.split("\r\n"),r=0;r<n.length;r+=1){var o=n[r].split(": "),i=o.shift(),s=o.join(": ");t[b(i)]=s}this._map=t}function E(){}function C(e){this._headers=e}function T(){}function S(){this._listeners=Object.create(null)}function x(e){r((function(){throw e}),0)}function O(e){this.type=e,this.target=void 0}function A(e,t){O.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function R(e,t){O.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function D(e,t){O.call(this,e),this.error=t.error}w.prototype.open=function(e,t){this._abort(!0);var n=this,s=this._xhr,a=1,u=0;this._abort=function(e){0!==n._sendTimeout&&(o(n._sendTimeout),n._sendTimeout=0),1!==a&&2!==a&&3!==a||(a=4,s.onload=_,s.onerror=_,s.onabort=_,s.onprogress=_,s.onreadystatechange=_,s.abort(),0!==u&&(o(u),u=0),e||(n.readyState=4,n.onabort(null),n.onreadystatechange())),a=0};var c=function(){if(1===a){var e=0,t="",r=void 0;if("contentType"in s)e=200,t="OK",r=s.contentType;else try{e=s.status,t=s.statusText,r=s.getResponseHeader("Content-Type")}catch(n){e=0,t="",r=void 0}0!==e&&(a=2,n.readyState=2,n.status=e,n.statusText=t,n._contentType=r,n.onreadystatechange())}},l=function(){if(c(),2===a||3===a){a=3;var e="";try{e=s.responseText}catch(e){}n.readyState=3,n.responseText=e,n.onprogress()}},d=function(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:_}),l(),1===a||2===a||3===a){if(a=4,0!==u&&(o(u),u=0),n.readyState=4,"load"===e)n.onload(t);else if("error"===e)n.onerror(t);else{if("abort"!==e)throw new TypeError;n.onabort(t)}n.onreadystatechange()}},h=function(){u=r((function(){h()}),500),3===s.readyState&&l()};"onload"in s&&(s.onload=function(e){d("load",e)}),"onerror"in s&&(s.onerror=function(e){d("error",e)}),"onabort"in s&&(s.onabort=function(e){d("abort",e)}),"onprogress"in s&&(s.onprogress=l),"onreadystatechange"in s&&(s.onreadystatechange=function(e){!function(e){null!=s&&(4===s.readyState?"onload"in s&&"onerror"in s&&"onabort"in s||d(""===s.responseText?"error":"load",e):3===s.readyState?"onprogress"in s||l():2===s.readyState&&c())}(e)}),!("contentType"in s)&&"ontimeout"in i.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),s.open(e,t,!0),"readyState"in s&&(u=r((function(){h()}),0))},w.prototype.abort=function(){this._abort(!1)},w.prototype.getResponseHeader=function(e){return this._contentType},w.prototype.setRequestHeader=function(e,t){var n=this._xhr;"setRequestHeader"in n&&n.setRequestHeader(e,t)},w.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},w.prototype.send=function(){if("ontimeout"in i.prototype&&("sendAsBinary"in i.prototype||"mozAnon"in i.prototype)||null==c||null==c.readyState||"complete"===c.readyState){var e=this._xhr;"withCredentials"in e&&(e.withCredentials=this.withCredentials);try{e.send(void 0)}catch(e){throw e}}else{var t=this;t._sendTimeout=r((function(){t._sendTimeout=0,t.send()}),4)}},m.prototype.get=function(e){return this._map[b(e)]},null!=i&&null==i.HEADERS_RECEIVED&&(i.HEADERS_RECEIVED=2),E.prototype.open=function(e,t,n,r,o,s,a){e.open("GET",o);var u=0;for(var c in e.onprogress=function(){var t=e.responseText.slice(u);u+=t.length,n(t)},e.onerror=function(e){e.preventDefault(),r(new Error("NetworkError"))},e.onload=function(){r(null)},e.onabort=function(){r(null)},e.onreadystatechange=function(){if(e.readyState===i.HEADERS_RECEIVED){var n=e.status,r=e.statusText,o=e.getResponseHeader("Content-Type"),s=e.getAllResponseHeaders();t(n,r,o,new m(s))}},e.withCredentials=s,a)Object.prototype.hasOwnProperty.call(a,c)&&e.setRequestHeader(c,a[c]);return e.send(),e},C.prototype.get=function(e){return this._headers.get(e)},T.prototype.open=function(e,t,n,r,o,i,s){var a=null,u=new y,c=u.signal,h=new f;return d(o,{headers:s,credentials:i?"include":"same-origin",signal:c,cache:"no-store"}).then((function(e){return a=e.body.getReader(),t(e.status,e.statusText,e.headers.get("Content-Type"),new C(e.headers)),new l((function(e,t){var r=function(){a.read().then((function(t){if(t.done)e(void 0);else{var o=h.decode(t.value,{stream:!0});n(o),r()}})).catch((function(e){t(e)}))};r()}))})).catch((function(e){return"AbortError"===e.name?void 0:e})).then((function(e){r(e)})),{abort:function(){null!=a&&a.cancel(),u.abort()}}},S.prototype.dispatchEvent=function(e){e.target=this;var t=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){x(e)}}},S.prototype.addEventListener=function(e,t){e=String(e);var n=this._listeners,r=n[e];null==r&&(r=[],n[e]=r);for(var o=!1,i=0;i<r.length;i+=1)r[i]===t&&(o=!0);o||r.push(t)},S.prototype.removeEventListener=function(e,t){e=String(e);var n=this._listeners,r=n[e];if(null!=r){for(var o=[],i=0;i<r.length;i+=1)r[i]!==t&&o.push(r[i]);0===o.length?delete n[e]:n[e]=o}},A.prototype=Object.create(O.prototype),R.prototype=Object.create(O.prototype),D.prototype=Object.create(O.prototype);var j=-1,N=-1,H=/^text\/event\-stream(;.*)?$/i,P=function(e,t){var n=null==e?t:parseInt(e,10);return n!=n&&(n=t),I(n)},I=function(e){return Math.min(Math.max(e,1e3),18e6)},L=function(e,t,n){try{"function"==typeof t&&t.call(e,n)}catch(e){x(e)}};function M(e,t){S.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,function(e,t,n){t=String(t);var a=Boolean(n.withCredentials),u=n.lastEventIdQueryParameterName||"lastEventId",c=I(1e3),l=P(n.heartbeatTimeout,45e3),d="",h=c,f=!1,p=0,y=n.headers||{},v=n.Transport,g=q&&null==v?void 0:new w(null!=v?new v:null!=i&&"withCredentials"in i.prototype||null==s?new i:new s),_=null!=v&&"string"!=typeof v?new v:null==g?new T:new E,b=void 0,m=0,C=j,S="",x="",O="",M="",$=0,V=0,X=0,G=function(t,n,r,o){if(0===C)if(200===t&&null!=r&&H.test(r)){C=1,f=Date.now(),h=c,e.readyState=1;var i=new R("open",{status:t,statusText:n,headers:o});e.dispatchEvent(i),L(e,e.onopen,i)}else{var s="";200!==t?(n&&(n=n.replace(/\s+/g," ")),s="EventSource's response has a status "+t+" "+n+" that is not 200. Aborting the connection."):s="EventSource's response has a Content-Type specifying an unsupported type: "+(null==r?"-":r.replace(/\s+/g," "))+". Aborting the connection.",U();i=new R("error",{status:t,statusText:n,headers:o});e.dispatchEvent(i),L(e,e.onerror,i),console.error(s)}},z=function(t){if(1===C){for(var n=-1,i=0;i<t.length;i+=1){(u=t.charCodeAt(i))!=="\n".charCodeAt(0)&&u!=="\r".charCodeAt(0)||(n=i)}var s=(-1!==n?M:"")+t.slice(0,n+1);M=(-1===n?M:"")+t.slice(n+1),""!==t&&(f=Date.now(),p+=t.length);for(var a=0;a<s.length;a+=1){var u=s.charCodeAt(a);if($===N&&u==="\n".charCodeAt(0))$=0;else if($===N&&($=0),u==="\r".charCodeAt(0)||u==="\n".charCodeAt(0)){if(0!==$){1===$&&(X=a+1);var y=s.slice(V,X-1),v=s.slice(X+(X<a&&s.charCodeAt(X)===" ".charCodeAt(0)?1:0),a);"data"===y?(S+="\n",S+=v):"id"===y?x=v:"event"===y?O=v:"retry"===y?(c=P(v,c),h=c):"heartbeatTimeout"===y&&(l=P(v,l),0!==m&&(o(m),m=r((function(){k()}),l)))}if(0===$){if(""!==S){d=x,""===O&&(O="message");var g=new A(O,{data:S.slice(1),lastEventId:x});if(e.dispatchEvent(g),"open"===O?L(e,e.onopen,g):"message"===O?L(e,e.onmessage,g):"error"===O&&L(e,e.onerror,g),2===C)return}S="",O=""}$=u==="\r".charCodeAt(0)?N:0}else 0===$&&(V=a,$=1),1===$?u===":".charCodeAt(0)&&(X=a+1,$=2):2===$&&($=3)}}},B=function(t){if(1===C||0===C){C=j,0!==m&&(o(m),m=0),m=r((function(){k()}),h),h=I(Math.min(16*c,2*h)),e.readyState=0;var n=new D("error",{error:t});e.dispatchEvent(n),L(e,e.onerror,n),null!=t&&console.error(t)}},U=function(){C=2,null!=b&&(b.abort(),b=void 0),0!==m&&(o(m),m=0),e.readyState=2},k=function(){if(m=0,C===j){f=!1,p=0,m=r((function(){k()}),l),C=0,S="",O="",x=d,M="",V=0,X=0,$=0;var n=t;"data:"!==t.slice(0,5)&&"blob:"!==t.slice(0,5)&&""!==d&&(n+=(-1===t.indexOf("?")?"?":"&")+u+"="+encodeURIComponent(d));var o=e.withCredentials,i={Accept:"text/event-stream"},s=e.headers;if(null!=s)for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(i[a]=s[a]);try{b=_.open(g,G,z,B,n,o,i)}catch(e){throw U(),e}}else if(f||null==b){var c=Math.max((f||Date.now())+l-Date.now(),1);f=!1,m=r((function(){k()}),c)}else B(new Error("No activity within "+l+" milliseconds. "+(0===C?"No response received.":p+" chars received.")+" Reconnecting.")),null!=b&&(b.abort(),b=void 0)};e.url=t,e.readyState=0,e.withCredentials=a,e.headers=y,e._close=U,k()}(this,e,t)}var q=null!=d&&null!=h&&"body"in h.prototype;M.prototype=Object.create(S.prototype),M.prototype.CONNECTING=0,M.prototype.OPEN=1,M.prototype.CLOSED=2,M.prototype.close=function(){this._close()},M.CONNECTING=0,M.OPEN=1,M.CLOSED=2,M.prototype.withCredentials=void 0;var $,V=u;null==i||null!=u&&"withCredentials"in u.prototype||(V=M),void 0!==($=function(e){e.EventSourcePolyfill=M,e.NativeEventSource=u,e.EventSource=V}(t))&&(e.exports=$)}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:s:globalThis)})),u=Object.freeze(Object.assign(Object.create(null),a,{default:a}));return i}));
var a=function(e){var t={exports:{}};return e(t,t.exports),t.exports}((function(e,t){!function(n){var r=n.setTimeout,o=n.clearTimeout,i=n.XMLHttpRequest,s=n.XDomainRequest,a=n.ActiveXObject,u=n.EventSource,c=n.document,l=n.Promise,d=n.fetch,h=n.Response,f=n.TextDecoder,p=n.TextEncoder,y=n.AbortController;if("undefined"==typeof window||"readyState"in c||null!=c.body||(c.readyState="loading",window.addEventListener("load",(function(e){c.readyState="complete"}),!1)),null==i&&null!=a&&(i=function(){return new a("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==y){var v=d;d=function(e,t){var n=t.signal;return v(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}}}}))},y=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function g(){this.bitsNeeded=0,this.codePoint=0}g.prototype.decode=function(e){function t(e,t,n){if(1===n)return e>=128>>t&&e<<t<=2047;if(2===n)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===n)return e>=65536>>t&&e<<t<=1114111;throw new Error}function n(e,t){if(6===e)return t>>6>15?3:t>31?2:1;if(12===e)return t>15?3:2;if(18===e)return 3;throw new Error}for(var r=65533,o="",i=this.bitsNeeded,s=this.codePoint,a=0;a<e.length;a+=1){var u=e[a];0!==i&&(u<128||u>191||!t(s<<6|63&u,i-6,n(i,s)))&&(i=0,s=r,o+=String.fromCharCode(s)),0===i?(u>=0&&u<=127?(i=0,s=u):u>=192&&u<=223?(i=6,s=31&u):u>=224&&u<=239?(i=12,s=15&u):u>=240&&u<=247?(i=18,s=7&u):(i=0,s=r),0===i||t(s,i,n(i,s))||(i=0,s=r)):(i-=6,s=s<<6|63&u),0===i&&(s<=65535?o+=String.fromCharCode(s):(o+=String.fromCharCode(55296+(s-65535-1>>10)),o+=String.fromCharCode(56320+(s-65535-1&1023))))}return this.bitsNeeded=i,this.codePoint=s,o};null!=f&&null!=p&&function(){try{return"test"===(new f).decode((new p).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1}()||(f=g);var _=function(){};function w(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=_,this.onload=_,this.onerror=_,this.onreadystatechange=_,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=_}function b(e){return e.replace(/[A-Z]/g,(function(e){return String.fromCharCode(e.charCodeAt(0)+32)}))}function m(e){for(var t=Object.create(null),n=e.split("\r\n"),r=0;r<n.length;r+=1){var o=n[r].split(": "),i=o.shift(),s=o.join(": ");t[b(i)]=s}this._map=t}function E(){}function C(e){this._headers=e}function T(){}function S(){this._listeners=Object.create(null)}function x(e){r((function(){throw e}),0)}function O(e){this.type=e,this.target=void 0}function A(e,t){O.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function R(e,t){O.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function j(e,t){O.call(this,e),this.error=t.error}w.prototype.open=function(e,t){this._abort(!0);var n=this,s=this._xhr,a=1,u=0;this._abort=function(e){0!==n._sendTimeout&&(o(n._sendTimeout),n._sendTimeout=0),1!==a&&2!==a&&3!==a||(a=4,s.onload=_,s.onerror=_,s.onabort=_,s.onprogress=_,s.onreadystatechange=_,s.abort(),0!==u&&(o(u),u=0),e||(n.readyState=4,n.onabort(null),n.onreadystatechange())),a=0};var c=function(){if(1===a){var e=0,t="",r=void 0;if("contentType"in s)e=200,t="OK",r=s.contentType;else try{e=s.status,t=s.statusText,r=s.getResponseHeader("Content-Type")}catch(n){e=0,t="",r=void 0}0!==e&&(a=2,n.readyState=2,n.status=e,n.statusText=t,n._contentType=r,n.onreadystatechange())}},l=function(){if(c(),2===a||3===a){a=3;var e="";try{e=s.responseText}catch(e){}n.readyState=3,n.responseText=e,n.onprogress()}},d=function(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:_}),l(),1===a||2===a||3===a){if(a=4,0!==u&&(o(u),u=0),n.readyState=4,"load"===e)n.onload(t);else if("error"===e)n.onerror(t);else{if("abort"!==e)throw new TypeError;n.onabort(t)}n.onreadystatechange()}},h=function(){u=r((function(){h()}),500),3===s.readyState&&l()};"onload"in s&&(s.onload=function(e){d("load",e)}),"onerror"in s&&(s.onerror=function(e){d("error",e)}),"onabort"in s&&(s.onabort=function(e){d("abort",e)}),"onprogress"in s&&(s.onprogress=l),"onreadystatechange"in s&&(s.onreadystatechange=function(e){!function(e){null!=s&&(4===s.readyState?"onload"in s&&"onerror"in s&&"onabort"in s||d(""===s.responseText?"error":"load",e):3===s.readyState?"onprogress"in s||l():2===s.readyState&&c())}(e)}),!("contentType"in s)&&"ontimeout"in i.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),s.open(e,t,!0),"readyState"in s&&(u=r((function(){h()}),0))},w.prototype.abort=function(){this._abort(!1)},w.prototype.getResponseHeader=function(e){return this._contentType},w.prototype.setRequestHeader=function(e,t){var n=this._xhr;"setRequestHeader"in n&&n.setRequestHeader(e,t)},w.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},w.prototype.send=function(){if("ontimeout"in i.prototype&&("sendAsBinary"in i.prototype||"mozAnon"in i.prototype)||null==c||null==c.readyState||"complete"===c.readyState){var e=this._xhr;"withCredentials"in e&&(e.withCredentials=this.withCredentials);try{e.send(void 0)}catch(e){throw e}}else{var t=this;t._sendTimeout=r((function(){t._sendTimeout=0,t.send()}),4)}},m.prototype.get=function(e){return this._map[b(e)]},null!=i&&null==i.HEADERS_RECEIVED&&(i.HEADERS_RECEIVED=2),E.prototype.open=function(e,t,n,r,o,s,a){e.open("GET",o);var u=0;for(var c in e.onprogress=function(){var t=e.responseText.slice(u);u+=t.length,n(t)},e.onerror=function(e){e.preventDefault(),r(new Error("NetworkError"))},e.onload=function(){r(null)},e.onabort=function(){r(null)},e.onreadystatechange=function(){if(e.readyState===i.HEADERS_RECEIVED){var n=e.status,r=e.statusText,o=e.getResponseHeader("Content-Type"),s=e.getAllResponseHeaders();t(n,r,o,new m(s))}},e.withCredentials=s,a)Object.prototype.hasOwnProperty.call(a,c)&&e.setRequestHeader(c,a[c]);return e.send(),e},C.prototype.get=function(e){return this._headers.get(e)},T.prototype.open=function(e,t,n,r,o,i,s){var a=null,u=new y,c=u.signal,h=new f;return d(o,{headers:s,credentials:i?"include":"same-origin",signal:c,cache:"no-store"}).then((function(e){return a=e.body.getReader(),t(e.status,e.statusText,e.headers.get("Content-Type"),new C(e.headers)),new l((function(e,t){var r=function(){a.read().then((function(t){if(t.done)e(void 0);else{var o=h.decode(t.value,{stream:!0});n(o),r()}})).catch((function(e){t(e)}))};r()}))})).catch((function(e){return"AbortError"===e.name?void 0:e})).then((function(e){r(e)})),{abort:function(){null!=a&&a.cancel(),u.abort()}}},S.prototype.dispatchEvent=function(e){e.target=this;var t=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){x(e)}}},S.prototype.addEventListener=function(e,t){e=String(e);var n=this._listeners,r=n[e];null==r&&(r=[],n[e]=r);for(var o=!1,i=0;i<r.length;i+=1)r[i]===t&&(o=!0);o||r.push(t)},S.prototype.removeEventListener=function(e,t){e=String(e);var n=this._listeners,r=n[e];if(null!=r){for(var o=[],i=0;i<r.length;i+=1)r[i]!==t&&o.push(r[i]);0===o.length?delete n[e]:n[e]=o}},A.prototype=Object.create(O.prototype),R.prototype=Object.create(O.prototype),j.prototype=Object.create(O.prototype);var D=-1,N=-1,H=/^text\/event\-stream(;.*)?$/i,P=function(e,t){var n=null==e?t:parseInt(e,10);return n!=n&&(n=t),I(n)},I=function(e){return Math.min(Math.max(e,1e3),18e6)},L=function(e,t,n){try{"function"==typeof t&&t.call(e,n)}catch(e){x(e)}};function M(e,t){S.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,function(e,t,n){t=String(t);var a=Boolean(n.withCredentials),u=n.lastEventIdQueryParameterName||"lastEventId",c=I(1e3),l=P(n.heartbeatTimeout,45e3),d="",h=c,f=!1,p=0,y=n.headers||{},v=n.Transport,g=q&&null==v?void 0:new w(null!=v?new v:null!=i&&"withCredentials"in i.prototype||null==s?new i:new s),_=null!=v&&"string"!=typeof v?new v:null==g?new T:new E,b=void 0,m=0,C=D,S="",x="",O="",M="",$=0,V=0,X=0,G=function(t,n,r,o){if(0===C)if(200===t&&null!=r&&H.test(r)){C=1,f=Date.now(),h=c,e.readyState=1;var i=new R("open",{status:t,statusText:n,headers:o});e.dispatchEvent(i),L(e,e.onopen,i)}else{var s="";200!==t?(n&&(n=n.replace(/\s+/g," ")),s="EventSource's response has a status "+t+" "+n+" that is not 200. Aborting the connection."):s="EventSource's response has a Content-Type specifying an unsupported type: "+(null==r?"-":r.replace(/\s+/g," "))+". Aborting the connection.",U();i=new R("error",{status:t,statusText:n,headers:o});e.dispatchEvent(i),L(e,e.onerror,i),console.error(s)}},z=function(t){if(1===C){for(var n=-1,i=0;i<t.length;i+=1){(u=t.charCodeAt(i))!=="\n".charCodeAt(0)&&u!=="\r".charCodeAt(0)||(n=i)}var s=(-1!==n?M:"")+t.slice(0,n+1);M=(-1===n?M:"")+t.slice(n+1),""!==t&&(f=Date.now(),p+=t.length);for(var a=0;a<s.length;a+=1){var u=s.charCodeAt(a);if($===N&&u==="\n".charCodeAt(0))$=0;else if($===N&&($=0),u==="\r".charCodeAt(0)||u==="\n".charCodeAt(0)){if(0!==$){1===$&&(X=a+1);var y=s.slice(V,X-1),v=s.slice(X+(X<a&&s.charCodeAt(X)===" ".charCodeAt(0)?1:0),a);"data"===y?(S+="\n",S+=v):"id"===y?x=v:"event"===y?O=v:"retry"===y?(c=P(v,c),h=c):"heartbeatTimeout"===y&&(l=P(v,l),0!==m&&(o(m),m=r((function(){k()}),l)))}if(0===$){if(""!==S){d=x,""===O&&(O="message");var g=new A(O,{data:S.slice(1),lastEventId:x});if(e.dispatchEvent(g),"open"===O?L(e,e.onopen,g):"message"===O?L(e,e.onmessage,g):"error"===O&&L(e,e.onerror,g),2===C)return}S="",O=""}$=u==="\r".charCodeAt(0)?N:0}else 0===$&&(V=a,$=1),1===$?u===":".charCodeAt(0)&&(X=a+1,$=2):2===$&&($=3)}}},B=function(t){if(1===C||0===C){C=D,0!==m&&(o(m),m=0),m=r((function(){k()}),h),h=I(Math.min(16*c,2*h)),e.readyState=0;var n=new j("error",{error:t});e.dispatchEvent(n),L(e,e.onerror,n),null!=t&&console.error(t)}},U=function(){C=2,null!=b&&(b.abort(),b=void 0),0!==m&&(o(m),m=0),e.readyState=2},k=function(){if(m=0,C===D){f=!1,p=0,m=r((function(){k()}),l),C=0,S="",O="",x=d,M="",V=0,X=0,$=0;var n=t;"data:"!==t.slice(0,5)&&"blob:"!==t.slice(0,5)&&""!==d&&(n+=(-1===t.indexOf("?")?"?":"&")+u+"="+encodeURIComponent(d));var o=e.withCredentials,i={Accept:"text/event-stream"},s=e.headers;if(null!=s)for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(i[a]=s[a]);try{b=_.open(g,G,z,B,n,o,i)}catch(e){throw U(),e}}else if(f||null==b){var c=Math.max((f||Date.now())+l-Date.now(),1);f=!1,m=r((function(){k()}),c)}else B(new Error("No activity within "+l+" milliseconds. "+(0===C?"No response received.":p+" chars received.")+" Reconnecting.")),null!=b&&(b.abort(),b=void 0)};e.url=t,e.readyState=0,e.withCredentials=a,e.headers=y,e._close=U,k()}(this,e,t)}var q=null!=d&&null!=h&&"body"in h.prototype;M.prototype=Object.create(S.prototype),M.prototype.CONNECTING=0,M.prototype.OPEN=1,M.prototype.CLOSED=2,M.prototype.close=function(){this._close()},M.CONNECTING=0,M.OPEN=1,M.CLOSED=2,M.prototype.withCredentials=void 0;var $,V=u;null==i||null!=u&&"withCredentials"in u.prototype||(V=M),void 0!==($=function(e){e.EventSourcePolyfill=M,e.NativeEventSource=u,e.EventSource=V}(t))&&(e.exports=$)}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:s:globalThis)})),u=Object.freeze(Object.assign(Object.create(null),a,{default:a}));return i}));
{
"name": "vue-sse",
"version": "2.0.2",
"version": "2.1.0",
"description": "A Vue plugin for using Server-Sent Events (EventSource)",

@@ -5,0 +5,0 @@ "main": "dist/vue-sse.common.js",

@@ -20,3 +20,3 @@ import './vue';

constructor(config?: SSEConfig);
create(config?: SSEConfig): SSEClient;
create(configOrURL?: SSEConfig | string): SSEClient;
}

@@ -23,0 +23,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc