docker-setup-qemu/dist/index.js

26 lines
1.8 MiB
JavaScript
Raw Normal View History

require('./sourcemap-register.js');(()=>{var __webpack_modules__={7799:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){if(i===undefined)i=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,i,s)}:function(e,t,r,i){if(i===undefined)i=r;e[i]=t[r]});var s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(r!=="default"&&Object.prototype.hasOwnProperty.call(e,r))i(t,e,r);s(t,e);return t};var n=this&&this.__awaiter||function(e,t,r,i){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,s){function fulfilled(e){try{step(i.next(e))}catch(e){s(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){s(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:true});t.saveCache=t.restoreCache=t.isFeatureAvailable=t.ReserveCacheError=t.ValidationError=void 0;const o=a(r(2186));const c=a(r(1017));const p=a(r(1518));const l=a(r(8245));const A=r(6490);class ValidationError extends Error{constructor(e){super(e);this.name="ValidationError";Object.setPrototypeOf(this,ValidationError.prototype)}}t.ValidationError=ValidationError;class ReserveCacheError extends Error{constructor(e){super(e);this.name="ReserveCacheError";Object.setPrototypeOf(this,ReserveCacheError.prototype)}}t.ReserveCacheError=ReserveCacheError;function checkPaths(e){if(!e||e.length===0){throw new ValidationError(`Path Validation Error: At least one directory or file path is required`)}}function checkKey(e){if(e.length>512){throw new ValidationError(`Key Validation Error: ${e} cannot be larger than 512 characters.`)}const t=/^[^,]*$/;if(!t.test(e)){throw new ValidationError(`Key Validation Error: ${e} cannot contain commas.`)}}function isFeatureAvailable(){return!!process.env["ACTIONS_CACHE_URL"]}t.isFeatureAvailable=isFeatureAvailable;function restoreCache(e,t,r,i,s=false){return n(this,void 0,void 0,(function*(){checkPaths(e);r=r||[];const a=[t,...r];o.debug("Resolved Keys:");o.debug(JSON.stringify(a));if(a.length>10){throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`)}for(const e of a){checkKey(e)}const n=yield p.getCompressionMethod();let d="";try{const t=yield l.getCacheEntry(a,e,{compressionMethod:n,enableCrossOsArchive:s});if(!(t===null||t===void 0?void 0:t.archiveLocation)){return undefined}if(i===null||i===void 0?void 0:i.lookupOnly){o.info("Lookup only - skipping download");return t.cacheKey}d=c.join(yield p.createTempDirectory(),p.getCacheFileName(n));o.debug(`Archive Path: ${d}`);yield l.downloadCache(t.archiveLocation,d,i);if(o.isDebug()){yield(0,A.listTar)(d,n)}const r=p.getArchiveFileSizeInBytes(d);o.info(`Cache Size: ~${Math.round(r/(1024*1024))} MB (${r} B)`);yield(0,A.extractTar)(d,n);o.info("Cache restored successfully");return t.cacheKey}catch(e){const t=e;if(t.name===ValidationError.name){throw e}else{o.warning(`Failed to restore: ${e.message}`)}}finally{try{yield p.unlinkFile(d)}catch(e){o.debug(`Failed to delete archive: ${e}`)}}return undefined}))}t.restoreCache=restoreCache;function saveCache(e,t,r,i=false){var s,a,d,u,m;return n(this,void 0,void 0,(function*(){checkPaths(e);checkKey(t);const n=yield p.getCompressionMethod();let g=-1;const h=yield p.resolvePaths(e);o.debug("Cache Paths:");o.debug(`${JSON.stringify(h)}`);if(h.length===0){throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`)}const E=yield p.createTempDirectory();const C=c.join(E,p.getCacheFileName(n));o.debug(`Archive Path: ${C}`);try{yield(0,A.createTar)(E,h,n);if(o.isDebug()){yield(0,A.listTar)(C,n)}const c=10*1024*1024*1024;cons
/*!
* mime-db
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015-2022 Douglas Christopher Wilson
* MIT Licensed
*/
e.exports=r(3765)},3583:(e,t,r)=>{"use strict";
/*!
* mime-types
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/var i=r(7426);var s=r(1017).extname;var a=/^\s*([^;\s]*)(?:;|\s|$)/;var n=/^text\//i;t.charset=charset;t.charsets={lookup:charset};t.contentType=contentType;t.extension=extension;t.extensions=Object.create(null);t.lookup=lookup;t.types=Object.create(null);populateMaps(t.extensions,t.types);function charset(e){if(!e||typeof e!=="string"){return false}var t=a.exec(e);var r=t&&i[t[1].toLowerCase()];if(r&&r.charset){return r.charset}if(t&&n.test(t[1])){return"UTF-8"}return false}function contentType(e){if(!e||typeof e!=="string"){return false}var r=e.indexOf("/")===-1?t.lookup(e):e;if(!r){return false}if(r.indexOf("charset")===-1){var i=t.charset(r);if(i)r+="; charset="+i.toLowerCase()}return r}function extension(e){if(!e||typeof e!=="string"){return false}var r=a.exec(e);var i=r&&t.extensions[r[1].toLowerCase()];if(!i||!i.length){return false}return i[0]}function lookup(e){if(!e||typeof e!=="string"){return false}var r=s("x."+e).toLowerCase().substr(1);if(!r){return false}return t.types[r]||false}function populateMaps(e,t){var r=["nginx","apache",undefined,"iana"];Object.keys(i).forEach((function forEachMimeType(s){var a=i[s];var n=a.extensions;if(!n||!n.length){return}e[s]=n;for(var o=0;o<n.length;o++){var c=n[o];if(t[c]){var p=r.indexOf(i[t[c]].source);var l=r.indexOf(a.source);if(t[c]!=="application/octet-stream"&&(p>l||p===l&&t[c].substr(0,12)==="application/")){continue}}t[c]=s}}))}},3973:(e,t,r)=>{e.exports=minimatch;minimatch.Minimatch=Minimatch;var i=function(){try{return r(1017)}catch(e){}}()||{sep:"/"};minimatch.sep=i.sep;var s=minimatch.GLOBSTAR=Minimatch.GLOBSTAR={};var a=r(3717);var n={"!":{open:"(?:(?!(?:",close:"))[^/]*?)"},"?":{open:"(?:",close:")?"},"+":{open:"(?:",close:")+"},"*":{open:"(?:",close:")*"},"@":{open:"(?:",close:")"}};var o="[^/]";var c=o+"*?";var p="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";var l="(?:(?!(?:\\/|^)\\.).)*?";var A=charSet("().*{}+?[]^$\\!");function charSet(e){return e.split("").reduce((function(e,t){e[t]=true;return e}),{})}var d=/\/+/;minimatch.filter=filter;function filter(e,t){t=t||{};return function(r,i,s){return minimatch(r,e,t)}}function ext(e,t){t=t||{};var r={};Object.keys(e).forEach((function(t){r[t]=e[t]}));Object.keys(t).forEach((function(e){r[e]=t[e]}));return r}minimatch.defaults=function(e){if(!e||typeof e!=="object"||!Object.keys(e).length){return minimatch}var t=minimatch;var r=function minimatch(r,i,s){return t(r,i,ext(e,s))};r.Minimatch=function Minimatch(r,i){return new t.Minimatch(r,ext(e,i))};r.Minimatch.defaults=function defaults(r){return t.defaults(ext(e,r)).Minimatch};r.filter=function filter(r,i){return t.filter(r,ext(e,i))};r.defaults=function defaults(r){return t.defaults(ext(e,r))};r.makeRe=function makeRe(r,i){return t.makeRe(r,ext(e,i))};r.braceExpand=function braceExpand(r,i){return t.braceExpand(r,ext(e,i))};r.match=function(r,i,s){return t.match(r,i,ext(e,s))};return r};Minimatch.defaults=function(e){return minimatch.defaults(e).Minimatch};function minimatch(e,t,r){assertValidPattern(t);if(!r)r={};if(!r.nocomment&&t.charAt(0)==="#"){return false}return new Minimatch(t,r).match(e)}function Minimatch(e,t){if(!(this instanceof Minimatch)){return new Minimatch(e,t)}assertValidPattern(e);if(!t)t={};e=e.trim();if(!t.allowWindowsEscape&&i.sep!=="/"){e=e.split(i.sep).join("/")}this.options=t;this.set=[];this.pattern=e;this.regexp=null;this.negate=false;this.comment=false;this.empty=false;this.partial=!!t.partial;this.make()}Minimatch.prototype.debug=function(){};Minimatch.prototype.make=make;function make(){var e=this.pattern;var t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=true;return}if(!e){this.empty=true;return}this.parseNegate();var r=this.globSet=this.braceExpand();if(t.debug)this.debug=function debug(){console.error.apply(console,arguments)};this.debug(this.pattern,r);r=this.globParts=r.map((function(e){return e.split(d)}));this.debug(this.pattern,r);r=r.map((function(e,t,r){return e.map(this.parse,this)}),this);this.debug(this.pattern,r);r=r.filter((function(e){return e.indexOf(false)===-1}));this.debug(this.pattern,r);thi
/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */if(!String.fromCodePoint){(function(){var e=String.fromCharCode;var t=Math.floor;var fromCodePoint=function(){var r=16384;var i=[];var s;var a;var n=-1;var o=arguments.length;if(!o){return""}var c="";while(++n<o){var p=Number(arguments[n]);if(!isFinite(p)||p<0||p>1114111||t(p)!==p){throw RangeError("Invalid code point: "+p)}if(p<=65535){i.push(p)}else{p-=65536;s=(p>>10)+55296;a=p%1024+56320;i.push(s,a)}if(n+1===o||i.length>r){c+=e.apply(null,i);i.length=0}}return c};if(Object.defineProperty){Object.defineProperty(String,"fromCodePoint",{value:fromCodePoint,configurable:true,writable:true})}else{String.fromCodePoint=fromCodePoint}})()}})(false?0:t)},8517:(e,t,r)=>{
/*!
* Tmp
*
* Copyright (c) 2011-2017 KARASZI Istvan <github@spam.raszi.hu>
*
* MIT Licensed
*/
const i=r(7147);const s=r(2037);const a=r(1017);const n=r(6113);const o={fs:i.constants,os:s.constants};const c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",p=/XXXXXX/,l=3,A=(o.O_CREAT||o.fs.O_CREAT)|(o.O_EXCL||o.fs.O_EXCL)|(o.O_RDWR||o.fs.O_RDWR),d=s.platform()==="win32",u=o.EBADF||o.os.errno.EBADF,m=o.ENOENT||o.os.errno.ENOENT,g=448,h=384,E="exit",C=[],y=i.rmdirSync.bind(i);let I=false;function rimraf(e,t){return i.rm(e,{recursive:true},t)}function FN_RIMRAF_SYNC(e){return i.rmSync(e,{recursive:true})}function tmpName(e,t){const r=_parseArguments(e,t),s=r[0],a=r[1];try{_assertAndSanitizeOptions(s)}catch(e){return a(e)}let n=s.tries;(function _getUniqueName(){try{const e=_generateTmpName(s);i.stat(e,(function(t){if(!t){if(n-- >0)return _getUniqueName();return a(new Error("Could not get a unique tmp filename, max tries reached "+e))}a(null,e)}))}catch(e){a(e)}})()}function tmpNameSync(e){const t=_parseArguments(e),r=t[0];_assertAndSanitizeOptions(r);let s=r.tries;do{const e=_generateTmpName(r);try{i.statSync(e)}catch(t){return e}}while(s-- >0);throw new Error("Could not get a unique tmp filename, max tries reached")}function file(e,t){const r=_parseArguments(e,t),s=r[0],a=r[1];tmpName(s,(function _tmpNameCreated(e,t){if(e)return a(e);i.open(t,A,s.mode||h,(function _fileCreated(e,r){if(e)return a(e);if(s.discardDescriptor){return i.close(r,(function _discardCallback(e){return a(e,t,undefined,_prepareTmpFileRemoveCallback(t,-1,s,false))}))}else{const e=s.discardDescriptor||s.detachDescriptor;a(null,t,r,_prepareTmpFileRemoveCallback(t,e?-1:r,s,false))}}))}))}function fileSync(e){const t=_parseArguments(e),r=t[0];const s=r.discardDescriptor||r.detachDescriptor;const a=tmpNameSync(r);var n=i.openSync(a,A,r.mode||h);if(r.discardDescriptor){i.closeSync(n);n=undefined}return{name:a,fd:n,removeCallback:_prepareTmpFileRemoveCallback(a,s?-1:n,r,true)}}function dir(e,t){const r=_parseArguments(e,t),s=r[0],a=r[1];tmpName(s,(function _tmpNameCreated(e,t){if(e)return a(e);i.mkdir(t,s.mode||g,(function _dirCreated(e){if(e)return a(e);a(null,t,_prepareTmpDirRemoveCallback(t,s,false))}))}))}function dirSync(e){const t=_parseArguments(e),r=t[0];const s=tmpNameSync(r);i.mkdirSync(s,r.mode||g);return{name:s,removeCallback:_prepareTmpDirRemoveCallback(s,r,true)}}function _removeFileAsync(e,t){const _handler=function(e){if(e&&!_isENOENT(e)){return t(e)}t()};if(0<=e[0])i.close(e[0],(function(){i.unlink(e[1],_handler)}));else i.unlink(e[1],_handler)}function _removeFileSync(e){let t=null;try{if(0<=e[0])i.closeSync(e[0])}catch(e){if(!_isEBADF(e)&&!_isENOENT(e))throw e}finally{try{i.unlinkSync(e[1])}catch(e){if(!_isENOENT(e))t=e}}if(t!==null){throw t}}function _prepareTmpFileRemoveCallback(e,t,r,i){const s=_prepareRemoveCallback(_removeFileSync,[t,e],i);const a=_prepareRemoveCallback(_removeFileAsync,[t,e],i,s);if(!r.keep)C.unshift(s);return i?s:a}function _prepareTmpDirRemoveCallback(e,t,r){const s=t.unsafeCleanup?rimraf:i.rmdir.bind(i);const a=t.unsafeCleanup?FN_RIMRAF_SYNC:y;const n=_prepareRemoveCallback(a,e,r);const o=_prepareRemoveCallback(s,e,r,n);if(!t.keep)C.unshift(n);return r?n:o}function _prepareRemoveCallback(e,t,r,i){let s=false;return function _cleanupCallback(a){if(!s){const n=i||_cleanupCallback;const o=C.indexOf(n);if(o>=0)C.splice(o,1);s=true;if(r||e===y||e===FN_RIMRAF_SYNC){return e(t)}else{return e(t,a||function(){})}}}}function _garbageCollector(){if(!I)return;while(C.length){try{C[0]()}catch(e){}}}function _randomChars(e){let t=[],r=null;try{r=n.randomBytes(e)}catch(t){r=n.pseudoRandomBytes(e)}for(var i=0;i<e;i++){t.push(c[r[i]%c.length])}return t.join("")}function _isBlank(e){return e===null||_isUndefined(e)||!e.trim()}function _isUndefined(e){return typeof e==="undefined"}function _parseArguments(e,t){if(typeof e==="function"){return[{},e]}if(_isUndefined(e)){return[{},t]}const r={};for(const t of Object.getOwnPropertyNames(e)){r[t]=e[t]}return[r,t]}function _generateTmpName(e){const t=e.tmpdir;if(!_isUndefined(e.name))return a.join(t,e.dir,e.name);if(!_isUndefined(e.template))return a.join(t,e.dir,e.t
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */;const escape=e=>e.replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22");const normalizeLinefeeds=e=>e.replace(/\r?\n|\r/g,"\r\n");const i=[];const s=new Uint8Array([13,10]);A=0;let a=false;for(const[t,n]of e){if(typeof n==="string"){const e=N.encode(r+`; name="${escape(normalizeLinefeeds(t))}"`+`\r\n\r\n${normalizeLinefeeds(n)}\r\n`);i.push(e);A+=e.byteLength}else{const e=N.encode(`${r}; name="${escape(normalizeLinefeeds(t))}"`+(n.name?`; filename="${escape(n.name)}"`:"")+"\r\n"+`Content-Type: ${n.type||"application/octet-stream"}\r\n\r\n`);i.push(e,n,s);if(typeof n.size==="number"){A+=e.byteLength+n.size+s.byteLength}else{a=true}}}const n=N.encode(`--${t}--`);i.push(n);A+=n.byteLength;if(a){A=null}l=e;p=async function*(){for(const e of i){if(e.stream){yield*e.stream()}else{yield e}}};d="multipart/form-data; boundary="+t}else if(n(e)){l=e;A=e.size;if(e.type){d=e.type}}else if(typeof e[Symbol.asyncIterator]==="function"){if(t){throw new TypeError("keepalive")}if(s.isDisturbed(e)||e.locked){throw new TypeError("Response body object should not be disturbed or locked")}i=e instanceof S?e:a(e)}if(typeof l==="string"||s.isBuffer(l)){A=Buffer.byteLength(l)}if(p!=null){let t;i=new S({async start(){t=p(e)[Symbol.asyncIterator]()},async pull(e){const{value:r,done:s}=await t.next();if(s){queueMicrotask((()=>{e.close()}))}else{if(!I(i)){e.enqueue(new Uint8Array(r))}}return e.desiredSize>0},async cancel(e){await t.return()},type:undefined})}const u={stream:i,source:l,length:A};return[u,d]}function safelyExtractBody(e,t=false){if(!S){S=r(5356).ReadableStream}if(e instanceof S){y(!s.isDisturbed(e),"The body has already been consumed.");y(!e.locked,"The stream is locked.")}return extractBody(e,t)}function cloneBody(e){const[t,r]=e.stream.tee();const i=g(r,{transfer:[r]});const[,s]=i.tee();e.stream=t;return{stream:s,length:e.length,source:e.source}}async function*consumeBody(e){if(e){if(B(e)){yield e}else{const t=e.stream;if(s.isDisturbed(t)){throw new TypeError("The body has already been consumed.")}if(t.locked){throw new TypeError("The stream is locked.")}t[C]=true;yield*t}}}function throwIfAborted(e){if(e.aborted){throw new m("The operation was aborted.","AbortError")}}function bodyMixinMethods(e){const t={blob(){return specConsumeBody(this,(e=>{let t=bodyMimeType(this);if(t==="failure"){t=""}else if(t){t=w(t)}return new h([e],{type:t})}),e)},arrayBuffer(){return specConsumeBody(this,(e=>new Uint8Array(e).buffer),e)},text(){return specConsumeBody(this,utf8DecodeBytes,e)},json(){return specConsumeBody(this,parseJSONFromBytes,e)},async formData(){u.brandCheck(this,e);throwIfAborted(this[d]);const t=this.headers.get("Content-Type");if(/multipart\/form-data/.test(t)){const e={};for(const[t,r]of this.headers)e[t.toLowerCase()]=r;const t=new A;let r;try{r=new i({headers:e,preservePath:true})}catch(e){throw new m(`${e}`,"AbortError")}r.on("field",((e,r)=>{t.append(e,r)}));r.on("file",((e,r,i,s,a)=>{const n=[];if(s==="base64"||s.toLowerCase()==="base64"){let s="";r.on("data",(e=>{s+=e.toString().replace(/[\r\n]/gm,"");const t=s.length-s.length%4;n.push(Buffer.from(s.slice(0,t),"base64"));s=s.slice(t)}));r.on("end",(()=>{n.push(Buffer.from(s,"base64"));t.append(e,new x(n,i,{type:a}))}))}else{r.on("data",(e=>{n.push(e)}));r.on("end",(()=>{t.append(e,new x(n,i,{type:a}))}))}}));const s=new Promise(((e,t)=>{r.on("finish",e);r.on("error",(e=>t(new TypeError(e))))}));if(this.body!==null)for await(const e of consumeBody(this[d].body))r.write(e);r.end();await s;return t}else if(/application\/x-www-form-urlencoded/.test(t)){let e;try{let t="";const r=new TextDecoder("utf-8",{ignoreBOM:true});for await(const e of consumeBody(this[d].body)){if(!B(e)){throw new TypeError("Expected Uint8Array chunk")}t+=r.decode(e,{stream:true})}t+=r.decode();e=new URLSearchParams(t)}catch(e){throw Object.assign(new TypeError,{cause:e})}const t=new A;for(const[r,i]of e){t.append(r,i)}return t}else{await Promise.resolve();throwIfAborted(this[d]);throw u.errors.exception({he
/*! ws. MIT License. Einar Otto Stangvik <einaros@gmail.com> */a[s-4]=this.maskKey[0];a[s-3]=this.maskKey[1];a[s-2]=this.maskKey[2];a[s-1]=this.maskKey[3];a[1]=r;if(r===126){a.writeUInt16BE(t,2)}else if(r===127){a[2]=a[3]=0;a.writeUIntBE(t,4,6)}a[1]|=128;for(let e=0;e<t;e++){a[s+e]=this.frameData[e]^this.maskKey[e%4]}return a}}e.exports={WebsocketFrameSend:WebsocketFrameSend}},1688:(e,t,r)=>{"use strict";const{Writable:i}=r(2781);const s=r(7643);const{parserStates:a,opcodes:n,states:o,emptyBuffer:c}=r(9188);const{kReadyState:p,kSentClose:l,kResponse:A,kReceivedClose:d}=r(7578);const{isValidStatusCode:u,failWebsocketConnection:m,websocketMessageReceived:g}=r(5515);const{WebsocketFrameSend:h}=r(5444);const E={};E.ping=s.channel("undici:websocket:ping");E.pong=s.channel("undici:websocket:pong");class ByteParser extends i{#n=[];#o=0;#c=a.INFO;#p={};#l=[];constructor(e){super();this.ws=e}_write(e,t,r){this.#n.push(e);this.#o+=e.length;this.run(r)}run(e){while(true){if(this.#c===a.INFO){if(this.#o<2){return e()}const t=this.consume(2);this.#p.fin=(t[0]&128)!==0;this.#p.opcode=t[0]&15;this.#p.originalOpcode??=this.#p.opcode;this.#p.fragmented=!this.#p.fin&&this.#p.opcode!==n.CONTINUATION;if(this.#p.fragmented&&this.#p.opcode!==n.BINARY&&this.#p.opcode!==n.TEXT){m(this.ws,"Invalid frame type was fragmented.");return}const r=t[1]&127;if(r<=125){this.#p.payloadLength=r;this.#c=a.READ_DATA}else if(r===126){this.#c=a.PAYLOADLENGTH_16}else if(r===127){this.#c=a.PAYLOADLENGTH_64}if(this.#p.fragmented&&r>125){m(this.ws,"Fragmented frame exceeded 125 bytes.");return}else if((this.#p.opcode===n.PING||this.#p.opcode===n.PONG||this.#p.opcode===n.CLOSE)&&r>125){m(this.ws,"Payload length for control frame exceeded 125 bytes.");return}else if(this.#p.opcode===n.CLOSE){if(r===1){m(this.ws,"Received close frame with a 1-byte body.");return}const e=this.consume(r);this.#p.closeInfo=this.parseCloseBody(false,e);if(!this.ws[l]){const e=Buffer.allocUnsafe(2);e.writeUInt16BE(this.#p.closeInfo.code,0);const t=new h(e);this.ws[A].socket.write(t.createFrame(n.CLOSE),(e=>{if(!e){this.ws[l]=true}}))}this.ws[p]=o.CLOSING;this.ws[d]=true;this.end();return}else if(this.#p.opcode===n.PING){const t=this.consume(r);if(!this.ws[d]){const e=new h(t);this.ws[A].socket.write(e.createFrame(n.PONG));if(E.ping.hasSubscribers){E.ping.publish({payload:t})}}this.#c=a.INFO;if(this.#o>0){continue}else{e();return}}else if(this.#p.opcode===n.PONG){const t=this.consume(r);if(E.pong.hasSubscribers){E.pong.publish({payload:t})}if(this.#o>0){continue}else{e();return}}}else if(this.#c===a.PAYLOADLENGTH_16){if(this.#o<2){return e()}const t=this.consume(2);this.#p.payloadLength=t.readUInt16BE(0);this.#c=a.READ_DATA}else if(this.#c===a.PAYLOADLENGTH_64){if(this.#o<8){return e()}const t=this.consume(8);const r=t.readUInt32BE(0);if(r>2**31-1){m(this.ws,"Received payload length > 2^31 bytes.");return}const i=t.readUInt32BE(4);this.#p.payloadLength=(r<<8)+i;this.#c=a.READ_DATA}else if(this.#c===a.READ_DATA){if(this.#o<this.#p.payloadLength){return e()}else if(this.#o>=this.#p.payloadLength){const e=this.consume(this.#p.payloadLength);this.#l.push(e);if(!this.#p.fragmented||this.#p.fin&&this.#p.opcode===n.CONTINUATION){const e=Buffer.concat(this.#l);g(this.ws,this.#p.originalOpcode,e);this.#p={};this.#l.length=0}this.#c=a.INFO}}if(this.#o>0){continue}else{e();break}}}consume(e){if(e>this.#o){return null}else if(e===0){return c}if(this.#n[0].length===e){this.#o-=this.#n[0].length;return this.#n.shift()}const t=Buffer.allocUnsafe(e);let r=0;while(r!==e){const i=this.#n[0];const{length:s}=i;if(s+r===e){t.set(this.#n.shift(),r);break}else if(s+r>e){t.set(i.subarray(0,e-r),r);this.#n[0]=i.subarray(e-r);break}else{t.set(this.#n.shift(),r);r+=i.length}}this.#o-=e;return t}parseCloseBody(e,t){let r;if(t.length>=2){r=t.readUInt16BE(0)}if(e){if(!u(r)){return null}return{code:r}}let i=t.subarray(2);if(i[0]===239&&i[1]===187&&i[2]===191){i=i.subarray(3)}if(r!==undefined&&!u(r)){return null}try{i=new TextDecoder("utf-8",{fatal:true}).decode(i)}catch{return null}return{code:r,reason:i}}get closingIn
//# sourceMappingURL=index.js.map