(storageKey: string)
| 176 | } |
| 177 | |
| 178 | function readFoldMap(storageKey: string): Record<string, boolean> { |
| 179 | if (typeof window === 'undefined') return {} |
| 180 | try { |
| 181 | const raw = window.localStorage.getItem(storageKey) |
| 182 | if (!raw) return {} |
| 183 | const parsed = JSON.parse(raw) |
| 184 | if (!parsed || typeof parsed !== 'object') return {} |
| 185 | return Object.fromEntries( |
| 186 | Object.entries(parsed as Record<string, unknown>).filter( |
| 187 | (entry): entry is [string, boolean] => |
| 188 | /^\d+$/.test(entry[0]) && typeof entry[1] === 'boolean' |
| 189 | ) |
| 190 | ) |
| 191 | } catch { |
| 192 | return {} |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | function codeBlockFoldStorageKey(notePath: string): string { |
| 197 | return `${CODE_BLOCK_FOLDS_STORAGE_PREFIX}:${encodeURIComponent(notePath)}` |
no outgoing calls
no test coverage detected