API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

I

interfaceAssetSourceCodec

@codexo/exojs / assets / stable

Turns an acquired representation into the normalized source an AssetFactory builds a resource from. The contract is deliberately asymmetric. A codec describes how source data ARRIVES - over the network, or as a slice of a container - and how the representation that arrived is read back: ```text Response -> Stored -> Source container bytes -> Stored -> Source ``` `Stored` is the representation worth keeping: what came off the wire, before any interpretation that would have to be redone anyway. Splitting it from `Source` is what lets a later cache persist exactly the acquired form rather than a re-encoded approximation of it. When no such split is useful, leave `Stored` at its default and make `decode` the identity. A codec validates the REPRESENTATION - well-formed JSON, a recognised container header, a supported version. It must not build runtime objects: compiling a module, creating a GPU resource or attaching a media element is the factory's work, and failures there are construction failures, not source failures.

0
props
3
methods
0
events
Import
import { AssetSourceCodec } from '@codexo/exojs'

Turns an acquired representation into the normalized source an AssetFactory builds a resource from.

The contract is deliberately asymmetric. A codec describes how source data ARRIVES - over the network, or as a slice of a container - and how the representation that arrived is read back:

```text Response -> Stored -> Source container bytes -> Stored -> Source ```

`Stored` is the representation worth keeping: what came off the wire, before any interpretation that would have to be redone anyway. Splitting it from `Source` is what lets a later cache persist exactly the acquired form rather than a re-encoded approximation of it. When no such split is useful, leave `Stored` at its default and make `decode` the identity.

A codec validates the REPRESENTATION - well-formed JSON, a recognised container header, a supported version. It must not build runtime objects: compiling a module, creating a GPU resource or attaching a media element is the factory's work, and failures there are construction failures, not source failures.

Methods3
Interpret a stored representation as the source a factory consumes.
fromBytes?(bytes: ArrayBuffer, context: SourceCodecContextWhat a codec is told about the acquisition it is decoding.): Promise<Stored>
Read the representation out of bytes the application already holds - a slice of an asset container, or any other in-memory acquisition. Omit it when the type cannot be built from bytes alone (it needs response headers, or a URL a browser primitive must own). Such a type cannot be packed into a container, and attempting it reports that specifically rather than failing somewhere inside a decode.
fromResponse(response: Response, context: SourceCodecContextWhat a codec is told about the acquisition it is decoding.): Promise<Stored>
Read the representation out of a network response.
Source