refactor(font): replace fontLifecycleManager singleton with lazy accessor

Convert the eager fontLifecycleManager singleton to getFontLifecycleManager()
(+ __resetFontLifecycleManager for tests), so its AbortController/FontFace
bookkeeping is set up on first use rather than at module load. Update consumers
(FontVirtualList, FontList, SampleList) and resolve it once as a field in
comparisonStore; the comparisonStore mock now exposes getFontLifecycleManager.
This commit is contained in:
Ilia Mashkov
2026-06-01 18:49:47 +03:00
parent 839460726e
commit b3bc40b76c
6 changed files with 43 additions and 26 deletions
@@ -15,8 +15,8 @@ import { createFontLoadRequestContfig } from '../../lib/createFontLoadRequestCon
import {
type FontLoadRequestConfig,
type UnifiedFont,
fontLifecycleManager,
getFontCatalog,
getFontLifecycleManager,
} from '../../model';
interface Props extends
@@ -53,6 +53,7 @@ let {
}: Props = $props();
const fontCatalog = getFontCatalog();
const fontLifecycleManager = getFontLifecycleManager();
const isLoading = $derived<boolean>(fontCatalog?.isLoading);
const isFetching = $derived<boolean>(fontCatalog.isFetching);