UNPKG

@yuebai008/cli

Version:

Command line interface for rapid qg-minigame development

1 lines 1.63 kB
import{Capability}from"./Target.js";import{SDKModel}from"./SDKModel.js";export class PaintProfilerModel extends SDKModel{layerTreeAgent;constructor(e){super(e),this.layerTreeAgent=e.layerTreeAgent()}async loadSnapshotFromFragments(e){const{snapshotId:t}=await this.layerTreeAgent.invoke_loadSnapshot({tiles:e});return t?new PaintProfilerSnapshot(this,t):null}loadSnapshot(e){const t={x:0,y:0,picture:e};return this.loadSnapshotFromFragments([t])}async makeSnapshot(e){const{snapshotId:t}=await this.layerTreeAgent.invoke_makeSnapshot({layerId:e});return t?new PaintProfilerSnapshot(this,t):null}}export class PaintProfilerSnapshot{#e;#t;#o;constructor(e,t){this.#e=e,this.#t=t,this.#o=1}release(){console.assert(this.#o>0,"release is already called on the object"),--this.#o||this.#e.layerTreeAgent.invoke_releaseSnapshot({snapshotId:this.#t})}addReference(){++this.#o,console.assert(this.#o>0,"Referencing a dead object")}async replay(e,t,o){return(await this.#e.layerTreeAgent.invoke_replaySnapshot({snapshotId:this.#t,fromStep:t,toStep:o,scale:e||1})).dataURL}async profile(e){return(await this.#e.layerTreeAgent.invoke_profileSnapshot({snapshotId:this.#t,minRepeatCount:5,minDuration:1,clipRect:e||void 0})).timings}async commandLog(){const e=await this.#e.layerTreeAgent.invoke_snapshotCommandLog({snapshotId:this.#t});return e.commandLog?e.commandLog.map(((e,t)=>new PaintProfilerLogItem(e,t))):null}}export class PaintProfilerLogItem{method;params;commandIndex;constructor(e,t){this.method=e.method,this.params=e.params,this.commandIndex=t}}SDKModel.register(PaintProfilerModel,{capabilities:Capability.DOM,autostart:!1});