@rsbuild/core 0.5.1 → 0.5.2

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.
@@ -1 +1 @@
1
- (()=>{var e={434:(e,t,o)=>{const r=o(147);const n=o(17);const s=o(37);const c=o(113);const a=o(684);const i=a.version;const u=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function parse(e){const t={};let o=e.toString();o=o.replace(/\r\n?/gm,"\n");let r;while((r=u.exec(o))!=null){const e=r[1];let o=r[2]||"";o=o.trim();const n=o[0];o=o.replace(/^(['"`])([\s\S]*)\1$/gm,"$2");if(n==='"'){o=o.replace(/\\n/g,"\n");o=o.replace(/\\r/g,"\r")}t[e]=o}return t}function _parseVault(e){const t=_vaultPath(e);const o=l.configDotenv({path:t});if(!o.parsed){const e=new Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);e.code="MISSING_DATA";throw e}const r=_dotenvKey(e).split(",");const n=r.length;let s;for(let e=0;e<n;e++){try{const t=r[e].trim();const n=_instructions(o,t);s=l.decrypt(n.ciphertext,n.key);break}catch(t){if(e+1>=n){throw t}}}return l.parse(s)}function _log(e){console.log(`[dotenv@${i}][INFO] ${e}`)}function _warn(e){console.log(`[dotenv@${i}][WARN] ${e}`)}function _debug(e){console.log(`[dotenv@${i}][DEBUG] ${e}`)}function _dotenvKey(e){if(e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0){return e.DOTENV_KEY}if(process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0){return process.env.DOTENV_KEY}return""}function _instructions(e,t){let o;try{o=new URL(t)}catch(e){if(e.code==="ERR_INVALID_URL"){const e=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");e.code="INVALID_DOTENV_KEY";throw e}throw e}const r=o.password;if(!r){const e=new Error("INVALID_DOTENV_KEY: Missing key part");e.code="INVALID_DOTENV_KEY";throw e}const n=o.searchParams.get("environment");if(!n){const e=new Error("INVALID_DOTENV_KEY: Missing environment part");e.code="INVALID_DOTENV_KEY";throw e}const s=`DOTENV_VAULT_${n.toUpperCase()}`;const c=e.parsed[s];if(!c){const e=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${s} in your .env.vault file.`);e.code="NOT_FOUND_DOTENV_ENVIRONMENT";throw e}return{ciphertext:c,key:r}}function _vaultPath(e){let t=null;if(e&&e.path&&e.path.length>0){if(Array.isArray(e.path)){for(const o of e.path){if(r.existsSync(o)){t=o.endsWith(".vault")?o:`${o}.vault`}}}else{t=e.path.endsWith(".vault")?e.path:`${e.path}.vault`}}else{t=n.resolve(process.cwd(),".env.vault")}if(r.existsSync(t)){return t}return null}function _resolveHome(e){return e[0]==="~"?n.join(s.homedir(),e.slice(1)):e}function _configVault(e){_log("Loading env from encrypted .env.vault");const t=l._parseVault(e);let o=process.env;if(e&&e.processEnv!=null){o=e.processEnv}l.populate(o,t,e);return{parsed:t}}function configDotenv(e){const t=n.resolve(process.cwd(),".env");let o="utf8";const s=Boolean(e&&e.debug);if(e&&e.encoding){o=e.encoding}else{if(s){_debug("No encoding is specified. UTF-8 is used by default")}}let c=[];if(e&&e.path){if(!Array.isArray(e.path)){if(r.existsSync(e.path)){c=[_resolveHome(e.path)]}}else{for(const t of e.path){if(r.existsSync(t)){c.push(_resolveHome(t))}}}if(!c.length){c=[t]}}const a=c.length?c:[t];const i={};try{for(const t of a){const n=l.parse(r.readFileSync(t,{encoding:o}));l.populate(i,n,e)}let t=process.env;if(e&&e.processEnv!=null){t=e.processEnv}l.populate(t,i,e)}catch(e){if(s){_debug(`Failed to load ${a} ${e.message}`)}return{error:e}}return{parsed:i}}function config(e){if(_dotenvKey(e).length===0){return l.configDotenv(e)}const t=_vaultPath(e);if(!t){_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`);return l.configDotenv(e)}return l._configVault(e)}function decrypt(e,t){const o=Buffer.from(t.slice(-64),"hex");let r=Buffer.from(e,"base64");const n=r.subarray(0,12);const s=r.subarray(-16);r=r.subarray(12,-16);try{const e=c.createDecipheriv("aes-256-gcm",o,n);e.setAuthTag(s);return`${e.update(r)}${e.final()}`}catch(e){const t=e instanceof RangeError;const o=e.message==="Invalid key length";const r=e.message==="Unsupported state or unable to authenticate data";if(t||o){const e=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");e.code="INVALID_DOTENV_KEY";throw e}else if(r){const e=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");e.code="DECRYPTION_FAILED";throw e}else{throw e}}}function populate(e,t,o={}){const r=Boolean(o&&o.debug);const n=Boolean(o&&o.override);if(typeof t!=="object"){const e=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");e.code="OBJECT_REQUIRED";throw e}for(const o of Object.keys(t)){if(Object.prototype.hasOwnProperty.call(e,o)){if(n===true){e[o]=t[o]}if(r){if(n===true){_debug(`"${o}" is already defined and WAS overwritten`)}else{_debug(`"${o}" is already defined and was NOT overwritten`)}}}else{e[o]=t[o]}}}const l={configDotenv:configDotenv,_configVault:_configVault,_parseVault:_parseVault,config:config,decrypt:decrypt,parse:parse,populate:populate};e.exports.configDotenv=l.configDotenv;e.exports._configVault=l._configVault;e.exports._parseVault=l._parseVault;e.exports.config=l.config;e.exports.decrypt=l.decrypt;e.exports.parse=l.parse;e.exports.populate=l.populate;e.exports=l},684:e=>{"use strict";e.exports=require("./package.json")},113:e=>{"use strict";e.exports=require("crypto")},147:e=>{"use strict";e.exports=require("fs")},37:e=>{"use strict";e.exports=require("os")},17:e=>{"use strict";e.exports=require("path")}};var t={};function __nccwpck_require__(o){var r=t[o];if(r!==undefined){return r.exports}var n=t[o]={exports:{}};var s=true;try{e[o](n,n.exports,__nccwpck_require__);s=false}finally{if(s)delete t[o]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var o=__nccwpck_require__(434);module.exports=o})();
1
+ (()=>{var e={396:(e,t,r)=>{const o=r(147);const n=r(17);const s=r(37);const c=r(113);const a=r(684);const i=a.version;const u=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function parse(e){const t={};let r=e.toString();r=r.replace(/\r\n?/gm,"\n");let o;while((o=u.exec(r))!=null){const e=o[1];let r=o[2]||"";r=r.trim();const n=r[0];r=r.replace(/^(['"`])([\s\S]*)\1$/gm,"$2");if(n==='"'){r=r.replace(/\\n/g,"\n");r=r.replace(/\\r/g,"\r")}t[e]=r}return t}function _parseVault(e){const t=_vaultPath(e);const r=l.configDotenv({path:t});if(!r.parsed){const e=new Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);e.code="MISSING_DATA";throw e}const o=_dotenvKey(e).split(",");const n=o.length;let s;for(let e=0;e<n;e++){try{const t=o[e].trim();const n=_instructions(r,t);s=l.decrypt(n.ciphertext,n.key);break}catch(t){if(e+1>=n){throw t}}}return l.parse(s)}function _log(e){console.log(`[dotenv@${i}][INFO] ${e}`)}function _warn(e){console.log(`[dotenv@${i}][WARN] ${e}`)}function _debug(e){console.log(`[dotenv@${i}][DEBUG] ${e}`)}function _dotenvKey(e){if(e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0){return e.DOTENV_KEY}if(process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0){return process.env.DOTENV_KEY}return""}function _instructions(e,t){let r;try{r=new URL(t)}catch(e){if(e.code==="ERR_INVALID_URL"){const e=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");e.code="INVALID_DOTENV_KEY";throw e}throw e}const o=r.password;if(!o){const e=new Error("INVALID_DOTENV_KEY: Missing key part");e.code="INVALID_DOTENV_KEY";throw e}const n=r.searchParams.get("environment");if(!n){const e=new Error("INVALID_DOTENV_KEY: Missing environment part");e.code="INVALID_DOTENV_KEY";throw e}const s=`DOTENV_VAULT_${n.toUpperCase()}`;const c=e.parsed[s];if(!c){const e=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${s} in your .env.vault file.`);e.code="NOT_FOUND_DOTENV_ENVIRONMENT";throw e}return{ciphertext:c,key:o}}function _vaultPath(e){let t=null;if(e&&e.path&&e.path.length>0){if(Array.isArray(e.path)){for(const r of e.path){if(o.existsSync(r)){t=r.endsWith(".vault")?r:`${r}.vault`}}}else{t=e.path.endsWith(".vault")?e.path:`${e.path}.vault`}}else{t=n.resolve(process.cwd(),".env.vault")}if(o.existsSync(t)){return t}return null}function _resolveHome(e){return e[0]==="~"?n.join(s.homedir(),e.slice(1)):e}function _configVault(e){_log("Loading env from encrypted .env.vault");const t=l._parseVault(e);let r=process.env;if(e&&e.processEnv!=null){r=e.processEnv}l.populate(r,t,e);return{parsed:t}}function configDotenv(e){const t=n.resolve(process.cwd(),".env");let r="utf8";const s=Boolean(e&&e.debug);if(e&&e.encoding){r=e.encoding}else{if(s){_debug("No encoding is specified. UTF-8 is used by default")}}let c=[t];if(e&&e.path){if(!Array.isArray(e.path)){c=[_resolveHome(e.path)]}else{c=[];for(const t of e.path){c.push(_resolveHome(t))}}}let a;const i={};for(const t of c){try{const n=l.parse(o.readFileSync(t,{encoding:r}));l.populate(i,n,e)}catch(e){if(s){_debug(`Failed to load ${t} ${e.message}`)}a=e}}let u=process.env;if(e&&e.processEnv!=null){u=e.processEnv}l.populate(u,i,e);if(a){return{parsed:i,error:a}}else{return{parsed:i}}}function config(e){if(_dotenvKey(e).length===0){return l.configDotenv(e)}const t=_vaultPath(e);if(!t){_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`);return l.configDotenv(e)}return l._configVault(e)}function decrypt(e,t){const r=Buffer.from(t.slice(-64),"hex");let o=Buffer.from(e,"base64");const n=o.subarray(0,12);const s=o.subarray(-16);o=o.subarray(12,-16);try{const e=c.createDecipheriv("aes-256-gcm",r,n);e.setAuthTag(s);return`${e.update(o)}${e.final()}`}catch(e){const t=e instanceof RangeError;const r=e.message==="Invalid key length";const o=e.message==="Unsupported state or unable to authenticate data";if(t||r){const e=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");e.code="INVALID_DOTENV_KEY";throw e}else if(o){const e=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");e.code="DECRYPTION_FAILED";throw e}else{throw e}}}function populate(e,t,r={}){const o=Boolean(r&&r.debug);const n=Boolean(r&&r.override);if(typeof t!=="object"){const e=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");e.code="OBJECT_REQUIRED";throw e}for(const r of Object.keys(t)){if(Object.prototype.hasOwnProperty.call(e,r)){if(n===true){e[r]=t[r]}if(o){if(n===true){_debug(`"${r}" is already defined and WAS overwritten`)}else{_debug(`"${r}" is already defined and was NOT overwritten`)}}}else{e[r]=t[r]}}}const l={configDotenv:configDotenv,_configVault:_configVault,_parseVault:_parseVault,config:config,decrypt:decrypt,parse:parse,populate:populate};e.exports.configDotenv=l.configDotenv;e.exports._configVault=l._configVault;e.exports._parseVault=l._parseVault;e.exports.config=l.config;e.exports.decrypt=l.decrypt;e.exports.parse=l.parse;e.exports.populate=l.populate;e.exports=l},684:e=>{"use strict";e.exports=require("./package.json")},113:e=>{"use strict";e.exports=require("crypto")},147:e=>{"use strict";e.exports=require("fs")},37:e=>{"use strict";e.exports=require("os")},17:e=>{"use strict";e.exports=require("path")}};var t={};function __nccwpck_require__(r){var o=t[r];if(o!==undefined){return o.exports}var n=t[r]={exports:{}};var s=true;try{e[r](n,n.exports,__nccwpck_require__);s=false}finally{if(s)delete t[r]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r=__nccwpck_require__(396);module.exports=r})();
@@ -1 +1 @@
1
- {"name":"dotenv","version":"16.4.4","funding":"https://dotenvx.com","license":"BSD-2-Clause","types":"lib/main.d.ts","type":"commonjs"}
1
+ {"name":"dotenv","version":"16.4.5","funding":"https://dotenvx.com","license":"BSD-2-Clause","types":"lib/main.d.ts","type":"commonjs"}
@@ -1 +1 @@
1
- (()=>{var e={104:e=>{"use strict";e.exports=(e,r,t)=>{const define=t=>Object.defineProperty(e,r,{value:t,enumerable:true,writable:true});Object.defineProperty(e,r,{configurable:true,enumerable:true,get(){const e=t();define(e);return e},set(e){define(e)}});return e}},669:(e,r,t)=>{"use strict";const o=t(147);let n;function hasDockerEnv(){try{o.statSync("/.dockerenv");return true}catch(e){return false}}function hasDockerCGroup(){try{return o.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch(e){return false}}e.exports=()=>{if(n===undefined){n=hasDockerEnv()||hasDockerCGroup()}return n}},729:(e,r,t)=>{"use strict";const o=t(37);const n=t(147);const s=t(669);const isWsl=()=>{if(process.platform!=="linux"){return false}if(o.release().toLowerCase().includes("microsoft")){if(s()){return false}return true}try{return n.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!s():false}catch(e){return false}};if(process.env.__IS_WSL_TEST__){e.exports=isWsl}else{e.exports=isWsl()}},331:(e,r,t)=>{const o=t(17);const n=t(81);const{promises:s,constants:i}=t(147);const a=t(729);const c=t(669);const u=t(104);const f=t.ab+"xdg-open";const{platform:p,arch:l}=process;const d=(()=>{const e="/mnt/";let r;return async function(){if(r){return r}const t="/etc/wsl.conf";let o=false;try{await s.access(t,i.F_OK);o=true}catch{}if(!o){return e}const n=await s.readFile(t,{encoding:"utf8"});const a=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(n);if(!a){return e}r=a.groups.mountPoint.trim();r=r.endsWith("/")?r:`${r}/`;return r}})();const pTryEach=async(e,r)=>{let t;for(const o of e){try{return await r(o)}catch(e){t=e}}throw t};const baseOpen=async e=>{e={wait:false,background:false,newInstance:false,allowNonzeroExitCode:false,...e};if(Array.isArray(e.app)){return pTryEach(e.app,(r=>baseOpen({...e,app:r})))}let{name:r,arguments:o=[]}=e.app||{};o=[...o];if(Array.isArray(r)){return pTryEach(r,(r=>baseOpen({...e,app:{name:r,arguments:o}})))}let u;const l=[];const m={};if(p==="darwin"){u="open";if(e.wait){l.push("--wait-apps")}if(e.background){l.push("--background")}if(e.newInstance){l.push("--new")}if(r){l.push("-a",r)}}else if(p==="win32"||a&&!c()){const t=await d();u=a?`${t}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`:`${process.env.SYSTEMROOT}\\System32\\WindowsPowerShell\\v1.0\\powershell`;l.push("-NoProfile","-NonInteractive","–ExecutionPolicy","Bypass","-EncodedCommand");if(!a){m.windowsVerbatimArguments=true}const n=["Start"];if(e.wait){n.push("-Wait")}if(r){n.push(`"\`"${r}\`""`,"-ArgumentList");if(e.target){o.unshift(e.target)}}else if(e.target){n.push(`"${e.target}"`)}if(o.length>0){o=o.map((e=>`"\`"${e}\`""`));n.push(o.join(","))}e.target=Buffer.from(n.join(" "),"utf16le").toString("base64")}else{if(r){u=r}else{const e=!__dirname||__dirname==="/";let r=false;try{await s.access(t.ab+"xdg-open",i.X_OK);r=true}catch{}const o=process.versions.electron||p==="android"||e||!r;u=o?"xdg-open":f}if(o.length>0){l.push(...o)}if(!e.wait){m.stdio="ignore";m.detached=true}}if(e.target){l.push(e.target)}if(p==="darwin"&&o.length>0){l.push("--args",...o)}const w=n.spawn(u,l,m);if(e.wait){return new Promise(((r,t)=>{w.once("error",t);w.once("close",(o=>{if(e.allowNonzeroExitCode&&o>0){t(new Error(`Exited with code ${o}`));return}r(w)}))}))}w.unref();return w};const open=(e,r)=>{if(typeof e!=="string"){throw new TypeError("Expected a `target`")}return baseOpen({...r,target:e})};const openApp=(e,r)=>{if(typeof e!=="string"){throw new TypeError("Expected a `name`")}const{arguments:t=[]}=r||{};if(t!==undefined&&t!==null&&!Array.isArray(t)){throw new TypeError("Expected `appArguments` as Array type")}return baseOpen({...r,app:{name:e,arguments:t}})};function detectArchBinary(e){if(typeof e==="string"||Array.isArray(e)){return e}const{[l]:r}=e;if(!r){throw new Error(`${l} is not supported`)}return r}function detectPlatformBinary({[p]:e},{wsl:r}){if(r&&a){return detectArchBinary(r)}if(!e){throw new Error(`${p} is not supported`)}return detectArchBinary(e)}const m={};u(m,"chrome",(()=>detectPlatformBinary({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}})));u(m,"firefox",(()=>detectPlatformBinary({darwin:"firefox",win32:"C:\\Program Files\\Mozilla Firefox\\firefox.exe",linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"})));u(m,"edge",(()=>detectPlatformBinary({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"})));open.apps=m;open.openApp=openApp;e.exports=open},81:e=>{"use strict";e.exports=require("child_process")},147:e=>{"use strict";e.exports=require("fs")},37:e=>{"use strict";e.exports=require("os")},17:e=>{"use strict";e.exports=require("path")}};var r={};function __nccwpck_require__(t){var o=r[t];if(o!==undefined){return o.exports}var n=r[t]={exports:{}};var s=true;try{e[t](n,n.exports,__nccwpck_require__);s=false}finally{if(s)delete r[t]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(331);module.exports=t})();
1
+ (()=>{var e={104:e=>{"use strict";e.exports=(e,r,t)=>{const define=t=>Object.defineProperty(e,r,{value:t,enumerable:true,writable:true});Object.defineProperty(e,r,{configurable:true,enumerable:true,get(){const e=t();define(e);return e},set(e){define(e)}});return e}},669:(e,r,t)=>{"use strict";const n=t(147);let o;function hasDockerEnv(){try{n.statSync("/.dockerenv");return true}catch(e){return false}}function hasDockerCGroup(){try{return n.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch(e){return false}}e.exports=()=>{if(o===undefined){o=hasDockerEnv()||hasDockerCGroup()}return o}},729:(e,r,t)=>{"use strict";const n=t(37);const o=t(147);const s=t(669);const isWsl=()=>{if(process.platform!=="linux"){return false}if(n.release().toLowerCase().includes("microsoft")){if(s()){return false}return true}try{return o.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!s():false}catch(e){return false}};if(process.env.__IS_WSL_TEST__){e.exports=isWsl}else{e.exports=isWsl()}},913:(e,r,t)=>{const n=t(17);const o=t(81);const{promises:s,constants:i}=t(147);const a=t(729);const c=t(669);const u=t(104);const f=t.ab+"xdg-open";const{platform:l,arch:p}=process;const hasContainerEnv=()=>{try{s.statSync("/run/.containerenv");return true}catch{return false}};let d;function isInsideContainer(){if(d===undefined){d=hasContainerEnv()||c()}return d}const m=(()=>{const e="/mnt/";let r;return async function(){if(r){return r}const t="/etc/wsl.conf";let n=false;try{await s.access(t,i.F_OK);n=true}catch{}if(!n){return e}const o=await s.readFile(t,{encoding:"utf8"});const a=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(o);if(!a){return e}r=a.groups.mountPoint.trim();r=r.endsWith("/")?r:`${r}/`;return r}})();const pTryEach=async(e,r)=>{let t;for(const n of e){try{return await r(n)}catch(e){t=e}}throw t};const baseOpen=async e=>{e={wait:false,background:false,newInstance:false,allowNonzeroExitCode:false,...e};if(Array.isArray(e.app)){return pTryEach(e.app,(r=>baseOpen({...e,app:r})))}let{name:r,arguments:n=[]}=e.app||{};n=[...n];if(Array.isArray(r)){return pTryEach(r,(r=>baseOpen({...e,app:{name:r,arguments:n}})))}let c;const u=[];const p={};if(l==="darwin"){c="open";if(e.wait){u.push("--wait-apps")}if(e.background){u.push("--background")}if(e.newInstance){u.push("--new")}if(r){u.push("-a",r)}}else if(l==="win32"||a&&!isInsideContainer()&&!r){const t=await m();c=a?`${t}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`:`${process.env.SYSTEMROOT}\\System32\\WindowsPowerShell\\v1.0\\powershell`;u.push("-NoProfile","-NonInteractive","–ExecutionPolicy","Bypass","-EncodedCommand");if(!a){p.windowsVerbatimArguments=true}const o=["Start"];if(e.wait){o.push("-Wait")}if(r){o.push(`"\`"${r}\`""`,"-ArgumentList");if(e.target){n.unshift(e.target)}}else if(e.target){o.push(`"${e.target}"`)}if(n.length>0){n=n.map((e=>`"\`"${e}\`""`));o.push(n.join(","))}e.target=Buffer.from(o.join(" "),"utf16le").toString("base64")}else{if(r){c=r}else{const e=!__dirname||__dirname==="/";let r=false;try{await s.access(t.ab+"xdg-open",i.X_OK);r=true}catch{}const n=process.versions.electron||l==="android"||e||!r;c=n?"xdg-open":f}if(n.length>0){u.push(...n)}if(!e.wait){p.stdio="ignore";p.detached=true}}if(e.target){u.push(e.target)}if(l==="darwin"&&n.length>0){u.push("--args",...n)}const d=o.spawn(c,u,p);if(e.wait){return new Promise(((r,t)=>{d.once("error",t);d.once("close",(n=>{if(!e.allowNonzeroExitCode&&n>0){t(new Error(`Exited with code ${n}`));return}r(d)}))}))}d.unref();return d};const open=(e,r)=>{if(typeof e!=="string"){throw new TypeError("Expected a `target`")}return baseOpen({...r,target:e})};const openApp=(e,r)=>{if(typeof e!=="string"){throw new TypeError("Expected a `name`")}const{arguments:t=[]}=r||{};if(t!==undefined&&t!==null&&!Array.isArray(t)){throw new TypeError("Expected `appArguments` as Array type")}return baseOpen({...r,app:{name:e,arguments:t}})};function detectArchBinary(e){if(typeof e==="string"||Array.isArray(e)){return e}const{[p]:r}=e;if(!r){throw new Error(`${p} is not supported`)}return r}function detectPlatformBinary({[l]:e},{wsl:r}){if(r&&a){return detectArchBinary(r)}if(!e){throw new Error(`${l} is not supported`)}return detectArchBinary(e)}const w={};u(w,"chrome",(()=>detectPlatformBinary({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}})));u(w,"firefox",(()=>detectPlatformBinary({darwin:"firefox",win32:"C:\\Program Files\\Mozilla Firefox\\firefox.exe",linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"})));u(w,"edge",(()=>detectPlatformBinary({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"})));open.apps=w;open.openApp=openApp;e.exports=open},81:e=>{"use strict";e.exports=require("child_process")},147:e=>{"use strict";e.exports=require("fs")},37:e=>{"use strict";e.exports=require("os")},17:e=>{"use strict";e.exports=require("path")}};var r={};function __nccwpck_require__(t){var n=r[t];if(n!==undefined){return n.exports}var o=r[t]={exports:{}};var s=true;try{e[t](o,o.exports,__nccwpck_require__);s=false}finally{if(s)delete r[t]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(913);module.exports=t})();
@@ -1 +1 @@
1
- {"name":"open","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"version":"8.4.0","funding":"https://github.com/sponsors/sindresorhus","license":"MIT","type":"commonjs"}
1
+ {"name":"open","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"version":"8.4.2","funding":"https://github.com/sponsors/sindresorhus","license":"MIT","type":"commonjs"}
@@ -1 +1 @@
1
- (()=>{var __webpack_modules__={540:(e,t,s)=>{"use strict";const r=s(659);r.createWebSocketStream=s(536);r.Server=s(679);r.Receiver=s(301);r.Sender=s(845);r.WebSocket=r;r.WebSocketServer=r.Server;e.exports=r},246:(e,t,s)=>{"use strict";const{EMPTY_BUFFER:r}=s(611);const i=Buffer[Symbol.species];function concat(e,t){if(e.length===0)return r;if(e.length===1)return e[0];const s=Buffer.allocUnsafe(t);let n=0;for(let t=0;t<e.length;t++){const r=e[t];s.set(r,n);n+=r.length}if(n<t){return new i(s.buffer,s.byteOffset,n)}return s}function _mask(e,t,s,r,i){for(let n=0;n<i;n++){s[r+n]=e[n]^t[n&3]}}function _unmask(e,t){for(let s=0;s<e.length;s++){e[s]^=t[s&3]}}function toArrayBuffer(e){if(e.length===e.buffer.byteLength){return e.buffer}return e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function toBuffer(e){toBuffer.readOnly=true;if(Buffer.isBuffer(e))return e;let t;if(e instanceof ArrayBuffer){t=new i(e)}else if(ArrayBuffer.isView(e)){t=new i(e.buffer,e.byteOffset,e.byteLength)}else{t=Buffer.from(e);toBuffer.readOnly=false}return t}e.exports={concat:concat,mask:_mask,toArrayBuffer:toArrayBuffer,toBuffer:toBuffer,unmask:_unmask};if(!process.env.WS_NO_BUFFER_UTIL){try{const t=s(471);e.exports.mask=function(e,s,r,i,n){if(n<48)_mask(e,s,r,i,n);else t.mask(e,s,r,i,n)};e.exports.unmask=function(e,s){if(e.length<32)_unmask(e,s);else t.unmask(e,s)}}catch(e){}}},611: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:()=>{}}},950:(e,t,s)=>{"use strict";const{kForOnEventAttribute:r,kListener:i}=s(611);const n=Symbol("kCode");const o=Symbol("kData");const a=Symbol("kError");const c=Symbol("kMessage");const l=Symbol("kReason");const f=Symbol("kTarget");const h=Symbol("kType");const d=Symbol("kWasClean");class Event{constructor(e){this[f]=null;this[h]=e}get target(){return this[f]}get type(){return this[h]}}Object.defineProperty(Event.prototype,"target",{enumerable:true});Object.defineProperty(Event.prototype,"type",{enumerable:true});class CloseEvent extends Event{constructor(e,t={}){super(e);this[n]=t.code===undefined?0:t.code;this[l]=t.reason===undefined?"":t.reason;this[d]=t.wasClean===undefined?false:t.wasClean}get code(){return this[n]}get reason(){return this[l]}get wasClean(){return this[d]}}Object.defineProperty(CloseEvent.prototype,"code",{enumerable:true});Object.defineProperty(CloseEvent.prototype,"reason",{enumerable:true});Object.defineProperty(CloseEvent.prototype,"wasClean",{enumerable:true});class ErrorEvent extends Event{constructor(e,t={}){super(e);this[a]=t.error===undefined?null:t.error;this[c]=t.message===undefined?"":t.message}get error(){return this[a]}get message(){return this[c]}}Object.defineProperty(ErrorEvent.prototype,"error",{enumerable:true});Object.defineProperty(ErrorEvent.prototype,"message",{enumerable:true});class MessageEvent extends Event{constructor(e,t={}){super(e);this[o]=t.data===undefined?null:t.data}get data(){return this[o]}}Object.defineProperty(MessageEvent.prototype,"data",{enumerable:true});const u={addEventListener(e,t,s={}){for(const n of this.listeners(e)){if(!s[r]&&n[i]===t&&!n[r]){return}}let n;if(e==="message"){n=function onMessage(e,s){const r=new MessageEvent("message",{data:s?e:e.toString()});r[f]=this;callListener(t,this,r)}}else if(e==="close"){n=function onClose(e,s){const r=new CloseEvent("close",{code:e,reason:s.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[f]=this;callListener(t,this,r)}}else if(e==="error"){n=function onError(e){const s=new ErrorEvent("error",{error:e,message:e.message});s[f]=this;callListener(t,this,s)}}else if(e==="open"){n=function onOpen(){const e=new Event("open");e[f]=this;callListener(t,this,e)}}else{return}n[r]=!!s[r];n[i]=t;if(s.once){this.once(e,n)}else{this.on(e,n)}},removeEventListener(e,t){for(const s of this.listeners(e)){if(s[i]===t&&!s[r]){this.removeListener(e,s);break}}}};e.exports={CloseEvent:CloseEvent,ErrorEvent:ErrorEvent,Event:Event,EventTarget:u,MessageEvent:MessageEvent};function callListener(e,t,s){if(typeof e==="object"&&e.handleEvent){e.handleEvent.call(e,s)}else{e.call(t,s)}}},780:(e,t,s)=>{"use strict";const{tokenChars:r}=s(201);function push(e,t,s){if(e[t]===undefined)e[t]=[s];else e[t].push(s)}function parse(e){const t=Object.create(null);let s=Object.create(null);let i=false;let n=false;let o=false;let a;let c;let l=-1;let f=-1;let h=-1;let d=0;for(;d<e.length;d++){f=e.charCodeAt(d);if(a===undefined){if(h===-1&&r[f]===1){if(l===-1)l=d}else if(d!==0&&(f===32||f===9)){if(h===-1&&l!==-1)h=d}else if(f===59||f===44){if(l===-1){throw new SyntaxError(`Unexpected character at index ${d}`)}if(h===-1)h=d;const r=e.slice(l,h);if(f===44){push(t,r,s);s=Object.create(null)}else{a=r}l=h=-1}else{throw new SyntaxError(`Unexpected character at index ${d}`)}}else if(c===undefined){if(h===-1&&r[f]===1){if(l===-1)l=d}else if(f===32||f===9){if(h===-1&&l!==-1)h=d}else if(f===59||f===44){if(l===-1){throw new SyntaxError(`Unexpected character at index ${d}`)}if(h===-1)h=d;push(s,e.slice(l,h),true);if(f===44){push(t,a,s);s=Object.create(null);a=undefined}l=h=-1}else if(f===61&&l!==-1&&h===-1){c=e.slice(l,d);l=h=-1}else{throw new SyntaxError(`Unexpected character at index ${d}`)}}else{if(n){if(r[f]!==1){throw new SyntaxError(`Unexpected character at index ${d}`)}if(l===-1)l=d;else if(!i)i=true;n=false}else if(o){if(r[f]===1){if(l===-1)l=d}else if(f===34&&l!==-1){o=false;h=d}else if(f===92){n=true}else{throw new SyntaxError(`Unexpected character at index ${d}`)}}else if(f===34&&e.charCodeAt(d-1)===61){o=true}else if(h===-1&&r[f]===1){if(l===-1)l=d}else if(l!==-1&&(f===32||f===9)){if(h===-1)h=d}else if(f===59||f===44){if(l===-1){throw new SyntaxError(`Unexpected character at index ${d}`)}if(h===-1)h=d;let r=e.slice(l,h);if(i){r=r.replace(/\\/g,"");i=false}push(s,c,r);if(f===44){push(t,a,s);s=Object.create(null);a=undefined}c=undefined;l=h=-1}else{throw new SyntaxError(`Unexpected character at index ${d}`)}}}if(l===-1||o||f===32||f===9){throw new SyntaxError("Unexpected end of input")}if(h===-1)h=d;const u=e.slice(l,h);if(a===undefined){push(t,u,s)}else{if(c===undefined){push(s,u,true)}else if(i){push(s,c,u.replace(/\\/g,""))}else{push(s,c,u)}push(t,a,s)}return t}function format(e){return Object.keys(e).map((t=>{let s=e[t];if(!Array.isArray(s))s=[s];return s.map((e=>[t].concat(Object.keys(e).map((t=>{let s=e[t];if(!Array.isArray(s))s=[s];return s.map((e=>e===true?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")}e.exports={format:format,parse:parse}},344:e=>{"use strict";const t=Symbol("kDone");const s=Symbol("kRun");class Limiter{constructor(e){this[t]=()=>{this.pending--;this[s]()};this.concurrency=e||Infinity;this.jobs=[];this.pending=0}add(e){this.jobs.push(e);this[s]()}[s](){if(this.pending===this.concurrency)return;if(this.jobs.length){const e=this.jobs.shift();this.pending++;e(this[t])}}}e.exports=Limiter},778:(e,t,s)=>{"use strict";const r=s(796);const i=s(246);const n=s(344);const{kStatusCode:o}=s(611);const a=Buffer[Symbol.species];const c=Buffer.from([0,0,255,255]);const l=Symbol("permessage-deflate");const f=Symbol("total-length");const h=Symbol("callback");const d=Symbol("buffers");const u=Symbol("error");let _;class PerMessageDeflate{constructor(e,t,s){this._maxPayload=s|0;this._options=e||{};this._threshold=this._options.threshold!==undefined?this._options.threshold:1024;this._isServer=!!t;this._deflate=null;this._inflate=null;this.params=null;if(!_){const e=this._options.concurrencyLimit!==undefined?this._options.concurrencyLimit:10;_=new n(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};if(this._options.serverNoContextTakeover){e.server_no_context_takeover=true}if(this._options.clientNoContextTakeover){e.client_no_context_takeover=true}if(this._options.serverMaxWindowBits){e.server_max_window_bits=this._options.serverMaxWindowBits}if(this._options.clientMaxWindowBits){e.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits==null){e.client_max_window_bits=true}return e}accept(e){e=this.normalizeParams(e);this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e);return this.params}cleanup(){if(this._inflate){this._inflate.close();this._inflate=null}if(this._deflate){const e=this._deflate[h];this._deflate.close();this._deflate=null;if(e){e(new Error("The deflate stream was closed while data was being processed"))}}}acceptAsServer(e){const t=this._options;const s=e.find((e=>{if(t.serverNoContextTakeover===false&&e.server_no_context_takeover||e.server_max_window_bits&&(t.serverMaxWindowBits===false||typeof t.serverMaxWindowBits==="number"&&t.serverMaxWindowBits>e.server_max_window_bits)||typeof t.clientMaxWindowBits==="number"&&!e.client_max_window_bits){return false}return true}));if(!s){throw new Error("None of the extension offers can be accepted")}if(t.serverNoContextTakeover){s.server_no_context_takeover=true}if(t.clientNoContextTakeover){s.client_no_context_takeover=true}if(typeof t.serverMaxWindowBits==="number"){s.server_max_window_bits=t.serverMaxWindowBits}if(typeof t.clientMaxWindowBits==="number"){s.client_max_window_bits=t.clientMaxWindowBits}else if(s.client_max_window_bits===true||t.clientMaxWindowBits===false){delete s.client_max_window_bits}return s}acceptAsClient(e){const t=e[0];if(this._options.clientNoContextTakeover===false&&t.client_no_context_takeover){throw new Error('Unexpected parameter "client_no_context_takeover"')}if(!t.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number"){t.client_max_window_bits=this._options.clientMaxWindowBits}}else if(this._options.clientMaxWindowBits===false||typeof this._options.clientMaxWindowBits==="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits){throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}return t}normalizeParams(e){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`)}s=s[0];if(t==="client_max_window_bits"){if(s!==true){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(t==="server_max_window_bits"){const e=+s;if(!Number.isInteger(e)||e<8||e>15){throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}s=e}else if(t==="client_no_context_takeover"||t==="server_no_context_takeover"){if(s!==true){throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}}else{throw new Error(`Unknown parameter "${t}"`)}e[t]=s}))}));return e}decompress(e,t,s){_.add((r=>{this._decompress(e,t,((e,t)=>{r();s(e,t)}))}))}compress(e,t,s){_.add((r=>{this._compress(e,t,((e,t)=>{r();s(e,t)}))}))}_decompress(e,t,s){const n=this._isServer?"client":"server";if(!this._inflate){const e=`${n}_max_window_bits`;const t=typeof this.params[e]!=="number"?r.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=r.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t});this._inflate[l]=this;this._inflate[f]=0;this._inflate[d]=[];this._inflate.on("error",inflateOnError);this._inflate.on("data",inflateOnData)}this._inflate[h]=s;this._inflate.write(e);if(t)this._inflate.write(c);this._inflate.flush((()=>{const e=this._inflate[u];if(e){this._inflate.close();this._inflate=null;s(e);return}const r=i.concat(this._inflate[d],this._inflate[f]);if(this._inflate._readableState.endEmitted){this._inflate.close();this._inflate=null}else{this._inflate[f]=0;this._inflate[d]=[];if(t&&this.params[`${n}_no_context_takeover`]){this._inflate.reset()}}s(null,r)}))}_compress(e,t,s){const n=this._isServer?"server":"client";if(!this._deflate){const e=`${n}_max_window_bits`;const t=typeof this.params[e]!=="number"?r.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=r.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t});this._deflate[f]=0;this._deflate[d]=[];this._deflate.on("data",deflateOnData)}this._deflate[h]=s;this._deflate.write(e);this._deflate.flush(r.Z_SYNC_FLUSH,(()=>{if(!this._deflate){return}let e=i.concat(this._deflate[d],this._deflate[f]);if(t){e=new a(e.buffer,e.byteOffset,e.length-4)}this._deflate[h]=null;this._deflate[f]=0;this._deflate[d]=[];if(t&&this.params[`${n}_no_context_takeover`]){this._deflate.reset()}s(null,e)}))}}e.exports=PerMessageDeflate;function deflateOnData(e){this[d].push(e);this[f]+=e.length}function inflateOnData(e){this[f]+=e.length;if(this[l]._maxPayload<1||this[f]<=this[l]._maxPayload){this[d].push(e);return}this[u]=new RangeError("Max payload size exceeded");this[u].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH";this[u][o]=1009;this.removeListener("data",inflateOnData);this.reset()}function inflateOnError(e){this[l]._inflate=null;e[o]=1007;this[h](e)}},301:(e,t,s)=>{"use strict";const{Writable:r}=s(781);const i=s(778);const{BINARY_TYPES:n,EMPTY_BUFFER:o,kStatusCode:a,kWebSocket:c}=s(611);const{concat:l,toArrayBuffer:f,unmask:h}=s(246);const{isValidStatusCode:d,isValidUTF8:u}=s(201);const _=Buffer[Symbol.species];const p=Promise.resolve();const m=typeof queueMicrotask==="function"?queueMicrotask:queueMicrotaskShim;const b=0;const k=1;const S=2;const y=3;const g=4;const E=5;const w=6;class Receiver extends r{constructor(e={}){super();this._binaryType=e.binaryType||n[0];this._extensions=e.extensions||{};this._isServer=!!e.isServer;this._maxPayload=e.maxPayload|0;this._skipUTF8Validation=!!e.skipUTF8Validation;this[c]=undefined;this._bufferedBytes=0;this._buffers=[];this._compressed=false;this._payloadLength=0;this._mask=undefined;this._fragmented=0;this._masked=false;this._fin=false;this._opcode=0;this._totalPayloadLength=0;this._messageLength=0;this._fragments=[];this._state=b;this._loop=false}_write(e,t,s){if(this._opcode===8&&this._state==b)return s();this._bufferedBytes+=e.length;this._buffers.push(e);this.startLoop(s)}consume(e){this._bufferedBytes-=e;if(e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){const t=this._buffers[0];this._buffers[0]=new _(t.buffer,t.byteOffset+e,t.length-e);return new _(t.buffer,t.byteOffset,e)}const t=Buffer.allocUnsafe(e);do{const s=this._buffers[0];const r=t.length-e;if(e>=s.length){t.set(this._buffers.shift(),r)}else{t.set(new Uint8Array(s.buffer,s.byteOffset,e),r);this._buffers[0]=new _(s.buffer,s.byteOffset+e,s.length-e)}e-=s.length}while(e>0);return t}startLoop(e){let t;this._loop=true;do{switch(this._state){case b:t=this.getInfo();break;case k:t=this.getPayloadLength16();break;case S:t=this.getPayloadLength64();break;case y:this.getMask();break;case g:t=this.getData(e);break;case E:this._loop=false;return;default:this._loop=false;m((()=>{this._state=b;this.startLoop(e)}));return}}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2){this._loop=false;return}const e=this.consume(2);if((e[0]&48)!==0){this._loop=false;return error(RangeError,"RSV2 and RSV3 must be clear",true,1002,"WS_ERR_UNEXPECTED_RSV_2_3")}const t=(e[0]&64)===64;if(t&&!this._extensions[i.extensionName]){this._loop=false;return error(RangeError,"RSV1 must be clear",true,1002,"WS_ERR_UNEXPECTED_RSV_1")}this._fin=(e[0]&128)===128;this._opcode=e[0]&15;this._payloadLength=e[1]&127;if(this._opcode===0){if(t){this._loop=false;return error(RangeError,"RSV1 must be clear",true,1002,"WS_ERR_UNEXPECTED_RSV_1")}if(!this._fragmented){this._loop=false;return error(RangeError,"invalid opcode 0",true,1002,"WS_ERR_INVALID_OPCODE")}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){this._loop=false;return error(RangeError,`invalid opcode ${this._opcode}`,true,1002,"WS_ERR_INVALID_OPCODE")}this._compressed=t}else if(this._opcode>7&&this._opcode<11){if(!this._fin){this._loop=false;return error(RangeError,"FIN must be set",true,1002,"WS_ERR_EXPECTED_FIN")}if(t){this._loop=false;return error(RangeError,"RSV1 must be clear",true,1002,"WS_ERR_UNEXPECTED_RSV_1")}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){this._loop=false;return error(RangeError,`invalid payload length ${this._payloadLength}`,true,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}}else{this._loop=false;return error(RangeError,`invalid opcode ${this._opcode}`,true,1002,"WS_ERR_INVALID_OPCODE")}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;this._masked=(e[1]&128)===128;if(this._isServer){if(!this._masked){this._loop=false;return error(RangeError,"MASK must be set",true,1002,"WS_ERR_EXPECTED_MASK")}}else if(this._masked){this._loop=false;return error(RangeError,"MASK must be clear",true,1002,"WS_ERR_UNEXPECTED_MASK")}if(this._payloadLength===126)this._state=k;else if(this._payloadLength===127)this._state=S;else return this.haveLength()}getPayloadLength16(){if(this._bufferedBytes<2){this._loop=false;return}this._payloadLength=this.consume(2).readUInt16BE(0);return this.haveLength()}getPayloadLength64(){if(this._bufferedBytes<8){this._loop=false;return}const e=this.consume(8);const t=e.readUInt32BE(0);if(t>Math.pow(2,53-32)-1){this._loop=false;return error(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",false,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")}this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4);return this.haveLength()}haveLength(){if(this._payloadLength&&this._opcode<8){this._totalPayloadLength+=this._payloadLength;if(this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){this._loop=false;return error(RangeError,"Max payload size exceeded",false,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH")}}if(this._masked)this._state=y;else this._state=g}getMask(){if(this._bufferedBytes<4){this._loop=false;return}this._mask=this.consume(4);this._state=g}getData(e){let t=o;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=false;return}t=this.consume(this._payloadLength);if(this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0){h(t,this._mask)}}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=E;this.decompress(t,e);return}if(t.length){this._messageLength=this._totalPayloadLength;this._fragments.push(t)}return this.dataMessage()}decompress(e,t){const s=this._extensions[i.extensionName];s.decompress(e,this._fin,((e,s)=>{if(e)return t(e);if(s.length){this._messageLength+=s.length;if(this._messageLength>this._maxPayload&&this._maxPayload>0){return t(error(RangeError,"Max payload size exceeded",false,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;const t=this._fragments;this._totalPayloadLength=0;this._messageLength=0;this._fragmented=0;this._fragments=[];if(this._opcode===2){let s;if(this._binaryType==="nodebuffer"){s=l(t,e)}else if(this._binaryType==="arraybuffer"){s=f(l(t,e))}else{s=t}this.emit("message",s,true)}else{const s=l(t,e);if(!this._skipUTF8Validation&&!u(s)){this._loop=false;return error(Error,"invalid UTF-8 sequence",true,1007,"WS_ERR_INVALID_UTF8")}this.emit("message",s,false)}}this._state=w}controlMessage(e){if(this._opcode===8){this._loop=false;if(e.length===0){this.emit("conclude",1005,o);this.end();this._state=b}else{const t=e.readUInt16BE(0);if(!d(t)){return error(RangeError,`invalid status code ${t}`,true,1002,"WS_ERR_INVALID_CLOSE_CODE")}const s=new _(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!u(s)){return error(Error,"invalid UTF-8 sequence",true,1007,"WS_ERR_INVALID_UTF8")}this.emit("conclude",t,s);this.end();this._state=b}}else if(this._opcode===9){this.emit("ping",e);this._state=w}else{this.emit("pong",e);this._state=w}}}e.exports=Receiver;function error(e,t,s,r,i){const n=new e(s?`Invalid WebSocket frame: ${t}`:t);Error.captureStackTrace(n,error);n.code=i;n[a]=r;return n}function queueMicrotaskShim(e){p.then(e).catch(throwErrorNextTick)}function throwError(e){throw e}function throwErrorNextTick(e){process.nextTick(throwError,e)}},845:(e,t,s)=>{"use strict";const{Duplex:r}=s(781);const{randomFillSync:i}=s(113);const n=s(778);const{EMPTY_BUFFER:o}=s(611);const{isValidStatusCode:a}=s(201);const{mask:c,toBuffer:l}=s(246);const f=Symbol("kByteLength");const h=Buffer.alloc(4);class Sender{constructor(e,t,s){this._extensions=t||{};if(s){this._generateMask=s;this._maskBuffer=Buffer.alloc(4)}this._socket=e;this._firstFragment=true;this._compress=false;this._bufferedBytes=0;this._deflating=false;this._queue=[]}static frame(e,t){let s;let r=false;let n=2;let o=false;if(t.mask){s=t.maskBuffer||h;if(t.generateMask){t.generateMask(s)}else{i(s,0,4)}o=(s[0]|s[1]|s[2]|s[3])===0;n=6}let a;if(typeof e==="string"){if((!t.mask||o)&&t[f]!==undefined){a=t[f]}else{e=Buffer.from(e);a=e.length}}else{a=e.length;r=t.mask&&t.readOnly&&!o}let l=a;if(a>=65536){n+=8;l=127}else if(a>125){n+=2;l=126}const d=Buffer.allocUnsafe(r?a+n:n);d[0]=t.fin?t.opcode|128:t.opcode;if(t.rsv1)d[0]|=64;d[1]=l;if(l===126){d.writeUInt16BE(a,2)}else if(l===127){d[2]=d[3]=0;d.writeUIntBE(a,4,6)}if(!t.mask)return[d,e];d[1]|=128;d[n-4]=s[0];d[n-3]=s[1];d[n-2]=s[2];d[n-1]=s[3];if(o)return[d,e];if(r){c(e,s,d,n,a);return[d]}c(e,s,e,0,a);return[d,e]}close(e,t,s,r){let i;if(e===undefined){i=o}else if(typeof e!=="number"||!a(e)){throw new TypeError("First argument must be a valid error code number")}else if(t===undefined||!t.length){i=Buffer.allocUnsafe(2);i.writeUInt16BE(e,0)}else{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);if(typeof t==="string"){i.write(t,2)}else{i.set(t,2)}}const n={[f]:i.length,fin:true,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:false,rsv1:false};if(this._deflating){this.enqueue([this.dispatch,i,false,n,r])}else{this.sendFrame(Sender.frame(i,n),r)}}ping(e,t,s){let r;let i;if(typeof e==="string"){r=Buffer.byteLength(e);i=false}else{e=l(e);r=e.length;i=l.readOnly}if(r>125){throw new RangeError("The data size must not be greater than 125 bytes")}const n={[f]:r,fin:true,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:false};if(this._deflating){this.enqueue([this.dispatch,e,false,n,s])}else{this.sendFrame(Sender.frame(e,n),s)}}pong(e,t,s){let r;let i;if(typeof e==="string"){r=Buffer.byteLength(e);i=false}else{e=l(e);r=e.length;i=l.readOnly}if(r>125){throw new RangeError("The data size must not be greater than 125 bytes")}const n={[f]:r,fin:true,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:false};if(this._deflating){this.enqueue([this.dispatch,e,false,n,s])}else{this.sendFrame(Sender.frame(e,n),s)}}send(e,t,s){const r=this._extensions[n.extensionName];let i=t.binary?2:1;let o=t.compress;let a;let c;if(typeof e==="string"){a=Buffer.byteLength(e);c=false}else{e=l(e);a=e.length;c=l.readOnly}if(this._firstFragment){this._firstFragment=false;if(o&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]){o=a>=r._threshold}this._compress=o}else{o=false;i=0}if(t.fin)this._firstFragment=true;if(r){const r={[f]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:i,readOnly:c,rsv1:o};if(this._deflating){this.enqueue([this.dispatch,e,this._compress,r,s])}else{this.dispatch(e,this._compress,r,s)}}else{this.sendFrame(Sender.frame(e,{[f]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:i,readOnly:c,rsv1:false}),s)}}dispatch(e,t,s,r){if(!t){this.sendFrame(Sender.frame(e,s),r);return}const i=this._extensions[n.extensionName];this._bufferedBytes+=s[f];this._deflating=true;i.compress(e,s.fin,((e,t)=>{if(this._socket.destroyed){const e=new Error("The socket was closed while data was being compressed");if(typeof r==="function")r(e);for(let t=0;t<this._queue.length;t++){const s=this._queue[t];const r=s[s.length-1];if(typeof r==="function")r(e)}return}this._bufferedBytes-=s[f];this._deflating=false;s.readOnly=false;this.sendFrame(Sender.frame(t,s),r);this.dequeue()}))}dequeue(){while(!this._deflating&&this._queue.length){const e=this._queue.shift();this._bufferedBytes-=e[3][f];Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][f];this._queue.push(e)}sendFrame(e,t){if(e.length===2){this._socket.cork();this._socket.write(e[0]);this._socket.write(e[1],t);this._socket.uncork()}else{this._socket.write(e[0],t)}}}e.exports=Sender},536:(e,t,s)=>{"use strict";const{Duplex:r}=s(781);function emitClose(e){e.emit("close")}function duplexOnEnd(){if(!this.destroyed&&this._writableState.finished){this.destroy()}}function duplexOnError(e){this.removeListener("error",duplexOnError);this.destroy();if(this.listenerCount("error")===0){this.emit("error",e)}}function createWebSocketStream(e,t){let s=true;const i=new r({...t,autoDestroy:false,emitClose:false,objectMode:false,writableObjectMode:false});e.on("message",(function message(t,s){const r=!s&&i._readableState.objectMode?t.toString():t;if(!i.push(r))e.pause()}));e.once("error",(function error(e){if(i.destroyed)return;s=false;i.destroy(e)}));e.once("close",(function close(){if(i.destroyed)return;i.push(null)}));i._destroy=function(t,r){if(e.readyState===e.CLOSED){r(t);process.nextTick(emitClose,i);return}let n=false;e.once("error",(function error(e){n=true;r(e)}));e.once("close",(function close(){if(!n)r(t);process.nextTick(emitClose,i)}));if(s)e.terminate()};i._final=function(t){if(e.readyState===e.CONNECTING){e.once("open",(function open(){i._final(t)}));return}if(e._socket===null)return;if(e._socket._writableState.finished){t();if(i._readableState.endEmitted)i.destroy()}else{e._socket.once("finish",(function finish(){t()}));e.close()}};i._read=function(){if(e.isPaused)e.resume()};i._write=function(t,s,r){if(e.readyState===e.CONNECTING){e.once("open",(function open(){i._write(t,s,r)}));return}e.send(t,r)};i.on("end",duplexOnEnd);i.on("error",duplexOnError);return i}e.exports=createWebSocketStream},382:(e,t,s)=>{"use strict";const{tokenChars:r}=s(201);function parse(e){const t=new Set;let s=-1;let i=-1;let n=0;for(n;n<e.length;n++){const o=e.charCodeAt(n);if(i===-1&&r[o]===1){if(s===-1)s=n}else if(n!==0&&(o===32||o===9)){if(i===-1&&s!==-1)i=n}else if(o===44){if(s===-1){throw new SyntaxError(`Unexpected character at index ${n}`)}if(i===-1)i=n;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{throw new SyntaxError(`Unexpected character at index ${n}`)}}if(s===-1||i!==-1){throw new SyntaxError("Unexpected end of input")}const o=e.slice(s,n);if(t.has(o)){throw new SyntaxError(`The "${o}" subprotocol is duplicated`)}t.add(o);return t}e.exports={parse:parse}},201:(e,t,s)=>{"use strict";const{isUtf8:r}=s(300);const i=[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];function isValidStatusCode(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function _isValidUTF8(e){const t=e.length;let s=0;while(s<t){if((e[s]&128)===0){s++}else if((e[s]&224)===192){if(s+1===t||(e[s+1]&192)!==128||(e[s]&254)===192){return false}s+=2}else if((e[s]&240)===224){if(s+2>=t||(e[s+1]&192)!==128||(e[s+2]&192)!==128||e[s]===224&&(e[s+1]&224)===128||e[s]===237&&(e[s+1]&224)===160){return false}s+=3}else if((e[s]&248)===240){if(s+3>=t||(e[s+1]&192)!==128||(e[s+2]&192)!==128||(e[s+3]&192)!==128||e[s]===240&&(e[s+1]&240)===128||e[s]===244&&e[s+1]>143||e[s]>244){return false}s+=4}else{return false}}return true}e.exports={isValidStatusCode:isValidStatusCode,isValidUTF8:_isValidUTF8,tokenChars:i};if(r){e.exports.isValidUTF8=function(e){return e.length<24?_isValidUTF8(e):r(e)}}else if(!process.env.WS_NO_UTF_8_VALIDATE){try{const t=s(177);e.exports.isValidUTF8=function(e){return e.length<32?_isValidUTF8(e):t(e)}}catch(e){}}},679:(e,t,s)=>{"use strict";const r=s(361);const i=s(685);const{Duplex:n}=s(781);const{createHash:o}=s(113);const a=s(780);const c=s(778);const l=s(382);const f=s(659);const{GUID:h,kWebSocket:d}=s(611);const u=/^[+/0-9A-Za-z]{22}==$/;const _=0;const p=1;const m=2;class WebSocketServer extends r{constructor(e,t){super();e={maxPayload:100*1024*1024,skipUTF8Validation:false,perMessageDeflate:false,handleProtocols:null,clientTracking:true,verifyClient:null,noServer:false,backlog:null,server:null,host:null,path:null,port:null,WebSocket:f,...e};if(e.port==null&&!e.server&&!e.noServer||e.port!=null&&(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(e.port!=null){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)}else if(e.server){this._server=e.server}if(this._server){const e=this.emit.bind(this,"connection");this._removeListeners=addListeners(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,s,r)=>{this.handleUpgrade(t,s,r,e)}})}if(e.perMessageDeflate===true)e.perMessageDeflate={};if(e.clientTracking){this.clients=new Set;this._shouldEmitClose=false}this.options=e;this._state=_}address(){if(this.options.noServer){throw new Error('The server is operating in "noServer" mode')}if(!this._server)return null;return this._server.address()}close(e){if(this._state===m){if(e){this.once("close",(()=>{e(new Error("The server is not running"))}))}process.nextTick(emitClose,this);return}if(e)this.once("close",e);if(this._state===p)return;this._state=p;if(this.options.noServer||this.options.server){if(this._server){this._removeListeners();this._removeListeners=this._server=null}if(this.clients){if(!this.clients.size){process.nextTick(emitClose,this)}else{this._shouldEmitClose=true}}else{process.nextTick(emitClose,this)}}else{const e=this._server;this._removeListeners();this._removeListeners=this._server=null;e.close((()=>{emitClose(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");const s=t!==-1?e.url.slice(0,t):e.url;if(s!==this.options.path)return false}return true}handleUpgrade(e,t,s,r){t.on("error",socketOnError);const i=e.headers["sec-websocket-key"];const n=+e.headers["sec-websocket-version"];if(e.method!=="GET"){const s="Invalid HTTP method";abortHandshakeOrEmitwsClientError(this,e,t,405,s);return}if(e.headers.upgrade.toLowerCase()!=="websocket"){const s="Invalid Upgrade header";abortHandshakeOrEmitwsClientError(this,e,t,400,s);return}if(!i||!u.test(i)){const s="Missing or invalid Sec-WebSocket-Key header";abortHandshakeOrEmitwsClientError(this,e,t,400,s);return}if(n!==8&&n!==13){const s="Missing or invalid Sec-WebSocket-Version header";abortHandshakeOrEmitwsClientError(this,e,t,400,s);return}if(!this.shouldHandle(e)){abortHandshake(t,400);return}const o=e.headers["sec-websocket-protocol"];let f=new Set;if(o!==undefined){try{f=l.parse(o)}catch(s){const r="Invalid Sec-WebSocket-Protocol header";abortHandshakeOrEmitwsClientError(this,e,t,400,r);return}}const h=e.headers["sec-websocket-extensions"];const d={};if(this.options.perMessageDeflate&&h!==undefined){const s=new c(this.options.perMessageDeflate,true,this.options.maxPayload);try{const e=a.parse(h);if(e[c.extensionName]){s.accept(e[c.extensionName]);d[c.extensionName]=s}}catch(s){const r="Invalid or unacceptable Sec-WebSocket-Extensions header";abortHandshakeOrEmitwsClientError(this,e,t,400,r);return}}if(this.options.verifyClient){const o={origin:e.headers[`${n===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(o,((n,o,a,c)=>{if(!n){return abortHandshake(t,o||401,a,c)}this.completeUpgrade(d,i,f,e,t,s,r)}));return}if(!this.options.verifyClient(o))return abortHandshake(t,401)}this.completeUpgrade(d,i,f,e,t,s,r)}completeUpgrade(e,t,s,r,i,n,l){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>_)return abortHandshake(i,503);const f=o("sha1").update(t+h).digest("base64");const u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${f}`];const p=new this.options.WebSocket(null);if(s.size){const e=this.options.handleProtocols?this.options.handleProtocols(s,r):s.values().next().value;if(e){u.push(`Sec-WebSocket-Protocol: ${e}`);p._protocol=e}}if(e[c.extensionName]){const t=e[c.extensionName].params;const s=a.format({[c.extensionName]:[t]});u.push(`Sec-WebSocket-Extensions: ${s}`);p._extensions=e}this.emit("headers",u,r);i.write(u.concat("\r\n").join("\r\n"));i.removeListener("error",socketOnError);p.setSocket(i,n,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation});if(this.clients){this.clients.add(p);p.on("close",(()=>{this.clients.delete(p);if(this._shouldEmitClose&&!this.clients.size){process.nextTick(emitClose,this)}}))}l(p,r)}}e.exports=WebSocketServer;function addListeners(e,t){for(const s of Object.keys(t))e.on(s,t[s]);return function removeListeners(){for(const s of Object.keys(t)){e.removeListener(s,t[s])}}}function emitClose(e){e._state=m;e.emit("close")}function socketOnError(){this.destroy()}function abortHandshake(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 abortHandshakeOrEmitwsClientError(e,t,s,r,i){if(e.listenerCount("wsClientError")){const r=new Error(i);Error.captureStackTrace(r,abortHandshakeOrEmitwsClientError);e.emit("wsClientError",r,s,t)}else{abortHandshake(s,r,i)}}},659:(e,t,s)=>{"use strict";const r=s(361);const i=s(687);const n=s(685);const o=s(808);const a=s(404);const{randomBytes:c,createHash:l}=s(113);const{Duplex:f,Readable:h}=s(781);const{URL:d}=s(310);const u=s(778);const _=s(301);const p=s(845);const{BINARY_TYPES:m,EMPTY_BUFFER:b,GUID:k,kForOnEventAttribute:S,kListener:y,kStatusCode:g,kWebSocket:E,NOOP:w}=s(611);const{EventTarget:{addEventListener:v,removeEventListener:x}}=s(950);const{format:O,parse:C}=s(780);const{toBuffer:T}=s(246);const N=30*1e3;const L=Symbol("kAborted");const W=[8,13];const P=["CONNECTING","OPEN","CLOSING","CLOSED"];const B=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class WebSocket extends r{constructor(e,t,s){super();this._binaryType=m[0];this._closeCode=1006;this._closeFrameReceived=false;this._closeFrameSent=false;this._closeMessage=b;this._closeTimer=null;this._extensions={};this._paused=false;this._protocol="";this._readyState=WebSocket.CONNECTING;this._receiver=null;this._sender=null;this._socket=null;if(e!==null){this._bufferedAmount=0;this._isServer=false;this._redirects=0;if(t===undefined){t=[]}else if(!Array.isArray(t)){if(typeof t==="object"&&t!==null){s=t;t=[]}else{t=[t]}}initAsClient(this,e,t,s)}else{this._isServer=true}}get binaryType(){return this._binaryType}set binaryType(e){if(!m.includes(e))return;this._binaryType=e;if(this._receiver)this._receiver._binaryType=e}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}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 p(e,this._extensions,s.generateMask);this._receiver=r;this._socket=e;r[E]=this;e[E]=this;r.on("conclude",receiverOnConclude);r.on("drain",receiverOnDrain);r.on("error",receiverOnError);r.on("message",receiverOnMessage);r.on("ping",receiverOnPing);r.on("pong",receiverOnPong);if(e.setTimeout)e.setTimeout(0);if(e.setNoDelay)e.setNoDelay();if(t.length>0)e.unshift(t);e.on("close",socketOnClose);e.on("data",socketOnData);e.on("end",socketOnEnd);e.on("error",socketOnError);this._readyState=WebSocket.OPEN;this.emit("open")}emitClose(){if(!this._socket){this._readyState=WebSocket.CLOSED;this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[u.extensionName]){this._extensions[u.extensionName].cleanup()}this._receiver.removeAllListeners();this._readyState=WebSocket.CLOSED;this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState===WebSocket.CLOSED)return;if(this.readyState===WebSocket.CONNECTING){const e="WebSocket was closed before the connection was established";abortHandshake(this,this._req,e);return}if(this.readyState===WebSocket.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)){this._socket.end()}return}this._readyState=WebSocket.CLOSING;this._sender.close(e,t,!this._isServer,(e=>{if(e)return;this._closeFrameSent=true;if(this._closeFrameReceived||this._receiver._writableState.errorEmitted){this._socket.end()}}));this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),N)}pause(){if(this.readyState===WebSocket.CONNECTING||this.readyState===WebSocket.CLOSED){return}this._paused=true;this._socket.pause()}ping(e,t,s){if(this.readyState===WebSocket.CONNECTING){throw new Error("WebSocket is not open: readyState 0 (CONNECTING)")}if(typeof e==="function"){s=e;e=t=undefined}else if(typeof t==="function"){s=t;t=undefined}if(typeof e==="number")e=e.toString();if(this.readyState!==WebSocket.OPEN){sendAfterClose(this,e,s);return}if(t===undefined)t=!this._isServer;this._sender.ping(e||b,t,s)}pong(e,t,s){if(this.readyState===WebSocket.CONNECTING){throw new Error("WebSocket is not open: readyState 0 (CONNECTING)")}if(typeof e==="function"){s=e;e=t=undefined}else if(typeof t==="function"){s=t;t=undefined}if(typeof e==="number")e=e.toString();if(this.readyState!==WebSocket.OPEN){sendAfterClose(this,e,s);return}if(t===undefined)t=!this._isServer;this._sender.pong(e||b,t,s)}resume(){if(this.readyState===WebSocket.CONNECTING||this.readyState===WebSocket.CLOSED){return}this._paused=false;if(!this._receiver._writableState.needDrain)this._socket.resume()}send(e,t,s){if(this.readyState===WebSocket.CONNECTING){throw new Error("WebSocket is not open: readyState 0 (CONNECTING)")}if(typeof t==="function"){s=t;t={}}if(typeof e==="number")e=e.toString();if(this.readyState!==WebSocket.OPEN){sendAfterClose(this,e,s);return}const r={binary:typeof e!=="string",mask:!this._isServer,compress:true,fin:true,...t};if(!this._extensions[u.extensionName]){r.compress=false}this._sender.send(e||b,r,s)}terminate(){if(this.readyState===WebSocket.CLOSED)return;if(this.readyState===WebSocket.CONNECTING){const e="WebSocket was closed before the connection was established";abortHandshake(this,this._req,e);return}if(this._socket){this._readyState=WebSocket.CLOSING;this._socket.destroy()}}}Object.defineProperty(WebSocket,"CONNECTING",{enumerable:true,value:P.indexOf("CONNECTING")});Object.defineProperty(WebSocket.prototype,"CONNECTING",{enumerable:true,value:P.indexOf("CONNECTING")});Object.defineProperty(WebSocket,"OPEN",{enumerable:true,value:P.indexOf("OPEN")});Object.defineProperty(WebSocket.prototype,"OPEN",{enumerable:true,value:P.indexOf("OPEN")});Object.defineProperty(WebSocket,"CLOSING",{enumerable:true,value:P.indexOf("CLOSING")});Object.defineProperty(WebSocket.prototype,"CLOSING",{enumerable:true,value:P.indexOf("CLOSING")});Object.defineProperty(WebSocket,"CLOSED",{enumerable:true,value:P.indexOf("CLOSED")});Object.defineProperty(WebSocket.prototype,"CLOSED",{enumerable:true,value:P.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(WebSocket.prototype,e,{enumerable:true})}));["open","error","close","message"].forEach((e=>{Object.defineProperty(WebSocket.prototype,`on${e}`,{enumerable:true,get(){for(const t of this.listeners(e)){if(t[S])return t[y]}return null},set(t){for(const t of this.listeners(e)){if(t[S]){this.removeListener(e,t);break}}if(typeof t!=="function")return;this.addEventListener(e,t,{[S]:true})}})}));WebSocket.prototype.addEventListener=v;WebSocket.prototype.removeEventListener=x;e.exports=WebSocket;function initAsClient(e,t,s,r){const o={protocolVersion:W[1],maxPayload:100*1024*1024,skipUTF8Validation:false,perMessageDeflate:true,followRedirects:false,maxRedirects:10,...r,createConnection:undefined,socketPath:undefined,hostname:undefined,protocol:undefined,timeout:undefined,method:"GET",host:undefined,path:undefined,port:undefined};if(!W.includes(o.protocolVersion)){throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} `+`(supported versions: ${W.join(", ")})`)}let a;if(t instanceof d){a=t}else{try{a=new d(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}}if(a.protocol==="http:"){a.protocol="ws:"}else if(a.protocol==="https:"){a.protocol="wss:"}e._url=a.href;const f=a.protocol==="wss:";const h=a.protocol==="ws+unix:";let _;if(a.protocol!=="ws:"&&!f&&!h){_='The URL\'s protocol must be one of "ws:", "wss:", '+'"http:", "https", or "ws+unix:"'}else if(h&&!a.pathname){_="The URL's pathname is empty"}else if(a.hash){_="The URL contains a fragment identifier"}if(_){const t=new SyntaxError(_);if(e._redirects===0){throw t}else{emitErrorAndClose(e,t);return}}const p=f?443:80;const m=c(16).toString("base64");const b=f?i.request:n.request;const S=new Set;let y;o.createConnection=f?tlsConnect:netConnect;o.defaultPort=o.defaultPort||p;o.port=a.port||p;o.host=a.hostname.startsWith("[")?a.hostname.slice(1,-1):a.hostname;o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":m,Connection:"Upgrade",Upgrade:"websocket"};o.path=a.pathname+a.search;o.timeout=o.handshakeTimeout;if(o.perMessageDeflate){y=new u(o.perMessageDeflate!==true?o.perMessageDeflate:{},false,o.maxPayload);o.headers["Sec-WebSocket-Extensions"]=O({[u.extensionName]:y.offer()})}if(s.length){for(const e of s){if(typeof e!=="string"||!B.test(e)||S.has(e)){throw new SyntaxError("An invalid or duplicated subprotocol was specified")}S.add(e)}o.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(o.origin){if(o.protocolVersion<13){o.headers["Sec-WebSocket-Origin"]=o.origin}else{o.headers.Origin=o.origin}}if(a.username||a.password){o.auth=`${a.username}:${a.password}`}if(h){const e=o.path.split(":");o.socketPath=e[0];o.path=e[1]}let g;if(o.followRedirects){if(e._redirects===0){e._originalIpc=h;e._originalSecure=f;e._originalHostOrSocketPath=h?o.socketPath:a.host;const t=r&&r.headers;r={...r,headers:{}};if(t){for(const[e,s]of Object.entries(t)){r.headers[e.toLowerCase()]=s}}}else if(e.listenerCount("redirect")===0){const t=h?e._originalIpc?o.socketPath===e._originalHostOrSocketPath:false:e._originalIpc?false:a.host===e._originalHostOrSocketPath;if(!t||e._originalSecure&&!f){delete o.headers.authorization;delete o.headers.cookie;if(!t)delete o.headers.host;o.auth=undefined}}if(o.auth&&!r.headers.authorization){r.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")}g=e._req=b(o);if(e._redirects){e.emit("redirect",e.url,g)}}else{g=e._req=b(o)}if(o.timeout){g.on("timeout",(()=>{abortHandshake(e,g,"Opening handshake has timed out")}))}g.on("error",(t=>{if(g===null||g[L])return;g=e._req=null;emitErrorAndClose(e,t)}));g.on("response",(i=>{const n=i.headers.location;const a=i.statusCode;if(n&&o.followRedirects&&a>=300&&a<400){if(++e._redirects>o.maxRedirects){abortHandshake(e,g,"Maximum redirects exceeded");return}g.abort();let i;try{i=new d(n,t)}catch(t){const s=new SyntaxError(`Invalid URL: ${n}`);emitErrorAndClose(e,s);return}initAsClient(e,i,s,r)}else if(!e.emit("unexpected-response",g,i)){abortHandshake(e,g,`Unexpected server response: ${i.statusCode}`)}}));g.on("upgrade",((t,s,r)=>{e.emit("upgrade",t);if(e.readyState!==WebSocket.CONNECTING)return;g=e._req=null;if(t.headers.upgrade.toLowerCase()!=="websocket"){abortHandshake(e,s,"Invalid Upgrade header");return}const i=l("sha1").update(m+k).digest("base64");if(t.headers["sec-websocket-accept"]!==i){abortHandshake(e,s,"Invalid Sec-WebSocket-Accept header");return}const n=t.headers["sec-websocket-protocol"];let a;if(n!==undefined){if(!S.size){a="Server sent a subprotocol but none was requested"}else if(!S.has(n)){a="Server sent an invalid subprotocol"}}else if(S.size){a="Server sent no subprotocol"}if(a){abortHandshake(e,s,a);return}if(n)e._protocol=n;const c=t.headers["sec-websocket-extensions"];if(c!==undefined){if(!y){const t="Server sent a Sec-WebSocket-Extensions header but no extension "+"was requested";abortHandshake(e,s,t);return}let t;try{t=C(c)}catch(t){const r="Invalid Sec-WebSocket-Extensions header";abortHandshake(e,s,r);return}const r=Object.keys(t);if(r.length!==1||r[0]!==u.extensionName){const t="Server indicated an extension that was not requested";abortHandshake(e,s,t);return}try{y.accept(t[u.extensionName])}catch(t){const r="Invalid Sec-WebSocket-Extensions header";abortHandshake(e,s,r);return}e._extensions[u.extensionName]=y}e.setSocket(s,r,{generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}));if(o.finishRequest){o.finishRequest(g,e)}else{g.end()}}function emitErrorAndClose(e,t){e._readyState=WebSocket.CLOSING;e.emit("error",t);e.emitClose()}function netConnect(e){e.path=e.socketPath;return o.connect(e)}function tlsConnect(e){e.path=undefined;if(!e.servername&&e.servername!==""){e.servername=o.isIP(e.host)?"":e.host}return a.connect(e)}function abortHandshake(e,t,s){e._readyState=WebSocket.CLOSING;const r=new Error(s);Error.captureStackTrace(r,abortHandshake);if(t.setHeader){t[L]=true;t.abort();if(t.socket&&!t.socket.destroyed){t.socket.destroy()}process.nextTick(emitErrorAndClose,e,r)}else{t.destroy(r);t.once("error",e.emit.bind(e,"error"));t.once("close",e.emitClose.bind(e))}}function sendAfterClose(e,t,s){if(t){const s=T(t).length;if(e._socket)e._sender._bufferedBytes+=s;else e._bufferedAmount+=s}if(s){const t=new Error(`WebSocket is not open: readyState ${e.readyState} `+`(${P[e.readyState]})`);process.nextTick(s,t)}}function receiverOnConclude(e,t){const s=this[E];s._closeFrameReceived=true;s._closeMessage=t;s._closeCode=e;if(s._socket[E]===undefined)return;s._socket.removeListener("data",socketOnData);process.nextTick(resume,s._socket);if(e===1005)s.close();else s.close(e,t)}function receiverOnDrain(){const e=this[E];if(!e.isPaused)e._socket.resume()}function receiverOnError(e){const t=this[E];if(t._socket[E]!==undefined){t._socket.removeListener("data",socketOnData);process.nextTick(resume,t._socket);t.close(e[g])}t.emit("error",e)}function receiverOnFinish(){this[E].emitClose()}function receiverOnMessage(e,t){this[E].emit("message",e,t)}function receiverOnPing(e){const t=this[E];t.pong(e,!t._isServer,w);t.emit("ping",e)}function receiverOnPong(e){this[E].emit("pong",e)}function resume(e){e.resume()}function socketOnClose(){const e=this[E];this.removeListener("close",socketOnClose);this.removeListener("data",socketOnData);this.removeListener("end",socketOnEnd);e._readyState=WebSocket.CLOSING;let t;if(!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&(t=e._socket.read())!==null){e._receiver.write(t)}e._receiver.end();this[E]=undefined;clearTimeout(e._closeTimer);if(e._receiver._writableState.finished||e._receiver._writableState.errorEmitted){e.emitClose()}else{e._receiver.on("error",receiverOnFinish);e._receiver.on("finish",receiverOnFinish)}}function socketOnData(e){if(!this[E]._receiver.write(e)){this.pause()}}function socketOnEnd(){const e=this[E];e._readyState=WebSocket.CLOSING;e._receiver.end();this.end()}function socketOnError(){const e=this[E];this.removeListener("error",socketOnError);this.on("error",w);if(e){e._readyState=WebSocket.CLOSING;this.destroy()}}},471:module=>{module.exports=eval("require")("bufferutil")},177:module=>{module.exports=eval("require")("utf-8-validate")},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")}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var s=__webpack_module_cache__[e]={exports:{}};var r=true;try{__webpack_modules__[e](s,s.exports,__nccwpck_require__);r=false}finally{if(r)delete __webpack_module_cache__[e]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__=__nccwpck_require__(540);module.exports=__webpack_exports__})();
1
+ (()=>{var __webpack_modules__={201:(e,t,s)=>{"use strict";const r=s(885);r.createWebSocketStream=s(334);r.Server=s(69);r.Receiver=s(997);r.Sender=s(345);r.WebSocket=r;r.WebSocketServer=r.Server;e.exports=r},64:(e,t,s)=>{"use strict";const{EMPTY_BUFFER:r}=s(547);const n=Buffer[Symbol.species];function concat(e,t){if(e.length===0)return r;if(e.length===1)return e[0];const s=Buffer.allocUnsafe(t);let i=0;for(let t=0;t<e.length;t++){const r=e[t];s.set(r,i);i+=r.length}if(i<t){return new n(s.buffer,s.byteOffset,i)}return s}function _mask(e,t,s,r,n){for(let i=0;i<n;i++){s[r+i]=e[i]^t[i&3]}}function _unmask(e,t){for(let s=0;s<e.length;s++){e[s]^=t[s&3]}}function toArrayBuffer(e){if(e.length===e.buffer.byteLength){return e.buffer}return e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function toBuffer(e){toBuffer.readOnly=true;if(Buffer.isBuffer(e))return e;let t;if(e instanceof ArrayBuffer){t=new n(e)}else if(ArrayBuffer.isView(e)){t=new n(e.buffer,e.byteOffset,e.byteLength)}else{t=Buffer.from(e);toBuffer.readOnly=false}return t}e.exports={concat:concat,mask:_mask,toArrayBuffer:toArrayBuffer,toBuffer:toBuffer,unmask:_unmask};if(!process.env.WS_NO_BUFFER_UTIL){try{const t=s(471);e.exports.mask=function(e,s,r,n,i){if(i<48)_mask(e,s,r,n,i);else t.mask(e,s,r,n,i)};e.exports.unmask=function(e,s){if(e.length<32)_unmask(e,s);else t.unmask(e,s)}}catch(e){}}},547: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:()=>{}}},874:(e,t,s)=>{"use strict";const{kForOnEventAttribute:r,kListener:n}=s(547);const i=Symbol("kCode");const o=Symbol("kData");const a=Symbol("kError");const c=Symbol("kMessage");const l=Symbol("kReason");const f=Symbol("kTarget");const h=Symbol("kType");const d=Symbol("kWasClean");class Event{constructor(e){this[f]=null;this[h]=e}get target(){return this[f]}get type(){return this[h]}}Object.defineProperty(Event.prototype,"target",{enumerable:true});Object.defineProperty(Event.prototype,"type",{enumerable:true});class CloseEvent extends Event{constructor(e,t={}){super(e);this[i]=t.code===undefined?0:t.code;this[l]=t.reason===undefined?"":t.reason;this[d]=t.wasClean===undefined?false:t.wasClean}get code(){return this[i]}get reason(){return this[l]}get wasClean(){return this[d]}}Object.defineProperty(CloseEvent.prototype,"code",{enumerable:true});Object.defineProperty(CloseEvent.prototype,"reason",{enumerable:true});Object.defineProperty(CloseEvent.prototype,"wasClean",{enumerable:true});class ErrorEvent extends Event{constructor(e,t={}){super(e);this[a]=t.error===undefined?null:t.error;this[c]=t.message===undefined?"":t.message}get error(){return this[a]}get message(){return this[c]}}Object.defineProperty(ErrorEvent.prototype,"error",{enumerable:true});Object.defineProperty(ErrorEvent.prototype,"message",{enumerable:true});class MessageEvent extends Event{constructor(e,t={}){super(e);this[o]=t.data===undefined?null:t.data}get data(){return this[o]}}Object.defineProperty(MessageEvent.prototype,"data",{enumerable:true});const u={addEventListener(e,t,s={}){for(const i of this.listeners(e)){if(!s[r]&&i[n]===t&&!i[r]){return}}let i;if(e==="message"){i=function onMessage(e,s){const r=new MessageEvent("message",{data:s?e:e.toString()});r[f]=this;callListener(t,this,r)}}else if(e==="close"){i=function onClose(e,s){const r=new CloseEvent("close",{code:e,reason:s.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[f]=this;callListener(t,this,r)}}else if(e==="error"){i=function onError(e){const s=new ErrorEvent("error",{error:e,message:e.message});s[f]=this;callListener(t,this,s)}}else if(e==="open"){i=function onOpen(){const e=new Event("open");e[f]=this;callListener(t,this,e)}}else{return}i[r]=!!s[r];i[n]=t;if(s.once){this.once(e,i)}else{this.on(e,i)}},removeEventListener(e,t){for(const s of this.listeners(e)){if(s[n]===t&&!s[r]){this.removeListener(e,s);break}}}};e.exports={CloseEvent:CloseEvent,ErrorEvent:ErrorEvent,Event:Event,EventTarget:u,MessageEvent:MessageEvent};function callListener(e,t,s){if(typeof e==="object"&&e.handleEvent){e.handleEvent.call(e,s)}else{e.call(t,s)}}},321:(e,t,s)=>{"use strict";const{tokenChars:r}=s(903);function push(e,t,s){if(e[t]===undefined)e[t]=[s];else e[t].push(s)}function parse(e){const t=Object.create(null);let s=Object.create(null);let n=false;let i=false;let o=false;let a;let c;let l=-1;let f=-1;let h=-1;let d=0;for(;d<e.length;d++){f=e.charCodeAt(d);if(a===undefined){if(h===-1&&r[f]===1){if(l===-1)l=d}else if(d!==0&&(f===32||f===9)){if(h===-1&&l!==-1)h=d}else if(f===59||f===44){if(l===-1){throw new SyntaxError(`Unexpected character at index ${d}`)}if(h===-1)h=d;const r=e.slice(l,h);if(f===44){push(t,r,s);s=Object.create(null)}else{a=r}l=h=-1}else{throw new SyntaxError(`Unexpected character at index ${d}`)}}else if(c===undefined){if(h===-1&&r[f]===1){if(l===-1)l=d}else if(f===32||f===9){if(h===-1&&l!==-1)h=d}else if(f===59||f===44){if(l===-1){throw new SyntaxError(`Unexpected character at index ${d}`)}if(h===-1)h=d;push(s,e.slice(l,h),true);if(f===44){push(t,a,s);s=Object.create(null);a=undefined}l=h=-1}else if(f===61&&l!==-1&&h===-1){c=e.slice(l,d);l=h=-1}else{throw new SyntaxError(`Unexpected character at index ${d}`)}}else{if(i){if(r[f]!==1){throw new SyntaxError(`Unexpected character at index ${d}`)}if(l===-1)l=d;else if(!n)n=true;i=false}else if(o){if(r[f]===1){if(l===-1)l=d}else if(f===34&&l!==-1){o=false;h=d}else if(f===92){i=true}else{throw new SyntaxError(`Unexpected character at index ${d}`)}}else if(f===34&&e.charCodeAt(d-1)===61){o=true}else if(h===-1&&r[f]===1){if(l===-1)l=d}else if(l!==-1&&(f===32||f===9)){if(h===-1)h=d}else if(f===59||f===44){if(l===-1){throw new SyntaxError(`Unexpected character at index ${d}`)}if(h===-1)h=d;let r=e.slice(l,h);if(n){r=r.replace(/\\/g,"");n=false}push(s,c,r);if(f===44){push(t,a,s);s=Object.create(null);a=undefined}c=undefined;l=h=-1}else{throw new SyntaxError(`Unexpected character at index ${d}`)}}}if(l===-1||o||f===32||f===9){throw new SyntaxError("Unexpected end of input")}if(h===-1)h=d;const u=e.slice(l,h);if(a===undefined){push(t,u,s)}else{if(c===undefined){push(s,u,true)}else if(n){push(s,c,u.replace(/\\/g,""))}else{push(s,c,u)}push(t,a,s)}return t}function format(e){return Object.keys(e).map((t=>{let s=e[t];if(!Array.isArray(s))s=[s];return s.map((e=>[t].concat(Object.keys(e).map((t=>{let s=e[t];if(!Array.isArray(s))s=[s];return s.map((e=>e===true?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")}e.exports={format:format,parse:parse}},658:e=>{"use strict";const t=Symbol("kDone");const s=Symbol("kRun");class Limiter{constructor(e){this[t]=()=>{this.pending--;this[s]()};this.concurrency=e||Infinity;this.jobs=[];this.pending=0}add(e){this.jobs.push(e);this[s]()}[s](){if(this.pending===this.concurrency)return;if(this.jobs.length){const e=this.jobs.shift();this.pending++;e(this[t])}}}e.exports=Limiter},613:(e,t,s)=>{"use strict";const r=s(796);const n=s(64);const i=s(658);const{kStatusCode:o}=s(547);const a=Buffer[Symbol.species];const c=Buffer.from([0,0,255,255]);const l=Symbol("permessage-deflate");const f=Symbol("total-length");const h=Symbol("callback");const d=Symbol("buffers");const u=Symbol("error");let _;class PerMessageDeflate{constructor(e,t,s){this._maxPayload=s|0;this._options=e||{};this._threshold=this._options.threshold!==undefined?this._options.threshold:1024;this._isServer=!!t;this._deflate=null;this._inflate=null;this.params=null;if(!_){const e=this._options.concurrencyLimit!==undefined?this._options.concurrencyLimit:10;_=new i(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};if(this._options.serverNoContextTakeover){e.server_no_context_takeover=true}if(this._options.clientNoContextTakeover){e.client_no_context_takeover=true}if(this._options.serverMaxWindowBits){e.server_max_window_bits=this._options.serverMaxWindowBits}if(this._options.clientMaxWindowBits){e.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits==null){e.client_max_window_bits=true}return e}accept(e){e=this.normalizeParams(e);this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e);return this.params}cleanup(){if(this._inflate){this._inflate.close();this._inflate=null}if(this._deflate){const e=this._deflate[h];this._deflate.close();this._deflate=null;if(e){e(new Error("The deflate stream was closed while data was being processed"))}}}acceptAsServer(e){const t=this._options;const s=e.find((e=>{if(t.serverNoContextTakeover===false&&e.server_no_context_takeover||e.server_max_window_bits&&(t.serverMaxWindowBits===false||typeof t.serverMaxWindowBits==="number"&&t.serverMaxWindowBits>e.server_max_window_bits)||typeof t.clientMaxWindowBits==="number"&&!e.client_max_window_bits){return false}return true}));if(!s){throw new Error("None of the extension offers can be accepted")}if(t.serverNoContextTakeover){s.server_no_context_takeover=true}if(t.clientNoContextTakeover){s.client_no_context_takeover=true}if(typeof t.serverMaxWindowBits==="number"){s.server_max_window_bits=t.serverMaxWindowBits}if(typeof t.clientMaxWindowBits==="number"){s.client_max_window_bits=t.clientMaxWindowBits}else if(s.client_max_window_bits===true||t.clientMaxWindowBits===false){delete s.client_max_window_bits}return s}acceptAsClient(e){const t=e[0];if(this._options.clientNoContextTakeover===false&&t.client_no_context_takeover){throw new Error('Unexpected parameter "client_no_context_takeover"')}if(!t.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number"){t.client_max_window_bits=this._options.clientMaxWindowBits}}else if(this._options.clientMaxWindowBits===false||typeof this._options.clientMaxWindowBits==="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits){throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}return t}normalizeParams(e){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`)}s=s[0];if(t==="client_max_window_bits"){if(s!==true){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(t==="server_max_window_bits"){const e=+s;if(!Number.isInteger(e)||e<8||e>15){throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}s=e}else if(t==="client_no_context_takeover"||t==="server_no_context_takeover"){if(s!==true){throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}}else{throw new Error(`Unknown parameter "${t}"`)}e[t]=s}))}));return e}decompress(e,t,s){_.add((r=>{this._decompress(e,t,((e,t)=>{r();s(e,t)}))}))}compress(e,t,s){_.add((r=>{this._compress(e,t,((e,t)=>{r();s(e,t)}))}))}_decompress(e,t,s){const i=this._isServer?"client":"server";if(!this._inflate){const e=`${i}_max_window_bits`;const t=typeof this.params[e]!=="number"?r.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=r.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t});this._inflate[l]=this;this._inflate[f]=0;this._inflate[d]=[];this._inflate.on("error",inflateOnError);this._inflate.on("data",inflateOnData)}this._inflate[h]=s;this._inflate.write(e);if(t)this._inflate.write(c);this._inflate.flush((()=>{const e=this._inflate[u];if(e){this._inflate.close();this._inflate=null;s(e);return}const r=n.concat(this._inflate[d],this._inflate[f]);if(this._inflate._readableState.endEmitted){this._inflate.close();this._inflate=null}else{this._inflate[f]=0;this._inflate[d]=[];if(t&&this.params[`${i}_no_context_takeover`]){this._inflate.reset()}}s(null,r)}))}_compress(e,t,s){const i=this._isServer?"server":"client";if(!this._deflate){const e=`${i}_max_window_bits`;const t=typeof this.params[e]!=="number"?r.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=r.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t});this._deflate[f]=0;this._deflate[d]=[];this._deflate.on("data",deflateOnData)}this._deflate[h]=s;this._deflate.write(e);this._deflate.flush(r.Z_SYNC_FLUSH,(()=>{if(!this._deflate){return}let e=n.concat(this._deflate[d],this._deflate[f]);if(t){e=new a(e.buffer,e.byteOffset,e.length-4)}this._deflate[h]=null;this._deflate[f]=0;this._deflate[d]=[];if(t&&this.params[`${i}_no_context_takeover`]){this._deflate.reset()}s(null,e)}))}}e.exports=PerMessageDeflate;function deflateOnData(e){this[d].push(e);this[f]+=e.length}function inflateOnData(e){this[f]+=e.length;if(this[l]._maxPayload<1||this[f]<=this[l]._maxPayload){this[d].push(e);return}this[u]=new RangeError("Max payload size exceeded");this[u].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH";this[u][o]=1009;this.removeListener("data",inflateOnData);this.reset()}function inflateOnError(e){this[l]._inflate=null;e[o]=1007;this[h](e)}},997:(e,t,s)=>{"use strict";const{Writable:r}=s(781);const n=s(613);const{BINARY_TYPES:i,EMPTY_BUFFER:o,kStatusCode:a,kWebSocket:c}=s(547);const{concat:l,toArrayBuffer:f,unmask:h}=s(64);const{isValidStatusCode:d,isValidUTF8:u}=s(903);const _=Buffer[Symbol.species];const p=Promise.resolve();const m=typeof queueMicrotask==="function"?queueMicrotask:queueMicrotaskShim;const b=0;const k=1;const S=2;const y=3;const g=4;const E=5;const w=6;class Receiver extends r{constructor(e={}){super();this._allowSynchronousEvents=!!e.allowSynchronousEvents;this._binaryType=e.binaryType||i[0];this._extensions=e.extensions||{};this._isServer=!!e.isServer;this._maxPayload=e.maxPayload|0;this._skipUTF8Validation=!!e.skipUTF8Validation;this[c]=undefined;this._bufferedBytes=0;this._buffers=[];this._compressed=false;this._payloadLength=0;this._mask=undefined;this._fragmented=0;this._masked=false;this._fin=false;this._opcode=0;this._totalPayloadLength=0;this._messageLength=0;this._fragments=[];this._errored=false;this._loop=false;this._state=b}_write(e,t,s){if(this._opcode===8&&this._state==b)return s();this._bufferedBytes+=e.length;this._buffers.push(e);this.startLoop(s)}consume(e){this._bufferedBytes-=e;if(e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){const t=this._buffers[0];this._buffers[0]=new _(t.buffer,t.byteOffset+e,t.length-e);return new _(t.buffer,t.byteOffset,e)}const t=Buffer.allocUnsafe(e);do{const s=this._buffers[0];const r=t.length-e;if(e>=s.length){t.set(this._buffers.shift(),r)}else{t.set(new Uint8Array(s.buffer,s.byteOffset,e),r);this._buffers[0]=new _(s.buffer,s.byteOffset+e,s.length-e)}e-=s.length}while(e>0);return t}startLoop(e){this._loop=true;do{switch(this._state){case b:this.getInfo(e);break;case k:this.getPayloadLength16(e);break;case S:this.getPayloadLength64(e);break;case y:this.getMask();break;case g:this.getData(e);break;case E:case w:this._loop=false;return}}while(this._loop);if(!this._errored)e()}getInfo(e){if(this._bufferedBytes<2){this._loop=false;return}const t=this.consume(2);if((t[0]&48)!==0){const t=this.createError(RangeError,"RSV2 and RSV3 must be clear",true,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(t);return}const s=(t[0]&64)===64;if(s&&!this._extensions[n.extensionName]){const t=this.createError(RangeError,"RSV1 must be clear",true,1002,"WS_ERR_UNEXPECTED_RSV_1");e(t);return}this._fin=(t[0]&128)===128;this._opcode=t[0]&15;this._payloadLength=t[1]&127;if(this._opcode===0){if(s){const t=this.createError(RangeError,"RSV1 must be clear",true,1002,"WS_ERR_UNEXPECTED_RSV_1");e(t);return}if(!this._fragmented){const t=this.createError(RangeError,"invalid opcode 0",true,1002,"WS_ERR_INVALID_OPCODE");e(t);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){const t=this.createError(RangeError,`invalid opcode ${this._opcode}`,true,1002,"WS_ERR_INVALID_OPCODE");e(t);return}this._compressed=s}else if(this._opcode>7&&this._opcode<11){if(!this._fin){const t=this.createError(RangeError,"FIN must be set",true,1002,"WS_ERR_EXPECTED_FIN");e(t);return}if(s){const t=this.createError(RangeError,"RSV1 must be clear",true,1002,"WS_ERR_UNEXPECTED_RSV_1");e(t);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){const t=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,true,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(t);return}}else{const t=this.createError(RangeError,`invalid opcode ${this._opcode}`,true,1002,"WS_ERR_INVALID_OPCODE");e(t);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;this._masked=(t[1]&128)===128;if(this._isServer){if(!this._masked){const t=this.createError(RangeError,"MASK must be set",true,1002,"WS_ERR_EXPECTED_MASK");e(t);return}}else if(this._masked){const t=this.createError(RangeError,"MASK must be clear",true,1002,"WS_ERR_UNEXPECTED_MASK");e(t);return}if(this._payloadLength===126)this._state=k;else if(this._payloadLength===127)this._state=S;else this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=false;return}this._payloadLength=this.consume(2).readUInt16BE(0);this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=false;return}const t=this.consume(8);const s=t.readUInt32BE(0);if(s>Math.pow(2,53-32)-1){const t=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",false,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(t);return}this._payloadLength=s*Math.pow(2,32)+t.readUInt32BE(4);this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8){this._totalPayloadLength+=this._payloadLength;if(this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){const t=this.createError(RangeError,"Max payload size exceeded",false,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(t);return}}if(this._masked)this._state=y;else this._state=g}getMask(){if(this._bufferedBytes<4){this._loop=false;return}this._mask=this.consume(4);this._state=g}getData(e){let t=o;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=false;return}t=this.consume(this._payloadLength);if(this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0){h(t,this._mask)}}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=E;this.decompress(t,e);return}if(t.length){this._messageLength=this._totalPayloadLength;this._fragments.push(t)}this.dataMessage(e)}decompress(e,t){const s=this._extensions[n.extensionName];s.decompress(e,this._fin,((e,s)=>{if(e)return t(e);if(s.length){this._messageLength+=s.length;if(this._messageLength>this._maxPayload&&this._maxPayload>0){const e=this.createError(RangeError,"Max payload size exceeded",false,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(e);return}this._fragments.push(s)}this.dataMessage(t);if(this._state===b)this.startLoop(t)}))}dataMessage(e){if(!this._fin){this._state=b;return}const t=this._messageLength;const s=this._fragments;this._totalPayloadLength=0;this._messageLength=0;this._fragmented=0;this._fragments=[];if(this._opcode===2){let r;if(this._binaryType==="nodebuffer"){r=l(s,t)}else if(this._binaryType==="arraybuffer"){r=f(l(s,t))}else{r=s}if(this._state===E||this._allowSynchronousEvents){this.emit("message",r,true);this._state=b}else{this._state=w;m((()=>{this.emit("message",r,true);this._state=b;this.startLoop(e)}))}}else{const r=l(s,t);if(!this._skipUTF8Validation&&!u(r)){const t=this.createError(Error,"invalid UTF-8 sequence",true,1007,"WS_ERR_INVALID_UTF8");e(t);return}if(this._state===E||this._allowSynchronousEvents){this.emit("message",r,false);this._state=b}else{this._state=w;m((()=>{this.emit("message",r,false);this._state=b;this.startLoop(e)}))}}}controlMessage(e,t){if(this._opcode===8){if(e.length===0){this._loop=false;this.emit("conclude",1005,o);this.end()}else{const s=e.readUInt16BE(0);if(!d(s)){const e=this.createError(RangeError,`invalid status code ${s}`,true,1002,"WS_ERR_INVALID_CLOSE_CODE");t(e);return}const r=new _(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!u(r)){const e=this.createError(Error,"invalid UTF-8 sequence",true,1007,"WS_ERR_INVALID_UTF8");t(e);return}this._loop=false;this.emit("conclude",s,r);this.end()}this._state=b;return}if(this._allowSynchronousEvents){this.emit(this._opcode===9?"ping":"pong",e);this._state=b}else{this._state=w;m((()=>{this.emit(this._opcode===9?"ping":"pong",e);this._state=b;this.startLoop(t)}))}}createError(e,t,s,r,n){this._loop=false;this._errored=true;const i=new e(s?`Invalid WebSocket frame: ${t}`:t);Error.captureStackTrace(i,this.createError);i.code=n;i[a]=r;return i}}e.exports=Receiver;function queueMicrotaskShim(e){p.then(e).catch(throwErrorNextTick)}function throwError(e){throw e}function throwErrorNextTick(e){process.nextTick(throwError,e)}},345:(e,t,s)=>{"use strict";const{Duplex:r}=s(781);const{randomFillSync:n}=s(113);const i=s(613);const{EMPTY_BUFFER:o}=s(547);const{isValidStatusCode:a}=s(903);const{mask:c,toBuffer:l}=s(64);const f=Symbol("kByteLength");const h=Buffer.alloc(4);class Sender{constructor(e,t,s){this._extensions=t||{};if(s){this._generateMask=s;this._maskBuffer=Buffer.alloc(4)}this._socket=e;this._firstFragment=true;this._compress=false;this._bufferedBytes=0;this._deflating=false;this._queue=[]}static frame(e,t){let s;let r=false;let i=2;let o=false;if(t.mask){s=t.maskBuffer||h;if(t.generateMask){t.generateMask(s)}else{n(s,0,4)}o=(s[0]|s[1]|s[2]|s[3])===0;i=6}let a;if(typeof e==="string"){if((!t.mask||o)&&t[f]!==undefined){a=t[f]}else{e=Buffer.from(e);a=e.length}}else{a=e.length;r=t.mask&&t.readOnly&&!o}let l=a;if(a>=65536){i+=8;l=127}else if(a>125){i+=2;l=126}const d=Buffer.allocUnsafe(r?a+i:i);d[0]=t.fin?t.opcode|128:t.opcode;if(t.rsv1)d[0]|=64;d[1]=l;if(l===126){d.writeUInt16BE(a,2)}else if(l===127){d[2]=d[3]=0;d.writeUIntBE(a,4,6)}if(!t.mask)return[d,e];d[1]|=128;d[i-4]=s[0];d[i-3]=s[1];d[i-2]=s[2];d[i-1]=s[3];if(o)return[d,e];if(r){c(e,s,d,i,a);return[d]}c(e,s,e,0,a);return[d,e]}close(e,t,s,r){let n;if(e===undefined){n=o}else if(typeof e!=="number"||!a(e)){throw new TypeError("First argument must be a valid error code number")}else if(t===undefined||!t.length){n=Buffer.allocUnsafe(2);n.writeUInt16BE(e,0)}else{const s=Buffer.byteLength(t);if(s>123){throw new RangeError("The message must not be greater than 123 bytes")}n=Buffer.allocUnsafe(2+s);n.writeUInt16BE(e,0);if(typeof t==="string"){n.write(t,2)}else{n.set(t,2)}}const i={[f]:n.length,fin:true,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:false,rsv1:false};if(this._deflating){this.enqueue([this.dispatch,n,false,i,r])}else{this.sendFrame(Sender.frame(n,i),r)}}ping(e,t,s){let r;let n;if(typeof e==="string"){r=Buffer.byteLength(e);n=false}else{e=l(e);r=e.length;n=l.readOnly}if(r>125){throw new RangeError("The data size must not be greater than 125 bytes")}const i={[f]:r,fin:true,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:false};if(this._deflating){this.enqueue([this.dispatch,e,false,i,s])}else{this.sendFrame(Sender.frame(e,i),s)}}pong(e,t,s){let r;let n;if(typeof e==="string"){r=Buffer.byteLength(e);n=false}else{e=l(e);r=e.length;n=l.readOnly}if(r>125){throw new RangeError("The data size must not be greater than 125 bytes")}const i={[f]:r,fin:true,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:false};if(this._deflating){this.enqueue([this.dispatch,e,false,i,s])}else{this.sendFrame(Sender.frame(e,i),s)}}send(e,t,s){const r=this._extensions[i.extensionName];let n=t.binary?2:1;let o=t.compress;let a;let c;if(typeof e==="string"){a=Buffer.byteLength(e);c=false}else{e=l(e);a=e.length;c=l.readOnly}if(this._firstFragment){this._firstFragment=false;if(o&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]){o=a>=r._threshold}this._compress=o}else{o=false;n=0}if(t.fin)this._firstFragment=true;if(r){const r={[f]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:c,rsv1:o};if(this._deflating){this.enqueue([this.dispatch,e,this._compress,r,s])}else{this.dispatch(e,this._compress,r,s)}}else{this.sendFrame(Sender.frame(e,{[f]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:c,rsv1:false}),s)}}dispatch(e,t,s,r){if(!t){this.sendFrame(Sender.frame(e,s),r);return}const n=this._extensions[i.extensionName];this._bufferedBytes+=s[f];this._deflating=true;n.compress(e,s.fin,((e,t)=>{if(this._socket.destroyed){const e=new Error("The socket was closed while data was being compressed");if(typeof r==="function")r(e);for(let t=0;t<this._queue.length;t++){const s=this._queue[t];const r=s[s.length-1];if(typeof r==="function")r(e)}return}this._bufferedBytes-=s[f];this._deflating=false;s.readOnly=false;this.sendFrame(Sender.frame(t,s),r);this.dequeue()}))}dequeue(){while(!this._deflating&&this._queue.length){const e=this._queue.shift();this._bufferedBytes-=e[3][f];Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][f];this._queue.push(e)}sendFrame(e,t){if(e.length===2){this._socket.cork();this._socket.write(e[0]);this._socket.write(e[1],t);this._socket.uncork()}else{this._socket.write(e[0],t)}}}e.exports=Sender},334:(e,t,s)=>{"use strict";const{Duplex:r}=s(781);function emitClose(e){e.emit("close")}function duplexOnEnd(){if(!this.destroyed&&this._writableState.finished){this.destroy()}}function duplexOnError(e){this.removeListener("error",duplexOnError);this.destroy();if(this.listenerCount("error")===0){this.emit("error",e)}}function createWebSocketStream(e,t){let s=true;const n=new r({...t,autoDestroy:false,emitClose:false,objectMode:false,writableObjectMode:false});e.on("message",(function message(t,s){const r=!s&&n._readableState.objectMode?t.toString():t;if(!n.push(r))e.pause()}));e.once("error",(function error(e){if(n.destroyed)return;s=false;n.destroy(e)}));e.once("close",(function close(){if(n.destroyed)return;n.push(null)}));n._destroy=function(t,r){if(e.readyState===e.CLOSED){r(t);process.nextTick(emitClose,n);return}let i=false;e.once("error",(function error(e){i=true;r(e)}));e.once("close",(function close(){if(!i)r(t);process.nextTick(emitClose,n)}));if(s)e.terminate()};n._final=function(t){if(e.readyState===e.CONNECTING){e.once("open",(function open(){n._final(t)}));return}if(e._socket===null)return;if(e._socket._writableState.finished){t();if(n._readableState.endEmitted)n.destroy()}else{e._socket.once("finish",(function finish(){t()}));e.close()}};n._read=function(){if(e.isPaused)e.resume()};n._write=function(t,s,r){if(e.readyState===e.CONNECTING){e.once("open",(function open(){n._write(t,s,r)}));return}e.send(t,r)};n.on("end",duplexOnEnd);n.on("error",duplexOnError);return n}e.exports=createWebSocketStream},320:(e,t,s)=>{"use strict";const{tokenChars:r}=s(903);function parse(e){const t=new Set;let s=-1;let n=-1;let i=0;for(i;i<e.length;i++){const o=e.charCodeAt(i);if(n===-1&&r[o]===1){if(s===-1)s=i}else if(i!==0&&(o===32||o===9)){if(n===-1&&s!==-1)n=i}else if(o===44){if(s===-1){throw new SyntaxError(`Unexpected character at index ${i}`)}if(n===-1)n=i;const r=e.slice(s,n);if(t.has(r)){throw new SyntaxError(`The "${r}" subprotocol is duplicated`)}t.add(r);s=n=-1}else{throw new SyntaxError(`Unexpected character at index ${i}`)}}if(s===-1||n!==-1){throw new SyntaxError("Unexpected end of input")}const o=e.slice(s,i);if(t.has(o)){throw new SyntaxError(`The "${o}" subprotocol is duplicated`)}t.add(o);return t}e.exports={parse:parse}},903:(e,t,s)=>{"use strict";const{isUtf8:r}=s(300);const n=[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];function isValidStatusCode(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function _isValidUTF8(e){const t=e.length;let s=0;while(s<t){if((e[s]&128)===0){s++}else if((e[s]&224)===192){if(s+1===t||(e[s+1]&192)!==128||(e[s]&254)===192){return false}s+=2}else if((e[s]&240)===224){if(s+2>=t||(e[s+1]&192)!==128||(e[s+2]&192)!==128||e[s]===224&&(e[s+1]&224)===128||e[s]===237&&(e[s+1]&224)===160){return false}s+=3}else if((e[s]&248)===240){if(s+3>=t||(e[s+1]&192)!==128||(e[s+2]&192)!==128||(e[s+3]&192)!==128||e[s]===240&&(e[s+1]&240)===128||e[s]===244&&e[s+1]>143||e[s]>244){return false}s+=4}else{return false}}return true}e.exports={isValidStatusCode:isValidStatusCode,isValidUTF8:_isValidUTF8,tokenChars:n};if(r){e.exports.isValidUTF8=function(e){return e.length<24?_isValidUTF8(e):r(e)}}else if(!process.env.WS_NO_UTF_8_VALIDATE){try{const t=s(177);e.exports.isValidUTF8=function(e){return e.length<32?_isValidUTF8(e):t(e)}}catch(e){}}},69:(e,t,s)=>{"use strict";const r=s(361);const n=s(685);const{Duplex:i}=s(781);const{createHash:o}=s(113);const a=s(321);const c=s(613);const l=s(320);const f=s(885);const{GUID:h,kWebSocket:d}=s(547);const u=/^[+/0-9A-Za-z]{22}==$/;const _=0;const p=1;const m=2;class WebSocketServer extends r{constructor(e,t){super();e={allowSynchronousEvents:false,autoPong:true,maxPayload:100*1024*1024,skipUTF8Validation:false,perMessageDeflate:false,handleProtocols:null,clientTracking:true,verifyClient:null,noServer:false,backlog:null,server:null,host:null,path:null,port:null,WebSocket:f,...e};if(e.port==null&&!e.server&&!e.noServer||e.port!=null&&(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(e.port!=null){this._server=n.createServer(((e,t)=>{const s=n.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)}else if(e.server){this._server=e.server}if(this._server){const e=this.emit.bind(this,"connection");this._removeListeners=addListeners(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,s,r)=>{this.handleUpgrade(t,s,r,e)}})}if(e.perMessageDeflate===true)e.perMessageDeflate={};if(e.clientTracking){this.clients=new Set;this._shouldEmitClose=false}this.options=e;this._state=_}address(){if(this.options.noServer){throw new Error('The server is operating in "noServer" mode')}if(!this._server)return null;return this._server.address()}close(e){if(this._state===m){if(e){this.once("close",(()=>{e(new Error("The server is not running"))}))}process.nextTick(emitClose,this);return}if(e)this.once("close",e);if(this._state===p)return;this._state=p;if(this.options.noServer||this.options.server){if(this._server){this._removeListeners();this._removeListeners=this._server=null}if(this.clients){if(!this.clients.size){process.nextTick(emitClose,this)}else{this._shouldEmitClose=true}}else{process.nextTick(emitClose,this)}}else{const e=this._server;this._removeListeners();this._removeListeners=this._server=null;e.close((()=>{emitClose(this)}))}}shouldHandle(e){if(this.options.path){const t=e.url.indexOf("?");const s=t!==-1?e.url.slice(0,t):e.url;if(s!==this.options.path)return false}return true}handleUpgrade(e,t,s,r){t.on("error",socketOnError);const n=e.headers["sec-websocket-key"];const i=+e.headers["sec-websocket-version"];if(e.method!=="GET"){const s="Invalid HTTP method";abortHandshakeOrEmitwsClientError(this,e,t,405,s);return}if(e.headers.upgrade.toLowerCase()!=="websocket"){const s="Invalid Upgrade header";abortHandshakeOrEmitwsClientError(this,e,t,400,s);return}if(!n||!u.test(n)){const s="Missing or invalid Sec-WebSocket-Key header";abortHandshakeOrEmitwsClientError(this,e,t,400,s);return}if(i!==8&&i!==13){const s="Missing or invalid Sec-WebSocket-Version header";abortHandshakeOrEmitwsClientError(this,e,t,400,s);return}if(!this.shouldHandle(e)){abortHandshake(t,400);return}const o=e.headers["sec-websocket-protocol"];let f=new Set;if(o!==undefined){try{f=l.parse(o)}catch(s){const r="Invalid Sec-WebSocket-Protocol header";abortHandshakeOrEmitwsClientError(this,e,t,400,r);return}}const h=e.headers["sec-websocket-extensions"];const d={};if(this.options.perMessageDeflate&&h!==undefined){const s=new c(this.options.perMessageDeflate,true,this.options.maxPayload);try{const e=a.parse(h);if(e[c.extensionName]){s.accept(e[c.extensionName]);d[c.extensionName]=s}}catch(s){const r="Invalid or unacceptable Sec-WebSocket-Extensions header";abortHandshakeOrEmitwsClientError(this,e,t,400,r);return}}if(this.options.verifyClient){const o={origin:e.headers[`${i===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(o,((i,o,a,c)=>{if(!i){return abortHandshake(t,o||401,a,c)}this.completeUpgrade(d,n,f,e,t,s,r)}));return}if(!this.options.verifyClient(o))return abortHandshake(t,401)}this.completeUpgrade(d,n,f,e,t,s,r)}completeUpgrade(e,t,s,r,n,i,l){if(!n.readable||!n.writable)return n.destroy();if(n[d]){throw new Error("server.handleUpgrade() was called more than once with the same "+"socket, possibly due to a misconfiguration")}if(this._state>_)return abortHandshake(n,503);const f=o("sha1").update(t+h).digest("base64");const u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${f}`];const p=new this.options.WebSocket(null,undefined,this.options);if(s.size){const e=this.options.handleProtocols?this.options.handleProtocols(s,r):s.values().next().value;if(e){u.push(`Sec-WebSocket-Protocol: ${e}`);p._protocol=e}}if(e[c.extensionName]){const t=e[c.extensionName].params;const s=a.format({[c.extensionName]:[t]});u.push(`Sec-WebSocket-Extensions: ${s}`);p._extensions=e}this.emit("headers",u,r);n.write(u.concat("\r\n").join("\r\n"));n.removeListener("error",socketOnError);p.setSocket(n,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation});if(this.clients){this.clients.add(p);p.on("close",(()=>{this.clients.delete(p);if(this._shouldEmitClose&&!this.clients.size){process.nextTick(emitClose,this)}}))}l(p,r)}}e.exports=WebSocketServer;function addListeners(e,t){for(const s of Object.keys(t))e.on(s,t[s]);return function removeListeners(){for(const s of Object.keys(t)){e.removeListener(s,t[s])}}}function emitClose(e){e._state=m;e.emit("close")}function socketOnError(){this.destroy()}function abortHandshake(e,t,s,r){s=s||n.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} ${n.STATUS_CODES[t]}\r\n`+Object.keys(r).map((e=>`${e}: ${r[e]}`)).join("\r\n")+"\r\n\r\n"+s)}function abortHandshakeOrEmitwsClientError(e,t,s,r,n){if(e.listenerCount("wsClientError")){const r=new Error(n);Error.captureStackTrace(r,abortHandshakeOrEmitwsClientError);e.emit("wsClientError",r,s,t)}else{abortHandshake(s,r,n)}}},885:(e,t,s)=>{"use strict";const r=s(361);const n=s(687);const i=s(685);const o=s(808);const a=s(404);const{randomBytes:c,createHash:l}=s(113);const{Duplex:f,Readable:h}=s(781);const{URL:d}=s(310);const u=s(613);const _=s(997);const p=s(345);const{BINARY_TYPES:m,EMPTY_BUFFER:b,GUID:k,kForOnEventAttribute:S,kListener:y,kStatusCode:g,kWebSocket:E,NOOP:w}=s(547);const{EventTarget:{addEventListener:v,removeEventListener:x}}=s(874);const{format:O,parse:C}=s(321);const{toBuffer:T}=s(64);const L=30*1e3;const N=Symbol("kAborted");const P=[8,13];const W=["CONNECTING","OPEN","CLOSING","CLOSED"];const B=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class WebSocket extends r{constructor(e,t,s){super();this._binaryType=m[0];this._closeCode=1006;this._closeFrameReceived=false;this._closeFrameSent=false;this._closeMessage=b;this._closeTimer=null;this._extensions={};this._paused=false;this._protocol="";this._readyState=WebSocket.CONNECTING;this._receiver=null;this._sender=null;this._socket=null;if(e!==null){this._bufferedAmount=0;this._isServer=false;this._redirects=0;if(t===undefined){t=[]}else if(!Array.isArray(t)){if(typeof t==="object"&&t!==null){s=t;t=[]}else{t=[t]}}initAsClient(this,e,t,s)}else{this._autoPong=s.autoPong;this._isServer=true}}get binaryType(){return this._binaryType}set binaryType(e){if(!m.includes(e))return;this._binaryType=e;if(this._receiver)this._receiver._binaryType=e}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}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 _({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation});this._sender=new p(e,this._extensions,s.generateMask);this._receiver=r;this._socket=e;r[E]=this;e[E]=this;r.on("conclude",receiverOnConclude);r.on("drain",receiverOnDrain);r.on("error",receiverOnError);r.on("message",receiverOnMessage);r.on("ping",receiverOnPing);r.on("pong",receiverOnPong);if(e.setTimeout)e.setTimeout(0);if(e.setNoDelay)e.setNoDelay();if(t.length>0)e.unshift(t);e.on("close",socketOnClose);e.on("data",socketOnData);e.on("end",socketOnEnd);e.on("error",socketOnError);this._readyState=WebSocket.OPEN;this.emit("open")}emitClose(){if(!this._socket){this._readyState=WebSocket.CLOSED;this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[u.extensionName]){this._extensions[u.extensionName].cleanup()}this._receiver.removeAllListeners();this._readyState=WebSocket.CLOSED;this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState===WebSocket.CLOSED)return;if(this.readyState===WebSocket.CONNECTING){const e="WebSocket was closed before the connection was established";abortHandshake(this,this._req,e);return}if(this.readyState===WebSocket.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)){this._socket.end()}return}this._readyState=WebSocket.CLOSING;this._sender.close(e,t,!this._isServer,(e=>{if(e)return;this._closeFrameSent=true;if(this._closeFrameReceived||this._receiver._writableState.errorEmitted){this._socket.end()}}));this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),L)}pause(){if(this.readyState===WebSocket.CONNECTING||this.readyState===WebSocket.CLOSED){return}this._paused=true;this._socket.pause()}ping(e,t,s){if(this.readyState===WebSocket.CONNECTING){throw new Error("WebSocket is not open: readyState 0 (CONNECTING)")}if(typeof e==="function"){s=e;e=t=undefined}else if(typeof t==="function"){s=t;t=undefined}if(typeof e==="number")e=e.toString();if(this.readyState!==WebSocket.OPEN){sendAfterClose(this,e,s);return}if(t===undefined)t=!this._isServer;this._sender.ping(e||b,t,s)}pong(e,t,s){if(this.readyState===WebSocket.CONNECTING){throw new Error("WebSocket is not open: readyState 0 (CONNECTING)")}if(typeof e==="function"){s=e;e=t=undefined}else if(typeof t==="function"){s=t;t=undefined}if(typeof e==="number")e=e.toString();if(this.readyState!==WebSocket.OPEN){sendAfterClose(this,e,s);return}if(t===undefined)t=!this._isServer;this._sender.pong(e||b,t,s)}resume(){if(this.readyState===WebSocket.CONNECTING||this.readyState===WebSocket.CLOSED){return}this._paused=false;if(!this._receiver._writableState.needDrain)this._socket.resume()}send(e,t,s){if(this.readyState===WebSocket.CONNECTING){throw new Error("WebSocket is not open: readyState 0 (CONNECTING)")}if(typeof t==="function"){s=t;t={}}if(typeof e==="number")e=e.toString();if(this.readyState!==WebSocket.OPEN){sendAfterClose(this,e,s);return}const r={binary:typeof e!=="string",mask:!this._isServer,compress:true,fin:true,...t};if(!this._extensions[u.extensionName]){r.compress=false}this._sender.send(e||b,r,s)}terminate(){if(this.readyState===WebSocket.CLOSED)return;if(this.readyState===WebSocket.CONNECTING){const e="WebSocket was closed before the connection was established";abortHandshake(this,this._req,e);return}if(this._socket){this._readyState=WebSocket.CLOSING;this._socket.destroy()}}}Object.defineProperty(WebSocket,"CONNECTING",{enumerable:true,value:W.indexOf("CONNECTING")});Object.defineProperty(WebSocket.prototype,"CONNECTING",{enumerable:true,value:W.indexOf("CONNECTING")});Object.defineProperty(WebSocket,"OPEN",{enumerable:true,value:W.indexOf("OPEN")});Object.defineProperty(WebSocket.prototype,"OPEN",{enumerable:true,value:W.indexOf("OPEN")});Object.defineProperty(WebSocket,"CLOSING",{enumerable:true,value:W.indexOf("CLOSING")});Object.defineProperty(WebSocket.prototype,"CLOSING",{enumerable:true,value:W.indexOf("CLOSING")});Object.defineProperty(WebSocket,"CLOSED",{enumerable:true,value:W.indexOf("CLOSED")});Object.defineProperty(WebSocket.prototype,"CLOSED",{enumerable:true,value:W.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((e=>{Object.defineProperty(WebSocket.prototype,e,{enumerable:true})}));["open","error","close","message"].forEach((e=>{Object.defineProperty(WebSocket.prototype,`on${e}`,{enumerable:true,get(){for(const t of this.listeners(e)){if(t[S])return t[y]}return null},set(t){for(const t of this.listeners(e)){if(t[S]){this.removeListener(e,t);break}}if(typeof t!=="function")return;this.addEventListener(e,t,{[S]:true})}})}));WebSocket.prototype.addEventListener=v;WebSocket.prototype.removeEventListener=x;e.exports=WebSocket;function initAsClient(e,t,s,r){const o={allowSynchronousEvents:false,autoPong:true,protocolVersion:P[1],maxPayload:100*1024*1024,skipUTF8Validation:false,perMessageDeflate:true,followRedirects:false,maxRedirects:10,...r,createConnection:undefined,socketPath:undefined,hostname:undefined,protocol:undefined,timeout:undefined,method:"GET",host:undefined,path:undefined,port:undefined};e._autoPong=o.autoPong;if(!P.includes(o.protocolVersion)){throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} `+`(supported versions: ${P.join(", ")})`)}let a;if(t instanceof d){a=t}else{try{a=new d(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}}if(a.protocol==="http:"){a.protocol="ws:"}else if(a.protocol==="https:"){a.protocol="wss:"}e._url=a.href;const f=a.protocol==="wss:";const h=a.protocol==="ws+unix:";let _;if(a.protocol!=="ws:"&&!f&&!h){_='The URL\'s protocol must be one of "ws:", "wss:", '+'"http:", "https", or "ws+unix:"'}else if(h&&!a.pathname){_="The URL's pathname is empty"}else if(a.hash){_="The URL contains a fragment identifier"}if(_){const t=new SyntaxError(_);if(e._redirects===0){throw t}else{emitErrorAndClose(e,t);return}}const p=f?443:80;const m=c(16).toString("base64");const b=f?n.request:i.request;const S=new Set;let y;o.createConnection=f?tlsConnect:netConnect;o.defaultPort=o.defaultPort||p;o.port=a.port||p;o.host=a.hostname.startsWith("[")?a.hostname.slice(1,-1):a.hostname;o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":m,Connection:"Upgrade",Upgrade:"websocket"};o.path=a.pathname+a.search;o.timeout=o.handshakeTimeout;if(o.perMessageDeflate){y=new u(o.perMessageDeflate!==true?o.perMessageDeflate:{},false,o.maxPayload);o.headers["Sec-WebSocket-Extensions"]=O({[u.extensionName]:y.offer()})}if(s.length){for(const e of s){if(typeof e!=="string"||!B.test(e)||S.has(e)){throw new SyntaxError("An invalid or duplicated subprotocol was specified")}S.add(e)}o.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(o.origin){if(o.protocolVersion<13){o.headers["Sec-WebSocket-Origin"]=o.origin}else{o.headers.Origin=o.origin}}if(a.username||a.password){o.auth=`${a.username}:${a.password}`}if(h){const e=o.path.split(":");o.socketPath=e[0];o.path=e[1]}let g;if(o.followRedirects){if(e._redirects===0){e._originalIpc=h;e._originalSecure=f;e._originalHostOrSocketPath=h?o.socketPath:a.host;const t=r&&r.headers;r={...r,headers:{}};if(t){for(const[e,s]of Object.entries(t)){r.headers[e.toLowerCase()]=s}}}else if(e.listenerCount("redirect")===0){const t=h?e._originalIpc?o.socketPath===e._originalHostOrSocketPath:false:e._originalIpc?false:a.host===e._originalHostOrSocketPath;if(!t||e._originalSecure&&!f){delete o.headers.authorization;delete o.headers.cookie;if(!t)delete o.headers.host;o.auth=undefined}}if(o.auth&&!r.headers.authorization){r.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")}g=e._req=b(o);if(e._redirects){e.emit("redirect",e.url,g)}}else{g=e._req=b(o)}if(o.timeout){g.on("timeout",(()=>{abortHandshake(e,g,"Opening handshake has timed out")}))}g.on("error",(t=>{if(g===null||g[N])return;g=e._req=null;emitErrorAndClose(e,t)}));g.on("response",(n=>{const i=n.headers.location;const a=n.statusCode;if(i&&o.followRedirects&&a>=300&&a<400){if(++e._redirects>o.maxRedirects){abortHandshake(e,g,"Maximum redirects exceeded");return}g.abort();let n;try{n=new d(i,t)}catch(t){const s=new SyntaxError(`Invalid URL: ${i}`);emitErrorAndClose(e,s);return}initAsClient(e,n,s,r)}else if(!e.emit("unexpected-response",g,n)){abortHandshake(e,g,`Unexpected server response: ${n.statusCode}`)}}));g.on("upgrade",((t,s,r)=>{e.emit("upgrade",t);if(e.readyState!==WebSocket.CONNECTING)return;g=e._req=null;if(t.headers.upgrade.toLowerCase()!=="websocket"){abortHandshake(e,s,"Invalid Upgrade header");return}const n=l("sha1").update(m+k).digest("base64");if(t.headers["sec-websocket-accept"]!==n){abortHandshake(e,s,"Invalid Sec-WebSocket-Accept header");return}const i=t.headers["sec-websocket-protocol"];let a;if(i!==undefined){if(!S.size){a="Server sent a subprotocol but none was requested"}else if(!S.has(i)){a="Server sent an invalid subprotocol"}}else if(S.size){a="Server sent no subprotocol"}if(a){abortHandshake(e,s,a);return}if(i)e._protocol=i;const c=t.headers["sec-websocket-extensions"];if(c!==undefined){if(!y){const t="Server sent a Sec-WebSocket-Extensions header but no extension "+"was requested";abortHandshake(e,s,t);return}let t;try{t=C(c)}catch(t){const r="Invalid Sec-WebSocket-Extensions header";abortHandshake(e,s,r);return}const r=Object.keys(t);if(r.length!==1||r[0]!==u.extensionName){const t="Server indicated an extension that was not requested";abortHandshake(e,s,t);return}try{y.accept(t[u.extensionName])}catch(t){const r="Invalid Sec-WebSocket-Extensions header";abortHandshake(e,s,r);return}e._extensions[u.extensionName]=y}e.setSocket(s,r,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}));if(o.finishRequest){o.finishRequest(g,e)}else{g.end()}}function emitErrorAndClose(e,t){e._readyState=WebSocket.CLOSING;e.emit("error",t);e.emitClose()}function netConnect(e){e.path=e.socketPath;return o.connect(e)}function tlsConnect(e){e.path=undefined;if(!e.servername&&e.servername!==""){e.servername=o.isIP(e.host)?"":e.host}return a.connect(e)}function abortHandshake(e,t,s){e._readyState=WebSocket.CLOSING;const r=new Error(s);Error.captureStackTrace(r,abortHandshake);if(t.setHeader){t[N]=true;t.abort();if(t.socket&&!t.socket.destroyed){t.socket.destroy()}process.nextTick(emitErrorAndClose,e,r)}else{t.destroy(r);t.once("error",e.emit.bind(e,"error"));t.once("close",e.emitClose.bind(e))}}function sendAfterClose(e,t,s){if(t){const s=T(t).length;if(e._socket)e._sender._bufferedBytes+=s;else e._bufferedAmount+=s}if(s){const t=new Error(`WebSocket is not open: readyState ${e.readyState} `+`(${W[e.readyState]})`);process.nextTick(s,t)}}function receiverOnConclude(e,t){const s=this[E];s._closeFrameReceived=true;s._closeMessage=t;s._closeCode=e;if(s._socket[E]===undefined)return;s._socket.removeListener("data",socketOnData);process.nextTick(resume,s._socket);if(e===1005)s.close();else s.close(e,t)}function receiverOnDrain(){const e=this[E];if(!e.isPaused)e._socket.resume()}function receiverOnError(e){const t=this[E];if(t._socket[E]!==undefined){t._socket.removeListener("data",socketOnData);process.nextTick(resume,t._socket);t.close(e[g])}t.emit("error",e)}function receiverOnFinish(){this[E].emitClose()}function receiverOnMessage(e,t){this[E].emit("message",e,t)}function receiverOnPing(e){const t=this[E];if(t._autoPong)t.pong(e,!this._isServer,w);t.emit("ping",e)}function receiverOnPong(e){this[E].emit("pong",e)}function resume(e){e.resume()}function socketOnClose(){const e=this[E];this.removeListener("close",socketOnClose);this.removeListener("data",socketOnData);this.removeListener("end",socketOnEnd);e._readyState=WebSocket.CLOSING;let t;if(!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&(t=e._socket.read())!==null){e._receiver.write(t)}e._receiver.end();this[E]=undefined;clearTimeout(e._closeTimer);if(e._receiver._writableState.finished||e._receiver._writableState.errorEmitted){e.emitClose()}else{e._receiver.on("error",receiverOnFinish);e._receiver.on("finish",receiverOnFinish)}}function socketOnData(e){if(!this[E]._receiver.write(e)){this.pause()}}function socketOnEnd(){const e=this[E];e._readyState=WebSocket.CLOSING;e._receiver.end();this.end()}function socketOnError(){const e=this[E];this.removeListener("error",socketOnError);this.on("error",w);if(e){e._readyState=WebSocket.CLOSING;this.destroy()}}},471:module=>{module.exports=eval("require")("bufferutil")},177:module=>{module.exports=eval("require")("utf-8-validate")},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")}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var s=__webpack_module_cache__[e]={exports:{}};var r=true;try{__webpack_modules__[e](s,s.exports,__nccwpck_require__);r=false}finally{if(r)delete __webpack_module_cache__[e]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__=__nccwpck_require__(201);module.exports=__webpack_exports__})();
@@ -1 +1 @@
1
- {"name":"ws","author":"Einar Otto Stangvik <einaros@gmail.com> (http://2x.io)","version":"8.14.2","license":"MIT","type":"commonjs"}
1
+ {"name":"ws","author":"Einar Otto Stangvik <einaros@gmail.com> (http://2x.io)","version":"8.16.0","license":"MIT","type":"commonjs"}
@@ -39,7 +39,7 @@ const applyServerOptions = (command) => {
39
39
  command.option("-o --open [url]", "open the page in browser on startup").option("--port <port>", "specify a port number for server to listen").option("--host <host>", "specify the host that the server listens to");
40
40
  };
41
41
  function runCli() {
42
- import_commander.program.name("rsbuild").usage("<command> [options]").version("0.5.1");
42
+ import_commander.program.name("rsbuild").usage("<command> [options]").version("0.5.2");
43
43
  const devCommand = import_commander.program.command("dev");
44
44
  const buildCommand = import_commander.program.command("build");
45
45
  const previewCommand = import_commander.program.command("preview");
@@ -34,7 +34,7 @@ function prepareCli() {
34
34
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
35
35
  console.log();
36
36
  }
37
- import_rslog.logger.greet(` ${`Rsbuild v${"0.5.1"}`}
37
+ import_rslog.logger.greet(` ${`Rsbuild v${"0.5.2"}`}
38
38
  `);
39
39
  }
40
40
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.js CHANGED
@@ -38,7 +38,7 @@ var import_config = require("./config");
38
38
  var import_shared = require("@rsbuild/shared");
39
39
  var import_mergeConfig = require("./mergeConfig");
40
40
  var import_constants = require("./constants");
41
- const version = "0.5.1";
41
+ const version = "0.5.2";
42
42
  // Annotate the CommonJS export names for ESM import in node:
43
43
  0 && (module.exports = {
44
44
  PLUGIN_CSS_NAME,
@@ -171,7 +171,7 @@ const pluginHtml = () => ({
171
171
  const entryNames = Object.keys(entries);
172
172
  const htmlPaths = api.getHTMLPaths();
173
173
  const htmlInfoMap = {};
174
- await Promise.all(
174
+ const finalOptions = await Promise.all(
175
175
  entryNames.map(async (entryName) => {
176
176
  const entryValue = entries[entryName].values();
177
177
  const chunks = getChunks(
@@ -221,7 +221,7 @@ const pluginHtml = () => ({
221
221
  pluginOptions.favicon = favicon;
222
222
  }
223
223
  }
224
- const finalOptions = (0, import_shared.mergeChainedOptions)({
224
+ const finalOptions2 = (0, import_shared.mergeChainedOptions)({
225
225
  defaults: pluginOptions,
226
226
  options: typeof config.tools.htmlPlugin === "boolean" ? {} : config.tools.htmlPlugin,
227
227
  utils: {
@@ -229,9 +229,12 @@ const pluginHtml = () => ({
229
229
  entryValue
230
230
  }
231
231
  });
232
- chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).use(HtmlPlugin, [finalOptions]);
232
+ return finalOptions2;
233
233
  })
234
234
  );
235
+ entryNames.forEach((entryName, index) => {
236
+ chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).use(HtmlPlugin, [finalOptions[index]]);
237
+ });
235
238
  const { HtmlBasicPlugin } = await Promise.resolve().then(() => __toESM(require("../rspack/HtmlBasicPlugin")));
236
239
  chain.plugin(CHAIN_ID.PLUGIN.HTML_BASIC).use(HtmlBasicPlugin, [htmlInfoMap]);
237
240
  if (config.security) {
@@ -53,7 +53,7 @@ const pluginInlineChunk = () => ({
53
53
  if (!scriptTests.length && !styleTests.length) {
54
54
  return;
55
55
  }
56
- chain.plugin(CHAIN_ID.PLUGIN.INLINE_HTML).use(InlineChunkHtmlPlugin, [
56
+ chain.plugin(CHAIN_ID.PLUGIN.INLINE_HTML).before(CHAIN_ID.PLUGIN.HTML_NONCE).use(InlineChunkHtmlPlugin, [
57
57
  {
58
58
  styleTests,
59
59
  scriptTests,
@@ -44,7 +44,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
44
44
  const context = {
45
45
  entry: (0, import_entry.getEntryObject)(config, "web"),
46
46
  targets: config.output?.targets || [],
47
- version: "0.5.1",
47
+ version: "0.5.2",
48
48
  rootPath,
49
49
  distPath,
50
50
  cachePath,
@@ -27,6 +27,7 @@ __export(HtmlNoncePlugin_exports, {
27
27
  });
28
28
  module.exports = __toCommonJS(HtmlNoncePlugin_exports);
29
29
  var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
30
+ var import_shared = require("@rsbuild/shared");
30
31
  class HtmlNoncePlugin {
31
32
  constructor(options) {
32
33
  __publicField(this, "name");
@@ -39,15 +40,23 @@ class HtmlNoncePlugin {
39
40
  if (!this.nonce) {
40
41
  return;
41
42
  }
43
+ const injectCode = (0, import_shared.createVirtualModule)(
44
+ `__webpack_nonce__ = "${this.nonce}";`
45
+ );
46
+ new compiler.webpack.EntryPlugin(compiler.context, injectCode, {
47
+ name: void 0
48
+ }).apply(compiler);
42
49
  compiler.hooks.compilation.tap(this.name, (compilation) => {
43
- (0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation).alterAssetTags.tap(this.name, (alterAssetTags) => {
44
- const {
45
- assetTags: { scripts }
46
- } = alterAssetTags;
47
- for (const script of scripts) {
48
- script.attributes.nonce = this.nonce;
50
+ (0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation).alterAssetTagGroups.tap(this.name, (data) => {
51
+ const { headTags, bodyTags } = data;
52
+ const allTags = [...headTags, ...bodyTags];
53
+ for (const tag of allTags) {
54
+ if (tag.tagName === "script" || tag.tagName === "style") {
55
+ tag.attributes ?? (tag.attributes = {});
56
+ tag.attributes.nonce = this.nonce;
57
+ }
49
58
  }
50
- return alterAssetTags;
59
+ return data;
51
60
  });
52
61
  });
53
62
  }
@@ -101,6 +101,14 @@ const applyDefaultMiddlewares = async ({
101
101
  upgradeEvents.push(
102
102
  compileMiddlewareAPI.onUpgrade.bind(compileMiddlewareAPI)
103
103
  );
104
+ middlewares.push((req, res, next) => {
105
+ if (req.url?.endsWith(".hot-update.json")) {
106
+ res.statusCode = 404;
107
+ res.end();
108
+ } else {
109
+ next();
110
+ }
111
+ });
104
112
  }
105
113
  if (dev.publicDir !== false && dev.publicDir?.name) {
106
114
  const { default: sirv } = await Promise.resolve().then(() => __toESM(require("../../compiled/sirv")));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -57,7 +57,7 @@
57
57
  "core-js": "~3.36.0",
58
58
  "html-webpack-plugin": "npm:html-rspack-plugin@5.6.2",
59
59
  "postcss": "^8.4.33",
60
- "@rsbuild/shared": "0.5.1"
60
+ "@rsbuild/shared": "0.5.2"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/node": "16.x",