> Aperture 0.1.0 — experimental, unpublished. [Package archive](/downloads/bolted-aperture-0.1.0.tgz).

# Optional vgpu covering surface

Aperture's ordinary entry point remains SVG + requestAnimationFrame. It does not import vgpu or request a GPU. `@bolted/aperture/vgpu` is an optional experimental renderer bridge; install `vgpu@^0.5.0` only for projects needing custom shader materials. This is separate from the optional GSAP animation driver. They can be composed.

Use `createVgpuSurface` after mounting, then pass the surface to `createAperture`. Supply import-free WGSL as a string or a vgpu shader artifact. Plain strings need no bundler plugin. Advanced WGSL imports use vgpu's documented loader configuration. `uniforms(frame)` returns a bag keyed by WGSL binding names. `frame` includes progress, phase, normalized origin, CSS width/height, reducedMotion, and pixelWidth/pixelHeight. Do not render private destination content to textures: the cover composites over live DOM.

```ts
import { createAperture, type OpeningSurface } from "@bolted/aperture";
import { createVgpuSurface } from "@bolted/aperture/vgpu";

const abort = new AbortController();
const cover = await createVgpuSurface({
  host,
  signal: abort.signal,
  shader: `
    @group(0) @binding(0) var<uniform> progress: f32;
    @fragment fn fs_main(@location(0) uv: vec2f) -> @location(0) vec4f {
      let a = 1.0 - progress;
      return vec4f(vec3f(0.15, 0.27, 0.94) * a, a);
    }
  `,
  uniforms: (f) => ({ progress: f.progress }),
  fallback: () => {
    const el = document.createElement("div");
    Object.assign(el.style, {
      position: "absolute",
      inset: "0",
      background: "#2546f0",
      zIndex: "3",
      pointerEvents: "none",
    });
    el.setAttribute("aria-hidden", "true");
    host.append(el);
    return {
      resize() {},
      render(f) {
        el.style.opacity = String(1 - f.progress);
      },
      dispose() {
        el.remove();
      },
    } satisfies OpeningSurface;
  },
});
const reveal = createAperture({ host, content, surface: cover });
await reveal.open({ x: 0.25, y: 0.7 });
// On unmount, abort a pending initialization and destroy any mounted controller.
abort.abort();
reveal.destroy();
```

A surface must cover closed content, become transparent at progress 1, and release its own resources in dispose. Content is visually present beneath it but remains inert until fully open. Your app owns focus movement and Escape behavior. Reduced motion follows the same core rules; seeking is available for inspection. Core calls resize and render; custom renderers do not need their own animation loop. If constructing the core fails after creating a surface, dispose the surface in your catch block.

The adapter renders one fullscreen pass per requested frame, skips GPU rendering at progress 1, and caps pixel ratio at 2 (default 1.5), allocation at approximately two million pixels and the device texture dimension limit. WebGPU needs a secure context (HTTPS or localhost) and a supported device/browser. The required fallback factory is also used on validation errors/device loss; it must return a usable surface and not throw. `onFallback(error)` reports this switch. `backend` is `webgpu` or `fallback`. Errors in user callbacks are the application's responsibility.

For React/Next.js, initialize a new surface and imperative controller in a client effect after both elements mount; abort and destroy them in cleanup. Do not pass a pre-created surface to `useAperture`: the existing SVG hook intentionally excludes `surface`, since React Strict Mode can dispose and remount owned resources. A surface is single-owner and must not be reused after disposal.

An AbortSignal cancels initialization and disposes the adapter after mount. Calling controller.destroy also disposes it. Importing is SSR-safe; initialization is browser-only. A suspended/offscreen animation policy remains the application's responsibility. Selvedge's copied research core demonstrates visibility pausing and the same satin field in a WebGL fallback. No physical iPhone frame-rate claim is made.

References: [vgpu Web quickstart](https://vgpu.sh/docs/get-started/web.md), [official source and API](https://github.com/vercel-labs/vgpu).
