@react-three/fiber 9.4.2 → 10.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.cjs +14832 -0
  3. package/dist/index.d.cts +3350 -0
  4. package/dist/index.d.mts +3350 -0
  5. package/dist/index.d.ts +3350 -0
  6. package/dist/index.mjs +14747 -0
  7. package/dist/legacy.cjs +14820 -0
  8. package/dist/legacy.d.cts +3347 -0
  9. package/dist/legacy.d.mts +3347 -0
  10. package/dist/legacy.d.ts +3347 -0
  11. package/dist/legacy.mjs +14735 -0
  12. package/dist/webgpu/index.cjs +15274 -0
  13. package/dist/webgpu/index.d.cts +3470 -0
  14. package/dist/webgpu/index.d.mts +3470 -0
  15. package/dist/webgpu/index.d.ts +3470 -0
  16. package/dist/webgpu/index.mjs +15177 -0
  17. package/package.json +44 -44
  18. package/react-reconciler/constants.d.ts +7 -0
  19. package/react-reconciler/constants.js +9 -0
  20. package/react-reconciler/index.d.ts +1044 -0
  21. package/react-reconciler/index.js +224 -0
  22. package/readme.md +98 -33
  23. package/CHANGELOG.md +0 -1186
  24. package/dist/declarations/src/core/events.d.ts +0 -92
  25. package/dist/declarations/src/core/hooks.d.ts +0 -53
  26. package/dist/declarations/src/core/index.d.ts +0 -13
  27. package/dist/declarations/src/core/loop.d.ts +0 -31
  28. package/dist/declarations/src/core/reconciler.d.ts +0 -50
  29. package/dist/declarations/src/core/renderer.d.ts +0 -89
  30. package/dist/declarations/src/core/store.d.ts +0 -130
  31. package/dist/declarations/src/core/utils.d.ts +0 -191
  32. package/dist/declarations/src/index.d.ts +0 -6
  33. package/dist/declarations/src/native/Canvas.d.ts +0 -13
  34. package/dist/declarations/src/native/events.d.ts +0 -4
  35. package/dist/declarations/src/native.d.ts +0 -6
  36. package/dist/declarations/src/three-types.d.ts +0 -68
  37. package/dist/declarations/src/web/Canvas.d.ts +0 -23
  38. package/dist/declarations/src/web/events.d.ts +0 -4
  39. package/dist/events-1eccaf1c.esm.js +0 -2510
  40. package/dist/events-5c8d1731.cjs.prod.js +0 -2569
  41. package/dist/events-c80effae.cjs.dev.js +0 -2569
  42. package/dist/react-three-fiber.cjs.d.ts +0 -2
  43. package/dist/react-three-fiber.cjs.dev.js +0 -222
  44. package/dist/react-three-fiber.cjs.js +0 -7
  45. package/dist/react-three-fiber.cjs.prod.js +0 -222
  46. package/dist/react-three-fiber.esm.js +0 -167
  47. package/native/dist/react-three-fiber-native.cjs.d.ts +0 -2
  48. package/native/dist/react-three-fiber-native.cjs.dev.js +0 -569
  49. package/native/dist/react-three-fiber-native.cjs.js +0 -7
  50. package/native/dist/react-three-fiber-native.cjs.prod.js +0 -569
  51. package/native/dist/react-three-fiber-native.esm.js +0 -517
  52. package/native/package.json +0 -5
