diff --git a/src/entities/Font/index.ts b/src/entities/Font/index.ts index a7d69ad..938ecb0 100644 --- a/src/entities/Font/index.ts +++ b/src/entities/Font/index.ts @@ -1,8 +1,21 @@ export * from './api'; export * from './domain'; export * from './lib'; -export * from './model'; export * from './ui'; +// Pure model surface (types + constants) is part of the convenient top-level +// API. Stateful stores are deliberately excluded — see below. +export * from './model/const/const'; +export * from './model/types'; + +/* + * Stores (`fontCatalogStore`, `fontLifecycleManager`, `FontsByIdsStore`) are + * intentionally NOT re-exported here. They instantiate module-level singletons + * and pull `@tanstack/query-core`, so funneling them through this barrel would + * make every consumer of `$entities/Font` eager-instantiate stores (and break + * tree-shaking / test init-order). Import them via the model segment: + * import { fontCatalogStore } from '$entities/Font/model'; + */ + // `./testing` is intentionally not re-exported: fixtures must not leak into the // production public API. Import them via `$entities/Font/testing`. diff --git a/src/features/FilterAndSortFonts/model/store/bindings.svelte.ts b/src/features/FilterAndSortFonts/model/store/bindings.svelte.ts index 417fc3e..4191533 100644 --- a/src/features/FilterAndSortFonts/model/store/bindings.svelte.ts +++ b/src/features/FilterAndSortFonts/model/store/bindings.svelte.ts @@ -9,7 +9,7 @@ * observer, so it lives at module scope, not in any individual widget. */ -import { fontCatalogStore } from '$entities/Font'; +import { fontCatalogStore } from '$entities/Font/model'; import { untrack } from 'svelte'; import { mapAppliedFiltersToParams } from '../../lib/mapper/mapAppliedFiltersToParams'; import { appliedFilterStore } from './appliedFilterStore/appliedFilterStore.svelte'; diff --git a/src/widgets/ComparisonView/model/stores/comparisonStore.svelte.ts b/src/widgets/ComparisonView/model/stores/comparisonStore.svelte.ts index 54b6ab3..2562cf3 100644 --- a/src/widgets/ComparisonView/model/stores/comparisonStore.svelte.ts +++ b/src/widgets/ComparisonView/model/stores/comparisonStore.svelte.ts @@ -15,12 +15,14 @@ import { type FontLoadRequestConfig, - FontsByIdsStore, type UnifiedFont, - fontCatalogStore, - fontLifecycleManager, getFontUrl, } from '$entities/Font'; +import { + FontsByIdsStore, + fontCatalogStore, + fontLifecycleManager, +} from '$entities/Font/model'; import { typographySettingsStore } from '$features/AdjustTypography/model'; import { createPersistentStore } from '$shared/lib'; import { untrack } from 'svelte'; diff --git a/src/widgets/ComparisonView/model/stores/comparisonStore.test.ts b/src/widgets/ComparisonView/model/stores/comparisonStore.test.ts index 2f2c87e..4f04d48 100644 --- a/src/widgets/ComparisonView/model/stores/comparisonStore.test.ts +++ b/src/widgets/ComparisonView/model/stores/comparisonStore.test.ts @@ -53,6 +53,16 @@ vi.mock('$shared/lib/helpers/createPersistentStore/createPersistentStore.svelte' vi.mock('$entities/Font', async importOriginal => { const actual = await importOriginal(); + return { + ...actual, + getFontUrl: vi.fn(() => 'https://example.com/font.woff2'), + }; +}); + +// Stores moved behind the model segment; mock them there. FontsByIdsStore is +// intentionally left real (spread from actual) so $state reactivity works. +vi.mock('$entities/Font/model', async importOriginal => { + const actual = await importOriginal(); return { ...actual, fontCatalogStore: { fonts: [] }, @@ -63,7 +73,6 @@ vi.mock('$entities/Font', async importOriginal => { getFontStatus: vi.fn(), ready: vi.fn(() => Promise.resolve()), }, - getFontUrl: vi.fn(() => 'https://example.com/font.woff2'), }; }); @@ -84,11 +93,11 @@ vi.mock('$features/AdjustTypography/model', () => ({ }, })); +import * as proxyFonts from '$entities/Font/api/proxy/proxyFonts'; import { fontCatalogStore, fontLifecycleManager, -} from '$entities/Font'; -import * as proxyFonts from '$entities/Font/api/proxy/proxyFonts'; +} from '$entities/Font/model'; import { ComparisonStore } from './comparisonStore.svelte'; describe('ComparisonStore', () => { diff --git a/src/widgets/ComparisonView/ui/FontList/FontList.svelte b/src/widgets/ComparisonView/ui/FontList/FontList.svelte index 4659390..9733f20 100644 --- a/src/widgets/ComparisonView/ui/FontList/FontList.svelte +++ b/src/widgets/ComparisonView/ui/FontList/FontList.svelte @@ -9,9 +9,11 @@ import { FontVirtualList, type UnifiedFont, VIRTUAL_INDEX_NOT_LOADED, +} from '$entities/Font'; +import { fontCatalogStore, fontLifecycleManager, -} from '$entities/Font'; +} from '$entities/Font/model'; import { getSkeletonWidth } from '$shared/lib/utils'; import { Button, diff --git a/src/widgets/SampleList/ui/SampleList/SampleList.svelte b/src/widgets/SampleList/ui/SampleList/SampleList.svelte index 2d37b8a..22611e5 100644 --- a/src/widgets/SampleList/ui/SampleList/SampleList.svelte +++ b/src/widgets/SampleList/ui/SampleList/SampleList.svelte @@ -8,9 +8,11 @@ import { FontVirtualList, createFontRowSizeResolver, +} from '$entities/Font'; +import { fontCatalogStore, fontLifecycleManager, -} from '$entities/Font'; +} from '$entities/Font/model'; import { TypographyMenu, typographySettingsStore, diff --git a/src/widgets/SampleList/ui/SampleListSection/SampleListSection.svelte b/src/widgets/SampleList/ui/SampleListSection/SampleListSection.svelte index 2ce0825..91b8a6b 100644 --- a/src/widgets/SampleList/ui/SampleListSection/SampleListSection.svelte +++ b/src/widgets/SampleList/ui/SampleListSection/SampleListSection.svelte @@ -3,7 +3,7 @@ Wraps SampleList with a Section component -->