/** * Asset management for ECSpresso ECS framework */ import type EventBus from './event-bus'; import type { AssetStatus, AssetDefinition, AssetHandle, AssetsResource, AssetEvents, AssetConfigurator } from './asset-types'; /** * Manages asset loading and access for ECSpresso */ export default class AssetManager = Record, AssetGroupNames extends string = string> { private readonly assets; private readonly groups; private eventBus; private closed; /** * Set the event bus for asset events * @internal */ setEventBus(eventBus: EventBus>): void; /** * Register an asset definition */ register(key: K, definition: AssetDefinition): void; /** * Load all assets marked as eager */ loadEagerAssets(): Promise; /** * Load a single asset by key */ loadAsset(key: K): Promise; /** * Load all assets in a group */ loadAssetGroup(groupName: AssetGroupNames): Promise; /** * Get a loaded asset. Throws if not loaded. */ get(key: K): AssetTypes[K]; /** * Get a loaded asset or undefined */ tryGet(key: K): AssetTypes[K] | undefined; /** * Get a handle to an asset with status information */ getHandle(key: K): AssetHandle; /** * Get the status of an asset */ getStatus(key: K): AssetStatus; /** * Check if an asset is loaded */ isLoaded(key: K): boolean; /** * Check if all assets in a group are loaded */ isGroupLoaded(groupName: AssetGroupNames): boolean; /** * Get the loading progress of a group (0-1) */ getGroupProgress(groupName: AssetGroupNames): number; /** * Get detailed group progress */ getGroupProgressDetails(groupName: AssetGroupNames): { loaded: number; total: number; progress: number; }; /** * Check group progress and emit events */ private checkGroupProgress; /** * Create the $assets resource object */ createResource(): AssetsResource; /** * Get all registered asset keys */ getKeys(): Array; /** * Get all group names */ getGroupNames(): string[]; /** * Get all asset keys in a group */ getGroupKeys(groupName: string): Array; /** @internal Stop in-flight loads from publishing or reactivating the manager. */ close(): void; /** @internal Release definitions and dependency references after world teardown. */ clear(): void; } /** * Implementation of AssetConfigurator for builder pattern */ export declare class AssetConfiguratorImpl = {}, AssetGroups extends string = never> implements AssetConfigurator { private readonly manager; constructor(manager: AssetManager); add(key: K, loader: () => Promise): AssetConfigurator, AssetGroups>; addWithConfig(key: K, definition: AssetDefinition): AssetConfigurator, AssetGroups>; addGroup Promise>>(groupName: GN, assets: T): AssetConfigurator>; }, AssetGroups | GN>; /** * Get the underlying manager * @internal */ getManager(): AssetManager; } /** * Create a new AssetConfigurator for builder pattern usage */ export declare function createAssetConfigurator = {}, AssetGroups extends string = never>(manager?: AssetManager): AssetConfiguratorImpl;