@yuebai008/cli
Version:
Command line interface for rapid qg-minigame development
1 lines • 2.27 kB
JavaScript
import*as Platform from"../../../../core/platform/platform.js";import*as SDK from"../../../../core/sdk/sdk.js";import*as UI from"../../legacy.js";import*as Components from"../utils/utils.js";import{CustomPreviewComponent}from"./CustomPreviewComponent.js";import objectPopoverStyles from"./objectPopover.css.js";import{ObjectPropertiesSection}from"./ObjectPropertiesSection.js";import objectValueStyles from"./objectValue.css.js";export class ObjectPopoverHelper{linkifier;resultHighlightedAsDOM;constructor(e,t){this.linkifier=e,this.resultHighlightedAsDOM=t}dispose(){this.resultHighlightedAsDOM&&SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight(),this.linkifier&&this.linkifier.dispose()}static async buildObjectPopover(e,t){const o=Platform.StringUtilities.trimEndWithMaxLength(e.description||"",MaxPopoverTextLength);let i=null;if("function"===e.type||"object"===e.type){let s=null,r=!1;if("node"===e.subtype&&(SDK.OverlayModel.OverlayModel.highlightObjectAsDOMNode(e),r=!0),e.customPreview()){const t=new CustomPreviewComponent(e);t.expandIfPossible(),i=t.element}else{i=document.createElement("div"),i.classList.add("object-popover-content"),t.registerCSSFiles([objectValueStyles,objectPopoverStyles]);const r=i.createChild("div","object-popover-title");"function"===e.type?(r.classList.add("source-code"),r.appendChild(ObjectPropertiesSection.valueElementForFunctionDescription(e.description))):(r.classList.add("monospace"),r.createChild("span").textContent=o),s=new Components.Linkifier.Linkifier;const n=new ObjectPropertiesSection(e,"",s,!0);n.element.classList.add("object-popover-tree"),n.titleLessMode(),i.appendChild(n.element)}return i.dataset.stableNameForTest="object-popover-content",t.setMaxContentSize(new UI.Geometry.Size(300,250)),t.setSizeBehavior("SetExactSize"),t.contentElement.appendChild(i),new ObjectPopoverHelper(s,r)}i=document.createElement("span"),i.dataset.stableNameForTest="object-popover-content",t.registerCSSFiles([objectValueStyles,objectPopoverStyles]);const s=i.createChild("span","monospace object-value-"+e.type);return s.style.whiteSpace="pre","string"===e.type?UI.UIUtils.createTextChildren(s,`"${o}"`):s.textContent=o,t.contentElement.appendChild(i),new ObjectPopoverHelper(null,!1)}}const MaxPopoverTextLength=1e4;