// Pure helpers for offline-mode support, kept out of the reactive module (offline.svelte.ts) so they // unit-test in the node env. Offline became implicit — the net-state machine detects connectivity, and // there is no deliberate toggle — so only the background dict-preload eligibility check and a one-time // cleanup of the retired deliberate-offline preference remain here. const STORAGE_KEY = 'scrabble.offlineMode'; /** * clearOfflinePref removes the retired deliberate-offline preference key. The offline model is implicit * now — the app boots online and the machine detects offline — so a persisted flag from a pre-redesign * install is orphaned data that is never read again; boot clears it once (best-effort) so nobody is left * with a dead key. */ export function clearOfflinePref(): void { try { if (typeof localStorage !== 'undefined') localStorage.removeItem(STORAGE_KEY); } catch { /* best-effort — a storage failure just leaves the orphaned key, which is never read anyway */ } } /** * offlinePreloadEligible reports whether a background dictionary preload should run in this context: an * installed standalone web PWA (not a Telegram/VK mini-app, not a plain browser tab) with a confirmed * email, currently online. Elsewhere the preload is wasted bandwidth — the context has no offline play * to prepare for — so kickDictPreload skips it. */ export function offlinePreloadEligible(opts: { hasEmail: boolean; standalone: boolean; inTelegram: boolean; inVK: boolean; online: boolean; }): boolean { return opts.hasEmail && opts.standalone && !opts.inTelegram && !opts.inVK && opts.online; }