import type { Font } from '@capsizecss/unpack'; import type * as unifont from 'unifont'; import type { z } from 'zod'; import type { fontProviderSchema, localFontFamilySchema, remoteFontFamilySchema, styleSchema } from './config.js'; import type { FONT_TYPES, GENERIC_FALLBACK_NAMES } from './constants.js'; import type { CollectedFontForMetrics } from './logic/optimize-fallbacks.js'; export type AstroFontProvider = z.infer; export interface ResolvedFontProvider { name?: string; provider: (config?: Record) => unifont.Provider; config?: Record; } export type LocalFontFamily = z.infer; interface ResolvedFontFamilyAttributes { nameWithHash: string; } export interface ResolvedLocalFontFamily extends ResolvedFontFamilyAttributes, Omit { variants: Array & { weight?: string; src: Array<{ url: string; tech?: string; }>; }>; } type RemoteFontFamily = z.infer; /** @lintignore somehow required by pickFontFaceProperty in utils */ export interface ResolvedRemoteFontFamily extends ResolvedFontFamilyAttributes, Omit, 'provider' | 'weights'> { provider: ResolvedFontProvider; weights?: Array; } export type FontFamily = LocalFontFamily | RemoteFontFamily; export type ResolvedFontFamily = ResolvedLocalFontFamily | ResolvedRemoteFontFamily; export type FontType = (typeof FONT_TYPES)[number]; /** * Preload data is used for links generation inside the component */ export interface PreloadData { /** * Absolute link to a font file, eg. /_astro/fonts/abc.woff */ url: string; /** * A font type, eg. woff2, woff, ttf... */ type: FontType; } export type FontFaceMetrics = Pick; export type GenericFallbackName = (typeof GENERIC_FALLBACK_NAMES)[number]; export type Defaults = Partial>; export interface FontFileData { hash: string; url: string; init: RequestInit | null; } export interface CreateUrlProxyParams { local: boolean; hasUrl: (hash: string) => boolean; saveUrl: (input: FontFileData) => void; savePreload: (preload: PreloadData) => void; saveFontData: (collected: CollectedFontForMetrics) => void; } /** * Holds associations of hash and original font file URLs, so they can be * downloaded whenever the hash is requested. */ export type FontFileDataMap = Map>; /** * Holds associations of CSS variables and preloadData/css to be passed to the virtual module. */ export type ConsumableMap = Map; css: string; }>; export type Style = z.output; export {};