export type GetApiContextDevWebFontsArgs = {domain: string, timeoutMS?: number | undefined}; export type GetApiContextDevWebFontsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Scrape font information from a website including font families, usage statistics, fallbacks, and element/word counts. * * GET /context-dev/web/fonts */ export const getApiContextDevWebFonts = async (args: GetApiContextDevWebFontsArgs, options?: GetApiContextDevWebFontsOptions) => { const {baseUrl = "https://api.orthogonal.com/mpp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.domain != null) query.append("domain", String(args.domain)) if (args.timeoutMS != null) query.append("timeoutMS", String(args.timeoutMS)) const url = `${baseUrl.replace(/\/+$/, '')}/context-dev/web/fonts${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };