@react-three/fiber 10.0.0-canary.f50076a → 10.0.0-canary.f511bb4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/extension.d.cts +3 -3
  2. package/dist/extension.d.mts +3 -3
  3. package/dist/extension.d.ts +3 -3
  4. package/dist/extension.mjs +1 -1
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.d.cts +5 -5
  7. package/dist/index.d.mts +5 -5
  8. package/dist/index.d.ts +5 -5
  9. package/dist/index.mjs +3 -3
  10. package/dist/legacy.cjs +1 -1
  11. package/dist/legacy.d.cts +4 -4
  12. package/dist/legacy.d.mts +4 -4
  13. package/dist/legacy.d.ts +4 -4
  14. package/dist/legacy.mjs +4 -4
  15. package/dist/shared/{fiber.DAl4H27x.d.cts → fiber.-1JhXWEC.d.cts} +1 -1
  16. package/dist/shared/{fiber.dvUbwHHn.mjs → fiber.B3mc9NA1.mjs} +306 -87
  17. package/dist/shared/{fiber.DNehrxK5.d.ts → fiber.Bkpap4yF.d.mts} +76 -1
  18. package/dist/shared/{fiber.TWXdbcWP.d.mts → fiber.BnIfHyTk.d.cts} +76 -1
  19. package/dist/shared/{fiber.I5Q4dVvl.d.cts → fiber.CLTHZhZp.d.cts} +30 -2
  20. package/dist/shared/{fiber.I5Q4dVvl.d.mts → fiber.CLTHZhZp.d.mts} +30 -2
  21. package/dist/shared/{fiber.I5Q4dVvl.d.ts → fiber.CLTHZhZp.d.ts} +30 -2
  22. package/dist/shared/{fiber.Cx-UAmMb.d.ts → fiber.CTEAJNmg.d.ts} +1 -1
  23. package/dist/shared/{fiber.B0oukOFO.mjs → fiber.CUKAa7Rv.mjs} +1 -1
  24. package/dist/shared/{fiber.BU0vBHc9.d.mts → fiber.CksZuiOV.d.mts} +1 -1
  25. package/dist/shared/{fiber.CEjezJYZ.cjs → fiber.DF7oitV8.cjs} +306 -87
  26. package/dist/shared/{fiber.11sXr8Eb.d.cts → fiber.NwhGYEh-.d.ts} +76 -1
  27. package/dist/webgpu/index.cjs +1 -1
  28. package/dist/webgpu/index.d.cts +4 -4
  29. package/dist/webgpu/index.d.mts +4 -4
  30. package/dist/webgpu/index.d.ts +4 -4
  31. package/dist/webgpu/index.mjs +4 -4
  32. package/package.json +1 -1
@@ -3,7 +3,7 @@ import { ReactNode, Component, RefObject, JSX } from 'react';
3
3
  import { Options } from 'react-use-measure';
4
4
  import * as THREE from 'three';
5
5
  import { ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D } from 'three';
6
- import { J as Properties, c as Size, F as Frameloop, e as Performance, D as Dpr, g as RootStore, p as EventManager, f as RootState, n as ComputeFunction, C as ConstructorRepresentation, _ as ObjectMap, I as InternalState, M as Mutable, O as Overwrite, y as Args, l as EventHandlers, B as InstanceProps, k as DomEvent, G as Instance, x as Catalogue, v as Root, a6 as ThreeCore, W as Bridge, Z as UnblockProps, a0 as Disposable, Q as ThreeCamera, $ as EquConfig } from './fiber.I5Q4dVvl.js';
6
+ import { K as Properties, c as Size, F as Frameloop, e as Performance, D as Dpr, g as RootStore, p as EventManager, f as RootState, n as ComputeFunction, C as ConstructorRepresentation, $ as ObjectMap, I as InternalState, M as Mutable, O as Overwrite, z as Args, l as EventHandlers, G as InstanceProps, k as DomEvent, H as Instance, y as Catalogue, w as Root, a7 as ThreeCore, Y as Bridge, _ as UnblockProps, a1 as Disposable, U as ThreeCamera, a0 as EquConfig } from './fiber.CLTHZhZp.mjs';
7
7
  import { WebGPURenderer, WebGPURendererParameters } from 'three/webgpu';
8
8
 
9
9
  //* Base Renderer Types =====================================
@@ -2255,16 +2255,67 @@ declare namespace ReactReconciler {
2255
2255
  ): void;
2256
2256
  }
2257
2257
 
