socket.io-rails 1.0.6 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/socket.io-rails/version.rb +1 -1
- data/vendor/assets/javascripts/socket.io.js +784 -704
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acd50b944e9b106826449319a56e8abb42babc3b
|
4
|
+
data.tar.gz: 26707ba9d3f949a928d364cb149e1a6346132e59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86a259d2f72aab4a4f0b885edb4f55f5dc958e72610b67bd8371ea8f972ae23137b3b59a450464474b49dab34fd816072d36b9a2a421e8d9d75a7b39d67bf2d7
|
7
|
+
data.tar.gz: fb502bf4aeb5475bafa3e8ded80caf736c77a1a2731227a8150ffc162e728f6b376cd0951361f79bed58ba308aaf075f1367576c9c09f5772a1406914121907e
|
@@ -1,18 +1,17 @@
|
|
1
|
-
!function(e){"object"==typeof exports
|
2
|
-
return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
1
|
+
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.io=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
|
3
2
|
|
4
|
-
module.exports =
|
3
|
+
module.exports = _dereq_('./lib/');
|
5
4
|
|
6
|
-
},{"./lib/":2}],2:[function(
|
5
|
+
},{"./lib/":2}],2:[function(_dereq_,module,exports){
|
7
6
|
|
8
7
|
/**
|
9
8
|
* Module dependencies.
|
10
9
|
*/
|
11
10
|
|
12
|
-
var url =
|
13
|
-
var parser =
|
14
|
-
var Manager =
|
15
|
-
var debug =
|
11
|
+
var url = _dereq_('./url');
|
12
|
+
var parser = _dereq_('socket.io-parser');
|
13
|
+
var Manager = _dereq_('./manager');
|
14
|
+
var debug = _dereq_('debug')('socket.io-client');
|
16
15
|
|
17
16
|
/**
|
18
17
|
* Module exports.
|
@@ -89,24 +88,25 @@ exports.connect = lookup;
|
|
89
88
|
* @api public
|
90
89
|
*/
|
91
90
|
|
92
|
-
exports.Manager =
|
93
|
-
exports.Socket =
|
91
|
+
exports.Manager = _dereq_('./manager');
|
92
|
+
exports.Socket = _dereq_('./socket');
|
94
93
|
|
95
|
-
},{"./manager":3,"./socket":5,"./url":6,"debug":9,"socket.io-parser":40}],3:[function(
|
94
|
+
},{"./manager":3,"./socket":5,"./url":6,"debug":9,"socket.io-parser":40}],3:[function(_dereq_,module,exports){
|
96
95
|
|
97
96
|
/**
|
98
97
|
* Module dependencies.
|
99
98
|
*/
|
100
99
|
|
101
|
-
var url =
|
102
|
-
var eio =
|
103
|
-
var Socket =
|
104
|
-
var Emitter =
|
105
|
-
var parser =
|
106
|
-
var on =
|
107
|
-
var bind =
|
108
|
-
var object =
|
109
|
-
var debug =
|
100
|
+
var url = _dereq_('./url');
|
101
|
+
var eio = _dereq_('engine.io-client');
|
102
|
+
var Socket = _dereq_('./socket');
|
103
|
+
var Emitter = _dereq_('component-emitter');
|
104
|
+
var parser = _dereq_('socket.io-parser');
|
105
|
+
var on = _dereq_('./on');
|
106
|
+
var bind = _dereq_('component-bind');
|
107
|
+
var object = _dereq_('object-component');
|
108
|
+
var debug = _dereq_('debug')('socket.io-client:manager');
|
109
|
+
var indexOf = _dereq_('indexof');
|
110
110
|
|
111
111
|
/**
|
112
112
|
* Module exports
|
@@ -141,13 +141,14 @@ function Manager(uri, opts){
|
|
141
141
|
this.timeout(null == opts.timeout ? 20000 : opts.timeout);
|
142
142
|
this.readyState = 'closed';
|
143
143
|
this.uri = uri;
|
144
|
-
this.connected =
|
144
|
+
this.connected = [];
|
145
145
|
this.attempts = 0;
|
146
146
|
this.encoding = false;
|
147
147
|
this.packetBuffer = [];
|
148
148
|
this.encoder = new parser.Encoder();
|
149
149
|
this.decoder = new parser.Decoder();
|
150
|
-
this.
|
150
|
+
this.autoConnect = opts.autoConnect !== false;
|
151
|
+
if (this.autoConnect) this.open();
|
151
152
|
}
|
152
153
|
|
153
154
|
/**
|
@@ -246,7 +247,8 @@ Manager.prototype.timeout = function(v){
|
|
246
247
|
*/
|
247
248
|
|
248
249
|
Manager.prototype.maybeReconnectOnOpen = function() {
|
249
|
-
if
|
250
|
+
// Only try to reconnect if it's the first time we're connecting
|
251
|
+
if (!this.openReconnect && !this.reconnecting && this._reconnection && this.attempts === 0) {
|
250
252
|
// keeps reconnection from firing twice for the same reconnection loop
|
251
253
|
this.openReconnect = true;
|
252
254
|
this.reconnect();
|
@@ -272,6 +274,7 @@ Manager.prototype.connect = function(fn){
|
|
272
274
|
var socket = this.engine;
|
273
275
|
var self = this;
|
274
276
|
this.readyState = 'opening';
|
277
|
+
this.skipReconnect = false;
|
275
278
|
|
276
279
|
// emit `open`
|
277
280
|
var openSub = on(socket, 'open', function() {
|
@@ -390,7 +393,9 @@ Manager.prototype.socket = function(nsp){
|
|
390
393
|
this.nsps[nsp] = socket;
|
391
394
|
var self = this;
|
392
395
|
socket.on('connect', function(){
|
393
|
-
self.connected
|
396
|
+
if (!~indexOf(self.connected, socket)) {
|
397
|
+
self.connected.push(socket);
|
398
|
+
}
|
394
399
|
});
|
395
400
|
}
|
396
401
|
return socket;
|
@@ -403,7 +408,11 @@ Manager.prototype.socket = function(nsp){
|
|
403
408
|
*/
|
404
409
|
|
405
410
|
Manager.prototype.destroy = function(socket){
|
406
|
-
|
411
|
+
var index = indexOf(this.connected, socket);
|
412
|
+
if (~index) this.connected.splice(index, 1);
|
413
|
+
if (this.connected.length) return;
|
414
|
+
|
415
|
+
this.close();
|
407
416
|
};
|
408
417
|
|
409
418
|
/**
|
@@ -471,7 +480,8 @@ Manager.prototype.cleanup = function(){
|
|
471
480
|
Manager.prototype.close =
|
472
481
|
Manager.prototype.disconnect = function(){
|
473
482
|
this.skipReconnect = true;
|
474
|
-
this.
|
483
|
+
this.readyState = 'closed';
|
484
|
+
this.engine && this.engine.close();
|
475
485
|
};
|
476
486
|
|
477
487
|
/**
|
@@ -497,7 +507,7 @@ Manager.prototype.onclose = function(reason){
|
|
497
507
|
*/
|
498
508
|
|
499
509
|
Manager.prototype.reconnect = function(){
|
500
|
-
if (this.reconnecting) return this;
|
510
|
+
if (this.reconnecting || this.skipReconnect) return this;
|
501
511
|
|
502
512
|
var self = this;
|
503
513
|
this.attempts++;
|
@@ -513,9 +523,15 @@ Manager.prototype.reconnect = function(){
|
|
513
523
|
|
514
524
|
this.reconnecting = true;
|
515
525
|
var timer = setTimeout(function(){
|
526
|
+
if (self.skipReconnect) return;
|
527
|
+
|
516
528
|
debug('attempting reconnect');
|
517
529
|
self.emitAll('reconnect_attempt', self.attempts);
|
518
530
|
self.emitAll('reconnecting', self.attempts);
|
531
|
+
|
532
|
+
// check again for the case socket closed in above events
|
533
|
+
if (self.skipReconnect) return;
|
534
|
+
|
519
535
|
self.open(function(err){
|
520
536
|
if (err) {
|
521
537
|
debug('reconnect attempt error');
|
@@ -550,7 +566,7 @@ Manager.prototype.onreconnect = function(){
|
|
550
566
|
this.emitAll('reconnect', attempt);
|
551
567
|
};
|
552
568
|
|
553
|
-
},{"./on":4,"./socket":5,"./url":6,"component-bind":7,"component-emitter":8,"debug":9,"engine.io-client":
|
569
|
+
},{"./on":4,"./socket":5,"./url":6,"component-bind":7,"component-emitter":8,"debug":9,"engine.io-client":10,"indexof":36,"object-component":37,"socket.io-parser":40}],4:[function(_dereq_,module,exports){
|
554
570
|
|
555
571
|
/**
|
556
572
|
* Module exports.
|
@@ -576,20 +592,19 @@ function on(obj, ev, fn) {
|
|
576
592
|
};
|
577
593
|
}
|
578
594
|
|
579
|
-
},{}],5:[function(
|
595
|
+
},{}],5:[function(_dereq_,module,exports){
|
580
596
|
|
581
597
|
/**
|
582
598
|
* Module dependencies.
|
583
599
|
*/
|
584
600
|
|
585
|
-
var parser =
|
586
|
-
var Emitter =
|
587
|
-
var toArray =
|
588
|
-
var on =
|
589
|
-
var bind =
|
590
|
-
var debug =
|
591
|
-
var hasBin =
|
592
|
-
var indexOf = require('indexof');
|
601
|
+
var parser = _dereq_('socket.io-parser');
|
602
|
+
var Emitter = _dereq_('component-emitter');
|
603
|
+
var toArray = _dereq_('to-array');
|
604
|
+
var on = _dereq_('./on');
|
605
|
+
var bind = _dereq_('component-bind');
|
606
|
+
var debug = _dereq_('debug')('socket.io-client:socket');
|
607
|
+
var hasBin = _dereq_('has-binary');
|
593
608
|
|
594
609
|
/**
|
595
610
|
* Module exports.
|
@@ -635,12 +650,11 @@ function Socket(io, nsp){
|
|
635
650
|
this.json = this; // compat
|
636
651
|
this.ids = 0;
|
637
652
|
this.acks = {};
|
638
|
-
this.open();
|
653
|
+
if (this.io.autoConnect) this.open();
|
639
654
|
this.receiveBuffer = [];
|
640
655
|
this.sendBuffer = [];
|
641
656
|
this.connected = false;
|
642
657
|
this.disconnected = true;
|
643
|
-
this.subEvents();
|
644
658
|
}
|
645
659
|
|
646
660
|
/**
|
@@ -656,6 +670,8 @@ Emitter(Socket.prototype);
|
|
656
670
|
*/
|
657
671
|
|
658
672
|
Socket.prototype.subEvents = function() {
|
673
|
+
if (this.subs) return;
|
674
|
+
|
659
675
|
var io = this.io;
|
660
676
|
this.subs = [
|
661
677
|
on(io, 'open', bind(this, 'onopen')),
|
@@ -665,15 +681,16 @@ Socket.prototype.subEvents = function() {
|
|
665
681
|
};
|
666
682
|
|
667
683
|
/**
|
668
|
-
*
|
684
|
+
* "Opens" the socket.
|
669
685
|
*
|
670
|
-
* @api
|
686
|
+
* @api public
|
671
687
|
*/
|
672
688
|
|
673
689
|
Socket.prototype.open =
|
674
690
|
Socket.prototype.connect = function(){
|
675
691
|
if (this.connected) return this;
|
676
692
|
|
693
|
+
this.subEvents();
|
677
694
|
this.io.open(); // ensure open
|
678
695
|
if ('open' == this.io.readyState) this.onopen();
|
679
696
|
return this;
|
@@ -742,7 +759,7 @@ Socket.prototype.packet = function(packet){
|
|
742
759
|
};
|
743
760
|
|
744
761
|
/**
|
745
|
-
*
|
762
|
+
* Called upon engine `open`.
|
746
763
|
*
|
747
764
|
* @api private
|
748
765
|
*/
|
@@ -926,9 +943,12 @@ Socket.prototype.ondisconnect = function(){
|
|
926
943
|
*/
|
927
944
|
|
928
945
|
Socket.prototype.destroy = function(){
|
929
|
-
|
930
|
-
|
931
|
-
this.subs
|
946
|
+
if (this.subs) {
|
947
|
+
// clean subscriptions to avoid reconnections
|
948
|
+
for (var i = 0; i < this.subs.length; i++) {
|
949
|
+
this.subs[i].destroy();
|
950
|
+
}
|
951
|
+
this.subs = null;
|
932
952
|
}
|
933
953
|
|
934
954
|
this.io.destroy(this);
|
@@ -943,27 +963,30 @@ Socket.prototype.destroy = function(){
|
|
943
963
|
|
944
964
|
Socket.prototype.close =
|
945
965
|
Socket.prototype.disconnect = function(){
|
946
|
-
if (
|
947
|
-
|
948
|
-
|
949
|
-
|
966
|
+
if (this.connected) {
|
967
|
+
debug('performing disconnect (%s)', this.nsp);
|
968
|
+
this.packet({ type: parser.DISCONNECT });
|
969
|
+
}
|
950
970
|
|
951
971
|
// remove socket from pool
|
952
972
|
this.destroy();
|
953
973
|
|
954
|
-
|
955
|
-
|
974
|
+
if (this.connected) {
|
975
|
+
// fire events
|
976
|
+
this.onclose('io client disconnect');
|
977
|
+
}
|
956
978
|
return this;
|
957
979
|
};
|
958
980
|
|
959
|
-
},{"./on":4,"component-bind":7,"component-emitter":8,"debug":9,"has-binary
|
960
|
-
|
981
|
+
},{"./on":4,"component-bind":7,"component-emitter":8,"debug":9,"has-binary":32,"socket.io-parser":40,"to-array":44}],6:[function(_dereq_,module,exports){
|
982
|
+
(function (global){
|
983
|
+
|
961
984
|
/**
|
962
985
|
* Module dependencies.
|
963
986
|
*/
|
964
987
|
|
965
|
-
var parseuri =
|
966
|
-
var debug =
|
988
|
+
var parseuri = _dereq_('parseuri');
|
989
|
+
var debug = _dereq_('debug')('socket.io-client:url');
|
967
990
|
|
968
991
|
/**
|
969
992
|
* Module exports.
|
@@ -990,7 +1013,9 @@ function url(uri, loc){
|
|
990
1013
|
// relative path support
|
991
1014
|
if ('string' == typeof uri) {
|
992
1015
|
if ('/' == uri.charAt(0)) {
|
993
|
-
if ('
|
1016
|
+
if ('/' == uri.charAt(1)) {
|
1017
|
+
uri = loc.protocol + uri;
|
1018
|
+
} else {
|
994
1019
|
uri = loc.hostname + uri;
|
995
1020
|
}
|
996
1021
|
}
|
@@ -1029,7 +1054,8 @@ function url(uri, loc){
|
|
1029
1054
|
return obj;
|
1030
1055
|
}
|
1031
1056
|
|
1032
|
-
},
|
1057
|
+
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
1058
|
+
},{"debug":9,"parseuri":38}],7:[function(_dereq_,module,exports){
|
1033
1059
|
/**
|
1034
1060
|
* Slice reference.
|
1035
1061
|
*/
|
@@ -1054,7 +1080,7 @@ module.exports = function(obj, fn){
|
|
1054
1080
|
}
|
1055
1081
|
};
|
1056
1082
|
|
1057
|
-
},{}],8:[function(
|
1083
|
+
},{}],8:[function(_dereq_,module,exports){
|
1058
1084
|
|
1059
1085
|
/**
|
1060
1086
|
* Expose `Emitter`.
|
@@ -1220,7 +1246,7 @@ Emitter.prototype.hasListeners = function(event){
|
|
1220
1246
|
return !! this.listeners(event).length;
|
1221
1247
|
};
|
1222
1248
|
|
1223
|
-
},{}],9:[function(
|
1249
|
+
},{}],9:[function(_dereq_,module,exports){
|
1224
1250
|
|
1225
1251
|
/**
|
1226
1252
|
* Expose `debug()` as the module.
|
@@ -1359,177 +1385,13 @@ try {
|
|
1359
1385
|
if (window.localStorage) debug.enable(localStorage.debug);
|
1360
1386
|
} catch(e){}
|
1361
1387
|
|
1362
|
-
},{}],10:[function(
|
1363
|
-
|
1364
|
-
/**
|
1365
|
-
* Module dependencies.
|
1366
|
-
*/
|
1367
|
-
|
1368
|
-
var index = require('indexof');
|
1369
|
-
|
1370
|
-
/**
|
1371
|
-
* Expose `Emitter`.
|
1372
|
-
*/
|
1373
|
-
|
1374
|
-
module.exports = Emitter;
|
1375
|
-
|
1376
|
-
/**
|
1377
|
-
* Initialize a new `Emitter`.
|
1378
|
-
*
|
1379
|
-
* @api public
|
1380
|
-
*/
|
1381
|
-
|
1382
|
-
function Emitter(obj) {
|
1383
|
-
if (obj) return mixin(obj);
|
1384
|
-
};
|
1385
|
-
|
1386
|
-
/**
|
1387
|
-
* Mixin the emitter properties.
|
1388
|
-
*
|
1389
|
-
* @param {Object} obj
|
1390
|
-
* @return {Object}
|
1391
|
-
* @api private
|
1392
|
-
*/
|
1393
|
-
|
1394
|
-
function mixin(obj) {
|
1395
|
-
for (var key in Emitter.prototype) {
|
1396
|
-
obj[key] = Emitter.prototype[key];
|
1397
|
-
}
|
1398
|
-
return obj;
|
1399
|
-
}
|
1400
|
-
|
1401
|
-
/**
|
1402
|
-
* Listen on the given `event` with `fn`.
|
1403
|
-
*
|
1404
|
-
* @param {String} event
|
1405
|
-
* @param {Function} fn
|
1406
|
-
* @return {Emitter}
|
1407
|
-
* @api public
|
1408
|
-
*/
|
1409
|
-
|
1410
|
-
Emitter.prototype.on = function(event, fn){
|
1411
|
-
this._callbacks = this._callbacks || {};
|
1412
|
-
(this._callbacks[event] = this._callbacks[event] || [])
|
1413
|
-
.push(fn);
|
1414
|
-
return this;
|
1415
|
-
};
|
1416
|
-
|
1417
|
-
/**
|
1418
|
-
* Adds an `event` listener that will be invoked a single
|
1419
|
-
* time then automatically removed.
|
1420
|
-
*
|
1421
|
-
* @param {String} event
|
1422
|
-
* @param {Function} fn
|
1423
|
-
* @return {Emitter}
|
1424
|
-
* @api public
|
1425
|
-
*/
|
1388
|
+
},{}],10:[function(_dereq_,module,exports){
|
1426
1389
|
|
1427
|
-
|
1428
|
-
var self = this;
|
1429
|
-
this._callbacks = this._callbacks || {};
|
1390
|
+
module.exports = _dereq_('./lib/');
|
1430
1391
|
|
1431
|
-
|
1432
|
-
self.off(event, on);
|
1433
|
-
fn.apply(this, arguments);
|
1434
|
-
}
|
1392
|
+
},{"./lib/":11}],11:[function(_dereq_,module,exports){
|
1435
1393
|
|
1436
|
-
|
1437
|
-
this.on(event, on);
|
1438
|
-
return this;
|
1439
|
-
};
|
1440
|
-
|
1441
|
-
/**
|
1442
|
-
* Remove the given callback for `event` or all
|
1443
|
-
* registered callbacks.
|
1444
|
-
*
|
1445
|
-
* @param {String} event
|
1446
|
-
* @param {Function} fn
|
1447
|
-
* @return {Emitter}
|
1448
|
-
* @api public
|
1449
|
-
*/
|
1450
|
-
|
1451
|
-
Emitter.prototype.off =
|
1452
|
-
Emitter.prototype.removeListener =
|
1453
|
-
Emitter.prototype.removeAllListeners = function(event, fn){
|
1454
|
-
this._callbacks = this._callbacks || {};
|
1455
|
-
|
1456
|
-
// all
|
1457
|
-
if (0 == arguments.length) {
|
1458
|
-
this._callbacks = {};
|
1459
|
-
return this;
|
1460
|
-
}
|
1461
|
-
|
1462
|
-
// specific event
|
1463
|
-
var callbacks = this._callbacks[event];
|
1464
|
-
if (!callbacks) return this;
|
1465
|
-
|
1466
|
-
// remove all handlers
|
1467
|
-
if (1 == arguments.length) {
|
1468
|
-
delete this._callbacks[event];
|
1469
|
-
return this;
|
1470
|
-
}
|
1471
|
-
|
1472
|
-
// remove specific handler
|
1473
|
-
var i = index(callbacks, fn._off || fn);
|
1474
|
-
if (~i) callbacks.splice(i, 1);
|
1475
|
-
return this;
|
1476
|
-
};
|
1477
|
-
|
1478
|
-
/**
|
1479
|
-
* Emit `event` with the given args.
|
1480
|
-
*
|
1481
|
-
* @param {String} event
|
1482
|
-
* @param {Mixed} ...
|
1483
|
-
* @return {Emitter}
|
1484
|
-
*/
|
1485
|
-
|
1486
|
-
Emitter.prototype.emit = function(event){
|
1487
|
-
this._callbacks = this._callbacks || {};
|
1488
|
-
var args = [].slice.call(arguments, 1)
|
1489
|
-
, callbacks = this._callbacks[event];
|
1490
|
-
|
1491
|
-
if (callbacks) {
|
1492
|
-
callbacks = callbacks.slice(0);
|
1493
|
-
for (var i = 0, len = callbacks.length; i < len; ++i) {
|
1494
|
-
callbacks[i].apply(this, args);
|
1495
|
-
}
|
1496
|
-
}
|
1497
|
-
|
1498
|
-
return this;
|
1499
|
-
};
|
1500
|
-
|
1501
|
-
/**
|
1502
|
-
* Return array of callbacks for `event`.
|
1503
|
-
*
|
1504
|
-
* @param {String} event
|
1505
|
-
* @return {Array}
|
1506
|
-
* @api public
|
1507
|
-
*/
|
1508
|
-
|
1509
|
-
Emitter.prototype.listeners = function(event){
|
1510
|
-
this._callbacks = this._callbacks || {};
|
1511
|
-
return this._callbacks[event] || [];
|
1512
|
-
};
|
1513
|
-
|
1514
|
-
/**
|
1515
|
-
* Check if this emitter has `event` handlers.
|
1516
|
-
*
|
1517
|
-
* @param {String} event
|
1518
|
-
* @return {Boolean}
|
1519
|
-
* @api public
|
1520
|
-
*/
|
1521
|
-
|
1522
|
-
Emitter.prototype.hasListeners = function(event){
|
1523
|
-
return !! this.listeners(event).length;
|
1524
|
-
};
|
1525
|
-
|
1526
|
-
},{"indexof":36}],11:[function(require,module,exports){
|
1527
|
-
|
1528
|
-
module.exports = require('./lib/');
|
1529
|
-
|
1530
|
-
},{"./lib/":12}],12:[function(require,module,exports){
|
1531
|
-
|
1532
|
-
module.exports = require('./socket');
|
1394
|
+
module.exports = _dereq_('./socket');
|
1533
1395
|
|
1534
1396
|
/**
|
1535
1397
|
* Exports parser
|
@@ -1537,21 +1399,22 @@ module.exports = require('./socket');
|
|
1537
1399
|
* @api public
|
1538
1400
|
*
|
1539
1401
|
*/
|
1540
|
-
module.exports.parser =
|
1402
|
+
module.exports.parser = _dereq_('engine.io-parser');
|
1541
1403
|
|
1542
|
-
},{"./socket":
|
1543
|
-
|
1404
|
+
},{"./socket":12,"engine.io-parser":21}],12:[function(_dereq_,module,exports){
|
1405
|
+
(function (global){
|
1406
|
+
/**
|
1544
1407
|
* Module dependencies.
|
1545
1408
|
*/
|
1546
1409
|
|
1547
|
-
var transports =
|
1548
|
-
var Emitter =
|
1549
|
-
var debug =
|
1550
|
-
var index =
|
1551
|
-
var parser =
|
1552
|
-
var parseuri =
|
1553
|
-
var parsejson =
|
1554
|
-
var parseqs =
|
1410
|
+
var transports = _dereq_('./transports');
|
1411
|
+
var Emitter = _dereq_('component-emitter');
|
1412
|
+
var debug = _dereq_('debug')('engine.io-client:socket');
|
1413
|
+
var index = _dereq_('indexof');
|
1414
|
+
var parser = _dereq_('engine.io-parser');
|
1415
|
+
var parseuri = _dereq_('parseuri');
|
1416
|
+
var parsejson = _dereq_('parsejson');
|
1417
|
+
var parseqs = _dereq_('parseqs');
|
1555
1418
|
|
1556
1419
|
/**
|
1557
1420
|
* Module exports.
|
@@ -1613,7 +1476,9 @@ function Socket(uri, opts){
|
|
1613
1476
|
this.upgrade = false !== opts.upgrade;
|
1614
1477
|
this.path = (opts.path || '/engine.io').replace(/\/$/, '') + '/';
|
1615
1478
|
this.forceJSONP = !!opts.forceJSONP;
|
1479
|
+
this.jsonp = false !== opts.jsonp;
|
1616
1480
|
this.forceBase64 = !!opts.forceBase64;
|
1481
|
+
this.enablesXDR = !!opts.enablesXDR;
|
1617
1482
|
this.timestampParam = opts.timestampParam || 't';
|
1618
1483
|
this.timestampRequests = opts.timestampRequests;
|
1619
1484
|
this.transports = opts.transports || ['polling', 'websocket'];
|
@@ -1649,9 +1514,9 @@ Socket.protocol = parser.protocol; // this is an int
|
|
1649
1514
|
*/
|
1650
1515
|
|
1651
1516
|
Socket.Socket = Socket;
|
1652
|
-
Socket.Transport =
|
1653
|
-
Socket.transports =
|
1654
|
-
Socket.parser =
|
1517
|
+
Socket.Transport = _dereq_('./transport');
|
1518
|
+
Socket.transports = _dereq_('./transports');
|
1519
|
+
Socket.parser = _dereq_('engine.io-parser');
|
1655
1520
|
|
1656
1521
|
/**
|
1657
1522
|
* Creates transport of the given type.
|
@@ -1682,7 +1547,9 @@ Socket.prototype.createTransport = function (name) {
|
|
1682
1547
|
path: this.path,
|
1683
1548
|
query: query,
|
1684
1549
|
forceJSONP: this.forceJSONP,
|
1550
|
+
jsonp: this.jsonp,
|
1685
1551
|
forceBase64: this.forceBase64,
|
1552
|
+
enablesXDR: this.enablesXDR,
|
1686
1553
|
timestampRequests: this.timestampRequests,
|
1687
1554
|
timestampParam: this.timestampParam,
|
1688
1555
|
policyPort: this.policyPort,
|
@@ -1711,11 +1578,28 @@ Socket.prototype.open = function () {
|
|
1711
1578
|
var transport;
|
1712
1579
|
if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') != -1) {
|
1713
1580
|
transport = 'websocket';
|
1581
|
+
} else if (0 == this.transports.length) {
|
1582
|
+
// Emit error on next tick so it can be listened to
|
1583
|
+
var self = this;
|
1584
|
+
setTimeout(function() {
|
1585
|
+
self.emit('error', 'No transports available');
|
1586
|
+
}, 0);
|
1587
|
+
return;
|
1714
1588
|
} else {
|
1715
1589
|
transport = this.transports[0];
|
1716
1590
|
}
|
1717
1591
|
this.readyState = 'opening';
|
1718
|
-
|
1592
|
+
|
1593
|
+
// Retry with the next transport if the transport is disabled (jsonp: false)
|
1594
|
+
var transport;
|
1595
|
+
try {
|
1596
|
+
transport = this.createTransport(transport);
|
1597
|
+
} catch (e) {
|
1598
|
+
this.transports.shift();
|
1599
|
+
this.open();
|
1600
|
+
return;
|
1601
|
+
}
|
1602
|
+
|
1719
1603
|
transport.open();
|
1720
1604
|
this.setTransport(transport);
|
1721
1605
|
};
|
@@ -1784,14 +1668,13 @@ Socket.prototype.probe = function (name) {
|
|
1784
1668
|
debug('probe transport "%s" pong', name);
|
1785
1669
|
self.upgrading = true;
|
1786
1670
|
self.emit('upgrading', transport);
|
1671
|
+
if (!transport) return;
|
1787
1672
|
Socket.priorWebsocketSuccess = 'websocket' == transport.name;
|
1788
1673
|
|
1789
1674
|
debug('pausing current transport "%s"', self.transport.name);
|
1790
1675
|
self.transport.pause(function () {
|
1791
1676
|
if (failed) return;
|
1792
|
-
if ('closed' == self.readyState
|
1793
|
-
return;
|
1794
|
-
}
|
1677
|
+
if ('closed' == self.readyState) return;
|
1795
1678
|
debug('changing transport and sending upgrade packet');
|
1796
1679
|
|
1797
1680
|
cleanup();
|
@@ -2073,6 +1956,10 @@ Socket.prototype.send = function (msg, fn) {
|
|
2073
1956
|
*/
|
2074
1957
|
|
2075
1958
|
Socket.prototype.sendPacket = function (type, data, fn) {
|
1959
|
+
if ('closing' == this.readyState || 'closed' == this.readyState) {
|
1960
|
+
return;
|
1961
|
+
}
|
1962
|
+
|
2076
1963
|
var packet = { type: type, data: data };
|
2077
1964
|
this.emit('packetCreate', packet);
|
2078
1965
|
this.writeBuffer.push(packet);
|
@@ -2088,9 +1975,41 @@ Socket.prototype.sendPacket = function (type, data, fn) {
|
|
2088
1975
|
|
2089
1976
|
Socket.prototype.close = function () {
|
2090
1977
|
if ('opening' == this.readyState || 'open' == this.readyState) {
|
2091
|
-
this.
|
2092
|
-
|
2093
|
-
this
|
1978
|
+
this.readyState = 'closing';
|
1979
|
+
|
1980
|
+
var self = this;
|
1981
|
+
|
1982
|
+
function close() {
|
1983
|
+
self.onClose('forced close');
|
1984
|
+
debug('socket closing - telling transport to close');
|
1985
|
+
self.transport.close();
|
1986
|
+
}
|
1987
|
+
|
1988
|
+
function cleanupAndClose() {
|
1989
|
+
self.removeListener('upgrade', cleanupAndClose);
|
1990
|
+
self.removeListener('upgradeError', cleanupAndClose);
|
1991
|
+
close();
|
1992
|
+
}
|
1993
|
+
|
1994
|
+
function waitForUpgrade() {
|
1995
|
+
// wait for upgrade to finish since we can't send packets while pausing a transport
|
1996
|
+
self.once('upgrade', cleanupAndClose);
|
1997
|
+
self.once('upgradeError', cleanupAndClose);
|
1998
|
+
}
|
1999
|
+
|
2000
|
+
if (this.writeBuffer.length) {
|
2001
|
+
this.once('drain', function() {
|
2002
|
+
if (this.upgrading) {
|
2003
|
+
waitForUpgrade();
|
2004
|
+
} else {
|
2005
|
+
close();
|
2006
|
+
}
|
2007
|
+
});
|
2008
|
+
} else if (this.upgrading) {
|
2009
|
+
waitForUpgrade();
|
2010
|
+
} else {
|
2011
|
+
close();
|
2012
|
+
}
|
2094
2013
|
}
|
2095
2014
|
|
2096
2015
|
return this;
|
@@ -2116,7 +2035,7 @@ Socket.prototype.onError = function (err) {
|
|
2116
2035
|
*/
|
2117
2036
|
|
2118
2037
|
Socket.prototype.onClose = function (reason, desc) {
|
2119
|
-
if ('opening' == this.readyState || 'open' == this.readyState) {
|
2038
|
+
if ('opening' == this.readyState || 'open' == this.readyState || 'closing' == this.readyState) {
|
2120
2039
|
debug('socket close with reason: "%s"', reason);
|
2121
2040
|
var self = this;
|
2122
2041
|
|
@@ -2168,13 +2087,14 @@ Socket.prototype.filterUpgrades = function (upgrades) {
|
|
2168
2087
|
return filteredUpgrades;
|
2169
2088
|
};
|
2170
2089
|
|
2171
|
-
}
|
2090
|
+
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
2091
|
+
},{"./transport":13,"./transports":14,"component-emitter":8,"debug":9,"engine.io-parser":21,"indexof":36,"parsejson":28,"parseqs":29,"parseuri":30}],13:[function(_dereq_,module,exports){
|
2172
2092
|
/**
|
2173
2093
|
* Module dependencies.
|
2174
2094
|
*/
|
2175
2095
|
|
2176
|
-
var parser =
|
2177
|
-
var Emitter =
|
2096
|
+
var parser = _dereq_('engine.io-parser');
|
2097
|
+
var Emitter = _dereq_('component-emitter');
|
2178
2098
|
|
2179
2099
|
/**
|
2180
2100
|
* Module exports.
|
@@ -2200,6 +2120,7 @@ function Transport (opts) {
|
|
2200
2120
|
this.readyState = '';
|
2201
2121
|
this.agent = opts.agent || false;
|
2202
2122
|
this.socket = opts.socket;
|
2123
|
+
this.enablesXDR = opts.enablesXDR;
|
2203
2124
|
}
|
2204
2125
|
|
2205
2126
|
/**
|
@@ -2296,13 +2217,8 @@ Transport.prototype.onOpen = function () {
|
|
2296
2217
|
*/
|
2297
2218
|
|
2298
2219
|
Transport.prototype.onData = function(data){
|
2299
|
-
|
2300
|
-
|
2301
|
-
this.onPacket(packet);
|
2302
|
-
} catch(e){
|
2303
|
-
e.data = data;
|
2304
|
-
this.onError('parser decode error', e);
|
2305
|
-
}
|
2220
|
+
var packet = parser.decodePacket(data, this.socket.binaryType);
|
2221
|
+
this.onPacket(packet);
|
2306
2222
|
};
|
2307
2223
|
|
2308
2224
|
/**
|
@@ -2324,15 +2240,16 @@ Transport.prototype.onClose = function () {
|
|
2324
2240
|
this.emit('close');
|
2325
2241
|
};
|
2326
2242
|
|
2327
|
-
},{"component-emitter":8,"engine.io-parser":
|
2328
|
-
|
2243
|
+
},{"component-emitter":8,"engine.io-parser":21}],14:[function(_dereq_,module,exports){
|
2244
|
+
(function (global){
|
2245
|
+
/**
|
2329
2246
|
* Module dependencies
|
2330
2247
|
*/
|
2331
2248
|
|
2332
|
-
var XMLHttpRequest =
|
2333
|
-
var XHR =
|
2334
|
-
var JSONP =
|
2335
|
-
var websocket =
|
2249
|
+
var XMLHttpRequest = _dereq_('xmlhttprequest');
|
2250
|
+
var XHR = _dereq_('./polling-xhr');
|
2251
|
+
var JSONP = _dereq_('./polling-jsonp');
|
2252
|
+
var websocket = _dereq_('./websocket');
|
2336
2253
|
|
2337
2254
|
/**
|
2338
2255
|
* Export transports.
|
@@ -2351,6 +2268,8 @@ exports.websocket = websocket;
|
|
2351
2268
|
function polling(opts){
|
2352
2269
|
var xhr;
|
2353
2270
|
var xd = false;
|
2271
|
+
var xs = false;
|
2272
|
+
var jsonp = false !== opts.jsonp;
|
2354
2273
|
|
2355
2274
|
if (global.location) {
|
2356
2275
|
var isSSL = 'https:' == location.protocol;
|
@@ -2362,26 +2281,31 @@ function polling(opts){
|
|
2362
2281
|
}
|
2363
2282
|
|
2364
2283
|
xd = opts.hostname != location.hostname || port != opts.port;
|
2284
|
+
xs = opts.secure != isSSL;
|
2365
2285
|
}
|
2366
2286
|
|
2367
2287
|
opts.xdomain = xd;
|
2288
|
+
opts.xscheme = xs;
|
2368
2289
|
xhr = new XMLHttpRequest(opts);
|
2369
2290
|
|
2370
2291
|
if ('open' in xhr && !opts.forceJSONP) {
|
2371
2292
|
return new XHR(opts);
|
2372
2293
|
} else {
|
2294
|
+
if (!jsonp) throw new Error('JSONP disabled');
|
2373
2295
|
return new JSONP(opts);
|
2374
2296
|
}
|
2375
2297
|
}
|
2376
2298
|
|
2377
|
-
},
|
2378
|
-
|
2299
|
+
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
2300
|
+
},{"./polling-jsonp":15,"./polling-xhr":16,"./websocket":18,"xmlhttprequest":19}],15:[function(_dereq_,module,exports){
|
2301
|
+
(function (global){
|
2302
|
+
|
2379
2303
|
/**
|
2380
2304
|
* Module requirements.
|
2381
2305
|
*/
|
2382
2306
|
|
2383
|
-
var Polling =
|
2384
|
-
var inherit =
|
2307
|
+
var Polling = _dereq_('./polling');
|
2308
|
+
var inherit = _dereq_('component-inherit');
|
2385
2309
|
|
2386
2310
|
/**
|
2387
2311
|
* Module exports.
|
@@ -2481,6 +2405,7 @@ JSONPPolling.prototype.doClose = function () {
|
|
2481
2405
|
if (this.form) {
|
2482
2406
|
this.form.parentNode.removeChild(this.form);
|
2483
2407
|
this.form = null;
|
2408
|
+
this.iframe = null;
|
2484
2409
|
}
|
2485
2410
|
|
2486
2411
|
Polling.prototype.doClose.call(this);
|
@@ -2512,7 +2437,7 @@ JSONPPolling.prototype.doPoll = function () {
|
|
2512
2437
|
this.script = script;
|
2513
2438
|
|
2514
2439
|
var isUAgecko = 'undefined' != typeof navigator && /gecko/i.test(navigator.userAgent);
|
2515
|
-
|
2440
|
+
|
2516
2441
|
if (isUAgecko) {
|
2517
2442
|
setTimeout(function () {
|
2518
2443
|
var iframe = document.createElement('iframe');
|
@@ -2608,16 +2533,18 @@ JSONPPolling.prototype.doWrite = function (data, fn) {
|
|
2608
2533
|
}
|
2609
2534
|
};
|
2610
2535
|
|
2611
|
-
},
|
2612
|
-
|
2536
|
+
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
2537
|
+
},{"./polling":17,"component-inherit":20}],16:[function(_dereq_,module,exports){
|
2538
|
+
(function (global){
|
2539
|
+
/**
|
2613
2540
|
* Module requirements.
|
2614
2541
|
*/
|
2615
2542
|
|
2616
|
-
var XMLHttpRequest =
|
2617
|
-
var Polling =
|
2618
|
-
var Emitter =
|
2619
|
-
var inherit =
|
2620
|
-
var debug =
|
2543
|
+
var XMLHttpRequest = _dereq_('xmlhttprequest');
|
2544
|
+
var Polling = _dereq_('./polling');
|
2545
|
+
var Emitter = _dereq_('component-emitter');
|
2546
|
+
var inherit = _dereq_('component-inherit');
|
2547
|
+
var debug = _dereq_('debug')('engine.io-client:polling-xhr');
|
2621
2548
|
|
2622
2549
|
/**
|
2623
2550
|
* Module exports.
|
@@ -2653,6 +2580,7 @@ function XHR(opts){
|
|
2653
2580
|
|
2654
2581
|
this.xd = opts.hostname != global.location.hostname ||
|
2655
2582
|
port != opts.port;
|
2583
|
+
this.xs = opts.secure != isSSL;
|
2656
2584
|
}
|
2657
2585
|
}
|
2658
2586
|
|
@@ -2679,8 +2607,10 @@ XHR.prototype.request = function(opts){
|
|
2679
2607
|
opts = opts || {};
|
2680
2608
|
opts.uri = this.uri();
|
2681
2609
|
opts.xd = this.xd;
|
2610
|
+
opts.xs = this.xs;
|
2682
2611
|
opts.agent = this.agent || false;
|
2683
2612
|
opts.supportsBinary = this.supportsBinary;
|
2613
|
+
opts.enablesXDR = this.enablesXDR;
|
2684
2614
|
return new Request(opts);
|
2685
2615
|
};
|
2686
2616
|
|
@@ -2733,10 +2663,14 @@ function Request(opts){
|
|
2733
2663
|
this.method = opts.method || 'GET';
|
2734
2664
|
this.uri = opts.uri;
|
2735
2665
|
this.xd = !!opts.xd;
|
2666
|
+
this.xs = !!opts.xs;
|
2736
2667
|
this.async = false !== opts.async;
|
2737
2668
|
this.data = undefined != opts.data ? opts.data : null;
|
2738
2669
|
this.agent = opts.agent;
|
2739
|
-
this.
|
2670
|
+
this.isBinary = opts.isBinary;
|
2671
|
+
this.supportsBinary = opts.supportsBinary;
|
2672
|
+
this.enablesXDR = opts.enablesXDR;
|
2673
|
+
this.create();
|
2740
2674
|
}
|
2741
2675
|
|
2742
2676
|
/**
|
@@ -2751,14 +2685,14 @@ Emitter(Request.prototype);
|
|
2751
2685
|
* @api private
|
2752
2686
|
*/
|
2753
2687
|
|
2754
|
-
Request.prototype.create = function(
|
2755
|
-
var xhr = this.xhr = new XMLHttpRequest({ agent: this.agent, xdomain: this.xd });
|
2688
|
+
Request.prototype.create = function(){
|
2689
|
+
var xhr = this.xhr = new XMLHttpRequest({ agent: this.agent, xdomain: this.xd, xscheme: this.xs, enablesXDR: this.enablesXDR });
|
2756
2690
|
var self = this;
|
2757
2691
|
|
2758
2692
|
try {
|
2759
2693
|
debug('xhr open %s: %s', this.method, this.uri);
|
2760
2694
|
xhr.open(this.method, this.uri, this.async);
|
2761
|
-
if (supportsBinary) {
|
2695
|
+
if (this.supportsBinary) {
|
2762
2696
|
// This has to be done after open because Firefox is stupid
|
2763
2697
|
// http://stackoverflow.com/questions/13216903/get-binary-data-with-xmlhttprequest-in-a-firefox-extension
|
2764
2698
|
xhr.responseType = 'arraybuffer';
|
@@ -2766,7 +2700,7 @@ Request.prototype.create = function(isBinary, supportsBinary){
|
|
2766
2700
|
|
2767
2701
|
if ('POST' == this.method) {
|
2768
2702
|
try {
|
2769
|
-
if (isBinary) {
|
2703
|
+
if (this.isBinary) {
|
2770
2704
|
xhr.setRequestHeader('Content-type', 'application/octet-stream');
|
2771
2705
|
} else {
|
2772
2706
|
xhr.setRequestHeader('Content-type', 'text/plain;charset=UTF-8');
|
@@ -2779,22 +2713,18 @@ Request.prototype.create = function(isBinary, supportsBinary){
|
|
2779
2713
|
xhr.withCredentials = true;
|
2780
2714
|
}
|
2781
2715
|
|
2782
|
-
|
2783
|
-
|
2784
|
-
|
2785
|
-
|
2716
|
+
if (this.hasXDR()) {
|
2717
|
+
xhr.onload = function(){
|
2718
|
+
self.onLoad();
|
2719
|
+
};
|
2720
|
+
xhr.onerror = function(){
|
2721
|
+
self.onError(xhr.responseText);
|
2722
|
+
};
|
2723
|
+
} else {
|
2724
|
+
xhr.onreadystatechange = function(){
|
2786
2725
|
if (4 != xhr.readyState) return;
|
2787
2726
|
if (200 == xhr.status || 1223 == xhr.status) {
|
2788
|
-
|
2789
|
-
if (contentType === 'application/octet-stream') {
|
2790
|
-
data = xhr.response;
|
2791
|
-
} else {
|
2792
|
-
if (!supportsBinary) {
|
2793
|
-
data = xhr.responseText;
|
2794
|
-
} else {
|
2795
|
-
data = 'ok';
|
2796
|
-
}
|
2797
|
-
}
|
2727
|
+
self.onLoad();
|
2798
2728
|
} else {
|
2799
2729
|
// make sure the `error` event handler that's user-set
|
2800
2730
|
// does not throw in the same tick and gets caught here
|
@@ -2802,14 +2732,8 @@ Request.prototype.create = function(isBinary, supportsBinary){
|
|
2802
2732
|
self.onError(xhr.status);
|
2803
2733
|
}, 0);
|
2804
2734
|
}
|
2805
|
-
}
|
2806
|
-
|
2807
|
-
}
|
2808
|
-
|
2809
|
-
if (null != data) {
|
2810
|
-
self.onData(data);
|
2811
|
-
}
|
2812
|
-
};
|
2735
|
+
};
|
2736
|
+
}
|
2813
2737
|
|
2814
2738
|
debug('xhr data %s', this.data);
|
2815
2739
|
xhr.send(this.data);
|
@@ -2873,7 +2797,11 @@ Request.prototype.cleanup = function(){
|
|
2873
2797
|
return;
|
2874
2798
|
}
|
2875
2799
|
// xmlhttprequest
|
2876
|
-
this.
|
2800
|
+
if (this.hasXDR()) {
|
2801
|
+
this.xhr.onload = this.xhr.onerror = empty;
|
2802
|
+
} else {
|
2803
|
+
this.xhr.onreadystatechange = empty;
|
2804
|
+
}
|
2877
2805
|
|
2878
2806
|
try {
|
2879
2807
|
this.xhr.abort();
|
@@ -2886,6 +2814,46 @@ Request.prototype.cleanup = function(){
|
|
2886
2814
|
this.xhr = null;
|
2887
2815
|
};
|
2888
2816
|
|
2817
|
+
/**
|
2818
|
+
* Called upon load.
|
2819
|
+
*
|
2820
|
+
* @api private
|
2821
|
+
*/
|
2822
|
+
|
2823
|
+
Request.prototype.onLoad = function(){
|
2824
|
+
var data;
|
2825
|
+
try {
|
2826
|
+
var contentType;
|
2827
|
+
try {
|
2828
|
+
contentType = this.xhr.getResponseHeader('Content-Type').split(';')[0];
|
2829
|
+
} catch (e) {}
|
2830
|
+
if (contentType === 'application/octet-stream') {
|
2831
|
+
data = this.xhr.response;
|
2832
|
+
} else {
|
2833
|
+
if (!this.supportsBinary) {
|
2834
|
+
data = this.xhr.responseText;
|
2835
|
+
} else {
|
2836
|
+
data = 'ok';
|
2837
|
+
}
|
2838
|
+
}
|
2839
|
+
} catch (e) {
|
2840
|
+
this.onError(e);
|
2841
|
+
}
|
2842
|
+
if (null != data) {
|
2843
|
+
this.onData(data);
|
2844
|
+
}
|
2845
|
+
};
|
2846
|
+
|
2847
|
+
/**
|
2848
|
+
* Check if it has XDomainRequest.
|
2849
|
+
*
|
2850
|
+
* @api private
|
2851
|
+
*/
|
2852
|
+
|
2853
|
+
Request.prototype.hasXDR = function(){
|
2854
|
+
return 'undefined' !== typeof global.XDomainRequest && !this.xs && this.enablesXDR;
|
2855
|
+
};
|
2856
|
+
|
2889
2857
|
/**
|
2890
2858
|
* Aborts the request.
|
2891
2859
|
*
|
@@ -2920,16 +2888,17 @@ function unloadHandler() {
|
|
2920
2888
|
}
|
2921
2889
|
}
|
2922
2890
|
|
2923
|
-
},
|
2891
|
+
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
2892
|
+
},{"./polling":17,"component-emitter":8,"component-inherit":20,"debug":9,"xmlhttprequest":19}],17:[function(_dereq_,module,exports){
|
2924
2893
|
/**
|
2925
2894
|
* Module dependencies.
|
2926
2895
|
*/
|
2927
2896
|
|
2928
|
-
var Transport =
|
2929
|
-
var parseqs =
|
2930
|
-
var parser =
|
2931
|
-
var inherit =
|
2932
|
-
var debug =
|
2897
|
+
var Transport = _dereq_('../transport');
|
2898
|
+
var parseqs = _dereq_('parseqs');
|
2899
|
+
var parser = _dereq_('engine.io-parser');
|
2900
|
+
var inherit = _dereq_('component-inherit');
|
2901
|
+
var debug = _dereq_('debug')('engine.io-client:polling');
|
2933
2902
|
|
2934
2903
|
/**
|
2935
2904
|
* Module exports.
|
@@ -2942,8 +2911,8 @@ module.exports = Polling;
|
|
2942
2911
|
*/
|
2943
2912
|
|
2944
2913
|
var hasXHR2 = (function() {
|
2945
|
-
var XMLHttpRequest =
|
2946
|
-
var xhr = new XMLHttpRequest({
|
2914
|
+
var XMLHttpRequest = _dereq_('xmlhttprequest');
|
2915
|
+
var xhr = new XMLHttpRequest({ xdomain: false });
|
2947
2916
|
return null != xhr.responseType;
|
2948
2917
|
})();
|
2949
2918
|
|
@@ -3167,16 +3136,16 @@ Polling.prototype.uri = function(){
|
|
3167
3136
|
return schema + '://' + this.hostname + port + this.path + query;
|
3168
3137
|
};
|
3169
3138
|
|
3170
|
-
},{"../transport":
|
3139
|
+
},{"../transport":13,"component-inherit":20,"debug":9,"engine.io-parser":21,"parseqs":29,"xmlhttprequest":19}],18:[function(_dereq_,module,exports){
|
3171
3140
|
/**
|
3172
3141
|
* Module dependencies.
|
3173
3142
|
*/
|
3174
3143
|
|
3175
|
-
var Transport =
|
3176
|
-
var parser =
|
3177
|
-
var parseqs =
|
3178
|
-
var inherit =
|
3179
|
-
var debug =
|
3144
|
+
var Transport = _dereq_('../transport');
|
3145
|
+
var parser = _dereq_('engine.io-parser');
|
3146
|
+
var parseqs = _dereq_('parseqs');
|
3147
|
+
var inherit = _dereq_('component-inherit');
|
3148
|
+
var debug = _dereq_('debug')('engine.io-client:websocket');
|
3180
3149
|
|
3181
3150
|
/**
|
3182
3151
|
* `ws` exposes a WebSocket-compatible interface in
|
@@ -3184,7 +3153,7 @@ var debug = require('debug')('engine.io-client:websocket');
|
|
3184
3153
|
* in the browser.
|
3185
3154
|
*/
|
3186
3155
|
|
3187
|
-
var WebSocket =
|
3156
|
+
var WebSocket = _dereq_('ws');
|
3188
3157
|
|
3189
3158
|
/**
|
3190
3159
|
* Module exports.
|
@@ -3398,13 +3367,21 @@ WS.prototype.check = function(){
|
|
3398
3367
|
return !!WebSocket && !('__initialize' in WebSocket && this.name === WS.prototype.name);
|
3399
3368
|
};
|
3400
3369
|
|
3401
|
-
},{"../transport":
|
3370
|
+
},{"../transport":13,"component-inherit":20,"debug":9,"engine.io-parser":21,"parseqs":29,"ws":31}],19:[function(_dereq_,module,exports){
|
3402
3371
|
// browser shim for xmlhttprequest module
|
3403
|
-
var hasCORS =
|
3372
|
+
var hasCORS = _dereq_('has-cors');
|
3404
3373
|
|
3405
3374
|
module.exports = function(opts) {
|
3406
3375
|
var xdomain = opts.xdomain;
|
3407
3376
|
|
3377
|
+
// scheme must be same when usign XDomainRequest
|
3378
|
+
// http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
|
3379
|
+
var xscheme = opts.xscheme;
|
3380
|
+
|
3381
|
+
// XDomainRequest has a flow of not sending cookie, therefore it should be disabled as a default.
|
3382
|
+
// https://github.com/Automattic/engine.io-client/pull/217
|
3383
|
+
var enablesXDR = opts.enablesXDR;
|
3384
|
+
|
3408
3385
|
// XMLHttpRequest can be disabled on IE
|
3409
3386
|
try {
|
3410
3387
|
if ('undefined' != typeof XMLHttpRequest && (!xdomain || hasCORS)) {
|
@@ -3412,6 +3389,15 @@ module.exports = function(opts) {
|
|
3412
3389
|
}
|
3413
3390
|
} catch (e) { }
|
3414
3391
|
|
3392
|
+
// Use XDomainRequest for IE8 if enablesXDR is true
|
3393
|
+
// because loading bar keeps flashing when using jsonp-polling
|
3394
|
+
// https://github.com/yujiosaka/socke.io-ie8-loading-example
|
3395
|
+
try {
|
3396
|
+
if ('undefined' != typeof XDomainRequest && !xscheme && enablesXDR) {
|
3397
|
+
return new XDomainRequest();
|
3398
|
+
}
|
3399
|
+
} catch (e) { }
|
3400
|
+
|
3415
3401
|
if (!xdomain) {
|
3416
3402
|
try {
|
3417
3403
|
return new ActiveXObject('Microsoft.XMLHTTP');
|
@@ -3419,7 +3405,7 @@ module.exports = function(opts) {
|
|
3419
3405
|
}
|
3420
3406
|
}
|
3421
3407
|
|
3422
|
-
},{"has-cors":34}],
|
3408
|
+
},{"has-cors":34}],20:[function(_dereq_,module,exports){
|
3423
3409
|
|
3424
3410
|
module.exports = function(a, b){
|
3425
3411
|
var fn = function(){};
|
@@ -3427,16 +3413,17 @@ module.exports = function(a, b){
|
|
3427
3413
|
a.prototype = new fn;
|
3428
3414
|
a.prototype.constructor = a;
|
3429
3415
|
};
|
3430
|
-
},{}],
|
3431
|
-
|
3416
|
+
},{}],21:[function(_dereq_,module,exports){
|
3417
|
+
(function (global){
|
3418
|
+
/**
|
3432
3419
|
* Module dependencies.
|
3433
3420
|
*/
|
3434
3421
|
|
3435
|
-
var keys =
|
3436
|
-
var sliceBuffer =
|
3437
|
-
var base64encoder =
|
3438
|
-
var after =
|
3439
|
-
var utf8 =
|
3422
|
+
var keys = _dereq_('./keys');
|
3423
|
+
var sliceBuffer = _dereq_('arraybuffer.slice');
|
3424
|
+
var base64encoder = _dereq_('base64-arraybuffer');
|
3425
|
+
var after = _dereq_('after');
|
3426
|
+
var utf8 = _dereq_('utf8');
|
3440
3427
|
|
3441
3428
|
/**
|
3442
3429
|
* Check if we are running an android browser. That requires us to use
|
@@ -3451,7 +3438,7 @@ var isAndroid = navigator.userAgent.match(/Android/i);
|
|
3451
3438
|
* Current protocol version.
|
3452
3439
|
*/
|
3453
3440
|
|
3454
|
-
exports.protocol =
|
3441
|
+
exports.protocol = 3;
|
3455
3442
|
|
3456
3443
|
/**
|
3457
3444
|
* Packet types.
|
@@ -3479,7 +3466,7 @@ var err = { type: 'error', data: 'parser error' };
|
|
3479
3466
|
* Create a blob api even for blob builder when vendor prefixes exist
|
3480
3467
|
*/
|
3481
3468
|
|
3482
|
-
var Blob =
|
3469
|
+
var Blob = _dereq_('blob');
|
3483
3470
|
|
3484
3471
|
/**
|
3485
3472
|
* Encodes a packet.
|
@@ -3497,12 +3484,17 @@ var Blob = require('blob');
|
|
3497
3484
|
* @api private
|
3498
3485
|
*/
|
3499
3486
|
|
3500
|
-
exports.encodePacket = function (packet, supportsBinary, callback) {
|
3501
|
-
if (typeof supportsBinary
|
3487
|
+
exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) {
|
3488
|
+
if ('function' == typeof supportsBinary) {
|
3502
3489
|
callback = supportsBinary;
|
3503
3490
|
supportsBinary = false;
|
3504
3491
|
}
|
3505
3492
|
|
3493
|
+
if ('function' == typeof utf8encode) {
|
3494
|
+
callback = utf8encode;
|
3495
|
+
utf8encode = null;
|
3496
|
+
}
|
3497
|
+
|
3506
3498
|
var data = (packet.data === undefined)
|
3507
3499
|
? undefined
|
3508
3500
|
: packet.data.buffer || packet.data;
|
@@ -3518,7 +3510,7 @@ exports.encodePacket = function (packet, supportsBinary, callback) {
|
|
3518
3510
|
|
3519
3511
|
// data fragment is optional
|
3520
3512
|
if (undefined !== packet.data) {
|
3521
|
-
encoded += utf8.encode(String(packet.data));
|
3513
|
+
encoded += utf8encode ? utf8.encode(String(packet.data)) : String(packet.data);
|
3522
3514
|
}
|
3523
3515
|
|
3524
3516
|
return callback('' + encoded);
|
@@ -3554,7 +3546,7 @@ function encodeBlobAsArrayBuffer(packet, supportsBinary, callback) {
|
|
3554
3546
|
var fr = new FileReader();
|
3555
3547
|
fr.onload = function() {
|
3556
3548
|
packet.data = fr.result;
|
3557
|
-
exports.encodePacket(packet, supportsBinary, callback);
|
3549
|
+
exports.encodePacket(packet, supportsBinary, true, callback);
|
3558
3550
|
};
|
3559
3551
|
return fr.readAsArrayBuffer(packet.data);
|
3560
3552
|
}
|
@@ -3616,14 +3608,20 @@ exports.encodeBase64Packet = function(packet, callback) {
|
|
3616
3608
|
* @api private
|
3617
3609
|
*/
|
3618
3610
|
|
3619
|
-
exports.decodePacket = function (data, binaryType) {
|
3611
|
+
exports.decodePacket = function (data, binaryType, utf8decode) {
|
3620
3612
|
// String data
|
3621
3613
|
if (typeof data == 'string' || data === undefined) {
|
3622
3614
|
if (data.charAt(0) == 'b') {
|
3623
3615
|
return exports.decodeBase64Packet(data.substr(1), binaryType);
|
3624
3616
|
}
|
3625
3617
|
|
3626
|
-
|
3618
|
+
if (utf8decode) {
|
3619
|
+
try {
|
3620
|
+
data = utf8.decode(data);
|
3621
|
+
} catch (e) {
|
3622
|
+
return err;
|
3623
|
+
}
|
3624
|
+
}
|
3627
3625
|
var type = data.charAt(0);
|
3628
3626
|
|
3629
3627
|
if (Number(type) != type || !packetslist[type]) {
|
@@ -3707,7 +3705,7 @@ exports.encodePayload = function (packets, supportsBinary, callback) {
|
|
3707
3705
|
}
|
3708
3706
|
|
3709
3707
|
function encodeOne(packet, doneCallback) {
|
3710
|
-
exports.encodePacket(packet, supportsBinary, function(message) {
|
3708
|
+
exports.encodePacket(packet, supportsBinary, true, function(message) {
|
3711
3709
|
doneCallback(null, setLengthHeader(message));
|
3712
3710
|
});
|
3713
3711
|
}
|
@@ -3783,7 +3781,7 @@ exports.decodePayload = function (data, binaryType, callback) {
|
|
3783
3781
|
}
|
3784
3782
|
|
3785
3783
|
if (msg.length) {
|
3786
|
-
packet = exports.decodePacket(msg, binaryType);
|
3784
|
+
packet = exports.decodePacket(msg, binaryType, true);
|
3787
3785
|
|
3788
3786
|
if (err.type == packet.type && err.data == packet.data) {
|
3789
3787
|
// parser error in individual packet - ignoring payload
|
@@ -3827,7 +3825,7 @@ exports.encodePayloadAsArrayBuffer = function(packets, callback) {
|
|
3827
3825
|
}
|
3828
3826
|
|
3829
3827
|
function encodeOne(packet, doneCallback) {
|
3830
|
-
exports.encodePacket(packet, true, function(data) {
|
3828
|
+
exports.encodePacket(packet, true, true, function(data) {
|
3831
3829
|
return doneCallback(null, data);
|
3832
3830
|
});
|
3833
3831
|
}
|
@@ -3885,7 +3883,7 @@ exports.encodePayloadAsArrayBuffer = function(packets, callback) {
|
|
3885
3883
|
|
3886
3884
|
exports.encodePayloadAsBlob = function(packets, callback) {
|
3887
3885
|
function encodeOne(packet, doneCallback) {
|
3888
|
-
exports.encodePacket(packet, true, function(encoded) {
|
3886
|
+
exports.encodePacket(packet, true, true, function(encoded) {
|
3889
3887
|
var binaryIdentifier = new Uint8Array(1);
|
3890
3888
|
binaryIdentifier[0] = 1;
|
3891
3889
|
if (typeof encoded === 'string') {
|
@@ -3938,14 +3936,25 @@ exports.decodePayloadAsBinary = function (data, binaryType, callback) {
|
|
3938
3936
|
var bufferTail = data;
|
3939
3937
|
var buffers = [];
|
3940
3938
|
|
3939
|
+
var numberTooLong = false;
|
3941
3940
|
while (bufferTail.byteLength > 0) {
|
3942
3941
|
var tailArray = new Uint8Array(bufferTail);
|
3943
3942
|
var isString = tailArray[0] === 0;
|
3944
3943
|
var msgLength = '';
|
3944
|
+
|
3945
3945
|
for (var i = 1; ; i++) {
|
3946
3946
|
if (tailArray[i] == 255) break;
|
3947
|
+
|
3948
|
+
if (msgLength.length > 310) {
|
3949
|
+
numberTooLong = true;
|
3950
|
+
break;
|
3951
|
+
}
|
3952
|
+
|
3947
3953
|
msgLength += tailArray[i];
|
3948
3954
|
}
|
3955
|
+
|
3956
|
+
if(numberTooLong) return callback(err, 0, 1);
|
3957
|
+
|
3949
3958
|
bufferTail = sliceBuffer(bufferTail, 2 + msgLength.length);
|
3950
3959
|
msgLength = parseInt(msgLength);
|
3951
3960
|
|
@@ -3962,17 +3971,19 @@ exports.decodePayloadAsBinary = function (data, binaryType, callback) {
|
|
3962
3971
|
}
|
3963
3972
|
}
|
3964
3973
|
}
|
3974
|
+
|
3965
3975
|
buffers.push(msg);
|
3966
3976
|
bufferTail = sliceBuffer(bufferTail, msgLength);
|
3967
3977
|
}
|
3968
3978
|
|
3969
3979
|
var total = buffers.length;
|
3970
3980
|
buffers.forEach(function(buffer, i) {
|
3971
|
-
callback(exports.decodePacket(buffer, binaryType), i, total);
|
3981
|
+
callback(exports.decodePacket(buffer, binaryType, true), i, total);
|
3972
3982
|
});
|
3973
3983
|
};
|
3974
3984
|
|
3975
|
-
}
|
3985
|
+
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
3986
|
+
},{"./keys":22,"after":23,"arraybuffer.slice":24,"base64-arraybuffer":25,"blob":26,"utf8":27}],22:[function(_dereq_,module,exports){
|
3976
3987
|
|
3977
3988
|
/**
|
3978
3989
|
* Gets the keys for an object.
|
@@ -3993,7 +4004,7 @@ module.exports = Object.keys || function keys (obj){
|
|
3993
4004
|
return arr;
|
3994
4005
|
};
|
3995
4006
|
|
3996
|
-
},{}],
|
4007
|
+
},{}],23:[function(_dereq_,module,exports){
|
3997
4008
|
module.exports = after
|
3998
4009
|
|
3999
4010
|
function after(count, callback, err_cb) {
|
@@ -4023,7 +4034,7 @@ function after(count, callback, err_cb) {
|
|
4023
4034
|
|
4024
4035
|
function noop() {}
|
4025
4036
|
|
4026
|
-
},{}],
|
4037
|
+
},{}],24:[function(_dereq_,module,exports){
|
4027
4038
|
/**
|
4028
4039
|
* An abstraction for slicing an arraybuffer even when
|
4029
4040
|
* ArrayBuffer.prototype.slice is not supported
|
@@ -4054,7 +4065,7 @@ module.exports = function(arraybuffer, start, end) {
|
|
4054
4065
|
return result.buffer;
|
4055
4066
|
};
|
4056
4067
|
|
4057
|
-
},{}],
|
4068
|
+
},{}],25:[function(_dereq_,module,exports){
|
4058
4069
|
/*
|
4059
4070
|
* base64-arraybuffer
|
4060
4071
|
* https://github.com/niklasvh/base64-arraybuffer
|
@@ -4115,8 +4126,9 @@ module.exports = function(arraybuffer, start, end) {
|
|
4115
4126
|
};
|
4116
4127
|
})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
|
4117
4128
|
|
4118
|
-
},{}],
|
4119
|
-
|
4129
|
+
},{}],26:[function(_dereq_,module,exports){
|
4130
|
+
(function (global){
|
4131
|
+
/**
|
4120
4132
|
* Create a blob builder even when vendor prefixes exist
|
4121
4133
|
*/
|
4122
4134
|
|
@@ -4166,249 +4178,253 @@ module.exports = (function() {
|
|
4166
4178
|
}
|
4167
4179
|
})();
|
4168
4180
|
|
4169
|
-
},{}
|
4170
|
-
|
4181
|
+
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
4182
|
+
},{}],27:[function(_dereq_,module,exports){
|
4183
|
+
(function (global){
|
4184
|
+
/*! http://mths.be/utf8js v2.0.0 by @mathias */
|
4171
4185
|
;(function(root) {
|
4172
4186
|
|
4173
|
-
|
4174
|
-
|
4175
|
-
|
4176
|
-
|
4177
|
-
|
4178
|
-
|
4179
|
-
|
4180
|
-
|
4181
|
-
|
4182
|
-
|
4183
|
-
|
4184
|
-
|
4185
|
-
|
4186
|
-
|
4187
|
-
|
4188
|
-
|
4189
|
-
|
4190
|
-
|
4191
|
-
|
4192
|
-
|
4193
|
-
|
4194
|
-
|
4195
|
-
|
4196
|
-
|
4197
|
-
|
4198
|
-
|
4199
|
-
|
4200
|
-
|
4201
|
-
|
4202
|
-
|
4203
|
-
|
4204
|
-
|
4205
|
-
|
4206
|
-
|
4207
|
-
|
4208
|
-
|
4209
|
-
|
4210
|
-
|
4211
|
-
|
4212
|
-
|
4213
|
-
|
4214
|
-
|
4215
|
-
|
4216
|
-
|
4217
|
-
|
4218
|
-
|
4219
|
-
|
4220
|
-
|
4221
|
-
|
4222
|
-
|
4223
|
-
|
4224
|
-
|
4225
|
-
|
4226
|
-
|
4227
|
-
|
4228
|
-
|
4229
|
-
|
4230
|
-
|
4231
|
-
|
4232
|
-
|
4233
|
-
|
4234
|
-
|
4235
|
-
|
4236
|
-
|
4237
|
-
|
4238
|
-
|
4239
|
-
|
4240
|
-
|
4241
|
-
|
4242
|
-
|
4243
|
-
|
4244
|
-
|
4245
|
-
|
4246
|
-
|
4247
|
-
|
4248
|
-
|
4249
|
-
|
4250
|
-
|
4251
|
-
|
4252
|
-
|
4253
|
-
|
4254
|
-
|
4255
|
-
|
4256
|
-
|
4257
|
-
|
4258
|
-
|
4259
|
-
|
4260
|
-
|
4261
|
-
|
4262
|
-
|
4263
|
-
|
4264
|
-
|
4265
|
-
|
4266
|
-
|
4267
|
-
|
4268
|
-
|
4269
|
-
|
4270
|
-
|
4271
|
-
|
4272
|
-
|
4273
|
-
|
4274
|
-
|
4275
|
-
|
4276
|
-
|
4277
|
-
|
4278
|
-
|
4279
|
-
|
4280
|
-
|
4281
|
-
|
4282
|
-
|
4283
|
-
|
4284
|
-
|
4285
|
-
|
4286
|
-
|
4287
|
-
|
4288
|
-
|
4289
|
-
|
4290
|
-
|
4291
|
-
|
4292
|
-
|
4293
|
-
|
4294
|
-
|
4295
|
-
|
4296
|
-
|
4297
|
-
|
4298
|
-
|
4299
|
-
|
4300
|
-
|
4301
|
-
|
4302
|
-
|
4303
|
-
|
4304
|
-
|
4305
|
-
|
4306
|
-
|
4307
|
-
|
4308
|
-
|
4309
|
-
|
4310
|
-
|
4311
|
-
|
4312
|
-
|
4313
|
-
|
4314
|
-
|
4315
|
-
|
4316
|
-
|
4317
|
-
|
4318
|
-
|
4319
|
-
|
4320
|
-
|
4321
|
-
|
4322
|
-
|
4323
|
-
|
4324
|
-
|
4325
|
-
|
4326
|
-
|
4327
|
-
|
4328
|
-
|
4329
|
-
|
4330
|
-
|
4331
|
-
|
4332
|
-
|
4333
|
-
|
4334
|
-
|
4335
|
-
|
4336
|
-
|
4337
|
-
|
4338
|
-
|
4339
|
-
|
4340
|
-
|
4341
|
-
|
4342
|
-
|
4343
|
-
|
4344
|
-
|
4345
|
-
|
4346
|
-
|
4347
|
-
|
4348
|
-
|
4349
|
-
|
4350
|
-
|
4351
|
-
|
4352
|
-
|
4353
|
-
|
4354
|
-
|
4355
|
-
|
4356
|
-
|
4357
|
-
|
4358
|
-
|
4359
|
-
|
4360
|
-
|
4361
|
-
|
4362
|
-
|
4363
|
-
|
4364
|
-
|
4365
|
-
|
4366
|
-
|
4367
|
-
|
4368
|
-
|
4369
|
-
|
4370
|
-
|
4371
|
-
|
4372
|
-
|
4373
|
-
|
4374
|
-
|
4375
|
-
|
4376
|
-
|
4377
|
-
|
4378
|
-
|
4379
|
-
|
4380
|
-
|
4381
|
-
|
4382
|
-
|
4383
|
-
|
4384
|
-
|
4385
|
-
|
4386
|
-
|
4387
|
-
|
4388
|
-
|
4389
|
-
|
4390
|
-
|
4391
|
-
|
4392
|
-
|
4393
|
-
|
4394
|
-
|
4395
|
-
|
4396
|
-
|
4397
|
-
|
4398
|
-
|
4399
|
-
|
4400
|
-
|
4401
|
-
|
4402
|
-
|
4403
|
-
|
4404
|
-
|
4405
|
-
|
4406
|
-
|
4187
|
+
// Detect free variables `exports`
|
4188
|
+
var freeExports = typeof exports == 'object' && exports;
|
4189
|
+
|
4190
|
+
// Detect free variable `module`
|
4191
|
+
var freeModule = typeof module == 'object' && module &&
|
4192
|
+
module.exports == freeExports && module;
|
4193
|
+
|
4194
|
+
// Detect free variable `global`, from Node.js or Browserified code,
|
4195
|
+
// and use it as `root`
|
4196
|
+
var freeGlobal = typeof global == 'object' && global;
|
4197
|
+
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
|
4198
|
+
root = freeGlobal;
|
4199
|
+
}
|
4200
|
+
|
4201
|
+
/*--------------------------------------------------------------------------*/
|
4202
|
+
|
4203
|
+
var stringFromCharCode = String.fromCharCode;
|
4204
|
+
|
4205
|
+
// Taken from http://mths.be/punycode
|
4206
|
+
function ucs2decode(string) {
|
4207
|
+
var output = [];
|
4208
|
+
var counter = 0;
|
4209
|
+
var length = string.length;
|
4210
|
+
var value;
|
4211
|
+
var extra;
|
4212
|
+
while (counter < length) {
|
4213
|
+
value = string.charCodeAt(counter++);
|
4214
|
+
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
|
4215
|
+
// high surrogate, and there is a next character
|
4216
|
+
extra = string.charCodeAt(counter++);
|
4217
|
+
if ((extra & 0xFC00) == 0xDC00) { // low surrogate
|
4218
|
+
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
4219
|
+
} else {
|
4220
|
+
// unmatched surrogate; only append this code unit, in case the next
|
4221
|
+
// code unit is the high surrogate of a surrogate pair
|
4222
|
+
output.push(value);
|
4223
|
+
counter--;
|
4224
|
+
}
|
4225
|
+
} else {
|
4226
|
+
output.push(value);
|
4227
|
+
}
|
4228
|
+
}
|
4229
|
+
return output;
|
4230
|
+
}
|
4231
|
+
|
4232
|
+
// Taken from http://mths.be/punycode
|
4233
|
+
function ucs2encode(array) {
|
4234
|
+
var length = array.length;
|
4235
|
+
var index = -1;
|
4236
|
+
var value;
|
4237
|
+
var output = '';
|
4238
|
+
while (++index < length) {
|
4239
|
+
value = array[index];
|
4240
|
+
if (value > 0xFFFF) {
|
4241
|
+
value -= 0x10000;
|
4242
|
+
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
|
4243
|
+
value = 0xDC00 | value & 0x3FF;
|
4244
|
+
}
|
4245
|
+
output += stringFromCharCode(value);
|
4246
|
+
}
|
4247
|
+
return output;
|
4248
|
+
}
|
4249
|
+
|
4250
|
+
/*--------------------------------------------------------------------------*/
|
4251
|
+
|
4252
|
+
function createByte(codePoint, shift) {
|
4253
|
+
return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
|
4254
|
+
}
|
4255
|
+
|
4256
|
+
function encodeCodePoint(codePoint) {
|
4257
|
+
if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
|
4258
|
+
return stringFromCharCode(codePoint);
|
4259
|
+
}
|
4260
|
+
var symbol = '';
|
4261
|
+
if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
|
4262
|
+
symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
|
4263
|
+
}
|
4264
|
+
else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
|
4265
|
+
symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
|
4266
|
+
symbol += createByte(codePoint, 6);
|
4267
|
+
}
|
4268
|
+
else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
|
4269
|
+
symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
|
4270
|
+
symbol += createByte(codePoint, 12);
|
4271
|
+
symbol += createByte(codePoint, 6);
|
4272
|
+
}
|
4273
|
+
symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
|
4274
|
+
return symbol;
|
4275
|
+
}
|
4276
|
+
|
4277
|
+
function utf8encode(string) {
|
4278
|
+
var codePoints = ucs2decode(string);
|
4279
|
+
|
4280
|
+
// console.log(JSON.stringify(codePoints.map(function(x) {
|
4281
|
+
// return 'U+' + x.toString(16).toUpperCase();
|
4282
|
+
// })));
|
4283
|
+
|
4284
|
+
var length = codePoints.length;
|
4285
|
+
var index = -1;
|
4286
|
+
var codePoint;
|
4287
|
+
var byteString = '';
|
4288
|
+
while (++index < length) {
|
4289
|
+
codePoint = codePoints[index];
|
4290
|
+
byteString += encodeCodePoint(codePoint);
|
4291
|
+
}
|
4292
|
+
return byteString;
|
4293
|
+
}
|
4294
|
+
|
4295
|
+
/*--------------------------------------------------------------------------*/
|
4296
|
+
|
4297
|
+
function readContinuationByte() {
|
4298
|
+
if (byteIndex >= byteCount) {
|
4299
|
+
throw Error('Invalid byte index');
|
4300
|
+
}
|
4301
|
+
|
4302
|
+
var continuationByte = byteArray[byteIndex] & 0xFF;
|
4303
|
+
byteIndex++;
|
4304
|
+
|
4305
|
+
if ((continuationByte & 0xC0) == 0x80) {
|
4306
|
+
return continuationByte & 0x3F;
|
4307
|
+
}
|
4308
|
+
|
4309
|
+
// If we end up here, it’s not a continuation byte
|
4310
|
+
throw Error('Invalid continuation byte');
|
4311
|
+
}
|
4312
|
+
|
4313
|
+
function decodeSymbol() {
|
4314
|
+
var byte1;
|
4315
|
+
var byte2;
|
4316
|
+
var byte3;
|
4317
|
+
var byte4;
|
4318
|
+
var codePoint;
|
4319
|
+
|
4320
|
+
if (byteIndex > byteCount) {
|
4321
|
+
throw Error('Invalid byte index');
|
4322
|
+
}
|
4323
|
+
|
4324
|
+
if (byteIndex == byteCount) {
|
4325
|
+
return false;
|
4326
|
+
}
|
4327
|
+
|
4328
|
+
// Read first byte
|
4329
|
+
byte1 = byteArray[byteIndex] & 0xFF;
|
4330
|
+
byteIndex++;
|
4331
|
+
|
4332
|
+
// 1-byte sequence (no continuation bytes)
|
4333
|
+
if ((byte1 & 0x80) == 0) {
|
4334
|
+
return byte1;
|
4335
|
+
}
|
4336
|
+
|
4337
|
+
// 2-byte sequence
|
4338
|
+
if ((byte1 & 0xE0) == 0xC0) {
|
4339
|
+
var byte2 = readContinuationByte();
|
4340
|
+
codePoint = ((byte1 & 0x1F) << 6) | byte2;
|
4341
|
+
if (codePoint >= 0x80) {
|
4342
|
+
return codePoint;
|
4343
|
+
} else {
|
4344
|
+
throw Error('Invalid continuation byte');
|
4345
|
+
}
|
4346
|
+
}
|
4347
|
+
|
4348
|
+
// 3-byte sequence (may include unpaired surrogates)
|
4349
|
+
if ((byte1 & 0xF0) == 0xE0) {
|
4350
|
+
byte2 = readContinuationByte();
|
4351
|
+
byte3 = readContinuationByte();
|
4352
|
+
codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
|
4353
|
+
if (codePoint >= 0x0800) {
|
4354
|
+
return codePoint;
|
4355
|
+
} else {
|
4356
|
+
throw Error('Invalid continuation byte');
|
4357
|
+
}
|
4358
|
+
}
|
4359
|
+
|
4360
|
+
// 4-byte sequence
|
4361
|
+
if ((byte1 & 0xF8) == 0xF0) {
|
4362
|
+
byte2 = readContinuationByte();
|
4363
|
+
byte3 = readContinuationByte();
|
4364
|
+
byte4 = readContinuationByte();
|
4365
|
+
codePoint = ((byte1 & 0x0F) << 0x12) | (byte2 << 0x0C) |
|
4366
|
+
(byte3 << 0x06) | byte4;
|
4367
|
+
if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
|
4368
|
+
return codePoint;
|
4369
|
+
}
|
4370
|
+
}
|
4371
|
+
|
4372
|
+
throw Error('Invalid UTF-8 detected');
|
4373
|
+
}
|
4374
|
+
|
4375
|
+
var byteArray;
|
4376
|
+
var byteCount;
|
4377
|
+
var byteIndex;
|
4378
|
+
function utf8decode(byteString) {
|
4379
|
+
byteArray = ucs2decode(byteString);
|
4380
|
+
byteCount = byteArray.length;
|
4381
|
+
byteIndex = 0;
|
4382
|
+
var codePoints = [];
|
4383
|
+
var tmp;
|
4384
|
+
while ((tmp = decodeSymbol()) !== false) {
|
4385
|
+
codePoints.push(tmp);
|
4386
|
+
}
|
4387
|
+
return ucs2encode(codePoints);
|
4388
|
+
}
|
4389
|
+
|
4390
|
+
/*--------------------------------------------------------------------------*/
|
4391
|
+
|
4392
|
+
var utf8 = {
|
4393
|
+
'version': '2.0.0',
|
4394
|
+
'encode': utf8encode,
|
4395
|
+
'decode': utf8decode
|
4396
|
+
};
|
4397
|
+
|
4398
|
+
// Some AMD build optimizers, like r.js, check for specific condition patterns
|
4399
|
+
// like the following:
|
4400
|
+
if (
|
4401
|
+
typeof define == 'function' &&
|
4402
|
+
typeof define.amd == 'object' &&
|
4403
|
+
define.amd
|
4404
|
+
) {
|
4405
|
+
define(function() {
|
4406
|
+
return utf8;
|
4407
|
+
});
|
4408
|
+
} else if (freeExports && !freeExports.nodeType) {
|
4409
|
+
if (freeModule) { // in Node.js or RingoJS v0.8.0+
|
4410
|
+
freeModule.exports = utf8;
|
4411
|
+
} else { // in Narwhal or RingoJS v0.7.0-
|
4412
|
+
var object = {};
|
4413
|
+
var hasOwnProperty = object.hasOwnProperty;
|
4414
|
+
for (var key in utf8) {
|
4415
|
+
hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
|
4416
|
+
}
|
4417
|
+
}
|
4418
|
+
} else { // in Rhino or a web browser
|
4419
|
+
root.utf8 = utf8;
|
4420
|
+
}
|
4407
4421
|
|
4408
4422
|
}(this));
|
4409
4423
|
|
4410
|
-
},{}
|
4411
|
-
|
4424
|
+
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
4425
|
+
},{}],28:[function(_dereq_,module,exports){
|
4426
|
+
(function (global){
|
4427
|
+
/**
|
4412
4428
|
* JSON parse.
|
4413
4429
|
*
|
4414
4430
|
* @see Based on jQuery#parseJSON (MIT) and JSON2
|
@@ -4440,7 +4456,8 @@ module.exports = function parsejson(data) {
|
|
4440
4456
|
return (new Function('return ' + data))();
|
4441
4457
|
}
|
4442
4458
|
};
|
4443
|
-
},{}
|
4459
|
+
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
4460
|
+
},{}],29:[function(_dereq_,module,exports){
|
4444
4461
|
/**
|
4445
4462
|
* Compiles a querystring
|
4446
4463
|
* Returns string representation of the object
|
@@ -4479,7 +4496,48 @@ exports.decode = function(qs){
|
|
4479
4496
|
return qry;
|
4480
4497
|
};
|
4481
4498
|
|
4482
|
-
},{}],
|
4499
|
+
},{}],30:[function(_dereq_,module,exports){
|
4500
|
+
/**
|
4501
|
+
* Parses an URI
|
4502
|
+
*
|
4503
|
+
* @author Steven Levithan <stevenlevithan.com> (MIT license)
|
4504
|
+
* @api private
|
4505
|
+
*/
|
4506
|
+
|
4507
|
+
var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
|
4508
|
+
|
4509
|
+
var parts = [
|
4510
|
+
'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'
|
4511
|
+
];
|
4512
|
+
|
4513
|
+
module.exports = function parseuri(str) {
|
4514
|
+
var src = str,
|
4515
|
+
b = str.indexOf('['),
|
4516
|
+
e = str.indexOf(']');
|
4517
|
+
|
4518
|
+
if (b != -1 && e != -1) {
|
4519
|
+
str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);
|
4520
|
+
}
|
4521
|
+
|
4522
|
+
var m = re.exec(str || ''),
|
4523
|
+
uri = {},
|
4524
|
+
i = 14;
|
4525
|
+
|
4526
|
+
while (i--) {
|
4527
|
+
uri[parts[i]] = m[i] || '';
|
4528
|
+
}
|
4529
|
+
|
4530
|
+
if (b != -1 && e != -1) {
|
4531
|
+
uri.source = src;
|
4532
|
+
uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');
|
4533
|
+
uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');
|
4534
|
+
uri.ipv6uri = true;
|
4535
|
+
}
|
4536
|
+
|
4537
|
+
return uri;
|
4538
|
+
};
|
4539
|
+
|
4540
|
+
},{}],31:[function(_dereq_,module,exports){
|
4483
4541
|
|
4484
4542
|
/**
|
4485
4543
|
* Module dependencies.
|
@@ -4524,12 +4582,14 @@ function ws(uri, protocols, opts) {
|
|
4524
4582
|
|
4525
4583
|
if (WebSocket) ws.prototype = WebSocket.prototype;
|
4526
4584
|
|
4527
|
-
},{}],32:[function(
|
4528
|
-
|
4585
|
+
},{}],32:[function(_dereq_,module,exports){
|
4586
|
+
(function (global){
|
4587
|
+
|
4588
|
+
/*
|
4529
4589
|
* Module requirements.
|
4530
4590
|
*/
|
4531
4591
|
|
4532
|
-
var isArray =
|
4592
|
+
var isArray = _dereq_('isarray');
|
4533
4593
|
|
4534
4594
|
/**
|
4535
4595
|
* Module exports.
|
@@ -4548,10 +4608,10 @@ module.exports = hasBinary;
|
|
4548
4608
|
|
4549
4609
|
function hasBinary(data) {
|
4550
4610
|
|
4551
|
-
function
|
4611
|
+
function _hasBinary(obj) {
|
4552
4612
|
if (!obj) return false;
|
4553
4613
|
|
4554
|
-
if ( (global.Buffer && Buffer.isBuffer(obj)) ||
|
4614
|
+
if ( (global.Buffer && global.Buffer.isBuffer(obj)) ||
|
4555
4615
|
(global.ArrayBuffer && obj instanceof ArrayBuffer) ||
|
4556
4616
|
(global.Blob && obj instanceof Blob) ||
|
4557
4617
|
(global.File && obj instanceof File)
|
@@ -4561,7 +4621,7 @@ function hasBinary(data) {
|
|
4561
4621
|
|
4562
4622
|
if (isArray(obj)) {
|
4563
4623
|
for (var i = 0; i < obj.length; i++) {
|
4564
|
-
if (
|
4624
|
+
if (_hasBinary(obj[i])) {
|
4565
4625
|
return true;
|
4566
4626
|
}
|
4567
4627
|
}
|
@@ -4571,7 +4631,7 @@ function hasBinary(data) {
|
|
4571
4631
|
}
|
4572
4632
|
|
4573
4633
|
for (var key in obj) {
|
4574
|
-
if (
|
4634
|
+
if (obj.hasOwnProperty(key) && _hasBinary(obj[key])) {
|
4575
4635
|
return true;
|
4576
4636
|
}
|
4577
4637
|
}
|
@@ -4580,21 +4640,22 @@ function hasBinary(data) {
|
|
4580
4640
|
return false;
|
4581
4641
|
}
|
4582
4642
|
|
4583
|
-
return
|
4643
|
+
return _hasBinary(data);
|
4584
4644
|
}
|
4585
4645
|
|
4586
|
-
},
|
4646
|
+
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
4647
|
+
},{"isarray":33}],33:[function(_dereq_,module,exports){
|
4587
4648
|
module.exports = Array.isArray || function (arr) {
|
4588
4649
|
return Object.prototype.toString.call(arr) == '[object Array]';
|
4589
4650
|
};
|
4590
4651
|
|
4591
|
-
},{}],34:[function(
|
4652
|
+
},{}],34:[function(_dereq_,module,exports){
|
4592
4653
|
|
4593
4654
|
/**
|
4594
4655
|
* Module dependencies.
|
4595
4656
|
*/
|
4596
4657
|
|
4597
|
-
var global =
|
4658
|
+
var global = _dereq_('global');
|
4598
4659
|
|
4599
4660
|
/**
|
4600
4661
|
* Module exports.
|
@@ -4613,7 +4674,7 @@ try {
|
|
4613
4674
|
module.exports = false;
|
4614
4675
|
}
|
4615
4676
|
|
4616
|
-
},{"global":35}],35:[function(
|
4677
|
+
},{"global":35}],35:[function(_dereq_,module,exports){
|
4617
4678
|
|
4618
4679
|
/**
|
4619
4680
|
* Returns `this`. Execute this without a "context" (i.e. without it being
|
@@ -4623,7 +4684,7 @@ try {
|
|
4623
4684
|
|
4624
4685
|
module.exports = (function () { return this; })();
|
4625
4686
|
|
4626
|
-
},{}],36:[function(
|
4687
|
+
},{}],36:[function(_dereq_,module,exports){
|
4627
4688
|
|
4628
4689
|
var indexOf = [].indexOf;
|
4629
4690
|
|
@@ -4634,7 +4695,7 @@ module.exports = function(arr, obj){
|
|
4634
4695
|
}
|
4635
4696
|
return -1;
|
4636
4697
|
};
|
4637
|
-
},{}],37:[function(
|
4698
|
+
},{}],37:[function(_dereq_,module,exports){
|
4638
4699
|
|
4639
4700
|
/**
|
4640
4701
|
* HOP ref.
|
@@ -4719,7 +4780,7 @@ exports.length = function(obj){
|
|
4719
4780
|
exports.isEmpty = function(obj){
|
4720
4781
|
return 0 == exports.length(obj);
|
4721
4782
|
};
|
4722
|
-
},{}],38:[function(
|
4783
|
+
},{}],38:[function(_dereq_,module,exports){
|
4723
4784
|
/**
|
4724
4785
|
* Parses an URI
|
4725
4786
|
*
|
@@ -4746,12 +4807,16 @@ module.exports = function parseuri(str) {
|
|
4746
4807
|
return uri;
|
4747
4808
|
};
|
4748
4809
|
|
4749
|
-
},{}],39:[function(
|
4750
|
-
|
4751
|
-
|
4810
|
+
},{}],39:[function(_dereq_,module,exports){
|
4811
|
+
(function (global){
|
4812
|
+
/*global Blob,File*/
|
4813
|
+
|
4814
|
+
/**
|
4815
|
+
* Module requirements
|
4752
4816
|
*/
|
4753
4817
|
|
4754
|
-
var isArray =
|
4818
|
+
var isArray = _dereq_('isarray');
|
4819
|
+
var isBuf = _dereq_('./is-buffer');
|
4755
4820
|
|
4756
4821
|
/**
|
4757
4822
|
* Replaces every Buffer | ArrayBuffer in packet with a numbered placeholder.
|
@@ -4763,39 +4828,38 @@ var isArray = require('isarray');
|
|
4763
4828
|
* @api public
|
4764
4829
|
*/
|
4765
4830
|
|
4766
|
-
exports.deconstructPacket = function(packet)
|
4767
|
-
|
4768
|
-
|
4769
|
-
|
4770
|
-
|
4771
|
-
|
4772
|
-
|
4773
|
-
|
4774
|
-
|
4775
|
-
|
4776
|
-
|
4777
|
-
|
4778
|
-
|
4779
|
-
|
4780
|
-
|
4781
|
-
|
4782
|
-
|
4783
|
-
|
4784
|
-
|
4785
|
-
|
4786
|
-
|
4787
|
-
|
4788
|
-
|
4789
|
-
return newData;
|
4790
|
-
}
|
4791
|
-
return data;
|
4831
|
+
exports.deconstructPacket = function(packet){
|
4832
|
+
var buffers = [];
|
4833
|
+
var packetData = packet.data;
|
4834
|
+
|
4835
|
+
function _deconstructPacket(data) {
|
4836
|
+
if (!data) return data;
|
4837
|
+
|
4838
|
+
if (isBuf(data)) {
|
4839
|
+
var placeholder = { _placeholder: true, num: buffers.length };
|
4840
|
+
buffers.push(data);
|
4841
|
+
return placeholder;
|
4842
|
+
} else if (isArray(data)) {
|
4843
|
+
var newData = new Array(data.length);
|
4844
|
+
for (var i = 0; i < data.length; i++) {
|
4845
|
+
newData[i] = _deconstructPacket(data[i]);
|
4846
|
+
}
|
4847
|
+
return newData;
|
4848
|
+
} else if ('object' == typeof data && !(data instanceof Date)) {
|
4849
|
+
var newData = {};
|
4850
|
+
for (var key in data) {
|
4851
|
+
newData[key] = _deconstructPacket(data[key]);
|
4852
|
+
}
|
4853
|
+
return newData;
|
4792
4854
|
}
|
4855
|
+
return data;
|
4856
|
+
}
|
4793
4857
|
|
4794
|
-
|
4795
|
-
|
4796
|
-
|
4797
|
-
|
4798
|
-
}
|
4858
|
+
var pack = packet;
|
4859
|
+
pack.data = _deconstructPacket(packetData);
|
4860
|
+
pack.attachments = buffers.length; // number of binary 'attachments'
|
4861
|
+
return {packet: pack, buffers: buffers};
|
4862
|
+
};
|
4799
4863
|
|
4800
4864
|
/**
|
4801
4865
|
* Reconstructs a binary packet from its placeholder packet and buffers
|
@@ -4806,31 +4870,31 @@ exports.deconstructPacket = function(packet) {
|
|
4806
4870
|
* @api public
|
4807
4871
|
*/
|
4808
4872
|
|
4809
|
-
|
4810
|
-
|
4873
|
+
exports.reconstructPacket = function(packet, buffers) {
|
4874
|
+
var curPlaceHolder = 0;
|
4811
4875
|
|
4812
|
-
|
4813
|
-
|
4814
|
-
|
4815
|
-
|
4816
|
-
|
4817
|
-
|
4818
|
-
|
4819
|
-
|
4820
|
-
|
4821
|
-
|
4822
|
-
|
4823
|
-
|
4824
|
-
|
4825
|
-
|
4826
|
-
}
|
4827
|
-
return data;
|
4876
|
+
function _reconstructPacket(data) {
|
4877
|
+
if (data && data._placeholder) {
|
4878
|
+
var buf = buffers[data.num]; // appropriate buffer (should be natural order anyway)
|
4879
|
+
return buf;
|
4880
|
+
} else if (isArray(data)) {
|
4881
|
+
for (var i = 0; i < data.length; i++) {
|
4882
|
+
data[i] = _reconstructPacket(data[i]);
|
4883
|
+
}
|
4884
|
+
return data;
|
4885
|
+
} else if (data && 'object' == typeof data) {
|
4886
|
+
for (var key in data) {
|
4887
|
+
data[key] = _reconstructPacket(data[key]);
|
4888
|
+
}
|
4889
|
+
return data;
|
4828
4890
|
}
|
4891
|
+
return data;
|
4892
|
+
}
|
4829
4893
|
|
4830
|
-
|
4831
|
-
|
4832
|
-
|
4833
|
-
|
4894
|
+
packet.data = _reconstructPacket(packet.data);
|
4895
|
+
packet.attachments = undefined; // no longer useful
|
4896
|
+
return packet;
|
4897
|
+
};
|
4834
4898
|
|
4835
4899
|
/**
|
4836
4900
|
* Asynchronously removes Blobs or Files from data via
|
@@ -4843,8 +4907,7 @@ exports.deconstructPacket = function(packet) {
|
|
4843
4907
|
*/
|
4844
4908
|
|
4845
4909
|
exports.removeBlobs = function(data, callback) {
|
4846
|
-
|
4847
|
-
function removeBlobsRecursive(obj, curKey, containingObject) {
|
4910
|
+
function _removeBlobs(obj, curKey, containingObject) {
|
4848
4911
|
if (!obj) return obj;
|
4849
4912
|
|
4850
4913
|
// convert any blob
|
@@ -4869,48 +4932,38 @@ exports.removeBlobs = function(data, callback) {
|
|
4869
4932
|
};
|
4870
4933
|
|
4871
4934
|
fileReader.readAsArrayBuffer(obj); // blob -> arraybuffer
|
4872
|
-
}
|
4873
|
-
|
4874
|
-
if (isArray(obj)) { // handle array
|
4935
|
+
} else if (isArray(obj)) { // handle array
|
4875
4936
|
for (var i = 0; i < obj.length; i++) {
|
4876
|
-
|
4937
|
+
_removeBlobs(obj[i], i, obj);
|
4877
4938
|
}
|
4878
4939
|
} else if (obj && 'object' == typeof obj && !isBuf(obj)) { // and object
|
4879
4940
|
for (var key in obj) {
|
4880
|
-
|
4941
|
+
_removeBlobs(obj[key], key, obj);
|
4881
4942
|
}
|
4882
4943
|
}
|
4883
4944
|
}
|
4884
4945
|
|
4885
4946
|
var pendingBlobs = 0;
|
4886
4947
|
var bloblessData = data;
|
4887
|
-
|
4948
|
+
_removeBlobs(bloblessData);
|
4888
4949
|
if (!pendingBlobs) {
|
4889
4950
|
callback(bloblessData);
|
4890
4951
|
}
|
4891
|
-
}
|
4952
|
+
};
|
4892
4953
|
|
4893
|
-
|
4894
|
-
|
4895
|
-
*
|
4896
|
-
* @api private
|
4897
|
-
*/
|
4898
|
-
function isBuf(obj) {
|
4899
|
-
return (global.Buffer && Buffer.isBuffer(obj)) ||
|
4900
|
-
(global.ArrayBuffer && obj instanceof ArrayBuffer);
|
4901
|
-
}
|
4954
|
+
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
4955
|
+
},{"./is-buffer":41,"isarray":42}],40:[function(_dereq_,module,exports){
|
4902
4956
|
|
4903
|
-
},{"isarray":41}],40:[function(require,module,exports){
|
4904
|
-
var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
|
4905
4957
|
/**
|
4906
4958
|
* Module dependencies.
|
4907
4959
|
*/
|
4908
4960
|
|
4909
|
-
var debug =
|
4910
|
-
var json =
|
4911
|
-
var isArray =
|
4912
|
-
var Emitter =
|
4913
|
-
var binary =
|
4961
|
+
var debug = _dereq_('debug')('socket.io-parser');
|
4962
|
+
var json = _dereq_('json3');
|
4963
|
+
var isArray = _dereq_('isarray');
|
4964
|
+
var Emitter = _dereq_('component-emitter');
|
4965
|
+
var binary = _dereq_('./binary');
|
4966
|
+
var isBuf = _dereq_('./is-buffer');
|
4914
4967
|
|
4915
4968
|
/**
|
4916
4969
|
* Protocol version.
|
@@ -4918,7 +4971,7 @@ var binary = require('./binary');
|
|
4918
4971
|
* @api public
|
4919
4972
|
*/
|
4920
4973
|
|
4921
|
-
exports.protocol =
|
4974
|
+
exports.protocol = 4;
|
4922
4975
|
|
4923
4976
|
/**
|
4924
4977
|
* Packet types.
|
@@ -4992,14 +5045,29 @@ exports.BINARY_EVENT = 5;
|
|
4992
5045
|
|
4993
5046
|
exports.BINARY_ACK = 6;
|
4994
5047
|
|
4995
|
-
|
5048
|
+
/**
|
5049
|
+
* Encoder constructor.
|
5050
|
+
*
|
5051
|
+
* @api public
|
5052
|
+
*/
|
5053
|
+
|
5054
|
+
exports.Encoder = Encoder;
|
5055
|
+
|
5056
|
+
/**
|
5057
|
+
* Decoder constructor.
|
5058
|
+
*
|
5059
|
+
* @api public
|
5060
|
+
*/
|
5061
|
+
|
5062
|
+
exports.Decoder = Decoder;
|
4996
5063
|
|
4997
5064
|
/**
|
4998
5065
|
* A socket.io Encoder instance
|
4999
5066
|
*
|
5000
5067
|
* @api public
|
5001
5068
|
*/
|
5002
|
-
|
5069
|
+
|
5070
|
+
function Encoder() {}
|
5003
5071
|
|
5004
5072
|
/**
|
5005
5073
|
* Encode a packet as a single string if non-binary, or as a
|
@@ -5094,8 +5162,6 @@ function encodeAsBinary(obj, callback) {
|
|
5094
5162
|
binary.removeBlobs(obj, writeEncoding);
|
5095
5163
|
}
|
5096
5164
|
|
5097
|
-
exports.Decoder = Decoder
|
5098
|
-
|
5099
5165
|
/**
|
5100
5166
|
* A socket.io Decoder instance
|
5101
5167
|
*
|
@@ -5136,9 +5202,7 @@ Decoder.prototype.add = function(obj) {
|
|
5136
5202
|
this.emit('decoded', packet);
|
5137
5203
|
}
|
5138
5204
|
}
|
5139
|
-
else if ((
|
5140
|
-
(global.ArrayBuffer && obj instanceof ArrayBuffer) ||
|
5141
|
-
obj.base64) { // raw binary data
|
5205
|
+
else if (isBuf(obj) || obj.base64) { // raw binary data
|
5142
5206
|
if (!this.reconstructor) {
|
5143
5207
|
throw new Error('got binary data when not reconstructing a packet');
|
5144
5208
|
} else {
|
@@ -5152,7 +5216,7 @@ Decoder.prototype.add = function(obj) {
|
|
5152
5216
|
else {
|
5153
5217
|
throw new Error('Unknown type: ' + obj);
|
5154
5218
|
}
|
5155
|
-
}
|
5219
|
+
};
|
5156
5220
|
|
5157
5221
|
/**
|
5158
5222
|
* Decode a packet String (JSON data)
|
@@ -5219,7 +5283,7 @@ function decodeString(str) {
|
|
5219
5283
|
|
5220
5284
|
debug('decoded %s as %j', str, p);
|
5221
5285
|
return p;
|
5222
|
-
}
|
5286
|
+
}
|
5223
5287
|
|
5224
5288
|
/**
|
5225
5289
|
* Deallocates a parser's resources
|
@@ -5231,7 +5295,7 @@ Decoder.prototype.destroy = function() {
|
|
5231
5295
|
if (this.reconstructor) {
|
5232
5296
|
this.reconstructor.finishedReconstruction();
|
5233
5297
|
}
|
5234
|
-
}
|
5298
|
+
};
|
5235
5299
|
|
5236
5300
|
/**
|
5237
5301
|
* A manager of a binary event's 'buffer sequence'. Should
|
@@ -5266,7 +5330,7 @@ BinaryReconstructor.prototype.takeBinaryData = function(binData) {
|
|
5266
5330
|
return packet;
|
5267
5331
|
}
|
5268
5332
|
return null;
|
5269
|
-
}
|
5333
|
+
};
|
5270
5334
|
|
5271
5335
|
/**
|
5272
5336
|
* Cleans up binary packet reconstruction variables.
|
@@ -5277,7 +5341,7 @@ BinaryReconstructor.prototype.takeBinaryData = function(binData) {
|
|
5277
5341
|
BinaryReconstructor.prototype.finishedReconstruction = function() {
|
5278
5342
|
this.reconPack = null;
|
5279
5343
|
this.buffers = [];
|
5280
|
-
}
|
5344
|
+
};
|
5281
5345
|
|
5282
5346
|
function error(data){
|
5283
5347
|
return {
|
@@ -5286,9 +5350,26 @@ function error(data){
|
|
5286
5350
|
};
|
5287
5351
|
}
|
5288
5352
|
|
5289
|
-
},{"./binary":39,"
|
5290
|
-
|
5291
|
-
|
5353
|
+
},{"./binary":39,"./is-buffer":41,"component-emitter":8,"debug":9,"isarray":42,"json3":43}],41:[function(_dereq_,module,exports){
|
5354
|
+
(function (global){
|
5355
|
+
|
5356
|
+
module.exports = isBuf;
|
5357
|
+
|
5358
|
+
/**
|
5359
|
+
* Returns true if obj is a buffer or an arraybuffer.
|
5360
|
+
*
|
5361
|
+
* @api private
|
5362
|
+
*/
|
5363
|
+
|
5364
|
+
function isBuf(obj) {
|
5365
|
+
return (global.Buffer && global.Buffer.isBuffer(obj)) ||
|
5366
|
+
(global.ArrayBuffer && obj instanceof ArrayBuffer);
|
5367
|
+
}
|
5368
|
+
|
5369
|
+
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
5370
|
+
},{}],42:[function(_dereq_,module,exports){
|
5371
|
+
module.exports=_dereq_(33)
|
5372
|
+
},{}],43:[function(_dereq_,module,exports){
|
5292
5373
|
/*! JSON v3.2.6 | http://bestiejs.github.io/json3 | Copyright 2012-2013, Kit Cambridge | http://kit.mit-license.org */
|
5293
5374
|
;(function (window) {
|
5294
5375
|
// Convenience aliases.
|
@@ -6151,7 +6232,7 @@ module.exports=require(33)
|
|
6151
6232
|
}
|
6152
6233
|
}(this));
|
6153
6234
|
|
6154
|
-
},{}],
|
6235
|
+
},{}],44:[function(_dereq_,module,exports){
|
6155
6236
|
module.exports = toArray
|
6156
6237
|
|
6157
6238
|
function toArray(list, index) {
|
@@ -6169,4 +6250,3 @@ function toArray(list, index) {
|
|
6169
6250
|
},{}]},{},[1])
|
6170
6251
|
(1)
|
6171
6252
|
});
|
6172
|
-
;
|