@php-wasm/cli 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/main.js +1 -1
  2. package/main.js.map +1 -1
  3. package/package.json +5 -5
package/main.js CHANGED
@@ -36,7 +36,7 @@ Char: `+y.c),d=new Error(d),y.error=d,R(y,"onerror",d),y}function z(y){return y.
36
36
  Actual: `+y.attribValue);else if(L==="xmlns"&&y.attribValue!==C)$(y,"xmlns: prefix must be bound to "+C+`
37
37
  Actual: `+y.attribValue);else{var K=y.tag,tt=y.tags[y.tags.length-1]||y;K.ns===tt.ns&&(K.ns=Object.create(tt.ns)),K.ns[L]=y.attribValue}y.attribList.push([y.attribName,y.attribValue])}else y.tag.attributes[y.attribName]=y.attribValue,X(y,"onattribute",{name:y.attribName,value:y.attribValue});y.attribName=y.attribValue=""}function Q(y,d){if(y.opt.xmlns){var S=y.tag,L=gt(y.tagName);S.prefix=L.prefix,S.local=L.local,S.uri=S.ns[L.prefix]||"",S.prefix&&!S.uri&&($(y,"Unbound namespace prefix: "+JSON.stringify(y.tagName)),S.uri=L.prefix);var K=y.tags[y.tags.length-1]||y;S.ns&&K.ns!==S.ns&&Object.keys(S.ns).forEach(function(P){X(y,"onopennamespace",{prefix:P,uri:S.ns[P]})});for(var tt=0,G=y.attribList.length;tt<G;tt++){var it=y.attribList[tt],O=it[0],s=it[1],t=gt(O,!0),e=t.prefix,a=t.local,I=e===""?"":S.ns[e]||"",_={name:O,value:s,prefix:e,local:a,uri:I};e&&e!=="xmlns"&&!I&&($(y,"Unbound namespace prefix: "+JSON.stringify(e)),_.uri=e),y.tag.attributes[O]=_,X(y,"onattribute",_)}y.attribList.length=0}y.tag.isSelfClosing=!!d,y.sawRoot=!0,y.tags.push(y.tag),X(y,"onopentag",y.tag),d||(!y.noscript&&y.tagName.toLowerCase()==="script"?y.state=c.SCRIPT:y.state=c.TEXT,y.tag=null,y.tagName=""),y.attribName=y.attribValue="",y.attribList.length=0}function et(y){if(!y.tagName){$(y,"Weird empty close tag."),y.textNode+="</>",y.state=c.TEXT;return}if(y.script){if(y.tagName!=="script"){y.script+="</"+y.tagName+">",y.tagName="",y.state=c.SCRIPT;return}X(y,"onscript",y.script),y.script=""}var d=y.tags.length,S=y.tagName;y.strict||(S=S[y.looseCase]());for(var L=S;d--;){var K=y.tags[d];if(K.name!==L)$(y,"Unexpected close tag");else break}if(d<0){$(y,"Unmatched closing tag: "+y.tagName),y.textNode+="</"+y.tagName+">",y.state=c.TEXT;return}y.tagName=S;for(var tt=y.tags.length;tt-- >d;){var G=y.tag=y.tags.pop();y.tagName=y.tag.name,X(y,"onclosetag",y.tagName);var it={};for(var O in G.ns)it[O]=G.ns[O];var s=y.tags[y.tags.length-1]||y;y.opt.xmlns&&G.ns!==s.ns&&Object.keys(G.ns).forEach(function(t){var e=G.ns[t];X(y,"onclosenamespace",{prefix:t,uri:e})})}d===0&&(y.closedRoot=!0),y.tagName=y.attribValue=y.attribName="",y.attribList.length=0,y.state=c.TEXT}function bt(y){var d=y.entity,S=d.toLowerCase(),L,K="";return y.ENTITIES[d]?y.ENTITIES[d]:y.ENTITIES[S]?y.ENTITIES[S]:(d=S,d.charAt(0)==="#"&&(d.charAt(1)==="x"?(d=d.slice(2),L=parseInt(d,16),K=L.toString(16)):(d=d.slice(1),L=parseInt(d,10),K=L.toString(10))),d=d.replace(/^0+/,""),isNaN(L)||K.toLowerCase()!==d?($(y,"Invalid character entity"),"&"+y.entity+";"):String.fromCodePoint(L))}function k(y,d){d==="<"?(y.state=c.OPEN_WAKA,y.startTagPosition=y.position):v(d)||($(y,"Non-whitespace before first tag."),y.textNode=d,y.state=c.TEXT)}function yt(y,d){var S="";return d<y.length&&(S=y.charAt(d)),S}function Tt(y){var d=this;if(this.error)throw this.error;if(d.closed)return J(d,"Cannot write after close. Assign an onready handler.");if(y===null)return z(d);typeof y=="object"&&(y=y.toString());for(var S=0,L="";L=yt(y,S++),d.c=L,!!L;)switch(d.trackPosition&&(d.position++,L===`
38
38
  `?(d.line++,d.column=0):d.column++),d.state){case c.BEGIN:if(d.state=c.BEGIN_WHITESPACE,L==="\uFEFF")continue;k(d,L);continue;case c.BEGIN_WHITESPACE:k(d,L);continue;case c.TEXT:if(d.sawRoot&&!d.closedRoot){for(var K=S-1;L&&L!=="<"&&L!=="&";)L=yt(y,S++),L&&d.trackPosition&&(d.position++,L===`
39
- `?(d.line++,d.column=0):d.column++);d.textNode+=y.substring(K,S-1)}L==="<"&&!(d.sawRoot&&d.closedRoot&&!d.strict)?(d.state=c.OPEN_WAKA,d.startTagPosition=d.position):(!v(L)&&(!d.sawRoot||d.closedRoot)&&$(d,"Text data outside of root node."),L==="&"?d.state=c.TEXT_ENTITY:d.textNode+=L);continue;case c.SCRIPT:L==="<"?d.state=c.SCRIPT_ENDING:d.script+=L;continue;case c.SCRIPT_ENDING:L==="/"?d.state=c.CLOSE_TAG:(d.script+="<"+L,d.state=c.SCRIPT);continue;case c.OPEN_WAKA:if(L==="!")d.state=c.SGML_DECL,d.sgmlDecl="";else if(!v(L))if(U(b,L))d.state=c.OPEN_TAG,d.tagName=L;else if(L==="/")d.state=c.CLOSE_TAG,d.tagName="";else if(L==="?")d.state=c.PROC_INST,d.procInstName=d.procInstBody="";else{if($(d,"Unencoded <"),d.startTagPosition+1<d.position){var tt=d.position-d.startTagPosition;L=new Array(tt).join(" ")+L}d.textNode+="<"+L,d.state=c.TEXT}continue;case c.SGML_DECL:if(d.sgmlDecl+L==="--"){d.state=c.COMMENT,d.comment="",d.sgmlDecl="";continue}d.doctype&&d.doctype!==!0&&d.sgmlDecl?(d.state=c.DOCTYPE_DTD,d.doctype+="<!"+d.sgmlDecl+L,d.sgmlDecl=""):(d.sgmlDecl+L).toUpperCase()===g?(X(d,"onopencdata"),d.state=c.CDATA,d.sgmlDecl="",d.cdata=""):(d.sgmlDecl+L).toUpperCase()===x?(d.state=c.DOCTYPE,(d.doctype||d.sawRoot)&&$(d,"Inappropriately located doctype declaration"),d.doctype="",d.sgmlDecl=""):L===">"?(X(d,"onsgmldeclaration",d.sgmlDecl),d.sgmlDecl="",d.state=c.TEXT):(A(L)&&(d.state=c.SGML_DECL_QUOTED),d.sgmlDecl+=L);continue;case c.SGML_DECL_QUOTED:L===d.q&&(d.state=c.SGML_DECL,d.q=""),d.sgmlDecl+=L;continue;case c.DOCTYPE:L===">"?(d.state=c.TEXT,X(d,"ondoctype",d.doctype),d.doctype=!0):(d.doctype+=L,L==="["?d.state=c.DOCTYPE_DTD:A(L)&&(d.state=c.DOCTYPE_QUOTED,d.q=L));continue;case c.DOCTYPE_QUOTED:d.doctype+=L,L===d.q&&(d.q="",d.state=c.DOCTYPE);continue;case c.DOCTYPE_DTD:L==="]"?(d.doctype+=L,d.state=c.DOCTYPE):L==="<"?(d.state=c.OPEN_WAKA,d.startTagPosition=d.position):A(L)?(d.doctype+=L,d.state=c.DOCTYPE_DTD_QUOTED,d.q=L):d.doctype+=L;continue;case c.DOCTYPE_DTD_QUOTED:d.doctype+=L,L===d.q&&(d.state=c.DOCTYPE_DTD,d.q="");continue;case c.COMMENT:L==="-"?d.state=c.COMMENT_ENDING:d.comment+=L;continue;case c.COMMENT_ENDING:L==="-"?(d.state=c.COMMENT_ENDED,d.comment=Y(d.opt,d.comment),d.comment&&X(d,"oncomment",d.comment),d.comment=""):(d.comment+="-"+L,d.state=c.COMMENT);continue;case c.COMMENT_ENDED:L!==">"?($(d,"Malformed comment"),d.comment+="--"+L,d.state=c.COMMENT):d.doctype&&d.doctype!==!0?d.state=c.DOCTYPE_DTD:d.state=c.TEXT;continue;case c.CDATA:L==="]"?d.state=c.CDATA_ENDING:d.cdata+=L;continue;case c.CDATA_ENDING:L==="]"?d.state=c.CDATA_ENDING_2:(d.cdata+="]"+L,d.state=c.CDATA);continue;case c.CDATA_ENDING_2:L===">"?(d.cdata&&X(d,"oncdata",d.cdata),X(d,"onclosecdata"),d.cdata="",d.state=c.TEXT):L==="]"?d.cdata+="]":(d.cdata+="]]"+L,d.state=c.CDATA);continue;case c.PROC_INST:L==="?"?d.state=c.PROC_INST_ENDING:v(L)?d.state=c.PROC_INST_BODY:d.procInstName+=L;continue;case c.PROC_INST_BODY:if(!d.procInstBody&&v(L))continue;L==="?"?d.state=c.PROC_INST_ENDING:d.procInstBody+=L;continue;case c.PROC_INST_ENDING:L===">"?(X(d,"onprocessinginstruction",{name:d.procInstName,body:d.procInstBody}),d.procInstName=d.procInstBody="",d.state=c.TEXT):(d.procInstBody+="?"+L,d.state=c.PROC_INST_BODY);continue;case c.OPEN_TAG:U(D,L)?d.tagName+=L:(xt(d),L===">"?Q(d):L==="/"?d.state=c.OPEN_TAG_SLASH:(v(L)||$(d,"Invalid character in tag name"),d.state=c.ATTRIB));continue;case c.OPEN_TAG_SLASH:L===">"?(Q(d,!0),et(d)):($(d,"Forward-slash in opening tag not followed by >"),d.state=c.ATTRIB);continue;case c.ATTRIB:if(v(L))continue;L===">"?Q(d):L==="/"?d.state=c.OPEN_TAG_SLASH:U(b,L)?(d.attribName=L,d.attribValue="",d.state=c.ATTRIB_NAME):$(d,"Invalid attribute name");continue;case c.ATTRIB_NAME:L==="="?d.state=c.ATTRIB_VALUE:L===">"?($(d,"Attribute without value"),d.attribValue=d.attribName,mt(d),Q(d)):v(L)?d.state=c.ATTRIB_NAME_SAW_WHITE:U(D,L)?d.attribName+=L:$(d,"Invalid attribute name");continue;case c.ATTRIB_NAME_SAW_WHITE:if(L==="=")d.state=c.ATTRIB_VALUE;else{if(v(L))continue;$(d,"Attribute without value"),d.tag.attributes[d.attribName]="",d.attribValue="",X(d,"onattribute",{name:d.attribName,value:""}),d.attribName="",L===">"?Q(d):U(b,L)?(d.attribName=L,d.state=c.ATTRIB_NAME):($(d,"Invalid attribute name"),d.state=c.ATTRIB)}continue;case c.ATTRIB_VALUE:if(v(L))continue;A(L)?(d.q=L,d.state=c.ATTRIB_VALUE_QUOTED):(d.opt.unquotedAttributeValues||J(d,"Unquoted attribute value"),d.state=c.ATTRIB_VALUE_UNQUOTED,d.attribValue=L);continue;case c.ATTRIB_VALUE_QUOTED:if(L!==d.q){L==="&"?d.state=c.ATTRIB_VALUE_ENTITY_Q:d.attribValue+=L;continue}mt(d),d.q="",d.state=c.ATTRIB_VALUE_CLOSED;continue;case c.ATTRIB_VALUE_CLOSED:v(L)?d.state=c.ATTRIB:L===">"?Q(d):L==="/"?d.state=c.OPEN_TAG_SLASH:U(b,L)?($(d,"No whitespace between attributes"),d.attribName=L,d.attribValue="",d.state=c.ATTRIB_NAME):$(d,"Invalid attribute name");continue;case c.ATTRIB_VALUE_UNQUOTED:if(!j(L)){L==="&"?d.state=c.ATTRIB_VALUE_ENTITY_U:d.attribValue+=L;continue}mt(d),L===">"?Q(d):d.state=c.ATTRIB;continue;case c.CLOSE_TAG:if(d.tagName)L===">"?et(d):U(D,L)?d.tagName+=L:d.script?(d.script+="</"+d.tagName,d.tagName="",d.state=c.SCRIPT):(v(L)||$(d,"Invalid tagname in closing tag"),d.state=c.CLOSE_TAG_SAW_WHITE);else{if(v(L))continue;B(b,L)?d.script?(d.script+="</"+L,d.state=c.SCRIPT):$(d,"Invalid tagname in closing tag."):d.tagName=L}continue;case c.CLOSE_TAG_SAW_WHITE:if(v(L))continue;L===">"?et(d):$(d,"Invalid characters in closing tag");continue;case c.TEXT_ENTITY:case c.ATTRIB_VALUE_ENTITY_Q:case c.ATTRIB_VALUE_ENTITY_U:var G,it;switch(d.state){case c.TEXT_ENTITY:G=c.TEXT,it="textNode";break;case c.ATTRIB_VALUE_ENTITY_Q:G=c.ATTRIB_VALUE_QUOTED,it="attribValue";break;case c.ATTRIB_VALUE_ENTITY_U:G=c.ATTRIB_VALUE_UNQUOTED,it="attribValue";break}if(L===";"){var O=bt(d);d.opt.unparsedEntities&&!Object.values(o.XML_ENTITIES).includes(O)?(d.entity="",d.state=G,d.write(O)):(d[it]+=O,d.entity="",d.state=G)}else U(d.entity.length?h:T,L)?d.entity+=L:($(d,"Invalid character in entity name"),d[it]+="&"+d.entity+L,d.entity="",d.state=G);continue;default:throw new Error(d,"Unknown state: "+d.state)}return d.position>=d.bufferCheckPosition&&p(d),d}/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */String.fromCodePoint||function(){var y=String.fromCharCode,d=Math.floor,S=function(){var L=16384,K=[],tt,G,it=-1,O=arguments.length;if(!O)return"";for(var s="";++it<O;){var t=Number(arguments[it]);if(!isFinite(t)||t<0||t>1114111||d(t)!==t)throw RangeError("Invalid code point: "+t);t<=65535?K.push(t):(t-=65536,tt=(t>>10)+55296,G=t%1024+56320,K.push(tt,G)),(it+1===O||K.length>L)&&(s+=y.apply(null,K),K.length=0)}return s};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:S,configurable:!0,writable:!0}):String.fromCodePoint=S}()})(l)}(ge)),ge}var Ee={},jr;function ai(){return jr||(jr=1,function(){Ee.stripBOM=function(l){return l[0]==="\uFEFF"?l.substring(1):l}}.call(H)),Ee}var wt={},Ur;function nn(){return Ur||(Ur=1,function(){var l;l=new RegExp(/(?!xmlns)^.*:/),wt.normalize=function(o){return o.toLowerCase()},wt.firstCharLowerCase=function(o){return o.charAt(0).toLowerCase()+o.slice(1)},wt.stripPrefix=function(o){return o.replace(l,"")},wt.parseNumbers=function(o){return isNaN(o)||(o=o%1===0?parseInt(o,10):parseFloat(o)),o},wt.parseBooleans=function(o){return/^(?:true|false)$/i.test(o)&&(o=o.toLowerCase()==="true"),o}}.call(H)),wt}var Xr;function ui(){return Xr||(Xr=1,function(l){(function(){var o,f,u,p,i,r,n,m,N,w=function(E,C){return function(){return E.apply(C,arguments)}},g=function(E,C){for(var M in C)x.call(C,M)&&(E[M]=C[M]);function b(){this.constructor=E}return b.prototype=C.prototype,E.prototype=new b,E.__super__=C.prototype,E},x={}.hasOwnProperty;m=si(),p=Ne,o=ai(),n=nn(),N=vn.setImmediate,f=Oe().defaults,i=function(E){return typeof E=="object"&&E!=null&&Object.keys(E).length===0},r=function(E,C,M){var b,D,T;for(b=0,D=E.length;b<D;b++)T=E[b],C=T(C,M);return C},u=function(E,C,M){var b;return b=Object.create(null),b.value=M,b.writable=!0,b.enumerable=!0,b.configurable=!0,Object.defineProperty(E,C,b)},l.Parser=function(E){g(C,E);function C(M){this.parseStringPromise=w(this.parseStringPromise,this),this.parseString=w(this.parseString,this),this.reset=w(this.reset,this),this.assignOrPush=w(this.assignOrPush,this),this.processAsync=w(this.processAsync,this);var b,D,T;if(!(this instanceof l.Parser))return new l.Parser(M);this.options={},D=f["0.2"];for(b in D)x.call(D,b)&&(T=D[b],this.options[b]=T);for(b in M)x.call(M,b)&&(T=M[b],this.options[b]=T);this.options.xmlns&&(this.options.xmlnskey=this.options.attrkey+"ns"),this.options.normalizeTags&&(this.options.tagNameProcessors||(this.options.tagNameProcessors=[]),this.options.tagNameProcessors.unshift(n.normalize)),this.reset()}return C.prototype.processAsync=function(){var M,b;try{return this.remaining.length<=this.options.chunkSize?(M=this.remaining,this.remaining="",this.saxParser=this.saxParser.write(M),this.saxParser.close()):(M=this.remaining.substr(0,this.options.chunkSize),this.remaining=this.remaining.substr(this.options.chunkSize,this.remaining.length),this.saxParser=this.saxParser.write(M),N(this.processAsync))}catch(D){if(b=D,!this.saxParser.errThrown)return this.saxParser.errThrown=!0,this.emit(b)}},C.prototype.assignOrPush=function(M,b,D){return b in M?(M[b]instanceof Array||u(M,b,[M[b]]),M[b].push(D)):this.options.explicitArray?u(M,b,[D]):u(M,b,D)},C.prototype.reset=function(){var M,b,D,T;return this.removeAllListeners(),this.saxParser=m.parser(this.options.strict,{trim:!1,normalize:!1,xmlns:this.options.xmlns}),this.saxParser.errThrown=!1,this.saxParser.onerror=function(h){return function(v){if(h.saxParser.resume(),!h.saxParser.errThrown)return h.saxParser.errThrown=!0,h.emit("error",v)}}(this),this.saxParser.onend=function(h){return function(){if(!h.saxParser.ended)return h.saxParser.ended=!0,h.emit("end",h.resultObject)}}(this),this.saxParser.ended=!1,this.EXPLICIT_CHARKEY=this.options.explicitCharkey,this.resultObject=null,T=[],M=this.options.attrkey,b=this.options.charkey,this.saxParser.onopentag=function(h){return function(v){var A,j,U,B,c;if(U={},U[b]="",!h.options.ignoreAttrs){c=v.attributes;for(A in c)x.call(c,A)&&(!(M in U)&&!h.options.mergeAttrs&&(U[M]={}),j=h.options.attrValueProcessors?r(h.options.attrValueProcessors,v.attributes[A],A):v.attributes[A],B=h.options.attrNameProcessors?r(h.options.attrNameProcessors,A):A,h.options.mergeAttrs?h.assignOrPush(U,B,j):u(U[M],B,j))}return U["#name"]=h.options.tagNameProcessors?r(h.options.tagNameProcessors,v.name):v.name,h.options.xmlns&&(U[h.options.xmlnskey]={uri:v.uri,local:v.local}),T.push(U)}}(this),this.saxParser.onclosetag=function(h){return function(){var v,A,j,U,B,c,F,R,X,W;if(c=T.pop(),B=c["#name"],(!h.options.explicitChildren||!h.options.preserveChildrenOrder)&&delete c["#name"],c.cdata===!0&&(v=c.cdata,delete c.cdata),X=T[T.length-1],c[b].match(/^\s*$/)&&!v?(A=c[b],delete c[b]):(h.options.trim&&(c[b]=c[b].trim()),h.options.normalize&&(c[b]=c[b].replace(/\s{2,}/g," ").trim()),c[b]=h.options.valueProcessors?r(h.options.valueProcessors,c[b],B):c[b],Object.keys(c).length===1&&b in c&&!h.EXPLICIT_CHARKEY&&(c=c[b])),i(c)&&(typeof h.options.emptyTag=="function"?c=h.options.emptyTag():c=h.options.emptyTag!==""?h.options.emptyTag:A),h.options.validator!=null&&(W="/"+function(){var Y,J,z;for(z=[],Y=0,J=T.length;Y<J;Y++)U=T[Y],z.push(U["#name"]);return z}().concat(B).join("/"),function(){var Y;try{return c=h.options.validator(W,X&&X[B],c)}catch(J){return Y=J,h.emit("error",Y)}}()),h.options.explicitChildren&&!h.options.mergeAttrs&&typeof c=="object"){if(!h.options.preserveChildrenOrder)U={},h.options.attrkey in c&&(U[h.options.attrkey]=c[h.options.attrkey],delete c[h.options.attrkey]),!h.options.charsAsChildren&&h.options.charkey in c&&(U[h.options.charkey]=c[h.options.charkey],delete c[h.options.charkey]),Object.getOwnPropertyNames(c).length>0&&(U[h.options.childkey]=c),c=U;else if(X){X[h.options.childkey]=X[h.options.childkey]||[],F={};for(j in c)x.call(c,j)&&u(F,j,c[j]);X[h.options.childkey].push(F),delete c["#name"],Object.keys(c).length===1&&b in c&&!h.EXPLICIT_CHARKEY&&(c=c[b])}}return T.length>0?h.assignOrPush(X,B,c):(h.options.explicitRoot&&(R=c,c={},u(c,B,R)),h.resultObject=c,h.saxParser.ended=!0,h.emit("end",h.resultObject))}}(this),D=function(h){return function(v){var A,j;if(j=T[T.length-1],j)return j[b]+=v,h.options.explicitChildren&&h.options.preserveChildrenOrder&&h.options.charsAsChildren&&(h.options.includeWhiteChars||v.replace(/\\n/g,"").trim()!=="")&&(j[h.options.childkey]=j[h.options.childkey]||[],A={"#name":"__text__"},A[b]=v,h.options.normalize&&(A[b]=A[b].replace(/\s{2,}/g," ").trim()),j[h.options.childkey].push(A)),j}}(this),this.saxParser.ontext=D,this.saxParser.oncdata=function(h){return function(v){var A;if(A=D(v),A)return A.cdata=!0}}()},C.prototype.parseString=function(M,b){var D;b!=null&&typeof b=="function"&&(this.on("end",function(T){return this.reset(),b(null,T)}),this.on("error",function(T){return this.reset(),b(T)}));try{return M=M.toString(),M.trim()===""?(this.emit("end",null),!0):(M=o.stripBOM(M),this.options.async?(this.remaining=M,N(this.processAsync),this.saxParser):this.saxParser.write(M).close())}catch(T){if(D=T,this.saxParser.errThrown||this.saxParser.ended){if(this.saxParser.ended)throw D}else return this.emit("error",D),this.saxParser.errThrown=!0}},C.prototype.parseStringPromise=function(M){return new Promise(function(b){return function(D,T){return b.parseString(M,function(h,v){return h?T(h):D(v)})}}(this))},C}(p),l.parseString=function(E,C,M){var b,D,T;return M!=null?(typeof M=="function"&&(b=M),typeof C=="object"&&(D=C)):(typeof C=="function"&&(b=C),D={}),T=new l.Parser(D),T.parseString(E,b)},l.parseStringPromise=function(E,C){var M,b;return typeof C=="object"&&(M=C),b=new l.Parser(M),b.parseStringPromise(E)}}).call(H)}(ye)),ye}var on;(function(){var l,o,f,u=function(i,r){for(var n in r)p.call(r,n)&&(i[n]=r[n]);function m(){this.constructor=i}return m.prototype=r.prototype,i.prototype=new m,i.__super__=r.prototype,i},p={}.hasOwnProperty;o=Oe(),l=ti(),f=ui(),nn(),o.defaults,function(i){u(r,i);function r(n){this.message=n}return r}(Error),l.Builder,f.Parser,f.parseString,on=f.parseStringPromise}).call(H);class ci{constructor(o,f,u){this.nextTxnId=1,this.pendingCommands=new Map,this.breakpoints=new Map,this.scriptIdByUrl=new Map,this.nextScriptId=1,this.objectHandles=new Map,this.nextObjectId=1,this.callFramesMap=new Map,this.xdebugConnected=!1,this.xdebugStatus="starting",this.initFileUri=null,this.dbgp=o,this.cdp=f,this.readPHPFile=u.getPHPFile,this.remoteRoot=u.remoteRoot||"",this.localRoot=u.localRoot||"";for(const p of u.knownScriptUrls)this.scriptIdByUrl.set(p,this.getOrCreateScriptId(p))}start(){this.dbgp.on("connected",()=>{this.xdebugConnected=!0,this.sendDbgpCommand("stdout","-c 1"),this.sendDbgpCommand("stderr","-c 1")}),this.dbgp.on("message",async o=>{try{const f=await on(o,{explicitArray:!1});await this.handleDbgpMessage(f)}catch{}}),this.dbgp.on("close",()=>{this.xdebugConnected=!1,this.cdp.sendMessage({method:"Debugger.paused",params:{reason:"terminated",callFrames:[]}}),setTimeout(()=>{this.cdp.ws&&this.cdp.ws.close()},100)}),this.cdp.on("clientConnected",()=>{if(this.xdebugConnected&&(this.sendInitialScripts(),this.xdebugStatus==="starting"||this.xdebugStatus==="break")){const o=this.sendDbgpCommand("stack_get");this.pendingCommands.set(o,{})}}),this.cdp.on("message",o=>{this.handleCdpMessage(o)}),this.cdp.on("clientDisconnected",()=>{this.xdebugConnected&&this.sendDbgpCommand("detach")})}sendInitialScripts(){if(this.initFileUri&&!this.scriptIdByUrl.has(this.initFileUri)){const o=this.getOrCreateScriptId(this.initFileUri);this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:o,url:this.initFileUri,startLine:0,startColumn:0,executionContextId:1}})}for(const[o,f]of this.scriptIdByUrl.entries())this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:f,url:o,startLine:0,startColumn:0,executionContextId:1}})}getOrCreateScriptId(o){let f=this.scriptIdByUrl.get(o);return f||(f=String(this.nextScriptId++),this.scriptIdByUrl.set(o,f)),f}formatPropertyFullName(o){let f=!1,u="";for(const p of o)p==='"'||p==="\\"||p==="\0"?(u+="\\"+p,f=!0):p===" "?(u+=p,f=!0):u+=p;return(f||o.includes("'"))&&(u=`"${u}"`),u}sendDbgpCommand(o,f){console.log("\x1B[1;32m[XDebug][send]\x1B[0m",o,f);const p=(this.nextTxnId++).toString();let i=`${o} -i ${p}`;return f!==void 0&&(i+=` ${f}`),this.dbgp.sendCommand(i),p}handleCdpMessage(o){const{id:f,method:u,params:p}=o;let i={},r=!0;switch(u){case"Debugger.enable":case"Runtime.enable":i={};break;case"Debugger.setBreakpointByUrl":{const{url:n,lineNumber:m}=p,N=n,w=(typeof m=="number"?m:0)+1,g=String(this.breakpoints.size+1);if(this.xdebugConnected){const x=`breakpoint_set -t line -f ${this.formatPropertyFullName(N)} -n ${w}`,E=this.sendDbgpCommand(x);this.pendingCommands.set(E,{cdpId:f,cdpMethod:u,params:{breakpointId:g,fileUri:N,line:w}}),r=!1}else this.breakpoints.set(g,{cdpId:g,xdebugId:null,file:N,line:w}),i={breakpointId:g,locations:[{scriptId:this.getOrCreateScriptId(N),lineNumber:w-1,columnNumber:0}]};break}case"Debugger.removeBreakpoint":{const{breakpointId:n}=p,m=String(n),N=this.breakpoints.get(m);if(N){if(N.xdebugId&&this.xdebugConnected){const w=`breakpoint_remove -d ${N.xdebugId}`,g=this.sendDbgpCommand(w);this.pendingCommands.set(g,{cdpId:f,cdpMethod:u}),r=!1}this.breakpoints.delete(m)}i={};break}case"Debugger.resume":{this.xdebugConnected&&(this.xdebugStatus="running",this.sendDbgpCommand("run")),i={};break}case"Debugger.stepOver":{this.xdebugConnected&&(this.xdebugStatus="running",this.sendDbgpCommand("step_over")),i={};break}case"Debugger.stepInto":{this.xdebugConnected&&(this.xdebugStatus="running",this.sendDbgpCommand("step_into")),i={};break}case"Debugger.stepOut":{this.xdebugConnected&&(this.xdebugStatus="running",this.sendDbgpCommand("step_out")),i={};break}case"Debugger.pause":{this.xdebugConnected&&this.sendDbgpCommand("break"),i={};break}case"Runtime.evaluate":case"Debugger.evaluateOnCallFrame":{const n=p.expression||"",m=p.callFrameId;if(u==="Debugger.evaluateOnCallFrame"){if(m===void 0||!this.callFramesMap.has(m)){this.cdp.sendMessage({id:f,error:{code:-32e3,message:"No such call frame"}});return}if(this.callFramesMap.get(m)!==0){this.cdp.sendMessage({id:f,error:{code:-32e3,message:"Evaluation in this frame not supported"}});return}}if(this.xdebugConnected){const N=Buffer.from(n).toString("base64"),w=this.sendDbgpCommand("eval",`-- ${N}`);this.pendingCommands.set(w,{cdpId:f,cdpMethod:u}),r=!1}else i={result:{type:"undefined",value:void 0}};break}case"Runtime.getProperties":{const{objectId:n}=p,m=this.objectHandles.get(n);if(m&&this.xdebugConnected)if(m.type==="context"){const N=m.contextId??0,g=`context_get -d ${m.depth} -c ${N}`,x=this.sendDbgpCommand(g);this.pendingCommands.set(x,{cdpId:f,cdpMethod:u}),r=!1}else if(m.type==="property"){const N=m.depth,w=m.fullname,g=this.formatPropertyFullName(w),x=`property_get -d ${N} -n ${g}`,E=this.sendDbgpCommand(x);this.pendingCommands.set(E,{cdpId:f,cdpMethod:u,params:{parentObjectId:n}}),r=!1}else i={result:[]};else i={result:[]};break}case"Debugger.getScriptSource":{const n=p.scriptId,m=[...this.scriptIdByUrl.entries()].find(([,w])=>w===n)?.[0];let N="";m&&(N=this.readPHPFile(this.uriToRemotePath(m))),i={scriptSource:N};break}default:i={};break}r&&this.cdp.sendMessage({id:f,result:i})}uriToRemotePath(o){return o.startsWith("file://")?o.slice(7):o}remoteToLocal(o){let f=o;return this.remoteRoot&&f.startsWith(this.remoteRoot)&&(f=xe.join(this.localRoot||"",f.slice(this.remoteRoot.length))),process.platform==="win32"&&f.startsWith("/")&&(f=f.slice(1)),f}async handleDbgpMessage(o){if(o.init){const f=o.init.$;this.initFileUri=f.fileuri||f.fileuri,this.xdebugStatus="starting";const u=this.sendDbgpCommand("step_into");this.pendingCommands.set(u,{}),this.cdp.ws&&this.sendInitialScripts();return}if(o.response){const f=o.response,u=f.$,p=u.command,i=u.transaction_id,r=this.pendingCommands.get(i);switch(p){case"breakpoint_set":{if(r&&r.cdpId!==void 0&&r.cdpMethod==="Debugger.setBreakpointByUrl"){const n=u.id,m=r.params;if(m){const{breakpointId:N,fileUri:w,line:g}=m;this.breakpoints.set(N,{cdpId:N,xdebugId:n,file:w,line:g});const x=this.getOrCreateScriptId(w),E={breakpointId:N,locations:[{scriptId:x,lineNumber:g-1,columnNumber:0}]};this.cdp.sendMessage({id:r.cdpId,result:E})}this.pendingCommands.delete(i)}break}case"breakpoint_remove":{r&&r.cdpId!==void 0&&(this.cdp.sendMessage({id:r.cdpId,result:{}}),this.pendingCommands.delete(i));break}case"run":case"step_into":case"step_over":case"step_out":{const n=u.status;if(this.xdebugStatus=n,f["xdebug:message"]){const m=f["xdebug:message"].$.filename;if(m&&!this.scriptIdByUrl.has(m)){const N=this.getOrCreateScriptId(m);this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:N,url:m,startLine:0,startColumn:0,executionContextId:1}})}}if(n==="break"){const m=this.sendDbgpCommand("stack_get");this.pendingCommands.set(m,{}),this.pendingCommands.delete(i)}else(n==="stopping"||n==="stopped")&&this.cdp.sendMessage({method:"Debugger.resumed",params:{}});break}case"eval":{if(r&&r.cdpId!==void 0){let n;if(f.property){const N=f.property,w=N.$.type,g=N.$.encoding;let x=null;if(Object.prototype.hasOwnProperty.call(N,"_")?x=N._:typeof N.$value<"u"&&(x=N.$value),g==="base64"&&x!==null)try{x=Buffer.from(x,"base64").toString()}catch{}if(w==="string")n={type:"string",value:x??""};else if(w==="int"||w==="float"||w==="bool"||w==="boolen"||w==="integer"||w==="double"){let E=x;w.startsWith("int")||w==="integer"?E=parseInt(x||"0",10):w==="float"||w==="double"?E=parseFloat(x||"0"):w.startsWith("bool")&&(E=x==="1"||x==="true"),n={type:"number",value:E}}else if(w==="array"||w==="object"){const E=N.$.classname||(w==="array"?"Array":"Object"),C=String(this.nextObjectId++),M=N.$.fullname||"";this.objectHandles.set(C,{type:"property",depth:0,contextId:0,fullname:M}),n={type:"object",objectId:C,className:E,description:E}}else w==="null"?n={type:"object",subtype:"null",value:null}:n={type:"undefined",value:void 0}}else n={type:"undefined",value:void 0};const m={result:n};this.cdp.sendMessage({id:r.cdpId,result:m}),this.pendingCommands.delete(i)}break}case"context_get":case"property_get":{if(r&&r.cdpId!==void 0){const n=[],m=f.property;if(m){const w=Array.isArray(m)?m:[m];for(const g of w){const x=g.$.name||g.$.fullname||"";let E=g.$.type||"undefined";const C=g.$.children==="1",M=g.$.encoding;let b=null;if(typeof g._<"u"&&(b=g._),M==="base64"&&b!==null)try{b=Buffer.from(b,"base64").toString()}catch{}if(C){const D=g.$.classname||(E==="array"?"Array":"Object"),T=String(this.nextObjectId++),h=r.cdpMethod==="Runtime.getProperties"&&r.params?.parentObjectId&&this.objectHandles.get(r.params.parentObjectId)?.contextId||0,v=r.cdpMethod==="Runtime.getProperties"&&r.params?.parentObjectId&&this.objectHandles.get(r.params.parentObjectId)?.depth||0;this.objectHandles.set(T,{type:"property",depth:v,contextId:h,fullname:g.$.fullname||x}),n.push({name:g.$.key||x,value:{type:"object",className:D,description:D,objectId:T},writable:!1,configurable:!1,enumerable:!0})}else{let D,T;E==="string"?D=b??"":E==="int"||E==="integer"?D=parseInt(b||"0",10):E==="float"||E==="double"?D=parseFloat(b||"0"):E==="bool"||E==="boolean"?(D=b==="1"||b==="true",E="boolean"):E==="null"?(D=null,T="null"):D=b;const h={type:E==="integer"?"number":E};T&&(h.subtype=T),h.value=D,n.push({name:g.$.key||x,value:h,writable:!1,configurable:!1,enumerable:!0})}}}const N={result:n};this.cdp.sendMessage({id:r.cdpId,result:N}),this.pendingCommands.delete(i)}break}case"stack_get":{if(f.stack){const n=Array.isArray(f.stack)?f.stack:[f.stack],m=[];this.callFramesMap.clear();for(const w of n){const g=w.$.filename,x=this.getOrCreateScriptId(g);this.scriptIdByUrl.has(g)||(this.scriptIdByUrl.set(g,x),this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:x,url:g,startLine:0,startColumn:0,executionContextId:1}}))}for(const w of n){const g=parseInt(w.$.level,10),x=w.$.filename,E=parseInt(w.$.lineno,10),C=w.$.where&&w.$.where!=="{main}"?w.$.where:"(anonymous)",M=this.getOrCreateScriptId(x),b=`frame:${g}`;this.callFramesMap.set(b,g);const D=[],T=String(this.nextObjectId++);this.objectHandles.set(T,{type:"context",contextId:0,depth:g}),D.push({type:"local",object:{objectId:T,className:"Object",description:"Local"}});const h=String(this.nextObjectId++);this.objectHandles.set(h,{type:"context",contextId:1,depth:g}),D.push({type:"global",object:{objectId:h,className:"Object",description:"Global"}}),m.push({callFrameId:b,functionName:C,location:{scriptId:M,lineNumber:E-1,columnNumber:0},scopeChain:D,this:{type:"object",className:"Object",description:"Object",objectId:h}})}let N="pause";if(n.length>0){const w=n[0];if(w.$.filename&&w.$.lineno){const g=w.$.filename,x=parseInt(w.$.lineno,10);for(const E of this.breakpoints.values())if(E.file===g&&E.line===x){N="breakpoint";break}}}this.cdp.sendMessage({method:"Debugger.paused",params:{reason:N,callFrames:m,hitBreakpoints:N==="breakpoint"?[""]:[]}})}this.pendingCommands.delete(i);break}default:{r&&r.cdpId!==void 0&&(this.cdp.sendMessage({id:r.cdpId,result:{}}),this.pendingCommands.delete(i));break}}}else if(o.stream){const f=o.stream,u=f.$.type,p=f.$.encoding||"none";let i=typeof f._=="string"?f._:"";p==="base64"&&(i=Buffer.from(i,"base64").toString()),this.cdp.sendMessage({method:"Log.entryAdded",params:{entry:{source:"other",level:u==="stderr"?"error":"info",text:i,timestamp:Date.now(),stackTrace:{callFrames:[]}}}})}else o.notify}}async function li(l){const o=l.cdpPort??9229,f=l.dbgpPort??9003,u=l.cdpHost??"localhost",p=l.phpRoot??import.meta.dirname,i=new Mn(o);console.log("Connect Chrome DevTools to CDP at:"),console.log(`devtools://devtools/bundled/inspector.html?ws=${u}:${o}`),await new Promise(w=>i.on("clientConnected",w)),await new Promise(w=>setTimeout(w,2e3)),console.log("Chrome connected! Initializing Xdebug receiver...");const r=new Pn(f);console.log(`XDebug receiver running on port ${f}`),console.log("Running a PHP script with Xdebug enabled...");function n(w){const g=[],x=cn(w);for(const E of x){const C=Dn(w,E),M=ln(C);M&&M.isDirectory()?g.push(...n(C)):E.endsWith(".php")&&g.push(`file://${C}`)}return g}const m=l.phpInstance?w=>l.phpInstance.readFileAsText(w):l.getPHPFile?l.getPHPFile:w=>{const g=w.startsWith("file://")?w.replace("file://",""):w;return De(g,"utf-8")},N=n(p);return new ci(r,i,{knownScriptUrls:N,remoteRoot:l.remoteRoot,localRoot:l.localRoot,getPHPFile:m})}let at=process.argv.slice(2);at.length||(at=["--help"]);const sn=(import.meta||{}).url,Te=new URL("ca-bundle.crt",sn).pathname;fn(Te)||qr(Te,pn.join(`
39
+ `?(d.line++,d.column=0):d.column++);d.textNode+=y.substring(K,S-1)}L==="<"&&!(d.sawRoot&&d.closedRoot&&!d.strict)?(d.state=c.OPEN_WAKA,d.startTagPosition=d.position):(!v(L)&&(!d.sawRoot||d.closedRoot)&&$(d,"Text data outside of root node."),L==="&"?d.state=c.TEXT_ENTITY:d.textNode+=L);continue;case c.SCRIPT:L==="<"?d.state=c.SCRIPT_ENDING:d.script+=L;continue;case c.SCRIPT_ENDING:L==="/"?d.state=c.CLOSE_TAG:(d.script+="<"+L,d.state=c.SCRIPT);continue;case c.OPEN_WAKA:if(L==="!")d.state=c.SGML_DECL,d.sgmlDecl="";else if(!v(L))if(U(b,L))d.state=c.OPEN_TAG,d.tagName=L;else if(L==="/")d.state=c.CLOSE_TAG,d.tagName="";else if(L==="?")d.state=c.PROC_INST,d.procInstName=d.procInstBody="";else{if($(d,"Unencoded <"),d.startTagPosition+1<d.position){var tt=d.position-d.startTagPosition;L=new Array(tt).join(" ")+L}d.textNode+="<"+L,d.state=c.TEXT}continue;case c.SGML_DECL:if(d.sgmlDecl+L==="--"){d.state=c.COMMENT,d.comment="",d.sgmlDecl="";continue}d.doctype&&d.doctype!==!0&&d.sgmlDecl?(d.state=c.DOCTYPE_DTD,d.doctype+="<!"+d.sgmlDecl+L,d.sgmlDecl=""):(d.sgmlDecl+L).toUpperCase()===g?(X(d,"onopencdata"),d.state=c.CDATA,d.sgmlDecl="",d.cdata=""):(d.sgmlDecl+L).toUpperCase()===x?(d.state=c.DOCTYPE,(d.doctype||d.sawRoot)&&$(d,"Inappropriately located doctype declaration"),d.doctype="",d.sgmlDecl=""):L===">"?(X(d,"onsgmldeclaration",d.sgmlDecl),d.sgmlDecl="",d.state=c.TEXT):(A(L)&&(d.state=c.SGML_DECL_QUOTED),d.sgmlDecl+=L);continue;case c.SGML_DECL_QUOTED:L===d.q&&(d.state=c.SGML_DECL,d.q=""),d.sgmlDecl+=L;continue;case c.DOCTYPE:L===">"?(d.state=c.TEXT,X(d,"ondoctype",d.doctype),d.doctype=!0):(d.doctype+=L,L==="["?d.state=c.DOCTYPE_DTD:A(L)&&(d.state=c.DOCTYPE_QUOTED,d.q=L));continue;case c.DOCTYPE_QUOTED:d.doctype+=L,L===d.q&&(d.q="",d.state=c.DOCTYPE);continue;case c.DOCTYPE_DTD:L==="]"?(d.doctype+=L,d.state=c.DOCTYPE):L==="<"?(d.state=c.OPEN_WAKA,d.startTagPosition=d.position):A(L)?(d.doctype+=L,d.state=c.DOCTYPE_DTD_QUOTED,d.q=L):d.doctype+=L;continue;case c.DOCTYPE_DTD_QUOTED:d.doctype+=L,L===d.q&&(d.state=c.DOCTYPE_DTD,d.q="");continue;case c.COMMENT:L==="-"?d.state=c.COMMENT_ENDING:d.comment+=L;continue;case c.COMMENT_ENDING:L==="-"?(d.state=c.COMMENT_ENDED,d.comment=Y(d.opt,d.comment),d.comment&&X(d,"oncomment",d.comment),d.comment=""):(d.comment+="-"+L,d.state=c.COMMENT);continue;case c.COMMENT_ENDED:L!==">"?($(d,"Malformed comment"),d.comment+="--"+L,d.state=c.COMMENT):d.doctype&&d.doctype!==!0?d.state=c.DOCTYPE_DTD:d.state=c.TEXT;continue;case c.CDATA:L==="]"?d.state=c.CDATA_ENDING:d.cdata+=L;continue;case c.CDATA_ENDING:L==="]"?d.state=c.CDATA_ENDING_2:(d.cdata+="]"+L,d.state=c.CDATA);continue;case c.CDATA_ENDING_2:L===">"?(d.cdata&&X(d,"oncdata",d.cdata),X(d,"onclosecdata"),d.cdata="",d.state=c.TEXT):L==="]"?d.cdata+="]":(d.cdata+="]]"+L,d.state=c.CDATA);continue;case c.PROC_INST:L==="?"?d.state=c.PROC_INST_ENDING:v(L)?d.state=c.PROC_INST_BODY:d.procInstName+=L;continue;case c.PROC_INST_BODY:if(!d.procInstBody&&v(L))continue;L==="?"?d.state=c.PROC_INST_ENDING:d.procInstBody+=L;continue;case c.PROC_INST_ENDING:L===">"?(X(d,"onprocessinginstruction",{name:d.procInstName,body:d.procInstBody}),d.procInstName=d.procInstBody="",d.state=c.TEXT):(d.procInstBody+="?"+L,d.state=c.PROC_INST_BODY);continue;case c.OPEN_TAG:U(D,L)?d.tagName+=L:(xt(d),L===">"?Q(d):L==="/"?d.state=c.OPEN_TAG_SLASH:(v(L)||$(d,"Invalid character in tag name"),d.state=c.ATTRIB));continue;case c.OPEN_TAG_SLASH:L===">"?(Q(d,!0),et(d)):($(d,"Forward-slash in opening tag not followed by >"),d.state=c.ATTRIB);continue;case c.ATTRIB:if(v(L))continue;L===">"?Q(d):L==="/"?d.state=c.OPEN_TAG_SLASH:U(b,L)?(d.attribName=L,d.attribValue="",d.state=c.ATTRIB_NAME):$(d,"Invalid attribute name");continue;case c.ATTRIB_NAME:L==="="?d.state=c.ATTRIB_VALUE:L===">"?($(d,"Attribute without value"),d.attribValue=d.attribName,mt(d),Q(d)):v(L)?d.state=c.ATTRIB_NAME_SAW_WHITE:U(D,L)?d.attribName+=L:$(d,"Invalid attribute name");continue;case c.ATTRIB_NAME_SAW_WHITE:if(L==="=")d.state=c.ATTRIB_VALUE;else{if(v(L))continue;$(d,"Attribute without value"),d.tag.attributes[d.attribName]="",d.attribValue="",X(d,"onattribute",{name:d.attribName,value:""}),d.attribName="",L===">"?Q(d):U(b,L)?(d.attribName=L,d.state=c.ATTRIB_NAME):($(d,"Invalid attribute name"),d.state=c.ATTRIB)}continue;case c.ATTRIB_VALUE:if(v(L))continue;A(L)?(d.q=L,d.state=c.ATTRIB_VALUE_QUOTED):(d.opt.unquotedAttributeValues||J(d,"Unquoted attribute value"),d.state=c.ATTRIB_VALUE_UNQUOTED,d.attribValue=L);continue;case c.ATTRIB_VALUE_QUOTED:if(L!==d.q){L==="&"?d.state=c.ATTRIB_VALUE_ENTITY_Q:d.attribValue+=L;continue}mt(d),d.q="",d.state=c.ATTRIB_VALUE_CLOSED;continue;case c.ATTRIB_VALUE_CLOSED:v(L)?d.state=c.ATTRIB:L===">"?Q(d):L==="/"?d.state=c.OPEN_TAG_SLASH:U(b,L)?($(d,"No whitespace between attributes"),d.attribName=L,d.attribValue="",d.state=c.ATTRIB_NAME):$(d,"Invalid attribute name");continue;case c.ATTRIB_VALUE_UNQUOTED:if(!j(L)){L==="&"?d.state=c.ATTRIB_VALUE_ENTITY_U:d.attribValue+=L;continue}mt(d),L===">"?Q(d):d.state=c.ATTRIB;continue;case c.CLOSE_TAG:if(d.tagName)L===">"?et(d):U(D,L)?d.tagName+=L:d.script?(d.script+="</"+d.tagName,d.tagName="",d.state=c.SCRIPT):(v(L)||$(d,"Invalid tagname in closing tag"),d.state=c.CLOSE_TAG_SAW_WHITE);else{if(v(L))continue;B(b,L)?d.script?(d.script+="</"+L,d.state=c.SCRIPT):$(d,"Invalid tagname in closing tag."):d.tagName=L}continue;case c.CLOSE_TAG_SAW_WHITE:if(v(L))continue;L===">"?et(d):$(d,"Invalid characters in closing tag");continue;case c.TEXT_ENTITY:case c.ATTRIB_VALUE_ENTITY_Q:case c.ATTRIB_VALUE_ENTITY_U:var G,it;switch(d.state){case c.TEXT_ENTITY:G=c.TEXT,it="textNode";break;case c.ATTRIB_VALUE_ENTITY_Q:G=c.ATTRIB_VALUE_QUOTED,it="attribValue";break;case c.ATTRIB_VALUE_ENTITY_U:G=c.ATTRIB_VALUE_UNQUOTED,it="attribValue";break}if(L===";"){var O=bt(d);d.opt.unparsedEntities&&!Object.values(o.XML_ENTITIES).includes(O)?(d.entity="",d.state=G,d.write(O)):(d[it]+=O,d.entity="",d.state=G)}else U(d.entity.length?h:T,L)?d.entity+=L:($(d,"Invalid character in entity name"),d[it]+="&"+d.entity+L,d.entity="",d.state=G);continue;default:throw new Error(d,"Unknown state: "+d.state)}return d.position>=d.bufferCheckPosition&&p(d),d}/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */String.fromCodePoint||function(){var y=String.fromCharCode,d=Math.floor,S=function(){var L=16384,K=[],tt,G,it=-1,O=arguments.length;if(!O)return"";for(var s="";++it<O;){var t=Number(arguments[it]);if(!isFinite(t)||t<0||t>1114111||d(t)!==t)throw RangeError("Invalid code point: "+t);t<=65535?K.push(t):(t-=65536,tt=(t>>10)+55296,G=t%1024+56320,K.push(tt,G)),(it+1===O||K.length>L)&&(s+=y.apply(null,K),K.length=0)}return s};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:S,configurable:!0,writable:!0}):String.fromCodePoint=S}()})(l)}(ge)),ge}var Ee={},jr;function ai(){return jr||(jr=1,function(){Ee.stripBOM=function(l){return l[0]==="\uFEFF"?l.substring(1):l}}.call(H)),Ee}var wt={},Ur;function nn(){return Ur||(Ur=1,function(){var l;l=new RegExp(/(?!xmlns)^.*:/),wt.normalize=function(o){return o.toLowerCase()},wt.firstCharLowerCase=function(o){return o.charAt(0).toLowerCase()+o.slice(1)},wt.stripPrefix=function(o){return o.replace(l,"")},wt.parseNumbers=function(o){return isNaN(o)||(o=o%1===0?parseInt(o,10):parseFloat(o)),o},wt.parseBooleans=function(o){return/^(?:true|false)$/i.test(o)&&(o=o.toLowerCase()==="true"),o}}.call(H)),wt}var Xr;function ui(){return Xr||(Xr=1,function(l){(function(){var o,f,u,p,i,r,n,m,N,w=function(E,C){return function(){return E.apply(C,arguments)}},g=function(E,C){for(var M in C)x.call(C,M)&&(E[M]=C[M]);function b(){this.constructor=E}return b.prototype=C.prototype,E.prototype=new b,E.__super__=C.prototype,E},x={}.hasOwnProperty;m=si(),p=Ne,o=ai(),n=nn(),N=vn.setImmediate,f=Oe().defaults,i=function(E){return typeof E=="object"&&E!=null&&Object.keys(E).length===0},r=function(E,C,M){var b,D,T;for(b=0,D=E.length;b<D;b++)T=E[b],C=T(C,M);return C},u=function(E,C,M){var b;return b=Object.create(null),b.value=M,b.writable=!0,b.enumerable=!0,b.configurable=!0,Object.defineProperty(E,C,b)},l.Parser=function(E){g(C,E);function C(M){this.parseStringPromise=w(this.parseStringPromise,this),this.parseString=w(this.parseString,this),this.reset=w(this.reset,this),this.assignOrPush=w(this.assignOrPush,this),this.processAsync=w(this.processAsync,this);var b,D,T;if(!(this instanceof l.Parser))return new l.Parser(M);this.options={},D=f["0.2"];for(b in D)x.call(D,b)&&(T=D[b],this.options[b]=T);for(b in M)x.call(M,b)&&(T=M[b],this.options[b]=T);this.options.xmlns&&(this.options.xmlnskey=this.options.attrkey+"ns"),this.options.normalizeTags&&(this.options.tagNameProcessors||(this.options.tagNameProcessors=[]),this.options.tagNameProcessors.unshift(n.normalize)),this.reset()}return C.prototype.processAsync=function(){var M,b;try{return this.remaining.length<=this.options.chunkSize?(M=this.remaining,this.remaining="",this.saxParser=this.saxParser.write(M),this.saxParser.close()):(M=this.remaining.substr(0,this.options.chunkSize),this.remaining=this.remaining.substr(this.options.chunkSize,this.remaining.length),this.saxParser=this.saxParser.write(M),N(this.processAsync))}catch(D){if(b=D,!this.saxParser.errThrown)return this.saxParser.errThrown=!0,this.emit(b)}},C.prototype.assignOrPush=function(M,b,D){return b in M?(M[b]instanceof Array||u(M,b,[M[b]]),M[b].push(D)):this.options.explicitArray?u(M,b,[D]):u(M,b,D)},C.prototype.reset=function(){var M,b,D,T;return this.removeAllListeners(),this.saxParser=m.parser(this.options.strict,{trim:!1,normalize:!1,xmlns:this.options.xmlns}),this.saxParser.errThrown=!1,this.saxParser.onerror=function(h){return function(v){if(h.saxParser.resume(),!h.saxParser.errThrown)return h.saxParser.errThrown=!0,h.emit("error",v)}}(this),this.saxParser.onend=function(h){return function(){if(!h.saxParser.ended)return h.saxParser.ended=!0,h.emit("end",h.resultObject)}}(this),this.saxParser.ended=!1,this.EXPLICIT_CHARKEY=this.options.explicitCharkey,this.resultObject=null,T=[],M=this.options.attrkey,b=this.options.charkey,this.saxParser.onopentag=function(h){return function(v){var A,j,U,B,c;if(U={},U[b]="",!h.options.ignoreAttrs){c=v.attributes;for(A in c)x.call(c,A)&&(!(M in U)&&!h.options.mergeAttrs&&(U[M]={}),j=h.options.attrValueProcessors?r(h.options.attrValueProcessors,v.attributes[A],A):v.attributes[A],B=h.options.attrNameProcessors?r(h.options.attrNameProcessors,A):A,h.options.mergeAttrs?h.assignOrPush(U,B,j):u(U[M],B,j))}return U["#name"]=h.options.tagNameProcessors?r(h.options.tagNameProcessors,v.name):v.name,h.options.xmlns&&(U[h.options.xmlnskey]={uri:v.uri,local:v.local}),T.push(U)}}(this),this.saxParser.onclosetag=function(h){return function(){var v,A,j,U,B,c,F,R,X,W;if(c=T.pop(),B=c["#name"],(!h.options.explicitChildren||!h.options.preserveChildrenOrder)&&delete c["#name"],c.cdata===!0&&(v=c.cdata,delete c.cdata),X=T[T.length-1],c[b].match(/^\s*$/)&&!v?(A=c[b],delete c[b]):(h.options.trim&&(c[b]=c[b].trim()),h.options.normalize&&(c[b]=c[b].replace(/\s{2,}/g," ").trim()),c[b]=h.options.valueProcessors?r(h.options.valueProcessors,c[b],B):c[b],Object.keys(c).length===1&&b in c&&!h.EXPLICIT_CHARKEY&&(c=c[b])),i(c)&&(typeof h.options.emptyTag=="function"?c=h.options.emptyTag():c=h.options.emptyTag!==""?h.options.emptyTag:A),h.options.validator!=null&&(W="/"+function(){var Y,J,z;for(z=[],Y=0,J=T.length;Y<J;Y++)U=T[Y],z.push(U["#name"]);return z}().concat(B).join("/"),function(){var Y;try{return c=h.options.validator(W,X&&X[B],c)}catch(J){return Y=J,h.emit("error",Y)}}()),h.options.explicitChildren&&!h.options.mergeAttrs&&typeof c=="object"){if(!h.options.preserveChildrenOrder)U={},h.options.attrkey in c&&(U[h.options.attrkey]=c[h.options.attrkey],delete c[h.options.attrkey]),!h.options.charsAsChildren&&h.options.charkey in c&&(U[h.options.charkey]=c[h.options.charkey],delete c[h.options.charkey]),Object.getOwnPropertyNames(c).length>0&&(U[h.options.childkey]=c),c=U;else if(X){X[h.options.childkey]=X[h.options.childkey]||[],F={};for(j in c)x.call(c,j)&&u(F,j,c[j]);X[h.options.childkey].push(F),delete c["#name"],Object.keys(c).length===1&&b in c&&!h.EXPLICIT_CHARKEY&&(c=c[b])}}return T.length>0?h.assignOrPush(X,B,c):(h.options.explicitRoot&&(R=c,c={},u(c,B,R)),h.resultObject=c,h.saxParser.ended=!0,h.emit("end",h.resultObject))}}(this),D=function(h){return function(v){var A,j;if(j=T[T.length-1],j)return j[b]+=v,h.options.explicitChildren&&h.options.preserveChildrenOrder&&h.options.charsAsChildren&&(h.options.includeWhiteChars||v.replace(/\\n/g,"").trim()!=="")&&(j[h.options.childkey]=j[h.options.childkey]||[],A={"#name":"__text__"},A[b]=v,h.options.normalize&&(A[b]=A[b].replace(/\s{2,}/g," ").trim()),j[h.options.childkey].push(A)),j}}(this),this.saxParser.ontext=D,this.saxParser.oncdata=function(h){return function(v){var A;if(A=D(v),A)return A.cdata=!0}}()},C.prototype.parseString=function(M,b){var D;b!=null&&typeof b=="function"&&(this.on("end",function(T){return this.reset(),b(null,T)}),this.on("error",function(T){return this.reset(),b(T)}));try{return M=M.toString(),M.trim()===""?(this.emit("end",null),!0):(M=o.stripBOM(M),this.options.async?(this.remaining=M,N(this.processAsync),this.saxParser):this.saxParser.write(M).close())}catch(T){if(D=T,this.saxParser.errThrown||this.saxParser.ended){if(this.saxParser.ended)throw D}else return this.emit("error",D),this.saxParser.errThrown=!0}},C.prototype.parseStringPromise=function(M){return new Promise(function(b){return function(D,T){return b.parseString(M,function(h,v){return h?T(h):D(v)})}}(this))},C}(p),l.parseString=function(E,C,M){var b,D,T;return M!=null?(typeof M=="function"&&(b=M),typeof C=="object"&&(D=C)):(typeof C=="function"&&(b=C),D={}),T=new l.Parser(D),T.parseString(E,b)},l.parseStringPromise=function(E,C){var M,b;return typeof C=="object"&&(M=C),b=new l.Parser(M),b.parseStringPromise(E)}}).call(H)}(ye)),ye}var on;(function(){var l,o,f,u=function(i,r){for(var n in r)p.call(r,n)&&(i[n]=r[n]);function m(){this.constructor=i}return m.prototype=r.prototype,i.prototype=new m,i.__super__=r.prototype,i},p={}.hasOwnProperty;o=Oe(),l=ti(),f=ui(),nn(),o.defaults,function(i){u(r,i);function r(n){this.message=n}return r}(Error),l.Builder,f.Parser,f.parseString,on=f.parseStringPromise}).call(H);class ci{constructor(o,f,u){this.nextTxnId=1,this.pendingCommands=new Map,this.breakpoints=new Map,this.scriptIdByUrl=new Map,this.nextScriptId=1,this.objectHandles=new Map,this.nextObjectId=1,this.callFramesMap=new Map,this.xdebugConnected=!1,this.xdebugStatus="starting",this.initFileUri=null,this.dbgp=o,this.cdp=f,this.readPHPFile=u.getPHPFile,this.remoteRoot=u.remoteRoot||"",this.localRoot=u.localRoot||"";for(const p of u.knownScriptUrls)this.scriptIdByUrl.set(p,this.getOrCreateScriptId(p))}start(){this.dbgp.on("connected",()=>{this.xdebugConnected=!0,this.sendDbgpCommand("stdout","-c 1"),this.sendDbgpCommand("stderr","-c 1")}),this.dbgp.on("message",async o=>{try{const f=await on(o,{explicitArray:!1});await this.handleDbgpMessage(f)}catch{}}),this.dbgp.on("close",()=>{this.xdebugConnected=!1,this.cdp.sendMessage({method:"Debugger.paused",params:{reason:"terminated",callFrames:[]}}),setTimeout(()=>{this.cdp.ws&&this.cdp.ws.close()},100)}),this.cdp.on("clientConnected",()=>{if(this.xdebugConnected&&(this.sendInitialScripts(),this.xdebugStatus==="starting"||this.xdebugStatus==="break")){const o=this.sendDbgpCommand("stack_get");this.pendingCommands.set(o,{})}}),this.cdp.on("message",o=>{this.handleCdpMessage(o)}),this.cdp.on("clientDisconnected",()=>{this.xdebugConnected&&this.sendDbgpCommand("detach")})}sendInitialScripts(){if(this.initFileUri&&!this.scriptIdByUrl.has(this.initFileUri)){const o=this.getOrCreateScriptId(this.initFileUri);this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:o,url:this.initFileUri,startLine:0,startColumn:0,executionContextId:1}})}for(const[o,f]of this.scriptIdByUrl.entries())this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:f,url:o,startLine:0,startColumn:0,executionContextId:1}})}getOrCreateScriptId(o){let f=this.scriptIdByUrl.get(o);return f||(f=String(this.nextScriptId++),this.scriptIdByUrl.set(o,f)),f}formatPropertyFullName(o){let f=!1,u="";for(const p of o)p==='"'||p==="\\"||p==="\0"?(u+="\\"+p,f=!0):p===" "?(u+=p,f=!0):u+=p;return(f||o.includes("'"))&&(u=`"${u}"`),u}sendDbgpCommand(o,f){console.log("\x1B[1;32m[XDebug][send]\x1B[0m",o,f);const p=(this.nextTxnId++).toString();let i=`${o} -i ${p}`;return f!==void 0&&(i+=` ${f}`),this.dbgp.sendCommand(i),p}async handleCdpMessage(o){const{id:f,method:u,params:p}=o;let i={},r=!0;switch(u){case"Debugger.enable":case"Runtime.enable":i={};break;case"Debugger.setBreakpointByUrl":{const{url:n,lineNumber:m}=p,N=n,w=(typeof m=="number"?m:0)+1,g=String(this.breakpoints.size+1);if(this.xdebugConnected){const x=`breakpoint_set -t line -f ${this.formatPropertyFullName(N)} -n ${w}`,E=this.sendDbgpCommand(x);this.pendingCommands.set(E,{cdpId:f,cdpMethod:u,params:{breakpointId:g,fileUri:N,line:w}}),r=!1}else this.breakpoints.set(g,{cdpId:g,xdebugId:null,file:N,line:w}),i={breakpointId:g,locations:[{scriptId:this.getOrCreateScriptId(N),lineNumber:w-1,columnNumber:0}]};break}case"Debugger.removeBreakpoint":{const{breakpointId:n}=p,m=String(n),N=this.breakpoints.get(m);if(N){if(N.xdebugId&&this.xdebugConnected){const w=`breakpoint_remove -d ${N.xdebugId}`,g=this.sendDbgpCommand(w);this.pendingCommands.set(g,{cdpId:f,cdpMethod:u}),r=!1}this.breakpoints.delete(m)}i={};break}case"Debugger.resume":{this.xdebugConnected&&(this.xdebugStatus="running",this.sendDbgpCommand("run")),i={};break}case"Debugger.stepOver":{this.xdebugConnected&&(this.xdebugStatus="running",this.sendDbgpCommand("step_over")),i={};break}case"Debugger.stepInto":{this.xdebugConnected&&(this.xdebugStatus="running",this.sendDbgpCommand("step_into")),i={};break}case"Debugger.stepOut":{this.xdebugConnected&&(this.xdebugStatus="running",this.sendDbgpCommand("step_out")),i={};break}case"Debugger.pause":{this.xdebugConnected&&this.sendDbgpCommand("break"),i={};break}case"Runtime.evaluate":case"Debugger.evaluateOnCallFrame":{const n=p.expression||"",m=p.callFrameId;if(u==="Debugger.evaluateOnCallFrame"){if(m===void 0||!this.callFramesMap.has(m)){this.cdp.sendMessage({id:f,error:{code:-32e3,message:"No such call frame"}});return}if(this.callFramesMap.get(m)!==0){this.cdp.sendMessage({id:f,error:{code:-32e3,message:"Evaluation in this frame not supported"}});return}}if(this.xdebugConnected){const N=Buffer.from(n).toString("base64"),w=this.sendDbgpCommand("eval",`-- ${N}`);this.pendingCommands.set(w,{cdpId:f,cdpMethod:u}),r=!1}else i={result:{type:"undefined",value:void 0}};break}case"Runtime.getProperties":{const{objectId:n}=p,m=this.objectHandles.get(n);if(m&&this.xdebugConnected)if(m.type==="context"){const N=m.contextId??0,g=`context_get -d ${m.depth} -c ${N}`,x=this.sendDbgpCommand(g);this.pendingCommands.set(x,{cdpId:f,cdpMethod:u}),r=!1}else if(m.type==="property"){const N=m.depth,w=m.fullname,g=this.formatPropertyFullName(w),x=`property_get -d ${N} -n ${g}`,E=this.sendDbgpCommand(x);this.pendingCommands.set(E,{cdpId:f,cdpMethod:u,params:{parentObjectId:n}}),r=!1}else i={result:[]};else i={result:[]};break}case"Debugger.getScriptSource":{const n=p.scriptId,m=[...this.scriptIdByUrl.entries()].find(([,w])=>w===n)?.[0];let N="";m&&(N=await this.readPHPFile(this.uriToRemotePath(m))),i={scriptSource:N};break}default:i={};break}r&&this.cdp.sendMessage({id:f,result:i})}uriToRemotePath(o){return o.startsWith("file://")?o.slice(7):o}remoteToLocal(o){let f=o;return this.remoteRoot&&f.startsWith(this.remoteRoot)&&(f=xe.join(this.localRoot||"",f.slice(this.remoteRoot.length))),process.platform==="win32"&&f.startsWith("/")&&(f=f.slice(1)),f}async handleDbgpMessage(o){if(o.init){const f=o.init.$;this.initFileUri=f.fileuri||f.fileuri,this.xdebugStatus="starting";const u=this.sendDbgpCommand("step_into");this.pendingCommands.set(u,{}),this.cdp.ws&&this.sendInitialScripts();return}if(o.response){const f=o.response,u=f.$,p=u.command,i=u.transaction_id,r=this.pendingCommands.get(i);switch(p){case"breakpoint_set":{if(r&&r.cdpId!==void 0&&r.cdpMethod==="Debugger.setBreakpointByUrl"){const n=u.id,m=r.params;if(m){const{breakpointId:N,fileUri:w,line:g}=m;this.breakpoints.set(N,{cdpId:N,xdebugId:n,file:w,line:g});const x=this.getOrCreateScriptId(w),E={breakpointId:N,locations:[{scriptId:x,lineNumber:g-1,columnNumber:0}]};this.cdp.sendMessage({id:r.cdpId,result:E})}this.pendingCommands.delete(i)}break}case"breakpoint_remove":{r&&r.cdpId!==void 0&&(this.cdp.sendMessage({id:r.cdpId,result:{}}),this.pendingCommands.delete(i));break}case"run":case"step_into":case"step_over":case"step_out":{const n=u.status;if(this.xdebugStatus=n,f["xdebug:message"]){const m=f["xdebug:message"].$.filename;if(m&&!this.scriptIdByUrl.has(m)){const N=this.getOrCreateScriptId(m);this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:N,url:m,startLine:0,startColumn:0,executionContextId:1}})}}if(n==="break"){const m=this.sendDbgpCommand("stack_get");this.pendingCommands.set(m,{}),this.pendingCommands.delete(i)}else(n==="stopping"||n==="stopped")&&this.cdp.sendMessage({method:"Debugger.resumed",params:{}});break}case"eval":{if(r&&r.cdpId!==void 0){let n;if(f.property){const N=f.property,w=N.$.type,g=N.$.encoding;let x=null;if(Object.prototype.hasOwnProperty.call(N,"_")?x=N._:typeof N.$value<"u"&&(x=N.$value),g==="base64"&&x!==null)try{x=Buffer.from(x,"base64").toString()}catch{}if(w==="string")n={type:"string",value:x??""};else if(w==="int"||w==="float"||w==="bool"||w==="boolen"||w==="integer"||w==="double"){let E=x;w.startsWith("int")||w==="integer"?E=parseInt(x||"0",10):w==="float"||w==="double"?E=parseFloat(x||"0"):w.startsWith("bool")&&(E=x==="1"||x==="true"),n={type:"number",value:E}}else if(w==="array"||w==="object"){const E=N.$.classname||(w==="array"?"Array":"Object"),C=String(this.nextObjectId++),M=N.$.fullname||"";this.objectHandles.set(C,{type:"property",depth:0,contextId:0,fullname:M}),n={type:"object",objectId:C,className:E,description:E}}else w==="null"?n={type:"object",subtype:"null",value:null}:n={type:"undefined",value:void 0}}else n={type:"undefined",value:void 0};const m={result:n};this.cdp.sendMessage({id:r.cdpId,result:m}),this.pendingCommands.delete(i)}break}case"context_get":case"property_get":{if(r&&r.cdpId!==void 0){const n=[],m=f.property;if(m){const w=Array.isArray(m)?m:[m];for(const g of w){const x=g.$.name||g.$.fullname||"";let E=g.$.type||"undefined";const C=g.$.children==="1",M=g.$.encoding;let b=null;if(typeof g._<"u"&&(b=g._),M==="base64"&&b!==null)try{b=Buffer.from(b,"base64").toString()}catch{}if(C){const D=g.$.classname||(E==="array"?"Array":"Object"),T=String(this.nextObjectId++),h=r.cdpMethod==="Runtime.getProperties"&&r.params?.parentObjectId&&this.objectHandles.get(r.params.parentObjectId)?.contextId||0,v=r.cdpMethod==="Runtime.getProperties"&&r.params?.parentObjectId&&this.objectHandles.get(r.params.parentObjectId)?.depth||0;this.objectHandles.set(T,{type:"property",depth:v,contextId:h,fullname:g.$.fullname||x}),n.push({name:g.$.key||x,value:{type:"object",className:D,description:D,objectId:T},writable:!1,configurable:!1,enumerable:!0})}else{let D,T;E==="string"?D=b??"":E==="int"||E==="integer"?D=parseInt(b||"0",10):E==="float"||E==="double"?D=parseFloat(b||"0"):E==="bool"||E==="boolean"?(D=b==="1"||b==="true",E="boolean"):E==="null"?(D=null,T="null"):D=b;const h={type:E==="integer"?"number":E};T&&(h.subtype=T),h.value=D,n.push({name:g.$.key||x,value:h,writable:!1,configurable:!1,enumerable:!0})}}}const N={result:n};this.cdp.sendMessage({id:r.cdpId,result:N}),this.pendingCommands.delete(i)}break}case"stack_get":{if(f.stack){const n=Array.isArray(f.stack)?f.stack:[f.stack],m=[];this.callFramesMap.clear();for(const w of n){const g=w.$.filename,x=this.getOrCreateScriptId(g);this.scriptIdByUrl.has(g)||(this.scriptIdByUrl.set(g,x),this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:x,url:g,startLine:0,startColumn:0,executionContextId:1}}))}for(const w of n){const g=parseInt(w.$.level,10),x=w.$.filename,E=parseInt(w.$.lineno,10),C=w.$.where&&w.$.where!=="{main}"?w.$.where:"(anonymous)",M=this.getOrCreateScriptId(x),b=`frame:${g}`;this.callFramesMap.set(b,g);const D=[],T=String(this.nextObjectId++);this.objectHandles.set(T,{type:"context",contextId:0,depth:g}),D.push({type:"local",object:{objectId:T,className:"Object",description:"Local"}});const h=String(this.nextObjectId++);this.objectHandles.set(h,{type:"context",contextId:1,depth:g}),D.push({type:"global",object:{objectId:h,className:"Object",description:"Global"}}),m.push({callFrameId:b,functionName:C,location:{scriptId:M,lineNumber:E-1,columnNumber:0},scopeChain:D,this:{type:"object",className:"Object",description:"Object",objectId:h}})}let N="pause";if(n.length>0){const w=n[0];if(w.$.filename&&w.$.lineno){const g=w.$.filename,x=parseInt(w.$.lineno,10);for(const E of this.breakpoints.values())if(E.file===g&&E.line===x){N="breakpoint";break}}}this.cdp.sendMessage({method:"Debugger.paused",params:{reason:N,callFrames:m,hitBreakpoints:N==="breakpoint"?[""]:[]}})}this.pendingCommands.delete(i);break}default:{r&&r.cdpId!==void 0&&(this.cdp.sendMessage({id:r.cdpId,result:{}}),this.pendingCommands.delete(i));break}}}else if(o.stream){const f=o.stream,u=f.$.type,p=f.$.encoding||"none";let i=typeof f._=="string"?f._:"";p==="base64"&&(i=Buffer.from(i,"base64").toString()),this.cdp.sendMessage({method:"Log.entryAdded",params:{entry:{source:"other",level:u==="stderr"?"error":"info",text:i,timestamp:Date.now(),stackTrace:{callFrames:[]}}}})}else o.notify}}async function li(l){const o=l.cdpPort??9229,f=l.dbgpPort??9003,u=l.cdpHost??"localhost",p=l.phpRoot??import.meta.dirname,i=new Mn(o);console.log("Connect Chrome DevTools to CDP at:"),console.log(`devtools://devtools/bundled/inspector.html?ws=${u}:${o}`),await new Promise(w=>i.on("clientConnected",w)),await new Promise(w=>setTimeout(w,2e3)),console.log("Chrome connected! Initializing Xdebug receiver...");const r=new Pn(f);console.log(`XDebug receiver running on port ${f}`),console.log("Running a PHP script with Xdebug enabled...");function n(w){const g=[],x=cn(w);for(const E of x){const C=Dn(w,E),M=ln(C);M&&M.isDirectory()?g.push(...n(C)):E.endsWith(".php")&&g.push(`file://${C}`)}return g}const m=l.phpInstance?w=>l.phpInstance.readFileAsText(w):l.getPHPFile?l.getPHPFile:w=>{const g=w.startsWith("file://")?w.replace("file://",""):w;return De(g,"utf-8")},N=n(p);return new ci(r,i,{knownScriptUrls:N,remoteRoot:l.remoteRoot,localRoot:l.localRoot,getPHPFile:m})}let at=process.argv.slice(2);at.length||(at=["--help"]);const sn=(import.meta||{}).url,Te=new URL("ca-bundle.crt",sn).pathname;fn(Te)||qr(Te,pn.join(`
40
40
  `));at.unshift("-d",`openssl.cafile=${Te}`);async function fi(){const l=new URL("php.ini",sn).pathname,o=process.env.PHP||dn;if(!mn.includes(o))throw new Error(`Unsupported PHP version ${o}`);const f=at.some(g=>g.startsWith("--xdebug"));f&&(at=at.filter(g=>g!=="--xdebug"));const u=at.some(g=>g.startsWith("--experimental-devtools"));u&&(at=at.filter(g=>g!=="--experimental-devtools"));const{TMPDIR:p,...i}=process.env,r=$e(xe.join(We.tmpdir(),"php-wasm-bin"));qr(`${r}/php`,`#!/bin/sh
41
41
  ${process.argv[0]} ${process.execArgv.join(" ")} ${process.argv[1]}
42
42
  `),hn(`${r}/php`,493);const n=$e(xe.join(We.tmpdir(),"php-wasm-sys-tmp")),m=new yn(await gn(o,{emscriptenOptions:{fileLockManager:new wn,processId:1,ENV:{...i,TMPDIR:n,TERM:"xterm",PATH:`${r}:${i.PATH}`}},withXdebug:f}));bn(m),u&&f&&(await li({})).start(),at.some(g=>g.startsWith("-c"))||at.unshift("-c",l);const w=await m.cli(["php",...at]);w.stderr.pipeTo(new WritableStream({write(g){process.stderr.write(g)}})),w.stdout.pipeTo(new WritableStream({write(g){process.stdout.write(g)}})),await w.exitCode.catch(g=>{throw g.name==="ExitStatus"&&process.exit(g.status===void 0?1:g.status),g}).finally(()=>{setTimeout(()=>{process.exit(0)},100)})}fi();