@react-three/fiber 9.5.0 → 10.0.0-alpha.1

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