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