refactor: consolidate font domain and model types into font.ts
All checks were successful
Workflow / build (pull_request) Successful in 59s
Workflow / publish (pull_request) Has been skipped

This commit is contained in:
Ilia Mashkov
2026-04-10 17:29:15 +03:00
parent 5f38996665
commit d9fa2bc501
6 changed files with 83 additions and 104 deletions

View File

@@ -1,15 +1,7 @@
/** // Applied fonts manager
* ============================================================================
* UNIFIED FONT STORE EXPORTS
* ============================================================================
*
* Single export point for the unified font store infrastructure.
*/
// Applied fonts manager (CSS loading - unchanged)
export { appliedFontsManager } from './appliedFontsStore/appliedFontsStore.svelte'; export { appliedFontsManager } from './appliedFontsStore/appliedFontsStore.svelte';
// Single FontStore (new implementation) // Single FontStore
export { export {
createFontStore, createFontStore,
FontStore, FontStore,

View File

@@ -1,72 +0,0 @@
/**
* Common font domain types
*
* Shared types for font entities across providers (Google, Fontshare).
* Includes categories, subsets, weights, and filter types.
*/
/**
* Unified font category across all providers
*/
export type FontCategory =
| 'sans-serif'
| 'serif'
| 'display'
| 'handwriting'
| 'monospace'
| 'slab'
| 'script';
/**
* Font provider identifier
*/
export type FontProvider = 'google' | 'fontshare';
/**
* Character subset support
*/
export type FontSubset = 'latin' | 'latin-ext' | 'cyrillic' | 'greek' | 'arabic' | 'devanagari';
/**
* Combined filter state for font queries
*/
export interface FontFilters {
/** Selected font providers */
providers: FontProvider[];
/** Selected font categories */
categories: FontCategory[];
/** Selected character subsets */
subsets: FontSubset[];
}
/** Filter group identifier */
export type FilterGroup = 'providers' | 'categories' | 'subsets';
/** Filter type including search query */
export type FilterType = FilterGroup | 'searchQuery';
/**
* Numeric font weights (100-900)
*/
export type FontWeight = '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
/**
* Italic variant with weight: "100italic", "400italic", "700italic", etc.
*/
export type FontWeightItalic = `${FontWeight}italic`;
/**
* All possible font variant identifiers
*
* Includes:
* - Numeric weights: "400", "700", etc.
* - Italic variants: "400italic", "700italic", etc.
* - Legacy names: "regular", "italic", "bold", "bolditalic"
*/
export type FontVariant =
| FontWeight
| FontWeightItalic
| 'regular'
| 'italic'
| 'bold'
| 'bolditalic';

View File

@@ -1,18 +1,78 @@
/** /**
* ============================================================================ * Font domain types
* NORMALIZATION TYPES *
* ============================================================================ * Shared types for font entities across providers (Google, Fontshare).
* Includes categories, subsets, weights, and the unified font model.
*/ */
import type { /**
FontCategory, * Unified font category across all providers
FontProvider, */
FontSubset, export type FontCategory =
FontVariant, | 'sans-serif'
} from './common'; | 'serif'
| 'display'
| 'handwriting'
| 'monospace'
| 'slab'
| 'script';
/** /**
* Font variant types (standardized) * Font provider identifier
*/
export type FontProvider = 'google' | 'fontshare';
/**
* Character subset support
*/
export type FontSubset = 'latin' | 'latin-ext' | 'cyrillic' | 'greek' | 'arabic' | 'devanagari';
/**
* Combined filter state for font queries
*/
export interface FontFilters {
/** Selected font providers */
providers: FontProvider[];
/** Selected font categories */
categories: FontCategory[];
/** Selected character subsets */
subsets: FontSubset[];
}
/** Filter group identifier */
export type FilterGroup = 'providers' | 'categories' | 'subsets';
/** Filter type including search query */
export type FilterType = FilterGroup | 'searchQuery';
/**
* Numeric font weights (100-900)
*/
export type FontWeight = '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
/**
* Italic variant with weight: "100italic", "400italic", "700italic", etc.
*/
export type FontWeightItalic = `${FontWeight}italic`;
/**
* All possible font variant identifiers
*
* Includes:
* - Numeric weights: "400", "700", etc.
* - Italic variants: "400italic", "700italic", etc.
* - Legacy names: "regular", "italic", "bold", "bolditalic"
*/
export type FontVariant =
| FontWeight
| FontWeightItalic
| 'regular'
| 'italic'
| 'bold'
| 'bolditalic';
/**
* Standardized font variant alias
*/ */
export type UnifiedFontVariant = FontVariant; export type UnifiedFontVariant = FontVariant;

View File

@@ -7,24 +7,23 @@
* All imports should use: `import { X } from '$entities/Font/model/types'` * All imports should use: `import { X } from '$entities/Font/model/types'`
*/ */
// Domain types // Font domain and model types
export type { export type {
FilterGroup,
FilterType,
FontCategory, FontCategory,
FontFeatures,
FontFilters,
FontMetadata,
FontProvider, FontProvider,
FontStyleUrls,
FontSubset, FontSubset,
FontVariant, FontVariant,
FontWeight, FontWeight,
FontWeightItalic, FontWeightItalic,
} from './common';
// Normalization types
export type {
FontFeatures,
FontMetadata,
FontStyleUrls,
UnifiedFont, UnifiedFont,
UnifiedFontVariant, UnifiedFontVariant,
} from './normalize'; } from './font';
// Store types // Store types
export type { export type {

View File

@@ -8,8 +8,8 @@ import type {
FontCategory, FontCategory,
FontProvider, FontProvider,
FontSubset, FontSubset,
} from './common'; UnifiedFont,
import type { UnifiedFont } from './normalize'; } from './font';
/** /**
* Font collection state * Font collection state

View File

@@ -18,8 +18,8 @@ import {
type FontLoadRequestConfig, type FontLoadRequestConfig,
type UnifiedFont, type UnifiedFont,
appliedFontsManager, appliedFontsManager,
fontStore,
} from '../../model'; } from '../../model';
import { fontStore } from '../../model/store';
interface Props extends interface Props extends
Omit< Omit<