PURPOSE
Holds accessibility flags shared across the engine and metagame UI. Owns the SKIP_REWARD_ANIMATIONS flag along with its persistence to localStorage, plus stub flags for TEXT_SCALE, HIGH_CONTRAST, and COLOR_MODE.
OWNS
ACCESSIBILITYobject — single in-memory record of accessibility flags.TEXT_SCALE— numeric scale multiplier for text (default1.0).HIGH_CONTRAST— boolean high-contrast toggle (defaultfalse).COLOR_MODE— color mode string (default'normal').SKIP_REWARD_ANIMATIONS— boolean to bypass reward animations.loadSkipRewardAnimations()— reads the persisted skip flag, syncs into memory, returns the parsed value.setSkipRewardAnimations(value)— writes the skip flag tolocalStorageand updates the in-memory copy.isSkipRewardAnimations()— reads the current in-memory value.- Module-load side effect calls
loadSkipRewardAnimations()so the flag is hydrated as soon as the module is imported.
READS FROM
localStoragevia thess_skip_reward_animkey.- No other module imports.
PUSHES TO
localStoragevia thess_skip_reward_animkey (string'true'or'false').- Mutates the exported
ACCESSIBILITYobject in place; consumers read flag state by reference.
DOES NOT
- Does not render UI or wire toggles to any settings screen.
- Does not enforce
TEXT_SCALE,HIGH_CONTRAST, orCOLOR_MODEanywhere — those fields exist as placeholders and are not persisted. - Does not validate or migrate stored values; any string other than
'true'is treated asfalse. - Does not emit events or notify subscribers when flags change.
- Does not throw if
localStorageis unavailable — load returnsfalse, set silently keeps the in-memory value.
Signals
- Persistence key:
ss_skip_reward_anim(constantSKIP_ANIM_KEY). - Stored value format: literal strings
'true'or'false'. - Missing key (
raw === null) resolves tofalse.
Entry points
loadSkipRewardAnimations()— called once on module load; callers may re-invoke to re-sync from storage.setSkipRewardAnimations(value)— accessibility-setting toggles.isSkipRewardAnimations()— runtime check before playing a reward animation.- Direct field access on
ACCESSIBILITY— anything reading the flag at runtime.
Pattern notes
- Plain mutable singleton: flags live on one exported object, no getter/setter wrapping.
- Storage access is wrapped in
try/catchso SSR or private-mode browsers degrade to in-memory defaults without throwing. - The in-memory
ACCESSIBILITY.SKIP_REWARD_ANIMATIONSis the source of truth for runtime reads;localStorageis only consulted at load. - Three of four flags (
TEXT_SCALE,HIGH_CONTRAST,COLOR_MODE) are declared but not yet persisted or wired — scaffolding for future accessibility work.