API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
classLoader
Central asset management hub for ExoJS applications. The `Loader` orchestrates fetching, processing, caching, and retrieval of all engine asset types. It ships with built-in factories for every first-party type (Texture, Sound, Music, Video, FontFace, HTMLImageElement, Json, text, SVG, VTT, binary, and WASM) and allows registering custom factories via register. Assets can be loaded in three ways: - **Direct** — `loader.load(Texture, 'hero.png')` fetches immediately and resolves to the finished asset. - **Bundle** — declare assets in a manifest with registerManifest, then call loadBundle to load groups on demand. - **Background** — call backgroundLoad or loadAll to pre-warm everything registered in the manifest at low priority. Once loaded, assets are stored in memory and returned from cache on subsequent `load` or get calls without re-fetching.
import { Loader } from '@codexo/exojs' Central asset management hub for ExoJS applications.
The `Loader` orchestrates fetching, processing, caching, and retrieval of all engine asset types. It ships with built-in factories for every first-party type (Texture, Sound, Music, Video, FontFace, HTMLImageElement, Json, text, SVG, VTT, binary, and WASM) and allows registering custom factories via register.
Assets can be loaded in three ways: - **Direct** — `loader.load(Texture, 'hero.png')` fetches immediately and resolves to the finished asset. - **Bundle** — declare assets in a manifest with registerManifest, then call loadBundle to load groups on demand. - **Background** — call backgroundLoad or loadAll to pre-warm everything registered in the manifest at low priority.
Once loaded, assets are stored in memory and returned from cache on subsequent `load` or get calls without re-fetching.
new(options: LoaderOptions): Loader add(type: Loadable, path: string): this add(type: Loadable, paths: readonly string[]): this add(type: Loadable, items: Readonly<Record<string, string>>): this backgroundLoad(): void destroy(): void get(type: typeof Json, alias: string): T get(type: T, alias: string): LoadReturn<T> has(type: Loadable, alias: string): boolean hasAssetType(typeName: string): boolean hasBundle(name: string): boolean hasExtension(ext: string): boolean hasLoadable(type: AssetConstructor): boolean load(type: typeof Json, path: string, options?: unknown): LoadingQueue<T> load(type: typeof Json, paths: readonly string[], options?: unknown): LoadingQueue<T[]> load(type: typeof Json, items: Readonly<Record<K, string>>, options?: unknown): LoadingQueue<Record<K, T>> load(asset: Asset<T>): LoadingQueue<T> load(assets: Assets<M>): LoadingQueue<InferLoadedMap<M>> load(config: M): LoadingQueue<InferLoadedMap<M>> load(path: PathExtension<S> extends keyof ExtensionTypeMap ? S : never): LoadingQueue<R> load(path: PathExtension<S> extends keyof ExtensionTypeMap ? S : never): LoadingQueue<LoadByPath<S>> load(type: ConstrainedLoadable<T, S>, path: S, options?: unknown): LoadingQueue<LoadReturn<T>> load(type: T, paths: readonly string[], options?: unknown): LoadingQueue<LoadReturn<T>[]> load(type: T, items: Readonly<Record<K, BatchValue>>, options?: unknown): LoadingQueue<Record<K, LoadReturn<T>>> loadAll(): Promise<void> loadBundle(name: string, options: LoadBundleOptions): Promise<void> peek(type: typeof Json, alias: string): T | null peek(type: T, alias: string): LoadReturn<T> | null register(type: AssetConstructor<T>, factory: AssetFactory<T>): this registerAssetType(typeName: K, handler: object): this registerAssetType(typeName: string, ctor: AssetConstructor, factory?: AssetFactory<unknown>): this registerExtension(ext: string, type: AssetConstructor): this registerManifest(manifest: AssetManifest): this setConcurrency(n: number): this unload(asset: Asset<T>): this unload(assets: Assets<M>): this unload(type: Loadable, alias: string): this unloadAll(type?: Loadable): this basePath: string fetchOptions: RequestInit onBundleProgress: Signal<[name, loaded, total]> onError: Signal<[type, alias, error]> onLoaded: Signal<[type, alias, resource]> onProgress: Signal<[loaded, total]>