@rindo/core 3.2.3-dev.1685596167.938c836 → 3.2.4
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/cli/index.cjs +11 -16
- package/cli/index.js +11 -16
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/rindo.js +2765 -2560
- package/compiler/rindo.min.js +2 -2
- package/dev-server/client/index.js +1 -1
- package/dev-server/client/package.json +1 -1
- package/dev-server/connector.html +2 -2
- package/dev-server/index.js +1 -1
- package/dev-server/package.json +1 -1
- package/dev-server/server-process.js +2 -2
- package/dev-server/ws.js +1 -1
- package/internal/app-data/package.json +1 -1
- package/internal/client/css-shim.js +1 -1
- package/internal/client/dom.js +1 -1
- package/internal/client/index.js +89 -38
- package/internal/client/package.json +1 -1
- package/internal/client/patch-browser.js +1 -1
- package/internal/client/patch-esm.js +1 -1
- package/internal/client/shadow-css.js +1 -1
- package/internal/hydrate/index.js +34 -28
- package/internal/hydrate/package.json +1 -1
- package/internal/hydrate/shadow-css.js +1 -2
- package/internal/package.json +1 -1
- package/internal/rindo-private.d.ts +14 -3
- package/internal/rindo-public-compiler.d.ts +11 -0
- package/internal/rindo-public-runtime.d.ts +1 -0
- package/internal/testing/index.js +19 -13
- package/internal/testing/package.json +1 -1
- package/internal/testing/shadow-css.js +1 -2
- package/mock-doc/index.cjs +2 -2
- package/mock-doc/index.js +2 -2
- package/mock-doc/package.json +1 -1
- package/package.json +7 -7
- package/screenshot/package.json +1 -1
- package/sys/node/autoprefixer.js +2 -2
- package/sys/node/glob.js +1 -1
- package/sys/node/graceful-fs.js +1 -1
- package/sys/node/index.js +290 -283
- package/sys/node/node-fetch.js +1 -4
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.js +46 -24
- package/testing/jest/jest-setup-test-framework.d.ts +8 -0
- package/testing/package.json +1 -1
- package/testing/reset-build-conditionals.d.ts +10 -0
- package/testing/spec-page.d.ts +5 -0
- package/cli/index.cjs.map +0 -1
- package/cli/index.js.map +0 -1
- package/compiler/rindo.js.map +0 -1
- package/sys/node/713.node-fetch.js +0 -452
package/dev-server/ws.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var e={777:(e,t,s)=>{"use strict";const r=s(762);r.createWebSocketStream=s(30),r.Server=s(284),r.Receiver=s(957),r.Sender=s(330),r.WebSocket=r,r.WebSocketServer=r.Server,e.exports=r},977:(e,t,s)=>{"use strict";const{EMPTY_BUFFER:r}=s(872),i=Buffer[Symbol.species];function o(e,t,s,r,i){for(let o=0;o<i;o++)s[r+o]=e[o]^t[3&o]}function n(e,t){for(let s=0;s<e.length;s++)e[s]^=t[3&s]}if(e.exports={concat:function(e,t){if(0===e.length)return r;if(1===e.length)return e[0];const s=Buffer.allocUnsafe(t);let o=0;for(let t=0;t<e.length;t++){const r=e[t];s.set(r,o),o+=r.length}return o<t?new i(s.buffer,s.byteOffset,o):s},mask:o,toArrayBuffer:function(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)},toBuffer:function e(t){if(e.readOnly=!0,Buffer.isBuffer(t))return t;let s;return t instanceof ArrayBuffer?s=new i(t):ArrayBuffer.isView(t)?s=new i(t.buffer,t.byteOffset,t.byteLength):(s=Buffer.from(t),e.readOnly=!1),s},unmask:n},!process.env.WS_NO_BUFFER_UTIL)try{const t=s(Object(function(){var e=new Error("Cannot find module 'bufferutil'");throw e.code="MODULE_NOT_FOUND",e}()));e.exports.mask=function(e,s,r,i,n){n<48?o(e,s,r,i,n):t.mask(e,s,r,i,n)},e.exports.unmask=function(e,s){e.length<32?n(e,s):t.unmask(e,s)}}catch(e){}},872:e=>{"use strict";e.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}},62:(e,t,s)=>{"use strict";const{kForOnEventAttribute:r,kListener:i}=s(872),o=Symbol("kCode"),n=Symbol("kData"),a=Symbol("kError"),h=Symbol("kMessage"),c=Symbol("kReason"),l=Symbol("kTarget"),d=Symbol("kType"),f=Symbol("kWasClean");class _{constructor(e){this[l]=null,this[d]=e}get target(){return this[l]}get type(){return this[d]}}Object.defineProperty(_.prototype,"target",{enumerable:!0}),Object.defineProperty(_.prototype,"type",{enumerable:!0});class u extends _{constructor(e,t={}){super(e),this[o]=void 0===t.code?0:t.code,this[c]=void 0===t.reason?"":t.reason,this[f]=void 0!==t.wasClean&&t.wasClean}get code(){return this[o]}get reason(){return this[c]}get wasClean(){return this[f]}}Object.defineProperty(u.prototype,"code",{enumerable:!0}),Object.defineProperty(u.prototype,"reason",{enumerable:!0}),Object.defineProperty(u.prototype,"wasClean",{enumerable:!0});class p extends _{constructor(e,t={}){super(e),this[a]=void 0===t.error?null:t.error,this[h]=void 0===t.message?"":t.message}get error(){return this[a]}get message(){return this[h]}}Object.defineProperty(p.prototype,"error",{enumerable:!0}),Object.defineProperty(p.prototype,"message",{enumerable:!0});class m extends _{constructor(e,t={}){super(e),this[n]=void 0===t.data?null:t.data}get data(){return this[n]}}Object.defineProperty(m.prototype,"data",{enumerable:!0});const y={addEventListener(e,t,s={}){for(const o of this.listeners(e))if(!s[r]&&o[i]===t&&!o[r])return;let o;if("message"===e)o=function(e,s){const r=new m("message",{data:s?e:e.toString()});r[l]=this,g(t,this,r)};else if("close"===e)o=function(e,s){const r=new u("close",{code:e,reason:s.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[l]=this,g(t,this,r)};else if("error"===e)o=function(e){const s=new p("error",{error:e,message:e.message});s[l]=this,g(t,this,s)};else{if("open"!==e)return;o=function(){const e=new _("open");e[l]=this,g(t,this,e)}}o[r]=!!s[r],o[i]=t,s.once?this.once(e,o):this.on(e,o)},removeEventListener(e,t){for(const s of this.listeners(e))if(s[i]===t&&!s[r]){this.removeListener(e,s);break}}};function g(e,t,s){"object"==typeof e&&e.handleEvent?e.handleEvent.call(e,s):e.call(t,s)}e.exports={CloseEvent:u,ErrorEvent:p,Event:_,EventTarget:y,MessageEvent:m}},503:(e,t,s)=>{"use strict";const{tokenChars:r}=s(746);function i(e,t,s){void 0===e[t]?e[t]=[s]:e[t].push(s)}e.exports={format:function(e){return Object.keys(e).map((t=>{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>[t].concat(Object.keys(e).map((t=>{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>!0===e?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(e){const t=Object.create(null);let s,o,n=Object.create(null),a=!1,h=!1,c=!1,l=-1,d=-1,f=-1,_=0;for(;_<e.length;_++)if(d=e.charCodeAt(_),void 0===s)if(-1===f&&1===r[d])-1===l&&(l=_);else if(0===_||32!==d&&9!==d){if(59!==d&&44!==d)throw new SyntaxError(`Unexpected character at index ${_}`);{if(-1===l)throw new SyntaxError(`Unexpected character at index ${_}`);-1===f&&(f=_);const r=e.slice(l,f);44===d?(i(t,r,n),n=Object.create(null)):s=r,l=f=-1}}else-1===f&&-1!==l&&(f=_);else if(void 0===o)if(-1===f&&1===r[d])-1===l&&(l=_);else if(32===d||9===d)-1===f&&-1!==l&&(f=_);else if(59===d||44===d){if(-1===l)throw new SyntaxError(`Unexpected character at index ${_}`);-1===f&&(f=_),i(n,e.slice(l,f),!0),44===d&&(i(t,s,n),n=Object.create(null),s=void 0),l=f=-1}else{if(61!==d||-1===l||-1!==f)throw new SyntaxError(`Unexpected character at index ${_}`);o=e.slice(l,_),l=f=-1}else if(h){if(1!==r[d])throw new SyntaxError(`Unexpected character at index ${_}`);-1===l?l=_:a||(a=!0),h=!1}else if(c)if(1===r[d])-1===l&&(l=_);else if(34===d&&-1!==l)c=!1,f=_;else{if(92!==d)throw new SyntaxError(`Unexpected character at index ${_}`);h=!0}else if(34===d&&61===e.charCodeAt(_-1))c=!0;else if(-1===f&&1===r[d])-1===l&&(l=_);else if(-1===l||32!==d&&9!==d){if(59!==d&&44!==d)throw new SyntaxError(`Unexpected character at index ${_}`);{if(-1===l)throw new SyntaxError(`Unexpected character at index ${_}`);-1===f&&(f=_);let r=e.slice(l,f);a&&(r=r.replace(/\\/g,""),a=!1),i(n,o,r),44===d&&(i(t,s,n),n=Object.create(null),s=void 0),o=void 0,l=f=-1}}else-1===f&&(f=_);if(-1===l||c||32===d||9===d)throw new SyntaxError("Unexpected end of input");-1===f&&(f=_);const u=e.slice(l,f);return void 0===s?i(t,u,n):(void 0===o?i(n,u,!0):i(n,o,a?u.replace(/\\/g,""):u),i(t,s,n)),t}}},305:e=>{"use strict";const t=Symbol("kDone"),s=Symbol("kRun");e.exports=class{constructor(e){this[t]=()=>{this.pending--,this[s]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[s]()}[s](){if(this.pending!==this.concurrency&&this.jobs.length){const e=this.jobs.shift();this.pending++,e(this[t])}}}},196:(e,t,s)=>{"use strict";const r=s(796),i=s(977),o=s(305),{kStatusCode:n}=s(872),a=Buffer[Symbol.species],h=Buffer.from([0,0,255,255]),c=Symbol("permessage-deflate"),l=Symbol("total-length"),d=Symbol("callback"),f=Symbol("buffers"),_=Symbol("error");let u;function p(e){this[f].push(e),this[l]+=e.length}function m(e){this[l]+=e.length,this[c]._maxPayload<1||this[l]<=this[c]._maxPayload?this[f].push(e):(this[_]=new RangeError("Max payload size exceeded"),this[_].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[_][n]=1009,this.removeListener("data",m),this.reset())}function y(e){this[c]._inflate=null,e[n]=1007,this[d](e)}e.exports=class{constructor(e,t,s){if(this._maxPayload=0|s,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!u){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;u=new o(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[d];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,s=e.find((e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits)));if(!s)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(s.server_no_context_takeover=!0),t.clientNoContextTakeover&&(s.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(s.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?s.client_max_window_bits=t.clientMaxWindowBits:!0!==s.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete s.client_max_window_bits,s}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach((e=>{Object.keys(e).forEach((t=>{let s=e[t];if(s.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(s=s[0],"client_max_window_bits"===t){if(!0!==s){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}else if("server_max_window_bits"===t){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==s)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}e[t]=s}))})),e}decompress(e,t,s){u.add((r=>{this._decompress(e,t,((e,t)=>{r(),s(e,t)}))}))}compress(e,t,s){u.add((r=>{this._compress(e,t,((e,t)=>{r(),s(e,t)}))}))}_decompress(e,t,s){const o=this._isServer?"client":"server";if(!this._inflate){const e=`${o}_max_window_bits`,t="number"!=typeof this.params[e]?r.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=r.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[c]=this,this._inflate[l]=0,this._inflate[f]=[],this._inflate.on("error",y),this._inflate.on("data",m)}this._inflate[d]=s,this._inflate.write(e),t&&this._inflate.write(h),this._inflate.flush((()=>{const e=this._inflate[_];if(e)return this._inflate.close(),this._inflate=null,void s(e);const r=i.concat(this._inflate[f],this._inflate[l]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[l]=0,this._inflate[f]=[],t&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),s(null,r)}))}_compress(e,t,s){const o=this._isServer?"server":"client";if(!this._deflate){const e=`${o}_max_window_bits`,t="number"!=typeof this.params[e]?r.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=r.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[l]=0,this._deflate[f]=[],this._deflate.on("data",p)}this._deflate[d]=s,this._deflate.write(e),this._deflate.flush(r.Z_SYNC_FLUSH,(()=>{if(!this._deflate)return;let e=i.concat(this._deflate[f],this._deflate[l]);t&&(e=new a(e.buffer,e.byteOffset,e.length-4)),this._deflate[d]=null,this._deflate[l]=0,this._deflate[f]=[],t&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),s(null,e)}))}}},957:(e,t,s)=>{"use strict";const{Writable:r}=s(781),i=s(196),{BINARY_TYPES:o,EMPTY_BUFFER:n,kStatusCode:a,kWebSocket:h}=s(872),{concat:c,toArrayBuffer:l,unmask:d}=s(977),{isValidStatusCode:f,isValidUTF8:_}=s(746),u=Buffer[Symbol.species];function p(e,t,s,r,i){const o=new e(s?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,p),o.code=i,o[a]=r,o}e.exports=class extends r{constructor(e={}){super(),this._binaryType=e.binaryType||o[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[h]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=0,this._loop=!1}_write(e,t,s){if(8===this._opcode&&0==this._state)return s();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){const t=this._buffers[0];return this._buffers[0]=new u(t.buffer,t.byteOffset+e,t.length-e),new u(t.buffer,t.byteOffset,e)}const t=Buffer.allocUnsafe(e);do{const s=this._buffers[0],r=t.length-e;e>=s.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(s.buffer,s.byteOffset,e),r),this._buffers[0]=new u(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return t}startLoop(e){let t;this._loop=!0;do{switch(this._state){case 0:t=this.getInfo();break;case 1:t=this.getPayloadLength16();break;case 2:t=this.getPayloadLength64();break;case 3:this.getMask();break;case 4:t=this.getData(e);break;default:return void(this._loop=!1)}}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2)return void(this._loop=!1);const e=this.consume(2);if(0!=(48&e[0]))return this._loop=!1,p(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");const t=64==(64&e[0]);if(t&&!this._extensions[i.extensionName])return this._loop=!1,p(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=128==(128&e[0]),this._opcode=15&e[0],this._payloadLength=127&e[1],0===this._opcode){if(t)return this._loop=!1,p(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,p(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented)return this._loop=!1,p(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=t}else{if(!(this._opcode>7&&this._opcode<11))return this._loop=!1,p(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin)return this._loop=!1,p(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,p(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength)return this._loop=!1,p(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=128==(128&e[1]),this._isServer){if(!this._masked)return this._loop=!1,p(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,p(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(126===this._payloadLength)this._state=1;else{if(127!==this._payloadLength)return this.haveLength();this._state=2}}getPayloadLength16(){if(!(this._bufferedBytes<2))return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength();this._loop=!1}getPayloadLength64(){if(this._bufferedBytes<8)return void(this._loop=!1);const e=this.consume(8),t=e.readUInt32BE(0);return t>Math.pow(2,21)-1?(this._loop=!1,p(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,p(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=n;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength)return void(this._loop=!1);t=this.consume(this._payloadLength),this._masked&&0!=(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])&&d(t,this._mask)}return this._opcode>7?this.controlMessage(t):this._compressed?(this._state=5,void this.decompress(t,e)):(t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage())}decompress(e,t){this._extensions[i.extensionName].decompress(e,this._fin,((e,s)=>{if(e)return t(e);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(p(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(s)}const r=this.dataMessage();if(r)return t(r);this.startLoop(t)}))}dataMessage(){if(this._fin){const e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let s;s="nodebuffer"===this._binaryType?c(t,e):"arraybuffer"===this._binaryType?l(c(t,e)):t,this.emit("message",s,!0)}else{const s=c(t,e);if(!this._skipUTF8Validation&&!_(s))return this._loop=!1,p(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",s,!1)}}this._state=0}controlMessage(e){if(8===this._opcode)if(this._loop=!1,0===e.length)this.emit("conclude",1005,n),this.end();else{const t=e.readUInt16BE(0);if(!f(t))return p(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");const s=new u(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!_(s))return p(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",t,s),this.end()}else 9===this._opcode?this.emit("ping",e):this.emit("pong",e);this._state=0}}},330:(e,t,s)=>{"use strict";s(808),s(404);const{randomFillSync:r}=s(113),i=s(196),{EMPTY_BUFFER:o}=s(872),{isValidStatusCode:n}=s(746),{mask:a,toBuffer:h}=s(977),c=Symbol("kByteLength"),l=Buffer.alloc(4);class d{constructor(e,t,s){this._extensions=t||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){let s,i,o=!1,n=2,h=!1;t.mask&&(s=t.maskBuffer||l,t.generateMask?t.generateMask(s):r(s,0,4),h=0==(s[0]|s[1]|s[2]|s[3]),n=6),"string"==typeof e?i=t.mask&&!h||void 0===t[c]?(e=Buffer.from(e)).length:t[c]:(i=e.length,o=t.mask&&t.readOnly&&!h);let d=i;i>=65536?(n+=8,d=127):i>125&&(n+=2,d=126);const f=Buffer.allocUnsafe(o?i+n:n);return f[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(f[0]|=64),f[1]=d,126===d?f.writeUInt16BE(i,2):127===d&&(f[2]=f[3]=0,f.writeUIntBE(i,4,6)),t.mask?(f[1]|=128,f[n-4]=s[0],f[n-3]=s[1],f[n-2]=s[2],f[n-1]=s[3],h?[f,e]:o?(a(e,s,f,n,i),[f]):(a(e,s,e,0,i),[f,e])):[f,e]}close(e,t,s,r){let i;if(void 0===e)i=o;else{if("number"!=typeof e||!n(e))throw new TypeError("First argument must be a valid error code number");if(void 0!==t&&t.length){const s=Buffer.byteLength(t);if(s>123)throw new RangeError("The message must not be greater than 123 bytes");i=Buffer.allocUnsafe(2+s),i.writeUInt16BE(e,0),"string"==typeof t?i.write(t,2):i.set(t,2)}else i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0)}const a={[c]:i.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,i,!1,a,r]):this.sendFrame(d.frame(i,a),r)}ping(e,t,s){let r,i;if("string"==typeof e?(r=Buffer.byteLength(e),i=!1):(r=(e=h(e)).length,i=h.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[c]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(d.frame(e,o),s)}pong(e,t,s){let r,i;if("string"==typeof e?(r=Buffer.byteLength(e),i=!1):(r=(e=h(e)).length,i=h.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[c]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(d.frame(e,o),s)}send(e,t,s){const r=this._extensions[i.extensionName];let o,n,a=t.binary?2:1,l=t.compress;if("string"==typeof e?(o=Buffer.byteLength(e),n=!1):(o=(e=h(e)).length,n=h.readOnly),this._firstFragment?(this._firstFragment=!1,l&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(l=o>=r._threshold),this._compress=l):(l=!1,a=0),t.fin&&(this._firstFragment=!0),r){const r={[c]:o,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:n,rsv1:l};this._deflating?this.enqueue([this.dispatch,e,this._compress,r,s]):this.dispatch(e,this._compress,r,s)}else this.sendFrame(d.frame(e,{[c]:o,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:n,rsv1:!1}),s)}dispatch(e,t,s,r){if(!t)return void this.sendFrame(d.frame(e,s),r);const o=this._extensions[i.extensionName];this._bufferedBytes+=s[c],this._deflating=!0,o.compress(e,s.fin,((e,t)=>{if(this._socket.destroyed){const e=new Error("The socket was closed while data was being compressed");"function"==typeof r&&r(e);for(let t=0;t<this._queue.length;t++){const s=this._queue[t],r=s[s.length-1];"function"==typeof r&&r(e)}}else this._bufferedBytes-=s[c],this._deflating=!1,s.readOnly=!1,this.sendFrame(d.frame(t,s),r),this.dequeue()}))}dequeue(){for(;!this._deflating&&this._queue.length;){const e=this._queue.shift();this._bufferedBytes-=e[3][c],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][c],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}e.exports=d},30:(e,t,s)=>{"use strict";const{Duplex:r}=s(781);function i(e){e.emit("close")}function o(){!this.destroyed&&this._writableState.finished&&this.destroy()}function n(e){this.removeListener("error",n),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}e.exports=function(e,t){let s=!0;const a=new r({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",(function(t,s){const r=!s&&a._readableState.objectMode?t.toString():t;a.push(r)||e.pause()})),e.once("error",(function(e){a.destroyed||(s=!1,a.destroy(e))})),e.once("close",(function(){a.destroyed||a.push(null)})),a._destroy=function(t,r){if(e.readyState===e.CLOSED)return r(t),void process.nextTick(i,a);let o=!1;e.once("error",(function(e){o=!0,r(e)})),e.once("close",(function(){o||r(t),process.nextTick(i,a)})),s&&e.terminate()},a._final=function(t){e.readyState!==e.CONNECTING?null!==e._socket&&(e._socket._writableState.finished?(t(),a._readableState.endEmitted&&a.destroy()):(e._socket.once("finish",(function(){t()})),e.close())):e.once("open",(function(){a._final(t)}))},a._read=function(){e.isPaused&&e.resume()},a._write=function(t,s,r){e.readyState!==e.CONNECTING?e.send(t,r):e.once("open",(function(){a._write(t,s,r)}))},a.on("end",o),a.on("error",n),a}},640:(e,t,s)=>{"use strict";const{tokenChars:r}=s(746);e.exports={parse:function(e){const t=new Set;let s=-1,i=-1,o=0;for(;o<e.length;o++){const n=e.charCodeAt(o);if(-1===i&&1===r[n])-1===s&&(s=o);else if(0===o||32!==n&&9!==n){if(44!==n)throw new SyntaxError(`Unexpected character at index ${o}`);{if(-1===s)throw new SyntaxError(`Unexpected character at index ${o}`);-1===i&&(i=o);const r=e.slice(s,i);if(t.has(r))throw new SyntaxError(`The "${r}" subprotocol is duplicated`);t.add(r),s=i=-1}}else-1===i&&-1!==s&&(i=o)}if(-1===s||-1!==i)throw new SyntaxError("Unexpected end of input");const n=e.slice(s,o);if(t.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return t.add(n),t}}},746:(e,t,s)=>{"use strict";const{isUtf8:r}=s(300);function i(e){const t=e.length;let s=0;for(;s<t;)if(0==(128&e[s]))s++;else if(192==(224&e[s])){if(s+1===t||128!=(192&e[s+1])||192==(254&e[s]))return!1;s+=2}else if(224==(240&e[s])){if(s+2>=t||128!=(192&e[s+1])||128!=(192&e[s+2])||224===e[s]&&128==(224&e[s+1])||237===e[s]&&160==(224&e[s+1]))return!1;s+=3}else{if(240!=(248&e[s]))return!1;if(s+3>=t||128!=(192&e[s+1])||128!=(192&e[s+2])||128!=(192&e[s+3])||240===e[s]&&128==(240&e[s+1])||244===e[s]&&e[s+1]>143||e[s]>244)return!1;s+=4}return!0}if(e.exports={isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:i,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},r)e.exports.isValidUTF8=function(e){return e.length<24?i(e):r(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{const t=s(Object(function(){var e=new Error("Cannot find module 'utf-8-validate'");throw e.code="MODULE_NOT_FOUND",e}()));e.exports.isValidUTF8=function(e){return e.length<32?i(e):t(e)}}catch(e){}},284:(e,t,s)=>{"use strict";const r=s(361),i=s(685),{createHash:o}=(s(687),s(808),s(404),s(113)),n=s(503),a=s(196),h=s(640),c=s(762),{GUID:l,kWebSocket:d}=s(872),f=/^[+/0-9A-Za-z]{22}==$/;function _(e){e._state=2,e.emit("close")}function u(){this.destroy()}function p(e,t,s,r){s=s||i.STATUS_CODES[t],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...r},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${i.STATUS_CODES[t]}\r\n`+Object.keys(r).map((e=>`${e}: ${r[e]}`)).join("\r\n")+"\r\n\r\n"+s)}function m(e,t,s,r,i){if(e.listenerCount("wsClientError")){const r=new Error(i);Error.captureStackTrace(r,m),e.emit("wsClientError",r,s,t)}else p(s,r,i)}e.exports=class extends r{constructor(e,t){if(super(),null==(e={maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:c,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=e.port?(this._server=i.createServer(((e,t)=>{const s=i.STATUS_CODES[426];t.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),t.end(s)})),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const s of Object.keys(t))e.on(s,t[s]);return function(){for(const s of Object.keys(t))e.removeListener(s,t[s])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,s,r)=>{this.handleUpgrade(t,s,r,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state)return e&&this.once("close",(()=>{e(new Error("The server is not running"))})),void process.nextTick(_,this);if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(_,this);else{const e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close((()=>{_(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,s,r){t.on("error",u);const i=e.headers["sec-websocket-key"],o=+e.headers["sec-websocket-version"];if("GET"!==e.method){return void m(this,e,t,405,"Invalid HTTP method")}if("websocket"!==e.headers.upgrade.toLowerCase()){return void m(this,e,t,400,"Invalid Upgrade header")}if(!i||!f.test(i)){return void m(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header")}if(8!==o&&13!==o){return void m(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header")}if(!this.shouldHandle(e))return void p(t,400);const c=e.headers["sec-websocket-protocol"];let l=new Set;if(void 0!==c)try{l=h.parse(c)}catch(s){return void m(this,e,t,400,"Invalid Sec-WebSocket-Protocol header")}const d=e.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&void 0!==d){const s=new a(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const e=n.parse(d);e[a.extensionName]&&(s.accept(e[a.extensionName]),_[a.extensionName]=s)}catch(s){return void m(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header")}}if(this.options.verifyClient){const n={origin:e.headers[""+(8===o?"sec-websocket-origin":"origin")],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(n,((o,n,a,h)=>{if(!o)return p(t,n||401,a,h);this.completeUpgrade(_,i,l,e,t,s,r)}));if(!this.options.verifyClient(n))return p(t,401)}this.completeUpgrade(_,i,l,e,t,s,r)}completeUpgrade(e,t,s,r,i,h,c){if(!i.readable||!i.writable)return i.destroy();if(i[d])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return p(i,503);const f=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${o("sha1").update(t+l).digest("base64")}`],m=new this.options.WebSocket(null);if(s.size){const e=this.options.handleProtocols?this.options.handleProtocols(s,r):s.values().next().value;e&&(f.push(`Sec-WebSocket-Protocol: ${e}`),m._protocol=e)}if(e[a.extensionName]){const t=e[a.extensionName].params,s=n.format({[a.extensionName]:[t]});f.push(`Sec-WebSocket-Extensions: ${s}`),m._extensions=e}this.emit("headers",f,r),i.write(f.concat("\r\n").join("\r\n")),i.removeListener("error",u),m.setSocket(i,h,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(m),m.on("close",(()=>{this.clients.delete(m),this._shouldEmitClose&&!this.clients.size&&process.nextTick(_,this)}))),c(m,r)}}},762:(e,t,s)=>{"use strict";const r=s(361),i=s(687),o=s(685),n=s(808),a=s(404),{randomBytes:h,createHash:c}=s(113),{Readable:l}=s(781),{URL:d}=s(310),f=s(196),_=s(957),u=s(330),{BINARY_TYPES:p,EMPTY_BUFFER:m,GUID:y,kForOnEventAttribute:g,kListener:b,kStatusCode:v,kWebSocket:S,NOOP:w}=s(872),{EventTarget:{addEventListener:k,removeEventListener:E}}=s(62),{format:x,parse:O}=s(503),{toBuffer:T}=s(977),C=Symbol("kAborted"),N=[8,13],L=["CONNECTING","OPEN","CLOSING","CLOSED"],P=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class R extends r{constructor(e,t,s){super(),this._binaryType=p[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=m,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=R.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==e?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===t?t=[]:Array.isArray(t)||("object"==typeof t&&null!==t?(s=t,t=[]):t=[t]),U(this,e,t,s)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){p.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,s){const r=new _({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation});this._sender=new u(e,this._extensions,s.generateMask),this._receiver=r,this._socket=e,r[S]=this,e[S]=this,r.on("conclude",A),r.on("drain",F),r.on("error",j),r.on("message",G),r.on("ping",V),r.on("pong",q),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",H),e.on("data",Y),e.on("end",X),e.on("error",K),this._readyState=R.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=R.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[f.extensionName]&&this._extensions[f.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=R.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==R.CLOSED)if(this.readyState!==R.CONNECTING)this.readyState!==R.CLOSING?(this._readyState=R.CLOSING,this._sender.close(e,t,!this._isServer,(e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())})),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),3e4)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();else{const e="WebSocket was closed before the connection was established";W(this,this._req,e)}}pause(){this.readyState!==R.CONNECTING&&this.readyState!==R.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,s){if(this.readyState===R.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===R.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||m,t,s)):D(this,e,s)}pong(e,t,s){if(this.readyState===R.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===R.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||m,t,s)):D(this,e,s)}resume(){this.readyState!==R.CONNECTING&&this.readyState!==R.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,s){if(this.readyState===R.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(s=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==R.OPEN)return void D(this,e,s);const r={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[f.extensionName]||(r.compress=!1),this._sender.send(e||m,r,s)}terminate(){if(this.readyState!==R.CLOSED)if(this.readyState!==R.CONNECTING)this._socket&&(this._readyState=R.CLOSING,this._socket.destroy());else{const e="WebSocket was closed before the connection was established";W(this,this._req,e)}}}function U(e,t,s,r){const n={protocolVersion:N[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(!N.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${N.join(", ")})`);let a;if(t instanceof d)a=t,e._url=t.href;else{try{a=new d(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}e._url=t}const l="wss:"===a.protocol,_="ws+unix:"===a.protocol;let u;if("ws:"===a.protocol||l||_?_&&!a.pathname?u="The URL's pathname is empty":a.hash&&(u="The URL contains a fragment identifier"):u='The URL\'s protocol must be one of "ws:", "wss:", or "ws+unix:"',u){const t=new SyntaxError(u);if(0===e._redirects)throw t;return void B(e,t)}const p=l?443:80,m=h(16).toString("base64"),g=l?i.request:o.request,b=new Set;let v,S;if(n.createConnection=l?M:I,n.defaultPort=n.defaultPort||p,n.port=a.port||p,n.host=a.hostname.startsWith("[")?a.hostname.slice(1,-1):a.hostname,n.headers={...n.headers,"Sec-WebSocket-Version":n.protocolVersion,"Sec-WebSocket-Key":m,Connection:"Upgrade",Upgrade:"websocket"},n.path=a.pathname+a.search,n.timeout=n.handshakeTimeout,n.perMessageDeflate&&(v=new f(!0!==n.perMessageDeflate?n.perMessageDeflate:{},!1,n.maxPayload),n.headers["Sec-WebSocket-Extensions"]=x({[f.extensionName]:v.offer()})),s.length){for(const e of s){if("string"!=typeof e||!P.test(e)||b.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");b.add(e)}n.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(n.origin&&(n.protocolVersion<13?n.headers["Sec-WebSocket-Origin"]=n.origin:n.headers.Origin=n.origin),(a.username||a.password)&&(n.auth=`${a.username}:${a.password}`),_){const e=n.path.split(":");n.socketPath=e[0],n.path=e[1]}if(n.followRedirects){if(0===e._redirects){e._originalIpc=_,e._originalSecure=l,e._originalHostOrSocketPath=_?n.socketPath:a.host;const t=r&&r.headers;if(r={...r,headers:{}},t)for(const[e,s]of Object.entries(t))r.headers[e.toLowerCase()]=s}else if(0===e.listenerCount("redirect")){const t=_?!!e._originalIpc&&n.socketPath===e._originalHostOrSocketPath:!e._originalIpc&&a.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!l)&&(delete n.headers.authorization,delete n.headers.cookie,t||delete n.headers.host,n.auth=void 0)}n.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(n.auth).toString("base64")),S=e._req=g(n),e._redirects&&e.emit("redirect",e.url,S)}else S=e._req=g(n);n.timeout&&S.on("timeout",(()=>{W(e,S,"Opening handshake has timed out")})),S.on("error",(t=>{null===S||S[C]||(S=e._req=null,B(e,t))})),S.on("response",(i=>{const o=i.headers.location,a=i.statusCode;if(o&&n.followRedirects&&a>=300&&a<400){if(++e._redirects>n.maxRedirects)return void W(e,S,"Maximum redirects exceeded");let i;S.abort();try{i=new d(o,t)}catch(t){const s=new SyntaxError(`Invalid URL: ${o}`);return void B(e,s)}U(e,i,s,r)}else e.emit("unexpected-response",S,i)||W(e,S,`Unexpected server response: ${i.statusCode}`)})),S.on("upgrade",((t,s,r)=>{if(e.emit("upgrade",t),e.readyState!==R.CONNECTING)return;if(S=e._req=null,"websocket"!==t.headers.upgrade.toLowerCase())return void W(e,s,"Invalid Upgrade header");const i=c("sha1").update(m+y).digest("base64");if(t.headers["sec-websocket-accept"]!==i)return void W(e,s,"Invalid Sec-WebSocket-Accept header");const o=t.headers["sec-websocket-protocol"];let a;if(void 0!==o?b.size?b.has(o)||(a="Server sent an invalid subprotocol"):a="Server sent a subprotocol but none was requested":b.size&&(a="Server sent no subprotocol"),a)return void W(e,s,a);o&&(e._protocol=o);const h=t.headers["sec-websocket-extensions"];if(void 0!==h){if(!v){return void W(e,s,"Server sent a Sec-WebSocket-Extensions header but no extension was requested")}let t;try{t=O(h)}catch(t){return void W(e,s,"Invalid Sec-WebSocket-Extensions header")}const r=Object.keys(t);if(1!==r.length||r[0]!==f.extensionName){return void W(e,s,"Server indicated an extension that was not requested")}try{v.accept(t[f.extensionName])}catch(t){return void W(e,s,"Invalid Sec-WebSocket-Extensions header")}e._extensions[f.extensionName]=v}e.setSocket(s,r,{generateMask:n.generateMask,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation})})),n.finishRequest?n.finishRequest(S,e):S.end()}function B(e,t){e._readyState=R.CLOSING,e.emit("error",t),e.emitClose()}function I(e){return e.path=e.socketPath,n.connect(e)}function M(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=n.isIP(e.host)?"":e.host),a.connect(e)}function W(e,t,s){e._readyState=R.CLOSING;const r=new Error(s);Error.captureStackTrace(r,W),t.setHeader?(t[C]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(B,e,r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function D(e,t,s){if(t){const s=T(t).length;e._socket?e._sender._bufferedBytes+=s:e._bufferedAmount+=s}if(s){const t=new Error(`WebSocket is not open: readyState ${e.readyState} (${L[e.readyState]})`);process.nextTick(s,t)}}function A(e,t){const s=this[S];s._closeFrameReceived=!0,s._closeMessage=t,s._closeCode=e,void 0!==s._socket[S]&&(s._socket.removeListener("data",Y),process.nextTick(z,s._socket),1005===e?s.close():s.close(e,t))}function F(){const e=this[S];e.isPaused||e._socket.resume()}function j(e){const t=this[S];void 0!==t._socket[S]&&(t._socket.removeListener("data",Y),process.nextTick(z,t._socket),t.close(e[v])),t.emit("error",e)}function $(){this[S].emitClose()}function G(e,t){this[S].emit("message",e,t)}function V(e){const t=this[S];t.pong(e,!t._isServer,w),t.emit("ping",e)}function q(e){this[S].emit("pong",e)}function z(e){e.resume()}function H(){const e=this[S];let t;this.removeListener("close",H),this.removeListener("data",Y),this.removeListener("end",X),e._readyState=R.CLOSING,this._readableState.endEmitted||e._closeFrameReceived||e._receiver._writableState.errorEmitted||null===(t=e._socket.read())||e._receiver.write(t),e._receiver.end(),this[S]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",$),e._receiver.on("finish",$))}function Y(e){this[S]._receiver.write(e)||this.pause()}function X(){const e=this[S];e._readyState=R.CLOSING,e._receiver.end(),this.end()}function K(){const e=this[S];this.removeListener("error",K),this.on("error",w),e&&(e._readyState=R.CLOSING,this.destroy())}Object.defineProperty(R,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")}),Object.defineProperty(R.prototype,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")}),Object.defineProperty(R,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")}),Object.defineProperty(R.prototype,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")}),Object.defineProperty(R,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")}),Object.defineProperty(R.prototype,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")}),Object.defineProperty(R,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")}),Object.defineProperty(R.prototype,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(R.prototype,e,{enumerable:!0})})),["open","error","close","message"].forEach((e=>{Object.defineProperty(R.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[g])return t[b];return null},set(t){for(const t of this.listeners(e))if(t[g]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[g]:!0})}})})),R.prototype.addEventListener=k,R.prototype.removeEventListener=E,e.exports=R},300:e=>{"use strict";e.exports=require("buffer")},113:e=>{"use strict";e.exports=require("crypto")},361:e=>{"use strict";e.exports=require("events")},685:e=>{"use strict";e.exports=require("http")},687:e=>{"use strict";e.exports=require("https")},808:e=>{"use strict";e.exports=require("net")},781:e=>{"use strict";e.exports=require("stream")},404:e=>{"use strict";e.exports=require("tls")},310:e=>{"use strict";e.exports=require("url")},796:e=>{"use strict";e.exports=require("zlib")}},t={};function s(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,s),o.exports}var r={};(()=>{var e=r,t=s(777);e.Server=t.Server,e.on=t.on,e.close=t.close,e.ping=t.ping})();var i=exports;for(var o in r)i[o]=r[o];r.__esModule&&Object.defineProperty(i,"__esModule",{value:!0})})();
|
|
1
|
+
(()=>{var e={777:(e,t,s)=>{"use strict";const r=s(762);r.createWebSocketStream=s(30),r.Server=s(284),r.Receiver=s(957),r.Sender=s(330),r.WebSocket=r,r.WebSocketServer=r.Server,e.exports=r},977:(e,t,s)=>{"use strict";const{EMPTY_BUFFER:r}=s(872),i=Buffer[Symbol.species];function o(e,t,s,r,i){for(let o=0;o<i;o++)s[r+o]=e[o]^t[3&o]}function n(e,t){for(let s=0;s<e.length;s++)e[s]^=t[3&s]}if(e.exports={concat:function(e,t){if(0===e.length)return r;if(1===e.length)return e[0];const s=Buffer.allocUnsafe(t);let o=0;for(let t=0;t<e.length;t++){const r=e[t];s.set(r,o),o+=r.length}return o<t?new i(s.buffer,s.byteOffset,o):s},mask:o,toArrayBuffer:function(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)},toBuffer:function e(t){if(e.readOnly=!0,Buffer.isBuffer(t))return t;let s;return t instanceof ArrayBuffer?s=new i(t):ArrayBuffer.isView(t)?s=new i(t.buffer,t.byteOffset,t.byteLength):(s=Buffer.from(t),e.readOnly=!1),s},unmask:n},!process.env.WS_NO_BUFFER_UTIL)try{const t=s(Object(function(){var e=new Error("Cannot find module 'bufferutil'");throw e.code="MODULE_NOT_FOUND",e}()));e.exports.mask=function(e,s,r,i,n){n<48?o(e,s,r,i,n):t.mask(e,s,r,i,n)},e.exports.unmask=function(e,s){e.length<32?n(e,s):t.unmask(e,s)}}catch(e){}},872:e=>{"use strict";e.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}},62:(e,t,s)=>{"use strict";const{kForOnEventAttribute:r,kListener:i}=s(872),o=Symbol("kCode"),n=Symbol("kData"),a=Symbol("kError"),h=Symbol("kMessage"),c=Symbol("kReason"),l=Symbol("kTarget"),d=Symbol("kType"),f=Symbol("kWasClean");class _{constructor(e){this[l]=null,this[d]=e}get target(){return this[l]}get type(){return this[d]}}Object.defineProperty(_.prototype,"target",{enumerable:!0}),Object.defineProperty(_.prototype,"type",{enumerable:!0});class u extends _{constructor(e,t={}){super(e),this[o]=void 0===t.code?0:t.code,this[c]=void 0===t.reason?"":t.reason,this[f]=void 0!==t.wasClean&&t.wasClean}get code(){return this[o]}get reason(){return this[c]}get wasClean(){return this[f]}}Object.defineProperty(u.prototype,"code",{enumerable:!0}),Object.defineProperty(u.prototype,"reason",{enumerable:!0}),Object.defineProperty(u.prototype,"wasClean",{enumerable:!0});class p extends _{constructor(e,t={}){super(e),this[a]=void 0===t.error?null:t.error,this[h]=void 0===t.message?"":t.message}get error(){return this[a]}get message(){return this[h]}}Object.defineProperty(p.prototype,"error",{enumerable:!0}),Object.defineProperty(p.prototype,"message",{enumerable:!0});class m extends _{constructor(e,t={}){super(e),this[n]=void 0===t.data?null:t.data}get data(){return this[n]}}Object.defineProperty(m.prototype,"data",{enumerable:!0});const y={addEventListener(e,t,s={}){for(const o of this.listeners(e))if(!s[r]&&o[i]===t&&!o[r])return;let o;if("message"===e)o=function(e,s){const r=new m("message",{data:s?e:e.toString()});r[l]=this,g(t,this,r)};else if("close"===e)o=function(e,s){const r=new u("close",{code:e,reason:s.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[l]=this,g(t,this,r)};else if("error"===e)o=function(e){const s=new p("error",{error:e,message:e.message});s[l]=this,g(t,this,s)};else{if("open"!==e)return;o=function(){const e=new _("open");e[l]=this,g(t,this,e)}}o[r]=!!s[r],o[i]=t,s.once?this.once(e,o):this.on(e,o)},removeEventListener(e,t){for(const s of this.listeners(e))if(s[i]===t&&!s[r]){this.removeListener(e,s);break}}};function g(e,t,s){"object"==typeof e&&e.handleEvent?e.handleEvent.call(e,s):e.call(t,s)}e.exports={CloseEvent:u,ErrorEvent:p,Event:_,EventTarget:y,MessageEvent:m}},503:(e,t,s)=>{"use strict";const{tokenChars:r}=s(746);function i(e,t,s){void 0===e[t]?e[t]=[s]:e[t].push(s)}e.exports={format:function(e){return Object.keys(e).map((t=>{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>[t].concat(Object.keys(e).map((t=>{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>!0===e?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(e){const t=Object.create(null);let s,o,n=Object.create(null),a=!1,h=!1,c=!1,l=-1,d=-1,f=-1,_=0;for(;_<e.length;_++)if(d=e.charCodeAt(_),void 0===s)if(-1===f&&1===r[d])-1===l&&(l=_);else if(0===_||32!==d&&9!==d){if(59!==d&&44!==d)throw new SyntaxError(`Unexpected character at index ${_}`);{if(-1===l)throw new SyntaxError(`Unexpected character at index ${_}`);-1===f&&(f=_);const r=e.slice(l,f);44===d?(i(t,r,n),n=Object.create(null)):s=r,l=f=-1}}else-1===f&&-1!==l&&(f=_);else if(void 0===o)if(-1===f&&1===r[d])-1===l&&(l=_);else if(32===d||9===d)-1===f&&-1!==l&&(f=_);else if(59===d||44===d){if(-1===l)throw new SyntaxError(`Unexpected character at index ${_}`);-1===f&&(f=_),i(n,e.slice(l,f),!0),44===d&&(i(t,s,n),n=Object.create(null),s=void 0),l=f=-1}else{if(61!==d||-1===l||-1!==f)throw new SyntaxError(`Unexpected character at index ${_}`);o=e.slice(l,_),l=f=-1}else if(h){if(1!==r[d])throw new SyntaxError(`Unexpected character at index ${_}`);-1===l?l=_:a||(a=!0),h=!1}else if(c)if(1===r[d])-1===l&&(l=_);else if(34===d&&-1!==l)c=!1,f=_;else{if(92!==d)throw new SyntaxError(`Unexpected character at index ${_}`);h=!0}else if(34===d&&61===e.charCodeAt(_-1))c=!0;else if(-1===f&&1===r[d])-1===l&&(l=_);else if(-1===l||32!==d&&9!==d){if(59!==d&&44!==d)throw new SyntaxError(`Unexpected character at index ${_}`);{if(-1===l)throw new SyntaxError(`Unexpected character at index ${_}`);-1===f&&(f=_);let r=e.slice(l,f);a&&(r=r.replace(/\\/g,""),a=!1),i(n,o,r),44===d&&(i(t,s,n),n=Object.create(null),s=void 0),o=void 0,l=f=-1}}else-1===f&&(f=_);if(-1===l||c||32===d||9===d)throw new SyntaxError("Unexpected end of input");-1===f&&(f=_);const u=e.slice(l,f);return void 0===s?i(t,u,n):(void 0===o?i(n,u,!0):i(n,o,a?u.replace(/\\/g,""):u),i(t,s,n)),t}}},305:e=>{"use strict";const t=Symbol("kDone"),s=Symbol("kRun");e.exports=class{constructor(e){this[t]=()=>{this.pending--,this[s]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[s]()}[s](){if(this.pending!==this.concurrency&&this.jobs.length){const e=this.jobs.shift();this.pending++,e(this[t])}}}},196:(e,t,s)=>{"use strict";const r=s(796),i=s(977),o=s(305),{kStatusCode:n}=s(872),a=Buffer[Symbol.species],h=Buffer.from([0,0,255,255]),c=Symbol("permessage-deflate"),l=Symbol("total-length"),d=Symbol("callback"),f=Symbol("buffers"),_=Symbol("error");let u;function p(e){this[f].push(e),this[l]+=e.length}function m(e){this[l]+=e.length,this[c]._maxPayload<1||this[l]<=this[c]._maxPayload?this[f].push(e):(this[_]=new RangeError("Max payload size exceeded"),this[_].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[_][n]=1009,this.removeListener("data",m),this.reset())}function y(e){this[c]._inflate=null,e[n]=1007,this[d](e)}e.exports=class{constructor(e,t,s){if(this._maxPayload=0|s,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!u){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;u=new o(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[d];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,s=e.find((e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits)));if(!s)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(s.server_no_context_takeover=!0),t.clientNoContextTakeover&&(s.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(s.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?s.client_max_window_bits=t.clientMaxWindowBits:!0!==s.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete s.client_max_window_bits,s}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach((e=>{Object.keys(e).forEach((t=>{let s=e[t];if(s.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(s=s[0],"client_max_window_bits"===t){if(!0!==s){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}else if("server_max_window_bits"===t){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==s)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}e[t]=s}))})),e}decompress(e,t,s){u.add((r=>{this._decompress(e,t,((e,t)=>{r(),s(e,t)}))}))}compress(e,t,s){u.add((r=>{this._compress(e,t,((e,t)=>{r(),s(e,t)}))}))}_decompress(e,t,s){const o=this._isServer?"client":"server";if(!this._inflate){const e=`${o}_max_window_bits`,t="number"!=typeof this.params[e]?r.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=r.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[c]=this,this._inflate[l]=0,this._inflate[f]=[],this._inflate.on("error",y),this._inflate.on("data",m)}this._inflate[d]=s,this._inflate.write(e),t&&this._inflate.write(h),this._inflate.flush((()=>{const e=this._inflate[_];if(e)return this._inflate.close(),this._inflate=null,void s(e);const r=i.concat(this._inflate[f],this._inflate[l]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[l]=0,this._inflate[f]=[],t&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),s(null,r)}))}_compress(e,t,s){const o=this._isServer?"server":"client";if(!this._deflate){const e=`${o}_max_window_bits`,t="number"!=typeof this.params[e]?r.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=r.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[l]=0,this._deflate[f]=[],this._deflate.on("data",p)}this._deflate[d]=s,this._deflate.write(e),this._deflate.flush(r.Z_SYNC_FLUSH,(()=>{if(!this._deflate)return;let e=i.concat(this._deflate[f],this._deflate[l]);t&&(e=new a(e.buffer,e.byteOffset,e.length-4)),this._deflate[d]=null,this._deflate[l]=0,this._deflate[f]=[],t&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),s(null,e)}))}}},957:(e,t,s)=>{"use strict";const{Writable:r}=s(781),i=s(196),{BINARY_TYPES:o,EMPTY_BUFFER:n,kStatusCode:a,kWebSocket:h}=s(872),{concat:c,toArrayBuffer:l,unmask:d}=s(977),{isValidStatusCode:f,isValidUTF8:_}=s(746),u=Buffer[Symbol.species];function p(e,t,s,r,i){const o=new e(s?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,p),o.code=i,o[a]=r,o}e.exports=class extends r{constructor(e={}){super(),this._binaryType=e.binaryType||o[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[h]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=0,this._loop=!1}_write(e,t,s){if(8===this._opcode&&0==this._state)return s();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){const t=this._buffers[0];return this._buffers[0]=new u(t.buffer,t.byteOffset+e,t.length-e),new u(t.buffer,t.byteOffset,e)}const t=Buffer.allocUnsafe(e);do{const s=this._buffers[0],r=t.length-e;e>=s.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(s.buffer,s.byteOffset,e),r),this._buffers[0]=new u(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return t}startLoop(e){let t;this._loop=!0;do{switch(this._state){case 0:t=this.getInfo();break;case 1:t=this.getPayloadLength16();break;case 2:t=this.getPayloadLength64();break;case 3:this.getMask();break;case 4:t=this.getData(e);break;default:return void(this._loop=!1)}}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2)return void(this._loop=!1);const e=this.consume(2);if(0!=(48&e[0]))return this._loop=!1,p(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");const t=64==(64&e[0]);if(t&&!this._extensions[i.extensionName])return this._loop=!1,p(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=128==(128&e[0]),this._opcode=15&e[0],this._payloadLength=127&e[1],0===this._opcode){if(t)return this._loop=!1,p(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,p(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented)return this._loop=!1,p(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=t}else{if(!(this._opcode>7&&this._opcode<11))return this._loop=!1,p(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin)return this._loop=!1,p(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,p(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength)return this._loop=!1,p(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=128==(128&e[1]),this._isServer){if(!this._masked)return this._loop=!1,p(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,p(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(126===this._payloadLength)this._state=1;else{if(127!==this._payloadLength)return this.haveLength();this._state=2}}getPayloadLength16(){if(!(this._bufferedBytes<2))return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength();this._loop=!1}getPayloadLength64(){if(this._bufferedBytes<8)return void(this._loop=!1);const e=this.consume(8),t=e.readUInt32BE(0);return t>Math.pow(2,21)-1?(this._loop=!1,p(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,p(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=n;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength)return void(this._loop=!1);t=this.consume(this._payloadLength),this._masked&&0!=(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])&&d(t,this._mask)}return this._opcode>7?this.controlMessage(t):this._compressed?(this._state=5,void this.decompress(t,e)):(t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage())}decompress(e,t){this._extensions[i.extensionName].decompress(e,this._fin,((e,s)=>{if(e)return t(e);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(p(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(s)}const r=this.dataMessage();if(r)return t(r);this.startLoop(t)}))}dataMessage(){if(this._fin){const e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let s;s="nodebuffer"===this._binaryType?c(t,e):"arraybuffer"===this._binaryType?l(c(t,e)):t,this.emit("message",s,!0)}else{const s=c(t,e);if(!this._skipUTF8Validation&&!_(s))return this._loop=!1,p(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",s,!1)}}this._state=0}controlMessage(e){if(8===this._opcode)if(this._loop=!1,0===e.length)this.emit("conclude",1005,n),this.end();else{const t=e.readUInt16BE(0);if(!f(t))return p(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");const s=new u(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!_(s))return p(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",t,s),this.end()}else 9===this._opcode?this.emit("ping",e):this.emit("pong",e);this._state=0}}},330:(e,t,s)=>{"use strict";s(808),s(404);const{randomFillSync:r}=s(113),i=s(196),{EMPTY_BUFFER:o}=s(872),{isValidStatusCode:n}=s(746),{mask:a,toBuffer:h}=s(977),c=Symbol("kByteLength"),l=Buffer.alloc(4);class d{constructor(e,t,s){this._extensions=t||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){let s,i,o=!1,n=2,h=!1;t.mask&&(s=t.maskBuffer||l,t.generateMask?t.generateMask(s):r(s,0,4),h=0==(s[0]|s[1]|s[2]|s[3]),n=6),"string"==typeof e?i=t.mask&&!h||void 0===t[c]?(e=Buffer.from(e)).length:t[c]:(i=e.length,o=t.mask&&t.readOnly&&!h);let d=i;i>=65536?(n+=8,d=127):i>125&&(n+=2,d=126);const f=Buffer.allocUnsafe(o?i+n:n);return f[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(f[0]|=64),f[1]=d,126===d?f.writeUInt16BE(i,2):127===d&&(f[2]=f[3]=0,f.writeUIntBE(i,4,6)),t.mask?(f[1]|=128,f[n-4]=s[0],f[n-3]=s[1],f[n-2]=s[2],f[n-1]=s[3],h?[f,e]:o?(a(e,s,f,n,i),[f]):(a(e,s,e,0,i),[f,e])):[f,e]}close(e,t,s,r){let i;if(void 0===e)i=o;else{if("number"!=typeof e||!n(e))throw new TypeError("First argument must be a valid error code number");if(void 0!==t&&t.length){const s=Buffer.byteLength(t);if(s>123)throw new RangeError("The message must not be greater than 123 bytes");i=Buffer.allocUnsafe(2+s),i.writeUInt16BE(e,0),"string"==typeof t?i.write(t,2):i.set(t,2)}else i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0)}const a={[c]:i.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,i,!1,a,r]):this.sendFrame(d.frame(i,a),r)}ping(e,t,s){let r,i;if("string"==typeof e?(r=Buffer.byteLength(e),i=!1):(r=(e=h(e)).length,i=h.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[c]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(d.frame(e,o),s)}pong(e,t,s){let r,i;if("string"==typeof e?(r=Buffer.byteLength(e),i=!1):(r=(e=h(e)).length,i=h.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");const o={[c]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(d.frame(e,o),s)}send(e,t,s){const r=this._extensions[i.extensionName];let o,n,a=t.binary?2:1,l=t.compress;if("string"==typeof e?(o=Buffer.byteLength(e),n=!1):(o=(e=h(e)).length,n=h.readOnly),this._firstFragment?(this._firstFragment=!1,l&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(l=o>=r._threshold),this._compress=l):(l=!1,a=0),t.fin&&(this._firstFragment=!0),r){const r={[c]:o,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:n,rsv1:l};this._deflating?this.enqueue([this.dispatch,e,this._compress,r,s]):this.dispatch(e,this._compress,r,s)}else this.sendFrame(d.frame(e,{[c]:o,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:n,rsv1:!1}),s)}dispatch(e,t,s,r){if(!t)return void this.sendFrame(d.frame(e,s),r);const o=this._extensions[i.extensionName];this._bufferedBytes+=s[c],this._deflating=!0,o.compress(e,s.fin,((e,t)=>{if(this._socket.destroyed){const e=new Error("The socket was closed while data was being compressed");"function"==typeof r&&r(e);for(let t=0;t<this._queue.length;t++){const s=this._queue[t],r=s[s.length-1];"function"==typeof r&&r(e)}}else this._bufferedBytes-=s[c],this._deflating=!1,s.readOnly=!1,this.sendFrame(d.frame(t,s),r),this.dequeue()}))}dequeue(){for(;!this._deflating&&this._queue.length;){const e=this._queue.shift();this._bufferedBytes-=e[3][c],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][c],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}e.exports=d},30:(e,t,s)=>{"use strict";const{Duplex:r}=s(781);function i(e){e.emit("close")}function o(){!this.destroyed&&this._writableState.finished&&this.destroy()}function n(e){this.removeListener("error",n),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}e.exports=function(e,t){let s=!0;const a=new r({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",(function(t,s){const r=!s&&a._readableState.objectMode?t.toString():t;a.push(r)||e.pause()})),e.once("error",(function(e){a.destroyed||(s=!1,a.destroy(e))})),e.once("close",(function(){a.destroyed||a.push(null)})),a._destroy=function(t,r){if(e.readyState===e.CLOSED)return r(t),void process.nextTick(i,a);let o=!1;e.once("error",(function(e){o=!0,r(e)})),e.once("close",(function(){o||r(t),process.nextTick(i,a)})),s&&e.terminate()},a._final=function(t){e.readyState!==e.CONNECTING?null!==e._socket&&(e._socket._writableState.finished?(t(),a._readableState.endEmitted&&a.destroy()):(e._socket.once("finish",(function(){t()})),e.close())):e.once("open",(function(){a._final(t)}))},a._read=function(){e.isPaused&&e.resume()},a._write=function(t,s,r){e.readyState!==e.CONNECTING?e.send(t,r):e.once("open",(function(){a._write(t,s,r)}))},a.on("end",o),a.on("error",n),a}},640:(e,t,s)=>{"use strict";const{tokenChars:r}=s(746);e.exports={parse:function(e){const t=new Set;let s=-1,i=-1,o=0;for(;o<e.length;o++){const n=e.charCodeAt(o);if(-1===i&&1===r[n])-1===s&&(s=o);else if(0===o||32!==n&&9!==n){if(44!==n)throw new SyntaxError(`Unexpected character at index ${o}`);{if(-1===s)throw new SyntaxError(`Unexpected character at index ${o}`);-1===i&&(i=o);const r=e.slice(s,i);if(t.has(r))throw new SyntaxError(`The "${r}" subprotocol is duplicated`);t.add(r),s=i=-1}}else-1===i&&-1!==s&&(i=o)}if(-1===s||-1!==i)throw new SyntaxError("Unexpected end of input");const n=e.slice(s,o);if(t.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return t.add(n),t}}},746:(e,t,s)=>{"use strict";const{isUtf8:r}=s(300);function i(e){const t=e.length;let s=0;for(;s<t;)if(0==(128&e[s]))s++;else if(192==(224&e[s])){if(s+1===t||128!=(192&e[s+1])||192==(254&e[s]))return!1;s+=2}else if(224==(240&e[s])){if(s+2>=t||128!=(192&e[s+1])||128!=(192&e[s+2])||224===e[s]&&128==(224&e[s+1])||237===e[s]&&160==(224&e[s+1]))return!1;s+=3}else{if(240!=(248&e[s]))return!1;if(s+3>=t||128!=(192&e[s+1])||128!=(192&e[s+2])||128!=(192&e[s+3])||240===e[s]&&128==(240&e[s+1])||244===e[s]&&e[s+1]>143||e[s]>244)return!1;s+=4}return!0}if(e.exports={isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:i,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},r)e.exports.isValidUTF8=function(e){return e.length<24?i(e):r(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{const t=s(Object(function(){var e=new Error("Cannot find module 'utf-8-validate'");throw e.code="MODULE_NOT_FOUND",e}()));e.exports.isValidUTF8=function(e){return e.length<32?i(e):t(e)}}catch(e){}},284:(e,t,s)=>{"use strict";const r=s(361),i=s(685),{createHash:o}=(s(687),s(808),s(404),s(113)),n=s(503),a=s(196),h=s(640),c=s(762),{GUID:l,kWebSocket:d}=s(872),f=/^[+/0-9A-Za-z]{22}==$/;function _(e){e._state=2,e.emit("close")}function u(){this.destroy()}function p(e,t,s,r){s=s||i.STATUS_CODES[t],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...r},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${i.STATUS_CODES[t]}\r\n`+Object.keys(r).map((e=>`${e}: ${r[e]}`)).join("\r\n")+"\r\n\r\n"+s)}function m(e,t,s,r,i){if(e.listenerCount("wsClientError")){const r=new Error(i);Error.captureStackTrace(r,m),e.emit("wsClientError",r,s,t)}else p(s,r,i)}e.exports=class extends r{constructor(e,t){if(super(),null==(e={maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:c,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=e.port?(this._server=i.createServer(((e,t)=>{const s=i.STATUS_CODES[426];t.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),t.end(s)})),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(const s of Object.keys(t))e.on(s,t[s]);return function(){for(const s of Object.keys(t))e.removeListener(s,t[s])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,s,r)=>{this.handleUpgrade(t,s,r,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state)return e&&this.once("close",(()=>{e(new Error("The server is not running"))})),void process.nextTick(_,this);if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(_,this);else{const e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close((()=>{_(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,s,r){t.on("error",u);const i=e.headers["sec-websocket-key"],o=+e.headers["sec-websocket-version"];if("GET"!==e.method){return void m(this,e,t,405,"Invalid HTTP method")}if("websocket"!==e.headers.upgrade.toLowerCase()){return void m(this,e,t,400,"Invalid Upgrade header")}if(!i||!f.test(i)){return void m(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header")}if(8!==o&&13!==o){return void m(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header")}if(!this.shouldHandle(e))return void p(t,400);const c=e.headers["sec-websocket-protocol"];let l=new Set;if(void 0!==c)try{l=h.parse(c)}catch(s){return void m(this,e,t,400,"Invalid Sec-WebSocket-Protocol header")}const d=e.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&void 0!==d){const s=new a(this.options.perMessageDeflate,!0,this.options.maxPayload);try{const e=n.parse(d);e[a.extensionName]&&(s.accept(e[a.extensionName]),_[a.extensionName]=s)}catch(s){return void m(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header")}}if(this.options.verifyClient){const n={origin:e.headers[""+(8===o?"sec-websocket-origin":"origin")],secure:!(!e.socket.authorized&&!e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(n,((o,n,a,h)=>{if(!o)return p(t,n||401,a,h);this.completeUpgrade(_,i,l,e,t,s,r)}));if(!this.options.verifyClient(n))return p(t,401)}this.completeUpgrade(_,i,l,e,t,s,r)}completeUpgrade(e,t,s,r,i,h,c){if(!i.readable||!i.writable)return i.destroy();if(i[d])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return p(i,503);const f=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${o("sha1").update(t+l).digest("base64")}`],m=new this.options.WebSocket(null);if(s.size){const e=this.options.handleProtocols?this.options.handleProtocols(s,r):s.values().next().value;e&&(f.push(`Sec-WebSocket-Protocol: ${e}`),m._protocol=e)}if(e[a.extensionName]){const t=e[a.extensionName].params,s=n.format({[a.extensionName]:[t]});f.push(`Sec-WebSocket-Extensions: ${s}`),m._extensions=e}this.emit("headers",f,r),i.write(f.concat("\r\n").join("\r\n")),i.removeListener("error",u),m.setSocket(i,h,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(m),m.on("close",(()=>{this.clients.delete(m),this._shouldEmitClose&&!this.clients.size&&process.nextTick(_,this)}))),c(m,r)}}},762:(e,t,s)=>{"use strict";const r=s(361),i=s(687),o=s(685),n=s(808),a=s(404),{randomBytes:h,createHash:c}=s(113),{Readable:l}=s(781),{URL:d}=s(310),f=s(196),_=s(957),u=s(330),{BINARY_TYPES:p,EMPTY_BUFFER:m,GUID:y,kForOnEventAttribute:g,kListener:b,kStatusCode:v,kWebSocket:S,NOOP:w}=s(872),{EventTarget:{addEventListener:k,removeEventListener:E}}=s(62),{format:x,parse:O}=s(503),{toBuffer:T}=s(977),C=Symbol("kAborted"),N=[8,13],L=["CONNECTING","OPEN","CLOSING","CLOSED"],P=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class U extends r{constructor(e,t,s){super(),this._binaryType=p[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=m,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=U.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==e?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===t?t=[]:Array.isArray(t)||("object"==typeof t&&null!==t?(s=t,t=[]):t=[t]),R(this,e,t,s)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){p.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,s){const r=new _({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation});this._sender=new u(e,this._extensions,s.generateMask),this._receiver=r,this._socket=e,r[S]=this,e[S]=this,r.on("conclude",A),r.on("drain",F),r.on("error",j),r.on("message",G),r.on("ping",V),r.on("pong",q),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",H),e.on("data",Y),e.on("end",X),e.on("error",K),this._readyState=U.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=U.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[f.extensionName]&&this._extensions[f.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=U.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==U.CLOSED)if(this.readyState!==U.CONNECTING)this.readyState!==U.CLOSING?(this._readyState=U.CLOSING,this._sender.close(e,t,!this._isServer,(e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())})),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),3e4)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();else{const e="WebSocket was closed before the connection was established";W(this,this._req,e)}}pause(){this.readyState!==U.CONNECTING&&this.readyState!==U.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,s){if(this.readyState===U.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===U.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||m,t,s)):D(this,e,s)}pong(e,t,s){if(this.readyState===U.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===U.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||m,t,s)):D(this,e,s)}resume(){this.readyState!==U.CONNECTING&&this.readyState!==U.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,s){if(this.readyState===U.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(s=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==U.OPEN)return void D(this,e,s);const r={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[f.extensionName]||(r.compress=!1),this._sender.send(e||m,r,s)}terminate(){if(this.readyState!==U.CLOSED)if(this.readyState!==U.CONNECTING)this._socket&&(this._readyState=U.CLOSING,this._socket.destroy());else{const e="WebSocket was closed before the connection was established";W(this,this._req,e)}}}function R(e,t,s,r){const n={protocolVersion:N[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(!N.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${N.join(", ")})`);let a;if(t instanceof d)a=t,e._url=t.href;else{try{a=new d(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}e._url=t}const l="wss:"===a.protocol,_="ws+unix:"===a.protocol;let u;if("ws:"===a.protocol||l||_?_&&!a.pathname?u="The URL's pathname is empty":a.hash&&(u="The URL contains a fragment identifier"):u='The URL\'s protocol must be one of "ws:", "wss:", or "ws+unix:"',u){const t=new SyntaxError(u);if(0===e._redirects)throw t;return void B(e,t)}const p=l?443:80,m=h(16).toString("base64"),g=l?i.request:o.request,b=new Set;let v,S;if(n.createConnection=l?M:I,n.defaultPort=n.defaultPort||p,n.port=a.port||p,n.host=a.hostname.startsWith("[")?a.hostname.slice(1,-1):a.hostname,n.headers={...n.headers,"Sec-WebSocket-Version":n.protocolVersion,"Sec-WebSocket-Key":m,Connection:"Upgrade",Upgrade:"websocket"},n.path=a.pathname+a.search,n.timeout=n.handshakeTimeout,n.perMessageDeflate&&(v=new f(!0!==n.perMessageDeflate?n.perMessageDeflate:{},!1,n.maxPayload),n.headers["Sec-WebSocket-Extensions"]=x({[f.extensionName]:v.offer()})),s.length){for(const e of s){if("string"!=typeof e||!P.test(e)||b.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");b.add(e)}n.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(n.origin&&(n.protocolVersion<13?n.headers["Sec-WebSocket-Origin"]=n.origin:n.headers.Origin=n.origin),(a.username||a.password)&&(n.auth=`${a.username}:${a.password}`),_){const e=n.path.split(":");n.socketPath=e[0],n.path=e[1]}if(n.followRedirects){if(0===e._redirects){e._originalIpc=_,e._originalSecure=l,e._originalHostOrSocketPath=_?n.socketPath:a.host;const t=r&&r.headers;if(r={...r,headers:{}},t)for(const[e,s]of Object.entries(t))r.headers[e.toLowerCase()]=s}else if(0===e.listenerCount("redirect")){const t=_?!!e._originalIpc&&n.socketPath===e._originalHostOrSocketPath:!e._originalIpc&&a.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!l)&&(delete n.headers.authorization,delete n.headers.cookie,t||delete n.headers.host,n.auth=void 0)}n.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(n.auth).toString("base64")),S=e._req=g(n),e._redirects&&e.emit("redirect",e.url,S)}else S=e._req=g(n);n.timeout&&S.on("timeout",(()=>{W(e,S,"Opening handshake has timed out")})),S.on("error",(t=>{null===S||S[C]||(S=e._req=null,B(e,t))})),S.on("response",(i=>{const o=i.headers.location,a=i.statusCode;if(o&&n.followRedirects&&a>=300&&a<400){if(++e._redirects>n.maxRedirects)return void W(e,S,"Maximum redirects exceeded");let i;S.abort();try{i=new d(o,t)}catch(t){const s=new SyntaxError(`Invalid URL: ${o}`);return void B(e,s)}R(e,i,s,r)}else e.emit("unexpected-response",S,i)||W(e,S,`Unexpected server response: ${i.statusCode}`)})),S.on("upgrade",((t,s,r)=>{if(e.emit("upgrade",t),e.readyState!==U.CONNECTING)return;if(S=e._req=null,"websocket"!==t.headers.upgrade.toLowerCase())return void W(e,s,"Invalid Upgrade header");const i=c("sha1").update(m+y).digest("base64");if(t.headers["sec-websocket-accept"]!==i)return void W(e,s,"Invalid Sec-WebSocket-Accept header");const o=t.headers["sec-websocket-protocol"];let a;if(void 0!==o?b.size?b.has(o)||(a="Server sent an invalid subprotocol"):a="Server sent a subprotocol but none was requested":b.size&&(a="Server sent no subprotocol"),a)return void W(e,s,a);o&&(e._protocol=o);const h=t.headers["sec-websocket-extensions"];if(void 0!==h){if(!v){return void W(e,s,"Server sent a Sec-WebSocket-Extensions header but no extension was requested")}let t;try{t=O(h)}catch(t){return void W(e,s,"Invalid Sec-WebSocket-Extensions header")}const r=Object.keys(t);if(1!==r.length||r[0]!==f.extensionName){return void W(e,s,"Server indicated an extension that was not requested")}try{v.accept(t[f.extensionName])}catch(t){return void W(e,s,"Invalid Sec-WebSocket-Extensions header")}e._extensions[f.extensionName]=v}e.setSocket(s,r,{generateMask:n.generateMask,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation})})),S.end()}function B(e,t){e._readyState=U.CLOSING,e.emit("error",t),e.emitClose()}function I(e){return e.path=e.socketPath,n.connect(e)}function M(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=n.isIP(e.host)?"":e.host),a.connect(e)}function W(e,t,s){e._readyState=U.CLOSING;const r=new Error(s);Error.captureStackTrace(r,W),t.setHeader?(t[C]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(B,e,r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function D(e,t,s){if(t){const s=T(t).length;e._socket?e._sender._bufferedBytes+=s:e._bufferedAmount+=s}if(s){const t=new Error(`WebSocket is not open: readyState ${e.readyState} (${L[e.readyState]})`);process.nextTick(s,t)}}function A(e,t){const s=this[S];s._closeFrameReceived=!0,s._closeMessage=t,s._closeCode=e,void 0!==s._socket[S]&&(s._socket.removeListener("data",Y),process.nextTick(z,s._socket),1005===e?s.close():s.close(e,t))}function F(){const e=this[S];e.isPaused||e._socket.resume()}function j(e){const t=this[S];void 0!==t._socket[S]&&(t._socket.removeListener("data",Y),process.nextTick(z,t._socket),t.close(e[v])),t.emit("error",e)}function $(){this[S].emitClose()}function G(e,t){this[S].emit("message",e,t)}function V(e){const t=this[S];t.pong(e,!t._isServer,w),t.emit("ping",e)}function q(e){this[S].emit("pong",e)}function z(e){e.resume()}function H(){const e=this[S];let t;this.removeListener("close",H),this.removeListener("data",Y),this.removeListener("end",X),e._readyState=U.CLOSING,this._readableState.endEmitted||e._closeFrameReceived||e._receiver._writableState.errorEmitted||null===(t=e._socket.read())||e._receiver.write(t),e._receiver.end(),this[S]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",$),e._receiver.on("finish",$))}function Y(e){this[S]._receiver.write(e)||this.pause()}function X(){const e=this[S];e._readyState=U.CLOSING,e._receiver.end(),this.end()}function K(){const e=this[S];this.removeListener("error",K),this.on("error",w),e&&(e._readyState=U.CLOSING,this.destroy())}Object.defineProperty(U,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")}),Object.defineProperty(U.prototype,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")}),Object.defineProperty(U,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")}),Object.defineProperty(U.prototype,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")}),Object.defineProperty(U,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")}),Object.defineProperty(U.prototype,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")}),Object.defineProperty(U,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")}),Object.defineProperty(U.prototype,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(U.prototype,e,{enumerable:!0})})),["open","error","close","message"].forEach((e=>{Object.defineProperty(U.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[g])return t[b];return null},set(t){for(const t of this.listeners(e))if(t[g]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[g]:!0})}})})),U.prototype.addEventListener=k,U.prototype.removeEventListener=E,e.exports=U},300:e=>{"use strict";e.exports=require("buffer")},113:e=>{"use strict";e.exports=require("crypto")},361:e=>{"use strict";e.exports=require("events")},685:e=>{"use strict";e.exports=require("http")},687:e=>{"use strict";e.exports=require("https")},808:e=>{"use strict";e.exports=require("net")},781:e=>{"use strict";e.exports=require("stream")},404:e=>{"use strict";e.exports=require("tls")},310:e=>{"use strict";e.exports=require("url")},796:e=>{"use strict";e.exports=require("zlib")}},t={};function s(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,s),o.exports}var r={};(()=>{var e=r,t=s(777);e.Server=t.Server,e.on=t.on,e.close=t.close,e.ping=t.ping})();var i=exports;for(var o in r)i[o]=r[o];r.__esModule&&Object.defineProperty(i,"__esModule",{value:!0})})();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Rindo Client Patch Esm v3.2.
|
|
2
|
+
Rindo Client Patch Esm v3.2.4 | MIT Licensed | https://rindojs.web.app
|
|
3
3
|
*/
|
|
4
4
|
var __assign=undefined&&undefined.__assign||function(){return __assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},__assign.apply(this,arguments)},StyleNode=function(){this.start=0,this.end=0,this.previous=null,this.parent=null,this.rules=null,this.parsedCssText="",this.cssText="",this.atRule=!1,this.type=0,this.keyframesName="",this.selector="",this.parsedSelector="";};function parse(e){return parseCss(lex(e=clean(e)),e)}function clean(e){return e.replace(RX.comments,"").replace(RX.port,"")}function lex(e){var t=new StyleNode;t.start=0,t.end=e.length;for(var r=t,n=0,s=e.length;n<s;n++)if(e[n]===OPEN_BRACE){r.rules||(r.rules=[]);var o=r,a=o.rules[o.rules.length-1]||null;(r=new StyleNode).start=n+1,r.parent=o,r.previous=a,o.rules.push(r);}else e[n]===CLOSE_BRACE&&(r.end=n+1,r=r.parent||t);return t}function parseCss(e,t){var r=t.substring(e.start,e.end-1);if(e.parsedCssText=e.cssText=r.trim(),e.parent){var n=e.previous?e.previous.end:e.parent.start;r=(r=(r=_expandUnicodeEscapes(r=t.substring(n,e.start-1))).replace(RX.multipleSpaces," ")).substring(r.lastIndexOf(";")+1);var s=e.parsedSelector=e.selector=r.trim();e.atRule=0===s.indexOf(AT_START),e.atRule?0===s.indexOf(MEDIA_START)?e.type=types.MEDIA_RULE:s.match(RX.keyframesRule)&&(e.type=types.KEYFRAMES_RULE,e.keyframesName=e.selector.split(RX.multipleSpaces).pop()):0===s.indexOf(VAR_START)?e.type=types.MIXIN_RULE:e.type=types.STYLE_RULE;}var o=e.rules;if(o)for(var a=0,i=o.length,l=void 0;a<i&&(l=o[a]);a++)parseCss(l,t);return e}function _expandUnicodeEscapes(e){return e.replace(/\\([0-9a-f]{1,6})\s/gi,(function(){for(var e=arguments[1],t=6-e.length;t--;)e="0"+e;return "\\"+e}))}var types={STYLE_RULE:1,KEYFRAMES_RULE:7,MEDIA_RULE:4,MIXIN_RULE:1e3},OPEN_BRACE="{",CLOSE_BRACE="}",RX={comments:/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,port:/@import[^;]*;/gim,customProp:/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?(?:[;\n]|$)/gim,mixinProp:/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?{[^}]*?}(?:[;\n]|$)?/gim,mixinApply:/@apply\s*\(?[^);]*\)?\s*(?:[;\n]|$)?/gim,varApply:/[^;:]*?:[^;]*?var\([^;]*\)(?:[;\n]|$)?/gim,keyframesRule:/^@[^\s]*keyframes/,multipleSpaces:/\s+/g},VAR_START="--",MEDIA_START="@media",AT_START="@",VAR_USAGE_START=/\bvar\(/,VAR_ASSIGN_START=/\B--[\w-]+\s*:/,COMMENTS=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,TRAILING_LINES=/^[\t ]+\n/gm;function findRegex(e,t,r){e.lastIndex=0;var n=t.substring(r).match(e);if(n){var s=r+n.index;return {start:s,end:s+n[0].length}}return null}function resolveVar(e,t,r){return e[t]?e[t]:r?executeTemplate(r,e):""}function findVarEndIndex(e,t){for(var r=0,n=t;n<e.length;n++){var s=e[n];if("("===s)r++;else if(")"===s&&--r<=0)return n+1}return n}function parseVar(e,t){var r=findRegex(VAR_USAGE_START,e,t);if(!r)return null;var n=findVarEndIndex(e,r.start),s=e.substring(r.end,n-1).split(","),o=s[0],a=s.slice(1);return {start:r.start,end:n,propName:o.trim(),fallback:a.length>0?a.join(",").trim():void 0}}function compileVar(e,t,r){var n=parseVar(e,r);if(!n)return t.push(e.substring(r,e.length)),e.length;var s=n.propName,o=null!=n.fallback?compileTemplate(n.fallback):void 0;return t.push(e.substring(r,n.start),(function(e){return resolveVar(e,s,o)})),n.end}function executeTemplate(e,t){for(var r="",n=0;n<e.length;n++){var s=e[n];r+="string"==typeof s?s:s(t);}return r}function findEndValue(e,t){for(var r=!1,n=!1,s=t;s<e.length;s++){var o=e[s];if(r)n&&'"'===o&&(r=!1),n||"'"!==o||(r=!1);else if('"'===o)r=!0,n=!0;else if("'"===o)r=!0,n=!1;else {if(";"===o)return s+1;if("}"===o)return s}}return s}function removeCustomAssigns(e){for(var t="",r=0;;){var n=findRegex(VAR_ASSIGN_START,e,r),s=n?n.start:e.length;if(t+=e.substring(r,s),!n)break;r=findEndValue(e,s);}return t}function compileTemplate(e){var t=0;e=removeCustomAssigns(e=e.replace(COMMENTS,"")).replace(TRAILING_LINES,"");for(var r=[];t<e.length;)t=compileVar(e,r,t);return r}function resolveValues(e){var t={};e.forEach((function(e){e.declarations.forEach((function(e){t[e.prop]=e.value;}));}));for(var r={},n=Object.entries(t),s=function(e){var t=!1;if(n.forEach((function(e){var n=e[0],s=executeTemplate(e[1],r);s!==r[n]&&(r[n]=s,t=!0);})),!t)return "break"},o=0;o<10;o++){if("break"===s())break}return r}function getSelectors(e,t){if(void 0===t&&(t=0),!e.rules)return [];var r=[];return e.rules.filter((function(e){return e.type===types.STYLE_RULE})).forEach((function(e){var n=getDeclarations(e.cssText);n.length>0&&e.parsedSelector.split(",").forEach((function(e){e=e.trim(),r.push({selector:e,declarations:n,specificity:computeSpecificity(),nu:t});})),t++;})),r}function computeSpecificity(e){return 1}var IMPORTANT="!important",FIND_DECLARATIONS=/(?:^|[;\s{]\s*)(--[\w-]*?)\s*:\s*(?:((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};{])+)|\{([^}]*)\}(?:(?=[;\s}])|$))/gm;function getDeclarations(e){for(var t,r=[];t=FIND_DECLARATIONS.exec(e.trim());){var n=normalizeValue(t[2]),s=n.value,o=n.important;r.push({prop:t[1].trim(),value:compileTemplate(s),important:o});}return r}function normalizeValue(e){var t=(e=e.replace(/\s+/gim," ").trim()).endsWith(IMPORTANT);return t&&(e=e.slice(0,e.length-IMPORTANT.length).trim()),{value:e,important:t}}function getActiveSelectors(e,t,r){var n=[],s=getScopesForElement(t,e);return r.forEach((function(e){return n.push(e)})),s.forEach((function(e){return n.push(e)})),sortSelectors(getSelectorsForScopes(n).filter((function(t){return matches(e,t.selector)})))}function getScopesForElement(e,t){for(var r=[];t;){var n=e.get(t);n&&r.push(n),t=t.parentElement;}return r}function getSelectorsForScopes(e){var t=[];return e.forEach((function(e){t.push.apply(t,e.selectors);})),t}function sortSelectors(e){return e.sort((function(e,t){return e.specificity===t.specificity?e.nu-t.nu:e.specificity-t.specificity})),e}function matches(e,t){return ":root"===t||"html"===t||e.matches(t)}function parseCSS(e){var t=parse(e),r=compileTemplate(e);return {original:e,template:r,selectors:getSelectors(t),usesCssVars:r.length>1}}function addGlobalStyle(e,t){if(e.some((function(e){return e.styleEl===t})))return !1;var r=parseCSS(t.textContent);return r.styleEl=t,e.push(r),!0}function updateGlobalScopes(e){var t=resolveValues(getSelectorsForScopes(e));e.forEach((function(e){e.usesCssVars&&(e.styleEl.textContent=executeTemplate(e.template,t));}));}function reScope(e,t){var r=e.template.map((function(r){return "string"==typeof r?replaceScope(r,e.scopeId,t):r})),n=e.selectors.map((function(r){return __assign(__assign({},r),{selector:replaceScope(r.selector,e.scopeId,t)})}));return __assign(__assign({},e),{template:r,selectors:n,scopeId:t})}function replaceScope(e,t,r){return e=replaceAll(e,"\\.".concat(t),".".concat(r))}function replaceAll(e,t,r){return e.replace(new RegExp(t,"g"),r)}function loadDocument(e,t){return loadDocumentStyles(e,t),loadDocumentLinks(e,t).then((function(){updateGlobalScopes(t);}))}function startWatcher(e,t){"undefined"!=typeof MutationObserver&&new MutationObserver((function(){loadDocumentStyles(e,t)&&updateGlobalScopes(t);})).observe(document.head,{childList:!0});}function loadDocumentLinks(e,t){for(var r=[],n=e.querySelectorAll('link[rel="stylesheet"][href]:not([data-no-shim])'),s=0;s<n.length;s++)r.push(addGlobalLink(e,t,n[s]));return Promise.all(r)}function loadDocumentStyles(e,t){return Array.from(e.querySelectorAll("style:not([data-styles]):not([data-no-shim])")).map((function(e){return addGlobalStyle(t,e)})).some(Boolean)}function addGlobalLink(e,t,r){var n=r.href;return fetch(n).then((function(e){return e.text()})).then((function(s){if(hasCssVariables(s)&&r.parentNode){hasRelativeUrls(s)&&(s=fixRelativeUrls(s,n));var o=e.createElement("style");o.setAttribute("data-styles",""),o.textContent=s,addGlobalStyle(t,o),r.parentNode.insertBefore(o,r),r.remove();}})).catch((function(e){console.error(e);}))}var CSS_VARIABLE_REGEXP=/[\s;{]--[-a-zA-Z0-9]+\s*:/m;function hasCssVariables(e){return e.indexOf("var(")>-1||CSS_VARIABLE_REGEXP.test(e)}var CSS_URL_REGEXP=/url[\s]*\([\s]*['"]?(?!(?:https?|data)\:|\/)([^\'\"\)]*)[\s]*['"]?\)[\s]*/gim;function hasRelativeUrls(e){return CSS_URL_REGEXP.lastIndex=0,CSS_URL_REGEXP.test(e)}function fixRelativeUrls(e,t){var r=t.replace(/[^/]*$/,"");return e.replace(CSS_URL_REGEXP,(function(e,t){var n=r+t;return e.replace(t,n)}))}var CustomStyle=function(){function e(e,t){this.win=e,this.doc=t,this.count=0,this.hostStyleMap=new WeakMap,this.hostScopeMap=new WeakMap,this.globalScopes=[],this.scopesMap=new Map,this.didInit=!1;}return e.prototype.i=function(){var e=this;return this.didInit||!this.win.requestAnimationFrame?Promise.resolve():(this.didInit=!0,new Promise((function(t){e.win.requestAnimationFrame((function(){startWatcher(e.doc,e.globalScopes),loadDocument(e.doc,e.globalScopes).then((function(){return t()}));}));})))},e.prototype.addLink=function(e){var t=this;return addGlobalLink(this.doc,this.globalScopes,e).then((function(){t.updateGlobal();}))},e.prototype.addGlobalStyle=function(e){addGlobalStyle(this.globalScopes,e)&&this.updateGlobal();},e.prototype.createHostStyle=function(e,t,r,n){if(this.hostScopeMap.has(e))throw new Error("host style already created");var s=this.registerHostTemplate(r,t,n),o=this.doc.createElement("style");return o.setAttribute("data-no-shim",""),s.usesCssVars?n?(o["s-sc"]=t="".concat(s.scopeId,"-").concat(this.count),o.textContent="/*needs update*/",this.hostStyleMap.set(e,o),this.hostScopeMap.set(e,reScope(s,t)),this.count++):(s.styleEl=o,s.usesCssVars||(o.textContent=executeTemplate(s.template,{})),this.globalScopes.push(s),this.updateGlobal(),this.hostScopeMap.set(e,s)):o.textContent=r,o},e.prototype.removeHost=function(e){var t=this.hostStyleMap.get(e);t&&t.remove(),this.hostStyleMap.delete(e),this.hostScopeMap.delete(e);},e.prototype.updateHost=function(e){var t=this.hostScopeMap.get(e);if(t&&t.usesCssVars&&t.isScoped){var r=this.hostStyleMap.get(e);if(r){var n=resolveValues(getActiveSelectors(e,this.hostScopeMap,this.globalScopes));r.textContent=executeTemplate(t.template,n);}}},e.prototype.updateGlobal=function(){updateGlobalScopes(this.globalScopes);},e.prototype.registerHostTemplate=function(e,t,r){var n=this.scopesMap.get(t);return n||((n=parseCSS(e)).scopeId=t,n.isScoped=r,this.scopesMap.set(t,n)),n},e}();!function(e){!e||e.__cssshim||e.CSS&&e.CSS.supports&&e.CSS.supports("color","var(--c)")||(e.__cssshim=new CustomStyle(e,e.document));}("undefined"!=typeof window&&window);
|
package/internal/client/dom.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Rindo Client Patch Browser v3.2.
|
|
2
|
+
Rindo Client Patch Browser v3.2.4 | MIT Licensed | https://rindojs.web.app
|
|
3
3
|
*/
|
|
4
4
|
(function(){
|
|
5
5
|
var aa=new Set("annotation-xml color-profile font-face font-face-src font-face-uri font-face-format font-face-name missing-glyph".split(" "));function g(a){var b=aa.has(a);a=/^[a-z][.0-9_a-z]*-[\-.0-9_a-z]*$/.test(a);return !b&&a}function l(a){var b=a.isConnected;if(void 0!==b)return b;for(;a&&!(a.__CE_isImportDocument||a instanceof Document);)a=a.parentNode||(window.ShadowRoot&&a instanceof ShadowRoot?a.host:void 0);return !(!a||!(a.__CE_isImportDocument||a instanceof Document))}
|
package/internal/client/index.js
CHANGED
|
@@ -19,7 +19,7 @@ let renderingRef = null;
|
|
|
19
19
|
let queueCongestion = 0;
|
|
20
20
|
let queuePending = false;
|
|
21
21
|
/*
|
|
22
|
-
Rindo Client Platform v3.2.
|
|
22
|
+
Rindo Client Platform v3.2.4 | MIT Licensed | https://rindojs.web.app
|
|
23
23
|
*/
|
|
24
24
|
import { BUILD, NAMESPACE } from '@rindo/core/internal/app-data';
|
|
25
25
|
const Build = {
|
|
@@ -1106,30 +1106,31 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
|
|
|
1106
1106
|
* @param vnodes a list of virtual DOM nodes to remove
|
|
1107
1107
|
* @param startIdx the index at which to start removing nodes (inclusive)
|
|
1108
1108
|
* @param endIdx the index at which to stop removing nodes (inclusive)
|
|
1109
|
-
* @param vnode a VNode
|
|
1110
|
-
* @param elm an element
|
|
1111
1109
|
*/
|
|
1112
|
-
const removeVnodes = (vnodes, startIdx, endIdx
|
|
1113
|
-
for (
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
elm['s-ol']
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1110
|
+
const removeVnodes = (vnodes, startIdx, endIdx) => {
|
|
1111
|
+
for (let index = startIdx; index <= endIdx; ++index) {
|
|
1112
|
+
const vnode = vnodes[index];
|
|
1113
|
+
if (vnode) {
|
|
1114
|
+
const elm = vnode.$elm$;
|
|
1115
|
+
nullifyVNodeRefs(vnode);
|
|
1116
|
+
if (elm) {
|
|
1117
|
+
if (BUILD.slotRelocation) {
|
|
1118
|
+
// we're removing this element
|
|
1119
|
+
// so it's possible we need to show slot fallback content now
|
|
1120
|
+
checkSlotFallbackVisibility = true;
|
|
1121
|
+
if (elm['s-ol']) {
|
|
1122
|
+
// remove the original location comment
|
|
1123
|
+
elm['s-ol'].remove();
|
|
1124
|
+
}
|
|
1125
|
+
else {
|
|
1126
|
+
// it's possible that child nodes of the node
|
|
1127
|
+
// that's being removed are slot nodes
|
|
1128
|
+
putBackInOriginalLocation(elm, true);
|
|
1129
|
+
}
|
|
1129
1130
|
}
|
|
1131
|
+
// remove the vnode's element from the dom
|
|
1132
|
+
elm.remove();
|
|
1130
1133
|
}
|
|
1131
|
-
// remove the vnode's element from the dom
|
|
1132
|
-
elm.remove();
|
|
1133
1134
|
}
|
|
1134
1135
|
}
|
|
1135
1136
|
};
|
|
@@ -1614,10 +1615,17 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
|
1614
1615
|
}
|
|
1615
1616
|
return slotNameAttr === '';
|
|
1616
1617
|
};
|
|
1617
|
-
|
|
1618
|
+
/**
|
|
1619
|
+
* 'Nullify' any VDom `ref` callbacks on a VDom node or its children by
|
|
1620
|
+
* calling them with `null`. This signals that the DOM element corresponding to
|
|
1621
|
+
* the VDom node has been removed from the DOM.
|
|
1622
|
+
*
|
|
1623
|
+
* @param vNode a virtual DOM node
|
|
1624
|
+
*/
|
|
1625
|
+
const nullifyVNodeRefs = (vNode) => {
|
|
1618
1626
|
if (BUILD.vdomRef) {
|
|
1619
1627
|
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
|
1620
|
-
vNode.$children$ && vNode.$children$.map(
|
|
1628
|
+
vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
|
|
1621
1629
|
}
|
|
1622
1630
|
};
|
|
1623
1631
|
/**
|
|
@@ -1778,11 +1786,33 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
|
1778
1786
|
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
|
1779
1787
|
return BUILD.taskQueue ? writeTask(dispatch) : dispatch();
|
|
1780
1788
|
};
|
|
1789
|
+
/**
|
|
1790
|
+
* Dispatch initial-render and update lifecycle hooks, enqueuing calls to
|
|
1791
|
+
* component lifecycle methods like `componentWillLoad` as well as
|
|
1792
|
+
* {@link updateComponent}, which will kick off the virtual DOM re-render.
|
|
1793
|
+
*
|
|
1794
|
+
* @param hostRef a reference to a host DOM node
|
|
1795
|
+
* @param isInitialLoad whether we're on the initial load or not
|
|
1796
|
+
* @returns an empty Promise which is used to enqueue a series of operations for
|
|
1797
|
+
* the component
|
|
1798
|
+
*/
|
|
1781
1799
|
const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
1782
1800
|
const elm = hostRef.$hostElement$;
|
|
1783
1801
|
const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
|
|
1784
1802
|
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
1785
|
-
|
|
1803
|
+
// We're going to use this variable together with `enqueue` to implement a
|
|
1804
|
+
// little promise-based queue. We start out with it `undefined`. When we add
|
|
1805
|
+
// the first function to the queue we'll set this variable to be that
|
|
1806
|
+
// function's return value. When we attempt to add subsequent values to the
|
|
1807
|
+
// queue we'll check that value and, if it was a `Promise`, we'll then chain
|
|
1808
|
+
// the new function off of that `Promise` using `.then()`. This will give our
|
|
1809
|
+
// queue two nice properties:
|
|
1810
|
+
//
|
|
1811
|
+
// 1. If all functions added to the queue are synchronous they'll be called
|
|
1812
|
+
// synchronously right away.
|
|
1813
|
+
// 2. If all functions added to the queue are asynchronous they'll all be
|
|
1814
|
+
// called in order after `dispatchHooks` exits.
|
|
1815
|
+
let maybePromise;
|
|
1786
1816
|
if (isInitialLoad) {
|
|
1787
1817
|
if (BUILD.lazyLoad && BUILD.hostListener) {
|
|
1788
1818
|
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
@@ -1793,24 +1823,50 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
1793
1823
|
}
|
|
1794
1824
|
emitLifecycleEvent(elm, 'componentWillLoad');
|
|
1795
1825
|
if (BUILD.cmpWillLoad) {
|
|
1796
|
-
|
|
1826
|
+
// If `componentWillLoad` returns a `Promise` then we want to wait on
|
|
1827
|
+
// whatever's going on in that `Promise` before we launch into
|
|
1828
|
+
// rendering the component, doing other lifecycle stuff, etc. So
|
|
1829
|
+
// in that case we assign the returned promise to the variable we
|
|
1830
|
+
// declared above to hold a possible 'queueing' Promise
|
|
1831
|
+
maybePromise = safeCall(instance, 'componentWillLoad');
|
|
1797
1832
|
}
|
|
1798
1833
|
}
|
|
1799
1834
|
else {
|
|
1800
1835
|
emitLifecycleEvent(elm, 'componentWillUpdate');
|
|
1801
1836
|
if (BUILD.cmpWillUpdate) {
|
|
1802
|
-
|
|
1837
|
+
// Like `componentWillLoad` above, we allow Rindo component
|
|
1838
|
+
// authors to return a `Promise` from this lifecycle callback, and
|
|
1839
|
+
// we specify that our runtime will wait for that `Promise` to
|
|
1840
|
+
// resolve before the component re-renders. So if the method
|
|
1841
|
+
// returns a `Promise` we need to keep it around!
|
|
1842
|
+
maybePromise = safeCall(instance, 'componentWillUpdate');
|
|
1803
1843
|
}
|
|
1804
1844
|
}
|
|
1805
1845
|
emitLifecycleEvent(elm, 'componentWillRender');
|
|
1806
1846
|
if (BUILD.cmpWillRender) {
|
|
1807
|
-
|
|
1847
|
+
maybePromise = enqueue(maybePromise, () => safeCall(instance, 'componentWillRender'));
|
|
1808
1848
|
}
|
|
1809
1849
|
endSchedule();
|
|
1810
|
-
return
|
|
1850
|
+
return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
1811
1851
|
};
|
|
1852
|
+
/**
|
|
1853
|
+
* This function uses a Promise to implement a simple first-in, first-out queue
|
|
1854
|
+
* of functions to be called.
|
|
1855
|
+
*
|
|
1856
|
+
* The queue is ordered on the basis of the first argument. If it's
|
|
1857
|
+
* `undefined`, then nothing is on the queue yet, so the provided function can
|
|
1858
|
+
* be called synchronously (although note that this function may return a
|
|
1859
|
+
* `Promise`). The idea is that then the return value of that enqueueing
|
|
1860
|
+
* operation is kept around, so that if it was a `Promise` then subsequent
|
|
1861
|
+
* functions can be enqueued by calling this function again with that `Promise`
|
|
1862
|
+
* as the first argument.
|
|
1863
|
+
*
|
|
1864
|
+
* @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
|
|
1865
|
+
* @param fn a function to enqueue
|
|
1866
|
+
* @returns either a `Promise` or the return value of the provided function
|
|
1867
|
+
*/
|
|
1868
|
+
const enqueue = (maybePromise, fn) => maybePromise instanceof Promise ? maybePromise.then(fn) : fn();
|
|
1812
1869
|
const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
1813
|
-
// updateComponent
|
|
1814
1870
|
const elm = hostRef.$hostElement$;
|
|
1815
1871
|
const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
|
|
1816
1872
|
const rc = elm['s-rc'];
|
|
@@ -2038,9 +2094,6 @@ const safeCall = (instance, method, arg) => {
|
|
|
2038
2094
|
}
|
|
2039
2095
|
return undefined;
|
|
2040
2096
|
};
|
|
2041
|
-
const then = (promise, thenFn) => {
|
|
2042
|
-
return promise && promise.then ? promise.then(thenFn) : thenFn();
|
|
2043
|
-
};
|
|
2044
2097
|
const emitLifecycleEvent = (elm, lifecycleName) => {
|
|
2045
2098
|
if (BUILD.lifecycleDOMEvents) {
|
|
2046
2099
|
emitEvent(elm, 'rindo_' + lifecycleName, {
|
|
@@ -2261,11 +2314,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
2261
2314
|
};
|
|
2262
2315
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
2263
2316
|
// initializeComponent
|
|
2264
|
-
if ((
|
|
2265
|
-
|
|
2317
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
2318
|
+
// Let the runtime know that the component has been initialized
|
|
2319
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
2266
2320
|
if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
|
|
2267
|
-
// we haven't initialized this element yet
|
|
2268
|
-
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
2269
2321
|
// lazy loaded components
|
|
2270
2322
|
// request the component's implementation to be
|
|
2271
2323
|
// wired up with the host element
|
|
@@ -2318,7 +2370,6 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
2318
2370
|
else {
|
|
2319
2371
|
// sync constructor component
|
|
2320
2372
|
Cstr = elm.constructor;
|
|
2321
|
-
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
2322
2373
|
// wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
|
|
2323
2374
|
// watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
|
|
2324
2375
|
// Rindo has completed instantiating the component.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rindo/core/internal/client",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.4",
|
|
4
4
|
"description": "Rindo internal client platform to be imported by the Rindo Compiler and internal runtime. Breaking changes can and will happen at any time.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"private": true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Rindo Client Patch Browser v3.2.
|
|
2
|
+
Rindo Client Patch Browser v3.2.4 | MIT Licensed | https://rindojs.web.app
|
|
3
3
|
*/
|
|
4
4
|
import { BUILD, NAMESPACE } from '@rindo/core/internal/app-data';
|
|
5
5
|
import { consoleDevInfo, plt, win, doc, promiseResolve, H } from '@rindo/core';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Rindo Client Patch Esm v3.2.
|
|
2
|
+
Rindo Client Patch Esm v3.2.4 | MIT Licensed | https://rindojs.web.app
|
|
3
3
|
*/
|
|
4
4
|
import { BUILD } from '@rindo/core/internal/app-data';
|
|
5
5
|
import { CSS, plt, win, promiseResolve } from '@rindo/core';
|