--- name: typegpu description: TypeGPU and raw WebGPU adapter patterns for HyperFrames. Use when creating GPU-rendered compositions with TypeGPU, raw WebGPU, WGSL fragment shaders, compute pipelines, liquid glass effects, particle systems, or any canvas layer driven by navigator.gpu that responds to HyperFrames hf-seek events. --- # TypeGPU / WebGPU for HyperFrames HyperFrames supports TypeGPU and raw WebGPU through its `typegpu` runtime adapter. The adapter does not own your pipeline. It publishes HyperFrames time and dispatches a seek event so your composition can render the exact GPU frame. ## Contract - Initialize WebGPU asynchronously (`await navigator.gpu.requestAdapter()`), but register all GSAP tweens **synchronously** — before any `await`. The HyperFrames player reads the timeline immediately at page load. - Render from HyperFrames time, not `performance.now()`. - Listen for the `hf-seek` event and re-render at exactly that time. - Guard against environments where WebGPU is unavailable — the adapter does not check for you. - For video renders, call `await device.queue.onSubmittedWorkDone()` after submitting GPU work to ensure the canvas is flushed before the frame is captured. The adapter sets `window.__hfTypegpuTime` and dispatches `new CustomEvent("hf-seek", { detail: { time } })` on each seek. ## Basic Pattern ```html ``` ## Timeline Registration GSAP tweens that drive text, captions, or HTML elements must be registered **synchronously** — before any `await`: ```js const tl = gsap.timeline({ paused: true }); // Caption tweens: synchronous, added before WebGPU init gsap.set(".cap", { opacity: 0 }); tl.to("#cap-1", { opacity: 1, duration: 0.3 }, 1.0); tl.to("#cap-1", { opacity: 0, duration: 0.2 }, 3.5); window.__timelines["my-comp"] = tl; // GPU-dependent tweens can go inside the async IIFE (async () => { // ... WebGPU init ... const proxy = { value: 0 }; tl.to(proxy, { value: 1, duration: 2, onUpdate: render }, 0.5); })(); ``` ## Video-Backed Effects (Liquid Glass, Distortion) To use a `