# AssetsApi

interface in `@dioramajs/diorama/assets`

```ts
import type { AssetsApi } from '@dioramajs/diorama/assets'
```

The `assets` service: a shared cache of media and models with progress.

```ts
interface AssetsApi
```

## Members

| Name | Type | Description |
| --- | --- | --- |
| `progress` | `ReadonlySignal<number>` | Progress of the current wave of high and normal work, 0..1. Never goes back within a wave. |
| `acquire` | `acquire<T>(key: string, make: (context: LoaderContext) => Promise<Loaded<T>>, options?: { readonly priority?: Priority; readonly weight?: number }): Asset<T, unknown>` | Get-or-create by key with a lease. Plugins share values they build this way (effects bitmaps). Errors of `make` reject `ready` unchanged and the owner reports them. |
| `load` | `load<K extends keyof AssetTypes>(url: string, options: LoadOptions<K> & { … }): Asset<AssetTypes[K]>` | Loads a URL and returns a lease at once. The type comes from `type` or the extension. Never throws: `ready` rejects with an AssetError, `ASSET_TYPE` for an unknown type, `ASSET_LOAD` for a network or HTTP failure, `ASSET_PARSE` or `ASSET_DECODER` for bad data. |
| `pause` | `pause(reason?: string): Off` | Low-priority loads and decodes wait while any pause is held (a flight). `reason` labels the call, as in `app.pause`. |
| `preload` | `preload(source: PreloadSource, options?: PreloadOptions): Preload` | Next page's media and models: URLs, a parsed Document (Astro, Swup) or a container (Barba). |
| `ready` | `ready(): Promise<void>` | Settles when the current wave is done, or at once without one. Failures count as done. |
| `stats` | `stats(): AssetsStats` | Counters of the cache. |
| `track` | `track(work: PromiseLike<unknown>, options?: { readonly priority?: Priority; readonly weight?: number }): void` | Counts outside work in the current wave, like first-screen effects, fonts or page HTML. `weight: 0` holds `ready()` without moving progress or starting a wave of its own. |

Also exported from `@dioramajs/assets`.

Defined in [packages/assets/src/types.ts](https://github.com/MasterKurosava/diorama/blob/main/packages/assets/src/types.ts#L206).
