1 (function webpackUniversalModuleDefinition(root, factory) {
2 if(typeof exports === 'object' && typeof module === 'object')
3 module.exports = factory();
4 else if(typeof define === 'function' && define.amd)
6 else if(typeof exports === 'object')
7 exports["eio"] = factory();
9 root["eio"] = factory();
11 return /******/ (function(modules) { // webpackBootstrap
12 /******/ // The module cache
13 /******/ var installedModules = {};
15 /******/ // The require function
16 /******/ function __webpack_require__(moduleId) {
18 /******/ // Check if module is in cache
19 /******/ if(installedModules[moduleId])
20 /******/ return installedModules[moduleId].exports;
22 /******/ // Create a new module (and put it into the cache)
23 /******/ var module = installedModules[moduleId] = {
25 /******/ id: moduleId,
26 /******/ loaded: false
29 /******/ // Execute the module function
30 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
32 /******/ // Flag the module as loaded
33 /******/ module.loaded = true;
35 /******/ // Return the exports of the module
36 /******/ return module.exports;
40 /******/ // expose the modules object (__webpack_modules__)
41 /******/ __webpack_require__.m = modules;
43 /******/ // expose the module cache
44 /******/ __webpack_require__.c = installedModules;
46 /******/ // __webpack_public_path__
47 /******/ __webpack_require__.p = "";
49 /******/ // Load entry module and return exports
50 /******/ return __webpack_require__(0);
52 /************************************************************************/
55 /***/ function(module, exports, __webpack_require__) {
58 module.exports = __webpack_require__(1);
66 module.exports.parser = __webpack_require__(9);
71 /***/ function(module, exports, __webpack_require__) {
74 * Module dependencies.
77 var transports = __webpack_require__(2);
78 var Emitter = __webpack_require__(18);
79 var debug = __webpack_require__(22)('engine.io-client:socket');
80 var index = __webpack_require__(29);
81 var parser = __webpack_require__(9);
82 var parseuri = __webpack_require__(30);
83 var parseqs = __webpack_require__(19);
89 module.exports = Socket;
94 * @param {String|Object} uri or options
95 * @param {Object} options
99 function Socket (uri, opts) {
100 if (!(this instanceof Socket)) return new Socket(uri, opts);
104 if (uri && 'object' === typeof uri) {
111 opts.hostname = uri.host;
112 opts.secure = uri.protocol === 'https' || uri.protocol === 'wss';
113 opts.port = uri.port;
114 if (uri.query) opts.query = uri.query;
115 } else if (opts.host) {
116 opts.hostname = parseuri(opts.host).host;
119 this.secure = null != opts.secure ? opts.secure
120 : (typeof location !== 'undefined' && 'https:' === location.protocol);
122 if (opts.hostname && !opts.port) {
123 // if no port is specified manually, use the protocol default
124 opts.port = this.secure ? '443' : '80';
127 this.agent = opts.agent || false;
128 this.hostname = opts.hostname ||
129 (typeof location !== 'undefined' ? location.hostname : 'localhost');
130 this.port = opts.port || (typeof location !== 'undefined' && location.port
132 : (this.secure ? 443 : 80));
133 this.query = opts.query || {};
134 if ('string' === typeof this.query) this.query = parseqs.decode(this.query);
135 this.upgrade = false !== opts.upgrade;
136 this.path = (opts.path || '/engine.io').replace(/\/$/, '') + '/';
137 this.forceJSONP = !!opts.forceJSONP;
138 this.jsonp = false !== opts.jsonp;
139 this.forceBase64 = !!opts.forceBase64;
140 this.enablesXDR = !!opts.enablesXDR;
141 this.withCredentials = false !== opts.withCredentials;
142 this.timestampParam = opts.timestampParam || 't';
143 this.timestampRequests = opts.timestampRequests;
144 this.transports = opts.transports || ['polling', 'websocket'];
145 this.transportOptions = opts.transportOptions || {};
146 this.readyState = '';
147 this.writeBuffer = [];
148 this.prevBufferLen = 0;
149 this.policyPort = opts.policyPort || 843;
150 this.rememberUpgrade = opts.rememberUpgrade || false;
151 this.binaryType = null;
152 this.onlyBinaryUpgrades = opts.onlyBinaryUpgrades;
153 this.perMessageDeflate = false !== opts.perMessageDeflate ? (opts.perMessageDeflate || {}) : false;
155 if (true === this.perMessageDeflate) this.perMessageDeflate = {};
156 if (this.perMessageDeflate && null == this.perMessageDeflate.threshold) {
157 this.perMessageDeflate.threshold = 1024;
160 // SSL options for Node.js client
161 this.pfx = opts.pfx || undefined;
162 this.key = opts.key || undefined;
163 this.passphrase = opts.passphrase || undefined;
164 this.cert = opts.cert || undefined;
165 this.ca = opts.ca || undefined;
166 this.ciphers = opts.ciphers || undefined;
167 this.rejectUnauthorized = opts.rejectUnauthorized === undefined ? true : opts.rejectUnauthorized;
168 this.forceNode = !!opts.forceNode;
170 // detect ReactNative environment
171 this.isReactNative = (typeof navigator !== 'undefined' && typeof navigator.product === 'string' && navigator.product.toLowerCase() === 'reactnative');
173 // other options for Node.js or ReactNative client
174 if (typeof self === 'undefined' || this.isReactNative) {
175 if (opts.extraHeaders && Object.keys(opts.extraHeaders).length > 0) {
176 this.extraHeaders = opts.extraHeaders;
179 if (opts.localAddress) {
180 this.localAddress = opts.localAddress;
186 this.upgrades = null;
187 this.pingInterval = null;
188 this.pingTimeout = null;
191 this.pingIntervalTimer = null;
192 this.pingTimeoutTimer = null;
197 Socket.priorWebsocketSuccess = false;
203 Emitter(Socket.prototype);
211 Socket.protocol = parser.protocol; // this is an int
214 * Expose deps for legacy compatibility
215 * and standalone browser access.
218 Socket.Socket = Socket;
219 Socket.Transport = __webpack_require__(8);
220 Socket.transports = __webpack_require__(2);
221 Socket.parser = __webpack_require__(9);
224 * Creates transport of the given type.
226 * @param {String} transport name
227 * @return {Transport}
231 Socket.prototype.createTransport = function (name) {
232 debug('creating transport "%s"', name);
233 var query = clone(this.query);
235 // append engine.io protocol identifier
236 query.EIO = parser.protocol;
239 query.transport = name;
241 // per-transport options
242 var options = this.transportOptions[name] || {};
244 // session id if we already have one
245 if (this.id) query.sid = this.id;
247 var transport = new transports[name]({
250 agent: options.agent || this.agent,
251 hostname: options.hostname || this.hostname,
252 port: options.port || this.port,
253 secure: options.secure || this.secure,
254 path: options.path || this.path,
255 forceJSONP: options.forceJSONP || this.forceJSONP,
256 jsonp: options.jsonp || this.jsonp,
257 forceBase64: options.forceBase64 || this.forceBase64,
258 enablesXDR: options.enablesXDR || this.enablesXDR,
259 withCredentials: options.withCredentials || this.withCredentials,
260 timestampRequests: options.timestampRequests || this.timestampRequests,
261 timestampParam: options.timestampParam || this.timestampParam,
262 policyPort: options.policyPort || this.policyPort,
263 pfx: options.pfx || this.pfx,
264 key: options.key || this.key,
265 passphrase: options.passphrase || this.passphrase,
266 cert: options.cert || this.cert,
267 ca: options.ca || this.ca,
268 ciphers: options.ciphers || this.ciphers,
269 rejectUnauthorized: options.rejectUnauthorized || this.rejectUnauthorized,
270 perMessageDeflate: options.perMessageDeflate || this.perMessageDeflate,
271 extraHeaders: options.extraHeaders || this.extraHeaders,
272 forceNode: options.forceNode || this.forceNode,
273 localAddress: options.localAddress || this.localAddress,
274 requestTimeout: options.requestTimeout || this.requestTimeout,
275 protocols: options.protocols || void (0),
276 isReactNative: this.isReactNative
282 function clone (obj) {
285 if (obj.hasOwnProperty(i)) {
293 * Initializes transport to use and starts probe.
297 Socket.prototype.open = function () {
299 if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') !== -1) {
300 transport = 'websocket';
301 } else if (0 === this.transports.length) {
302 // Emit error on next tick so it can be listened to
304 setTimeout(function () {
305 self.emit('error', 'No transports available');
309 transport = this.transports[0];
311 this.readyState = 'opening';
313 // Retry with the next transport if the transport is disabled (jsonp: false)
315 transport = this.createTransport(transport);
317 this.transports.shift();
323 this.setTransport(transport);
327 * Sets the current transport. Disables the existing one (if any).
332 Socket.prototype.setTransport = function (transport) {
333 debug('setting transport %s', transport.name);
336 if (this.transport) {
337 debug('clearing existing transport %s', this.transport.name);
338 this.transport.removeAllListeners();
342 this.transport = transport;
344 // set up transport listeners
346 .on('drain', function () {
349 .on('packet', function (packet) {
350 self.onPacket(packet);
352 .on('error', function (e) {
355 .on('close', function () {
356 self.onClose('transport close');
361 * Probes a transport.
363 * @param {String} transport name
367 Socket.prototype.probe = function (name) {
368 debug('probing transport "%s"', name);
369 var transport = this.createTransport(name, { probe: 1 });
373 Socket.priorWebsocketSuccess = false;
375 function onTransportOpen () {
376 if (self.onlyBinaryUpgrades) {
377 var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary;
378 failed = failed || upgradeLosesBinary;
382 debug('probe transport "%s" opened', name);
383 transport.send([{ type: 'ping', data: 'probe' }]);
384 transport.once('packet', function (msg) {
386 if ('pong' === msg.type && 'probe' === msg.data) {
387 debug('probe transport "%s" pong', name);
388 self.upgrading = true;
389 self.emit('upgrading', transport);
390 if (!transport) return;
391 Socket.priorWebsocketSuccess = 'websocket' === transport.name;
393 debug('pausing current transport "%s"', self.transport.name);
394 self.transport.pause(function () {
396 if ('closed' === self.readyState) return;
397 debug('changing transport and sending upgrade packet');
401 self.setTransport(transport);
402 transport.send([{ type: 'upgrade' }]);
403 self.emit('upgrade', transport);
405 self.upgrading = false;
409 debug('probe transport "%s" failed', name);
410 var err = new Error('probe error');
411 err.transport = transport.name;
412 self.emit('upgradeError', err);
417 function freezeTransport () {
420 // Any callback called by transport should be ignored since now
429 // Handle any error that happens while probing
430 function onerror (err) {
431 var error = new Error('probe error: ' + err);
432 error.transport = transport.name;
436 debug('probe transport "%s" failed because of error: %s', name, err);
438 self.emit('upgradeError', error);
441 function onTransportClose () {
442 onerror('transport closed');
445 // When the socket is closed while we're probing
446 function onclose () {
447 onerror('socket closed');
450 // When the socket is upgraded while we're probing
451 function onupgrade (to) {
452 if (transport && to.name !== transport.name) {
453 debug('"%s" works - aborting "%s"', to.name, transport.name);
458 // Remove all listeners on the transport and on self
459 function cleanup () {
460 transport.removeListener('open', onTransportOpen);
461 transport.removeListener('error', onerror);
462 transport.removeListener('close', onTransportClose);
463 self.removeListener('close', onclose);
464 self.removeListener('upgrading', onupgrade);
467 transport.once('open', onTransportOpen);
468 transport.once('error', onerror);
469 transport.once('close', onTransportClose);
471 this.once('close', onclose);
472 this.once('upgrading', onupgrade);
478 * Called when connection is deemed open.
483 Socket.prototype.onOpen = function () {
484 debug('socket open');
485 this.readyState = 'open';
486 Socket.priorWebsocketSuccess = 'websocket' === this.transport.name;
490 // we check for `readyState` in case an `open`
491 // listener already closed the socket
492 if ('open' === this.readyState && this.upgrade && this.transport.pause) {
493 debug('starting upgrade probes');
494 for (var i = 0, l = this.upgrades.length; i < l; i++) {
495 this.probe(this.upgrades[i]);
506 Socket.prototype.onPacket = function (packet) {
507 if ('opening' === this.readyState || 'open' === this.readyState ||
508 'closing' === this.readyState) {
509 debug('socket receive: type "%s", data "%s"', packet.type, packet.data);
511 this.emit('packet', packet);
513 // Socket is live - any packet counts
514 this.emit('heartbeat');
516 switch (packet.type) {
518 this.onHandshake(JSON.parse(packet.data));
527 var err = new Error('server error');
528 err.code = packet.data;
533 this.emit('data', packet.data);
534 this.emit('message', packet.data);
538 debug('packet received with socket readyState "%s"', this.readyState);
543 * Called upon handshake completion.
545 * @param {Object} handshake obj
549 Socket.prototype.onHandshake = function (data) {
550 this.emit('handshake', data);
552 this.transport.query.sid = data.sid;
553 this.upgrades = this.filterUpgrades(data.upgrades);
554 this.pingInterval = data.pingInterval;
555 this.pingTimeout = data.pingTimeout;
557 // In case open handler closes socket
558 if ('closed' === this.readyState) return;
561 // Prolong liveness of socket on heartbeat
562 this.removeListener('heartbeat', this.onHeartbeat);
563 this.on('heartbeat', this.onHeartbeat);
567 * Resets ping timeout.
572 Socket.prototype.onHeartbeat = function (timeout) {
573 clearTimeout(this.pingTimeoutTimer);
575 self.pingTimeoutTimer = setTimeout(function () {
576 if ('closed' === self.readyState) return;
577 self.onClose('ping timeout');
578 }, timeout || (self.pingInterval + self.pingTimeout));
582 * Pings server every `this.pingInterval` and expects response
583 * within `this.pingTimeout` or closes connection.
588 Socket.prototype.setPing = function () {
590 clearTimeout(self.pingIntervalTimer);
591 self.pingIntervalTimer = setTimeout(function () {
592 debug('writing ping packet - expecting pong within %sms', self.pingTimeout);
594 self.onHeartbeat(self.pingTimeout);
595 }, self.pingInterval);
599 * Sends a ping packet.
604 Socket.prototype.ping = function () {
606 this.sendPacket('ping', function () {
612 * Called on `drain` event
617 Socket.prototype.onDrain = function () {
618 this.writeBuffer.splice(0, this.prevBufferLen);
620 // setting prevBufferLen = 0 is very important
621 // for example, when upgrading, upgrade packet is sent over,
622 // and a nonzero prevBufferLen could cause problems on `drain`
623 this.prevBufferLen = 0;
625 if (0 === this.writeBuffer.length) {
633 * Flush write buffers.
638 Socket.prototype.flush = function () {
639 if ('closed' !== this.readyState && this.transport.writable &&
640 !this.upgrading && this.writeBuffer.length) {
641 debug('flushing %d packets in socket', this.writeBuffer.length);
642 this.transport.send(this.writeBuffer);
643 // keep track of current length of writeBuffer
644 // splice writeBuffer and callbackBuffer on `drain`
645 this.prevBufferLen = this.writeBuffer.length;
653 * @param {String} message.
654 * @param {Function} callback function.
655 * @param {Object} options.
656 * @return {Socket} for chaining.
660 Socket.prototype.write =
661 Socket.prototype.send = function (msg, options, fn) {
662 this.sendPacket('message', msg, options, fn);
669 * @param {String} packet type.
670 * @param {String} data.
671 * @param {Object} options.
672 * @param {Function} callback function.
676 Socket.prototype.sendPacket = function (type, data, options, fn) {
677 if ('function' === typeof data) {
682 if ('function' === typeof options) {
687 if ('closing' === this.readyState || 'closed' === this.readyState) {
691 options = options || {};
692 options.compress = false !== options.compress;
699 this.emit('packetCreate', packet);
700 this.writeBuffer.push(packet);
701 if (fn) this.once('flush', fn);
706 * Closes the connection.
711 Socket.prototype.close = function () {
712 if ('opening' === this.readyState || 'open' === this.readyState) {
713 this.readyState = 'closing';
717 if (this.writeBuffer.length) {
718 this.once('drain', function () {
719 if (this.upgrading) {
725 } else if (this.upgrading) {
733 self.onClose('forced close');
734 debug('socket closing - telling transport to close');
735 self.transport.close();
738 function cleanupAndClose () {
739 self.removeListener('upgrade', cleanupAndClose);
740 self.removeListener('upgradeError', cleanupAndClose);
744 function waitForUpgrade () {
745 // wait for upgrade to finish since we can't send packets while pausing a transport
746 self.once('upgrade', cleanupAndClose);
747 self.once('upgradeError', cleanupAndClose);
754 * Called upon transport error
759 Socket.prototype.onError = function (err) {
760 debug('socket error %j', err);
761 Socket.priorWebsocketSuccess = false;
762 this.emit('error', err);
763 this.onClose('transport error', err);
767 * Called upon transport close.
772 Socket.prototype.onClose = function (reason, desc) {
773 if ('opening' === this.readyState || 'open' === this.readyState || 'closing' === this.readyState) {
774 debug('socket close with reason: "%s"', reason);
778 clearTimeout(this.pingIntervalTimer);
779 clearTimeout(this.pingTimeoutTimer);
781 // stop event from firing again for transport
782 this.transport.removeAllListeners('close');
784 // ensure transport won't stay open
785 this.transport.close();
787 // ignore further transport communication
788 this.transport.removeAllListeners();
791 this.readyState = 'closed';
797 this.emit('close', reason, desc);
799 // clean buffers after, so users can still
800 // grab the buffers on `close` event
801 self.writeBuffer = [];
802 self.prevBufferLen = 0;
807 * Filters upgrades, returning only those matching client transports.
809 * @param {Array} server upgrades
814 Socket.prototype.filterUpgrades = function (upgrades) {
815 var filteredUpgrades = [];
816 for (var i = 0, j = upgrades.length; i < j; i++) {
817 if (~index(this.transports, upgrades[i])) filteredUpgrades.push(upgrades[i]);
819 return filteredUpgrades;
825 /***/ function(module, exports, __webpack_require__) {
828 * Module dependencies
831 var XMLHttpRequest = __webpack_require__(3);
832 var XHR = __webpack_require__(6);
833 var JSONP = __webpack_require__(26);
834 var websocket = __webpack_require__(27);
840 exports.polling = polling;
841 exports.websocket = websocket;
844 * Polling transport polymorphic constructor.
845 * Decides on xhr vs jsonp based on feature detection.
850 function polling (opts) {
854 var jsonp = false !== opts.jsonp;
856 if (typeof location !== 'undefined') {
857 var isSSL = 'https:' === location.protocol;
858 var port = location.port;
860 // some user agents have empty `location.port`
862 port = isSSL ? 443 : 80;
865 xd = opts.hostname !== location.hostname || port !== opts.port;
866 xs = opts.secure !== isSSL;
871 xhr = new XMLHttpRequest(opts);
873 if ('open' in xhr && !opts.forceJSONP) {
874 return new XHR(opts);
876 if (!jsonp) throw new Error('JSONP disabled');
877 return new JSONP(opts);
884 /***/ function(module, exports, __webpack_require__) {
886 // browser shim for xmlhttprequest module
888 var hasCORS = __webpack_require__(4);
889 var globalThis = __webpack_require__(5);
891 module.exports = function (opts) {
892 var xdomain = opts.xdomain;
894 // scheme must be same when usign XDomainRequest
895 // http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
896 var xscheme = opts.xscheme;
898 // XDomainRequest has a flow of not sending cookie, therefore it should be disabled as a default.
899 // https://github.com/Automattic/engine.io-client/pull/217
900 var enablesXDR = opts.enablesXDR;
902 // XMLHttpRequest can be disabled on IE
904 if ('undefined' !== typeof XMLHttpRequest && (!xdomain || hasCORS)) {
905 return new XMLHttpRequest();
909 // Use XDomainRequest for IE8 if enablesXDR is true
910 // because loading bar keeps flashing when using jsonp-polling
911 // https://github.com/yujiosaka/socke.io-ie8-loading-example
913 if ('undefined' !== typeof XDomainRequest && !xscheme && enablesXDR) {
914 return new XDomainRequest();
920 return new globalThis[['Active'].concat('Object').join('X')]('Microsoft.XMLHTTP');
928 /***/ function(module, exports) {
934 * Logic borrowed from Modernizr:
936 * - https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cors.js
940 module.exports = typeof XMLHttpRequest !== 'undefined' &&
941 'withCredentials' in new XMLHttpRequest();
943 // if XMLHttp support is disabled in IE then it will throw
944 // when trying to create
945 module.exports = false;
951 /***/ function(module, exports) {
953 module.exports = (function () {
954 if (typeof self !== 'undefined') {
956 } else if (typeof window !== 'undefined') {
959 return Function('return this')(); // eslint-disable-line no-new-func
966 /***/ function(module, exports, __webpack_require__) {
968 /* global attachEvent */
971 * Module requirements.
974 var XMLHttpRequest = __webpack_require__(3);
975 var Polling = __webpack_require__(7);
976 var Emitter = __webpack_require__(18);
977 var inherit = __webpack_require__(20);
978 var debug = __webpack_require__(22)('engine.io-client:polling-xhr');
979 var globalThis = __webpack_require__(5);
985 module.exports = XHR;
986 module.exports.Request = Request;
995 * XHR Polling constructor.
997 * @param {Object} opts
1001 function XHR (opts) {
1002 Polling.call(this, opts);
1003 this.requestTimeout = opts.requestTimeout;
1004 this.extraHeaders = opts.extraHeaders;
1006 if (typeof location !== 'undefined') {
1007 var isSSL = 'https:' === location.protocol;
1008 var port = location.port;
1010 // some user agents have empty `location.port`
1012 port = isSSL ? 443 : 80;
1015 this.xd = (typeof location !== 'undefined' && opts.hostname !== location.hostname) ||
1017 this.xs = opts.secure !== isSSL;
1022 * Inherits from Polling.
1025 inherit(XHR, Polling);
1028 * XHR supports binary
1031 XHR.prototype.supportsBinary = true;
1034 * Creates a request.
1036 * @param {String} method
1040 XHR.prototype.request = function (opts) {
1042 opts.uri = this.uri();
1045 opts.agent = this.agent || false;
1046 opts.supportsBinary = this.supportsBinary;
1047 opts.enablesXDR = this.enablesXDR;
1048 opts.withCredentials = this.withCredentials;
1050 // SSL options for Node.js client
1051 opts.pfx = this.pfx;
1052 opts.key = this.key;
1053 opts.passphrase = this.passphrase;
1054 opts.cert = this.cert;
1056 opts.ciphers = this.ciphers;
1057 opts.rejectUnauthorized = this.rejectUnauthorized;
1058 opts.requestTimeout = this.requestTimeout;
1060 // other options for Node.js client
1061 opts.extraHeaders = this.extraHeaders;
1063 return new Request(opts);
1069 * @param {String} data to send.
1070 * @param {Function} called upon flush.
1074 XHR.prototype.doWrite = function (data, fn) {
1075 var isBinary = typeof data !== 'string' && data !== undefined;
1076 var req = this.request({ method: 'POST', data: data, isBinary: isBinary });
1078 req.on('success', fn);
1079 req.on('error', function (err) {
1080 self.onError('xhr post error', err);
1086 * Starts a poll cycle.
1091 XHR.prototype.doPoll = function () {
1093 var req = this.request();
1095 req.on('data', function (data) {
1098 req.on('error', function (err) {
1099 self.onError('xhr poll error', err);
1105 * Request constructor
1107 * @param {Object} options
1111 function Request (opts) {
1112 this.method = opts.method || 'GET';
1113 this.uri = opts.uri;
1114 this.xd = !!opts.xd;
1115 this.xs = !!opts.xs;
1116 this.async = false !== opts.async;
1117 this.data = undefined !== opts.data ? opts.data : null;
1118 this.agent = opts.agent;
1119 this.isBinary = opts.isBinary;
1120 this.supportsBinary = opts.supportsBinary;
1121 this.enablesXDR = opts.enablesXDR;
1122 this.withCredentials = opts.withCredentials;
1123 this.requestTimeout = opts.requestTimeout;
1125 // SSL options for Node.js client
1126 this.pfx = opts.pfx;
1127 this.key = opts.key;
1128 this.passphrase = opts.passphrase;
1129 this.cert = opts.cert;
1131 this.ciphers = opts.ciphers;
1132 this.rejectUnauthorized = opts.rejectUnauthorized;
1134 // other options for Node.js client
1135 this.extraHeaders = opts.extraHeaders;
1144 Emitter(Request.prototype);
1147 * Creates the XHR object and sends the request.
1152 Request.prototype.create = function () {
1153 var opts = { agent: this.agent, xdomain: this.xd, xscheme: this.xs, enablesXDR: this.enablesXDR };
1155 // SSL options for Node.js client
1156 opts.pfx = this.pfx;
1157 opts.key = this.key;
1158 opts.passphrase = this.passphrase;
1159 opts.cert = this.cert;
1161 opts.ciphers = this.ciphers;
1162 opts.rejectUnauthorized = this.rejectUnauthorized;
1164 var xhr = this.xhr = new XMLHttpRequest(opts);
1168 debug('xhr open %s: %s', this.method, this.uri);
1169 xhr.open(this.method, this.uri, this.async);
1171 if (this.extraHeaders) {
1172 xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);
1173 for (var i in this.extraHeaders) {
1174 if (this.extraHeaders.hasOwnProperty(i)) {
1175 xhr.setRequestHeader(i, this.extraHeaders[i]);
1181 if ('POST' === this.method) {
1183 if (this.isBinary) {
1184 xhr.setRequestHeader('Content-type', 'application/octet-stream');
1186 xhr.setRequestHeader('Content-type', 'text/plain;charset=UTF-8');
1192 xhr.setRequestHeader('Accept', '*/*');
1196 if ('withCredentials' in xhr) {
1197 xhr.withCredentials = this.withCredentials;
1200 if (this.requestTimeout) {
1201 xhr.timeout = this.requestTimeout;
1204 if (this.hasXDR()) {
1205 xhr.onload = function () {
1208 xhr.onerror = function () {
1209 self.onError(xhr.responseText);
1212 xhr.onreadystatechange = function () {
1213 if (xhr.readyState === 2) {
1215 var contentType = xhr.getResponseHeader('Content-Type');
1216 if (self.supportsBinary && contentType === 'application/octet-stream' || contentType === 'application/octet-stream; charset=UTF-8') {
1217 xhr.responseType = 'arraybuffer';
1221 if (4 !== xhr.readyState) return;
1222 if (200 === xhr.status || 1223 === xhr.status) {
1225 // make sure the `error` event handler that's user-set
1226 // does not throw in the same tick and gets caught here
1227 setTimeout(function () {
1228 self.onError(typeof xhr.status === 'number' ? xhr.status : 0);
1234 debug('xhr data %s', this.data);
1235 xhr.send(this.data);
1237 // Need to defer since .create() is called directly fhrom the constructor
1238 // and thus the 'error' event can only be only bound *after* this exception
1239 // occurs. Therefore, also, we cannot throw here at all.
1240 setTimeout(function () {
1246 if (typeof document !== 'undefined') {
1247 this.index = Request.requestsCount++;
1248 Request.requests[this.index] = this;
1253 * Called upon successful response.
1258 Request.prototype.onSuccess = function () {
1259 this.emit('success');
1264 * Called if we have data.
1269 Request.prototype.onData = function (data) {
1270 this.emit('data', data);
1275 * Called upon error.
1280 Request.prototype.onError = function (err) {
1281 this.emit('error', err);
1291 Request.prototype.cleanup = function (fromError) {
1292 if ('undefined' === typeof this.xhr || null === this.xhr) {
1296 if (this.hasXDR()) {
1297 this.xhr.onload = this.xhr.onerror = empty;
1299 this.xhr.onreadystatechange = empty;
1308 if (typeof document !== 'undefined') {
1309 delete Request.requests[this.index];
1321 Request.prototype.onLoad = function () {
1326 contentType = this.xhr.getResponseHeader('Content-Type');
1328 if (contentType === 'application/octet-stream' || contentType === 'application/octet-stream; charset=UTF-8') {
1329 data = this.xhr.response || this.xhr.responseText;
1331 data = this.xhr.responseText;
1342 * Check if it has XDomainRequest.
1347 Request.prototype.hasXDR = function () {
1348 return typeof XDomainRequest !== 'undefined' && !this.xs && this.enablesXDR;
1352 * Aborts the request.
1357 Request.prototype.abort = function () {
1362 * Aborts pending requests when unloading the window. This is needed to prevent
1363 * memory leaks (e.g. when using IE) and to ensure that no spurious error is
1367 Request.requestsCount = 0;
1368 Request.requests = {};
1370 if (typeof document !== 'undefined') {
1371 if (typeof attachEvent === 'function') {
1372 attachEvent('onunload', unloadHandler);
1373 } else if (typeof addEventListener === 'function') {
1374 var terminationEvent = 'onpagehide' in globalThis ? 'pagehide' : 'unload';
1375 addEventListener(terminationEvent, unloadHandler, false);
1379 function unloadHandler () {
1380 for (var i in Request.requests) {
1381 if (Request.requests.hasOwnProperty(i)) {
1382 Request.requests[i].abort();
1390 /***/ function(module, exports, __webpack_require__) {
1393 * Module dependencies.
1396 var Transport = __webpack_require__(8);
1397 var parseqs = __webpack_require__(19);
1398 var parser = __webpack_require__(9);
1399 var inherit = __webpack_require__(20);
1400 var yeast = __webpack_require__(21);
1401 var debug = __webpack_require__(22)('engine.io-client:polling');
1407 module.exports = Polling;
1410 * Is XHR2 supported?
1413 var hasXHR2 = (function () {
1414 var XMLHttpRequest = __webpack_require__(3);
1415 var xhr = new XMLHttpRequest({ xdomain: false });
1416 return null != xhr.responseType;
1420 * Polling interface.
1422 * @param {Object} opts
1426 function Polling (opts) {
1427 var forceBase64 = (opts && opts.forceBase64);
1428 if (!hasXHR2 || forceBase64) {
1429 this.supportsBinary = false;
1431 Transport.call(this, opts);
1435 * Inherits from Transport.
1438 inherit(Polling, Transport);
1444 Polling.prototype.name = 'polling';
1447 * Opens the socket (triggers polling). We write a PING message to determine
1448 * when the transport is open.
1453 Polling.prototype.doOpen = function () {
1460 * @param {Function} callback upon buffers are flushed and transport is paused
1464 Polling.prototype.pause = function (onPause) {
1467 this.readyState = 'pausing';
1471 self.readyState = 'paused';
1475 if (this.polling || !this.writable) {
1479 debug('we are currently polling - waiting to pause');
1481 this.once('pollComplete', function () {
1482 debug('pre-pause polling complete');
1487 if (!this.writable) {
1488 debug('we are currently writing - waiting to pause');
1490 this.once('drain', function () {
1491 debug('pre-pause writing complete');
1501 * Starts polling cycle.
1506 Polling.prototype.poll = function () {
1508 this.polling = true;
1514 * Overloads onData to detect payloads.
1519 Polling.prototype.onData = function (data) {
1521 debug('polling got data %s', data);
1522 var callback = function (packet, index, total) {
1523 // if its the first message we consider the transport open
1524 if ('opening' === self.readyState && packet.type === 'open') {
1528 // if its a close packet, we close the ongoing requests
1529 if ('close' === packet.type) {
1534 // otherwise bypass onData and handle the message
1535 self.onPacket(packet);
1539 parser.decodePayload(data, this.socket.binaryType, callback);
1541 // if an event did not trigger closing
1542 if ('closed' !== this.readyState) {
1543 // if we got data we're not polling
1544 this.polling = false;
1545 this.emit('pollComplete');
1547 if ('open' === this.readyState) {
1550 debug('ignoring poll - transport state "%s"', this.readyState);
1556 * For polling, send a close packet.
1561 Polling.prototype.doClose = function () {
1565 debug('writing close packet');
1566 self.write([{ type: 'close' }]);
1569 if ('open' === this.readyState) {
1570 debug('transport open - closing');
1573 // in case we're trying to close while
1574 // handshaking is in progress (GH-164)
1575 debug('transport not open - deferring close');
1576 this.once('open', close);
1581 * Writes a packets payload.
1583 * @param {Array} data packets
1584 * @param {Function} drain callback
1588 Polling.prototype.write = function (packets) {
1590 this.writable = false;
1591 var callbackfn = function () {
1592 self.writable = true;
1596 parser.encodePayload(packets, this.supportsBinary, function (data) {
1597 self.doWrite(data, callbackfn);
1602 * Generates uri for connection.
1607 Polling.prototype.uri = function () {
1608 var query = this.query || {};
1609 var schema = this.secure ? 'https' : 'http';
1612 // cache busting is forced
1613 if (false !== this.timestampRequests) {
1614 query[this.timestampParam] = yeast();
1617 if (!this.supportsBinary && !query.sid) {
1621 query = parseqs.encode(query);
1623 // avoid port if default for schema
1624 if (this.port && (('https' === schema && Number(this.port) !== 443) ||
1625 ('http' === schema && Number(this.port) !== 80))) {
1626 port = ':' + this.port;
1629 // prepend ? to query
1631 query = '?' + query;
1634 var ipv6 = this.hostname.indexOf(':') !== -1;
1635 return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query;
1641 /***/ function(module, exports, __webpack_require__) {
1644 * Module dependencies.
1647 var parser = __webpack_require__(9);
1648 var Emitter = __webpack_require__(18);
1654 module.exports = Transport;
1657 * Transport abstract constructor.
1659 * @param {Object} options.
1663 function Transport (opts) {
1664 this.path = opts.path;
1665 this.hostname = opts.hostname;
1666 this.port = opts.port;
1667 this.secure = opts.secure;
1668 this.query = opts.query;
1669 this.timestampParam = opts.timestampParam;
1670 this.timestampRequests = opts.timestampRequests;
1671 this.readyState = '';
1672 this.agent = opts.agent || false;
1673 this.socket = opts.socket;
1674 this.enablesXDR = opts.enablesXDR;
1675 this.withCredentials = opts.withCredentials;
1677 // SSL options for Node.js client
1678 this.pfx = opts.pfx;
1679 this.key = opts.key;
1680 this.passphrase = opts.passphrase;
1681 this.cert = opts.cert;
1683 this.ciphers = opts.ciphers;
1684 this.rejectUnauthorized = opts.rejectUnauthorized;
1685 this.forceNode = opts.forceNode;
1687 // results of ReactNative environment detection
1688 this.isReactNative = opts.isReactNative;
1690 // other options for Node.js client
1691 this.extraHeaders = opts.extraHeaders;
1692 this.localAddress = opts.localAddress;
1699 Emitter(Transport.prototype);
1704 * @param {String} str
1705 * @return {Transport} for chaining
1709 Transport.prototype.onError = function (msg, desc) {
1710 var err = new Error(msg);
1711 err.type = 'TransportError';
1712 err.description = desc;
1713 this.emit('error', err);
1718 * Opens the transport.
1723 Transport.prototype.open = function () {
1724 if ('closed' === this.readyState || '' === this.readyState) {
1725 this.readyState = 'opening';
1733 * Closes the transport.
1738 Transport.prototype.close = function () {
1739 if ('opening' === this.readyState || 'open' === this.readyState) {
1748 * Sends multiple packets.
1750 * @param {Array} packets
1754 Transport.prototype.send = function (packets) {
1755 if ('open' === this.readyState) {
1756 this.write(packets);
1758 throw new Error('Transport not open');
1768 Transport.prototype.onOpen = function () {
1769 this.readyState = 'open';
1770 this.writable = true;
1777 * @param {String} data
1781 Transport.prototype.onData = function (data) {
1782 var packet = parser.decodePacket(data, this.socket.binaryType);
1783 this.onPacket(packet);
1787 * Called with a decoded packet.
1790 Transport.prototype.onPacket = function (packet) {
1791 this.emit('packet', packet);
1795 * Called upon close.
1800 Transport.prototype.onClose = function () {
1801 this.readyState = 'closed';
1808 /***/ function(module, exports, __webpack_require__) {
1811 * Module dependencies.
1814 var keys = __webpack_require__(10);
1815 var hasBinary = __webpack_require__(11);
1816 var sliceBuffer = __webpack_require__(13);
1817 var after = __webpack_require__(14);
1818 var utf8 = __webpack_require__(15);
1821 if (typeof ArrayBuffer !== 'undefined') {
1822 base64encoder = __webpack_require__(16);
1826 * Check if we are running an android browser. That requires us to use
1827 * ArrayBuffer with polling transports...
1829 * http://ghinda.net/jpeg-blob-ajax-android/
1832 var isAndroid = typeof navigator !== 'undefined' && /Android/i.test(navigator.userAgent);
1835 * Check if we are running in PhantomJS.
1836 * Uploading a Blob with PhantomJS does not work correctly, as reported here:
1837 * https://github.com/ariya/phantomjs/issues/11395
1840 var isPhantomJS = typeof navigator !== 'undefined' && /PhantomJS/i.test(navigator.userAgent);
1843 * When true, avoids using Blobs to encode payloads.
1846 var dontSendBlobs = isAndroid || isPhantomJS;
1849 * Current protocol version.
1852 exports.protocol = 3;
1858 var packets = exports.packets = {
1860 , close: 1 // non-ws
1868 var packetslist = keys(packets);
1871 * Premade error packet.
1874 var err = { type: 'error', data: 'parser error' };
1877 * Create a blob api even for blob builder when vendor prefixes exist
1880 var Blob = __webpack_require__(17);
1885 * <packet type id> [ <data> ]
1893 * Binary is encoded in an identical principle
1898 exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) {
1899 if (typeof supportsBinary === 'function') {
1900 callback = supportsBinary;
1901 supportsBinary = false;
1904 if (typeof utf8encode === 'function') {
1905 callback = utf8encode;
1909 var data = (packet.data === undefined)
1911 : packet.data.buffer || packet.data;
1913 if (typeof ArrayBuffer !== 'undefined' && data instanceof ArrayBuffer) {
1914 return encodeArrayBuffer(packet, supportsBinary, callback);
1915 } else if (typeof Blob !== 'undefined' && data instanceof Blob) {
1916 return encodeBlob(packet, supportsBinary, callback);
1919 // might be an object with { base64: true, data: dataAsBase64String }
1920 if (data && data.base64) {
1921 return encodeBase64Object(packet, callback);
1924 // Sending data as a utf-8 string
1925 var encoded = packets[packet.type];
1927 // data fragment is optional
1928 if (undefined !== packet.data) {
1929 encoded += utf8encode ? utf8.encode(String(packet.data), { strict: false }) : String(packet.data);
1932 return callback('' + encoded);
1936 function encodeBase64Object(packet, callback) {
1937 // packet data is an object { base64: true, data: dataAsBase64String }
1938 var message = 'b' + exports.packets[packet.type] + packet.data.data;
1939 return callback(message);
1943 * Encode packet helpers for binary types
1946 function encodeArrayBuffer(packet, supportsBinary, callback) {
1947 if (!supportsBinary) {
1948 return exports.encodeBase64Packet(packet, callback);
1951 var data = packet.data;
1952 var contentArray = new Uint8Array(data);
1953 var resultBuffer = new Uint8Array(1 + data.byteLength);
1955 resultBuffer[0] = packets[packet.type];
1956 for (var i = 0; i < contentArray.length; i++) {
1957 resultBuffer[i+1] = contentArray[i];
1960 return callback(resultBuffer.buffer);
1963 function encodeBlobAsArrayBuffer(packet, supportsBinary, callback) {
1964 if (!supportsBinary) {
1965 return exports.encodeBase64Packet(packet, callback);
1968 var fr = new FileReader();
1969 fr.onload = function() {
1970 exports.encodePacket({ type: packet.type, data: fr.result }, supportsBinary, true, callback);
1972 return fr.readAsArrayBuffer(packet.data);
1975 function encodeBlob(packet, supportsBinary, callback) {
1976 if (!supportsBinary) {
1977 return exports.encodeBase64Packet(packet, callback);
1980 if (dontSendBlobs) {
1981 return encodeBlobAsArrayBuffer(packet, supportsBinary, callback);
1984 var length = new Uint8Array(1);
1985 length[0] = packets[packet.type];
1986 var blob = new Blob([length.buffer, packet.data]);
1988 return callback(blob);
1992 * Encodes a packet with binary data in a base64 string
1994 * @param {Object} packet, has `type` and `data`
1995 * @return {String} base64 encoded message
1998 exports.encodeBase64Packet = function(packet, callback) {
1999 var message = 'b' + exports.packets[packet.type];
2000 if (typeof Blob !== 'undefined' && packet.data instanceof Blob) {
2001 var fr = new FileReader();
2002 fr.onload = function() {
2003 var b64 = fr.result.split(',')[1];
2004 callback(message + b64);
2006 return fr.readAsDataURL(packet.data);
2011 b64data = String.fromCharCode.apply(null, new Uint8Array(packet.data));
2013 // iPhone Safari doesn't let you apply with typed arrays
2014 var typed = new Uint8Array(packet.data);
2015 var basic = new Array(typed.length);
2016 for (var i = 0; i < typed.length; i++) {
2017 basic[i] = typed[i];
2019 b64data = String.fromCharCode.apply(null, basic);
2021 message += btoa(b64data);
2022 return callback(message);
2026 * Decodes a packet. Changes format to Blob if requested.
2028 * @return {Object} with `type` and `data` (if any)
2032 exports.decodePacket = function (data, binaryType, utf8decode) {
2033 if (data === undefined) {
2037 if (typeof data === 'string') {
2038 if (data.charAt(0) === 'b') {
2039 return exports.decodeBase64Packet(data.substr(1), binaryType);
2043 data = tryDecode(data);
2044 if (data === false) {
2048 var type = data.charAt(0);
2050 if (Number(type) != type || !packetslist[type]) {
2054 if (data.length > 1) {
2055 return { type: packetslist[type], data: data.substring(1) };
2057 return { type: packetslist[type] };
2061 var asArray = new Uint8Array(data);
2062 var type = asArray[0];
2063 var rest = sliceBuffer(data, 1);
2064 if (Blob && binaryType === 'blob') {
2065 rest = new Blob([rest]);
2067 return { type: packetslist[type], data: rest };
2070 function tryDecode(data) {
2072 data = utf8.decode(data, { strict: false });
2080 * Decodes a packet encoded in a base64 string
2082 * @param {String} base64 encoded message
2083 * @return {Object} with `type` and `data` (if any)
2086 exports.decodeBase64Packet = function(msg, binaryType) {
2087 var type = packetslist[msg.charAt(0)];
2088 if (!base64encoder) {
2089 return { type: type, data: { base64: true, data: msg.substr(1) } };
2092 var data = base64encoder.decode(msg.substr(1));
2094 if (binaryType === 'blob' && Blob) {
2095 data = new Blob([data]);
2098 return { type: type, data: data };
2102 * Encodes multiple messages (payload).
2108 * 11:hello world2:hi
2110 * If any contents are binary, they will be encoded as base64 strings. Base64
2111 * encoded strings are marked with a b before the length specifier
2113 * @param {Array} packets
2117 exports.encodePayload = function (packets, supportsBinary, callback) {
2118 if (typeof supportsBinary === 'function') {
2119 callback = supportsBinary;
2120 supportsBinary = null;
2123 var isBinary = hasBinary(packets);
2125 if (supportsBinary && isBinary) {
2126 if (Blob && !dontSendBlobs) {
2127 return exports.encodePayloadAsBlob(packets, callback);
2130 return exports.encodePayloadAsArrayBuffer(packets, callback);
2133 if (!packets.length) {
2134 return callback('0:');
2137 function setLengthHeader(message) {
2138 return message.length + ':' + message;
2141 function encodeOne(packet, doneCallback) {
2142 exports.encodePacket(packet, !isBinary ? false : supportsBinary, false, function(message) {
2143 doneCallback(null, setLengthHeader(message));
2147 map(packets, encodeOne, function(err, results) {
2148 return callback(results.join(''));
2153 * Async array map using after
2156 function map(ary, each, done) {
2157 var result = new Array(ary.length);
2158 var next = after(ary.length, done);
2160 var eachWithIndex = function(i, el, cb) {
2161 each(el, function(error, msg) {
2167 for (var i = 0; i < ary.length; i++) {
2168 eachWithIndex(i, ary[i], next);
2173 * Decodes data when a payload is maybe expected. Possible binary contents are
2174 * decoded from their base64 representation
2176 * @param {String} data, callback method
2180 exports.decodePayload = function (data, binaryType, callback) {
2181 if (typeof data !== 'string') {
2182 return exports.decodePayloadAsBinary(data, binaryType, callback);
2185 if (typeof binaryType === 'function') {
2186 callback = binaryType;
2192 // parser error - ignoring payload
2193 return callback(err, 0, 1);
2196 var length = '', n, msg;
2198 for (var i = 0, l = data.length; i < l; i++) {
2199 var chr = data.charAt(i);
2206 if (length === '' || (length != (n = Number(length)))) {
2207 // parser error - ignoring payload
2208 return callback(err, 0, 1);
2211 msg = data.substr(i + 1, n);
2213 if (length != msg.length) {
2214 // parser error - ignoring payload
2215 return callback(err, 0, 1);
2219 packet = exports.decodePacket(msg, binaryType, false);
2221 if (err.type === packet.type && err.data === packet.data) {
2222 // parser error in individual packet - ignoring payload
2223 return callback(err, 0, 1);
2226 var ret = callback(packet, i + n, l);
2227 if (false === ret) return;
2235 if (length !== '') {
2236 // parser error - ignoring payload
2237 return callback(err, 0, 1);
2243 * Encodes multiple messages (payload) as binary.
2245 * <1 = binary, 0 = string><number from 0-9><number from 0-9>[...]<number
2249 * 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers
2251 * @param {Array} packets
2252 * @return {ArrayBuffer} encoded payload
2256 exports.encodePayloadAsArrayBuffer = function(packets, callback) {
2257 if (!packets.length) {
2258 return callback(new ArrayBuffer(0));
2261 function encodeOne(packet, doneCallback) {
2262 exports.encodePacket(packet, true, true, function(data) {
2263 return doneCallback(null, data);
2267 map(packets, encodeOne, function(err, encodedPackets) {
2268 var totalLength = encodedPackets.reduce(function(acc, p) {
2270 if (typeof p === 'string'){
2275 return acc + len.toString().length + len + 2; // string/binary identifier + separator = 2
2278 var resultArray = new Uint8Array(totalLength);
2280 var bufferIndex = 0;
2281 encodedPackets.forEach(function(p) {
2282 var isString = typeof p === 'string';
2285 var view = new Uint8Array(p.length);
2286 for (var i = 0; i < p.length; i++) {
2287 view[i] = p.charCodeAt(i);
2292 if (isString) { // not true binary
2293 resultArray[bufferIndex++] = 0;
2294 } else { // true binary
2295 resultArray[bufferIndex++] = 1;
2298 var lenStr = ab.byteLength.toString();
2299 for (var i = 0; i < lenStr.length; i++) {
2300 resultArray[bufferIndex++] = parseInt(lenStr[i]);
2302 resultArray[bufferIndex++] = 255;
2304 var view = new Uint8Array(ab);
2305 for (var i = 0; i < view.length; i++) {
2306 resultArray[bufferIndex++] = view[i];
2310 return callback(resultArray.buffer);
2318 exports.encodePayloadAsBlob = function(packets, callback) {
2319 function encodeOne(packet, doneCallback) {
2320 exports.encodePacket(packet, true, true, function(encoded) {
2321 var binaryIdentifier = new Uint8Array(1);
2322 binaryIdentifier[0] = 1;
2323 if (typeof encoded === 'string') {
2324 var view = new Uint8Array(encoded.length);
2325 for (var i = 0; i < encoded.length; i++) {
2326 view[i] = encoded.charCodeAt(i);
2328 encoded = view.buffer;
2329 binaryIdentifier[0] = 0;
2332 var len = (encoded instanceof ArrayBuffer)
2333 ? encoded.byteLength
2336 var lenStr = len.toString();
2337 var lengthAry = new Uint8Array(lenStr.length + 1);
2338 for (var i = 0; i < lenStr.length; i++) {
2339 lengthAry[i] = parseInt(lenStr[i]);
2341 lengthAry[lenStr.length] = 255;
2344 var blob = new Blob([binaryIdentifier.buffer, lengthAry.buffer, encoded]);
2345 doneCallback(null, blob);
2350 map(packets, encodeOne, function(err, results) {
2351 return callback(new Blob(results));
2356 * Decodes data when a payload is maybe expected. Strings are decoded by
2357 * interpreting each byte as a key code for entries marked to start with 0. See
2358 * description of encodePayloadAsBinary
2360 * @param {ArrayBuffer} data, callback method
2364 exports.decodePayloadAsBinary = function (data, binaryType, callback) {
2365 if (typeof binaryType === 'function') {
2366 callback = binaryType;
2370 var bufferTail = data;
2373 while (bufferTail.byteLength > 0) {
2374 var tailArray = new Uint8Array(bufferTail);
2375 var isString = tailArray[0] === 0;
2378 for (var i = 1; ; i++) {
2379 if (tailArray[i] === 255) break;
2381 // 310 = char length of Number.MAX_VALUE
2382 if (msgLength.length > 310) {
2383 return callback(err, 0, 1);
2386 msgLength += tailArray[i];
2389 bufferTail = sliceBuffer(bufferTail, 2 + msgLength.length);
2390 msgLength = parseInt(msgLength);
2392 var msg = sliceBuffer(bufferTail, 0, msgLength);
2395 msg = String.fromCharCode.apply(null, new Uint8Array(msg));
2397 // iPhone Safari doesn't let you apply to typed arrays
2398 var typed = new Uint8Array(msg);
2400 for (var i = 0; i < typed.length; i++) {
2401 msg += String.fromCharCode(typed[i]);
2407 bufferTail = sliceBuffer(bufferTail, msgLength);
2410 var total = buffers.length;
2411 buffers.forEach(function(buffer, i) {
2412 callback(exports.decodePacket(buffer, binaryType, true), i, total);
2419 /***/ function(module, exports) {
2423 * Gets the keys for an object.
2425 * @return {Array} keys
2429 module.exports = Object.keys || function keys (obj){
2431 var has = Object.prototype.hasOwnProperty;
2433 for (var i in obj) {
2434 if (has.call(obj, i)) {
2444 /***/ function(module, exports, __webpack_require__) {
2446 /* global Blob File */
2449 * Module requirements.
2452 var isArray = __webpack_require__(12);
2454 var toString = Object.prototype.toString;
2455 var withNativeBlob = typeof Blob === 'function' ||
2456 typeof Blob !== 'undefined' && toString.call(Blob) === '[object BlobConstructor]';
2457 var withNativeFile = typeof File === 'function' ||
2458 typeof File !== 'undefined' && toString.call(File) === '[object FileConstructor]';
2464 module.exports = hasBinary;
2467 * Checks for binary data.
2469 * Supports Buffer, ArrayBuffer, Blob and File.
2471 * @param {Object} anything
2475 function hasBinary (obj) {
2476 if (!obj || typeof obj !== 'object') {
2481 for (var i = 0, l = obj.length; i < l; i++) {
2482 if (hasBinary(obj[i])) {
2489 if ((typeof Buffer === 'function' && Buffer.isBuffer && Buffer.isBuffer(obj)) ||
2490 (typeof ArrayBuffer === 'function' && obj instanceof ArrayBuffer) ||
2491 (withNativeBlob && obj instanceof Blob) ||
2492 (withNativeFile && obj instanceof File)
2497 // see: https://github.com/Automattic/has-binary/pull/4
2498 if (obj.toJSON && typeof obj.toJSON === 'function' && arguments.length === 1) {
2499 return hasBinary(obj.toJSON(), true);
2502 for (var key in obj) {
2503 if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) {
2514 /***/ function(module, exports) {
2516 var toString = {}.toString;
2518 module.exports = Array.isArray || function (arr) {
2519 return toString.call(arr) == '[object Array]';
2525 /***/ function(module, exports) {
2528 * An abstraction for slicing an arraybuffer even when
2529 * ArrayBuffer.prototype.slice is not supported
2534 module.exports = function(arraybuffer, start, end) {
2535 var bytes = arraybuffer.byteLength;
2539 if (arraybuffer.slice) { return arraybuffer.slice(start, end); }
2541 if (start < 0) { start += bytes; }
2542 if (end < 0) { end += bytes; }
2543 if (end > bytes) { end = bytes; }
2545 if (start >= bytes || start >= end || bytes === 0) {
2546 return new ArrayBuffer(0);
2549 var abv = new Uint8Array(arraybuffer);
2550 var result = new Uint8Array(end - start);
2551 for (var i = start, ii = 0; i < end; i++, ii++) {
2552 result[ii] = abv[i];
2554 return result.buffer;
2560 /***/ function(module, exports) {
2562 module.exports = after
2564 function after(count, callback, err_cb) {
2566 err_cb = err_cb || noop
2569 return (count === 0) ? callback() : proxy
2571 function proxy(err, result) {
2572 if (proxy.count <= 0) {
2573 throw new Error('after called too many times')
2577 // after first error, rest are passed to err_cb
2581 // future error callbacks will go to error handler
2583 } else if (proxy.count === 0 && !bail) {
2584 callback(null, result)
2594 /***/ function(module, exports) {
2596 /*! https://mths.be/utf8js v2.1.2 by @mathias */
2598 var stringFromCharCode = String.fromCharCode;
2600 // Taken from https://mths.be/punycode
2601 function ucs2decode(string) {
2604 var length = string.length;
2607 while (counter < length) {
2608 value = string.charCodeAt(counter++);
2609 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
2610 // high surrogate, and there is a next character
2611 extra = string.charCodeAt(counter++);
2612 if ((extra & 0xFC00) == 0xDC00) { // low surrogate
2613 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
2615 // unmatched surrogate; only append this code unit, in case the next
2616 // code unit is the high surrogate of a surrogate pair
2627 // Taken from https://mths.be/punycode
2628 function ucs2encode(array) {
2629 var length = array.length;
2633 while (++index < length) {
2634 value = array[index];
2635 if (value > 0xFFFF) {
2637 output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
2638 value = 0xDC00 | value & 0x3FF;
2640 output += stringFromCharCode(value);
2645 function checkScalarValue(codePoint, strict) {
2646 if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
2649 'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
2650 ' is not a scalar value'
2657 /*--------------------------------------------------------------------------*/
2659 function createByte(codePoint, shift) {
2660 return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
2663 function encodeCodePoint(codePoint, strict) {
2664 if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
2665 return stringFromCharCode(codePoint);
2668 if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
2669 symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
2671 else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
2672 if (!checkScalarValue(codePoint, strict)) {
2675 symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
2676 symbol += createByte(codePoint, 6);
2678 else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
2679 symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
2680 symbol += createByte(codePoint, 12);
2681 symbol += createByte(codePoint, 6);
2683 symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
2687 function utf8encode(string, opts) {
2689 var strict = false !== opts.strict;
2691 var codePoints = ucs2decode(string);
2692 var length = codePoints.length;
2695 var byteString = '';
2696 while (++index < length) {
2697 codePoint = codePoints[index];
2698 byteString += encodeCodePoint(codePoint, strict);
2703 /*--------------------------------------------------------------------------*/
2705 function readContinuationByte() {
2706 if (byteIndex >= byteCount) {
2707 throw Error('Invalid byte index');
2710 var continuationByte = byteArray[byteIndex] & 0xFF;
2713 if ((continuationByte & 0xC0) == 0x80) {
2714 return continuationByte & 0x3F;
2717 // If we end up here, it’s not a continuation byte
2718 throw Error('Invalid continuation byte');
2721 function decodeSymbol(strict) {
2728 if (byteIndex > byteCount) {
2729 throw Error('Invalid byte index');
2732 if (byteIndex == byteCount) {
2737 byte1 = byteArray[byteIndex] & 0xFF;
2740 // 1-byte sequence (no continuation bytes)
2741 if ((byte1 & 0x80) == 0) {
2746 if ((byte1 & 0xE0) == 0xC0) {
2747 byte2 = readContinuationByte();
2748 codePoint = ((byte1 & 0x1F) << 6) | byte2;
2749 if (codePoint >= 0x80) {
2752 throw Error('Invalid continuation byte');
2756 // 3-byte sequence (may include unpaired surrogates)
2757 if ((byte1 & 0xF0) == 0xE0) {
2758 byte2 = readContinuationByte();
2759 byte3 = readContinuationByte();
2760 codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
2761 if (codePoint >= 0x0800) {
2762 return checkScalarValue(codePoint, strict) ? codePoint : 0xFFFD;
2764 throw Error('Invalid continuation byte');
2769 if ((byte1 & 0xF8) == 0xF0) {
2770 byte2 = readContinuationByte();
2771 byte3 = readContinuationByte();
2772 byte4 = readContinuationByte();
2773 codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
2774 (byte3 << 0x06) | byte4;
2775 if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
2780 throw Error('Invalid UTF-8 detected');
2786 function utf8decode(byteString, opts) {
2788 var strict = false !== opts.strict;
2790 byteArray = ucs2decode(byteString);
2791 byteCount = byteArray.length;
2793 var codePoints = [];
2795 while ((tmp = decodeSymbol(strict)) !== false) {
2796 codePoints.push(tmp);
2798 return ucs2encode(codePoints);
2810 /***/ function(module, exports) {
2813 * base64-arraybuffer
2814 * https://github.com/niklasvh/base64-arraybuffer
2816 * Copyright (c) 2012 Niklas von Hertzen
2817 * Licensed under the MIT license.
2822 var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2824 // Use a lookup table to find the index.
2825 var lookup = new Uint8Array(256);
2826 for (var i = 0; i < chars.length; i++) {
2827 lookup[chars.charCodeAt(i)] = i;
2830 exports.encode = function(arraybuffer) {
2831 var bytes = new Uint8Array(arraybuffer),
2832 i, len = bytes.length, base64 = "";
2834 for (i = 0; i < len; i+=3) {
2835 base64 += chars[bytes[i] >> 2];
2836 base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
2837 base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
2838 base64 += chars[bytes[i + 2] & 63];
2841 if ((len % 3) === 2) {
2842 base64 = base64.substring(0, base64.length - 1) + "=";
2843 } else if (len % 3 === 1) {
2844 base64 = base64.substring(0, base64.length - 2) + "==";
2850 exports.decode = function(base64) {
2851 var bufferLength = base64.length * 0.75,
2852 len = base64.length, i, p = 0,
2853 encoded1, encoded2, encoded3, encoded4;
2855 if (base64[base64.length - 1] === "=") {
2857 if (base64[base64.length - 2] === "=") {
2862 var arraybuffer = new ArrayBuffer(bufferLength),
2863 bytes = new Uint8Array(arraybuffer);
2865 for (i = 0; i < len; i+=4) {
2866 encoded1 = lookup[base64.charCodeAt(i)];
2867 encoded2 = lookup[base64.charCodeAt(i+1)];
2868 encoded3 = lookup[base64.charCodeAt(i+2)];
2869 encoded4 = lookup[base64.charCodeAt(i+3)];
2871 bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
2872 bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
2873 bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
2883 /***/ function(module, exports) {
2886 * Create a blob builder even when vendor prefixes exist
\r
2889 var BlobBuilder = typeof BlobBuilder !== 'undefined' ? BlobBuilder :
\r
2890 typeof WebKitBlobBuilder !== 'undefined' ? WebKitBlobBuilder :
\r
2891 typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder :
\r
2892 typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder :
\r
2896 * Check if Blob constructor is supported
\r
2899 var blobSupported = (function() {
\r
2901 var a = new Blob(['hi']);
\r
2902 return a.size === 2;
\r
2909 * Check if Blob constructor supports ArrayBufferViews
\r
2910 * Fails in Safari 6, so we need to map to ArrayBuffers there.
\r
2913 var blobSupportsArrayBufferView = blobSupported && (function() {
\r
2915 var b = new Blob([new Uint8Array([1,2])]);
\r
2916 return b.size === 2;
\r
2923 * Check if BlobBuilder is supported
\r
2926 var blobBuilderSupported = BlobBuilder
\r
2927 && BlobBuilder.prototype.append
\r
2928 && BlobBuilder.prototype.getBlob;
\r
2931 * Helper function that maps ArrayBufferViews to ArrayBuffers
\r
2932 * Used by BlobBuilder constructor and old browsers that didn't
\r
2933 * support it in the Blob constructor.
\r
2936 function mapArrayBufferViews(ary) {
\r
2937 return ary.map(function(chunk) {
\r
2938 if (chunk.buffer instanceof ArrayBuffer) {
\r
2939 var buf = chunk.buffer;
\r
2941 // if this is a subarray, make a copy so we only
\r
2942 // include the subarray region from the underlying buffer
\r
2943 if (chunk.byteLength !== buf.byteLength) {
\r
2944 var copy = new Uint8Array(chunk.byteLength);
\r
2945 copy.set(new Uint8Array(buf, chunk.byteOffset, chunk.byteLength));
\r
2946 buf = copy.buffer;
\r
2956 function BlobBuilderConstructor(ary, options) {
\r
2957 options = options || {};
\r
2959 var bb = new BlobBuilder();
\r
2960 mapArrayBufferViews(ary).forEach(function(part) {
\r
2964 return (options.type) ? bb.getBlob(options.type) : bb.getBlob();
\r
2967 function BlobConstructor(ary, options) {
\r
2968 return new Blob(mapArrayBufferViews(ary), options || {});
\r
2971 if (typeof Blob !== 'undefined') {
\r
2972 BlobBuilderConstructor.prototype = Blob.prototype;
\r
2973 BlobConstructor.prototype = Blob.prototype;
\r
2976 module.exports = (function() {
\r
2977 if (blobSupported) {
\r
2978 return blobSupportsArrayBufferView ? Blob : BlobConstructor;
\r
2979 } else if (blobBuilderSupported) {
\r
2980 return BlobBuilderConstructor;
\r
2989 /***/ function(module, exports, __webpack_require__) {
2993 * Expose `Emitter`.
\r
2997 module.exports = Emitter;
\r
3001 * Initialize a new `Emitter`.
\r
3006 function Emitter(obj) {
\r
3007 if (obj) return mixin(obj);
\r
3011 * Mixin the emitter properties.
\r
3013 * @param {Object} obj
\r
3014 * @return {Object}
\r
3018 function mixin(obj) {
\r
3019 for (var key in Emitter.prototype) {
\r
3020 obj[key] = Emitter.prototype[key];
\r
3026 * Listen on the given `event` with `fn`.
\r
3028 * @param {String} event
\r
3029 * @param {Function} fn
\r
3030 * @return {Emitter}
\r
3034 Emitter.prototype.on =
\r
3035 Emitter.prototype.addEventListener = function(event, fn){
\r
3036 this._callbacks = this._callbacks || {};
\r
3037 (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
\r
3043 * Adds an `event` listener that will be invoked a single
\r
3044 * time then automatically removed.
\r
3046 * @param {String} event
\r
3047 * @param {Function} fn
\r
3048 * @return {Emitter}
\r
3052 Emitter.prototype.once = function(event, fn){
\r
3054 this.off(event, on);
\r
3055 fn.apply(this, arguments);
\r
3059 this.on(event, on);
\r
3064 * Remove the given callback for `event` or all
\r
3065 * registered callbacks.
\r
3067 * @param {String} event
\r
3068 * @param {Function} fn
\r
3069 * @return {Emitter}
\r
3073 Emitter.prototype.off =
\r
3074 Emitter.prototype.removeListener =
\r
3075 Emitter.prototype.removeAllListeners =
\r
3076 Emitter.prototype.removeEventListener = function(event, fn){
\r
3077 this._callbacks = this._callbacks || {};
\r
3080 if (0 == arguments.length) {
\r
3081 this._callbacks = {};
\r
3086 var callbacks = this._callbacks['$' + event];
\r
3087 if (!callbacks) return this;
\r
3089 // remove all handlers
\r
3090 if (1 == arguments.length) {
\r
3091 delete this._callbacks['$' + event];
\r
3095 // remove specific handler
\r
3097 for (var i = 0; i < callbacks.length; i++) {
\r
3098 cb = callbacks[i];
\r
3099 if (cb === fn || cb.fn === fn) {
\r
3100 callbacks.splice(i, 1);
\r
3105 // Remove event specific arrays for event types that no
\r
3106 // one is subscribed for to avoid memory leak.
\r
3107 if (callbacks.length === 0) {
\r
3108 delete this._callbacks['$' + event];
\r
3115 * Emit `event` with the given args.
\r
3117 * @param {String} event
\r
3118 * @param {Mixed} ...
\r
3119 * @return {Emitter}
\r
3122 Emitter.prototype.emit = function(event){
\r
3123 this._callbacks = this._callbacks || {};
\r
3125 var args = new Array(arguments.length - 1)
\r
3126 , callbacks = this._callbacks['$' + event];
\r
3128 for (var i = 1; i < arguments.length; i++) {
\r
3129 args[i - 1] = arguments[i];
\r
3133 callbacks = callbacks.slice(0);
\r
3134 for (var i = 0, len = callbacks.length; i < len; ++i) {
\r
3135 callbacks[i].apply(this, args);
\r
3143 * Return array of callbacks for `event`.
\r
3145 * @param {String} event
\r
3150 Emitter.prototype.listeners = function(event){
\r
3151 this._callbacks = this._callbacks || {};
\r
3152 return this._callbacks['$' + event] || [];
\r
3156 * Check if this emitter has `event` handlers.
\r
3158 * @param {String} event
\r
3159 * @return {Boolean}
\r
3163 Emitter.prototype.hasListeners = function(event){
\r
3164 return !! this.listeners(event).length;
\r
3170 /***/ function(module, exports) {
3173 * Compiles a querystring
3174 * Returns string representation of the object
3180 exports.encode = function (obj) {
3183 for (var i in obj) {
3184 if (obj.hasOwnProperty(i)) {
3185 if (str.length) str += '&';
3186 str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
3194 * Parses a simple querystring into an object
3196 * @param {String} qs
3200 exports.decode = function(qs){
3202 var pairs = qs.split('&');
3203 for (var i = 0, l = pairs.length; i < l; i++) {
3204 var pair = pairs[i].split('=');
3205 qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
3213 /***/ function(module, exports) {
3216 module.exports = function(a, b){
3217 var fn = function(){};
3218 fn.prototype = b.prototype;
3219 a.prototype = new fn;
3220 a.prototype.constructor = a;
3225 /***/ function(module, exports) {
3229 var alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split('')
3237 * Return a string representing the specified number.
3239 * @param {Number} num The number to convert.
3240 * @returns {String} The string representation of the number.
3243 function encode(num) {
3247 encoded = alphabet[num % length] + encoded;
3248 num = Math.floor(num / length);
3255 * Return the integer value specified by the given string.
3257 * @param {String} str The string to convert.
3258 * @returns {Number} The integer value represented by the string.
3261 function decode(str) {
3264 for (i = 0; i < str.length; i++) {
3265 decoded = decoded * length + map[str.charAt(i)];
3272 * Yeast: A tiny growing id generator.
3274 * @returns {String} A unique id.
3278 var now = encode(+new Date());
3280 if (now !== prev) return seed = 0, prev = now;
3281 return now +'.'+ encode(seed++);
3285 // Map each character to its index.
3287 for (; i < length; i++) map[alphabet[i]] = i;
3290 // Expose the `yeast`, `encode` and `decode` functions.
3292 yeast.encode = encode;
3293 yeast.decode = decode;
3294 module.exports = yeast;
3299 /***/ function(module, exports, __webpack_require__) {
3301 /* WEBPACK VAR INJECTION */(function(process) {'use strict';
3303 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
3306 * This is the web browser implementation of `debug()`.
3308 * Expose `debug()` as the module.
3311 exports = module.exports = __webpack_require__(24);
3313 exports.formatArgs = formatArgs;
3314 exports.save = save;
3315 exports.load = load;
3316 exports.useColors = useColors;
3317 exports.storage = 'undefined' != typeof chrome && 'undefined' != typeof chrome.storage ? chrome.storage.local : localstorage();
3323 exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
3326 * Currently only WebKit-based Web Inspectors, Firefox >= v31,
3327 * and the Firebug extension (any Firefox version) are known
3328 * to support "%c" CSS customizations.
3330 * TODO: add a `localStorage` variable to explicitly enable/disable colors
3333 function useColors() {
3334 // NB: In an Electron preload script, document will be defined but not fully
3335 // initialized. Since we know we're in Chrome, we'll just detect this case
3337 if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
3341 // Internet Explorer and Edge do not support colors.
3342 if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
3346 // is webkit? http://stackoverflow.com/a/16459606/376773
3347 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
3348 return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance ||
3349 // is firebug? http://stackoverflow.com/a/398120/376773
3350 typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) ||
3351 // is firefox >= v31?
3352 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
3353 typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 ||
3354 // double check webkit in userAgent just in case we are in a worker
3355 typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
3359 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
3362 exports.formatters.j = function (v) {
3364 return JSON.stringify(v);
3366 return '[UnexpectedJSONParseError]: ' + err.message;
3371 * Colorize log arguments if enabled.
3376 function formatArgs(args) {
3377 var useColors = this.useColors;
3379 args[0] = (useColors ? '%c' : '') + this.namespace + (useColors ? ' %c' : ' ') + args[0] + (useColors ? '%c ' : ' ') + '+' + exports.humanize(this.diff);
3381 if (!useColors) return;
3383 var c = 'color: ' + this.color;
3384 args.splice(1, 0, c, 'color: inherit');
3386 // the final "%c" is somewhat tricky, because there could be other
3387 // arguments passed either before or after the %c, so we need to
3388 // figure out the correct index to insert the CSS into
3391 args[0].replace(/%[a-zA-Z%]/g, function (match) {
3392 if ('%%' === match) return;
3394 if ('%c' === match) {
3395 // we only are interested in the *last* %c
3396 // (the user may have provided their own)
3401 args.splice(lastC, 0, c);
3405 * Invokes `console.log()` when available.
3406 * No-op when `console.log` is not a "function".
3412 // this hackery is required for IE8/9, where
3413 // the `console.log` function doesn't have 'apply'
3414 return 'object' === (typeof console === 'undefined' ? 'undefined' : _typeof(console)) && console.log && Function.prototype.apply.call(console.log, console, arguments);
3418 * Save `namespaces`.
3420 * @param {String} namespaces
3424 function save(namespaces) {
3426 if (null == namespaces) {
3427 exports.storage.removeItem('debug');
3429 exports.storage.debug = namespaces;
3435 * Load `namespaces`.
3437 * @return {String} returns the previously persisted debug modes
3444 r = exports.storage.debug;
3447 // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
3448 if (!r && typeof process !== 'undefined' && 'env' in process) {
3449 r = process.env.DEBUG;
3456 * Enable namespaces listed in `localStorage.debug` initially.
3459 exports.enable(load());
3462 * Localstorage attempts to return the localstorage.
3464 * This is necessary because safari throws
3465 * when a user disables cookies/localstorage
3466 * and you attempt to access it.
3468 * @return {LocalStorage}
3472 function localstorage() {
3474 return window.localStorage;
3477 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(23)))
3481 /***/ function(module, exports) {
3483 // shim for using process in browser
3484 var process = module.exports = {};
3486 // cached from whatever global is present so that test runners that stub it
3487 // don't break things. But we need to wrap it in a try catch in case it is
3488 // wrapped in strict mode code which doesn't define any globals. It's inside a
3489 // function because try/catches deoptimize in certain engines.
3491 var cachedSetTimeout;
3492 var cachedClearTimeout;
3494 function defaultSetTimout() {
3495 throw new Error('setTimeout has not been defined');
3497 function defaultClearTimeout () {
3498 throw new Error('clearTimeout has not been defined');
3502 if (typeof setTimeout === 'function') {
3503 cachedSetTimeout = setTimeout;
3505 cachedSetTimeout = defaultSetTimout;
3508 cachedSetTimeout = defaultSetTimout;
3511 if (typeof clearTimeout === 'function') {
3512 cachedClearTimeout = clearTimeout;
3514 cachedClearTimeout = defaultClearTimeout;
3517 cachedClearTimeout = defaultClearTimeout;
3520 function runTimeout(fun) {
3521 if (cachedSetTimeout === setTimeout) {
3522 //normal enviroments in sane situations
3523 return setTimeout(fun, 0);
3525 // if setTimeout wasn't available but was latter defined
3526 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
3527 cachedSetTimeout = setTimeout;
3528 return setTimeout(fun, 0);
3531 // when when somebody has screwed with setTimeout but no I.E. maddness
3532 return cachedSetTimeout(fun, 0);
3535 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
3536 return cachedSetTimeout.call(null, fun, 0);
3538 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
3539 return cachedSetTimeout.call(this, fun, 0);
3545 function runClearTimeout(marker) {
3546 if (cachedClearTimeout === clearTimeout) {
3547 //normal enviroments in sane situations
3548 return clearTimeout(marker);
3550 // if clearTimeout wasn't available but was latter defined
3551 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
3552 cachedClearTimeout = clearTimeout;
3553 return clearTimeout(marker);
3556 // when when somebody has screwed with setTimeout but no I.E. maddness
3557 return cachedClearTimeout(marker);
3560 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
3561 return cachedClearTimeout.call(null, marker);
3563 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
3564 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
3565 return cachedClearTimeout.call(this, marker);
3573 var draining = false;
3575 var queueIndex = -1;
3577 function cleanUpNextTick() {
3578 if (!draining || !currentQueue) {
3582 if (currentQueue.length) {
3583 queue = currentQueue.concat(queue);
3592 function drainQueue() {
3596 var timeout = runTimeout(cleanUpNextTick);
3599 var len = queue.length;
3601 currentQueue = queue;
3603 while (++queueIndex < len) {
3605 currentQueue[queueIndex].run();
3611 currentQueue = null;
3613 runClearTimeout(timeout);
3616 process.nextTick = function (fun) {
3617 var args = new Array(arguments.length - 1);
3618 if (arguments.length > 1) {
3619 for (var i = 1; i < arguments.length; i++) {
3620 args[i - 1] = arguments[i];
3623 queue.push(new Item(fun, args));
3624 if (queue.length === 1 && !draining) {
3625 runTimeout(drainQueue);
3629 // v8 likes predictible objects
3630 function Item(fun, array) {
3634 Item.prototype.run = function () {
3635 this.fun.apply(null, this.array);
3637 process.title = 'browser';
3638 process.browser = true;
3641 process.version = ''; // empty string to avoid regexp issues
3642 process.versions = {};
3647 process.addListener = noop;
3648 process.once = noop;
3650 process.removeListener = noop;
3651 process.removeAllListeners = noop;
3652 process.emit = noop;
3653 process.prependListener = noop;
3654 process.prependOnceListener = noop;
3656 process.listeners = function (name) { return [] }
3658 process.binding = function (name) {
3659 throw new Error('process.binding is not supported');
3662 process.cwd = function () { return '/' };
3663 process.chdir = function (dir) {
3664 throw new Error('process.chdir is not supported');
3666 process.umask = function() { return 0; };
3671 /***/ function(module, exports, __webpack_require__) {
3676 * This is the common logic for both the Node.js and web browser
3677 * implementations of `debug()`.
3679 * Expose `debug()` as the module.
3682 exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
3683 exports.coerce = coerce;
3684 exports.disable = disable;
3685 exports.enable = enable;
3686 exports.enabled = enabled;
3687 exports.humanize = __webpack_require__(25);
3690 * Active `debug` instances.
3692 exports.instances = [];
3695 * The currently active debug mode names, and names to skip.
3702 * Map of special "%n" handling functions, for the debug "format" argument.
3704 * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
3707 exports.formatters = {};
3711 * @param {String} namespace
3716 function selectColor(namespace) {
3720 for (i in namespace) {
3721 hash = (hash << 5) - hash + namespace.charCodeAt(i);
3722 hash |= 0; // Convert to 32bit integer
3725 return exports.colors[Math.abs(hash) % exports.colors.length];
3729 * Create a debugger with the given `namespace`.
3731 * @param {String} namespace
3732 * @return {Function}
3736 function createDebug(namespace) {
3742 if (!debug.enabled) return;
3746 // set `diff` timestamp
3747 var curr = +new Date();
3748 var ms = curr - (prevTime || curr);
3750 self.prev = prevTime;
3754 // turn the `arguments` into a proper Array
3755 var args = new Array(arguments.length);
3756 for (var i = 0; i < args.length; i++) {
3757 args[i] = arguments[i];
3760 args[0] = exports.coerce(args[0]);
3762 if ('string' !== typeof args[0]) {
3763 // anything else let's inspect with %O
3767 // apply any `formatters` transformations
3769 args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
3770 // if we encounter an escaped % then don't increase the array index
3771 if (match === '%%') return match;
3773 var formatter = exports.formatters[format];
3774 if ('function' === typeof formatter) {
3775 var val = args[index];
3776 match = formatter.call(self, val);
3778 // now we need to remove `args[index]` since it's inlined in the `format`
3779 args.splice(index, 1);
3785 // apply env-specific formatting (colors, etc.)
3786 exports.formatArgs.call(self, args);
3788 var logFn = debug.log || exports.log || console.log.bind(console);
3789 logFn.apply(self, args);
3792 debug.namespace = namespace;
3793 debug.enabled = exports.enabled(namespace);
3794 debug.useColors = exports.useColors();
3795 debug.color = selectColor(namespace);
3796 debug.destroy = destroy;
3798 // env-specific initialization logic for debug instances
3799 if ('function' === typeof exports.init) {
3800 exports.init(debug);
3803 exports.instances.push(debug);
3808 function destroy() {
3809 var index = exports.instances.indexOf(this);
3811 exports.instances.splice(index, 1);
3819 * Enables a debug mode by namespaces. This can include modes
3820 * separated by a colon and wildcards.
3822 * @param {String} namespaces
3826 function enable(namespaces) {
3827 exports.save(namespaces);
3833 var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
3834 var len = split.length;
3836 for (i = 0; i < len; i++) {
3837 if (!split[i]) continue; // ignore empty strings
3838 namespaces = split[i].replace(/\*/g, '.*?');
3839 if (namespaces[0] === '-') {
3840 exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
3842 exports.names.push(new RegExp('^' + namespaces + '$'));
3846 for (i = 0; i < exports.instances.length; i++) {
3847 var instance = exports.instances[i];
3848 instance.enabled = exports.enabled(instance.namespace);
3853 * Disable debug output.
3858 function disable() {
3863 * Returns true if the given mode name is enabled, false otherwise.
3865 * @param {String} name
3870 function enabled(name) {
3871 if (name[name.length - 1] === '*') {
3875 for (i = 0, len = exports.skips.length; i < len; i++) {
3876 if (exports.skips[i].test(name)) {
3880 for (i = 0, len = exports.names.length; i < len; i++) {
3881 if (exports.names[i].test(name)) {
3891 * @param {Mixed} val
3896 function coerce(val) {
3897 if (val instanceof Error) return val.stack || val.message;
3903 /***/ function(module, exports) {
3916 * Parse or format the given `val`.
3920 * - `long` verbose formatting [false]
3922 * @param {String|Number} val
3923 * @param {Object} [options]
3924 * @throws {Error} throw an error if val is not a non-empty string or a number
3925 * @return {String|Number}
3929 module.exports = function(val, options) {
3930 options = options || {};
3931 var type = typeof val;
3932 if (type === 'string' && val.length > 0) {
3934 } else if (type === 'number' && isNaN(val) === false) {
3935 return options.long ? fmtLong(val) : fmtShort(val);
3938 'val is not a non-empty string or a valid number. val=' +
3944 * Parse the given `str` and return milliseconds.
3946 * @param {String} str
3951 function parse(str) {
3953 if (str.length > 100) {
3956 var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
3962 var n = parseFloat(match[1]);
3963 var type = (match[2] || 'ms').toLowerCase();
3993 case 'milliseconds':
4005 * Short format for `ms`.
4007 * @param {Number} ms
4012 function fmtShort(ms) {
4014 return Math.round(ms / d) + 'd';
4017 return Math.round(ms / h) + 'h';
4020 return Math.round(ms / m) + 'm';
4023 return Math.round(ms / s) + 's';
4029 * Long format for `ms`.
4031 * @param {Number} ms
4036 function fmtLong(ms) {
4037 return plural(ms, d, 'day') ||
4038 plural(ms, h, 'hour') ||
4039 plural(ms, m, 'minute') ||
4040 plural(ms, s, 'second') ||
4045 * Pluralization helper.
4048 function plural(ms, n, name) {
4053 return Math.floor(ms / n) + ' ' + name;
4055 return Math.ceil(ms / n) + ' ' + name + 's';
4061 /***/ function(module, exports, __webpack_require__) {
4064 * Module requirements.
4067 var Polling = __webpack_require__(7);
4068 var inherit = __webpack_require__(20);
4069 var globalThis = __webpack_require__(5);
4075 module.exports = JSONPPolling;
4078 * Cached regular expressions.
4081 var rNewline = /\n/g;
4082 var rEscapedNewline = /\\n/g;
4085 * Global JSONP callbacks.
4094 function empty () { }
4097 * JSONP Polling constructor.
4099 * @param {Object} opts.
4103 function JSONPPolling (opts) {
4104 Polling.call(this, opts);
4106 this.query = this.query || {};
4108 // define global callbacks array if not present
4109 // we do this here (lazily) to avoid unneeded global pollution
4111 // we need to consider multiple engines in the same page
4112 callbacks = globalThis.___eio = (globalThis.___eio || []);
4115 // callback identifier
4116 this.index = callbacks.length;
4118 // add callback to jsonp global
4120 callbacks.push(function (msg) {
4124 // append to query string
4125 this.query.j = this.index;
4127 // prevent spurious errors from being emitted when the window is unloaded
4128 if (typeof addEventListener === 'function') {
4129 addEventListener('beforeunload', function () {
4130 if (self.script) self.script.onerror = empty;
4136 * Inherits from Polling.
4139 inherit(JSONPPolling, Polling);
4142 * JSONP only supports binary as base64 encoded strings
4145 JSONPPolling.prototype.supportsBinary = false;
4148 * Closes the socket.
4153 JSONPPolling.prototype.doClose = function () {
4155 this.script.parentNode.removeChild(this.script);
4160 this.form.parentNode.removeChild(this.form);
4165 Polling.prototype.doClose.call(this);
4169 * Starts a poll cycle.
4174 JSONPPolling.prototype.doPoll = function () {
4176 var script = document.createElement('script');
4179 this.script.parentNode.removeChild(this.script);
4183 script.async = true;
4184 script.src = this.uri();
4185 script.onerror = function (e) {
4186 self.onError('jsonp poll error', e);
4189 var insertAt = document.getElementsByTagName('script')[0];
4191 insertAt.parentNode.insertBefore(script, insertAt);
4193 (document.head || document.body).appendChild(script);
4195 this.script = script;
4197 var isUAgecko = 'undefined' !== typeof navigator && /gecko/i.test(navigator.userAgent);
4200 setTimeout(function () {
4201 var iframe = document.createElement('iframe');
4202 document.body.appendChild(iframe);
4203 document.body.removeChild(iframe);
4209 * Writes with a hidden iframe.
4211 * @param {String} data to send
4212 * @param {Function} called upon flush.
4216 JSONPPolling.prototype.doWrite = function (data, fn) {
4220 var form = document.createElement('form');
4221 var area = document.createElement('textarea');
4222 var id = this.iframeId = 'eio_iframe_' + this.index;
4225 form.className = 'socketio';
4226 form.style.position = 'absolute';
4227 form.style.top = '-1000px';
4228 form.style.left = '-1000px';
4230 form.method = 'POST';
4231 form.setAttribute('accept-charset', 'utf-8');
4233 form.appendChild(area);
4234 document.body.appendChild(form);
4240 this.form.action = this.uri();
4242 function complete () {
4247 function initIframe () {
4250 self.form.removeChild(self.iframe);
4252 self.onError('jsonp polling iframe removal error', e);
4257 // ie6 dynamic iframes with target="" support (thanks Chris Lambacher)
4258 var html = '<iframe src="javascript:0" name="' + self.iframeId + '">';
4259 iframe = document.createElement(html);
4261 iframe = document.createElement('iframe');
4262 iframe.name = self.iframeId;
4263 iframe.src = 'javascript:0';
4266 iframe.id = self.iframeId;
4268 self.form.appendChild(iframe);
4269 self.iframe = iframe;
4274 // escape \n to prevent it from being converted into \r\n by some UAs
4275 // double escaping is required for escaped new lines because unescaping of new lines can be done safely on server-side
4276 data = data.replace(rEscapedNewline, '\\\n');
4277 this.area.value = data.replace(rNewline, '\\n');
4283 if (this.iframe.attachEvent) {
4284 this.iframe.onreadystatechange = function () {
4285 if (self.iframe.readyState === 'complete') {
4290 this.iframe.onload = complete;
4297 /***/ function(module, exports, __webpack_require__) {
4300 * Module dependencies.
4303 var Transport = __webpack_require__(8);
4304 var parser = __webpack_require__(9);
4305 var parseqs = __webpack_require__(19);
4306 var inherit = __webpack_require__(20);
4307 var yeast = __webpack_require__(21);
4308 var debug = __webpack_require__(22)('engine.io-client:websocket');
4310 var BrowserWebSocket, NodeWebSocket;
4312 if (typeof WebSocket !== 'undefined') {
4313 BrowserWebSocket = WebSocket;
4314 } else if (typeof self !== 'undefined') {
4315 BrowserWebSocket = self.WebSocket || self.MozWebSocket;
4318 if (typeof window === 'undefined') {
4320 NodeWebSocket = __webpack_require__(28);
4325 * Get either the `WebSocket` or `MozWebSocket` globals
4326 * in the browser or try to resolve WebSocket-compatible
4327 * interface exposed by `ws` for Node-like environment.
4330 var WebSocketImpl = BrowserWebSocket || NodeWebSocket;
4336 module.exports = WS;
4339 * WebSocket transport constructor.
4341 * @api {Object} connection options
4345 function WS (opts) {
4346 var forceBase64 = (opts && opts.forceBase64);
4348 this.supportsBinary = false;
4350 this.perMessageDeflate = opts.perMessageDeflate;
4351 this.usingBrowserWebSocket = BrowserWebSocket && !opts.forceNode;
4352 this.protocols = opts.protocols;
4353 if (!this.usingBrowserWebSocket) {
4354 WebSocketImpl = NodeWebSocket;
4356 Transport.call(this, opts);
4360 * Inherits from Transport.
4363 inherit(WS, Transport);
4371 WS.prototype.name = 'websocket';
4374 * WebSockets support binary
4377 WS.prototype.supportsBinary = true;
4385 WS.prototype.doOpen = function () {
4386 if (!this.check()) {
4387 // let probe timeout
4391 var uri = this.uri();
4392 var protocols = this.protocols;
4396 if (!this.isReactNative) {
4397 opts.agent = this.agent;
4398 opts.perMessageDeflate = this.perMessageDeflate;
4400 // SSL options for Node.js client
4401 opts.pfx = this.pfx;
4402 opts.key = this.key;
4403 opts.passphrase = this.passphrase;
4404 opts.cert = this.cert;
4406 opts.ciphers = this.ciphers;
4407 opts.rejectUnauthorized = this.rejectUnauthorized;
4410 if (this.extraHeaders) {
4411 opts.headers = this.extraHeaders;
4413 if (this.localAddress) {
4414 opts.localAddress = this.localAddress;
4419 this.usingBrowserWebSocket && !this.isReactNative
4421 ? new WebSocketImpl(uri, protocols)
4422 : new WebSocketImpl(uri)
4423 : new WebSocketImpl(uri, protocols, opts);
4425 return this.emit('error', err);
4428 if (this.ws.binaryType === undefined) {
4429 this.supportsBinary = false;
4432 if (this.ws.supports && this.ws.supports.binary) {
4433 this.supportsBinary = true;
4434 this.ws.binaryType = 'nodebuffer';
4436 this.ws.binaryType = 'arraybuffer';
4439 this.addEventListeners();
4443 * Adds event listeners to the socket
4448 WS.prototype.addEventListeners = function () {
4451 this.ws.onopen = function () {
4454 this.ws.onclose = function () {
4457 this.ws.onmessage = function (ev) {
4458 self.onData(ev.data);
4460 this.ws.onerror = function (e) {
4461 self.onError('websocket error', e);
4466 * Writes data to socket.
4468 * @param {Array} array of packets.
4472 WS.prototype.write = function (packets) {
4474 this.writable = false;
4476 // encodePacket efficient as it uses WS framing
4477 // no need for encodePayload
4478 var total = packets.length;
4479 for (var i = 0, l = total; i < l; i++) {
4480 (function (packet) {
4481 parser.encodePacket(packet, self.supportsBinary, function (data) {
4482 if (!self.usingBrowserWebSocket) {
4483 // always create a new object (GH-437)
4485 if (packet.options) {
4486 opts.compress = packet.options.compress;
4489 if (self.perMessageDeflate) {
4490 var len = 'string' === typeof data ? Buffer.byteLength(data) : data.length;
4491 if (len < self.perMessageDeflate.threshold) {
4492 opts.compress = false;
4497 // Sometimes the websocket has already been closed but the browser didn't
4498 // have a chance of informing us about it yet, in that case send will
4501 if (self.usingBrowserWebSocket) {
4502 // TypeError is thrown when passing the second argument on Safari
4505 self.ws.send(data, opts);
4508 debug('websocket closed before onclose event');
4520 // defer to next tick to allow Socket to clear writeBuffer
4521 setTimeout(function () {
4522 self.writable = true;
4534 WS.prototype.onClose = function () {
4535 Transport.prototype.onClose.call(this);
4544 WS.prototype.doClose = function () {
4545 if (typeof this.ws !== 'undefined') {
4551 * Generates uri for connection.
4556 WS.prototype.uri = function () {
4557 var query = this.query || {};
4558 var schema = this.secure ? 'wss' : 'ws';
4561 // avoid port if default for schema
4562 if (this.port && (('wss' === schema && Number(this.port) !== 443) ||
4563 ('ws' === schema && Number(this.port) !== 80))) {
4564 port = ':' + this.port;
4567 // append timestamp to URI
4568 if (this.timestampRequests) {
4569 query[this.timestampParam] = yeast();
4572 // communicate binary support capabilities
4573 if (!this.supportsBinary) {
4577 query = parseqs.encode(query);
4579 // prepend ? to query
4581 query = '?' + query;
4584 var ipv6 = this.hostname.indexOf(':') !== -1;
4585 return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query;
4589 * Feature detection for WebSocket.
4591 * @return {Boolean} whether this transport is available.
4595 WS.prototype.check = function () {
4596 return !!WebSocketImpl && !('__initialize' in WebSocketImpl && this.name === WS.prototype.name);
4602 /***/ function(module, exports) {
4608 /***/ function(module, exports) {
4611 var indexOf = [].indexOf;
4613 module.exports = function(arr, obj){
4614 if (indexOf) return arr.indexOf(obj);
4615 for (var i = 0; i < arr.length; ++i) {
4616 if (arr[i] === obj) return i;
4623 /***/ function(module, exports) {
4628 * @author Steven Levithan <stevenlevithan.com> (MIT license)
4632 var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
4635 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'
4638 module.exports = function parseuri(str) {
4640 b = str.indexOf('['),
4641 e = str.indexOf(']');
4643 if (b != -1 && e != -1) {
4644 str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);
4647 var m = re.exec(str || ''),
4652 uri[parts[i]] = m[i] || '';
4655 if (b != -1 && e != -1) {
4657 uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');
4658 uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');
4662 uri.pathNames = pathNames(uri, uri['path']);
4663 uri.queryKey = queryKey(uri, uri['query']);
4668 function pathNames(obj, path) {
4669 var regx = /\/{2,9}/g,
4670 names = path.replace(regx, "/").split("/");
4672 if (path.substr(0, 1) == '/' || path.length === 0) {
4675 if (path.substr(path.length - 1, 1) == '/') {
4676 names.splice(names.length - 1, 1);
4682 function queryKey(uri, query) {
4685 query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) {