@php-wasm/cli 2.0.22 → 3.0.0
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/main.js +2 -2
- package/main.js.map +1 -1
- package/package.json +5 -5
package/main.js
CHANGED
|
@@ -46,8 +46,8 @@ Actual: `+y.attribValue);else{var K=y.tag,tt=y.tags[y.tags.length-1]||y;K.ns===t
|
|
|
46
46
|
|
|
47
47
|
2. Run your php file, project, plugin or theme using PHP.wasm or Playground CLI.
|
|
48
48
|
|
|
49
|
-
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[n,c]of this.scriptIdByUrl.entries())await this.sendScriptToCDP(n,c)}async sendScriptToCDP(n,c){const a=this.uriFromBridgeToCDPSyntaxHighlight(n),f=this.uriFromBridgeToCDP(n)
|
|
50
|
-
`),i=t.map((g,b)=>b===0?"AAAA":"AACA").join(";"),m={version:3,file:f,sources:[a],sourcesContent:[o],mappings:i},w=`data:application/json;base64,${Buffer.from(JSON.stringify(m),"utf-8").toString("base64")}`;this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:c,url:f,startLine:0,startColumn:0,endLine:t.length,endColumn:0,executionContextId:1,sourceMapURL:w}})}getOrCreateScriptId(n){let c=this.scriptIdByUrl.get(n);return c||(c=Mn("sha256").update(String(this.nextScriptId++)).digest("hex").slice(0,16),this.scriptIdByUrl.set(n,c)),c}formatPropertyFullName(n){let c=!1,a="";for(const f of n)f==='"'||f==="\\"||f==="\0"?(a+="\\"+f,c=!0):f===" "?(a+=f,c=!0):a+=f;return(c||n.includes("'"))&&(a=`"${a}"`),a}sendDbgpCommand(n,c){const f=(this.nextTxnId++).toString();let o=`${n} -i ${f}`;return c!==void 0&&(o+=` ${c}`),this.dbgp.sendCommand(o),f}async handleCdpMessage(n){const{id:c,method:a,params:f}=n;let o={},t=!0;switch(a){case"Debugger.enable":case"Runtime.enable":o={};break;case"Debugger.setBreakpointByUrl":{const{url:i,lineNumber:m}=f,N=this.uriFromCDPToBridge(i),w=this.uriFromBridgeToDBGP(N),g=(typeof m=="number"?m:0)+1,b=String(this.breakpoints.size+1);if(this.xdebugConnected){const x=`breakpoint_set -t line -f ${this.formatPropertyFullName(w)} -n ${g}`,O=this.sendDbgpCommand(x);this.pendingCommands.set(O,{cdpId:c,cdpMethod:a,params:{breakpointId:b,fileUri:N,lineNumber:g}}),t=!1}else this.breakpoints.set(b,{cdpId:b,xdebugId:null,fileUri:N,lineNumber:g}),o={breakpointId:b,locations:[{scriptId:this.getOrCreateScriptId(N),lineNumber:g-1,columnNumber:0}]};break}case"Debugger.removeBreakpoint":{const{breakpointId:i}=f,m=String(i),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:c,cdpMethod:a}),t=!1}this.breakpoints.delete(m)}o={};break}case"Debugger.resume":{this.xdebugConnected&&this.sendDbgpCommand("run"),o={};break}case"Debugger.stepOver":{this.xdebugConnected&&this.sendDbgpCommand("step_over"),o={};break}case"Debugger.stepInto":{this.xdebugConnected&&this.sendDbgpCommand("step_into"),o={};break}case"Debugger.stepOut":{this.xdebugConnected&&this.sendDbgpCommand("step_out"),o={};break}case"Debugger.pause":{this.xdebugConnected&&this.sendDbgpCommand("break"),o={};break}case"Runtime.evaluate":case"Debugger.evaluateOnCallFrame":{const i=f.expression||"",m=f.callFrameId;if(a==="Debugger.evaluateOnCallFrame"){if(m===void 0||!this.callFramesMap.has(m)){this.cdp.sendMessage({id:c,error:{code:-32e3,message:"No such call frame"}});return}if(this.callFramesMap.get(m)!==0){this.cdp.sendMessage({id:c,error:{code:-32e3,message:"Evaluation in this frame not supported"}});return}}if(this.xdebugConnected){const N=Buffer.from(i).toString("base64"),w=this.sendDbgpCommand("eval",`-- ${N}`);this.pendingCommands.set(w,{cdpId:c,cdpMethod:a}),t=!1}else o={result:{type:"undefined",value:void 0}};break}case"Runtime.getProperties":{const{objectId:i}=f,m=this.objectHandles.get(i);if(m&&this.xdebugConnected)if(m.type==="context"){const N=m.contextId??0,g=`context_get -d ${m.depth} -c ${N} -p 0 -m 32`,b=this.sendDbgpCommand(g),x={...m,currentPage:0,aggregatedProps:[]};this.objectHandles.set(i,x),this.pendingCommands.set(b,{cdpId:c,cdpMethod:a,params:{objectId:i}}),t=!1}else if(m.type==="property"){const N=m.depth,w=m.fullname,g=this.formatPropertyFullName(w),b=`property_get -d ${N} -n ${g} -p 0 -m 32`,x=this.sendDbgpCommand(b),O={...m,currentPage:0,aggregatedProps:[]};this.objectHandles.set(i,O),this.pendingCommands.set(x,{cdpId:c,cdpMethod:a,params:{parentObjectId:i}}),t=!1}else o={result:[]};else o={result:[]};break}case"Debugger.getScriptSource":{const i=f.scriptId,m=[...this.scriptIdByUrl.entries()].find(([,w])=>w===i)?.[0],N=[];m&&N.push(`Here's the full path for your convenience:
|
|
49
|
+
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[n,c]of this.scriptIdByUrl.entries())await this.sendScriptToCDP(n,c)}async sendScriptToCDP(n,c){const a=this.uriFromBridgeToCDPSyntaxHighlight(n),f=this.uriFromBridgeToCDP(n);try{const o=await this.readPHPFile(n),t=o.split(`
|
|
50
|
+
`),i=t.map((g,b)=>b===0?"AAAA":"AACA").join(";"),m={version:3,file:f,sources:[a],sourcesContent:[o],mappings:i},w=`data:application/json;base64,${Buffer.from(JSON.stringify(m),"utf-8").toString("base64")}`;this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:c,url:f,startLine:0,startColumn:0,endLine:t.length,endColumn:0,executionContextId:1,sourceMapURL:w}})}catch(o){this.cdp.sendMessage({method:"Log.entryAdded",params:{entry:{source:"other",level:"warning",text:o.message,timestamp:Date.now()}}})}}getOrCreateScriptId(n){let c=this.scriptIdByUrl.get(n);return c||(c=Mn("sha256").update(String(this.nextScriptId++)).digest("hex").slice(0,16),this.scriptIdByUrl.set(n,c)),c}formatPropertyFullName(n){let c=!1,a="";for(const f of n)f==='"'||f==="\\"||f==="\0"?(a+="\\"+f,c=!0):f===" "?(a+=f,c=!0):a+=f;return(c||n.includes("'"))&&(a=`"${a}"`),a}sendDbgpCommand(n,c){const f=(this.nextTxnId++).toString();let o=`${n} -i ${f}`;return c!==void 0&&(o+=` ${c}`),this.dbgp.sendCommand(o),f}async handleCdpMessage(n){const{id:c,method:a,params:f}=n;let o={},t=!0;switch(a){case"Debugger.enable":case"Runtime.enable":o={};break;case"Debugger.setBreakpointByUrl":{const{url:i,lineNumber:m}=f,N=this.uriFromCDPToBridge(i),w=this.uriFromBridgeToDBGP(N),g=(typeof m=="number"?m:0)+1,b=String(this.breakpoints.size+1);if(this.xdebugConnected){const x=`breakpoint_set -t line -f ${this.formatPropertyFullName(w)} -n ${g}`,O=this.sendDbgpCommand(x);this.pendingCommands.set(O,{cdpId:c,cdpMethod:a,params:{breakpointId:b,fileUri:N,lineNumber:g}}),t=!1}else this.breakpoints.set(b,{cdpId:b,xdebugId:null,fileUri:N,lineNumber:g}),o={breakpointId:b,locations:[{scriptId:this.getOrCreateScriptId(N),lineNumber:g-1,columnNumber:0}]};break}case"Debugger.removeBreakpoint":{const{breakpointId:i}=f,m=String(i),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:c,cdpMethod:a}),t=!1}this.breakpoints.delete(m)}o={};break}case"Debugger.resume":{this.xdebugConnected&&this.sendDbgpCommand("run"),o={};break}case"Debugger.stepOver":{this.xdebugConnected&&this.sendDbgpCommand("step_over"),o={};break}case"Debugger.stepInto":{this.xdebugConnected&&this.sendDbgpCommand("step_into"),o={};break}case"Debugger.stepOut":{this.xdebugConnected&&this.sendDbgpCommand("step_out"),o={};break}case"Debugger.pause":{this.xdebugConnected&&this.sendDbgpCommand("break"),o={};break}case"Runtime.evaluate":case"Debugger.evaluateOnCallFrame":{const i=f.expression||"",m=f.callFrameId;if(a==="Debugger.evaluateOnCallFrame"){if(m===void 0||!this.callFramesMap.has(m)){this.cdp.sendMessage({id:c,error:{code:-32e3,message:"No such call frame"}});return}if(this.callFramesMap.get(m)!==0){this.cdp.sendMessage({id:c,error:{code:-32e3,message:"Evaluation in this frame not supported"}});return}}if(this.xdebugConnected){const N=Buffer.from(i).toString("base64"),w=this.sendDbgpCommand("eval",`-- ${N}`);this.pendingCommands.set(w,{cdpId:c,cdpMethod:a}),t=!1}else o={result:{type:"undefined",value:void 0}};break}case"Runtime.getProperties":{const{objectId:i}=f,m=this.objectHandles.get(i);if(m&&this.xdebugConnected)if(m.type==="context"){const N=m.contextId??0,g=`context_get -d ${m.depth} -c ${N} -p 0 -m 32`,b=this.sendDbgpCommand(g),x={...m,currentPage:0,aggregatedProps:[]};this.objectHandles.set(i,x),this.pendingCommands.set(b,{cdpId:c,cdpMethod:a,params:{objectId:i}}),t=!1}else if(m.type==="property"){const N=m.depth,w=m.fullname,g=this.formatPropertyFullName(w),b=`property_get -d ${N} -n ${g} -p 0 -m 32`,x=this.sendDbgpCommand(b),O={...m,currentPage:0,aggregatedProps:[]};this.objectHandles.set(i,O),this.pendingCommands.set(x,{cdpId:c,cdpMethod:a,params:{parentObjectId:i}}),t=!1}else o={result:[]};else o={result:[]};break}case"Debugger.getScriptSource":{const i=f.scriptId,m=[...this.scriptIdByUrl.entries()].find(([,w])=>w===i)?.[0],N=[];m&&N.push(`Here's the full path for your convenience:
|
|
51
51
|
`,`${this.uriFromBridgeToCDPSyntaxHighlight(m).replace("file://","")}
|
|
52
52
|
`),o={scriptSource:["`Are you looking for your source code?","Go to PHP.wasm group in the navigator and find it there.",...N,"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:
|
|
53
53
|
`,"https://github.com/WordPress/wordpress-playground/pull/2566`"].join(`
|