refactor(GetFonts): unify filterManager factory + singleton under model/state

Merge the factory previously in lib/filterManager/ with the singleton
previously in model/state/manager.svelte.ts into a single
model/state/filterManager/ slice. The factory builds stateful runes-backed
objects, so it belongs alongside the singleton in model/, not in lib/.

lib/ now contains only the pure mapManagerToParams transform.
Public barrel signature unchanged.
This commit is contained in:
Ilia Mashkov
2026-05-24 15:23:25 +03:00
parent 33d3429060
commit cb8f6ffc97
8 changed files with 45 additions and 35 deletions
+14 -8
View File
@@ -1,19 +1,25 @@
export { mapManagerToParams } from './lib';
export {
/**
* Filter Manager
*/
createFilterManager,
type FilterManager,
mapManagerToParams,
} from './lib';
export { filtersStore } from './model/state/filters.svelte';
export { filterManager } from './model/state/manager.svelte';
export {
filterManager,
/**
* Filter Store
*/
filtersStore,
/**
* Sort Store
*/
SORT_MAP,
SORT_OPTIONS,
type SortApiValue,
type SortOption,
sortStore,
} from './model/store/sortStore.svelte';
} from './model';
export {
FilterControls,
-5
View File
@@ -1,6 +1 @@
export {
createFilterManager,
type FilterManager,
} from './filterManager/filterManager.svelte';
export { mapManagerToParams } from './mapper/mapManagerToParams';
@@ -1,5 +1,5 @@
import type { ProxyFontsParams } from '$entities/Font/api';
import type { FilterManager } from '../filterManager/filterManager.svelte';
import type { FilterManager } from '../../model';
/**
* Maps filter manager to proxy API parameters.
+9 -1
View File
@@ -23,11 +23,19 @@ export {
* Main filter controller
*/
export {
/**
* Factory for constructing a filter manager instance
*/
createFilterManager,
/**
* Reactive interface returned by `createFilterManager`
*/
type FilterManager,
/**
* High-level manager for syncing search and filters
*/
filterManager,
} from './state/manager.svelte';
} from './state/filterManager/filterManager.svelte';
/**
* Side-effect import: installs the global filterManager+sortStore → fontStore
@@ -13,8 +13,8 @@ import { fontStore } from '$entities/Font';
import { untrack } from 'svelte';
import { mapManagerToParams } from '../../lib/mapper/mapManagerToParams';
import { sortStore } from '../store/sortStore.svelte';
import { filterManager } from './filterManager/filterManager.svelte';
import { filtersStore } from './filters.svelte';
import { filterManager } from './manager.svelte';
$effect.root(() => {
/**
@@ -1,9 +1,12 @@
/**
* Filter manager for font filtering
* Filter manager factory and singleton.
*
* Manages multiple filter groups (providers, categories, subsets)
* with debounced search input. Provides reactive state for filter
* selections and convenience methods for bulk operations.
* Owns multiple filter groups (providers, categories, subsets) plus a
* debounced search input. Provides reactive state for filter selections
* and convenience methods for bulk operations.
*
* The factory (`createFilterManager`) is exported for tests; the app
* consumes the `filterManager` singleton at the bottom of this file.
*
* @example
* ```ts
@@ -25,7 +28,7 @@ import { createDebouncedState } from '$shared/lib/helpers';
import type {
FilterConfig,
FilterGroupConfig,
} from '../../model';
} from '../../types/filter';
/**
* Creates a filter manager instance
@@ -123,3 +126,15 @@ export function createFilterManager<TValue extends string>(config: FilterConfig<
}
export type FilterManager = ReturnType<typeof createFilterManager>;
/**
* App-wide filter manager singleton.
*
* Constructed with empty groups; the filtersStore filterManager wiring
* lives in `./bindings.svelte` and populates groups once backend filter
* metadata arrives.
*/
export const filterManager = createFilterManager({
queryValue: '',
groups: [],
});
@@ -1,14 +0,0 @@
/**
* Filter manager singleton.
*
* Constructed with empty groups; the filtersStore → filterManager wiring
* lives in `./bindings.svelte` and populates groups once the backend
* filter metadata arrives.
*/
import { createFilterManager } from '../../lib/filterManager/filterManager.svelte';
export const filterManager = createFilterManager({
queryValue: '',
groups: [],
});