@ntlab/ntjs-assets 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/js/bootstrap-icons/bootstrap-icons.svg +1 -1
- package/assets/js/bootstrap-icons/folder-plus.svg +2 -2
- package/assets/js/bootstrap-icons/font/bootstrap-icons.css +1981 -0
- package/assets/js/bootstrap-icons/font/bootstrap-icons.json +1955 -0
- package/assets/js/bootstrap-icons/font/bootstrap-icons.min.css +5 -0
- package/assets/js/bootstrap-icons/font/bootstrap-icons.scss +1993 -0
- package/assets/js/bootstrap-icons/font/fonts/bootstrap-icons.woff +0 -0
- package/assets/js/bootstrap-icons/font/fonts/bootstrap-icons.woff2 +0 -0
- package/assets/js/bootstrap-icons/postcard-heart-fill.svg +1 -1
- package/assets/js/bootstrap-icons/trash.svg +2 -2
- package/assets/js/jquery/jquery.js +840 -1045
- package/assets/js/jquery/jquery.min.js +2 -2
- package/assets/js/jquery/jquery.min.map +1 -1
- package/assets/js/jquery/jquery.slim.js +834 -1039
- package/assets/js/jquery/jquery.slim.min.js +2 -2
- package/assets/js/jquery/jquery.slim.min.map +1 -1
- package/assets/js/popper.js/cjs/enums.js +1 -1
- package/assets/js/popper.js/cjs/popper-base.js +12 -170
- package/assets/js/popper.js/cjs/popper-base.js.map +1 -1
- package/assets/js/popper.js/cjs/popper-lite.js +14 -184
- package/assets/js/popper.js/cjs/popper-lite.js.map +1 -1
- package/assets/js/popper.js/cjs/popper.js +14 -197
- package/assets/js/popper.js/cjs/popper.js.map +1 -1
- package/assets/js/popper.js/esm/createPopper.js +6 -66
- package/assets/js/popper.js/esm/modifiers/arrow.js +1 -12
- package/assets/js/popper.js/esm/modifiers/computeStyles.js +2 -14
- package/assets/js/popper.js/esm/utils/computeAutoPlacement.js +0 -4
- package/assets/js/popper.js/esm/utils/userAgent.js +1 -1
- package/assets/js/popper.js/umd/enums.js +1 -1
- package/assets/js/popper.js/umd/enums.min.js +1 -1
- package/assets/js/popper.js/umd/popper-base.js +12 -170
- package/assets/js/popper.js/umd/popper-base.js.map +1 -1
- package/assets/js/popper.js/umd/popper-base.min.js +2 -2
- package/assets/js/popper.js/umd/popper-base.min.js.map +1 -1
- package/assets/js/popper.js/umd/popper-lite.js +14 -184
- package/assets/js/popper.js/umd/popper-lite.js.map +1 -1
- package/assets/js/popper.js/umd/popper-lite.min.js +2 -2
- package/assets/js/popper.js/umd/popper-lite.min.js.map +1 -1
- package/assets/js/popper.js/umd/popper.js +14 -197
- package/assets/js/popper.js/umd/popper.js.map +1 -1
- package/assets/js/popper.js/umd/popper.min.js +2 -2
- package/assets/js/popper.js/umd/popper.min.js.map +1 -1
- package/assets/js/semantic-ui/components/accordion.css +196 -74
- package/assets/js/semantic-ui/components/accordion.js +570 -591
- package/assets/js/semantic-ui/components/accordion.min.css +4 -4
- package/assets/js/semantic-ui/components/accordion.min.js +6 -6
- package/assets/js/semantic-ui/components/ad.css +40 -51
- package/assets/js/semantic-ui/components/ad.min.css +4 -4
- package/assets/js/semantic-ui/components/api.js +1154 -1117
- package/assets/js/semantic-ui/components/api.min.js +6 -6
- package/assets/js/semantic-ui/components/breadcrumb.css +7 -7
- package/assets/js/semantic-ui/components/breadcrumb.min.css +4 -4
- package/assets/js/semantic-ui/components/button.css +895 -1227
- package/assets/js/semantic-ui/components/button.min.css +4 -4
- package/assets/js/semantic-ui/components/calendar.css +60 -33
- package/assets/js/semantic-ui/components/calendar.js +1952 -1575
- package/assets/js/semantic-ui/components/calendar.min.css +4 -4
- package/assets/js/semantic-ui/components/calendar.min.js +6 -6
- package/assets/js/semantic-ui/components/card.css +1004 -441
- package/assets/js/semantic-ui/components/card.min.css +4 -4
- package/assets/js/semantic-ui/components/checkbox.css +275 -303
- package/assets/js/semantic-ui/components/checkbox.js +863 -855
- package/assets/js/semantic-ui/components/checkbox.min.css +4 -4
- package/assets/js/semantic-ui/components/checkbox.min.js +6 -6
- package/assets/js/semantic-ui/components/comment.css +45 -63
- package/assets/js/semantic-ui/components/comment.min.css +4 -4
- package/assets/js/semantic-ui/components/container.css +98 -4
- package/assets/js/semantic-ui/components/container.min.css +4 -4
- package/assets/js/semantic-ui/components/dimmer.css +95 -196
- package/assets/js/semantic-ui/components/dimmer.js +698 -717
- package/assets/js/semantic-ui/components/dimmer.min.css +4 -4
- package/assets/js/semantic-ui/components/dimmer.min.js +6 -6
- package/assets/js/semantic-ui/components/divider.css +75 -93
- package/assets/js/semantic-ui/components/divider.min.css +4 -4
- package/assets/js/semantic-ui/components/dropdown.css +490 -413
- package/assets/js/semantic-ui/components/dropdown.js +4203 -4068
- package/assets/js/semantic-ui/components/dropdown.min.css +4 -4
- package/assets/js/semantic-ui/components/dropdown.min.js +6 -6
- package/assets/js/semantic-ui/components/embed.css +27 -38
- package/assets/js/semantic-ui/components/embed.js +647 -673
- package/assets/js/semantic-ui/components/embed.min.css +4 -4
- package/assets/js/semantic-ui/components/embed.min.js +6 -6
- package/assets/js/semantic-ui/components/emoji.css +11156 -9192
- package/assets/js/semantic-ui/components/emoji.min.css +3 -3
- package/assets/js/semantic-ui/components/feed.css +56 -78
- package/assets/js/semantic-ui/components/feed.min.css +4 -4
- package/assets/js/semantic-ui/components/flag.css +1037 -929
- package/assets/js/semantic-ui/components/flag.min.css +4 -4
- package/assets/js/semantic-ui/components/flyout.css +552 -0
- package/assets/js/semantic-ui/components/flyout.js +1567 -0
- package/assets/js/semantic-ui/components/flyout.min.css +9 -0
- package/assets/js/semantic-ui/components/flyout.min.js +11 -0
- package/assets/js/semantic-ui/components/form.css +536 -530
- package/assets/js/semantic-ui/components/form.js +2037 -1945
- package/assets/js/semantic-ui/components/form.min.css +4 -4
- package/assets/js/semantic-ui/components/form.min.js +6 -6
- package/assets/js/semantic-ui/components/grid.css +218 -345
- package/assets/js/semantic-ui/components/grid.min.css +4 -4
- package/assets/js/semantic-ui/components/header.css +137 -154
- package/assets/js/semantic-ui/components/header.min.css +4 -4
- package/assets/js/semantic-ui/components/icon.css +3000 -2750
- package/assets/js/semantic-ui/components/icon.min.css +4 -4
- package/assets/js/semantic-ui/components/image.css +54 -49
- package/assets/js/semantic-ui/components/image.min.css +4 -4
- package/assets/js/semantic-ui/components/input.css +1081 -227
- package/assets/js/semantic-ui/components/input.min.css +4 -4
- package/assets/js/semantic-ui/components/item.css +91 -138
- package/assets/js/semantic-ui/components/item.min.css +4 -4
- package/assets/js/semantic-ui/components/label.css +470 -481
- package/assets/js/semantic-ui/components/label.min.css +4 -4
- package/assets/js/semantic-ui/components/list.css +93 -114
- package/assets/js/semantic-ui/components/list.min.css +4 -4
- package/assets/js/semantic-ui/components/loader.css +452 -536
- package/assets/js/semantic-ui/components/loader.min.css +4 -4
- package/assets/js/semantic-ui/components/menu.css +408 -510
- package/assets/js/semantic-ui/components/menu.min.css +9 -1
- package/assets/js/semantic-ui/components/message.css +188 -213
- package/assets/js/semantic-ui/components/message.min.css +4 -4
- package/assets/js/semantic-ui/components/modal.css +174 -166
- package/assets/js/semantic-ui/components/modal.js +1558 -1146
- package/assets/js/semantic-ui/components/modal.min.css +4 -4
- package/assets/js/semantic-ui/components/modal.min.js +6 -6
- package/assets/js/semantic-ui/components/nag.css +183 -41
- package/assets/js/semantic-ui/components/nag.js +527 -467
- package/assets/js/semantic-ui/components/nag.min.css +4 -4
- package/assets/js/semantic-ui/components/nag.min.js +6 -6
- package/assets/js/semantic-ui/components/placeholder.css +62 -76
- package/assets/js/semantic-ui/components/placeholder.min.css +4 -4
- package/assets/js/semantic-ui/components/popup.css +681 -312
- package/assets/js/semantic-ui/components/popup.js +1470 -1463
- package/assets/js/semantic-ui/components/popup.min.css +4 -4
- package/assets/js/semantic-ui/components/popup.min.js +6 -6
- package/assets/js/semantic-ui/components/progress.css +149 -217
- package/assets/js/semantic-ui/components/progress.js +945 -1002
- package/assets/js/semantic-ui/components/progress.min.css +4 -4
- package/assets/js/semantic-ui/components/progress.min.js +6 -6
- package/assets/js/semantic-ui/components/rail.css +17 -22
- package/assets/js/semantic-ui/components/rail.min.css +3 -3
- package/assets/js/semantic-ui/components/rating.css +89 -184
- package/assets/js/semantic-ui/components/rating.js +509 -521
- package/assets/js/semantic-ui/components/rating.min.css +4 -4
- package/assets/js/semantic-ui/components/rating.min.js +6 -6
- package/assets/js/semantic-ui/components/reset.css +12 -17
- package/assets/js/semantic-ui/components/reset.min.css +4 -4
- package/assets/js/semantic-ui/components/reveal.css +46 -85
- package/assets/js/semantic-ui/components/reveal.min.css +4 -4
- package/assets/js/semantic-ui/components/search.css +157 -96
- package/assets/js/semantic-ui/components/search.js +1522 -1479
- package/assets/js/semantic-ui/components/search.min.css +4 -4
- package/assets/js/semantic-ui/components/search.min.js +6 -6
- package/assets/js/semantic-ui/components/segment.css +317 -249
- package/assets/js/semantic-ui/components/segment.min.css +4 -4
- package/assets/js/semantic-ui/components/shape.css +16 -32
- package/assets/js/semantic-ui/components/shape.js +763 -812
- package/assets/js/semantic-ui/components/shape.min.css +4 -4
- package/assets/js/semantic-ui/components/shape.min.js +6 -6
- package/assets/js/semantic-ui/components/sidebar.css +128 -216
- package/assets/js/semantic-ui/components/sidebar.js +1042 -1003
- package/assets/js/semantic-ui/components/sidebar.min.css +4 -4
- package/assets/js/semantic-ui/components/sidebar.min.js +6 -6
- package/assets/js/semantic-ui/components/site.css +123 -48
- package/assets/js/semantic-ui/components/site.js +438 -478
- package/assets/js/semantic-ui/components/site.min.css +4 -4
- package/assets/js/semantic-ui/components/site.min.js +6 -6
- package/assets/js/semantic-ui/components/slider.css +133 -141
- package/assets/js/semantic-ui/components/slider.js +1312 -1274
- package/assets/js/semantic-ui/components/slider.min.css +9 -1
- package/assets/js/semantic-ui/components/slider.min.js +6 -6
- package/assets/js/semantic-ui/components/state.js +640 -659
- package/assets/js/semantic-ui/components/state.min.js +6 -6
- package/assets/js/semantic-ui/components/statistic.css +83 -124
- package/assets/js/semantic-ui/components/statistic.min.css +4 -4
- package/assets/js/semantic-ui/components/step.css +118 -184
- package/assets/js/semantic-ui/components/step.min.css +4 -4
- package/assets/js/semantic-ui/components/sticky.css +3 -8
- package/assets/js/semantic-ui/components/sticky.js +849 -892
- package/assets/js/semantic-ui/components/sticky.min.css +4 -4
- package/assets/js/semantic-ui/components/sticky.min.js +6 -6
- package/assets/js/semantic-ui/components/tab.css +16 -20
- package/assets/js/semantic-ui/components/tab.js +896 -941
- package/assets/js/semantic-ui/components/tab.min.css +4 -4
- package/assets/js/semantic-ui/components/tab.min.js +6 -6
- package/assets/js/semantic-ui/components/table.css +2073 -884
- package/assets/js/semantic-ui/components/table.min.css +4 -4
- package/assets/js/semantic-ui/components/text.css +51 -30
- package/assets/js/semantic-ui/components/text.min.css +4 -4
- package/assets/js/semantic-ui/components/toast.css +200 -137
- package/assets/js/semantic-ui/components/toast.js +912 -832
- package/assets/js/semantic-ui/components/toast.min.css +4 -4
- package/assets/js/semantic-ui/components/toast.min.js +6 -6
- package/assets/js/semantic-ui/components/transition.css +371 -1282
- package/assets/js/semantic-ui/components/transition.js +999 -1074
- package/assets/js/semantic-ui/components/transition.min.css +4 -4
- package/assets/js/semantic-ui/components/transition.min.js +6 -6
- package/assets/js/semantic-ui/components/visibility.js +1215 -1247
- package/assets/js/semantic-ui/components/visibility.min.js +6 -6
- package/assets/js/semantic-ui/semantic.css +43777 -37429
- package/assets/js/semantic-ui/semantic.js +29152 -26694
- package/assets/js/semantic-ui/semantic.min.css +6 -399
- package/assets/js/semantic-ui/semantic.min.js +6 -6
- package/assets/js/semantic-ui/themes/basic/assets/fonts/icons.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Bold.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Bold.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-BoldItalic.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-BoldItalic.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Italic.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Italic.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Regular.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Regular.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Bold.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Bold.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-BoldItalic.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-BoldItalic.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Italic.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Italic.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Regular.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Regular.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/brand-icons.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/brand-icons.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/icons.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/icons.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/outline-icons.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/outline-icons.woff2 +0 -0
- package/assets/js/semantic-ui/themes/famfamfam/assets/images/flags.png +0 -0
- package/assets/js/semantic-ui/themes/github/assets/fonts/octicons.woff2 +0 -0
- package/assets/js/socket.io/socket.io.esm.min.js +3 -3
- package/assets/js/socket.io/socket.io.esm.min.js.map +1 -1
- package/assets/js/socket.io/socket.io.js +841 -333
- package/assets/js/socket.io/socket.io.js.map +1 -1
- package/assets/js/socket.io/socket.io.min.js +3 -3
- package/assets/js/socket.io/socket.io.min.js.map +1 -1
- package/assets/js/socket.io/socket.io.msgpack.min.js +3 -3
- package/assets/js/socket.io/socket.io.msgpack.min.js.map +1 -1
- package/cdn.json +19 -4
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Socket.IO v4.
|
|
3
|
-
* (c) 2014-
|
|
2
|
+
* Socket.IO v4.7.0
|
|
3
|
+
* (c) 2014-2023 Guillermo Rauch
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
(function (global, factory) {
|
|
@@ -12,17 +12,11 @@
|
|
|
12
12
|
function _typeof(obj) {
|
|
13
13
|
"@babel/helpers - typeof";
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
_typeof = function (obj) {
|
|
21
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return _typeof(obj);
|
|
15
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
16
|
+
return typeof obj;
|
|
17
|
+
} : function (obj) {
|
|
18
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
19
|
+
}, _typeof(obj);
|
|
26
20
|
}
|
|
27
21
|
|
|
28
22
|
function _classCallCheck(instance, Constructor) {
|
|
@@ -44,11 +38,14 @@
|
|
|
44
38
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
45
39
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
46
40
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
41
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
42
|
+
writable: false
|
|
43
|
+
});
|
|
47
44
|
return Constructor;
|
|
48
45
|
}
|
|
49
46
|
|
|
50
47
|
function _extends() {
|
|
51
|
-
_extends = Object.assign
|
|
48
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
52
49
|
for (var i = 1; i < arguments.length; i++) {
|
|
53
50
|
var source = arguments[i];
|
|
54
51
|
|
|
@@ -61,7 +58,6 @@
|
|
|
61
58
|
|
|
62
59
|
return target;
|
|
63
60
|
};
|
|
64
|
-
|
|
65
61
|
return _extends.apply(this, arguments);
|
|
66
62
|
}
|
|
67
63
|
|
|
@@ -77,22 +73,24 @@
|
|
|
77
73
|
configurable: true
|
|
78
74
|
}
|
|
79
75
|
});
|
|
76
|
+
Object.defineProperty(subClass, "prototype", {
|
|
77
|
+
writable: false
|
|
78
|
+
});
|
|
80
79
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
function _getPrototypeOf(o) {
|
|
84
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
83
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
85
84
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
86
85
|
};
|
|
87
86
|
return _getPrototypeOf(o);
|
|
88
87
|
}
|
|
89
88
|
|
|
90
89
|
function _setPrototypeOf(o, p) {
|
|
91
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
90
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
92
91
|
o.__proto__ = p;
|
|
93
92
|
return o;
|
|
94
93
|
};
|
|
95
|
-
|
|
96
94
|
return _setPrototypeOf(o, p);
|
|
97
95
|
}
|
|
98
96
|
|
|
@@ -111,7 +109,7 @@
|
|
|
111
109
|
|
|
112
110
|
function _construct(Parent, args, Class) {
|
|
113
111
|
if (_isNativeReflectConstruct()) {
|
|
114
|
-
_construct = Reflect.construct;
|
|
112
|
+
_construct = Reflect.construct.bind();
|
|
115
113
|
} else {
|
|
116
114
|
_construct = function _construct(Parent, args, Class) {
|
|
117
115
|
var a = [null];
|
|
@@ -210,9 +208,9 @@
|
|
|
210
208
|
return object;
|
|
211
209
|
}
|
|
212
210
|
|
|
213
|
-
function _get(
|
|
211
|
+
function _get() {
|
|
214
212
|
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
215
|
-
_get = Reflect.get;
|
|
213
|
+
_get = Reflect.get.bind();
|
|
216
214
|
} else {
|
|
217
215
|
_get = function _get(target, property, receiver) {
|
|
218
216
|
var base = _superPropBase(target, property);
|
|
@@ -221,14 +219,14 @@
|
|
|
221
219
|
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
222
220
|
|
|
223
221
|
if (desc.get) {
|
|
224
|
-
return desc.get.call(receiver);
|
|
222
|
+
return desc.get.call(arguments.length < 3 ? target : receiver);
|
|
225
223
|
}
|
|
226
224
|
|
|
227
225
|
return desc.value;
|
|
228
226
|
};
|
|
229
227
|
}
|
|
230
228
|
|
|
231
|
-
return _get(
|
|
229
|
+
return _get.apply(this, arguments);
|
|
232
230
|
}
|
|
233
231
|
|
|
234
232
|
function _unsupportedIterableToArray(o, minLen) {
|
|
@@ -357,17 +355,40 @@
|
|
|
357
355
|
|
|
358
356
|
fileReader.onload = function () {
|
|
359
357
|
var content = fileReader.result.split(",")[1];
|
|
360
|
-
callback("b" + content);
|
|
358
|
+
callback("b" + (content || ""));
|
|
361
359
|
};
|
|
362
360
|
|
|
363
361
|
return fileReader.readAsDataURL(data);
|
|
364
362
|
};
|
|
365
363
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
364
|
+
function toArray(data) {
|
|
365
|
+
if (data instanceof Uint8Array) {
|
|
366
|
+
return data;
|
|
367
|
+
} else if (data instanceof ArrayBuffer) {
|
|
368
|
+
return new Uint8Array(data);
|
|
369
|
+
} else {
|
|
370
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
var TEXT_ENCODER;
|
|
375
|
+
function encodePacketToBinary(packet, callback) {
|
|
376
|
+
if (withNativeBlob$1 && packet.data instanceof Blob) {
|
|
377
|
+
return packet.data.arrayBuffer().then(toArray).then(callback);
|
|
378
|
+
} else if (withNativeArrayBuffer$2 && (packet.data instanceof ArrayBuffer || isView$1(packet.data))) {
|
|
379
|
+
return callback(toArray(packet.data));
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
encodePacket(packet, false, function (encoded) {
|
|
383
|
+
if (!TEXT_ENCODER) {
|
|
384
|
+
TEXT_ENCODER = new TextEncoder();
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
callback(TEXT_ENCODER.encode(encoded));
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// imported from https://github.com/socketio/base64-arraybuffer
|
|
371
392
|
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; // Use a lookup table to find the index.
|
|
372
393
|
|
|
373
394
|
var lookup$1 = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);
|
|
@@ -375,7 +396,6 @@
|
|
|
375
396
|
for (var i$1 = 0; i$1 < chars.length; i$1++) {
|
|
376
397
|
lookup$1[chars.charCodeAt(i$1)] = i$1;
|
|
377
398
|
}
|
|
378
|
-
|
|
379
399
|
var decode$1 = function decode(base64) {
|
|
380
400
|
var bufferLength = base64.length * 0.75,
|
|
381
401
|
len = base64.length,
|
|
@@ -411,7 +431,6 @@
|
|
|
411
431
|
};
|
|
412
432
|
|
|
413
433
|
var withNativeArrayBuffer$1 = typeof ArrayBuffer === "function";
|
|
414
|
-
|
|
415
434
|
var decodePacket = function decodePacket(encodedPacket, binaryType) {
|
|
416
435
|
if (typeof encodedPacket !== "string") {
|
|
417
436
|
return {
|
|
@@ -458,12 +477,24 @@
|
|
|
458
477
|
var mapBinary = function mapBinary(data, binaryType) {
|
|
459
478
|
switch (binaryType) {
|
|
460
479
|
case "blob":
|
|
461
|
-
|
|
480
|
+
if (data instanceof Blob) {
|
|
481
|
+
// from WebSocket + binaryType "blob"
|
|
482
|
+
return data;
|
|
483
|
+
} else {
|
|
484
|
+
// from HTTP long-polling or WebTransport
|
|
485
|
+
return new Blob([data]);
|
|
486
|
+
}
|
|
462
487
|
|
|
463
488
|
case "arraybuffer":
|
|
464
489
|
default:
|
|
465
|
-
|
|
466
|
-
|
|
490
|
+
if (data instanceof ArrayBuffer) {
|
|
491
|
+
// from HTTP long-polling (base64) or WebSocket + binaryType "arraybuffer"
|
|
492
|
+
return data;
|
|
493
|
+
} else {
|
|
494
|
+
// from WebTransport (Uint8Array)
|
|
495
|
+
return data.buffer;
|
|
496
|
+
}
|
|
497
|
+
|
|
467
498
|
}
|
|
468
499
|
};
|
|
469
500
|
|
|
@@ -502,6 +533,18 @@
|
|
|
502
533
|
return packets;
|
|
503
534
|
};
|
|
504
535
|
|
|
536
|
+
var TEXT_DECODER;
|
|
537
|
+
function decodePacketFromBinary(data, isBinary, binaryType) {
|
|
538
|
+
if (!TEXT_DECODER) {
|
|
539
|
+
// lazily created for compatibility with old browser platforms
|
|
540
|
+
TEXT_DECODER = new TextDecoder();
|
|
541
|
+
} // 48 === "0".charCodeAt(0) (OPEN packet type)
|
|
542
|
+
// 54 === "6".charCodeAt(0) (NOOP packet type)
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
var isPlainBinary = isBinary || data[0] < 48 || data[0] > 54;
|
|
546
|
+
return decodePacket(isPlainBinary ? data : TEXT_DECODER.decode(data), binaryType);
|
|
547
|
+
}
|
|
505
548
|
var protocol$1 = 4;
|
|
506
549
|
|
|
507
550
|
/**
|
|
@@ -667,7 +710,7 @@
|
|
|
667
710
|
return !!this.listeners(event).length;
|
|
668
711
|
};
|
|
669
712
|
|
|
670
|
-
var
|
|
713
|
+
var globalThisShim = function () {
|
|
671
714
|
if (typeof self !== "undefined") {
|
|
672
715
|
return self;
|
|
673
716
|
} else if (typeof window !== "undefined") {
|
|
@@ -675,7 +718,7 @@
|
|
|
675
718
|
} else {
|
|
676
719
|
return Function("return this")();
|
|
677
720
|
}
|
|
678
|
-
}
|
|
721
|
+
}();
|
|
679
722
|
|
|
680
723
|
function pick(obj) {
|
|
681
724
|
for (var _len = arguments.length, attr = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
@@ -691,15 +734,15 @@
|
|
|
691
734
|
}, {});
|
|
692
735
|
} // Keep a reference to the real timeout functions so they can be used when overridden
|
|
693
736
|
|
|
694
|
-
var NATIVE_SET_TIMEOUT = setTimeout;
|
|
695
|
-
var NATIVE_CLEAR_TIMEOUT = clearTimeout;
|
|
737
|
+
var NATIVE_SET_TIMEOUT = globalThisShim.setTimeout;
|
|
738
|
+
var NATIVE_CLEAR_TIMEOUT = globalThisShim.clearTimeout;
|
|
696
739
|
function installTimerFunctions(obj, opts) {
|
|
697
740
|
if (opts.useNativeTimers) {
|
|
698
|
-
obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(
|
|
699
|
-
obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(
|
|
741
|
+
obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThisShim);
|
|
742
|
+
obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThisShim);
|
|
700
743
|
} else {
|
|
701
|
-
obj.setTimeoutFn = setTimeout.bind(
|
|
702
|
-
obj.clearTimeoutFn = clearTimeout.bind(
|
|
744
|
+
obj.setTimeoutFn = globalThisShim.setTimeout.bind(globalThisShim);
|
|
745
|
+
obj.clearTimeoutFn = globalThisShim.clearTimeout.bind(globalThisShim);
|
|
703
746
|
}
|
|
704
747
|
} // base64 encoded buffers are about 33% bigger (https://en.wikipedia.org/wiki/Base64)
|
|
705
748
|
|
|
@@ -736,6 +779,46 @@
|
|
|
736
779
|
return length;
|
|
737
780
|
}
|
|
738
781
|
|
|
782
|
+
// imported from https://github.com/galkn/querystring
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* Compiles a querystring
|
|
786
|
+
* Returns string representation of the object
|
|
787
|
+
*
|
|
788
|
+
* @param {Object}
|
|
789
|
+
* @api private
|
|
790
|
+
*/
|
|
791
|
+
function encode$1(obj) {
|
|
792
|
+
var str = '';
|
|
793
|
+
|
|
794
|
+
for (var i in obj) {
|
|
795
|
+
if (obj.hasOwnProperty(i)) {
|
|
796
|
+
if (str.length) str += '&';
|
|
797
|
+
str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
return str;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Parses a simple querystring into an object
|
|
805
|
+
*
|
|
806
|
+
* @param {String} qs
|
|
807
|
+
* @api private
|
|
808
|
+
*/
|
|
809
|
+
|
|
810
|
+
function decode(qs) {
|
|
811
|
+
var qry = {};
|
|
812
|
+
var pairs = qs.split('&');
|
|
813
|
+
|
|
814
|
+
for (var i = 0, l = pairs.length; i < l; i++) {
|
|
815
|
+
var pair = pairs[i].split('=');
|
|
816
|
+
qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
return qry;
|
|
820
|
+
}
|
|
821
|
+
|
|
739
822
|
var TransportError = /*#__PURE__*/function (_Error) {
|
|
740
823
|
_inherits(TransportError, _Error);
|
|
741
824
|
|
|
@@ -753,7 +836,7 @@
|
|
|
753
836
|
return _this;
|
|
754
837
|
}
|
|
755
838
|
|
|
756
|
-
return TransportError;
|
|
839
|
+
return _createClass(TransportError);
|
|
757
840
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
758
841
|
|
|
759
842
|
var Transport = /*#__PURE__*/function (_Emitter) {
|
|
@@ -764,8 +847,8 @@
|
|
|
764
847
|
/**
|
|
765
848
|
* Transport abstract constructor.
|
|
766
849
|
*
|
|
767
|
-
* @param {Object} options
|
|
768
|
-
* @
|
|
850
|
+
* @param {Object} opts - options
|
|
851
|
+
* @protected
|
|
769
852
|
*/
|
|
770
853
|
function Transport(opts) {
|
|
771
854
|
var _this2;
|
|
@@ -777,7 +860,6 @@
|
|
|
777
860
|
installTimerFunctions(_assertThisInitialized(_this2), opts);
|
|
778
861
|
_this2.opts = opts;
|
|
779
862
|
_this2.query = opts.query;
|
|
780
|
-
_this2.readyState = "";
|
|
781
863
|
_this2.socket = opts.socket;
|
|
782
864
|
return _this2;
|
|
783
865
|
}
|
|
@@ -788,7 +870,7 @@
|
|
|
788
870
|
* @param description
|
|
789
871
|
* @param context - the error context
|
|
790
872
|
* @return {Transport} for chaining
|
|
791
|
-
* @
|
|
873
|
+
* @protected
|
|
792
874
|
*/
|
|
793
875
|
|
|
794
876
|
|
|
@@ -801,30 +883,23 @@
|
|
|
801
883
|
}
|
|
802
884
|
/**
|
|
803
885
|
* Opens the transport.
|
|
804
|
-
*
|
|
805
|
-
* @api public
|
|
806
886
|
*/
|
|
807
887
|
|
|
808
888
|
}, {
|
|
809
889
|
key: "open",
|
|
810
890
|
value: function open() {
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
this.doOpen();
|
|
814
|
-
}
|
|
815
|
-
|
|
891
|
+
this.readyState = "opening";
|
|
892
|
+
this.doOpen();
|
|
816
893
|
return this;
|
|
817
894
|
}
|
|
818
895
|
/**
|
|
819
896
|
* Closes the transport.
|
|
820
|
-
*
|
|
821
|
-
* @api public
|
|
822
897
|
*/
|
|
823
898
|
|
|
824
899
|
}, {
|
|
825
900
|
key: "close",
|
|
826
901
|
value: function close() {
|
|
827
|
-
if ("opening"
|
|
902
|
+
if (this.readyState === "opening" || this.readyState === "open") {
|
|
828
903
|
this.doClose();
|
|
829
904
|
this.onClose();
|
|
830
905
|
}
|
|
@@ -835,20 +910,19 @@
|
|
|
835
910
|
* Sends multiple packets.
|
|
836
911
|
*
|
|
837
912
|
* @param {Array} packets
|
|
838
|
-
* @api public
|
|
839
913
|
*/
|
|
840
914
|
|
|
841
915
|
}, {
|
|
842
916
|
key: "send",
|
|
843
917
|
value: function send(packets) {
|
|
844
|
-
if ("open"
|
|
918
|
+
if (this.readyState === "open") {
|
|
845
919
|
this.write(packets);
|
|
846
920
|
}
|
|
847
921
|
}
|
|
848
922
|
/**
|
|
849
923
|
* Called upon open
|
|
850
924
|
*
|
|
851
|
-
* @
|
|
925
|
+
* @protected
|
|
852
926
|
*/
|
|
853
927
|
|
|
854
928
|
}, {
|
|
@@ -863,7 +937,7 @@
|
|
|
863
937
|
* Called with data.
|
|
864
938
|
*
|
|
865
939
|
* @param {String} data
|
|
866
|
-
* @
|
|
940
|
+
* @protected
|
|
867
941
|
*/
|
|
868
942
|
|
|
869
943
|
}, {
|
|
@@ -875,7 +949,7 @@
|
|
|
875
949
|
/**
|
|
876
950
|
* Called with a decoded packet.
|
|
877
951
|
*
|
|
878
|
-
* @
|
|
952
|
+
* @protected
|
|
879
953
|
*/
|
|
880
954
|
|
|
881
955
|
}, {
|
|
@@ -886,7 +960,7 @@
|
|
|
886
960
|
/**
|
|
887
961
|
* Called upon close.
|
|
888
962
|
*
|
|
889
|
-
* @
|
|
963
|
+
* @protected
|
|
890
964
|
*/
|
|
891
965
|
|
|
892
966
|
}, {
|
|
@@ -896,6 +970,42 @@
|
|
|
896
970
|
|
|
897
971
|
_get(_getPrototypeOf(Transport.prototype), "emitReserved", this).call(this, "close", details);
|
|
898
972
|
}
|
|
973
|
+
/**
|
|
974
|
+
* Pauses the transport, in order not to lose packets during an upgrade.
|
|
975
|
+
*
|
|
976
|
+
* @param onPause
|
|
977
|
+
*/
|
|
978
|
+
|
|
979
|
+
}, {
|
|
980
|
+
key: "pause",
|
|
981
|
+
value: function pause(onPause) {}
|
|
982
|
+
}, {
|
|
983
|
+
key: "createUri",
|
|
984
|
+
value: function createUri(schema) {
|
|
985
|
+
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
986
|
+
return schema + "://" + this._hostname() + this._port() + this.opts.path + this._query(query);
|
|
987
|
+
}
|
|
988
|
+
}, {
|
|
989
|
+
key: "_hostname",
|
|
990
|
+
value: function _hostname() {
|
|
991
|
+
var hostname = this.opts.hostname;
|
|
992
|
+
return hostname.indexOf(":") === -1 ? hostname : "[" + hostname + "]";
|
|
993
|
+
}
|
|
994
|
+
}, {
|
|
995
|
+
key: "_port",
|
|
996
|
+
value: function _port() {
|
|
997
|
+
if (this.opts.port && (this.opts.secure && Number(this.opts.port !== 443) || !this.opts.secure && Number(this.opts.port) !== 80)) {
|
|
998
|
+
return ":" + this.opts.port;
|
|
999
|
+
} else {
|
|
1000
|
+
return "";
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
}, {
|
|
1004
|
+
key: "_query",
|
|
1005
|
+
value: function _query(query) {
|
|
1006
|
+
var encodedQuery = encode$1(query);
|
|
1007
|
+
return encodedQuery.length ? "?" + encodedQuery : "";
|
|
1008
|
+
}
|
|
899
1009
|
}]);
|
|
900
1010
|
|
|
901
1011
|
return Transport;
|
|
@@ -917,7 +1027,7 @@
|
|
|
917
1027
|
* @api public
|
|
918
1028
|
*/
|
|
919
1029
|
|
|
920
|
-
function encode
|
|
1030
|
+
function encode(num) {
|
|
921
1031
|
var encoded = '';
|
|
922
1032
|
|
|
923
1033
|
do {
|
|
@@ -935,9 +1045,9 @@
|
|
|
935
1045
|
*/
|
|
936
1046
|
|
|
937
1047
|
function yeast() {
|
|
938
|
-
var now = encode
|
|
1048
|
+
var now = encode(+new Date());
|
|
939
1049
|
if (now !== prev) return seed = 0, prev = now;
|
|
940
|
-
return now + '.' + encode
|
|
1050
|
+
return now + '.' + encode(seed++);
|
|
941
1051
|
} //
|
|
942
1052
|
// Map each character to its index.
|
|
943
1053
|
//
|
|
@@ -946,46 +1056,6 @@
|
|
|
946
1056
|
map[alphabet[i]] = i;
|
|
947
1057
|
}
|
|
948
1058
|
|
|
949
|
-
// imported from https://github.com/galkn/querystring
|
|
950
|
-
|
|
951
|
-
/**
|
|
952
|
-
* Compiles a querystring
|
|
953
|
-
* Returns string representation of the object
|
|
954
|
-
*
|
|
955
|
-
* @param {Object}
|
|
956
|
-
* @api private
|
|
957
|
-
*/
|
|
958
|
-
function encode(obj) {
|
|
959
|
-
var str = '';
|
|
960
|
-
|
|
961
|
-
for (var i in obj) {
|
|
962
|
-
if (obj.hasOwnProperty(i)) {
|
|
963
|
-
if (str.length) str += '&';
|
|
964
|
-
str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
return str;
|
|
969
|
-
}
|
|
970
|
-
/**
|
|
971
|
-
* Parses a simple querystring into an object
|
|
972
|
-
*
|
|
973
|
-
* @param {String} qs
|
|
974
|
-
* @api private
|
|
975
|
-
*/
|
|
976
|
-
|
|
977
|
-
function decode(qs) {
|
|
978
|
-
var qry = {};
|
|
979
|
-
var pairs = qs.split('&');
|
|
980
|
-
|
|
981
|
-
for (var i = 0, l = pairs.length; i < l; i++) {
|
|
982
|
-
var pair = pairs[i].split('=');
|
|
983
|
-
qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
return qry;
|
|
987
|
-
}
|
|
988
|
-
|
|
989
1059
|
// imported from https://github.com/component/has-cors
|
|
990
1060
|
var value = false;
|
|
991
1061
|
|
|
@@ -998,7 +1068,7 @@
|
|
|
998
1068
|
var hasCORS = value;
|
|
999
1069
|
|
|
1000
1070
|
// browser shim for xmlhttprequest module
|
|
1001
|
-
function
|
|
1071
|
+
function XHR(opts) {
|
|
1002
1072
|
var xdomain = opts.xdomain; // XMLHttpRequest can be disabled on IE
|
|
1003
1073
|
|
|
1004
1074
|
try {
|
|
@@ -1009,15 +1079,16 @@
|
|
|
1009
1079
|
|
|
1010
1080
|
if (!xdomain) {
|
|
1011
1081
|
try {
|
|
1012
|
-
return new
|
|
1082
|
+
return new globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
|
|
1013
1083
|
} catch (e) {}
|
|
1014
1084
|
}
|
|
1015
1085
|
}
|
|
1086
|
+
function createCookieJar() {}
|
|
1016
1087
|
|
|
1017
1088
|
function empty() {}
|
|
1018
1089
|
|
|
1019
1090
|
var hasXHR2 = function () {
|
|
1020
|
-
var xhr = new
|
|
1091
|
+
var xhr = new XHR({
|
|
1021
1092
|
xdomain: false
|
|
1022
1093
|
});
|
|
1023
1094
|
return null != xhr.responseType;
|
|
@@ -1032,7 +1103,7 @@
|
|
|
1032
1103
|
* XHR Polling constructor.
|
|
1033
1104
|
*
|
|
1034
1105
|
* @param {Object} opts
|
|
1035
|
-
* @
|
|
1106
|
+
* @package
|
|
1036
1107
|
*/
|
|
1037
1108
|
function Polling(opts) {
|
|
1038
1109
|
var _this;
|
|
@@ -1051,7 +1122,6 @@
|
|
|
1051
1122
|
}
|
|
1052
1123
|
|
|
1053
1124
|
_this.xd = typeof location !== "undefined" && opts.hostname !== location.hostname || port !== opts.port;
|
|
1054
|
-
_this.xs = opts.secure !== isSSL;
|
|
1055
1125
|
}
|
|
1056
1126
|
/**
|
|
1057
1127
|
* XHR supports binary
|
|
@@ -1060,12 +1130,13 @@
|
|
|
1060
1130
|
|
|
1061
1131
|
var forceBase64 = opts && opts.forceBase64;
|
|
1062
1132
|
_this.supportsBinary = hasXHR2 && !forceBase64;
|
|
1133
|
+
|
|
1134
|
+
if (_this.opts.withCredentials) {
|
|
1135
|
+
_this.cookieJar = createCookieJar();
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1063
1138
|
return _this;
|
|
1064
1139
|
}
|
|
1065
|
-
/**
|
|
1066
|
-
* Transport name.
|
|
1067
|
-
*/
|
|
1068
|
-
|
|
1069
1140
|
|
|
1070
1141
|
_createClass(Polling, [{
|
|
1071
1142
|
key: "name",
|
|
@@ -1076,7 +1147,7 @@
|
|
|
1076
1147
|
* Opens the socket (triggers polling). We write a PING message to determine
|
|
1077
1148
|
* when the transport is open.
|
|
1078
1149
|
*
|
|
1079
|
-
* @
|
|
1150
|
+
* @protected
|
|
1080
1151
|
*/
|
|
1081
1152
|
|
|
1082
1153
|
}, {
|
|
@@ -1087,8 +1158,8 @@
|
|
|
1087
1158
|
/**
|
|
1088
1159
|
* Pauses polling.
|
|
1089
1160
|
*
|
|
1090
|
-
* @param {Function} callback upon buffers are flushed and transport is paused
|
|
1091
|
-
* @
|
|
1161
|
+
* @param {Function} onPause - callback upon buffers are flushed and transport is paused
|
|
1162
|
+
* @package
|
|
1092
1163
|
*/
|
|
1093
1164
|
|
|
1094
1165
|
}, {
|
|
@@ -1126,7 +1197,7 @@
|
|
|
1126
1197
|
/**
|
|
1127
1198
|
* Starts polling cycle.
|
|
1128
1199
|
*
|
|
1129
|
-
* @
|
|
1200
|
+
* @private
|
|
1130
1201
|
*/
|
|
1131
1202
|
|
|
1132
1203
|
}, {
|
|
@@ -1139,7 +1210,7 @@
|
|
|
1139
1210
|
/**
|
|
1140
1211
|
* Overloads onData to detect payloads.
|
|
1141
1212
|
*
|
|
1142
|
-
* @
|
|
1213
|
+
* @protected
|
|
1143
1214
|
*/
|
|
1144
1215
|
|
|
1145
1216
|
}, {
|
|
@@ -1182,7 +1253,7 @@
|
|
|
1182
1253
|
/**
|
|
1183
1254
|
* For polling, send a close packet.
|
|
1184
1255
|
*
|
|
1185
|
-
* @
|
|
1256
|
+
* @protected
|
|
1186
1257
|
*/
|
|
1187
1258
|
|
|
1188
1259
|
}, {
|
|
@@ -1207,9 +1278,8 @@
|
|
|
1207
1278
|
/**
|
|
1208
1279
|
* Writes a packets payload.
|
|
1209
1280
|
*
|
|
1210
|
-
* @param {Array} data packets
|
|
1211
|
-
* @
|
|
1212
|
-
* @api private
|
|
1281
|
+
* @param {Array} packets - data packets
|
|
1282
|
+
* @protected
|
|
1213
1283
|
*/
|
|
1214
1284
|
|
|
1215
1285
|
}, {
|
|
@@ -1229,15 +1299,14 @@
|
|
|
1229
1299
|
/**
|
|
1230
1300
|
* Generates uri for connection.
|
|
1231
1301
|
*
|
|
1232
|
-
* @
|
|
1302
|
+
* @private
|
|
1233
1303
|
*/
|
|
1234
1304
|
|
|
1235
1305
|
}, {
|
|
1236
1306
|
key: "uri",
|
|
1237
1307
|
value: function uri() {
|
|
1238
|
-
var query = this.query || {};
|
|
1239
1308
|
var schema = this.opts.secure ? "https" : "http";
|
|
1240
|
-
var
|
|
1309
|
+
var query = this.query || {}; // cache busting is forced
|
|
1241
1310
|
|
|
1242
1311
|
if (false !== this.opts.timestampRequests) {
|
|
1243
1312
|
query[this.opts.timestampParam] = yeast();
|
|
@@ -1245,22 +1314,15 @@
|
|
|
1245
1314
|
|
|
1246
1315
|
if (!this.supportsBinary && !query.sid) {
|
|
1247
1316
|
query.b64 = 1;
|
|
1248
|
-
} // avoid port if default for schema
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
if (this.opts.port && ("https" === schema && Number(this.opts.port) !== 443 || "http" === schema && Number(this.opts.port) !== 80)) {
|
|
1252
|
-
port = ":" + this.opts.port;
|
|
1253
1317
|
}
|
|
1254
1318
|
|
|
1255
|
-
|
|
1256
|
-
var ipv6 = this.opts.hostname.indexOf(":") !== -1;
|
|
1257
|
-
return schema + "://" + (ipv6 ? "[" + this.opts.hostname + "]" : this.opts.hostname) + port + this.opts.path + (encodedQuery.length ? "?" + encodedQuery : "");
|
|
1319
|
+
return this.createUri(schema, query);
|
|
1258
1320
|
}
|
|
1259
1321
|
/**
|
|
1260
1322
|
* Creates a request.
|
|
1261
1323
|
*
|
|
1262
1324
|
* @param {String} method
|
|
1263
|
-
* @
|
|
1325
|
+
* @private
|
|
1264
1326
|
*/
|
|
1265
1327
|
|
|
1266
1328
|
}, {
|
|
@@ -1270,7 +1332,7 @@
|
|
|
1270
1332
|
|
|
1271
1333
|
_extends(opts, {
|
|
1272
1334
|
xd: this.xd,
|
|
1273
|
-
|
|
1335
|
+
cookieJar: this.cookieJar
|
|
1274
1336
|
}, this.opts);
|
|
1275
1337
|
|
|
1276
1338
|
return new Request(this.uri(), opts);
|
|
@@ -1280,7 +1342,7 @@
|
|
|
1280
1342
|
*
|
|
1281
1343
|
* @param {String} data to send.
|
|
1282
1344
|
* @param {Function} called upon flush.
|
|
1283
|
-
* @
|
|
1345
|
+
* @private
|
|
1284
1346
|
*/
|
|
1285
1347
|
|
|
1286
1348
|
}, {
|
|
@@ -1300,7 +1362,7 @@
|
|
|
1300
1362
|
/**
|
|
1301
1363
|
* Starts a poll cycle.
|
|
1302
1364
|
*
|
|
1303
|
-
* @
|
|
1365
|
+
* @private
|
|
1304
1366
|
*/
|
|
1305
1367
|
|
|
1306
1368
|
}, {
|
|
@@ -1328,7 +1390,7 @@
|
|
|
1328
1390
|
* Request constructor
|
|
1329
1391
|
*
|
|
1330
1392
|
* @param {Object} options
|
|
1331
|
-
* @
|
|
1393
|
+
* @package
|
|
1332
1394
|
*/
|
|
1333
1395
|
function Request(uri, opts) {
|
|
1334
1396
|
var _this8;
|
|
@@ -1340,7 +1402,6 @@
|
|
|
1340
1402
|
_this8.opts = opts;
|
|
1341
1403
|
_this8.method = opts.method || "GET";
|
|
1342
1404
|
_this8.uri = uri;
|
|
1343
|
-
_this8.async = false !== opts.async;
|
|
1344
1405
|
_this8.data = undefined !== opts.data ? opts.data : null;
|
|
1345
1406
|
|
|
1346
1407
|
_this8.create();
|
|
@@ -1350,7 +1411,7 @@
|
|
|
1350
1411
|
/**
|
|
1351
1412
|
* Creates the XHR object and sends the request.
|
|
1352
1413
|
*
|
|
1353
|
-
* @
|
|
1414
|
+
* @private
|
|
1354
1415
|
*/
|
|
1355
1416
|
|
|
1356
1417
|
|
|
@@ -1359,13 +1420,14 @@
|
|
|
1359
1420
|
value: function create() {
|
|
1360
1421
|
var _this9 = this;
|
|
1361
1422
|
|
|
1423
|
+
var _a;
|
|
1424
|
+
|
|
1362
1425
|
var opts = pick(this.opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
|
|
1363
1426
|
opts.xdomain = !!this.opts.xd;
|
|
1364
|
-
|
|
1365
|
-
var xhr = this.xhr = new XMLHttpRequest$1(opts);
|
|
1427
|
+
var xhr = this.xhr = new XHR(opts);
|
|
1366
1428
|
|
|
1367
1429
|
try {
|
|
1368
|
-
xhr.open(this.method, this.uri,
|
|
1430
|
+
xhr.open(this.method, this.uri, true);
|
|
1369
1431
|
|
|
1370
1432
|
try {
|
|
1371
1433
|
if (this.opts.extraHeaders) {
|
|
@@ -1387,8 +1449,9 @@
|
|
|
1387
1449
|
|
|
1388
1450
|
try {
|
|
1389
1451
|
xhr.setRequestHeader("Accept", "*/*");
|
|
1390
|
-
} catch (e) {}
|
|
1452
|
+
} catch (e) {}
|
|
1391
1453
|
|
|
1454
|
+
(_a = this.opts.cookieJar) === null || _a === void 0 ? void 0 : _a.addCookies(xhr); // ie6 check
|
|
1392
1455
|
|
|
1393
1456
|
if ("withCredentials" in xhr) {
|
|
1394
1457
|
xhr.withCredentials = this.opts.withCredentials;
|
|
@@ -1399,6 +1462,12 @@
|
|
|
1399
1462
|
}
|
|
1400
1463
|
|
|
1401
1464
|
xhr.onreadystatechange = function () {
|
|
1465
|
+
var _a;
|
|
1466
|
+
|
|
1467
|
+
if (xhr.readyState === 3) {
|
|
1468
|
+
(_a = _this9.opts.cookieJar) === null || _a === void 0 ? void 0 : _a.parseCookies(xhr);
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1402
1471
|
if (4 !== xhr.readyState) return;
|
|
1403
1472
|
|
|
1404
1473
|
if (200 === xhr.status || 1223 === xhr.status) {
|
|
@@ -1431,7 +1500,7 @@
|
|
|
1431
1500
|
/**
|
|
1432
1501
|
* Called upon error.
|
|
1433
1502
|
*
|
|
1434
|
-
* @
|
|
1503
|
+
* @private
|
|
1435
1504
|
*/
|
|
1436
1505
|
|
|
1437
1506
|
}, {
|
|
@@ -1443,7 +1512,7 @@
|
|
|
1443
1512
|
/**
|
|
1444
1513
|
* Cleans up house.
|
|
1445
1514
|
*
|
|
1446
|
-
* @
|
|
1515
|
+
* @private
|
|
1447
1516
|
*/
|
|
1448
1517
|
|
|
1449
1518
|
}, {
|
|
@@ -1470,7 +1539,7 @@
|
|
|
1470
1539
|
/**
|
|
1471
1540
|
* Called upon load.
|
|
1472
1541
|
*
|
|
1473
|
-
* @
|
|
1542
|
+
* @private
|
|
1474
1543
|
*/
|
|
1475
1544
|
|
|
1476
1545
|
}, {
|
|
@@ -1487,7 +1556,7 @@
|
|
|
1487
1556
|
/**
|
|
1488
1557
|
* Aborts the request.
|
|
1489
1558
|
*
|
|
1490
|
-
* @
|
|
1559
|
+
* @package
|
|
1491
1560
|
*/
|
|
1492
1561
|
|
|
1493
1562
|
}, {
|
|
@@ -1513,7 +1582,7 @@
|
|
|
1513
1582
|
// @ts-ignore
|
|
1514
1583
|
attachEvent("onunload", unloadHandler);
|
|
1515
1584
|
} else if (typeof addEventListener === "function") {
|
|
1516
|
-
var terminationEvent = "onpagehide" in
|
|
1585
|
+
var terminationEvent = "onpagehide" in globalThisShim ? "pagehide" : "unload";
|
|
1517
1586
|
addEventListener(terminationEvent, unloadHandler, false);
|
|
1518
1587
|
}
|
|
1519
1588
|
}
|
|
@@ -1539,7 +1608,7 @@
|
|
|
1539
1608
|
};
|
|
1540
1609
|
}
|
|
1541
1610
|
}();
|
|
1542
|
-
var WebSocket =
|
|
1611
|
+
var WebSocket = globalThisShim.WebSocket || globalThisShim.MozWebSocket;
|
|
1543
1612
|
var usingBrowserWebSocket = true;
|
|
1544
1613
|
var defaultBinaryType = "arraybuffer";
|
|
1545
1614
|
|
|
@@ -1552,8 +1621,8 @@
|
|
|
1552
1621
|
/**
|
|
1553
1622
|
* WebSocket transport constructor.
|
|
1554
1623
|
*
|
|
1555
|
-
* @
|
|
1556
|
-
* @
|
|
1624
|
+
* @param {Object} opts - connection options
|
|
1625
|
+
* @protected
|
|
1557
1626
|
*/
|
|
1558
1627
|
function WS(opts) {
|
|
1559
1628
|
var _this;
|
|
@@ -1564,24 +1633,12 @@
|
|
|
1564
1633
|
_this.supportsBinary = !opts.forceBase64;
|
|
1565
1634
|
return _this;
|
|
1566
1635
|
}
|
|
1567
|
-
/**
|
|
1568
|
-
* Transport name.
|
|
1569
|
-
*
|
|
1570
|
-
* @api public
|
|
1571
|
-
*/
|
|
1572
|
-
|
|
1573
1636
|
|
|
1574
1637
|
_createClass(WS, [{
|
|
1575
1638
|
key: "name",
|
|
1576
1639
|
get: function get() {
|
|
1577
1640
|
return "websocket";
|
|
1578
1641
|
}
|
|
1579
|
-
/**
|
|
1580
|
-
* Opens socket.
|
|
1581
|
-
*
|
|
1582
|
-
* @api private
|
|
1583
|
-
*/
|
|
1584
|
-
|
|
1585
1642
|
}, {
|
|
1586
1643
|
key: "doOpen",
|
|
1587
1644
|
value: function doOpen() {
|
|
@@ -1611,7 +1668,7 @@
|
|
|
1611
1668
|
/**
|
|
1612
1669
|
* Adds event listeners to the socket
|
|
1613
1670
|
*
|
|
1614
|
-
* @
|
|
1671
|
+
* @private
|
|
1615
1672
|
*/
|
|
1616
1673
|
|
|
1617
1674
|
}, {
|
|
@@ -1642,13 +1699,6 @@
|
|
|
1642
1699
|
return _this2.onError("websocket error", e);
|
|
1643
1700
|
};
|
|
1644
1701
|
}
|
|
1645
|
-
/**
|
|
1646
|
-
* Writes data to socket.
|
|
1647
|
-
*
|
|
1648
|
-
* @param {Array} array of packets.
|
|
1649
|
-
* @api private
|
|
1650
|
-
*/
|
|
1651
|
-
|
|
1652
1702
|
}, {
|
|
1653
1703
|
key: "write",
|
|
1654
1704
|
value: function write(packets) {
|
|
@@ -1690,12 +1740,6 @@
|
|
|
1690
1740
|
_loop(i);
|
|
1691
1741
|
}
|
|
1692
1742
|
}
|
|
1693
|
-
/**
|
|
1694
|
-
* Closes socket.
|
|
1695
|
-
*
|
|
1696
|
-
* @api private
|
|
1697
|
-
*/
|
|
1698
|
-
|
|
1699
1743
|
}, {
|
|
1700
1744
|
key: "doClose",
|
|
1701
1745
|
value: function doClose() {
|
|
@@ -1707,20 +1751,14 @@
|
|
|
1707
1751
|
/**
|
|
1708
1752
|
* Generates uri for connection.
|
|
1709
1753
|
*
|
|
1710
|
-
* @
|
|
1754
|
+
* @private
|
|
1711
1755
|
*/
|
|
1712
1756
|
|
|
1713
1757
|
}, {
|
|
1714
1758
|
key: "uri",
|
|
1715
1759
|
value: function uri() {
|
|
1716
|
-
var query = this.query || {};
|
|
1717
1760
|
var schema = this.opts.secure ? "wss" : "ws";
|
|
1718
|
-
var
|
|
1719
|
-
|
|
1720
|
-
if (this.opts.port && ("wss" === schema && Number(this.opts.port) !== 443 || "ws" === schema && Number(this.opts.port) !== 80)) {
|
|
1721
|
-
port = ":" + this.opts.port;
|
|
1722
|
-
} // append timestamp to URI
|
|
1723
|
-
|
|
1761
|
+
var query = this.query || {}; // append timestamp to URI
|
|
1724
1762
|
|
|
1725
1763
|
if (this.opts.timestampRequests) {
|
|
1726
1764
|
query[this.opts.timestampParam] = yeast();
|
|
@@ -1731,41 +1769,170 @@
|
|
|
1731
1769
|
query.b64 = 1;
|
|
1732
1770
|
}
|
|
1733
1771
|
|
|
1734
|
-
|
|
1735
|
-
var ipv6 = this.opts.hostname.indexOf(":") !== -1;
|
|
1736
|
-
return schema + "://" + (ipv6 ? "[" + this.opts.hostname + "]" : this.opts.hostname) + port + this.opts.path + (encodedQuery.length ? "?" + encodedQuery : "");
|
|
1772
|
+
return this.createUri(schema, query);
|
|
1737
1773
|
}
|
|
1738
1774
|
/**
|
|
1739
1775
|
* Feature detection for WebSocket.
|
|
1740
1776
|
*
|
|
1741
1777
|
* @return {Boolean} whether this transport is available.
|
|
1742
|
-
* @
|
|
1778
|
+
* @private
|
|
1743
1779
|
*/
|
|
1744
1780
|
|
|
1745
1781
|
}, {
|
|
1746
1782
|
key: "check",
|
|
1747
1783
|
value: function check() {
|
|
1748
|
-
return !!WebSocket
|
|
1784
|
+
return !!WebSocket;
|
|
1749
1785
|
}
|
|
1750
1786
|
}]);
|
|
1751
1787
|
|
|
1752
1788
|
return WS;
|
|
1753
1789
|
}(Transport);
|
|
1754
1790
|
|
|
1791
|
+
function shouldIncludeBinaryHeader(packet, encoded) {
|
|
1792
|
+
// 48 === "0".charCodeAt(0) (OPEN packet type)
|
|
1793
|
+
// 54 === "6".charCodeAt(0) (NOOP packet type)
|
|
1794
|
+
return packet.type === "message" && typeof packet.data !== "string" && encoded[0] >= 48 && encoded[0] <= 54;
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
var WT = /*#__PURE__*/function (_Transport) {
|
|
1798
|
+
_inherits(WT, _Transport);
|
|
1799
|
+
|
|
1800
|
+
var _super = _createSuper(WT);
|
|
1801
|
+
|
|
1802
|
+
function WT() {
|
|
1803
|
+
_classCallCheck(this, WT);
|
|
1804
|
+
|
|
1805
|
+
return _super.apply(this, arguments);
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
_createClass(WT, [{
|
|
1809
|
+
key: "name",
|
|
1810
|
+
get: function get() {
|
|
1811
|
+
return "webtransport";
|
|
1812
|
+
}
|
|
1813
|
+
}, {
|
|
1814
|
+
key: "doOpen",
|
|
1815
|
+
value: function doOpen() {
|
|
1816
|
+
var _this = this;
|
|
1817
|
+
|
|
1818
|
+
// @ts-ignore
|
|
1819
|
+
if (typeof WebTransport !== "function") {
|
|
1820
|
+
return;
|
|
1821
|
+
} // @ts-ignore
|
|
1822
|
+
|
|
1823
|
+
|
|
1824
|
+
this.transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]);
|
|
1825
|
+
this.transport.closed.then(function () {
|
|
1826
|
+
return _this.onClose();
|
|
1827
|
+
}); // note: we could have used async/await, but that would require some additional polyfills
|
|
1828
|
+
|
|
1829
|
+
this.transport.ready.then(function () {
|
|
1830
|
+
_this.transport.createBidirectionalStream().then(function (stream) {
|
|
1831
|
+
var reader = stream.readable.getReader();
|
|
1832
|
+
_this.writer = stream.writable.getWriter();
|
|
1833
|
+
var binaryFlag;
|
|
1834
|
+
|
|
1835
|
+
var read = function read() {
|
|
1836
|
+
reader.read().then(function (_ref) {
|
|
1837
|
+
var done = _ref.done,
|
|
1838
|
+
value = _ref.value;
|
|
1839
|
+
|
|
1840
|
+
if (done) {
|
|
1841
|
+
return;
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
if (!binaryFlag && value.byteLength === 1 && value[0] === 54) {
|
|
1845
|
+
binaryFlag = true;
|
|
1846
|
+
} else {
|
|
1847
|
+
// TODO expose binarytype
|
|
1848
|
+
_this.onPacket(decodePacketFromBinary(value, binaryFlag, "arraybuffer"));
|
|
1849
|
+
|
|
1850
|
+
binaryFlag = false;
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1853
|
+
read();
|
|
1854
|
+
});
|
|
1855
|
+
};
|
|
1856
|
+
|
|
1857
|
+
read();
|
|
1858
|
+
var handshake = _this.query.sid ? "0{\"sid\":\"".concat(_this.query.sid, "\"}") : "0";
|
|
1859
|
+
|
|
1860
|
+
_this.writer.write(new TextEncoder().encode(handshake)).then(function () {
|
|
1861
|
+
return _this.onOpen();
|
|
1862
|
+
});
|
|
1863
|
+
});
|
|
1864
|
+
});
|
|
1865
|
+
}
|
|
1866
|
+
}, {
|
|
1867
|
+
key: "write",
|
|
1868
|
+
value: function write(packets) {
|
|
1869
|
+
var _this2 = this;
|
|
1870
|
+
|
|
1871
|
+
this.writable = false;
|
|
1872
|
+
|
|
1873
|
+
var _loop = function _loop(i) {
|
|
1874
|
+
var packet = packets[i];
|
|
1875
|
+
var lastPacket = i === packets.length - 1;
|
|
1876
|
+
encodePacketToBinary(packet, function (data) {
|
|
1877
|
+
if (shouldIncludeBinaryHeader(packet, data)) {
|
|
1878
|
+
_this2.writer.write(Uint8Array.of(54));
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
_this2.writer.write(data).then(function () {
|
|
1882
|
+
if (lastPacket) {
|
|
1883
|
+
nextTick(function () {
|
|
1884
|
+
_this2.writable = true;
|
|
1885
|
+
|
|
1886
|
+
_this2.emitReserved("drain");
|
|
1887
|
+
}, _this2.setTimeoutFn);
|
|
1888
|
+
}
|
|
1889
|
+
});
|
|
1890
|
+
});
|
|
1891
|
+
};
|
|
1892
|
+
|
|
1893
|
+
for (var i = 0; i < packets.length; i++) {
|
|
1894
|
+
_loop(i);
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
}, {
|
|
1898
|
+
key: "doClose",
|
|
1899
|
+
value: function doClose() {
|
|
1900
|
+
var _a;
|
|
1901
|
+
|
|
1902
|
+
(_a = this.transport) === null || _a === void 0 ? void 0 : _a.close();
|
|
1903
|
+
}
|
|
1904
|
+
}]);
|
|
1905
|
+
|
|
1906
|
+
return WT;
|
|
1907
|
+
}(Transport);
|
|
1908
|
+
|
|
1755
1909
|
var transports = {
|
|
1756
1910
|
websocket: WS,
|
|
1911
|
+
webtransport: WT,
|
|
1757
1912
|
polling: Polling
|
|
1758
1913
|
};
|
|
1759
1914
|
|
|
1760
1915
|
// imported from https://github.com/galkn/parseuri
|
|
1761
1916
|
|
|
1762
1917
|
/**
|
|
1763
|
-
* Parses
|
|
1918
|
+
* Parses a URI
|
|
1919
|
+
*
|
|
1920
|
+
* Note: we could also have used the built-in URL object, but it isn't supported on all platforms.
|
|
1921
|
+
*
|
|
1922
|
+
* See:
|
|
1923
|
+
* - https://developer.mozilla.org/en-US/docs/Web/API/URL
|
|
1924
|
+
* - https://caniuse.com/url
|
|
1925
|
+
* - https://www.rfc-editor.org/rfc/rfc3986#appendix-B
|
|
1926
|
+
*
|
|
1927
|
+
* History of the parse() method:
|
|
1928
|
+
* - first commit: https://github.com/socketio/socket.io-client/commit/4ee1d5d94b3906a9c052b459f1a818b15f38f91c
|
|
1929
|
+
* - export into its own module: https://github.com/socketio/engine.io-client/commit/de2c561e4564efeb78f1bdb1ba39ef81b2822cb3
|
|
1930
|
+
* - reimport: https://github.com/socketio/engine.io-client/commit/df32277c3f6d622eec5ed09f493cae3f3391d242
|
|
1764
1931
|
*
|
|
1765
1932
|
* @author Steven Levithan <stevenlevithan.com> (MIT license)
|
|
1766
1933
|
* @api private
|
|
1767
1934
|
*/
|
|
1768
|
-
var re = /^(?:(?![
|
|
1935
|
+
var re = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
|
|
1769
1936
|
var parts = ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'];
|
|
1770
1937
|
function parse(str) {
|
|
1771
1938
|
var src = str,
|
|
@@ -1800,11 +1967,11 @@
|
|
|
1800
1967
|
var regx = /\/{2,9}/g,
|
|
1801
1968
|
names = path.replace(regx, "/").split("/");
|
|
1802
1969
|
|
|
1803
|
-
if (path.
|
|
1970
|
+
if (path.slice(0, 1) == '/' || path.length === 0) {
|
|
1804
1971
|
names.splice(0, 1);
|
|
1805
1972
|
}
|
|
1806
1973
|
|
|
1807
|
-
if (path.
|
|
1974
|
+
if (path.slice(-1) == '/') {
|
|
1808
1975
|
names.splice(names.length - 1, 1);
|
|
1809
1976
|
}
|
|
1810
1977
|
|
|
@@ -1829,9 +1996,8 @@
|
|
|
1829
1996
|
/**
|
|
1830
1997
|
* Socket constructor.
|
|
1831
1998
|
*
|
|
1832
|
-
* @param {String|Object} uri or options
|
|
1999
|
+
* @param {String|Object} uri - uri or options
|
|
1833
2000
|
* @param {Object} opts - options
|
|
1834
|
-
* @api public
|
|
1835
2001
|
*/
|
|
1836
2002
|
function Socket(uri) {
|
|
1837
2003
|
var _this;
|
|
@@ -1841,6 +2007,7 @@
|
|
|
1841
2007
|
_classCallCheck(this, Socket);
|
|
1842
2008
|
|
|
1843
2009
|
_this = _super.call(this);
|
|
2010
|
+
_this.writeBuffer = [];
|
|
1844
2011
|
|
|
1845
2012
|
if (uri && "object" === _typeof(uri)) {
|
|
1846
2013
|
opts = uri;
|
|
@@ -1867,8 +2034,7 @@
|
|
|
1867
2034
|
|
|
1868
2035
|
_this.hostname = opts.hostname || (typeof location !== "undefined" ? location.hostname : "localhost");
|
|
1869
2036
|
_this.port = opts.port || (typeof location !== "undefined" && location.port ? location.port : _this.secure ? "443" : "80");
|
|
1870
|
-
_this.transports = opts.transports || ["polling", "websocket"];
|
|
1871
|
-
_this.readyState = "";
|
|
2037
|
+
_this.transports = opts.transports || ["polling", "websocket", "webtransport"];
|
|
1872
2038
|
_this.writeBuffer = [];
|
|
1873
2039
|
_this.prevBufferLen = 0;
|
|
1874
2040
|
_this.opts = _extends({
|
|
@@ -1878,6 +2044,7 @@
|
|
|
1878
2044
|
upgrade: true,
|
|
1879
2045
|
timestampParam: "t",
|
|
1880
2046
|
rememberUpgrade: false,
|
|
2047
|
+
addTrailingSlash: true,
|
|
1881
2048
|
rejectUnauthorized: true,
|
|
1882
2049
|
perMessageDeflate: {
|
|
1883
2050
|
threshold: 1024
|
|
@@ -1885,7 +2052,7 @@
|
|
|
1885
2052
|
transportOptions: {},
|
|
1886
2053
|
closeOnBeforeunload: true
|
|
1887
2054
|
}, opts);
|
|
1888
|
-
_this.opts.path = _this.opts.path.replace(/\/$/, "") + "/";
|
|
2055
|
+
_this.opts.path = _this.opts.path.replace(/\/$/, "") + (_this.opts.addTrailingSlash ? "/" : "");
|
|
1889
2056
|
|
|
1890
2057
|
if (typeof _this.opts.query === "string") {
|
|
1891
2058
|
_this.opts.query = decode(_this.opts.query);
|
|
@@ -1904,14 +2071,16 @@
|
|
|
1904
2071
|
// Firefox closes the connection when the "beforeunload" event is emitted but not Chrome. This event listener
|
|
1905
2072
|
// ensures every browser behaves the same (no "disconnect" event at the Socket.IO level when the page is
|
|
1906
2073
|
// closed/reloaded)
|
|
1907
|
-
|
|
2074
|
+
_this.beforeunloadEventListener = function () {
|
|
1908
2075
|
if (_this.transport) {
|
|
1909
2076
|
// silently close the transport
|
|
1910
2077
|
_this.transport.removeAllListeners();
|
|
1911
2078
|
|
|
1912
2079
|
_this.transport.close();
|
|
1913
2080
|
}
|
|
1914
|
-
}
|
|
2081
|
+
};
|
|
2082
|
+
|
|
2083
|
+
addEventListener("beforeunload", _this.beforeunloadEventListener, false);
|
|
1915
2084
|
}
|
|
1916
2085
|
|
|
1917
2086
|
if (_this.hostname !== "localhost") {
|
|
@@ -1932,9 +2101,9 @@
|
|
|
1932
2101
|
/**
|
|
1933
2102
|
* Creates transport of the given type.
|
|
1934
2103
|
*
|
|
1935
|
-
* @param {String} transport name
|
|
2104
|
+
* @param {String} name - transport name
|
|
1936
2105
|
* @return {Transport}
|
|
1937
|
-
* @
|
|
2106
|
+
* @private
|
|
1938
2107
|
*/
|
|
1939
2108
|
|
|
1940
2109
|
|
|
@@ -1963,7 +2132,7 @@
|
|
|
1963
2132
|
/**
|
|
1964
2133
|
* Initializes transport to use and starts probe.
|
|
1965
2134
|
*
|
|
1966
|
-
* @
|
|
2135
|
+
* @private
|
|
1967
2136
|
*/
|
|
1968
2137
|
|
|
1969
2138
|
}, {
|
|
@@ -2001,7 +2170,7 @@
|
|
|
2001
2170
|
/**
|
|
2002
2171
|
* Sets the current transport. Disables the existing one (if any).
|
|
2003
2172
|
*
|
|
2004
|
-
* @
|
|
2173
|
+
* @private
|
|
2005
2174
|
*/
|
|
2006
2175
|
|
|
2007
2176
|
}, {
|
|
@@ -2023,8 +2192,8 @@
|
|
|
2023
2192
|
/**
|
|
2024
2193
|
* Probes a transport.
|
|
2025
2194
|
*
|
|
2026
|
-
* @param {String} transport name
|
|
2027
|
-
* @
|
|
2195
|
+
* @param {String} name - transport name
|
|
2196
|
+
* @private
|
|
2028
2197
|
*/
|
|
2029
2198
|
|
|
2030
2199
|
}, {
|
|
@@ -2132,12 +2301,22 @@
|
|
|
2132
2301
|
transport.once("close", onTransportClose);
|
|
2133
2302
|
this.once("close", onclose);
|
|
2134
2303
|
this.once("upgrading", onupgrade);
|
|
2135
|
-
|
|
2304
|
+
|
|
2305
|
+
if (this.upgrades.indexOf("webtransport") !== -1 && name !== "webtransport") {
|
|
2306
|
+
// favor WebTransport
|
|
2307
|
+
this.setTimeoutFn(function () {
|
|
2308
|
+
if (!failed) {
|
|
2309
|
+
transport.open();
|
|
2310
|
+
}
|
|
2311
|
+
}, 200);
|
|
2312
|
+
} else {
|
|
2313
|
+
transport.open();
|
|
2314
|
+
}
|
|
2136
2315
|
}
|
|
2137
2316
|
/**
|
|
2138
2317
|
* Called when connection is deemed open.
|
|
2139
2318
|
*
|
|
2140
|
-
* @
|
|
2319
|
+
* @private
|
|
2141
2320
|
*/
|
|
2142
2321
|
|
|
2143
2322
|
}, {
|
|
@@ -2149,7 +2328,7 @@
|
|
|
2149
2328
|
this.flush(); // we check for `readyState` in case an `open`
|
|
2150
2329
|
// listener already closed the socket
|
|
2151
2330
|
|
|
2152
|
-
if ("open" === this.readyState && this.opts.upgrade
|
|
2331
|
+
if ("open" === this.readyState && this.opts.upgrade) {
|
|
2153
2332
|
var i = 0;
|
|
2154
2333
|
var l = this.upgrades.length;
|
|
2155
2334
|
|
|
@@ -2161,7 +2340,7 @@
|
|
|
2161
2340
|
/**
|
|
2162
2341
|
* Handles a packet.
|
|
2163
2342
|
*
|
|
2164
|
-
* @
|
|
2343
|
+
* @private
|
|
2165
2344
|
*/
|
|
2166
2345
|
|
|
2167
2346
|
}, {
|
|
@@ -2202,7 +2381,7 @@
|
|
|
2202
2381
|
* Called upon handshake completion.
|
|
2203
2382
|
*
|
|
2204
2383
|
* @param {Object} data - handshake obj
|
|
2205
|
-
* @
|
|
2384
|
+
* @private
|
|
2206
2385
|
*/
|
|
2207
2386
|
|
|
2208
2387
|
}, {
|
|
@@ -2223,7 +2402,7 @@
|
|
|
2223
2402
|
/**
|
|
2224
2403
|
* Sets and resets ping timeout timer based on server pings.
|
|
2225
2404
|
*
|
|
2226
|
-
* @
|
|
2405
|
+
* @private
|
|
2227
2406
|
*/
|
|
2228
2407
|
|
|
2229
2408
|
}, {
|
|
@@ -2243,7 +2422,7 @@
|
|
|
2243
2422
|
/**
|
|
2244
2423
|
* Called on `drain` event
|
|
2245
2424
|
*
|
|
2246
|
-
* @
|
|
2425
|
+
* @private
|
|
2247
2426
|
*/
|
|
2248
2427
|
|
|
2249
2428
|
}, {
|
|
@@ -2264,7 +2443,7 @@
|
|
|
2264
2443
|
/**
|
|
2265
2444
|
* Flush write buffers.
|
|
2266
2445
|
*
|
|
2267
|
-
* @
|
|
2446
|
+
* @private
|
|
2268
2447
|
*/
|
|
2269
2448
|
|
|
2270
2449
|
}, {
|
|
@@ -2316,11 +2495,10 @@
|
|
|
2316
2495
|
/**
|
|
2317
2496
|
* Sends a message.
|
|
2318
2497
|
*
|
|
2319
|
-
* @param {String} message.
|
|
2320
|
-
* @param {Function} callback function.
|
|
2498
|
+
* @param {String} msg - message.
|
|
2321
2499
|
* @param {Object} options.
|
|
2500
|
+
* @param {Function} callback function.
|
|
2322
2501
|
* @return {Socket} for chaining.
|
|
2323
|
-
* @api public
|
|
2324
2502
|
*/
|
|
2325
2503
|
|
|
2326
2504
|
}, {
|
|
@@ -2338,11 +2516,11 @@
|
|
|
2338
2516
|
/**
|
|
2339
2517
|
* Sends a packet.
|
|
2340
2518
|
*
|
|
2341
|
-
* @param {String} packet type.
|
|
2519
|
+
* @param {String} type: packet type.
|
|
2342
2520
|
* @param {String} data.
|
|
2343
2521
|
* @param {Object} options.
|
|
2344
|
-
* @param {Function} callback function.
|
|
2345
|
-
* @
|
|
2522
|
+
* @param {Function} fn - callback function.
|
|
2523
|
+
* @private
|
|
2346
2524
|
*/
|
|
2347
2525
|
|
|
2348
2526
|
}, {
|
|
@@ -2376,8 +2554,6 @@
|
|
|
2376
2554
|
}
|
|
2377
2555
|
/**
|
|
2378
2556
|
* Closes the connection.
|
|
2379
|
-
*
|
|
2380
|
-
* @api public
|
|
2381
2557
|
*/
|
|
2382
2558
|
|
|
2383
2559
|
}, {
|
|
@@ -2429,7 +2605,7 @@
|
|
|
2429
2605
|
/**
|
|
2430
2606
|
* Called upon transport error
|
|
2431
2607
|
*
|
|
2432
|
-
* @
|
|
2608
|
+
* @private
|
|
2433
2609
|
*/
|
|
2434
2610
|
|
|
2435
2611
|
}, {
|
|
@@ -2442,7 +2618,7 @@
|
|
|
2442
2618
|
/**
|
|
2443
2619
|
* Called upon transport close.
|
|
2444
2620
|
*
|
|
2445
|
-
* @
|
|
2621
|
+
* @private
|
|
2446
2622
|
*/
|
|
2447
2623
|
|
|
2448
2624
|
}, {
|
|
@@ -2459,6 +2635,7 @@
|
|
|
2459
2635
|
this.transport.removeAllListeners();
|
|
2460
2636
|
|
|
2461
2637
|
if (typeof removeEventListener === "function") {
|
|
2638
|
+
removeEventListener("beforeunload", this.beforeunloadEventListener, false);
|
|
2462
2639
|
removeEventListener("offline", this.offlineEventListener, false);
|
|
2463
2640
|
} // set ready state
|
|
2464
2641
|
|
|
@@ -2477,9 +2654,8 @@
|
|
|
2477
2654
|
/**
|
|
2478
2655
|
* Filters upgrades, returning only those matching client transports.
|
|
2479
2656
|
*
|
|
2480
|
-
* @param {Array} server upgrades
|
|
2481
|
-
* @
|
|
2482
|
-
*
|
|
2657
|
+
* @param {Array} upgrades - server upgrades
|
|
2658
|
+
* @private
|
|
2483
2659
|
*/
|
|
2484
2660
|
|
|
2485
2661
|
}, {
|
|
@@ -2501,6 +2677,8 @@
|
|
|
2501
2677
|
}(Emitter);
|
|
2502
2678
|
Socket$1.protocol = protocol$1;
|
|
2503
2679
|
|
|
2680
|
+
Socket$1.protocol;
|
|
2681
|
+
|
|
2504
2682
|
/**
|
|
2505
2683
|
* URL parser.
|
|
2506
2684
|
*
|
|
@@ -2674,7 +2852,7 @@
|
|
|
2674
2852
|
|
|
2675
2853
|
function reconstructPacket(packet, buffers) {
|
|
2676
2854
|
packet.data = _reconstructPacket(packet.data, buffers);
|
|
2677
|
-
packet.attachments
|
|
2855
|
+
delete packet.attachments; // no longer useful
|
|
2678
2856
|
|
|
2679
2857
|
return packet;
|
|
2680
2858
|
}
|
|
@@ -2682,8 +2860,14 @@
|
|
|
2682
2860
|
function _reconstructPacket(data, buffers) {
|
|
2683
2861
|
if (!data) return data;
|
|
2684
2862
|
|
|
2685
|
-
if (data && data._placeholder) {
|
|
2686
|
-
|
|
2863
|
+
if (data && data._placeholder === true) {
|
|
2864
|
+
var isIndexValid = typeof data.num === "number" && data.num >= 0 && data.num < buffers.length;
|
|
2865
|
+
|
|
2866
|
+
if (isIndexValid) {
|
|
2867
|
+
return buffers[data.num]; // appropriate buffer (should be natural order anyway)
|
|
2868
|
+
} else {
|
|
2869
|
+
throw new Error("illegal attachments");
|
|
2870
|
+
}
|
|
2687
2871
|
} else if (Array.isArray(data)) {
|
|
2688
2872
|
for (var i = 0; i < data.length; i++) {
|
|
2689
2873
|
data[i] = _reconstructPacket(data[i], buffers);
|
|
@@ -2699,6 +2883,12 @@
|
|
|
2699
2883
|
return data;
|
|
2700
2884
|
}
|
|
2701
2885
|
|
|
2886
|
+
/**
|
|
2887
|
+
* These strings must not be used as event names, as they have a special meaning.
|
|
2888
|
+
*/
|
|
2889
|
+
|
|
2890
|
+
var RESERVED_EVENTS$1 = ["connect", "connect_error", "disconnect", "disconnecting", "newListener", "removeListener" // used by the Node.js EventEmitter
|
|
2891
|
+
];
|
|
2702
2892
|
/**
|
|
2703
2893
|
* Protocol version.
|
|
2704
2894
|
*
|
|
@@ -2746,8 +2936,12 @@
|
|
|
2746
2936
|
value: function encode(obj) {
|
|
2747
2937
|
if (obj.type === PacketType.EVENT || obj.type === PacketType.ACK) {
|
|
2748
2938
|
if (hasBinary(obj)) {
|
|
2749
|
-
|
|
2750
|
-
|
|
2939
|
+
return this.encodeAsBinary({
|
|
2940
|
+
type: obj.type === PacketType.EVENT ? PacketType.BINARY_EVENT : PacketType.BINARY_ACK,
|
|
2941
|
+
nsp: obj.nsp,
|
|
2942
|
+
data: obj.data,
|
|
2943
|
+
id: obj.id
|
|
2944
|
+
});
|
|
2751
2945
|
}
|
|
2752
2946
|
}
|
|
2753
2947
|
|
|
@@ -2804,13 +2998,18 @@
|
|
|
2804
2998
|
}]);
|
|
2805
2999
|
|
|
2806
3000
|
return Encoder;
|
|
2807
|
-
}();
|
|
3001
|
+
}(); // see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript
|
|
3002
|
+
|
|
3003
|
+
function isObject(value) {
|
|
3004
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
|
3005
|
+
}
|
|
2808
3006
|
/**
|
|
2809
3007
|
* A socket.io Decoder instance
|
|
2810
3008
|
*
|
|
2811
3009
|
* @return {Object} decoder
|
|
2812
3010
|
*/
|
|
2813
3011
|
|
|
3012
|
+
|
|
2814
3013
|
var Decoder = /*#__PURE__*/function (_Emitter) {
|
|
2815
3014
|
_inherits(Decoder, _Emitter);
|
|
2816
3015
|
|
|
@@ -2843,10 +3042,16 @@
|
|
|
2843
3042
|
var packet;
|
|
2844
3043
|
|
|
2845
3044
|
if (typeof obj === "string") {
|
|
3045
|
+
if (this.reconstructor) {
|
|
3046
|
+
throw new Error("got plaintext data when reconstructing a packet");
|
|
3047
|
+
}
|
|
3048
|
+
|
|
2846
3049
|
packet = this.decodeString(obj);
|
|
3050
|
+
var isBinaryEvent = packet.type === PacketType.BINARY_EVENT;
|
|
3051
|
+
|
|
3052
|
+
if (isBinaryEvent || packet.type === PacketType.BINARY_ACK) {
|
|
3053
|
+
packet.type = isBinaryEvent ? PacketType.EVENT : PacketType.ACK; // binary packet's json
|
|
2847
3054
|
|
|
2848
|
-
if (packet.type === PacketType.BINARY_EVENT || packet.type === PacketType.BINARY_ACK) {
|
|
2849
|
-
// binary packet's json
|
|
2850
3055
|
this.reconstructor = new BinaryReconstructor(packet); // no attachments, labeled binary but no binary data to follow
|
|
2851
3056
|
|
|
2852
3057
|
if (packet.attachments === 0) {
|
|
@@ -2975,6 +3180,7 @@
|
|
|
2975
3180
|
function destroy() {
|
|
2976
3181
|
if (this.reconstructor) {
|
|
2977
3182
|
this.reconstructor.finishedReconstruction();
|
|
3183
|
+
this.reconstructor = null;
|
|
2978
3184
|
}
|
|
2979
3185
|
}
|
|
2980
3186
|
}], [{
|
|
@@ -2982,17 +3188,17 @@
|
|
|
2982
3188
|
value: function isPayloadValid(type, payload) {
|
|
2983
3189
|
switch (type) {
|
|
2984
3190
|
case PacketType.CONNECT:
|
|
2985
|
-
return
|
|
3191
|
+
return isObject(payload);
|
|
2986
3192
|
|
|
2987
3193
|
case PacketType.DISCONNECT:
|
|
2988
3194
|
return payload === undefined;
|
|
2989
3195
|
|
|
2990
3196
|
case PacketType.CONNECT_ERROR:
|
|
2991
|
-
return typeof payload === "string" ||
|
|
3197
|
+
return typeof payload === "string" || isObject(payload);
|
|
2992
3198
|
|
|
2993
3199
|
case PacketType.EVENT:
|
|
2994
3200
|
case PacketType.BINARY_EVENT:
|
|
2995
|
-
return Array.isArray(payload) && payload.
|
|
3201
|
+
return Array.isArray(payload) && (typeof payload[0] === "number" || typeof payload[0] === "string" && RESERVED_EVENTS$1.indexOf(payload[0]) === -1);
|
|
2996
3202
|
|
|
2997
3203
|
case PacketType.ACK:
|
|
2998
3204
|
case PacketType.BINARY_ACK:
|
|
@@ -3088,6 +3294,31 @@
|
|
|
3088
3294
|
newListener: 1,
|
|
3089
3295
|
removeListener: 1
|
|
3090
3296
|
});
|
|
3297
|
+
/**
|
|
3298
|
+
* A Socket is the fundamental class for interacting with the server.
|
|
3299
|
+
*
|
|
3300
|
+
* A Socket belongs to a certain Namespace (by default /) and uses an underlying {@link Manager} to communicate.
|
|
3301
|
+
*
|
|
3302
|
+
* @example
|
|
3303
|
+
* const socket = io();
|
|
3304
|
+
*
|
|
3305
|
+
* socket.on("connect", () => {
|
|
3306
|
+
* console.log("connected");
|
|
3307
|
+
* });
|
|
3308
|
+
*
|
|
3309
|
+
* // send an event to the server
|
|
3310
|
+
* socket.emit("foo", "bar");
|
|
3311
|
+
*
|
|
3312
|
+
* socket.on("foobar", () => {
|
|
3313
|
+
* // an event was received from the server
|
|
3314
|
+
* });
|
|
3315
|
+
*
|
|
3316
|
+
* // upon disconnection
|
|
3317
|
+
* socket.on("disconnect", (reason) => {
|
|
3318
|
+
* console.log(`disconnected due to ${reason}`);
|
|
3319
|
+
* });
|
|
3320
|
+
*/
|
|
3321
|
+
|
|
3091
3322
|
var Socket = /*#__PURE__*/function (_Emitter) {
|
|
3092
3323
|
_inherits(Socket, _Emitter);
|
|
3093
3324
|
|
|
@@ -3095,8 +3326,6 @@
|
|
|
3095
3326
|
|
|
3096
3327
|
/**
|
|
3097
3328
|
* `Socket` constructor.
|
|
3098
|
-
*
|
|
3099
|
-
* @public
|
|
3100
3329
|
*/
|
|
3101
3330
|
function Socket(io, nsp, opts) {
|
|
3102
3331
|
var _this;
|
|
@@ -3104,9 +3333,52 @@
|
|
|
3104
3333
|
_classCallCheck(this, Socket);
|
|
3105
3334
|
|
|
3106
3335
|
_this = _super.call(this);
|
|
3336
|
+
/**
|
|
3337
|
+
* Whether the socket is currently connected to the server.
|
|
3338
|
+
*
|
|
3339
|
+
* @example
|
|
3340
|
+
* const socket = io();
|
|
3341
|
+
*
|
|
3342
|
+
* socket.on("connect", () => {
|
|
3343
|
+
* console.log(socket.connected); // true
|
|
3344
|
+
* });
|
|
3345
|
+
*
|
|
3346
|
+
* socket.on("disconnect", () => {
|
|
3347
|
+
* console.log(socket.connected); // false
|
|
3348
|
+
* });
|
|
3349
|
+
*/
|
|
3350
|
+
|
|
3107
3351
|
_this.connected = false;
|
|
3352
|
+
/**
|
|
3353
|
+
* Whether the connection state was recovered after a temporary disconnection. In that case, any missed packets will
|
|
3354
|
+
* be transmitted by the server.
|
|
3355
|
+
*/
|
|
3356
|
+
|
|
3357
|
+
_this.recovered = false;
|
|
3358
|
+
/**
|
|
3359
|
+
* Buffer for packets received before the CONNECT packet
|
|
3360
|
+
*/
|
|
3361
|
+
|
|
3108
3362
|
_this.receiveBuffer = [];
|
|
3363
|
+
/**
|
|
3364
|
+
* Buffer for packets that will be sent once the socket is connected
|
|
3365
|
+
*/
|
|
3366
|
+
|
|
3109
3367
|
_this.sendBuffer = [];
|
|
3368
|
+
/**
|
|
3369
|
+
* The queue of packets to be sent with retry in case of failure.
|
|
3370
|
+
*
|
|
3371
|
+
* Packets are sent one by one, each waiting for the server acknowledgement, in order to guarantee the delivery order.
|
|
3372
|
+
* @private
|
|
3373
|
+
*/
|
|
3374
|
+
|
|
3375
|
+
_this._queue = [];
|
|
3376
|
+
/**
|
|
3377
|
+
* A sequence to generate the ID of the {@link QueuedPacket}.
|
|
3378
|
+
* @private
|
|
3379
|
+
*/
|
|
3380
|
+
|
|
3381
|
+
_this._queueSeq = 0;
|
|
3110
3382
|
_this.ids = 0;
|
|
3111
3383
|
_this.acks = {};
|
|
3112
3384
|
_this.flags = {};
|
|
@@ -3117,11 +3389,23 @@
|
|
|
3117
3389
|
_this.auth = opts.auth;
|
|
3118
3390
|
}
|
|
3119
3391
|
|
|
3392
|
+
_this._opts = _extends({}, opts);
|
|
3120
3393
|
if (_this.io._autoConnect) _this.open();
|
|
3121
3394
|
return _this;
|
|
3122
3395
|
}
|
|
3123
3396
|
/**
|
|
3124
3397
|
* Whether the socket is currently disconnected
|
|
3398
|
+
*
|
|
3399
|
+
* @example
|
|
3400
|
+
* const socket = io();
|
|
3401
|
+
*
|
|
3402
|
+
* socket.on("connect", () => {
|
|
3403
|
+
* console.log(socket.disconnected); // false
|
|
3404
|
+
* });
|
|
3405
|
+
*
|
|
3406
|
+
* socket.on("disconnect", () => {
|
|
3407
|
+
* console.log(socket.disconnected); // true
|
|
3408
|
+
* });
|
|
3125
3409
|
*/
|
|
3126
3410
|
|
|
3127
3411
|
|
|
@@ -3144,7 +3428,21 @@
|
|
|
3144
3428
|
this.subs = [on(io, "open", this.onopen.bind(this)), on(io, "packet", this.onpacket.bind(this)), on(io, "error", this.onerror.bind(this)), on(io, "close", this.onclose.bind(this))];
|
|
3145
3429
|
}
|
|
3146
3430
|
/**
|
|
3147
|
-
* Whether the Socket will try to reconnect when its Manager connects or reconnects
|
|
3431
|
+
* Whether the Socket will try to reconnect when its Manager connects or reconnects.
|
|
3432
|
+
*
|
|
3433
|
+
* @example
|
|
3434
|
+
* const socket = io();
|
|
3435
|
+
*
|
|
3436
|
+
* console.log(socket.active); // true
|
|
3437
|
+
*
|
|
3438
|
+
* socket.on("disconnect", (reason) => {
|
|
3439
|
+
* if (reason === "io server disconnect") {
|
|
3440
|
+
* // the disconnection was initiated by the server, you need to manually reconnect
|
|
3441
|
+
* console.log(socket.active); // false
|
|
3442
|
+
* }
|
|
3443
|
+
* // else the socket will automatically try to reconnect
|
|
3444
|
+
* console.log(socket.active); // true
|
|
3445
|
+
* });
|
|
3148
3446
|
*/
|
|
3149
3447
|
|
|
3150
3448
|
}, {
|
|
@@ -3155,7 +3453,12 @@
|
|
|
3155
3453
|
/**
|
|
3156
3454
|
* "Opens" the socket.
|
|
3157
3455
|
*
|
|
3158
|
-
* @
|
|
3456
|
+
* @example
|
|
3457
|
+
* const socket = io({
|
|
3458
|
+
* autoConnect: false
|
|
3459
|
+
* });
|
|
3460
|
+
*
|
|
3461
|
+
* socket.connect();
|
|
3159
3462
|
*/
|
|
3160
3463
|
|
|
3161
3464
|
}, {
|
|
@@ -3169,7 +3472,7 @@
|
|
|
3169
3472
|
return this;
|
|
3170
3473
|
}
|
|
3171
3474
|
/**
|
|
3172
|
-
* Alias for connect()
|
|
3475
|
+
* Alias for {@link connect()}.
|
|
3173
3476
|
*/
|
|
3174
3477
|
|
|
3175
3478
|
}, {
|
|
@@ -3180,8 +3483,17 @@
|
|
|
3180
3483
|
/**
|
|
3181
3484
|
* Sends a `message` event.
|
|
3182
3485
|
*
|
|
3486
|
+
* This method mimics the WebSocket.send() method.
|
|
3487
|
+
*
|
|
3488
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send
|
|
3489
|
+
*
|
|
3490
|
+
* @example
|
|
3491
|
+
* socket.send("hello");
|
|
3492
|
+
*
|
|
3493
|
+
* // this is equivalent to
|
|
3494
|
+
* socket.emit("message", "hello");
|
|
3495
|
+
*
|
|
3183
3496
|
* @return self
|
|
3184
|
-
* @public
|
|
3185
3497
|
*/
|
|
3186
3498
|
|
|
3187
3499
|
}, {
|
|
@@ -3199,15 +3511,25 @@
|
|
|
3199
3511
|
* Override `emit`.
|
|
3200
3512
|
* If the event is in `events`, it's emitted normally.
|
|
3201
3513
|
*
|
|
3514
|
+
* @example
|
|
3515
|
+
* socket.emit("hello", "world");
|
|
3516
|
+
*
|
|
3517
|
+
* // all serializable datastructures are supported (no need to call JSON.stringify)
|
|
3518
|
+
* socket.emit("hello", 1, "2", { 3: ["4"], 5: Uint8Array.from([6]) });
|
|
3519
|
+
*
|
|
3520
|
+
* // with an acknowledgement from the server
|
|
3521
|
+
* socket.emit("hello", "world", (val) => {
|
|
3522
|
+
* // ...
|
|
3523
|
+
* });
|
|
3524
|
+
*
|
|
3202
3525
|
* @return self
|
|
3203
|
-
* @public
|
|
3204
3526
|
*/
|
|
3205
3527
|
|
|
3206
3528
|
}, {
|
|
3207
3529
|
key: "emit",
|
|
3208
3530
|
value: function emit(ev) {
|
|
3209
3531
|
if (RESERVED_EVENTS.hasOwnProperty(ev)) {
|
|
3210
|
-
throw new Error('"' + ev + '" is a reserved event name');
|
|
3532
|
+
throw new Error('"' + ev.toString() + '" is a reserved event name');
|
|
3211
3533
|
}
|
|
3212
3534
|
|
|
3213
3535
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
@@ -3215,6 +3537,13 @@
|
|
|
3215
3537
|
}
|
|
3216
3538
|
|
|
3217
3539
|
args.unshift(ev);
|
|
3540
|
+
|
|
3541
|
+
if (this._opts.retries && !this.flags.fromQueue && !this.flags["volatile"]) {
|
|
3542
|
+
this._addToQueue(args);
|
|
3543
|
+
|
|
3544
|
+
return this;
|
|
3545
|
+
}
|
|
3546
|
+
|
|
3218
3547
|
var packet = {
|
|
3219
3548
|
type: PacketType.EVENT,
|
|
3220
3549
|
data: args
|
|
@@ -3253,7 +3582,9 @@
|
|
|
3253
3582
|
value: function _registerAckCallback(id, ack) {
|
|
3254
3583
|
var _this2 = this;
|
|
3255
3584
|
|
|
3256
|
-
var
|
|
3585
|
+
var _a;
|
|
3586
|
+
|
|
3587
|
+
var timeout = (_a = this.flags.timeout) !== null && _a !== void 0 ? _a : this._opts.ackTimeout;
|
|
3257
3588
|
|
|
3258
3589
|
if (timeout === undefined) {
|
|
3259
3590
|
this.acks[id] = ack;
|
|
@@ -3284,6 +3615,135 @@
|
|
|
3284
3615
|
ack.apply(_this2, [null].concat(args));
|
|
3285
3616
|
};
|
|
3286
3617
|
}
|
|
3618
|
+
/**
|
|
3619
|
+
* Emits an event and waits for an acknowledgement
|
|
3620
|
+
*
|
|
3621
|
+
* @example
|
|
3622
|
+
* // without timeout
|
|
3623
|
+
* const response = await socket.emitWithAck("hello", "world");
|
|
3624
|
+
*
|
|
3625
|
+
* // with a specific timeout
|
|
3626
|
+
* try {
|
|
3627
|
+
* const response = await socket.timeout(1000).emitWithAck("hello", "world");
|
|
3628
|
+
* } catch (err) {
|
|
3629
|
+
* // the server did not acknowledge the event in the given delay
|
|
3630
|
+
* }
|
|
3631
|
+
*
|
|
3632
|
+
* @return a Promise that will be fulfilled when the server acknowledges the event
|
|
3633
|
+
*/
|
|
3634
|
+
|
|
3635
|
+
}, {
|
|
3636
|
+
key: "emitWithAck",
|
|
3637
|
+
value: function emitWithAck(ev) {
|
|
3638
|
+
var _this3 = this;
|
|
3639
|
+
|
|
3640
|
+
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
3641
|
+
args[_key4 - 1] = arguments[_key4];
|
|
3642
|
+
}
|
|
3643
|
+
|
|
3644
|
+
// the timeout flag is optional
|
|
3645
|
+
var withErr = this.flags.timeout !== undefined || this._opts.ackTimeout !== undefined;
|
|
3646
|
+
return new Promise(function (resolve, reject) {
|
|
3647
|
+
args.push(function (arg1, arg2) {
|
|
3648
|
+
if (withErr) {
|
|
3649
|
+
return arg1 ? reject(arg1) : resolve(arg2);
|
|
3650
|
+
} else {
|
|
3651
|
+
return resolve(arg1);
|
|
3652
|
+
}
|
|
3653
|
+
});
|
|
3654
|
+
|
|
3655
|
+
_this3.emit.apply(_this3, [ev].concat(args));
|
|
3656
|
+
});
|
|
3657
|
+
}
|
|
3658
|
+
/**
|
|
3659
|
+
* Add the packet to the queue.
|
|
3660
|
+
* @param args
|
|
3661
|
+
* @private
|
|
3662
|
+
*/
|
|
3663
|
+
|
|
3664
|
+
}, {
|
|
3665
|
+
key: "_addToQueue",
|
|
3666
|
+
value: function _addToQueue(args) {
|
|
3667
|
+
var _this4 = this;
|
|
3668
|
+
|
|
3669
|
+
var ack;
|
|
3670
|
+
|
|
3671
|
+
if (typeof args[args.length - 1] === "function") {
|
|
3672
|
+
ack = args.pop();
|
|
3673
|
+
}
|
|
3674
|
+
|
|
3675
|
+
var packet = {
|
|
3676
|
+
id: this._queueSeq++,
|
|
3677
|
+
tryCount: 0,
|
|
3678
|
+
pending: false,
|
|
3679
|
+
args: args,
|
|
3680
|
+
flags: _extends({
|
|
3681
|
+
fromQueue: true
|
|
3682
|
+
}, this.flags)
|
|
3683
|
+
};
|
|
3684
|
+
args.push(function (err) {
|
|
3685
|
+
if (packet !== _this4._queue[0]) {
|
|
3686
|
+
// the packet has already been acknowledged
|
|
3687
|
+
return;
|
|
3688
|
+
}
|
|
3689
|
+
|
|
3690
|
+
var hasError = err !== null;
|
|
3691
|
+
|
|
3692
|
+
if (hasError) {
|
|
3693
|
+
if (packet.tryCount > _this4._opts.retries) {
|
|
3694
|
+
_this4._queue.shift();
|
|
3695
|
+
|
|
3696
|
+
if (ack) {
|
|
3697
|
+
ack(err);
|
|
3698
|
+
}
|
|
3699
|
+
}
|
|
3700
|
+
} else {
|
|
3701
|
+
_this4._queue.shift();
|
|
3702
|
+
|
|
3703
|
+
if (ack) {
|
|
3704
|
+
for (var _len5 = arguments.length, responseArgs = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
|
|
3705
|
+
responseArgs[_key5 - 1] = arguments[_key5];
|
|
3706
|
+
}
|
|
3707
|
+
|
|
3708
|
+
ack.apply(void 0, [null].concat(responseArgs));
|
|
3709
|
+
}
|
|
3710
|
+
}
|
|
3711
|
+
|
|
3712
|
+
packet.pending = false;
|
|
3713
|
+
return _this4._drainQueue();
|
|
3714
|
+
});
|
|
3715
|
+
|
|
3716
|
+
this._queue.push(packet);
|
|
3717
|
+
|
|
3718
|
+
this._drainQueue();
|
|
3719
|
+
}
|
|
3720
|
+
/**
|
|
3721
|
+
* Send the first packet of the queue, and wait for an acknowledgement from the server.
|
|
3722
|
+
* @param force - whether to resend a packet that has not been acknowledged yet
|
|
3723
|
+
*
|
|
3724
|
+
* @private
|
|
3725
|
+
*/
|
|
3726
|
+
|
|
3727
|
+
}, {
|
|
3728
|
+
key: "_drainQueue",
|
|
3729
|
+
value: function _drainQueue() {
|
|
3730
|
+
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
3731
|
+
|
|
3732
|
+
if (!this.connected || this._queue.length === 0) {
|
|
3733
|
+
return;
|
|
3734
|
+
}
|
|
3735
|
+
|
|
3736
|
+
var packet = this._queue[0];
|
|
3737
|
+
|
|
3738
|
+
if (packet.pending && !force) {
|
|
3739
|
+
return;
|
|
3740
|
+
}
|
|
3741
|
+
|
|
3742
|
+
packet.pending = true;
|
|
3743
|
+
packet.tryCount++;
|
|
3744
|
+
this.flags = packet.flags;
|
|
3745
|
+
this.emit.apply(this, packet.args);
|
|
3746
|
+
}
|
|
3287
3747
|
/**
|
|
3288
3748
|
* Sends a packet.
|
|
3289
3749
|
*
|
|
@@ -3307,22 +3767,34 @@
|
|
|
3307
3767
|
}, {
|
|
3308
3768
|
key: "onopen",
|
|
3309
3769
|
value: function onopen() {
|
|
3310
|
-
var
|
|
3770
|
+
var _this5 = this;
|
|
3311
3771
|
|
|
3312
3772
|
if (typeof this.auth == "function") {
|
|
3313
3773
|
this.auth(function (data) {
|
|
3314
|
-
|
|
3315
|
-
type: PacketType.CONNECT,
|
|
3316
|
-
data: data
|
|
3317
|
-
});
|
|
3774
|
+
_this5._sendConnectPacket(data);
|
|
3318
3775
|
});
|
|
3319
3776
|
} else {
|
|
3320
|
-
this.
|
|
3321
|
-
type: PacketType.CONNECT,
|
|
3322
|
-
data: this.auth
|
|
3323
|
-
});
|
|
3777
|
+
this._sendConnectPacket(this.auth);
|
|
3324
3778
|
}
|
|
3325
3779
|
}
|
|
3780
|
+
/**
|
|
3781
|
+
* Sends a CONNECT packet to initiate the Socket.IO session.
|
|
3782
|
+
*
|
|
3783
|
+
* @param data
|
|
3784
|
+
* @private
|
|
3785
|
+
*/
|
|
3786
|
+
|
|
3787
|
+
}, {
|
|
3788
|
+
key: "_sendConnectPacket",
|
|
3789
|
+
value: function _sendConnectPacket(data) {
|
|
3790
|
+
this.packet({
|
|
3791
|
+
type: PacketType.CONNECT,
|
|
3792
|
+
data: this._pid ? _extends({
|
|
3793
|
+
pid: this._pid,
|
|
3794
|
+
offset: this._lastOffset
|
|
3795
|
+
}, data) : data
|
|
3796
|
+
});
|
|
3797
|
+
}
|
|
3326
3798
|
/**
|
|
3327
3799
|
* Called upon engine or manager `error`.
|
|
3328
3800
|
*
|
|
@@ -3368,8 +3840,7 @@
|
|
|
3368
3840
|
switch (packet.type) {
|
|
3369
3841
|
case PacketType.CONNECT:
|
|
3370
3842
|
if (packet.data && packet.data.sid) {
|
|
3371
|
-
|
|
3372
|
-
this.onconnect(id);
|
|
3843
|
+
this.onconnect(packet.data.sid, packet.data.pid);
|
|
3373
3844
|
} else {
|
|
3374
3845
|
this.emitReserved("connect_error", new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
|
|
3375
3846
|
}
|
|
@@ -3443,6 +3914,10 @@
|
|
|
3443
3914
|
}
|
|
3444
3915
|
|
|
3445
3916
|
_get(_getPrototypeOf(Socket.prototype), "emit", this).apply(this, args);
|
|
3917
|
+
|
|
3918
|
+
if (this._pid && args.length && typeof args[args.length - 1] === "string") {
|
|
3919
|
+
this._lastOffset = args[args.length - 1];
|
|
3920
|
+
}
|
|
3446
3921
|
}
|
|
3447
3922
|
/**
|
|
3448
3923
|
* Produces an ack callback to emit with an event.
|
|
@@ -3460,8 +3935,8 @@
|
|
|
3460
3935
|
if (sent) return;
|
|
3461
3936
|
sent = true;
|
|
3462
3937
|
|
|
3463
|
-
for (var
|
|
3464
|
-
args[
|
|
3938
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
3939
|
+
args[_key6] = arguments[_key6];
|
|
3465
3940
|
}
|
|
3466
3941
|
|
|
3467
3942
|
self.packet({
|
|
@@ -3496,11 +3971,16 @@
|
|
|
3496
3971
|
|
|
3497
3972
|
}, {
|
|
3498
3973
|
key: "onconnect",
|
|
3499
|
-
value: function onconnect(id) {
|
|
3974
|
+
value: function onconnect(id, pid) {
|
|
3500
3975
|
this.id = id;
|
|
3976
|
+
this.recovered = pid && this._pid === pid;
|
|
3977
|
+
this._pid = pid; // defined only if connection state recovery is enabled
|
|
3978
|
+
|
|
3501
3979
|
this.connected = true;
|
|
3502
3980
|
this.emitBuffered();
|
|
3503
3981
|
this.emitReserved("connect");
|
|
3982
|
+
|
|
3983
|
+
this._drainQueue(true);
|
|
3504
3984
|
}
|
|
3505
3985
|
/**
|
|
3506
3986
|
* Emit buffered events (received and emitted).
|
|
@@ -3511,16 +3991,16 @@
|
|
|
3511
3991
|
}, {
|
|
3512
3992
|
key: "emitBuffered",
|
|
3513
3993
|
value: function emitBuffered() {
|
|
3514
|
-
var
|
|
3994
|
+
var _this6 = this;
|
|
3515
3995
|
|
|
3516
3996
|
this.receiveBuffer.forEach(function (args) {
|
|
3517
|
-
return
|
|
3997
|
+
return _this6.emitEvent(args);
|
|
3518
3998
|
});
|
|
3519
3999
|
this.receiveBuffer = [];
|
|
3520
4000
|
this.sendBuffer.forEach(function (packet) {
|
|
3521
|
-
|
|
4001
|
+
_this6.notifyOutgoingListeners(packet);
|
|
3522
4002
|
|
|
3523
|
-
|
|
4003
|
+
_this6.packet(packet);
|
|
3524
4004
|
});
|
|
3525
4005
|
this.sendBuffer = [];
|
|
3526
4006
|
}
|
|
@@ -3558,10 +4038,20 @@
|
|
|
3558
4038
|
this.io["_destroy"](this);
|
|
3559
4039
|
}
|
|
3560
4040
|
/**
|
|
3561
|
-
* Disconnects the socket manually.
|
|
4041
|
+
* Disconnects the socket manually. In that case, the socket will not try to reconnect.
|
|
4042
|
+
*
|
|
4043
|
+
* If this is the last active Socket instance of the {@link Manager}, the low-level connection will be closed.
|
|
4044
|
+
*
|
|
4045
|
+
* @example
|
|
4046
|
+
* const socket = io();
|
|
4047
|
+
*
|
|
4048
|
+
* socket.on("disconnect", (reason) => {
|
|
4049
|
+
* // console.log(reason); prints "io client disconnect"
|
|
4050
|
+
* });
|
|
4051
|
+
*
|
|
4052
|
+
* socket.disconnect();
|
|
3562
4053
|
*
|
|
3563
4054
|
* @return self
|
|
3564
|
-
* @public
|
|
3565
4055
|
*/
|
|
3566
4056
|
|
|
3567
4057
|
}, {
|
|
@@ -3584,10 +4074,9 @@
|
|
|
3584
4074
|
return this;
|
|
3585
4075
|
}
|
|
3586
4076
|
/**
|
|
3587
|
-
* Alias for disconnect()
|
|
4077
|
+
* Alias for {@link disconnect()}.
|
|
3588
4078
|
*
|
|
3589
4079
|
* @return self
|
|
3590
|
-
* @public
|
|
3591
4080
|
*/
|
|
3592
4081
|
|
|
3593
4082
|
}, {
|
|
@@ -3598,9 +4087,11 @@
|
|
|
3598
4087
|
/**
|
|
3599
4088
|
* Sets the compress flag.
|
|
3600
4089
|
*
|
|
4090
|
+
* @example
|
|
4091
|
+
* socket.compress(false).emit("hello");
|
|
4092
|
+
*
|
|
3601
4093
|
* @param compress - if `true`, compresses the sending data
|
|
3602
4094
|
* @return self
|
|
3603
|
-
* @public
|
|
3604
4095
|
*/
|
|
3605
4096
|
|
|
3606
4097
|
}, {
|
|
@@ -3613,8 +4104,10 @@
|
|
|
3613
4104
|
* Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not
|
|
3614
4105
|
* ready to send messages.
|
|
3615
4106
|
*
|
|
4107
|
+
* @example
|
|
4108
|
+
* socket.volatile.emit("hello"); // the server may or may not receive it
|
|
4109
|
+
*
|
|
3616
4110
|
* @returns self
|
|
3617
|
-
* @public
|
|
3618
4111
|
*/
|
|
3619
4112
|
|
|
3620
4113
|
}, {
|
|
@@ -3627,16 +4120,14 @@
|
|
|
3627
4120
|
* Sets a modifier for a subsequent event emission that the callback will be called with an error when the
|
|
3628
4121
|
* given number of milliseconds have elapsed without an acknowledgement from the server:
|
|
3629
4122
|
*
|
|
3630
|
-
*
|
|
4123
|
+
* @example
|
|
3631
4124
|
* socket.timeout(5000).emit("my-event", (err) => {
|
|
3632
4125
|
* if (err) {
|
|
3633
4126
|
* // the server did not acknowledge the event in the given delay
|
|
3634
4127
|
* }
|
|
3635
4128
|
* });
|
|
3636
|
-
* ```
|
|
3637
4129
|
*
|
|
3638
4130
|
* @returns self
|
|
3639
|
-
* @public
|
|
3640
4131
|
*/
|
|
3641
4132
|
|
|
3642
4133
|
}, {
|
|
@@ -3649,8 +4140,12 @@
|
|
|
3649
4140
|
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
|
3650
4141
|
* callback.
|
|
3651
4142
|
*
|
|
4143
|
+
* @example
|
|
4144
|
+
* socket.onAny((event, ...args) => {
|
|
4145
|
+
* console.log(`got ${event}`);
|
|
4146
|
+
* });
|
|
4147
|
+
*
|
|
3652
4148
|
* @param listener
|
|
3653
|
-
* @public
|
|
3654
4149
|
*/
|
|
3655
4150
|
|
|
3656
4151
|
}, {
|
|
@@ -3666,8 +4161,12 @@
|
|
|
3666
4161
|
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
|
3667
4162
|
* callback. The listener is added to the beginning of the listeners array.
|
|
3668
4163
|
*
|
|
4164
|
+
* @example
|
|
4165
|
+
* socket.prependAny((event, ...args) => {
|
|
4166
|
+
* console.log(`got event ${event}`);
|
|
4167
|
+
* });
|
|
4168
|
+
*
|
|
3669
4169
|
* @param listener
|
|
3670
|
-
* @public
|
|
3671
4170
|
*/
|
|
3672
4171
|
|
|
3673
4172
|
}, {
|
|
@@ -3682,8 +4181,20 @@
|
|
|
3682
4181
|
/**
|
|
3683
4182
|
* Removes the listener that will be fired when any event is emitted.
|
|
3684
4183
|
*
|
|
4184
|
+
* @example
|
|
4185
|
+
* const catchAllListener = (event, ...args) => {
|
|
4186
|
+
* console.log(`got event ${event}`);
|
|
4187
|
+
* }
|
|
4188
|
+
*
|
|
4189
|
+
* socket.onAny(catchAllListener);
|
|
4190
|
+
*
|
|
4191
|
+
* // remove a specific listener
|
|
4192
|
+
* socket.offAny(catchAllListener);
|
|
4193
|
+
*
|
|
4194
|
+
* // or remove all listeners
|
|
4195
|
+
* socket.offAny();
|
|
4196
|
+
*
|
|
3685
4197
|
* @param listener
|
|
3686
|
-
* @public
|
|
3687
4198
|
*/
|
|
3688
4199
|
|
|
3689
4200
|
}, {
|
|
@@ -3711,8 +4222,6 @@
|
|
|
3711
4222
|
/**
|
|
3712
4223
|
* Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
|
|
3713
4224
|
* e.g. to remove listeners.
|
|
3714
|
-
*
|
|
3715
|
-
* @public
|
|
3716
4225
|
*/
|
|
3717
4226
|
|
|
3718
4227
|
}, {
|
|
@@ -3724,17 +4233,14 @@
|
|
|
3724
4233
|
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
|
3725
4234
|
* callback.
|
|
3726
4235
|
*
|
|
3727
|
-
*
|
|
3728
|
-
*
|
|
3729
|
-
* <pre><code>
|
|
4236
|
+
* Note: acknowledgements sent to the server are not included.
|
|
3730
4237
|
*
|
|
4238
|
+
* @example
|
|
3731
4239
|
* socket.onAnyOutgoing((event, ...args) => {
|
|
3732
|
-
* console.log(event);
|
|
4240
|
+
* console.log(`sent event ${event}`);
|
|
3733
4241
|
* });
|
|
3734
4242
|
*
|
|
3735
|
-
*
|
|
3736
|
-
*
|
|
3737
|
-
* @public
|
|
4243
|
+
* @param listener
|
|
3738
4244
|
*/
|
|
3739
4245
|
|
|
3740
4246
|
}, {
|
|
@@ -3750,17 +4256,14 @@
|
|
|
3750
4256
|
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
|
3751
4257
|
* callback. The listener is added to the beginning of the listeners array.
|
|
3752
4258
|
*
|
|
3753
|
-
*
|
|
3754
|
-
*
|
|
3755
|
-
* <pre><code>
|
|
4259
|
+
* Note: acknowledgements sent to the server are not included.
|
|
3756
4260
|
*
|
|
4261
|
+
* @example
|
|
3757
4262
|
* socket.prependAnyOutgoing((event, ...args) => {
|
|
3758
|
-
* console.log(event);
|
|
4263
|
+
* console.log(`sent event ${event}`);
|
|
3759
4264
|
* });
|
|
3760
4265
|
*
|
|
3761
|
-
*
|
|
3762
|
-
*
|
|
3763
|
-
* @public
|
|
4266
|
+
* @param listener
|
|
3764
4267
|
*/
|
|
3765
4268
|
|
|
3766
4269
|
}, {
|
|
@@ -3775,22 +4278,20 @@
|
|
|
3775
4278
|
/**
|
|
3776
4279
|
* Removes the listener that will be fired when any event is emitted.
|
|
3777
4280
|
*
|
|
3778
|
-
* @
|
|
3779
|
-
*
|
|
3780
|
-
*
|
|
3781
|
-
*
|
|
3782
|
-
* const handler = (event, ...args) => {
|
|
3783
|
-
* console.log(event);
|
|
4281
|
+
* @example
|
|
4282
|
+
* const catchAllListener = (event, ...args) => {
|
|
4283
|
+
* console.log(`sent event ${event}`);
|
|
3784
4284
|
* }
|
|
3785
4285
|
*
|
|
3786
|
-
* socket.onAnyOutgoing(
|
|
4286
|
+
* socket.onAnyOutgoing(catchAllListener);
|
|
3787
4287
|
*
|
|
3788
|
-
* //
|
|
3789
|
-
* socket.offAnyOutgoing(
|
|
4288
|
+
* // remove a specific listener
|
|
4289
|
+
* socket.offAnyOutgoing(catchAllListener);
|
|
3790
4290
|
*
|
|
3791
|
-
*
|
|
4291
|
+
* // or remove all listeners
|
|
4292
|
+
* socket.offAnyOutgoing();
|
|
3792
4293
|
*
|
|
3793
|
-
* @
|
|
4294
|
+
* @param [listener] - the catch-all listener (optional)
|
|
3794
4295
|
*/
|
|
3795
4296
|
|
|
3796
4297
|
}, {
|
|
@@ -3818,8 +4319,6 @@
|
|
|
3818
4319
|
/**
|
|
3819
4320
|
* Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
|
|
3820
4321
|
* e.g. to remove listeners.
|
|
3821
|
-
*
|
|
3822
|
-
* @public
|
|
3823
4322
|
*/
|
|
3824
4323
|
|
|
3825
4324
|
}, {
|
|
@@ -4085,11 +4584,12 @@
|
|
|
4085
4584
|
var openSubDestroy = on(socket, "open", function () {
|
|
4086
4585
|
self.onopen();
|
|
4087
4586
|
fn && fn();
|
|
4088
|
-
});
|
|
4587
|
+
});
|
|
4588
|
+
|
|
4589
|
+
var onError = function onError(err) {
|
|
4590
|
+
_this2.cleanup();
|
|
4089
4591
|
|
|
4090
|
-
|
|
4091
|
-
self.cleanup();
|
|
4092
|
-
self._readyState = "closed";
|
|
4592
|
+
_this2._readyState = "closed";
|
|
4093
4593
|
|
|
4094
4594
|
_this2.emitReserved("error", err);
|
|
4095
4595
|
|
|
@@ -4097,31 +4597,28 @@
|
|
|
4097
4597
|
fn(err);
|
|
4098
4598
|
} else {
|
|
4099
4599
|
// Only do this if there is no fn to handle the error
|
|
4100
|
-
|
|
4600
|
+
_this2.maybeReconnectOnOpen();
|
|
4101
4601
|
}
|
|
4102
|
-
}
|
|
4602
|
+
}; // emit `error`
|
|
4103
4603
|
|
|
4104
|
-
if (false !== this._timeout) {
|
|
4105
|
-
var timeout = this._timeout;
|
|
4106
4604
|
|
|
4107
|
-
|
|
4108
|
-
openSubDestroy(); // prevents a race condition with the 'open' event
|
|
4109
|
-
} // set timer
|
|
4605
|
+
var errorSub = on(socket, "error", onError);
|
|
4110
4606
|
|
|
4607
|
+
if (false !== this._timeout) {
|
|
4608
|
+
var timeout = this._timeout; // set timer
|
|
4111
4609
|
|
|
4112
4610
|
var timer = this.setTimeoutFn(function () {
|
|
4113
4611
|
openSubDestroy();
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
socket.emit("error", new Error("timeout"));
|
|
4612
|
+
onError(new Error("timeout"));
|
|
4613
|
+
socket.close();
|
|
4117
4614
|
}, timeout);
|
|
4118
4615
|
|
|
4119
4616
|
if (this.opts.autoUnref) {
|
|
4120
4617
|
timer.unref();
|
|
4121
4618
|
}
|
|
4122
4619
|
|
|
4123
|
-
this.subs.push(function
|
|
4124
|
-
|
|
4620
|
+
this.subs.push(function () {
|
|
4621
|
+
_this2.clearTimeoutFn(timer);
|
|
4125
4622
|
});
|
|
4126
4623
|
}
|
|
4127
4624
|
|
|
@@ -4179,7 +4676,11 @@
|
|
|
4179
4676
|
}, {
|
|
4180
4677
|
key: "ondata",
|
|
4181
4678
|
value: function ondata(data) {
|
|
4182
|
-
|
|
4679
|
+
try {
|
|
4680
|
+
this.decoder.add(data);
|
|
4681
|
+
} catch (e) {
|
|
4682
|
+
this.onclose("parse error", e);
|
|
4683
|
+
}
|
|
4183
4684
|
}
|
|
4184
4685
|
/**
|
|
4185
4686
|
* Called when parser fully decodes a packet.
|
|
@@ -4190,7 +4691,12 @@
|
|
|
4190
4691
|
}, {
|
|
4191
4692
|
key: "ondecoded",
|
|
4192
4693
|
value: function ondecoded(packet) {
|
|
4193
|
-
this
|
|
4694
|
+
var _this3 = this;
|
|
4695
|
+
|
|
4696
|
+
// the nextTick call prevents an exception in a user-provided event listener from triggering a disconnection due to a "parse error"
|
|
4697
|
+
nextTick(function () {
|
|
4698
|
+
_this3.emitReserved("packet", packet);
|
|
4699
|
+
}, this.setTimeoutFn);
|
|
4194
4700
|
}
|
|
4195
4701
|
/**
|
|
4196
4702
|
* Called upon socket error.
|
|
@@ -4218,6 +4724,8 @@
|
|
|
4218
4724
|
if (!socket) {
|
|
4219
4725
|
socket = new Socket(this, nsp, opts);
|
|
4220
4726
|
this.nsps[nsp] = socket;
|
|
4727
|
+
} else if (this._autoConnect && !socket.active) {
|
|
4728
|
+
socket.connect();
|
|
4221
4729
|
}
|
|
4222
4730
|
|
|
4223
4731
|
return socket;
|
|
@@ -4328,7 +4836,7 @@
|
|
|
4328
4836
|
}, {
|
|
4329
4837
|
key: "reconnect",
|
|
4330
4838
|
value: function reconnect() {
|
|
4331
|
-
var
|
|
4839
|
+
var _this4 = this;
|
|
4332
4840
|
|
|
4333
4841
|
if (this._reconnecting || this.skipReconnect) return this;
|
|
4334
4842
|
var self = this;
|
|
@@ -4343,7 +4851,7 @@
|
|
|
4343
4851
|
var timer = this.setTimeoutFn(function () {
|
|
4344
4852
|
if (self.skipReconnect) return;
|
|
4345
4853
|
|
|
4346
|
-
|
|
4854
|
+
_this4.emitReserved("reconnect_attempt", self.backoff.attempts); // check again for the case socket closed in above events
|
|
4347
4855
|
|
|
4348
4856
|
|
|
4349
4857
|
if (self.skipReconnect) return;
|
|
@@ -4352,7 +4860,7 @@
|
|
|
4352
4860
|
self._reconnecting = false;
|
|
4353
4861
|
self.reconnect();
|
|
4354
4862
|
|
|
4355
|
-
|
|
4863
|
+
_this4.emitReserved("reconnect_error", err);
|
|
4356
4864
|
} else {
|
|
4357
4865
|
self.onreconnect();
|
|
4358
4866
|
}
|
|
@@ -4363,8 +4871,8 @@
|
|
|
4363
4871
|
timer.unref();
|
|
4364
4872
|
}
|
|
4365
4873
|
|
|
4366
|
-
this.subs.push(function
|
|
4367
|
-
|
|
4874
|
+
this.subs.push(function () {
|
|
4875
|
+
_this4.clearTimeoutFn(timer);
|
|
4368
4876
|
});
|
|
4369
4877
|
}
|
|
4370
4878
|
}
|