Skip to content

createAssets

createAssets<T>(assetsMap): Assets<T>

Defined in: asset.ts:98

Creates a set of typed asset controllers, one per key in the map.

Each controller exposes show() and hide() methods. It is also directly awaitable — await assets.logo is shorthand for await assets.logo.show().

Image assets require a duration (in ms). Calling show() will automatically record the assetEnd after that many milliseconds. Calling hide() before the timer fires cancels the auto-hide.

Video assets do not require a duration — the video’s natural length determines how long it plays. Call hide() explicitly to stop it.

T extends Record<string, AssetConfig>

{ [K in string | number | symbol]: AssetConfigFor<T[K][“path”]> }

Assets<T>

const assets = createAssets({
logo: { path: './logo.png', audio: 0, fullScreen: false, duration: 3000 },
intro: { path: './intro.mp4', audio: 1.0, fullScreen: true },
})
await assets.logo // shows logo for 3 s, then auto-hides
await page.goto('/dashboard')
assets.intro.show() // start video overlay (non-blocking for caller)
await assets.intro.hide() // hide video overlay manually