import { E as ElementAnchor } from './shader-B7AluScJ.js'; export { S as Shader, a as ShaderProps, b as ShaderScene, c as ShaderSceneLifecycle, e as elementToNDC, r as rectAnchorPoint, s as screenToNDC } from './shader-B7AluScJ.js'; export { E as EscapeShader, a as EscapeShaderProps } from './escape-shader-BeEBt1C2.js'; import * as react_jsx_runtime from 'react/jsx-runtime'; import { ReactNode, RefObject } from 'react'; interface HtmlTextureProps { children: ReactNode; interactive?: boolean; /** * Cap the snapshot canvas DPR. The SVG raster + GPU upload scale with * pixel count, so on a Retina display lowering this to `1` cuts ~4× of * per-frame snapshot cost. Useful when the consuming shader already * blurs/distorts the texture (e.g. wave displacement). Default: full * `window.devicePixelRatio`. */ maxPixelRatio?: number; /** * When true, the overlay fills the parent via * `position: absolute; inset: 0`, letting the Shader (and whatever sizes * it from outside) dictate dimensions. Default is content-driven sizing — * the overlay is `position: relative` and its children's intrinsic size * drives the Shader. * * Use `fill` when the snapshot tree's height comes from outside the * Shader (e.g. a parent sized via `h-[70dvh]`) and you want to use * `h-full` / `w-full` inside. This avoids viewport units (vh/dvh/vw/dvw) * being re-resolved against the SVG foreignObject's own box during * rasterization, which produces a height/width mismatch between the * live element and its cloned copy in the snapshot. */ fill?: boolean; } /** * Renders DOM children as an invisible interactive overlay whose contents * are captured (every frame when interactive, on mutation otherwise) and * fed to the parent as a texture. * * Must be used inside from "shader-dom". For the shaders/react * integration, import from "shader-dom/shaders" instead. When used without * either parent, the children render as plain pass-through (no shader). */ declare function HtmlTexture(props: HtmlTextureProps): react_jsx_runtime.JSX.Element; interface SnapshotOptions { /** * When true, `getComputedStyle` is queried on every descendant with an * active `transition-*` declaration so mid-animation intermediate * values are inlined on the clone. Defaults to `false`. Enable only * while `transitionrun` has fired and `transitionend`/`transitioncancel` * hasn't balanced it — see `observeInvalidations`. */ captureTransitions?: boolean; /** * Cap the device pixel ratio used to size the snapshot canvas. The SVG * is rasterized at `min(window.devicePixelRatio, maxPixelRatio)` × the * element's CSS size; lowering this trades visual sharpness for a * proportional reduction in `imgDecode`, `drawImage`, and the * subsequent `texImage2D` upload (each scales with pixel count). * * Useful when the snapshot is consumed by a shader that already blurs * or distorts the texture (e.g. wave displacement) — the lost detail * is invisible. Default: `Infinity` (use full devicePixelRatio). */ maxPixelRatio?: number; } /** * Snapshots an HTML element onto a target canvas (async due to Image load). * * Pipeline: clone → sync form state → apply pseudo-class markers → freeze * text metrics → (optional) capture transition intermediates → embed images → * serialize to XML → wrap in SVG foreignObject with cached page CSS → * SVG string cache check (skip rasterize on identical string) → load as Image → * draw to target canvas at dpr. * * No PNG encoding, no blob URLs — draws directly to the canvas * that backs the CanvasTexture for immediate GPU upload. */ declare function snapshotToCanvas(el: HTMLElement, targetCanvas: HTMLCanvasElement, onComplete?: () => void, options?: SnapshotOptions): Promise; interface UseDomSnapshotOptions { interactive?: boolean; /** * Fired after every successful snapshot. With event-driven scheduling * this fires at most once per animation frame, and only when an event * (mutation, resize, pointer, focus, input, selection, transition tick, * or image load) actually invalidated the snapshot. */ onSnapshot?: (canvas: HTMLCanvasElement) => void; /** * Cap the snapshot canvas DPR. See `SnapshotOptions.maxPixelRatio` for * the full rationale. Default: `Infinity`. */ maxPixelRatio?: number; } /** * Drives the DOM snapshot pipeline for a ref'd element. Unlike a naive * rAF loop, this hook is event-driven: observers (see * `observeInvalidations`) fan into a single `scheduler.invalidate()`, * which coalesces multiple events in one frame into a single snapshot * call. When the DOM is idle, zero snapshot work happens. * * The transition-aware mini-loop keeps invalidating each frame while * CSS transitions are active (tracked via `transitionrun`/`transitionend`) * so transition intermediates get sampled and applied to the clone. * * The returned canvas reference is stable across renders; its contents * update in place. three.js consumers wrap it in CanvasTexture and set * `needsUpdate = true` once per frame. */ declare function useDomSnapshot(sourceRef: RefObject, options?: UseDomSnapshotOptions): HTMLCanvasElement | null; interface UseShaderResult { /** * The WebGL `` rendered by the nearest ancestor ``. `null` * before mount; checking it before use is cheap and avoids assertions. */ canvas: HTMLCanvasElement | null; /** * Convert viewport-relative pixels (e.g. `event.clientX`/`clientY`) to the * shader plane's NDC space (`x, y ∈ [-1, 1]`, `+y` up). Returns `[0, 0]` * when the canvas isn't mounted yet. */ toNDC: (clientX: number, clientY: number) => [number, number]; /** * Convert an element's anchor point to NDC. Useful for triggering effects * from a button's center regardless of how the user interacted with it * (mouse, keyboard, screen reader). */ elementToNDC: (element: Element, anchor?: ElementAnchor) => [number, number]; } /** * Read coordinate-conversion helpers bound to the nearest ancestor ``. * Throws when used outside of a `` subtree. * * @example * const { toNDC } = useShader() *