@yuebai008/cli
Version:
Command line interface for rapid qg-minigame development
1 lines • 1.97 kB
JavaScript
import*as Host from"../../core/host/host.js";import*as i18n from"../../core/i18n/i18n.js";import*as SDK from"../../core/sdk/sdk.js";import*as UI from"../../ui/legacy/legacy.js";import{ProfilesPanel}from"./ProfilesPanel.js";import{instance}from"./ProfileTypeRegistry.js";const UIStrings={revealInSummaryView:"Reveal in Summary view"},str_=i18n.i18n.registerUIStrings("panels/profiler/HeapProfilerPanel.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);let heapProfilerPanelInstance;export class HeapProfilerPanel extends ProfilesPanel{constructor(){const e=instance;super("heap_profiler",[e.heapSnapshotProfileType,e.trackingHeapSnapshotProfileType,e.samplingHeapProfileType],"profiler.heap-toggle-recording")}static instance(){return heapProfilerPanelInstance||(heapProfilerPanelInstance=new HeapProfilerPanel),heapProfilerPanelInstance}appendApplicableItems(e,n,t){if(!(t instanceof SDK.RemoteObject.RemoteObject))return;if(!this.isShowing())return;const r=t;if(!r.objectId)return;const o=r.objectId;if(!instance.heapSnapshotProfileType.getProfiles().length)return;const i=r.runtimeModel().heapProfilerModel();i&&n.revealSection().appendItem(i18nString(UIStrings.revealInSummaryView),function(e){i.snapshotObjectIdForObjectId(o).then((n=>{this.isShowing()&&n&&this.showObject(n,e)}))}.bind(this,"Summary"))}handleAction(e,n){const t=UI.Context.Context.instance().flavor(HeapProfilerPanel);return console.assert(Boolean(t)&&t instanceof HeapProfilerPanel),t&&t.toggleRecord(),!0}wasShown(){super.wasShown(),UI.Context.Context.instance().setFlavor(HeapProfilerPanel,this),Host.userMetrics.panelLoaded("heap_profiler","DevTools.Launch.HeapProfiler")}willHide(){UI.Context.Context.instance().setFlavor(HeapProfilerPanel,null)}showObject(e,n){const t=instance.heapSnapshotProfileType.getProfiles();for(let r=0;r<t.length;r++){const o=t[r];if(o.maxJSObjectId>=parseInt(e,10)){this.showProfile(o);this.viewForProfile(o).selectLiveObject(n,e);break}}}}