2026-01-13 20:02:20 +03:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-29 14:38:07 +03:00
|
|
|
export function createGoogleFontsStore(params: GoogleFontsParams = {}) {
|
2026-01-13 20:02:20 +03:00
|
|
|
return new GoogleFontsStore(params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const googleFontsStore = new GoogleFontsStore();
|