PageSourceSearch

https://devdocs.io/assets/app/settings-1d96bbb208ac85f44b0c9bf19e00ccd344a67117ea5bc5194e53cd61de668aee.js

js devdocs.io collected 2026-09-24 08:29:55 UTC 3,152 bytes, 1 lines download raw bytes

1import{app}from"./app.js";import{config}from"./config.js";import{settingsStore}from"../lib/settings_store.js";import{$}from"../lib/util.js";export class Settings{static PREFERENCE_KEYS=["hideDisabled","hideIntro","manualUpdate","fastScroll","arrowScroll","analyticsConsent","docs","dark","theme","layout","size","tips","noAutofocus","autoInstall","autoLatestVersion","spaceScroll","spaceTimeout","noDocSpecificIcon"];static INTERNAL_KEYS=["count","schema","version","news"];static LAYOUTS=["_max-width","_sidebar-hidden","_native-scrollbars","_text-justify-hyphenate"];static defaults={count:0,hideDisabled:!1,hideIntro:!1,news:0,manualUpdate:!1,schema:1,analyticsConsent:!1,theme:"auto",spaceScroll:1,spaceTimeout:.5,noDocSpecificIcon:!1,autoLatestVersion:!1};constructor(){this.store=settingsStore,this.cache={},this.autoSupported="not all"!==window.matchMedia("(prefers-color-scheme)").media,this.autoSupported&&(this.darkModeQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.darkModeQuery.addListener(()=>this.setTheme(this.get("theme"))))}get(t){const e=this.cache,s=t=>t;let o;return e.hasOwnProperty(t)?s(e[t]):(e[t]=null!=(o=this.store.get(t))?o:Settings.defaults[t],"theme"!==t||"auto"!==e[t]||this.darkModeQuery?s(e[t]):s(e[t]="default"))}set(t,e){this.store.set(t,e),delete this.cache[t],"theme"===t&&this.setTheme(e)}del(t){this.store.del(t),delete this.cache[t]}hasDocs(){try{return!!this.store.get("docs")}catch(t){}}getDocs(){return this.store.get("docs")?.split("/")||config.default_docs}setDocs(t){this.set("docs",t.join("/"))}getTips(){return this.store.get("tips")?.split("/")||[]}setTips(t){this.set("tips",t.join("/"))}setLayout(t,e){this.toggleLayout(t,e);const s=(this.store.get("layout")||"").split(" ");$.arrayDelete(s,""),e?s.includes(t)||s.push(t):$.arrayDelete(s,t),s.length>0?this.set("layout",s.join(" ")):this.del("layout")}hasLayout(t){return(this.store.get("layout")||"").split(" ").includes(t)}setSize(t){this.set("size",t)}dump(){return this.store.dump()}export(){const t=this.dump();for(var e of Settings.INTERNAL_KEYS)delete t[e];return t}import(t){let e,s;const o=this.export();for(e in o)s=o[e],t.hasOwnProperty(e)||this.del(e);for(e in t)s=t[e],Settings.PREFERENCE_KEYS.includes(e)&&this.set(e,s)}reset(){this.store.reset(),this.cache={}}initLayout(){for(var t of(1===this.get("dark")&&(this.set("theme","dark"),this.del("dark")),this.setTheme(this.get("theme")),Settings.LAYOUTS))this.toggleLayout(t,this.hasLayout(t));this.initSidebarWidth()}setTheme(t){"auto"===t&&(t=this.darkModeQuery.matches?"dark":"default");const{classList:e}=document.documentElement;e.remove("_theme-default","_theme-dark"),e.add("_theme-"+t),this.updateColorMeta()}updateColorMeta(){const t=getComputedStyle(document.documentElement).getPropertyValue("--headerBackground").trim();$("meta[name=theme-color]").setAttribute("content",t)}toggleLayout(t,e){const{classList:s}=document.body;"_sidebar-hidden"===t&&app.router?.isSettings||s.toggle(t,e),s.toggle("_overlay-scrollbars",$.overlayScrollbarsEnabled())}initSidebarWidth(){const t=this.get("size");t&&document.documentElement.style.setProperty("--sidebarWidth",t+"px")}}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.