Class: AssetCatalog
Defined in: assets/catalog.ts:16
A read-only query engine for retrieving strongly-typed asset metadata from an AssetManifest.
- Use this class to safely extract dimensions, durations, and specific configurations for images, videos, audio files, and fonts, with built-in runtime validation.
Example
import { AssetCatalog } from './catalog';
import { manifest } from './generated-manifest';
* const catalog = new AssetCatalog(manifest);
const dimensions = catalog.getImageSize("hero-banner.png");
console.log(dimensions.width); // 1920
Constructors
Constructor
new AssetCatalog(
manifest):AssetCatalog
Defined in: assets/catalog.ts:21
Creates an instance of AssetCatalog.
Parameters
manifest
The underlying immutable asset manifest lookup structure.
Returns
AssetCatalog
Methods
getAudioDuration()
getAudioDuration(
src):number
Defined in: assets/catalog.ts:98
Convenient shortcut to get the exact playback duration of an audio asset. *
Parameters
src
string
The unique source path or identifier of the audio asset.
Returns
number
The duration of the audio in seconds.
Throws
Inherits the missing asset error from getAudioMeta.
getAudioMeta()
getAudioMeta(
src):AudioMeta
Defined in: assets/catalog.ts:53
Retrieves the complete metadata object for a specified audio track. *
Parameters
src
string
The unique source path or identifier of the audio asset.
Returns
The associated AudioMeta block.
Throws
If the audio resource does not exist in the manifest.
getFontFamilyMetas()
getFontFamilyMetas(
fontFamily):FontMeta[]
Defined in: assets/catalog.ts:78
Return every font face registered for a family, across all weights and slants. Used to register the whole family with the renderer so the font matcher can resolve any requested weight to its nearest available file.
Parameters
fontFamily
string
The font family name (e.g. "Inter").
Returns
FontMeta[]
All matching FontMeta entries; empty if the family is unknown.
getFontMeta()
getFontMeta(
key):FontMeta
Defined in: assets/catalog.ts:65
Retrieves the complete metadata object for a specified font face. *
Parameters
key
string
The unique lookup key or family name of the font asset.
Returns
The associated FontMeta block.
Throws
If the font resource key does not exist in the manifest.
getImageMeta()
getImageMeta(
src):ImageMeta
Defined in: assets/catalog.ts:29
Retrieves the complete metadata object for a specified image. *
Parameters
src
string
The unique source path or identifier of the image asset.
Returns
The associated ImageMeta block.
Throws
If the image resource does not exist in the manifest.
getImageSize()
getImageSize(
src):object
Defined in: assets/catalog.ts:108
Convenient shortcut to isolate the structural layout dimensions of an image asset. *
Parameters
src
string
The unique source path or identifier of the image asset.
Returns
object
An object containing the width and height dimensions of the asset.
height
height:
number
width
width:
number
Throws
Inherits the missing asset error from getImageMeta.
getVideoDuration()
getVideoDuration(
src):number
Defined in: assets/catalog.ts:88
Convenient shortcut to get the exact playback duration of a video asset. *
Parameters
src
string
The unique source path or identifier of the video asset.
Returns
number
The duration of the video in seconds (or frames, depending on manifest standard).
Throws
Inherits the missing asset error from getVideoMeta.
getVideoMeta()
getVideoMeta(
src):VideoMeta
Defined in: assets/catalog.ts:41
Retrieves the complete metadata object for a specified video. *
Parameters
src
string
The unique source path or identifier of the video asset.
Returns
The associated VideoMeta block.
Throws
If the video resource does not exist in the manifest.