프로젝트

일반

사용자정보

통계
| 개정판:

root / HServer / 00.Server / 00.Program / node_modules / engine.io-client / engine.io.js

이력 | 보기 | 이력해설 | 다운로드 (110 KB)

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