@react-three/fiber 10.0.0-canary.4f9f64c → 10.0.0-canary.5140ac8

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.
Files changed (37) hide show
  1. package/dist/chunks/webgpu.cjs +37 -0
  2. package/dist/chunks/webgpu.mjs +21 -0
  3. package/dist/extension.cjs +13 -0
  4. package/dist/extension.d.cts +19 -0
  5. package/dist/extension.d.mts +19 -0
  6. package/dist/extension.d.ts +19 -0
  7. package/dist/extension.mjs +1 -0
  8. package/dist/index.cjs +97 -15367
  9. package/dist/index.d.cts +123 -3874
  10. package/dist/index.d.mts +123 -3874
  11. package/dist/index.d.ts +123 -3846
  12. package/dist/index.mjs +10 -15268
  13. package/dist/legacy.cjs +105 -15307
  14. package/dist/legacy.d.cts +115 -3874
  15. package/dist/legacy.d.mts +115 -3874
  16. package/dist/legacy.d.ts +116 -3849
  17. package/dist/legacy.mjs +21 -15224
  18. package/dist/shared/fiber.Biz9olEe.mjs +481 -0
  19. package/dist/shared/fiber.C6hitYDY.d.cts +48 -0
  20. package/dist/shared/fiber.C_MFx7We.d.cts +1237 -0
  21. package/dist/shared/fiber.C_MFx7We.d.mts +1237 -0
  22. package/dist/shared/fiber.C_MFx7We.d.ts +1237 -0
  23. package/dist/shared/fiber.CaF-CYl7.mjs +16562 -0
  24. package/dist/shared/fiber.CtivZ3IY.d.ts +2494 -0
  25. package/dist/shared/fiber.CvlK0a1Z.d.mts +2494 -0
  26. package/dist/shared/fiber.D4fD6H74.d.mts +48 -0
  27. package/dist/shared/fiber.DEF5PVV3.cjs +16660 -0
  28. package/dist/shared/fiber.DfiCufha.cjs +521 -0
  29. package/dist/shared/fiber.VTTQNnlj.d.cts +2494 -0
  30. package/dist/shared/fiber.YgTUGbja.d.ts +48 -0
  31. package/dist/webgpu/index.cjs +100 -16206
  32. package/dist/webgpu/index.d.cts +116 -4190
  33. package/dist/webgpu/index.d.mts +116 -4190
  34. package/dist/webgpu/index.d.ts +116 -4162
  35. package/dist/webgpu/index.mjs +15 -16090
  36. package/package.json +13 -10
  37. package/readme.md +1 -1
