()
| 597 | } |
| 598 | |
| 599 | async function loadState() { |
| 600 | if (stateLoaded) { |
| 601 | return stateCache; |
| 602 | } |
| 603 | try { |
| 604 | const content = await readFile(STATE_FILE, "utf8"); |
| 605 | stateCache = normalizeState(JSON.parse(content)); |
| 606 | } catch { |
| 607 | stateCache = createInitialState(); |
| 608 | await persistState(); |
| 609 | } |
| 610 | stateLoaded = true; |
| 611 | return stateCache; |
| 612 | } |
| 613 | |
| 614 | function escapeHtml(value) { |
| 615 | return String(value) |
no test coverage detected