/** * HMR handler for `czap:update` messages. * * Performs surgical DOM updates when `@quantize` CSS or shader * uniforms change during development, avoiding full page reloads. * * @module */ import { dispatchCzapEvent } from '@czap/web'; declare global { interface HTMLCanvasElement { /** * czap runtime-attached WebGL program for HMR uniform updates. * Set by the shader directive when a program is linked. */ __czapProgram?: WebGLProgram; } } // --------------------------------------------------------------------------- // Types // --------------------------------------------------------------------------- /** * Shape of the HMR payload the czap Vite plugin ships over the Vite * dev-server WebSocket. Handled by {@link handleHMR} on the client. */ export interface HMRPayload { /** Message discriminator. Always `'czap:update'`. */ readonly type: 'czap:update'; /** Boundary id whose compiled output changed. */ readonly boundary: string; /** New compiled CSS (omitted when only uniforms changed). */ readonly css?: string; /** New shader-uniform values (omitted when only CSS changed). */ readonly uniforms?: Record; } // --------------------------------------------------------------------------- // CSS Hot Update // --------------------------------------------------------------------------- /** * Find or create a