API reference

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

C

classLoaderScope

@codexo/exojs / assets / stable

An owner of asset claims with an explicit lifetime. Assets acquired through a scope stay resident for as long as that scope holds them, and are freed when it releases them - but only if no other scope still holds the same asset. Several scopes can own one asset independently: they share a single fetch and a single resident payload, and one scope releasing never invalidates another. Create a scope with Loader.createScope whenever an asset's lifetime is shorter than the application's - a level, a streamed chunk, a UI panel, a prefetch. Assets acquired directly on the Loader are held for the application's lifetime instead and are freed only when the loader is destroyed. A scope describes a lifetime, never a set of assets: what to acquire comes from an Assets catalog or an Asset descriptor passed to get / load, and typed access stays on that catalog. Scopes nest: createScope makes a child whose claims are independent but whose lifetime cannot outlive its parent's.

3
props
17
methods
4
events
Import
import { LoaderScope } from '@codexo/exojs'

An owner of asset claims with an explicit lifetime.

Assets acquired through a scope stay resident for as long as that scope holds them, and are freed when it releases them - but only if no other scope still holds the same asset. Several scopes can own one asset independently: they share a single fetch and a single resident payload, and one scope releasing never invalidates another.

Create a scope with Loader.createScope whenever an asset's lifetime is shorter than the application's - a level, a streamed chunk, a UI panel, a prefetch. Assets acquired directly on the Loader are held for the application's lifetime instead and are freed only when the loader is destroyed.

A scope describes a lifetime, never a set of assets: what to acquire comes from an Assets catalog or an Asset descriptor passed to get / load, and typed access stays on that catalog.

Scopes nest: createScope makes a child whose claims are independent but whose lifetime cannot outlive its parent's.

Methods17
Creates a child scope: an independent claim owner that cannot outlive this one. The child claims, shares and releases assets exactly like any other scope - one fetch, one resident payload, one claim per owner - and holding the same asset as its parent means two claims, not one. Destroying the child frees only the child's claims; destroying the parent destroys every child it still has first, recursively, so a scene or level teardown reaches the scopes created underneath it without extra bookkeeping. The hierarchy is a lifetime hierarchy only. It never affects asset identity, ownership or what a release frees.
destroy(): void
Releases every claim this scope still holds and destroys any child scope it still has. Assets another scope also holds stay resident, and destroying an already-destroyed scope is a no-op. Acquiring through the scope afterwards - get, load, loadContainer - throws, because the claim it would register has no owner left to release it.
get(path: [KindByPathThe asset type inferred from a path literal, or `never` when unregistered.<S>] extends [never] ? never : S, options?: unknown): LeafForPath<S>
Unpacks an asset container (.exoa) and claims every entry under THIS scope, so the container's assets share this scope's lifetime rather than getting one of their own. See Loader.loadContainer for the format and identity contract.
release(handle: object): void
Drops this scope's claim on one asset. The payload is freed only when no other scope still holds it; a scope can never release another owner's claim. Accepts the handle or value-ref returned by get, an Asset descriptor, a whole Assets catalog, a catalog leaf, or a (type, source) pair. Releasing something this scope never claimed is a no-op, and releasing twice is idempotent. Throws only for an object that has no claim identity at all - a resolved non-leaf resource, or an object this loader has never issued. Release such a resource through its descriptor or its (type, source) pair instead.
Drops this scope's claim on one asset. The payload is freed only when no other scope still holds it; a scope can never release another owner's claim. Accepts the handle or value-ref returned by get, an Asset descriptor, a whole Assets catalog, a catalog leaf, or a (type, source) pair. Releasing something this scope never claimed is a no-op, and releasing twice is idempotent. Throws only for an object that has no claim identity at all - a resolved non-leaf resource, or an object this loader has never issued. Release such a resource through its descriptor or its (type, source) pair instead.
Drops this scope's claim on one asset. The payload is freed only when no other scope still holds it; a scope can never release another owner's claim. Accepts the handle or value-ref returned by get, an Asset descriptor, a whole Assets catalog, a catalog leaf, or a (type, source) pair. Releasing something this scope never claimed is a no-op, and releasing twice is idempotent. Throws only for an object that has no claim identity at all - a resolved non-leaf resource, or an object this loader has never issued. Release such a resource through its descriptor or its (type, source) pair instead.
Drops this scope's claim on one asset. The payload is freed only when no other scope still holds it; a scope can never release another owner's claim. Accepts the handle or value-ref returned by get, an Asset descriptor, a whole Assets catalog, a catalog leaf, or a (type, source) pair. Releasing something this scope never claimed is a no-op, and releasing twice is idempotent. Throws only for an object that has no claim identity at all - a resolved non-leaf resource, or an object this loader has never issued. Release such a resource through its descriptor or its (type, source) pair instead.
Properties3
id: number
Stable, unique per loader run. Diagnostic only; two scopes are never equal by name or kind.
name?: string
Optional human-readable label, surfaced by Loader.inspect. Purely descriptive: two scopes created under the same name are two independent owners, never the same scope. Naming a scope can therefore never make one consumer release another's claim.
Events4
Fired when an asset acquired through this scope fails to load. Does not prevent onLoadComplete.
Fired after each asset of this scope's batch settles. loaded = resolved count, total = batch size.
Source