Home / File/ fs-font-file-content-resolver.ts — astro Source File

fs-font-file-content-resolver.ts — astro Source File

Architecture documentation for fs-font-file-content-resolver.ts, a typescript file in the astro codebase. 3 imports, 0 dependents.

File typescript CoreAstro RenderingEngine 3 imports 1 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  07700b7b_8319_7286_5f38_52c3c69d06d9["fs-font-file-content-resolver.ts"]
  ef8a1e3f_e350_75a6_b92d_62a8566d8db9["../core/errors/index.js"]
  07700b7b_8319_7286_5f38_52c3c69d06d9 --> ef8a1e3f_e350_75a6_b92d_62a8566d8db9
  e92fda44_4a5d_b83b_1a45_958cdae6c91b["./definitions.js"]
  07700b7b_8319_7286_5f38_52c3c69d06d9 --> e92fda44_4a5d_b83b_1a45_958cdae6c91b
  c52a5f83_66e3_37d7_9ebb_767f7129bc62["node:path"]
  07700b7b_8319_7286_5f38_52c3c69d06d9 --> c52a5f83_66e3_37d7_9ebb_767f7129bc62
  style 07700b7b_8319_7286_5f38_52c3c69d06d9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { isAbsolute } from 'node:path';
import { AstroError, AstroErrorData } from '../../../core/errors/index.js';
import type { FontFileContentResolver } from '../definitions.js';

type ReadFileSync = (path: string) => string;

export class FsFontFileContentResolver implements FontFileContentResolver {
	#readFileSync: ReadFileSync;

	constructor({ readFileSync }: { readFileSync: ReadFileSync }) {
		this.#readFileSync = readFileSync;
	}

	resolve(url: string): string {
		if (!isAbsolute(url)) {
			// HTTP URLs are enough
			return url;
		}
		try {
			// We use the url and the file content for the id generation because:
			// - The URL is not hashed unlike remote providers
			// - A font file can renamed and swapped so we would incorrectly cache it
			return url + this.#readFileSync(url);
		} catch (cause) {
			throw new AstroError(AstroErrorData.UnknownFilesystemError, { cause });
		}
	}
}

Domain

Subdomains

Functions

Types

Dependencies

  • ../core/errors/index.js
  • ./definitions.js
  • node:path

Frequently Asked Questions

What does fs-font-file-content-resolver.ts do?
fs-font-file-content-resolver.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in fs-font-file-content-resolver.ts?
fs-font-file-content-resolver.ts defines 1 function(s): path.
What does fs-font-file-content-resolver.ts depend on?
fs-font-file-content-resolver.ts imports 3 module(s): ../core/errors/index.js, ./definitions.js, node:path.
Where is fs-font-file-content-resolver.ts in the architecture?
fs-font-file-content-resolver.ts is located at packages/astro/src/assets/fonts/infra/fs-font-file-content-resolver.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