/** * CompositorStatePool -- ring buffer of pre-allocated CompositeState objects. * * The compositor grabs one, writes into it, hands it to the renderer, * which returns it after DOM application. Zero-allocation hot path. * * @module */ import type { CompositeState } from './compositor.js'; interface CompositorStatePoolShape { acquire(): CompositeState; release(state: CompositeState): void; readonly size: number; readonly available: number; } /** * Mutable views into a CompositeState's fields. `CompositeState` declares * its fields as `readonly Record<...>`, but the compositor and the pool * both need to mutate those records in place for the zero-allocation * hot path. This helper centralises the single cast that strips * `readonly` so callers can stay type-safe without re-casting at each * write site. */ export interface MutableCompositeStateViews { readonly discrete: Record; readonly blend: Record>; readonly css: Record; readonly glsl: Record; readonly wgsl: Record; readonly aria: Record; } /** * Expose the inner `Record<…>`s of a {@link CompositeState} as mutable views * for the zero-allocation hot path. Single sanctioned site that strips * `readonly` — do not cast at other call sites. */ export declare function accessCompositeState(state: CompositeState): MutableCompositeStateViews; /** * Creates a ring-buffer pool of pre-allocated CompositeState objects. * Acquire/release pattern avoids GC allocations on the hot render path. * Default 8 slots -- enough for typical compositor with 4-6 quantizers + headroom. * * @example * ```ts * const pool = CompositorStatePool.make(4); * const state = pool.acquire(); * state.discrete['theme'] = 'dark'; * state.outputs.css['--bg'] = '#000'; * pool.release(state); // resets and returns to pool * pool.available; // 4 * ``` */ declare function _make(capacity?: number): CompositorStatePoolShape; /** * CompositorStatePool -- ring buffer of pre-allocated CompositeState objects. * Zero-allocation hot path: acquire a state, write into it, render, then release. * * @example * ```ts * const pool = CompositorStatePool.make(8); * const state = pool.acquire(); * // Write compositor output into state.discrete, state.blend, state.outputs * pool.release(state); // resets and returns to pool * console.log(pool.size, pool.available); // 8, 8 * ``` */ export declare const CompositorStatePool: { make: typeof _make; }; export declare namespace CompositorStatePool { /** Structural shape of a pool instance: `acquire`, `release`, `size`, `available`. */ type Shape = CompositorStatePoolShape; } export {}; //# sourceMappingURL=compositor-pool.d.ts.map