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
+3 -1
View File
@@ -3,7 +3,7 @@
Application shell with providers and page wrapper
-->
<script lang="ts">
import { themeManager } from '$features/ChangeAppTheme';
import { getThemeManager } from '$features/ChangeAppTheme';
import G from '$shared/assets/G.svg';
import { ResponsiveProvider } from '$shared/lib';
import { cn } from '$shared/lib';
@@ -32,6 +32,8 @@ interface Props {
let { children }: Props = $props();
let fontsReady = $state(true);
const themeManager = getThemeManager();
const theme = $derived(themeManager.value);
onMount(() => themeManager.init());