(raw: string | null)
| 40 | } |
| 41 | |
| 42 | function decode(raw: string | null): Readonly<ViewPreferences> { |
| 43 | try { |
| 44 | const record: unknown = JSON.parse(raw ?? 'null'); |
| 45 | if (record && typeof record === 'object' && 'version' in record && record.version === 1 && 'preferences' in record) { |
| 46 | return validated(record.preferences); |
| 47 | } |
| 48 | } catch { /* Invalid storage is equivalent to no saved preference. */ } |
| 49 | return DEFAULT_VIEW_PREFERENCES; |
| 50 | } |
| 51 | |
| 52 | /** Stable snapshots prevent a settings change from remounting or resetting either scene. */ |
| 53 | export function readViewPreferences(project: string): Readonly<ViewPreferences> { |
no test coverage detected