You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4670 lines
108 KiB

7 years ago
  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)
  5. define([], factory);
  6. else if(typeof exports === 'object')
  7. exports["eio"] = factory();
  8. else
  9. root["eio"] = factory();
  10. })(this, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/ // The require function
  15. /******/ function __webpack_require__(moduleId) {
  16. /******/ // Check if module is in cache
  17. /******/ if(installedModules[moduleId])
  18. /******/ return installedModules[moduleId].exports;
  19. /******/ // Create a new module (and put it into the cache)
  20. /******/ var module = installedModules[moduleId] = {
  21. /******/ exports: {},
  22. /******/ id: moduleId,
  23. /******/ loaded: false
  24. /******/ };
  25. /******/ // Execute the module function
  26. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  27. /******/ // Flag the module as loaded
  28. /******/ module.loaded = true;
  29. /******/ // Return the exports of the module
  30. /******/ return module.exports;
  31. /******/ }
  32. /******/ // expose the modules object (__webpack_modules__)
  33. /******/ __webpack_require__.m = modules;
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/ // __webpack_public_path__
  37. /******/ __webpack_require__.p = "";
  38. /******/ // Load entry module and return exports
  39. /******/ return __webpack_require__(0);
  40. /******/ })
  41. /************************************************************************/
  42. /******/ ([
  43. /* 0 */
  44. /***/ function(module, exports, __webpack_require__) {
  45. 'use strict';
  46. module.exports = __webpack_require__(1);
  47. /***/ },
  48. /* 1 */
  49. /***/ function(module, exports, __webpack_require__) {
  50. 'use strict';
  51. module.exports = __webpack_require__(2);
  52. /**
  53. * Exports parser
  54. *
  55. * @api public
  56. *
  57. */
  58. module.exports.parser = __webpack_require__(9);
  59. /***/ },
  60. /* 2 */
  61. /***/ function(module, exports, __webpack_require__) {
  62. /* WEBPACK VAR INJECTION */(function(global) {'use strict';
  63. 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; };
  64. /**
  65. * Module dependencies.
  66. */
  67. var transports = __webpack_require__(3);
  68. var Emitter = __webpack_require__(19);
  69. var debug = __webpack_require__(23)('engine.io-client:socket');
  70. var index = __webpack_require__(30);
  71. var parser = __webpack_require__(9);
  72. var parseuri = __webpack_require__(31);
  73. var parsejson = __webpack_require__(32);
  74. var parseqs = __webpack_require__(20);
  75. /**
  76. * Module exports.
  77. */
  78. module.exports = Socket;
  79. /**
  80. * Socket constructor.
  81. *
  82. * @param {String|Object} uri or options
  83. * @param {Object} options
  84. * @api public
  85. */
  86. function Socket(uri, opts) {
  87. if (!(this instanceof Socket)) return new Socket(uri, opts);
  88. opts = opts || {};
  89. if (uri && 'object' === (typeof uri === 'undefined' ? 'undefined' : _typeof(uri))) {
  90. opts = uri;
  91. uri = null;
  92. }
  93. if (uri) {
  94. uri = parseuri(uri);
  95. opts.hostname = uri.host;
  96. opts.secure = uri.protocol === 'https' || uri.protocol === 'wss';
  97. opts.port = uri.port;
  98. if (uri.query) opts.query = uri.query;
  99. } else if (opts.host) {
  100. opts.hostname = parseuri(opts.host).host;
  101. }
  102. this.secure = null != opts.secure ? opts.secure : global.location && 'https:' === location.protocol;
  103. if (opts.hostname && !opts.port) {
  104. // if no port is specified manually, use the protocol default
  105. opts.port = this.secure ? '443' : '80';
  106. }
  107. this.agent = opts.agent || false;
  108. this.hostname = opts.hostname || (global.location ? location.hostname : 'localhost');
  109. this.port = opts.port || (global.location && location.port ? location.port : this.secure ? 443 : 80);
  110. this.query = opts.query || {};
  111. if ('string' === typeof this.query) this.query = parseqs.decode(this.query);
  112. this.upgrade = false !== opts.upgrade;
  113. this.path = (opts.path || '/engine.io').replace(/\/$/, '') + '/';
  114. this.forceJSONP = !!opts.forceJSONP;
  115. this.jsonp = false !== opts.jsonp;
  116. this.forceBase64 = !!opts.forceBase64;
  117. this.enablesXDR = !!opts.enablesXDR;
  118. this.timestampParam = opts.timestampParam || 't';
  119. this.timestampRequests = opts.timestampRequests;
  120. this.transports = opts.transports || ['polling', 'websocket'];
  121. this.readyState = '';
  122. this.writeBuffer = [];
  123. this.prevBufferLen = 0;
  124. this.policyPort = opts.policyPort || 843;
  125. this.rememberUpgrade = opts.rememberUpgrade || false;
  126. this.binaryType = null;
  127. this.onlyBinaryUpgrades = opts.onlyBinaryUpgrades;
  128. this.perMessageDeflate = false !== opts.perMessageDeflate ? opts.perMessageDeflate || {} : false;
  129. if (true === this.perMessageDeflate) this.perMessageDeflate = {};
  130. if (this.perMessageDeflate && null == this.perMessageDeflate.threshold) {
  131. this.perMessageDeflate.threshold = 1024;
  132. }
  133. // SSL options for Node.js client
  134. this.pfx = opts.pfx || null;
  135. this.key = opts.key || null;
  136. this.passphrase = opts.passphrase || null;
  137. this.cert = opts.cert || null;
  138. this.ca = opts.ca || null;
  139. this.ciphers = opts.ciphers || null;
  140. this.rejectUnauthorized = opts.rejectUnauthorized === undefined ? null : opts.rejectUnauthorized;
  141. this.forceNode = !!opts.forceNode;
  142. // other options for Node.js client
  143. var freeGlobal = (typeof global === 'undefined' ? 'undefined' : _typeof(global)) === 'object' && global;
  144. if (freeGlobal.global === freeGlobal) {
  145. if (opts.extraHeaders && Object.keys(opts.extraHeaders).length > 0) {
  146. this.extraHeaders = opts.extraHeaders;
  147. }
  148. if (opts.localAddress) {
  149. this.localAddress = opts.localAddress;
  150. }
  151. }
  152. // set on handshake
  153. this.id = null;
  154. this.upgrades = null;
  155. this.pingInterval = null;
  156. this.pingTimeout = null;
  157. // set on heartbeat
  158. this.pingIntervalTimer = null;
  159. this.pingTimeoutTimer = null;
  160. this.open();
  161. }
  162. Socket.priorWebsocketSuccess = false;
  163. /**
  164. * Mix in `Emitter`.
  165. */
  166. Emitter(Socket.prototype);
  167. /**
  168. * Protocol version.
  169. *
  170. * @api public
  171. */
  172. Socket.protocol = parser.protocol; // this is an int
  173. /**
  174. * Expose deps for legacy compatibility
  175. * and standalone browser access.
  176. */
  177. Socket.Socket = Socket;
  178. Socket.Transport = __webpack_require__(8);
  179. Socket.transports = __webpack_require__(3);
  180. Socket.parser = __webpack_require__(9);
  181. /**
  182. * Creates transport of the given type.
  183. *
  184. * @param {String} transport name
  185. * @return {Transport}
  186. * @api private
  187. */
  188. Socket.prototype.createTransport = function (name) {
  189. debug('creating transport "%s"', name);
  190. var query = clone(this.query);
  191. // append engine.io protocol identifier
  192. query.EIO = parser.protocol;
  193. // transport name
  194. query.transport = name;
  195. // session id if we already have one
  196. if (this.id) query.sid = this.id;
  197. var transport = new transports[name]({
  198. agent: this.agent,
  199. hostname: this.hostname,
  200. port: this.port,
  201. secure: this.secure,
  202. path: this.path,
  203. query: query,
  204. forceJSONP: this.forceJSONP,
  205. jsonp: this.jsonp,
  206. forceBase64: this.forceBase64,
  207. enablesXDR: this.enablesXDR,
  208. timestampRequests: this.timestampRequests,
  209. timestampParam: this.timestampParam,
  210. policyPort: this.policyPort,
  211. socket: this,
  212. pfx: this.pfx,
  213. key: this.key,
  214. passphrase: this.passphrase,
  215. cert: this.cert,
  216. ca: this.ca,
  217. ciphers: this.ciphers,
  218. rejectUnauthorized: this.rejectUnauthorized,
  219. perMessageDeflate: this.perMessageDeflate,
  220. extraHeaders: this.extraHeaders,
  221. forceNode: this.forceNode,
  222. localAddress: this.localAddress
  223. });
  224. return transport;
  225. };
  226. function clone(obj) {
  227. var o = {};
  228. for (var i in obj) {
  229. if (obj.hasOwnProperty(i)) {
  230. o[i] = obj[i];
  231. }
  232. }
  233. return o;
  234. }
  235. /**
  236. * Initializes transport to use and starts probe.
  237. *
  238. * @api private
  239. */
  240. Socket.prototype.open = function () {
  241. var transport;
  242. if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') !== -1) {
  243. transport = 'websocket';
  244. } else if (0 === this.transports.length) {
  245. // Emit error on next tick so it can be listened to
  246. var self = this;
  247. setTimeout(function () {
  248. self.emit('error', 'No transports available');
  249. }, 0);
  250. return;
  251. } else {
  252. transport = this.transports[0];
  253. }
  254. this.readyState = 'opening';
  255. // Retry with the next transport if the transport is disabled (jsonp: false)
  256. try {
  257. transport = this.createTransport(transport);
  258. } catch (e) {
  259. this.transports.shift();
  260. this.open();
  261. return;
  262. }
  263. transport.open();
  264. this.setTransport(transport);
  265. };
  266. /**
  267. * Sets the current transport. Disables the existing one (if any).
  268. *
  269. * @api private
  270. */
  271. Socket.prototype.setTransport = function (transport) {
  272. debug('setting transport %s', transport.name);
  273. var self = this;
  274. if (this.transport) {
  275. debug('clearing existing transport %s', this.transport.name);
  276. this.transport.removeAllListeners();
  277. }
  278. // set up transport
  279. this.transport = transport;
  280. // set up transport listeners
  281. transport.on('drain', function () {
  282. self.onDrain();
  283. }).on('packet', function (packet) {
  284. self.onPacket(packet);
  285. }).on('error', function (e) {
  286. self.onError(e);
  287. }).on('close', function () {
  288. self.onClose('transport close');
  289. });
  290. };
  291. /**
  292. * Probes a transport.
  293. *
  294. * @param {String} transport name
  295. * @api private
  296. */
  297. Socket.prototype.probe = function (name) {
  298. debug('probing transport "%s"', name);
  299. var transport = this.createTransport(name, { probe: 1 });
  300. var failed = false;
  301. var self = this;
  302. Socket.priorWebsocketSuccess = false;
  303. function onTransportOpen() {
  304. if (self.onlyBinaryUpgrades) {
  305. var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary;
  306. failed = failed || upgradeLosesBinary;
  307. }
  308. if (failed) return;
  309. debug('probe transport "%s" opened', name);
  310. transport.send([{ type: 'ping', data: 'probe' }]);
  311. transport.once('packet', function (msg) {
  312. if (failed) return;
  313. if ('pong' === msg.type && 'probe' === msg.data) {
  314. debug('probe transport "%s" pong', name);
  315. self.upgrading = true;
  316. self.emit('upgrading', transport);
  317. if (!transport) return;
  318. Socket.priorWebsocketSuccess = 'websocket' === transport.name;
  319. debug('pausing current transport "%s"', self.transport.name);
  320. self.transport.pause(function () {
  321. if (failed) return;
  322. if ('closed' === self.readyState) return;
  323. debug('changing transport and sending upgrade packet');
  324. cleanup();
  325. self.setTransport(transport);
  326. transport.send([{ type: 'upgrade' }]);
  327. self.emit('upgrade', transport);
  328. transport = null;
  329. self.upgrading = false;
  330. self.flush();
  331. });
  332. } else {
  333. debug('probe transport "%s" failed', name);
  334. var err = new Error('probe error');
  335. err.transport = transport.name;
  336. self.emit('upgradeError', err);
  337. }
  338. });
  339. }
  340. function freezeTransport() {
  341. if (failed) return;
  342. // Any callback called by transport should be ignored since now
  343. failed = true;
  344. cleanup();
  345. transport.close();
  346. transport = null;
  347. }
  348. // Handle any error that happens while probing
  349. function onerror(err) {
  350. var error = new Error('probe error: ' + err);
  351. error.transport = transport.name;
  352. freezeTransport();
  353. debug('probe transport "%s" failed because of error: %s', name, err);
  354. self.emit('upgradeError', error);
  355. }
  356. function onTransportClose() {
  357. onerror('transport closed');
  358. }
  359. // When the socket is closed while we're probing
  360. function onclose() {
  361. onerror('socket closed');
  362. }
  363. // When the socket is upgraded while we're probing
  364. function onupgrade(to) {
  365. if (transport && to.name !== transport.name) {
  366. debug('"%s" works - aborting "%s"', to.name, transport.name);
  367. freezeTransport();
  368. }
  369. }
  370. // Remove all listeners on the transport and on self
  371. function cleanup() {
  372. transport.removeListener('open', onTransportOpen);
  373. transport.removeListener('error', onerror);
  374. transport.removeListener('close', onTransportClose);
  375. self.removeListener('close', onclose);
  376. self.removeListener('upgrading', onupgrade);
  377. }
  378. transport.once('open', onTransportOpen);
  379. transport.once('error', onerror);
  380. transport.once('close', onTransportClose);
  381. this.once('close', onclose);
  382. this.once('upgrading', onupgrade);
  383. transport.open();
  384. };
  385. /**
  386. * Called when connection is deemed open.
  387. *
  388. * @api public
  389. */
  390. Socket.prototype.onOpen = function () {
  391. debug('socket open');
  392. this.readyState = 'open';
  393. Socket.priorWebsocketSuccess = 'websocket' === this.transport.name;
  394. this.emit('open');
  395. this.flush();
  396. // we check for `readyState` in case an `open`
  397. // listener already closed the socket
  398. if ('open' === this.readyState && this.upgrade && this.transport.pause) {
  399. debug('starting upgrade probes');
  400. for (var i = 0, l = this.upgrades.length; i < l; i++) {
  401. this.probe(this.upgrades[i]);
  402. }
  403. }
  404. };
  405. /**
  406. * Handles a packet.
  407. *
  408. * @api private
  409. */
  410. Socket.prototype.onPacket = function (packet) {
  411. if ('opening' === this.readyState || 'open' === this.readyState || 'closing' === this.readyState) {
  412. debug('socket receive: type "%s", data "%s"', packet.type, packet.data);
  413. this.emit('packet', packet);
  414. // Socket is live - any packet counts
  415. this.emit('heartbeat');
  416. switch (packet.type) {
  417. case 'open':
  418. this.onHandshake(parsejson(packet.data));
  419. break;
  420. case 'pong':
  421. this.setPing();
  422. this.emit('pong');
  423. break;
  424. case 'error':
  425. var err = new Error('server error');
  426. err.code = packet.data;
  427. this.onError(err);
  428. break;
  429. case 'message':
  430. this.emit('data', packet.data);
  431. this.emit('message', packet.data);
  432. break;
  433. }
  434. } else {
  435. debug('packet received with socket readyState "%s"', this.readyState);
  436. }
  437. };
  438. /**
  439. * Called upon handshake completion.
  440. *
  441. * @param {Object} handshake obj
  442. * @api private
  443. */
  444. Socket.prototype.onHandshake = function (data) {
  445. this.emit('handshake', data);
  446. this.id = data.sid;
  447. this.transport.query.sid = data.sid;
  448. this.upgrades = this.filterUpgrades(data.upgrades);
  449. this.pingInterval = data.pingInterval;
  450. this.pingTimeout = data.pingTimeout;
  451. this.onOpen();
  452. // In case open handler closes socket
  453. if ('closed' === this.readyState) return;
  454. this.setPing();
  455. // Prolong liveness of socket on heartbeat
  456. this.removeListener('heartbeat', this.onHeartbeat);
  457. this.on('heartbeat', this.onHeartbeat);
  458. };
  459. /**
  460. * Resets ping timeout.
  461. *
  462. * @api private
  463. */
  464. Socket.prototype.onHeartbeat = function (timeout) {
  465. clearTimeout(this.pingTimeoutTimer);
  466. var self = this;
  467. self.pingTimeoutTimer = setTimeout(function () {
  468. if ('closed' === self.readyState) return;
  469. self.onClose('ping timeout');
  470. }, timeout || self.pingInterval + self.pingTimeout);
  471. };
  472. /**
  473. * Pings server every `this.pingInterval` and expects response
  474. * within `this.pingTimeout` or closes connection.
  475. *
  476. * @api private
  477. */
  478. Socket.prototype.setPing = function () {
  479. var self = this;
  480. clearTimeout(self.pingIntervalTimer);
  481. self.pingIntervalTimer = setTimeout(function () {
  482. debug('writing ping packet - expecting pong within %sms', self.pingTimeout);
  483. self.ping();
  484. self.onHeartbeat(self.pingTimeout);
  485. }, self.pingInterval);
  486. };
  487. /**
  488. * Sends a ping packet.
  489. *
  490. * @api private
  491. */
  492. Socket.prototype.ping = function () {
  493. var self = this;
  494. this.sendPacket('ping', function () {
  495. self.emit('ping');
  496. });
  497. };
  498. /**
  499. * Called on `drain` event
  500. *
  501. * @api private
  502. */
  503. Socket.prototype.onDrain = function () {
  504. this.writeBuffer.splice(0, this.prevBufferLen);
  505. // setting prevBufferLen = 0 is very important
  506. // for example, when upgrading, upgrade packet is sent over,
  507. // and a nonzero prevBufferLen could cause problems on `drain`
  508. this.prevBufferLen = 0;
  509. if (0 === this.writeBuffer.length) {
  510. this.emit('drain');
  511. } else {
  512. this.flush();
  513. }
  514. };
  515. /**
  516. * Flush write buffers.
  517. *
  518. * @api private
  519. */
  520. Socket.prototype.flush = function () {
  521. if ('closed' !== this.readyState && this.transport.writable && !this.upgrading && this.writeBuffer.length) {
  522. debug('flushing %d packets in socket', this.writeBuffer.length);
  523. this.transport.send(this.writeBuffer);
  524. // keep track of current length of writeBuffer
  525. // splice writeBuffer and callbackBuffer on `drain`
  526. this.prevBufferLen = this.writeBuffer.length;
  527. this.emit('flush');
  528. }
  529. };
  530. /**
  531. * Sends a message.
  532. *
  533. * @param {String} message.
  534. * @param {Function} callback function.
  535. * @param {Object} options.
  536. * @return {Socket} for chaining.
  537. * @api public
  538. */
  539. Socket.prototype.write = Socket.prototype.send = function (msg, options, fn) {
  540. this.sendPacket('message', msg, options, fn);
  541. return this;
  542. };
  543. /**
  544. * Sends a packet.
  545. *
  546. * @param {String} packet type.
  547. * @param {String} data.
  548. * @param {Object} options.
  549. * @param {Function} callback function.
  550. * @api private
  551. */
  552. Socket.prototype.sendPacket = function (type, data, options, fn) {
  553. if ('function' === typeof data) {
  554. fn = data;
  555. data = undefined;
  556. }
  557. if ('function' === typeof options) {
  558. fn = options;
  559. options = null;
  560. }
  561. if ('closing' === this.readyState || 'closed' === this.readyState) {
  562. return;
  563. }
  564. options = options || {};
  565. options.compress = false !== options.compress;
  566. var packet = {
  567. type: type,
  568. data: data,
  569. options: options
  570. };
  571. this.emit('packetCreate', packet);
  572. this.writeBuffer.push(packet);
  573. if (fn) this.once('flush', fn);
  574. this.flush();
  575. };
  576. /**
  577. * Closes the connection.
  578. *
  579. * @api private
  580. */
  581. Socket.prototype.close = function () {
  582. if ('opening' === this.readyState || 'open' === this.readyState) {
  583. this.readyState = 'closing';
  584. var self = this;
  585. if (this.writeBuffer.length) {
  586. this.once('drain', function () {
  587. if (this.upgrading) {
  588. waitForUpgrade();
  589. } else {
  590. close();
  591. }
  592. });
  593. } else if (this.upgrading) {
  594. waitForUpgrade();
  595. } else {
  596. close();
  597. }
  598. }
  599. function close() {
  600. self.onClose('forced close');
  601. debug('socket closing - telling transport to close');
  602. self.transport.close();
  603. }
  604. function cleanupAndClose() {
  605. self.removeListener('upgrade', cleanupAndClose);
  606. self.removeListener('upgradeError', cleanupAndClose);
  607. close();
  608. }
  609. function waitForUpgrade() {
  610. // wait for upgrade to finish since we can't send packets while pausing a transport
  611. self.once('upgrade', cleanupAndClose);
  612. self.once('upgradeError', cleanupAndClose);
  613. }
  614. return this;
  615. };
  616. /**
  617. * Called upon transport error
  618. *
  619. * @api private
  620. */
  621. Socket.prototype.onError = function (err) {
  622. debug('socket error %j', err);
  623. Socket.priorWebsocketSuccess = false;
  624. this.emit('error', err);
  625. this.onClose('transport error', err);
  626. };
  627. /**
  628. * Called upon transport close.
  629. *
  630. * @api private
  631. */
  632. Socket.prototype.onClose = function (reason, desc) {
  633. if ('opening' === this.readyState || 'open' === this.readyState || 'closing' === this.readyState) {
  634. debug('socket close with reason: "%s"', reason);
  635. var self = this;
  636. // clear timers
  637. clearTimeout(this.pingIntervalTimer);
  638. clearTimeout(this.pingTimeoutTimer);
  639. // stop event from firing again for transport
  640. this.transport.removeAllListeners('close');
  641. // ensure transport won't stay open
  642. this.transport.close();
  643. // ignore further transport communication
  644. this.transport.removeAllListeners();
  645. // set ready state
  646. this.readyState = 'closed';
  647. // clear session id
  648. this.id = null;
  649. // emit close event
  650. this.emit('close', reason, desc);
  651. // clean buffers after, so users can still
  652. // grab the buffers on `close` event
  653. self.writeBuffer = [];
  654. self.prevBufferLen = 0;
  655. }
  656. };
  657. /**
  658. * Filters upgrades, returning only those matching client transports.
  659. *
  660. * @param {Array} server upgrades
  661. * @api private
  662. *
  663. */
  664. Socket.prototype.filterUpgrades = function (upgrades) {
  665. var filteredUpgrades = [];
  666. for (var i = 0, j = upgrades.length; i < j; i++) {
  667. if (~index(this.transports, upgrades[i])) filteredUpgrades.push(upgrades[i]);
  668. }
  669. return filteredUpgrades;
  670. };
  671. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  672. /***/ },
  673. /* 3 */
  674. /***/ function(module, exports, __webpack_require__) {
  675. /* WEBPACK VAR INJECTION */(function(global) {'use strict';
  676. /**
  677. * Module dependencies
  678. */
  679. var XMLHttpRequest = __webpack_require__(4);
  680. var XHR = __webpack_require__(6);
  681. var JSONP = __webpack_require__(27);
  682. var websocket = __webpack_require__(28);
  683. /**
  684. * Export transports.
  685. */
  686. exports.polling = polling;
  687. exports.websocket = websocket;
  688. /**
  689. * Polling transport polymorphic constructor.
  690. * Decides on xhr vs jsonp based on feature detection.
  691. *
  692. * @api private
  693. */
  694. function polling(opts) {
  695. var xhr;
  696. var xd = false;
  697. var xs = false;
  698. var jsonp = false !== opts.jsonp;
  699. if (global.location) {
  700. var isSSL = 'https:' === location.protocol;
  701. var port = location.port;
  702. // some user agents have empty `location.port`
  703. if (!port) {
  704. port = isSSL ? 443 : 80;
  705. }
  706. xd = opts.hostname !== location.hostname || port !== opts.port;
  707. xs = opts.secure !== isSSL;
  708. }
  709. opts.xdomain = xd;
  710. opts.xscheme = xs;
  711. xhr = new XMLHttpRequest(opts);
  712. if ('open' in xhr && !opts.forceJSONP) {
  713. return new XHR(opts);
  714. } else {
  715. if (!jsonp) throw new Error('JSONP disabled');
  716. return new JSONP(opts);
  717. }
  718. }
  719. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  720. /***/ },
  721. /* 4 */
  722. /***/ function(module, exports, __webpack_require__) {
  723. /* WEBPACK VAR INJECTION */(function(global) {'use strict';
  724. // browser shim for xmlhttprequest module
  725. var hasCORS = __webpack_require__(5);
  726. module.exports = function (opts) {
  727. var xdomain = opts.xdomain;
  728. // scheme must be same when usign XDomainRequest
  729. // http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
  730. var xscheme = opts.xscheme;
  731. // XDomainRequest has a flow of not sending cookie, therefore it should be disabled as a default.
  732. // https://github.com/Automattic/engine.io-client/pull/217
  733. var enablesXDR = opts.enablesXDR;
  734. // XMLHttpRequest can be disabled on IE
  735. try {
  736. if ('undefined' !== typeof XMLHttpRequest && (!xdomain || hasCORS)) {
  737. return new XMLHttpRequest();
  738. }
  739. } catch (e) {}
  740. // Use XDomainRequest for IE8 if enablesXDR is true
  741. // because loading bar keeps flashing when using jsonp-polling
  742. // https://github.com/yujiosaka/socke.io-ie8-loading-example
  743. try {
  744. if ('undefined' !== typeof XDomainRequest && !xscheme && enablesXDR) {
  745. return new XDomainRequest();
  746. }
  747. } catch (e) {}
  748. if (!xdomain) {
  749. try {
  750. return new global[['Active'].concat('Object').join('X')]('Microsoft.XMLHTTP');
  751. } catch (e) {}
  752. }
  753. };
  754. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  755. /***/ },
  756. /* 5 */
  757. /***/ function(module, exports) {
  758. /**
  759. * Module exports.
  760. *
  761. * Logic borrowed from Modernizr:
  762. *
  763. * - https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cors.js
  764. */
  765. try {
  766. module.exports = typeof XMLHttpRequest !== 'undefined' &&
  767. 'withCredentials' in new XMLHttpRequest();
  768. } catch (err) {
  769. // if XMLHttp support is disabled in IE then it will throw
  770. // when trying to create
  771. module.exports = false;
  772. }
  773. /***/ },
  774. /* 6 */
  775. /***/ function(module, exports, __webpack_require__) {
  776. /* WEBPACK VAR INJECTION */(function(global) {'use strict';
  777. /**
  778. * Module requirements.
  779. */
  780. var XMLHttpRequest = __webpack_require__(4);
  781. var Polling = __webpack_require__(7);
  782. var Emitter = __webpack_require__(19);
  783. var inherit = __webpack_require__(21);
  784. var debug = __webpack_require__(23)('engine.io-client:polling-xhr');
  785. /**
  786. * Module exports.
  787. */
  788. module.exports = XHR;
  789. module.exports.Request = Request;
  790. /**
  791. * Empty function
  792. */
  793. function empty() {}
  794. /**
  795. * XHR Polling constructor.
  796. *
  797. * @param {Object} opts
  798. * @api public
  799. */
  800. function XHR(opts) {
  801. Polling.call(this, opts);
  802. this.requestTimeout = opts.requestTimeout;
  803. if (global.location) {
  804. var isSSL = 'https:' === location.protocol;
  805. var port = location.port;
  806. // some user agents have empty `location.port`
  807. if (!port) {
  808. port = isSSL ? 443 : 80;
  809. }
  810. this.xd = opts.hostname !== global.location.hostname || port !== opts.port;
  811. this.xs = opts.secure !== isSSL;
  812. } else {
  813. this.extraHeaders = opts.extraHeaders;
  814. }
  815. }
  816. /**
  817. * Inherits from Polling.
  818. */
  819. inherit(XHR, Polling);
  820. /**
  821. * XHR supports binary
  822. */
  823. XHR.prototype.supportsBinary = true;
  824. /**
  825. * Creates a request.
  826. *
  827. * @param {String} method
  828. * @api private
  829. */
  830. XHR.prototype.request = function (opts) {
  831. opts = opts || {};
  832. opts.uri = this.uri();
  833. opts.xd = this.xd;
  834. opts.xs = this.xs;
  835. opts.agent = this.agent || false;
  836. opts.supportsBinary = this.supportsBinary;
  837. opts.enablesXDR = this.enablesXDR;
  838. // SSL options for Node.js client
  839. opts.pfx = this.pfx;
  840. opts.key = this.key;
  841. opts.passphrase = this.passphrase;
  842. opts.cert = this.cert;
  843. opts.ca = this.ca;
  844. opts.ciphers = this.ciphers;
  845. opts.rejectUnauthorized = this.rejectUnauthorized;
  846. opts.requestTimeout = this.requestTimeout;
  847. // other options for Node.js client
  848. opts.extraHeaders = this.extraHeaders;
  849. return new Request(opts);
  850. };
  851. /**
  852. * Sends data.
  853. *
  854. * @param {String} data to send.
  855. * @param {Function} called upon flush.
  856. * @api private
  857. */
  858. XHR.prototype.doWrite = function (data, fn) {
  859. var isBinary = typeof data !== 'string' && data !== undefined;
  860. var req = this.request({ method: 'POST', data: data, isBinary: isBinary });
  861. var self = this;
  862. req.on('success', fn);
  863. req.on('error', function (err) {
  864. self.onError('xhr post error', err);
  865. });
  866. this.sendXhr = req;
  867. };
  868. /**
  869. * Starts a poll cycle.
  870. *
  871. * @api private
  872. */
  873. XHR.prototype.doPoll = function () {
  874. debug('xhr poll');
  875. var req = this.request();
  876. var self = this;
  877. req.on('data', function (data) {
  878. self.onData(data);
  879. });
  880. req.on('error', function (err) {
  881. self.onError('xhr poll error', err);
  882. });
  883. this.pollXhr = req;
  884. };
  885. /**
  886. * Request constructor
  887. *
  888. * @param {Object} options
  889. * @api public
  890. */
  891. function Request(opts) {
  892. this.method = opts.method || 'GET';
  893. this.uri = opts.uri;
  894. this.xd = !!opts.xd;
  895. this.xs = !!opts.xs;
  896. this.async = false !== opts.async;
  897. this.data = undefined !== opts.data ? opts.data : null;
  898. this.agent = opts.agent;
  899. this.isBinary = opts.isBinary;
  900. this.supportsBinary = opts.supportsBinary;
  901. this.enablesXDR = opts.enablesXDR;
  902. this.requestTimeout = opts.requestTimeout;
  903. // SSL options for Node.js client
  904. this.pfx = opts.pfx;
  905. this.key = opts.key;
  906. this.passphrase = opts.passphrase;
  907. this.cert = opts.cert;
  908. this.ca = opts.ca;
  909. this.ciphers = opts.ciphers;
  910. this.rejectUnauthorized = opts.rejectUnauthorized;
  911. // other options for Node.js client
  912. this.extraHeaders = opts.extraHeaders;
  913. this.create();
  914. }
  915. /**
  916. * Mix in `Emitter`.
  917. */
  918. Emitter(Request.prototype);
  919. /**
  920. * Creates the XHR object and sends the request.
  921. *
  922. * @api private
  923. */
  924. Request.prototype.create = function () {
  925. var opts = { agent: this.agent, xdomain: this.xd, xscheme: this.xs, enablesXDR: this.enablesXDR };
  926. // SSL options for Node.js client
  927. opts.pfx = this.pfx;
  928. opts.key = this.key;
  929. opts.passphrase = this.passphrase;
  930. opts.cert = this.cert;
  931. opts.ca = this.ca;
  932. opts.ciphers = this.ciphers;
  933. opts.rejectUnauthorized = this.rejectUnauthorized;
  934. var xhr = this.xhr = new XMLHttpRequest(opts);
  935. var self = this;
  936. try {
  937. debug('xhr open %s: %s', this.method, this.uri);
  938. xhr.open(this.method, this.uri, this.async);
  939. try {
  940. if (this.extraHeaders) {
  941. xhr.setDisableHeaderCheck(true);
  942. for (var i in this.extraHeaders) {
  943. if (this.extraHeaders.hasOwnProperty(i)) {
  944. xhr.setRequestHeader(i, this.extraHeaders[i]);
  945. }
  946. }
  947. }
  948. } catch (e) {}
  949. if (this.supportsBinary) {
  950. // This has to be done after open because Firefox is stupid
  951. // http://stackoverflow.com/questions/13216903/get-binary-data-with-xmlhttprequest-in-a-firefox-extension
  952. xhr.responseType = 'arraybuffer';
  953. }
  954. if ('POST' === this.method) {
  955. try {
  956. if (this.isBinary) {
  957. xhr.setRequestHeader('Content-type', 'application/octet-stream');
  958. } else {
  959. xhr.setRequestHeader('Content-type', 'text/plain;charset=UTF-8');
  960. }
  961. } catch (e) {}
  962. }
  963. try {
  964. xhr.setRequestHeader('Accept', '*/*');
  965. } catch (e) {}
  966. // ie6 check
  967. if ('withCredentials' in xhr) {
  968. xhr.withCredentials = true;
  969. }
  970. if (this.requestTimeout) {
  971. xhr.timeout = this.requestTimeout;
  972. }
  973. if (this.hasXDR()) {
  974. xhr.onload = function () {
  975. self.onLoad();
  976. };
  977. xhr.onerror = function () {
  978. self.onError(xhr.responseText);
  979. };
  980. } else {
  981. xhr.onreadystatechange = function () {
  982. if (4 !== xhr.readyState) return;
  983. if (200 === xhr.status || 1223 === xhr.status) {
  984. self.onLoad();
  985. } else {
  986. // make sure the `error` event handler that's user-set
  987. // does not throw in the same tick and gets caught here
  988. setTimeout(function () {
  989. self.onError(xhr.status);
  990. }, 0);
  991. }
  992. };
  993. }
  994. debug('xhr data %s', this.data);
  995. xhr.send(this.data);
  996. } catch (e) {
  997. // Need to defer since .create() is called directly fhrom the constructor
  998. // and thus the 'error' event can only be only bound *after* this exception
  999. // occurs. Therefore, also, we cannot throw here at all.
  1000. setTimeout(function () {
  1001. self.onError(e);
  1002. }, 0);
  1003. return;
  1004. }
  1005. if (global.document) {
  1006. this.index = Request.requestsCount++;
  1007. Request.requests[this.index] = this;
  1008. }
  1009. };
  1010. /**
  1011. * Called upon successful response.
  1012. *
  1013. * @api private
  1014. */
  1015. Request.prototype.onSuccess = function () {
  1016. this.emit('success');
  1017. this.cleanup();
  1018. };
  1019. /**
  1020. * Called if we have data.
  1021. *
  1022. * @api private
  1023. */
  1024. Request.prototype.onData = function (data) {
  1025. this.emit('data', data);
  1026. this.onSuccess();
  1027. };
  1028. /**
  1029. * Called upon error.
  1030. *
  1031. * @api private
  1032. */
  1033. Request.prototype.onError = function (err) {
  1034. this.emit('error', err);
  1035. this.cleanup(true);
  1036. };
  1037. /**
  1038. * Cleans up house.
  1039. *
  1040. * @api private
  1041. */
  1042. Request.prototype.cleanup = function (fromError) {
  1043. if ('undefined' === typeof this.xhr || null === this.xhr) {
  1044. return;
  1045. }
  1046. // xmlhttprequest
  1047. if (this.hasXDR()) {
  1048. this.xhr.onload = this.xhr.onerror = empty;
  1049. } else {
  1050. this.xhr.onreadystatechange = empty;
  1051. }
  1052. if (fromError) {
  1053. try {
  1054. this.xhr.abort();
  1055. } catch (e) {}
  1056. }
  1057. if (global.document) {
  1058. delete Request.requests[this.index];
  1059. }
  1060. this.xhr = null;
  1061. };
  1062. /**
  1063. * Called upon load.
  1064. *
  1065. * @api private
  1066. */
  1067. Request.prototype.onLoad = function () {
  1068. var data;
  1069. try {
  1070. var contentType;
  1071. try {
  1072. contentType = this.xhr.getResponseHeader('Content-Type').split(';')[0];
  1073. } catch (e) {}
  1074. if (contentType === 'application/octet-stream') {
  1075. data = this.xhr.response || this.xhr.responseText;
  1076. } else {
  1077. if (!this.supportsBinary) {
  1078. data = this.xhr.responseText;
  1079. } else {
  1080. try {
  1081. data = String.fromCharCode.apply(null, new Uint8Array(this.xhr.response));
  1082. } catch (e) {
  1083. var ui8Arr = new Uint8Array(this.xhr.response);
  1084. var dataArray = [];
  1085. for (var idx = 0, length = ui8Arr.length; idx < length; idx++) {
  1086. dataArray.push(ui8Arr[idx]);
  1087. }
  1088. data = String.fromCharCode.apply(null, dataArray);
  1089. }
  1090. }
  1091. }
  1092. } catch (e) {
  1093. this.onError(e);
  1094. }
  1095. if (null != data) {
  1096. this.onData(data);
  1097. }
  1098. };
  1099. /**
  1100. * Check if it has XDomainRequest.
  1101. *
  1102. * @api private
  1103. */
  1104. Request.prototype.hasXDR = function () {
  1105. return 'undefined' !== typeof global.XDomainRequest && !this.xs && this.enablesXDR;
  1106. };
  1107. /**
  1108. * Aborts the request.
  1109. *
  1110. * @api public
  1111. */
  1112. Request.prototype.abort = function () {
  1113. this.cleanup();
  1114. };
  1115. /**
  1116. * Aborts pending requests when unloading the window. This is needed to prevent
  1117. * memory leaks (e.g. when using IE) and to ensure that no spurious error is
  1118. * emitted.
  1119. */
  1120. Request.requestsCount = 0;
  1121. Request.requests = {};
  1122. if (global.document) {
  1123. if (global.attachEvent) {
  1124. global.attachEvent('onunload', unloadHandler);
  1125. } else if (global.addEventListener) {
  1126. global.addEventListener('beforeunload', unloadHandler, false);
  1127. }
  1128. }
  1129. function unloadHandler() {
  1130. for (var i in Request.requests) {
  1131. if (Request.requests.hasOwnProperty(i)) {
  1132. Request.requests[i].abort();
  1133. }
  1134. }
  1135. }
  1136. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  1137. /***/ },
  1138. /* 7 */
  1139. /***/ function(module, exports, __webpack_require__) {
  1140. 'use strict';
  1141. /**
  1142. * Module dependencies.
  1143. */
  1144. var Transport = __webpack_require__(8);
  1145. var parseqs = __webpack_require__(20);
  1146. var parser = __webpack_require__(9);
  1147. var inherit = __webpack_require__(21);
  1148. var yeast = __webpack_require__(22);
  1149. var debug = __webpack_require__(23)('engine.io-client:polling');
  1150. /**
  1151. * Module exports.
  1152. */
  1153. module.exports = Polling;
  1154. /**
  1155. * Is XHR2 supported?
  1156. */
  1157. var hasXHR2 = function () {
  1158. var XMLHttpRequest = __webpack_require__(4);
  1159. var xhr = new XMLHttpRequest({ xdomain: false });
  1160. return null != xhr.responseType;
  1161. }();
  1162. /**
  1163. * Polling interface.
  1164. *
  1165. * @param {Object} opts
  1166. * @api private
  1167. */
  1168. function Polling(opts) {
  1169. var forceBase64 = opts && opts.forceBase64;
  1170. if (!hasXHR2 || forceBase64) {
  1171. this.supportsBinary = false;
  1172. }
  1173. Transport.call(this, opts);
  1174. }
  1175. /**
  1176. * Inherits from Transport.
  1177. */
  1178. inherit(Polling, Transport);
  1179. /**
  1180. * Transport name.
  1181. */
  1182. Polling.prototype.name = 'polling';
  1183. /**
  1184. * Opens the socket (triggers polling). We write a PING message to determine
  1185. * when the transport is open.
  1186. *
  1187. * @api private
  1188. */
  1189. Polling.prototype.doOpen = function () {
  1190. this.poll();
  1191. };
  1192. /**
  1193. * Pauses polling.
  1194. *
  1195. * @param {Function} callback upon buffers are flushed and transport is paused
  1196. * @api private
  1197. */
  1198. Polling.prototype.pause = function (onPause) {
  1199. var self = this;
  1200. this.readyState = 'pausing';
  1201. function pause() {
  1202. debug('paused');
  1203. self.readyState = 'paused';
  1204. onPause();
  1205. }
  1206. if (this.polling || !this.writable) {
  1207. var total = 0;
  1208. if (this.polling) {
  1209. debug('we are currently polling - waiting to pause');
  1210. total++;
  1211. this.once('pollComplete', function () {
  1212. debug('pre-pause polling complete');
  1213. --total || pause();
  1214. });
  1215. }
  1216. if (!this.writable) {
  1217. debug('we are currently writing - waiting to pause');
  1218. total++;
  1219. this.once('drain', function () {
  1220. debug('pre-pause writing complete');
  1221. --total || pause();
  1222. });
  1223. }
  1224. } else {
  1225. pause();
  1226. }
  1227. };
  1228. /**
  1229. * Starts polling cycle.
  1230. *
  1231. * @api public
  1232. */
  1233. Polling.prototype.poll = function () {
  1234. debug('polling');
  1235. this.polling = true;
  1236. this.doPoll();
  1237. this.emit('poll');
  1238. };
  1239. /**
  1240. * Overloads onData to detect payloads.
  1241. *
  1242. * @api private
  1243. */
  1244. Polling.prototype.onData = function (data) {
  1245. var self = this;
  1246. debug('polling got data %s', data);
  1247. var callback = function callback(packet, index, total) {
  1248. // if its the first message we consider the transport open
  1249. if ('opening' === self.readyState) {
  1250. self.onOpen();
  1251. }
  1252. // if its a close packet, we close the ongoing requests
  1253. if ('close' === packet.type) {
  1254. self.onClose();
  1255. return false;
  1256. }
  1257. // otherwise bypass onData and handle the message
  1258. self.onPacket(packet);
  1259. };
  1260. // decode payload
  1261. parser.decodePayload(data, this.socket.binaryType, callback);
  1262. // if an event did not trigger closing
  1263. if ('closed' !== this.readyState) {
  1264. // if we got data we're not polling
  1265. this.polling = false;
  1266. this.emit('pollComplete');
  1267. if ('open' === this.readyState) {
  1268. this.poll();
  1269. } else {
  1270. debug('ignoring poll - transport state "%s"', this.readyState);
  1271. }
  1272. }
  1273. };
  1274. /**
  1275. * For polling, send a close packet.
  1276. *
  1277. * @api private
  1278. */
  1279. Polling.prototype.doClose = function () {
  1280. var self = this;
  1281. function close() {
  1282. debug('writing close packet');
  1283. self.write([{ type: 'close' }]);
  1284. }
  1285. if ('open' === this.readyState) {
  1286. debug('transport open - closing');
  1287. close();
  1288. } else {
  1289. // in case we're trying to close while
  1290. // handshaking is in progress (GH-164)
  1291. debug('transport not open - deferring close');
  1292. this.once('open', close);
  1293. }
  1294. };
  1295. /**
  1296. * Writes a packets payload.
  1297. *
  1298. * @param {Array} data packets
  1299. * @param {Function} drain callback
  1300. * @api private
  1301. */
  1302. Polling.prototype.write = function (packets) {
  1303. var self = this;
  1304. this.writable = false;
  1305. var callbackfn = function callbackfn() {
  1306. self.writable = true;
  1307. self.emit('drain');
  1308. };
  1309. parser.encodePayload(packets, this.supportsBinary, function (data) {
  1310. self.doWrite(data, callbackfn);
  1311. });
  1312. };
  1313. /**
  1314. * Generates uri for connection.
  1315. *
  1316. * @api private
  1317. */
  1318. Polling.prototype.uri = function () {
  1319. var query = this.query || {};
  1320. var schema = this.secure ? 'https' : 'http';
  1321. var port = '';
  1322. // cache busting is forced
  1323. if (false !== this.timestampRequests) {
  1324. query[this.timestampParam] = yeast();
  1325. }
  1326. if (!this.supportsBinary && !query.sid) {
  1327. query.b64 = 1;
  1328. }
  1329. query = parseqs.encode(query);
  1330. // avoid port if default for schema
  1331. if (this.port && ('https' === schema && Number(this.port) !== 443 || 'http' === schema && Number(this.port) !== 80)) {
  1332. port = ':' + this.port;
  1333. }
  1334. // prepend ? to query
  1335. if (query.length) {
  1336. query = '?' + query;
  1337. }
  1338. var ipv6 = this.hostname.indexOf(':') !== -1;
  1339. return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query;
  1340. };
  1341. /***/ },
  1342. /* 8 */
  1343. /***/ function(module, exports, __webpack_require__) {
  1344. 'use strict';
  1345. /**
  1346. * Module dependencies.
  1347. */
  1348. var parser = __webpack_require__(9);
  1349. var Emitter = __webpack_require__(19);
  1350. /**
  1351. * Module exports.
  1352. */
  1353. module.exports = Transport;
  1354. /**
  1355. * Transport abstract constructor.
  1356. *
  1357. * @param {Object} options.
  1358. * @api private
  1359. */
  1360. function Transport(opts) {
  1361. this.path = opts.path;
  1362. this.hostname = opts.hostname;
  1363. this.port = opts.port;
  1364. this.secure = opts.secure;
  1365. this.query = opts.query;
  1366. this.timestampParam = opts.timestampParam;
  1367. this.timestampRequests = opts.timestampRequests;
  1368. this.readyState = '';
  1369. this.agent = opts.agent || false;
  1370. this.socket = opts.socket;
  1371. this.enablesXDR = opts.enablesXDR;
  1372. // SSL options for Node.js client
  1373. this.pfx = opts.pfx;
  1374. this.key = opts.key;
  1375. this.passphrase = opts.passphrase;
  1376. this.cert = opts.cert;
  1377. this.ca = opts.ca;
  1378. this.ciphers = opts.ciphers;
  1379. this.rejectUnauthorized = opts.rejectUnauthorized;
  1380. this.forceNode = opts.forceNode;
  1381. // other options for Node.js client
  1382. this.extraHeaders = opts.extraHeaders;
  1383. this.localAddress = opts.localAddress;
  1384. }
  1385. /**
  1386. * Mix in `Emitter`.
  1387. */
  1388. Emitter(Transport.prototype);
  1389. /**
  1390. * Emits an error.
  1391. *
  1392. * @param {String} str
  1393. * @return {Transport} for chaining
  1394. * @api public
  1395. */
  1396. Transport.prototype.onError = function (msg, desc) {
  1397. var err = new Error(msg);
  1398. err.type = 'TransportError';
  1399. err.description = desc;
  1400. this.emit('error', err);
  1401. return this;
  1402. };
  1403. /**
  1404. * Opens the transport.
  1405. *
  1406. * @api public
  1407. */
  1408. Transport.prototype.open = function () {
  1409. if ('closed' === this.readyState || '' === this.readyState) {
  1410. this.readyState = 'opening';
  1411. this.doOpen();
  1412. }
  1413. return this;
  1414. };
  1415. /**
  1416. * Closes the transport.
  1417. *
  1418. * @api private
  1419. */
  1420. Transport.prototype.close = function () {
  1421. if ('opening' === this.readyState || 'open' === this.readyState) {
  1422. this.doClose();
  1423. this.onClose();
  1424. }
  1425. return this;
  1426. };
  1427. /**
  1428. * Sends multiple packets.
  1429. *
  1430. * @param {Array} packets
  1431. * @api private
  1432. */
  1433. Transport.prototype.send = function (packets) {
  1434. if ('open' === this.readyState) {
  1435. this.write(packets);
  1436. } else {
  1437. throw new Error('Transport not open');
  1438. }
  1439. };
  1440. /**
  1441. * Called upon open
  1442. *
  1443. * @api private
  1444. */
  1445. Transport.prototype.onOpen = function () {
  1446. this.readyState = 'open';
  1447. this.writable = true;
  1448. this.emit('open');
  1449. };
  1450. /**
  1451. * Called with data.
  1452. *
  1453. * @param {String} data
  1454. * @api private
  1455. */
  1456. Transport.prototype.onData = function (data) {
  1457. var packet = parser.decodePacket(data, this.socket.binaryType);
  1458. this.onPacket(packet);
  1459. };
  1460. /**
  1461. * Called with a decoded packet.
  1462. */
  1463. Transport.prototype.onPacket = function (packet) {
  1464. this.emit('packet', packet);
  1465. };
  1466. /**
  1467. * Called upon close.
  1468. *
  1469. * @api private
  1470. */
  1471. Transport.prototype.onClose = function () {
  1472. this.readyState = 'closed';
  1473. this.emit('close');
  1474. };
  1475. /***/ },
  1476. /* 9 */
  1477. /***/ function(module, exports, __webpack_require__) {
  1478. /* WEBPACK VAR INJECTION */(function(global) {/**
  1479. * Module dependencies.
  1480. */
  1481. var keys = __webpack_require__(10);
  1482. var hasBinary = __webpack_require__(11);
  1483. var sliceBuffer = __webpack_require__(13);
  1484. var after = __webpack_require__(14);
  1485. var utf8 = __webpack_require__(15);
  1486. var base64encoder;
  1487. if (global && global.ArrayBuffer) {
  1488. base64encoder = __webpack_require__(17);
  1489. }
  1490. /**
  1491. * Check if we are running an android browser. That requires us to use
  1492. * ArrayBuffer with polling transports...
  1493. *
  1494. * http://ghinda.net/jpeg-blob-ajax-android/
  1495. */
  1496. var isAndroid = typeof navigator !== 'undefined' && /Android/i.test(navigator.userAgent);
  1497. /**
  1498. * Check if we are running in PhantomJS.
  1499. * Uploading a Blob with PhantomJS does not work correctly, as reported here:
  1500. * https://github.com/ariya/phantomjs/issues/11395
  1501. * @type boolean
  1502. */
  1503. var isPhantomJS = typeof navigator !== 'undefined' && /PhantomJS/i.test(navigator.userAgent);
  1504. /**
  1505. * When true, avoids using Blobs to encode payloads.
  1506. * @type boolean
  1507. */
  1508. var dontSendBlobs = isAndroid || isPhantomJS;
  1509. /**
  1510. * Current protocol version.
  1511. */
  1512. exports.protocol = 3;
  1513. /**
  1514. * Packet types.
  1515. */
  1516. var packets = exports.packets = {
  1517. open: 0 // non-ws
  1518. , close: 1 // non-ws
  1519. , ping: 2
  1520. , pong: 3
  1521. , message: 4
  1522. , upgrade: 5
  1523. , noop: 6
  1524. };
  1525. var packetslist = keys(packets);
  1526. /**
  1527. * Premade error packet.
  1528. */
  1529. var err = { type: 'error', data: 'parser error' };
  1530. /**
  1531. * Create a blob api even for blob builder when vendor prefixes exist
  1532. */
  1533. var Blob = __webpack_require__(18);
  1534. /**
  1535. * Encodes a packet.
  1536. *
  1537. * <packet type id> [ <data> ]
  1538. *
  1539. * Example:
  1540. *
  1541. * 5hello world
  1542. * 3
  1543. * 4
  1544. *
  1545. * Binary is encoded in an identical principle
  1546. *
  1547. * @api private
  1548. */
  1549. exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) {
  1550. if ('function' == typeof supportsBinary) {
  1551. callback = supportsBinary;
  1552. supportsBinary = false;
  1553. }
  1554. if ('function' == typeof utf8encode) {
  1555. callback = utf8encode;
  1556. utf8encode = null;
  1557. }
  1558. var data = (packet.data === undefined)
  1559. ? undefined
  1560. : packet.data.buffer || packet.data;
  1561. if (global.ArrayBuffer && data instanceof ArrayBuffer) {
  1562. return encodeArrayBuffer(packet, supportsBinary, callback);
  1563. } else if (Blob && data instanceof global.Blob) {
  1564. return encodeBlob(packet, supportsBinary, callback);
  1565. }
  1566. // might be an object with { base64: true, data: dataAsBase64String }
  1567. if (data && data.base64) {
  1568. return encodeBase64Object(packet, callback);
  1569. }
  1570. // Sending data as a utf-8 string
  1571. var encoded = packets[packet.type];
  1572. // data fragment is optional
  1573. if (undefined !== packet.data) {
  1574. encoded += utf8encode ? utf8.encode(String(packet.data)) : String(packet.data);
  1575. }
  1576. return callback('' + encoded);
  1577. };
  1578. function encodeBase64Object(packet, callback) {
  1579. // packet data is an object { base64: true, data: dataAsBase64String }
  1580. var message = 'b' + exports.packets[packet.type] + packet.data.data;
  1581. return callback(message);
  1582. }
  1583. /**
  1584. * Encode packet helpers for binary types
  1585. */
  1586. function encodeArrayBuffer(packet, supportsBinary, callback) {
  1587. if (!supportsBinary) {
  1588. return exports.encodeBase64Packet(packet, callback);
  1589. }
  1590. var data = packet.data;
  1591. var contentArray = new Uint8Array(data);
  1592. var resultBuffer = new Uint8Array(1 + data.byteLength);
  1593. resultBuffer[0] = packets[packet.type];
  1594. for (var i = 0; i < contentArray.length; i++) {
  1595. resultBuffer[i+1] = contentArray[i];
  1596. }
  1597. return callback(resultBuffer.buffer);
  1598. }
  1599. function encodeBlobAsArrayBuffer(packet, supportsBinary, callback) {
  1600. if (!supportsBinary) {
  1601. return exports.encodeBase64Packet(packet, callback);
  1602. }
  1603. var fr = new FileReader();
  1604. fr.onload = function() {
  1605. packet.data = fr.result;
  1606. exports.encodePacket(packet, supportsBinary, true, callback);
  1607. };
  1608. return fr.readAsArrayBuffer(packet.data);
  1609. }
  1610. function encodeBlob(packet, supportsBinary, callback) {
  1611. if (!supportsBinary) {
  1612. return exports.encodeBase64Packet(packet, callback);
  1613. }
  1614. if (dontSendBlobs) {
  1615. return encodeBlobAsArrayBuffer(packet, supportsBinary, callback);
  1616. }
  1617. var length = new Uint8Array(1);
  1618. length[0] = packets[packet.type];
  1619. var blob = new Blob([length.buffer, packet.data]);
  1620. return callback(blob);
  1621. }
  1622. /**
  1623. * Encodes a packet with binary data in a base64 string
  1624. *
  1625. * @param {Object} packet, has `type` and `data`
  1626. * @return {String} base64 encoded message
  1627. */
  1628. exports.encodeBase64Packet = function(packet, callback) {
  1629. var message = 'b' + exports.packets[packet.type];
  1630. if (Blob && packet.data instanceof global.Blob) {
  1631. var fr = new FileReader();
  1632. fr.onload = function() {
  1633. var b64 = fr.result.split(',')[1];
  1634. callback(message + b64);
  1635. };
  1636. return fr.readAsDataURL(packet.data);
  1637. }
  1638. var b64data;
  1639. try {
  1640. b64data = String.fromCharCode.apply(null, new Uint8Array(packet.data));
  1641. } catch (e) {
  1642. // iPhone Safari doesn't let you apply with typed arrays
  1643. var typed = new Uint8Array(packet.data);
  1644. var basic = new Array(typed.length);
  1645. for (var i = 0; i < typed.length; i++) {
  1646. basic[i] = typed[i];
  1647. }
  1648. b64data = String.fromCharCode.apply(null, basic);
  1649. }
  1650. message += global.btoa(b64data);
  1651. return callback(message);
  1652. };
  1653. /**
  1654. * Decodes a packet. Changes format to Blob if requested.
  1655. *
  1656. * @return {Object} with `type` and `data` (if any)
  1657. * @api private
  1658. */
  1659. exports.decodePacket = function (data, binaryType, utf8decode) {
  1660. if (data === undefined) {
  1661. return err;
  1662. }
  1663. // String data
  1664. if (typeof data == 'string') {
  1665. if (data.charAt(0) == 'b') {
  1666. return exports.decodeBase64Packet(data.substr(1), binaryType);
  1667. }
  1668. if (utf8decode) {
  1669. data = tryDecode(data);
  1670. if (data === false) {
  1671. return err;
  1672. }
  1673. }
  1674. var type = data.charAt(0);
  1675. if (Number(type) != type || !packetslist[type]) {
  1676. return err;
  1677. }
  1678. if (data.length > 1) {
  1679. return { type: packetslist[type], data: data.substring(1) };
  1680. } else {
  1681. return { type: packetslist[type] };
  1682. }
  1683. }
  1684. var asArray = new Uint8Array(data);
  1685. var type = asArray[0];
  1686. var rest = sliceBuffer(data, 1);
  1687. if (Blob && binaryType === 'blob') {
  1688. rest = new Blob([rest]);
  1689. }
  1690. return { type: packetslist[type], data: rest };
  1691. };
  1692. function tryDecode(data) {
  1693. try {
  1694. data = utf8.decode(data);
  1695. } catch (e) {
  1696. return false;
  1697. }
  1698. return data;
  1699. }
  1700. /**
  1701. * Decodes a packet encoded in a base64 string
  1702. *
  1703. * @param {String} base64 encoded message
  1704. * @return {Object} with `type` and `data` (if any)
  1705. */
  1706. exports.decodeBase64Packet = function(msg, binaryType) {
  1707. var type = packetslist[msg.charAt(0)];
  1708. if (!base64encoder) {
  1709. return { type: type, data: { base64: true, data: msg.substr(1) } };
  1710. }
  1711. var data = base64encoder.decode(msg.substr(1));
  1712. if (binaryType === 'blob' && Blob) {
  1713. data = new Blob([data]);
  1714. }
  1715. return { type: type, data: data };
  1716. };
  1717. /**
  1718. * Encodes multiple messages (payload).
  1719. *
  1720. * <length>:data
  1721. *
  1722. * Example:
  1723. *
  1724. * 11:hello world2:hi
  1725. *
  1726. * If any contents are binary, they will be encoded as base64 strings. Base64
  1727. * encoded strings are marked with a b before the length specifier
  1728. *
  1729. * @param {Array} packets
  1730. * @api private
  1731. */
  1732. exports.encodePayload = function (packets, supportsBinary, callback) {
  1733. if (typeof supportsBinary == 'function') {
  1734. callback = supportsBinary;
  1735. supportsBinary = null;
  1736. }
  1737. var isBinary = hasBinary(packets);
  1738. if (supportsBinary && isBinary) {
  1739. if (Blob && !dontSendBlobs) {
  1740. return exports.encodePayloadAsBlob(packets, callback);
  1741. }
  1742. return exports.encodePayloadAsArrayBuffer(packets, callback);
  1743. }
  1744. if (!packets.length) {
  1745. return callback('0:');
  1746. }
  1747. function setLengthHeader(message) {
  1748. return message.length + ':' + message;
  1749. }
  1750. function encodeOne(packet, doneCallback) {
  1751. exports.encodePacket(packet, !isBinary ? false : supportsBinary, true, function(message) {
  1752. doneCallback(null, setLengthHeader(message));
  1753. });
  1754. }
  1755. map(packets, encodeOne, function(err, results) {
  1756. return callback(results.join(''));
  1757. });
  1758. };
  1759. /**
  1760. * Async array map using after
  1761. */
  1762. function map(ary, each, done) {
  1763. var result = new Array(ary.length);
  1764. var next = after(ary.length, done);
  1765. var eachWithIndex = function(i, el, cb) {
  1766. each(el, function(error, msg) {
  1767. result[i] = msg;
  1768. cb(error, result);
  1769. });
  1770. };
  1771. for (var i = 0; i < ary.length; i++) {
  1772. eachWithIndex(i, ary[i], next);
  1773. }
  1774. }
  1775. /*
  1776. * Decodes data when a payload is maybe expected. Possible binary contents are
  1777. * decoded from their base64 representation
  1778. *
  1779. * @param {String} data, callback method
  1780. * @api public
  1781. */
  1782. exports.decodePayload = function (data, binaryType, callback) {
  1783. if (typeof data != 'string') {
  1784. return exports.decodePayloadAsBinary(data, binaryType, callback);
  1785. }
  1786. if (typeof binaryType === 'function') {
  1787. callback = binaryType;
  1788. binaryType = null;
  1789. }
  1790. var packet;
  1791. if (data == '') {
  1792. // parser error - ignoring payload
  1793. return callback(err, 0, 1);
  1794. }
  1795. var length = ''
  1796. , n, msg;
  1797. for (var i = 0, l = data.length; i < l; i++) {
  1798. var chr = data.charAt(i);
  1799. if (':' != chr) {
  1800. length += chr;
  1801. } else {
  1802. if ('' == length || (length != (n = Number(length)))) {
  1803. // parser error - ignoring payload
  1804. return callback(err, 0, 1);
  1805. }
  1806. msg = data.substr(i + 1, n);
  1807. if (length != msg.length) {
  1808. // parser error - ignoring payload
  1809. return callback(err, 0, 1);
  1810. }
  1811. if (msg.length) {
  1812. packet = exports.decodePacket(msg, binaryType, true);
  1813. if (err.type == packet.type && err.data == packet.data) {
  1814. // parser error in individual packet - ignoring payload
  1815. return callback(err, 0, 1);
  1816. }
  1817. var ret = callback(packet, i + n, l);
  1818. if (false === ret) return;
  1819. }
  1820. // advance cursor
  1821. i += n;
  1822. length = '';
  1823. }
  1824. }
  1825. if (length != '') {
  1826. // parser error - ignoring payload
  1827. return callback(err, 0, 1);
  1828. }
  1829. };
  1830. /**
  1831. * Encodes multiple messages (payload) as binary.
  1832. *
  1833. * <1 = binary, 0 = string><number from 0-9><number from 0-9>[...]<number
  1834. * 255><data>
  1835. *
  1836. * Example:
  1837. * 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers
  1838. *
  1839. * @param {Array} packets
  1840. * @return {ArrayBuffer} encoded payload
  1841. * @api private
  1842. */
  1843. exports.encodePayloadAsArrayBuffer = function(packets, callback) {
  1844. if (!packets.length) {
  1845. return callback(new ArrayBuffer(0));
  1846. }
  1847. function encodeOne(packet, doneCallback) {
  1848. exports.encodePacket(packet, true, true, function(data) {
  1849. return doneCallback(null, data);
  1850. });
  1851. }
  1852. map(packets, encodeOne, function(err, encodedPackets) {
  1853. var totalLength = encodedPackets.reduce(function(acc, p) {
  1854. var len;
  1855. if (typeof p === 'string'){
  1856. len = p.length;
  1857. } else {
  1858. len = p.byteLength;
  1859. }
  1860. return acc + len.toString().length + len + 2; // string/binary identifier + separator = 2
  1861. }, 0);
  1862. var resultArray = new Uint8Array(totalLength);
  1863. var bufferIndex = 0;
  1864. encodedPackets.forEach(function(p) {
  1865. var isString = typeof p === 'string';
  1866. var ab = p;
  1867. if (isString) {
  1868. var view = new Uint8Array(p.length);
  1869. for (var i = 0; i < p.length; i++) {
  1870. view[i] = p.charCodeAt(i);
  1871. }
  1872. ab = view.buffer;
  1873. }
  1874. if (isString) { // not true binary
  1875. resultArray[bufferIndex++] = 0;
  1876. } else { // true binary
  1877. resultArray[bufferIndex++] = 1;
  1878. }
  1879. var lenStr = ab.byteLength.toString();
  1880. for (var i = 0; i < lenStr.length; i++) {
  1881. resultArray[bufferIndex++] = parseInt(lenStr[i]);
  1882. }
  1883. resultArray[bufferIndex++] = 255;
  1884. var view = new Uint8Array(ab);
  1885. for (var i = 0; i < view.length; i++) {
  1886. resultArray[bufferIndex++] = view[i];
  1887. }
  1888. });
  1889. return callback(resultArray.buffer);
  1890. });
  1891. };
  1892. /**
  1893. * Encode as Blob
  1894. */
  1895. exports.encodePayloadAsBlob = function(packets, callback) {
  1896. function encodeOne(packet, doneCallback) {
  1897. exports.encodePacket(packet, true, true, function(encoded) {
  1898. var binaryIdentifier = new Uint8Array(1);
  1899. binaryIdentifier[0] = 1;
  1900. if (typeof encoded === 'string') {
  1901. var view = new Uint8Array(encoded.length);
  1902. for (var i = 0; i < encoded.length; i++) {
  1903. view[i] = encoded.charCodeAt(i);
  1904. }
  1905. encoded = view.buffer;
  1906. binaryIdentifier[0] = 0;
  1907. }
  1908. var len = (encoded instanceof ArrayBuffer)
  1909. ? encoded.byteLength
  1910. : encoded.size;
  1911. var lenStr = len.toString();
  1912. var lengthAry = new Uint8Array(lenStr.length + 1);
  1913. for (var i = 0; i < lenStr.length; i++) {
  1914. lengthAry[i] = parseInt(lenStr[i]);
  1915. }
  1916. lengthAry[lenStr.length] = 255;
  1917. if (Blob) {
  1918. var blob = new Blob([binaryIdentifier.buffer, lengthAry.buffer, encoded]);
  1919. doneCallback(null, blob);
  1920. }
  1921. });
  1922. }
  1923. map(packets, encodeOne, function(err, results) {
  1924. return callback(new Blob(results));
  1925. });
  1926. };
  1927. /*
  1928. * Decodes data when a payload is maybe expected. Strings are decoded by
  1929. * interpreting each byte as a key code for entries marked to start with 0. See
  1930. * description of encodePayloadAsBinary
  1931. *
  1932. * @param {ArrayBuffer} data, callback method
  1933. * @api public
  1934. */
  1935. exports.decodePayloadAsBinary = function (data, binaryType, callback) {
  1936. if (typeof binaryType === 'function') {
  1937. callback = binaryType;
  1938. binaryType = null;
  1939. }
  1940. var bufferTail = data;
  1941. var buffers = [];
  1942. var numberTooLong = false;
  1943. while (bufferTail.byteLength > 0) {
  1944. var tailArray = new Uint8Array(bufferTail);
  1945. var isString = tailArray[0] === 0;
  1946. var msgLength = '';
  1947. for (var i = 1; ; i++) {
  1948. if (tailArray[i] == 255) break;
  1949. if (msgLength.length > 310) {
  1950. numberTooLong = true;
  1951. break;
  1952. }
  1953. msgLength += tailArray[i];
  1954. }
  1955. if(numberTooLong) return callback(err, 0, 1);
  1956. bufferTail = sliceBuffer(bufferTail, 2 + msgLength.length);
  1957. msgLength = parseInt(msgLength);
  1958. var msg = sliceBuffer(bufferTail, 0, msgLength);
  1959. if (isString) {
  1960. try {
  1961. msg = String.fromCharCode.apply(null, new Uint8Array(msg));
  1962. } catch (e) {
  1963. // iPhone Safari doesn't let you apply to typed arrays
  1964. var typed = new Uint8Array(msg);
  1965. msg = '';
  1966. for (var i = 0; i < typed.length; i++) {
  1967. msg += String.fromCharCode(typed[i]);
  1968. }
  1969. }
  1970. }
  1971. buffers.push(msg);
  1972. bufferTail = sliceBuffer(bufferTail, msgLength);
  1973. }
  1974. var total = buffers.length;
  1975. buffers.forEach(function(buffer, i) {
  1976. callback(exports.decodePacket(buffer, binaryType, true), i, total);
  1977. });
  1978. };
  1979. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  1980. /***/ },
  1981. /* 10 */
  1982. /***/ function(module, exports) {
  1983. /**
  1984. * Gets the keys for an object.
  1985. *
  1986. * @return {Array} keys
  1987. * @api private
  1988. */
  1989. module.exports = Object.keys || function keys (obj){
  1990. var arr = [];
  1991. var has = Object.prototype.hasOwnProperty;
  1992. for (var i in obj) {
  1993. if (has.call(obj, i)) {
  1994. arr.push(i);
  1995. }
  1996. }
  1997. return arr;
  1998. };
  1999. /***/ },
  2000. /* 11 */
  2001. /***/ function(module, exports, __webpack_require__) {
  2002. /* WEBPACK VAR INJECTION */(function(global) {
  2003. /*
  2004. * Module requirements.
  2005. */
  2006. var isArray = __webpack_require__(12);
  2007. /**
  2008. * Module exports.
  2009. */
  2010. module.exports = hasBinary;
  2011. /**
  2012. * Checks for binary data.
  2013. *
  2014. * Right now only Buffer and ArrayBuffer are supported..
  2015. *
  2016. * @param {Object} anything
  2017. * @api public
  2018. */
  2019. function hasBinary(data) {
  2020. function _hasBinary(obj) {
  2021. if (!obj) return false;
  2022. if ( (global.Buffer && global.Buffer.isBuffer && global.Buffer.isBuffer(obj)) ||
  2023. (global.ArrayBuffer && obj instanceof ArrayBuffer) ||
  2024. (global.Blob && obj instanceof Blob) ||
  2025. (global.File && obj instanceof File)
  2026. ) {
  2027. return true;
  2028. }
  2029. if (isArray(obj)) {
  2030. for (var i = 0; i < obj.length; i++) {
  2031. if (_hasBinary(obj[i])) {
  2032. return true;
  2033. }
  2034. }
  2035. } else if (obj && 'object' == typeof obj) {
  2036. // see: https://github.com/Automattic/has-binary/pull/4
  2037. if (obj.toJSON && 'function' == typeof obj.toJSON) {
  2038. obj = obj.toJSON();
  2039. }
  2040. for (var key in obj) {
  2041. if (Object.prototype.hasOwnProperty.call(obj, key) && _hasBinary(obj[key])) {
  2042. return true;
  2043. }
  2044. }
  2045. }
  2046. return false;
  2047. }
  2048. return _hasBinary(data);
  2049. }
  2050. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  2051. /***/ },
  2052. /* 12 */
  2053. /***/ function(module, exports) {
  2054. module.exports = Array.isArray || function (arr) {
  2055. return Object.prototype.toString.call(arr) == '[object Array]';
  2056. };
  2057. /***/ },
  2058. /* 13 */
  2059. /***/ function(module, exports) {
  2060. /**
  2061. * An abstraction for slicing an arraybuffer even when
  2062. * ArrayBuffer.prototype.slice is not supported
  2063. *
  2064. * @api public
  2065. */
  2066. module.exports = function(arraybuffer, start, end) {
  2067. var bytes = arraybuffer.byteLength;
  2068. start = start || 0;
  2069. end = end || bytes;
  2070. if (arraybuffer.slice) { return arraybuffer.slice(start, end); }
  2071. if (start < 0) { start += bytes; }
  2072. if (end < 0) { end += bytes; }
  2073. if (end > bytes) { end = bytes; }
  2074. if (start >= bytes || start >= end || bytes === 0) {
  2075. return new ArrayBuffer(0);
  2076. }
  2077. var abv = new Uint8Array(arraybuffer);
  2078. var result = new Uint8Array(end - start);
  2079. for (var i = start, ii = 0; i < end; i++, ii++) {
  2080. result[ii] = abv[i];
  2081. }
  2082. return result.buffer;
  2083. };
  2084. /***/ },
  2085. /* 14 */
  2086. /***/ function(module, exports) {
  2087. module.exports = after
  2088. function after(count, callback, err_cb) {
  2089. var bail = false
  2090. err_cb = err_cb || noop
  2091. proxy.count = count
  2092. return (count === 0) ? callback() : proxy
  2093. function proxy(err, result) {
  2094. if (proxy.count <= 0) {
  2095. throw new Error('after called too many times')
  2096. }
  2097. --proxy.count
  2098. // after first error, rest are passed to err_cb
  2099. if (err) {
  2100. bail = true
  2101. callback(err)
  2102. // future error callbacks will go to error handler
  2103. callback = err_cb
  2104. } else if (proxy.count === 0 && !bail) {
  2105. callback(null, result)
  2106. }
  2107. }
  2108. }
  2109. function noop() {}
  2110. /***/ },
  2111. /* 15 */
  2112. /***/ function(module, exports, __webpack_require__) {
  2113. var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module, global) {/*! https://mths.be/wtf8 v1.0.0 by @mathias */
  2114. ;(function(root) {
  2115. // Detect free variables `exports`
  2116. var freeExports = typeof exports == 'object' && exports;
  2117. // Detect free variable `module`
  2118. var freeModule = typeof module == 'object' && module &&
  2119. module.exports == freeExports && module;
  2120. // Detect free variable `global`, from Node.js or Browserified code,
  2121. // and use it as `root`
  2122. var freeGlobal = typeof global == 'object' && global;
  2123. if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
  2124. root = freeGlobal;
  2125. }
  2126. /*--------------------------------------------------------------------------*/
  2127. var stringFromCharCode = String.fromCharCode;
  2128. // Taken from https://mths.be/punycode
  2129. function ucs2decode(string) {
  2130. var output = [];
  2131. var counter = 0;
  2132. var length = string.length;
  2133. var value;
  2134. var extra;
  2135. while (counter < length) {
  2136. value = string.charCodeAt(counter++);
  2137. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  2138. // high surrogate, and there is a next character
  2139. extra = string.charCodeAt(counter++);
  2140. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  2141. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  2142. } else {
  2143. // unmatched surrogate; only append this code unit, in case the next
  2144. // code unit is the high surrogate of a surrogate pair
  2145. output.push(value);
  2146. counter--;
  2147. }
  2148. } else {
  2149. output.push(value);
  2150. }
  2151. }
  2152. return output;
  2153. }
  2154. // Taken from https://mths.be/punycode
  2155. function ucs2encode(array) {
  2156. var length = array.length;
  2157. var index = -1;
  2158. var value;
  2159. var output = '';
  2160. while (++index < length) {
  2161. value = array[index];
  2162. if (value > 0xFFFF) {
  2163. value -= 0x10000;
  2164. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  2165. value = 0xDC00 | value & 0x3FF;
  2166. }
  2167. output += stringFromCharCode(value);
  2168. }
  2169. return output;
  2170. }
  2171. /*--------------------------------------------------------------------------*/
  2172. function createByte(codePoint, shift) {
  2173. return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
  2174. }
  2175. function encodeCodePoint(codePoint) {
  2176. if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
  2177. return stringFromCharCode(codePoint);
  2178. }
  2179. var symbol = '';
  2180. if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
  2181. symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
  2182. }
  2183. else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
  2184. symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
  2185. symbol += createByte(codePoint, 6);
  2186. }
  2187. else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
  2188. symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
  2189. symbol += createByte(codePoint, 12);
  2190. symbol += createByte(codePoint, 6);
  2191. }
  2192. symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
  2193. return symbol;
  2194. }
  2195. function wtf8encode(string) {
  2196. var codePoints = ucs2decode(string);
  2197. var length = codePoints.length;
  2198. var index = -1;
  2199. var codePoint;
  2200. var byteString = '';
  2201. while (++index < length) {
  2202. codePoint = codePoints[index];
  2203. byteString += encodeCodePoint(codePoint);
  2204. }
  2205. return byteString;
  2206. }
  2207. /*--------------------------------------------------------------------------*/
  2208. function readContinuationByte() {
  2209. if (byteIndex >= byteCount) {
  2210. throw Error('Invalid byte index');
  2211. }
  2212. var continuationByte = byteArray[byteIndex] & 0xFF;
  2213. byteIndex++;
  2214. if ((continuationByte & 0xC0) == 0x80) {
  2215. return continuationByte & 0x3F;
  2216. }
  2217. // If we end up here, it’s not a continuation byte.
  2218. throw Error('Invalid continuation byte');
  2219. }
  2220. function decodeSymbol() {
  2221. var byte1;
  2222. var byte2;
  2223. var byte3;
  2224. var byte4;
  2225. var codePoint;
  2226. if (byteIndex > byteCount) {
  2227. throw Error('Invalid byte index');
  2228. }
  2229. if (byteIndex == byteCount) {
  2230. return false;
  2231. }
  2232. // Read the first byte.
  2233. byte1 = byteArray[byteIndex] & 0xFF;
  2234. byteIndex++;
  2235. // 1-byte sequence (no continuation bytes)
  2236. if ((byte1 & 0x80) == 0) {
  2237. return byte1;
  2238. }
  2239. // 2-byte sequence
  2240. if ((byte1 & 0xE0) == 0xC0) {
  2241. var byte2 = readContinuationByte();
  2242. codePoint = ((byte1 & 0x1F) << 6) | byte2;
  2243. if (codePoint >= 0x80) {
  2244. return codePoint;
  2245. } else {
  2246. throw Error('Invalid continuation byte');
  2247. }
  2248. }
  2249. // 3-byte sequence (may include unpaired surrogates)
  2250. if ((byte1 & 0xF0) == 0xE0) {
  2251. byte2 = readContinuationByte();
  2252. byte3 = readContinuationByte();
  2253. codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
  2254. if (codePoint >= 0x0800) {
  2255. return codePoint;
  2256. } else {
  2257. throw Error('Invalid continuation byte');
  2258. }
  2259. }
  2260. // 4-byte sequence
  2261. if ((byte1 & 0xF8) == 0xF0) {
  2262. byte2 = readContinuationByte();
  2263. byte3 = readContinuationByte();
  2264. byte4 = readContinuationByte();
  2265. codePoint = ((byte1 & 0x0F) << 0x12) | (byte2 << 0x0C) |
  2266. (byte3 << 0x06) | byte4;
  2267. if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
  2268. return codePoint;
  2269. }
  2270. }
  2271. throw Error('Invalid WTF-8 detected');
  2272. }
  2273. var byteArray;
  2274. var byteCount;
  2275. var byteIndex;
  2276. function wtf8decode(byteString) {
  2277. byteArray = ucs2decode(byteString);
  2278. byteCount = byteArray.length;
  2279. byteIndex = 0;
  2280. var codePoints = [];
  2281. var tmp;
  2282. while ((tmp = decodeSymbol()) !== false) {
  2283. codePoints.push(tmp);
  2284. }
  2285. return ucs2encode(codePoints);
  2286. }
  2287. /*--------------------------------------------------------------------------*/
  2288. var wtf8 = {
  2289. 'version': '1.0.0',
  2290. 'encode': wtf8encode,
  2291. 'decode': wtf8decode
  2292. };
  2293. // Some AMD build optimizers, like r.js, check for specific condition patterns
  2294. // like the following:
  2295. if (
  2296. true
  2297. ) {
  2298. !(__WEBPACK_AMD_DEFINE_RESULT__ = function() {
  2299. return wtf8;
  2300. }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  2301. } else if (freeExports && !freeExports.nodeType) {
  2302. if (freeModule) { // in Node.js or RingoJS v0.8.0+
  2303. freeModule.exports = wtf8;
  2304. } else { // in Narwhal or RingoJS v0.7.0-
  2305. var object = {};
  2306. var hasOwnProperty = object.hasOwnProperty;
  2307. for (var key in wtf8) {
  2308. hasOwnProperty.call(wtf8, key) && (freeExports[key] = wtf8[key]);
  2309. }
  2310. }
  2311. } else { // in Rhino or a web browser
  2312. root.wtf8 = wtf8;
  2313. }
  2314. }(this));
  2315. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(16)(module), (function() { return this; }())))
  2316. /***/ },
  2317. /* 16 */
  2318. /***/ function(module, exports) {
  2319. module.exports = function(module) {
  2320. if(!module.webpackPolyfill) {
  2321. module.deprecate = function() {};
  2322. module.paths = [];
  2323. // module.parent = undefined by default
  2324. module.children = [];
  2325. module.webpackPolyfill = 1;
  2326. }
  2327. return module;
  2328. }
  2329. /***/ },
  2330. /* 17 */
  2331. /***/ function(module, exports) {
  2332. /*
  2333. * base64-arraybuffer
  2334. * https://github.com/niklasvh/base64-arraybuffer
  2335. *
  2336. * Copyright (c) 2012 Niklas von Hertzen
  2337. * Licensed under the MIT license.
  2338. */
  2339. (function(){
  2340. "use strict";
  2341. var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  2342. // Use a lookup table to find the index.
  2343. var lookup = new Uint8Array(256);
  2344. for (var i = 0; i < chars.length; i++) {
  2345. lookup[chars.charCodeAt(i)] = i;
  2346. }
  2347. exports.encode = function(arraybuffer) {
  2348. var bytes = new Uint8Array(arraybuffer),
  2349. i, len = bytes.length, base64 = "";
  2350. for (i = 0; i < len; i+=3) {
  2351. base64 += chars[bytes[i] >> 2];
  2352. base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
  2353. base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
  2354. base64 += chars[bytes[i + 2] & 63];
  2355. }
  2356. if ((len % 3) === 2) {
  2357. base64 = base64.substring(0, base64.length - 1) + "=";
  2358. } else if (len % 3 === 1) {
  2359. base64 = base64.substring(0, base64.length - 2) + "==";
  2360. }
  2361. return base64;
  2362. };
  2363. exports.decode = function(base64) {
  2364. var bufferLength = base64.length * 0.75,
  2365. len = base64.length, i, p = 0,
  2366. encoded1, encoded2, encoded3, encoded4;
  2367. if (base64[base64.length - 1] === "=") {
  2368. bufferLength--;
  2369. if (base64[base64.length - 2] === "=") {
  2370. bufferLength--;
  2371. }
  2372. }
  2373. var arraybuffer = new ArrayBuffer(bufferLength),
  2374. bytes = new Uint8Array(arraybuffer);
  2375. for (i = 0; i < len; i+=4) {
  2376. encoded1 = lookup[base64.charCodeAt(i)];
  2377. encoded2 = lookup[base64.charCodeAt(i+1)];
  2378. encoded3 = lookup[base64.charCodeAt(i+2)];
  2379. encoded4 = lookup[base64.charCodeAt(i+3)];
  2380. bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
  2381. bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
  2382. bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
  2383. }
  2384. return arraybuffer;
  2385. };
  2386. })();
  2387. /***/ },
  2388. /* 18 */
  2389. /***/ function(module, exports) {
  2390. /* WEBPACK VAR INJECTION */(function(global) {/**
  2391. * Create a blob builder even when vendor prefixes exist
  2392. */
  2393. var BlobBuilder = global.BlobBuilder
  2394. || global.WebKitBlobBuilder
  2395. || global.MSBlobBuilder
  2396. || global.MozBlobBuilder;
  2397. /**
  2398. * Check if Blob constructor is supported
  2399. */
  2400. var blobSupported = (function() {
  2401. try {
  2402. var a = new Blob(['hi']);
  2403. return a.size === 2;
  2404. } catch(e) {
  2405. return false;
  2406. }
  2407. })();
  2408. /**
  2409. * Check if Blob constructor supports ArrayBufferViews
  2410. * Fails in Safari 6, so we need to map to ArrayBuffers there.
  2411. */
  2412. var blobSupportsArrayBufferView = blobSupported && (function() {
  2413. try {
  2414. var b = new Blob([new Uint8Array([1,2])]);
  2415. return b.size === 2;
  2416. } catch(e) {
  2417. return false;
  2418. }
  2419. })();
  2420. /**
  2421. * Check if BlobBuilder is supported
  2422. */
  2423. var blobBuilderSupported = BlobBuilder
  2424. && BlobBuilder.prototype.append
  2425. && BlobBuilder.prototype.getBlob;
  2426. /**
  2427. * Helper function that maps ArrayBufferViews to ArrayBuffers
  2428. * Used by BlobBuilder constructor and old browsers that didn't
  2429. * support it in the Blob constructor.
  2430. */
  2431. function mapArrayBufferViews(ary) {
  2432. for (var i = 0; i < ary.length; i++) {
  2433. var chunk = ary[i];
  2434. if (chunk.buffer instanceof ArrayBuffer) {
  2435. var buf = chunk.buffer;
  2436. // if this is a subarray, make a copy so we only
  2437. // include the subarray region from the underlying buffer
  2438. if (chunk.byteLength !== buf.byteLength) {
  2439. var copy = new Uint8Array(chunk.byteLength);
  2440. copy.set(new Uint8Array(buf, chunk.byteOffset, chunk.byteLength));
  2441. buf = copy.buffer;
  2442. }
  2443. ary[i] = buf;
  2444. }
  2445. }
  2446. }
  2447. function BlobBuilderConstructor(ary, options) {
  2448. options = options || {};
  2449. var bb = new BlobBuilder();
  2450. mapArrayBufferViews(ary);
  2451. for (var i = 0; i < ary.length; i++) {
  2452. bb.append(ary[i]);
  2453. }
  2454. return (options.type) ? bb.getBlob(options.type) : bb.getBlob();
  2455. };
  2456. function BlobConstructor(ary, options) {
  2457. mapArrayBufferViews(ary);
  2458. return new Blob(ary, options || {});
  2459. };
  2460. module.exports = (function() {
  2461. if (blobSupported) {
  2462. return blobSupportsArrayBufferView ? global.Blob : BlobConstructor;
  2463. } else if (blobBuilderSupported) {
  2464. return BlobBuilderConstructor;
  2465. } else {
  2466. return undefined;
  2467. }
  2468. })();
  2469. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  2470. /***/ },
  2471. /* 19 */
  2472. /***/ function(module, exports, __webpack_require__) {
  2473. /**
  2474. * Expose `Emitter`.
  2475. */
  2476. if (true) {
  2477. module.exports = Emitter;
  2478. }
  2479. /**
  2480. * Initialize a new `Emitter`.
  2481. *
  2482. * @api public
  2483. */
  2484. function Emitter(obj) {
  2485. if (obj) return mixin(obj);
  2486. };
  2487. /**
  2488. * Mixin the emitter properties.
  2489. *
  2490. * @param {Object} obj
  2491. * @return {Object}
  2492. * @api private
  2493. */
  2494. function mixin(obj) {
  2495. for (var key in Emitter.prototype) {
  2496. obj[key] = Emitter.prototype[key];
  2497. }
  2498. return obj;
  2499. }
  2500. /**
  2501. * Listen on the given `event` with `fn`.
  2502. *
  2503. * @param {String} event
  2504. * @param {Function} fn
  2505. * @return {Emitter}
  2506. * @api public
  2507. */
  2508. Emitter.prototype.on =
  2509. Emitter.prototype.addEventListener = function(event, fn){
  2510. this._callbacks = this._callbacks || {};
  2511. (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
  2512. .push(fn);
  2513. return this;
  2514. };
  2515. /**
  2516. * Adds an `event` listener that will be invoked a single
  2517. * time then automatically removed.
  2518. *
  2519. * @param {String} event
  2520. * @param {Function} fn
  2521. * @return {Emitter}
  2522. * @api public
  2523. */
  2524. Emitter.prototype.once = function(event, fn){
  2525. function on() {
  2526. this.off(event, on);
  2527. fn.apply(this, arguments);
  2528. }
  2529. on.fn = fn;
  2530. this.on(event, on);
  2531. return this;
  2532. };
  2533. /**
  2534. * Remove the given callback for `event` or all
  2535. * registered callbacks.
  2536. *
  2537. * @param {String} event
  2538. * @param {Function} fn
  2539. * @return {Emitter}
  2540. * @api public
  2541. */
  2542. Emitter.prototype.off =
  2543. Emitter.prototype.removeListener =
  2544. Emitter.prototype.removeAllListeners =
  2545. Emitter.prototype.removeEventListener = function(event, fn){
  2546. this._callbacks = this._callbacks || {};
  2547. // all
  2548. if (0 == arguments.length) {
  2549. this._callbacks = {};
  2550. return this;
  2551. }
  2552. // specific event
  2553. var callbacks = this._callbacks['$' + event];
  2554. if (!callbacks) return this;
  2555. // remove all handlers
  2556. if (1 == arguments.length) {
  2557. delete this._callbacks['$' + event];
  2558. return this;
  2559. }
  2560. // remove specific handler
  2561. var cb;
  2562. for (var i = 0; i < callbacks.length; i++) {
  2563. cb = callbacks[i];
  2564. if (cb === fn || cb.fn === fn) {
  2565. callbacks.splice(i, 1);
  2566. break;
  2567. }
  2568. }
  2569. return this;
  2570. };
  2571. /**
  2572. * Emit `event` with the given args.
  2573. *
  2574. * @param {String} event
  2575. * @param {Mixed} ...
  2576. * @return {Emitter}
  2577. */
  2578. Emitter.prototype.emit = function(event){
  2579. this._callbacks = this._callbacks || {};
  2580. var args = [].slice.call(arguments, 1)
  2581. , callbacks = this._callbacks['$' + event];
  2582. if (callbacks) {
  2583. callbacks = callbacks.slice(0);
  2584. for (var i = 0, len = callbacks.length; i < len; ++i) {
  2585. callbacks[i].apply(this, args);
  2586. }
  2587. }
  2588. return this;
  2589. };
  2590. /**
  2591. * Return array of callbacks for `event`.
  2592. *
  2593. * @param {String} event
  2594. * @return {Array}
  2595. * @api public
  2596. */
  2597. Emitter.prototype.listeners = function(event){
  2598. this._callbacks = this._callbacks || {};
  2599. return this._callbacks['$' + event] || [];
  2600. };
  2601. /**
  2602. * Check if this emitter has `event` handlers.
  2603. *
  2604. * @param {String} event
  2605. * @return {Boolean}
  2606. * @api public
  2607. */
  2608. Emitter.prototype.hasListeners = function(event){
  2609. return !! this.listeners(event).length;
  2610. };
  2611. /***/ },
  2612. /* 20 */
  2613. /***/ function(module, exports) {
  2614. /**
  2615. * Compiles a querystring
  2616. * Returns string representation of the object
  2617. *
  2618. * @param {Object}
  2619. * @api private
  2620. */
  2621. exports.encode = function (obj) {
  2622. var str = '';
  2623. for (var i in obj) {
  2624. if (obj.hasOwnProperty(i)) {
  2625. if (str.length) str += '&';
  2626. str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
  2627. }
  2628. }
  2629. return str;
  2630. };
  2631. /**
  2632. * Parses a simple querystring into an object
  2633. *
  2634. * @param {String} qs
  2635. * @api private
  2636. */
  2637. exports.decode = function(qs){
  2638. var qry = {};
  2639. var pairs = qs.split('&');
  2640. for (var i = 0, l = pairs.length; i < l; i++) {
  2641. var pair = pairs[i].split('=');
  2642. qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
  2643. }
  2644. return qry;
  2645. };
  2646. /***/ },
  2647. /* 21 */
  2648. /***/ function(module, exports) {
  2649. module.exports = function(a, b){
  2650. var fn = function(){};
  2651. fn.prototype = b.prototype;
  2652. a.prototype = new fn;
  2653. a.prototype.constructor = a;
  2654. };
  2655. /***/ },
  2656. /* 22 */
  2657. /***/ function(module, exports) {
  2658. 'use strict';
  2659. var alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split('')
  2660. , length = 64
  2661. , map = {}
  2662. , seed = 0
  2663. , i = 0
  2664. , prev;
  2665. /**
  2666. * Return a string representing the specified number.
  2667. *
  2668. * @param {Number} num The number to convert.
  2669. * @returns {String} The string representation of the number.
  2670. * @api public
  2671. */
  2672. function encode(num) {
  2673. var encoded = '';
  2674. do {
  2675. encoded = alphabet[num % length] + encoded;
  2676. num = Math.floor(num / length);
  2677. } while (num > 0);
  2678. return encoded;
  2679. }
  2680. /**
  2681. * Return the integer value specified by the given string.
  2682. *
  2683. * @param {String} str The string to convert.
  2684. * @returns {Number} The integer value represented by the string.
  2685. * @api public
  2686. */
  2687. function decode(str) {
  2688. var decoded = 0;
  2689. for (i = 0; i < str.length; i++) {
  2690. decoded = decoded * length + map[str.charAt(i)];
  2691. }
  2692. return decoded;
  2693. }
  2694. /**
  2695. * Yeast: A tiny growing id generator.
  2696. *
  2697. * @returns {String} A unique id.
  2698. * @api public
  2699. */
  2700. function yeast() {
  2701. var now = encode(+new Date());
  2702. if (now !== prev) return seed = 0, prev = now;
  2703. return now +'.'+ encode(seed++);
  2704. }
  2705. //
  2706. // Map each character to its index.
  2707. //
  2708. for (; i < length; i++) map[alphabet[i]] = i;
  2709. //
  2710. // Expose the `yeast`, `encode` and `decode` functions.
  2711. //
  2712. yeast.encode = encode;
  2713. yeast.decode = decode;
  2714. module.exports = yeast;
  2715. /***/ },
  2716. /* 23 */
  2717. /***/ function(module, exports, __webpack_require__) {
  2718. /* WEBPACK VAR INJECTION */(function(process) {
  2719. /**
  2720. * This is the web browser implementation of `debug()`.
  2721. *
  2722. * Expose `debug()` as the module.
  2723. */
  2724. exports = module.exports = __webpack_require__(25);
  2725. exports.log = log;
  2726. exports.formatArgs = formatArgs;
  2727. exports.save = save;
  2728. exports.load = load;
  2729. exports.useColors = useColors;
  2730. exports.storage = 'undefined' != typeof chrome
  2731. && 'undefined' != typeof chrome.storage
  2732. ? chrome.storage.local
  2733. : localstorage();
  2734. /**
  2735. * Colors.
  2736. */
  2737. exports.colors = [
  2738. 'lightseagreen',
  2739. 'forestgreen',
  2740. 'goldenrod',
  2741. 'dodgerblue',
  2742. 'darkorchid',
  2743. 'crimson'
  2744. ];
  2745. /**
  2746. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  2747. * and the Firebug extension (any Firefox version) are known
  2748. * to support "%c" CSS customizations.
  2749. *
  2750. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  2751. */
  2752. function useColors() {
  2753. // is webkit? http://stackoverflow.com/a/16459606/376773
  2754. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  2755. return (typeof document !== 'undefined' && 'WebkitAppearance' in document.documentElement.style) ||
  2756. // is firebug? http://stackoverflow.com/a/398120/376773
  2757. (window.console && (console.firebug || (console.exception && console.table))) ||
  2758. // is firefox >= v31?
  2759. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  2760. (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
  2761. }
  2762. /**
  2763. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  2764. */
  2765. exports.formatters.j = function(v) {
  2766. try {
  2767. return JSON.stringify(v);
  2768. } catch (err) {
  2769. return '[UnexpectedJSONParseError]: ' + err.message;
  2770. }
  2771. };
  2772. /**
  2773. * Colorize log arguments if enabled.
  2774. *
  2775. * @api public
  2776. */
  2777. function formatArgs() {
  2778. var args = arguments;
  2779. var useColors = this.useColors;
  2780. args[0] = (useColors ? '%c' : '')
  2781. + this.namespace
  2782. + (useColors ? ' %c' : ' ')
  2783. + args[0]
  2784. + (useColors ? '%c ' : ' ')
  2785. + '+' + exports.humanize(this.diff);
  2786. if (!useColors) return args;
  2787. var c = 'color: ' + this.color;
  2788. args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));
  2789. // the final "%c" is somewhat tricky, because there could be other
  2790. // arguments passed either before or after the %c, so we need to
  2791. // figure out the correct index to insert the CSS into
  2792. var index = 0;
  2793. var lastC = 0;
  2794. args[0].replace(/%[a-z%]/g, function(match) {
  2795. if ('%%' === match) return;
  2796. index++;
  2797. if ('%c' === match) {
  2798. // we only are interested in the *last* %c
  2799. // (the user may have provided their own)
  2800. lastC = index;
  2801. }
  2802. });
  2803. args.splice(lastC, 0, c);
  2804. return args;
  2805. }
  2806. /**
  2807. * Invokes `console.log()` when available.
  2808. * No-op when `console.log` is not a "function".
  2809. *
  2810. * @api public
  2811. */
  2812. function log() {
  2813. // this hackery is required for IE8/9, where
  2814. // the `console.log` function doesn't have 'apply'
  2815. return 'object' === typeof console
  2816. && console.log
  2817. && Function.prototype.apply.call(console.log, console, arguments);
  2818. }
  2819. /**
  2820. * Save `namespaces`.
  2821. *
  2822. * @param {String} namespaces
  2823. * @api private
  2824. */
  2825. function save(namespaces) {
  2826. try {
  2827. if (null == namespaces) {
  2828. exports.storage.removeItem('debug');
  2829. } else {
  2830. exports.storage.debug = namespaces;
  2831. }
  2832. } catch(e) {}
  2833. }
  2834. /**
  2835. * Load `namespaces`.
  2836. *
  2837. * @return {String} returns the previously persisted debug modes
  2838. * @api private
  2839. */
  2840. function load() {
  2841. var r;
  2842. try {
  2843. return exports.storage.debug;
  2844. } catch(e) {}
  2845. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  2846. if (typeof process !== 'undefined' && 'env' in process) {
  2847. return process.env.DEBUG;
  2848. }
  2849. }
  2850. /**
  2851. * Enable namespaces listed in `localStorage.debug` initially.
  2852. */
  2853. exports.enable(load());
  2854. /**
  2855. * Localstorage attempts to return the localstorage.
  2856. *
  2857. * This is necessary because safari throws
  2858. * when a user disables cookies/localstorage
  2859. * and you attempt to access it.
  2860. *
  2861. * @return {LocalStorage}
  2862. * @api private
  2863. */
  2864. function localstorage(){
  2865. try {
  2866. return window.localStorage;
  2867. } catch (e) {}
  2868. }
  2869. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(24)))
  2870. /***/ },
  2871. /* 24 */
  2872. /***/ function(module, exports) {
  2873. // shim for using process in browser
  2874. var process = module.exports = {};
  2875. // cached from whatever global is present so that test runners that stub it
  2876. // don't break things. But we need to wrap it in a try catch in case it is
  2877. // wrapped in strict mode code which doesn't define any globals. It's inside a
  2878. // function because try/catches deoptimize in certain engines.
  2879. var cachedSetTimeout;
  2880. var cachedClearTimeout;
  2881. function defaultSetTimout() {
  2882. throw new Error('setTimeout has not been defined');
  2883. }
  2884. function defaultClearTimeout () {
  2885. throw new Error('clearTimeout has not been defined');
  2886. }
  2887. (function () {
  2888. try {
  2889. if (typeof setTimeout === 'function') {
  2890. cachedSetTimeout = setTimeout;
  2891. } else {
  2892. cachedSetTimeout = defaultSetTimout;
  2893. }
  2894. } catch (e) {
  2895. cachedSetTimeout = defaultSetTimout;
  2896. }
  2897. try {
  2898. if (typeof clearTimeout === 'function') {
  2899. cachedClearTimeout = clearTimeout;
  2900. } else {
  2901. cachedClearTimeout = defaultClearTimeout;
  2902. }
  2903. } catch (e) {
  2904. cachedClearTimeout = defaultClearTimeout;
  2905. }
  2906. } ())
  2907. function runTimeout(fun) {
  2908. if (cachedSetTimeout === setTimeout) {
  2909. //normal enviroments in sane situations
  2910. return setTimeout(fun, 0);
  2911. }
  2912. // if setTimeout wasn't available but was latter defined
  2913. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  2914. cachedSetTimeout = setTimeout;
  2915. return setTimeout(fun, 0);
  2916. }
  2917. try {
  2918. // when when somebody has screwed with setTimeout but no I.E. maddness
  2919. return cachedSetTimeout(fun, 0);
  2920. } catch(e){
  2921. try {
  2922. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  2923. return cachedSetTimeout.call(null, fun, 0);
  2924. } catch(e){
  2925. // 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
  2926. return cachedSetTimeout.call(this, fun, 0);
  2927. }
  2928. }
  2929. }
  2930. function runClearTimeout(marker) {
  2931. if (cachedClearTimeout === clearTimeout) {
  2932. //normal enviroments in sane situations
  2933. return clearTimeout(marker);
  2934. }
  2935. // if clearTimeout wasn't available but was latter defined
  2936. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  2937. cachedClearTimeout = clearTimeout;
  2938. return clearTimeout(marker);
  2939. }
  2940. try {
  2941. // when when somebody has screwed with setTimeout but no I.E. maddness
  2942. return cachedClearTimeout(marker);
  2943. } catch (e){
  2944. try {
  2945. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  2946. return cachedClearTimeout.call(null, marker);
  2947. } catch (e){
  2948. // 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.
  2949. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  2950. return cachedClearTimeout.call(this, marker);
  2951. }
  2952. }
  2953. }
  2954. var queue = [];
  2955. var draining = false;
  2956. var currentQueue;
  2957. var queueIndex = -1;
  2958. function cleanUpNextTick() {
  2959. if (!draining || !currentQueue) {
  2960. return;
  2961. }
  2962. draining = false;
  2963. if (currentQueue.length) {
  2964. queue = currentQueue.concat(queue);
  2965. } else {
  2966. queueIndex = -1;
  2967. }
  2968. if (queue.length) {
  2969. drainQueue();
  2970. }
  2971. }
  2972. function drainQueue() {
  2973. if (draining) {
  2974. return;
  2975. }
  2976. var timeout = runTimeout(cleanUpNextTick);
  2977. draining = true;
  2978. var len = queue.length;
  2979. while(len) {
  2980. currentQueue = queue;
  2981. queue = [];
  2982. while (++queueIndex < len) {
  2983. if (currentQueue) {
  2984. currentQueue[queueIndex].run();
  2985. }
  2986. }
  2987. queueIndex = -1;
  2988. len = queue.length;
  2989. }
  2990. currentQueue = null;
  2991. draining = false;
  2992. runClearTimeout(timeout);
  2993. }
  2994. process.nextTick = function (fun) {
  2995. var args = new Array(arguments.length - 1);
  2996. if (arguments.length > 1) {
  2997. for (var i = 1; i < arguments.length; i++) {
  2998. args[i - 1] = arguments[i];
  2999. }
  3000. }
  3001. queue.push(new Item(fun, args));
  3002. if (queue.length === 1 && !draining) {
  3003. runTimeout(drainQueue);
  3004. }
  3005. };
  3006. // v8 likes predictible objects
  3007. function Item(fun, array) {
  3008. this.fun = fun;
  3009. this.array = array;
  3010. }
  3011. Item.prototype.run = function () {
  3012. this.fun.apply(null, this.array);
  3013. };
  3014. process.title = 'browser';
  3015. process.browser = true;
  3016. process.env = {};
  3017. process.argv = [];
  3018. process.version = ''; // empty string to avoid regexp issues
  3019. process.versions = {};
  3020. function noop() {}
  3021. process.on = noop;
  3022. process.addListener = noop;
  3023. process.once = noop;
  3024. process.off = noop;
  3025. process.removeListener = noop;
  3026. process.removeAllListeners = noop;
  3027. process.emit = noop;
  3028. process.binding = function (name) {
  3029. throw new Error('process.binding is not supported');
  3030. };
  3031. process.cwd = function () { return '/' };
  3032. process.chdir = function (dir) {
  3033. throw new Error('process.chdir is not supported');
  3034. };
  3035. process.umask = function() { return 0; };
  3036. /***/ },
  3037. /* 25 */
  3038. /***/ function(module, exports, __webpack_require__) {
  3039. /**
  3040. * This is the common logic for both the Node.js and web browser
  3041. * implementations of `debug()`.
  3042. *
  3043. * Expose `debug()` as the module.
  3044. */
  3045. exports = module.exports = debug.debug = debug;
  3046. exports.coerce = coerce;
  3047. exports.disable = disable;
  3048. exports.enable = enable;
  3049. exports.enabled = enabled;
  3050. exports.humanize = __webpack_require__(26);
  3051. /**
  3052. * The currently active debug mode names, and names to skip.
  3053. */
  3054. exports.names = [];
  3055. exports.skips = [];
  3056. /**
  3057. * Map of special "%n" handling functions, for the debug "format" argument.
  3058. *
  3059. * Valid key names are a single, lowercased letter, i.e. "n".
  3060. */
  3061. exports.formatters = {};
  3062. /**
  3063. * Previously assigned color.
  3064. */
  3065. var prevColor = 0;
  3066. /**
  3067. * Previous log timestamp.
  3068. */
  3069. var prevTime;
  3070. /**
  3071. * Select a color.
  3072. *
  3073. * @return {Number}
  3074. * @api private
  3075. */
  3076. function selectColor() {
  3077. return exports.colors[prevColor++ % exports.colors.length];
  3078. }
  3079. /**
  3080. * Create a debugger with the given `namespace`.
  3081. *
  3082. * @param {String} namespace
  3083. * @return {Function}
  3084. * @api public
  3085. */
  3086. function debug(namespace) {
  3087. // define the `disabled` version
  3088. function disabled() {
  3089. }
  3090. disabled.enabled = false;
  3091. // define the `enabled` version
  3092. function enabled() {
  3093. var self = enabled;
  3094. // set `diff` timestamp
  3095. var curr = +new Date();
  3096. var ms = curr - (prevTime || curr);
  3097. self.diff = ms;
  3098. self.prev = prevTime;
  3099. self.curr = curr;
  3100. prevTime = curr;
  3101. // add the `color` if not set
  3102. if (null == self.useColors) self.useColors = exports.useColors();
  3103. if (null == self.color && self.useColors) self.color = selectColor();
  3104. var args = new Array(arguments.length);
  3105. for (var i = 0; i < args.length; i++) {
  3106. args[i] = arguments[i];
  3107. }
  3108. args[0] = exports.coerce(args[0]);
  3109. if ('string' !== typeof args[0]) {
  3110. // anything else let's inspect with %o
  3111. args = ['%o'].concat(args);
  3112. }
  3113. // apply any `formatters` transformations
  3114. var index = 0;
  3115. args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
  3116. // if we encounter an escaped % then don't increase the array index
  3117. if (match === '%%') return match;
  3118. index++;
  3119. var formatter = exports.formatters[format];
  3120. if ('function' === typeof formatter) {
  3121. var val = args[index];
  3122. match = formatter.call(self, val);
  3123. // now we need to remove `args[index]` since it's inlined in the `format`
  3124. args.splice(index, 1);
  3125. index--;
  3126. }
  3127. return match;
  3128. });
  3129. // apply env-specific formatting
  3130. args = exports.formatArgs.apply(self, args);
  3131. var logFn = enabled.log || exports.log || console.log.bind(console);
  3132. logFn.apply(self, args);
  3133. }
  3134. enabled.enabled = true;
  3135. var fn = exports.enabled(namespace) ? enabled : disabled;
  3136. fn.namespace = namespace;
  3137. return fn;
  3138. }
  3139. /**
  3140. * Enables a debug mode by namespaces. This can include modes
  3141. * separated by a colon and wildcards.
  3142. *
  3143. * @param {String} namespaces
  3144. * @api public
  3145. */
  3146. function enable(namespaces) {
  3147. exports.save(namespaces);
  3148. var split = (namespaces || '').split(/[\s,]+/);
  3149. var len = split.length;
  3150. for (var i = 0; i < len; i++) {
  3151. if (!split[i]) continue; // ignore empty strings
  3152. namespaces = split[i].replace(/[\\^$+?.()|[\]{}]/g, '\\$&').replace(/\*/g, '.*?');
  3153. if (namespaces[0] === '-') {
  3154. exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  3155. } else {
  3156. exports.names.push(new RegExp('^' + namespaces + '$'));
  3157. }
  3158. }
  3159. }
  3160. /**
  3161. * Disable debug output.
  3162. *
  3163. * @api public
  3164. */
  3165. function disable() {
  3166. exports.enable('');
  3167. }
  3168. /**
  3169. * Returns true if the given mode name is enabled, false otherwise.
  3170. *
  3171. * @param {String} name
  3172. * @return {Boolean}
  3173. * @api public
  3174. */
  3175. function enabled(name) {
  3176. var i, len;
  3177. for (i = 0, len = exports.skips.length; i < len; i++) {
  3178. if (exports.skips[i].test(name)) {
  3179. return false;
  3180. }
  3181. }
  3182. for (i = 0, len = exports.names.length; i < len; i++) {
  3183. if (exports.names[i].test(name)) {
  3184. return true;
  3185. }
  3186. }
  3187. return false;
  3188. }
  3189. /**
  3190. * Coerce `val`.
  3191. *
  3192. * @param {Mixed} val
  3193. * @return {Mixed}
  3194. * @api private
  3195. */
  3196. function coerce(val) {
  3197. if (val instanceof Error) return val.stack || val.message;
  3198. return val;
  3199. }
  3200. /***/ },
  3201. /* 26 */
  3202. /***/ function(module, exports) {
  3203. /**
  3204. * Helpers.
  3205. */
  3206. var s = 1000
  3207. var m = s * 60
  3208. var h = m * 60
  3209. var d = h * 24
  3210. var y = d * 365.25
  3211. /**
  3212. * Parse or format the given `val`.
  3213. *
  3214. * Options:
  3215. *
  3216. * - `long` verbose formatting [false]
  3217. *
  3218. * @param {String|Number} val
  3219. * @param {Object} options
  3220. * @throws {Error} throw an error if val is not a non-empty string or a number
  3221. * @return {String|Number}
  3222. * @api public
  3223. */
  3224. module.exports = function (val, options) {
  3225. options = options || {}
  3226. var type = typeof val
  3227. if (type === 'string' && val.length > 0) {
  3228. return parse(val)
  3229. } else if (type === 'number' && isNaN(val) === false) {
  3230. return options.long ?
  3231. fmtLong(val) :
  3232. fmtShort(val)
  3233. }
  3234. throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val))
  3235. }
  3236. /**
  3237. * Parse the given `str` and return milliseconds.
  3238. *
  3239. * @param {String} str
  3240. * @return {Number}
  3241. * @api private
  3242. */
  3243. function parse(str) {
  3244. str = String(str)
  3245. if (str.length > 10000) {
  3246. return
  3247. }
  3248. var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str)
  3249. if (!match) {
  3250. return
  3251. }
  3252. var n = parseFloat(match[1])
  3253. var type = (match[2] || 'ms').toLowerCase()
  3254. switch (type) {
  3255. case 'years':
  3256. case 'year':
  3257. case 'yrs':
  3258. case 'yr':
  3259. case 'y':
  3260. return n * y
  3261. case 'days':
  3262. case 'day':
  3263. case 'd':
  3264. return n * d
  3265. case 'hours':
  3266. case 'hour':
  3267. case 'hrs':
  3268. case 'hr':
  3269. case 'h':
  3270. return n * h
  3271. case 'minutes':
  3272. case 'minute':
  3273. case 'mins':
  3274. case 'min':
  3275. case 'm':
  3276. return n * m
  3277. case 'seconds':
  3278. case 'second':
  3279. case 'secs':
  3280. case 'sec':
  3281. case 's':
  3282. return n * s
  3283. case 'milliseconds':
  3284. case 'millisecond':
  3285. case 'msecs':
  3286. case 'msec':
  3287. case 'ms':
  3288. return n
  3289. default:
  3290. return undefined
  3291. }
  3292. }
  3293. /**
  3294. * Short format for `ms`.
  3295. *
  3296. * @param {Number} ms
  3297. * @return {String}
  3298. * @api private
  3299. */
  3300. function fmtShort(ms) {
  3301. if (ms >= d) {
  3302. return Math.round(ms / d) + 'd'
  3303. }
  3304. if (ms >= h) {
  3305. return Math.round(ms / h) + 'h'
  3306. }
  3307. if (ms >= m) {
  3308. return Math.round(ms / m) + 'm'
  3309. }
  3310. if (ms >= s) {
  3311. return Math.round(ms / s) + 's'
  3312. }
  3313. return ms + 'ms'
  3314. }
  3315. /**
  3316. * Long format for `ms`.
  3317. *
  3318. * @param {Number} ms
  3319. * @return {String}
  3320. * @api private
  3321. */
  3322. function fmtLong(ms) {
  3323. return plural(ms, d, 'day') ||
  3324. plural(ms, h, 'hour') ||
  3325. plural(ms, m, 'minute') ||
  3326. plural(ms, s, 'second') ||
  3327. ms + ' ms'
  3328. }
  3329. /**
  3330. * Pluralization helper.
  3331. */
  3332. function plural(ms, n, name) {
  3333. if (ms < n) {
  3334. return
  3335. }
  3336. if (ms < n * 1.5) {
  3337. return Math.floor(ms / n) + ' ' + name
  3338. }
  3339. return Math.ceil(ms / n) + ' ' + name + 's'
  3340. }
  3341. /***/ },
  3342. /* 27 */
  3343. /***/ function(module, exports, __webpack_require__) {
  3344. /* WEBPACK VAR INJECTION */(function(global) {'use strict';
  3345. /**
  3346. * Module requirements.
  3347. */
  3348. var Polling = __webpack_require__(7);
  3349. var inherit = __webpack_require__(21);
  3350. /**
  3351. * Module exports.
  3352. */
  3353. module.exports = JSONPPolling;
  3354. /**
  3355. * Cached regular expressions.
  3356. */
  3357. var rNewline = /\n/g;
  3358. var rEscapedNewline = /\\n/g;
  3359. /**
  3360. * Global JSONP callbacks.
  3361. */
  3362. var callbacks;
  3363. /**
  3364. * Noop.
  3365. */
  3366. function empty() {}
  3367. /**
  3368. * JSONP Polling constructor.
  3369. *
  3370. * @param {Object} opts.
  3371. * @api public
  3372. */
  3373. function JSONPPolling(opts) {
  3374. Polling.call(this, opts);
  3375. this.query = this.query || {};
  3376. // define global callbacks array if not present
  3377. // we do this here (lazily) to avoid unneeded global pollution
  3378. if (!callbacks) {
  3379. // we need to consider multiple engines in the same page
  3380. if (!global.___eio) global.___eio = [];
  3381. callbacks = global.___eio;
  3382. }
  3383. // callback identifier
  3384. this.index = callbacks.length;
  3385. // add callback to jsonp global
  3386. var self = this;
  3387. callbacks.push(function (msg) {
  3388. self.onData(msg);
  3389. });
  3390. // append to query string
  3391. this.query.j = this.index;
  3392. // prevent spurious errors from being emitted when the window is unloaded
  3393. if (global.document && global.addEventListener) {
  3394. global.addEventListener('beforeunload', function () {
  3395. if (self.script) self.script.onerror = empty;
  3396. }, false);
  3397. }
  3398. }
  3399. /**
  3400. * Inherits from Polling.
  3401. */
  3402. inherit(JSONPPolling, Polling);
  3403. /*
  3404. * JSONP only supports binary as base64 encoded strings
  3405. */
  3406. JSONPPolling.prototype.supportsBinary = false;
  3407. /**
  3408. * Closes the socket.
  3409. *
  3410. * @api private
  3411. */
  3412. JSONPPolling.prototype.doClose = function () {
  3413. if (this.script) {
  3414. this.script.parentNode.removeChild(this.script);
  3415. this.script = null;
  3416. }
  3417. if (this.form) {
  3418. this.form.parentNode.removeChild(this.form);
  3419. this.form = null;
  3420. this.iframe = null;
  3421. }
  3422. Polling.prototype.doClose.call(this);
  3423. };
  3424. /**
  3425. * Starts a poll cycle.
  3426. *
  3427. * @api private
  3428. */
  3429. JSONPPolling.prototype.doPoll = function () {
  3430. var self = this;
  3431. var script = document.createElement('script');
  3432. if (this.script) {
  3433. this.script.parentNode.removeChild(this.script);
  3434. this.script = null;
  3435. }
  3436. script.async = true;
  3437. script.src = this.uri();
  3438. script.onerror = function (e) {
  3439. self.onError('jsonp poll error', e);
  3440. };
  3441. var insertAt = document.getElementsByTagName('script')[0];
  3442. if (insertAt) {
  3443. insertAt.parentNode.insertBefore(script, insertAt);
  3444. } else {
  3445. (document.head || document.body).appendChild(script);
  3446. }
  3447. this.script = script;
  3448. var isUAgecko = 'undefined' !== typeof navigator && /gecko/i.test(navigator.userAgent);
  3449. if (isUAgecko) {
  3450. setTimeout(function () {
  3451. var iframe = document.createElement('iframe');
  3452. document.body.appendChild(iframe);
  3453. document.body.removeChild(iframe);
  3454. }, 100);
  3455. }
  3456. };
  3457. /**
  3458. * Writes with a hidden iframe.
  3459. *
  3460. * @param {String} data to send
  3461. * @param {Function} called upon flush.
  3462. * @api private
  3463. */
  3464. JSONPPolling.prototype.doWrite = function (data, fn) {
  3465. var self = this;
  3466. if (!this.form) {
  3467. var form = document.createElement('form');
  3468. var area = document.createElement('textarea');
  3469. var id = this.iframeId = 'eio_iframe_' + this.index;
  3470. var iframe;
  3471. form.className = 'socketio';
  3472. form.style.position = 'absolute';
  3473. form.style.top = '-1000px';
  3474. form.style.left = '-1000px';
  3475. form.target = id;
  3476. form.method = 'POST';
  3477. form.setAttribute('accept-charset', 'utf-8');
  3478. area.name = 'd';
  3479. form.appendChild(area);
  3480. document.body.appendChild(form);
  3481. this.form = form;
  3482. this.area = area;
  3483. }
  3484. this.form.action = this.uri();
  3485. function complete() {
  3486. initIframe();
  3487. fn();
  3488. }
  3489. function initIframe() {
  3490. if (self.iframe) {
  3491. try {
  3492. self.form.removeChild(self.iframe);
  3493. } catch (e) {
  3494. self.onError('jsonp polling iframe removal error', e);
  3495. }
  3496. }
  3497. try {
  3498. // ie6 dynamic iframes with target="" support (thanks Chris Lambacher)
  3499. var html = '<iframe src="javascript:0" name="' + self.iframeId + '">';
  3500. iframe = document.createElement(html);
  3501. } catch (e) {
  3502. iframe = document.createElement('iframe');
  3503. iframe.name = self.iframeId;
  3504. iframe.src = 'javascript:0';
  3505. }
  3506. iframe.id = self.iframeId;
  3507. self.form.appendChild(iframe);
  3508. self.iframe = iframe;
  3509. }
  3510. initIframe();
  3511. // escape \n to prevent it from being converted into \r\n by some UAs
  3512. // double escaping is required for escaped new lines because unescaping of new lines can be done safely on server-side
  3513. data = data.replace(rEscapedNewline, '\\\n');
  3514. this.area.value = data.replace(rNewline, '\\n');
  3515. try {
  3516. this.form.submit();
  3517. } catch (e) {}
  3518. if (this.iframe.attachEvent) {
  3519. this.iframe.onreadystatechange = function () {
  3520. if (self.iframe.readyState === 'complete') {
  3521. complete();
  3522. }
  3523. };
  3524. } else {
  3525. this.iframe.onload = complete;
  3526. }
  3527. };
  3528. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  3529. /***/ },
  3530. /* 28 */
  3531. /***/ function(module, exports, __webpack_require__) {
  3532. /* WEBPACK VAR INJECTION */(function(global) {'use strict';
  3533. /**
  3534. * Module dependencies.
  3535. */
  3536. var Transport = __webpack_require__(8);
  3537. var parser = __webpack_require__(9);
  3538. var parseqs = __webpack_require__(20);
  3539. var inherit = __webpack_require__(21);
  3540. var yeast = __webpack_require__(22);
  3541. var debug = __webpack_require__(23)('engine.io-client:websocket');
  3542. var BrowserWebSocket = global.WebSocket || global.MozWebSocket;
  3543. var NodeWebSocket;
  3544. if (typeof window === 'undefined') {
  3545. try {
  3546. NodeWebSocket = __webpack_require__(29);
  3547. } catch (e) {}
  3548. }
  3549. /**
  3550. * Get either the `WebSocket` or `MozWebSocket` globals
  3551. * in the browser or try to resolve WebSocket-compatible
  3552. * interface exposed by `ws` for Node-like environment.
  3553. */
  3554. var WebSocket = BrowserWebSocket;
  3555. if (!WebSocket && typeof window === 'undefined') {
  3556. WebSocket = NodeWebSocket;
  3557. }
  3558. /**
  3559. * Module exports.
  3560. */
  3561. module.exports = WS;
  3562. /**
  3563. * WebSocket transport constructor.
  3564. *
  3565. * @api {Object} connection options
  3566. * @api public
  3567. */
  3568. function WS(opts) {
  3569. var forceBase64 = opts && opts.forceBase64;
  3570. if (forceBase64) {
  3571. this.supportsBinary = false;
  3572. }
  3573. this.perMessageDeflate = opts.perMessageDeflate;
  3574. this.usingBrowserWebSocket = BrowserWebSocket && !opts.forceNode;
  3575. if (!this.usingBrowserWebSocket) {
  3576. WebSocket = NodeWebSocket;
  3577. }
  3578. Transport.call(this, opts);
  3579. }
  3580. /**
  3581. * Inherits from Transport.
  3582. */
  3583. inherit(WS, Transport);
  3584. /**
  3585. * Transport name.
  3586. *
  3587. * @api public
  3588. */
  3589. WS.prototype.name = 'websocket';
  3590. /*
  3591. * WebSockets support binary
  3592. */
  3593. WS.prototype.supportsBinary = true;
  3594. /**
  3595. * Opens socket.
  3596. *
  3597. * @api private
  3598. */
  3599. WS.prototype.doOpen = function () {
  3600. if (!this.check()) {
  3601. // let probe timeout
  3602. return;
  3603. }
  3604. var uri = this.uri();
  3605. var protocols = void 0;
  3606. var opts = {
  3607. agent: this.agent,
  3608. perMessageDeflate: this.perMessageDeflate
  3609. };
  3610. // SSL options for Node.js client
  3611. opts.pfx = this.pfx;
  3612. opts.key = this.key;
  3613. opts.passphrase = this.passphrase;
  3614. opts.cert = this.cert;
  3615. opts.ca = this.ca;
  3616. opts.ciphers = this.ciphers;
  3617. opts.rejectUnauthorized = this.rejectUnauthorized;
  3618. if (this.extraHeaders) {
  3619. opts.headers = this.extraHeaders;
  3620. }
  3621. if (this.localAddress) {
  3622. opts.localAddress = this.localAddress;
  3623. }
  3624. try {
  3625. this.ws = this.usingBrowserWebSocket ? new WebSocket(uri) : new WebSocket(uri, protocols, opts);
  3626. } catch (err) {
  3627. return this.emit('error', err);
  3628. }
  3629. if (this.ws.binaryType === undefined) {
  3630. this.supportsBinary = false;
  3631. }
  3632. if (this.ws.supports && this.ws.supports.binary) {
  3633. this.supportsBinary = true;
  3634. this.ws.binaryType = 'nodebuffer';
  3635. } else {
  3636. this.ws.binaryType = 'arraybuffer';
  3637. }
  3638. this.addEventListeners();
  3639. };
  3640. /**
  3641. * Adds event listeners to the socket
  3642. *
  3643. * @api private
  3644. */
  3645. WS.prototype.addEventListeners = function () {
  3646. var self = this;
  3647. this.ws.onopen = function () {
  3648. self.onOpen();
  3649. };
  3650. this.ws.onclose = function () {
  3651. self.onClose();
  3652. };
  3653. this.ws.onmessage = function (ev) {
  3654. self.onData(ev.data);
  3655. };
  3656. this.ws.onerror = function (e) {
  3657. self.onError('websocket error', e);
  3658. };
  3659. };
  3660. /**
  3661. * Writes data to socket.
  3662. *
  3663. * @param {Array} array of packets.
  3664. * @api private
  3665. */
  3666. WS.prototype.write = function (packets) {
  3667. var self = this;
  3668. this.writable = false;
  3669. // encodePacket efficient as it uses WS framing
  3670. // no need for encodePayload
  3671. var total = packets.length;
  3672. for (var i = 0, l = total; i < l; i++) {
  3673. (function (packet) {
  3674. parser.encodePacket(packet, self.supportsBinary, function (data) {
  3675. if (!self.usingBrowserWebSocket) {
  3676. // always create a new object (GH-437)
  3677. var opts = {};
  3678. if (packet.options) {
  3679. opts.compress = packet.options.compress;
  3680. }
  3681. if (self.perMessageDeflate) {
  3682. var len = 'string' === typeof data ? global.Buffer.byteLength(data) : data.length;
  3683. if (len < self.perMessageDeflate.threshold) {
  3684. opts.compress = false;
  3685. }
  3686. }
  3687. }
  3688. // Sometimes the websocket has already been closed but the browser didn't
  3689. // have a chance of informing us about it yet, in that case send will
  3690. // throw an error
  3691. try {
  3692. if (self.usingBrowserWebSocket) {
  3693. // TypeError is thrown when passing the second argument on Safari
  3694. self.ws.send(data);
  3695. } else {
  3696. self.ws.send(data, opts);
  3697. }
  3698. } catch (e) {
  3699. debug('websocket closed before onclose event');
  3700. }
  3701. --total || done();
  3702. });
  3703. })(packets[i]);
  3704. }
  3705. function done() {
  3706. self.emit('flush');
  3707. // fake drain
  3708. // defer to next tick to allow Socket to clear writeBuffer
  3709. setTimeout(function () {
  3710. self.writable = true;
  3711. self.emit('drain');
  3712. }, 0);
  3713. }
  3714. };
  3715. /**
  3716. * Called upon close
  3717. *
  3718. * @api private
  3719. */
  3720. WS.prototype.onClose = function () {
  3721. Transport.prototype.onClose.call(this);
  3722. };
  3723. /**
  3724. * Closes socket.
  3725. *
  3726. * @api private
  3727. */
  3728. WS.prototype.doClose = function () {
  3729. if (typeof this.ws !== 'undefined') {
  3730. this.ws.close();
  3731. }
  3732. };
  3733. /**
  3734. * Generates uri for connection.
  3735. *
  3736. * @api private
  3737. */
  3738. WS.prototype.uri = function () {
  3739. var query = this.query || {};
  3740. var schema = this.secure ? 'wss' : 'ws';
  3741. var port = '';
  3742. // avoid port if default for schema
  3743. if (this.port && ('wss' === schema && Number(this.port) !== 443 || 'ws' === schema && Number(this.port) !== 80)) {
  3744. port = ':' + this.port;
  3745. }
  3746. // append timestamp to URI
  3747. if (this.timestampRequests) {
  3748. query[this.timestampParam] = yeast();
  3749. }
  3750. // communicate binary support capabilities
  3751. if (!this.supportsBinary) {
  3752. query.b64 = 1;
  3753. }
  3754. query = parseqs.encode(query);
  3755. // prepend ? to query
  3756. if (query.length) {
  3757. query = '?' + query;
  3758. }
  3759. var ipv6 = this.hostname.indexOf(':') !== -1;
  3760. return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query;
  3761. };
  3762. /**
  3763. * Feature detection for WebSocket.
  3764. *
  3765. * @return {Boolean} whether this transport is available.
  3766. * @api public
  3767. */
  3768. WS.prototype.check = function () {
  3769. return !!WebSocket && !('__initialize' in WebSocket && this.name === WS.prototype.name);
  3770. };
  3771. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  3772. /***/ },
  3773. /* 29 */
  3774. /***/ function(module, exports) {
  3775. /* (ignored) */
  3776. /***/ },
  3777. /* 30 */
  3778. /***/ function(module, exports) {
  3779. var indexOf = [].indexOf;
  3780. module.exports = function(arr, obj){
  3781. if (indexOf) return arr.indexOf(obj);
  3782. for (var i = 0; i < arr.length; ++i) {
  3783. if (arr[i] === obj) return i;
  3784. }
  3785. return -1;
  3786. };
  3787. /***/ },
  3788. /* 31 */
  3789. /***/ function(module, exports) {
  3790. /**
  3791. * Parses an URI
  3792. *
  3793. * @author Steven Levithan <stevenlevithan.com> (MIT license)
  3794. * @api private
  3795. */
  3796. var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
  3797. var parts = [
  3798. 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'
  3799. ];
  3800. module.exports = function parseuri(str) {
  3801. var src = str,
  3802. b = str.indexOf('['),
  3803. e = str.indexOf(']');
  3804. if (b != -1 && e != -1) {
  3805. str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);
  3806. }
  3807. var m = re.exec(str || ''),
  3808. uri = {},
  3809. i = 14;
  3810. while (i--) {
  3811. uri[parts[i]] = m[i] || '';
  3812. }
  3813. if (b != -1 && e != -1) {
  3814. uri.source = src;
  3815. uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');
  3816. uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');
  3817. uri.ipv6uri = true;
  3818. }
  3819. return uri;
  3820. };
  3821. /***/ },
  3822. /* 32 */
  3823. /***/ function(module, exports) {
  3824. /* WEBPACK VAR INJECTION */(function(global) {/**
  3825. * JSON parse.
  3826. *
  3827. * @see Based on jQuery#parseJSON (MIT) and JSON2
  3828. * @api private
  3829. */
  3830. var rvalidchars = /^[\],:{}\s]*$/;
  3831. var rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g;
  3832. var rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
  3833. var rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g;
  3834. var rtrimLeft = /^\s+/;
  3835. var rtrimRight = /\s+$/;
  3836. module.exports = function parsejson(data) {
  3837. if ('string' != typeof data || !data) {
  3838. return null;
  3839. }
  3840. data = data.replace(rtrimLeft, '').replace(rtrimRight, '');
  3841. // Attempt to parse using the native JSON parser first
  3842. if (global.JSON && JSON.parse) {
  3843. return JSON.parse(data);
  3844. }
  3845. if (rvalidchars.test(data.replace(rvalidescape, '@')
  3846. .replace(rvalidtokens, ']')
  3847. .replace(rvalidbraces, ''))) {
  3848. return (new Function('return ' + data))();
  3849. }
  3850. };
  3851. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  3852. /***/ }
  3853. /******/ ])
  3854. });
  3855. ;