@@ -0,0 +1,3347 @@
1
+ import * as THREE$1 from 'three';
2
+ import { Color as Color$1, ColorRepresentation, Euler as Euler$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Quaternion as Quaternion$1, Matrix3 as Matrix3$1, Matrix4 as Matrix4$1, Object3D, Texture as Texture$1, OrthographicCamera } from 'three';
3
+ import * as React$1 from 'react';
4
+ import { ReactNode, Component, RefObject, JSX } from 'react';
5
+ import { StoreApi } from 'zustand';
6
+ import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
7
+ import * as react_reconciler from 'C:\\dev\\react-three-fiber\\node_modules\\.pnpm\\@types+react-reconciler@0.32.3_@types+react@19.2.7\\node_modules\\@types\\react-reconciler\\index.d.ts';
8
+ import * as three_webgpu from 'three/webgpu';
9
+ import { Node, ShaderNodeObject } from 'three/webgpu';
10
+ import { Options } from 'react-use-measure';
11
+ import * as react_jsx_runtime from 'react/jsx-runtime';
12
+
13
+ function _mergeNamespaces(n, m) {
14
+ m.forEach(function (e) {
15
+ e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
16
+ if (k !== 'default' && !(k in n)) {
17
+ var d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: function () { return e[k]; }
21
+ });
22
+ }
23
+ });
24
+ });
25
+ return Object.freeze(n);
26
+ }
27
+
28
+ /**
29
+ * @fileoverview Internal Three.js re-exports - LEGACY ENTRY
30
+ *
31
+ * Pure WebGL path - no WebGPU imports.
32
+ * Use this for the legacy import path: @react-three/fiber/legacy
33
+ *
34
+ * This keeps bundle size minimal for apps that don't need WebGPU.
35
+ */
36
+ declare const R3F_BUILD_LEGACY = true;
37
+ declare const R3F_BUILD_WEBGPU = false;
38
+
39
+ declare const Inspector: {
40
+ new (): {};
41
+ };
42
+ declare const WebGPURenderer: {
43
+ new (): {};
44
+ };
45
+
46
+ var THREE = /*#__PURE__*/_mergeNamespaces({
47
+ __proto__: null,
48
+ Inspector: Inspector,
49
+ R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
50
+ R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
51
+ WebGPURenderer: WebGPURenderer
52
+ }, [THREE$1]);
53
+
54
+ //* Utility Types ==============================
55
+
56
+ type NonFunctionKeys<P> = { [K in keyof P]-?: P[K] extends Function ? never : K }[keyof P]
57
+ type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O
58
+ type Properties<T> = Pick<T, NonFunctionKeys<T>>
59
+ type Mutable<P> = { [K in keyof P]: P[K] | Readonly<P[K]> }
60
+ type IsOptional<T> = undefined extends T ? true : false
61
+ type IsAllOptional<T extends any[]> = T extends [infer First, ...infer Rest]
62
+ ? IsOptional<First> extends true
63
+ ? IsAllOptional<Rest>
64
+ : false
65
+ : true
66
+
67
+ //* Camera Types ==============================
68
+
69
+ type ThreeCamera = (THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera) & { manual?: boolean }
70
+
71
+ //* Act Type ==============================
72
+
73
+ type Act = <T = any>(cb: () => Promise<T>) => Promise<T>
74
+
75
+ //* Bridge & Block Types ==============================
76
+
77
+ type Bridge = React$1.FC<{ children?: React$1.ReactNode }>
78
+
79
+ type SetBlock = false | Promise<null> | null
80
+ type UnblockProps = { set: React$1.Dispatch<React$1.SetStateAction<SetBlock>>; children: React$1.ReactNode }
81
+
82
+ //* Object Map Type ==============================
83
+
84
+ interface ObjectMap {
85
+ nodes: { [name: string]: THREE$1.Object3D }
86
+ materials: { [name: string]: THREE$1.Material }
87
+ meshes: { [name: string]: THREE$1.Mesh }
88
+ }
89
+
90
+ //* Equality Config ==============================
91
+
92
+ interface EquConfig {
93
+ /** Compare arrays by reference equality a === b (default), or by shallow equality */
94
+ arrays?: 'reference' | 'shallow'
95
+ /** Compare objects by reference equality a === b (default), or by shallow equality */
96
+ objects?: 'reference' | 'shallow'
97
+ /** If true the keys in both a and b must match 1:1 (default), if false a's keys must intersect b's */
98
+ strict?: boolean
99
+ }
100
+
101
+ //* Disposable Type ==============================
102
+
103
+ interface Disposable {
104
+ type?: string
105
+ dispose?: () => void
106
+ }
107
+
108
+ //* Event-related Types =====================================
109
+
110
+ interface Intersection extends THREE$1.Intersection {
111
+ /** The event source (the object which registered the handler) */
112
+ eventObject: THREE$1.Object3D
113
+ }
114
+
115
+ type Camera = THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera
116
+
117
+ interface IntersectionEvent<TSourceEvent> extends Intersection {
118
+ /** The event source (the object which registered the handler) */
119
+ eventObject: THREE$1.Object3D
120
+ /** An array of intersections */
121
+ intersections: Intersection[]
122
+ /** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
123
+ unprojectedPoint: THREE$1.Vector3
124
+ /** Normalized event coordinates */
125
+ pointer: THREE$1.Vector2
126
+ /** Delta between first click and this event */
127
+ delta: number
128
+ /** The ray that pierced it */
129
+ ray: THREE$1.Ray
130
+ /** The camera that was used by the raycaster */
131
+ camera: Camera
132
+ /** stopPropagation will stop underlying handlers from firing */
133
+ stopPropagation: () => void
134
+ /** The original host event */
135
+ nativeEvent: TSourceEvent
136
+ /** If the event was stopped by calling stopPropagation */
137
+ stopped: boolean
138
+ }
139
+
140
+ type ThreeEvent<TEvent> = IntersectionEvent<TEvent> & Properties<TEvent>
141
+ type DomEvent = PointerEvent | MouseEvent | WheelEvent
142
+
143
+ /** DOM event handlers registered on the canvas element */
144
+ interface Events {
145
+ onClick: EventListener
146
+ onContextMenu: EventListener
147
+ onDoubleClick: EventListener
148
+ onWheel: EventListener
149
+ onPointerDown: EventListener
150
+ onPointerUp: EventListener
151
+ onPointerLeave: EventListener
152
+ onPointerMove: EventListener
153
+ onPointerCancel: EventListener
154
+ onLostPointerCapture: EventListener
155
+ onDragEnter: EventListener
156
+ onDragLeave: EventListener
157
+ onDragOver: EventListener
158
+ onDrop: EventListener
159
+ }
160
+
161
+ /** Event handlers that can be attached to R3F objects (meshes, groups, etc.) */
162
+ interface EventHandlers {
163
+ onClick?: (event: ThreeEvent<MouseEvent>) => void
164
+ onContextMenu?: (event: ThreeEvent<MouseEvent>) => void
165
+ onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void
166
+ /** Fires continuously while dragging over the object */
167
+ onDragOver?: (event: ThreeEvent<DragEvent>) => void
168
+ /** Fires once when drag enters the object */
169
+ onDragOverEnter?: (event: ThreeEvent<DragEvent>) => void
170
+ /** Fires once when drag leaves the object */
171
+ onDragOverLeave?: (event: ThreeEvent<DragEvent>) => void
172
+ /** Fires when drag misses this object (for objects that have drag handlers) */
173
+ onDragOverMissed?: (event: DragEvent) => void
174
+ /** Fires when a drop occurs on this object */
175
+ onDrop?: (event: ThreeEvent<DragEvent>) => void
176
+ /** Fires when a drop misses this object (for objects that have drop handlers) */
177
+ onDropMissed?: (event: DragEvent) => void
178
+ onPointerUp?: (event: ThreeEvent<PointerEvent>) => void
179
+ onPointerDown?: (event: ThreeEvent<PointerEvent>) => void
180
+ onPointerOver?: (event: ThreeEvent<PointerEvent>) => void
181
+ onPointerOut?: (event: ThreeEvent<PointerEvent>) => void
182
+ onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void
183
+ onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void
184
+ onPointerMove?: (event: ThreeEvent<PointerEvent>) => void
185
+ onPointerMissed?: (event: MouseEvent) => void
186
+ onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void
187
+ onWheel?: (event: ThreeEvent<WheelEvent>) => void
188
+ onLostPointerCapture?: (event: ThreeEvent<PointerEvent>) => void
189
+ }
190
+
191
+ type FilterFunction = (items: THREE$1.Intersection[], state: RootState) => THREE$1.Intersection[]
192
+ type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void
193
+
194
+ interface EventManager<TTarget> {
195
+ /** Determines if the event layer is active */
196
+ enabled: boolean
197
+ /** Event layer priority, higher prioritized layers come first and may stop(-propagate) lower layer */
198
+ priority: number
199
+ /** The compute function needs to set up the raycaster and an xy- pointer */
200
+ compute?: ComputeFunction
201
+ /** The filter can re-order or re-structure the intersections */
202
+ filter?: FilterFunction
203
+ /** The target node the event layer is tied to */
204
+ connected?: TTarget
205
+ /** All the pointer event handlers through which the host forwards native events */
206
+ handlers?: Events
207
+ /** Allows re-connecting to another target */
208
+ connect?: (target: TTarget) => void
209
+ /** Removes all existing events handlers from the target */
210
+ disconnect?: () => void
211
+ /** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
212
+ * explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
213
+ */
214
+ update?: () => void
215
+ }
216
+
217
+ interface PointerCaptureTarget {
218
+ intersection: Intersection
219
+ target: Element
220
+ }
221
+
222
+ //* Scheduler Types (useFrame) ==============================
223
+
224
+
225
+
226
+ // Public Options --------------------------------
227
+
228
+ /**
229
+ * Options for useFrame hook
230
+ */
231
+ interface UseFrameNextOptions {
232
+ /** Optional stable id for the job. Auto-generated if not provided */
233
+ id?: string
234
+ /** Named phase to run in. Default: 'update' */
235
+ phase?: string
236
+ /** Run before this phase or job id */
237
+ before?: string | string[]
238
+ /** Run after this phase or job id */
239
+ after?: string | string[]
240
+ /** Priority within phase. Higher runs first. Default: 0 */
241
+ priority?: number
242
+ /** Max frames per second for this job */
243
+ fps?: number
244
+ /** If true, skip frames when behind. If false, try to catch up. Default: true */
245
+ drop?: boolean
246
+ /** Enable/disable without unregistering. Default: true */
247
+ enabled?: boolean
248
+ }
249
+
250
+ /** Alias for UseFrameNextOptions */
251
+ type UseFrameOptions = UseFrameNextOptions
252
+
253
+ /**
254
+ * Options for addPhase
255
+ */
256
+ interface AddPhaseOptions {
257
+ /** Insert this phase before the specified phase */
258
+ before?: string
259
+ /** Insert this phase after the specified phase */
260
+ after?: string
261
+ }
262
+
263
+ // Frame State --------------------------------
264
+
265
+ /**
266
+ * State passed to useFrame callbacks
267
+ */
268
+ interface FrameNextState extends RootState {
269
+ /** High-resolution timestamp from RAF (ms) */
270
+ time: number
271
+ /** Time since last frame in seconds (for legacy compatibility with THREE.Clock) */
272
+ delta: number
273
+ /** Elapsed time since first frame in seconds (for legacy compatibility with THREE.Clock) */
274
+ elapsed: number
275
+ /** Incrementing frame counter */
276
+ frame: number
277
+ }
278
+
279
+ /** Alias for FrameNextState */
280
+ type FrameState = FrameNextState
281
+
282
+ // Callback Types --------------------------------
283
+
284
+ /**
285
+ * Callback function for useFrame
286
+ */
287
+ type FrameNextCallback = (state: FrameNextState, delta: number) => void
288
+
289
+ /** Alias for FrameNextCallback */
290
+ type FrameCallback = FrameNextCallback
291
+
292
+ // Controls returned from useFrame --------------------------------
293
+
294
+ /**
295
+ * Controls object returned from useFrame hook
296
+ */
297
+ interface FrameNextControls {
298
+ /** The job's unique ID */
299
+ id: string
300
+ /** Access to the global scheduler for frame loop control */
301
+ scheduler: SchedulerApi
302
+ /** Manually step this job only (bypasses FPS limiting) */
303
+ step(timestamp?: number): void
304
+ /** Manually step ALL jobs in the scheduler */
305
+ stepAll(timestamp?: number): void
306
+ /** Pause this job (set enabled=false) */
307
+ pause(): void
308
+ /** Resume this job (set enabled=true) */
309
+ resume(): void
310
+ /** Reactive paused state - automatically triggers re-render when changed */
311
+ isPaused: boolean
312
+ }
313
+
314
+ /** Alias for FrameNextControls */
315
+ type FrameControls = FrameNextControls
316
+
317
+ // Scheduler Interface --------------------------------
318
+
319
+ /**
320
+ * Public interface for the global Scheduler
321
+ */
322
+ interface SchedulerApi {
323
+ //* Phase Management --------------------------------
324
+
325
+ /** Add a named phase to the scheduler */
326
+ addPhase(name: string, options?: AddPhaseOptions): void
327
+ /** Get the ordered list of phase names */
328
+ readonly phases: string[]
329
+ /** Check if a phase exists */
330
+ hasPhase(name: string): boolean
331
+
332
+ //* Root Management --------------------------------
333
+
334
+ /** Register a root (Canvas) with the scheduler. Returns unsubscribe function. */
335
+ registerRoot(id: string, getState: () => RootState): () => void
336
+ /** Unregister a root */
337
+ unregisterRoot(id: string): void
338
+ /** Generate a unique root ID */
339
+ generateRootId(): string
340
+ /** Get the number of registered roots */
341
+ getRootCount(): number
342
+
343
+ //* Job Registration --------------------------------
344
+
345
+ /** Register a job with the scheduler (returns unsubscribe function) */
346
+ register(
347
+ callback: FrameNextCallback,
348
+ options?: {
349
+ id?: string
350
+ rootId?: string
351
+ phase?: string
352
+ before?: string | string[]
353
+ after?: string | string[]
354
+ priority?: number
355
+ fps?: number
356
+ drop?: boolean
357
+ enabled?: boolean
358
+ },
359
+ ): () => void
360
+ /** Update a job's options */
361
+ updateJob(
362
+ id: string,
363
+ options: {
364
+ priority?: number
365
+ fps?: number
366
+ drop?: boolean
367
+ enabled?: boolean
368
+ phase?: string
369
+ before?: string | string[]
370
+ after?: string | string[]
371
+ },
372
+ ): void
373
+ /** Unregister a job by ID */
374
+ unregister(id: string, rootId?: string): void
375
+ /** Get the number of registered jobs */
376
+ getJobCount(): number
377
+ /** Get all job IDs */
378
+ getJobIds(): string[]
379
+
380
+ //* Global Jobs (for legacy addEffect/addAfterEffect) --------------------------------
381
+
382
+ /** Register a global job (runs once per frame, not per-root). Returns unsubscribe function. */
383
+ registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void
384
+
385
+ //* Idle Callbacks (for legacy addTail) --------------------------------
386
+
387
+ /** Register an idle callback (fires when loop stops). Returns unsubscribe function. */
388
+ onIdle(callback: (timestamp: number) => void): () => void
389
+
390
+ //* Frame Loop Control --------------------------------
391
+
392
+ /** Start the scheduler loop */
393
+ start(): void
394
+ /** Stop the scheduler loop */
395
+ stop(): void
396
+ /** Check if the scheduler is running */
397
+ readonly isRunning: boolean
398
+ /** Get/set the frameloop mode ('always', 'demand', 'never') */
399
+ frameloop: Frameloop
400
+
401
+ //* Manual Stepping --------------------------------
402
+
403
+ /** Manually step all jobs once (for frameloop='never' or testing) */
404
+ step(timestamp?: number): void
405
+ /** Manually step a single job by ID */
406
+ stepJob(id: string, timestamp?: number): void
407
+ /** Request frame(s) to be rendered (for frameloop='demand') */
408
+ invalidate(frames?: number): void
409
+
410
+ //* Per-Job Control --------------------------------
411
+
412
+ /** Check if a job is paused */
413
+ isJobPaused(id: string): boolean
414
+ /** Pause a job */
415
+ pauseJob(id: string): void
416
+ /** Resume a job */
417
+ resumeJob(id: string): void
418
+ /** Subscribe to job state changes (for reactive isPaused). Returns unsubscribe function. */
419
+ subscribeJobState(id: string, listener: () => void): () => void
420
+ }
421
+
422
+ //* Core Store Types ========================================
423
+
424
+ type Subscription = {
425
+ ref: React$1.RefObject<RenderCallback>
426
+ priority: number
427
+ store: RootStore
428
+ }
429
+
430
+ type Dpr = number | [min: number, max: number]
431
+
432
+ interface Size {
433
+ width: number
434
+ height: number
435
+ top: number
436
+ left: number
437
+ }
438
+
439
+ type Frameloop = 'always' | 'demand' | 'never'
440
+
441
+ interface Viewport extends Size {
442
+ /** The initial pixel ratio */
443
+ initialDpr: number
444
+ /** Current pixel ratio */
445
+ dpr: number
446
+ /** size.width / viewport.width */
447
+ factor: number
448
+ /** Camera distance */
449
+ distance: number
450
+ /** Camera aspect ratio: width / height */
451
+ aspect: number
452
+ }
453
+
454
+ type RenderCallback = (state: RootState, delta: number, frame?: XRFrame) => void
455
+
456
+ interface Performance {
457
+ /** Current performance normal, between min and max */
458
+ current: number
459
+ /** How low the performance can go, between 0 and max */
460
+ min: number
461
+ /** How high the performance can go, between min and max */
462
+ max: number
463
+ /** Time until current returns to max in ms */
464
+ debounce: number
465
+ /** Sets current to min, puts the system in regression */
466
+ regress: () => void
467
+ }
468
+
469
+ interface InternalState {
470
+ interaction: THREE$1.Object3D[]
471
+ hovered: Map<string, ThreeEvent<DomEvent>>
472
+ subscribers: Subscription[]
473
+ capturedMap: Map<number, Map<THREE$1.Object3D, PointerCaptureTarget>>
474
+ initialClick: [x: number, y: number]
475
+ initialHits: THREE$1.Object3D[]
476
+ lastEvent: React$1.RefObject<DomEvent | null>
477
+ active: boolean
478
+ priority: number
479
+ frames: number
480
+ subscribe: (callback: React$1.RefObject<RenderCallback>, priority: number, store: RootStore) => () => void
481
+ /** Internal renderer storage - use state.renderer or state.gl to access */
482
+ actualRenderer: THREE$1.WebGLRenderer | any // WebGPURenderer when available
483
+ /** Global scheduler reference (for useFrame hook) */
484
+ scheduler: SchedulerApi | null
485
+ /** This root's unique ID in the global scheduler */
486
+ rootId?: string
487
+ /** Function to unregister this root from the global scheduler */
488
+ unregisterRoot?: () => void
489
+ /** Container for child attachment (scene for root, original container for portals) */
490
+ container?: THREE$1.Object3D
491
+ }
492
+
493
+ interface XRManager {
494
+ connect: () => void
495
+ disconnect: () => void
496
+ }
497
+
498
+ //* Root State Interface ====================================
499
+
500
+ interface RootState {
501
+ /** Set current state */
502
+ set: StoreApi<RootState>['setState']
503
+ /** Get current state */
504
+ get: StoreApi<RootState>['getState']
505
+ /** (deprecated) The instance of the WebGLrenderer */
506
+ gl: THREE$1.WebGLRenderer
507
+ /** The instance of the WebGPU renderer, the fallback, OR the default renderer as a mask of gl */
508
+ renderer: THREE$1.WebGLRenderer | any // WebGPURenderer when available
509
+ /** Inspector of the webGPU Renderer. Init in the canvas */
510
+ inspector: any // Inspector type from three/webgpu
511
+
512
+ /** Default camera */
513
+ camera: ThreeCamera
514
+ /** Default scene (may be overridden in portals to point to the portal container) */
515
+ scene: THREE$1.Scene
516
+ /** The actual root THREE.Scene - always points to the true scene, even inside portals */
517
+ rootScene: THREE$1.Scene
518
+ /** Default raycaster */
519
+ raycaster: THREE$1.Raycaster
520
+ /** Event layer interface, contains the event handler and the node they're connected to */
521
+ events: EventManager<any>
522
+ /** XR interface */
523
+ xr: XRManager
524
+ /** Currently used controls */
525
+ controls: THREE$1.EventDispatcher | null
526
+ /** Normalized event coordinates */
527
+ pointer: THREE$1.Vector2
528
+ /** @deprecated Normalized event coordinates, use "pointer" instead! */
529
+ mouse: THREE$1.Vector2
530
+ /* Whether to enable r139's THREE.ColorManagement */
531
+ legacy: boolean
532
+ /** Shortcut to gl.outputColorSpace = THREE.LinearSRGBColorSpace */
533
+ linear: boolean
534
+ /** Shortcut to gl.toneMapping = NoTonemapping */
535
+ flat: boolean
536
+ /** Color space assigned to 8-bit input textures (color maps). Most textures are authored in sRGB. */
537
+ textureColorSpace: THREE$1.ColorSpace
538
+ /** Render loop flags */
539
+ frameloop: Frameloop
540
+ performance: Performance
541
+ /** Reactive pixel-size of the canvas */
542
+ size: Size
543
+ /** Reactive size of the viewport in threejs units */
544
+ viewport: Viewport & {
545
+ getCurrentViewport: (
546
+ camera?: ThreeCamera,
547
+ target?: THREE$1.Vector3 | Parameters<THREE$1.Vector3['set']>,
548
+ size?: Size,
549
+ ) => Omit<Viewport, 'dpr' | 'initialDpr'>
550
+ }
551
+ /** Flags the canvas for render, but doesn't render in itself */
552
+ invalidate: (frames?: number, stackFrames?: boolean) => void
553
+ /** Advance (render) one step */
554
+ advance: (timestamp: number, runGlobalEffects?: boolean) => void
555
+ /** Shortcut to setting the event layer */
556
+ setEvents: (events: Partial<EventManager<any>>) => void
557
+ /** Shortcut to manual sizing */
558
+ setSize: (width: number, height: number, top?: number, left?: number) => void
559
+ /** Shortcut to manual setting the pixel ratio */
560
+ setDpr: (dpr: Dpr) => void
561
+ /** Shortcut to setting frameloop flags */
562
+ setFrameloop: (frameloop: Frameloop) => void
563
+ /** Set error state to propagate to error boundary */
564
+ setError: (error: Error | null) => void
565
+ /** Current error state (null when no error) */
566
+ error: Error | null
567
+ /** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
568
+ uniforms: UniformStore
569
+ /** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
570
+ nodes: Record<string, any>
571
+ /** Global TSL texture nodes - use useTextures() hook for operations */
572
+ textures: Map<string, any>
573
+ /** WebGPU PostProcessing instance - use usePostProcessing() hook */
574
+ postProcessing: any | null // THREE.PostProcessing when available
575
+ /** Global TSL pass nodes for post-processing - use usePostProcessing() hook */
576
+ passes: Record<string, any>
577
+ /** When the canvas was clicked but nothing was hit */
578
+ onPointerMissed?: (event: MouseEvent) => void
579
+ /** When a dragover event has missed any target */
580
+ onDragOverMissed?: (event: DragEvent) => void
581
+ /** When a drop event has missed any target */
582
+ onDropMissed?: (event: DragEvent) => void
583
+ /** If this state model is layered (via createPortal) then this contains the previous layer */
584
+ previousRoot?: RootStore
585
+ /** Internals */
586
+ internal: InternalState
587
+ // flags for triggers
588
+ // if we are using the webGl renderer, this will be true
589
+ isLegacy: boolean
590
+ // regardless of renderer, if the system supports webGpu, this will be true
591
+ webGPUSupported: boolean
592
+ //if we are on native
593
+ isNative: boolean
594
+ }
595
+
596
+ type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>
597
+
598
+ //* Base Renderer Types =====================================
599
+
600
+ // Shim for OffscreenCanvas since it was removed from DOM types
601
+ interface OffscreenCanvas$1 extends EventTarget {}
602
+
603
+ interface BaseRendererProps {
604
+ canvas: HTMLCanvasElement | OffscreenCanvas$1
605
+ powerPreference?: 'high-performance' | 'low-power' | 'default'
606
+ antialias?: boolean
607
+ alpha?: boolean
608
+ }
609
+
610
+ type RendererFactory<TRenderer, TParams> =
611
+ | TRenderer
612
+ | ((defaultProps: TParams) => TRenderer)
613
+ | ((defaultProps: TParams) => Promise<TRenderer>)
614
+
615
+ interface Renderer {
616
+ render: (scene: THREE$1.Scene, camera: THREE$1.Camera) => any
617
+ }
618
+
619
+ //* WebGL Renderer Props ==============================
620
+
621
+ type DefaultGLProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & {
622
+ canvas: HTMLCanvasElement | OffscreenCanvas$1
623
+ }
624
+
625
+ type GLProps =
626
+ | Renderer
627
+ | ((defaultProps: DefaultGLProps) => Renderer)
628
+ | ((defaultProps: DefaultGLProps) => Promise<Renderer>)
629
+ | Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
630
+
631
+ //* WebGPU Renderer Props ==============================
632
+
633
+ type DefaultRendererProps = {
634
+ canvas: HTMLCanvasElement | OffscreenCanvas$1
635
+ [key: string]: any
636
+ }
637
+
638
+ type RendererProps =
639
+ | any // WebGPURenderer
640
+ | ((defaultProps: DefaultRendererProps) => any)
641
+ | ((defaultProps: DefaultRendererProps) => Promise<any>)
642
+ | Partial<Properties<any> | Record<string, any>>
643
+
644
+ //* Camera Props ==============================
645
+
646
+ type CameraProps = (
647
+ | THREE$1.Camera
648
+ | Partial<
649
+ ThreeElement<typeof THREE$1.Camera> &
650
+ ThreeElement<typeof THREE$1.PerspectiveCamera> &
651
+ ThreeElement<typeof THREE$1.OrthographicCamera>
652
+ >
653
+ ) & {
654
+ /** Flags the camera as manual, putting projection into your own hands */
655
+ manual?: boolean
656
+ }
657
+
658
+ //* Render Props ==============================
659
+
660
+ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
661
+ /** A threejs renderer instance or props that go into the default renderer */
662
+ gl?: GLProps
663
+ /** A WebGPU renderer instance or props that go into the default renderer */
664
+ renderer?: RendererProps
665
+ /** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
666
+ size?: Size
667
+ /**
668
+ * Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
669
+ * but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
670
+ * @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
671
+ */
672
+ shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
673
+ /**
674
+ * Disables three r139 color management.
675
+ * @see https://threejs.org/docs/#manual/en/introduction/Color-management
676
+ */
677
+ legacy?: boolean
678
+ /** Switch off automatic sRGB encoding and gamma correction */
679
+ linear?: boolean
680
+ /** Use `THREE.NoToneMapping` instead of `THREE.ACESFilmicToneMapping` */
681
+ flat?: boolean
682
+ /** Working color space for automatic texture colorspace assignment. Defaults to THREE.SRGBColorSpace */
683
+ /** Color space assigned to 8-bit input textures (color maps). Defaults to sRGB. Most textures are authored in sRGB. */
684
+ textureColorSpace?: THREE$1.ColorSpace
685
+ /** Creates an orthographic camera */
686
+ orthographic?: boolean
687
+ /**
688
+ * R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
689
+ * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
690
+ */
691
+ frameloop?: Frameloop
692
+ /**
693
+ * R3F performance options for adaptive performance.
694
+ * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
695
+ */
696
+ performance?: Partial<Omit<Performance, 'regress'>>
697
+ /** Target pixel ratio. Can clamp between a range: `[min, max]` */
698
+ dpr?: Dpr
699
+ /** Props that go into the default raycaster */
700
+ raycaster?: Partial<THREE$1.Raycaster>
701
+ /** A `THREE.Scene` instance or props that go into the default scene */
702
+ scene?: THREE$1.Scene | Partial<THREE$1.Scene>
703
+ /** A `THREE.Camera` instance or props that go into the default camera */
704
+ camera?: CameraProps
705
+ /** An R3F event manager to manage elements' pointer events */
706
+ events?: (store: RootStore) => EventManager<HTMLElement>
707
+ /** Callback after the canvas has rendered (but not yet committed) */
708
+ onCreated?: (state: RootState) => void
709
+ /** Response for pointer clicks that have missed any target */
710
+ onPointerMissed?: (event: MouseEvent) => void
711
+ /** Response for dragover events that have missed any target */
712
+ onDragOverMissed?: (event: DragEvent) => void
713
+ /** Response for drop events that have missed any target */
714
+ onDropMissed?: (event: DragEvent) => void
715
+ }
716
+
717
+ //* Reconciler Root ==============================
718
+
719
+ interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
720
+ configure: (config?: RenderProps<TCanvas>) => Promise<ReconcilerRoot<TCanvas>>
721
+ render: (element: ReactNode) => RootStore
722
+ unmount: () => void
723
+ }
724
+
725
+ //* Inject State ==============================
726
+
727
+ type InjectState = Partial<
728
+ Omit<RootState, 'events'> & {
729
+ events?: {
730
+ enabled?: boolean
731
+ priority?: number
732
+ compute?: ComputeFunction
733
+ connected?: any
734
+ }
735
+ /**
736
+ * When true (default), injects a THREE.Scene between container and children if container isn't already a Scene.
737
+ * This ensures state.scene is always a real THREE.Scene with proper properties (background, environment, fog).
738
+ * Set to false to use the container directly as scene (anti-pattern, but supported for edge cases).
739
+ */
740
+ injectScene?: boolean
741
+ }
742
+ >
743
+
744
+ //* Reconciler Types ==============================
745
+
746
+ interface Root {
747
+ fiber: react_reconciler.FiberRoot
748
+ store: RootStore
749
+ }
750
+
751
+ type AttachFnType<O = any> = (parent: any, self: O) => () => void
752
+ type AttachType<O = any> = string | AttachFnType<O>
753
+
754
+ type ConstructorRepresentation<T = any> = new (...args: any[]) => T
755
+
756
+ interface Catalogue {
757
+ [name: string]: ConstructorRepresentation
758
+ }
759
+
760
+ // TODO: handle constructor overloads
761
+ // https://github.com/pmndrs/react-three-fiber/pull/2931
762
+ // https://github.com/microsoft/TypeScript/issues/37079
763
+ type Args<T> = T extends ConstructorRepresentation
764
+ ? T extends typeof Color$1
765
+ ? [r: number, g: number, b: number] | [color: ColorRepresentation]
766
+ : ConstructorParameters<T>
767
+ : any[]
768
+
769
+ type ArgsProp<P> = P extends ConstructorRepresentation
770
+ ? IsAllOptional<ConstructorParameters<P>> extends true
771
+ ? { args?: Args<P> }
772
+ : { args: Args<P> }
773
+ : { args: unknown[] }
774
+
775
+ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
776
+ object?: T
777
+ dispose?: null
778
+ attach?: AttachType<T>
779
+ onUpdate?: (self: T) => void
780
+ }
781
+
782
+ interface Instance<O = any> {
783
+ root: RootStore
784
+ type: string
785
+ parent: Instance | null
786
+ children: Instance[]
787
+ props: InstanceProps<O> & Record<string, unknown>
788
+ object: O & { __r3f?: Instance<O> }
789
+ eventCount: number
790
+ handlers: Partial<EventHandlers>
791
+ attach?: AttachType<O>
792
+ previousAttach?: any
793
+ isHidden: boolean
794
+ }
795
+
796
+ interface HostConfig {
797
+ type: string
798
+ props: Instance['props']
799
+ container: RootStore
800
+ instance: Instance
801
+ textInstance: void
802
+ suspenseInstance: Instance
803
+ hydratableInstance: never
804
+ formInstance: never
805
+ publicInstance: Instance['object']
806
+ hostContext: {}
807
+ childSet: never
808
+ timeoutHandle: number | undefined
809
+ noTimeout: -1
810
+ TransitionStatus: null
811
+ }
812
+ declare global {
813
+ var IS_REACT_ACT_ENVIRONMENT: boolean | undefined
814
+ }
815
+
816
+ //* Loop Types ==============================
817
+
818
+ type GlobalRenderCallback = (timestamp: number) => void
819
+
820
+ type GlobalEffectType = 'before' | 'after' | 'tail'
821
+
822
+ //* Canvas Types ==============================
823
+
824
+ interface CanvasProps
825
+ extends Omit<RenderProps<HTMLCanvasElement>, 'size'>,
826
+ React$1.HTMLAttributes<HTMLDivElement> {
827
+ children?: React$1.ReactNode
828
+ ref?: React$1.Ref<HTMLCanvasElement>
829
+ /** Canvas fallback content, similar to img's alt prop */
830
+ fallback?: React$1.ReactNode
831
+ /**
832
+ * Options to pass to useMeasure.
833
+ * @see https://github.com/pmndrs/react-use-measure#api
834
+ */
835
+ resize?: Options
836
+ /** The target where events are being subscribed to, default: the div that wraps canvas */
837
+ eventSource?: HTMLElement | React$1.RefObject<HTMLElement>
838
+ /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
839
+ eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
840
+ }
841
+
842
+ //* Loader Types ==============================
843
+
844
+ type InputLike = string | string[] | string[][] | Readonly<string | string[] | string[][]>
845
+
846
+ // Define a loader-like interface that matches THREE.Loader's load signature
847
+ // This works for both generic and non-generic THREE.Loader instances
848
+ interface LoaderLike {
849
+ load(
850
+ url: InputLike,
851
+ onLoad?: (result: any) => void,
852
+ onProgress?: (event: ProgressEvent<EventTarget>) => void,
853
+ onError?: (error: unknown) => void,
854
+ ): any
855
+ }
856
+
857
+ type GLTFLike = { scene: THREE$1.Object3D }
858
+
859
+ type LoaderInstance<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
860
+ T extends ConstructorRepresentation<LoaderLike> ? InstanceType<T> : T
861
+
862
+ // Infer result type from the load method's callback parameter
863
+ type InferLoadResult<T> = T extends {
864
+ load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
865
+ }
866
+ ? R
867
+ : T extends ConstructorRepresentation<any>
868
+ ? InstanceType<T> extends {
869
+ load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
870
+ }
871
+ ? R
872
+ : any
873
+ : any
874
+
875
+ type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = InferLoadResult<
876
+ LoaderInstance<T>
877
+ > extends infer R
878
+ ? R extends GLTFLike
879
+ ? R & ObjectMap
880
+ : R
881
+ : never
882
+
883
+ type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = (
884
+ loader: LoaderInstance<T>,
885
+ ) => void
886
+
887
+ type WebGLDefaultProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & BaseRendererProps
888
+
889
+ type WebGLProps =
890
+ | RendererFactory<THREE$1.WebGLRenderer, WebGLDefaultProps>
891
+ | Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
892
+
893
+ interface WebGLShadowConfig {
894
+ shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
895
+ }
896
+
897
+ //* Global Types ==============================
898
+
899
+ declare global {
900
+ /** Uniform node type - a Node with a value property (matches Three.js UniformNode) */
901
+ interface UniformNode<T = unknown> extends Node {
902
+ value: T
903
+ }
904
+
905
+ /** Flat record of uniform nodes (no nested scopes) */
906
+ type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
907
+
908
+ /**
909
+ * Uniform store that can contain both root-level uniforms and scoped uniform objects
910
+ * Used by state.uniforms which has structure like:
911
+ * { uTime: UniformNode, player: { uHealth: UniformNode }, enemy: { uHealth: UniformNode } }
912
+ */
913
+ type UniformStore = Record<string, UniformNode | UniformRecord>
914
+
915
+ /**
916
+ * Acceptable input values for useUniforms - raw values that get converted to UniformNodes
917
+ * Supports: primitives, Three.js types, plain objects (converted to vectors), and UniformNodes
918
+ */
919
+ type UniformValue =
920
+ | number
921
+ | string
922
+ | boolean
923
+ | three_webgpu.Color
924
+ | three_webgpu.Vector2
925
+ | three_webgpu.Vector3
926
+ | three_webgpu.Vector4
927
+ | three_webgpu.Matrix3
928
+ | three_webgpu.Matrix4
929
+ | three_webgpu.Euler
930
+ | three_webgpu.Quaternion
931
+ | { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
932
+ | UniformNode
933
+
934
+ /** Input record for useUniforms - accepts raw values or UniformNodes */
935
+ type UniformInputRecord = Record<string, UniformValue>
936
+ }
937
+
938
+ //* Fn Return Type ==============================
939
+
940
+ /** The return type of Fn() - a callable shader function node */
941
+ type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
942
+
943
+ //* Module Augmentation ==============================
944
+
945
+ declare module 'three/tsl' {
946
+ /**
947
+ * Fn with array parameter destructuring
948
+ * @example Fn(([uv, skew]) => { ... })
949
+ */
950
+ export function Fn<R extends Node = Node>(
951
+ jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
952
+ ): ShaderCallable<R>
953
+
954
+ /**
955
+ * Fn with object parameter destructuring
956
+ * @example Fn(({ color, intensity }) => { ... })
957
+ */
958
+ export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
959
+ jsFunc: (inputs: T) => ShaderNodeObject<R>,
960
+ ): ShaderCallable<R>
961
+
962
+ /**
963
+ * Fn with array params + layout
964
+ * @example Fn(([a, b]) => { ... }, { layout: [...] })
965
+ */
966
+ export function Fn<R extends Node = Node>(
967
+ jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
968
+ layout: { layout?: unknown },
969
+ ): ShaderCallable<R>
970
+
971
+ /**
972
+ * Fn with object params + layout
973
+ */
974
+ export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
975
+ jsFunc: (inputs: T) => ShaderNodeObject<R>,
976
+ layout: { layout?: unknown },
977
+ ): ShaderCallable<R>
978
+ }
979
+
980
+ /**
981
+ * PostProcessing Types for usePostProcessing hook (WebGPU only)
982
+ */
983
+
984
+
985
+
986
+ declare global {
987
+ /** Pass record - stores TSL pass nodes for post-processing */
988
+ type PassRecord = Record<string, any>
989
+
990
+ /** Setup callback - runs first to configure MRT, create additional passes */
991
+ type PostProcessingSetupCallback = (state: RootState) => PassRecord | void
992
+
993
+ /** Main callback - runs second to configure outputNode, create effect passes */
994
+ type PostProcessingMainCallback = (state: RootState) => PassRecord | void
995
+
996
+ /** Return type for usePostProcessing hook */
997
+ interface UsePostProcessingReturn {
998
+ /** Current passes from state */
999
+ passes: PassRecord
1000
+ /** PostProcessing instance (null if not initialized) */
1001
+ postProcessing: any | null // THREE.PostProcessing
1002
+ /** Clear all passes from state */
1003
+ clearPasses: () => void
1004
+ /** Reset PostProcessing entirely (clears PP + passes) */
1005
+ reset: () => void
1006
+ /** Re-run setup/main callbacks with current closure values */
1007
+ rebuild: () => void
1008
+ /** True when PostProcessing is configured and ready */
1009
+ isReady: boolean
1010
+ }
1011
+ }
1012
+
1013
+ //* Global Type Declarations ==============================
1014
+
1015
+ declare global {
1016
+ // Job --------------------------------
1017
+
1018
+ /**
1019
+ * Internal job representation in the scheduler
1020
+ */
1021
+ interface Job {
1022
+ /** Unique identifier */
1023
+ id: string
1024
+ /** The callback to execute */
1025
+ callback: FrameNextCallback
1026
+ /** Phase this job belongs to */
1027
+ phase: string
1028
+ /** Run before these phases/job ids */
1029
+ before: Set<string>
1030
+ /** Run after these phases/job ids */
1031
+ after: Set<string>
1032
+ /** Priority within phase (higher first) */
1033
+ priority: number
1034
+ /** Insertion order for deterministic tie-breaking */
1035
+ index: number
1036
+ /** Max FPS for this job (undefined = no limit) */
1037
+ fps?: number
1038
+ /** Drop frames when behind (true) or catch up (false) */
1039
+ drop: boolean
1040
+ /** Last run timestamp (ms) */
1041
+ lastRun?: number
1042
+ /** Whether job is enabled */
1043
+ enabled: boolean
1044
+ /** Internal flag: system jobs (like default render) don't block user render takeover */
1045
+ system?: boolean
1046
+ }
1047
+
1048
+ // Phase Graph --------------------------------
1049
+
1050
+ /**
1051
+ * A node in the phase graph
1052
+ */
1053
+ interface PhaseNode {
1054
+ /** Phase name */
1055
+ name: string
1056
+ /** Whether this was auto-generated from a before/after constraint */
1057
+ isAutoGenerated: boolean
1058
+ }
1059
+
1060
+ /**
1061
+ * Options for creating a job from hook options
1062
+ */
1063
+ interface JobOptions {
1064
+ id?: string
1065
+ phase?: string
1066
+ before?: string | string[]
1067
+ after?: string | string[]
1068
+ priority?: number
1069
+ fps?: number
1070
+ drop?: boolean
1071
+ enabled?: boolean
1072
+ }
1073
+
1074
+ // Frame Loop State --------------------------------
1075
+
1076
+ /**
1077
+ * Internal frame loop state
1078
+ */
1079
+ interface FrameLoopState {
1080
+ /** Whether the loop is running */
1081
+ running: boolean
1082
+ /** Current RAF handle */
1083
+ rafHandle: number | null
1084
+ /** Last frame timestamp in ms (null = uninitialized) */
1085
+ lastTime: number | null
1086
+ /** Frame counter */
1087
+ frameCount: number
1088
+ /** Elapsed time since first frame in ms */
1089
+ elapsedTime: number
1090
+ /** createdAt timestamp in ms */
1091
+ createdAt: number
1092
+ }
1093
+
1094
+ // Root Entry --------------------------------
1095
+
1096
+ /**
1097
+ * Internal representation of a registered root (Canvas).
1098
+ * Tracks jobs and manages rebuild state for this root.
1099
+ * @internal
1100
+ */
1101
+ interface RootEntry {
1102
+ /** Unique identifier for this root */
1103
+ id: string
1104
+ /** Function to get the root's current state */
1105
+ getState: () => RootState
1106
+ /** Map of job IDs to Job objects */
1107
+ jobs: Map<string, Job>
1108
+ /** Cached sorted job list for execution order */
1109
+ sortedJobs: Job[]
1110
+ /** Whether sortedJobs needs rebuilding */
1111
+ needsRebuild: boolean
1112
+ }
1113
+
1114
+ /**
1115
+ * Internal representation of a global job (deprecated API).
1116
+ * Global jobs run once per frame, not per-root.
1117
+ * Used by legacy addEffect/addAfterEffect APIs.
1118
+ * @internal
1119
+ * @deprecated Use useFrame with phases instead
1120
+ */
1121
+ interface GlobalJob {
1122
+ /** Unique identifier for this global job */
1123
+ id: string
1124
+ /** Callback invoked with RAF timestamp in ms */
1125
+ callback: (timestamp: number) => void
1126
+ }
1127
+
1128
+ // HMR Support --------------------------------
1129
+
1130
+ /**
1131
+ * Hot Module Replacement data structure for preserving scheduler state
1132
+ * @internal
1133
+ */
1134
+ interface HMRData {
1135
+ /** Shared data object for storing values across reloads */
1136
+ data: Record<string, any>
1137
+ /** Optional function to accept HMR updates */
1138
+ accept?: () => void
1139
+ }
1140
+
1141
+ // Default Phases --------------------------------
1142
+
1143
+ /**
1144
+ * Default phase names for the scheduler
1145
+ */
1146
+ type DefaultPhase = 'start' | 'input' | 'physics' | 'update' | 'render' | 'finish'
1147
+ }
1148
+
1149
+ type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
1150
+
1151
+ interface MathRepresentation {
1152
+ set(...args: number[]): any
1153
+ }
1154
+ interface VectorRepresentation extends MathRepresentation {
1155
+ setScalar(value: number): any
1156
+ }
1157
+ type MathTypes = MathRepresentation | Euler$1 | Color$1
1158
+
1159
+ type MathType<T extends MathTypes> = T extends Color$1
1160
+ ? Args<typeof Color$1> | ColorRepresentation
1161
+ : T extends VectorRepresentation | Layers$1 | Euler$1
1162
+ ? T | MutableOrReadonlyParameters<T['set']> | number
1163
+ : T | MutableOrReadonlyParameters<T['set']>
1164
+
1165
+ type MathProps<P> = {
1166
+ [K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
1167
+ }
1168
+
1169
+ type Vector2 = MathType<Vector2$1>
1170
+ type Vector3 = MathType<Vector3$1>
1171
+ type Vector4 = MathType<Vector4$1>
1172
+ type Color = MathType<Color$1>
1173
+ type Layers = MathType<Layers$1>
1174
+ type Quaternion = MathType<Quaternion$1>
1175
+ type Euler = MathType<Euler$1>
1176
+ type Matrix3 = MathType<Matrix3$1>
1177
+ type Matrix4 = MathType<Matrix4$1>
1178
+
1179
+ interface RaycastableRepresentation {
1180
+ raycast(raycaster: Raycaster, intersects: Intersection$1[]): void
1181
+ }
1182
+ type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}
1183
+
1184
+ interface ReactProps<P> {
1185
+ children?: React.ReactNode
1186
+ ref?: React.Ref<P>
1187
+ key?: React.Key
1188
+ }
1189
+
1190
+ type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
1191
+ Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P>>
1192
+ >
1193
+
1194
+ type ThreeElement<T extends ConstructorRepresentation> = Mutable<
1195
+ Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
1196
+ >
1197
+
1198
+ type ThreeToJSXElements<T extends Record<string, any>> = {
1199
+ [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
1200
+ }
1201
+
1202
+ type ThreeExports = typeof THREE
1203
+ type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
1204
+
1205
+ interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
1206
+ primitive: Omit<ThreeElement<any>, 'args'> & { object: object }
1207
+ // Conflicts with DOM types can be accessed through a three* prefix
1208
+ threeAudio: ThreeElementsImpl['audio']
1209
+ threeSource: ThreeElementsImpl['source']
1210
+ threeLine: ThreeElementsImpl['line']
1211
+ threePath: ThreeElementsImpl['path']
1212
+ }
1213
+
1214
+ declare module 'react' {
1215
+ namespace JSX {
1216
+ interface IntrinsicElements extends ThreeElements {}
1217
+ }
1218
+ }
1219
+
1220
+ declare module 'react/jsx-runtime' {
1221
+ namespace JSX {
1222
+ interface IntrinsicElements extends ThreeElements {}
1223
+ }
1224
+ }
1225
+
1226
+ declare module 'react/jsx-dev-runtime' {
1227
+ namespace JSX {
1228
+ interface IntrinsicElements extends ThreeElements {}
1229
+ }
1230
+ }
1231
+
1232
+ type three_d_Color = Color;
1233
+ type three_d_ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = ElementProps<T, P>;
1234
+ type three_d_Euler = Euler;
1235
+ type three_d_EventProps<P> = EventProps<P>;
1236
+ type three_d_Layers = Layers;
1237
+ type three_d_MathProps<P> = MathProps<P>;
1238
+ type three_d_MathRepresentation = MathRepresentation;
1239
+ type three_d_MathType<T extends MathTypes> = MathType<T>;
1240
+ type three_d_MathTypes = MathTypes;
1241
+ type three_d_Matrix3 = Matrix3;
1242
+ type three_d_Matrix4 = Matrix4;
1243
+ type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
1244
+ type three_d_Quaternion = Quaternion;
1245
+ type three_d_RaycastableRepresentation = RaycastableRepresentation;
1246
+ type three_d_ReactProps<P> = ReactProps<P>;
1247
+ type three_d_ThreeElement<T extends ConstructorRepresentation> = ThreeElement<T>;
1248
+ type three_d_ThreeElements = ThreeElements;
1249
+ type three_d_ThreeElementsImpl = ThreeElementsImpl;
1250
+ type three_d_ThreeExports = ThreeExports;
1251
+ type three_d_ThreeToJSXElements<T extends Record<string, any>> = ThreeToJSXElements<T>;
1252
+ type three_d_Vector2 = Vector2;
1253
+ type three_d_Vector3 = Vector3;
1254
+ type three_d_Vector4 = Vector4;
1255
+ type three_d_VectorRepresentation = VectorRepresentation;
1256
+ declare namespace three_d {
1257
+ export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
1258
+ }
1259
+
1260
+ declare function removeInteractivity(store: RootStore, object: Object3D): void;
1261
+ declare function createEvents(store: RootStore): {
1262
+ handlePointer: (name: string) => (event: DomEvent) => void;
1263
+ };
1264
+ /** Default R3F event manager for web */
1265
+ declare function createPointerEvents(store: RootStore): EventManager<HTMLElement>;
1266
+
1267
+ /**
1268
+ * Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
1269
+ * This allows external code to access loader methods like abort().
1270
+ */
1271
+ declare function getLoader<L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(Proto: L): L extends ConstructorRepresentation<infer T> ? T : L;
1272
+ /**
1273
+ * Synchronously loads and caches assets with a three loader.
1274
+ *
1275
+ * Note: this hook's caller must be wrapped with `React.Suspense`
1276
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1277
+ */
1278
+ declare function useLoader<I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void): I extends any[] ? LoaderResult<L>[] : LoaderResult<L>;
1279
+ declare namespace useLoader {
1280
+ var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void) => void;
1281
+ var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I) => void;
1282
+ var loader: typeof getLoader;
1283
+ }
1284
+
1285
+ /**
1286
+ * Global Singleton Scheduler - manages the frame loop and job execution for ALL R3F roots.
1287
+ *
1288
+ * Features:
1289
+ * - Single RAF loop for entire application
1290
+ * - Root registration (multiple Canvas support)
1291
+ * - Global phases for addEffect/addAfterEffect (deprecated)
1292
+ * - Per-root job management with phases, priorities, FPS throttling
1293
+ * - onIdle callbacks for addTail (deprecated)
1294
+ * - Demand mode support via invalidate()
1295
+ */
1296
+ declare class Scheduler {
1297
+ private static instance;
1298
+ /**
1299
+ * Get the global scheduler instance (creates if doesn't exist).
1300
+ * Uses HMR data to preserve instance across hot reloads.
1301
+ * @returns {Scheduler} The singleton scheduler instance
1302
+ */
1303
+ static get(): Scheduler;
1304
+ /**
1305
+ * Reset the singleton instance. Stops the loop and clears all state.
1306
+ * Primarily used for testing to ensure clean state between tests.
1307
+ * @returns {void}
1308
+ */
1309
+ static reset(): void;
1310
+ private roots;
1311
+ private phaseGraph;
1312
+ private loopState;
1313
+ private stoppedTime;
1314
+ private nextRootIndex;
1315
+ private globalBeforeJobs;
1316
+ private globalAfterJobs;
1317
+ private nextGlobalIndex;
1318
+ private idleCallbacks;
1319
+ private nextJobIndex;
1320
+ private jobStateListeners;
1321
+ private pendingFrames;
1322
+ private _frameloop;
1323
+ get phases(): string[];
1324
+ get frameloop(): Frameloop;
1325
+ set frameloop(mode: Frameloop);
1326
+ get isRunning(): boolean;
1327
+ constructor();
1328
+ /**
1329
+ * Register a root (Canvas) with the scheduler.
1330
+ * The first root to register starts the RAF loop (if frameloop='always').
1331
+ * @param {string} id - Unique identifier for this root
1332
+ * @param {() => RootState} getState - Function to get the root's current state
1333
+ * @returns {() => void} Unsubscribe function to remove this root
1334
+ */
1335
+ registerRoot(id: string, getState: () => RootState): () => void;
1336
+ /**
1337
+ * Unregister a root from the scheduler.
1338
+ * Cleans up all job state listeners for this root's jobs.
1339
+ * The last root to unregister stops the RAF loop.
1340
+ * @param {string} id - The root ID to unregister
1341
+ * @returns {void}
1342
+ */
1343
+ unregisterRoot(id: string): void;
1344
+ /**
1345
+ * Add a named phase to the scheduler's execution order.
1346
+ * Marks all roots for rebuild to incorporate the new phase.
1347
+ * @param {string} name - The phase name (e.g., 'physics', 'postprocess')
1348
+ * @param {AddPhaseOptions} [options] - Positioning options (before/after other phases)
1349
+ * @returns {void}
1350
+ * @example
1351
+ * scheduler.addPhase('physics', { before: 'update' });
1352
+ * scheduler.addPhase('postprocess', { after: 'render' });
1353
+ */
1354
+ addPhase(name: string, options?: AddPhaseOptions): void;
1355
+ /**
1356
+ * Check if a phase exists in the scheduler.
1357
+ * @param {string} name - The phase name to check
1358
+ * @returns {boolean} True if the phase exists
1359
+ */
1360
+ hasPhase(name: string): boolean;
1361
+ /**
1362
+ * Register a global job that runs once per frame (not per-root).
1363
+ * Used internally by deprecated addEffect/addAfterEffect APIs.
1364
+ * @param {'before' | 'after'} phase - When to run: 'before' all roots or 'after' all roots
1365
+ * @param {string} id - Unique identifier for this global job
1366
+ * @param {(timestamp: number) => void} callback - Function called each frame with RAF timestamp
1367
+ * @returns {() => void} Unsubscribe function to remove this global job
1368
+ * @deprecated Use useFrame with phases instead
1369
+ */
1370
+ registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void;
1371
+ /**
1372
+ * Register an idle callback that fires when the loop stops.
1373
+ * Used internally by deprecated addTail API.
1374
+ * @param {(timestamp: number) => void} callback - Function called when loop becomes idle
1375
+ * @returns {() => void} Unsubscribe function to remove this idle callback
1376
+ * @deprecated Use demand mode with invalidate() instead
1377
+ */
1378
+ onIdle(callback: (timestamp: number) => void): () => void;
1379
+ /**
1380
+ * Notify all registered idle callbacks.
1381
+ * Called when the loop stops in demand mode.
1382
+ * @param {number} timestamp - The RAF timestamp when idle occurred
1383
+ * @returns {void}
1384
+ * @private
1385
+ */
1386
+ private notifyIdle;
1387
+ /**
1388
+ * Register a job (frame callback) with a specific root.
1389
+ * This is the core registration method used by useFrame internally.
1390
+ * @param {FrameNextCallback} callback - The function to call each frame
1391
+ * @param {JobOptions & { rootId?: string; system?: boolean }} [options] - Job configuration
1392
+ * @param {string} [options.rootId] - Target root ID (defaults to first registered root)
1393
+ * @param {string} [options.id] - Unique job ID (auto-generated if not provided)
1394
+ * @param {string} [options.phase] - Execution phase (defaults to 'update')
1395
+ * @param {number} [options.priority] - Priority within phase (higher = earlier, default 0)
1396
+ * @param {number} [options.fps] - FPS throttle limit
1397
+ * @param {boolean} [options.drop] - Drop frames when behind (default true)
1398
+ * @param {boolean} [options.enabled] - Whether job is active (default true)
1399
+ * @param {boolean} [options.system] - Internal flag for system jobs (not user-facing)
1400
+ * @returns {() => void} Unsubscribe function to remove this job
1401
+ */
1402
+ register(callback: FrameNextCallback, options?: JobOptions & {
1403
+ rootId?: string;
1404
+ system?: boolean;
1405
+ }): () => void;
1406
+ /**
1407
+ * Unregister a job by its ID.
1408
+ * Searches all roots if rootId is not provided.
1409
+ * @param {string} id - The job ID to unregister
1410
+ * @param {string} [rootId] - Optional root ID to search (searches all if not provided)
1411
+ * @returns {void}
1412
+ */
1413
+ unregister(id: string, rootId?: string): void;
1414
+ /**
1415
+ * Update a job's options dynamically.
1416
+ * Searches all roots to find the job by ID.
1417
+ * Phase/constraint changes trigger a rebuild of the sorted job list.
1418
+ * @param {string} id - The job ID to update
1419
+ * @param {Partial<JobOptions>} options - The options to update
1420
+ * @returns {void}
1421
+ */
1422
+ updateJob(id: string, options: Partial<JobOptions>): void;
1423
+ /**
1424
+ * Check if a job is currently paused (disabled).
1425
+ * @param {string} id - The job ID to check
1426
+ * @returns {boolean} True if the job exists and is paused
1427
+ */
1428
+ isJobPaused(id: string): boolean;
1429
+ /**
1430
+ * Subscribe to state changes for a specific job.
1431
+ * Listener is called when job is paused or resumed.
1432
+ * @param {string} id - The job ID to subscribe to
1433
+ * @param {() => void} listener - Callback invoked on state changes
1434
+ * @returns {() => void} Unsubscribe function
1435
+ */
1436
+ subscribeJobState(id: string, listener: () => void): () => void;
1437
+ /**
1438
+ * Notify all listeners that a job's state has changed.
1439
+ * @param {string} id - The job ID that changed
1440
+ * @returns {void}
1441
+ * @private
1442
+ */
1443
+ private notifyJobStateChange;
1444
+ /**
1445
+ * Pause a job by ID (sets enabled=false).
1446
+ * Notifies any subscribed state listeners.
1447
+ * @param {string} id - The job ID to pause
1448
+ * @returns {void}
1449
+ */
1450
+ pauseJob(id: string): void;
1451
+ /**
1452
+ * Resume a paused job by ID (sets enabled=true).
1453
+ * Resets job timing to prevent frame accumulation.
1454
+ * Notifies any subscribed state listeners.
1455
+ * @param {string} id - The job ID to resume
1456
+ * @returns {void}
1457
+ */
1458
+ resumeJob(id: string): void;
1459
+ /**
1460
+ * Start the requestAnimationFrame loop.
1461
+ * Resets timing state (elapsedTime, frameCount) on start.
1462
+ * No-op if already running.
1463
+ * @returns {void}
1464
+ */
1465
+ start(): void;
1466
+ /**
1467
+ * Stop the requestAnimationFrame loop.
1468
+ * Cancels any pending RAF callback.
1469
+ * No-op if not running.
1470
+ * @returns {void}
1471
+ */
1472
+ stop(): void;
1473
+ /**
1474
+ * Request frames to be rendered in demand mode.
1475
+ * Accumulates pending frames (capped at 60) and starts the loop if not running.
1476
+ * No-op if frameloop is not 'demand'.
1477
+ * @param {number} [frames=1] - Number of frames to request
1478
+ * @param {boolean} [stackFrames=false] - Whether to add frames to existing pending count
1479
+ * - `false` (default): Sets pending frames to the specified value (replaces existing count)
1480
+ * - `true`: Adds frames to existing pending count (useful for accumulating invalidations)
1481
+ * @returns {void}
1482
+ * @example
1483
+ * // Request a single frame render
1484
+ * scheduler.invalidate();
1485
+ *
1486
+ * @example
1487
+ * // Request 5 frames (e.g., for animations)
1488
+ * scheduler.invalidate(5);
1489
+ *
1490
+ * @example
1491
+ * // Set pending frames to exactly 3 (don't stack with existing)
1492
+ * scheduler.invalidate(3, false);
1493
+ *
1494
+ * @example
1495
+ * // Add 2 more frames to existing pending count
1496
+ * scheduler.invalidate(2, true);
1497
+ */
1498
+ invalidate(frames?: number, stackFrames?: boolean): void;
1499
+ /**
1500
+ * Reset timing state for deterministic testing.
1501
+ * Preserves jobs and roots but resets lastTime, frameCount, elapsedTime, etc.
1502
+ * @returns {void}
1503
+ */
1504
+ resetTiming(): void;
1505
+ /**
1506
+ * Manually execute a single frame for all roots.
1507
+ * Useful for frameloop='never' mode or testing scenarios.
1508
+ * @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
1509
+ * @returns {void}
1510
+ * @example
1511
+ * // Manual control mode
1512
+ * scheduler.frameloop = 'never';
1513
+ * scheduler.step(); // Execute one frame
1514
+ */
1515
+ step(timestamp?: number): void;
1516
+ /**
1517
+ * Manually execute a single job by its ID.
1518
+ * Useful for testing individual job callbacks in isolation.
1519
+ * @param {string} id - The job ID to step
1520
+ * @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
1521
+ * @returns {void}
1522
+ */
1523
+ stepJob(id: string, timestamp?: number): void;
1524
+ /**
1525
+ * Main RAF loop callback.
1526
+ * Executes frame, handles demand mode, and schedules next frame.
1527
+ * @param {number} timestamp - RAF timestamp in milliseconds
1528
+ * @returns {void}
1529
+ * @private
1530
+ */
1531
+ private loop;
1532
+ /**
1533
+ * Execute a single frame across all roots.
1534
+ * Order: globalBefore → each root's jobs → globalAfter
1535
+ * @param {number} timestamp - RAF timestamp in milliseconds
1536
+ * @returns {void}
1537
+ * @private
1538
+ */
1539
+ private executeFrame;
1540
+ /**
1541
+ * Run all global jobs from a job map.
1542
+ * Catches and logs errors without stopping execution.
1543
+ * @param {Map<string, GlobalJob>} jobs - The global jobs map to execute
1544
+ * @param {number} timestamp - RAF timestamp in milliseconds
1545
+ * @returns {void}
1546
+ * @private
1547
+ */
1548
+ private runGlobalJobs;
1549
+ /**
1550
+ * Execute all jobs for a single root in sorted order.
1551
+ * Rebuilds sorted job list if needed, then dispatches each job.
1552
+ * Errors are caught and propagated to the root's error boundary.
1553
+ * @param {RootEntry} root - The root entry to tick
1554
+ * @param {number} timestamp - RAF timestamp in milliseconds
1555
+ * @param {number} delta - Time since last frame in seconds
1556
+ * @returns {void}
1557
+ * @private
1558
+ */
1559
+ private tickRoot;
1560
+ /**
1561
+ * Get the total number of registered jobs across all roots.
1562
+ * Includes both per-root jobs and global before/after jobs.
1563
+ * @returns {number} Total job count
1564
+ */
1565
+ getJobCount(): number;
1566
+ /**
1567
+ * Get all registered job IDs across all roots.
1568
+ * Includes both per-root jobs and global before/after jobs.
1569
+ * @returns {string[]} Array of all job IDs
1570
+ */
1571
+ getJobIds(): string[];
1572
+ /**
1573
+ * Get the number of registered roots (Canvas instances).
1574
+ * @returns {number} Number of registered roots
1575
+ */
1576
+ getRootCount(): number;
1577
+ /**
1578
+ * Check if any user (non-system) jobs are registered in a specific phase.
1579
+ * Used by the default render job to know if a user has taken over rendering.
1580
+ *
1581
+ * @param phase The phase to check
1582
+ * @param rootId Optional root ID to check (checks all roots if not provided)
1583
+ * @returns true if any user jobs exist in the phase
1584
+ */
1585
+ hasUserJobsInPhase(phase: string, rootId?: string): boolean;
1586
+ /**
1587
+ * Generate a unique root ID for automatic root registration.
1588
+ * @returns {string} A unique root ID in the format 'root_N'
1589
+ */
1590
+ generateRootId(): string;
1591
+ /**
1592
+ * Generate a unique job ID.
1593
+ * @returns {string} A unique job ID in the format 'job_N'
1594
+ * @private
1595
+ */
1596
+ private generateJobId;
1597
+ /**
1598
+ * Normalize before/after constraints to a Set.
1599
+ * Handles undefined, single string, or array inputs.
1600
+ * @param {string | string[] | undefined} value - The constraint value(s)
1601
+ * @returns {Set<string>} Normalized Set of constraint strings
1602
+ * @private
1603
+ */
1604
+ private normalizeConstraints;
1605
+ }
1606
+ /**
1607
+ * Get the global scheduler instance.
1608
+ * Creates one if it doesn't exist.
1609
+ */
1610
+ declare const getScheduler: () => Scheduler;
1611
+
1612
+ /**
1613
+ * Frame hook with phase-based ordering, priority, and FPS throttling.
1614
+ *
1615
+ * Returns a controls object for manual stepping, pausing, and resuming.
1616
+ *
1617
+ * @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
1618
+ * @param priorityOrOptions - Either a priority number (backwards compat) or options object
1619
+ * @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
1620
+ *
1621
+ * @example
1622
+ * // Simple priority (backwards compat)
1623
+ * useFrame((state, delta) => { ... }, 5)
1624
+ *
1625
+ * @example
1626
+ * // With phase-based ordering
1627
+ * useFrame((state, delta) => { ... }, { phase: 'physics' })
1628
+ *
1629
+ * @example
1630
+ * // With controls
1631
+ * const controls = useFrame(cb, { phase: 'physics', id: 'my-physics' })
1632
+ * controls.step() // Step this job only
1633
+ * controls.stepAll() // Step all jobs
1634
+ * controls.pause() // Pause this job
1635
+ * controls.resume() // Resume this job
1636
+ *
1637
+ * @example
1638
+ * // Manual mode (frameloop='never')
1639
+ * const { stepAll } = useFrame(cb)
1640
+ * // In your animation controller:
1641
+ * stepAll() // Advance all useFrame jobs
1642
+ *
1643
+ * @example
1644
+ * // Scheduler-only access (no callback)
1645
+ * const { scheduler } = useFrame()
1646
+ * scheduler.pauseJob('some-job-id')
1647
+ *
1648
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
1649
+ */
1650
+ declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
1651
+
1652
+ declare const IsObject: (url: unknown) => url is Record<string, string>;
1653
+ type TextureArray<T> = T extends string[] ? Texture$1[] : never;
1654
+ type TextureRecord<T> = T extends Record<string, string> ? {
1655
+ [key in keyof T]: Texture$1;
1656
+ } : never;
1657
+ type SingleTexture<T> = T extends string ? Texture$1 : never;
1658
+ type MappedTextureType<T extends string[] | string | Record<string, string>> = TextureArray<T> | TextureRecord<T> | SingleTexture<T>;
1659
+ /** Options for useTexture hook */
1660
+ type UseTextureOptions<Url extends string[] | string | Record<string, string>> = {
1661
+ /** Callback when texture(s) finish loading */
1662
+ onLoad?: (texture: MappedTextureType<Url>) => void;
1663
+ /**
1664
+ * Cache the texture in R3F's global state for access via useTextures().
1665
+ * When true:
1666
+ * - Textures persist until explicitly disposed
1667
+ * - Returns existing cached textures if available (preserving modifications like colorSpace)
1668
+ * @default false
1669
+ */
1670
+ cache?: boolean;
1671
+ };
1672
+ /**
1673
+ * Load texture(s) using Three's TextureLoader with Suspense support.
1674
+ *
1675
+ * @param input - URL string, array of URLs, or object mapping keys to URLs
1676
+ * @param optionsOrOnLoad - Options object or legacy onLoad callback
1677
+ *
1678
+ * @example
1679
+ * ```tsx
1680
+ * // Single texture
1681
+ * const diffuse = useTexture('/textures/diffuse.png')
1682
+ *
1683
+ * // Multiple textures (array)
1684
+ * const [diffuse, normal] = useTexture(['/diffuse.png', '/normal.png'])
1685
+ *
1686
+ * // Named textures (object)
1687
+ * const { diffuse, normal } = useTexture({
1688
+ * diffuse: '/diffuse.png',
1689
+ * normal: '/normal.png'
1690
+ * })
1691
+ *
1692
+ * // With caching - returns same texture object across components
1693
+ * // Modifications (colorSpace, wrapS, etc.) are preserved
1694
+ * const diffuse = useTexture('/diffuse.png', { cache: true })
1695
+ * diffuse.colorSpace = THREE.SRGBColorSpace
1696
+ *
1697
+ * // Another component gets the SAME texture with colorSpace already set
1698
+ * const sameDiffuse = useTexture('/diffuse.png', { cache: true })
1699
+ *
1700
+ * // Access cache directly
1701
+ * const { get } = useTextures()
1702
+ * const cached = get('/diffuse.png')
1703
+ * ```
1704
+ */
1705
+ declare function useTexture<Url extends string[] | string | Record<string, string>>(input: Url, optionsOrOnLoad?: UseTextureOptions<Url> | ((texture: MappedTextureType<Url>) => void)): MappedTextureType<Url>;
1706
+ declare namespace useTexture {
1707
+ var preload: (url: string | string[]) => void;
1708
+ var clear: (input: string | string[]) => void;
1709
+ }
1710
+ declare const Texture: ({ children, input, onLoad, cache, }: {
1711
+ children?: (texture: ReturnType<typeof useTexture>) => ReactNode;
1712
+ input: Parameters<typeof useTexture>[0];
1713
+ onLoad?: Parameters<typeof useTexture>[1];
1714
+ cache?: boolean;
1715
+ }) => react_jsx_runtime.JSX.Element;
1716
+
1717
+ type TextureEntry = Texture$1 | {
1718
+ value: Texture$1;
1719
+ [key: string]: any;
1720
+ };
1721
+ interface UseTexturesReturn {
1722
+ /** Map of all textures currently in cache */
1723
+ textures: Map<string, TextureEntry>;
1724
+ /** Get a specific texture by key (usually URL) */
1725
+ get: (key: string) => TextureEntry | undefined;
1726
+ /** Check if a texture exists in cache */
1727
+ has: (key: string) => boolean;
1728
+ /** Add a texture to the cache */
1729
+ add: (key: string, value: TextureEntry) => void;
1730
+ /** Add multiple textures to the cache */
1731
+ addMultiple: (items: Map<string, TextureEntry> | Record<string, TextureEntry>) => void;
1732
+ /** Remove a texture from cache (does NOT dispose GPU resources) */
1733
+ remove: (key: string) => void;
1734
+ /** Remove multiple textures from cache */
1735
+ removeMultiple: (keys: string[]) => void;
1736
+ /** Dispose a texture's GPU resources and remove from cache */
1737
+ dispose: (key: string) => void;
1738
+ /** Dispose multiple textures */
1739
+ disposeMultiple: (keys: string[]) => void;
1740
+ /** Dispose ALL cached textures - use with caution */
1741
+ disposeAll: () => void;
1742
+ }
1743
+ /**
1744
+ * Hook for managing the global texture cache in R3F state.
1745
+ *
1746
+ * Textures are stored in a Map with URL/path keys for efficient lookup.
1747
+ * Useful for sharing texture references across materials and components.
1748
+ *
1749
+ * @example
1750
+ * ```tsx
1751
+ * const { textures, add, get, remove, has, dispose } = useTextures()
1752
+ *
1753
+ * // Check if texture is already cached
1754
+ * if (!has('/textures/diffuse.png')) {
1755
+ * // Load with useTexture and cache: true, or manually add
1756
+ * const tex = useTexture('/textures/diffuse.png', { cache: true })
1757
+ * }
1758
+ *
1759
+ * // Access cached texture from anywhere
1760
+ * const diffuse = get('/textures/diffuse.png')
1761
+ * if (diffuse) material.map = diffuse
1762
+ *
1763
+ * // Remove from cache only (texture still in GPU memory)
1764
+ * remove('/textures/old.png')
1765
+ *
1766
+ * // Fully dispose (frees GPU memory + removes from cache)
1767
+ * dispose('/textures/unused.png')
1768
+ *
1769
+ * // Nuclear option - dispose everything
1770
+ * disposeAll()
1771
+ * ```
1772
+ */
1773
+ declare function useTextures(): UseTexturesReturn;
1774
+
1775
+ /**
1776
+ * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
1777
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
1778
+ */
1779
+ declare function useStore(): RootStore;
1780
+ /**
1781
+ * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
1782
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
1783
+ */
1784
+ declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
1785
+ /**
1786
+ * Exposes an object's {@link Instance}.
1787
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
1788
+ *
1789
+ * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
1790
+ */
1791
+ declare function useInstanceHandle<T>(ref: React.RefObject<T>): React.RefObject<Instance<T>>;
1792
+ /**
1793
+ * Returns a node graph of an object with named nodes & materials.
1794
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
1795
+ */
1796
+ declare function useGraph(object: Object3D): ObjectMap;
1797
+
1798
+ /**
1799
+ * Adds a global render callback which is called each frame BEFORE rendering.
1800
+ *
1801
+ * @deprecated Use `useFrame(callback, { phase: 'start' })` instead.
1802
+ * This function will be removed in a future version.
1803
+ *
1804
+ * @param callback - Function called each frame with timestamp
1805
+ * @returns Unsubscribe function
1806
+ *
1807
+ * @example
1808
+ * // OLD (deprecated)
1809
+ * const unsub = addEffect((timestamp) => { ... })
1810
+ *
1811
+ * // NEW
1812
+ * useFrame((state, delta) => { ... }, { phase: 'start' })
1813
+ *
1814
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
1815
+ */
1816
+ declare function addEffect(callback: GlobalRenderCallback): () => void;
1817
+ /**
1818
+ * Adds a global after-render callback which is called each frame AFTER rendering.
1819
+ *
1820
+ * @deprecated Use `useFrame(callback, { phase: 'finish' })` instead.
1821
+ * This function will be removed in a future version.
1822
+ *
1823
+ * @param callback - Function called each frame with timestamp
1824
+ * @returns Unsubscribe function
1825
+ *
1826
+ * @example
1827
+ * // OLD (deprecated)
1828
+ * const unsub = addAfterEffect((timestamp) => { ... })
1829
+ *
1830
+ * // NEW
1831
+ * useFrame((state, delta) => { ... }, { phase: 'finish' })
1832
+ *
1833
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
1834
+ */
1835
+ declare function addAfterEffect(callback: GlobalRenderCallback): () => void;
1836
+ /**
1837
+ * Adds a global callback which is called when rendering stops.
1838
+ *
1839
+ * @deprecated Use `scheduler.onIdle(callback)` instead.
1840
+ * This function will be removed in a future version.
1841
+ *
1842
+ * @param callback - Function called when rendering stops
1843
+ * @returns Unsubscribe function
1844
+ *
1845
+ * @example
1846
+ * // OLD (deprecated)
1847
+ * const unsub = addTail((timestamp) => { ... })
1848
+ *
1849
+ * // NEW
1850
+ * const { scheduler } = useFrame()
1851
+ * const unsub = scheduler.onIdle((timestamp) => { ... })
1852
+ *
1853
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
1854
+ */
1855
+ declare function addTail(callback: GlobalRenderCallback): () => void;
1856
+ /**
1857
+ * Invalidates the view, requesting a frame to be rendered.
1858
+ * In demand mode, this triggers the scheduler to run frames.
1859
+ *
1860
+ * @param state - Optional root state (ignored in new scheduler, kept for backwards compat)
1861
+ * @param frames - Number of frames to request (default: 1)
1862
+ * @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
1863
+ *
1864
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
1865
+ */
1866
+ declare function invalidate(state?: RootState, frames?: number, stackFrames?: boolean): void;
1867
+ /**
1868
+ * Advances the frameloop and runs render effects.
1869
+ * Useful for when manually rendering via `frameloop="never"`.
1870
+ *
1871
+ * @param timestamp - The timestamp to use for this frame
1872
+ * @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
1873
+ * @param state - Ignored (kept for backwards compat)
1874
+ * @param frame - Ignored (kept for backwards compat)
1875
+ *
1876
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
1877
+ */
1878
+ declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame): void;
1879
+
1880
+ /* eslint-disable @definitelytyped/no-unnecessary-generics */
1881
+ declare function ReactReconciler<
1882
+ Type,
1883
+ Props,
1884
+ Container,
1885
+ Instance,
1886
+ TextInstance,
1887
+ SuspenseInstance,
1888
+ HydratableInstance,
1889
+ FormInstance,
1890
+ PublicInstance,
1891
+ HostContext,
1892
+ ChildSet,
1893
+ TimeoutHandle,
1894
+ NoTimeout,
1895
+ TransitionStatus,
1896
+ >(
1897
+ /* eslint-enable @definitelytyped/no-unnecessary-generics */
1898
+ config: ReactReconciler.HostConfig<
1899
+ Type,
1900
+ Props,
1901
+ Container,
1902
+ Instance,
1903
+ TextInstance,
1904
+ SuspenseInstance,
1905
+ HydratableInstance,
1906
+ FormInstance,
1907
+ PublicInstance,
1908
+ HostContext,
1909
+ ChildSet,
1910
+ TimeoutHandle,
1911
+ NoTimeout,
1912
+ TransitionStatus
1913
+ >,
1914
+ ): ReactReconciler.Reconciler<Container, Instance, TextInstance, SuspenseInstance, FormInstance, PublicInstance>;
1915
+
1916
+ declare namespace ReactReconciler {
1917
+ interface HostConfig<
1918
+ Type,
1919
+ Props,
1920
+ Container,
1921
+ Instance,
1922
+ TextInstance,
1923
+ SuspenseInstance,
1924
+ HydratableInstance,
1925
+ FormInstance,
1926
+ PublicInstance,
1927
+ HostContext,
1928
+ ChildSet,
1929
+ TimeoutHandle,
1930
+ NoTimeout,
1931
+ TransitionStatus,
1932
+ > {
1933
+ // -------------------
1934
+ // Modes
1935
+ // -------------------
1936
+ /**
1937
+ * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.
1938
+ *
1939
+ * 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.
1940
+ *
1941
+ * ```js
1942
+ * const HostConfig = {
1943
+ * // ...
1944
+ * supportsMutation: true,
1945
+ * // ...
1946
+ * }
1947
+ * ```
1948
+ *
1949
+ * Depending on the mode, the reconciler will call different methods on your host config.
1950
+ *
1951
+ * If you're not sure which one you want, you likely need the mutation mode.
1952
+ */
1953
+ supportsMutation: boolean;
1954
+
1955
+ /**
1956
+ * The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.
1957
+ *
1958
+ * 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".
1959
+ *
1960
+ * ```js
1961
+ * const HostConfig = {
1962
+ * // ...
1963
+ * supportsPersistence: true,
1964
+ * // ...
1965
+ * }
1966
+ * ```
1967
+ *
1968
+ * Depending on the mode, the reconciler will call different methods on your host config.
1969
+ *
1970
+ * If you're not sure which one you want, you likely need the mutation mode.
1971
+ */
1972
+ supportsPersistence: boolean;
1973
+
1974
+ // -------------------
1975
+ // Core Methods
1976
+ // -------------------
1977
+
1978
+ /**
1979
+ * 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`.
1980
+ *
1981
+ * 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.
1982
+ *
1983
+ * 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.
1984
+ *
1985
+ * 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.
1986
+ *
1987
+ * 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.
1988
+ */
1989
+ createInstance(
1990
+ type: Type,
1991
+ props: Props,
1992
+ rootContainer: Container,
1993
+ hostContext: HostContext,
1994
+ internalHandle: OpaqueHandle,
1995
+ ): Instance;
1996
+
1997
+ /**
1998
+ * Same as `createInstance`, but for text nodes. If your renderer doesn't support text nodes, you can throw here.
1999
+ */
2000
+ createTextInstance(
2001
+ text: string,
2002
+ rootContainer: Container,
2003
+ hostContext: HostContext,
2004
+ internalHandle: OpaqueHandle,
2005
+ ): TextInstance;
2006
+
2007
+ /**
2008
+ * 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.
2009
+ *
2010
+ * 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.
2011
+ */
2012
+ appendInitialChild(parentInstance: Instance, child: Instance | TextInstance): void;
2013
+
2014
+ /**
2015
+ * 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.
2016
+ *
2017
+ * 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.
2018
+ *
2019
+ * 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.
2020
+ *
2021
+ * If you don't want to do anything here, you should return `false`.
2022
+ */
2023
+ finalizeInitialChildren(
2024
+ instance: Instance,
2025
+ type: Type,
2026
+ props: Props,
2027
+ rootContainer: Container,
2028
+ hostContext: HostContext,
2029
+ ): boolean;
2030
+
2031
+ /**
2032
+ * 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.
2033
+ *
2034
+ * 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.
2035
+ *
2036
+ * If you don't want to do anything here, you should return `false`.
2037
+ *
2038
+ * This method happens **in the render phase**. Do not mutate the tree from it.
2039
+ */
2040
+ shouldSetTextContent(type: Type, props: Props): boolean;
2041
+
2042
+ /**
2043
+ * This method lets you return the initial host context from the root of the tree. See `getChildHostContext` for the explanation of host context.
2044
+ *
2045
+ * If you don't intend to use host context, you can return `null`.
2046
+ *
2047
+ * This method happens **in the render phase**. Do not mutate the tree from it.
2048
+ */
2049
+ getRootHostContext(rootContainer: Container): HostContext | null;
2050
+
2051
+ /**
2052
+ * 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.
2053
+ *
2054
+ * 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.
2055
+ *
2056
+ * If you don't want to do anything here, return `parentHostContext`.
2057
+ *
2058
+ * This method happens **in the render phase**. Do not mutate the tree from it.
2059
+ */
2060
+ getChildHostContext(parentHostContext: HostContext, type: Type, rootContainer: Container): HostContext;
2061
+
2062
+ /**
2063
+ * 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.
2064
+ *
2065
+ * If you don't want to do anything here, return `instance`.
2066
+ */
2067
+ getPublicInstance(instance: Instance | TextInstance): PublicInstance;
2068
+
2069
+ /**
2070
+ * 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`.
2071
+ *
2072
+ * Even if you don't want to do anything here, you need to return `null` from it.
2073
+ */
2074
+ prepareForCommit(containerInfo: Container): Record<string, any> | null;
2075
+
2076
+ /**
2077
+ * 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.
2078
+ *
2079
+ * You can leave it empty.
2080
+ */
2081
+ resetAfterCommit(containerInfo: Container): void;
2082
+
2083
+ /**
2084
+ * This method is called for a container that's used as a portal target. Usually you can leave it empty.
2085
+ */
2086
+ preparePortalMount(containerInfo: Container): void;
2087
+
2088
+ /**
2089
+ * You can proxy this to `setTimeout` or its equivalent in your environment.
2090
+ */
2091
+ scheduleTimeout(fn: (...args: unknown[]) => unknown, delay?: number): TimeoutHandle;
2092
+
2093
+ /**
2094
+ * You can proxy this to `clearTimeout` or its equivalent in your environment.
2095
+ */
2096
+ cancelTimeout(id: TimeoutHandle): void;
2097
+
2098
+ /**
2099
+ * 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`.
2100
+ */
2101
+ noTimeout: NoTimeout;
2102
+
2103
+ /**
2104
+ * 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.
2105
+ */
2106
+ supportsMicrotasks?: boolean;
2107
+
2108
+ /**
2109
+ * Optional. You can proxy this to `queueMicrotask` or its equivalent in your environment.
2110
+ */
2111
+ scheduleMicrotask?(fn: () => unknown): void;
2112
+
2113
+ /**
2114
+ * 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`.
2115
+ */
2116
+ isPrimaryRenderer: boolean;
2117
+
2118
+ /**
2119
+ * Whether the renderer shouldn't trigger missing `act()` warnings
2120
+ */
2121
+ warnsIfNotActing?: boolean;
2122
+
2123
+ getInstanceFromNode(node: any): Fiber | null | undefined;
2124
+
2125
+ beforeActiveInstanceBlur(): void;
2126
+
2127
+ afterActiveInstanceBlur(): void;
2128
+
2129
+ prepareScopeUpdate(scopeInstance: any, instance: any): void;
2130
+
2131
+ getInstanceFromScope(scopeInstance: any): null | Instance;
2132
+
2133
+ detachDeletedInstance(node: Instance): void;
2134
+
2135
+ // -------------------
2136
+ // Mutation Methods
2137
+ // (optional)
2138
+ // If you're using React in mutation mode (you probably do), you'll need to implement a few more methods.
2139
+ // -------------------
2140
+
2141
+ /**
2142
+ * 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.
2143
+ *
2144
+ * 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`.
2145
+ */
2146
+ appendChild?(parentInstance: Instance, child: Instance | TextInstance): void;
2147
+
2148
+ /**
2149
+ * 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.
2150
+ */
2151
+ appendChildToContainer?(container: Container, child: Instance | TextInstance): void;
2152
+
2153
+ /**
2154
+ * 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.
2155
+ *
2156
+ * 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.
2157
+ */
2158
+ insertBefore?(
2159
+ parentInstance: Instance,
2160
+ child: Instance | TextInstance,
2161
+ beforeChild: Instance | TextInstance | SuspenseInstance,
2162
+ ): void;
2163
+
2164
+ /**
2165
+ * 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.
2166
+ */
2167
+ insertInContainerBefore?(
2168
+ container: Container,
2169
+ child: Instance | TextInstance,
2170
+ beforeChild: Instance | TextInstance | SuspenseInstance,
2171
+ ): void;
2172
+
2173
+ /**
2174
+ * This method should mutate the `parentInstance` to remove the `child` from the list of its children.
2175
+ *
2176
+ * 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.
2177
+ */
2178
+ removeChild?(parentInstance: Instance, child: Instance | TextInstance | SuspenseInstance): void;
2179
+
2180
+ /**
2181
+ * 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.
2182
+ */
2183
+ removeChildFromContainer?(container: Container, child: Instance | TextInstance | SuspenseInstance): void;
2184
+
2185
+ /**
2186
+ * 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 = ''`.
2187
+ *
2188
+ * If you never return `true` from `shouldSetTextContent`, you can leave it empty.
2189
+ */
2190
+ resetTextContent?(instance: Instance): void;
2191
+
2192
+ /**
2193
+ * This method should mutate the `textInstance` and update its text content to `nextText`.
2194
+ *
2195
+ * Here, `textInstance` is a node created by `createTextInstance`.
2196
+ */
2197
+ commitTextUpdate?(textInstance: TextInstance, oldText: string, newText: string): void;
2198
+
2199
+ /**
2200
+ * This method is only called if you returned `true` from `finalizeInitialChildren` for this instance.
2201
+ *
2202
+ * 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.
2203
+ *
2204
+ * 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.
2205
+ *
2206
+ * 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.
2207
+ *
2208
+ * If you never return `true` from `finalizeInitialChildren`, you can leave it empty.
2209
+ */
2210
+ commitMount?(instance: Instance, type: Type, props: Props, internalInstanceHandle: OpaqueHandle): void;
2211
+
2212
+ /**
2213
+ * This method should mutate the instance to match nextProps.
2214
+ *
2215
+ * 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.
2216
+ */
2217
+ commitUpdate?(
2218
+ instance: Instance,
2219
+ type: Type,
2220
+ prevProps: Props,
2221
+ nextProps: Props,
2222
+ internalHandle: OpaqueHandle,
2223
+ ): void;
2224
+
2225
+ /**
2226
+ * 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.
2227
+ */
2228
+ hideInstance?(instance: Instance): void;
2229
+
2230
+ /**
2231
+ * Same as `hideInstance`, but for nodes created by `createTextInstance`.
2232
+ */
2233
+ hideTextInstance?(textInstance: TextInstance): void;
2234
+
2235
+ /**
2236
+ * This method should make the `instance` visible, undoing what `hideInstance` did.
2237
+ */
2238
+ unhideInstance?(instance: Instance, props: Props): void;
2239
+
2240
+ /**
2241
+ * Same as `unhideInstance`, but for nodes created by `createTextInstance`.
2242
+ */
2243
+ unhideTextInstance?(textInstance: TextInstance, text: string): void;
2244
+
2245
+ /**
2246
+ * This method should mutate the `container` root node and remove all children from it.
2247
+ */
2248
+ clearContainer?(container: Container): void;
2249
+
2250
+ // -------------------
2251
+ // Persistence Methods
2252
+ // (optional)
2253
+ // 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.
2254
+ // -------------------
2255
+ cloneInstance?(
2256
+ instance: Instance,
2257
+ type: Type,
2258
+ oldProps: Props,
2259
+ newProps: Props,
2260
+ keepChildren: boolean,
2261
+ recyclableInstance: null | Instance,
2262
+ ): Instance;
2263
+ createContainerChildSet?(container: Container): ChildSet;
2264
+ appendChildToContainerChildSet?(childSet: ChildSet, child: Instance | TextInstance): void;
2265
+ finalizeContainerChildren?(container: Container, newChildren: ChildSet): void;
2266
+ replaceContainerChildren?(container: Container, newChildren: ChildSet): void;
2267
+ cloneHiddenInstance?(
2268
+ instance: Instance,
2269
+ type: Type,
2270
+ props: Props,
2271
+ internalInstanceHandle: OpaqueHandle,
2272
+ ): Instance;
2273
+ cloneHiddenTextInstance?(instance: Instance, text: Type, internalInstanceHandle: OpaqueHandle): TextInstance;
2274
+
2275
+ // -------------------
2276
+ // Hydration Methods
2277
+ // (optional)
2278
+ // 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.
2279
+ //
2280
+ // 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.
2281
+ // -------------------
2282
+ supportsHydration: boolean;
2283
+
2284
+ canHydrateInstance?(instance: HydratableInstance, type: Type, props: Props): null | Instance;
2285
+
2286
+ canHydrateTextInstance?(instance: HydratableInstance, text: string): null | TextInstance;
2287
+
2288
+ canHydrateSuspenseInstance?(instance: HydratableInstance): null | SuspenseInstance;
2289
+
2290
+ isSuspenseInstancePending?(instance: SuspenseInstance): boolean;
2291
+
2292
+ isSuspenseInstanceFallback?(instance: SuspenseInstance): boolean;
2293
+
2294
+ registerSuspenseInstanceRetry?(instance: SuspenseInstance, callback: () => void): void;
2295
+
2296
+ getNextHydratableSibling?(instance: HydratableInstance): null | HydratableInstance;
2297
+
2298
+ getFirstHydratableChild?(parentInstance: Container | Instance): null | HydratableInstance;
2299
+
2300
+ hydrateInstance?(
2301
+ instance: Instance,
2302
+ type: Type,
2303
+ props: Props,
2304
+ rootContainerInstance: Container,
2305
+ hostContext: HostContext,
2306
+ internalInstanceHandle: any,
2307
+ ): null | any[];
2308
+
2309
+ hydrateTextInstance?(textInstance: TextInstance, text: string, internalInstanceHandle: any): boolean;
2310
+
2311
+ hydrateSuspenseInstance?(suspenseInstance: SuspenseInstance, internalInstanceHandle: any): void;
2312
+
2313
+ getNextHydratableInstanceAfterSuspenseInstance?(suspenseInstance: SuspenseInstance): null | HydratableInstance;
2314
+
2315
+ // Returns the SuspenseInstance if this node is a direct child of a
2316
+ // SuspenseInstance. I.e. if its previous sibling is a Comment with
2317
+ // SUSPENSE_x_START_DATA. Otherwise, null.
2318
+ getParentSuspenseInstance?(targetInstance: any): null | SuspenseInstance;
2319
+
2320
+ commitHydratedContainer?(container: Container): void;
2321
+
2322
+ commitHydratedSuspenseInstance?(suspenseInstance: SuspenseInstance): void;
2323
+
2324
+ didNotMatchHydratedContainerTextInstance?(
2325
+ parentContainer: Container,
2326
+ textInstance: TextInstance,
2327
+ text: string,
2328
+ ): void;
2329
+
2330
+ didNotMatchHydratedTextInstance?(
2331
+ parentType: Type,
2332
+ parentProps: Props,
2333
+ parentInstance: Instance,
2334
+ textInstance: TextInstance,
2335
+ text: string,
2336
+ ): void;
2337
+
2338
+ didNotHydrateContainerInstance?(parentContainer: Container, instance: HydratableInstance): void;
2339
+
2340
+ didNotHydrateInstance?(
2341
+ parentType: Type,
2342
+ parentProps: Props,
2343
+ parentInstance: Instance,
2344
+ instance: HydratableInstance,
2345
+ ): void;
2346
+
2347
+ didNotFindHydratableContainerInstance?(parentContainer: Container, type: Type, props: Props): void;
2348
+
2349
+ didNotFindHydratableContainerTextInstance?(parentContainer: Container, text: string): void;
2350
+
2351
+ didNotFindHydratableContainerSuspenseInstance?(parentContainer: Container): void;
2352
+
2353
+ didNotFindHydratableInstance?(
2354
+ parentType: Type,
2355
+ parentProps: Props,
2356
+ parentInstance: Instance,
2357
+ type: Type,
2358
+ props: Props,
2359
+ ): void;
2360
+
2361
+ didNotFindHydratableTextInstance?(
2362
+ parentType: Type,
2363
+ parentProps: Props,
2364
+ parentInstance: Instance,
2365
+ text: string,
2366
+ ): void;
2367
+
2368
+ didNotFindHydratableSuspenseInstance?(parentType: Type, parentProps: Props, parentInstance: Instance): void;
2369
+
2370
+ errorHydratingContainer?(parentContainer: Container): void;
2371
+
2372
+ // Undocumented
2373
+ // https://github.com/facebook/react/pull/26722
2374
+ NotPendingTransition: TransitionStatus | null;
2375
+ HostTransitionContext: ReactContext<TransitionStatus>;
2376
+
2377
+ // https://github.com/facebook/react/pull/28751
2378
+ setCurrentUpdatePriority(newPriority: EventPriority): void;
2379
+ getCurrentUpdatePriority(): EventPriority;
2380
+ resolveUpdatePriority(): EventPriority;
2381
+
2382
+ // https://github.com/facebook/react/pull/28804
2383
+ resetFormInstance(form: FormInstance): void;
2384
+
2385
+ // https://github.com/facebook/react/pull/25105
2386
+ requestPostPaintCallback(callback: (time: number) => void): void;
2387
+
2388
+ // https://github.com/facebook/react/pull/26025
2389
+ shouldAttemptEagerTransition(): boolean;
2390
+
2391
+ // https://github.com/facebook/react/pull/31528
2392
+ trackSchedulerEvent(): void;
2393
+
2394
+ // https://github.com/facebook/react/pull/31008
2395
+ resolveEventType(): null | string;
2396
+ resolveEventTimeStamp(): number;
2397
+
2398
+ /**
2399
+ * 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.
2400
+ */
2401
+ maySuspendCommit(type: Type, props: Props): boolean;
2402
+
2403
+ /**
2404
+ * 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.
2405
+ */
2406
+ preloadInstance(type: Type, props: Props): boolean;
2407
+
2408
+ /**
2409
+ * 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.
2410
+ */
2411
+ startSuspendingCommit(): void;
2412
+
2413
+ /**
2414
+ * This method is called after `startSuspendingCommit` for each Host Component that indicated it might suspend a commit.
2415
+ */
2416
+ suspendInstance(type: Type, props: Props): void;
2417
+
2418
+ /**
2419
+ * This method is called after all `suspendInstance` calls are complete.
2420
+ *
2421
+ * Return `null` if the commit can happen immediately.
2422
+ *
2423
+ * 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.
2424
+ */
2425
+ waitForCommitToBeReady():
2426
+ | ((initiateCommit: (...args: unknown[]) => unknown) => (...args: unknown[]) => unknown)
2427
+ | null;
2428
+ }
2429
+
2430
+ interface Thenable<T> {
2431
+ then(resolve: () => T, reject?: () => T): T;
2432
+ }
2433
+
2434
+ type RootTag = 0 | 1 | 2;
2435
+
2436
+ type WorkTag =
2437
+ | 0
2438
+ | 1
2439
+ | 2
2440
+ | 3
2441
+ | 4
2442
+ | 5
2443
+ | 6
2444
+ | 7
2445
+ | 8
2446
+ | 9
2447
+ | 10
2448
+ | 11
2449
+ | 12
2450
+ | 13
2451
+ | 14
2452
+ | 15
2453
+ | 16
2454
+ | 17
2455
+ | 18
2456
+ | 19
2457
+ | 20
2458
+ | 21
2459
+ | 22
2460
+ | 23
2461
+ | 24;
2462
+
2463
+ type HookType =
2464
+ | "useState"
2465
+ | "useReducer"
2466
+ | "useContext"
2467
+ | "useRef"
2468
+ | "useEffect"
2469
+ | "useLayoutEffect"
2470
+ | "useCallback"
2471
+ | "useMemo"
2472
+ | "useImperativeHandle"
2473
+ | "useDebugValue"
2474
+ | "useDeferredValue"
2475
+ | "useTransition"
2476
+ | "useMutableSource"
2477
+ | "useOpaqueIdentifier"
2478
+ | "useCacheRefresh";
2479
+
2480
+ interface Source {
2481
+ fileName: string;
2482
+ lineNumber: number;
2483
+ }
2484
+
2485
+ // TODO: Ideally these types would be opaque but that doesn't work well with
2486
+ // our reconciler fork infra, since these leak into non-reconciler packages.
2487
+ type LanePriority = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17;
2488
+
2489
+ type Lanes = number;
2490
+ type Lane = number;
2491
+
2492
+ type Flags = number;
2493
+
2494
+ type TypeOfMode = number;
2495
+
2496
+ type EventPriority = number;
2497
+
2498
+ interface ReactProvider<T> {
2499
+ $$typeof: symbol | number;
2500
+ type: ReactProviderType<T>;
2501
+ key: null | string;
2502
+ ref: null;
2503
+ props: {
2504
+ value: T;
2505
+ children?: ReactNode;
2506
+ };
2507
+ }
2508
+
2509
+ interface ReactProviderType<T> {
2510
+ $$typeof: symbol | number;
2511
+ _context: ReactContext<T>;
2512
+ }
2513
+
2514
+ interface ReactConsumer<T> {
2515
+ $$typeof: symbol | number;
2516
+ type: ReactContext<T>;
2517
+ key: null | string;
2518
+ ref: null;
2519
+ props: {
2520
+ children: (value: T) => ReactNode;
2521
+ unstable_observedBits?: number;
2522
+ };
2523
+ }
2524
+
2525
+ interface ReactContext<T> {
2526
+ $$typeof: symbol | number;
2527
+ Consumer: ReactContext<T>;
2528
+ Provider: ReactProviderType<T>;
2529
+ _currentValue: T;
2530
+ _currentValue2: T;
2531
+ _threadCount: number;
2532
+ // DEV only
2533
+ _currentRenderer?: {
2534
+ [key: string]: any;
2535
+ } | null;
2536
+ _currentRenderer2?: {
2537
+ [key: string]: any;
2538
+ } | null;
2539
+ // This value may be added by application code
2540
+ // to improve DEV tooling display names
2541
+ displayName?: string;
2542
+ }
2543
+
2544
+ interface ReactPortal {
2545
+ $$typeof: symbol | number;
2546
+ key: null | string;
2547
+ containerInfo: any;
2548
+ children: ReactNode;
2549
+ // TODO: figure out the API for cross-renderer implementation.
2550
+ implementation: any;
2551
+ }
2552
+
2553
+ interface RefObject {
2554
+ current: any;
2555
+ }
2556
+
2557
+ interface ContextDependency<T> {
2558
+ context: ReactContext<T>;
2559
+ observedBits: number;
2560
+ next: ContextDependency<unknown> | null;
2561
+ }
2562
+
2563
+ interface Dependencies {
2564
+ lanes: Lanes;
2565
+ firstContext: ContextDependency<unknown> | null;
2566
+ }
2567
+
2568
+ interface Fiber {
2569
+ // These first fields are conceptually members of an Instance. This used to
2570
+ // be split into a separate type and intersected with the other Fiber fields,
2571
+ // but until Flow fixes its intersection bugs, we've merged them into a
2572
+ // single type.
2573
+
2574
+ // An Instance is shared between all versions of a component. We can easily
2575
+ // break this out into a separate object to avoid copying so much to the
2576
+ // alternate versions of the tree. We put this on a single object for now to
2577
+ // minimize the number of objects created during the initial render.
2578
+
2579
+ // Tag identifying the type of fiber.
2580
+ tag: WorkTag;
2581
+
2582
+ // Unique identifier of this child.
2583
+ key: null | string;
2584
+
2585
+ // The value of element.type which is used to preserve the identity during
2586
+ // reconciliation of this child.
2587
+ elementType: any;
2588
+
2589
+ // The resolved function/class/ associated with this fiber.
2590
+ type: any;
2591
+
2592
+ // The local state associated with this fiber.
2593
+ stateNode: any;
2594
+
2595
+ // Conceptual aliases
2596
+ // parent : Instance -> return The parent happens to be the same as the
2597
+ // return fiber since we've merged the fiber and instance.
2598
+
2599
+ // Remaining fields belong to Fiber
2600
+
2601
+ // The Fiber to return to after finishing processing this one.
2602
+ // This is effectively the parent, but there can be multiple parents (two)
2603
+ // so this is only the parent of the thing we're currently processing.
2604
+ // It is conceptually the same as the return address of a stack frame.
2605
+ return: Fiber | null;
2606
+
2607
+ // Singly Linked List Tree Structure.
2608
+ child: Fiber | null;
2609
+ sibling: Fiber | null;
2610
+ index: number;
2611
+
2612
+ // The ref last used to attach this node.
2613
+ // I'll avoid adding an owner field for prod and model that as functions.
2614
+ ref:
2615
+ | null
2616
+ | (((handle: unknown) => void) & {
2617
+ _stringRef?: string | null;
2618
+ })
2619
+ | RefObject;
2620
+
2621
+ // Input is the data coming into process this fiber. Arguments. Props.
2622
+ pendingProps: any; // This type will be more specific once we overload the tag.
2623
+ memoizedProps: any; // The props used to create the output.
2624
+
2625
+ // A queue of state updates and callbacks.
2626
+ updateQueue: unknown;
2627
+
2628
+ // The state used to create the output
2629
+ memoizedState: any;
2630
+
2631
+ // Dependencies (contexts, events) for this fiber, if it has any
2632
+ dependencies: Dependencies | null;
2633
+
2634
+ // Bitfield that describes properties about the fiber and its subtree. E.g.
2635
+ // the ConcurrentMode flag indicates whether the subtree should be async-by-
2636
+ // default. When a fiber is created, it inherits the mode of its
2637
+ // parent. Additional flags can be set at creation time, but after that the
2638
+ // value should remain unchanged throughout the fiber's lifetime, particularly
2639
+ // before its child fibers are created.
2640
+ mode: TypeOfMode;
2641
+
2642
+ // Effect
2643
+ flags: Flags;
2644
+ subtreeFlags: Flags;
2645
+ deletions: Fiber[] | null;
2646
+
2647
+ // Singly linked list fast path to the next fiber with side-effects.
2648
+ nextEffect: Fiber | null;
2649
+
2650
+ // The first and last fiber with side-effect within this subtree. This allows
2651
+ // us to reuse a slice of the linked list when we reuse the work done within
2652
+ // this fiber.
2653
+ firstEffect: Fiber | null;
2654
+ lastEffect: Fiber | null;
2655
+
2656
+ lanes: Lanes;
2657
+ childLanes: Lanes;
2658
+
2659
+ // This is a pooled version of a Fiber. Every fiber that gets updated will
2660
+ // eventually have a pair. There are cases when we can clean up pairs to save
2661
+ // memory if we need to.
2662
+ alternate: Fiber | null;
2663
+
2664
+ // Time spent rendering this Fiber and its descendants for the current update.
2665
+ // This tells us how well the tree makes use of sCU for memoization.
2666
+ // It is reset to 0 each time we render and only updated when we don't bailout.
2667
+ // This field is only set when the enableProfilerTimer flag is enabled.
2668
+ actualDuration?: number;
2669
+
2670
+ // If the Fiber is currently active in the "render" phase,
2671
+ // This marks the time at which the work began.
2672
+ // This field is only set when the enableProfilerTimer flag is enabled.
2673
+ actualStartTime?: number;
2674
+
2675
+ // Duration of the most recent render time for this Fiber.
2676
+ // This value is not updated when we bailout for memoization purposes.
2677
+ // This field is only set when the enableProfilerTimer flag is enabled.
2678
+ selfBaseDuration?: number;
2679
+
2680
+ // Sum of base times for all descendants of this Fiber.
2681
+ // This value bubbles up during the "complete" phase.
2682
+ // This field is only set when the enableProfilerTimer flag is enabled.
2683
+ treeBaseDuration?: number;
2684
+
2685
+ // Conceptual aliases
2686
+ // workInProgress : Fiber -> alternate The alternate used for reuse happens
2687
+ // to be the same as work in progress.
2688
+ // __DEV__ only
2689
+ _debugID?: number;
2690
+ _debugSource?: Source | null;
2691
+ _debugOwner?: Fiber | null;
2692
+ _debugIsCurrentlyTiming?: boolean;
2693
+ _debugNeedsRemount?: boolean;
2694
+
2695
+ // Used to verify that the order of hooks does not change between renders.
2696
+ _debugHookTypes?: HookType[] | null;
2697
+ }
2698
+
2699
+ type FiberRoot = any;
2700
+
2701
+ // Concurrent related struct
2702
+ type MutableSource = any;
2703
+
2704
+ type OpaqueHandle = any;
2705
+ type OpaqueRoot = any;
2706
+
2707
+ // 0 is PROD, 1 is DEV.
2708
+ // Might add PROFILE later.
2709
+ type BundleType = 0 | 1;
2710
+
2711
+ interface DevToolsConfig<Instance, TextInstance, RendererInspectionConfig> {
2712
+ bundleType: BundleType;
2713
+ version: string;
2714
+ rendererPackageName: string;
2715
+ // Note: this actually *does* depend on Fiber internal fields.
2716
+ // Used by "inspect clicked DOM element" in React DevTools.
2717
+ findFiberByHostInstance?: (instance: Instance | TextInstance) => Fiber | null;
2718
+ rendererConfig?: RendererInspectionConfig;
2719
+ }
2720
+
2721
+ interface SuspenseHydrationCallbacks<SuspenseInstance> {
2722
+ onHydrated?: (suspenseInstance: SuspenseInstance) => void;
2723
+ onDeleted?: (suspenseInstance: SuspenseInstance) => void;
2724
+ }
2725
+
2726
+ interface TransitionTracingCallbacks {
2727
+ onTransitionStart?: (transitionName: string, startTime: number) => void;
2728
+ onTransitionProgress?: (
2729
+ transitionName: string,
2730
+ startTime: number,
2731
+ currentTime: number,
2732
+ pending: Array<{ name: null | string }>,
2733
+ ) => void;
2734
+ onTransitionIncomplete?: (
2735
+ transitionName: string,
2736
+ startTime: number,
2737
+ deletions: Array<{
2738
+ type: string;
2739
+ name?: string;
2740
+ newName?: string;
2741
+ endTime: number;
2742
+ }>,
2743
+ ) => void;
2744
+ onTransitionComplete?: (transitionName: string, startTime: number, endTime: number) => void;
2745
+ onMarkerProgress?: (
2746
+ transitionName: string,
2747
+ marker: string,
2748
+ startTime: number,
2749
+ currentTime: number,
2750
+ pending: Array<{ name: null | string }>,
2751
+ ) => void;
2752
+ onMarkerIncomplete?: (
2753
+ transitionName: string,
2754
+ marker: string,
2755
+ startTime: number,
2756
+ deletions: Array<{
2757
+ type: string;
2758
+ name?: string;
2759
+ newName?: string;
2760
+ endTime: number;
2761
+ }>,
2762
+ ) => void;
2763
+ onMarkerComplete?: (transitionName: string, marker: string, startTime: number, endTime: number) => void;
2764
+ }
2765
+
2766
+ interface ComponentSelector {
2767
+ $$typeof: symbol | number;
2768
+ value: React$AbstractComponent<never, unknown>;
2769
+ }
2770
+
2771
+ interface HasPseudoClassSelector {
2772
+ $$typeof: symbol | number;
2773
+ value: Selector[];
2774
+ }
2775
+
2776
+ interface RoleSelector {
2777
+ $$typeof: symbol | number;
2778
+ value: string;
2779
+ }
2780
+
2781
+ interface TextSelector {
2782
+ $$typeof: symbol | number;
2783
+ value: string;
2784
+ }
2785
+
2786
+ interface TestNameSelector {
2787
+ $$typeof: symbol | number;
2788
+ value: string;
2789
+ }
2790
+
2791
+ type Selector = ComponentSelector | HasPseudoClassSelector | RoleSelector | TextSelector | TestNameSelector;
2792
+
2793
+ // TODO can not find React$AbstractComponent def
2794
+ type React$AbstractComponent<Config, Instance = any> = any;
2795
+
2796
+ interface BoundingRect {
2797
+ x: number;
2798
+ y: number;
2799
+ width: number;
2800
+ height: number;
2801
+ }
2802
+
2803
+ type IntersectionObserverOptions = any;
2804
+
2805
+ interface BaseErrorInfo {
2806
+ componentStack?: string;
2807
+ }
2808
+
2809
+ interface Reconciler<Container, Instance, TextInstance, SuspenseInstance, FormInstance, PublicInstance> {
2810
+ createContainer(
2811
+ containerInfo: Container,
2812
+ tag: RootTag,
2813
+ hydrationCallbacks: null | SuspenseHydrationCallbacks<SuspenseInstance>,
2814
+ isStrictMode: boolean,
2815
+ concurrentUpdatesByDefaultOverride: null | boolean,
2816
+ identifierPrefix: string,
2817
+ onUncaughtError: (error: Error, info: BaseErrorInfo & { errorBoundary?: Component }) => void,
2818
+ onCaughtError: (error: Error, info: BaseErrorInfo) => void,
2819
+ onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
2820
+ onDefaultTransitionIndicator: () => void,
2821
+ transitionCallbacks: null | TransitionTracingCallbacks,
2822
+ ): OpaqueRoot;
2823
+
2824
+ createPortal(
2825
+ children: ReactNode,
2826
+ containerInfo: any, // TODO: figure out the API for cross-renderer implementation.
2827
+ implementation: any,
2828
+ key?: string | null,
2829
+ ): ReactPortal;
2830
+
2831
+ registerMutableSourceForHydration(root: FiberRoot, mutableSource: MutableSource): void;
2832
+
2833
+ createComponentSelector(component: React$AbstractComponent<never, unknown>): ComponentSelector;
2834
+
2835
+ createHasPseudoClassSelector(selectors: Selector[]): HasPseudoClassSelector;
2836
+
2837
+ createRoleSelector(role: string): RoleSelector;
2838
+
2839
+ createTextSelector(text: string): TextSelector;
2840
+
2841
+ createTestNameSelector(id: string): TestNameSelector;
2842
+
2843
+ getFindAllNodesFailureDescription(hostRoot: Instance, selectors: Selector[]): string | null;
2844
+
2845
+ findAllNodes(hostRoot: Instance, selectors: Selector[]): Instance[];
2846
+
2847
+ findBoundingRects(hostRoot: Instance, selectors: Selector[]): BoundingRect[];
2848
+
2849
+ focusWithin(hostRoot: Instance, selectors: Selector[]): boolean;
2850
+
2851
+ observeVisibleRects(
2852
+ hostRoot: Instance,
2853
+ selectors: Selector[],
2854
+ callback: (intersections: Array<{ ratio: number; rect: BoundingRect }>) => void,
2855
+ options?: IntersectionObserverOptions,
2856
+ ): { disconnect: () => void };
2857
+
2858
+ createHydrationContainer(
2859
+ initialChildren: ReactNode,
2860
+ callback: (() => void) | null | undefined,
2861
+ containerInfo: Container,
2862
+ tag: RootTag,
2863
+ hydrationCallbacks: null | SuspenseHydrationCallbacks<SuspenseInstance>,
2864
+ isStrictMode: boolean,
2865
+ concurrentUpdatesByDefaultOverride: null | boolean,
2866
+ identifierPrefix: string,
2867
+ onRecoverableError: (error: Error) => void,
2868
+ transitionCallbacks: null | TransitionTracingCallbacks,
2869
+ ): OpaqueRoot;
2870
+
2871
+ updateContainer(
2872
+ element: ReactNode,
2873
+ container: OpaqueRoot,
2874
+ parentComponent?: Component<any, any> | null,
2875
+ callback?: (() => void) | null,
2876
+ ): Lane;
2877
+
2878
+ batchedUpdates<A, R>(fn: (a: A) => R, a: A): R;
2879
+
2880
+ deferredUpdates<A>(fn: () => A): A;
2881
+
2882
+ 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;
2883
+
2884
+ flushControlled(fn: () => any): void;
2885
+
2886
+ flushSync(): void;
2887
+ flushSync<R>(fn: () => R): R;
2888
+
2889
+ isAlreadyRendering(): boolean;
2890
+
2891
+ flushPassiveEffects(): boolean;
2892
+
2893
+ getPublicRootInstance(container: OpaqueRoot): Component<any, any> | PublicInstance | null;
2894
+
2895
+ attemptSynchronousHydration(fiber: Fiber): void;
2896
+
2897
+ attemptDiscreteHydration(fiber: Fiber): void;
2898
+
2899
+ attemptContinuousHydration(fiber: Fiber): void;
2900
+
2901
+ attemptHydrationAtCurrentPriority(fiber: Fiber): void;
2902
+
2903
+ getCurrentUpdatePriority(): LanePriority;
2904
+
2905
+ runWithPriority<T>(priority: LanePriority, fn: () => T): T;
2906
+
2907
+ findHostInstance(component: any): PublicInstance | null;
2908
+
2909
+ findHostInstanceWithWarning(component: any, methodName: string): PublicInstance | null;
2910
+
2911
+ findHostInstanceWithNoPortals(fiber: Fiber): PublicInstance | null;
2912
+
2913
+ shouldError(fiber: Fiber): boolean | undefined;
2914
+
2915
+ shouldSuspend(fiber: Fiber): boolean;
2916
+
2917
+ injectIntoDevTools(devToolsConfig: DevToolsConfig<Instance, TextInstance, any>): boolean;
2918
+ }
2919
+ }
2920
+
2921
+ declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
2922
+ declare function extend<T extends Catalogue>(objects: T): void;
2923
+ declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
2924
+
2925
+ declare const isRenderer: (def: any) => boolean;
2926
+ interface OffscreenCanvas extends EventTarget {
2927
+ }
2928
+ declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
2929
+ declare function createRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
2930
+ declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
2931
+ declare function createPortal(children: ReactNode, container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>, state?: InjectState): JSX.Element;
2932
+ /**
2933
+ * Force React to flush any updates inside the provided callback synchronously and immediately.
2934
+ * All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
2935
+ * Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
2936
+ * having to revert to a non-React solution. Note: this will only flush updates within the `Canvas` root.
2937
+ */
2938
+ declare function flushSync<R>(fn: () => R): R;
2939
+
2940
+ declare const context: React$1.Context<RootStore>;
2941
+ declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
2942
+
2943
+ /**
2944
+ * Safely flush async effects when testing, simulating a legacy root.
2945
+ * @deprecated Import from React instead. import { act } from 'react'
2946
+ */
2947
+ declare const act: typeof React$1.act;
2948
+ /**
2949
+ * An SSR-friendly useLayoutEffect.
2950
+ *
2951
+ * React currently throws a warning when using useLayoutEffect on the server.
2952
+ * To get around it, we can conditionally useEffect on the server (no-op) and
2953
+ * useLayoutEffect elsewhere.
2954
+ *
2955
+ * @see https://github.com/facebook/react/issues/14927
2956
+ */
2957
+ declare const useIsomorphicLayoutEffect: typeof React$1.useLayoutEffect;
2958
+ /**
2959
+ * Creates a stable ref that always contains the latest callback.
2960
+ * Useful for avoiding dependency arrays while ensuring the latest closure is called.
2961
+ *
2962
+ * @param fn - The callback function to wrap
2963
+ * @returns A ref containing the current callback
2964
+ */
2965
+ declare function useMutableCallback<T>(fn: T): React$1.RefObject<T>;
2966
+ /**
2967
+ * Bridges renderer Context and StrictMode from a primary renderer.
2968
+ * Used to maintain React context when rendering into portals or secondary canvases.
2969
+ *
2970
+ * @returns A Bridge component that wraps children with the parent renderer's context
2971
+ */
2972
+ declare function useBridge(): Bridge;
2973
+ /**
2974
+ * Internal component that blocks rendering until a promise resolves.
2975
+ * Used for suspense-like blocking behavior.
2976
+ *
2977
+ * @param set - Function to set the blocking promise
2978
+ */
2979
+ declare function Block({ set }: Omit<UnblockProps, 'children'>): null;
2980
+ /**
2981
+ * Error boundary component for catching and handling errors in the React tree.
2982
+ * Forwards errors to a state setter for external handling.
2983
+ *
2984
+ * NOTE: static members get down-level transpiled to mutations which break tree-shaking
2985
+ */
2986
+ declare const ErrorBoundary: {
2987
+ new (props: {
2988
+ set: React$1.Dispatch<Error | undefined>;
2989
+ children: React$1.ReactNode;
2990
+ }): {
2991
+ state: {
2992
+ error: boolean;
2993
+ };
2994
+ componentDidCatch(err: Error): void;
2995
+ render(): React$1.ReactNode;
2996
+ context: unknown;
2997
+ setState<K extends "error">(state: {
2998
+ error: boolean;
2999
+ } | ((prevState: Readonly<{
3000
+ error: boolean;
3001
+ }>, props: Readonly<{
3002
+ set: React$1.Dispatch<Error | undefined>;
3003
+ children: React$1.ReactNode;
3004
+ }>) => {
3005
+ error: boolean;
3006
+ } | Pick<{
3007
+ error: boolean;
3008
+ }, K> | null) | Pick<{
3009
+ error: boolean;
3010
+ }, K> | null, callback?: (() => void) | undefined): void;
3011
+ forceUpdate(callback?: (() => void) | undefined): void;
3012
+ readonly props: Readonly<{
3013
+ set: React$1.Dispatch<Error | undefined>;
3014
+ children: React$1.ReactNode;
3015
+ }>;
3016
+ componentDidMount?(): void;
3017
+ shouldComponentUpdate?(nextProps: Readonly<{
3018
+ set: React$1.Dispatch<Error | undefined>;
3019
+ children: React$1.ReactNode;
3020
+ }>, nextState: Readonly<{
3021
+ error: boolean;
3022
+ }>, nextContext: any): boolean;
3023
+ componentWillUnmount?(): void;
3024
+ getSnapshotBeforeUpdate?(prevProps: Readonly<{
3025
+ set: React$1.Dispatch<Error | undefined>;
3026
+ children: React$1.ReactNode;
3027
+ }>, prevState: Readonly<{
3028
+ error: boolean;
3029
+ }>): any;
3030
+ componentDidUpdate?(prevProps: Readonly<{
3031
+ set: React$1.Dispatch<Error | undefined>;
3032
+ children: React$1.ReactNode;
3033
+ }>, prevState: Readonly<{
3034
+ error: boolean;
3035
+ }>, snapshot?: any): void;
3036
+ componentWillMount?(): void;
3037
+ UNSAFE_componentWillMount?(): void;
3038
+ componentWillReceiveProps?(nextProps: Readonly<{
3039
+ set: React$1.Dispatch<Error | undefined>;
3040
+ children: React$1.ReactNode;
3041
+ }>, nextContext: any): void;
3042
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{
3043
+ set: React$1.Dispatch<Error | undefined>;
3044
+ children: React$1.ReactNode;
3045
+ }>, nextContext: any): void;
3046
+ componentWillUpdate?(nextProps: Readonly<{
3047
+ set: React$1.Dispatch<Error | undefined>;
3048
+ children: React$1.ReactNode;
3049
+ }>, nextState: Readonly<{
3050
+ error: boolean;
3051
+ }>, nextContext: any): void;
3052
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<{
3053
+ set: React$1.Dispatch<Error | undefined>;
3054
+ children: React$1.ReactNode;
3055
+ }>, nextState: Readonly<{
3056
+ error: boolean;
3057
+ }>, nextContext: any): void;
3058
+ };
3059
+ new (props: {
3060
+ set: React$1.Dispatch<Error | undefined>;
3061
+ children: React$1.ReactNode;
3062
+ }, context: any): {
3063
+ state: {
3064
+ error: boolean;
3065
+ };
3066
+ componentDidCatch(err: Error): void;
3067
+ render(): React$1.ReactNode;
3068
+ context: unknown;
3069
+ setState<K extends "error">(state: {
3070
+ error: boolean;
3071
+ } | ((prevState: Readonly<{
3072
+ error: boolean;
3073
+ }>, props: Readonly<{
3074
+ set: React$1.Dispatch<Error | undefined>;
3075
+ children: React$1.ReactNode;
3076
+ }>) => {
3077
+ error: boolean;
3078
+ } | Pick<{
3079
+ error: boolean;
3080
+ }, K> | null) | Pick<{
3081
+ error: boolean;
3082
+ }, K> | null, callback?: (() => void) | undefined): void;
3083
+ forceUpdate(callback?: (() => void) | undefined): void;
3084
+ readonly props: Readonly<{
3085
+ set: React$1.Dispatch<Error | undefined>;
3086
+ children: React$1.ReactNode;
3087
+ }>;
3088
+ componentDidMount?(): void;
3089
+ shouldComponentUpdate?(nextProps: Readonly<{
3090
+ set: React$1.Dispatch<Error | undefined>;
3091
+ children: React$1.ReactNode;
3092
+ }>, nextState: Readonly<{
3093
+ error: boolean;
3094
+ }>, nextContext: any): boolean;
3095
+ componentWillUnmount?(): void;
3096
+ getSnapshotBeforeUpdate?(prevProps: Readonly<{
3097
+ set: React$1.Dispatch<Error | undefined>;
3098
+ children: React$1.ReactNode;
3099
+ }>, prevState: Readonly<{
3100
+ error: boolean;
3101
+ }>): any;
3102
+ componentDidUpdate?(prevProps: Readonly<{
3103
+ set: React$1.Dispatch<Error | undefined>;
3104
+ children: React$1.ReactNode;
3105
+ }>, prevState: Readonly<{
3106
+ error: boolean;
3107
+ }>, snapshot?: any): void;
3108
+ componentWillMount?(): void;
3109
+ UNSAFE_componentWillMount?(): void;
3110
+ componentWillReceiveProps?(nextProps: Readonly<{
3111
+ set: React$1.Dispatch<Error | undefined>;
3112
+ children: React$1.ReactNode;
3113
+ }>, nextContext: any): void;
3114
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{
3115
+ set: React$1.Dispatch<Error | undefined>;
3116
+ children: React$1.ReactNode;
3117
+ }>, nextContext: any): void;
3118
+ componentWillUpdate?(nextProps: Readonly<{
3119
+ set: React$1.Dispatch<Error | undefined>;
3120
+ children: React$1.ReactNode;
3121
+ }>, nextState: Readonly<{
3122
+ error: boolean;
3123
+ }>, nextContext: any): void;
3124
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<{
3125
+ set: React$1.Dispatch<Error | undefined>;
3126
+ children: React$1.ReactNode;
3127
+ }>, nextState: Readonly<{
3128
+ error: boolean;
3129
+ }>, nextContext: any): void;
3130
+ };
3131
+ getDerivedStateFromError: () => {
3132
+ error: boolean;
3133
+ };
3134
+ contextType?: React$1.Context<any> | undefined;
3135
+ propTypes?: any;
3136
+ };
3137
+
3138
+ /**
3139
+ * React internal props that should not be passed to Three.js objects.
3140
+ */
3141
+ declare const REACT_INTERNAL_PROPS: string[];
3142
+ /**
3143
+ * Returns the instance's initial (outermost) root.
3144
+ * Traverses through previousRoot links to find the original root store.
3145
+ *
3146
+ * @param instance - R3F instance to find root for
3147
+ * @returns The outermost root store
3148
+ */
3149
+ declare function findInitialRoot<T>(instance: Instance<T>): RootStore;
3150
+ /**
3151
+ * Returns instance root state.
3152
+ * If the object doesn't have __r3f (e.g., child meshes in primitives/GLTFs),
3153
+ * traverses ancestors to find the nearest managed parent.
3154
+ *
3155
+ * @param obj - Three.js object to get root state for
3156
+ * @returns Root state if found, undefined otherwise
3157
+ */
3158
+ declare function getRootState<T extends Object3D = Object3D>(obj: T): RootState | undefined;
3159
+ /**
3160
+ * Collects nodes, materials, and meshes from a Three.js Object3D hierarchy.
3161
+ * Handles duplicate material names by appending UUID prefixes.
3162
+ *
3163
+ * @param object - Root object to traverse
3164
+ * @returns ObjectMap containing named nodes, materials, and meshes
3165
+ *
3166
+ * @example
3167
+ * const { nodes, materials, meshes } = buildGraph(gltf.scene)
3168
+ * // Access by name: nodes.Head, materials.Metal, meshes.Body
3169
+ */
3170
+ declare function buildGraph(object: Object3D): ObjectMap;
3171
+ /**
3172
+ * Disposes an object and all its disposable properties.
3173
+ * Skips Scene objects as they should not be disposed automatically.
3174
+ *
3175
+ * @param obj - Object to dispose
3176
+ */
3177
+ declare function dispose<T extends Disposable>(obj: T): void;
3178
+ /**
3179
+ * Extracts instance props from React reconciler fiber props.
3180
+ * Filters out React-internal props (children, key, ref).
3181
+ *
3182
+ * @param queue - Pending props from reconciler fiber
3183
+ * @returns Props object without React-internal keys
3184
+ */
3185
+ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>): Instance<T>['props'];
3186
+ /**
3187
+ * Creates or retrieves an R3F instance descriptor for a Three.js object.
3188
+ * Each object in the scene carries a LocalState descriptor (__r3f).
3189
+ *
3190
+ * @param target - Target object to prepare
3191
+ * @param root - Root store for this instance
3192
+ * @param type - String identifier for the object type
3193
+ * @param props - Initial props for the instance
3194
+ * @returns Instance descriptor
3195
+ */
3196
+ declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
3197
+ /**
3198
+ * Triggers an update for an instance.
3199
+ * Calls onUpdate callback and invalidates the frame if necessary.
3200
+ *
3201
+ * @param instance - Instance to invalidate
3202
+ */
3203
+ declare function invalidateInstance(instance: Instance): void;
3204
+
3205
+ /**
3206
+ * Reserved prop names that should not be applied to Three.js objects.
3207
+ */
3208
+ declare const RESERVED_PROPS: string[];
3209
+ /**
3210
+ * Resolves a potentially pierced property key (e.g., 'material-color' → material.color).
3211
+ * First tries the entire key as a single property, then attempts piercing.
3212
+ *
3213
+ * @param root - Root object to resolve from
3214
+ * @param key - Property key (may contain dashes for piercing)
3215
+ * @returns Object containing root, key, and target value
3216
+ *
3217
+ * @example
3218
+ * resolve(mesh, 'material-color')
3219
+ * // => { root: mesh.material, key: 'color', target: mesh.material.color }
3220
+ */
3221
+ declare function resolve(root: any, key: string): {
3222
+ root: any;
3223
+ key: string;
3224
+ target: any;
3225
+ };
3226
+ /**
3227
+ * Attaches a child instance to a parent instance.
3228
+ * Handles both string-based attachment (e.g., 'geometry', 'material-map')
3229
+ * and function-based attachment for custom logic.
3230
+ *
3231
+ * @param parent - Parent instance
3232
+ * @param child - Child instance to attach
3233
+ *
3234
+ * @example
3235
+ * // String attachment
3236
+ * <bufferGeometry attach="geometry" />
3237
+ * // Array attachment
3238
+ * <light attach="lights-0" />
3239
+ * // Function attachment
3240
+ * <thing attach={(parent, self) => { parent.customProp = self }} />
3241
+ */
3242
+ declare function attach(parent: Instance, child: Instance): void;
3243
+ /**
3244
+ * Detaches a child instance from a parent instance.
3245
+ * Restores the previous value or deletes the property if it was never set.
3246
+ *
3247
+ * @param parent - Parent instance
3248
+ * @param child - Child instance to detach
3249
+ */
3250
+ declare function detach(parent: Instance, child: Instance): void;
3251
+ /**
3252
+ * Compares old and new props to determine which properties have changed.
3253
+ * Also handles resetting removed props for HMR/fast-refresh.
3254
+ *
3255
+ * @param instance - Instance to diff props for
3256
+ * @param newProps - New props to compare against
3257
+ * @returns Object containing only changed props
3258
+ *
3259
+ * @example
3260
+ * const changes = diffProps(instance, { position: [1, 2, 3], color: 'red' })
3261
+ * // => { position: [1, 2, 3] } (only if position changed)
3262
+ */
3263
+ declare function diffProps<T = any>(instance: Instance<T>, newProps: Instance<T>['props']): Instance<T>['props'];
3264
+ /**
3265
+ * Applies a set of props to a Three.js object.
3266
+ * Handles special cases like colors, vectors, textures, events, and pierced props.
3267
+ *
3268
+ * @param object - Three.js object to apply props to
3269
+ * @param props - Props to apply
3270
+ * @returns The object with props applied
3271
+ *
3272
+ * @example
3273
+ * applyProps(mesh, { position: [0, 1, 0], 'material-color': 'red' })
3274
+ */
3275
+ declare function applyProps<T = any>(object: Instance<T>['object'], props: Instance<T>['props']): Instance<T>['object'];
3276
+
3277
+ /**
3278
+ * Calculates the device pixel ratio for rendering.
3279
+ * Handles array DPR ranges [min, max] to clamp devicePixelRatio.
3280
+ *
3281
+ * @param dpr - Target DPR value or [min, max] range
3282
+ * @returns Calculated DPR value
3283
+ *
3284
+ * @example
3285
+ * calculateDpr(2) // => 2
3286
+ * calculateDpr([1, 2]) // => clamps window.devicePixelRatio between 1 and 2
3287
+ */
3288
+ declare function calculateDpr(dpr: Dpr): number;
3289
+ /**
3290
+ * Extracts the first segment of a UUID string (before the first hyphen).
3291
+ * Used for creating unique material names when duplicates exist.
3292
+ *
3293
+ * @param uuid - UUID string to extract prefix from
3294
+ * @returns First segment of the UUID
3295
+ *
3296
+ * @example
3297
+ * getUuidPrefix('a1b2c3d4-e5f6-g7h8-i9j0') // => 'a1b2c3d4'
3298
+ */
3299
+ declare function getUuidPrefix(uuid: string): string;
3300
+ /**
3301
+ * Updates camera projection based on viewport size.
3302
+ * Adjusts aspect ratio for perspective cameras or bounds for orthographic cameras.
3303
+ * Respects camera.manual flag - manual cameras are not modified.
3304
+ *
3305
+ * @param camera - Camera to update
3306
+ * @param size - Current viewport size
3307
+ */
3308
+ declare function updateCamera(camera: ThreeCamera, size: Size): void;
3309
+
3310
+ declare const is: {
3311
+ obj: (a: any) => boolean;
3312
+ fun: (a: any) => a is Function;
3313
+ str: (a: any) => a is string;
3314
+ num: (a: any) => a is number;
3315
+ boo: (a: any) => a is boolean;
3316
+ und: (a: any) => boolean;
3317
+ nul: (a: any) => boolean;
3318
+ arr: (a: any) => a is any[];
3319
+ equ(a: any, b: any, { arrays, objects, strict }?: EquConfig): boolean;
3320
+ };
3321
+ declare const isOrthographicCamera: (def: ThreeCamera) => def is OrthographicCamera;
3322
+ declare const isRef: (obj: unknown) => obj is React.RefObject<unknown>;
3323
+ declare const isColorRepresentation: (value: unknown) => value is ColorRepresentation;
3324
+ declare const isObject3D: (object: any) => object is Object3D;
3325
+ declare const isTexture: (value: unknown) => value is Texture$1;
3326
+ type VectorLike = {
3327
+ set: (...args: any[]) => void;
3328
+ constructor?: Function;
3329
+ };
3330
+ declare const isVectorLike: (object: unknown) => object is VectorLike;
3331
+ type Copyable = {
3332
+ copy: (...args: any[]) => void;
3333
+ constructor?: Function;
3334
+ };
3335
+ declare const isCopyable: (object: unknown) => object is Copyable;
3336
+ declare const hasConstructor: (object: unknown) => object is {
3337
+ constructor?: Function;
3338
+ };
3339
+
3340
+ /**
3341
+ * A DOM canvas which accepts threejs elements as children.
3342
+ * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
3343
+ */
3344
+ declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
3345
+
3346
+ export { Block, Canvas, ErrorBoundary, IsObject, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Scheduler, Texture, _roots, act, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, context, createEvents, createPointerEvents, createPortal, createRoot, createStore, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, getInstanceProps, getRootState, getScheduler, getUuidPrefix, hasConstructor, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isObject3D, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, prepare, reconciler, removeInteractivity, resolve, unmountComponentAtNode, updateCamera, useBridge, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useStore, useTexture, useTextures, useThree };
3347
+ export type { Act, AddPhaseOptions, Args, ArgsProp, AttachFnType, AttachType, BaseRendererProps, Bridge, Camera, CameraProps, CanvasProps, Catalogue, Color, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DomEvent, Dpr, ElementProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FilterFunction, FrameCallback, FrameControls, FrameNextCallback, FrameNextControls, FrameNextState, FrameState, Frameloop, GLProps, GLTFLike, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, Properties, Quaternion, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, Renderer, RendererFactory, RendererProps, Root, RootState, RootStore, SchedulerApi, SetBlock, Size, Subscription, TextureEntry, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseFrameNextOptions, UseFrameOptions, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager };