ConfigFile
42/api/os/ConfigFile.js
ConfigFile is the base class for system config files. Each manager extends it to own one persistent settings file.
It provides a standard lifecycle: load or reset the file, run setup hooks, and expose a ready promise.
Backing files
A ConfigFile reads and writes a single data file through persist. Files must end in .json, .json5 or .cbor.
Paths are normalized. Relative filenames belong to the current user and are stored under $HOME. Absolute paths are global. For example, "config/apps.json5" maps to the user's config/apps.json5, while "/users.json5" is shared by everyone.
Instance state
path- the resolved file path.isUserConfig- true when the filename is relative (belongs to the current user).defaults- fallback value merged in when the file is reset.value- the loaded config data.version- the file's last-modified timestamp, or-1when missing. Managers use it to detect remote updates.ready- a promise that resolves once init completes. Await it before using a manager.
Lifecycle
Managers override the hooks, then call init():
load()orreset()- in the desktop realm,reset()runs when the file does not exist yet,load()otherwise. Other realms always load.setup(...)- post-load setup, used to register event listeners and kick off async work.ready.resolve()- signals that the manager is usable.
Overridable hooks:
setup(...)- runs after the value is loaded.postload()- runs aftervalueis set (from both load and reset).populate()- returns the initial value used byreset().
Methods
init(...args)- runs the lifecycle. Resolvesreadyon success.load()- reads the file intovalue, then runspostload(). Corrupt files are reported and reset instead.reset()- rebuildsvaluefromconfigure(defaults, populate()), runspostload(), saves.save()- writesvalueto disk. Skips user configs when no user is logged in.update(value)- merges an object intovalue, or runs a function over it, then saves.