UNPKG

@yuebai008/cli

Version:

Command line interface for rapid qg-minigame development

42 lines (38 loc) 6.57 kB
import*as i18n from"../../../../core/i18n/i18n.js";import*as ChromeLink from"../../../../ui/components/chrome_link/chrome_link.js";import*as Dialogs from"../../../../ui/components/dialogs/dialogs.js";import*as ComponentHelpers from"../../../../ui/components/helpers/helpers.js";import*as IconButton from"../../../../ui/components/icon_button/icon_button.js";import*as LegacyWrapper from"../../../../ui/components/legacy_wrapper/legacy_wrapper.js";import*as Coordinator from"../../../../ui/components/render_coordinator/render_coordinator.js";import*as ReportView from"../../../../ui/components/report_view/report_view.js";import*as UI from"../../../../ui/legacy/legacy.js";import*as LitHtml from"../../../../ui/lit-html/lit-html.js";import preloadingDisabledInfobarStyles from"./preloadingDisabledInfobar.css.js";const UIStrings={infobarPreloadingIsDisabled:"Preloading is disabled",infobarPreloadingIsForceEnabled:"Preloading is force-enabled",titleReasonsPreventingPreloading:"Reasons preventing preloading",headerDisabledByPreference:"User settings or extension",descriptionDisabledByPreference:"Preloading is disabled because of user settings or an extension. Go to {PH1} to update your preference. Go to {PH2} to disable any extension that blocks preloading.",preloadingPagesSettings:"Preload pages settings",extensionsSettings:"Extensions settings",headerDisabledByDataSaver:"Data Saver",descriptionDisabledByDataSaver:"Preloading is disabled because of the operating system's Data Saver mode.",headerDisabledByBatterySaver:"Battery Saver",descriptionDisabledByBatterySaver:"Preloading is disabled because of the operating system's Battery Saver mode.",headerDisabledByHoldbackPrefetchSpeculationRules:"Prefetch was disabled, but is force-enabled now",descriptionDisabledByHoldbackPrefetchSpeculationRules:"Prefetch is forced-enabled because DevTools is open. When DevTools is closed, prefetch will be disabled because this browser session is part of a holdback group used for performance comparisons.",headerDisabledByHoldbackPrerenderSpeculationRules:"Prerendering was disabled, but is force-enabled now",descriptionDisabledByHoldbackPrerenderSpeculationRules:"Prerendering is forced-enabled because DevTools is open. When DevTools is closed, prerendering will be disabled because this browser session is part of a holdback group used for performance comparisons.",footerLearnMore:"Learn more"},str_=i18n.i18n.registerUIStrings("panels/application/preloading/components/PreloadingDisabledInfobar.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_),coordinator=Coordinator.RenderCoordinator.RenderCoordinator.instance();export class PreloadingDisabledInfobar extends LegacyWrapper.LegacyWrapper.WrappableComponent{static litTagName=LitHtml.literal`devtools-resources-preloading-disabled-infobar`;#e=this.attachShadow({mode:"open"});#i={disabledByPreference:!1,disabledByDataSaver:!1,disabledByBatterySaver:!1,disabledByHoldbackPrefetchSpeculationRules:!1,disabledByHoldbackPrerenderSpeculationRules:!1};connectedCallback(){this.#e.adoptedStyleSheets=[preloadingDisabledInfobarStyles],this.#a()}set data(e){this.#i=e,this.#a()}async#a(){await coordinator.write("PreloadingDisabledInfobar render",(()=>{LitHtml.render(this.#r(),this.#e,{host:this})}))}#r(){const e=this.#i.disabledByHoldbackPrefetchSpeculationRules||this.#i.disabledByHoldbackPrerenderSpeculationRules;let i;if(this.#i.disabledByPreference||this.#i.disabledByDataSaver||this.#i.disabledByBatterySaver)i=i18nString(UIStrings.infobarPreloadingIsDisabled);else{if(!e)return LitHtml.nothing;i=i18nString(UIStrings.infobarPreloadingIsForceEnabled)}return LitHtml.html` <div id='container'> <span id='header'> ${i} </span> <${Dialogs.IconDialog.IconDialog.litTagName} .data=${{iconData:{iconName:"info",color:"var(--icon-default-hover)",width:"16px",height:"16px"},closeButton:!0,position:"auto",horizontalAlignment:"auto",closeOnESC:!0,closeOnScroll:!1}} > ${this.#t()} </${Dialogs.IconDialog.IconDialog.litTagName}> </div> `}#t(){const e="https://developer.chrome.com/blog/prerender-pages/",i=UI.XLink.XLink.create(e,i18nString(UIStrings.footerLearnMore)),a=UI.Fragment.html` <x-link class="icon-link devtools-link" tabindex="0" href="${e}"></x-link> `,r=new IconButton.Icon.Icon;return r.data={iconName:"open-externally",color:"var(--icon-default-hover)",width:"16px",height:"16px"},a.append(r),LitHtml.html` <div id='contents'> <div id='title'>${i18nString(UIStrings.titleReasonsPreventingPreloading)}</div> <${ReportView.ReportView.Report.litTagName}> ${this.#n()} ${this.#o()} ${this.#s()} ${this.#l()} ${this.#d()} <${ReportView.ReportView.ReportSectionDivider.litTagName}> </${ReportView.ReportView.ReportSectionDivider.litTagName}> </${ReportView.ReportView.Report.litTagName}> <div id='footer'> ${i} ${a} </div> </div> `}#c(e,i,a){return e?LitHtml.html` <div class='key'> ${i} </div> <div class='value'> ${a} </div> `:LitHtml.nothing}#n(){const e=new ChromeLink.ChromeLink.ChromeLink;e.href="chrome://settings/cookies",e.textContent=i18nString(UIStrings.preloadingPagesSettings);const i=new ChromeLink.ChromeLink.ChromeLink;i.href="chrome://extensions",i.textContent=i18nString(UIStrings.extensionsSettings);const a=i18n.i18n.getFormatLocalizedString(str_,UIStrings.descriptionDisabledByPreference,{PH1:e,PH2:i});return this.#c(this.#i.disabledByPreference,i18nString(UIStrings.headerDisabledByPreference),a)}#o(){return this.#c(this.#i.disabledByDataSaver,i18nString(UIStrings.headerDisabledByDataSaver),i18nString(UIStrings.descriptionDisabledByDataSaver))}#s(){return this.#c(this.#i.disabledByBatterySaver,i18nString(UIStrings.headerDisabledByBatterySaver),i18nString(UIStrings.descriptionDisabledByBatterySaver))}#l(){return this.#c(this.#i.disabledByHoldbackPrefetchSpeculationRules,i18nString(UIStrings.headerDisabledByHoldbackPrefetchSpeculationRules),i18nString(UIStrings.descriptionDisabledByHoldbackPrefetchSpeculationRules))}#d(){return this.#c(this.#i.disabledByHoldbackPrerenderSpeculationRules,i18nString(UIStrings.headerDisabledByHoldbackPrerenderSpeculationRules),i18nString(UIStrings.descriptionDisabledByHoldbackPrerenderSpeculationRules))}}ComponentHelpers.CustomElements.defineComponent("devtools-resources-preloading-disabled-infobar",PreloadingDisabledInfobar);