UNPKG

@yuebai008/cli

Version:

Command line interface for rapid qg-minigame development

1 lines 23.1 kB
import*as Common from"../common/common.js";import*as Host from"../host/host.js";import*as i18n from"../i18n/i18n.js";import*as Platform from"../platform/platform.js";import*as Root from"../root/root.js";import{ScopeRef}from"./RemoteObject.js";import{Events as ResourceTreeModelEvents,ResourceTreeModel}from"./ResourceTreeModel.js";import{RuntimeModel}from"./RuntimeModel.js";import{Script}from"./Script.js";import{Capability,Type}from"./Target.js";import{SDKModel}from"./SDKModel.js";import{SourceMapManager}from"./SourceMapManager.js";const UIStrings={local:"Local",closure:"Closure",block:"Block",script:"Script",withBlock:"`With` block",catchBlock:"`Catch` block",global:"Global",module:"Module",expression:"Expression"},str_=i18n.i18n.registerUIStrings("core/sdk/DebuggerModel.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);export function sortAndMergeRanges(e){function t(e,t){return e.lineNumber-t.lineNumber||e.columnNumber-t.columnNumber}function n(e,n){if(e.scriptId!==n.scriptId)return!1;const a=t(e.start,n.start);return a<0?t(e.end,n.start)>=0:!(a>0)||t(e.start,n.end)<=0}if(0===e.length)return[];e.sort(((e,n)=>e.scriptId<n.scriptId?-1:e.scriptId>n.scriptId?1:t(e.start,n.start)||t(e.end,n.end)));let a=e[0];const s=[];for(let r=1;r<e.length;++r){const i=e[r];n(a,i)?t(a.end,i.end)<=0&&(a={...a,end:i.end}):(s.push(a),a=i)}return s.push(a),s}export var StepMode;!function(e){e.StepInto="StepInto",e.StepOut="StepOut",e.StepOver="StepOver"}(StepMode||(StepMode={}));export class DebuggerModel extends SDKModel{agent;runtimeModelInternal;#e;#t;#n;#a;#s;continueToLocationCallback;#r;#i;#o;#l;#c;#u;#d;evaluateOnCallFrameCallback;#g;#p=new Common.ObjectWrapper.ObjectWrapper;#h;#m;constructor(e){super(e),e.registerDebuggerDispatcher(new DebuggerDispatcher(this)),this.agent=e.debuggerAgent(),this.runtimeModelInternal=e.model(RuntimeModel),this.#e=new SourceMapManager(e),this.#t=null,this.#n=new Map,this.#a=new Map,this.#s=[],this.continueToLocationCallback=null,this.#r=null,this.#i=!1,this.#o=null,this.#l=0,this.#c=null,this.#u=null,this.#d=null,this.evaluateOnCallFrameCallback=null,this.#g=null,this.#h=null,this.#m=!1,Common.Settings.Settings.instance().moduleSetting("pauseOnExceptionEnabled").addChangeListener(this.pauseOnExceptionStateChanged,this),Common.Settings.Settings.instance().moduleSetting("pauseOnCaughtException").addChangeListener(this.pauseOnExceptionStateChanged,this),Common.Settings.Settings.instance().moduleSetting("pauseOnUncaughtException").addChangeListener(this.pauseOnExceptionStateChanged,this),Common.Settings.Settings.instance().moduleSetting("disableAsyncStackTraces").addChangeListener(this.asyncStackTracesStateChanged,this),Common.Settings.Settings.instance().moduleSetting("breakpointsActive").addChangeListener(this.breakpointsActiveChanged,this),e.suspended()||this.enableDebugger(),this.#e.setEnabled(Common.Settings.Settings.instance().moduleSetting("jsSourceMapsEnabled").get()),Common.Settings.Settings.instance().moduleSetting("jsSourceMapsEnabled").addChangeListener((e=>this.#e.setEnabled(e.data)));const t=e.model(ResourceTreeModel);t&&t.addEventListener(ResourceTreeModelEvents.FrameNavigated,this.onFrameNavigated,this)}sourceMapManager(){return this.#e}runtimeModel(){return this.runtimeModelInternal}debuggerEnabled(){return Boolean(this.#i)}debuggerId(){return this.#o}async enableDebugger(){if(this.#i)return;this.#i=!0;const e=Root.Runtime.Runtime.queryParam("remoteFrontend")||Root.Runtime.Runtime.queryParam("ws")?1e7:1e8,t=this.agent.invoke_enable({maxScriptsCacheSize:e});let n;Root.Runtime.experiments.isEnabled(Root.Runtime.ExperimentName.INSTRUMENTATION_BREAKPOINTS)&&(n=this.agent.invoke_setInstrumentationBreakpoint({instrumentation:"beforeScriptExecution"})),this.pauseOnExceptionStateChanged(),this.asyncStackTracesStateChanged(),Common.Settings.Settings.instance().moduleSetting("breakpointsActive").get()||this.breakpointsActiveChanged(),this.dispatchEventToListeners(Events.DebuggerWasEnabled,this);const[a]=await Promise.all([t,n]);this.registerDebugger(a)}async syncDebuggerId(){const e=Root.Runtime.Runtime.queryParam("remoteFrontend")||Root.Runtime.Runtime.queryParam("ws")?1e7:1e8,t=this.agent.invoke_enable({maxScriptsCacheSize:e});return t.then(this.registerDebugger.bind(this)),t}onFrameNavigated(){DebuggerModel.shouldResyncDebuggerId||(DebuggerModel.shouldResyncDebuggerId=!0)}registerDebugger(e){if(e.getError()||void 0===e.debuggerId)return void(this.#i=!1);const{debuggerId:t}=e;_debuggerIdToModel.set(t,this),this.#o=t,this.dispatchEventToListeners(Events.DebuggerIsReadyToPause,this)}isReadyToPause(){return Boolean(this.#o)}static async modelForDebuggerId(e){return DebuggerModel.shouldResyncDebuggerId&&(await DebuggerModel.resyncDebuggerIdForModels(),DebuggerModel.shouldResyncDebuggerId=!1),_debuggerIdToModel.get(e)||null}static async resyncDebuggerIdForModels(){const e=_debuggerIdToModel.values();for(const t of e)t.debuggerEnabled()&&await t.syncDebuggerId()}async disableDebugger(){this.#i&&(this.#i=!1,await this.asyncStackTracesStateChanged(),await this.agent.invoke_disable(),this.#m=!1,this.globalObjectCleared(),this.dispatchEventToListeners(Events.DebuggerWasDisabled,this),"string"==typeof this.#o&&_debuggerIdToModel.delete(this.#o),this.#o=null)}skipAllPauses(e){this.#l&&(clearTimeout(this.#l),this.#l=0),this.agent.invoke_setSkipAllPauses({skip:e})}skipAllPausesUntilReloadOrTimeout(e){this.#l&&clearTimeout(this.#l),this.agent.invoke_setSkipAllPauses({skip:!0}),this.#l=window.setTimeout(this.skipAllPauses.bind(this,!1),e)}pauseOnExceptionStateChanged(){const e=Common.Settings.Settings.instance().moduleSetting("pauseOnCaughtException").get();let t;const n=Common.Settings.Settings.instance().moduleSetting("pauseOnUncaughtException").get();t=e&&n?"all":e?"caught":n?"uncaught":"none",this.agent.invoke_setPauseOnExceptions({state:t})}asyncStackTracesStateChanged(){const e=!Common.Settings.Settings.instance().moduleSetting("disableAsyncStackTraces").get()&&this.#i?32:0;return this.agent.invoke_setAsyncCallStackDepth({maxDepth:e})}breakpointsActiveChanged(){this.agent.invoke_setBreakpointsActive({active:Common.Settings.Settings.instance().moduleSetting("breakpointsActive").get()})}setComputeAutoStepRangesCallback(e){this.#u=e}async computeAutoStepSkipList(e){let t=[];if(this.#u&&this.#t&&this.#t.callFrames.length>0){const[n]=this.#t.callFrames;t=await this.#u.call(null,e,n)}return sortAndMergeRanges(t.map((({start:e,end:t})=>({scriptId:e.scriptId,start:{lineNumber:e.lineNumber,columnNumber:e.columnNumber},end:{lineNumber:t.lineNumber,columnNumber:t.columnNumber}}))))}async stepInto(){const e=await this.computeAutoStepSkipList(StepMode.StepInto);this.agent.invoke_stepInto({breakOnAsyncCall:!1,skipList:e})}async stepOver(){this.#h=this.#t?.callFrames[0]?.functionLocation()??null;const e=await this.computeAutoStepSkipList(StepMode.StepOver);this.agent.invoke_stepOver({skipList:e})}async stepOut(){const e=await this.computeAutoStepSkipList(StepMode.StepOut);0!==e.length?this.agent.invoke_stepOver({skipList:e}):this.agent.invoke_stepOut()}scheduleStepIntoAsync(){this.computeAutoStepSkipList(StepMode.StepInto).then((e=>{this.agent.invoke_stepInto({breakOnAsyncCall:!0,skipList:e})}))}resume(){this.agent.invoke_resume({terminateOnResume:!1}),this.#m=!1}pause(){this.#m=!0,this.skipAllPauses(!1),this.agent.invoke_pause()}async setBreakpointByURL(e,t,n,a){let s;if(this.target().type()===Type.Node&&e.startsWith("file://")){const t=Common.ParsedURL.ParsedURL.urlToRawPathString(e,Host.Platform.isWin());s=`${Platform.StringUtilities.escapeForRegExp(t)}|${Platform.StringUtilities.escapeForRegExp(e)}`,Host.Platform.isWin()&&t.match(/^.:\\/)&&(s=`[${t[0].toUpperCase()}${t[0].toLowerCase()}]`+s.substr(1))}let r=0;const i=this.#a.get(e)||[];for(let e=0,n=i.length;e<n;++e){const n=i[e];t===n.lineOffset&&(r=r?Math.min(r,n.columnOffset):n.columnOffset)}n=Math.max(n||0,r);const o=await this.agent.invoke_setBreakpointByUrl({lineNumber:t,url:s?void 0:e,urlRegex:s,columnNumber:n,condition:a});if(o.getError())return{locations:[],breakpointId:null};let l=[];return o.locations&&(l=o.locations.map((e=>Location.fromPayload(this,e)))),{locations:l,breakpointId:o.breakpointId}}async setBreakpointInAnonymousScript(e,t,n,a){const s=await this.agent.invoke_setBreakpointByUrl({lineNumber:t,scriptHash:e,columnNumber:n,condition:a});if(s.getError())return{locations:[],breakpointId:null};let r=[];return s.locations&&(r=s.locations.map((e=>Location.fromPayload(this,e)))),{locations:r,breakpointId:s.breakpointId}}async removeBreakpoint(e){await this.agent.invoke_removeBreakpoint({breakpointId:e})}async getPossibleBreakpoints(e,t,n){const a=await this.agent.invoke_getPossibleBreakpoints({start:e.payload(),end:t?t.payload():void 0,restrictToFunction:n});return a.getError()||!a.locations?[]:a.locations.map((e=>BreakLocation.fromPayload(this,e)))}async fetchAsyncStackTrace(e){const t=await this.agent.invoke_getStackTrace({stackTraceId:e});return t.getError()?null:t.stackTrace}breakpointResolved(e,t){this.#p.dispatchEventToListeners(e,Location.fromPayload(this,t))}globalObjectCleared(){this.resetDebuggerPausedDetails(),this.reset(),this.dispatchEventToListeners(Events.GlobalObjectCleared,this)}reset(){for(const e of this.#n.values())this.#e.detachSourceMap(e);this.#n.clear(),this.#a.clear(),this.#s=[],this.#h=null}scripts(){return Array.from(this.#n.values())}scriptForId(e){return this.#n.get(e)||null}scriptsForSourceURL(e){return this.#a.get(e)||[]}scriptsForExecutionContext(e){const t=[];for(const n of this.#n.values())n.executionContextId===e.id&&t.push(n);return t}get callFrames(){return this.#t?this.#t.callFrames:null}debuggerPausedDetails(){return this.#t}async setDebuggerPausedDetails(e){return this.#m=!1,this.#t=e,!(this.#c&&!await this.#c.call(null,e,this.#h))&&(this.#h=null,this.dispatchEventToListeners(Events.DebuggerPaused,this),this.setSelectedCallFrame(e.callFrames[0]),!0)}resetDebuggerPausedDetails(){this.#m=!1,this.#t=null,this.setSelectedCallFrame(null)}setBeforePausedCallback(e){this.#c=e}setExpandCallFramesCallback(e){this.#d=e}setEvaluateOnCallFrameCallback(e){this.evaluateOnCallFrameCallback=e}setSynchronizeBreakpointsCallback(e){this.#g=e}async pausedScript(e,t,n,a,s,r){if("instrumentation"===t){const e=this.scriptForId(n.scriptId);return this.#g&&e&&await this.#g(e),void this.resume()}const i=new DebuggerPausedDetails(this,e,t,n,a,s,r);if(this.#d&&(i.callFrames=await this.#d.call(null,i.callFrames)),this.continueToLocationCallback){const e=this.continueToLocationCallback;if(this.continueToLocationCallback=null,e(i))return}await this.setDebuggerPausedDetails(i)?Common.EventTarget.fireEvent("DevTools.DebuggerPaused"):this.#h?this.stepOver():this.stepInto()}resumedScript(){this.resetDebuggerPausedDetails(),this.dispatchEventToListeners(Events.DebuggerResumed,this)}parsedScriptSource(e,t,n,a,s,r,i,o,l,c,u,d,g,p,h,m,b,S,I,k){const C=this.#n.get(e);if(C)return C;let f=!1;l&&"isDefault"in l&&(f=!l.isDefault);const y=new Script(this,e,t,n,a,s,r,i,o,f,c,u,d,p,h,m,b,S,I,k);this.registerScript(y),this.dispatchEventToListeners(Events.ParsedScriptSource,y),y.isInlineScript()&&!y.hasSourceURL&&(y.isModule?Host.userMetrics.inlineScriptParsed(0):Host.userMetrics.inlineScriptParsed(1)),y.sourceMapURL&&!g&&this.#e.attachSourceMap(y,y.sourceURL,y.sourceMapURL);return g&&y.isAnonymousScript()&&(this.#s.push(y),this.collectDiscardedScripts()),y}setSourceMapURL(e,t){this.#e.detachSourceMap(e),e.sourceMapURL=t,this.#e.attachSourceMap(e,e.sourceURL,e.sourceMapURL)}async setDebugInfoURL(e,t){this.#d&&this.#t&&(this.#t.callFrames=await this.#d.call(null,this.#t.callFrames)),this.dispatchEventToListeners(Events.DebugInfoAttached,e)}executionContextDestroyed(e){for(const t of this.#n.values())t.executionContextId===e.id&&this.#e.detachSourceMap(t)}registerScript(e){if(this.#n.set(e.scriptId,e),e.isAnonymousScript())return;let t=this.#a.get(e.sourceURL);t||(t=[],this.#a.set(e.sourceURL,t)),t.unshift(e)}unregisterScript(e){console.assert(e.isAnonymousScript()),this.#n.delete(e.scriptId)}collectDiscardedScripts(){if(this.#s.length<1e3)return;const e=this.#s.splice(0,100);for(const t of e)this.unregisterScript(t),this.dispatchEventToListeners(Events.DiscardedAnonymousScriptSource,t)}createRawLocation(e,t,n,a){return this.createRawLocationByScriptId(e.scriptId,t,n,a)}createRawLocationByURL(e,t,n,a){for(const s of this.#a.get(e)||[])if(!(s.lineOffset>t||s.lineOffset===t&&void 0!==n&&s.columnOffset>n||s.endLine<t||s.endLine===t&&void 0!==n&&s.endColumn<=n))return new Location(this,s.scriptId,t,n,a);return null}createRawLocationByScriptId(e,t,n,a){return new Location(this,e,t,n,a)}createRawLocationsByStackTrace(e){const t=[];for(let n=e;n;n=n.parent)for(const{scriptId:e,lineNumber:a,columnNumber:s}of n.callFrames)t.push(this.createRawLocationByScriptId(e,a,s));return t}isPaused(){return Boolean(this.debuggerPausedDetails())}isPausing(){return this.#m}setSelectedCallFrame(e){this.#r!==e&&(this.#r=e,this.dispatchEventToListeners(Events.CallFrameSelected,this))}selectedCallFrame(){return this.#r}async evaluateOnSelectedCallFrame(e){const t=this.selectedCallFrame();if(!t)throw new Error("No call frame selected");return t.evaluate(e)}functionDetailsPromise(e){return e.getAllProperties(!1,!1).then(function(e){if(!e)return null;let t=null;if(e.internalProperties)for(const n of e.internalProperties)"[[FunctionLocation]]"===n.name&&(t=n.value);let n=null;if(e.properties)for(const t of e.properties)"name"===t.name&&t.value&&"string"===t.value.type&&(n=t.value);let a=null;t&&(a=this.createRawLocationByScriptId(t.value.scriptId,t.value.lineNumber,t.value.columnNumber));return{location:a,functionName:n?n.value:""}}.bind(this))}async setVariableValue(e,t,n,a){return(await this.agent.invoke_setVariableValue({scopeNumber:e,variableName:t,newValue:n,callFrameId:a})).getError()}addBreakpointListener(e,t,n){this.#p.addEventListener(e,t,n)}removeBreakpointListener(e,t,n){this.#p.removeEventListener(e,t,n)}async setBlackboxPatterns(e){return!(await this.agent.invoke_setBlackboxPatterns({patterns:e})).getError()}dispose(){this.#e.dispose(),this.#o&&_debuggerIdToModel.delete(this.#o),Common.Settings.Settings.instance().moduleSetting("pauseOnExceptionEnabled").removeChangeListener(this.pauseOnExceptionStateChanged,this),Common.Settings.Settings.instance().moduleSetting("pauseOnCaughtException").removeChangeListener(this.pauseOnExceptionStateChanged,this),Common.Settings.Settings.instance().moduleSetting("disableAsyncStackTraces").removeChangeListener(this.asyncStackTracesStateChanged,this)}async suspendModel(){await this.disableDebugger()}async resumeModel(){await this.enableDebugger()}static shouldResyncDebuggerId=!1;getContinueToLocationCallback(){return this.continueToLocationCallback}getEvaluateOnCallFrameCallback(){return this.evaluateOnCallFrameCallback}}export const _debuggerIdToModel=new Map;export var PauseOnExceptionsState;!function(e){e.DontPauseOnExceptions="none",e.PauseOnAllExceptions="all",e.PauseOnCaughtExceptions="caught",e.PauseOnUncaughtExceptions="uncaught"}(PauseOnExceptionsState||(PauseOnExceptionsState={}));export var Events;!function(e){e.DebuggerWasEnabled="DebuggerWasEnabled",e.DebuggerWasDisabled="DebuggerWasDisabled",e.DebuggerPaused="DebuggerPaused",e.DebuggerResumed="DebuggerResumed",e.DebugInfoAttached="DebugInfoAttached",e.ParsedScriptSource="ParsedScriptSource",e.DiscardedAnonymousScriptSource="DiscardedAnonymousScriptSource",e.GlobalObjectCleared="GlobalObjectCleared",e.CallFrameSelected="CallFrameSelected",e.DebuggerIsReadyToPause="DebuggerIsReadyToPause",e.ScriptSourceWasEdited="ScriptSourceWasEdited"}(Events||(Events={}));class DebuggerDispatcher{#b;constructor(e){this.#b=e}paused({callFrames:e,reason:t,data:n,hitBreakpoints:a,asyncStackTrace:s,asyncStackTraceId:r}){this.#b.debuggerEnabled()&&this.#b.pausedScript(e,t,n,a||[],s,r)}resumed(){this.#b.debuggerEnabled()&&this.#b.resumedScript()}scriptParsed({scriptId:e,url:t,startLine:n,startColumn:a,endLine:s,endColumn:r,executionContextId:i,hash:o,executionContextAuxData:l,isLiveEdit:c,sourceMapURL:u,hasSourceURL:d,length:g,isModule:p,stackTrace:h,codeOffset:m,scriptLanguage:b,debugSymbols:S,embedderName:I}){this.#b.debuggerEnabled()&&this.#b.parsedScriptSource(e,t,n,a,s,r,i,o,l,Boolean(c),u,Boolean(d),!1,g||0,p||null,h||null,m||null,b||null,S||null,I||null)}scriptFailedToParse({scriptId:e,url:t,startLine:n,startColumn:a,endLine:s,endColumn:r,executionContextId:i,hash:o,executionContextAuxData:l,sourceMapURL:c,hasSourceURL:u,length:d,isModule:g,stackTrace:p,codeOffset:h,scriptLanguage:m,embedderName:b}){this.#b.debuggerEnabled()&&this.#b.parsedScriptSource(e,t,n,a,s,r,i,o,l,!1,c,Boolean(u),!0,d||0,g||null,p||null,h||null,m||null,null,b||null)}breakpointResolved({breakpointId:e,location:t}){this.#b.debuggerEnabled()&&this.#b.breakpointResolved(e,t)}}export class Location{debuggerModel;scriptId;lineNumber;columnNumber;inlineFrameIndex;constructor(e,t,n,a,s){this.debuggerModel=e,this.scriptId=t,this.lineNumber=n,this.columnNumber=a||0,this.inlineFrameIndex=s||0}static fromPayload(e,t,n){return new Location(e,t.scriptId,t.lineNumber,t.columnNumber,n)}payload(){return{scriptId:this.scriptId,lineNumber:this.lineNumber,columnNumber:this.columnNumber}}script(){return this.debuggerModel.scriptForId(this.scriptId)}continueToLocation(e){e&&(this.debuggerModel.continueToLocationCallback=this.paused.bind(this,e)),this.debuggerModel.agent.invoke_continueToLocation({location:this.payload(),targetCallFrames:"current"})}paused(e,t){const n=t.callFrames[0].location();return n.scriptId===this.scriptId&&n.lineNumber===this.lineNumber&&n.columnNumber===this.columnNumber&&(e(),!0)}id(){return this.debuggerModel.target().id()+":"+this.scriptId+":"+this.lineNumber+":"+this.columnNumber}}export class BreakLocation extends Location{type;constructor(e,t,n,a,s){super(e,t,n,a),s&&(this.type=s)}static fromPayload(e,t){return new BreakLocation(e,t.scriptId,t.lineNumber,t.columnNumber,t.type)}}export class CallFrame{debuggerModel;#S;payload;#I;#k;#C;#f;#y;#M;#v;#L=null;canBeRestarted;constructor(e,t,n,a,s){this.debuggerModel=e,this.#S=t,this.payload=n,this.#I=Location.fromPayload(e,n.location,a),this.#k=[],this.#C=null,this.#f=a||0,this.#y=s||n.functionName,this.canBeRestarted=Boolean(n.canBeRestarted);for(let e=0;e<n.scopeChain.length;++e){const t=new Scope(this,e);this.#k.push(t),"local"===t.type()&&(this.#C=t)}n.functionLocation&&(this.#M=Location.fromPayload(e,n.functionLocation)),this.#v=n.returnValue?this.debuggerModel.runtimeModel().createRemoteObject(n.returnValue):null}static fromPayloadArray(e,t){const n=[];for(let a=0;a<t.length;++a){const s=t[a],r=e.scriptForId(s.location.scriptId);r&&n.push(new CallFrame(e,r,s))}return n}createVirtualCallFrame(e,t){return new CallFrame(this.debuggerModel,this.#S,this.payload,e,t)}setMissingDebugInfoDetails(e){this.#L=e}get missingDebugInfoDetails(){return this.#L}get script(){return this.#S}get id(){return this.payload.callFrameId}get inlineFrameIndex(){return this.#f}scopeChain(){return this.#k}localScope(){return this.#C}thisObject(){return this.payload.this?this.debuggerModel.runtimeModel().createRemoteObject(this.payload.this):null}returnValue(){return this.#v}async setReturnValue(e){if(!this.#v)return null;const t=await this.debuggerModel.agent.invoke_evaluateOnCallFrame({callFrameId:this.id,expression:e,silent:!0,objectGroup:"backtrace"});if(t.getError()||t.exceptionDetails)return null;return(await this.debuggerModel.agent.invoke_setReturnValue({newValue:t.result})).getError()?null:(this.#v=this.debuggerModel.runtimeModel().createRemoteObject(t.result),this.#v)}get functionName(){return this.#y}location(){return this.#I}functionLocation(){return this.#M||null}async evaluate(e){const t=this.debuggerModel,n=t.runtimeModel();if((Boolean(e.throwOnSideEffect)||void 0!==e.timeout)&&(!1===n.hasSideEffectSupport()||null===n.hasSideEffectSupport()&&!await n.checkSideEffectSupport()))return{error:"Side-effect checks not supported by backend."};const a=t.getEvaluateOnCallFrameCallback();if(a){const t=await a(this,e);if(t)return t}const s=await this.debuggerModel.agent.invoke_evaluateOnCallFrame({callFrameId:this.id,expression:e.expression,objectGroup:e.objectGroup,includeCommandLineAPI:e.includeCommandLineAPI,silent:e.silent,returnByValue:e.returnByValue,generatePreview:e.generatePreview,throwOnSideEffect:e.throwOnSideEffect,timeout:e.timeout}),r=s.getError();return r?{error:r}:{object:n.createRemoteObject(s.result),exceptionDetails:s.exceptionDetails}}async restart(){console.assert(this.canBeRestarted,"This frame can not be restarted."),await this.debuggerModel.agent.invoke_restartFrame({callFrameId:this.id,mode:"StepInto"})}getPayload(){return this.payload}}export class Scope{#R;#D;#E;#P;#x;#F;#T;constructor(e,t){this.#R=e,this.#D=e.getPayload().scopeChain[t],this.#E=this.#D.type,this.#P=this.#D.name,this.#x=t,this.#T=null;const n=this.#D.startLocation?Location.fromPayload(e.debuggerModel,this.#D.startLocation):null,a=this.#D.endLocation?Location.fromPayload(e.debuggerModel,this.#D.endLocation):null;n&&a&&n.scriptId===a.scriptId?this.#F={start:n,end:a}:this.#F=null}callFrame(){return this.#R}type(){return this.#E}typeName(){switch(this.#E){case"local":return i18nString(UIStrings.local);case"closure":return i18nString(UIStrings.closure);case"catch":return i18nString(UIStrings.catchBlock);case"eval":return i18n.i18n.lockedString("Eval");case"block":return i18nString(UIStrings.block);case"script":return i18nString(UIStrings.script);case"with":return i18nString(UIStrings.withBlock);case"global":return i18nString(UIStrings.global);case"module":return i18nString(UIStrings.module);case"wasm-expression-stack":return i18nString(UIStrings.expression)}return""}name(){return this.#P}range(){return this.#F}object(){if(this.#T)return this.#T;const e=this.#R.debuggerModel.runtimeModel(),t="with"!==this.#E&&"global"!==this.#E;return this.#T=t?e.createScopeRemoteObject(this.#D.object,new ScopeRef(this.#x,this.#R.id)):e.createRemoteObject(this.#D.object),this.#T}description(){return"with"!==this.#E&&"global"!==this.#E?"":this.#D.object.description||""}icon(){}}export class DebuggerPausedDetails{debuggerModel;callFrames;reason;auxData;breakpointIds;asyncStackTrace;asyncStackTraceId;constructor(e,t,n,a,s,r,i){this.debuggerModel=e,this.callFrames=CallFrame.fromPayloadArray(e,t),this.reason=n,this.auxData=a,this.breakpointIds=s,r&&(this.asyncStackTrace=this.cleanRedundantFrames(r)),this.asyncStackTraceId=i}exception(){return"exception"!==this.reason&&"promiseRejection"!==this.reason?null:this.debuggerModel.runtimeModel().createRemoteObject(this.auxData)}cleanRedundantFrames(e){let t=e,n=null;for(;t;)"async function"===t.description&&t.callFrames.length&&t.callFrames.shift(),n&&!t.callFrames.length?n.parent=t.parent:n=t,t=t.parent;return e}}SDKModel.register(DebuggerModel,{capabilities:Capability.JS,autostart:!0});export const LOGPOINT_SOURCE_URL="debugger://logpoint";export const COND_BREAKPOINT_SOURCE_URL="debugger://breakpoint";