dev-font-file-id-generator.ts — astro Source File
Architecture documentation for dev-font-file-id-generator.ts, a typescript file in the astro codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR c9d5eef5_dcdb_1649_9209_5a22550c254d["dev-font-file-id-generator.ts"] e92fda44_4a5d_b83b_1a45_958cdae6c91b["./definitions.js"] c9d5eef5_dcdb_1649_9209_5a22550c254d --> e92fda44_4a5d_b83b_1a45_958cdae6c91b ea387312_d0a2_bb52_dafc_3872f7307f95["../../src/assets/fonts/types.js"] c9d5eef5_dcdb_1649_9209_5a22550c254d --> ea387312_d0a2_bb52_dafc_3872f7307f95 07866fa4_1b50_10c2_1b6b_5b1f385406b5["unifont"] c9d5eef5_dcdb_1649_9209_5a22550c254d --> 07866fa4_1b50_10c2_1b6b_5b1f385406b5 style c9d5eef5_dcdb_1649_9209_5a22550c254d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type * as unifont from 'unifont';
import type { FontFileContentResolver, FontFileIdGenerator, Hasher } from '../definitions.js';
import type { FontType } from '../types.js';
export class DevFontFileIdGenerator implements FontFileIdGenerator {
readonly #hasher: Hasher;
readonly #contentResolver: FontFileContentResolver;
constructor({
hasher,
contentResolver,
}: {
hasher: Hasher;
contentResolver: FontFileContentResolver;
}) {
this.#hasher = hasher;
this.#contentResolver = contentResolver;
}
#formatWeight(weight: unifont.FontFaceData['weight']): string | undefined {
if (Array.isArray(weight)) {
return weight.join('-');
}
if (typeof weight === 'number') {
return weight.toString();
}
return weight?.replace(/\s+/g, '-');
}
generate({
cssVariable,
originalUrl,
type,
font,
}: {
originalUrl: string;
type: FontType;
cssVariable: string;
font: unifont.FontFaceData;
}): string {
return [
cssVariable.slice(2),
this.#formatWeight(font.weight),
font.style,
font.meta?.subset,
`${this.#hasher.hashString(this.#contentResolver.resolve(originalUrl))}.${type}`,
]
.filter(Boolean)
.join('-');
}
}
Domain
Subdomains
Classes
Dependencies
- ../../src/assets/fonts/types.js
- ./definitions.js
- unifont
Source
Frequently Asked Questions
What does dev-font-file-id-generator.ts do?
dev-font-file-id-generator.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What does dev-font-file-id-generator.ts depend on?
dev-font-file-id-generator.ts imports 3 module(s): ../../src/assets/fonts/types.js, ./definitions.js, unifont.
Where is dev-font-file-id-generator.ts in the architecture?
dev-font-file-id-generator.ts is located at packages/astro/src/assets/fonts/infra/dev-font-file-id-generator.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/assets/fonts/infra).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free