refactor(font): expose stores via model segment, not the top barrel
Re-exporting the store singletons (fontCatalogStore, fontLifecycleManager, FontsByIdsStore) through entities/Font/index.ts meant every consumer of the barrel eager-instantiated stores and pulled @tanstack/query-core — in dev, test, and as retained code. Drop the store re-export from the top barrel; keep the pure surface (types, constants, domain, lib, ui) there for convenience. Consumers that need stores import $entities/Font/model. Aligns with the BaseQueryStore carve-out: barrel by default, segment path when it would drag a heavy or side-effectful dependency.
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -53,6 +53,16 @@ vi.mock('$shared/lib/helpers/createPersistentStore/createPersistentStore.svelte'
|
||||
|
||||
vi.mock('$entities/Font', async importOriginal => {
|
||||
const actual = await importOriginal<typeof import('$entities/Font')>();
|
||||
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<typeof import('$entities/Font/model')>();
|
||||
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', () => {
|
||||
|
||||
Reference in New Issue
Block a user