@yuebai008/cli
Version:
Command line interface for rapid qg-minigame development
16 lines • 2.97 kB
JavaScript
import*as ComponentHelpers from"../../../ui/components/helpers/helpers.js";import*as LitHtml from"../../../ui/lit-html/lit-html.js";import*as i18n from"../../../core/i18n/i18n.js";import*as NetworkForward from"../forward/forward.js";import*as IconButton from"../../../ui/components/icon_button/icon_button.js";import*as Platform from"../../../core/platform/platform.js";import{HeaderSectionRow}from"./HeaderSectionRow.js";import requestHeaderSectionStyles from"./RequestHeaderSection.css.js";const{render:render,html:html}=LitHtml,UIStrings={learnMore:"Learn more",provisionalHeadersAreShownDisableCache:"Provisional headers are shown. Disable cache to see full headers.",onlyProvisionalHeadersAre:"Only provisional headers are available because this request was not sent over the network and instead was served from a local cache, which doesn’t store the original request headers. Disable cache to see full request headers.",provisionalHeadersAreShown:"Provisional headers are shown."},str_=i18n.i18n.registerUIStrings("panels/network/components/RequestHeaderSection.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);export class RequestHeaderSection extends HTMLElement{static litTagName=LitHtml.literal`devtools-request-header-section`;#e=this.attachShadow({mode:"open"});#t;#r=[];connectedCallback(){this.#e.adoptedStyleSheets=[requestHeaderSectionStyles]}set data(e){this.#t=e.request,this.#r=this.#t.requestHeaders().map((e=>({name:Platform.StringUtilities.toLowerCaseString(e.name),value:e.value}))),this.#r.sort(((e,t)=>Platform.StringUtilities.compare(e.name,t.name))),e.toReveal?.section===NetworkForward.UIRequestLocation.UIHeaderSection.Request&&this.#r.filter((t=>t.name===e.toReveal?.header?.toLowerCase())).forEach((e=>{e.highlight=!0})),this.#o()}#o(){this.#t&&render(html`
${this.#s()}
${this.#r.map((e=>html`
<${HeaderSectionRow.litTagName} .data=${{header:e}}></${HeaderSectionRow.litTagName}>
`))}
`,this.#e,{host:this})}#s(){if(!this.#t||void 0!==this.#t.requestHeadersText())return LitHtml.nothing;let e,t="";return this.#t.cachedInMemory()||this.#t.cached()?(e=i18nString(UIStrings.provisionalHeadersAreShownDisableCache),t=i18nString(UIStrings.onlyProvisionalHeadersAre)):e=i18nString(UIStrings.provisionalHeadersAreShown),html`
<div class="call-to-action">
<div class="call-to-action-body">
<div class="explanation" title=${t}>
<${IconButton.Icon.Icon.litTagName} class="inline-icon" .data=${{iconName:"warning-filled",color:"var(--icon-warning)",width:"16px",height:"16px"}}>
</${IconButton.Icon.Icon.litTagName}>
${e} <x-link href="https://developer.chrome.com/docs/devtools/network/reference/#provisional-headers" class="link">${i18nString(UIStrings.learnMore)}</x-link>
</div>
</div>
</div>
`}}ComponentHelpers.CustomElements.defineComponent("devtools-request-header-section",RequestHeaderSection);