import * as react_jsx_runtime from 'react/jsx-runtime'; import { CSSProperties, RefObject } from 'react'; /** Texture source: URL string, or an HTML element for dynamic textures */ type TextureSource = string | HTMLImageElement | HTMLVideoElement | HTMLCanvasElement; type TextureWrap = 'clamp' | 'repeat' | 'mirror'; type TextureFilter = 'nearest' | 'linear' | 'mipmap'; type ChannelType = '2d' | 'cube'; /** Advanced texture options with wrap/filter/vflip control */ interface TextureOptions { src: TextureSource; wrap?: TextureWrap; filter?: TextureFilter; vflip?: boolean; /** Cubemap texture (6-face) */ cube?: boolean; } /** A texture input: shorthand source or full options object */ type TextureInput = TextureSource | TextureOptions; /** Texture inputs mapped to Shadertoy channels */ type TextureInputs = { iChannel0?: TextureInput; iChannel1?: TextureInput; iChannel2?: TextureInput; iChannel3?: TextureInput; }; type PassName = 'BufferA' | 'BufferB' | 'BufferC' | 'BufferD' | 'Image'; /** A channel input for a multipass pass: external texture or another pass name */ type PassInput = TextureInput | PassName; /** Configuration for a single render pass */ interface PassConfig { code: string; iChannel0?: PassInput; iChannel1?: PassInput; iChannel2?: PassInput; iChannel3?: PassInput; } /** Multipass configuration: Buffer A-D + Image */ type MultipassConfig = { [K in PassName]?: PassConfig; }; interface ShadertoyApiSampler { filter: string; wrap: string; vflip: string; srgb: string; internal: string; } interface ShadertoyApiInput { id: number; src: string; ctype: string; channel: number; sampler: ShadertoyApiSampler; published: number; } interface ShadertoyApiOutput { id: number; channel: number; } interface ShadertoyApiRenderPass { inputs: ShadertoyApiInput[]; outputs: ShadertoyApiOutput[]; code: string; name: string; description: string; type: string; } interface ShadertoyApiInfo { id: string; date: string; viewed: number; name: string; username: string; description: string; likes: number; published: number; flags: number; tags: string[]; hasliked: number; } interface ShadertoyApiShader { ver: string; info: ShadertoyApiInfo; renderpass: ShadertoyApiRenderPass[]; } interface ShaderMeta { name: string; author: string; description: string; tags: string[]; license?: string; } /** Supported custom uniform value types */ type CustomUniformValue = number | [number, number] | [number, number, number] | [number, number, number, number] | Float32Array; /** Map of custom uniform names to values */ type CustomUniforms = Record; /** Context passed to onFrame callback */ interface FrameContext { time: number; frame: number; delta: number; /** Mutable — modify values to update uniforms this frame */ uniforms: CustomUniforms; resolution: [number, number]; mouse: MouseState; } interface ShadertoyProps { /** Shadertoy-compatible GLSL fragment shader (must contain mainImage) */ fragmentShader?: string; /** Multipass configuration (Buffer A-D + Image) */ passes?: MultipassConfig; /** Texture inputs for iChannel0-3 (single-pass mode) */ textures?: TextureInputs; /** Shadertoy shader ID — fetches shader from API */ id?: string; /** Shadertoy API key (required when using id) */ apiKey?: string; /** Show license/author overlay (default: true when using id) */ showLicense?: boolean; /** Container style */ style?: CSSProperties; /** Container className */ className?: string; /** Pause rendering (default: false) */ paused?: boolean; /** iTime speed multiplier (default: 1.0) */ speed?: number; /** Device pixel ratio (default: window.devicePixelRatio) */ pixelRatio?: number; /** Enable mouse/touch tracking (default: true) */ mouse?: boolean; /** Enable keyboard input texture (default: false) */ keyboard?: boolean; /** Enable audio input texture — true for mic, or pass a MediaStream (default: false) */ audio?: boolean | MediaStream; /** Called when GLSL compilation fails */ onError?: (error: string) => void; /** Called when WebGL is ready */ onLoad?: () => void; /** Custom uniforms (auto-declared in GLSL preamble) */ uniforms?: CustomUniforms; /** Per-frame callback — mutate ctx.uniforms to update values */ onFrame?: (ctx: FrameContext) => void; } interface UseShadertoyOptions { fragmentShader?: string; passes?: MultipassConfig; textures?: TextureInputs; id?: string; apiKey?: string; paused?: boolean; speed?: number; pixelRatio?: number; mouse?: boolean; keyboard?: boolean; audio?: boolean | MediaStream; onError?: (error: string) => void; onLoad?: () => void; uniforms?: CustomUniforms; onFrame?: (ctx: FrameContext) => void; } interface UseShadertoyReturn { canvasRef: RefObject; isReady: boolean; error: string | null; pause: () => void; resume: () => void; meta: ShaderMeta | null; } interface MouseState { x: number; y: number; clickX: number; clickY: number; pressed: boolean; } interface KeyboardState { /** 256×3 texture data buffer (row0=keyDown, row1=keyPressed, row2=toggle) */ data: Uint8Array; /** Per-key toggle state */ toggles: Uint8Array; /** Whether any key changed this frame */ dirty: boolean; } interface AudioState { /** 512×2 texture data (row0=FFT, row1=waveform) */ data: Uint8Array; /** AnalyserNode frequency data buffer */ frequencyData: Uint8Array; /** AnalyserNode time-domain data buffer */ waveformData: Uint8Array; /** WebAudio resources */ context: AudioContext | null; analyser: AnalyserNode | null; sourceNode: MediaStreamAudioSourceNode | null; } declare function Shadertoy({ fragmentShader, passes, textures, id, apiKey, showLicense, style, className, paused, speed, pixelRatio, mouse, keyboard, audio, onError, onLoad, uniforms, onFrame, }: ShadertoyProps): react_jsx_runtime.JSX.Element; declare function useShadertoy({ fragmentShader, passes: passesProp, textures: texturesProp, id, apiKey, paused, speed, pixelRatio, mouse: mouseEnabled, keyboard: keyboardEnabled, audio: audioEnabled, onError, onLoad, uniforms: uniformsProp, onFrame, }: UseShadertoyOptions): UseShadertoyReturn & { meta: ShaderMeta | null; }; /** * Fetch a shader from the Shadertoy API. */ declare function fetchShader(id: string, apiKey: string): Promise; /** * Convert a Shadertoy API shader to our MultipassConfig + TextureInputs + meta. */ declare function apiToConfig(shader: ShadertoyApiShader): { passes: MultipassConfig; textures: TextureInputs; meta: ShaderMeta; }; export { type AudioState, type ChannelType, type CustomUniformValue, type CustomUniforms, type FrameContext, type KeyboardState, type MultipassConfig, type PassConfig, type PassName, type ShaderMeta, Shadertoy, type ShadertoyApiShader, type ShadertoyProps, type TextureFilter, type TextureInput, type TextureInputs, type TextureOptions, type TextureWrap, type UseShadertoyOptions, type UseShadertoyReturn, apiToConfig, fetchShader, useShadertoy };