mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-12 16:38:12 -05:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c100b7b61c | ||
|
|
f03eeca39a | ||
|
|
d8cc8aef7e | ||
|
|
ccfd8caba6 | ||
|
|
24fee27ba3 | ||
|
|
310f8557a7 | ||
|
|
dbd2a07cda | ||
|
|
94e27cd072 | ||
|
|
a4dffc6527 | ||
|
|
7c44893d78 | ||
|
|
b833f918c8 | ||
|
|
24d8d1f67f | ||
|
|
6f2a50b932 |
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -12,12 +12,12 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [10.x, 12.x, 14.x, 15.x]
|
||||
node-version: [12, 14, 16]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm ci
|
||||
|
||||
22
CHANGELOG.md
22
CHANGELOG.md
@@ -1,3 +1,25 @@
|
||||
# [4.2.0](https://github.com/socketio/socket.io/compare/4.1.3...4.2.0) (2021-08-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **typings:** allow async listener in typed events ([ccfd8ca](https://github.com/socketio/socket.io/commit/ccfd8caba6d38b7ba6c5114bd8179346ed07671c))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* ignore the query string when serving client JavaScript ([#4024](https://github.com/socketio/socket.io/issues/4024)) ([24fee27](https://github.com/socketio/socket.io/commit/24fee27ba36485308f8e995879c10931532c814e))
|
||||
|
||||
|
||||
## [4.1.3](https://github.com/socketio/socket.io/compare/4.1.2...4.1.3) (2021-07-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix io.except() method ([94e27cd](https://github.com/socketio/socket.io/commit/94e27cd072c8a4eeb9636f6ffbb7a21d382f36b0))
|
||||
* remove x-sourcemap header ([a4dffc6](https://github.com/socketio/socket.io/commit/a4dffc6527f412d51a786ae5bf2e9080fe1ca63c))
|
||||
|
||||
|
||||
## [4.1.2](https://github.com/socketio/socket.io/compare/4.1.1...4.1.2) (2021-05-17)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# socket.io
|
||||
[](https://repl.it/github/socketio/socket.io)
|
||||
[](https://replit.com/@socketio/socketio-minimal-example)
|
||||
[](#backers) [](#sponsors)
|
||||
[](https://github.com/socketio/socket.io/actions)
|
||||
[](https://david-dm.org/socketio/socket.io)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* Socket.IO v4.1.2
|
||||
* Socket.IO v4.2.0
|
||||
* (c) 2014-2021 Guillermo Rauch
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
@@ -142,7 +142,7 @@ function lookup(uri, opts) {
|
||||
}
|
||||
|
||||
opts = opts || {};
|
||||
var parsed = url_1.url(uri, opts.path || "/socket.io");
|
||||
var parsed = (0, url_1.url)(uri, opts.path || "/socket.io");
|
||||
var source = parsed.source;
|
||||
var id = parsed.id;
|
||||
var path = parsed.path;
|
||||
@@ -243,11 +243,11 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
@@ -258,6 +258,8 @@ exports.Manager = void 0;
|
||||
|
||||
var eio = __webpack_require__(/*! engine.io-client */ "./node_modules/engine.io-client/lib/index.js");
|
||||
|
||||
var util_1 = __webpack_require__(/*! engine.io-client/lib/util */ "./node_modules/engine.io-client/lib/util.js");
|
||||
|
||||
var socket_1 = __webpack_require__(/*! ./socket */ "./build/socket.js");
|
||||
|
||||
var parser = __webpack_require__(/*! socket.io-parser */ "./node_modules/socket.io-parser/dist/index.js");
|
||||
@@ -280,6 +282,8 @@ var Manager = /*#__PURE__*/function (_typed_events_1$Stric) {
|
||||
|
||||
_classCallCheck(this, Manager);
|
||||
|
||||
var _a;
|
||||
|
||||
_this = _super.call(this);
|
||||
_this.nsps = {};
|
||||
_this.subs = [];
|
||||
@@ -292,6 +296,7 @@ var Manager = /*#__PURE__*/function (_typed_events_1$Stric) {
|
||||
opts = opts || {};
|
||||
opts.path = opts.path || "/socket.io";
|
||||
_this.opts = opts;
|
||||
(0, util_1.installTimerFunctions)(_assertThisInitialized(_this), opts);
|
||||
|
||||
_this.reconnection(opts.reconnection !== false);
|
||||
|
||||
@@ -301,7 +306,7 @@ var Manager = /*#__PURE__*/function (_typed_events_1$Stric) {
|
||||
|
||||
_this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000);
|
||||
|
||||
_this.randomizationFactor(opts.randomizationFactor || 0.5);
|
||||
_this.randomizationFactor((_a = opts.randomizationFactor) !== null && _a !== void 0 ? _a : 0.5);
|
||||
|
||||
_this.backoff = new Backoff({
|
||||
min: _this.reconnectionDelay(),
|
||||
@@ -412,12 +417,12 @@ var Manager = /*#__PURE__*/function (_typed_events_1$Stric) {
|
||||
this._readyState = "opening";
|
||||
this.skipReconnect = false; // emit `open`
|
||||
|
||||
var openSubDestroy = on_1.on(socket, "open", function () {
|
||||
var openSubDestroy = (0, on_1.on)(socket, "open", function () {
|
||||
self.onopen();
|
||||
fn && fn();
|
||||
}); // emit `error`
|
||||
|
||||
var errorSub = on_1.on(socket, "error", function (err) {
|
||||
var errorSub = (0, on_1.on)(socket, "error", function (err) {
|
||||
debug("error");
|
||||
self.cleanup();
|
||||
self._readyState = "closed";
|
||||
@@ -441,7 +446,7 @@ var Manager = /*#__PURE__*/function (_typed_events_1$Stric) {
|
||||
} // set timer
|
||||
|
||||
|
||||
var timer = setTimeout(function () {
|
||||
var timer = this.setTimeoutFn(function () {
|
||||
debug("connect attempt timed out after %d", timeout);
|
||||
openSubDestroy();
|
||||
socket.close();
|
||||
@@ -490,7 +495,7 @@ var Manager = /*#__PURE__*/function (_typed_events_1$Stric) {
|
||||
this.emitReserved("open"); // add new subs
|
||||
|
||||
var socket = this.engine;
|
||||
this.subs.push(on_1.on(socket, "ping", this.onping.bind(this)), on_1.on(socket, "data", this.ondata.bind(this)), on_1.on(socket, "error", this.onerror.bind(this)), on_1.on(socket, "close", this.onclose.bind(this)), on_1.on(this.decoder, "decoded", this.ondecoded.bind(this)));
|
||||
this.subs.push((0, on_1.on)(socket, "ping", this.onping.bind(this)), (0, on_1.on)(socket, "data", this.ondata.bind(this)), (0, on_1.on)(socket, "error", this.onerror.bind(this)), (0, on_1.on)(socket, "close", this.onclose.bind(this)), (0, on_1.on)(this.decoder, "decoded", this.ondecoded.bind(this)));
|
||||
}
|
||||
/**
|
||||
* Called upon a ping.
|
||||
@@ -689,7 +694,7 @@ var Manager = /*#__PURE__*/function (_typed_events_1$Stric) {
|
||||
var delay = this.backoff.duration();
|
||||
debug("will wait %dms before reconnect attempt", delay);
|
||||
this._reconnecting = true;
|
||||
var timer = setTimeout(function () {
|
||||
var timer = this.setTimeoutFn(function () {
|
||||
if (self.skipReconnect) return;
|
||||
debug("attempting reconnect");
|
||||
|
||||
@@ -781,7 +786,7 @@ exports.on = on;
|
||||
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
@@ -803,11 +808,11 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
@@ -855,6 +860,8 @@ var Socket = /*#__PURE__*/function (_typed_events_1$Stric) {
|
||||
_classCallCheck(this, Socket);
|
||||
|
||||
_this = _super.call(this);
|
||||
_this.connected = false;
|
||||
_this.disconnected = true;
|
||||
_this.receiveBuffer = [];
|
||||
_this.sendBuffer = [];
|
||||
_this.ids = 0;
|
||||
@@ -862,13 +869,6 @@ var Socket = /*#__PURE__*/function (_typed_events_1$Stric) {
|
||||
_this.flags = {};
|
||||
_this.io = io;
|
||||
_this.nsp = nsp;
|
||||
_this.ids = 0;
|
||||
_this.acks = {};
|
||||
_this.receiveBuffer = [];
|
||||
_this.sendBuffer = [];
|
||||
_this.connected = false;
|
||||
_this.disconnected = true;
|
||||
_this.flags = {};
|
||||
|
||||
if (opts && opts.auth) {
|
||||
_this.auth = opts.auth;
|
||||
@@ -889,20 +889,25 @@ var Socket = /*#__PURE__*/function (_typed_events_1$Stric) {
|
||||
value: function subEvents() {
|
||||
if (this.subs) return;
|
||||
var io = this.io;
|
||||
this.subs = [on_1.on(io, "open", this.onopen.bind(this)), on_1.on(io, "packet", this.onpacket.bind(this)), on_1.on(io, "error", this.onerror.bind(this)), on_1.on(io, "close", this.onclose.bind(this))];
|
||||
this.subs = [(0, on_1.on)(io, "open", this.onopen.bind(this)), (0, on_1.on)(io, "packet", this.onpacket.bind(this)), (0, on_1.on)(io, "error", this.onerror.bind(this)), (0, on_1.on)(io, "close", this.onclose.bind(this))];
|
||||
}
|
||||
/**
|
||||
* Whether the Socket will try to reconnect when its Manager connects or reconnects
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: "connect",
|
||||
|
||||
key: "active",
|
||||
get: function get() {
|
||||
return !!this.subs;
|
||||
}
|
||||
/**
|
||||
* "Opens" the socket.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: "connect",
|
||||
value: function connect() {
|
||||
if (this.connected) return this;
|
||||
this.subEvents();
|
||||
@@ -1335,8 +1340,11 @@ var Socket = /*#__PURE__*/function (_typed_events_1$Stric) {
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: "onAny",
|
||||
|
||||
key: "volatile",
|
||||
get: function get() {
|
||||
this.flags["volatile"] = true;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
||||
* callback.
|
||||
@@ -1344,6 +1352,9 @@ var Socket = /*#__PURE__*/function (_typed_events_1$Stric) {
|
||||
* @param listener
|
||||
* @public
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: "onAny",
|
||||
value: function onAny(listener) {
|
||||
this._anyListeners = this._anyListeners || [];
|
||||
|
||||
@@ -1409,17 +1420,6 @@ var Socket = /*#__PURE__*/function (_typed_events_1$Stric) {
|
||||
value: function listenersAny() {
|
||||
return this._anyListeners || [];
|
||||
}
|
||||
}, {
|
||||
key: "active",
|
||||
get: function get() {
|
||||
return !!this.subs;
|
||||
}
|
||||
}, {
|
||||
key: "volatile",
|
||||
get: function get() {
|
||||
this.flags["volatile"] = true;
|
||||
return this;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Socket;
|
||||
@@ -1457,11 +1457,11 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
@@ -1499,14 +1499,14 @@ var StrictEventEmitter = /*#__PURE__*/function (_Emitter) {
|
||||
|
||||
_createClass(StrictEventEmitter, [{
|
||||
key: "on",
|
||||
|
||||
value:
|
||||
/**
|
||||
* Adds the `listener` function as an event listener for `ev`.
|
||||
*
|
||||
* @param ev Name of the event
|
||||
* @param listener Callback function
|
||||
*/
|
||||
value: function on(ev, listener) {
|
||||
function on(ev, listener) {
|
||||
_get(_getPrototypeOf(StrictEventEmitter.prototype), "on", this).call(this, ev, listener);
|
||||
|
||||
return this;
|
||||
@@ -2003,11 +2003,7 @@ function useColors() {
|
||||
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
||||
|
||||
|
||||
return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
||||
typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
||||
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
||||
typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
||||
typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
||||
return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
||||
}
|
||||
/**
|
||||
* Colorize log arguments if enabled.
|
||||
@@ -2150,7 +2146,7 @@ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread n
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
||||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
||||
|
||||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
||||
|
||||
@@ -2215,6 +2211,8 @@ function setup(env) {
|
||||
function createDebug(namespace) {
|
||||
var prevTime;
|
||||
var enableOverride = null;
|
||||
var namespacesCache;
|
||||
var enabledCache;
|
||||
|
||||
function debug() {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
@@ -2278,7 +2276,16 @@ function setup(env) {
|
||||
enumerable: true,
|
||||
configurable: false,
|
||||
get: function get() {
|
||||
return enableOverride === null ? createDebug.enabled(namespace) : enableOverride;
|
||||
if (enableOverride !== null) {
|
||||
return enableOverride;
|
||||
}
|
||||
|
||||
if (namespacesCache !== createDebug.namespaces) {
|
||||
namespacesCache = createDebug.namespaces;
|
||||
enabledCache = createDebug.enabled(namespace);
|
||||
}
|
||||
|
||||
return enabledCache;
|
||||
},
|
||||
set: function set(v) {
|
||||
enableOverride = v;
|
||||
@@ -2308,6 +2315,7 @@ function setup(env) {
|
||||
|
||||
function enable(namespaces) {
|
||||
createDebug.save(namespaces);
|
||||
createDebug.namespaces = namespaces;
|
||||
createDebug.names = [];
|
||||
createDebug.skips = [];
|
||||
var i;
|
||||
@@ -2490,11 +2498,11 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
@@ -2510,6 +2518,9 @@ var parseuri = __webpack_require__(/*! parseuri */ "./node_modules/parseuri/inde
|
||||
|
||||
var parseqs = __webpack_require__(/*! parseqs */ "./node_modules/parseqs/index.js");
|
||||
|
||||
var _require = __webpack_require__(/*! ./util */ "./node_modules/engine.io-client/lib/util.js"),
|
||||
installTimerFunctions = _require.installTimerFunctions;
|
||||
|
||||
var Socket = /*#__PURE__*/function (_Emitter) {
|
||||
_inherits(Socket, _Emitter);
|
||||
|
||||
@@ -2546,6 +2557,7 @@ var Socket = /*#__PURE__*/function (_Emitter) {
|
||||
opts.hostname = parseuri(opts.host).host;
|
||||
}
|
||||
|
||||
installTimerFunctions(_assertThisInitialized(_this), opts);
|
||||
_this.secure = null != opts.secure ? opts.secure : typeof location !== "undefined" && "https:" === location.protocol;
|
||||
|
||||
if (opts.hostname && !opts.port) {
|
||||
@@ -2665,7 +2677,7 @@ var Socket = /*#__PURE__*/function (_Emitter) {
|
||||
transport = "websocket";
|
||||
} else if (0 === this.transports.length) {
|
||||
// Emit error on next tick so it can be listened to
|
||||
setTimeout(function () {
|
||||
this.setTimeoutFn(function () {
|
||||
_this2.emit("error", "No transports available");
|
||||
}, 0);
|
||||
return;
|
||||
@@ -2883,6 +2895,7 @@ var Socket = /*#__PURE__*/function (_Emitter) {
|
||||
case "ping":
|
||||
this.resetPingTimeout();
|
||||
this.sendPacket("pong");
|
||||
this.emit("ping");
|
||||
this.emit("pong");
|
||||
break;
|
||||
|
||||
@@ -2933,8 +2946,8 @@ var Socket = /*#__PURE__*/function (_Emitter) {
|
||||
value: function resetPingTimeout() {
|
||||
var _this5 = this;
|
||||
|
||||
clearTimeout(this.pingTimeoutTimer);
|
||||
this.pingTimeoutTimer = setTimeout(function () {
|
||||
this.clearTimeoutFn(this.pingTimeoutTimer);
|
||||
this.pingTimeoutTimer = this.setTimeoutFn(function () {
|
||||
_this5.onClose("ping timeout");
|
||||
}, this.pingInterval + this.pingTimeout);
|
||||
|
||||
@@ -3122,8 +3135,8 @@ var Socket = /*#__PURE__*/function (_Emitter) {
|
||||
if ("opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState) {
|
||||
debug('socket close with reason: "%s"', reason); // clear timers
|
||||
|
||||
clearTimeout(this.pingIntervalTimer);
|
||||
clearTimeout(this.pingTimeoutTimer); // stop event from firing again for transport
|
||||
this.clearTimeoutFn(this.pingIntervalTimer);
|
||||
this.clearTimeoutFn(this.pingTimeoutTimer); // stop event from firing again for transport
|
||||
|
||||
this.transport.removeAllListeners("close"); // ensure transport won't stay open
|
||||
|
||||
@@ -3219,11 +3232,11 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
@@ -3231,6 +3244,9 @@ var parser = __webpack_require__(/*! engine.io-parser */ "./node_modules/engine.
|
||||
|
||||
var Emitter = __webpack_require__(/*! component-emitter */ "./node_modules/component-emitter/index.js");
|
||||
|
||||
var _require = __webpack_require__(/*! ./util */ "./node_modules/engine.io-client/lib/util.js"),
|
||||
installTimerFunctions = _require.installTimerFunctions;
|
||||
|
||||
var debug = __webpack_require__(/*! debug */ "./node_modules/debug/src/browser.js")("engine.io-client:transport");
|
||||
|
||||
var Transport = /*#__PURE__*/function (_Emitter) {
|
||||
@@ -3250,6 +3266,7 @@ var Transport = /*#__PURE__*/function (_Emitter) {
|
||||
_classCallCheck(this, Transport);
|
||||
|
||||
_this = _super.call(this);
|
||||
installTimerFunctions(_assertThisInitialized(_this), opts);
|
||||
_this.opts = opts;
|
||||
_this.query = opts.query;
|
||||
_this.readyState = "";
|
||||
@@ -3386,7 +3403,7 @@ module.exports = Transport;
|
||||
/*! no static exports found */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
var XMLHttpRequest = __webpack_require__(/*! ../../contrib/xmlhttprequest-ssl/XMLHttpRequest */ "./node_modules/engine.io-client/lib/xmlhttprequest.js");
|
||||
var XMLHttpRequest = __webpack_require__(/*! xmlhttprequest-ssl */ "./node_modules/engine.io-client/lib/xmlhttprequest.js");
|
||||
|
||||
var XHR = __webpack_require__(/*! ./polling-xhr */ "./node_modules/engine.io-client/lib/transports/polling-xhr.js");
|
||||
|
||||
@@ -3460,11 +3477,11 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
@@ -3519,13 +3536,18 @@ var JSONPPolling = /*#__PURE__*/function (_Polling) {
|
||||
|
||||
|
||||
_createClass(JSONPPolling, [{
|
||||
key: "doClose",
|
||||
|
||||
key: "supportsBinary",
|
||||
get: function get() {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Closes the socket.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: "doClose",
|
||||
value: function doClose() {
|
||||
if (this.script) {
|
||||
// prevent spurious errors from being emitted when the window is unloaded
|
||||
@@ -3580,7 +3602,7 @@ var JSONPPolling = /*#__PURE__*/function (_Polling) {
|
||||
var isUAgecko = "undefined" !== typeof navigator && /gecko/i.test(navigator.userAgent);
|
||||
|
||||
if (isUAgecko) {
|
||||
setTimeout(function () {
|
||||
this.setTimeoutFn(function () {
|
||||
var iframe = document.createElement("iframe");
|
||||
document.body.appendChild(iframe);
|
||||
document.body.removeChild(iframe);
|
||||
@@ -3673,11 +3695,6 @@ var JSONPPolling = /*#__PURE__*/function (_Polling) {
|
||||
this.iframe.onload = complete;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "supportsBinary",
|
||||
get: function get() {
|
||||
return false;
|
||||
}
|
||||
}]);
|
||||
|
||||
return JSONPPolling;
|
||||
@@ -3710,23 +3727,24 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
/* global attachEvent */
|
||||
var XMLHttpRequest = __webpack_require__(/*! ../../contrib/xmlhttprequest-ssl/XMLHttpRequest */ "./node_modules/engine.io-client/lib/xmlhttprequest.js");
|
||||
var XMLHttpRequest = __webpack_require__(/*! xmlhttprequest-ssl */ "./node_modules/engine.io-client/lib/xmlhttprequest.js");
|
||||
|
||||
var Polling = __webpack_require__(/*! ./polling */ "./node_modules/engine.io-client/lib/transports/polling.js");
|
||||
|
||||
var Emitter = __webpack_require__(/*! component-emitter */ "./node_modules/component-emitter/index.js");
|
||||
|
||||
var _require = __webpack_require__(/*! ../util */ "./node_modules/engine.io-client/lib/util.js"),
|
||||
pick = _require.pick;
|
||||
pick = _require.pick,
|
||||
installTimerFunctions = _require.installTimerFunctions;
|
||||
|
||||
var globalThis = __webpack_require__(/*! ../globalThis */ "./node_modules/engine.io-client/lib/globalThis.browser.js");
|
||||
|
||||
@@ -3866,6 +3884,7 @@ var Request = /*#__PURE__*/function (_Emitter) {
|
||||
_classCallCheck(this, Request);
|
||||
|
||||
_this4 = _super2.call(this);
|
||||
installTimerFunctions(_assertThisInitialized(_this4), opts);
|
||||
_this4.opts = opts;
|
||||
_this4.method = opts.method || "GET";
|
||||
_this4.uri = uri;
|
||||
@@ -3945,7 +3964,7 @@ var Request = /*#__PURE__*/function (_Emitter) {
|
||||
} else {
|
||||
// make sure the `error` event handler that's user-set
|
||||
// does not throw in the same tick and gets caught here
|
||||
setTimeout(function () {
|
||||
_this5.setTimeoutFn(function () {
|
||||
_this5.onError(typeof xhr.status === "number" ? xhr.status : 0);
|
||||
}, 0);
|
||||
}
|
||||
@@ -3958,7 +3977,7 @@ var Request = /*#__PURE__*/function (_Emitter) {
|
||||
// Need to defer since .create() is called directly from the constructor
|
||||
// and thus the 'error' event can only be only bound *after* this exception
|
||||
// occurs. Therefore, also, we cannot throw here at all.
|
||||
setTimeout(function () {
|
||||
this.setTimeoutFn(function () {
|
||||
_this5.onError(e);
|
||||
}, 0);
|
||||
return;
|
||||
@@ -4131,11 +4150,11 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
@@ -4161,14 +4180,23 @@ var Polling = /*#__PURE__*/function (_Transport) {
|
||||
}
|
||||
|
||||
_createClass(Polling, [{
|
||||
key: "doOpen",
|
||||
|
||||
key: "name",
|
||||
get:
|
||||
/**
|
||||
* Transport name.
|
||||
*/
|
||||
function get() {
|
||||
return "polling";
|
||||
}
|
||||
/**
|
||||
* Opens the socket (triggers polling). We write a PING message to determine
|
||||
* when the transport is open.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: "doOpen",
|
||||
value: function doOpen() {
|
||||
this.poll();
|
||||
}
|
||||
@@ -4361,15 +4389,6 @@ var Polling = /*#__PURE__*/function (_Transport) {
|
||||
var ipv6 = this.opts.hostname.indexOf(":") !== -1;
|
||||
return schema + "://" + (ipv6 ? "[" + this.opts.hostname + "]" : this.opts.hostname) + port + this.opts.path + query;
|
||||
}
|
||||
}, {
|
||||
key: "name",
|
||||
|
||||
/**
|
||||
* Transport name.
|
||||
*/
|
||||
get: function get() {
|
||||
return "polling";
|
||||
}
|
||||
}]);
|
||||
|
||||
return Polling;
|
||||
@@ -4388,10 +4407,25 @@ module.exports = Polling;
|
||||
|
||||
var globalThis = __webpack_require__(/*! ../globalThis */ "./node_modules/engine.io-client/lib/globalThis.browser.js");
|
||||
|
||||
var nextTick = function () {
|
||||
var isPromiseAvailable = typeof Promise === "function" && typeof Promise.resolve === "function";
|
||||
|
||||
if (isPromiseAvailable) {
|
||||
return function (cb) {
|
||||
return Promise.resolve().then(cb);
|
||||
};
|
||||
} else {
|
||||
return function (cb, setTimeoutFn) {
|
||||
return setTimeoutFn(cb, 0);
|
||||
};
|
||||
}
|
||||
}();
|
||||
|
||||
module.exports = {
|
||||
WebSocket: globalThis.WebSocket || globalThis.MozWebSocket,
|
||||
usingBrowserWebSocket: true,
|
||||
defaultBinaryType: "arraybuffer"
|
||||
defaultBinaryType: "arraybuffer",
|
||||
nextTick: nextTick
|
||||
};
|
||||
|
||||
/***/ }),
|
||||
@@ -4417,11 +4451,11 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
@@ -4439,7 +4473,8 @@ var _require = __webpack_require__(/*! ../util */ "./node_modules/engine.io-clie
|
||||
var _require2 = __webpack_require__(/*! ./websocket-constructor */ "./node_modules/engine.io-client/lib/transports/websocket-constructor.browser.js"),
|
||||
WebSocket = _require2.WebSocket,
|
||||
usingBrowserWebSocket = _require2.usingBrowserWebSocket,
|
||||
defaultBinaryType = _require2.defaultBinaryType;
|
||||
defaultBinaryType = _require2.defaultBinaryType,
|
||||
nextTick = _require2.nextTick;
|
||||
|
||||
var debug = __webpack_require__(/*! debug */ "./node_modules/debug/src/browser.js")("engine.io-client:websocket"); // detect ReactNative environment
|
||||
|
||||
@@ -4474,13 +4509,18 @@ var WS = /*#__PURE__*/function (_Transport) {
|
||||
|
||||
|
||||
_createClass(WS, [{
|
||||
key: "doOpen",
|
||||
|
||||
key: "name",
|
||||
get: function get() {
|
||||
return "websocket";
|
||||
}
|
||||
/**
|
||||
* Opens socket.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: "doOpen",
|
||||
value: function doOpen() {
|
||||
if (!this.check()) {
|
||||
// let probe timeout
|
||||
@@ -4587,11 +4627,11 @@ var WS = /*#__PURE__*/function (_Transport) {
|
||||
if (lastPacket) {
|
||||
// fake drain
|
||||
// defer to next tick to allow Socket to clear writeBuffer
|
||||
setTimeout(function () {
|
||||
nextTick(function () {
|
||||
_this3.writable = true;
|
||||
|
||||
_this3.emit("drain");
|
||||
}, 0);
|
||||
}, _this3.setTimeoutFn);
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -4673,11 +4713,6 @@ var WS = /*#__PURE__*/function (_Transport) {
|
||||
value: function check() {
|
||||
return !!WebSocket && !("__initialize" in WebSocket && this.name === WS.prototype.name);
|
||||
}
|
||||
}, {
|
||||
key: "name",
|
||||
get: function get() {
|
||||
return "websocket";
|
||||
}
|
||||
}]);
|
||||
|
||||
return WS;
|
||||
@@ -4692,7 +4727,9 @@ module.exports = WS;
|
||||
!*** ./node_modules/engine.io-client/lib/util.js ***!
|
||||
\***************************************************/
|
||||
/*! no static exports found */
|
||||
/***/ (function(module, exports) {
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
var globalThis = __webpack_require__(/*! ./globalThis */ "./node_modules/engine.io-client/lib/globalThis.browser.js");
|
||||
|
||||
module.exports.pick = function (obj) {
|
||||
for (var _len = arguments.length, attr = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
@@ -4706,6 +4743,20 @@ module.exports.pick = function (obj) {
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
}; // Keep a reference to the real timeout functions so they can be used when overridden
|
||||
|
||||
|
||||
var NATIVE_SET_TIMEOUT = setTimeout;
|
||||
var NATIVE_CLEAR_TIMEOUT = clearTimeout;
|
||||
|
||||
module.exports.installTimerFunctions = function (obj, opts) {
|
||||
if (opts.useNativeTimers) {
|
||||
obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThis);
|
||||
obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThis);
|
||||
} else {
|
||||
obj.setTimeoutFn = setTimeout.bind(globalThis);
|
||||
obj.clearTimeoutFn = clearTimeout.bind(globalThis);
|
||||
}
|
||||
};
|
||||
|
||||
/***/ }),
|
||||
@@ -5523,11 +5574,11 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
@@ -5580,14 +5631,14 @@ var Encoder = /*#__PURE__*/function () {
|
||||
|
||||
_createClass(Encoder, [{
|
||||
key: "encode",
|
||||
|
||||
value:
|
||||
/**
|
||||
* Encode a packet as a single string if non-binary, or as a
|
||||
* buffer sequence, depending on packet type.
|
||||
*
|
||||
* @param {Object} obj - packet object
|
||||
*/
|
||||
value: function encode(obj) {
|
||||
function encode(obj) {
|
||||
debug("encoding packet %j", obj);
|
||||
|
||||
if (obj.type === PacketType.EVENT || obj.type === PacketType.ACK) {
|
||||
@@ -5800,11 +5851,11 @@ var Decoder = /*#__PURE__*/function (_Emitter) {
|
||||
}
|
||||
}, {
|
||||
key: "destroy",
|
||||
|
||||
value:
|
||||
/**
|
||||
* Deallocates a parser's resources
|
||||
*/
|
||||
value: function destroy() {
|
||||
function destroy() {
|
||||
if (this.reconstructor) {
|
||||
this.reconstructor.finishedReconstruction();
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
4
client-dist/socket.io.min.js
vendored
4
client-dist/socket.io.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
4
client-dist/socket.io.msgpack.min.js
vendored
4
client-dist/socket.io.msgpack.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -24,6 +24,7 @@
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mocha": "^8.2.3",
|
||||
"@types/chai": "^4.2.16",
|
||||
"@types/uuid": "^8.3.0",
|
||||
"chai": "^4.3.4",
|
||||
|
||||
20
examples/webpack-build-server/index.js
Normal file
20
examples/webpack-build-server/index.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const { Server } = require("socket.io");
|
||||
|
||||
const clientFile = require("./node_modules/socket.io/client-dist/socket.io.min?raw");
|
||||
const clientMap = require("./node_modules/socket.io/client-dist/socket.io.min.js.map?raw");
|
||||
|
||||
Server.sendFile = (filename, req, res) => {
|
||||
res.end(filename.endsWith(".map") ? clientMap : clientFile);
|
||||
};
|
||||
|
||||
const io = new Server();
|
||||
|
||||
io.on("connection", socket => {
|
||||
console.log(`connect ${socket.id}`);
|
||||
|
||||
socket.on("disconnect", (reason) => {
|
||||
console.log(`disconnect ${socket.id} due to ${reason}`);
|
||||
});
|
||||
});
|
||||
|
||||
io.listen(3000);
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
const server = require('http').createServer();
|
||||
const io = require('socket.io')(server, {
|
||||
serveClient: false
|
||||
});
|
||||
const port = process.env.PORT || 3000;
|
||||
|
||||
io.on('connect', onConnect);
|
||||
server.listen(port, () => console.log('server listening on port ' + port));
|
||||
|
||||
function onConnect(socket){
|
||||
console.log('connect ' + socket.id);
|
||||
|
||||
socket.on('disconnect', () => console.log('disconnect ' + socket.id));
|
||||
}
|
||||
@@ -4,13 +4,15 @@
|
||||
"description": "A sample Webpack build (for the server)",
|
||||
"scripts": {
|
||||
"start": "node dist/server.js",
|
||||
"build": "webpack --config ./support/webpack.config.js"
|
||||
"build": "webpack"
|
||||
},
|
||||
"author": "Damien Arrachequesne",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"bufferutil": "^4.0.3",
|
||||
"socket.io": "^4.0.0",
|
||||
"webpack": "~4.43.0",
|
||||
"webpack-cli": "~3.3.11"
|
||||
"utf-8-validate": "^5.0.5",
|
||||
"webpack": "^5.39.0",
|
||||
"webpack-cli": "^4.7.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
|
||||
module.exports = {
|
||||
entry: './lib/index.js',
|
||||
target: 'node',
|
||||
output: {
|
||||
path: require('path').join(__dirname, '../dist'),
|
||||
filename: 'server.js'
|
||||
},
|
||||
mode: 'production'
|
||||
};
|
||||
19
examples/webpack-build-server/webpack.config.js
Normal file
19
examples/webpack-build-server/webpack.config.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const path = require("path");
|
||||
|
||||
module.exports = {
|
||||
entry: "./index.js",
|
||||
target: "node",
|
||||
mode: "production",
|
||||
output: {
|
||||
path: path.resolve(__dirname, "dist"),
|
||||
filename: "index.js",
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
resourceQuery: /raw/,
|
||||
type: "asset/source",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -10,7 +10,8 @@ import type {
|
||||
} from "./typed-events";
|
||||
|
||||
export class BroadcastOperator<EmitEvents extends EventsMap>
|
||||
implements TypedEventBroadcaster<EmitEvents> {
|
||||
implements TypedEventBroadcaster<EmitEvents>
|
||||
{
|
||||
constructor(
|
||||
private readonly adapter: Adapter,
|
||||
private readonly rooms: Set<Room> = new Set<Room>(),
|
||||
@@ -186,7 +187,7 @@ export class BroadcastOperator<EmitEvents extends EventsMap>
|
||||
return sockets.map((socket) => {
|
||||
if (socket instanceof Socket) {
|
||||
// FIXME the TypeScript compiler complains about missing private properties
|
||||
return (socket as unknown) as RemoteSocket<EmitEvents>;
|
||||
return socket as unknown as RemoteSocket<EmitEvents>;
|
||||
} else {
|
||||
return new RemoteSocket(this.adapter, socket as SocketDetails);
|
||||
}
|
||||
@@ -257,7 +258,8 @@ interface SocketDetails {
|
||||
* Expose of subset of the attributes and methods of the Socket class
|
||||
*/
|
||||
export class RemoteSocket<EmitEvents extends EventsMap>
|
||||
implements TypedEventBroadcaster<EmitEvents> {
|
||||
implements TypedEventBroadcaster<EmitEvents>
|
||||
{
|
||||
public readonly id: SocketId;
|
||||
public readonly handshake: Handshake;
|
||||
public readonly rooms: Set<Room>;
|
||||
|
||||
22
lib/index.ts
22
lib/index.ts
@@ -201,10 +201,8 @@ export class Server<
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_nsps: Map<
|
||||
string,
|
||||
Namespace<ListenEvents, EmitEvents, ServerSideEvents>
|
||||
> = new Map();
|
||||
_nsps: Map<string, Namespace<ListenEvents, EmitEvents, ServerSideEvents>> =
|
||||
new Map();
|
||||
private parentNsps: Map<
|
||||
ParentNspNameMatchFn,
|
||||
ParentNamespace<ListenEvents, EmitEvents, ServerSideEvents>
|
||||
@@ -336,7 +334,7 @@ export class Server<
|
||||
this.clientPathRegex = new RegExp(
|
||||
"^" +
|
||||
escapedPath +
|
||||
"/socket\\.io(\\.min|\\.msgpack\\.min)?\\.js(\\.map)?$"
|
||||
"/socket\\.io(\\.min|\\.msgpack\\.min)?\\.js(\\.map)?(?:\\?|$)"
|
||||
);
|
||||
return this;
|
||||
}
|
||||
@@ -471,7 +469,7 @@ export class Server<
|
||||
const evs = srv.listeners("request").slice(0);
|
||||
srv.removeAllListeners("request");
|
||||
srv.on("request", (req, res) => {
|
||||
if (this.clientPathRegex.test(req.url)) {
|
||||
if (this.clientPathRegex.test(req.url!)) {
|
||||
this.serve(req, res);
|
||||
} else {
|
||||
for (let i = 0; i < evs.length; i++) {
|
||||
@@ -489,7 +487,7 @@ export class Server<
|
||||
* @private
|
||||
*/
|
||||
private serve(req: http.IncomingMessage, res: http.ServerResponse): void {
|
||||
const filename = req.url!.replace(this._path, "");
|
||||
const filename = req.url!.replace(this._path, "").replace(/\?.*$/, "");
|
||||
const isMap = dotMapRegex.test(filename);
|
||||
const type = isMap ? "map" : "source";
|
||||
|
||||
@@ -517,9 +515,6 @@ export class Server<
|
||||
);
|
||||
res.setHeader("ETag", expectedEtag);
|
||||
|
||||
if (!isMap) {
|
||||
res.setHeader("X-SourceMap", filename.substring(1) + ".map");
|
||||
}
|
||||
Server.sendFile(filename, req, res);
|
||||
}
|
||||
|
||||
@@ -705,11 +700,8 @@ export class Server<
|
||||
* @return self
|
||||
* @public
|
||||
*/
|
||||
public except(
|
||||
name: Room | Room[]
|
||||
): Server<ListenEvents, EmitEvents, ServerSideEvents> {
|
||||
this.sockets.except(name);
|
||||
return this;
|
||||
public except(name: Room | Room[]): BroadcastOperator<EmitEvents> {
|
||||
return this.sockets.except(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,9 +14,8 @@ export class ParentNamespace<
|
||||
ServerSideEvents extends EventsMap = DefaultEventsMap
|
||||
> extends Namespace<ListenEvents, EmitEvents, ServerSideEvents> {
|
||||
private static count: number = 0;
|
||||
private children: Set<
|
||||
Namespace<ListenEvents, EmitEvents, ServerSideEvents>
|
||||
> = new Set();
|
||||
private children: Set<Namespace<ListenEvents, EmitEvents, ServerSideEvents>> =
|
||||
new Set();
|
||||
|
||||
constructor(server: Server<ListenEvents, EmitEvents, ServerSideEvents>) {
|
||||
super(server, "/_" + ParentNamespace.count++);
|
||||
|
||||
@@ -130,9 +130,8 @@ export class Socket<
|
||||
private readonly server: Server<ListenEvents, EmitEvents, ServerSideEvents>;
|
||||
private readonly adapter: Adapter;
|
||||
private acks: Map<number, () => void> = new Map();
|
||||
private fns: Array<
|
||||
(event: Array<any>, next: (err?: Error) => void) => void
|
||||
> = [];
|
||||
private fns: Array<(event: Array<any>, next: (err?: Error) => void) => void> =
|
||||
[];
|
||||
private flags: BroadcastFlags = {};
|
||||
private _anyListeners?: Array<(...args: any[]) => void>;
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ export type ReservedOrUserListener<
|
||||
* Needed because of https://github.com/microsoft/TypeScript/issues/41778
|
||||
*/
|
||||
type FallbackToUntypedListener<T> = [T] extends [never]
|
||||
? (...args: any[]) => void
|
||||
? (...args: any[]) => void | Promise<void>
|
||||
: T;
|
||||
|
||||
/**
|
||||
@@ -91,7 +91,8 @@ export abstract class StrictEventEmitter<
|
||||
ReservedEvents extends EventsMap = {}
|
||||
>
|
||||
extends EventEmitter
|
||||
implements TypedEventBroadcaster<EmitEvents> {
|
||||
implements TypedEventBroadcaster<EmitEvents>
|
||||
{
|
||||
/**
|
||||
* Adds the `listener` function as an event listener for `ev`.
|
||||
*
|
||||
|
||||
1814
package-lock.json
generated
1814
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
31
package.json
31
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "socket.io",
|
||||
"version": "4.1.2",
|
||||
"version": "4.2.0",
|
||||
"description": "node.js realtime framework server",
|
||||
"keywords": [
|
||||
"realtime",
|
||||
@@ -45,33 +45,30 @@
|
||||
"prepack": "npm run compile"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/cookie": "^0.4.0",
|
||||
"@types/cors": "^2.8.8",
|
||||
"@types/cookie": "^0.4.1",
|
||||
"@types/cors": "^2.8.12",
|
||||
"@types/node": ">=10.0.0",
|
||||
"accepts": "~1.3.4",
|
||||
"base64id": "~2.0.0",
|
||||
"debug": "~4.3.1",
|
||||
"engine.io": "~5.1.0",
|
||||
"socket.io-adapter": "~2.3.0",
|
||||
"socket.io-parser": "~4.0.3"
|
||||
"debug": "~4.3.2",
|
||||
"engine.io": "~5.2.0",
|
||||
"socket.io-adapter": "~2.3.2",
|
||||
"socket.io-parser": "~4.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mocha": "^8.0.4",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"eslint": "^7.14.0",
|
||||
"eslint-config-prettier": "^6.11.0",
|
||||
"@types/mocha": "^9.0.0",
|
||||
"expect.js": "0.3.1",
|
||||
"mocha": "^3.5.3",
|
||||
"nyc": "^15.1.0",
|
||||
"prettier": "^2.2.0",
|
||||
"prettier": "^2.3.2",
|
||||
"rimraf": "^3.0.2",
|
||||
"socket.io-client": "4.1.2",
|
||||
"socket.io-client": "4.2.0",
|
||||
"socket.io-client-v2": "npm:socket.io-client@^2.4.0",
|
||||
"superagent": "^6.1.0",
|
||||
"supertest": "^6.0.1",
|
||||
"ts-node": "^9.0.0",
|
||||
"tsd": "^0.14.0",
|
||||
"typescript": "^4.1.2"
|
||||
"supertest": "^6.1.6",
|
||||
"ts-node": "^10.2.1",
|
||||
"tsd": "^0.17.0",
|
||||
"typescript": "^4.4.2"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
|
||||
@@ -59,7 +59,7 @@ describe("socket.io", () => {
|
||||
if (err) return done(err);
|
||||
expect(res.headers["content-type"]).to.be("application/javascript");
|
||||
expect(res.headers.etag).to.be('"' + clientVersion + '"');
|
||||
expect(res.headers["x-sourcemap"]).to.be(filename + ".map");
|
||||
expect(res.headers["x-sourcemap"]).to.be(undefined);
|
||||
expect(res.text).to.match(/engine\.io/);
|
||||
expect(res.status).to.be(200);
|
||||
done();
|
||||
@@ -83,6 +83,10 @@ describe("socket.io", () => {
|
||||
};
|
||||
|
||||
it("should serve client", testSource("socket.io.js"));
|
||||
it(
|
||||
"should serve client with query string",
|
||||
testSource("socket.io.js?buster=" + Date.now())
|
||||
);
|
||||
it("should serve source map", testSourceMap("socket.io.js.map"));
|
||||
it("should serve client (min)", testSource("socket.io.min.js"));
|
||||
|
||||
@@ -836,6 +840,27 @@ describe("socket.io", () => {
|
||||
});
|
||||
|
||||
it("should exclude a specific socket when emitting", (done) => {
|
||||
const srv = createServer();
|
||||
const io = new Server(srv);
|
||||
|
||||
srv.listen(() => {
|
||||
const socket1 = client(srv, "/");
|
||||
const socket2 = client(srv, "/");
|
||||
|
||||
socket2.on("a", () => {
|
||||
done(new Error("should not happen"));
|
||||
});
|
||||
socket1.on("a", () => {
|
||||
done();
|
||||
});
|
||||
|
||||
socket2.on("connect", () => {
|
||||
io.except(socket2.id).emit("a");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("should exclude a specific socket when emitting (in a namespace)", (done) => {
|
||||
const srv = createServer();
|
||||
const sio = new Server(srv);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user