import type * as unifont from 'unifont'; import type { CollectedFontForMetrics } from './core/optimize-fallbacks.js'; import type { CssProperties, FontFaceMetrics, FontFileData, FontProvider, FontType, GenericFallbackName, ResolveFontOptions, Style } from './types.js'; export interface Hasher { hashString: (input: string) => string; hashObject: (input: Record) => string; } export interface UrlResolver { resolve: (id: string) => string; readonly cspResources: Array; } export interface FontFileContentResolver { resolve: (url: string) => string; } export interface CssRenderer { generateFontFace: (family: string, properties: CssProperties) => string; generateCssVariable: (key: string, values: Array) => string; } export interface FontMetricsResolver { getMetrics: (name: string, font: CollectedFontForMetrics) => Promise; generateFontFace: (input: { metrics: FontFaceMetrics; fallbackMetrics: FontFaceMetrics; name: string; font: string; properties: CssProperties; }) => string; } export interface SystemFallbacksProvider { getLocalFonts: (fallback: GenericFallbackName) => Array | null; getMetricsForLocalFont: (family: string) => FontFaceMetrics; } export interface FontFetcher { fetch: (input: FontFileData) => Promise; } export interface FontTypeExtractor { extract: (url: string) => FontType; } export interface FontFileReader { extract: (input: { family: string; url: string; }) => { weight: string; style: Style; }; } export interface FontFileIdGenerator { generate: (input: { originalUrl: string; type: FontType; cssVariable: string; font: unifont.FontFaceData; }) => string; } export interface StringMatcher { getClosestMatch: (target: string, candidates: Array) => string; } export interface Storage { getItem: (key: string) => Promise; getItemRaw: (key: string) => Promise; setItem: (key: string, value: any) => Promise; setItemRaw: (key: string, value: any) => Promise; } export interface FontResolver { resolveFont: (options: ResolveFontOptions> & { provider: FontProvider; }) => Promise>; listFonts: (options: { provider: FontProvider; }) => Promise; }