()
| 215 | |
| 216 | /** Create a new local state store instance. */ |
| 217 | export function createRuntimeLocalStateStore(): RuntimeLocalStateStore { |
| 218 | const table = new Map<InstanceId, RuntimeLocalState>(); |
| 219 | |
| 220 | return Object.freeze({ |
| 221 | get: (instanceId) => table.get(instanceId), |
| 222 | set: (instanceId, patch) => { |
| 223 | const prev = table.get(instanceId) ?? DEFAULT_STATE; |
| 224 | const next: RuntimeLocalState = { |
| 225 | layout: patch.layout !== undefined ? patch.layout : prev.layout, |
| 226 | hover: patch.hover !== undefined ? patch.hover : prev.hover, |
| 227 | pressed: patch.pressed !== undefined ? patch.pressed : prev.pressed, |
| 228 | focusable: patch.focusable !== undefined ? patch.focusable : prev.focusable, |
| 229 | tabIndex: patch.tabIndex !== undefined ? patch.tabIndex : prev.tabIndex, |
| 230 | }; |
| 231 | const frozen = freezeState(next); |
| 232 | table.set(instanceId, frozen); |
| 233 | return frozen; |
| 234 | }, |
| 235 | delete: (instanceId) => { |
| 236 | table.delete(instanceId); |
| 237 | }, |
| 238 | }); |
| 239 | } |
| 240 | |
| 241 | /* ========== Virtual List State Store ========== */ |
| 242 |
no test coverage detected