API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
interfaceAssetSourceCodec
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.
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.
decode(stored: Stored, context: SourceCodecContextWhat a codec is told about the acquisition it is decoding.): Promise<Source>fromBytes?(bytes: ArrayBuffer, context: SourceCodecContextWhat a codec is told about the acquisition it is decoding.): Promise<Stored>fromResponse(response: Response, context: SourceCodecContextWhat a codec is told about the acquisition it is decoding.): Promise<Stored>