1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-03 12:20:04 +02:00

update node modules

This commit is contained in:
s2
2021-05-07 15:56:33 +02:00
parent d81e8e9fb8
commit 3ec373077c
550 changed files with 84712 additions and 15991 deletions

166
node_modules/ws/lib/websocket.js generated vendored
View File

@@ -37,22 +37,21 @@ class WebSocket extends EventEmitter {
* Create a new `WebSocket`.
*
* @param {(String|url.URL)} address The URL to which to connect
* @param {(String|String[])} protocols The subprotocols
* @param {Object} options Connection options
* @param {(String|String[])} [protocols] The subprotocols
* @param {Object} [options] Connection options
*/
constructor(address, protocols, options) {
super();
this.readyState = WebSocket.CONNECTING;
this.protocol = '';
this._binaryType = BINARY_TYPES[0];
this._closeCode = 1006;
this._closeFrameReceived = false;
this._closeFrameSent = false;
this._closeMessage = '';
this._closeTimer = null;
this._closeCode = 1006;
this._extensions = {};
this._protocol = '';
this._readyState = WebSocket.CONNECTING;
this._receiver = null;
this._sender = null;
this._socket = null;
@@ -75,19 +74,6 @@ class WebSocket extends EventEmitter {
}
}
get CONNECTING() {
return WebSocket.CONNECTING;
}
get CLOSING() {
return WebSocket.CLOSING;
}
get CLOSED() {
return WebSocket.CLOSED;
}
get OPEN() {
return WebSocket.OPEN;
}
/**
* This deviates from the WHATWG interface since ws doesn't support the
* required default "blob" type (instead we define a custom "nodebuffer"
@@ -126,17 +112,38 @@ class WebSocket extends EventEmitter {
return Object.keys(this._extensions).join();
}
/**
* @type {String}
*/
get protocol() {
return this._protocol;
}
/**
* @type {Number}
*/
get readyState() {
return this._readyState;
}
/**
* @type {String}
*/
get url() {
return this._url;
}
/**
* Set up the socket and the internal resources.
*
* @param {net.Socket} socket The network socket between the server and client
* @param {Buffer} head The first packet of the upgraded stream
* @param {Number} maxPayload The maximum allowed message size
* @param {Number} [maxPayload=0] The maximum allowed message size
* @private
*/
setSocket(socket, head, maxPayload) {
const receiver = new Receiver(
this._binaryType,
this.binaryType,
this._extensions,
this._isServer,
maxPayload
@@ -166,7 +173,7 @@ class WebSocket extends EventEmitter {
socket.on('end', socketOnEnd);
socket.on('error', socketOnError);
this.readyState = WebSocket.OPEN;
this._readyState = WebSocket.OPEN;
this.emit('open');
}
@@ -177,7 +184,7 @@ class WebSocket extends EventEmitter {
*/
emitClose() {
if (!this._socket) {
this.readyState = WebSocket.CLOSED;
this._readyState = WebSocket.CLOSED;
this.emit('close', this._closeCode, this._closeMessage);
return;
}
@@ -187,7 +194,7 @@ class WebSocket extends EventEmitter {
}
this._receiver.removeAllListeners();
this.readyState = WebSocket.CLOSED;
this._readyState = WebSocket.CLOSED;
this.emit('close', this._closeCode, this._closeMessage);
}
@@ -206,8 +213,8 @@ class WebSocket extends EventEmitter {
* - - - - -|fin|<---------------------+
* +---+
*
* @param {Number} code Status code explaining why the connection is closing
* @param {String} data A string explaining why the connection is closing
* @param {Number} [code] Status code explaining why the connection is closing
* @param {String} [data] A string explaining why the connection is closing
* @public
*/
close(code, data) {
@@ -222,7 +229,7 @@ class WebSocket extends EventEmitter {
return;
}
this.readyState = WebSocket.CLOSING;
this._readyState = WebSocket.CLOSING;
this._sender.close(code, data, !this._isServer, (err) => {
//
// This error is handled by the `'error'` listener on the socket. We only
@@ -246,9 +253,9 @@ class WebSocket extends EventEmitter {
/**
* Send a ping.
*
* @param {*} data The data to send
* @param {Boolean} mask Indicates whether or not to mask `data`
* @param {Function} cb Callback which is executed when the ping is sent
* @param {*} [data] The data to send
* @param {Boolean} [mask] Indicates whether or not to mask `data`
* @param {Function} [cb] Callback which is executed when the ping is sent
* @public
*/
ping(data, mask, cb) {
@@ -278,9 +285,9 @@ class WebSocket extends EventEmitter {
/**
* Send a pong.
*
* @param {*} data The data to send
* @param {Boolean} mask Indicates whether or not to mask `data`
* @param {Function} cb Callback which is executed when the pong is sent
* @param {*} [data] The data to send
* @param {Boolean} [mask] Indicates whether or not to mask `data`
* @param {Function} [cb] Callback which is executed when the pong is sent
* @public
*/
pong(data, mask, cb) {
@@ -311,13 +318,15 @@ class WebSocket extends EventEmitter {
* Send a data message.
*
* @param {*} data The message to send
* @param {Object} options Options object
* @param {Boolean} options.compress Specifies whether or not to compress
* @param {Object} [options] Options object
* @param {Boolean} [options.compress] Specifies whether or not to compress
* `data`
* @param {Boolean} options.binary Specifies whether `data` is binary or text
* @param {Boolean} options.fin Specifies whether the fragment is the last one
* @param {Boolean} options.mask Specifies whether or not to mask `data`
* @param {Function} cb Callback which is executed when data is written out
* @param {Boolean} [options.binary] Specifies whether `data` is binary or
* text
* @param {Boolean} [options.fin=true] Specifies whether the fragment is the
* last one
* @param {Boolean} [options.mask] Specifies whether or not to mask `data`
* @param {Function} [cb] Callback which is executed when data is written out
* @public
*/
send(data, options, cb) {
@@ -365,14 +374,28 @@ class WebSocket extends EventEmitter {
}
if (this._socket) {
this.readyState = WebSocket.CLOSING;
this._readyState = WebSocket.CLOSING;
this._socket.destroy();
}
}
}
readyStates.forEach((readyState, i) => {
WebSocket[readyState] = i;
const descriptor = { enumerable: true, value: i };
Object.defineProperty(WebSocket.prototype, readyState, descriptor);
Object.defineProperty(WebSocket, readyState, descriptor);
});
[
'binaryType',
'bufferedAmount',
'extensions',
'protocol',
'readyState',
'url'
].forEach((property) => {
Object.defineProperty(WebSocket.prototype, property, { enumerable: true });
});
//
@@ -381,6 +404,8 @@ readyStates.forEach((readyState, i) => {
//
['open', 'error', 'close', 'message'].forEach((method) => {
Object.defineProperty(WebSocket.prototype, `on${method}`, {
configurable: true,
enumerable: true,
/**
* Return the listener of the event.
*
@@ -424,19 +449,22 @@ module.exports = WebSocket;
*
* @param {WebSocket} websocket The client to initialize
* @param {(String|url.URL)} address The URL to which to connect
* @param {String} protocols The subprotocols
* @param {Object} options Connection options
* @param {(Boolean|Object)} options.perMessageDeflate Enable/disable
* @param {String} [protocols] The subprotocols
* @param {Object} [options] Connection options
* @param {(Boolean|Object)} [options.perMessageDeflate=true] Enable/disable
* permessage-deflate
* @param {Number} options.handshakeTimeout Timeout in milliseconds for the
* @param {Number} [options.handshakeTimeout] Timeout in milliseconds for the
* handshake request
* @param {Number} options.protocolVersion Value of the `Sec-WebSocket-Version`
* header
* @param {String} options.origin Value of the `Origin` or
* @param {Number} [options.protocolVersion=13] Value of the
* `Sec-WebSocket-Version` header
* @param {String} [options.origin] Value of the `Origin` or
* `Sec-WebSocket-Origin` header
* @param {Number} options.maxPayload The maximum allowed message size
* @param {Boolean} options.followRedirects Whether or not to follow redirects
* @param {Number} options.maxRedirects The maximum number of redirects allowed
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
* size
* @param {Boolean} [options.followRedirects=false] Whether or not to follow
* redirects
* @param {Number} [options.maxRedirects=10] The maximum number of redirects
* allowed
* @private
*/
function initAsClient(websocket, address, protocols, options) {
@@ -469,10 +497,10 @@ function initAsClient(websocket, address, protocols, options) {
if (address instanceof URL) {
parsedUrl = address;
websocket.url = address.href;
websocket._url = address.href;
} else {
parsedUrl = new URL(address);
websocket.url = address;
websocket._url = address;
}
const isUnixSocket = parsedUrl.protocol === 'ws+unix:';
@@ -544,10 +572,10 @@ function initAsClient(websocket, address, protocols, options) {
}
req.on('error', (err) => {
if (websocket._req.aborted) return;
if (req === null || req.aborted) return;
req = websocket._req = null;
websocket.readyState = WebSocket.CLOSING;
websocket._readyState = WebSocket.CLOSING;
websocket.emit('error', err);
websocket.emitClose();
});
@@ -618,7 +646,7 @@ function initAsClient(websocket, address, protocols, options) {
return;
}
if (serverProt) websocket.protocol = serverProt;
if (serverProt) websocket._protocol = serverProt;
if (perMessageDeflate) {
try {
@@ -667,7 +695,7 @@ function tlsConnect(options) {
options.path = undefined;
if (!options.servername && options.servername !== '') {
options.servername = options.host;
options.servername = net.isIP(options.host) ? '' : options.host;
}
return tls.connect(options);
@@ -683,13 +711,23 @@ function tlsConnect(options) {
* @private
*/
function abortHandshake(websocket, stream, message) {
websocket.readyState = WebSocket.CLOSING;
websocket._readyState = WebSocket.CLOSING;
const err = new Error(message);
Error.captureStackTrace(err, abortHandshake);
if (stream.setHeader) {
stream.abort();
if (stream.socket && !stream.socket.destroyed) {
//
// On Node.js >= 14.3.0 `request.abort()` does not destroy the socket if
// called after the request completed. See
// https://github.com/websockets/ws/issues/1869.
//
stream.socket.destroy();
}
stream.once('abort', websocket.emitClose.bind(websocket));
websocket.emit('error', err);
} else {
@@ -704,8 +742,8 @@ function abortHandshake(websocket, stream, message) {
* when the `readyState` attribute is `CLOSING` or `CLOSED`.
*
* @param {WebSocket} websocket The WebSocket instance
* @param {*} data The data to send
* @param {Function} cb Callback
* @param {*} [data] The data to send
* @param {Function} [cb] Callback
* @private
*/
function sendAfterClose(websocket, data, cb) {
@@ -772,7 +810,7 @@ function receiverOnError(err) {
websocket._socket.removeListener('data', socketOnData);
websocket.readyState = WebSocket.CLOSING;
websocket._readyState = WebSocket.CLOSING;
websocket._closeCode = err[kStatusCode];
websocket.emit('error', err);
websocket._socket.destroy();
@@ -831,7 +869,7 @@ function socketOnClose() {
this.removeListener('close', socketOnClose);
this.removeListener('end', socketOnEnd);
websocket.readyState = WebSocket.CLOSING;
websocket._readyState = WebSocket.CLOSING;
//
// The close frame might not have been received or the `'end'` event emitted,
@@ -882,7 +920,7 @@ function socketOnData(chunk) {
function socketOnEnd() {
const websocket = this[kWebSocket];
websocket.readyState = WebSocket.CLOSING;
websocket._readyState = WebSocket.CLOSING;
websocket._receiver.end();
this.end();
}
@@ -899,7 +937,7 @@ function socketOnError() {
this.on('error', NOOP);
if (websocket) {
websocket.readyState = WebSocket.CLOSING;
websocket._readyState = WebSocket.CLOSING;
this.destroy();
}
}