@viji-dev/core 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/artist-dts-p5.js +1 -1
- package/dist/artist-dts.js +1 -1
- package/dist/artist-global-p5.d.ts +1 -1
- package/dist/artist-global.d.ts +1 -1
- package/dist/assets/{viji.worker-CwvLwn6O.js → viji.worker-CV0DI4PF.js} +37 -37
- package/dist/docs-api.js +72 -72
- package/dist/{essentia-wasm.web-DclksH__.js → essentia-wasm.web-B9-7D9aP.js} +1 -1
- package/dist/{index-BFSuPQzu.js → index-Dw5Jy7so.js} +5 -5
- package/dist/index.d.ts +68 -3
- package/dist/index.js +1 -1
- package/dist/{scene-analysis-2Ov0HS52.js → scene-analysis-Bsf4JrzY.js} +83 -22
- package/dist/scene-analysis.d.ts +67 -2
- package/dist/scene-analysis.js +1 -1
- package/package.json +117 -117
package/dist/artist-dts.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const artistDts = "// Viji Artist API - Global Type Definitions\n// All types are placed inside declare global {} because this file uses export {}\n// for top-level await support, which makes it a module (where top-level declarations\n// would otherwise be module-scoped, not global).\n\ndeclare global {\n /**\r\n * Real-time audio analysis for the main audio stream (`viji.audio`).\r\n * Provides volume, frequency bands, beat detection (with triggers, events, BPM),\r\n * spectral features, and access to raw FFT / waveform data.\r\n *\r\n * All numeric outputs are zeroed when `isConnected` is `false`.\r\n */\r\n interface AudioAPI {\r\n /** `true` when an audio source is connected; otherwise all numeric fields read as `0` and helper methods return empty data. */\r\n isConnected: boolean;\r\n /** Overall loudness across the stream. */\r\n volume: {\r\n /** Instantaneous RMS volume in 0..1. */\r\n current: number;\r\n /** Instantaneous peak amplitude in 0..1. */\r\n peak: number;\r\n /** Volume with a 200ms decay envelope; rises fast, falls smoothly. Use for flicker-free animations. */\r\n smoothed: number;\r\n };\r\n /** Energy in five fixed frequency bands, plus a smoothed companion (~150ms decay) for each. All in 0..1. */\r\n bands: {\r\n /** Instant low-band energy (20-120 Hz, bass/kick range). 0..1. */\r\n low: number;\r\n /** Instant low-mid energy (120-400 Hz). 0..1. */\r\n lowMid: number;\r\n /** Instant mid energy (400-1600 Hz, vocals/instruments). 0..1. */\r\n mid: number;\r\n /** Instant high-mid energy (1600-6000 Hz, cymbals/hi-hats). 0..1. */\r\n highMid: number;\r\n /** Instant high-band energy (6000-16000 Hz, air/brilliance). 0..1. */\r\n high: number;\r\n /** Smoothed `low` (~150ms decay). 0..1. */\r\n lowSmoothed: number;\r\n /** Smoothed `lowMid` (~150ms decay). 0..1. */\r\n lowMidSmoothed: number;\r\n /** Smoothed `mid` (~150ms decay). 0..1. */\r\n midSmoothed: number;\r\n /** Smoothed `highMid` (~150ms decay). 0..1. */\r\n highMidSmoothed: number;\r\n /** Smoothed `high` (~150ms decay). 0..1. */\r\n highSmoothed: number;\r\n };\r\n /** Beat detection: fast/smoothed energy curves, single-frame boolean triggers, raw event list, and BPM tracking. */\r\n beat: {\r\n /** Kick energy curve in 0..1 with a 300ms decay. Peaks on each detected kick. */\r\n kick: number;\r\n /** Snare energy curve in 0..1 with a 300ms decay. */\r\n snare: number;\r\n /** Hi-hat energy curve in 0..1 with a 300ms decay. */\r\n hat: number;\r\n /** Energy curve for any beat type in 0..1 with a 300ms decay. */\r\n any: number;\r\n /** Smoothed `kick` curve in 0..1 with a 500ms decay. Use for ambient pulses. */\r\n kickSmoothed: number;\r\n /** Smoothed `snare` curve in 0..1 with a 500ms decay. */\r\n snareSmoothed: number;\r\n /** Smoothed `hat` curve in 0..1 with a 500ms decay. */\r\n hatSmoothed: number;\r\n /** Smoothed `any` curve in 0..1 with a 500ms decay. */\r\n anySmoothed: number;\r\n /** Single-frame boolean triggers OR-accumulated between frames, so no detected beat is lost. */\r\n triggers: {\r\n /** `true` for one frame when any beat is detected. */\r\n any: boolean;\r\n /** `true` for one frame when a kick is detected. */\r\n kick: boolean;\r\n /** `true` for one frame when a snare is detected. */\r\n snare: boolean;\r\n /** `true` for one frame when a hi-hat is detected. */\r\n hat: boolean;\r\n };\r\n /** All beats detected since the last render frame (zero or more). Cleared each frame. */\r\n events: Array<{\r\n /** Which drum was detected. */\r\n type: 'kick' | 'snare' | 'hat';\r\n /** Timestamp of the detection in milliseconds. */\r\n time: number;\r\n /** Strength of the beat in 0..1. */\r\n strength: number;\r\n }>;\r\n /** Currently detected tempo in beats per minute. Defaults to `120` when no audio. */\r\n bpm: number;\r\n /** Confidence of the BPM tracker in 0..1. */\r\n confidence: number;\r\n /** `true` when the BPM tracker has a stable lock on the current tempo. */\r\n isLocked: boolean;\r\n };\r\n /** High-level spectral features derived from the FFT. */\r\n spectral: {\r\n /** Normalized spectral centroid in 0..1. Higher values mean brighter, more treble-heavy sound. */\r\n brightness: number;\r\n /** Normalized spectral flatness in 0..1. Higher values mean noisier (white-noise-like) sound; lower values mean tonal. */\r\n flatness: number;\r\n };\r\n /**\r\n * Returns the raw FFT magnitude spectrum as a `Uint8Array` (1024 bins, each 0..255).\r\n * Bin `i` covers frequency `i × (sampleRate / fftSize)`. The returned array is a\r\n * snapshot from the latest analysis tick; repeated calls in the same frame return the same data.\r\n *\r\n * @example\r\n * const fft = viji.audio.getFrequencyData();\r\n * for (let i = 0; i < fft.length; i++) drawBar(i, fft[i] / 255);\r\n */\r\n getFrequencyData: () => Uint8Array;\r\n /**\r\n * Returns the raw time-domain waveform as a `Float32Array` (2048 PCM samples in -1..1).\r\n * The returned array is a snapshot; repeated calls in the same frame return the same data.\r\n *\r\n * @example\r\n * const wave = viji.audio.getWaveform();\r\n * for (let i = 0; i < wave.length; i++) drawSample(i, wave[i]);\r\n */\r\n getWaveform: () => Float32Array;\r\n }\r\n\n /**\r\n * Lightweight audio analysis for additional or device audio streams. A strict\r\n * subset of `AudioAPI` that exposes volume, frequency bands, spectral features,\r\n * and raw FFT/waveform access, but **no beat detection** (no `beat`, no BPM,\r\n * no triggers, no events).\r\n */\r\n interface AudioStreamAPI {\r\n /** `true` when this audio stream is connected; otherwise all numeric fields read as `0`. */\r\n isConnected: boolean;\r\n /** Overall loudness across the stream. */\r\n volume: {\r\n /** Instantaneous RMS volume in 0..1. */\r\n current: number;\r\n /** Instantaneous peak amplitude in 0..1. */\r\n peak: number;\r\n /** Volume with a 200ms decay envelope. */\r\n smoothed: number;\r\n };\r\n /** Energy in five fixed frequency bands, plus a smoothed companion (~150ms decay) for each. All in 0..1. */\r\n bands: {\r\n /** Instant low-band energy (20-120 Hz). 0..1. */\r\n low: number;\r\n /** Instant low-mid energy (120-400 Hz). 0..1. */\r\n lowMid: number;\r\n /** Instant mid energy (400-1600 Hz). 0..1. */\r\n mid: number;\r\n /** Instant high-mid energy (1600-6000 Hz). 0..1. */\r\n highMid: number;\r\n /** Instant high-band energy (6000-16000 Hz). 0..1. */\r\n high: number;\r\n /** Smoothed `low` (~150ms decay). 0..1. */\r\n lowSmoothed: number;\r\n /** Smoothed `lowMid` (~150ms decay). 0..1. */\r\n lowMidSmoothed: number;\r\n /** Smoothed `mid` (~150ms decay). 0..1. */\r\n midSmoothed: number;\r\n /** Smoothed `highMid` (~150ms decay). 0..1. */\r\n highMidSmoothed: number;\r\n /** Smoothed `high` (~150ms decay). 0..1. */\r\n highSmoothed: number;\r\n };\r\n /** High-level spectral features derived from the FFT. */\r\n spectral: {\r\n /** Normalized spectral centroid in 0..1. */\r\n brightness: number;\r\n /** Normalized spectral flatness in 0..1. */\r\n flatness: number;\r\n };\r\n /**\r\n * Returns the raw FFT magnitude spectrum for this stream as a `Uint8Array`\r\n * (1024 bins, each 0..255). Snapshot semantics; see `AudioAPI.getFrequencyData`.\r\n */\r\n getFrequencyData: () => Uint8Array;\r\n /**\r\n * Returns the raw time-domain waveform for this stream as a `Float32Array`\r\n * (2048 samples, each -1..1). Snapshot semantics; see `AudioAPI.getWaveform`.\r\n */\r\n getWaveform: () => Float32Array;\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.button()`. The host renders a clickable\r\n * momentary button. The resulting `value` is `true` for one frame after press,\r\n * then auto-resets to `false`.\r\n */\r\n interface ButtonConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Display name shown on the button in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n }\r\n\n /**\r\n * Reactive object returned by `viji.button()`. `value` is a momentary flag:\r\n * `true` for exactly one frame after the user clicks, then auto-resets to\r\n * `false`. Use it to trigger discrete events from `render()`.\r\n */\r\n interface ButtonParameter {\r\n /** `true` for the single frame after the user clicks the button, `false` otherwise. */\r\n value: boolean;\r\n /** Display name shown on the button in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Options accepted by `VijiCore.captureFrame()` for snapshotting the current\r\n * scene. Controls output format, encoding, and target resolution / aspect.\r\n */\r\n interface CaptureFrameOptions {\r\n /** Output format: `'blob'` for an encoded image, `'bitmap'` for a GPU-friendly `ImageBitmap`. Default: `'blob'`. */\r\n format?: 'blob' | 'bitmap';\r\n /**\r\n * MIME type for `'blob'` output (ignored for `'bitmap'`). Examples:\r\n * `'image/png'`, `'image/jpeg'`, `'image/webp'`. Default: `'image/png'`\r\n * (lossless, preserves alpha). Pass a lossy type for smaller files when\r\n * transparency does not matter.\r\n */\r\n type?: string;\r\n /**\r\n * Encoding quality for lossy `'blob'` formats (`'image/jpeg'`, `'image/webp'`),\r\n * from `0` (smallest) to `1` (best). Values outside the range are clamped.\r\n * Ignored for `'image/png'` and for `format: 'bitmap'`. When omitted, the\r\n * browser's default quality is used.\r\n */\r\n quality?: number;\r\n /**\r\n * Target resolution.\r\n * - `number`: scale factor relative to the current canvas size (e.g., `0.5` = 50%).\r\n * - `Resolution`: exact output size. If the aspect ratio differs from the\r\n * canvas, the source is center-cropped before scaling.\r\n */\r\n resolution?: number | Resolution;\r\n /**\r\n * Frame role to capture. `'plate'` (default) captures the clean pre-overlay\r\n * frame — thumbnails and VJ source frames, identical to previous behavior.\r\n * `'display'` captures the composited frame the viewer sees, including the\r\n * branding overlay when the session applies it. On headless cores no\r\n * overlay is ever drawn, so `'display'` degrades to `'plate'`. Note:\r\n * center-cropping via `resolution` can crop the edge-anchored overlay out\r\n * of a `'display'` capture — display captures are intended at canvas aspect.\r\n */\r\n frame?: 'plate' | 'display';\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.color()`. Defines the color picker's\r\n * label and UI grouping/visibility.\r\n */\r\n interface ColorConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Display name shown next to the color swatch in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n /**\r\n * Enable a transparency channel. When `true` the canonical value is always an\r\n * 8-digit `#rrggbbaa` (opaque inputs are padded `ff`), the picker shows an alpha\r\n * slider, and the shader uniform is a `vec4`. When `false` (default) the value is\r\n * `#rrggbb` and any alpha-bearing input is rejected. Default: `false`.\r\n */\r\n alpha?: boolean;\r\n }\r\n\n /**\r\n * Accepted input forms for color parameters. Internally normalized to canonical\r\n * lowercase hex: `#rrggbb` for an opaque parameter, `#rrggbbaa` for a parameter\r\n * declared with `alpha: true`. See `viji.color()` for full documentation.\r\n *\r\n * - `string`: hex (`#rrggbb`, `#rgb`), CSS `rgb(r, g, b)`, CSS `hsl(h, s%, l%)`,\r\n * GLSL-style `vec3(r, g, b)` (0..1), or P5-style `hsb(h, s, b)` (0..360 / 0..100 / 0..100)\r\n * - `{ r, g, b }`: RGB object with components in 0..255\r\n * - `{ h, s, b }`: HSB object with `h` in 0..360, `s` and `b` in 0..100\r\n *\r\n * Alpha-bearing forms (`#rrggbbaa`, `#rgba`, `rgba()`, `hsla()`, `vec4()`, and the\r\n * objects with an `a` field in 0..1) are accepted ONLY by a parameter declared with\r\n * `alpha: true`; an opaque parameter rejects them even when the alpha is `1`.\r\n */\r\n type ColorInput = string | {\r\n /** Red component in 0..255. */\r\n r: number;\r\n /** Green component in 0..255. */\r\n g: number;\r\n /** Blue component in 0..255. */\r\n b: number;\r\n /** Alpha in 0..1. Only valid on a parameter declared with `alpha: true`. */\r\n a?: number;\r\n } | {\r\n /** Hue in 0..360. */\r\n h: number;\r\n /** Saturation in 0..100. */\r\n s: number;\r\n /** Brightness in 0..100. */\r\n b: number;\r\n /** Alpha in 0..1. Only valid on a parameter declared with `alpha: true`. */\r\n a?: number;\r\n };\r\n\n /**\r\n * Reactive object returned by `viji.color()`. `value` is always a canonical\r\n * lowercase hex string whose width is fixed by the parameter's mode (`#rrggbb`,\r\n * or `#rrggbbaa` when declared with `alpha: true`); `rgb`, `hsb` and `alpha` are\r\n * derived accessors that are recomputed (and frozen) every time the user changes\r\n * the color.\r\n */\r\n interface ColorParameter {\r\n /** Canonical lowercase hex color string: `#rrggbb`, or `#rrggbbaa` when `alpha: true`. Updates in real-time. */\r\n value: string;\r\n /** Alpha in 0..1. Always present: `1` on an opaque parameter, the live alpha when `alpha: true`. */\r\n alpha: number;\r\n /** RGB components as integers in 0..255 (frozen, recomputed when value changes). */\r\n rgb: {\r\n /** Red component, integer in 0..255. */\r\n r: number;\r\n /** Green component, integer in 0..255. */\r\n g: number;\r\n /** Blue component, integer in 0..255. */\r\n b: number;\r\n };\r\n /** HSB components: `h` in 0..360, `s` and `b` in 0..100 (frozen, recomputed when value changes). */\r\n hsb: {\r\n /** Hue in 0..360. */\r\n h: number;\r\n /** Saturation in 0..100. */\r\n s: number;\r\n /** Brightness in 0..100. */\r\n b: number;\r\n };\r\n /** Display name shown next to the swatch in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.coordinate()`. The host renders a 2D\r\n * draggable pad; both `x` and `y` are clamped to `-1..1`.\r\n */\r\n interface CoordinateConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Snap increment for both `x` and `y` components. Default: `0.01`. */\r\n step?: number;\r\n /** Display name shown next to the pad in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n }\r\n\n /**\r\n * Reactive object returned by `viji.coordinate()`. `value.x` and `value.y` are\r\n * always in `-1..1`; the host UI renders a draggable 2D pad.\r\n */\r\n interface CoordinateParameter {\r\n /** Current `{ x, y }` position. Both components are in `-1..1`. Updates in real-time. */\r\n value: CoordinateValue;\r\n /** Snap increment for both `x` and `y` components. */\r\n step: number;\r\n /** Display name shown next to the pad in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Two-component coordinate, both axes in `-1..1` (centered on the canvas).\r\n * Returned and consumed by `viji.coordinate()`.\r\n */\r\n type CoordinateValue = {\r\n /** Horizontal axis in `-1..1` (left to right, `0` = canvas center). */\r\n x: number;\r\n /** Vertical axis in `-1..1` (bottom to top, `0` = canvas center). */\r\n y: number;\r\n };\r\n\n /**\r\n * Identifier for an individual computer-vision feature pipeline. Returned by\r\n * `VideoAPI.cv.getActiveFeatures()` and used internally to track state.\r\n */\r\n type CVFeature = 'faceDetection' | 'faceMesh' | 'handTracking' | 'poseDetection' | 'bodySegmentation' | 'emotionDetection';\r\n\n /**\r\n * Computer-vision processing rate relative to the input video stream rate.\r\n * `'full'` runs CV on every delivered video frame, `'half'` every other frame,\r\n * `'quarter'` every fourth, `'eighth'` every eighth. Lower rates reduce CPU/GPU\r\n * cost. (Throttles the camera/stream frame cadence, independent of scene FPS.)\r\n */\r\n type CVFrameRateMode = 'full' | 'half' | 'quarter' | 'eighth';\r\n\n /**\r\n * Device motion data sourced from the platform's `DeviceMotionEvent`. All\r\n * accelerations are in metres per second squared (m/s²); rotation rates are\r\n * in degrees per second. Inner objects may be `null` when the underlying\r\n * sensor is unavailable, and individual axes may be `null` on platforms that\r\n * report only some components.\r\n */\r\n interface DeviceMotionData {\r\n /** Acceleration without gravity (m/s²). `null` when no accelerometer is available. */\r\n acceleration: {\r\n /** Acceleration along the device's X axis in m/s². `null` if unsupported. */\r\n x: number | null;\r\n /** Acceleration along the device's Y axis in m/s². `null` if unsupported. */\r\n y: number | null;\r\n /** Acceleration along the device's Z axis in m/s². `null` if unsupported. */\r\n z: number | null;\r\n } | null;\r\n /** Acceleration including gravity (m/s²). `null` when no accelerometer is available. */\r\n accelerationIncludingGravity: {\r\n /** Acceleration including gravity along the device's X axis in m/s². `null` if unsupported. */\r\n x: number | null;\r\n /** Acceleration including gravity along the device's Y axis in m/s². `null` if unsupported. */\r\n y: number | null;\r\n /** Acceleration including gravity along the device's Z axis in m/s². `null` if unsupported. */\r\n z: number | null;\r\n } | null;\r\n /** Angular rotation rate (degrees per second). `null` when no gyroscope is available. */\r\n rotationRate: {\r\n /** Rotation rate around the device's Z axis in deg/s. `null` if unsupported. */\r\n alpha: number | null;\r\n /** Rotation rate around the device's X axis in deg/s. `null` if unsupported. */\r\n beta: number | null;\r\n /** Rotation rate around the device's Y axis in deg/s. `null` if unsupported. */\r\n gamma: number | null;\r\n } | null;\r\n /** Interval between sensor updates in milliseconds. */\r\n interval: number;\r\n }\r\n\n /**\r\n * DeviceOrientationEvent data\r\n * Matches native DeviceOrientationEvent structure\r\n */\r\n interface DeviceOrientationData {\r\n /** Rotation around Z-axis (0-360 degrees, compass heading) */\r\n alpha: number | null;\r\n /** Rotation around X-axis (-180 to 180 degrees, front-to-back tilt) */\r\n beta: number | null;\r\n /** Rotation around Y-axis (-90 to 90 degrees, left-to-right tilt) */\r\n gamma: number | null;\r\n /** True if using magnetometer (compass) for absolute orientation */\r\n absolute: boolean;\r\n }\r\n\n /**\r\n * Sensor snapshot for the device running the scene. Both fields read `null`\r\n * when the corresponding sensor is unavailable or has not delivered a sample yet.\r\n */\r\n interface DeviceSensorState {\r\n /** Motion data (acceleration, rotation rate, sampling interval). `null` if no motion sensor is available. */\r\n motion: DeviceMotionData | null;\r\n /** Orientation data (alpha/beta/gamma in degrees). `null` if no orientation sensor is available. */\r\n orientation: DeviceOrientationData | null;\r\n }\r\n\n /**\r\n * External device state (includes id and name)\r\n */\r\n interface DeviceState extends DeviceSensorState {\r\n /** Unique device identifier */\r\n id: string;\r\n /** User-friendly device name */\r\n name: string;\r\n /** Device camera video (null if not available) */\r\n video: VideoAPI | null;\r\n /** Device audio stream (null if not available) */\r\n audio: AudioStreamAPI | null;\r\n }\r\n\n /**\r\n * 52 ARKit-compatible face blendshape coefficients (each in 0..1) derived from\r\n * MediaPipe FaceLandmarker. All fields are `0` unless emotion detection is\r\n * enabled. Available on each `FaceData.blendshapes`.\r\n */\r\n interface FaceBlendshapes {\r\n /** Coefficient (0..1) for the inner brow of the left eye pulling down. */\r\n browDownLeft: number;\r\n /** Coefficient (0..1) for the inner brow of the right eye pulling down. */\r\n browDownRight: number;\r\n /** Coefficient (0..1) for both inner brows pulling up. */\r\n browInnerUp: number;\r\n /** Coefficient (0..1) for the outer left brow pulling up. */\r\n browOuterUpLeft: number;\r\n /** Coefficient (0..1) for the outer right brow pulling up. */\r\n browOuterUpRight: number;\r\n /** Coefficient (0..1) for puffed cheeks. */\r\n cheekPuff: number;\r\n /** Coefficient (0..1) for the left cheek squinting. */\r\n cheekSquintLeft: number;\r\n /** Coefficient (0..1) for the right cheek squinting. */\r\n cheekSquintRight: number;\r\n /** Coefficient (0..1) for the left eyelid closing. */\r\n eyeBlinkLeft: number;\r\n /** Coefficient (0..1) for the right eyelid closing. */\r\n eyeBlinkRight: number;\r\n /** Coefficient (0..1) for the left eye looking down. */\r\n eyeLookDownLeft: number;\r\n /** Coefficient (0..1) for the right eye looking down. */\r\n eyeLookDownRight: number;\r\n /** Coefficient (0..1) for the left eye looking inward (toward the nose). */\r\n eyeLookInLeft: number;\r\n /** Coefficient (0..1) for the right eye looking inward. */\r\n eyeLookInRight: number;\r\n /** Coefficient (0..1) for the left eye looking outward (away from the nose). */\r\n eyeLookOutLeft: number;\r\n /** Coefficient (0..1) for the right eye looking outward. */\r\n eyeLookOutRight: number;\r\n /** Coefficient (0..1) for the left eye looking up. */\r\n eyeLookUpLeft: number;\r\n /** Coefficient (0..1) for the right eye looking up. */\r\n eyeLookUpRight: number;\r\n /** Coefficient (0..1) for the left eye squinting. */\r\n eyeSquintLeft: number;\r\n /** Coefficient (0..1) for the right eye squinting. */\r\n eyeSquintRight: number;\r\n /** Coefficient (0..1) for the left eye opening wide. */\r\n eyeWideLeft: number;\r\n /** Coefficient (0..1) for the right eye opening wide. */\r\n eyeWideRight: number;\r\n /** Coefficient (0..1) for the jaw moving forward. */\r\n jawForward: number;\r\n /** Coefficient (0..1) for the jaw moving left. */\r\n jawLeft: number;\r\n /** Coefficient (0..1) for the jaw opening (mouth open). */\r\n jawOpen: number;\r\n /** Coefficient (0..1) for the jaw moving right. */\r\n jawRight: number;\r\n /** Coefficient (0..1) for the mouth closing tightly. */\r\n mouthClose: number;\r\n /** Coefficient (0..1) for a dimple appearing on the left side. */\r\n mouthDimpleLeft: number;\r\n /** Coefficient (0..1) for a dimple appearing on the right side. */\r\n mouthDimpleRight: number;\r\n /** Coefficient (0..1) for the left mouth corner pulling down (frown). */\r\n mouthFrownLeft: number;\r\n /** Coefficient (0..1) for the right mouth corner pulling down (frown). */\r\n mouthFrownRight: number;\r\n /** Coefficient (0..1) for funneling the lips outward. */\r\n mouthFunnel: number;\r\n /** Coefficient (0..1) for the mouth shifting left. */\r\n mouthLeft: number;\r\n /** Coefficient (0..1) for the lower lip on the left pulling down. */\r\n mouthLowerDownLeft: number;\r\n /** Coefficient (0..1) for the lower lip on the right pulling down. */\r\n mouthLowerDownRight: number;\r\n /** Coefficient (0..1) for the left lip pressing inward. */\r\n mouthPressLeft: number;\r\n /** Coefficient (0..1) for the right lip pressing inward. */\r\n mouthPressRight: number;\r\n /** Coefficient (0..1) for puckered lips. */\r\n mouthPucker: number;\r\n /** Coefficient (0..1) for the mouth shifting right. */\r\n mouthRight: number;\r\n /** Coefficient (0..1) for the lower lip rolling inward. */\r\n mouthRollLower: number;\r\n /** Coefficient (0..1) for the upper lip rolling inward. */\r\n mouthRollUpper: number;\r\n /** Coefficient (0..1) for the lower lip shrugging. */\r\n mouthShrugLower: number;\r\n /** Coefficient (0..1) for the upper lip shrugging. */\r\n mouthShrugUpper: number;\r\n /** Coefficient (0..1) for the left mouth corner pulling up (smile). */\r\n mouthSmileLeft: number;\r\n /** Coefficient (0..1) for the right mouth corner pulling up (smile). */\r\n mouthSmileRight: number;\r\n /** Coefficient (0..1) for the left mouth corner stretching outward. */\r\n mouthStretchLeft: number;\r\n /** Coefficient (0..1) for the right mouth corner stretching outward. */\r\n mouthStretchRight: number;\r\n /** Coefficient (0..1) for the upper lip on the left raising. */\r\n mouthUpperUpLeft: number;\r\n /** Coefficient (0..1) for the upper lip on the right raising. */\r\n mouthUpperUpRight: number;\r\n /** Coefficient (0..1) for the left side of the nose sneering. */\r\n noseSneerLeft: number;\r\n /** Coefficient (0..1) for the right side of the nose sneering. */\r\n noseSneerRight: number;\r\n /** Coefficient (0..1) for the tongue protruding. */\r\n tongueOut: number;\r\n }\r\n\n /**\r\n * One detected face produced by the video CV pipeline. Each field is\r\n * populated only by its source model; fields whose source model is not\r\n * enabled read as `null` so the absence is loud rather than silent. Enable\r\n * the relevant `enable*` verb on `viji.video.cv` to populate each group:\r\n *\r\n * - `bounds`, `center`, `confidence`: populated by `enableFaceDetection(true)`.\r\n * - `landmarks`: populated by `enableFaceMesh(true)` (empty array otherwise).\r\n * - `headPose`: populated by `enableFaceMesh(true)`.\r\n * - `blendshapes`, `expressions`: populated by `enableEmotionDetection(true)`.\r\n *\r\n * If a field is `null`, call the corresponding `enable*` verb on\r\n * `viji.video.cv` to populate it. Each active CV feature consumes its own\r\n * WebGL context for MediaPipe; enabling many at once on lower-end hardware\r\n * can hit context limits.\r\n */\r\n interface FaceData {\r\n /** Index-based face identifier (`0`, `1`, …). Stable within a single frame, may change between frames. */\r\n id: number;\r\n /** Bounding box, all components normalized to 0..1 of the source frame. `null` unless face detection is enabled. */\r\n bounds: {\r\n /** Left edge of the face bounding box, normalized 0..1. */\r\n x: number;\r\n /** Top edge of the face bounding box, normalized 0..1. */\r\n y: number;\r\n /** Width of the face bounding box, normalized 0..1. */\r\n width: number;\r\n /** Height of the face bounding box, normalized 0..1. */\r\n height: number;\r\n } | null;\r\n /** Center of the bounding box, normalized 0..1. `null` unless face detection is enabled. */\r\n center: {\r\n /** Horizontal center of the face, normalized 0..1. */\r\n x: number;\r\n /** Vertical center of the face, normalized 0..1. */\r\n y: number;\r\n } | null;\r\n /** Detection confidence in 0..1. `null` unless face detection is enabled. */\r\n confidence: number | null;\r\n /** 468 normalized face mesh landmarks when face mesh is enabled; empty array otherwise. */\r\n landmarks: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n /** Optional depth (relative). */\r\n z?: number;\r\n }[];\r\n /** Estimated head rotation in degrees. `null` unless face mesh is enabled. */\r\n headPose: {\r\n /** Up/down rotation in degrees (-90..90). Positive = head looking up, negative = looking down. */\r\n pitch: number;\r\n /** Left/right rotation in degrees (-90..90). Positive = head turned to the subject's right, negative = to the left. */\r\n yaw: number;\r\n /** Tilt rotation in degrees (-180..180). Positive = head tilted to the subject's right (right ear toward right shoulder). */\r\n roll: number;\r\n } | null;\r\n /** Seven expression confidence scores in 0..1. `null` unless emotion detection is enabled. */\r\n expressions: {\r\n /** Confidence (0..1) of a neutral expression. */\r\n neutral: number;\r\n /** Confidence (0..1) of a happy / smiling expression. */\r\n happy: number;\r\n /** Confidence (0..1) of a sad expression. */\r\n sad: number;\r\n /** Confidence (0..1) of an angry expression. */\r\n angry: number;\r\n /** Confidence (0..1) of a surprised expression. */\r\n surprised: number;\r\n /** Confidence (0..1) of a disgusted expression. */\r\n disgusted: number;\r\n /** Confidence (0..1) of a fearful expression. */\r\n fearful: number;\r\n } | null;\r\n /** 52 ARKit-compatible facial muscle coefficients. `null` unless emotion detection is enabled. */\r\n blendshapes: FaceBlendshapes | null;\r\n }\r\n\n /**\r\n * Render-loop pacing mode. `'full'` runs `render()` on every animation frame,\r\n * `'half'` every 2nd frame, `'quarter'` every 4th, `'eighth'` every 8th. Lower\r\n * rates save CPU/GPU on lower-cost scenes. The resulting FPS is the screen\r\n * refresh rate divided by the mode divisor (1/2/4/8), so on a 60 Hz display:\r\n * `'full'` ~60, `'half'` ~30, `'quarter'` ~15, `'eighth'` ~7.5.\r\n */\r\n type FrameRateMode = 'full' | 'half' | 'quarter' | 'eighth';\r\n\n /**\r\n * One named frequency band reported by the audio analyzer\r\n * (e.g., `{ name: 'low', min: 20, max: 120 }`). Frequencies are in Hertz.\r\n */\r\n interface FrequencyBand {\r\n /** Human-readable band name (e.g., `'low'`, `'mid'`, `'high'`). */\r\n name: string;\r\n /** Lower edge of the band in Hertz (inclusive). */\r\n min: number;\r\n /** Upper edge of the band in Hertz (exclusive). */\r\n max: number;\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.gradient()`. Defines the ramp editor's\r\n * stop bounds, transparency mode, label and UI grouping/visibility.\r\n */\r\n interface GradientConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const ramp = viji.gradient(...)` → `ramp`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Minimum number of stops the editor allows. Integer in `2..32`. Default: `2`. */\r\n minStops?: number;\r\n /** Maximum number of stops the editor allows. Integer in `2..32`; sizes the shader uniform arrays. Default: `8`. */\r\n maxStops?: number;\r\n /** Display name shown next to the ramp in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n /**\r\n * Enable per-stop transparency. When `true` every stop color is `#rrggbbaa`\r\n * (opaque inputs padded `ff`) and the shader sampler returns a `vec4`. When\r\n * `false` (default) stops are `#rrggbb` and alpha-bearing stop colors are rejected.\r\n */\r\n alpha?: boolean;\r\n }\r\n\n /**\r\n * Stop list accepted by `viji.gradient()` and `setParameter()`. Any order;\r\n * normalized to a sorted, canonical {@link GradientValue}.\r\n */\r\n type GradientInput = ReadonlyArray<GradientStopInput>;\r\n\n /**\r\n * Reactive object returned by `viji.gradient()`. `value` is the live, frozen,\r\n * sorted stop list; `at(t)` samples the ramp with CSS `linear-gradient`\r\n * semantics (premultiplied sRGB between stops, hard edges on duplicate\r\n * positions) and returns a canonical hex string in the same width as the stops.\r\n */\r\n interface GradientParameter {\r\n /** Current stops, frozen and sorted ascending by position. Updates in real-time. */\r\n value: GradientValue;\r\n /**\r\n * Sample the ramp at `t` (clamped to `0..1`). Returns canonical hex in the\r\n * gradient's width. The shader renderer exposes the same function as\r\n * `<name>(float t)` in GLSL.\r\n */\r\n at(t: number): string;\r\n /** Display name shown next to the ramp in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * One stop of a gradient value. `color` is canonical lowercase hex in the\r\n * gradient's mode (`#rrggbb`, or `#rrggbbaa` when declared with `alpha: true`).\r\n */\r\n interface GradientStop {\r\n /** Canonical hex color of this stop. */\r\n color: string;\r\n /** Position along the ramp in `0..1`. */\r\n position: number;\r\n }\r\n\n /**\r\n * One artist- or host-supplied gradient stop. `color` accepts every form a\r\n * color parameter accepts, normalized per the gradient's `alpha` mode.\r\n */\r\n interface GradientStopInput {\r\n /** Any accepted color form (hex, CSS functions, RGB / HSB objects). */\r\n color: ColorInput;\r\n /** Position along the ramp in `0..1`. */\r\n position: number;\r\n }\r\n\n /**\r\n * Value of a gradient parameter: a frozen list of stops sorted ascending by\r\n * position. Duplicate positions are allowed and form a hard edge. The length is\r\n * within the parameter's `minStops..maxStops`. No wrapper: geometry (linear,\r\n * radial, angle) is the scene's concern.\r\n */\r\n type GradientValue = readonly GradientStop[];\r\n\n /**\r\n * One detected hand produced by the video CV pipeline. Carries 21 landmarks,\r\n * a palm shortcut, and ML-classified gesture confidence scores. Up to two\r\n * hands appear in `VideoAPI.hands` simultaneously.\r\n */\r\n interface HandData {\r\n /** Index-based hand identifier (`0` or `1`). */\r\n id: number;\r\n /** Which hand. Always lowercase. */\r\n handedness: 'left' | 'right';\r\n /** Detection confidence in 0..1. */\r\n confidence: number;\r\n /** Bounding box, all components normalized to 0..1 of the source frame. */\r\n bounds: {\r\n /** Left edge of the hand bounding box, normalized 0..1. */\r\n x: number;\r\n /** Top edge of the hand bounding box, normalized 0..1. */\r\n y: number;\r\n /** Width of the hand bounding box, normalized 0..1. */\r\n width: number;\r\n /** Height of the hand bounding box, normalized 0..1. */\r\n height: number;\r\n };\r\n /** 21 MediaPipe hand landmarks, normalized 0..1. */\r\n landmarks: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n /** Depth (relative). */\r\n z: number;\r\n }[];\r\n /** Palm center, equivalent to `landmarks[9]` (middle-finger MCP). */\r\n palm: {\r\n /** Palm horizontal coordinate, normalized 0..1. */\r\n x: number;\r\n /** Palm vertical coordinate, normalized 0..1. */\r\n y: number;\r\n /** Palm depth (relative). */\r\n z: number;\r\n };\r\n /**\r\n * ML-classified gesture confidences from MediaPipe GestureRecognizer.\r\n * Each value is in 0..1; multiple gestures can fire simultaneously.\r\n */\r\n gestures: {\r\n /** Confidence (0..1) of a closed-fist gesture. */\r\n fist: number;\r\n /** Confidence (0..1) of an open-palm gesture. */\r\n openPalm: number;\r\n /** Confidence (0..1) of a peace / victory sign. */\r\n peace: number;\r\n /** Confidence (0..1) of a thumbs-up gesture. */\r\n thumbsUp: number;\r\n /** Confidence (0..1) of a thumbs-down gesture. */\r\n thumbsDown: number;\r\n /** Confidence (0..1) of a pointing-up gesture. */\r\n pointing: number;\r\n /** Confidence (0..1) of the ASL \"I love you\" sign. */\r\n iLoveYou: number;\r\n };\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.image()`. The host renders an upload\r\n * field; the user-supplied image becomes available as an `ImageBitmap` (Native)\r\n * or a P5 image wrapper (P5 renderer).\r\n */\r\n interface ImageConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Display name shown next to the upload field in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n }\r\n\n /**\r\n * Reactive object returned by `viji.image()`. `value` is `null` until the user\r\n * uploads an image; in P5 scenes a `.p5` accessor is also added at runtime so\r\n * the image works directly with `image()`, `texture()`, etc.\r\n */\r\n interface ImageParameter {\r\n /**\r\n * Uploaded image as an `ImageBitmap`, or `null` until the user provides one.\r\n * Read it where you use it (inside `render()`): when the host replaces or\r\n * clears the image, the previous bitmap is closed, so a reference kept from\r\n * an earlier frame becomes unusable.\r\n */\r\n value: ImageBitmap | null;\r\n /** P5-compatible image wrapper. Only available in the P5 renderer; added at runtime by the P5 adapter. */\r\n readonly p5?: any;\r\n /** Display name shown next to the upload field in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Keyboard input state for the current frame: per-key press / hold / release\r\n * queries (case-insensitive), the live set of held keys, modifier flags, and\r\n * a Shadertoy-compatible texture buffer for shader-side keyboard reads.\r\n *\r\n * Key names follow the browser's `event.key` standard\r\n * (`'a'`, `'arrowup'`, `' '` for Space, `'enter'`, `'escape'`, etc.).\r\n */\r\n interface KeyboardAPI {\r\n /** Returns `true` while the named key is held. Case-insensitive. */\r\n isPressed(key: string): boolean;\r\n /** Returns `true` for exactly one frame on the rising edge of the named key (no key-repeat). Case-insensitive. */\r\n wasPressed(key: string): boolean;\r\n /** Returns `true` for exactly one frame on the falling edge of the named key. Case-insensitive. */\r\n wasReleased(key: string): boolean;\r\n /** Set of all currently held keys, lowercased. Persists across frames. */\r\n activeKeys: Set<string>;\r\n /** Set of keys whose key-down fired this frame, lowercased. Cleared each frame. */\r\n pressedThisFrame: Set<string>;\r\n /** Set of keys whose key-up fired this frame, lowercased. Cleared each frame. */\r\n releasedThisFrame: Set<string>;\r\n /** Most recently pressed key in its original case (e.g., `'A'` when Shift is held). */\r\n lastKeyPressed: string;\r\n /** Most recently released key in its original case. */\r\n lastKeyReleased: string;\r\n /** `true` while the Shift key is held. */\r\n shift: boolean;\r\n /** `true` while the Ctrl key is held. */\r\n ctrl: boolean;\r\n /** `true` while the Alt (or Option) key is held. */\r\n alt: boolean;\r\n /** `true` while the Meta (Windows / Cmd) key is held. */\r\n meta: boolean;\r\n /**\r\n * Shadertoy-compatible 256×3 keyboard texture (256 keycodes × 3 rows).\r\n * Row 0: held state (1 / 0). Row 1: pressed-this-frame (1 / 0). Row 2: per-key toggle.\r\n * Bound to a uniform sampler in shader scenes; rarely needed in JS.\r\n */\r\n textureData: Uint8Array;\r\n }\r\n\n /**\r\n * Mouse input state for the current frame: position, individual button states,\r\n * per-frame movement, scroll wheel, and frame-based press / release events.\r\n * Coordinates are in canvas-space pixels with `(0, 0)` at the top-left corner.\r\n *\r\n * For interactions that should also work on touch devices, prefer `viji.pointer`.\r\n */\r\n interface MouseAPI {\r\n /** Canvas-space X position in pixels. */\r\n x: number;\r\n /** Canvas-space Y position in pixels. */\r\n y: number;\r\n /** `true` when the cursor is currently over the canvas. */\r\n isInCanvas: boolean;\r\n /** `true` if any mouse button is currently held. */\r\n isPressed: boolean;\r\n /** `true` while the left mouse button is held. */\r\n leftButton: boolean;\r\n /** `true` while the right mouse button is held. The browser context menu is suppressed on the canvas. */\r\n rightButton: boolean;\r\n /** `true` while the middle (wheel) mouse button is held. */\r\n middleButton: boolean;\r\n /** Horizontal movement this frame in pixels. Resets to `0` each frame. */\r\n deltaX: number;\r\n /** Vertical movement this frame in pixels. Resets to `0` each frame. */\r\n deltaY: number;\r\n /** Vertical scroll accumulated this frame (alias of `wheelY`). Resets to `0` each frame. */\r\n wheelDelta: number;\r\n /** Horizontal scroll accumulated this frame (e.g., trackpad gestures, tilt-wheel mice). Resets to `0` each frame. */\r\n wheelX: number;\r\n /** Vertical scroll accumulated this frame. Resets to `0` each frame. */\r\n wheelY: number;\r\n /** `true` for exactly one frame when any button is first pressed, then auto-resets. */\r\n wasPressed: boolean;\r\n /** `true` for exactly one frame when any button is released, then auto-resets. */\r\n wasReleased: boolean;\r\n /** `true` if the mouse moved this frame (any non-zero `deltaX` / `deltaY`). Resets each frame. */\r\n wasMoved: boolean;\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.number()`. Defines the bounds, step,\r\n * label, and UI grouping/visibility for a precise numeric input.\r\n */\r\n interface NumberConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Inclusive minimum value. Default: `0`. */\r\n min?: number;\r\n /** Inclusive maximum value. Default: `100`. */\r\n max?: number;\r\n /**\r\n * Increment between values. When omitted, auto-derives from `min`/`max` as\r\n * the largest power of 10 giving ~100 positions across the range (e.g.,\r\n * range `0..1` → `0.01`, range `0..100` → `1`, range `0.1..5` → `0.01`).\r\n * Specify explicitly for integer counts (`step: 1`) or fine precision\r\n * (`step: 0.001`).\r\n */\r\n step?: number;\r\n /** Display name shown next to the input in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n }\r\n\n /**\r\n * Reactive object returned by `viji.number()`. Like `SliderParameter` but the\r\n * host UI renders a precise numeric input rather than a draggable slider.\r\n */\r\n interface NumberParameter {\r\n /** Current numeric value in the configured `min..max` range. Updates in real-time. */\r\n value: number;\r\n /** Inclusive minimum value. */\r\n min: number;\r\n /** Inclusive maximum value. */\r\n max: number;\r\n /** Increment between values. */\r\n step: number;\r\n /** Display name shown next to the input in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Visibility category for a parameter. The host hides parameters whose category\r\n * is not currently available (e.g., `'audio'` controls hide when no audio\r\n * source is connected). `'general'` parameters are always visible.\r\n */\r\n type ParameterCategory = 'audio' | 'video' | 'interaction' | 'general';\r\n\n /**\r\n * Unified pointer that abstracts mouse and primary touch into a single input\r\n * stream. Recommended for click / drag / position-tracking interactions that\r\n * should work identically on desktop and mobile.\r\n *\r\n * Use `viji.mouse` for mouse-specific features (right click, middle click,\r\n * scroll wheel); use `viji.touches` for multi-touch, pressure, or radius.\r\n */\r\n interface PointerAPI {\r\n /** Canvas-space X position in pixels. */\r\n x: number;\r\n /** Canvas-space Y position in pixels. */\r\n y: number;\r\n /** Horizontal movement since the last frame in pixels. */\r\n deltaX: number;\r\n /** Vertical movement since the last frame in pixels. */\r\n deltaY: number;\r\n /** `true` while the pointer is \"down\": left mouse button held, or a touch active. */\r\n isDown: boolean;\r\n /** `true` for exactly one frame when the pointer becomes down, then auto-resets. */\r\n wasPressed: boolean;\r\n /** `true` for exactly one frame when the pointer is released, then auto-resets. */\r\n wasReleased: boolean;\r\n /** `true` while the pointer is within the canvas bounds. */\r\n isInCanvas: boolean;\r\n /** Currently active input source: `'touch'` when at least one touch is active, otherwise `'mouse'` (or `'none'` when the cursor is off-canvas). */\r\n type: 'mouse' | 'touch' | 'none';\r\n }\r\n\n /**\r\n * Detected body pose from MediaPipe BlazePose. `landmarks` contains 33 points;\r\n * the `face` / `torso` / `leftArm` / `rightArm` / `leftLeg` / `rightLeg` arrays\r\n * are pre-grouped slices for convenience.\r\n */\r\n interface PoseData {\r\n /** Average landmark visibility in 0..1. */\r\n confidence: number;\r\n /** 33 BlazePose landmarks, normalized 0..1. Each carries a per-point `visibility` score. */\r\n landmarks: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n /** Depth (relative). */\r\n z: number;\r\n /** Visibility / confidence of this individual landmark in 0..1. */\r\n visibility: number;\r\n }[];\r\n /** Face landmarks (BlazePose indices 0..10). Coordinates normalized 0..1. */\r\n face: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n }[];\r\n /** Torso landmarks (BlazePose indices 11, 12, 23, 24). Coordinates normalized 0..1. */\r\n torso: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n }[];\r\n /** Left-arm landmarks (BlazePose indices 11, 13, 15). Coordinates normalized 0..1. */\r\n leftArm: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n }[];\r\n /** Right-arm landmarks (BlazePose indices 12, 14, 16). Coordinates normalized 0..1. */\r\n rightArm: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n }[];\r\n /** Left-leg landmarks (BlazePose indices 23, 25, 27, 29, 31). Coordinates normalized 0..1. */\r\n leftLeg: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n }[];\r\n /** Right-leg landmarks (BlazePose indices 24, 26, 28, 30, 32). Coordinates normalized 0..1. */\r\n rightLeg: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n }[];\r\n }\r\n\n /**\r\n * Discrete pixel dimensions for a canvas, frame capture, or render target.\r\n */\r\n type Resolution = {\r\n /** Width in pixels (positive integer). */\r\n width: number;\r\n /** Height in pixels (positive integer). */\r\n height: number;\r\n };\r\n\n /**\r\n * Per-pixel person/background segmentation mask. Mask dimensions reflect the\r\n * ML model's output and may differ from the source video frame.\r\n */\r\n interface SegmentationData {\r\n /** Flat per-pixel mask: each byte is `0` (background) or `1` (person). Length = `width * height`. */\r\n mask: Uint8Array;\r\n /** Mask width in pixels. */\r\n width: number;\r\n /** Mask height in pixels. */\r\n height: number;\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.select()`. The host renders the choices\r\n * as a dropdown or segmented control.\r\n */\r\n interface SelectConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Available choices. The element type (`string` or `number`) becomes the parameter's value type. Required. */\r\n options: string[] | number[];\r\n /** Display name shown next to the dropdown in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n }\r\n\n /**\r\n * Reactive object returned by `viji.select()`. `value` matches the element type\r\n * of the configured `options` array (`string` or `number`).\r\n */\r\n interface SelectParameter {\r\n /** Currently selected option. Updates in real-time when the user changes the selection. */\r\n value: string | number;\r\n /** The full list of choices originally configured. */\r\n options: string[] | number[];\r\n /** Display name shown next to the dropdown in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.slider()`. Defines the slider's bounds,\r\n * increment, label, and UI grouping/visibility.\r\n */\r\n interface SliderConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Inclusive minimum value of the slider. Default: `0`. */\r\n min?: number;\r\n /** Inclusive maximum value of the slider. Default: `100`. */\r\n max?: number;\r\n /**\r\n * Increment between values. When omitted, auto-derives from `min`/`max` as\r\n * the largest power of 10 giving ~100 positions across the range (e.g.,\r\n * range `0..1` → `0.01`, range `0..100` → `1`, range `0.1..5` → `0.01`,\r\n * range `0..1000` → `10`). Specify explicitly for integer counts\r\n * (`step: 1` on a range of `3..30`) or fine precision (`step: 0.001`).\r\n */\r\n step?: number;\r\n /** Display name shown next to the control in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n }\r\n\n /**\r\n * Reactive object returned by `viji.slider()`. `value` updates in real-time as\r\n * the user drags the control; the remaining fields mirror the configuration.\r\n */\r\n interface SliderParameter {\r\n /** Current slider value in the configured `min..max` range. Updates in real-time. */\r\n value: number;\r\n /** Inclusive minimum value of the slider. */\r\n min: number;\r\n /** Inclusive maximum value of the slider. */\r\n max: number;\r\n /** Increment between values. */\r\n step: number;\r\n /** Display name shown next to the control in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.text()`. The host renders a single-line\r\n * text input field.\r\n */\r\n interface TextConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Display name shown next to the text field in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n /** Maximum character count enforced by the host UI. Default: `1000`. */\r\n maxLength?: number;\r\n }\r\n\n /**\r\n * Reactive object returned by `viji.text()`. `value` updates as the user types\r\n * and is enforced to be no longer than `maxLength` by the host UI.\r\n */\r\n interface TextParameter {\r\n /** Current text content. Updates in real-time as the user types. */\r\n value: string;\r\n /** Maximum character count enforced by the host UI. */\r\n maxLength?: number;\r\n /** Display name shown next to the input in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.toggle()`. Defines the on/off switch's\r\n * label and UI grouping/visibility.\r\n */\r\n interface ToggleConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Display name shown next to the switch in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n }\r\n\n /**\r\n * Reactive object returned by `viji.toggle()`. `value` flips between `true`\r\n * and `false` as the user interacts with the switch.\r\n */\r\n interface ToggleParameter {\r\n /** Current state of the switch. Updates in real-time when the user toggles it. */\r\n value: boolean;\r\n /** Display name shown next to the switch in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Multi-touch input state. Lists all active touches, plus per-frame\r\n * `started` / `moved` / `ended` arrays for frame-based gesture handling.\r\n *\r\n * For single-point interactions that should also work with a mouse, prefer\r\n * `viji.pointer`. It switches automatically between mouse and primary touch.\r\n */\r\n interface TouchAPI {\r\n /** All currently active touch points. Order is stable but not ordered by id. */\r\n points: TouchPoint[];\r\n /** Number of currently active touches (equivalent to `points.length`). */\r\n count: number;\r\n /** Touches that started this frame (also visible in `points`). Cleared each frame. */\r\n started: TouchPoint[];\r\n /** Touches that moved this frame. Cleared each frame. */\r\n moved: TouchPoint[];\r\n /** Touches that ended this frame. Each entry has `isEnding === true`. Cleared each frame. */\r\n ended: TouchPoint[];\r\n /** Convenience shortcut to `points[0]`, or `null` when no touches are active. */\r\n primary: TouchPoint | null;\r\n }\r\n\n /**\r\n * One active touch contact reported by `TouchAPI`. Position, pressure, radius,\r\n * rotation, per-frame movement, velocity, and lifecycle flags. Coordinates are\r\n * in canvas-space pixels.\r\n *\r\n * Some fields (notably `pressure` / `force`, `radiusX` / `radiusY`,\r\n * `rotationAngle`) are passed through from the device; values vary by\r\n * platform; many devices report `0` when unsupported.\r\n */\r\n interface TouchPoint {\r\n /** Stable touch identifier across frames for the duration of this contact. */\r\n id: number;\r\n /** Canvas-space X position in pixels. */\r\n x: number;\r\n /** Canvas-space Y position in pixels. */\r\n y: number;\r\n /** Touch pressure in 0..1 (device-dependent; often `0` on devices without force support). */\r\n pressure: number;\r\n /** Contact radius, `Math.max(radiusX, radiusY)` in pixels. */\r\n radius: number;\r\n /** Horizontal contact radius in pixels (raw device value). */\r\n radiusX: number;\r\n /** Vertical contact radius in pixels (raw device value). */\r\n radiusY: number;\r\n /** Contact area rotation in radians (raw device value). */\r\n rotationAngle: number;\r\n /** Touch force in 0..1; alias of `pressure`. */\r\n force: number;\r\n /** `true` while the touch position is within the canvas bounds. */\r\n isInCanvas: boolean;\r\n /** Horizontal movement since the last frame in pixels. */\r\n deltaX: number;\r\n /** Vertical movement since the last frame in pixels. */\r\n deltaY: number;\r\n /** Movement velocity in pixels per second, computed by Viji. */\r\n velocity: {\r\n /** Horizontal velocity component in pixels per second. */\r\n x: number;\r\n /** Vertical velocity component in pixels per second. */\r\n y: number;\r\n };\r\n /** `true` for exactly one frame when this touch starts, then auto-resets. */\r\n isNew: boolean;\r\n /** `true` while the touch is ongoing. */\r\n isActive: boolean;\r\n /** `true` for exactly one frame when this touch ends, then auto-resets. */\r\n isEnding: boolean;\r\n }\r\n\n const VERSION = \"0.18.0\";\r\n\n /**\r\n * Real-time video API: drawable frame, dimensions, and the source-side\r\n * properties of the connected stream. All computer-vision data and controls\r\n * (faces, hands, pose, segmentation, the analysed frame, and feature\r\n * enable/disable verbs) live on `viji.video.cv`.\r\n *\r\n * When `isConnected` is `false`, `currentFrame` is `null`, all dimensions are\r\n * `0`, and every member of `cv` holds its empty default.\r\n */\r\n interface VideoAPI {\r\n /** `true` when a video stream is connected. When `false`, all other fields hold their default empty values. */\r\n isConnected: boolean;\r\n /** Latest video frame, drawable directly with `ctx.drawImage()`. `null` when disconnected. */\r\n currentFrame: OffscreenCanvas | ImageBitmap | null;\r\n /** Source video frame width in pixels. `0` when disconnected. */\r\n frameWidth: number;\r\n /** Source video frame height in pixels. `0` when disconnected. */\r\n frameHeight: number;\r\n /** Source video frame rate in Hz (frames per second). `0` when disconnected. */\r\n frameRate: number;\r\n /**\r\n * Returns the latest frame as raw RGBA `ImageData` for per-pixel CPU analysis,\r\n * or `null` when disconnected. Slow compared to drawing `currentFrame` directly;\r\n * use only when you need to read individual pixel values.\r\n */\r\n getFrameData: () => ImageData | null;\r\n /**\r\n * Computer-vision surface for this video stream. Holds both the data\r\n * outputs (`faces`, `hands`, `pose`, `segmentation`, `analysedFrame`,\r\n * `getAnalysedFrameData`) and the verbs that activate them\r\n * (`enable*`/`disable*`/`getActiveFeatures`/`isProcessing`).\r\n *\r\n * Multiple features can be active simultaneously, but each adds CPU/GPU\r\n * and WebGL-context cost; toggle only what you need.\r\n *\r\n * `analysedFrame` and the result fields refresh together once per host\r\n * frame as an atomic snapshot: within a single `render()` call they are\r\n * always paired.\r\n */\r\n cv: VideoCVAPI;\r\n }\r\n\n /**\r\n * Computer-vision surface attached to a `VideoAPI`. Combines paired CV data\r\n * outputs (the analysed frame and its detection / segmentation results) with\r\n * the verbs that activate the underlying MediaPipe pipelines.\r\n *\r\n * Available on the main video stream (`viji.video.cv`) and on additional\r\n * streams (`viji.videoStreams[i].cv`) — same surface, same verbs, activated\r\n * per stream. `analysedFrame` is populated on the MAIN stream only; on other\r\n * streams it stays `null` (use `currentFrame`). Device videos\r\n * (`viji.devices[i].video.cv`) do not run CV yet; their `cv` surface exists\r\n * for API consistency with the data fields at their empty defaults.\r\n */\r\n interface VideoCVAPI {\r\n /**\r\n * The exact video frame that produced the current `faces` / `hands` /\r\n * `pose` / `segmentation` results: the frame MediaPipe actually analysed.\r\n *\r\n * Choose between `analysedFrame` and `viji.video.currentFrame` by asking\r\n * whether the effect reads pixels from the displayed frame at CV-derived\r\n * positions. Reach for `analysedFrame` when the answer is yes\r\n * (compositing the segmentation mask onto the body, sampling skin tone\r\n * under a face landmark, warping the face along its mesh, texture-mapped\r\n * face filters): pairing the displayed frame with the CV results is\r\n * required for those effects. Stay on `currentFrame` when the answer is\r\n * no (drawing landmark dots, particles, debug overlays, geometry driven\r\n * by CV positions): `analysedFrame` only refreshes when MediaPipe\r\n * completes an inference, which is not every frame, so reaching for it\r\n * without a reason makes the displayed video stutter or hold between\r\n * inferences.\r\n *\r\n * Pairing guarantee: within a single `render()` call, `analysedFrame`\r\n * is paired with the values of `faces`, `hands`, `pose`, `segmentation`\r\n * read in the same call.\r\n *\r\n * `null` until the first CV inference completes after a feature is\r\n * enabled, after the video disconnects, or after a CV-feature toggle\r\n * clears state. A common pattern is\r\n * `viji.video.cv.analysedFrame ?? viji.video.currentFrame` to fall back\r\n * to the live feed during the brief startup window; expect a small\r\n * visual hitch when the source switches as the first inference lands.\r\n *\r\n * Read-only: this `OffscreenCanvas` is owned by the engine. Do not\r\n * mutate it (no `getContext`-and-paint, no `transferToImageBitmap`).\r\n * Drawing it as a source (`ctx.drawImage`, `gl.texImage2D`,\r\n * `p5.image(...)`) is the only supported usage.\r\n */\r\n analysedFrame: OffscreenCanvas | null;\r\n /**\r\n * Returns `analysedFrame` as raw RGBA `ImageData` for per-pixel CPU\r\n * analysis, or `null` when no CV result has landed yet (or the stream is\r\n * disconnected). Cached: re-extracted only when a new CV result arrives,\r\n * so multiple readers within a render share one allocation. Slow\r\n * compared to drawing `analysedFrame` directly. Use only when you need\r\n * pixel values aligned with CV landmark positions (e.g. sampling skin\r\n * colour at a face landmark).\r\n */\r\n getAnalysedFrameData: () => ImageData | null;\r\n /** Detected faces (empty array when face detection is off or no faces are visible). */\r\n faces: FaceData[];\r\n /** Detected hands (up to 2; empty array when hand tracking is off or no hands are visible). */\r\n hands: HandData[];\r\n /** Detected body pose, or `null` when pose detection is off or no pose is visible. */\r\n pose: PoseData | null;\r\n /** Body segmentation mask, or `null` when segmentation is off. */\r\n segmentation: SegmentationData | null;\r\n /**\r\n * Toggle face detection. Populates `face.bounds`, `face.center`,\r\n * `face.confidence` on each detected face. Independent of face mesh and\r\n * emotion detection.\r\n *\r\n * Safe to call from module scope as well as from inside `render()`. The\r\n * verb is idempotent and reference-counted; per-frame calls inside\r\n * `render()` (the canonical toggle-gated pattern) are cheap.\r\n *\r\n * @returns Resolves once the underlying pipeline has finished switching.\r\n */\r\n enableFaceDetection(enabled: boolean): Promise<void>;\r\n /**\r\n * Toggle 468-point face mesh and computed head pose (`pitch`, `yaw`,\r\n * `roll`). Populates `face.landmarks` and `face.headPose` on the face\r\n * entry. Does NOT populate `face.bounds` / `face.center` / `face.confidence`\r\n * — those are produced only by face detection. Enable both if you need\r\n * both, or compute bounds from `face.landmarks` min/max yourself.\r\n *\r\n * Safe to call from module scope as well as from inside `render()`. The\r\n * verb is idempotent and reference-counted.\r\n *\r\n * @returns Resolves once the pipeline has finished switching.\r\n */\r\n enableFaceMesh(enabled: boolean): Promise<void>;\r\n /**\r\n * Toggle 7 expressions + 52 ARKit blendshape coefficients on each face.\r\n * Populates `face.blendshapes` and `face.expressions`. Internally requires\r\n * the face landmarker model (loads it alongside `enableFaceMesh` if both\r\n * are enabled; loads it on its own otherwise so `face.landmarks` and\r\n * `face.headPose` are also populated). Does NOT populate\r\n * `face.bounds` / `face.center` / `face.confidence` — enable face\r\n * detection for those.\r\n *\r\n * Safe to call from module scope as well as from inside `render()`. The\r\n * verb is idempotent and reference-counted.\r\n *\r\n * @returns Resolves once the pipeline has finished switching.\r\n */\r\n enableEmotionDetection(enabled: boolean): Promise<void>;\r\n /**\r\n * Toggle 21-point hand landmarks and ML-classified gesture confidences\r\n * for up to two hands. Populates `viji.video.cv.hands[]` with `landmarks`,\r\n * `palm`, `bounds` (computed from landmarks), and `gestures`.\r\n *\r\n * Safe to call from module scope as well as from inside `render()`. The\r\n * verb is idempotent and reference-counted.\r\n *\r\n * @returns Resolves once the pipeline has finished switching.\r\n */\r\n enableHandTracking(enabled: boolean): Promise<void>;\r\n /**\r\n * Toggle 33-point BlazePose body landmarks (face / torso / arms / legs).\r\n * Populates `viji.video.cv.pose`.\r\n *\r\n * Safe to call from module scope as well as from inside `render()`. The\r\n * verb is idempotent and reference-counted.\r\n *\r\n * @returns Resolves once the pipeline has finished switching.\r\n */\r\n enablePoseDetection(enabled: boolean): Promise<void>;\r\n /**\r\n * Toggle per-pixel person/background segmentation mask. Populates\r\n * `viji.video.cv.segmentation`.\r\n *\r\n * Safe to call from module scope as well as from inside `render()`. The\r\n * verb is idempotent and reference-counted.\r\n *\r\n * @returns Resolves once the pipeline has finished switching.\r\n */\r\n enableBodySegmentation(enabled: boolean): Promise<void>;\r\n /** Returns the list of CV features currently enabled on this stream. */\r\n getActiveFeatures(): CVFeature[];\r\n /** Returns `true` if the CV worker is actively processing frames. */\r\n isProcessing(): boolean;\r\n }\r\n\n /**\r\n * The Viji API surface available to artist code as the global `viji` object.\r\n * Groups canvas access, timing, connected media APIs, user interaction, device\r\n * sensors, parameter helpers, and the `useContext()` selector.\r\n */\r\n interface VijiAPI {\r\n /** The `OffscreenCanvas` driving the scene. The host owns its lifecycle and dimensions; prefer `useContext()` over touching this directly. */\r\n canvas: OffscreenCanvas;\r\n /** 2D rendering context. `undefined` until `viji.useContext('2d')` is called; afterwards equals the cached context. */\r\n ctx?: OffscreenCanvasRenderingContext2D;\r\n /** WebGL rendering context. `undefined` until `viji.useContext('webgl')` or `'webgl2'` is called; afterwards equals the cached context. */\r\n gl?: WebGLRenderingContext | WebGL2RenderingContext;\r\n /** WebGPU canvas context. `undefined` until `viji.useContext('webgpu')` (or a direct `viji.canvas.getContext('webgpu')`) succeeds; afterwards equals the acquired context. Stays `undefined` on browsers without WebGPU support. */\r\n gpu?: GPUCanvasContext;\r\n /** Current canvas width in pixels. Updates automatically when the host resizes the canvas; read every frame. */\r\n width: number;\r\n /** Current canvas height in pixels. Updates automatically when the host resizes the canvas; read every frame. */\r\n height: number;\r\n /** Seconds elapsed since the scene started (monotonically increasing float). Use for oscillations and absolute-time effects. */\r\n time: number;\r\n /** Seconds since the previous frame. Use for accumulation: movement, physics, fades, anything that should progress per second regardless of FPS. */\r\n deltaTime: number;\r\n /** Integer frame counter starting at `0` and incrementing by `1` each frame. */\r\n frameCount: number;\r\n /** Target frames-per-second for the host's current frame-rate mode (screen refresh rate divided by the mode divisor 1/2/4/8). */\r\n fps: number;\r\n /** Real-time analysis of the main audio stream: volume, frequency bands, beat detection, spectral features. Fields are zeroed when no audio source is connected. */\r\n audio: AudioAPI;\r\n /** Main video stream API: pixel access, frame metadata, and computer-vision results (face, hands, pose, segmentation). */\r\n video: VideoAPI;\r\n /** Additional video streams provided by the host. These do not run CV processing; use them for raw pixel access only. */\r\n videoStreams: VideoAPI[];\r\n /** Additional audio streams (lightweight analysis: volume, bands, spectral). No beat detection; use the main `audio` for that. */\r\n audioStreams: AudioStreamAPI[];\r\n /** Mouse position, buttons, wheel, and per-frame movement state. Coordinates are in canvas pixels. */\r\n mouse: MouseAPI;\r\n /** Keyboard state: per-frame press/release queries, currently held keys, and modifier flags. */\r\n keyboard: KeyboardAPI;\r\n /** Multi-touch state: count, primary touch shortcut, and the per-frame `started` / `moved` / `ended` arrays. */\r\n touches: TouchAPI;\r\n /** Unified pointer (mouse + primary touch). Convenient single-point input that works on both desktop and mobile. */\r\n pointer: PointerAPI;\r\n /** Internal device sensors (motion + orientation) reported by the device running the scene. */\r\n device: DeviceSensorState;\r\n /** External connected devices reporting sensor / camera / audio. Each entry has its own `id`, `name`, and per-device API surface. */\r\n devices: DeviceState[];\r\n /**\r\n * Declares a numeric slider parameter. The host UI renders a draggable slider.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const radius = viji.slider(50, { min: 10, max: 200, step: 1, label: 'Radius' });\r\n * // ...\r\n * function render(viji) { drawCircle(radius.value); }\r\n */\r\n slider: (defaultValue: number, config: SliderConfig) => SliderParameter;\r\n /**\r\n * Declares a color parameter. Accepts hex strings, CSS color functions, or RGB / HSB objects;\r\n * the value is always normalized to a canonical lowercase hex string and exposes derived\r\n * `.rgb` / `.hsb` / `.alpha` accessors. Pass `alpha: true` to enable transparency: the value\r\n * becomes `#rrggbbaa` and alpha-bearing inputs (`rgba()`, `#rrggbbaa`, ...) are accepted.\r\n * Without it, alpha-bearing inputs are rejected.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const tint = viji.color('#ff6600', { label: 'Tint' });\r\n * // tint.value -> '#ff6600', tint.rgb -> { r: 255, g: 102, b: 0 }, tint.hsb -> { h: 24, s: 100, b: 100 }, tint.alpha -> 1\r\n * const glow = viji.color('#ffffff80', { label: 'Glow', alpha: true });\r\n * // glow.value -> '#ffffff80', glow.alpha -> 0.5\r\n */\r\n color: (defaultValue: ColorInput, config: ColorConfig) => ColorParameter;\r\n /**\r\n * Declares a boolean toggle parameter. The host UI renders an on/off switch.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const showTrail = viji.toggle(true, { label: 'Show Trail' });\r\n */\r\n toggle: (defaultValue: boolean, config: ToggleConfig) => ToggleParameter;\r\n /**\r\n * Declares a dropdown selection parameter. The element type of `options`\r\n * (`string` or `number`) determines the parameter's value type.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const shape = viji.select('circle', { options: ['circle', 'square', 'triangle'], label: 'Shape' });\r\n */\r\n select: (defaultValue: string | number, config: SelectConfig) => SelectParameter;\r\n /**\r\n * Declares a text input parameter. The host UI renders a single-line text field.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const caption = viji.text('Hello', { label: 'Caption', maxLength: 64 });\r\n */\r\n text: (defaultValue: string, config: TextConfig) => TextParameter;\r\n /**\r\n * Declares a precise numeric input parameter. Like `slider()` but the host UI\r\n * shows a number field instead of a draggable handle.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const count = viji.number(12, { min: 1, max: 64, step: 1, label: 'Count' });\r\n */\r\n number: (defaultValue: number, config: NumberConfig) => NumberParameter;\r\n /**\r\n * Declares an image upload parameter. The user-supplied image becomes available\r\n * as `value` (an `ImageBitmap`); in P5 scenes a `.p5` accessor is also added at runtime.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const tex = viji.image(null, { label: 'Texture' });\r\n * if (tex.value) ctx.drawImage(tex.value, 0, 0, viji.width, viji.height);\r\n */\r\n image: (defaultValue: null, config: ImageConfig) => ImageParameter;\r\n /**\r\n * Declares a momentary button parameter. `value` is `true` for one frame after\r\n * the user clicks, then auto-resets. Perfect for triggering discrete events.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const reset = viji.button({ label: 'Reset' });\r\n * function render(viji) { if (reset.value) state = initialState; }\r\n */\r\n button: (config: ButtonConfig) => ButtonParameter;\r\n /**\r\n * Declares a 2D coordinate parameter. Both `value.x` and `value.y` are in `-1..1`.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const origin = viji.coordinate({ x: 0, y: 0 }, { label: 'Origin' });\r\n * const cx = viji.width / 2 + origin.value.x * viji.width * 0.4;\r\n */\r\n coordinate: (defaultValue: CoordinateValue, config: CoordinateConfig) => CoordinateParameter;\r\n /**\r\n * Declares a gradient parameter. The host renders a ramp editor; `value` is the live,\r\n * sorted stop list and `at(t)` samples the ramp (CSS `linear-gradient` semantics).\r\n * Stop colors accept every color form; pass `alpha: true` for per-stop transparency.\r\n * `default` is required (no evenly-spaced shorthand). Must be called at the top level\r\n * of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const ramp = viji.gradient(\r\n * [{ color: '#ff6b6b', position: 0 }, { color: '#4ecdc4', position: 1 }],\r\n * { label: 'Ramp' }\r\n * );\r\n * function render(viji) {\r\n * const fill = viji.ctx.createLinearGradient(0, 0, viji.width, 0);\r\n * for (const stop of ramp.value) fill.addColorStop(stop.position, stop.color);\r\n * viji.ctx.fillStyle = fill;\r\n * viji.ctx.fillRect(0, 0, viji.width, viji.height);\r\n * viji.ctx.fillStyle = ramp.at(0.5); // per-element color, same math as the fill\r\n * }\r\n */\r\n gradient: (defaultValue: GradientInput, config: GradientConfig) => GradientParameter;\r\n /**\r\n * Selects the 2D canvas rendering context. Returns the same instance on\r\n * subsequent calls and also stores it on `viji.ctx`. A canvas only supports\r\n * one context type. If a different context type was already requested,\r\n * the call returns `null`. Choose ONE type and use it for the entire scene.\r\n *\r\n * @example\r\n * const ctx = viji.useContext('2d');\r\n * ctx.fillRect(0, 0, viji.width, viji.height);\r\n */\r\n useContext(type: '2d'): OffscreenCanvasRenderingContext2D;\r\n /**\r\n * Selects a WebGL 1 rendering context. Returns the same instance on subsequent\r\n * calls and also stores it on `viji.gl`. A canvas only supports one context\r\n * type. If a different context type was already requested, the call returns\r\n * `null`. Choose ONE type and use it for the entire scene.\r\n */\r\n useContext(type: 'webgl'): WebGLRenderingContext;\r\n /**\r\n * Selects a WebGL 2 rendering context. Returns the same instance on subsequent\r\n * calls and also stores it on `viji.gl`. A canvas only supports one context\r\n * type. If a different context type was already requested, the call returns\r\n * `null`. Choose ONE type and use it for the entire scene.\r\n */\r\n useContext(type: 'webgl2'): WebGL2RenderingContext;\r\n /**\r\n * Selects a WebGPU canvas context. Returns the raw `GPUCanvasContext` and\r\n * also stores it on `viji.gpu`. Adapter and device acquisition stay in scene\r\n * code (`navigator.gpu` is available; top-level `await` works), and the\r\n * scene must call `configure()` on the context before rendering. A canvas\r\n * only supports one context type. Returns `null` when a different context\r\n * type was already requested OR when the browser has no WebGPU support,\r\n * so always guard and provide a fallback. Choose ONE type and use it for\r\n * the entire scene.\r\n *\r\n * @example\r\n * const gctx = viji.useContext('webgpu');\r\n * if (!navigator.gpu || !gctx) {\r\n * // fall back, e.g. render a message via a 2d scene variant\r\n * } else {\r\n * const adapter = await navigator.gpu.requestAdapter();\r\n * const device = await adapter.requestDevice();\r\n * const format = navigator.gpu.getPreferredCanvasFormat();\r\n * gctx.configure({ device, format, alphaMode: 'opaque' });\r\n * }\r\n */\r\n useContext(type: 'webgpu'): GPUCanvasContext | null;\r\n }\r\n\n // ===== WEBGPU TYPES (inlined from @webgpu/types v0.1.72) =====\n // *********************************************************************************************\n // This file is manually-edited by diffing against an autogenerated file. See README.md.\n // *********************************************************************************************\n\n // *********************************************************************************************\n // Manually-written - auto copied from extra.d.ts\n // *********************************************************************************************\n\n // AllowSharedBufferSource wasn't introduced until TypeScript 5.2.\n // But it also didn't include SharedArrayBuffer in the union.\n // This broke in ES2024 when ArrayBuffer gained some properties that SharedArrayBuffer didn't.\n // So, we use our own definition for AllowSharedBufferSource.\n\n type GPUAllowSharedBufferSource =\n\n | BufferSource\n | SharedArrayBuffer;\n\n // Stronger typing for getContext()\n\n interface HTMLCanvasElement {\n getContext(\n contextId:\n | \"webgpu\"\n ): GPUCanvasContext | null;\n }\n interface OffscreenCanvas {\n getContext(\n contextId:\n | \"webgpu\"\n ): GPUCanvasContext | null;\n }\n\n // Defined as an empty interface here to prevent errors when using these types in a worker.\n\n interface HTMLVideoElement {}\n\n // Strict types defined to help developers catch a common class of errors.\n // This interface defines depth as an undefined, which will cause a type check failure if someone\n // attempts to set depth rather than depthOrArrayLayers on a GPUExtent3D (an easy mistake to make.)\n\n type GPUOrigin2DStrict =\n\n | Iterable<GPUIntegerCoordinate>\n | GPUOrigin2DDictStrict;\n interface GPUOrigin2DDictStrict\n extends GPUOrigin2DDict {\n /** @deprecated Does not exist for GPUOrigin2D. */\n z?: undefined;\n }\n type GPUExtent3DStrict =\n\n | Iterable<GPUIntegerCoordinate>\n | GPUExtent3DDictStrict;\n interface GPUExtent3DDictStrict\n extends GPUExtent3DDict {\n /** @deprecated The correct name is `depthOrArrayLayers`. */\n depth?: undefined;\n }\n\n // Stronger typing for event listeners.\n\n /** @internal */\n interface __GPUDeviceEventMap {\n uncapturederror: GPUUncapturedErrorEvent;\n }\n\n // Extensions to the generated definition below.\n interface GPUDevice {\n addEventListener<\n K extends keyof __GPUDeviceEventMap\n >(\n type: K,\n listener: (\n this: GPUDevice,\n ev: __GPUDeviceEventMap[K]\n ) => any,\n options?:\n | boolean\n | AddEventListenerOptions\n ): void;\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?:\n | boolean\n | AddEventListenerOptions\n ): void;\n removeEventListener<\n K extends keyof __GPUDeviceEventMap\n >(\n type: K,\n listener: (\n this: GPUDevice,\n ev: __GPUDeviceEventMap[K]\n ) => any,\n options?:\n | boolean\n | EventListenerOptions\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?:\n | boolean\n | EventListenerOptions\n ): void;\n }\n\n interface GPUCanvasConfigurationOut\n extends Required<\n Omit<\n GPUCanvasConfiguration,\n \"toneMapping\"\n >\n > {\n /** {@inheritDoc GPUCanvasConfiguration.viewFormats} */\n viewFormats: GPUTextureFormat[];\n /**\n * {@inheritDoc GPUCanvasConfiguration.toneMapping}\n */\n toneMapping?: GPUCanvasToneMapping;\n }\n\n /** @deprecated Use {@link GPUTexelCopyBufferLayout} */\n type GPUImageDataLayout =\n GPUTexelCopyBufferLayout;\n /** @deprecated Use {@link GPUTexelCopyBufferInfo} */\n type GPUImageCopyBuffer =\n GPUTexelCopyBufferInfo;\n /** @deprecated Use {@link GPUTexelCopyTextureInfo} */\n type GPUImageCopyTexture =\n GPUTexelCopyTextureInfo;\n /** @deprecated Use {@link GPUCopyExternalImageDestInfo} */\n type GPUImageCopyTextureTagged =\n GPUCopyExternalImageDestInfo;\n /** @deprecated Use {@link GPUCopyExternalImageSourceInfo} */\n type GPUImageCopyExternalImage =\n GPUCopyExternalImageSourceInfo;\n /** @deprecated Use {@link GPUCopyExternalImageSource} */\n type GPUImageCopyExternalImageSource =\n GPUCopyExternalImageSource;\n\n // *********************************************************************************************\n // Semi-auto-generated (by manual diff with autogenerated types)\n // *********************************************************************************************\n\n type GPUBindingResource =\n\n | GPUSampler\n | GPUTexture\n | GPUTextureView\n | GPUBuffer\n | GPUBufferBinding\n | GPUExternalTexture;\n type GPUBufferDynamicOffset =\n number;\n type GPUBufferUsageFlags =\n number;\n type GPUColor =\n\n | Iterable<number>\n | GPUColorDict;\n type GPUColorWriteFlags =\n number;\n type GPUCopyExternalImageSource =\n\n | ImageBitmap\n | ImageData\n | HTMLImageElement\n | HTMLVideoElement\n | VideoFrame\n | HTMLCanvasElement\n | OffscreenCanvas;\n type GPUDepthBias =\n number;\n type GPUExtent3D =\n\n | Iterable<GPUIntegerCoordinate>\n | GPUExtent3DDict;\n type GPUFlagsConstant =\n number;\n type GPUIndex32 =\n number;\n type GPUIntegerCoordinate =\n number;\n type GPUIntegerCoordinateOut =\n number;\n type GPUMapModeFlags =\n number;\n type GPUOrigin2D =\n\n | Iterable<GPUIntegerCoordinate>\n | GPUOrigin2DDict;\n type GPUOrigin3D =\n\n | Iterable<GPUIntegerCoordinate>\n | GPUOrigin3DDict;\n type GPUPipelineConstantValue =\n number;\n type GPUSampleMask =\n number;\n type GPUShaderStageFlags =\n number;\n type GPUSignedOffset32 =\n number;\n type GPUSize32 =\n number;\n type GPUSize32Out =\n number;\n type GPUSize64 =\n number;\n type GPUSize64Out =\n number;\n type GPUStencilValue =\n number;\n type GPUTextureUsageFlags =\n number;\n type GPUAddressMode =\n\n | \"clamp-to-edge\"\n | \"repeat\"\n | \"mirror-repeat\";\n type GPUAutoLayoutMode =\n \"auto\";\n type GPUBlendFactor =\n\n | \"zero\"\n | \"one\"\n | \"src\"\n | \"one-minus-src\"\n | \"src-alpha\"\n | \"one-minus-src-alpha\"\n | \"dst\"\n | \"one-minus-dst\"\n | \"dst-alpha\"\n | \"one-minus-dst-alpha\"\n | \"src-alpha-saturated\"\n | \"constant\"\n | \"one-minus-constant\"\n | \"src1\"\n | \"one-minus-src1\"\n | \"src1-alpha\"\n | \"one-minus-src1-alpha\";\n type GPUBlendOperation =\n\n | \"add\"\n | \"subtract\"\n | \"reverse-subtract\"\n | \"min\"\n | \"max\";\n type GPUBufferBindingType =\n\n | \"uniform\"\n | \"storage\"\n | \"read-only-storage\";\n type GPUBufferMapState =\n\n | \"unmapped\"\n | \"pending\"\n | \"mapped\";\n type GPUCanvasAlphaMode =\n\n | \"opaque\"\n | \"premultiplied\";\n type GPUCanvasToneMappingMode =\n\n | \"standard\"\n | \"extended\";\n type GPUCompareFunction =\n\n | \"never\"\n | \"less\"\n | \"equal\"\n | \"less-equal\"\n | \"greater\"\n | \"not-equal\"\n | \"greater-equal\"\n | \"always\";\n type GPUCompilationMessageType =\n\n | \"error\"\n | \"warning\"\n | \"info\";\n type GPUCullMode =\n\n | \"none\"\n | \"front\"\n | \"back\";\n type GPUDeviceLostReason =\n\n | \"unknown\"\n | \"destroyed\";\n type GPUErrorFilter =\n\n | \"validation\"\n | \"out-of-memory\"\n | \"internal\";\n type GPUFeatureName =\n\n | \"core-features-and-limits\"\n | \"depth-clip-control\"\n | \"depth32float-stencil8\"\n | \"texture-compression-bc\"\n | \"texture-compression-bc-sliced-3d\"\n | \"texture-compression-etc2\"\n | \"texture-compression-astc\"\n | \"texture-compression-astc-sliced-3d\"\n | \"timestamp-query\"\n | \"indirect-first-instance\"\n | \"shader-f16\"\n | \"rg11b10ufloat-renderable\"\n | \"bgra8unorm-storage\"\n | \"float32-filterable\"\n | \"float32-blendable\"\n | \"clip-distances\"\n | \"dual-source-blending\"\n | \"subgroups\"\n | \"texture-formats-tier1\"\n | \"texture-formats-tier2\"\n | \"primitive-index\"\n | \"texture-component-swizzle\"\n | \"subgroup-size-control\";\n type GPUFilterMode =\n\n | \"nearest\"\n | \"linear\";\n type GPUFrontFace =\n\n | \"ccw\"\n | \"cw\";\n type GPUIndexFormat =\n\n | \"uint16\"\n | \"uint32\";\n type GPULoadOp =\n\n | \"load\"\n | \"clear\";\n type GPUMipmapFilterMode =\n\n | \"nearest\"\n | \"linear\";\n type GPUPipelineErrorReason =\n\n | \"validation\"\n | \"internal\";\n type GPUPowerPreference =\n\n | \"low-power\"\n | \"high-performance\";\n type GPUPrimitiveTopology =\n\n | \"point-list\"\n | \"line-list\"\n | \"line-strip\"\n | \"triangle-list\"\n | \"triangle-strip\";\n type GPUQueryType =\n\n | \"occlusion\"\n | \"timestamp\";\n type GPUSamplerBindingType =\n\n | \"filtering\"\n | \"non-filtering\"\n | \"comparison\";\n type GPUStencilOperation =\n\n | \"keep\"\n | \"zero\"\n | \"replace\"\n | \"invert\"\n | \"increment-clamp\"\n | \"decrement-clamp\"\n | \"increment-wrap\"\n | \"decrement-wrap\";\n type GPUStorageTextureAccess =\n\n | \"write-only\"\n | \"read-only\"\n | \"read-write\";\n type GPUStoreOp =\n\n | \"store\"\n | \"discard\";\n type GPUTextureAspect =\n\n | \"all\"\n | \"stencil-only\"\n | \"depth-only\";\n type GPUTextureDimension =\n\n | \"1d\"\n | \"2d\"\n | \"3d\";\n type GPUTextureFormat =\n\n | \"r8unorm\"\n | \"r8snorm\"\n | \"r8uint\"\n | \"r8sint\"\n | \"r16unorm\"\n | \"r16snorm\"\n | \"r16uint\"\n | \"r16sint\"\n | \"r16float\"\n | \"rg8unorm\"\n | \"rg8snorm\"\n | \"rg8uint\"\n | \"rg8sint\"\n | \"r32uint\"\n | \"r32sint\"\n | \"r32float\"\n | \"rg16unorm\"\n | \"rg16snorm\"\n | \"rg16uint\"\n | \"rg16sint\"\n | \"rg16float\"\n | \"rgba8unorm\"\n | \"rgba8unorm-srgb\"\n | \"rgba8snorm\"\n | \"rgba8uint\"\n | \"rgba8sint\"\n | \"bgra8unorm\"\n | \"bgra8unorm-srgb\"\n | \"rgb9e5ufloat\"\n | \"rgb10a2uint\"\n | \"rgb10a2unorm\"\n | \"rg11b10ufloat\"\n | \"rg32uint\"\n | \"rg32sint\"\n | \"rg32float\"\n | \"rgba16unorm\"\n | \"rgba16snorm\"\n | \"rgba16uint\"\n | \"rgba16sint\"\n | \"rgba16float\"\n | \"rgba32uint\"\n | \"rgba32sint\"\n | \"rgba32float\"\n | \"stencil8\"\n | \"depth16unorm\"\n | \"depth24plus\"\n | \"depth24plus-stencil8\"\n | \"depth32float\"\n | \"depth32float-stencil8\"\n | \"bc1-rgba-unorm\"\n | \"bc1-rgba-unorm-srgb\"\n | \"bc2-rgba-unorm\"\n | \"bc2-rgba-unorm-srgb\"\n | \"bc3-rgba-unorm\"\n | \"bc3-rgba-unorm-srgb\"\n | \"bc4-r-unorm\"\n | \"bc4-r-snorm\"\n | \"bc5-rg-unorm\"\n | \"bc5-rg-snorm\"\n | \"bc6h-rgb-ufloat\"\n | \"bc6h-rgb-float\"\n | \"bc7-rgba-unorm\"\n | \"bc7-rgba-unorm-srgb\"\n | \"etc2-rgb8unorm\"\n | \"etc2-rgb8unorm-srgb\"\n | \"etc2-rgb8a1unorm\"\n | \"etc2-rgb8a1unorm-srgb\"\n | \"etc2-rgba8unorm\"\n | \"etc2-rgba8unorm-srgb\"\n | \"eac-r11unorm\"\n | \"eac-r11snorm\"\n | \"eac-rg11unorm\"\n | \"eac-rg11snorm\"\n | \"astc-4x4-unorm\"\n | \"astc-4x4-unorm-srgb\"\n | \"astc-5x4-unorm\"\n | \"astc-5x4-unorm-srgb\"\n | \"astc-5x5-unorm\"\n | \"astc-5x5-unorm-srgb\"\n | \"astc-6x5-unorm\"\n | \"astc-6x5-unorm-srgb\"\n | \"astc-6x6-unorm\"\n | \"astc-6x6-unorm-srgb\"\n | \"astc-8x5-unorm\"\n | \"astc-8x5-unorm-srgb\"\n | \"astc-8x6-unorm\"\n | \"astc-8x6-unorm-srgb\"\n | \"astc-8x8-unorm\"\n | \"astc-8x8-unorm-srgb\"\n | \"astc-10x5-unorm\"\n | \"astc-10x5-unorm-srgb\"\n | \"astc-10x6-unorm\"\n | \"astc-10x6-unorm-srgb\"\n | \"astc-10x8-unorm\"\n | \"astc-10x8-unorm-srgb\"\n | \"astc-10x10-unorm\"\n | \"astc-10x10-unorm-srgb\"\n | \"astc-12x10-unorm\"\n | \"astc-12x10-unorm-srgb\"\n | \"astc-12x12-unorm\"\n | \"astc-12x12-unorm-srgb\";\n type GPUTextureSampleType =\n\n | \"float\"\n | \"unfilterable-float\"\n | \"depth\"\n | \"sint\"\n | \"uint\";\n type GPUTextureViewDimension =\n\n | \"1d\"\n | \"2d\"\n | \"2d-array\"\n | \"cube\"\n | \"cube-array\"\n | \"3d\";\n type GPUVertexFormat =\n\n | \"uint8\"\n | \"uint8x2\"\n | \"uint8x4\"\n | \"sint8\"\n | \"sint8x2\"\n | \"sint8x4\"\n | \"unorm8\"\n | \"unorm8x2\"\n | \"unorm8x4\"\n | \"snorm8\"\n | \"snorm8x2\"\n | \"snorm8x4\"\n | \"uint16\"\n | \"uint16x2\"\n | \"uint16x4\"\n | \"sint16\"\n | \"sint16x2\"\n | \"sint16x4\"\n | \"unorm16\"\n | \"unorm16x2\"\n | \"unorm16x4\"\n | \"snorm16\"\n | \"snorm16x2\"\n | \"snorm16x4\"\n | \"float16\"\n | \"float16x2\"\n | \"float16x4\"\n | \"float32\"\n | \"float32x2\"\n | \"float32x3\"\n | \"float32x4\"\n | \"uint32\"\n | \"uint32x2\"\n | \"uint32x3\"\n | \"uint32x4\"\n | \"sint32\"\n | \"sint32x2\"\n | \"sint32x3\"\n | \"sint32x4\"\n | \"unorm10-10-10-2\"\n | \"snorm10-10-10-2\"\n | \"unorm8x4-bgra\";\n type GPUVertexStepMode =\n\n | \"vertex\"\n | \"instance\";\n\n interface GPUBindGroupDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * The {@link GPUBindGroupLayout} the entries of this bind group will conform to.\n */\n layout: GPUBindGroupLayout;\n /**\n * A list of entries describing the resources to expose to the shader for each binding\n * described by the {@link GPUBindGroupDescriptor#layout}.\n */\n entries: Iterable<GPUBindGroupEntry>;\n }\n\n interface GPUBindGroupEntry {\n /**\n * A unique identifier for a resource binding within the {@link GPUBindGroup}, corresponding to a\n * {@link GPUBindGroupLayoutEntry#binding | GPUBindGroupLayoutEntry.binding} and a @binding\n * attribute in the {@link GPUShaderModule}.\n */\n binding: GPUIndex32;\n /**\n * The resource to bind, which may be a {@link GPUSampler}, {@link GPUTexture}, {@link GPUTextureView},\n * {@link GPUBuffer}, {@link GPUBufferBinding}, or {@link GPUExternalTexture}.\n */\n resource: GPUBindingResource;\n }\n\n interface GPUBindGroupLayoutDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * A list of entries describing the shader resource bindings for a bind group.\n */\n entries: Iterable<GPUBindGroupLayoutEntry>;\n }\n\n interface GPUBindGroupLayoutEntry {\n /**\n * A unique identifier for a resource binding within the {@link GPUBindGroupLayout}, corresponding\n * to a {@link GPUBindGroupEntry#binding | GPUBindGroupEntry.binding} and a @binding\n * attribute in the {@link GPUShaderModule}.\n */\n binding: GPUIndex32;\n /**\n * A bitset of the members of {@link GPUShaderStage}.\n * Each set bit indicates that a {@link GPUBindGroupLayoutEntry}'s resource\n * will be accessible from the associated shader stage.\n */\n visibility: GPUShaderStageFlags;\n /**\n */\n buffer?: GPUBufferBindingLayout;\n /**\n */\n sampler?: GPUSamplerBindingLayout;\n /**\n */\n texture?: GPUTextureBindingLayout;\n /**\n */\n storageTexture?: GPUStorageTextureBindingLayout;\n /**\n * Exactly one of these members must be set, indicating the binding type.\n * The contents of the member specify options specific to that type.\n * The corresponding resource in {@link GPUDevice#createBindGroup} requires\n * the corresponding binding resource type for this binding.\n */\n externalTexture?: GPUExternalTextureBindingLayout;\n }\n\n interface GPUBlendComponent {\n /**\n * Defines the {@link GPUBlendOperation} used to calculate the values written to the target\n * attachment components.\n */\n operation?: GPUBlendOperation;\n /**\n * Defines the {@link GPUBlendFactor} operation to be performed on values from the fragment shader.\n */\n srcFactor?: GPUBlendFactor;\n /**\n * Defines the {@link GPUBlendFactor} operation to be performed on values from the target attachment.\n */\n dstFactor?: GPUBlendFactor;\n }\n\n interface GPUBlendState {\n /**\n * Defines the blending behavior of the corresponding render target for color channels.\n */\n color: GPUBlendComponent;\n /**\n * Defines the blending behavior of the corresponding render target for the alpha channel.\n */\n alpha: GPUBlendComponent;\n }\n\n interface GPUBufferBinding {\n /**\n * The {@link GPUBuffer} to bind.\n */\n buffer: GPUBuffer;\n /**\n * The offset, in bytes, from the beginning of {@link GPUBufferBinding#buffer} to the\n * beginning of the range exposed to the shader by the buffer binding.\n */\n offset?: GPUSize64;\n /**\n * The size, in bytes, of the buffer binding.\n * If not map/exist|provided, specifies the range starting at\n * {@link GPUBufferBinding#offset} and ending at the end of {@link GPUBufferBinding#buffer}.\n */\n size?: GPUSize64;\n }\n\n interface GPUBufferBindingLayout {\n /**\n * Indicates the type required for buffers bound to this binding.\n */\n type?: GPUBufferBindingType;\n /**\n * Indicates whether this binding requires a dynamic offset.\n */\n hasDynamicOffset?: boolean;\n /**\n * Indicates the minimum {@link GPUBufferBinding#size} of a buffer binding used with this bind point.\n * Bindings are always validated against this size in {@link GPUDevice#createBindGroup}.\n * If this *is not* `0`, pipeline creation additionally [$validating shader binding|validates$]\n * that this value ≥ the minimum buffer binding size of the variable.\n * If this *is* `0`, it is ignored by pipeline creation, and instead draw/dispatch commands\n * [$Validate encoder bind groups|validate$] that each binding in the {@link GPUBindGroup}\n * satisfies the minimum buffer binding size of the variable.\n * Note:\n * Similar execution-time validation is theoretically possible for other\n * binding-related fields specified for early validation, like\n * {@link GPUTextureBindingLayout#sampleType} and {@link GPUStorageTextureBindingLayout#format},\n * which currently can only be validated in pipeline creation.\n * However, such execution-time validation could be costly or unnecessarily complex, so it is\n * available only for {@link GPUBufferBindingLayout#minBindingSize} which is expected to have the\n * most ergonomic impact.\n */\n minBindingSize?: GPUSize64;\n }\n\n interface GPUBufferDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * The size of the buffer in bytes.\n */\n size: GPUSize64;\n /**\n * The allowed usages for the buffer.\n */\n usage: GPUBufferUsageFlags;\n /**\n * If `true` creates the buffer in an already mapped state, allowing\n * {@link GPUBuffer#getMappedRange} to be called immediately. It is valid to set\n * {@link GPUBufferDescriptor#mappedAtCreation} to `true` even if {@link GPUBufferDescriptor#usage}\n * does not contain {@link GPUBufferUsage#MAP_READ} or {@link GPUBufferUsage#MAP_WRITE}. This can be\n * used to set the buffer's initial data.\n * Guarantees that even if the buffer creation eventually fails, it will still appear as if the\n * mapped range can be written/read to until it is unmapped.\n */\n mappedAtCreation?: boolean;\n }\n\n interface GPUCanvasConfiguration {\n /**\n * The {@link GPUDevice} that textures returned by {@link GPUCanvasContext#getCurrentTexture} will be\n * compatible with.\n */\n device: GPUDevice;\n /**\n * The format that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have.\n * Must be one of the Supported context formats.\n */\n format: GPUTextureFormat;\n /**\n * The usage that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have.\n * {@link GPUTextureUsage#RENDER_ATTACHMENT} is the default, but is not automatically included\n * if the usage is explicitly set. Be sure to include {@link GPUTextureUsage#RENDER_ATTACHMENT}\n * when setting a custom usage if you wish to use textures returned by\n * {@link GPUCanvasContext#getCurrentTexture} as color targets for a render pass.\n */\n usage?: GPUTextureUsageFlags;\n /**\n * The formats that views created from textures returned by\n * {@link GPUCanvasContext#getCurrentTexture} may use.\n */\n viewFormats?: Iterable<GPUTextureFormat>;\n /**\n * The color space that values written into textures returned by\n * {@link GPUCanvasContext#getCurrentTexture} should be displayed with.\n */\n colorSpace?: PredefinedColorSpace;\n /**\n * The tone mapping determines how the content of textures returned by\n * {@link GPUCanvasContext#getCurrentTexture} are to be displayed.\n * <div class=note heading>\n * This is a required feature, but user agents might not yet implement it,\n * effectively supporting only the default {@link GPUCanvasToneMapping}.\n * In such implementations, this member **should not** exist in its implementation of\n * {@link GPUCanvasConfiguration}, to make feature detection possible using\n * {@link GPUCanvasContext#getConfiguration}.\n * This is especially important in implementations which otherwise have HDR capabilities\n * (where a <l>'@media/dynamic-range'</l> of <l>''@media/dynamic-range/high''</l> would be\n * exposed).\n * If an implementation exposes this member and a `high` dynamic range, it **should** render the\n * canvas as an HDR element, not clamp values to the SDR range of the HDR display.\n * </div>\n */\n toneMapping?: GPUCanvasToneMapping;\n /**\n * Determines the effect that alpha values will have on the content of textures returned by\n * {@link GPUCanvasContext#getCurrentTexture} when read, displayed, or used as an image source.\n */\n alphaMode?: GPUCanvasAlphaMode;\n }\n\n interface GPUCanvasToneMapping {\n mode?: GPUCanvasToneMappingMode;\n }\n\n interface GPUColorDict {\n /**\n * The red channel value.\n */\n r: number;\n /**\n * The green channel value.\n */\n g: number;\n /**\n * The blue channel value.\n */\n b: number;\n /**\n * The alpha channel value.\n */\n a: number;\n }\n\n interface GPUColorTargetState {\n /**\n * The {@link GPUTextureFormat} of this color target. The pipeline will only be compatible with\n * {@link GPURenderPassEncoder}s which use a {@link GPUTextureView} of this format in the\n * corresponding color attachment.\n */\n format: GPUTextureFormat;\n /**\n * The blending behavior for this color target. If left undefined, disables blending for this\n * color target.\n */\n blend?: GPUBlendState;\n /**\n * Bitmask controlling which channels are are written to when drawing to this color target.\n */\n writeMask?: GPUColorWriteFlags;\n }\n\n type GPUCommandBufferDescriptor =\n GPUObjectDescriptorBase;\n type GPUCommandEncoderDescriptor =\n GPUObjectDescriptorBase;\n\n interface GPUComputePassDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * Defines which timestamp values will be written for this pass, and where to write them to.\n */\n timestampWrites?: GPUComputePassTimestampWrites;\n }\n\n interface GPUComputePassTimestampWrites {\n /**\n * The {@link GPUQuerySet}, of type {@link GPUQueryType} `\"timestamp\"`, that the query results will be\n * written to.\n */\n querySet: GPUQuerySet;\n /**\n * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into\n * which the timestamp at the beginning of the compute pass will be written.\n */\n beginningOfPassWriteIndex?: GPUSize32;\n /**\n * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into\n * which the timestamp at the end of the compute pass will be written.\n */\n endOfPassWriteIndex?: GPUSize32;\n }\n\n interface GPUComputePipelineDescriptor\n extends GPUPipelineDescriptorBase {\n /**\n * Describes the compute shader entry point of the pipeline.\n */\n compute: GPUProgrammableStage;\n }\n\n interface GPUCopyExternalImageDestInfo\n extends GPUTexelCopyTextureInfo {\n /**\n * Describes the color space and encoding used to encode data into the destination texture.\n * This {@link https://www.w3.org/TR/webgpu/#color-space-conversions | may result} in values outside of the range [0, 1]\n * being written to the target texture, if its format can represent them.\n * Otherwise, the results are clamped to the target texture format's range.\n * Note:\n * If {@link GPUCopyExternalImageDestInfo#colorSpace} matches the source image,\n * conversion might not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}.\n */\n colorSpace?: PredefinedColorSpace;\n /**\n * Describes whether the data written into the texture should have its RGB channels\n * premultiplied by the alpha channel, or not.\n * If this option is set to `true` and the {@link GPUCopyExternalImageSourceInfo#source} is also\n * premultiplied, the source RGB values must be preserved even if they exceed their\n * corresponding alpha values.\n * Note:\n * If {@link GPUCopyExternalImageDestInfo#premultipliedAlpha} matches the source image,\n * conversion might not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}.\n */\n premultipliedAlpha?: boolean;\n }\n\n interface GPUCopyExternalImageSourceInfo {\n /**\n * The source of the texel copy. The copy source data is captured at the moment that\n * {@link GPUQueue#copyExternalImageToTexture} is issued. Source size is determined as described\n * by the external source dimensions table.\n */\n source: GPUCopyExternalImageSource;\n /**\n * Defines the origin of the copy - the minimum (top-left) corner of the source sub-region to copy from.\n * Together with `copySize`, defines the full copy sub-region.\n */\n origin?: GPUOrigin2D;\n /**\n * Describes whether the source image is vertically flipped, or not.\n * If this option is set to `true`, the copy is flipped vertically: the bottom row of the source\n * region is copied into the first row of the destination region, and so on.\n * The {@link GPUCopyExternalImageSourceInfo#origin} option is still relative to the top-left corner\n * of the source image, increasing downward.\n */\n flipY?: boolean;\n }\n\n interface GPUDepthStencilState {\n /**\n * The {@link GPUTextureViewDescriptor#format} of {@link GPURenderPassDescriptor#depthStencilAttachment}\n * this {@link GPURenderPipeline} will be compatible with.\n */\n format: GPUTextureFormat;\n /**\n * Indicates if this {@link GPURenderPipeline} can modify\n * {@link GPURenderPassDescriptor#depthStencilAttachment} depth values.\n */\n depthWriteEnabled?: boolean;\n /**\n * The comparison operation used to test fragment depths against\n * {@link GPURenderPassDescriptor#depthStencilAttachment} depth values.\n */\n depthCompare?: GPUCompareFunction;\n /**\n * Defines how stencil comparisons and operations are performed for front-facing primitives.\n */\n stencilFront?: GPUStencilFaceState;\n /**\n * Defines how stencil comparisons and operations are performed for back-facing primitives.\n */\n stencilBack?: GPUStencilFaceState;\n /**\n * Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value\n * bits are read when performing stencil comparison tests.\n */\n stencilReadMask?: GPUStencilValue;\n /**\n * Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value\n * bits are written to when performing stencil operations.\n */\n stencilWriteMask?: GPUStencilValue;\n /**\n * Constant depth bias added to each triangle fragment. See [$biased fragment depth$] for details.\n */\n depthBias?: GPUDepthBias;\n /**\n * Depth bias that scales with the triangle fragment’s slope. See [$biased fragment depth$] for details.\n */\n depthBiasSlopeScale?: number;\n /**\n * The maximum depth bias of a triangle fragment. See [$biased fragment depth$] for details.\n */\n depthBiasClamp?: number;\n }\n\n interface GPUDeviceDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * Specifies the features that are required by the device request.\n * The request will fail if the adapter cannot provide these features.\n * Exactly the specified set of features, and no more or less, will be allowed in validation\n * of API calls on the resulting device.\n */\n requiredFeatures?: Iterable<GPUFeatureName>;\n /**\n * Specifies the limits that are required by the device request.\n * The request will fail if the adapter cannot provide these limits.\n * Each key with a non-`undefined` value must be the name of a member of supported limits.\n * API calls on the resulting device perform validation according to the exact limits of the\n * device (not the adapter; see {@link https://www.w3.org/TR/webgpu/#limits}).\n * <!-- If we ever need limit types other than GPUSize32/GPUSize64, we can change the value\n * type to `double` or `any` in the future and write out the type conversion explicitly (by\n * reference to WebIDL spec). Or change the entire type to `any` and add back a `dictionary\n * GPULimits` and define the conversion of the whole object by reference to WebIDL. -->\n */\n requiredLimits?: Record<\n string,\n | GPUSize64\n | undefined\n >;\n /**\n * The descriptor for the default {@link GPUQueue}.\n */\n defaultQueue?: GPUQueueDescriptor;\n }\n\n interface GPUExtent3DDict {\n /**\n * The width of the extent.\n */\n width: GPUIntegerCoordinate;\n /**\n * The height of the extent.\n */\n height?: GPUIntegerCoordinate;\n /**\n * The depth of the extent or the number of array layers it contains.\n * If used with a {@link GPUTexture} with a {@link GPUTextureDimension} of {@link GPUTextureDimension} `\"3d\"`\n * defines the depth of the texture. If used with a {@link GPUTexture} with a {@link GPUTextureDimension}\n * of {@link GPUTextureDimension} `\"2d\"` defines the number of array layers in the texture.\n */\n depthOrArrayLayers?: GPUIntegerCoordinate;\n }\n\n interface GPUExternalTextureBindingLayout {}\n\n interface GPUExternalTextureDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * The video source to import the external texture from. Source size is determined as described\n * by the external source dimensions table.\n */\n source:\n | HTMLVideoElement\n | VideoFrame;\n /**\n * The color space the image contents of {@link GPUExternalTextureDescriptor#source} will be\n * converted into when reading.\n */\n colorSpace?: PredefinedColorSpace;\n }\n\n interface GPUFragmentState\n extends GPUProgrammableStage {\n /**\n * A list of {@link GPUColorTargetState} defining the formats and behaviors of the color targets\n * this pipeline writes to.\n */\n targets: Iterable<\n | GPUColorTargetState\n | null\n | undefined\n >;\n }\n\n interface GPUMultisampleState {\n /**\n * Number of samples per pixel. This {@link GPURenderPipeline} will be compatible only\n * with attachment textures ({@link GPURenderPassDescriptor#colorAttachments}\n * and {@link GPURenderPassDescriptor#depthStencilAttachment})\n * with matching {@link GPUTextureDescriptor#sampleCount}s.\n */\n count?: GPUSize32;\n /**\n * Mask determining which samples are written to.\n */\n mask?: GPUSampleMask;\n /**\n * When `true` indicates that a fragment's alpha channel should be used to generate a sample\n * coverage mask.\n */\n alphaToCoverageEnabled?: boolean;\n }\n\n interface GPUObjectDescriptorBase {\n /**\n * The initial value of {@link GPUObjectBase#label | GPUObjectBase.label}.\n */\n label?: string;\n }\n\n interface GPUOrigin2DDict {\n x?: GPUIntegerCoordinate;\n y?: GPUIntegerCoordinate;\n }\n\n interface GPUOrigin3DDict {\n x?: GPUIntegerCoordinate;\n y?: GPUIntegerCoordinate;\n z?: GPUIntegerCoordinate;\n }\n\n interface GPUPipelineDescriptorBase\n extends GPUObjectDescriptorBase {\n /**\n * The {@link GPUPipelineLayout} for this pipeline, or {@link GPUAutoLayoutMode} `\"auto\"` to generate\n * the pipeline layout automatically.\n * Note: If {@link GPUAutoLayoutMode} `\"auto\"` is used the pipeline cannot share {@link GPUBindGroup}s\n * with any other pipelines.\n */\n layout:\n | GPUPipelineLayout\n | GPUAutoLayoutMode;\n }\n\n interface GPUPipelineErrorInit {\n reason: GPUPipelineErrorReason;\n }\n\n interface GPUPipelineLayoutDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * A list of optional {@link GPUBindGroupLayout}s the pipeline will use. Each element corresponds\n * to a @group attribute in the {@link GPUShaderModule}, with the `N`th element corresponding\n * with `@group(N)`.\n */\n bindGroupLayouts: Iterable<\n | GPUBindGroupLayout\n | null\n | undefined\n >;\n /**\n * The size, in bytes, of the immediate data range used by the pipeline.\n */\n immediateSize?: GPUSize32;\n }\n\n interface GPUPrimitiveState {\n /**\n * The type of primitive to be constructed from the vertex inputs.\n */\n topology?: GPUPrimitiveTopology;\n /**\n * For pipelines with strip topologies\n * ({@link GPUPrimitiveTopology} `\"line-strip\"` or {@link GPUPrimitiveTopology} `\"triangle-strip\"`),\n * this determines the index buffer format and primitive restart value\n * ({@link GPUIndexFormat} `\"uint16\"`/`0xFFFF` or {@link GPUIndexFormat} `\"uint32\"`/`0xFFFFFFFF`).\n * It is not allowed on pipelines with non-strip topologies.\n * Note: Some implementations require knowledge of the primitive restart value to compile\n * pipeline state objects.\n * To use a strip-topology pipeline with an indexed draw call\n * ({@link GPURenderCommandsMixin#drawIndexed()} or {@link GPURenderCommandsMixin#drawIndexedIndirect}),\n * this must be set, and it must match the index buffer format used with the draw call\n * (set in {@link GPURenderCommandsMixin#setIndexBuffer}).\n * See {@link https://www.w3.org/TR/webgpu/#primitive-assembly} for additional details.\n */\n stripIndexFormat?: GPUIndexFormat;\n /**\n * Defines which polygons are considered front-facing.\n */\n frontFace?: GPUFrontFace;\n /**\n * Defines which polygon orientation will be culled, if any.\n */\n cullMode?: GPUCullMode;\n /**\n * If true, indicates that depth clipping is disabled.\n * Requires the {@link GPUFeatureName} `\"depth-clip-control\"` feature to be enabled.\n */\n unclippedDepth?: boolean;\n }\n\n interface GPUProgrammableStage {\n /**\n * The {@link GPUShaderModule} containing the code that this programmable stage will execute.\n */\n module: GPUShaderModule;\n /**\n * The name of the function in {@link GPUProgrammableStage#module} that this stage will use to\n * perform its work.\n * NOTE: Since the {@link GPUProgrammableStage#entryPoint} dictionary member is\n * not required, methods which consume a {@link GPUProgrammableStage} must use the\n * \"[$get the entry point$]\" algorithm to determine which entry point\n * it refers to.\n */\n entryPoint?: string;\n /**\n * Specifies the values of pipeline-overridable constants in the shader module\n * {@link GPUProgrammableStage#module}.\n * Each such pipeline-overridable constant is uniquely identified by a single\n * pipeline-overridable constant identifier string, representing the pipeline\n * constant ID of the constant if its declaration specifies one, and otherwise the\n * constant's identifier name.\n * The key of each key-value pair must equal the\n * pipeline-overridable constant identifier string|identifier string\n * of one such constant, with the comparison performed\n * according to the rules for WGSL identifier comparison.\n * When the pipeline is executed, that constant will have the specified value.\n * Values are specified as <dfn typedef for=\"\">GPUPipelineConstantValue</dfn>, which is a `double`.\n * They are converted [$to WGSL type$] of the pipeline-overridable constant (`bool`/`i32`/`u32`/`f32`/`f16`).\n * If conversion fails, a validation error is generated.\n * <div class=example>\n * Pipeline-overridable constants defined in WGSL:\n * ```wgsl\n * @id(0) override has_point_light: bool = true; // Algorithmic control.\n * @id(1200) override specular_param: f32 = 2.3; // Numeric control.\n * @id(1300) override gain: f32; // Must be overridden.\n * override width: f32 = 0.0; // Specifed at the API level\n * // using the name \"width\".\n * override depth: f32; // Specifed at the API level\n * // using the name \"depth\".\n * // Must be overridden.\n * override height = 2 * depth; // The default value\n * // (if not set at the API level),\n * // depends on another\n * // overridable constant.\n * ```\n * Corresponding JavaScript code, providing only the overrides which are required\n * (have no defaults):\n * ```js\n * {\n * // ...\n * constants: {\n * 1300: 2.0, // \"gain\"\n * depth: -1, // \"depth\"\n * }\n * }\n * ```\n * Corresponding JavaScript code, overriding all constants:\n * ```js\n * {\n * // ...\n * constants: {\n * 0: false, // \"has_point_light\"\n * 1200: 3.0, // \"specular_param\"\n * 1300: 2.0, // \"gain\"\n * width: 20, // \"width\"\n * depth: -1, // \"depth\"\n * height: 15, // \"height\"\n * }\n * }\n * ```\n * </div>\n */\n constants?: Record<\n string,\n GPUPipelineConstantValue\n >;\n }\n\n interface GPUQuerySetDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * The type of queries managed by {@link GPUQuerySet}.\n */\n type: GPUQueryType;\n /**\n * The number of queries managed by {@link GPUQuerySet}.\n */\n count: GPUSize32;\n }\n\n type GPUQueueDescriptor =\n GPUObjectDescriptorBase;\n type GPURenderBundleDescriptor =\n GPUObjectDescriptorBase;\n\n interface GPURenderBundleEncoderDescriptor\n extends GPURenderPassLayout {\n /**\n * If `true`, indicates that the render bundle does not modify the depth component of the\n * {@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed\n * in.\n * See read-only depth-stencil.\n */\n depthReadOnly?: boolean;\n /**\n * If `true`, indicates that the render bundle does not modify the stencil component of the\n * {@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed\n * in.\n * See read-only depth-stencil.\n */\n stencilReadOnly?: boolean;\n }\n\n interface GPURenderPassColorAttachment {\n /**\n * Describes the texture subresource that will be output to for this color attachment.\n * The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#view}).\n */\n view:\n | GPUTexture\n | GPUTextureView;\n /**\n * Indicates the depth slice index of {@link GPUTextureViewDimension} `\"3d\"` {@link GPURenderPassColorAttachment#view}\n * that will be output to for this color attachment.\n */\n depthSlice?: GPUIntegerCoordinate;\n /**\n * Describes the texture subresource that will receive the resolved output for this color\n * attachment if {@link GPURenderPassColorAttachment#view} is multisampled.\n * The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#resolveTarget}).\n */\n resolveTarget?:\n | GPUTexture\n | GPUTextureView;\n /**\n * Indicates the value to clear {@link GPURenderPassColorAttachment#view} to prior to executing the\n * render pass. If not map/exist|provided, defaults to `{r: 0, g: 0, b: 0, a: 0}`. Ignored\n * if {@link GPURenderPassColorAttachment#loadOp} is not {@link GPULoadOp} `\"clear\"`.\n * The components of {@link GPURenderPassColorAttachment#clearValue} are all double values.\n * They are converted [$to a texel value of texture format$] matching the render attachment.\n * If conversion fails, a validation error is generated.\n */\n clearValue?: GPUColor;\n /**\n * Indicates the load operation to perform on {@link GPURenderPassColorAttachment#view} prior to\n * executing the render pass.\n * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `\"clear\"` for details.\n */\n loadOp: GPULoadOp;\n /**\n * The store operation to perform on {@link GPURenderPassColorAttachment#view}\n * after executing the render pass.\n */\n storeOp: GPUStoreOp;\n }\n\n interface GPURenderPassDepthStencilAttachment {\n /**\n * Describes the texture subresource that will be output to and read from for this\n * depth/stencil attachment.\n * The subresource is determined by calling [$get as texture view$]({@link GPURenderPassDepthStencilAttachment#view}).\n */\n view:\n | GPUTexture\n | GPUTextureView;\n /**\n * Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s depth component\n * to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#depthLoadOp}\n * is not {@link GPULoadOp} `\"clear\"`. Must be between 0.0 and 1.0, inclusive.\n * <!-- POSTV1(unrestricted-depth): unless unrestricted depth is enabled -->\n */\n depthClearValue?: number;\n /**\n * Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s\n * depth component prior to executing the render pass.\n * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `\"clear\"` for details.\n */\n depthLoadOp?: GPULoadOp;\n /**\n * The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s\n * depth component after executing the render pass.\n */\n depthStoreOp?: GPUStoreOp;\n /**\n * Indicates that the depth component of {@link GPURenderPassDepthStencilAttachment#view}\n * is read only.\n */\n depthReadOnly?: boolean;\n /**\n * Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s stencil component\n * to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#stencilLoadOp}\n * is not {@link GPULoadOp} `\"clear\"`.\n * The value will be converted to the type of the stencil aspect of `view` by taking the same\n * number of LSBs as the number of bits in the stencil aspect of one texel block|texel of `view`.\n */\n stencilClearValue?: GPUStencilValue;\n /**\n * Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s\n * stencil component prior to executing the render pass.\n * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `\"clear\"` for details.\n */\n stencilLoadOp?: GPULoadOp;\n /**\n * The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s\n * stencil component after executing the render pass.\n */\n stencilStoreOp?: GPUStoreOp;\n /**\n * Indicates that the stencil component of {@link GPURenderPassDepthStencilAttachment#view}\n * is read only.\n */\n stencilReadOnly?: boolean;\n }\n\n interface GPURenderPassDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * The set of {@link GPURenderPassColorAttachment} values in this sequence defines which\n * color attachments will be output to when executing this render pass.\n * Due to compatible usage list|usage compatibility, no color attachment\n * may alias another attachment or any resource used inside the render pass.\n */\n colorAttachments: Iterable<\n | GPURenderPassColorAttachment\n | null\n | undefined\n >;\n /**\n * The {@link GPURenderPassDepthStencilAttachment} value that defines the depth/stencil\n * attachment that will be output to and tested against when executing this render pass.\n * Due to compatible usage list|usage compatibility, no writable depth/stencil attachment\n * may alias another attachment or any resource used inside the render pass.\n */\n depthStencilAttachment?: GPURenderPassDepthStencilAttachment;\n /**\n * The {@link GPUQuerySet} value defines where the occlusion query results will be stored for this pass.\n */\n occlusionQuerySet?: GPUQuerySet;\n /**\n * Defines which timestamp values will be written for this pass, and where to write them to.\n */\n timestampWrites?: GPURenderPassTimestampWrites;\n /**\n * The maximum number of draw calls that will be done in the render pass. Used by some\n * implementations to size work injected before the render pass. Keeping the default value\n * is a good default, unless it is known that more draw calls will be done.\n */\n maxDrawCount?: GPUSize64;\n }\n\n interface GPURenderPassLayout\n extends GPUObjectDescriptorBase {\n /**\n * A list of the {@link GPUTextureFormat}s of the color attachments for this pass or bundle.\n */\n colorFormats: Iterable<\n | GPUTextureFormat\n | null\n | undefined\n >;\n /**\n * The {@link GPUTextureFormat} of the depth/stencil attachment for this pass or bundle.\n */\n depthStencilFormat?: GPUTextureFormat;\n /**\n * Number of samples per pixel in the attachments for this pass or bundle.\n */\n sampleCount?: GPUSize32;\n }\n\n interface GPURenderPassTimestampWrites {\n /**\n * The {@link GPUQuerySet}, of type {@link GPUQueryType} `\"timestamp\"`, that the query results will be\n * written to.\n */\n querySet: GPUQuerySet;\n /**\n * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into\n * which the timestamp at the beginning of the render pass will be written.\n */\n beginningOfPassWriteIndex?: GPUSize32;\n /**\n * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into\n * which the timestamp at the end of the render pass will be written.\n */\n endOfPassWriteIndex?: GPUSize32;\n }\n\n interface GPURenderPipelineDescriptor\n extends GPUPipelineDescriptorBase {\n /**\n * Describes the vertex shader entry point of the pipeline and its input buffer layouts.\n */\n vertex: GPUVertexState;\n /**\n * Describes the primitive-related properties of the pipeline.\n */\n primitive?: GPUPrimitiveState;\n /**\n * Describes the optional depth-stencil properties, including the testing, operations, and bias.\n */\n depthStencil?: GPUDepthStencilState;\n /**\n * Describes the multi-sampling properties of the pipeline.\n */\n multisample?: GPUMultisampleState;\n /**\n * Describes the fragment shader entry point of the pipeline and its output colors. If\n * not map/exist|provided, the {@link https://www.w3.org/TR/webgpu/#no-color-output} mode is enabled.\n */\n fragment?: GPUFragmentState;\n }\n\n interface GPURequestAdapterOptions {\n /**\n * Requests an adapter that supports at least a particular set of capabilities.\n * This influences the {@link adapter#[[default feature level]]} of devices created\n * from this adapter. The capabilities for each level are defined below, and the exact\n * steps are defined in {@link GPU#requestAdapter} and \"a new device\".\n * If the implementation or system does not support all of the capabilities in the\n * requested feature level, {@link GPU#requestAdapter} will return `null`.\n * Note:\n * Applications should typically make a single {@link GPU#requestAdapter} call with the lowest\n * feature level they support, then inspect the adapter for additional capabilities they can\n * use optionally, and request those in {@link GPUAdapter#requestDevice}.\n * The allowed <dfn dfn for=\"\">feature level string</dfn> values are:\n * <dl dfn-type=dfn dfn-for=\"feature level string\">\n * : <dfn noexport>\"core\"</dfn>\n * The following set of capabilities:\n * - The limit/Default limits.\n * - {@link GPUFeatureName} `\"core-features-and-limits\"`.\n * Note:\n * Adapters with this {@link adapter#[[default feature level]]} may\n * conventionally be referred to as \"Core-defaulting\".\n * : <dfn noexport>\"compatibility\"</dfn>\n * The following set of capabilities:\n * - The limit/Compatibility Mode Default limits.\n * - No features. (It excludes the {@link GPUFeatureName} `\"core-features-and-limits\"` feature.)\n * If the implementation cannot enforce the stricter \"Compatibility Mode\"\n * validation rules, {@link GPU#requestAdapter} will ignore this request and\n * treat it as a request for feature level string/\"core\".\n * Note:\n * Adapters with this {@link adapter#[[default feature level]]} may\n * conventionally be referred to as \"Compatibility-defaulting\".\n */\n featureLevel?: string;\n /**\n * Optionally provides a hint indicating what class of adapter should be selected from\n * the system's available adapters.\n * The value of this hint may influence which adapter is chosen, but it must not\n * influence whether an adapter is returned or not.\n * Note:\n * The primary utility of this hint is to influence which GPU is used in a multi-GPU system.\n * For instance, some laptops have a low-power integrated GPU and a high-performance\n * discrete GPU. This hint may also affect the power configuration of the selected GPU to\n * match the requested power preference.\n * Note:\n * Depending on the exact hardware configuration, such as battery status and attached displays\n * or removable GPUs, the user agent may select different adapters given the same power\n * preference.\n * Typically, given the same hardware configuration and state and\n * `powerPreference`, the user agent is likely to select the same adapter.\n */\n powerPreference?: GPUPowerPreference;\n /**\n * When set to `true` indicates that only a fallback adapter may be returned. If the user\n * agent does not support a fallback adapter, will cause {@link GPU#requestAdapter} to\n * resolve to `null`.\n * Note:\n * {@link GPU#requestAdapter} may still return a fallback adapter if\n * {@link GPURequestAdapterOptions#forceFallbackAdapter} is set to `false` and either no\n * other appropriate adapter is available or the user agent chooses to return a\n * fallback adapter. Developers that wish to prevent their applications from running on\n * fallback adapters should check the {@link GPUAdapter#info}.{@link GPUAdapterInfo#isFallbackAdapter}\n * attribute prior to requesting a {@link GPUDevice}.\n */\n forceFallbackAdapter?: boolean;\n xrCompatible?: boolean;\n }\n\n interface GPUSamplerBindingLayout {\n /**\n * Indicates the required type of a sampler bound to this bindings.\n */\n type?: GPUSamplerBindingType;\n }\n\n interface GPUSamplerDescriptor\n extends GPUObjectDescriptorBase {\n /**\n */\n addressModeU?: GPUAddressMode;\n /**\n */\n addressModeV?: GPUAddressMode;\n /**\n * Specifies the {@link GPUAddressMode | address modes} for the texture width, height, and depth\n * coordinates, respectively.\n */\n addressModeW?: GPUAddressMode;\n /**\n * Specifies the sampling behavior when the sampled area is smaller than or equal to one\n * texel.\n */\n magFilter?: GPUFilterMode;\n /**\n * Specifies the sampling behavior when the sampled area is larger than one texel.\n */\n minFilter?: GPUFilterMode;\n /**\n * Specifies behavior for sampling between mipmap levels.\n */\n mipmapFilter?: GPUMipmapFilterMode;\n /**\n */\n lodMinClamp?: number;\n /**\n * Specifies the minimum and maximum levels of detail, respectively, used internally when\n * sampling a texture.\n */\n lodMaxClamp?: number;\n /**\n * When provided the sampler will be a comparison sampler with the specified\n * {@link GPUCompareFunction}.\n * Note: Comparison samplers may use filtering, but the sampling results will be\n * implementation-dependent and may differ from the normal filtering rules.\n */\n compare?: GPUCompareFunction;\n /**\n * Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is\n * enabled when {@link GPUSamplerDescriptor#maxAnisotropy} is > 1 and the implementation supports it.\n * Anisotropic filtering improves the image quality of textures sampled at oblique viewing\n * angles. Higher {@link GPUSamplerDescriptor#maxAnisotropy} values indicate the maximum ratio of\n * anisotropy supported when filtering.\n * <div class=note heading>\n * Most implementations support {@link GPUSamplerDescriptor#maxAnisotropy} values in range\n * between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor#maxAnisotropy}\n * will be clamped to the maximum value that the platform supports.\n * The precise filtering behavior is implementation-dependent.\n * </div>\n */\n maxAnisotropy?: number;\n }\n\n interface GPUShaderModuleCompilationHint {\n entryPoint: string;\n /**\n * A {@link GPUPipelineLayout} that the {@link GPUShaderModule} may be used with in a future\n * {@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline} call.\n * If set to {@link GPUAutoLayoutMode} `\"auto\"` the layout will be the [$default pipeline layout$]\n * for the entry point associated with this hint will be used.\n */\n layout?:\n | GPUPipelineLayout\n | GPUAutoLayoutMode;\n }\n\n interface GPUShaderModuleDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * The <a href=\"https://gpuweb.github.io/gpuweb/wgsl/\">WGSL</a> source code for the shader\n * module.\n */\n code: string;\n /**\n * A list of {@link GPUShaderModuleCompilationHint}s.\n * Any hint provided by an application **should** contain information about one entry point of\n * a pipeline that will eventually be created from the entry point.\n * Implementations **should** use any information present in the {@link GPUShaderModuleCompilationHint}\n * to perform as much compilation as is possible within {@link GPUDevice#createShaderModule}.\n * Aside from type-checking, these hints are not validated in any way.\n * <div class=note heading>\n * Supplying information in {@link GPUShaderModuleDescriptor#compilationHints} does not have any\n * observable effect, other than performance. It may be detrimental to performance to\n * provide hints for pipelines that never end up being created.\n * Because a single shader module can hold multiple entry points, and multiple pipelines\n * can be created from a single shader module, it can be more performant for an\n * implementation to do as much compilation as possible once in\n * {@link GPUDevice#createShaderModule} rather than multiple times in the multiple calls to\n * {@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline}.\n * Hints are only applied to the entry points they explicitly name.\n * Unlike {@link GPUProgrammableStage#entryPoint | GPUProgrammableStage.entryPoint},\n * there is no default, even if only one entry point is present in the module.\n * </div>\n * Note:\n * Hints are not validated in an observable way, but user agents **may** surface identifiable\n * errors (like unknown entry point names or incompatible pipeline layouts) to developers,\n * for example in the browser developer console.\n */\n compilationHints?: Iterable<GPUShaderModuleCompilationHint>;\n }\n\n interface GPUStencilFaceState {\n /**\n * The {@link GPUCompareFunction} used when testing the RenderState.`[[stencilReference]]` value\n * against the fragment's {@link GPURenderPassDescriptor#depthStencilAttachment} stencil values.\n */\n compare?: GPUCompareFunction;\n /**\n * The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by\n * {@link GPUStencilFaceState#compare} fails.\n */\n failOp?: GPUStencilOperation;\n /**\n * The {@link GPUStencilOperation} performed if the fragment depth comparison described by\n * {@link GPUDepthStencilState#depthCompare} fails.\n */\n depthFailOp?: GPUStencilOperation;\n /**\n * The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by\n * {@link GPUStencilFaceState#compare} passes.\n */\n passOp?: GPUStencilOperation;\n }\n\n interface GPUStorageTextureBindingLayout {\n /**\n * The access mode for this binding, indicating readability and writability.\n */\n access?: GPUStorageTextureAccess;\n /**\n * The required {@link GPUTextureViewDescriptor#format} of texture views bound to this binding.\n */\n format: GPUTextureFormat;\n /**\n * Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to\n * this binding.\n */\n viewDimension?: GPUTextureViewDimension;\n }\n\n interface GPUTexelCopyBufferInfo\n extends GPUTexelCopyBufferLayout {\n /**\n * A buffer which either contains texel data to be copied or will store the texel data being\n * copied, depending on the method it is being passed to.\n */\n buffer: GPUBuffer;\n }\n\n interface GPUTexelCopyBufferLayout {\n /**\n * The offset, in bytes, from the beginning of the texel data source (such as a\n * {@link GPUTexelCopyBufferInfo#buffer | GPUTexelCopyBufferInfo.buffer}) to the start of the texel data\n * within that source.\n */\n offset?: GPUSize64;\n /**\n * The stride, in bytes, between the beginning of each texel block row and the subsequent\n * texel block row.\n * Required if there are multiple texel block rows (i.e. the copy height or depth is more\n * than one block).\n */\n bytesPerRow?: GPUSize32;\n /**\n * Number of texel block rows per single texel image of the texture.\n * {@link GPUTexelCopyBufferLayout#rowsPerImage} ×\n * {@link GPUTexelCopyBufferLayout#bytesPerRow} is the stride, in bytes, between the beginning of each\n * texel image of data and the subsequent texel image.\n * Required if there are multiple texel images (i.e. the copy depth is more than one).\n */\n rowsPerImage?: GPUSize32;\n }\n\n interface GPUTexelCopyTextureInfo {\n /**\n * Texture to copy to/from.\n */\n texture: GPUTexture;\n /**\n * Mip-map level of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from.\n */\n mipLevel?: GPUIntegerCoordinate;\n /**\n * Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from.\n * Together with `copySize`, defines the full copy sub-region.\n */\n origin?: GPUOrigin3D;\n /**\n * Defines which aspects of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from.\n */\n aspect?: GPUTextureAspect;\n }\n\n interface GPUTextureBindingLayout {\n /**\n * Indicates the type required for texture views bound to this binding.\n */\n sampleType?: GPUTextureSampleType;\n /**\n * Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to\n * this binding.\n */\n viewDimension?: GPUTextureViewDimension;\n /**\n * Indicates whether or not texture views bound to this binding must be multisampled.\n */\n multisampled?: boolean;\n }\n\n interface GPUTextureDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * The width, height, and depth or layer count of the texture.\n */\n size: GPUExtent3DStrict;\n /**\n * The number of mip levels the texture will contain.\n */\n mipLevelCount?: GPUIntegerCoordinate;\n /**\n * The sample count of the texture. A {@link GPUTextureDescriptor#sampleCount} > `1` indicates\n * a multisampled texture.\n */\n sampleCount?: GPUSize32;\n /**\n * Whether the texture is one-dimensional, an array of two-dimensional layers, or three-dimensional.\n */\n dimension?: GPUTextureDimension;\n /**\n * The format of the texture.\n */\n format: GPUTextureFormat;\n /**\n * The allowed usages for the texture.\n */\n usage: GPUTextureUsageFlags;\n /**\n * Specifies what view {@link GPUTextureViewDescriptor#format} values will be allowed when calling\n * {@link GPUTexture#createView} on this texture (in addition to the texture's actual\n * {@link GPUTextureDescriptor#format}).\n * <div class=note heading>\n * Adding a format to this list may have a significant performance impact, so it is best\n * to avoid adding formats unnecessarily.\n * The actual performance impact is highly dependent on the target system; developers must\n * test various systems to find out the impact on their particular application.\n * For example, on some systems any texture with a {@link GPUTextureDescriptor#format} or\n * {@link GPUTextureDescriptor#viewFormats} entry including\n * {@link GPUTextureFormat} `\"rgba8unorm-srgb\"` will perform less optimally than a\n * {@link GPUTextureFormat} `\"rgba8unorm\"` texture which does not.\n * Similar caveats exist for other formats and pairs of formats on other systems.\n * </div>\n * Formats in this list must be texture view format compatible with the texture format.\n * <div algorithm data-timeline=const>\n * Two {@link GPUTextureFormat}s `format` and `viewFormat` are <dfn dfn for=\"\">texture view format compatible</dfn> on a given `device` if:\n * - `format` equals `viewFormat`, or\n * - `format` and `viewFormat` differ only in whether they are `srgb` formats (have the `-srgb` suffix) and `device.features` list/contains {@link GPUFeatureName} `\"core-features-and-limits\"`.\n * </div>\n */\n viewFormats?: Iterable<GPUTextureFormat>;\n /**\n * <div class=compatmode>\n * On devices without {@link GPUFeatureName} `\"core-features-and-limits\"`,\n * views created from this texture must have this as their {@link GPUTextureViewDescriptor#dimension}.\n * If not specified, a default is chosen.\n * </div>\n * On devices with {@link GPUFeatureName} `\"core-features-and-limits\"`,\n * this is ignored, and there is no such restriction.\n */\n textureBindingViewDimension?: GPUTextureViewDimension;\n }\n\n interface GPUTextureViewDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * The format of the texture view. Must be either the {@link GPUTextureDescriptor#format} of the\n * texture or one of the {@link GPUTextureDescriptor#viewFormats} specified during its creation.\n */\n format?: GPUTextureFormat;\n /**\n * The dimension to view the texture as.\n */\n dimension?: GPUTextureViewDimension;\n /**\n * The allowed {@link GPUTextureUsage | usage(s)} for the texture view. Must be a subset of the\n * {@link GPUTexture#usage} flags of the texture. If 0, defaults to the full set of\n * {@link GPUTexture#usage} flags of the texture.\n * Note: If the view's {@link GPUTextureViewDescriptor#format} doesn't support all of the\n * texture's {@link GPUTextureDescriptor#usage}s, the default will fail,\n * and the view's {@link GPUTextureViewDescriptor#usage} must be specified explicitly.\n */\n usage?: GPUTextureUsageFlags;\n /**\n * Which {@link GPUTextureAspect | aspect(s)} of the texture are accessible to the texture view.\n */\n aspect?: GPUTextureAspect;\n /**\n * The first (most detailed) mipmap level accessible to the texture view.\n */\n baseMipLevel?: GPUIntegerCoordinate;\n /**\n * How many mipmap levels, starting with {@link GPUTextureViewDescriptor#baseMipLevel}, are accessible to\n * the texture view.\n */\n mipLevelCount?: GPUIntegerCoordinate;\n /**\n * The index of the first array layer accessible to the texture view.\n */\n baseArrayLayer?: GPUIntegerCoordinate;\n /**\n * How many array layers, starting with {@link GPUTextureViewDescriptor#baseArrayLayer}, are accessible\n * to the texture view.\n */\n arrayLayerCount?: GPUIntegerCoordinate;\n /**\n * A string of length four, with each character mapping to the texture view's red/green/blue/alpha\n * channels, respectively.\n * When accessed by a shader, the red/green/blue/alpha channels are replaced by the value\n * corresponding to the component specified in `swizzle[0]`, `swizzle[1]`, `swizzle[2]`, and\n * `swizzle[3]`, respectively:\n * - `\"r\"`: Take its value from the red channel of the texture.\n * - `\"g\"`: Take its value from the green channel of the texture.\n * - `\"b\"`: Take its value from the blue channel of the texture.\n * - `\"a\"`: Take its value from the alpha channel of the texture.\n * - `\"0\"`: Force its value to 0.\n * - `\"1\"`: Force its value to 1.\n * Requires the {@link GPUFeatureName} `\"texture-component-swizzle\"` feature to be enabled.\n */\n swizzle?: string;\n }\n\n interface GPUUncapturedErrorEventInit\n extends EventInit {\n error: GPUError;\n }\n\n interface GPUVertexAttribute {\n /**\n * The {@link GPUVertexFormat} of the attribute.\n */\n format: GPUVertexFormat;\n /**\n * The offset, in bytes, from the beginning of the element to the data for the attribute.\n */\n offset: GPUSize64;\n /**\n * The numeric location associated with this attribute, which will correspond with a\n * <a href=\"https://gpuweb.github.io/gpuweb/wgsl/#input-output-locations\">\"@location\" attribute</a>\n * declared in the {@link GPURenderPipelineDescriptor#vertex}.{@link GPUProgrammableStage#module | module}.\n */\n shaderLocation: GPUIndex32;\n }\n\n interface GPUVertexBufferLayout {\n /**\n * The stride, in bytes, between elements of this array.\n */\n arrayStride: GPUSize64;\n /**\n * Whether each element of this array represents per-vertex data or per-instance data\n */\n stepMode?: GPUVertexStepMode;\n /**\n * An array defining the layout of the vertex attributes within each element.\n */\n attributes: Iterable<GPUVertexAttribute>;\n }\n\n interface GPUVertexState\n extends GPUProgrammableStage {\n /**\n * A list of {@link GPUVertexBufferLayout}s, each defining the layout of vertex attribute data in a\n * vertex buffer used by this pipeline.\n */\n buffers?: Iterable<\n | GPUVertexBufferLayout\n | null\n | undefined\n >;\n }\n\n interface GPUBindingCommandsMixin {\n /**\n * Sets the current {@link GPUBindGroup} for the given index.\n * @param index - The index to set the bind group at.\n * @param bindGroup - Bind group to use for subsequent render or compute commands.\n * @param dynamicOffsets - Array containing buffer offsets in bytes for each entry in\n * \t`bindGroup` marked as {@link GPUBindGroupLayoutEntry#buffer}.{@link GPUBufferBindingLayout#hasDynamicOffset}.-->\n */\n setBindGroup(\n index: GPUIndex32,\n bindGroup:\n | GPUBindGroup\n | null\n | undefined,\n dynamicOffsets?: Iterable<GPUBufferDynamicOffset>\n ): undefined;\n /**\n * Sets the current {@link GPUBindGroup} for the given index, specifying dynamic offsets as a subset\n * of a Uint32Array.\n * @param index - The index to set the bind group at.\n * @param bindGroup - Bind group to use for subsequent render or compute commands.\n * @param dynamicOffsetsData - Array containing buffer offsets in bytes for each entry in\n * \t`bindGroup` marked as {@link GPUBindGroupLayoutEntry#buffer}.{@link GPUBufferBindingLayout#hasDynamicOffset}.\n * @param dynamicOffsetsDataStart - Offset in elements into `dynamicOffsetsData` where the\n * \tbuffer offset data begins.\n * @param dynamicOffsetsDataLength - Number of buffer offsets to read from `dynamicOffsetsData`.\n */\n setBindGroup(\n index: GPUIndex32,\n bindGroup:\n | GPUBindGroup\n | null\n | undefined,\n dynamicOffsetsData: Uint32Array,\n dynamicOffsetsDataStart: GPUSize64,\n dynamicOffsetsDataLength: GPUSize32\n ): undefined;\n /**\n * Sets immediate data for subsequent render or compute commands.\n * @param rangeOffset - Offset in bytes into the immediate data range to begin writing at.\n * @param data - Data to write into the immediate data range.\n * @param dataOffset - Offset into `data` to begin writing from. Given in elements if\n * \t`data` is a {@link TypedArray} and bytes otherwise.\n * @param dataSize - Size of content to write from `data`. Given in elements if\n * \t`data` is a {@link TypedArray} and bytes otherwise.\n */\n setImmediates(\n rangeOffset: GPUSize32,\n data: GPUAllowSharedBufferSource,\n dataOffset?: GPUSize64,\n dataSize?: GPUSize64\n ): undefined;\n }\n\n interface GPUCommandsMixin {}\n\n interface GPUDebugCommandsMixin {\n /**\n * Begins a labeled debug group containing subsequent commands.\n * @param groupLabel - The label for the command group.\n */\n pushDebugGroup(\n groupLabel: string\n ): undefined;\n /**\n * Ends the labeled debug group most recently started by {@link GPUDebugCommandsMixin#pushDebugGroup}.\n */\n popDebugGroup(): undefined;\n /**\n * Marks a point in a stream of commands with a label.\n * @param markerLabel - The label to insert.\n */\n insertDebugMarker(\n markerLabel: string\n ): undefined;\n }\n\n interface GPUObjectBase {\n label: string;\n }\n\n interface GPUPipelineBase {\n /**\n * Gets a {@link GPUBindGroupLayout} that is compatible with the {@link GPUPipelineBase}'s\n * {@link GPUBindGroupLayout} at `index`.\n * @param index - Index into the pipeline layout's {@link GPUPipelineLayout}.`[[bindGroupLayouts]]`\n * \tsequence.\n */\n getBindGroupLayout(\n index: number\n ): GPUBindGroupLayout;\n }\n\n interface GPURenderCommandsMixin {\n /**\n * Sets the current {@link GPURenderPipeline}.\n * @param pipeline - The render pipeline to use for subsequent drawing commands.\n */\n setPipeline(\n pipeline: GPURenderPipeline\n ): undefined;\n /**\n * Sets the current index buffer.\n * @param buffer - Buffer containing index data to use for subsequent drawing commands.\n * @param indexFormat - Format of the index data contained in `buffer`.\n * @param offset - Offset in bytes into `buffer` where the index data begins. Defaults to `0`.\n * @param size - Size in bytes of the index data in `buffer`.\n * \tDefaults to the size of the buffer minus the offset.\n */\n setIndexBuffer(\n buffer: GPUBuffer,\n indexFormat: GPUIndexFormat,\n offset?: GPUSize64,\n size?: GPUSize64\n ): undefined;\n /**\n * Sets the current vertex buffer for the given slot.\n * @param slot - The vertex buffer slot to set the vertex buffer for.\n * @param buffer - Buffer containing vertex data to use for subsequent drawing commands.\n * @param offset - Offset in bytes into `buffer` where the vertex data begins. Defaults to `0`.\n * @param size - Size in bytes of the vertex data in `buffer`.\n * \tDefaults to the size of the buffer minus the offset.\n */\n setVertexBuffer(\n slot: GPUIndex32,\n buffer:\n | GPUBuffer\n | null\n | undefined,\n offset?: GPUSize64,\n size?: GPUSize64\n ): undefined;\n /**\n * Draws primitives.\n * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification.\n * @param vertexCount - The number of vertices to draw.\n * @param instanceCount - The number of instances to draw.\n * @param firstVertex - Offset into the vertex buffers, in vertices, to begin drawing from.\n * @param firstInstance - First instance to draw.\n */\n draw(\n vertexCount: GPUSize32,\n instanceCount?: GPUSize32,\n firstVertex?: GPUSize32,\n firstInstance?: GPUSize32\n ): undefined;\n /**\n * Draws indexed primitives.\n * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification.\n * @param indexCount - The number of indices to draw.\n * @param instanceCount - The number of instances to draw.\n * @param firstIndex - Offset into the index buffer, in indices, begin drawing from.\n * @param baseVertex - Added to each index value before indexing into the vertex buffers.\n * @param firstInstance - First instance to draw.\n */\n drawIndexed(\n indexCount: GPUSize32,\n instanceCount?: GPUSize32,\n firstIndex?: GPUSize32,\n baseVertex?: GPUSignedOffset32,\n firstInstance?: GPUSize32\n ): undefined;\n /**\n * Draws primitives using parameters read from a {@link GPUBuffer}.\n * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification.\n * packed block of **four 32-bit unsigned integer values (16 bytes total)**, given in the same\n * order as the arguments for {@link GPURenderCommandsMixin#draw}. For example:\n * @param indirectBuffer - Buffer containing the indirect draw parameters.\n * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.\n */\n drawIndirect(\n indirectBuffer: GPUBuffer,\n indirectOffset: GPUSize64\n ): undefined;\n /**\n * Draws indexed primitives using parameters read from a {@link GPUBuffer}.\n * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification.\n * tightly packed block of **five 32-bit unsigned integer values (20 bytes total)**, given in\n * the same order as the arguments for {@link GPURenderCommandsMixin#drawIndexed}. For example:\n * @param indirectBuffer - Buffer containing the indirect drawIndexed parameters.\n * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.\n */\n drawIndexedIndirect(\n indirectBuffer: GPUBuffer,\n indirectOffset: GPUSize64\n ): undefined;\n }\n\n interface NavigatorGPU {\n /**\n * A global singleton providing top-level entry points like {@link GPU#requestAdapter}.\n */\n readonly gpu: GPU;\n }\n\n interface GPU {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPU\";\n /**\n * Requests an adapter from the user agent.\n * The user agent chooses whether to return an adapter, and, if so,\n * chooses according to the provided options.\n * @param options - Criteria used to select the adapter.\n */\n requestAdapter(\n options?: GPURequestAdapterOptions\n ): Promise<GPUAdapter | null>;\n /**\n * Returns an optimal {@link GPUTextureFormat} for displaying 8-bit depth, standard dynamic range\n * content on this system. Must only return {@link GPUTextureFormat} `\"rgba8unorm\"` or\n * {@link GPUTextureFormat} `\"bgra8unorm\"`.\n * The returned value can be passed as the {@link GPUCanvasConfiguration#format} to\n * {@link GPUCanvasContext#configure} calls on a {@link GPUCanvasContext} to ensure the associated\n * canvas is able to display its contents efficiently.\n * Note: Canvases which are not displayed to the screen may or may not benefit from using this\n * format.\n */\n getPreferredCanvasFormat(): GPUTextureFormat;\n readonly wgslLanguageFeatures: WGSLLanguageFeatures;\n }\n\n var GPU: {\n prototype: GPU;\n new (): never;\n };\n\n interface GPUAdapter {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUAdapter\";\n /**\n * The set of values in `this`.{@link GPUAdapter#[[adapter]]}.{@link adapter#[[features]]}.\n */\n readonly features: GPUSupportedFeatures;\n /**\n * The limits in `this`.{@link GPUAdapter#[[adapter]]}.{@link adapter#[[limits]]}.\n */\n readonly limits: GPUSupportedLimits;\n /**\n * Information about the physical adapter underlying this {@link GPUAdapter}.\n * For a given {@link GPUAdapter}, the {@link GPUAdapterInfo} values exposed are constant over time.\n * The same object is returned each time. To create that object for the first time:\n * <div algorithm=GPUAdapter.info>\n * <div data-timeline=content>\n * **Called on:** {@link GPUAdapter} `this`.\n * **Returns:** {@link GPUAdapterInfo}\n * Content timeline steps:\n * 1. Return a [$new adapter info$] for `this.adapter`.\n * </div>\n * </div>\n */\n readonly info: GPUAdapterInfo;\n /**\n * Requests a device from the adapter.\n * This is a one-time action: if a device is returned successfully,\n * the adapter becomes {@link adapter#[[state]]#\"consumed\"}.\n * @param descriptor - Description of the {@link GPUDevice} to request.\n */\n requestDevice(\n descriptor?: GPUDeviceDescriptor\n ): Promise<GPUDevice>;\n }\n\n var GPUAdapter: {\n prototype: GPUAdapter;\n new (): never;\n };\n\n interface GPUAdapterInfo {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUAdapterInfo\";\n /**\n * The name of the vendor of the adapter, if available. Empty string otherwise.\n */\n readonly vendor: string;\n /**\n * The name of the family or class of GPUs the adapter belongs to, if available. Empty\n * string otherwise.\n */\n readonly architecture: string;\n /**\n * A vendor-specific identifier for the adapter, if available. Empty string otherwise.\n * Note: This is a value that represents the type of adapter. For example, it may be a\n * [PCI device ID](https://pcisig.com/). It does not uniquely identify a given piece of\n * hardware like a serial number.\n */\n readonly device: string;\n /**\n * A human readable string describing the adapter as reported by the driver, if available.\n * Empty string otherwise.\n * Note: Because no formatting is applied to {@link GPUAdapterInfo#description} attempting to parse\n * this value is not recommended. Applications which change their behavior based on the\n * {@link GPUAdapterInfo}, such as applying workarounds for known driver issues, should rely on the\n * other fields when possible.\n */\n readonly description: string;\n /**\n * If the \"subgroups\" feature is supported, the minimum supported subgroup size for the\n * adapter.\n *\n * @todo Temporarily optional until all browsers have implemented it.\n * Check support before using. (Use the non-null assertion operator `!` where needed.)\n */\n readonly subgroupMinSize?: number;\n /**\n * If the \"subgroups\" feature is supported, the maximum supported subgroup size for the\n * adapter.\n *\n * @todo Temporarily optional until all browsers have implemented it.\n * Check support before using. (Use the non-null assertion operator `!` where needed.)\n */\n readonly subgroupMaxSize?: number;\n /**\n * Whether the adapter is a fallback adapter.\n **/\n readonly isFallbackAdapter: boolean;\n }\n\n var GPUAdapterInfo: {\n prototype: GPUAdapterInfo;\n new (): never;\n };\n\n interface GPUBindGroup\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUBindGroup\";\n }\n\n var GPUBindGroup: {\n prototype: GPUBindGroup;\n new (): never;\n };\n\n interface GPUBindGroupLayout\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUBindGroupLayout\";\n }\n\n var GPUBindGroupLayout: {\n prototype: GPUBindGroupLayout;\n new (): never;\n };\n\n interface GPUBuffer\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUBuffer\";\n readonly size: GPUSize64Out;\n readonly usage: GPUFlagsConstant;\n readonly mapState: GPUBufferMapState;\n /**\n * Maps the given range of the {@link GPUBuffer} and resolves the returned Promise when the\n * {@link GPUBuffer}'s content is ready to be accessed with {@link GPUBuffer#getMappedRange}.\n * The resolution of the returned Promise **only** indicates that the buffer has been mapped.\n * It does not guarantee the completion of any other operations visible to the content timeline,\n * and in particular does not imply that any other Promise returned from\n * {@link GPUQueue#onSubmittedWorkDone()} or {@link GPUBuffer#mapAsync} on other {@link GPUBuffer}s\n * have resolved.\n * The resolution of the Promise returned from {@link GPUQueue#onSubmittedWorkDone}\n * **does** imply the completion of\n * {@link GPUBuffer#mapAsync} calls made prior to that call,\n * on {@link GPUBuffer}s last used exclusively on that queue.\n * @param mode - Whether the buffer should be mapped for reading or writing.\n * @param offset - Offset in bytes into the buffer to the start of the range to map.\n * @param size - Size in bytes of the range to map.\n */\n mapAsync(\n mode: GPUMapModeFlags,\n offset?: GPUSize64,\n size?: GPUSize64\n ): Promise<undefined>;\n /**\n * Returns an ArrayBuffer with the contents of the {@link GPUBuffer} in the given mapped range.\n * @param offset - Offset in bytes into the buffer to return buffer contents from.\n * @param size - Size in bytes of the ArrayBuffer to return.\n */\n getMappedRange(\n offset?: GPUSize64,\n size?: GPUSize64\n ): ArrayBuffer;\n /**\n * Unmaps the mapped range of the {@link GPUBuffer} and makes its contents available for use by the\n * GPU again.\n */\n unmap(): undefined;\n /**\n * Destroys the {@link GPUBuffer}.\n * Note: It is valid to destroy a buffer multiple times.\n * Note: Since no further operations can be enqueued using this buffer, implementations can\n * free resource allocations, including mapped memory that was just unmapped.\n */\n destroy(): undefined;\n }\n\n var GPUBuffer: {\n prototype: GPUBuffer;\n new (): never;\n };\n\n interface GPUCanvasContext {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUCanvasContext\";\n /**\n * The canvas this context was created from.\n */\n readonly canvas:\n | HTMLCanvasElement\n | OffscreenCanvas;\n /**\n * Configures the context for this canvas.\n * This clears the drawing buffer to transparent black (in [$Replace the drawing buffer$]).\n * See {@link GPUCanvasContext#getConfiguration} for information on feature detection.\n * @param configuration - Desired configuration for the context.\n */\n configure(\n configuration: GPUCanvasConfiguration\n ): undefined;\n /**\n * Removes the context configuration. Destroys any textures produced while configured.\n */\n unconfigure(): undefined;\n /**\n * Returns the context configuration, or `null` if the context is not configured.\n * Note:\n * This method exists primarily for feature detection of members (and sub-members) of\n * {@link GPUCanvasConfiguration}; see those members for details.\n * For supported members, it returns the originally-supplied values.\n */\n getConfiguration(): GPUCanvasConfigurationOut | null;\n /**\n * Get the {@link GPUTexture} that will be composited to the document by the {@link GPUCanvasContext}\n * next.\n * Note: The same {@link GPUTexture} object will be returned by every\n * call to {@link GPUCanvasContext#getCurrentTexture} until \"[$Expire the current texture$]\"\n * runs, even if that {@link GPUTexture} is destroyed, failed validation, or failed to allocate.\n */\n getCurrentTexture(): GPUTexture;\n }\n\n var GPUCanvasContext: {\n prototype: GPUCanvasContext;\n new (): never;\n };\n\n interface GPUCommandBuffer\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUCommandBuffer\";\n }\n\n var GPUCommandBuffer: {\n prototype: GPUCommandBuffer;\n new (): never;\n };\n\n interface GPUCommandEncoder\n extends GPUObjectBase,\n GPUCommandsMixin,\n GPUDebugCommandsMixin {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUCommandEncoder\";\n /**\n * Begins encoding a render pass described by `descriptor`.\n * @param descriptor - Description of the {@link GPURenderPassEncoder} to create.\n */\n beginRenderPass(\n descriptor: GPURenderPassDescriptor\n ): GPURenderPassEncoder;\n beginComputePass(\n descriptor?: GPUComputePassDescriptor\n ): GPUComputePassEncoder;\n /**\n * Shorthand, equivalent to {@link GPUCommandEncoder#copyBufferToBuffer}.\n */\n copyBufferToBuffer(\n source: GPUBuffer,\n destination: GPUBuffer,\n size?: GPUSize64\n ): undefined;\n /**\n * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a\n * {@link GPUBuffer} to a sub-region of another {@link GPUBuffer}.\n * @param source - The {@link GPUBuffer} to copy from.\n * @param sourceOffset - Offset in bytes into `source` to begin copying from.\n * @param destination - The {@link GPUBuffer} to copy to.\n * @param destinationOffset - Offset in bytes into `destination` to place the copied data.\n * @param size - Bytes to copy. Defaults to the size of the buffer `source` minus `sourceOffset`.\n */\n copyBufferToBuffer(\n source: GPUBuffer,\n sourceOffset: GPUSize64,\n destination: GPUBuffer,\n destinationOffset: GPUSize64,\n size?: GPUSize64\n ): undefined;\n /**\n * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a\n * {@link GPUBuffer} to a sub-region of one or multiple continuous texture subresources.\n * @param source - Combined with `copySize`, defines the region of the source buffer.\n * @param destination - Combined with `copySize`, defines the region of the destination texture subresource.\n * \t`copySize`:\n */\n copyBufferToTexture(\n source: GPUTexelCopyBufferInfo,\n destination: GPUTexelCopyTextureInfo,\n copySize: GPUExtent3DStrict\n ): undefined;\n /**\n * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one or\n * multiple continuous texture subresources to a sub-region of a {@link GPUBuffer}.\n * @param source - Combined with `copySize`, defines the region of the source texture subresources.\n * @param destination - Combined with `copySize`, defines the region of the destination buffer.\n * \t`copySize`:\n */\n copyTextureToBuffer(\n source: GPUTexelCopyTextureInfo,\n destination: GPUTexelCopyBufferInfo,\n copySize: GPUExtent3DStrict\n ): undefined;\n /**\n * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one\n * or multiple contiguous texture subresources to another sub-region of one or\n * multiple continuous texture subresources.\n * @param source - Combined with `copySize`, defines the region of the source texture subresources.\n * @param destination - Combined with `copySize`, defines the region of the destination texture subresources.\n * \t`copySize`:\n */\n copyTextureToTexture(\n source: GPUTexelCopyTextureInfo,\n destination: GPUTexelCopyTextureInfo,\n copySize: GPUExtent3DStrict\n ): undefined;\n /**\n * Encode a command into the {@link GPUCommandEncoder} that fills a sub-region of a\n * {@link GPUBuffer} with zeros.\n * @param buffer - The {@link GPUBuffer} to clear.\n * @param offset - Offset in bytes into `buffer` where the sub-region to clear begins.\n * @param size - Size in bytes of the sub-region to clear. Defaults to the size of the buffer minus `offset`.\n */\n clearBuffer(\n buffer: GPUBuffer,\n offset?: GPUSize64,\n size?: GPUSize64\n ): undefined;\n /**\n * Resolves query results from a {@link GPUQuerySet} out into a range of a {@link GPUBuffer}.\n * \tquerySet:\n * \tfirstQuery:\n * \tqueryCount:\n * \tdestination:\n * \tdestinationOffset:\n */\n resolveQuerySet(\n querySet: GPUQuerySet,\n firstQuery: GPUSize32,\n queryCount: GPUSize32,\n destination: GPUBuffer,\n destinationOffset: GPUSize64\n ): undefined;\n /**\n * Completes recording of the commands sequence and returns a corresponding {@link GPUCommandBuffer}.\n * \tdescriptor:\n */\n finish(\n descriptor?: GPUCommandBufferDescriptor\n ): GPUCommandBuffer;\n }\n\n var GPUCommandEncoder: {\n prototype: GPUCommandEncoder;\n new (): never;\n };\n\n interface GPUCompilationInfo {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUCompilationInfo\";\n readonly messages: ReadonlyArray<GPUCompilationMessage>;\n }\n\n var GPUCompilationInfo: {\n prototype: GPUCompilationInfo;\n new (): never;\n };\n\n interface GPUCompilationMessage {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUCompilationMessage\";\n /**\n * The human-readable, localizable text for this compilation message.\n * Note: The {@link GPUCompilationMessage#message} should follow the best practices for language\n * and direction information. This includes making use of any future standards which may\n * emerge regarding the reporting of string language and direction metadata.\n * <p class=\"note editorial\"><span class=marker>Editorial note:</span>\n * At the time of this writing, no language/direction recommendation is available that provides\n * compatibility and consistency with legacy APIs, but when there is, adopt it formally.\n */\n readonly message: string;\n /**\n * The severity level of the message.\n * If the {@link GPUCompilationMessage#type} is {@link GPUCompilationMessageType} `\"error\"`, it\n * corresponds to a shader-creation error.\n */\n readonly type: GPUCompilationMessageType;\n /**\n * The line number in the shader {@link GPUShaderModuleDescriptor#code} the\n * {@link GPUCompilationMessage#message} corresponds to. Value is one-based, such that a lineNum of\n * `1` indicates the first line of the shader {@link GPUShaderModuleDescriptor#code}. Lines are\n * delimited by line breaks.\n * If the {@link GPUCompilationMessage#message} corresponds to a substring this points to\n * the line on which the substring begins. Must be `0` if the {@link GPUCompilationMessage#message}\n * does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}.\n */\n readonly lineNum: number;\n /**\n * The offset, in UTF-16 code units, from the beginning of line {@link GPUCompilationMessage#lineNum}\n * of the shader {@link GPUShaderModuleDescriptor#code} to the point or beginning of the substring\n * that the {@link GPUCompilationMessage#message} corresponds to. Value is one-based, such that a\n * {@link GPUCompilationMessage#linePos} of `1` indicates the first code unit of the line.\n * If {@link GPUCompilationMessage#message} corresponds to a substring this points to the\n * first UTF-16 code unit of the substring. Must be `0` if the {@link GPUCompilationMessage#message}\n * does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}.\n */\n readonly linePos: number;\n /**\n * The offset from the beginning of the shader {@link GPUShaderModuleDescriptor#code} in UTF-16\n * code units to the point or beginning of the substring that {@link GPUCompilationMessage#message}\n * corresponds to. Must reference the same position as {@link GPUCompilationMessage#lineNum} and\n * {@link GPUCompilationMessage#linePos}. Must be `0` if the {@link GPUCompilationMessage#message}\n * does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}.\n */\n readonly offset: number;\n /**\n * The number of UTF-16 code units in the substring that {@link GPUCompilationMessage#message}\n * corresponds to. If the message does not correspond with a substring then\n * {@link GPUCompilationMessage#length} must be 0.\n */\n readonly length: number;\n }\n\n var GPUCompilationMessage: {\n prototype: GPUCompilationMessage;\n new (): never;\n };\n\n interface GPUComputePassEncoder\n extends GPUObjectBase,\n GPUCommandsMixin,\n GPUDebugCommandsMixin,\n GPUBindingCommandsMixin {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUComputePassEncoder\";\n /**\n * Sets the current {@link GPUComputePipeline}.\n * @param pipeline - The compute pipeline to use for subsequent dispatch commands.\n */\n setPipeline(\n pipeline: GPUComputePipeline\n ): undefined;\n /**\n * Dispatch work to be performed with the current {@link GPUComputePipeline}.\n * See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification.\n * @param workgroupCountX - X dimension of the grid of workgroups to dispatch.\n * @param workgroupCountY - Y dimension of the grid of workgroups to dispatch.\n * @param workgroupCountZ - Z dimension of the grid of workgroups to dispatch.\n */\n dispatchWorkgroups(\n workgroupCountX: GPUSize32,\n workgroupCountY?: GPUSize32,\n workgroupCountZ?: GPUSize32\n ): undefined;\n /**\n * Dispatch work to be performed with the current {@link GPUComputePipeline} using parameters read\n * from a {@link GPUBuffer}.\n * See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification.\n * packed block of **three 32-bit unsigned integer values (12 bytes total)**,\n * given in the same order as the arguments for {@link GPUComputePassEncoder#dispatchWorkgroups}.\n * For example:\n * @param indirectBuffer - Buffer containing the indirect dispatch parameters.\n * @param indirectOffset - Offset in bytes into `indirectBuffer` where the dispatch data begins.\n */\n dispatchWorkgroupsIndirect(\n indirectBuffer: GPUBuffer,\n indirectOffset: GPUSize64\n ): undefined;\n /**\n * Completes recording of the compute pass commands sequence.\n */\n end(): undefined;\n }\n\n var GPUComputePassEncoder: {\n prototype: GPUComputePassEncoder;\n new (): never;\n };\n\n interface GPUComputePipeline\n extends GPUObjectBase,\n GPUPipelineBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUComputePipeline\";\n }\n\n var GPUComputePipeline: {\n prototype: GPUComputePipeline;\n new (): never;\n };\n\n interface GPUDevice\n extends EventTarget,\n GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUDevice\";\n /**\n * A set containing the {@link GPUFeatureName} values of the features\n * supported by the device (i.e. the ones with which it was created).\n */\n readonly features: GPUSupportedFeatures;\n /**\n * Exposes the limits supported by the device\n * (which are exactly the ones with which it was created).\n */\n readonly limits: GPUSupportedLimits;\n /**\n * Information about the physical adapter which created the device\n * that this GPUDevice refers to.\n * For a given GPUDevice, the GPUAdapterInfo values exposed are constant\n * over time.\n */\n readonly adapterInfo: GPUAdapterInfo;\n /**\n * The primary {@link GPUQueue} for this device.\n */\n readonly queue: GPUQueue;\n /**\n * Destroys the device, preventing further operations on it.\n * Outstanding asynchronous operations will fail.\n * Note: It is valid to destroy a device multiple times.\n * Note: Since no further operations can be enqueued on this device, implementations can abort\n * outstanding asynchronous operations immediately and free resource allocations, including\n * mapped memory that was just unmapped.\n */\n destroy(): undefined;\n /**\n * Creates a {@link GPUBuffer}.\n * @param descriptor - Description of the {@link GPUBuffer} to create.\n */\n createBuffer(\n descriptor: GPUBufferDescriptor\n ): GPUBuffer;\n /**\n * Creates a {@link GPUTexture}.\n * @param descriptor - Description of the {@link GPUTexture} to create.\n */\n createTexture(\n descriptor: GPUTextureDescriptor\n ): GPUTexture;\n /**\n * Creates a {@link GPUSampler}.\n * @param descriptor - Description of the {@link GPUSampler} to create.\n */\n createSampler(\n descriptor?: GPUSamplerDescriptor\n ): GPUSampler;\n /**\n * Creates a {@link GPUExternalTexture} wrapping the provided image source.\n * @param descriptor - Provides the external image source object (and any creation options).\n */\n importExternalTexture(\n descriptor: GPUExternalTextureDescriptor\n ): GPUExternalTexture;\n /**\n * Creates a {@link GPUBindGroupLayout}.\n * @param descriptor - Description of the {@link GPUBindGroupLayout} to create.\n */\n createBindGroupLayout(\n descriptor: GPUBindGroupLayoutDescriptor\n ): GPUBindGroupLayout;\n /**\n * Creates a {@link GPUPipelineLayout}.\n * @param descriptor - Description of the {@link GPUPipelineLayout} to create.\n */\n createPipelineLayout(\n descriptor: GPUPipelineLayoutDescriptor\n ): GPUPipelineLayout;\n /**\n * Creates a {@link GPUBindGroup}.\n * @param descriptor - Description of the {@link GPUBindGroup} to create.\n */\n createBindGroup(\n descriptor: GPUBindGroupDescriptor\n ): GPUBindGroup;\n /**\n * Creates a {@link GPUShaderModule}.\n * @param descriptor - Description of the {@link GPUShaderModule} to create.\n */\n createShaderModule(\n descriptor: GPUShaderModuleDescriptor\n ): GPUShaderModule;\n /**\n * Creates a {@link GPUComputePipeline} using immediate pipeline creation.\n * @param descriptor - Description of the {@link GPUComputePipeline} to create.\n */\n createComputePipeline(\n descriptor: GPUComputePipelineDescriptor\n ): GPUComputePipeline;\n /**\n * Creates a {@link GPURenderPipeline} using immediate pipeline creation.\n * @param descriptor - Description of the {@link GPURenderPipeline} to create.\n */\n createRenderPipeline(\n descriptor: GPURenderPipelineDescriptor\n ): GPURenderPipeline;\n /**\n * Creates a {@link GPUComputePipeline} using async pipeline creation.\n * The returned Promise resolves when the created pipeline\n * is ready to be used without additional delay.\n * If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}.\n * (A {@link GPUError} is not dispatched to the device.)\n * Note: Use of this method is preferred whenever possible, as it prevents blocking the\n * queue timeline work on pipeline compilation.\n * @param descriptor - Description of the {@link GPUComputePipeline} to create.\n */\n createComputePipelineAsync(\n descriptor: GPUComputePipelineDescriptor\n ): Promise<GPUComputePipeline>;\n /**\n * Creates a {@link GPURenderPipeline} using async pipeline creation.\n * The returned Promise resolves when the created pipeline\n * is ready to be used without additional delay.\n * If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}.\n * (A {@link GPUError} is not dispatched to the device.)\n * Note: Use of this method is preferred whenever possible, as it prevents blocking the\n * queue timeline work on pipeline compilation.\n * @param descriptor - Description of the {@link GPURenderPipeline} to create.\n */\n createRenderPipelineAsync(\n descriptor: GPURenderPipelineDescriptor\n ): Promise<GPURenderPipeline>;\n /**\n * Creates a {@link GPUCommandEncoder}.\n * @param descriptor - Description of the {@link GPUCommandEncoder} to create.\n */\n createCommandEncoder(\n descriptor?: GPUCommandEncoderDescriptor\n ): GPUCommandEncoder;\n /**\n * Creates a {@link GPURenderBundleEncoder}.\n * @param descriptor - Description of the {@link GPURenderBundleEncoder} to create.\n */\n createRenderBundleEncoder(\n descriptor: GPURenderBundleEncoderDescriptor\n ): GPURenderBundleEncoder;\n /**\n * Creates a {@link GPUQuerySet}.\n * @param descriptor - Description of the {@link GPUQuerySet} to create.\n */\n createQuerySet(\n descriptor: GPUQuerySetDescriptor\n ): GPUQuerySet;\n /**\n * A slot-backed attribute holding a promise which is created with the device, remains\n * pending for the lifetime of the device, then resolves when the device is lost.\n * Upon initialization, it is set to a new promise.\n */\n readonly lost: Promise<GPUDeviceLostInfo>;\n /**\n * Pushes a new GPU error scope onto the {@link GPUDevice}.`[[errorScopeStack]]` for `this`.\n * @param filter - Which class of errors this error scope observes.\n */\n pushErrorScope(\n filter: GPUErrorFilter\n ): undefined;\n /**\n * Pops a GPU error scope off the {@link GPUDevice}.`[[errorScopeStack]]` for `this`\n * and resolves to **any** {@link GPUError} observed by the error scope, or `null` if none.\n * There is no guarantee of the ordering of promise resolution.\n */\n popErrorScope(): Promise<GPUError | null>;\n /**\n * An event handler IDL attribute for the `uncapturederror` event type.\n */\n onuncapturederror:\n | ((\n this: GPUDevice,\n ev: GPUUncapturedErrorEvent\n ) => any)\n | null;\n }\n\n var GPUDevice: {\n prototype: GPUDevice;\n new (): never;\n };\n\n interface GPUDeviceLostInfo {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUDeviceLostInfo\";\n readonly reason: GPUDeviceLostReason;\n readonly message: string;\n }\n\n var GPUDeviceLostInfo: {\n prototype: GPUDeviceLostInfo;\n new (): never;\n };\n\n interface GPUError {\n /**\n * A human-readable, localizable text message providing information about the error that\n * occurred.\n * Note: This message is generally intended for application developers to debug their\n * applications and capture information for debug reports, not to be surfaced to end-users.\n * Note: User agents should not include potentially machine-parsable details in this message,\n * such as free system memory on {@link GPUErrorFilter} `\"out-of-memory\"` or other details about the\n * conditions under which memory was exhausted.\n * Note: The {@link GPUError#message} should follow the best practices for language and\n * direction information. This includes making use of any future standards which may emerge\n * regarding the reporting of string language and direction metadata.\n * <p class=\"note editorial\"><span class=marker>Editorial note:</span>\n * At the time of this writing, no language/direction recommendation is available that provides\n * compatibility and consistency with legacy APIs, but when there is, adopt it formally.\n */\n readonly message: string;\n }\n\n var GPUError: {\n prototype: GPUError;\n new (): never;\n };\n\n interface GPUExternalTexture\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUExternalTexture\";\n }\n\n var GPUExternalTexture: {\n prototype: GPUExternalTexture;\n new (): never;\n };\n\n interface GPUInternalError\n extends GPUError {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUInternalError\";\n }\n\n var GPUInternalError: {\n prototype: GPUInternalError;\n new (\n message: string\n ): GPUInternalError;\n };\n\n interface GPUOutOfMemoryError\n extends GPUError {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUOutOfMemoryError\";\n }\n\n var GPUOutOfMemoryError: {\n prototype: GPUOutOfMemoryError;\n new (\n message: string\n ): GPUOutOfMemoryError;\n };\n\n interface GPUPipelineError\n extends DOMException {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUPipelineError\";\n /**\n * A read-only slot-backed attribute exposing the type of error encountered in pipeline creation\n * as a <dfn enum for=\"\">GPUPipelineErrorReason</dfn>:\n * <ul dfn-type=enum-value dfn-for=GPUPipelineErrorReason>\n * - <dfn>\"validation\"</dfn>: A [$validation error$].\n * - <dfn>\"internal\"</dfn>: An [$internal error$].\n * </ul>\n */\n readonly reason: GPUPipelineErrorReason;\n }\n\n var GPUPipelineError: {\n prototype: GPUPipelineError;\n new (\n message:\n | string\n | undefined,\n options: GPUPipelineErrorInit\n ): GPUPipelineError;\n };\n\n interface GPUPipelineLayout\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUPipelineLayout\";\n }\n\n var GPUPipelineLayout: {\n prototype: GPUPipelineLayout;\n new (): never;\n };\n\n interface GPUQuerySet\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUQuerySet\";\n /**\n * Destroys the {@link GPUQuerySet}.\n */\n destroy(): undefined;\n /**\n * The type of the queries managed by this {@link GPUQuerySet}.\n */\n readonly type: GPUQueryType;\n /**\n * The number of queries managed by this {@link GPUQuerySet}.\n */\n readonly count: GPUSize32Out;\n }\n\n var GPUQuerySet: {\n prototype: GPUQuerySet;\n new (): never;\n };\n\n interface GPUQueue\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUQueue\";\n /**\n * Schedules the execution of the command buffers by the GPU on this queue.\n * Submitted command buffers cannot be used again.\n * \t`commandBuffers`:\n */\n submit(\n commandBuffers: Iterable<GPUCommandBuffer>\n ): undefined;\n /**\n * Returns a Promise that resolves once this queue finishes processing all the work submitted\n * up to this moment.\n * Resolution of this Promise implies the completion of\n * {@link GPUBuffer#mapAsync} calls made prior to that call,\n * on {@link GPUBuffer}s last used exclusively on that queue.\n */\n onSubmittedWorkDone(): Promise<undefined>;\n /**\n * Issues a write operation of the provided data into a {@link GPUBuffer}.\n * @param buffer - The buffer to write to.\n * @param bufferOffset - Offset in bytes into `buffer` to begin writing at.\n * @param data - Data to write into `buffer`.\n * @param dataOffset - Offset in into `data` to begin writing from. Given in elements if\n * \t`data` is a `TypedArray` and bytes otherwise.\n * @param size - Size of content to write from `data` to `buffer`. Given in elements if\n * \t`data` is a `TypedArray` and bytes otherwise.\n */\n writeBuffer(\n buffer: GPUBuffer,\n bufferOffset: GPUSize64,\n data: GPUAllowSharedBufferSource,\n dataOffset?: GPUSize64,\n size?: GPUSize64\n ): undefined;\n /**\n * Issues a write operation of the provided data into a {@link GPUTexture}.\n * @param destination - The texture subresource and origin to write to.\n * @param data - Data to write into `destination`.\n * @param dataLayout - Layout of the content in `data`.\n * @param size - Extents of the content to write from `data` to `destination`.\n */\n writeTexture(\n destination: GPUTexelCopyTextureInfo,\n data: GPUAllowSharedBufferSource,\n dataLayout: GPUTexelCopyBufferLayout,\n size: GPUExtent3DStrict\n ): undefined;\n /**\n * Issues a copy operation of the contents of a platform image/canvas\n * into the destination texture.\n * This operation performs {@link https://www.w3.org/TR/webgpu/#color-space-conversions | color encoding} into the destination\n * encoding according to the parameters of {@link GPUCopyExternalImageDestInfo}.\n * Copying into a `-srgb` texture results in the same texture bytes, not the same decoded\n * values, as copying into the corresponding non-`-srgb` format.\n * Thus, after a copy operation, sampling the destination texture has\n * different results depending on whether its format is `-srgb`, all else unchanged.\n * <!-- POSTV1(srgb-linear): If added, explain here how it interacts. -->\n * @param source - source image and origin to copy to `destination`.\n * @param destination - The texture subresource and origin to write to, and its encoding metadata.\n * @param copySize - Extents of the content to write from `source` to `destination`.\n */\n copyExternalImageToTexture(\n source: GPUCopyExternalImageSourceInfo,\n destination: GPUCopyExternalImageDestInfo,\n copySize: GPUExtent3DStrict\n ): undefined;\n }\n\n var GPUQueue: {\n prototype: GPUQueue;\n new (): never;\n };\n\n interface GPURenderBundle\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPURenderBundle\";\n }\n\n var GPURenderBundle: {\n prototype: GPURenderBundle;\n new (): never;\n };\n\n interface GPURenderBundleEncoder\n extends GPUObjectBase,\n GPUCommandsMixin,\n GPUDebugCommandsMixin,\n GPUBindingCommandsMixin,\n GPURenderCommandsMixin {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPURenderBundleEncoder\";\n /**\n * Completes recording of the render bundle commands sequence.\n * \tdescriptor:\n */\n finish(\n descriptor?: GPURenderBundleDescriptor\n ): GPURenderBundle;\n }\n\n var GPURenderBundleEncoder: {\n prototype: GPURenderBundleEncoder;\n new (): never;\n };\n\n interface GPURenderPassEncoder\n extends GPUObjectBase,\n GPUCommandsMixin,\n GPUDebugCommandsMixin,\n GPUBindingCommandsMixin,\n GPURenderCommandsMixin {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPURenderPassEncoder\";\n /**\n * Sets the viewport used during the rasterization stage to linearly map from\n * NDC|normalized device coordinates to viewport coordinates.\n * @param x - Minimum X value of the viewport in pixels.\n * @param y - Minimum Y value of the viewport in pixels.\n * @param width - Width of the viewport in pixels.\n * @param height - Height of the viewport in pixels.\n * @param minDepth - Minimum depth value of the viewport.\n * @param maxDepth - Maximum depth value of the viewport.\n */\n setViewport(\n x: number,\n y: number,\n width: number,\n height: number,\n minDepth: number,\n maxDepth: number\n ): undefined;\n /**\n * Sets the scissor rectangle used during the rasterization stage.\n * After transformation into viewport coordinates any fragments which fall outside the scissor\n * rectangle will be discarded.\n * @param x - Minimum X value of the scissor rectangle in pixels.\n * @param y - Minimum Y value of the scissor rectangle in pixels.\n * @param width - Width of the scissor rectangle in pixels.\n * @param height - Height of the scissor rectangle in pixels.\n */\n setScissorRect(\n x: GPUIntegerCoordinate,\n y: GPUIntegerCoordinate,\n width: GPUIntegerCoordinate,\n height: GPUIntegerCoordinate\n ): undefined;\n /**\n * Sets the constant blend color and alpha values used with {@link GPUBlendFactor} `\"constant\"`\n * and {@link GPUBlendFactor} `\"one-minus-constant\"` {@link GPUBlendFactor}s.\n * @param color - The color to use when blending.\n */\n setBlendConstant(\n color: GPUColor\n ): undefined;\n /**\n * Sets the RenderState.`[[stencilReference]]` value used during stencil tests with\n * the {@link GPUStencilOperation} `\"replace\"` {@link GPUStencilOperation}.\n * @param reference - The new stencil reference value.\n */\n setStencilReference(\n reference: GPUStencilValue\n ): undefined;\n /**\n * @param queryIndex - The index of the query in the query set.\n */\n beginOcclusionQuery(\n queryIndex: GPUSize32\n ): undefined;\n /**\n */\n endOcclusionQuery(): undefined;\n /**\n * Executes the commands previously recorded into the given {@link GPURenderBundle}s as part of\n * this render pass.\n * When a {@link GPURenderBundle} is executed, it does not inherit the render pass's pipeline, bind\n * groups, or vertex and index buffers. After a {@link GPURenderBundle} has executed, the render\n * pass's pipeline, bind group, and vertex/index buffer state is cleared\n * (to the initial, empty values).\n * Note: The state is cleared, not restored to the previous state.\n * This occurs even if zero {@link GPURenderBundle | GPURenderBundles} are executed.\n * @param bundles - List of render bundles to execute.\n */\n executeBundles(\n bundles: Iterable<GPURenderBundle>\n ): undefined;\n /**\n * Completes recording of the render pass commands sequence.\n */\n end(): undefined;\n }\n\n var GPURenderPassEncoder: {\n prototype: GPURenderPassEncoder;\n new (): never;\n };\n\n interface GPURenderPipeline\n extends GPUObjectBase,\n GPUPipelineBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPURenderPipeline\";\n }\n\n var GPURenderPipeline: {\n prototype: GPURenderPipeline;\n new (): never;\n };\n\n interface GPUSampler\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUSampler\";\n }\n\n var GPUSampler: {\n prototype: GPUSampler;\n new (): never;\n };\n\n interface GPUShaderModule\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUShaderModule\";\n /**\n * Returns any messages generated during the {@link GPUShaderModule}'s compilation.\n * The locations, order, and contents of messages are implementation-defined.\n * In particular, messages aren't necessarily ordered by {@link GPUCompilationMessage#lineNum}.\n */\n getCompilationInfo(): Promise<GPUCompilationInfo>;\n }\n\n var GPUShaderModule: {\n prototype: GPUShaderModule;\n new (): never;\n };\n\n type GPUSupportedFeatures =\n ReadonlySet<string>;\n\n interface GPUSupportedLimits {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUSupportedLimits\";\n readonly maxTextureDimension1D: number;\n readonly maxTextureDimension2D: number;\n readonly maxTextureDimension3D: number;\n readonly maxTextureArrayLayers: number;\n readonly maxBindGroups: number;\n readonly maxBindGroupsPlusVertexBuffers: number;\n readonly maxBindingsPerBindGroup: number;\n readonly maxDynamicUniformBuffersPerPipelineLayout: number;\n readonly maxDynamicStorageBuffersPerPipelineLayout: number;\n readonly maxSampledTexturesPerShaderStage: number;\n readonly maxSamplersPerShaderStage: number;\n readonly maxStorageBuffersPerShaderStage: number;\n /**\n * @todo Temporarily optional until all browsers have implemented it.\n * Check support before using. (Use the non-null assertion operator `!` where needed.)\n */\n readonly maxStorageBuffersInVertexStage?: number;\n /**\n * @todo Temporarily optional until all browsers have implemented it.\n * Check support before using. (Use the non-null assertion operator `!` where needed.)\n */\n readonly maxStorageBuffersInFragmentStage?: number;\n readonly maxStorageTexturesPerShaderStage: number;\n /**\n * @todo Temporarily optional until all browsers have implemented it.\n * Check support before using. (Use the non-null assertion operator `!` where needed.)\n */\n readonly maxStorageTexturesInVertexStage?: number;\n /**\n * @todo Temporarily optional until all browsers have implemented it.\n * Check support before using. (Use the non-null assertion operator `!` where needed.)\n */\n readonly maxStorageTexturesInFragmentStage?: number;\n readonly maxUniformBuffersPerShaderStage: number;\n readonly maxUniformBufferBindingSize: number;\n readonly maxStorageBufferBindingSize: number;\n readonly minUniformBufferOffsetAlignment: number;\n readonly minStorageBufferOffsetAlignment: number;\n readonly maxVertexBuffers: number;\n readonly maxBufferSize: number;\n readonly maxVertexAttributes: number;\n readonly maxVertexBufferArrayStride: number;\n readonly maxInterStageShaderVariables: number;\n readonly maxColorAttachments: number;\n readonly maxColorAttachmentBytesPerSample: number;\n readonly maxComputeWorkgroupStorageSize: number;\n readonly maxComputeInvocationsPerWorkgroup: number;\n readonly maxComputeWorkgroupSizeX: number;\n readonly maxComputeWorkgroupSizeY: number;\n readonly maxComputeWorkgroupSizeZ: number;\n readonly maxComputeWorkgroupsPerDimension: number;\n readonly maxImmediateSize: number;\n }\n\n var GPUSupportedLimits: {\n prototype: GPUSupportedLimits;\n new (): never;\n };\n\n interface GPUTexture\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUTexture\";\n /**\n * Creates a {@link GPUTextureView}.\n * @param descriptor - Description of the {@link GPUTextureView} to create.\n */\n createView(\n descriptor?: GPUTextureViewDescriptor\n ): GPUTextureView;\n /**\n * Destroys the {@link GPUTexture}.\n */\n destroy(): undefined;\n /**\n * The width of this {@link GPUTexture}.\n */\n readonly width: GPUIntegerCoordinateOut;\n /**\n * The height of this {@link GPUTexture}.\n */\n readonly height: GPUIntegerCoordinateOut;\n /**\n * The depth or layer count of this {@link GPUTexture}.\n */\n readonly depthOrArrayLayers: GPUIntegerCoordinateOut;\n /**\n * The number of mip levels of this {@link GPUTexture}.\n */\n readonly mipLevelCount: GPUIntegerCoordinateOut;\n /**\n * The number of sample count of this {@link GPUTexture}.\n */\n readonly sampleCount: GPUSize32Out;\n /**\n * The dimension of the set of texel for each of this {@link GPUTexture}'s subresources.\n */\n readonly dimension: GPUTextureDimension;\n /**\n * The format of this {@link GPUTexture}.\n */\n readonly format: GPUTextureFormat;\n /**\n * The allowed usages for this {@link GPUTexture}.\n */\n readonly usage: GPUFlagsConstant;\n /**\n * On devices without \"core-features-and-limits\", views created from this\n * texture must have this as their dimension.\n *\n * On devices with \"core-features-and-limits\", this is undefined, and there is\n * no such restriction.\n *\n * @todo Temporarily optional until all browsers have implemented it.\n * It is safe to access on any browser, as it will just (correctly) return\n * `undefined` if not implemented. Note, depending on the device, `undefined`\n * is a valid value even in browsers that implement this attribute. (So be\n * careful if using the non-null assertion operator `!` on this.)\n */\n readonly textureBindingViewDimension?:\n | GPUTextureViewDimension\n | undefined;\n }\n\n var GPUTexture: {\n prototype: GPUTexture;\n new (): never;\n };\n\n interface GPUTextureView\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUTextureView\";\n }\n\n var GPUTextureView: {\n prototype: GPUTextureView;\n new (): never;\n };\n\n interface GPUUncapturedErrorEvent\n extends Event {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUUncapturedErrorEvent\";\n /**\n * A slot-backed attribute holding an object representing the error that was uncaptured.\n * This has the same type as errors returned by {@link GPUDevice#popErrorScope}.\n */\n readonly error: GPUError;\n }\n\n var GPUUncapturedErrorEvent: {\n prototype: GPUUncapturedErrorEvent;\n new (\n type: string,\n gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit\n ): GPUUncapturedErrorEvent;\n };\n\n interface GPUValidationError\n extends GPUError {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUValidationError\";\n }\n\n var GPUValidationError: {\n prototype: GPUValidationError;\n new (\n message: string\n ): GPUValidationError;\n };\n\n type WGSLLanguageFeatures =\n ReadonlySet<string>;\n\n interface Navigator\n extends NavigatorGPU {}\n\n interface WorkerNavigator\n extends NavigatorGPU {}\n\n interface GPUBufferUsage {\n readonly MAP_READ: GPUFlagsConstant;\n readonly MAP_WRITE: GPUFlagsConstant;\n readonly COPY_SRC: GPUFlagsConstant;\n readonly COPY_DST: GPUFlagsConstant;\n readonly INDEX: GPUFlagsConstant;\n readonly VERTEX: GPUFlagsConstant;\n readonly UNIFORM: GPUFlagsConstant;\n readonly STORAGE: GPUFlagsConstant;\n readonly INDIRECT: GPUFlagsConstant;\n readonly QUERY_RESOLVE: GPUFlagsConstant;\n }\n\n var GPUBufferUsage: GPUBufferUsage;\n\n interface GPUColorWrite {\n readonly RED: GPUFlagsConstant;\n readonly GREEN: GPUFlagsConstant;\n readonly BLUE: GPUFlagsConstant;\n readonly ALPHA: GPUFlagsConstant;\n readonly ALL: GPUFlagsConstant;\n }\n\n var GPUColorWrite: GPUColorWrite;\n\n interface GPUMapMode {\n readonly READ: GPUFlagsConstant;\n readonly WRITE: GPUFlagsConstant;\n }\n\n var GPUMapMode: GPUMapMode;\n\n interface GPUShaderStage {\n readonly VERTEX: GPUFlagsConstant;\n readonly FRAGMENT: GPUFlagsConstant;\n readonly COMPUTE: GPUFlagsConstant;\n }\n\n var GPUShaderStage: GPUShaderStage;\n\n interface GPUTextureUsage {\n readonly COPY_SRC: GPUFlagsConstant;\n readonly COPY_DST: GPUFlagsConstant;\n readonly TEXTURE_BINDING: GPUFlagsConstant;\n readonly STORAGE_BINDING: GPUFlagsConstant;\n readonly RENDER_ATTACHMENT: GPUFlagsConstant;\n readonly TRANSIENT_ATTACHMENT: GPUFlagsConstant;\n }\n\n var GPUTextureUsage: GPUTextureUsage;\n\n // ===== END WEBGPU TYPES =====\n\n // Runtime global - the main viji object\n const viji: VijiAPI;\n \n // Function type aliases (artists define their own render/setup functions)\n type Render = (viji: VijiAPI) => void;\n type Setup = (viji: VijiAPI) => void;\n}\n\n// Module marker (enables top-level await in artist code)\nexport {};\n";
|
|
1
|
+
export const artistDts = "// Viji Artist API - Global Type Definitions\n// All types are placed inside declare global {} because this file uses export {}\n// for top-level await support, which makes it a module (where top-level declarations\n// would otherwise be module-scoped, not global).\n\ndeclare global {\n /**\r\n * Real-time audio analysis for the main audio stream (`viji.audio`).\r\n * Provides volume, frequency bands, beat detection (with triggers, events, BPM),\r\n * spectral features, and access to raw FFT / waveform data.\r\n *\r\n * All numeric outputs are zeroed when `isConnected` is `false`.\r\n */\r\n interface AudioAPI {\r\n /** `true` when an audio source is connected; otherwise all numeric fields read as `0` and helper methods return empty data. */\r\n isConnected: boolean;\r\n /** Overall loudness across the stream. */\r\n volume: {\r\n /** Instantaneous RMS volume in 0..1. */\r\n current: number;\r\n /** Instantaneous peak amplitude in 0..1. */\r\n peak: number;\r\n /** Volume with a 200ms decay envelope; rises fast, falls smoothly. Use for flicker-free animations. */\r\n smoothed: number;\r\n };\r\n /** Energy in five fixed frequency bands, plus a smoothed companion (~150ms decay) for each. All in 0..1. */\r\n bands: {\r\n /** Instant low-band energy (20-120 Hz, bass/kick range). 0..1. */\r\n low: number;\r\n /** Instant low-mid energy (120-400 Hz). 0..1. */\r\n lowMid: number;\r\n /** Instant mid energy (400-1600 Hz, vocals/instruments). 0..1. */\r\n mid: number;\r\n /** Instant high-mid energy (1600-6000 Hz, cymbals/hi-hats). 0..1. */\r\n highMid: number;\r\n /** Instant high-band energy (6000-16000 Hz, air/brilliance). 0..1. */\r\n high: number;\r\n /** Smoothed `low` (~150ms decay). 0..1. */\r\n lowSmoothed: number;\r\n /** Smoothed `lowMid` (~150ms decay). 0..1. */\r\n lowMidSmoothed: number;\r\n /** Smoothed `mid` (~150ms decay). 0..1. */\r\n midSmoothed: number;\r\n /** Smoothed `highMid` (~150ms decay). 0..1. */\r\n highMidSmoothed: number;\r\n /** Smoothed `high` (~150ms decay). 0..1. */\r\n highSmoothed: number;\r\n };\r\n /** Beat detection: fast/smoothed energy curves, single-frame boolean triggers, raw event list, and BPM tracking. */\r\n beat: {\r\n /** Kick energy curve in 0..1 with a 300ms decay. Peaks on each detected kick. */\r\n kick: number;\r\n /** Snare energy curve in 0..1 with a 300ms decay. */\r\n snare: number;\r\n /** Hi-hat energy curve in 0..1 with a 300ms decay. */\r\n hat: number;\r\n /** Energy curve for any beat type in 0..1 with a 300ms decay. */\r\n any: number;\r\n /** Smoothed `kick` curve in 0..1 with a 500ms decay. Use for ambient pulses. */\r\n kickSmoothed: number;\r\n /** Smoothed `snare` curve in 0..1 with a 500ms decay. */\r\n snareSmoothed: number;\r\n /** Smoothed `hat` curve in 0..1 with a 500ms decay. */\r\n hatSmoothed: number;\r\n /** Smoothed `any` curve in 0..1 with a 500ms decay. */\r\n anySmoothed: number;\r\n /** Single-frame boolean triggers OR-accumulated between frames, so no detected beat is lost. */\r\n triggers: {\r\n /** `true` for one frame when any beat is detected. */\r\n any: boolean;\r\n /** `true` for one frame when a kick is detected. */\r\n kick: boolean;\r\n /** `true` for one frame when a snare is detected. */\r\n snare: boolean;\r\n /** `true` for one frame when a hi-hat is detected. */\r\n hat: boolean;\r\n };\r\n /** All beats detected since the last render frame (zero or more). Cleared each frame. */\r\n events: Array<{\r\n /** Which drum was detected. */\r\n type: 'kick' | 'snare' | 'hat';\r\n /** Timestamp of the detection in milliseconds. */\r\n time: number;\r\n /** Strength of the beat in 0..1. */\r\n strength: number;\r\n }>;\r\n /** Currently detected tempo in beats per minute. Defaults to `120` when no audio. */\r\n bpm: number;\r\n /** Confidence of the BPM tracker in 0..1. */\r\n confidence: number;\r\n /** `true` when the BPM tracker has a stable lock on the current tempo. */\r\n isLocked: boolean;\r\n };\r\n /** High-level spectral features derived from the FFT. */\r\n spectral: {\r\n /** Normalized spectral centroid in 0..1. Higher values mean brighter, more treble-heavy sound. */\r\n brightness: number;\r\n /** Normalized spectral flatness in 0..1. Higher values mean noisier (white-noise-like) sound; lower values mean tonal. */\r\n flatness: number;\r\n };\r\n /**\r\n * Returns the raw FFT magnitude spectrum as a `Uint8Array` (1024 bins, each 0..255).\r\n * Bin `i` covers frequency `i × (sampleRate / fftSize)`. The returned array is a\r\n * snapshot from the latest analysis tick; repeated calls in the same frame return the same data.\r\n *\r\n * @example\r\n * const fft = viji.audio.getFrequencyData();\r\n * for (let i = 0; i < fft.length; i++) drawBar(i, fft[i] / 255);\r\n */\r\n getFrequencyData: () => Uint8Array;\r\n /**\r\n * Returns the raw time-domain waveform as a `Float32Array` (2048 PCM samples in -1..1).\r\n * The returned array is a snapshot; repeated calls in the same frame return the same data.\r\n *\r\n * @example\r\n * const wave = viji.audio.getWaveform();\r\n * for (let i = 0; i < wave.length; i++) drawSample(i, wave[i]);\r\n */\r\n getWaveform: () => Float32Array;\r\n }\r\n\n /**\r\n * Lightweight audio analysis for additional or device audio streams. A strict\r\n * subset of `AudioAPI` that exposes volume, frequency bands, spectral features,\r\n * and raw FFT/waveform access, but **no beat detection** (no `beat`, no BPM,\r\n * no triggers, no events).\r\n */\r\n interface AudioStreamAPI {\r\n /** `true` when this audio stream is connected; otherwise all numeric fields read as `0`. */\r\n isConnected: boolean;\r\n /** Overall loudness across the stream. */\r\n volume: {\r\n /** Instantaneous RMS volume in 0..1. */\r\n current: number;\r\n /** Instantaneous peak amplitude in 0..1. */\r\n peak: number;\r\n /** Volume with a 200ms decay envelope. */\r\n smoothed: number;\r\n };\r\n /** Energy in five fixed frequency bands, plus a smoothed companion (~150ms decay) for each. All in 0..1. */\r\n bands: {\r\n /** Instant low-band energy (20-120 Hz). 0..1. */\r\n low: number;\r\n /** Instant low-mid energy (120-400 Hz). 0..1. */\r\n lowMid: number;\r\n /** Instant mid energy (400-1600 Hz). 0..1. */\r\n mid: number;\r\n /** Instant high-mid energy (1600-6000 Hz). 0..1. */\r\n highMid: number;\r\n /** Instant high-band energy (6000-16000 Hz). 0..1. */\r\n high: number;\r\n /** Smoothed `low` (~150ms decay). 0..1. */\r\n lowSmoothed: number;\r\n /** Smoothed `lowMid` (~150ms decay). 0..1. */\r\n lowMidSmoothed: number;\r\n /** Smoothed `mid` (~150ms decay). 0..1. */\r\n midSmoothed: number;\r\n /** Smoothed `highMid` (~150ms decay). 0..1. */\r\n highMidSmoothed: number;\r\n /** Smoothed `high` (~150ms decay). 0..1. */\r\n highSmoothed: number;\r\n };\r\n /** High-level spectral features derived from the FFT. */\r\n spectral: {\r\n /** Normalized spectral centroid in 0..1. */\r\n brightness: number;\r\n /** Normalized spectral flatness in 0..1. */\r\n flatness: number;\r\n };\r\n /**\r\n * Returns the raw FFT magnitude spectrum for this stream as a `Uint8Array`\r\n * (1024 bins, each 0..255). Snapshot semantics; see `AudioAPI.getFrequencyData`.\r\n */\r\n getFrequencyData: () => Uint8Array;\r\n /**\r\n * Returns the raw time-domain waveform for this stream as a `Float32Array`\r\n * (2048 samples, each -1..1). Snapshot semantics; see `AudioAPI.getWaveform`.\r\n */\r\n getWaveform: () => Float32Array;\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.button()`. The host renders a clickable\r\n * momentary button. The resulting `value` is `true` for one frame after press,\r\n * then auto-resets to `false`.\r\n */\r\n interface ButtonConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Display name shown on the button in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n }\r\n\n /**\r\n * Reactive object returned by `viji.button()`. `value` is a momentary flag:\r\n * `true` for exactly one frame after the user clicks, then auto-resets to\r\n * `false`. Use it to trigger discrete events from `render()`.\r\n */\r\n interface ButtonParameter {\r\n /** `true` for the single frame after the user clicks the button, `false` otherwise. */\r\n value: boolean;\r\n /** Display name shown on the button in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Options accepted by `VijiCore.captureFrame()` for snapshotting the current\r\n * scene. Controls output format, encoding, and target resolution / aspect.\r\n */\r\n interface CaptureFrameOptions {\r\n /** Output format: `'blob'` for an encoded image, `'bitmap'` for a GPU-friendly `ImageBitmap`. Default: `'blob'`. */\r\n format?: 'blob' | 'bitmap';\r\n /**\r\n * MIME type for `'blob'` output (ignored for `'bitmap'`). Examples:\r\n * `'image/png'`, `'image/jpeg'`, `'image/webp'`. Default: `'image/png'`\r\n * (lossless, preserves alpha). Pass a lossy type for smaller files when\r\n * transparency does not matter.\r\n */\r\n type?: string;\r\n /**\r\n * Encoding quality for lossy `'blob'` formats (`'image/jpeg'`, `'image/webp'`),\r\n * from `0` (smallest) to `1` (best). Values outside the range are clamped.\r\n * Ignored for `'image/png'` and for `format: 'bitmap'`. When omitted, the\r\n * browser's default quality is used.\r\n */\r\n quality?: number;\r\n /**\r\n * Target resolution.\r\n * - `number`: scale factor relative to the current canvas size (e.g., `0.5` = 50%).\r\n * - `Resolution`: exact output size. If the aspect ratio differs from the\r\n * canvas, the source is center-cropped before scaling.\r\n */\r\n resolution?: number | Resolution;\r\n /**\r\n * Frame role to capture. `'plate'` (default) captures the clean pre-overlay\r\n * frame — thumbnails and VJ source frames, identical to previous behavior.\r\n * `'display'` captures the composited frame the viewer sees, including the\r\n * branding overlay when the session applies it. On headless cores no\r\n * overlay is ever drawn, so `'display'` degrades to `'plate'`. Note:\r\n * center-cropping via `resolution` can crop the edge-anchored overlay out\r\n * of a `'display'` capture — display captures are intended at canvas aspect.\r\n */\r\n frame?: 'plate' | 'display';\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.color()`. Defines the color picker's\r\n * label and UI grouping/visibility.\r\n */\r\n interface ColorConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Display name shown next to the color swatch in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n /**\r\n * Enable a transparency channel. When `true` the canonical value is always an\r\n * 8-digit `#rrggbbaa` (opaque inputs are padded `ff`), the picker shows an alpha\r\n * slider, and the shader uniform is a `vec4`. When `false` (default) the value is\r\n * `#rrggbb` and any alpha-bearing input is rejected. Default: `false`.\r\n */\r\n alpha?: boolean;\r\n }\r\n\n /**\r\n * Accepted input forms for color parameters. Internally normalized to canonical\r\n * lowercase hex: `#rrggbb` for an opaque parameter, `#rrggbbaa` for a parameter\r\n * declared with `alpha: true`. See `viji.color()` for full documentation.\r\n *\r\n * - `string`: hex (`#rrggbb`, `#rgb`), CSS `rgb(r, g, b)`, CSS `hsl(h, s%, l%)`,\r\n * GLSL-style `vec3(r, g, b)` (0..1), or P5-style `hsb(h, s, b)` (0..360 / 0..100 / 0..100)\r\n * - `{ r, g, b }`: RGB object with components in 0..255\r\n * - `{ h, s, b }`: HSB object with `h` in 0..360, `s` and `b` in 0..100\r\n *\r\n * Alpha-bearing forms (`#rrggbbaa`, `#rgba`, `rgba()`, `hsla()`, `vec4()`, and the\r\n * objects with an `a` field in 0..1) are accepted ONLY by a parameter declared with\r\n * `alpha: true`; an opaque parameter rejects them even when the alpha is `1`.\r\n */\r\n type ColorInput = string | {\r\n /** Red component in 0..255. */\r\n r: number;\r\n /** Green component in 0..255. */\r\n g: number;\r\n /** Blue component in 0..255. */\r\n b: number;\r\n /** Alpha in 0..1. Only valid on a parameter declared with `alpha: true`. */\r\n a?: number;\r\n } | {\r\n /** Hue in 0..360. */\r\n h: number;\r\n /** Saturation in 0..100. */\r\n s: number;\r\n /** Brightness in 0..100. */\r\n b: number;\r\n /** Alpha in 0..1. Only valid on a parameter declared with `alpha: true`. */\r\n a?: number;\r\n };\r\n\n /**\r\n * Reactive object returned by `viji.color()`. `value` is always a canonical\r\n * lowercase hex string whose width is fixed by the parameter's mode (`#rrggbb`,\r\n * or `#rrggbbaa` when declared with `alpha: true`); `rgb`, `hsb` and `alpha` are\r\n * derived accessors that are recomputed (and frozen) every time the user changes\r\n * the color.\r\n */\r\n interface ColorParameter {\r\n /** Canonical lowercase hex color string: `#rrggbb`, or `#rrggbbaa` when `alpha: true`. Updates in real-time. */\r\n value: string;\r\n /** Alpha in 0..1. Always present: `1` on an opaque parameter, the live alpha when `alpha: true`. */\r\n alpha: number;\r\n /** RGB components as integers in 0..255 (frozen, recomputed when value changes). */\r\n rgb: {\r\n /** Red component, integer in 0..255. */\r\n r: number;\r\n /** Green component, integer in 0..255. */\r\n g: number;\r\n /** Blue component, integer in 0..255. */\r\n b: number;\r\n };\r\n /** HSB components: `h` in 0..360, `s` and `b` in 0..100 (frozen, recomputed when value changes). */\r\n hsb: {\r\n /** Hue in 0..360. */\r\n h: number;\r\n /** Saturation in 0..100. */\r\n s: number;\r\n /** Brightness in 0..100. */\r\n b: number;\r\n };\r\n /** Display name shown next to the swatch in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.coordinate()`. The host renders a 2D\r\n * draggable pad; both `x` and `y` are clamped to `-1..1`.\r\n */\r\n interface CoordinateConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Snap increment for both `x` and `y` components. Default: `0.01`. */\r\n step?: number;\r\n /** Display name shown next to the pad in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n }\r\n\n /**\r\n * Reactive object returned by `viji.coordinate()`. `value.x` and `value.y` are\r\n * always in `-1..1`; the host UI renders a draggable 2D pad.\r\n */\r\n interface CoordinateParameter {\r\n /** Current `{ x, y }` position. Both components are in `-1..1`. Updates in real-time. */\r\n value: CoordinateValue;\r\n /** Snap increment for both `x` and `y` components. */\r\n step: number;\r\n /** Display name shown next to the pad in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Two-component coordinate, both axes in `-1..1` (centered on the canvas).\r\n * Returned and consumed by `viji.coordinate()`.\r\n */\r\n type CoordinateValue = {\r\n /** Horizontal axis in `-1..1` (left to right, `0` = canvas center). */\r\n x: number;\r\n /** Vertical axis in `-1..1` (bottom to top, `0` = canvas center). */\r\n y: number;\r\n };\r\n\n /**\r\n * Identifier for an individual computer-vision feature pipeline. Returned by\r\n * `VideoAPI.cv.getActiveFeatures()` and used internally to track state.\r\n */\r\n type CVFeature = 'faceDetection' | 'faceMesh' | 'handTracking' | 'poseDetection' | 'bodySegmentation' | 'emotionDetection';\r\n\n /**\r\n * Computer-vision processing rate relative to the input video stream rate.\r\n * `'full'` runs CV on every delivered video frame, `'half'` every other frame,\r\n * `'quarter'` every fourth, `'eighth'` every eighth. Lower rates reduce CPU/GPU\r\n * cost. (Throttles the camera/stream frame cadence, independent of scene FPS.)\r\n */\r\n type CVFrameRateMode = 'full' | 'half' | 'quarter' | 'eighth';\r\n\n /**\r\n * Device motion data sourced from the platform's `DeviceMotionEvent`. All\r\n * accelerations are in metres per second squared (m/s²); rotation rates are\r\n * in degrees per second. Inner objects may be `null` when the underlying\r\n * sensor is unavailable, and individual axes may be `null` on platforms that\r\n * report only some components.\r\n */\r\n interface DeviceMotionData {\r\n /** Acceleration without gravity (m/s²). `null` when no accelerometer is available. */\r\n acceleration: {\r\n /** Acceleration along the device's X axis in m/s². `null` if unsupported. */\r\n x: number | null;\r\n /** Acceleration along the device's Y axis in m/s². `null` if unsupported. */\r\n y: number | null;\r\n /** Acceleration along the device's Z axis in m/s². `null` if unsupported. */\r\n z: number | null;\r\n } | null;\r\n /** Acceleration including gravity (m/s²). `null` when no accelerometer is available. */\r\n accelerationIncludingGravity: {\r\n /** Acceleration including gravity along the device's X axis in m/s². `null` if unsupported. */\r\n x: number | null;\r\n /** Acceleration including gravity along the device's Y axis in m/s². `null` if unsupported. */\r\n y: number | null;\r\n /** Acceleration including gravity along the device's Z axis in m/s². `null` if unsupported. */\r\n z: number | null;\r\n } | null;\r\n /** Angular rotation rate (degrees per second). `null` when no gyroscope is available. */\r\n rotationRate: {\r\n /** Rotation rate around the device's Z axis in deg/s. `null` if unsupported. */\r\n alpha: number | null;\r\n /** Rotation rate around the device's X axis in deg/s. `null` if unsupported. */\r\n beta: number | null;\r\n /** Rotation rate around the device's Y axis in deg/s. `null` if unsupported. */\r\n gamma: number | null;\r\n } | null;\r\n /** Interval between sensor updates in milliseconds. */\r\n interval: number;\r\n }\r\n\n /**\r\n * DeviceOrientationEvent data\r\n * Matches native DeviceOrientationEvent structure\r\n */\r\n interface DeviceOrientationData {\r\n /** Rotation around Z-axis (0-360 degrees, compass heading) */\r\n alpha: number | null;\r\n /** Rotation around X-axis (-180 to 180 degrees, front-to-back tilt) */\r\n beta: number | null;\r\n /** Rotation around Y-axis (-90 to 90 degrees, left-to-right tilt) */\r\n gamma: number | null;\r\n /** True if using magnetometer (compass) for absolute orientation */\r\n absolute: boolean;\r\n }\r\n\n /**\r\n * Sensor snapshot for the device running the scene. Both fields read `null`\r\n * when the corresponding sensor is unavailable or has not delivered a sample yet.\r\n */\r\n interface DeviceSensorState {\r\n /** Motion data (acceleration, rotation rate, sampling interval). `null` if no motion sensor is available. */\r\n motion: DeviceMotionData | null;\r\n /** Orientation data (alpha/beta/gamma in degrees). `null` if no orientation sensor is available. */\r\n orientation: DeviceOrientationData | null;\r\n }\r\n\n /**\r\n * External device state (includes id and name)\r\n */\r\n interface DeviceState extends DeviceSensorState {\r\n /** Unique device identifier */\r\n id: string;\r\n /** User-friendly device name */\r\n name: string;\r\n /** Device camera video (null if not available) */\r\n video: VideoAPI | null;\r\n /** Device audio stream (null if not available) */\r\n audio: AudioStreamAPI | null;\r\n }\r\n\n /**\r\n * 52 ARKit-compatible face blendshape coefficients (each in 0..1) derived from\r\n * MediaPipe FaceLandmarker. All fields are `0` unless emotion detection is\r\n * enabled. Available on each `FaceData.blendshapes`.\r\n */\r\n interface FaceBlendshapes {\r\n /** Coefficient (0..1) for the inner brow of the left eye pulling down. */\r\n browDownLeft: number;\r\n /** Coefficient (0..1) for the inner brow of the right eye pulling down. */\r\n browDownRight: number;\r\n /** Coefficient (0..1) for both inner brows pulling up. */\r\n browInnerUp: number;\r\n /** Coefficient (0..1) for the outer left brow pulling up. */\r\n browOuterUpLeft: number;\r\n /** Coefficient (0..1) for the outer right brow pulling up. */\r\n browOuterUpRight: number;\r\n /** Coefficient (0..1) for puffed cheeks. */\r\n cheekPuff: number;\r\n /** Coefficient (0..1) for the left cheek squinting. */\r\n cheekSquintLeft: number;\r\n /** Coefficient (0..1) for the right cheek squinting. */\r\n cheekSquintRight: number;\r\n /** Coefficient (0..1) for the left eyelid closing. */\r\n eyeBlinkLeft: number;\r\n /** Coefficient (0..1) for the right eyelid closing. */\r\n eyeBlinkRight: number;\r\n /** Coefficient (0..1) for the left eye looking down. */\r\n eyeLookDownLeft: number;\r\n /** Coefficient (0..1) for the right eye looking down. */\r\n eyeLookDownRight: number;\r\n /** Coefficient (0..1) for the left eye looking inward (toward the nose). */\r\n eyeLookInLeft: number;\r\n /** Coefficient (0..1) for the right eye looking inward. */\r\n eyeLookInRight: number;\r\n /** Coefficient (0..1) for the left eye looking outward (away from the nose). */\r\n eyeLookOutLeft: number;\r\n /** Coefficient (0..1) for the right eye looking outward. */\r\n eyeLookOutRight: number;\r\n /** Coefficient (0..1) for the left eye looking up. */\r\n eyeLookUpLeft: number;\r\n /** Coefficient (0..1) for the right eye looking up. */\r\n eyeLookUpRight: number;\r\n /** Coefficient (0..1) for the left eye squinting. */\r\n eyeSquintLeft: number;\r\n /** Coefficient (0..1) for the right eye squinting. */\r\n eyeSquintRight: number;\r\n /** Coefficient (0..1) for the left eye opening wide. */\r\n eyeWideLeft: number;\r\n /** Coefficient (0..1) for the right eye opening wide. */\r\n eyeWideRight: number;\r\n /** Coefficient (0..1) for the jaw moving forward. */\r\n jawForward: number;\r\n /** Coefficient (0..1) for the jaw moving left. */\r\n jawLeft: number;\r\n /** Coefficient (0..1) for the jaw opening (mouth open). */\r\n jawOpen: number;\r\n /** Coefficient (0..1) for the jaw moving right. */\r\n jawRight: number;\r\n /** Coefficient (0..1) for the mouth closing tightly. */\r\n mouthClose: number;\r\n /** Coefficient (0..1) for a dimple appearing on the left side. */\r\n mouthDimpleLeft: number;\r\n /** Coefficient (0..1) for a dimple appearing on the right side. */\r\n mouthDimpleRight: number;\r\n /** Coefficient (0..1) for the left mouth corner pulling down (frown). */\r\n mouthFrownLeft: number;\r\n /** Coefficient (0..1) for the right mouth corner pulling down (frown). */\r\n mouthFrownRight: number;\r\n /** Coefficient (0..1) for funneling the lips outward. */\r\n mouthFunnel: number;\r\n /** Coefficient (0..1) for the mouth shifting left. */\r\n mouthLeft: number;\r\n /** Coefficient (0..1) for the lower lip on the left pulling down. */\r\n mouthLowerDownLeft: number;\r\n /** Coefficient (0..1) for the lower lip on the right pulling down. */\r\n mouthLowerDownRight: number;\r\n /** Coefficient (0..1) for the left lip pressing inward. */\r\n mouthPressLeft: number;\r\n /** Coefficient (0..1) for the right lip pressing inward. */\r\n mouthPressRight: number;\r\n /** Coefficient (0..1) for puckered lips. */\r\n mouthPucker: number;\r\n /** Coefficient (0..1) for the mouth shifting right. */\r\n mouthRight: number;\r\n /** Coefficient (0..1) for the lower lip rolling inward. */\r\n mouthRollLower: number;\r\n /** Coefficient (0..1) for the upper lip rolling inward. */\r\n mouthRollUpper: number;\r\n /** Coefficient (0..1) for the lower lip shrugging. */\r\n mouthShrugLower: number;\r\n /** Coefficient (0..1) for the upper lip shrugging. */\r\n mouthShrugUpper: number;\r\n /** Coefficient (0..1) for the left mouth corner pulling up (smile). */\r\n mouthSmileLeft: number;\r\n /** Coefficient (0..1) for the right mouth corner pulling up (smile). */\r\n mouthSmileRight: number;\r\n /** Coefficient (0..1) for the left mouth corner stretching outward. */\r\n mouthStretchLeft: number;\r\n /** Coefficient (0..1) for the right mouth corner stretching outward. */\r\n mouthStretchRight: number;\r\n /** Coefficient (0..1) for the upper lip on the left raising. */\r\n mouthUpperUpLeft: number;\r\n /** Coefficient (0..1) for the upper lip on the right raising. */\r\n mouthUpperUpRight: number;\r\n /** Coefficient (0..1) for the left side of the nose sneering. */\r\n noseSneerLeft: number;\r\n /** Coefficient (0..1) for the right side of the nose sneering. */\r\n noseSneerRight: number;\r\n /** Coefficient (0..1) for the tongue protruding. */\r\n tongueOut: number;\r\n }\r\n\n /**\r\n * One detected face produced by the video CV pipeline. Each field is\r\n * populated only by its source model; fields whose source model is not\r\n * enabled read as `null` so the absence is loud rather than silent. Enable\r\n * the relevant `enable*` verb on `viji.video.cv` to populate each group:\r\n *\r\n * - `bounds`, `center`, `confidence`: populated by `enableFaceDetection(true)`.\r\n * - `landmarks`: populated by `enableFaceMesh(true)` (empty array otherwise).\r\n * - `headPose`: populated by `enableFaceMesh(true)`.\r\n * - `blendshapes`, `expressions`: populated by `enableEmotionDetection(true)`.\r\n *\r\n * If a field is `null`, call the corresponding `enable*` verb on\r\n * `viji.video.cv` to populate it. Each active CV feature consumes its own\r\n * WebGL context for MediaPipe; enabling many at once on lower-end hardware\r\n * can hit context limits.\r\n */\r\n interface FaceData {\r\n /** Index-based face identifier (`0`, `1`, …). Stable within a single frame, may change between frames. */\r\n id: number;\r\n /** Bounding box, all components normalized to 0..1 of the source frame. `null` unless face detection is enabled. */\r\n bounds: {\r\n /** Left edge of the face bounding box, normalized 0..1. */\r\n x: number;\r\n /** Top edge of the face bounding box, normalized 0..1. */\r\n y: number;\r\n /** Width of the face bounding box, normalized 0..1. */\r\n width: number;\r\n /** Height of the face bounding box, normalized 0..1. */\r\n height: number;\r\n } | null;\r\n /** Center of the bounding box, normalized 0..1. `null` unless face detection is enabled. */\r\n center: {\r\n /** Horizontal center of the face, normalized 0..1. */\r\n x: number;\r\n /** Vertical center of the face, normalized 0..1. */\r\n y: number;\r\n } | null;\r\n /** Detection confidence in 0..1. `null` unless face detection is enabled. */\r\n confidence: number | null;\r\n /** 468 normalized face mesh landmarks when face mesh is enabled; empty array otherwise. */\r\n landmarks: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n /** Optional depth (relative). */\r\n z?: number;\r\n }[];\r\n /** Estimated head rotation in degrees. `null` unless face mesh is enabled. */\r\n headPose: {\r\n /** Up/down rotation in degrees (-90..90). Positive = head looking up, negative = looking down. */\r\n pitch: number;\r\n /** Left/right rotation in degrees (-90..90). Positive = head turned to the subject's right, negative = to the left. */\r\n yaw: number;\r\n /** Tilt rotation in degrees (-180..180). Positive = head tilted to the subject's right (right ear toward right shoulder). */\r\n roll: number;\r\n } | null;\r\n /** Seven expression confidence scores in 0..1. `null` unless emotion detection is enabled. */\r\n expressions: {\r\n /** Confidence (0..1) of a neutral expression. */\r\n neutral: number;\r\n /** Confidence (0..1) of a happy / smiling expression. */\r\n happy: number;\r\n /** Confidence (0..1) of a sad expression. */\r\n sad: number;\r\n /** Confidence (0..1) of an angry expression. */\r\n angry: number;\r\n /** Confidence (0..1) of a surprised expression. */\r\n surprised: number;\r\n /** Confidence (0..1) of a disgusted expression. */\r\n disgusted: number;\r\n /** Confidence (0..1) of a fearful expression. */\r\n fearful: number;\r\n } | null;\r\n /** 52 ARKit-compatible facial muscle coefficients. `null` unless emotion detection is enabled. */\r\n blendshapes: FaceBlendshapes | null;\r\n }\r\n\n /**\r\n * Render-loop pacing mode. `'full'` runs `render()` on every animation frame,\r\n * `'half'` every 2nd frame, `'quarter'` every 4th, `'eighth'` every 8th. Lower\r\n * rates save CPU/GPU on lower-cost scenes. The resulting FPS is the screen\r\n * refresh rate divided by the mode divisor (1/2/4/8), so on a 60 Hz display:\r\n * `'full'` ~60, `'half'` ~30, `'quarter'` ~15, `'eighth'` ~7.5.\r\n */\r\n type FrameRateMode = 'full' | 'half' | 'quarter' | 'eighth';\r\n\n /**\r\n * One named frequency band reported by the audio analyzer\r\n * (e.g., `{ name: 'low', min: 20, max: 120 }`). Frequencies are in Hertz.\r\n */\r\n interface FrequencyBand {\r\n /** Human-readable band name (e.g., `'low'`, `'mid'`, `'high'`). */\r\n name: string;\r\n /** Lower edge of the band in Hertz (inclusive). */\r\n min: number;\r\n /** Upper edge of the band in Hertz (exclusive). */\r\n max: number;\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.gradient()`. Defines the ramp editor's\r\n * stop bounds, transparency mode, label and UI grouping/visibility.\r\n */\r\n interface GradientConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const ramp = viji.gradient(...)` → `ramp`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Minimum number of stops the editor allows. Integer in `2..32`. Default: `2`. */\r\n minStops?: number;\r\n /** Maximum number of stops the editor allows. Integer in `2..32`; sizes the shader uniform arrays. Default: `8`. */\r\n maxStops?: number;\r\n /** Display name shown next to the ramp in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n /**\r\n * Enable per-stop transparency. When `true` every stop color is `#rrggbbaa`\r\n * (opaque inputs padded `ff`) and the shader sampler returns a `vec4`. When\r\n * `false` (default) stops are `#rrggbb` and alpha-bearing stop colors are rejected.\r\n */\r\n alpha?: boolean;\r\n }\r\n\n /**\r\n * Stop list accepted by `viji.gradient()` and `setParameter()`. Any order;\r\n * normalized to a sorted, canonical {@link GradientValue}.\r\n */\r\n type GradientInput = ReadonlyArray<GradientStopInput>;\r\n\n /**\r\n * Reactive object returned by `viji.gradient()`. `value` is the live, frozen,\r\n * sorted stop list; `at(t)` samples the ramp with CSS `linear-gradient`\r\n * semantics (premultiplied sRGB between stops, hard edges on duplicate\r\n * positions) and returns a canonical hex string in the same width as the stops.\r\n */\r\n interface GradientParameter {\r\n /** Current stops, frozen and sorted ascending by position. Updates in real-time. */\r\n value: GradientValue;\r\n /**\r\n * Sample the ramp at `t` (clamped to `0..1`). Returns canonical hex in the\r\n * gradient's width. The shader renderer exposes the same function as\r\n * `<name>(float t)` in GLSL.\r\n */\r\n at(t: number): string;\r\n /** Display name shown next to the ramp in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * One stop of a gradient value. `color` is canonical lowercase hex in the\r\n * gradient's mode (`#rrggbb`, or `#rrggbbaa` when declared with `alpha: true`).\r\n */\r\n interface GradientStop {\r\n /** Canonical hex color of this stop. */\r\n color: string;\r\n /** Position along the ramp in `0..1`. */\r\n position: number;\r\n }\r\n\n /**\r\n * One artist- or host-supplied gradient stop. `color` accepts every form a\r\n * color parameter accepts, normalized per the gradient's `alpha` mode.\r\n */\r\n interface GradientStopInput {\r\n /** Any accepted color form (hex, CSS functions, RGB / HSB objects). */\r\n color: ColorInput;\r\n /** Position along the ramp in `0..1`. */\r\n position: number;\r\n }\r\n\n /**\r\n * Value of a gradient parameter: a frozen list of stops sorted ascending by\r\n * position. Duplicate positions are allowed and form a hard edge. The length is\r\n * within the parameter's `minStops..maxStops`. No wrapper: geometry (linear,\r\n * radial, angle) is the scene's concern.\r\n */\r\n type GradientValue = readonly GradientStop[];\r\n\n /**\r\n * One detected hand produced by the video CV pipeline. Carries 21 landmarks,\r\n * a palm shortcut, and ML-classified gesture confidence scores. Up to two\r\n * hands appear in `VideoAPI.hands` simultaneously.\r\n */\r\n interface HandData {\r\n /** Index-based hand identifier (`0` or `1`). */\r\n id: number;\r\n /** Which hand. Always lowercase. */\r\n handedness: 'left' | 'right';\r\n /** Detection confidence in 0..1. */\r\n confidence: number;\r\n /** Bounding box, all components normalized to 0..1 of the source frame. */\r\n bounds: {\r\n /** Left edge of the hand bounding box, normalized 0..1. */\r\n x: number;\r\n /** Top edge of the hand bounding box, normalized 0..1. */\r\n y: number;\r\n /** Width of the hand bounding box, normalized 0..1. */\r\n width: number;\r\n /** Height of the hand bounding box, normalized 0..1. */\r\n height: number;\r\n };\r\n /** 21 MediaPipe hand landmarks, normalized 0..1. */\r\n landmarks: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n /** Depth (relative). */\r\n z: number;\r\n }[];\r\n /** Palm center, equivalent to `landmarks[9]` (middle-finger MCP). */\r\n palm: {\r\n /** Palm horizontal coordinate, normalized 0..1. */\r\n x: number;\r\n /** Palm vertical coordinate, normalized 0..1. */\r\n y: number;\r\n /** Palm depth (relative). */\r\n z: number;\r\n };\r\n /**\r\n * ML-classified gesture confidences from MediaPipe GestureRecognizer.\r\n * Each value is in 0..1; multiple gestures can fire simultaneously.\r\n */\r\n gestures: {\r\n /** Confidence (0..1) of a closed-fist gesture. */\r\n fist: number;\r\n /** Confidence (0..1) of an open-palm gesture. */\r\n openPalm: number;\r\n /** Confidence (0..1) of a peace / victory sign. */\r\n peace: number;\r\n /** Confidence (0..1) of a thumbs-up gesture. */\r\n thumbsUp: number;\r\n /** Confidence (0..1) of a thumbs-down gesture. */\r\n thumbsDown: number;\r\n /** Confidence (0..1) of a pointing-up gesture. */\r\n pointing: number;\r\n /** Confidence (0..1) of the ASL \"I love you\" sign. */\r\n iLoveYou: number;\r\n };\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.image()`. The host renders an upload\r\n * field; the user-supplied image becomes available as an `ImageBitmap` (Native)\r\n * or a P5 image wrapper (P5 renderer).\r\n */\r\n interface ImageConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Display name shown next to the upload field in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n }\r\n\n /**\r\n * Reactive object returned by `viji.image()`. `value` is `null` until the user\r\n * uploads an image; in P5 scenes a `.p5` accessor is also added at runtime so\r\n * the image works directly with `image()`, `texture()`, etc.\r\n */\r\n interface ImageParameter {\r\n /**\r\n * Uploaded image as an `ImageBitmap`, or `null` until the user provides one.\r\n * Read it where you use it (inside `render()`): when the host replaces or\r\n * clears the image, the previous bitmap is closed, so a reference kept from\r\n * an earlier frame becomes unusable.\r\n */\r\n value: ImageBitmap | null;\r\n /** P5-compatible image wrapper. Only available in the P5 renderer; added at runtime by the P5 adapter. */\r\n readonly p5?: any;\r\n /** Display name shown next to the upload field in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Keyboard input state for the current frame: per-key press / hold / release\r\n * queries (case-insensitive), the live set of held keys, modifier flags, and\r\n * a Shadertoy-compatible texture buffer for shader-side keyboard reads.\r\n *\r\n * Key names follow the browser's `event.key` standard\r\n * (`'a'`, `'arrowup'`, `' '` for Space, `'enter'`, `'escape'`, etc.).\r\n */\r\n interface KeyboardAPI {\r\n /** Returns `true` while the named key is held. Case-insensitive. */\r\n isPressed(key: string): boolean;\r\n /** Returns `true` for exactly one frame on the rising edge of the named key (no key-repeat). Case-insensitive. */\r\n wasPressed(key: string): boolean;\r\n /** Returns `true` for exactly one frame on the falling edge of the named key. Case-insensitive. */\r\n wasReleased(key: string): boolean;\r\n /** Set of all currently held keys, lowercased. Persists across frames. */\r\n activeKeys: Set<string>;\r\n /** Set of keys whose key-down fired this frame, lowercased. Cleared each frame. */\r\n pressedThisFrame: Set<string>;\r\n /** Set of keys whose key-up fired this frame, lowercased. Cleared each frame. */\r\n releasedThisFrame: Set<string>;\r\n /** Most recently pressed key in its original case (e.g., `'A'` when Shift is held). */\r\n lastKeyPressed: string;\r\n /** Most recently released key in its original case. */\r\n lastKeyReleased: string;\r\n /** `true` while the Shift key is held. */\r\n shift: boolean;\r\n /** `true` while the Ctrl key is held. */\r\n ctrl: boolean;\r\n /** `true` while the Alt (or Option) key is held. */\r\n alt: boolean;\r\n /** `true` while the Meta (Windows / Cmd) key is held. */\r\n meta: boolean;\r\n /**\r\n * Shadertoy-compatible 256×3 keyboard texture (256 keycodes × 3 rows).\r\n * Row 0: held state (1 / 0). Row 1: pressed-this-frame (1 / 0). Row 2: per-key toggle.\r\n * Bound to a uniform sampler in shader scenes; rarely needed in JS.\r\n */\r\n textureData: Uint8Array;\r\n }\r\n\n /**\r\n * Mouse input state for the current frame: position, individual button states,\r\n * per-frame movement, scroll wheel, and frame-based press / release events.\r\n * Coordinates are in canvas-space pixels with `(0, 0)` at the top-left corner.\r\n *\r\n * For interactions that should also work on touch devices, prefer `viji.pointer`.\r\n */\r\n interface MouseAPI {\r\n /** Canvas-space X position in pixels. */\r\n x: number;\r\n /** Canvas-space Y position in pixels. */\r\n y: number;\r\n /** `true` when the cursor is currently over the canvas. */\r\n isInCanvas: boolean;\r\n /** `true` if any mouse button is currently held. */\r\n isPressed: boolean;\r\n /** `true` while the left mouse button is held. */\r\n leftButton: boolean;\r\n /** `true` while the right mouse button is held. The browser context menu is suppressed on the canvas. */\r\n rightButton: boolean;\r\n /** `true` while the middle (wheel) mouse button is held. */\r\n middleButton: boolean;\r\n /** Horizontal movement this frame in pixels. Resets to `0` each frame. */\r\n deltaX: number;\r\n /** Vertical movement this frame in pixels. Resets to `0` each frame. */\r\n deltaY: number;\r\n /** Vertical scroll accumulated this frame (alias of `wheelY`). Resets to `0` each frame. */\r\n wheelDelta: number;\r\n /** Horizontal scroll accumulated this frame (e.g., trackpad gestures, tilt-wheel mice). Resets to `0` each frame. */\r\n wheelX: number;\r\n /** Vertical scroll accumulated this frame. Resets to `0` each frame. */\r\n wheelY: number;\r\n /** `true` for exactly one frame when any button is first pressed, then auto-resets. */\r\n wasPressed: boolean;\r\n /** `true` for exactly one frame when any button is released, then auto-resets. */\r\n wasReleased: boolean;\r\n /** `true` if the mouse moved this frame (any non-zero `deltaX` / `deltaY`). Resets each frame. */\r\n wasMoved: boolean;\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.number()`. Defines the bounds, step,\r\n * label, and UI grouping/visibility for a precise numeric input.\r\n */\r\n interface NumberConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Inclusive minimum value. Default: `0`. */\r\n min?: number;\r\n /** Inclusive maximum value. Default: `100`. */\r\n max?: number;\r\n /**\r\n * Increment between values. When omitted, auto-derives from `min`/`max` as\r\n * the largest power of 10 giving ~100 positions across the range (e.g.,\r\n * range `0..1` → `0.01`, range `0..100` → `1`, range `0.1..5` → `0.01`).\r\n * Specify explicitly for integer counts (`step: 1`) or fine precision\r\n * (`step: 0.001`).\r\n */\r\n step?: number;\r\n /** Display name shown next to the input in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n }\r\n\n /**\r\n * Reactive object returned by `viji.number()`. Like `SliderParameter` but the\r\n * host UI renders a precise numeric input rather than a draggable slider.\r\n */\r\n interface NumberParameter {\r\n /** Current numeric value in the configured `min..max` range. Updates in real-time. */\r\n value: number;\r\n /** Inclusive minimum value. */\r\n min: number;\r\n /** Inclusive maximum value. */\r\n max: number;\r\n /** Increment between values. */\r\n step: number;\r\n /** Display name shown next to the input in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Visibility category for a parameter. The host hides parameters whose category\r\n * is not currently available (e.g., `'audio'` controls hide when no audio\r\n * source is connected). `'general'` parameters are always visible.\r\n */\r\n type ParameterCategory = 'audio' | 'video' | 'interaction' | 'general';\r\n\n /**\r\n * Unified pointer that abstracts mouse and primary touch into a single input\r\n * stream. Recommended for click / drag / position-tracking interactions that\r\n * should work identically on desktop and mobile.\r\n *\r\n * Use `viji.mouse` for mouse-specific features (right click, middle click,\r\n * scroll wheel); use `viji.touches` for multi-touch, pressure, or radius.\r\n */\r\n interface PointerAPI {\r\n /** Canvas-space X position in pixels. */\r\n x: number;\r\n /** Canvas-space Y position in pixels. */\r\n y: number;\r\n /** Horizontal movement since the last frame in pixels. */\r\n deltaX: number;\r\n /** Vertical movement since the last frame in pixels. */\r\n deltaY: number;\r\n /** `true` while the pointer is \"down\": left mouse button held, or a touch active. */\r\n isDown: boolean;\r\n /** `true` for exactly one frame when the pointer becomes down, then auto-resets. */\r\n wasPressed: boolean;\r\n /** `true` for exactly one frame when the pointer is released, then auto-resets. */\r\n wasReleased: boolean;\r\n /** `true` while the pointer is within the canvas bounds. */\r\n isInCanvas: boolean;\r\n /** Currently active input source: `'touch'` when at least one touch is active, otherwise `'mouse'` (or `'none'` when the cursor is off-canvas). */\r\n type: 'mouse' | 'touch' | 'none';\r\n }\r\n\n /**\r\n * Detected body pose from MediaPipe BlazePose. `landmarks` contains 33 points;\r\n * the `face` / `torso` / `leftArm` / `rightArm` / `leftLeg` / `rightLeg` arrays\r\n * are pre-grouped slices for convenience.\r\n */\r\n interface PoseData {\r\n /** Average landmark visibility in 0..1. */\r\n confidence: number;\r\n /** 33 BlazePose landmarks, normalized 0..1. Each carries a per-point `visibility` score. */\r\n landmarks: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n /** Depth (relative). */\r\n z: number;\r\n /** Visibility / confidence of this individual landmark in 0..1. */\r\n visibility: number;\r\n }[];\r\n /** Face landmarks (BlazePose indices 0..10). Coordinates normalized 0..1. */\r\n face: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n }[];\r\n /** Torso landmarks (BlazePose indices 11, 12, 23, 24). Coordinates normalized 0..1. */\r\n torso: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n }[];\r\n /** Left-arm landmarks (BlazePose indices 11, 13, 15). Coordinates normalized 0..1. */\r\n leftArm: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n }[];\r\n /** Right-arm landmarks (BlazePose indices 12, 14, 16). Coordinates normalized 0..1. */\r\n rightArm: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n }[];\r\n /** Left-leg landmarks (BlazePose indices 23, 25, 27, 29, 31). Coordinates normalized 0..1. */\r\n leftLeg: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n }[];\r\n /** Right-leg landmarks (BlazePose indices 24, 26, 28, 30, 32). Coordinates normalized 0..1. */\r\n rightLeg: {\r\n /** Horizontal landmark coordinate, normalized 0..1. */\r\n x: number;\r\n /** Vertical landmark coordinate, normalized 0..1. */\r\n y: number;\r\n }[];\r\n }\r\n\n /**\r\n * Discrete pixel dimensions for a canvas, frame capture, or render target.\r\n */\r\n type Resolution = {\r\n /** Width in pixels (positive integer). */\r\n width: number;\r\n /** Height in pixels (positive integer). */\r\n height: number;\r\n };\r\n\n /**\r\n * Per-pixel person/background segmentation mask. Mask dimensions reflect the\r\n * ML model's output and may differ from the source video frame.\r\n */\r\n interface SegmentationData {\r\n /** Flat per-pixel mask: each byte is `0` (background) or `1` (person). Length = `width * height`. */\r\n mask: Uint8Array;\r\n /** Mask width in pixels. */\r\n width: number;\r\n /** Mask height in pixels. */\r\n height: number;\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.select()`. The host renders the choices\r\n * as a dropdown or segmented control.\r\n */\r\n interface SelectConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Available choices. The element type (`string` or `number`) becomes the parameter's value type. Required. */\r\n options: string[] | number[];\r\n /** Display name shown next to the dropdown in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n }\r\n\n /**\r\n * Reactive object returned by `viji.select()`. `value` matches the element type\r\n * of the configured `options` array (`string` or `number`).\r\n */\r\n interface SelectParameter {\r\n /** Currently selected option. Updates in real-time when the user changes the selection. */\r\n value: string | number;\r\n /** The full list of choices originally configured. */\r\n options: string[] | number[];\r\n /** Display name shown next to the dropdown in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.slider()`. Defines the slider's bounds,\r\n * increment, label, and UI grouping/visibility.\r\n */\r\n interface SliderConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Inclusive minimum value of the slider. Default: `0`. */\r\n min?: number;\r\n /** Inclusive maximum value of the slider. Default: `100`. */\r\n max?: number;\r\n /**\r\n * Increment between values. When omitted, auto-derives from `min`/`max` as\r\n * the largest power of 10 giving ~100 positions across the range (e.g.,\r\n * range `0..1` → `0.01`, range `0..100` → `1`, range `0.1..5` → `0.01`,\r\n * range `0..1000` → `10`). Specify explicitly for integer counts\r\n * (`step: 1` on a range of `3..30`) or fine precision (`step: 0.001`).\r\n */\r\n step?: number;\r\n /** Display name shown next to the control in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n }\r\n\n /**\r\n * Reactive object returned by `viji.slider()`. `value` updates in real-time as\r\n * the user drags the control; the remaining fields mirror the configuration.\r\n */\r\n interface SliderParameter {\r\n /** Current slider value in the configured `min..max` range. Updates in real-time. */\r\n value: number;\r\n /** Inclusive minimum value of the slider. */\r\n min: number;\r\n /** Inclusive maximum value of the slider. */\r\n max: number;\r\n /** Increment between values. */\r\n step: number;\r\n /** Display name shown next to the control in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.text()`. The host renders a single-line\r\n * text input field.\r\n */\r\n interface TextConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Display name shown next to the text field in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n /** Maximum character count enforced by the host UI. Default: `1000`. */\r\n maxLength?: number;\r\n }\r\n\n /**\r\n * Reactive object returned by `viji.text()`. `value` updates as the user types\r\n * and is enforced to be no longer than `maxLength` by the host UI.\r\n */\r\n interface TextParameter {\r\n /** Current text content. Updates in real-time as the user types. */\r\n value: string;\r\n /** Maximum character count enforced by the host UI. */\r\n maxLength?: number;\r\n /** Display name shown next to the input in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Configuration object passed to `viji.toggle()`. Defines the on/off switch's\r\n * label and UI grouping/visibility.\r\n */\r\n interface ToggleConfig {\r\n /**\r\n * Advanced: explicit parameter identity. Normally you do NOT set this —\r\n * the parameter's name is inferred from the variable or object key you\r\n * assign it to (`const speed = viji.slider(...)` → `speed`). Set `name`\r\n * only for parameters not assigned to a variable or key (created in an\r\n * array, loop, or factory). Must be a valid identifier and scene-globally\r\n * unique. When set, it overrides the inferred name.\r\n */\r\n name?: string;\r\n /** Display name shown next to the switch in the parameter UI. Optional — defaults to the parameter's name. */\r\n label?: string;\r\n /** Optional tooltip / help text shown next to the control. */\r\n description?: string;\r\n /** Group name for organizing related parameters under a shared heading. Default: `'general'`. */\r\n group?: string;\r\n /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */\r\n category?: ParameterCategory;\r\n }\r\n\n /**\r\n * Reactive object returned by `viji.toggle()`. `value` flips between `true`\r\n * and `false` as the user interacts with the switch.\r\n */\r\n interface ToggleParameter {\r\n /** Current state of the switch. Updates in real-time when the user toggles it. */\r\n value: boolean;\r\n /** Display name shown next to the switch in the parameter UI. */\r\n label?: string;\r\n /** Tooltip / help text for the control (empty string when not configured). */\r\n description?: string;\r\n /** Group name under which the control appears in the UI. */\r\n group: string;\r\n /** Visibility category that controls when the parameter is shown. */\r\n category: ParameterCategory;\r\n }\r\n\n /**\r\n * Multi-touch input state. Lists all active touches, plus per-frame\r\n * `started` / `moved` / `ended` arrays for frame-based gesture handling.\r\n *\r\n * For single-point interactions that should also work with a mouse, prefer\r\n * `viji.pointer`. It switches automatically between mouse and primary touch.\r\n */\r\n interface TouchAPI {\r\n /** All currently active touch points. Order is stable but not ordered by id. */\r\n points: TouchPoint[];\r\n /** Number of currently active touches (equivalent to `points.length`). */\r\n count: number;\r\n /** Touches that started this frame (also visible in `points`). Cleared each frame. */\r\n started: TouchPoint[];\r\n /** Touches that moved this frame. Cleared each frame. */\r\n moved: TouchPoint[];\r\n /** Touches that ended this frame. Each entry has `isEnding === true`. Cleared each frame. */\r\n ended: TouchPoint[];\r\n /** Convenience shortcut to `points[0]`, or `null` when no touches are active. */\r\n primary: TouchPoint | null;\r\n }\r\n\n /**\r\n * One active touch contact reported by `TouchAPI`. Position, pressure, radius,\r\n * rotation, per-frame movement, velocity, and lifecycle flags. Coordinates are\r\n * in canvas-space pixels.\r\n *\r\n * Some fields (notably `pressure` / `force`, `radiusX` / `radiusY`,\r\n * `rotationAngle`) are passed through from the device; values vary by\r\n * platform; many devices report `0` when unsupported.\r\n */\r\n interface TouchPoint {\r\n /** Stable touch identifier across frames for the duration of this contact. */\r\n id: number;\r\n /** Canvas-space X position in pixels. */\r\n x: number;\r\n /** Canvas-space Y position in pixels. */\r\n y: number;\r\n /** Touch pressure in 0..1 (device-dependent; often `0` on devices without force support). */\r\n pressure: number;\r\n /** Contact radius, `Math.max(radiusX, radiusY)` in pixels. */\r\n radius: number;\r\n /** Horizontal contact radius in pixels (raw device value). */\r\n radiusX: number;\r\n /** Vertical contact radius in pixels (raw device value). */\r\n radiusY: number;\r\n /** Contact area rotation in radians (raw device value). */\r\n rotationAngle: number;\r\n /** Touch force in 0..1; alias of `pressure`. */\r\n force: number;\r\n /** `true` while the touch position is within the canvas bounds. */\r\n isInCanvas: boolean;\r\n /** Horizontal movement since the last frame in pixels. */\r\n deltaX: number;\r\n /** Vertical movement since the last frame in pixels. */\r\n deltaY: number;\r\n /** Movement velocity in pixels per second, computed by Viji. */\r\n velocity: {\r\n /** Horizontal velocity component in pixels per second. */\r\n x: number;\r\n /** Vertical velocity component in pixels per second. */\r\n y: number;\r\n };\r\n /** `true` for exactly one frame when this touch starts, then auto-resets. */\r\n isNew: boolean;\r\n /** `true` while the touch is ongoing. */\r\n isActive: boolean;\r\n /** `true` for exactly one frame when this touch ends, then auto-resets. */\r\n isEnding: boolean;\r\n }\r\n\n const VERSION = \"0.20.0\";\r\n\n /**\r\n * Real-time video API: drawable frame, dimensions, and the source-side\r\n * properties of the connected stream. All computer-vision data and controls\r\n * (faces, hands, pose, segmentation, the analysed frame, and feature\r\n * enable/disable verbs) live on `viji.video.cv`.\r\n *\r\n * When `isConnected` is `false`, `currentFrame` is `null`, all dimensions are\r\n * `0`, and every member of `cv` holds its empty default.\r\n */\r\n interface VideoAPI {\r\n /** `true` when a video stream is connected. When `false`, all other fields hold their default empty values. */\r\n isConnected: boolean;\r\n /** Latest video frame, drawable directly with `ctx.drawImage()`. `null` when disconnected. */\r\n currentFrame: OffscreenCanvas | ImageBitmap | null;\r\n /** Source video frame width in pixels. `0` when disconnected. */\r\n frameWidth: number;\r\n /** Source video frame height in pixels. `0` when disconnected. */\r\n frameHeight: number;\r\n /** Source video frame rate in Hz (frames per second). `0` when disconnected. */\r\n frameRate: number;\r\n /**\r\n * Returns the latest frame as raw RGBA `ImageData` for per-pixel CPU analysis,\r\n * or `null` when disconnected. Slow compared to drawing `currentFrame` directly;\r\n * use only when you need to read individual pixel values.\r\n */\r\n getFrameData: () => ImageData | null;\r\n /**\r\n * Computer-vision surface for this video stream. Holds both the data\r\n * outputs (`faces`, `hands`, `pose`, `segmentation`, `analysedFrame`,\r\n * `getAnalysedFrameData`) and the verbs that activate them\r\n * (`enable*`/`disable*`/`getActiveFeatures`/`isProcessing`).\r\n *\r\n * Multiple features can be active simultaneously, but each adds CPU/GPU\r\n * and WebGL-context cost; toggle only what you need.\r\n *\r\n * `analysedFrame` and the result fields refresh together once per host\r\n * frame as an atomic snapshot: within a single `render()` call they are\r\n * always paired.\r\n */\r\n cv: VideoCVAPI;\r\n }\r\n\n /**\r\n * Computer-vision surface attached to a `VideoAPI`. Combines paired CV data\r\n * outputs (the analysed frame and its detection / segmentation results) with\r\n * the verbs that activate the underlying MediaPipe pipelines.\r\n *\r\n * Available on the main video stream (`viji.video.cv`) and on additional\r\n * streams (`viji.videoStreams[i].cv`) — same surface, same verbs, activated\r\n * per stream. `analysedFrame` is populated on the MAIN stream only; on other\r\n * streams it stays `null` (use `currentFrame`). Device videos\r\n * (`viji.devices[i].video.cv`) do not run CV yet; their `cv` surface exists\r\n * for API consistency with the data fields at their empty defaults.\r\n */\r\n interface VideoCVAPI {\r\n /**\r\n * The exact video frame that produced the current `faces` / `hands` /\r\n * `pose` / `segmentation` results: the frame MediaPipe actually analysed.\r\n *\r\n * Choose between `analysedFrame` and `viji.video.currentFrame` by asking\r\n * whether the effect reads pixels from the displayed frame at CV-derived\r\n * positions. Reach for `analysedFrame` when the answer is yes\r\n * (compositing the segmentation mask onto the body, sampling skin tone\r\n * under a face landmark, warping the face along its mesh, texture-mapped\r\n * face filters): pairing the displayed frame with the CV results is\r\n * required for those effects. Stay on `currentFrame` when the answer is\r\n * no (drawing landmark dots, particles, debug overlays, geometry driven\r\n * by CV positions): `analysedFrame` only refreshes when MediaPipe\r\n * completes an inference, which is not every frame, so reaching for it\r\n * without a reason makes the displayed video stutter or hold between\r\n * inferences.\r\n *\r\n * Pairing guarantee: within a single `render()` call, `analysedFrame`\r\n * is paired with the values of `faces`, `hands`, `pose`, `segmentation`\r\n * read in the same call.\r\n *\r\n * `null` until the first CV inference completes after a feature is\r\n * enabled, after the video disconnects, or after a CV-feature toggle\r\n * clears state. A common pattern is\r\n * `viji.video.cv.analysedFrame ?? viji.video.currentFrame` to fall back\r\n * to the live feed during the brief startup window; expect a small\r\n * visual hitch when the source switches as the first inference lands.\r\n *\r\n * Read-only: this `OffscreenCanvas` is owned by the engine. Do not\r\n * mutate it (no `getContext`-and-paint, no `transferToImageBitmap`).\r\n * Drawing it as a source (`ctx.drawImage`, `gl.texImage2D`,\r\n * `p5.image(...)`) is the only supported usage.\r\n */\r\n analysedFrame: OffscreenCanvas | null;\r\n /**\r\n * Returns `analysedFrame` as raw RGBA `ImageData` for per-pixel CPU\r\n * analysis, or `null` when no CV result has landed yet (or the stream is\r\n * disconnected). Cached: re-extracted only when a new CV result arrives,\r\n * so multiple readers within a render share one allocation. Slow\r\n * compared to drawing `analysedFrame` directly. Use only when you need\r\n * pixel values aligned with CV landmark positions (e.g. sampling skin\r\n * colour at a face landmark).\r\n */\r\n getAnalysedFrameData: () => ImageData | null;\r\n /** Detected faces (empty array when face detection is off or no faces are visible). */\r\n faces: FaceData[];\r\n /** Detected hands (up to 2; empty array when hand tracking is off or no hands are visible). */\r\n hands: HandData[];\r\n /** Detected body pose, or `null` when pose detection is off or no pose is visible. */\r\n pose: PoseData | null;\r\n /** Body segmentation mask, or `null` when segmentation is off. */\r\n segmentation: SegmentationData | null;\r\n /**\r\n * Toggle face detection. Populates `face.bounds`, `face.center`,\r\n * `face.confidence` on each detected face. Independent of face mesh and\r\n * emotion detection.\r\n *\r\n * Safe to call from module scope as well as from inside `render()`. The\r\n * verb is idempotent and reference-counted; per-frame calls inside\r\n * `render()` (the canonical toggle-gated pattern) are cheap.\r\n *\r\n * @returns Resolves once the underlying pipeline has finished switching.\r\n */\r\n enableFaceDetection(enabled: boolean): Promise<void>;\r\n /**\r\n * Toggle 468-point face mesh and computed head pose (`pitch`, `yaw`,\r\n * `roll`). Populates `face.landmarks` and `face.headPose` on the face\r\n * entry. Does NOT populate `face.bounds` / `face.center` / `face.confidence`\r\n * — those are produced only by face detection. Enable both if you need\r\n * both, or compute bounds from `face.landmarks` min/max yourself.\r\n *\r\n * Safe to call from module scope as well as from inside `render()`. The\r\n * verb is idempotent and reference-counted.\r\n *\r\n * @returns Resolves once the pipeline has finished switching.\r\n */\r\n enableFaceMesh(enabled: boolean): Promise<void>;\r\n /**\r\n * Toggle 7 expressions + 52 ARKit blendshape coefficients on each face.\r\n * Populates `face.blendshapes` and `face.expressions`. Internally requires\r\n * the face landmarker model (loads it alongside `enableFaceMesh` if both\r\n * are enabled; loads it on its own otherwise so `face.landmarks` and\r\n * `face.headPose` are also populated). Does NOT populate\r\n * `face.bounds` / `face.center` / `face.confidence` — enable face\r\n * detection for those.\r\n *\r\n * Safe to call from module scope as well as from inside `render()`. The\r\n * verb is idempotent and reference-counted.\r\n *\r\n * @returns Resolves once the pipeline has finished switching.\r\n */\r\n enableEmotionDetection(enabled: boolean): Promise<void>;\r\n /**\r\n * Toggle 21-point hand landmarks and ML-classified gesture confidences\r\n * for up to two hands. Populates `viji.video.cv.hands[]` with `landmarks`,\r\n * `palm`, `bounds` (computed from landmarks), and `gestures`.\r\n *\r\n * Safe to call from module scope as well as from inside `render()`. The\r\n * verb is idempotent and reference-counted.\r\n *\r\n * @returns Resolves once the pipeline has finished switching.\r\n */\r\n enableHandTracking(enabled: boolean): Promise<void>;\r\n /**\r\n * Toggle 33-point BlazePose body landmarks (face / torso / arms / legs).\r\n * Populates `viji.video.cv.pose`.\r\n *\r\n * Safe to call from module scope as well as from inside `render()`. The\r\n * verb is idempotent and reference-counted.\r\n *\r\n * @returns Resolves once the pipeline has finished switching.\r\n */\r\n enablePoseDetection(enabled: boolean): Promise<void>;\r\n /**\r\n * Toggle per-pixel person/background segmentation mask. Populates\r\n * `viji.video.cv.segmentation`.\r\n *\r\n * Safe to call from module scope as well as from inside `render()`. The\r\n * verb is idempotent and reference-counted.\r\n *\r\n * @returns Resolves once the pipeline has finished switching.\r\n */\r\n enableBodySegmentation(enabled: boolean): Promise<void>;\r\n /** Returns the list of CV features currently enabled on this stream. */\r\n getActiveFeatures(): CVFeature[];\r\n /** Returns `true` if the CV worker is actively processing frames. */\r\n isProcessing(): boolean;\r\n }\r\n\n /**\r\n * The Viji API surface available to artist code as the global `viji` object.\r\n * Groups canvas access, timing, connected media APIs, user interaction, device\r\n * sensors, parameter helpers, and the `useContext()` selector.\r\n */\r\n interface VijiAPI {\r\n /** The `OffscreenCanvas` driving the scene. The host owns its lifecycle and dimensions; prefer `useContext()` over touching this directly. */\r\n canvas: OffscreenCanvas;\r\n /** 2D rendering context. `undefined` until `viji.useContext('2d')` is called; afterwards equals the cached context. */\r\n ctx?: OffscreenCanvasRenderingContext2D;\r\n /** WebGL rendering context. `undefined` until `viji.useContext('webgl')` or `'webgl2'` is called; afterwards equals the cached context. */\r\n gl?: WebGLRenderingContext | WebGL2RenderingContext;\r\n /** WebGPU canvas context. `undefined` until `viji.useContext('webgpu')` (or a direct `viji.canvas.getContext('webgpu')`) succeeds; afterwards equals the acquired context. Stays `undefined` on browsers without WebGPU support. */\r\n gpu?: GPUCanvasContext;\r\n /** Current canvas width in pixels. Updates automatically when the host resizes the canvas; read every frame. */\r\n width: number;\r\n /** Current canvas height in pixels. Updates automatically when the host resizes the canvas; read every frame. */\r\n height: number;\r\n /** Seconds elapsed since the scene started (monotonically increasing float). Use for oscillations and absolute-time effects. */\r\n time: number;\r\n /** Seconds since the previous frame. Use for accumulation: movement, physics, fades, anything that should progress per second regardless of FPS. */\r\n deltaTime: number;\r\n /** Integer frame counter starting at `0` and incrementing by `1` each frame. */\r\n frameCount: number;\r\n /** Target frames-per-second for the host's current frame-rate mode (screen refresh rate divided by the mode divisor 1/2/4/8). */\r\n fps: number;\r\n /** Real-time analysis of the main audio stream: volume, frequency bands, beat detection, spectral features. Fields are zeroed when no audio source is connected. */\r\n audio: AudioAPI;\r\n /** Main video stream API: pixel access, frame metadata, and computer-vision results (face, hands, pose, segmentation). */\r\n video: VideoAPI;\r\n /** Additional video streams provided by the host. These do not run CV processing; use them for raw pixel access only. */\r\n videoStreams: VideoAPI[];\r\n /** Additional audio streams (lightweight analysis: volume, bands, spectral). No beat detection; use the main `audio` for that. */\r\n audioStreams: AudioStreamAPI[];\r\n /** Mouse position, buttons, wheel, and per-frame movement state. Coordinates are in canvas pixels. */\r\n mouse: MouseAPI;\r\n /** Keyboard state: per-frame press/release queries, currently held keys, and modifier flags. */\r\n keyboard: KeyboardAPI;\r\n /** Multi-touch state: count, primary touch shortcut, and the per-frame `started` / `moved` / `ended` arrays. */\r\n touches: TouchAPI;\r\n /** Unified pointer (mouse + primary touch). Convenient single-point input that works on both desktop and mobile. */\r\n pointer: PointerAPI;\r\n /** Internal device sensors (motion + orientation) reported by the device running the scene. */\r\n device: DeviceSensorState;\r\n /** External connected devices reporting sensor / camera / audio. Each entry has its own `id`, `name`, and per-device API surface. */\r\n devices: DeviceState[];\r\n /**\r\n * Declares a numeric slider parameter. The host UI renders a draggable slider.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const radius = viji.slider(50, { min: 10, max: 200, step: 1, label: 'Radius' });\r\n * // ...\r\n * function render(viji) { drawCircle(radius.value); }\r\n */\r\n slider: (defaultValue: number, config: SliderConfig) => SliderParameter;\r\n /**\r\n * Declares a color parameter. Accepts hex strings, CSS color functions, or RGB / HSB objects;\r\n * the value is always normalized to a canonical lowercase hex string and exposes derived\r\n * `.rgb` / `.hsb` / `.alpha` accessors. Pass `alpha: true` to enable transparency: the value\r\n * becomes `#rrggbbaa` and alpha-bearing inputs (`rgba()`, `#rrggbbaa`, ...) are accepted.\r\n * Without it, alpha-bearing inputs are rejected.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const tint = viji.color('#ff6600', { label: 'Tint' });\r\n * // tint.value -> '#ff6600', tint.rgb -> { r: 255, g: 102, b: 0 }, tint.hsb -> { h: 24, s: 100, b: 100 }, tint.alpha -> 1\r\n * const glow = viji.color('#ffffff80', { label: 'Glow', alpha: true });\r\n * // glow.value -> '#ffffff80', glow.alpha -> 0.5\r\n */\r\n color: (defaultValue: ColorInput, config: ColorConfig) => ColorParameter;\r\n /**\r\n * Declares a boolean toggle parameter. The host UI renders an on/off switch.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const showTrail = viji.toggle(true, { label: 'Show Trail' });\r\n */\r\n toggle: (defaultValue: boolean, config: ToggleConfig) => ToggleParameter;\r\n /**\r\n * Declares a dropdown selection parameter. The element type of `options`\r\n * (`string` or `number`) determines the parameter's value type.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const shape = viji.select('circle', { options: ['circle', 'square', 'triangle'], label: 'Shape' });\r\n */\r\n select: (defaultValue: string | number, config: SelectConfig) => SelectParameter;\r\n /**\r\n * Declares a text input parameter. The host UI renders a single-line text field.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const caption = viji.text('Hello', { label: 'Caption', maxLength: 64 });\r\n */\r\n text: (defaultValue: string, config: TextConfig) => TextParameter;\r\n /**\r\n * Declares a precise numeric input parameter. Like `slider()` but the host UI\r\n * shows a number field instead of a draggable handle.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const count = viji.number(12, { min: 1, max: 64, step: 1, label: 'Count' });\r\n */\r\n number: (defaultValue: number, config: NumberConfig) => NumberParameter;\r\n /**\r\n * Declares an image upload parameter. The user-supplied image becomes available\r\n * as `value` (an `ImageBitmap`); in P5 scenes a `.p5` accessor is also added at runtime.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const tex = viji.image(null, { label: 'Texture' });\r\n * if (tex.value) ctx.drawImage(tex.value, 0, 0, viji.width, viji.height);\r\n */\r\n image: (defaultValue: null, config: ImageConfig) => ImageParameter;\r\n /**\r\n * Declares a momentary button parameter. `value` is `true` for one frame after\r\n * the user clicks, then auto-resets. Perfect for triggering discrete events.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const reset = viji.button({ label: 'Reset' });\r\n * function render(viji) { if (reset.value) state = initialState; }\r\n */\r\n button: (config: ButtonConfig) => ButtonParameter;\r\n /**\r\n * Declares a 2D coordinate parameter. Both `value.x` and `value.y` are in `-1..1`.\r\n * Must be called at the top level of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const origin = viji.coordinate({ x: 0, y: 0 }, { label: 'Origin' });\r\n * const cx = viji.width / 2 + origin.value.x * viji.width * 0.4;\r\n */\r\n coordinate: (defaultValue: CoordinateValue, config: CoordinateConfig) => CoordinateParameter;\r\n /**\r\n * Declares a gradient parameter. The host renders a ramp editor; `value` is the live,\r\n * sorted stop list and `at(t)` samples the ramp (CSS `linear-gradient` semantics).\r\n * Stop colors accept every color form; pass `alpha: true` for per-stop transparency.\r\n * `default` is required (no evenly-spaced shorthand). Must be called at the top level\r\n * of the scene, never inside `render()`.\r\n *\r\n * @example\r\n * const ramp = viji.gradient(\r\n * [{ color: '#ff6b6b', position: 0 }, { color: '#4ecdc4', position: 1 }],\r\n * { label: 'Ramp' }\r\n * );\r\n * function render(viji) {\r\n * const fill = viji.ctx.createLinearGradient(0, 0, viji.width, 0);\r\n * for (const stop of ramp.value) fill.addColorStop(stop.position, stop.color);\r\n * viji.ctx.fillStyle = fill;\r\n * viji.ctx.fillRect(0, 0, viji.width, viji.height);\r\n * viji.ctx.fillStyle = ramp.at(0.5); // per-element color, same math as the fill\r\n * }\r\n */\r\n gradient: (defaultValue: GradientInput, config: GradientConfig) => GradientParameter;\r\n /**\r\n * Selects the 2D canvas rendering context. Returns the same instance on\r\n * subsequent calls and also stores it on `viji.ctx`. A canvas only supports\r\n * one context type. If a different context type was already requested,\r\n * the call returns `null`. Choose ONE type and use it for the entire scene.\r\n *\r\n * @example\r\n * const ctx = viji.useContext('2d');\r\n * ctx.fillRect(0, 0, viji.width, viji.height);\r\n */\r\n useContext(type: '2d'): OffscreenCanvasRenderingContext2D;\r\n /**\r\n * Selects a WebGL 1 rendering context. Returns the same instance on subsequent\r\n * calls and also stores it on `viji.gl`. A canvas only supports one context\r\n * type. If a different context type was already requested, the call returns\r\n * `null`. Choose ONE type and use it for the entire scene.\r\n */\r\n useContext(type: 'webgl'): WebGLRenderingContext;\r\n /**\r\n * Selects a WebGL 2 rendering context. Returns the same instance on subsequent\r\n * calls and also stores it on `viji.gl`. A canvas only supports one context\r\n * type. If a different context type was already requested, the call returns\r\n * `null`. Choose ONE type and use it for the entire scene.\r\n */\r\n useContext(type: 'webgl2'): WebGL2RenderingContext;\r\n /**\r\n * Selects a WebGPU canvas context. Returns the raw `GPUCanvasContext` and\r\n * also stores it on `viji.gpu`. Adapter and device acquisition stay in scene\r\n * code (`navigator.gpu` is available; top-level `await` works), and the\r\n * scene must call `configure()` on the context before rendering. A canvas\r\n * only supports one context type. Returns `null` when a different context\r\n * type was already requested OR when the browser has no WebGPU support,\r\n * so always guard and provide a fallback. Choose ONE type and use it for\r\n * the entire scene.\r\n *\r\n * @example\r\n * const gctx = viji.useContext('webgpu');\r\n * if (!navigator.gpu || !gctx) {\r\n * // fall back, e.g. render a message via a 2d scene variant\r\n * } else {\r\n * const adapter = await navigator.gpu.requestAdapter();\r\n * const device = await adapter.requestDevice();\r\n * const format = navigator.gpu.getPreferredCanvasFormat();\r\n * gctx.configure({ device, format, alphaMode: 'opaque' });\r\n * }\r\n */\r\n useContext(type: 'webgpu'): GPUCanvasContext | null;\r\n }\r\n\n // ===== WEBGPU TYPES (inlined from @webgpu/types v0.1.72) =====\n // *********************************************************************************************\n // This file is manually-edited by diffing against an autogenerated file. See README.md.\n // *********************************************************************************************\n\n // *********************************************************************************************\n // Manually-written - auto copied from extra.d.ts\n // *********************************************************************************************\n\n // AllowSharedBufferSource wasn't introduced until TypeScript 5.2.\n // But it also didn't include SharedArrayBuffer in the union.\n // This broke in ES2024 when ArrayBuffer gained some properties that SharedArrayBuffer didn't.\n // So, we use our own definition for AllowSharedBufferSource.\n\n type GPUAllowSharedBufferSource =\n\n | BufferSource\n | SharedArrayBuffer;\n\n // Stronger typing for getContext()\n\n interface HTMLCanvasElement {\n getContext(\n contextId:\n | \"webgpu\"\n ): GPUCanvasContext | null;\n }\n interface OffscreenCanvas {\n getContext(\n contextId:\n | \"webgpu\"\n ): GPUCanvasContext | null;\n }\n\n // Defined as an empty interface here to prevent errors when using these types in a worker.\n\n interface HTMLVideoElement {}\n\n // Strict types defined to help developers catch a common class of errors.\n // This interface defines depth as an undefined, which will cause a type check failure if someone\n // attempts to set depth rather than depthOrArrayLayers on a GPUExtent3D (an easy mistake to make.)\n\n type GPUOrigin2DStrict =\n\n | Iterable<GPUIntegerCoordinate>\n | GPUOrigin2DDictStrict;\n interface GPUOrigin2DDictStrict\n extends GPUOrigin2DDict {\n /** @deprecated Does not exist for GPUOrigin2D. */\n z?: undefined;\n }\n type GPUExtent3DStrict =\n\n | Iterable<GPUIntegerCoordinate>\n | GPUExtent3DDictStrict;\n interface GPUExtent3DDictStrict\n extends GPUExtent3DDict {\n /** @deprecated The correct name is `depthOrArrayLayers`. */\n depth?: undefined;\n }\n\n // Stronger typing for event listeners.\n\n /** @internal */\n interface __GPUDeviceEventMap {\n uncapturederror: GPUUncapturedErrorEvent;\n }\n\n // Extensions to the generated definition below.\n interface GPUDevice {\n addEventListener<\n K extends keyof __GPUDeviceEventMap\n >(\n type: K,\n listener: (\n this: GPUDevice,\n ev: __GPUDeviceEventMap[K]\n ) => any,\n options?:\n | boolean\n | AddEventListenerOptions\n ): void;\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?:\n | boolean\n | AddEventListenerOptions\n ): void;\n removeEventListener<\n K extends keyof __GPUDeviceEventMap\n >(\n type: K,\n listener: (\n this: GPUDevice,\n ev: __GPUDeviceEventMap[K]\n ) => any,\n options?:\n | boolean\n | EventListenerOptions\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?:\n | boolean\n | EventListenerOptions\n ): void;\n }\n\n interface GPUCanvasConfigurationOut\n extends Required<\n Omit<\n GPUCanvasConfiguration,\n \"toneMapping\"\n >\n > {\n /** {@inheritDoc GPUCanvasConfiguration.viewFormats} */\n viewFormats: GPUTextureFormat[];\n /**\n * {@inheritDoc GPUCanvasConfiguration.toneMapping}\n */\n toneMapping?: GPUCanvasToneMapping;\n }\n\n /** @deprecated Use {@link GPUTexelCopyBufferLayout} */\n type GPUImageDataLayout =\n GPUTexelCopyBufferLayout;\n /** @deprecated Use {@link GPUTexelCopyBufferInfo} */\n type GPUImageCopyBuffer =\n GPUTexelCopyBufferInfo;\n /** @deprecated Use {@link GPUTexelCopyTextureInfo} */\n type GPUImageCopyTexture =\n GPUTexelCopyTextureInfo;\n /** @deprecated Use {@link GPUCopyExternalImageDestInfo} */\n type GPUImageCopyTextureTagged =\n GPUCopyExternalImageDestInfo;\n /** @deprecated Use {@link GPUCopyExternalImageSourceInfo} */\n type GPUImageCopyExternalImage =\n GPUCopyExternalImageSourceInfo;\n /** @deprecated Use {@link GPUCopyExternalImageSource} */\n type GPUImageCopyExternalImageSource =\n GPUCopyExternalImageSource;\n\n // *********************************************************************************************\n // Semi-auto-generated (by manual diff with autogenerated types)\n // *********************************************************************************************\n\n type GPUBindingResource =\n\n | GPUSampler\n | GPUTexture\n | GPUTextureView\n | GPUBuffer\n | GPUBufferBinding\n | GPUExternalTexture;\n type GPUBufferDynamicOffset =\n number;\n type GPUBufferUsageFlags =\n number;\n type GPUColor =\n\n | Iterable<number>\n | GPUColorDict;\n type GPUColorWriteFlags =\n number;\n type GPUCopyExternalImageSource =\n\n | ImageBitmap\n | ImageData\n | HTMLImageElement\n | HTMLVideoElement\n | VideoFrame\n | HTMLCanvasElement\n | OffscreenCanvas;\n type GPUDepthBias =\n number;\n type GPUExtent3D =\n\n | Iterable<GPUIntegerCoordinate>\n | GPUExtent3DDict;\n type GPUFlagsConstant =\n number;\n type GPUIndex32 =\n number;\n type GPUIntegerCoordinate =\n number;\n type GPUIntegerCoordinateOut =\n number;\n type GPUMapModeFlags =\n number;\n type GPUOrigin2D =\n\n | Iterable<GPUIntegerCoordinate>\n | GPUOrigin2DDict;\n type GPUOrigin3D =\n\n | Iterable<GPUIntegerCoordinate>\n | GPUOrigin3DDict;\n type GPUPipelineConstantValue =\n number;\n type GPUSampleMask =\n number;\n type GPUShaderStageFlags =\n number;\n type GPUSignedOffset32 =\n number;\n type GPUSize32 =\n number;\n type GPUSize32Out =\n number;\n type GPUSize64 =\n number;\n type GPUSize64Out =\n number;\n type GPUStencilValue =\n number;\n type GPUTextureUsageFlags =\n number;\n type GPUAddressMode =\n\n | \"clamp-to-edge\"\n | \"repeat\"\n | \"mirror-repeat\";\n type GPUAutoLayoutMode =\n \"auto\";\n type GPUBlendFactor =\n\n | \"zero\"\n | \"one\"\n | \"src\"\n | \"one-minus-src\"\n | \"src-alpha\"\n | \"one-minus-src-alpha\"\n | \"dst\"\n | \"one-minus-dst\"\n | \"dst-alpha\"\n | \"one-minus-dst-alpha\"\n | \"src-alpha-saturated\"\n | \"constant\"\n | \"one-minus-constant\"\n | \"src1\"\n | \"one-minus-src1\"\n | \"src1-alpha\"\n | \"one-minus-src1-alpha\";\n type GPUBlendOperation =\n\n | \"add\"\n | \"subtract\"\n | \"reverse-subtract\"\n | \"min\"\n | \"max\";\n type GPUBufferBindingType =\n\n | \"uniform\"\n | \"storage\"\n | \"read-only-storage\";\n type GPUBufferMapState =\n\n | \"unmapped\"\n | \"pending\"\n | \"mapped\";\n type GPUCanvasAlphaMode =\n\n | \"opaque\"\n | \"premultiplied\";\n type GPUCanvasToneMappingMode =\n\n | \"standard\"\n | \"extended\";\n type GPUCompareFunction =\n\n | \"never\"\n | \"less\"\n | \"equal\"\n | \"less-equal\"\n | \"greater\"\n | \"not-equal\"\n | \"greater-equal\"\n | \"always\";\n type GPUCompilationMessageType =\n\n | \"error\"\n | \"warning\"\n | \"info\";\n type GPUCullMode =\n\n | \"none\"\n | \"front\"\n | \"back\";\n type GPUDeviceLostReason =\n\n | \"unknown\"\n | \"destroyed\";\n type GPUErrorFilter =\n\n | \"validation\"\n | \"out-of-memory\"\n | \"internal\";\n type GPUFeatureName =\n\n | \"core-features-and-limits\"\n | \"depth-clip-control\"\n | \"depth32float-stencil8\"\n | \"texture-compression-bc\"\n | \"texture-compression-bc-sliced-3d\"\n | \"texture-compression-etc2\"\n | \"texture-compression-astc\"\n | \"texture-compression-astc-sliced-3d\"\n | \"timestamp-query\"\n | \"indirect-first-instance\"\n | \"shader-f16\"\n | \"rg11b10ufloat-renderable\"\n | \"bgra8unorm-storage\"\n | \"float32-filterable\"\n | \"float32-blendable\"\n | \"clip-distances\"\n | \"dual-source-blending\"\n | \"subgroups\"\n | \"texture-formats-tier1\"\n | \"texture-formats-tier2\"\n | \"primitive-index\"\n | \"texture-component-swizzle\"\n | \"subgroup-size-control\";\n type GPUFilterMode =\n\n | \"nearest\"\n | \"linear\";\n type GPUFrontFace =\n\n | \"ccw\"\n | \"cw\";\n type GPUIndexFormat =\n\n | \"uint16\"\n | \"uint32\";\n type GPULoadOp =\n\n | \"load\"\n | \"clear\";\n type GPUMipmapFilterMode =\n\n | \"nearest\"\n | \"linear\";\n type GPUPipelineErrorReason =\n\n | \"validation\"\n | \"internal\";\n type GPUPowerPreference =\n\n | \"low-power\"\n | \"high-performance\";\n type GPUPrimitiveTopology =\n\n | \"point-list\"\n | \"line-list\"\n | \"line-strip\"\n | \"triangle-list\"\n | \"triangle-strip\";\n type GPUQueryType =\n\n | \"occlusion\"\n | \"timestamp\";\n type GPUSamplerBindingType =\n\n | \"filtering\"\n | \"non-filtering\"\n | \"comparison\";\n type GPUStencilOperation =\n\n | \"keep\"\n | \"zero\"\n | \"replace\"\n | \"invert\"\n | \"increment-clamp\"\n | \"decrement-clamp\"\n | \"increment-wrap\"\n | \"decrement-wrap\";\n type GPUStorageTextureAccess =\n\n | \"write-only\"\n | \"read-only\"\n | \"read-write\";\n type GPUStoreOp =\n\n | \"store\"\n | \"discard\";\n type GPUTextureAspect =\n\n | \"all\"\n | \"stencil-only\"\n | \"depth-only\";\n type GPUTextureDimension =\n\n | \"1d\"\n | \"2d\"\n | \"3d\";\n type GPUTextureFormat =\n\n | \"r8unorm\"\n | \"r8snorm\"\n | \"r8uint\"\n | \"r8sint\"\n | \"r16unorm\"\n | \"r16snorm\"\n | \"r16uint\"\n | \"r16sint\"\n | \"r16float\"\n | \"rg8unorm\"\n | \"rg8snorm\"\n | \"rg8uint\"\n | \"rg8sint\"\n | \"r32uint\"\n | \"r32sint\"\n | \"r32float\"\n | \"rg16unorm\"\n | \"rg16snorm\"\n | \"rg16uint\"\n | \"rg16sint\"\n | \"rg16float\"\n | \"rgba8unorm\"\n | \"rgba8unorm-srgb\"\n | \"rgba8snorm\"\n | \"rgba8uint\"\n | \"rgba8sint\"\n | \"bgra8unorm\"\n | \"bgra8unorm-srgb\"\n | \"rgb9e5ufloat\"\n | \"rgb10a2uint\"\n | \"rgb10a2unorm\"\n | \"rg11b10ufloat\"\n | \"rg32uint\"\n | \"rg32sint\"\n | \"rg32float\"\n | \"rgba16unorm\"\n | \"rgba16snorm\"\n | \"rgba16uint\"\n | \"rgba16sint\"\n | \"rgba16float\"\n | \"rgba32uint\"\n | \"rgba32sint\"\n | \"rgba32float\"\n | \"stencil8\"\n | \"depth16unorm\"\n | \"depth24plus\"\n | \"depth24plus-stencil8\"\n | \"depth32float\"\n | \"depth32float-stencil8\"\n | \"bc1-rgba-unorm\"\n | \"bc1-rgba-unorm-srgb\"\n | \"bc2-rgba-unorm\"\n | \"bc2-rgba-unorm-srgb\"\n | \"bc3-rgba-unorm\"\n | \"bc3-rgba-unorm-srgb\"\n | \"bc4-r-unorm\"\n | \"bc4-r-snorm\"\n | \"bc5-rg-unorm\"\n | \"bc5-rg-snorm\"\n | \"bc6h-rgb-ufloat\"\n | \"bc6h-rgb-float\"\n | \"bc7-rgba-unorm\"\n | \"bc7-rgba-unorm-srgb\"\n | \"etc2-rgb8unorm\"\n | \"etc2-rgb8unorm-srgb\"\n | \"etc2-rgb8a1unorm\"\n | \"etc2-rgb8a1unorm-srgb\"\n | \"etc2-rgba8unorm\"\n | \"etc2-rgba8unorm-srgb\"\n | \"eac-r11unorm\"\n | \"eac-r11snorm\"\n | \"eac-rg11unorm\"\n | \"eac-rg11snorm\"\n | \"astc-4x4-unorm\"\n | \"astc-4x4-unorm-srgb\"\n | \"astc-5x4-unorm\"\n | \"astc-5x4-unorm-srgb\"\n | \"astc-5x5-unorm\"\n | \"astc-5x5-unorm-srgb\"\n | \"astc-6x5-unorm\"\n | \"astc-6x5-unorm-srgb\"\n | \"astc-6x6-unorm\"\n | \"astc-6x6-unorm-srgb\"\n | \"astc-8x5-unorm\"\n | \"astc-8x5-unorm-srgb\"\n | \"astc-8x6-unorm\"\n | \"astc-8x6-unorm-srgb\"\n | \"astc-8x8-unorm\"\n | \"astc-8x8-unorm-srgb\"\n | \"astc-10x5-unorm\"\n | \"astc-10x5-unorm-srgb\"\n | \"astc-10x6-unorm\"\n | \"astc-10x6-unorm-srgb\"\n | \"astc-10x8-unorm\"\n | \"astc-10x8-unorm-srgb\"\n | \"astc-10x10-unorm\"\n | \"astc-10x10-unorm-srgb\"\n | \"astc-12x10-unorm\"\n | \"astc-12x10-unorm-srgb\"\n | \"astc-12x12-unorm\"\n | \"astc-12x12-unorm-srgb\";\n type GPUTextureSampleType =\n\n | \"float\"\n | \"unfilterable-float\"\n | \"depth\"\n | \"sint\"\n | \"uint\";\n type GPUTextureViewDimension =\n\n | \"1d\"\n | \"2d\"\n | \"2d-array\"\n | \"cube\"\n | \"cube-array\"\n | \"3d\";\n type GPUVertexFormat =\n\n | \"uint8\"\n | \"uint8x2\"\n | \"uint8x4\"\n | \"sint8\"\n | \"sint8x2\"\n | \"sint8x4\"\n | \"unorm8\"\n | \"unorm8x2\"\n | \"unorm8x4\"\n | \"snorm8\"\n | \"snorm8x2\"\n | \"snorm8x4\"\n | \"uint16\"\n | \"uint16x2\"\n | \"uint16x4\"\n | \"sint16\"\n | \"sint16x2\"\n | \"sint16x4\"\n | \"unorm16\"\n | \"unorm16x2\"\n | \"unorm16x4\"\n | \"snorm16\"\n | \"snorm16x2\"\n | \"snorm16x4\"\n | \"float16\"\n | \"float16x2\"\n | \"float16x4\"\n | \"float32\"\n | \"float32x2\"\n | \"float32x3\"\n | \"float32x4\"\n | \"uint32\"\n | \"uint32x2\"\n | \"uint32x3\"\n | \"uint32x4\"\n | \"sint32\"\n | \"sint32x2\"\n | \"sint32x3\"\n | \"sint32x4\"\n | \"unorm10-10-10-2\"\n | \"snorm10-10-10-2\"\n | \"unorm8x4-bgra\";\n type GPUVertexStepMode =\n\n | \"vertex\"\n | \"instance\";\n\n interface GPUBindGroupDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * The {@link GPUBindGroupLayout} the entries of this bind group will conform to.\n */\n layout: GPUBindGroupLayout;\n /**\n * A list of entries describing the resources to expose to the shader for each binding\n * described by the {@link GPUBindGroupDescriptor#layout}.\n */\n entries: Iterable<GPUBindGroupEntry>;\n }\n\n interface GPUBindGroupEntry {\n /**\n * A unique identifier for a resource binding within the {@link GPUBindGroup}, corresponding to a\n * {@link GPUBindGroupLayoutEntry#binding | GPUBindGroupLayoutEntry.binding} and a @binding\n * attribute in the {@link GPUShaderModule}.\n */\n binding: GPUIndex32;\n /**\n * The resource to bind, which may be a {@link GPUSampler}, {@link GPUTexture}, {@link GPUTextureView},\n * {@link GPUBuffer}, {@link GPUBufferBinding}, or {@link GPUExternalTexture}.\n */\n resource: GPUBindingResource;\n }\n\n interface GPUBindGroupLayoutDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * A list of entries describing the shader resource bindings for a bind group.\n */\n entries: Iterable<GPUBindGroupLayoutEntry>;\n }\n\n interface GPUBindGroupLayoutEntry {\n /**\n * A unique identifier for a resource binding within the {@link GPUBindGroupLayout}, corresponding\n * to a {@link GPUBindGroupEntry#binding | GPUBindGroupEntry.binding} and a @binding\n * attribute in the {@link GPUShaderModule}.\n */\n binding: GPUIndex32;\n /**\n * A bitset of the members of {@link GPUShaderStage}.\n * Each set bit indicates that a {@link GPUBindGroupLayoutEntry}'s resource\n * will be accessible from the associated shader stage.\n */\n visibility: GPUShaderStageFlags;\n /**\n */\n buffer?: GPUBufferBindingLayout;\n /**\n */\n sampler?: GPUSamplerBindingLayout;\n /**\n */\n texture?: GPUTextureBindingLayout;\n /**\n */\n storageTexture?: GPUStorageTextureBindingLayout;\n /**\n * Exactly one of these members must be set, indicating the binding type.\n * The contents of the member specify options specific to that type.\n * The corresponding resource in {@link GPUDevice#createBindGroup} requires\n * the corresponding binding resource type for this binding.\n */\n externalTexture?: GPUExternalTextureBindingLayout;\n }\n\n interface GPUBlendComponent {\n /**\n * Defines the {@link GPUBlendOperation} used to calculate the values written to the target\n * attachment components.\n */\n operation?: GPUBlendOperation;\n /**\n * Defines the {@link GPUBlendFactor} operation to be performed on values from the fragment shader.\n */\n srcFactor?: GPUBlendFactor;\n /**\n * Defines the {@link GPUBlendFactor} operation to be performed on values from the target attachment.\n */\n dstFactor?: GPUBlendFactor;\n }\n\n interface GPUBlendState {\n /**\n * Defines the blending behavior of the corresponding render target for color channels.\n */\n color: GPUBlendComponent;\n /**\n * Defines the blending behavior of the corresponding render target for the alpha channel.\n */\n alpha: GPUBlendComponent;\n }\n\n interface GPUBufferBinding {\n /**\n * The {@link GPUBuffer} to bind.\n */\n buffer: GPUBuffer;\n /**\n * The offset, in bytes, from the beginning of {@link GPUBufferBinding#buffer} to the\n * beginning of the range exposed to the shader by the buffer binding.\n */\n offset?: GPUSize64;\n /**\n * The size, in bytes, of the buffer binding.\n * If not map/exist|provided, specifies the range starting at\n * {@link GPUBufferBinding#offset} and ending at the end of {@link GPUBufferBinding#buffer}.\n */\n size?: GPUSize64;\n }\n\n interface GPUBufferBindingLayout {\n /**\n * Indicates the type required for buffers bound to this binding.\n */\n type?: GPUBufferBindingType;\n /**\n * Indicates whether this binding requires a dynamic offset.\n */\n hasDynamicOffset?: boolean;\n /**\n * Indicates the minimum {@link GPUBufferBinding#size} of a buffer binding used with this bind point.\n * Bindings are always validated against this size in {@link GPUDevice#createBindGroup}.\n * If this *is not* `0`, pipeline creation additionally [$validating shader binding|validates$]\n * that this value ≥ the minimum buffer binding size of the variable.\n * If this *is* `0`, it is ignored by pipeline creation, and instead draw/dispatch commands\n * [$Validate encoder bind groups|validate$] that each binding in the {@link GPUBindGroup}\n * satisfies the minimum buffer binding size of the variable.\n * Note:\n * Similar execution-time validation is theoretically possible for other\n * binding-related fields specified for early validation, like\n * {@link GPUTextureBindingLayout#sampleType} and {@link GPUStorageTextureBindingLayout#format},\n * which currently can only be validated in pipeline creation.\n * However, such execution-time validation could be costly or unnecessarily complex, so it is\n * available only for {@link GPUBufferBindingLayout#minBindingSize} which is expected to have the\n * most ergonomic impact.\n */\n minBindingSize?: GPUSize64;\n }\n\n interface GPUBufferDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * The size of the buffer in bytes.\n */\n size: GPUSize64;\n /**\n * The allowed usages for the buffer.\n */\n usage: GPUBufferUsageFlags;\n /**\n * If `true` creates the buffer in an already mapped state, allowing\n * {@link GPUBuffer#getMappedRange} to be called immediately. It is valid to set\n * {@link GPUBufferDescriptor#mappedAtCreation} to `true` even if {@link GPUBufferDescriptor#usage}\n * does not contain {@link GPUBufferUsage#MAP_READ} or {@link GPUBufferUsage#MAP_WRITE}. This can be\n * used to set the buffer's initial data.\n * Guarantees that even if the buffer creation eventually fails, it will still appear as if the\n * mapped range can be written/read to until it is unmapped.\n */\n mappedAtCreation?: boolean;\n }\n\n interface GPUCanvasConfiguration {\n /**\n * The {@link GPUDevice} that textures returned by {@link GPUCanvasContext#getCurrentTexture} will be\n * compatible with.\n */\n device: GPUDevice;\n /**\n * The format that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have.\n * Must be one of the Supported context formats.\n */\n format: GPUTextureFormat;\n /**\n * The usage that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have.\n * {@link GPUTextureUsage#RENDER_ATTACHMENT} is the default, but is not automatically included\n * if the usage is explicitly set. Be sure to include {@link GPUTextureUsage#RENDER_ATTACHMENT}\n * when setting a custom usage if you wish to use textures returned by\n * {@link GPUCanvasContext#getCurrentTexture} as color targets for a render pass.\n */\n usage?: GPUTextureUsageFlags;\n /**\n * The formats that views created from textures returned by\n * {@link GPUCanvasContext#getCurrentTexture} may use.\n */\n viewFormats?: Iterable<GPUTextureFormat>;\n /**\n * The color space that values written into textures returned by\n * {@link GPUCanvasContext#getCurrentTexture} should be displayed with.\n */\n colorSpace?: PredefinedColorSpace;\n /**\n * The tone mapping determines how the content of textures returned by\n * {@link GPUCanvasContext#getCurrentTexture} are to be displayed.\n * <div class=note heading>\n * This is a required feature, but user agents might not yet implement it,\n * effectively supporting only the default {@link GPUCanvasToneMapping}.\n * In such implementations, this member **should not** exist in its implementation of\n * {@link GPUCanvasConfiguration}, to make feature detection possible using\n * {@link GPUCanvasContext#getConfiguration}.\n * This is especially important in implementations which otherwise have HDR capabilities\n * (where a <l>'@media/dynamic-range'</l> of <l>''@media/dynamic-range/high''</l> would be\n * exposed).\n * If an implementation exposes this member and a `high` dynamic range, it **should** render the\n * canvas as an HDR element, not clamp values to the SDR range of the HDR display.\n * </div>\n */\n toneMapping?: GPUCanvasToneMapping;\n /**\n * Determines the effect that alpha values will have on the content of textures returned by\n * {@link GPUCanvasContext#getCurrentTexture} when read, displayed, or used as an image source.\n */\n alphaMode?: GPUCanvasAlphaMode;\n }\n\n interface GPUCanvasToneMapping {\n mode?: GPUCanvasToneMappingMode;\n }\n\n interface GPUColorDict {\n /**\n * The red channel value.\n */\n r: number;\n /**\n * The green channel value.\n */\n g: number;\n /**\n * The blue channel value.\n */\n b: number;\n /**\n * The alpha channel value.\n */\n a: number;\n }\n\n interface GPUColorTargetState {\n /**\n * The {@link GPUTextureFormat} of this color target. The pipeline will only be compatible with\n * {@link GPURenderPassEncoder}s which use a {@link GPUTextureView} of this format in the\n * corresponding color attachment.\n */\n format: GPUTextureFormat;\n /**\n * The blending behavior for this color target. If left undefined, disables blending for this\n * color target.\n */\n blend?: GPUBlendState;\n /**\n * Bitmask controlling which channels are are written to when drawing to this color target.\n */\n writeMask?: GPUColorWriteFlags;\n }\n\n type GPUCommandBufferDescriptor =\n GPUObjectDescriptorBase;\n type GPUCommandEncoderDescriptor =\n GPUObjectDescriptorBase;\n\n interface GPUComputePassDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * Defines which timestamp values will be written for this pass, and where to write them to.\n */\n timestampWrites?: GPUComputePassTimestampWrites;\n }\n\n interface GPUComputePassTimestampWrites {\n /**\n * The {@link GPUQuerySet}, of type {@link GPUQueryType} `\"timestamp\"`, that the query results will be\n * written to.\n */\n querySet: GPUQuerySet;\n /**\n * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into\n * which the timestamp at the beginning of the compute pass will be written.\n */\n beginningOfPassWriteIndex?: GPUSize32;\n /**\n * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into\n * which the timestamp at the end of the compute pass will be written.\n */\n endOfPassWriteIndex?: GPUSize32;\n }\n\n interface GPUComputePipelineDescriptor\n extends GPUPipelineDescriptorBase {\n /**\n * Describes the compute shader entry point of the pipeline.\n */\n compute: GPUProgrammableStage;\n }\n\n interface GPUCopyExternalImageDestInfo\n extends GPUTexelCopyTextureInfo {\n /**\n * Describes the color space and encoding used to encode data into the destination texture.\n * This {@link https://www.w3.org/TR/webgpu/#color-space-conversions | may result} in values outside of the range [0, 1]\n * being written to the target texture, if its format can represent them.\n * Otherwise, the results are clamped to the target texture format's range.\n * Note:\n * If {@link GPUCopyExternalImageDestInfo#colorSpace} matches the source image,\n * conversion might not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}.\n */\n colorSpace?: PredefinedColorSpace;\n /**\n * Describes whether the data written into the texture should have its RGB channels\n * premultiplied by the alpha channel, or not.\n * If this option is set to `true` and the {@link GPUCopyExternalImageSourceInfo#source} is also\n * premultiplied, the source RGB values must be preserved even if they exceed their\n * corresponding alpha values.\n * Note:\n * If {@link GPUCopyExternalImageDestInfo#premultipliedAlpha} matches the source image,\n * conversion might not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}.\n */\n premultipliedAlpha?: boolean;\n }\n\n interface GPUCopyExternalImageSourceInfo {\n /**\n * The source of the texel copy. The copy source data is captured at the moment that\n * {@link GPUQueue#copyExternalImageToTexture} is issued. Source size is determined as described\n * by the external source dimensions table.\n */\n source: GPUCopyExternalImageSource;\n /**\n * Defines the origin of the copy - the minimum (top-left) corner of the source sub-region to copy from.\n * Together with `copySize`, defines the full copy sub-region.\n */\n origin?: GPUOrigin2D;\n /**\n * Describes whether the source image is vertically flipped, or not.\n * If this option is set to `true`, the copy is flipped vertically: the bottom row of the source\n * region is copied into the first row of the destination region, and so on.\n * The {@link GPUCopyExternalImageSourceInfo#origin} option is still relative to the top-left corner\n * of the source image, increasing downward.\n */\n flipY?: boolean;\n }\n\n interface GPUDepthStencilState {\n /**\n * The {@link GPUTextureViewDescriptor#format} of {@link GPURenderPassDescriptor#depthStencilAttachment}\n * this {@link GPURenderPipeline} will be compatible with.\n */\n format: GPUTextureFormat;\n /**\n * Indicates if this {@link GPURenderPipeline} can modify\n * {@link GPURenderPassDescriptor#depthStencilAttachment} depth values.\n */\n depthWriteEnabled?: boolean;\n /**\n * The comparison operation used to test fragment depths against\n * {@link GPURenderPassDescriptor#depthStencilAttachment} depth values.\n */\n depthCompare?: GPUCompareFunction;\n /**\n * Defines how stencil comparisons and operations are performed for front-facing primitives.\n */\n stencilFront?: GPUStencilFaceState;\n /**\n * Defines how stencil comparisons and operations are performed for back-facing primitives.\n */\n stencilBack?: GPUStencilFaceState;\n /**\n * Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value\n * bits are read when performing stencil comparison tests.\n */\n stencilReadMask?: GPUStencilValue;\n /**\n * Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value\n * bits are written to when performing stencil operations.\n */\n stencilWriteMask?: GPUStencilValue;\n /**\n * Constant depth bias added to each triangle fragment. See [$biased fragment depth$] for details.\n */\n depthBias?: GPUDepthBias;\n /**\n * Depth bias that scales with the triangle fragment’s slope. See [$biased fragment depth$] for details.\n */\n depthBiasSlopeScale?: number;\n /**\n * The maximum depth bias of a triangle fragment. See [$biased fragment depth$] for details.\n */\n depthBiasClamp?: number;\n }\n\n interface GPUDeviceDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * Specifies the features that are required by the device request.\n * The request will fail if the adapter cannot provide these features.\n * Exactly the specified set of features, and no more or less, will be allowed in validation\n * of API calls on the resulting device.\n */\n requiredFeatures?: Iterable<GPUFeatureName>;\n /**\n * Specifies the limits that are required by the device request.\n * The request will fail if the adapter cannot provide these limits.\n * Each key with a non-`undefined` value must be the name of a member of supported limits.\n * API calls on the resulting device perform validation according to the exact limits of the\n * device (not the adapter; see {@link https://www.w3.org/TR/webgpu/#limits}).\n * <!-- If we ever need limit types other than GPUSize32/GPUSize64, we can change the value\n * type to `double` or `any` in the future and write out the type conversion explicitly (by\n * reference to WebIDL spec). Or change the entire type to `any` and add back a `dictionary\n * GPULimits` and define the conversion of the whole object by reference to WebIDL. -->\n */\n requiredLimits?: Record<\n string,\n | GPUSize64\n | undefined\n >;\n /**\n * The descriptor for the default {@link GPUQueue}.\n */\n defaultQueue?: GPUQueueDescriptor;\n }\n\n interface GPUExtent3DDict {\n /**\n * The width of the extent.\n */\n width: GPUIntegerCoordinate;\n /**\n * The height of the extent.\n */\n height?: GPUIntegerCoordinate;\n /**\n * The depth of the extent or the number of array layers it contains.\n * If used with a {@link GPUTexture} with a {@link GPUTextureDimension} of {@link GPUTextureDimension} `\"3d\"`\n * defines the depth of the texture. If used with a {@link GPUTexture} with a {@link GPUTextureDimension}\n * of {@link GPUTextureDimension} `\"2d\"` defines the number of array layers in the texture.\n */\n depthOrArrayLayers?: GPUIntegerCoordinate;\n }\n\n interface GPUExternalTextureBindingLayout {}\n\n interface GPUExternalTextureDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * The video source to import the external texture from. Source size is determined as described\n * by the external source dimensions table.\n */\n source:\n | HTMLVideoElement\n | VideoFrame;\n /**\n * The color space the image contents of {@link GPUExternalTextureDescriptor#source} will be\n * converted into when reading.\n */\n colorSpace?: PredefinedColorSpace;\n }\n\n interface GPUFragmentState\n extends GPUProgrammableStage {\n /**\n * A list of {@link GPUColorTargetState} defining the formats and behaviors of the color targets\n * this pipeline writes to.\n */\n targets: Iterable<\n | GPUColorTargetState\n | null\n | undefined\n >;\n }\n\n interface GPUMultisampleState {\n /**\n * Number of samples per pixel. This {@link GPURenderPipeline} will be compatible only\n * with attachment textures ({@link GPURenderPassDescriptor#colorAttachments}\n * and {@link GPURenderPassDescriptor#depthStencilAttachment})\n * with matching {@link GPUTextureDescriptor#sampleCount}s.\n */\n count?: GPUSize32;\n /**\n * Mask determining which samples are written to.\n */\n mask?: GPUSampleMask;\n /**\n * When `true` indicates that a fragment's alpha channel should be used to generate a sample\n * coverage mask.\n */\n alphaToCoverageEnabled?: boolean;\n }\n\n interface GPUObjectDescriptorBase {\n /**\n * The initial value of {@link GPUObjectBase#label | GPUObjectBase.label}.\n */\n label?: string;\n }\n\n interface GPUOrigin2DDict {\n x?: GPUIntegerCoordinate;\n y?: GPUIntegerCoordinate;\n }\n\n interface GPUOrigin3DDict {\n x?: GPUIntegerCoordinate;\n y?: GPUIntegerCoordinate;\n z?: GPUIntegerCoordinate;\n }\n\n interface GPUPipelineDescriptorBase\n extends GPUObjectDescriptorBase {\n /**\n * The {@link GPUPipelineLayout} for this pipeline, or {@link GPUAutoLayoutMode} `\"auto\"` to generate\n * the pipeline layout automatically.\n * Note: If {@link GPUAutoLayoutMode} `\"auto\"` is used the pipeline cannot share {@link GPUBindGroup}s\n * with any other pipelines.\n */\n layout:\n | GPUPipelineLayout\n | GPUAutoLayoutMode;\n }\n\n interface GPUPipelineErrorInit {\n reason: GPUPipelineErrorReason;\n }\n\n interface GPUPipelineLayoutDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * A list of optional {@link GPUBindGroupLayout}s the pipeline will use. Each element corresponds\n * to a @group attribute in the {@link GPUShaderModule}, with the `N`th element corresponding\n * with `@group(N)`.\n */\n bindGroupLayouts: Iterable<\n | GPUBindGroupLayout\n | null\n | undefined\n >;\n /**\n * The size, in bytes, of the immediate data range used by the pipeline.\n */\n immediateSize?: GPUSize32;\n }\n\n interface GPUPrimitiveState {\n /**\n * The type of primitive to be constructed from the vertex inputs.\n */\n topology?: GPUPrimitiveTopology;\n /**\n * For pipelines with strip topologies\n * ({@link GPUPrimitiveTopology} `\"line-strip\"` or {@link GPUPrimitiveTopology} `\"triangle-strip\"`),\n * this determines the index buffer format and primitive restart value\n * ({@link GPUIndexFormat} `\"uint16\"`/`0xFFFF` or {@link GPUIndexFormat} `\"uint32\"`/`0xFFFFFFFF`).\n * It is not allowed on pipelines with non-strip topologies.\n * Note: Some implementations require knowledge of the primitive restart value to compile\n * pipeline state objects.\n * To use a strip-topology pipeline with an indexed draw call\n * ({@link GPURenderCommandsMixin#drawIndexed()} or {@link GPURenderCommandsMixin#drawIndexedIndirect}),\n * this must be set, and it must match the index buffer format used with the draw call\n * (set in {@link GPURenderCommandsMixin#setIndexBuffer}).\n * See {@link https://www.w3.org/TR/webgpu/#primitive-assembly} for additional details.\n */\n stripIndexFormat?: GPUIndexFormat;\n /**\n * Defines which polygons are considered front-facing.\n */\n frontFace?: GPUFrontFace;\n /**\n * Defines which polygon orientation will be culled, if any.\n */\n cullMode?: GPUCullMode;\n /**\n * If true, indicates that depth clipping is disabled.\n * Requires the {@link GPUFeatureName} `\"depth-clip-control\"` feature to be enabled.\n */\n unclippedDepth?: boolean;\n }\n\n interface GPUProgrammableStage {\n /**\n * The {@link GPUShaderModule} containing the code that this programmable stage will execute.\n */\n module: GPUShaderModule;\n /**\n * The name of the function in {@link GPUProgrammableStage#module} that this stage will use to\n * perform its work.\n * NOTE: Since the {@link GPUProgrammableStage#entryPoint} dictionary member is\n * not required, methods which consume a {@link GPUProgrammableStage} must use the\n * \"[$get the entry point$]\" algorithm to determine which entry point\n * it refers to.\n */\n entryPoint?: string;\n /**\n * Specifies the values of pipeline-overridable constants in the shader module\n * {@link GPUProgrammableStage#module}.\n * Each such pipeline-overridable constant is uniquely identified by a single\n * pipeline-overridable constant identifier string, representing the pipeline\n * constant ID of the constant if its declaration specifies one, and otherwise the\n * constant's identifier name.\n * The key of each key-value pair must equal the\n * pipeline-overridable constant identifier string|identifier string\n * of one such constant, with the comparison performed\n * according to the rules for WGSL identifier comparison.\n * When the pipeline is executed, that constant will have the specified value.\n * Values are specified as <dfn typedef for=\"\">GPUPipelineConstantValue</dfn>, which is a `double`.\n * They are converted [$to WGSL type$] of the pipeline-overridable constant (`bool`/`i32`/`u32`/`f32`/`f16`).\n * If conversion fails, a validation error is generated.\n * <div class=example>\n * Pipeline-overridable constants defined in WGSL:\n * ```wgsl\n * @id(0) override has_point_light: bool = true; // Algorithmic control.\n * @id(1200) override specular_param: f32 = 2.3; // Numeric control.\n * @id(1300) override gain: f32; // Must be overridden.\n * override width: f32 = 0.0; // Specifed at the API level\n * // using the name \"width\".\n * override depth: f32; // Specifed at the API level\n * // using the name \"depth\".\n * // Must be overridden.\n * override height = 2 * depth; // The default value\n * // (if not set at the API level),\n * // depends on another\n * // overridable constant.\n * ```\n * Corresponding JavaScript code, providing only the overrides which are required\n * (have no defaults):\n * ```js\n * {\n * // ...\n * constants: {\n * 1300: 2.0, // \"gain\"\n * depth: -1, // \"depth\"\n * }\n * }\n * ```\n * Corresponding JavaScript code, overriding all constants:\n * ```js\n * {\n * // ...\n * constants: {\n * 0: false, // \"has_point_light\"\n * 1200: 3.0, // \"specular_param\"\n * 1300: 2.0, // \"gain\"\n * width: 20, // \"width\"\n * depth: -1, // \"depth\"\n * height: 15, // \"height\"\n * }\n * }\n * ```\n * </div>\n */\n constants?: Record<\n string,\n GPUPipelineConstantValue\n >;\n }\n\n interface GPUQuerySetDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * The type of queries managed by {@link GPUQuerySet}.\n */\n type: GPUQueryType;\n /**\n * The number of queries managed by {@link GPUQuerySet}.\n */\n count: GPUSize32;\n }\n\n type GPUQueueDescriptor =\n GPUObjectDescriptorBase;\n type GPURenderBundleDescriptor =\n GPUObjectDescriptorBase;\n\n interface GPURenderBundleEncoderDescriptor\n extends GPURenderPassLayout {\n /**\n * If `true`, indicates that the render bundle does not modify the depth component of the\n * {@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed\n * in.\n * See read-only depth-stencil.\n */\n depthReadOnly?: boolean;\n /**\n * If `true`, indicates that the render bundle does not modify the stencil component of the\n * {@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed\n * in.\n * See read-only depth-stencil.\n */\n stencilReadOnly?: boolean;\n }\n\n interface GPURenderPassColorAttachment {\n /**\n * Describes the texture subresource that will be output to for this color attachment.\n * The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#view}).\n */\n view:\n | GPUTexture\n | GPUTextureView;\n /**\n * Indicates the depth slice index of {@link GPUTextureViewDimension} `\"3d\"` {@link GPURenderPassColorAttachment#view}\n * that will be output to for this color attachment.\n */\n depthSlice?: GPUIntegerCoordinate;\n /**\n * Describes the texture subresource that will receive the resolved output for this color\n * attachment if {@link GPURenderPassColorAttachment#view} is multisampled.\n * The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#resolveTarget}).\n */\n resolveTarget?:\n | GPUTexture\n | GPUTextureView;\n /**\n * Indicates the value to clear {@link GPURenderPassColorAttachment#view} to prior to executing the\n * render pass. If not map/exist|provided, defaults to `{r: 0, g: 0, b: 0, a: 0}`. Ignored\n * if {@link GPURenderPassColorAttachment#loadOp} is not {@link GPULoadOp} `\"clear\"`.\n * The components of {@link GPURenderPassColorAttachment#clearValue} are all double values.\n * They are converted [$to a texel value of texture format$] matching the render attachment.\n * If conversion fails, a validation error is generated.\n */\n clearValue?: GPUColor;\n /**\n * Indicates the load operation to perform on {@link GPURenderPassColorAttachment#view} prior to\n * executing the render pass.\n * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `\"clear\"` for details.\n */\n loadOp: GPULoadOp;\n /**\n * The store operation to perform on {@link GPURenderPassColorAttachment#view}\n * after executing the render pass.\n */\n storeOp: GPUStoreOp;\n }\n\n interface GPURenderPassDepthStencilAttachment {\n /**\n * Describes the texture subresource that will be output to and read from for this\n * depth/stencil attachment.\n * The subresource is determined by calling [$get as texture view$]({@link GPURenderPassDepthStencilAttachment#view}).\n */\n view:\n | GPUTexture\n | GPUTextureView;\n /**\n * Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s depth component\n * to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#depthLoadOp}\n * is not {@link GPULoadOp} `\"clear\"`. Must be between 0.0 and 1.0, inclusive.\n * <!-- POSTV1(unrestricted-depth): unless unrestricted depth is enabled -->\n */\n depthClearValue?: number;\n /**\n * Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s\n * depth component prior to executing the render pass.\n * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `\"clear\"` for details.\n */\n depthLoadOp?: GPULoadOp;\n /**\n * The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s\n * depth component after executing the render pass.\n */\n depthStoreOp?: GPUStoreOp;\n /**\n * Indicates that the depth component of {@link GPURenderPassDepthStencilAttachment#view}\n * is read only.\n */\n depthReadOnly?: boolean;\n /**\n * Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s stencil component\n * to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#stencilLoadOp}\n * is not {@link GPULoadOp} `\"clear\"`.\n * The value will be converted to the type of the stencil aspect of `view` by taking the same\n * number of LSBs as the number of bits in the stencil aspect of one texel block|texel of `view`.\n */\n stencilClearValue?: GPUStencilValue;\n /**\n * Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s\n * stencil component prior to executing the render pass.\n * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `\"clear\"` for details.\n */\n stencilLoadOp?: GPULoadOp;\n /**\n * The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s\n * stencil component after executing the render pass.\n */\n stencilStoreOp?: GPUStoreOp;\n /**\n * Indicates that the stencil component of {@link GPURenderPassDepthStencilAttachment#view}\n * is read only.\n */\n stencilReadOnly?: boolean;\n }\n\n interface GPURenderPassDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * The set of {@link GPURenderPassColorAttachment} values in this sequence defines which\n * color attachments will be output to when executing this render pass.\n * Due to compatible usage list|usage compatibility, no color attachment\n * may alias another attachment or any resource used inside the render pass.\n */\n colorAttachments: Iterable<\n | GPURenderPassColorAttachment\n | null\n | undefined\n >;\n /**\n * The {@link GPURenderPassDepthStencilAttachment} value that defines the depth/stencil\n * attachment that will be output to and tested against when executing this render pass.\n * Due to compatible usage list|usage compatibility, no writable depth/stencil attachment\n * may alias another attachment or any resource used inside the render pass.\n */\n depthStencilAttachment?: GPURenderPassDepthStencilAttachment;\n /**\n * The {@link GPUQuerySet} value defines where the occlusion query results will be stored for this pass.\n */\n occlusionQuerySet?: GPUQuerySet;\n /**\n * Defines which timestamp values will be written for this pass, and where to write them to.\n */\n timestampWrites?: GPURenderPassTimestampWrites;\n /**\n * The maximum number of draw calls that will be done in the render pass. Used by some\n * implementations to size work injected before the render pass. Keeping the default value\n * is a good default, unless it is known that more draw calls will be done.\n */\n maxDrawCount?: GPUSize64;\n }\n\n interface GPURenderPassLayout\n extends GPUObjectDescriptorBase {\n /**\n * A list of the {@link GPUTextureFormat}s of the color attachments for this pass or bundle.\n */\n colorFormats: Iterable<\n | GPUTextureFormat\n | null\n | undefined\n >;\n /**\n * The {@link GPUTextureFormat} of the depth/stencil attachment for this pass or bundle.\n */\n depthStencilFormat?: GPUTextureFormat;\n /**\n * Number of samples per pixel in the attachments for this pass or bundle.\n */\n sampleCount?: GPUSize32;\n }\n\n interface GPURenderPassTimestampWrites {\n /**\n * The {@link GPUQuerySet}, of type {@link GPUQueryType} `\"timestamp\"`, that the query results will be\n * written to.\n */\n querySet: GPUQuerySet;\n /**\n * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into\n * which the timestamp at the beginning of the render pass will be written.\n */\n beginningOfPassWriteIndex?: GPUSize32;\n /**\n * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into\n * which the timestamp at the end of the render pass will be written.\n */\n endOfPassWriteIndex?: GPUSize32;\n }\n\n interface GPURenderPipelineDescriptor\n extends GPUPipelineDescriptorBase {\n /**\n * Describes the vertex shader entry point of the pipeline and its input buffer layouts.\n */\n vertex: GPUVertexState;\n /**\n * Describes the primitive-related properties of the pipeline.\n */\n primitive?: GPUPrimitiveState;\n /**\n * Describes the optional depth-stencil properties, including the testing, operations, and bias.\n */\n depthStencil?: GPUDepthStencilState;\n /**\n * Describes the multi-sampling properties of the pipeline.\n */\n multisample?: GPUMultisampleState;\n /**\n * Describes the fragment shader entry point of the pipeline and its output colors. If\n * not map/exist|provided, the {@link https://www.w3.org/TR/webgpu/#no-color-output} mode is enabled.\n */\n fragment?: GPUFragmentState;\n }\n\n interface GPURequestAdapterOptions {\n /**\n * Requests an adapter that supports at least a particular set of capabilities.\n * This influences the {@link adapter#[[default feature level]]} of devices created\n * from this adapter. The capabilities for each level are defined below, and the exact\n * steps are defined in {@link GPU#requestAdapter} and \"a new device\".\n * If the implementation or system does not support all of the capabilities in the\n * requested feature level, {@link GPU#requestAdapter} will return `null`.\n * Note:\n * Applications should typically make a single {@link GPU#requestAdapter} call with the lowest\n * feature level they support, then inspect the adapter for additional capabilities they can\n * use optionally, and request those in {@link GPUAdapter#requestDevice}.\n * The allowed <dfn dfn for=\"\">feature level string</dfn> values are:\n * <dl dfn-type=dfn dfn-for=\"feature level string\">\n * : <dfn noexport>\"core\"</dfn>\n * The following set of capabilities:\n * - The limit/Default limits.\n * - {@link GPUFeatureName} `\"core-features-and-limits\"`.\n * Note:\n * Adapters with this {@link adapter#[[default feature level]]} may\n * conventionally be referred to as \"Core-defaulting\".\n * : <dfn noexport>\"compatibility\"</dfn>\n * The following set of capabilities:\n * - The limit/Compatibility Mode Default limits.\n * - No features. (It excludes the {@link GPUFeatureName} `\"core-features-and-limits\"` feature.)\n * If the implementation cannot enforce the stricter \"Compatibility Mode\"\n * validation rules, {@link GPU#requestAdapter} will ignore this request and\n * treat it as a request for feature level string/\"core\".\n * Note:\n * Adapters with this {@link adapter#[[default feature level]]} may\n * conventionally be referred to as \"Compatibility-defaulting\".\n */\n featureLevel?: string;\n /**\n * Optionally provides a hint indicating what class of adapter should be selected from\n * the system's available adapters.\n * The value of this hint may influence which adapter is chosen, but it must not\n * influence whether an adapter is returned or not.\n * Note:\n * The primary utility of this hint is to influence which GPU is used in a multi-GPU system.\n * For instance, some laptops have a low-power integrated GPU and a high-performance\n * discrete GPU. This hint may also affect the power configuration of the selected GPU to\n * match the requested power preference.\n * Note:\n * Depending on the exact hardware configuration, such as battery status and attached displays\n * or removable GPUs, the user agent may select different adapters given the same power\n * preference.\n * Typically, given the same hardware configuration and state and\n * `powerPreference`, the user agent is likely to select the same adapter.\n */\n powerPreference?: GPUPowerPreference;\n /**\n * When set to `true` indicates that only a fallback adapter may be returned. If the user\n * agent does not support a fallback adapter, will cause {@link GPU#requestAdapter} to\n * resolve to `null`.\n * Note:\n * {@link GPU#requestAdapter} may still return a fallback adapter if\n * {@link GPURequestAdapterOptions#forceFallbackAdapter} is set to `false` and either no\n * other appropriate adapter is available or the user agent chooses to return a\n * fallback adapter. Developers that wish to prevent their applications from running on\n * fallback adapters should check the {@link GPUAdapter#info}.{@link GPUAdapterInfo#isFallbackAdapter}\n * attribute prior to requesting a {@link GPUDevice}.\n */\n forceFallbackAdapter?: boolean;\n xrCompatible?: boolean;\n }\n\n interface GPUSamplerBindingLayout {\n /**\n * Indicates the required type of a sampler bound to this bindings.\n */\n type?: GPUSamplerBindingType;\n }\n\n interface GPUSamplerDescriptor\n extends GPUObjectDescriptorBase {\n /**\n */\n addressModeU?: GPUAddressMode;\n /**\n */\n addressModeV?: GPUAddressMode;\n /**\n * Specifies the {@link GPUAddressMode | address modes} for the texture width, height, and depth\n * coordinates, respectively.\n */\n addressModeW?: GPUAddressMode;\n /**\n * Specifies the sampling behavior when the sampled area is smaller than or equal to one\n * texel.\n */\n magFilter?: GPUFilterMode;\n /**\n * Specifies the sampling behavior when the sampled area is larger than one texel.\n */\n minFilter?: GPUFilterMode;\n /**\n * Specifies behavior for sampling between mipmap levels.\n */\n mipmapFilter?: GPUMipmapFilterMode;\n /**\n */\n lodMinClamp?: number;\n /**\n * Specifies the minimum and maximum levels of detail, respectively, used internally when\n * sampling a texture.\n */\n lodMaxClamp?: number;\n /**\n * When provided the sampler will be a comparison sampler with the specified\n * {@link GPUCompareFunction}.\n * Note: Comparison samplers may use filtering, but the sampling results will be\n * implementation-dependent and may differ from the normal filtering rules.\n */\n compare?: GPUCompareFunction;\n /**\n * Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is\n * enabled when {@link GPUSamplerDescriptor#maxAnisotropy} is > 1 and the implementation supports it.\n * Anisotropic filtering improves the image quality of textures sampled at oblique viewing\n * angles. Higher {@link GPUSamplerDescriptor#maxAnisotropy} values indicate the maximum ratio of\n * anisotropy supported when filtering.\n * <div class=note heading>\n * Most implementations support {@link GPUSamplerDescriptor#maxAnisotropy} values in range\n * between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor#maxAnisotropy}\n * will be clamped to the maximum value that the platform supports.\n * The precise filtering behavior is implementation-dependent.\n * </div>\n */\n maxAnisotropy?: number;\n }\n\n interface GPUShaderModuleCompilationHint {\n entryPoint: string;\n /**\n * A {@link GPUPipelineLayout} that the {@link GPUShaderModule} may be used with in a future\n * {@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline} call.\n * If set to {@link GPUAutoLayoutMode} `\"auto\"` the layout will be the [$default pipeline layout$]\n * for the entry point associated with this hint will be used.\n */\n layout?:\n | GPUPipelineLayout\n | GPUAutoLayoutMode;\n }\n\n interface GPUShaderModuleDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * The <a href=\"https://gpuweb.github.io/gpuweb/wgsl/\">WGSL</a> source code for the shader\n * module.\n */\n code: string;\n /**\n * A list of {@link GPUShaderModuleCompilationHint}s.\n * Any hint provided by an application **should** contain information about one entry point of\n * a pipeline that will eventually be created from the entry point.\n * Implementations **should** use any information present in the {@link GPUShaderModuleCompilationHint}\n * to perform as much compilation as is possible within {@link GPUDevice#createShaderModule}.\n * Aside from type-checking, these hints are not validated in any way.\n * <div class=note heading>\n * Supplying information in {@link GPUShaderModuleDescriptor#compilationHints} does not have any\n * observable effect, other than performance. It may be detrimental to performance to\n * provide hints for pipelines that never end up being created.\n * Because a single shader module can hold multiple entry points, and multiple pipelines\n * can be created from a single shader module, it can be more performant for an\n * implementation to do as much compilation as possible once in\n * {@link GPUDevice#createShaderModule} rather than multiple times in the multiple calls to\n * {@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline}.\n * Hints are only applied to the entry points they explicitly name.\n * Unlike {@link GPUProgrammableStage#entryPoint | GPUProgrammableStage.entryPoint},\n * there is no default, even if only one entry point is present in the module.\n * </div>\n * Note:\n * Hints are not validated in an observable way, but user agents **may** surface identifiable\n * errors (like unknown entry point names or incompatible pipeline layouts) to developers,\n * for example in the browser developer console.\n */\n compilationHints?: Iterable<GPUShaderModuleCompilationHint>;\n }\n\n interface GPUStencilFaceState {\n /**\n * The {@link GPUCompareFunction} used when testing the RenderState.`[[stencilReference]]` value\n * against the fragment's {@link GPURenderPassDescriptor#depthStencilAttachment} stencil values.\n */\n compare?: GPUCompareFunction;\n /**\n * The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by\n * {@link GPUStencilFaceState#compare} fails.\n */\n failOp?: GPUStencilOperation;\n /**\n * The {@link GPUStencilOperation} performed if the fragment depth comparison described by\n * {@link GPUDepthStencilState#depthCompare} fails.\n */\n depthFailOp?: GPUStencilOperation;\n /**\n * The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by\n * {@link GPUStencilFaceState#compare} passes.\n */\n passOp?: GPUStencilOperation;\n }\n\n interface GPUStorageTextureBindingLayout {\n /**\n * The access mode for this binding, indicating readability and writability.\n */\n access?: GPUStorageTextureAccess;\n /**\n * The required {@link GPUTextureViewDescriptor#format} of texture views bound to this binding.\n */\n format: GPUTextureFormat;\n /**\n * Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to\n * this binding.\n */\n viewDimension?: GPUTextureViewDimension;\n }\n\n interface GPUTexelCopyBufferInfo\n extends GPUTexelCopyBufferLayout {\n /**\n * A buffer which either contains texel data to be copied or will store the texel data being\n * copied, depending on the method it is being passed to.\n */\n buffer: GPUBuffer;\n }\n\n interface GPUTexelCopyBufferLayout {\n /**\n * The offset, in bytes, from the beginning of the texel data source (such as a\n * {@link GPUTexelCopyBufferInfo#buffer | GPUTexelCopyBufferInfo.buffer}) to the start of the texel data\n * within that source.\n */\n offset?: GPUSize64;\n /**\n * The stride, in bytes, between the beginning of each texel block row and the subsequent\n * texel block row.\n * Required if there are multiple texel block rows (i.e. the copy height or depth is more\n * than one block).\n */\n bytesPerRow?: GPUSize32;\n /**\n * Number of texel block rows per single texel image of the texture.\n * {@link GPUTexelCopyBufferLayout#rowsPerImage} ×\n * {@link GPUTexelCopyBufferLayout#bytesPerRow} is the stride, in bytes, between the beginning of each\n * texel image of data and the subsequent texel image.\n * Required if there are multiple texel images (i.e. the copy depth is more than one).\n */\n rowsPerImage?: GPUSize32;\n }\n\n interface GPUTexelCopyTextureInfo {\n /**\n * Texture to copy to/from.\n */\n texture: GPUTexture;\n /**\n * Mip-map level of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from.\n */\n mipLevel?: GPUIntegerCoordinate;\n /**\n * Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from.\n * Together with `copySize`, defines the full copy sub-region.\n */\n origin?: GPUOrigin3D;\n /**\n * Defines which aspects of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from.\n */\n aspect?: GPUTextureAspect;\n }\n\n interface GPUTextureBindingLayout {\n /**\n * Indicates the type required for texture views bound to this binding.\n */\n sampleType?: GPUTextureSampleType;\n /**\n * Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to\n * this binding.\n */\n viewDimension?: GPUTextureViewDimension;\n /**\n * Indicates whether or not texture views bound to this binding must be multisampled.\n */\n multisampled?: boolean;\n }\n\n interface GPUTextureDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * The width, height, and depth or layer count of the texture.\n */\n size: GPUExtent3DStrict;\n /**\n * The number of mip levels the texture will contain.\n */\n mipLevelCount?: GPUIntegerCoordinate;\n /**\n * The sample count of the texture. A {@link GPUTextureDescriptor#sampleCount} > `1` indicates\n * a multisampled texture.\n */\n sampleCount?: GPUSize32;\n /**\n * Whether the texture is one-dimensional, an array of two-dimensional layers, or three-dimensional.\n */\n dimension?: GPUTextureDimension;\n /**\n * The format of the texture.\n */\n format: GPUTextureFormat;\n /**\n * The allowed usages for the texture.\n */\n usage: GPUTextureUsageFlags;\n /**\n * Specifies what view {@link GPUTextureViewDescriptor#format} values will be allowed when calling\n * {@link GPUTexture#createView} on this texture (in addition to the texture's actual\n * {@link GPUTextureDescriptor#format}).\n * <div class=note heading>\n * Adding a format to this list may have a significant performance impact, so it is best\n * to avoid adding formats unnecessarily.\n * The actual performance impact is highly dependent on the target system; developers must\n * test various systems to find out the impact on their particular application.\n * For example, on some systems any texture with a {@link GPUTextureDescriptor#format} or\n * {@link GPUTextureDescriptor#viewFormats} entry including\n * {@link GPUTextureFormat} `\"rgba8unorm-srgb\"` will perform less optimally than a\n * {@link GPUTextureFormat} `\"rgba8unorm\"` texture which does not.\n * Similar caveats exist for other formats and pairs of formats on other systems.\n * </div>\n * Formats in this list must be texture view format compatible with the texture format.\n * <div algorithm data-timeline=const>\n * Two {@link GPUTextureFormat}s `format` and `viewFormat` are <dfn dfn for=\"\">texture view format compatible</dfn> on a given `device` if:\n * - `format` equals `viewFormat`, or\n * - `format` and `viewFormat` differ only in whether they are `srgb` formats (have the `-srgb` suffix) and `device.features` list/contains {@link GPUFeatureName} `\"core-features-and-limits\"`.\n * </div>\n */\n viewFormats?: Iterable<GPUTextureFormat>;\n /**\n * <div class=compatmode>\n * On devices without {@link GPUFeatureName} `\"core-features-and-limits\"`,\n * views created from this texture must have this as their {@link GPUTextureViewDescriptor#dimension}.\n * If not specified, a default is chosen.\n * </div>\n * On devices with {@link GPUFeatureName} `\"core-features-and-limits\"`,\n * this is ignored, and there is no such restriction.\n */\n textureBindingViewDimension?: GPUTextureViewDimension;\n }\n\n interface GPUTextureViewDescriptor\n extends GPUObjectDescriptorBase {\n /**\n * The format of the texture view. Must be either the {@link GPUTextureDescriptor#format} of the\n * texture or one of the {@link GPUTextureDescriptor#viewFormats} specified during its creation.\n */\n format?: GPUTextureFormat;\n /**\n * The dimension to view the texture as.\n */\n dimension?: GPUTextureViewDimension;\n /**\n * The allowed {@link GPUTextureUsage | usage(s)} for the texture view. Must be a subset of the\n * {@link GPUTexture#usage} flags of the texture. If 0, defaults to the full set of\n * {@link GPUTexture#usage} flags of the texture.\n * Note: If the view's {@link GPUTextureViewDescriptor#format} doesn't support all of the\n * texture's {@link GPUTextureDescriptor#usage}s, the default will fail,\n * and the view's {@link GPUTextureViewDescriptor#usage} must be specified explicitly.\n */\n usage?: GPUTextureUsageFlags;\n /**\n * Which {@link GPUTextureAspect | aspect(s)} of the texture are accessible to the texture view.\n */\n aspect?: GPUTextureAspect;\n /**\n * The first (most detailed) mipmap level accessible to the texture view.\n */\n baseMipLevel?: GPUIntegerCoordinate;\n /**\n * How many mipmap levels, starting with {@link GPUTextureViewDescriptor#baseMipLevel}, are accessible to\n * the texture view.\n */\n mipLevelCount?: GPUIntegerCoordinate;\n /**\n * The index of the first array layer accessible to the texture view.\n */\n baseArrayLayer?: GPUIntegerCoordinate;\n /**\n * How many array layers, starting with {@link GPUTextureViewDescriptor#baseArrayLayer}, are accessible\n * to the texture view.\n */\n arrayLayerCount?: GPUIntegerCoordinate;\n /**\n * A string of length four, with each character mapping to the texture view's red/green/blue/alpha\n * channels, respectively.\n * When accessed by a shader, the red/green/blue/alpha channels are replaced by the value\n * corresponding to the component specified in `swizzle[0]`, `swizzle[1]`, `swizzle[2]`, and\n * `swizzle[3]`, respectively:\n * - `\"r\"`: Take its value from the red channel of the texture.\n * - `\"g\"`: Take its value from the green channel of the texture.\n * - `\"b\"`: Take its value from the blue channel of the texture.\n * - `\"a\"`: Take its value from the alpha channel of the texture.\n * - `\"0\"`: Force its value to 0.\n * - `\"1\"`: Force its value to 1.\n * Requires the {@link GPUFeatureName} `\"texture-component-swizzle\"` feature to be enabled.\n */\n swizzle?: string;\n }\n\n interface GPUUncapturedErrorEventInit\n extends EventInit {\n error: GPUError;\n }\n\n interface GPUVertexAttribute {\n /**\n * The {@link GPUVertexFormat} of the attribute.\n */\n format: GPUVertexFormat;\n /**\n * The offset, in bytes, from the beginning of the element to the data for the attribute.\n */\n offset: GPUSize64;\n /**\n * The numeric location associated with this attribute, which will correspond with a\n * <a href=\"https://gpuweb.github.io/gpuweb/wgsl/#input-output-locations\">\"@location\" attribute</a>\n * declared in the {@link GPURenderPipelineDescriptor#vertex}.{@link GPUProgrammableStage#module | module}.\n */\n shaderLocation: GPUIndex32;\n }\n\n interface GPUVertexBufferLayout {\n /**\n * The stride, in bytes, between elements of this array.\n */\n arrayStride: GPUSize64;\n /**\n * Whether each element of this array represents per-vertex data or per-instance data\n */\n stepMode?: GPUVertexStepMode;\n /**\n * An array defining the layout of the vertex attributes within each element.\n */\n attributes: Iterable<GPUVertexAttribute>;\n }\n\n interface GPUVertexState\n extends GPUProgrammableStage {\n /**\n * A list of {@link GPUVertexBufferLayout}s, each defining the layout of vertex attribute data in a\n * vertex buffer used by this pipeline.\n */\n buffers?: Iterable<\n | GPUVertexBufferLayout\n | null\n | undefined\n >;\n }\n\n interface GPUBindingCommandsMixin {\n /**\n * Sets the current {@link GPUBindGroup} for the given index.\n * @param index - The index to set the bind group at.\n * @param bindGroup - Bind group to use for subsequent render or compute commands.\n * @param dynamicOffsets - Array containing buffer offsets in bytes for each entry in\n * \t`bindGroup` marked as {@link GPUBindGroupLayoutEntry#buffer}.{@link GPUBufferBindingLayout#hasDynamicOffset}.-->\n */\n setBindGroup(\n index: GPUIndex32,\n bindGroup:\n | GPUBindGroup\n | null\n | undefined,\n dynamicOffsets?: Iterable<GPUBufferDynamicOffset>\n ): undefined;\n /**\n * Sets the current {@link GPUBindGroup} for the given index, specifying dynamic offsets as a subset\n * of a Uint32Array.\n * @param index - The index to set the bind group at.\n * @param bindGroup - Bind group to use for subsequent render or compute commands.\n * @param dynamicOffsetsData - Array containing buffer offsets in bytes for each entry in\n * \t`bindGroup` marked as {@link GPUBindGroupLayoutEntry#buffer}.{@link GPUBufferBindingLayout#hasDynamicOffset}.\n * @param dynamicOffsetsDataStart - Offset in elements into `dynamicOffsetsData` where the\n * \tbuffer offset data begins.\n * @param dynamicOffsetsDataLength - Number of buffer offsets to read from `dynamicOffsetsData`.\n */\n setBindGroup(\n index: GPUIndex32,\n bindGroup:\n | GPUBindGroup\n | null\n | undefined,\n dynamicOffsetsData: Uint32Array,\n dynamicOffsetsDataStart: GPUSize64,\n dynamicOffsetsDataLength: GPUSize32\n ): undefined;\n /**\n * Sets immediate data for subsequent render or compute commands.\n * @param rangeOffset - Offset in bytes into the immediate data range to begin writing at.\n * @param data - Data to write into the immediate data range.\n * @param dataOffset - Offset into `data` to begin writing from. Given in elements if\n * \t`data` is a {@link TypedArray} and bytes otherwise.\n * @param dataSize - Size of content to write from `data`. Given in elements if\n * \t`data` is a {@link TypedArray} and bytes otherwise.\n */\n setImmediates(\n rangeOffset: GPUSize32,\n data: GPUAllowSharedBufferSource,\n dataOffset?: GPUSize64,\n dataSize?: GPUSize64\n ): undefined;\n }\n\n interface GPUCommandsMixin {}\n\n interface GPUDebugCommandsMixin {\n /**\n * Begins a labeled debug group containing subsequent commands.\n * @param groupLabel - The label for the command group.\n */\n pushDebugGroup(\n groupLabel: string\n ): undefined;\n /**\n * Ends the labeled debug group most recently started by {@link GPUDebugCommandsMixin#pushDebugGroup}.\n */\n popDebugGroup(): undefined;\n /**\n * Marks a point in a stream of commands with a label.\n * @param markerLabel - The label to insert.\n */\n insertDebugMarker(\n markerLabel: string\n ): undefined;\n }\n\n interface GPUObjectBase {\n label: string;\n }\n\n interface GPUPipelineBase {\n /**\n * Gets a {@link GPUBindGroupLayout} that is compatible with the {@link GPUPipelineBase}'s\n * {@link GPUBindGroupLayout} at `index`.\n * @param index - Index into the pipeline layout's {@link GPUPipelineLayout}.`[[bindGroupLayouts]]`\n * \tsequence.\n */\n getBindGroupLayout(\n index: number\n ): GPUBindGroupLayout;\n }\n\n interface GPURenderCommandsMixin {\n /**\n * Sets the current {@link GPURenderPipeline}.\n * @param pipeline - The render pipeline to use for subsequent drawing commands.\n */\n setPipeline(\n pipeline: GPURenderPipeline\n ): undefined;\n /**\n * Sets the current index buffer.\n * @param buffer - Buffer containing index data to use for subsequent drawing commands.\n * @param indexFormat - Format of the index data contained in `buffer`.\n * @param offset - Offset in bytes into `buffer` where the index data begins. Defaults to `0`.\n * @param size - Size in bytes of the index data in `buffer`.\n * \tDefaults to the size of the buffer minus the offset.\n */\n setIndexBuffer(\n buffer: GPUBuffer,\n indexFormat: GPUIndexFormat,\n offset?: GPUSize64,\n size?: GPUSize64\n ): undefined;\n /**\n * Sets the current vertex buffer for the given slot.\n * @param slot - The vertex buffer slot to set the vertex buffer for.\n * @param buffer - Buffer containing vertex data to use for subsequent drawing commands.\n * @param offset - Offset in bytes into `buffer` where the vertex data begins. Defaults to `0`.\n * @param size - Size in bytes of the vertex data in `buffer`.\n * \tDefaults to the size of the buffer minus the offset.\n */\n setVertexBuffer(\n slot: GPUIndex32,\n buffer:\n | GPUBuffer\n | null\n | undefined,\n offset?: GPUSize64,\n size?: GPUSize64\n ): undefined;\n /**\n * Draws primitives.\n * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification.\n * @param vertexCount - The number of vertices to draw.\n * @param instanceCount - The number of instances to draw.\n * @param firstVertex - Offset into the vertex buffers, in vertices, to begin drawing from.\n * @param firstInstance - First instance to draw.\n */\n draw(\n vertexCount: GPUSize32,\n instanceCount?: GPUSize32,\n firstVertex?: GPUSize32,\n firstInstance?: GPUSize32\n ): undefined;\n /**\n * Draws indexed primitives.\n * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification.\n * @param indexCount - The number of indices to draw.\n * @param instanceCount - The number of instances to draw.\n * @param firstIndex - Offset into the index buffer, in indices, begin drawing from.\n * @param baseVertex - Added to each index value before indexing into the vertex buffers.\n * @param firstInstance - First instance to draw.\n */\n drawIndexed(\n indexCount: GPUSize32,\n instanceCount?: GPUSize32,\n firstIndex?: GPUSize32,\n baseVertex?: GPUSignedOffset32,\n firstInstance?: GPUSize32\n ): undefined;\n /**\n * Draws primitives using parameters read from a {@link GPUBuffer}.\n * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification.\n * packed block of **four 32-bit unsigned integer values (16 bytes total)**, given in the same\n * order as the arguments for {@link GPURenderCommandsMixin#draw}. For example:\n * @param indirectBuffer - Buffer containing the indirect draw parameters.\n * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.\n */\n drawIndirect(\n indirectBuffer: GPUBuffer,\n indirectOffset: GPUSize64\n ): undefined;\n /**\n * Draws indexed primitives using parameters read from a {@link GPUBuffer}.\n * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification.\n * tightly packed block of **five 32-bit unsigned integer values (20 bytes total)**, given in\n * the same order as the arguments for {@link GPURenderCommandsMixin#drawIndexed}. For example:\n * @param indirectBuffer - Buffer containing the indirect drawIndexed parameters.\n * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.\n */\n drawIndexedIndirect(\n indirectBuffer: GPUBuffer,\n indirectOffset: GPUSize64\n ): undefined;\n }\n\n interface NavigatorGPU {\n /**\n * A global singleton providing top-level entry points like {@link GPU#requestAdapter}.\n */\n readonly gpu: GPU;\n }\n\n interface GPU {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPU\";\n /**\n * Requests an adapter from the user agent.\n * The user agent chooses whether to return an adapter, and, if so,\n * chooses according to the provided options.\n * @param options - Criteria used to select the adapter.\n */\n requestAdapter(\n options?: GPURequestAdapterOptions\n ): Promise<GPUAdapter | null>;\n /**\n * Returns an optimal {@link GPUTextureFormat} for displaying 8-bit depth, standard dynamic range\n * content on this system. Must only return {@link GPUTextureFormat} `\"rgba8unorm\"` or\n * {@link GPUTextureFormat} `\"bgra8unorm\"`.\n * The returned value can be passed as the {@link GPUCanvasConfiguration#format} to\n * {@link GPUCanvasContext#configure} calls on a {@link GPUCanvasContext} to ensure the associated\n * canvas is able to display its contents efficiently.\n * Note: Canvases which are not displayed to the screen may or may not benefit from using this\n * format.\n */\n getPreferredCanvasFormat(): GPUTextureFormat;\n readonly wgslLanguageFeatures: WGSLLanguageFeatures;\n }\n\n var GPU: {\n prototype: GPU;\n new (): never;\n };\n\n interface GPUAdapter {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUAdapter\";\n /**\n * The set of values in `this`.{@link GPUAdapter#[[adapter]]}.{@link adapter#[[features]]}.\n */\n readonly features: GPUSupportedFeatures;\n /**\n * The limits in `this`.{@link GPUAdapter#[[adapter]]}.{@link adapter#[[limits]]}.\n */\n readonly limits: GPUSupportedLimits;\n /**\n * Information about the physical adapter underlying this {@link GPUAdapter}.\n * For a given {@link GPUAdapter}, the {@link GPUAdapterInfo} values exposed are constant over time.\n * The same object is returned each time. To create that object for the first time:\n * <div algorithm=GPUAdapter.info>\n * <div data-timeline=content>\n * **Called on:** {@link GPUAdapter} `this`.\n * **Returns:** {@link GPUAdapterInfo}\n * Content timeline steps:\n * 1. Return a [$new adapter info$] for `this.adapter`.\n * </div>\n * </div>\n */\n readonly info: GPUAdapterInfo;\n /**\n * Requests a device from the adapter.\n * This is a one-time action: if a device is returned successfully,\n * the adapter becomes {@link adapter#[[state]]#\"consumed\"}.\n * @param descriptor - Description of the {@link GPUDevice} to request.\n */\n requestDevice(\n descriptor?: GPUDeviceDescriptor\n ): Promise<GPUDevice>;\n }\n\n var GPUAdapter: {\n prototype: GPUAdapter;\n new (): never;\n };\n\n interface GPUAdapterInfo {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUAdapterInfo\";\n /**\n * The name of the vendor of the adapter, if available. Empty string otherwise.\n */\n readonly vendor: string;\n /**\n * The name of the family or class of GPUs the adapter belongs to, if available. Empty\n * string otherwise.\n */\n readonly architecture: string;\n /**\n * A vendor-specific identifier for the adapter, if available. Empty string otherwise.\n * Note: This is a value that represents the type of adapter. For example, it may be a\n * [PCI device ID](https://pcisig.com/). It does not uniquely identify a given piece of\n * hardware like a serial number.\n */\n readonly device: string;\n /**\n * A human readable string describing the adapter as reported by the driver, if available.\n * Empty string otherwise.\n * Note: Because no formatting is applied to {@link GPUAdapterInfo#description} attempting to parse\n * this value is not recommended. Applications which change their behavior based on the\n * {@link GPUAdapterInfo}, such as applying workarounds for known driver issues, should rely on the\n * other fields when possible.\n */\n readonly description: string;\n /**\n * If the \"subgroups\" feature is supported, the minimum supported subgroup size for the\n * adapter.\n *\n * @todo Temporarily optional until all browsers have implemented it.\n * Check support before using. (Use the non-null assertion operator `!` where needed.)\n */\n readonly subgroupMinSize?: number;\n /**\n * If the \"subgroups\" feature is supported, the maximum supported subgroup size for the\n * adapter.\n *\n * @todo Temporarily optional until all browsers have implemented it.\n * Check support before using. (Use the non-null assertion operator `!` where needed.)\n */\n readonly subgroupMaxSize?: number;\n /**\n * Whether the adapter is a fallback adapter.\n **/\n readonly isFallbackAdapter: boolean;\n }\n\n var GPUAdapterInfo: {\n prototype: GPUAdapterInfo;\n new (): never;\n };\n\n interface GPUBindGroup\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUBindGroup\";\n }\n\n var GPUBindGroup: {\n prototype: GPUBindGroup;\n new (): never;\n };\n\n interface GPUBindGroupLayout\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUBindGroupLayout\";\n }\n\n var GPUBindGroupLayout: {\n prototype: GPUBindGroupLayout;\n new (): never;\n };\n\n interface GPUBuffer\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUBuffer\";\n readonly size: GPUSize64Out;\n readonly usage: GPUFlagsConstant;\n readonly mapState: GPUBufferMapState;\n /**\n * Maps the given range of the {@link GPUBuffer} and resolves the returned Promise when the\n * {@link GPUBuffer}'s content is ready to be accessed with {@link GPUBuffer#getMappedRange}.\n * The resolution of the returned Promise **only** indicates that the buffer has been mapped.\n * It does not guarantee the completion of any other operations visible to the content timeline,\n * and in particular does not imply that any other Promise returned from\n * {@link GPUQueue#onSubmittedWorkDone()} or {@link GPUBuffer#mapAsync} on other {@link GPUBuffer}s\n * have resolved.\n * The resolution of the Promise returned from {@link GPUQueue#onSubmittedWorkDone}\n * **does** imply the completion of\n * {@link GPUBuffer#mapAsync} calls made prior to that call,\n * on {@link GPUBuffer}s last used exclusively on that queue.\n * @param mode - Whether the buffer should be mapped for reading or writing.\n * @param offset - Offset in bytes into the buffer to the start of the range to map.\n * @param size - Size in bytes of the range to map.\n */\n mapAsync(\n mode: GPUMapModeFlags,\n offset?: GPUSize64,\n size?: GPUSize64\n ): Promise<undefined>;\n /**\n * Returns an ArrayBuffer with the contents of the {@link GPUBuffer} in the given mapped range.\n * @param offset - Offset in bytes into the buffer to return buffer contents from.\n * @param size - Size in bytes of the ArrayBuffer to return.\n */\n getMappedRange(\n offset?: GPUSize64,\n size?: GPUSize64\n ): ArrayBuffer;\n /**\n * Unmaps the mapped range of the {@link GPUBuffer} and makes its contents available for use by the\n * GPU again.\n */\n unmap(): undefined;\n /**\n * Destroys the {@link GPUBuffer}.\n * Note: It is valid to destroy a buffer multiple times.\n * Note: Since no further operations can be enqueued using this buffer, implementations can\n * free resource allocations, including mapped memory that was just unmapped.\n */\n destroy(): undefined;\n }\n\n var GPUBuffer: {\n prototype: GPUBuffer;\n new (): never;\n };\n\n interface GPUCanvasContext {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUCanvasContext\";\n /**\n * The canvas this context was created from.\n */\n readonly canvas:\n | HTMLCanvasElement\n | OffscreenCanvas;\n /**\n * Configures the context for this canvas.\n * This clears the drawing buffer to transparent black (in [$Replace the drawing buffer$]).\n * See {@link GPUCanvasContext#getConfiguration} for information on feature detection.\n * @param configuration - Desired configuration for the context.\n */\n configure(\n configuration: GPUCanvasConfiguration\n ): undefined;\n /**\n * Removes the context configuration. Destroys any textures produced while configured.\n */\n unconfigure(): undefined;\n /**\n * Returns the context configuration, or `null` if the context is not configured.\n * Note:\n * This method exists primarily for feature detection of members (and sub-members) of\n * {@link GPUCanvasConfiguration}; see those members for details.\n * For supported members, it returns the originally-supplied values.\n */\n getConfiguration(): GPUCanvasConfigurationOut | null;\n /**\n * Get the {@link GPUTexture} that will be composited to the document by the {@link GPUCanvasContext}\n * next.\n * Note: The same {@link GPUTexture} object will be returned by every\n * call to {@link GPUCanvasContext#getCurrentTexture} until \"[$Expire the current texture$]\"\n * runs, even if that {@link GPUTexture} is destroyed, failed validation, or failed to allocate.\n */\n getCurrentTexture(): GPUTexture;\n }\n\n var GPUCanvasContext: {\n prototype: GPUCanvasContext;\n new (): never;\n };\n\n interface GPUCommandBuffer\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUCommandBuffer\";\n }\n\n var GPUCommandBuffer: {\n prototype: GPUCommandBuffer;\n new (): never;\n };\n\n interface GPUCommandEncoder\n extends GPUObjectBase,\n GPUCommandsMixin,\n GPUDebugCommandsMixin {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUCommandEncoder\";\n /**\n * Begins encoding a render pass described by `descriptor`.\n * @param descriptor - Description of the {@link GPURenderPassEncoder} to create.\n */\n beginRenderPass(\n descriptor: GPURenderPassDescriptor\n ): GPURenderPassEncoder;\n beginComputePass(\n descriptor?: GPUComputePassDescriptor\n ): GPUComputePassEncoder;\n /**\n * Shorthand, equivalent to {@link GPUCommandEncoder#copyBufferToBuffer}.\n */\n copyBufferToBuffer(\n source: GPUBuffer,\n destination: GPUBuffer,\n size?: GPUSize64\n ): undefined;\n /**\n * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a\n * {@link GPUBuffer} to a sub-region of another {@link GPUBuffer}.\n * @param source - The {@link GPUBuffer} to copy from.\n * @param sourceOffset - Offset in bytes into `source` to begin copying from.\n * @param destination - The {@link GPUBuffer} to copy to.\n * @param destinationOffset - Offset in bytes into `destination` to place the copied data.\n * @param size - Bytes to copy. Defaults to the size of the buffer `source` minus `sourceOffset`.\n */\n copyBufferToBuffer(\n source: GPUBuffer,\n sourceOffset: GPUSize64,\n destination: GPUBuffer,\n destinationOffset: GPUSize64,\n size?: GPUSize64\n ): undefined;\n /**\n * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a\n * {@link GPUBuffer} to a sub-region of one or multiple continuous texture subresources.\n * @param source - Combined with `copySize`, defines the region of the source buffer.\n * @param destination - Combined with `copySize`, defines the region of the destination texture subresource.\n * \t`copySize`:\n */\n copyBufferToTexture(\n source: GPUTexelCopyBufferInfo,\n destination: GPUTexelCopyTextureInfo,\n copySize: GPUExtent3DStrict\n ): undefined;\n /**\n * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one or\n * multiple continuous texture subresources to a sub-region of a {@link GPUBuffer}.\n * @param source - Combined with `copySize`, defines the region of the source texture subresources.\n * @param destination - Combined with `copySize`, defines the region of the destination buffer.\n * \t`copySize`:\n */\n copyTextureToBuffer(\n source: GPUTexelCopyTextureInfo,\n destination: GPUTexelCopyBufferInfo,\n copySize: GPUExtent3DStrict\n ): undefined;\n /**\n * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one\n * or multiple contiguous texture subresources to another sub-region of one or\n * multiple continuous texture subresources.\n * @param source - Combined with `copySize`, defines the region of the source texture subresources.\n * @param destination - Combined with `copySize`, defines the region of the destination texture subresources.\n * \t`copySize`:\n */\n copyTextureToTexture(\n source: GPUTexelCopyTextureInfo,\n destination: GPUTexelCopyTextureInfo,\n copySize: GPUExtent3DStrict\n ): undefined;\n /**\n * Encode a command into the {@link GPUCommandEncoder} that fills a sub-region of a\n * {@link GPUBuffer} with zeros.\n * @param buffer - The {@link GPUBuffer} to clear.\n * @param offset - Offset in bytes into `buffer` where the sub-region to clear begins.\n * @param size - Size in bytes of the sub-region to clear. Defaults to the size of the buffer minus `offset`.\n */\n clearBuffer(\n buffer: GPUBuffer,\n offset?: GPUSize64,\n size?: GPUSize64\n ): undefined;\n /**\n * Resolves query results from a {@link GPUQuerySet} out into a range of a {@link GPUBuffer}.\n * \tquerySet:\n * \tfirstQuery:\n * \tqueryCount:\n * \tdestination:\n * \tdestinationOffset:\n */\n resolveQuerySet(\n querySet: GPUQuerySet,\n firstQuery: GPUSize32,\n queryCount: GPUSize32,\n destination: GPUBuffer,\n destinationOffset: GPUSize64\n ): undefined;\n /**\n * Completes recording of the commands sequence and returns a corresponding {@link GPUCommandBuffer}.\n * \tdescriptor:\n */\n finish(\n descriptor?: GPUCommandBufferDescriptor\n ): GPUCommandBuffer;\n }\n\n var GPUCommandEncoder: {\n prototype: GPUCommandEncoder;\n new (): never;\n };\n\n interface GPUCompilationInfo {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUCompilationInfo\";\n readonly messages: ReadonlyArray<GPUCompilationMessage>;\n }\n\n var GPUCompilationInfo: {\n prototype: GPUCompilationInfo;\n new (): never;\n };\n\n interface GPUCompilationMessage {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUCompilationMessage\";\n /**\n * The human-readable, localizable text for this compilation message.\n * Note: The {@link GPUCompilationMessage#message} should follow the best practices for language\n * and direction information. This includes making use of any future standards which may\n * emerge regarding the reporting of string language and direction metadata.\n * <p class=\"note editorial\"><span class=marker>Editorial note:</span>\n * At the time of this writing, no language/direction recommendation is available that provides\n * compatibility and consistency with legacy APIs, but when there is, adopt it formally.\n */\n readonly message: string;\n /**\n * The severity level of the message.\n * If the {@link GPUCompilationMessage#type} is {@link GPUCompilationMessageType} `\"error\"`, it\n * corresponds to a shader-creation error.\n */\n readonly type: GPUCompilationMessageType;\n /**\n * The line number in the shader {@link GPUShaderModuleDescriptor#code} the\n * {@link GPUCompilationMessage#message} corresponds to. Value is one-based, such that a lineNum of\n * `1` indicates the first line of the shader {@link GPUShaderModuleDescriptor#code}. Lines are\n * delimited by line breaks.\n * If the {@link GPUCompilationMessage#message} corresponds to a substring this points to\n * the line on which the substring begins. Must be `0` if the {@link GPUCompilationMessage#message}\n * does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}.\n */\n readonly lineNum: number;\n /**\n * The offset, in UTF-16 code units, from the beginning of line {@link GPUCompilationMessage#lineNum}\n * of the shader {@link GPUShaderModuleDescriptor#code} to the point or beginning of the substring\n * that the {@link GPUCompilationMessage#message} corresponds to. Value is one-based, such that a\n * {@link GPUCompilationMessage#linePos} of `1` indicates the first code unit of the line.\n * If {@link GPUCompilationMessage#message} corresponds to a substring this points to the\n * first UTF-16 code unit of the substring. Must be `0` if the {@link GPUCompilationMessage#message}\n * does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}.\n */\n readonly linePos: number;\n /**\n * The offset from the beginning of the shader {@link GPUShaderModuleDescriptor#code} in UTF-16\n * code units to the point or beginning of the substring that {@link GPUCompilationMessage#message}\n * corresponds to. Must reference the same position as {@link GPUCompilationMessage#lineNum} and\n * {@link GPUCompilationMessage#linePos}. Must be `0` if the {@link GPUCompilationMessage#message}\n * does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}.\n */\n readonly offset: number;\n /**\n * The number of UTF-16 code units in the substring that {@link GPUCompilationMessage#message}\n * corresponds to. If the message does not correspond with a substring then\n * {@link GPUCompilationMessage#length} must be 0.\n */\n readonly length: number;\n }\n\n var GPUCompilationMessage: {\n prototype: GPUCompilationMessage;\n new (): never;\n };\n\n interface GPUComputePassEncoder\n extends GPUObjectBase,\n GPUCommandsMixin,\n GPUDebugCommandsMixin,\n GPUBindingCommandsMixin {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUComputePassEncoder\";\n /**\n * Sets the current {@link GPUComputePipeline}.\n * @param pipeline - The compute pipeline to use for subsequent dispatch commands.\n */\n setPipeline(\n pipeline: GPUComputePipeline\n ): undefined;\n /**\n * Dispatch work to be performed with the current {@link GPUComputePipeline}.\n * See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification.\n * @param workgroupCountX - X dimension of the grid of workgroups to dispatch.\n * @param workgroupCountY - Y dimension of the grid of workgroups to dispatch.\n * @param workgroupCountZ - Z dimension of the grid of workgroups to dispatch.\n */\n dispatchWorkgroups(\n workgroupCountX: GPUSize32,\n workgroupCountY?: GPUSize32,\n workgroupCountZ?: GPUSize32\n ): undefined;\n /**\n * Dispatch work to be performed with the current {@link GPUComputePipeline} using parameters read\n * from a {@link GPUBuffer}.\n * See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification.\n * packed block of **three 32-bit unsigned integer values (12 bytes total)**,\n * given in the same order as the arguments for {@link GPUComputePassEncoder#dispatchWorkgroups}.\n * For example:\n * @param indirectBuffer - Buffer containing the indirect dispatch parameters.\n * @param indirectOffset - Offset in bytes into `indirectBuffer` where the dispatch data begins.\n */\n dispatchWorkgroupsIndirect(\n indirectBuffer: GPUBuffer,\n indirectOffset: GPUSize64\n ): undefined;\n /**\n * Completes recording of the compute pass commands sequence.\n */\n end(): undefined;\n }\n\n var GPUComputePassEncoder: {\n prototype: GPUComputePassEncoder;\n new (): never;\n };\n\n interface GPUComputePipeline\n extends GPUObjectBase,\n GPUPipelineBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUComputePipeline\";\n }\n\n var GPUComputePipeline: {\n prototype: GPUComputePipeline;\n new (): never;\n };\n\n interface GPUDevice\n extends EventTarget,\n GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUDevice\";\n /**\n * A set containing the {@link GPUFeatureName} values of the features\n * supported by the device (i.e. the ones with which it was created).\n */\n readonly features: GPUSupportedFeatures;\n /**\n * Exposes the limits supported by the device\n * (which are exactly the ones with which it was created).\n */\n readonly limits: GPUSupportedLimits;\n /**\n * Information about the physical adapter which created the device\n * that this GPUDevice refers to.\n * For a given GPUDevice, the GPUAdapterInfo values exposed are constant\n * over time.\n */\n readonly adapterInfo: GPUAdapterInfo;\n /**\n * The primary {@link GPUQueue} for this device.\n */\n readonly queue: GPUQueue;\n /**\n * Destroys the device, preventing further operations on it.\n * Outstanding asynchronous operations will fail.\n * Note: It is valid to destroy a device multiple times.\n * Note: Since no further operations can be enqueued on this device, implementations can abort\n * outstanding asynchronous operations immediately and free resource allocations, including\n * mapped memory that was just unmapped.\n */\n destroy(): undefined;\n /**\n * Creates a {@link GPUBuffer}.\n * @param descriptor - Description of the {@link GPUBuffer} to create.\n */\n createBuffer(\n descriptor: GPUBufferDescriptor\n ): GPUBuffer;\n /**\n * Creates a {@link GPUTexture}.\n * @param descriptor - Description of the {@link GPUTexture} to create.\n */\n createTexture(\n descriptor: GPUTextureDescriptor\n ): GPUTexture;\n /**\n * Creates a {@link GPUSampler}.\n * @param descriptor - Description of the {@link GPUSampler} to create.\n */\n createSampler(\n descriptor?: GPUSamplerDescriptor\n ): GPUSampler;\n /**\n * Creates a {@link GPUExternalTexture} wrapping the provided image source.\n * @param descriptor - Provides the external image source object (and any creation options).\n */\n importExternalTexture(\n descriptor: GPUExternalTextureDescriptor\n ): GPUExternalTexture;\n /**\n * Creates a {@link GPUBindGroupLayout}.\n * @param descriptor - Description of the {@link GPUBindGroupLayout} to create.\n */\n createBindGroupLayout(\n descriptor: GPUBindGroupLayoutDescriptor\n ): GPUBindGroupLayout;\n /**\n * Creates a {@link GPUPipelineLayout}.\n * @param descriptor - Description of the {@link GPUPipelineLayout} to create.\n */\n createPipelineLayout(\n descriptor: GPUPipelineLayoutDescriptor\n ): GPUPipelineLayout;\n /**\n * Creates a {@link GPUBindGroup}.\n * @param descriptor - Description of the {@link GPUBindGroup} to create.\n */\n createBindGroup(\n descriptor: GPUBindGroupDescriptor\n ): GPUBindGroup;\n /**\n * Creates a {@link GPUShaderModule}.\n * @param descriptor - Description of the {@link GPUShaderModule} to create.\n */\n createShaderModule(\n descriptor: GPUShaderModuleDescriptor\n ): GPUShaderModule;\n /**\n * Creates a {@link GPUComputePipeline} using immediate pipeline creation.\n * @param descriptor - Description of the {@link GPUComputePipeline} to create.\n */\n createComputePipeline(\n descriptor: GPUComputePipelineDescriptor\n ): GPUComputePipeline;\n /**\n * Creates a {@link GPURenderPipeline} using immediate pipeline creation.\n * @param descriptor - Description of the {@link GPURenderPipeline} to create.\n */\n createRenderPipeline(\n descriptor: GPURenderPipelineDescriptor\n ): GPURenderPipeline;\n /**\n * Creates a {@link GPUComputePipeline} using async pipeline creation.\n * The returned Promise resolves when the created pipeline\n * is ready to be used without additional delay.\n * If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}.\n * (A {@link GPUError} is not dispatched to the device.)\n * Note: Use of this method is preferred whenever possible, as it prevents blocking the\n * queue timeline work on pipeline compilation.\n * @param descriptor - Description of the {@link GPUComputePipeline} to create.\n */\n createComputePipelineAsync(\n descriptor: GPUComputePipelineDescriptor\n ): Promise<GPUComputePipeline>;\n /**\n * Creates a {@link GPURenderPipeline} using async pipeline creation.\n * The returned Promise resolves when the created pipeline\n * is ready to be used without additional delay.\n * If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}.\n * (A {@link GPUError} is not dispatched to the device.)\n * Note: Use of this method is preferred whenever possible, as it prevents blocking the\n * queue timeline work on pipeline compilation.\n * @param descriptor - Description of the {@link GPURenderPipeline} to create.\n */\n createRenderPipelineAsync(\n descriptor: GPURenderPipelineDescriptor\n ): Promise<GPURenderPipeline>;\n /**\n * Creates a {@link GPUCommandEncoder}.\n * @param descriptor - Description of the {@link GPUCommandEncoder} to create.\n */\n createCommandEncoder(\n descriptor?: GPUCommandEncoderDescriptor\n ): GPUCommandEncoder;\n /**\n * Creates a {@link GPURenderBundleEncoder}.\n * @param descriptor - Description of the {@link GPURenderBundleEncoder} to create.\n */\n createRenderBundleEncoder(\n descriptor: GPURenderBundleEncoderDescriptor\n ): GPURenderBundleEncoder;\n /**\n * Creates a {@link GPUQuerySet}.\n * @param descriptor - Description of the {@link GPUQuerySet} to create.\n */\n createQuerySet(\n descriptor: GPUQuerySetDescriptor\n ): GPUQuerySet;\n /**\n * A slot-backed attribute holding a promise which is created with the device, remains\n * pending for the lifetime of the device, then resolves when the device is lost.\n * Upon initialization, it is set to a new promise.\n */\n readonly lost: Promise<GPUDeviceLostInfo>;\n /**\n * Pushes a new GPU error scope onto the {@link GPUDevice}.`[[errorScopeStack]]` for `this`.\n * @param filter - Which class of errors this error scope observes.\n */\n pushErrorScope(\n filter: GPUErrorFilter\n ): undefined;\n /**\n * Pops a GPU error scope off the {@link GPUDevice}.`[[errorScopeStack]]` for `this`\n * and resolves to **any** {@link GPUError} observed by the error scope, or `null` if none.\n * There is no guarantee of the ordering of promise resolution.\n */\n popErrorScope(): Promise<GPUError | null>;\n /**\n * An event handler IDL attribute for the `uncapturederror` event type.\n */\n onuncapturederror:\n | ((\n this: GPUDevice,\n ev: GPUUncapturedErrorEvent\n ) => any)\n | null;\n }\n\n var GPUDevice: {\n prototype: GPUDevice;\n new (): never;\n };\n\n interface GPUDeviceLostInfo {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUDeviceLostInfo\";\n readonly reason: GPUDeviceLostReason;\n readonly message: string;\n }\n\n var GPUDeviceLostInfo: {\n prototype: GPUDeviceLostInfo;\n new (): never;\n };\n\n interface GPUError {\n /**\n * A human-readable, localizable text message providing information about the error that\n * occurred.\n * Note: This message is generally intended for application developers to debug their\n * applications and capture information for debug reports, not to be surfaced to end-users.\n * Note: User agents should not include potentially machine-parsable details in this message,\n * such as free system memory on {@link GPUErrorFilter} `\"out-of-memory\"` or other details about the\n * conditions under which memory was exhausted.\n * Note: The {@link GPUError#message} should follow the best practices for language and\n * direction information. This includes making use of any future standards which may emerge\n * regarding the reporting of string language and direction metadata.\n * <p class=\"note editorial\"><span class=marker>Editorial note:</span>\n * At the time of this writing, no language/direction recommendation is available that provides\n * compatibility and consistency with legacy APIs, but when there is, adopt it formally.\n */\n readonly message: string;\n }\n\n var GPUError: {\n prototype: GPUError;\n new (): never;\n };\n\n interface GPUExternalTexture\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUExternalTexture\";\n }\n\n var GPUExternalTexture: {\n prototype: GPUExternalTexture;\n new (): never;\n };\n\n interface GPUInternalError\n extends GPUError {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUInternalError\";\n }\n\n var GPUInternalError: {\n prototype: GPUInternalError;\n new (\n message: string\n ): GPUInternalError;\n };\n\n interface GPUOutOfMemoryError\n extends GPUError {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUOutOfMemoryError\";\n }\n\n var GPUOutOfMemoryError: {\n prototype: GPUOutOfMemoryError;\n new (\n message: string\n ): GPUOutOfMemoryError;\n };\n\n interface GPUPipelineError\n extends DOMException {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUPipelineError\";\n /**\n * A read-only slot-backed attribute exposing the type of error encountered in pipeline creation\n * as a <dfn enum for=\"\">GPUPipelineErrorReason</dfn>:\n * <ul dfn-type=enum-value dfn-for=GPUPipelineErrorReason>\n * - <dfn>\"validation\"</dfn>: A [$validation error$].\n * - <dfn>\"internal\"</dfn>: An [$internal error$].\n * </ul>\n */\n readonly reason: GPUPipelineErrorReason;\n }\n\n var GPUPipelineError: {\n prototype: GPUPipelineError;\n new (\n message:\n | string\n | undefined,\n options: GPUPipelineErrorInit\n ): GPUPipelineError;\n };\n\n interface GPUPipelineLayout\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUPipelineLayout\";\n }\n\n var GPUPipelineLayout: {\n prototype: GPUPipelineLayout;\n new (): never;\n };\n\n interface GPUQuerySet\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUQuerySet\";\n /**\n * Destroys the {@link GPUQuerySet}.\n */\n destroy(): undefined;\n /**\n * The type of the queries managed by this {@link GPUQuerySet}.\n */\n readonly type: GPUQueryType;\n /**\n * The number of queries managed by this {@link GPUQuerySet}.\n */\n readonly count: GPUSize32Out;\n }\n\n var GPUQuerySet: {\n prototype: GPUQuerySet;\n new (): never;\n };\n\n interface GPUQueue\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUQueue\";\n /**\n * Schedules the execution of the command buffers by the GPU on this queue.\n * Submitted command buffers cannot be used again.\n * \t`commandBuffers`:\n */\n submit(\n commandBuffers: Iterable<GPUCommandBuffer>\n ): undefined;\n /**\n * Returns a Promise that resolves once this queue finishes processing all the work submitted\n * up to this moment.\n * Resolution of this Promise implies the completion of\n * {@link GPUBuffer#mapAsync} calls made prior to that call,\n * on {@link GPUBuffer}s last used exclusively on that queue.\n */\n onSubmittedWorkDone(): Promise<undefined>;\n /**\n * Issues a write operation of the provided data into a {@link GPUBuffer}.\n * @param buffer - The buffer to write to.\n * @param bufferOffset - Offset in bytes into `buffer` to begin writing at.\n * @param data - Data to write into `buffer`.\n * @param dataOffset - Offset in into `data` to begin writing from. Given in elements if\n * \t`data` is a `TypedArray` and bytes otherwise.\n * @param size - Size of content to write from `data` to `buffer`. Given in elements if\n * \t`data` is a `TypedArray` and bytes otherwise.\n */\n writeBuffer(\n buffer: GPUBuffer,\n bufferOffset: GPUSize64,\n data: GPUAllowSharedBufferSource,\n dataOffset?: GPUSize64,\n size?: GPUSize64\n ): undefined;\n /**\n * Issues a write operation of the provided data into a {@link GPUTexture}.\n * @param destination - The texture subresource and origin to write to.\n * @param data - Data to write into `destination`.\n * @param dataLayout - Layout of the content in `data`.\n * @param size - Extents of the content to write from `data` to `destination`.\n */\n writeTexture(\n destination: GPUTexelCopyTextureInfo,\n data: GPUAllowSharedBufferSource,\n dataLayout: GPUTexelCopyBufferLayout,\n size: GPUExtent3DStrict\n ): undefined;\n /**\n * Issues a copy operation of the contents of a platform image/canvas\n * into the destination texture.\n * This operation performs {@link https://www.w3.org/TR/webgpu/#color-space-conversions | color encoding} into the destination\n * encoding according to the parameters of {@link GPUCopyExternalImageDestInfo}.\n * Copying into a `-srgb` texture results in the same texture bytes, not the same decoded\n * values, as copying into the corresponding non-`-srgb` format.\n * Thus, after a copy operation, sampling the destination texture has\n * different results depending on whether its format is `-srgb`, all else unchanged.\n * <!-- POSTV1(srgb-linear): If added, explain here how it interacts. -->\n * @param source - source image and origin to copy to `destination`.\n * @param destination - The texture subresource and origin to write to, and its encoding metadata.\n * @param copySize - Extents of the content to write from `source` to `destination`.\n */\n copyExternalImageToTexture(\n source: GPUCopyExternalImageSourceInfo,\n destination: GPUCopyExternalImageDestInfo,\n copySize: GPUExtent3DStrict\n ): undefined;\n }\n\n var GPUQueue: {\n prototype: GPUQueue;\n new (): never;\n };\n\n interface GPURenderBundle\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPURenderBundle\";\n }\n\n var GPURenderBundle: {\n prototype: GPURenderBundle;\n new (): never;\n };\n\n interface GPURenderBundleEncoder\n extends GPUObjectBase,\n GPUCommandsMixin,\n GPUDebugCommandsMixin,\n GPUBindingCommandsMixin,\n GPURenderCommandsMixin {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPURenderBundleEncoder\";\n /**\n * Completes recording of the render bundle commands sequence.\n * \tdescriptor:\n */\n finish(\n descriptor?: GPURenderBundleDescriptor\n ): GPURenderBundle;\n }\n\n var GPURenderBundleEncoder: {\n prototype: GPURenderBundleEncoder;\n new (): never;\n };\n\n interface GPURenderPassEncoder\n extends GPUObjectBase,\n GPUCommandsMixin,\n GPUDebugCommandsMixin,\n GPUBindingCommandsMixin,\n GPURenderCommandsMixin {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPURenderPassEncoder\";\n /**\n * Sets the viewport used during the rasterization stage to linearly map from\n * NDC|normalized device coordinates to viewport coordinates.\n * @param x - Minimum X value of the viewport in pixels.\n * @param y - Minimum Y value of the viewport in pixels.\n * @param width - Width of the viewport in pixels.\n * @param height - Height of the viewport in pixels.\n * @param minDepth - Minimum depth value of the viewport.\n * @param maxDepth - Maximum depth value of the viewport.\n */\n setViewport(\n x: number,\n y: number,\n width: number,\n height: number,\n minDepth: number,\n maxDepth: number\n ): undefined;\n /**\n * Sets the scissor rectangle used during the rasterization stage.\n * After transformation into viewport coordinates any fragments which fall outside the scissor\n * rectangle will be discarded.\n * @param x - Minimum X value of the scissor rectangle in pixels.\n * @param y - Minimum Y value of the scissor rectangle in pixels.\n * @param width - Width of the scissor rectangle in pixels.\n * @param height - Height of the scissor rectangle in pixels.\n */\n setScissorRect(\n x: GPUIntegerCoordinate,\n y: GPUIntegerCoordinate,\n width: GPUIntegerCoordinate,\n height: GPUIntegerCoordinate\n ): undefined;\n /**\n * Sets the constant blend color and alpha values used with {@link GPUBlendFactor} `\"constant\"`\n * and {@link GPUBlendFactor} `\"one-minus-constant\"` {@link GPUBlendFactor}s.\n * @param color - The color to use when blending.\n */\n setBlendConstant(\n color: GPUColor\n ): undefined;\n /**\n * Sets the RenderState.`[[stencilReference]]` value used during stencil tests with\n * the {@link GPUStencilOperation} `\"replace\"` {@link GPUStencilOperation}.\n * @param reference - The new stencil reference value.\n */\n setStencilReference(\n reference: GPUStencilValue\n ): undefined;\n /**\n * @param queryIndex - The index of the query in the query set.\n */\n beginOcclusionQuery(\n queryIndex: GPUSize32\n ): undefined;\n /**\n */\n endOcclusionQuery(): undefined;\n /**\n * Executes the commands previously recorded into the given {@link GPURenderBundle}s as part of\n * this render pass.\n * When a {@link GPURenderBundle} is executed, it does not inherit the render pass's pipeline, bind\n * groups, or vertex and index buffers. After a {@link GPURenderBundle} has executed, the render\n * pass's pipeline, bind group, and vertex/index buffer state is cleared\n * (to the initial, empty values).\n * Note: The state is cleared, not restored to the previous state.\n * This occurs even if zero {@link GPURenderBundle | GPURenderBundles} are executed.\n * @param bundles - List of render bundles to execute.\n */\n executeBundles(\n bundles: Iterable<GPURenderBundle>\n ): undefined;\n /**\n * Completes recording of the render pass commands sequence.\n */\n end(): undefined;\n }\n\n var GPURenderPassEncoder: {\n prototype: GPURenderPassEncoder;\n new (): never;\n };\n\n interface GPURenderPipeline\n extends GPUObjectBase,\n GPUPipelineBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPURenderPipeline\";\n }\n\n var GPURenderPipeline: {\n prototype: GPURenderPipeline;\n new (): never;\n };\n\n interface GPUSampler\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUSampler\";\n }\n\n var GPUSampler: {\n prototype: GPUSampler;\n new (): never;\n };\n\n interface GPUShaderModule\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUShaderModule\";\n /**\n * Returns any messages generated during the {@link GPUShaderModule}'s compilation.\n * The locations, order, and contents of messages are implementation-defined.\n * In particular, messages aren't necessarily ordered by {@link GPUCompilationMessage#lineNum}.\n */\n getCompilationInfo(): Promise<GPUCompilationInfo>;\n }\n\n var GPUShaderModule: {\n prototype: GPUShaderModule;\n new (): never;\n };\n\n type GPUSupportedFeatures =\n ReadonlySet<string>;\n\n interface GPUSupportedLimits {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUSupportedLimits\";\n readonly maxTextureDimension1D: number;\n readonly maxTextureDimension2D: number;\n readonly maxTextureDimension3D: number;\n readonly maxTextureArrayLayers: number;\n readonly maxBindGroups: number;\n readonly maxBindGroupsPlusVertexBuffers: number;\n readonly maxBindingsPerBindGroup: number;\n readonly maxDynamicUniformBuffersPerPipelineLayout: number;\n readonly maxDynamicStorageBuffersPerPipelineLayout: number;\n readonly maxSampledTexturesPerShaderStage: number;\n readonly maxSamplersPerShaderStage: number;\n readonly maxStorageBuffersPerShaderStage: number;\n /**\n * @todo Temporarily optional until all browsers have implemented it.\n * Check support before using. (Use the non-null assertion operator `!` where needed.)\n */\n readonly maxStorageBuffersInVertexStage?: number;\n /**\n * @todo Temporarily optional until all browsers have implemented it.\n * Check support before using. (Use the non-null assertion operator `!` where needed.)\n */\n readonly maxStorageBuffersInFragmentStage?: number;\n readonly maxStorageTexturesPerShaderStage: number;\n /**\n * @todo Temporarily optional until all browsers have implemented it.\n * Check support before using. (Use the non-null assertion operator `!` where needed.)\n */\n readonly maxStorageTexturesInVertexStage?: number;\n /**\n * @todo Temporarily optional until all browsers have implemented it.\n * Check support before using. (Use the non-null assertion operator `!` where needed.)\n */\n readonly maxStorageTexturesInFragmentStage?: number;\n readonly maxUniformBuffersPerShaderStage: number;\n readonly maxUniformBufferBindingSize: number;\n readonly maxStorageBufferBindingSize: number;\n readonly minUniformBufferOffsetAlignment: number;\n readonly minStorageBufferOffsetAlignment: number;\n readonly maxVertexBuffers: number;\n readonly maxBufferSize: number;\n readonly maxVertexAttributes: number;\n readonly maxVertexBufferArrayStride: number;\n readonly maxInterStageShaderVariables: number;\n readonly maxColorAttachments: number;\n readonly maxColorAttachmentBytesPerSample: number;\n readonly maxComputeWorkgroupStorageSize: number;\n readonly maxComputeInvocationsPerWorkgroup: number;\n readonly maxComputeWorkgroupSizeX: number;\n readonly maxComputeWorkgroupSizeY: number;\n readonly maxComputeWorkgroupSizeZ: number;\n readonly maxComputeWorkgroupsPerDimension: number;\n readonly maxImmediateSize: number;\n }\n\n var GPUSupportedLimits: {\n prototype: GPUSupportedLimits;\n new (): never;\n };\n\n interface GPUTexture\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUTexture\";\n /**\n * Creates a {@link GPUTextureView}.\n * @param descriptor - Description of the {@link GPUTextureView} to create.\n */\n createView(\n descriptor?: GPUTextureViewDescriptor\n ): GPUTextureView;\n /**\n * Destroys the {@link GPUTexture}.\n */\n destroy(): undefined;\n /**\n * The width of this {@link GPUTexture}.\n */\n readonly width: GPUIntegerCoordinateOut;\n /**\n * The height of this {@link GPUTexture}.\n */\n readonly height: GPUIntegerCoordinateOut;\n /**\n * The depth or layer count of this {@link GPUTexture}.\n */\n readonly depthOrArrayLayers: GPUIntegerCoordinateOut;\n /**\n * The number of mip levels of this {@link GPUTexture}.\n */\n readonly mipLevelCount: GPUIntegerCoordinateOut;\n /**\n * The number of sample count of this {@link GPUTexture}.\n */\n readonly sampleCount: GPUSize32Out;\n /**\n * The dimension of the set of texel for each of this {@link GPUTexture}'s subresources.\n */\n readonly dimension: GPUTextureDimension;\n /**\n * The format of this {@link GPUTexture}.\n */\n readonly format: GPUTextureFormat;\n /**\n * The allowed usages for this {@link GPUTexture}.\n */\n readonly usage: GPUFlagsConstant;\n /**\n * On devices without \"core-features-and-limits\", views created from this\n * texture must have this as their dimension.\n *\n * On devices with \"core-features-and-limits\", this is undefined, and there is\n * no such restriction.\n *\n * @todo Temporarily optional until all browsers have implemented it.\n * It is safe to access on any browser, as it will just (correctly) return\n * `undefined` if not implemented. Note, depending on the device, `undefined`\n * is a valid value even in browsers that implement this attribute. (So be\n * careful if using the non-null assertion operator `!` on this.)\n */\n readonly textureBindingViewDimension?:\n | GPUTextureViewDimension\n | undefined;\n }\n\n var GPUTexture: {\n prototype: GPUTexture;\n new (): never;\n };\n\n interface GPUTextureView\n extends GPUObjectBase {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUTextureView\";\n }\n\n var GPUTextureView: {\n prototype: GPUTextureView;\n new (): never;\n };\n\n interface GPUUncapturedErrorEvent\n extends Event {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUUncapturedErrorEvent\";\n /**\n * A slot-backed attribute holding an object representing the error that was uncaptured.\n * This has the same type as errors returned by {@link GPUDevice#popErrorScope}.\n */\n readonly error: GPUError;\n }\n\n var GPUUncapturedErrorEvent: {\n prototype: GPUUncapturedErrorEvent;\n new (\n type: string,\n gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit\n ): GPUUncapturedErrorEvent;\n };\n\n interface GPUValidationError\n extends GPUError {\n /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */\n readonly __brand: \"GPUValidationError\";\n }\n\n var GPUValidationError: {\n prototype: GPUValidationError;\n new (\n message: string\n ): GPUValidationError;\n };\n\n type WGSLLanguageFeatures =\n ReadonlySet<string>;\n\n interface Navigator\n extends NavigatorGPU {}\n\n interface WorkerNavigator\n extends NavigatorGPU {}\n\n interface GPUBufferUsage {\n readonly MAP_READ: GPUFlagsConstant;\n readonly MAP_WRITE: GPUFlagsConstant;\n readonly COPY_SRC: GPUFlagsConstant;\n readonly COPY_DST: GPUFlagsConstant;\n readonly INDEX: GPUFlagsConstant;\n readonly VERTEX: GPUFlagsConstant;\n readonly UNIFORM: GPUFlagsConstant;\n readonly STORAGE: GPUFlagsConstant;\n readonly INDIRECT: GPUFlagsConstant;\n readonly QUERY_RESOLVE: GPUFlagsConstant;\n }\n\n var GPUBufferUsage: GPUBufferUsage;\n\n interface GPUColorWrite {\n readonly RED: GPUFlagsConstant;\n readonly GREEN: GPUFlagsConstant;\n readonly BLUE: GPUFlagsConstant;\n readonly ALPHA: GPUFlagsConstant;\n readonly ALL: GPUFlagsConstant;\n }\n\n var GPUColorWrite: GPUColorWrite;\n\n interface GPUMapMode {\n readonly READ: GPUFlagsConstant;\n readonly WRITE: GPUFlagsConstant;\n }\n\n var GPUMapMode: GPUMapMode;\n\n interface GPUShaderStage {\n readonly VERTEX: GPUFlagsConstant;\n readonly FRAGMENT: GPUFlagsConstant;\n readonly COMPUTE: GPUFlagsConstant;\n }\n\n var GPUShaderStage: GPUShaderStage;\n\n interface GPUTextureUsage {\n readonly COPY_SRC: GPUFlagsConstant;\n readonly COPY_DST: GPUFlagsConstant;\n readonly TEXTURE_BINDING: GPUFlagsConstant;\n readonly STORAGE_BINDING: GPUFlagsConstant;\n readonly RENDER_ATTACHMENT: GPUFlagsConstant;\n readonly TRANSIENT_ATTACHMENT: GPUFlagsConstant;\n }\n\n var GPUTextureUsage: GPUTextureUsage;\n\n // ===== END WEBGPU TYPES =====\n\n // Runtime global - the main viji object\n const viji: VijiAPI;\n \n // Function type aliases (artists define their own render/setup functions)\n type Render = (viji: VijiAPI) => void;\n type Setup = (viji: VijiAPI) => void;\n}\n\n// Module marker (enables top-level await in artist code)\nexport {};\n";
|