- Implemented UnifiedFontStore extending BaseFontStore - Added pagination support with derived metadata - Added provider-specific shortcuts (setProvider, setCategory, etc.) - Added pagination methods (nextPage, prevPage, goToPage) - Added category getter shortcuts (sansSerifFonts, serifFonts, etc.) - Updated store exports to include unified store - Fixed typo in googleFontsStore.svelte.ts (createGoogleFontsStore) Phase 2/7: Proxy API Integration for GlyphDiff
28 lines
859 B
TypeScript
28 lines
859 B
TypeScript
import type { GoogleFontsParams } from '../../api';
|
|
import { fetchGoogleFontsQuery } from '../services';
|
|
import type { UnifiedFont } from '../types';
|
|
import { BaseFontStore } from './baseFontStore.svelte';
|
|
|
|
/**
|
|
* Google Fonts store wrapping TanStack Query with runes
|
|
*/
|
|
export class GoogleFontsStore extends BaseFontStore<GoogleFontsParams> {
|
|
constructor(initialParams: GoogleFontsParams = {}) {
|
|
super(initialParams);
|
|
}
|
|
|
|
protected getQueryKey(params: GoogleFontsParams) {
|
|
return ['googleFonts', params] as const;
|
|
}
|
|
|
|
protected async fetchFn(params: GoogleFontsParams): Promise<UnifiedFont[]> {
|
|
return fetchGoogleFontsQuery(params);
|
|
}
|
|
}
|
|
|
|
export function createGoogleFontsStore(params: GoogleFontsParams = {}) {
|
|
return new GoogleFontsStore(params);
|
|
}
|
|
|
|
export const googleFontsStore = new GoogleFontsStore();
|