2258
+ /**
2259
+ * Registers constructors so they can be rendered as JSX elements.
2260
+ *
2261
+ * - `extend({ OrbitControls })` makes each constructor available under its camelCased key
2262
+ * (`<orbitControls />`). Values that are not constructors are skipped, so a whole module
2263
+ * namespace can be passed.
2264
+ * - `extend(MyClass)` registers one constructor and returns a component to render it with.
2265
+ *
2266
+ * Registrations are global, shared by every copy and entry of fiber, and are checked before the
2267
+ * three namespace of a root's renderer when an element name is resolved.
2268
+ *
2269
+ * @example
2270
+ * import { OrbitControls } from 'three/addons/controls/OrbitControls.js'
2271
+ * extend({ OrbitControls })
2272
+ * // <orbitControls args={[camera, gl.domElement]} />
2273
+ *
2274
+ * @example
2275
+ * const Controls = extend(OrbitControls)
2276
+ * // <Controls args={[camera, gl.domElement]} />
2277
+ *
2278
+ * @see https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively
2279
+ */
2258
2280
  declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
2281
+ /** Registers each constructor in `objects` under its key; see the first overload. */
2259
2282
  declare function extend<T extends Catalogue>(objects: T): void;
2283
+ /** Registers every constructor in a module namespace, skipping other exports; see the first overload. */
2260
2284
  declare function extend(objects: Record<string, unknown>): void;
2261
2285
 
2286
+ /**
2287
+ * R3F's React reconciler: a mutation-mode host config that turns JSX elements into three.js objects.
2288
+ * Each root's {@link RootStore} is its container, and children attach to `internal.container`
2289
+ * (a portal's target) or else the root's `scene`.
2290
+ *
2291
+ * - **Element names** resolve through `extend()` registrations first, then the three namespace of
2292
+ * the root's renderer. A `three` prefix (`<threeLine>`) is stripped when no element by the
2293
+ * prefixed name exists. `<primitive object={...}>` wraps an existing object.
2294
+ * - **Construction is deferred** until an instance is attached to a mounted parent, so a tree that
2295
+ * Suspense discards never creates three objects.
2296
+ * - **Updates** apply only changed props. Changing `args` (or a primitive's `object`) reconstructs
2297
+ * the object instead; the swap happens in `resetAfterCommit`, before layout effects, so refs
2298
+ * already point to the new object.
2299
+ * - **Removal** detaches the object and disposes it (at idle priority, or immediately in an `act`
2300
+ * test environment), unless it is a primitive, a `Scene`, or it or an ancestor has `dispose={null}`.
2301
+ * - **Priority**: not the primary renderer, so it runs alongside react-dom, and update priority
2302
+ * follows react-dom's event priorities. View-transition commits are flushed synchronously, since
2303
+ * three has nothing to animate between commits.
2304
+ *
2305
+ * `createRoot`, `createPortal` and `flushSync` drive it; app code rarely needs it directly.
2306
+ */
2262
2307
  declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
2263
2308
 
2264
2309
  declare const isRenderer: (def: any) => boolean;
2265
2310
  interface OffscreenCanvas extends EventTarget {
2266
2311
  }
2267
2312
  declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
2313
+ /**
2314
+ * Unmount the root on `canvas`. The teardown runs once React has committed the unmount, and waits
2315
+ * for a renderer that is still being created. `callback` runs when the root is gone: after the
2316
+ * teardown, and when it disposed a renderer R3F created whose `dispose()` is async (WebGPURenderer
2317
+ * from three r186), after that dispose has settled.
2318
+ */
2268
2319
  declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
2269
2320
  declare function createPortal(children: ReactNode, container: THREE.Object3D | RefObject<THREE.Object3D | null> | RefObject<THREE.Object3D>, state?: InjectState): JSX.Element;
