@php-wasm/xdebug-bridge 2.0.22 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const i=require("./run-cli-Bk1CbeEI.cjs");i.main();
1
+ "use strict";const i=require("./run-cli-Ca3F82Ga.cjs");i.main();
package/cli.js CHANGED
@@ -1,2 +1,2 @@
1
- import { m } from "./run-cli-DSVIAiTE.js";
1
+ import { m } from "./run-cli-Czst-QEr.js";
2
2
  m();
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./run-cli-Bk1CbeEI.cjs");exports.CDPServer=e.CDPServer;exports.DbgpSession=e.DbgpSession;exports.XdebugCDPBridge=e.XdebugCDPBridge;exports.main=e.main;exports.startBridge=e.startBridge;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./run-cli-Ca3F82Ga.cjs");exports.CDPServer=e.CDPServer;exports.DbgpSession=e.DbgpSession;exports.XdebugCDPBridge=e.XdebugCDPBridge;exports.main=e.main;exports.startBridge=e.startBridge;
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as e, D as r, X as g, m as i, s as D } from "./run-cli-DSVIAiTE.js";
1
+ import { C as e, D as r, X as g, m as i, s as D } from "./run-cli-Czst-QEr.js";
2
2
  export {
3
3
  e as CDPServer,
4
4
  r as DbgpSession,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/xdebug-bridge",
3
- "version": "2.0.22",
3
+ "version": "3.0.1",
4
4
  "description": "XDebug bridge server for PHP.wasm",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "license": "GPL-2.0-or-later",
41
41
  "types": "index.d.ts",
42
- "gitHead": "4ba4984b3ab981acafc5d7139258985d345f1caf",
42
+ "gitHead": "9a65507f4294f48d98953edb9fc91392a8fab759",
43
43
  "engines": {
44
44
  "node": ">=20.18.3",
45
45
  "npm": ">=10.1.0"
@@ -51,10 +51,10 @@
51
51
  "ws": "8.18.1",
52
52
  "xml2js": "0.6.2",
53
53
  "yargs": "17.7.2",
54
- "@php-wasm/logger": "2.0.22",
55
- "@php-wasm/universal": "2.0.22",
56
- "@wp-playground/common": "2.0.22",
57
- "@php-wasm/node": "2.0.22"
54
+ "@php-wasm/logger": "3.0.1",
55
+ "@php-wasm/universal": "3.0.1",
56
+ "@wp-playground/common": "3.0.1",
57
+ "@php-wasm/node": "3.0.1"
58
58
  },
59
59
  "overrides": {
60
60
  "rollup": "^4.34.6",
@@ -29,7 +29,7 @@
29
29
  * @license
30
30
  * Copyright (c) 2016, Contributors
31
31
  * SPDX-License-Identifier: ISC
32
- */var ze,Ge,Ye;const Cr=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,Ir=(Ge=(ze=process==null?void 0:process.versions)===null||ze===void 0?void 0:ze.node)!==null&&Ge!==void 0?Ge:(Ye=process==null?void 0:process.version)===null||Ye===void 0?void 0:Ye.slice(1);if(Ir&&Number(Ir.match(/^([^.]+)/)[1])<Cr)throw Error(`yargs parser supports a minimum Node.js version of ${Cr}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);const Ks=process?process.env:{},rs=new Gs({cwd:process.cwd,env:()=>Ks,format:kn.format,normalize:Ot.normalize,resolve:Ot.resolve,require:a=>{if(typeof require<"u")return require(a);if(a.match(/\.json$/))return JSON.parse(Xt.readFileSync(a,"utf8"));throw Error("only .json config files are supported in ESM")}}),Ce=function(t,e){return rs.parse(t.slice(),e).argv};Ce.detailed=function(a,t){return rs.parse(a.slice(),t)};Ce.camelCase=me;Ce.decamelize=es;Ce.looksLikeNumber=ns;function is(){return Qs()?0:1}function Qs(){return Js()&&!process.defaultApp}function Js(){return!!process.versions.electron}function Zs(a){return a.slice(is()+1)}function to(){return process.argv[is()]}class gt extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,gt)}}const eo={fs:{readFileSync:Xt.readFileSync,writeFile:Xt.writeFile},format:kn.format,resolve:Ot.resolve,exists:a=>{try{return Xt.statSync(a).isFile()}catch{return!1}}};let Ft;class no{constructor(t){t=t||{},this.directory=t.directory||"./locales",this.updateFiles=typeof t.updateFiles=="boolean"?t.updateFiles:!0,this.locale=t.locale||"en",this.fallbackToLanguage=typeof t.fallbackToLanguage=="boolean"?t.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...t){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);const e=t.shift();let n=function(){};return typeof t[t.length-1]=="function"&&(n=t.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]=e,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),Ft.format.apply(Ft.format,[this.cache[this.locale][e]||e].concat(t))}__n(){const t=Array.prototype.slice.call(arguments),e=t.shift(),n=t.shift(),s=t.shift();let i=function(){};typeof t[t.length-1]=="function"&&(i=t.pop()),this.cache[this.locale]||this._readLocaleFile();let r=s===1?e:n;this.cache[this.locale][e]&&(r=this.cache[this.locale][e][s===1?"one":"other"]),!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]={one:e,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:i})):i();const o=[r];return~r.indexOf("%d")&&o.push(s),Ft.format.apply(Ft.format,o.concat(t))}setLocale(t){this.locale=t}getLocale(){return this.locale}updateLocale(t){this.cache[this.locale]||this._readLocaleFile();for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this.cache[this.locale][e]=t[e])}_taggedLiteral(t,...e){let n="";return t.forEach(function(s,i){const r=e[i+1];n+=s,typeof r<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(e,1)))}_enqueueWrite(t){this.writeQueue.push(t),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){const t=this,e=this.writeQueue[0],n=e.directory,s=e.locale,i=e.cb,r=this._resolveLocaleFile(n,s),o=JSON.stringify(this.cache[s],null,2);Ft.fs.writeFile(r,o,"utf-8",function(l){t.writeQueue.shift(),t.writeQueue.length>0&&t._processWriteQueue(),i(l)})}_readLocaleFile(){let t={};const e=this._resolveLocaleFile(this.directory,this.locale);try{Ft.fs.readFileSync&&(t=JSON.parse(Ft.fs.readFileSync(e,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+e),n.code==="ENOENT")t={};else throw n}this.cache[this.locale]=t}_resolveLocaleFile(t,e){let n=Ft.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){const s=Ft.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(s)&&(n=s)}return n}_fileExistsSync(t){return Ft.exists(t)}}function ro(a,t){Ft=t;const e=new no(a);return{__:e.__.bind(e),__n:e.__n.bind(e),setLocale:e.setLocale.bind(e),getLocale:e.getLocale.bind(e),updateLocale:e.updateLocale.bind(e),locale:e.locale}}const io=a=>ro(a,eo),so="require is not supported by ESM",Dr="loading a directory of commands is not supported yet for ESM";let xe;try{xe=ys.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:Ve&&Ve.tagName.toUpperCase()==="SCRIPT"&&Ve.src||new URL("run-cli-Bk1CbeEI.cjs",document.baseURI).href)}catch{xe=process.cwd()}const oo=xe.substring(0,xe.lastIndexOf("node_modules")),ao={assert:{notStrictEqual:gr.notStrictEqual,strictEqual:gr.strictEqual},cliui:Vs,findUp:Hs,getEnv:a=>process.env[a],inspect:kn.inspect,getCallerFile:()=>{throw new gt(Dr)},getProcessArgvBin:to,mainFilename:oo||process.cwd(),Parser:Ce,path:{basename:Ot.basename,dirname:Ot.dirname,extname:Ot.extname,relative:Ot.relative,resolve:Ot.resolve},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(a,t)=>process.emitWarning(a,t),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:Xt.readFileSync,require:()=>{throw new gt(so)},requireDirectory:()=>{throw new gt(Dr)},stringWidth:a=>[...a].length,y18n:io({directory:Ot.resolve(xe,"../../../locales"),updateFiles:!1})};function Bt(a,t,e,n){e.assert.notStrictEqual(a,t,n)}function Tr(a,t){t.assert.strictEqual(typeof a,"string")}function Xe(a){return Object.keys(a)}function yt(a){return!!a&&!!a.then&&typeof a.then=="function"}function be(a){const e=a.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,s=e.shift();if(!s)throw new Error(`No command found in: ${a}`);const i={cmd:s.replace(n,""),demanded:[],optional:[]};return e.forEach((r,o)=>{let l=!1;r=r.replace(/\s/g,""),/\.+[\]>]/.test(r)&&o===e.length-1&&(l=!0),/^\[/.test(r)?i.optional.push({cmd:r.replace(n,"").split("|"),variadic:l}):i.demanded.push({cmd:r.replace(n,"").split("|"),variadic:l})}),i}const uo=["first","second","third","fourth","fifth","sixth"];function z(a,t,e){function n(){return typeof a=="object"?[{demanded:[],optional:[]},a,t]:[be(`cmd ${a}`),t,e]}try{let s=0;const[i,r,o]=n(),l=[].slice.call(r);for(;l.length&&l[l.length-1]===void 0;)l.pop();const E=o||l.length;if(E<i.demanded.length)throw new gt(`Not enough arguments provided. Expected ${i.demanded.length} but received ${l.length}.`);const m=i.demanded.length+i.optional.length;if(E>m)throw new gt(`Too many arguments provided. Expected max ${m} but received ${E}.`);i.demanded.forEach(p=>{const y=l.shift(),w=vr(y);p.cmd.filter(_=>_===w||_==="*").length===0&&_r(w,p.cmd,s),s+=1}),i.optional.forEach(p=>{if(l.length===0)return;const y=l.shift(),w=vr(y);p.cmd.filter(_=>_===w||_==="*").length===0&&_r(w,p.cmd,s),s+=1})}catch(s){console.warn(s.stack)}}function vr(a){return Array.isArray(a)?"array":a===null?"null":typeof a}function _r(a,t,e){throw new gt(`Invalid ${uo[e]||"manyith"} argument. Expected ${t.join(" or ")} but received ${a}.`)}class co{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,n=!0,s=!1){if(z("<array|function> [boolean] [boolean] [boolean]",[t,e,n],arguments.length),Array.isArray(t)){for(let i=0;i<t.length;i++){if(typeof t[i]!="function")throw Error("middleware must be a function");const r=t[i];r.applyBeforeValidation=e,r.global=n}Array.prototype.push.apply(this.globalMiddleware,t)}else if(typeof t=="function"){const i=t;i.applyBeforeValidation=e,i.global=n,i.mutates=s,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){const n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(s=>{const i=[...n[e]||[],e];return s.option?!i.includes(s.option):!0}),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){const t=this.frozens.pop();t!==void 0&&(this.globalMiddleware=t)}reset(){this.globalMiddleware=this.globalMiddleware.filter(t=>t.global)}}function lo(a){return a?a.map(t=>(t.applyBeforeValidation=!1,t)):[]}function we(a,t,e,n){return e.reduce((s,i)=>{if(i.applyBeforeValidation!==n)return s;if(i.mutates){if(i.applied)return s;i.applied=!0}if(yt(s))return s.then(r=>Promise.all([r,i(r,t)])).then(([r,o])=>Object.assign(r,o));{const r=i(s,t);return yt(r)?r.then(o=>Object.assign(s,o)):Object.assign(s,r)}},a)}function Ee(a,t,e=n=>{throw n}){try{const n=fo(a)?a():a;return yt(n)?n.then(s=>t(s)):t(n)}catch(n){return e(n)}}function fo(a){return typeof a=="function"}function ho(a){if(typeof require>"u")return null;for(let t=0,e=Object.keys(require.cache),n;t<e.length;t++)if(n=require.cache[e[t]],n.exports===a)return n;return null}const oe=/(^\*)|(^\$0)/;class po{constructor(t,e,n,s){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=s,this.usage=t,this.globalMiddleware=n,this.validation=e}addDirectory(t,e,n,s){s=s||{},typeof s.recurse!="boolean"&&(s.recurse=!1),Array.isArray(s.extensions)||(s.extensions=["js"]);const i=typeof s.visit=="function"?s.visit:r=>r;s.visit=(r,o,l)=>{const E=i(r,o,l);if(E){if(this.requireCache.has(o))return E;this.requireCache.add(o),this.addHandler(E)}return E},this.shim.requireDirectory({require:e,filename:n},t,s)}addHandler(t,e,n,s,i,r){let o=[];const l=lo(i);if(s=s||(()=>{}),Array.isArray(t))if(go(t))[t,...o]=t;else for(const E of t)this.addHandler(E);else if(bo(t)){let E=Array.isArray(t.command)||typeof t.command=="string"?t.command:this.moduleName(t);t.aliases&&(E=[].concat(E).concat(t.aliases)),this.addHandler(E,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated);return}else if(Nr(n)){this.addHandler([t].concat(o),e,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof t=="string"){const E=be(t);o=o.map(y=>be(y).cmd);let m=!1;const p=[E.cmd].concat(o).filter(y=>oe.test(y)?(m=!0,!1):!0);p.length===0&&m&&p.push("$0"),m&&(E.cmd=p[0],o=p.slice(1),t=t.replace(oe,E.cmd)),o.forEach(y=>{this.aliasMap[y]=E.cmd}),e!==!1&&this.usage.command(t,e,m,o,r),this.handlers[E.cmd]={original:t,description:e,handler:s,builder:n||{},middlewares:l,deprecated:r,demanded:E.demanded,optional:E.optional},m&&(this.defaultCommand=this.handlers[E.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,n,s,i,r){const o=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,l=e.getInternalMethods().getContext(),E=l.commands.slice(),m=!t;t&&(l.commands.push(t),l.fullCommands.push(o.original));const p=this.applyBuilderUpdateUsageAndParse(m,o,e,n.aliases,E,s,i,r);return yt(p)?p.then(y=>this.applyMiddlewareAndGetResult(m,o,y.innerArgv,l,i,y.aliases,e)):this.applyMiddlewareAndGetResult(m,o,p.innerArgv,l,i,p.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,n,s,i,r,o,l){const E=e.builder;let m=n;if(zn(E)){n.getInternalMethods().getUsageInstance().freeze();const p=E(n.getInternalMethods().reset(s),l);if(yt(p))return p.then(y=>(m=So(y)?y:n,this.parseAndUpdateUsage(t,e,m,i,r,o)))}else yo(E)&&(n.getInternalMethods().getUsageInstance().freeze(),m=n.getInternalMethods().reset(s),Object.keys(e.builder).forEach(p=>{m.option(p,E[p])}));return this.parseAndUpdateUsage(t,e,m,i,r,o)}parseAndUpdateUsage(t,e,n,s,i,r){t&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(s,e),e.description);const o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,i,r);return yt(o)?o.then(l=>({aliases:n.parsed.aliases,innerArgv:l})):{aliases:n.parsed.aliases,innerArgv:o}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&t.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(t,e){const n=oe.test(e.original)?e.original.replace(oe,"").trim():e.original,s=t.filter(i=>!oe.test(i));return s.push(n),`$0 ${s.join(" ")}`}handleValidationAndGetResult(t,e,n,s,i,r,o,l){if(!r.getInternalMethods().getHasOutput()){const E=r.getInternalMethods().runValidation(i,l,r.parsed.error,t);n=Ee(n,m=>(E(m),m))}if(e.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();const E=!!r.getOptions().configuration["populate--"];r.getInternalMethods().postProcess(n,E,!1,!1),n=we(n,r,o,!1),n=Ee(n,m=>{const p=e.handler(m);return yt(p)?p.then(()=>m):m}),t||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),yt(n)&&!r.getInternalMethods().hasParseCallback()&&n.catch(m=>{try{r.getInternalMethods().getUsageInstance().fail(null,m)}catch{}})}return t||(s.commands.pop(),s.fullCommands.pop()),n}applyMiddlewareAndGetResult(t,e,n,s,i,r,o){let l={};if(i)return n;o.getInternalMethods().getHasOutput()||(l=this.populatePositionals(e,n,s,o));const E=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),m=we(n,o,E,!0);return yt(m)?m.then(p=>this.handleValidationAndGetResult(t,e,p,s,r,o,E,l)):this.handleValidationAndGetResult(t,e,m,s,r,o,E,l)}populatePositionals(t,e,n,s){e._=e._.slice(n.commands.length);const i=t.demanded.slice(0),r=t.optional.slice(0),o={};for(this.validation.positionalCount(i.length,e._.length);i.length;){const l=i.shift();this.populatePositional(l,e,o)}for(;r.length;){const l=r.shift();this.populatePositional(l,e,o)}return e._=n.commands.concat(e._.map(l=>""+l)),this.postProcessPositionals(e,o,this.cmdToParseOptions(t.original),s),o}populatePositional(t,e,n){const s=t.cmd[0];t.variadic?n[s]=e._.splice(0).map(String):e._.length&&(n[s]=[String(e._.shift())])}cmdToParseOptions(t){const e={array:[],default:{},alias:{},demand:{}},n=be(t);return n.demanded.forEach(s=>{const[i,...r]=s.cmd;s.variadic&&(e.array.push(i),e.default[i]=[]),e.alias[i]=r,e.demand[i]=!0}),n.optional.forEach(s=>{const[i,...r]=s.cmd;s.variadic&&(e.array.push(i),e.default[i]=[]),e.alias[i]=r}),e}postProcessPositionals(t,e,n,s){const i=Object.assign({},s.getOptions());i.default=Object.assign(n.default,i.default);for(const E of Object.keys(n.alias))i.alias[E]=(i.alias[E]||[]).concat(n.alias[E]);i.array=i.array.concat(n.array),i.config={};const r=[];if(Object.keys(e).forEach(E=>{e[E].map(m=>{i.configuration["unknown-options-as-args"]&&(i.key[E]=!0),r.push(`--${E}`),r.push(m)})}),!r.length)return;const o=Object.assign({},i.configuration,{"populate--":!1}),l=this.shim.Parser.detailed(r,Object.assign({},i,{configuration:o}));if(l.error)s.getInternalMethods().getUsageInstance().fail(l.error.message,l.error);else{const E=Object.keys(e);Object.keys(e).forEach(m=>{E.push(...l.aliases[m])}),Object.keys(l.argv).forEach(m=>{E.includes(m)&&(e[m]||(e[m]=l.argv[m]),!this.isInConfigs(s,m)&&!this.isDefaulted(s,m)&&Object.prototype.hasOwnProperty.call(t,m)&&Object.prototype.hasOwnProperty.call(l.argv,m)&&(Array.isArray(t[m])||Array.isArray(l.argv[m]))?t[m]=[].concat(t[m],l.argv[m]):t[m]=l.argv[m])})}}isDefaulted(t,e){const{default:n}=t.getOptions();return Object.prototype.hasOwnProperty.call(n,e)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(e))}isInConfigs(t,e){const{configObjects:n}=t.getOptions();return n.some(s=>Object.prototype.hasOwnProperty.call(s,e))||n.some(s=>Object.prototype.hasOwnProperty.call(s,this.shim.Parser.camelCase(e)))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){const n=oe.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}const e=this.defaultCommand.builder;if(zn(e))return e(t,!0);Nr(e)||Object.keys(e).forEach(n=>{t.option(n,e[n])})}moduleName(t){const e=ho(t);if(!e)throw new Error(`No command name given for module: ${this.shim.inspect(t)}`);return this.commandFromFilename(e.filename)}commandFromFilename(t){return this.shim.path.basename(t,this.shim.path.extname(t))}extractDesc({describe:t,description:e,desc:n}){for(const s of[t,e,n]){if(typeof s=="string"||s===!1)return s;Bt(s,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){const t=this.frozens.pop();Bt(t,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function mo(a,t,e,n){return new po(a,t,e,n)}function Nr(a){return typeof a=="object"&&!!a.builder&&typeof a.handler=="function"}function go(a){return a.every(t=>typeof t=="string")}function zn(a){return typeof a=="function"}function yo(a){return typeof a=="object"}function bo(a){return typeof a=="object"&&!Array.isArray(a)}function Oe(a={},t=()=>!0){const e={};return Xe(a).forEach(n=>{t(n,a[n])&&(e[n]=a[n])}),e}function ge(a){typeof process>"u"||[process.stdout,process.stderr].forEach(t=>{const e=t;e._handle&&e.isTTY&&typeof e._handle.setBlocking=="function"&&e._handle.setBlocking(a)})}function wo(a){return typeof a=="boolean"}function Eo(a,t){const e=t.y18n.__,n={},s=[];n.failFn=function(R){s.push(R)};let i=null,r=null,o=!0;n.showHelpOnFail=function(R=!0,$){const[W,G]=typeof R=="string"?[!0,R]:[R,$];return a.getInternalMethods().isGlobalContext()&&(r=G),i=G,o=W,n};let l=!1;n.fail=function(R,$){const W=a.getInternalMethods().getLoggerInstance();if(s.length)for(let G=s.length-1;G>=0;--G){const k=s[G];if(wo(k)){if($)throw $;if(R)throw Error(R)}else k(R,$,n)}else{if(a.getExitProcess()&&ge(!0),!l){l=!0,o&&(a.showHelp("error"),W.error()),(R||$)&&W.error(R||$);const G=i||r;G&&((R||$)&&W.error(""),W.error(G))}if($=$||new gt(R),a.getExitProcess())return a.exit(1);if(a.getInternalMethods().hasParseCallback())return a.exit(1,$);throw $}};let E=[],m=!1;n.usage=(S,R)=>S===null?(m=!0,E=[],n):(m=!1,E.push([S,R||""]),n),n.getUsage=()=>E,n.getUsageDisabled=()=>m,n.getPositionalGroupName=()=>e("Positionals:");let p=[];n.example=(S,R)=>{p.push([S,R||""])};let y=[];n.command=function(R,$,W,G,k=!1){W&&(y=y.map(V=>(V[2]=!1,V))),y.push([R,$||"",W,G,k])},n.getCommands=()=>y;let w={};n.describe=function(R,$){Array.isArray(R)?R.forEach(W=>{n.describe(W,$)}):typeof R=="object"?Object.keys(R).forEach(W=>{n.describe(W,R[W])}):w[R]=$},n.getDescriptions=()=>w;let D=[];n.epilog=S=>{D.push(S)};let _=!1,C;n.wrap=S=>{_=!0,C=S},n.getWrap=()=>t.getEnv("YARGS_DISABLE_WRAP")?null:(_||(C=U(),_=!0),C);const T="__yargsString__:";n.deferY18nLookup=S=>T+S,n.help=function(){if(v)return v;g();const R=a.customScriptName?a.$0:t.path.basename(a.$0),$=a.getDemandedOptions(),W=a.getDemandedCommands(),G=a.getDeprecatedOptions(),k=a.getGroups(),V=a.getOptions();let ft=[];ft=ft.concat(Object.keys(w)),ft=ft.concat(Object.keys($)),ft=ft.concat(Object.keys(W)),ft=ft.concat(Object.keys(V.default)),ft=ft.filter(X),ft=Object.keys(ft.reduce((Q,x)=>(x!=="_"&&(Q[x]=!0),Q),{}));const Ct=n.getWrap(),at=t.cliui({width:Ct,wrap:!!Ct});if(!m){if(E.length)E.forEach(Q=>{at.div({text:`${Q[0].replace(/\$0/g,R)}`}),Q[1]&&at.div({text:`${Q[1]}`,padding:[1,0,0,0]})}),at.div();else if(y.length){let Q=null;W._?Q=`${R} <${e("command")}>
32
+ */var ze,Ge,Ye;const Cr=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,Ir=(Ge=(ze=process==null?void 0:process.versions)===null||ze===void 0?void 0:ze.node)!==null&&Ge!==void 0?Ge:(Ye=process==null?void 0:process.version)===null||Ye===void 0?void 0:Ye.slice(1);if(Ir&&Number(Ir.match(/^([^.]+)/)[1])<Cr)throw Error(`yargs parser supports a minimum Node.js version of ${Cr}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);const Ks=process?process.env:{},rs=new Gs({cwd:process.cwd,env:()=>Ks,format:kn.format,normalize:Ot.normalize,resolve:Ot.resolve,require:a=>{if(typeof require<"u")return require(a);if(a.match(/\.json$/))return JSON.parse(Xt.readFileSync(a,"utf8"));throw Error("only .json config files are supported in ESM")}}),Ce=function(t,e){return rs.parse(t.slice(),e).argv};Ce.detailed=function(a,t){return rs.parse(a.slice(),t)};Ce.camelCase=me;Ce.decamelize=es;Ce.looksLikeNumber=ns;function is(){return Qs()?0:1}function Qs(){return Js()&&!process.defaultApp}function Js(){return!!process.versions.electron}function Zs(a){return a.slice(is()+1)}function to(){return process.argv[is()]}class gt extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,gt)}}const eo={fs:{readFileSync:Xt.readFileSync,writeFile:Xt.writeFile},format:kn.format,resolve:Ot.resolve,exists:a=>{try{return Xt.statSync(a).isFile()}catch{return!1}}};let Ft;class no{constructor(t){t=t||{},this.directory=t.directory||"./locales",this.updateFiles=typeof t.updateFiles=="boolean"?t.updateFiles:!0,this.locale=t.locale||"en",this.fallbackToLanguage=typeof t.fallbackToLanguage=="boolean"?t.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...t){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);const e=t.shift();let n=function(){};return typeof t[t.length-1]=="function"&&(n=t.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]=e,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),Ft.format.apply(Ft.format,[this.cache[this.locale][e]||e].concat(t))}__n(){const t=Array.prototype.slice.call(arguments),e=t.shift(),n=t.shift(),s=t.shift();let i=function(){};typeof t[t.length-1]=="function"&&(i=t.pop()),this.cache[this.locale]||this._readLocaleFile();let r=s===1?e:n;this.cache[this.locale][e]&&(r=this.cache[this.locale][e][s===1?"one":"other"]),!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]={one:e,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:i})):i();const o=[r];return~r.indexOf("%d")&&o.push(s),Ft.format.apply(Ft.format,o.concat(t))}setLocale(t){this.locale=t}getLocale(){return this.locale}updateLocale(t){this.cache[this.locale]||this._readLocaleFile();for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this.cache[this.locale][e]=t[e])}_taggedLiteral(t,...e){let n="";return t.forEach(function(s,i){const r=e[i+1];n+=s,typeof r<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(e,1)))}_enqueueWrite(t){this.writeQueue.push(t),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){const t=this,e=this.writeQueue[0],n=e.directory,s=e.locale,i=e.cb,r=this._resolveLocaleFile(n,s),o=JSON.stringify(this.cache[s],null,2);Ft.fs.writeFile(r,o,"utf-8",function(l){t.writeQueue.shift(),t.writeQueue.length>0&&t._processWriteQueue(),i(l)})}_readLocaleFile(){let t={};const e=this._resolveLocaleFile(this.directory,this.locale);try{Ft.fs.readFileSync&&(t=JSON.parse(Ft.fs.readFileSync(e,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+e),n.code==="ENOENT")t={};else throw n}this.cache[this.locale]=t}_resolveLocaleFile(t,e){let n=Ft.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){const s=Ft.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(s)&&(n=s)}return n}_fileExistsSync(t){return Ft.exists(t)}}function ro(a,t){Ft=t;const e=new no(a);return{__:e.__.bind(e),__n:e.__n.bind(e),setLocale:e.setLocale.bind(e),getLocale:e.getLocale.bind(e),updateLocale:e.updateLocale.bind(e),locale:e.locale}}const io=a=>ro(a,eo),so="require is not supported by ESM",Dr="loading a directory of commands is not supported yet for ESM";let xe;try{xe=ys.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:Ve&&Ve.tagName.toUpperCase()==="SCRIPT"&&Ve.src||new URL("run-cli-Ca3F82Ga.cjs",document.baseURI).href)}catch{xe=process.cwd()}const oo=xe.substring(0,xe.lastIndexOf("node_modules")),ao={assert:{notStrictEqual:gr.notStrictEqual,strictEqual:gr.strictEqual},cliui:Vs,findUp:Hs,getEnv:a=>process.env[a],inspect:kn.inspect,getCallerFile:()=>{throw new gt(Dr)},getProcessArgvBin:to,mainFilename:oo||process.cwd(),Parser:Ce,path:{basename:Ot.basename,dirname:Ot.dirname,extname:Ot.extname,relative:Ot.relative,resolve:Ot.resolve},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(a,t)=>process.emitWarning(a,t),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:Xt.readFileSync,require:()=>{throw new gt(so)},requireDirectory:()=>{throw new gt(Dr)},stringWidth:a=>[...a].length,y18n:io({directory:Ot.resolve(xe,"../../../locales"),updateFiles:!1})};function Bt(a,t,e,n){e.assert.notStrictEqual(a,t,n)}function Tr(a,t){t.assert.strictEqual(typeof a,"string")}function Xe(a){return Object.keys(a)}function yt(a){return!!a&&!!a.then&&typeof a.then=="function"}function be(a){const e=a.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,s=e.shift();if(!s)throw new Error(`No command found in: ${a}`);const i={cmd:s.replace(n,""),demanded:[],optional:[]};return e.forEach((r,o)=>{let l=!1;r=r.replace(/\s/g,""),/\.+[\]>]/.test(r)&&o===e.length-1&&(l=!0),/^\[/.test(r)?i.optional.push({cmd:r.replace(n,"").split("|"),variadic:l}):i.demanded.push({cmd:r.replace(n,"").split("|"),variadic:l})}),i}const uo=["first","second","third","fourth","fifth","sixth"];function z(a,t,e){function n(){return typeof a=="object"?[{demanded:[],optional:[]},a,t]:[be(`cmd ${a}`),t,e]}try{let s=0;const[i,r,o]=n(),l=[].slice.call(r);for(;l.length&&l[l.length-1]===void 0;)l.pop();const E=o||l.length;if(E<i.demanded.length)throw new gt(`Not enough arguments provided. Expected ${i.demanded.length} but received ${l.length}.`);const m=i.demanded.length+i.optional.length;if(E>m)throw new gt(`Too many arguments provided. Expected max ${m} but received ${E}.`);i.demanded.forEach(p=>{const y=l.shift(),w=vr(y);p.cmd.filter(_=>_===w||_==="*").length===0&&_r(w,p.cmd,s),s+=1}),i.optional.forEach(p=>{if(l.length===0)return;const y=l.shift(),w=vr(y);p.cmd.filter(_=>_===w||_==="*").length===0&&_r(w,p.cmd,s),s+=1})}catch(s){console.warn(s.stack)}}function vr(a){return Array.isArray(a)?"array":a===null?"null":typeof a}function _r(a,t,e){throw new gt(`Invalid ${uo[e]||"manyith"} argument. Expected ${t.join(" or ")} but received ${a}.`)}class co{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,n=!0,s=!1){if(z("<array|function> [boolean] [boolean] [boolean]",[t,e,n],arguments.length),Array.isArray(t)){for(let i=0;i<t.length;i++){if(typeof t[i]!="function")throw Error("middleware must be a function");const r=t[i];r.applyBeforeValidation=e,r.global=n}Array.prototype.push.apply(this.globalMiddleware,t)}else if(typeof t=="function"){const i=t;i.applyBeforeValidation=e,i.global=n,i.mutates=s,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){const n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(s=>{const i=[...n[e]||[],e];return s.option?!i.includes(s.option):!0}),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){const t=this.frozens.pop();t!==void 0&&(this.globalMiddleware=t)}reset(){this.globalMiddleware=this.globalMiddleware.filter(t=>t.global)}}function lo(a){return a?a.map(t=>(t.applyBeforeValidation=!1,t)):[]}function we(a,t,e,n){return e.reduce((s,i)=>{if(i.applyBeforeValidation!==n)return s;if(i.mutates){if(i.applied)return s;i.applied=!0}if(yt(s))return s.then(r=>Promise.all([r,i(r,t)])).then(([r,o])=>Object.assign(r,o));{const r=i(s,t);return yt(r)?r.then(o=>Object.assign(s,o)):Object.assign(s,r)}},a)}function Ee(a,t,e=n=>{throw n}){try{const n=fo(a)?a():a;return yt(n)?n.then(s=>t(s)):t(n)}catch(n){return e(n)}}function fo(a){return typeof a=="function"}function ho(a){if(typeof require>"u")return null;for(let t=0,e=Object.keys(require.cache),n;t<e.length;t++)if(n=require.cache[e[t]],n.exports===a)return n;return null}const oe=/(^\*)|(^\$0)/;class po{constructor(t,e,n,s){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=s,this.usage=t,this.globalMiddleware=n,this.validation=e}addDirectory(t,e,n,s){s=s||{},typeof s.recurse!="boolean"&&(s.recurse=!1),Array.isArray(s.extensions)||(s.extensions=["js"]);const i=typeof s.visit=="function"?s.visit:r=>r;s.visit=(r,o,l)=>{const E=i(r,o,l);if(E){if(this.requireCache.has(o))return E;this.requireCache.add(o),this.addHandler(E)}return E},this.shim.requireDirectory({require:e,filename:n},t,s)}addHandler(t,e,n,s,i,r){let o=[];const l=lo(i);if(s=s||(()=>{}),Array.isArray(t))if(go(t))[t,...o]=t;else for(const E of t)this.addHandler(E);else if(bo(t)){let E=Array.isArray(t.command)||typeof t.command=="string"?t.command:this.moduleName(t);t.aliases&&(E=[].concat(E).concat(t.aliases)),this.addHandler(E,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated);return}else if(Nr(n)){this.addHandler([t].concat(o),e,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof t=="string"){const E=be(t);o=o.map(y=>be(y).cmd);let m=!1;const p=[E.cmd].concat(o).filter(y=>oe.test(y)?(m=!0,!1):!0);p.length===0&&m&&p.push("$0"),m&&(E.cmd=p[0],o=p.slice(1),t=t.replace(oe,E.cmd)),o.forEach(y=>{this.aliasMap[y]=E.cmd}),e!==!1&&this.usage.command(t,e,m,o,r),this.handlers[E.cmd]={original:t,description:e,handler:s,builder:n||{},middlewares:l,deprecated:r,demanded:E.demanded,optional:E.optional},m&&(this.defaultCommand=this.handlers[E.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,n,s,i,r){const o=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,l=e.getInternalMethods().getContext(),E=l.commands.slice(),m=!t;t&&(l.commands.push(t),l.fullCommands.push(o.original));const p=this.applyBuilderUpdateUsageAndParse(m,o,e,n.aliases,E,s,i,r);return yt(p)?p.then(y=>this.applyMiddlewareAndGetResult(m,o,y.innerArgv,l,i,y.aliases,e)):this.applyMiddlewareAndGetResult(m,o,p.innerArgv,l,i,p.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,n,s,i,r,o,l){const E=e.builder;let m=n;if(zn(E)){n.getInternalMethods().getUsageInstance().freeze();const p=E(n.getInternalMethods().reset(s),l);if(yt(p))return p.then(y=>(m=So(y)?y:n,this.parseAndUpdateUsage(t,e,m,i,r,o)))}else yo(E)&&(n.getInternalMethods().getUsageInstance().freeze(),m=n.getInternalMethods().reset(s),Object.keys(e.builder).forEach(p=>{m.option(p,E[p])}));return this.parseAndUpdateUsage(t,e,m,i,r,o)}parseAndUpdateUsage(t,e,n,s,i,r){t&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(s,e),e.description);const o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,i,r);return yt(o)?o.then(l=>({aliases:n.parsed.aliases,innerArgv:l})):{aliases:n.parsed.aliases,innerArgv:o}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&t.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(t,e){const n=oe.test(e.original)?e.original.replace(oe,"").trim():e.original,s=t.filter(i=>!oe.test(i));return s.push(n),`$0 ${s.join(" ")}`}handleValidationAndGetResult(t,e,n,s,i,r,o,l){if(!r.getInternalMethods().getHasOutput()){const E=r.getInternalMethods().runValidation(i,l,r.parsed.error,t);n=Ee(n,m=>(E(m),m))}if(e.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();const E=!!r.getOptions().configuration["populate--"];r.getInternalMethods().postProcess(n,E,!1,!1),n=we(n,r,o,!1),n=Ee(n,m=>{const p=e.handler(m);return yt(p)?p.then(()=>m):m}),t||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),yt(n)&&!r.getInternalMethods().hasParseCallback()&&n.catch(m=>{try{r.getInternalMethods().getUsageInstance().fail(null,m)}catch{}})}return t||(s.commands.pop(),s.fullCommands.pop()),n}applyMiddlewareAndGetResult(t,e,n,s,i,r,o){let l={};if(i)return n;o.getInternalMethods().getHasOutput()||(l=this.populatePositionals(e,n,s,o));const E=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),m=we(n,o,E,!0);return yt(m)?m.then(p=>this.handleValidationAndGetResult(t,e,p,s,r,o,E,l)):this.handleValidationAndGetResult(t,e,m,s,r,o,E,l)}populatePositionals(t,e,n,s){e._=e._.slice(n.commands.length);const i=t.demanded.slice(0),r=t.optional.slice(0),o={};for(this.validation.positionalCount(i.length,e._.length);i.length;){const l=i.shift();this.populatePositional(l,e,o)}for(;r.length;){const l=r.shift();this.populatePositional(l,e,o)}return e._=n.commands.concat(e._.map(l=>""+l)),this.postProcessPositionals(e,o,this.cmdToParseOptions(t.original),s),o}populatePositional(t,e,n){const s=t.cmd[0];t.variadic?n[s]=e._.splice(0).map(String):e._.length&&(n[s]=[String(e._.shift())])}cmdToParseOptions(t){const e={array:[],default:{},alias:{},demand:{}},n=be(t);return n.demanded.forEach(s=>{const[i,...r]=s.cmd;s.variadic&&(e.array.push(i),e.default[i]=[]),e.alias[i]=r,e.demand[i]=!0}),n.optional.forEach(s=>{const[i,...r]=s.cmd;s.variadic&&(e.array.push(i),e.default[i]=[]),e.alias[i]=r}),e}postProcessPositionals(t,e,n,s){const i=Object.assign({},s.getOptions());i.default=Object.assign(n.default,i.default);for(const E of Object.keys(n.alias))i.alias[E]=(i.alias[E]||[]).concat(n.alias[E]);i.array=i.array.concat(n.array),i.config={};const r=[];if(Object.keys(e).forEach(E=>{e[E].map(m=>{i.configuration["unknown-options-as-args"]&&(i.key[E]=!0),r.push(`--${E}`),r.push(m)})}),!r.length)return;const o=Object.assign({},i.configuration,{"populate--":!1}),l=this.shim.Parser.detailed(r,Object.assign({},i,{configuration:o}));if(l.error)s.getInternalMethods().getUsageInstance().fail(l.error.message,l.error);else{const E=Object.keys(e);Object.keys(e).forEach(m=>{E.push(...l.aliases[m])}),Object.keys(l.argv).forEach(m=>{E.includes(m)&&(e[m]||(e[m]=l.argv[m]),!this.isInConfigs(s,m)&&!this.isDefaulted(s,m)&&Object.prototype.hasOwnProperty.call(t,m)&&Object.prototype.hasOwnProperty.call(l.argv,m)&&(Array.isArray(t[m])||Array.isArray(l.argv[m]))?t[m]=[].concat(t[m],l.argv[m]):t[m]=l.argv[m])})}}isDefaulted(t,e){const{default:n}=t.getOptions();return Object.prototype.hasOwnProperty.call(n,e)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(e))}isInConfigs(t,e){const{configObjects:n}=t.getOptions();return n.some(s=>Object.prototype.hasOwnProperty.call(s,e))||n.some(s=>Object.prototype.hasOwnProperty.call(s,this.shim.Parser.camelCase(e)))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){const n=oe.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}const e=this.defaultCommand.builder;if(zn(e))return e(t,!0);Nr(e)||Object.keys(e).forEach(n=>{t.option(n,e[n])})}moduleName(t){const e=ho(t);if(!e)throw new Error(`No command name given for module: ${this.shim.inspect(t)}`);return this.commandFromFilename(e.filename)}commandFromFilename(t){return this.shim.path.basename(t,this.shim.path.extname(t))}extractDesc({describe:t,description:e,desc:n}){for(const s of[t,e,n]){if(typeof s=="string"||s===!1)return s;Bt(s,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){const t=this.frozens.pop();Bt(t,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function mo(a,t,e,n){return new po(a,t,e,n)}function Nr(a){return typeof a=="object"&&!!a.builder&&typeof a.handler=="function"}function go(a){return a.every(t=>typeof t=="string")}function zn(a){return typeof a=="function"}function yo(a){return typeof a=="object"}function bo(a){return typeof a=="object"&&!Array.isArray(a)}function Oe(a={},t=()=>!0){const e={};return Xe(a).forEach(n=>{t(n,a[n])&&(e[n]=a[n])}),e}function ge(a){typeof process>"u"||[process.stdout,process.stderr].forEach(t=>{const e=t;e._handle&&e.isTTY&&typeof e._handle.setBlocking=="function"&&e._handle.setBlocking(a)})}function wo(a){return typeof a=="boolean"}function Eo(a,t){const e=t.y18n.__,n={},s=[];n.failFn=function(R){s.push(R)};let i=null,r=null,o=!0;n.showHelpOnFail=function(R=!0,$){const[W,G]=typeof R=="string"?[!0,R]:[R,$];return a.getInternalMethods().isGlobalContext()&&(r=G),i=G,o=W,n};let l=!1;n.fail=function(R,$){const W=a.getInternalMethods().getLoggerInstance();if(s.length)for(let G=s.length-1;G>=0;--G){const k=s[G];if(wo(k)){if($)throw $;if(R)throw Error(R)}else k(R,$,n)}else{if(a.getExitProcess()&&ge(!0),!l){l=!0,o&&(a.showHelp("error"),W.error()),(R||$)&&W.error(R||$);const G=i||r;G&&((R||$)&&W.error(""),W.error(G))}if($=$||new gt(R),a.getExitProcess())return a.exit(1);if(a.getInternalMethods().hasParseCallback())return a.exit(1,$);throw $}};let E=[],m=!1;n.usage=(S,R)=>S===null?(m=!0,E=[],n):(m=!1,E.push([S,R||""]),n),n.getUsage=()=>E,n.getUsageDisabled=()=>m,n.getPositionalGroupName=()=>e("Positionals:");let p=[];n.example=(S,R)=>{p.push([S,R||""])};let y=[];n.command=function(R,$,W,G,k=!1){W&&(y=y.map(V=>(V[2]=!1,V))),y.push([R,$||"",W,G,k])},n.getCommands=()=>y;let w={};n.describe=function(R,$){Array.isArray(R)?R.forEach(W=>{n.describe(W,$)}):typeof R=="object"?Object.keys(R).forEach(W=>{n.describe(W,R[W])}):w[R]=$},n.getDescriptions=()=>w;let D=[];n.epilog=S=>{D.push(S)};let _=!1,C;n.wrap=S=>{_=!0,C=S},n.getWrap=()=>t.getEnv("YARGS_DISABLE_WRAP")?null:(_||(C=U(),_=!0),C);const T="__yargsString__:";n.deferY18nLookup=S=>T+S,n.help=function(){if(v)return v;g();const R=a.customScriptName?a.$0:t.path.basename(a.$0),$=a.getDemandedOptions(),W=a.getDemandedCommands(),G=a.getDeprecatedOptions(),k=a.getGroups(),V=a.getOptions();let ft=[];ft=ft.concat(Object.keys(w)),ft=ft.concat(Object.keys($)),ft=ft.concat(Object.keys(W)),ft=ft.concat(Object.keys(V.default)),ft=ft.filter(X),ft=Object.keys(ft.reduce((Q,x)=>(x!=="_"&&(Q[x]=!0),Q),{}));const Ct=n.getWrap(),at=t.cliui({width:Ct,wrap:!!Ct});if(!m){if(E.length)E.forEach(Q=>{at.div({text:`${Q[0].replace(/\$0/g,R)}`}),Q[1]&&at.div({text:`${Q[1]}`,padding:[1,0,0,0]})}),at.div();else if(y.length){let Q=null;W._?Q=`${R} <${e("command")}>
33
33
  `:Q=`${R} [${e("command")}]
34
34
  `,at.div(`${Q}`)}}if(y.length>1||y.length===1&&!y[0][2]){at.div(e("Commands:"));const Q=a.getInternalMethods().getContext(),x=Q.commands.length?`${Q.commands.join(" ")} `:"";a.getInternalMethods().getParserConfiguration()["sort-commands"]===!0&&(y=y.sort((j,P)=>j[0].localeCompare(P[0])));const b=R?`${R} `:"";y.forEach(j=>{const P=`${b}${x}${j[0].replace(/^\$0 ?/,"")}`;at.span({text:P,padding:[0,2,0,2],width:I(y,Ct,`${R}${x}`)+4},{text:j[1]});const J=[];j[2]&&J.push(`[${e("default")}]`),j[3]&&j[3].length&&J.push(`[${e("aliases:")} ${j[3].join(", ")}]`),j[4]&&(typeof j[4]=="string"?J.push(`[${e("deprecated: %s",j[4])}]`):J.push(`[${e("deprecated")}]`)),J.length?at.div({text:J.join(" "),padding:[0,0,0,2],align:"right"}):at.div()}),at.div()}const st=(Object.keys(V.alias)||[]).concat(Object.keys(a.parsed.newAliases)||[]);ft=ft.filter(Q=>!a.parsed.newAliases[Q]&&st.every(x=>(V.alias[x]||[]).indexOf(Q)===-1));const ut=e("Options:");k[ut]||(k[ut]=[]),M(ft,V.alias,k,ut);const _t=Q=>/^--/.test(De(Q)),K=Object.keys(k).filter(Q=>k[Q].length>0).map(Q=>{const x=k[Q].filter(X).map(b=>{if(st.includes(b))return b;for(let j=0,P;(P=st[j])!==void 0;j++)if((V.alias[P]||[]).includes(b))return P;return b});return{groupName:Q,normalizedKeys:x}}).filter(({normalizedKeys:Q})=>Q.length>0).map(({groupName:Q,normalizedKeys:x})=>{const b=x.reduce((j,P)=>(j[P]=[P].concat(V.alias[P]||[]).map(J=>Q===n.getPositionalGroupName()?J:(/^[0-9]$/.test(J)?V.boolean.includes(P)?"-":"--":J.length>1?"--":"-")+J).sort((J,ot)=>_t(J)===_t(ot)?0:_t(J)?1:-1).join(", "),j),{});return{groupName:Q,normalizedKeys:x,switches:b}});if(K.filter(({groupName:Q})=>Q!==n.getPositionalGroupName()).some(({normalizedKeys:Q,switches:x})=>!Q.every(b=>_t(x[b])))&&K.filter(({groupName:Q})=>Q!==n.getPositionalGroupName()).forEach(({normalizedKeys:Q,switches:x})=>{Q.forEach(b=>{_t(x[b])&&(x[b]=xo(x[b],4))})}),K.forEach(({groupName:Q,normalizedKeys:x,switches:b})=>{at.div(Q),x.forEach(j=>{const P=b[j];let J=w[j]||"",ot=null;J.includes(T)&&(J=e(J.substring(T.length))),V.boolean.includes(j)&&(ot=`[${e("boolean")}]`),V.count.includes(j)&&(ot=`[${e("count")}]`),V.string.includes(j)&&(ot=`[${e("string")}]`),V.normalize.includes(j)&&(ot=`[${e("string")}]`),V.array.includes(j)&&(ot=`[${e("array")}]`),V.number.includes(j)&&(ot=`[${e("number")}]`);const rt=f=>typeof f=="string"?`[${e("deprecated: %s",f)}]`:`[${e("deprecated")}]`,ht=[j in G?rt(G[j]):null,ot,j in $?`[${e("required")}]`:null,V.choices&&V.choices[j]?`[${e("choices:")} ${n.stringifiedValues(V.choices[j])}]`:null,q(V.default[j],V.defaultDescription[j])].filter(Boolean).join(" ");at.span({text:De(P),padding:[0,2,0,2+Ar(P)],width:I(b,Ct)+4},J);const A=a.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;ht&&!A?at.div({text:ht,padding:[0,0,0,2],align:"right"}):at.div()}),at.div()}),p.length&&(at.div(e("Examples:")),p.forEach(Q=>{Q[0]=Q[0].replace(/\$0/g,R)}),p.forEach(Q=>{Q[1]===""?at.div({text:Q[0],padding:[0,2,0,2]}):at.div({text:Q[0],padding:[0,2,0,2],width:I(p,Ct)+4},{text:Q[1]})}),at.div()),D.length>0){const Q=D.map(x=>x.replace(/\$0/g,R)).join(`
35
35
  `);at.div(`${Q}
@@ -109,8 +109,8 @@ Actual: `+x.attribValue);else{var J=x.tag,ot=x.tags[x.tags.length-1]||x;J.ns===o
109
109
 
110
110
  2. Run your php file, project, plugin or theme using PHP.wasm or Playground CLI.
111
111
 
112
- 3. Witness the magic break.`,timestamp:Date.now()}}}),this.cdp.sendMessage({method:"Log.entryAdded",params:{entry:{source:"other",level:"info",text:" ",timestamp:Date.now()}}})})}stop(){this.dbgp.close(),this.cdp.close()}async sendInitialScripts(){for(const[t,e]of this.scriptIdByUrl.entries())await this.sendScriptToCDP(t,e)}async sendScriptToCDP(t,e){const n=this.uriFromBridgeToCDPSyntaxHighlight(t),s=this.uriFromBridgeToCDP(t),i=await this.readPHPFile(t),r=i.split(`
113
- `),o=r.map((p,y)=>y===0?"AAAA":"AACA").join(";"),l={version:3,file:s,sources:[n],sourcesContent:[i],mappings:o},m=`data:application/json;base64,${Buffer.from(JSON.stringify(l),"utf-8").toString("base64")}`;this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:e,url:s,startLine:0,startColumn:0,endLine:r.length,endColumn:0,executionContextId:1,sourceMapURL:m}})}getOrCreateScriptId(t){let e=this.scriptIdByUrl.get(t);return e||(e=Es.createHash("sha256").update(String(this.nextScriptId++)).digest("hex").slice(0,16),this.scriptIdByUrl.set(t,e)),e}formatPropertyFullName(t){let e=!1,n="";for(const s of t)s==='"'||s==="\\"||s==="\0"?(n+="\\"+s,e=!0):s===" "?(n+=s,e=!0):n+=s;return(e||t.includes("'"))&&(n=`"${n}"`),n}sendDbgpCommand(t,e){const s=(this.nextTxnId++).toString();let i=`${t} -i ${s}`;return e!==void 0&&(i+=` ${e}`),this.dbgp.sendCommand(i),s}async handleCdpMessage(t){const{id:e,method:n,params:s}=t;let i={},r=!0;switch(n){case"Debugger.enable":case"Runtime.enable":i={};break;case"Debugger.setBreakpointByUrl":{const{url:o,lineNumber:l}=s,E=this.uriFromCDPToBridge(o),m=this.uriFromBridgeToDBGP(E),p=(typeof l=="number"?l:0)+1,y=String(this.breakpoints.size+1);if(this.xdebugConnected){const w=`breakpoint_set -t line -f ${this.formatPropertyFullName(m)} -n ${p}`,D=this.sendDbgpCommand(w);this.pendingCommands.set(D,{cdpId:e,cdpMethod:n,params:{breakpointId:y,fileUri:E,lineNumber:p}}),r=!1}else this.breakpoints.set(y,{cdpId:y,xdebugId:null,fileUri:E,lineNumber:p}),i={breakpointId:y,locations:[{scriptId:this.getOrCreateScriptId(E),lineNumber:p-1,columnNumber:0}]};break}case"Debugger.removeBreakpoint":{const{breakpointId:o}=s,l=String(o),E=this.breakpoints.get(l);if(E){if(E.xdebugId&&this.xdebugConnected){const m=`breakpoint_remove -d ${E.xdebugId}`,p=this.sendDbgpCommand(m);this.pendingCommands.set(p,{cdpId:e,cdpMethod:n}),r=!1}this.breakpoints.delete(l)}i={};break}case"Debugger.resume":{this.xdebugConnected&&this.sendDbgpCommand("run"),i={};break}case"Debugger.stepOver":{this.xdebugConnected&&this.sendDbgpCommand("step_over"),i={};break}case"Debugger.stepInto":{this.xdebugConnected&&this.sendDbgpCommand("step_into"),i={};break}case"Debugger.stepOut":{this.xdebugConnected&&this.sendDbgpCommand("step_out"),i={};break}case"Debugger.pause":{this.xdebugConnected&&this.sendDbgpCommand("break"),i={};break}case"Runtime.evaluate":case"Debugger.evaluateOnCallFrame":{const o=s.expression||"",l=s.callFrameId;if(n==="Debugger.evaluateOnCallFrame"){if(l===void 0||!this.callFramesMap.has(l)){this.cdp.sendMessage({id:e,error:{code:-32e3,message:"No such call frame"}});return}if(this.callFramesMap.get(l)!==0){this.cdp.sendMessage({id:e,error:{code:-32e3,message:"Evaluation in this frame not supported"}});return}}if(this.xdebugConnected){const E=Buffer.from(o).toString("base64"),m=this.sendDbgpCommand("eval",`-- ${E}`);this.pendingCommands.set(m,{cdpId:e,cdpMethod:n}),r=!1}else i={result:{type:"undefined",value:void 0}};break}case"Runtime.getProperties":{const{objectId:o}=s,l=this.objectHandles.get(o);if(l&&this.xdebugConnected)if(l.type==="context"){const E=l.contextId??0,p=`context_get -d ${l.depth} -c ${E} -p 0 -m 32`,y=this.sendDbgpCommand(p),w={...l,currentPage:0,aggregatedProps:[]};this.objectHandles.set(o,w),this.pendingCommands.set(y,{cdpId:e,cdpMethod:n,params:{objectId:o}}),r=!1}else if(l.type==="property"){const E=l.depth,m=l.fullname,p=this.formatPropertyFullName(m),y=`property_get -d ${E} -n ${p} -p 0 -m 32`,w=this.sendDbgpCommand(y),D={...l,currentPage:0,aggregatedProps:[]};this.objectHandles.set(o,D),this.pendingCommands.set(w,{cdpId:e,cdpMethod:n,params:{parentObjectId:o}}),r=!1}else i={result:[]};else i={result:[]};break}case"Debugger.getScriptSource":{const o=s.scriptId,l=[...this.scriptIdByUrl.entries()].find(([,m])=>m===o)?.[0],E=[];l&&E.push(`Here's the full path for your convenience:
112
+ 3. Witness the magic break.`,timestamp:Date.now()}}}),this.cdp.sendMessage({method:"Log.entryAdded",params:{entry:{source:"other",level:"info",text:" ",timestamp:Date.now()}}})})}stop(){this.dbgp.close(),this.cdp.close()}async sendInitialScripts(){for(const[t,e]of this.scriptIdByUrl.entries())await this.sendScriptToCDP(t,e)}async sendScriptToCDP(t,e){const n=this.uriFromBridgeToCDPSyntaxHighlight(t),s=this.uriFromBridgeToCDP(t);try{const i=await this.readPHPFile(t),r=i.split(`
113
+ `),o=r.map((p,y)=>y===0?"AAAA":"AACA").join(";"),l={version:3,file:s,sources:[n],sourcesContent:[i],mappings:o},m=`data:application/json;base64,${Buffer.from(JSON.stringify(l),"utf-8").toString("base64")}`;this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:e,url:s,startLine:0,startColumn:0,endLine:r.length,endColumn:0,executionContextId:1,sourceMapURL:m}})}catch(i){this.cdp.sendMessage({method:"Log.entryAdded",params:{entry:{source:"other",level:"warning",text:i.message,timestamp:Date.now()}}})}}getOrCreateScriptId(t){let e=this.scriptIdByUrl.get(t);return e||(e=Es.createHash("sha256").update(String(this.nextScriptId++)).digest("hex").slice(0,16),this.scriptIdByUrl.set(t,e)),e}formatPropertyFullName(t){let e=!1,n="";for(const s of t)s==='"'||s==="\\"||s==="\0"?(n+="\\"+s,e=!0):s===" "?(n+=s,e=!0):n+=s;return(e||t.includes("'"))&&(n=`"${n}"`),n}sendDbgpCommand(t,e){const s=(this.nextTxnId++).toString();let i=`${t} -i ${s}`;return e!==void 0&&(i+=` ${e}`),this.dbgp.sendCommand(i),s}async handleCdpMessage(t){const{id:e,method:n,params:s}=t;let i={},r=!0;switch(n){case"Debugger.enable":case"Runtime.enable":i={};break;case"Debugger.setBreakpointByUrl":{const{url:o,lineNumber:l}=s,E=this.uriFromCDPToBridge(o),m=this.uriFromBridgeToDBGP(E),p=(typeof l=="number"?l:0)+1,y=String(this.breakpoints.size+1);if(this.xdebugConnected){const w=`breakpoint_set -t line -f ${this.formatPropertyFullName(m)} -n ${p}`,D=this.sendDbgpCommand(w);this.pendingCommands.set(D,{cdpId:e,cdpMethod:n,params:{breakpointId:y,fileUri:E,lineNumber:p}}),r=!1}else this.breakpoints.set(y,{cdpId:y,xdebugId:null,fileUri:E,lineNumber:p}),i={breakpointId:y,locations:[{scriptId:this.getOrCreateScriptId(E),lineNumber:p-1,columnNumber:0}]};break}case"Debugger.removeBreakpoint":{const{breakpointId:o}=s,l=String(o),E=this.breakpoints.get(l);if(E){if(E.xdebugId&&this.xdebugConnected){const m=`breakpoint_remove -d ${E.xdebugId}`,p=this.sendDbgpCommand(m);this.pendingCommands.set(p,{cdpId:e,cdpMethod:n}),r=!1}this.breakpoints.delete(l)}i={};break}case"Debugger.resume":{this.xdebugConnected&&this.sendDbgpCommand("run"),i={};break}case"Debugger.stepOver":{this.xdebugConnected&&this.sendDbgpCommand("step_over"),i={};break}case"Debugger.stepInto":{this.xdebugConnected&&this.sendDbgpCommand("step_into"),i={};break}case"Debugger.stepOut":{this.xdebugConnected&&this.sendDbgpCommand("step_out"),i={};break}case"Debugger.pause":{this.xdebugConnected&&this.sendDbgpCommand("break"),i={};break}case"Runtime.evaluate":case"Debugger.evaluateOnCallFrame":{const o=s.expression||"",l=s.callFrameId;if(n==="Debugger.evaluateOnCallFrame"){if(l===void 0||!this.callFramesMap.has(l)){this.cdp.sendMessage({id:e,error:{code:-32e3,message:"No such call frame"}});return}if(this.callFramesMap.get(l)!==0){this.cdp.sendMessage({id:e,error:{code:-32e3,message:"Evaluation in this frame not supported"}});return}}if(this.xdebugConnected){const E=Buffer.from(o).toString("base64"),m=this.sendDbgpCommand("eval",`-- ${E}`);this.pendingCommands.set(m,{cdpId:e,cdpMethod:n}),r=!1}else i={result:{type:"undefined",value:void 0}};break}case"Runtime.getProperties":{const{objectId:o}=s,l=this.objectHandles.get(o);if(l&&this.xdebugConnected)if(l.type==="context"){const E=l.contextId??0,p=`context_get -d ${l.depth} -c ${E} -p 0 -m 32`,y=this.sendDbgpCommand(p),w={...l,currentPage:0,aggregatedProps:[]};this.objectHandles.set(o,w),this.pendingCommands.set(y,{cdpId:e,cdpMethod:n,params:{objectId:o}}),r=!1}else if(l.type==="property"){const E=l.depth,m=l.fullname,p=this.formatPropertyFullName(m),y=`property_get -d ${E} -n ${p} -p 0 -m 32`,w=this.sendDbgpCommand(y),D={...l,currentPage:0,aggregatedProps:[]};this.objectHandles.set(o,D),this.pendingCommands.set(w,{cdpId:e,cdpMethod:n,params:{parentObjectId:o}}),r=!1}else i={result:[]};else i={result:[]};break}case"Debugger.getScriptSource":{const o=s.scriptId,l=[...this.scriptIdByUrl.entries()].find(([,m])=>m===o)?.[0],E=[];l&&E.push(`Here's the full path for your convenience:
114
114
  `,`${this.uriFromBridgeToCDPSyntaxHighlight(l).replace("file://","")}
115
115
  `),i={scriptSource:["`Are you looking for your source code?","Go to PHP.wasm group in the navigator and find it there.",...E,"What is this file, then? It's a placeholder required due to the dev tools limitations.","The XDebug <-> Devtools bridge implement PHP syntax highlighting using source maps,",'and the unfortunate side effect is having a "source" file and a "target" file.',`This is the "source". If you're interested in even more details, see the discussion at:
116
116
  `,"https://github.com/WordPress/wordpress-playground/pull/2566`"].join(`
@@ -7599,33 +7599,48 @@ class ua {
7599
7599
  await this.sendScriptToCDP(t, e);
7600
7600
  }
7601
7601
  async sendScriptToCDP(t, e) {
7602
- const n = this.uriFromBridgeToCDPSyntaxHighlight(t), s = this.uriFromBridgeToCDP(t), i = await this.readPHPFile(t), r = i.split(`
7602
+ const n = this.uriFromBridgeToCDPSyntaxHighlight(t), s = this.uriFromBridgeToCDP(t);
7603
+ try {
7604
+ const i = await this.readPHPFile(t), r = i.split(`
7603
7605
  `), o = r.map((p, y) => y === 0 ? "AAAA" : "AACA").join(";"), l = {
7604
- version: 3,
7605
- // File uri has to match the script parsed url
7606
- // While the sources url has to match the syntax
7607
- // highlighted file displayed in Devtools.
7608
- file: s,
7609
- sources: [n],
7610
- sourcesContent: [i],
7611
- mappings: o
7612
- }, m = `data:application/json;base64,${Buffer.from(
7613
- JSON.stringify(l),
7614
- "utf-8"
7615
- ).toString("base64")}`;
7616
- this.cdp.sendMessage({
7617
- method: "Debugger.scriptParsed",
7618
- params: {
7619
- scriptId: e,
7620
- url: s,
7621
- startLine: 0,
7622
- startColumn: 0,
7623
- endLine: r.length,
7624
- endColumn: 0,
7625
- executionContextId: 1,
7626
- sourceMapURL: m
7627
- }
7628
- });
7606
+ version: 3,
7607
+ // File uri has to match the script parsed url
7608
+ // While the sources url has to match the syntax
7609
+ // highlighted file displayed in Devtools.
7610
+ file: s,
7611
+ sources: [n],
7612
+ sourcesContent: [i],
7613
+ mappings: o
7614
+ }, m = `data:application/json;base64,${Buffer.from(
7615
+ JSON.stringify(l),
7616
+ "utf-8"
7617
+ ).toString("base64")}`;
7618
+ this.cdp.sendMessage({
7619
+ method: "Debugger.scriptParsed",
7620
+ params: {
7621
+ scriptId: e,
7622
+ url: s,
7623
+ startLine: 0,
7624
+ startColumn: 0,
7625
+ endLine: r.length,
7626
+ endColumn: 0,
7627
+ executionContextId: 1,
7628
+ sourceMapURL: m
7629
+ }
7630
+ });
7631
+ } catch (i) {
7632
+ this.cdp.sendMessage({
7633
+ method: "Log.entryAdded",
7634
+ params: {
7635
+ entry: {
7636
+ source: "other",
7637
+ level: "warning",
7638
+ text: i.message,
7639
+ timestamp: Date.now()
7640
+ }
7641
+ }
7642
+ });
7643
+ }
7629
7644
  }
7630
7645
  getOrCreateScriptId(t) {
7631
7646
  let e = this.scriptIdByUrl.get(t);