PassthroughFontResolver Class — astro Architecture
Architecture documentation for the PassthroughFontResolver class in utils.js from the astro codebase.
Entity Profile
Dependency Diagram
graph TD b6a0ecd8_ebff_7ea1_d777_730d1e46877b["PassthroughFontResolver"] cf581885_d0e2_b165_a30e_db299dd301a8["utils.js"] b6a0ecd8_ebff_7ea1_d777_730d1e46877b -->|defined in| cf581885_d0e2_b165_a30e_db299dd301a8 29aae4ec_3098_e518_5778_b26a1e8adc96["constructor()"] b6a0ecd8_ebff_7ea1_d777_730d1e46877b -->|method| 29aae4ec_3098_e518_5778_b26a1e8adc96 cee8f92a_5749_0f9c_000d_6a4657b2e205["create()"] b6a0ecd8_ebff_7ea1_d777_730d1e46877b -->|method| cee8f92a_5749_0f9c_000d_6a4657b2e205 080c0d0d_d8e4_44ec_a3df_8353a88c77aa["resolveFont()"] b6a0ecd8_ebff_7ea1_d777_730d1e46877b -->|method| 080c0d0d_d8e4_44ec_a3df_8353a88c77aa 4fec4033_c80d_8a71_69e0_3807819bc659["listFonts()"] b6a0ecd8_ebff_7ea1_d777_730d1e46877b -->|method| 4fec4033_c80d_8a71_69e0_3807819bc659
Relationship Graph
Source Code
packages/astro/test/units/assets/fonts/utils.js lines 106–151
export class PassthroughFontResolver {
/** @type {Map<string, import('../../../../dist/index.js').FontProvider<Record<string, any>>>} */
#providers;
/**
* @private
* @param {Map<string, import('../../../../dist/index.js').FontProvider<Record<string, any>>>} providers
*/
constructor(providers) {
this.#providers = providers;
}
/**
* @param {{ families: Array<import('../../../../dist/assets/fonts/types').ResolvedFontFamily>; hasher: Hasher }} param0
*/
static async create({ families, hasher }) {
/** @type {Map<string, import('../../../../dist/index.js').FontProvider<Record<string, any>>>} */
const providers = new Map();
for (const { provider } of families) {
provider.name = `${provider.name}-${hasher.hashObject(provider.config ?? {})}`;
providers.set(provider.name, /** @type {any} */ (provider));
}
const storage = new SpyStorage();
await Promise.all(
Array.from(providers.values()).map(async (provider) => {
await provider.init?.({ storage, root: new URL(import.meta.url) });
}),
);
return new PassthroughFontResolver(providers);
}
/**
* @param {import('../../../../dist/assets/fonts/types.js').ResolveFontOptions<Record<string, any>> & { provider: import('../../../../dist/index.js').FontProvider; }} param0
*/
async resolveFont({ provider, ...rest }) {
const res = await this.#providers.get(provider.name)?.resolveFont(rest);
return res?.fonts ?? [];
}
/**
* @param {{ provider: import('../../../../dist/index.js').FontProvider }} param0
*/
async listFonts({ provider }) {
return await this.#providers.get(provider.name)?.listFonts?.();
}
}
Domain
Source
Frequently Asked Questions
What is the PassthroughFontResolver class?
PassthroughFontResolver is a class in the astro codebase, defined in packages/astro/test/units/assets/fonts/utils.js.
Where is PassthroughFontResolver defined?
PassthroughFontResolver is defined in packages/astro/test/units/assets/fonts/utils.js at line 106.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free