UNPKG

@hiddentao/clockwork-engine

Version:

A TypeScript/PIXI.js game engine for deterministic, replayable games with built-in rendering

31 lines (30 loc) 1.07 kB
import { Loader } from "../Loader"; /** * Headless loader wrapper that returns empty strings for non-essential data. * For data marked as requiredForReplay, forwards the request to the wrapped loader. * * Use cases: * - Server-side replay validation (loads only replay-essential data) * - Automated testing with minimal asset dependencies * - CI/CD environments where only critical assets are needed */ export class HeadlessLoader extends Loader { constructor(loader) { super(); this.wrappedLoader = loader; } /** * Fetch data by ID. * Returns empty string for non-essential data, forwards to wrapped loader for replay-essential data. * * @param id - The identifier for the data to fetch * @param options - Options including requiredForValidation flag * @returns Promise that resolves to the data or empty string */ async fetchData(id, options) { if (options?.requiredForValidation) { return this.wrappedLoader.fetchData(id, options); } return ""; } }