diff --git a/babel.config.js b/babel.config.js index 4a3cb1ea..3b5d429d 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,11 +1,3 @@ module.exports = { - presets: [ - [ - '@vue/app', - { - polyfills: false, - useBuiltIns: false - }, - ] - ], + presets: ['bili/babel'], }; diff --git a/bili.config.js b/bili.config.js index 67ef9761..484a1a3a 100644 --- a/bili.config.js +++ b/bili.config.js @@ -1,5 +1,6 @@ module.exports = { input: 'src/index.js', + presets: ['bili/babel'], output: { format: ['esm', 'cjs', 'umd-min'], moduleName: 'VoicenterEventsSDK', diff --git a/dist/voicenter-events-sdk.cjs.js b/dist/voicenter-events-sdk.cjs.js index bb92b84e..b8208982 100644 --- a/dist/voicenter-events-sdk.cjs.js +++ b/dist/voicenter-events-sdk.cjs.js @@ -2,46 +2,9 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } -var _regeneratorRuntime = _interopDefault(require('../node_modules/@babel/runtime/regenerator')); var io = _interopDefault(require('socket.io-client/socket.io')); var debounce = _interopDefault(require('lodash/debounce')); -function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { - try { - var info = gen[key](arg); - var value = info.value; - } catch (error) { - reject(error); - return; - } - - if (info.done) { - resolve(value); - } else { - Promise.resolve(value).then(_next, _throw); - } -} - -function _asyncToGenerator(fn) { - return function () { - var self = this, - args = arguments; - return new Promise(function (resolve, reject) { - var gen = fn.apply(self, args); - - function _next(value) { - asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); - } - - function _throw(err) { - asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); - } - - _next(undefined); - }); - }; -} - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); @@ -64,40 +27,6 @@ function _createClass(Constructor, protoProps, staticProps) { return Constructor; } -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; -} - -function _objectSpread(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - var ownKeys = Object.keys(source); - - if (typeof Object.getOwnPropertySymbols === 'function') { - ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { - return Object.getOwnPropertyDescriptor(source, sym).enumerable; - })); - } - - ownKeys.forEach(function (key) { - _defineProperty(target, key, source[key]); - }); - } - - return target; -} - var eventTypes = { LOGIN: 'loginStatus', LOGIN_RESPONSE: 'loginResponse', @@ -114,6 +43,7 @@ var eventTypes = { RECONNECT_FAILED: 'reconnect_failed', KEEP_ALIVE: 'keepalive', KEEP_ALIVE_RESPONSE: 'keepaliveResponse', + CLOSE: 'closeme', ERROR: 'error' }; @@ -246,6 +176,8 @@ var defaultOptions = { transports: ['websocket'], upgrade: false }; +var allConnections = []; +var listenersMap = new Map(); var EventsSDK = /*#__PURE__*/ @@ -255,7 +187,7 @@ function () { _classCallCheck(this, EventsSDK); - this.options = _objectSpread({}, defaultOptions, options); + this.options = Object.assign({}, defaultOptions, {}, options); if (!this.options.token) { throw new Error('A token property should be provided'); @@ -266,12 +198,13 @@ function () { this.server = null; this.socket = null; this.connected = false; + this.connections = allConnections; this.connectionEstablished = false; this.shouldReconnect = true; this._initReconnectOptions(); - this._listenersMap = new Map(); + this._listenersMap = listenersMap; this._retryConnection = debounce(this._connect.bind(this), this.reconnectOptions.reconnectionDelay, { leading: true, trailing: false @@ -410,7 +343,9 @@ function () { this._initKeepAlive(); - this.login(); + if (server !== 'default') { + this.login(); + } } }, { key: "_checkInit", @@ -426,14 +361,11 @@ function () { var protocol = this.options.protocol; var url = "".concat(protocol, "://").concat(domain); this.Logger.log('Connecting to..', url); - - if (this.socket) { - this.socket.close(); - } - - this.socket = io(url, _objectSpread({}, this.options, { + this.closeAllConnections(); + this.socket = io(url, Object.assign({}, this.options, { debug: false })); + allConnections.push(this.socket); this.connectionEstablished = true; } }, { @@ -446,6 +378,7 @@ function () { this.socket.on(eventTypes.CONNECT_ERROR, this._onConnectError.bind(this)); this.socket.on(eventTypes.CONNECT_TIMEOUT, this._onConnectTimeout.bind(this)); this.socket.on(eventTypes.KEEP_ALIVE_RESPONSE, this._onKeepAlive.bind(this)); + this.socket.onevent = this._onEvent.bind(this); } }, { key: "_initKeepAlive", @@ -525,70 +458,32 @@ function () { } }, { key: "_getServers", - value: function () { - var _getServers2 = _asyncToGenerator( - /*#__PURE__*/ - _regeneratorRuntime.mark(function _callee() { - var res; - return _regeneratorRuntime.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - _context.prev = 0; - _context.next = 3; - return fetch("".concat(this.options.url, "/").concat(this.options.token)); - - case 3: - res = _context.sent; - _context.next = 6; - return res.json(); - - case 6: - this.servers = _context.sent; - _context.next = 12; - break; - - case 9: - _context.prev = 9; - _context.t0 = _context["catch"](0); - this.servers = defaultServers; - - case 12: - case "end": - return _context.stop(); - } - } - }, _callee, this, [[0, 9]]); - })); - - function _getServers() { - return _getServers2.apply(this, arguments); + value: async function _getServers() { + try { + var res = await fetch("".concat(this.options.url, "/").concat(this.options.token)); + this.servers = await res.json(); + } catch (e) { + this.servers = defaultServers; } - - return _getServers; - }() + } }, { key: "_onEvent", - value: function _onEvent() { - var _this2 = this; - - this.socket.onevent = function (packet) { - if (!packet.data) { - return; - } + value: function _onEvent(packet) { + if (!packet.data) { + return; + } - var evt = _this2._parsePacket(packet); + var evt = this._parsePacket(packet); - _this2.Logger.log("New event -> ".concat(evt.name), evt); + this.Logger.log("New event -> ".concat(evt.name), evt); - _this2._listenersMap.forEach(function (callback, eventName) { - if (eventName === '*') { - callback(evt); - } else if (evt.name === eventName) { - callback(evt); - } - }); - }; + this._listenersMap.forEach(function (callback, eventName) { + if (eventName === '*') { + callback(evt); + } else if (evt.name === eventName) { + callback(evt); + } + }); } /** * Initializes socket connection. Should be called before any other action @@ -597,55 +492,55 @@ function () { }, { key: "init", - value: function () { - var _init = _asyncToGenerator( - /*#__PURE__*/ - _regeneratorRuntime.mark(function _callee2() { - return _regeneratorRuntime.wrap(function _callee2$(_context2) { - while (1) { - switch (_context2.prev = _context2.next) { - case 0: - if (!this.connectionEstablished) { - _context2.next = 2; - break; - } - - return _context2.abrupt("return", true); - - case 2: - _context2.next = 4; - return this._getServers(); - - case 4: - this._connect(); - - this._initReconnectDelays(); - - return _context2.abrupt("return", true); - - case 7: - case "end": - return _context2.stop(); - } - } - }, _callee2, this); - })); + value: async function init() { + if (this.connectionEstablished) { + return true; + } - function init() { - return _init.apply(this, arguments); + if (this.socket) { + this.emit(eventTypes.CLOSE); } - return init; - }() + await this._getServers(); + + this._connect(); + + this._initReconnectDelays(); + + return true; + } /** - * Disconnects definitively from the servers + * Sets the monitor code token + * @param token + */ + + }, { + key: "setToken", + value: function setToken(token) { + this.options.token = token; + } + /** + * Closes all existing connections + */ + + }, { + key: "closeAllConnections", + value: function closeAllConnections() { + allConnections.forEach(function (connection) { + connection.close(); + }); + allConnections = []; + } + /** + * Disconnects the socket instance from the servers */ }, { key: "disconnect", value: function disconnect() { this.shouldReconnect = false; - this.socket.close(); + this._listenersMap = new Map(); + this.closeAllConnections(); } /** * Listens for new events @@ -659,8 +554,6 @@ function () { this._listenersMap.set(eventName, callback); this._checkInit(); - - this._onEvent(); } /** * Emits an event to the server @@ -670,7 +563,9 @@ function () { }, { key: "emit", - value: function emit(eventName, data) { + value: function emit(eventName) { + var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + this._checkInit(); this.Logger.log("EMIT -> ".concat(eventName), data); @@ -683,22 +578,22 @@ function () { }, { key: "login", value: function login() { - var _this3 = this; + var _this2 = this; this._checkInit(); var resolved = false; return new Promise(function (resolve, reject) { - _this3.on(eventTypes.LOGIN, function (data) { + _this2.on(eventTypes.LOGIN, function (data) { resolved = true; resolve(data); }); - _this3.emit('login', { - token: _this3.options.token + _this2.emit('login', { + token: _this2.options.token }); - _this3.socket.on(eventTypes.ERROR, function (err) { + _this2.socket.on(eventTypes.ERROR, function (err) { if (!resolved) { reject(err); } diff --git a/dist/voicenter-events-sdk.esm.js b/dist/voicenter-events-sdk.esm.js index c92b52ce..c7f6707c 100644 --- a/dist/voicenter-events-sdk.esm.js +++ b/dist/voicenter-events-sdk.esm.js @@ -1,43 +1,6 @@ -import _regeneratorRuntime from '../node_modules/@babel/runtime/regenerator'; import io from 'socket.io-client/socket.io'; import debounce from 'lodash/debounce'; -function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { - try { - var info = gen[key](arg); - var value = info.value; - } catch (error) { - reject(error); - return; - } - - if (info.done) { - resolve(value); - } else { - Promise.resolve(value).then(_next, _throw); - } -} - -function _asyncToGenerator(fn) { - return function () { - var self = this, - args = arguments; - return new Promise(function (resolve, reject) { - var gen = fn.apply(self, args); - - function _next(value) { - asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); - } - - function _throw(err) { - asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); - } - - _next(undefined); - }); - }; -} - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); @@ -60,40 +23,6 @@ function _createClass(Constructor, protoProps, staticProps) { return Constructor; } -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; -} - -function _objectSpread(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - var ownKeys = Object.keys(source); - - if (typeof Object.getOwnPropertySymbols === 'function') { - ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { - return Object.getOwnPropertyDescriptor(source, sym).enumerable; - })); - } - - ownKeys.forEach(function (key) { - _defineProperty(target, key, source[key]); - }); - } - - return target; -} - var eventTypes = { LOGIN: 'loginStatus', LOGIN_RESPONSE: 'loginResponse', @@ -254,7 +183,7 @@ function () { _classCallCheck(this, EventsSDK); - this.options = _objectSpread({}, defaultOptions, options); + this.options = Object.assign({}, defaultOptions, {}, options); if (!this.options.token) { throw new Error('A token property should be provided'); @@ -429,7 +358,7 @@ function () { var url = "".concat(protocol, "://").concat(domain); this.Logger.log('Connecting to..', url); this.closeAllConnections(); - this.socket = io(url, _objectSpread({}, this.options, { + this.socket = io(url, Object.assign({}, this.options, { debug: false })); allConnections.push(this.socket); @@ -525,48 +454,14 @@ function () { } }, { key: "_getServers", - value: function () { - var _getServers2 = _asyncToGenerator( - /*#__PURE__*/ - _regeneratorRuntime.mark(function _callee() { - var res; - return _regeneratorRuntime.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - _context.prev = 0; - _context.next = 3; - return fetch("".concat(this.options.url, "/").concat(this.options.token)); - - case 3: - res = _context.sent; - _context.next = 6; - return res.json(); - - case 6: - this.servers = _context.sent; - _context.next = 12; - break; - - case 9: - _context.prev = 9; - _context.t0 = _context["catch"](0); - this.servers = defaultServers; - - case 12: - case "end": - return _context.stop(); - } - } - }, _callee, this, [[0, 9]]); - })); - - function _getServers() { - return _getServers2.apply(this, arguments); + value: async function _getServers() { + try { + var res = await fetch("".concat(this.options.url, "/").concat(this.options.token)); + this.servers = await res.json(); + } catch (e) { + this.servers = defaultServers; } - - return _getServers; - }() + } }, { key: "_onEvent", value: function _onEvent(packet) { @@ -593,50 +488,23 @@ function () { }, { key: "init", - value: function () { - var _init = _asyncToGenerator( - /*#__PURE__*/ - _regeneratorRuntime.mark(function _callee2() { - return _regeneratorRuntime.wrap(function _callee2$(_context2) { - while (1) { - switch (_context2.prev = _context2.next) { - case 0: - if (!this.connectionEstablished) { - _context2.next = 2; - break; - } - - return _context2.abrupt("return", true); - - case 2: - if (this.socket) { - this.emit(eventTypes.CLOSE); - } - - _context2.next = 5; - return this._getServers(); - - case 5: - this._connect(); - - this._initReconnectDelays(); - - return _context2.abrupt("return", true); - - case 8: - case "end": - return _context2.stop(); - } - } - }, _callee2, this); - })); + value: async function init() { + if (this.connectionEstablished) { + return true; + } - function init() { - return _init.apply(this, arguments); + if (this.socket) { + this.emit(eventTypes.CLOSE); } - return init; - }() + await this._getServers(); + + this._connect(); + + this._initReconnectDelays(); + + return true; + } /** * Sets the monitor code token * @param token diff --git a/dist/voicenter-events-sdk.umd.js b/dist/voicenter-events-sdk.umd.js index 0fc7a292..0a7d767f 100644 --- a/dist/voicenter-events-sdk.umd.js +++ b/dist/voicenter-events-sdk.umd.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("socket.io-client/socket.io")):"function"==typeof define&&define.amd?define(["socket.io-client/socket.io"],e):(t=t||self).VoicenterEventsSDK=e(t.io)}(this,function(t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n,o=(function(t){var e=function(t){var e,n=Object.prototype,o=n.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",c=r.asyncIterator||"@@asyncIterator",s=r.toStringTag||"@@toStringTag";function a(t,e,n,o){var r=e&&e.prototype instanceof y?e:y,i=Object.create(r.prototype),c=new T(o||[]);return i._invoke=function(t,e,n){var o=l;return function(r,i){if(o===f)throw new Error("Generator is already running");if(o===v){if("throw"===r)throw i;return L()}for(n.method=r,n.arg=i;;){var c=n.delegate;if(c){var s=w(c,n);if(s){if(s===p)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===l)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=f;var a=u(t,e,n);if("normal"===a.type){if(o=n.done?v:h,a.arg===p)continue;return{value:a.arg,done:n.done}}"throw"===a.type&&(o=v,n.method="throw",n.arg=a.arg)}}}(t,n,c),i}function u(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=a;var l="suspendedStart",h="suspendedYield",f="executing",v="completed",p={};function y(){}function d(){}function g(){}var E={};E[i]=function(){return this};var m=Object.getPrototypeOf,_=m&&m(m(x([])));_&&_!==n&&o.call(_,i)&&(E=_);var k=g.prototype=y.prototype=Object.create(E);function O(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function b(t){var e;this._invoke=function(n,r){function i(){return new Promise(function(e,i){!function e(n,r,i,c){var s=u(t[n],t,r);if("throw"!==s.type){var a=s.arg,l=a.value;return l&&"object"==typeof l&&o.call(l,"__await")?Promise.resolve(l.__await).then(function(t){e("next",t,i,c)},function(t){e("throw",t,i,c)}):Promise.resolve(l).then(function(t){a.value=t,i(a)},function(t){return e("throw",t,i,c)})}c(s.arg)}(n,r,e,i)})}return e=e?e.then(i,i):i()}}function w(t,n){var o=t.iterator[n.method];if(o===e){if(n.delegate=null,"throw"===n.method){if(t.iterator.return&&(n.method="return",n.arg=e,w(t,n),"throw"===n.method))return p;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var r=u(o,t.iterator,n.arg);if("throw"===r.type)return n.method="throw",n.arg=r.arg,n.delegate=null,p;var i=r.arg;return i?i.done?(n[t.resultName]=i.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,p):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,p)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function N(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function x(t){if(t){var n=t[i];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,c=function n(){for(;++r=0;--i){var c=this.tryEntries[i],s=c.completion;if("root"===c.tryLoc)return r("end");if(c.tryLoc<=this.prev){var a=o.call(c,"catchLoc"),u=o.call(c,"finallyLoc");if(a&&u){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&o.call(r,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),N(n),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var o=n.completion;if("throw"===o.type){var r=o.arg;N(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,o){return this.delegate={iterator:x(t),resultName:n,nextLoc:o},"next"===this.method&&(this.arg=e),p}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}(n={exports:{}},n.exports),n.exports);function r(t,e,n,o,r,i,c){try{var s=t[i](c),a=s.value}catch(t){return void n(t)}s.done?e(a):Promise.resolve(a).then(o,r)}function i(t){return function(){var e=this,n=arguments;return new Promise(function(o,i){var c=t.apply(e,n);function s(t){r(c,o,i,s,a,"next",t)}function a(t){r(c,o,i,s,a,"throw",t)}s(void 0)})}}function c(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};c(this,t),this.debug=e.debug}return a(t,[{key:"_log",value:function(t,e){var n=e?"".concat(t,", %c Data -> ").concat(JSON.stringify(e)):"".concat(t),o=(new Date).toUTCString();console.log("%c ".concat(o,": %c ").concat(n),"color: #276749;","color: #4299e1;","color: #2c3e50;")}},{key:"_error",value:function(t,e){var n=e?"".concat(t,", Data -> ").concat(JSON.stringify(e)):"".concat(t),o=(new Date).toUTCString();console.error("".concat(o,": ").concat(n))}},{key:"log",value:function(t,e){this.debug&&(t&&!e?this._log(t):this._log(t,e))}},{key:"error",value:function(t,e){this.debug&&(t&&!e?this._error(t):this._error(t,e))}}]),t}();var p=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},y="object"==typeof e&&e&&e.Object===Object&&e,d="object"==typeof self&&self&&self.Object===Object&&self,g=y||d||Function("return this")(),E=function(){return g.Date.now()},m=g.Symbol,_=Object.prototype,k=_.hasOwnProperty,O=_.toString,b=m?m.toStringTag:void 0;var w=function(t){var e=k.call(t,b),n=t[b];try{t[b]=void 0;var o=!0}catch(t){}var r=O.call(t);return o&&(e?t[b]=n:delete t[b]),r},C=Object.prototype.toString;var N=function(t){return C.call(t)},T="[object Null]",x="[object Undefined]",L=m?m.toStringTag:void 0;var R=function(t){return null==t?void 0===t?x:T:L&&L in Object(t)?w(t):N(t)};var S=function(t){return null!=t&&"object"==typeof t},D="[object Symbol]";var P=function(t){return"symbol"==typeof t||S(t)&&R(t)==D},I=NaN,j=/^\s+|\s+$/g,A=/^[-+]0x[0-9a-f]+$/i,M=/^0b[01]+$/i,F=/^0o[0-7]+$/i,U=parseInt;var V=function(t){if("number"==typeof t)return t;if(P(t))return I;if(p(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=p(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(j,"");var n=M.test(t);return n||F.test(t)?U(t.slice(2),n?2:8):A.test(t)?I:+t},G="Expected a function",K=Math.max,$=Math.min;var J=function(t,e,n){var o,r,i,c,s,a,u=0,l=!1,h=!1,f=!0;if("function"!=typeof t)throw new TypeError(G);function v(e){var n=o,i=r;return o=r=void 0,u=e,c=t.apply(i,n)}function y(t){var n=t-a;return void 0===a||n>=e||n<0||h&&t-u>=i}function d(){var t=E();if(y(t))return g(t);s=setTimeout(d,function(t){var n=e-(t-a);return h?$(n,i-(t-u)):n}(t))}function g(t){return s=void 0,f&&o?v(t):(o=r=void 0,c)}function m(){var t=E(),n=y(t);if(o=arguments,r=this,a=t,n){if(void 0===s)return function(t){return u=t,s=setTimeout(d,e),l?v(t):c}(a);if(h)return clearTimeout(s),s=setTimeout(d,e),v(a)}return void 0===s&&(s=setTimeout(d,e)),c}return e=V(e)||0,p(n)&&(l=!!n.leading,i=(h="maxWait"in n)?K(V(n.maxWait)||0,e):i,f="trailing"in n?!!n.trailing:f),m.cancel=function(){void 0!==s&&clearTimeout(s),u=0,o=a=r=s=void 0},m.flush=function(){return void 0===s?c:g(E())},m};var Q={url:"https://monitorapi.voicenter.co.il/monitorAPI/getMonitorUrls",token:null,forceNew:!1,reconnectionDelay:1e4,reconnectionDelayMax:1e4,timeout:1e4,keepAliveTimeout:6e4,protocol:"https",transports:["websocket"],upgrade:!1},W=[],X=new Map,Y=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(c(this,e),this.options=l({},Q,t),!this.options.token)throw new Error("A token property should be provided");this.Logger=new v(this.options),this.servers=[],this.server=null,this.socket=null,this.connected=!1,this.connections=W,this.connectionEstablished=!1,this.shouldReconnect=!0,this._initReconnectOptions(),this._listenersMap=X,this._retryConnection=J(this._connect.bind(this),this.reconnectOptions.reconnectionDelay,{leading:!0,trailing:!1})}return a(e,[{key:"_initReconnectOptions",value:function(){this.reconnectOptions={retryCount:1,reconnectionDelay:this.options.reconnectionDelay,minReconnectionDelay:this.options.reconnectionDelay,maxReconnectionDelay:3e5}}},{key:"_onConnect",value:function(){this._initReconnectDelays(),this.connected=!0,this.Logger.log(h.CONNECT,this.reconnectOptions)}},{key:"_initReconnectDelays",value:function(){this.reconnectOptions.retryCount=1;var t=this.reconnectOptions.minReconnectionDelay;this.reconnectOptions.reconnectionDelay=t,this.socket.io.reconnectionDelay(t),this.socket.io.reconnectionDelayMax(t)}},{key:"_onConnectError",value:function(t){this._retryConnection("next"),this.connected=!1,this.Logger.log(h.CONNECT_ERROR,t)}},{key:"_onReconnectFailed",value:function(){this._retryConnection("next"),this.Logger.log(h.RECONNECT_FAILED,this.reconnectOptions)}},{key:"_onConnectTimeout",value:function(){this._retryConnection("next"),this.Logger.log(h.CONNECT_TIMEOUT,this.reconnectOptions)}},{key:"_onReconnectAttempt",value:function(t){if(t>2)this._retryConnection("next");else{if(this.reconnectOptions.reconnectionDelay0&&void 0!==arguments[0]?arguments[0]:"default";this.shouldReconnect=!0;var e=null;if("default"===t)e=this._findCurrentServer();else if("next"===t)e=this._findNextAvailableServer();else{if("prev"!==t)throw new Error("Incorrect 'server' parameter passed to connect function ".concat(t,". Should be 'default' or 'next'"));e=this._findMaxPriorityServer()}e&&(this._initSocketConnection(),this._initSocketEvents(),this._initKeepAlive(),"default"!==t&&this.login())}},{key:"_checkInit",value:function(){if(!this.connectionEstablished)throw new Error('Make sure you call "sdk.init()" before doing other operations.')}},{key:"_initSocketConnection",value:function(){var e=this.server.Domain,n=this.options.protocol,o="".concat(n,"://").concat(e);this.Logger.log("Connecting to..",o),this.closeAllConnections(),this.socket=t(o,l({},this.options,{debug:!1})),W.push(this.socket),this.connectionEstablished=!0}},{key:"_initSocketEvents",value:function(){this.socket.on(h.RECONNECT_ATTEMPT,this._onReconnectAttempt.bind(this)),this.socket.on(h.RECONNECT_FAILED,this._onReconnectFailed.bind(this)),this.socket.on(h.CONNECT,this._onConnect.bind(this)),this.socket.on(h.DISCONNECT,this._onDisconnect.bind(this)),this.socket.on(h.CONNECT_ERROR,this._onConnectError.bind(this)),this.socket.on(h.CONNECT_TIMEOUT,this._onConnectTimeout.bind(this)),this.socket.on(h.KEEP_ALIVE_RESPONSE,this._onKeepAlive.bind(this)),this.socket.onevent=this._onEvent.bind(this)}},{key:"_initKeepAlive",value:function(){var t=this;setTimeout(function(){t.socket?(t.emit(h.KEEP_ALIVE,t.options.token),t._connect("prev")):t._initSocketConnection()},this.options.keepAliveTimeout)}},{key:"_findCurrentServer",value:function(){var t=null;if(this.servers.length&&(t=this.servers[0]),this.server=t,!this.server)throw new Error("Could not find any server to establish connection with");return this.server}},{key:"_findNextAvailableServer",value:function(){var t=this.server.Priority;if(this.Logger.log("Failover -> Trying to find another server"),t>0){var e=t-1,n=this.servers.find(function(t){return t.Priority===e});if(!n&&!(n=this._findMaxPriorityServer()))return;if(this.server.Domain!==n.Domain)return this.server=n,this.server;this.Logger.log("Failover -> Found new server. Connecting to it...",this.server)}return null}},{key:"_findMaxPriorityServer",value:function(){this.Logger.log("Fallback -> Trying to find previous server","_findMaxPriorityServer");var t,e,n,o=(t=this.servers,e=null,n=-1,t.forEach(function(t){t.Priority>n&&(n=t.Priority,e=t)}),e);return this.server&&o.Domain!==this.server.Domain?(this.server=o,this.Logger.log("Fallback -> Trying to find previous server",this.server),this.server):null}},{key:"_getServers",value:function(){var t=i(o.mark(function t(){var e;return o.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,fetch("".concat(this.options.url,"/").concat(this.options.token));case 3:return e=t.sent,t.next=6,e.json();case 6:this.servers=t.sent,t.next=12;break;case 9:t.prev=9,t.t0=t.catch(0),this.servers=f;case 12:case"end":return t.stop()}},t,this,[[0,9]])}));return function(){return t.apply(this,arguments)}}()},{key:"_onEvent",value:function(t){if(t.data){var e=this._parsePacket(t);this.Logger.log("New event -> ".concat(e.name),e),this._listenersMap.forEach(function(t,n){"*"===n?t(e):e.name===n&&t(e)})}}},{key:"init",value:function(){var t=i(o.mark(function t(){return o.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.connectionEstablished){t.next=2;break}return t.abrupt("return",!0);case 2:return this.socket&&this.emit(h.CLOSE),t.next=5,this._getServers();case 5:return this._connect(),this._initReconnectDelays(),t.abrupt("return",!0);case 8:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}()},{key:"setToken",value:function(t){this.options.token=t}},{key:"closeAllConnections",value:function(){W.forEach(function(t){t.close()}),W=[]}},{key:"disconnect",value:function(){this.shouldReconnect=!1,this._listenersMap=new Map,this.closeAllConnections()}},{key:"on",value:function(t,e){this._listenersMap.set(t,e),this._checkInit()}},{key:"emit",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this._checkInit(),this.Logger.log("EMIT -> ".concat(t),e),this.socket.emit(t,e)}},{key:"login",value:function(){var t=this;this._checkInit();var e=!1;return new Promise(function(n,o){t.on(h.LOGIN,function(t){e=!0,n(t)}),t.emit("login",{token:t.options.token}),t.socket.on(h.ERROR,function(t){e||o(t)})})}}]),e}();return"undefined"!=typeof window&&(window.EventsSDK=Y),Y}); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("socket.io-client/socket.io")):"function"==typeof define&&define.amd?define(["socket.io-client/socket.io"],t):(e=e||self).VoicenterEventsSDK=t(e.io)}(this,function(e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};t(this,e),this.debug=n.debug}return o(e,[{key:"_log",value:function(e,t){var n=t?"".concat(e,", %c Data -> ").concat(JSON.stringify(t)):"".concat(e),o=(new Date).toUTCString();console.log("%c ".concat(o,": %c ").concat(n),"color: #276749;","color: #4299e1;","color: #2c3e50;")}},{key:"_error",value:function(e,t){var n=t?"".concat(e,", Data -> ").concat(JSON.stringify(t)):"".concat(e),o=(new Date).toUTCString();console.error("".concat(o,": ").concat(n))}},{key:"log",value:function(e,t){this.debug&&(e&&!t?this._log(e):this._log(e,t))}},{key:"error",value:function(e,t){this.debug&&(e&&!t?this._error(e):this._error(e,t))}}]),e}();var s=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},l="object"==typeof a&&a&&a.Object===Object&&a,u="object"==typeof self&&self&&self.Object===Object&&self,h=l||u||Function("return this")(),f=function(){return h.Date.now()},v=h.Symbol,y=Object.prototype,d=y.hasOwnProperty,p=y.toString,E=v?v.toStringTag:void 0;var g=function(e){var t=d.call(e,E),n=e[E];try{e[E]=void 0;var o=!0}catch(e){}var i=p.call(e);return o&&(t?e[E]=n:delete e[E]),i},_=Object.prototype.toString;var k=function(e){return _.call(e)},O="[object Null]",C="[object Undefined]",T=v?v.toStringTag:void 0;var N=function(e){return null==e?void 0===e?C:O:T&&T in Object(e)?g(e):k(e)};var m=function(e){return null!=e&&"object"==typeof e},b="[object Symbol]";var R=function(e){return"symbol"==typeof e||m(e)&&N(e)==b},D=NaN,S=/^\s+|\s+$/g,w=/^[-+]0x[0-9a-f]+$/i,L=/^0b[01]+$/i,I=/^0o[0-7]+$/i,P=parseInt;var A=function(e){if("number"==typeof e)return e;if(R(e))return D;if(s(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=s(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(S,"");var n=L.test(e);return n||I.test(e)?P(e.slice(2),n?2:8):w.test(e)?D:+e},x="Expected a function",M=Math.max,j=Math.min;var U=function(e,t,n){var o,i,r,c,a,l,u=0,h=!1,v=!1,y=!0;if("function"!=typeof e)throw new TypeError(x);function d(t){var n=o,r=i;return o=i=void 0,u=t,c=e.apply(r,n)}function p(e){var n=e-l;return void 0===l||n>=t||n<0||v&&e-u>=r}function E(){var e=f();if(p(e))return g(e);a=setTimeout(E,function(e){var n=t-(e-l);return v?j(n,r-(e-u)):n}(e))}function g(e){return a=void 0,y&&o?d(e):(o=i=void 0,c)}function _(){var e=f(),n=p(e);if(o=arguments,i=this,l=e,n){if(void 0===a)return function(e){return u=e,a=setTimeout(E,t),h?d(e):c}(l);if(v)return clearTimeout(a),a=setTimeout(E,t),d(l)}return void 0===a&&(a=setTimeout(E,t)),c}return t=A(t)||0,s(n)&&(h=!!n.leading,r=(v="maxWait"in n)?M(A(n.maxWait)||0,t):r,y="trailing"in n?!!n.trailing:y),_.cancel=function(){void 0!==a&&clearTimeout(a),u=0,o=l=i=a=void 0},_.flush=function(){return void 0===a?c:g(f())},_};var V={url:"https://monitorapi.voicenter.co.il/monitorAPI/getMonitorUrls",token:null,forceNew:!1,reconnectionDelay:1e4,reconnectionDelayMax:1e4,timeout:1e4,keepAliveTimeout:6e4,protocol:"https",transports:["websocket"],upgrade:!1},F=[],K=new Map,G=function(){function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(t(this,n),this.options=Object.assign({},V,{},e),!this.options.token)throw new Error("A token property should be provided");this.Logger=new c(this.options),this.servers=[],this.server=null,this.socket=null,this.connected=!1,this.connections=F,this.connectionEstablished=!1,this.shouldReconnect=!0,this._initReconnectOptions(),this._listenersMap=K,this._retryConnection=U(this._connect.bind(this),this.reconnectOptions.reconnectionDelay,{leading:!0,trailing:!1})}return o(n,[{key:"_initReconnectOptions",value:function(){this.reconnectOptions={retryCount:1,reconnectionDelay:this.options.reconnectionDelay,minReconnectionDelay:this.options.reconnectionDelay,maxReconnectionDelay:3e5}}},{key:"_onConnect",value:function(){this._initReconnectDelays(),this.connected=!0,this.Logger.log(i.CONNECT,this.reconnectOptions)}},{key:"_initReconnectDelays",value:function(){this.reconnectOptions.retryCount=1;var e=this.reconnectOptions.minReconnectionDelay;this.reconnectOptions.reconnectionDelay=e,this.socket.io.reconnectionDelay(e),this.socket.io.reconnectionDelayMax(e)}},{key:"_onConnectError",value:function(e){this._retryConnection("next"),this.connected=!1,this.Logger.log(i.CONNECT_ERROR,e)}},{key:"_onReconnectFailed",value:function(){this._retryConnection("next"),this.Logger.log(i.RECONNECT_FAILED,this.reconnectOptions)}},{key:"_onConnectTimeout",value:function(){this._retryConnection("next"),this.Logger.log(i.CONNECT_TIMEOUT,this.reconnectOptions)}},{key:"_onReconnectAttempt",value:function(e){if(e>2)this._retryConnection("next");else{if(this.reconnectOptions.reconnectionDelay0&&void 0!==arguments[0]?arguments[0]:"default";this.shouldReconnect=!0;var t=null;if("default"===e)t=this._findCurrentServer();else if("next"===e)t=this._findNextAvailableServer();else{if("prev"!==e)throw new Error("Incorrect 'server' parameter passed to connect function ".concat(e,". Should be 'default' or 'next'"));t=this._findMaxPriorityServer()}t&&(this._initSocketConnection(),this._initSocketEvents(),this._initKeepAlive(),"default"!==e&&this.login())}},{key:"_checkInit",value:function(){if(!this.connectionEstablished)throw new Error('Make sure you call "sdk.init()" before doing other operations.')}},{key:"_initSocketConnection",value:function(){var t=this.server.Domain,n=this.options.protocol,o="".concat(n,"://").concat(t);this.Logger.log("Connecting to..",o),this.closeAllConnections(),this.socket=e(o,Object.assign({},this.options,{debug:!1})),F.push(this.socket),this.connectionEstablished=!0}},{key:"_initSocketEvents",value:function(){this.socket.on(i.RECONNECT_ATTEMPT,this._onReconnectAttempt.bind(this)),this.socket.on(i.RECONNECT_FAILED,this._onReconnectFailed.bind(this)),this.socket.on(i.CONNECT,this._onConnect.bind(this)),this.socket.on(i.DISCONNECT,this._onDisconnect.bind(this)),this.socket.on(i.CONNECT_ERROR,this._onConnectError.bind(this)),this.socket.on(i.CONNECT_TIMEOUT,this._onConnectTimeout.bind(this)),this.socket.on(i.KEEP_ALIVE_RESPONSE,this._onKeepAlive.bind(this)),this.socket.onevent=this._onEvent.bind(this)}},{key:"_initKeepAlive",value:function(){var e=this;setTimeout(function(){e.socket?(e.emit(i.KEEP_ALIVE,e.options.token),e._connect("prev")):e._initSocketConnection()},this.options.keepAliveTimeout)}},{key:"_findCurrentServer",value:function(){var e=null;if(this.servers.length&&(e=this.servers[0]),this.server=e,!this.server)throw new Error("Could not find any server to establish connection with");return this.server}},{key:"_findNextAvailableServer",value:function(){var e=this.server.Priority;if(this.Logger.log("Failover -> Trying to find another server"),e>0){var t=e-1,n=this.servers.find(function(e){return e.Priority===t});if(!n&&!(n=this._findMaxPriorityServer()))return;if(this.server.Domain!==n.Domain)return this.server=n,this.server;this.Logger.log("Failover -> Found new server. Connecting to it...",this.server)}return null}},{key:"_findMaxPriorityServer",value:function(){this.Logger.log("Fallback -> Trying to find previous server","_findMaxPriorityServer");var e,t,n,o=(e=this.servers,t=null,n=-1,e.forEach(function(e){e.Priority>n&&(n=e.Priority,t=e)}),t);return this.server&&o.Domain!==this.server.Domain?(this.server=o,this.Logger.log("Fallback -> Trying to find previous server",this.server),this.server):null}},{key:"_getServers",value:async function(){try{var e=await fetch("".concat(this.options.url,"/").concat(this.options.token));this.servers=await e.json()}catch(e){this.servers=r}}},{key:"_onEvent",value:function(e){if(e.data){var t=this._parsePacket(e);this.Logger.log("New event -> ".concat(t.name),t),this._listenersMap.forEach(function(e,n){"*"===n?e(t):t.name===n&&e(t)})}}},{key:"init",value:async function(){return!!this.connectionEstablished||(this.socket&&this.emit(i.CLOSE),await this._getServers(),this._connect(),this._initReconnectDelays(),!0)}},{key:"setToken",value:function(e){this.options.token=e}},{key:"closeAllConnections",value:function(){F.forEach(function(e){e.close()}),F=[]}},{key:"disconnect",value:function(){this.shouldReconnect=!1,this._listenersMap=new Map,this.closeAllConnections()}},{key:"on",value:function(e,t){this._listenersMap.set(e,t),this._checkInit()}},{key:"emit",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this._checkInit(),this.Logger.log("EMIT -> ".concat(e),t),this.socket.emit(e,t)}},{key:"login",value:function(){var e=this;this._checkInit();var t=!1;return new Promise(function(n,o){e.on(i.LOGIN,function(e){t=!0,n(e)}),e.emit("login",{token:e.options.token}),e.socket.on(i.ERROR,function(e){t||o(e)})})}}]),n}();return"undefined"!=typeof window&&(window.EventsSDK=G),G}); //# sourceMappingURL=voicenter-events-sdk.umd.js.map diff --git a/dist/voicenter-events-sdk.umd.js.map b/dist/voicenter-events-sdk.umd.js.map index ac3d19bd..945fb0f7 100644 --- a/dist/voicenter-events-sdk.umd.js.map +++ b/dist/voicenter-events-sdk.umd.js.map @@ -1 +1 @@ -{"version":3,"file":"voicenter-events-sdk.umd.js","sources":["../node_modules/regenerator-runtime/runtime.js","../src/eventTypes.js","../src/config.js","../src/Logger.js","../node_modules/lodash/isObject.js","../node_modules/lodash/_freeGlobal.js","../node_modules/lodash/_root.js","../node_modules/lodash/now.js","../node_modules/lodash/_Symbol.js","../node_modules/lodash/_getRawTag.js","../node_modules/lodash/_objectToString.js","../node_modules/lodash/_baseGetTag.js","../node_modules/lodash/isObjectLike.js","../node_modules/lodash/isSymbol.js","../node_modules/lodash/toNumber.js","../node_modules/lodash/debounce.js","../src/sdk.js","../src/utils.js","../src/index.js"],"sourcesContent":["/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nvar runtime = (function (exports) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n exports.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunctionPrototype[toStringTagSymbol] =\n GeneratorFunction.displayName = \"GeneratorFunction\";\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n prototype[method] = function(arg) {\n return this._invoke(method, arg);\n };\n });\n }\n\n exports.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n exports.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n if (!(toStringTagSymbol in genFun)) {\n genFun[toStringTagSymbol] = \"GeneratorFunction\";\n }\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n exports.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return Promise.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return Promise.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke(\"throw\", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new Promise(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList) {\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList)\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n // Note: [\"return\"] must be used for ES3 parsing compatibility.\n if (delegate.iterator[\"return\"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n Gp[toStringTagSymbol] = \"Generator\";\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n typeof module === \"object\" ? module.exports : {}\n));\n\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n // This module should not be running in strict mode, so the above\n // assignment should always work unless something is misconfigured. Just\n // in case runtime.js accidentally runs in strict mode, we can escape\n // strict mode using a global Function call. This could conceivably fail\n // if a Content Security Policy forbids using Function, but in that case\n // the proper solution is to fix the accidental strict mode problem. If\n // you've misconfigured your bundler to force strict mode and applied a\n // CSP to forbid Function, and you're not willing to fix either of those\n // problems, please detail your unique predicament in a GitHub issue.\n Function(\"r\", \"regeneratorRuntime = r\")(runtime);\n}\n","export default {\n LOGIN: 'loginStatus',\n LOGIN_RESPONSE: 'loginResponse',\n QUEUE_EVENT: 'QueueEvent',\n EXTENSION_EVENT: 'ExtensionEvent',\n ALL_EXTENSION_STATUS: 'AllExtensionsStatus',\n CONNECT_ERROR: 'connect_error',\n CONNECT_TIMEOUT: 'connect_timeout',\n DISCONNECT: 'disconnect',\n RECONNECT: 'reconnect',\n RECONNECT_ATTEMPT: 'reconnect_attempt',\n RECONNECTING: 'reconnecting',\n RECONNECT_ERROR: 'reconnect_error',\n RECONNECT_FAILED: 'reconnect_failed',\n KEEP_ALIVE: 'keepalive',\n KEEP_ALIVE_RESPONSE: 'keepaliveResponse',\n CLOSE: 'closeme',\n ERROR: 'error',\n}\n","export const defaultServers = [{\n 'URLID': 59,\n 'Priority': 5,\n 'Version': 2,\n 'Domain': 'monitor1.voicenter.co'\n}, {\n 'URLID': 3,\n 'Priority': 4,\n 'Version': 2,\n 'Domain': 'monitor3.voicenter.co.il'\n}, {\n 'URLID': 4,\n 'Priority': 3,\n 'Version': 2,\n 'Domain': 'monitor4.voicenter.co.il'\n}, {\n 'URLID': 11,\n 'Priority': 2,\n 'Version': 2,\n 'Domain': 'monitor11.voicenter.co'\n}, {\n 'URLID': 5,\n 'Priority': 0,\n 'Version': 2,\n 'Domain': 'monitor5.voicenter.co.il'\n}];\n","\nclass Logger {\n constructor(options = {}) {\n this.debug = options.debug\n }\n\n /**\n * Logs to console a colored message\n * @param message\n * @param data\n * @private\n */\n _log(message, data) {\n let toLog = data ? `${message}, %c Data -> ${JSON.stringify(data)}` : `${message}`\n let now = new Date().toUTCString()\n console.log(`%c ${now}: %c ${toLog}`, `color: #276749;`, `color: #4299e1;`, `color: #2c3e50;`)\n }\n\n /**\n * Logs to console a colored message\n * @param message\n * @param data\n * @private\n */\n _error(message, data) {\n let toLog = data ? `${message}, Data -> ${JSON.stringify(data)}` : `${message}`\n let now = new Date().toUTCString()\n console.error(`${now}: ${toLog}`)\n }\n\n /**\n * Logs messages in case debug mode is set\n * @param message\n * @param data\n */\n log(message, data) {\n if (this.debug) {\n if (message && !data) {\n this._log(message)\n } else {\n this._log(message, data)\n }\n }\n }\n /**\n * Logs error messages in case debug mode is set\n * @param message\n * @param data\n */\n error(message, data) {\n if (this.debug) {\n if (message && !data) {\n this._error(message)\n } else {\n this._error(message, data)\n }\n }\n }\n}\n\nexport default Logger\n","/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\nmodule.exports = isObject;\n","/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\nmodule.exports = freeGlobal;\n","var freeGlobal = require('./_freeGlobal');\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\nmodule.exports = root;\n","var root = require('./_root');\n\n/**\n * Gets the timestamp of the number of milliseconds that have elapsed since\n * the Unix epoch (1 January 1970 00:00:00 UTC).\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Date\n * @returns {number} Returns the timestamp.\n * @example\n *\n * _.defer(function(stamp) {\n * console.log(_.now() - stamp);\n * }, _.now());\n * // => Logs the number of milliseconds it took for the deferred invocation.\n */\nvar now = function() {\n return root.Date.now();\n};\n\nmodule.exports = now;\n","var root = require('./_root');\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\n\nmodule.exports = Symbol;\n","var Symbol = require('./_Symbol');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\n\nmodule.exports = getRawTag;\n","/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\n\nmodule.exports = objectToString;\n","var Symbol = require('./_Symbol'),\n getRawTag = require('./_getRawTag'),\n objectToString = require('./_objectToString');\n\n/** `Object#toString` result references. */\nvar nullTag = '[object Null]',\n undefinedTag = '[object Undefined]';\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n}\n\nmodule.exports = baseGetTag;\n","/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return value != null && typeof value == 'object';\n}\n\nmodule.exports = isObjectLike;\n","var baseGetTag = require('./_baseGetTag'),\n isObjectLike = require('./isObjectLike');\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && baseGetTag(value) == symbolTag);\n}\n\nmodule.exports = isSymbol;\n","var isObject = require('./isObject'),\n isSymbol = require('./isSymbol');\n\n/** Used as references for various `Number` constants. */\nvar NAN = 0 / 0;\n\n/** Used to match leading and trailing whitespace. */\nvar reTrim = /^\\s+|\\s+$/g;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = value.replace(reTrim, '');\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\nmodule.exports = toNumber;\n","var isObject = require('./isObject'),\n now = require('./now'),\n toNumber = require('./toNumber');\n\n/** Error message constants. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max,\n nativeMin = Math.min;\n\n/**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed `func` invocations and a `flush` method to immediately invoke them.\n * Provide `options` to indicate whether `func` should be invoked on the\n * leading and/or trailing edge of the `wait` timeout. The `func` is invoked\n * with the last arguments provided to the debounced function. Subsequent\n * calls to the debounced function return the result of the last `func`\n * invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the debounced function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.debounce` and `_.throttle`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to debounce.\n * @param {number} [wait=0] The number of milliseconds to delay.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=false]\n * Specify invoking on the leading edge of the timeout.\n * @param {number} [options.maxWait]\n * The maximum time `func` is allowed to be delayed before it's invoked.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new debounced function.\n * @example\n *\n * // Avoid costly calculations while the window size is in flux.\n * jQuery(window).on('resize', _.debounce(calculateLayout, 150));\n *\n * // Invoke `sendMail` when clicked, debouncing subsequent calls.\n * jQuery(element).on('click', _.debounce(sendMail, 300, {\n * 'leading': true,\n * 'trailing': false\n * }));\n *\n * // Ensure `batchLog` is invoked once after 1 second of debounced calls.\n * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });\n * var source = new EventSource('/stream');\n * jQuery(source).on('message', debounced);\n *\n * // Cancel the trailing debounced invocation.\n * jQuery(window).on('popstate', debounced.cancel);\n */\nfunction debounce(func, wait, options) {\n var lastArgs,\n lastThis,\n maxWait,\n result,\n timerId,\n lastCallTime,\n lastInvokeTime = 0,\n leading = false,\n maxing = false,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n wait = toNumber(wait) || 0;\n if (isObject(options)) {\n leading = !!options.leading;\n maxing = 'maxWait' in options;\n maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n\n function invokeFunc(time) {\n var args = lastArgs,\n thisArg = lastThis;\n\n lastArgs = lastThis = undefined;\n lastInvokeTime = time;\n result = func.apply(thisArg, args);\n return result;\n }\n\n function leadingEdge(time) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time;\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait);\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result;\n }\n\n function remainingWait(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime,\n timeWaiting = wait - timeSinceLastCall;\n\n return maxing\n ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)\n : timeWaiting;\n }\n\n function shouldInvoke(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||\n (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));\n }\n\n function timerExpired() {\n var time = now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time));\n }\n\n function trailingEdge(time) {\n timerId = undefined;\n\n // Only invoke if we have `lastArgs` which means `func` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = undefined;\n return result;\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = undefined;\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(now());\n }\n\n function debounced() {\n var time = now(),\n isInvoking = shouldInvoke(time);\n\n lastArgs = arguments;\n lastThis = this;\n lastCallTime = time;\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n clearTimeout(timerId);\n timerId = setTimeout(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait);\n }\n return result;\n }\n debounced.cancel = cancel;\n debounced.flush = flush;\n return debounced;\n}\n\nmodule.exports = debounce;\n","import io from 'socket.io-client/socket.io';\nimport eventTypes from './eventTypes';\nimport { defaultServers } from './config';\nimport Logger from './Logger';\nimport debounce from 'lodash/debounce'\nimport { getServerWithHighestPriority } from './utils';\n\nconst defaultOptions = {\n url: `https://monitorapi.voicenter.co.il/monitorAPI/getMonitorUrls`,\n token: null,\n forceNew: false,\n reconnectionDelay: 10000,\n reconnectionDelayMax: 10000,\n timeout: 10000,\n keepAliveTimeout: 60000,\n protocol: 'https',\n transports: ['websocket'],\n upgrade: false\n};\n\nlet allConnections = []\nlet listenersMap = new Map()\nclass EventsSDK {\n constructor(options = {}) {\n this.options = {\n ...defaultOptions,\n ...options,\n };\n if (!this.options.token) {\n throw new Error('A token property should be provided');\n }\n this.Logger = new Logger(this.options);\n this.servers = [];\n this.server = null;\n this.socket = null;\n this.connected = false\n this.connections = allConnections\n this.connectionEstablished = false;\n this.shouldReconnect = true\n this._initReconnectOptions();\n this._listenersMap = listenersMap\n this._retryConnection = debounce(this._connect.bind(this), this.reconnectOptions.reconnectionDelay, { leading: true, trailing: false })\n }\n\n _initReconnectOptions() {\n this.reconnectOptions = {\n retryCount: 1,\n reconnectionDelay: this.options.reconnectionDelay, // 10 seconds. After each re-connection attempt this number will increase (minReconnectionDelay * attempts) => 10, 20, 30, 40 seconds ... up to 5min\n minReconnectionDelay: this.options.reconnectionDelay, // 10 seconds\n maxReconnectionDelay: 60000 * 5 // 5 minutes\n }\n }\n _onConnect() {\n this._initReconnectDelays()\n this.connected = true\n this.Logger.log(eventTypes.CONNECT, this.reconnectOptions)\n }\n\n _initReconnectDelays() {\n this.reconnectOptions.retryCount = 1;\n let minReconnectDelay = this.reconnectOptions.minReconnectionDelay;\n this.reconnectOptions.reconnectionDelay = minReconnectDelay;\n this.socket.io.reconnectionDelay(minReconnectDelay);\n this.socket.io.reconnectionDelayMax(minReconnectDelay);\n }\n\n _onConnectError(data) {\n this._retryConnection('next')\n this.connected = false\n this.Logger.log(eventTypes.CONNECT_ERROR, data)\n }\n\n _onReconnectFailed() {\n this._retryConnection('next')\n this.Logger.log(eventTypes.RECONNECT_FAILED, this.reconnectOptions)\n }\n\n _onConnectTimeout() {\n this._retryConnection('next')\n this.Logger.log(eventTypes.CONNECT_TIMEOUT, this.reconnectOptions)\n }\n\n _onReconnectAttempt(attempts) {\n if (attempts > 2) {\n this._retryConnection('next')\n return\n }\n if (this.reconnectOptions.reconnectionDelay < this.reconnectOptions.maxReconnectionDelay) {\n let newDelay = this.reconnectOptions.minReconnectionDelay * this.reconnectOptions.retryCount;\n this.reconnectOptions.reconnectionDelay = newDelay;\n this.socket.io.reconnectionDelay(newDelay);\n this.socket.io.reconnectionDelayMax(newDelay);\n }\n this.reconnectOptions.retryCount++;\n this.Logger.log(eventTypes.RECONNECT_ATTEMPT, this.reconnectOptions)\n }\n\n _onDisconnect() {\n if (this.shouldReconnect) {\n this._connect('next')\n }\n this.connected = false\n this.Logger.log(eventTypes.DISCONNECT, this.reconnectOptions)\n }\n\n _onKeepAlive(data) {\n if(data === false && this.connected) {\n this._initSocketConnection()\n this.Logger.log(eventTypes.KEEP_ALIVE_RESPONSE, this.reconnectOptions)\n }\n }\n\n _parsePacket(packet) {\n if (!packet.data) {\n return {};\n }\n let name = packet.data[0];\n let data = packet.data[1];\n return {\n name,\n data\n };\n }\n\n _connect(server = 'default') {\n this.shouldReconnect = true\n let serverToConnect = null\n if (server === 'default') {\n serverToConnect = this._findCurrentServer();\n } else if (server === 'next') {\n serverToConnect = this._findNextAvailableServer()\n } else if (server === 'prev') {\n serverToConnect = this._findMaxPriorityServer()\n } else {\n throw new Error(`Incorrect 'server' parameter passed to connect function ${server}. Should be 'default' or 'next'`)\n }\n if (!serverToConnect) {\n // skip the connect because we didn't find a new server to connect to.\n return\n }\n this._initSocketConnection();\n this._initSocketEvents();\n this._initKeepAlive();\n if (server !== 'default'){\n this.login()\n }\n }\n\n _checkInit() {\n if (!this.connectionEstablished) {\n throw new Error('Make sure you call \"sdk.init()\" before doing other operations.')\n }\n }\n\n _initSocketConnection() {\n let domain = this.server.Domain;\n let protocol = this.options.protocol;\n let url = `${protocol}://${domain}`;\n this.Logger.log('Connecting to..', url)\n this.closeAllConnections()\n this.socket = io(url, {\n ...this.options,\n debug: false\n });\n allConnections.push(this.socket)\n this.connectionEstablished = true;\n }\n\n _initSocketEvents() {\n this.socket.on(eventTypes.RECONNECT_ATTEMPT, this._onReconnectAttempt.bind(this));\n this.socket.on(eventTypes.RECONNECT_FAILED, this._onReconnectFailed.bind(this));\n this.socket.on(eventTypes.CONNECT, this._onConnect.bind(this));\n this.socket.on(eventTypes.DISCONNECT, this._onDisconnect.bind(this));\n this.socket.on(eventTypes.CONNECT_ERROR, this._onConnectError.bind(this));\n this.socket.on(eventTypes.CONNECT_TIMEOUT, this._onConnectTimeout.bind(this));\n this.socket.on(eventTypes.KEEP_ALIVE_RESPONSE, this._onKeepAlive.bind(this));\n this.socket.onevent = this._onEvent.bind(this)\n }\n\n _initKeepAlive() {\n setTimeout(()=>{\n if(this.socket) {\n this.emit(eventTypes.KEEP_ALIVE, this.options.token);\n this._connect('prev')\n }\n else {\n this._initSocketConnection()\n }\n }, this.options.keepAliveTimeout);\n }\n\n _findCurrentServer() {\n let server = null;\n if (this.servers.length) {\n server = this.servers[0];\n }\n this.server = server;\n if (!this.server) {\n throw new Error('Could not find any server to establish connection with');\n }\n return this.server\n }\n\n _findNextAvailableServer() {\n let currentServerPriority = this.server.Priority;\n this.Logger.log(`Failover -> Trying to find another server`)\n if (currentServerPriority > 0) {\n let nextServerPriority = currentServerPriority - 1;\n let nextServer = this.servers.find(server => server.Priority === nextServerPriority);\n if (!nextServer) {\n nextServer = this._findMaxPriorityServer()\n if (!nextServer) {\n return\n }\n }\n if (this.server.Domain !== nextServer.Domain) {\n this.server = nextServer;\n return this.server\n }\n this.Logger.log(`Failover -> Found new server. Connecting to it...`, this.server)\n }\n return null\n }\n\n _findMaxPriorityServer() {\n this.Logger.log(`Fallback -> Trying to find previous server`, '_findMaxPriorityServer')\n let maxPriorityServer = getServerWithHighestPriority(this.servers)\n if(this.server && maxPriorityServer.Domain !== this.server.Domain) {\n this.server = maxPriorityServer;\n this.Logger.log(`Fallback -> Trying to find previous server`, this.server)\n return this.server\n }\n return null\n }\n\n async _getServers() {\n try {\n let res = await fetch(`${this.options.url}/${this.options.token}`);\n this.servers = await res.json();\n } catch (e) {\n this.servers = defaultServers;\n }\n }\n\n _onEvent(packet) {\n if (!packet.data) {\n return;\n }\n let evt = this._parsePacket(packet);\n this.Logger.log(`New event -> ${evt.name}`, evt);\n this._listenersMap.forEach((callback, eventName) => {\n if (eventName === '*') {\n callback(evt);\n } else if (evt.name === eventName) {\n callback(evt);\n }\n })\n }\n\n /**\n * Initializes socket connection. Should be called before any other action\n * @return {Promise}\n */\n async init() {\n if (this.connectionEstablished) {\n return true;\n }\n if (this.socket) {\n this.emit(eventTypes.CLOSE)\n }\n await this._getServers();\n this._connect()\n this._initReconnectDelays()\n return true\n }\n\n /**\n * Sets the monitor code token\n * @param token\n */\n setToken(token) {\n this.options.token = token\n }\n /**\n * Closes all existing connections\n */\n closeAllConnections() {\n allConnections.forEach(connection => {\n connection.close()\n })\n allConnections = []\n }\n /**\n * Disconnects the socket instance from the servers\n */\n disconnect() {\n this.shouldReconnect = false\n this._listenersMap = new Map()\n this.closeAllConnections()\n }\n\n /**\n * Listens for new events\n * @param {string} eventName (name of the event, * for all events)\n * @param {function} callback (callback function when even with the specified name is received)\n */\n on(eventName, callback) {\n this._listenersMap.set(eventName, callback)\n this._checkInit()\n }\n\n /**\n * Emits an event to the server\n * @param {string} eventName (name of the event)\n * @param {object} data (data for the event)\n */\n\n emit(eventName, data = {}) {\n this._checkInit()\n this.Logger.log(`EMIT -> ${eventName}`, data)\n this.socket.emit(eventName, data);\n }\n\n /**\n * Login (logs in based on the token/credentials provided)\n */\n login() {\n this._checkInit()\n let resolved = false\n return new Promise((resolve, reject) => {\n this.on(eventTypes.LOGIN, data => {\n resolved = true\n resolve(data)\n })\n this.emit('login', { token: this.options.token });\n this.socket.on(eventTypes.ERROR, err => {\n if(!resolved) {\n reject(err);\n }\n })\n });\n }\n\n}\n\nexport default EventsSDK;\n","export function getServerWithHighestPriority(servers) {\n let chosenServer = null\n let maxPriority = -1\n servers.forEach(server => {\n if (server.Priority > maxPriority) {\n maxPriority = server.Priority\n chosenServer = server\n }\n })\n return chosenServer\n}\n","const version = '__VERSION__'\nimport sdk from './sdk'\nif (typeof window !== 'undefined') {\n // Make it available on window\n window.EventsSDK = sdk\n}\n\nexport default sdk\n"],"names":["runtime","exports","undefined","Op","Object","prototype","hasOwn","hasOwnProperty","$Symbol","Symbol","iteratorSymbol","iterator","asyncIteratorSymbol","asyncIterator","toStringTagSymbol","toStringTag","wrap","innerFn","outerFn","self","tryLocsList","protoGenerator","Generator","generator","create","context","Context","_invoke","state","GenStateSuspendedStart","method","arg","GenStateExecuting","Error","GenStateCompleted","doneResult","delegate","delegateResult","maybeInvokeDelegate","ContinueSentinel","sent","_sent","dispatchException","abrupt","record","tryCatch","type","done","GenStateSuspendedYield","value","makeInvokeMethod","fn","obj","call","err","GeneratorFunction","GeneratorFunctionPrototype","IteratorPrototype","this","getProto","getPrototypeOf","NativeIteratorPrototype","values","Gp","defineIteratorMethods","forEach","AsyncIterator","previousPromise","callInvokeWithMethodAndArg","Promise","resolve","reject","invoke","result","__await","then","unwrapped","error","TypeError","info","resultName","next","nextLoc","pushTryEntry","locs","entry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","iterable","iteratorMethod","isNaN","length","i","constructor","displayName","isGeneratorFunction","genFun","ctor","name","mark","setPrototypeOf","__proto__","awrap","async","iter","toString","keys","object","key","reverse","pop","skipTempReset","prev","charAt","slice","stop","rootRecord","rval","exception","handle","loc","caught","hasCatch","hasFinally","finallyEntry","complete","finish","catch","thrown","delegateYield","module","regeneratorRuntime","accidentalStrictMode","Function","LOGIN","LOGIN_RESPONSE","QUEUE_EVENT","EXTENSION_EVENT","ALL_EXTENSION_STATUS","CONNECT_ERROR","CONNECT_TIMEOUT","DISCONNECT","RECONNECT","RECONNECT_ATTEMPT","RECONNECTING","RECONNECT_ERROR","RECONNECT_FAILED","KEEP_ALIVE","KEEP_ALIVE_RESPONSE","CLOSE","ERROR","defaultServers","Logger","options","debug","message","data","toLog","JSON","stringify","now","Date","toUTCString","console","log","_log","_error","global","freeSelf","freeGlobal","root","objectProto","nativeObjectToString","symToStringTag","isOwn","tag","unmasked","e","nullTag","undefinedTag","getRawTag","objectToString","symbolTag","isObjectLike","baseGetTag","NAN","reTrim","reIsBadHex","reIsBinary","reIsOctal","freeParseInt","parseInt","isSymbol","isObject","other","valueOf","replace","isBinary","test","FUNC_ERROR_TEXT","nativeMax","Math","max","nativeMin","min","func","wait","lastArgs","lastThis","maxWait","timerId","lastCallTime","lastInvokeTime","leading","maxing","trailing","invokeFunc","time","args","thisArg","apply","shouldInvoke","timeSinceLastCall","timerExpired","trailingEdge","setTimeout","timeWaiting","remainingWait","debounced","isInvoking","arguments","leadingEdge","clearTimeout","toNumber","cancel","flush","defaultOptions","url","token","forceNew","reconnectionDelay","reconnectionDelayMax","timeout","keepAliveTimeout","protocol","transports","upgrade","allConnections","listenersMap","Map","EventsSDK","servers","server","socket","connected","connections","connectionEstablished","shouldReconnect","_initReconnectOptions","_listenersMap","_retryConnection","debounce","_connect","bind","reconnectOptions","retryCount","minReconnectionDelay","maxReconnectionDelay","_initReconnectDelays","eventTypes","CONNECT","minReconnectDelay","io","attempts","newDelay","_initSocketConnection","packet","serverToConnect","_findCurrentServer","_findNextAvailableServer","_findMaxPriorityServer","_initSocketEvents","_initKeepAlive","login","domain","Domain","closeAllConnections","on","_onReconnectAttempt","_onReconnectFailed","_onConnect","_onDisconnect","_onConnectError","_onConnectTimeout","_onKeepAlive","onevent","_onEvent","_this","emit","currentServerPriority","Priority","nextServerPriority","nextServer","find","chosenServer","maxPriority","maxPriorityServer","fetch","res","json","evt","_parsePacket","callback","eventName","_getServers","connection","close","set","_checkInit","resolved","_this2","window","sdk"],"mappings":"weAOA,IAAIA,EAAW,SAAUC,GAGvB,IAEIC,EAFAC,EAAKC,OAAOC,UACZC,EAASH,EAAGI,eAEZC,EAA4B,mBAAXC,OAAwBA,OAAS,GAClDC,EAAiBF,EAAQG,UAAY,aACrCC,EAAsBJ,EAAQK,eAAiB,kBAC/CC,EAAoBN,EAAQO,aAAe,gBAE/C,SAASC,EAAKC,EAASC,EAASC,EAAMC,GAEpC,IAAIC,EAAiBH,GAAWA,EAAQb,qBAAqBiB,EAAYJ,EAAUI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,EAAMnQ,KAAKoQ,aAAanC,QACvB5H,OAAOY,2BAAoBkJ,EAAIpN,MAAQoN,QACvCnD,cAAczM,QAAQ,SAAC8P,EAAUC,GAClB,MAAdA,EACFD,EAASF,GACAA,EAAIpN,OAASuN,GACtBD,EAASF,mIAUTnQ,KAAK6M,gEACA,iBAEL7M,KAAK0M,aACF6C,KAAK7B,EAAWxH,gBAEjBlG,KAAKuQ,iCACNpD,gBACAM,0CACE,sIAOA9B,QACFrF,QAAQqF,MAAQA,gDAMrBS,EAAe7L,QAAQ,SAAAiQ,GACrBA,EAAWC,UAEbrE,EAAiB,6CAMZU,iBAAkB,OAClBE,cAAgB,IAAIV,SACpBqC,iDAQJ2B,EAAWD,QACPrD,cAAc0D,IAAIJ,EAAWD,QAC7BM,0CASFL,OAAW7J,yDAAO,QAChBkK,kBACAtK,OAAOY,sBAAeqJ,GAAa7J,QACnCiG,OAAO6C,KAAKe,EAAW7J,mDAOvBkK,iBACDC,GAAW,SACR,IAAIjQ,QAAQ,SAACC,EAASC,GAC3BgQ,EAAKjC,GAAGlB,EAAWvI,MAAO,SAAAsB,GACxBmK,GAAW,EACXhQ,EAAQ6F,KAEVoK,EAAKtB,KAAK,QAAS,CAAE5D,MAAOkF,EAAKvK,QAAQqF,QACzCkF,EAAKnE,OAAOkC,GAAGlB,EAAWvH,MAAO,SAAAvG,GAC3BgR,GACF/P,EAAOjB,sBE/UK,oBAAXkR,SAETA,OAAOvE,UAAYwE"} \ No newline at end of file +{"version":3,"file":"voicenter-events-sdk.umd.js","sources":["../src/eventTypes.js","../src/config.js","../src/Logger.js","../node_modules/lodash/isObject.js","../node_modules/lodash/_freeGlobal.js","../node_modules/lodash/_root.js","../node_modules/lodash/now.js","../node_modules/lodash/_Symbol.js","../node_modules/lodash/_getRawTag.js","../node_modules/lodash/_objectToString.js","../node_modules/lodash/_baseGetTag.js","../node_modules/lodash/isObjectLike.js","../node_modules/lodash/isSymbol.js","../node_modules/lodash/toNumber.js","../node_modules/lodash/debounce.js","../src/sdk.js","../src/utils.js","../src/index.js"],"sourcesContent":["export default {\n LOGIN: 'loginStatus',\n LOGIN_RESPONSE: 'loginResponse',\n QUEUE_EVENT: 'QueueEvent',\n EXTENSION_EVENT: 'ExtensionEvent',\n ALL_EXTENSION_STATUS: 'AllExtensionsStatus',\n CONNECT_ERROR: 'connect_error',\n CONNECT_TIMEOUT: 'connect_timeout',\n DISCONNECT: 'disconnect',\n RECONNECT: 'reconnect',\n RECONNECT_ATTEMPT: 'reconnect_attempt',\n RECONNECTING: 'reconnecting',\n RECONNECT_ERROR: 'reconnect_error',\n RECONNECT_FAILED: 'reconnect_failed',\n KEEP_ALIVE: 'keepalive',\n KEEP_ALIVE_RESPONSE: 'keepaliveResponse',\n CLOSE: 'closeme',\n ERROR: 'error',\n}\n","export const defaultServers = [{\n 'URLID': 59,\n 'Priority': 5,\n 'Version': 2,\n 'Domain': 'monitor1.voicenter.co'\n}, {\n 'URLID': 3,\n 'Priority': 4,\n 'Version': 2,\n 'Domain': 'monitor3.voicenter.co.il'\n}, {\n 'URLID': 4,\n 'Priority': 3,\n 'Version': 2,\n 'Domain': 'monitor4.voicenter.co.il'\n}, {\n 'URLID': 11,\n 'Priority': 2,\n 'Version': 2,\n 'Domain': 'monitor11.voicenter.co'\n}, {\n 'URLID': 5,\n 'Priority': 0,\n 'Version': 2,\n 'Domain': 'monitor5.voicenter.co.il'\n}];\n","\nclass Logger {\n constructor(options = {}) {\n this.debug = options.debug\n }\n\n /**\n * Logs to console a colored message\n * @param message\n * @param data\n * @private\n */\n _log(message, data) {\n let toLog = data ? `${message}, %c Data -> ${JSON.stringify(data)}` : `${message}`\n let now = new Date().toUTCString()\n console.log(`%c ${now}: %c ${toLog}`, `color: #276749;`, `color: #4299e1;`, `color: #2c3e50;`)\n }\n\n /**\n * Logs to console a colored message\n * @param message\n * @param data\n * @private\n */\n _error(message, data) {\n let toLog = data ? `${message}, Data -> ${JSON.stringify(data)}` : `${message}`\n let now = new Date().toUTCString()\n console.error(`${now}: ${toLog}`)\n }\n\n /**\n * Logs messages in case debug mode is set\n * @param message\n * @param data\n */\n log(message, data) {\n if (this.debug) {\n if (message && !data) {\n this._log(message)\n } else {\n this._log(message, data)\n }\n }\n }\n /**\n * Logs error messages in case debug mode is set\n * @param message\n * @param data\n */\n error(message, data) {\n if (this.debug) {\n if (message && !data) {\n this._error(message)\n } else {\n this._error(message, data)\n }\n }\n }\n}\n\nexport default Logger\n","/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\nmodule.exports = isObject;\n","/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\nmodule.exports = freeGlobal;\n","var freeGlobal = require('./_freeGlobal');\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\nmodule.exports = root;\n","var root = require('./_root');\n\n/**\n * Gets the timestamp of the number of milliseconds that have elapsed since\n * the Unix epoch (1 January 1970 00:00:00 UTC).\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Date\n * @returns {number} Returns the timestamp.\n * @example\n *\n * _.defer(function(stamp) {\n * console.log(_.now() - stamp);\n * }, _.now());\n * // => Logs the number of milliseconds it took for the deferred invocation.\n */\nvar now = function() {\n return root.Date.now();\n};\n\nmodule.exports = now;\n","var root = require('./_root');\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\n\nmodule.exports = Symbol;\n","var Symbol = require('./_Symbol');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\n\nmodule.exports = getRawTag;\n","/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\n\nmodule.exports = objectToString;\n","var Symbol = require('./_Symbol'),\n getRawTag = require('./_getRawTag'),\n objectToString = require('./_objectToString');\n\n/** `Object#toString` result references. */\nvar nullTag = '[object Null]',\n undefinedTag = '[object Undefined]';\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n}\n\nmodule.exports = baseGetTag;\n","/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return value != null && typeof value == 'object';\n}\n\nmodule.exports = isObjectLike;\n","var baseGetTag = require('./_baseGetTag'),\n isObjectLike = require('./isObjectLike');\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && baseGetTag(value) == symbolTag);\n}\n\nmodule.exports = isSymbol;\n","var isObject = require('./isObject'),\n isSymbol = require('./isSymbol');\n\n/** Used as references for various `Number` constants. */\nvar NAN = 0 / 0;\n\n/** Used to match leading and trailing whitespace. */\nvar reTrim = /^\\s+|\\s+$/g;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = value.replace(reTrim, '');\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\nmodule.exports = toNumber;\n","var isObject = require('./isObject'),\n now = require('./now'),\n toNumber = require('./toNumber');\n\n/** Error message constants. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max,\n nativeMin = Math.min;\n\n/**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed `func` invocations and a `flush` method to immediately invoke them.\n * Provide `options` to indicate whether `func` should be invoked on the\n * leading and/or trailing edge of the `wait` timeout. The `func` is invoked\n * with the last arguments provided to the debounced function. Subsequent\n * calls to the debounced function return the result of the last `func`\n * invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the debounced function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.debounce` and `_.throttle`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to debounce.\n * @param {number} [wait=0] The number of milliseconds to delay.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=false]\n * Specify invoking on the leading edge of the timeout.\n * @param {number} [options.maxWait]\n * The maximum time `func` is allowed to be delayed before it's invoked.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new debounced function.\n * @example\n *\n * // Avoid costly calculations while the window size is in flux.\n * jQuery(window).on('resize', _.debounce(calculateLayout, 150));\n *\n * // Invoke `sendMail` when clicked, debouncing subsequent calls.\n * jQuery(element).on('click', _.debounce(sendMail, 300, {\n * 'leading': true,\n * 'trailing': false\n * }));\n *\n * // Ensure `batchLog` is invoked once after 1 second of debounced calls.\n * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });\n * var source = new EventSource('/stream');\n * jQuery(source).on('message', debounced);\n *\n * // Cancel the trailing debounced invocation.\n * jQuery(window).on('popstate', debounced.cancel);\n */\nfunction debounce(func, wait, options) {\n var lastArgs,\n lastThis,\n maxWait,\n result,\n timerId,\n lastCallTime,\n lastInvokeTime = 0,\n leading = false,\n maxing = false,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n wait = toNumber(wait) || 0;\n if (isObject(options)) {\n leading = !!options.leading;\n maxing = 'maxWait' in options;\n maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n\n function invokeFunc(time) {\n var args = lastArgs,\n thisArg = lastThis;\n\n lastArgs = lastThis = undefined;\n lastInvokeTime = time;\n result = func.apply(thisArg, args);\n return result;\n }\n\n function leadingEdge(time) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time;\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait);\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result;\n }\n\n function remainingWait(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime,\n timeWaiting = wait - timeSinceLastCall;\n\n return maxing\n ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)\n : timeWaiting;\n }\n\n function shouldInvoke(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||\n (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));\n }\n\n function timerExpired() {\n var time = now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time));\n }\n\n function trailingEdge(time) {\n timerId = undefined;\n\n // Only invoke if we have `lastArgs` which means `func` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = undefined;\n return result;\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = undefined;\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(now());\n }\n\n function debounced() {\n var time = now(),\n isInvoking = shouldInvoke(time);\n\n lastArgs = arguments;\n lastThis = this;\n lastCallTime = time;\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n clearTimeout(timerId);\n timerId = setTimeout(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait);\n }\n return result;\n }\n debounced.cancel = cancel;\n debounced.flush = flush;\n return debounced;\n}\n\nmodule.exports = debounce;\n","import io from 'socket.io-client/socket.io';\nimport eventTypes from './eventTypes';\nimport { defaultServers } from './config';\nimport Logger from './Logger';\nimport debounce from 'lodash/debounce'\nimport { getServerWithHighestPriority } from './utils';\n\nconst defaultOptions = {\n url: `https://monitorapi.voicenter.co.il/monitorAPI/getMonitorUrls`,\n token: null,\n forceNew: false,\n reconnectionDelay: 10000,\n reconnectionDelayMax: 10000,\n timeout: 10000,\n keepAliveTimeout: 60000,\n protocol: 'https',\n transports: ['websocket'],\n upgrade: false\n};\n\nlet allConnections = []\nlet listenersMap = new Map()\nclass EventsSDK {\n constructor(options = {}) {\n this.options = {\n ...defaultOptions,\n ...options,\n };\n if (!this.options.token) {\n throw new Error('A token property should be provided');\n }\n this.Logger = new Logger(this.options);\n this.servers = [];\n this.server = null;\n this.socket = null;\n this.connected = false\n this.connections = allConnections\n this.connectionEstablished = false;\n this.shouldReconnect = true\n this._initReconnectOptions();\n this._listenersMap = listenersMap\n this._retryConnection = debounce(this._connect.bind(this), this.reconnectOptions.reconnectionDelay, { leading: true, trailing: false })\n }\n\n _initReconnectOptions() {\n this.reconnectOptions = {\n retryCount: 1,\n reconnectionDelay: this.options.reconnectionDelay, // 10 seconds. After each re-connection attempt this number will increase (minReconnectionDelay * attempts) => 10, 20, 30, 40 seconds ... up to 5min\n minReconnectionDelay: this.options.reconnectionDelay, // 10 seconds\n maxReconnectionDelay: 60000 * 5 // 5 minutes\n }\n }\n _onConnect() {\n this._initReconnectDelays()\n this.connected = true\n this.Logger.log(eventTypes.CONNECT, this.reconnectOptions)\n }\n\n _initReconnectDelays() {\n this.reconnectOptions.retryCount = 1;\n let minReconnectDelay = this.reconnectOptions.minReconnectionDelay;\n this.reconnectOptions.reconnectionDelay = minReconnectDelay;\n this.socket.io.reconnectionDelay(minReconnectDelay);\n this.socket.io.reconnectionDelayMax(minReconnectDelay);\n }\n\n _onConnectError(data) {\n this._retryConnection('next')\n this.connected = false\n this.Logger.log(eventTypes.CONNECT_ERROR, data)\n }\n\n _onReconnectFailed() {\n this._retryConnection('next')\n this.Logger.log(eventTypes.RECONNECT_FAILED, this.reconnectOptions)\n }\n\n _onConnectTimeout() {\n this._retryConnection('next')\n this.Logger.log(eventTypes.CONNECT_TIMEOUT, this.reconnectOptions)\n }\n\n _onReconnectAttempt(attempts) {\n if (attempts > 2) {\n this._retryConnection('next')\n return\n }\n if (this.reconnectOptions.reconnectionDelay < this.reconnectOptions.maxReconnectionDelay) {\n let newDelay = this.reconnectOptions.minReconnectionDelay * this.reconnectOptions.retryCount;\n this.reconnectOptions.reconnectionDelay = newDelay;\n this.socket.io.reconnectionDelay(newDelay);\n this.socket.io.reconnectionDelayMax(newDelay);\n }\n this.reconnectOptions.retryCount++;\n this.Logger.log(eventTypes.RECONNECT_ATTEMPT, this.reconnectOptions)\n }\n\n _onDisconnect() {\n if (this.shouldReconnect) {\n this._connect('next')\n }\n this.connected = false\n this.Logger.log(eventTypes.DISCONNECT, this.reconnectOptions)\n }\n\n _onKeepAlive(data) {\n if(data === false && this.connected) {\n this._initSocketConnection()\n this.Logger.log(eventTypes.KEEP_ALIVE_RESPONSE, this.reconnectOptions)\n }\n }\n\n _parsePacket(packet) {\n if (!packet.data) {\n return {};\n }\n let name = packet.data[0];\n let data = packet.data[1];\n return {\n name,\n data\n };\n }\n\n _connect(server = 'default') {\n this.shouldReconnect = true\n let serverToConnect = null\n if (server === 'default') {\n serverToConnect = this._findCurrentServer();\n } else if (server === 'next') {\n serverToConnect = this._findNextAvailableServer()\n } else if (server === 'prev') {\n serverToConnect = this._findMaxPriorityServer()\n } else {\n throw new Error(`Incorrect 'server' parameter passed to connect function ${server}. Should be 'default' or 'next'`)\n }\n if (!serverToConnect) {\n // skip the connect because we didn't find a new server to connect to.\n return\n }\n this._initSocketConnection();\n this._initSocketEvents();\n this._initKeepAlive();\n if (server !== 'default'){\n this.login()\n }\n }\n\n _checkInit() {\n if (!this.connectionEstablished) {\n throw new Error('Make sure you call \"sdk.init()\" before doing other operations.')\n }\n }\n\n _initSocketConnection() {\n let domain = this.server.Domain;\n let protocol = this.options.protocol;\n let url = `${protocol}://${domain}`;\n this.Logger.log('Connecting to..', url)\n this.closeAllConnections()\n this.socket = io(url, {\n ...this.options,\n debug: false\n });\n allConnections.push(this.socket)\n this.connectionEstablished = true;\n }\n\n _initSocketEvents() {\n this.socket.on(eventTypes.RECONNECT_ATTEMPT, this._onReconnectAttempt.bind(this));\n this.socket.on(eventTypes.RECONNECT_FAILED, this._onReconnectFailed.bind(this));\n this.socket.on(eventTypes.CONNECT, this._onConnect.bind(this));\n this.socket.on(eventTypes.DISCONNECT, this._onDisconnect.bind(this));\n this.socket.on(eventTypes.CONNECT_ERROR, this._onConnectError.bind(this));\n this.socket.on(eventTypes.CONNECT_TIMEOUT, this._onConnectTimeout.bind(this));\n this.socket.on(eventTypes.KEEP_ALIVE_RESPONSE, this._onKeepAlive.bind(this));\n this.socket.onevent = this._onEvent.bind(this)\n }\n\n _initKeepAlive() {\n setTimeout(()=>{\n if(this.socket) {\n this.emit(eventTypes.KEEP_ALIVE, this.options.token);\n this._connect('prev')\n }\n else {\n this._initSocketConnection()\n }\n }, this.options.keepAliveTimeout);\n }\n\n _findCurrentServer() {\n let server = null;\n if (this.servers.length) {\n server = this.servers[0];\n }\n this.server = server;\n if (!this.server) {\n throw new Error('Could not find any server to establish connection with');\n }\n return this.server\n }\n\n _findNextAvailableServer() {\n let currentServerPriority = this.server.Priority;\n this.Logger.log(`Failover -> Trying to find another server`)\n if (currentServerPriority > 0) {\n let nextServerPriority = currentServerPriority - 1;\n let nextServer = this.servers.find(server => server.Priority === nextServerPriority);\n if (!nextServer) {\n nextServer = this._findMaxPriorityServer()\n if (!nextServer) {\n return\n }\n }\n if (this.server.Domain !== nextServer.Domain) {\n this.server = nextServer;\n return this.server\n }\n this.Logger.log(`Failover -> Found new server. Connecting to it...`, this.server)\n }\n return null\n }\n\n _findMaxPriorityServer() {\n this.Logger.log(`Fallback -> Trying to find previous server`, '_findMaxPriorityServer')\n let maxPriorityServer = getServerWithHighestPriority(this.servers)\n if(this.server && maxPriorityServer.Domain !== this.server.Domain) {\n this.server = maxPriorityServer;\n this.Logger.log(`Fallback -> Trying to find previous server`, this.server)\n return this.server\n }\n return null\n }\n\n async _getServers() {\n try {\n let res = await fetch(`${this.options.url}/${this.options.token}`);\n this.servers = await res.json();\n } catch (e) {\n this.servers = defaultServers;\n }\n }\n\n _onEvent(packet) {\n if (!packet.data) {\n return;\n }\n let evt = this._parsePacket(packet);\n this.Logger.log(`New event -> ${evt.name}`, evt);\n this._listenersMap.forEach((callback, eventName) => {\n if (eventName === '*') {\n callback(evt);\n } else if (evt.name === eventName) {\n callback(evt);\n }\n })\n }\n\n /**\n * Initializes socket connection. Should be called before any other action\n * @return {Promise}\n */\n async init() {\n if (this.connectionEstablished) {\n return true;\n }\n if (this.socket) {\n this.emit(eventTypes.CLOSE)\n }\n await this._getServers();\n this._connect()\n this._initReconnectDelays()\n return true\n }\n\n /**\n * Sets the monitor code token\n * @param token\n */\n setToken(token) {\n this.options.token = token\n }\n /**\n * Closes all existing connections\n */\n closeAllConnections() {\n allConnections.forEach(connection => {\n connection.close()\n })\n allConnections = []\n }\n /**\n * Disconnects the socket instance from the servers\n */\n disconnect() {\n this.shouldReconnect = false\n this._listenersMap = new Map()\n this.closeAllConnections()\n }\n\n /**\n * Listens for new events\n * @param {string} eventName (name of the event, * for all events)\n * @param {function} callback (callback function when even with the specified name is received)\n */\n on(eventName, callback) {\n this._listenersMap.set(eventName, callback)\n this._checkInit()\n }\n\n /**\n * Emits an event to the server\n * @param {string} eventName (name of the event)\n * @param {object} data (data for the event)\n */\n\n emit(eventName, data = {}) {\n this._checkInit()\n this.Logger.log(`EMIT -> ${eventName}`, data)\n this.socket.emit(eventName, data);\n }\n\n /**\n * Login (logs in based on the token/credentials provided)\n */\n login() {\n this._checkInit()\n let resolved = false\n return new Promise((resolve, reject) => {\n this.on(eventTypes.LOGIN, data => {\n resolved = true\n resolve(data)\n })\n this.emit('login', { token: this.options.token });\n this.socket.on(eventTypes.ERROR, err => {\n if(!resolved) {\n reject(err);\n }\n })\n });\n }\n\n}\n\nexport default EventsSDK;\n","export function getServerWithHighestPriority(servers) {\n let chosenServer = null\n let maxPriority = -1\n servers.forEach(server => {\n if (server.Priority > maxPriority) {\n maxPriority = server.Priority\n chosenServer = server\n }\n })\n return chosenServer\n}\n","const version = '__VERSION__'\nimport sdk from './sdk'\nif (typeof window !== 'undefined') {\n // Make it available on window\n window.EventsSDK = sdk\n}\n\nexport default sdk\n"],"names":["LOGIN","LOGIN_RESPONSE","QUEUE_EVENT","EXTENSION_EVENT","ALL_EXTENSION_STATUS","CONNECT_ERROR","CONNECT_TIMEOUT","DISCONNECT","RECONNECT","RECONNECT_ATTEMPT","RECONNECTING","RECONNECT_ERROR","RECONNECT_FAILED","KEEP_ALIVE","KEEP_ALIVE_RESPONSE","CLOSE","ERROR","defaultServers","Logger","options","debug","message","data","toLog","JSON","stringify","now","Date","toUTCString","console","log","error","this","_log","_error","value","type","global","Object","freeSelf","self","freeGlobal","Function","root","Symbol","objectProto","prototype","hasOwnProperty","nativeObjectToString","toString","symToStringTag","toStringTag","undefined","isOwn","call","tag","unmasked","e","result","nullTag","undefinedTag","getRawTag","objectToString","symbolTag","isObjectLike","baseGetTag","NAN","reTrim","reIsBadHex","reIsBinary","reIsOctal","freeParseInt","parseInt","isSymbol","isObject","other","valueOf","replace","isBinary","test","slice","FUNC_ERROR_TEXT","nativeMax","Math","max","nativeMin","min","func","wait","lastArgs","lastThis","maxWait","timerId","lastCallTime","lastInvokeTime","leading","maxing","trailing","TypeError","invokeFunc","time","args","thisArg","apply","shouldInvoke","timeSinceLastCall","timerExpired","trailingEdge","setTimeout","timeWaiting","remainingWait","debounced","isInvoking","arguments","leadingEdge","clearTimeout","toNumber","cancel","flush","defaultOptions","url","token","forceNew","reconnectionDelay","reconnectionDelayMax","timeout","keepAliveTimeout","protocol","transports","upgrade","allConnections","listenersMap","Map","EventsSDK","Error","servers","server","socket","connected","connections","connectionEstablished","shouldReconnect","_initReconnectOptions","_listenersMap","_retryConnection","debounce","_connect","bind","reconnectOptions","retryCount","minReconnectionDelay","maxReconnectionDelay","_initReconnectDelays","eventTypes","CONNECT","minReconnectDelay","io","attempts","newDelay","_initSocketConnection","packet","name","serverToConnect","_findCurrentServer","_findNextAvailableServer","_findMaxPriorityServer","_initSocketEvents","_initKeepAlive","login","domain","Domain","closeAllConnections","push","on","_onReconnectAttempt","_onReconnectFailed","_onConnect","_onDisconnect","_onConnectError","_onConnectTimeout","_onKeepAlive","onevent","_onEvent","_this","emit","length","currentServerPriority","Priority","nextServerPriority","nextServer","find","chosenServer","maxPriority","maxPriorityServer","forEach","res","fetch","json","evt","_parsePacket","callback","eventName","_getServers","connection","close","set","_checkInit","resolved","Promise","resolve","reject","_this2","err","window","sdk"],"mappings":"ioBAAe,CACbA,MAAO,cACPC,eAAgB,gBAChBC,YAAa,aACbC,gBAAiB,iBACjBC,qBAAsB,sBACtBC,cAAe,gBACfC,gBAAiB,kBACjBC,WAAY,aACZC,UAAW,YACXC,kBAAmB,oBACnBC,aAAc,eACdC,gBAAiB,kBACjBC,iBAAkB,mBAClBC,WAAY,YACZC,oBAAqB,oBACrBC,MAAO,UACPC,MAAO,SCjBIC,EAAiB,CAAC,OACpB,YACG,UACD,SACD,yBACT,OACQ,WACG,UACD,SACD,4BACT,OACQ,WACG,UACD,SACD,4BACT,OACQ,YACG,UACD,SACD,0BACT,OACQ,WACG,UACD,SACD,6BCvBNC,8BACQC,yDAAU,kBACfC,MAAQD,EAAQC,6CASlBC,EAASC,OACRC,EAAQD,YAAUD,0BAAuBG,KAAKC,UAAUH,cAAaD,GACrEK,GAAM,IAAIC,MAAOC,cACrBC,QAAQC,iBAAUJ,kBAAWH,yFASxBF,EAASC,OACVC,EAAQD,YAAUD,uBAAoBG,KAAKC,UAAUH,cAAaD,GAClEK,GAAM,IAAIC,MAAOC,cACrBC,QAAQE,gBAASL,eAAQ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