UNPKG

@yuebai008/cli

Version:

Command line interface for rapid qg-minigame development

1 lines 3.15 kB
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 UI from"../../ui/legacy/legacy.js";import{DeveloperResourcesListView}from"./DeveloperResourcesListView.js";import developerResourcesViewStyles from"./developerResourcesView.css.js";const UIStrings={enterTextToSearchTheUrlAndError:"Enter text to search the URL and Error columns",loadHttpsDeveloperResources:"Load `HTTP(S)` developer resources through the website you inspect, not through DevTools",enableLoadingThroughTarget:"Load through website",resourcesCurrentlyLoading:"{PH1} resources, {PH2} currently loading",resources:"{n, plural, =1 {# resource} other {# resources}}"},str_=i18n.i18n.registerUIStrings("panels/developer_resources/DeveloperResourcesView.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);export class DeveloperResourcesView extends UI.ThrottledWidget.ThrottledWidget{textFilterRegExp;filterInput;coverageResultsElement;listView;statusToolbarElement;statusMessageElement;loader;constructor(){super(!0);const e=this.contentElement.createChild("div","developer-resource-view-toolbar-container"),t=new UI.Toolbar.Toolbar("developer-resource-view-toolbar",e);this.textFilterRegExp=null;this.filterInput=new UI.Toolbar.ToolbarInput(i18nString(UIStrings.enterTextToSearchTheUrlAndError),"",1),this.filterInput.addEventListener(UI.Toolbar.ToolbarInput.Event.TextChanged,this.onFilterChanged,this),t.appendToolbarItem(this.filterInput);const r=SDK.PageResourceLoader.getLoadThroughTargetSetting(),s=new UI.Toolbar.ToolbarSettingCheckbox(r,i18nString(UIStrings.loadHttpsDeveloperResources),i18nString(UIStrings.enableLoadingThroughTarget));t.appendToolbarItem(s),this.coverageResultsElement=this.contentElement.createChild("div","developer-resource-view-results"),this.listView=new DeveloperResourcesListView(this.isVisible.bind(this)),this.listView.show(this.coverageResultsElement),this.statusToolbarElement=this.contentElement.createChild("div","developer-resource-view-toolbar-summary"),this.statusMessageElement=this.statusToolbarElement.createChild("div","developer-resource-view-message"),this.loader=SDK.PageResourceLoader.PageResourceLoader.instance(),this.loader.addEventListener(SDK.PageResourceLoader.Events.Update,this.update,this),this.update()}async doUpdate(){this.listView.reset(),this.listView.update(this.loader.getResourcesLoaded().values()),this.updateStats()}updateStats(){const{loading:e,resources:t}=this.loader.getNumberOfResources();this.statusMessageElement.textContent=e>0?i18nString(UIStrings.resourcesCurrentlyLoading,{PH1:t,PH2:e}):i18nString(UIStrings.resources,{n:t})}isVisible(e){return!this.textFilterRegExp||this.textFilterRegExp.test(e.url)||this.textFilterRegExp.test(e.errorMessage||"")}onFilterChanged(){if(!this.listView)return;const e=this.filterInput.value();this.textFilterRegExp=e?Platform.StringUtilities.createPlainTextSearchRegex(e,"i"):null,this.listView.updateFilterAndHighlight(this.textFilterRegExp),this.updateStats()}wasShown(){super.wasShown(),this.registerCSSFiles([developerResourcesViewStyles])}}