Loading files
cb96349f4This file is pinned to the selected release. Download the original to open it in your design tool.
import { type DOMAIN, PREF_KEYS } from 'consts'
import Preference from 'preference'
import structuredClone from 'structuredClone'
import config from 'mc/config'
import Modules from 'modules'
// biome-ignore lint/suspicious/noExplicitAny: Match the type definition of mc/config
const modConfig: Record<string, any> = Modules.has('mod/config') ? Modules.importNow('mod/config') : {}
export default function loadPreferences(category: keyof typeof DOMAIN) {
const mcPreference = structuredClone(config[category.toLowerCase()] ?? {})
const modPreference = structuredClone(modConfig[category.toLowerCase()] ?? {})
const preference = { ...mcPreference, ...modPreference }
const keys = PREF_KEYS.filter((s) => s[0] === category)
for (const [domain, key, ctor] of keys) {
const value = Preference.get(domain, key)
if (value != null) {
preference[key] = ctor(value)
}
}
return preference
}
cb96349f4This file is pinned to the selected release. Download the original to open it in your design tool.
Files from this revision, including CAD and LFS contents. Git history is not included.
Or in GitHub Desktop, choose File → Clone repository → URL and paste this address.
Public repositories can be cloned without signing in. For pushing, use your ThingAtlas username and a Git access token as the password.
git lfs install git clone https://thingatlas.com/git/-unclaimed/stack-chan-374381865.git
Includes Git history, branches, and Git LFS files. Clones the repository’s default branch, regardless of the version shown here.