@react-three/fiber 10.0.0-alpha.5 → 10.0.0-canary.04087d8

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