@yuebai008/cli
Version:
Command line interface for rapid qg-minigame development
8 lines • 24 kB
JavaScript
import*as Common from"../../core/common/common.js";import*as i18n from"../../core/i18n/i18n.js";import*as Platform from"../../core/platform/platform.js";import*as SDK from"../../core/sdk/sdk.js";import*as HeapSnapshotModel from"../../models/heap_snapshot_model/heap_snapshot_model.js";import*as DataGrid from"../../ui/legacy/components/data_grid/data_grid.js";import*as UI from"../../ui/legacy/legacy.js";import{HeapSnapshotSortableDataGridEvents}from"./HeapSnapshotDataGrids.js";const UIStrings={genericStringsTwoPlaceholders:"{PH1}, {PH2}",internalArray:"(internal array)[]",userObjectReachableFromWindow:"User object reachable from window",detachedFromDomTree:"Detached from DOM tree",previewIsNotAvailable:"Preview is not available",revealInSummaryView:"Reveal in Summary view",summary:"Summary",revealObjectSWithIdSInSummary:"Reveal object ''{PH1}'' with id @{PH2} in Summary view",storeAsGlobalVariable:"Store as global variable",inElement:"in"},str_=i18n.i18n.registerUIStrings("panels/profiler/HeapSnapshotGridNodes.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);class HeapSnapshotGridNodeBase extends DataGrid.DataGrid.DataGridNode{}export class HeapSnapshotGridNode extends(Common.ObjectWrapper.eventMixin(HeapSnapshotGridNodeBase)){dataGridInternal;instanceCount;savedChildren;retrievedChildrenRanges;providerObject;reachableFromWindow;populated;constructor(e,t){super(null,t),this.dataGridInternal=e,this.instanceCount=0,this.savedChildren=new Map,this.retrievedChildrenRanges=[],this.providerObject=null,this.reachableFromWindow=!1}get name(){}heapSnapshotDataGrid(){return this.dataGridInternal}createProvider(){throw new Error("Not implemented.")}comparator(){throw new Error("Not implemented.")}getHash(){throw new Error("Not implemented.")}createChildNode(e){throw new Error("Not implemented.")}retainersDataSource(){return null}provider(){return this.providerObject||(this.providerObject=this.createProvider()),this.providerObject}createCell(e){return super.createCell(e)}collapse(){super.collapse(),this.dataGridInternal.updateVisibleNodes(!0)}expand(){super.expand(),this.dataGridInternal.updateVisibleNodes(!0)}dispose(){this.providerObject&&this.providerObject.dispose();for(let e=this.children[0];e;e=e.traverseNextNode(!0,this,!0))e.dispose()}queryObjectContent(e,t){throw new Error("Not implemented.")}tryQueryObjectContent(e,t){throw new Error("Not implemented.")}populateContextMenu(e,t,a){}toPercentString(e){return e.toFixed(0)+" %"}toUIDistance(e){const t=HeapSnapshotModel.HeapSnapshotModel.baseSystemDistance;return e>=0&&e<t?e.toString():"−"}allChildren(){return this.dataGridInternal.allChildren(this)}removeChildByIndex(e){this.dataGridInternal.removeChildByIndex(this,e)}childForPosition(e){let t=0;for(let a=0;a<this.retrievedChildrenRanges.length;a++){const n=this.retrievedChildrenRanges[a];if(n.from<=e&&e<n.to){const a=t+e-n.from;return this.allChildren()[a]}t+=n.to-n.from+1}return null}createValueCell(e){const t=UI.Fragment.html`<td class="numeric-column" />`,a=this.dataGrid;if(a.snapshot&&0!==a.snapshot.totalSize){const a=document.createElement("div"),n=UI.Fragment.html`<span>${this.data[e]}</span>`;a.appendChild(n);const i=e+"-percent";if(i in this.data){const r=UI.Fragment.html`<span class="percent-column">${this.data[i]}</span>`;a.appendChild(r),a.classList.add("profile-multiple-values"),UI.ARIAUtils.markAsHidden(n),UI.ARIAUtils.markAsHidden(r),this.setCellAccessibleName(i18nString(UIStrings.genericStringsTwoPlaceholders,{PH1:this.data[e],PH2:this.data[i]}),t,e)}t.appendChild(a)}return t}populate(){this.populated||(this.populated=!0,this.provider().sortAndRewind(this.comparator()).then((()=>this.populateChildren())))}expandWithoutPopulate(){return this.populated=!0,this.expand(),this.provider().sortAndRewind(this.comparator())}childHashForEntity(e){return"edgeIndex"in e?e.edgeIndex:e.id}populateChildren(e,t){return new Promise((a=>{e=e||0,t=t||e+this.dataGridInternal.defaultPopulateCount();let n=e;function i(e){if(n>=e)return;const t=Math.min(n+this.dataGridInternal.defaultPopulateCount(),e);this.provider().serializeItemsRange(n,t).then((t=>o.call(this,t,e))),n=t}function r(e,t){if(this.savedChildren){const a=this.childHashForEntity(e),n=this.savedChildren.get(a);if(n)return void this.dataGridInternal.insertChild(this,n,t)}this.dataGridInternal.insertChild(this,this.createChildNode(e),t)}function s(e,t,a){const n=new DataGrid.ShowMoreDataGridNode.ShowMoreDataGridNode(this.populateChildren.bind(this),e,t,this.dataGridInternal.defaultPopulateCount());this.dataGridInternal.insertChild(this,n,a)}function o(e,t){let o=0,d=e.startPosition;const l=e.items;let h=0;if(this.retrievedChildrenRanges.length){let t=0,a=!1,n={from:0,to:0};for(;t<this.retrievedChildrenRanges.length;){if(n=this.retrievedChildrenRanges[t],n.to>=d){a=!0;break}h+=n.to-n.from,n.to<e.totalLength&&(h+=1),++t}if(!a||e.startPosition<n.from){this.allChildren()[h-1].setEndPosition(e.startPosition),s.call(this,e.startPosition,a?n.from:e.totalLength,h),n={from:e.startPosition,to:e.startPosition},a||(t=this.retrievedChildrenRanges.length),this.retrievedChildrenRanges.splice(t,0,n)}else h+=d-n.from;for(;n.to<e.endPosition;){const a=n.to-d;h+=a,o+=a,d=n.to;const i=this.retrievedChildrenRanges[t+1];let s=i?i.from:e.totalLength;for(s>e.endPosition&&(s=e.endPosition);d<s;)r.call(this,l[o++],h++),++d;i&&s===i.from?(n.to=i.to,this.removeChildByIndex(h),this.retrievedChildrenRanges.splice(t+1,1)):(n.to=s,s===e.totalLength?this.removeChildByIndex(h):this.allChildren()[h].setStartPosition(e.endPosition))}}else{e.startPosition>0&&(this.retrievedChildrenRanges.push({from:0,to:0}),s.call(this,0,e.startPosition,h++)),this.retrievedChildrenRanges.push({from:e.startPosition,to:e.endPosition});for(let e=0,t=l.length;e<t;++e)r.call(this,l[e],h++);e.endPosition<e.totalLength&&s.call(this,e.endPosition,e.totalLength,h++)}this.instanceCount+=l.length,n<t?i.call(this,t):(this.expanded&&this.dataGridInternal.updateVisibleNodes(!0),a(),this.dispatchEventToListeners(HeapSnapshotGridNode.Events.PopulateComplete))}i.call(this,t)}))}saveChildren(){this.savedChildren.clear();const e=this.allChildren();for(let t=0,a=e.length;t<a;++t){const a=e[t];a.expanded&&this.savedChildren.set(a.getHash(),a)}}async sort(){this.dataGridInternal.recursiveSortingEnter(),await this.provider().sortAndRewind(this.comparator()),this.saveChildren(),this.dataGridInternal.removeAllChildren(this),this.retrievedChildrenRanges=[];const e=this.instanceCount;this.instanceCount=0,await this.populateChildren(0,e);for(const e of this.allChildren())e.expanded&&e.sort();this.dataGridInternal.recursiveSortingLeave()}}!function(e){let t;!function(e){e.PopulateComplete="PopulateComplete"}(t=e.Events||(e.Events={}))}(HeapSnapshotGridNode||(HeapSnapshotGridNode={}));export class HeapSnapshotGenericObjectNode extends HeapSnapshotGridNode{referenceName;nameInternal;type;distance;shallowSize;retainedSize;snapshotNodeId;snapshotNodeIndex;detachedDOMTreeNode;linkElement;constructor(e,t){if(super(e,!1),!t)return;this.referenceName=null,this.nameInternal=t.name,this.type=t.type,this.distance=t.distance,this.shallowSize=t.selfSize,this.retainedSize=t.retainedSize,this.snapshotNodeId=t.id,this.snapshotNodeIndex=t.nodeIndex,"string"===this.type?this.reachableFromWindow=!0:"object"===this.type&&this.nameInternal.startsWith("Window")?(this.nameInternal=this.shortenWindowURL(this.nameInternal,!1),this.reachableFromWindow=!0):t.canBeQueried&&(this.reachableFromWindow=!0),t.detachedDOMTreeNode&&(this.detachedDOMTreeNode=!0);const a=e.snapshot,n=this.shallowSize/a.totalSize*100,i=this.retainedSize/a.totalSize*100;this.data={distance:this.toUIDistance(this.distance),shallowSize:Platform.NumberUtilities.withThousandsSeparator(this.shallowSize),retainedSize:Platform.NumberUtilities.withThousandsSeparator(this.retainedSize),"shallowSize-percent":this.toPercentString(n),"retainedSize-percent":this.toPercentString(i)}}get name(){return this.nameInternal}retainersDataSource(){return void 0===this.snapshotNodeIndex?null:{snapshot:this.dataGridInternal.snapshot,snapshotNodeIndex:this.snapshotNodeIndex}}createCell(e){return"object"!==e?this.createValueCell(e):this.createObjectCell()}createObjectCell(){let e=this.nameInternal,t="object";switch(this.type){case"concatenated string":case"string":e=`"${e}"`,t="string";break;case"regexp":e=`/${e}/`,t="string";break;case"closure":e=`${e}()`,t="function";break;case"bigint":t="bigint";break;case"number":t="number";break;case"hidden":case"object shape":t="null";break;case"array":e=e?`${e}[]`:i18nString(UIStrings.internalArray)}return this.createObjectCellWithValue(t,e||"")}createObjectCellWithValue(e,t){const a=UI.Fragment.Fragment.build`
<td class="object-column disclosure">
<div class="source-code event-properties" style="overflow: visible;" $="container">
<span class="value object-value-${e}">${t}</span>
<span class="object-value-id">@${this.snapshotNodeId}</span>
</div>
</td>`,n=a.$("container");this.prefixObjectCell(n),this.reachableFromWindow&&n.appendChild(UI.Fragment.html`<span class="heap-object-tag" title="${i18nString(UIStrings.userObjectReachableFromWindow)}">🗖</span>`),this.detachedDOMTreeNode&&n.appendChild(UI.Fragment.html`<span class="heap-object-tag" title="${i18nString(UIStrings.detachedFromDomTree)}">✀</span>`),this.appendSourceLocation(n);const i=a.element();return this.depth&&i.style.setProperty("padding-left",this.depth*this.dataGrid.indentWidth+"px"),i}prefixObjectCell(e){}async appendSourceLocation(e){const t=UI.Fragment.html`<span class="heap-object-source-link" />`;e.appendChild(t);const a=await this.dataGridInternal.dataDisplayDelegate().linkifyObject(this.snapshotNodeIndex);a?(t.appendChild(a),this.linkElement=a):t.remove()}async queryObjectContent(e,t){return await this.tryQueryObjectContent(e,t)||e.runtimeModel().createRemoteObjectFromPrimitiveValue(i18nString(UIStrings.previewIsNotAvailable))}async tryQueryObjectContent(e,t){return"string"===this.type?e.runtimeModel().createRemoteObjectFromPrimitiveValue(this.nameInternal):await e.objectForSnapshotObjectId(String(this.snapshotNodeId),t)}async updateHasChildren(){const e=await this.provider().isEmpty();this.setHasChildren(!e)}shortenWindowURL(e,t){const a=e.indexOf("/"),n=t?e.indexOf("@"):e.length;if(-1===a||-1===n)return e;const i=e.substring(a+1,n).trimLeft();let r=Platform.StringUtilities.trimURL(i);return r.length>40&&(r=Platform.StringUtilities.trimMiddle(r,40)),e.substr(0,a+2)+r+e.substr(n)}populateContextMenu(e,t,a){if(e.revealSection().appendItem(i18nString(UIStrings.revealInSummaryView),(()=>{t.showObject(String(this.snapshotNodeId),i18nString(UIStrings.summary))})),this.referenceName)for(const a of this.referenceName.matchAll(/\((?<objectName>[^@)]*) @(?<snapshotNodeId>\d+)\)/g)){const{objectName:n,snapshotNodeId:i}=a.groups;e.revealSection().appendItem(i18nString(UIStrings.revealObjectSWithIdSInSummary,{PH1:n,PH2:i}),(()=>{t.showObject(i,i18nString(UIStrings.summary))}))}a&&e.revealSection().appendItem(i18nString(UIStrings.storeAsGlobalVariable),(async()=>{const e=await this.tryQueryObjectContent(a,"");if(e){const t=a.target().model(SDK.ConsoleModel.ConsoleModel);await(t?.saveToTempVariable(UI.Context.Context.instance().flavor(SDK.RuntimeModel.ExecutionContext),e))}else Common.Console.Console.instance().error(i18nString(UIStrings.previewIsNotAvailable))}))}}export class HeapSnapshotObjectNode extends HeapSnapshotGenericObjectNode{referenceName;referenceType;edgeIndex;snapshot;parentObjectNode;cycledWithAncestorGridNode;constructor(e,t,a,n){super(e,a.node),this.referenceName=a.name,this.referenceType=a.type,this.edgeIndex=a.edgeIndex,this.snapshot=t,this.parentObjectNode=n,this.cycledWithAncestorGridNode=this.findAncestorWithSameSnapshotNodeId(),this.cycledWithAncestorGridNode||this.updateHasChildren();const i=this.data;i.count="",i.addedCount="",i.removedCount="",i.countDelta="",i.addedSize="",i.removedSize="",i.sizeDelta=""}retainersDataSource(){return void 0===this.snapshotNodeIndex?null:{snapshot:this.snapshot,snapshotNodeIndex:this.snapshotNodeIndex}}createProvider(){if(void 0===this.snapshotNodeIndex)throw new Error("Cannot create a provider on a root node");return this.snapshot.createEdgesProvider(this.snapshotNodeIndex)}findAncestorWithSameSnapshotNodeId(){let e=this.parentObjectNode;for(;e;){if(e.snapshotNodeId===this.snapshotNodeId)return e;e=e.parentObjectNode}return null}createChildNode(e){return new HeapSnapshotObjectNode(this.dataGridInternal,this.snapshot,e,this)}getHash(){return this.edgeIndex}comparator(){const e=this.dataGridInternal.isSortOrderAscending();switch(this.dataGridInternal.sortColumnId()){case"object":return new HeapSnapshotModel.HeapSnapshotModel.ComparatorConfig("!edgeName",e,"retainedSize",!1);case"count":default:return new HeapSnapshotModel.HeapSnapshotModel.ComparatorConfig("!edgeName",!0,"retainedSize",!1);case"shallowSize":return new HeapSnapshotModel.HeapSnapshotModel.ComparatorConfig("selfSize",e,"!edgeName",!0);case"retainedSize":return new HeapSnapshotModel.HeapSnapshotModel.ComparatorConfig("retainedSize",e,"!edgeName",!0);case"distance":return new HeapSnapshotModel.HeapSnapshotModel.ComparatorConfig("distance",e,"name",!0)}}prefixObjectCell(e){let t=this.referenceName||"(empty)",a="name";switch(this.referenceType){case"context":a="object-value-number";break;case"internal":case"hidden":case"weak":a="object-value-null";break;case"element":t=`[${t}]`}this.cycledWithAncestorGridNode&&e.classList.add("cycled-ancessor-node"),e.prepend(UI.Fragment.html`<span class="property-name ${a}">${t}</span>
<span class="grayed">${this.edgeNodeSeparator()}</span>`)}edgeNodeSeparator(){return"::"}}export class HeapSnapshotRetainingObjectNode extends HeapSnapshotObjectNode{constructor(e,t,a,n){super(e,t,a,n)}createProvider(){if(void 0===this.snapshotNodeIndex)throw new Error("Cannot create providers on root nodes");return this.snapshot.createRetainingEdgesProvider(this.snapshotNodeIndex)}createChildNode(e){return new HeapSnapshotRetainingObjectNode(this.dataGridInternal,this.snapshot,e,this)}edgeNodeSeparator(){return i18nString(UIStrings.inElement)}expand(){this.expandRetainersChain(20)}expandRetainersChain(e){if(!this.populated)return this.once(HeapSnapshotGridNode.Events.PopulateComplete).then((()=>this.expandRetainersChain(e))),void this.populate();if(super.expand(),--e>0&&this.children.length>0){const t=this.children[0];if((t.distance||0)>1)return void t.expandRetainersChain(e)}this.dataGridInternal.dispatchEventToListeners(HeapSnapshotSortableDataGridEvents.ExpandRetainersComplete)}}export class HeapSnapshotInstanceNode extends HeapSnapshotGenericObjectNode{baseSnapshotOrSnapshot;isDeletedNode;constructor(e,t,a,n){super(e,a),this.baseSnapshotOrSnapshot=t,this.isDeletedNode=n,this.updateHasChildren();const i=this.data;i.count="",i.countDelta="",i.sizeDelta="",this.isDeletedNode?(i.addedCount="",i.addedSize="",i.removedCount="•",i.removedSize=Platform.NumberUtilities.withThousandsSeparator(this.shallowSize||0)):(i.addedCount="•",i.addedSize=Platform.NumberUtilities.withThousandsSeparator(this.shallowSize||0),i.removedCount="",i.removedSize="")}retainersDataSource(){return void 0===this.snapshotNodeIndex?null:{snapshot:this.baseSnapshotOrSnapshot,snapshotNodeIndex:this.snapshotNodeIndex}}createProvider(){if(void 0===this.snapshotNodeIndex)throw new Error("Cannot create providers on root nodes");return this.baseSnapshotOrSnapshot.createEdgesProvider(this.snapshotNodeIndex)}createChildNode(e){return new HeapSnapshotObjectNode(this.dataGridInternal,this.baseSnapshotOrSnapshot,e,null)}getHash(){if(void 0===this.snapshotNodeId)throw new Error("Cannot hash root nodes");return this.snapshotNodeId}comparator(){const e=this.dataGridInternal.isSortOrderAscending();switch(this.dataGridInternal.sortColumnId()){case"object":return new HeapSnapshotModel.HeapSnapshotModel.ComparatorConfig("!edgeName",e,"retainedSize",!1);case"distance":return new HeapSnapshotModel.HeapSnapshotModel.ComparatorConfig("distance",e,"retainedSize",!1);case"count":default:return new HeapSnapshotModel.HeapSnapshotModel.ComparatorConfig("!edgeName",!0,"retainedSize",!1);case"addedSize":case"removedSize":case"shallowSize":return new HeapSnapshotModel.HeapSnapshotModel.ComparatorConfig("selfSize",e,"!edgeName",!0);case"retainedSize":return new HeapSnapshotModel.HeapSnapshotModel.ComparatorConfig("retainedSize",e,"!edgeName",!0)}}}export class HeapSnapshotConstructorNode extends HeapSnapshotGridNode{nameInternal;nodeFilter;distance;count;shallowSize;retainedSize;constructor(e,t,a,n){super(e,a.count>0),this.nameInternal=t,this.nodeFilter=n,this.distance=a.distance,this.count=a.count,this.shallowSize=a.self,this.retainedSize=a.maxRet;const i=e.snapshot,r=this.retainedSize/i.totalSize*100,s=this.shallowSize/i.totalSize*100;this.data={object:t,count:Platform.NumberUtilities.withThousandsSeparator(this.count),distance:this.toUIDistance(this.distance),shallowSize:Platform.NumberUtilities.withThousandsSeparator(this.shallowSize),retainedSize:Platform.NumberUtilities.withThousandsSeparator(this.retainedSize),"shallowSize-percent":this.toPercentString(s),"retainedSize-percent":this.toPercentString(r)}}get name(){return this.nameInternal}createProvider(){return this.dataGridInternal.snapshot.createNodesProviderForClass(this.nameInternal,this.nodeFilter)}async populateNodeBySnapshotObjectId(e){this.dataGridInternal.resetNameFilter(),await this.expandWithoutPopulate();const t=await this.provider().nodePosition(e);if(-1===t)return this.collapse(),[];await this.populateChildren(t,null);const a=this.childForPosition(t);return a?[this,a]:[]}filteredOut(e){return-1===this.nameInternal.toLowerCase().indexOf(e)}createCell(e){const t="object"===e?super.createCell(e):this.createValueCell(e);return"object"===e&&this.count>1&&t.appendChild(UI.Fragment.html`<span class="objects-count">×${this.count}</span>`),t}createChildNode(e){return new HeapSnapshotInstanceNode(this.dataGridInternal,this.dataGridInternal.snapshot,e,!1)}comparator(){const e=this.dataGridInternal.isSortOrderAscending(),t=this.dataGridInternal.sortColumnId();switch(t){case"object":return new HeapSnapshotModel.HeapSnapshotModel.ComparatorConfig("name",e,"id",!0);case"distance":return new HeapSnapshotModel.HeapSnapshotModel.ComparatorConfig("distance",e,"retainedSize",!1);case"shallowSize":return new HeapSnapshotModel.HeapSnapshotModel.ComparatorConfig("selfSize",e,"id",!0);case"retainedSize":return new HeapSnapshotModel.HeapSnapshotModel.ComparatorConfig("retainedSize",e,"id",!0);default:throw new Error(`Invalid sort column id ${t}`)}}}export class HeapSnapshotDiffNodesProvider{addedNodesProvider;deletedNodesProvider;addedCount;removedCount;constructor(e,t,a,n){this.addedNodesProvider=e,this.deletedNodesProvider=t,this.addedCount=a,this.removedCount=n}dispose(){this.addedNodesProvider.dispose(),this.deletedNodesProvider.dispose()}nodePosition(e){throw new Error("Unreachable")}isEmpty(){return Promise.resolve(!1)}async serializeItemsRange(e,t){let a,n;if(e<this.addedCount){a=await this.addedNodesProvider.serializeItemsRange(e,t);for(const e of a.items)e.isAddedNotRemoved=!0;if(a.endPosition>=t)return a.totalLength=this.addedCount+this.removedCount,a;n=a,a=await this.deletedNodesProvider.serializeItemsRange(0,t-a.endPosition)}else n=new HeapSnapshotModel.HeapSnapshotModel.ItemsRange(0,0,0,[]),a=await this.deletedNodesProvider.serializeItemsRange(e-this.addedCount,t-this.addedCount);n.items.length||(n.startPosition=this.addedCount+a.startPosition);for(const e of a.items)e.isAddedNotRemoved=!1;return n.items.push(...a.items),n.endPosition=this.addedCount+a.endPosition,n.totalLength=this.addedCount+this.removedCount,n}async sortAndRewind(e){await this.addedNodesProvider.sortAndRewind(e),await this.deletedNodesProvider.sortAndRewind(e)}}export class HeapSnapshotDiffNode extends HeapSnapshotGridNode{nameInternal;addedCount;removedCount;countDelta;addedSize;removedSize;sizeDelta;deletedIndexes;constructor(e,t,a){super(e,!0),this.nameInternal=t,this.addedCount=a.addedCount,this.removedCount=a.removedCount,this.countDelta=a.countDelta,this.addedSize=a.addedSize,this.removedSize=a.removedSize,this.sizeDelta=a.sizeDelta,this.deletedIndexes=a.deletedIndexes,this.data={object:t,addedCount:Platform.NumberUtilities.withThousandsSeparator(this.addedCount),removedCount:Platform.NumberUtilities.withThousandsSeparator(this.removedCount),countDelta:this.signForDelta(this.countDelta)+Platform.NumberUtilities.withThousandsSeparator(Math.abs(this.countDelta)),addedSize:Platform.NumberUtilities.withThousandsSeparator(this.addedSize),removedSize:Platform.NumberUtilities.withThousandsSeparator(this.removedSize),sizeDelta:this.signForDelta(this.sizeDelta)+Platform.NumberUtilities.withThousandsSeparator(Math.abs(this.sizeDelta))}}get name(){return this.nameInternal}createProvider(){const e=this.dataGridInternal;if(null===e.snapshot||void 0===e.baseSnapshot||void 0===e.baseSnapshot.uid)throw new Error("Data sources have not been set correctly");const t=e.snapshot.createAddedNodesProvider(e.baseSnapshot.uid,this.nameInternal),a=e.baseSnapshot.createDeletedNodesProvider(this.deletedIndexes);if(!t||!a)throw new Error("Failed to create node providers");return new HeapSnapshotDiffNodesProvider(t,a,this.addedCount,this.removedCount)}createCell(e){const t=super.createCell(e);return"object"!==e&&t.classList.add("numeric-column"),t}createChildNode(e){const t=this.dataGridInternal;if(e.isAddedNotRemoved){if(null===t.snapshot)throw new Error("Data sources have not been set correctly");return new HeapSnapshotInstanceNode(this.dataGridInternal,t.snapshot,e,!1)}if(void 0===t.baseSnapshot)throw new Error("Data sources have not been set correctly");return new HeapSnapshotInstanceNode(this.dataGridInternal,t.baseSnapshot,e,!0)}comparator(){const e=this.dataGridInternal.isSortOrderAscending(),t=this.dataGridInternal.sortColumnId();switch(t){case"object":return new HeapSnapshotModel.HeapSnapshotModel.ComparatorConfig("name",e,"id",!0);case"addedCount":case"removedCount":case"countDelta":return new HeapSnapshotModel.HeapSnapshotModel.ComparatorConfig("name",!0,"id",!0);case"addedSize":case"removedSize":case"sizeDelta":return new HeapSnapshotModel.HeapSnapshotModel.ComparatorConfig("selfSize",e,"id",!0);default:throw new Error(`Invalid sort column ${t}`)}}filteredOut(e){return-1===this.nameInternal.toLowerCase().indexOf(e)}signForDelta(e){return 0===e?"":e>0?"+":"−"}}export class AllocationGridNode extends HeapSnapshotGridNode{populated;allocationNode;constructor(e,t){super(e,t.hasChildren),this.populated=!1,this.allocationNode=t,this.data={liveCount:Platform.NumberUtilities.withThousandsSeparator(t.liveCount),count:Platform.NumberUtilities.withThousandsSeparator(t.count),liveSize:Platform.NumberUtilities.withThousandsSeparator(t.liveSize),size:Platform.NumberUtilities.withThousandsSeparator(t.size),name:t.name}}populate(){this.populated||this.doPopulate()}async doPopulate(){this.populated=!0;const e=await this.dataGridInternal.snapshot.allocationNodeCallers(this.allocationNode.id),t=e.nodesWithSingleCaller;let a=this;const n=this.dataGridInternal;for(const e of t){const t=new AllocationGridNode(n,e);n.appendNode(a,t),a=t,a.populated=!0,this.expanded&&a.expand()}const i=e.branchingCallers;i.sort(this.dataGridInternal.createComparator());for(const e of i)n.appendNode(a,new AllocationGridNode(n,e));n.updateVisibleNodes(!0)}expand(){super.expand(),1===this.children.length&&this.children[0].expand()}createCell(e){if("name"!==e)return this.createValueCell(e);const t=super.createCell(e),a=this.allocationNode,n=this.dataGridInternal.heapProfilerModel();if(a.scriptId){const e=this.dataGridInternal.linkifier.linkifyScriptLocation(n?n.target():null,String(a.scriptId),a.scriptName,a.line-1,{columnNumber:a.column-1,inlineFrameIndex:0,className:"profile-node-file"});e.style.maxWidth="75%",t.insertBefore(e,t.firstChild)}return t}allocationNodeId(){return this.allocationNode.id}}