2270
2321
  interface PortalProps {
@@ -2281,6 +2332,30 @@ declare function Portal({ children, container, state }: PortalProps): JSX.Elemen
2281
2332
  */
2282
2333
  declare function flushSync<R>(fn: () => R): R;
2283
2334
 
2335
+ /**
2336
+ * Creates the Zustand store that holds one root's {@link RootState}.
2337
+ *
2338
+ * The store starts unconfigured: the renderer, `camera`, `scene`, `raycaster`, `frustum` and `pointer`
2339
+ * are `null` placeholders until the root's renderer support has loaded and `configure()` in
2340
+ * `renderer.tsx` fills them in. Only core's part of `RootState` is created here; packages building on
2341
+ * fiber add their own fields through root extensions.
2342
+ *
2343
+ * Besides the initial state, the store wires up:
2344
+ * - `state.gl` and `state.renderer` as accessors over `internal.actualRenderer`. `gl` reports a
2345
+ * deprecation when user code reads it outside legacy mode.
2346
+ * - `rootScene` following `scene` whenever `scene` is set to a real `THREE.Scene`.
2347
+ * - On a size or DPR change: updating the camera and resizing the root's own canvas target (or the
2348
+ * renderer when there is none).
2349
+ * - On a camera change: adding an unparented camera to `rootScene`, then refreshing the viewport and
2350
+ * (when `autoUpdateFrustum` is set) the frustum.
2351
+ * - Calling `invalidate(state)` after every state change.
2352
+ *
2353
+ * `createRoot` calls this once per canvas.
2354
+ *
2355
+ * @param invalidate - Requests frames for a root. Bound into `state.invalidate` and called on every store change.
2356
+ * @param advance - Steps a root manually. Bound into `state.advance`.
2357
+ * @returns The root's store, which is also the reconciler container for that root.
2358
+ */
2284
2359
  declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
2285
2360
 
2286
2361
  /** Whether any root has loaded a renderer yet. */
@@ -3,7 +3,7 @@ import { ReactNode, Component, RefObject, JSX } from 'react';
3
3
  import { Options } from 'react-use-measure';
4
4
  import * as THREE from 'three';
5
5
  import { ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D } from 'three';
6
- import { J as Properties, c as Size, F as Frameloop, e as Performance, D as Dpr, g as RootStore, p as EventManager, f as RootState, n as ComputeFunction, C as ConstructorRepresentation, _ as ObjectMap, I as InternalState, M as Mutable, O as Overwrite, y as Args, l as EventHandlers, B as InstanceProps, k as DomEvent, G as Instance, x as Catalogue, v as Root, a6 as ThreeCore, W as Bridge, Z as UnblockProps, a0 as Disposable, Q as ThreeCamera, $ as EquConfig } from './fiber.I5Q4dVvl.mjs';
6
+ import { K as Properties, c as Size, F as Frameloop, e as Performance, D as Dpr, g as RootStore, p as EventManager, f as RootState, n as ComputeFunction, C as ConstructorRepresentation, $ as ObjectMap, I as InternalState, M as Mutable, O as Overwrite, z as Args, l as EventHandlers, G as InstanceProps, k as DomEvent, H as Instance, y as Catalogue, w as Root, a7 as ThreeCore, Y as Bridge, _ as UnblockProps, a1 as Disposable, U as ThreeCamera, a0 as EquConfig } from './fiber.CLTHZhZp.cjs';
7
7
  import { WebGPURenderer, WebGPURendererParameters } from 'three/webgpu';
8
8
 
9
9
  //* Base Renderer Types =====================================
@@ -2255,16 +2255,67 @@ declare namespace ReactReconciler {
2255
2255
  ): void;
2256
2256
  }
2257
2257
 
2258
+ /**
2259
+ * Registers constructors so they can be rendered as JSX elements.
2260
+ *
2261
+ * - `extend({ OrbitControls })` makes each constructor available under its camelCased key
2262
+ * (`<orbitControls />`). Values that are not constructors are skipped, so a whole module
2263
+ * namespace can be passed.
2264
+ * - `extend(MyClass)` registers one constructor and returns a component to render it with.
2265
+ *
2266
+ * Registrations are global, shared by every copy and entry of fiber, and are checked before the
2267
+ * three namespace of a root's renderer when an element name is resolved.
2268
+ *
2269
+ * @example
2270
+ * import { OrbitControls } from 'three/addons/controls/OrbitControls.js'
2271
+ * extend({ OrbitControls })
2272
+ * // <orbitControls args={[camera, gl.domElement]} />
2273
+ *
2274
+ * @example
2275
+ * const Controls = extend(OrbitControls)
2276
+ * // <Controls args={[camera, gl.domElement]} />
2277
+ *
2278
+ * @see https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively
2279
+ */
2258
2280
  declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
2281
+ /** Registers each constructor in `objects` under its key; see the first overload. */
2259
2282
  declare function extend<T extends Catalogue>(objects: T): void;
2283
+ /** Registers every constructor in a module namespace, skipping other exports; see the first overload. */
2260
2284
  declare function extend(objects: Record<string, unknown>): void;
2261
2285
 
2286
+ /**
2287
+ * R3F's React reconciler: a mutation-mode host config that turns JSX elements into three.js objects.
2288
+ * Each root's {@link RootStore} is its container, and children attach to `internal.container`
2289
+ * (a portal's target) or else the root's `scene`.
2290
+ *
2291
+ * - **Element names** resolve through `extend()` registrations first, then the three namespace of
2292
+ * the root's renderer. A `three` prefix (`<threeLine>`) is stripped when no element by the
2293
+ * prefixed name exists. `<primitive object={...}>` wraps an existing object.
2294
+ * - **Construction is deferred** until an instance is attached to a mounted parent, so a tree that
2295
+ * Suspense discards never creates three objects.
2296
+ * - **Updates** apply only changed props. Changing `args` (or a primitive's `object`) reconstructs
2297
+ * the object instead; the swap happens in `resetAfterCommit`, before layout effects, so refs
2298
+ * already point to the new object.
2299
+ * - **Removal** detaches the object and disposes it (at idle priority, or immediately in an `act`
2300
+ * test environment), unless it is a primitive, a `Scene`, or it or an ancestor has `dispose={null}`.
2301
+ * - **Priority**: not the primary renderer, so it runs alongside react-dom, and update priority
2302
+ * follows react-dom's event priorities. View-transition commits are flushed synchronously, since
2303
+ * three has nothing to animate between commits.
2304
+ *
2305
+ * `createRoot`, `createPortal` and `flushSync` drive it; app code rarely needs it directly.
2306
+ */
2262
2307
  declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
