refactor(theme): replace themeManager singleton with lazy getThemeManager

Convert the eager themeManager singleton to a getThemeManager() lazy accessor
(+ __resetThemeManager for tests), so the persistent-store subscription is set
up on first access rather than at module load. Update the barrel and consumers
(Layout init/destroy, ThemeSwitch, story, test).
This commit is contained in:
Ilia Mashkov
2026-06-01 18:39:17 +03:00
parent 0b675635b3
commit 3dca11fea8
6 changed files with 33 additions and 9 deletions
@@ -8,10 +8,11 @@ import { IconButton } from '$shared/ui';
import MoonIcon from '@lucide/svelte/icons/moon';
import SunIcon from '@lucide/svelte/icons/sun';
import { getContext } from 'svelte';
import { themeManager } from '../../model';
import { getThemeManager } from '../../model';
const responsive = getContext<ResponsiveManager>('responsive');
const themeManager = getThemeManager();
const theme = $derived(themeManager.value);
</script>