@@ -0,0 +1,2494 @@
1
+ import * as React$1 from 'react';
2
+ import { ReactNode, Component, RefObject, JSX } from 'react';
3
+ import { Options } from 'react-use-measure';
4
+ import { al as RenderProps, m as ConstructorRepresentation, aJ as ObjectMap, a8 as BaseRendererProps, a9 as RendererFactory, aA as Properties, I as InternalState, J as RootState, E as Euler$1, K as RootStore, a4 as EventManager, _ as DomEvent, aw as Instance, o as ThreeElement, as as Catalogue, ap as Root, am as InjectState, aR as ThreeCore, aG as Bridge, aI as UnblockProps, aL as Disposable, D as Dpr, aE as ThreeCamera, z as Size, aK as EquConfig } from './fiber.C_MFx7We.cjs';
5
+ import * as THREE from 'three';
6
+ import { ColorRepresentation, Euler, Loader, RenderTargetOptions as RenderTargetOptions$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D } from 'three';
7
+ import { WebGPURenderer } from 'three/webgpu';
8
+
9
+ //* Loop Types ==============================
10
+
11
+ type GlobalRenderCallback = (timestamp: number) => void
12
+
13
+ type GlobalEffectType = 'before' | 'after' | 'tail'
14
+
15
+ declare const presetsObj: {
16
+ apartment: string;
17
+ city: string;
18
+ dawn: string;
19
+ forest: string;
20
+ lobby: string;
21
+ night: string;
22
+ park: string;
23
+ studio: string;
24
+ sunset: string;
25
+ warehouse: string;
26
+ };
27
+ type PresetsType = keyof typeof presetsObj;
28
+
29
+ //* Background Types ==============================
30
+
31
+ /**
32
+ * Expanded object form for background configuration.
33
+ * Allows separate textures for background (visual backdrop) and environment (PBR lighting).
34
+ */
35
+ interface BackgroundConfig {
36
+ /** HDRI preset name: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse' */
37
+ preset?: PresetsType
38
+ /** Files for cube texture (6 faces) or a single equirect (.hdr, .exr, .jpg, .png, .webp, .avif, .gif) */
39
+ files?: string | string[]
40
+ /** Separate files for scene.background (visual backdrop) */
41
+ backgroundMap?: string | string[]
42
+ backgroundRotation?: Euler | [number, number, number]
43
+ backgroundBlurriness?: number
44
+ backgroundIntensity?: number
45
+ /** Separate files for scene.environment (PBR lighting/reflections) */
46
+ envMap?: string | string[]
47
+ environmentRotation?: Euler | [number, number, number]
48
+ environmentIntensity?: number
49
+ path?: string
50
+ extensions?: (loader: Loader) => void
51
+ }
52
+
53
+ /**
54
+ * Background prop type for Canvas.
55
+ *
56
+ * String detection priority:
57
+ * 1. Preset - exact match against known presets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
58
+ * 2. URL - starts with /, ./, ../, http://, https://, data:, OR has an image extension (a query or hash may follow)
59
+ * 3. Color - default fallback (CSS color names, hex values, rgb(), etc.)
60
+ *
61
+ * @example Color
62
+ * ```tsx
63
+ * <Canvas background="red" />
64
+ * <Canvas background="#ff0000" />
65
+ * <Canvas background={0xff0000} />
66
+ * ```
67
+ *
68
+ * @example Preset
69
+ * ```tsx
70
+ * <Canvas background="city" />
71
+ * ```
72
+ *
73
+ * @example URL
74
+ * ```tsx
75
+ * <Canvas background="/path/to/env.hdr" />
76
+ * <Canvas background="./sky.jpg" />
77
+ * ```
78
+ *
79
+ * @example Object form
80
+ * ```tsx
81
+ * <Canvas background={{
82
+ * files: ['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png'],
83
+ * backgroundMap: 'path/to/sky.jpg',
84
+ * envMap: 'path/to/lighting.hdr',
85
+ * backgroundBlurriness: 0.5,
86
+ * }} />
87
+ * ```
88
+ */
89
+ type BackgroundProp =
90
+ | ColorRepresentation // "red", "#ff0000", 0xff0000
91
+ | string // URL or preset
92
+ | BackgroundConfig // Expanded object form
93
+
94
+ //* Canvas Types ==============================
95
+
96
+ interface CanvasProps
97
+ extends Omit<RenderProps<HTMLCanvasElement>, 'size' | '_primaryToken'>, React$1.HTMLAttributes<HTMLDivElement> {
98
+ children?: React$1.ReactNode
99
+ ref?: React$1.Ref<HTMLCanvasElement>
100
+ /** Canvas fallback content, similar to img's alt prop */
101
+ fallback?: React$1.ReactNode
102
+ /**
103
+ * Options to pass to useMeasure.
104
+ * @see https://github.com/pmndrs/react-use-measure#api
105
+ */
106
+ resize?: Options
107
+ /** The target where events are being subscribed to, default: the div that wraps canvas */
108
+ eventSource?: Element | React$1.RefObject<Element | null>
109
+ /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
110
+ eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
111
+ /** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
112
+ hmr?: boolean
113
+ /** Canvas resolution width in pixels. If omitted, uses container width. */
114
+ width?: number
115
+ /** Canvas resolution height in pixels. If omitted, uses container height. */
116
+ height?: number
117
+ /** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
118
+ forceEven?: boolean
119
+ /**
120
+ * Scene background configuration.
121
+ * Accepts colors, URLs, presets, or an expanded object for separate background/environment.
122
+ * @see BackgroundProp for full documentation and examples
123
+ */
124
+ background?: BackgroundProp
125
+ }
126
+
127
+ //* Loader Types ==============================
128
+
129
+ type InputLike = string | string[] | string[][] | Readonly<string | string[] | string[][]>
130
+
131
+ // Define a loader-like interface that matches THREE.Loader's load signature
132
+ // This works for both generic and non-generic THREE.Loader instances
133
+ interface LoaderLike {
134
+ load(
135
+ url: InputLike,
136
+ onLoad?: (result: any) => void,
137
+ onProgress?: (event: ProgressEvent<EventTarget>) => void,
138
+ onError?: (error: unknown) => void,
139
+ ): any
140
+ }
141
+
142
+ type GLTFLike = { scene: THREE.Object3D }
143
+
144
+ type LoaderInstance<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
145
+ T extends ConstructorRepresentation<LoaderLike> ? InstanceType<T> : T
146
+
147
+ // Infer result type from the load method's callback parameter
148
+ type InferLoadResult<T> = T extends {
149
+ load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
150
+ }
151
+ ? R
152
+ : T extends ConstructorRepresentation<any>
153
+ ? InstanceType<T> extends {
154
+ load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
155
+ }
156
+ ? R
157
+ : any
158
+ : any
159
+
160
+ type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
161
+ InferLoadResult<LoaderInstance<T>> extends infer R ? (R extends GLTFLike ? R & ObjectMap : R) : never
162
+
163
+ type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = (
164
+ loader: LoaderInstance<T>,
165
+ ) => void
166
+
167
+ //* Renderer Props ========================================
168
+
169
+ type WebGLDefaultProps = Omit<THREE.WebGLRendererParameters, 'canvas'> & BaseRendererProps
170
+
171
+ type WebGLProps =
172
+ | RendererFactory<THREE.WebGLRenderer, WebGLDefaultProps>
173
+ | Partial<Properties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters>
174
+
175
+ interface WebGLShadowConfig {
176
+ shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE.WebGLShadowMap>
177
+ }
178
+
179
+ //* Legacy-specific Types ========================================
180
+
181
+ /** Legacy (WebGL) renderer type - re-exported as R3FRenderer from @react-three/fiber/legacy */
182
+ type LegacyRenderer = THREE.WebGLRenderer
183
+
184
+ /** Legacy internal state with narrowed renderer type */
185
+ interface LegacyInternalState extends Omit<InternalState, 'actualRenderer'> {
186
+ actualRenderer: THREE.WebGLRenderer
187
+ }
188
+
189
+ /**
190
+ * Legacy-specific RootState with narrowed renderer type.
191
+ * Automatically used when importing from `@react-three/fiber/legacy`.
192
+ *
193
+ * @example
194
+ * ```tsx
195
+ * import { useThree } from '@react-three/fiber/legacy'
196
+ *
197
+ * function MyComponent() {
198
+ * const { renderer } = useThree()
199
+ * // renderer is typed as THREE.WebGLRenderer
200
+ * renderer.shadowMap.enabled = true
201
+ * }
202
+ * ```
203
+ */
204
+ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
205
+ /** The WebGL renderer instance */
206
+ renderer: THREE.WebGLRenderer
207
+ /** Internals with WebGL renderer */
208
+ internal: LegacyInternalState
209
+ }
210
+
211
+ //* RenderTarget Types ==============================
212
+
213
+
214
+ type RenderTargetOptions = RenderTargetOptions$1
215
+
216
+ type EnvironmentLoaderProps = {
217
+ files?: string | string[];
218
+ path?: string;
219
+ preset?: PresetsType;
220
+ extensions?: (loader: Loader) => void;
221
+ colorSpace?: ColorSpace;
222
+ };
223
+ /**
224
+ * Loads environment textures for reflections and lighting.
225
+ * Supports HDR files, presets, and cubemaps.
226
+ *
227
+ * @example Basic usage
228
+ * ```jsx
229
+ * const texture = useEnvironment({ preset: 'sunset' })
230
+ * ```
231
+ */
232
+ declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown, THREE.TextureEventMap> | CubeTexture<unknown>;
233
+ declare namespace useEnvironment {
234
+ var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
235
+ var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
236
+ }
237
+ /**
238
+ * Options accepted by `useEnvironment.preload`.
239
+ *
240
+ * `colorSpace` is deliberately omitted: preload only warms the loader cache, and colorSpace is
241
+ * applied to the texture by `useEnvironment()` at use time, per consumer. Accepting it here would
242
+ * advertise an option this function silently ignores.
243
+ */
244
+ type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'colorSpace'>;
245
+ type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
246
+
247
+ /**
248
+ * Props for Environment component that sets up global cubemap for PBR materials and backgrounds.
249
+ *
250
+ * @property children - React children to render into custom environment portal
251
+ * @property frames - Number of frames to render the environment. Use 1 for static, Infinity for animated (default: 1)
252
+ * @property near - Near clipping plane for cube camera (default: 0.1)
253
+ * @property far - Far clipping plane for cube camera (default: 1000)
254
+ * @property resolution - Resolution of the cube render target (default: 256)
255
+ * @property background - Whether to set scene.background. Can be true, false, or "only" (which only sets background) (default: false)
256
+ *
257
+ * @property blur - @deprecated Use backgroundBlurriness instead
258
+ * @property backgroundBlurriness - Blur factor between 0 and 1 for background (default: 0, requires three.js 0.146+)
259
+ * @property backgroundIntensity - Intensity factor for background (default: 1, requires three.js 0.163+)
260
+ * @property backgroundRotation - Rotation for background as Euler angles (default: [0,0,0], requires three.js 0.163+)
261
+ * @property environmentIntensity - Intensity factor for environment lighting (default: 1, requires three.js 0.163+)
262
+ * @property environmentRotation - Rotation for environment as Euler angles (default: [0,0,0], requires three.js 0.163+)
263
+ *
264
+ * @property map - Pre-existing texture to use as environment map
265
+ * @property preset - HDRI Haven preset: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse'. Not for production use.
266
+ * @property scene - Custom THREE.Scene or ref to apply environment to (default: uses default scene)
267
+ * @property ground - Ground projection settings. Use true for defaults or object with:
268
+ * - height: Height of camera used to create env map (default: 15)
269
+ * - radius: Radius of the world (default: 60)
270
+ * - scale: Scale of backside projected sphere (default: 1000)
271
+ *
272
+ * Additional loader props:
273
+ * @property files - File path(s) for environment. Supports .hdr, .exr, .jpg (Ultra HDR or plain), an LDR .png/.webp/.avif/.gif, or array of 6 cube faces
274
+ * @property path - Base path for file loading
275
+ * @property extensions - Texture extensions override
276
+ */
277
+ type EnvironmentProps = {
278
+ children?: React$1.ReactNode;
279
+ frames?: number;
280
+ near?: number;
281
+ far?: number;
282
+ resolution?: number;
283
+ background?: boolean | 'only';
284
+ /** deprecated, use backgroundBlurriness */
285
+ blur?: number;
286
+ backgroundBlurriness?: number;
287
+ backgroundIntensity?: number;
288
+ backgroundRotation?: Euler$1;
289
+ environmentIntensity?: number;
290
+ environmentRotation?: Euler$1;
291
+ map?: Texture$1;
292
+ preset?: PresetsType;
293
+ scene?: Scene | React$1.RefObject<Scene>;
294
+ ground?: boolean | {
295
+ radius?: number;
296
+ height?: number;
297
+ scale?: number;
298
+ };
299
+ /** Solid color for background (alternative to files/preset) */
300
+ color?: ColorRepresentation;
301
+ /** Separate files for background (when different from environment files) */
302
+ backgroundFiles?: string | string[];
303
+ } & EnvironmentLoaderProps;
304
+ /**
305
+ * Internal component that applies a pre-existing texture as environment map.
306
+ * Sets scene.environment and optionally scene.background.
307
+ *
308
+ * @example
309
+ * ```jsx
310
+ * <CubeCamera>{(texture) => <EnvironmentMap map={texture} />}</CubeCamera>
311
+ * ```
312
+ */
313
+ declare function EnvironmentMap({ scene, background, map, ...config }: EnvironmentProps): null;
314
+ /**
315
+ * Internal component that loads environment textures from files or presets.
316
+ * Uses HDRLoader for .hdr, EXRLoader for .exr, UltraHDRLoader for .jpg/.jpeg (a JPEG without a gain
317
+ * map loads as a plain image), TextureLoader for an LDR .png/.webp/.avif/.gif, or CubeTextureLoader
318
+ * for arrays of images.
319
+ *
320
+ * @example With preset
321
+ * ```jsx
322
+ * <EnvironmentCube preset="sunset" />
323
+ * ```
324
+ *
325
+ * @example From HDR file
326
+ * ```jsx
327
+ * <EnvironmentCube files="environment.hdr" />
328
+ * ```
329
+ *
330
+ * @example From an Ultra HDR JPEG (smallest footprint)
331
+ * ```jsx
332
+ * <EnvironmentCube files="file.jpg" />
333
+ * ```
334
+ *
335
+ * @example From cube faces
336
+ * ```jsx
337
+ * <EnvironmentCube files={['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png']} />
338
+ * ```
339
+ */
340
+ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, ...rest }: EnvironmentProps): null;
341
+ /**
342
+ * Internal component that renders custom environment using a portal and cube camera.
343
+ * Renders children into an off-buffer and films with a cube camera to create environment map.
344
+ * Can be static (frames=1) or animated (frames=Infinity).
345
+ *
346
+ * @example Custom environment with sphere
347
+ * ```jsx
348
+ * <EnvironmentPortal background near={1} far={1000} resolution={256}>
349
+ * <mesh scale={100}>
350
+ * <sphereGeometry args={[1, 64, 64]} />
351
+ * <meshBasicMaterial map={texture} side={THREE.BackSide} />
352
+ * </mesh>
353
+ * </EnvironmentPortal>
354
+ * ```
355
+ *
356
+ * @example Animated environment
357
+ * ```jsx
358
+ * <EnvironmentPortal frames={Infinity} resolution={256}>
359
+ * <Float>
360
+ * <mesh />
361
+ * </Float>
362
+ * </EnvironmentPortal>
363
+ * ```
364
+ *
365
+ * @example Mixed with preset
366
+ * ```jsx
367
+ * <EnvironmentPortal preset="warehouse">
368
+ * <mesh />
369
+ * </EnvironmentPortal>
370
+ * ```
371
+ */
372
+ declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, scene, files, path, preset, extensions, }: EnvironmentProps): React$1.JSX.Element;
373
+ /**
374
+ * Sets up a global environment map for PBR materials and backgrounds.
375
+ * Affects scene.environment and optionally scene.background unless a custom scene is passed.
376
+ *
377
+ * Supports multiple input methods:
378
+ * - **Presets**: Selection of HDRI Haven assets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
379
+ * - **Files**: HDR (.hdr), EXR (.exr), JPEG (.jpg, Ultra HDR when it carries a gain map), LDR image (.png, .webp, .avif, .gif), or cube faces (array of 6 images)
380
+ * - **Texture**: Pre-existing cube texture via `map` prop
381
+ * - **Custom Scene**: Render children into environment using portal and cube camera
382
+ * - **Ground Projection**: Project environment onto ground plane
383
+ *
384
+ * @remarks
385
+ * - Preset property is NOT meant for production and may fail (relies on CDNs)
386
+ * - Ultra HDR JPEG has the smallest file footprint
387
+ * - Use `frames={Infinity}` for animated environments with low resolution for performance
388
+ * - Ground projection places models on the "ground" within the environment map
389
+ * - Supports self-hosting with @pmndrs/assets using dynamic imports
390
+ *
391
+ * @example Basic preset usage
392
+ * ```jsx
393
+ * <Environment preset="sunset" />
394
+ * ```
395
+ *
396
+ * @example From HDR file
397
+ * ```jsx
398
+ * <Environment files="/hdr/environment.hdr" />
399
+ * ```
400
+ *
401
+ * @example From an Ultra HDR JPEG (smallest footprint)
402
+ * ```jsx
403
+ * <Environment files="file.jpg" />
404
+ * ```
405
+ *
406
+ * @example With self-hosted assets
407
+ * ```jsx
408
+ * import { suspend } from 'suspend-react'
409
+ * const city = import('@pmndrs/assets/hdri/city.exr').then(m => m.default)
410
+ *
411
+ * <Environment files={suspend(city)} />
412
+ * ```
413
+ *
414
+ * @example From existing texture
415
+ * ```jsx
416
+ * <CubeCamera>{(texture) => <Environment map={texture} />}</CubeCamera>
417
+ * ```
418
+ *
419
+ * @example Custom environment scene
420
+ * ```jsx
421
+ * <Environment background near={1} far={1000} resolution={256}>
422
+ * <mesh scale={100}>
423
+ * <sphereGeometry args={[1, 64, 64]} />
424
+ * <meshBasicMaterial map={texture} side={THREE.BackSide} />
425
+ * </mesh>
426
+ * </Environment>
427
+ * ```
428
+ *
429
+ * @example Animated environment
430
+ * ```jsx
431
+ * <Environment frames={Infinity} resolution={256}>
432
+ * <Float>
433
+ * <mesh />
434
+ * </Float>
435
+ * </Environment>
436
+ * ```
437
+ *
438
+ * @example Mixed custom scene with preset
439
+ * ```jsx
440
+ * <Environment background preset="warehouse">
441
+ * <mesh />
442
+ * </Environment>
443
+ * ```
444
+ *
445
+ * @example With ground projection
446
+ * ```jsx
447
+ * <Environment ground={{ height: 15, radius: 60 }} preset="city" />
448
+ * ```
449
+ *
450
+ * @example As background only
451
+ * ```jsx
452
+ * <Environment background="only" preset="sunset" />
453
+ * ```
454
+ *
455
+ * @example With rotation and intensity
456
+ * ```jsx
457
+ * <Environment
458
+ * background
459
+ * backgroundBlurriness={0.5}
460
+ * backgroundIntensity={0.8}
461
+ * backgroundRotation={[0, Math.PI / 2, 0]}
462
+ * environmentIntensity={1.2}
463
+ * environmentRotation={[0, Math.PI / 4, 0]}
464
+ * preset="studio"
465
+ * />
466
+ * ```
467
+ */
468
+ declare function Environment(props: EnvironmentProps): React$1.JSX.Element;
469
+
470
+ /**
471
+ * Moves every trace of interactivity from one object to its replacement, for reconstruction.
472
+ *
473
+ * When `args` or a `primitive`'s `object` changes, R3F builds a new three object and keeps the same
474
+ * instance. Removing the old object from the interaction state and registering the new one from
475
+ * scratch makes events *work* again (#3778), but it forgets what was in flight: a pointer resting on
476
+ * the object fires a second `onPointerEnter` without ever having left, and an active pointer capture
477
+ * is dropped mid-drag. Rewriting the references instead keeps the interaction continuous across a
478
+ * swap the user never asked to see (#3744).
479
+ *
480
+ * Captures are re-keyed rather than released, so the DOM-level capture on `captureData.target` is
481
+ * left alone — releasing and re-acquiring it is precisely the glitch being avoided.
482
+ *
483
+ * Visibility handlers are deliberately not transferred: that registry is keyed by `object.uuid`, so
484
+ * the replacement re-registers itself through `applyProps`. The old entry is dropped here so it
485
+ * cannot outlive the object it described.
486
+ */
487
+ declare function swapInteractivity(store: RootStore, object: THREE.Object3D, newObject: THREE.Object3D): void;
488
+ declare function removeInteractivity(store: RootStore, object: THREE.Object3D): void;
489
+ declare function createEvents(store: RootStore): {
490
+ handlePointer: (name: string) => (event: DomEvent) => void;
491
+ flushDeferredPointers: () => void;
492
+ processDeferredPointer: (event: DomEvent, pointerId: number) => void;
493
+ };
494
+ /** Default R3F event manager for web */
495
+ declare function createPointerEvents(store: RootStore): EventManager<Element>;
496
+
497
+ /**
498
+ * Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
499
+ * This allows external code to access loader methods like abort().
500
+ */
501
+ declare function getLoader<L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(Proto: L): L extends ConstructorRepresentation<infer T> ? T : L;
502
+ /**
503
+ * Synchronously loads and caches assets with a three loader.
504
+ *
505
+ * Note: this hook's caller must be wrapped with `React.Suspense`
506
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
507
+ */
508
+ declare function useLoader<I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void, cacheKey?: InputLike): I extends any[] ? LoaderResult<L>[] : LoaderResult<L>;
509
+ declare namespace useLoader {
510
+ var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void, cacheKey?: InputLike) => void;
511
+ var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, cacheKey?: InputLike) => void;
512
+ var loader: typeof getLoader;
513
+ }
514
+
515
+ declare const IsObject: (url: unknown) => url is Record<string, string>;
516
+ type TextureArray<T> = T extends string[] ? Texture$1[] : never;
517
+ type TextureRecord<T> = T extends Record<string, string> ? {
518
+ [key in keyof T]: Texture$1;
519
+ } : never;
520
+ type SingleTexture<T> = T extends string ? Texture$1 : never;
521
+ type MappedTextureType<T extends string[] | string | Record<string, string>> = TextureArray<T> | TextureRecord<T> | SingleTexture<T>;
522
+ /** Options for useTexture hook */
523
+ type UseTextureOptions<Url extends string[] | string | Record<string, string>> = {
524
+ /** Callback when texture(s) finish loading */
525
+ onLoad?: (texture: MappedTextureType<Url>) => void;
526
+ /**
527
+ * Register the texture(s) in R3F's global texture registry for access via useTextures().
528
+ * When true (the default):
529
+ * - Textures persist until explicitly disposed
530
+ * - On mount, returns existing registered textures if available (preserving modifications like colorSpace)
531
+ *
532
+ * Reads are taken once at mount — a mounted `useTexture` does not re-render when the registry
533
+ * changes. To react to registry swaps, use `useTextures(s => s.get(key))` instead.
534
+ *
535
+ * Pass `false` to opt out of registry enrollment entirely.
536
+ * @default true
537
+ */
538
+ cache?: boolean;
539
+ };
540
+ /**
541
+ * Load texture(s) using Three's TextureLoader with Suspense support.
542
+ *
543
+ * @param input - URL string, array of URLs, or object mapping keys to URLs
544
+ * @param optionsOrOnLoad - Options object or legacy onLoad callback
545
+ *
546
+ * @example
547
+ * ```tsx
548
+ * // Single texture
549
+ * const diffuse = useTexture('/textures/diffuse.png')
550
+ *
551
+ * // Multiple textures (array)
552
+ * const [diffuse, normal] = useTexture(['/diffuse.png', '/normal.png'])
553
+ *
554
+ * // Named textures (object)
555
+ * const { diffuse, normal } = useTexture({
556
+ * diffuse: '/diffuse.png',
557
+ * normal: '/normal.png'
558
+ * })
559
+ *
560
+ * // Textures are registered in the global registry by default — the same texture
561
+ * // object is shared across components and modifications (colorSpace, wrapS, etc.) are preserved
562
+ * const diffuse = useTexture('/diffuse.png')
563
+ * diffuse.colorSpace = THREE.SRGBColorSpace
564
+ *
565
+ * // Another component gets the SAME texture with colorSpace already set
566
+ * const sameDiffuse = useTexture('/diffuse.png')
567
+ *
568
+ * // Opt out of registry enrollment for a one-off texture
569
+ * const scratch = useTexture('/scratch.png', { cache: false })
570
+ *
571
+ * // Access the registry directly
572
+ * const { get } = useTextures()
573
+ * const cached = get('/diffuse.png')
574
+ * ```
575
+ */
576
+ declare function useTexture<Url extends string[] | string | Record<string, string>>(input: Url, optionsOrOnLoad?: UseTextureOptions<Url> | ((texture: MappedTextureType<Url>) => void)): MappedTextureType<Url>;
577
+ declare namespace useTexture {
578
+ var preload: (url: string | string[]) => void;
579
+ var clear: (input: string | string[]) => void;
580
+ }
581
+ declare const Texture: ({ children, input, onLoad, cache, }: {
582
+ children?: (texture: ReturnType<typeof useTexture>) => ReactNode;
583
+ input: Parameters<typeof useTexture>[0];
584
+ onLoad?: Parameters<typeof useTexture>[1];
585
+ cache?: boolean;
586
+ }) => React$1.JSX.Element;
587
+
588
+ /** Accepted shapes for a registry read: a single key, a list of keys, or a name→key map. */
589
+ type TextureInput = string | string[] | Record<string, string>;
590
+ /** Result of a `get()` read, mirroring the input shape. */
591
+ type TextureResult<Input extends TextureInput> = Input extends string ? Texture$1 | undefined : Input extends string[] ? (Texture$1 | undefined)[] : {
592
+ [K in keyof Input]: Texture$1 | undefined;
593
+ };
594
+ /** Options for `dispose()`. */
595
+ interface DisposeOptions {
596
+ /** Dispose even if the texture still has active references (default false). */
597
+ force?: boolean;
598
+ }
599
+ interface UseTexturesReturn {
600
+ /** The live registry Map (key → Texture). Treat as read-only. */
601
+ readonly all: Map<string, Texture$1>;
602
+ /** Read one texture, an array of textures, or a name→texture record (mirrors the input shape). */
603
+ get<Input extends TextureInput>(input: Input): TextureResult<Input>;
604
+ /** Check whether a key exists in the registry. */
605
+ has(key: string): boolean;
606
+ /**
607
+ * Register a texture (or a record of textures) that has no URL — e.g. a render
608
+ * target or procedural texture. URL-loaded textures are registered automatically
609
+ * by `useTexture` (registry enrollment is on by default).
610
+ */
611
+ add(key: string, texture: Texture$1): void;
612
+ add(record: Record<string, Texture$1>): void;
613
+ /**
614
+ * Dispose a texture's GPU resources and remove it from the registry.
615
+ * Refcount-aware: if the key is still in use by a mounted `useTexture` consumer it is
616
+ * skipped (with a warning) unless `{ force: true }` is passed.
617
+ * @returns true if disposed, false if skipped.
618
+ */
619
+ dispose(key: string, options?: DisposeOptions): boolean;
620
+ /** Dispose every texture in the registry and clear it. Use on scene teardown. */
621
+ disposeAll(): void;
622
+ }
623
+ /**
624
+ * Reactive Texture registry — load once with `useTexture`, reach the textures from anywhere.
625
+ *
626
+ * This is a registry of plain `Texture` objects (not TSL nodes), so the same texture can feed
627
+ * a material map, a heightmap sampler, or anything else. It does **not** load — pair it with
628
+ * `useTexture` for loading (registry enrollment is on by default); `useTextures` is for access and lifecycle.
629
+ *
630
+ * The returned handle is **reactive**: the calling component re-renders when the registry
631
+ * changes. Pass a selector to scope the subscription to a single read.
632
+ *
633
+ * @example
634
+ * ```tsx
635
+ * // Load + register once (anywhere in the tree) — registered by default
636
+ * useTexture({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
637
+ *
638
+ * // Reach them from another component — record form lands straight into a material
639
+ * const { map, normalMap } = useTextures().get({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
640
+ * return <meshStandardMaterial map={map} normalMap={normalMap} />
641
+ *
642
+ * // A set of heightmaps at once
643
+ * const [a, b, c] = useTextures().get(['/h0.png', '/h1.png', '/h2.png'])
644
+ *
645
+ * // Register a non-URL texture (render target / procedural)
646
+ * useTextures().add('rt-main', renderTarget.texture)
647
+ *
648
+ * // Deliberate GPU cleanup (refcount-aware; force to override)
649
+ * useTextures().dispose('/diffuse.jpg')
650
+ * useTextures().disposeAll() // scene teardown
651
+ * ```
652
+ *
653
+ * @remarks
654
+ * **Future expansion:** an imperative async loader (e.g. `await useTextures().load('/x.jpg')`) is
655
+ * intentionally not included yet. It would let non-React code (loading screens, dynamic streaming)
656
+ * populate the registry without Suspense, at the cost of putting loading back into this hook. It
657
+ * will be added only if a concrete consumer needs imperative loading; for now, loading lives in
658
+ * `useTexture`.
659
+ */
660
+ declare function useTextures(): UseTexturesReturn;
661
+ declare function useTextures<T>(selector: (registry: UseTexturesReturn) => T): T;
662
+
663
+ /**
664
+ * Exposes an object's {@link Instance}.
665
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
666
+ *
667
+ * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
668
+ */
669
+ declare function useInstanceHandle<T>(ref: React.RefObject<T>): React.RefObject<Instance<T>>;
670
+ /**
671
+ * Returns a node graph of an object with named nodes & materials.
672
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
673
+ */
674
+ declare function useGraph(object: Object3D): ObjectMap;
675
+
676
+ /**
677
+ * Adds a global render callback which is called each frame BEFORE rendering.
678
+ *
679
+ * @deprecated Use `useFrame(callback, { phase: 'start' })` instead.
680
+ * This function will be removed in a future version.
681
+ *
682
+ * @param callback - Function called each frame with timestamp
683
+ * @returns Unsubscribe function
684
+ *
685
+ * @example
686
+ * // OLD (deprecated)
687
+ * const unsub = addEffect((timestamp) => { ... })
688
+ *
689
+ * // NEW
690
+ * useFrame((state, delta) => { ... }, { phase: 'start' })
691
+ *
692
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
693
+ */
694
+ declare function addEffect(callback: GlobalRenderCallback): () => void;
695
+ /**
696
+ * Adds a global after-render callback which is called each frame AFTER rendering.
697
+ *
698
+ * @deprecated Use `useFrame(callback, { phase: 'finish' })` instead.
699
+ * This function will be removed in a future version.
700
+ *
701
+ * @param callback - Function called each frame with timestamp
702
+ * @returns Unsubscribe function
703
+ *
704
+ * @example
705
+ * // OLD (deprecated)
706
+ * const unsub = addAfterEffect((timestamp) => { ... })
707
+ *
708
+ * // NEW
709
+ * useFrame((state, delta) => { ... }, { phase: 'finish' })
710
+ *
711
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
712
+ */
713
+ declare function addAfterEffect(callback: GlobalRenderCallback): () => void;
714
+ /**
715
+ * Adds a global callback which is called when rendering stops.
716
+ *
717
+ * @deprecated Use `scheduler.onIdle(callback)` instead.
718
+ * This function will be removed in a future version.
719
+ *
720
+ * @param callback - Function called when rendering stops
721
+ * @returns Unsubscribe function
722
+ *
723
+ * @example
724
+ * // OLD (deprecated)
725
+ * const unsub = addTail((timestamp) => { ... })
726
+ *
727
+ * // NEW
728
+ * const { scheduler } = useFrame()
729
+ * const unsub = scheduler.onIdle((timestamp) => { ... })
730
+ *
731
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
732
+ */
733
+ declare function addTail(callback: GlobalRenderCallback): () => void;
734
+ /**
735
+ * Invalidates the view, requesting a frame to be rendered.
736
+ * In demand mode, this triggers the scheduler to run frames.
737
+ *
738
+ * With a state argument, only that root's jobs run on the requested frames; other
739
+ * roots on 'demand' stay idle. Without one, every registered root is invalidated.
740
+ *
741
+ * @param state - Optional root state; targets the invalidation at that root
742
+ * @param frames - Number of frames to request (default: 1)
743
+ * @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
744
+ *
745
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
746
+ */
747
+ declare function invalidate(state?: RootState, frames?: number, stackFrames?: boolean): void;
748
+ /**
749
+ * Advances the frameloop and runs render effects.
750
+ * Useful for when manually rendering via `frameloop="never"`.
751
+ *
752
+ * With a state argument, only that root is stepped. Without one, every
753
+ * registered root is stepped for backwards compatibility.
754
+ *
755
+ * @param timestamp - The timestamp to use for this frame
756
+ * @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
757
+ * @param state - Optional root state; targets the manual step at that root
758
+ *
759
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
760
+ */
761
+ declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
762
+
763
+ /* eslint-disable @definitelytyped/no-unnecessary-generics */
764
+ declare function ReactReconciler<
765
+ Type,
766
+ Props,
767
+ Container,
768
+ Instance,
769
+ TextInstance,
770
+ SuspenseInstance,
771
+ HydratableInstance,
772
+ FormInstance,
773
+ PublicInstance,
774
+ HostContext,
775
+ ChildSet,
776
+ TimeoutHandle,
777
+ NoTimeout,
778
+ TransitionStatus,
779
+ >(
780
+ /* eslint-enable @definitelytyped/no-unnecessary-generics */
781
+ config: ReactReconciler.HostConfig<
782
+ Type,
783
+ Props,
784
+ Container,
785
+ Instance,
786
+ TextInstance,
787
+ SuspenseInstance,
788
+ HydratableInstance,
789
+ FormInstance,
790
+ PublicInstance,
791
+ HostContext,
792
+ ChildSet,
793
+ TimeoutHandle,
794
+ NoTimeout,
795
+ TransitionStatus
796
+ >,
797
+ ): ReactReconciler.Reconciler<Container, Instance, TextInstance, SuspenseInstance, FormInstance, PublicInstance>;
798
+
799
+ declare namespace ReactReconciler {
800
+ interface HostConfig<
801
+ Type,
802
+ Props,
803
+ Container,
804
+ Instance,
805
+ TextInstance,
806
+ SuspenseInstance,
807
+ HydratableInstance,
808
+ FormInstance,
809
+ PublicInstance,
810
+ HostContext,
811
+ ChildSet,
812
+ TimeoutHandle,
813
+ NoTimeout,
814
+ TransitionStatus,
815
+ > {
816
+ // -------------------
817
+ // Modes
818
+ // -------------------
819
+ /**
820
+ * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.
821
+ *
822
+ * If your target platform is similar to the DOM and has methods similar to `appendChild`, `removeChild`, and so on, you'll want to use the **mutation mode**. This is the same mode used by React DOM, React ART, and the classic React Native renderer.
823
+ *
824
+ * ```js
825
+ * const HostConfig = {
826
+ * // ...
827
+ * supportsMutation: true,
828
+ * // ...
829
+ * }
830
+ * ```
831
+ *
832
+ * Depending on the mode, the reconciler will call different methods on your host config.
833
+ *
834
+ * If you're not sure which one you want, you likely need the mutation mode.
835
+ */
836
+ supportsMutation: boolean;
837
+
838
+ /**
839
+ * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.
840
+ *
841
+ * If your target platform has immutable trees, you'll want the **persistent mode** instead. In that mode, existing nodes are never mutated, and instead every change clones the parent tree and then replaces the whole parent tree at the root. This is the node used by the new React Native renderer, codenamed "Fabric".
842
+ *
843
+ * ```js
844
+ * const HostConfig = {
845
+ * // ...
846
+ * supportsPersistence: true,
847
+ * // ...
848
+ * }
849
+ * ```
850
+ *
851
+ * Depending on the mode, the reconciler will call different methods on your host config.
852
+ *
853
+ * If you're not sure which one you want, you likely need the mutation mode.
854
+ */
855
+ supportsPersistence: boolean;
856
+
857
+ // -------------------
858
+ // Core Methods
859
+ // -------------------
860
+
861
+ /**
862
+ * This method should return a newly created node. For example, the DOM renderer would call `document.createElement(type)` here and then set the properties from `props`.
863
+ *
864
+ * You can use `rootContainer` to access the root container associated with that tree. For example, in the DOM renderer, this is useful to get the correct `document` reference that the root belongs to.
865
+ *
866
+ * The `hostContext` parameter lets you keep track of some information about your current place in the tree. To learn more about it, see `getChildHostContext` below.
867
+ *
868
+ * The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its internal fields, be aware that it may change significantly between versions. You're taking on additional maintenance risk by reading from it, and giving up all guarantees if you write something to it.
869
+ *
870
+ * This method happens **in the render phase**. It can (and usually should) mutate the node it has just created before returning it, but it must not modify any other nodes. It must not register any event handlers on the parent tree. This is because an instance being created doesn't guarantee it would be placed in the tree — it could be left unused and later collected by GC. If you need to do something when an instance is definitely in the tree, look at `commitMount` instead.
871
+ */
872
+ createInstance(
873
+ type: Type,
874
+ props: Props,
875
+ rootContainer: Container,
876
+ hostContext: HostContext,
877
+ internalHandle: OpaqueHandle,
878
+ ): Instance;
879
+
880
+ /**
881
+ * Same as `createInstance`, but for text nodes. If your renderer doesn't support text nodes, you can throw here.
882
+ */
883
+ createTextInstance(
884
+ text: string,
885
+ rootContainer: Container,
886
+ hostContext: HostContext,
887
+ internalHandle: OpaqueHandle,
888
+ ): TextInstance;
889
+
890
+ /**
891
+ * This method should mutate the `parentInstance` and add the child to its list of children. For example, in the DOM this would translate to a `parentInstance.appendChild(child)` call.
892
+ *
893
+ * This method happens **in the render phase**. It can mutate `parentInstance` and `child`, but it must not modify any other nodes. It's called while the tree is still being built up and not connected to the actual tree on the screen.
894
+ */
895
+ appendInitialChild(parentInstance: Instance, child: Instance | TextInstance): void;
896
+
897
+ /**
898
+ * In this method, you can perform some final mutations on the `instance`. Unlike with `createInstance`, by the time `finalizeInitialChildren` is called, all the initial children have already been added to the `instance`, but the instance itself has not yet been connected to the tree on the screen.
899
+ *
900
+ * This method happens **in the render phase**. It can mutate `instance`, but it must not modify any other nodes. It's called while the tree is still being built up and not connected to the actual tree on the screen.
901
+ *
902
+ * There is a second purpose to this method. It lets you specify whether there is some work that needs to happen when the node is connected to the tree on the screen. If you return `true`, the instance will receive a `commitMount` call later. See its documentation below.
903
+ *
904
+ * If you don't want to do anything here, you should return `false`.
905
+ */
906
+ finalizeInitialChildren(
907
+ instance: Instance,
908
+ type: Type,
909
+ props: Props,
910
+ rootContainer: Container,
911
+ hostContext: HostContext,
912
+ ): boolean;
913
+
914
+ /**
915
+ * Some target platforms support setting an instance's text content without manually creating a text node. For example, in the DOM, you can set `node.textContent` instead of creating a text node and appending it.
916
+ *
917
+ * If you return `true` from this method, React will assume that this node's children are text, and will not create nodes for them. It will instead rely on you to have filled that text during `createInstance`. This is a performance optimization. For example, the DOM renderer returns `true` only if `type` is a known text-only parent (like `'textarea'`) or if `props.children` has a `'string'` type. If you return `true`, you will need to implement `resetTextContent` too.
918
+ *
919
+ * If you don't want to do anything here, you should return `false`.
920
+ *
921
+ * This method happens **in the render phase**. Do not mutate the tree from it.
922
+ */
923
+ shouldSetTextContent(type: Type, props: Props): boolean;
924
+
925
+ /**
926
+ * This method lets you return the initial host context from the root of the tree. See `getChildHostContext` for the explanation of host context.
927
+ *
928
+ * If you don't intend to use host context, you can return `null`.
929
+ *
930
+ * This method happens **in the render phase**. Do not mutate the tree from it.
931
+ */
932
+ getRootHostContext(rootContainer: Container): HostContext | null;
933
+
934
+ /**
935
+ * Host context lets you track some information about where you are in the tree so that it's available inside `createInstance` as the `hostContext` parameter. For example, the DOM renderer uses it to track whether it's inside an HTML or an SVG tree, because `createInstance` implementation needs to be different for them.
936
+ *
937
+ * If the node of this `type` does not influence the context you want to pass down, you can return `parentHostContext`. Alternatively, you can return any custom object representing the information you want to pass down.
938
+ *
939
+ * If you don't want to do anything here, return `parentHostContext`.
940
+ *
941
+ * This method happens **in the render phase**. Do not mutate the tree from it.
942
+ */
943
+ getChildHostContext(parentHostContext: HostContext, type: Type, rootContainer: Container): HostContext;
944
+
945
+ /**
946
+ * Determines what object gets exposed as a ref. You'll likely want to return the `instance` itself. But in some cases it might make sense to only expose some part of it.
947
+ *
948
+ * If you don't want to do anything here, return `instance`.
949
+ */
950
+ getPublicInstance(instance: Instance | TextInstance): PublicInstance;
951
+
952
+ /**
953
+ * This method lets you store some information before React starts making changes to the tree on the screen. For example, the DOM renderer stores the current text selection so that it can later restore it. This method is mirrored by `resetAfterCommit`.
954
+ *
955
+ * Even if you don't want to do anything here, you need to return `null` from it.
956
+ */
957
+ prepareForCommit(containerInfo: Container): Record<string, any> | null;
958
+
959
+ /**
960
+ * This method is called right after React has performed the tree mutations. You can use it to restore something you've stored in `prepareForCommit` — for example, text selection.
961
+ *
962
+ * You can leave it empty.
963
+ */
964
+ resetAfterCommit(containerInfo: Container): void;
965
+
966
+ /**
967
+ * This method is called for a container that's used as a portal target. Usually you can leave it empty.
968
+ */
969
+ preparePortalMount(containerInfo: Container): void;
970
+
971
+ /**
972
+ * You can proxy this to `setTimeout` or its equivalent in your environment.
973
+ */
974
+ scheduleTimeout(fn: (...args: unknown[]) => unknown, delay?: number): TimeoutHandle;
975
+
976
+ /**
977
+ * You can proxy this to `clearTimeout` or its equivalent in your environment.
978
+ */
979
+ cancelTimeout(id: TimeoutHandle): void;
980
+
981
+ /**
982
+ * This is a property (not a function) that should be set to something that can never be a valid timeout ID. For example, you can set it to `-1`.
983
+ */
984
+ noTimeout: NoTimeout;
985
+
986
+ /**
987
+ * Set this to true to indicate that your renderer supports `scheduleMicrotask`. We use microtasks as part of our discrete event implementation in React DOM. If you're not sure if your renderer should support this, you probably should. The option to not implement `scheduleMicrotask` exists so that platforms with more control over user events, like React Native, can choose to use a different mechanism.
988
+ */
989
+ supportsMicrotasks?: boolean;
990
+
991
+ /**
992
+ * Optional. You can proxy this to `queueMicrotask` or its equivalent in your environment.
993
+ */
994
+ scheduleMicrotask?(fn: () => unknown): void;
995
+
996
+ /**
997
+ * This is a property (not a function) that should be set to `true` if your renderer is the main one on the page. For example, if you're writing a renderer for the Terminal, it makes sense to set it to `true`, but if your renderer is used *on top of* React DOM or some other existing renderer, set it to `false`.
998
+ */
999
+ isPrimaryRenderer: boolean;
1000
+
1001
+ /**
1002
+ * Whether the renderer shouldn't trigger missing `act()` warnings
1003
+ */
1004
+ warnsIfNotActing?: boolean;
1005
+
1006
+ getInstanceFromNode(node: any): Fiber | null | undefined;
1007
+
1008
+ beforeActiveInstanceBlur(): void;
1009
+
1010
+ afterActiveInstanceBlur(): void;
1011
+
1012
+ prepareScopeUpdate(scopeInstance: any, instance: any): void;
1013
+
1014
+ getInstanceFromScope(scopeInstance: any): null | Instance;
1015
+
1016
+ detachDeletedInstance(node: Instance): void;
1017
+
1018
+ // -------------------
1019
+ // Mutation Methods
1020
+ // (optional)
1021
+ // If you're using React in mutation mode (you probably do), you'll need to implement a few more methods.
1022
+ // -------------------
1023
+
1024
+ /**
1025
+ * This method should mutate the `parentInstance` and add the child to its list of children. For example, in the DOM this would translate to a `parentInstance.appendChild(child)` call.
1026
+ *
1027
+ * Although this method currently runs in the commit phase, you still should not mutate any other nodes in it. If you need to do some additional work when a node is definitely connected to the visible tree, look at `commitMount`.
1028
+ */
1029
+ appendChild?(parentInstance: Instance, child: Instance | TextInstance): void;
1030
+
1031
+ /**
1032
+ * Same as `appendChild`, but for when a node is attached to the root container. This is useful if attaching to the root has a slightly different implementation, or if the root container nodes are of a different type than the rest of the tree.
1033
+ */
1034
+ appendChildToContainer?(container: Container, child: Instance | TextInstance): void;
1035
+
1036
+ /**
1037
+ * This method should mutate the `parentInstance` and place the `child` before `beforeChild` in the list of its children. For example, in the DOM this would translate to a `parentInstance.insertBefore(child, beforeChild)` call.
1038
+ *
1039
+ * Note that React uses this method both for insertions and for reordering nodes. Similar to DOM, it is expected that you can call `insertBefore` to reposition an existing child. Do not mutate any other parts of the tree from it.
1040
+ */
1041
+ insertBefore?(
1042
+ parentInstance: Instance,
1043
+ child: Instance | TextInstance,
1044
+ beforeChild: Instance | TextInstance | SuspenseInstance,
1045
+ ): void;
1046
+
1047
+ /**
1048
+ * Same as `insertBefore`, but for when a node is attached to the root container. This is useful if attaching to the root has a slightly different implementation, or if the root container nodes are of a different type than the rest of the tree.
1049
+ */
1050
+ insertInContainerBefore?(
1051
+ container: Container,
1052
+ child: Instance | TextInstance,
1053
+ beforeChild: Instance | TextInstance | SuspenseInstance,
1054
+ ): void;
1055
+
1056
+ /**
1057
+ * This method should mutate the `parentInstance` to remove the `child` from the list of its children.
1058
+ *
1059
+ * React will only call it for the top-level node that is being removed. It is expected that garbage collection would take care of the whole subtree. You are not expected to traverse the child tree in it.
1060
+ */
1061
+ removeChild?(parentInstance: Instance, child: Instance | TextInstance | SuspenseInstance): void;
1062
+
1063
+ /**
1064
+ * Same as `removeChild`, but for when a node is detached from the root container. This is useful if attaching to the root has a slightly different implementation, or if the root container nodes are of a different type than the rest of the tree.
1065
+ */
1066
+ removeChildFromContainer?(container: Container, child: Instance | TextInstance | SuspenseInstance): void;
1067
+
1068
+ /**
1069
+ * If you returned `true` from `shouldSetTextContent` for the previous props, but returned `false` from `shouldSetTextContent` for the next props, React will call this method so that you can clear the text content you were managing manually. For example, in the DOM you could set `node.textContent = ''`.
1070
+ *
1071
+ * If you never return `true` from `shouldSetTextContent`, you can leave it empty.
1072
+ */
1073
+ resetTextContent?(instance: Instance): void;
1074
+
1075
+ /**
1076
+ * This method should mutate the `textInstance` and update its text content to `nextText`.
1077
+ *
1078
+ * Here, `textInstance` is a node created by `createTextInstance`.
1079
+ */
1080
+ commitTextUpdate?(textInstance: TextInstance, oldText: string, newText: string): void;
1081
+
1082
+ /**
1083
+ * This method is only called if you returned `true` from `finalizeInitialChildren` for this instance.
1084
+ *
1085
+ * It lets you do some additional work after the node is actually attached to the tree on the screen for the first time. For example, the DOM renderer uses it to trigger focus on nodes with the `autoFocus` attribute.
1086
+ *
1087
+ * Note that `commitMount` does not mirror `removeChild` one to one because `removeChild` is only called for the top-level removed node. This is why ideally `commitMount` should not mutate any nodes other than the `instance` itself. For example, if it registers some events on some node above, it will be your responsibility to traverse the tree in `removeChild` and clean them up, which is not ideal.
1088
+ *
1089
+ * The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its internal fields, be aware that it may change significantly between versions. You're taking on additional maintenance risk by reading from it, and giving up all guarantees if you write something to it.
1090
+ *
1091
+ * If you never return `true` from `finalizeInitialChildren`, you can leave it empty.
1092
+ */
1093
+ commitMount?(instance: Instance, type: Type, props: Props, internalInstanceHandle: OpaqueHandle): void;
1094
+
1095
+ /**
1096
+ * This method should mutate the instance to match nextProps.
1097
+ *
1098
+ * The internalHandle data structure is meant to be opaque. If you bend the rules and rely on its internal fields, be aware that it may change significantly between versions. You're taking on additional maintenance risk by reading from it, and giving up all guarantees if you write something to it.
1099
+ */
1100
+ commitUpdate?(
1101
+ instance: Instance,
1102
+ type: Type,
1103
+ prevProps: Props,
1104
+ nextProps: Props,
1105
+ internalHandle: OpaqueHandle,
1106
+ ): void;
1107
+
1108
+ /**
1109
+ * This method should make the `instance` invisible without removing it from the tree. For example, it can apply visual styling to hide it. It is used by Suspense to hide the tree while the fallback is visible.
1110
+ */
1111
+ hideInstance?(instance: Instance): void;
1112
+
1113
+ /**
1114
+ * Same as `hideInstance`, but for nodes created by `createTextInstance`.
1115
+ */
1116
+ hideTextInstance?(textInstance: TextInstance): void;
1117
+
1118
+ /**
1119
+ * This method should make the `instance` visible, undoing what `hideInstance` did.
1120
+ */
1121
+ unhideInstance?(instance: Instance, props: Props): void;
1122
+
1123
+ /**
1124
+ * Same as `unhideInstance`, but for nodes created by `createTextInstance`.
1125
+ */
1126
+ unhideTextInstance?(textInstance: TextInstance, text: string): void;
1127
+
1128
+ /**
1129
+ * This method should mutate the `container` root node and remove all children from it.
1130
+ */
1131
+ clearContainer?(container: Container): void;
1132
+
1133
+ // -------------------
1134
+ // Persistence Methods
1135
+ // (optional)
1136
+ // If you use the persistent mode instead of the mutation mode, you would still need the "Core Methods". However, instead of the Mutation Methods above you will implement a different set of methods that performs cloning nodes and replacing them at the root level. You can find a list of them in the "Persistence" section [listed in this file](https://github.com/facebook/react/blob/master/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js). File an issue if you need help.
1137
+ // -------------------
1138
+ cloneInstance?(
1139
+ instance: Instance,
1140
+ type: Type,
1141
+ oldProps: Props,
1142
+ newProps: Props,
1143
+ keepChildren: boolean,
1144
+ recyclableInstance: null | Instance,
1145
+ ): Instance;
1146
+ createContainerChildSet?(container: Container): ChildSet;
1147
+ appendChildToContainerChildSet?(childSet: ChildSet, child: Instance | TextInstance): void;
1148
+ finalizeContainerChildren?(container: Container, newChildren: ChildSet): void;
1149
+ replaceContainerChildren?(container: Container, newChildren: ChildSet): void;
1150
+ cloneHiddenInstance?(
1151
+ instance: Instance,
1152
+ type: Type,
1153
+ props: Props,
1154
+ internalInstanceHandle: OpaqueHandle,
1155
+ ): Instance;
1156
+ cloneHiddenTextInstance?(instance: Instance, text: Type, internalInstanceHandle: OpaqueHandle): TextInstance;
1157
+
1158
+ // -------------------
1159
+ // Hydration Methods
1160
+ // (optional)
1161
+ // You can optionally implement hydration to "attach" to the existing tree during the initial render instead of creating it from scratch. For example, the DOM renderer uses this to attach to an HTML markup.
1162
+ //
1163
+ // To support hydration, you need to declare `supportsHydration: true` and then implement the methods in the "Hydration" section [listed in this file](https://github.com/facebook/react/blob/master/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js). File an issue if you need help.
1164
+ // -------------------
1165
+ supportsHydration: boolean;
1166
+
1167
+ canHydrateInstance?(instance: HydratableInstance, type: Type, props: Props): null | Instance;
1168
+
1169
+ canHydrateTextInstance?(instance: HydratableInstance, text: string): null | TextInstance;
1170
+
1171
+ canHydrateSuspenseInstance?(instance: HydratableInstance): null | SuspenseInstance;
1172
+
1173
+ isSuspenseInstancePending?(instance: SuspenseInstance): boolean;
1174
+
1175
+ isSuspenseInstanceFallback?(instance: SuspenseInstance): boolean;
1176
+
1177
+ registerSuspenseInstanceRetry?(instance: SuspenseInstance, callback: () => void): void;
1178
+
1179
+ getNextHydratableSibling?(instance: HydratableInstance): null | HydratableInstance;
1180
+
1181
+ getFirstHydratableChild?(parentInstance: Container | Instance): null | HydratableInstance;
1182
+
1183
+ hydrateInstance?(
1184
+ instance: Instance,
1185
+ type: Type,
1186
+ props: Props,
1187
+ rootContainerInstance: Container,
1188
+ hostContext: HostContext,
1189
+ internalInstanceHandle: any,
1190
+ ): null | any[];
1191
+
1192
+ hydrateTextInstance?(textInstance: TextInstance, text: string, internalInstanceHandle: any): boolean;
1193
+
1194
+ hydrateSuspenseInstance?(suspenseInstance: SuspenseInstance, internalInstanceHandle: any): void;
1195
+
1196
+ getNextHydratableInstanceAfterSuspenseInstance?(suspenseInstance: SuspenseInstance): null | HydratableInstance;
1197
+
1198
+ // Returns the SuspenseInstance if this node is a direct child of a
1199
+ // SuspenseInstance. I.e. if its previous sibling is a Comment with
1200
+ // SUSPENSE_x_START_DATA. Otherwise, null.
1201
+ getParentSuspenseInstance?(targetInstance: any): null | SuspenseInstance;
1202
+
1203
+ commitHydratedContainer?(container: Container): void;
1204
+
1205
+ commitHydratedSuspenseInstance?(suspenseInstance: SuspenseInstance): void;
1206
+
1207
+ didNotMatchHydratedContainerTextInstance?(
1208
+ parentContainer: Container,
1209
+ textInstance: TextInstance,
1210
+ text: string,
1211
+ ): void;
1212
+
1213
+ didNotMatchHydratedTextInstance?(
1214
+ parentType: Type,
1215
+ parentProps: Props,
1216
+ parentInstance: Instance,
1217
+ textInstance: TextInstance,
1218
+ text: string,
1219
+ ): void;
1220
+
1221
+ didNotHydrateContainerInstance?(parentContainer: Container, instance: HydratableInstance): void;
1222
+
1223
+ didNotHydrateInstance?(
1224
+ parentType: Type,
1225
+ parentProps: Props,
1226
+ parentInstance: Instance,
1227
+ instance: HydratableInstance,
1228
+ ): void;
1229
+
1230
+ didNotFindHydratableContainerInstance?(parentContainer: Container, type: Type, props: Props): void;
1231
+
1232
+ didNotFindHydratableContainerTextInstance?(parentContainer: Container, text: string): void;
1233
+
1234
+ didNotFindHydratableContainerSuspenseInstance?(parentContainer: Container): void;
1235
+
1236
+ didNotFindHydratableInstance?(
1237
+ parentType: Type,
1238
+ parentProps: Props,
1239
+ parentInstance: Instance,
1240
+ type: Type,
1241
+ props: Props,
1242
+ ): void;
1243
+
1244
+ didNotFindHydratableTextInstance?(
1245
+ parentType: Type,
1246
+ parentProps: Props,
1247
+ parentInstance: Instance,
1248
+ text: string,
1249
+ ): void;
1250
+
1251
+ didNotFindHydratableSuspenseInstance?(parentType: Type, parentProps: Props, parentInstance: Instance): void;
1252
+
1253
+ errorHydratingContainer?(parentContainer: Container): void;
1254
+
1255
+ // Undocumented
1256
+ // https://github.com/facebook/react/pull/26722
1257
+ NotPendingTransition: TransitionStatus | null;
1258
+ HostTransitionContext: ReactContext<TransitionStatus>;
1259
+
1260
+ // https://github.com/facebook/react/pull/28751
1261
+ setCurrentUpdatePriority(newPriority: EventPriority): void;
1262
+ getCurrentUpdatePriority(): EventPriority;
1263
+ resolveUpdatePriority(): EventPriority;
1264
+
1265
+ // https://github.com/facebook/react/pull/28804
1266
+ resetFormInstance(form: FormInstance): void;
1267
+
1268
+ // https://github.com/facebook/react/pull/25105
1269
+ requestPostPaintCallback(callback: (time: number) => void): void;
1270
+
1271
+ // https://github.com/facebook/react/pull/26025
1272
+ shouldAttemptEagerTransition(): boolean;
1273
+
1274
+ // https://github.com/facebook/react/pull/31528
1275
+ trackSchedulerEvent(): void;
1276
+
1277
+ // https://github.com/facebook/react/pull/31008
1278
+ resolveEventType(): null | string;
1279
+ resolveEventTimeStamp(): number;
1280
+
1281
+ /**
1282
+ * This method is called during render to determine if the Host Component type and props require some kind of loading process to complete before committing an update.
1283
+ */
1284
+ maySuspendCommit(type: Type, props: Props): boolean;
1285
+
1286
+ /**
1287
+ * This method may be called during render if the Host Component type and props might suspend a commit. It can be used to initiate any work that might shorten the duration of a suspended commit.
1288
+ */
1289
+ preloadInstance(type: Type, props: Props): boolean;
1290
+
1291
+ /**
1292
+ * This method is called just before the commit phase. Use it to set up any necessary state while any Host Components that might suspend this commit are evaluated to determine if the commit must be suspended.
1293
+ */
1294
+ startSuspendingCommit(): void;
1295
+
1296
+ /**
1297
+ * This method is called after `startSuspendingCommit` for each Host Component that indicated it might suspend a commit.
1298
+ */
1299
+ suspendInstance(type: Type, props: Props): void;
1300
+
1301
+ /**
1302
+ * This method is called after all `suspendInstance` calls are complete.
1303
+ *
1304
+ * Return `null` if the commit can happen immediately.
1305
+ *
1306
+ * Return `(initiateCommit: Function) => Function` if the commit must be suspended. The argument to this callback will initiate the commit when called. The return value is a cancellation function that the Reconciler can use to abort the commit.
1307
+ */
1308
+ waitForCommitToBeReady():
1309
+ | ((initiateCommit: (...args: unknown[]) => unknown) => (...args: unknown[]) => unknown)
1310
+ | null;
1311
+ }
1312
+
1313
+ interface Thenable<T> {
1314
+ then(resolve: () => T, reject?: () => T): T;
1315
+ }
1316
+
1317
+ type RootTag = 0 | 1 | 2;
1318
+
1319
+ type WorkTag =
1320
+ | 0
1321
+ | 1
1322
+ | 2
1323
+ | 3
1324
+ | 4
1325
+ | 5
1326
+ | 6
1327
+ | 7
1328
+ | 8
1329
+ | 9
1330
+ | 10
1331
+ | 11
1332
+ | 12
1333
+ | 13
1334
+ | 14
1335
+ | 15
1336
+ | 16
1337
+ | 17
1338
+ | 18
1339
+ | 19
1340
+ | 20
1341
+ | 21
1342
+ | 22
1343
+ | 23
1344
+ | 24;
1345
+
1346
+ type HookType =
1347
+ | "useState"
1348
+ | "useReducer"
1349
+ | "useContext"
1350
+ | "useRef"
1351
+ | "useEffect"
1352
+ | "useLayoutEffect"
1353
+ | "useCallback"
1354
+ | "useMemo"
1355
+ | "useImperativeHandle"
1356
+ | "useDebugValue"
1357
+ | "useDeferredValue"
1358
+ | "useTransition"
1359
+ | "useMutableSource"
1360
+ | "useOpaqueIdentifier"
1361
+ | "useCacheRefresh";
1362
+
1363
+ interface Source {
1364
+ fileName: string;
1365
+ lineNumber: number;
1366
+ }
1367
+
1368
+ // TODO: Ideally these types would be opaque but that doesn't work well with
1369
+ // our reconciler fork infra, since these leak into non-reconciler packages.
1370
+ type LanePriority = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17;
1371
+
1372
+ type Lanes = number;
1373
+
1374
+ type Lane = number & { __LaneBrand: any };
1375
+
1376
+ type Flags = number;
1377
+
1378
+ type TypeOfMode = number;
1379
+
1380
+ type EventPriority = number;
1381
+
1382
+ interface ReactProvider<T> {
1383
+ $$typeof: symbol | number;
1384
+ type: ReactProviderType<T>;
1385
+ key: null | string;
1386
+ ref: null;
1387
+ props: {
1388
+ value: T;
1389
+ children?: ReactNode;
1390
+ };
1391
+ }
1392
+
1393
+ interface ReactProviderType<T> {
1394
+ $$typeof: symbol | number;
1395
+ _context: ReactContext<T>;
1396
+ }
1397
+
1398
+ interface ReactConsumer<T> {
1399
+ $$typeof: symbol | number;
1400
+ type: ReactContext<T>;
1401
+ key: null | string;
1402
+ ref: null;
1403
+ props: {
1404
+ children: (value: T) => ReactNode;
1405
+ unstable_observedBits?: number;
1406
+ };
1407
+ }
1408
+
1409
+ interface ReactContext<T> {
1410
+ $$typeof: symbol | number;
1411
+ Consumer: ReactContext<T>;
1412
+ Provider: ReactProviderType<T>;
1413
+ _currentValue: T;
1414
+ _currentValue2: T;
1415
+ _threadCount: number;
1416
+ // DEV only
1417
+ _currentRenderer?: {
1418
+ [key: string]: any;
1419
+ } | null;
1420
+ _currentRenderer2?: {
1421
+ [key: string]: any;
1422
+ } | null;
1423
+ // This value may be added by application code
1424
+ // to improve DEV tooling display names
1425
+ displayName?: string;
1426
+ }
1427
+
1428
+ interface ReactPortal {
1429
+ $$typeof: symbol | number;
1430
+ key: null | string;
1431
+ containerInfo: any;
1432
+ children: ReactNode;
1433
+ // TODO: figure out the API for cross-renderer implementation.
1434
+ implementation: any;
1435
+ }
1436
+
1437
+ interface RefObject {
1438
+ current: any;
1439
+ }
1440
+
1441
+ interface ContextDependency<T> {
1442
+ context: ReactContext<T>;
1443
+ observedBits: number;
1444
+ next: ContextDependency<unknown> | null;
1445
+ }
1446
+
1447
+ interface Dependencies {
1448
+ lanes: Lanes;
1449
+ firstContext: ContextDependency<unknown> | null;
1450
+ }
1451
+
1452
+ interface Fiber {
1453
+ // These first fields are conceptually members of an Instance. This used to
1454
+ // be split into a separate type and intersected with the other Fiber fields,
1455
+ // but until Flow fixes its intersection bugs, we've merged them into a
1456
+ // single type.
1457
+
1458
+ // An Instance is shared between all versions of a component. We can easily
1459
+ // break this out into a separate object to avoid copying so much to the
1460
+ // alternate versions of the tree. We put this on a single object for now to
1461
+ // minimize the number of objects created during the initial render.
1462
+
1463
+ // Tag identifying the type of fiber.
1464
+ tag: WorkTag;
1465
+
1466
+ // Unique identifier of this child.
1467
+ key: null | string;
1468
+
1469
+ // The value of element.type which is used to preserve the identity during
1470
+ // reconciliation of this child.
1471
+ elementType: any;
1472
+
1473
+ // The resolved function/class/ associated with this fiber.
1474
+ type: any;
1475
+
1476
+ // The local state associated with this fiber.
1477
+ stateNode: any;
1478
+
1479
+ // Conceptual aliases
1480
+ // parent : Instance -> return The parent happens to be the same as the
1481
+ // return fiber since we've merged the fiber and instance.
1482
+
1483
+ // Remaining fields belong to Fiber
1484
+
1485
+ // The Fiber to return to after finishing processing this one.
1486
+ // This is effectively the parent, but there can be multiple parents (two)
1487
+ // so this is only the parent of the thing we're currently processing.
1488
+ // It is conceptually the same as the return address of a stack frame.
1489
+ return: Fiber | null;
1490
+
1491
+ // Singly Linked List Tree Structure.
1492
+ child: Fiber | null;
1493
+ sibling: Fiber | null;
1494
+ index: number;
1495
+
1496
+ // The ref last used to attach this node.
1497
+ // I'll avoid adding an owner field for prod and model that as functions.
1498
+ ref:
1499
+ | null
1500
+ | (((handle: unknown) => void) & {
1501
+ _stringRef?: string | null;
1502
+ })
1503
+ | RefObject;
1504
+
1505
+ // Input is the data coming into process this fiber. Arguments. Props.
1506
+ pendingProps: any; // This type will be more specific once we overload the tag.
1507
+ memoizedProps: any; // The props used to create the output.
1508
+
1509
+ // A queue of state updates and callbacks.
1510
+ updateQueue: unknown;
1511
+
1512
+ // The state used to create the output
1513
+ memoizedState: any;
1514
+
1515
+ // Dependencies (contexts, events) for this fiber, if it has any
1516
+ dependencies: Dependencies | null;
1517
+
1518
+ // Bitfield that describes properties about the fiber and its subtree. E.g.
1519
+ // the ConcurrentMode flag indicates whether the subtree should be async-by-
1520
+ // default. When a fiber is created, it inherits the mode of its
1521
+ // parent. Additional flags can be set at creation time, but after that the
1522
+ // value should remain unchanged throughout the fiber's lifetime, particularly
1523
+ // before its child fibers are created.
1524
+ mode: TypeOfMode;
1525
+
1526
+ // Effect
1527
+ flags: Flags;
1528
+ subtreeFlags: Flags;
1529
+ deletions: Fiber[] | null;
1530
+
1531
+ // Singly linked list fast path to the next fiber with side-effects.
1532
+ nextEffect: Fiber | null;
1533
+
1534
+ // The first and last fiber with side-effect within this subtree. This allows
1535
+ // us to reuse a slice of the linked list when we reuse the work done within
1536
+ // this fiber.
1537
+ firstEffect: Fiber | null;
1538
+ lastEffect: Fiber | null;
1539
+
1540
+ lanes: Lanes;
1541
+ childLanes: Lanes;
1542
+
1543
+ // This is a pooled version of a Fiber. Every fiber that gets updated will
1544
+ // eventually have a pair. There are cases when we can clean up pairs to save
1545
+ // memory if we need to.
1546
+ alternate: Fiber | null;
1547
+
1548
+ // Time spent rendering this Fiber and its descendants for the current update.
1549
+ // This tells us how well the tree makes use of sCU for memoization.
1550
+ // It is reset to 0 each time we render and only updated when we don't bailout.
1551
+ // This field is only set when the enableProfilerTimer flag is enabled.
1552
+ actualDuration?: number;
1553
+
1554
+ // If the Fiber is currently active in the "render" phase,
1555
+ // This marks the time at which the work began.
1556
+ // This field is only set when the enableProfilerTimer flag is enabled.
1557
+ actualStartTime?: number;
1558
+
1559
+ // Duration of the most recent render time for this Fiber.
1560
+ // This value is not updated when we bailout for memoization purposes.
1561
+ // This field is only set when the enableProfilerTimer flag is enabled.
1562
+ selfBaseDuration?: number;
1563
+
1564
+ // Sum of base times for all descendants of this Fiber.
1565
+ // This value bubbles up during the "complete" phase.
1566
+ // This field is only set when the enableProfilerTimer flag is enabled.
1567
+ treeBaseDuration?: number;
1568
+
1569
+ // Conceptual aliases
1570
+ // workInProgress : Fiber -> alternate The alternate used for reuse happens
1571
+ // to be the same as work in progress.
1572
+ // __DEV__ only
1573
+ _debugID?: number;
1574
+ _debugSource?: Source | null;
1575
+ _debugOwner?: Fiber | null;
1576
+ _debugIsCurrentlyTiming?: boolean;
1577
+ _debugNeedsRemount?: boolean;
1578
+
1579
+ // Used to verify that the order of hooks does not change between renders.
1580
+ _debugHookTypes?: HookType[] | null;
1581
+ }
1582
+
1583
+ type FiberRoot = any;
1584
+
1585
+ // Concurrent related struct
1586
+ type MutableSource = any;
1587
+
1588
+ type OpaqueHandle = any;
1589
+ type OpaqueRoot = any;
1590
+
1591
+ // 0 is PROD, 1 is DEV.
1592
+ // Might add PROFILE later.
1593
+ type BundleType = 0 | 1;
1594
+
1595
+ interface DevToolsConfig<Instance, TextInstance, RendererInspectionConfig> {
1596
+ bundleType: BundleType;
1597
+ version: string;
1598
+ rendererPackageName: string;
1599
+ // Note: this actually *does* depend on Fiber internal fields.
1600
+ // Used by "inspect clicked DOM element" in React DevTools.
1601
+ findFiberByHostInstance?: (instance: Instance | TextInstance) => Fiber | null;
1602
+ rendererConfig?: RendererInspectionConfig;
1603
+ }
1604
+
1605
+ interface SuspenseHydrationCallbacks<SuspenseInstance> {
1606
+ onHydrated?: (suspenseInstance: SuspenseInstance) => void;
1607
+ onDeleted?: (suspenseInstance: SuspenseInstance) => void;
1608
+ }
1609
+
1610
+ interface TransitionTracingCallbacks {
1611
+ onTransitionStart?: (transitionName: string, startTime: number) => void;
1612
+ onTransitionProgress?: (
1613
+ transitionName: string,
1614
+ startTime: number,
1615
+ currentTime: number,
1616
+ pending: Array<{ name: null | string }>,
1617
+ ) => void;
1618
+ onTransitionIncomplete?: (
1619
+ transitionName: string,
1620
+ startTime: number,
1621
+ deletions: Array<{
1622
+ type: string;
1623
+ name?: string;
1624
+ newName?: string;
1625
+ endTime: number;
1626
+ }>,
1627
+ ) => void;
1628
+ onTransitionComplete?: (transitionName: string, startTime: number, endTime: number) => void;
1629
+ onMarkerProgress?: (
1630
+ transitionName: string,
1631
+ marker: string,
1632
+ startTime: number,
1633
+ currentTime: number,
1634
+ pending: Array<{ name: null | string }>,
1635
+ ) => void;
1636
+ onMarkerIncomplete?: (
1637
+ transitionName: string,
1638
+ marker: string,
1639
+ startTime: number,
1640
+ deletions: Array<{
1641
+ type: string;
1642
+ name?: string;
1643
+ newName?: string;
1644
+ endTime: number;
1645
+ }>,
1646
+ ) => void;
1647
+ onMarkerComplete?: (transitionName: string, marker: string, startTime: number, endTime: number) => void;
1648
+ }
1649
+
1650
+ interface ComponentSelector {
1651
+ $$typeof: symbol | number;
1652
+ value: React$AbstractComponent<never, unknown>;
1653
+ }
1654
+
1655
+ interface HasPseudoClassSelector {
1656
+ $$typeof: symbol | number;
1657
+ value: Selector[];
1658
+ }
1659
+
1660
+ interface RoleSelector {
1661
+ $$typeof: symbol | number;
1662
+ value: string;
1663
+ }
1664
+
1665
+ interface TextSelector {
1666
+ $$typeof: symbol | number;
1667
+ value: string;
1668
+ }
1669
+
1670
+ interface TestNameSelector {
1671
+ $$typeof: symbol | number;
1672
+ value: string;
1673
+ }
1674
+
1675
+ type Selector = ComponentSelector | HasPseudoClassSelector | RoleSelector | TextSelector | TestNameSelector;
1676
+
1677
+ // TODO can not find React$AbstractComponent def
1678
+ type React$AbstractComponent<Config, Instance = any> = any;
1679
+
1680
+ interface BoundingRect {
1681
+ x: number;
1682
+ y: number;
1683
+ width: number;
1684
+ height: number;
1685
+ }
1686
+
1687
+ type IntersectionObserverOptions = any;
1688
+
1689
+ interface BaseErrorInfo {
1690
+ componentStack?: string;
1691
+ }
1692
+
1693
+ interface Reconciler<Container, Instance, TextInstance, SuspenseInstance, FormInstance, PublicInstance> {
1694
+ createContainer(
1695
+ containerInfo: Container,
1696
+ tag: RootTag,
1697
+ hydrationCallbacks: null | SuspenseHydrationCallbacks<SuspenseInstance>,
1698
+ isStrictMode: boolean,
1699
+ concurrentUpdatesByDefaultOverride: null | boolean,
1700
+ identifierPrefix: string,
1701
+ onUncaughtError: (error: Error, info: BaseErrorInfo & { errorBoundary?: Component }) => void,
1702
+ onCaughtError: (error: Error, info: BaseErrorInfo) => void,
1703
+ onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
1704
+ onDefaultTransitionIndicator: () => void,
1705
+ ): OpaqueRoot;
1706
+
1707
+ createPortal(
1708
+ children: ReactNode,
1709
+ containerInfo: any, // TODO: figure out the API for cross-renderer implementation.
1710
+ implementation: any,
1711
+ key?: string | null,
1712
+ ): ReactPortal;
1713
+
1714
+ createComponentSelector(component: React$AbstractComponent<never, unknown>): ComponentSelector;
1715
+
1716
+ createHasPseudoClassSelector(selectors: Selector[]): HasPseudoClassSelector;
1717
+
1718
+ createRoleSelector(role: string): RoleSelector;
1719
+
1720
+ createTextSelector(text: string): TextSelector;
1721
+
1722
+ createTestNameSelector(id: string): TestNameSelector;
1723
+
1724
+ getFindAllNodesFailureDescription(hostRoot: Instance, selectors: Selector[]): string | null;
1725
+
1726
+ findAllNodes(hostRoot: Instance, selectors: Selector[]): Instance[];
1727
+
1728
+ findBoundingRects(hostRoot: Instance, selectors: Selector[]): BoundingRect[];
1729
+
1730
+ focusWithin(hostRoot: Instance, selectors: Selector[]): boolean;
1731
+
1732
+ observeVisibleRects(
1733
+ hostRoot: Instance,
1734
+ selectors: Selector[],
1735
+ callback: (intersections: Array<{ ratio: number; rect: BoundingRect }>) => void,
1736
+ options?: IntersectionObserverOptions,
1737
+ ): { disconnect: () => void };
1738
+
1739
+ createHydrationContainer(
1740
+ initialChildren: ReactNode,
1741
+ callback: (() => void) | null | undefined,
1742
+ containerInfo: Container,
1743
+ tag: RootTag,
1744
+ hydrationCallbacks: null | SuspenseHydrationCallbacks<SuspenseInstance>,
1745
+ isStrictMode: boolean,
1746
+ concurrentUpdatesByDefaultOverride: null | boolean,
1747
+ identifierPrefix: string,
1748
+ onUncaughtError: (error: Error, info: BaseErrorInfo & { errorBoundary?: Component }) => void,
1749
+ onCaughtError: (error: Error, info: BaseErrorInfo) => void,
1750
+ onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
1751
+ onDefaultTransitionIndicator: () => void,
1752
+ transitionCallbacks: null | TransitionTracingCallbacks,
1753
+ formState: unknown,
1754
+ ): OpaqueRoot;
1755
+
1756
+ updateContainer(
1757
+ element: ReactNode,
1758
+ container: OpaqueRoot,
1759
+ parentComponent?: Component<any, any> | null,
1760
+ callback?: (() => void) | null,
1761
+ ): Lane;
1762
+
1763
+ updateContainerSync(
1764
+ element: ReactNode,
1765
+ container: OpaqueRoot,
1766
+ parentComponent?: Component<any, any> | null,
1767
+ callback?: (() => void) | null,
1768
+ ): Lane;
1769
+
1770
+ batchedUpdates<A, R>(fn: (a: A) => R, a: A): R;
1771
+
1772
+ deferredUpdates<A>(fn: () => A): A;
1773
+
1774
+ discreteUpdates<A, B, C, D, R>(fn: (arg0: A, arg1: B, arg2: C, arg3: D) => R, a: A, b: B, c: C, d: D): R;
1775
+
1776
+ flushSync(): void;
1777
+ flushSync<R>(fn: () => R): R;
1778
+
1779
+ flushSyncFromReconciler(): void;
1780
+ flushSyncFromReconciler<R>(fn: () => R): R;
1781
+
1782
+ flushSyncWork(): boolean;
1783
+
1784
+ isAlreadyRendering(): boolean;
1785
+
1786
+ flushPassiveEffects(): boolean;
1787
+
1788
+ getPublicRootInstance(container: OpaqueRoot): Component<any, any> | PublicInstance | null;
1789
+
1790
+ attemptSynchronousHydration(fiber: Fiber): void;
1791
+
1792
+ attemptContinuousHydration(fiber: Fiber): void;
1793
+
1794
+ attemptHydrationAtCurrentPriority(fiber: Fiber): void;
1795
+
1796
+ findHostInstance(component: any): PublicInstance | null;
1797
+
1798
+ findHostInstanceWithWarning(component: any, methodName: string): PublicInstance | null;
1799
+
1800
+ findHostInstanceWithNoPortals(fiber: Fiber): PublicInstance | null;
1801
+
1802
+ shouldError(fiber: Fiber): boolean | undefined;
1803
+
1804
+ shouldSuspend(fiber: Fiber): boolean;
1805
+
1806
+ injectIntoDevTools(devToolsConfig: DevToolsConfig<Instance, TextInstance, any>): boolean;
1807
+ }
1808
+
1809
+ function defaultOnUncaughtError(error: Error): void;
1810
+ function defaultOnCaughtError(error: Error): void;
1811
+ function defaultOnRecoverableError(error: Error): void;
1812
+
1813
+ function startHostTransition(
1814
+ formFiber: Fiber,
1815
+ pendingState: unknown,
1816
+ action: ((formData: FormData) => void) | null,
1817
+ formData: FormData,
1818
+ ): void;
1819
+ }
1820
+
1821
+ /**
1822
+ * Registers constructors so they can be rendered as JSX elements.
1823
+ *
1824
+ * - `extend({ OrbitControls })` makes each constructor available under its camelCased key
1825
+ * (`<orbitControls />`). Values that are not constructors are skipped, so a whole module
1826
+ * namespace can be passed.
1827
+ * - `extend(MyClass)` registers one constructor and returns a component to render it with.
1828
+ *
1829
+ * Registrations are global, shared by every copy and entry of fiber, and are checked before the
1830
+ * three namespace of a root's renderer when an element name is resolved.
1831
+ *
1832
+ * @example
1833
+ * import { OrbitControls } from 'three/addons/controls/OrbitControls.js'
1834
+ * extend({ OrbitControls })
1835
+ * // <orbitControls args={[camera, gl.domElement]} />
1836
+ *
1837
+ * @example
1838
+ * const Controls = extend(OrbitControls)
1839
+ * // <Controls args={[camera, gl.domElement]} />
1840
+ *
1841
+ * @see https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively
1842
+ */
1843
+ declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
1844
+ /** Registers each constructor in `objects` under its key; see the first overload. */
1845
+ declare function extend<T extends Catalogue>(objects: T): void;
1846
+ /** Registers every constructor in a module namespace, skipping other exports; see the first overload. */
1847
+ declare function extend(objects: Record<string, unknown>): void;
1848
+
1849
+ /**
1850
+ * R3F's React reconciler: a mutation-mode host config that turns JSX elements into three.js objects.
1851
+ * Each root's {@link RootStore} is its container, and children attach to `internal.container`
1852
+ * (a portal's target) or else the root's `scene`.
1853
+ *
1854
+ * - **Element names** resolve through `extend()` registrations first, then the three namespace of
1855
+ * the root's renderer. A `three` prefix (`<threeLine>`) is stripped when no element by the
1856
+ * prefixed name exists. `<primitive object={...}>` wraps an existing object.
1857
+ * - **Construction is deferred** until an instance is attached to a mounted parent, so a tree that
1858
+ * Suspense discards never creates three objects.
1859
+ * - **Updates** apply only changed props. Changing `args` (or a primitive's `object`) reconstructs
1860
+ * the object instead; the swap happens in `resetAfterCommit`, before layout effects, so refs
1861
+ * already point to the new object.
1862
+ * - **Removal** detaches the object and disposes it (at idle priority, or immediately in an `act`
1863
+ * test environment), unless it is a primitive, a `Scene`, or it or an ancestor has `dispose={null}`.
1864
+ * - **Priority**: not the primary renderer, so it runs alongside react-dom, and update priority
1865
+ * follows react-dom's event priorities. View-transition commits are flushed synchronously, since
1866
+ * three has nothing to animate between commits.
1867
+ *
1868
+ * `createRoot`, `createPortal` and `flushSync` drive it; app code rarely needs it directly.
1869
+ */
1870
+ declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
1871
+ /**
1872
+ * Force React to flush any updates inside the provided callback synchronously and immediately.
1873
+ * All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
1874
+ * Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
1875
+ * having to revert to a non-React solution. Note: this will only flush updates within the `Canvas` root.
1876
+ */
1877
+ declare function flushSync<R>(fn: () => R): R;
1878
+
1879
+ declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
1880
+ /**
1881
+ * Unmount the root on `canvas`. The teardown runs once React has committed the unmount, and waits
1882
+ * for a renderer that is still being created. `callback` runs when the root is gone: after the
1883
+ * teardown, and when it disposed a renderer R3F created whose `dispose()` is async (WebGPURenderer
1884
+ * from three r186), after that dispose has settled.
1885
+ */
1886
+ declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
1887
+
1888
+ declare function createPortal(children: ReactNode, container: THREE.Object3D | RefObject<THREE.Object3D | null> | RefObject<THREE.Object3D>, state?: InjectState): JSX.Element;
1889
+ interface PortalProps {
1890
+ children: ReactNode;
1891
+ state?: InjectState;
1892
+ container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>;
1893
+ }
1894
+ declare function Portal({ children, container, state }: PortalProps): JSX.Element;
1895
+
1896
+ /** Renderer resources: creation, shared canvas lookup, and ownership through final release. */
1897
+
1898
+ declare const isRenderer: (def: any) => boolean;
1899
+ interface PrimaryCanvasEntry {
1900
+ /** The WebGPURenderer instance owned by this primary canvas */
1901
+ renderer: WebGPURenderer;
1902
+ /** The zustand store for this canvas */
1903
+ store: RootStore;
1904
+ /** The primary's scheduler root id; a sharing canvas renders after it by default */
1905
+ rootId?: string;
1906
+ }
1907
+ /**
1908
+ * Register a primary canvas that can be targeted by secondary canvases.
1909
+ *
1910
+ * @param id - Registry key: the canvas id, or DEFAULT_PRIMARY
1911
+ * @param renderer - The WebGPURenderer owned by this canvas
1912
+ * @param store - The zustand store for this canvas
1913
+ * @param options - The owner token that announced it and its scheduler root id
1914
+ * @returns Cleanup function to unregister on unmount
1915
+ */
1916
+ declare function registerPrimary(id: string, renderer: WebGPURenderer, store: RootStore, options?: {
1917
+ token?: object;
1918
+ rootId?: string;
1919
+ }): () => void;
1920
+ /**
1921
+ * Get a registered primary canvas by id.
1922
+ *
1923
+ * @param id - The id of the primary canvas to look up
1924
+ * @returns The primary canvas entry or undefined if not found
1925
+ */
1926
+ declare function getPrimary(id: string): PrimaryCanvasEntry | undefined;
1927
+ /**
1928
+ * Wait for a primary canvas to be registered (`share="id"`).
1929
+ * Returns immediately if already registered, otherwise waits, even through a primary remounting.
1930
+ *
1931
+ * @param id - The id of the primary canvas to wait for
1932
+ * @param timeout - Optional timeout in ms (default: 5000)
1933
+ * @returns Promise that resolves with the primary canvas entry
1934
+ */
1935
+ declare function waitForPrimary(id: string, timeout?: number): Promise<PrimaryCanvasEntry>;
1936
+ /**
1937
+ * Check if a primary canvas with the given id exists.
1938
+ *
1939
+ * @param id - The id to check
1940
+ * @returns True if a primary canvas with this id is registered
1941
+ */
1942
+ declare function hasPrimary(id: string): boolean;
1943
+ /**
1944
+ * Unregister a primary canvas. Called on unmount.
1945
+ *
1946
+ * @param id - The id of the primary canvas to unregister
1947
+ */
1948
+ declare function unregisterPrimary(id: string): void;
1949
+ /**
1950
+ * Get all registered primary canvas ids. Useful for debugging.
1951
+ */
1952
+ declare function getPrimaryIds(): string[];
1953
+
1954
+ /**
1955
+ * Creates the Zustand store that holds one root's {@link RootState}.
1956
+ *
1957
+ * The store starts unconfigured: the renderer, `camera`, `scene`, `raycaster`, `frustum` and `pointer`
1958
+ * are `null` placeholders until the root's renderer support has loaded and `configure()` in
1959
+ * `configuration.ts` fills them in. Only core's part of `RootState` is created here; packages building on
1960
+ * fiber add their own fields through root extensions.
1961
+ *
1962
+ * Besides the initial state, the store wires up:
1963
+ * - `state.gl` and `state.renderer` as accessors over `internal.actualRenderer`. `gl` reports a
1964
+ * deprecation when user code reads it outside legacy mode.
1965
+ * - `rootScene` following `scene` whenever `scene` is set to a real `THREE.Scene`.
1966
+ * - On a size or DPR change: updating the camera and resizing the root's own canvas target (or the
1967
+ * renderer when there is none).
1968
+ * - On a camera change: adding an unparented camera to `rootScene`, then refreshing the viewport and
1969
+ * (when `autoUpdateFrustum` is set) the frustum.
1970
+ * - Calling `invalidate(state)` after every state change.
1971
+ *
1972
+ * `createRoot` calls this once per canvas.
1973
+ *
1974
+ * @param invalidate - Requests frames for a root. Bound into `state.invalidate` and called on every store change.
1975
+ * @param advance - Steps a root manually. Bound into `state.advance`.
1976
+ * @returns The root's store, which is also the reconciler container for that root.
1977
+ */
1978
+ declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
1979
+
1980
+ /** Whether any root has loaded a renderer yet. */
1981
+ declare function hasThree(): boolean;
1982
+ /**
1983
+ * Three's shared core: the classes and constants `three` and `three/webgpu` have in common.
1984
+ * Available once the first root's renderer support is loaded (during `configure()`), which is
1985
+ * before any element renders, any hook runs, or `onCreated` fires.
1986
+ */
1987
+ declare function getThree(): ThreeCore;
1988
+ /** Resolves with three's shared core as soon as a root has loaded one. */
1989
+ declare function whenThree(): Promise<ThreeCore>;
1990
+
1991
+ /**
1992
+ * An SSR-friendly useLayoutEffect.
1993
+ *
1994
+ * React currently throws a warning when using useLayoutEffect on the server.
1995
+ * To get around it, we can conditionally useEffect on the server (no-op) and
1996
+ * useLayoutEffect elsewhere.
1997
+ *
1998
+ * @see https://github.com/facebook/react/issues/14927
1999
+ */
2000
+ declare const useIsomorphicLayoutEffect: typeof React$1.useLayoutEffect;
2001
+ /**
2002
+ * Creates a stable ref that always contains the latest callback.
2003
+ * Useful for avoiding dependency arrays while ensuring the latest closure is called.
2004
+ *
2005
+ * @param fn - The callback function to wrap
2006
+ * @returns A ref containing the current callback
2007
+ */
2008
+ declare function useMutableCallback<T>(fn: T): React$1.RefObject<T>;
2009
+ /**
2010
+ * Bridges renderer Context, StrictMode, and Activity visibility from a primary renderer.
2011
+ * Used to maintain React context when rendering into portals or secondary canvases.
2012
+ *
2013
+ * @returns A Bridge component that wraps children with the parent renderer's context
2014
+ */
2015
+ declare function useBridge(): Bridge;
2016
+ /**
2017
+ * Internal component that blocks rendering until a promise resolves.
2018
+ * Used for suspense-like blocking behavior.
2019
+ *
2020
+ * @param set - Function to set the blocking promise
2021
+ */
2022
+ declare function Block({ set }: Omit<UnblockProps, 'children'>): null;
2023
+ /**
2024
+ * Error boundary component for catching and handling errors in the React tree.
2025
+ * Forwards errors to a state setter for external handling.
2026
+ *
2027
+ * NOTE: static members get down-level transpiled to mutations which break tree-shaking
2028
+ */
2029
+ declare const ErrorBoundary: {
2030
+ new (props: {
2031
+ set: React$1.Dispatch<Error | undefined>;
2032
+ children: React$1.ReactNode;
2033
+ }): {
2034
+ state: {
2035
+ error: boolean;
2036
+ };
2037
+ componentDidCatch(err: Error): void;
2038
+ render(): React$1.ReactNode;
2039
+ context: unknown;
2040
+ setState<K extends "error">(state: {
2041
+ error: boolean;
2042
+ } | ((prevState: Readonly<{
2043
+ error: boolean;
2044
+ }>, props: Readonly<{
2045
+ set: React$1.Dispatch<Error | undefined>;
2046
+ children: React$1.ReactNode;
2047
+ }>) => {
2048
+ error: boolean;
2049
+ } | Pick<{
2050
+ error: boolean;
2051
+ }, K> | null) | Pick<{
2052
+ error: boolean;
2053
+ }, K> | null, callback?: (() => void) | undefined): void;
2054
+ forceUpdate(callback?: (() => void) | undefined): void;
2055
+ readonly props: Readonly<{
2056
+ set: React$1.Dispatch<Error | undefined>;
2057
+ children: React$1.ReactNode;
2058
+ }>;
2059
+ componentDidMount?(): void;
2060
+ shouldComponentUpdate?(nextProps: Readonly<{
2061
+ set: React$1.Dispatch<Error | undefined>;
2062
+ children: React$1.ReactNode;
2063
+ }>, nextState: Readonly<{
2064
+ error: boolean;
2065
+ }>, nextContext: any): boolean;
2066
+ componentWillUnmount?(): void;
2067
+ getSnapshotBeforeUpdate?(prevProps: Readonly<{
2068
+ set: React$1.Dispatch<Error | undefined>;
2069
+ children: React$1.ReactNode;
2070
+ }>, prevState: Readonly<{
2071
+ error: boolean;
2072
+ }>): any;
2073
+ componentDidUpdate?(prevProps: Readonly<{
2074
+ set: React$1.Dispatch<Error | undefined>;
2075
+ children: React$1.ReactNode;
2076
+ }>, prevState: Readonly<{
2077
+ error: boolean;
2078
+ }>, snapshot?: any): void;
2079
+ componentWillMount?(): void;
2080
+ UNSAFE_componentWillMount?(): void;
2081
+ componentWillReceiveProps?(nextProps: Readonly<{
2082
+ set: React$1.Dispatch<Error | undefined>;
2083
+ children: React$1.ReactNode;
2084
+ }>, nextContext: any): void;
2085
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{
2086
+ set: React$1.Dispatch<Error | undefined>;
2087
+ children: React$1.ReactNode;
2088
+ }>, nextContext: any): void;
2089
+ componentWillUpdate?(nextProps: Readonly<{
2090
+ set: React$1.Dispatch<Error | undefined>;
2091
+ children: React$1.ReactNode;
2092
+ }>, nextState: Readonly<{
2093
+ error: boolean;
2094
+ }>, nextContext: any): void;
2095
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<{
2096
+ set: React$1.Dispatch<Error | undefined>;
2097
+ children: React$1.ReactNode;
2098
+ }>, nextState: Readonly<{
2099
+ error: boolean;
2100
+ }>, nextContext: any): void;
2101
+ };
2102
+ new (props: {
2103
+ set: React$1.Dispatch<Error | undefined>;
2104
+ children: React$1.ReactNode;
2105
+ }, context: any): {
2106
+ state: {
2107
+ error: boolean;
2108
+ };
2109
+ componentDidCatch(err: Error): void;
2110
+ render(): React$1.ReactNode;
2111
+ context: unknown;
2112
+ setState<K extends "error">(state: {
2113
+ error: boolean;
2114
+ } | ((prevState: Readonly<{
2115
+ error: boolean;
2116
+ }>, props: Readonly<{
2117
+ set: React$1.Dispatch<Error | undefined>;
2118
+ children: React$1.ReactNode;
2119
+ }>) => {
2120
+ error: boolean;
2121
+ } | Pick<{
2122
+ error: boolean;
2123
+ }, K> | null) | Pick<{
2124
+ error: boolean;
2125
+ }, K> | null, callback?: (() => void) | undefined): void;
2126
+ forceUpdate(callback?: (() => void) | undefined): void;
2127
+ readonly props: Readonly<{
2128
+ set: React$1.Dispatch<Error | undefined>;
2129
+ children: React$1.ReactNode;
2130
+ }>;
2131
+ componentDidMount?(): void;
2132
+ shouldComponentUpdate?(nextProps: Readonly<{
2133
+ set: React$1.Dispatch<Error | undefined>;
2134
+ children: React$1.ReactNode;
2135
+ }>, nextState: Readonly<{
2136
+ error: boolean;
2137
+ }>, nextContext: any): boolean;
2138
+ componentWillUnmount?(): void;
2139
+ getSnapshotBeforeUpdate?(prevProps: Readonly<{
2140
+ set: React$1.Dispatch<Error | undefined>;
2141
+ children: React$1.ReactNode;
2142
+ }>, prevState: Readonly<{
2143
+ error: boolean;
2144
+ }>): any;
2145
+ componentDidUpdate?(prevProps: Readonly<{
2146
+ set: React$1.Dispatch<Error | undefined>;
2147
+ children: React$1.ReactNode;
2148
+ }>, prevState: Readonly<{
2149
+ error: boolean;
2150
+ }>, snapshot?: any): void;
2151
+ componentWillMount?(): void;
2152
+ UNSAFE_componentWillMount?(): void;
2153
+ componentWillReceiveProps?(nextProps: Readonly<{
2154
+ set: React$1.Dispatch<Error | undefined>;
2155
+ children: React$1.ReactNode;
2156
+ }>, nextContext: any): void;
2157
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{
2158
+ set: React$1.Dispatch<Error | undefined>;
2159
+ children: React$1.ReactNode;
2160
+ }>, nextContext: any): void;
2161
+ componentWillUpdate?(nextProps: Readonly<{
2162
+ set: React$1.Dispatch<Error | undefined>;
2163
+ children: React$1.ReactNode;
2164
+ }>, nextState: Readonly<{
2165
+ error: boolean;
2166
+ }>, nextContext: any): void;
2167
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<{
2168
+ set: React$1.Dispatch<Error | undefined>;
2169
+ children: React$1.ReactNode;
2170
+ }>, nextState: Readonly<{
2171
+ error: boolean;
2172
+ }>, nextContext: any): void;
2173
+ };
2174
+ getDerivedStateFromError: () => {
2175
+ error: boolean;
2176
+ };
2177
+ contextType?: React$1.Context<any> | undefined;
2178
+ propTypes?: any;
2179
+ };
2180
+
2181
+ /**
2182
+ * React internal props that should not be passed to Three.js objects.
2183
+ */
2184
+ declare const REACT_INTERNAL_PROPS: string[];
2185
+ /**
2186
+ * Returns the instance's initial (outermost) root.
2187
+ * Traverses through previousRoot links to find the original root store.
2188
+ *
2189
+ * @param instance - R3F instance to find root for
2190
+ * @returns The outermost root store
2191
+ */
2192
+ declare function findInitialRoot<T>(instance: Instance<T>): RootStore;
2193
+ /**
2194
+ * Returns instance root state.
2195
+ * If the object doesn't have __r3f (e.g., child meshes in primitives/GLTFs),
2196
+ * traverses ancestors to find the nearest managed parent.
2197
+ *
2198
+ * @param obj - Three.js object to get root state for
2199
+ * @returns Root state if found, undefined otherwise
2200
+ */
2201
+ declare function getRootState<T extends THREE.Object3D = THREE.Object3D>(obj: T): RootState | undefined;
2202
+ /**
2203
+ * Collects nodes, materials, and meshes from a Three.js Object3D hierarchy.
2204
+ * Handles duplicate material names by appending UUID prefixes.
2205
+ *
2206
+ * @param object - Root object to traverse
2207
+ * @returns ObjectMap containing named nodes, materials, and meshes
2208
+ *
2209
+ * @example
2210
+ * const { nodes, materials, meshes } = buildGraph(gltf.scene)
2211
+ * // Access by name: nodes.Head, materials.Metal, meshes.Body
2212
+ */
2213
+ declare function buildGraph(object: THREE.Object3D): ObjectMap;
2214
+ /**
2215
+ * Disposes an object and all its disposable properties.
2216
+ * Skips Scene objects as they should not be disposed automatically.
2217
+ *
2218
+ * @param obj - Object to dispose
2219
+ */
2220
+ declare function dispose<T extends Disposable>(obj: T): void;
2221
+ /**
2222
+ * Extracts instance props from React reconciler fiber props.
2223
+ * Filters out React-internal props (children, key, ref).
2224
+ *
2225
+ * @param queue - Pending props from reconciler fiber
2226
+ * @returns Props object without React-internal keys
2227
+ */
2228
+ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>): Instance<T>['props'];
2229
+ /**
2230
+ * Creates or retrieves an R3F instance descriptor for a Three.js object.
2231
+ * Each object in the scene carries a LocalState descriptor (__r3f).
2232
+ *
2233
+ * @param target - Target object to prepare
2234
+ * @param root - Root store for this instance
2235
+ * @param type - String identifier for the object type
2236
+ * @param props - Initial props for the instance
2237
+ * @returns Instance descriptor
2238
+ */
2239
+ declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
2240
+ /**
2241
+ * Triggers an update for an instance.
2242
+ * Invalidates the frame if the root is in demand mode.
2243
+ *
2244
+ * @param instance - Instance to invalidate
2245
+ */
2246
+ declare function invalidateInstance(instance: Instance): void;
2247
+
2248
+ /**
2249
+ * Reserved prop names that should not be applied to Three.js objects.
2250
+ */
2251
+ declare const RESERVED_PROPS: string[];
2252
+ /**
2253
+ * Resolves a potentially pierced property key (e.g., 'material-color' → material.color).
2254
+ * First tries the entire key as a single property, then attempts piercing.
2255
+ *
2256
+ * @param root - Root object to resolve from
2257
+ * @param key - Property key (may contain dashes for piercing)
2258
+ * @returns Object containing root, key, and target value
2259
+ *
2260
+ * @example
2261
+ * resolve(mesh, 'material-color')
2262
+ * // => { root: mesh.material, key: 'color', target: mesh.material.color }
2263
+ */
2264
+ declare function resolve(root: any, key: string): {
2265
+ root: any;
2266
+ key: string;
2267
+ target: any;
2268
+ };
2269
+ /**
2270
+ * Attaches a child instance to a parent instance.
2271
+ * Handles both string-based attachment (e.g., 'geometry', 'material-map')
2272
+ * and function-based attachment for custom logic.
2273
+ *
2274
+ * @param parent - Parent instance
2275
+ * @param child - Child instance to attach
2276
+ *
2277
+ * @example
2278
+ * // String attachment
2279
+ * <bufferGeometry attach="geometry" />
2280
+ * // Array attachment
2281
+ * <light attach="lights-0" />
2282
+ * // Function attachment
2283
+ * <thing attach={(parent, self) => { parent.customProp = self }} />
2284
+ */
2285
+ declare function attach(parent: Instance, child: Instance): void;
2286
+ /**
2287
+ * Detaches a child instance from a parent instance.
2288
+ * Restores the previous value or deletes the property if it was never set.
2289
+ *
2290
+ * @param parent - Parent instance
2291
+ * @param child - Child instance to detach
2292
+ */
2293
+ declare function detach(parent: Instance, child: Instance): void;
2294
+ /**
2295
+ * Compares old and new props to determine which properties have changed.
2296
+ * Also handles resetting removed props for HMR/fast-refresh.
2297
+ *
2298
+ * @param instance - Instance to diff props for
2299
+ * @param newProps - New props to compare against
2300
+ * @returns Object containing only changed props
2301
+ *
2302
+ * @example
2303
+ * const changes = diffProps(instance, { position: [1, 2, 3], color: 'red' })
2304
+ * // => { position: [1, 2, 3] } (only if position changed)
2305
+ */
2306
+ declare function diffProps<T = any>(instance: Instance<T>, newProps: Instance<T>['props']): Instance<T>['props'];
2307
+ /**
2308
+ * Applies a set of props to a Three.js object.
2309
+ * Handles special cases like colors, vectors, textures, events, and pierced props.
2310
+ *
2311
+ * @param object - Three.js object to apply props to
2312
+ * @param props - Props to apply
2313
+ * @returns The object with props applied
2314
+ *
2315
+ * @example
2316
+ * applyProps(mesh, { position: [0, 1, 0], 'material-color': 'red' })
2317
+ */
2318
+ declare function applyProps<T = any>(object: Instance<T>['object'], props: Instance<T>['props']): Instance<T>['object'];
2319
+
2320
+ /**
2321
+ * Calculates the device pixel ratio for rendering.
2322
+ * Handles array DPR ranges [min, max] to clamp devicePixelRatio.
2323
+ *
2324
+ * @param dpr - Target DPR value or [min, max] range
2325
+ * @returns Calculated DPR value
2326
+ *
2327
+ * @example
2328
+ * calculateDpr(2) // => 2
2329
+ * calculateDpr([1, 2]) // => clamps window.devicePixelRatio between 1 and 2
2330
+ */
2331
+ declare function calculateDpr(dpr: Dpr): number;
2332
+ /**
2333
+ * Extracts the first segment of a UUID string (before the first hyphen).
2334
+ * Used for creating unique material names when duplicates exist.
2335
+ *
2336
+ * @param uuid - UUID string to extract prefix from
2337
+ * @returns First segment of the UUID
2338
+ *
2339
+ * @example
2340
+ * getUuidPrefix('a1b2c3d4-e5f6-g7h8-i9j0') // => 'a1b2c3d4'
2341
+ */
2342
+ declare function getUuidPrefix(uuid: string): string;
2343
+ /**
2344
+ * Updates camera projection based on viewport size.
2345
+ * Adjusts aspect ratio for perspective cameras or bounds for orthographic cameras.
2346
+ * Respects camera.manual flag - manual cameras are not modified.
2347
+ *
2348
+ * @param camera - Camera to update
2349
+ * @param size - Current viewport size
2350
+ */
2351
+ declare function updateCamera(camera: ThreeCamera, size: Size): void;
2352
+ /**
2353
+ * Updates a frustum from a camera's projection and world matrices.
2354
+ * If no target frustum is provided, creates and returns a new one.
2355
+ *
2356
+ * @param camera - Camera to extract frustum from
2357
+ * @param frustum - Optional existing frustum to update (creates new if not provided)
2358
+ * @returns The updated or newly created frustum
2359
+ *
2360
+ * @example
2361
+ * // Create new frustum
2362
+ * const frustum = updateFrustum(camera)
2363
+ *
2364
+ * // Update existing frustum (no allocation)
2365
+ * updateFrustum(camera, existingFrustum)
2366
+ *
2367
+ * // Use for visibility checks
2368
+ * if (frustum.containsPoint(point)) { ... }
2369
+ * if (frustum.intersectsObject(mesh)) { ... }
2370
+ */
2371
+ declare function updateFrustum(camera: ThreeCamera, frustum?: THREE.Frustum): THREE.Frustum;
2372
+
2373
+ declare const is: {
2374
+ obj: (a: any) => boolean;
2375
+ fun: (a: any) => a is Function;
2376
+ str: (a: any) => a is string;
2377
+ num: (a: any) => a is number;
2378
+ boo: (a: any) => a is boolean;
2379
+ und: (a: any) => boolean;
2380
+ nul: (a: any) => boolean;
2381
+ arr: (a: any) => a is any[];
2382
+ equ(a: any, b: any, { arrays, objects, strict }?: EquConfig): boolean;
2383
+ };
2384
+ declare const isOrthographicCamera: (def: ThreeCamera) => def is THREE.OrthographicCamera;
2385
+ declare const isRef: (obj: unknown) => obj is React.RefObject<unknown>;
2386
+ declare const isColorRepresentation: (value: unknown) => value is THREE.ColorRepresentation;
2387
+ declare const isObject3D: (object: any) => object is THREE.Object3D;
2388
+ declare const isTexture: (value: unknown) => value is THREE.Texture;
2389
+ declare const isLayers: (value: unknown) => value is THREE.Layers;
2390
+ declare const isUniform: (value: unknown) => value is THREE.Uniform;
2391
+ type VectorLike = {
2392
+ set: (...args: any[]) => void;
2393
+ constructor?: Function;
2394
+ };
2395
+ declare const isVectorLike: (object: unknown) => object is VectorLike;
2396
+ type Copyable = {
2397
+ copy: (...args: any[]) => void;
2398
+ constructor?: Function;
2399
+ };
2400
+ declare const isCopyable: (object: unknown) => object is Copyable;
2401
+ declare const hasConstructor: (object: unknown) => object is {
2402
+ constructor?: Function;
2403
+ };
2404
+
2405
+ /**
2406
+ * Symbol marker for deferred ref resolution.
2407
+ * Used to identify values that should be resolved from refs after mount.
2408
+ */
2409
+ declare const FROM_REF: unique symbol;
2410
+ /** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
2411
+ interface FromRefMarker<T = unknown, R = T> {
2412
+ [FROM_REF]: React$1.RefObject<T | null>;
2413
+ /** Optional transform applied to the resolved ref before assignment. */
2414
+ transform?: (value: T) => R;
2415
+ }
2416
+ /**
2417
+ * Defers prop application until the referenced object is available.
2418
+ * Useful for props like `target` that need sibling refs to be populated.
2419
+ *
2420
+ * Only top-level props on a three element are resolved: a marker nested inside another value
2421
+ * (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
2422
+ * than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
2423
+ * what gets assigned.
2424
+ *
2425
+ * @param ref - React ref object to resolve at mount time
2426
+ * @param transform - Optional mapping from the resolved object to the value the prop expects
2427
+ * @returns A marker value that the reconciler resolves after mount
2428
+ *
2429
+ * @example
2430
+ * const targetRef = useRef<THREE.Object3D>(null)
2431
+ *
2432
+ * <group ref={targetRef} position={[-3, -2, -15]} />
2433
+ * <spotLight target={fromRef(targetRef)} intensity={100} />
2434
+ *
2435
+ * @example
2436
+ * // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
2437
+ * <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
2438
+ */
2439
+ declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
2440
+ declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
2441
+ /**
2442
+ * Type guard to check if a value is a fromRef marker.
2443
+ *
2444
+ * @param value - Value to check
2445
+ * @returns True if value is a fromRef marker
2446
+ */
2447
+ declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
2448
+
2449
+ /**
2450
+ * Symbol marker for mount-only method calls.
2451
+ * Used to identify methods that should only be called once on initial mount.
2452
+ */
2453
+ declare const ONCE: unique symbol;
2454
+ /**
2455
+ * Marks a method call to be executed only on initial mount.
2456
+ * Useful for geometry transforms that should not be reapplied on every render.
2457
+ *
2458
+ * When `args` prop changes (triggering reconstruction), the method will be
2459
+ * called again on the new instance since appliedOnce is not carried over.
2460
+ *
2461
+ * @param args - Arguments to pass to the method
2462
+ * @returns A marker value that applyProps will execute once
2463
+ *
2464
+ * @example
2465
+ * // Rotate geometry on mount
2466
+ * <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
2467
+ *
2468
+ * // Multiple arguments
2469
+ * <bufferGeometry applyMatrix4={once(matrix)} />
2470
+ *
2471
+ * // No arguments
2472
+ * <geometry center={once()} />
2473
+ */
2474
+ declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
2475
+ /**
2476
+ * What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
2477
+ * the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
2478
+ * methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
2479
+ *
2480
+ * The runtime value is always the marker object; only the declared type follows the prop.
2481
+ */
2482
+ type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
2483
+ /**
2484
+ * Type guard to check if a value is a once marker.
2485
+ *
2486
+ * @param value - Value to check
2487
+ * @returns True if value is a once marker
2488
+ */
2489
+ declare function isOnce(value: unknown): value is {
2490
+ [ONCE]: any[] | true;
2491
+ };
2492
+
2493
+ export { useTexture as $, EnvironmentMap as H, EnvironmentCube as J, EnvironmentPortal as K, Environment as M, presetsObj as N, swapInteractivity as Q, removeInteractivity as S, createEvents as T, useInstanceHandle as U, useGraph as V, useLoader as X, IsObject as Y, addEffect as a, Texture as a0, useTextures as a5, useEnvironment as a7, extend as a8, reconciler as a9, diffProps as aA, applyProps as aB, is as aC, isOrthographicCamera as aD, isRef as aE, isColorRepresentation as aF, isObject3D as aG, isTexture as aH, isLayers as aI, isUniform as aJ, isVectorLike as aK, isCopyable as aL, hasConstructor as aM, FROM_REF as aN, fromRef as aP, isFromRef as aQ, ONCE as aR, once as aS, isOnce as aU, flushSync as aa, _roots as ab, unmountComponentAtNode as ac, createPortal as ad, Portal as ae, useIsomorphicLayoutEffect as af, useMutableCallback as ag, useBridge as ah, Block as ai, ErrorBoundary as aj, calculateDpr as ak, getUuidPrefix as al, updateCamera as am, updateFrustum as an, REACT_INTERNAL_PROPS as ao, findInitialRoot as ap, getRootState as aq, buildGraph as ar, dispose as as, getInstanceProps as at, prepare as au, invalidateInstance as av, RESERVED_PROPS as aw, resolve as ax, attach as ay, detach as az, addAfterEffect as b, createPointerEvents as c, addTail as d, advance as e, isRenderer as f, getPrimary as g, hasPrimary as h, invalidate as i, getPrimaryIds as j, createStore as k, getThree as l, hasThree as m, whenThree as n, registerPrimary as r, unregisterPrimary as u, waitForPrimary as w };
2494
+ export type { LegacyInternalState as A, BackgroundConfig as B, CanvasProps as C, LegacyRootState as D, Extensions as E, EnvironmentProps as F, GlobalRenderCallback as G, InputLike as I, LoaderLike as L, PresetsType as O, PrimaryCanvasEntry as P, RenderTargetOptions as R, WebGLDefaultProps as W, MappedTextureType as Z, UseTextureOptions as _, TextureInput as a1, TextureResult as a2, DisposeOptions as a3, UseTexturesReturn as a4, EnvironmentLoaderProps as a6, FromRefMarker as aO, OnceValue as aT, GlobalEffectType as o, BackgroundProp as p, GLTFLike as q, LoaderInstance as s, InferLoadResult as t, LoaderResult as v, WebGLProps as x, WebGLShadowConfig as y, LegacyRenderer as z };