@yuebai008/cli
Version:
Command line interface for rapid qg-minigame development
4 lines • 3.61 kB
JavaScript
import*as i18n from"../../../../core/i18n/i18n.js";import*as DataGrid from"../../../../ui/components/data_grid/data_grid.js";import*as SDK from"../../../../core/sdk/sdk.js";import{assertNotNullOrUndefined}from"../../../../core/platform/platform.js";import*as ComponentHelpers from"../../../../ui/components/helpers/helpers.js";import*as LegacyWrapper from"../../../../ui/components/legacy_wrapper/legacy_wrapper.js";import*as LitHtml from"../../../../ui/lit-html/lit-html.js";import*as Diff from"../../../../third_party/diff/diff.js";const UIStrings={url:"URL",action:"Action",status:"Status",statusNotTriggered:"Not triggered",statusPending:"Pending",statusRunning:"Running",statusReady:"Ready",statusSuccess:"Success",statusFailure:"Failure"},str_=i18n.i18n.registerUIStrings("panels/application/preloading/components/MismatchedPreloadingGrid.ts",UIStrings);export const i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);class PreloadingUIUtils{static action(t){switch(t){case"Prefetch":return i18n.i18n.lockedString("prefetch");case"Prerender":return i18n.i18n.lockedString("prerender")}}static status(t){switch(t){case"NotTriggered":return i18nString(UIStrings.statusNotTriggered);case"Pending":return i18nString(UIStrings.statusPending);case"Running":return i18nString(UIStrings.statusRunning);case"Ready":return i18nString(UIStrings.statusReady);case"Success":return i18nString(UIStrings.statusSuccess);case"Failure":return i18nString(UIStrings.statusFailure);case"NotSupported":return i18n.i18n.lockedString("Internal error")}}}const{render:render,html:html}=LitHtml;export class MismatchedPreloadingGrid extends LegacyWrapper.LegacyWrapper.WrappableComponent{static litTagName=LitHtml.literal`devtools-resources-mismatched-preloading-grid`;#t=this.attachShadow({mode:"open"});#r=null;connectedCallback(){this.#t.adoptedStyleSheets=[],this.#e()}set data(t){this.#r=t,this.#e()}#e(){if(null===this.#r)return;const t={columns:[{id:"url",title:i18nString(UIStrings.url),widthWeighting:40,hideable:!1,visible:!0,sortable:!0},{id:"action",title:i18nString(UIStrings.action),widthWeighting:15,hideable:!1,visible:!0,sortable:!0},{id:"status",title:i18nString(UIStrings.status),widthWeighting:15,hideable:!1,visible:!0,sortable:!0}],rows:this.#i(),striped:!0};render(html`
<${DataGrid.DataGridController.DataGridController.litTagName} .data=${t}>
</${DataGrid.DataGridController.DataGridController.litTagName}>
`,this.#t,{host:this})}#i(){assertNotNullOrUndefined(this.#r);const t=this.#r.pageURL;return this.#r.rows.map((r=>({row:r,diffScore:Diff.Diff.DiffWrapper.characterScore(r.url,t)}))).sort(((t,r)=>r.diffScore-t.diffScore)).map((({row:r})=>({cells:[{columnId:"url",value:r.url,renderer:()=>function(t,r){function e(t,r){return LitHtml.html`<span style=${LitHtml.Directives.styleMap(t)}>${r}</span>`}const i=Diff.Diff.DiffWrapper.charDiff(t,r).map((t=>{const r=t[1];switch(t[0]){case Diff.Diff.Operation.Equal:return e({},r);case Diff.Diff.Operation.Insert:return e({color:"var(--sys-color-green)","text-decoration":"line-through"},r);case Diff.Diff.Operation.Delete:return e({color:"var(--sys-color-error)"},r);case Diff.Diff.Operation.Edit:return e({color:"var(--sys-color-green)","text-decoration":"line-through"},r);default:throw new Error("unreachable")}}),LitHtml.nothing);return LitHtml.html`<div>${i}</div>`}(r.url,t)},{columnId:"action",value:PreloadingUIUtils.action(r.action)},{columnId:"status",value:PreloadingUIUtils.status(r.status)}]})))}}ComponentHelpers.CustomElements.defineComponent("devtools-resources-mismatched-preloading-grid",MismatchedPreloadingGrid);