2263
2308
 
2264
2309
  declare const isRenderer: (def: any) => boolean;
2265
2310
  interface OffscreenCanvas extends EventTarget {
2266
2311
  }
2267
2312
  declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
2313
+ /**
2314
+ * Unmount the root on `canvas`. The teardown runs once React has committed the unmount, and waits
2315
+ * for a renderer that is still being created. `callback` runs when the root is gone: after the
2316
+ * teardown, and when it disposed a renderer R3F created whose `dispose()` is async (WebGPURenderer
2317
+ * from three r186), after that dispose has settled.
2318
+ */
2268
2319
  declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
2269
2320
  declare function createPortal(children: ReactNode, container: THREE.Object3D | RefObject<THREE.Object3D | null> | RefObject<THREE.Object3D>, state?: InjectState): JSX.Element;
2270
2321
  interface PortalProps {
@@ -2281,6 +2332,30 @@ declare function Portal({ children, container, state }: PortalProps): JSX.Elemen
2281
2332
  */
2282
2333
  declare function flushSync<R>(fn: () => R): R;
2283
2334
 
2335
+ /**
2336
+ * Creates the Zustand store that holds one root's {@link RootState}.
2337
+ *
2338
+ * The store starts unconfigured: the renderer, `camera`, `scene`, `raycaster`, `frustum` and `pointer`
2339
+ * are `null` placeholders until the root's renderer support has loaded and `configure()` in
2340
+ * `renderer.tsx` fills them in. Only core's part of `RootState` is created here; packages building on
2341
+ * fiber add their own fields through root extensions.
2342
+ *
2343
+ * Besides the initial state, the store wires up:
2344
+ * - `state.gl` and `state.renderer` as accessors over `internal.actualRenderer`. `gl` reports a
2345
+ * deprecation when user code reads it outside legacy mode.
2346
+ * - `rootScene` following `scene` whenever `scene` is set to a real `THREE.Scene`.
2347
+ * - On a size or DPR change: updating the camera and resizing the root's own canvas target (or the
2348
+ * renderer when there is none).
2349
+ * - On a camera change: adding an unparented camera to `rootScene`, then refreshing the viewport and
2350
+ * (when `autoUpdateFrustum` is set) the frustum.
2351
+ * - Calling `invalidate(state)` after every state change.
2352
+ *
2353
+ * `createRoot` calls this once per canvas.
2354
+ *
2355
+ * @param invalidate - Requests frames for a root. Bound into `state.invalidate` and called on every store change.
2356
+ * @param advance - Steps a root manually. Bound into `state.advance`.
2357
+ * @returns The root's store, which is also the reconciler container for that root.
2358
+ */
2284
2359
  declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
2285
2360
 
2286
2361
  /** Whether any root has loaded a renderer yet. */
@@ -477,6 +477,11 @@ interface InternalState {
477
477
  * Selected once, from the entry's provider, and copied into portals with the rest of `internal`.
478
478
  */
479
479
  support: R3FRendererSupport
480
+ /**
481
+ * Releases this root's lease on its renderer. The last release disposes a renderer R3F created;
482
+ * a renderer passed in as an instance is never disposed by R3F.
483
+ */
484
+ releaseRenderer?: () => void | Promise<void>
480
485
  /** Global scheduler reference (for useFrame hook) */
481
486
  scheduler: SchedulerApi | null
482
487
  /**
@@ -489,6 +494,8 @@ interface InternalState {
489
494
  rootId?: string
490
495
  /** Function to unregister this root from the global scheduler */
491
496
  unregisterRoot?: () => void
497
+ /** Function to stop following devicePixelRatio changes */
498
+ unwatchDpr?: () => void
492
499
  /** Container for child attachment (scene for root, original container for portals) */
493
500
  container?: THREE.Object3D
494
501
  /**
@@ -530,6 +537,12 @@ interface InternalState {
530
537
  * Only set when isSecondary is true.
531
538
  */
532
539
  targetId?: string
540
+ /**
541
+ * This secondary stopped sharing because the primary's renderer fell back to its
542
+ * WebGL2 backend (#3965): it owns the renderer it constructed, so it is not
543
+ * `isSecondary` (which marks a canvas borrowing another's renderer).
544
+ */
545
+ sharedRendererFallback?: boolean
533
546
  /**
534
547
  * Function to unregister this primary canvas from the registry.
535
548
  * Only set when this canvas has an `id` prop.
@@ -660,9 +673,17 @@ type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>
660
673
  // to avoid bundling @types/react-reconciler which causes absolute path issues
661
674
  type FiberRoot = any
662
675
 
676
+ /** A promise tagged with its state, the protocol React's `use` reads */
677
+ type TrackedPromise<T> = Promise<T> &
678
+ ({ status: 'pending' } | { status: 'fulfilled'; value: T } | { status: 'rejected'; reason: unknown })
679
+
663
680
  interface Root {
664
681
  fiber: FiberRoot
665
682
  store: RootStore
683
+ /** Set while a teardown waits on React. Configure and render clear it, which cancels the teardown */
684
+ unmountClaim: symbol | null
685
+ /** Pending only while a renderer is being created */
686
+ ready: TrackedPromise<unknown>
666
687
  }
667
688
 
668
689
  type AttachFnType<O = any> = (parent: any, self: O) => () => void
@@ -772,7 +793,14 @@ declare function useStore(): RootStore;
772
793
  */
773
794
  declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
774
795
 
796
+ /**
797
+ * React context that carries the current root's {@link RootStore}. Each root provides its store and
798
+ * each portal provides its own scoped one; `useStore`, and every hook built on it, reads it.
799
+ *
800
+ * Stored on `globalThis` under `Symbol.for('@react-three/fiber.context')`, so every copy and entry
801
+ * of fiber shares a single context.
802
+ */
775
803
  declare const context: React.Context<RootStore>;
776
804
 
777
- export { useStore as ag, useThree as ah, context as ai, registerRootExtension as r, setRenderOverride as s };
778
- export type { EquConfig as $, AttachFnType as A, InstanceProps as B, ConstructorRepresentation as C, Dpr as D, Events as E, Frameloop as F, Instance as G, HostConfig as H, InternalState as I, Properties as J, IsOptional as K, IsAllOptional as L, Mutable as M, NonFunctionKeys as N, Overwrite as O, PointerState as P, ThreeCamera as Q, R3FRenderTarget as R, Subscription as S, ThreeEvent as T, Act as U, Viewport as V, Bridge as W, XRManager as X, SetBlock as Y, UnblockProps as Z, ObjectMap as _, RootExtension as a, Disposable as a0, FrameNextState as a1, FrameState as a2, FrameNextCallback as a3, FrameCallback as a4, ThreeNamespace as a5, ThreeCore as a6, OcclusionSupport as a7, WebGLSupport as a8, WebGPUSupport as a9, RendererSupport as aa, RendererProvider as ab, Register as ac, RegisteredRenderer as ad, ForRegisteredRenderer as ae, R3FRendererSupport as af, R3FRenderer as b, Size as c, RenderCallback as d, Performance as e, RootState as f, RootStore as g, Intersection as h, Camera as i, IntersectionEvent as j, DomEvent as k, EventHandlers as l, FilterFunction as m, ComputeFunction as n, XRPointerConfig as o, EventManager as p, PointerCaptureTarget as q, VisibilityEntry as t, FiberRoot as u, Root as v, AttachType as w, Catalogue as x, Args as y, ArgsProp as z };
805
+ export { useStore as ah, useThree as ai, context as aj, registerRootExtension as r, setRenderOverride as s };
806
+ export type { ObjectMap as $, AttachFnType as A, ArgsProp as B, ConstructorRepresentation as C, Dpr as D, Events as E, Frameloop as F, InstanceProps as G, Instance as H, InternalState as I, HostConfig as J, Properties as K, IsOptional as L, Mutable as M, NonFunctionKeys as N, Overwrite as O, PointerState as P, IsAllOptional as Q, R3FRenderTarget as R, Subscription as S, ThreeEvent as T, ThreeCamera as U, Viewport as V, Act as W, XRManager as X, Bridge as Y, SetBlock as Z, UnblockProps as _, RootExtension as a, EquConfig as a0, Disposable as a1, FrameNextState as a2, FrameState as a3, FrameNextCallback as a4, FrameCallback as a5, ThreeNamespace as a6, ThreeCore as a7, OcclusionSupport as a8, WebGLSupport as a9, WebGPUSupport as aa, RendererSupport as ab, RendererProvider as ac, Register as ad, RegisteredRenderer as ae, ForRegisteredRenderer as af, R3FRendererSupport as ag, R3FRenderer as b, Size as c, RenderCallback as d, Performance as e, RootState as f, RootStore as g, Intersection as h, Camera as i, IntersectionEvent as j, DomEvent as k, EventHandlers as l, FilterFunction as m, ComputeFunction as n, XRPointerConfig as o, EventManager as p, PointerCaptureTarget as q, VisibilityEntry as t, FiberRoot as u, TrackedPromise as v, Root as w, AttachType as x, Catalogue as y, Args as z };
@@ -477,6 +477,11 @@ interface InternalState {
477
477
  * Selected once, from the entry's provider, and copied into portals with the rest of `internal`.
478
478
  */
479
479
  support: R3FRendererSupport
480
+ /**
481
+ * Releases this root's lease on its renderer. The last release disposes a renderer R3F created;
482
+ * a renderer passed in as an instance is never disposed by R3F.
483
+ */
484
+ releaseRenderer?: () => void | Promise<void>
480
485
  /** Global scheduler reference (for useFrame hook) */
481
486
  scheduler: SchedulerApi | null
482
487
  /**
@@ -489,6 +494,8 @@ interface InternalState {
489
494
  rootId?: string
490
495
  /** Function to unregister this root from the global scheduler */
491
496
  unregisterRoot?: () => void
497
+ /** Function to stop following devicePixelRatio changes */
498
+ unwatchDpr?: () => void
492
499
  /** Container for child attachment (scene for root, original container for portals) */
493
500
  container?: THREE.Object3D
494
501
  /**
@@ -530,6 +537,12 @@ interface InternalState {
530
537
  * Only set when isSecondary is true.
531
538
  */
532
539
  targetId?: string
540
+ /**
541
+ * This secondary stopped sharing because the primary's renderer fell back to its
542
+ * WebGL2 backend (#3965): it owns the renderer it constructed, so it is not
543
+ * `isSecondary` (which marks a canvas borrowing another's renderer).
544
+ */
545
+ sharedRendererFallback?: boolean
533
546
  /**
534
547
  * Function to unregister this primary canvas from the registry.
535
548
  * Only set when this canvas has an `id` prop.
@@ -660,9 +673,17 @@ type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>
660
673
  // to avoid bundling @types/react-reconciler which causes absolute path issues
661
674
  type FiberRoot = any
662
675
 
676
+ /** A promise tagged with its state, the protocol React's `use` reads */
677
+ type TrackedPromise<T> = Promise<T> &
678
+ ({ status: 'pending' } | { status: 'fulfilled'; value: T } | { status: 'rejected'; reason: unknown })
679
+
663
680
  interface Root {
664
681
  fiber: FiberRoot
665
682
  store: RootStore
683
+ /** Set while a teardown waits on React. Configure and render clear it, which cancels the teardown */
684
+ unmountClaim: symbol | null
685
+ /** Pending only while a renderer is being created */
686
+ ready: TrackedPromise<unknown>
666
687
  }
667
688
 
668
689
  type AttachFnType<O = any> = (parent: any, self: O) => () => void
@@ -772,7 +793,14 @@ declare function useStore(): RootStore;
772
793
  */
773
794
  declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
774
795
 
796
+ /**
797
+ * React context that carries the current root's {@link RootStore}. Each root provides its store and
798
+ * each portal provides its own scoped one; `useStore`, and every hook built on it, reads it.
799
+ *
800
+ * Stored on `globalThis` under `Symbol.for('@react-three/fiber.context')`, so every copy and entry
801
+ * of fiber shares a single context.
802
+ */
775
803
  declare const context: React.Context<RootStore>;
776
804
 
777
- export { useStore as ag, useThree as ah, context as ai, registerRootExtension as r, setRenderOverride as s };
778
- export type { EquConfig as $, AttachFnType as A, InstanceProps as B, ConstructorRepresentation as C, Dpr as D, Events as E, Frameloop as F, Instance as G, HostConfig as H, InternalState as I, Properties as J, IsOptional as K, IsAllOptional as L, Mutable as M, NonFunctionKeys as N, Overwrite as O, PointerState as P, ThreeCamera as Q, R3FRenderTarget as R, Subscription as S, ThreeEvent as T, Act as U, Viewport as V, Bridge as W, XRManager as X, SetBlock as Y, UnblockProps as Z, ObjectMap as _, RootExtension as a, Disposable as a0, FrameNextState as a1, FrameState as a2, FrameNextCallback as a3, FrameCallback as a4, ThreeNamespace as a5, ThreeCore as a6, OcclusionSupport as a7, WebGLSupport as a8, WebGPUSupport as a9, RendererSupport as aa, RendererProvider as ab, Register as ac, RegisteredRenderer as ad, ForRegisteredRenderer as ae, R3FRendererSupport as af, R3FRenderer as b, Size as c, RenderCallback as d, Performance as e, RootState as f, RootStore as g, Intersection as h, Camera as i, IntersectionEvent as j, DomEvent as k, EventHandlers as l, FilterFunction as m, ComputeFunction as n, XRPointerConfig as o, EventManager as p, PointerCaptureTarget as q, VisibilityEntry as t, FiberRoot as u, Root as v, AttachType as w, Catalogue as x, Args as y, ArgsProp as z };
805
+ export { useStore as ah, useThree as ai, context as aj, registerRootExtension as r, setRenderOverride as s };
806
+ export type { ObjectMap as $, AttachFnType as A, ArgsProp as B, ConstructorRepresentation as C, Dpr as D, Events as E, Frameloop as F, InstanceProps as G, Instance as H, InternalState as I, HostConfig as J, Properties as K, IsOptional as L, Mutable as M, NonFunctionKeys as N, Overwrite as O, PointerState as P, IsAllOptional as Q, R3FRenderTarget as R, Subscription as S, ThreeEvent as T, ThreeCamera as U, Viewport as V, Act as W, XRManager as X, Bridge as Y, SetBlock as Z, UnblockProps as _, RootExtension as a, EquConfig as a0, Disposable as a1, FrameNextState as a2, FrameState as a3, FrameNextCallback as a4, FrameCallback as a5, ThreeNamespace as a6, ThreeCore as a7, OcclusionSupport as a8, WebGLSupport as a9, WebGPUSupport as aa, RendererSupport as ab, RendererProvider as ac, Register as ad, RegisteredRenderer as ae, ForRegisteredRenderer as af, R3FRendererSupport as ag, R3FRenderer as b, Size as c, RenderCallback as d, Performance as e, RootState as f, RootStore as g, Intersection as h, Camera as i, IntersectionEvent as j, DomEvent as k, EventHandlers as l, FilterFunction as m, ComputeFunction as n, XRPointerConfig as o, EventManager as p, PointerCaptureTarget as q, VisibilityEntry as t, FiberRoot as u, TrackedPromise as v, Root as w, AttachType as x, Catalogue as y, Args as z };
@@ -477,6 +477,11 @@ interface InternalState {
477
477
  * Selected once, from the entry's provider, and copied into portals with the rest of `internal`.
478
478
  */
479
479
  support: R3FRendererSupport
480
+ /**
481
+ * Releases this root's lease on its renderer. The last release disposes a renderer R3F created;
482
+ * a renderer passed in as an instance is never disposed by R3F.
483
+ */
484
+ releaseRenderer?: () => void | Promise<void>
480
485
  /** Global scheduler reference (for useFrame hook) */
481
486
  scheduler: SchedulerApi | null
482
487
  /**
@@ -489,6 +494,8 @@ interface InternalState {
489
494
  rootId?: string
490
495
  /** Function to unregister this root from the global scheduler */
491
496
  unregisterRoot?: () => void
497
+ /** Function to stop following devicePixelRatio changes */
498
+ unwatchDpr?: () => void
492
499
  /** Container for child attachment (scene for root, original container for portals) */
493
500
  container?: THREE.Object3D
494
501
  /**
@@ -530,6 +537,12 @@ interface InternalState {
530
537
  * Only set when isSecondary is true.
531
538
  */
532
539
  targetId?: string
540
+ /**
541
+ * This secondary stopped sharing because the primary's renderer fell back to its
542
+ * WebGL2 backend (#3965): it owns the renderer it constructed, so it is not
543
+ * `isSecondary` (which marks a canvas borrowing another's renderer).
544
+ */
545
+ sharedRendererFallback?: boolean
533
546
  /**
534
547
  * Function to unregister this primary canvas from the registry.
535
548
  * Only set when this canvas has an `id` prop.
@@ -660,9 +673,17 @@ type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>
660
673
  // to avoid bundling @types/react-reconciler which causes absolute path issues
661
674
  type FiberRoot = any
662
675
 
676
+ /** A promise tagged with its state, the protocol React's `use` reads */
677
+ type TrackedPromise<T> = Promise<T> &
678
+ ({ status: 'pending' } | { status: 'fulfilled'; value: T } | { status: 'rejected'; reason: unknown })
679
+
663
680
  interface Root {
664
681
  fiber: FiberRoot
665
682
  store: RootStore
683
+ /** Set while a teardown waits on React. Configure and render clear it, which cancels the teardown */
684
+ unmountClaim: symbol | null
685
+ /** Pending only while a renderer is being created */
686
+ ready: TrackedPromise<unknown>
666
687
  }
667
688
 
668
689
  type AttachFnType<O = any> = (parent: any, self: O) => () => void
@@ -772,7 +793,14 @@ declare function useStore(): RootStore;
772
793
  */
773
794
  declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
774
795
 
796
+ /**
797
+ * React context that carries the current root's {@link RootStore}. Each root provides its store and
798
+ * each portal provides its own scoped one; `useStore`, and every hook built on it, reads it.
799
+ *
800
+ * Stored on `globalThis` under `Symbol.for('@react-three/fiber.context')`, so every copy and entry
801
+ * of fiber shares a single context.
802
+ */
775
803
  declare const context: React.Context<RootStore>;
776
804
 
777
- export { useStore as ag, useThree as ah, context as ai, registerRootExtension as r, setRenderOverride as s };
778
- export type { EquConfig as $, AttachFnType as A, InstanceProps as B, ConstructorRepresentation as C, Dpr as D, Events as E, Frameloop as F, Instance as G, HostConfig as H, InternalState as I, Properties as J, IsOptional as K, IsAllOptional as L, Mutable as M, NonFunctionKeys as N, Overwrite as O, PointerState as P, ThreeCamera as Q, R3FRenderTarget as R, Subscription as S, ThreeEvent as T, Act as U, Viewport as V, Bridge as W, XRManager as X, SetBlock as Y, UnblockProps as Z, ObjectMap as _, RootExtension as a, Disposable as a0, FrameNextState as a1, FrameState as a2, FrameNextCallback as a3, FrameCallback as a4, ThreeNamespace as a5, ThreeCore as a6, OcclusionSupport as a7, WebGLSupport as a8, WebGPUSupport as a9, RendererSupport as aa, RendererProvider as ab, Register as ac, RegisteredRenderer as ad, ForRegisteredRenderer as ae, R3FRendererSupport as af, R3FRenderer as b, Size as c, RenderCallback as d, Performance as e, RootState as f, RootStore as g, Intersection as h, Camera as i, IntersectionEvent as j, DomEvent as k, EventHandlers as l, FilterFunction as m, ComputeFunction as n, XRPointerConfig as o, EventManager as p, PointerCaptureTarget as q, VisibilityEntry as t, FiberRoot as u, Root as v, AttachType as w, Catalogue as x, Args as y, ArgsProp as z };
805
+ export { useStore as ah, useThree as ai, context as aj, registerRootExtension as r, setRenderOverride as s };
806
+ export type { ObjectMap as $, AttachFnType as A, ArgsProp as B, ConstructorRepresentation as C, Dpr as D, Events as E, Frameloop as F, InstanceProps as G, Instance as H, InternalState as I, HostConfig as J, Properties as K, IsOptional as L, Mutable as M, NonFunctionKeys as N, Overwrite as O, PointerState as P, IsAllOptional as Q, R3FRenderTarget as R, Subscription as S, ThreeEvent as T, ThreeCamera as U, Viewport as V, Act as W, XRManager as X, Bridge as Y, SetBlock as Z, UnblockProps as _, RootExtension as a, EquConfig as a0, Disposable as a1, FrameNextState as a2, FrameState as a3, FrameNextCallback as a4, FrameCallback as a5, ThreeNamespace as a6, ThreeCore as a7, OcclusionSupport as a8, WebGLSupport as a9, WebGPUSupport as aa, RendererSupport as ab, RendererProvider as ac, Register as ad, RegisteredRenderer as ae, ForRegisteredRenderer as af, R3FRendererSupport as ag, R3FRenderer as b, Size as c, RenderCallback as d, Performance as e, RootState as f, RootStore as g, Intersection as h, Camera as i, IntersectionEvent as j, DomEvent as k, EventHandlers as l, FilterFunction as m, ComputeFunction as n, XRPointerConfig as o, EventManager as p, PointerCaptureTarget as q, VisibilityEntry as t, FiberRoot as u, TrackedPromise as v, Root as w, AttachType as x, Catalogue as y, Args as z };
@@ -1,4 +1,4 @@
1
- import { a3 as FrameNextCallback } from './fiber.I5Q4dVvl.js';
1
+ import { a4 as FrameNextCallback } from './fiber.CLTHZhZp.js';
2
2
  import { UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
3
3
 
4
4
  /**
@@ -361,4 +361,4 @@ function notifyRootExtensionsHmr(store) {
361
361
  for (const setUpBy of applied.values()) current(registry, setUpBy).hmr?.(store);
362
362
  }
363
363
 
364
- export { Block as B, ErrorBoundary as E, useThree as a, useFrame as b, context as c, useIsomorphicLayoutEffect as d, useMutableCallback as e, useBridge as f, getTextureView as g, unstageTextures as h, stageTextures as i, detachRootExtensions as j, attachRootExtensions as k, notifyAlpha as l, notifyRootExtensionsHmr as m, notifyDepreciated as n, registerRootExtension as r, setRenderOverride as s, useStore as u };
364
+ export { Block as B, ErrorBoundary as E, useThree as a, useFrame as b, context as c, useIsomorphicLayoutEffect as d, useMutableCallback as e, useBridge as f, getTextureView as g, unstageTextures as h, stageTextures as i, attachRootExtensions as j, detachRootExtensions as k, notifyAlpha as l, notifyRootExtensionsHmr as m, notifyDepreciated as n, registerRootExtension as r, setRenderOverride as s, useStore as u };
@@ -1,4 +1,4 @@
1
- import { a3 as FrameNextCallback } from './fiber.I5Q4dVvl.mjs';
1
+ import { a4 as FrameNextCallback } from './fiber.CLTHZhZp.mjs';
2
2
  import { UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
3
3
 
4
4
  /**