UNPKG

@yuebai008/cli

Version:

Command line interface for rapid qg-minigame development

1 lines 8.37 kB
import*as Common from"../../core/common/common.js";import*as i18n from"../../core/i18n/i18n.js";import*as UI from"../../ui/legacy/legacy.js";import renderingOptionsStyles from"./renderingOptions.css.js";const UIStrings={paintFlashing:"Paint flashing",highlightsAreasOfThePageGreen:"Highlights areas of the page (green) that need to be repainted. May not be suitable for people prone to photosensitive epilepsy.",layoutShiftRegions:"Layout Shift Regions",highlightsAreasOfThePageBlueThat:"Highlights areas of the page (blue) that were shifted. May not be suitable for people prone to photosensitive epilepsy.",layerBorders:"Layer borders",showsLayerBordersOrangeoliveAnd:"Shows layer borders (orange/olive) and tiles (cyan).",frameRenderingStats:"Frame Rendering Stats",plotsFrameThroughputDropped:"Plots frame throughput, dropped frames distribution, and GPU memory.",scrollingPerformanceIssues:"Scrolling performance issues",highlightsElementsTealThatCan:"Highlights elements (teal) that can slow down scrolling, including touch & wheel event handlers and other main-thread scrolling situations.",highlightAdFrames:"Highlight ad frames",highlightsFramesRedDetectedToBe:"Highlights frames (red) detected to be ads.",coreWebVitals:"Core Web Vitals",showsAnOverlayWithCoreWebVitals:"Shows an overlay with Core Web Vitals.",disableLocalFonts:"Disable local fonts",disablesLocalSourcesInFontface:"Disables `local()` sources in `@font-face` rules. Requires a page reload to apply.",emulateAFocusedPage:"Emulate a focused page",emulatesAFocusedPage:"Emulates a focused page.",emulateAutoDarkMode:"Enable automatic dark mode",emulatesAutoDarkMode:"Enables automatic dark mode and sets `prefers-color-scheme` to `dark`.",forcesMediaTypeForTestingPrint:"Forces media type for testing print and screen styles",forcesCssPreferscolorschemeMedia:"Forces CSS `prefers-color-scheme` media feature",forcesCssPrefersreducedmotion:"Forces CSS `prefers-reduced-motion` media feature",forcesCssPreferscontrastMedia:"Forces CSS `prefers-contrast` media feature",forcesCssPrefersreduceddataMedia:"Forces CSS `prefers-reduced-data` media feature",forcesCssPrefersreducedtransparencyMedia:"Forces CSS `prefers-reduced-transparency` media feature",forcesCssColorgamutMediaFeature:"Forces CSS `color-gamut` media feature",forcesVisionDeficiencyEmulation:"Forces vision deficiency emulation",disableAvifImageFormat:"Disable `AVIF` image format",requiresAPageReloadToApplyAnd:"Requires a page reload to apply and disables caching for image requests.",disableWebpImageFormat:"Disable `WebP` image format",forcesCssForcedColors:"Forces CSS forced-colors media feature"},str_=i18n.i18n.registerUIStrings("entrypoints/inspector_main/RenderingOptions.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_),supportsPrefersReducedData=()=>window.matchMedia("not all and (prefers-reduced-data), (prefers-reduced-data)").matches,supportsPrefersReducedTransparency=()=>window.matchMedia("not all and (prefers-reduced-transparency), (prefers-reduced-transparency)").matches,supportsPrefersContrast=()=>window.matchMedia("not all and (prefers-contrast), (prefers-contrast)").matches;let renderingOptionsViewInstance,reloadActionDelegateInstance;export class RenderingOptionsView extends UI.Widget.VBox{constructor(){super(!0),this.#e(i18nString(UIStrings.paintFlashing),i18nString(UIStrings.highlightsAreasOfThePageGreen),Common.Settings.Settings.instance().moduleSetting("showPaintRects")),this.#e(i18nString(UIStrings.layoutShiftRegions),i18nString(UIStrings.highlightsAreasOfThePageBlueThat),Common.Settings.Settings.instance().moduleSetting("showLayoutShiftRegions")),this.#e(i18nString(UIStrings.layerBorders),i18nString(UIStrings.showsLayerBordersOrangeoliveAnd),Common.Settings.Settings.instance().moduleSetting("showDebugBorders")),this.#e(i18nString(UIStrings.frameRenderingStats),i18nString(UIStrings.plotsFrameThroughputDropped),Common.Settings.Settings.instance().moduleSetting("showFPSCounter")),this.#e(i18nString(UIStrings.scrollingPerformanceIssues),i18nString(UIStrings.highlightsElementsTealThatCan),Common.Settings.Settings.instance().moduleSetting("showScrollBottleneckRects")),this.#e(i18nString(UIStrings.highlightAdFrames),i18nString(UIStrings.highlightsFramesRedDetectedToBe),Common.Settings.Settings.instance().moduleSetting("showAdHighlights")),this.#e(i18nString(UIStrings.coreWebVitals),i18nString(UIStrings.showsAnOverlayWithCoreWebVitals),Common.Settings.Settings.instance().moduleSetting("showWebVitals")),this.#e(i18nString(UIStrings.disableLocalFonts),i18nString(UIStrings.disablesLocalSourcesInFontface),Common.Settings.Settings.instance().moduleSetting("localFontsDisabled")),this.#e(i18nString(UIStrings.emulateAFocusedPage),i18nString(UIStrings.emulatesAFocusedPage),Common.Settings.Settings.instance().moduleSetting("emulatePageFocus")),this.#e(i18nString(UIStrings.emulateAutoDarkMode),i18nString(UIStrings.emulatesAutoDarkMode),Common.Settings.Settings.instance().moduleSetting("emulateAutoDarkMode")),this.contentElement.createChild("div").classList.add("panel-section-separator"),this.#t(i18nString(UIStrings.forcesCssPreferscolorschemeMedia),Common.Settings.Settings.instance().moduleSetting("emulatedCSSMediaFeaturePrefersColorScheme")),this.#t(i18nString(UIStrings.forcesMediaTypeForTestingPrint),Common.Settings.Settings.instance().moduleSetting("emulatedCSSMedia")),this.#t(i18nString(UIStrings.forcesCssForcedColors),Common.Settings.Settings.instance().moduleSetting("emulatedCSSMediaFeatureForcedColors")),window.matchMedia("not all and (prefers-contrast), (prefers-contrast)").matches&&this.#t(i18nString(UIStrings.forcesCssPreferscontrastMedia),Common.Settings.Settings.instance().moduleSetting("emulatedCSSMediaFeaturePrefersContrast")),this.#t(i18nString(UIStrings.forcesCssPrefersreducedmotion),Common.Settings.Settings.instance().moduleSetting("emulatedCSSMediaFeaturePrefersReducedMotion")),window.matchMedia("not all and (prefers-reduced-data), (prefers-reduced-data)").matches&&this.#t(i18nString(UIStrings.forcesCssPrefersreduceddataMedia),Common.Settings.Settings.instance().moduleSetting("emulatedCSSMediaFeaturePrefersReducedData")),window.matchMedia("not all and (prefers-reduced-transparency), (prefers-reduced-transparency)").matches&&this.#t(i18nString(UIStrings.forcesCssPrefersreducedtransparencyMedia),Common.Settings.Settings.instance().moduleSetting("emulatedCSSMediaFeaturePrefersReducedTransparency")),this.#t(i18nString(UIStrings.forcesCssColorgamutMediaFeature),Common.Settings.Settings.instance().moduleSetting("emulatedCSSMediaFeatureColorGamut")),this.contentElement.createChild("div").classList.add("panel-section-separator"),this.#t(i18nString(UIStrings.forcesVisionDeficiencyEmulation),Common.Settings.Settings.instance().moduleSetting("emulatedVisionDeficiency")),this.contentElement.createChild("div").classList.add("panel-section-separator"),this.#e(i18nString(UIStrings.disableAvifImageFormat),i18nString(UIStrings.requiresAPageReloadToApplyAnd),Common.Settings.Settings.instance().moduleSetting("avifFormatDisabled")),this.#e(i18nString(UIStrings.disableWebpImageFormat),i18nString(UIStrings.requiresAPageReloadToApplyAnd),Common.Settings.Settings.instance().moduleSetting("webpFormatDisabled")),this.contentElement.createChild("div").classList.add("panel-section-separator")}static instance(e={forceNew:null}){const{forceNew:t}=e;return renderingOptionsViewInstance&&!t||(renderingOptionsViewInstance=new RenderingOptionsView),renderingOptionsViewInstance}#n(e,t,n){const s=UI.UIUtils.CheckboxLabel.create(e,!1,t);return UI.SettingsUI.bindCheckbox(s.checkboxElement,n),s}#e(e,t,n){const s=this.#n(e,t,n);return this.contentElement.appendChild(s),s}#t(e,t){const n=UI.SettingsUI.createControlForSetting(t,e);n&&this.contentElement.appendChild(n)}wasShown(){super.wasShown(),this.registerCSSFiles([renderingOptionsStyles])}}export class ReloadActionDelegate{static instance(e={forceNew:null}){const{forceNew:t}=e;return reloadActionDelegateInstance&&!t||(reloadActionDelegateInstance=new ReloadActionDelegate),reloadActionDelegateInstance}handleAction(e,t){const n=Common.Settings.Settings.instance().moduleSetting("emulatedCSSMediaFeaturePrefersColorScheme");if("rendering.toggle-prefers-color-scheme"===t){const e=["","light","dark"],t=e.findIndex((e=>e===n.get()||""));return n.set(e[(t+1)%3]),!0}return!1}}